6502-OS/spicode.s65

110 lines
1.7 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
.byte '@'
out_str: .res 40
FMT_INIT_FAIL: .asciiz "KB init failed: %x%x > %x%x%x"