MSU1 video player update (framerate support)
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.
This commit is contained in:
parent
a701dfbe2e
commit
b964f1fa7b
@ -2,11 +2,11 @@
|
||||
|
||||
dispcnt .byt 0
|
||||
|
||||
stddur .byt 0
|
||||
altdur .byt 0
|
||||
altcnt .byt 0
|
||||
curdur .byt 0
|
||||
curcnt .byt 0
|
||||
stddur .byt 0 ; standard picture duration in fields
|
||||
altdur .byt 0 ; alternate picture duration in fields
|
||||
altcnt .byt 0 ; use alternate picture duration every n frames
|
||||
curdur .byt 0 ; current valid duration
|
||||
curcnt .byt 0 ; current frame count for picture duration
|
||||
numframes .word 0
|
||||
firstframe .byt 0
|
||||
charptr .byt 0
|
||||
|
||||
@ -46,52 +46,52 @@ msu1loop:
|
||||
sta altdur
|
||||
lda $2001
|
||||
sta altcnt
|
||||
stz curcnt
|
||||
ldy numframes
|
||||
dey
|
||||
lda #$01
|
||||
sta curcnt
|
||||
ldx numframes
|
||||
dex
|
||||
|
||||
msu1loop2
|
||||
lda isr_flag
|
||||
beq msu1loop2
|
||||
stz isr_flag
|
||||
lda dispcnt
|
||||
cmp #$02
|
||||
beq +
|
||||
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
|
||||
ldx #16256
|
||||
stx $4305
|
||||
ldy #16256
|
||||
sty $4305
|
||||
lda #$01
|
||||
sta $420b
|
||||
+ inc dispcnt
|
||||
lda dispcnt
|
||||
cmp curdur
|
||||
bne msu1loop2
|
||||
+ inc dispcnt ;inc field count
|
||||
lda dispcnt ;and compare with current duration
|
||||
cmp curdur ;if not reached...
|
||||
bne msu1loop2 ;...wait another field
|
||||
|
||||
lda firstframe
|
||||
lda firstframe ;first frame ready for display?
|
||||
beq +
|
||||
|
||||
lda #$01
|
||||
lda #$01 ;then start audio
|
||||
sta MSU_CONTROL
|
||||
stz firstframe
|
||||
|
||||
+
|
||||
inc curcnt
|
||||
lda curcnt
|
||||
cmp altcnt
|
||||
bne +
|
||||
stz curcnt
|
||||
lda altdur
|
||||
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
|
||||
skip sta curdur
|
||||
stz dispcnt
|
||||
dey
|
||||
beq msu1stop
|
||||
+ 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
|
||||
@ -99,8 +99,8 @@ skip sta curdur
|
||||
sta $4301
|
||||
lda #$08
|
||||
sta $4300
|
||||
ldx #512
|
||||
stx $4305
|
||||
ldy #512
|
||||
sty $4305
|
||||
lda #$01
|
||||
sta $420b
|
||||
lda charptr
|
||||
@ -109,14 +109,14 @@ ptr1
|
||||
lda #$04
|
||||
sta $210b
|
||||
sta charptr
|
||||
ldx #$0000
|
||||
stx $2116
|
||||
ldy #$0000
|
||||
sty $2116
|
||||
jmp msu1loop2
|
||||
ptr2
|
||||
stz $210b
|
||||
stz charptr
|
||||
ldx #$4000
|
||||
stx $2116
|
||||
ldy #$4000
|
||||
sty $2116
|
||||
jmp msu1loop2
|
||||
|
||||
msu1stop:
|
||||
|
||||
@ -76,7 +76,7 @@ int main(int argc, char **argv) {
|
||||
char inpal[768], outpal[512];
|
||||
|
||||
FILE *in, *out;
|
||||
int fileno=1;
|
||||
int fileno=0, startframe=0;
|
||||
uint16_t numcolors;
|
||||
char filename[80];
|
||||
out=fopen("out.msu", "wb");
|
||||
@ -87,7 +87,14 @@ int main(int argc, char **argv) {
|
||||
fwrite(&filename, 5, 1, out); /* write padding for now */
|
||||
while(1) {
|
||||
sprintf(filename, "%08d.tga", fileno++);
|
||||
if((in=fopen(filename, "rb"))==NULL) break;
|
||||
if((in=fopen(filename, "rb"))==NULL) {
|
||||
if(fileno==1) {
|
||||
startframe = 1;
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
fseek(in, 5, SEEK_SET);
|
||||
fread(&numcolors, 2, 1, in);
|
||||
fseek(in, 18, SEEK_SET);
|
||||
@ -104,6 +111,7 @@ int main(int argc, char **argv) {
|
||||
convertpalette(inpal, outpal);
|
||||
fwrite(outpal, 512, 1, out);
|
||||
}
|
||||
fileno-=startframe;
|
||||
numframes_l=fileno&0xff;
|
||||
numframes_h=fileno>>8;
|
||||
fseek(out, 0, SEEK_SET);
|
||||
|
||||
@ -6,10 +6,13 @@ spc_upload:
|
||||
- cmp $2140
|
||||
bne -
|
||||
|
||||
; IPL protocol: $2142-3 = target address
|
||||
; IPL portmap outside transfer state:
|
||||
; $2141 = command (transfer / run)
|
||||
; $2142-3 = target address
|
||||
; $2140 = trigger
|
||||
lda @spcaddr
|
||||
sta $2142
|
||||
ldx #$01
|
||||
ldx #$01 ; transfer
|
||||
stx $2141
|
||||
ldx #$cc
|
||||
stx $2140
|
||||
@ -17,6 +20,9 @@ spc_upload:
|
||||
- cpx $2140
|
||||
bne -
|
||||
|
||||
; IPL portmap inside transfer state:
|
||||
; $2140 = sequence number
|
||||
; $2141 = payload
|
||||
; init counters
|
||||
sep #$20 : .as
|
||||
ldx #$00 ; sequence counter
|
||||
@ -35,8 +41,8 @@ spc_loop
|
||||
spc_end
|
||||
rep #$20 : .al
|
||||
lda @spcexec
|
||||
sta $2142
|
||||
stz $2141 ; data = 0
|
||||
sta $2142 ; set exec address
|
||||
stz $2141 ; command: run
|
||||
ldx $2140
|
||||
inx
|
||||
inx
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user