* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: 8*p files checksum calculation  (Read 838 times)

0 Members and 1 Guest are viewing this topic.

Offline utz

  • Full User
  • Join Date: Jun 2015
  • Location: Absurdistan
  • Posts: 150
  • Post Rating Ratio: +11/-0
  • 01000101110
    • utz82
    • utz's hp
  • WalriiPoints: 50
8*p files checksum calculation
« on: November 02, 2015, 09:45:54 pm »
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.
« Last Edit: November 02, 2015, 09:48:31 pm by utz »


  • Calculators owned: TI-82, TI-83, TI-83+, TI-85, TI-86, TI-92+, Sharp PC-1403

Offline Snektron

  • Lvl 69 Russian Snake
  • CodeWalrus Staff
  • Super User
  • Topic Management
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3161
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Re: 8*p files checksum calculation
« Reply #1 on: November 02, 2015, 09:59:35 pm »
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...


Offline Adriweb

  • Full User
  • Join Date: Jan 2015
  • Location: France & Canada
  • Posts: 407
  • Post Rating Ratio: +7/-1
    • Adriweb
    • @Adriweb
    • Adriweb
    • @UC-UIrbk5SuaUCvnV6SQvt-Q
    • /u/Adriweb
    • Adriweb
    • TI-Planet.org
  • Gender: Male
Re: 8*p files checksum calculation
« Reply #2 on: November 02, 2015, 10:03:54 pm »
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)
« Last Edit: November 02, 2015, 10:16:24 pm by Adriweb »
  • 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

Offline utz

  • Full User
  • Join Date: Jun 2015
  • Location: Absurdistan
  • Posts: 150
  • Post Rating Ratio: +11/-0
  • 01000101110
    • utz82
    • utz's hp
  • WalriiPoints: 50
Re: 8*p files checksum calculation
« Reply #3 on: November 02, 2015, 10:51:52 pm »
@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

Offline Adriweb

  • Full User
  • Join Date: Jan 2015
  • Location: France & Canada
  • Posts: 407
  • Post Rating Ratio: +7/-1
    • Adriweb
    • @Adriweb
    • Adriweb
    • @UC-UIrbk5SuaUCvnV6SQvt-Q
    • /u/Adriweb
    • Adriweb
    • TI-Planet.org
  • Gender: Male
Re: 8*p files checksum calculation
« Reply #4 on: November 02, 2015, 10:58:36 pm »
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.
« Last Edit: November 02, 2015, 11:05:26 pm by Adriweb »
  • 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

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games