mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-26 07:38:06 +11:00
Compare commits
No commits in common. "6c1b1f2b79827b1e0d6b7498ab3d3085256cb9b0" and "8d5c26f299a1f092215b1bb6e1d32cbef1aa95de" have entirely different histories.
6c1b1f2b79
...
8d5c26f299
@ -5,24 +5,8 @@
|
|||||||
; *** Constants ***
|
; *** Constants ***
|
||||||
.equ KBD_PORT 0x01
|
.equ KBD_PORT 0x01
|
||||||
|
|
||||||
; Keys that have a special meaning in GetC. All >= 0x80. They are interpreted
|
|
||||||
; by GetC directly and are never returned as-is.
|
|
||||||
.equ KBD_KEY_ALPHA 0x80
|
|
||||||
.equ KBD_KEY_2ND 0x81
|
|
||||||
|
|
||||||
; *** Variables ***
|
|
||||||
; active long-term modifiers, such as a-lock
|
|
||||||
; bit 0: A-Lock
|
|
||||||
.equ KBD_MODS KBD_RAMSTART
|
|
||||||
.equ KBD_RAMEND @+1
|
|
||||||
|
|
||||||
; *** Code ***
|
; *** Code ***
|
||||||
|
|
||||||
kbdInit:
|
|
||||||
xor a
|
|
||||||
ld (KBD_MODS), a
|
|
||||||
ret
|
|
||||||
|
|
||||||
; Wait for a digit to be pressed and sets the A register ASCII value
|
; Wait for a digit to be pressed and sets the A register ASCII value
|
||||||
; corresponding to that key press.
|
; corresponding to that key press.
|
||||||
;
|
;
|
||||||
@ -40,14 +24,8 @@ kbdGetC:
|
|||||||
push bc
|
push bc
|
||||||
push hl
|
push hl
|
||||||
|
|
||||||
; During this GetC loop, register C holds the modificators
|
; During this GetC loop, register C holds the modificators (Alpha, 2nd)
|
||||||
; bit 0: Alpha
|
ld c, 0
|
||||||
; bit 1: 2nd
|
|
||||||
; Initial value should be zero, but if A-Lock is on, it's 1
|
|
||||||
ld a, (KBD_MODS)
|
|
||||||
and 1
|
|
||||||
ld c, a
|
|
||||||
|
|
||||||
; loop until a digit is pressed
|
; loop until a digit is pressed
|
||||||
.loop:
|
.loop:
|
||||||
ld hl, .dtbl
|
ld hl, .dtbl
|
||||||
@ -82,29 +60,22 @@ kbdGetC:
|
|||||||
ld a, (hl)
|
ld a, (hl)
|
||||||
or a ; is char 0?
|
or a ; is char 0?
|
||||||
jr z, .loop ; yes? unsupported. loop.
|
jr z, .loop ; yes? unsupported. loop.
|
||||||
call .debounce
|
cp 0x80 ; is it alpha?
|
||||||
cp KBD_KEY_ALPHA
|
jr nz, .notalpha
|
||||||
jr c, .end ; A < 0x80? valid char, return it.
|
|
||||||
jr z, .handleAlpha
|
|
||||||
cp KBD_KEY_2ND
|
|
||||||
jr z, .handle2nd
|
|
||||||
jp .loop
|
|
||||||
.handleAlpha:
|
|
||||||
set 0, c
|
set 0, c
|
||||||
bit 1, c ; 2nd set?
|
jr .loop
|
||||||
jp z, .loop ; unset? loop
|
.notalpha:
|
||||||
; we've just hit Alpha with 2nd set. Toggle A-Lock and set Alpha to
|
|
||||||
; the value A-Lock has.
|
; wait until all keys are de-pressed
|
||||||
ld a, (KBD_MODS)
|
push af ; --> lvl 1
|
||||||
xor 1
|
.wait:
|
||||||
ld (KBD_MODS), a
|
xor a
|
||||||
ld c, a
|
call .get
|
||||||
jp .loop
|
inc a ; if a was 0xff, will become 0 (nz test)
|
||||||
.handle2nd:
|
jr nz, .wait ; non-zero? something is pressed
|
||||||
set 1, c
|
|
||||||
jp .loop
|
pop af ; <-- lvl 1
|
||||||
|
|
||||||
.end:
|
|
||||||
pop hl
|
pop hl
|
||||||
pop bc
|
pop bc
|
||||||
ret
|
ret
|
||||||
@ -118,28 +89,18 @@ kbdGetC:
|
|||||||
in a, (KBD_PORT)
|
in a, (KBD_PORT)
|
||||||
ei
|
ei
|
||||||
ret
|
ret
|
||||||
.debounce:
|
|
||||||
; wait until all keys are de-pressed
|
|
||||||
push af ; --> lvl 1
|
|
||||||
.wait:
|
|
||||||
xor a
|
|
||||||
call .get
|
|
||||||
inc a ; if a was 0xff, will become 0 (nz test)
|
|
||||||
jr nz, .wait ; non-zero? something is pressed
|
|
||||||
|
|
||||||
pop af ; <-- lvl 1
|
|
||||||
ret
|
|
||||||
|
|
||||||
; digits table. each row represents a group. first item is group mask.
|
; digits table. each row represents a group. first item is group mask.
|
||||||
; 0 means unsupported. no group 7 because it has no keys.
|
; 0 means unsupported. no group 7 because it has no keys.
|
||||||
|
; 0x80 is a special value for ALPHA key which is never returned directly.
|
||||||
.dtbl:
|
.dtbl:
|
||||||
.db 0xfe, 0, 0, 0, 0, 0, 0, 0, 0
|
.db 0xfe, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
.db 0xfd, 0x0d, '+' ,'-' ,'*', '/', '^', 0, 0
|
.db 0xfd, 0x0d, '+' ,'-' ,'*', '/', '^', 0, 0
|
||||||
.db 0xfb, 0, '3', '6', '9', ')', 0, 0, 0
|
.db 0xfb, 0, '3', '6', '9', ')', 0, 0, 0
|
||||||
.db 0xf7, '.', '2', '5', '8', '(', 0, 0, 0
|
.db 0xf7, '.', '2', '5', '8', '(', 0, 0, 0
|
||||||
.db 0xef, '0', '1', '4', '7', ',', 0, 0, 0
|
.db 0xef, '0', '1', '4', '7', ',', 0, 0, 0
|
||||||
.db 0xdf, 0, 0, 0, 0, 0, 0, 0, KBD_KEY_ALPHA
|
.db 0xdf, 0, 0, 0, 0, 0, 0, 0, 0x80
|
||||||
.db 0xbf, 0, 0, 0, 0, 0, KBD_KEY_2ND, 0, 0x7f
|
.db 0xbf, 0, 0, 0, 0, 0, 0, 0, 0x7f
|
||||||
|
|
||||||
; alpha table. same as .dtbl, for when we're in alpha mode.
|
; alpha table. same as .dtbl, for when we're in alpha mode.
|
||||||
.atbl:
|
.atbl:
|
||||||
@ -148,5 +109,5 @@ kbdGetC:
|
|||||||
.db 0xfb, '?', 0, 'V', 'Q', 'L', 'G', 0, 0
|
.db 0xfb, '?', 0, 'V', 'Q', 'L', 'G', 0, 0
|
||||||
.db 0xf7, ':', 'Z', 'U', 'P', 'K', 'F', 'C', 0
|
.db 0xf7, ':', 'Z', 'U', 'P', 'K', 'F', 'C', 0
|
||||||
.db 0xef, '_', 'Y', 'T', 'O', 'J', 'E', 'B', 0
|
.db 0xef, '_', 'Y', 'T', 'O', 'J', 'E', 'B', 0
|
||||||
.db 0xdf, 0, 'X', 'S', 'N', 'I', 'D', 'A', KBD_KEY_ALPHA
|
.db 0xdf, 0, 'X', 'S', 'N', 'I', 'D', 'A', 0x80
|
||||||
.db 0xbf, 0, 0, 0, 0, 0, KBD_KEY_2ND, 0, 0x7f
|
.db 0xbf, 0, 0, 0, 0, 0, 0, 0, 0x7f
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
; Current row being written on. In terms of pixels, not of glyphs. During a
|
; Current row being written on. In terms of pixels, not of glyphs. During a
|
||||||
; linefeed, this increases by FNT_HEIGHT+1.
|
; linefeed, this increases by FNT_HEIGHT+1.
|
||||||
.equ LCD_CURROW LCD_RAMSTART
|
.equ LCD_CURROW LCD_RAMSTART
|
||||||
; Current column
|
|
||||||
.equ LCD_CURCOL @+1
|
|
||||||
.equ LCD_RAMEND @+1
|
.equ LCD_RAMEND @+1
|
||||||
|
|
||||||
; *** Code ***
|
; *** Code ***
|
||||||
@ -36,34 +34,36 @@ lcdInit:
|
|||||||
; Initialize variables
|
; Initialize variables
|
||||||
xor a
|
xor a
|
||||||
ld (LCD_CURROW), a
|
ld (LCD_CURROW), a
|
||||||
ld (LCD_CURCOL), a
|
|
||||||
|
|
||||||
; Clear screen
|
|
||||||
call lcdClrScr
|
|
||||||
|
|
||||||
; Enable the LCD
|
; Enable the LCD
|
||||||
ld a, LCD_CMD_ENABLE
|
ld a, LCD_CMD_ENABLE
|
||||||
call lcdCmd
|
call lcdWait
|
||||||
|
out (LCD_PORT_CMD), a
|
||||||
|
|
||||||
; Hack to get LCD to work. According to WikiTI, we're to sure why TIOS
|
; Hack to get LCD to work. According to WikiTI, we're to sure why TIOS
|
||||||
; sends these, but it sends it, and it is required to make the LCD
|
; sends these, but it sends it, and it is required to make the LCD
|
||||||
; work. So...
|
; work. So...
|
||||||
ld a, 0x17
|
ld a, 0x17
|
||||||
call lcdCmd
|
call lcdWait
|
||||||
|
out (LCD_PORT_CMD), a
|
||||||
ld a, 0x0b
|
ld a, 0x0b
|
||||||
call lcdCmd
|
call lcdWait
|
||||||
|
out (LCD_PORT_CMD), a
|
||||||
|
|
||||||
; Set some usable contrast
|
; Set some usable contrast
|
||||||
ld a, LCD_CMD_CONTRAST+0x34
|
ld a, LCD_CMD_CONTRAST+0x34
|
||||||
call lcdCmd
|
call lcdWait
|
||||||
|
out (LCD_PORT_CMD), a
|
||||||
|
|
||||||
; Enable 6-bit mode.
|
; Enable 6-bit mode.
|
||||||
ld a, LCD_CMD_6BIT
|
ld a, LCD_CMD_6BIT
|
||||||
call lcdCmd
|
call lcdWait
|
||||||
|
out (LCD_PORT_CMD), a
|
||||||
|
|
||||||
; Enable X-increment mode
|
; Enable X-increment mode
|
||||||
ld a, LCD_CMD_XINC
|
ld a, LCD_CMD_XINC
|
||||||
call lcdCmd
|
call lcdWait
|
||||||
|
out (LCD_PORT_CMD), a
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -78,23 +78,11 @@ lcdWait:
|
|||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Send cmd A to LCD
|
|
||||||
lcdCmd:
|
|
||||||
out (LCD_PORT_CMD), a
|
|
||||||
jr lcdWait
|
|
||||||
|
|
||||||
; Send data A to LCD
|
|
||||||
lcdData:
|
|
||||||
out (LCD_PORT_DATA), a
|
|
||||||
jr lcdWait
|
|
||||||
|
|
||||||
; Turn LCD off
|
; Turn LCD off
|
||||||
lcdOff:
|
lcdOff:
|
||||||
push af
|
|
||||||
ld a, LCD_CMD_DISABLE
|
ld a, LCD_CMD_DISABLE
|
||||||
call lcdCmd
|
call lcdWait
|
||||||
out (LCD_PORT_CMD), a
|
out (LCD_PORT_CMD), a
|
||||||
pop af
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Set LCD's current column to A
|
; Set LCD's current column to A
|
||||||
@ -102,7 +90,8 @@ lcdSetCol:
|
|||||||
push af
|
push af
|
||||||
; The col index specified in A is compounded with LCD_CMD_COL
|
; The col index specified in A is compounded with LCD_CMD_COL
|
||||||
add a, LCD_CMD_COL
|
add a, LCD_CMD_COL
|
||||||
call lcdCmd
|
call lcdWait
|
||||||
|
out (LCD_PORT_CMD), a
|
||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -111,7 +100,8 @@ lcdSetRow:
|
|||||||
push af
|
push af
|
||||||
; The col index specified in A is compounded with LCD_CMD_COL
|
; The col index specified in A is compounded with LCD_CMD_COL
|
||||||
add a, LCD_CMD_ROW
|
add a, LCD_CMD_ROW
|
||||||
call lcdCmd
|
call lcdWait
|
||||||
|
out (LCD_PORT_CMD), a
|
||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -125,23 +115,32 @@ lcdSendGlyph:
|
|||||||
|
|
||||||
ld a, (LCD_CURROW)
|
ld a, (LCD_CURROW)
|
||||||
call lcdSetRow
|
call lcdSetRow
|
||||||
ld a, (LCD_CURCOL)
|
|
||||||
call lcdSetCol
|
|
||||||
|
|
||||||
; let's increase (and wrap) col now
|
ld b, 7
|
||||||
inc a
|
|
||||||
ld (LCD_CURCOL), a
|
|
||||||
cp 16
|
|
||||||
jr nz, .skip
|
|
||||||
call lcdLinefeed
|
|
||||||
.skip:
|
|
||||||
ld b, FNT_HEIGHT
|
|
||||||
.loop:
|
.loop:
|
||||||
ld a, (hl)
|
ld a, (hl)
|
||||||
inc hl
|
inc hl
|
||||||
call lcdData
|
call lcdWait
|
||||||
|
out (LCD_PORT_DATA), a
|
||||||
djnz .loop
|
djnz .loop
|
||||||
|
|
||||||
|
; Now that we've sent our 7 rows of pixels, let's go in "Y-increment"
|
||||||
|
; mode to let the LCD increase by one column after we've sent our 8th
|
||||||
|
; line, which is blank (padding).
|
||||||
|
ld a, LCD_CMD_YINC
|
||||||
|
call lcdWait
|
||||||
|
out (LCD_PORT_CMD), a
|
||||||
|
|
||||||
|
; send blank line
|
||||||
|
xor a
|
||||||
|
call lcdWait
|
||||||
|
out (LCD_PORT_DATA), a
|
||||||
|
|
||||||
|
; go back in X-increment mode
|
||||||
|
ld a, LCD_CMD_XINC
|
||||||
|
call lcdWait
|
||||||
|
out (LCD_PORT_CMD), a
|
||||||
|
|
||||||
pop hl
|
pop hl
|
||||||
pop bc
|
pop bc
|
||||||
pop af
|
pop af
|
||||||
@ -154,53 +153,10 @@ lcdLinefeed:
|
|||||||
add a, FNT_HEIGHT+1
|
add a, FNT_HEIGHT+1
|
||||||
ld (LCD_CURROW), a
|
ld (LCD_CURROW), a
|
||||||
xor a
|
xor a
|
||||||
ld (LCD_CURCOL), a
|
|
||||||
pop af
|
|
||||||
ret
|
|
||||||
|
|
||||||
; Clears B rows starting at row A
|
|
||||||
; The LCD will then be set back at row A, column 0
|
|
||||||
; B is not preserved by this routine
|
|
||||||
lcdClrX:
|
|
||||||
push af
|
|
||||||
call lcdSetRow
|
|
||||||
ld a, LCD_CMD_8BIT
|
|
||||||
call lcdCmd
|
|
||||||
.outer:
|
|
||||||
push bc ; --> lvl 1
|
|
||||||
ld b, 11
|
|
||||||
ld a, LCD_CMD_YINC
|
|
||||||
call lcdCmd
|
|
||||||
xor a
|
|
||||||
call lcdSetCol
|
call lcdSetCol
|
||||||
.inner:
|
|
||||||
call lcdData
|
|
||||||
djnz .inner
|
|
||||||
ld a, LCD_CMD_XINC
|
|
||||||
call lcdCmd
|
|
||||||
xor a
|
|
||||||
call lcdData
|
|
||||||
pop bc ; <-- lvl 1
|
|
||||||
djnz .outer
|
|
||||||
ld a, LCD_CMD_6BIT
|
|
||||||
call lcdCmd
|
|
||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
lcdClrLn:
|
|
||||||
push bc
|
|
||||||
ld b, FNT_HEIGHT+1
|
|
||||||
call lcdClrX
|
|
||||||
pop bc
|
|
||||||
ret
|
|
||||||
|
|
||||||
lcdClrScr:
|
|
||||||
push bc
|
|
||||||
ld b, 64
|
|
||||||
call lcdClrX
|
|
||||||
pop bc
|
|
||||||
ret
|
|
||||||
|
|
||||||
lcdPutC:
|
lcdPutC:
|
||||||
cp ASCII_LF
|
cp ASCII_LF
|
||||||
jp z, lcdLinefeed
|
jp z, lcdLinefeed
|
||||||
|
@ -28,9 +28,8 @@
|
|||||||
.inc "fnt/mgm.asm"
|
.inc "fnt/mgm.asm"
|
||||||
.equ LCD_RAMSTART RAMSTART
|
.equ LCD_RAMSTART RAMSTART
|
||||||
.inc "ti/lcd.asm"
|
.inc "ti/lcd.asm"
|
||||||
.equ KBD_RAMSTART LCD_RAMEND
|
|
||||||
.inc "ti/kbd.asm"
|
.inc "ti/kbd.asm"
|
||||||
.equ STDIO_RAMSTART KBD_RAMEND
|
.equ STDIO_RAMSTART LCD_RAMEND
|
||||||
.equ STDIO_GETC kbdGetC
|
.equ STDIO_GETC kbdGetC
|
||||||
.equ STDIO_PUTC lcdPutC
|
.equ STDIO_PUTC lcdPutC
|
||||||
.inc "stdio.asm"
|
.inc "stdio.asm"
|
||||||
@ -61,7 +60,6 @@ boot:
|
|||||||
halt
|
halt
|
||||||
|
|
||||||
main:
|
main:
|
||||||
call kbdInit
|
|
||||||
call lcdInit
|
call lcdInit
|
||||||
xor a
|
xor a
|
||||||
call lcdSetCol
|
call lcdSetCol
|
||||||
|
Loading…
Reference in New Issue
Block a user