[[File:Nintendo-64-Controller-Pak.jpg|thumb]]The Controller Pak is a memory card accessory, similar to memory cards used by the PlayStation consoles. Certain games allow saving of game files to the Controller Pak. Just like the [[Rumble Pak|Rumble]] and [[Transfer Pak|Transfer Paks]], it plugs into the bottom of the Nintendo 64 [[Controller|controller]]. Some games are unable to save game files without the pak, however the games are still playable. The Controller Pak is also useful for carrying game saves between consoles and exchanging saves between multiple paks using a game's save manager. Original Controller Paks by Nintendo have a total of 32 KiB of memory available for saves, and use a custom (FAT-inspired) filesystem to allocate data from different games, implemented in software by the Nintendo SDK. Some third-party pak (such as by Datel) feature more memory (eg. 256 KiB or 512 KiB), via a bank switching system. This system was supported by the official Nintendo SDK, making such paks work transparently on all commercial games, even though Nintendo itself did not produce or sold any multi-bank controller pak. == Hardware == === Components === The primary component that makes up the Controller Pak is a 28pin, 32,768-byte [[wikipedia:Static random-access memory|SRAM]] chip, backed by a 3.3V battery located on the opposite side of the PCB. The battery supplies a low current to the SRAM when either not plugged into a controller or when the console is turned off, preventing the SRAM from losing data. While the controller's accessory port supports a 16 bit address, the Controller Pak leaves the 16th bit disconnected, as the SRAM only uses 15 bits for addressing. At least some, if not all, of the official Controller Paks used the [[:File:LH52256CVN.pdf|LH52256CVN]] SRAM chip manufactured by Sharp. Alternative SRAM chips do exist. Any chip that follows the same pinout and runs on 3.3V should be compatible. One example is the AS6C62256-55PCN made by Alliance Memory. While not produced anymore, Toshiba's TC55257DFL-85V and Chiplus' CS18LV02563 are also compatible. === Operation === The pins of the SRAM chip are mapped 1 to 1 with the [[Controller#Accessory_Port|accessory port's pinout]], except for pin A15 (the 16th address bit). On OEM paks (official ones produced by Nintendo), pin A15 is connected to pin CE2 of the SRAM chip (Chip Enable 2), causing the SRAM to go into an idle mode when asserted. On some third-party paks, instead, pin A15 is completely disconnected. [[File:20220327 205835.jpg|thumb|Example of a third-party (clone) controller pak where pin A15 (third from right) is disconnected]] The Chip Enable pin is inverted on the PCB using a transistor, meaning that the pin must be pulled HIGH to enable the chip. Write Enable and Output Enable should be pulled LOW to enable their respective function. Refer to the SRAM's datasheet for how to read/write data. [[Category:Accessories]] [[Category:Paks]] [[File:AccessoryPortPinout.png|600px|thumb|Pinout of the accessory port connector with respect to the pak's orientation|none]] == Software == When accessing the Controller Pak via the [[Joybus Protocol|joybus]] protocol, the accessory presents the following memory map: {| class="wikitable" |+OEM (official) Controller Pak memory map !Address !Description |- |0x0000 - 0x7FFF |SRAM: actual contents of the pak |- |0x8000 - 0xFFFF |Writes are ignored, reads return 0 |} The Nintendo SDK (libultra) is designed to support a bank switching system, even though only third-party companies (like Datel) ever produced such paks. This is the memory map: {| class="wikitable" |+ Multi-bank (eg: Datel) Controller Pak memory map !Address !Description |- |0x0000 - 0x7FFF |Read/write current bank (32 KiB) |- |0x8000 - 0xFFFF |Bank-switching: the LSBs of the written word set the bank number. If the bank number does not exist, the behavior is not fully investigated but it appears to just mirror. Eg: for a 4-bank cpak, writing 5 selects bank 1. Reads return 0. |} There is no provision to read the number of available banks. Software is required to either ask that to the user, or perform a discovery process (eg: switching banks and checking contents until the first bank is seen again). Notice that this memory map is also compatible with the original one; in fact, ignoring the writes in range 0x8000-0xFFFF can be interpreted as "always switching to bank 0 which is the only available bank". Some clone Controller Paks instead are designed with A15 pin disconnected, exposing the following memory map: {| class="wikitable" |+ Third-party (clone) Controller Pak memory map !Address !Description |- |0x0000 - 0x7FFF |SRAM: actual contents of the pak |- |0x8000 - 0xFFFF |Mirror of the contents |} Notice that this memory map is actually '''not''' compatible with the bank switching system. In fact, the Nintendo SDK will performa a bank switch by writing the bank number to 0x8000, but this will cause the bank number to be treated as data and written at 0x0000. Luckily, the first block (called "label area") is unused in the [[Controller Pak/Filesystem|standard filesystem]] which might explain why the designers of these clone PCBs never realized the mistake, == File System == {{Main|Controller_Pak/Filesystem|l1=Controller Pak/Filesystem}} Save data management on the Controller Pak is facilitated through a simple proprietary filesystem. In all official and unofficial Controller Paks, there are 32,768 bytes of SRAM available, which is split into 256-byte sectors referred to as "pages". This allows for a maximum capacity of 128 pages, 5 of which are reserved for the filesystem data, and the remaining 123 for user software.