HOW TO PATCH VOLTAGE CONTROL ============================ This text assumes, that you are familiar with the functions of VC. Please read the readme of VC and if you have a chance, take a look at my Win95 program VCPatch. I know, you wouldn't be interested in that text, if you would run a Win system, but I can't believe you don't find one in your close surrounding :) Since VoltageControl (VC) consists of several linked code segments, the parameters are spread over three locations in the PRC file. There are no absolute locations for the parameters, a patch program rather has to search for 'magic words' (explained later) followed then by the actual patch values. Future updates of BC may shift the values in the PRC file, but they will keep their location relativ to the magic words. A 'word' references to 16-bit values, all word values are stored in Motorola format MSB first, then LSB. 1. Patching the symbol position ------------------------------- The symbol position is stored in two words, one for black and white, one for gray scale display. If the patch seems to be funny, please keep in mind, that I had to keep the display routine on the Pilot as fast as possible, so I loaded the work on the patch utility :). The x-position can be 0-152, the y-position 0-147 (symbol has 8 x 13 pixels). The upper/left corner of the screen is 0,0. Reference point is the left/up corner of the symbol. The x-position can only be adapted in 8 pixel steps, such allowing x-values of 0, 8, 16, 24 etc. The formula for the word you need to store is: y*20 + x/8 . Example: Let's assume you want to position the symbol in the lower/right corner (152,147), you get a word value of: 147*20 + 152/8 = 2959. That's the value for the b/w display, the value for grayscale is always doubled. So you got now two words, 2959 and 5918. Search for the consecutive bytes 38, 60, 0, 0 and store at the next location the MSB, at the next+1 the LSB of the b/w word. Search again for 38, 60, 0, 0 and store the grayscale position word in the same way as the b/w word. To clearify that, again an example: MSB of 2959 is 11, the LSB 143. So your first patch should look like: 38, 60, 0, 0, 11, 143 . You will find exactly 2 sequences 38, 60, 0, 0 (yes, I know, I limited myself to use a MOVE #anything,d3 never again in that program ). PLEASE NOTE: If you do anything wrong (not 8-step x-pos, wrong location, etc), the hack is _very_ likely to crash!! You are modifying code! 2. Patching the symbol calibration ---------------------------------- There are 8 values you need for each battery type (Alkaline and NiCad).The first value is the 'battery full' (all 8 elements in the battery symbol are on), the last value is the 'battery empty' value. The values are words, representing the voltage * 100. (2.47volts is 247). The max. value represents a full symbol, the min. value an empty one. It is senseful (and my patch utility does so), to distribute the remaining 6 values equally between the min/max values, but it is not necessary. But it's *necessary* that the values are constantly increasing from min to max. So when the user chooses 2.1v as min. and 2.8v as max. value, you would produce the 8 values 210, 220, 230, 240, 250, 260, 270 and 280 from it. It makes no sense (for me), but you could store a sequence like 210, 211, 220, 221 etc., but never 210, 220, 215, 240, 205 or so ... :) Patching the symbol calibration starts with the search for the consecutive bytes 1, 2, 3, 4, 5, 6, 7, 8. Immediately after that, store the 8 words (16 bytes) in the order maxvalue to minvalue for the alkaline setting, then maxvalue to minvalue for the NiCad setting. So you store a total of 32 bytes. Then a 33rd byte follows, indicating whether the symbol is displayed always, or only when the battery voltage falls below the max value. The byte uses two bits, to indicate that for the alkaline setting (bit 0) and the NiCad setting (bit 1). If the corresponding bit is set to 0, the symbol shows always. Set it to 1 to blank the symbol if voltage is above max value. ATTENTION: The blank bits use only a single byte, so the total count of bytes you replace is 33. Example: Alkaline calibration: 280, 270, 260, 250, 240, 230, 220, 210 NiCad calibration: 245, 240, 235, 230, 225, 220, 215, 210 Alkaline blank: OFF NiCad blank: ON The patch: 1,2,3,4,5,6,7,8, 1,24,1,14,1,4,0,250,0,240,0,230,0,220,0,210, 0,245,0,240,0,235,0,230,0,225,0,220,0,215,0,210, 2 ( % 00000010 ) 3. Patching the warning levels ------------------------------ There are 3 warning levels for each batt. type. Warning level 1 is the highest and occurs first every 3 minutes. The 2.level occurs next and every 55 sec. The 1. and 2. level pop up the message, you should hot-sync and change batteries as fast as possible. The 3. level warning is the last one, and skips the hint for the hot-sync, assuming there is not enough power left for a serial port operation. Strange, that most urgent message occurs again every 3 minutes. The messages and the timings are the original ones from the OS. Again: The values from level 1 to 3 *must* decrease! And please: Limit the user entry to a senseful level!! If you make it possible to patch values, let's say 1.3, 1.2 and 1.1 volts, the user will probably loose his data without even getting a single warning!!! Ok, search for the magic word 1,2,3,4,5,6,7,1 , reference byte is the location after that sequence. Values are again stored as words, voltage * 100: ref+ 2/ 3 = Alkaline warning level 1 (MSB, LSB) ref+ 8/ 9 = Alkaline warning level 2 (MSB, LSB) ref+14/15 = Alkaline warning level 3 (MSB, LSB) ref+20/21 = NiCad warning level 1 (MSB, LSB) ref+26/27 = NiCad warning level 2 (MSB, LSB) ref+32/33 = NiCad warning level 3 (MSB, LSB) ref+38/39 = Warn-once-only flags The warn-once-only flags are determining, whether the warning levels 1 and 2 are repeated with the default behaviour of the OS (3 minutes and 55 seconds), or occur only once per level. The 3. level is always repeated to avoid data loss. Bit 0 is for the alkaline, bit 1 for the NiCad setting. Bit=1 means warn-once only, bit=0 means default warnings. ATTENTION: Although using only 2 bits, the warn-once-only value is a word. In the moment the 2 bits are located in the byte ref+37, but I might use the rest of the word for future improvements, so process ref+36/37 as a word value. 4. Patching the [i]nfo screen ----------------------------- Nearly forgot that one . VCPatch also updates the ascii text, that's displayed in the [i]nfo screen of VoltageControl. Here is, how it works: Search for the ascii strings 'aline:' and 'NiCad:' (case sensitive) and consider the first character of each string as the reference point for the following offsets: ref + 29/ 30/ 31/ 32 = max. calib. - 4 chars (i.e. '2.10') ref + 57/ 58/ 59/ 60 = min. calib. - 4 chars ref + 79/ 80/ 81/ 82 = Warnlevel 1 - 4 chars ref +101/102/103/104 = Warnlevel 2 - 4 chars ref +123/124/125/126 = Warnlevel 3 - 4 chars ref +153/154/155 = Warn once only - 3 chars ('ON ' / 'OFF') ref +179/180/181 = Blank below max. - 3 chars ('ON ' / 'OFF') The string 'ON ' for the last two values have a blank in the end. You probably guessed already, after you found the 'aline', you have to fill in the Alkaline values, after the 'NiCad', the NiCad values. 5. Conclusion ------------- I did VCPatch as a graphical tool, since there are quite a few values to manipulate. Sliders are nearly optimal for that task, especially since they can be easily limited to a min/max value. Also the positioning of the symbol is much nicer in a graphical environment, I used the overlay of a Pilot image to do it. There's a screen shot on my software page, just for an impression. There is no reason, not to do the patch with any hex editor, but I wouldn't want to do it manually :). A last hint: If you plan to code a tool, don't forget to *read* the values of the existing Hack of the user and use them as default. Such, little modifications from session to session are easier to do, and you don't have to start always from scratch. In that way (by the various 'magic words'), you can also determine on start up, whether you have a valid VC prc-file or not (at least most likely). And a last request: It was some work, to compile that instructions (I even had to look up some values in my own patch program ). Be so kind, to inform me in case you have written the 'killer patch utility' for DOS, WIN31, Linux, TOS, BeOS, OS/2 or whatever platform and try to make it public to other users. If you'd like, I could post it on my software page. (c)Peter Strobel, Stein, Germany January, 30th 1998 PSPilot@pstec.de http://www.pspilot.de