6502-OS/spicode.s65

137 lines
2.0 KiB
Plaintext
Raw Normal View History

2023-12-08 22:56:35 +01:00
.include "system.h65"
2023-12-16 02:41:19 +01:00
.include "string.h65"
2023-12-08 22:56:35 +01:00
.include "lcd.h65"
.include "math.h65"
2023-12-09 23:33:42 +01:00
.include "keypad.h65"
2024-01-09 02:30:01 +01:00
.include "ps2_keyboard_text_handler.h65"
2023-12-16 02:41:19 +01:00
.include "chars.h65"
2024-01-02 23:37:07 +01:00
.include "parity.h65"
.include "sleep.h65"
2023-12-16 02:41:19 +01:00
.import homeloop:absolute
2023-12-08 22:56:35 +01:00
.import home:absolute
2024-01-09 02:30:01 +01:00
.import ps2_keyboard_util:absolute
.import ps2_keyboard_printer:absolute
2023-12-20 12:27:54 +01:00
2023-12-08 22:56:35 +01:00
.segment "SPI"
.export CODE_START
2023-12-20 12:27:54 +01:00
.import memcopy
2023-12-08 22:56:35 +01:00
CODE_START:
2023-12-09 23:33:42 +01:00
.assert * = $5000, error, "SPI Code not at $5000"
2023-12-16 02:41:19 +01:00
jsr lcd::clear
2023-12-31 01:59:06 +01:00
DEBUG_LED_OFF 0
DEBUG_LED_OFF 1
DEBUG_LED_OFF 2
2023-12-20 12:27:54 +01:00
2023-12-09 23:33:42 +01:00
stz kp::_DEBUG_VAL
2024-01-09 02:30:01 +01:00
lda #'$'
jsr lcd::print_char
2023-12-09 23:33:42 +01:00
@loop:
2023-12-31 01:59:06 +01:00
wai
@read_keypad:
2023-12-09 23:33:42 +01:00
lda kp::_DEBUG_VAL
2023-12-31 01:59:06 +01:00
jeq @loop
2024-01-09 02:30:01 +01:00
2023-12-16 02:41:19 +01:00
cmp #'*'
jeq homeloop
2024-01-09 02:30:01 +01:00
cmp #'0'
beq @l0
2023-12-20 12:27:54 +01:00
cmp #'1'
beq @l1
cmp #'2'
beq @l2
cmp #'3'
beq @l3
2024-01-09 02:30:01 +01:00
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
2023-12-20 12:27:54 +01:00
cmp #'A'
beq @lA
2023-12-22 12:10:54 +01:00
cmp #'B'
beq @lB
cmp #'C'
beq @lC
2024-01-02 23:37:07 +01:00
cmp #'D'
beq @lD
2023-12-20 12:27:54 +01:00
jsr lcd::print_char
2023-12-31 01:59:06 +01:00
jmp @loop
2024-01-09 02:30:01 +01:00
@l0:
jmp ps2_keyboard_util
2023-12-20 12:27:54 +01:00
@l1:
2024-01-09 02:30:01 +01:00
jmp _ps2_keyboard_printer
2023-12-20 12:27:54 +01:00
@l2:
@l3:
2024-01-09 02:30:01 +01:00
@l4:
@l5:
@l6:
@l7:
@l8:
@l9:
@lhash:
2023-12-20 12:27:54 +01:00
@lA:
2023-12-22 12:10:54 +01:00
@lB:
@lC:
2024-01-02 23:37:07 +01:00
@lD:
jmp @loop
2023-12-20 12:27:54 +01:00
2024-01-09 02:30:01 +01:00
.proc _ps2_keyboard_printer
jsr lcd::clear
jsr kb::init
jeq loop
ps2kb_PrintCmdFailed
; jmp homeloop
ps2kb_CmdEnable
jsr ps2kb::begin_receive
2023-12-31 01:59:06 +01:00
2024-01-02 23:37:07 +01:00
2024-01-09 02:30:01 +01:00
loop:
2024-01-11 20:51:45 +01:00
wai
; put shift, ralt and lalt in debug leds
lda kb::modifier
Reverse A
and #%00000111
ora IO1 + IO::RANH
sta IO1 + IO::RANH
2024-01-09 02:30:01 +01:00
lda kb::char
beq @no_char
stz kb::char
2024-01-02 23:37:07 +01:00
jsr lcd::print_char
2024-01-09 02:30:01 +01:00
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
2024-01-02 23:37:07 +01:00
.endproc
2024-01-09 02:30:01 +01:00
.byte '@'
out_str: .res 40
FMT_INIT_FAIL: .asciiz "KB init failed: %x%x > %x%x%x"