From ff387a8918ccffbc6415ce947a4328b9bf9e20cd Mon Sep 17 00:00:00 2001 From: geijoenr Date: Mon, 16 Mar 2015 20:19:01 +0000 Subject: [PATCH] msx2: add new vdp driver based on v99xx 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 | 4 +- Kernel/platform-msx2/bootrom.s | 6 --- Kernel/platform-msx2/devtty.c | 10 ++-- Kernel/platform-msx2/fuzix.lnk | 1 + Kernel/platform-msx2/msx2.s | 14 +++--- Kernel/platform-msx2/vdp.c | 89 ++++++++++++++++++++++++++++++++++ Kernel/platform-msx2/vdp.s | 17 ------- 7 files changed, 104 insertions(+), 37 deletions(-) create mode 100644 Kernel/platform-msx2/vdp.c delete mode 100644 Kernel/platform-msx2/vdp.s diff --git a/Kernel/platform-msx2/Makefile b/Kernel/platform-msx2/Makefile index 22f28ca9..8ee6e7f8 100644 --- a/Kernel/platform-msx2/Makefile +++ b/Kernel/platform-msx2/Makefile @@ -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/ diff --git a/Kernel/platform-msx2/bootrom.s b/Kernel/platform-msx2/bootrom.s index 0a9a10c8..2849c7d7 100644 --- a/Kernel/platform-msx2/bootrom.s +++ b/Kernel/platform-msx2/bootrom.s @@ -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 ; diff --git a/Kernel/platform-msx2/devtty.c b/Kernel/platform-msx2/devtty.c index e0b754bd..11b801a0 100644 --- a/Kernel/platform-msx2/devtty.c +++ b/Kernel/platform-msx2/devtty.c @@ -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() diff --git a/Kernel/platform-msx2/fuzix.lnk b/Kernel/platform-msx2/fuzix.lnk index ff81d2c2..fec52a01 100644 --- a/Kernel/platform-msx2/fuzix.lnk +++ b/Kernel/platform-msx2/fuzix.lnk @@ -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 diff --git a/Kernel/platform-msx2/msx2.s b/Kernel/platform-msx2/msx2.s index b5e78710..a1326d78 100644 --- a/Kernel/platform-msx2/msx2.s +++ b/Kernel/platform-msx2/msx2.s @@ -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 index 00000000..ec900ff9 --- /dev/null +++ b/Kernel/platform-msx2/vdp.c @@ -0,0 +1,89 @@ +/* + * TEXT2 mode VT + */ + +#include +#include +#include + +/* 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 index baedb782..00000000 --- a/Kernel/platform-msx2/vdp.s +++ /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 -- 2.34.1