Skip to content

Instantly share code, notes, and snippets.

@RoelN
Created September 12, 2018 11:01
Show Gist options
  • Save RoelN/728ad393b632bf70d47f872be5ed7fbd to your computer and use it in GitHub Desktop.
Save RoelN/728ad393b632bf70d47f872be5ed7fbd to your computer and use it in GitHub Desktop.
BasicUpstart2(start)
.macro waste_cycles(n) {
.var nops = floor(n/2)
.var rem = n&1
.var c = n
.if (rem == 0) {
.for (var i = 0; i < nops; i++) {
nop
.eval c -= 2
}
} else {
.for (var i = 0; i < nops-1; i++) {
nop
.eval c -= 2
}
bit $fe
.eval c -= 3
}
.if (c != 0) {
.print n
.print c
.error "assert"
}
}
///////////////////////////////
*= $4000
start:
lda #$00
sta $3fff // Clear border garbage
// Interrupt
sei
lda #<irq
sta $0314
lda #>irq
sta $0315
lda #$00
sta $d012
lda #$01
sta $d019
sta $d01a
lda #$7f
sta $dc0d
cli
jmp *
///////////////////////////////
irq:
lda $d019
and #$01
sta $d019
bne cycle
jmp $ea81
cycle:
lda $d011
ora #$08
sta $d011
// Let's boogie!
ldx #$10
cpx $d012
bne * - 3
.var x=0
.for (x=0;x<$e4;x++) {
waste_cycles(63)
}
lda $d012
sta $0400 // Results in #$f9... and sometimes $fa
// Open the bottom border on line $f9
lda $d011
and #$f7
sta $d011
// Turn off VIC
lda $d011
and #%00001000
sta $d011
jmp $ea81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment