6502-OS/programs/spi-menu.s65

93 lines
1.7 KiB
Plaintext
Raw Normal View History

2023-12-08 22:56:35 +01:00
.include "spi.h65"
.include "string.h65"
.include "keypad.h65"
.include "lcd.h65"
2023-12-16 02:41:19 +01:00
.include "chars.h65"
2023-12-08 22:56:35 +01:00
.import home:absolute
.import SPI_IO
2023-12-08 00:13:02 +01:00
2023-12-08 22:56:35 +01:00
.export spi_menu
2023-12-08 00:13:02 +01:00
.bss
trans_bytes: .res 1
trans_pages: .res 1
status: .res 1
status_str: .res 17 ; 16 + null
.code
.proc spi_menu
stz trans_bytes
stz trans_pages
lda #'X'
sta status
@print_menu:
2023-12-08 22:56:35 +01:00
jsr lcd::clear
2023-12-08 00:13:02 +01:00
Print MENU
@print_status:
2023-12-09 23:32:43 +01:00
lda #lcd::LINE4
jsr lcd::set_position
2023-12-16 02:41:19 +01:00
Strf FMT_STATUS,status_str,trans_pages,trans_bytes,status
PrintNC status_str
2023-12-08 00:13:02 +01:00
@loop:
; check if a byte has been transferred
@check_byte:
lda spi_p::bytes_written
cmp trans_bytes
bne @byte_written
@check_page:
lda spi_p::pages_written
cmp trans_pages
bne @page_written
bra @read_keypad
@byte_written:
sta trans_bytes
2023-12-09 23:32:43 +01:00
; bra @print_status
bra @read_keypad
2023-12-08 00:13:02 +01:00
@page_written:
sta trans_pages
bra @print_status
@read_keypad:
2023-12-08 22:56:35 +01:00
lda kp::_DEBUG_VAL
2023-12-08 00:13:02 +01:00
beq @loop
; TODO debug
sta 0
2023-12-08 22:56:35 +01:00
stz kp::_DEBUG_VAL
2023-12-08 00:13:02 +01:00
lda 0
cmp #'*'
beq @return_home
cmp #'A'
beq @spi_begin
cmp #'B'
beq @spi_end
cmp #'C'
beq @spi_jump
bra @loop
@spi_begin:
lda #'@'
sta status
jsr spi_p::begin
jmp @print_menu
@spi_end:
lda #'X'
sta status
jsr spi_p::end
jmp @print_menu
@spi_jump:
jsr spi_p::end
2023-12-08 22:56:35 +01:00
jsr lcd::clear
2023-12-08 00:13:02 +01:00
Print START
2023-12-08 22:56:35 +01:00
jmp spi_p::CODE_START
2023-12-08 00:13:02 +01:00
@return_home:
jsr spi_p::end
jmp home
.endproc
.rodata
MENU:
2023-12-16 02:41:19 +01:00
.byte chars::DOT, "A Beg. Transfer"
2023-12-08 00:13:02 +01:00
.byte "B> Stop Transfer"
.asciiz "C> Jump Home <*"
; .asciiz "0b0p Status: X"
FMT_STATUS: .asciiz "%x%xb Status:%x"
BEGIN: .asciiz "---BEGIN SPI---"
START: .asciiz "---START SPI---"