mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-10-21 17:24:39 +00:00
75 lines
1.6 KiB
NASM
75 lines
1.6 KiB
NASM
// A minimal working raster IRQ
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
.label HARDWARE_IRQ = $fffe
|
|
.label RASTER = $d012
|
|
.label VIC_CONTROL = $d011
|
|
.label IRQ_STATUS = $d019
|
|
.label IRQ_ENABLE = $d01a
|
|
.const IRQ_RASTER = 1
|
|
.label BGCOL = $d020
|
|
.label FGCOL = $d021
|
|
.const WHITE = 1
|
|
.const BLACK = 0
|
|
.label CIA1_INTERRUPT = $dc0d
|
|
.const CIA_INTERRUPT_CLEAR = $7f
|
|
// Processor port data direction register
|
|
.label PROCPORT_DDR = 0
|
|
// Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
|
|
.const PROCPORT_DDR_MEMORY_MASK = 7
|
|
// Processor Port Register controlling RAM/ROM configuration and the datasette
|
|
.label PROCPORT = 1
|
|
// RAM in $A000, $E000 I/O in $D000
|
|
.const PROCPORT_RAM_IO = $35
|
|
// RAM in $A000, $E000 CHAR ROM in $D000
|
|
main: {
|
|
sei
|
|
// Disable kernal & basic
|
|
lda #PROCPORT_DDR_MEMORY_MASK
|
|
sta PROCPORT_DDR
|
|
lda #PROCPORT_RAM_IO
|
|
sta PROCPORT
|
|
// Disable CIA 1 Timer IRQ
|
|
lda #CIA_INTERRUPT_CLEAR
|
|
sta CIA1_INTERRUPT
|
|
// Set raster line to $100
|
|
lda #$80
|
|
ora VIC_CONTROL
|
|
sta VIC_CONTROL
|
|
lda #0
|
|
sta RASTER
|
|
// Enable Raster Interrupt
|
|
lda #IRQ_RASTER
|
|
sta IRQ_ENABLE
|
|
// Set the IRQ routine
|
|
lda #<irq
|
|
sta HARDWARE_IRQ
|
|
lda #>irq
|
|
sta HARDWARE_IRQ+1
|
|
cli
|
|
b1:
|
|
inc FGCOL
|
|
jmp b1
|
|
}
|
|
// Interrupt Routine
|
|
irq: {
|
|
sta rega+1
|
|
stx regx+1
|
|
sty regy+1
|
|
lda #WHITE
|
|
sta BGCOL
|
|
lda #BLACK
|
|
sta BGCOL
|
|
// Acknowledge the IRQ
|
|
lda #IRQ_RASTER
|
|
sta IRQ_STATUS
|
|
rega:
|
|
lda #00
|
|
regx:
|
|
ldx #00
|
|
regy:
|
|
ldy #00
|
|
rti
|
|
}
|