BIOSF UPLOAD

From NeoGeo Development Wiki
Revision as of 00:44, 15 December 2011 by Furrtek (talk | contribs)
Jump to navigation Jump to search

BIOSF_UPLOAD ($C00546): Upload data to DRAM

BIOS_UPSRC      (32bit): Source (Long)
BIOS_UPDEST     (32bit): Destination (Long)
BIOS_UPSIZE     (32bit): Size (Long)
BIOS_UPZONE     $10FEDA (8bit):  Zone (Byte, 0=PRG, 1=FIX, 2=SPR, 3=Z80, 4=PCM, 5=PAT)
BIOS_UPBANK     (8bit):  Bank (Byte)

For FIX, Z80 (, PAT ?) and PCM upload, the destination has to be multiplied by 2 (8bit busses). The SPR bank size is 1MiB (4 banks), PCM bank size is 512KiB (4 banks). The other zones aren't banked.

BIOS_UPDEST (and BIOS_UPSRC ?) is incremented by the size upon completion, which allows to do multiple consecutive uploads.

Steps

  • $FF0004.w and $10FD80 are pushed
  • $FF0004.w = 1
  • $10FD80=0, system mode
  • BIOS_UPZONE anded with $F
  • Jump table
  • Subrout1
  • Copydata
  • BIOS_UPZONE anded with $F
  • Jump table
  • Subrout2
  • Restore $10FD80.w and $FF0004.w

Subrout1

  • BIOS_UPZONE=0: RTS
  • BIOS_UPZONE=1: $FF0129.b=0, $FF0105.b=5 (FIX set, upload type)
  • BIOS_UPZONE=2: $FF0121.b=0, $FF0105.b=0, $FF01A1.b=UploadBank (SPR set, upload type)
  • BIOS_UPZONE=3: $FF0127.b=0, $FF0105.b=4 (Z80 set, upload type)
  • BIOS_UPZONE=4: $FF0123.b=0, $FF0105.b=1, $FF01A3.b=UploadBank (PCM set, upload type)
  • BIOS_UPZONE=5: RTS
  • BIOS_UPZONE=6: RTS
  • BIOS_UPZONE=7: $FF0121.b=0, $FF0105.b=0, $FF01A1.b=UploadBank (SPR set, upload type)
  • BIOS_UPZONE=8: RTS
  • BIOS_UPZONE=9~F:RTS

Subrout2=

  • BIOS_UPZONE=0: RTS
  • BIOS_UPZONE=1: $FF0149.b=0 FIX unset
  • BIOS_UPZONE=2: $FF0141.b=0 SPR unset
  • BIOS_UPZONE=3: $FF0147.b=0 Z80 unset
  • BIOS_UPZONE=4: $FF0143.b=0 PCM unset
  • BIOS_UPZONE=5: RTS
  • BIOS_UPZONE=6: RTS
  • BIOS_UPZONE=7: $FF0141.b=0 SPR unset
  • BIOS_UPZONE=8: RTS
  • BIOS_UPZONE=9~F:RTS

Copydata

  • $FF016F.b=1 disable interrupts ?
  • BIOS_UPZONE anded with $1F
  • Jump table
  • BIOS_UPZONE=0:Upload PRG DMA

Load word copy microcode Dest=size+dest bsr LoadMicrocodeA0 ;0BEA6: 610000C8 moveq #0,d0 ;0BEAA: 7000 bsr DoDMAWordCopyBypass ;0BEAC: 61000038

  • BIOS_UPZONE=1:Upload Fix DMA

Load byte copy microcode bsr DoDMAWordCopy ;0BDDC: 61000102 Dest=Dest+(size*2)

  • BIOS_UPZONE=2:Upload Srites DMA

Load word copy microcode

	move.l	UploadSize(a5),32226(a5)	;0BD62: 2B6D7EFC7DE2
LAB_021A:
	move.l	32226(a5),d0		;0BD68: 202D7DE2
	beq.s	LAB_021C		;0BD6C: 675C
	add.l	UploadDest(a5),d0		;0BD6E: D0AD7EF4
	cmpi.l	#$00100000,d0		;0BD72: 0C8000100000
	bls.s	LAB_021B		;0BD78: 632E
	move.l	#$00100000,d0		;0BD7A: 203C00100000
	sub.l	UploadDest(a5),d0		;0BD80: 90AD7EF4
	move.l	d0,UploadSize(a5)		;0BD84: 2B407EFC
	move.l	32226(a5),d1		;0BD88: 222D7DE2
	sub.l	d0,d1			;0BD8C: 9280
	move.l	d1,32226(a5)		;0BD8E: 2B417DE2
	bsr	DoDMAWordCopy		;0BD92: 6100014C
	clr.l	UploadDest(a5)		;0BD96: 42AD7EF4
	addq.b	#1,UploadBank(a5)		;0BD9A: 522D7EDB
	move.b	UploadBank(a5),EXT_023D	;0BD9E: 13ED7EDB00FF01A1
	bra.s	LAB_021A		;0BDA6: 60C0
LAB_021B:
	bsr	DoDMAWordCopy		;0BDA8: 61000136
	move.l	UploadDest(a5),d0		;0BDAC: 202D7EF4
	add.l	UploadSize(a5),d0		;0BDB0: D0AD7EFC
	cmpi.l	#$00100000,d0		;0BDB4: 0C8000100000
	bcs.s	LAB_021C		;0BDBA: 650E
	clr.l	d0			;0BDBC: 4280
	addq.b	#1,UploadBank(a5)		;0BDBE: 522D7EDB
	move.b	UploadBank(a5),EXT_023D	;0BDC2: 13ED7EDB00FF01A1
LAB_021C:
	move.l	d0,UploadDest(a5)		;0BDCA: 2B407EF4
	rts				;0BDCE: 4E75
  • BIOS_UPZONE=3 Upload Z80 DMA

lea MicrocodeByteCopy(pc),a0 ;0BE84: 41FA0214 bsr LoadMicrocodeA0 ;0BE88: 610000E6 bsr DoDMAWordCopy ;0BE8C: 61000052 move.l UploadDest(a5),d0 ;0BE90: 202D7EF4 add.l UploadSize(a5),d0 ;0BE94: D0AD7EFC add.l UploadSize(a5),d0 ;0BE98: D0AD7EFC move.l d0,UploadDest(a5) ;0BE9C: 2B407EF4 rts ;0BEA0: 4E75

  • BIOS_UPZONE=4

UploadCopyPCMMethod0: lea MicrocodeByteCopy(pc),a0 ;0BDF2: 41FA02A6 bsr LoadMicrocodeA0 ;0BDF6: 61000178 move.l UploadSize(a5),32226(a5) ;0BDFA: 2B6D7EFC7DE2 LAB_021E: move.l 32226(a5),d0 ;0BE00: 202D7DE2 beq.s LAB_0221 ;0BE04: 6756 add.l d0,d0 ;0BE06: D080 add.l UploadDest(a5),d0 ;0BE08: D0AD7EF4 cmpi.l #$00100000,d0 ;0BE0C: 0C8000100000 bhi.s LAB_021F ;0BE12: 6208 move.l 32226(a5),UploadSize(a5) ;0BE14: 2B6D7DE27EFC bra.s LAB_0220 ;0BE1A: 603C LAB_021F: move.l #$00100000,d0 ;0BE1C: 203C00100000 sub.l UploadDest(a5),d0 ;0BE22: 90AD7EF4 lsr.l #1,d0 ;0BE26: E288 move.l d0,UploadSize(a5) ;0BE28: 2B407EFC move.l 32226(a5),d1 ;0BE2C: 222D7DE2 sub.l d0,d1 ;0BE30: 9280 move.l d1,32226(a5) ;0BE32: 2B417DE2 bsr DoByteCopy ;0BE36: 61000112 clr.l UploadDest(a5) ;0BE3A: 42AD7EF4 addq.b #1,UploadBank(a5) ;0BE3E: 522D7EDB move.b UploadBank(a5),EXT_023E ;0BE42: 13ED7EDB00FF01A3 move.l UploadSrc(a5),d0 ;0BE4A: 202D7EF8 add.l UploadSize(a5),d0 ;0BE4E: D0AD7EFC move.l d0,UploadSrc(a5) ;0BE52: 2B407EF8 bra.s LAB_021E ;0BE56: 60A8 LAB_0220: bsr DoByteCopy ;0BE58: 610000F0 LAB_0221: move.l UploadDest(a5),d0 ;0BE5C: 202D7EF4 add.l UploadSize(a5),d0 ;0BE60: D0AD7EFC add.l UploadSize(a5),d0 ;0BE64: D0AD7EFC cmpi.l #$00100000,d0 ;0BE68: 0C8000100000 bcs.s LAB_0222 ;0BE6E: 650E clr.l d0 ;0BE70: 4280 addq.b #1,UploadBank(a5) ;0BE72: 522D7EDB move.b UploadBank(a5),EXT_023E ;0BE76: 13ED7EDB00FF01A3 LAB_0222: move.l d0,UploadDest(a5) ;0BE7E: 2B407EF4 rts ;0BE82: 4E75

  • BIOS_UPZONE=5

UploadCopyPATMethod0&1: move.b #$00,EXT_022D ;0BF98: 13FC000000FF0127 Z80 set move.b #$04,EXT_0224 ;0BFA0: 13FC000400FF0105 Upload type lea UPLOADZONE,a1 ;0BFA8: 43F900E00000 moveq #0,d0 ;0BFAE: 7000 move.b UploadBank(a5),d0 ;0BFB0: 102D7EDB swap d0 ;0BFB4: 4840 lsl.l #4,d0 ;0BFB6: E988 or.l UploadDest(a5),d0 ;0BFB8: 80AD7EF4 lsr.l #8,d0 ;0BFBC: E088 move d0,30518(a5) ;0BFBE: 3B407736 movea.l UploadSrc(a5),a0 ;0BFC2: 206D7EF8 moveq #0,d0 ;0BFC6: 7000

  • BIOS_UPZONE=6

lea MicrocodeWordCopy(pc),a0 ;0BEBE: 41FA01BC bsr LoadMicrocodeA0 ;0BEC2: 610000AC move.l #$00400000,d0 ;0BEC6: 203C00400000 bsr DoDMAWordCopyBypass ;0BECC: 61000018 move.l UploadDest(a5),d0 ;0BED0: 202D7EF4 add.l UploadSize(a5),d0 ;0BED4: D0AD7EFC move.l d0,UploadDest(a5) ;0BED8: 2B407EF4 rts ;0BEDC: 4E75 rts ;0BEDE: 4E75

  • BIOS_UPZONE=7

move.l #$00E00000,d0 ;0BC5A: 203C00E00000 add.l UploadDest(a5),d0 ;0BC60: D0AD7EF4 movea.l d0,a1 ;0BC64: 2240 movea.l UploadSrc(a5),a0 ;0BC66: 206D7EF8 moveq #0,d0 ;0BC6A: 7000 move.l (a0)+,d7 ;0BC6C: 2E18 beq.s LAB_0218 ;0BC6E: 6738 LAB_0215: move.l (a0)+,(a1)+ ;0BC70: 22D8 beq.s LAB_0216 ;0BC72: 6712 dbf d7,LAB_0215 ;0BC74: 51CFFFFA move.l a1,d0 ;0BC78: 2009 subi.l #$00E00000,d0 ;0BC7A: 048000E00000 move.l d0,UploadDest(a5) ;0BC80: 2B407EF4 rts ;0BC84: 4E75

  • BIOS_UPZONE=8

UploadCopyPRGMethod0: lea MicrocodeWordCopy(pc),a0 ;0BEA2: 41FA01D8 bsr LoadMicrocodeA0 ;0BEA6: 610000C8 moveq #0,d0 ;0BEAA: 7000 bsr DoDMAWordCopyBypass ;0BEAC: 61000038 move.l UploadDest(a5),d0 ;0BEB0: 202D7EF4 add.l UploadSize(a5),d0 ;0BEB4: D0AD7EFC move.l d0,UploadDest(a5) ;0BEB8: 2B407EF4 rts ;0BEBC: 4E75

  • BIOS_UPZONE=9~F:RTS

00 C0 BD 0E 00 C0 BC B6 00 C0 BC 48 00 C0 BC F8 00 C0 BC CC 00 C0 BF 98 00 C0 BD 3A 00 C0 BC 5A 00 C0 BD 0E 00 C0 BE DE 00 C0 BE DE 00 C0 BE DE 00 C0 BE DE 00 C0 BE DE 00 C0 BE DE 00 C0 BE DE

  • Watchdog kicked
  • $FF016F.b=0 enable interrupts ?