nascom: commit the vt work in progress ready for 0.2
authorAlan Cox <alan@linux.intel.com>
Sun, 2 Sep 2018 20:58:21 +0000 (21:58 +0100)
committerAlan Cox <alan@linux.intel.com>
Sun, 2 Sep 2018 20:58:21 +0000 (21:58 +0100)
Kernel/platform-nascom/nascom-vt.s [new file with mode: 0644]

diff --git a/Kernel/platform-nascom/nascom-vt.s b/Kernel/platform-nascom/nascom-vt.s
new file mode 100644 (file)
index 0000000..f2ca50c
--- /dev/null
@@ -0,0 +1,162 @@
+;
+;      The Nascom has a fairly simple default video console except
+;      that each line has margins of space that are used for other
+;      stuff
+;
+               .module nascom-vt
+
+
+               .globl _cursor_off
+               .globl _cursor_disable
+               .globl _cursor_on
+               .globl _plot_char
+               .globl _clear_lines
+               .globl _clear_across
+               .globl _vtattr_notify
+               .globl _scroll_up
+               .globl _scroll_down
+
+
+               .area _CODE
+;
+;      Required to preserve BC
+;
+addr:          
+               ld a,e          ; get Y
+               dec a           ; weird line wrapping
+               and #15
+               add a,a
+               add a,a
+               add a,a
+               add a,a         ; x16: as far as we can 8bit add
+               ld l,a
+               ld h,#0
+               ld e,d
+               ld d,h          ; DE is now 00xx where xx is the X value
+               add hl,hl       ; x 32
+               add hl,hl       ; x 64
+               ld de,#0xF800
+               add hl,de
+               ret
+
+_cursor_off:
+               ld hl,(cpos)
+               bit 7,h         ; all valid cpos values are > 0x8000
+               ret z
+               ld a,(csave)
+               ld (hl),a
+               xor a
+               ld (cpos+1),a
+_cursor_disable:
+               ret
+
+_cursor_on:
+               pop hl
+               pop de
+               push de
+               push hl
+               call addr
+               ld a,(hl)
+               ld (hl),#'_;
+               ld (csave),a
+               ld (cpos),hl
+               ret
+
+_plot_char:
+               pop hl
+               pop de
+               pop bc
+               push bc
+               push de
+               push hl
+               ld (hl),c
+               ret
+
+;
+;      The weird layout means we can't do a single ldir
+;
+_clear_lines:
+               pop hl
+               pop de
+               push de         ; E = Y D = count
+               push hl
+               ld c,d
+               ld d,#0
+wipenext:
+               push de
+               call addr
+               xor a
+wipeline:
+               ld b,#48
+wiper:         ld (hl),#' '
+               inc hl
+               djnz wiper
+               pop de
+               inc e
+               dec d
+               jr nz, wipenext
+               ret
+
+_clear_across:
+               pop hl
+               pop de          ; E = y D = x
+               pop bc          ; C = count
+               push bc
+               push de
+               push hl
+               call addr
+               ld a,#' '
+               ld b,c
+clear2:                ld (hl),a
+               inc hl
+               djnz clear2
+_vtattr_notify:
+               ret
+
+_scroll_up:
+               ; Do the special case first
+               ld hl,#0xF80A
+               ld de,#0xFBCA
+               ld bc,#48
+               ldir
+               ld de,#0xF80A
+               ld hl,#0xF84A
+               ; BC is always 0 here
+               ld a,#15
+nextup:
+               ld c,#48
+               ldir
+               ld c,#16
+               add hl,bc
+               ex de,hl
+               add hl,bc
+               ex de,hl
+               pop bc
+               dec a
+               jr nz,nextup
+               ret
+
+_scroll_down:
+               ld hl,#0xFB79
+               ld de,#0xFBB9
+               ld a,#15
+nextdown:
+               ld bc,#48
+               lddr
+               ld bc,#0xFFF0           ; - 16
+               add hl,bc
+               ex de,hl
+               add hl,bc
+               ex de,hl
+               dec a
+               jr nz, nextdown
+               ; Top line special case
+               ld hl,#0xFBC0
+               ld de,#0xF800
+               ld bc,#48
+               ldir
+               ret
+
+               .area _DATA
+csave:         .byte 0
+cpos:          .word 0