231 lines
4.7 KiB
Plaintext
231 lines
4.7 KiB
Plaintext
.include "system/system.h65"
|
|
.include "string.h65"
|
|
.export home,homeloop
|
|
.import printer:absolute
|
|
.import spi_menu:absolute
|
|
|
|
.code
|
|
|
|
;********************************************************************************
|
|
; Modules
|
|
;********************************************************************************
|
|
; LCD
|
|
; .include "utility.asm6502"
|
|
; LCD_IO = IO1
|
|
.include "system/lcd.h65"
|
|
.include "chars.h65"
|
|
; Keypad Reading
|
|
; KP_IO = IO2
|
|
.include "system/keypad.h65"
|
|
; SPI
|
|
.include "system/spi.h65"
|
|
; Printer
|
|
; .include "programs/printer.s65"
|
|
.include "programs/print_slow.h65"
|
|
; .include "programs/spi-menu.s65"
|
|
; Digital Humidity and Temerature Sensor
|
|
; .include "dht.s65"
|
|
|
|
|
|
;********************************************************************************
|
|
; Interrupts
|
|
;********************************************************************************
|
|
.zeropage
|
|
irq_via_ifr: .res 1
|
|
.code
|
|
nmi:
|
|
lda #'%'
|
|
jsr lcd::print_char
|
|
rti
|
|
irq:
|
|
; read IRFs, while bit 7 ist set handle interrupts
|
|
; DEBUG_LED_ON 2
|
|
@irq_io1:
|
|
lda IO1 + IO::IFR
|
|
sta irq_via_ifr
|
|
bbr7 irq_via_ifr,@irq_io2 ; skip
|
|
bbs2 irq_via_ifr,@irq_kb1 ; shit reg -> first 8 bits
|
|
bbs5 irq_via_ifr,@irq_kb2 ; timer -> last 3 bits
|
|
bra @irq_unknown
|
|
@irq_io2:
|
|
lda IO2 + IO::IFR
|
|
sta irq_via_ifr
|
|
bbr7 irq_via_ifr,@irq_return ; skip
|
|
bbs2 irq_via_ifr,@irq_spi_p ; check SR
|
|
bbs1 irq_via_ifr,@irq_keypad ; check CA1
|
|
|
|
@irq_unknown:
|
|
; this SHOULD never be reached
|
|
jsr lcd::clear
|
|
Print "Unknown IRQ"
|
|
; force reset interrupt flags
|
|
lda #$ff
|
|
sta IO1 + IO::IFR
|
|
sta IO2 + IO::IFR
|
|
bra @irq_return
|
|
@irq_keypad:
|
|
jsr kp::read_irq
|
|
bra @irq_return
|
|
@irq_spi_p:
|
|
jsr spi_p::irq_read_byte
|
|
bra @irq_return
|
|
; jmp (spi_p::irq_handler)
|
|
; JsrIndirect (spi_p::irq_handler), @irq_return
|
|
@irq_kb1:
|
|
; Print "$3000"
|
|
jsr $3000
|
|
bra @irq_return
|
|
@irq_kb2:
|
|
; Print "$3100"
|
|
jsr $3100
|
|
bra @irq_return
|
|
; @irq_dht:
|
|
; lda IO1 + IO::T1CL ;T1L2 ; clear interrupt flag
|
|
; bra @irq_return
|
|
@irq_return:
|
|
rti
|
|
|
|
;********************************************************************************
|
|
; Reset sequence
|
|
;********************************************************************************
|
|
reset:
|
|
jsr lcd::init
|
|
|
|
; TODO debug stuff
|
|
stz IO2 + IO::DDRB
|
|
lda #$ff
|
|
sta IO1 + IO::DDRA
|
|
DEBUG_LED_OFF 0
|
|
DEBUG_LED_OFF 1
|
|
DEBUG_LED_OFF 1
|
|
|
|
jsr kp::init
|
|
|
|
DEBUG_LED_ON 0
|
|
|
|
jsr spi_p::init
|
|
DEBUG_LED_ON 1
|
|
|
|
; SetCustomChar chars::CAT,0
|
|
; SetCustomChar chars::SMILEY,1
|
|
; SetCustomChar chars::SMILEY_XD,2
|
|
|
|
; DEBUG_LED_ON 2
|
|
|
|
; enable interrupts
|
|
cli
|
|
bra home
|
|
|
|
.proc home
|
|
Print message_menu
|
|
; jsr rb_keypad_read
|
|
stz kp::_DEBUG_VAL
|
|
bra homeloop
|
|
.endproc
|
|
.proc homeloop
|
|
@loop:
|
|
lda kp::_DEBUG_VAL
|
|
beq @loop
|
|
; TODO debug
|
|
sta 0
|
|
stz kp::_DEBUG_VAL
|
|
lda 0
|
|
; beq home
|
|
cmp #'A'
|
|
jeq printer
|
|
cmp #'B'
|
|
jeq spi_menu
|
|
cmp #'C'
|
|
jeq print_1
|
|
cmp #'D'
|
|
jeq print_2
|
|
cmp #'1'
|
|
beq @debug0_on
|
|
cmp #'2'
|
|
beq @debug0_off
|
|
cmp #'4'
|
|
beq @debug1_on
|
|
cmp #'5'
|
|
beq @debug1_off
|
|
cmp #'7'
|
|
beq @debug2_on
|
|
cmp #'8'
|
|
beq @debug2_off
|
|
cmp #'9'
|
|
beq @print_rb
|
|
cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home)
|
|
beq home
|
|
wai
|
|
jmp @loop
|
|
|
|
@debug0_off:
|
|
DEBUG_LED_OFF 0
|
|
jmp @loop
|
|
@debug0_on:
|
|
DEBUG_LED_ON 0
|
|
jmp @loop
|
|
@debug1_off:
|
|
DEBUG_LED_OFF 1
|
|
jmp @loop
|
|
@debug1_on:
|
|
DEBUG_LED_ON 1
|
|
jmp @loop
|
|
@debug2_off:
|
|
DEBUG_LED_OFF 2
|
|
jmp @loop
|
|
@debug2_on:
|
|
DEBUG_LED_ON 2
|
|
jmp @loop
|
|
@print_rb:
|
|
jsr lcd::clear
|
|
Print str_io2
|
|
lda IO2 + IO::RB
|
|
jsr lcd::print_char
|
|
lda #'''
|
|
jsr lcd::print_char
|
|
jmp @loop
|
|
.endproc
|
|
|
|
|
|
print_1:
|
|
jsr lcd::clear
|
|
PrintSlow message_1,10
|
|
jmp home
|
|
|
|
print_2:
|
|
jsr lcd::clear
|
|
PrintSlow message_2,10
|
|
jmp home
|
|
|
|
.rodata
|
|
message_1:
|
|
.byte " Powered by "
|
|
.byte "......6502......"
|
|
.byte " **** "
|
|
.asciiz "www.quintern.xyz"
|
|
message_2:
|
|
.byte "0123456789=!?#+*"
|
|
.byte "ABCDEFGHIJKLMNOP"
|
|
.byte "QRSTUVWXYZÖÄÜß-_"
|
|
.asciiz "{[(<>)]}$%&/,;.:"
|
|
message_menu:
|
|
.byte "<A> Printer "
|
|
; .byte "<B> Temperatur "
|
|
.byte "<B> SPI-Menu "
|
|
.byte "<C> Text 1 "
|
|
.asciiz "<D> Text 2 "
|
|
str_spi_begin:
|
|
.asciiz "---BEGIN SPI---"
|
|
str_spi_start:
|
|
.asciiz "---START SPI---"
|
|
str_io2:
|
|
.asciiz "IO2::RB='"
|
|
|
|
;********************************************************************************
|
|
; reset vector
|
|
;********************************************************************************
|
|
.segment "RESET_VECTOR"
|
|
.word nmi
|
|
.word reset
|
|
.word irq
|