mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-10 05:29:49 +00:00
C64 VIC-II RasterIRQ methods and example
This commit is contained in:
parent
bf273456a3
commit
db4a5eed00
40
examples/c64/rasterirq.mfk
Normal file
40
examples/c64/rasterirq.mfk
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
void RasterA()
|
||||
{
|
||||
vic_rasterirq_acknowledge()
|
||||
vic_border = $00
|
||||
|
||||
vic_rasterirq_reconfigure(RasterB.addr, $40)
|
||||
vic_raster_return()
|
||||
}
|
||||
|
||||
void RasterB()
|
||||
{
|
||||
vic_rasterirq_acknowledge()
|
||||
vic_border = $04
|
||||
|
||||
vic_rasterirq_reconfigure(RasterC.addr, $A0)
|
||||
vic_raster_return()
|
||||
}
|
||||
|
||||
void RasterC()
|
||||
{
|
||||
vic_rasterirq_acknowledge()
|
||||
vic_border = $02
|
||||
|
||||
vic_rasterirq_reconfigure(RasterA.addr, $00)
|
||||
vic_raster_return()
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
byte i
|
||||
|
||||
// Configure Raster IRQ
|
||||
vic_rasterirq_configure(RasterA.addr, $00)
|
||||
|
||||
while true
|
||||
{
|
||||
i = 0
|
||||
}
|
||||
}
|
@ -164,4 +164,48 @@ const byte medium_gray = 12
|
||||
const byte light_green = 13
|
||||
const byte light_blue = 14
|
||||
const byte light_grey = 15
|
||||
const byte light_gray = 15
|
||||
const byte light_gray = 15
|
||||
|
||||
|
||||
asm void vic_rasterirq_configure(pointer CallbackFunction, byte RasterLine)
|
||||
{
|
||||
sei
|
||||
ldx CallbackFunction.lo
|
||||
stx $0314
|
||||
ldy CallbackFunction.hi
|
||||
sty $0315
|
||||
lda #$7f ;CIA interrupt off
|
||||
sta $dc0d
|
||||
lda #$01 ;Raster interrupt on
|
||||
sta $d01a
|
||||
lda #27 ;High bit of interrupt position = 0
|
||||
sta $d011
|
||||
lda RasterLine ;Line where next IRQ happens
|
||||
sta $d012
|
||||
lda $dc0d ;Acknowledge IRQ (to be sure)
|
||||
cli
|
||||
rts
|
||||
}
|
||||
|
||||
asm void vic_rasterirq_reconfigure(pointer CallbackFunction, byte RasterLine)
|
||||
{
|
||||
ldx CallbackFunction.lo
|
||||
stx $0314
|
||||
ldy CallbackFunction.hi
|
||||
sty $0315
|
||||
lda RasterLine ;Line where next IRQ happens
|
||||
sta $d012
|
||||
rts
|
||||
}
|
||||
|
||||
asm macro void vic_rasterirq_acknowledge()
|
||||
{
|
||||
lda #$FF
|
||||
sta $D019
|
||||
}
|
||||
|
||||
asm macro void vic_raster_return()
|
||||
{
|
||||
lda #$00
|
||||
jmp $EA81
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user