Last active
July 30, 2022 19:39
-
-
Save pawelkrol/6078d3e365826acd8f513466cb905ace to your computer and use it in GitHub Desktop.
Dream's Kickass Demo Framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//---------------------------------------- | |
// HOW TO: | |
// | |
// 1. Include dependencies: | |
// | |
// .pc = $0800 "Framework" | |
// .import source "kickass.src" | |
// | |
// 2. Initialise program: | |
// | |
// msx_setup_play($1000,$1003) | |
// jsr irq_init | |
// ...do your other stuff here... | |
// clc | |
// lda #$02 | |
// ldx #<irq1 | |
// ldy #>irq1 | |
// jsr irq_setup_addr | |
// | |
// 3. Set up IRQ routine: | |
// | |
// irq: | |
// jsr msx_play_exec | |
// ...do your other stuff here... | |
// lda #$02 | |
// ldx #<irq1 | |
// ldy #>irq1 | |
// rts | |
//---------------------------------------- | |
.const SYNCHRO_COUNTER = $0a//$0b | |
//---------------------------------------- | |
irq_init: | |
// Block SHIFT+C=: | |
lda #$08 | |
jsr $ffd2 | |
// No key repetition: | |
lda #$40 | |
sta $028a | |
// Setup IRQ handler: | |
sei | |
lda #$35 | |
sta $01 | |
lda #<irq_exit | |
sta $fffa | |
sta $fffc | |
lda #>irq_exit | |
sta $fffb | |
sta $fffd | |
lda #<irq_hard | |
sta $fffe | |
lda #>irq_hard | |
sta $ffff | |
lda #<irq_soft | |
sta $0314 | |
lda #>irq_soft | |
sta $0315 | |
lda #$7f | |
sta $dc0d | |
lda $d011 | |
and #$7f | |
sta $d011 | |
sta $dc0e | |
lda #$01 | |
sta $d01a | |
sta $d019 | |
sec | |
jmp irq_reset | |
//---------------------------------------- | |
irq_hard: | |
pha | |
txa | |
pha | |
tya | |
pha | |
lda $01 | |
pha | |
lda #$35 | |
sta $01 | |
jsr irq_proc | |
stx irq_proc+1 | |
sty irq_proc+2 | |
sta $d012 | |
lda #<irq_hard | |
sta $fffe | |
lda #>irq_hard | |
sta $ffff | |
inc $d019 | |
lda $dc0d | |
pla | |
sta $01 | |
pla | |
tay | |
pla | |
tax | |
pla | |
irq_exit: | |
rti | |
//---------------------------------------- | |
irq_soft: | |
lda $01 | |
pha | |
lda #$35 | |
sta $01 | |
jsr irq_proc | |
stx irq_proc+1 | |
sty irq_proc+2 | |
sta $d012 | |
lda #<irq_hard | |
sta $fffe | |
lda #>irq_hard | |
sta $ffff | |
inc $d019 | |
pla | |
sta $01 | |
jmp $ea7e | |
//---------------------------------------- | |
irq_proc: | |
jmp * | |
//---------------------------------------- | |
irq_none: | |
lda #$00 | |
ldx #<irq_none | |
ldy #>irq_none | |
rts | |
//---------------------------------------- | |
irq_reset: | |
lda #$00 | |
ldx #<irq_none | |
ldy #>irq_none | |
jmp irq_setup_addr | |
//---------------------------------------- | |
irq_setup_addr: | |
sei | |
sta $d012 | |
stx irq_proc+1 | |
sty irq_proc+2 | |
bcs *+3 | |
cli | |
rts | |
//---------------------------------------- | |
raster_wait: | |
bit $d012 | |
bmi *+7 | |
bit $d012 | |
bpl *-3 | |
bit $d012 | |
bmi *-3 | |
rts | |
//---------------------------------------- | |
msx_play_exec: | |
rts | |
// inc $d020 | |
.const music_addr_lo = *+1 | |
.const music_addr_hi = *+2 | |
jsr $ffff | |
// dec $d020 | |
// Increment synchronisation counter SYNCHRO_COUNTER: | |
inc SYNCHRO_COUNTER + 0 | |
bne *+4 | |
inc SYNCHRO_COUNTER + 1 | |
rts | |
//---------------------------------------- | |
.macro msx_setup_play(init,play) | |
{ | |
ldx #<play | |
ldy #>play | |
stx music_addr_lo | |
sty music_addr_hi | |
// Enable music play routine within any IRQ procedure: | |
lda #$ea ; nop | |
sta msx_play_exec | |
// Reset synchronisation timer: | |
lda #$00 | |
sta SYNCHRO_COUNTER + 0 | |
sta SYNCHRO_COUNTER + 1 | |
// Initialise soundtrack: | |
lda #$00 | |
tax | |
tay | |
jsr init | |
} | |
//---------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment