msx2: add new vdp driver based on v99xx
authorgeijoenr <enric.geijo@gmail.com>
Mon, 16 Mar 2015 20:19:01 +0000 (20:19 +0000)
committergeijoenr <enric.geijo@gmail.com>
Mon, 16 Mar 2015 20:32:47 +0000 (20:32 +0000)
with this don't need the bios anymore to initialize
the vdp, and have more flexibility to later implement
multiple VT.

Kernel/platform-msx2/Makefile
Kernel/platform-msx2/bootrom.s
Kernel/platform-msx2/devtty.c
Kernel/platform-msx2/fuzix.lnk
Kernel/platform-msx2/msx2.s
Kernel/platform-msx2/vdp.c [new file with mode: 0644]
Kernel/platform-msx2/vdp.s [deleted file]

index 22f28ca..8ee6e7f 100644 (file)
@@ -1,11 +1,11 @@
 
 CSRCS = ../dev/devsd.c ../dev/mbr.c ../dev/blkdev.c
 CSRCS += devfd.c devhd.c devlpr.c
-CSRCS += devices.c main.c devtty.c ../dev/rp5c01.c devrtc.c
+CSRCS += devices.c main.c devtty.c ../dev/rp5c01.c devrtc.c ../dev/v99xx.c vdp.c
 COMMON_CSRCS = devmegasd.c
 DISCARD_CSRCS = discard.c
 DISCARD_DSRCS = ../dev/devsd_discard.c
-ASRCS = msx2.s crt0.s vdp.s
+ASRCS = msx2.s crt0.s
 ASRCS += tricks.s commonmem.s bootrom.s
 
 CROSS_CCOPTS += -I../dev/
index 0a9a10c..2849c7d 100644 (file)
@@ -31,12 +31,6 @@ bootstrap:
                ld  a,#0x81                 ; run only in rom mode, as we do not use BIOS better save 4 ram pages
                call z,#BIOS_CHGCPU
 
-               ; FIXME: init vdp using bios so that font is in place after vdpinit
-               ld a,#0x50
-               ld (0xf3ae),a
-               ld ix,#0x00d5
-               call #0x015f
-
                ;
                ; set ram in slot_page 2
                ;
index e0b754b..11b801a 100644 (file)
@@ -46,11 +46,9 @@ ttyready_t tty_writeready(uint8_t minor)
 void tty_putc(uint8_t minor, unsigned char c)
 {
        minor;
-//
-//     if (minor == 1) {
-               vtoutput(&c, 1);
-//             return;
-//     }
+
+       vtoutput(&c, 1);
+
        tty_debug2 = c;
 }
 
@@ -134,7 +132,7 @@ static void keydecode(void)
 
        /* TODO: function keys (F1-F10), graph, code */
 
-       tty_inproc(1, c);
+       vt_inproc(1, c);
 }
 
 void update_keyboard()
index ff81d2c..fec52a0 100644 (file)
@@ -44,4 +44,5 @@ platform-msx2/devmegasd.rel
 platform-msx2/mbr.rel
 platform-msx2/devrtc.rel
 platform-msx2/rp5c01.rel
+platform-msx2/v99xx.rel
 -e
index b5e7871..a1326d7 100644 (file)
@@ -8,6 +8,7 @@
             .globl init_early
             .globl init_hardware
             .globl interrupt_handler
+           .globl platform_interrupt_all
             .globl _program_vectors
            .globl map_kernel
            .globl map_process
@@ -50,7 +51,7 @@
            ;
            ; vdp - we must initialize this bit early for the vt
            ;
-           .globl vdpinit
+           .globl _vdpinit
 
             .include "kernel.def"
             .include "../kernel.def"
@@ -103,11 +104,7 @@ init_hardware:
            ld a, #'Z'
            out (0x2F), a
 
-           ; Program the video engine
-           ; FIXME:  disable for now and initalize in bootstrap using the bios
-           ;         current implementation only works when booting from msx-dos
-           ;         because font data is wiped from vram on mode change
-           ; call vdpinit
+           call _vdpinit
 
            ld a, #'I'
            out (0x2F), a
@@ -125,6 +122,11 @@ init_hardware:
 
             .area _COMMONMEM
 
+platform_interrupt_all:
+           ld bc,(_vdpport)
+           in a, (c)
+           ret
+
 _program_vectors:
             ; we are called, with interrupts disabled, by both newproc() and crt0
            ; will exit with interrupts off
diff --git a/Kernel/platform-msx2/vdp.c b/Kernel/platform-msx2/vdp.c
new file mode 100644 (file)
index 0000000..ec900ff
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * TEXT2 mode VT
+ */
+
+#include <kernel.h>
+#include <vt.h>
+#include <v99xx.h>
+
+/* TODO: extend to support multiple VT (or scrollable history)
+ * possible to keep up to 31 pages in VRAM */
+#define VT_BASE 0x0000
+#define VT_BASE_FONT 0x1000
+#define VT_BASE_BLINK 0x800
+#define VT_BUFSIZE 80
+
+extern void *fontdata_6x8;
+
+static uint8_t vt_buff[VT_BUFSIZE];
+static uint16_t cur_blink_addr = 0;
+
+void vdpinit()
+{
+    v99xx_set_mode(MODE_TEXT2);
+    v99xx_set_color(15, 4);
+    v99xx_copy_to_vram(VT_BASE_FONT + 32*8, (uint8_t *)&fontdata_6x8, 768);
+    v99xx_set_blink_color(15, 8);
+    v99xx_set_blink_period(4, 4);
+}
+
+void clear_lines(int8_t y, int8_t ct)
+{
+    uint16_t addr;
+
+    addr = VT_BASE + y * VT_WIDTH;
+    v99xx_memset_vram(addr, ' ',  ct * VT_WIDTH);
+}
+
+void clear_across(int8_t y, int8_t x, int16_t l)
+{
+    uint16_t addr;
+
+    addr = VT_BASE + y * VT_WIDTH + x;
+    v99xx_memset_vram(addr, ' ', l);
+}
+
+void cursor_off(void)
+{
+    v99xx_write_vram(cur_blink_addr, 0);
+}
+
+void cursor_on(int8_t y, int8_t x)
+{
+    uint16_t blink_addr;
+    uint8_t bit;
+
+    blink_addr = VT_BASE_BLINK + y * 10 + (x >> 3);
+    bit = 7 - (x & 0x7);
+
+    v99xx_write_vram(blink_addr, 1 << bit);
+    cur_blink_addr = blink_addr;
+}
+
+void memcpy_vram(uint16_t dst, uint16_t src, uint16_t size)
+{
+    uint16_t i;
+
+    for (i = 0; i < size; i += VT_BUFSIZE) {
+       v99xx_copy_from_vram(vt_buff, src + i, VT_BUFSIZE);
+       v99xx_copy_to_vram(dst + i, vt_buff, VT_BUFSIZE);
+    }
+}
+
+void scroll_up(void)
+{
+    memcpy_vram(VT_BASE, VT_WIDTH, VT_WIDTH * VT_BOTTOM);
+}
+
+void scroll_down(void)
+{
+    memcpy_vram(VT_WIDTH, VT_BASE, VT_WIDTH * VT_BOTTOM);
+}
+
+void plot_char(int8_t y, int8_t x, uint16_t c)
+{
+    uint16_t addr;
+
+    addr = VT_BASE + y * VT_WIDTH + x;
+    v99xx_write_vram(addr, c);
+}
diff --git a/Kernel/platform-msx2/vdp.s b/Kernel/platform-msx2/vdp.s
deleted file mode 100644 (file)
index baedb78..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-            .module vdp
-
-            .include "kernel.def"
-            .include "../kernel.def"
-
-           .include "../dev/vdp2.s"
-
-           .area _COMMONMEM
-
-;
-;      FIXME: should use vdpport, but right now vdpport is in data not
-;      common space.
-;
-platform_interrupt_all:
-           ld c, #0x99
-           in a, (c)
-           ret