Compare commits
4 Commits
9a1324a29a
...
2c41506765
Author | SHA1 | Date | |
---|---|---|---|
2c41506765 | |||
e9c9f978a2 | |||
151e57e9be | |||
3c09810aa8 |
@ -23,8 +23,8 @@ status_str: .res 17 ; 16 + null
|
|||||||
Print MENU
|
Print MENU
|
||||||
@print_status:
|
@print_status:
|
||||||
Strf FMT_STATUS,status_str,trans_pages,trans_bytes,status
|
Strf FMT_STATUS,status_str,trans_pages,trans_bytes,status
|
||||||
lda #(lcd::CMD_SET_ADDRESS | lcd::LINE4)
|
lda #lcd::LINE4
|
||||||
jsr lcd::_cmd
|
jsr lcd::set_position
|
||||||
Print status_str
|
Print status_str
|
||||||
@loop:
|
@loop:
|
||||||
; check if a byte has been transferred
|
; check if a byte has been transferred
|
||||||
@ -39,11 +39,11 @@ status_str: .res 17 ; 16 + null
|
|||||||
bra @read_keypad
|
bra @read_keypad
|
||||||
@byte_written:
|
@byte_written:
|
||||||
sta trans_bytes
|
sta trans_bytes
|
||||||
bra @print_status
|
; bra @print_status
|
||||||
|
bra @read_keypad
|
||||||
@page_written:
|
@page_written:
|
||||||
sta trans_pages
|
sta trans_pages
|
||||||
bra @print_status
|
bra @print_status
|
||||||
|
|
||||||
@read_keypad:
|
@read_keypad:
|
||||||
lda kp::_DEBUG_VAL
|
lda kp::_DEBUG_VAL
|
||||||
beq @loop
|
beq @loop
|
||||||
|
99
spicode.s65
99
spicode.s65
@ -1,12 +1,13 @@
|
|||||||
.include "system.h65"
|
.include "system.h65"
|
||||||
.include "lcd.h65"
|
.include "lcd.h65"
|
||||||
.include "math.h65"
|
.include "math.h65"
|
||||||
|
.include "keypad.h65"
|
||||||
.import home:absolute
|
.import home:absolute
|
||||||
.segment "SPI"
|
.segment "SPI"
|
||||||
.export CODE_START
|
.export CODE_START
|
||||||
|
|
||||||
Export
|
|
||||||
CODE_START:
|
CODE_START:
|
||||||
|
.assert * = $5000, error, "SPI Code not at $5000"
|
||||||
lda '$'
|
lda '$'
|
||||||
jsr lcd::print_char
|
jsr lcd::print_char
|
||||||
lda #<TEST_FMT
|
lda #<TEST_FMT
|
||||||
@ -25,45 +26,17 @@ CODE_START:
|
|||||||
sta ARG6
|
sta ARG6
|
||||||
jsr strf
|
jsr strf
|
||||||
Print TEST_OUT
|
Print TEST_OUT
|
||||||
@spiloop:
|
stz kp::_DEBUG_VAL
|
||||||
bbs4 ASDA,dasdZQ
|
@loop:
|
||||||
lda IO1 + IO::RA
|
lda kp::_DEBUG_VAL
|
||||||
lda IO2 + IO::RA
|
jeq home
|
||||||
jeq @spiloop
|
bra @loop
|
||||||
bge @spiloop
|
|
||||||
nop
|
|
||||||
bra @spiloop
|
|
||||||
bro @spiloop
|
|
||||||
jmp home
|
|
||||||
lda €asdaasd
|
|
||||||
lda €$ff
|
|
||||||
lds €asda
|
|
||||||
|
|
||||||
lds #($ff | asd)
|
|
||||||
lda #'c'
|
|
||||||
lda #(jk:)
|
|
||||||
|
|
||||||
|
|
||||||
; TODO allocate zp memory
|
|
||||||
fmt_idx = $30
|
fmt_idx = $30
|
||||||
out_idx = $31
|
out_idx = $31
|
||||||
;********************************************************************************
|
|
||||||
; @function Format a string
|
|
||||||
; @details
|
|
||||||
; If there is no value to be read, the Pz will be set
|
|
||||||
; Formats:
|
|
||||||
; - u: unsigned decimal integer (1 byte)
|
|
||||||
; - U: unsigned decimal integer (2 bytes)
|
|
||||||
; @param ARG0-1: Format string address
|
|
||||||
; @param ARG2-3: Output string address
|
|
||||||
; @param ARG4+: Additional parameters
|
|
||||||
; @returns
|
|
||||||
; @modifies: A, Y
|
|
||||||
;********************************************************************************
|
|
||||||
.proc strf
|
.proc strf
|
||||||
stz out_idx
|
stz out_idx
|
||||||
stz fmt_idx
|
stz fmt_idx
|
||||||
ldy #0 ; position in string
|
|
||||||
ldx #0 ; index of format args
|
ldx #0 ; index of format args
|
||||||
@loop:
|
@loop:
|
||||||
ldy fmt_idx
|
ldy fmt_idx
|
||||||
@ -81,7 +54,7 @@ out_idx = $31
|
|||||||
@percent: ; check for format in next position
|
@percent: ; check for format in next position
|
||||||
iny
|
iny
|
||||||
sty fmt_idx
|
sty fmt_idx
|
||||||
lda (ARG0),y
|
lda (ARG0),y ; next char
|
||||||
beq @null
|
beq @null
|
||||||
; formats
|
; formats
|
||||||
cmp #'x'
|
cmp #'x'
|
||||||
@ -124,26 +97,68 @@ out_idx = $31
|
|||||||
; @param A: Number to convert
|
; @param A: Number to convert
|
||||||
; @returns A: Most significant digit
|
; @returns A: Most significant digit
|
||||||
; @returns X: Least significant digit
|
; @returns X: Least significant digit
|
||||||
; @modifies X,Y,A
|
; @modifies A,X,Y
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
.proc int8_to_hex_str
|
.proc int8_to_hex_str
|
||||||
pha
|
pha
|
||||||
and #%00001111
|
and #%00001111
|
||||||
tay
|
tay
|
||||||
ldx HEX_CHARS,y
|
ldx HEX_CHARS_UPPER,y
|
||||||
pla
|
pla
|
||||||
div A,16
|
div A,16
|
||||||
and #%00001111
|
and #%00001111
|
||||||
tay
|
tay
|
||||||
lda HEX_CHARS,y
|
lda HEX_CHARS_UPPER,y
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HEX_CHARS: .byte "0123456789ABCDEF"
|
;********************************************************************************
|
||||||
|
; @function Convert any int into hex
|
||||||
|
; @param ARG2-3: Address of output string
|
||||||
|
; @param Y: Offset onto output string
|
||||||
|
; @param A: Number of digits to convert
|
||||||
|
; @param X: Offset onto ARG4 = start of int (big endian)
|
||||||
|
; @returns Y: New offset onto output string
|
||||||
|
; @returns A: 0
|
||||||
|
; @returns X: Offset onto ARG4 = past the end of number
|
||||||
|
; @modifies X,Y,A
|
||||||
|
;********************************************************************************
|
||||||
|
.proc int_to_hex_str
|
||||||
|
cmp #0
|
||||||
|
@loop:
|
||||||
|
beq @rts ; check done
|
||||||
|
; load next byte
|
||||||
|
pha
|
||||||
|
lda ARG4,x
|
||||||
|
inx
|
||||||
|
phx
|
||||||
|
pha ; copy byte
|
||||||
|
div A,16 ; get first 4 bits = first digit
|
||||||
|
and #%00001111
|
||||||
|
phy
|
||||||
|
tay
|
||||||
|
lda HEX_CHARS_LOWER,y
|
||||||
|
ply
|
||||||
|
sta (ARG2),y
|
||||||
|
iny
|
||||||
|
pla ; get copy
|
||||||
|
and #%00001111 ; lower 4 bits = second digit
|
||||||
|
phy
|
||||||
|
tay
|
||||||
|
lda HEX_CHARS_LOWER,y
|
||||||
|
ply
|
||||||
|
sta (ARG2),y
|
||||||
|
iny
|
||||||
|
plx
|
||||||
|
pla
|
||||||
|
dec
|
||||||
|
@rts:
|
||||||
|
rts
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
TEST_FMT: .asciiz "%x -> %x -> %x:)"
|
TEST_FMT: .asciiz "%x -> %x -> %x:)"
|
||||||
TEST_OUT: .asciiz "TESTOUT"
|
TEST_OUT: .asciiz "TESTOUT"
|
||||||
|
HEX_CHARS_UPPER: .byte "0123456789ABCDEF"
|
||||||
|
HEX_CHARS_LOWER: .byte "0123456789abcdef"
|
||||||
|
@ -20,7 +20,7 @@ INCLUDE_LCD = 1
|
|||||||
|
|
||||||
.scope lcd
|
.scope lcd
|
||||||
LCD_IO = IO1
|
LCD_IO = IO1
|
||||||
Import lcd,init,clear,print,print_char,_cmd
|
Import lcd,init,clear,print,print_char,set_position
|
||||||
|
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
; @macro Print a null-terminated string
|
; @macro Print a null-terminated string
|
||||||
|
@ -152,14 +152,33 @@ charcount: .res 1
|
|||||||
;; @returns A: the cursor position
|
;; @returns A: the cursor position
|
||||||
;;********************************************************************************
|
;;********************************************************************************
|
||||||
.proc set_position
|
.proc set_position
|
||||||
cmp #$40
|
|
||||||
bge @invalid
|
|
||||||
sta charcount
|
|
||||||
pha
|
pha
|
||||||
|
cmp #$60
|
||||||
|
bge @invalid
|
||||||
|
cmp #$50
|
||||||
|
bge @line4
|
||||||
|
cmp #$40
|
||||||
|
bge @line2
|
||||||
|
cmp #$20
|
||||||
|
bge @invalid
|
||||||
|
cmp #$10
|
||||||
|
bge @line3
|
||||||
|
bra @set
|
||||||
|
; @line1: ; starts at $00, charcount at $00
|
||||||
|
@line2: ; starts at $40, charcount at $10
|
||||||
|
sbc #$30 ; carry is already set
|
||||||
|
bra @set
|
||||||
|
@line3: ; starts at $10, charcount at $20
|
||||||
|
add #$10
|
||||||
|
bra @set
|
||||||
|
@line4: ; starts at $50, charcount at $30
|
||||||
|
sbc #$20
|
||||||
|
@set:
|
||||||
|
sta charcount
|
||||||
|
pla
|
||||||
ora #lcd::CMD_SET_ADDRESS
|
ora #lcd::CMD_SET_ADDRESS
|
||||||
jsr _cmd
|
jsr _cmd
|
||||||
pla
|
and #(<~lcd::CMD_SET_ADDRESS) ; return original argument
|
||||||
@rts:
|
|
||||||
rts
|
rts
|
||||||
@invalid:
|
@invalid:
|
||||||
lda $14
|
lda $14
|
||||||
@ -167,7 +186,7 @@ charcount: .res 1
|
|||||||
lda #(lcd::CMD_SET_ADDRESS | (lcd::LINE2 + 4))
|
lda #(lcd::CMD_SET_ADDRESS | (lcd::LINE2 + 4))
|
||||||
jsr _cmd
|
jsr _cmd
|
||||||
lda #(lcd::LINE2 + 4)
|
lda #(lcd::LINE2 + 4)
|
||||||
bra @rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user