CARD: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= CARD ($C00468) =
=CARD ($C00468)=


The CARD routine is used to perform action on the memory card.
The CARD [[system ROM]] call is used to perform operations on the [[memory card]].


'''Warning:''' register contents aren't preserved !
'''Warning:''' register contents aren't preserved !
Line 7: Line 7:
==Variables==
==Variables==


The following variables are used when using the CARD routine :
The following variables are used when calling CARD:


{| class="regdef"
{| class="regdef"
Line 19: Line 19:
|BIOS_CARD_COMMAND
|BIOS_CARD_COMMAND
|byte
|byte
|BIOS or Game
|System ROM or game
|Command to execute,
|Command code to execute
|-
|-
|$10FDC6
|$10FDC6
|BIOS_CARD_ANSWER
|BIOS_CARD_ANSWER
|byte
|byte
|BIOS
|System ROM
|Answer code for the command
|Answer code (see below)
|-
|-
|$10FDC8
|$10FDC8
|BIOS_CARD_START
|BIOS_CARD_START
|longword
|longword
|BIOS or Game
|System ROM or game
|Pointer to data
|Pointer to data
|-
|-
Line 37: Line 37:
|BIOS_CARD_SIZE
|BIOS_CARD_SIZE
|word
|word
|BIOS or Game
|System ROM or game
|Size of data
|Size of data
|-
|-
Line 43: Line 43:
|BIOS_CARD_FCB
|BIOS_CARD_FCB
|word
|word
|BIOS or Game
|System ROM or game
|Game NGH number
|Game [[NGH number]]
|-
|-
|$10FDD0
|$10FDD0
|BIOS_CARD_SUB
|BIOS_CARD_SUB
|byte or word
|byte or word
|BIOS or Game
|System ROM or game
|Game Subnumber
|Game save sub-number
|}
|}


The following temporary variable are used when calling CARD :
The following temporary variables are used when calling CARD :


{| class="regdef"
{| class="regdef"
Line 64: Line 64:
|BIOS_CARD_DIRECTORY_START
|BIOS_CARD_DIRECTORY_START
|long word
|long word
|Start of Directory
|Start of directory
|-
|-
|$10FD08
|$10FD08
Line 84: Line 84:
|BIOS_CARD_DATA_START
|BIOS_CARD_DATA_START
|long word
|long word
|Start of Data
|Start of data
|-
|-
|$10FD14
|$10FD14
|BIOS_CARD_TYPE
|BIOS_CARD_TYPE
|word
|word
|$0 : 8 bits wide card
|
 
* $0 : 8 bits card
$01 : 16 bits wide card
* $01 : 16 bits card
 
* $80 : 16 bits wide weird card (todo)
$80 : 16 bits wide weird card (more to come on them)
|-
|-
|$10FD16
|$10FD16
Line 103: Line 102:
==BIOS_CARD_ANSWER==
==BIOS_CARD_ANSWER==


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


'''$00''': Normal completion
* $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


'''$80''': No card inserted
=Commands=


'''$81''': Card isn't formated
==$0: Format memory card==


'''$82''': Data doesn't exist
Formats the memory card.


'''$83''': FAT error
==$1: Data search==


'''$84''': Memory card is full
Return the number of save files for the specified game.


'''$85''': Write disable or ROM card
'''Inputs''':
 
==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.
BIOS_CARD_FCB must contain the NGH number of the desired game.


'''Outputs''' :
'''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.
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 - Data load===
==$2: Load data==


Load the specified save file in RAM.
Loads the specified save file in RAM.


'''Inputs''':
'''Inputs''':


BIOS_CARD_FCB must contain the game NGH number.
* 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_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).


BIOS_CARD_START must contain an address where the save will be loaded.
==$3: Save data==
 
BIOS_CARD_SIZE must contain the size of the save (normally 64 bytes).
 
===$3 - Data save===


Save from RAM to the specified save file.
Save from RAM to the specified save file.
Line 157: Line 147:
'''Inputs''':
'''Inputs''':


BIOS_CARD_FCB must contain the game NGH number.
* 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).


BIOS_CARD_SUB must contain the game save number (16 max per game).
==$4: Delete data==
 
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.
Delete the specified file.
Line 171: Line 158:
'''Inputs''':
'''Inputs''':


BIOS_CARD_FCB must contain the game NGH number.
* 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_SUB must contain the game save number (16 max per game).


===$5 - Read Data title===
==$5: Read data title==


Read the Data Title of the BIOS_CARD_SIZE save file.
Read the data title of a save file.


'''Inputs''':
'''Inputs''':


BIOS_CARD_START must contain an address to put the Data Title
* BIOS_CARD_START must be a pointer to which the title string will be copied.
 
* BIOS_CARD_SIZE must contain the game save number ?
BIOS_CARD_SIZE contain the save file to read from.


===$6 - User name save===
==$6: Save user name==


Set the user name of the memory card.
Set the user name of the memory card.
Line 191: Line 176:
'''Inputs''':
'''Inputs''':


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


===$7 - User name load===
==$7: Load user name==


Load the user name of the memory card.
Loads the user name of the memory card.


'''Inputs''':
'''Inputs''':


BIOS_CARD_START address where to put the data.
BIOS_CARD_START must be a pointer to which the user name's string will be copied.
 
= 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) :
 
{|class="wikitable sortable"
!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."
|}


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

Latest revision as of 15:42, 21 August 2024

CARD ($C00468)

The CARD system ROM call is used to perform operations 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.