|
TTDPatch Site |
Action6
Action 6Modify the contents of the following spriteAction 6 allows modifying the contents of the following sprite. It uses the values of the grf parameters and writes them into the data of the following sprite. The data looks as follows: <Sprite-number> * <Length> 06 (<param-num> <param-size> <offset>){n} FF
The triplet of <param-num> <param-size> <offset> can be repeated as often as desired. Sprite-numberThis is just the number you are at.LengthCount the number of bytes in this action.param-numThis is the parameter number from the newgrf(w).cfg parameters to apply to the following sprite data. It can of course be the result of an ActionD calculation as well. The first parameter has number 00.The modification is not carried out if the parameter has not been defined yet. param-sizeHow many bytes of the parameter to use. If this is larger than 4 (the size of a parameter), the bytes of the following parameter are used. In that case, all required parameters must be defined or no modification will be done.If this value has bit 7 set, the parameter is added to the destination value, instead of simply stored. This is useful especially when allocating sprites using the GRF Resource Management, because one typically allocates more than one sprite, but the parameter can only hold a single number, the first sprite allocated. Thus, to apply several sprite numbers properly (such that it works for several activations, not just the first one), use an algorithm like the following:
offsetNumber of byte in the following sprite to modify. The counting starts with 0 at the action byte and can go up to the length of the sprite. It is not possible to add data at the end of the sprite.Since TTDPatch 2.0.1 alpha 51, this is an extended byte (see GRFActionsDetailed). This action is processed only once during the initialization of a .grf file and is ignored during the following activations every time a game is started or loaded. Therefore, to conditionally skip this action, you must use action 9 and not action 7. Since 2.0.1 alpha 51, this is no longer true, Action 6 will be applied both at initialization as well as activation. You can therefore use either action 7 or 9 to skip it, whichever is appropriate. This is an example on how to apply the sprite numbers returned by the GRF Resource Management to an action 0: // First, set param 1 (<j>) to the old value of param 0 (<i>)
-1 * 5 0D 01 00 00 00
// Then, use the GRF Resource Management to reserve 3 sprites
-1 * 9 0D 00 00 00 FE FF 08 03 00
// Now calculate <j> = <i> - <j>
-1 * 5 0D 01 02 00 01
// So <j> = new <i> - old <i>
// Use Action 6 to add <j> to the sprite numbers in the sample sprite layout
-1 * 11 06 01 84 07 01 84 11 01 84 1B FF
-1 * 32 00 04 01 01 00 09
01
00 00 00 00 // first allocated sprite
00 00 00 10 05 02 01 00 00 00 // second allocated sprite
00 0B 00 10 05 02 02 00 00 00 // third
80
Created by: system last modification: Monday 27 of November, 2006 [01:24:51 UTC] by patchman |
Login Search
|