Files
CDi_MiSTer/sim2/testroms/vmpeg_scan_test.asm
2026-01-25 11:37:39 +01:00

255 lines
5.8 KiB
NASM
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
section .text
org $400000
vector:
dc.l $1234
dc.l main
main:
move.w #$0000,$303FFE ; Data buffer
move.w #$2000,$E040C0 ; FMV SYSCMD - Decoder off
nop
move.w #$0100,$E040C0 ; FMV SYSCMD - Clear FIFO
nop
move.w #$1000,$E040C0 ; FMV SYSCMD - Decoder on
move.w #$02D4,$E040DC ; FMV IVEC
move.w #$F7CF,$E04060 ; FMV IER
move.l #fmvirq,$168
move.w #$807B,$E0300C ; FMA IVEC
move.w #$013C,$E0301C ; FMA IER
move.l #fmairq,$1EC
move.w #$2480,$303FFC ; CDIC IVEC
move.l #cdicirq,$200
move #$2000,SR
move.w #$0024,$303C00 ; Command Register = Reset Mode 2
move.w #$8000,$303FFE ; Data buffer
; #$01274700 Dragon's Lair Intro
; #$00323400 FMVtest
; #$00397400 7th Guest Philips Logo
; #$55387000 7th Guest ?
; #$01341100 Space Ace Intro
; #$02140600 Space Ace Intro - Nearly the end (15 frames left)
; #$00425900 2 Unlimited Beyond Limits (Channel 0001)
; #$42252600 Burger King - Multilanguage?
; #$00152100 VideoCD Example (Channel ffff)
; #$01164500 Coneheads (USA)
; #$01414300 Coneheads (USA) Continue
move.w #$002a,$303C00 ; Read Mode 2
move.w #$0100,$303C06 ; File Register
move.l #$ffffffff,$303C08 ; Channel Register
move.w #$0000,$303C0C ; Audio Channel Register
move.l #$01164500,$303C02 ; Timer Register
move.w #$C000,$303FFE ; Start the Read by setting bit 15 of the data buffer
jsr WaitForSectorAndUse
jsr WaitForSectorAndUse
lea timecodes,a2
seek_forward:
; We assume that the sequence header was decoded by now
; Now stop the playback and continue at a different position
move.w #$0000,$303FFE ; Stop reading from disc
move.l (a2)+,$303C02 ; Timer Register
move.w #$C000,$303FFE ; Start the Read by setting bit 15 of the data buffer
move.w #$0100,$E040C0 ; FMV SYSCMD - Clear FIFO
move.b #'Z',$80002019
; Search for one picture to show
waitforpics:
jsr WaitForSectorAndUse
cmp.w #1,$00E040A4
bmi waitforpics
move.b #'B',$80002019
; And repeat ...
bra seek_forward
timecodes:
dc.l $02050000
dc.l $03000000
dc.l $03050000
dc.l $04000000
dc.l $04050000
dc.l $05000000
dc.l $05050000
dc.l $06000000
dc.l $06050000
dc.l $07000000
dc.l $07050000
dc.l $08000000
dc.l $08050000
dc.l $09000000
dc.l $09050000
dc.l $10000000
dc.l $10050000
dc.l $11000000
dc.l $11050000
dc.l $12000000
dc.l $12050000
dc.l $13000000
dc.l $13050000
dc.l $14000000
dc.l $14050000
dc.l $15000000
dc.l $15050000
dc.l $16000000
dc.l $16050000
dc.l $17000000
dc.l $17050000
dc.l $18000000
dc.l $18050000
dc.l $19000000
dc.l $19050000
dc.l $20000000
dc.l $20050000
dc.l $21000000
dc.l $21050000
dc.l $22000000
dc.l $22050000
dc.l $23000000
dc.l $23050000
dc.l $24000000
dc.l $24050000
dc.l $25000000
dc.l $25050000
dc.l $26000000
dc.l $26050000
dc.l $27000000
dc.l $27050000
dc.l $28000000
dc.l $28050000
dc.l $29000000
dc.l $29050000
WaitForSectorAndUse:
jsr waitforcdicirq
; We need to check for the Mode 2 header now. It can be either MPEG Audio or MPEG Video
; MPEG Video should have submode 0x62 (Real Time Sector, Form and Video)
; followed by a coding of 0x0f (for MPEG Video)
; MPEG Audio should have 0x64 (Real Time Sector, Form and Video)
; followed by a coding of 0x7f (for MPEG Audio)
move.b 10(a0),d2
cmp.b #$64,d2
beq audio
cmp.b #$62,d2
beq video
rts
audio:
; DMA CDIC to Memory
move.b d0,$80004000 ; reset status
move.l #$3000,$8000400c ; Memory Address Counter
move.w #$480,$8000400a ; Size for MPEG Audio
move.b #$92,$80004005 ; Dev. to Mem., 16 Bit Words,
move.b #$80,$80004007 ; start DMA
move.w d1,$303FF8 ; DMA Control Register = Start Transmission at a00
; DMA Memory to FMA
move.b d0,$80004040 ; reset status
move.l #$3000,$8000404c ; Memory Address Counter
move.w #$480,$8000404a ; Memory Transfer Counter
move.b #$04,$80004046 ; SCR, MAC Count Up, DAC No Change (like the CDIC on CH1)
move.b #$12,$80004045 ; Dev. to Mem., 16 Bit Words,
move.b #$30,$80004044 ; ACK/RDY device (like the CDIC on CH1)
move.b #$80,$80004047 ; start DMA
move.w #$8002,$00E03000 ; Syscmd = Start DMA
; Continue loop
rts
video:
; DMA CDIC to Memory
move.b d0,$80004000 ; reset status
move.l #$3000,$8000400c ; Memory Address Counter
move.w #$48a,$8000400a ; Size for MPEG Video
move.b #$92,$80004005 ; Dev. to Mem., 16 Bit Words,
move.b #$80,$80004007 ; start DMA
move.w d1,$303FF8 ; DMA Control Register = Start Transmission at a00
; DMA Memory to FMV
; The original driver uses 0x484 for memory transfer counter
; since the first 6 words are transferred via CPU to XFER
; We are doing the same
move.w $3000,$0e040de
move.w $3002,$0e040de
move.w $3004,$0e040de
move.w $3006,$0e040de
move.w $3008,$0e040de
move.w $300a,$0e040de
move.b d0,$80004040 ; reset status
move.l #$300c,$8000400c ; Memory Address Counter
move.w #$484,$8000404a ; Memory Transfer Counter
move.b #$04,$80004046 ; SCR, MAC Count Up, DAC No Change (like the CDIC on CH1)
move.b #$12,$80004045 ; Dev. to Mem., 16 Bit Words,
move.b #$30,$80004044 ; ACK/RDY device (like the CDIC on CH1)
move.b #$80,$80004047 ; start DMA
move.w #$8000,$00E040C0 ; Syscmd = Start DMA
rts
waitforcdicirq:
move #0,d0
waitforcdicirqloop:
cmp #0,d0
beq waitforcdicirqloop
move.b #'O',$80002019
rts
cdicirq:
move.b #'I',$80002019
move.w $303FF4,d0 ; clear flags on ABUFD
; ignore ABUF
move.w $303FF6,d0 ; clear flags on XBUF
btst.l #$f,d0
beq noint
move.w $303FFe,d0
btst.l #$0,d0 ; check lowest bit of data buffer
beq lower_buf
higher_buf:
move.w #$8a0c,d1 ; DMA Control for 0x0A0C
move.l #$300a00,a0 ; Buffer location in CDIC memory
bra read_data
lower_buf:
move.w #$800c,d1 ; DMA Control for 0x000C
move.l #$300000,a0 ; Buffer location in CDIC memory
read_data:
; Highest bit is set
move #1,d0
rte
noint:
move #0,d0
rte
fmvirq:
move.b #'V',$80002019
move $00E04062,d7
rte
fmairq:
move.b #'A',$80002019
move $00E0301A,d7
rte