CARD: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
m (4 revisions: Import from wikkii)
m (Formatting, wording)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== [[BIOSF_CRDACCESS]] ($C00468): Perform memory card operation ==
=CARD ($C00468)=
 
The CARD [[system ROM]] call is used to perform opeartions on the [[memory card]].


'''Warning:''' register contents aren't preserved !
'''Warning:''' register contents aren't preserved !


(Informations provided by [[User:Smkdan]])
==Variables==
 
The following variables are used when calling CARD:
 
{| class="regdef"
| '''Address'''
| '''DEF name'''
| '''Size'''
| '''Set by'''
| '''Description'''
|-
|$10FDC4
|BIOS_CARD_COMMAND
|byte
|System ROM or game
|Command code to execute
|-
|$10FDC6
|BIOS_CARD_ANSWER
|byte
|System ROM
|Answer code (see below)
|-
|$10FDC8
|BIOS_CARD_START
|longword
|System ROM or game
|Pointer to data
|-
|$10FDCC
|BIOS_CARD_SIZE
|word
|System ROM or game
|Size of data
|-
|$10FDCE
|BIOS_CARD_FCB
|word
|System ROM or game
|Game [[NGH number]]
|-
|$10FDD0
|BIOS_CARD_SUB
|byte or word
|System ROM or game
|Game save sub-number
|}
 
The following temporary variables are used when calling CARD :
 
{| class="regdef"
| '''Address'''
| '''DEF name'''
| '''Size'''
| '''Description'''
|-
|$10FD04
|BIOS_CARD_DIRECTORY_START
|long word
|Start of directory
|-
|$10FD08
|BIOS_CARD_BLOCK_NUMBER
|word
|Number of blocks
|-
|$10FD0A
|BIOS_CARD_FAT_START
|long word
|Start of FAT
|-
|$10FD0E
|BIOS_CARD_FAT_SIZE
|word
|Size of FAT
|-
|$10FD10
|BIOS_CARD_DATA_START
|long word
|Start of data
|-
|$10FD14
|BIOS_CARD_TYPE
|word
|
* $0 : 8 bits card
* $01 : 16 bits card
* $80 : 16 bits wide weird card (todo)
|-
|$10FD16
|BIOS_CARD_SIZE
|word
|Size of the card
|}
 
==BIOS_CARD_ANSWER==
 
This variable contains the result of the operation. Bit 7 indicates an error.
 
* $00: Normal completion
* $80: No card inserted
* $81: Card isn't formatted
* $82: Requested data doesn't exist
* $83: FAT error
* $84: Card is full
* $85: Write disabled or ROM card
 
=Commands=
 
==$0: Format memory card==
 
Formats the memory card.
 
==$1: Data search==
 
Return the number of save files for the specified game.
 
'''Inputs''':
 
BIOS_CARD_FCB must contain the NGH number of the desired game.
 
'''Outputs''':
 
BIOS_CARD_SUB contains a 16 bit mask for all 16 available blocks for the game. If a bit is set, then the corresponding save block exists.
 
==$2: Load data==
 
Loads the specified save file in RAM.
 
'''Inputs''':
 
* BIOS_CARD_FCB must contain the NGH number of the desired game.
* BIOS_CARD_SUB must contain the game save number (16 max. per game).
* BIOS_CARD_START must be a pointer to which the save data will be loaded.
* BIOS_CARD_SIZE must contain the size of the save (usually 64 bytes).
 
==$3: Save data==
 
Save from RAM to the specified save file.
 
'''Inputs''':
 
* BIOS_CARD_FCB must contain the NGH number of the desired game.
* BIOS_CARD_SUB must contain the game save number (16 max. per game).
* BIOS_CARD_START must be a pointer from which the save data will be copied.
* BIOS_CARD_SIZE must contain the size of the save (usually 64 bytes).
 
==$4: Delete data==
 
Delete the specified file.


Memory locations used:
'''Inputs''':


<pre>
* BIOS_CARD_FCB must contain the NGH number of the desired game.
BIOS_CRDF      (8bit): function to perform when calling BIOSF_CRDACCESS, see below table
* BIOS_CARD_SUB must contain the game save number (16 max. per game).
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
</pre>


To access memory card, the RAM addresses above must be set depending on the function being attempted
==$5: Read data title==
BIOS_CRDF values:


;$00 (Format)
Read the data title of a save file.
:No extra parameters


;$01 (Find)
'''Inputs''':
:'''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)
* BIOS_CARD_START must be a pointer to which the title string will be copied.
:'''In''':
* BIOS_CARD_SIZE must contain the game save number ?
: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)
==$6: Save user name==
:'''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)
Set the user name of the memory card.
:'''In''':
:CRDNGH: NGH of file
:CRDFILE: the file # of the given NGH to delete


;$05 (GETNAME)
'''Inputs''':
:Gets name of a save file, forgot how these work...


;$06 (SETUSER) (the username of the card)
BIOS_CARD_START must be a pointer to the user name's string (max. 16 bytes).
;$07 (GETUSER)


==$7: Load user name==


==Error handling==
Loads the user name of the memory card.
Errors may occur and the BIOS will store a value in BIOS_CRDRESULT depending on what went wrong:


{{8BitRegister|Error occured|1|0|4|Error code|3}}
'''Inputs''':


Error codes:
BIOS_CARD_START must be a pointer to which the user name's string will be copied.
*0: no card inserted
*1: card inserted, but not formatted
*2: attempted to load a file that doesn't exist on the card
*3: checksum error?
*4: attempted to save to a full card
*5: card write protect switch is active


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

Latest revision as of 05:19, 28 February 2017

CARD ($C00468)

The CARD system ROM call is used to perform opeartions on the memory card.

Warning: register contents aren't preserved !

Variables

The following variables are used when calling CARD:

Address DEF name Size Set by Description
$10FDC4 BIOS_CARD_COMMAND byte System ROM or game Command code to execute
$10FDC6 BIOS_CARD_ANSWER byte System ROM Answer code (see below)
$10FDC8 BIOS_CARD_START longword System ROM or game Pointer to data
$10FDCC BIOS_CARD_SIZE word System ROM or game Size of data
$10FDCE BIOS_CARD_FCB word System ROM or game Game NGH number
$10FDD0 BIOS_CARD_SUB byte or word System ROM or game Game save sub-number

The following temporary variables are used when calling CARD :

Address DEF name Size Description
$10FD04 BIOS_CARD_DIRECTORY_START long word Start of directory
$10FD08 BIOS_CARD_BLOCK_NUMBER word Number of blocks
$10FD0A BIOS_CARD_FAT_START long word Start of FAT
$10FD0E BIOS_CARD_FAT_SIZE word Size of FAT
$10FD10 BIOS_CARD_DATA_START long word Start of data
$10FD14 BIOS_CARD_TYPE word
  • $0 : 8 bits card
  • $01 : 16 bits card
  • $80 : 16 bits wide weird card (todo)
$10FD16 BIOS_CARD_SIZE word Size of the card

BIOS_CARD_ANSWER

This variable contains the result of the operation. Bit 7 indicates an error.

  • $00: Normal completion
  • $80: No card inserted
  • $81: Card isn't formatted
  • $82: Requested data doesn't exist
  • $83: FAT error
  • $84: Card is full
  • $85: Write disabled or ROM card

Commands

$0: Format memory card

Formats the memory card.

$1: Data search

Return the number of save files for the specified game.

Inputs:

BIOS_CARD_FCB must contain the NGH number of the desired game.

Outputs:

BIOS_CARD_SUB contains a 16 bit mask for all 16 available blocks for the game. If a bit is set, then the corresponding save block exists.

$2: Load data

Loads the specified save file in RAM.

Inputs:

  • BIOS_CARD_FCB must contain the NGH number of the desired game.
  • BIOS_CARD_SUB must contain the game save number (16 max. per game).
  • BIOS_CARD_START must be a pointer to which the save data will be loaded.
  • BIOS_CARD_SIZE must contain the size of the save (usually 64 bytes).

$3: Save data

Save from RAM to the specified save file.

Inputs:

  • BIOS_CARD_FCB must contain the NGH number of the desired game.
  • BIOS_CARD_SUB must contain the game save number (16 max. per game).
  • BIOS_CARD_START must be a pointer from which the save data will be copied.
  • BIOS_CARD_SIZE must contain the size of the save (usually 64 bytes).

$4: Delete data

Delete the specified file.

Inputs:

  • BIOS_CARD_FCB must contain the NGH number of the desired game.
  • BIOS_CARD_SUB must contain the game save number (16 max. per game).

$5: Read data title

Read the data title of a save file.

Inputs:

  • BIOS_CARD_START must be a pointer to which the title string will be copied.
  • BIOS_CARD_SIZE must contain the game save number ?

$6: Save user name

Set the user name of the memory card.

Inputs:

BIOS_CARD_START must be a pointer to the user name's string (max. 16 bytes).

$7: Load user name

Loads the user name of the memory card.

Inputs:

BIOS_CARD_START must be a pointer to which the user name's string will be copied.