158 lines
2.2 KiB
Plaintext
158 lines
2.2 KiB
Plaintext
#include "dma.i65"
|
|
#include "msu1.i65"
|
|
|
|
msu1init:
|
|
sep #$20 : .as
|
|
rep #$10 : .xl
|
|
ldx #$0000
|
|
stx MSU_SEEK_OFFSET
|
|
stx MSU_SEEK_BANK
|
|
- bit MSU_STATUS
|
|
bmi -
|
|
|
|
stx MSU_TRACK
|
|
- bit MSU_STATUS
|
|
bvs -
|
|
ldx #$0000
|
|
stx $2116
|
|
|
|
lda #$04
|
|
sta charptr
|
|
sta $210b
|
|
|
|
; prepare DMA
|
|
ldx #$2001
|
|
stx $4302
|
|
stz $4304
|
|
|
|
lda #$01
|
|
sta firstframe
|
|
|
|
rts
|
|
|
|
|
|
msu1loop:
|
|
sep #$20 : .as
|
|
rep #$10 : .xl
|
|
stz dispcnt
|
|
lda $2001
|
|
sta numframes
|
|
lda $2001
|
|
sta numframes+1
|
|
lda $2001
|
|
sta curdur
|
|
sta stddur
|
|
lda $2001
|
|
sta altdur
|
|
lda $2001
|
|
sta altcnt
|
|
lda #$01
|
|
sta curcnt
|
|
ldx #$0000
|
|
stx $1000 ;temp var
|
|
ldx numframes
|
|
dex
|
|
lda #$21 ;V-Count IRQ + Auto Joypad Read
|
|
sta $4200
|
|
|
|
lda numframes
|
|
sta @$306000
|
|
lda numframes+1
|
|
sta @$306001
|
|
lda stddur
|
|
sta @$306002
|
|
lda altdur
|
|
sta @$306003
|
|
lda altcnt
|
|
sta @$306004
|
|
lda curdur
|
|
sta @$306005
|
|
lda curcnt
|
|
sta @$306006
|
|
msu1loop2
|
|
lda isr_flag
|
|
beq msu1loop2
|
|
stz isr_flag
|
|
lda dispcnt ;load field count
|
|
cmp #$02 ;if >= 2 don't draw anymore
|
|
bpl +
|
|
;load half picture
|
|
lda #$18
|
|
phx
|
|
ldx $1000
|
|
sta @$306100, x
|
|
inx
|
|
stx $1000
|
|
plx
|
|
sta $4301
|
|
lda #$09
|
|
sta $4300
|
|
ldy #16256
|
|
sty $4305
|
|
lda #$01
|
|
sta $420b
|
|
+ inc dispcnt ;inc field count
|
|
lda dispcnt ;and compare with current duration
|
|
phx
|
|
ldx $1000
|
|
sta @$306100, x
|
|
inx
|
|
stx $1000
|
|
plx
|
|
cmp curdur ;if not reached...
|
|
bne msu1loop2 ;...wait another field
|
|
|
|
lda firstframe ;first frame ready for display?
|
|
beq +
|
|
|
|
lda #$01 ;then start audio
|
|
sta MSU_CONTROL
|
|
stz firstframe
|
|
|
|
+
|
|
lda curcnt ;
|
|
cmp altcnt ;compare with alternation frequency
|
|
bne + ;if reached...
|
|
stz curcnt ;...reset current frame count
|
|
lda altdur ;use alternate duration for next frame
|
|
bra skip
|
|
+ lda stddur ;else use normal duration
|
|
inc curcnt ;and inc current frame count
|
|
skip sta curdur ;store in current duration
|
|
stz dispcnt ;reset field counter
|
|
dex ;countdown total frames
|
|
beq msu1stop ;stop if end of movie
|
|
|
|
;load palette
|
|
stz $2121
|
|
lda #$22
|
|
sta $4301
|
|
lda #$08
|
|
sta $4300
|
|
ldy #512
|
|
sty $4305
|
|
lda #$01
|
|
sta $420b
|
|
lda charptr
|
|
bne ptr2
|
|
ptr1
|
|
lda #$04
|
|
sta $210b
|
|
sta charptr
|
|
ldy #$0000
|
|
sty $2116
|
|
jmp msu1loop2
|
|
ptr2
|
|
stz $210b
|
|
stz charptr
|
|
ldy #$4000
|
|
sty $2116
|
|
jmp msu1loop2
|
|
|
|
msu1stop:
|
|
; lda #$80
|
|
; sta $2100
|
|
; stz $420c
|
|
stz MSU_CONTROL
|
|
rts
|