Compare commits
No commits in common. "2c41506765c4cce75bc633b6848ef96cb214ba06" and "9a1324a29a64b0afe8f64dbd29949b5aab8e4581" have entirely different histories.
2c41506765
...
9a1324a29a
@ -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::LINE4
|
lda #(lcd::CMD_SET_ADDRESS | lcd::LINE4)
|
||||||
jsr lcd::set_position
|
jsr lcd::_cmd
|
||||||
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
|
||||||
|
97
spicode.s65
97
spicode.s65
@ -1,13 +1,12 @@
|
|||||||
.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
|
||||||
@ -26,17 +25,45 @@ CODE_START:
|
|||||||
sta ARG6
|
sta ARG6
|
||||||
jsr strf
|
jsr strf
|
||||||
Print TEST_OUT
|
Print TEST_OUT
|
||||||
stz kp::_DEBUG_VAL
|
@spiloop:
|
||||||
@loop:
|
bbs4 ASDA,dasdZQ
|
||||||
lda kp::_DEBUG_VAL
|
lda IO1 + IO::RA
|
||||||
jeq home
|
lda IO2 + IO::RA
|
||||||
bra @loop
|
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
|
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
|
||||||
@ -54,7 +81,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 ; next char
|
lda (ARG0),y
|
||||||
beq @null
|
beq @null
|
||||||
; formats
|
; formats
|
||||||
cmp #'x'
|
cmp #'x'
|
||||||
@ -97,68 +124,26 @@ 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 A,X,Y
|
; @modifies X,Y,A
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
.proc int8_to_hex_str
|
.proc int8_to_hex_str
|
||||||
pha
|
pha
|
||||||
and #%00001111
|
and #%00001111
|
||||||
tay
|
tay
|
||||||
ldx HEX_CHARS_UPPER,y
|
ldx HEX_CHARS,y
|
||||||
pla
|
pla
|
||||||
div A,16
|
div A,16
|
||||||
and #%00001111
|
and #%00001111
|
||||||
tay
|
tay
|
||||||
lda HEX_CHARS_UPPER,y
|
lda HEX_CHARS,y
|
||||||
rts
|
rts
|
||||||
.endproc
|
.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_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,set_position
|
Import lcd,init,clear,print,print_char,_cmd
|
||||||
|
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
; @macro Print a null-terminated string
|
; @macro Print a null-terminated string
|
||||||
|
@ -152,33 +152,14 @@ charcount: .res 1
|
|||||||
;; @returns A: the cursor position
|
;; @returns A: the cursor position
|
||||||
;;********************************************************************************
|
;;********************************************************************************
|
||||||
.proc set_position
|
.proc set_position
|
||||||
pha
|
|
||||||
cmp #$60
|
|
||||||
bge @invalid
|
|
||||||
cmp #$50
|
|
||||||
bge @line4
|
|
||||||
cmp #$40
|
cmp #$40
|
||||||
bge @line2
|
|
||||||
cmp #$20
|
|
||||||
bge @invalid
|
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
|
sta charcount
|
||||||
pla
|
pha
|
||||||
ora #lcd::CMD_SET_ADDRESS
|
ora #lcd::CMD_SET_ADDRESS
|
||||||
jsr _cmd
|
jsr _cmd
|
||||||
and #(<~lcd::CMD_SET_ADDRESS) ; return original argument
|
pla
|
||||||
|
@rts:
|
||||||
rts
|
rts
|
||||||
@invalid:
|
@invalid:
|
||||||
lda $14
|
lda $14
|
||||||
@ -186,7 +167,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)
|
||||||
rts
|
bra @rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user