entropia / tip-toi-reveng

Trying to understand the file format of Tip Toi
http://tttool.entropia.de/
MIT License
647 stars 121 forks source link

Modulo 5 - calculation wrong #185

Closed SciLor closed 2 years ago

SciLor commented 6 years ago

I am using following code to generate different random numbers:

  _random:
  - T($r,65535) $random+=$r $random*=25173 $random+=13849 J(_random_next) P(nop)
  _random_next:
  - $nextId2:=$random $nextId2%=2 $nextId3:=$random $nextId3%=3 $nextId4:=$random $nextId4%=4 J(_random_next2) P(nop)
  _random_next2:
  - $nextId5:=$random $nextId5%=5 $nextId6:=$random $nextId6%=6 $nextId7:=$random $nextId7%=7

I am using them to play random sounds:

Does not play anything if _random executed once or more times

  haus_buchstabe_b_error:
  - $nextId5==0? J(haus_bett) P(nop)
  - $nextId5==1? J(haus_bild_minnie) P(nop)
  - $nextId5==2? J(haus_bild_donald) P(nop)
  - $nextId5==3? J(haus_bild_pluto) P(nop)
  - $nextId5==4? J(haus_ev_badematte) P(nop)

Plays fine random sounds

  haus_buchstabe_b_works:
  - $nextId7==0? J(haus_bett) P(nop)
  - $nextId7==1? J(haus_bild_minnie) P(nop)
  - $nextId7==2? J(haus_bild_donald) P(nop)
  - $nextId7==3? J(haus_bild_pluto) P(nop)
  - $nextId7==4? J(haus_ev_badematte) P(nop)
  - $nextId7==5? J(haus_ev_badematte) P(nop)
  - $nextId7==6? J(haus_bett) P(nop)
nomeata commented 6 years ago

You could try to debug this by using code from https://bitbucket.org/nomeata/tiptoi-taschenrechner/src/676f0352d3999b348e11daa7002281703ef2800a/taschenrechner.yaml?at=master&fileviewer=file-view-default to let the pen read out the value of $nextId5.

Maybe _random_next2 for some reason gets aborted after $nextId5 := $random?

You could try

$nextId5_tmp := $random  $nextid5_tmp %= 5 $nextId5 := $nextid5_tmp

to avoid having large values in $nextId5 if the script is aborted too early.

SciLor commented 6 years ago

The script isn't aborted. Nextid6 and 7 are filled fine and changed each time.

I will try your script to investigate it.

nomeata commented 3 years ago

Did you get to investigate this issue?

SciLor commented 3 years ago

Not really, I havn't touched the tttoool for 2 years

nomeata commented 2 years ago

I’ll close this issue, anyone feel free to reopen if still relevant.