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