Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions patterns/tic80.hexpat
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#pragma author Luke
#pragma description TIC-80 Cartridge
#include <std/mem.pat>

/*!
The pattern for the .tic TIC-80 cart format.
Adapted from https://github.com/nesbox/TIC-80/wiki/.tic-File-Format
*/

enum TypeValue : u8 {
CHUNK_TILES = 1,
CHUNK_SPRITES = 2,
CHUNK_COVER_DEP = 3,
CHUNK_MAP = 4,
CHUNK_CODE = 5,
CHUNK_FLAGS = 6,
CHUNK_SAMPLES = 9,
CHUNK_WAVEFORM = 10,
CHUNK_PALETTE = 12,
CHUNK_PATTERNS_DEP = 13,
CHUNK_MUSIC = 14,
CHUNK_PATTERNS = 15,
CHUNK_CODE_ZIP = 16,
CHUNK_DEFAULT = 17,
CHUNK_SCREEN = 18,
CHUNK_BINARY = 19
};

bitfield FlagChunk {
Flag0 : 1;
Flag1 : 1;
Flag2 : 1;
Flag3 : 1;
Flag4 : 1;
Flag5 : 1;
Flag6 : 1;
Flag7 : 1;
};

bitfield BankAndTypeField {
TypeValue Type : 5 [[comment("The type of chunk.")]];
Bank : 3 [[comment("The bank # of the chunk.")]];
};

struct Chunk {
BankAndTypeField BankAndType [[comment("This byte stores both the bank and type.")]];
le u16 Size [[comment("The size of the chunk. (Value 0 = 65536 except for CHUNK_DEFAULTs)")]];
padding[1];
if (Size == 0 && BankAndType.Type != TypeValue::CHUNK_DEFAULT) {
u8 Data[65536] [[comment("The chunk data. Interpret according to the type.")]];
} else {
u8 Data[Size] [[comment("The chunk data. Interpret according to the type.")]];
}
};

Chunk File[while($ < std::mem::size())] @ 0x00;
Binary file added tests/patterns/test_data/tic80.hexpat.tic
Binary file not shown.