Compare commits

..

No commits in common. "2c41506765c4cce75bc633b6848ef96cb214ba06" and "9a1324a29a64b0afe8f64dbd29949b5aab8e4581" have entirely different histories.

4 changed files with 51 additions and 85 deletions

View File

@ -23,8 +23,8 @@ status_str: .res 17 ; 16 + null
Print MENU
@print_status:
Strf FMT_STATUS,status_str,trans_pages,trans_bytes,status
lda #lcd::LINE4
jsr lcd::set_position
lda #(lcd::CMD_SET_ADDRESS | lcd::LINE4)
jsr lcd::_cmd
Print status_str
@loop:
; check if a byte has been transferred
@ -39,11 +39,11 @@ status_str: .res 17 ; 16 + null
bra @read_keypad
@byte_written:
sta trans_bytes
; bra @print_status
bra @read_keypad
bra @print_status
@page_written:
sta trans_pages
bra @print_status
@read_keypad:
lda kp::_DEBUG_VAL
beq @loop

View File

@ -1,13 +1,12 @@
.include "system.h65"
.include "lcd.h65"
.include "math.h65"
.include "keypad.h65"
.import home:absolute
.segment "SPI"
.export CODE_START
Export
CODE_START:
.assert * = $5000, error, "SPI Code not at $5000"
lda '$'
jsr lcd::print_char
lda #<TEST_FMT
@ -26,17 +25,45 @@ CODE_START:
sta ARG6
jsr strf
Print TEST_OUT
stz kp::_DEBUG_VAL
@loop:
lda kp::_DEBUG_VAL
jeq home
bra @loop
@spiloop:
bbs4 ASDA,dasdZQ
lda IO1 + IO::RA
lda IO2 + IO::RA
jeq @spiloop
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
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
stz out_idx
stz fmt_idx
ldy #0 ; position in string
ldx #0 ; index of format args
@loop:
ldy fmt_idx
@ -54,7 +81,7 @@ out_idx = $31
@percent: ; check for format in next position
iny
sty fmt_idx
lda (ARG0),y ; next char
lda (ARG0),y
beq @null
; formats
cmp #'x'
@ -97,68 +124,26 @@ out_idx = $31
; @param A: Number to convert
; @returns A: Most significant digit
; @returns X: Least significant digit
; @modifies A,X,Y
; @modifies X,Y,A
;********************************************************************************
.proc int8_to_hex_str
pha
and #%00001111
tay
ldx HEX_CHARS_UPPER,y
ldx HEX_CHARS,y
pla
div A,16
and #%00001111
tay
lda HEX_CHARS_UPPER,y
lda HEX_CHARS,y
rts
.endproc
;********************************************************************************
; @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
HEX_CHARS: .byte "0123456789ABCDEF"
TEST_FMT: .asciiz "%x -> %x -> %x:)"
TEST_OUT: .asciiz "TESTOUT"
HEX_CHARS_UPPER: .byte "0123456789ABCDEF"
HEX_CHARS_LOWER: .byte "0123456789abcdef"

View File

@ -20,7 +20,7 @@ INCLUDE_LCD = 1
.scope lcd
LCD_IO = IO1
Import lcd,init,clear,print,print_char,set_position
Import lcd,init,clear,print,print_char,_cmd
;********************************************************************************
; @macro Print a null-terminated string

View File

@ -152,33 +152,14 @@ charcount: .res 1
;; @returns A: the cursor position
;;********************************************************************************
.proc set_position
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
pha
ora #lcd::CMD_SET_ADDRESS
jsr _cmd
and #(<~lcd::CMD_SET_ADDRESS) ; return original argument
pla
@rts:
rts
@invalid:
lda $14
@ -186,7 +167,7 @@ charcount: .res 1
lda #(lcd::CMD_SET_ADDRESS | (lcd::LINE2 + 4))
jsr _cmd
lda #(lcd::LINE2 + 4)
rts
bra @rts
.endproc