6502-OS/main.s65

153 lines
3.3 KiB
Plaintext
Raw Normal View History

2023-10-27 16:50:58 +02:00
.segment "CODE"
2023-10-26 19:51:20 +02:00
.include "system/system.h65"
2023-10-28 03:48:27 +02:00
;********************************************************************************
; Modules
;********************************************************************************
; LCD
; .include "utility.asm6502"
LCD_IO = IO1
.include "lcd.s65"
; Keypad Reading
KP_IO = IO1
.include "keypad.s65"
; Printer
.include "printer.s65"
; Digital Humidity and Temerature Sensor
; .include "dht.s65"
2023-10-26 19:51:20 +02:00
;********************************************************************************
; Interrupts
;********************************************************************************
nmi:
2023-10-27 16:50:58 +02:00
lda #'%'
jsr _lcd_char
2023-10-26 19:51:20 +02:00
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
2023-10-27 16:50:58 +02:00
; bbs1 0,irq_keypad
2023-10-26 19:51:20 +02:00
lda #'-'
jsr _lcd_char
2023-10-27 16:50:58 +02:00
; bbs4 0,irq_dht
; bbs6 0,irq_dht
2023-10-26 19:51:20 +02:00
rti
irq_keypad:
jsr kp_read
rti
irq_dht:
2023-10-27 16:50:58 +02:00
lda IO1 + IO_T1CL ;T1L2 ; clear interrupt flag
; jsr dht_irq
2023-10-26 19:51:20 +02:00
rti
;********************************************************************************
; Reset sequence
;********************************************************************************
reset:
lda #%11111111
2023-10-27 16:50:58 +02:00
sta IO1 + IO_DDRA
2023-10-26 19:51:20 +02:00
.macro SET_DEBUG_LED_OFF
lda #%00000000
2023-10-27 16:50:58 +02:00
sta IO1 + IO_RANH
2023-10-26 19:51:20 +02:00
.endmacro
.macro SET_DEBUG_LED_ON
lda #%11111111
2023-10-27 16:50:58 +02:00
sta IO1 + IO_RANH
2023-10-26 19:51:20 +02:00
.endmacro
2023-10-28 03:48:27 +02:00
; SET_DEBUG_LED_OFF
2023-10-26 19:51:20 +02:00
jsr lcd_init
2023-10-28 03:48:27 +02:00
; .repeat 1000
; nop
; .endrepeat
; SET_DEBUG_LED_ON
jsr kp_init
; SET_DEBUG_LED_OFF
2023-10-26 19:51:20 +02:00
2023-10-27 16:50:58 +02:00
; ; 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
2023-10-26 19:51:20 +02:00
; enable interrupts
cli
.proc return_home
2023-10-28 03:48:27 +02:00
Print message_menu
; @return_home:
; lda menu,x
; beq @return_home_done
; sta TO_PRINT,x
; jsr _lcd_char
; inx
; bra @return_home
; @return_home_done:
; jsr lcd_print_clear
2023-10-26 19:51:20 +02:00
.endproc
.proc home
2023-10-28 03:48:27 +02:00
; SET_DEBUG_LED_ON
2023-10-26 19:51:20 +02:00
jsr kb_read
beq home
cmp #'A'
jeq printer
cmp #'B'
2023-10-27 16:50:58 +02:00
; jeq dht_request
2023-10-26 19:51:20 +02:00
cmp #'C'
2023-10-28 03:48:27 +02:00
jeq print_1
2023-10-26 19:51:20 +02:00
cmp #'D'
2023-10-28 03:48:27 +02:00
jeq print_2
2023-10-26 19:51:20 +02:00
cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home)
beq return_home
2023-10-28 03:48:27 +02:00
; .repeat 500
; nop
; .endrepeat
; SET_DEBUG_LED_OFF
; .repeat 500
; nop
; .endrepeat
jmp home
2023-10-26 19:51:20 +02:00
.endproc
print_1:
2023-10-28 03:48:27 +02:00
Print message_1
2023-10-26 19:51:20 +02:00
jmp home
print_2:
2023-10-28 03:48:27 +02:00
Print message_2
2023-10-26 19:51:20 +02:00
jmp home
2023-10-27 16:50:58 +02:00
.segment "RODATA"
2023-10-26 19:51:20 +02:00
message_1: .asciiz " Powered by ......6502...... **** www.quintern.xyz"
message_2: .asciiz " Danke fuer eure Aufmerksamkeit ;) "
2023-10-28 03:48:27 +02:00
message_menu:
2023-10-26 19:51:20 +02:00
.byte "<A> Printer "
.byte "<B> Temperatur "
.byte "<C> Text 1 "
.asciiz "<D> Text 2 "
2023-10-27 16:50:58 +02:00
.segment "CODE"
2023-10-26 19:51:20 +02:00
;********************************************************************************
; reset vector
;********************************************************************************
2023-10-27 16:50:58 +02:00
.segment "RESET_VECTOR"
2023-10-26 19:51:20 +02:00
.word nmi
.word reset
.word irq