-
Notifications
You must be signed in to change notification settings - Fork 0
/
zscript.txt
6242 lines (4761 loc) · 215 KB
/
zscript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//Docs for 2.53.1, 2.55.0
//Rev. 0.7.6; 27th October, 2019
Search for !#! to find areas that require completion.
//===================================================================================
// --- ZScript built-in functions and variables ---
//===================================================================================
/*
* These functions are all INTERNAL to ZQuest. They require no header
* or other import directives to work, and are all direct representations
* of ZASM instructions.
*
* These functions and commands are the BASIC BUILDING BLOCKS of ZScript:
* While they require no other functions to work, ALL other functions
* in headers (such as std.zh) RELY, and OPERATE using these functions.
*
* Thus, it is essential to know what each of these does, how they work,
* and how to use them.
*
* For other included functions, that are not internal (i.e. external functions)
* please read the documentation specific to each header. These are individual
* files (e.g. std.txt), however if you wish to view all the pre-packaged ZScript
* functions, and commands, you may view the EXTENDED DOCUMENTATION, as
* those documentation files contain all of the 'Essential ZScript' that
* you will want to use.
*
* Where possible, the ZASM instruction used by the functions, and the
* commands detailed herein are listed inline with the entry for the related
* function / command. Full (public) ZASM documentation is, sadly incomplete.
*
* Note: Functions and variables other than global functions are properties
* of **objects**. Objects are divided into TYPED POINTER CLASSes, and the
* the syntax for using them is:
*
* [object name]->[property]
*
* where "[object name]" is the object's name (e.g. Link, Game, Screen)/
* and "[property]" is the function.
*
* Example:
* void GetCurDMap() is a Game property, and is called as:
*
* Game->GetCurDMap();
*
* "Link", "Screen" and "Game" are always available and don't need to be
* instantiated, while you must initialise other classes, such as ffc, item,
* and npc.
*
* ZScript functions are of the types: int, float, bool, and void. Of these,
* only void does not return a value. (The void type is normally used to run
* a series of instructions, or to set values). The other types retrun values
* appropriate to their type.
*
* Note: In the following, "int" indicates that a parameter is truncated by a
* function to an integer, or that the return value will always be an integer
* however, ZScript itself makes no distinction between int and float types.
*/
/************************************************************************************************************/
//////////////////
/// ZASM Flags ///
//////////////////
ZASM uses a series of special flags, to determine how it should follow logical instructions,
including the following:
SCRIPT FLAGS
TRUEFLAG : A condition in the script, is true
MOREFLAG : Must be set manually with ZASM.
FALSEFLAG : Must be set namually with ZASM.
LESSFLAG : Must be set manually with ZASM.
Instructions
SETTRUE : Set the Script Flag TRUEFLAG.
SETTRUE Sets a true condition for the Assembler, if a COMPARERV and COMPARER validate.
This is used when making statements in ZScript.
SETFALSE: Set the Script Flag FALSEFLAG: ZScript does not do this.
SETMORE : Set the Script FLag MOREFLAG: ZScript does not do this.
SETLESS : Set the Script Flag LESSFLAG: ZScript does not do this.
These flags are used in evaluation instructions, to determine if an instruction should run.
Examples of these are as follows:
GOTOTRUE: Executes the GOTO instruction only if the Script Flag TRUEFLAG is enabled.
GOTOFALSE: Executes the GOTO instruction only if the Script Flag FALSEFLAG is enabled.
GOTOMORE: Executes the GOTO instruction only if the Script Flag MOREFLAG is enabled.
GOTOLESS: Executes the GOTO instruction only if the Script Flag LESSFLAG is enabled.
In contrast, GOTO/GOTOR ignore all flags, and conditions.
ZScript always compiles down to GOTO, GOTOR, and GOTOTRUE instructions.
The other FLAG-typed GOTO instruction types are valid only in ZASM, and serve no useful purpose.
GOTOLESS, GOTOMORE, and GOTOFALSE are effectively deprecated.
//================================================== =====
//--- Instruction Processing Order and General Timing ---
================================================== =======
1. Instructions in Global script Init (if starting a new game)
2. Instructions in Global Script OnContinue (is resuming a game)
3. Instructions from FFCs that run on screen init, excluding draw instructions.
Note: Instructions are handled on a per-ffc basis, in ID order; so a script on ffc ID 1 runs,
then a script on ffc ID 2, up to ffc ID 32. If an ffc has no script, it is skipped.
4. Instructions immediately inside the run() function of a global active script, if the game has just loaded.
5. Instructions in the global active script's infinite loop prior to Waitdraw,
6. Instructions from an ffc script positioned after (an illegal)
Waitdraw() instruction in that script from the previous frame.
Note: Requires being on at least the second frame of a game session.
7. Screen bitmap drawing.
8. Enqueued Script Drawing from the global active script, (and from ffcs on the previous frame).
9. Drawing Instructions in the global active script prior to Waitdraw().
10. Instructions in an ffc script, excluding draw commands.
Note: Instructions are handled on a per-ffc basis, in ID order; so a script on ffc ID 1 runs,
then a script on ffc ID 2, up to ffc ID 32. If an ffc has no script, it is skipped.
11. Screen Scrolling (2.50.2, or later)
12. Waitdraw() in a global active script.
13. Engine writing to Link->Dir and Link->Tile.
14. FFCs enqueue draws for the next frame.
Note: Instructions are handled on a per-ffc basis, in ID order; so a script on ffc ID 1 runs,
then a script on ffc ID 2, up to ffc ID 32. If an ffc has no script, it is skipped.
15. Instructions from item action scripts.
16. Instructions from item collect scripts.
17. Instructions in the global active script, called after Waitdraw()
17(b). Screen Scrolling ( 2.50.0, and 2.50.1 )]
18. Instructions in an OnExit script, if the game is exiting.
19. Return to (3).
//=================
//--- Pointers ---
//=================
Global array pointers start at 4096 (when traced). These are added in escalating value, but in the reverse-order
of declaration. e.g. The last declared array will be ID 4096.
/************************************************************************************************************/
////////////////////////
/// Operator Symbols ///
////////////////////////
ZScript supports value input as decimal, hexidecimal, and binary.
To input hexidecimal values, preface them with '0x'. Thus, '0x0F' for '16'.
To input binary balues, end them with a lowercase 'b'. Thus, '11b' for '3'.
Name Sign ZASM (R) ZASM (V) Definition
PLUS + ADDR<><> ADDV<><> Adds a value a + b, a + 3
MINUS - SUBR<><> SUBV<><> Subtracts a value a - b, a - 2
INCREMENT ++ Increments a value by '1'
DECREMENT -- Decreases a value by '1'
MULTIPLY * MULTR<><> MULTV<><> Multiplies values a * b
DIVIDE / DIVR<><> DIVV<><> Divides values a / b
MODULUS % Returns the remainder of integer division of 4 % 2
NOT ! NOT<> Inverse logic boolean operator.
if ( !var1 == 0 ) returns true if var1 is zero,
and false if var1 is non-zero
EQUALS = SETR<><> SETV<><> Sets a value to another value a = 4
EXACTLY EQUALS == Compares value a == b and returns if they match.
NOT EQUALS != Compares values a != b and returns if they do not match,
LESSTHAN < Comapres a < b and returns if a is less then b.
MORETHAN > Compares a > b and returns if a is more than b.
LOGICAL OR || Boolean logic, Or.
LOGICAL AND && Boolean Logic And.
SET ADDRESS ARG SETA1<><>
SETA2<><>
GET ADDRESS ARG GETA1<><>
GETA2<><>
Note: LOGICAL XOR (^^) is not valid in ZScript, but you may simulate it with custom functions.
/////////////////////////
/// Bitwise Operators ///
/////////////////////////
Reminder: You may reference a binary value using a numeric sequence, ending in 'b':
0100010b
('34' decimal)
Or ZScript Symbol ZASM Instructions:
| ORV<><>
ORR<><>
And ZScript Symbol ZASM Instructions:
& ANDR<><>
ANDV<><>
Not ZScript Symbol ZASM Instructions:
~ BITNOT<>
Left Shift:
ZScript Symbol ZASM Instructions
<< LSHIFTV<><>
LSHIFTR<><>
Right Shift:
ZScript Symbol ZASM Instructions
>> RSHIFTV<><>
RSHIFTR<><>
Xor ZScript Symbol ZASM Instructions:
^ XORV<><>
XORR<><>
Nor ZScript Symbol ZASM Instructions:
~| NORV<><>
NORR<><>
XNor ZScript Symbol ZASM Instructions:
~^ XNORV<><>
XNORV<><>
Nand ZScript Symbol ZASM Instructions:
~& NANDV<><>
NANDR<><>
/************************************************************************************************************/
//========================
//--- Global Functions ---
//========================
/////////////////////////
/// General Functions ///
/////////////////////////
void Waitdraw(); ZASM Instruction:
WAITDRAW
/**
* Halts execution of the script until ZC's internal code has been run (movement,
* collision detection, etc.), but before the screen is drawn. This can only
* be used in the active global script.
* Waitdraw() may only be called from the global active script; not from FFC scripts.
* The sequence of ZC actions is as follows:
* FFCs (in numerical sequence, from FFC 01, to FFC 32)
* Enemies
* EWeapons
* Link
* LWeapons
* Hookshot
* Collision Checking
* Store Link->Input / Link->Press
* Waitdraw()
* Drawing
* Rendering of the Screen
* Screen Scrolling
* Drawing from FFCs
*
* Note: Drawing from FFCs technically occurs with other Drawing, but as it is issued after Waitdraw(),
* it is offset (a frame late) and renders after screen scrolling, and after any other drawing in the same
* frame as draw instructions from ffcs are called. To ensure that drawing done by ffcs is in sync with
* other drawing, it is imperative to call it from your global script, using the ffc to trigger global
* conditions that cause global drawing instructions that are called before Waitdraw() in your global
* active script to evaluate true.
*
* Anything placed after Waitdraw() will not present graphical effects until the next frame.
* It is possible { ! CHECK } to read/store Link->Tile, Link->Dir and other variables *after* Waitdraw()
* in one frame, and then use these values to modify other pointer members so that they are drawn correctly
* at the next execution of Waitdraw().
*
*
*/ Example Use:
Waitdraw();
//! Submit bug report that Link->Dir and Link->Tile are incorrect before Waitdraw.
*//////////////////////////////
* Waitdraw() in ffc scripts ///
* --------------------------///
* Althouth technically illegal, it is possible to call Waitdraw() in an *ffc script*. Doing this has the
* following effects, and/or consequences:
*
* 1. The Compiler will report an error, and print the error to Allegro log:
* 'Warning: Waitdraw() may only be used in global scripts.'
* 2. Any instruction sint he ffc script that are called before the Waitdraw() instruction in the ffc script
* will run this frame, after Waitdraw() in your global active script.
* 3. Any instructions called *after* Waitdraw() in the ffc script, will run BEFORE BOTH Waitdraw() in your
* global active script, and BEFORE any other instructions in your global active script's infinite loop.
*
* This behaviour may change in future versions of ZC, and using Waitdraw() in ffc scripts is not advised.
*///////////////////////////////
* Waitdraw() in item scripts ///
* ---------------------------///
* Althouth technically illegal, it is possible to call Waitdraw() in an item sctipt. Doing this has the
* following effects, and/or consequences:
*
* 1. The Compiler will report an error, and print the error to Allegro log:
* 'Warning: Waitdraw() may only be used in global scripts.'
* 2.
*
* This behaviour may change in future versions of ZC, and using Waitdraw() in item scripts is not advised.
/************************************************************************************************************/
void Waitframe(); ZASM Instruction:
WAITFRAME
/**
* Temporarily halts execution of the current script. This function returns at
* the beginning of the next frame of gameplay.
* Slots 1, 3 and 4 Global scripts and item scripts only execute for one frame,
* so in those scripts Waitframe() is essentially Quit().
* It is safe to call Waitframe in the active global script.
* A Waitframe is required in all infinite loops (e.g. while(true) ) so that ZC may
* pause to break in order to advance to the next frame, then resume the loop from the start.
*
*/ Example Use:
Waitframe();
*///////////////////////////////
* Waitdraw() in item scripts ///
* ---------------------------///
* Althouth technically legal, it is invalid to call Waitframe() in an item sctipt. Doing this has the
* following effects, and/or consequences:
*
* 1. The script will prematurely exit.
*
* Calling Waitframe() in an item script is effectively identical to calling Quit(), however this behaviour
* may change in future versions of ZC, and using Waitframe() in item scripts is not advised.
/************************************************************************************************************/
void Quit(); ZASM Instruction:
QUIT
/**
* Terminates execution of the current script. Does not return.
* Caution: If called from a global script, the script itself exits.
*
*/ Example Use:
Quit();
/************************************************************************************************************/
////////////////////
/// Modify Tiles ///
////////////////////
void CopyTile(int srctile, int desttile); ZASM Instruction:
COPYTILERR d2,d3
COPYTILEVV
COPYTILERV
COPYTILEVR
/**
* Copies the tile specified by scrtile onto the tile space
* specified by desttile. The valid tile value range is 0 to 65519.
* This change is temporary within the quest file
* and not be retained when saving the game.
*
*/ Example Use:
CopyTile(312,11614);
Copies tile 312, to tile 11614. Tiles 312, and 11614 will be identical.
/** TIP **
* CopyTile may be used to change Link's tile, by copying a tile onto whatever tile ZC is
* using as a source for Link->Tile
* Thus, although you cannot write directly to Link->Tile, you can write to the actual tile
* that is being used for this Link attribute, and you can do this for any other game graphic
* that you need to change.
*
* When doing this, it is important to read Link->Dir or Link->Flip, *after* Waitdraw() and
* perform the CopyTile() operation immediately thereafter.
*/
/************************************************************************************************************/
void SwapTile(int firsttile, int secondtile); ZASM Instruction:
SWAPTILERR d2,d3
SWAPTILEVV
SWAPTILEVR
SWAPTILERV
/**
* Swaps the two tiles specified by firsttile and secondtile.
* The valid tile value range is 0 to 65519.
* This change is *TEMPORARY* within the quest file
* and will not be retained when saving the game.
*
*/ Example Use:
SwapTile(312,11614);
Changes tile 11614 into tile 312; and tile 312 into tile 11614, transposing their positions.
/************************************************************************************************************/
void ClearTile(int tileref); ZASM Instruction:
CLEARTILER <d3>
CLEARTILEV
/**
* Erases the tile specified by tileref.
* This change is temporary within the quest file
* and will not be retained when saving the game.
* Tiles are not / are (!check!) shifted upward to adjust for the cleared tile.
*
*/ Example Use:
ClearTile(21362);
Clears tile 21362 by ( blanking it to colour 0 ) | ( removing it and shifting all tiles
thereafter upward ).
/************************************************************************************************************/
//Overlay Tile
//! ZASM-only for this version of ZC.
void OverlayTile()
OVERLAYTILEVV
OVERLAYTILEVR
OVERLAYTILERV
OVERLAYTILERR
/************************************************************************************************************/
///////////////
/// Tracing ///
///////////////
void Trace(float val); ZASM Instruction:
TRACER d3
TRACEV
/**
* Prints a line containing a string representation of val to allegro.log.
* Useful for debugging scripts. You may trace int, and float types.
* For b oolean values, see TraceB() below.
* Values printed to allegro.log no not incorporate any spacing, or carriage
* returns. You must manually add these into your commands.
* Int values are not truncated when printed, and will always have four leading
* zeros after the decimal point.
* To add new lines (carriange returns), see TraceNL() below.
*
*/ Example Use:
int val = 4;
Trace(val);
Prints 4.000 to allegro.log
/************************************************************************************************************/
void TraceB(bool state); ZASM Instruction:
TRACE2R d3
TRACE2V
/**
* Prints a boolean state to allegro.log. Works as trace() above, but prints 'true'
* or 'false' to allegro.log
*
*/ Example Use:
bool test = true;
TraceB(test);
Prints 'true' to allegro.log.
/************************************************************************************************************/
void TraceToBase( int val, int base, ZASM Instruction:
int mindigits ); TRACE3
/**
* Prints a line in allegro.log representing 'val' in numerical base 'base',
* where 2 <= base <= 36, with minimum digits 'mindigits'.
* (Base must be at least base-2, and at most, base-36)
* Can be useful for checking hex values or flags ORed together, or just to trace
* an integer value, as Trace() always traces to four decimal places.
* mindigits specifies the minimum number of integer digits to print.
* Unlike Trace(), Decimal values are not printed. TraceToBase *does not* handle floats.
* If you specify a floating point value as arg 'val', it will be Floored before conversion.
*
*/ Example Use:
TraceToBase(20,8,1);
Converts (decimal) d20 to base-8 (o24 in base-8) and prints value '024' to allegro.log
TraceToBase(50,16,1);
Converts (decimal) d50 to base-16 (0x32 hexadecimal) and prints value '0x32' to allegro.log.
/************************************************************************************************************/
void ClearTrace(); ZASM Instruction:
TRACE4
/**
* Clears allegro.log of all current traces and messages from Zelda Classic/ZQuest.
* Works on a per-quest, per-session basis. Values recorded from previous sessions are not erased.
*
*/ Example Use
ClearTrace();
/************************************************************************************************************/
void TraceNL(); ZASM Instruction:
TRACE5
/**
* Traces a newline to allegro.log
* This inserts a carriage return (as if pressing return/enter) into allegro.log
* and is useful for providing formatting to debugging.
*
*/ Example Use:
TraceNL();
Prints a carriage return to allegro.log.
/************************************************************************************************************/
void TraceS(int s[]); ZASM Instruction:
TRACE6 d3
/**
* Works as Trace() above, but prints a full string to allegro.log, using the array pointer
* (name) as its argument.
* Maximum 512 characters. Functions from string.zh can be used to split larger strings.
*
*/ Example Use:
int testString[]="This is a string.";
TraceS(testString);
Prints 'This is a string.' to allegro.log.
/************************************************************************************************************/
///////////////////////
/// Array Functions ///
///////////////////////
int SizeOfArray(int array[]); ZASM Instruction:
ARRAYSIZE d2
/**
* Returns the index size of the array pointed by 'array'.
* Works only on int, and float type arrays. Boolean arrays are not supported.
* Useful in for loops.
*
*/ Example Use:
int isAnArray[216];
int x;
x = SizeOfArray(isAnArray);
The value of x becomes 216.
/************************************************************************************************************/
//////////////////////////////
/// Mathematical Functions ///
//////////////////////////////
int Rand(int n); ZASM Instruction:
RNDR<><> d2,d3
RNDV<><>
/**
* Computes and returns a random integer from 0 to n-1,
* or a negative value between n+1 and 0 if 'n' is negative.
*
* Note: The paramater 'n' is an integer, and any floating point (ZScript float)
* value passed to it will be truncated (floored) to the nearest integer.
* Rand(3.75) is identical to Rand(3).
*/ Example Use:
Rand(40);
Produces a random number between 0 and 39.
Rand(-20);
produces a random number between -19 and 0.
/************************************************************************************************************/
float Sin(float deg); ZASM Instruction:
SINR<><> d2,d3
SINV<><>
/**
* Returns the trigonometric sine of the parameter, which is interpreted
* as a degree value.
*
*/ Example Use:
float x = Sin(32);
x = 0.5299
/************************************************************************************************************/
float Cos(float deg); ZASM Instruction:
COSR<><> d2,d3
COSV<><>
/**
* Returns the trigonometric cosine of the parameter, which is
* interpreted as a degree value.
*
*/ Example Usage:
float x = Cos(40);
x = 0.7660
/************************************************************************************************************/
float Tan(float deg); ZASM Instruction:
TANR<><> d2,d3
TANV<><>
/**
* Returns the trigonometric tangent of the parameter, which is
* interpreted as a degree value. The return value is undefined if
* deg is of the form 90 + 180n for an integral value of n.
*
*/ Example Use:
float x = Tan(100);
x = -5.6712
/************************************************************************************************************/
//!Sources: OMultImmediate, OArcSinRegister
//Is there a direct ZASM instruction equivalent, or does this function run as a routine?
float RadianSin(float rad);
/**
* Returns the trigonometric sine of the parameter, which is interpreted
* as a radian value.
*
*/ Example Use:
/************************************************************************************************************/
//!Sources: OMultImmediate, OCosRegister
//Is there a direct ZASM instruction equivalent, or does this function run as a routine?
float RadianCos(float rad);
/**
* Returns the trigonometric cosine of the parameter, which is
* interpreted as a radian value.
*
*/ Example Use:
/************************************************************************************************************/
float RadianTan(float rad);
/**
* Returns the trigonometric tangent of the parameter, which is
* interpreted as a radian value. The return value is undefined for
* values of rad near (pi/2) + n*pi, for n an integer.
*
*/ Example Use:
/************************************************************************************************************/
float ArcTan(int x, int y); ZASM Instruction:
ARCTANR<>
(Does ARCTANV exist?)
/**
* Returns the trigonometric arctangent of the coordinates, which is
* interpreted as a radian value.
*
*/ Example Use:
/************************************************************************************************************/
float ArcSin(float x); ZASM Instruction:
ARCSINR<><>
ARCSINV<><> (Can't find this in the source code)
ffasm.cpp line 217
/**
* Returns the trigonometric arcsine of x, which is
* interpreted as a radian value.
*
*/ Example Use:
/************************************************************************************************************/
float ArcCos(float x); ZASM Instruction:
ARCCOSR<><>
ARCCOSV<><>
/**
* Returns the trigonometric arccosine of x, which is
* interpreted as a radian value.
*
*/ Example Use:
/************************************************************************************************************/
float Max(float a, float b); ZASM Instruction:
MAXR<><>
MAXV<><>
/**
* Returns the greater of a and b.
*
*/ Example Use:
/************************************************************************************************************/
float Min(float a, float b); ZASM Instriction:
MINR<><>
MINV<><>
/**
* Returns the lesser of a and b.
*
*/ Example Use:
/************************************************************************************************************/
int Pow(int base, int exp); ZASM Instruction:
POWERR<><>
POWERV<><>
/**
* Returns base^exp. The return value is undefined for base=exp=0. Note
* also negative values of exp may not be useful, as the return value is
* truncated to the nearest integer.
*
*/ Example Use:
/************************************************************************************************************/
int InvPow(int base, int exp); ZASM Instruction:
IPOWERR<><>
IPOWERV<><>
/**
* Returns base^(1/exp). The return value is undefined for exp=0, or
* if exp is even and base is negative. Note also that negative values
* of exp may not be useful, as the return value is truncated to the
* nearest integer.
*
*/ Example Use:
/************************************************************************************************************/
float Log10(float val); ZASM Instruction:
LOG10<>
/**
* Returns the log of val to the base 10. Any value <= 0 will return 0.
*
*/ Example Use:
/************************************************************************************************************/
float Ln(float val); ZASM Instruction:
LOGE<>
/**
* Returns the natural logarithm of val (to the base e). Any value <= 0 will return 0.
*
*/ Example Use:
/************************************************************************************************************/
int Factorial(int val); ZASM Instruction:
FACTORIAL<>
/**
* Returns val!. val < 0 returns 0.
*
*/ Example Use:
/************************************************************************************************************/
float Abs(float val); ZASM Instruction:
ABS<>
/**
* Return the absolute value of the parameter, if possible. If the
* absolute value would overflow the parameter, the return value is
* undefined.
*
*/ Example Use:
/************************************************************************************************************/
float Sqrt(float val); ZASM Instruction:
SQROOTV<><>
SQROOTR<><>
/**
* Computes the square root of the parameter. The return value is
* undefined for val < 0.
* NOTE: Passing negative values to Sqrt() will return an error. See SafeSqrt() in std.zh
*/ Example Use:
int x = Sqrt(16);
x = 4
/************************************************************************************************************/
/************************************************************************************************************/
//====================================
//--- Game Functions and Variables ---
//====================================
class Game
int GetCurScreen(); ZASM Instruction:
CURSCR
/**
* Retrieves the number of the current screen within the current map.
*/ Example Use: !#!
/************************************************************************************************************/
int GetCurDMapScreen(); ZASM Instruction:
CURDSCR
/**
* Retrieves the number of the current screen within the current DMap.
*/ Example Use: !#!
/************************************************************************************************************/
int GetCurLevel(); ZASM Instruction:
CURLEVEL
/**
* Retrieves the number of the dungeon level of the current DMap. Multiple
* DMaps can have the same dungeon level - this signifies that they share
* a map, compass, level keys and such.
*/ Example Use: !#!
/************************************************************************************************************/
int GetCurMap(); ZASM Instruction:
CURMAAP
/**
* Retrieves the number of the current map.
*/ Example Use: !#!
/************************************************************************************************************/
int GetCurDMap(); ZASM Instruction:
CURDMAP
/**
* Returns the number of the current DMap.
*/ Example Use: !#!
/************************************************************************************************************/
int DMapFlags[]; ZASM Instruction:
DMAPFLAGSD
/**
* An array of 512 integers, containing the DMap's flags ORed (|) together.
* Use the 'DMF_' constants, or the 'DMapFlag()' functions from std.zh if you are not comfortable with binary.
*/ Example Use: !#!
/************************************************************************************************************/
int DMapLevel[]; ZASM Instruction:
DMAPLEVELD
/**
* An array of 512 integers containing each DMap's level
*/ Example Use: !#!
/************************************************************************************************************/
int DMapCompass[]; ZASM Instruction:
DMAPCOMPASSD
/**
* An array of 512 integers containing each DMap's compass screen
*/ Example Use: !#!
/************************************************************************************************************/
int DMapContinue[]; ZASM Instruction:
DMAPCONTINUED
/**
* An array of 512 integers containing each DMap's continue screen
*/ Example Use: !#!
/************************************************************************************************************/
int DMapMIDI[]; ZASM Instruction:
DMAPMIDID
/**
* An array of 512 integers containing each DMap's MIDI.
* Positive numbers are for custom MIDIs, and negative values are used for
* the built-in game MIDIs. Because of the way DMap MIDIs are handled
* internally, however, built-in MIDIs besides the overworld, dungeon, and
* level 9 songs won't match up with Game->PlayMIDI() and Game->GetMIDI().
*/ Example Use: !#!
/************************************************************************************************************/
void GetDMapName(int DMap, int buffer[]);
ZASM Instruction:
GETDMAPNAME
/**
* Loads DMap with ID 'DMap's name into 'buffer'.
* See std_constsnts.zh for appropriate buffer size.
*/ Example Use: !#!
/************************************************************************************************************/
void GetDMapTitle(int DMap, int buffer[]);
ZASM Instruction:
GETDMAPTITLE
/**
* Loads DMap with ID 'DMap's title into 'buffer'.
* See std_constants.zh for appropriate buffer size.
*/ Example Use: !#!
/************************************************************************************************************/
void GetDMapIntro(int DMap, int buffer[]);
ZASM Instruction:
GETDMAPINTRO
/**
* Loads DMap with ID 'DMap's intro string into 'buffer'.
* See std_constants.zh for appropriate buffer size.
*/ Example Use: !#!
/************************************************************************************************************/
int DMapOffset[]; ZASM Instruction:
DMAPOFFSET
/**
* An array of 512 integers containing the X offset of each DMap.
* Game->DMapOffset is read-only; while setting it is not syntactically
* incorrect, it does nothing.
*/ Example Use: !#!
/************************************************************************************************************/
int DMapMap[]; ZASM Instruction:
DMAPMAP
/**
* An array of 512 integers containing the map used by each DMap.
* Game->DMapMap is read-only; while setting it is not syntactically
* incorrect, it does nothing.
*/ Example Use: !#!
/************************************************************************************************************/
int NumDeaths; ZASM Instruction:
GAMEDEATHS
/**
* Returns or sets the number of times Link has perished during this quest.
*/ Example Use: !#!
/************************************************************************************************************/
int Cheat; ZASM Instruction:
GAMECHEAT
/**
* Returns, or sets the current cheat level of the quest player.
* Valid values are 0, 1, 2, 3, and 4.
*/ Example Use: !#!
/************************************************************************************************************/
int Time ZASM Instruction:
GAMETIME
/**
* Returns the time elapsed in this quest, in 60ths of a second. (i.e. in frames).
* The return value is undefined if TimeValid is false (see below).
*/ Example Use: !#!
/************************************************************************************************************/
bool TimeValid; ZASM Instruction:
GAMETIMEVALID
/**
* True if the elapsed quest time can be determined for the current quest.
*/ Example Use: !#!
/************************************************************************************************************/
bool HasPlayed; ZASM Instruction:
GAMEHASPLAYED
/**
* This value is true if the current quest session was loaded from a saved
* game, false if the quest was started fresh.
*/ Example Use: !#!
/************************************************************************************************************/
bool Standalone; ZASM Instruction:
GAMESTANDALONE
/**
* This value is true if the game is running in standalone mode, false if not.
* Game->Standalone is read-only; while setting it is not syntactically
* incorrect, it does nothing.
*
* Standalone mode is set by command line params when launching ZC.
*/ Example Use: !#!
/************************************************************************************************************/
int GuyCount[]; ZASM Instruction:
GAMEGUYCOUNT
/**