[ACK PATCH] Hacking the DRAW command to display tiles

Chris H.'s Ultima / ACS-style game development system!

Moderators: Ice Cream Jonsey, joltcountry

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

[ACK PATCH] Hacking the DRAW command to display tiles

Post by rld »

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

Code: Select all

50&#58;begin &#123;draw&#58; x y to x y of color thickness&#125;
   thickln2&#40;mac_var&#40;1&#41;,mac_var&#40;2&#41;,mac_var&#40;3&#41;,mac_var&#40;4&#41;,mac_var&#40;5&#41;,mac_var&#40;6&#41;&#41;;
end;

with the code

Code: Select all

   50&#58;begin &#123;draw&#58; x y to x y of color thickness&#125;
      if &#40;mac_var&#40;1&#41; = 999&#41; then
      begin
         if &#40;mac_var&#40;2&#41; = 1&#41; then
         begin 
            putgrap&#40;mac_var&#40;3&#41;, mac_var&#40;4&#41;, mac_var&#40;5&#41;&#41;;
         end;
      end else
      begin
            thickln2&#40;mac_var&#40;1&#41;,mac_var&#40;2&#41;,mac_var&#40;3&#41;,mac_var&#40;4&#41;,mac_var&#40;5&#41;,mac_var&#40;6&#41;&#41;;
      end;
   end;

Testing this out in BRIGANDS, the following macro

Image

displays tiles as shown below:

Image

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.

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

That is awesome!
Which of you is interested in my fine wares?

Post Reply