Difference between revisions of "ReadingPatchVariables"

From GRFSpecs
Jump to navigationJump to search
m (7 revisions)
m (Bot: Automated text replacement (--= +==))
Line 2: Line 2:
 
=Reading Patch variables=
 
=Reading Patch variables=
   
-=Introduction=-
 
   
 
Since 2.0.1 alpha 48, it has been possible to use action D to read various special Patch variables. These are usually switch values, but there are also a few other useful values.
 
Since 2.0.1 alpha 48, it has been possible to use action D to read various special Patch variables. These are usually switch values, but there are also a few other useful values.
   
  +
==Syntax==
-=Format=-
 
   
<pre> -+&lt;Sprite-number&gt; * &lt;Length&gt; 0D &lt;target&gt; &lt;operation&gt; &lt;variable&gt; FE FF FF 00 00+-</pre>
+
<Sprite-number> * <Length> 0D <target> <operation> <variable> FE FF FF 00 00
   
  +
{|
||'''Element'''|[[GRFActionsDetailed|'''Size''']]|'''Description'''
 
  +
!Element!![[GRFActionsDetailed|Size]]!!Description
   
  +
|-
0D|B|Defines action 0D
 
  +
|0D||B||Defines action 0D
   
  +
|-
&lt;target&gt;|B|Target parameter
 
  +
|<target>||B||Target parameter
   
  +
|-
&lt;operation&gt;|B|As for ActionD, but only assignment is valid.
 
  +
|<operation>||B||As for ActionD, but only assignment is valid.
   
  +
|-
&lt;variable&gt;|B|Patch variable number to read. See below.
 
  +
|<variable>||B||Patch variable number to read. See below.
   
  +
|-
FE|B|Defines a special variable access
 
  +
|FE||B||Defines a special variable access
   
  +
|-
FF FF 00 00|D|Indicates that a patch variable is being read||
 
  +
|FF FF 00 00||D||Indicates that a patch variable is being read
  +
|}
   
 
==variable==
 
==variable==
Line 28: Line 35:
 
The following patch variables are defined:
 
The following patch variables are defined:
   
  +
{|
||variable|Switch|Value
 
  +
!variable!!Switch!!Value
   
  +
|-
00|miscmods/-Yo|Bit switch
 
  +
|00||miscmods/-Yo||Bit switch
   
  +
|-
01|experimentalfeatures/-XF|Bit switch
 
  +
|01||experimentalfeatures/-XF||Bit switch
   
  +
|-
02|morevehicles/-x|Vehicle array multiplier
 
  +
|02||morevehicles/-x||Vehicle array multiplier
   
  +
|-
03|mountains&amp;curves;/-mc|Two bytes with four sets of two bits
 
  +
|03||mountains&amp;curves;/-mc||Two bytes with four sets of two bits
   
  +
|-
04|planecrashcontrol/-Xc|Bit switch
 
  +
|04||planecrashcontrol/-Xc||Bit switch
   
  +
|-
05|autorenew/-Xa|Signed value
 
  +
|05||autorenew/-Xa||Signed value
   
  +
|-
06|multihead/-M|Speed increase, in percent
 
  +
|06||multihead/-M||Speed increase, in percent
   
  +
|-
07|disasters/-XD|Bit switch
 
  +
|07||disasters/-XD||Bit switch
   
  +
|-
08|unifiedmaglev/-XM|Unified maglev mode
 
  +
|08||unifiedmaglev/-XM||Unified maglev mode
   
  +
|-
09|bridgespeedlimits/-XX|Speed fraction, in percent
 
  +
|09||bridgespeedlimits/-XX||Speed fraction, in percent
   
  +
|-
0A|---|TTD Language, see the &quot;new scheme&quot; for [[Action4#language_id|action 4]]
 
  +
|0A||---||TTD Language, see the "new scheme" for [[Action4#language_id|action 4]]
   
  +
|-
0B|startyear/-XY|Year-1920
 
  +
|0B||startyear/-XY||Year-1920
   
  +
|-
0C|morebuildoptions/-YB|Bit switch
 
  +
|0C||morebuildoptions/-YB||Bit switch
   
  +
|-
0D|moresteam/-YM|value=LF (two hex digits), L=length, F=frequency
 
  +
|0D||moresteam/-YM||value=LF (two hex digits), L=length, F=frequency
   
  +
|-
0E|freighttrains/-Yf|weight factor
 
  +
|0E||freighttrains/-Yf||weight factor
   
  +
|-
0F|wagonspeedlimits/-YL|Speed increase for empty wagons
 
  +
|0F||wagonspeedlimits/-YL||Speed increase for empty wagons
   
  +
|-
10|planespeed/-YP|speed factor
 
  +
|10||planespeed/-YP||speed factor
   
  +
|-
11|dual company colors|2CC colormap base sprite (since r1404)
 
  +
|11||dual company colors||2CC colormap base sprite (since r1404)
   
  +
|-
12|miscmods2/-Zm|Bit switch (since r1738)
 
  +
|12||miscmods2/-Zm||Bit switch (since r1738)
   
  +
|-
13|map size information|Format = -MABXYSS (since r11961 and r1817)
 
  +
|13||map size information||Format = -MABXYSS (since r11961 and r1817)
   
  +
|-
| | M &nbsp;: the type of map
 
  +
||| || M : the type of map
   
  +
|-
| |bit 0 set : squared map. Clear : rectangular map
 
  +
||| ||bit 0 set : squared map. Clear : rectangular map
   
  +
|-
| |bit 1 set &nbsp; : Y is the bigger edge(bit 0 is clear).Clear : X is the bigger edge.
 
  +
||| ||bit 1 set : Y is the bigger edge(bit 0 is clear).Clear : X is the bigger edge.
   
  +
|-
| |A &nbsp;: minimum edge(log2) of the map
 
  +
||| ||A : minimum edge(log2) of the map
   
  +
|-
| |B &nbsp;: maximum edge(log2) of the map
 
  +
||| ||B : maximum edge(log2) of the map
   
  +
|-
| |XY : edges(log2) of each side of the map.
 
  +
||| ||XY : edges(log2) of each side of the map.
   
  +
|-
| |SS : combination of both X and Y, thus giving the size(log2) of the map
 
  +
||| ||SS : combination of both X and Y, thus giving the size(log2) of the map
   
  +
|-
| |All map sizes will be substracted by 6, as to keep the size 64 the smallest one, thus zero based||
 
  +
||| ||All map sizes will be substracted by 6, as to keep the size 64 the smallest one, thus zero based
  +
|}
   
 
If experimentalfeatures, miscmods, or miscmods2 are off, the corresponding value will be zero. For all other switches, the value is unspecified if the switch is off, so [[TTDPatchFlags|action 7 variable 85]] should be checked first.
 
If experimentalfeatures, miscmods, or miscmods2 are off, the corresponding value will be zero. For all other switches, the value is unspecified if the switch is off, so [[TTDPatchFlags|action 7 variable 85]] should be checked first.

Revision as of 23:30, 14 June 2011

Reading Patch variables

Since 2.0.1 alpha 48, it has been possible to use action D to read various special Patch variables. These are usually switch values, but there are also a few other useful values.

Syntax

<Sprite-number> * <Length> 0D <target> <operation> <variable> FE FF FF 00 00
Element Size Description
0D B Defines action 0D
<target> B Target parameter
<operation> B As for ActionD, but only assignment is valid.
<variable> B Patch variable number to read. See below.
FE B Defines a special variable access
FF FF 00 00 D Indicates that a patch variable is being read

variable

The following patch variables are defined:

variable Switch Value
00 miscmods/-Yo Bit switch
01 experimentalfeatures/-XF Bit switch
02 morevehicles/-x Vehicle array multiplier
03 mountains&curves;/-mc Two bytes with four sets of two bits
04 planecrashcontrol/-Xc Bit switch
05 autorenew/-Xa Signed value
06 multihead/-M Speed increase, in percent
07 disasters/-XD Bit switch
08 unifiedmaglev/-XM Unified maglev mode
09 bridgespeedlimits/-XX Speed fraction, in percent
0A --- TTD Language, see the "new scheme" for action 4
0B startyear/-XY Year-1920
0C morebuildoptions/-YB Bit switch
0D moresteam/-YM value=LF (two hex digits), L=length, F=frequency
0E freighttrains/-Yf weight factor
0F wagonspeedlimits/-YL Speed increase for empty wagons
10 planespeed/-YP speed factor
11 dual company colors 2CC colormap base sprite (since r1404)
12 miscmods2/-Zm Bit switch (since r1738)
13 map size information Format = -MABXYSS (since r11961 and r1817)
M : the type of map
bit 0 set : squared map. Clear : rectangular map
bit 1 set : Y is the bigger edge(bit 0 is clear).Clear : X is the bigger edge.
A : minimum edge(log2) of the map
B : maximum edge(log2) of the map
XY : edges(log2) of each side of the map.
SS : combination of both X and Y, thus giving the size(log2) of the map
All map sizes will be substracted by 6, as to keep the size 64 the smallest one, thus zero based

If experimentalfeatures, miscmods, or miscmods2 are off, the corresponding value will be zero. For all other switches, the value is unspecified if the switch is off, so action 7 variable 85 should be checked first.