MSU1 AV player demo

This commit is contained in:
ikari 2010-12-29 15:12:09 +01:00
parent e0b817e17c
commit d6e7623463
8 changed files with 119 additions and 34 deletions

View File

@ -1,4 +1,4 @@
OBJS = header.ips reset.o65 main.o65 data.o65 const.o65 dma.o65 msu1.o65 # gfx.o65 # vars.o65 OBJS = header.ips reset.o65 main.o65 data.o65 const.o65 dma.o65 msu1.o65 spc.o65 # gfx.o65 # vars.o65
all: msu1vid.sfc all: msu1vid.sfc

View File

@ -14,11 +14,9 @@ hdma_blank .byt 40
; h/vscroll: write to $210d twice, write to $210e twice (mode 3) ; h/vscroll: write to $210d twice, write to $210e twice (mode 3)
; adjust hscroll and vscroll to split one tilemap row into two display rows ; adjust hscroll and vscroll to split one tilemap row into two display rows
; (tilemap memory saving measure) ; in conjunction with 16x16 tiles this reduces the effective tilemap size
hdma_scroll .byt 40 ; to 288 bytes
.word 0 hdma_scroll .byt 56
.word 511
.byt 16
.word 0 .word 0
.word 152+255 .word 152+255
.byt 16 .byt 16
@ -51,13 +49,13 @@ hdma_scroll .byt 40
; tilemap address switch: write to $2107 once (mode 0) ; tilemap address switch: write to $2107 once (mode 0)
; last row of tilemap is located elsewhere due to size ; last row of tilemap is located elsewhere due to size
hdma_tilemap .byt 40 hdma_tilemap .byt 40
.byt $3c .byt $bc
.byt 127 .byt 127
.byt $3c .byt $bc
.byt 1 .byt 1
.byt $3c .byt $bc
.byt 1 .byt 1
.byt $7c .byt $fc
.byt 0 .byt 0
; tilemap part 1 (goes to VRAM 7F00-7FFF) ; tilemap part 1 (goes to VRAM 7F00-7FFF)
@ -89,3 +87,29 @@ tilemap .word $0000, $0000, $0002, $0004, $0006, $0008, $000a, $000c
tilemap2 .word $0000, $01c0, $01c2, $01c4, $01c6, $01c8, $01ca, $01cc tilemap2 .word $0000, $01c0, $01c2, $01c4, $01c6, $01c8, $01ca, $01cc
.word $01ce, $01e0, $01e2, $01e4, $01e6, $01e8, $01ea, $0000 .word $01ce, $01e0, $01e2, $01e4, $01e6, $01e8, $01ea, $0000
spcaddr .word $0100 ; target address
spcexec .word $0100 ; execute address
spclen .byt 100 ; length
spccode .byt $e8, $6c ; - MOV A, #$6c
.byt $c4, $f2 ; MOV $f2, A
.byt $e8, $20 ; MOV A, #$20
.byt $c4, $f3 ; MOV $f3, A
.byt $78, $20, $f3 ; CMP $f3, #$20
.byt $d0, $f3 ; BNE -
.byt $e8, $2c ; - MOV A, #$6c
.byt $c4, $f2 ; MOV $f2, A
.byt $e8, $00 ; MOV A, #$20
.byt $c4, $f3 ; MOV $f3, A
.byt $78, $00, $f3 ; CMP $f3, #$20
.byt $d0, $f3 ; BNE -
.byt $e8, $3c ; - MOV A, #$6c
.byt $c4, $f2 ; MOV $f2, A
.byt $e8, $00 ; MOV A, #$20
.byt $c4, $f3 ; MOV $f3, A
.byt $78, $00, $f3 ; CMP $f3, #$20
.byt $d0, $f3 ; BNE -
.byt $2f, $fe ; - BRA -

View File

@ -49,10 +49,12 @@ setup_hdma:
sty $4332 sty $4332
sta $4334 sta $4334
ldx #184 ;Set IRQ trigger to line 184 ldx #185 ;Set IRQ trigger to line 185
stx $4209 ; stx $4209 ;
lda #$a1 ;NMI + V-Count IRQ + Auto Joypad Read lda #$21 ;V-Count IRQ + Auto Joypad Read
sta $4200 sta $4200
lda #$0e
sta $420c
rts rts

View File

@ -9,23 +9,22 @@ RESET:
jmp @GAME_MAIN jmp @GAME_MAIN
NMI_16bit: NMI_16bit:
php pha
rep #$30 : .al : .xl sep #$20 : .as
pha: phx: phy: phd: phb lda $4210 ; ack interrupt
jsl @NMI_ROUTINE lda #$0e
rep #$30 : .al : .xl sta $420c ; enable HDMA ch. 1-3
int_exit: pla
plb: pld: ply: plx: pla
plp
rti rti
IRQ_16bit: IRQ_16bit:
php pha
rep #$30 : .al : .xl sep #$20 : .as
pha: phx: phy: phd: phb lda #$01
jsl @IRQ_ROUTINE sta isr_flag
rep #$30 : .al : .xl lda $4211 ;Acknowledge irq
bra int_exit pla
rti
;error vectors ;error vectors
ABT_8bit: ABT_16bit: ABT_8bit: ABT_16bit:

View File

@ -6,6 +6,7 @@ GAME_MAIN:
jsr killdma jsr killdma
jsr waitblank jsr waitblank
jsr snes_init jsr snes_init
jsr spc_upload
lda #$01 lda #$01
sta $420d ; fast cpu sta $420d ; fast cpu
jsr setup_gfx jsr setup_gfx
@ -148,8 +149,7 @@ snes_init:
stz $420a ; stz $420a ;
stz $420b ; stz $420b ;
stz $420c ; stz $420c ;
lda #$01 stz $420d ; FAAAAAST
sta $420d ; FAAAAAST
lda #$8f lda #$8f
sta $2100 ;INIDISP: force blank sta $2100 ;INIDISP: force blank
stz $2101 ; stz $2101 ;

View File

@ -9,6 +9,10 @@ msu1init:
stx MSU_SEEK_BANK stx MSU_SEEK_BANK
- bit MSU_STATUS - bit MSU_STATUS
bmi - bmi -
stx MSU_TRACK
- bit MSU_STATUS
bvs -
ldx #$0000 ldx #$0000
stx $2116 stx $2116
@ -27,6 +31,8 @@ msu1loop:
sep #$20 : .as sep #$20 : .as
rep #$10 : .xl rep #$10 : .xl
stz dispcnt stz dispcnt
lda #$01
sta MSU_CONTROL
msu1loop2 msu1loop2
lda isr_flag lda isr_flag
beq msu1loop2 beq msu1loop2
@ -45,7 +51,6 @@ msu1loop2
cmp #$02 cmp #$02
bne msu1loop2 bne msu1loop2
stz dispcnt
;load palette ;load palette
stz $2121 stz $2121
lda #$22 lda #$22
@ -56,6 +61,7 @@ msu1loop2
stx $4305 stx $4305
lda #$01 lda #$01
sta $420b sta $420b
stz dispcnt
lda charptr lda charptr
bne ptr2 bne ptr2
ptr1 ptr1
@ -64,10 +70,10 @@ ptr1
sta charptr sta charptr
ldx #$0000 ldx #$0000
stx $2116 stx $2116
bra msu1loop2 jmp msu1loop2
ptr2 ptr2
stz $210b stz $210b
stz charptr stz charptr
ldx #$4000 ldx #$4000
stx $2116 stx $2116
bra msu1loop2 jmp msu1loop2

View File

@ -11,16 +11,20 @@
; NMI - called on VBlank ; NMI - called on VBlank
NMI_ROUTINE: NMI_ROUTINE:
sep #$20 : .as sep #$20 : .as
pha
lda $4210 ; ack interrupt lda $4210 ; ack interrupt
lda #$0e ; lda #$0e
sta $420c ; enable HDMA ch. 1-3 ; sta $420c ; enable HDMA ch. 1-3
pla
rtl rtl
; IRQ - called when triggered ; IRQ - called when triggered
IRQ_ROUTINE: IRQ_ROUTINE:
sep #$20 : .as sep #$20 : .as
pha
lda $4211 ;Acknowledge irq
lda #$01 lda #$01
sta isr_flag sta isr_flag
lda $4211 ;Acknowledge irq pla
rtl rtl

50
snes/msu1/spc.a65 Normal file
View File

@ -0,0 +1,50 @@
spc_upload:
rep #$20 : .al
sep #$10 : .xs
lda #$bbaa ; wait for IPL bootup
- cmp $2140
bne -
; IPL protocol: $2142-3 = target address
lda @spcaddr
sta $2142
ldx #$01
stx $2141
ldx #$cc
stx $2140
; wait for echo
- cpx $2140
bne -
; init counters
sep #$20 : .as
ldx #$00 ; sequence counter
lda @spclen
tay ; countdown
spc_loop
lda @spccode, x ; fill data byte
sta $2141 ; write data...
stx $2140 ; ...and write sequence counter
- cpx $2140 ; wait for echo from IPL
bne -
inx ; increment sequence counter...
dey
bne spc_loop ; if not, do it again
spc_end
rep #$20 : .al
lda @spcexec
sta $2142
stz $2141 ; data = 0
ldx $2140
inx
inx
stx $2140 ; send sequence end / execute
- cpx $2140 ; wait for last echo
bne -
sep #$20 : .as
rep #$10 : .xl
rts ; and done!