mirror of
https://github.com/KarolS/millfork.git
synced 2024-05-31 18:41:30 +00:00
Compare commits
3 Commits
a6c3875375
...
11bef277cf
Author | SHA1 | Date | |
---|---|---|---|
|
11bef277cf | ||
|
b0e8b5c8d6 | ||
|
db4a5eed00 |
48
examples/c64/rasterirq.mfk
Normal file
48
examples/c64/rasterirq.mfk
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
void RasterA() {
|
||||
vic_rasterirq_acknowledge()
|
||||
|
||||
// First raster split, set border to black
|
||||
vic_border = black
|
||||
|
||||
// Set up next raster split
|
||||
vic_rasterirq_reconfigure(RasterB.addr, $40)
|
||||
|
||||
vic_rasterirq_return()
|
||||
}
|
||||
|
||||
void RasterB() {
|
||||
vic_rasterirq_acknowledge()
|
||||
|
||||
// Second raster split, Dark grey
|
||||
vic_border = dark_grey
|
||||
|
||||
// Set up next raster split
|
||||
vic_rasterirq_reconfigure(RasterC.addr, $A0)
|
||||
|
||||
vic_rasterirq_return()
|
||||
}
|
||||
|
||||
void RasterC() {
|
||||
vic_rasterirq_acknowledge()
|
||||
|
||||
// Third raster split, Light grey
|
||||
vic_border = light_grey
|
||||
|
||||
// Set up next raster split
|
||||
vic_rasterirq_reconfigure(RasterA.addr, $00)
|
||||
|
||||
vic_rasterirq_return()
|
||||
}
|
||||
|
||||
void main() {
|
||||
byte i
|
||||
|
||||
// Configure Raster IRQ
|
||||
vic_rasterirq_configure(RasterA.addr, $00)
|
||||
|
||||
// Loop forever
|
||||
while true {
|
||||
i = 0 // Do nothing here
|
||||
}
|
||||
}
|
|
@ -164,4 +164,44 @@ 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_rasterirq_return() {
|
||||
lda #$00
|
||||
jmp $EA81
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user