July 11, 2020, 08:11:10 pm

The shoutbox is currently out of service. Join us on Discord instead.
You can help CodeWalrus stay online by donating here.

WARNING: DO NOT UPGRADE your TI-83 Premium CE or TI-84 Plus CE to OS 5.5.1 and higher. It removes all compatibility with most games and removes ASM/C programming! DOWNGRADING IS IMPOSSIBLE. BE WARNED! Likewise, do NOT update your TI-Nspire CX past OS 4.5.0, else using Ndless and ASM/C programs will be impossible.

8*p files checksum calculation

Started by utz, November 02, 2015, 09:45:54 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


November 02, 2015, 09:45:54 pm Last Edit: November 02, 2015, 09:48:31 pm by utz
Fiddeling with a new TI-Z80 program packer because I'm not happy with any of the existing ones. Now I noticed something strange regarding checksum calculation for 82p files.

It seems the 82 actually doesn't care about the checksum at all. I've compared outputs of a few different utilities (original CrASH packer, bin8x, and my own oysterpac.pl), and they all give different checksum values, however all the files run just fine in CrASH.

The "holy" Link Guide states that the checksum is "the lower 16 bits of the sum of all bytes in the data section." However, that's certainly not what bin8x and crprgm82.exe are doing.
So what exactly is the 'correct' way of calculating the checksum? Can one just supply a random value and assume CrASH to correct it at relocation time? Also, how is this handled on other models? Seems I'm not getting away with this on TI83 for example.


i made a java binpack 8xp a while ago, but i think that uses the same way to calcuate it as binpack 8xp.
IIRC i only made it because the ohter one was in python and relative paths were doing weird
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


November 02, 2015, 10:03:54 pm #2 Last Edit: November 02, 2015, 10:16:24 pm by Adriweb
Here are my PHP and C++ implementations of the checksum calculation/retrieval (several ways: one from instance data when a file has been opened, one when it's created from scratch, and one just reading from the file):
- https://github.com/adriweb/tivars_lib/blob/master/src/TIVarFile.php#L179-L218
- https://github.com/adriweb/tivars_lib_cpp/blob/master/src/TIVarFile.cpp#L151-L191
(they're identical, just the language-syntax changes, basically, so take your pick)
Co-founder & co-administrator of TI-Planet and Inspired-Lua


@Adriweb: Damn, that looks so much more professional than my n00bish fumblings, I should just use that. But then again I need to learn some high level coding, so I'm probably gonna stick with mine. ... So in essence, seems you're sticking to the Link Guide, ie. calculating the checksum from file offset 55. crprgm82 on the other hand calculates it from offset 60, then subtracts 86 from the value.  ???  :crazy:


November 02, 2015, 10:58:36 pm #4 Last Edit: November 02, 2015, 11:05:26 pm by Adriweb
I don't know crprgm82 but from the way you describe it, it's probably just hardcoding things specific for the program vartypes (0x05 and 0x06), and it simply adds the known partial checksum + the data len after that (adds to the checksum once calculated, I mean), so it doesn't need to start at 55 like I do (to handle other vartypes) but 60, right where the actual custom data starts.

Anyway, you're welcome to use my lib if you want, it's not open-source and under the MIT License for nothing :)
If you do so, check out the tests.{php,cpp} file, it should get you started.
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Powered by EzPortal