summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.asm14
-rw-r--r--ports.asm25
-rw-r--r--video.asm21
-rw-r--r--video.c78
4 files changed, 99 insertions, 39 deletions
diff --git a/main.asm b/main.asm
index 26aea4b..d91cde0 100644
--- a/main.asm
+++ b/main.asm
@@ -43,7 +43,7 @@
xdef _ti89
; xdef _ti92plus
- xdef _main
+ xdef __main
xdef _nostub
include "../tios.h"
@@ -218,25 +218,15 @@ F_DEC_W MACRO
;; I might be able to unify rotation flags or maybe use a
;; lookup table
-;;; one-off flag operations:
-;;; CCF - invert CARRY
-;;; CPL - H,N=1
-;;; RLD
-;;;
-
-
-
-
-_main:
+__main:
movem.l d0-d7/a0-a6,-(sp)
bsr emu_setup
movem.l (sp)+,d0-d7/a0-a6
rts
include "ports.asm"
- include "video.asm"
include "interrupts.asm"
include "flags.asm"
diff --git a/ports.asm b/ports.asm
index 056cd82..32a4a94 100644
--- a/ports.asm
+++ b/ports.asm
@@ -562,13 +562,23 @@ port_out_0e:
port_in_0f:
port_out_0f:
port_in_10:
+ xref video_row
+ xref video_increment
+ xref video_enabled
+ xref video_6bit
+ xref video_busy
+ xref video_cur_row
+ xref video_cur_col
+ xref video_write
+ xref video_read
+
;; LCD status
clr.b d1
- or.b video_increment(pc),d1
- or.b video_row(pc),d1
- or.b video_enabled(pc),d1
- or.b video_6bit(pc),d1
- or.b video_busy(pc),d1
+ or.b video_increment,d1
+ or.b video_row,d1
+ or.b video_enabled,d1
+ or.b video_6bit,d1
+ or.b video_busy,d1
rts
port_out_10:
@@ -653,10 +663,13 @@ port_out_10_set_row:
port_in_11:
;; LCD data
- bra video_read
+ jsr video_read
+ move.b d0,d1 ; return value
+ rts
port_out_11:
;; LCD data
+ move.b d1,(a7)+
bra video_write
port_in_12:
diff --git a/video.asm b/video.asm
deleted file mode 100644
index b47d06c..0000000
--- a/video.asm
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-video_row: dc.b 0 ; $01 if in row mode - x
- ; $00 if in column mode - y
-video_increment: dc.b 0 ; $02 if in increment mode
- ; $00 if in decrement mode
-video_enabled: dc.b 0 ; $20 if screen is blanked
-video_6bit: dc.b 0 ; $40 if in 8 bit mode, $00 if in 6
- ; bit mode
-video_busy: dc.b 0 ; always 0
-
-video_cur_row: dc.b 0
-video_cur_col: dc.b 0
-
- EVEN
-
-video_read:
- rts
-
-video_write:
- rts
diff --git a/video.c b/video.c
new file mode 100644
index 0000000..ee53ea4
--- /dev/null
+++ b/video.c
@@ -0,0 +1,78 @@
+/* LCD controller driver for 680 project.
+ *
+ * Copyright 2010, Duncan Smith
+ * GPL
+ */
+
+#include <graph.h>
+#include <nostub.h>
+
+#define VIDEO_ROWMODE 0x01
+#define VIDEO_COLMODE 0x00
+char video_row;
+
+#define VIDEO_AUTOINC 0x02
+#define VIDEO_AUTODEC 0x00
+char video_increment;
+
+#define VIDEO_ENABLED 0x00
+#define VIDEO_DISABLED 0x20
+char video_enabled;
+
+#define VIDEO_6BIT 0x00
+#define VIDEO_8BIT 0x40
+char video_6bit;
+
+char video_busy; // Always 0
+
+char video_cur_row;
+char video_cur_col;
+
+void video_write(char);
+char video_read(void);
+void *video_compute_address(void);
+int video_compute_shift(void);
+
+void video_write(char data)
+{
+ int shift = video_compute_shift();
+ short int data_mask = ~(0xff00 >> shift);
+ short int data_dat = data >> (shift-8);
+ void *addr = video_compute_address();
+ *((short int *)addr) &= data_mask;
+ *((short int *)addr) |= data_dat;
+ return;
+}
+
+char video_read(void)
+{
+ int shift = video_compute_shift();
+ void *addr = video_compute_address();
+ short int data = *((short int *)addr);
+ data <<= (shift-8);
+ data &= 0xff;
+ return;
+}
+
+void *video_compute_address()
+{
+ void *addr;
+ int off;
+
+ addr = LCD_MEM;
+ addr += (video_cur_row) * (240 / 8);
+
+ if (video_6bit == VIDEO_6BIT)
+ off = video_cur_col * 6 / 8;
+ else
+ off = video_cur_col;
+ return addr + off;
+}
+
+int video_compute_shift()
+{
+ if (video_6bit == VIDEO_8BIT)
+ return 0;
+
+ return (video_cur_col * 6) % 8;
+}