View Single Post
Old 12-16-2017, 08:35 AM   #22
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
Quote:
Originally Posted by JIPG-reader View Post
In previous versions of this patch, there was only one "replace" of four bytes by another four bytes.

This is the reason why I ask.
The new patch works differently, you only need to change the last replace_int line.

(The value used by the timer is actually in milliseconds, but numbers larger than 255 are encoded in a complicated way, so with the old patch it was necessary to specify a different 4-byte sequence for 3000, 5000, etc. The new patch takes a smaller number in seconds, which can be entered as a plain integer, and multiplies it by 1024 to get an approximation of the timer value in milliseconds. The first replace_bytes line is just to set up this code to do the multiplication.)

(Edit: And if you are wondering why multiply by 1024 instead of 1000? 4 bytes is not enough space to load a multiplicand and load a multiplier and perform a normal multiplication. But there is a trick for multiplying by powers of 2 using a logical-shift-left instruction that doesn't require loading the multiplier. 1024 = 2 to the 10th power.)

Last edited by GeoffR; 12-16-2017 at 06:53 PM. Reason: Why multiply by 1024 instead of 1000?
GeoffR is offline   Reply With Quote