· 9 years ago · Jan 10, 2017, 10:32 PM
1//Docs for 2.54 Beta
2//Rev. 0.9.5
3//for 2.54 b52
4//10th January, 2017
5
6Search for !#! to find areas that require completion.
7
8//===================================================================================
9// --- ZScript built-in functions and variables ---
10//===================================================================================
11/*
12* These functions are all INTERNAL to ZQuest. They require no header
13* or other import directives to work, and are all direct representations
14* of ZASM instructions.
15*
16* These functions and commands are the BASIC BUILDING BLOCKS of ZScript:
17* While they require no other functions to work, ALL other functions
18* in headers (such as std.zh) RELY, and OPERATE using these functions.
19*
20* Thus, it is essential to know what each of these does, how they work,
21* and how to use them.
22*
23* For other included functions, that are not internal (i.e. external functions)
24* please read the documentation specific to each header. These are individual
25* files (e.g. std.txt), however if you wish to view all the pre-packaged ZScript
26* functions, and commands, you may view the EXTENDED DOCUMENTATION, as
27* those documentation files contain all of the 'Essential ZScript' that
28* you will want to use.
29*
30* Where possible, the ZASM instruction used by the functions, and the
31* commands detailed herein are listed inline with the entry for the related
32* function / command. Full (public) ZASM documentation is, sadly incomplete.
33*
34* Note: Functions and variables other than global functions are properties
35* of **objects**. Objects are divided into NAMESPACEs and CLASSes, and the
36* the syntax for using them is:
37*
38* [object name]->[property]
39*
40* where "[object name]" is the object's name (e.g. Link, Game, Screen)/
41* and "[property]" is the function.
42*
43* Example:
44* void GetCurDMap() is a Game property, and is called as:
45*
46* Game->GetCurDMap();
47*
48* "Link", "Screen" and "Game" are always available and don't need to be
49* instantiated, while you must initialise other classes, such as ffc, item,
50* and npc.
51*
52* ZScript functions are of the types: int, float, bool, and void. Of these,
53* only void does not return a value. (The void type is normally used to run
54* a series of instructions, or to set values). The other types retrun values
55* appropriate to their type.
56*
57* Note: In the following, "int" indicates that a parameter is truncated by a
58* function to an integer, or that the return value will always be an integer
59* however, ZScript itself makes no distinction between int and float types.
60*/
61
62/************************************************************************************************************/
63
64//////////////////
65/// ZASM Flags ///
66//////////////////
67
68ZASM uses a series of special flags, to determine how it should follow logical instructions,
69including the following:
70
71SCRIPT FLAGS
72TRUEFLAG : A condition in the script, is true
73MOREFLAG : Must be set manually with ZASM.
74FALSEFLAG : Must be set namually with ZASM.
75LESSFLAG : Must be set manually with ZASM.
76
77Instructions
78SETTRUE : Set the Script Flag TRUEFLAG.
79 SETTRUE Sets a true condition for the Assembler, if a COMPARERV and COMPARER validate.
80 This is used when making statements in ZScript.
81SETFALSE: Set the Script Flag FALSEFLAG: ZScript does not do this.
82SETMORE : Set the Script FLag MOREFLAG: ZScript does not do this.
83SETLESS : Set the Script Flag LESSFLAG: ZScript does not do this.
84
85These flags are used in evaluation instructions, to determine if an instruction should run.
86
87Examples of these are as follows:
88
89GOTOTRUE: Executes the GOTO instruction only if the Script Flag TRUEFLAG is enabled.
90GOTOFALSE: Executes the GOTO instruction only if the Script Flag FALSEFLAG is enabled.
91GOTOMORE: Executes the GOTO instruction only if the Script Flag MOREFLAG is enabled.
92GOTOLESS: Executes the GOTO instruction only if the Script Flag LESSFLAG is enabled.
93
94In contrast, GOTO/GOTOR ignore all flags, and conditions.
95
96ZScript always compiles down to GOTO, GOTOR, and GOTOTRUE instructions.
97The other FLAG-typed GOTO instruction types are valid only in ZASM, and serve no useful purpose.
98GOTOLESS, GOTOMORE, and GOTOFALSE are effectively deprecated.
99
100//=======================================================
101//--- Instruction Processing Order and General Timing ---
102=========================================================
103
1041. Instructions in Global script Init (if starting a new game)
1052. Instructions in Global Script OnContinue (is resuming a game)
1063. Instructions immediately inside the run() function of a global active script.
1074. Instructions in the global active script's infinite loop prior to Waitdraw,
108 if (5) does not exist, or on the first frame of the game.
1095. Instructions from an ffc script positioned after (an illegal)
110 Waitdraw() instruction in that script from the previous frame.
111 Note: Requires being on at least the second frame of a game session.
1126. Instructions in the global active script prior to Waitdraw().
1137. Instructions in an ffc script, other than (5), excluding draw commands.
1148. Screen Scrolling (2.50.2, or later)
1159. Instructions from item scripts.
11610. Waitdraw() in a global active script.
11711. Engine writing to Link->Dir and Link->Tile.
11812. Instructions in the global active script, called after Waitdraw()
11912(b). Screen Scrolling ( 2.50.0, and 2.50.1 )
12013. Drawing from FFCs
12114. Instructions in an OnExit script, if the game is exiting.
12215. Return to (5).
123
124
125//=================
126//--- Pointers ---
127//=================
128
129Global array pointers start at 4096 (when traced). These are added in escalating value, but in the reverse-order
130of declaration. e.g. The last declared array will be ID 4096.
131
132/************************************************************************************************************/
133
134
135////////////////////////
136/// Operator Symbols ///
137////////////////////////
138
139ZScript supports value input as decimal, hexidecimal, and binary.
140
141To input hexidecimal values, preface them with '0x'. Thus, '0x0F' for '16'.
142To input binary balues, end them with a lowercase 'b'. Thus, '11b' for '3'.
143
144Name Sign ZASM (R) ZASM (V) Definition
145PLUS + ADDR<><> ADDV<><> Adds a value a + b, a + 3
146MINUS - SUBR<><> SUBV<><> Subtracts a value a - b, a - 2
147INCREMENT ++ Increments a value by '1'
148DECREMENT -- Decreases a value by '1'
149MULTIPLY * MULTR<><> MULTV<><> Multiplies values a * b
150DIVIDE / DIVR<><> DIVV<><> Divides values a / b
151MODULUS % Returns the remainder of integer division of 4 % 2
152NOT ! NOT<> Inverse logic boolean operator.
153 if ( !var1 == 0 ) returns true if var1 is zero,
154 and false if var1 is non-zero
155EQUALS = SETR<><> SETV<><> Sets a value to another value a = 4
156EXACTLY EQUALS == Compares value a == b and returns if they match.
157NOT EQUALS != Compares values a != b and returns if they do not match,
158LESSTHAN < Comapres a < b and returns if a is less then b.
159MORETHAN > Compares a > b and returns if a is more than b.
160LOGICAL OR || Boolean logic, Or.
161LOGICAL AND && Boolean Logic And.
162
163SET ADDRESS ARG SETA1<><>
164 SETA2<><>
165GET ADDRESS ARG GETA1<><>
166 GETA2<><>
167
168Note: LOGICAL XOR (^^) is not valid in ZScript, but you may simulate it with custom functions.
169
170
171/////////////////////////
172/// Bitwise Operators ///
173/////////////////////////
174
175Reminder: You may reference a binary value using a numeric sequence, ending in 'b':
176 0100010b
177 ('34' decimal)
178
179Or ZScript Symbol ZASM Instructions:
180 | ORV<><>
181 ORR<><>
182
183And ZScript Symbol ZASM Instructions:
184 & ANDR<><>
185 ANDV<><>
186
187Not ZScript Symbol ZASM Instructions:
188 ~ BITNOT<>
189
190Left Shift:
191 ZScript Symbol ZASM Instructions
192 << LSHIFTV<><>
193 LSHIFTR<><>
194
195Right Shift:
196 ZScript Symbol ZASM Instructions
197 >> RSHIFTV<><>
198 RSHIFTR<><>
199
200Xor ZScript Symbol ZASM Instructions:
201 ^ XORV<><>
202 XORR<><>
203
204Nor ZScript Symbol ZASM Instructions:
205 ~| NORV<><>
206 NORR<><>
207
208XNor ZScript Symbol ZASM Instructions:
209 ~^ XNORV<><>
210 XNORV<><>
211
212Nand ZScript Symbol ZASM Instructions:
213 ~& NANDV<><>
214 NANDR<><>
215
216/************************************************************************************************************/
217
218
219//========================
220//--- Global Functions ---
221//========================
222
223/////////////////////////
224/// General Functions ///
225/////////////////////////
226
227
228void Waitdraw(); ZASM Instruction:
229 WAITDRAW
230/**
231* Halts execution of the script until ZC's internal code has been run (movement,
232* collision detection, etc.), but before the screen is drawn. This can only
233* be used in the active global script.
234* Waitdraw() may only be called from the global active script; not from FFC scripts.
235* The sequence of ZC actions is as follows:
236
237* FFCs (in numerical sequence, from FFC 01, to FFC 32)
238* Enemies
239* EWeapons
240* Link
241* LWeapons
242* Hookshot
243* Collision Checking
244* Store Link->Input / Link->Press
245* Waitdraw()
246* Drawing
247* Rendering of the Screen
248* Screen Scrolling
249* Drawing from FFCs
250*
251* Note: Drawing from FFCs technically occurs with other Drawing, but as it is issued after Waitdraw(),
252* it is offset (a frame late) and renders after screen scrolling, and after any other drawing in the same
253* frame as draw instructions from ffcs are called. To ensure that drawing done by ffcs is in sync with
254* other drawing, it is imperative to call it from your global script, using the ffc to trigger global
255* conditions that cause global drawing instructions that are called before Waitdraw() in your global
256* active script to evaluate true.
257*
258* Anything placed after Waitdraw() will not present graphical effects until the next frame.
259* It is possible { ! CHECK } to read/store Link->Tile, Link->Dir and other variables *after* Waitdraw()
260* in one frame, and then use these values to modify other pointer members so that they are drawn correctly
261* at the next execution of Waitdraw().
262*
263*
264*/ Example Use:
265
266 Waitdraw();
267
268//! Submit bug report that Link->Dir and Link->Tile are incorrect before Waitdraw.
269
270*//////////////////////////////
271* Waitdraw() in ffc scripts ///
272* --------------------------///
273* Althouth technically illegal, it is possible to call Waitdraw() in an *ffc script*. Doing this has the
274* following effects, and/or consequences:
275*
276* 1. The Compiler will report an error, and print the error to Allegro log:
277* 'Warning: Waitdraw() may only be used in global scripts.'
278* 2. Any instruction sint he ffc script that are called before the Waitdraw() instruction in the ffc script
279* will run this frame, after Waitdraw() in your global active script.
280* 3. Any instructions called *after* Waitdraw() in the ffc script, will run BEFORE BOTH Waitdraw() in your
281* global active script, and BEFORE any other instructions in your global active script's infinite loop.
282*
283* This behaviour may change in future versions of ZC, and using Waitdraw() in ffc scripts is not advised.
284
285*///////////////////////////////
286* Waitdraw() in item scripts ///
287* ---------------------------///
288* Althouth technically illegal, it is possible to call Waitdraw() in an item sctipt. Doing this has the
289* following effects, and/or consequences:
290*
291* 1. The Compiler will report an error, and print the error to Allegro log:
292* 'Warning: Waitdraw() may only be used in global scripts.'
293* 2.
294*
295* This behaviour may change in future versions of ZC, and using Waitdraw() in item scripts is not advised.
296
297/************************************************************************************************************/
298
299void Waitframe(); ZASM Instruction:
300 WAITFRAME
301/**
302* Temporarily halts execution of the current script. This function returns at
303* the beginning of the next frame of gameplay.
304* Slots 1, 3 and 4 Global scripts and item scripts only execute for one frame,
305* so in those scripts Waitframe() is essentially Quit().
306* It is safe to call Waitframe in the active global script.
307* A Waitframe is required in all infinite loops (e.g. while(true) ) so that ZC may
308* pause to break in order to advance to the next frame, then resume the loop from the start.
309*
310*/ Example Use:
311
312 Waitframe();
313
314*///////////////////////////////
315* Waitdraw() in item scripts ///
316* ---------------------------///
317* Althouth technically legal, it is invalid to call Waitframe() in an item sctipt. Doing this has the
318* following effects, and/or consequences:
319*
320* 1. The script will prematurely exit.
321*
322* Calling Waitframe() in an item script is effectively identical to calling Quit(), however this behaviour
323* may change in future versions of ZC, and using Waitframe() in item scripts is not advised.
324
325/************************************************************************************************************/
326
327void Quit(); ZASM Instruction:
328 QUIT
329/**
330* Terminates execution of the current script. Does not return.
331* Caution: If called from a global script, the script itself exits.
332*
333*/ Example Use:
334
335 Quit();
336
337/************************************************************************************************************/
338
339////////////////////
340/// Modify Tiles ///
341////////////////////
342
343
344void CopyTile(int srctile, int desttile); ZASM Instruction:
345 COPYTILERR d2,d3
346 COPYTILEVV
347 COPYTILERV
348 COPYTILEVR
349/**
350* Copies the tile specified by scrtile onto the tile space
351* specified by desttile. The valid tile value range is 0 to 65519.
352* This change is temporary within the quest file
353* and not be retained when saving the game.
354*
355*/ Example Use:
356
357 CopyTile(312,11614);
358 Copies tile 312, to tile 11614. Tiles 312, and 11614 will be identical.
359
360/** TIP **
361* CopyTile may be used to change Link's tile, by copying a tile onto whatever tile ZC is
362* using as a source for Link->Tile
363* Thus, although you cannot write directly to Link->Tile, you can write to the actual tile
364* that is being used for this Link attribute, and you can do this for any other game graphic
365* that you need to change.
366*
367* When doing this, it is important to read Link->Dir or Link->Flip, *after* Waitdraw() and
368* perform the CopyTile() operation immediately thereafter.
369*/
370
371/************************************************************************************************************/
372
373void SwapTile(int firsttile, int secondtile); ZASM Instruction:
374 SWAPTILERR d2,d3
375 SWAPTILEVV
376 SWAPTILEVR
377 SWAPTILERV
378/**
379* Swaps the two tiles specified by firsttile and secondtile.
380* The valid tile value range is 0 to 65519.
381* This change is *TEMPORARY* within the quest file
382* and will not be retained when saving the game.
383*
384*/ Example Use:
385
386SwapTile(312,11614);
387Changes tile 11614 into tile 312; and tile 312 into tile 11614, transposing their positions.
388
389/************************************************************************************************************/
390
391void OverlayTile(int firsttile, int secondtile); ZASM Instruction:
392 OVERLAYTILEVV
393 OVERLAYTILEVR
394 OVERLAYTILERV
395 OVERLAYTILERR
396/**
397* Overlays secondtile onto firsttile, ignoring all pixels of colour 0.
398* The valid tile value range is 0 to 65519.
399* This change is *TEMPORARY* within the quest file
400* and will not be retained when saving the game.
401*
402*/ Example Use:
403
404
405/************************************************************************************************************/
406
407void ClearTile(int tileref); ZASM Instruction:
408 CLEARTILER <d3>
409 CLEARTILEV
410/**
411* Erases the tile specified by tileref.
412* This change is temporary within the quest file
413* and will not be retained when saving the game.
414* Tiles are not / are (!check!) shifted upward to adjust for the cleared tile.
415*
416*/ Example Use:
417
418 ClearTile(21362);
419 Clears tile 21362 by ( blanking it to colour 0 ) | ( removing it and shifting all tiles
420 thereafter upward ).
421
422/************************************************************************************************************/
423
424//Overlay Tile
425
426//! Is there a ZScript equivalent of this?!
427//! This instruction seems to be ***ZASM-specific***.
428//! Game->overlayTile() and Screen->OverlayTile() both return an error (no such pointer).
429//! Add this to the bytecode in a future build.
430//! As far as I can tell, this should work from ZASM, but it was never added to the ZScript side. (11/July/2016: ZRPG)
431
432void OverlayTile() ?
433
434 OVERLAYTILEVV
435 OVERLAYTILEVR
436 OVERLAYTILERV
437 OVERLAYTILERR
438
439/************************************************************************************************************/
440
441///////////////
442/// Tracing ///
443///////////////
444
445
446void Trace(float val); ZASM Instruction:
447 TRACER d3
448 TRACEV
449/**
450* Prints a line containing a string representation of val to allegro.log.
451* Useful for debugging scripts. You may trace int, and float types.
452* For b oolean values, see TraceB() below.
453* Values printed to allegro.log no not incorporate any spacing, or carriage
454* returns. You must manually add these into your commands.
455* Int values are not truncated when printed, and will always have four leading
456* zeros after the decimal point.
457* To add new lines (carriange returns), see TraceNL() below.
458*
459*/ Example Use:
460
461 int val = 4;
462 Trace(val);
463 Prints 4.000 to allegro.log
464
465/************************************************************************************************************/
466
467void TraceB(bool state); ZASM Instruction:
468 TRACE2R d3
469 TRACE2V
470/**
471* Prints a boolean state to allegro.log. Works as trace() above, but prints 'true'
472* or 'false' to allegro.log
473*
474*/ Example Use:
475
476 bool test = true;
477 TraceB(test);
478 Prints 'true' to allegro.log.
479
480/************************************************************************************************************/
481
482void TraceToBase( int val, int base, ZASM Instruction:
483 int mindigits ); TRACE3
484/**
485* Prints a line in allegro.log representing 'val' in numerical base 'base',
486* where 2 <= base <= 36, with minimum digits 'mindigits'.
487* (Base must be at least base-2, and at most, base-36)
488* Can be useful for checking hex values or flags ORed together, or just to trace
489* an integer value, as Trace() always traces to four decimal places.
490* mindigits specifies the minimum number of integer digits to print.
491* Unlike Trace(), Decimal values are not printed. TraceToBase *does not* handle floats.
492* If you specify a floating point value as arg 'val', it will be Floored before conversion.
493*
494*/ Example Use:
495
496 TraceToBase(20,8,1);
497 Converts (decimal) d20 to base-8 (o24 in base-8) and prints value '024' to allegro.log
498
499 TraceToBase(50,16,1);
500 Converts (decimal) d50 to base-16 (0x32 hexadecimal) and prints value '0x32' to allegro.log.
501
502/************************************************************************************************************/
503
504void ClearTrace(); ZASM Instruction:
505 TRACE4
506/**
507* Clears allegro.log of all current traces and messages from Zelda Classic/ZQuest.
508* Works on a per-quest, per-session basis. Values recorded from previous sessions are not erased.
509*
510*/ Example Use
511
512 ClearTrace();
513
514/************************************************************************************************************/
515
516void TraceNL(); ZASM Instruction:
517 TRACE5
518/**
519* Traces a newline to allegro.log
520* This inserts a carriage return (as if pressing return/enter) into allegro.log
521* and is useful for providing formatting to debugging.
522*
523*/ Example Use:
524
525 TraceNL();
526 Prints a carriage return to allegro.log.
527
528/************************************************************************************************************/
529
530void TraceS(int s[]); ZASM Instruction:
531 TRACE6 d3
532/**
533* Works as Trace() above, but prints a full string to allegro.log, using the array pointer
534* (name) as its argument.
535* Maximum 512 characters. Functions from string.zh can be used to split larger strings.
536*
537*/ Example Use:
538
539 int testString[]="This is a string.";
540 TraceS(testString);
541 Prints 'This is a string.' to allegro.log.
542
543/************************************************************************************************************/
544
545///////////////////////
546/// Array Functions ///
547///////////////////////
548
549
550int SizeOfArray(int array[]); ZASM Instruction:
551 ARRAYSIZE d2
552/**
553* Returns the index size of the array pointed by 'array'.
554* Works only on int, and float type arrays. Boolean arrays are not supported.
555* Useful in for loops.
556*
557*/ Example Use:
558
559 int isAnArray[216];
560 int x;
561 x = SizeOfArray(isAnArray);
562 The value of x becomes 216.
563
564/************************************************************************************************************/
565
566int SizeOfArrayBool(bool array[]); ZASM Instruction:
567 ARRAYSIZEB d2
568/**
569* Returns the index size of the array pointed by 'array'.
570* As SizeOfArray(int *ptr), save that it works specifically with bool typed arrays.
571* Useful in for loops.
572*
573*/ Example Use:
574
575
576/************************************************************************************************************/
577
578int SizeOfArrayFFC(ffc array[]); ZASM Instruction:
579 ARRAYSIZEF d2
580/**
581* Returns the index size of the array pointed by 'array'.
582* As SizeOfArray(int *ptr), save that it works specifically with ffc typed arrays.
583* Useful in for loops.
584*
585*/ Example Use:
586
587
588/************************************************************************************************************/
589
590int SizeOfArrayNPC(npc array[]); ZASM Instruction:
591 ARRAYSIZEN d2
592/**
593* Returns the index size of the array pointed by 'array'.
594* As SizeOfArray(int *ptr), save that it works specifically with npc typed arrays.
595* Useful in for loops.
596*
597*/ Example Use:
598
599/************************************************************************************************************/
600
601int SizeOfArrayItem(item array[]); ZASM Instruction:
602 ARRAYSIZEI d2
603/**
604* Returns the index size of the array pointed by 'array'.
605* As SizeOfArray(int *ptr), save that it works specifically with item typed arrays.
606* Useful in for loops.
607*
608*/ Example Use:
609
610/************************************************************************************************************/
611
612int SizeOfArrayItemdata(itemdata array[]);
613 ZASM Instruction:
614 ARRAYSIZEID d2
615/**
616* Returns the index size of the array pointed by 'array'.
617* As SizeOfArray(int *ptr), save that it works specifically with itemdata typed arrays.
618* Useful in for loops.
619*
620*/ Example Use:
621
622/************************************************************************************************************/
623
624int SizeOfArrayLWeapon(lweapon array[]);
625 ZASM Instruction:
626 ARRAYSIZEL d2
627/**
628* Returns the index size of the array pointed by 'array'.
629* As SizeOfArray(int *ptr), save that it works specifically with lweapon typed arrays.
630* Useful in for loops.
631*
632*/ Example Use:
633
634/************************************************************************************************************/
635
636int SizeOfArrayEWeapon(eweapon array[]);
637 ZASM Instruction:
638 ARRAYSIZEE d2
639/**
640* Returns the index size of the array pointed by 'array'.
641* As SizeOfArray(int *ptr), save that it works specifically with eweapon typed arrays.
642* Useful in for loops.
643*
644*/ Example Use:
645
646/************************************************************************************************************/
647
648
649
650
651//////////////////////////////
652/// Mathematical Functions ///
653//////////////////////////////
654
655int Rand(int n); ZASM Instruction:
656 RNDR<><> d2,d3
657 RNDV<><>
658
659/**
660* Computes and returns a random integer from 0 to n-1,
661* or a negative value between n+1 and 0 if 'n' is negative.
662*
663* Note: The paramater 'n' is an integer, and any floating point (ZScript float)
664* value passed to it will be truncated (floored) to the nearest integer.
665* Rand(3.75) is identical to Rand(3).
666*/ Example Use:
667
668 Rand(40);
669 Produces a random number between 0 and 39.
670 Rand(-20);
671 produces a random number between -19 and 0.
672
673
674/************************************************************************************************************/
675
676float Sin(float deg); ZASM Instruction:
677 SINR<><> d2,d3
678 SINV<><>
679
680/**
681* Returns the trigonometric sine of the parameter, which is interpreted
682* as a degree value.
683*
684*/ Example Use:
685
686 float x = Sin(32);
687 x = 0.5299
688
689/************************************************************************************************************/
690
691float Cos(float deg); ZASM Instruction:
692 COSR<><> d2,d3
693 COSV<><>
694
695/**
696* Returns the trigonometric cosine of the parameter, which is
697* interpreted as a degree value.
698*
699*/ Example Usage:
700
701 float x = Cos(40);
702 x = 0.7660
703
704/************************************************************************************************************/
705
706float Tan(float deg); ZASM Instruction:
707 TANR<><> d2,d3
708 TANV<><>
709
710/**
711* Returns the trigonometric tangent of the parameter, which is
712* interpreted as a degree value. The return value is undefined if
713* deg is of the form 90 + 180n for an integral value of n.
714*
715*/ Example Use:
716
717 float x = Tan(100);
718 x = -5.6712
719
720/************************************************************************************************************/
721
722//!Sources: OMultImmediate, OArcSinRegister
723//Is there a direct ZASM instruction equivalent, or does this function run as a routine?
724
725float RadianSin(float rad);
726/**
727* Returns the trigonometric sine of the parameter, which is interpreted
728* as a radian value.
729*
730*/ Example Use:
731
732/************************************************************************************************************/
733
734//!Sources: OMultImmediate, OCosRegister
735//Is there a direct ZASM instruction equivalent, or does this function run as a routine?
736
737float RadianCos(float rad);
738/**
739* Returns the trigonometric cosine of the parameter, which is
740* interpreted as a radian value.
741*
742*/ Example Use:
743
744/************************************************************************************************************/
745
746//!Sources: OMultImmediate, OTanRegister
747//Is there a direct ZASM instruction equivalent, or does this function run as a routine?
748
749float RadianTan(float rad);
750/**
751* Returns the trigonometric tangent of the parameter, which is
752* interpreted as a radian value. The return value is undefined for
753* values of rad near (pi/2) + n*pi, for n an integer.
754*
755*/ Example Use:
756
757/************************************************************************************************************/
758
759float ArcTan(int x, int y); ZASM Instruction:
760 ARCTANR<>
761 (Does ARCTANV exist?)
762/**
763* Returns the trigonometric arctangent of the coordinates, which is
764* interpreted as a radian value.
765*
766*/ Example Use:
767
768/************************************************************************************************************/
769
770float ArcSin(float x); ZASM Instruction:
771 ARCSINR<><>
772 ARCSINV<><> (Can't find this in the source code)
773 ffasm.cpp line 217
774/**
775* Returns the trigonometric arcsine of x, which is
776* interpreted as a radian value.
777*
778*/ Example Use:
779
780/************************************************************************************************************/
781
782float ArcCos(float x); ZASM Instruction:
783 ARCCOSR<><>
784 ARCCOSV<><>
785
786/**
787* Returns the trigonometric arccosine of x, which is
788* interpreted as a radian value.
789*
790*/ Example Use:
791
792/************************************************************************************************************/
793
794float Max(float a, float b); ZASM Instruction:
795 MAXR<><>
796 MAXV<><>
797/**
798* Returns the greater of a and b.
799*
800*/ Example Use:
801
802/************************************************************************************************************/
803
804float Min(float a, float b); ZASM Instriction:
805 MINR<><>
806 MINV<><>
807/**
808* Returns the lesser of a and b.
809*
810*/ Example Use:
811
812/************************************************************************************************************/
813
814int Pow(int base, int exp); ZASM Instruction:
815 POWERR<><>
816 POWERV<><>
817/**
818* Returns base^exp. The return value is undefined for base=exp=0. Note
819* also negative values of exp may not be useful, as the return value is
820* truncated to the nearest integer.
821*
822*/ Example Use:
823
824/************************************************************************************************************/
825
826int InvPow(int base, int exp); ZASM Instruction:
827 IPOWERR<><>
828 IPOWERV<><>
829/**
830* Returns base^(1/exp). The return value is undefined for exp=0, or
831* if exp is even and base is negative. Note also that negative values
832* of exp may not be useful, as the return value is truncated to the
833* nearest integer.
834*
835*/ Example Use:
836
837/************************************************************************************************************/
838
839float Log10(float val); ZASM Instruction:
840 LOG10<>
841/**
842* Returns the log of val to the base 10. Any value <= 0 will return 0.
843*
844*/ Example Use:
845
846/************************************************************************************************************/
847
848float Ln(float val); ZASM Instruction:
849 LOGE<>
850
851/**
852* Returns the natural logarithm of val (to the base e). Any value <= 0 will return 0.
853*
854*/ Example Use:
855
856/************************************************************************************************************/
857
858int Factorial(int val); ZASM Instruction:
859 FACTORIAL<>
860/**
861* Returns val!. val < 0 returns 0.
862*
863*/ Example Use:
864
865/************************************************************************************************************/
866
867float Abs(float val); ZASM Instruction:
868 ABS<>
869/**
870* Return the absolute value of the parameter, if possible. If the
871* absolute value would overflow the parameter, the return value is
872* undefined.
873*
874*/ Example Use:
875
876/************************************************************************************************************/
877
878float Sqrt(float val); ZASM Instruction:
879 SQROOTV<><>
880 SQROOTR<><>
881/**
882* Computes the square root of the parameter. The return value is
883* undefined for val < 0.
884* NOTE: Passing negative values to Sqrt() will return an error. See SafeSqrt() in std.zh
885*/ Example Use:
886
887 int x = Sqrt(16);
888 x = 4
889
890/************************************************************************************************************/
891/************************************************************************************************************/
892
893
894
895//====================================
896//--- Game Functions and Variables ---
897//====================================
898
899 namespace Game
900
901
902 int GetPointer(bool *ptr[]); ZASM Instruction:
903 BOOLARRPTR
904 /**
905 * Returns the pointer of a bool array as a float.
906 */ Example Use:
907 bool arr[16];
908 int size = SizeOfArray( GetPointer(arr) );
909 //Size == 16
910
911/************************************************************************************************************/
912
913
914 int GetCurScreen(); ZASM Instruction:
915 CURSCR
916 /**
917 * Retrieves the number of the current screen within the current map.
918 */ Example Use: !#!
919
920/************************************************************************************************************/
921
922 int GetCurDMapScreen(); ZASM Instruction:
923 CURDSCR
924 /**
925 * Retrieves the number of the current screen within the current DMap.
926 */ Example Use: !#!
927
928/************************************************************************************************************/
929
930 int GetCurLevel(); ZASM Instruction:
931 CURLEVEL
932 /**
933 * Retrieves the number of the dungeon level of the current DMap. Multiple
934 * DMaps can have the same dungeon level - this signifies that they share
935 * a map, compass, level keys and such.
936 */ Example Use: !#!
937
938/************************************************************************************************************/
939
940 int GetCurMap(); ZASM Instruction:
941 CURMAAP
942 /**
943 * Retrieves the number of the current map.
944 */ Example Use: !#!
945
946/************************************************************************************************************/
947
948 int GetCurDMap(); ZASM Instruction:
949 CURDMAP
950 /**
951 * Returns the number of the current DMap.
952 */ Example Use: !#!
953
954/************************************************************************************************************/
955
956 int DMapFlags[]; ZASM Instruction:
957 DMAPFLAGSD
958 /**
959 * An array of 512 integers, containing the DMap's flags ORed (|) together.
960 * Use the 'DMF_' constants, or the 'DMapFlag()' functions from std.zh if you are not comfortable with binary.
961 */ Example Use: !#!
962
963/************************************************************************************************************/
964
965 int DMapLevel[]; ZASM Instruction:
966 DMAPLEVELD
967 /**
968 * An array of 512 integers containing each DMap's level
969 */ Example Use: !#!
970
971/************************************************************************************************************/
972
973 int DMapCompass[]; ZASM Instruction:
974 DMAPCOMPASSD
975 /**
976 * An array of 512 integers containing each DMap's compass screen
977 */ Example Use: !#!
978
979/************************************************************************************************************/
980
981 int DMapContinue[]; ZASM Instruction:
982 DMAPCONTINUED
983 /**
984 * An array of 512 integers containing each DMap's continue screen
985 */ Example Use: !#!
986
987/************************************************************************************************************/
988
989 int DMapMIDI[]; ZASM Instruction:
990 DMAPMIDID
991 /**
992 * An array of 512 integers containing each DMap's MIDI.
993 * Positive numbers are for custom MIDIs, and negative values are used for
994 * the built-in game MIDIs. Because of the way DMap MIDIs are handled
995 * internally, however, built-in MIDIs besides the overworld, dungeon, and
996 * level 9 songs won't match up with Game->PlayMIDI() and Game->GetMIDI().
997 */ Example Use: !#!
998
999/************************************************************************************************************/
1000
1001 void GetDMapName(int DMap, int buffer[]);
1002
1003 ZASM Instruction:
1004 GETDMAPNAME
1005 /**
1006 * Loads DMap with ID 'DMap's name into 'buffer'.
1007 * See std_constsnts.zh for appropriate buffer size.
1008 */ Example Use: !#!
1009
1010/************************************************************************************************************/
1011
1012 void SetDMapName(int dmap_id, int buffer[]);
1013
1014 ZASM Instruction:
1015 SETDMAPNAME
1016 /**
1017 * Loads string 'buffer[]' to the DMap Name field for DMap with ID 'dmap_id'.
1018 * See std_constsnts.zh for appropriate buffer size.
1019 */ Example Use: !#!
1020
1021/************************************************************************************************************/
1022
1023 void GetDMapTitle(int DMap, int buffer[]);
1024
1025 ZASM Instruction:
1026 GETDMAPTITLE
1027 /**
1028 * Loads DMap with ID 'DMap's title into 'buffer'.
1029 * See std_constants.zh for appropriate buffer size.
1030 */ Example Use: !#!
1031
1032/************************************************************************************************************/
1033
1034 void SetDMapTitle(int DMap, int buffer[]);
1035
1036 ZASM Instruction:
1037 SETDMAPTITLE
1038 /**
1039 * Loads string 'buffer[]' to the DMap Title field for DMap with ID 'dmap_id'.
1040 * See std_constsnts.zh for appropriate buffer size.
1041 */ Example Use: !#!
1042
1043/************************************************************************************************************/
1044
1045 void GetDMapIntro(int DMap, int buffer[]);
1046
1047 ZASM Instruction:
1048 GETDMAPINTRO
1049 /**
1050 * Loads DMap with ID 'DMap's intro string into 'buffer'.
1051 * See std_constants.zh for appropriate buffer size.
1052 */ Example Use: !#!
1053
1054/************************************************************************************************************/
1055
1056 void SetDMapIntro(int DMap, int buffer[]);
1057
1058 ZASM Instruction:
1059 SETDMAPINTRO
1060 /**
1061 * Loads string 'buffer[]' to the DMap Intro field for DMap with ID 'dmap_id'.
1062 * See std_constsnts.zh for appropriate buffer size.
1063 */ Example Use: !#!
1064
1065/************************************************************************************************************/
1066
1067 int DMapOffset[]; ZASM Instruction:
1068 DMAPOFFSET
1069 /**
1070 * An array of 512 integers containing the X offset of each DMap.
1071 * Game->DMapOffset is read-only; while setting it is not syntactically
1072 * incorrect, it does nothing.
1073 */ Example Use: !#!
1074
1075/************************************************************************************************************/
1076
1077 int DMapPalette[]; ZASM Instruction:
1078 DMAPLEVELPAL
1079 /**
1080 * An array of 512 integers containing each DMap's Level Palette
1081 */ Example Use: !#!
1082
1083/************************************************************************************************************/
1084
1085 int DMapMap[]; ZASM Instruction:
1086 DMAPMAP
1087
1088 /**
1089 * An array of 512 integers containing the map used by each DMap.
1090 * Game->DMapMap is read-only; while setting it is not syntactically
1091 * incorrect, it does nothing.
1092 */ Example Use: !#!
1093
1094/************************************************************************************************************/
1095
1096
1097 void GreyscaleOn() ZASM Instruction
1098 GREYSCALEON
1099
1100 /**
1101 * Renders the entire display in greyscale.
1102 */ Example Use: !#!
1103
1104/************************************************************************************************************/
1105
1106 void GreyscaleOff() ZASM Instruction
1107 GREYSCALEOFF
1108
1109 /**
1110 * Returns the display rendering to colour.
1111 */ Example Use: !#!
1112
1113/************************************************************************************************************/
1114
1115 int NumDeaths; ZASM Instruction:
1116 GAMEDEATHS
1117 /**
1118 * Returns or sets the number of times Link has perished during this quest.
1119 */ Example Use: !#!
1120
1121/************************************************************************************************************/
1122
1123 int Cheat; ZASM Instruction:
1124 GAMECHEAT
1125 /**
1126 * Returns, or sets the current cheat level of the quest player.
1127 * Valid values are 0, 1, 2, 3, and 4.
1128 */ Example Use: !#!
1129
1130/************************************************************************************************************/
1131
1132 bool CappedFPS; ZASM Instruction:
1133 GAMETHROTTLE
1134 /**
1135 * Returns if the user enabled an uncapped mode either with F1 or TILDE.
1136 * Returns 'true' is the game is capped to 60fps, or false otherwise.
1137 * At present, you may get (read), but NOT set (write to) this value.
1138 */ Example Use: !#!
1139
1140/************************************************************************************************************/
1141
1142 int Time ZASM Instruction:
1143 GAMETIME
1144 /**
1145 * Returns the time elapsed in this quest, in 60ths of a second. (i.e. in frames).
1146 * The return value is undefined if TimeValid is false (see below).
1147 */ Example Use: !#!
1148
1149/************************************************************************************************************/
1150
1151 bool TimeValid; ZASM Instruction:
1152 GAMETIMEVALID
1153 /**
1154 * True if the elapsed quest time can be determined for the current quest.
1155 */ Example Use: !#!
1156
1157/************************************************************************************************************/
1158
1159 bool HasPlayed; ZASM Instruction:
1160 GAMEHASPLAYED
1161 /**
1162 * This value is true if the current quest session was loaded from a saved
1163 * game, false if the quest was started fresh.
1164 */ Example Use: !#!
1165
1166/************************************************************************************************************/
1167
1168 bool Standalone; ZASM Instruction:
1169 GAMESTANDALONE
1170 /**
1171 * This value is true if the game is running in standalone mode, false if not.
1172 * Game->Standalone is read-only; while setting it is not syntactically
1173 * incorrect, it does nothing.
1174 *
1175 * Standalone mode is set by command line params when launching ZC.
1176 */ Example Use: !#!
1177
1178/************************************************************************************************************/
1179
1180 int GuyCount[]; ZASM Instruction:
1181 GAMEGUYCOUNT
1182 /**
1183 * The number of NPCs (enemies and guys) on screen i of this map, where
1184 * i is the index used to access this array. This array is exclusively used
1185 * to determine which enemies had previously been killed, and thus won't
1186 * return, when you re-enter a screen.
1187 * Note: This is only a count of the enemies that remain on a screen; not their IDs.
1188 */ Example Use: !#!
1189
1190/************************************************************************************************************/
1191
1192 int ContinueDMap; ZASM Instruction:
1193 GAMECONTDMAP
1194 /**
1195 * Returns or sets the DMap where Link will be respawned after quitting and reloading the game.
1196 */ Example Use: !#!
1197
1198/************************************************************************************************************/
1199
1200 int ContinueScreen; ZASM Instruction:
1201 GAMECONTSCR
1202 /**
1203 * Returns or sets the map screen where Link will be respawned after quitting and reloading the game.
1204 */ Example Use: !#!
1205
1206/************************************************************************************************************/
1207
1208 int LastEntranceDMap; ZASM Instruction:
1209 GAMEENTRDMAP
1210 /**
1211 * Returns or sets the DMap where Link will be respawned after dying and continuing.
1212 */ Example Use: !#!
1213
1214/************************************************************************************************************/
1215
1216 int LastEntranceScreen; ZASM Instruction:
1217 GAMEENTRSCR
1218 /**
1219 * Returns or sets the map screen where Link will be respawned after dying and continuing.
1220 */ Example Use: !#!
1221
1222/************************************************************************************************************/
1223
1224 int Counter[]; ZASM Instruction:
1225 GAMECOUNTERD
1226 /**
1227 * Returns of sets the current value of the game counters.
1228 * Use the CR_ constants in std.zh to index into this array.
1229 */ Example Use: !#!
1230
1231/************************************************************************************************************/
1232
1233 int MCounter[]; ZASM Instruction:
1234 GAMEMCOUNTERD
1235 /**
1236 * Returns or sets the current maximum value of the game counters.
1237 * Use the CR_ constants in std.zh to index into this array.
1238 */ Example Use: !#!
1239
1240/************************************************************************************************************/
1241
1242 int DCounter[]; ZASM Instruction:
1243 GAMEDCOUNTERD
1244 /**
1245 * Returns of sets the current value of the game drain counters.
1246 * Use the CR_ constants in std.zh to index into this array.
1247 * Note that if the player hasn't acquired the '1/2 Magic Upgrade' yet,
1248 * then setting the CR_MAGIC drain counter to a negative value will
1249 * drain the magic counter by 2 per frame rather than 1.
1250 */ Example Use: !#!
1251
1252/************************************************************************************************************/
1253
1254 int Generic[]; ZASM Instruction:
1255 GAMEGENERICD
1256 /**
1257 * An array of miscellaneous game values, such as number of heart
1258 * containers and magic drain rate.
1259 * Use the GEN_ constants in std.zh to index into this array.
1260 */ Example Use: !#!
1261
1262/************************************************************************************************************/
1263
1264 int LItems ZASM Instruction:
1265 GAMELITEMSD
1266 /**
1267 * The exploration items (map, compass, boss key etc.) of dungeon level i
1268 * currently under the possession of the player, where i is
1269 * the index used to access this array. Each element of this
1270 * array consists of flags OR'd (|) together; use the LI_ constants in
1271 * std.zh to set or compare these values.
1272 */ Example Use: !#!
1273
1274/************************************************************************************************************/
1275
1276 int LKeys[]; ZASM Instruction:
1277 GAMELKEYSD
1278 /**
1279 * The number of level keys of level i currently under the possession of
1280 * the player, where i is the index used to access this array.
1281 */ Example Use: !#!
1282
1283/************************************************************************************************************/
1284
1285 int GetScreenFlags(int map, int screen, int flagset);
1286
1287 ZASM Instruction:
1288 GETSCREENFLAGS
1289 /**
1290 * Returns the screen flags from screen 'screen' on map 'map',
1291 * interpreted in the same way as Screen->Flags
1292 */ Example Use: !#!
1293
1294
1295 Game->LKeys[3]+=4; //Gives the player four keys to Level 3.
1296
1297
1298/************************************************************************************************************/
1299
1300 int GetScreenEFlags(int map, int screen, int flagset);
1301
1302 ZASM Instruction:
1303 GETSCREENEFLAGS
1304
1305 /**
1306 * Returns the enemy flags from screen 'screen' on map 'map',
1307 * interpreted in the same way as Screen->EFlags
1308 */ Example Use: !#!
1309
1310/************************************************************************************************************/
1311
1312 bool GetScreenState(int map, int screen, int flag);
1313
1314 ZASM Instruction:
1315 SCREENSTATEDD
1316 /**
1317 * As with State, but retrieves the miscellaneous flags of any screen,
1318 * not just the current one. This function is undefined if map is less
1319 * than 1 or greater than the maximum map number of your quest, or if
1320 * screen is greater than 127.
1321 * Note: Screen numbers in ZQuest are usually displayed in hexadecimal.
1322 * Use the ST_ constants in std.zh for the flag parameter.
1323 */ Example Use: !#!
1324
1325/************************************************************************************************************/
1326
1327 void SetScreenState(int map, int screen, int flag, bool value);
1328
1329 ZASM Instruction:
1330 SCREENSTATEDD
1331
1332 /**
1333 * As with State, but sets the miscellaneous flags of any screen, not
1334 * just the current one. This function is undefined if map is less than
1335 * 1 or greater than the maximum map number of your quest, or if
1336 * screen is greater than 127.
1337 * Note: Screen numbers in ZQuest are usually displayed in hexadecimal.
1338 * Use the ST_ constants in std.zh for the flag parameter.
1339 */ Example Use: !#!
1340
1341/************************************************************************************************************/
1342
1343 float GetScreenD(int screen, int reg);
1344
1345 ZASM Instruction:
1346 SDDD
1347 /**
1348 * Retrieves the value of D[reg] on the given screen of the current
1349 * DMap.
1350 */ Example Use: !#!
1351
1352/************************************************************************************************************/
1353
1354 void SetScreenD(int screen, int reg, float value);
1355
1356 ZASM Instruction:
1357 SDDD
1358 /**
1359 * Sets the value of D[reg] on the given screen of the current DMap.
1360 */ Example Use: !#!
1361
1362/************************************************************************************************************/
1363
1364 float GetDMapScreenD(int dmap, int screen, int reg);
1365
1366 ZASM Instruction:
1367 SDDDD
1368 /**
1369 * Retrieves the value of D[reg] on the given screen of the given
1370 * DMap.
1371 */ Example Use: !#!
1372
1373/************************************************************************************************************/
1374
1375 void SetDMapScreenD(int dmap, int screen, int reg, float value
1376
1377 ZASM Instruction:
1378 SDDDD
1379 /**
1380 * Sets the value of D[reg] on the given screen of the given DMap.
1381 */ Example Use: !#!
1382
1383 itemdata LoadItemData(int item);
1384 LOADITEMDATAR
1385 LOADITEMDATAV
1386 /**
1387 * Retrieves the itemdata pointer corresponding to the given item.
1388 * Use the item pointer ID variable or I_ constants in std.zh as values.
1389 */ Example Use: !#!
1390 Game->LoadItemData[I_BRANG1]
1391
1392
1393/************************************************************************************************************/
1394 //! This compiles, but it is incomplete and returns 0.
1395 float GetDMapScreenDoor(int dmap, int screen, int door);
1396
1397 ZASM Instruction:
1398 n/a
1399 /**
1400 * Retrieves the value of Screen->Door[door] on the given screen of the given
1401 * DMap.
1402 */ Example Use: !#!
1403
1404/************************************************************************************************************/
1405 //! This compiles, but it is incomplete and returns 0.
1406 void SetDMapScreenDoor(int dmap, int screen, int door, float value
1407
1408 ZASM Instruction:
1409 SDDDD
1410 /**
1411 * Sets the value of Screen->Door[door] on the given screen of the given DMap.
1412 */ Example Use: !#!
1413
1414
1415/************************************************************************************************************/
1416 //! This compiles, but it is incomplete and returns 0.
1417 bool GetDMapScreenState(int dmap, int screen, int index);
1418
1419 ZASM Instruction:
1420 n/a
1421 /**
1422 * Retrieves the value of Screen->State[index] on the given screen of the given
1423 * DMap.
1424 */ Example Use: !#!
1425
1426/************************************************************************************************************/
1427 //! This compiles, but it is incomplete and returns 0.
1428 void SetDMapScreenState(int dmap, int screen, int index, bool value
1429
1430 ZASM Instruction:
1431 SDDDD
1432 /**
1433 * Sets the value of Screen->State[index] on the given screen of the given DMap.
1434 */ Example Use: !#!
1435
1436
1437/************************************************************************************************************/
1438
1439 void PlaySound(int soundid); ZASM Instruction:
1440 PLAYSOUNDR
1441 PLAYSOUNDV
1442 /**
1443 * Plays one of the quest's sound effects. Use the SFX_ constants in
1444 * std.zh as values of soundid.
1445 */ Example Use: !#!
1446
1447/************************************************************************************************************/
1448
1449 void PauseSound(int soundid); ZASM Instruction:
1450 PAUSESOUNDR
1451 PAUSESOUNDV
1452 /**
1453 * Pauses one of the quest's playing sound effects. Use the SFX_ constants in
1454 * std.zh as values of soundid.
1455 */ Example Use: !#!
1456
1457/************************************************************************************************************/
1458
1459 void ResumeSound(int soundid); ZASM Instruction:
1460 RESUMESOUNDR
1461 RESUMESOUNDV
1462 /**
1463 * Resumes one of the quest's paused sound effects. Use the SFX_ constants in
1464 * std.zh as values of soundid.
1465 */ Example Use: !#!
1466
1467/************************************************************************************************************/
1468
1469 void EndSound(int soundid); ZASM Instruction:
1470 ENDSOUNDR
1471 ENDSOUNDV
1472 /**
1473 * Kills one of the quest's playing sound effects. Use the SFX_ constants in
1474 * std.zh as values of soundid.
1475 */ Example Use: !#!
1476
1477/************************************************************************************************************/
1478
1479 void PauseMusic(); ZASM Instruction:
1480 PAUSEMUSIC
1481 PAUSEMUSIC
1482 /**
1483 * Pauses the present, playing MIDI or Enhanced Music file.
1484 */ Example Use: !#!
1485
1486/************************************************************************************************************/
1487
1488 void ResumeMusic(); ZASM Instruction:
1489 RESUMEMUSIC
1490 RESUMEMUSIC
1491 /**
1492 * Resumes the present, playing MIDI or Enhanced Music file.
1493 */ Example Use: !#!
1494
1495/************************************************************************************************************/
1496
1497 void PlayMIDI(int MIDIid); ZASM Instruction:
1498 PLAYMIDIR
1499 PLAYMIDIV
1500 /**
1501 * Changes the current screen MIDI to MIDIid.
1502 * Will revert to the DMap (or screen) MIDI upon leaving the screen.
1503 */ Example Use: !#!
1504
1505/************************************************************************************************************/
1506
1507 int GetMIDI(); ZASM Instruction:
1508 GETMIDI
1509 /**
1510 * Returns the current screen MIDI that is playing.
1511 * Positive numbers are for custom MIDIs, and negative values are used
1512 * for the built-in game MIDIs.
1513 */ Example Use: !#!
1514
1515/************************************************************************************************************/
1516
1517 bool PlayEnhancedMusic(int filename[], int track);
1518
1519 ZASM Instruction:
1520 PLAYENHMUSIC
1521 /**
1522 * Play the specified enhanced music if it's available. If the music
1523 * cannot be played, the current music will continue. The music will
1524 * revert to normal upon leaving the screen.
1525 * Returns true if the music file was loaded successfully.
1526 * The filename cannot be more than 255 characters. If the music format
1527 * does not support multiple tracks, the track argument will be ignored.
1528 */ Example Use:
1529
1530 int music[]="myfile.mp3"; // Make a string with the filename of the music to play.
1531 if ( !Game->PlayEnhancedMusic(music, 1) ) Game->PlayMIDI(midi_id);
1532
1533 // Plays the enhanced music file 'myfle.mp3', track 1.
1534 // If the file is mssing, the game will instead play
1535 // the midi specified as midi_id.
1536
1537/************************************************************************************************************/
1538
1539 void GetDMapMusicFilename(int dmap, int buf[]);
1540
1541 ZASM Instruction:
1542 GETMUSICFILE
1543 /**
1544 * Load the filename of the given DMap's enhanced music into buf.
1545 * buf should be at least 256 elements in size.
1546 */ Example Use: !#!
1547
1548/************************************************************************************************************/
1549
1550 int GetDMapMusicTrack(int dmap);
1551
1552 ZASM Instruction:
1553 GETMUSICTRACK
1554 /**
1555 * Returns the given DMap's enhanced music track. This is valid but
1556 * meaningless if the music format doesn't support multiple tracks.
1557 */ Example Use: !#!
1558
1559/************************************************************************************************************/
1560
1561 void SetDMapEnhancedMusic(int dmap, int filename[], int track);
1562
1563 ZASM Instruction:
1564 SETDMAPENHMUSIC
1565 /**
1566 * Sets the specified DMap's enhanced music to the given filename and
1567 * track number. If the music format does not support multiple tracks,
1568 * the track argument will be ignored. The filename must not be more
1569 * than 255 characters.
1570 */ Example Use: !#!
1571
1572/************************************************************************************************************/
1573
1574 int GetComboData(int map, int screen, int position);
1575
1576 ZASM Instruction:
1577 COMBODDM
1578 /**
1579 * Grabs a particular combo reference from anywhere in the game
1580 * world, based on map (NOT DMap), screen number, and position.
1581 * Don't forget that the screen index should be in hexadecimal,
1582 * and that maps are counted from 1 upwards.
1583 * Position is considered an index, treated the same way as in
1584 * Screen->ComboD[], with a legal range of 0 to 175.
1585 */ Example Use: !#!
1586
1587/************************************************************************************************************/
1588
1589 void SetComboData(int map, int screen, int position, int value);
1590
1591 ZASM Instruction:
1592 COMBODDM
1593 /**
1594 * Sets a particular combo reference anywhere in the game world,
1595 * based on map (NOT DMap), screen number, and position.
1596 * Don't forget that the screen index should be in hexadecimal,
1597 * and that maps are counted from 1 upwards.
1598 * Position is considered an index, treated the same way as in
1599 * Screen->ComboD[], with a legal range of 0 to 175.
1600 */ Example Use: !#!
1601
1602/************************************************************************************************************/
1603
1604 int GetComboCSet(int map, int screen, int position);
1605
1606 ZASM Instruction:
1607 COMBOCDM
1608 /**
1609 * Grabs a particular combo's CSet from anywhere in the game
1610 * world, based on map (NOT DMap), screen number, and position.
1611 * Position is considered an index, treated the same way as in
1612 * Screen->ComboC[], with a legal range of 0 to 175.
1613 */ Example Use: !#!
1614
1615/************************************************************************************************************/
1616
1617 void SetComboCSet(int map, int screen, int position, int value);
1618
1619 ZASM Instruction:
1620 COMBOCDM
1621 /**
1622 * Sets a particular combo's CSet anywhere in the game world,
1623 * based on map (NOT DMap), screen number, and position. Position
1624 * is considered an index, treated the same way as in Screen->ComboC[]
1625 * with a legal range of 0 to 175.
1626 */ Example Use: !#!
1627
1628/************************************************************************************************************/
1629
1630 int GetComboFlag(int map, int screen, int position);
1631
1632 ZASM Instruction:
1633 COMBOFDM
1634 /**
1635 * Grabs a particular combo's placed flag from anywhere in the game
1636 * world, based on map (NOT DMap), screen number, and position.
1637 * Position is considered an index, treated the same way as in
1638 * Screen->ComboF[], with a legal range of 0 to 175.
1639 */ Example Use: !#!
1640
1641/************************************************************************************************************/
1642
1643 void SetComboFlag(int map, int screen, int position, int value);
1644
1645 ZASM Instruction:
1646 COMBOFDM
1647 /**
1648 * Sets a particular combo's placed flag anywhere in the game world,
1649 * based on map (NOT DMap), screen number, and position. Position
1650 * is considered an index, treated the same way as in Screen->ComboF[]
1651 * with a legal range of 0 to 175.
1652 */ Example Use: !#!
1653
1654/************************************************************************************************************/
1655
1656 int GetComboType(int map, int screen, int position);
1657
1658 ZASM Instruction:
1659 COMBOTDM
1660 /**
1661 * Grabs a particular combo's type from anywhere in the game
1662 * world, based on map (NOT DMap), screen number, and position.
1663 * Position is considered an index, treated the same way as in
1664 * Screen->ComboT[]. Note that you are grabbing an actual combo
1665 * attribute as referenced by the combo on screen you're
1666 * referring to.
1667 */ Example Use: !#!
1668
1669/************************************************************************************************************/
1670
1671 void SetComboType(int map, int screen, int position, int value);
1672
1673 ZASM Instruction:
1674 COMBOTDM
1675 /**
1676 * Sets a particular combo's type anywhere in the game world,
1677 * based on map (NOT DMap), screen number, and position. Position
1678 * is considered an index, treated the same way as in Screen->ComboT[].
1679 * Note that you are grabbing an actual combo attribute as referenced
1680 * by the combo on screen you're referring to, which means that
1681 * setting this attribute will affect ALL references to this combo
1682 * throughout the quest.
1683 */ Example Use: !#!
1684
1685/************************************************************************************************************/
1686
1687 int GetComboInherentFlag(int map, int screen, int position);
1688
1689 ZASM Instruction:
1690 COMBOIDM
1691 /**
1692 * Grabs a particular combo's inherent flag from anywhere in the game
1693 * world, based on map (NOT DMap), screen number, and position.
1694 * Position is considered an index, treated the same way as in
1695 * Screen->ComboI[]. Note that you are grabbing an actual combo
1696 * attribute as referenced by the combo on screen you're
1697 * referring to.
1698 */ Example Use: !#!
1699
1700/************************************************************************************************************/
1701
1702 void SetComboInherentFlag(int map, int screen, int position, int value);
1703
1704 ZASM Instruction:
1705 COMBOIDM
1706 /**
1707 * Sets a particular combo's inherent flag anywhere in the game world,
1708 * based on map (NOT DMap), screen number, and position. Position
1709 * is considered an index, treated the same way as in Screen->ComboI[].
1710 * Note that you are grabbing an actual combo attribute as referenced
1711 * by the combo on screen you're referring to, which means that
1712 * setting this attribute will affect ALL references to this combo
1713 * throughout the quest.
1714 */ Example Use: !#!
1715
1716/************************************************************************************************************/
1717
1718 int GetComboSolid(int map, int screen, int position);
1719
1720 ZASM Instruction:
1721 COMBOSDM
1722 /**
1723 * Grabs a particular combo's solidity flag from anywhere in the game
1724 * world, based on map (NOT DMap), screen number, and position.
1725 * Position is considered an index, treated the same way as in
1726 * Screen->ComboS[]. Note that you are grabbing an actual combo
1727 * attribute as referenced by the combo on screen you're
1728 * referring to.
1729 */ Example Use: !#!
1730
1731/************************************************************************************************************/
1732
1733 void SetComboSolid(int map, int screen, int position, int value);
1734
1735 ZASM Instruction:
1736 COMBOSDM
1737 /**
1738 * Sets a particular combo's solidity anywhere in the game world,
1739 * based on map (NOT DMap), screen number, and position. Position
1740 * is considered an index, treated the same way as in Screen->ComboS[].
1741 * Note that you are grabbing an actual combo attribute as referenced
1742 * by the combo on screen you're referring to, which means that
1743 * setting this attribute will affect ALL references to this combo
1744 * throughout the quest.
1745 */ Example Use: !#!
1746
1747/************************************************************************************************************/
1748
1749 int ComboTile(int combo); ZASM Instruction:
1750 COMBOTILE
1751 /**
1752 * Returns the tile used by combo 'combo'
1753 */ Example Use: !#!
1754
1755/************************************************************************************************************/
1756
1757 void GetSaveName(int buffer[]);
1758
1759 ZASM Instruction:
1760 GETSAVENAME
1761 /**
1762 * Loads the current save file's name into 'buffer'
1763 * Buffer should be at least 9 elements long
1764 */ Example Use: !#!
1765
1766/************************************************************************************************************/
1767
1768 void SetSaveName(int name[]);
1769
1770 ZASM Instruction:
1771 SETSAVENAME
1772 /**
1773 * Sets the current file's save name to 'name'
1774 * Buffer should be no more than 9 elements
1775 */ Example Use: !#!
1776
1777/************************************************************************************************************/
1778
1779 void End(); ZASM Instruction:
1780 GAMEEND
1781 /**
1782 * IMMEDIATELY ends the current game and returns to the file select screen
1783 */ Example Use: !#!
1784
1785/************************************************************************************************************/
1786
1787 void Save(); ZASM Instruction:
1788 GAMESAVE
1789 /**
1790 * Saves the current game
1791 */ Example Use: !#!
1792
1793/************************************************************************************************************/
1794
1795 bool ShowSaveScreen(); ZASM Instruction:
1796 SAVESCREEN
1797 /**
1798 * Displays the save screen. Returns true if the user chose to save, false otherwise.
1799 */ Example Use: !#!
1800
1801/************************************************************************************************************/
1802
1803 void ShowSaveQuitScreen(); ZASM Instruction:
1804 SAVEQUITSCREEN
1805 /**
1806 * Displays the save and quit screen.
1807 */ Example Use: !#!
1808
1809/************************************************************************************************************/
1810
1811 void GetMessage(int string, int buffer[]);
1812
1813 ZASM Instruction:
1814 GETMESSAGE
1815 /**
1816 * Loads 'string' into 'buffer'. Use the function from std.zh
1817 * or use string.zh to remove trailing ' ' characters whilst loading.
1818 */ Example Use: !#!
1819
1820/************************************************************************************************************/
1821
1822 void SetMessage(int message, int buffer[]);
1823
1824 ZASM Instruction:
1825 SETMESSAGE
1826 /**
1827 * Loads string 'buffer[]' into ZQ Message 'message'.
1828 */ Example Use: !#!
1829
1830/************************************************************************************************************/
1831
1832 int GetFFCScript(int name[]); ZASM Instruction:
1833 GETFFCSCRIPT
1834 /**
1835 * Returns the number of the script with the given name or -1 if there is
1836 * no such script. The script name should be passed as a string.
1837 * (!) This was added around 2.50.0 RC4. Earlier beta versions will not be able to perform this function.
1838 */ Example Use: !#!
1839
1840/************************************************************************************************************/
1841
1842 bool ClickToFreezeEnabled; ZASM Instruction:
1843 GAMECLICKFREEZE
1844 /**
1845 * If this is false, the "Click to Freeze" setting will not function, ensuring
1846 * that the script can use the mouse freely. This overrides the setting rather
1847 * than changing it, so remembering and restoring the initial value is unnecessary.
1848 */ Example Use: !#!
1849
1850/************************************************************************************************************/
1851DEBUGGING: These might find their way into namespace Debug->
1852/************************************************************************************************************/
1853
1854int RefFFC; ZASM Instruction:
1855 REFFFC
1856 /**
1857 * Returns the present ffc refrence from the stack. FOR DEBUGGING ONLY!
1858 * THIS WILL BE DISABLED IN RELEASE BUILDS !
1859 */ Example Use:
1860
1861/************************************************************************************************************/
1862
1863int RefItem; ZASM Instruction:
1864 REFITEM
1865 /**
1866 * Returns the present item refrence from the stack. FOR DEBUGGING ONLY!
1867 * THIS WILL BE DISABLED IN RELEASE BUILDS !
1868 */ Example Use:
1869
1870/************************************************************************************************************/
1871
1872int RefItemdata; ZASM Instruction:
1873 REFIDATA
1874 /**
1875 * Returns the present itemdata refrence from the stack. FOR DEBUGGING ONLY!
1876 * THIS WILL BE DISABLED IN RELEASE BUILDS !
1877 */ Example Use:
1878
1879/************************************************************************************************************/
1880
1881int RefLWeapon; ZASM Instruction:
1882 REFLWPN
1883 /**
1884 * Returns the present lweapon refrence from the stack. FOR DEBUGGING ONLY!
1885 * THIS WILL BE DISABLED IN RELEASE BUILDS !
1886 */ Example Use:
1887
1888/************************************************************************************************************/
1889
1890int RefEWeapon; ZASM Instruction:
1891 REFEWPN
1892 /**
1893 * Returns the present eweapon refrence from the stack. FOR DEBUGGING ONLY!
1894 * THIS WILL BE DISABLED IN RELEASE BUILDS !
1895 */ Example Use:
1896
1897/************************************************************************************************************/
1898
1899int RefNPC; ZASM Instruction:
1900 REFNPC
1901 /**
1902 * Returns the present npc refrence from the stack. FOR DEBUGGING ONLY!
1903 * THIS WILL BE DISABLED IN RELEASE BUILDS !
1904 */ Example Use:
1905
1906/************************************************************************************************************/
1907
1908int SP; ZASM Instruction:
1909 SP
1910 /**
1911 * Returns the value of the stack pointer. FOR DEBUGGING ONLY!
1912 * THIS WILL BE DISABLED IN RELEASE BUILDS !
1913 */ Example Use:
1914/************************************************************************************************************/
1915
1916//======================================
1917//--- Screen Functions and Variables ---
1918//======================================
1919
1920 namespace Screen
1921
1922float D[]; ZASM Instruction:
1923 SD
1924 SDD
1925
1926
1927/**
1928* Each screen has 8 general purpose registers for use by script
1929* programmers. These values are recorded in the save file when the
1930* player saves their game. Do with these as you will.
1931* Note that these registers are tied to screen/DMap combinations.
1932* Encountering the same screen in a different DMap will result in a
1933* different D[] array.
1934*
1935* Values in Screen->D are preserved through game saving.
1936*
1937*/ Example Use: !#!
1938
1939/************************************************************************************************************/
1940
1941int Flags[]; ZASM Instruction:
1942 SCREENFLAGSD
1943 SCREENFLAGS
1944
1945/**
1946* An array of ten integers containing the states of the flags in the
1947* 10 categories on the Screen Data tabs 1 and 2. Each flag is ORed into the
1948* Flags[x] value, starting with the top flag as the smallest bit.
1949* Use the SF_ constants as the array acces for this value, and the
1950* GetScreenFlags function if you are not comfortable with binary.
1951* This is read-only; while setting it is not syntactically incorrect, it does nothing.
1952*
1953*/ Example Use: !#!
1954
1955/************************************************************************************************************/
1956
1957int EFlags[]; ZASM Instruction:
1958 SCREENEFLAGSD
1959 SCREENEFLAGS
1960
1961/**
1962* An array of 3 integers containing the states of the flags in the
1963* E.Flags tab of the Screen Data dialog. Each flag is ORed into the
1964* EFlags[x] value, starting with the top flag as the smallest bit.
1965* Use the SEF_ constants as the array acces for this value, and the
1966* GetScreenEFlags function if you are not comfortable with binary.
1967* This is read-only; while setting it is not syntactically incorrect, it does nothing.
1968*
1969*/ Example Use: !#!
1970
1971/************************************************************************************************************/
1972
1973int ComboD[]; ZASM Instruction:
1974 CD### COMBOD
1975 COMBODD COMBODDM
1976 COMBODDM COMBOSD
1977
1978/**
1979* The combo ID of the ith combo on the screen, where i is the index
1980* used to access this array. Combos are counted left to right, top to
1981* bottom.
1982* Screen dimensions are 16 combos wide, by 11 combos high.
1983*
1984*/ Example Use: !#!
1985
1986/************************************************************************************************************/
1987
1988int ComboC[]; ZASM Instruction:
1989 CC### COMBOC
1990 COMBOCD COMBOCDM
1991
1992/**
1993* The CSet of the tile used by the ith combo on the screen, where i is
1994* the index used to access this array. Combos are counted left to right,
1995* top to bottom.
1996* Screen dimensions are 16 combos wide, by 11 combos high.
1997*
1998*/ Example Use: !#!
1999
2000/************************************************************************************************************/
2001
2002int ComboF[]; ZASM Instruction:
2003 CF### COMBOF
2004 COMBOFD COMBOFDM
2005
2006/**
2007* The placed flag of the ith combo on the screen, where i is the index
2008* used to access this array. Combos are counted left to right, top to
2009* bottom. Use the CF_ constants in std.zh to set or compare these values.
2010* Screen dimensions are 16 combos wide, by 11 combos high.
2011*
2012*/ Example Use: !#!
2013
2014/************************************************************************************************************/
2015
2016int ComboI[]; ZASM Instruction:
2017 CI### COMBOID
2018 COMBOIDM
2019
2020
2021/**
2022* The inherent flag of the ith combo on the screen, where i is the index
2023* used to access this array. Combos are counted left to right, top to
2024* bottom. Use the CF_ constants in std.zh to set or compare these values.
2025* Screen dimensions are 16 combos wide, by 11 combos high.
2026*
2027*/ Example Use: !#!
2028
2029/************************************************************************************************************/
2030
2031int ComboT[]; ZASM Instruction:
2032 CT### COMBOTD
2033 COMBOTDM
2034
2035
2036/**
2037* The combo type of the ith combo on the screen, where i is the index
2038* used to access this array. Combos are counted left to right, top to
2039* bottom. Use the CT_ constants in std.zh to set or compare these values.
2040* Screen dimensions are 16 combos wide, by 11 combos high.
2041*
2042*/ Example Use: !#!
2043
2044/************************************************************************************************************/
2045
2046int ComboS[]; ZASM Instruction:
2047 CS### COMBOSD
2048 COMBOSDM
2049
2050
2051/**
2052* The walkability mask of the ith combo on the screen, where i is the
2053* index used to access this array. Combos are counted left to right, top
2054* to bottom. The least signficant bit is true if the top-left of the combo
2055* is solid, the second-least signficant bit is true if the bottom-left
2056* of the combo is is solid, the third-least significant bit is true if the
2057* top-right of the combo is solid, and the fourth-least significant bit is
2058* true if the bottom-right of the combo is solid.
2059* Screen dimensions are 16 combos wide, by 11 combos high.
2060*
2061*/ Example Use: !#!
2062
2063/************************************************************************************************************/
2064
2065int MovingBlockX; ZASM Instruction:
2066 PUSHBLOCKX
2067
2068
2069/**
2070* The X position of the current moving block. If there is no moving block
2071* on the screen, it will be -1. This is read-only; while setting it is not
2072* syntactically incorrect, it does nothing.
2073*
2074*/ Example Use: !#!
2075
2076/************************************************************************************************************/
2077
2078int MovingBlockY; ZASM Instruction:
2079 PUSHBLOCKY
2080
2081/**
2082* The Y position of the current moving block. If there is no moving block
2083* on the screen, it will be -1. This is read-only; while setting it is not
2084* syntactically incorrect, it does nothing.
2085*
2086*/ Example Use: !#!
2087
2088/************************************************************************************************************/
2089
2090int MovingBlockCombo; ZASM Instruction:
2091 PUSHBLOCKCOMBO
2092
2093/**
2094* The combo used by moving block. If there is no block moving, the value
2095* is undefined.
2096*
2097*/ Example Use: !#!
2098
2099/************************************************************************************************************/
2100
2101int MovingBlockCSet; ZASM Instruction:
2102 PUSHBLOCKCSET
2103
2104/**
2105* The CSet used by moving block. If there is no block moving, the value
2106* is undefined.
2107*
2108*/ Example Use: !#!
2109
2110/************************************************************************************************************/
2111
2112int UnderCombo; ZASM Instruction:
2113 UNDERCOMBO
2114
2115/**
2116* The current screen's under combo.
2117* !#! Is setting this legal?
2118*
2119*/ Example Use: !#!
2120
2121/************************************************************************************************************/
2122
2123int UnderCSet; ZASM Instruction:
2124 UNDERCSET
2125
2126/**
2127* The current screen's under CSet.
2128* !#! Is setting this legal?
2129*
2130*/ Example Use: !#!
2131
2132/************************************************************************************************************/
2133
2134bool State[]; ZASM Instruction:
2135 SCREENSTATED
2136
2137/**
2138* An array of miscellaneous status data associated with the current
2139* screen.
2140* Screen states involve such things as permanent screen secrets, the
2141* status of lock blocks and treasure chest combos, and whether items have
2142* been collected.
2143* These values are recorded in the save file when the player saves their
2144* game. Use the ST_ constants in std.zh as indices into this array.
2145*
2146*/ Example Use: !#!
2147
2148/************************************************************************************************************/
2149
2150int Door[]; ZASM Instruction:
2151 SCRDOORD
2152 SCRDOOR
2153
2154/**
2155* The door type for each of the four doors on a screen. Doors are counted
2156* using the first four DIR_ constants in std.zh. Use the D_ constants in
2157* std.zh to compare these values.
2158*
2159*/ Example Use: !#!
2160
2161/************************************************************************************************************/
2162
2163int RoomType; ZASM Instruction:
2164 ROOMTYPE
2165
2166/**
2167* The type of room this screen is (Special Item, Bomb Upgrade, etc)
2168* This is currently read-only.
2169* Use the RT_* constants in std.zh
2170*
2171*/ Example Use: !#!
2172
2173/************************************************************************************************************/
2174
2175int RoomData; ZASM Instruction:
2176 ROOMDATA
2177
2178/**
2179* This is the data associated with the room type above. What it means depends
2180* on the room type. For Special Item, it will be the item ID, for a Shop, it
2181* will be the Shop Number, etc.
2182* Basically, this is what's in the "Catch-all" menu item underneath Room Type.
2183* If the room type has no data (eg, Ganon's room), this will be undefined.
2184*
2185*/ Example Use: !#!
2186
2187/************************************************************************************************************/
2188
2189void TriggerSecrets(); ZASM Instruction:
2190 SECRETS ? !#!
2191
2192/**
2193* Triggers screen secrets temporarily. Set Screen->State[ST_SECRET]
2194* to true beforehand or afterward if you would like them to remain
2195* permanent.
2196*
2197*/ Example Use: Screen->TriggerSecrets();
2198
2199
2200/************************************************************************************************************/
2201
2202void WavyIn(); ZASM Instruction:
2203 WAVYIN
2204
2205/**
2206* Replicates the warping screen wave effect (inbound) from a tile warp.
2207*
2208*/ Example Use: !#!
2209
2210/************************************************************************************************************/
2211
2212void WavyOut(); ZASM Instruction:
2213 WAVYOUT
2214
2215/**
2216* Replicates the warping screen wave effect (outbound) from a tile warp.
2217*
2218*/ Example Use: !#!
2219
2220/************************************************************************************************************/
2221
2222void ZapIn(); ZASM Instruction:
2223 ZAPIN
2224
2225/**
2226* Replicates the warping screen zap effect (inbound) from a tile warp.
2227*
2228*/ Example Use: !#!
2229
2230/************************************************************************************************************/
2231
2232void ZapOut(); ZASM Instruction:
2233 ZAPOUT
2234
2235/**
2236* Replicates the warping screen zap effect (outbound) from a tile warp.
2237*
2238*/ Example Use: !#!
2239
2240/************************************************************************************************************/
2241
2242void OpeningWipe(); ZASM Instruction:
2243 OPENWIPE
2244
2245/**
2246* Replicates the opening wipe screen effect (using the quest rule for its type) from a tile warp.
2247*
2248*/ Example Use: !#!
2249
2250/************************************************************************************************************/
2251
2252bool Lit; ZASM Instruction:
2253 LIT
2254
2255/**
2256* Whether or not the screen is lit. Setting this variable will change the
2257* lighting setting of the screen until you change screens.
2258*
2259*/ Example Use: !#!
2260
2261
2262/************************************************************************************************************/
2263
2264int Wavy; ZASM Instruction:
2265 WAVY
2266
2267/**
2268* The time, in frames, that the 'wave' screen effect will be in effect.
2269* This value is decremented once per frame. As the value of Wavy approaches 0,
2270* the intensity of the waves decreases.
2271*
2272*/ Example Use: !#!
2273
2274/************************************************************************************************************/
2275
2276int Quake; ZASM Instruction:
2277 QUAKE
2278
2279/**
2280* The time, in frames, that the screen will shake. This value is decremented
2281* once per frame. As the value of Quake approaches 0, the intensity of the
2282* screen shaking decreases.
2283*
2284*/ Example Use: !#!
2285
2286/************************************************************************************************************/
2287
2288void SetSideWarp(int warp, int screen, int dmap, int type); ZASM Instruction:
2289 SETSIDEWARP
2290
2291/**
2292* Sets the current screen's side warp 'warp' to the destination screen,
2293* DMap and type. If any of the parameters screen, dmap or type are equal
2294* to -1, they will remain unchanged. If warp is not between 0 and 3, the
2295* function does nothing.
2296
2297* Directions match DIR_* in std_constants.zh
2298* Use constants SIDEWARP_* in std_constants.zh
2299*
2300*/ Example Use: !#!
2301
2302/************************************************************************************************************/
2303
2304void SetTileWarp(int warp, int screen, int dmap, int type); ZASM Instruction:
2305 SETTILEWARP
2306
2307/**
2308* Sets the current screen's tile warp 'warp' to the destination screen,
2309* DMap and type. If any of the parameters screen, dmap or type are equal
2310* to -1, they will remain unchanged. If warp is not between 0 and 3, the
2311* function does nothing
2312*
2313* Warp-Tiles A, B, C, and D are 0, 1, 2, and 3 respectively.
2314* Use constants TILEWARP_* in std_constants.zh
2315*
2316*/ Example Use: !#!
2317
2318/************************************************************************************************************/
2319
2320int GetSideWarpDMap(int warp); ZASM Instruction:
2321 GETSIDEWARPDMAP
2322
2323/**
2324* Returns the destination DMap of the given side warp on the current screen.
2325* Returns -1 if warp is not between 0 and 3.
2326*
2327* Side-Warp Directions match DIR_* in std_constants.zh
2328* Use constants SIDEWARP_* in std_constants.zh
2329*
2330*/ Example Use: !#!
2331
2332/************************************************************************************************************/
2333
2334int GetSideWarpScreen(int warp); ZASM Instruction:
2335 GETSIDEWARPSCR
2336
2337/**
2338* Returns the destination screen of the given side warp on the current
2339* screen. Returns -1 if warp is not between 0 and 3.
2340*
2341* Directions match DIR_* in std_constants.zh
2342* Use constants SIDEWARP_* in std_constants.zh
2343*
2344*/ Example Use: !#!
2345
2346/************************************************************************************************************/
2347
2348int GetSideWarpType(int warp); ZASM Instruction:
2349 GETSIDEWARPTYPE
2350
2351/**
2352* Returns the warp type of the given side warp on the current screen.
2353* Returns -1 if warp is not between 0 and 3.
2354*
2355* Directions match DIR_* in std_constants.zh
2356* Use constants SIDEWARP_* in std_constants.zh
2357*
2358*/ Example Use: !#!
2359
2360/************************************************************************************************************/
2361
2362int GetTileWarpDMap(int warp); ZASM Instruction:
2363 GETTILEWARPDMAP
2364
2365/**
2366* Returns the destination DMap of the given tile warp on the current screen.
2367* Returns -1 if warp is not between 0 and 3.
2368*
2369* Warp-Tiles A, B, C, and D are 0, 1, 2, and 3 respectively.
2370* Use constants TILEWARP_* in std_constants.zh
2371*
2372*/ Example Use: !#!
2373
2374/************************************************************************************************************/
2375
2376int GetTileWarpScreen(int warp); ZASM Instruction:
2377 GETTILEWARPSCR
2378
2379/**
2380* Returns the destination screen of the given tile warp on the current
2381* screen. Returns -1 if warp is not between 0 and 3.
2382*
2383* Warp-Tiles A, B, C, and D are 0, 1, 2, and 3 respectively.
2384* Use constants TILEWARP_* in std_constants.zh
2385*
2386*/ Example Use: !#!
2387
2388/************************************************************************************************************/
2389
2390int GetTileWarpType(int warp); ZASM Instruction:
2391 GETTILEWARPTYPE
2392
2393/**
2394* Returns the warp type of the given tile warp on the current screen.
2395* Returns -1 if warp is not between 0 and 3.
2396*
2397* Warp-Tiles A, B, C, and D are 0, 1, 2, and 3 respectively.
2398* Use constants TILEWARP_* in std_constants.zh
2399*
2400*/ Example Use: !#!
2401
2402/************************************************************************************************************/
2403
2404int LayerMap(int n); ZASM Instruction:
2405 LAYERMAP
2406
2407/**
2408* Returns the map of the screen currently being used as the nth layer.
2409* Values of n less than 1 or greater than 6, or layers that are not set up,
2410* returns -1.
2411*
2412*/ Example Use: !#!
2413
2414/************************************************************************************************************/
2415
2416int LayerScreen(int n); ZASM Instruction:
2417 LAYERSCREEN
2418
2419/**
2420* Returns the number of the screen currently being used as the nth layer.
2421* Values of n less than 1 or greater than 6, or layers that are not set up,
2422* returns -1.
2423*
2424*/ Example Use: !#!
2425
2426/************************************************************************************************************/
2427
2428int NumItems(); ZASM Instruction:
2429 ITEMCOUNT
2430
2431/**
2432* Returns the number of items currently present on the screen. Screen
2433* items, shop items, and items dropped by enemies are counted; Link's
2434* weapons, such as lit bombs, or enemy weapons are not counted.
2435* Note that this value is only correct up until the next call to
2436* Waitframe().
2437*
2438*/ Example Use: !#!
2439
2440/************************************************************************************************************/
2441
2442item LoadItem(int num); ZASM Instruction:
2443 LOADITEMR
2444 LOADITEMV
2445
2446/**
2447* Returns a pointer to the numth item on the current screen. The return
2448* value is undefined unless 1 <= num <= NumItems().
2449*
2450* Attempting to return an invalid item pointer will print an error to allegro.log.
2451*
2452*/ Example Use: !#!
2453
2454/************************************************************************************************************/
2455
2456item CreateItem(int id); ZASM Instruction:
2457 CREATEITEMV
2458 CREATEITEMR
2459
2460/**
2461* Returns a pointer to the numth FFC on the current screen. The return
2462* value is undefined unless 1 <= num <= ffcs, where ffcs is the number
2463* of FFCs active on the screen.
2464*
2465*/ Example Use: !#!
2466
2467/************************************************************************************************************/
2468
2469ffc LoadFFC(int num); ZASM Instruction:
2470 GETFFCSCRIPT
2471
2472/**
2473* Returns a pointer to the numth FFC on the current screen. The return
2474* value is undefined unless 1 <= num <= ffcs, where ffcs is the number
2475* of FFCs active on the screen.
2476*
2477*/ Example Use: !#!
2478
2479/************************************************************************************************************/
2480
2481int NumNPCs(); ZASM Instruction:
2482 NPCCOUNT
2483
2484/**
2485* Returns the number of NPCs (enemies and guys) on the screen.
2486* Note that this value is only correct up until the next call to
2487* Waitframe().
2488*
2489*/ Example Use: !#!
2490
2491/************************************************************************************************************/
2492
2493npc LoadNPC(int num); ZASM Instruction:
2494 LOADNPCR
2495 LOADNPCV
2496
2497/**
2498* Returns a pointer to the numth NPC on the current screen. The return
2499* value is undefined unless 1 <= num <= NumNPCs().
2500*
2501*/ Example Use: !#!
2502
2503/************************************************************************************************************/
2504
2505npc CreateNPC(int id); ZASM Instruction:
2506 CREATENPCR
2507 CREATENPCV
2508
2509/**
2510* Creates an npc of the given type at (0,0). Use the NPC_ constants in
2511* std.zh to pass into this method. The return value is a pointer to the
2512* new NPC.
2513* The maximum number of NPCs on any given screen is 255. ZC will report an
2514* error to allegro.log if you try to create NPCs after reaching that maximum.
2515*
2516*/ Example Use: !#!
2517
2518/************************************************************************************************************/
2519
2520int NumLWeapons(); ZASM Instruction:
2521 LWPNCOUNT
2522
2523/**
2524* Returns the number of Link weapon projectiles currently present on the screen.
2525* This includes things like Link's arrows, bombs, magic, etc. Note that this
2526* value is only correct up until the next call of Waitframe().
2527*
2528*/ Example Use: !#!
2529
2530/************************************************************************************************************/
2531
2532lweapon LoadLWeapon(int num); ZASM Instruction:
2533 LOADLWEAPONR
2534 LOADLWEAPONV
2535
2536/**
2537* Returns a pointer to the num-th lweapon on the current screen. The return
2538* value is undefined unless 1 <= num <= NumLWeapons().
2539*
2540*/ Example Use: !#!
2541
2542/************************************************************************************************************/
2543
2544lweapon CreateLWeapon(int type); ZASM Instruction:
2545 CREATELWEAPONR
2546 CREATELWEAPONV
2547
2548/**
2549* Creates an lweapon of the given type at (0,0). Use the LW_ constants in
2550* std.zh to pass into this method. The return value is a pointer to the
2551* new lweapon.
2552* The maximum number of lweapons on any given screen is 255. ZC will NOT report an
2553* error to allegro.log if you try to create lweapons after reaching that maximum.
2554* The maximum instances for lweapons, and eweapons are independent.
2555* This cap is of *all* lweapons, of any type. Mixing types will not increase this cap.
2556*
2557*/ Example Use: !#!
2558
2559/************************************************************************************************************/
2560
2561int NumEWeapons(); ZASM Instruction:
2562 EWPNCOUNT
2563
2564/**
2565* Returns the number of Enemy weapon projectiles currently present on the screen.
2566* This includes things like Enemy arrows, bombs, magic, etc. Note that this
2567* value is only correct up until the next call of Waitframe().
2568*
2569*/ Example Use: !#!
2570
2571/************************************************************************************************************/
2572
2573eweapon LoadEWeapon(int num); ZASM Instruction:
2574 LOADEWEAPONR
2575 LOADEWEAPONV
2576
2577/**
2578* Returns a pointer to the numth eweapon on the current screen. The return
2579* value is undefined unless 1 <= num <= NumEWeapons().
2580*
2581*/ Example Use: !#!
2582
2583/************************************************************************************************************/
2584
2585eweapon CreateEWeapon(int type); ZASM Instruction:
2586 CREATEEWEAPONR
2587 CREATEEWEAPONV
2588
2589/**
2590* Creates an eweapon of the given type at (0,0). Use the EW_ constants in
2591* std.zh to pass into this method. The return value is a pointer to the
2592* new lweapon.
2593* The maximum number of eweapons on any given screen is 255. ZC will NOT report an
2594* error to allegro.log if you try to create eweapons after reaching that maximum.
2595* The maximum instances for eweapons, and lweapons are independent.
2596* This cap is of *all* eweapons, of any type. Mixing types will not increase this cap.
2597*
2598*/ Example Use: !#!
2599
2600/************************************************************************************************************/
2601
2602bool isSolid(int x, int y); ZASM Instruction:
2603 ISSOLID
2604
2605/**
2606* Returns true if the screen position (x, y) is solid - that is, if it
2607* is within the solid portion of a combo on layers 0, 1 or 2. If either
2608* x or y exceed the screen's bounds, then it will return false.
2609* It will also return false if the only applicable solid combo is a solid
2610* water combo that has recently been 'dried' by the whistle.
2611*
2612*/ Example Use: !#!
2613
2614/************************************************************************************************************/
2615
2616void ClearSprites(int spritelist); ZASM Instruction:
2617 CLEARSPRITESR
2618 CLEARSPRITESV
2619
2620/**
2621* Clears all of a certain kind of sprite from the screen. Use the SL_
2622* constants in std.zh to pass into this method.
2623*
2624*/ Example Use: !#!
2625
2626/************************************************************************************************************/
2627
2628void Message(int string);
2629
2630 ZASM Instruction:
2631 MSGSTRR
2632 MSGSTRV
2633/**
2634* Prints the message string with given ID onto the screen.
2635* If string is 0, the currently displayed message is removed.
2636* This method's behavior is undefined if string is less than 0
2637* or greater than the total number of messages in the quest.
2638*/ Example Use: !#!
2639
2640/************************************************************************************************************/
2641
2642 //===============================//
2643 // SCRIPT DRAWING COMMANDS //
2644 //===============================//
2645
2646 /* These commands use the Allegro 4 drawing primitives to render drawn
2647 effects directly to the screen. You may draw to the screen immediately
2648 which is considered RT_SCREEN (see: Render Targets), or you may change
2649 to another render target (1 through 5) and issue your drawing commands,
2650 then render that back to the screen.
2651
2652 All render targets have eight valid layers, 0 through 7.
2653 Drawing colour 0 to a layer of a bitmap render target erases a section of that,
2654 creating a transparent area on that layer. Any transparent area that extends
2655 through all layers will be drawn as transparent when rendered back to the screen
2656 if 'bool mask' is set true.
2657
2658 Drawing colour 0 directly to a screen layer is undefined.
2659
2660 Please note: For all draw primitives, if the quest rule 'Subscreen Appears
2661 Above Sprites' is set,passing the layer argument as 7 will allow drawing
2662 on top of the subscreen.
2663
2664 Tha maximum number of script drawing instructions per frame is 1000.
2665
2666
2667
2668void Rectangle( int layer, int x, int y, int x2, int y2,
2669 int color, float scale,
2670 int rx, int ry, int rangle,
2671 bool fill, int opacity );
2672
2673 ZASM Instruction:
2674 RECTR
2675 RECT
2676
2677/**
2678* Draws a rectangle on the specified layer of the current screen, using args to set its properties:
2679*
2680* METRICS
2681* (x,y) as the top-left corner and (x2,y2) as the bottom-right corner.
2682*
2683* COLOUR
2684*
2685* SCALE AND ROTATION
2686*
2687* FILL AND OPACITY
2688*
2689* Then scales the rectangle uniformly about its center by the given
2690* factor.
2691* Lastly, a rotation, centered about the point (rx, ry), is performed
2692* counterclockwise using an angle of rangle degrees.
2693* A filled rectangle is drawn if fill is true; otherwise, this method
2694* draws a wireframe.
2695* The rectangle is drawn using the specified index into the entire
2696* 256-element palette: for instance, passing in a color of 17 would
2697* use color 1 of cset 1.
2698* Opacity controls how transparent the rectangle will be.
2699* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
2700* for an opaque (100%) image. Other values are **ignored**, and will be treated
2701* as translucent (OP_TRANS, or 64).
2702*
2703*/ Example Use: !#!
2704
2705/************************************************************************************************************/
2706
2707void Circle( int layer, int x, int y, int radius,
2708 int color, float scale,
2709 int rx, int ry, int rangle,
2710 bool fill, int opacity );
2711
2712
2713 ZASM Instruction:
2714 CIRCLE
2715 CIRCLER
2716
2717/**
2718* Draws a circle on the specified layer of the current screen with
2719* center (x,y) and radius scale*radius.
2720* Then performs a rotation counterclockwise, centered about the point
2721* (rx, ry), using an angle of rangle degrees.
2722* A filled circle is drawn if fill is true; otherwise, this method
2723* draws a wireframe.
2724* The circle is drawn using the specified index into the entire
2725* 256-element palette: for instance, passing in a color of 17 would
2726* use color 1 of cset 1.
2727* Opacity controls how transparent the circle will be.
2728* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
2729* for an opaque (100%) image. Other values are **ignored**, and will be treated
2730* as translucent (OP_TRANS, or 64).
2731*
2732*/ Example Use: !#!
2733
2734/************************************************************************************************************/
2735
2736void Arc( int layer, int x, int y, int radius, int startangle, int endangle,
2737 int color, float scale,
2738 int rx, int ry, int rangle,
2739 bool closed, bool fill, int opacity );
2740
2741 ZASM Instruction:
2742 ARC
2743 ARCR
2744
2745/**
2746* Draws an arc of a circle on the specified layer of the current
2747* screen. The circle in question has center (x,y) and radius
2748* scale*radius.
2749* The arc beings at startangle degrees counterclockwise from standard
2750* position, and ends at endangle degress counterclockwise from standard
2751* position. The behavior of this function is undefined unless
2752* 0 <= endangle-startangle < 360.
2753* The arc is then rotated about the point (rx, ry) using an angle of
2754* rangle radians.
2755* If closed is true, a line is drawn from the center of the circle to
2756* each endpoint of the arc, forming a sector of the circle. If fill
2757* is also true, a filled sector is drawn instead.
2758* The arc or sector is drawn using the specified index into the entire
2759* 256-element palette: for instance, passing in a color of 17 would
2760* use color 1 of cset 1.
2761* Opacity controls how transparent the arc will be.
2762* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
2763* for an opaque (100%) image. Other values are **ignored**, and will be treated
2764* as translucent (OP_TRANS, or 64).
2765*
2766*/ Example Use: !#!
2767
2768/************************************************************************************************************/
2769
2770void Ellipse( int layer, int x, int y, int xradius, int yradius,
2771 int color, float scale,
2772 int rx, int ry, int rangle,
2773 bool fill, int opacity);
2774
2775
2776
2777 ZASM Instruction:
2778 ELLIPSE2
2779 ELLIPSER
2780
2781/**
2782* Draws an ellipse on the specified layer of the current screen with
2783* center (x,y), x-axis radius xradius, and y-axis radius yradius.
2784* Then performs a rotation counterclockwise, centered about the point
2785* (rx, ry), using an angle of rangle degrees.
2786* A filled ellipse is drawn if fill is true; otherwise, this method
2787* draws a wireframe.
2788* The ellipse is drawn using the specified index into the entire
2789* 256-element palette: for instance, passing in a color of 17 would
2790* use color 1 of cset 1.
2791* Opacity controls how transparent the ellipse will be.
2792* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
2793* for an opaque (100%) image. Other values are **ignored**, and will be treated
2794* as translucent (OP_TRANS, or 64).
2795*
2796*/ Example Use: !#!
2797
2798/************************************************************************************************************/
2799
2800void Spline( int layer, int x1, int y1, int x2, int y2, int x3, int y3,int x4, int y4,
2801 int color, int opacity);
2802
2803 ZASM Instruction:
2804 SPLINER
2805 SPLINE
2806
2807/**
2808* Draws a cardinal spline on the specified layer of the current screen
2809* between (x1,y1) and (x4,y4)
2810* The spline is drawn using the specified index into the entire
2811* 256-element palette: for instance, passing in a color of 17 would
2812* use color 1 of cset 1.
2813* Opacity controls how transparent the ellipse will be.
2814* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
2815* for an opaque (100%) image. Other values are **ignored**, and will be treated
2816* as translucent (OP_TRANS, or 64).
2817*
2818*/ Example Use: !#!
2819
2820/************************************************************************************************************/
2821
2822void Line( int layer, int x, int y, int x2, int y2,
2823 int color, float scale,
2824 int rx, int ry, int rangle,
2825 int opacity );
2826
2827 ZASM Instruction:
2828 LINE
2829 LINER
2830/**
2831* Draws a line on the specified layer of the current screen between
2832* (x,y) and (x2,y2).
2833* Then scales the line uniformly by a factor of scale about the line's
2834* midpoint.
2835* Finally, performs a rotation counterclockwise, centered about the
2836* point (rx, ry), using an angle of rangle degrees.
2837* The line is drawn using the specified index into the entire
2838* 256-element palette: for instance, passing in a color of 17 would
2839* use color 1 of cset 1.
2840* Opacity controls how transparent the line will be.
2841* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
2842* for an opaque (100%) image. Other values are **ignored**, and will be treated
2843* as translucent (OP_TRANS, or 64).
2844*
2845*/ Example Use: !#!
2846
2847/************************************************************************************************************/
2848
2849void PutPixel (int layer, int x, int y,
2850 int color,
2851 int rx, int ry, int rangle,
2852 int opacity);
2853
2854 ZASM Instruction:
2855 PUTPIXEL
2856 PUTPIXELR
2857/**
2858* Draws a raw pixel on the specified layer of the current screen
2859* at (x,y).
2860* Then performs a rotation counterclockwise, centered about the point
2861* (rx, ry), using an angle of rangle degrees.
2862* The point is drawn using the specified index into the entire
2863* 256-element palette: for instance, passing in a color of 17 would
2864* use color 1 of cset 1.
2865* Opacity controls how transparent the point will be.
2866* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
2867* for an opaque (100%) image. Other values are **ignored**, and will be treated
2868* as translucent (OP_TRANS, or 64).
2869*
2870*/ Example Use: !#!
2871
2872/************************************************************************************************************/
2873
2874void DrawTile (int layer, int x, int y,
2875 int tile, int blockw, int blockh,
2876 int cset, int xscale, int yscale,
2877 int rx, int ry, int rangle,
2878 int flip,
2879 bool transparency, int opacity);
2880
2881 ZASM Instruction:
2882 DRAWTILE
2883 DRAWTILER
2884/**
2885* Draws a block of tiles on the specified layer of the current screen,
2886* starting at (x,y), using the specified cset.
2887* Starting with the specified tile, this method copies a block of size
2888* blockh x blockw from the tile sheet to the screen. This method's
2889* behavior is undefined unless 1 <= blockh, blockw <= 20.
2890* Scale specifies the actual size in pixels! So scale 1 would mean it is
2891* only one pixel in size. To use the default sizes of block w,h you must
2892* set xscale and yscale to -1. These values are not independant of one another,
2893* so you cannot set xscale and leave yscale at -1.
2894* rx, ry : these work now, just like the other primitives.
2895* rangle performs a rotation clockwise using an angle of rangle degrees.
2896* Flip specifies how the tiles should be flipped when drawn:
2897* 0: No flip
2898* 1: Horizontal flip
2899* 2: Vertical flip
2900* 3: Both (180 degree rotation)
2901* If transparency is true, the tiles' transparent regions will be
2902* respected.
2903* Opacity controls how transparent the solid portions of the tiles will
2904* be.
2905* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
2906* for an opaque (100%) image. Other values are **ignored**, and will be treated
2907* as translucent (OP_TRANS, or 64).
2908*/ Example Use: !#!
2909
2910/************************************************************************************************************/
2911
2912void FastTile (int layer, int x, int y,
2913 int tile, int cset,
2914 int opacity );
2915
2916 ZASM Instruction:
2917 FASTTILER
2918/**
2919* Optimized and simpler version of DrawTile()
2920* Draws a single tile on the current screen much in the same way as DrawTile().
2921* See DrawTile() for an explanation on what these arguments do.
2922*/ Example Use: !#!
2923
2924/************************************************************************************************************/
2925
2926void DrawCombo (int layer, int x, int y,
2927 int combo, int w, int h,
2928 int cset, int xscale, int yscale,
2929 int rx, int ry, int rangle,
2930 int frame, int flip,
2931 bool transparency, int opacity);
2932
2933 ZASM Instruction:
2934 DRAWCOMBO
2935 DRAWCOMBOR
2936/**
2937* Draws a combo on the specified layer of the current screen,
2938* starting at (x,y), using the specified cset.
2939* Starting with the specified tile referenced by the combo,
2940* this method copies a block of size
2941* blockh x blockw from the tile sheet to the screen. This method's
2942* behavior is undefined unless 1 <= blockh, blockw <= 20.
2943* Scale specifies the actual size in pixels! So scale 1 would mean it is
2944* only one pixel in size. To use the default sizes of block w,h you must
2945* set xscale and yscale to -1. These values are not independant of one another,
2946* so you cannot set xscale and leave yscale at -1.
2947* rx, ry : works now :
2948* rangle performs a rotation clockwise using an angle of rangle degrees.
2949* Flip specifies how the tiles should be flipped when drawn:
2950* 0: No flip
2951* 1: Horizontal flip
2952* 2: Vertical flip
2953* 3: Both (180 degree rotation)
2954* If transparency is true, the tiles' transparent regions will be
2955* respected.
2956* Opacity controls how transparent the solid portions of the tiles will
2957* be.
2958* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
2959* for an opaque (100%) image. Other values are **ignored**, and will be treated
2960* as translucent (OP_TRANS, or 64).
2961*/ Example Use: !#!
2962
2963/************************************************************************************************************/
2964
2965void FastCombo (int layer, int x, int y,
2966 int combo, int cset,
2967 int opacity );
2968
2969 ZASM Instruction:
2970 FASTCOMBOR
2971/**
2972* Optimized and simpler version of DrawCombo()
2973* Draws a single combo on the current screen much in the same way as DrawCombo().
2974* See DrawCombo() for an explanation on what these arguments do.
2975*/ Example Use: !#!
2976
2977/************************************************************************************************************/
2978
2979void DrawCharacter (int layer, int x, int y,
2980 int font, int color, int background_color,
2981 int width, int height, int glyph,
2982 int opacity );
2983
2984 ZASM Instruction:
2985 DRAWCHARR
2986/**
2987* Draws a single ASCII character 'glyph' on the specified layer of the current screen,
2988* using the specified font index (see std.zh for FONT_* list to pass to this method),
2989* starting at (x,y), using the specified color as the foreground color
2990* and background_color as the background color. * NOTE * Use -1 for a transparent background.
2991* The arguments width and height may be used to draw the glyph
2992* of any arbitrary size begining at 1 pixel up to 512 pixels large. (more than four times the size of the screen)
2993* Passing 0 or negative values to this will use the default fonts w and h.
2994* Opacity controls how transparent the is.
2995* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
2996* for an opaque (100%) image. Other values are **ignored**, and will be treated
2997* as translucent (OP_TRANS, or 64).
2998*/ Example Use: !#!
2999
3000/************************************************************************************************************/
3001
3002void DrawInteger (int layer, int x, int y,
3003 int font, int color, int background_color,
3004 int width, int height, int number, int number_decimal_places,
3005 int opacity);
3006
3007
3008 ZASM Instruction:
3009 DRAWINTR
3010/**
3011* Draws a zscript 'int' or 'float' on the specified layer of the current screen,
3012* using the specified font index (see std.zh for FONT_* list to pass to this method),
3013* starting at (x,y), using the specified color as the foreground color
3014* and background_color as the background color. * NOTE * Use -1 for a transparent background.
3015* The arguments width and height may be used to draw the number
3016* of any arbitrary size begining at 1 pixel up to 512 pixels large.
3017* Passing 0 or negative values to this will use the default fonts w and h.
3018* The number can be rendered as type 'int' or 'float' by setting the argument
3019* "number_decimal_places", which is only valid if set to 0 or <= 4.
3020* Opacity controls how transparent the is.
3021* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
3022* for an opaque (100%) image. Other values are **ignored**, and will be treated
3023* as translucent (OP_TRANS, or 64).
3024*/ Example Use: !#!
3025
3026/************************************************************************************************************/
3027
3028void DrawString( int layer, int x, int y,
3029 int font, int color, int background_color, int format,
3030 int ptr[],
3031 int opacity );
3032
3033 ZASM Instruction:
3034 DRAWSTRINGR
3035/**
3036* Prints a NULL terminated string up to 256 characters from an int array
3037* containing ASCII data (*ptr) on the specified layer of the current screen,
3038* using the specified font index (see std.zh for FONT_* list to pass to this method),
3039* using the specified color as the foreground color
3040* and background_color as the background color. * NOTE * Use -1 for a transparent background.
3041* The array pointer should be passed as the argument for '*ptr', ie.
3042* int string[] = "Example String"; Screen->DrawString(l,x,y,f,c,b_c,fo,o,string);
3043* int format tells the engine how to format the string. (see std.zh for TF_* list to pass to this method)
3044* Opacity controls how transparent the message is.
3045* You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
3046* for an opaque (100%) image. Other values are **ignored**, and will be treated
3047* as translucent (OP_TRANS, or 64).
3048*/ Example Use: !#!
3049
3050/************************************************************************************************************/
3051
3052
3053
3054 /////////////////////////
3055 // (Psuedo) 3D drawing //
3056 /////////////////////////
3057
3058 //! When allocating a texture, the size (h,w) must be between 1 and 16, in powers of two.
3059 //! Thus, legal sizes are 1, 2, 4, 8, and 16.
3060 //! This applies to *all* the pseudo-3d and 3-D drawing functions.
3061
3062 void Quad ( int layer,
3063 int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4,
3064 int w, int h, int cset, int flip, int texture, int render_mode);
3065
3066 ZASM Instruction:
3067 QUADR
3068
3069 /**
3070 * Draws a quad on the specified layer with the corners x1,y1 through x4,y4.
3071 * Corners are drawn in a counterclockwise order starting from x1,y1. ( So
3072 * if you draw a "square" for example starting from the bottom-right corner
3073 * instead of the usual top-left, the the image will be textured onto the
3074 * quad so it appears upside-down. -yes, these are rotatable. )
3075 *
3076 * From there a single or block of tiles, combos **or a bitmap** is then texture mapped
3077 * onto the quad using the arguments w, h, cset, flip, and render_mode.
3078 * A positive vale in texture will draw the image from the tilesheet pages,
3079 * whereas a negative value will be drawn from the combo page. 0 will draw combo number 0.
3080 * Both w and h are undefined unless 1 <= blockh, blockw <= 16, and it is a power of
3081 * two. ie: 1, 2 are acceptable, but 2, 15 are not.
3082 *
3083 * To specify a bitmap as a texture, sum 65520 with the bitmap ID, or use the constant TEX_BITMAP + Bitmap
3084 * Example: Screen->Quad(6, 0, 0, 40, 25, 18, 50, 60, 110, 0, 0, 0, 0, TEX_BITMAP+RT_BITMAP0, PT_TEXTURE);
3085 *
3086 *
3087 * Flip specifies how the tiles/combos should be flipped when drawn:
3088 * 0: No flip
3089 * 1: Horizontal flip
3090 * 2: Vertical flip
3091 * 3: Both (180 degree rotation)
3092 * (!) See std.zh for a list of all available render_mode arguments.
3093 */ Example Use: !#!
3094
3095 /************************************************************************************************************/
3096
3097 void Triangle ( int layer,
3098 int x1, int y1, int x2, int y2, int x3, int y3,
3099 int w, int h, int cset, int flip, int texture, int render_mode);
3100
3101 ZASM Instruction:
3102 TRIANGLER
3103
3104 /**
3105 * Draws a triangle on the specified layer with the corners x1,y1 through x4,y4.
3106 * Corners are drawn in a counterclockwise order starting from x1,y1.
3107 * From there a single or block of tiles or combos is then texture mapped
3108 * onto the triangle using the arguments w, h, cset, flip, and render_mode.
3109 *
3110 * A positive value in texture will draw the image from the tilesheet pages,
3111 * whereas a negative value will be drawn from the combo page. 0 will draw combo number 0.
3112 * Both w and h are undefined unless 1 <= blockh, blockw <= 16, and it is a power of
3113 * two. ie: 1, 2 are acceptable, but 2, 15 are not.
3114 *
3115 * Flip specifies how the tiles/combos should be flipped when drawn:
3116 * 0: No flip
3117 * 1: Horizontal flip
3118 * 2: Vertical flip
3119 * 3: Both (180 degree rotation)
3120 * (!) See std.zh for a list of all available render_mode arguments.
3121 */ Example Use: !#!
3122
3123 /************************************************************************************************************/
3124
3125 void Triangle3D ( int layer,
3126 int pos[9], int uv[6], int csets[3], int size[2],
3127 int flip, int tile, int polytype );
3128
3129 ZASM Instruction:
3130 TRIANGLE3DR
3131 /**
3132 * Draws a 3d triangle on the specified layer with the corners x1,y1 through x4,y4.
3133 * Corners are drawn in a counterclockwise order starting from x1,y1.
3134 * From there a single or block of tiles or combos is then texture mapped
3135 * onto the triangle using the arguments w, h, cset, flip, and render_mode.
3136 *
3137 * A positive value in texture will draw the image from the tilesheet pages,
3138 * whereas a negative value will be drawn from the combo page. 0 will draw combo number 0.
3139 * Both w and h are undefined unless 1 <= blockh, blockw <= 16, and it is a power of
3140 * two. ie: 1, 2 are acceptable, but 2, 15 are not.
3141 *
3142 * Arguments take the form of array pointers: Thus, you must declare arrays with the values that you wish to use
3143 * and pass their pointers to each of the following:
3144 *
3145 * [9]pos - x, y, z positions of the 3 corners.
3146 * [6]uv - x, y texture coordinates of the given texture.
3147 * [3]csets - of the corners to interpolate between.
3148 * [2]size - w, h, of the texture.
3149 * w, and h must be in values of 1, 2, 4, 8, or 16.
3150 *
3151 *
3152 * Flip specifies how the tiles/combos should be flipped when drawn:
3153 * 0: No flip
3154 * 1: Horizontal flip
3155 * 2: Vertical flip
3156 * 3: Both (180 degree rotation)
3157 * (!) See std.zh for a list of all available render_mode arguments.
3158 */ Example Use: !#!
3159
3160 /************************************************************************************************************/
3161
3162 void Quad3D ( int layer,
3163 int pos[], int uv[], int cset[], int size[],
3164 int flip, int texture, int render_mode );
3165
3166 ZASM Instruction:
3167 QUAD3DR
3168
3169 /**
3170 * Draws a Quad on the specified layer similar to Quad.
3171 * Arguments take the form of array pointers: Thus, you must declare arrays with the values that you wish to use
3172 * and pass their pointers to each of the following:
3173 *
3174 * [12]pos - x, y, z positions of the 4 corners.
3175 * [8]uv - x, y texture coordinates of the given texture.
3176 * [4]csets - of the corners to interpolate between.
3177 * [2]size - w, h, of the texture.
3178 * w, and h must be in values of 1, 2, 4, 8, or 16.
3179 * (!) See std.zh for a list of all available render_mode arguments.
3180 */ Example Use: !#!
3181
3182 /************************************************************************************************************/
3183
3184 void SetRenderTarget( int bitmap_id );
3185
3186 ZASM Instruction:
3187 SETRENDERTARGET
3188
3189 /**
3190 * Sets the target bitmap for all succesive drawing commands.
3191 * These can be directly to the screen or any one of the available off-screen bitmaps,
3192 * which are generally categorized as -1(screen) or 0-bitmapNumber(off-screen).
3193 *
3194 * (!) See std.zh for a complete list of valid render targets (RT_*).
3195 */ Example Use: !#!
3196
3197 /************************************************************************************************************/
3198
3199 void DrawBitmap ( int layer,
3200 int bitmap_id,
3201 int source_x, int source_y, int source_w, int source_h,
3202 int dest_x, int dest_y, int dest_w, int dest_h,
3203 float rotation, bool mask);
3204
3205 ZASM Instruction:
3206 BITMAPR
3207
3208 /**
3209 * Draws a source rect from off-screen Bitmap with id of bitmap_id onto
3210 * an area of the screen described by dest rect at the given layer.
3211 *
3212 * (!) Note* Script drawing functions are enqueued and executed in a frame-by-frame basis
3213 * based on the order of which layer they need to be drawn to. Drawing to or from
3214 * seperate render tagets or bitmaps is no exception! So keep in mind in order to
3215 * eliminate unwanted drawing orders or bugs.
3216 */ Example Use:
3217 Screen->DrawBitmap( 6, myBitmapId, 0, 0, 16, 16, 79, 57, 32, 32, 0, true );
3218 This would draw a 16x16 area starting at the upper-left corner of source bitmap to
3219 layer 6 of the current screen at coordinates 79,57 with a width and height of
3220
3221
3222
3223 // Screen/Layer Drawing
3224 */
3225
3226 /************************************************************************************************************/
3227
3228 void DrawBitmapEx ( int layer,
3229 int bitmap_id,
3230 int source_x, int source_y, int source_w, int source_h,
3231 int dest_x, int dest_y, int dest_w, int dest_h,
3232 float rotation, int cx, int cy, int mode, int lit, bool mask);
3233
3234 ZASM: BITMAPEXR
3235
3236 /**
3237 *
3238 * As DrawBitmap(), except that it can do more things.
3239 *
3240 * The 'mode' parameter sets up drawing modes. AT PRESENT this supports normal opaque drawing as DrawBitmap()
3241 * AND it supports TRANSLUCENT MODE, which will allow drawing translucent bitmaps.
3242 * The translucent mode does not yet support rotation, and some other modes are temporarily suspended, pending
3243 * full implementation.
3244 *
3245 * See std_constants.zh, under BITDX_* (or possibly we'll change this to BMPDX_* later?) for a list of modes,
3246 * and more information
3247 *
3248 * Draws a source rect from off-screen Bitmap with id of bitmap_id onto
3249 * an area of the screen described by dest rect at the given layer.
3250 *
3251 * (!) Note* Script drawing functions are enqueued and executed in a frame-by-frame basis
3252 * based on the order of which layer they need to be drawn to. Drawing to or from
3253 * seperate render tagets or bitmaps is no exception! So keep in mind in order to
3254 * eliminate unwanted drawing orders or bugs.
3255 *
3256 * Set 'mode' to a value of '1' to draw a translucent bitmap.
3257 *
3258 * Note: Rotation does not work with translucent bitmaps at this time.
3259 *
3260 * cx, cy: Used for pivot
3261 * lit: used for lit colour in light table (may not work).
3262 *
3263 */ Example Use:
3264 Screen->DrawBitmapEx( 6, myBitmapId, 0, 0, 16, 16, 79, 57, 32, 32, 0, 1, true );
3265 This would draw a translucent 16x16 area starting at the upper-left corner of source
3266 bitmap to layer 6 of the current screen at coordinates 79,57 with a width and height of
3267
3268
3269
3270
3271 // Screen/Layer Drawing
3272 */
3273
3274 /************************************************************************************************************/
3275
3276 void DrawLayer (int layer,
3277 int source_map, int source_screen, int source_layer,
3278 int x, int y, float rotation, int opacity);
3279
3280 ZASM Instruction:
3281 DRAWLAYERR
3282
3283 /**
3284 * Draws an entire Layer from source_screen on source_map on the specified layer of the current screen at (x,y).
3285 * If rotation is not zero, it(the entire layer) will rotate about its center.
3286 *
3287 * Opacity controls how transparent the solid portions of the tiles will
3288 * You may use OP_TRANS (64) for a translucent (50%) image, or OP_OPAQUE (128)
3289 * for an opaque (100%) image. Other values are **ignored**, and will be treated
3290 * as translucent (OP_TRANS, or 64).
3291 *
3292 * Also see ScreenToLayer() in std.zh
3293 */ Example Use:
3294
3295 /************************************************************************************************************/
3296
3297 void DrawScreen (int layer,
3298 int map, int source_screen,
3299 int x, int y, float rotation);
3300
3301 ZASM Instruction:
3302 DRAWSCREENR
3303
3304 /**
3305 * Draws an entire screen from screen on map on the specified layer of the current screen at (x,y).
3306 * If rotation is not zero, it(the entire screen) will rotate about its center.
3307 *
3308 */ Example Use:
3309
3310/************************************************************************************************************/
3311/************************************************************************************************************/
3312
3313
3314
3315//===================================
3316//--- FFC Functions and Variables ---
3317//===================================
3318
3319 class ffc
3320
3321/*
3322* The following functions, and arrays are part of the ffc class.
3323*
3324* Ordinarily, these are set when writing an ffc script, using the pointer
3325* this->
3326* Example: this->Data = 10; Sets the Data variable for the present ffc
3327* to a value of '10'.
3328*
3329* The 'this->' pointer is used in ffcs, and item scripts only. It references ffc
3330* variables and arrays in an ffc script; and itemdata variables in an item script.
3331*
3332* Changing ffc variables without 'this->':
3333*
3334* You may change a variable, or array value of the ffc class by loading the ffc into a custom pointer
3335* using Screen->LoadFFC(int number) as follows:
3336*
3337* ffc f; //Declare a general ffc pointer.
3338* //You must use the ffc token to declare the pointer, but you may use any
3339* //name that you desire for it. 'f' here, is merely a short-name example.
3340*
3341* f = Screen->LoadFFC(10); //Loads the data of ffc ID 10 for the present screen into the 'f' pointer.
3342*
3343* f->Data = 15; //Sets the 'Data' variable of the ffc to a value of '15'.
3344*
3345* f->X = 120; //Sets the X-position of the ffc assigned to pointer 'f' to a value of '120'.
3346*/
3347
3348
3349
3350 int ID; ZASM Instruction
3351 FFCID, REFFFC
3352
3353 /**
3354 * Returns the screen index of the FFC, or set working FFC ID.
3355 * Can be set, to change the index of a pointer, but this requires testing and may be unstable.
3356 *
3357 */
3358
3359
3360/************************************************************************************************************/
3361
3362 int GetPointer(ffc *ptr[]); ZASM Instruction:
3363 FFCARRPTR
3364 /**
3365 * Returns the pointer of a ffc array as a float.
3366 */ Example Use:
3367 ffc arr[16];
3368 int size = SizeOfArray( GetPointer(arr) );
3369 //Size == 16
3370
3371/************************************************************************************************************/
3372
3373 ffc SetPointer(int value); ZASM Instruction:
3374 FFCARRPTR2
3375 /**
3376 * Converts an int pointer to the ffc type, for assigning.
3377 */ Example Use:
3378 ffc arr[16]; ffc arrB[2]; int arrC[2];
3379 arrC[0] = GetPointer(arr);
3380 arrB[0] = SetPointer(arrC[0]);
3381
3382/************************************************************************************************************/
3383
3384int Data; ZASM Instruction:
3385 DATA<d3>
3386
3387/**
3388* The number of the combo associated with this FFC.
3389*/ Example Use:
3390
3391 f->Data = 10;
3392 Sets the ffc to Combo 10.
3393
3394/************************************************************************************************************/
3395
3396int Script; ZASM Instruction:
3397 FFSCRIPT<d3>
3398
3399/**
3400* The number of the script assigned to the FFC. This will be automatically
3401* set to 0 when the FFC's script halts. A script cannot change the script of
3402* the FFC running it; in other words, f->Script is read-only when f==this.
3403* When an FFC's script is changed, its arguments, Misc[], and registers will
3404* all be set to 0, and it will start running from the beginning. Set
3405* ffc->InitD[] after setting the script before the script starts running
3406* to pass arguments to it.
3407*
3408*/ Example Use:
3409
3410 f->Script = 10;
3411 Sets the ffc to Combo 10.
3412
3413/************************************************************************************************************/
3414
3415int CSet; ZASM Instruction:
3416 FCSET<d3>
3417
3418/**
3419* The cset of the FFC.
3420*
3421*/ Example Use:
3422
3423 f->CSet = 2;
3424 Sets the ffc to CSet 2.
3425
3426/************************************************************************************************************/
3427
3428int Delay; ZASM Instruction:
3429 DELAY<d3>
3430
3431/**
3432* The FFC's animation delay, in frames.
3433*
3434*/ Example Use:
3435
3436 f->Delay = 120;
3437 120 frames will pass before the ffc animates.
3438
3439/************************************************************************************************************/
3440
3441float X; ZASM Instruction:
3442 FX<d3>
3443
3444/**
3445* The FFC's X position on the screen.
3446*
3447* Values outside the screen boundaries *are* legal.
3448*
3449*/ Example Use:
3450
3451 f->X = 43;
3452 Sets the ffc at X-position 43; 43 pixels to the right of the leftmost screen edge.
3453
3454/************************************************************************************************************/
3455
3456float Y; ZASM Instruction:
3457 FY<d3>
3458
3459/**
3460* The FFC's Y position on the screen.
3461*
3462* Values outside the screen boundaries *are* legal.
3463* The Y value 0 is automatically offset to account for the passive subscreen.
3464* To place an ffc in the area of the passive subscreen, a negative value must be passed to Y.
3465*
3466*/ Example Use:
3467
3468 f->X = 90;
3469 Sets the ffc at Y-position to 90; i.e. 90 pixels below the passive subscreen.
3470
3471/************************************************************************************************************/
3472
3473float Vx; ZASM Instruction:
3474 XD<d3>
3475
3476/**
3477* The FFC's velocity's X-component.
3478*
3479*
3480*/ Example Use:
3481
3482 f->Vx = 20;
3483 The ffc will move by 20 pixels per second on the X avis.
3484
3485/************************************************************************************************************/
3486
3487float Vy; ZASM Instruction:
3488 YD<d3>
3489
3490/**
3491* The FFC's velocity's Y-component.
3492*
3493*
3494*/ Example Use:
3495
3496 f->Vy = 20;
3497 The ffc will move by 20 pixels per second on the Y avis.
3498
3499/************************************************************************************************************/
3500
3501float Ax; ZASM Instruction:
3502 XD2<d3>
3503
3504/**
3505* The FFC's acceleration's X-component.
3506*
3507*
3508*/ Example Use:
3509
3510 f->Vx = 1.03;
3511 Every frame, the velocity X-component will increase by 1.03.
3512
3513/************************************************************************************************************/
3514
3515float Ay; ZASM Instruction:
3516 YD2<d3>
3517
3518/**
3519* The FFC's acceleration's Y-component.
3520*
3521*
3522*/ Example Use:
3523
3524 f->Vx = 0.2903;
3525 Every frame, the velocity Y-component will increase by 0.2903.
3526
3527/************************************************************************************************************/
3528
3529bool Flags[]; ZASM Instruction:
3530 FLAG<d3>
3531 FFFLAGSD
3532
3533
3534/**
3535* The FFC's set of flags. Use the FFCF_ constants in std.zh as the
3536* index to access a particular flag.
3537*
3538*/ Example Use: !#!
3539
3540/************************************************************************************************************/
3541
3542int TileWidth; ZASM Instruction:
3543 FFTWIDTH<d3>
3544 WIDTH<>
3545
3546/**
3547* The number of tile columns composing the FFC.
3548* The maximum value is '4'.
3549*
3550*/ Example Use: !#!
3551
3552/************************************************************************************************************/
3553
3554int TileHeight; ZASM Instruction:
3555 FFTHEIGHT<d3>
3556 HEIGHT<>
3557
3558/**
3559* The number of tile rows composing the FFC.
3560* The maximum value is '4'.
3561*
3562*/ Example Use: !#!
3563
3564/************************************************************************************************************/
3565
3566int EffectWidth; ZASM Instruction:
3567 FFCWIDTH<d3>
3568
3569/**
3570* The width (in pixels) of the area of effect of the combo associated with the FFC.
3571* The maximum value is '64'.
3572*
3573*/ Example Use: !#!
3574
3575/************************************************************************************************************/
3576
3577int EffectHeight; ZASM Instruction:
3578 FFCHEIGHT<d3>
3579
3580/**
3581* The width (in pixels) of the area of effect of the combo associated with the FFC.
3582* The maximum value is '64'.
3583*
3584*/ Example Use: !#!
3585
3586/************************************************************************************************************/
3587
3588int Link; ZASM Instruction:
3589 FFLINK<d3>
3590 LINK<>
3591
3592/**
3593* The number of the FFC linked to by this FFC.
3594*
3595*/ Example Use: !#!
3596
3597/************************************************************************************************************/
3598
3599float InitD[8]; ZASM Instruction:
3600 FFINITD<>
3601 FFINITDD<>?
3602 D<>
3603
3604/**
3605* The original values of the FFC's 8 D input values as they are stored in
3606* the .qst file, regardless of whether they have been modified by ZScript.
3607*
3608*/ Example Use: !#!
3609
3610/************************************************************************************************************/
3611
3612float Misc[16]; ZASM Instruction:
3613 FFMISC
3614 FFMISCD
3615
3616/**
3617* An array of 16 miscellaneous variables for you to use as you please.
3618* These variables are not saved with the ffc.
3619*
3620*/ Example Use: !#!
3621
3622/************************************************************************************************************/
3623
3624Address Argument ZASM Instruction
3625 A<>
3626
3627/************************************************************************************************************/
3628/************************************************************************************************************/
3629
3630
3631
3632
3633
3634//====================================
3635//--- Link Functions and Variables ---
3636//====================================
3637
3638 namespace Link
3639
3640
3641int X; ZASM Instruction:
3642 LINKX
3643
3644/**
3645* Link's X position on the screen, in pixels. Float values passed to this will be truncated to ints.
3646*
3647*/ Example Use: !#!
3648
3649/************************************************************************************************************/
3650
3651int Y; ZASM Instruction:
3652 LINKY
3653
3654/**
3655* Link's Y position on the screen, in pixels. Float values passed to this will be truncated to ints.
3656*
3657*/ Example Use: !#!
3658
3659/************************************************************************************************************/
3660
3661int Z; ZASM Instruction:
3662 LINKZ
3663
3664/**
3665* Link's Z position on the screen, in pixels. Float values passed to this will be truncated to ints.
3666*
3667*/ Example Use: !#!
3668
3669/************************************************************************************************************/
3670
3671bool Invisible; ZASM Instruction:
3672 LINKINVIS
3673
3674/**
3675* Whether Link is currently being draw to the screen. Set true to remove him from view.
3676*
3677*/ Example Use: !#!
3678
3679/************************************************************************************************************/
3680
3681bool CollDetection; ZASM Instruction:
3682 LINKINVINC
3683
3684/**
3685* If true, Link's collision detection with npcs and eweapons is currently turned off.
3686* This variable works on a different system to clocks and the level 4 cheat, so it will not
3687* necessarily return true if they are set.
3688*
3689*/ Example Use: !#!
3690
3691/************************************************************************************************************/
3692
3693int Jump; ZASM Instruction:
3694 LINKJUMP
3695
3696/**
3697* Link's upward velocity, in pixels. If negative, Link will fall.
3698* The downward acceleration of Gravity (in Init Data) modifies this value every frame.
3699*
3700* This value is intended to be in pixels, but appears to be in tiles. ?!
3701*
3702*/ Example Use: !#!
3703
3704/************************************************************************************************************/
3705
3706int SwordJinx; ZASM Instruction:
3707 LINKSWORDJINX
3708
3709/**
3710* The time, in frames, until Link regains use of his sword. -1 signifies
3711* a permanent loss of the sword caused by a Red Bubble.
3712*
3713*/ Example Use: !#!
3714
3715/************************************************************************************************************/
3716
3717int ItemJinx; ZASM Instruction:
3718 LINKITEMJINX
3719
3720/**
3721* The time, in frames, until Link regains use of his items. -1 signifies
3722* a permanent loss of his items. caused by a Red Bubble.
3723*
3724*/ Example Use: !#!
3725
3726/************************************************************************************************************/
3727
3728int Drunk; ZASM Instruction:
3729 LINKDRUNK
3730
3731/**
3732* The time, in frames, that Link will be 'drunk'. If positive, the player's
3733* controls are randomly interfered with, causing Link to move erratically.
3734* This value is decremented once per frame. As the value of Drunk approaches 0,
3735* the intensity of the effect decreases.
3736*
3737*/ Example Use: !#!
3738
3739/************************************************************************************************************/
3740
3741int Dir; ZASM Instruction:
3742 LINKDIR
3743
3744/**
3745* The direction Link is facing. Use the DIR_ constants in std.zh to set
3746* or compare this variable. Note: even though Link can move diagonally if the
3747* quest allows it, his sprite doesn't ever use any of the diagonal directions,
3748* which are intended for enemies only.
3749*
3750* Reading this value occurs after Waitdraw().
3751*
3752*/ Example Use: !#!
3753
3754/************************************************************************************************************/
3755
3756int HitDir; ZASM Instruction:
3757 LINKHITDIR
3758
3759/**
3760* The direction Link should bounce in when he is hit. This is mostly useful for
3761* simulating getting hit by setting Link->Action to LA_GOTHURTLAND.
3762*
3763* This value does nothing if Link->Action does not equal LA_GOTHURTLAND or LA_GOTHURTWATER.
3764* Forcing this value to -1 prevent Link from being knocked back when injured, or when touching any enemy.
3765*
3766*/ Example Use: !#!
3767
3768/************************************************************************************************************/
3769
3770int WarpEffect; ZASM Instruction:
3771 WARPEFFECT
3772
3773/**
3774* Sets a warp effect type prior to doing Screen->Warp
3775* These replicate the in-build effects for tile warps.
3776* see 'std_constants.zh' under WARPFX_* for a list of effects.
3777*
3778*/ Example Use: !#!
3779
3780/************************************************************************************************************/
3781
3782int WarpSound; ZASM Instruction:
3783 LINKWARPSOUND
3784
3785/**
3786* Setting this to a value other than '0' will play that sound when Link warps.
3787*
3788*/ Example Use: !#!
3789
3790/************************************************************************************************************/
3791
3792bool SideWarpSounds; ZASM Instruction:
3793 PLAYWARPSOUND
3794
3795/**
3796* By default, even if you set a warp sound, it will not play in sidewarps.
3797* If you enable this setting, the sound will play in side warps.
3798* At present, this does not disable playing the sound otherwise. Set Link->WarpSound = 0 to do that.
3799*
3800*/ Example Use: !#!
3801
3802/************************************************************************************************************/
3803
3804bool PitWarpSounds; ZASM Instruction:
3805 PLAYPITWARPSFX
3806
3807/**
3808* By default, even if you set a warp sound, it will not play in pit warps.
3809* If you enable this setting, the sound will play in a pit warp, one time.
3810* This value resets after the pit warp, so it is mandatory to re-set it each time tat you desire a pit warp
3811* to play a sound. Do this before Waitdraw().
3812*
3813*/ Example Use: !#!
3814
3815/************************************************************************************************************/
3816
3817int UseWarpReturn; ZASM Instruction:
3818 LINKRETSQUARE
3819
3820/**
3821* Setting this to a value between 0 and 3 will change the target return square for Link->Warp
3822* Valid values are: 0 (A), 1 (B), 2 (C), and 3 (D). Other values will be clamed within this range.
3823*
3824*/ Example Use: !#!
3825
3826/************************************************************************************************************/
3827
3828int UsingItem; ZASM Instruction:
3829 LINKUSINITEM
3830
3831/**
3832* Returns the ID of an item used when Link uses an item.
3833* Returns -1 if Link is not using an item this frame.
3834* Does not work at present.
3835*
3836*/ Example Use: !#!
3837
3838/************************************************************************************************************/
3839
3840int UsingItemA; ZASM Instruction:
3841 LINKUSINITEMA
3842
3843/**
3844* Returns the ID of an item used when Link uses an item on button A.
3845* Returns -1 if Link is not using an item this frame.
3846* Does not work at present.
3847*
3848*/ Example Use: !#!
3849
3850/************************************************************************************************************/
3851
3852int UsingItemB; ZASM Instruction:
3853 LINKUSINITEMB
3854
3855/**
3856* Returns the ID of an item used when Link uses an item on button B.
3857* Returns -1 if Link is not using an item this frame.
3858* Does not work at present.
3859*
3860*/ Example Use: !#!
3861
3862/************************************************************************************************************/
3863
3864bool Diagonal; ZASM Instruction:
3865 LINKDIAG
3866
3867/**
3868* This corresponds to whether 'Diagonal Movement' is enabled, or not.
3869* This will initially return true, or false, based on the setting in Quest->Graphics->Sprites->Link.
3870* You may enable, or disable diagonal movement by writing to this value.
3871*
3872*/ Example Use: !#!
3873
3874/************************************************************************************************************/
3875
3876bool BigHitbox; ZASM Instruction:
3877 LINKBIGHITBOX
3878
3879/**
3880* This corresponds to whether 'Big Hitbox' is enabled, or not.
3881* This will initially return true, or false, based on the setting in Quest->Graphics->Sprites->Link.
3882* You may enable, or disable big hitbox, by writing to this value.
3883*
3884*/ Example Use: !#!
3885
3886/************************************************************************************************************/
3887
3888int HP; ZASM Instruction:
3889 LINKHP
3890
3891/**
3892* Link's current hitpoints, in 16ths of a heart.
3893*
3894*/ Example Use: !#!
3895
3896/************************************************************************************************************/
3897
3898int MP; ZASM Instruction:
3899 LINKMP
3900
3901/**
3902* Link's current amount of magic, in 32nds of a magic block.
3903*
3904*/ Example Use: !#!
3905
3906/************************************************************************************************************/
3907
3908int MaxHP; ZASM Instruction:
3909 LINKMAXHP
3910
3911/**
3912* Link's maximum hitpoints, in 16ths of a heart.
3913*
3914*/ Example Use: !#!
3915
3916/************************************************************************************************************/
3917
3918int MaxMP; ZASM Instruction:
3919 LINKMAXMP
3920
3921/**
3922* Link's maximum amount of magic, in 32nds of a magic block.
3923*
3924*/ Example Use: !#!
3925
3926/************************************************************************************************************/
3927
3928int Action; ZASM Instruction:
3929 LINKACTION<>
3930
3931/**
3932* Link's current action. Use the LA_ constants in std.zh to set or
3933* compare this value.
3934* This value is read-write, but writing some actions are undefined in this
3935* version of ZC. The following are known to work if you write to them:
3936*
3937* LA_NONE
3938* LA_WALKING
3939* LA_ATTACKING
3940* LA_FROZEN //Verify
3941* LA_HOLD1LAND
3942* LA_HOLD2LAND
3943* LA_GOTHURTLAND
3944* LA_SWIMMING
3945* LA_GOTHURTWATER
3946* LA_HOLD1WATER
3947* LA_HOLD2WATER
3948* LA_CASTING
3949* LA_DROWNING
3950* LA_CHARGING //Resets chargeclock?
3951* LA_SPINNING //Resets spinclock?
3952* LA_DIVING //Verify
3953*
3954*/ Example Use: !#!
3955
3956/************************************************************************************************************/
3957
3958int HeldItem; ZASM Instruction:
3959 LINKHELD<>
3960
3961/**
3962* Link's current action. Use the LA_ constants in std.zh to set or
3963* The item that Link is currently holding up; reading or setting this
3964* field is undefined if Link's action is not current a hold action.
3965* Use the I_ constants in std.zh to specify the item, or -1 to show
3966* no item. Setting HeldItem to values other than -1 or a valid item
3967* ID is undefined.
3968*
3969*/ Example Use: !#!
3970
3971/************************************************************************************************************/
3972
3973int LadderX; ZASM Instruction:
3974 LINKLADDERX
3975
3976/**
3977* The X position of Link's stepladder, or 0 if no ladder is onscreen.
3978* This is read-only; while setting it is not syntactically incorrect, it does nothing.
3979*
3980*/ Example Use: !#!
3981
3982/************************************************************************************************************/
3983
3984int LadderY; ZASM Instruction:
3985 LINKLADDERY
3986
3987/**
3988* The Y position of Link's stepladder, or 0 if no ladder is onscreen.
3989* This is read-only; while setting it is not syntactically incorrect, it does nothing.
3990*
3991*/ Example Use: !#!
3992
3993/************************************************************************************************************/
3994
3995
3996
3997 *** Input Functions ***
3998 * The following Input* boolean values return true if the player is pressing
3999 * the corresponding button, analog stick, or key. Writing to this variable simulates
4000 * the press or release of that referenced button, analog stick, or key.
4001 */
4002
4003 bool InputStart; ZASM: INPUTSTART
4004
4005 bool InputMap; ZASM: INPUTMAP
4006
4007 bool InputUp; ZASM: INPUTUP
4008
4009 bool InputDown; ZASM: INPUTDOWN
4010
4011 bool InputLeft; ZASM: INPUTLEFT
4012
4013 bool InputRight; ZASM: INPUTRIGHT
4014
4015 bool InputA; ZASM: INPUTA
4016
4017 bool InputB; ZASM: INPUTB
4018
4019 bool InputL; ZASM: INPUTL
4020
4021 bool InputR; ZASM: INPUTR
4022
4023 bool InputEx1 ZASM: INPUTEX1
4024
4025 bool InputEx2 ZASM: INPUTEX2
4026
4027 bool InputEx3 ZASM: INPUTEX3
4028
4029 bool InputEx4 ZASM: INPUTEX4
4030
4031 bool InputAxisUp; ZASM: INPUTAXISUP
4032
4033 bool InputAxisDown; ZASM: INPUTAXISDOWN
4034
4035 bool InputAxisLeft; ZASM: INPUTAXISLEFT
4036
4037 bool InputAxisRight; ZASM: INPUTAXISRIGHT
4038
4039
4040 *** Press Functions ***
4041 /**
4042 * The following Press* boolean values return true if the player activated
4043 * the corresponding button, analog stick, or key this frame. Writing to this
4044 * variable simulates the press or release of that referenced button, analog stick,
4045 * or keys input press state.
4046 */
4047
4048
4049 bool PressStart; ZASM: INPUTPRESSSTART
4050
4051 bool PressMap; ZASM: INPUTPRESSMAP
4052
4053 bool PressUp; ZASM: INPUTPRESSUP
4054
4055 bool PressDown; ZASM: INPUTPRESSDOWN
4056
4057 bool PressLeft; ZASM: INPUTPRESSLEFT
4058
4059 bool PressRight; ZASM: INPUTPRESSRIGHT
4060
4061 bool PressA; ZASM: INPUTPRESSA
4062
4063 bool PressB; ZASM: INPUTPRESSB
4064
4065 bool PressL; ZASM: INPUTPRESSL
4066
4067 bool PressR; ZASM: INPUTPRESSR
4068
4069 bool PressEx1 ZASM: INPUTPRESSEX1
4070
4071 bool PressEx2 ZASM: INPUTPRESSEX2
4072
4073 bool PressEx3 ZASM: INPUTPRESSEX3
4074
4075 bool PressEx4 ZASM: INPUTPRESSEX4
4076
4077 bool PressAxisUp; ZASM: PRESSAXISUP
4078
4079 bool PressAxisDown; ZASM: PRESSAXISDOWN
4080
4081 bool PressAxisLeft; ZASM: PRESSAXISLEFT
4082
4083 bool PressAxisRight; ZASM: PRESSAXISRIGHT
4084
4085/************************************************************************************************************/
4086
4087int InputMouseX; ZASM Instruction:
4088 INPUTMOUSEX
4089
4090/**
4091* The mouse's in-game X position. This value is undefined if
4092* the mouse pointer is outside the Zelda Classic window.
4093*
4094*/ Example Use: !#!
4095
4096/************************************************************************************************************/
4097
4098int InputMouseY; ZASM Instruction:
4099 INPUTMOUSEY
4100
4101/**
4102* The mouse's in-game Y position. This value is undefined if
4103* the mouse pointer is outside the Zelda Classic window.
4104*
4105*/ Example Use: !#!
4106
4107/************************************************************************************************************/
4108
4109int InputMouseB; ZASM Instruction:
4110 INPUTMOUSEB
4111
4112/**
4113* Whether the left or right mouse buttons are pressed, as two flags OR'd (|) together;
4114* use the MB_ constants or the Input'X'Click functions in std.zh to check the button states.
4115* InputMouseB is read only; while setting it is not syntactically incorrect, it does nothing
4116* If you are not comfortable with binary, you can use the InputMouse'x' functions in std.zh
4117*
4118*/ Example Use: !#!
4119
4120/************************************************************************************************************/
4121
4122int InputMouseZ; ZASM Instruction:
4123 INPUTMOUSEB
4124
4125/**
4126* The current state of the mouse's scroll wheel, negative for scrolling down and positive for scrolling up.
4127*
4128*/ Example Use: !#!
4129
4130/************************************************************************************************************/
4131
4132bool Item[256]; ZASM Instruction:
4133 LINKITEMD
4134
4135/**
4136* True if Link's inventory contains the item whose ID is the index of
4137* the array access. Use the I_ constants in std.zh as an index into this array.
4138*
4139*/ Example Use: !#!
4140
4141/************************************************************************************************************/
4142
4143int Equipment; ZASM Instruction:
4144 LINKEQUIP
4145
4146/**
4147* Contains the item IDs of what is currently equiped to Link's A and B buttons.
4148* The first 8 bits contain the A button item, and the second 8 bits contain the B button item.
4149* If you are not comfortable with performing binary operations,
4150* you can use the functions GetEquipmentA() or GetEquipmentB() in std.zh.
4151*
4152*/ Example Use: !#!
4153
4154/************************************************************************************************************/
4155
4156int ItemA; ZASM Instruction:
4157 LINKITEMA
4158
4159/**
4160* Contains the item IDs of what is currently equiped to Link's A button.
4161* Writing to this variable will set an item to the A-button.
4162* This will occur even if the item is not in inventory, and not on the subscreen.
4163* This will ignore if you have B+A or B-only subscreens, and force-set the item.
4164* The intent of this is to allow scriters to easily create scripted subscreens.
4165*
4166*/ Example Use: !#!
4167
4168/************************************************************************************************************/
4169
4170int ItemB; ZASM Instruction:
4171 LINKITEMB
4172
4173/**
4174* Contains the item IDs of what is currently equiped to Link's B button.
4175* Writing to this variable will set an item to the A-button.
4176* This will occur even if the item is not in inventory, and not on the subscreen.
4177* The intent of this is to allow scriters to easily create scripted subscreens.
4178*
4179*/ Example Use: !#!
4180
4181/************************************************************************************************************/
4182//! Untested
4183int SetItemSlot(int itm_id, bool a_button, bool force);
4184 ZASM Instruction:
4185 SETITEMSLOT
4186
4187/**
4188* This allows you to set Link's button items without binary operations, and to decide whether to
4189* obey quest rules, or inventory.
4190*
4191* When using this, 'itm_id' is the ID number of the item.
4192* Set 'slot' to 0 for Slot B, or 1 for Slot A. We may later expand this to cover more buttons.
4193* Set' force' to 0 to ignore inventory and item slot rules.
4194* Otherwise this is a flagset, where '0' is NONE, 1 is REQUIRE_INVENTORY, and 2 is REQUIRE_RULE for Slot
4195* Combine these as desired. If 'REQUIRE_RULE' is enabled, then non-sword items will only be
4196* assigned to the A-button if the quest rule for B+A subscreens is enabled.
4197* If REQUIRE_INVENTORY is set, then an item will not be assigned unless it is set true in Link->Item[]
4198*
4199*/ Example Use: !#!
4200
4201/************************************************************************************************************/
4202
4203
4204int Tile; ZASM Instruction:
4205 LINKTILE
4206
4207/**
4208* The current tile associated with Link. The effect of writing to this variable is undefined.
4209* Because Link's tile is not determined until he is drawn, this will actually represent
4210* Link's tile in the previous frame.
4211*
4212*/ Example Use: !#!
4213
4214/************************************************************************************************************/
4215
4216int Flip; ZASM Instruction:
4217 LINKFLIP
4218
4219/**
4220* The flip value of current tile associated with Link.
4221* The effect of writing to this variable is undefined (will do nothing).
4222* Because Link's tile is not determined until he is drawn, this will actually represent
4223* Link's tile flip in the previous frame.
4224*
4225*/ Example Use: !#!
4226
4227
4228/************************************************************************************************************/
4229
4230int Eaten; ZASM Instruction:
4231 LINKEATEN
4232
4233/**
4234* This stores a counter for how long Link has been inside a LikeLike, or similar enemy.
4235* It returns 0 if Link is not eaten, otherwise it returns the duration of him being eaten.
4236*
4237*/ Example Use: !#!
4238
4239/************************************************************************************************************/
4240
4241int Extend; ZASM Instruction:
4242 LINKEXTEND
4243
4244/**
4245* Sets the extend value for all of Link's various actions for his current sprite, and direction.
4246* This is equivalent to the Extend value set in Quest->Graphics->Sprites->Link when selecting
4247* a tile, click on his sprites for any given action, and press the 'x' key.
4248* The options are 16x16, 16x32, and 32x32; which correspond to Extend values of ( 0, 1, and 2 )
4249* respectively.
4250*
4251* This also returns the present extend value of Link's sprite for his current direction and sprite.
4252*
4253* You may force-set all sprites, and directions to an extend value by assigning a negative number to
4254* this variable, where -1 == 0 -2 == 1, -3 == 2, -4 == 3, and -5 == 4.
4255*
4256* See the 'LINKEXTEND_* values in std_constants for more details.
4257*/
4258
4259/************************************************************************************************************/
4260
4261int GetLinkExtend(int sprite, int dir); ZASM Instruction:
4262 SETLINKEXTEND
4263
4264/**
4265* Gets the extend value for one of Link's various actions based on a direction.
4266* This is equivalent to the Extend value set in Quest->Graphics->Sprites->Link when selecting a tile.
4267* See 'std_constants' entries under LSPR_* for a list of the various attributes for 'sprite'.
4268*/
4269
4270/************************************************************************************************************/
4271
4272void SetLinkExtend(int sprite, int dir, int extend);
4273 ZASM Instruction:
4274 SETLINKEXTEND
4275
4276/**
4277* Sets the extend value for one of Link's various actions.
4278* This is equivalent to the Extend value set in Quest->Graphics->Sprites->Link when selecting a tile.
4279* 'sprite' is the 'action', 'dir' is the sprite direction, and 'extend' is a value between 1 and 3.
4280* An extend value of '4' is reserved for future implementations of Link->Hit/DrawOffsets ad HitWidth/height.
4281* See 'std_constants' entries under LSPR_* for a list of the various attributes for 'sprite'.
4282*
4283* See the 'LINKEXTEND_* values in std_constants for more details on possible extend values.
4284*/
4285
4286
4287/************************************************************************************************************/
4288//Untested
4289void SetLinkTile(int sprite, int tile, int dir)
4290 ZASM Instruction:
4291 SETLINKTILE
4292
4293/**
4294* Sets the tile for Link's various actions. This is intended to work as OTile for Link.
4295* 'sprite' is the action for the tile. See Quest->Graphics->Sprites->Link for a visual reference.
4296* 'tile is the base tile for the sequence. It uses the animation style set in the sprites editor.
4297* 'dir' is the direction for the tile.
4298* See 'std_constants' entries under LSPR_* for a list of the various attributes for 'sprite'.
4299*
4300* See the 'LINKEXTEND_* values in std_constants for more details on possible extend values.
4301*/
4302
4303/************************************************************************************************************/
4304//!Untested
4305int GetLinkTile(int sprite, int dir)
4306 ZASM Instruction:
4307 LINKGETTILE
4308
4309/**
4310* Returns the OTile for one of Link's various actions.
4311* 'sprite' is the action for the tile. See Quest->Graphics->Sprites->Link for a visual reference.
4312* 'dir' is the direction for the tile.
4313* See 'std_constants' entries under LSPR_* for a list of the various attributes for 'sprite'.
4314*/
4315
4316/************************************************************************************************************/
4317
4318int WalkTile, SwimTile, DiveTile, SlashTile, JumpTile, ChargeTile, StabTile, CastingTile, PoundTile, FloatTile
4319 Hold1LandTile, Hold2LandTile, Hold1WaterTile, Hold2WaterTile;
4320
4321 ZASM Instructions:
4322 LINKWALKTILE, LINKSWIMTILE, LINKDIVETILE, LINKSLASHTILE, LINKJUMPTILE
4323 LINKCHARGETILE, LINKSTABTILE, LINKCASTTILE, LINKPOUNDTILE, LINKFLOATTILE,
4324 LINKHOLD1LTILE, LINKHOLD2LTILE, LINKHOLD1WTILE, LINKHOLD2WTILE
4325
4326/**
4327* A series of fourteen individual setter/getter ints to set or return the tile for all of Link's various actions.
4328*
4329* In future, setting this values of 0 through 4 will set Link->Extend based on Link's present drection and
4330* sprite and values of -1 through -5 will force Extend = 0 through Extend = 4 for all sprites and directions.
4331*
4332* Checking this will return the tile value for the desired sprite using Link's current direction.
4333* Setting this will set the tile for the sprite in Link's current direction.
4334*
4335* These exist to manually test getting, and setting values to these sprites, and are scheduled to be removed
4336* in a future build, supplanted by Link->SetLinkTile(int sprite, int dir, int tile)
4337*/
4338
4339/************************************************************************************************************/
4340
4341int HitHeight; ZASM Instruction:
4342 LINKHYSZ
4343
4344/**
4345* link's Hitbox height in pixels.
4346* This is not usable, as Link->Extend cannot be set.
4347* While setting it is not syntactically incorrect, it does nothing.
4348* You can read a value that you assign to this (e.g. for custom collision functions).
4349* This value is not preserved through sessions: Loading a saved game will reset it to the default.
4350*
4351*/ Example Use: !#!
4352
4353/************************************************************************************************************/
4354
4355int HitWidth; ZASM Instruction:
4356 LINKHXSZ
4357
4358/**
4359* link's Hitbox width in pixels.
4360* This is not usable, as Link->Extend cannot be set.
4361* While setting it is not syntactically incorrect, it does nothing.
4362* You can read a value that you assign to this (e.g. for custom collision functions).
4363* This value is not preserved through sessions: Loading a saved game will reset it to the default.
4364*
4365*/ Example Use: !#!
4366
4367/************************************************************************************************************/
4368
4369int TileWidth; ZASM Instruction:
4370 LINKTYSZ
4371/**
4372* Link's width, in tiles.
4373* This is not usable, as Link->Extend cannot be set.
4374* While setting it is not syntactically incorrect, it does nothing.
4375* You can read a value that you assign to this (e.g. for custom/proxy sprite drawing).
4376* This value is not preserved through sessions: Loading a saved game will reset it to the default.
4377*
4378*/ Example Use: !#!
4379
4380/************************************************************************************************************/
4381
4382int TileHeight; ZASM Instruction:
4383 LINKTXSZ
4384
4385/**
4386* Link's height, in tiles.
4387* This is not usable, as Link->Extend cannot be set.
4388* While setting it is not syntactically incorrect, it does nothing.
4389* You can read a value that you assign to this (e.g. for custom/proxy sprite drawing).
4390* This value is not preserved through sessions: Loading a saved game will reset it to the default.
4391*
4392*/ Example Use: !#!
4393
4394/************************************************************************************************************/
4395
4396int HitZHeight; ZASM Instruction:
4397 LINKHZSZ
4398
4399/**
4400* The Z-axis height of Link's hitbox, or collision rectangle.
4401* The lower it is, the lower a flying or jumping enemy must fly in order to hit Link.
4402* To jump over a sprite, you must be higher than its Z + HitZHeight.
4403* The values of DrawZOffset and HitZHeight are linked. Setting one, also sets the other.
4404* Writing to this is ignored unless Extend is set to values >=3.
4405* This is not usable, as Link->Extend cannot be set.
4406* While setting it is not syntactically incorrect, it does nothing.
4407* You can read a value that you assign to this (e.g. for custom collision functions).
4408* This value is not preserved through sessions: Loading a saved game will reset it to the default.
4409*
4410*/ Example Use: !#!
4411
4412/************************************************************************************************************/
4413
4414int HitXOffset; ZASM Instruction:
4415 LINKHXOFS
4416
4417/**
4418* The X offset of Link's hitbox, or collision rectangle.
4419* Setting it to positive or negative values will move Link's hitbox left or right.
4420* Writing to this is ignored unless Extend is set to values >=3.
4421* This is not usable, as Link->Extend cannot be set.
4422* While setting it is not syntactically incorrect, it does nothing.
4423* You can read a value that you assign to this (e.g. for custom collision functions).
4424* This value is not preserved through sessions: Loading a saved game will reset it to the default.
4425*
4426*/ Example Use: !#!
4427
4428/************************************************************************************************************/
4429
4430int HitYOffset; ZASM Instruction:
4431 LINKHYOFS
4432
4433/**
4434* The Y offset of Link's hitbox, or collision rectangle.
4435* Setting it to positive or negative values will move Link's hitbox up or down.
4436* Writing to this is ignored unless Extend is set to values >=3.
4437* This is not usable, as Link->Extend cannot be set.
4438* While setting it is not syntactically incorrect, it does nothing.
4439* You can read a value that you assign to this (e.g. for custom collision functions).
4440* This value is not preserved through sessions: Loading a saved game will reset it to the default.
4441*
4442*/ Example Use: !#!
4443
4444/************************************************************************************************************/
4445
4446int DrawXOffset; ZASM Instruction:
4447 LINKXOFS
4448
4449/**
4450* The X offset of Link's sprite.
4451* Setting it to positive or negative values will move the sprite's tiles left or right relative to its position.
4452* Writing to this is ignored unless Extend is set to values >=3.
4453* This is not usable, as Link->Extend cannot be set.
4454* While setting it is not syntactically incorrect, it does nothing.
4455* You can read a value that you assign to this.
4456* This value is not preserved through sessions: Loading a saved game will reset it to the default.
4457*
4458*/ Example Use: !#!
4459
4460/************************************************************************************************************/
4461
4462int DrawYOffset; ZASM Instruction:
4463 LINKYOFS
4464
4465/**
4466* The Y offset of Link's sprite.
4467* Setting it to positive or negative values will move the sprite's tiles up or down relative to its position.
4468* Writing to this is ignored unless Extend is set to values >=3.
4469* This is not usable, as Link->Extend cannot be set.
4470* While setting it is not syntactically incorrect, it does nothing.
4471* You can read a value that you assign to this.
4472* This value is not preserved through sessions: Loading a saved game will reset it to the default.
4473*
4474*/ Example Use: !#!
4475
4476/************************************************************************************************************/
4477
4478int DrawZOffset; ZASM Instruction:
4479 LINKZOFS
4480
4481/**
4482* The Z offset of Link's sprite.
4483* Writing to this is ignored unless Extend is set to values >=3.
4484* The values of DrawZOffset and HitZHeight are linked. Setting one, also sets the other.
4485* This is not usable, as Link->Extend cannot be set.
4486* While setting it is not syntactically incorrect, it does nothing.
4487* You can read a value that you assign to this.
4488* This value is not preserved through sessions: Loading a saved game will reset it to the default.
4489*
4490*/ Example Use: !#!
4491
4492/************************************************************************************************************/
4493
4494float Misc[32]; ZASM Instruction:
4495 LINKMISC
4496 LINKMISCD
4497
4498/**
4499* An array of 32 miscellaneous variables for you to use as you please.
4500* These variables are not saved with Link.
4501*
4502*/ Example Use: !#!
4503
4504/************************************************************************************************************/
4505
4506void Warp(int DMap, int screen); ZASM Instruction:
4507 WARP
4508 WARPR
4509
4510/**
4511* Warps link to the given screen in the given DMap, just like if he'd
4512* triggered an 'Insta-Warp'-type warp.
4513*
4514*/ Example Use: !#!
4515
4516/************************************************************************************************************/
4517
4518void PitWarp(int DMap, int screen); ZASM Instruction:
4519 PITWARP
4520 PITWARPR
4521
4522/**
4523* This is identical to Warp, but Link's X and Y positions are preserved
4524* when he enters the destination screen, rather than being set to the
4525* Warp Return square.
4526*
4527*/ Example Use: !#!
4528
4529/************************************************************************************************************/
4530
4531SelectAWeapon(int dir); ZASM Instruction:
4532 !#!
4533
4534/**
4535* Sets the A button item to the next one in the given direction based on
4536* the indices set in the subscreen. This will skip over items if A and B
4537* would be set to the same item.
4538* If the quest rule "Can Select A-Button Weapon On Subscreen" is disabled,
4539* this function does nothing.
4540*
4541*/ Example Use: !#!
4542
4543/************************************************************************************************************/
4544
4545SelectBWeapon(int dir); ZASM Instruction:
4546 !#!
4547
4548/**
4549* Sets the B button item to the next one in the given direction based on
4550* the indices set in the subscreen. This will skip over items if A and B
4551* would be set to the same item.
4552*
4553*/ Example Use: !#!
4554
4555
4556/************************************************************************************************************/
4557/************************************************************************************************************/
4558
4559
4560//===================================
4561//--- NPC Functions and Variables ---
4562//===================================
4563
4564 class npc
4565
4566
4567 float UID; ZASM Instruction:
4568 NPCUID
4569 /**
4570 * Returns the UID of an npc.
4571 */ Example Use:
4572
4573/************************************************************************************************************/
4574
4575 int GetPointer(npc *ptr[]); ZASM Instruction:
4576 NPCARRPTR
4577 /**
4578 * Returns the pointer of a item array as a float.
4579 */ Example Use:
4580 item arr[16];
4581 int size = SizeOfArray( GetPointer(arr) );
4582 //Size == 16
4583
4584/************************************************************************************************************/
4585
4586 npc SetPointer(int value); ZASM Instruction:
4587 NPCARRPTR2
4588 /**
4589 * Converts an int pointer to the npc type, for assigning.
4590 */ Example Use:
4591 npc arr[16]; npc arrB[2]; int arrC[2];
4592 arrC[0] = GetPointer(arr);
4593 arrB[0] = SetPointer(arrC[0]);
4594
4595/************************************************************************************************************/
4596
4597 bool isValid(); ZASM Instruction:
4598 ISVALIDNPC
4599 /**
4600 * Returns whether or not this NPC pointer is still valid. A pointer
4601 * becomes invalid if the enemy dies or Link leaves the screen.
4602 * Trying to access any variable of an invalid NPC pointer prints
4603 * an error to allegro.log and does nothing.
4604 */
4605
4606/************************************************************************************************************/
4607
4608 void GetName(int buffer[]); ZASM Instruction:
4609 NPCNAME
4610 /**
4611 * Loads the npc's name into 'buffer'. To load an NPC from an ID rather than a pointer,
4612 * use 'GetNPCName' from std.zh
4613 */
4614
4615/************************************************************************************************************/
4616
4617 int ID; ZASM Instruction:
4618 NPCID
4619 /**
4620 * The NPC's enemy ID number.
4621 * npc->ID is read-only; while setting it is not syntactically incorrect, it does nothing.
4622 */
4623
4624/************************************************************************************************************/
4625
4626 int Type; ZASM Instruction:
4627 NPCTYPE
4628 /**
4629 * The NPC's Type. Use the NPCT_ constants in std.zh to compare this value.
4630 * npc->Type is read-only; while setting it is not syntactically incorrect, it does nothing.
4631 */
4632
4633/************************************************************************************************************/
4634
4635 int X; ZASM Instruction:
4636 NPCX
4637 /**
4638 * The NPC's current X coordinate, in pixels. Float values passed to this will be cast to int.
4639 */
4640
4641/************************************************************************************************************/
4642
4643 int Y; ZASM Instruction:
4644 NPCY
4645 /**
4646 * The NPC's current Y coordinate, in pixels. Float values passed to this will be cast to int.
4647 */
4648
4649/************************************************************************************************************/
4650
4651 int Z; ZASM Instruction:
4652 NPCZ
4653 /**
4654 * The NPC's current Z coordinate, in pixels. Float values passed to this will be cast to int.
4655 */
4656
4657/************************************************************************************************************/
4658
4659 int Jump; ZASM Instruction:
4660 NPCJUMP
4661 /**
4662 * The NPC's upward velocity, in pixels. If negative, the NPC will fall.
4663 * The downward acceleration of Gravity (in Init Data) modifies this value every frame.
4664 */
4665
4666/************************************************************************************************************/
4667
4668 int Dir; ZASM Instruction:
4669 NPCDIR
4670 /**
4671 * The direction the NPC is facing. Use the DIR_ constants in std.zh to
4672 * set and compare this value.
4673 */
4674
4675/************************************************************************************************************/
4676
4677 int Rate; ZASM Instruction:
4678 NPCRATE
4679 /**
4680 * The rate at which the NPC changes direction. For a point of reference,
4681 * the "Octorok (Magic)" enemy has a rate of 16. The effect of writing to
4682 * this field is currently undefined.
4683 */
4684
4685/************************************************************************************************************/
4686
4687 int Haltrate; ZASM Instruction:
4688 NPCHALTRATE
4689 /**
4690 * The extent to which the NPC stands still while moving around the
4691 * screen. As a point of reference, the Zols and Gels have haltrate of
4692 * 16. The effect of writing to this field is currently undefined.
4693 */
4694
4695/************************************************************************************************************/
4696
4697 int Homing; ZASM Instruction:
4698 NPCHOMING
4699 /**
4700 * How likely the NPC is to move towards Link.
4701 * The effect of writing to this field is currently undefined.
4702 */
4703
4704/************************************************************************************************************/
4705
4706 int Hunger; ZASM Instruction:
4707 NPRCHUNGE
4708 /**
4709 * How likely the NPC is to move towards bait.
4710 * The effect of writing to this field is currently undefined.
4711 */
4712
4713/************************************************************************************************************/
4714
4715 int Step; ZASM Instruction:
4716 NPCSTEP
4717 /**
4718 * The NPC's movement speed. A Step of 100 usually means that
4719 * the enemy moves at approximately one pixel per animation frame.
4720 * As a point of reference, the "Octorok (Magic)" enemy has
4721 * a step of 200. The effect of writing to this field is
4722 * currently undefined.
4723 */
4724
4725/************************************************************************************************************/
4726
4727 bool CollDetection; ZASM Instruction:
4728 NPCCOLLDET
4729 /**
4730 * Whether the NPC will use the system's code to work out collisions with Link
4731 * Initialised as 'true'.
4732 */
4733
4734/************************************************************************************************************/
4735
4736 int ASpeed; ZASM Instruction:
4737 NPCFRAMERATE
4738 /**
4739 * The the NPC's animation frame rate, in screen frames. The effect of
4740 * writing to this field is currently undefined.
4741 */
4742
4743/************************************************************************************************************/
4744
4745 int DrawStyle; ZASM Instruction:
4746 NPCDRAWTYPE
4747 /**
4748 * The way the NPC is animated. Use the DS_ constants in std.zh to set or
4749 * compare this value. The effect of writing to this field is currently undefined.
4750 */
4751
4752/************************************************************************************************************/
4753
4754 int HP; ZASM Instruction:
4755 NPCHP
4756 /**
4757 * The NPC's current hitpoints. A weapon with a Power of 1 removes 2
4758 * hitpoints.
4759 */
4760
4761/************************************************************************************************************/
4762
4763 int Damage; ZASM Instruction:
4764 NPCDP
4765 /**
4766 * The amount of damage dealt to an unprotected Link when he touches this NPC, in
4767 * quarter-hearts.
4768 */
4769
4770/************************************************************************************************************/
4771
4772 int WeaponDamage; ZASM Instruction:
4773 NPCWDP
4774 /**
4775 * The amount of damage dealt to an unprotected Link by this NPC's weapon, in
4776 * quarter-hearts.
4777 */
4778
4779/************************************************************************************************************/
4780
4781 int Stun; ZASM Instruction:
4782 NPCSTUN
4783 /**
4784 * The time, in frames, that the NPC will be stunned. Some types of enemies cannot be stunned.
4785 */
4786
4787/************************************************************************************************************/
4788
4789 int OriginalTile; ZASM Instruction:
4790 NPCOTILE
4791 /**
4792 * The number of the starting tile used by this NPC.
4793 */
4794
4795/************************************************************************************************************/
4796
4797 int Tile; ZASM Instruction:
4798 NPCTILE
4799 /**
4800 * The current tile associated with this NPC. The effect of writing to this variable is undefined.
4801 */
4802
4803/************************************************************************************************************/
4804
4805 int Weapon; ZASM Instruction:
4806 NPCWEAPON
4807 /**
4808 * The weapon used by this enemy. Use the WPN_ constants (NOT the EW_ constants)
4809 * in std.zh to set or compare this value.
4810 */
4811
4812/************************************************************************************************************/
4813
4814 int ItemSet; ZASM Instruction:
4815 NPCITEMSET
4816 /**
4817 * The items that the NPC might drop when killed. Use the IS_ constants
4818 * in std.zh to set or compare this value.
4819 */
4820
4821/************************************************************************************************************/
4822
4823 int CSet; ZASM Instruction:
4824 NPCCSET
4825 /**
4826 * The CSet used by this NPC.
4827 */
4828
4829/************************************************************************************************************/
4830
4831 int BossPal; ZASM Instruction:
4832 NPCBOSSPAL
4833 /**
4834 * The boss pallete used by this NPC; this pallete is only used if CSet
4835 * is 14 (the reserved boss cset). Use the BPAL_ constants in std.zh to
4836 * set or compare this value.
4837 */
4838
4839/************************************************************************************************************/
4840
4841 int SFX; ZASM Instruction:
4842 NPCBGSFX
4843 /**
4844 * The sound effects emitted by the enemy. Use the SFX_ constants in
4845 * std.zh to set or compare this value.
4846 */
4847
4848/************************************************************************************************************/
4849
4850 int Extend; ZASM Instruction:
4851 NPCEXTEND
4852 /**
4853 * Whether to extend the sprite of the enemy.
4854 */
4855
4856/************************************************************************************************************/
4857
4858 int TileWidth; ZASM Instruction:
4859 NPCTXSZ
4860 /**
4861 * The number of tile columns composing the sprite.
4862 * Writing to this is ignored unless Extend is set to values >=3.
4863 */
4864
4865/************************************************************************************************************/
4866
4867 int TileHeight; ZASM Instruction:
4868 NPCTYSZ
4869 /**
4870 * The number of tile rows composing the sprite.
4871 * Writing to this is ignored unless Extend is set to values >=3.
4872 */
4873
4874/************************************************************************************************************/
4875
4876 int HitWidth; ZASM Instruction:
4877 NPCHXSZ
4878 /**
4879 * The width of the sprite's hitbox, or collision rectangle.
4880 */
4881
4882/************************************************************************************************************/
4883
4884 int HitHeight; ZASM Instruction:
4885 NPCHYSZ
4886 /**
4887 * The height of the sprite's hitbox, or collision rectangle.
4888 */
4889
4890/************************************************************************************************************/
4891
4892 int HitZHeight; ZASM Instruction:
4893 NPCHZSZ
4894 /**
4895 * The Z-axis height of the sprite's hitbox, or collision rectangle.
4896 * The greater it is, the higher Link must jump or fly over the sprite to avoid taking damage.
4897 * To jump over a sprite, you must be higher than its Z + HitZHeight.
4898 * The values of DrawZOffset and HitZHeight are linked. Setting one, also sets the other.
4899 */
4900
4901/************************************************************************************************************/
4902
4903 int HitXOffset; ZASM Instruction:
4904 NPCHXOFS
4905 /**
4906 * The X offset of the sprite's hitbox, or collision rectangle.
4907 * Setting it to positive or negative values will move the sprite's hitbox left or right.
4908 */
4909
4910/************************************************************************************************************/
4911
4912 int HitYOffset; ZASM Instruction:
4913 NPCHYOFS
4914 /**
4915 * The Y offset of the sprite's hitbox, or collision rectangle.
4916 * Setting it to positive or negative values will move the sprite's hitbox up or down.
4917 */
4918
4919/************************************************************************************************************/
4920
4921 int DrawXOffset; ZASM Instruction:
4922 NPCXOFS
4923 /**
4924 * The X offset of the sprite.
4925 * Setting it to positive or negative values will move the sprite's tiles left or right relative to its position.
4926 */
4927
4928/************************************************************************************************************/
4929
4930 int DrawYOffset; ZASM Instruction:
4931 NPCYOFS
4932 /**
4933 * The Y offset of the sprite. In non-sideview screens, this is usually -2.
4934 * Setting it to positive or negative values will move the sprite's tiles up or down relative to its position.
4935 */
4936
4937/************************************************************************************************************/
4938
4939 int DrawZOffset; ZASM Instruction:
4940 NPCZOFS
4941 /**
4942 * The Z offset of the sprite. This is ignored unless Extend is set to values >=3.
4943 * The values of DrawZOffset and HitZHeight are linked. Setting one, also sets the other.
4944 */
4945
4946/************************************************************************************************************/
4947
4948 int InvFrames; ZASM Instruction:
4949 NPCINVINC
4950 /**
4951 * Returns if the enemy is temporarily invincible, from being hit, or otherwise.
4952 * Returns the number of remaining invincibility frames if the enemy is invincible, otherwise 0.
4953 *
4954 */ Example Use: !#!
4955
4956/************************************************************************************************************/
4957
4958 int Invincible; ZASM Instruction:
4959 NPCSUPERMAN
4960 /**
4961 * Returns if the enemy is invincible, because of ( superman variable ).
4962 *
4963 */ Example Use: !#!
4964
4965/************************************************************************************************************/
4966
4967 bool HasItem; ZASM Instruction:
4968 NPCHASITEM
4969 /**
4970 * Returns if the enemy is holding the screen item.
4971 *
4972 */ Example Use: !#!
4973
4974/************************************************************************************************************/
4975
4976 bool Ringleader; ZASM Instruction:
4977 NPCRINGLEAD
4978 /**
4979 * Returns if the enemy is a 'ringleader'.
4980 *
4981 */ Example Use: !#!
4982
4983/************************************************************************************************************/
4984
4985 int Defense[]; ZASM Instruction:
4986 NPCDEFENSED
4987 /**
4988 * The npc's Defense values, as an array of 18 integers. Use the NPCD_ and NPCDT_ constants
4989 * in std.zh to set or compare these values.
4990 */
4991
4992/************************************************************************************************************/
4993
4994 int ScriptDefense[]; ZASM Instruction:
4995 NPCSCRDEFENSED
4996 /**
4997 * The npc's Script Weapon Defense values, as an array of 10 integers. Use the NPCSD_ and NPCDT_ constants
4998 * in std.zh to set or compare these values.
4999 *
5000 * This corresponds to the 'Defenses 3' tab in the Enemy Editor.
5001 */
5002
5003/************************************************************************************************************/
5004
5005 int Attributes[]; ZASM Instruction:
5006 NPCDD
5007 /**
5008 * The npc's Miscellaneous Attributes, as an array of ten integers.
5009 * They are read-only; while setting them is not syntactically incorrect, it does nothing.
5010 */
5011
5012/************************************************************************************************************/
5013
5014 int MiscFlags; ZASM Instruction:
5015 NPCMFLAGS
5016 /**
5017 * The npc's Misc. Flags as 14 bits ORed together, starting with 'Damaged by Power 0 Weapons',
5018 * and working down the flags in the order they are shown in the Enemy Editor.
5019 * npc->MiscFlags is read-only; while setting it is not syntactically incorrect, it does nothing.
5020 * If you are not comfortable with binary operations, you can use 'GetNPCMiscFlag' from std.zh
5021 */
5022
5023/************************************************************************************************************/
5024
5025 float Misc[32]; ZASM Instruction:
5026 NPCMISCD
5027 /**
5028 * An array of 32 miscellaneous variables for you to use as you please.
5029 */
5030
5031/************************************************************************************************************/
5032
5033 void BreakShield(); ZASM Instruction:
5034 BREAKSHIELD
5035 /**
5036 * Breaks the enemy's shield if it has one. This works even if the flag
5037 * "Hammer Can Break Shield" is not checked.
5038 */
5039
5040
5041/************************************************************************************************************/
5042/************************************************************************************************************/
5043
5044
5045
5046
5047//======================================
5048//--- Weapon Functions and Variables ---
5049//======================================
5050
5051 class weapon
5052
5053
5054 //! ZScript supports two different weapon classes:
5055 //! The lweapon class is used for Link's weapons (that damage enemies, and trigger objects)
5056 //! while the eweapon class is used for enemy weapons, that can damage Link.
5057 //!
5058 //! Both the lweapon, and the eweapon class have all of the following atributes:
5059
5060 bool isValid(); ZASM Instruction:
5061 ISVALIDLWPN
5062 ISVALIDEWPN
5063
5064 /**
5065 * Returns whether this weapon pointer is still valid. A weapon pointer
5066 * becomes invalid when the weapon fades away or disappears
5067 * or Link leaves the screen. Accessing any variables using an
5068 * invalid weapon pointer prints an error message to allegro.log and
5069 * does nothing.
5070 */ Example Use: !#!
5071
5072/************************************************************************************************************/
5073
5074 float UID; ZASM Instruction:
5075 LWPNUID
5076 EWPNUID
5077 /**
5078 * Returns the UID of an *weapon.
5079 */ Example Use:
5080
5081/************************************************************************************************************/
5082
5083 int GetPointer(eweapon *ptr[]);
5084 int GetPointer(lweapon *ptr[]);
5085 ZASM Instruction:
5086 LWPNARRPTR
5087 EWPNARRPTR
5088 /**
5089 * Returns the pointer of a *weapon array as a float.
5090 */ Example Use:
5091 eweapon arr[16];
5092 int size = SizeOfArray( GetPointer(arr) );
5093 //Size == 16
5094
5095/************************************************************************************************************/
5096
5097 lweapon SetPointer(int value);
5098 eweapon SetPointer(int value); ZASM Instruction:
5099 LWPNARRPTR2
5100 EWPNARRPTR2
5101 /**
5102 * Converts an int pointer to the *weapon type, for assigning.
5103 */ Example Use:
5104 eweapon arr[16]; eweapon arrB[2]; int arrC[2];
5105 arrC[0] = GetPointer(arr);
5106 arrB[0] = SetPointer(arrC[0]);
5107
5108/************************************************************************************************************/
5109
5110 void UseSprite(int id); ZASM Instruction:
5111 LWPNUSESPRITER, LWPNUSESPRITEV
5112 EWPNUSESPRITER, EWPNUSESPRITEV
5113
5114 /**
5115 * Reads a 'Weapons/Misc' sprite entry in your quest file, and assigns
5116 * the OriginalTile, Tile, OriginalCSet, CSet, FlashCSet, NumFrames,
5117 * Frame, ASpeed, Flip and Flash variables of this weapon based on
5118 * this entry's data. Passing negative values, and values greater than
5119 * 255, will do nothing.
5120 */ Example Use: !#!
5121
5122/************************************************************************************************************/
5123
5124 bool Behind; ZASM Instruction:
5125 LWPNBEHIND
5126 EWPNBEHIND
5127
5128 /**
5129 * Ensures that the weapon's graphic is drawn behind Link and enemies.
5130 */ Example Use: !#!
5131
5132/************************************************************************************************************/
5133
5134 int ID; ZASM Instruction:
5135 LWPNID
5136 EWPNID
5137
5138 /**
5139 * The weapon's ID number. Use the LW_ or EW_ constants to compare
5140 * this value. The effect of writing to this field is currently undefined.
5141 */ Example Use: !#!
5142
5143/************************************************************************************************************/
5144
5145 int X; ZASM Instruction:
5146 LWPNX
5147 EWPNX
5148
5149 /**
5150 * The weapon's X position on the screen, in pixels. Float values passed
5151 * to this will be cast to int.
5152 */ Example Use: !#!
5153
5154/************************************************************************************************************/
5155
5156 int Y; ZASM Instruction:
5157 LWPNY
5158 EWPNY
5159
5160 /**
5161 * The weapon's Y position on the screen, in pixels. Float values passed
5162 * to this will be cast to int.
5163 */ Example Use: !#!
5164
5165/************************************************************************************************************/
5166
5167 int Z; ZASM Instruction:
5168 LWPNZ
5169 EWPNZ
5170
5171 /**
5172 * The weapon's Z position on the screen, in pixels. Float values passed
5173 * to this will be cast to int.
5174 */ Example Use: !#!
5175
5176/************************************************************************************************************/
5177
5178 int Jump; ZASM Instruction:
5179 LWPNJUMP
5180 EWPNJUMP
5181
5182 /**
5183 * The weapon's falling speed on the screen. Bombs, Bait and
5184 * Fire obey gravity.
5185 */ Example Use: !#!
5186
5187/************************************************************************************************************/
5188
5189 int DrawStyle; ZASM Instruction:
5190 LWPNDRAWTYPE
5191 EWPNDRAWTYPE
5192
5193 /**
5194 * An integer representing how the weapon is to be drawn. Use one of the
5195 * DS_ constants in std.zh to set or compare this value.
5196 */ Example Use: !#!
5197
5198/************************************************************************************************************/
5199
5200 int Dir; ZASM Instruction:
5201 LWPNDIR
5202 eWPNDIR
5203
5204 /**
5205 * The direction that the weapon is facing. Used by certain weapon types
5206 * to determine movement, shield deflection and such.
5207 */ Example Use: !#!
5208
5209/************************************************************************************************************/
5210
5211 int Range; ZASM Instruction:
5212 LWPNRANGE
5213
5214 /**
5215 * The range of the weapon in pixels.
5216 * The range in pixels for boomerang and hookshot lweapons; and the duration in frames for arrow lweapons.
5217 *
5218 */ Example Use: !#!
5219
5220/************************************************************************************************************/
5221
5222 int OriginalTile; ZASM Instruction:
5223 LWPNOTILE
5224 EWPNOTILE
5225
5226 /**
5227 * The starting tile of the weapon's animation.
5228 */ Example Use: !#!
5229
5230/************************************************************************************************************/
5231
5232 int Tile; ZASM Instruction:
5233 LWPNTILE
5234 EWPNTILE
5235
5236 /**
5237 * The current tile associated with this weapon.
5238 */ Example Use: !#!
5239
5240/************************************************************************************************************/
5241
5242 int OriginalCSet; ZASM Instruction:
5243 LWPNOCSET
5244 EWPNOCSET
5245
5246 /**
5247 * The starting CSet of the weapon's animation.
5248 */ Example Use: !#!
5249
5250/************************************************************************************************************/
5251
5252 int CSet; ZASM Instruction:
5253 LWPNCSET
5254 EWPNCSET
5255
5256 /**
5257 * This weapon's current CSet.
5258 */ Example Use: !#!
5259
5260/************************************************************************************************************/
5261
5262 int FlashCSet; ZASM Instruction:
5263 LWPNFLASHCSET
5264 EWPNFLASHCSET
5265
5266 /**
5267 * The CSet used during this weapon's flash frames, if this weapon flashes.
5268 */ Example Use: !#!
5269
5270/************************************************************************************************************/
5271
5272 int NumFrames; ZASM Instruction:
5273 LWPNFRAMES
5274 EWPNFRAMES
5275
5276 /**
5277 * The number of frames in this weapon's animation.
5278 */ Example Use: !#!
5279
5280/************************************************************************************************************/
5281
5282 int Frame; ZASM Instruction:
5283 LWPNFRAME
5284 EWPNFRAME
5285
5286 /**
5287 * The weapon's current animation frame.
5288 */ Example Use: !#!
5289
5290/************************************************************************************************************/
5291
5292 int ASpeed; ZASM Instruction:
5293 LWPNASPEED
5294 EWPNASPEED
5295
5296 /**
5297 * The speed at which this weapon animates, in screen frames.
5298 */ Example Use: !#!
5299
5300/************************************************************************************************************/
5301
5302 int Damage; ZASM Instruction:
5303 LWPNPOWER
5304 EWPNPOWER
5305
5306 /**
5307 * The amount of damage that this weapon causes to Link/an enemy upon contact.
5308 */ Example Use: !#!
5309
5310/************************************************************************************************************/
5311
5312 int Step; ZASM Instruction:
5313 LWPNSTEP
5314 EWPNSTEP
5315
5316 /**
5317 * Usually associated with the weapon's velocity. A Step of 100
5318 * typically means that the weapon moves at approximately one pixel
5319 * per animation frame.
5320 */ Example Use: !#!
5321
5322/************************************************************************************************************/
5323
5324 int Angle; ZASM Instruction:
5325 LWPNANGLE
5326 EWPNANGLE
5327
5328 /**
5329 * The weapon's current angle in clockwise radians; used by certain weapon
5330 * types with angular movement. 0 = right, PI/2 = down, etc. Note: if you
5331 * want Link's shield to interact with the weapon correctly, you must set
5332 * its Dir to a direction that approximates this angle.
5333 */ Example Use: !#!
5334
5335/************************************************************************************************************/
5336
5337 bool Angular; ZASM Instruction:
5338 LWPNANGULAR
5339 EWPNANGULAR
5340
5341 /**
5342 * Specifies whether a weapon has angular movement.
5343 */ Example Use: !#!
5344
5345/************************************************************************************************************/
5346
5347 bool CollDetection; ZASM Instruction:
5348 LWPNCOLLDET
5349 EWPNCOLLDET
5350
5351 /**
5352 * Whether the weapon will use the system's code to work out collisions with
5353 * Link and/or enemies (depending on weapon type). Initialised as 'true'.
5354 */ Example Use: !#!
5355
5356/************************************************************************************************************/
5357
5358 int DeadState; ZASM Instruction:
5359 LWPNDEAD
5360 EWPNDEAD
5361
5362 /**
5363 * The current state of the weapon. Important to keep track of. A value of
5364 * -1 indicates that it is active, and moves according to the weapon's
5365 * Dir, Step, Angular, and Angle values. Use -1 if you want the engine to
5366 * handle movement and collision. Use any value below -1 if you want a
5367 * dummy weapon that you can control on your own.
5368 *
5369 * Given a deadstate value of -10, a weapon will turn of its collision
5370 * detection and movement. If it has a positive value, it will
5371 * decrement once per frame until it equals 0, whereupon the weapon is
5372 * removed. If you want to remove the weapon, write one of the WDS_
5373 * constants in std.zh (appropriate for the weapon) to this variable.
5374 *
5375 * Weapons with the type *_SPARKLE have a DeadState equal to the number
5376 * of frames in their sprite animation, when created.
5377 */ Example Use: !#!
5378
5379/************************************************************************************************************/
5380
5381 bool Flash; ZASM Instruction:
5382 LWPNFLASH
5383 EWPNFLASH
5384
5385 /**
5386 * Whether or not the weapon flashes. A flashing weapon alternates between
5387 * its CSet and its FlashCSet.
5388 */ Example Use: !#!
5389
5390/************************************************************************************************************/
5391
5392 int Flip; ZASM Instruction:
5393 LWPNFLIP
5394 EWPNFLIP
5395
5396 /**
5397 * Whether and how the weapon's tiles should be flipped.
5398 * 0: No flip
5399 * 1: Horizontal flip
5400 * 2: Vertical flip
5401 * 3: Both (180 degree rotation)
5402 */ Example Use: !#!
5403
5404/************************************************************************************************************/
5405
5406 int Extend; ZASM Instruction:
5407 LWPNEXTEND
5408 EWPNEXTEND
5409
5410 /**
5411 * Whether to extend the sprite of the weapon.
5412 */ Example Use: !#!
5413
5414/************************************************************************************************************/
5415
5416 int TileWidth; ZASM Instruction:
5417 LWPNTXSZ
5418 EWPNTXSZ
5419
5420 /**
5421 * The number of tile columns composing the sprite.
5422 * Writing to this is ignored unless Extend is set to values >=3.
5423 */ Example Use: !#!
5424
5425/************************************************************************************************************/
5426
5427 int TileHeight; ZASM Instruction:
5428 LWPNTYSZ
5429 EWPNTYSZ
5430
5431 /**
5432 * The number of tile rows composing the sprite.
5433 * Writing to this is ignored unless Extend is set to values >=3.
5434 */ Example Use: !#!
5435
5436/************************************************************************************************************/
5437
5438 int HitWidth; ZASM Instruction:
5439 LWPNHXSZ
5440 EWPNHXSZ
5441
5442 /**
5443 * The width of the sprite's hitbox, or collision rectangle.
5444 */ Example Use: !#!
5445
5446/************************************************************************************************************/
5447
5448 int HitHeight; ZASM Instruction:
5449 LWPNHYSZ
5450 WEPNHYSZ
5451
5452 /**
5453 * The height of the sprite's hitbox, or collision rectangle.
5454 */ Example Use: !#!
5455
5456/************************************************************************************************************/
5457
5458 int HitZHeight; ZASM Instruction:
5459 LWPNHZSZ
5460 EWPNHZSZ
5461
5462 /**
5463 * The Z-axis height of the sprite's hitbox, or collision rectangle.
5464 * The greater it is, the higher Link must jump or fly over the sprite
5465 * To jump over a sprite, you must be higher than its Z + HitZHeight.
5466 * The values of DrawZOffset and HitZHight are linked. Setting one, also sets the other.
5467 * to avoid taking damage.
5468 */ Example Use: !#!
5469
5470/************************************************************************************************************/
5471
5472 int HitXOffset; ZASM Instruction:
5473 LWPNHXOFS
5474 EWPNHXOFS
5475
5476 /**
5477 * The X offset of the sprite's hitbox, or collision rectangle.
5478 * Setting it to positive or negative values will move the sprite's
5479 * hitbox left or right.
5480 */ Example Use: !#!
5481
5482/************************************************************************************************************/
5483
5484 int HitYOffset; ZASM Instruction:
5485 LWPNHYOFS
5486 EWPNHYOFS
5487
5488 /**
5489 * The Y offset of the sprite's hitbox, or collision rectangle.
5490 * Setting it to positive or negative values will move the sprite's
5491 * hitbox up or down.
5492 */ Example Use: !#!
5493
5494/************************************************************************************************************/
5495
5496 int DrawXOffset; ZASM Instruction:
5497 LWPNXOFS
5498 EWPNXOFS
5499
5500 /**
5501 * The X offset of the sprite.
5502 * Setting it to positive or negative values will move the sprite's
5503 * tiles left or right relative to its position.
5504 */ Example Use: !#!
5505
5506/************************************************************************************************************/
5507
5508 int DrawYOffset; ZASM Instruction:
5509 LWPNYOFS
5510 EWPNYOFS
5511
5512 /**
5513 * The Y offset of the sprite.
5514 * Setting it to positive or negative values will move the sprite's
5515 * tiles up or down relative to its position.
5516 */ Example Use: !#!
5517
5518/************************************************************************************************************/
5519
5520 int DrawZOffset; ZASM Instruction:
5521 LWPNZOFS
5522 EWPNZOFS
5523
5524 /**
5525 * The Z offset of the sprite.
5526 * The values of DrawZOffset and HitZHeight are linked. Setting one, also sets the other.
5527 */ Example Use: !#!
5528
5529/************************************************************************************************************/
5530
5531 float Misc[32]; ZASM Instruction:
5532 LWPNMISCD
5533 EWPNMISCD
5534
5535 /**
5536 * An array of 32 miscellaneous variables for you to use as you please.
5537 */ Example Use: !#!
5538
5539
5540/************************************************************************************************************/
5541/************************************************************************************************************/
5542
5543//====================================
5544//--- Item Functions and Variables ---
5545//====================================
5546
5547 class item
5548
5549
5550 bool isValid(); ZASM Instruction:
5551 ISVALIDITEM
5552
5553 /**
5554 * Returns whether this item pointer is still valid. An item pointer
5555 * becomes invalid when Link picks up the item, the item fades away,
5556 * or Link leaves the screen. Accessing any variables using an
5557 * invalid item pointer prints an error message to allegro.log and
5558 * does nothing.
5559 *
5560 */ Example Use: !#!
5561
5562/************************************************************************************************************/
5563
5564 int X; ZASM Instruction:
5565 ITEMX
5566
5567 /**
5568 * The item's X position on the screen, in pixels. Float values passed to this will be cast to int.
5569 *
5570 */ Example Use: !#!
5571
5572/************************************************************************************************************/
5573
5574 int Y; ZASM Instruction:
5575 ITEMY
5576 /**
5577 * The item's Y position on the screen, in pixels. Float values passed to this will be cast to int.
5578 *
5579 */ Example Use: !#!
5580
5581/************************************************************************************************************/
5582
5583 int Jump ZASM Instruction:
5584 ITEMJUMP
5585
5586 /**
5587 * The item's upward velocity, in pixels. If negative, the item will fall.
5588 * The downward acceleration of Gravity (in Init Data) modifies this value every frame.
5589 *
5590 */ Example Use: !#!
5591
5592/************************************************************************************************************/
5593
5594 int DrawStyle; ZASM Instruction:
5595 ITEMDRAWTYPE
5596 /**
5597 * An integer representing how the item is to be drawn. Use one of the
5598 * DS_ constants in std.zh to set or compare this value.
5599 *
5600 */ Example Use: !#!
5601
5602/************************************************************************************************************/
5603
5604 int ID; ZASM Instruction:
5605 ITEMID
5606 /**
5607 * This item's ID number. Use the I_ constants to compare this value. The effect of writing to this field is currently undefined.
5608 *
5609 */ Example Use: !#!
5610
5611/************************************************************************************************************/
5612
5613 int OriginalTile; ZASM Instruction:
5614 ITEMOTILE
5615 /**
5616 * The starting tile of the item's animation.
5617 *
5618 */ Example Use: !#!
5619
5620/************************************************************************************************************/
5621
5622 int Tile; ZASM Instruction:
5623 ITEMTILE
5624 /**
5625 * The current tile associated with this item.
5626 *
5627 */ Example Use: !#!
5628
5629/************************************************************************************************************/
5630
5631 int CSet; ZASM Instruction:
5632 ITEMCSET
5633 /**
5634 * This item's CSet.
5635 *
5636 */ Example Use: !#!
5637
5638/************************************************************************************************************/
5639
5640 int FlashCSet; ZASM Instruction:
5641 ITEMFLASHCSET
5642 /**
5643 * The CSet used during this item's flash frames, if this item flashes.
5644 *
5645 */ Example Use: !#!
5646
5647/************************************************************************************************************/
5648
5649 int NumFrames; ZASM Instruction:
5650 ITEMFRAMES
5651 /**
5652 * The number of frames in this item's animation.
5653 *
5654 */ Example Use: !#!
5655
5656/************************************************************************************************************/
5657
5658 int Frame; ZASM Instruction:
5659 ITEMFRAME
5660 /**
5661 * The tile that is this item's current animation frame.
5662 *
5663 */ Example Use: !#!
5664
5665/************************************************************************************************************/
5666
5667 int ASpeed; ZASM Instruction:
5668 ITEMASPEED
5669 /**
5670 * The speed at which this item animates, in screen frames.
5671 *
5672 */ Example Use: !#!
5673
5674/************************************************************************************************************/
5675
5676 int ACLock; ZASM Instruction:
5677 ITEMACLK
5678
5679 /**
5680 * Returns the present tick of the animation clock.
5681 *
5682 */
5683
5684/************************************************************************************************************/
5685
5686 int Delay; ZASM Instruction:
5687 ITEMDELAY
5688 /**
5689 * The amount of time the animation is suspended after the last frame,
5690 * before the animation restarts, in item frames. That is, the total
5691 * number of screen frames of extra wait is Delay*ASpeed.
5692 *
5693 */ Example Use: !#!
5694
5695/************************************************************************************************************/
5696
5697 bool Flash; ZASM Instruction:
5698 ITEMFLASH
5699 /**
5700 * Whether or not the item flashes. A flashing item alternates between
5701 * its CSet and its FlashCSet.
5702 *
5703 */ Example Use: !#!
5704
5705/************************************************************************************************************/
5706
5707 int Flip; ZASM Instruction:
5708 ITEMFLIP
5709
5710 /**
5711 * Whether and how the item's tiles should be flipped.
5712 * 0: No flip
5713 * 1: Horizontal flip
5714 * 2: Vertical flip
5715 * 3: Both (180 degree rotation)
5716 *
5717 */ Example Use: !#!
5718
5719/************************************************************************************************************/
5720
5721 int Pickup; ZASM Instruction:
5722 ITEMPICKUP
5723 /**
5724 * The pickup flags of the item, which determine what happens when Link
5725 * picks up the item. Its value consists of flags OR'd (|) together; use
5726 * the IP_ constants in std.zh to set or compare these values.
5727 * A special note about IP_ENEMYCARRIED: if the Quest Rule "Hide Enemy-
5728 * Carried Items" is set, then an item carried by an enemy will have its
5729 * X and Y values set to -128 while the enemy is carrying it. If this
5730 * flag is removed from such an item, then it will be moved to the enemy's
5731 * on-screen location.
5732 * If you are not comfortable with performing binary operations, use the ItemPickup functions from std.zh.
5733 *
5734 */ Example Use: !#!
5735
5736/************************************************************************************************************/
5737
5738 int Extend; ZASM Instruction:
5739 ITEMEXTEND
5740 /**
5741 * Whether to extend the sprite of the item.
5742 *
5743 */ Example Use: !#!
5744
5745/************************************************************************************************************/
5746
5747 int TileWidth; ZASM Instruction:
5748 !
5749 /**
5750 * The number of tile columns composing the sprite.
5751 * Writing to this is ignored unless Extend is set to values >=3.
5752 *
5753 */ Example Use: !#!
5754
5755/************************************************************************************************************/
5756
5757 int TileHeight; ZASM Instruction:
5758 !
5759 /**
5760 * The number of tile rows composing the sprite.
5761 * Writing to this is ignored unless Extend is set to values >=3.
5762 *
5763 */ Example Use: !#!
5764
5765/************************************************************************************************************/
5766
5767 int HitWidth; ZASM Instruction:
5768 ITEMHSXZ
5769 /**
5770 * The width of the sprite's hitbox, or collision rectangle.
5771 *
5772 */ Example Use: !#!
5773
5774/************************************************************************************************************/
5775
5776 int HitHeight; ZASM Instruction:
5777 ITEMHYSZ
5778 /**
5779 * The height of the sprite's hitbox, or collision rectangle.
5780 *
5781 */ Example Use: !#!
5782
5783/************************************************************************************************************/
5784
5785 int HitZHeight; ZASM Instruction:
5786 ITEMHXSZ
5787 /**
5788 * The Z-axis height of the sprite's hitbox, or collision rectangle.
5789 * The greater it is, the higher Link must jump or fly over the sprite to avoid picking up the item.
5790 * To jump over a sprite, you must be higher than its Z + HitZHeight.
5791 *
5792 */ Example Use: !#!
5793
5794/************************************************************************************************************/
5795
5796 int HitXOffset; ZASM Instruction:
5797 ITEMHXOFS
5798 /**
5799 * The X offset of the sprite's hitbox, or collision rectangle.
5800 * Setting it to positive or negative values will move the sprite's hitbox left or right.
5801 *
5802 */ Example Use: !#!
5803
5804/************************************************************************************************************/
5805
5806 int HitYOffset; ZASM Instruction:
5807 ITEMHYOFS
5808 /**
5809 * The Y offset of the sprite's hitbox, or collision rectangle.
5810 * Setting it to positive or negative values will move the sprite's hitbox up or down.
5811 *
5812 */ Example Use: !#!
5813
5814/************************************************************************************************************/
5815
5816 int DrawXOffset; ZASM Instruction:
5817 ITEMXOFS
5818 /**
5819 * The X offset of the sprite.
5820 * Setting it to positive or negative values will move the sprite's tiles left or right relative to its position.
5821 *
5822 */ Example Use: !#!
5823
5824/************************************************************************************************************/
5825
5826 int DrawYOffset; ZASM Instruction:
5827 ITEMYOFS
5828 /**
5829 * The Y offset of the sprite.
5830 * Setting it to positive or negative values will move the sprite's tiles up or down relative to its position.
5831 *
5832 */ Example Use: !#!
5833
5834/************************************************************************************************************/
5835
5836 int DrawZOffset; ZASM Instruction:
5837 ITEMZOFS
5838 /**
5839 * The Z offset of the sprite.
5840 * The values of DrawZOffset and HitZHeight are linked. Setting one, also sets the other.
5841 *
5842 */ Example Use: !#!
5843
5844/************************************************************************************************************/
5845
5846 float Misc[32]; ZASM Instruction:
5847 ITEMMISCD
5848 /**
5849 * An array of 32 miscellaneous variables for you to use as you please.
5850 * Note that lweapons and eweapons possess exactly the same attributes,
5851 * although their designation affects how they are treated by the engine.
5852 * The values here correspond to both the lweapon and eweapon type.
5853 *
5854 */ Example Use: !#!
5855
5856
5857/************************************************************************************************************/
5858/************************************************************************************************************/
5859
5860
5861//=========================================
5862//--- Itemdata Functions and Variables ---
5863//=========================================
5864
5865
5866 int GetPointer(itemdata *ptr[]);
5867 ZASM Instruction:
5868 IDATAARRPTR
5869 /**
5870 * Returns the pointer of a itemdata array as a float.
5871 */ Example Use:
5872 itemdata arr[16];
5873 int size = SizeOfArray( GetPointer(arr) );
5874 //Size == 16
5875
5876/************************************************************************************************************/
5877
5878 itemdata SetPointer(int value); ZASM Instruction:
5879 IDATAARRPTR2
5880 /**
5881 * Converts an int pointer to the itemdata type, for assigning.
5882 */ Example Use:
5883 itemdata arr[16]; itemdata arrB[2]; int arrC[2];
5884 arrC[0] = GetPointer(arr);
5885 arrB[0] = SetPointer(arrC[0]);
5886
5887/************************************************************************************************************/
5888
5889 //! You may reference itemdata variables via item scripts, using the 'this' pointer.
5890
5891 class itemdata
5892 int ID; ZASM Instruction:
5893 IDATAID
5894 /**
5895 * Returns the item number of the item in question.
5896 * Can be called with this->ID in item scripts.
5897 */ Example Use: !#!
5898
5899/************************************************************************************************************/
5900
5901 int Modifier; ZASM Instruction:
5902 IDATALTM
5903 /**
5904 * The Link Tile Modifier
5905 *
5906 */ Example Use: !#!
5907
5908/************************************************************************************************************/
5909
5910 int Tile; ZASM Instruction:
5911 IDATATILE
5912 /**
5913 * The tile used by the item.
5914 *
5915 */ Example Use: !#!
5916
5917/************************************************************************************************************/
5918
5919 int CSet; ZASM Instruction:
5920 IDATAID
5921 /**
5922 * The CSet of the tile used by the item.
5923 *
5924 */ Example Use: !#!
5925
5926/************************************************************************************************************/
5927
5928 int Flash; ZASM Instruction:
5929 IDATAFLASH
5930 /**
5931 * The Flash value for the CSet
5932 *
5933 */ Example Use: !#!
5934
5935/************************************************************************************************************/
5936
5937 int AFrames; ZASM Instruction:
5938 IDATAFRAMES
5939 /**
5940 * The number of animation frames in the item's tile animation.
5941 *
5942 */ Example Use: !#!
5943
5944/************************************************************************************************************/
5945
5946 int ASpeed; ZASM Instruction:
5947 IDATAASPEED
5948 /**
5949 * The speed of the item's animation.
5950 *
5951 */ Example Use: !#!
5952
5953/************************************************************************************************************/
5954
5955 int Delay; ZASM Instruction:
5956 IDATADELAY
5957 /**
5958 * The Delay value, before the animation begins.
5959 *
5960 */ Example Use: !#!
5961
5962/************************************************************************************************************/
5963
5964 int Script; ZASM Instruction:
5965 IDATAID
5966 /**
5967 * The Action Script for the item.
5968 *
5969 */ Example Use: !#!
5970
5971/************************************************************************************************************/
5972
5973 int PScript; ZASM Instruction:
5974 IDATAID
5975 /**
5976 * The Pickup Script for the item.
5977 *
5978 */ Example Use: !#!
5979
5980/************************************************************************************************************/
5981
5982 int MagicCost; ZASM Instruction:
5983 IDATAID
5984 /**
5985 * The item's maic (or rupees, if this is set) cost.
5986 *
5987 */ Example Use: !#!
5988
5989/************************************************************************************************************/
5990
5991 int MinHearts; ZASM Instruction:
5992 IDATAID
5993 /**
5994 * The minimum number of hearts required to pick up the item.
5995 *
5996 */ Example Use: !#!
5997
5998/************************************************************************************************************/
5999
6000bool Combine; ZASM Instruction:
6001 IDATACOMBINE
6002 /**
6003 * Corresponds to 'Upgrade when collected twice'.
6004 *
6005 */ Example Use: !#!
6006
6007/************************************************************************************************************/
6008
6009bool Downgrade; ZASM Instruction:
6010 IDATADOWNGRADE
6011 /**
6012 * Corresponds to the 'Remove When Used' option on the Action tab of the item editor.
6013 *
6014 */ Example Use: !#!
6015
6016/************************************************************************************************************/
6017
6018bool KeepOld; ZASM Instruction:
6019 IDATAKEEPOLD
6020 /**
6021 * Corresponds to 'Keep lower level items on the Pickup tab of the item editor.
6022 * NOTE: Not to be confused with 'Keep', which corresponds to the 'Equipment Item' box.
6023 *
6024 */ Example Use: !#!
6025
6026/************************************************************************************************************/
6027
6028bool RupeeCost; ZASM Instruction:
6029 IDATARUPEECOST
6030 /**
6031 * Corresponds to the 'Use Rupees Instead of Magic' option on the item editor 'Action' tab.
6032 *
6033 */ Example Use: !#!
6034
6035/************************************************************************************************************/
6036
6037bool Edible; ZASM Instruction:
6038 IDATAEDIBLE
6039 /**
6040 * Corresponds to the 'Can be Eaten by Enemies' box on the Pickup tab of the item editor.
6041 *
6042 */ Example Use: !#!
6043
6044/************************************************************************************************************/
6045
6046bool GainLower; ZASM Instruction:
6047 IDATAGAINLOWER
6048 /**
6049 * Corresponds to the 'Gain All Lower Level Items' box on the Pickup tab of the item editor.
6050 *
6051 */ Example Use: !#!
6052
6053/************************************************************************************************************/
6054
6055bool Flag1; ZASM Instruction:
6056 IDATAFLAG1
6057 /**
6058 * Multipurpose Flag 1
6059 *
6060 * The properties of this flag change based on the item class (family).
6061 * This corresponds to the box directly below 'Equiment Item'.
6062 * For swords, this is 'B.H. is Percent'.
6063 * Scripted item classes may make use of this as a general-purpose 'Script 1' flag.
6064 * See 'zscript_itemdata.txt' for more information on what this flag does, based on the item class.
6065 *
6066 */ Example Use: !#!
6067
6068/************************************************************************************************************/
6069
6070bool Flag2; ZASM Instruction:
6071 IDATAFLAG2
6072 /**
6073 * Multipurpose Flag 2
6074 *
6075 * The properties of this flag change based on the item class (family).
6076 * This corresponds to the box directly below 'Flag 1, or two boxes down from 'Equiment Item'.
6077 * For swords, this is 'B.D. is Percent'.
6078 * Scripted item classes may make use of this as a general-purpose 'Script 2' flag.
6079 * See 'zscript_itemdata.txt' for more information on what this flag does, based on the item class.
6080 *
6081 */ Example Use: !#!
6082
6083/************************************************************************************************************/
6084
6085bool Flag3; ZASM Instruction:
6086 IDATAFLAG3
6087 /**
6088 * Multipurpose Flag 3
6089 *
6090 * The properties of this flag change based on the item class (family).
6091 * This corresponds to the box directly right of 'Equiment Item'.
6092 * For swords, this is 'B. Penetrates Enemies'.
6093 * Scripted item classes may make use of this as a general-purpose 'Script 3' flag.
6094 * See 'zscript_itemdata.txt' for more information on what this flag does, based on the item class.
6095 *
6096 */ Example Use: !#!
6097
6098/************************************************************************************************************/
6099
6100bool Flag4; ZASM Instruction:
6101 IDATAFLAG4
6102 /**
6103 * Multipurpose Flag 4
6104 *
6105 * The properties of this flag change based on the item class (family).
6106 * This corresponds to the box directly right of 'Flag 2'.
6107 * For swords, this is 'Can Slash'.
6108 * Scripted item classes may make use of this as a general-purpose 'Script 4' flag.
6109 * See 'zscript_itemdata.txt' for more information on what this flag does, based on the item class.
6110 *
6111 */ Example Use: !#!
6112
6113/************************************************************************************************************/
6114
6115bool Flag5; ZASM Instruction:
6116 IDATAFLAG5
6117 /**
6118 * Multipurpose Flag 5
6119 *
6120 * The properties of this flag change based on the item class (family).
6121 * This corresponds to the box directly below 'Flag 4'.
6122 * For swords, this is '<Unused>', and greyed out.
6123 * Scripted item classes may make use of this as a general-purpose 'Script 5' flag.
6124 * See 'zscript_itemdata.txt' for more information on what this flag does, based on the item class.
6125 *
6126 */ Example Use: !#!
6127
6128/************************************************************************************************************/
6129
6130bool Unused; ZASM Instruction:
6131 IDATAFLAGUNUSED
6132 /**
6133 * ? - An extra script-only flag. It's a mystery to everyone.
6134 * Likely best left unused in the event that we need to reserve it.
6135 *
6136 */ Example Use: !#!
6137
6138/************************************************************************************************************/
6139
6140 float InitD[]; ZASM Instruction:
6141 IDATAINITDD
6142 /**
6143 * The original values of the item's 8 'D#' input values are they are stored in the
6144 * .qst file, regardles of whether they have been modified by ZScript.
6145 */ Example Use: !#!
6146
6147/************************************************************************************************************/
6148
6149 void GetName(int buffer[]); ZASM Instruction:
6150 !
6151 /**
6152 * Loads the item this itemdata is attributed to's name into 'buffer'
6153 */ Example Use: !#!
6154
6155/************************************************************************************************************/
6156
6157 int Family; ZASM Instruction:
6158 IDATAFAMILY
6159 /**
6160 * The kind of item to which this class belongs (swords, boomerangs,
6161 * potions, etc.) Use the IC_ constants in std.zh to set or compare this
6162 * value.
6163 */ Example Use: !#!
6164
6165/************************************************************************************************************/
6166
6167 int Level; ZASM Instruction:
6168 IDATALEVEL
6169 /**
6170 * The level of this item. Higher-level items replace lower-level items
6171 * when they are picked up.
6172 */ Example Use: !#!
6173
6174/************************************************************************************************************/
6175
6176 int Power; ZASM Instruction:
6177 IDATAPOWER
6178 /**
6179 * The item's power, for most items this is amount of damage dealt but is
6180 * used for other values in some items (ie. Roc's Feather)
6181 */ Example Use: !#!
6182
6183/************************************************************************************************************/
6184
6185 int Amount; ZASM Instruction:
6186 IDATAAMOUNT
6187 /**
6188 * Corresponds to the "Increase Amount" entry in the Item Editor.
6189 * The value of this data member can have two meanings:
6190 * If Amount & 0x8000 is 1, the drain counter for this item is set
6191 * to Amount & 0x3FFF. The game then slowly fills the counter of this item
6192 * (see Counter below) out of the drain counter. Gaining rupees uses the
6193 * drain counter, for example.
6194 * is set to Amount when the item is picked up.
6195 * If Amount & 0x8000 is 0, the counter of this item is increased, if
6196 * Amount & 0x4000 is 1, or decreased, if Amount & 0x4000 is 0, by
6197 * Amount & 0x3FFF when the item is picked up.
6198 */ Example Use: !#!
6199
6200/************************************************************************************************************/
6201
6202 int Max; ZASM Instruction:
6203 IDATAMAX
6204 /**
6205 * Corresponds to the "Full Max" entry in the Item Editor.
6206 * In conjunction with MaxIncrement (see below) this value controls how
6207 * the maximum value of the counter of this item (see Counter below) is
6208 * modified when the item is picked up. If MaxIncrement is nonzero at that
6209 * time, the counter's new maximum value is at that time set to the
6210 * minimum of its current value plus MaxIncrement, Max.
6211 * If Max is less than the current maximum of the counter, Max is ignored
6212 * and that maximum is used instead.
6213 * Notice that as a special case, if Max = MaxIncrement, the counter's
6214 * maximum value will be forced equal to Max.
6215 */ Example Use: !#!
6216
6217/************************************************************************************************************/
6218
6219 int MaxIncrement; ZASM Instruction:
6220 IDATASETMAX
6221 /**
6222 * Corresponds to the "+Max" entry in the Item Editor.
6223 * In conjunction with Max (see above) this value controls how the
6224 * maximum value of the counter of this item (see Counter below) is
6225 * modified when the item is picked up. If MaxIncrement is nonzero at that
6226 * time, the counter's new maximum value is at that time set to the
6227 * minimum of its current value plus MaxIncrement, and Max.
6228 * If Max is less than the current maximum of the counter, Max is ignored
6229 * and that maximum is used instead.
6230 */ Example Use: !#!
6231
6232/************************************************************************************************************/
6233
6234 bool Keep; ZASM Instruction:
6235 IDATAKEEP
6236 /**
6237 * Corresponds to the "Equipment Item" checkbox in the Item Editor.
6238 * If true, Link will keep the item, and it will show up as an item or
6239 * equipment in the subscreen. If false, it may modify the current value
6240 * or maximum value of its counter (see Counter below), then disappear.
6241 * The White Sword and Raft, for instance, have Keep true, and keys and
6242 * rupees have Keep false.
6243 */ Example Use: !#!
6244
6245/************************************************************************************************************/
6246
6247 int Counter; ZASM Instruction:
6248 IDATACOUNTER
6249 /**
6250 * Corresponds to the "Counter Reference" entry in the Item Editor.
6251 * The game counter whose current and modified values might be modified
6252 * when the item is picked up (see Amount, Max, and MaxIncrement above.)
6253 * Use the CT_ constants in std.zh to set or compare this value.
6254 */ Example Use: !#!
6255
6256/************************************************************************************************************/
6257
6258 int UseSound; ZASM Instruction:
6259 IDATAUSESOUND
6260
6261 /**
6262 * Corresponds to the "Sound" entry on the action tab in the Item Editor.
6263 */ Example Use: !#!
6264
6265/************************************************************************************************************/
6266
6267 int Attributes[10]; ZASM Instruction:
6268 IDATAATTRIB
6269
6270 /**
6271 * An array of ten integers containing the Attributes values.
6272 * These correspond to the text entry fields, in the item editor 'Data' tab.
6273 *
6274 */
6275
6276/************************************************************************************************************/
6277
6278 int Sprites[10]; ZASM Instruction:
6279 IDATASPRITES
6280
6281 /**
6282 * An array of ten integers containing the Sprites values.
6283 * These correspond to the pull-down options in the item editor 'Action' tab. .
6284 *
6285 */
6286
6287/************************************************************************************************************/
6288
6289 bool Flags[5]; ZASM Instruction:
6290 IDATAFLAGS
6291
6292 /**
6293 * An array of five multipurpose boolean flags. The properties of this flag change based on the item class (family).
6294 * Flag[0] corresponds to the box directly below 'Equiment Item'. For swords, this is 'B.H. is Percent'.
6295 * Flag[1] corresponds to the box directly below 'Flag 1'. For swords, this is 'B.D. is Percent'.
6296 * Flag[2] corresponds to the box directly right of 'Equiment Item'. For swords, this is 'B. Penetrates Enemies'.
6297 * Flag[3] corresponds to the box directly right of 'Flag 2'. For swords, this is 'Can Slash'.
6298 * Flag[4] corresponds to the box directly below 'Flag 4'.For swords, this is '<Unused>', and greyed out.
6299 *
6300 * Scripted item classes may make use of these as a general-purpose script flags.
6301 * See 'zscript_itemdata.txt' for more information on what this flag does, based on the item class.
6302 */
6303
6304/************************************************************************************************************/
6305
6306 int Misc1, Misc2, Misc3, Misc4, Misc5, Misc6, Misc7, Misc8, Misc9, Misc10;
6307 ZASM Instructions:
6308 IDATAMISC1, IDATAMISC2, IDATAMISC3, IDATAMISC4, IDATAMISC5
6309 IDATAMISC6, IDATAMISC7, IDATAMISC8, IDATAMISC9, IDATAMISC10
6310 /**
6311 * These correspond to the pull-down options in the item editor 'Data' tab.
6312 *
6313 * Example: For a Sword Misc1 is 'Beam hearts', and Misc2 is 'Beam .
6314 *
6315 */ Example Use: !#!
6316
6317/************************************************************************************************************/
6318
6319 int Attribute1, Attribute2, Attribute3, Attribute4, Attribute5, Attribute6,
6320 Attribute7, Attribute8, Attribute9, Attribute10;
6321 ZASM Instructions:
6322 IDATAWPN, IDATAWPN2, IDATAWPN3, IDATAWPN4, IDATAWPN5
6323 IDATAWPN6, IDATAWPN7, IDATAWPN8, IDATAWPN9, IDATAWPN10
6324 /**
6325 * These correspond to the pull-down options in the item editor 'Action' tab.
6326 *
6327 * Example: For a Sword Attribute1 is 'Sprite', Attribute 2 is 'Slash sprite'
6328 * and Attribute 3 is 'Beam sprite'.
6329 *
6330 */ Example Use: !#!
6331
6332/************************************************************************************************************/
6333/************************************************************************************************************/
6334
6335
6336//////////////////////
6337/// Array Building ///
6338//////////////////////
6339
6340
6341//////////////////////////////////////
6342/// Poke, or Peek at Memory Values ///
6343/////////////////////////////////////////////////////////////////////////////////////////////////////////
6344/// The following functions are used by ZScript to build arrays, and move data between the registers ///
6345/// that hold them, and generally interpret the values in registers for using arrays. ///
6346/////////////////////////////////////////////////////////////////////////////////////////////////////////
6347/// When an array is declared in ZScript, the following commands are used to create it, ///
6348/// and store its values: ///
6349/// ///
6350/// Creating arrays (global): ///
6351/// ///
6352/// int arr[16]; ///
6353/// int x; ///
6354/// ///
6355/// ZASM Output: ///
6356/// ALLOCATEGMEMV d2,16 : allocates 16 indices to d2 ///
6357/// SETR gd1,d2 : assigns the register d2 to global register gd1 ///
6358/// SETV gd2,0 ///
6359/// ///
6360/////////////////////////////////////////////////////////////////////////////////////////////////////////
6361/// When an array is accessed, and the value of an index read, these instructions: ///
6362/// ///
6363/// int x; ///
6364/// int arr[16]; ///
6365/// x = arr[2]; ///
6366/// ///
6367/// ZASM Output: ///
6368/// ///
6369/// SETV d2,0 : Clear expression axcumulator #1 ///
6370/// PUSHR d3 : Push expression accumulator #2 ///
6371/// SETR d4,SP : Stack frame pointer to stack pointer. ///
6372/// SETR d2,gd1 : Set the value of arr[] to the expression accumulator #1. ///
6373/// PUSHR d2 : Push the expression accumulaor #1 ///
6374/// SETV d2,2 : Store the index we're reading in the expression accumulator #1 ///
6375/// POP d0 : Pop the array index accumulator ///
6376/// SETR d1,d2 : Store the expression accumulator #1 into the secondary array index accumulator. ///
6377/// SETR d2,GLOBALRAM : Read the array values into the expression accumulator #1 ///
6378/// SETR gd2,d2 : Store the value of the inex into x. ///
6379/// SETV d3,0 : Clear the secondary expression accumulator. ///
6380/// ///
6381/////////////////////////////////////////////////////////////////////////////////////////////////////////
6382/// When the values in an array are modified, these instructions: ///
6383/// ///
6384/// arr[2] = 6; ///
6385/// ///
6386/// ZASM Output: ///
6387/// ///
6388/// SETV d2,0 : Clear expression accumulator #1 ///
6389/// PUSHR d3 : Push expression accumulator #2 ///
6390/// SETR d4,SP : Stack frame pointer to stack pointer. ///
6391/// SETV d2,6 : Set expression accumulator #1 to a value of 6 ///
6392/// SETR d0,gd1 : Prep the array index accumulator with the array stored in gd1 ///
6393/// SETR d5,d2 : Sink the value in d2 ///
6394/// PUSHR d0 : Push the array index accumulator. ///
6395/// SETV d2,2 : Store the index to modify in The expression accumulator #1 ///
6396/// POP d0 : Pop off the array index accumulator ///
6397/// SETR d1,d2 : Assign the value of the expression accumulator #1 to the ///
6398/// : secondary array index accumulator. ///
6399/// SETR GLOBALRAM,d5 : Store the value. ///
6400/// SETV d3,0 : Clear the expression accumulaTor #2 ///
6401/////////////////////////////////////////////////////////////////////////////////////////////////////////
6402/// Using these, it would be possible to generate your own array handling routines. ///
6403/////////////////////////////////////////////////////////////////////////////////////////////////////////
6404/// Global arrays are allocated in the REVERSE order of DECLARATION! ///
6405/////////////////////////////////////////////////////////////////////////////////////////////////////////
6406
6407// Peek at RAM value in a global address.
6408
6409void GetGlobalRAM(int register) ZASM Instruction:
6410 GLOBALRAMD
6411Example Use:
6412 Game->GetGlobalRAM(10)
6413 Returns the value in gd10
6414
6415/************************************************************************************************************/
6416
6417// POKE value into Global address
6418
6419void SetGlobalRAM(int register, int value) ZASM Instruction:
6420 GLOBALRAMD<><>
6421Example Use:
6422 Game->SetGlobalRAM(10,6)
6423 Sets gd10 to a value of '6'.
6424
6425/************************************************************************************************************/
6426
6427//Peek at register value of specific script address.
6428void GetScriptRAM(int register) ZASM Instruction:
6429 SCRIPTRAMD<>
6430Example Use:
6431 Game->GetScriptRAM(4)
6432 Returns the value of Script RAM register 4.
6433
6434/************************************************************************************************************/
6435
6436//POKE Vakue into Script RAM address
6437void SetScriptRAM(int register, int value) ZASM Instruction:
6438 SCRIPTRAMD<><>
6439Example Use:
6440 Game->SetScriptRAM(4,12)
6441 Sets script RAM register 4 to a value of '12'
6442
6443/************************************************************************************************************/
6444
6445
6446///////////////////////////////////////
6447/// Misc ZASM-Specific Instructions ///
6448///////////////////////////////////////
6449
6450GOTO<><>
6451GOTOTRUE<><>
6452GOTOFALSE<><>
6453GOTOLESS<><>
6454GOTOMORE<><>
6455POP<>
6456PUSHR<>
6457PUSHV<>
6458ENQUEUER<><>
6459ENQUEUEV<><>
6460DEQUEUE<>
6461GOTOR<>
6462LOADI<><>
6463STOREI<><>
6464LOOP<><>
6465MODR<><>
6466MODV<><>
6467CHECKTRIG
6468COMPOUNDR<>
6469COMPOUNDV<>
6470FLIPROTTILEVV<><>
6471FLIPROTTILERR<><>
6472FLIPROTTILERV<><>
6473FLIPROTTILEVR<><>
6474
6475/* These may not be implemented.
6476 GETTILEPIXELV<>
6477 GETTILEPIXELR<>
6478 SETTILEPIXELV<>
6479 SETTILEPIXELC<>
6480
6481 SHIFTTILEVV<><>
6482 SHIFTTILEVR<><>
6483 SHIFTTILERR<><>
6484 SHIFTTILERV<><>
6485*/
6486
6487
6488/* Handles array data allocation.
6489 ALLOCATEMEMR<><>
6490 ALLOCATEMEMV<><>
6491 ALLOCATEMGEMR<><>
6492 ALLOCATEMGEMV<><>
6493*/
6494
6495/************************************************************************************************************/
6496
6497ZASM Register Reservations
6498
6499Name Register Use
6500SP
6501 stack pointer
6502D4
6503 stack frame pointer
6504D6
6505 stack frame offset accumulator
6506D2
6507 expression accumulator #1
6508D3
6509 expression accumulator #2
6510D0
6511 array index accumulator
6512D1
6513 secondary array index accumulator
6514D5
6515 pure SETR sink
6516
6517
6518//Unimplemented ZASM Instructions
6519GETTILEPIXEL
6520SETTILEPIXEL
6521FLIPROTATETILE
6522SHIFTTILE
6523
6524//partially Implemented ZASM
6525
6526OVERLAYTILE : Supports 8-bit mode tiles only. May support 4-bit only in CSet 0
6527
6528************************************
6529Misc ZASM
6530
6531LOADI LoadIndirect
6532STOREI StoreIndirect
6533
6534
6535////////////////////
6536/// Undocumented ///
6537////////////////////
6538
6539The following are unsupported, and unfinished ZScript functions.
6540 * While calling them is not while setting it is not syntactically incorrect, it does nothing.
6541
6542void SetColorBuffer( int amount, int offset, ZASM Instruction:
6543 int stride, int *ptr ) SETCOLORB
6544
6545Opcode: OSetColorBufferRegister()
6546Example Use:
6547
6548/************************************************************************************************************/
6549
6550void GetColorBuffer( int amount, int offset, ZASM Instruction:
6551 int stride, int *ptr ) GETCOLORB
6552
6553Opcode: OGetColorBufferRegister();
6554Exaple Use:
6555
6556/************************************************************************************************************/
6557
6558void SetDepthBuffer( int amount, int offset, ZASM Instruction:
6559 int stride, int *ptr ) SETDEPTHB
6560
6561Opcode: OSetDepthBufferRegister();
6562Example Use:
6563
6564/************************************************************************************************************/
6565
6566void GetDepthBuffer( int amount, int offset, ZASM Instruction:
6567 int stride, int *ptr ) GETDEPTHB
6568
6569Opcode: OGetDepthBufferRegister();
6570Example use:
6571
6572/************************************************************************************************************/
6573
6574Undocumented / ZASM Exclusive
6575
6576FLOODFILL
6577
6578//////////////////////////////////////////////
6579/// System Limitations, Minimums, Maximums ///
6580//////////////////////////////////////////////
6581
6582 Maximum numeric literal: 214747.9999
6583
6584Ints, Floats, Arrays
6585
6586 Maximum float: -214747.9999 to 214747.9999
6587 Maximum int -214747 to 214747
6588 Maximum array size (number of indices): 214747
6589
6590 * This further includes arrays with a type of npc, leweapon, eweapon, item, and itemdata.
6591 Maximum value in an array index: Same as float, or int; based on type declaration.
6592 Maximum size of string index: 214747
6593 Maximum string length: 214747
6594 Maximum simultaneous arrays in operation: 4095
6595
6596Counters, Tiles, Combos, Strings
6597
6598 Maximum Tiles: 65519
6599 Maximum Combos: 65279
6600 Maximum Counter Value: 0 to 32767
6601 Maximum strings in string editor: ( 65519 )
6602
6603 Largest tile ID (ZQ Editors): 32767 ?
6604
6605 The largest value that can be referenced in the ZQ item, enemy, and other editors.
6606
6607 --> I seem to remember a problem calling high values.
6608
6609Pointers and Objects
6610
6611 Maximum number of item pointers (on-screen items) at any one time: 255
6612 Maximum number of lweapon pointers (on-screen lweapons) at any one time: 255
6613 Maximum number of eweapon pointers (on-screen eweapons) at any one time: 255
6614 Maximum number of npc pointers (on-screen NPCs) at any one time: 255
6615 Maximum number of ffc (on-screen FFCs) pointers at any one time: 32
6616 Array Pointers (maximum number of arrays in operation): 4095
6617
6618 Maximum total (cumulative) number of 'object' pointers at any one time: 1020
6619 * 255 each, npc, lweapon, eweapon, item + 32 (ffcs)
6620
6621 --> ZC separates pointers by class. All pointers are stored in vectors, with pointer IDs ranging from 1 to 255.
6622
6623 Maximum Z Height of a Screen Object (npc, weapon, item) or Link: 32767. Values above this wrap to -32767, which is reset to 0 every frame.
6624
6625Compiler
6626
6627 Maximum constants (any scope): Unlimited. (Constants are converted to their true value at compilation, and are not preserved by name.)
6628 Maximum global variables: 255*
6629 Maximum global functions: 4,294,967,295 (2^32-1).
6630 Note that this is limited by the filesystem, as each function requires its ASCII size in bytes,
6631 and is stored in the quest file. Many filesystems have a file size limit, that restricts it.
6632 At the smallest function size, max functions would use ~40GB of space.
6633 It is further restricted by the maximum buffer size at between 18MB and 22MB.
6634
6635Script Drawing
6636
6637 Maximum number of drawing commands per frame: 1000
6638 Maximum distance (x,y) for drawing, including off-screen areas (and bitmaps): -214747.9999 to 214747.9999 (X and Y)
6639 Maximum Z Height for 3D Drawing: 214747.9999
6640
6641 --> Negative Z Height is effectively '0'.
6642
6643Stack Operation
6644
6645 Maximum number of concurrent stacks: ?
6646 --> Essentially, the maximum number of concurrent scripts; except that item scripts share one stack.
6647
6648 Maximum variables in operation at any given time: 255* (gd1-gd255)
6649 Maximum variables per script: 255*
6650 Maximum function calls per script ( 127* )
6651 *Note: 255 variables will compile, but fail to run. A safe maximum is closer to 245, to allow instructions and function calls on the stack
6652 *Note: Both variables, and function calls share registers (global variables are gd registers), and thus cumulatively count against their combined caps (within a register type). See: ZASM_Registers
6653 --> How are these tabulated at compilation, and is there a strict ratio ( function call:variable ) ?
6654 --> Script-scope variables use gd registers. Thus, you need to retain free registers for scripts to run.
6655
6656 Maximum script buffer size: ~18MB, including code imported with the 'import' directive.
6657 --> Maximum line count is also limited, but it is restricted by being a signed int.
6658 --> Thus, max line-count is somewhere around 2,147,483,647 lines, however,
6659 this is still restricted by the 18MB buffer size.
6660
6661 Maximum number of instructions: 2^32-1 * Max Scripts
6662 Maximum instructions per script: 4,294,967,295 (2^31 - 1)
6663 Maximum instructions per frame: Effectively unlimited, save by instructions per script.
6664
6665 Maximum number of scripts ?
6666 Max ffc scripts at compilation ?
6667 Max Item scripts at compilation ?
6668 Max global scripts at compilation ?
6669 --> I know this is unlikely to ever be reached.
6670
6671 Maximum function calls per script: Limited by maximum instructions, and available gd registers.
6672 Maximum local functions per script: ? Effectively unlimited, and tied to maximum functions (see above).
6673
6674Maximum Values (Binary, Hex) for Use as Flags
6675
6676 The largest literal that you can use as a flag, binary, is: 110100011010111101
6677 ( dec. 214717, hex 0x346BD )
6678
6679 The largest true binary value (all ones) is 11111111111111111
6680 ( dec. 131071, hex 0x1FFFF )
6681
6682 While these are certainly possible, the largest absolutely useful value, that maximises all places in
6683 both binary, and hex, and thus is the true flag maximum is: 65535 (decimal).
6684 This becomes 1111111111111111b, or 0XFFFF, which means that you may use each place to its full potential,
6685 at all times.
6686
6687 Thus, the maximum useful flags are a width of 16-bit, and are represented below.
6688
6689 Max Flag
6690
6691 Binary Hexadecimal Decimal
6692 1111111111111111b 0XFFFF 65535
6693
6694
6695//! A list of all known system limitations.
6696
6697################################
6698## COMPILER ERROR DEFINITIONS ##
6699################################
6700These errors are generated by the parser, during compilation.
6701
6702Error codes are broken down by type:
6703P** Preprocessing errors.
6704S** Symbol table errors.
6705T** Type-checking errors.
6706G** Code Generation Errors
6707** Array Errors ---We need to change these to A**
6708
6709Errors of each class are given unique numerical identifiers, ranging from 00 to 41, such as P01, or G33.
6710The letter code will give you an indication of the type of error, and the full code will give you specific details.
6711
6712In ZQuest v2.50.2 and later, the compiler will report name of the script that generated (where possible).
6713This applies only to errors caused by scripts, and not errors at a 'global' level, such as global functions.
6714Thus, if you are using 2.50.2, or later, an error without a script name is likely to be caused at global scope.
6715
6716#####################
6717## Specific Errors ##
6718## Preprocessing ##
6719#####################
6720
6721P00: Can't open or parse input file!
6722
6723Your script file contains illegal characters, or is not plain ASCII Text.
6724
6725Otherwise, it is possible that the compiler is unable to write to the disk, that the disk is out of space.
6726
6727Last, your file may be bad, such as a file in the qrong encoding format (not ASCII text).
6728
6729P01: Failure to parse imported file foo.
6730
6731Generally means that you are trying to call a file via the import directive that does not exist; or that
6732you have a typo in the filename, or path.
6733
6734
6735P02: Recursion limit of x hit while preprocessing.
6736
6737Caused by attempting to import a file recursively. For example:
6738
6739If you declare: import "script.z" ... and ... the file 'script.z' has the line: ' import "script.z" ' inside it.
6740
6741This error should no longer exist! Recursive imports should resolve as duplicate finction/variable/script declarations.
6742
6743Error P03: You may only place import statements at file scope.
6744
6745Import directives ( import "file.z" ) may only be declared at a global scope, not within
6746a function, statement, or script.
6747
6748P35: There is already a constant with name 'foo' defined.
6749You attempted to define the same constant more than once.
6750The identifier (declared name) of all constants MUST be UNIQUE.
6751
6752
6753#####################
6754## Specific Errors ##
6755## Symbol Table ##
6756#####################
6757
6758S04: Function 'foo' was already declared with that type signature.
6759
6760You attempted to declare a function with the same parameters twice, int he same scope.
6761This can occur when using different types, if the compiler cannot resolve a difference between the signatures.
6762
6763To fix this, remove one function,or change its signature (the arguments inside the parens) so that each is unique or;
6764If you declare a functiona t a global scope, and the same at a local scope, remove one of the two.
6765
6766Note that return type is NOT enough to distinguish otherwise identical function declarations and that 'int' and 'float'
6767types are the same type internally, so int/float is identical insofar as the signature is concerned.
6768
6769If two function type signatures are identical except that one has a parameter of type float where the other has the
6770same parameter of type int, you will have a conflict.
6771
6772There are two additional subtle situations where you might get a conflict:
6773
67741. A function declared at file scope might conflict with a function that's implicitly added to file scope
6775by the preprocessor because of an import statement.
67762. A function might conflict with one already reserved by the ZScript standard library (std.zh).
6777
6778S05: Function parameter 'foo' cannot have void type.
6779
6780You cannot set a parameter (argument of a function) as a void type. e.g.:
6781int foo(void var){ return var+1; }
6782
6783This is illegal, and the param 'var' muct be changed to a legal type.
6784
6785S06: Duplicate script with name 'foo' already exists.
6786
6787Script names must be wholly unique. For example, if there's already an ffc script named 'my_script' you cannot
6788declare an item script with the name 'my_script'.
6789
6790S07: Variable 'foo' can't have type void.
6791
6792Variables at any scope may not have a void type. Only functions may have this type.
6793
6794S08: There is already a variable with name 'foo' defined in this scope.
6795
6796Variable identifiers must be unique at any given scope. Thus, this is illegal:
6797
6798ffc script my_ffc(){
6799 void run(int x){
6800 int v = 1;
6801 int w = 10;
6802 int x = 0.5;
6803 int y = 13;
6804 int z = v+w+x+y;
6805 Trace(z);
6806 }
6807}
6808
6809As the variable 'x' is declared in the params of the run() function, it cannot be declared inside the function with
6810the same identifier (name).
6811
6812
6813S09: Variable 'foo' is undeclared.
6814
6815You attempted to reference a variable identifier (namme) that has not been declared.
6816Usually this is due to a typo:
6817
6818int var;
6819if ( val > 0 ) Link->X += var;
6820
6821Here, 'val' will return this error, as it was not declared.
6822
6823A variable with the give name could not be found in the current or any enclosing scope. Keep in mind the following subtleties:
68241. To access a different script's global variables, or to access a global variable from within a function delcared at file scope,
6825you must use the dot operator: scriptname.varname.
68262. To access the data members of the ffc or item associated with a script, you must use the this pointer: this->varname.
68273. ZScript uses C++-style for loop scoping rules, so variables declared in the header part of the for loop cannot be
6828accessed outside the loop:
6829
6830Code:
6831
6832for(int i=0; i<5;i++);
6833i = 2; //NOT legal
6834
6835S10: Function 'foo' is undeclared.
6836
6837You attempted to call a function that was not declared. This is usually due to either a typo in your code, or failing
6838to import a mandatory header. Check that you are importing 'std.zh' as well, as failing to do this will result in a slew
6839of this error type.
6840
6841S11: Script 'foo' must implement void run().
6842
6843Every script must implement run() function call. The signature may be empty, or contain arguments.
6844Zelda Classic uses all the code inside the run() function when executing the script, so a script without
6845this function would do nothing, and will return an error.
6846
6847S12: Script 'foo's' run() must have return type void.
6848
6849Is this error even implemented? The run() function is automatic, and never declared by type, unless the user tries to declare
6850a separate run(params) function with a different type.
6851
6852S26: Pointer types (ffc, etc) cannot be declared as global variables.
6853
6854/* It is illegal to declare a global variable (that is, a variable in script scope) or any type other than int, float, and bool.
6855Why? Recall that global variables are permanent; they persist from frame to frame, screen to screen.
6856Pointer types, on the other hand, reference ffcs or items that are transitory; they become stale after a single WAITFRAME,
6857so it makes no sense to try to store them for the long term.
6858*/
6859
6860This explanation may no longer be true, as pointers may no longer be dereferenced by Waitframe(),
6861and global pointers may also be implemented in a future version.
6862
6863
6864S30: Script foo may have only one run method.
6865
6866You may not call a run() function more than once per script.
6867Your run method may have any type signature, but because of this flexibility, the compiler cannot
6868determine which run script it the "real" entry point of the script if multiple run methods are declared.
6869
6870S32: Script foo is of illegal type.
6871
6872The only legal script tokens are: global, ffc, and item. You cannot declare other types (such as itemdata script).
6873
6874S38: Script-scope global variable declaration syntax is deprecated; put declarations at file scope instead.
6875You cannot declare a global variable in a global script, outside the run function.
6876
6877Example:
6878
6879global script active{
6880 int x;
6881 void run(){
6882 x = 16;
6883 }
6884}
6885
6886This is ILLEGAL. The declaration of variable 'x' must either be at a global scope, or at the scope of the
6887run function. Do this, instead:
6888
6889int x;
6890global script active{
6891 void run(){
6892 x = 16;
6893 }
6894}
6895
6896This creates a global variable at the file scope.
6897
6898S39: Array 'foo' can't have type void.
6899Arrays may be types of int, float, bool, ffc, item, itemdata, npc, lweapon, or eweapon; but arrays
6900with a void type are illegal.
6901
6902S40: Pointer types (ffc, etc) cannot be declared as global arrays.
6903As of 2.50.2, global array declarations may only have the following types:
6904int, float, bool
6905Any other type is illegal.
6906
6907S41: There is already an array with name 'foo' defined in this scope.
6908As with variables, and functions, arrays must have unique identifiers within the same scope.
6909
6910###################
6911## LEXING ERRORS ##
6912###################
6913L24: Too many global variables.
6914
6915The assembly language to which ZScript is compiled has a built-in maximum of 256 global variables. ZScript can't do anything if you exceed this limit.
6916
6917#####################
6918## Specific Errors ##
6919## Type Checking ##
6920#####################
6921
6922T13: Script 'foo' has id that's not an integer.
6923
6924/* I do not know what can cause this error, or if it ever occurs. */
6925
6926T14: Script 'foo's' id must be between 0 and 255.
6927
6928Occurs if you try to load more than 256 scripts of any given type at any given time.
6929/* The maximum number of concurrent scripts (of any given type?) is 256. */
6930
6931T15: Script 'foo's' id is already in use.
6932You attempted to laod two scripts into the same slot.
6933/* I do not know if this is EVER possible. */
6934
6935T16: Cast from foo to bar.
6936
6937The only "safe" implicit casts are from int to float and vice-versa (since they are the same type),
6938and from int (or float) to bool (0 becomes false, anything else true).
6939The results of any other kind of cast are unspecified.
6940
6941/*
6942Is this error still in effect? Casting from npc to itemdata, or others, usually results in a different error code.
6943Further, Cannot cast from wtf to int, is a thing.
6944*/
6945
6946Explicit casts are unimplemented and unnecessary.
6947
6948T17: Cannot cast from foo to bar.
6949
6950You attempted to typecast illegally, such as tyring to typecast from bool to float.
6951
6952T18: Operand is void.
6953Occurs if you try to use a void type value in an operation.
6954/* I do not know if this is EVER possible. */
6955
6956T19: Constant division by zero.
6957
6958While constant-folding, the compiler has detected a division by zero
6959
6960 Example:
6961 const int MY_CONSTANT = 0;
6962 ffc script foo{
6963 void run(){
6964 int x = 6;
6965 Link->Jump = x / MY_CONSTANT;
6966 }
6967 }
6968
6969Correct the value of your constant. Perhaps you meant to use a variable?
6970
6971Note that only division by a CONSTANT zero can be detected at compile time.
6972The following code, for instance, compiles with no errors but will generate script errors during execution.
6973
6974 Example:
6975
6976 int x = 0;
6977 int y;
6978 y = 1/x;
6979
6980
6981
6982
6983T20: Truncation of constant x.
6984
6985Constants can only be specified to four places of decimal precision, withing the legal range of values.
6986Any extra digits are simply ignored by the compiler, which then issues this warning.
6987
6988Any values greater than MAX_CONSTANT, or less then MIN_CONSTANT will result in this error.
6989
6990## Applies to variables, but does not throw an error:
6991Both floats and ints can only be specified to four places of decimal precision.
6992Any extra digits are simply ignored by the compiler, which then issues this warning.
6993
6994Any values greater than MAX_VARIABLE, or less then MIN_VARIABLE will result in this error.
6995
6996########
6997
6998T21: Could not match type signature 'foo'.
6999
7000When calling a function, you used the wrong number, or types, of parameters.
7001The compiler can determine no way of casting the parameters of a function call so that they
7002match the type signature of a declared function.
7003
7004For instance, in the following snippet
7005Code:
7006
7007int x = Sin(true);
7008
7009since true cannot be cast to a float, this function call cannot be matched to the library function Sin, triggering this error.
7010
7011
7012T22: Two or more functions match type signature 'foo'.
7013
7014If there is ambiguity as to which function declaration a function call should matched to,
7015the compiler will attempt to determine the "best fit."
7016These measures are however occasionally still not enough. Consider for instance the following snippet:
7017Code:
7018
7019void foo(int x, bool y) {}
7020void foo(bool x, int y) {}
7021foo(1,1);
7022
7023matching either of the two foo declarations requires one cast, so no match can be made.
7024In contrast, the following code has no error:
7025Code:
7026
7027void foo(int x, bool y) {}
7028void foo(bool x, bool y) {}
7029foo(1,1);
7030
7031(The first foo function is matched.)
7032
7033It is best to design functions so that noambiguity is possible, by addign extra params, to change the signature or by using
7034different identifiers (function names) when using more params is not desirable.
7035
7036T23: This function must return a value.
7037
7038All return statements must be followed by an expression if the enclosing function returns a value.
7039Note that the compiler does NOT attempt to verify that all executions paths of a function with non-void
7040return type actually returns a value; if you fail to return a value, the return value is undefined.
7041For instace, the following is a legal (though incorrect) ZScript program:
7042
7043int foo() {}
7044
7045/* I don't believe anythign ever returns this error.
7046I've seen functions with int/float/bool types, and no returns compile, without errors.
7047Perhaps we should fix this, and issue a warning during compilation? */
7048
7049T25: Constant bitshift by noninteger amount; truncating to nearest integer.
7050
7051The bitshift operators (<< and >>) require that their second parameters be whole integers.
7052
7053T27: Left of the arrow (->) operator must be a pointer type (ffc, etc).
7054
7055It makes no sense to write "x->foo" if x is of type int.
7056You may only use the dereference (->) operator on pointer types.
7057
7058T28: That pointer type does not have a function 'foo'.
7059
7060You tried to use the dereference operator (->) to call a function that does not exist for the pointer type being dereferenced.
7061Check the list of member variables and functions and verify you have not mistyped the function you are trying to call.
7062
7063This generally occurs when calling internal functions, using the incorrect class, or namespace, such as:
7064
7065Game->Rectangle() instead of Screen->Rectangle()
7066
7067The extra std.zh component 'shortcuts.zh' assists in preventing this error type.
7068
7069
7070T29: That pointer type does not have a variable 'foo'.
7071
7072You tried to use the dereference operator (->) to call a member variable that does not exist for the pointer type being dereferenced.
7073Check the list of member variables and verify you have not mistyped the variable you are trying to call.
7074
7075This generally occurs when calling internal variables, using the incorrect class, or namespace, such as:
7076
7077Link->D[] instead of Screen->D[]
7078
7079/* The extra std.zh component 'shortcuts.zh' assists in preventing this error type.
7080Probaby not, as this requires silly amounts of functions to handle variables with identical identifiers.
7081C'est la vie. perhaps we'll do it, but I really am not fond of the idea. */
7082
7083As above, but the member variable you tried to access does not exist.
7084
7085Error T31: The index of 'foo' must be an integer.
7086
7087/* This has been deprecated, so who cares? */
7088
7089
7090T36: Cannot change the value of constant variable 'foo'.
7091
7092You cannot assign a CONSTANT to another value.
7093
7094T37: Global variables can only be initialized to constants or globals declared in the same script.
7095You cannot (directly) simultaneously declare, and initialise a global value using the value of a variable at
7096the scope of another script, or function.
7097
7098Example:
7099int x = script.a;
7100ffc script foo{
7101 int a = 6;
7102 void run(){
7103 for ( int q = 9; q < Rand(15); q++ ) a++;
7104 }
7105}
7106
7107This is ILLEGAL. You cannot initialise the value of the global variable 'x' using the local value
7108of 'a' in the ffc script 'foo'.
7109
7110/* I believe this is deprecated, as I do not believe that script level declarations remain legal */
7111
7112T45 (old version, T38): Arrays can only be initialized to numerical values
7113You attempted to declare an array using a floating point value (e.g. 10.5), constant or equation,
7114rather than a numeric literal.
7115
7116
7117 Consider that you want to declare an array with an explicit size of '40':
7118 These are ILLEGAL:
7119 int my_arr[26+14];
7120 const int CONSTANT = 30;
7121 int my_arr[CONSTANT];
7122 int my_arr[CONSTANT/2+20]
7123
7124 YOu must declare an arrray with a numeric literal:
7125 int my_array[40];
7126 This is the only legal way to declare the size of an array as of 2.50.2.
7127
7128
7129#####################
7130## Specific Errors ##
7131## @Generation ##
7132#####################
7133
7134
7135G33: Break must lie inside of an enclosing for or while loop.
7136
7137The 'break' keyword aborts the loop (in a for, while, or do statement) in which it is called.
7138You must be in a loop to break out of one, so calling 'break' outside of a loop is illegal.
7139
7140
7141G34: Continue must lie inside of an enclosing for or while loop.
7142
7143The 'continue' keyword halts a loop, and repeats the loop from its head (in a for, while, or do statement) in which it is called.
7144You must be in a loop to continue one, so calling 'continue' outside of a loop is illegal.
7145
7146As the above error, but with the continue keyword. Continue aborts the current iteration of the loop and skips to the next iteration.
7147
7148
7149##################
7150## Array Errors ##
7151##################
7152
7153Error A42 (old, Error O1): Array is too small. ( Converting to A42 in 2.50.3 )
7154You attempted to declare an array, with a set of values, where the number of values in the set
7155exceeds an explicit array size declaration:
7156
7157int foo[4]={1,2,3,4,5};
7158The declared size is '4', but you tried to initialise it with five elements.
7159
7160/* THis doesn't seem right, as this seems to be covered by Err 02. Check the source to see what causes this. */
7161
7162Error O2: Array initializer larger than specified dimensions. ( Converting to A43 in 2.50.3)
7163You attempted to initialise an array, with a set of values, where the number of values in the set
7164exceeds an explicit array size declaration:
7165
7166int foo[4]={1,2,3,4,5};
7167The declared size is '4', but you tried to initialise it with five elements.
7168
7169Error O3: String array initializer larger than specified dimensions, space must be allocated for NULL terminator.
7170( Convering to A44 in 2.50.3 )
7171YOu attempted to seclare a QUOTEDSTRING of an explicit size, but you didn;t add space
7172for the NULL terminator; or you used more chars than you allocated:
7173
7174int my_string[17]="This is a string.";
7175 THis allocates only enough indices for the chars, but not for the NULL terminator.
7176 The array size here needs to be 18.
7177int my_string[12]="THis is a string.";
7178 You tried to initialise a QUOTEDSTRING that is longer than the array size.
7179 The minimum array size for this is '18'.
7180
7181 It is generally best either to declare strings with an implicit size (set by the initialiser):
7182 int my_string[]="This is a string";
7183 This reads the nuber of chars, adds one to the count (for NULL), and sizes the array to 18.
7184 ...or...
7185 Declare the string with an arbitrarily large size:
7186 int my_string[256]="This is a string";
7187 This reserves 256 chars. Only 18 are used, and the rest of the indices
7188 are initialised as '0' (NULL). YOu may later populate the unused space, if desired.
7189
7190
7191#################
7192## Misc Errors ##
7193#################
7194
7195FATAL FATAL ERROR I0: bad internal error code
7196A fallback error if no other type matches the problem.
7197
7198/* I have no idea what causes this. Be afraid, very afraid. */
7199
7200/* OTHER ERRORS
7201Document any further error codes here.
7202We need to convert the array errors from raw numeric, to A** codes.
7203*/
7204
7205########################
7206## OPERATIONAL ERRORS ##
7207###################################################################################################
7208## These errors occur only during the operation of script execution (i.e. when running a script, ##
7209## in Zelda Classic while playing a quest). ##
7210## --------------------------------------------------------------------------------------------- ##
7211## In ZC versions 2.50.2, and later, operational script errors will return the ID of the script ##
7212## from which they were generated. ##
7213###################################################################################################
7214
7215//! These errors will be reported to allegro.log (or the ZConsole) when scripts run.
7216
7217
7218
7219////////////////////
7220/// Stack Errors ///
7221////////////////////
7222
7223 "Stack over or underflow, stack pointer = %ld\n"
7224
7225* !? How should I describe this, and give examples?
7226
7227 "Invalid ZASM command %ld reached\n"
7228
7229Stack instruction countber reached, or exceeded. The stack counter is an unsigned int, so it's maximum value is 65536.
7230You have isused more instructiosn this frame than the instructon counter can ahndle. Look through your code for
7231something that may be doing this.
7232
7233////////////////////
7234/// Array Errors ///
7235////////////////////
7236
7237 "Invalid value (%i) passed to '%s'\n"
7238 "Invalid index (%ld) to local array of size %ld\n"
7239
7240You attempted to reference an array index that is either too small, or too large.
7241Check the size of your array, and try again.
7242Perhaps you have a for loop, or other loop that is parsing the array, and trying to read beyond its index ranges.
7243
7244
7245 "Invalid pointer (%i) passed to array (don't change the values of your array pointers)\n"
7246
7247Array pointers values in operation are 1 through 4095, ( and 4096 to 8164? as declared global pointers ?).
7248An array may not have a pointer of '0', nor may you reference an array for which a pointer does not exist.
7249Often, this error is caused by attempting to reference an array that you created, without updating the saved game slot
7250as the old save does not have the array allocated, but the script is attempting to reference its global ID.
7251
7252 "Script tried to deallocate memory at invalid address %ld\n"
7253 "Script tried to deallocate memory that was not allocated at address %ld\n"
7254
7255/* Script attempted to change the value of an array index // that does not exist // due to the inability to declare an array
7256because too many registers are in use?
7257
7258
7259 "You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n"
7260You attempted to read, or write to a Screen->D[register] that was less than 1, or greater than 10.
7261Check for loops, and vriables that read/write to Screen->D for any that can fall outside the legal range.
7262
7263 "Array initialized to invalid size of %d\n"
7264You attempted to init array to a size less than 1, or a size greater than 214747, or;
7265You attempted to init array with a constant, a variable, a formula, or with a floating point value.
7266Arrays may ONLY be initialised with numeric literals (integers only) between 1 and 214747.
7267
7268 "%d local arrays already in use, no more can be allocated\n", MAX_ZCARRAY_SIZE-1);
7269The maximum number of arrays in operation at one time is 4095.
7270
7271"Invalid pointer value of %ld passed to global allocate\n"
7272 !
7273
7274/////////////////////////////
7275/// Object Pointer Errors ///
7276/////////////////////////////
7277
7278 "Invalid NPC with UID %ld passed to %s\nNPCs on screen have UIDs "
7279 "Invalid item with UID %ld passed to %s\nItems on screen have UIDs "
7280 "Invalid lweapon with UID %ld passed to %s\nLWeapons on screen have UIDs "
7281 "Invalid eweapon with UID %ld passed to %s\nEWeapons on screen have UIDs "
7282
7283 "Script attempted to reference a nonexistent NPC!\n"
7284 "You were trying to reference the %s of an NPC with UID = %ld; NPC on screen are UIDs "
7285
7286 "Script attempted to reference a nonexistent item!\n"
7287 "You were trying to reference an item with UID = %ld; Items on screen are UIDs: "
7288
7289 "Script attempted to reference a nonexistent LWeapon!\n"
7290 "You were trying to reference the %s of an LWeapon with UID = %ld; LWeapons on screen are UIDs "
7291
7292 "Script attempted to reference a nonexistent EWeapon!\n"
7293 "You were trying to reference the %s of an EWeapon with UID = %ld; EWeapons on screen are UIDs "
7294
7295You attempted to reference a game object that has a maximum legal range of 1 to 255.
7296It is possible that you tried to read outside that range, or that the pointer that you were loading is not valid.
7297Check NumItems(), NumLWeapons(), NumEWeapons(0, and NumNPCs() before referencing them; and verify that the object ->IsValid()
7298Check for loops that may attempt ro reference items outside of the range that actually exist.
7299Look for any for loops that access these objects, that start, or end at zero.
7300
7301The best way to ensure this does not occur, is to make a for loop as follows:
7302
7303 for ( int q = 1; q < Screen->NumLWeapons; q++ )
7304
7305 //or//
7306
7307 for ( int q = Screen->NumLWeapons(); q > 0; q-- )
7308
7309...replacing NumLWeapons() withthe appropriate type that you are attempting to load.
7310
7311You may be attempting to refrence a pointer that has fallen out of scope.
7312You may be attempting to reference a pointer that is no longer valid, or has been removed.
7313Check ( pinter->IsValid() ) by itself, to ensure this does not occur:
7314
7315 if ( pointer->IsValid ) {
7316 if ( pointer->ID == LW_FIRE ) //Do things.
7317 }
7318
7319This helps to prevent loading invalid pointers.
7320
7321////////////////////////////////
7322/// Maths and Logical Errors ///
7323////////////////////////////////
7324
7325"Script attempted to divide %ld by zero!\n"
7326"Script attempted to modulo %ld by zero!\n"
7327
7328"Script attempted to pass %ld into ArcSin!\n"
7329"Script attempted to pass %ld into ArcCos!\n"
7330"Script tried to calculate log of 0\n"
7331"Script tried to calculate log of %f\n"
7332"Script tried to calculate ln of 0\n"
7333"Script tried to calculate ln of %f\n"
7334"Script attempted to calculate 0 to the power 0!\n"
7335"Script attempted to calculate square root of %ld!\n"
7336
7337Look for scripts that pass a variable into these functions, or use a variable in a mathematical operation, that
7338may be zero at any point, and correct it to ensure that it is never zero, or that it is never illegal for the type of
7339mathematical operation you wish to perform.
7340
7341Chweck for any hardcoded values, or constants that are in use with these functions that may be illegal, or irrational.
7342
7343////////////////////////////////
7344/// System Limitation Errors ///
7345////////////////////////////////
7346
7347"Couldn't create lweapon %ld, screen lweapon limit reached\n"
7348"Couldn't create eweapon %ld, screen eweapon limit reached\n"
7349"Couldn't create item \"%s\", screen item limit reached\n"
7350"Couldn't create NPC \"%s\", screen NPC limit reached\n"
7351
7352You may create a maximum of 255 of any one object type on the screen at any one time.
7353Look for anything that is generating extra pointers, and add a statement such as:
7354 if ( Screen->NumNPCs() < 255 )
7355
7356 "Max draw primitive limit reached\n"
7357The maximum number of drawing function calls, per frame, is 1,000.
7358
7359/////////////////////
7360/// String Errors ///
7361/////////////////////
7362
7363 "Array supplied to 'Game->GetDMapMusicFilename' not large enough\n"
7364 "Array supplied to 'Game->GetSaveName' not large enough\n"
7365 "String supplied to 'Game->GetSaveName' too large\n"
7366 "Array supplied to 'Game->GetMessage' not large enough\n"
7367 "Array supplied to 'Game->GetDMapName' not large enough\n"
7368 "Array supplied to 'Game->GetDMapTitle' not large enough\n"
7369 "Array supplied to 'Game->GetDMapIntro' not large enough\n"
7370 "Array supplied to 'itemdata->GetName' not large enough\n"
7371 "Array supplied to 'npc->GetName' not large enough\n"
7372
7373The buffer for these actions must be equal to the size of the text to load into it, plus one, for NULL.
7374
7375If you wish to load a game name, with Game->LoadSaveName(), and the name on the file select is FOO, you must
7376supply a buffer with a size of [4] to hold it. (Three chars in the name, plus one for NULL.)
7377
7378////////////////////
7379/// Misc. Errors ///
7380////////////////////
7381
7382 "Waitdraw can only be used in the active global script\n"
7383You attempted to call Waitdrw() in an ffc script, or an item script; or in your global OnContinue,
7384global OnExit, or ~Init scripts.
7385You may only use the Waitdraw() function from a global active script.
7386
7387 "No other scripts are currently supported\n"
7388? You should never see this. May indicate that you have attempted to load more scripts than ZC can handle.
7389
7390
7391 "Invalid value (%i) passed to '%s'\n"
7392!? WHat should we put here?
7393
7394 "Global scripts currently have no A registers\n"
7395This error can only occur if you are coding ZASM, and attempt to utilise an Address register with a global script.
7396
7397////////////////////////
7398/// Script Reporting ///
7399////////////////////////
7400
7401 //Events that will be recorded if Quest Rule 'Log Game Events to Allegro.log' is enabled:
7402
7403"Script created lweapon %ld with UID = %ld\n"
7404"Script created eweapon %ld with UID = %ld\n"
7405"Script created item \"%s\" with UID = %ld\n"
7406"Script created NPC \"%s\" with UID = %ld\n"
7407
7408When any new game object is generated by script, and reporting is enabled, the lweapon, and the name of the
7409script that generated it, will be reported to allegro.log.
7410
7411
7412///////////////////////////
7413/// Documentation Staff ///
7414///////////////////////////
7415
7416ZScript documentation generated, and maintained by:
7417DarkDragon (retired)
7418Gleeok
7419Saffith
7420ZoriaRPG