There is now a small header for the MSU video files: uint16_t framecount; uint8_t std_frameduration; uint8_t alt_frameduration; uint8_t alt_durfreq; framecount is the number of frames in the video. std_frameduration is the usual duration of a video frame in SNES video frames. alt_frameduration is an alternate duration alt_durfreq specifies after how many frames the alternate duration should be used for a single video frame. The frame counter is reset afterwards. This allows to use simple pulldown patterns. e.g. for a 29.97fps video you need 2:2 pulldown (display every video frame for two SNES video frames). In this case, std_frameduration, alt_frameduration, alt_durfreq are: 2, 2, x (any number is good for the freq in this case) For 23.976fps video one would do 3:2 pulldown (displaying every other video frame for three SNES video frames). The format would be: 2, 3, 1 Frame size is always 224x144, 32512 bytes (4 tiles wasted to save tilemap memory), followed by 512 bytes of palette.
129 lines
1.8 KiB
Plaintext
129 lines
1.8 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 numframes
|
|
dex
|
|
|
|
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
|
|
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
|
|
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
|
|
- bra -
|
|
|