[ACK PATCH] Hacking the DRAW command to display tiles
Posted: Wed Sep 09, 2009 12:33 pm
This code patch for the ACK player module (ACK02) is based on the ACK 3.251 release, using the procedure described in a previous post. Warning: given that I do not understand approximately 99% of the code in the ACK source package, it is entirely possible (and in fact quite likely) that modifying your ACK release as detailed below will result in horrific bugs and crashes. I take no responsibility for any aggravation that results from this.
The following edit extends the DRAW macro command, which is normally used to draw a line between two points on the screen:
DRAW x1 y1 TO x2 y2 OF color thickness
For example, the command "DRAW 0 0 TO 100 100 OF 15 1" draws a line from (0,0) to (100,100) with color 15 (white) and thickness 1 pixel.
Since this macro command has a lot of parameters, it is a useful place to squeeze in some unofficial hooks to allow macros to do interesting things that they cannot currently do. This edit extends the DRAW command so that it can also be used to draw a single tile (from the primary set) on the screen.
The hook checks the first two parameters of the DRAW command. If x1 is anything other than 999, the code assumes you are trying to draw a line and proceeds accordingly. If x1=999, the second parameter (y1) is checked. If y1=1, then the command draws a tile using the following parameters:
DRAW 999 1 TO <x> <y> OF <tile> 0
The function that actually draws the tile (putgrap, in U_GRAPS.PAS) multiplies x by 4 and adds 1 to y before drawing the tile, so if you say:
DRAW 999 1 TO 4 31 OF 42 0
then tile #42 will be drawn at x=16, y=32. The tile numbering (which starts at 1 for the first tile) matches the tile numbers shown in the graphic tile editor.
THE EDIT: In O_PLAY0.PAS starting around line 2462, replace the following code in the run_macro procedure
with the code
Testing this out in BRIGANDS, the following macro

displays tiles as shown below:

This could be used to create animations centered on the player and other effects that mosaics do not easily allow. Note that the tile-drawing is low level and does not include the transparency function; as with mosaics, tiles are drawn exactly as shown in the editor.
The following edit extends the DRAW macro command, which is normally used to draw a line between two points on the screen:
DRAW x1 y1 TO x2 y2 OF color thickness
For example, the command "DRAW 0 0 TO 100 100 OF 15 1" draws a line from (0,0) to (100,100) with color 15 (white) and thickness 1 pixel.
Since this macro command has a lot of parameters, it is a useful place to squeeze in some unofficial hooks to allow macros to do interesting things that they cannot currently do. This edit extends the DRAW command so that it can also be used to draw a single tile (from the primary set) on the screen.
The hook checks the first two parameters of the DRAW command. If x1 is anything other than 999, the code assumes you are trying to draw a line and proceeds accordingly. If x1=999, the second parameter (y1) is checked. If y1=1, then the command draws a tile using the following parameters:
DRAW 999 1 TO <x> <y> OF <tile> 0
The function that actually draws the tile (putgrap, in U_GRAPS.PAS) multiplies x by 4 and adds 1 to y before drawing the tile, so if you say:
DRAW 999 1 TO 4 31 OF 42 0
then tile #42 will be drawn at x=16, y=32. The tile numbering (which starts at 1 for the first tile) matches the tile numbers shown in the graphic tile editor.
THE EDIT: In O_PLAY0.PAS starting around line 2462, replace the following code in the run_macro procedure
Code: Select all
50:begin {draw: x y to x y of color thickness}
thickln2(mac_var(1),mac_var(2),mac_var(3),mac_var(4),mac_var(5),mac_var(6));
end;
Code: Select all
50:begin {draw: x y to x y of color thickness}
if (mac_var(1) = 999) then
begin
if (mac_var(2) = 1) then
begin
putgrap(mac_var(3), mac_var(4), mac_var(5));
end;
end else
begin
thickln2(mac_var(1),mac_var(2),mac_var(3),mac_var(4),mac_var(5),mac_var(6));
end;
end;

displays tiles as shown below:

This could be used to create animations centered on the player and other effects that mosaics do not easily allow. Note that the tile-drawing is low level and does not include the transparency function; as with mosaics, tiles are drawn exactly as shown in the editor.