Skip to content

Instantly share code, notes, and snippets.

@wizofwor
Created January 3, 2019 21:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wizofwor/14d8ae4aeffdf1abdc674ffca5ec4ba4 to your computer and use it in GitHub Desktop.
.const SCREEN_RAM = $0400
.const COLOR_RAM = $d800
.const flag = $02
// --- main --------------------------------------------------------
BasicUpstart2(start)
* = $3000 "program"
start: jsr initialize
jsr irq_setup
main_loop: lda flag
beq main_loop
//inc $d020
lda #$00
sta flag
jmp main_loop
// --- Subroutines -------------------------------------------------
// Clear Screen
initialize: ldx #0
lda #$0
!: sta SCREEN_RAM+$000,x
sta SCREEN_RAM+$0ff,x
sta SCREEN_RAM+$1ff,x
sta SCREEN_RAM+$2ff,x
dex
bne !-
lda #00
sta $d020
sta $d021
// Initialize varibles
lda #$00
sta flag
rts
// --- irq routines ------------------------------------------------
.macro set_irq(addr, row_lo, row_hi){
.if (!row_hi) {
lda $d011 // high bit of raster line
and $7f
sta $d011
}
else {
lda $d011
ora #$80
sta $d011
}
lda row_lo // low byte of raster line
sta $d012
lda #<addr
sta 788
lda #>addr
sta 789
}
.const raster_row1 = 100
.const raster_row2 = 150
.const raster_row3 = 200
irq_setup: sei
lda #$7f
sta $dc0d
sta $dd0d
lda #$00
sta $dc02
lda #$01
sta $d01a
set_irq(irq01, raster_row1, false)
cli
rts
/* IRQ01 - Logo */
irq01: lda #$01
sta $d020
sta $d021
set_irq(irq02, raster_row2, false)
!out: asl $d019
jmp $ea81
/* IRQ02 - Cloud */
irq02: lda #$02
sta $d020
sta $d021
set_irq(irq03, raster_row3, false)
!out: asl $d019
jmp $ea81
/* IRQ03 - Scroll */
irq03: lda #$03
sta $d020
sta $d021
set_irq(irq01, raster_row1, false)
lda #$00
sta flag
!out: asl $d019
jmp $ea81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment