From ab6a141805f5d5b255f195908d9be329e6e771dd Mon Sep 17 00:00:00 2001 From: Tormod Volden Date: Mon, 7 Jan 2019 22:53:05 +0100 Subject: [PATCH] dragon-mooh: Remaining assembly VT routines for vc Use own vc.c version calling the assembly routines Signed-off-by: Tormod Volden --- Kernel/platform-dragon-mooh/vc.c | 65 ++++++++++++++++++++++++++++ Kernel/platform-dragon-mooh/vc_asm.h | 9 ++++ Kernel/platform-dragon-mooh/vc_asm.s | 61 ++++++++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 Kernel/platform-dragon-mooh/vc.c create mode 100644 Kernel/platform-dragon-mooh/vc_asm.h diff --git a/Kernel/platform-dragon-mooh/vc.c b/Kernel/platform-dragon-mooh/vc.c new file mode 100644 index 00000000..03f6cc5b --- /dev/null +++ b/Kernel/platform-dragon-mooh/vc.c @@ -0,0 +1,65 @@ +#include +#include +#include + +#include +#include "vc_asm.h" + +unsigned char vt_mangle_6847(unsigned char c); + +/* Use macros so that functions are kept identical to Kernel/vt.c */ +#undef VT_MAP_CHAR +#define VT_MAP_CHAR(x) vt_mangle_6847(x) +#define VT_BASE ((uint8_t *) VC_BASE + 0x200 * (curtty - 2)) +#define VT_WIDTH 32 +#define VC (curtty - 2) + +static unsigned char *cpos[2]; +static unsigned char csave[2]; + +static uint8_t *char_addr(uint8_t y1, uint8_t x1) +{ + return VT_BASE + VT_WIDTH * y1 + x1; +} + +void vc_cursor_off(void) +{ + if (cpos[VC]) + vc_write_char(cpos[VC], csave[VC]); +} + +void vc_cursor_on(int8_t y, int8_t x) +{ + cpos[VC] = char_addr(y, x); + csave[VC] = vc_read_char(cpos[VC]); + vc_write_char(cpos[VC], 0x80); /* black square */ +} + +void vc_plot_char(int8_t y, int8_t x, uint16_t c) +{ + vc_write_char(char_addr(y, x), VT_MAP_CHAR(c)); +} + +void vc_clear_lines(int8_t y, int8_t ct) +{ + unsigned char *s = char_addr(y, 0); + vc_memset(s, ' ', ct * VT_WIDTH); +} + +void vc_clear_across(int8_t y, int8_t x, int16_t l) +{ + unsigned char *s = char_addr(y, x); + vc_memset(s, ' ', l); +} + +void vc_vtattr_notify(void) +{ +} + +unsigned char vt_mangle_6847(unsigned char c) +{ + if (c >= 96) + c -= 32; + c &= 0x3F; + return c; +} diff --git a/Kernel/platform-dragon-mooh/vc_asm.h b/Kernel/platform-dragon-mooh/vc_asm.h new file mode 100644 index 00000000..ffa86883 --- /dev/null +++ b/Kernel/platform-dragon-mooh/vc_asm.h @@ -0,0 +1,9 @@ + +void vc_clear(int8_t); +void vc_memset(unsigned char *, char, uint16_t); + +void vc_write_char(char *, char); +char vc_read_char(char *); + +void vc_scroll_up(void); +void vc_scroll_down(void); diff --git a/Kernel/platform-dragon-mooh/vc_asm.s b/Kernel/platform-dragon-mooh/vc_asm.s index 58b9e517..94de388b 100644 --- a/Kernel/platform-dragon-mooh/vc_asm.s +++ b/Kernel/platform-dragon-mooh/vc_asm.s @@ -7,6 +7,11 @@ .globl _set_vid_mode .globl _set_vc_mode .globl _vc_clear + .globl _vc_write_char + .globl _vc_read_char + .globl _vc_memset + .globl _vc_scroll_up + .globl _vc_scroll_down include "kernel.def" @@ -50,3 +55,59 @@ cllp std ,x++ leas 2,s jmp _unmap_video +_vc_write_char: + jsr _map_video + stb ,x + jmp _unmap_video + +_vc_read_char: + jsr _map_video + ldb ,x + jmp _unmap_video + +vtbase lda _curtty + deca + deca + asla + clrb + ldx #VC_BASE + leax d,x + leay 512,x + rts + +_vc_scroll_up: + pshs y,x ; x: make space for end address + jsr vtbase + sty ,s + leay 32,x + jsr _map_video +scup ldd ,y++ + std ,x++ + cmpx ,s + blo scup + jsr _unmap_video + puls y,x,pc + +_vc_scroll_down: + pshs y,x + jsr vtbase + stx ,s + leax -32,y + jsr _map_video +scdn ldd ,--x + std ,--y + cmpx ,s + bhi scdn + jsr _unmap_video + puls y,x,pc + +_vc_memset: + pshs y + ldy 4,s + jsr _map_video +vcms stb ,x+ + leay -1,y + bne vcms + jsr _unmap_video + puls y,pc + -- 2.34.1