BIOSF UPLOAD: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
== BIOSF_UPLOAD ($C00546): Upload data to [[DRAM]] ==
The BIOSF_UPLOAD ($C00546) call copies data to the NeoGeo CD [[DRAM]].


<pre>
The parameters are:
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)
</pre>


For FIX, Z80 (, PAT ?) and PCM upload, the destination has to be multiplied by 2 (8bit busses).
*{{BR|BIOS_UPSRC}} (longword): Data source address
The SPR bank size is 1MiB (4 banks), PCM bank size is 512KiB (4 banks). The other zones aren't banked.
*{{BR|BIOS_UPDEST}} (longword): Data destination address
*{{BR|BIOS_UPSIZE}} (longword): Data size
*{{BR|BIOS_UPZONE}} (byte): Zone/method, see below
*{{BR|BIOS_UPBANK}} (byte): DRAM bank


BIOS_UPDEST (and BIOS_UPSRC ?) is incremented by the size upon completion, which allows to do multiple consecutive uploads.
When the call returns, BIOS_UPDEST points to the end of the copied data, allowing multiple consecutive uploads without setting the destination address again.


==Steps==
=Banks=


*$FF0004.w and $10FD80 are pushed
Some DRAM zones have banks: SPR has 4 banks (each 1MiB), PCM has 2 banks (each 512KiB).
*$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===
=Zones/methods=


*BIOS_UPZONE=0: RTS
==$00: Copy PRG words (DMA)==
*BIOS_UPZONE=1: $FF0129.b=0, $FF0105.b=5 (FIX set, upload type)
Loads word copy DMA microcode.
*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===
==$01: Copy Fix graphics bytes (DMA)==
*BIOS_UPZONE=0: RTS
Loads byte copy DMA microcode. Dest = Dest + Size * 2.
*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==
==$02: Copy Sprite graphics words (DMA)==
*$FF016F.b=1 disable interrupts ?
Loads word copy DMA microcode. Copies over 1MiB are possible, the bank is incremented automatically.
*BIOS_UPZONE anded with $1F
*Jump table


*BIOS_UPZONE=0:Upload PRG DMA
==$03: Copy Z80 program bytes (DMA)==
Load word copy microcode
Loads byte copy DMA 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
<pre>
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
</pre>
*BIOS_UPZONE=3 Upload Z80 DMA


lea MicrocodeByteCopy(pc),a0 ;0BE84: 41FA0214
The destination address must be multiplied by 2 (8bit bus) ? Size doesn't have to be multiplied, but has to be an even number ?
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
==$04: Copy PCM bytes (CPU)==
UploadCopyPCMMethod0:
Loads byte copy DMA microcode.
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
The destination address must be multiplied by 2 (8bit bus). Size doesn't have to be multiplied, but has to be an even number. Copies over 1MiB are possible, the bank is incremented automatically.
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
==$05: Install [[PAT file]]==
00 C0 BC B6
Notes:
00 C0 BC 48
*10F736.l=((Bank*$10000)+Dest)/256
00 C0 BC F8
*10F736+Address/2
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
==$06: Copy palette words (DMA)==
*$FF016F.b=0 enable interrupts ?
Loads word copy DMA microcode.
 
==$07: Copy compressed sprite graphics (CPU)==
The first longword's value indicates the size of the '''compressed''' data, BIOS_UPSIZE isn't used.
When a longword zero is copied, the following longword indicates how many zero longwords to insert.
 
This method allows compression of large transparent zones. Is it ever used by games ?
 
==$08: Copy PRG words (DMA)==
Same as method $00.
 
==$10: Copy PRG longwords (CPU)==
Size must be a multiple of 4.
 
==$11: Copy Fix graphics words (CPU)==
The destination address must be multiplied by 2 (8bit bus). Size doesn't have to be multiplied, but has to be an even number.
 
==$12: Copy Sprite graphics longwords (CPU)==
Size must be a multiple of 4.
 
==$13: Copy Z80 program bytes (CPU)==
The destination address must be multiplied by 2 (8bit bus). Size doesn't have to be multiplied, but has to be an even number.
 
==$14: Copy PCM bytes (CPU)==
The destination address must be multiplied by 2 (8bit bus). Size doesn't have to be multiplied, but has to be an even number. Copies over 1MiB are possible, the bank is incremented automatically.
 
Difference with $04 ?
 
==$15: Install PAT file==
Same as method $05.
 
==$16: Copy palette longwords (CPU)==
Size must be a multiple of 4.
 
==$17: Copy compressed sprite graphics (CPU)==
Same as method $07.
 
==$18: Copy PRG longwords (CPU)==
Same as method $10.


[[Category:BIOS calls]]
[[Category:BIOS calls]]

Latest revision as of 20:15, 15 May 2024

The BIOSF_UPLOAD ($C00546) call copies data to the NeoGeo CD DRAM.

The parameters are:

BIOS_UPSRC ($10FEF8 ) (longword): Data source address

BIOS_UPDEST ($10FEF4 ) (longword): Data destination address

BIOS_UPSIZE ($10FEFC ) (longword): Data size

BIOS_UPZONE ($10FEDA ) (byte): Zone/method, see below

BIOS_UPBANK ($10FEDB ) (byte): DRAM bank

When the call returns, BIOS_UPDEST points to the end of the copied data, allowing multiple consecutive uploads without setting the destination address again.

Banks

Some DRAM zones have banks: SPR has 4 banks (each 1MiB), PCM has 2 banks (each 512KiB).

Zones/methods

$00: Copy PRG words (DMA)

Loads word copy DMA microcode.

$01: Copy Fix graphics bytes (DMA)

Loads byte copy DMA microcode. Dest = Dest + Size * 2.

$02: Copy Sprite graphics words (DMA)

Loads word copy DMA microcode. Copies over 1MiB are possible, the bank is incremented automatically.

$03: Copy Z80 program bytes (DMA)

Loads byte copy DMA microcode.

The destination address must be multiplied by 2 (8bit bus) ? Size doesn't have to be multiplied, but has to be an even number ?

$04: Copy PCM bytes (CPU)

Loads byte copy DMA microcode.

The destination address must be multiplied by 2 (8bit bus). Size doesn't have to be multiplied, but has to be an even number. Copies over 1MiB are possible, the bank is incremented automatically.

$05: Install PAT file

Notes:

  • 10F736.l=((Bank*$10000)+Dest)/256
  • 10F736+Address/2

$06: Copy palette words (DMA)

Loads word copy DMA microcode.

$07: Copy compressed sprite graphics (CPU)

The first longword's value indicates the size of the compressed data, BIOS_UPSIZE isn't used. When a longword zero is copied, the following longword indicates how many zero longwords to insert.

This method allows compression of large transparent zones. Is it ever used by games ?

$08: Copy PRG words (DMA)

Same as method $00.

$10: Copy PRG longwords (CPU)

Size must be a multiple of 4.

$11: Copy Fix graphics words (CPU)

The destination address must be multiplied by 2 (8bit bus). Size doesn't have to be multiplied, but has to be an even number.

$12: Copy Sprite graphics longwords (CPU)

Size must be a multiple of 4.

$13: Copy Z80 program bytes (CPU)

The destination address must be multiplied by 2 (8bit bus). Size doesn't have to be multiplied, but has to be an even number.

$14: Copy PCM bytes (CPU)

The destination address must be multiplied by 2 (8bit bus). Size doesn't have to be multiplied, but has to be an even number. Copies over 1MiB are possible, the bank is incremented automatically.

Difference with $04 ?

$15: Install PAT file

Same as method $05.

$16: Copy palette longwords (CPU)

Size must be a multiple of 4.

$17: Copy compressed sprite graphics (CPU)

Same as method $07.

$18: Copy PRG longwords (CPU)

Same as method $10.