CARD: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
== BIOSF_CARD ($C00468): Perform memory card operation ==
= CARD ($C00468) =
 
The CARD routine is used to perform action 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 using the CARD routine :
 
{| class="regdef"
| '''Address'''
| '''DEF name'''
| '''Size'''
| '''Set by'''
| '''Description'''
|-
|$10FDC4
|BIOS_CARD_COMMAND
|byte
|BIOS or Game
|Command to execute,
|-
|$10FDC6
|BIOS_CARD_ANSWER
|byte
|BIOS
|Answer code for the command
|-
|$10FDC8
|BIOS_CARD_START
|longword
|BIOS or Game
|Pointer to data
|-
|$10FDCC
|BIOS_CARD_SIZE
|word
|BIOS or Game
|Size of data
|-
|$10FDCE
|BIOS_CARD_FCB
|word
|BIOS or Game
|Game NGH number
|-
|$10FDD0
|BIOS_CARD_SUB
|byte or word
|BIOS or Game
|Game Subnumber
|}
 
==BIOS_CARD_ANSWER==
 
This variable contain the result of the operation.
 
'''$00''': Normal completion
 
'''$80''': No card inserted
 
'''$81''': Card isn't formated
 
'''$82''': Data doesn't exist
 
'''$83''': FAT error
 
'''$84''': Memory card is full
 
'''$85''': Write disable or ROM card
 
==Commands==
 
===$0 - Format memory card===
 
Format the memory card.
 
===$1 - Data Search===
 
Find the number of save files for the specified game.
 
'''Inputs''' :
 
BIOS_CARD_FCB must contain the NGH number of the game to search.
 
'''Outputs''' :
 
BIOS_CARD_SUB contain a 16 bits mask for all 16 available blocks for the game. If bit '''n''' is set to 1, then the '''n''' save exist for this game.
 
===$2 - Data load===
 
Load the specified save file in RAM.
 
'''Inputs''':
 
BIOS_CARD_FCB must contain the game NGH number.
 
BIOS_CARD_SUB must contain the game save number (16 max per game).
 
BIOS_CARD_START must contain an address where the save will be loaded.
 
BIOS_CARD_SIZE must contain the size of the save (normally 64 bytes).
 
===$3 - Data save===
 
Save from RAM to the specified save file.
 
'''Inputs''':
 
BIOS_CARD_FCB must contain the game NGH number.
 
BIOS_CARD_SUB must contain the game save number (16 max per game).
 
BIOS_CARD_START must contain an address from where the save will be saved.
 
BIOS_CARD_SIZE must contain the size of the save (normally 64 bytes).
 
===$4 - Data delete===
 
Delete the specified file.
 
'''Inputs''':
 
BIOS_CARD_FCB must contain the game NGH number.
 
BIOS_CARD_SUB must contain the game save number (16 max per game).
 
===$5 - Read Data title===
 
Read the Data Title of the BIOS_CARD_SIZE save file.
 
'''Inputs''':
 
BIOS_CARD_START must contain an address to put the Data Title


Memory locations used:
BIOS_CARD_SIZE contain the save file to read from.


<pre>
===$6 - User name save===
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
</pre>


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


;$00 (Format)
'''Inputs''':
:No extra parameters


;$01 (Find)
BIOS_CARD_START address to the username (max 16 bytes).
:'''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)
===$7 - User name 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)
Load the user name of the memory card.
:'''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)
'''Inputs''':
:'''In''':
:CRDNGH: NGH of file
:CRDFILE: the file # of the given NGH to delete


;$05 (GETNAME)
BIOS_CARD_START address where to put the data.
:Gets name of a save file, forgot how these work...


;$06 (SETUSER) (the username of the card)
= CARD_ERROR ($C0046E) =
;$07 (GETUSER)


The CARD_ERROR routine can handle automatically some errors depending on the command and the error code.


==Error handling==
Most of the time it will display a message on screen (using [[MESS_OUT]]) but the routine can also automatically format the memory card if it's needed. (On AES, a user confirmation is asked before formating, on MVS it is done automatically).
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}}
List of command/error combination that CARD_ERROR handle (based on the sp-s2 bios) :


Error codes:
{|class="wikitable sortable"
*0: no card inserted
!Command!!Error!!Result
*1: card inserted, but not formatted
|-
*2: attempted to load a file that doesn't exist on the card
|2 (Data load)
*3: checksum error?
|$81 (card not formated)
*4: attempted to save to a full card
|Display "NO DATA FOR THIS GAME."
*5: card write protect switch is active or read/write check fail
|-
|2 (Data load)
|$83 (FAT error)
|Display "ERROR ON MEMORY CARD."
|-
|2 (Data load)
|$85 (Write disable)
|Display "NO DATA FOR THIS GAME."
|-
|3 (Data save)
|$81 (card not formated)
|Format the card
|-
|3 (Data save)
|$83 (FAT error)
|Format the card
|-
|3 (Data save)
|$84 (Card is full)
|Bring up a menu to delete some saves
|-
|3 (Data save)
|$85 (Write protected)
|Display "MEMORY CARD WRITE PROTECTED."
|-
|4 (Data delete)
|$85 (Write protected)
|Display "MEMORY CARD WRITE PROTECTED."
|-
|6 (Username save)
|$81 (card nor formated)
|Format the card
|-
|6 (Username save)
|$85 (Write protected)
|Display "MEMORY CARD WRITE PROTECTED."
|-
|7 (Username load)
|$81 (card nor formated)
|Display "NO DATA FOR THIS GAME."
|-
|-
|7 (Username load)
|$85 (Write protected)
|Display "NO DATA FOR THIS GAME."
|}


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

Revision as of 09:23, 20 October 2012

CARD ($C00468)

The CARD routine is used to perform action on the memory card.

Warning: register contents aren't preserved !

Variables

The following variables are used when using the CARD routine :

Address DEF name Size Set by Description
$10FDC4 BIOS_CARD_COMMAND byte BIOS or Game Command to execute,
$10FDC6 BIOS_CARD_ANSWER byte BIOS Answer code for the command
$10FDC8 BIOS_CARD_START longword BIOS or Game Pointer to data
$10FDCC BIOS_CARD_SIZE word BIOS or Game Size of data
$10FDCE BIOS_CARD_FCB word BIOS or Game Game NGH number
$10FDD0 BIOS_CARD_SUB byte or word BIOS or Game Game Subnumber

BIOS_CARD_ANSWER

This variable contain the result of the operation.

$00: Normal completion

$80: No card inserted

$81: Card isn't formated

$82: Data doesn't exist

$83: FAT error

$84: Memory card is full

$85: Write disable or ROM card

Commands

$0 - Format memory card

Format the memory card.

$1 - Data Search

Find the number of save files for the specified game.

Inputs :

BIOS_CARD_FCB must contain the NGH number of the game to search.

Outputs :

BIOS_CARD_SUB contain a 16 bits mask for all 16 available blocks for the game. If bit n is set to 1, then the n save exist for this game.

$2 - Data load

Load the specified save file in RAM.

Inputs:

BIOS_CARD_FCB must contain the game NGH number.

BIOS_CARD_SUB must contain the game save number (16 max per game).

BIOS_CARD_START must contain an address where the save will be loaded.

BIOS_CARD_SIZE must contain the size of the save (normally 64 bytes).

$3 - Data save

Save from RAM to the specified save file.

Inputs:

BIOS_CARD_FCB must contain the game NGH number.

BIOS_CARD_SUB must contain the game save number (16 max per game).

BIOS_CARD_START must contain an address from where the save will be saved.

BIOS_CARD_SIZE must contain the size of the save (normally 64 bytes).

$4 - Data delete

Delete the specified file.

Inputs:

BIOS_CARD_FCB must contain the game NGH number.

BIOS_CARD_SUB must contain the game save number (16 max per game).

$5 - Read Data title

Read the Data Title of the BIOS_CARD_SIZE save file.

Inputs:

BIOS_CARD_START must contain an address to put the Data Title

BIOS_CARD_SIZE contain the save file to read from.

$6 - User name save

Set the user name of the memory card.

Inputs:

BIOS_CARD_START address to the username (max 16 bytes).

$7 - User name load

Load the user name of the memory card.

Inputs:

BIOS_CARD_START address where to put the data.

CARD_ERROR ($C0046E)

The CARD_ERROR routine can handle automatically some errors depending on the command and the error code.

Most of the time it will display a message on screen (using MESS_OUT) but the routine can also automatically format the memory card if it's needed. (On AES, a user confirmation is asked before formating, on MVS it is done automatically).

List of command/error combination that CARD_ERROR handle (based on the sp-s2 bios) :

Command Error Result
2 (Data load) $81 (card not formated) Display "NO DATA FOR THIS GAME."
2 (Data load) $83 (FAT error) Display "ERROR ON MEMORY CARD."
2 (Data load) $85 (Write disable) Display "NO DATA FOR THIS GAME."
3 (Data save) $81 (card not formated) Format the card
3 (Data save) $83 (FAT error) Format the card
3 (Data save) $84 (Card is full) Bring up a menu to delete some saves
3 (Data save) $85 (Write protected) Display "MEMORY CARD WRITE PROTECTED."
4 (Data delete) $85 (Write protected) Display "MEMORY CARD WRITE PROTECTED."
6 (Username save) $81 (card nor formated) Format the card
6 (Username save) $85 (Write protected) Display "MEMORY CARD WRITE PROTECTED."
7 (Username load) $81 (card nor formated) Display "NO DATA FOR THIS GAME."
7 (Username load) $85 (Write protected) Display "NO DATA FOR THIS GAME."