Skip to content

Instantly share code, notes, and snippets.

@leiradel
Last active March 14, 2024 16:30
Show Gist options
  • Save leiradel/bce9db9e717fd888579582922927367a to your computer and use it in GitHub Desktop.
Save leiradel/bce9db9e717fd888579582922927367a to your computer and use it in GitHub Desktop.
ZX Spectrum TAP pattern for ImHex
#pragma description ZX Spectrum TAP
#pragma endian little
import std.mem;
enum Flag: u8 {
Header = 0,
Body = 255
};
enum Type: u8 {
Program = 0,
NumberArray = 1,
CharacterArray = 2,
Byte = 3
};
struct Block {
u16 length;
Flag flag;
if (flag == Flag::Header) {
Type type;
char filename[10];
u16 datalen;
if (type == Type::Program) {
u16 startline;
u16 programlen;
}
else if (type == Type::Byte) {
u16 startaddr;
u8 reserved[2];
}
else {
u8 reserved1;
u8 varname;
u8 reserved2[2];
}
}
else {
u8 data[length - 2];
}
u8 checksum;
};
struct Tape {
Block block[while($ < std::mem::size())];
};
Tape tape @ 0x00 [[comment("Tape"), name("Tape")]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment