Memory card: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
(Details about blocks. Moved pinout to new page.)
Line 1: Line 1:
[[File:snkmemcard.jpg|thumb|SRAM memory card, showing the SRAM chip and voltage detection circuit. Picture by [[User:HPMAN|HPMAN]]]]
[[File:snkmemcard.jpg|thumb|SRAM memory card, showing the SRAM chip and voltage detection circuit. Picture by [[User:HPMAN|HPMAN]]]]


The NeoGeo (AES and some [[MVS hardware|MVS]]) uses JEIDA V3 memory cards to store game saves and/or high scores. The original SNK-branded card could only hold 2KiB of data.
The NeoGeo home console and some [[MVS hardware|MVS]] cabs can use JEIDA V3 memory cards to store game saves and/or high scores, allowing players to save their progress and continue on any system running the same game.


The official SNK memory card was a battery-based 2KiB card using a LH5116 CMOS SRAM chip and voltage switching circuitry. Data retention voltage: 2V. The SP-S2 [[system ROM]] can handle memory cards up to 16KiB. The card is embedded in [[CD systems]] as a 8KiB battery-backed RAM chip.
Even if the memory card [[68k memory map|address space]] can be freely used, games should only perform memory card operations through the [[CARD]] system ROM call to avoid data corruption.


See the [[CARD]] call description for memory card operations.
=Supported card types=
 
The SP-S2 [[system ROM]] (and probably all the others) can handle 8 memory card sizes from 2KiB up to 16KiB, in 2KiB steps:
*2KiB
*4KiB
*6KiB
*8KiB
*10KiB
*14KiB
*16KiB
 
And 4 different card types:
*8 bits wide (only the low byte is used)
*16 bits wide
*16 bits wide "doubled"
*"SNK ROM" cards
 
=Original SNK card=
 
The original SNK-branded memory card was a battery-backed 8-bit wide 2KiB card using a LH5116 SRAM chip and voltage switching circuitry.
 
Since it uses a battery, it may be prone to data loss if the voltage drops below 2V. It is unclear if the battery is charged up when plugged into a powered system or not.
 
=CD systems=
 
A "virtual" memory card is embedded in [[CD systems]] as a 8KiB battery-backed SRAM chip.


=Data format=
=Data format=


The system ROM can handle 8 different card sizes (2K, 4K, 6K, 8K, 10K, 14K and 16K) and 4 different card types (8 bits wide, 16 bits wide, 16 bits wide "doubled", and "SNK ROM" cards).
All cards use the same format regardless of capacity, only regions sizes differ. Since the JEIDA data bus is 16-bits wide, make sure to double the address for 8-bit cards if you choose to access their memory directly.


All cards use the same format regardless of capacity.
The data is referred to as "blocks", one block being 64 bytes. The header always occupies the first block. Eg. A 2KiB card can hold (2048/64)-1 = 31 blocks.


The data is split into 5 regions:
The data is split into 5 regions:
Line 17: Line 42:
==Header==
==Header==


Always 128 bytes.
Always 64 bytes.


{| class="regdef"
{|class="wikitable"
| '''Address'''
| '''Address'''
| '''Name'''
| '''Name'''
Line 35: Line 60:
|CARD_SIZE
|CARD_SIZE
|word
|word
|Card capacity
|Address space used by the memory card. Eg. A 2KiB 8-bit card is $1000.
|-
|-
|$C
|$C
Line 75: Line 100:
==Directory==
==Directory==


List of saves of 32, 64, 96, 128, 160, 192, 224 or 256 entries. The size depends on the card's capacity.  
List of saves of 32, 64, 96, 128, 160, 192, 224 or 256 entries. The size depends on the card's capacity.


Each entry has the following format:
Note that since the header occupies the first block, there will always be at least one unused directory entry.
 
Each entry is 4 bytes, with the following format:


{| class="regdef"
{| class="regdef"
Line 86: Line 113:
|$0
|$0
|byte
|byte
|Save sub number (CARD_SUB), 0 to 15. $FF if entry is free.
|Save sub-number (CARD_SUB), 0 to 15. $FF if entry is free.
|-
|-
|$1
|$1
Line 94: Line 121:
|$3
|$3
|byte
|byte
|FAT entry number (see below)
|FAT entry index (see below)
|}
|}


==FAT 1==
==FAT 1==


List of used blocks, of 64, 128, 192, or 256 entries. The size depends on the card's capacity.
List of used blocks of 64, 128, 192, or 256 entries. The size depends on the card's capacity.
* $02 is a block reservd by the system ROM
* $02 is a block reserved by the system ROM
* $01 is a block used by a game
* $01 is a block used by a game
* $00 is a free block
* $00 is a free block
Line 107: Line 134:


FAT 2 is simply a mirror of FAT 1.
FAT 2 is simply a mirror of FAT 1.
If any of the FAT tables checksum is bad, the correct table is written over the other one. If both checksums are bad, the system ROM displays an error.


==Game Data==
==Game Data==


Many games use 64 bytes, but some might use more.
Many games use only one block, but some may use more.


The first 20 bytes are the data title (usually the game and stage name).
The first 20 bytes contain the data title (usually the game and stage name).


=Registers=
=Registers=


* Write is enabled if {{Reg|REG_CRDUNLOCK1}} is 0 and {{Reg|REG_CRDUNLOCK2}} is 1
* Write is enabled if {{Reg|REG_CRDUNLOCK1}} and {{Reg|REG_CRDUNLOCK2}} are written to
* The WP (Write Protect) pin is read through bit 6 of {{Reg|REG_STATUS_B}}
* The WP (Write Protect) pin is read through bit 6 of {{Reg|REG_STATUS_B}}
* CD1 (Card Detect 1) is read through bit 4 of {{Reg|REG_STATUS_B}}
* CD1 (Card Detect 1) is read through bit 4 of {{Reg|REG_STATUS_B}}
* CD2 (Card Detect 2) is read through bit 5 of {{Reg|REG_STATUS_B}}
* CD2 (Card Detect 2) is read through bit 5 of {{Reg|REG_STATUS_B}}
* Attribute memory is selected if {{Reg|REG_CRDREGSEL}} is 1
** Both must be 0 if the card is inserted correctly
 
* Attribute memory is selected if {{Reg|REG_CRDREGSEL}} is written to, never used ?
=Card pinout (top)=
 
[[File:Lh5116_pinout.png|right|frame|LH5116 pinout]]
 
{|class="wikitable"
!Pin #||Name||Signal||Description||Goes to
|-
|1||bgcolor="#DDDDDD" colspan="4"|GND
|-
|2||bgcolor="#AACCFF"|D3||CDD3||rowspan="5"|Data bus||rowspan="5"|{{Chipname|NEO-G0}}
|-
|3||bgcolor="#AACCFF"|D4||CDD4
|-
|4||bgcolor="#AACCFF"|D5||CDD5
|-
|5||bgcolor="#AACCFF"|D6||CDD6
|-
|6||bgcolor="#AACCFF"|D7||CDD7
|-
|7||bgcolor="#AA77FF"|/CE1||CRDC||Chip enable 1||{{Chipname|NEO-C1}}
|-
|8||bgcolor="#FFFF77"|A10||CDA10||Address||{{Chipname|NEO-E0}}
|-
|9||bgcolor="#AA77FF"|/OE||CRDO||Output enable||{{Chipname|NEO-C1}}
|-
|10||bgcolor="#FFFF77"|A11||CDA11||rowspan="5"|Address bus||rowspan="5"|{{Chipname|NEO-E0}}
|-
|11||bgcolor="#FFFF77"|A9||CDA9
|-
|12||bgcolor="#FFFF77"|A8||CDA8
|-
|13||bgcolor="#FFFF77"|A13||CDA13
|-
|14||bgcolor="#FFFF77"|A14||CDA14
|-
|15||bgcolor="#AA77FF"|/WE|| ||Write enable||HC32
|-
|16||bgcolor="#AA77FF"|/BUSY||Low when card is busy||colspan="2"|Not used
|-
|17||bgcolor="#FF8888" colspan="4"|VCC
|-
|18||bgcolor="#FF4444" colspan="4"|VPP
|-
|19||bgcolor="#FFFF77"|A16||CDA16||rowspan="11"|Address bus||rowspan="11"|{{Chipname|NEO-E0}}
|-
|20||bgcolor="#FFFF77"|A15||CDA15
|-
|21||bgcolor="#FFFF77"|A12||CDA12
|-
|22||bgcolor="#FFFF77"|A7||CDA7
|-
|23||bgcolor="#FFFF77"|A6||CDA6
|-
|24||bgcolor="#FFFF77"|A5||CDA5
|-
|25||bgcolor="#FFFF77"|A4||CDA4
|-
|26||bgcolor="#FFFF77"|A3||CDA3
|-
|27||bgcolor="#FFFF77"|A2||CDA2
|-
|28||bgcolor="#FFFF77"|A1||CDA1
|-
|29||bgcolor="#FFFF77"|A0||CDA0
|-
|30||bgcolor="#AACCFF"|D0||CDD0||rowspan="3"|Data bus||rowspan="3"|{{Chipname|NEO-G0}}
|-
|31||bgcolor="#AACCFF"|D1||CDD1
|-
|32||bgcolor="#AACCFF"|D2||CDD2
|-
|33||bgcolor="#AA77FF"|WP||WP||High if card is write-protected||{{Chipname|NEO-C1}}
|-
|34||bgcolor="#DDDDDD" colspan="4"|GND
|}


=Card pinout (bottom)=
=Pinout=


{|class="wikitable"
See [[Memory card pinout]].
!Pin #||Name||Signal||Description||Goes to
|-
|35||bgcolor="#DDDDDD" colspan="4"|GND
|-
|36||bgcolor="#DDDDDD"|/CD1||CD1||Card detect||{{Chipname|NEO-C1}}
|-
|37||bgcolor="#AACCFF"|D11||CDD11||rowspan="5"|Data bus||rowspan="5"|{{Chipname|NEO-G0}}
|-
|38||bgcolor="#AACCFF"|D12||CDD12
|-
|39||bgcolor="#AACCFF"|D13||CDD13
|-
|40||bgcolor="#AACCFF"|D14||CDD14
|-
|41||bgcolor="#AACCFF"|D15||CDD15
|-
|42||bgcolor="#AA77FF"|/CE2||CRDC||Chip enable 2||{{Chipname|NEO-C1}}
|-
|43||bgcolor="#AA77FF"|/VS1||colspan="3" rowspan="3"|Not used
|-
|44||bgcolor="#AA77FF"|/IORD
|-
|45||bgcolor="#AA77FF"|/IOWR
|-
|46||bgcolor="#FFFF77"|A17||CDA17||rowspan="5"|Address bus||rowspan="5"|{{Chipname|NEO-E0}}
|-
|47||bgcolor="#FFFF77"|A18||CDA18
|-
|48||bgcolor="#FFFF77"|A19||CDA19
|-
|49||bgcolor="#FFFF77"|A20||CDA20
|-
|50||bgcolor="#FFFF77"|A21||CDA21
|-
|51||bgcolor="#FF8888" colspan="4"|VCC
|-
|52||bgcolor="#FF8888" colspan="4"|VCC
|-
|53||bgcolor="#FFFF77"|A22||CDA22||rowspan="2"|Address bus||rowspan="2"|{{Chipname|NEO-E0}}
|-
|54||bgcolor="#FFFF77"|A23||CDA23
|-
|55||bgcolor="#FFFF77"|A24||colspan="3" rowspan="5"|Not used
|-
|56||bgcolor="#FFFF77"|A25
|-
|57||bgcolor="#AA77FF"|/VS2
|-
|58||bgcolor="#AA77FF"|RESET
|-
|59||bgcolor="#AA77FF"|/WAIT
|-
|60||NC||colspan="3"|Reserved
|-
|61||bgcolor="#AA77FF"|/REG|| ||Select attribute memory||HC32
|-
|62||bgcolor="#AA77FF"|BVD2||rowspan="2"|Battery voltage detect||colspan="2" rowspan="2"|Not used
|-
|63||bgcolor="#AA77FF"|BVD1
|-
|64||bgcolor="#AACCFF"|D8||CDD8||rowspan="3"|Data bus||rowspan="3"|{{Chipname|NEO-G0}}
|-
|65||bgcolor="#AACCFF"|D9||CDD9
|-
|66||bgcolor="#AACCFF"|D10||CDD10
|-
|67||bgcolor="#DDDDDD"|/CD2||CD2||Card detect||{{Chipname|NEO-C1}}
|-
|68||bgcolor="#DDDDDD" colspan="4"|GND
|}


[[Category:Cartridge systems]]
[[Category:Cartridge systems]]

Revision as of 01:38, 28 January 2018

SRAM memory card, showing the SRAM chip and voltage detection circuit. Picture by HPMAN

The NeoGeo home console and some MVS cabs can use JEIDA V3 memory cards to store game saves and/or high scores, allowing players to save their progress and continue on any system running the same game.

Even if the memory card address space can be freely used, games should only perform memory card operations through the CARD system ROM call to avoid data corruption.

Supported card types

The SP-S2 system ROM (and probably all the others) can handle 8 memory card sizes from 2KiB up to 16KiB, in 2KiB steps:

  • 2KiB
  • 4KiB
  • 6KiB
  • 8KiB
  • 10KiB
  • 14KiB
  • 16KiB

And 4 different card types:

  • 8 bits wide (only the low byte is used)
  • 16 bits wide
  • 16 bits wide "doubled"
  • "SNK ROM" cards

Original SNK card

The original SNK-branded memory card was a battery-backed 8-bit wide 2KiB card using a LH5116 SRAM chip and voltage switching circuitry.

Since it uses a battery, it may be prone to data loss if the voltage drops below 2V. It is unclear if the battery is charged up when plugged into a powered system or not.

CD systems

A "virtual" memory card is embedded in CD systems as a 8KiB battery-backed SRAM chip.

Data format

All cards use the same format regardless of capacity, only regions sizes differ. Since the JEIDA data bus is 16-bits wide, make sure to double the address for 8-bit cards if you choose to access their memory directly.

The data is referred to as "blocks", one block being 64 bytes. The header always occupies the first block. Eg. A 2KiB card can hold (2048/64)-1 = 31 blocks.

The data is split into 5 regions:

Header

Always 64 bytes.

Address Name Size Description
$0~$9 10 bytes Zeros or "SNK ROM " (development unit ?)

For 16 bits "doubled" cards, $6 is set to $0001

$A CARD_SIZE word Address space used by the memory card. Eg. A 2KiB 8-bit card is $1000.
$C byte 0
$D CARD_FAT_1_CHKSUM byte Checksum of FAT 1
$E CARD_FAT_2_CHKSUM byte Checksum of FAT 2
$F CARD_USERNAME_AVAILABLE byte 0 : Username unavailable, !0 : Username available
$10 CARD_USERNAME 16 bytes Card holder's username
$20 CARD_MAGIC 16 bytes $4E $XX $45 $XX $4F $XX $2D $XX $47 $XX $45 $XX $4F $XX $80 $XX ("NEO-GEO", $80)
$30 CARD_REGION byte Region of the system that formated the card, 0 = Japan, 1 = USA, 2 = Europe

Directory

List of saves of 32, 64, 96, 128, 160, 192, 224 or 256 entries. The size depends on the card's capacity.

Note that since the header occupies the first block, there will always be at least one unused directory entry.

Each entry is 4 bytes, with the following format:

Address Size Description
$0 byte Save sub-number (CARD_SUB), 0 to 15. $FF if entry is free.
$1 word Game's NGH number
$3 byte FAT entry index (see below)

FAT 1

List of used blocks of 64, 128, 192, or 256 entries. The size depends on the card's capacity.

  • $02 is a block reserved by the system ROM
  • $01 is a block used by a game
  • $00 is a free block

FAT 2

FAT 2 is simply a mirror of FAT 1.

If any of the FAT tables checksum is bad, the correct table is written over the other one. If both checksums are bad, the system ROM displays an error.

Game Data

Many games use only one block, but some may use more.

The first 20 bytes contain the data title (usually the game and stage name).

Registers

Pinout

See Memory card pinout.