-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.doc
More file actions
832 lines (604 loc) · 33.4 KB
/
event.doc
File metadata and controls
832 lines (604 loc) · 33.4 KB
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
=== Zero page ===
Memory addresses $0080 to $00FF are the system area. The meaning of the
addresses with a currently defined meaning are listed here. The initial
values can be set using the assembler, and they can also be changed at
run time.
$A0 = The low 3-bits selects which active inventory is the current one. The
bit3 is automatically set when IMOV is used, within the $A2 and $A3 events,
and so is bit4 when it is actually affecting the slots; this can be used to
detect if that event is due to IMOV rather than IGIV or ITAK.
$A1 = Mask for item slot flags to match for IGIV, ITAK, and some other
inventory-oriented instructions. Some flags are always handled in a special
way regardless of this mask.
$A2 = Give item event (see below).
$A3 = Take item event (see below).
$A4 = Name item event (see below).
$A5 = Screen number to use for item windows.
$B0 = Window keyboard event (see below).
$B1 = A value which can be read by music programs in .BGM lumps. This can
be used to make dynamic music according to the state of the game.
$B2 = The address of the call stack used with CALS and RETS. This has the
same format as the deck used with DPUT and DTAK, and you can use those
instructions with this as well.
$B3 = Status which is written by CALS and RETS (the game engine never reads
this but you can read this for your own use). The low 13-bits are a copy of
the low 13-bits of the second operand of CALS or RETS, and the high 3-bits
are the first operand register number (0 for A, 7 for H).
$B4 = Received data event (see below). This event will only be used if the
"external" configuration setting has been defined as a non-empty string.
$B5 = Controls font animations. Some font animations can be set to only be
animated when a specific bit in this field is set or clear. Changing this
will not have any effect until the screen is redrawn (which usually occurs
once per frame automatically).
$B6 = If the control flag $0200 is set, then this controls which bits of
the colour and flags of overlay tiles are inherited by stats that are
moving over them. The low nybble is used for colours and the high nybble
is used for the kind bits.
$C0 = Saves the delay and flags for the global script. The low 8-bits are
the delay number and the high 8-bits are flags, except for: bit8 means to
save the delay, bit9 means to save the walk/face/user flags, and bit13
means to save the lock flag; the layers and disable flag cannot be saved.
The bits that cause things to be saved will also cause them to be restored;
if the bits are clear then they are neither saved nor restored.
$C1 = New dynamic stat callback event (see below).
$C2 = The starting address of the overlay memory (not to be confused with
the board overlay).
$C3 = The size of the most recently loaded overlay memory. This will also
be used when saving an overlay memory at run time, so you can change it if
you want to save it with a different size than it was loaded with.
$C4 = Joystick input levels. The low nybble is for normal game mode, the
next nybble is for text windows, the next nybble is for item windows, and
the high nybble is for custom windows.
$C5 = Script return event (see below).
$C6 = Stores the address of the next instruction after a branch or a write
to a S operand (causing returning from the subroutine). The address which
is stored is of the instruction that would be executed next if the branch
or return did not occur.
$C7 = Address of the board creation info structure, which is used when
warping to a non-existing board. See the below section for details of the
format of this structure. If this address is zero, then it is an error to
warp to a non-existing board.
$C8 = Transport event (see below).
$C9 = The default overlay, which is used when objects within the overlay
are moved out of the way or deleted. The low byte specifies the character
code and the high byte specifies the colour code.
$CA = Instruction pointer for global scripts. This is updated upon leaving
a board, if on the board that was previously active, global scripts are
allowed to execute and stat 1 has at least one instance and stat 1 does
not have any text.
$CB = Global control flags (see below).
$CC = J register. This is mostly like a general-purpose register (except
that it is only 16-bits long), although some instructions may use it for
additional arguments and/or results.
$CD = K register. This is like the J register.
$CE = Saved program counter for U coroutine.
$CF = Saved program counter for V coroutine.
$D0 to $D7 = Saved WXYZ registers for U coroutine.
$D8 to $DF = Saved WXYZ registers for V coroutine.
$E0 = Keyboard event (see below).
$E1 = Frame event (see below).
$E2 = Used for custom commands. If it is nonzero, then it is the address
of a record with two cells being the address of the next record (or zero
if this is the last record) and the global string number which is the name
of a custom script command; this string should consist only of uppercase
letters. Immediately following the record is the code to be executed when
that command is encountered in a script; see "script command events" below.
$E3 = Address of memory for light shape to suppress overlay around the
player. If this is 65486 or more then the overlay is not suppressed. This
points to a block of forty-nine cells. The first 24 cells are north of the
player, the next one is for the same row as the player, and the rest are
then south of the player; they are in order north to south. Each cell has
the high byte for the left edge and the low byte for the right edge of the
light; these values have 128 for the player's location, lesser numbers for
west and higher numbers for east.
$E4 = The target board number for a warp. (The WARP instruction will
automatically set this, as well as $E5 to $EB; you will not normally
need to touch these by yourself, but you might have a use for them.)
$E5 = The subroutine to call after a warp occurs. If this is nonzero then
a warp will occur before the next turn; it is automatically reset to zero
before calling the subroutine. The return value is ignored.
$E6 to $EB = The WARP instruction saves the values of the XYZ registers
here so that the warp subroutine will receive these values.
$EC = Frame counter. This is automatically incremented by the game engine
after each frame, and its value is used for time-based animations.
$ED = Screen number to use for text windows.
$EE = X scroll rate. Set to 65535 to scroll instantly. Lesser numbers will
limit the amount of scrolling per frame.
$EF = Y scroll rate.
Anything in the range $0080 to $00FF which is not listed here should be
left at zero for compatibility with future versions of Super ZZ Zero.
=== Global control flags ===
$0001 = Disable scrolling. (The CAM E instruction can be used to set or
clear this flag. Also note that this is independent from the "no scroll"
flag in the screen definition; if that no scroll flag is set, then this
one is ignored and it never scrolls that screen automatically.)
$0002 = If set, then the delay of stats that a message is successfully
sent to is set to zero. If clear, then it will only do this if the message
is a subroutine message.
$0004 = If set, then the message timer never expires, allowing the message
line text to be displayed until overridden or erased by the user.
$0008 = Disables saving the game by the F3 and F5 keys. Board flags may
specify to allow saving regardless of this in specific circumstances.
$0010 = If set, then the current state of the current board is saved when
warping to another board; this ignores the persist flag and will not
restore the saved board by warping to that board number; see below for
restoring the saved board state. This bit is automatically cleared after
the board state is saved. (Note that setting bits $0030 together will first
save and then immediately restore it and delete the saved state, so this is
probably not a useful combination.)
$0020 = If this bit is set when warping to another board, and a board state
has been saved by the $0010 bit, then it will restore the saved board state
instead of loading the board normally. The board number is still set to the
requested board number when warping, which is not necessarily the number of
the saved board, and this works even if there is no board with the board
number of the warp (in which case it will be created if you warp out of the
board with the persist flag set). This bit will not be cleared after it is
restored, but it will delete the saved board state, so this bit will be
ineffective unless the board state is saved again.
$0040 = When a message is successfully sent (because there is an unlocked
stat that has the label with the specified name) then it will set this bit.
You can clear this bit by yourself before sending it in case you want to
check if it is successfully sent.
$0080 = Causes it to automatically stop the key repeat when a text window,
item window, or custom window is opened, and again when it is closed.
$0100 = If this is set then number keys are treated as directions for the
purpose of key events.
$0200 = Uses the sensor field of the stat instance data of stats in the
overlay to remember what it was standing on, instead of using the data at
address $C9. (It still uses $C9 for moving stuff other than stats.)
=== Order of execution ===
Each turn consists of the following order:
* Do warping, if there is a pending warp. This will go to another board
(saving the old board if the old board is set as persistent), and then
will call the warp subroutine, setting the warp subroutine register to 0
before it is called. If another warp is set during this warp subroutine,
then this step repeats until no more warps are set.
* Do automatic scrolling, if enabled.
* Display the current screen.
* Wait for the next frame, and process the keyboard during this time. Some
keys affect the system and will work immediately; a key will also work
immediately if the game is paused.
* Execute the key event, if a key was pushed that can be handled by the
game world (see $00E0 below for the list of these keys). This is skipped
if no key is pushed or if the INSERT key is pushed. Saving and restoring
the game is handled at this step, when applicable.
* If the dynamic stat event is set, add a new dynamic stat (which is given
a new number if there are no vacant dynamic stat numbers available) and
execute the dynamic stat event. The dynamic stat event is set to 0 before
this is executed; if it is set to nonzero during this time then this step
is repeated until it is no longer set.
* Increment the frame counter and execute the global frame event. If the
return value is nonzero, the rest of the below steps are skipped.
* Scan the board, starting at (0,0) and going to the east, continuing on
west edge of the next row when reaching the end of each row; during this
scan it will execute the frame event of the element on the main layer of
each tile that is scanned.
* For each stat in numerical order, it will handle each instance of that
stat. If the stat is vacant, everything about the stat and its instances
is reset to zero (including the text), otherwise it will execute the stat
event of each instance in order. If the layer is zero or if the coordinates
are out of range (the coordinates are ignored for independent stats) then
that instance is deleted from the list, renumbering all further instances
of that stat (but the stat itself is not renumbered). (When a stat is
deleted by DIE, KILM, etc, it will mark it for deletion in this way.)
=== Global events ===
The events marked (#) will save the A,B,C,D registers before being called,
and then restored afterward; if they are called several times in sequence,
then they are restored only after all calls are completed. (In some cases,
they may be preserved from other events that are also marked with (#).)
$00A2 (#)
This event is called when giving items with IGIV or #GIVEITEM. It is
called after checking weight (if applicable) and after clearing all
marks in all item slots, for each slot that might be usable (it is
possible that it will fail even if it returns zero for all slots, since
(unlike ITAK) it does not know yet if there is enough space). This will
also save and zero the A,B,C,D registers like the $00A3 event does.
W = Item number and flags (same as second operand of IGIV)
X = Quantity (actual or requested, or remaining in fourth phase)
Y = Slot number
Z = Current state; OR of return values so far, starts at $10
J = Normally same as J was when IGIV is used but might be different
K = Number of slots required
Cond. flag = False during first three phases, true during fourth phase
The return value is a bit field with the bits:
bit0 = Skip this slot. During the first three phases, it will cause it
to avoid marking this slot and avoid adding to the running total which
it internally uses to decide when to stop; during the fourth phase, it
will prevent the slot from being affected automatically.
bit1 = Immediately fail.
bit2 = Try again afterward if it fails (including due to bit1). This has
no effect during the fourth phase.
bit3 = If set during the fourth phase (no meaning in other phases), the
remaining quantity is decreased by the value of the A register. If this
would reduce it to less than zero, it is reduced to zero instead.
bit4 = This bit is automatically set during the first phase involving
checking for fully matching slots (both the item and flags).
bit5 = This bit is automatically set during the second phase involving
checking for matching slots, that do not necessarily fully match (the
item matches; the flags will only match those set in the mask and those
that it always checks).
bit6 = This bit is automatically set during the third phase involving
checking for vacant slots.
$00A3 (#)
This event is called when taking a item with ITAK or #TAKEITEM. It is
only called after making all other checks that it can be taken; if it
returns zero then it will proceed. This event is called for every slot
where the item might be taken from. This will save the A,B,C,D registers
and will set those registers to zero before calling this event the first
time for one use of ITAK; they will be preserved between calls for one
use of ITAK, though.
W = Item number and flags (same as second operand of ITAK)
X = Quantity (actual or requested, whichever is less)
Y = Slot number
Z = Current state; OR of return values so far, starts at zero
J = Normally same as J was when ITAK is used but might be different
K = Number of slots required
The return value is a bit field with the bits:
bit0 = Immediately fail.
bit1 = Avoid using this slot. It might be able to use other slots if they
contain a sufficient amount of the requested item; it will immediately
look if there is a suitable one.
bit2 = Do not call this event for any further slots during this pass;
assume they are acceptable and no further processing is required. (If
another pass is added afterward, then it will use this event again.)
bit3 = If this attempt fails (although not if bit11 is set), then add
another pass after this one instead of abandoning the attempt. [*]
bit4 = Do not affect any slots. Everything else is still done and it
might be successful or not, but the inventory is unchanged. This does
not prevent the special use of item definitions from being applied. [*]
bit5 = The quantity is changed to the value of the A register. No other
changes are made; this does not change which slots are used.
bit6 = Unconditionally claim to be successful when finished, even if it
actually failed to do anything. (If combined with bit0, then it will do
nothing and not recalculate the quantity but will claim success.) [*]
bit7 = This bit is set during the second and subsequent passes which are
added due to bit3. This does not apply for passes added due to bit9.
bit8 = This bit is set if the total quantity that it is able to take is
at least as much as was requested. [*]
bit9 = If this attempt is successful, add another pass after this one,
before making changes to the inventory list. This additional pass does
not retry checking which items are suitable; it will always use the same
items as before. Additionally, the bits marked [*] will remain set during
the additional pass if they are set during this pass (bit9 is cleared).
bit10 = This bit is set for passes added due to bit9. [*]
bit11 = Immediately fail and abort the attempt regardless of which other
bits are set.
$00A4 (#)
This event is called when displaying the inventory menu, and is used for
deciding how the item's name should be displayed. The text buffer is
initially empty when this is called; the final value when it returns is
used as the displayed name. If the text buffer is still empty when it
returns, then the item's name is used.
W = Item ID number and slot flags
X = Slot number
Y = Item definition flags
Z = Usage: 0(item menu)
Condition flag = True if item is unidentified, or false if identified.
Return = If negative then this item is not displayed, but if zero or
positive then it is displayed. The bits are as follows:
bit8 = If set then the low 8-bits override the colour of the text.
bit9 = Prevents selecting this slot.
bit14 = Used internally; setting this by yourself has no effect.
bit15 = Displays it as a vacant slot (which cannot be selected).
$00B0 (#)
This event is used for overriding the behaviour of windows if the "use
window key event" flag is set for that window definition.
W = ASCII code of key pushed (same as for $00E0 event)
Y = Cursor position (zero-based)
J = Number of items
K = Scroll position
Text windows also use:
X = Key code for current line (zero if not applicable)
Z = Type of current line ('!', '$', ':', or zero)
Item windows also use:
X = Item slot number; the high 16-bits are the bits like the $00A4 event
Z = Cursor position for moving from (-1 if not moving)
Return = If 0 then causes nothing to happen, 1 to 127 will replace the
effect by the normal effect of the specified key code (so "LET S,W" will
have the normal behaviour if W is not changed), and negative numbers have
the special meanings explained below:
-1 = Cancel menu
-2 = Set cursor position (zero-based) to J (*)
-3 = Set scroll position (zero-based) to K (*)
-4 = Modify window colours; J=code 0-15, K=new value (*)
Text windows also use:
-50 = Find next line with first byte equal to J (*)
-51 = Close and use text buffer as target label name
Item windows also use:
-50 = Reload items
-51 = Set cursor position to item slot J (*)
-52 = Change to screen J (*)
The ones marked with (*) can add an additional -100 to continue the
execution (from the address which is automatically stored in memory cell
$00C6) after doing the operation. The W,X,Y,Z,J,K registers will be set
again before it is called.
$00B4
If config.external is defined, then this event is called when ASN.1 data
is received from the external program.
W = Class number
X = Type number
Y = Length
Z = Zero if primitive, one if constructed
Return = Nonzero to send the contents of a ASN.1 register as a reply;
subtract one from the return value to figure out which one to use.
$00C1
This event is called during each frame, before $00E1, but also creates a
new dynamic stat when this event is nonzero. It is set to zero before
being called, and if set to nonzero again before it returns, another new
dynamic stat is added and this is repeated. When adding a new dynamic
stat, first it will look for an existing stat whose mode flags include
both bit0 (DYNAMIC) and bit1 (VACANT), and if it exists, use that one.
Otherwise, a new stat is created. Either way, the new mode flags will be
bit0 (DYNAMIC) only.
W = The stat number of the new stat (zero if failed)
X,Y,Z = Zero
Return = If nonzero, adds a instance of this stat; the layer/lock flags
of the new instance will be the return value of this event, and the X, Y,
and other values will be zero.
$00C5
This event occurs when a #RETURN command in a script returns to a stack
frame that was pushed when the stat had a non-zero delay. (The delay is
normally in range 1 to 255, but by the use of SCFR instruction you can
save delay numbers outside of that range; that can be used to pass extra
information to this event.)
W = Stat number and stat XY index
X,Y = Currently not meaningful
Z = Saved delay number
Return = New delay value. A negative number means to continue execution.
$00C8
This event occurs whenever something tries to move through a transporter,
after it calls the EV_TRANSPORT events of the transporter and after it
checks that it is valid and pushes things out of the way if necessary,
but before actually moving the object through the transporter.
W = Source coordinates
X = Destination coordinates
Y = Transporter coordinates
Z = Movement classes
Condition flag = Suppression flag
Return = One of the below. Set condition flag to treat >0 as successful.
<0 = Try transporting again
0 = Continue
>0 = Cancel; return value as new coordinates
$00E0
Keyboard event at the beginning of each frame, if any key is pushed.
Number pad are treated as numbers or arrows depending on num lock.
A key code can be a printable ASCII character or one of the following:
1 to 4 = Debug commands
8 = BACKSPACE
9 = TAB
13 = ENTER or RETURN
16 = SHIFT+RIGHT
17 = SHIFT+LEFT
24 = UP
25 = DOWN
26 = RIGHT
27 = LEFT
30 = SHIFT+UP
31 = SHIFT+DOWN
W = ASCII code of key pushed
X = X delta of direction (0 if not applicable)
Y = Y delta of direction (0 if not applicable)
Z = Direction (-1 if not applicable)
Return = Unused.
$00E1
Event called at each frame, after the key event (if any) but before
everything else happens during this frame.
W,X,Y,Z = Zero
Return = Nonzero to skip the rest of the current turn (freeze time).
=== Script command events ===
A script command event uses the following registers:
W = Script XY record index
X = X coordinate
Y = Y coordinate
Z = Stat's speed
The return value uses the bits:
bit0 = Script execution will not continue until next turn.
bit1 = Do not skip the rest of the current line.
bit2 = Stop script execution.
bit3 = Unconditionally stop immediately.
bit4 = Go back to the beginning of the current line.
=== Element events ===
In all cases, X and Y are the coordinates of the tile the event is for.
EV_FRAME (0)
Called during each frame, on the scan of the board; this should not be
used to move things around (use EV_STAT instead), but can be used for
animation, changing this tile itself, etc.
W = Kind
Z = Parameter
Return = Unused.
EV_STAT (1)
Called whenever a stat's turn to be executed. If it is a independent
stat, then W and X and Y are still set, but Z is always zero, and the
element number for the event will be 241 or 242 or 243.
W = Stat number and stat XY index
Z = Parameter (zero for independent stats)
Return = Nonzero to prevent automatically setting the delay.
EV_PUSH (2)
Called when this object would be pushed.
W = Direction
Z = Parameter (+256 if pushing while transporting)
Condition flag = Suppression flag
Return = Nonzero to prevent pushing.
EV_TRANSPORT (3)
Called when this tile is hit by something attempting to be transported
through it; only if A_TRANSPORTABLE attribute is set for the object that
is trying to be transported through it.
W = Direction
Z = Previously attempted target coordinates, or zero if none
Condition flag = Suppression flag
Return = Target coordinates; zero to prevent transport.
EV_SENSOR (4)
This event occurs when a stat tries to move onto a sensor (which does not
necessarily have the A_FLOOR attribute). Only stats can try to move onto
sensors, and only in the main layer, although the sensor doesn't have to
be a stat (but it is OK if it is). Sensors cannot move onto sensors.
W = Stat number and stat XY index trying to move onto the sensor
Z = Movement flags (see below)
Return = Nonzero to allow movement onto the sensor; zero for normal move.
For the movement flags, bit7-bit3 are the same as for GMOV, but the other
bits have other meanings. The bit31-bit16 are the movement classes, and
the bit15-bit8 are the element number of the object being moved, and the
bit0 is set if it is moving from one sensor to another sensor, and bit1
is set if DROP is used, and bit2 is not currently meaningful.
=== Board creation info structure ===
The first cell of this structure has the low 8-bits indicating how many
more cells follow and the high 8-bits are the following flags:
* bit15 = Save the board after the subroutine returns if set. It will
not save it (only saving it if later warping away from the board when
it persists) if this bit is clear.
* bit14 = Copy variable properties from previous board if set. Delete
all variable properties if this bit is clear.
* bit13 = Copy user data from previous board if set. (If clear, then it
will be set to zero, instead.)
* bit12 = Set this bit to preserve all instances of independent stats
which are being copied from the previous board.
The further fields are (the default value is zero for all of them):
* 1 = The board width. If zero, then it is the same as the previous board.
* 2 = The board height. If zero, then same as the previous board.
* 3 = Number of stats to copy from the previous board.
* 4 = Screen number for the new board.
* 5 = Board flags for the new board.
* 6 = Overlay fill: The low byte means character and high byte means
colour. If this is zero then the overlay will be transparent, but if
nonzero then it will be visible.
* 7 = Main fill: The main layer fill, where the low byte is the kind
and the high byte is the colour. The parameter will always be zero.
After all of the fields of the structure, will be the beginning of a
subroutine which will be executed, after entering the new board but
before the warp subroutine is called, and also before handling the
initial scroll position, variable properties, switching the screen,
and loading the global script. Changes made during this subroutine
may affect the handling of this (although it will not affect which
warp subroutine is called, but it can affect its arguments).
The subroutine call will have the registers set as follows: W is the
previously selected board number, and X,Y,Z are zero. The return value
should be zero (but is ignored in the current version).
=== ASN.1 ===
(This feature is considered to be experimental.)
There are four global ASN.1 registers, each of which stores a ASN.1 value.
There are also .USD lumps each of which stores a ASN.1 value. These should
not be used too often, since they might be inefficient.
In the below explanations, there are three contexts, and each one indicates
which contexts it is applicable for:
(d) = Direct (the ASN1 opcode)
(r) = Reading
(w) = Writing
(s) = String writing
(R) = Begin a reading context
(W) = Begin a writing context
(S) = Begin a string writing context
(!) = Different usage of low 4-bits
When beginning a writing context, the program counter will be the next
instruction but it is a subroutine call; when it returns, the return value
is interpreted as described below but it will then continue from that
point. The W, X, Y, Z registers are zero when entering the context and each
time it returns, until it fully exits the context at which point the values
of those registers are restored. A reading context is similar but the W, X,
Y, Z registers work like the $00B4 event.
The ASN1 opcode working is complicated and is explained here. The second
operand is as follows:
* bit1-bit0 (drws) = First ASN.1 register.
* bit3-bit2 (drws) = Second ASN.1 register.
* bit4 (rws) = Exit context. If it is inside of a construction other than
the top one when in a writing context, it will end that construction and
otherwise continue writing.
* bit5 (rws) = Set the program counter back to the beginning of the reading
or writing context.
* bit6 (r) = Conditionally set the program counter back to the beginning
of the reading context.
* bit6 (d) = For operations that create a context, this will cause it to
use the first operand as the instruction address in the context instead of
using the existing instruction address.
* bit7 (d) = Copy J to first operand register after doing operation.
* bit15-bit8 (drw) = ASN.1 operation code.
Any bits not listed here should be clear.
The operation codes are:
$00 (drw) = Copy second register to first register. If both specify the
same register, then there is no effect.
$01 (drw) = Move second register to first register; the second register
will be null after it is moved. This is more efficient than copying.
$02 (d) = Save the first register in the .USD lump whose number is
specified by the first operand.
$03 (d) = Load the first register from the .USD lump whose number is
specified by the first operand.
$04 (d) = Read the class, type, and length of the first register; the
class is stored in J, the type is stored in K, and the length in the first
operand. The condition flag is set if constructed or clear if primitive.
$05 (d) = Write the class and type and primitive/constructed of the first
register; the class is read from J (only the low 2-bits are used), the type
is read from K, and the condition flag is for primitive/constructed.
$06 (d) = Set the first register to a signed integer, read from the
first operand.
$07 (d) = Set the first register to a unsigned integer, read from the
first operand.
$08 (d) = Read the first register as a signed integer into the first
operand. The condition flag will be true if it is valid or false if not
valid. The ASN.1 type must be either integer or enumerated.
$09 (d) = Read the first register as a unsigned integer into the first
operand. The condition flag will be true if it is valid or false if not
valid. The ASN.1 type must be either integer or enumerated.
$0A (drw) = Send the first register to an external program (which must be
set by the user configuration file).
$0B (d) = Read the contents of the first register into the text buffer; the
first operand will then contain the new length of the text buffer. If there
is not enough room, or if the ASN.1 value contains a null byte, it will be
truncated and the condition flag will be false; if it works then it will be
true. This operation ignores the ASN.1 type, and just copies the bytes
directly into the text buffer.
$0C (d) = Revert the .USD lump specified by the first operand.
$0D (dW) = Begin a constructed value into the first register. The class
will be read from J and the type from K. The first operand is A to not
sort the data, B to sort it as a set, and C to sort as a key/value list.
$0E (dW) = Begin a single value into the first register. This works like
the $0D except that J and K are ignored and only one item can be written,
and the first operand is ignored.
$0F (drw) = Exchange registers.
$10 (w) = Begin a sequence.
$11 (w) = Begin a set.
$12 (w) = Begin a key/value list.
$13 (w) = Set an implicit type for the next item, according to the J and
K registers.
$14 (w) = Write the value from the first register.
$15 (w) = Write a boolean value; the condition flag specifies the boolean
value to be written.
$16 (w) = Write a null value.
$17 (w) = Write the contents of the text buffer as a octet string. (Use $13
if you want to specify a different type.)
$18 (w!) = Write a integer with the value of a status variable. The low
4-bits selects which status variable.
$19 (w) = Write the value from the first register and then second register.
$28 (d) = Read a byte from the first register; the first operand specifies
the zero-based byte offset. The J register will contain the byte that has
been read, and the condition flag is true if it is in range; if it is not
in range or if it is constructed then the condition flag will be false.
This ignores the class and type of the ASN.1 register; it only cares about
the length and if it is primitive.
$29 (d) = Set the script text of a stat to the text of the first register,
which must be a PC string, IA5 string, or octet string. The first operand
specifies which stat; if it is zero, or if it a stat that already has text
or does not exist, or if the ASN.1 type is wrong or if it is too long,
then it is an error.
$2D (dW) = Like $0D but writes to the external program instead.
$2E (dW) = Like $0E but writes to the external program instead.
$30 (dR) = Begin a reading context for the first register, which must be
constructed; it will enumerate the items it contains. The second register
is the one that the current item will be stored in. When it is finished,
the second register will contain null, and the first register will be
restored to its original value.
$31 (r) = Access the next item in a reading context. It will exit the
context if there is no more left. The condition flag is true if there is
another item or false if not (operation $30 also does this).
$32 (r) = Go back to the first item in a reading context.
$38 (dS) = Begin a primitive value into the first register; this will use
the string writing context, to write raw data. The J and K registers are
used to specify the class and type. The first register is not set until
the context is finished.
$39 (dS) = Like $38 but writes to the external program instead.
$3A (s) = Append a single byte from the J register.
$3B (s!) = Append a single byte from the low 8-bits of one of the registers
A to H selected by using the low 3-bits of this operand.
$3C (s) = Append the contents of the text buffer.
$3D (s) = Append the contents of the first register.
$3E (s) = Append a substring of the first register; A specifies the start
offset (zero-based) and B specifies the length. If they are out of range,
they are changed to numbers that are in range.