150 lines
2.4 KiB
Plaintext
150 lines
2.4 KiB
Plaintext
;;********************************************************************************
|
|
;; @file
|
|
;; @details:
|
|
;; This code is loaded to the computer via a SPI interface
|
|
;; Currently, it must be loaded to $5000, where the main loop will begin
|
|
;;********************************************************************************
|
|
|
|
.include "system.h65"
|
|
.include "string.h65"
|
|
.include "lcd.h65"
|
|
.include "math.h65"
|
|
.include "keypad.h65"
|
|
.include "ps2_keyboard_text_handler.h65"
|
|
.include "chars.h65"
|
|
.include "parity.h65"
|
|
.include "sleep.h65"
|
|
.import homeloop:absolute
|
|
.import home:absolute
|
|
.import ps2_keyboard_util:absolute
|
|
.import ps2_keyboard_printer:absolute
|
|
|
|
.segment "SPI"
|
|
.export CODE_START
|
|
|
|
.import memcopy
|
|
|
|
|
|
|
|
CODE_START:
|
|
.assert * = $5000, error, "SPI Code not at $5000"
|
|
jsr lcd::clear
|
|
DEBUG_LED_OFF 0
|
|
DEBUG_LED_OFF 1
|
|
DEBUG_LED_OFF 2
|
|
|
|
stz kp::_DEBUG_VAL
|
|
lda #'$'
|
|
jsr lcd::print_char
|
|
@loop:
|
|
wai
|
|
@read_keypad:
|
|
lda kp::_DEBUG_VAL
|
|
jeq @loop
|
|
|
|
cmp #'*'
|
|
jeq homeloop
|
|
cmp #'0'
|
|
beq @l0
|
|
cmp #'1'
|
|
beq @l1
|
|
cmp #'2'
|
|
beq @l2
|
|
cmp #'3'
|
|
beq @l3
|
|
cmp #'4'
|
|
beq @l4
|
|
cmp #'5'
|
|
beq @l5
|
|
cmp #'6'
|
|
beq @l6
|
|
cmp #'7'
|
|
beq @l7
|
|
cmp #'8'
|
|
beq @l8
|
|
cmp #'9'
|
|
beq @l9
|
|
cmp #'#'
|
|
beq @lhash
|
|
cmp #'A'
|
|
beq @lA
|
|
cmp #'B'
|
|
beq @lB
|
|
cmp #'C'
|
|
beq @lC
|
|
cmp #'D'
|
|
beq @lD
|
|
jsr lcd::print_char
|
|
jmp @loop
|
|
@l0:
|
|
jmp ps2_keyboard_util
|
|
@l1:
|
|
jmp _ps2_keyboard_printer
|
|
@l2:
|
|
lcd_SetCursorPos $26
|
|
lda #'6'
|
|
jsr lcd::print_char
|
|
lcd_IncrementCursor
|
|
lda #'8'
|
|
jsr lcd::print_char
|
|
@l3:
|
|
@l4:
|
|
@l5:
|
|
@l6:
|
|
@l7:
|
|
@l8:
|
|
@l9:
|
|
@lhash:
|
|
@lA:
|
|
@lB:
|
|
@lC:
|
|
@lD:
|
|
jmp @loop
|
|
|
|
.proc _ps2_keyboard_printer
|
|
jsr lcd::clear
|
|
jsr kb::init
|
|
jeq loop
|
|
ps2kb_PrintCmdFailed
|
|
; jmp homeloop
|
|
ps2kb_CmdEnable
|
|
jsr ps2kb::begin_receive
|
|
|
|
|
|
loop:
|
|
wai
|
|
; put shift, ralt and lalt in debug leds
|
|
lda kb::modifier
|
|
Reverse A
|
|
and #%00000111
|
|
ora IO1 + IO::RANH
|
|
sta IO1 + IO::RANH
|
|
lda kb::char
|
|
beq @no_char
|
|
stz kb::char
|
|
jsr lcd::print_char
|
|
bra loop
|
|
@no_char:
|
|
lda kb::keycode
|
|
beq loop
|
|
stz kb::keycode
|
|
cmp #kb::K::ESCAPE
|
|
beq @esacpe
|
|
cmp #kb::K::PRINT
|
|
beq @clear_display
|
|
cmp #kb::K::F12
|
|
jeq _ps2_keyboard_printer
|
|
bra loop
|
|
@esacpe:
|
|
jmp home
|
|
@clear_display:
|
|
jsr lcd::clear
|
|
bra loop
|
|
.endproc
|
|
|
|
|
|
|
|
.byte '@'
|
|
out_str: .res 40
|
|
FMT_INIT_FAIL: .asciiz "KB init failed: %x%x > %x%x%x"
|