Skip to content

Instantly share code, notes, and snippets.

@cfdrake
Last active June 7, 2021 03:47
Show Gist options
  • Save cfdrake/a23c7861d2673bc3e3ec213e9719a05f to your computer and use it in GitHub Desktop.
Save cfdrake/a23c7861d2673bc3e3ec213e9719a05f to your computer and use it in GitHub Desktop.
c64 rasterbars wip
processor 6502
MACRO DELAY ;; {1} - loop iterations
ldx {1}
.loop:
dex
bne .loop
ENDM
MACRO RASTER ;; {1} - background color to set
lda {1}
sta $d020
sta $d021
ENDM
;; VICE autostart logic
org $0801
.byte $0b, $08, $01, $00, $9e, $32, $30, $36
.byte $31, $00, $00, $00
;; Interrupt logic
setup_interrupts:
sei ; turn off interrupts
lda #$7f
sta $dc0d
sta $dd0d
lda #$01
sta $d01a
lda #<irq ; set interrupt handler
ldx #>irq
sta $0314
stx $0315
ldy #$00 ; enable raster interrupts
sty $d012
lda $dc0d ; acknowledge interrupts
lda $dd0d
asl $d019
cli
;; Main loop
main_loop:
jmp main_loop
;; Raster interrupt
irq:
DELAY #$05
RASTER #$06
DELAY #$0a
RASTER #$13
DELAY #$0a
RASTER #$0e
DELAY #$0c
RASTER #$03
DELAY #$15
RASTER #$01
DELAY #$17
RASTER #$03
DELAY #$17
RASTER #$0e
DELAY #$17
RASTER #$13
DELAY #$17
RASTER #$06
DELAY #$0a
RASTER #$00
asl $d019 ; return from interrupt
jmp $ea81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment