6502-OS/spicode.s65

110 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

;;********************************************************************************
;; @file
2024-08-08 20:39:25 +02:00
;; @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
;;********************************************************************************
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-08-08 20:15:50 +02:00
jmp ps2_keyboard_printer
2023-12-20 12:27:54 +01:00
@l2:
lcd_SetCursorPos $26
lda #'6'
jsr lcd::print_char
lcd_IncrementCursor
lda #'8'
jsr lcd::print_char
2023-12-20 12:27:54 +01:00
@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-02 23:37:07 +01:00
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"