blm@cxsea.UUCP (Brian Matthews) (01/01/89)
Note: in the follow article I describe how to make some modifications to standard Macintosh system software. Only do this if you understand the instructions, and take the normal precautions (backup, use a copy of the System, etc). The modifications are fairly simple, but don't blame me if you screw something up. After reading the discussion on moving the cursor faster, I decided to dig around a bit. So, taking Macsbug in hand (so to speak), I disassembled the cursor VBL, and figured out (approximately) how the mcky resources are used. Note that I'm working on a MacPlus running System 6.0.2, but I suspect the scaling stuff is the same for ADB rodents and recent systems. As someone else pointed out, there is one mcky resource for each of the Mouse Tracking choices in the Mouse cdev. They are stored as mcky 0 (tablet) through mcky 4 (fastest) in the System file. Each mcky resource consists of 8 bytes. Each byte is a threshold value, and the index of the byte within the mcky is the scale value. It's not entirely clear exactly how the value that is compared to the threshold value is computed. It has something to do with how far the mouse moved in the last 60th of a second (obviously :-)), but the cursor VBL also appears to keep some kind of running average. This means that in a short move, long move pair, the long move will be scaled less than in a long move, long move pair. In any case, a movement value between 1 and 255 is calculated, and looked up in the current mcky resource. The index of the first byte greater than or equal to the movement value is used as the scale factor. For example, the tablet mcky resource is all FF's, so the movement value is always less than the first threshold, and no scaling is done. The fastest mcky resource contains 01 04 07 0A 0D 0F 10 FF, so that a movement value of 1 will result in no scaling (matching the first theshold value), but a movement value of 0C will result in a scale factor of 5 (as the 5th byte counting from 1 is 0D and the first threshold greater than or equal to the movement value of 0C). The last byte is FF so the movement value will always at least match this. The mcky resource is copied into the cursor VBL, so it can't be made longer without patching the cursor VBL itself. Therefore, the maximum scale factor is fixed at 8 without patching (which I'll talk about in a bit). You can however, modify a mcky so that scaling takes place faster. For instance, I modifed mcky 0 to read 01 03 03 03 03 03 03 FF. A movement factor of 1 still results in a scale factor of 1 (so I can still move the mouse in single pixel increments). A movement factor of 2 or 3 will result in a scale factor of 2, and any larger movement factor will result in the maximum scale factor. If you'd like to modify a mcky, simply fire up ResEdit, open the System file and the mcky resources, and choose one of them. I chose 0, as this a "special" mcky in a sense. You can use any of them, just remember which. When you have decided on a mcky to use, open it. You will see 8 hex bytes. These are the threshold values. Simply change the bytes you want changed, and save everything. Note that the last byte should always be FF so the search stops, and there should be exactly eight bytes. Next, open the control panel, choose Mouse, and select the mouse tracking corresponding the mcky you modified. The cursor movement should change immediately to reflect the changed mcky. You can also experiment by modifying the threshold value in memory. To do this, you'll need Macsbug or some other debugger. I've included in parens the Macsbug 6.0 command to use in each case. First, get into the debugger, and disassemble the instructions E8 bytes past the address in 8ee (il @8ee+e8). This should look something like: LEA *-$00F0,A0 CLR.W D2 ADDQ.W #$1, D2 CMP.B (A0)+,D5 BHI.S *-$0004 If it doesn't look like this, STOP! You're cursor VBL is different than mine. If it is the same as this, the address placed in A0 by the LEA is the address of the copy of the mcky resource. It will be 8 bytes before the address in 8ee (so you can look at them with dm @8ee-8). You can modify these bytes in memory, and instantly see the effect on the cursor (use sb @8ee-8 xx xx xx xx xx xx xx in Macsbug). Note that you should leave the last byte FF. A future project for some intrepid INIT writer out there is to write an INIT which patches the cursor VBL to use a different address, so a larger mcky can be used. As the LEA only takes four bytes, it will take some doing. You'd also have to think about what to do with Control Panel, as the mouse copies the chosen mcky into the cursor VBL, like we did by hand above. -- Brian L. Matthews blm@cxsea.UUCP ...{mnetor,uw-beaver!ssc-vax}!cxsea!blm +1 206 251 6811 Computer X Inc. - a division of Motorola New Enterprises