1b6cee71dSXin LI 2b6cee71dSXin LI#------------------------------------------------------------------------------ 3*898496eeSXin LI# $File: c64,v 1.14 2023/06/16 19:24:06 christos Exp $ 4b6cee71dSXin LI# c64: file(1) magic for various commodore 64 related files 5b6cee71dSXin LI# 6b6cee71dSXin LI# From: Dirk Jagdmann <doj@cubic.org> 7b6cee71dSXin LI 8b6cee71dSXin LI0x16500 belong 0x12014100 D64 Image 9b6cee71dSXin LI0x16500 belong 0x12014180 D71 Image 10b6cee71dSXin LI0x61800 belong 0x28034400 D81 Image 11b6cee71dSXin LI0 belong 0x43154164 X64 Image 12b6cee71dSXin LI 13a4d6d3b8SXin LI# C64 (and other CBM) cartridges 14a4d6d3b8SXin LI# Extended by David Korth <gerbilsoft@gerbilsoft.com> 15a4d6d3b8SXin LI# Reference: https://vice-emu.sourceforge.io/vice_17.html#SEC391 16a4d6d3b8SXin LI 17a4d6d3b8SXin LI0 string C64\40CARTRIDGE Commodore 64 cartridge 18a4d6d3b8SXin LI>0x20 ubyte 0 \b, 19a4d6d3b8SXin LI>0x20 ubyte !0 20a4d6d3b8SXin LI>>0x20 string/T x \b: "%.32s", 21a4d6d3b8SXin LI>0x16 beshort 0 22a4d6d3b8SXin LI>>0x18 beshort 0x0000 16 KB game 23a4d6d3b8SXin LI>>0x18 beshort 0x0001 8 KB game 24a4d6d3b8SXin LI>>0x18 beshort 0x0100 UltiMax mode 25a4d6d3b8SXin LI>>0x18 beshort 0x0101 RAM/disabled 26a4d6d3b8SXin LI>0x16 beshort 1 Action Replay 27a4d6d3b8SXin LI>0x16 beshort 2 KCS Power Cartridge 28a4d6d3b8SXin LI>0x16 beshort 3 Final Cartridge III 29a4d6d3b8SXin LI>0x16 beshort 4 Simons' BASIC 30a4d6d3b8SXin LI>0x16 beshort 5 Ocean type 1 31a4d6d3b8SXin LI>0x16 beshort 6 Expert Cartridge 32a4d6d3b8SXin LI>0x16 beshort 7 Fun Play, Power Play 33a4d6d3b8SXin LI>0x16 beshort 8 Super Games 34a4d6d3b8SXin LI>0x16 beshort 9 Atomic Power 35a4d6d3b8SXin LI>0x16 beshort 10 Epyx Fastload 36a4d6d3b8SXin LI>0x16 beshort 11 Westermann Learning 37a4d6d3b8SXin LI>0x16 beshort 12 Rex Utility 38a4d6d3b8SXin LI>0x16 beshort 13 Final Cartridge I 39a4d6d3b8SXin LI>0x16 beshort 14 Magic Formel 40a4d6d3b8SXin LI>0x16 beshort 15 C64 Game System, System 3 41a4d6d3b8SXin LI>0x16 beshort 16 Warp Speed 42a4d6d3b8SXin LI>0x16 beshort 17 Dinamic 43a4d6d3b8SXin LI>0x16 beshort 18 Zaxxon / Super Zaxxon (Sega) 44a4d6d3b8SXin LI>0x16 beshort 19 Magic Desk, Domark, HES Australia 45a4d6d3b8SXin LI>0x16 beshort 20 Super Snapshot V5 46a4d6d3b8SXin LI>0x16 beshort 21 Comal-80 47a4d6d3b8SXin LI>0x16 beshort 22 Structured BASIC 48a4d6d3b8SXin LI>0x16 beshort 23 Ross 49a4d6d3b8SXin LI>0x16 beshort 24 Dela EP64 50a4d6d3b8SXin LI>0x16 beshort 25 Dela EP7x8 51a4d6d3b8SXin LI>0x16 beshort 26 Dela EP256 52a4d6d3b8SXin LI>0x16 beshort 27 Rex EP256 53a4d6d3b8SXin LI>0x16 beshort 28 Mikro Assembler 54a4d6d3b8SXin LI>0x16 beshort 29 Final Cartridge Plus 55a4d6d3b8SXin LI>0x16 beshort 30 Action Replay 4 56a4d6d3b8SXin LI>0x16 beshort 31 Stardos 57a4d6d3b8SXin LI>0x16 beshort 32 EasyFlash 58a4d6d3b8SXin LI>0x16 beshort 33 EasyFlash Xbank 59a4d6d3b8SXin LI>0x16 beshort 34 Capture 60a4d6d3b8SXin LI>0x16 beshort 35 Action Replay 3 61a4d6d3b8SXin LI>0x16 beshort 36 62a4d6d3b8SXin LI>>0x1A ubyte 1 Nordic Replay 63a4d6d3b8SXin LI>>0x1A ubyte !1 Retro Replay 64a4d6d3b8SXin LI>0x16 beshort 37 MMC64 65a4d6d3b8SXin LI>0x16 beshort 38 MMC Replay 66a4d6d3b8SXin LI>0x16 beshort 39 IDE64 67a4d6d3b8SXin LI>0x16 beshort 40 Super Snapshot V4 68a4d6d3b8SXin LI>0x16 beshort 41 IEEE-488 69a4d6d3b8SXin LI>0x16 beshort 42 Game Killer 70a4d6d3b8SXin LI>0x16 beshort 43 Prophet64 71a4d6d3b8SXin LI>0x16 beshort 44 EXOS 72a4d6d3b8SXin LI>0x16 beshort 45 Freeze Frame 73a4d6d3b8SXin LI>0x16 beshort 46 Freeze Machine 74a4d6d3b8SXin LI>0x16 beshort 47 Snapshot64 75a4d6d3b8SXin LI>0x16 beshort 48 Super Explode V5.0 76a4d6d3b8SXin LI>0x16 beshort 49 Magic Voice 77a4d6d3b8SXin LI>0x16 beshort 50 Action Replay 2 78a4d6d3b8SXin LI>0x16 beshort 51 MACH 5 79a4d6d3b8SXin LI>0x16 beshort 52 Diashow-Maker 80a4d6d3b8SXin LI>0x16 beshort 53 Pagefox 81a4d6d3b8SXin LI>0x16 beshort 54 Kingsoft 82a4d6d3b8SXin LI>0x16 beshort 55 Silverrock 128K Cartridge 83a4d6d3b8SXin LI>0x16 beshort 56 Formel 64 84a4d6d3b8SXin LI>0x16 beshort 57 85a4d6d3b8SXin LI>>0x1A ubyte 1 Hucky 86a4d6d3b8SXin LI>>0x1A ubyte !1 RGCD 87a4d6d3b8SXin LI>0x16 beshort 58 RR-Net MK3 88a4d6d3b8SXin LI>0x16 beshort 59 EasyCalc 89a4d6d3b8SXin LI>0x16 beshort 60 GMod2 90a4d6d3b8SXin LI>0x16 beshort 61 MAX Basic 91a4d6d3b8SXin LI>0x16 beshort 62 GMod3 92a4d6d3b8SXin LI>0x16 beshort 63 ZIPP-CODE 48 93a4d6d3b8SXin LI>0x16 beshort 64 Blackbox V8 94a4d6d3b8SXin LI>0x16 beshort 65 Blackbox V3 95a4d6d3b8SXin LI>0x16 beshort 66 Blackbox V4 96a4d6d3b8SXin LI>0x16 beshort 67 REX RAM-Floppy 97a4d6d3b8SXin LI>0x16 beshort 68 BIS-Plus 98a4d6d3b8SXin LI>0x16 beshort 69 SD-BOX 99a4d6d3b8SXin LI>0x16 beshort 70 MultiMAX 100a4d6d3b8SXin LI>0x16 beshort 71 Blackbox V9 101a4d6d3b8SXin LI>0x16 beshort 72 Lt. Kernal Host Adaptor 102a4d6d3b8SXin LI>0x16 beshort 73 RAMLink 103a4d6d3b8SXin LI>0x16 beshort 74 H.E.R.O. 104a4d6d3b8SXin LI>0x16 beshort 75 IEEE Flash! 64 105a4d6d3b8SXin LI>0x16 beshort 76 Turtle Graphics II 106a4d6d3b8SXin LI>0x16 beshort 77 Freeze Frame MK2 107a4d6d3b8SXin LI 108a4d6d3b8SXin LI0 string C128\40CARTRIDGE Commodore 128 cartridge 109a4d6d3b8SXin LI>0x20 ubyte 0 \b, 110a4d6d3b8SXin LI>0x20 ubyte !0 111a4d6d3b8SXin LI>>0x20 string/T x \b: "%.32s", 112a4d6d3b8SXin LI>0x16 beshort 0 generic cartridge 113a4d6d3b8SXin LI>0x16 beshort 1 Warpspeed128 114a4d6d3b8SXin LI>>0x1A ubyte 1 \b, REU support 115a4d6d3b8SXin LI>>0x1A ubyte 2 \b, REU support, with I/O and ROM banking 116a4d6d3b8SXin LI 117a4d6d3b8SXin LI0 string CBM2\40CARTRIDGE Commodore CBM-II cartridge 118a4d6d3b8SXin LI>0x20 ubyte !0 119a4d6d3b8SXin LI>>0x20 string/T x \b: "%.32s" 120a4d6d3b8SXin LI 121a4d6d3b8SXin LI0 string VIC20\40CARTRIDGE Commodore VIC-20 cartridge 122a4d6d3b8SXin LI>0x20 ubyte 0 \b, 123a4d6d3b8SXin LI>0x20 ubyte !0 124a4d6d3b8SXin LI>>0x20 string/T x \b: "%.32s", 125a4d6d3b8SXin LI>0x16 beshort 0 generic cartridge 126a4d6d3b8SXin LI>0x16 beshort 1 Mega-Cart 127a4d6d3b8SXin LI>0x16 beshort 2 Behr Bonz 128a4d6d3b8SXin LI>0x16 beshort 3 Vic Flash Plugin 129a4d6d3b8SXin LI>0x16 beshort 4 UltiMem 130a4d6d3b8SXin LI>0x16 beshort 5 Final Expansion 131a4d6d3b8SXin LI 132a4d6d3b8SXin LI0 string PLUS4\40CARTRIDGE Commodore 16/Plus4 cartridge 133a4d6d3b8SXin LI>0x20 ubyte !0 134a4d6d3b8SXin LI>>0x20 string/T x \b: "%.32s" 135a4d6d3b8SXin LI 136a4d6d3b8SXin LI 137a4d6d3b8SXin LI# DreamLoad archives see: 138a4d6d3b8SXin LI# https://www.lemon64.com/forum/viewtopic.php?t=37415\ 139a4d6d3b8SXin LI# &sid=494dc2ca91289e05dadf80a7f8a968fe (at the bottom). 140a4d6d3b8SXin LI# https://www.c64-wiki.com/wiki/DreamLoad. 141a4d6d3b8SXin LI# Example HVSC Commodore 64 music collection: 142a4d6d3b8SXin LI# https://kohina.duckdns.org/HVSC/C64Music/10_Years_HVSC.dfi 143a4d6d3b8SXin LI 144a4d6d3b8SXin LI0 byte 0 145a4d6d3b8SXin LI>1 string DREAMLOAD\40FILE\40ARCHIVE 146a4d6d3b8SXin LI>>0x17 byte 0 DFI Image 147a4d6d3b8SXin LI>>>0x1a leshort x version: %d. 148a4d6d3b8SXin LI>>>0x18 leshort x \b%d 149a4d6d3b8SXin LI>>>0x1c lelong x tracks: %d 150a4d6d3b8SXin LI 151b6cee71dSXin LI0 string GCR-1541 GCR Image 152b6cee71dSXin LI>8 byte x version: %i 153b6cee71dSXin LI>9 byte x tracks: %i 154b6cee71dSXin LI 155b6cee71dSXin LI9 string PSUR ARC archive (c64) 156b6cee71dSXin LI2 string -LH1- LHA archive (c64) 157b6cee71dSXin LI 158b6cee71dSXin LI0 string C64File PC64 Emulator file 159b6cee71dSXin LI>8 string >\0 "%s" 160b6cee71dSXin LI0 string C64Image PC64 Freezer Image 161b6cee71dSXin LI 162b6cee71dSXin LI0 beshort 0x38CD C64 PCLink Image 163b6cee71dSXin LI0 string CBM\144\0\0 Power 64 C64 Emulator Snapshot 164b6cee71dSXin LI 165b6cee71dSXin LI0 belong 0xFF424CFF WRAptor packer (c64) 166b6cee71dSXin LI 167b6cee71dSXin LI0 string C64S\x20tape\x20file T64 tape Image 16843a5ec4eSXin LI>32 leshort x Version:%#x 169b6cee71dSXin LI>36 leshort !0 Entries:%i 170b6cee71dSXin LI>40 string x Name:%.24s 171b6cee71dSXin LI 172b6cee71dSXin LI0 string C64\x20tape\x20image\x20file\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0 T64 tape Image 17343a5ec4eSXin LI>32 leshort x Version:%#x 174b6cee71dSXin LI>36 leshort !0 Entries:%i 175b6cee71dSXin LI>40 string x Name:%.24s 176b6cee71dSXin LI 177b6cee71dSXin LI0 string C64S\x20tape\x20image\x20file\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0 T64 tape Image 17843a5ec4eSXin LI>32 leshort x Version:%#x 179b6cee71dSXin LI>36 leshort !0 Entries:%i 180b6cee71dSXin LI>40 string x Name:%.24s 1819ce06829SXin LI 1829ce06829SXin LI# Raw tape file format (.tap files) 1839ce06829SXin LI# Esa Hyyti <esa@netlab.tkk.fi> 1849ce06829SXin LI0 string C64-TAPE-RAW C64 Raw Tape File (.tap), 1859ce06829SXin LI>0x0c byte x Version:%u, 1869ce06829SXin LI>0x10 lelong x Length:%u cycles 18758a0f0d0SEitan Adler 18858a0f0d0SEitan Adler# magic for Goattracker2, http://covertbitops.c64.org/ 18958a0f0d0SEitan Adler# from Alex Myczko <alex@aiei.ch> 19058a0f0d0SEitan Adler0 string GTS5 GoatTracker 2 song 19158a0f0d0SEitan Adler>4 string >\0 \b, "%s" 19258a0f0d0SEitan Adler>36 string >\0 \b by %s 19358a0f0d0SEitan Adler>68 string >\0 \b (C) %s 19458a0f0d0SEitan Adler>100 byte >0 \b, %u subsong(s) 19558a0f0d0SEitan Adler 19643a5ec4eSXin LI# CBM BASIC (cc65 compiled) 197*898496eeSXin LI# Summary: binary executable or Basic program for Commodore C64 computers 198*898496eeSXin LI# Update: Joerg Jenderek 199*898496eeSXin LI# URL: http://fileformats.archiveteam.org/wiki/Commodore_BASIC_tokenized_file 200*898496eeSXin LI# Reference: https://www.c64-wiki.com/wiki/BASIC_token 201*898496eeSXin LI# https://github.com/thezerobit/bastext/blob/master/bastext.doc 202*898496eeSXin LI# http://mark0.net/download/triddefs_xml.7z/defs/p/prg-c64.trid.xml 203*898496eeSXin LI# TODO: unify Commodore BASIC/program sub routines 204*898496eeSXin LI# Note: "PUCrunch archive data" moved from ./archive and merged with c64-exe 20543a5ec4eSXin LI0 leshort 0x0801 206*898496eeSXin LI# display Commodore C64 BASIC program (strength=50) after "Lynx archive" (strength=330) handled by ./archive 207*898496eeSXin LI#!:strength +0 208*898496eeSXin LI# if first token is not SYS this implies BASIC program in most cases 209*898496eeSXin LI>6 ubyte !0x9e 210*898496eeSXin LI# but sELF-ExTRACTING-zIP executable unzp6420.prg contains SYS token at end of second BASIC line (at 0x35) 211*898496eeSXin LI>>23 search/30 \323ELF-E\330TRACTING-\332IP 212*898496eeSXin LI>>>0 use c64-exe 213*898496eeSXin LI>>23 default x 214*898496eeSXin LI>>>0 use c64-prg 215*898496eeSXin LI# if first token is SYS this implies binary executable 216*898496eeSXin LI>6 ubyte =0x9e 217*898496eeSXin LI>>0 use c64-exe 218*898496eeSXin LI# display information about C64 binary executable (memory address, line number, token) 219*898496eeSXin LI0 name c64-exe 220*898496eeSXin LI>0 uleshort x Commodore C64 221*898496eeSXin LI# http://a1bert.kapsi.fi/Dev/pucrunch/ 222*898496eeSXin LI# start address 0801h; next offset 080bh; BASIC line number is 239=00EFh; BASIC instruction is SYS 2061 223*898496eeSXin LI# the above combination appartly also occur for other Commodore programs like: gunzip111.c64.prg 224*898496eeSXin LI# and there exist PUCrunch archive for other machines like C16 with other magics 225*898496eeSXin LI>0 string \x01\x08\x0b\x08\xef\x00\x9e\x32\x30\x36\x31 program, probably PUCrunch archive data 226*898496eeSXin LI!:mime application/x-compress-pucrunch 227*898496eeSXin LI!:ext prg/pck 228*898496eeSXin LI>0 string !\x01\x08\x0b\x08\xef\x00\x9e\x32\x30\x36\x31 program 229*898496eeSXin LI!:mime application/x-commodore-exec 230*898496eeSXin LI!:ext prg/ 231*898496eeSXin LI# start address like: 801h 232*898496eeSXin LI>0 uleshort !0x0801 \b, start address %#4.4x 233*898496eeSXin LI# 1st BASIC fragment 234*898496eeSXin LI>2 use basic-line 235*898496eeSXin LI# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line 236*898496eeSXin LI>(2.s-0x800) ubyte x 237*898496eeSXin LI>>&-1 ubyte !0 \b, no EOL=%#x 238*898496eeSXin LI# valid 2nd BASIC fragment found only in sELF-ExTRACTING-zIP executable unzp6420.prg 239*898496eeSXin LI>>23 search/30 \323ELF-E\330TRACTING-\332IP 240*898496eeSXin LI# jump again from beginning 241*898496eeSXin LI>>>(2.s-0x800) ubyte x 242*898496eeSXin LI>>>>&0 use basic-line 243*898496eeSXin LI# Zero-byte marking the end of the BASIC line 244*898496eeSXin LI>-3 ubyte !0 \b, 3 last bytes %#2.2x 245*898496eeSXin LI# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program 246*898496eeSXin LI>>-2 ubeshort x \b%4.4x 247*898496eeSXin LI# display information about tokenized C64 BASIC program (memory address, line number, token) 248*898496eeSXin LI0 name c64-prg 249*898496eeSXin LI>0 uleshort x Commodore C64 BASIC program 250*898496eeSXin LI!:mime application/x-commodore-basic 251*898496eeSXin LI# Tokenized BASIC programs were stored by Commodore as file type program "PRG" in separate field in directory structures. 252*898496eeSXin LI# So file name can have no suffix like in saveroms; When transferring to other platforms, they are often saved with .prg extensions. 253*898496eeSXin LI# BAS suffix is typically used for the BASIC source but also found in program pods.bas 254*898496eeSXin LI!:ext prg/bas/ 255*898496eeSXin LI# start address like: 801h 256*898496eeSXin LI>0 uleshort !0x0801 \b, start address %#4.4x 257*898496eeSXin LI# 1st BASIC fragment 258*898496eeSXin LI>2 use basic-line 259*898496eeSXin LI# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line 260*898496eeSXin LI>(2.s-0x0800) ubyte x 261*898496eeSXin LI>>&-1 ubyte !0 \b, no EOL=%#x 262*898496eeSXin LI# 2nd BASIC fragment 263*898496eeSXin LI>>&0 use basic-line 264*898496eeSXin LI# zero-byte marking the end of the BASIC line 265*898496eeSXin LI>-3 ubyte !0 \b, 3 last bytes %#2.2x 266*898496eeSXin LI# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program 267*898496eeSXin LI>>-2 ubeshort x \b%4.4x 268*898496eeSXin LI# Summary: binary executable or Basic program for Commodore C128 computers 269*898496eeSXin LI# URL: https://en.wikipedia.org/wiki/Commodore_128 270*898496eeSXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/p/prg-c128.trid.xml 271*898496eeSXin LI# From: Joerg Jenderek 272*898496eeSXin LI# Note: Commodore 128 BASIC 7.0 variant; there exist varaints with different start addresses 273*898496eeSXin LI0 leshort 0x1C01 274*898496eeSXin LI!:strength +1 275*898496eeSXin LI# GRR: line above with strength 51 (50+1) is too generic because it matches SVr3 curses screen image, big-endian with strength (50) handled by ./terminfo 276*898496eeSXin LI# probably skip SVr3 curses images with "invalid high" second line offset 277*898496eeSXin LI>2 uleshort <0x1D02 278*898496eeSXin LI# skip foo with "invalid low" second line offset 279*898496eeSXin LI>>2 uleshort >0x1C06 280*898496eeSXin LI# if first token is not SYS this implies BASIC program 281*898496eeSXin LI>>>6 ubyte !0x9e 282*898496eeSXin LI>>>>0 use c128-prg 283*898496eeSXin LI# if first token is SYS this implies binary executable 284*898496eeSXin LI>>>6 ubyte =0x9e 285*898496eeSXin LI>>>>0 use c128-exe 286*898496eeSXin LI# Summary: binary executable or Basic program for Commodore C128 computers 287*898496eeSXin LI# Note: Commodore 128 BASIC 7.1 extension by Rick Simon 288*898496eeSXin LI# start adress 132Dh 289*898496eeSXin LI#0 leshort 0x132D THIS_IS_C128_7.1 290*898496eeSXin LI#>0 use c128-prg 291*898496eeSXin LI# Summary: binary executable or Basic program for Commodore C128 computers 292*898496eeSXin LI# Note: Commodore 128 BASIC 7.0 saved with graphics mode enabled 293*898496eeSXin LI# start adress 4001h 294*898496eeSXin LI#0 leshort 0x4001 THIS_IS_C128_GRAPHIC 295*898496eeSXin LI#>0 use c128-prg 296*898496eeSXin LI# display information about tokenized C128 BASIC program (memory address, line number, token) 297*898496eeSXin LI0 name c128-prg 298*898496eeSXin LI>0 uleshort x Commodore C128 BASIC program 299*898496eeSXin LI!:mime application/x-commodore-basic 300*898496eeSXin LI!:ext prg 301*898496eeSXin LI# start address like: 1C01h 302*898496eeSXin LI>0 uleshort !0x1C01 \b, start address %#4.4x 303*898496eeSXin LI# 1st BASIC fragment 304*898496eeSXin LI>2 use basic-line 305*898496eeSXin LI# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line 306*898496eeSXin LI>(2.s-0x1C00) ubyte x 307*898496eeSXin LI>>&-1 ubyte !0 \b, no EOL=%#x 308*898496eeSXin LI# 2nd BASIC fragment 309*898496eeSXin LI>>&0 use basic-line 310*898496eeSXin LI# Zero-byte marking the end of the BASIC line 311*898496eeSXin LI>-3 ubyte !0 \b, 3 last bytes %#2.2x 312*898496eeSXin LI# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program 313*898496eeSXin LI>>-2 ubeshort x \b%4.4x 314*898496eeSXin LI# display information about C128 program (memory address, line number, token) 315*898496eeSXin LI0 name c128-exe 316*898496eeSXin LI>0 uleshort x Commodore C128 program 317*898496eeSXin LI!:mime application/x-commodore-exec 318*898496eeSXin LI!:ext prg/ 319*898496eeSXin LI# start address like: 1C01h 320*898496eeSXin LI>0 uleshort !0x1C01 \b, start address %#4.4x 321*898496eeSXin LI# 1st BASIC fragment 322*898496eeSXin LI>2 use basic-line 323*898496eeSXin LI# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line 324*898496eeSXin LI>(2.s-0x1C00) ubyte x 325*898496eeSXin LI>>&-1 ubyte !0 \b, no EOL=%#x 326*898496eeSXin LI# no valid 2nd BASIC fragment in Commodore executables 327*898496eeSXin LI#>>&0 use basic-line 328*898496eeSXin LI# Zero-byte marking the end of the BASIC line 329*898496eeSXin LI>-3 ubyte !0 \b, 3 last bytes %#2.2x 330*898496eeSXin LI# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program 331*898496eeSXin LI>>-2 ubeshort x \b%4.4x 332*898496eeSXin LI# Summary: binary executable or Basic program for Commodore C16/VIC-20/Plus4 computers 333*898496eeSXin LI# URL: https://en.wikipedia.org/wiki/Commodore_Plus/4 334*898496eeSXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/p/prg-vic20.trid.xml 335*898496eeSXin LI# defs/p/prg-plus4.trid.xml 336*898496eeSXin LI# From: Joerg Jenderek 337*898496eeSXin LI# Note: there exist VIC-20 variants with different start address 338*898496eeSXin LI# GRR: line below is too generic because it matches Novell LANalyzer capture 339*898496eeSXin LI# with regular trace header record handled by ./sniffer 340*898496eeSXin LI0 leshort 0x1001 341*898496eeSXin LI# skip regular Novell LANalyzer capture (novell-2.tr1 novell-lanalyzer.tr1 novell-win10.tr1) with "invalid low" token value 54h 342*898496eeSXin LI>6 ubyte >0x7F 343*898496eeSXin LI# skip regular Novell LANalyzer capture (novell-2.tr1 novell-lanalyzer.tr1 novell-win10.tr1) with "invalid low" second line offset 4Ch 344*898496eeSXin LI#>>2 uleshort >0x1006 OFFSET_NOT_TOO_LOW 345*898496eeSXin LI# skip foo with "invalid high" second line offset but not for 0x123b (Minefield.prg) 346*898496eeSXin LI#>>>2 uleshort <0x1102 OFFSET_NOT_TOO_HIGH 347*898496eeSXin LI# if first token is not SYS this implies BASIC program 348*898496eeSXin LI>>6 ubyte !0x9e 349*898496eeSXin LI# valid second end of line separator implies BASIC program 350*898496eeSXin LI>>>(2.s-0x1000) ubyte =0 351*898496eeSXin LI>>>>0 use c16-prg 352*898496eeSXin LI# invalid second end of line separator !=0 implies binary executable like: Minefield.prg 353*898496eeSXin LI>>>(2.s-0x1000) ubyte !0 354*898496eeSXin LI>>>>0 use c16-exe 355*898496eeSXin LI# if first token is SYS this implies binary executable 356*898496eeSXin LI>>6 ubyte =0x9e 357*898496eeSXin LI>>>0 use c16-exe 358*898496eeSXin LI# display information about C16 program (memory address, line number, token) 359*898496eeSXin LI0 name c16-exe 360*898496eeSXin LI>0 uleshort x Commodore C16/VIC-20/Plus4 program 361*898496eeSXin LI!:mime application/x-commodore-exec 362*898496eeSXin LI!:ext prg/ 363*898496eeSXin LI# start address like: 1001h 364*898496eeSXin LI>0 uleshort !0x1001 \b, start address %#4.4x 365*898496eeSXin LI# 1st BASIC fragment 366*898496eeSXin LI>2 use basic-line 367*898496eeSXin LI# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line 368*898496eeSXin LI>(2.s-0x1000) ubyte x 369*898496eeSXin LI>>&-1 ubyte !0 \b, no EOL=%#x 370*898496eeSXin LI# no valid 2nd BASIC fragment in excutables 371*898496eeSXin LI#>>&0 use basic-line 372*898496eeSXin LI# Zero-byte marking the end of the BASIC line 373*898496eeSXin LI>-3 ubyte !0 \b, 3 last bytes %#2.2x 374*898496eeSXin LI# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program 375*898496eeSXin LI>>-2 ubeshort x \b%4.4x 376*898496eeSXin LI# display information about tokenized C16 BASIC program (memory address, line number, token) 377*898496eeSXin LI0 name c16-prg 378*898496eeSXin LI>0 uleshort x Commodore C16/VIC-20/Plus4 BASIC program 379*898496eeSXin LI!:mime application/x-commodore-basic 380*898496eeSXin LI!:ext prg 381*898496eeSXin LI# start address like: 1001h 382*898496eeSXin LI>0 uleshort !0x1001 \b, start address %#4.4x 383*898496eeSXin LI# 1st BASIC fragment 384*898496eeSXin LI>2 use basic-line 385*898496eeSXin LI# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line 386*898496eeSXin LI>(2.s-0x1000) ubyte x 387*898496eeSXin LI>>&-1 ubyte !0 \b, no EOL=%#x 388*898496eeSXin LI# 2nd BASIC fragment 389*898496eeSXin LI>>&0 use basic-line 390*898496eeSXin LI# Zero-byte marking the end of the BASIC line 391*898496eeSXin LI>-3 ubyte !0 \b, 3 last bytes %#2.2x 392*898496eeSXin LI# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program 393*898496eeSXin LI>>-2 ubeshort x \b%4.4x 394*898496eeSXin LI# Summary: binary executable or Basic program for Commodore VIC-20 computer with 8K RAM expansion 395*898496eeSXin LI# URL: https://en.wikipedia.org/wiki/VIC-20 396*898496eeSXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/p/prg-vic20-8k.trid.xml 397*898496eeSXin LI# From: Joerg Jenderek 398*898496eeSXin LI# Note: Basic v2.0 with Basic v4.0 extension (VIC20); there exist VIC-20 variants with different start addresses 399*898496eeSXin LI# start adress 1201h 400*898496eeSXin LI0 leshort 0x1201 401*898496eeSXin LI# if first token is not SYS this implies BASIC program 402*898496eeSXin LI>6 ubyte !0x9e 403*898496eeSXin LI>>0 use vic-prg 404*898496eeSXin LI# if first token is SYS this implies binary executable 405*898496eeSXin LI>6 ubyte =0x9e 406*898496eeSXin LI>>0 use vic-exe 407*898496eeSXin LI# display information about Commodore VIC-20 BASIC+8K program (memory address, line number, token) 408*898496eeSXin LI0 name vic-prg 409*898496eeSXin LI>0 uleshort x Commodore VIC-20 +8K BASIC program 410*898496eeSXin LI!:mime application/x-commodore-basic 411*898496eeSXin LI!:ext prg 412*898496eeSXin LI# start address like: 1201h 413*898496eeSXin LI>0 uleshort !0x1201 \b, start address %#4.4x 414*898496eeSXin LI# 1st BASIC fragment 415*898496eeSXin LI>2 use basic-line 416*898496eeSXin LI# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line 417*898496eeSXin LI>(2.s-0x1200) ubyte x 418*898496eeSXin LI>>&-1 ubyte !0 \b, no EOL=%#x 419*898496eeSXin LI# 2nd BASIC fragment 420*898496eeSXin LI>>&0 use basic-line 421*898496eeSXin LI# Zero-byte marking the end of the BASIC line 422*898496eeSXin LI>-3 ubyte !0 \b, 3 last bytes %#2.2x 423*898496eeSXin LI# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program 424*898496eeSXin LI>>-2 ubeshort x \b%4.4x 425*898496eeSXin LI# display information about Commodore VIC-20 +8K program (memory address, line number, token) 426*898496eeSXin LI0 name vic-exe 427*898496eeSXin LI>0 uleshort x Commodore VIC-20 +8K program 428*898496eeSXin LI!:mime application/x-commodore-exec 429*898496eeSXin LI!:ext prg/ 430*898496eeSXin LI# start address like: 1201h 431*898496eeSXin LI>0 uleshort !0x1201 \b, start address %#4.4x 432*898496eeSXin LI# 1st BASIC fragment 433*898496eeSXin LI>2 use basic-line 434*898496eeSXin LI# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line 435*898496eeSXin LI>(2.s-0x0400) ubyte x 436*898496eeSXin LI>>&-1 ubyte !0 \b, no EOL=%#x 437*898496eeSXin LI# no valid 2nd BASIC fragment in excutables 438*898496eeSXin LI#>>&0 use basic-line 439*898496eeSXin LI# Zero-byte marking the end of the BASIC line 440*898496eeSXin LI>-3 ubyte !0 \b, 3 last bytes %#2.2x 441*898496eeSXin LI# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program 442*898496eeSXin LI>>-2 ubeshort x \b%4.4x 443*898496eeSXin LI# Summary: binary executable or Basic program for Commodore PET computers 444*898496eeSXin LI# URL: https://en.wikipedia.org/wiki/Commodore_PET 445*898496eeSXin LI# Reference: http://mark0.net/download/triddefs_xml.7z/defs/p/prg-pet.trid.xml 446*898496eeSXin LI# From: Joerg Jenderek 447*898496eeSXin LI# start adress 0401h 448*898496eeSXin LI0 leshort 0x0401 449*898496eeSXin LI!:strength +1 450*898496eeSXin LI# GRR: line above with strength 51 (50+1) is too generic because it matches TTComp archive data, ASCII, 1K dictionary 451*898496eeSXin LI# (strength=48=50-2) handled by ./archive and shared library (strength=50) handled by ./ibm6000 452*898496eeSXin LI# skip TTComp archive data, ASCII, 1K dictionary ttcomp-ascii-1k.bin with "invalid high" second line offset 4162h 453*898496eeSXin LI>2 uleshort <0x0502 454*898496eeSXin LI# skip foo with "invalid low" second line offset 455*898496eeSXin LI#>>2 uleshort >0x0406 OFFSET_NOT_TOO_LOW 456*898496eeSXin LI# skip bar with "invalid end of line" 457*898496eeSXin LI#>>>(2.s-0x0400) ubyte =0 END_OF_LINE_OK 458*898496eeSXin LI# if first token is not SYS this implies BASIC program 459*898496eeSXin LI>>6 ubyte !0x9e 460*898496eeSXin LI>>>0 use pet-prg 461*898496eeSXin LI# if first token is SYS this implies binary executable 462*898496eeSXin LI>>6 ubyte =0x9e 463*898496eeSXin LI>>>0 use pet-exe 464*898496eeSXin LI# display information about Commodore PET BASIC program (memory address, line number, token) 465*898496eeSXin LI0 name pet-prg 466*898496eeSXin LI>0 uleshort x Commodore PET BASIC program 467*898496eeSXin LI!:mime application/x-commodore-basic 468*898496eeSXin LI!:ext prg 469*898496eeSXin LI# start address like: 0401h 470*898496eeSXin LI>0 uleshort !0x0401 \b, start address %#4.4x 471*898496eeSXin LI# 1st BASIC fragment 472*898496eeSXin LI>2 use basic-line 473*898496eeSXin LI# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line 474*898496eeSXin LI>(2.s-0x0400) ubyte x 475*898496eeSXin LI# 2nd BASIC fragment 476*898496eeSXin LI>>&0 use basic-line 477*898496eeSXin LI# zero-byte marking the end of the BASIC line 478*898496eeSXin LI>-3 ubyte !0 \b, 3 last bytes %#2.2x 479*898496eeSXin LI# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program 480*898496eeSXin LI>>-2 ubeshort x \b%4.4x 481*898496eeSXin LI# display information about Commodore PET program (memory address, line number, token) 482*898496eeSXin LI0 name pet-exe 483*898496eeSXin LI>0 uleshort x Commodore PET program 484*898496eeSXin LI!:mime application/x-commodore-exec 485*898496eeSXin LI!:ext prg/ 486*898496eeSXin LI# start address like: 0401h 487*898496eeSXin LI>0 uleshort !0x0401 \b, start address %#4.4x 488*898496eeSXin LI# 1st BASIC fragment 489*898496eeSXin LI>2 use basic-line 490*898496eeSXin LI# jump to 1 byte before next BASIC fragment; this must be zero-byte marking the end of line 491*898496eeSXin LI>(2.s-0x0400) ubyte x 492*898496eeSXin LI>>&-1 ubyte !0 \b, no EOL=%#x 493*898496eeSXin LI# no valid 2nd BASIC fragment in excutables 494*898496eeSXin LI#>>&0 use basic-line 495*898496eeSXin LI# Zero-byte marking the end of the BASIC line 496*898496eeSXin LI>-3 ubyte !0 \b, 3 last bytes %#2.2x 497*898496eeSXin LI# Two zero-bytes in place of the pointer to next BASIC line indicates the end of the program 498*898496eeSXin LI>>-2 ubeshort x \b%4.4x 499*898496eeSXin LI# display information about tokenized BASIC line (memory address, line number, Token) 500*898496eeSXin LI0 name basic-line 501*898496eeSXin LI# pointer to memory address of beginning of "next" BASIC line 502*898496eeSXin LI# greater then previous offset but maximal 100h difference 503*898496eeSXin LI>0 uleshort x \b, offset %#4.4x 504*898496eeSXin LI# offset 0x0000 indicates the end of BASIC program; so bytes afterwards may be some other data 505*898496eeSXin LI>0 uleshort 0 506*898496eeSXin LI# not line number but first 2 data bytes 507*898496eeSXin LI>>2 ubeshort x \b, data %#4.4x 508*898496eeSXin LI# not token but next 2 data bytes 509*898496eeSXin LI>>4 ubeshort x \b%4.4x 510*898496eeSXin LI# not token arguments but next data bytes 511*898496eeSXin LI>>6 ubequad x \b%16.16llx 512*898496eeSXin LI>>14 ubequad x \b%16.16llx... 513*898496eeSXin LI# like 0x0d20352020204c594e5820495820204259205749 "\r 5 LYNX IX BY WILL CORLEY" for LyNX archive Darkon.lnx handled by ./archive 514*898496eeSXin LI#>>3 string x "%-0.30s" 515*898496eeSXin LI>0 uleshort >0 516*898496eeSXin LI# BASIC line number with range from 0 to 65520; practice to increment numbers by some value (5, 10 or 100) 517*898496eeSXin LI>>2 uleshort x \b, line %u 518*898496eeSXin LI# https://www.c64-wiki.com/wiki/BASIC_token 519*898496eeSXin LI# The "high-bit" bytes from #128-#254 stood for the various BASIC commands and mathematical operators 520*898496eeSXin LI>>4 ubyte x \b, token (%#x) 521*898496eeSXin LI# https://www.c64-wiki.com/wiki/REM 522*898496eeSXin LI>>4 string \x8f REM 523*898496eeSXin LI# remark string like: ** SYNTHESIZER BY RICOCHET ** 524*898496eeSXin LI>>>5 string >\0 %s 525*898496eeSXin LI#>>>>&1 uleshort x \b, NEXT OFFSET %#4.4x 526*898496eeSXin LI# https://www.c64-wiki.com/wiki/PRINT 527*898496eeSXin LI>>4 string \x99 PRINT 528*898496eeSXin LI# string like: "Hello world" "\021 \323ELF-E\330TRACTING-\332IP (64 ONLY)\016\231":\2362141 529*898496eeSXin LI>>>5 string x %s 530*898496eeSXin LI#>>>>&0 ubequad x AFTER_PRINT=%#16.16llx 531*898496eeSXin LI# https://www.c64-wiki.com/wiki/POKE 532*898496eeSXin LI>>4 string \x97 POKE 533*898496eeSXin LI# <Memory address>,<number> 534*898496eeSXin LI>>>5 regex \^[0-9,\040]+ %s 535*898496eeSXin LI# BASIC command delimiter colon (:=3Ah) 536*898496eeSXin LI>>>>&-2 ubyte =0x3A 537*898496eeSXin LI# after BASIC command delimiter colon remaining (<255) other tokenized BASIC commands 538*898496eeSXin LI>>>>>&0 string x "%s" 539*898496eeSXin LI# https://www.c64-wiki.com/wiki/SYS 0x9e=\236 540*898496eeSXin LI>>4 string \x9e SYS 541*898496eeSXin LI# SYS <Address> parameter is a 16-bit unsigned integer; in the range 0 - 65535 542*898496eeSXin LI>>>5 regex \^[0-9]{1,5} %s 543*898496eeSXin LI# maybe followed by spaces, "control-characters" or colon (:) followed by next commnds or in victracker.prg 544*898496eeSXin LI# (\302(43)\252256\254\302(44)\25236) /T.L.R/ 545*898496eeSXin LI#>>>5 string x SYS_STRING="%s" 546*898496eeSXin LI# https://www.c64-wiki.com/wiki/GOSUB 547*898496eeSXin LI>>4 string \x8d GOSUB 548*898496eeSXin LI# <line> 549*898496eeSXin LI>>>5 string >\0 %s 550