; xkas ; register definitions MSU_STATUS = $2000 MSU_READ = $2001 MSU_ID = $2002 MSU_SEEK = $2000 MSU_TRACK = $2004 MSU_VOLUME = $2006 MSU_CONTROL = $2007 CheckForMSU: ; assuming 16-bit xy ldx MSU_ID ; cpx.w #$2D53 ; 'S-' bne NoMSU ldx MSU_ID + 2 cpx.w #$534D ; 'MS' bne NoMSU ldx MSU_ID + 4 cpx.w #$3155 ; 'U1' bne NoMSU MSUFound: ; Do something when it's detected... jsr PlayMSUTrack rts NoMSU: ; Jump somewhere else when it's not... rts PlayMSUTrack: lda #$FF sta MSU_VOLUME ldx #$0001 ; Writing a 16-bit value will automatically set $2005 as well stx MSU_TRACK lda #$01 ; Set audio state to play, no repeat. sta MSU_CONTROL rts PlayMSUTrack_WithLooping: lda #$FF sta MSU_VOLUME ldx #$0001 ; Writing a 16-bit value will automatically set $2005 as well stx MSU_TRACK lda #$03 ; Set audio state to play, with repeat. sta MSU_CONTROL rts SeekMSUData: ldx #$0410 ; seek to $00000410 stx MSU_SEEK ldx #$0000 stx MSU_SEEK+2 - bit MSU_STATUS ; Wait for the Data Busy bit to clear. bmi - rts LoadTilemapFromMSU: ; to load a tileset, do the same thing but load the data directly ; (no separate tile/attribute bytes) ldx #$4000 ; Set target address stx VMADDL ; to VRAM ldy #$0000 ; Initialize counter - lda MSU_DATA ; Grab tile byte sta VMDATAL iny lda MSU_DATA ; Grab attribute byte sta VMDATAH iny cpy #$0800 ; length of $800 bytes bne - rts LoadPaletteFromMSU: lda #$10 ; Set starting point - color #16 sta CGADD ldy #$0000 ; Initialize counter - lda MSU_DATA sta CGADD iny cpy #$20 ; Colors are 16-bit values, so we must copy 32 bytes, not 16. bne - rts