BIOS calls: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 3: Line 3:
Simplify hierarchy and tell on which system each call works ?
Simplify hierarchy and tell on which system each call works ?


= Universal BIOS calls =
= Generic BIOS calls =


BIOS calls common to every system.
BIOS calls common to every system.


== BIOSF_CLEARFIX: Clear fix layer ==
== BIOSF_CLEARFIX ($C004C2): Clear fix layer ==


== BIOSF_CLEARSPR: Clear sprites ==
== BIOSF_CLEARSPR ($C004C8): Clear sprites ==


== BIOSF_? ($C0044A): (Called every frame) ==
== BIOSF_VBL ($C0044A): Multiple purpose VBL routine ==


Sets values in RAM according to buttons states. Often called each frame.
Sets values in RAM according to buttons states, checks CDDA commands, probably other things... Always (?) called each frame by games.


Memory locations set:
Memory locations set (all 8bit):
<pre>
<pre>
BIOS_P1CURRENT    $10FD95 Joystick 1 state
BIOS_P1CURRENT    $10FD95 Joystick 1 state
Line 34: Line 34:


= AES/MVS BIOS calls =
= AES/MVS BIOS calls =
AES/MVS specific calls.


SP-E jump table:
SP-E jump table:
Line 42: Line 40:
|Function
|Function
|-
|-
|$C00402
|$C00402 to $C00432
|rowspan="9"|Same
|Entry point
|-
|$C00408
|-
|$C0040E
|-
|$C00414
|-
|$C0041A
|-
|$C00420
|-
|$C00426
|-
|$C0042C
|-
|$C00432
|-
|-
|$C00438
|$C00438
|Boot process
|Boot process
|-
|-
|$C0043E
|$C0043E to $C00462
|
|?
|-
|$C00444
|
|-
|$C0044A
|
|-
|$C00450
|
|-
|$C00456
|
|-
|$C0045C
|
|-
|$C00462
|
|-
|-
|$C00468
|$C00468
Line 100: Line 64:
|RTS
|RTS
|-
|-
|$C004C2
|$C004C2 to $C004D4
|
|?
|-
|$C004C8
|
|-
|$C004CE
|
|-
|$C004D4
|
|}
|}


Line 116: Line 71:
(Informations provided by [[User:Smkdan]])
(Informations provided by [[User:Smkdan]])


Memory locations used (all 8bit):
Memory locations used:


<pre>
<pre>
Line 123: Line 78:
BIOS_CRDPTR    (32bit): pointer to read from/write to
BIOS_CRDPTR    (32bit): pointer to read from/write to
BIOS_CRDSIZE    (16bit): how much data to read/write from/to card
BIOS_CRDSIZE    (16bit): how much data to read/write from/to card
BIOS_CRDNGH    (16bit): usually game NGH.  Unique identifier for the game that 'owns' the save file
BIOS_CRDNGH    (16bit): usually game [[NGH]].  Unique identifier for the game that 'owns' the save file
BIOS_CRDFILE    (16bit): each NGH has up to 16 save 'files' associated with
BIOS_CRDFILE    (16bit): each NGH has up to 16 save 'files' associated with
</pre>
</pre>
Line 174: Line 129:
= CD BIOS calls =
= CD BIOS calls =


* Same ones as the AES/MVS ?
Same ones as the AES/MVS ?


== BIOSF_UPLOAD ($C00546): Upload data to DRAM ==
== BIOSF_UPLOAD ($C00546): Upload data to [[DRAM]] ==


Arguments:
<pre>
*$10FEF8: Source (Long)
BIOS_UPSRC      (32bit): Source (Long)
*$10FEF4: Destination (Long)
BIOS_UPDEST    (32bit): Destination (Long)
*$10FEDA: Zone (Byte, 0=PRG, 1=FIX, 2=SPR, 3=Z80, 4=PCM, 5=PAT)
BIOS_UPSIZE    (32bit): Size (Long)
*$10FEFC: Size (Long)
BIOS_UPZONE    (8bit): Zone (Byte, 0=PRG, 1=FIX, 2=SPR, 3=Z80, 4=PCM, 5=PAT)
*$10FEDB: Bank (Byte)
BIOS_UPBANK    (8bit): Bank (Byte)
</pre>


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


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


== BIOSF_LOADFILE ($C00552): Load file from CD (with animation) ==
== BIOSF_LOADFILE ($C00552): Load file from CD (with animation) ==


A0 points to a file information block made of:
A0 points to a file information block made of:
*File name, ends with 0 (32 chars buffer ?)
*The file name, ends with 0 (32 chars buffer ?)
*Bank (byte)
*The destination bank (8bit)
*Eventual padding bytes to align Offset
*Eventual padding bytes to align the destination
*Offset (long)
*Destination (32bit)
 
Example (?): "STAGE_2.SPR",0x02,0x00,0x1600 loads STAGE_2.SPR at $201600 in the [[sprite]] DRAM.


For FIX, Z80 and PCM files, Offset is multiplied by 2 (8 bit busses).
For FIX, Z80 (, PAT ?) and PCM files, the destination is multiplied by 2 (8bit busses).


The destination memory is automatically chosen according to the file's extension.
The destination memory is automatically chosen according to the file's extension.


== BIOSF_CDPLAYER ($C0055E): Reset to CD player ==
== BIOSF_CDPLAYER ($C0055E): Reset to CD player ==
== BIOSF_LOADFILEX (?) ($C00564): Load file from CD (no animation) ==


== BIOSF_CDDACMD ($C0056A): Issue CDDA command ==
== BIOSF_CDDACMD ($C0056A): Issue CDDA command ==


Word in D0, command/track ?
Command/track pair in D0. Hooks the VBL interrupt for a while.


= CDZ BIOS calls =
= CDZ BIOS calls =


* Check track 0 ? [[Copy protection]]
Check track 0 ? [[Copy protection]]


[[Category:Code]]
[[Category:Code]]
[[Category:CPUs]]
[[Category:CPUs]]

Revision as of 05:32, 8 March 2011

Please see ASM Defines or C Defines for the hex addresses.

Simplify hierarchy and tell on which system each call works ?

Generic BIOS calls

BIOS calls common to every system.

BIOSF_CLEARFIX ($C004C2): Clear fix layer

BIOSF_CLEARSPR ($C004C8): Clear sprites

BIOSF_VBL ($C0044A): Multiple purpose VBL routine

Sets values in RAM according to buttons states, checks CDDA commands, probably other things... Always (?) called each frame by games.

Memory locations set (all 8bit):

BIOS_P1CURRENT     $10FD95 Joystick 1 state
BIOS_P1PREVIOUS    $10FD96 Previous joystick 1 state
BIOS_P1CHANGE      $10FD97 Joystick 1 state change (edges)
BIOS_P1REPEAT      $10FD98 Joystick 1 repeat (edge, and strobe if held more than ? calls)

BIOS_P2CURRENT     $10FD9B Joystick 2 state
BIOS_P2PREVIOUS    $10FD9C Previous joystick 2 state
BIOS_P2CHANGE      $10FD9D Joystick 2 state change (edges)
BIOS_P2REPEAT      $10FD9E Joystick 2 repeat (edge, and strobe if held more than ? calls)

BIOS_STATCURNT     Joystick 1/2 start/select state
BIOS_STATCHANGE    Previous Joystick 1/2 start/select state

Bit definitions: see Joypads

AES/MVS BIOS calls

SP-E jump table:

Call address Function
$C00402 to $C00432 Entry point
$C00438 Boot process
$C0043E to $C00462 ?
$C00468 BIOSF_CRDACCESS
$C0046E BIOSF_CRDREPORT
$C00474
$C0047A
$C00480 to $C004BC RTS
$C004C2 to $C004D4 ?

BIOSF_CRDACCESS ($C00468): Perform memory card operation

(Informations provided by User:Smkdan)

Memory locations used:

BIOS_CRDF       (8bit): function to perform when calling BIOSF_CRDACCESS, see below table
BIOS_CRDRESULT  (8bit): 00 on success, else 80+ and encodes the error, see below table
BIOS_CRDPTR     (32bit): pointer to read from/write to
BIOS_CRDSIZE    (16bit): how much data to read/write from/to card
BIOS_CRDNGH     (16bit): usually game [[NGH]].  Unique identifier for the game that 'owns' the save file
BIOS_CRDFILE    (16bit): each NGH has up to 16 save 'files' associated with

To access memory card, the RAM addresses above must be set depending on the function being attempted BIOS_CRDF values:

$00 (Format)
No extra parameters
$01 (Find)
In: BIOS_CRDNGH: NGH to find save files for
Out: BIOS_CRDFILE: 16bit mask containing 1 bits for each one of the 16 save files if present.
0 bits mean the save file is not present. i.e. FFFF = all 16 saves used, 8000 = only save file 15 is used
$02 (Load)
In:
CRDPTR: pointer to store loaded data to
CRDSIZE: the max size of data to load (automatically stops when entire file is loaded)
CRDNGH: NGH of file
CRDFILE: the file # of the given NGH to load from
$03 (Save)
In:
CRDPTR: pointer to read data to store to the card
CRDSIZE: size of data to save
CRDNGH: NGH of file
CRDFILE: the file # of the given NGH to save as
$04 (Delete)
In:
CRDNGH: NGH of file
CRDFILE: the file # of the given NGH to delete
$05 (GETNAME)
Gets name of a save file, forgot how these work...
$06 (SETUSER) (the username of the card)
$07 (GETUSER)

Errors may occur and the BIOS will store a value in BIOS_CRDRESULT depending on what went wrong:

  • $00: no errors
  • $80: no card inserted
  • $81: card inserted, but not formatted
  • $82: attempted to load a file that doesn't exist on the card
  • $83: checksum error?
  • $84: attempted to save to a full card
  • $85: card write protect switch is active

CD BIOS calls

Same ones as the AES/MVS ?

BIOSF_UPLOAD ($C00546): Upload data to DRAM

BIOS_UPSRC      (32bit): Source (Long)
BIOS_UPDEST     (32bit): Destination (Long)
BIOS_UPSIZE     (32bit): Size (Long)
BIOS_UPZONE     (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.

BIOSF_LOADFILE ($C00552): Load file from CD (with animation)

A0 points to a file information block made of:

  • The file name, ends with 0 (32 chars buffer ?)
  • The destination bank (8bit)
  • Eventual padding bytes to align the destination
  • Destination (32bit)

Example (?): "STAGE_2.SPR",0x02,0x00,0x1600 loads STAGE_2.SPR at $201600 in the sprite DRAM.

For FIX, Z80 (, PAT ?) and PCM files, the destination is multiplied by 2 (8bit busses).

The destination memory is automatically chosen according to the file's extension.

BIOSF_CDPLAYER ($C0055E): Reset to CD player

BIOSF_LOADFILEX (?) ($C00564): Load file from CD (no animation)

BIOSF_CDDACMD ($C0056A): Issue CDDA command

Command/track pair in D0. Hooks the VBL interrupt for a while.

CDZ BIOS calls

Check track 0 ? Copy protection