BIOSF UPLOAD: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 15: Line 15:


==Steps==
==Steps==
*$FF0004.w and $10FD80 are pushed
*$FF0004.w and $10FD80 are pushed
*$FF0004.w = 1
*$FF0004.w = 1
*$10FD80=0, system mode
*$10FD80=0, system mode
*BIOS_UPZONE anded with $F
*Mapping
*Jump table
*$FF016F.b=1 disable interrupts ?
*Subrout1
*Copy
*Copydata
*Watchdog kicked
*BIOS_UPZONE anded with $F
*$FF016F.b=0 enable interrupts ?
*Jump table
*Unmapping
*Subrout2
*Restore $10FD80.w and $FF0004.w
*Restore $10FD80.w and $FF0004.w


===Subrout1===
==Modes==


*BIOS_UPZONE=0: RTS
*BIOS_UPZONE=0: Upload PRG DMA words
*BIOS_UPZONE=1: $FF0129.b=0, $FF0105.b=5 (FIX set, upload type)
**Load word copy microcode
*BIOS_UPZONE=2: $FF0121.b=0, $FF0105.b=0, $FF01A1.b=UploadBank (SPR set, upload type)
**Dest=size+dest
*BIOS_UPZONE=3: $FF0127.b=0, $FF0105.b=4  (Z80 set, upload type)
**LoadMicrocodeA0
*BIOS_UPZONE=4: $FF0123.b=0, $FF0105.b=1, $FF01A3.b=UploadBank (PCM set, upload type)
**DoDMAWordCopyBypass
*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=1: Upload Fix DMA bytes
*BIOS_UPZONE=0: RTS
**$FF0129.b=0, $FF0105.b=5 (FIX set, upload type)
*BIOS_UPZONE=1: $FF0149.b=0 FIX unset
**Load byte copy microcode
*BIOS_UPZONE=2: $FF0141.b=0 SPR unset
**DoDMAWordCopy
*BIOS_UPZONE=3: $FF0147.b=0 Z80 unset
**Dest=Dest+(size*2)
*BIOS_UPZONE=4: $FF0143.b=0 PCM unset
**$FF0149.b=0 FIX 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==
*BIOS_UPZONE=2: Upload Srites DMA words
*$FF016F.b=1 disable interrupts ?
**$FF0121.b=0, $FF0105.b=0, $FF01A1.b=UploadBank (SPR set, upload type)
*BIOS_UPZONE anded with $1F
**Load word copy microcode
*Jump table
**Upload (>1MiB possible, bank is autoincremented)
**DoDMAWordCopy
**$FF0141.b=0 SPR unset


*BIOS_UPZONE=0:Upload PRG DMA
*BIOS_UPZONE=3: Upload Z80 DMA bytes
Load word copy microcode
**$FF0127.b=0, $FF0105.b=4  (Z80 set, upload type)
Dest=size+dest
**Load byte copy microcode
LoadMicrocodeA0
**DoByteCopy
d0=0
**Dest=Dest+(size*2)
DoDMAWordCopyBypass
**$FF0147.b=0 Z80 unset


*BIOS_UPZONE=1:Upload Fix DMA
*BIOS_UPZONE=4: Upload PCM DMA bytes
Load byte copy microcode
**$FF0123.b=0, $FF0105.b=1, $FF01A3.b=UploadBank (PCM set, upload type)
DoDMAWordCopy
**Load byte copy microcode
Dest=Dest+(size*2)
**Upload (>1MiB possible, bank is autoincremented)
**DoByteCopy
**$FF0143.b=0 PCM unset


*BIOS_UPZONE=2:Upload Srites DMA
*BIOS_UPZONE=5: Install PAT
Load word copy microcode
**$FF0127.b=0, Z80 set
Is size = 0 ? Yes: dest=0, RTS
**$FF0105.b=4, upload type
No:
**10F736.l=((Bank*$10000)+Dest)/256
Upload (>1MiB possible, bank is autoincremented)
**10F736+Address/2
DoDMAWordCopy
**See [[PAT file]] for data format


*BIOS_UPZONE=3 Upload Z80 DMA
*BIOS_UPZONE=6: Upload palette words
Load byte copy microcode
**Load word copy microcode
Dest=Dest+(size*2)
**move.l #$00400000,d0 ;0BEC6: 203C00400000
**bsr DoDMAWordCopyBypass    ;0BECC: 61000018
**Dest=size+dest


*BIOS_UPZONE=4 Upload PCM DMA
*BIOS_UPZONE=7: Upload sprites loop longwords (?)
Load byte copy microcode
**$FF0121.b=0, $FF0105.b=0, $FF01A1.b=UploadBank (SPR set, upload type)
Upload (>1MiB possible, bank is autoincremented)
**A1=Dest+$E00000
DoByteCopy
**Size.l=(Src.l)
**Size=0 ? Yes: Dest=A1-$E00000
**Copy src to dest
**...weird longword copy in a loop to upload zone
**$FF0141.b=0 SPR unset


*BIOS_UPZONE=5 UploadCopyPATMethod0&1:
*BIOS_UPZONE=8: Upload PRG DMA
$FF0127.b=0, Z80 set
**Same as 0
$FF0105.b=4, upload type
10F736.l=((Bank*$10000)+Dest)/256
10F736+Address/2


See [[PAT file]] for data format
*BIOS_UPZONE=10: Upload PRG loop longwords
**Load word copy microcode
**$FF0004.w=$31
**DoLongwordCopyBypass
**$FF0004.w=$0331
**Dest=Dest+Size


*BIOS_UPZONE=6:
*BIOS_UPZONE=11: Upload FIX loop words
Load word copy microcode
**$FF0129.b=0, $FF0105.b=5 (FIX set, upload type)
move.l #$00400000,d0 ;0BEC6: 203C00400000
**DoWordToByteCopy
bsr DoDMAWordCopyBypass ;0BECC: 61000018
**Dest=Dest+(size*2)
Dest=size+dest
**$FF0149.b=0 FIX unset


*BIOS_UPZONE=7
*BIOS_UPZONE=12: Upload Sprites loop longwords
A1=Dest+$E00000
**$FF0121.b=0, $FF0105.b=0, $FF01A1.b=UploadBank (SPR set, upload type)
Size.l=(Src.l)
**bsr DoLongwordCopy ;0BC48: 610002BC
Size=0 ? Yes: Dest=A1-$E00000
**Dest=Dest+Size
Copy src to dest
**$FF0141.b=0 SPR unset
...weird longword copy in a loop to upload zone


*BIOS_UPZONE=8
*BIOS_UPZONE=13: Upload Z80 loop bytes
Same as 0
**$FF0127.b=0, $FF0105.b=4  (Z80 set, upload type)
*BIOS_UPZONE=9~F:RTS
**bsr DoByteCopy ;0BCF8: 61000250
**Dest=Dest+(size*2)
**$FF0147.b=0 Z80 unset


*BIOS_UPZONE=10
*BIOS_UPZONE=14: Upload PCM loop bytes
<pre>
**$FF0123.b=0, $FF0105.b=1, $FF01A3.b=UploadBank (PCM set, upload type)
UploadCopyPRGMethod1:
**DoByteCopy ;0BCCC: 6100027C
Load word copy microcode
**Dest=Dest+(size*2)
$FF0004.w=$31
**Auto bank++
DoLongwordCopyBypass ;0BD20: 610001EA
**$FF0143.b=0 PCM unset
$FF0004.w=$0331
Dest=Dest+Size


*BIOS_UPZONE=11
*BIOS_UPZONE=15: Install PAT
UploadCopyFIXMethod1:
**Same as 5
bsr DoWordToByteCopy ;0BCB6: 6100026A
Dest=Dest+(size*2)


*BIOS_UPZONE=12
*BIOS_UPZONE=16: Upload palette longwords
UploadCopySpritesMethod1:
**Load word copy microcode
bsr DoLongwordCopy ;0BC48: 610002BC
**move.l #$00400000,d0 ;0BD42: 203C00400000
Dest=Dest+Size
**bsr DoLongwordCopyBypass ;0BD48: 610001C2
**Dest=Dest+Size


*BIOS_UPZONE=13
*BIOS_UPZONE=17: Upload sprites loop longwords (?)
UploadCopyZ80Method1:
**$FF0121.b=0, $FF0105.b=0, $FF01A1.b=UploadBank (SPR set, upload type)
bsr DoByteCopy ;0BCF8: 61000250
**Similar to 7, longword copy in a loop to upload zone
Dest=Dest+(size*2)
**$FF0141.b=0 SPR unset
 
*BIOS_UPZONE=14
UploadCopyPCMMethod1:
DoByteCopy ;0BCCC: 6100027C
Dest=Dest+(size*2)
Auto bank++
 
*BIOS_UPZONE=15
Same as 5
*BIOS_UPZONE=16
Load word copy microcode
move.l #$00400000,d0 ;0BD42: 203C00400000
bsr DoLongwordCopyBypass ;0BD48: 610001C2
Dest=Dest+Size
 
*BIOS_UPZONE=17
Similar to 7, longword copy in a loop to upload zone


*BIOS_UPZONE=18
*BIOS_UPZONE=18
Same as 10
**Same as 10
*BIOS_UPZONE=19~1F:RTS
 
*Watchdog kicked
*$FF016F.b=0 enable interrupts ?


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

Revision as of 02:00, 15 December 2011

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
  • Mapping
  • $FF016F.b=1 disable interrupts ?
  • Copy
  • Watchdog kicked
  • $FF016F.b=0 enable interrupts ?
  • Unmapping
  • Restore $10FD80.w and $FF0004.w

Modes

  • BIOS_UPZONE=0: Upload PRG DMA words
    • Load word copy microcode
    • Dest=size+dest
    • LoadMicrocodeA0
    • DoDMAWordCopyBypass
  • BIOS_UPZONE=1: Upload Fix DMA bytes
    • $FF0129.b=0, $FF0105.b=5 (FIX set, upload type)
    • Load byte copy microcode
    • DoDMAWordCopy
    • Dest=Dest+(size*2)
    • $FF0149.b=0 FIX unset
  • BIOS_UPZONE=2: Upload Srites DMA words
    • $FF0121.b=0, $FF0105.b=0, $FF01A1.b=UploadBank (SPR set, upload type)
    • Load word copy microcode
    • Upload (>1MiB possible, bank is autoincremented)
    • DoDMAWordCopy
    • $FF0141.b=0 SPR unset
  • BIOS_UPZONE=3: Upload Z80 DMA bytes
    • $FF0127.b=0, $FF0105.b=4 (Z80 set, upload type)
    • Load byte copy microcode
    • DoByteCopy
    • Dest=Dest+(size*2)
    • $FF0147.b=0 Z80 unset
  • BIOS_UPZONE=4: Upload PCM DMA bytes
    • $FF0123.b=0, $FF0105.b=1, $FF01A3.b=UploadBank (PCM set, upload type)
    • Load byte copy microcode
    • Upload (>1MiB possible, bank is autoincremented)
    • DoByteCopy
    • $FF0143.b=0 PCM unset
  • BIOS_UPZONE=5: Install PAT
    • $FF0127.b=0, Z80 set
    • $FF0105.b=4, upload type
    • 10F736.l=((Bank*$10000)+Dest)/256
    • 10F736+Address/2
    • See PAT file for data format
  • BIOS_UPZONE=6: Upload palette words
    • Load word copy microcode
    • move.l #$00400000,d0 ;0BEC6: 203C00400000
    • bsr DoDMAWordCopyBypass ;0BECC: 61000018
    • Dest=size+dest
  • BIOS_UPZONE=7: Upload sprites loop longwords (?)
    • $FF0121.b=0, $FF0105.b=0, $FF01A1.b=UploadBank (SPR set, upload type)
    • A1=Dest+$E00000
    • Size.l=(Src.l)
    • Size=0 ? Yes: Dest=A1-$E00000
    • Copy src to dest
    • ...weird longword copy in a loop to upload zone
    • $FF0141.b=0 SPR unset
  • BIOS_UPZONE=8: Upload PRG DMA
    • Same as 0
  • BIOS_UPZONE=10: Upload PRG loop longwords
    • Load word copy microcode
    • $FF0004.w=$31
    • DoLongwordCopyBypass
    • $FF0004.w=$0331
    • Dest=Dest+Size
  • BIOS_UPZONE=11: Upload FIX loop words
    • $FF0129.b=0, $FF0105.b=5 (FIX set, upload type)
    • DoWordToByteCopy
    • Dest=Dest+(size*2)
    • $FF0149.b=0 FIX unset
  • BIOS_UPZONE=12: Upload Sprites loop longwords
    • $FF0121.b=0, $FF0105.b=0, $FF01A1.b=UploadBank (SPR set, upload type)
    • bsr DoLongwordCopy ;0BC48: 610002BC
    • Dest=Dest+Size
    • $FF0141.b=0 SPR unset
  • BIOS_UPZONE=13: Upload Z80 loop bytes
    • $FF0127.b=0, $FF0105.b=4 (Z80 set, upload type)
    • bsr DoByteCopy ;0BCF8: 61000250
    • Dest=Dest+(size*2)
    • $FF0147.b=0 Z80 unset
  • BIOS_UPZONE=14: Upload PCM loop bytes
    • $FF0123.b=0, $FF0105.b=1, $FF01A3.b=UploadBank (PCM set, upload type)
    • DoByteCopy ;0BCCC: 6100027C
    • Dest=Dest+(size*2)
    • Auto bank++
    • $FF0143.b=0 PCM unset
  • BIOS_UPZONE=15: Install PAT
    • Same as 5
  • BIOS_UPZONE=16: Upload palette longwords
    • Load word copy microcode
    • move.l #$00400000,d0 ;0BD42: 203C00400000
    • bsr DoLongwordCopyBypass ;0BD48: 610001C2
    • Dest=Dest+Size
  • BIOS_UPZONE=17: Upload sprites loop longwords (?)
    • $FF0121.b=0, $FF0105.b=0, $FF01A1.b=UploadBank (SPR set, upload type)
    • Similar to 7, longword copy in a loop to upload zone
    • $FF0141.b=0 SPR unset
  • BIOS_UPZONE=18
    • Same as 10