Join us on Discord!
You can help CodeWalrus stay online by donating here.

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.

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.
  • Calculators owned: TI-82, TI-83, TI-83+, TI-85, TI-86, TI-92+, Sharp PC-1403

Snektron

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
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Adriweb

#2
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)
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

utz

@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:
  • Calculators owned: TI-82, TI-83, TI-83+, TI-85, TI-86, TI-92+, Sharp PC-1403

Adriweb

#4
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.
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Powered by EzPortal