7#ifndef __LIBDRAGON_TPAK_H
8#define __LIBDRAGON_TPAK_H
51#define TPAK_ERROR_INVALID_ARGUMENT -1
53#define TPAK_ERROR_NO_TPAK -2
55#define TPAK_ERROR_NO_CONTROLLER -3
57#define TPAK_ERROR_UNKNOWN_BEHAVIOUR -4
59#define TPAK_ERROR_NO_CARTRIDGE -5
61#define TPAK_ERROR_ADDRESS_OVERFLOW -6
75#define TPAK_STATUS_READY 0x01
81#define TPAK_STATUS_WAS_RESET 0x04
87#define TPAK_STATUS_IS_RESETTING 0x08
93#define TPAK_STATUS_REMOVED 0x40
99#define TPAK_STATUS_POWERED 0x80
107typedef enum __attribute__ ((packed))
172typedef enum __attribute__ ((packed))
205typedef enum __attribute__ ((packed))
227typedef enum __attribute__ ((packed))
262typedef enum __attribute__ ((packed))
370int tpak_set_value(
int controller, uint16_t address, uint8_t value);
454int tpak_write(
int controller, uint16_t address, uint8_t* data, uint16_t size);
469int tpak_read(
int controller, uint16_t address, uint8_t* buffer, uint16_t size);
uint8_t destination_code
Japan-only identifier.
Definition tpak.h:332
int tpak_init(int controller)
Prepare a Transfer Pak for read/write commands.
Definition tpak.c:51
gb_cart_ram_size_t ram_size_code
RAM size identifier.
Definition tpak.h:330
int tpak_set_access(int controller, bool access_state)
Set the access mode flag for a Transfer Pak.
Definition tpak.c:71
gbc_support_type gbc_support
Game Boy Color support.
Definition tpak.h:298
int tpak_read(int controller, uint16_t address, uint8_t *buffer, uint16_t size)
Read data from a Game Boy cartridge to a buffer via Transfer Pak.
Definition tpak.c:143
uint8_t title[15]
Game title in ASCII.
Definition tpak.h:279
sgb_support_type is_sgb_supported
Super Game Boy support.
Definition tpak.h:324
int tpak_set_power(int controller, bool power_state)
Set the power enabled flag for a Transfer Pak.
Definition tpak.c:77
bool tpak_check_header(struct gameboy_cartridge_header *header)
Verify a Game Boy cartridge ROM header checksum.
Definition tpak.c:180
uint16_t global_checksum
Checksum of entire cartridge ROM.
Definition tpak.h:340
uint8_t logo[48]
Bitmap image data for the boot logo.
Definition tpak.h:311
sgb_support_type
Super Game Boy cartridge compatibility values.
Definition tpak.h:263
@ SGB_ENHANCED
Enhanced for Super Game Boy.
Definition tpak.h:267
@ SGB_NOT_ENHANCED
Not enhanced for Super Game Boy.
Definition tpak.h:265
gbc_support_type gbc_support
Game Boy Color support.
Definition tpak.h:281
gb_cart_rom_size_t rom_size_code
ROM size identifier.
Definition tpak.h:328
uint8_t header_checksum
Checksum of cartridge ROM header.
Definition tpak.h:338
int tpak_set_value(int controller, uint16_t address, uint8_t value)
Set Transfer Pak or Game Boy cartridge status/control value.
Definition tpak.c:44
uint8_t title[11]
Game title in ASCII.
Definition tpak.h:294
uint16_t new_licensee_code
"New" publisher identifier.
Definition tpak.h:322
uint8_t manufacturer_code[4]
Manufacturer identifier.
Definition tpak.h:296
gb_cart_type_t
Game Boy cartridge types.
Definition tpak.h:108
@ GB_MBC5_RUMBLE
MBC5 (max 8 MiB ROM) + Rumble.
Definition tpak.h:148
@ GB_MMM01_RAM_BATTERY
MMM01 ("Meta-mapper") + RAM + Battery.
Definition tpak.h:130
@ GB_HUC1_RAM_BATTERY
Hudson HuC1 + RAM + Battery.
Definition tpak.h:164
@ GB_HUC3
Hudson HuC3.
Definition tpak.h:162
@ GB_ROM_RAM
ROM (32 KiB) + RAM (max 8 KiB)
Definition tpak.h:122
@ GB_MBC5_RUMBLE_RAM_BATTERY
MBC5 (max 8 MiB ROM) + Rumble + RAM (128 KiB) + Battery.
Definition tpak.h:152
@ GB_MBC5_RAM_BATTERY
MBC5 (max 8 MiB ROM) + RAM (128 KiB) + Battery.
Definition tpak.h:146
@ GB_MBC2_BATTERY
MBC2 (max 256 KiB ROM; 512x4 bits RAM built-in) + Battery.
Definition tpak.h:120
@ GB_MBC3_TIMER_RAM_BATTERY
MBC3 (max 2 MiB ROM) + Real-Time Clock + RAM (64 KiB) + Battery.
Definition tpak.h:140
@ GB_MBC5_RUMBLE_RAM
MBC5 (max 8 MiB ROM) + Rumble + RAM (128 KiB)
Definition tpak.h:150
@ GB_MBC6
MBC6.
Definition tpak.h:154
@ GB_MBC5_RAM
MBC5 (max 8 MiB ROM) + RAM (128 KiB)
Definition tpak.h:144
@ GB_MBC3_RAM
MBC3 (max 2 MiB ROM) + RAM (64 KiB)
Definition tpak.h:134
@ GB_POCKET_CAMERA
Game Boy Camera.
Definition tpak.h:158
@ GB_MMM01
MMM01 ("Meta-mapper")
Definition tpak.h:126
@ GB_MBC3_RAM_BATTERY
MBC3 (max 2 MiB ROM) + RAM (64 KiB) + Battery.
Definition tpak.h:136
@ GB_BANDAI_TAMA5
Bandai TAMA5.
Definition tpak.h:160
@ GB_ROM_ONLY
ROM only (32 KiB ROM)
Definition tpak.h:110
@ GB_MBC2
MBC2 (max 256 KiB ROM; 512x4 bits RAM built-in)
Definition tpak.h:118
@ GB_MBC3_TIMER_BATTERY
MBC3 (max 2 MiB ROM) + Real-Time Clock + Battery.
Definition tpak.h:138
@ GB_MBC1_RAM_BATTERY
MBC1 (max 2 MiB ROM) + RAM (32 KiB) + Battery.
Definition tpak.h:116
@ GB_MBC1
MBC1 (max 2 MiB ROM)
Definition tpak.h:112
@ GB_MMM01_RAM
MMM01 ("Meta-mapper") + RAM.
Definition tpak.h:128
@ GB_MBC5
MBC5 (max 8 MiB ROM)
Definition tpak.h:142
@ GB_MBC1_RAM
MBC1 (max 2 MiB ROM) + RAM (32 KiB)
Definition tpak.h:114
@ GB_MBC7_SENSOR_RUMBLE_RAM_BATTERY
MBC7 + Tilt Sensor + Rumble + RAM + Battery.
Definition tpak.h:156
@ GB_MBC3
MBC3 (max 2 MiB ROM)
Definition tpak.h:132
@ GB_ROM_RAM_BATTERY
ROM (32 KiB) + RAM (max 8 KiB) + Battery.
Definition tpak.h:124
uint8_t version_number
Version number of the game.
Definition tpak.h:336
uint8_t old_licensee_code
"Old" publisher identifier.
Definition tpak.h:334
int tpak_get_cartridge_header(int controller, struct gameboy_cartridge_header *header)
Read the Game Boy cartridge ROM header from a Transfer Pak.
Definition tpak.c:96
uint8_t entry_point[4]
Z80 instructions to boot the main program.
Definition tpak.h:309
gb_cart_type_t cartridge_type
Cartridge type.
Definition tpak.h:326
gb_cart_ram_size_t
Game Boy cartridge RAM size types.
Definition tpak.h:206
@ GB_RAM_2KB
RAM size: 2 KiB (no banks)
Definition tpak.h:210
@ GB_RAM_128KB
RAM size: 128 KiB (16 banks)
Definition tpak.h:218
@ GB_RAM_64KB
RAM size: 64 KiB (8 banks)
Definition tpak.h:216
@ GB_RAM_NONE
RAM not available.
Definition tpak.h:208
@ GB_RAM_32KB
RAM size: 32 KiB (4 banks)
Definition tpak.h:214
@ GB_RAM_8KB
RAM size: 8 KiB (no banks)
Definition tpak.h:212
int tpak_set_bank(int controller, int bank)
Set the cartridge data address memory bank for a Transfer Pak.
Definition tpak.c:83
int tpak_write(int controller, uint16_t address, uint8_t *data, uint16_t size)
Write data from a buffer to a Game Boy cartridge via Transfer Pak.
Definition tpak.c:106
uint8_t overflow[16]
Padding.
Definition tpak.h:342
gb_cart_rom_size_t
Game Boy cartridge ROM size types.
Definition tpak.h:173
@ GB_ROM_1536KB
ROM size: 1.5 MiB (96 banks)
Definition tpak.h:197
@ GB_ROM_64KB
ROM size: 64 KiB (4 banks)
Definition tpak.h:177
@ GB_ROM_1MB
ROM size: 1 MiB (64 banks)
Definition tpak.h:185
@ GB_ROM_1152KB
ROM size: 1.125 MiB (72 banks)
Definition tpak.h:193
@ GB_ROM_512KB
ROM size: 512 KiB (32 banks)
Definition tpak.h:183
@ GB_ROM_256KB
ROM size: 256 KiB (16 banks)
Definition tpak.h:181
@ GB_ROM_32KB
ROM size: 32 KiB (no banks)
Definition tpak.h:175
@ GB_ROM_8MB
ROM size: 8 MiB (512 banks)
Definition tpak.h:191
@ GB_ROM_1280KB
ROM size: 1.25 MiB (80 banks)
Definition tpak.h:195
@ GB_ROM_128KB
ROM size: 128 KiB (8 banks)
Definition tpak.h:179
@ GB_ROM_2MB
ROM size: 2 MiB (128 banks)
Definition tpak.h:187
@ GB_ROM_4MB
ROM size: 4 MiB (256 banks)
Definition tpak.h:189
gbc_support_type
Game Boy Color cartridge compatibility values.
Definition tpak.h:228
@ GBC_NOT_SUPPORTED
Game Boy Color not supported.
Definition tpak.h:236
@ GBC_ONLY_SUPPORTED
Game Boy Color required.
Definition tpak.h:253
@ GBC_DMG_SUPPORTED
Game Boy Color enhanced.
Definition tpak.h:244
uint8_t tpak_get_status(int controller)
Get the status flags for a Transfer Pak.
Definition tpak.c:88
"New" Game Boy Color cartridge ROM header title structure.
Definition tpak.h:292
"Old" Game Boy Color cartridge ROM header title structure.
Definition tpak.h:277