Compare commits
No commits in common. "03221c5fb4d934c2cda0a0ed243193e6ad85d785" and "811d50122fca8eb2fbd7b278600a386333029551" have entirely different histories.
03221c5fb4
...
811d50122f
34
main.s65
34
main.s65
@ -54,7 +54,7 @@
|
|||||||
; Interrupts
|
; Interrupts
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
.zeropage
|
.zeropage
|
||||||
irq_via_ifr: .res 1
|
IRQ_VAR: .res 1
|
||||||
.code
|
.code
|
||||||
nmi:
|
nmi:
|
||||||
lda #'%'
|
lda #'%'
|
||||||
@ -62,22 +62,26 @@ nmi:
|
|||||||
rti
|
rti
|
||||||
irq:
|
irq:
|
||||||
; read IRFs, while bit 7 ist set handle interrupts
|
; read IRFs, while bit 7 ist set handle interrupts
|
||||||
@irq_io1:
|
; @irq_io1:
|
||||||
lda IO1 + IO::IFR
|
; lda SPI_IO+IO::IFR
|
||||||
sta irq_via_ifr
|
; sta IRQ_VAR
|
||||||
bbr7 irq_via_ifr,@irq_io1 ; skip
|
; bbr7 IRQ_VAR,@irq_io2
|
||||||
bbs2 irq_via_ifr,@irq_kb1 ; shit reg -> first 8 bits
|
|
||||||
bbs5 irq_via_ifr,@irq_kb2 ; timer -> last 3 bits
|
|
||||||
@irq_io2:
|
@irq_io2:
|
||||||
lda IO2 + IO::IFR
|
lda IO2+IO::IFR
|
||||||
sta irq_via_ifr
|
sta IRQ_VAR
|
||||||
bbr7 irq_via_ifr,@irq_return ; skip
|
bbr7 IRQ_VAR,@irq_return
|
||||||
bbs2 irq_via_ifr,@irq_spi_p ; check SR
|
bbs2 IRQ_VAR,@irq_spi_p ; check SR
|
||||||
bbs1 irq_via_ifr,@irq_keypad ; check CA1
|
bbs1 IRQ_VAR,@irq_keypad ; check CA1
|
||||||
|
|
||||||
|
;
|
||||||
|
lda IO1+IO::IFR
|
||||||
|
sta IRQ_VAR
|
||||||
|
bbr7 IRQ_VAR,@irq_return
|
||||||
|
bbs2 IRQ_VAR,@irq_kb1 ; shit reg -> first 8 bits
|
||||||
|
bbs5 IRQ_VAR,@irq_kb2 ; timer -> last 3 bits
|
||||||
; this SHOULD never be reached
|
; this SHOULD never be reached
|
||||||
jsr lcd::clear
|
jsr lcd::clear
|
||||||
Print "Unknown IRQ"
|
Print str_irq_unknown
|
||||||
; force reset interrupt flags
|
; force reset interrupt flags
|
||||||
lda #$ff
|
lda #$ff
|
||||||
sta IO1 + IO::IFR
|
sta IO1 + IO::IFR
|
||||||
@ -230,6 +234,10 @@ str_spi_begin:
|
|||||||
.asciiz "---BEGIN SPI---"
|
.asciiz "---BEGIN SPI---"
|
||||||
str_spi_start:
|
str_spi_start:
|
||||||
.asciiz "---START SPI---"
|
.asciiz "---START SPI---"
|
||||||
|
str_irq:
|
||||||
|
.asciiz "IRQ detected! "
|
||||||
|
str_irq_unknown:
|
||||||
|
.asciiz "Unknown IRQ src!"
|
||||||
str_io2:
|
str_io2:
|
||||||
.asciiz "IO2::RB='"
|
.asciiz "IO2::RB='"
|
||||||
|
|
||||||
|
23
spicode.s65
23
spicode.s65
@ -106,6 +106,9 @@ CODE_START:
|
|||||||
jsr lcd::print_char
|
jsr lcd::print_char
|
||||||
bra @loop
|
bra @loop
|
||||||
|
|
||||||
|
|
||||||
|
; .out .sprintf("SPI: CODE_START at %x", *)
|
||||||
|
|
||||||
|
|
||||||
kbinit:
|
kbinit:
|
||||||
lda #'['
|
lda #'['
|
||||||
@ -119,8 +122,6 @@ kbinit:
|
|||||||
; the 3 last bits take about 230us, at @1MHz => wait 230 cycles and then the shift register
|
; the 3 last bits take about 230us, at @1MHz => wait 230 cycles and then the shift register
|
||||||
lda #230
|
lda #230
|
||||||
sta kb::KB_IO + IO::T2CL
|
sta kb::KB_IO + IO::T2CL
|
||||||
stz key_read
|
|
||||||
stz key_read+1
|
|
||||||
|
|
||||||
; enable SR interrupts
|
; enable SR interrupts
|
||||||
lda #(IO::IRQ::IRQ | IO::IRQ::SR)
|
lda #(IO::IRQ::IRQ | IO::IRQ::SR)
|
||||||
@ -136,7 +137,7 @@ irq_on_shift_reg:
|
|||||||
lda #'{'
|
lda #'{'
|
||||||
jsr lcd::print_char
|
jsr lcd::print_char
|
||||||
lda kb::KB_IO + IO::SR
|
lda kb::KB_IO + IO::SR
|
||||||
sta key_read
|
sta keycode
|
||||||
stz kb::KB_IO + IO::SR
|
stz kb::KB_IO + IO::SR
|
||||||
|
|
||||||
; disable SR interrupts
|
; disable SR interrupts
|
||||||
@ -158,7 +159,7 @@ irq_on_timer:
|
|||||||
lda #'<'
|
lda #'<'
|
||||||
jsr lcd::print_char
|
jsr lcd::print_char
|
||||||
lda kb::KB_IO + IO::SR
|
lda kb::KB_IO + IO::SR
|
||||||
sta key_read + 1
|
sta keycode + 1
|
||||||
|
|
||||||
lda kb::KB_IO + IO::T2CL ; clear interrupt flag
|
lda kb::KB_IO + IO::T2CL ; clear interrupt flag
|
||||||
|
|
||||||
@ -172,29 +173,25 @@ irq_on_timer:
|
|||||||
stz kb::KB_IO + IO::SR
|
stz kb::KB_IO + IO::SR
|
||||||
|
|
||||||
; lda #'|'
|
; lda #'|'
|
||||||
lda key_read
|
lda keycode
|
||||||
jsr lcd::print_char
|
jsr lcd::print_char
|
||||||
lda key_read + 1
|
lda keycode + 1
|
||||||
jsr lcd::print_char
|
jsr lcd::print_char
|
||||||
; rotate bit 2 (last bit of keycode) into the carry
|
; rotate bit 2 (last bit of keycode) into the carry
|
||||||
ror
|
ror
|
||||||
ror
|
ror
|
||||||
ror
|
ror
|
||||||
lda key_read ; not affecting carry
|
lda keycode ; not affecting carry
|
||||||
rol ; rotate carry into byte, rotate startbit into carry
|
rol ; rotate carry into byte, rotate startbit into carry
|
||||||
; TODO byte is inverted, maybe consider wasting 256 bytes for a bit reverse lookup table?
|
; TODO byte is inverted, maybe consider wasting 256 bytes for a bit reverse lookup table?
|
||||||
sta keycode
|
sta keycode + 1
|
||||||
jsr lcd::print_char
|
jsr lcd::print_char
|
||||||
|
|
||||||
stz key_read
|
|
||||||
stz key_read+1
|
|
||||||
|
|
||||||
lda #'>'
|
lda #'>'
|
||||||
jsr lcd::print_char
|
jsr lcd::print_char
|
||||||
rts
|
rts
|
||||||
|
|
||||||
key_read: .res 2
|
keycode: .res 3
|
||||||
keycode: .res 1
|
|
||||||
kb_irq1:
|
kb_irq1:
|
||||||
lda #'!'
|
lda #'!'
|
||||||
jsr lcd::print_char
|
jsr lcd::print_char
|
||||||
|
@ -10,8 +10,6 @@ INCLUDE_IOW65C22 = 1
|
|||||||
|
|
||||||
.scope IO
|
.scope IO
|
||||||
|
|
||||||
; not using a struct for this since the syntax for access would be the same,
|
|
||||||
; ie label+IO::RA
|
|
||||||
.enum
|
.enum
|
||||||
; IO-CHIPS OFFSETS FOR PINS FROM BASE ADDRESS
|
; IO-CHIPS OFFSETS FOR PINS FROM BASE ADDRESS
|
||||||
RB = $0 ; Register B (ORB/IRB)
|
RB = $0 ; Register B (ORB/IRB)
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
;********************************************************************************
|
|
||||||
; @module irq_handler
|
|
||||||
; @type system
|
|
||||||
;********************************************************************************
|
|
||||||
.ifndef INCLUDE_IRQ_HANDLER
|
|
||||||
INCLUDE_IRQ_HANDLER = 1
|
|
||||||
|
|
||||||
.scope irq
|
|
||||||
|
|
||||||
.endscope
|
|
||||||
.endif
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
.include "irq_handler.h65"
|
|
||||||
.bss
|
|
||||||
|
|
||||||
|
|
||||||
.code
|
|
||||||
|
|
||||||
.proc register_via_handler
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc remove_via_handler
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc main_handler
|
|
||||||
Print "Unknown IRQ"
|
|
||||||
rti
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.zeropage
|
|
||||||
tmp: .res 1
|
|
||||||
|
|
||||||
.macro VIAHandler via_addr, via_handlers_table
|
|
||||||
lda via_addr + IO::IFR
|
|
||||||
sta tmp
|
|
||||||
bbr7 tmp,@rts ; irq
|
|
||||||
bbs0 tmp,@ca2
|
|
||||||
bbs1 tmp,@ca1
|
|
||||||
bbs2 tmp,@sr
|
|
||||||
bbs3 tmp,@cb2
|
|
||||||
bbs4 tmp,@cb1
|
|
||||||
bbs5 tmp,@t2
|
|
||||||
bbs6 tmp,@t1
|
|
||||||
; TODO error, one should have been true
|
|
||||||
stp
|
|
||||||
@rts:
|
|
||||||
rts
|
|
||||||
@ca2: jmp (via_handlers_table)
|
|
||||||
@ca1: jmp (via_handlers_table+2)
|
|
||||||
@sr: jmp (via_handlers_table+4)
|
|
||||||
@cb2: jmp (via_handlers_table+6)
|
|
||||||
@cb1: jmp (via_handlers_table+8)
|
|
||||||
@t2: jmp (via_handlers_table+10)
|
|
||||||
@t1: jmp (via_handlers_table+12)
|
|
||||||
.endmacro
|
|
@ -22,54 +22,44 @@ LCD_IO = IO1
|
|||||||
Import lcd,init,clear,print,print_char,set_position,set_custom_char
|
Import lcd,init,clear,print,print_char,set_position,set_custom_char
|
||||||
Import lcd,_cmd,_wait_nbusy,_write_ram,_read_ram
|
Import lcd,_cmd,_wait_nbusy,_write_ram,_read_ram
|
||||||
|
|
||||||
;;********************************************************************************
|
;********************************************************************************
|
||||||
;; @macro Clear the screen and print a null-terminated string
|
; @macro Clear the screen and print a null-terminated string
|
||||||
;; @param message: Address of the message or string literal
|
; @param message: Address of the message
|
||||||
;; @details
|
;********************************************************************************
|
||||||
;; If message is a string literal, it will be stored in rodata
|
|
||||||
;; and the address of this segment will be used
|
|
||||||
;;********************************************************************************
|
|
||||||
.macro Print message
|
.macro Print message
|
||||||
|
; .out .sprintf("message is a string literal: '%s' len=%x", message, .strlen(message))
|
||||||
|
.if .match(message, "")
|
||||||
|
.pushseg
|
||||||
|
.rodata
|
||||||
|
: .asciiz message
|
||||||
|
.popseg
|
||||||
|
.out .sprintf("message is a string literal: '%s' len=%x", message, .strlen(message))
|
||||||
jsr lcd::clear
|
jsr lcd::clear
|
||||||
.if .match(message, "") ; message is a string literal -> store in rodata
|
lda #<:-
|
||||||
.pushseg
|
sta ARG0
|
||||||
.rodata
|
lda #>:-
|
||||||
: .asciiz message
|
sta ARG1
|
||||||
.popseg
|
.else
|
||||||
lda #<:-
|
.out "message is a n0t string"
|
||||||
sta ARG0
|
jsr lcd::clear
|
||||||
lda #>:-
|
lda #<message
|
||||||
sta ARG1
|
sta ARG0
|
||||||
.else ; message is not a string
|
lda #>message
|
||||||
lda #<message
|
sta ARG1
|
||||||
sta ARG0
|
|
||||||
lda #>message
|
|
||||||
sta ARG1
|
|
||||||
.endif
|
.endif
|
||||||
jsr lcd::print
|
jsr lcd::print
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
;;********************************************************************************
|
;********************************************************************************
|
||||||
;; @macro Print a null-terminated string
|
; @macro Print a null-terminated string
|
||||||
;; @param message: Address of the message or string literal
|
; @param message: Address of the message
|
||||||
;;********************************************************************************
|
;********************************************************************************
|
||||||
.macro PrintNC message
|
.macro PrintNC message
|
||||||
.if .match(message, "") ; message is a string literal -> store in rodata
|
lda #<message
|
||||||
.pushseg
|
sta ARG0
|
||||||
.rodata
|
lda #>message
|
||||||
: .asciiz message
|
sta ARG1
|
||||||
.popseg
|
|
||||||
lda #<:-
|
|
||||||
sta ARG0
|
|
||||||
lda #>:-
|
|
||||||
sta ARG1
|
|
||||||
.else ; message is not a string
|
|
||||||
lda #<message
|
|
||||||
sta ARG0
|
|
||||||
lda #>message
|
|
||||||
sta ARG1
|
|
||||||
.endif
|
|
||||||
jsr lcd::print
|
jsr lcd::print
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
@ -31,30 +31,19 @@ Import str, hex_char_to_uint8, hex_str_to_uint, uint8_to_hex_str
|
|||||||
|
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
; @function Macro for passing arguments to strf
|
; @function Macro for passing arguments to strf
|
||||||
; @param fmt: Format string address or string literal
|
; @param fmt: Format string address
|
||||||
; @param out: Output string address
|
; @param out: Output string address
|
||||||
; @param x0-x9: Additional parameters
|
; @param x0-x9: Additional parameters
|
||||||
; @warning Addresses as additional paramters must be passed like this `#<addr,#>addr`
|
; @warning Addresses as additional paramteres must be passed like this `#<addr,#>addr`
|
||||||
; @modifies: A, X, Y
|
; @modifies: A, X, Y
|
||||||
; @see strf
|
; @see strf
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
.macro Strf fmt,out,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
|
.macro Strf fmt,out,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
|
||||||
@N_ARGS .set 0 ; @ so that it doesnt break cheap labels
|
@N_ARGS .set 0 ; @ so that it doesnt break cheap labels
|
||||||
.if .match(fmt, "") ; fmt is a string literal -> store in rodata
|
lda #<fmt
|
||||||
.pushseg
|
sta ARG0
|
||||||
.rodata
|
lda #>fmt
|
||||||
: .asciiz fmt
|
sta ARG1
|
||||||
.popseg
|
|
||||||
lda #<:-
|
|
||||||
sta ARG0
|
|
||||||
lda #>:-
|
|
||||||
sta ARG1
|
|
||||||
.else ; message is not a string
|
|
||||||
lda #<fmt
|
|
||||||
sta ARG0
|
|
||||||
lda #>fmt
|
|
||||||
sta ARG1
|
|
||||||
.endif
|
|
||||||
lda #<out
|
lda #<out
|
||||||
sta ARG2
|
sta ARG2
|
||||||
lda #>out
|
lda #>out
|
||||||
@ -67,10 +56,8 @@ Import str, hex_char_to_uint8, hex_str_to_uint, uint8_to_hex_str
|
|||||||
_StrfStoreArg x5
|
_StrfStoreArg x5
|
||||||
_StrfStoreArg x6
|
_StrfStoreArg x6
|
||||||
_StrfStoreArg x7
|
_StrfStoreArg x7
|
||||||
_StrfStoreArg x8
|
|
||||||
_StrfStoreArg x9
|
|
||||||
jsr str::strf
|
jsr str::strf
|
||||||
; .out .sprintf("info: Strf: called with %d arguments", @N_ARGS)
|
.out .sprintf("info: Strf: called with %d arguments", @N_ARGS)
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
; TODO allocate zp memory
|
; TODO allocate zp memory
|
||||||
|
Loading…
Reference in New Issue
Block a user