BIOSF UPLOAD

From NeoGeo Development Wiki
Revision as of 00:53, 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

Load byte copy microcode Dest=Dest+(size*2)

  • BIOS_UPZONE=4 Upload PCM DMA

Load byte copy microcode

	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
LAB_022D:
	move	(a0),d0			;0BFC8: 3010
	beq	LAB_0232		;0BFCA: 67000082
	move	2(a0),d1		;0BFCE: 32280002
	add	EXT_016D,d1		;0BFD2: D2790010F736
	lsr	#1,d1			;0BFD8: E249
	bsr	LAB_022F		;0BFDA: 61000046
	move	4(a0),d1		;0BFDE: 32280004
	add	EXT_016D,d1		;0BFE2: D2790010F736
	lsr	#1,d1			;0BFE8: E249
	subq	#1,d1			;0BFEA: 5341
	bsr	LAB_022F		;0BFEC: 61000034
	tst.l	6(a0)			;0BFF0: 4AA80006
	beq	LAB_022E		;0BFF4: 67000026
	addq	#1,d0			;0BFF8: 5240
	move	6(a0),d1		;0BFFA: 32280006
	add	EXT_016D,d1		;0BFFE: D2790010F736
	lsr	#1,d1			;0C004: E249
	bsr	LAB_022F		;0C006: 6100001A
	move	8(a0),d1		;0C00A: 32280008
	add	EXT_016D,d1		;0C00E: D2790010F736
	lsr	#1,d1			;0C014: E249
	subq	#1,d1			;0C016: 5341
	bsr	LAB_022F		;0C018: 61000008
LAB_022E:
	lea	10(a0),a0		;0C01C: 41E8000A
	bra.s	LAB_022D		;0C020: 60A6
LAB_022F:
	btst	#0,d0			;0C022: 08000000
	bne	LAB_0233		;0C026: 66000030
	move	d1,d3			;0C02A: 3601
	lsr	#8,d1			;0C02C: E049
	bsr	LAB_0230		;0C02E: 61000004
	move	d3,d1			;0C032: 3203
LAB_0230:
	move.l	d0,d2			;0C034: 2400
	add.l	d2,d2			;0C036: D482
	btst	#0,d0			;0C038: 08000000
	beq.s	LAB_0231		;0C03C: 6708
	move.b	d1,-1(a1,d2.l)		;0C03E: 138128FF
	addq	#1,d0			;0C042: 5240
	rts				;0C044: 4E75
  • 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

Same as 0

  • BIOS_UPZONE=9~F:RTS
  • BIOS_UPZONE=10
UploadCopyPRGMethod1:
	lea	MicrocodeWordCopy(pc),a0		;0BD0E: 41FA036C
	bsr	LoadMicrocodeA0		;0BD12: 6100025C
	moveq	#0,d0			;0BD16: 7000
	move	#$0031,EXT_0210		;0BD18: 33FC003100FF0004
	bsr	DoLongwordCopyBypass		;0BD20: 610001EA
	move	#$0331,EXT_0210		;0BD24: 33FC033100FF0004
	move.l	UploadDest(a5),d0		;0BD2C: 202D7EF4
	add.l	UploadSize(a5),d0		;0BD30: D0AD7EFC
	move.l	d0,UploadDest(a5)		;0BD34: 2B407EF4
	rts				;0BD38: 4E75

	lea	MicrocodeWordCopy(pc),a0		;0BD3A: 41FA0340
	bsr	LoadMicrocodeA0		;0BD3E: 61000230
	move.l	#$00400000,d0		;0BD42: 203C00400000
	bsr	DoLongwordCopyBypass		;0BD48: 610001C2
	move.l	UploadDest(a5),d0		;0BD4C: 202D7EF4
	add.l	UploadSize(a5),d0		;0BD50: D0AD7EFC
	move.l	d0,UploadDest(a5)		;0BD54: 2B407EF4
	rts				;0BD58: 4E75
  • BIOS_UPZONE=11
UploadCopyFIXMethod1:
	bsr	DoWordToByteCopy		;0BCB6: 6100026A
	move.l	UploadDest(a5),d0		;0BCBA: 202D7EF4
	add.l	UploadSize(a5),d0		;0BCBE: D0AD7EFC
	add.l	UploadSize(a5),d0		;0BCC2: D0AD7EFC
	move.l	d0,UploadDest(a5)		;0BCC6: 2B407EF4
	rts				;0BCCA: 4E75
  • BIOS_UPZONE=12
UploadCopySpritesMethod1:
	bsr		DoLongwordCopy		;0BC48: 610002BC
	move.l	UploadDest(a5),d0		;0BC4C: 202D7EF4
	add.l		UploadSize(a5),d0		;0BC50: D0AD7EFC
	move.l	d0,UploadDest(a5)		;0BC54: 2B407EF4
	rts				;0BC58: 4E75

	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=13
UploadCopyZ80Method1:
	bsr	DoByteCopy		;0BCF8: 61000250
	move.l	UploadDest(a5),d0		;0BCFC: 202D7EF4
	add.l	UploadSize(a5),d0		;0BD00: D0AD7EFC
	add.l	UploadSize(a5),d0		;0BD04: D0AD7EFC
	move.l	d0,UploadDest(a5)		;0BD08: 2B407EF4
	rts				;0BD0C: 4E75
  • BIOS_UPZONE=14
UploadCopyPCMMethod1:
	bsr	DoByteCopy		;0BCCC: 6100027C
	move.l	UploadDest(a5),d0		;0BCD0: 202D7EF4
	add.l	UploadSize(a5),d0		;0BCD4: D0AD7EFC
	add.l	UploadSize(a5),d0		;0BCD8: D0AD7EFC
	cmpi.l	#$00100000,d0		;0BCDC: 0C8000100000
	bcs.s	LAB_0219		;0BCE2: 650E
	addq.b	#1,UploadBank(a5)		;0BCE4: 522D7EDB
	move.b	UploadBank(a5),EXT_023E	;0BCE8: 13ED7EDB00FF01A3
	clr.l	d0			;0BCF0: 4280
LAB_0219:
	move.l	d0,UploadDest(a5)		;0BCF2: 2B407EF4
	rts				;0BCF6: 4E75
  • BIOS_UPZONE=15

Same as 5

  • BIOS_UPZONE=16
	lea	MicrocodeWordCopy(pc),a0		;0BD3A: 41FA0340
	bsr	LoadMicrocodeA0		;0BD3E: 61000230
	move.l	#$00400000,d0		;0BD42: 203C00400000
	bsr	DoLongwordCopyBypass		;0BD48: 610001C2
	move.l	UploadDest(a5),d0		;0BD4C: 202D7EF4
	add.l	UploadSize(a5),d0		;0BD50: D0AD7EFC
	move.l	d0,UploadDest(a5)		;0BD54: 2B407EF4
	rts				;0BD58: 4E75
  • BIOS_UPZONE=17
	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=18

Same as 10

  • BIOS_UPZONE=19~1F:RTS
  • Watchdog kicked
  • $FF016F.b=0 enable interrupts ?