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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| ZSTD | `application/zstd` | [`patterns/zstd.hexpat`](patterns/zstd.hexpat) | Zstandard compressed data format |
| MOD | `3d-model/mod` | [`patterns/DMC3HD-Mod.hexpat`](patterns/dmc3_hd_mod.hexpat) | 3D Model files used in Devil May Cry 3 HD Collection |
| CBM BASIC | | [`commodore_basic.hexpat`](patterns/commodore_basic.hexpat) | Commodore BASIC |
| Atari XEX | | [`xex.hexpat`](patterns/xex.hexpat) | Atari 8-bit binary format |
| Terminfo | `application/x-terminfo` and `application/x-terminfo2` | [`patterns/terminfo.hexpat`](patterns/terminfo.hexpat) | Compiled *(legacy and extended)* term info entry |

### Scripts
Expand Down
34 changes: 34 additions & 0 deletions patterns/xex.hexpat
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma author Adiee5
#pragma description Atari 8-bit binary format (.xex)
#pragma endian little
#pragma magic [ FF FF ] @ 0

import std.mem;
import std.io;

u16 header @ 0;

if (header != 0xFFFF)
std::error("Not a valid XEX file");

fn hex_dec_addr(u16 num){
return std::format("0x{:04X} ({})", num, num);
};

struct block {
u16 start [[comment("Address of the first byte"), format("hex_dec_addr")]];
if (start == 0xFFFF) continue; //an unnecessary header to be ignored
u16 end [[comment("Address of the last byte"), format("hex_dec_addr")]];

// since 1 and 2 byte blocks sometimes have special meanings,
// we make them regural variables instead of byte arrays,
// so that reading their values from the GUI is easier
match (end-start){
(0): u8 data;
(1): u16 data [[format("hex_dec_addr")]];
(_): u8 data[end-start+1];
}

};

block data_blocks[while(!std::mem::eof())] @ 2 [[name("Data Blocks")]];
Binary file added tests/patterns/test_data/xex.hexpat.xex
Binary file not shown.