6502-OS/main.s65

149 lines
3.2 KiB
Plaintext
Raw Normal View History

2023-10-26 19:51:20 +02:00
.include "system/system.h65"
.org $8000 ; EEPROM Start Address
;********************************************************************************
; Interrupts
;********************************************************************************
nmi:
rti
irq:
; lda IFR2 todo: verify that the line below does the same thing
lda IO2+IO_IFR
sta 0
; todo: decide wether to read keypad or dht
ora #%10100000
; jsr lcd_char ;TODO: Remove
jsr kp_read
rti
bbs1 0,irq_keypad
lda #'-'
jsr _lcd_char
bbs4 0,irq_dht
bbs6 0,irq_dht
rti
irq_keypad:
jsr kp_read
rti
irq_dht:
lda T1L2 ; clear interrupt flag
jsr dht_irq
rti
;********************************************************************************
; Reset sequence
;********************************************************************************
reset:
lda #%11111111
sta IO2 + IO_DDRA
.macro SET_DEBUG_LED_OFF
lda #%00000000
sta IO2 + IO_RANH
.endmacro
.macro SET_DEBUG_LED_ON
lda #%11111111
sta IO2 + IO_RANH
.endmacro
SET_DEBUG_LED_OFF
jsr lcd_init
SET_DEBUG_LED_ON
; jsr kp_init
; INIT DHT
lda #%11000010 ; enable interrupt for Timer 1 and CA1 on IO2
sta IER2
lda #%00111111 ; set Timer 1 to interrupt when loaded
and ACR2
sta ACR2
lda #%00000001 ; set PCR2 bit 0 CA1 pos edge interrupt
ora PCR2
sta PCR2
stz DHT_STATUS
; enable interrupts
cli
.proc return_home
ldx #$00
@return_home:
lda menu,x
beq @return_home_done
sta TO_PRINT,x
inx
bra @return_home
@return_home_done:
jsr lcd_print_clear
.endproc
.proc home
jsr kb_read
beq home
cmp #'A'
jeq printer
cmp #'B'
jeq dht_request
cmp #'C'
beq print_1
cmp #'D'
beq print_2
cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home)
beq return_home
bra home
.endproc
print_1:
ldx #$00
@print_1:
lda message_1,x
sta TO_PRINT,x
inx
bne @print_1
jsr lcd_print_clear
jmp home
print_2:
ldx #$00
@print_2:
lda message_2,x
sta TO_PRINT,x
inx
bne @print_2
jsr lcd_print_clear
jmp home
.rodata
message_1: .asciiz " Powered by ......6502...... **** www.quintern.xyz"
message_2: .asciiz " Danke fuer eure Aufmerksamkeit ;) "
menu:
.byte "<A> Printer "
.byte "<B> Temperatur "
.byte "<C> Text 1 "
.asciiz "<D> Text 2 "
.code
;********************************************************************************
; Modules
;********************************************************************************
; LCD
; .include "utility.asm6502"
LCD_IO = IO1
.include "lcd.asm6502"
; Keypad Reading
KP_IO = IO1
.include "keypad.asm6502"
; Printer
.include "printer.asm6502"
; Digital Humidity and Temerature Sensor
.include "dht.asm6502"
;********************************************************************************
; reset vector
;********************************************************************************
.rodata
.org $fffa
.word nmi
.word reset
.word irq