diff options
author | B. Watson <urchlay@slackware.uk> | 2022-08-29 16:11:13 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2022-08-29 16:11:13 -0400 |
commit | e2ba8458a5cfdfacfaf103e7ba97d610afa6c970 (patch) | |
tree | cd665e602e6e2b636578a7d3d7894380605dafcc /cart.h | |
download | bw-atari8-tools-e2ba8458a5cfdfacfaf103e7ba97d610afa6c970.tar.gz |
initial commit
Diffstat (limited to 'cart.h')
-rw-r--r-- | cart.h | 55 |
1 files changed, 55 insertions, 0 deletions
@@ -0,0 +1,55 @@ + +/* CART header support for cart2xex + + Format of CART header (from atari800 cart.txt): + + first 4 bytes containing 'C' 'A' 'R' 'T'. + next 4 bytes containing cartridge type in MSB format (see the table below). + next 4 bytes containing cartridge checksum in MSB format (ROM only). + next 4 bytes are currently unused (zero). + followed immediately with the ROM data: 4, 8, 16, 32, 40, 64, 128, 256, 512 + or 1024 kilobytes. + + See cart.c for the list of cart types. +*/ + +#ifndef CART_H +#define CART_H + +#define CART_SIGNATURE "CART" + +#define CART_SIGNATURE_OFFSET 0 +#define CART_TYPE_OFFSET 4 +#define CART_CHECKSUM_OFFSET 8 +#define CART_UNUSED_OFFSET 12 + +typedef enum { + M_INVALID, + M_ATARI8, + M_5200 +} machine_t; + +typedef struct { + int machine; + int size; + char *name; +} cart_t; + +extern cart_t cart_types[]; +extern const int MAX_CART_TYPE; + +int has_cart_signature(unsigned char *cart); +void cart_dump_header(unsigned char *cart, int calc_cksum); +unsigned int get_cart_type(unsigned char *cart); +unsigned int get_cart_size(unsigned char *cart); +unsigned int get_cart_checksum(unsigned char *cart); +machine_t get_cart_machine(unsigned char *cart); +unsigned int calc_rom_checksum(unsigned char *rom, int bytes); +unsigned int cart_checksum_ok(unsigned char *cart); +int create_cart_header( + unsigned char *buffer, unsigned char *rom, unsigned int type); +void set_cart_checksum(unsigned char *cart, unsigned int sum); +void set_cart_type(unsigned char *cart, unsigned int type); +void set_cart_unused(unsigned char *cart, unsigned int data); + +#endif |