commit 9df7c3e

chld  ·  2026-10-28 12:35:35 +0000 UTC
parent 60461f0
cleanup
81 files changed,  +3, -14956
D main.c
D uxn.o
D x.diff
+0, -23
 1@@ -1,23 +0,0 @@
 2-environment:
 3-  BUILD_SUBMITTER: git.sr.ht
 4-  SITE: rabbits.srht.site/uxn2
 5-image: debian/stable
 6-packages:
 7-- curl
 8-- libsdl2-dev
 9-shell: false
10-oauth: pages.sr.ht/PAGES:RW
11-sources:
12-- https://git.sr.ht/~rabbits/uxn2
13-tasks:
14-- build: |
15-    mkdir bin/
16-    cc -I/usr/include/SDL2 -DNDEBUG -O2 -g0 -s -lSDL2 uxn2/src/uxn2.c -o bin/uxn2 $(sdl2-config --cflags --libs)
17-- upload: |
18-    tar -czf out.tar.gz bin/
19-    acurl() {
20-        set +x
21-        curl -H "Authorization: Bearer ${OAUTH2_TOKEN}" "${@}"
22-        set -x
23-    }
24-    acurl -fsS "https://pages.sr.ht/publish/${SITE}" -Fcontent=@out.tar.gz
+0, -22
 1@@ -1,22 +0,0 @@
 2-AlignAfterOpenBracket: DontAlign
 3-AlignEscapedNewlines: DontAlign
 4-AlignOperands: DontAlign
 5-AllowShortBlocksOnASingleLine: Always
 6-AllowShortCaseLabelsOnASingleLine: true
 7-AllowShortEnumsOnASingleLine: true
 8-AllowShortIfStatementsOnASingleLine: true
 9-AllowShortLoopsOnASingleLine: true
10-AlwaysBreakAfterDefinitionReturnType: TopLevel
11-BreakBeforeTernaryOperators: false
12-BinPackArguments: false
13-BinPackParameters: false
14-BreakBeforeBraces: WebKit
15-IndentCaseLabels: false
16-TabWidth: 4
17-IndentWidth: 4
18-ContinuationIndentWidth: 4
19-UseTab: ForContinuationAndIndentation
20-ColumnLimit: 0
21-ReflowComments: false
22-SortIncludes: false
23-SpaceBeforeParens: false
+0, -1
1@@ -1 +0,0 @@
2-prg/not88aonly.uhs
+0, -19
 1@@ -1,19 +0,0 @@
 2-on:
 3-  issues:
 4-    types:
 5-      - opened
 6-  pull_request:
 7-    types:
 8-      - opened
 9-permissions:
10-  contents: read
11-  issues: write
12-  pull-requests: write
13-jobs:
14-  default:
15-    runs-on: ubuntu-latest
16-    steps:
17-      - run: gh issue edit ${{ github.event.issue.number }} --add-assignee ${{ github.repository_owner }}
18-        env:
19-          GH_TOKEN: ${{ github.token }}
20-          GH_REPO: ${{ github.repository }}
+3, -2
 1@@ -8,9 +8,10 @@
 2 *.bak
 3 /*-test
 4 /screenshot-*.bmp
 5-
 6+*.tns
 7+*.o
 8+*.elf
 9 *snarf
10 *theme
11-
12 bios.rom
13 bios.rom.sym
+0, -112
  1@@ -1,112 +0,0 @@
  2-# Uxn2
  3-
  4-A graphical emulator for the [Varvara Computer](https://wiki.xxiivv.com/site/varvara.html), written in C99(SDL2). 
  5-
  6-## Building 
  7-
  8-You must have [SDL2](https://www.libsdl.org/) installed.
  9-
 10-```sh
 11-cc -I/usr/include/SDL2 -DNDEBUG -O2 -g0 -s -lSDL2 src/uxn2.c -o bin/uxn2
 12-```
 13-
 14-For your convenience a [Makefile](https://en.wikipedia.org/wiki/Make_(software)#Makefile) is provided. 
 15-
 16-```sh
 17-make run
 18-```
 19-
 20-You can run `make install` to build and install the files. By default, files are installed into `~/.local` but this can be overridden using `PREFIX`:
 21-
 22-```sh
 23-# installs files into /opt/uxn/bin
 24-$ make PREFIX=/opt/uxn install
 25-```
 26-
 27-### Plan 9
 28-
 29-If you're on plan 9.
 30-
 31-```sh
 32-cd src/
 33-cc -p -I/sys/include/npe -I /sys/include/npe/SDL2/ uxn2.c
 34-6l -o uxn2 uxn2.6
 35-```
 36-
 37-If do not wish to build it yourself, you can [download linux binaries](https://rabbits.srht.site/uxn2/bin/uxn2).
 38-
 39-[![builds.sr.ht status](https://builds.sr.ht/~rabbits/uxn2.svg)](https://builds.sr.ht/~rabbits/uxn2?)
 40-
 41-## Usage
 42-
 43-The first parameter is the rom file, the subsequent arguments will be accessible to the rom, via the [Console vector](https://wiki.xxiivv.com/site/varvara.html#console).
 44-
 45-```sh
 46-bin/uxn2 bin/example.rom arg1 arg2
 47-```
 48-
 49-- `-f` to start in fullscreen
 50-- `-2` to start in zoomed x2
 51-
 52-## Assembler
 53-
 54-This repository comes with a copy of the compiled [Drifblim](https://git.sr.ht/~rabbits/drifblim) assembler. 
 55-
 56-```sh
 57-cat etc/utils/drifblim.rom.txt | bin/uxn2 etc/utils/xh.rom > bin/drifblim.rom
 58-bin/uxn2 bin/drifblim.rom etc/tests/opctest.tal bin/opctest.rom
 59-```
 60-
 61-## Devices
 62-
 63-The file device is _not_ sandboxed, it is able read or write outside of the working directory.
 64-
 65-- `00` system
 66-- `10` console
 67-- `20` screen
 68-- `40` audio
 69-- `50` audio
 70-- `60` audio
 71-- `70` audio
 72-- `80` controller
 73-- `90` mouse
 74-- `a0` file(a)
 75-- `b0` file(b)
 76-- `c0` datetime
 77-
 78-## Emulator Controls
 79-
 80-- `F1` toggle zoom
 81-- `F2` toggle debugger
 82-- `F4` reboot
 83-- `F5` reboot(soft)
 84-
 85-### Buttons
 86-
 87-- `LCTRL` A
 88-- `LALT` B
 89-- `LSHIFT` SEL 
 90-- `HOME` START
 91-
 92-## SDL2
 93-
 94-To build this emulator, you must install [SDL2](https://wiki.libsdl.org/) for your distro. If you are using a package manager:
 95-
 96-```sh
 97-sudo pacman -Sy sdl2             # Arch
 98-sudo apt install libsdl2-dev     # Ubuntu
 99-sudo xbps-install SDL2-devel     # Void Linux
100-brew install sdl2                # OS X
101-```
102-
103-## Need a hand?
104-
105-The following resources are a good place to start:
106-
107-* [XXIIVV — uxntal](https://wiki.xxiivv.com/site/uxntal.html)
108-* [XXIIVV — uxntal reference](https://wiki.xxiivv.com/site/uxntal_reference.html)
109-* [compudanzas — uxn tutorial](https://compudanzas.net/uxn_tutorial.html)
110-
111-## Contributing
112-
113-Submit patches using [`git send-email`](https://git-send-email.io/) to the [~rabbits/public-inbox mailing list](https://lists.sr.ht/~rabbits/public-inbox).
+0, -370
  1@@ -1,370 +0,0 @@
  2-This document describes the Uxn assembler, including the nonstandard
  3-extensions of the implementation included in this repository.
  4-
  5-Specify two or three command-line arguments:
  6-
  7-* Input file name (you can specify /dev/stdin to read from stdin).
  8-
  9-* Output file name (you can specify /dev/stdout to write to stdout, or you
 10-can specify /dev/null to discard the output).
 11-
 12-* Name output file name (you can specify /dev/stdout to write to stdout).
 13-This is optional, and if specified, then it will write a list of labels
 14-(including unused labels too) and their addresses to this file. (This is a
 15-nonstandard feature.)
 16-
 17-Switches are also allowed if preceding the other arguments:
 18-
 19- -a will set the starting address to 0x0100.
 20-
 21- -i followed by a token will parse that token before parsing the input
 22- file. This must be a single token, and not the beginning of a macro or a
 23- comment. This switch may occur multiple times.
 24-
 25-
 26-=== Tokens ===
 27-
 28-A token consists of a sequence of one or more non-whitespace characters
 29-(you can have whitespace characters to separate them). The maximum length
 30-of each token is sixty-three characters.
 31-
 32-All numbers must be lowercase hexadecimal, and normally must be either two
 33-or four hex digits.
 34-
 35-The following standard tokens are available:
 36-
 37- ( which begins a block comment; all further tokens up to ) are ignored.
 38- Comments can be nested.
 39-
 40- [ or ] has no meaning. Anything inside this block is still assembled as
 41- though the [ and ] commands are not present.
 42-
 43- ~ and a file name will include that file as a source file.
 44-
 45- % and a macro name will define a macro; you will need tokens { and }
 46- around the definition of the macro.
 47-
 48- The name of a previously defined macro without % in front will call that
 49- macro, as though its definition is substituted in its place.
 50-
 51- | and a number or label name will set the current address to that number
 52- (or to the address of that label). Any address is possible, but you cannot
 53- assemble anything in the zero page nor can anything be assembled out of
 54- order, although you can skip any space.
 55-
 56- $ and a number or label name will advance the address by that number (or
 57- by the address of that label). (The padding will  be all zeros if not
 58- filled in.)
 59-
 60- @ and a name will make a label with that name. If the label name starts
 61- with a uppercase letter, then warnings about that label being unused are
 62- suppressed. (Otherwise, a warning is emitted if the label is never used.)
 63-
 64- & and a name will make a label whose name is the same as the most recent
 65- @ command and then / and then the name specified by the & command.
 66-
 67- # and a number will make a LIT or LIT2 opcode with the specified number
 68- (the number of hex digits determines which opcode).
 69-
 70- A number without # is similar but the opcode is omitted, so raw data is
 71- emitted instead.
 72-
 73- . and a name will make a LIT opcode whose value is the low 8-bits of the
 74- address of the specified name.
 75-
 76- , and a name will make a LIT opcode whose value is a signed 8-bit value
 77- which is a relative offset of the address of the specified name; this
 78- should be used immediately preceding a JMP, JSR, or JCN instruction.
 79-
 80- ; and a name will make a LIT2 opcode whose value is the address of the
 81- specified name.
 82-
 83- : and a name will write the 16-bit address of the specified name directly,
 84- without any opcode. (It is like ; but excluding the LIT2 instruction.)
 85-
 86- = and a name is the same as : and a name.
 87-
 88- - and a name is like . but without the LIT opcode.
 89-
 90- _ and a name is like , but without the LIT opcode.
 91-
 92- ? and a name will make a JCI instruction jumping to that label.
 93-
 94- ! and a name will make a JMI instruction jumping to that label.
 95-
 96- / and a name will treat it like & but instead of making the label, it will
 97- be a JSI to that label (since & cannot be used with JSI due to being used
 98- for a different purpose, / is available for this purpose instead).
 99-
100- " and any characters (other than whitespaces) will emit that sequence of
101- characters without any opcodes or delimiters. (If you need spaces, then
102- you must use separate tokens such as 20 for spaces.)
103-
104- { and } can be used around a lambda block (they can also be used for
105- macros as described above). This is the same as the nonstandard [& ]@
106- block (described below), but internally uses a separate stack. You can
107- also use other runes at the beginning e.g. ?{ } is like the [? ]@ block.
108-
109- An instruction opcode consists of three uppercase letters, optionally
110- followed by any combination of instruction flags which can be "2" for
111- 16-bit operands, "r" to work with the other stack, and/or "k" to keep
112- the input operands in the stack. (You cannot code the JCI, JMI, and JSI
113- instructions in this way, although BRK can be coded in this way.)
114-
115- A name by itself to make a JSI instruction (if it does not match any
116- of the other tokens mentioned above).
117-
118-The following nonstandard tokens are available:
119-
120- \\ begins a line comment, which ends at the next line break.
121-
122- \~ and a file name will include the contents of the binary file.
123-
124- \. or \, is like . or , but excluding the LIT instruction. (These are
125- like - and _ but are nonstandard; they were added before the - and _
126- signs were made standard.)
127-
128- \ and a number pushes the number to the special stack (which is a stack
129- which exists only at compile-time).
130-
131- \: and a name will push the address of the name to the special stack.
132- The label must come before this command; forward references cannot be
133- used with this command, and & also cannot be used.
134-
135- \@ and a name will pop an address from the special stack and define a
136- label whose address is the address which has been popped in this way.
137-
138- \_ and further text is a special calculation; see the below section
139- about special calculations. These are executed immediately at compile
140- time, before the compiled program is written to the output file.
141-
142- \` is like \_ but the calculation is deferred until when references
143- are being resolved. By this time, any references that come before this
144- command will already be resolved, and the memory containing them can
145- be read and overwritten by the calculation if desired.
146-
147- \- or \= followed by eight more characters and optionally ; will make
148- a graphical tile; you should have eight such commands per tile, and
149- a semicolon at the end of the last one. Use \- for 1bpp tiles and \=
150- for 2bpp tiles. The colour codes are . or 0 for the background colour,
151- and numbers 1 2 3 for the other colours.
152-
153- \r will cause it to automatically change opcodes without "r" to the ones
154- with "r" and vice-versa until the next \r token. This also affects the
155- # and , and . and ; tokens, and causes the uses of JSI and JCI to be
156- errors (but JMI and BRK are OK and are not affected by \r).
157-
158- [@ makes a anonymous label; the matching ] command will reference the
159- same anonymous label as this one. (Nesting is allowed.)
160-
161- ]@ will make a anonymous label which the matching [ before it will
162- reference it.
163-
164- [, [. [; [: [? [! will act like a , . ; : ? ! referencing the anonymous
165- label defined by the matching ]@ command.
166-
167- ], ]. ]; ]: ]? ]! will act like a , . ; : ? ! referencing the anonymous
168- label defined by the matching [@ command.
169-
170- [& and ]& are like [! and ]! but the opcode is JSI instead of JMI.
171-
172- ]\ acts like \: for the matching [@ command.
173-
174- ][ is like [! corresponding to a later ] and then ]@ corresponding to a
175- earlier [ command (it can be used like a else block).
176-
177-For the . , : ; commands, the name can optionally start with & to mean
178-that it is interpreted the same as for a & command.
179-
180-Another nonstandard feature is that if you define a macro whose name
181-starts with a character which has a special meaning, then that special
182-meaning is ignored in the rest of the file.
183-
184-
185-=== Special calculations ===
186-
187-Each instruction is a single character.
188-
189-Numbers 0 to 9 and a to f push that number to the special stack.
190-
191-'  ( y z -- yz )  Calculates z+(y<<4).
192-
193-"  ( w x y z -- wxyz )  Calculates z+(y<<4)+(x<<8)+(w<<12).
194-
195-_  ( -- )  Set loop point.
196-
197-!  ( x -- )  Set current address.
198-
199-@  ( -- x )  Get current address.
200-
201-#  ( x -- )  Set current length. (This length includes the zero page,
202-even though the zero page is not written to the output file.)
203-
204-$  ( -- x )  Get current length.
205-
206-+  ( x y -- z )  Addition x+y.
207-
208--  ( x y -- z )  Subtraction x-y.
209-
210-*  ( x y -- z )  Multiplication x*y.
211-
212-/  ( x y -- z )  Division x/y.
213-
214-%  ( x y -- z )  Modulo x&y.
215-
216-&  ( x y -- z )  Bitwise AND.
217-
218-|  ( x y -- z )  Bitwise OR.
219-
220-^  ( x y -- z )  Bitwise XOR.
221-
222-<  ( x y -- z )  Left shift x by y bits.
223-
224->  ( x y -- z )  Right shift x by y bits.
225-
226-:  ( x -- x x )  Duplicate.
227-
228-,  ( x y -- y x )  Swap.
229-
230-.  ( x -- )  Discard.
231-
232-E  ( code -- )  Emit an error and stop compiling.
233-
234-g  ( address -- value )  Read 8-bits from memory.
235-
236-G  ( address -- value )  Read 16-bits from memory.
237-
238-k  ( count -- count? )  Similar to o (below) but ends the loop if the new
239-count is zero instead of the old count.
240-
241-L  ( condition -- )  Go back to beginning of loop if condition is nonzero.
242-
243-o  ( count -- count? )  If count is nonzero, decrement and go back to the
244-beginning; if it is already zero then just discards it and continues the
245-execution from here instead.
246-
247-p  ( value address -- )  Write 8-bits to memory. You can write anywhere
248-including the zero page and can also overwrite memory that has already
249-been written. Anything written to the zero page can be read back by other
250-special calculations but will not be written to the output file; anything
251-written outside of the zero page is written to the output file too.
252-
253-P  ( value address -- )  Write 16-bits to memory.
254-
255-w  ( value -- )  Write 8-bits at the current address and advance. You
256-cannot write in the zero page or overwrite what is already written.
257-
258-W  ( value -- )  Write 16-bits at the current address and advance. You
259-cannot write in the zero page or overwrite what is already written.
260-
261-x  ( length -- )  Add padding into expanded memory.
262-
263-()  ( condition -- )  Put other commands in the () block; it will be
264-executed only if the condition is zero, and skipped if nonzero. Conditional
265-blocks of the same kind cannot be nested.
266-
267-[]  ( condition -- )  Put other commands in the [] block; it will be
268-executed only if the condition is nonzero, and skipped if zero. Conditional
269-blocks of the same kind cannot be nested.
270-
271-
272-=== Name output format ===
273-
274-The name output format has each record on a line by itself, and each
275-record will be like:   |xxxx @yyyy
276-
277-xxxx is four lowercase hex digits being the address of that label.
278-
279-yyyy is the name of that label.
280-
281-
282-=== Expanded memory ===
283-
284-A nonstandard feature allows writing large files that have preset data in
285-expanded memory. Any expanded memory data comes after the conventional
286-memory data. It is possible that some data will fit in conventional memory
287-in which case such data will be entered into conventional memory, but you
288-can override this using alignment and padding commands.
289-
290-The following nonstandard tokens are used for expanded memory:
291-
292- \* followed by a name will make a label that refers to the address within
293- expanded memory. The plain name refers to the low 16-bits of the address
294- and the name followed by ^ refers to the high 16-bits (the page number).
295- This also sets the initial scope name of any sub-assemblies that follow.
296-
297- \^ followed by a file name is similar to \~ but writes the data into
298- expanded memory.
299-
300- \B \E \F followed by a digit 0 to 9 or a letter a to u (representing a
301- number ten to thirty) will begin a new expanded memory block which is
302- aligned to begin or end at an address divisible by two to the power of
303- that number, or to fit into an aligned space with that size. For example,
304- \Bg will require the data to begin on a page boundary, while \Fg will
305- require this block to fit in a single page (which might be the same page
306- as the previous block if it fits).
307-
308- \A followed by a number (which can be a 32-bit number) will begin a new
309- expanded memory block which begins at the specified absolute address. If
310- everything before it is already beyond that address, then it is an error.
311-
312- \C followed by a number will begin a new expanded memory block which must
313- fit into the specified number of pages, otherwise it is an error. If
314- necessary, it will align it to a new page, but if the data is small enough
315- then this will be unnecessary and it will not do alignment.
316-
317- \D followed by a number will begin a new expanded memory block which must
318- start on the specified page but not necessarily at the beginning.
319-
320- [^ ]^ surround a block which will be entered into expanded memory. This
321- can contain assembly code which makes up to sixty-four bytes of data, and
322- should not contain any labels nor references (including anonymous labels
323- and references due to the [@ ]@ blocks). (However, \: is allowed.)
324-
325- ^ followed by a file name makes a sub-assembly. This is similar to ~ but
326- the data which is assembled from that file is written to expanded memory
327- like \^ instead of like \~ does. This is parsed after the rest of the main
328- file is parsed, instead of before like the ~ command does. The initial
329- internal address in the sub-assembly, which is also the starting address
330- that data will be copied from, is the same as the outer address; you can
331- use | to change this if desired. (The intended use of this is for making
332- overlays which contain absolute addressing within the overlay. If you
333- only use relative addressing then this is not important.) A temporary file
334- named ".uxn_subassembly" will be created; it can safely be deleted.
335-
336- \+ followed by a name of a label or macro will export that label or macro
337- to all sub-assemblies; inside of a sub-assembly it will export a name (you
338- cannot export a macro from a sub-assembly) into the main code (which can
339- be exported to later sub-assemblies, but not ones that come before). Even
340- if it is exported from the main code, a label defined by \* cannot be
341- referenced by sub-assemblies in the same or an earlier block than the \*
342- is in, but can be referenced by sub-assemblies in any later block.
343-
344-
345-=== Compact fonts ===
346-
347-There is also a nonstandard feature to make 8x8 fonts compact. This uses
348-the following nonstandard tokens:
349-
350- [' and ]' surround a block that contains character codes to be remapped.
351- Within this block, # and " and \~ and direct numeric data is affected,
352- and anything else is not affected.
353-
354- \m followed by a number and then ~ and a file name will treat that file
355- as a raw 8x8 1bpp font, and will be copied into the output like \~ does
356- but will delete unused characters from the font, and renumber the rest
357- of the characters and change the data in the [' and ]' to the renumbered
358- character codes; the number before ~ is the first character code number.
359- After this, the address of character code zero (which is not necessarily
360- a valid character code) is pushed to the special stack so that \@ can be
361- used. The \m command cannot occur more than once. Any character codes
362- that are beyond the end of the (full) font will be renumbered to numbers
363- after the end of the font with the deleted characters, so that you can
364- still add more characters in your own program beyond those in the font
365- file that is specified.
366-
367- \mk followed by two or four hex digits will cause those characters to be
368- kept even if they are not used. If there are four hex digits, then it is
369- a range (inclusive on both ends), and it will guarantee that they will be
370- a contiguous range of character codes.
371-
+0, -26
 1@@ -1,26 +0,0 @@
 2-This document contains instructions for compiling the programs in this
 3-repository, in case they are helpful for anyone.
 4-
 5-Note that these programs are designed for Linux. There is no guarantee
 6-that they will work on Windows; if you wish to use them on Windows, you
 7-may consider using WSL (although I have not tried this, because I do not
 8-have Microsoft Windows).
 9-
10-
11-=== Assembler ===
12-
13-The uxnasm.c file is the assembler and does not have any dependencies
14-other than the C standard library; you can just compile it normally,
15-using gcc or clang (although I have not tried clang).
16-
17-
18-=== Emulator ===
19-
20-The main.c file is the emulator itself, and requires SDL1. The top of
21-the main.c file contains a shell command to compile it which works on
22-my computer, although your computer might be set up differently.
23-
24-One person, who was using Windows 11, WSL2, Ubuntu, compiled it using the
25-below command, with the "libsdl1.2-compat-dev" package:
26-  gcc main.c -o uxn38 -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -lSDL -L/usr/local/lib
27-
+0, -347
  1@@ -1,347 +0,0 @@
  2-.\" Manpage reference for uxntal.
  3-.\" by Eiríkr Åsheim
  4-.\" Contact d_m@plastic-idolatry.com to correct errors or typos.
  5-.TH uxntal 7 "12 Aug 2026" "1.0" "Uxntal Reference Guide"
  6-.SH NAME
  7-uxntal \- assembly language for Varvara virtual machine
  8-.SH DESCRIPTION
  9-Uxntal is an 8-bit instruction set for programming the Varvara virtual machine.
 10-It uses the lower 5-bits to specify an opcode, and the upper 3-bits to specify
 11-optional modes.
 12-
 13-ROMs consist of a 16-bit address space of bytes. Any byte can be interpreted as either data or an instruction. A 2-byte program counter (\fIpc\fP) determines the address of the next instruction to decode and run.
 14-
 15-Instructions manipulate data using two stacks: a working stack (\fBwst\fP) and a return stack (\fBrst\fP). Each stack consists of 256 bytes, and in the case of overflow or underflow the stack pointer will wrap (the stacks are circular).
 16-
 17-There are also 256 bytes of device memory, which are used to interact with the virtual machine and its devices.
 18-
 19-Instructions deal with unsigned 8-bit values (\fIbytes\fP) and unsigned 16-bit values (\fIshorts\fP). There are no other built-in data types. Occasionally values are treated as signed, such as when loading, storing, or jumping with a relative address.
 20-
 21-Short values are stored on the stack in big-endian byte order: the least significant byte will be on the top of the stack. This makes \fB#abcd\fP equivalent to \fB#ab #cd\fP.
 22-
 23-.SH INSTRUCTION LAYOUT
 24-
 25- 0x01 ----
 26- 0x02     \\
 27- 0x04      +- \fIopcode\fP
 28- 0x08     /
 29- 0x10 ----
 30- 0x20 ---- 2: \fIshort mode\fP
 31- 0x40 ---- r: \fIreturn mode\fP
 32- 0x80 ---- k: \fIkeep mode\fP
 33-
 34-.SH OPCODE LAYOUT
 35-
 36-There are 32 base values for opcodes:
 37-
 38-    0x00 \fBBRK*\fP   0x08 \fBEQU\fP    0x10 \fBLDZ\fP    0x18 \fBADD\fP
 39-    0x01 \fBINC\fP    0x09 \fBNEQ\fP    0x11 \fBSTZ\fP    0x19 \fBSUB\fP
 40-    0x02 \fBPOP\fP    0x0a \fBGTH\fP    0x12 \fBLDR\fP    0x1a \fBMUL\fP
 41-    0x03 \fBNIP\fP    0x0b \fBLTH\fP    0x13 \fBSTR\fP    0x1b \fBDIV\fP
 42-    0x04 \fBSWP\fP    0x0c \fBJMP\fP    0x14 \fBLDA\fP    0x1c \fBAND\fP
 43-    0x05 \fBROT\fP    0x0d \fBJCN\fP    0x15 \fBSTA\fP    0x1d \fBORA\fP
 44-    0x06 \fBDUP\fP    0x0e \fBJSR\fP    0x16 \fBDEI\fP    0x1e \fBEOR\fP
 45-    0x07 \fBOVR\fP    0x0f \fBSTH\fP    0x17 \fBDEO\fP    0x1f \fBSFT\fP
 46-
 47-The "complete" opcode's value can be derived by combining the base value with its flags.
 48-
 49-For example, \fBADD2k\fP is \fB(ADD | 2 | k)\fP = \fB(0x18 | 0x20 | 0x80)\fP = \fB0xb8\fP.
 50-
 51-Unlike other opcodes, \fB0x00\fP (\fBBRK*\fP) is contextual: its meaning depends on the \fImode\fP bits provided:
 52-
 53-    0x00 \fBBRK\fP    0x80 \fBLIT\fP
 54-    0x20 \fBJCI\fP    0xa0 \fBLIT2\fP
 55-    0x40 \fBJMI\fP    0xc0 \fBLITr\fP
 56-    0x60 \fBJSI\fP    0xe0 \fBLIT2r\fP
 57-
 58-.SH STACK EFFECTS
 59-
 60-.BR
 61-
 62-.SS NOTATION
 63-
 64-Given a stack effect \fB( a^ b^ c^ -- c^ a^ b^ )\fP here is what each symbol means:
 65-
 66-    \fB(\fP and \fB)\fP are comment delimiters
 67-    \fBa^\fP, \fBb^\fP, and \fBc^\fP are values on the stack
 68-    \fB^\fP indicates that each value is a \fIbyte\fP (\fB*\fP would indicate \fIshort\fP)
 69-    \fB--\fP separates the "before" and "after" of the stack effect
 70-
 71-The effect here is to move the top byte of the stack below the next two bytes, which could be achieved with \fBROT ROT\fP.
 72-
 73-By default stack effects describe the effect on \fBwst\fP. When \fBrst\fP is involved we use \fB[]\fP to differentiate the stacks. For example \fB( a* [b*] -- a+1* [b+1*] )\fP will increment the top short of both \fBwst\fP and \fBrst\fP.
 74-
 75-.SS EFFECTS AND MODES
 76-
 77-Regular instructions have a single stack effect which is modified in a predictable way by any additional modes.
 78-
 79-For example the generic effect for \fBADD\fP is ( x y -- x+y ). The eight combinations of modes have the following effects:
 80-
 81-.nf
 82-
 83-    \fBADD\fP    ( x^ y^   -- x+y^ )         sum bytes from \fBwst\fP
 84-    \fBADDr\fP   ( [x^ y^] -- [x+y^] )       sum bytes from \fBrst\fP
 85-    \fBADD2\fP   ( x* y*   -- x+y* )         sum shorts from \fBwst\fP
 86-    \fBADD2r\fP  ( [x* y*] -- [x+y*] )       sum shorts from \fBrst\fP
 87-    \fBADDk\fP   ( x^ y^   -- x^ y^ x+y^ )   sum and keep bytes from \fBwst\fP
 88-    \fBADDkr\fP  ( [x^ y^] -- [x^ y^ x+y^] ) sum and keep bytes from \fBrst\fP
 89-    \fBADD2k\fP  ( x* y*   -- x* y* x+y* )   sum and keep shorts from \fBwst\fP
 90-    \fBADD2kr\fP ( [x* y*] -- [x* y* x+y*] ) sum and keep shorts from \fBrst\fP
 91-
 92-.fi
 93-
 94-Thus for regular instructions writing a "generic" effect (leaving sigils off values whose size depends on \fIshort mode\fP) is sufficient to describe its behavior across all eight variations. Note that some instructions always read values of a fixed size. For example the boolean condition read by \fBJCN\fP is always one byte, no matter what modes are used.
 95-
 96-In \fIreturn mode\fP the stacks are reversed. Effects on \fBwst\fP will instead affect \fBrst\fP, and effects on \fBrst\fP will instead affect \fBwst\fP. For example, \fBSTH\fP reads a byte from \fBwst\fP and writes it to \fBrst\fP, but \fBSTHr\fP reads a byte from \fBrst\fP and writes it to \fBwst\fP.
 97-
 98-In \fIkeep mode\fP all the values on the left-hand side of the stack effect will also appear on the right-hand side before the outputs. For example, \fBSWP\fP is \fB(x y -- y x)\fP but \fBSWPk\fP is \fB(x y -- x y y x)\fP.
 99-
100-.SS TERMINOLOGY
101-
102-We consider the top of the stack to be the first value of the stack, and count back from there. For example, given the stack effect \fB( a b c -- )\fP we would say that \fBc\fP is the top of the stack, \fBb\fP is the second value (second from the top), and \fBa\fP is the third value (third from the top).
103-
104-.SH REGULAR INSTRUCTIONS
105-
106-.BR
107-
108-.SS INC ( x -- x+1 )
109-
110-Increment the top value of the stack by 1.
111-
112-Overflow will be truncated, so \fB#ff INC\fP will evaluate to \fB0x00\fP.
113-
114-.SS POP ( x -- )
115-
116-Remove the top value of the stack.
117-
118-\fBPOPk\fP is guaranteed to have no effect (it will not change the stack).
119-
120-.SS NIP ( x y -- y )
121-
122-Remove the second value of the stack.
123-
124-Note that \fBNIPk\fP is identical to \fBDUP\fP.
125-
126-.SS SWP ( x y -- y x )
127-
128-Swap the top two values of the stack.
129-
130-.SS ROT ( x y z -- y z x )
131-
132-Rotate the top three values of the stack. The lowest becomes the top and the others are each shifted down one place.
133-
134-.SS DUP ( x -- x x )
135-
136-Place a copy of the top value of the stack on top of the stack.
137-
138-.SS OVR ( x y -- x y x )
139-
140-Place a copy of the second value of the stack on top of the stack.
141-
142-.SS EQU ( x y -- x==y^ )
143-
144-Test whether the top two values of the stack are equal.
145-
146-Result is guaranteed to be boolean (\fB0x00\fP or \fB0x01\fP).
147-
148-.SS NEQ ( x y -- x!=y^ )
149-
150-Test whether the top two values of the stack are not equal.
151-
152-Result is guaranteed to be boolean (\fB0x00\fP or \fB0x01\fP).
153-
154-.SS GTH ( x y -- x>y^ )
155-
156-Test whether the second value of the stack is greater than the top.
157-
158-Result is guaranteed to be boolean (\fB0x00\fP or \fB0x01\fP).
159-
160-.SS LTH ( x y -- x<y^ )
161-
162-Test whether the second value of the stack is less than the top.
163-
164-Result is guaranteed to be boolean (\fB0x00\fP or \fB0x01\fP).
165-
166-.SS JMP ( x -- ; pc <- x )
167-
168-Jump to a location.
169-
170-The program counter (\fIpc\fP) is unconditionally updated. When \fIx\fP is a byte, it is treated as relative (\fBpc += x\fP) and when \fIx\fP is a short it is treated as absolute (\fBpc = x\fP).
171-
172-It is common to \fBJMP\fP with boolean bytes (0-1) to handle simple conditionals. For example:
173-
174-    \fB@max ( x^ y^ -- max^ ) GTHk JMP SWP POP JMP2r\fP
175-
176-.SS JCN ( bool^ x -- ; pc <- x if bool )
177-
178-Jump to a location when a condition is true.
179-
180-The program counter (\fIpc\fP) is updated when \fIbool\fP is non-zero. When \fIx\fP is a byte, it is treated as relative (\fBpc += x\fP) and when \fIx\fP is a short it is treated as absolute (\fBpc = x\fP).
181-
182-.SS JSR ( x -- [pc+1*] )
183-
184-Jump to a location, saving a reference to return to.
185-
186-Stores the next address to execute before unconditionally updating the program counter (\fIpc\fP). This instruction is usually used to invoke subroutines, which use the \fBJMP2r\fP to return. When \fIx\fP is a byte, it is treated as relative (\fBpc += x\fP) and when \fIx\fP is a short it is treated as absolute (\fBpc = x\fP).
187-
188-The saved address will always be a short regardless of \fIshort mode\fP.
189-
190-.SS STH ( x -- [x] )
191-
192-Move the top value of the stack to the return stack.
193-
194-.SS LDZ ( zp^ -- x )
195-
196-Load data from a zero-page address (\fB0x00 - 0xff\fP).
197-
198-.SS STZ ( x zp^ -- )
199-
200-Store data at a zero-page address (\fB0x00 - 0xff\fP).
201-
202-.SS LDR ( rel^ -- x )
203-
204-Load data from a relative address (\fBpc + x\fP).
205-
206-Note that unlike \fBLDZk\fP and \fBLDAk\fP the \fBLDRk\fP instruction is not very useful, since a relative address is usually only meaningful when run from a particular address (i.e. for a particular \fIpc\fP value).
207-
208-.SS STR ( x rel^ -- )
209-
210-Store data at a relative address (\fBpc + x\fP).
211-
212-Note that unlike \fBSTZk\fP and \fBSTAk\fP the \fBSTRk\fP instruction is not very useful, since a relative address is usually only meaningful when run from a particular address (i.e. for a particular \fIpc\fP value).
213-
214-.SS LDA ( abs* -- x )
215-
216-Load data from an absolute address (\fB0x0000 - 0xffff\fP).
217-
218-.SS STA ( x abs* -- )
219-
220-Store data at an absolute address (\fB0x0000 - 0xffff\fP).
221-
222-.SS DEI ( dev^ -- x )
223-
224-Read data from a device port (\fB0x00 - 0xff\fP).
225-
226-Reading from some ports may have an effect on the underlying VM; in other cases it will simply read values from device memory. For two-byte device ports the effect (if any) is triggered by reading the higher byte (the most significant byte).
227-
228-See Varvara device documentation for more details.
229-
230-.SS DEO ( x dev^ -- )
231-
232-Write data to a device port (\fB0x00 - 0xff\fP).
233-
234-Writing to some ports may have an effect on the underlying VM; in other cases it will simply write values to device memory. For two-byte device ports the effect (if any) is triggered by writing the lower byte (the least significant byte).
235-
236-See Varvara device documentation for more details.
237-
238-.SS ADD ( x y -- x+y )
239-
240-Add the top two values of the stack.
241-
242-Overflow will be truncated, so \fB#ff #03 ADD\fP will evaluate to \fB0x02\fP.
243-
244-.SS SUB ( x y -- x-y )
245-
246-Subtract the top of the stack from the second value of the stack.
247-
248-Underflow will be truncated, so \fB#01 #03 SUB\fP will evaluate to \fB0xfe\fP.
249-
250-.SS MUL ( x y -- xy )
251-
252-Multiply the top two values of the stack.
253-
254-Overflow will be truncated, so \fB#11 #11 MUL\fP will evaluate to \fB0x21\fP.
255-
256-.SS DIV ( x y -- x/y )
257-
258-Divide the second value of the stack by the top of the stack.
259-
260-\fBDIV\fP implements \fIEuclidean division\fP, which is also known as \fIinteger division\fP. It returns whole numbers, so \fB#08 #09 DIV\fP evaluates to \fB0x00\fP.
261-
262-Division by zero will return zero (instead of signaling an error).
263-
264-Unlike \fBADD\fP, \fBSUB\fP, and \fBMUL\fP, \fBDIV\fP does not behave correctly for numbers which should be treated as signed. For example, the signed byte representation of \fB-2\fP is \fB0xfe\fP, but \fB#06 #fe DIV\fP evaluates to \fB0x00\fP (\fB6 / 254 = 0\fP). For signed values the correct result should instead be \fB0xfd\fP (\fB6 / -2 = -3\fP).
265-
266-There is no \fIremainder\fP instruction, but the phrase \fBDIVk MUL SUB\fP can be used to compute the remainder.
267-
268-.SS AND ( x y -- x&y )
269-
270-Compute the bitwise intersection of the top two values of the stack.
271-
272-.SS ORA ( x y -- x|y )
273-
274-Compute the bitwise union of the top two values of the stack.
275-
276-.SS EOR ( x y -- x^y )
277-
278-Compute the bitwise exclusive-or (\fIxor\fP) of the top two values of the stack.
279-
280-.SS SFT ( x rl^ -- (x>>l)<<r )
281-
282-Compute a bit shift of the second value of the stack; the directions and distances of the shift are determined by the top value of the stack.
283-
284-Given a byte \fIrl\fP consisting of a low nibble (\fIl\fP) and a high nibble (\fIr\fP), this instruction shifts \fIx\fP left by \fIl\fP and then right by \fIr\fP.
285-
286-Right shifts are unsigned (they introduce zero bits). There are no signed shifts.
287-
288-For 16-bit (and 8-bit) values, one nibble (\fB0x0 - 0xf\fP) is sufficient to express all useful left or right shifts.
289-
290-  Right: \fB#ff #03 SFT\fP evaluates to \fB0x1f\fP
291-  Left:  \fB#ff #20 SFT\fP evaluates to \fB0xfc\fP
292-  Both:  \fB#ff #23 SFT\fP evaluates to \fB0x7c\fP
293-
294-There is no rotation instruction but one-byte rotations can be accomplished with \fBDUP\fP and \fBSFT2\fP:
295-
296-    \fB#87 DUP #03 SFT2 NIP\fP ( 0x87 rotated right by 3 is 0xf0 )
297-    \fB#87 DUP #20 SFT2 POP\fP ( 0x87 rotated left by 2 is 0x1e )
298-
299-.SH SPECIAL INSTRUCTIONS
300-
301-These instructions do not accept all mode flags (some do not accept any).
302-
303-.SS BRK
304-
305-The break instruction is used to end a vector call and return control to the virtual machine.
306-
307-.SS JCI, JMI, and JSI
308-
309-The "immediate jump" instructions are produced by the assembler. They interpret the next 2 bytes of the ROM as a relative address (\fIaddr\fP) and have the following effects:
310-
311- \fBJMI\fP ( -- )       jump to \fIaddr\fP unconditionally
312- \fBJCI\fP ( bool^ -- ) jump to \fIaddr\fP if \fIbool\fP is non-zero
313- \fBJSI\fP ( -- [pc*] ) jump to \fIaddr\fP saving the current address (\fIpc\fP) on \fIrst\fP
314-
315-(The instruction pointer will be moved forward 2 bytes, past the relative address.)
316-
317-These instructions are created by the assembler from special syntax:
318-
319-    \fB!dest\fP produces \fBJMI wx yz\fP
320-    \fB?dest\fP produces \fBJCI wx yz\fP
321-    \fBdest\fP  produces \fBJSI wx yz\fP (assuming \fBdest\fP is not a macro or reserved)
322-
323-.SS LIT, LIT2, LITr, and LIT2r
324-
325-Push a literal value on the stack.
326-
327-The "literal" instructions are used to push new data onto the stacks. They interpret the next 1-2 bytes of the ROM (\fIwx\fP, \fIwxyz\fP) as data and push it onto the corresponding stack:
328-
329-    \fBLIT\fP   ( -- wx^ )     push literal byte \fIwx\fP onto the \fBwst\fP
330-    \fBLITr\fP  ( -- [wx^] )   push literal byte \fIwx\fP onto the \fBrst\fP
331-    \fBLIT2\fP  ( -- wxyz* )   push literal short \fIwxyz\fP (2 bytes) onto the \fBwst\fP
332-    \fBLIT2r\fP ( -- [wxyz*] ) push literal short \fIwxyz\fP (2 bytes) onto the \fBrst\fP
333-
334-(The instruction pointer will be moved forward 1-2 bytes, past the literal data.)
335-
336-Literal values can be updated dynamically using store instructions:
337-
338-    #abcd ;x STA2
339-    ( later on... )
340-    LIT2 [ @x $2 ]
341-
342-.SH SEE ALSO
343-
344- https://wiki.xxiivv.com/site/uxntal_opcodes.html   \fIUxntal Opcodes\fP
345- https://wiki.xxiivv.com/site/uxntal_syntax.html    \fIUxntal Syntax\fP
346- https://wiki.xxiivv.com/site/uxntal_modes.html     \fIUxntal Modes\fP
347- https://wiki.xxiivv.com/site/uxntal_immediate.html \fIImmediate opcodes\fP
348- https://wiki.xxiivv.com/site/varvara.html          \fIVarvara\fP
+0, -394
  1@@ -1,394 +0,0 @@
  2-
  3-=== Command-line switches ===
  4-
  5--D
  6-  Use double buffering for the display.
  7-
  8--F
  9-  Start in full screen mode. It will decide the appropriate screen size
 10-  automatically if you do not specify the -w and -h switches. This does
 11-  not imply -S but you may specify both switches.
 12-
 13--I
 14-  Use a separate thread to read from stdin.
 15-
 16--J #
 17-  Set joystick mode. See the below section about joystick for details.
 18-
 19--N
 20-  Tells the window manager to omit the frame.
 21-
 22--O
 23-  Emulate touch screen. (This is an experimental feature, and may be
 24-  changed or removed in future.)
 25-
 26--Q
 27-  Disable the mouse initially (it can still be enabled at run time).
 28-
 29--S
 30-  Disallow the uxn program to change the screen size.
 31-
 32--T year.month.day.hours.minutes.seconds.wday.yday.yday.isdst
 33-  Use a fixed value for the date/time, by numbers with dots in between. In
 34-  this case, it will read the same values from the date/time device each
 35-  time it is read. If you put less numbers than expected, then zero will
 36-  be used for the remaining values; however, some programs will use these
 37-  values to seed a random number generator and will not work correctly if
 38-  they are zero. (Note that the month number is zero-based, while the day
 39-  number is one-based.)
 40-
 41--T @unixtime
 42-  Use a fixed value for the date/time like the other -T does, but treat
 43-  the argument as UNIX time if the argument starts with a at sign; it will
 44-  be converted to the corresponding date/time in the Gregorian calendar.
 45-  In this case, the presence or absence of the -Z switch does matter,
 46-  since it will convert it to local time if the -Z switch is not specified
 47-  or to UTC if the -Z switch is specified.
 48-
 49--Y
 50-  Enable file system access including writing.
 51-
 52--Z
 53-  Use UTC instead of local time. (Has no effect in combination with -T,
 54-  unless the UNIX time variant of -T is used.)
 55-
 56--a #
 57-  Set audio. See the below section about audio for details. If both -a and
 58-  -n switches are used, then audio data is written to stdout (it is signed
 59-  16-bits big-endian).
 60-
 61--d
 62-  Enable some debugging features. (Some will work even without this.)
 63-
 64--e #
 65-  Execute another program (with "sh -c"), which will be connected to this
 66-  one using the standard I/O. For example, it can be used with nc to make
 67-  remote two players.
 68-
 69--h #
 70-  Set default screen height.
 71-
 72--i
 73-  Hide the system mouse cursor. (The Uxn program might still draw its own
 74-  mouse cursor, which most do.)
 75-
 76--j
 77-  Enable key repeat for joypad emulation.
 78-
 79--m #
 80-  Specify memory writes and device writes to do before or after loading the
 81-  file. See the "Memory/device scripts" section below for details.
 82-
 83--n
 84-  Disable GUI. Either this switch or -I is required in order to read stdin.
 85-  If neither -n nor -I is specified, then stdin cannot be read (although
 86-  command-line arguments can still be read).
 87-
 88--p #
 89-  Select the palette. Valid palette numbers are 0 to 7, where 7 is the
 90-  default setting and means that the running Uxn program can set colours.
 91-  If you follow the palette number by a equal sign and then RGB hex codes
 92-  then it will define that palette. Specify eight RGB colours each of which
 93-  is six hex digits, with commas in between.
 94-
 95--q
 96-  Disable standard I/O.
 97-
 98--s #
 99-  Define scroll amount.
100-
101--t #
102-  Set the frame rate, in milliseconds per frame.
103-
104--w #
105-  Set default screen width.
106-
107--x
108-  Enable nonstandard features.
109-
110--y
111-  Enable read-only file system access.
112-
113--z #
114-  Set zoom level.
115-
116-
117-=== Function keys ===
118-
119-F1
120-  Advance one frame, even if paused.
121-
122-F2
123-  Mute/unmute audio.
124-
125-F3
126-  Toggle the mouse mode. When the mouse mode is disabled, the mouse device
127-  does not work; the mouse vector is not called and the mouse coordinates
128-  and button state is not updated.
129-
130-F4
131-  Change which graphics layers are displayed. Either both layers, or only
132-  foreground or only background.
133-
134-F5
135-  Redraw screen. If the right shift key is also pushed, then also sends
136-  some debug output to stderr.
137-
138-F6 / F7
139-  Palette selection.
140-
141-F8
142-  Debug menu.
143-
144-F9
145-  Restart.
146-
147-F10
148-  Quit.
149-
150-PAUSE
151-  Pause/unpause VM.
152-
153-PAGE-UP / PAGE-DOWN
154-  Scroll up/down.
155-
156-Some programs use shortcut keys with control and letters. This does not
157-work in this program; therefore, END is an alias for the joypad A button
158-(the left control key also corresponds to the joypad A button, but if used
159-together with letter keys, will enter control characters instead).
160-
161-
162-=== Audio ===
163-
164-The audio setting consists of a sequence of letters and numbers; each item
165-is one letter "a" to "z" followed by a number of any number of digits. (It
166-can optionally have - at first for negative numbers, although most options
167-cannot use negative numbers.)
168-
169-b = Buffer size.
170-
171-c = Number of output channels, which can be 1 (mono) or 2 (stereo).
172-
173-e = Envelope speed. If not specified, then it is fifteenths of seconds.
174-
175-m = If set to 1, then audio is initially muted. (This option is ignored if
176-the -n switch is used.)
177-
178-n = Transpose amount.
179-
180-r = Sample rate in hertz. Normally, this setting is also the sample rate
181-for middle C.
182-
183-v = Output volume from 0 to 273. If not all of the four VM audio channels
184-are being used, then this number may be set higher than 273.
185-
186-(Currently there is not the setting of interpolation, filter, etc.)
187-
188-
189-=== Joystick ===
190-
191-The joystick parameter can be ? to list joysticks, or ? and a number to
192-display details about that joystick, or it can be the below specification
193-in order to configure joysticks.
194-
195-The first part is numbers with commas in between, being the joystick ID
196-numbers (as shown by the ? list); up to four numbers can be specified. If
197-a number is omitted, then that slot is not used.
198-
199-After the first part is a forward slash, and then the mapping (all
200-joysticks must use an identical mapping). Each item is a letter and then
201-a number, with no delimiters in between. The letters can be:
202-
203-A B S T U D L R
204-  Specify which joystick button to map to the uxn joypad button;
205-  respectively, A, B, SELECT, START, UP, DOWN, LEFT, RIGHT. Only the first
206-  128 buttons can be mapped.
207-
208-X Y x y
209-  Specify which axis to use as the X and Y axis. Uppercase letters means
210-  that axis is reversed; do not specify both "X" and "x", and do not
211-  specify both "Y" and "y".
212-
213-s
214-  Set sensitivity, from 1 to 32767. Higher numbers mean the joystick must
215-  be moved more in order to register, while lower numbers means that it
216-  does not need to moved much in order to be registered.
217-
218-H h I i
219-  Specify the hat number to use. Different letters correspond to different
220-  orientations (specify only up to one of these letters, not all of them).
221-  "h" is normal, "H" is reverse, "I" and "i" are sideways.
222-
223-
224-=== Nonstandard features ===
225-
226-The -x switch enables the following nonstandard features, which include
227-some nonstandard expansion commands and nonstandard ports. They should not
228-be used in portable programs until they become standardized, though (you
229-can discuss in the mailing list of Uxn; changes may also be made in future,
230-possibly as a result of the discussions).
231-
232-If any such features listed below become standardized in future, then their
233-documentation will be moved to the varvara.doc file, and the -x switch will
234-no longer be required in order to use them.
235-
236-The list of expansion commands below uses > for output parameters (from the
237-emulator to the program), ? for parameters that may be input and/or output,
238-* for 16-bit values, and % for values of lengths other than 8-bits or
239-16-bits or if they are of a variable length.
240-
241-03 device_id uuid% >version ?extra%
242-  Loads a nonstandard device, or a nonstandard command for an existing
243-  device or that applies globally; see below section for details. This is
244-  called a "UUID-based extension".
245-
246-04 >pages*
247-  Tells number of expanded memory pages. (This is the maximum valid value
248-  for src_page and dst_page in expanded memory operations.) (If some of the
249-  pages are read-only, then this is only the number of writable pages. The
250-  number of writable pages might be less than the tital number of pages on
251-  systems with insufficient memory but that is able to emulate larger
252-  memory by reading from the program file instead.)
253-
254-a0 offset%
255-  Given a 32-bit offset, seek the currently opened file to the specified
256-  absolute offset. (The effect of seeking (absolute or relative) when a
257-  file is opened in append mode is unspecified.) If the file is not already
258-  open, it is opened for reading and writing (the append flag is ignored);
259-  if writing is not allowed, then it is opened for reading only.
260-
261-a1 offset%
262-  Given a signed 32-bit offset, seek the currently opened file to the
263-  specified offset relative to the current file position.
264-
265-a2 offset%
266-  Given a signed 32-bit offset, seek the currently opened file to the
267-  specified offset relative to the end of the file.
268-
269-a3 >offset%
270-  Tell the current offset of the currently opened file; the 32-bit offset
271-  will be stored in the expansion command buffer.
272-
273-b_ ?offset%
274-  Same as a_ but for the second file.
275-
276-Nonstandard ports of devices are:
277-
278-16
279-  Input flags. Currently only the low bit is used (the rest must be clear).
280-  If the low bit is set, then EOF trigger is enabled; the vector is called
281-  on EOF, with the type and input both set to zero.
282-
283-36*/46*/56*/66*
284-  Detune register. This is treated as sixteen fraction bits, and is then
285-  added to 1.0 and multiplied by the frequency which has been specified by
286-  the pitch and length ports.
287-
288-a7/b7
289-  In addition to the usual effect (sets the append mode), writing anything
290-  to this port (whether or not it is the same value that was previously
291-  written) will close the file.
292-
293-
294-=== Extensions ===
295-
296-This describes the nonstandard "03 extensions" command mentioned above.
297-
298-The parts of the command are:
299-
300-* Command code: Always 0x03.
301-
302-* Device number: A command that does not load or override a device into a
303-device slot is zero, otherwise it is a nonzero multiple of sixteen. Some
304-extensions and some implementations may have further restrictions. If this
305-number is not a multiple of sixteen (but must be at least sixteen), then
306-the low nybble indicates how many additional consecutive devices to be
307-affected; e.g. #33 means to affect all four audio devices (the high nybble
308-is 3 for the first audio device, and the low nybble 3 means the other 3).
309-
310-* UUID: Sixteen bytes, which identifies the extension.
311-
312-* Version: One byte. The emulator writes a nonzero value here (the specific
313-value is defined by the extension) if it is supported in this mode with
314-this device number and other parameters, or zero if it is not implemented.
315-(The uxn program should put zero here by default, so that if running on an
316-emulator that doesn't process the 03 command at all, it will work.)
317-
318-* Extra data: The number of bytes and meaning is defined by the specific
319-extension; this may be read-only, write-only, or some combination. If the
320-extension is not implemented, then the emulator MUST ignore it and MUST NOT
321-attempt to write anything here, and MUST NOT override any devices.
322-
323-An example of how to use this:
324-
325-  @load-ext1 ( -- success ) ;ext1 #02 DEO2 ;ext1/v LDA JMP2r
326-  @ext1 03 d0 <uuid> &v 00
327-
328-This example does not use any extra data, and selects an extension for
329-device #d0. The <uuid> must be replaced by the appropriate sixteen-byte
330-UUID for the extension being selected.
331-
332-
333-=== Implemented extensions ===
334-
335-This section lists the UUID-based extensions that are implemented in
336-this emulator (the -x switch is required, since they use nonstandard
337-expansion commands to activate them).
338-
339-See the file extension.doc for the definition of the extensions.
340-
341-* 4105259c-e061-11f0-963f-002618745416 (uses /dev/urandom)
342-
343-* 80175132-e263-11ed-b8c9-002618745416
344-
345-* 970b5a0c-2c44-11ee-ac3b-002618745416
346-
347-* 9c5f1356-6bc5-11ef-a6c9-002618745416 (also requires -I and -Y)
348-
349-
350-=== Memory/device scripts ===
351-
352-A command with the -m switch has the subcommands which have the format of
353-an optional "." to indicate executed after instead of before loading, and
354-then an optional letter "g" to "z" to specify the specific command (if none
355-is specified, then it is a memory command), and then the address in hex,
356-and then optionally = and the data in hex. The address is treated as a pure
357-number while the data is a sequence of bytes so the number of digits must
358-be an even number.
359-
360-It can also optionally be @ and a file name, in which case the commands are
361-loaded from a file. The file cannot itself have @ commands, but it may have
362-lines starting with # as comments.
363-
364-The subcommands are:
365-
366-Memory (no letter)
367-  Write memory starting at the specified address.
368-
369-Device trigger (p)
370-  Write and trigger devices starting at the specified address. If there are
371-  multiple bytes of data, then multiple consecutive ports are written to
372-  and are triggered.
373-
374-Device set (s)
375-  Same as device trigger but omit the trigger; only writes are done.
376-
377-Extension set (u)
378-  The data is the same as the 03 expansion command but without the initial
379-  03; it is automatically written into memory and executed as an expansion
380-  command. (This is a shortcut for the specific case of loading an
381-  extension that is not loaded by the uxn program itself, rather than
382-  having to use the -m and -mp switches. The address can be omitted,
383-  since the expansion command does not care about the address.)
384-
385-Execute (x)
386-  Execute uxn code at the specified address, which must be nonzero, and
387-  cannot be in expanded memory. (The data of this command is not used.)
388-
389-Screen compatibility flag (z2)
390-  The first byte of the data is the screen compatibility mode; see
391-  extension.doc for a list of the valid flags.
392-
393-During the execution of any of these commands, it behaves as though the -x
394-switch is specified, even if it isn't specified.
395-
+0, -177
  1@@ -1,177 +0,0 @@
  2-( dev/audio )
  3-
  4-%GET-NOTE { #00 SWP ;melody ADD2 LDA }
  5-%GET-HEXCHAR  { #00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2 }
  6-
  7-( devices )
  8-
  9-|00 @System     [ &vector $2 &pad      $6 &r      $2 &g     $2 &b      $2 ]
 10-|20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y    $2 &addr  $2 &pixel $1 &sprite $1 ]
 11-|30 @Audio0     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
 12-|80 @Controller [ &vector $2 &button $1 &key    $1 ]
 13-
 14-( variables )
 15-
 16-|0000
 17-
 18-@timer     $1
 19-@progress  $1
 20-@selection $1
 21-@offset
 22-	&x $2 &y $2
 23-
 24-|0100 ( -> )
 25-	
 26-	( theme )
 27-	#0f8f .System/r DEO2 
 28-	#0f8f .System/g DEO2 
 29-	#0f80 .System/b DEO2 
 30-
 31-	( vectors )
 32-	;on-frame .Screen/vector DEO2
 33-	;on-button .Controller/vector DEO2
 34-
 35-	( setup synth )
 36-	#0208 .Audio0/adsr DEO2
 37-	;saw .Audio0/addr DEO2
 38-	#0100 .Audio0/length DEO2
 39-	#dd .Audio0/volume DEO ( TODO: turn ON )
 40-
 41-	( center )
 42-	.Screen/width DEI2 #01 SFT2 #0080 SUB2 .offset/x STZ2
 43-	.Screen/height DEI2 #01 SFT2 #0040 SUB2 .offset/y STZ2
 44-
 45-	;draw JSR2
 46-	#02 ;draw-selector JSR2
 47-
 48-BRK
 49-
 50-@on-button ( -> )
 51-
 52-	.Controller/button DEI #04 SFT
 53-	[ #01 ] NEQk NIP ,&no-up JCN 
 54-		.selection LDZ STHk 
 55-		#00 ;draw-note JSR2
 56-		[ STHkr GET-NOTE INC ] #00 STHkr ;melody ADD2 STA
 57-		STHr #01 ;draw-note JSR2
 58-		#02 ;draw-selector JSR2
 59-		&no-up
 60-	[ #02 ] NEQk NIP ,&no-down JCN 
 61-		.selection LDZ STHk 
 62-		#00 ;draw-note JSR2
 63-		[ STHkr GET-NOTE #01 SUB ] #00 STHkr ;melody ADD2 STA
 64-		STHr #01 ;draw-note JSR2
 65-		#02 ;draw-selector JSR2
 66-		&no-down
 67-	[ #04 ] NEQk NIP ,&no-left JCN 
 68-		#00 ;draw-selector JSR2
 69-		.selection LDZ #01 SUB #1f AND .selection STZ
 70-		#02 ;draw-selector JSR2
 71-		&no-left
 72-	[ #08 ] NEQk NIP ,&no-right JCN 
 73-		#00 ;draw-selector JSR2
 74-		.selection LDZ INC #1f AND .selection STZ
 75-		#02 ;draw-selector JSR2
 76-		&no-right
 77-	POP
 78-	
 79-BRK
 80-
 81-@on-frame ( -> )
 82-
 83-	( incr ) .timer LDZ INC .timer STZ 
 84-	( skip ) .timer LDZ #10 EQU #01 JCN [ BRK ]
 85-	.progress LDZ 
 86-	( play note )    DUP GET-NOTE .Audio0/pitch DEO
 87-	( erase last )   DUP #01 SUB #1f AND #01 ,draw-note JSR
 88-	( draw current ) #01 ,draw-note JSR
 89-	( incr ) .progress LDZ INC #1f AND .progress STZ
 90-	#00 .timer STZ
 91-
 92-BRK
 93-
 94-@draw ( -- )
 95-
 96-	#20 #00
 97-	&loop
 98-		DUP #01 ,draw-note JSR
 99-		INC GTHk ,&loop JCN
100-	POP2
101-
102-JMP2r
103-
104-@draw-note ( id color -- )
105-
106-	STH STH
107-	( set x ) [ #00 STHkr ] #30 SFT2 .offset/x LDZ2 ADD2 .Screen/x DEO2
108-	( set y ) [ #00 #00 STHkr ;melody ADD2 LDA ] #20 SFT2 #0100 SWP2 SUB2 .offset/y LDZ2 ADD2 #0080 ADD2 .Screen/y DEO2
109-	( set addr ) ;marker-icn [ #00 .progress LDZ STHr EQU #08 MUL ADD2 ] .Screen/addr DEO2
110-	( draw ) STHr .Screen/sprite DEO
111-
112-JMP2r
113-
114-@draw-selector ( color -- )
115-	
116-	STH
117-	[ #00 .selection LDZ ] #30 SFT2 .offset/x LDZ2 ADD2 .Screen/x DEO2
118-	#0070 .offset/y LDZ2 ADD2 .Screen/y DEO2
119-	;selector-icn .Screen/addr DEO2
120-	STHkr .Screen/sprite DEO
121-
122-	.Screen/y DEI2k #0008 ADD2 ROT DEO2
123-	.selection LDZ GET-NOTE STHr ,draw-byte JSR
124-
125-JMP2r
126-
127-@draw-byte ( byte color -- )
128-	
129-	STH 
130-	DUP 
131-		#04 SFT GET-HEXCHAR 
132-		( draw ) STHkr .Screen/sprite DEO
133-	.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
134-		#0f AND GET-HEXCHAR 
135-		( draw ) STHr .Screen/sprite DEO
136-
137-JMP2r
138-
139-@melody 
140-	54 52 54 4f 4b 4f 48 ff
141-	54 52 54 4f 4b 4f 48 ff
142-	54 56 57 56 57 54 56 54 
143-	56 52 54 52 54 50 54 ff 
144-
145-@selector-icn
146-	0000 0010 387c 0000
147-
148-@marker-icn
149-	3844 8282 8244 3800
150-	387c fefe fe7c 3800
151-
152-@saw 
153-	0003 0609 0c0f 1215 181b 1e21 2427 2a2d
154-	3033 3639 3b3e 4143 4649 4b4e 5052 5557
155-	595b 5e60 6264 6667 696b 6c6e 7071 7274
156-	7576 7778 797a 7b7b 7c7d 7d7e 7e7e 7e7e
157-	7f7e 7e7e 7e7e 7d7d 7c7b 7b7a 7978 7776
158-	7574 7271 706e 6c6b 6967 6664 6260 5e5b
159-	5957 5552 504e 4b49 4643 413e 3b39 3633
160-	302d 2a27 2421 1e1b 1815 120f 0c09 0603
161-	00fd faf7 f4f1 eeeb e8e5 e2df dcd9 d6d3
162-	d0cd cac7 c5c2 bfbd bab7 b5b2 b0ae aba9
163-	a7a5 a2a0 9e9c 9a99 9795 9492 908f 8e8c
164-	8b8a 8988 8786 8585 8483 8382 8282 8282
165-	8182 8282 8282 8383 8485 8586 8788 898a
166-	8b8c 8e8f 9092 9495 9799 9a9c 9ea0 a2a5
167-	a7a9 abae b0b2 b5b7 babd bfc2 c5c7 cacd
168-	d0d3 d6d9 dcdf e2e5 e8eb eef1 f4f7 fafd 
169-
170-@font-hex ( 0-F )
171-	007c 8282 8282 827c 0030 1010 1010 1010
172-	007c 8202 7c80 80fe 007c 8202 1c02 827c
173-	000c 1424 4484 fe04 00fe 8080 7c02 827c
174-	007c 8280 fc82 827c 007c 8202 1e02 0202
175-	007c 8282 7c82 827c 007c 8282 7e02 827c
176-	007c 8202 7e82 827e 00fc 8282 fc82 82fc
177-	007c 8280 8080 827c 00fc 8282 8282 82fc
178-	007c 8280 f080 827c 007c 8280 f080 8080
+0, -59
 1@@ -1,59 +0,0 @@
 2-( 54K . Console Test
 3-| arguments "abc" "def"
 4-| stream "ghi" )
 5-
 6-|10 @Console/vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
 7-|0050 @Varvara/version
 8-
 9-|100
10-
11-@on-reset ( -> )
12-	;meta #06 DEO2
13-	;on-console .Console/vector DEO2
14-	[ LIT2 01 -Console/type ] DEI NEQ ?fail
15-	BRK
16-
17-@meta 00
18-	( name ) "Console 20 "Device 20 "Test(80K) 0a
19-	( details ) "Testing 20 "Program 0a
20-	( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
21-	( date ) "23 20 "Jul 20 "2026 00
22-	( . ) 01
23-	( - ) 56 =Varvara/version
24-
25-@on-console ( -> )
26-	.Console/type DEI .Console/read DEI
27-	( inc ) [ LIT2 &ptr =expect ] INC2k INC2 ,&ptr STR2
28-	LDA2 NEQ2 ?fail
29-	,&ptr LDR2 ;expect/end EQU2 ?pass
30-	BRK
31-
32-@fail ( -> )
33-	;dict/fail str/<print>
34-	#010f DEO
35-	BRK
36-
37-@pass ( type read ptr* -> )
38-	;dict/pass str/<print>
39-	#800f DEO
40-	BRK
41-
42-(
43-@|Utils )
44-
45-@str/<print> ( str* -- )
46-	LDAk DUP ?{ POP POP2 JMP2r }
47-	#18 DEO
48-	INC2 !/<print>
49-
50-(
51-@|Data )
52-
53-@expect ( . )
54-	( arg1 ) [ 02 "a 02 "b 02 "c 03 0a ]
55-	( arg2 ) [ 02 "d 02 "e 02 "f 04 0a ]
56-	( strm ) [ 01 "g 01 "h 01 "i 04 0a ] &end
57-
58-@dict/pass "Console: 20 "pass 0a $1
59-	&fail "Console: 20 "fail 0a $1
60-
+0, -87
 1@@ -1,87 +0,0 @@
 2-( 54K . Datetime Test )
 3-
 4-|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
 5-|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
 6-|0050 @Varvara/version
 7-
 8-|100
 9-
10-@on-reset ( -> )
11-	;meta #06 DEO2
12-	.DateTime/year DEI2k dec/<print>
13-	[ LIT "- ] .Console/write DEO
14-	INC INC DEIk INC <print-dec-pad>
15-	[ LIT "- ] .Console/write DEO
16-	INC DEI <print-dec-pad>
17-	#0a18 DEO
18-	( | .. )
19-	;dict/date str/<print>
20-	[ LIT2 00 -DateTime/dotw ] DEI #20 SFT ;dict/days ADD2 str/<print>
21-	[ LIT2 ", 18 ] DEO
22-	#2018 DEO
23-	[ LIT2 00 -DateTime/month ] DEI #20 SFT ;dict/months ADD2 str/<print>
24-	#2018 DEO
25-	[ LIT2 00 -DateTime/day ] DEI dec/<print>
26-	[ LIT2 ", 18 ] DEO
27-	#2018 DEO
28-	.DateTime/year DEI2 dec/<print>
29-	#0a18 DEO
30-	( | .. )
31-	;dict/time str/<print>
32-	.DateTime/hour DEIk <print-dec-pad>
33-	[ LIT2 ": 18 ] DEO
34-	INC DEIk <print-dec-pad>
35-	[ LIT2 ": 18 ] DEO
36-	INC DEI <print-dec-pad>
37-	#0a18 DEO
38-	( | .. )
39-	;dict/doty str/<print>
40-	.DateTime/doty DEI2 dec/<print>
41-	#0a18 DEO
42-	#800f DEO
43-	BRK
44-
45-@meta 00
46-	( name ) "Datetime 20 "Device 20 "Test(80K) 0a
47-	( details ) "Testing 20 "Program 0a
48-	( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
49-	( date ) "24 20 "Jun 20 "2026 00
50-	( . ) 01
51-	( - ) 56 =Varvara/version
52-
53-@<print-dec-pad> ( byte -- )
54-	#0a DIVk dec/<emit>
55-	DIVk MUL SUB
56-	( >> )
57-
58-@dec/<emit> ( byte -- )
59-	LIT "0 ADD #18 DEO
60-	JMP2r
61-
62-@str/<print> ( str* -- )
63-	LDAk DUP ?{ POP POP2 JMP2r }
64-	#18 DEO
65-	INC2 !/<print>
66-
67-@dec/<print> ( short* -- )
68-	#2710 [ LIT2r 00fb ]
69-	&>w
70-		DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?{ DUP dec/<emit>
71-			INCr }
72-		POP2 #000a DIV2 SWPr INCr STHkr ?&>w
73-	POP2r POP2 POP2 JMP2r
74-
75-(
76-@|assets )
77-
78-@dict/date "The 20 "date 20 "is: 20 $1
79-	&time "The 20 "time 20 "is: 20 $1
80-	&doty "The 20 "day 20 "of 20 "the 20 "year 20 "is: 20 $1
81-	&months [
82-	"Jan $1 "Feb $1 "Mar $1 "Apr $1
83-	"May $1 "Jun $1 "Jul $1 "Aug $1
84-	"Sep $1 "Oct $1 "Nov $1 "Dec $1 ]
85-	&days [
86-	"Sun $1 "Mon $1 "Tue $1 "Wed $1
87-	"Thu $1 "Fri $1 "Sat $1 ]
88-
+0, -229
  1@@ -1,229 +0,0 @@
  2-( 54K . File Test )
  3-
  4-|10 @Console/vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
  5-|a0 @File/vector $2 &success $1 &success-lb $1 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
  6-|004f @Varvara/version
  7-
  8-|100
  9-
 10-@on-reset ( -> )
 11-	;meta #06 DEO2
 12-	#800f DEO
 13-	;dict/write file/test-write <test>
 14-	;dict/append file/test-append <test>
 15-	;dict/read file/test-read <test>
 16-	;dict/read-of file/test-read-of <test>
 17-	;dict/stat file/test-stat <test>
 18-	;dict/stat-oversize file/test-stat-oversize <test>
 19-	;dict/stat-of file/test-stat-of <test>
 20-	;dict/write-of file/test-write-of <test>
 21-	;dict/delete file/test-delete <test>
 22-	;dict/success file/test-success <test>
 23-	( | Dir )
 24-	;dict/dir-spacer file/test-dir-spacer <test>
 25-	;dict/dir-partial file/test-dir-partial <test>
 26-	( ;dict/dir-nostream file/test-dir-nostream <test> ) ( | cleanup )
 27-	;file/name .File/name DEO2
 28-	#01 .File/delete DEO
 29-	BRK
 30-
 31-@meta 00
 32-	( name ) "File 20 "Device 20 "Test(80K) 0a
 33-	( details ) "Testing 20 "Program 0a
 34-	( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
 35-	( date ) "24 20 "Jun 20 "2026 00
 36-	( . ) 01
 37-	( - ) 56 =Varvara/version
 38-
 39-(
 40-@|Tests )
 41-
 42-@file/test-write ( -- pass )
 43-	;&name .File/name DEO2
 44-	#0002 .File/length DEO2
 45-	;&a1 .File/write DEO2
 46-	.File/success DEI2 #0002 EQU2 JMP2r
 47-
 48-@file/test-append ( -- pass )
 49-	;&name .File/name DEO2
 50-	#0002 .File/length DEO2
 51-	#01 .File/append DEO
 52-	;&b1 .File/write DEO2
 53-	.File/success DEI2 #0002 EQU2 JMP2r
 54-
 55-@file/test-read ( -- pass )
 56-	;&name .File/name DEO2
 57-	( 4+2 ) #0006 .File/length DEO2
 58-	;&read-buf .File/read DEO2
 59-	( success ) .File/success DEI2 #0004 EQU2
 60-	( a ) ;&a1 LDA2 ;&a2 LDA2 EQU2 AND
 61-	( b ) ;&b1 LDA2 ;&b2 LDA2 EQU2 AND JMP2r
 62-
 63-@file/test-stat ( -- pass )
 64-	;&name .File/name DEO2
 65-	#0004 .File/length DEO2
 66-	;&stat-buf .File/stat DEO2
 67-	( success ) .File/success DEI2 #0004 EQU2
 68-	( a ) ;&stat-hs LDA2 LIT2 "00 EQU2 AND
 69-	( b ) ;&stat-ls LDA2 LIT2 "04 EQU2 AND
 70-	( | try missing file )
 71-	;&unknown-name .File/name DEO2
 72-	#0002 .File/length DEO2
 73-	;&stat-buf .File/stat DEO2
 74-	;&stat-buf LDA2 LIT2 "!! EQU2 AND JMP2r
 75-
 76-@file/test-stat-of ( -- pass )
 77-	;&name .File/name DEO2
 78-	#0004 .File/length DEO2
 79-	#fffe .File/stat DEO2
 80-	.File/success DEI2 #0002 EQU2 JMP2r
 81-
 82-@file/test-stat-oversize ( -- pass )
 83-	;&name .File/name DEO2
 84-	#0020 .File/length DEO2
 85-	#00 .File/append DEO
 86-	#f000 .File/write DEO2
 87-	( | Read stat too small )
 88-	;&name .File/name DEO2
 89-	#0000 .File/length DEO2
 90-	;&sobuf .File/stat DEO2
 91-	;&sobuf LDA #00 EQU ?{ #00 JMP2r }
 92-	#0001 .File/length DEO2
 93-	;&sobuf .File/stat DEO2
 94-	;&sobuf LDA LIT "? EQU ?{ #00 JMP2r }
 95-	#0002 .File/length DEO2
 96-	;&sobuf .File/stat DEO2
 97-	;&sobuf LDA2 LIT2 "20 EQU2 ?{ #00 JMP2r }
 98-	#0003 .File/length DEO2
 99-	;&sobuf .File/stat DEO2
100-	;&sobuf LDA2 LIT2 "02 EQU2 JMP2r
101-	&sobuf $4
102-
103-@file/test-delete ( -- pass )
104-	;&name .File/name DEO2
105-	#01 .File/delete DEO
106-	.File/success DEI2 #0001 EQU2
107-	( | stat )
108-	;&name .File/name DEO2
109-	#0002 .File/length DEO2
110-	;&null-buf .File/stat DEO2
111-	;&null-buf LDA2 LIT2 "!! EQU2 AND
112-	( | try failure )
113-	#01 .File/delete DEO
114-	.File/success DEI2 #0000 EQU2 AND JMP2r
115-
116-@file/test-write-of ( -- pass )
117-	;&name .File/name DEO2
118-	#0004 .File/length DEO2
119-	#fffe .File/write DEO2
120-	.File/success DEI2 #0002 EQU2 JMP2r
121-
122-@file/test-read-of ( -- pass )
123-	;&name .File/name DEO2
124-	#0002 .File/length DEO2
125-	#ffff .File/read DEO2
126-	.File/success DEI2 #0001 EQU2 JMP2r
127-
128-@file/test-dir-spacer ( -- pass )
129-	;&dirpath .File/name DEO2
130-	#0200 .File/length DEO2
131-	;&dirbuf .File/read DEO2
132-	;&dirbuf #0004 ADD2 LDA #09 EQU JMP2r
133-
134-	&dirpath ". 00
135-
136-@file/test-dir-partial ( -- pass )
137-	( a ) LIT "~ ;&dirbuf #0007 ADD2 STA
138-	( b ) LIT "~ ;&dirbuf #0009 ADD2 STA
139-	;&dirpath .File/name DEO2
140-	#0008 .File/length DEO2
141-	;&dirbuf .File/read DEO2
142-	( b ) LIT "~ ;&dirbuf #0009 ADD2 LDA EQU
143-	( a ) LIT "~ ;&dirbuf #0007 ADD2 LDA NEQ AND JMP2r
144-
145-@file/test-dir-nostream ( -- pass )
146-	;&dirpath .File/name DEO2
147-	#0008 .File/length DEO2
148-	;&bufa .File/read DEO2
149-	;&bufb .File/read DEO2
150-	;&bufa ;&bufb !str/cmp
151-
152-@file/test-success ( -- pass )
153-	;&name .File/name DEO2
154-	#01 .File/delete DEO
155-	#00 .File/success-lb DEI EQU ?{ #00 JMP2r }
156-	( | Make file )
157-	#0003 .File/length DEO2
158-	;&string .File/write DEO2
159-	.File/success DEI2 #0003 EQU2 ?{ #00 JMP2r }
160-	( | Zero load )
161-	#0000 .File/length DEO2
162-	;&sz .File/read DEO2
163-	#00 .File/success-lb DEI EQU ?{ #00 JMP2r }
164-	( | Each letter )
165-	#0001 .File/length DEO2
166-	;&sa .File/read DEO2
167-	.File/success-lb DEI ?{ #00 JMP2r }
168-	[ LIT2 &sa $1 "a ] EQU ?{ #00 JMP2r }
169-	;&sb .File/read DEO2
170-	.File/success-lb DEI ?{ #00 JMP2r }
171-	[ LIT2 &sb $1 "b ] EQU ?{ #00 JMP2r }
172-	;&sc .File/read DEO2
173-	.File/success-lb DEI ?{ #00 JMP2r }
174-	[ LIT2 &sc $1 "c ] EQU ?{ #00 JMP2r }
175-	;&sz .File/read DEO2
176-	.File/success-lb DEI ?{ #01 JMP2r }
177-	#00 JMP2r
178-
179-	&string "abc 00 &sz $1
180-
181-(
182-@|Helpers )
183-
184-@<test> ( name* f -- )
185-	?{
186-		str/<print>
187-		#010f DEO
188-		;dict/fail !str/<print> }
189-	str/<print>
190-	;dict/pass
191-	( >> )
192-
193-@str/<print> ( str* -- )
194-	LDAk DUP ?{ POP POP2 JMP2r }
195-	.Console/write DEO
196-	INC2 !/<print>
197-
198-@str/cmp ( a* b* -- f )
199-	STH2
200-	&>wc
201-		LDAk ?{ &d LDA LDAr STHr EQU JMP2r }
202-		LDAk LDAkr STHr NEQ ?&d
203-		INC2 INC2r !&>wc
204-
205-(
206-@|Assets )
207-
208-@dict/write "File/write: 20 $1
209-	&append "File/append: 20 $1
210-	&read "File/read: 20 $1
211-	&stat "File/stat: 20 $1
212-	&stat-oversize "File/stat(oversize): 20 $1
213-	&stat-of "File/stat(overflow): 20 $1
214-	&delete "File/delete: 20 $1
215-	&write-of "File/write(overflow): 20 $1
216-	&read-of "File/read(overflow): 20 $1
217-	&dir-spacer "File/dir(spacer): 20 $1
218-	&dir-nostream "File/dir(nostream): 20 $1
219-	&dir-partial "File/dir(partial): 20 $1
220-	&success "File/success: 20 $1
221-	&fail "fail 0a $1
222-	&pass "pass 0a $1
223-
224-@file/a1 1234 &b1 5678
225-	( read buf ) &read-buf &a2 $2 &b2 $2
226-	( stat buf ) &stat-buf &stat-hs $2 &stat-ls $2
227-	( null buf ) &null-buf $4
228-	&name "test.txt $1
229-	&unknown-name "abcdefghj $1 &dirbuf $200 &bufa $8 &bufb $8
230-
+0, -1470
   1@@ -1,1470 +0,0 @@
   2-( 54K . Opcode Tester )
   3-
   4-|100
   5-
   6-@on-reset ( -> )
   7-	( | PART 1:
   8-	| LIT2: Puts a short on the stack
   9-	| LIT: Puts a byte on the stack
  10-	| #06 DEO: Write to metadata ports
  11-	| #18 DEO: Write a letter in terminal )
  12-	;meta #06 DEO2
  13-	[ LIT2 "kO ] #18 DEO
  14-	#18 DEO
  15-	#2018 DEO
  16-	( | PART 2:
  17-	| LITr: Put a byte on return stack
  18-	| STH: Move a byte from working stack to return stack
  19-	| STH2r: Move a short from return stack to working stack )
  20-	[ LITr "k ] [ LIT "O ] STH
  21-	STH2r #18 DEO
  22-	#18 DEO
  23-	#2018 DEO
  24-	( | PART 3:
  25-	| LIT2r: Put a short on return stack
  26-	| DUP: Duplicate byte
  27-	| ADDr: Add bytes on return stack )
  28-	[ LIT2r "k 4d ] #01 DUP STH
  29-	ADDr STH
  30-	ADDr STH2r #18 DEO
  31-	#18 DEO
  32-	#2018 DEO
  33-	( | PART 4:
  34-	| JSI: Subroutine to relative short address
  35-	| JMP2r: Jumps to absolute address on return stack )
  36-	tests/<print-ok>
  37-	#2018 DEO
  38-	( | PART 5:
  39-	| POP2: Removes a short from the stack
  40-	| INC2: Increments short on stack
  41-	| DUP2: Duplicate short
  42-	| LDA: load byte from absolute address
  43-	| JCI: Conditional subroutine to relative short address )
  44-	;dict/ok str/<print>
  45-	#2018 DEO
  46-	( | PART 6:
  47-	| JSR2: Jump to subroutine from short pointer
  48-	| LDAk: Non-destructive load byte from absolute address )
  49-	{ "Ok $1 }
  50-	STH2r ;str/<print> JSR2 #2018 DEO
  51-	( | PART 7:
  52-	| Relative distance bytes )
  53-	tests/<rel>
  54-	SWP #18 DEO
  55-	#18 DEO
  56-	( | PART 8:
  57-	| Test every opcode )
  58-	#1234 #00 STZ2
  59-	( sentinel ) #1234 LIT2r 5678
  60-	( run tests ) tests/<run>
  61-	( sentinel ) #1234 EQU2 LIT2r 5678 EQU2r STHr AND ;dict/sentinel tests/<print>
  62-	( | PART 9:
  63-	| Testing that stacks are circular and wrapping )
  64-	POP #12 #34 ADD #46 EQU STH
  65-	POP #1234 ADD #46 EQU STH
  66-	POP2 #1111 #2222 ADD2 #3333 EQU2 STHr AND STHr AND ;dict/stack-wrap tests/<print>
  67-	( restore stack ) #0000 #0000
  68-	( | PART 10:
  69-	| Testing that zero-page is wrapping )
  70-	#5678 #ff STZ2
  71-	( LDZ ) #00 LDZ #ff LDZ ADD #ce EQU
  72-	( LDZ2 ) #ff LDZ2 ADD #ce EQU AND ;dict/zp-wrap tests/<print>
  73-	( | PART 11:
  74-	| Testing that device page is wrapping )
  75-	#1234 #ff DEO2
  76-	( DEI ) #00 DEI #ff DEI ADD #46 EQU
  77-	( DEI2 ) #ff DEI2 ADD #46 EQU AND ;dict/dev-wrap tests/<print>
  78-	#0000 DEO
  79-	#00ff DEO
  80-	( | PART 12: Requires 0x10000 ram
  81-	| Testing RAM wrapping
  82-	| Storing 12 in 0xffff, and 34 in 0x0000 )
  83-	#1234 #ffff STA2
  84-	( LDA ) #0000 LDA #ffff LDA ADD #46 EQU
  85-	( LDA2 ) #ffff LDA2 ADD #46 EQU AND ;dict/ram-wrap tests/<print>
  86-	( | PART 13: Requires 0x10000 ram
  87-	| Testing PC wrapping: split instruction
  88-	| Storing 80[LIT] in 0xffff, and 55[val8] in 0x0000
  89-	| Storing 6c[JMP2r] in 0x0001 )
  90-	#8055 #ffff STA2
  91-	#6c #01 STZ
  92-	#ffff JSR2 #55 EQU ;dict/pc-wrap tests/<print>
  93-	( | PART 14: Requires 0x10000 ram
  94-	| Testing PC wrapping: split value after instruction
  95-	| Storing a0[LIT2] in 0xfffe,
  96-	| and 0x55[hi-byte] in 0xffff, and 0xaa[lo-byte] in 0x0000
  97-	| Storing 6c[JMP2r] in 0x0001 )
  98-	#a055 #fffe STA2
  99-	#aa6c #0000 STA2
 100-	#fffe JSR2 #55aa EQU2 ;dict/pc2-wrap tests/<print>
 101-	( | PART 15: Requires 0x10000 ram
 102-	| Testing that LIT is wrapping )
 103-	#80 #ffff STA ( LIT ) #d6 #0000 STA ( <d6> )
 104-	#a0 #0001 STA ( LIT2 ) ;&lt1-return #0002 STA2 ( <hi>,<lo> )
 105-	#2c #0004 STA ( JMP2 )
 106-	#ffff JMP2 &lt1-return #d6 EQU ;dict/lt1-wrap tests/<print>
 107-	( | PART 16: Requires 0x10000 ram
 108-	| Testing that LIT2 is wrapping )
 109-	#a0 #fffe STA ( LIT2 ) #a1 #ffff STA ( <d6> ) #23 #0000 STA ( <76> )
 110-	#a0 #0001 STA ( LIT2 ) ;&lt2-return #0002 STA2 ( <hi>,<lo> )
 111-	#2c #0004 STA ( JMP2 )
 112-	#fffe JMP2 &lt2-return #a123 EQU2 ;dict/lt2-wrap tests/<print>
 113-	( | PART 17: Requires 0x10000 ram
 114-	| Testing that JMI is wrapping )
 115-	#c8  ;dict/jmi-wrap str/<print>
 116-	#40 #fffe STA ( JMI ) #00 #ffff STA ( <00> ) #01 #0000 STA ( <01> )
 117-	#01 #0001 STA ( INC )
 118-	#a0 #0002 STA ( LIT2 ) ;&jmi-return #0003 STA2 ( <hi>,<lo> )
 119-	#2c #0005 STA ( JMP2 )
 120-	#fffe JMP2 &jmi-return #c8 EQU tests/<outcome>
 121-	( | PART 18: Requires 0x10000 ram
 122-	| Testing that JSI is wrapping )
 123-	#ea  ;dict/jsi-wrap str/<print>
 124-	#60 #fffe STA ( JSI ) #00 #ffff STA ( <00> ) #01 #0000 STA ( <01> )
 125-	#01 #0001 STA ( INC )
 126-	#a0 #0002 STA ( LIT2 ) ;&jsi-return #0003 STA2 ( <hi>,<lo> )
 127-	#2c #0005 STA ( JMP2 )
 128-	#fffe JMP2 &jsi-return POP2r #ea EQU tests/<outcome>
 129-	( | PART 19: 
 130-	| Testing that JSI is wrapping )
 131-	#8b #01  ;dict/jci-wrap str/<print>
 132-	#20 #fffe STA ( JCI ) #00 #ffff STA ( <00> ) #01 #0000 STA ( <01> )
 133-	#01 #0001 STA ( INC )
 134-	#a0 #0002 STA ( LIT2 ) ;&jci-return #0003 STA2 ( <hi>,<lo> )
 135-	#2c #0005 STA ( JMP2 )
 136-	#fffe JMP2 &jci-return POP2r #8b EQU tests/<outcome>
 137-	( | You have a working uxn! )
 138-	#800f DEO
 139-	BRK
 140-
 141-
 142-@str/<print> ( str* -- )
 143-	LDAk DUP ?{ POP POP2 JMP2r }
 144-	#18 DEO
 145-	INC2 !/<print>
 146-
 147-@dict/ok "Ok 00
 148-	&fail "fail 0a 00
 149-	&pass "pass 0a 00
 150-	&stack-wrap "Stk-wrap: 20 $1
 151-	&ram-wrap "Ram-wrap: 20 $1
 152-	&pc-wrap "Pc1-wrap: 20 $1
 153-	&pc2-wrap "Pc2-wrap: 20 $1
 154-	&zp-wrap "Zer-wrap: 20 $1
 155-	&dev-wrap "Dev-wrap: 20 $1
 156-	&opc-test "Opc-test: 20 $1
 157-	&sentinel "Sentinel: 20 $1
 158-	&lt1-wrap "Lt1-wrap: 20 $1
 159-	&lt2-wrap "Lt2-wrap: 20 $1
 160-	&jci-wrap "Jci-wrap: 20 $1
 161-	&jmi-wrap "Jmi-wrap: 20 $1
 162-	&jsi-wrap "Jsi-wrap: 20 $1
 163-
 164-(
 165-@|Relative Distance Bytes )
 166-
 167-@meta 00
 168-	( name ) "Opctest 0a
 169-	( details ) "A 20 "Testing 20 "Program 0a
 170-	( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
 171-	( date ) "9 20 "Jun 20 "2026 $2
 172-
 173-(
 174-@|Tests )
 175-
 176-@tests/<run> ( -- )
 177-	[ LITr 00 ] ;&lut-end ;&lut
 178-	&>l
 179-		STHkr #0f AND ?{ #0a18 DEO }
 180-		STHkr u8/<print>
 181-		#2018 DEO
 182-		LDA2k JSR2 #01 EQU ?{ #010f DEO
 183-			BRK }
 184-		INC2 INC2 INCr GTH2k ?&>l
 185-	POP2 POP2 POPr #0a18 DEO
 186-	#01 ;dict/opc-test !tests/<print>
 187-
 188-@tests/<print> ( f name* -- )
 189-	str/<print> &<outcome>
 190-	?{ #010f DEO
 191-		;dict/fail !str/<print> }
 192-	;dict/pass !str/<print>
 193-
 194-@tests/back "O $7c &<rel> ,&back LDR ,&forw LDR JMP2r
 195-	$7e
 196-	&forw "k
 197-
 198-@tests/<print-ok> ( -- )
 199-	[ LIT2 "kO ] #18 DEO
 200-	#18 DEO
 201-	JMP2r
 202-
 203-@u8/<print> ( byte -- )
 204-	DUP #04 SFT /<print-nibble>
 205-	( >> )
 206-	&<print-nibble> ( byte -- )
 207-	#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
 208-	JMP2r
 209-
 210-(
 211-@|imm )
 212-
 213-@op-brk ( -- pass )
 214-	( skip ) #01 JMP2r
 215-
 216-@op-jci ( -- pass )
 217-	( - ) #12 #01 ?{ INC }
 218-	#12 EQU
 219-	( - ) #34 #00 ?{ INC }
 220-	#35 EQU AND
 221-	( - ) #34 #ff ?{ INC }
 222-	#34 EQU AND JMP2r
 223-
 224-@op-jmi ( -- pass )
 225-	( - ) #12 !{
 226-	INC }
 227-	#12 EQU JMP2r
 228-
 229-@op-jsi ( -- pass )
 230-	#12 /t #24 EQU JMP2r
 231-	&t DUP ADD JMP2r
 232-
 233-@op-lit ( -- pass )
 234-	LIT 12 #12 EQU JMP2r
 235-
 236-@op-lit2 ( -- pass )
 237-	LIT2 1234 #12 #34 EQU2 JMP2r
 238-
 239-@op-litr ( -- pass )
 240-	LITr 12 STHr #12 EQU JMP2r
 241-
 242-@op-lit2r ( -- pass )
 243-	LIT2r 1234 STH2r #1234 EQU2 JMP2r
 244-
 245-(
 246-@|m )
 247-
 248-@op-inc ( -- pass )
 249-	( - ) #01 INC [ #02 ] EQU
 250-	( - ) #ff INC #00 EQU AND
 251-	( - ) #fe INC #ff EQU AND
 252-	( - ) #00 INC #01 EQU AND JMP2r
 253-
 254-@op-pop ( -- pass )
 255-	( - ) #0a #0b POP [ #0a ] EQU
 256-	( - ) #0a #0b #0c POP POP [ #0a ] EQU AND
 257-	( - ) #0a #0b #0c ADD POP [ #0a ] EQU AND
 258-	( - ) #0a #0b #0c POP ADD [ #15 ] EQU AND JMP2r
 259-
 260-@op-nip ( -- pass )
 261-	( - ) #12 #34 #56 NIP ADD [ #68 ] EQU JMP2r
 262-
 263-@op-swp ( -- pass )
 264-	( - ) #02 #10 SWP DIV [ #08 ] EQU JMP2r
 265-
 266-@op-rot ( -- pass )
 267-	( - ) #02 #04 #10 ROT DIV ADD [ #0c ] EQU JMP2r
 268-
 269-@op-dup ( -- pass )
 270-	( - ) #0a #0b DUP ADD ADD [ #20 ] EQU JMP2r
 271-
 272-@op-ovr ( -- pass )
 273-	( - ) #02 #10 OVR DIV ADD [ #0a ] EQU JMP2r
 274-
 275-@op-equ ( -- pass )
 276-	( - ) #f8 #f8 EQU #01 EQU
 277-	( - ) #01 #01 EQU #01 EQU AND
 278-	( - ) #f8 #01 EQU #00 EQU AND
 279-	( - ) #00 #ff EQU #00 EQU AND JMP2r
 280-
 281-@op-neq ( -- pass )
 282-	( - ) #f8 #f8 NEQ #00 EQU
 283-	( - ) #01 #01 NEQ #00 EQU AND
 284-	( - ) #f8 #01 NEQ #01 EQU AND
 285-	( - ) #01 #f8 NEQ #01 EQU AND JMP2r
 286-
 287-@op-gth ( -- pass )
 288-	( - ) #f8 #f8 GTH #00 EQU
 289-	( - ) #01 #01 GTH #00 EQU AND
 290-	( - ) #f8 #01 GTH #01 EQU AND
 291-	( - ) #01 #f8 GTH #00 EQU AND JMP2r
 292-
 293-@op-lth ( -- pass )
 294-	( - ) #f8 #f8 LTH #00 EQU
 295-	( - ) #01 #01 LTH #00 EQU AND
 296-	( - ) #f8 #01 LTH #00 EQU AND
 297-	( - ) #01 #ff LTH #01 EQU AND JMP2r
 298-
 299-@op-jmp ( -- pass )
 300-	( - ) #12 #34 ,&x [ JMP SWP &x ] POP [ #12 ] EQU
 301-	( - ) #12 #34 ,&t [ JMP &back ] POP [ #34 ] EQU AND JMP2r
 302-	&t SWP ,&back JMP
 303-
 304-@op-jcn ( -- pass )
 305-	( - ) #23 #03 ,&x [ JCN INC &x ] [ #23 ] EQU
 306-	( - ) #23 #00 ,&y [ JCN INC &y ] [ #24 ] EQU AND
 307-	( - ) #12 #34 #ff ,&t [ JCN &back ] POP [ #34 ] EQU AND
 308-	( - ) #12 #34 #00 ,&t [ JCN ] POP [ #12 ] EQU AND JMP2r
 309-	&t SWP ,&back JMP
 310-
 311-@op-jsr ( -- pass )
 312-	( - ) #12 #34 ,&routine JSR [ #46 ] EQU JMP2r
 313-	&routine ADD JMP2r
 314-
 315-@op-sth ( -- pass )
 316-	( - ) #0a [ STH ] #0b [ STH ] ADDr STHr [ #15 ] EQU JMP2r
 317-
 318-@op-ldz ( -- pass )
 319-	( - ) #00 LDZ #12 EQU JMP2r
 320-
 321-@op-stz ( -- pass )
 322-	#ff03 STZ
 323-	#5602 STZ
 324-	( ) #5602 LDZ EQU #ff03 LDZ EQU AND JMP2r
 325-
 326-@op-ldr ( -- pass )
 327-	( advance ) [ !{ &a 12 ( -128 ) $6e &u 34 } ]
 328-	( - ) ,&t LDR #12 EQU
 329-	( - ) ,&u LDR #34 EQU AND
 330-	( -128 ) ,&a LDR #12 EQU AND
 331-	( +127 ) ,&b LDR #56 EQU AND [ !{ &t 12 ( +127 ) $77 &b 56 } ] JMP2r
 332-
 333-@op-str ( -- pass )
 334-	( advance ) [ !{ &a $1 ( -128 ) $63 &u $1 ] }
 335-	( - ) #34 ,&t [ STR ] ,&t LDR #34 EQU
 336-	( - ) #12 ,&u [ STR ] ,&u LDR #12 EQU AND
 337-	( -128 ) [ LIT2 56 _&a ] STR
 338-	( +127 ) [ LIT2 56 _&b ] STR
 339-	[ !{ &t $1 ( +127 ) $7b &b $1 } ]
 340-	( - check ) ;&a LDA #56 EQU AND ;&b LDA #56 EQU AND JMP2r
 341-
 342-@op-lda ( -- pass )
 343-	( - ) ;&value LDA #ef EQU JMP2r
 344-	&value ef
 345-
 346-@op-sta ( -- pass )
 347-	#34 ;&b STA
 348-	#12 ;&a STA
 349-	;&a LDA #12 EQU ;&b LDA #34 EQU AND JMP2r
 350-	&a 00 &b 00
 351-
 352-@op-dei ( -- pass )
 353-	( skip ) #01 JMP2r
 354-
 355-@op-deo ( -- pass )
 356-	( skip ) #01 JMP2r
 357-
 358-@op-add ( -- pass )
 359-	( - ) #ff #00 ADD #ff EQU
 360-	( - ) #01 #ff ADD #00 EQU AND
 361-	( - ) #ff #ff ADD [ #fe ] EQU AND JMP2r
 362-
 363-@op-sub ( -- pass )
 364-	( - ) #ff #00 SUB #ff EQU
 365-	( - ) #01 #ff SUB [ #02 ] EQU AND
 366-	( - ) #ff #ff SUB #00 EQU AND
 367-	( - ) #fe #ff SUB #ff EQU AND JMP2r
 368-
 369-@op-mul ( -- pass )
 370-	( - ) #00 #01 MUL #00 EQU
 371-	( - ) #3f #e7 MUL [ #d9 ] EQU AND
 372-	( - ) #37 #3f MUL [ #89 ] EQU AND
 373-	( - ) #10 #02 MUL [ #20 ] EQU AND JMP2r
 374-
 375-@op-div ( -- pass )
 376-	( - ) #10 #06 DIV [ #02 ] EQU
 377-	( - ) #20 #20 DIV #01 EQU AND
 378-	( - ) #34 #01 DIV [ #34 ] EQU AND
 379-	( - ) #02 #ef DIV #00 EQU AND
 380-	( - ) #02 #00 DIV #00 EQU AND
 381-	( - ) #00 #00 DIV #00 EQU AND
 382-	( - ) #fe #02 DIV #7f EQU AND
 383-	( - ) #03 #fd DIV #00 EQU AND JMP2r
 384-
 385-@op-and ( -- pass )
 386-	( - ) #fc #3f AND [ #3c ] EQU
 387-	( - ) #f0 #0f AND #00 EQU AND
 388-	( - ) #ff #3c AND [ #3c ] EQU AND
 389-	( - ) #02 #03 AND [ #02 ] EQU AND JMP2r
 390-
 391-@op-ora ( -- pass )
 392-	( - ) #0f #f0 ORA #ff EQU
 393-	( - ) #ab #cd ORA [ #ef ] EQU AND
 394-	( - ) #12 #34 ORA [ #36 ] EQU AND
 395-	( - ) #88 #10 ORA [ #98 ] EQU AND JMP2r
 396-
 397-@op-eor ( -- pass )
 398-	( - ) #00 #00 EOR #00 EQU
 399-	( - ) #ff #00 EOR #ff EQU AND
 400-	( - ) #aa #55 EOR #ff EQU AND
 401-	( - ) #ff #ff EOR #00 EQU AND JMP2r
 402-
 403-@op-sft ( -- pass )
 404-	( - ) #ff #08 SFT #00 EQU
 405-	( - ) #ff #e0 SFT #00 EQU AND
 406-	( - ) #ff #11 SFT [ #fe ] EQU AND
 407-	( - ) #ff #12 SFT [ #7e ] EQU AND
 408-	( - ) #ff #00 SFT [ #ff ] EQU AND
 409-	( - ) #ff #77 SFT [ #80 ] EQU AND
 410-	( - ) #ff #88 SFT [ #00 ] EQU AND
 411-	( - ) #ff #ff SFT [ #00 ] EQU AND JMP2r
 412-
 413-(
 414-@|m2 )
 415-
 416-@op-inc2 ( -- pass )
 417-	( - ) #00ff INC2 [ #0100 ] EQU2
 418-	( - ) #ffff INC2 [ #0000 ] EQU2 AND
 419-	( - ) #fffe INC2 [ #ffff ] EQU2 AND
 420-	( - ) #0000 INC2 [ #0001 ] EQU2 AND JMP2r
 421-
 422-@op-pop2 ( -- pass )
 423-	( - ) #0a0b #0c0d POP2 [ #0a0b ] EQU2
 424-	( - ) #0a0b #0c0d #0e0f POP2 POP2 #0a0b EQU2 AND
 425-	( - ) #0a0b #0c0d #0e0f ADD2 POP2 #0a0b EQU2 AND
 426-	( - ) #0a0b #0c0d #0e0f POP2 ADD2 #1618 EQU2 AND JMP2r
 427-
 428-@op-nip2 ( -- pass )
 429-	( - ) #1234 #5678 #9abc NIP2 ADD2 #acf0 EQU2 JMP2r
 430-
 431-@op-swp2 ( -- pass )
 432-	( - ) #0a0b #0c0d SWP2 NIP2 #0a0b EQU2 JMP2r
 433-
 434-@op-rot2 ( -- pass )
 435-	( - ) #0a0b #0c0d #0c0f ROT2 ADD2 NIP2 #161a EQU2 JMP2r
 436-
 437-@op-dup2 ( -- pass )
 438-	( - ) #0a0b DUP2 ADD2 #1416 EQU2 JMP2r
 439-
 440-@op-ovr2 ( -- pass )
 441-	( - ) #0a0b #0c0d OVR2 NIP2 ADD2 #1416 EQU2 JMP2r
 442-
 443-@op-equ2 ( -- pass )
 444-	( - ) #f801 #f801 EQU2 #01 EQU
 445-	( - ) #01f8 #01f8 EQU2 #01 EQU AND
 446-	( - ) #f801 #01f9 EQU2 #00 EQU AND
 447-	( - ) #01f8 #f802 EQU2 #00 EQU AND JMP2r
 448-
 449-@op-neq2 ( -- pass )
 450-	( - ) #f801 #f801 NEQ2 #00 EQU
 451-	( - ) #01f8 #01f8 NEQ2 #00 EQU AND
 452-	( - ) #f802 #01f9 NEQ2 #01 EQU AND
 453-	( - ) #01f9 #f802 NEQ2 #01 EQU AND JMP2r
 454-
 455-@op-gth2 ( -- pass )
 456-	( - ) #f801 #f802 GTH2 #00 EQU
 457-	( - ) #01f8 #01f9 GTH2 #00 EQU AND
 458-	( - ) #f801 #01f9 GTH2 #01 EQU AND
 459-	( - ) #01f8 #f802 GTH2 #00 EQU AND JMP2r
 460-
 461-@op-lth2 ( -- pass )
 462-	( - ) #f801 #f802 LTH2 #01 EQU
 463-	( - ) #01f8 #01f9 LTH2 #01 EQU AND
 464-	( - ) #f801 #01f9 LTH2 #00 EQU AND
 465-	( - ) #01f8 #f802 LTH2 #01 EQU AND JMP2r
 466-
 467-@op-jmp2 ( -- pass )
 468-	( - ) #56 #78 ;&t [ JMP2 SWP &t ] POP #56 EQU JMP2r
 469-
 470-@op-jcn2 ( -- pass )
 471-	( - ) #23 #10 ;&abs-x [ JCN2 INC &abs-x ] #23 EQU
 472-	( - ) #23 #00 ;&abs-y [ JCN2 INC &abs-y ] #24 EQU AND JMP2r
 473-
 474-@op-jsr2 ( -- pass )
 475-	( - ) #12 ;&t JSR2 #24 EQU JMP2r
 476-	&t DUP ADD JMP2r
 477-
 478-@op-sth2 ( -- pass )
 479-	( - ) #1234 [ STH2 ] ADDr STHr #46 EQU JMP2r
 480-
 481-@op-ldz2 ( -- pass )
 482-	( - ) #00 LDZ2 #1234 EQU2 JMP2r
 483-
 484-@op-stz2 ( -- pass )
 485-	( - ) #5678 #04 [ STZ2 ] #04 LDZ2 #5678 EQU2 JMP2r
 486-
 487-@op-ldr2 ( -- pass )
 488-	( advance ) [ !{ &a 1234 ( -128 ) $6a &u 3456 } ]
 489-	( - ) ,&t LDR2 #1234 EQU2
 490-	( - ) ,&u LDR2 #3456 EQU2 AND
 491-	( -128 ) ,&a LDR2 #1234 EQU2 AND
 492-	( +127 ) ,&b LDR2 #5678 EQU2 AND [ !{ &t 1234 ( +127 ) $75 &b 5678 } ] JMP2r
 493-
 494-@op-str2 ( -- pass )
 495-	( advance ) [ !{ &a $2 ( -128 ) $5b &u $2 ] }
 496-	( - ) #1234 ,&t [ STR2 ] ,&t LDR2 #1234 EQU2
 497-	( - ) #1234 ,&u [ STR2 ] ,&u LDR2 #1234 EQU2 AND
 498-	( -128 ) #1234 ,&a STR2
 499-	( +127 ) #1234 ,&b STR2
 500-	[ !{ &t $2 ( +127 ) $7a &b $2 } ]
 501-	( - check ) ;&a LDA2 #1234 EQU2 AND ;&b LDA2 #1234 EQU2 AND JMP2r
 502-
 503-@op-lda2 ( -- pass )
 504-	( - ) ;&t LDA2 #1234 EQU2 JMP2r
 505-	&t 1234
 506-
 507-@op-sta2 ( -- pass )
 508-	( - ) #1234 ;&t [ STA2 ] ;&t LDA2 #1234 EQU2 JMP2r
 509-	&t $2
 510-
 511-@op-dei2 ( -- pass )
 512-	( skip ) #01 JMP2r
 513-
 514-@op-deo2 ( -- pass )
 515-	( skip ) #01 JMP2r
 516-
 517-@op-add2 ( -- pass )
 518-	( - ) #ffff #0000 ADD2 [ #ffff ] EQU2
 519-	( - ) #0001 #ffff ADD2 [ #0000 ] EQU2 AND
 520-	( - ) #ffff #ffff ADD2 [ #fffe ] EQU2 AND
 521-	( - ) #fffe #ffff ADD2 [ #fffd ] EQU2 AND JMP2r
 522-
 523-@op-sub2 ( -- pass )
 524-	( - ) #ffff #0000 SUB2 [ #ffff ] EQU2
 525-	( - ) #0001 #ffff SUB2 [ #0002 ] EQU2 AND
 526-	( - ) #ffff #ffff SUB2 [ #0000 ] EQU2 AND
 527-	( - ) #fffe #ffff SUB2 [ #ffff ] EQU2 AND JMP2r
 528-
 529-@op-mul2 ( -- pass )
 530-	( - ) #1000 #0003 MUL2 [ #3000 ] EQU2
 531-	( - ) #abcd #1234 MUL2 [ #4fa4 ] EQU2 AND
 532-	( - ) #8000 #0200 MUL2 [ #0000 ] EQU2 AND
 533-	( - ) #2222 #0003 MUL2 [ #6666 ] EQU2 AND JMP2r
 534-
 535-@op-div2 ( -- pass )
 536-	( - ) #03e8 #0006 DIV2 [ #00a6 ] EQU2
 537-	( - ) #abcd #1234 DIV2 [ #0009 ] EQU2 AND
 538-	( - ) #8000 #0200 DIV2 [ #0040 ] EQU2 AND
 539-	( - ) #2222 #0003 DIV2 [ #0b60 ] EQU2 AND
 540-	( - ) #0202 #0000 DIV2 [ #0000 ] EQU2 AND
 541-	( - ) #0000 #0000 DIV2 #0000 EQU2 AND
 542-	( - ) #fffe #0002 DIV2 #7fff EQU2 AND
 543-	( - ) #0003 #fffd DIV2 #0000 EQU2 AND JMP2r
 544-
 545-@op-and2 ( -- pass )
 546-	( - ) #f0f0 #00f0 AND2 [ #00f0 ] EQU2
 547-	( - ) #aaaa #5555 AND2 [ #0000 ] EQU2 AND
 548-	( - ) #ffff #1234 AND2 [ #1234 ] EQU2 AND
 549-	( - ) #abcd #0a0c AND2 [ #0a0c ] EQU2 AND JMP2r
 550-
 551-@op-ora2 ( -- pass )
 552-	( - ) #0f0f #f0f0 ORA2 [ #ffff ] EQU2
 553-	( - ) #abab #cdcd ORA2 [ #efef ] EQU2 AND
 554-	( - ) #1122 #1234 ORA2 [ #1336 ] EQU2 AND
 555-	( - ) #8888 #1000 ORA2 [ #9888 ] EQU2 AND JMP2r
 556-
 557-@op-eor2 ( -- pass )
 558-	( - ) #ffff #ff00 EOR2 [ #00ff ] EQU2
 559-	( - ) #aaaa #5555 EOR2 [ #ffff ] EQU2 AND
 560-	( - ) #1122 #1234 EOR2 [ #0316 ] EQU2 AND
 561-	( - ) #8888 #1000 EOR2 [ #9888 ] EQU2 AND JMP2r
 562-
 563-@op-sft2 ( -- pass )
 564-	( - ) #ffff #01 SFT2 [ #7fff ] EQU2
 565-	( - ) #ffff #70 SFT2 [ #ff80 ] EQU2 AND
 566-	( - ) #ffff #7e SFT2 [ #0180 ] EQU2 AND
 567-	( - ) #ffff #00 SFT2 [ #ffff ] EQU2 AND
 568-	( - ) #ffff #ff SFT2 [ #8000 ] EQU2 AND
 569-	( - ) #ffff #e3 SFT2 [ #c000 ] EQU2 AND JMP2r
 570-
 571-(
 572-@|mr )
 573-
 574-@op-incr ( -- pass )
 575-	( - ) LITr 01 INCr STHr #02 EQU JMP2r
 576-
 577-@op-popr ( -- pass )
 578-	( - ) LITr 0a LITr 0b POPr STHr #0a EQU JMP2r
 579-
 580-@op-nipr ( -- pass )
 581-	( - ) LITr 12 LITr 34 LITr 56 NIPr ADDr STHr #68 EQU JMP2r
 582-
 583-@op-swpr ( -- pass )
 584-	( - ) LITr 02 LITr 03 SWPr POPr STHr #03 EQU JMP2r
 585-
 586-@op-rotr ( -- pass )
 587-	( - ) LITr 0a LITr 0b LITr 0c ROTr POPr POPr STHr #0b EQU JMP2r
 588-
 589-@op-dupr ( -- pass )
 590-	( - ) LITr 0a DUPr STHr STHr #0a0a EQU2 JMP2r
 591-
 592-@op-ovrr ( -- pass )
 593-	( - ) LITr 0a LITr 0b OVRr STHr POPr POPr #0a EQU JMP2r
 594-
 595-@op-equr ( -- pass )
 596-	( - ) LITr f8 LITr f8 EQUr STHr #01 EQU JMP2r
 597-
 598-@op-neqr ( -- pass )
 599-	( - ) LITr f8 LITr f8 NEQr STHr #00 EQU JMP2r
 600-
 601-@op-gthr ( -- pass )
 602-	( - ) LITr f8 LITr f8 GTHr STHr #00 EQU JMP2r
 603-
 604-@op-lthr ( -- pass )
 605-	( - ) LITr f8 LITr f8 LTHr STHr #00 EQU JMP2r
 606-
 607-@op-jmpr ( -- pass )
 608-	( - ) LITr _&t [ JMPr ] #01 EQU JMP2r
 609-	&t #01 JMP2r
 610-
 611-@op-jcnr ( -- pass )
 612-	( - ) #23 LIT2r 02 _&x [ JCNr INC &x ] [ #23 ] EQU
 613-	( - ) #23 LIT2r 00 _&y [ JCNr INC &y ] [ #24 ] EQU AND
 614-	( - ) #1234 LIT2r f0 _&t [ JCNr &back ] POP [ #34 ] EQU AND
 615-	( - ) #1234 LIT2r 00 _&t [ JCNr ] POP [ #12 ] EQU AND JMP2r
 616-	&t SWP ,&back JMP
 617-
 618-@op-jsrr ( -- pass )
 619-	LITr 0a LITr _&t JSRr STHr #14 EQU JMP2r
 620-	&t DUPr ADDr JMP2
 621-
 622-@op-sthr ( -- pass )
 623-	( - ) LITr 55 [ STHr ] #55 EQU JMP2r
 624-
 625-@op-ldzr ( -- pass )
 626-	( - ) LITr 00 LDZr STHr #12 EQU JMP2r
 627-
 628-@op-stzr ( -- pass )
 629-	( - ) LIT2r 5606 [ STZr ] #06 LDZ #56 EQU JMP2r
 630-
 631-@op-ldrr ( -- pass )
 632-	( advance ) [ !{ &u 34 ] }
 633-	( - ) LITr _&t LDRr STHr #12 EQU
 634-	( - ) LITr _&u LDRr STHr #34 EQU AND JMP2r
 635-	&t 12
 636-
 637-@op-strr ( -- pass )
 638-	( advance ) [ !{ &u $1 ] }
 639-	( - ) LITr 34 LITr _&t [ STRr ] ,&t LDR #34 EQU
 640-	( - ) LITr 12 LITr _&u [ STRr ] ,&u LDR #12 EQU AND JMP2r
 641-	&t $1
 642-
 643-@op-ldar ( -- pass )
 644-	( - ) LIT2r =&value LDAr STHr #ef EQU JMP2r
 645-	&value ef
 646-
 647-@op-star ( -- pass )
 648-	( - ) LITr 12 LIT2r =&value [ STAr ] ;&value LDA #12 EQU JMP2r
 649-	&value 00
 650-
 651-@op-deir ( -- pass )
 652-	( skip ) #01 JMP2r
 653-
 654-@op-deor ( -- pass )
 655-	( skip ) #01 JMP2r
 656-
 657-@op-addr ( -- pass )
 658-	( - ) LITr ff LITr 00 ADDr STHr #ff EQU JMP2r
 659-
 660-@op-subr ( -- pass )
 661-	( - ) LITr ff LITr 00 SUBr STHr #ff EQU JMP2r
 662-
 663-@op-mulr ( -- pass )
 664-	( - ) LITr 00 LITr 01 MULr STHr #00 EQU JMP2r
 665-
 666-@op-divr ( -- pass )
 667-	( - ) LITr 10 LITr 06 DIVr STHr [ #02 ] EQU JMP2r
 668-
 669-@op-andr ( -- pass )
 670-	( - ) LITr fc LITr 3f ANDr STHr [ #3c ] EQU JMP2r
 671-
 672-@op-orar ( -- pass )
 673-	( - ) LITr 0f LITr f0 ORAr STHr #ff EQU JMP2r
 674-
 675-@op-eorr ( -- pass )
 676-	( - ) LITr 00 LITr 00 EORr STHr #00 EQU JMP2r
 677-
 678-@op-sftr ( -- pass )
 679-	( - ) LITr ff LITr 08 SFTr STHr #00 EQU JMP2r
 680-
 681-(
 682-@|m2r )
 683-
 684-@op-inc2r ( -- pass )
 685-	( - ) LIT2r 00ff INC2r
 686-	( . ) STH2r [ #0100 ] EQU2 JMP2r
 687-
 688-@op-pop2r ( -- pass )
 689-	( - ) LIT2r 0a0b LIT2r 0c0d POP2r
 690-	( . ) STH2r [ #0a0b ] EQU2 JMP2r
 691-
 692-@op-nip2r ( -- pass )
 693-	( - ) LIT2r 1234 LIT2r 5678 NIP2r
 694-	( . ) STH2r #5678 EQU2 JMP2r
 695-
 696-@op-swp2r ( -- pass )
 697-	( - ) LIT2r 0a0b LIT2r 0c0d SWP2r
 698-	( . ) STH2r POP2r #0a0b EQU2 JMP2r
 699-
 700-@op-rot2r ( -- pass )
 701-	( - ) LIT2r 0a0b LIT2r 0c0d LIT2r 0c0f ROT2r POP2r POP2r
 702-	( . ) STH2r #0c0d EQU2 JMP2r
 703-
 704-@op-dup2r ( -- pass )
 705-	( - ) LIT2r 0a0b DUP2r
 706-	( . ) STH2r STH2r ADD2 #1416 EQU2 JMP2r
 707-
 708-@op-ovr2r ( -- pass )
 709-	( - ) LIT2r 0a0b LIT2r 0c0d OVR2r
 710-	( . ) STH2r STH2r
 711-	( . ) STH2r ADD2 ADD2 #2023 EQU2 JMP2r
 712-
 713-@op-equ2r ( -- pass )
 714-	( - ) LIT2r 0a0b LIT2r 0a0b EQU2r STHr #01 EQU
 715-	( - ) LIT2r 0a0b LIT2r 0c0d EQU2r STHr #00 EQU AND JMP2r
 716-
 717-@op-neq2r ( -- pass )
 718-	( - ) LIT2r 0a0b LIT2r 0a0b NEQ2r STHr #00 EQU
 719-	( - ) LIT2r 0a0b LIT2r 0c0d NEQ2r STHr #01 EQU AND JMP2r
 720-
 721-@op-gth2r ( -- pass )
 722-	( - ) LIT2r f801 LIT2r f801 GTH2r STHr #00 EQU
 723-	( - ) LIT2r f801 LIT2r 01f8 GTH2r STHr #01 EQU AND JMP2r
 724-
 725-@op-lth2r ( -- pass )
 726-	( - ) LIT2r f801 LIT2r f801 LTH2r STHr #00 EQU
 727-	( - ) LIT2r 01f8 LIT2r f801 LTH2r STHr #01 EQU AND JMP2r
 728-
 729-@op-jmp2r ( -- pass )
 730-	( - ) #5678 LIT2r =&t [ JMP2r ] SWP &t POP #56 EQU JMP2r
 731-
 732-@op-jcn2r ( -- pass )
 733-	( - ) #23 LITr f0 LIT2r =&x [ JCN2r INC &x ] #23 EQU
 734-	( - ) #23 LITr 00 LIT2r =&y [ JCN2r INC &y ] #24 EQU AND JMP2r
 735-
 736-@op-jsr2r ( -- pass )
 737-	( - ) LITr 12 LIT2r =&t JSR2r STHr #24 EQU JMP2r
 738-	&t DUPr ADDr JMP2
 739-
 740-@op-sth2r ( -- pass )
 741-	( - ) LIT2r 0a0b
 742-	( . ) STH2r #0a0b EQU2 JMP2r
 743-
 744-@op-ldz2r ( -- pass )
 745-	( - ) LITr 00 [ LDZ2r ]
 746-	( . ) STH2r #1234 EQU2 JMP2r
 747-
 748-@op-stz2r ( -- pass )
 749-	( - ) LIT2r 5678 LITr 08 [ STZ2r ] #08 LDZ2 #5678 EQU2 JMP2r
 750-
 751-@op-ldr2r ( -- pass )
 752-	( advance ) [ !{ &u 1234 ] }
 753-	( - ) LITr _&t [ LDR2r ] STH2r #1234 EQU2
 754-	( - ) LITr _&u [ LDR2r ] STH2r #1234 EQU2 AND JMP2r
 755-	&t 1234
 756-
 757-@op-str2r ( -- pass )
 758-	( advance ) [ !{ &u $2 ] }
 759-	( - ) LIT2r 1234 LITr _&t [ STR2r ] ,&t LDR2 #1234 EQU2
 760-	( - ) LIT2r 1234 LITr _&u [ STR2r ] ,&u LDR2 #1234 EQU2 AND JMP2r
 761-	&t $2
 762-
 763-@op-lda2r ( -- pass )
 764-	( - ) LIT2r =&t [ LDA2r ]
 765-	( . ) STH2r #1234 EQU2 JMP2r
 766-	&t 1234
 767-
 768-@op-sta2r ( -- pass )
 769-	( - ) LIT2r 1234 LIT2r =&t [ STA2r ] ;&t LDA2 #1234 EQU2 JMP2r
 770-	&t $2
 771-
 772-@op-dei2r ( -- pass )
 773-	( skip ) #01 JMP2r
 774-
 775-@op-deo2r ( -- pass )
 776-	( skip ) #01 JMP2r
 777-
 778-@op-add2r ( -- pass )
 779-	( - ) LIT2r ffff LIT2r 0000 ADD2r STH2r [ #ffff ] EQU2
 780-	( - ) LIT2r 0001 LIT2r ffff ADD2r STH2r [ #0000 ] EQU2 AND
 781-	( - ) LIT2r ffff LIT2r ffff ADD2r STH2r [ #fffe ] EQU2 AND
 782-	( - ) LIT2r fffe LIT2r ffff ADD2r STH2r [ #fffd ] EQU2 AND JMP2r
 783-
 784-@op-sub2r ( -- pass )
 785-	( - ) LIT2r ffff LIT2r 0000 SUB2r STH2r [ #ffff ] EQU2
 786-	( - ) LIT2r 0001 LIT2r ffff SUB2r STH2r [ #0002 ] EQU2 AND
 787-	( - ) LIT2r ffff LIT2r ffff SUB2r STH2r [ #0000 ] EQU2 AND
 788-	( - ) LIT2r fffe LIT2r ffff SUB2r STH2r [ #ffff ] EQU2 AND JMP2r
 789-
 790-@op-mul2r ( -- pass )
 791-	( - ) LIT2r 1000 LIT2r 0003 MUL2r STH2r [ #3000 ] EQU2
 792-	( - ) LIT2r abcd LIT2r 1234 MUL2r STH2r [ #4fa4 ] EQU2 AND
 793-	( - ) LIT2r 8000 LIT2r 0200 MUL2r STH2r [ #0000 ] EQU2 AND
 794-	( - ) LIT2r 2222 LIT2r 0003 MUL2r STH2r [ #6666 ] EQU2 AND JMP2r
 795-
 796-@op-div2r ( -- pass )
 797-	( - ) LIT2r 03e8 LIT2r 0006 DIV2r STH2r [ #00a6 ] EQU2
 798-	( - ) LIT2r abcd LIT2r 1234 DIV2r STH2r [ #0009 ] EQU2 AND
 799-	( - ) LIT2r 8000 LIT2r 0200 DIV2r STH2r [ #0040 ] EQU2 AND
 800-	( - ) LIT2r 2222 LIT2r 0003 DIV2r STH2r [ #0b60 ] EQU2 AND
 801-	( - ) LIT2r 0202 LIT2r 0000 DIV2r STH2r [ #0000 ] EQU2 AND JMP2r
 802-
 803-@op-and2r ( -- pass )
 804-	( - ) LIT2r f0f0 LIT2r 00f0 AND2r STH2r [ #00f0 ] EQU2
 805-	( - ) LIT2r aaaa LIT2r 5555 AND2r STH2r [ #0000 ] EQU2 AND
 806-	( - ) LIT2r ffff LIT2r 1234 AND2r STH2r [ #1234 ] EQU2 AND
 807-	( - ) LIT2r abcd LIT2r 0a0c AND2r STH2r [ #0a0c ] EQU2 AND JMP2r
 808-
 809-@op-ora2r ( -- pass )
 810-	( - ) LIT2r 0f0f LIT2r f0f0 ORA2r STH2r [ #ffff ] EQU2
 811-	( - ) LIT2r abab LIT2r cdcd ORA2r STH2r [ #efef ] EQU2 AND
 812-	( - ) LIT2r 1122 LIT2r 1234 ORA2r STH2r [ #1336 ] EQU2 AND
 813-	( - ) LIT2r 8888 LIT2r 1000 ORA2r STH2r [ #9888 ] EQU2 AND JMP2r
 814-
 815-@op-eor2r ( -- pass )
 816-	( - ) LIT2r ffff LIT2r ff00 EOR2r STH2r [ #00ff ] EQU2
 817-	( - ) LIT2r aaaa LIT2r 5555 EOR2r STH2r [ #ffff ] EQU2 AND
 818-	( - ) LIT2r 1122 LIT2r 1234 EOR2r STH2r [ #0316 ] EQU2 AND
 819-	( - ) LIT2r 8888 LIT2r 1000 EOR2r STH2r [ #9888 ] EQU2 AND JMP2r
 820-
 821-@op-sft2r ( -- pass )
 822-	( - ) LIT2r ffff LITr 01 SFT2r STH2r [ #7fff ] EQU2
 823-	( - ) LIT2r ffff LITr 70 SFT2r STH2r [ #ff80 ] EQU2 AND
 824-	( - ) LIT2r ffff LITr 7e SFT2r STH2r [ #0180 ] EQU2 AND
 825-	( - ) LIT2r ffff LITr e3 SFT2r STH2r [ #c000 ] EQU2 AND JMP2r
 826-
 827-(
 828-@|mk )
 829-
 830-@op-inck ( -- pass )
 831-	( - ) #01 INCk #0102 EQU2
 832-	( - ) #ff INCk #ff00 EQU2 AND JMP2r
 833-
 834-@op-popk ( -- pass )
 835-	( - ) #0a #0b POPk #0a0b EQU2 JMP2r
 836-
 837-@op-nipk ( -- pass )
 838-	( - ) #12 #34 NIPk NIP NIP #34 EQU
 839-	( - ) #12 #34 NIPk NIP #1234 EQU2 AND JMP2r
 840-
 841-@op-swpk ( -- pass )
 842-	( - ) #12 #34 SWPk NIP2 #3412 EQU2
 843-	( - ) #12 #34 SWPk POP2 #1234 EQU2 AND JMP2r
 844-
 845-@op-rotk ( -- pass )
 846-	( - ) #02 #04 #10 ROTk POP POP POP ROT DIV ADD #0c EQU
 847-	( - ) #02 #04 #10 ROTk [ STH STH STH ] POP POP POP STHr STHr STHr DIV ADD [ #0c ] EQU AND JMP2r
 848-
 849-@op-dupk ( -- pass )
 850-	( - ) #0a DUPk EQU SWP [ #0a ] EQU AND
 851-	( - ) #ff DUPk EQU SWP #ff EQU AND AND JMP2r
 852-
 853-@op-ovrk ( -- pass )
 854-	( - ) #02 #10 OVRk POP POP POP #0210 EQU2
 855-	( check result ) #02 #10 OVRk NIP NIP DIV ADD [ #0a ] EQU AND JMP2r
 856-
 857-@op-equk ( -- pass )
 858-	( - ) #0a #0a EQUk ROT [ #0a ] EQU ROT [ #0a ] EQU AND SWP #01 EQU AND
 859-	( - ) #0a #0b EQUk ROT [ #0a ] EQU ROT [ #0b ] EQU AND SWP #00 EQU AND AND JMP2r
 860-
 861-@op-neqk ( -- pass )
 862-	( - ) #0a #0b NEQk ROT [ #0a ] EQU ROT [ #0b ] EQU AND SWP #01 EQU AND
 863-	( - ) #0a #0a NEQk ROT [ #0a ] EQU ROT [ #0a ] EQU AND SWP #00 EQU AND AND JMP2r
 864-
 865-@op-gthk ( -- pass )
 866-	( - ) #f8 #01 GTHk ROT [ #f8 ] EQU ROT #01 EQU AND SWP #01 EQU AND
 867-	( - ) #01 #f8 GTHk ROT #01 EQU ROT [ #f8 ] EQU AND SWP #00 EQU AND AND JMP2r
 868-
 869-@op-lthk ( -- pass )
 870-	( - ) #01 #ff LTHk ROT #01 EQU ROT #ff EQU AND SWP #01 EQU AND
 871-	( - ) #f8 #01 LTHk ROT [ #f8 ] EQU ROT #01 EQU AND SWP #00 EQU AND AND JMP2r
 872-
 873-@op-jmpk ( -- pass )
 874-	( - ) #1234 ,&x [ JMPk SWP &x ] POP2 [ #12 ] EQU
 875-	( - ) #1234 ,&t [ JMPk &back ] POP2 [ #34 ] EQU AND JMP2r
 876-	&t POP SWP ,&back JMPk
 877-
 878-@op-jcnk ( -- pass )
 879-	( - ) LITr 0a #00 ,&x JCNk INCr &x POP2 STHr #0b EQU
 880-	( - ) LITr 0a #81 ,&y JCNk INCr &y POP2 STHr #0a EQU AND JMP2r
 881-
 882-@op-jsrk ( -- pass )
 883-	( - ) #0a ,&t JSRk #0b EQU JMP2r
 884-	&t POP INC JMP2r
 885-
 886-@op-sthk ( -- pass )
 887-	( - ) #08 STHk STHr ADD #10 EQU JMP2r
 888-
 889-@op-ldzk ( -- pass )
 890-	( - ) #00 LDZk [ #12 ] EQU SWP #00 EQU AND JMP2r
 891-
 892-@op-stzk ( -- pass )
 893-	( - ) #56 #0a STZk POP2 #0a LDZ [ #56 ] EQU
 894-	( - ) #ab #0b STZk #ab0b EQU2 AND JMP2r
 895-
 896-@op-ldrk ( -- pass )
 897-	( - ) ,&t LDRk [ #12 ] EQU NIP JMP2r
 898-	&t 12
 899-
 900-@op-strk ( -- pass )
 901-	( - ) #34 ,&t STRk POP2 ,&t LDR [ #34 ] EQU
 902-	( - ) #34 ,&t STRk SWP [ #34 ] EQU NIP AND JMP2r
 903-	&t $1
 904-
 905-@op-ldak ( -- pass )
 906-	( - ) ;&t LDAk [ STH ] ;&t EQU2 STHr [ #ef ] EQU AND JMP2r
 907-	&t ef
 908-
 909-@op-stak ( -- pass )
 910-	( - ) #12 ;&t STAk POP2 POP ;&t LDA [ #12 ] EQU
 911-	( - ) #34 ;&t STAk [ STH2 ] [ #34 ] EQU STH2r ;&t EQU2 AND AND JMP2r
 912-	&t 00
 913-
 914-@op-deik ( -- pass )
 915-	( skip ) #01 JMP2r
 916-
 917-@op-deok ( -- pass )
 918-	( skip ) #01 JMP2r
 919-
 920-@op-addk ( -- pass )
 921-	( - ) #03 #05 ADDk ROT [ #03 ] EQU ROT [ #05 ] EQU AND SWP [ #08 ] EQU AND
 922-	( - ) #ff #01 ADDk ROT #ff EQU ROT #01 EQU AND SWP #00 EQU AND AND JMP2r
 923-
 924-@op-subk ( -- pass )
 925-	( - ) #ff #00 SUBk ROT #ff EQU ROT #00 EQU AND SWP #ff EQU AND
 926-	( - ) #01 #ff SUBk ROT #01 EQU ROT #ff EQU AND SWP [ #02 ] EQU AND AND JMP2r
 927-
 928-@op-mulk ( -- pass )
 929-	( - ) #03 #04 MULk ROT [ #03 ] EQU ROT [ #04 ] EQU AND SWP [ #0c ] EQU AND
 930-	( - ) #10 #02 MULk ROT [ #10 ] EQU ROT [ #02 ] EQU AND SWP [ #20 ] EQU AND AND JMP2r
 931-
 932-@op-divk ( -- pass )
 933-	( - ) #10 #02 DIVk ROT [ #10 ] EQU ROT [ #02 ] EQU AND SWP [ #08 ] EQU AND
 934-	( - ) #34 #01 DIVk ROT [ #34 ] EQU ROT #01 EQU AND SWP [ #34 ] EQU AND AND JMP2r
 935-
 936-@op-andk ( -- pass )
 937-	( - ) #fc #3f ANDk ROT [ #fc ] EQU ROT [ #3f ] EQU AND SWP [ #3c ] EQU AND
 938-	( - ) #ff #aa ANDk ROT #ff EQU ROT [ #aa ] EQU AND SWP [ #aa ] EQU AND AND JMP2r
 939-
 940-@op-orak ( -- pass )
 941-	( - ) #0f #f0 ORAk ROT [ #0f ] EQU ROT [ #f0 ] EQU AND SWP #ff EQU AND
 942-	( - ) #12 #34 ORAk ROT [ #12 ] EQU ROT [ #34 ] EQU AND SWP [ #36 ] EQU AND AND JMP2r
 943-
 944-@op-eork ( -- pass )
 945-	( - ) #aa #55 EORk ROT [ #aa ] EQU ROT [ #55 ] EQU AND SWP #ff EQU AND
 946-	( - ) #ff #ff EORk ROT #ff EQU ROT #ff EQU AND SWP #00 EQU AND AND JMP2r
 947-
 948-@op-sftk ( -- pass )
 949-	( - ) #ff #11 SFTk ROT #ff EQU ROT [ #11 ] EQU AND SWP [ #fe ] EQU AND
 950-	( - ) #ff #12 SFTk ROT #ff EQU ROT [ #12 ] EQU AND SWP [ #7e ] EQU AND AND JMP2r
 951-
 952-(
 953-@|m2k )
 954-
 955-@op-inc2k ( -- pass )
 956-	( - ) #00ff INC2k ADD2 #01ff EQU2 JMP2r
 957-
 958-@op-pop2k ( -- pass )
 959-	( - ) #0a0b POP2k #0a0b EQU2 JMP2r
 960-
 961-@op-nip2k ( -- pass )
 962-	( - ) #1234 #5678 NIP2k #5678 EQU2 STH
 963-	( - ) #5678 EQU2 STH
 964-	ANDr
 965-	( - ) #1234 EQU2 STHr AND JMP2r
 966-
 967-@op-swp2k ( -- pass )
 968-	( - ) #1234 #5678 SWP2k
 969-	( | tests )
 970-	#1234 EQU2 STH
 971-	#5678 EQU2 STH
 972-	#5678 EQU2 STH
 973-	#1234 EQU2 STH
 974-	ANDr ANDr ANDr STHr JMP2r
 975-
 976-@op-rot2k ( -- pass )
 977-	( - ) #000a #000b #000c ROT2k
 978-	( | tests )
 979-	#000a EQU2 STH
 980-	#000c EQU2 STH
 981-	#000b EQU2 STH
 982-	#000c EQU2 STH
 983-	#000b EQU2 STH
 984-	#000a EQU2 STH
 985-	ANDr ANDr ANDr ANDr ANDr STHr JMP2r
 986-
 987-@op-dup2k ( -- pass )
 988-	( - ) #0a0b DUP2k
 989-	( | tests )
 990-	#0a0b EQU2 STH
 991-	#0a0b EQU2 STH
 992-	#0a0b EQU2 STH
 993-	ANDr ANDr STHr JMP2r
 994-
 995-@op-ovr2k ( -- pass )
 996-	( - ) #0a0b #0c0d OVR2k
 997-	( | tests )
 998-	#0a0b EQU2 STH
 999-	#0c0d EQU2 STH
1000-	#0a0b EQU2 STH
1001-	#0c0d EQU2 STH
1002-	#0a0b EQU2 STH
1003-	ANDr ANDr ANDr ANDr STHr JMP2r
1004-
1005-@op-equ2k ( -- pass )
1006-	( - ) #0a0b #0a0b EQU2k STH
1007-	EQU2 STHr AND
1008-	( - ) #0a0b #0e0f EQU2k #00 EQU STH
1009-	EQU2 #00 EQU STHr AND AND JMP2r
1010-
1011-@op-neq2k ( -- pass )
1012-	( - ) #0a0b #0a0b NEQ2k #00 EQU STH
1013-	NEQ2 #00 EQU STHr AND
1014-	( - ) #0a0b #0e0f NEQ2k STH
1015-	NEQ2 STHr AND AND JMP2r
1016-
1017-@op-gth2k ( -- pass )
1018-	( - ) #000a #000b GTH2k #00 EQU STH
1019-	GTH2 #00 EQU STHr AND
1020-	( - ) #000b #000a GTH2k STH
1021-	GTH2 STHr AND AND JMP2r
1022-
1023-@op-lth2k ( -- pass )
1024-	( - ) #000b #000a LTH2k #00 EQU STH
1025-	LTH2 #00 EQU STHr AND
1026-	( - ) #000a #000b LTH2k STH
1027-	LTH2 STHr AND AND JMP2r
1028-
1029-@op-jmp2k ( -- pass )
1030-	( - ) LIT2r 1234 ;&x [ JMP2k SWPr &x ] POP2 STHr POPr #34 EQU
1031-	( - ) LIT2r 1234 ;&t [ JMP2k &back ] POP2 POPr STHr #34 EQU AND JMP2r
1032-	&t POP2 SWPr ;&back JMP2k
1033-
1034-@op-jcn2k ( -- pass )
1035-	( - ) LITr 0a #00 ;&x JCN2k INCr &x POP2 POP STHr #0b EQU
1036-	( - ) LITr 0a #18 ;&y JCN2k INCr &y POP2 POP STHr #0a EQU AND JMP2r
1037-
1038-@op-jsr2k ( -- pass )
1039-	( - ) #0a ;&t JSR2k #0b EQU JMP2r
1040-	&t POP2 INC JMP2r
1041-
1042-@op-sth2k ( -- pass )
1043-	( - ) #0a0b STH2k STH2r EQU2 JMP2r
1044-
1045-@op-ldz2k ( -- pass )
1046-	( - ) #00 LDZ2k #1234 EQU2 SWP #00 EQU AND JMP2r
1047-
1048-@op-stz2k ( -- pass )
1049-	( - ) #5678 #05 [ STZ2k ] #05 EQU STH
1050-	#5678 EQU2 STHr AND #05 LDZ2 #5678 EQU2 AND JMP2r
1051-
1052-@op-ldr2k ( -- pass )
1053-	( - ) ,&t LDR2k [ LIT2 &t 1234 ] EQU2 NIP JMP2r
1054-
1055-@op-str2k ( -- pass )
1056-	( - ) #1234 ,&t STR2k POP [ LIT2 &t $2 ] EQU2 JMP2r
1057-
1058-@op-lda2k ( -- pass )
1059-	( - ) ;&t LDA2k [ LIT2 &t 1234 ] EQU2 NIP NIP JMP2r
1060-
1061-@op-sta2k ( -- pass )
1062-	( - ) #1234 ;&t STA2k POP2 [ LIT2 &t $2 ] EQU2 JMP2r
1063-
1064-@op-dei2k ( -- pass )
1065-	( skip ) #01 JMP2r
1066-
1067-@op-deo2k ( -- pass )
1068-	( skip ) #01 JMP2r
1069-
1070-@op-add2k ( -- pass )
1071-	#0a0b #0c0d ADD2k
1072-	( | tests )
1073-	#1618 EQU2 STH
1074-	#0c0d EQU2 STH
1075-	#0a0b EQU2 STH
1076-	ANDr ANDr STHr JMP2r
1077-
1078-@op-sub2k ( -- pass )
1079-	#0a0b #0c0d SUB2k
1080-	( | tests )
1081-	#fdfe EQU2 STH
1082-	#0c0d EQU2 STH
1083-	#0a0b EQU2 STH
1084-	ANDr ANDr STHr JMP2r
1085-
1086-@op-mul2k ( -- pass )
1087-	#0a0b #0c0d MUL2k
1088-	( | tests )
1089-	#068f EQU2 STH
1090-	#0c0d EQU2 STH
1091-	#0a0b EQU2 STH
1092-	ANDr ANDr STHr JMP2r
1093-
1094-@op-div2k ( -- pass )
1095-	#0c0d #0003 DIV2k
1096-	( | tests )
1097-	#0404 EQU2 STH
1098-	#0003 EQU2 STH
1099-	#0c0d EQU2 STH
1100-	ANDr ANDr STHr JMP2r
1101-
1102-@op-and2k ( -- pass )
1103-	#0c0d #a5a5 AND2k
1104-	( | tests )
1105-	#0405 EQU2 STH
1106-	#a5a5 EQU2 STH
1107-	#0c0d EQU2 STH
1108-	ANDr ANDr STHr JMP2r
1109-
1110-@op-ora2k ( -- pass )
1111-	#0c0d #a5a5 ORA2k
1112-	( | tests )
1113-	#adad EQU2 STH
1114-	#a5a5 EQU2 STH
1115-	#0c0d EQU2 STH
1116-	ANDr ANDr STHr JMP2r
1117-
1118-@op-eor2k ( -- pass )
1119-	#0c0d #a5a5 EOR2k
1120-	( | tests )
1121-	#a9a8 EQU2 STH
1122-	#a5a5 EQU2 STH
1123-	#0c0d EQU2 STH
1124-	ANDr ANDr STHr JMP2r
1125-
1126-@op-sft2k ( -- pass )
1127-	( - ) #1234 #32 SFT2k
1128-	( | test )
1129-	#2468 EQU2 STH
1130-	#32 EQU STH
1131-	#1234 EQU2 STH
1132-	ANDr ANDr STHr JMP2r
1133-
1134-(
1135-@|mkr )
1136-
1137-@op-inckr ( -- pass )
1138-	( - ) LITr 01 INCkr LIT2r 0102 EQU2r
1139-	( - ) LITr ff INCkr LIT2r ff00 EQU2r ANDr STHr JMP2r
1140-
1141-@op-popkr ( -- pass )
1142-	( - ) LIT2r 0a0b POPkr LIT2r 0a0b EQU2r STHr JMP2r
1143-
1144-@op-nipkr ( -- pass )
1145-	( - ) LIT2r 1234 NIPkr NIPr NIPr LITr 34 EQUr
1146-	( - ) LIT2r 1234 NIPkr NIPr LIT2r 1234 EQU2r ANDr STHr JMP2r
1147-
1148-@op-swpkr ( -- pass )
1149-	( - ) LIT2r 1234 SWPkr NIP2r LIT2r 3412 EQU2r
1150-	( - ) LIT2r 1234 SWPkr POP2r LIT2r 1234 EQU2r ANDr STHr JMP2r
1151-
1152-@op-rotkr ( -- pass )
1153-	LITr 0a LITr 0b LITr 0c ROTkr STH2r #0c0a EQU2 STH2r #0c0b EQU2 STH2r #0a0b EQU2 AND AND JMP2r
1154-
1155-@op-dupkr ( -- pass )
1156-	( - ) LITr 0a DUPkr
1157-	( . ) STH2r #0a0a EQU2
1158-	( . ) STHr #0a EQU AND JMP2r
1159-
1160-@op-ovrkr ( -- pass )
1161-	( - ) LIT2r 0a0b OVRkr
1162-	( . ) STH2r #0b0a EQU2
1163-	( . ) STH2r #0b0a EQU2 AND
1164-	( . ) STHr #0a EQU AND JMP2r
1165-
1166-@op-equkr ( -- pass )
1167-	( - ) LIT2r 0a0a EQUkr ROTr LITr 0a EQUr ROTr LITr 0a EQUr ANDr SWPr LITr 01 EQUr ANDr
1168-	( - ) LIT2r 0a0b EQUkr ROTr LITr 0a EQUr ROTr LITr 0b EQUr ANDr SWPr LITr 00 EQUr ANDr ANDr STHr JMP2r
1169-
1170-@op-neqkr ( -- pass )
1171-	( - ) LIT2r 0a0b NEQkr ROTr LITr 0a EQUr ROTr LITr 0b EQUr ANDr SWPr LITr 01 EQUr ANDr
1172-	( - ) LIT2r 0a0a NEQkr ROTr LITr 0a EQUr ROTr LITr 0a EQUr ANDr SWPr LITr 00 EQUr ANDr ANDr STHr JMP2r
1173-
1174-@op-gthkr ( -- pass )
1175-	( - ) LIT2r f801 GTHkr ROTr LITr f8 EQUr ROTr LITr 01 EQUr ANDr SWPr LITr 01 EQUr ANDr
1176-	( - ) LIT2r 01f8 GTHkr ROTr LITr 01 EQUr ROTr LITr f8 EQUr ANDr SWPr LITr 00 EQUr ANDr ANDr STHr JMP2r
1177-
1178-@op-lthkr ( -- pass )
1179-	( - ) LIT2r 01ff LTHkr ROTr LITr 01 EQUr ROTr LITr ff EQUr ANDr SWPr LITr 01 EQUr ANDr
1180-	( - ) LIT2r f801 LTHkr ROTr LITr f8 EQUr ROTr LITr 01 EQUr ANDr SWPr LITr 00 EQUr ANDr ANDr STHr JMP2r
1181-
1182-@op-jmpkr ( -- pass )
1183-	( - ) #1234 LITr _&x [ JMPkr SWP &x ] POP POPr [ #12 ] EQU
1184-	( - ) #1234 LITr _&t [ JMPkr &back ] POP POPr [ #34 ] EQU AND JMP2r
1185-	&t POPr SWP LITr _&back JMPkr
1186-
1187-@op-jcnkr ( -- pass )
1188-	( - ) #0a LIT2r 00 _&x JCNkr
1189-	INC &x POP2r #0b EQU
1190-	( - ) #0a LIT2r 01 _&y JCNkr
1191-	INC &y POP2r #0a EQU AND JMP2r
1192-
1193-@op-jsrkr ( -- pass )
1194-	( - ) LITr 0a LITr _&t JSRkr STHr #0b EQU JMP2r
1195-	&t POPr INCr JMP2
1196-
1197-@op-sthkr ( -- pass )
1198-	( - ) LIT2r 0a0b STH2kr STH2r EQU2 JMP2r
1199-
1200-@op-ldzkr ( -- pass )
1201-	( - ) LITr 00 LDZkr STH2r #0012 EQU2 JMP2r
1202-
1203-@op-stzkr ( -- pass )
1204-	( - ) LITr 56 LITr 0a STZkr
1205-	POP2r LITr 0a LDZr LITr 56 EQUr
1206-	( - ) LITr ab LITr 0b STZkr
1207-	LIT2r ab0b EQU2r ANDr STHr JMP2r
1208-
1209-@op-ldrkr ( -- pass )
1210-	( - ) LITr _&t LDRkr [ LITr 12 ] EQUr NIPr STHr JMP2r
1211-	&t 12
1212-
1213-@op-strkr ( -- pass )
1214-	( - ) LITr 34 LITr _&t STRkr
1215-	POP2r LITr _&t LDRr [ LITr 34 ] EQUr
1216-	( - ) LITr 34 LITr _&t STRkr
1217-	SWPr [ LITr 34 ] EQUr NIPr ANDr STHr JMP2r
1218-	&t $1
1219-
1220-@op-ldakr ( -- pass )
1221-	( - ) LIT2r =&t LDAkr [ STHr ] LIT2r =&t EQU2r STH
1222-	[ LITr ef ] EQUr ANDr STHr JMP2r
1223-	&t ef
1224-
1225-@op-stakr ( -- pass )
1226-	( - ) LITr 12 LIT2r =&t STAkr
1227-	POP2r POPr LIT2r =&t LDAr [ LITr 12 ] EQUr
1228-	( - ) LITr 34 LIT2r =&t STAkr
1229-	[ STH2r ] [ LITr 34 ] EQUr STH2
1230-	LIT2r =&t EQU2r ANDr ANDr STHr JMP2r
1231-	&t 00
1232-
1233-@op-deikr ( -- pass )
1234-	( skip ) #01 JMP2r
1235-
1236-@op-deokr ( -- pass )
1237-	( skip ) #01 JMP2r
1238-
1239-@op-addkr ( -- pass )
1240-	( - ) LITr 03 LITr 05 ADDkr ROTr LITr 03 EQUr ROTr LITr 05 EQUr ANDr SWPr LITr 08 EQUr ANDr
1241-	( - ) LITr ff LITr 01 ADDkr ROTr LITr ff EQUr ROTr LITr 01 EQUr ANDr SWPr LITr 00 EQUr ANDr ANDr STHr JMP2r
1242-
1243-@op-subkr ( -- pass )
1244-	( - ) LITr ff LITr 00 SUBkr ROTr LITr ff EQUr ROTr LITr 00 EQUr ANDr SWPr LITr ff EQUr ANDr
1245-	( - ) LITr 01 LITr ff SUBkr ROTr LITr 01 EQUr ROTr LITr ff EQUr ANDr SWPr LITr 02 EQUr ANDr ANDr STHr JMP2r
1246-
1247-@op-mulkr ( -- pass )
1248-	( - ) LITr 03 LITr 04 MULkr ROTr LITr 03 EQUr ROTr LITr 04 EQUr ANDr SWPr LITr 0c EQUr ANDr
1249-	( - ) LITr 10 LITr 02 MULkr ROTr LITr 10 EQUr ROTr LITr 02 EQUr ANDr SWPr LITr 20 EQUr ANDr ANDr STHr JMP2r
1250-
1251-@op-divkr ( -- pass )
1252-	( - ) LITr 10 LITr 02 DIVkr ROTr LITr 10 EQUr ROTr LITr 02 EQUr ANDr SWPr LITr 08 EQUr ANDr
1253-	( - ) LITr 34 LITr 01 DIVkr ROTr LITr 34 EQUr ROTr LITr 01 EQUr ANDr SWPr LITr 34 EQUr ANDr ANDr STHr JMP2r
1254-
1255-@op-andkr ( -- pass )
1256-	( - ) LITr fc LITr 3f ANDkr ROTr LITr fc EQUr ROTr LITr 3f EQUr ANDr SWPr LITr 3c EQUr ANDr
1257-	( - ) LITr ff LITr aa ANDkr ROTr LITr ff EQUr ROTr LITr aa EQUr ANDr SWPr LITr aa EQUr ANDr ANDr STHr JMP2r
1258-
1259-@op-orakr ( -- pass )
1260-	( - ) LITr 0f LITr f0 ORAkr ROTr LITr 0f EQUr ROTr LITr f0 EQUr ANDr SWPr LITr ff EQUr ANDr
1261-	( - ) LITr 12 LITr 34 ORAkr ROTr LITr 12 EQUr ROTr LITr 34 EQUr ANDr SWPr LITr 36 EQUr ANDr ANDr STHr JMP2r
1262-
1263-@op-eorkr ( -- pass )
1264-	( - ) LITr aa LITr 55 EORkr ROTr LITr aa EQUr ROTr LITr 55 EQUr ANDr SWPr LITr ff EQUr ANDr
1265-	( - ) LITr ff LITr ff EORkr ROTr LITr ff EQUr ROTr LITr ff EQUr ANDr SWPr LITr 00 EQUr ANDr ANDr STHr JMP2r
1266-
1267-@op-sftkr ( -- pass )
1268-	( - ) LITr ff LITr 11 SFTkr ROTr LITr ff EQUr ROTr LITr 11 EQUr ANDr SWPr LITr fe EQUr ANDr
1269-	( - ) LITr ff LITr 12 SFTkr ROTr LITr ff EQUr ROTr LITr 12 EQUr ANDr SWPr LITr 7e EQUr ANDr ANDr STHr JMP2r
1270-
1271-(
1272-@|m2kr )
1273-
1274-@op-inc2kr ( -- pass )
1275-	( - ) LIT2r 00ff INC2kr ADD2r LIT2r 01ff EQU2r STHr JMP2r
1276-
1277-@op-pop2kr ( -- pass )
1278-	( - ) LIT2r 0a0b POP2kr LIT2r 0a0b EQU2r STHr JMP2r
1279-
1280-@op-nip2kr ( -- pass )
1281-	( - ) LIT2r 1234 LIT2r 5678 NIP2kr LIT2r 5678 EQU2r STHr
1282-	( - ) LIT2r 5678 EQU2r STHr AND
1283-	( - ) LIT2r 1234 EQU2r STH
1284-	ANDr STHr JMP2r
1285-
1286-@op-swp2kr ( -- pass )
1287-	( - ) LIT2r 1234 LIT2r 5678 SWP2kr
1288-	( | tests )
1289-	LIT2r 1234 EQU2r STHr LIT2r 5678 EQU2r STHr LIT2r 5678 EQU2r STHr LIT2r 1234 EQU2r STHr AND AND AND JMP2r
1290-
1291-@op-rot2kr ( -- pass )
1292-	( - ) LIT2r 1234 LIT2r 5678 LIT2r 9abc ROT2kr STH2r #1234 EQU2 STH2r #9abc EQU2 STH2r #5678 EQU2 STH2r #9abc EQU2 STH2r #5678 EQU2 STH2r #1234 EQU2 AND AND AND AND AND JMP2r
1293-
1294-@op-dup2kr ( -- pass )
1295-	( - ) LIT2r 1234 DUP2kr ADD2r ADD2r STH2r #369c EQU2 JMP2r
1296-
1297-@op-ovr2kr ( -- pass )
1298-	( - ) LIT2r 0a0b LIT2r 0c0d OVR2kr STH2r #0a0b EQU2 STH2r #0c0d EQU2 STH2r #0a0b EQU2 STH2r #0c0d EQU2 STH2r #0a0b EQU2 AND AND AND AND JMP2r
1299-
1300-@op-equ2kr ( -- pass )
1301-	( - ) LIT2r 0a0b LIT2r 0a0b EQU2kr STHr EQU2r STH
1302-	ANDr
1303-	( - ) LIT2r 0a0b LIT2r 0e0f EQU2kr LITr 00 EQUr STHr EQU2r LITr 00 EQUr STH
1304-	ANDr ANDr STHr JMP2r
1305-
1306-@op-neq2kr ( -- pass )
1307-	( - ) LIT2r 0a0b LIT2r 0a0b NEQ2kr LITr 00 EQUr STHr NEQ2r LITr 00 EQUr STH
1308-	ANDr
1309-	( - ) LIT2r 0a0b LIT2r 0e0f NEQ2kr STHr NEQ2r STH
1310-	ANDr ANDr STHr JMP2r
1311-
1312-@op-gth2kr ( -- pass )
1313-	( - ) LIT2r 000a LIT2r 000b GTH2kr LITr 00 EQUr STHr GTH2r LITr 00 EQUr STH
1314-	ANDr
1315-	( - ) LIT2r 000b LIT2r 000a GTH2kr STHr GTH2r STH
1316-	ANDr ANDr STHr JMP2r
1317-
1318-@op-lth2kr ( -- pass )
1319-	( - ) LIT2r 000b LIT2r 000a LTH2kr LITr 00 EQUr STHr LTH2r LITr 00 EQUr STH
1320-	ANDr
1321-	( - ) LIT2r 000a LIT2r 000b LTH2kr STHr LTH2r STH
1322-	ANDr ANDr STHr JMP2r
1323-
1324-@op-jmp2kr ( -- pass )
1325-	( - ) #1234 LIT2r =&x [ JMP2kr SWP &x ] POP2r POP #12 EQU
1326-	( - ) #1234 LIT2r =&t [ JMP2kr &back ] POP2r POP #34 EQU AND JMP2r
1327-	&t POP2r SWP LIT2r =&back JMP2kr
1328-
1329-@op-jcn2kr ( -- pass )
1330-	( - ) #0a LITr 00 LIT2r =&x JCN2kr
1331-	INC &x POP2r POPr #0b EQU
1332-	( - ) #0a LITr 01 LIT2r =&y JCN2kr
1333-	INC &y POP2r POPr #0a EQU AND JMP2r
1334-
1335-@op-jsr2kr ( -- pass )
1336-	( - ) LITr 0a LIT2r =&t JSR2kr STHr #0b EQU JMP2r
1337-	&t POP2r INCr JMP2
1338-
1339-@op-sth2kr ( -- pass )
1340-	( - ) LIT2r 0a0b STH2kr #0a0b EQU2 #0a0b STH2r EQU2 AND JMP2r
1341-
1342-@op-ldz2kr ( -- pass )
1343-	( - ) LITr 00 LDZ2kr STH2r #1234 EQU2 STHr #00 EQU AND JMP2r
1344-
1345-@op-stz2kr ( -- pass )
1346-	( - ) LIT2r 5678 LITr 09 [ STZ2kr ] STHr #09 EQU STH2r #5678 EQU2 AND #09 LDZ2 #5678 EQU2 AND JMP2r
1347-
1348-@op-ldr2kr ( -- pass )
1349-	( - ) LITr _&t LDR2kr [ LIT2r &t 1234 ] EQU2r NIPr STHr JMP2r
1350-
1351-@op-str2kr ( -- pass )
1352-	( - ) LIT2r 1234 LITr _&t STR2kr
1353-	POPr [ LIT2r &t $2 ] EQU2r STHr JMP2r
1354-
1355-@op-lda2kr ( -- pass )
1356-	( - ) LIT2r =&t LDA2kr [ LIT2r &t 1234 ] EQU2r NIPr NIPr STHr JMP2r
1357-
1358-@op-sta2kr ( -- pass )
1359-	( - ) LIT2r 1234 LIT2r =&t STA2kr
1360-	POP2r [ LIT2r &t $2 ] EQU2r STHr JMP2r
1361-
1362-@op-dei2kr ( -- pass )
1363-	( skip ) #01 JMP2r
1364-
1365-@op-deo2kr ( -- pass )
1366-	( skip ) #01 JMP2r
1367-
1368-@op-add2kr ( -- pass )
1369-	LIT2r 0a0b LIT2r 0c0d ADD2kr
1370-	( | tests )
1371-	LIT2r 1618 EQU2r STHr LIT2r 0c0d EQU2r STHr LIT2r 0a0b EQU2r STHr AND AND JMP2r
1372-
1373-@op-sub2kr ( -- pass )
1374-	LIT2r 0a0b LIT2r 0c0d SUB2kr
1375-	( | tests )
1376-	LIT2r fdfe EQU2r STHr LIT2r 0c0d EQU2r STHr LIT2r 0a0b EQU2r STHr AND AND JMP2r
1377-
1378-@op-mul2kr ( -- pass )
1379-	LIT2r 0a0b LIT2r 0c0d MUL2kr
1380-	( | tests )
1381-	LIT2r 068f EQU2r STHr LIT2r 0c0d EQU2r STHr LIT2r 0a0b EQU2r STHr AND AND JMP2r
1382-
1383-@op-div2kr ( -- pass )
1384-	LIT2r 0c0d LIT2r 0003 DIV2kr
1385-	( | tests )
1386-	LIT2r 0404 EQU2r STHr LIT2r 0003 EQU2r STHr LIT2r 0c0d EQU2r STHr AND AND JMP2r
1387-
1388-@op-and2kr ( -- pass )
1389-	LIT2r 0c0d LIT2r a5a5 AND2kr
1390-	( | tests )
1391-	LIT2r 0405 EQU2r STHr LIT2r a5a5 EQU2r STHr LIT2r 0c0d EQU2r STHr AND AND JMP2r
1392-
1393-@op-ora2kr ( -- pass )
1394-	LIT2r 0c0d LIT2r a5a5 ORA2kr
1395-	( | tests )
1396-	LIT2r adad EQU2r STHr LIT2r a5a5 EQU2r STHr LIT2r 0c0d EQU2r STHr AND AND JMP2r
1397-
1398-@op-eor2kr ( -- pass )
1399-	LIT2r 0c0d LIT2r a5a5 EOR2kr
1400-	( | tests )
1401-	LIT2r a9a8 EQU2r STHr LIT2r a5a5 EQU2r STHr LIT2r 0c0d EQU2r STHr AND AND JMP2r
1402-
1403-@op-sft2kr ( -- pass )
1404-	( - ) LIT2r 1234 LITr 32 SFT2kr LIT2r 2468 EQU2r SWP2r LIT2r 1234 EQU2r ANDr LIT2r 3201 EQU2r STHr JMP2r
1405-
1406-@tests/lut [
1407-	=op-brk =op-inc =op-pop =op-nip
1408-	=op-swp =op-rot =op-dup =op-ovr
1409-	=op-equ =op-neq =op-gth =op-lth
1410-	=op-jmp =op-jcn =op-jsr =op-sth
1411-	=op-ldz =op-stz =op-ldr =op-str
1412-	=op-lda =op-sta =op-dei =op-deo
1413-	=op-add =op-sub =op-mul =op-div
1414-	=op-and =op-ora =op-eor =op-sft
1415-	=op-jci =op-inc2 =op-pop2 =op-nip2
1416-	=op-swp2 =op-rot2 =op-dup2 =op-ovr2
1417-	=op-equ2 =op-neq2 =op-gth2 =op-lth2
1418-	=op-jmp2 =op-jcn2 =op-jsr2 =op-sth2
1419-	=op-ldz2 =op-stz2 =op-ldr2 =op-str2
1420-	=op-lda2 =op-sta2 =op-dei2 =op-deo2
1421-	=op-add2 =op-sub2 =op-mul2 =op-div2
1422-	=op-and2 =op-ora2 =op-eor2 =op-sft2
1423-	=op-jmi =op-incr =op-popr =op-nipr
1424-	=op-swpr =op-rotr =op-dupr =op-ovrr
1425-	=op-equr =op-neqr =op-gthr =op-lthr
1426-	=op-jmpr =op-jcnr =op-jsrr =op-sthr
1427-	=op-ldzr =op-stzr =op-ldrr =op-strr
1428-	=op-ldar =op-star =op-deir =op-deor
1429-	=op-addr =op-subr =op-mulr =op-divr
1430-	=op-andr =op-orar =op-eorr =op-sftr
1431-	=op-jsi =op-inc2r =op-pop2r =op-nip2r
1432-	=op-swp2r =op-rot2r =op-dup2r =op-ovr2r
1433-	=op-equ2r =op-neq2r =op-gth2r =op-lth2r
1434-	=op-jmp2r =op-jcn2r =op-jsr2r =op-sth2r
1435-	=op-ldz2r =op-stz2r =op-ldr2r =op-str2r
1436-	=op-lda2r =op-sta2r =op-dei2r =op-deo2r
1437-	=op-add2r =op-sub2r =op-mul2r =op-div2r
1438-	=op-and2r =op-ora2r =op-eor2r =op-sft2r
1439-	=op-lit =op-inck =op-popk =op-nipk
1440-	=op-swpk =op-rotk =op-dupk =op-ovrk
1441-	=op-equk =op-neqk =op-gthk =op-lthk
1442-	=op-jmpk =op-jcnk =op-jsrk =op-sthk
1443-	=op-ldzk =op-stzk =op-ldrk =op-strk
1444-	=op-ldak =op-stak =op-deik =op-deok
1445-	=op-addk =op-subk =op-mulk =op-divk
1446-	=op-andk =op-orak =op-eork =op-sftk
1447-	=op-lit2 =op-inc2k =op-pop2k =op-nip2k
1448-	=op-swp2k =op-rot2k =op-dup2k =op-ovr2k
1449-	=op-equ2k =op-neq2k =op-gth2k =op-lth2k
1450-	=op-jmp2k =op-jcn2k =op-jsr2k =op-sth2k
1451-	=op-ldz2k =op-stz2k =op-ldr2k =op-str2k
1452-	=op-lda2k =op-sta2k =op-dei2k =op-deo2k
1453-	=op-add2k =op-sub2k =op-mul2k =op-div2k
1454-	=op-and2k =op-ora2k =op-eor2k =op-sft2k
1455-	=op-litr =op-inckr =op-popkr =op-nipkr
1456-	=op-swpkr =op-rotkr =op-dupkr =op-ovrkr
1457-	=op-equkr =op-neqkr =op-gthkr =op-lthkr
1458-	=op-jmpkr =op-jcnkr =op-jsrkr =op-sthkr
1459-	=op-ldzkr =op-stzkr =op-ldrkr =op-strkr
1460-	=op-ldakr =op-stakr =op-deikr =op-deokr
1461-	=op-addkr =op-subkr =op-mulkr =op-divkr
1462-	=op-andkr =op-orakr =op-eorkr =op-sftkr
1463-	=op-lit2r =op-inc2kr =op-pop2kr =op-nip2kr
1464-	=op-swp2kr =op-rot2kr =op-dup2kr =op-ovr2kr
1465-	=op-equ2kr =op-neq2kr =op-gth2kr =op-lth2kr
1466-	=op-jmp2kr =op-jcn2kr =op-jsr2kr =op-sth2kr
1467-	=op-ldz2kr =op-stz2kr =op-ldr2kr =op-str2kr
1468-	=op-lda2kr =op-sta2kr =op-dei2kr =op-deo2kr
1469-	=op-add2kr =op-sub2kr =op-mul2kr =op-div2kr
1470-	=op-and2kr =op-ora2kr =op-eor2kr =op-sft2kr ] &lut-end
1471-
+0, -604
  1@@ -1,604 +0,0 @@
  2-( 54K . Perifs
  3-| Controller: Buttons should highlight on press and display the button and key bytes.
  4-| Mouse: Buttons should highlight on press and display the x and y position. )
  5-
  6-|00 @System/vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
  7-|20 @Screen/vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
  8-|80 @Controller/vector $2 &button $1 &key $1
  9-|90 @Mouse/vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2
 10-|c0 @DateTime/year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
 11-|0050 @Varvara/version
 12-
 13-|000
 14-
 15-	@center/x $2 &y $2
 16-	@wheel/y $1 &y-lo $1
 17-
 18-|100
 19-
 20-@on-reset ( -> )
 21-	;meta #06 DEO2
 22-	( | Set size )
 23-	#0180 .Screen/width DEO2
 24-	#0180 .Screen/height DEO2
 25-	( | Theme )
 26-	#0f0f .System/r DEO2
 27-	#00ff .System/g DEO2
 28-	#00ff .System/b DEO2
 29-	( | Wipe layers )
 30-	#0000 DUP2 .Screen/x DEO2
 31-	.Screen/y DEO2
 32-	[ LIT2 80 -Screen/pixel ] DEO
 33-	[ LIT2 c0 -Screen/pixel ] DEO
 34-	( | Blank vectors )
 35-	#0000 #00 &l DEO2k #10 ADD DUP [ ?/l POP POP2 ]
 36-	( | Halt recover )
 37-	[ LIT2 80 -System/halt ] DEO
 38-	[ LIT2 01 -System/halt ] DEO
 39-	[ LIT2 00 -System/halt ] DEO
 40-	( | Distant pixels )
 41-	#8000 .Screen/x DEO2
 42-	#8000 .Screen/y DEO2
 43-	[ LIT2 00 -Screen/pixel ] DEO
 44-	[ LIT2 40 -Screen/pixel ] DEO
 45-	[ LIT2 80 -Screen/pixel ] DEO
 46-	[ LIT2 c0 -Screen/pixel ] DEO
 47-	[ LIT2 d0 -Screen/pixel ] DEO
 48-	[ LIT2 e0 -Screen/pixel ] DEO
 49-	[ LIT2 f0 -Screen/pixel ] DEO
 50-	( | Find center )
 51-	.Screen/width DEI2 #01 SFT2 .center/x STZ2
 52-	.Screen/height DEI2 #01 SFT2 .center/y STZ2
 53-	controller/<draw>
 54-	mouse/<draw>
 55-	smile/<draw-all>
 56-	;controller/on-event .Controller/vector DEO2
 57-	;mouse/on-event .Mouse/vector DEO2
 58-	;fps/on-frame .Screen/vector DEO2
 59-	BRK
 60-
 61-@meta 00 "Perifs 0a
 62-	( details ) "A 20 "Peripherals 20 "Test 0a
 63-	( author ) "By 20 "Hundred 20 "Rabbits 0a
 64-	( date ) "3 20 "Sep 20 "2026 00
 65-	( . ) 02
 66-	( - ) 56 =Varvara/version
 67-	( - ) 83 =appicon
 68-
 69-%Screen/<set-pos> ( x* y* -- ) {
 70-	.Screen/y DEO2
 71-	.Screen/x DEO2 }
 72-
 73-%Screen/<mod-x> ( x* -- ) {
 74-	.Screen/x DEI2 ADD2 .Screen/x DEO2 }
 75-
 76-%Screen/<mod-y> ( x* -- ) {
 77-	.Screen/y DEI2 ADD2 .Screen/y DEO2 }
 78-
 79-%Screen/<mod> ( x* y* -- ) {
 80-	Screen/<mod-y>
 81-	Screen/<mod-x> }
 82-
 83-%u8/mod ( a b -- res ) {
 84-	DIVk MUL SUB }
 85-
 86-(
 87-@|Controller )
 88-
 89-@controller/on-event ( -> )
 90-	/<draw>
 91-	( | print stack on start button )
 92-	[ LIT2 08 -Controller/button ] DEI
 93-	( | handlers )
 94-	DUP ?{ smile/<next> }
 95-	NEQ ?{ #010e DEO }
 96-	BRK
 97-
 98-@controller/<draw> ( -- )
 99-	.Controller/button DEI2
100-	( | background )
101-	.center/x LDZ2 #0040 SUB2 .Screen/x DEO2
102-	.center/y LDZ2 #0040 SUB2 .Screen/y DEO2
103-	#03f9 ;&icns #f6 <draw-times>
104-	( | output )
105-	#0010 #ffb0 Screen/<mod>
106-	DUP2 hex/<draw-short>
107-	( | A button )
108-	OVR #01 AND #00 EQU ?{
109-		.center/x LDZ2 #0028 ADD2 .Screen/x DEO2
110-		.center/y LDZ2 #0020 SUB2 .Screen/y DEO2
111-		#03fe ;large/icns #16 <draw-times> }
112-	( | B button )
113-	OVR #02 AND #00 EQU ?{
114-		.center/x LDZ2 #0010 ADD2 .Screen/x DEO2
115-		.center/y LDZ2 #0020 SUB2 .Screen/y DEO2
116-		#03fe ;large/icns #16 <draw-times> }
117-	( | S button )
118-	OVR #04 AND #00 EQU ?{
119-		.center/x LDZ2 #0018 SUB2 .Screen/x DEO2
120-		.center/y LDZ2 #0018 SUB2 .Screen/y DEO2
121-		#03ff ;small/icn #16 <draw-times> }
122-	( | Z button )
123-	OVR #08 AND #00 EQU ?{
124-		.center/x LDZ2 #0008 SUB2 .Screen/x DEO2
125-		.center/y LDZ2 #0018 SUB2 .Screen/y DEO2
126-		#03ff ;small/icn #16 <draw-times> }
127-	( | Up arrow )
128-	OVR #10 AND #00 EQU ?{
129-		.center/x LDZ2 #0030 SUB2 .Screen/x DEO2
130-		.center/y LDZ2 #0028 SUB2 .Screen/y DEO2
131-		#0fff ;arrow/icn #00 <draw-times> }
132-	( | Down arrow )
133-	OVR #20 AND #00 EQU ?{
134-		.center/x LDZ2 #0030 SUB2 .Screen/x DEO2
135-		.center/y LDZ2 #0018 SUB2 .Screen/y DEO2
136-		#0fff ;arrow/icn #00 <draw-times> }
137-	( | Left arrow )
138-	OVR #40 AND #00 EQU ?{
139-		.center/x LDZ2 #0038 SUB2 .Screen/x DEO2
140-		.center/y LDZ2 #0020 SUB2 .Screen/y DEO2
141-		#0fff ;arrow/icn #00 <draw-times> }
142-	( | Right arrow )
143-	OVR #80 AND #00 EQU ?{
144-		.center/x LDZ2 #0028 SUB2 .Screen/x DEO2
145-		.center/y LDZ2 #0020 SUB2 .Screen/y DEO2
146-		#0fff ;arrow/icn #00 <draw-times> }
147-	POP2 JMP2r
148-
149-(
150-@|Mouse )
151-
152-@mouse/on-event ( -> )
153-	[ LIT2 &last $1 -Mouse/state ] DEI DUP ,&last STR
154-	EQUk ?{
155-		DUP #00 EQU ?{ smile/<next> } }
156-	POP2 /<draw>
157-	/<draw-cursor>
158-	BRK
159-
160-@mouse/<draw-cursor> ( -- )
161-	[ LIT2 00 -Screen/auto ] DEO
162-	;&cursor-icn .Screen/addr DEO2
163-	[ LIT2 &last-x $2 ] .Screen/x DEO2
164-	[ LIT2 &last-y $2 ] .Screen/y DEO2
165-	[ LIT2 40 -Screen/sprite ] DEO
166-	.Mouse/x DEI2 #0003 SUB2 DUP2 ,&last-x STR2
167-	.Screen/x DEO2
168-	.Mouse/y DEI2 #0003 SUB2 DUP2 ,&last-y STR2
169-	.Screen/y DEO2
170-	[ LIT2 43 -Screen/sprite ] DEO
171-	JMP2r
172-
173-@mouse/<draw> ( -- )
174-	.center/x LDZ2 #0040 SUB2 .Screen/x DEO2
175-	.center/y LDZ2 #0020 ADD2 .Screen/y DEO2
176-	#03fc ;&icns #f6 <draw-times>
177-	( | output )
178-	#0010 #ffd0 Screen/<mod>
179-	[ LIT2 01 -Screen/auto ] DEO
180-	.Mouse/state DEI DUP hex/<draw-byte>
181-	( | x )
182-	#0018 Screen/<mod-x>
183-	.Mouse/x DEI2 hex/<draw-short>
184-	( | y )
185-	#0008 Screen/<mod-x>
186-	.Mouse/y DEI2 hex/<draw-short>
187-	( | mouse 1 )
188-	DUP #01 AND #00 EQU ?{
189-		.center/x LDZ2 #0040 SUB2 .Screen/x DEO2
190-		.center/y LDZ2 #0022 ADD2 .Screen/y DEO2
191-		#0fff ;&tip-icn #16 <draw-times> }
192-	( | mouse 2 )
193-	DUP #02 AND #00 EQU ?{
194-		.center/x LDZ2 #0028 SUB2 .Screen/x DEO2
195-		.center/y LDZ2 #0022 ADD2 .Screen/y DEO2
196-		#0fff ;small/icn #16 <draw-times> }
197-	( | mouse 3 )
198-	DUP #04 AND #00 EQU ?{
199-		.center/x LDZ2 #0018 SUB2 .Screen/x DEO2
200-		.center/y LDZ2 #0022 ADD2 .Screen/y DEO2
201-		#0fff ;small/icn #16 <draw-times> }
202-	POP !wheel/<redraw>
203-
204-@wheel/<redraw> ( -- )
205-	.center/x LDZ2 #0047 ADD2 .Screen/x DEO2
206-	.center/y LDZ2 #0010 ADD2 .Screen/y DEO2
207-	[ LIT2 01 -Screen/auto ] DEO
208-	.&y-lo LDZ hex/<draw-byte>
209-	( | wheel )
210-	.center/x LDZ2 #0048 ADD2 .Screen/x DEO2
211-	.center/y LDZ2 #0020 ADD2 .Screen/y DEO2
212-	#03ff ;&icns #16 <draw-times>
213-	#03ff ;&icns2 #16 <draw-times>
214-	.&y LDZ2k .Mouse/scrolly DEI2 ADD2 ROT STZ2
215-	.&y LDZ2 DUP2 #0010 ADD2 /offset
216-	( >> )
217-	&offset ( wheelpos* -- )
218-	DUP2 #001f AND2 .center/x LDZ2 #0048 ADD2 /load .Screen/x DEO2
219-	#0018 ADD2 #001f AND2 .center/y LDZ2 #0020 ADD2 /load .Screen/y DEO2
220-	[ LIT2 03 -Screen/pixel ] DEO
221-	JMP2r
222-
223-	&load ( offset* base* -- coord* )
224-	SWP2 ;&offsets ADD2 LDA #00 SWP ADD2 JMP2r
225-
226-(
227-@|Smile )
228-
229-@smile/<next> ( -- )
230-	[ LIT &ptr $1 ] INCk ,&ptr STR
231-	[ LIT2 00 -Screen/auto ] DEO
232-	#0a u8/mod
233-	( | draw )
234-	#0028 .Screen/x DEO2
235-	.Screen/height DEI2 #0018 SUB2 .Screen/y DEO2
236-	DUP hex/<draw-byte>
237-	/<clear>
238-	#00 SWP DUP ADD ;&lut ADD2 LDA2 JMP2
239-
240-@smile/<draw-all> ( -- )
241-	;&lut-end ;&lut
242-	&>l
243-		/<clear>
244-		LDA2k JSR2 INC2 INC2 GTH2k ?/>l
245-	POP2 POP2 JMP2r
246-
247-@smile/<set-pos> ( -- )
248-	#0010 .Screen/height DEI2 #0020 SUB2 Screen/<set-pos>
249-	JMP2r
250-
251-@smile/<clear> ( -- )
252-	[ LIT2 11 -Screen/auto ] DEO
253-	( | bg )
254-	/<set-pos>
255-	;hash .Screen/addr DEO2
256-	[ LIT2 03 -Screen/sprite ] DEOk DEO
257-	( | fg )
258-	/<set-pos>
259-	;fill .Screen/addr DEO2
260-	[ LIT2 40 -Screen/sprite ] DEOk DEO
261-	JMP2r
262-
263-@smile/<draw-0> ( Draw 1bpp four times by moving x,y )
264-	/<set-pos>
265-	[ LIT2 00 -Screen/auto ] DEO
266-	( a ) ;&hor-a .Screen/addr DEO2
267-	[ LIT2 03 -Screen/sprite ] DEO
268-	#0008 Screen/<mod-x>
269-	( b ) ;&hor-b .Screen/addr DEO2
270-	[ LIT2 03 -Screen/sprite ] DEO
271-	#fff8 #0008 Screen/<mod>
272-	( c ) ;&hor-c .Screen/addr DEO2
273-	[ LIT2 03 -Screen/sprite ] DEO
274-	#0008 #0000 Screen/<mod>
275-	( d ) ;&hor-d .Screen/addr DEO2
276-	[ LIT2 03 -Screen/sprite ] DEO
277-	JMP2r
278-
279-@smile/<draw-1> ( Draw 1bpp two times using addr-y )
280-	/<set-pos>
281-	[ LIT2 16 -Screen/auto ] DEO
282-	;&hor .Screen/addr DEO2
283-	[ LIT2 03 -Screen/sprite ] DEOk DEO
284-	JMP2r
285-
286-@smile/<draw-2> ( Draw 1bpp two times using addr-x )
287-	/<set-pos>
288-	[ LIT2 15 -Screen/auto ] DEO
289-	;&ver .Screen/addr DEO2
290-	[ LIT2 03 -Screen/sprite ] DEOk DEO
291-	JMP2r
292-
293-@smile/<draw-3> ( Draw 1bpp-flipx two times using addr-y )
294-	/<set-pos>
295-	#0008 #0000 Screen/<mod>
296-	[ LIT2 16 -Screen/auto ] DEO
297-	;&horx .Screen/addr DEO2
298-	[ LIT2 13 -Screen/sprite ] DEOk DEO
299-	JMP2r
300-
301-@smile/<draw-4> ( Draw 1bpp-flipy two times using addr-x )
302-	/<set-pos>
303-	#0000 #0008 Screen/<mod>
304-	[ LIT2 15 -Screen/auto ] DEO
305-	;&very .Screen/addr DEO2
306-	[ LIT2 23 -Screen/sprite ] DEOk DEO
307-	JMP2r
308-
309-@smile/<draw-5> ( Draw 2bpp two times using addr-x )
310-	/<set-pos>
311-	[ LIT2 15 -Screen/auto ] DEO
312-	;&2bpp .Screen/addr DEO2
313-	[ LIT2 81 -Screen/sprite ] DEOk DEO
314-	JMP2r
315-
316-@smile/<draw-6> ( Draw 1bpp, once for the outline, once for the face )
317-	/<set-pos>
318-	[ LIT2 16 -Screen/auto ] DEO
319-	;&outline .Screen/addr DEO2
320-	[ LIT2 03 -Screen/sprite ] DEOk DEO
321-	#0000 #fff0 Screen/<mod>
322-	;&face .Screen/addr DEO2
323-	[ LIT2 0f -Screen/sprite ] DEOk DEO
324-	JMP2r
325-
326-@smile/<draw-7> ( Draw 1bpp, once for the outline, once for the face in fg )
327-	/<set-pos>
328-	[ LIT2 16 -Screen/auto ] DEO
329-	;&outline .Screen/addr DEO2
330-	[ LIT2 03 -Screen/sprite ] DEOk DEO
331-	#0000 #fff0 Screen/<mod>
332-	;&face .Screen/addr DEO2
333-	[ LIT2 43 -Screen/sprite ] DEOk DEO
334-	JMP2r
335-
336-@smile/<draw-8> ( Draw using pixels )
337-	/<set-pos>
338-	;&hor-a icn/<draw-tile>
339-	#0008 #fff8 Screen/<mod>
340-	;&hor-b icn/<draw-tile>
341-	#fff8 #0000 Screen/<mod>
342-	;&hor-c icn/<draw-tile>
343-	#0008 #fff8 Screen/<mod>
344-	;&hor-d !icn/<draw-tile>
345-
346-@smile/<draw-9> ( Draw offscreen origin )
347-	/<set-pos>
348-	.Screen/x DEI2 #0030 SUB2 .Screen/x DEO2
349-	;&offscreen .Screen/addr DEO2
350-	[ LIT2 76 -Screen/auto ] DEO
351-	[ LIT2 03 -Screen/sprite ] DEOk DEO
352-	JMP2r
353-
354-(
355-@|Fps )
356-
357-@fps/on-frame ( -> )
358-	[ LIT &f $1 ] INCk ,&f STR
359-	[ LIT2 &t $1 -DateTime/second ] DEI DUP ,&t STR
360-	EQU ?{
361-		INCk /<redraw>
362-		[ LIT2 00 _&f ] STR }
363-	POP BRK
364-
365-@fps/<redraw> ( update -- )
366-	DUP [ LIT &last $1 ] NEQ ?{ POP JMP2r }
367-	DUP ,&last STR
368-	[ LIT2 01 -Screen/auto ] DEO
369-	#0010 .Screen/height DEI2 #0030 SUB2 Screen/<set-pos> !dec/<draw-10>
370-
371-(
372-@|Icn )
373-
374-@icn/<draw-tile> ( addr* -- )
375-	[ LIT2 01 -Screen/auto ] DEO
376-	DUP2 #0008 ADD2 SWP2
377-	&>v
378-		LDAk /<draw-row>
379-		#fff8 #0001 Screen/<mod>
380-		INC2 GTH2k ?/>v
381-	POP2 POP2 JMP2r
382-
383-@icn/<draw-row> ( byte -- )
384-	STH
385-	#ff07
386-	&>h
387-		STHkr OVR SFT #01 AND #03 MUL .Screen/pixel DEO
388-		#01 SUB NEQk ?/>h
389-	POP2 POPr JMP2r
390-
391-(
392-@|Generics )
393-
394-@<draw-times> ( color times addr* auto -- )
395-	.Screen/auto DEO
396-	.Screen/addr DEO2
397-	SWP STH
398-	[ LITr -Screen/sprite ]
399-	&>l
400-		DEOkr
401-		INC DUP ?/>l
402-	POP POP2r JMP2r
403-
404-@dec/<draw-10> ( byte -- )
405-	DUP #0a DIV chr/<draw-num>
406-	#0a u8/mod !chr/<draw-num>
407-
408-@hex/<draw-short> ( short* -- )
409-	[ LIT2 01 -Screen/auto ] DEO
410-	SWP /<draw-byte>
411-	( >> )
412-
413-@hex/<draw-byte> ( byte -- )
414-	DUP #04 SFT chr/<draw-num>
415-	( >> )
416-
417-@chr/<draw-num> ( char -- )
418-	#00 SWP #0f AND #30 SFT2 ;&icns ADD2 .Screen/addr DEO2
419-	[ LIT2 03 -Screen/sprite ] DEO
420-	JMP2r
421-
422-(
423-@|Assets )
424-
425-@smile/lut [3
426-	=/<draw-0> =/<draw-1> =/<draw-2>
427-	=/<draw-3> =/<draw-4> =/<draw-5>
428-	=/<draw-6> =/<draw-7> =/<draw-8>
429-	=/<draw-9> ] &lut-end
430-
431-@hash [ aa55 aa55 aa55 aa55 ]
432-
433-@fill [ ffff ffff ffff ffff ]
434-
435-@appicon [8
436-	0000 0000 0000 0102 0000 0000 0000 0001
437-	0000 0000 3cc3 0000 0000 0000 003c ffff
438-	0000 0000 0000 8040 0000 0000 0000 0080
439-	0404 0809 0808 0404 0303 0706 0707 0303
440-	0000 81c3 8100 423c ffff 7ebc 7eff bdc3
441-	2020 1090 1010 2020 c0c0 e060 e0e0 c0c0
442-	0201 0000 0000 0000 0100 0000 0000 0000
443-	0000 c33c 0000 0000 ffff 3c00 0000 0000
444-	4080 0000 0000 0000 8000 0000 0000 0000 ]
445-
446-@wheel/offsets [
447-	07 08 09 0a 0b 0b 0c 0c 0c 0c 0c 0b 0b 0a 09 08
448-	07 06 05 04 03 03 02 02 02 02 02 03 03 04 05 06 ]
449-	&icns [ 0718 2040 4080 8081 c030 0804 0402 0202 ]
450-	&icns2 [ 8080 4040 2018 0700 0202 0404 0830 c000 ]
451-
452-@arrow/icn [ 187e 7eff ff7e 7e18 ]
453-
454-@small/icn [ 0000 001f 3f3f 3f1f 0000 00f8 fcfc fcf8 ]
455-
456-@large/icns [8
457-	071f 3f7f 7fff ffff e0f8 fcfe feff ffff
458-	ffff ff7f 7f3f 1f07 ffff fffe fefc f8e0 ]
459-
460-@controller/icns [8
461-	0000 0f30 4040 8080 0000 ff00 0000 0000
462-	0042 8100 0000 0000 0000 ff00 0000 0000
463-	0000 ff00 0000 0000 0000 ff00 0000 0000
464-	0000 ff00 0000 0000 0000 ff00 0000 0000
465-	0000 ff00 0000 0000 0000 ff00 0000 0000
466-	0000 ff00 0000 0000 0000 ff00 0000 0000
467-	0000 ff00 0000 0000 0000 ff00 0000 0000
468-	0000 ff00 0000 0000 0000 f00c 0202 0101
469-	8080 8080 8080 8080 0000 0000 0000 0000
470-	0000 0000 0000 0000 0000 0000 0000 0000
471-	0000 0000 0000 0000 0000 0000 0000 0000
472-	0000 0000 0000 0000 0000 0000 0000 0000
473-	0000 0000 0000 0000 0000 0000 0000 0000
474-	0000 0000 0000 0000 0000 0000 0000 0000
475-	0000 0000 0000 0000 0000 0000 0000 0000
476-	0000 0000 0000 0000 0101 0101 0101 0101
477-	8080 8080 8080 8080 0000 0000 0000 0000
478-	0000 0000 0000 0018 0000 0000 0000 0000
479-	0000 0000 0000 0000 0000 0000 0000 0000
480-	0000 0000 0000 0000 0000 0000 0000 0000
481-	0000 0000 0000 0000 0000 0000 0000 0000
482-	0000 0000 0000 0302 0000 0000 0000 8040
483-	0000 0000 0000 0000 0000 0000 0000 0102
484-	0000 0000 0000 8040 0101 0101 0101 0101
485-	8080 8080 8080 8080 0000 0001 0101 011f
486-	6681 8100 0000 0000 0000 0080 8080 80f8
487-	0000 0000 0000 0000 0000 0000 0000 0000
488-	0000 0000 0000 0000 0000 0000 0000 0000
489-	0000 0000 0000 0000 0000 0000 0000 0000
490-	0203 0202 0300 0000 4080 4040 8000 0000
491-	0000 0000 0000 0000 0203 0202 0200 0000
492-	40c0 4040 4000 0000 0101 0101 0101 0101
493-	8080 8081 8180 8080 6080 8000 0080 8060
494-	0000 0000 0000 0000 0601 0100 0001 0106
495-	0000 0080 8000 0000 0001 0202 0100 0201
496-	0080 4000 8040 4080 0003 0000 0102 0203
497-	00c0 4040 8000 00c0 0000 0000 0000 0000
498-	0718 2040 4080 8080 e018 0402 0201 0101
499-	0000 0000 0000 0000 0718 2040 4080 8080
500-	e018 0402 0201 0101 0101 0101 0101 0101
501-	8080 8080 8080 8080 1f01 0101 0100 0000
502-	0000 0000 0081 8166 f880 8080 8000 0000
503-	0000 0000 0000 0000 0000 001f 2020 201f
504-	0000 00f8 0404 04f8 0000 001f 2020 201f
505-	0000 00f8 0404 04f8 0000 0000 0000 0000
506-	8080 8040 4020 1807 0101 0102 0204 18e0
507-	0000 0000 0000 0000 8080 8040 4020 1807
508-	0101 0102 0204 18e0 0101 0101 0101 0101
509-	8080 8080 4040 300f 0000 0000 0000 00ff
510-	1800 0000 0000 00ff 0000 0000 0000 00ff
511-	0000 0000 0000 00ff 0000 0000 0000 00ff
512-	0000 0000 0000 00ff 0000 0000 0000 00ff
513-	0000 0000 0000 00ff 0000 0000 0000 00ff
514-	0000 0000 0000 00ff 0000 0000 0000 00ff
515-	0000 0000 0000 00ff 0000 0000 0000 00ff
516-	0000 0000 0000 00ff 0101 0101 0202 0cf0 ]
517-
518-@mouse/icns [8
519-	0000 0001 0618 6482 0718 6080 0000 0000
520-	e01f 0000 0000 0000 00c0 3f00 001f 2020
521-	0000 ff00 00f8 0404 0000 ff00 001f 2020
522-	0000 ff00 00f8 0404 0000 ff00 0000 0000
523-	0000 ff00 0000 0000 0000 ff00 0000 0000
524-	0000 ff00 0000 0000 0000 ff00 0000 0000
525-	0000 ff00 0000 0000 0000 ff00 0000 0000
526-	0000 ff00 0000 0000 0000 c03e 0101 0101
527-	6418 0601 0000 0000 0000 0080 6018 0700
528-	0000 0000 001f e000 201f 0000 3fc0 0000
529-	04f8 0000 ff00 0000 201f 0000 ff00 0000
530-	04f8 0000 ff00 0000 0000 0000 ff00 0000
531-	0000 0000 ff00 0000 0000 0000 ff00 0000
532-	0000 0000 ff00 0000 0000 0000 ff00 0000
533-	0000 0000 ff00 0000 0000 0000 ff00 0000
534-	0000 0000 ff00 0000 0101 013e c000 0000
535-	0000 6090 90f0 9090 0000 0000 0000 0000
536-	0000 0000 0000 0000 0000 0302 0203 0202
537-	0000 8040 4080 4040 0000 0102 0202 0202
538-	0000 8040 0000 0040 0000 0000 0000 0000
539-	0000 0000 0000 0000 0000 0000 0000 0000
540-	0000 0000 0000 0000 0000 0000 0000 0000
541-	0000 0000 0000 0000 0000 0000 0000 0000
542-	0000 0000 0000 0000 0000 0000 0000 0000
543-	9000 0000 0000 0000 0000 0000 0000 0000
544-	0000 0000 0000 0000 0300 0000 0000 0000
545-	8000 0000 0000 0000 0100 0000 0000 0000
546-	8000 0000 0000 0000 0000 0000 0000 0000
547-	0000 0000 0000 0000 0000 0000 0000 0000
548-	0000 0000 0000 0000 0000 0000 0000 0000
549-	0000 0000 0000 0000 0000 0000 0000 0000
550-	0000 0000 0000 0000 0000 0000 0000 0000 ]
551-	&tip-icn [ 0000 0000 187c 1800 $8 ]
552-	&cursor-icn [ 1010 10ee 1010 1000 ]
553-
554-@chr/icns [8
555-	0018 2424 2424 2418 0008 1808 0808 0808
556-	0018 2404 1820 203c 0018 2404 1804 2418
557-	0024 2424 1c04 0404 003c 2020 1804 2418
558-	0018 2420 3824 2418 003c 0408 1010 1010
559-	0018 2424 1824 2418 0018 2424 1c04 2418
560-	0018 2424 3c24 2424 0038 2424 3824 2438
561-	0018 2420 2020 2418 0038 2424 2424 2438
562-	001c 2020 3820 201c 001c 2020 3820 2020 ]
563-
564-@smile/hor
565-	&hor-a [ 030c 1020 4040 889c ]
566-	&hor-b [ c030 0804 0202 1129 ]
567-	&hor-c [ 8880 4443 2010 0c03 ]
568-	&hor-d [ 1101 22c2 0408 30c0 ]
569-
570-@smile/horx [8
571-	030c 1020 4040 8894 c030 0804 0202 1139
572-	8880 4443 2010 0c03 1101 22c2 0408 30c0 ]
573-
574-@smile/very [8
575-	030c 1020 4344 8088 9c88 4040 2010 0c03
576-	c030 0804 c222 0111 2911 0202 0408 30c0 ]
577-
578-@smile/ver [8
579-	030c 1020 4040 889c 8880 4443 2010 0c03
580-	c030 0804 0202 1129 1101 22c2 0408 30c0 ]
581-
582-@smile/2bpp [8
583-	030c 1020 4040 889c 030c 1020 4040 889c
584-	8880 4443 2010 0c03 8880 4443 2010 0c03
585-	c030 0804 0202 1129 c030 0804 0202 1129
586-	1101 22c2 0408 30c0 1101 22c2 0408 30c0 ]
587-
588-@smile/outline [8
589-	030c 1020 4040 8080 c030 0804 0202 0101
590-	8080 4040 2010 0c03 0101 0202 0408 30c0 ]
591-
592-@smile/face [8
593-	0000 0000 0000 081c 0000 0000 0000 1028
594-	0800 0403 0000 0000 1000 20c0 0000 0000 ]
595-
596-@smile/offscreen [8
597-	aa55 aa55 aa55 aa55 0000 0000 0000 0000
598-	0000 0000 0000 0000 0000 0000 0000 0000
599-	0000 0000 0000 0000 0000 0000 0000 0000
600-	030c 1020 4040 889c c030 0804 0202 1129
601-	aa55 aa55 aa55 aa55 0000 0000 0000 0000
602-	0000 0000 0000 0000 0000 0000 0000 0000
603-	0000 0000 0000 0000 0000 0000 0000 0000
604-	8880 4443 2010 0c03 1101 22c2 0408 30c0 ]
605-
+0, -152
  1@@ -1,152 +0,0 @@
  2-( All five portraits should look right )
  3-
  4-|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
  5-|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
  6-
  7-|0100
  8-	( | size )
  9-	#00a0 .Screen/width DEO2
 10-	#0020 .Screen/height DEO2
 11-	( | theme )
 12-	#05ae .System/r DEO2
 13-	#0a9f .System/g DEO2
 14-	#097f .System/b DEO2
 15-	( | normal horizontal )
 16-	#0000 .Screen/x DEO2
 17-	#0000 .Screen/y DEO2
 18-	[ LIT2 35 -Screen/auto ] DEO
 19-	;img-hor .Screen/addr DEO2
 20-	#85 <draw-4times>
 21-	( | normal vertical )
 22-	#0020 .Screen/x DEO2
 23-	#0000 .Screen/y DEO2
 24-	[ LIT2 36 -Screen/auto ] DEO
 25-	;img-ver .Screen/addr DEO2
 26-	#85 <draw-4times>
 27-	( | flipped horizontal )
 28-	#0058 .Screen/x DEO2
 29-	#0000 .Screen/y DEO2
 30-	[ LIT2 36 -Screen/auto ] DEO
 31-	;img-x-flipped .Screen/addr DEO2
 32-	#95 <draw-4times>
 33-	( | flipped vertical )
 34-	#0060 .Screen/x DEO2
 35-	#0018 .Screen/y DEO2
 36-	[ LIT2 36 -Screen/auto ] DEO
 37-	;img-y-flipped .Screen/addr DEO2
 38-	#a5 <draw-4times>
 39-	( | flipped horizontal/vertical )
 40-	#0098 .Screen/x DEO2
 41-	#0018 .Screen/y DEO2
 42-	[ LIT2 36 -Screen/auto ] DEO
 43-	;img-xy-flipped .Screen/addr DEO2
 44-	#b5 <draw-4times>
 45-	BRK
 46-
 47-@<draw-4times> ( color -- )
 48-	.Screen/sprite DEOk DEOk DEOk DEO
 49-	JMP2r
 50-
 51-@draw-fast ( w h addr* color -- )
 52-	,&color STR
 53-	.Screen/addr DEO2
 54-	SWP #01 SUB #40 SFT #06 ORA .Screen/auto DEO
 55-	#00 SWP SUB
 56-	&times ( -- )
 57-		[ LIT2 &color $1 -Screen/sprite ] DEO
 58-		INC DUP ?&times
 59-	POP JMP2r
 60-
 61-(
 62-@|assets )
 63-
 64-@img-ver [
 65-	0000 0008 0404 0501 ffff fff7 fbfa f9f9
 66-	0000 1000 21ff ffff ffff efde 21ff ffff
 67-	2020 0060 f8ff fffc dfdf 9f67 f8ff fffc
 68-	0703 2110 0888 c851 e7fb ddee 76b6 d64d
 69-	0307 0617 172f 080c fbf7 f6e5 e7cf e8ec
 70-	ffef 1fff ff1f 0f37 f7ef 1fff 8f07 0733
 71-	fbff ffff fcf8 f3f7 fbf7 fff8 f0f0 f1f1
 72-	d3d7 c783 0100 0040 8bc7 d79b 1d3e 3e5e
 73-	0e06 0301 0101 0505 eef6 fbfd fdfd f9f9
 74-	7bfb 3fff ffff ffff 3b3b 3fff ffff ffff
 75-	f7f7 f7ff fff7 fffb f3ff fff3 fbff ffe3
 76-	c0e0 e0e4 e5e3 c7cf feee eeea e9eb f7cf
 77-	3800 0103 c7ff ffff c6fe fd3b c7ff ffff
 78-	ff7f 3f0f a0b8 bebf ff7f 3f5f b1bf bfbf
 79-	dfbf fefd fb07 0fdf c387 fefd fb07 efdf
 80-	bf7f ffff ffff ffff bf7f ffff ffff ffff ]
 81-
 82-@img-hor [
 83-	0000 0008 0404 0501 ffff fff7 fbfa f9f9
 84-	0307 0617 172f 080c fbf7 f6e5 e7cf e8ec
 85-	0e06 0301 0101 0505 eef6 fbfd fdfd f9f9
 86-	3800 0103 c7ff ffff c6fe fd3b c7ff ffff
 87-	0000 1000 21ff ffff ffff efde 21ff ffff
 88-	ffef 1fff ff1f 0f37 f7ef 1fff 8f07 0733
 89-	7bfb 3fff ffff ffff 3b3b 3fff ffff ffff
 90-	ff7f 3f0f a0b8 bebf ff7f 3f5f b1bf bfbf
 91-	2020 0060 f8ff fffc dfdf 9f67 f8ff fffc
 92-	fbff ffff fcf8 f3f7 fbf7 fff8 f0f0 f1f1
 93-	f7f7 f7ff fff7 fffb f3ff fff3 fbff ffe3
 94-	dfbf fefd fb07 0fdf c387 fefd fb07 efdf
 95-	0703 2110 0888 c851 e7fb ddee 76b6 d64d
 96-	d3d7 c783 0100 0040 8bc7 d79b 1d3e 3e5e
 97-	c0e0 e0e4 e5e3 c7cf feee eeea e9eb f7cf
 98-	bf7f ffff ffff ffff bf7f ffff ffff ffff ]
 99-
100-@img-x-flipped [
101-	e0c0 8408 1011 138a e7df bb77 6e6d 6bb2
102-	0404 0006 1fff ff3f fbfb f9e6 1fff ff3f
103-	0000 0800 84ff ffff ffff f77b 84ff ffff
104-	0000 0010 2020 a080 ffff ffef df5f 9f9f
105-	cbeb e3c1 8000 0002 d1e3 ebd9 b87c 7c7a
106-	dfff ffff 3f1f cfef dfef ff1f 0f0f 8f8f
107-	fff7 f8ff fff8 f0ec eff7 f8ff f1e0 e0cc
108-	c0e0 60e8 e8f4 1030 dfef 6fa7 e7f3 1737
109-	0307 0727 a7c7 e3f3 7f77 7757 97d7 eff3
110-	efef efff ffef ffdf cfff ffcf dfff ffc7
111-	dedf fcff ffff ffff dcdc fcff ffff ffff
112-	7060 c080 8080 a0a0 776f dfbf bfbf 9f9f
113-	fdfe ffff ffff ffff fdfe ffff ffff ffff
114-	fbfd 7fbf dfe0 f0fb c3e1 7fbf dfe0 f7fb
115-	fffe fcf0 051d 7dfd fffe fcfa 8dfd fdfd
116-	1c00 80c0 e3ff ffff 637f bfdc e3ff ffff ]
117-
118-@img-y-flipped [
119-	ffff ffc7 0301 0038 ffff ffc7 3bfd fec6
120-	bfbe b8a0 0f3f 7fff bfbf bfb1 5f3f 7fff
121-	df0f 07fb fdfe bfdf dfef 07fb fdfe 87c3
122-	ffff ffff ffff 7fbf ffff ffff ffff 7fbf
123-	0505 0101 0103 060e f9f9 fdfd fdfb f6ee
124-	ffff ffff ff3f fb7b ffff ffff ff3f 3b3b
125-	fbff f7ff fff7 f7f7 e3ff fffb f3ff fff3
126-	cfc7 e3e5 e4e0 e0c0 cff7 ebe9 eaee eefe
127-	0c08 2f17 1706 0703 ece8 cfe7 e5f6 f7fb
128-	370f 1fff ff1f efff 3307 078f ff1f eff7
129-	f7f3 f8fc ffff fffb f1f1 f0f0 f8ff f7fb
130-	4000 0001 83c7 d7d3 5e3e 3e1d 9bd7 c78b
131-	0105 0404 0800 0000 f9f9 fafb f7ff ffff
132-	ffff ff21 0010 0000 ffff ff21 deef ffff
133-	fcff fff8 6000 2020 fcff fff8 679f dfdf
134-	51c8 8808 1021 0307 4dd6 b676 eedd fbe7 ]
135-
136-@img-xy-flipped [
137-	ffff ffff ffff fefd ffff ffff ffff fefd
138-	fbf0 e0df bf7f fdfb fbf7 e0df bf7f e1c3
139-	fd7d 1d05 f0fc feff fdfd fd8d fafc feff
140-	ffff ffe3 c080 001c ffff ffe3 dcbf 7f63
141-	f3e3 c7a7 2707 0703 f3ef d797 5777 777f
142-	dfff efff ffef efef c7ff ffdf cfff ffcf
143-	ffff ffff fffc dfde ffff ffff fffc dcdc
144-	a0a0 8080 80c0 6070 9f9f bfbf bfdf 6f77
145-	0200 0080 c1e3 ebcb 7a7c 7cb8 d9eb e3d1
146-	efcf 1f3f ffff ffdf 8f8f 0f0f 1fff efdf
147-	ecf0 f8ff fff8 f7ff cce0 e0f1 fff8 f7ef
148-	3010 f4e8 e860 e0c0 3717 f3e7 a76f efdf
149-	8a13 1110 0884 c0e0 b26b 6d6e 77bb dfe7
150-	3fff ff1f 0600 0404 3fff ff1f e6f9 fbfb
151-	ffff ff84 0008 0000 ffff ff84 7bf7 ffff
152-	80a0 2020 1000 0000 9f9f 5fdf efff ffff ]
153-
+0, -260
  1@@ -1,260 +0,0 @@
  2-( )
  3-
  4-|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
  5-|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
  6-|80 @Controller &vector $2 &button $1 &key $1
  7-|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2
  8-
  9-|000
 10-
 11-	@position &x $2 &y $2
 12-
 13-|100
 14-
 15-@on-reset ( -> )
 16-	#375e .System/r DEO2
 17-	#286c .System/g DEO2
 18-	#2358 .System/b DEO2
 19-	;on-mouse .Mouse/vector DEO2
 20-	;on-button .Controller/vector DEO2
 21-	<draw-guide>
 22-	#0028 #0028 <move>
 23-	BRK
 24-
 25-@on-button ( -> )
 26-	.Controller/button DEI
 27-	( | handlers )
 28-	DUP #10 NEQ ?{
 29-		.position/x LDZ2 .position/y LDZ2 #0004 SUB2 <move> }
 30-	DUP #20 NEQ ?{
 31-		.position/x LDZ2 .position/y LDZ2 #0004 ADD2 <move> }
 32-	DUP #40 NEQ ?{
 33-		.position/x LDZ2 #0004 SUB2 .position/y LDZ2 <move> }
 34-	DUP #80 NEQ ?{
 35-		.position/x LDZ2 #0004 ADD2 .position/y LDZ2 <move> }
 36-	DUP #14 NEQ ?{
 37-		.position/x LDZ2 .position/y LDZ2 #0040 SUB2 <move> }
 38-	DUP #24 NEQ ?{
 39-		.position/x LDZ2 .position/y LDZ2 #0040 ADD2 <move> }
 40-	DUP #44 NEQ ?{
 41-		.position/x LDZ2 #0040 SUB2 .position/y LDZ2 <move> }
 42-	DUP #84 NEQ ?{
 43-		.position/x LDZ2 #0040 ADD2 .position/y LDZ2 <move> }
 44-	DUP #01 NEQ ?{ <toggle-size> }
 45-	DUP #02 NEQ ?{ <toggle-theme> }
 46-	DUP #08 NEQ ?{ <toggle-pos> }
 47-	POP <draw-portraits>
 48-	BRK
 49-
 50-@on-mouse ( -> )
 51-	.Mouse/x DEI2 .Mouse/y DEI2 <move>
 52-	BRK
 53-
 54-(
 55-@|drawing )
 56-
 57-@<toggle-pos> ( -- )
 58-	.position/x LDZ2 #8000 NEQ2 ?{ #0000 DUP2 !<move> }
 59-	#8000 DUP2 !<move>
 60-
 61-@<toggle-size> ( -- )
 62-	.Screen/width DEI2 #0200 EQU2 ?{
 63-		#0200 .Screen/width DEO2
 64-		#0200 .Screen/height DEO2
 65-		<draw-guide> !<draw-portraits> }
 66-	#0180 .Screen/width DEO2
 67-	#0180 .Screen/height DEO2
 68-	<draw-guide> !<draw-portraits>
 69-
 70-@<toggle-theme> ( -- )
 71-	#ff00 .System/r DEI2 EQU2 ?{
 72-		#ff00 .System/r DEO2
 73-		#0ff0 .System/g DEO2
 74-		#00ff .System/b DEO2
 75-		JMP2r }
 76-	#00ff .System/r DEO2
 77-	#0ff0 .System/g DEO2
 78-	#ff00 .System/b DEO2
 79-	JMP2r
 80-
 81-@<move> ( x* y* -- )
 82-	( | clear )
 83-	.position/x LDZ2 #0020 SUB2 .Screen/x DEO2
 84-	.position/y LDZ2 #0020 SUB2 .Screen/y DEO2
 85-	[ LIT2 71 -Screen/auto ] DEO
 86-	;fill-icn .Screen/addr DEO2
 87-	#f8
 88-	&>l
 89-		#40 .Screen/sprite DEO
 90-		INC DUP ?&>l
 91-	POP OVR2 <phex>
 92-	#2018 DEO
 93-	DUP2 <phex>
 94-	#0a18 DEO
 95-	( | update )
 96-	.position/y STZ2
 97-	.position/x STZ2
 98-	( >> )
 99-
100-@<draw-portraits> ( -- )
101-	.position/x LDZ2 .Screen/x DEO2
102-	.position/y LDZ2 .Screen/y DEO2
103-	[ LIT2 36 -Screen/auto ] DEO
104-	.Mouse/state DEI .Controller/button DEI #0f AND ORA ?<draw-box>
105-	( | top-left )
106-	.Screen/x DEI2k #0000 ADD2 ROT DEO2
107-	.Screen/y DEI2k #0020 SUB2 ROT DEO2
108-	#8140 ORA <draw-portrait>
109-	.Screen/x DEI2k #0008 SUB2 ROT DEO2
110-	.Screen/y DEI2k #0020 SUB2 ROT DEO2
111-	#9140 ORA <draw-portrait>
112-	.Screen/x DEI2k #0000 SUB2 ROT DEO2
113-	.Screen/y DEI2k #0018 ADD2 ROT DEO2
114-	#b140 ORA <draw-portrait>
115-	.Screen/x DEI2k #0008 ADD2 ROT DEO2
116-	.Screen/y DEI2k #0020 ADD2 ROT DEO2
117-	#a140 ORA <draw-portrait>
118-	( | pixels )
119-	[ LIT2 00 -Screen/auto ] DEO
120-	.position/x LDZ2 .Screen/x DEO2
121-	.position/y LDZ2 .Screen/y DEO2
122-	#43 .Screen/pixel DEO
123-	.position/x LDZ2 #001f ADD2 .Screen/x DEO2
124-	.position/y LDZ2 #001f ADD2 .Screen/y DEO2
125-	#43 .Screen/pixel DEO
126-	.position/x LDZ2 #0020 SUB2 .Screen/x DEO2
127-	.position/y LDZ2 #0020 SUB2 .Screen/y DEO2
128-	#43 .Screen/pixel DEO
129-	JMP2r
130-
131-@<draw-portrait> ( color -- )
132-	;portrait-chr .Screen/addr DEO2
133-	.Screen/sprite DEOk DEOk DEOk DEO
134-	JMP2r
135-
136-@<draw-box> ( -- )
137-	( | top left )
138-	.Screen/x DEI2k #0020 SUB2 ROT DEO2
139-	.Screen/y DEI2k #0020 SUB2 ROT DEO2
140-	;box-icn .Screen/addr DEO2
141-	#43 .Screen/sprite DEOk DEOk DEOk DEO
142-	( | top right )
143-	.Screen/x DEI2k #0038 ADD2 ROT DEO2
144-	.Screen/y DEI2k #0020 SUB2 ROT DEO2
145-	;box-icn .Screen/addr DEO2
146-	#53 .Screen/sprite DEOk DEOk DEOk DEO
147-	( | bottom right )
148-	.Screen/x DEI2k #0000 ADD2 ROT DEO2
149-	.Screen/y DEI2k #0018 ADD2 ROT DEO2
150-	;box-icn .Screen/addr DEO2
151-	#73 .Screen/sprite DEOk DEOk DEOk DEO
152-	( | bottom left )
153-	.Screen/x DEI2k #0038 SUB2 ROT DEO2
154-	.Screen/y DEI2k #0020 ADD2 ROT DEO2
155-	;box-icn .Screen/addr DEO2
156-	#63 .Screen/sprite DEOk DEOk DEOk DEO
157-	JMP2r
158-
159-@<draw-circle> ( color -- )
160-	[ LITr -Screen/x ] DEI2r ;circle-chr .Screen/addr DEO2
161-	DUP .Screen/sprite DEO
162-	DUP #10 ORA .Screen/sprite DEO
163-	.Screen/y DEI2k #0008 ADD2 ROT DEO2
164-	DUP #20 ORA .Screen/sprite DEO
165-	#30 ORA .Screen/sprite DEO
166-	.Screen/y DEI2k #0008 SUB2 ROT DEO2
167-	[ LIT2r 0010 ] ADD2r [ LITr -Screen/x ] DEO2r
168-	JMP2r
169-
170-@<draw-guide> ( -- )
171-	#0080 .Screen/x DEO2
172-	#0080 .Screen/y DEO2
173-	#82 .Screen/pixel DEO
174-	#93 .Screen/pixel DEO
175-	#a1 .Screen/pixel DEO
176-	#0008 DUP2 .Screen/x DEO2
177-	.Screen/y DEO2
178-	#e2 .Screen/auto DEO
179-	;guide-icn .Screen/addr DEO2
180-	#0f00
181-	&>l
182-		#01 .Screen/sprite DEO
183-		INC GTHk ?&>l
184-	POP2
185-	( | circles 1bpp )
186-	#0088 .Screen/x DEO2
187-	#0008 .Screen/y DEO2
188-	#01 .Screen/auto DEO
189-	#0f00
190-	&>ll
191-		DUP <draw-circle>
192-		INC GTHk ?&>ll
193-	POP2
194-	( | circles 2bpp )
195-	#0088 .Screen/x DEO2
196-	#0018 .Screen/y DEO2
197-	#01 .Screen/auto DEO
198-	#0f00
199-	&>lll
200-		DUP #80 ORA <draw-circle>
201-		INC GTHk ?&>lll
202-	POP2 JMP2r
203-
204-@<update-cursor> ( color addr* -- )
205-	[ LIT2 00 -Screen/auto ] DEO
206-	;fill-icn .Screen/addr DEO2
207-	#40 <draw-cursor>
208-	.Mouse/x DEI2 ,<draw-cursor>/x STR2
209-	.Mouse/y DEI2 ,<draw-cursor>/y STR2
210-	.Screen/addr DEO2
211-
212-@<draw-cursor> ( color -- )
213-	[ LIT2 &x $2 ] .Screen/x DEO2
214-	[ LIT2 &y $2 ] .Screen/y DEO2
215-	.Screen/sprite DEO
216-	JMP2r
217-
218-@<phex> ( short* -: )
219-	SWP /b
220-	&b ( byte -: )
221-	DUP #04 SFT /c
222-	&c ( byte -: )
223-	#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
224-	JMP2r
225-
226-@guide-icn [ 8000 0000 0000 0000 ]
227-
228-@fill-icn [ ffff ffff ffff ffff ]
229-
230-@cursor-icn [ 80c0 e0f0 f8e0 1000 ]
231-
232-@portrait-chr [
233-	070f 1e1d 1b3b 3b3b f0e0 c0c0 d08b 8080
234-	f76f cf9f 9f5f 5f5f 0000 0007 1c40 4040
235-	fffb f975 7576 7667 0000 3164 0406 0607
236-	efef efef eddd 9e1e 0060 8000 0000 0000
237-	3b2b 280d 0105 0506 8080 8081 e1f1 f1f0
238-	5f6c 639b 0f27 77ab 4060 639b 0f27 67ab
239-	0dc8 b0e5 cded fdfc 0dc8 b0e4 ccec fcfc
240-	5e1e 1c9c 9d1d 5d59 4000 0080 8000 4040
241-	0607 0707 070e 0e0e f0f0 f0f0 f0e0 e0e0
242-	fb73 7fb7 bbbf bfdd f373 7b37 3b3f 3f1c
243-	ffff ffff ffff ffff ffff ffff ffff ff7f
244-	dba7 97f7 f7ed dd9d c080 90f0 f0e0 c080
245-	1e0e 0000 0000 0000 c0c0 f0ff ffff ffff
246-	ee03 0000 0000 0000 0e12 fcff ffff ffff
247-	fffc f30f 1f1f 1f3f 9f3c f30f dfdf dfbf
248-	3c80 8080 80c0 c0e0 0003 3fbf bfbf dfef ]
249-
250-@box-icn [
251-	0000 0000 0001 0204 0000 0f30 c000 0000
252-	03fc 0000 0000 0000 ff00 0000 0000 0000
253-	0808 1010 2020 2020 0000 0000 0000 0000
254-	0000 0000 0000 0000 0000 0000 0000 0000
255-	4040 4040 4040 8080 0000 0000 0000 0000
256-	0000 0000 0000 0000 0000 0000 0000 0000
257-	8080 8080 8080 8080 0000 0000 0000 0000
258-	0000 0000 0000 0000 0000 0000 0000 0000 ]
259-
260-@circle-chr [ 071f 3c70 60e3 c7c7 0000 030f 1f1f 3f3f ]
261-
+0, -128
  1@@ -1,128 +0,0 @@
  2-( Screen.pixel: test rom for screen pixel drawing )
  3-
  4-|00 @System/vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
  5-|20 @Screen/vector $2 &width $2 &height $2 &auto $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
  6-
  7-|000
  8-
  9-	@center &x $2 &y $2
 10-
 11-|100
 12-
 13-@on-reset ( -> )
 14-	( | theme )
 15-	#f07f .System/r DEO2
 16-	#f0d6 .System/g DEO2
 17-	#f0b2 .System/b DEO2
 18-	( | resize )
 19-	#00c8 DUP2 .Screen/width DEO2
 20-	.Screen/height DEO2
 21-	( | find screen center )
 22-	.Screen/width DEI2 #01 SFT2 .center/x STZ2
 23-	.Screen/height DEI2 #01 SFT2 .center/y STZ2
 24-	( | draw )
 25-	<draw-bg-fill>
 26-	<draw-bg-corners>
 27-	<draw-pixels>
 28-	#01 .Screen/auto DEO
 29-	<draw-default>
 30-	<draw-fg-corners>
 31-	<draw-default-flipx>
 32-	BRK
 33-
 34-@<draw-bg-fill> ( -- )
 35-	.center/x LDZ2 .Screen/x DEO2
 36-	.center/y LDZ2 .Screen/y DEO2
 37-	( | 4-way backgrounds )
 38-	#0400
 39-	&>l
 40-		DUP DUP #40 SFT #80 ADD ORA .Screen/pixel DEO
 41-		INC GTHk ?&>l
 42-	POP2 JMP2r
 43-
 44-@<draw-bg-corners> ( -- )
 45-	.center/x LDZ2 #01 SFT2 .Screen/x DEO2
 46-	.center/y LDZ2 #01 SFT2 .Screen/y DEO2
 47-	#b0 .Screen/pixel DEO
 48-	.center/x LDZ2 #01 SFT2 #0003 MUL2 .Screen/x DEO2
 49-	.center/y LDZ2 #01 SFT2 .Screen/y DEO2
 50-	#a1 .Screen/pixel DEO
 51-	.center/x LDZ2 #01 SFT2 #0003 MUL2 .Screen/x DEO2
 52-	.center/y LDZ2 #01 SFT2 #0003 MUL2 .Screen/y DEO2
 53-	#83 .Screen/pixel DEO
 54-	.center/x LDZ2 #01 SFT2 .Screen/x DEO2
 55-	.center/y LDZ2 #01 SFT2 #0003 MUL2 .Screen/y DEO2
 56-	#92 .Screen/pixel DEO
 57-	JMP2r
 58-
 59-@<draw-fg-corners> ( -- )
 60-	.center/x LDZ2 #02 SFT2 .Screen/x DEO2
 61-	.center/y LDZ2 #02 SFT2 .Screen/y DEO2
 62-	#f1 .Screen/pixel DEO
 63-	.center/x LDZ2 #02 SFT2 #0007 MUL2 .Screen/x DEO2
 64-	.center/y LDZ2 #02 SFT2 .Screen/y DEO2
 65-	#e3 .Screen/pixel DEO
 66-	( clear ) #e0 .Screen/pixel DEO
 67-	.center/x LDZ2 #02 SFT2 #0007 MUL2 .Screen/x DEO2
 68-	.center/y LDZ2 #02 SFT2 #0007 MUL2 .Screen/y DEO2
 69-	#c2 .Screen/pixel DEO
 70-	.center/x LDZ2 #02 SFT2 .Screen/x DEO2
 71-	.center/y LDZ2 #02 SFT2 #0007 MUL2 .Screen/y DEO2
 72-	#d0 .Screen/pixel DEO
 73-	JMP2r
 74-
 75-@<draw-pixels> ( -- )
 76-	( | bottom-left, background )
 77-	.center/x LDZ2 #0010 SUB2 .Screen/x DEO2
 78-	.center/y LDZ2 .Screen/y DEO2
 79-	( auto-x ) #01 .Screen/auto DEO
 80-	#00
 81-	&>bl
 82-		#00 OVR EQU OVR #0f AND ORA ?{
 83-			.center/x LDZ2 #0010 SUB2 .Screen/x DEO2
 84-			.Screen/y DEI2k INC2 ROT DEO2 }
 85-		DUP #04 SFT OVR #0f AND LTH INC .Screen/pixel DEO
 86-		INC DUP ?&>bl
 87-	POP
 88-	( | bottom-right, foreground )
 89-	.center/x LDZ2 .Screen/x DEO2
 90-	.center/y LDZ2 #0010 SUB2 .Screen/y DEO2
 91-	( auto-y ) #02 .Screen/auto DEO
 92-	#00
 93-	&>br
 94-		#00 OVR EQU OVR #0f AND ORA ?{
 95-			.center/y LDZ2 #0010 SUB2 .Screen/y DEO2
 96-			.Screen/x DEI2k INC2 ROT DEO2 }
 97-		DUP #04 SFT OVR #0f AND GTH INC #40 ORA .Screen/pixel DEO
 98-		INC DUP ?&>br
 99-	POP JMP2r
100-
101-
102-@<draw-default> ( -- )
103-	#0010 .Screen/x DEO2
104-	#0008 .Screen/y DEO2
105-	;bike-bin/end ;bike-bin [ LIT2r 83 00 ]
106-	&>l
107-		LDAk #40 ORA .Screen/pixel DEO
108-		INCr NEQkr STHr ?{
109-			#0010 .Screen/x DEO2
110-			.Screen/y DEI2 INC2 .Screen/y DEO2
111-			POPr LITr 00 }
112-		INC2 GTH2k ?&>l
113-	POP2 POP2 POP2r JMP2r
114-
115-@<draw-default-flipx> ( -- )
116-	#0093 .Screen/x DEO2
117-	#0070 .Screen/y DEO2
118-	;bike-bin/end ;bike-bin [ LIT2r 83 00 ]
119-	&>l
120-		LDAk #03 MUL #50 ORA .Screen/pixel DEO
121-		INCr NEQkr STHr ?{
122-			#0093 .Screen/x DEO2
123-			.Screen/y DEI2 INC2 .Screen/y DEO2
124-			POPr LITr 00 }
125-		INC2 GTH2k ?&>l
126-	POP2 POP2 POP2r JMP2r
127-
128-@bike-bin [
129-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 01 01 01 01 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 01 01 01 01 01 01 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 00 00 00 01 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 00 00 00 00 00 00 01 01 00 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 00 00 00 00 00 00 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 00 00 00 00 00 00 00 00 01 01 00 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 00 00 00 00 00 00 00 00 00 01 00 01 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 01 00 01 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 00 00 01 00 00 00 00 00 00 00 00 01 01 00 01 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 00 01 00 00 00 00 00 00 01 01 01 00 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 01 00 00 01 00 00 00 01 01 01 00 00 01 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 01 00 00 00 01 01 01 01 01 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 01 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 00 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 01 00 00 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01 00 00 00 00 00 00 00 01 01 00 00 00 01 01 00 01 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 00 00 01 01 01 01 01 00 01 01 01 01 01 01 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 00 00 01 01 01 00 00 00 01 01 00 01 00 01 01 00 01 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 01 01 01 01 01 01 00 01 00 00 00 00 00 00 00 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 00 00 00 00 01 01 01 01 01 01 01 01 01 00 00 00 00 01 01 01 01 01 01 01 01 01 00 01 01 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 01 00 01 01 01 01 00 01 00 01 01 01 01 01 01 01 01 01 01 00 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 01 01 01 00 01 01 01 01 01 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 01 00 01 01 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 01 01 01 01 01 00 00 00 00 01 00 00 00 00 00 01 01 01 01 01 01 01 00 01 01 01 00 01 00 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 01 00 00 01 00 01 01 01 01 00 00 00 00 00 01 00 00 00 00 01 01 01 01 01 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 01 01 01 01 00 00 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 01 01 01 01 00 00 01 01 01 01 00 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 01 01 01 01 00 01 01 01 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 00 00 01 01 01 01 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 01 01 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 01 01 01 01 01 01 00 00 00 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 01 01 00 01 01 00 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 01 01 01 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 01 00 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 01 01 01 01 00 01 00 00 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 01 00 00 01 01 01 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 00 01 01 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 01 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 01 01 01 00 00 01 01 00 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 01 00 00 01 01 01 01 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 01 01 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 01 01 01 01 00 00 01 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 01 00 00 01 01 01 00 01 01 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 01 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 01 00 00 00 00 00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 01 00 00 01 01 01 00 01 01 01 00 00 01 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 01 01 00 01 01 01 00 00 00 01 00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 01 00 00 00 00 00 00 01 01 01 00 00 01 00 00 00 00 00 00 00 00 00 00 01 00 01 01 01 00 01 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 01 01 01 00 00 00 01 01 01 00 01 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 01 00 01 01 01 00 01 00 00 01 01 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 01 00 01 01 01 00 01 00 00 00 00 00 00 00 00 00 01 00 01 01 01 00 00 00 01 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 01 01 01 01 00 00 01 00 01 01 01 00 01 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 01 00 01 01 01 00 00 00 01 00 00 01 00 01 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 01 00 00 00 01 01 01 00 01 00 00 00 00 00 00 00 01 00 00 01 01 00 00 00 00 00 01 00 00 00 00 00 01 00 00 01 00 00 00 01 00 00 01 00 00 00 01 00 00 01 01 01 00 00 01 00 00 00 01 01 00 00 01 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 01 01 00 01 01 00 00 00 00 00 01 00 01 00 00 01 00 00 00 00 01 00 00 01 00 00 00 01 00 00 01 00 00 00 00 00 01 00 00 00 00 00 01 01 00 00 01 00 00 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 01 00 00 00 00 01 00 00 00 01 00 00 01 00 00 01 00 00 00 01 00 01 01 01 00 00 01 00 00 00 00 00 01 01 00 01 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 01 01 01 00 01 01 00 00 00 01 00 00 01 00 00 01 00 00 00 01 00 00 00 00 01 00 00 00 00 00 00 00 01 01 00 01 00 00 00 00 00 01 00 00 01 01 00 00 00 00 00 00 00 00 01 00 00 00 00 01 00 00 01 00 00 01 00 00 01 00 00 01 00 01 01 01 00 00 01 00 00 00 00 00 01 01 01 00 00 01 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 00 01 00 00 01 01 00 00 00 00 00 00 00 00 01 01 00 00 01 00 00 00 01 00 00 01 00 00 01 00 00 01 00 00 00 00 01 00 00 00 00 00 00 00 00 01 01 00 00 01 00 00 00 00 01 00 01 01 00 01 01 00 00 00 00 00 00 00 01 00 00 00 01 00 00 01 00 00 01 00 00 01 00 00 01 01 01 01 01 00 01 00 00 00 00 01 01 00 00 01 01 00 01 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 00 00 01 00 01 01 00 00 01 00 00 00 00 00 00 00 01 01 00 01 01 00 00 01 00 00 01 00 00 01 00 00 01 00 00 00 01 00 00 00 00 00 00 00 01 01 00 01 01 00 01 00 00 00 00 01 00 01 01 00 00 00 01 01 00 00 00 00 00 00 01 00 00 00 01 00 00 01 00 01 00 01 00 00 01 00 01 01 01 00 01 00 00 00 00 01 00 00 00 00 01 01 00 01 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 00 00 00 01 00 01 01 00 00 00 01 01 00 00 00 00 00 00 01 00 00 01 00 00 00 01 00 01 00 01 00 00 01 00 00 00 01 00 00 00 00 00 00 01 01 00 00 00 01 01 00 01 00 00 00 01 00 01 01 00 00 00 00 00 00 01 01 00 00 00 00 00 01 00 00 00 01 00 01 00 01 00 01 00 00 01 01 01 01 00 01 00 00 00 01 01 00 00 00 00 00 00 01 01 00 01 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 00 00 00 01 00 01 01 00 00 00 00 00 00 01 01 00 00 00 00 01 01 00 01 01 00 00 01 00 01 00 01 00 01 00 00 00 01 00 00 00 00 00 01 01 00 00 00 00 00 00 01 01 00 01 00 00 01 00 01 01 00 00 00 00 00 00 00 00 01 01 00 00 00 00 01 00 00 01 00 01 00 01 00 01 00 01 01 01 01 01 01 00 00 01 01 00 00 00 00 00 00 01 01 01 01 00 01 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 00 01 01 00 00 00 01 00 00 01 01 00 01 00 01 00 01 00 01 00 00 01 00 00 00 00 01 01 00 00 00 00 00 00 00 00 01 01 00 01 00 00 01 00 01 01 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 01 00 00 01 01 00 01 01 01 00 01 01 01 01 00 00 00 01 00 00 00 00 00 01 01 00 00 00 01 01 00 01 01 00 00 01 00 01 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 00 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 00 01 01 00 01 00 01 00 01 01 00 00 01 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 01 01 00 01 00 01 00 00 01 01 01 01 01 01 00 00 00 00 00 00 00 01 01 00 00 00 01 00 01 00 01 01 01 00 01 01 01 01 00 00 01 01 00 00 01 00 01 00 00 00 01 01 01 00 01 00 01 01 00 00 01 00 01 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 00 00 00 00 00 01 00 00 01 01 00 01 01 01 00 00 00 00 00 00 00 01 01 00 01 01 00 01 01 00 01 00 01 00 01 00 01 00 00 00 01 01 00 00 00 00 00 00 00 01 01 01 01 01 01 00 00 01 01 00 01 01 00 00 00 00 00 01 01 01 01 00 00 00 00 00 01 01 00 00 01 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 01 01 00 01 01 00 00 00 00 00 00 00 00 00 01 00 01 01 00 00 00 00 00 01 01 01 01 00 00 00 00 00 01 01 01 01 00 01 01 01 01 01 01 00 01 00 00 01 01 00 00 00 00 00 01 01 01 01 00 00 00 00 00 01 01 00 01 01 00 01 01 00 00 00 00 00 00 00 00 00 01 01 01 01 00 00 00 01 01 00 01 01 00 00 01 01 01 00 01 01 00 00 00 00 01 01 01 01 00 00 00 00 00 00 00 00 01 01 01 01 00 01 01 01 01 01 01 01 01 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 00 00 01 01 01 01 00 00 00 01 01 01 00 01 01 00 01 00 01 00 01 01 00 00 00 01 01 01 01 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 00 00 01 01 00 01 01 01 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 01 01 01 00 01 01 01 01 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 00 00 01 01 00 01 00 00 01 01 01 00 00 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 00 01 01 01 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 00 01 01 00 01 00 00 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01 00 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 01 01 01 00 01 01 00 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 01 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 01 00 01 01 01 00 00 01 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 00 00 00 01 01 01 00 00 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 01 00 01 01 01 01 01 00 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 00 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 00 01 01 01 01 00 01 01 01 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01 01 01 00 00 00 01 01 01 01 01 01 00 01 01 01 00 00 00 00 00 01 01 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 00 00 01 01 00 00 01 01 01 00 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 01 01 00 00 00 00 00 00 00 00 00 01 01 01 01 00 00 00 00 01 01 01 01 01 00 01 01 01 01 01 00 00 00 01 01 01 01 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01 00 01 01 01 01 01 01 01 00 00 01 01 01 00 00 00 01 01 01 01 01 00 00 00 01 00 01 01 00 00 00 00 00 00 00 00 00 01 01 01 01 00 00 00 00 01 01 00 01 01 01 01 01 01 01 01 00 00 00 00 01 01 01 01 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 01 01 00 00 00 00 00 01 01 01 01 00 00 00 00 00 00 01 01 00 01 01 01 01 01 00 01 00 01 00 00 01 01 00 00 00 00 01 01 01 00 00 00 00 00 01 01 00 01 01 01 01 01 01 01 01 01 01 01 01 01 00 01 01 01 00 01 01 01 01 01 01 01 01 00 00 01 00 01 01 00 00 00 00 00 01 01 01 01 00 00 00 00 00 00 01 01 00 01 01 00 01 00 01 00 01 01 00 01 01 00 00 00 00 00 00 01 01 01 01 00 00 00 00 00 01 01 00 01 01 00 00 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 01 00 00 01 00 01 00 01 01 00 01 01 00 01 00 00 00 01 01 00 00 00 00 00 01 01 01 01 00 01 01 01 00 01 01 01 01 00 00 01 01 01 00 01 01 01 01 01 01 01 01 01 00 01 01 01 01 01 00 00 01 00 00 01 01 00 01 01 01 00 00 00 00 00 00 00 00 00 01 00 00 01 00 01 00 01 01 00 01 01 00 01 00 00 01 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 00 01 01 00 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 01 00 01 01 01 01 01 01 01 01 01 01 01 00 00 00 00 01 01 00 00 00 00 00 00 00 01 01 01 01 00 01 01 01 01 00 00 01 01 00 00 00 01 01 01 01 01 01 00 00 01 01 01 00 01 01 00 00 00 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 00 00 01 00 01 01 00 00 00 00 00 00 00 00 00 01 01 00 00 00 01 00 00 01 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 01 01 01 01 00 00 01 01 00 00 00 00 01 01 01 00 00 00 01 01 00 00 01 01 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 00 00 01 01 00 00 00 01 00 00 01 00 01 00 01 00 01 00 01 00 00 01 00 00 00 01 01 00 00 00 00 00 00 00 00 00 01 01 00 01 00 00 01 00 01 01 00 00 00 00 00 00 00 01 01 00 00 00 00 01 00 00 01 00 00 01 00 01 00 01 00 00 01 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 01 01 01 01 01 00 00 01 01 00 01 01 01 00 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 01 01 00 00 00 00 01 00 00 01 00 00 01 00 01 00 01 00 00 01 00 00 01 00 00 00 00 01 01 00 00 00 00 00 00 00 01 01 01 01 00 00 00 01 00 01 01 00 00 00 00 00 01 00 00 00 00 00 01 00 00 00 01 00 01 00 00 01 00 00 01 00 01 00 00 00 01 00 00 00 00 00 01 01 00 00 01 00 01 01 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 00 01 01 01 01 01 00 00 00 00 00 00 00 01 00 01 01 00 00 00 00 00 01 00 00 00 00 00 01 00 00 00 01 00 01 00 00 01 00 00 01 00 01 00 00 00 01 00 00 00 00 00 01 00 00 00 00 00 01 01 00 01 00 00 00 00 01 00 01 01 00 00 00 01 01 00 00 00 00 00 01 00 00 00 01 00 00 01 00 00 01 00 00 01 00 00 01 00 00 00 01 00 00 00 00 00 00 01 00 00 00 01 01 00 01 00 00 00 00 00 01 01 01 01 01 01 00 00 00 00 00 00 00 01 01 01 00 00 00 00 00 00 00 00 01 00 01 01 00 00 00 01 01 00 00 00 00 00 01 00 00 00 01 00 00 01 00 00 01 00 00 01 00 00 01 00 00 00 01 00 00 00 00 00 01 01 00 00 00 01 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 01 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 01 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 00 01 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 01 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 01 01 01 01 00 01 01 00 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 01 00 00 00 00 01 00 00 00 01 00 00 01 00 00 00 01 00 00 01 00 00 00 00 01 00 00 00 00 00 00 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 01 00 00 00 00 00 00 00 01 00 00 00 00 01 00 00 01 00 00 00 01 00 00 01 00 00 00 01 00 00 00 00 01 00 00 00 00 00 00 00 01 01 00 01 00 00 00 00 00 00 01 01 00 01 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 01 00 01 01 00 00 00 00 00 00 00 01 00 01 01 01 00 00 00 01 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 01 00 00 00 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 01 01 00 00 00 01 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 01 00 00 00 01 01 01 00 01 00 00 00 00 00 00 00 00 00 01 00 01 01 01 00 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 00 01 01 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 01 01 00 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 00 01 01 01 00 01 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 00 00 00 00 00 01 00 00 00 00 00 01 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 00 00 01 00 00 00 00 00 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 00 00 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 00 00 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 00 00 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 00 00 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 01 00 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 01 00 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 01 00 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 01 00 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 01 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 01 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 01 01 01 01 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 01 01 01 01 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 01 01 01 01 00 00 01 00 00 00 00 00 01 00 00 00 00 00 01 00 00 01 01 01 01 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 01 01 01 01 00 00 01 00 00 00 00 00 01 00 00 00 00 00 01 00 00 01 01 01 01 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 01 01 01 01 01 01 00 00 00 00 01 00 00 00 00 01 01 01 01 01 01 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 01 01 01 01 01 01 00 00 00 00 01 00 00 00 00 01 01 01 01 01 01 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 00 00 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 00 01 00 01 01 01 01 01 01 01 01 01 00 01 00 00 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 00 01 00 01 01 01 01 01 01 01 01 01 00 01 00 00 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 00 01 00 01 00 01 00 01 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 00 01 00 01 00 01 00 01 00 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ] &end
+0, -217
  1@@ -1,217 +0,0 @@
  2-( Screen:
  3-	Draws a table of all possible sprite arrangements. )
  4-
  5-|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
  6-|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
  7-|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1
  8-
  9-|0000
 10-
 11-	@center &x $2 &y $2
 12-
 13-|0100 ( -> )
 14-
 15-	( vector )
 16-	;on-frame .Screen/vector DEO2
 17-	( theme )
 18-	#f07f .System/r DEO2
 19-	#f0e0 .System/g DEO2
 20-	#f0c0 .System/b DEO2
 21-	( gba screen size 00f0 x 00a0 )
 22-	( nds screen size 0100 x 00c0 )
 23-	#0100 .Screen/width DEO2
 24-	#00b0 .Screen/height DEO2
 25-	( find screen center )
 26-	.Screen/width DEI2 #01 SFT2 .center/x STZ2
 27-	.Screen/height DEI2 #01 SFT2 .center/y STZ2
 28-	( draw )
 29-	draw-size
 30-	draw-sprites
 31-	draw-1bpp
 32-	draw-2bpp
 33-
 34-BRK
 35-
 36-(
 37-@|vectors )
 38-
 39-@on-frame ( -> )
 40-
 41-	( scroll background )
 42-	[ LIT2 &f $2 ] INC2k ,&f STR2
 43-		#01 SFT2
 44-		#001f AND2
 45-		#0040 SUB2
 46-			DUP2 .Screen/x DEO2
 47-			.Screen/y DEO2
 48-	;patt-icn draw-fill
 49-
 50-	.center/x LDZ2 #0070 SUB2 .Screen/x DEO2
 51-	.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
 52-	;anim-chr ,&f LDR2 #00ff AND2 #02 SFT #07 AND #40 SFT ADD2 .Screen/addr DEO2
 53-	#8f .Screen/sprite DEO
 54-
 55-	draw-size
 56-	draw-sprites
 57-	draw-1bpp
 58-	draw-2bpp
 59-
 60-BRK
 61-
 62-(
 63-@|drawing )
 64-
 65-@draw-sprites ( -- )
 66-
 67-	( horizontal )
 68-	.center/x LDZ2 #0060 SUB2 .Screen/x DEO2
 69-	.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
 70-	;font-icn .Screen/addr DEO2
 71-	#f6 .Screen/auto DEO
 72-	#05 .Screen/sprite DEO
 73-	( vertical )
 74-	.center/x LDZ2 #0070 SUB2 .Screen/x DEO2
 75-	.center/y LDZ2 #0038 SUB2 .Screen/y DEO2
 76-	;font-icn .Screen/addr DEO2
 77-	#f5 .Screen/auto DEO
 78-	#05 .Screen/sprite DEO
 79-	( table )
 80-	#00 .Screen/auto DEO
 81-	;preview-chr .Screen/addr DEO2
 82-	#00
 83-	&loop
 84-		( move ) #00 OVR #0f AND #30 SFT
 85-			.center/x LDZ2 #0060 SUB2 ADD2 .Screen/x DEO2
 86-		( move ) #00 OVR #f0 AND #01 SFT
 87-			.center/y LDZ2 #0038 SUB2 ADD2 .Screen/y DEO2
 88-		( draw ) DUP .Screen/sprite DEO
 89-		INC DUP ?&loop
 90-	POP
 91-
 92-JMP2r
 93-
 94-@draw-1bpp ( -- )
 95-
 96-	#1000
 97-	&loop
 98-		( color ) STHk
 99-		( y ) #00 OVR #42 SFT2
100-			.center/y LDZ2 #0038 SUB2 ADD2 STH2
101-		( x ) #00 OVR #03 AND #40 SFT2 #0040 ADD2
102-			.center/x LDZ2 #0010 SUB2 ADD2
103-		STH2r STHr #00 draw-circle
104-		INC GTHk ?&loop
105-	POP2
106-
107-JMP2r
108-
109-@draw-2bpp ( -- )
110-
111-	#1000
112-	&loop
113-		( color ) STHk
114-		( y ) #00 OVR #42 SFT2
115-			.center/y LDZ2 #0008 ADD2 ADD2 STH2
116-		( x ) #00 OVR #03 AND #40 SFT2 #0040 ADD2
117-			.center/x LDZ2 #0010 SUB2 ADD2
118-		STH2r STHr #80 draw-circle
119-		INC GTHk ?&loop
120-	POP2
121-
122-JMP2r
123-
124-@draw-circle ( x* y* color depth -- )
125-
126-	ADD STH
127-	;preview-chr .Screen/addr DEO2
128-	.Screen/y DEO2
129-	.Screen/x DEO2
130-	#01 .Screen/auto DEO
131-	STHr .Screen/sprite DEOk
132-	#02 .Screen/auto DEO
133-	SWP #10 ADD SWP DEOk
134-	.Screen/x DEI2k #0008 SUB2 ROT DEO2
135-	#01 .Screen/auto DEO
136-	SWP #10 ADD SWP DEOk
137-	SWP #10 ADD SWP DEO
138-
139-JMP2r
140-
141-@draw-fill ( patt* color -- )
142-
143-	.Screen/addr DEO2
144-	[ LIT2 01 -Screen/auto ] DEO
145-	.Screen/x DEI2 ,&anchor STR2
146-	.Screen/width DEI2 #03 SFT2 NIP #08 ADD ,&x STR
147-	.Screen/height DEI2 #03 SFT2 NIP #08 ADD #00
148-	&h
149-		DUP #02 SFT STH
150-		[ LIT &x $1 ] #00
151-		&w
152-			DUP #02 SFT STHkr ADD #01 AND .Screen/sprite DEO
153-			INC GTHk ?&w
154-			.Screen/y DEI2k #0008 ADD2 ROT DEO2
155-			[ LIT2 &anchor $2 ] .Screen/x DEO2
156-		POP2 POPr
157-		INC GTHk ?&h
158-	POP2
159-
160-JMP2r
161-
162-@draw-size ( -- )
163-
164-	#01 .Screen/auto DEO
165-	.center/x LDZ2 #0030 ADD2 .Screen/x DEO2
166-	.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
167-	.Screen/width DEI2 draw-dec
168-	;x-icn .Screen/addr DEO2
169-	#01 .Screen/sprite DEO
170-	.Screen/height DEI2
171-
172-@draw-dec ( short* -- )
173-
174-	#00 ,&z STR
175-	#2710 draw-dec/parse
176-	#03e8 draw-dec/parse
177-	#0064 draw-dec/parse
178-	#000a draw-dec/parse
179-	NIP
180-	&emit
181-		DUP [ LIT &z $1 ] EQU ?&skip
182-			#ff ,&z STR #00 OVR #30 SFT ;font-icn ADD2 .Screen/addr DEO2
183-			#01 .Screen/sprite DEO
184-			&skip
185-	POP
186-
187-JMP2r
188-	&parse DIV2k DUP ,&emit JSR MUL2 SUB2 JMP2r
189-
190-(
191-@|assets )
192-
193-@patt-icn [
194-	aa55 aa55 aa55 aa55 ]
195-@x-icn [
196-	0000 0018 1800 0000 ]
197-@preview-chr [
198-	0f38 675f dfbf bfbf 0007 1820 2344 4848 ]
199-@font-icn ( 0-f ) [
200-	007c 8282 8282 827c 0030 1010 1010 1010
201-	007c 8202 7c80 80fe 007c 8202 1c02 827c
202-	000c 1424 4484 fe04 00fe 8080 7c02 827c
203-	007c 8280 fc82 827c 007c 8202 1e02 0202
204-	007c 8282 7c82 827c 007c 8282 7e02 827c
205-	007c 8202 7e82 827e 00fc 8282 fc82 82fc
206-	007c 8280 8080 827c 00fc 8282 8282 82fc
207-	007c 8280 f080 827c 007c 8280 f080 8080 [
208-@anim-chr [
209-	0000 0018 1800 0000 c381 0000 0000 81c3 
210-	0000 183c 3c18 0000 0000 0000 0000 0000
211-	0018 3c7e 7e3c 1800 0000 0000 0000 0000 
212-	3c7e ffe7 e7ff 7e3c 0000 0018 1800 0000
213-	ffff e7c3 c3e7 ffff 0000 183c 3c18 0000 
214-	ffe7 c381 81c3 e7ff 0018 3c7e 7e3c 1800
215-	c381 0000 0000 81c3 3c7e ffe7 e7ff 7e3c 
216-	0000 0000 0000 0000 ffff e7c3 c3e7 ffff
217-	0000 0000 0000 0000 ffe7 c381 81c3 e7ff ]
218-
+0, -158
  1@@ -1,158 +0,0 @@
  2-( 54K . System Device Tests )
  3-
  4-|00 @System/vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
  5-|10 @Console/vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
  6-|0050 @Varvara/version
  7-
  8-|100
  9-
 10-@on-reset ( -> )
 11-	;meta #06 DEO2
 12-	( | Halt recover )
 13-	[ LIT2 80 -System/state ] DEO
 14-	[ LIT2 01 -System/state ] DEO
 15-	[ LIT2 00 -System/state ] DEO
 16-	( | )
 17-	#800f DEO
 18-	system/test-wst ;dict/wst ROT <test>
 19-	system/test-rst ;dict/rst ROT <test>
 20-	;dict/cpyl system/test-copyl <test>
 21-	;dict/cpyr system/test-copyr <test>
 22-	;dict/cpyl2 system/test-copyl2 <test>
 23-	;dict/fill system/test-fill <test>
 24-	BRK
 25-	( | boundary check )
 26-	;mmu-over .System/expansion DEO2
 27-	;dict/over #0000 LDA #ffff LDA #8888 EQU2 <test>
 28-	BRK
 29-
 30-@meta 00
 31-	( name ) "System 20 "Device 20 "Test(80K) 0a
 32-	( details ) "Testing 20 "Program 0a
 33-	( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
 34-	( date ) "24 20 "Jun 20 "2026 00
 35-	( . ) 01
 36-	( - ) 56 =Varvara/version
 37-
 38-(
 39-@|test )
 40-
 41-@system/test-wst ( -- pass )
 42-	( 1 ) #12 [ LITr -System/wst ] DEIr POP
 43-	( 2 ) #1234 [ LITr -System/wst ] DEIr POP2
 44-	( ) STH2r #0102 EQU2 JMP2r
 45-
 46-@system/test-rst ( -- pass )
 47-	( 1 ) LITr 12 .System/rst DEI POPr
 48-	( 2 ) LIT2r 1234 .System/rst DEI POP2r
 49-	( account for return addr+2 ) #0304 EQU2 JMP2r
 50-
 51-@system/test-fill ( -- pass )
 52-	;buf #0003 ADD2 ;mmu-fill/a STA2
 53-	;mmu-fill .System/expansion DEO2
 54-	;buf #0013 ;res4 mem/cmp
 55-	( | test clamp )
 56-	;mmu-fill-of .System/expansion DEO2
 57-	#fffe LDA2 LIT2 "AA EQU2 AND
 58-	( | read overflow )
 59-	;mmu-fill-mov .System/expansion DEO2
 60-	;res LDA2 #0000 EQU2 AND JMP2r
 61-
 62-@system/test-copyl ( -- pass )
 63-	;buf #0006 ADD2 ;mmu-cpyl/a STA2
 64-	;buf #0003 ADD2 ;mmu-cpyl/b STA2
 65-	;mmu-cpyl .System/expansion DEO2
 66-	;buf #0013 ;res1 mem/cmp
 67-	( | test clamp )
 68-	;mmu-cpyl-of .System/expansion DEO2
 69-	#fffe LDA2 LIT2 "BB EQU2 AND
 70-	( | read overflow )
 71-	;mmu-fill-mov .System/expansion DEO2
 72-	;res LDA2 #0000 EQU2 AND JMP2r
 73-
 74-@system/test-copyr ( -- pass )
 75-	;buf #0003 ADD2 ;mmu-cpyr/a STA2
 76-	;buf #0009 ADD2 ;mmu-cpyr/b STA2
 77-	;mmu-cpyr .System/expansion DEO2
 78-	;buf #0013 ;res2 mem/cmp
 79-	( | test clamp )
 80-	;mmu-cpyr-of .System/expansion DEO2
 81-	#fffe LDA2 LIT2 "CC EQU2 AND
 82-	( | read overflow )
 83-	;mmu-fill-mov .System/expansion DEO2
 84-	;res LDA2 #0000 EQU2 AND JMP2r
 85-
 86-@system/test-copyl2 ( -- pass )
 87-	;buf #0009 ADD2 ;mmu-cpyl/a STA2
 88-	;buf #0006 ADD2 ;mmu-cpyl/b STA2
 89-	;mmu-cpyl .System/expansion DEO2
 90-	;buf #0013 ;res3 !mem/cmp
 91-
 92-(
 93-@|Helpers )
 94-
 95-@<test> ( name* f -- )
 96-	?{
 97-		str/<print>
 98-		#010f DEO
 99-		;dict/fail !str/<print> }
100-	str/<print>
101-	;dict/pass
102-	( >> )
103-
104-@str/<print> ( str* -- )
105-	LDAk DUP ?{ POP POP2 JMP2r }
106-	.Console/write DEO
107-	INC2 !/<print>
108-
109-@mem/cmp ( a* length* b* -- t )
110-	STH2
111-	OVR2 ADD2 SWP2
112-	&>l
113-		EQU2k ?{
114-			LDAk LDAkr STHr NEQ ?{ INC2 INC2r !&>l } }
115-	POP2r EQU2 JMP2r
116-
117-@dict
118-	&wst "System/wst: 20 $1
119-	&rst "System/rst: 20 $1
120-	&cpyl "System/cpyl: 20 $1
121-	&cpyr "System/cpyr: 20 $1
122-	&cpyl2 "System/cpyl2: 20 $1
123-	&fill "System/fill: 20 $1
124-	&over "System/overflow: 20 $1
125-	&pass "pass 0a $1
126-	&fail "fail 0a $1
127-
128-@buf [ "......[hello]..... $1 ]
129-
130-@res1 [ "...[hello]lo]..... $1 ]
131-
132-@res2 [ "...[hello[hello].. $1 ]
133-
134-@res3 [ "...[he[hello]lo].. $1 ]
135-
136-@res4 [ "...-------------.. $1 ]
137-
138-@fill-b [ "BBBB 00 ]
139-
140-@fill-c [ "CCCC 00 ]
141-
142-@mmu-fill [ 00 000d 0000 &a $2 2d ]
143-
144-@mmu-fill-of [ 00 0004 0000 fffe "A ]
145-
146-@mmu-fill-mov [ 01 0002 0001 0000 =res ]
147-
148-@mmu-cpyl [ 01 0007 0000 &a $2 0000 &b $2 ]
149-
150-@mmu-cpyl-of [ 01 0004 0000 =fill-b 0000 fffe ]
151-
152-@mmu-cpyr [ 02 0007 0000 &a $2 0000 &b $2 ]
153-
154-@mmu-cpyr-of [ 02 0004 0000 =fill-c 0000 fffe ]
155-
156-@mmu-over [ 00 0002 0000 ffff 88 ]
157-
158-@res $2
159-
+0, -195
  1@@ -1,195 +0,0 @@
  2-a001 2e80 0637 6001 eb20 0009 a004 1260
  3-0b3f 600b 6260 00b8 2000 12a0 018b 8010
  4-3780 1716 2000 06a0 0170 600b 2400 0044
  5-7269 6662 6c69 6d0a 5578 6e74 616c 2835
  6-344b 2920 4173 7365 6d62 6c65 720a 4279
  7-2044 6576 696e 6520 4c75 204c 696e 7665
  8-6761 0a32 3620 4175 6720 3230 3236 0a0a
  9-5573 6167 653a 2069 6e2e 7461 6c20 6f75
 10-742e 726f 6d0a 0001 5600 5080 1216 6000
 11-13a0 0417 1609 2000 0a60 0ae0 2000 04a0
 12-800f 1700 0680 210b 2000 04a0 0211 2c02
 13-a000 0008 0680 fa13 2000 0ca0 0211 80eb
 14-3360 00c6 4000 38a0 0231 80df 3340 0058
 15-a001 f580 b837 a000 0180 ba37 c000 a001
 16-ed80 bc37 80b3 1620 0002 4f6c 8000 60ff
 17-b341 40ff e92e 6472 6966 626c 696d 00a0
 18-0010 13a0 0000 116c 60ff f4a0 0211 4009
 19-41a0 0000 0680 3f09 2000 0722 a000 0040
 20-01c7 8180 ed13 316c a040 0713 a000 4011
 21-6ca0 0040 0680 7f09 2000 0722 a000 4040
 22-01a7 8180 ed13 316c a002 3140 0904 a00d
 23-26a0 07bd 35a0 0000 a007 b535 6ca0 0e26
 24-a005 2235 a000 00a0 0e26 356c a01e 26a0
 25-09f6 35a0 0000 a01e 2635 6ca0 4e26 a008
 26-b335 a000 00a0 4e26 356c 6000 2d60 ffdc
 27-60ff e860 ffb8 60ff c460 01de 6001 8ea0
 28-0000 6000 f460 09d4 2000 0a60 0185 6009
 29-cb20 0001 6ca0 010f 176c a002 cd80 0237
 30-a000 ffa0 0b2d 35a0 0100 4008 8100 ff00
 31-0001 0000 0080 1633 a002 e980 0237 8000
 32-6c00 0001 0001 0000 0001 0001 0001 0000
 33-0000 02df 80d6 06a0 dead af60 0008 ef60
 34-ffd3 0880 006f 80dd 3380 dc13 a002 e180
 35-0237 6ca0 0c7f 6009 30a0 0040 6009 32a0
 36-0c89 6009 2ca0 0b2d 3426 a000 ff39 6009
 37-2621 a00c 8e60 0919 a000 4080 a837 a000
 38-0180 aa37 a000 ff40 0011 2126 809f 33a0
 39-02e9 8002 37a0 02df 80ae 37a9 20ff eb22
 40-22a0 040d 60fe e1a0 0040 80a8 37a0 08b3
 41-34a0 4e26 a000 0280 aa37 2680 ae37 a000
 42-0338 9480 0004 af80 aa37 2126 80ae 376f
 43-38aa 20ff df22 226c 2126 a000 0028 2000
 44-0426 60fe 6380 a837 a000 0126 80aa 37a0
 45-0588 35a0 03bb 80a4 37a0 2100 0920 0006
 46-a000 0060 0023 6001 a260 08b0 2000 19a0
 47-03e1 80ac 3780 a316 2000 0580 0a40 0194
 48-8000 6001 8f40 ffe1 6c60 088b a004 0760
 49-085f a00c f960 0859 a00c a060 0853 6008
 50-5080 0a80 1917 6c50 6174 6820 002e 7379
 51-6d00 4552 524f 523a 2062 616e 6b20 3120
 52-756e 7375 7070 6f72 7465 640a 00a0 0d22
 53-4001 8d80 4132 a004 b029 2000 09a0 0d1d
 54-a00c e060 07d1 802e 32a0 04ef 2920 0009
 55-a00d 1da0 0cce 6007 be60 0820 2000 0c60
 56-05e2 6008 1720 0003 4004 d86c 8008 336c
 57-9020 0002 226c a004 802c a004 8040 ffec
 58-6007 2a20 065b 6002 4c20 0640 9060 0163
 59-a11d 2000 0d22 6000 a2a1 1d20 00c0 2240
 60-01d0 2134 2c22 a001 0913 a004 b040 ffbc
 61-3426 c000 a028 0028 0f58 a029 0028 0f59
 62-cfc0 ef53 2000 0340 ffb0 6c60 033a 6000
 63-4a80 0060 004b a004 dc40 ff90 34a0 7b00
 64-2920 000a a001 0a13 a004 ef40 ff7e 6cb4
 65-26c0 0080 7b08 0480 7b08 1d0f 58a0 7d00
 66-280f 59cf c0eb 5320 0009 2280 0060 0011
 67-40ff 6760 0005 8020 4000 06a0 0521 4006
 68-31a0 0e26 a126 a01e 262b 2000 09a0 0cf0
 69-a00c c760 06e1 80e9 3315 6c60 0307 af80
 70-e032 a00e 2626 ef60 067b 2000 0e60 066f
 71-6006 6caa 20ff ee22 a0ff ff23 626c 2360
 72-0009 6006 5aa0 0574 4005 e7a0 c024 13a0
 73-00c0 116c 0680 200a 2000 16a0 00c0 60fe
 74-ef80 0a09 20ff e4a0 0001 2180 fa33 40ff
 75-daa0 00c0 8106 80ff 0b20 0009 a00c f0a0
 76-0cd4 6006 7280 eb13 316c a000 8081 0680
 77-bf0b 2000 06a0 0cf0 6006 5980 ee13 316c
 78-26a0 80e7 1394 802f 0820 0009 9460 ffda
 79-2194 20ff f022 80d3 1280 0513 4002 7c21
 80-a000 c813 802f 60ff c1a0 0080 24a0 05aa
 81-4005 5f0f a006 9594 cf08 2000 0ca0 0003
 82-3894 20ff f222 a0ff ff42 6c22 6c22 4001
 83-d040 fe91 6000 6c40 feb1 6000 6660 0305
 84-4005 2b60 005d 6002 fc40 051e 6000 5440
 85-ff8e 60ff aa40 0223 8080 6004 df60 0043
 86-6003 da40 04d6 8080 6004 d160 0035 6003
 87-be40 04c8 80a0 6004 c360 0027 6003 b840
 88-04b6 6000 1e80 2040 04a8 6000 1680 4040
 89-04a0 8060 4004 9b60 0009 4004 5560 0003
 90-4004 4321 9480 200a 2000 09a0 0cf9 a00c
 91-d440 0583 6c7c 061a 2406 2340 062c 2606
 92-322c 0638 5f06 3d2e 0646 2d06 4b3b 0654
 93-3d06 5921 066a 3f06 6223 0677 2206 7d7d
 94-060d 7e03 9828 0611 2906 0b5b 060b 5d06
 95-0b25 0614 0026 6000 0e80 0009 0f26 a007
 96-af60 04e1 4f1d 6ce0 1f00 a007 4fa4 a000
 97-0324 6004 d920 000f 41a0 0003 3894 20ff
 98-ec22 2262 8000 6c22 5cb4 a04c 4928 8070
 99-1f0f 5da0 0003 3894 8021 0b20 002e 9480
100-3209 2000 05c0 2040 001d 9480 7209 2000
101-05c0 4040 0011 9480 6b09 2000 05c0 8040
102-0005 2242 8000 6c5d 2140 ffcb 224f 6c4c
103-4954 494e 4350 4f50 4e49 5053 5750 524f
104-5444 5550 4f56 5245 5155 4e45 5147 5448
105-4c54 484a 4d50 4a43 4e4a 5352 5354 484c
106-445a 5354 5a4c 4452 5354 524c 4441 5354
107-4144 4549 4445 4f41 4444 5355 424d 554c
108-4449 5641 4e44 4f52 4145 4f52 5346 5442
109-524b 0022 a000 00a1 80fa 3326 a00d 26a1
110-2180 f933 3560 000e 0560 000a 8034 3380
111-3333 a008 016c 0680 041f 6003 8504 4003
112-8180 d932 26a0 0d26 2920 0006 a00c f960
113-0422 a000 0239 b460 ffcb 6000 5e80 bd33
114-6cce bb2e 2e2e 2e00 6003 a220 0025 9480
115-7b08 2000 1e94 60fd da21 1d20 0015 60fd
116-1a21 1d20 0016 6000 a321 1d20 000e 60fe
117-a40c 6ca0 0cf9 a00c d440 03db a00d 01a0
118-0cd4 4003 d294 807b 0820 ff67 9480 2f08
119-20fd 8c94 8026 0820 fd85 6c60 006e a11d
120-2000 1022 a008 b334 6002 4780 0260 02d6
121-4000 1a23 2660 023a 6001 2a20 0008 6002
122-c527 3540 0130 22a0 0d01 4003 8704 6000
123-2160 001e 6000 1be0 08b3 f480 0060 0012
124-60ff 65a0 08b2 6002 a964 7467 7964 5542
125-8000 a04e 26a1 26a0 9626 2b20 0009 a00c
126-f0a0 0cb8 6003 5080 e933 156c 2680 1c33
127-6002 d101 0f80 db32 a04e 26a8 2000 2326
128-a000 0338 94cf 0920 000a a1a0 0000 6002
129-d420 0015 22a0 0003 3894 8000 0401 3840
130-ffd9 2222 a0ff ff42 6c22 2342 6c60 ffbc
131-a11d 2000 0e22 a008 b334 2480 01a0 ffff
132-40ff 6a23 6c60 0285 2002 6460 ff17 60ff
133-9b60 0069 2000 06a0 0cf9 6002 d760 006c
134-3423 6ca0 08b3 34a0 4e26 a121 1480 011c
135-2000 27b4 a001 0028 2000 1f26 a000 0438
136-9480 4119 801a 0b20 000f a00c 9760 02e1
137-2660 02dd 800a 60fa 8a22 a000 0338 9480
138-0004 0138 aa20 ffc2 2222 40f9 8626 a000
139-8038 0220 0001 6ca0 0d0b 4002 77a1 1d20
140-0003 8000 6ca1 2114 8002 1c6c a121 af14
141-8001 1d6f 156c 2121 af14 8002 1d6f 156c
142-8017 3360 fe7f 60ff 4460 ffd9 2000 1d26
143-6001 7360 001b 6000 18a0 0000 6000 12a0
144-0000 6000 0ca0 0588 3460 0005 60ff bd34
145-6c04 6000 00a0 1e26 a126 a04e 262b 2000
146-09a0 0cf0 a00c a360 020d 80e9 3315 6ca0
147-0a79 60ff ab03 6ca0 0a81 40ff a3a0 0a88
148-60ff 9da1 1d20 0004 2280 006c 6001 1760
149-000e 60ff 5803 6ca0 0a97 60ff 8360 0106
150-2121 396c 80af 32a0 1e26 a820 0013 26a0
151-0bf5 35a6 a000 0438 342e a000 0a38 40ff
152-e922 226c b460 00e6 a121 3460 ff2f 2000
153-06a0 0cf9 4001 6e34 6c60 ffe8 2303 4000
154-9b60 ffe0 2340 0090 60ff d924 3460 ffb0
155-6000 0f03 4000 8560 ffca 2434 60ff a140
156-0076 26a0 0080 3802 2000 016c a00d 0b40
157-0133 26a0 0003 3834 a0ce bb29 2000 0222
158-6ca0 09e0 356c a00b 1c40 0086 60fc 1840
159-004a 6000 cf80 0209 8050 1f80 801d 6000
160-3b60 00c9 8000 0820 001e 6000 b706 8002
161-0920 0008 0260 0097 0340 0020 8004 0920
162-0006 6000 8a40 0010 22a0 0cf9 a00c d940
163-0105 6000 0760 ff1f 0460 0000 8fa0 0100
164-a180 fa33 4f80 0008 2000 0c26 a000 ff2b
165-2000 0426 80f6 3307 20f7 cb22 02a0 0d13
166-a00c e840 00d1 80d5 326c 60ff f938 80cd
167-336c 2f94 0620 0004 0222 626c ef2e 2140
168-fff1 800f 1c80 0a8b 2000 0519 8061 186c
169-0280 3018 6c94 8030 1906 8009 0a0c 6c80
170-2719 0680 0a19 8005 0a0c 6c02 80ff 6ce0
171-0000 c040 7f60 ffdd c000 0f78 2194 20ff
172-f122 6f6c a660 0017 2421 3903 6c26 60ff
173-c401 2000 0514 8000 086c 2140 fff0 2194
174-20ff fb21 6c2f 2660 fff5 2440 0009 2f27
175-3824 4000 0221 61a8 2000 0794 d44f 0820
176-fff3 6228 6ca0 0cae 6000 5e60 0063 a00c
177-a060 005d a000 00a1 2134 a000 0438 6000
178-5026 a000 0838 3424 a000 0638 34a0 0004
179-3840 001c a00c c060 002f 6000 34a0 0ca0
180-6000 2ea0 00c0 6000 28a0 0588 34a0 0080
181-a00c 8960 001b 6000 1880 3a60 f7c5 6000
182-1660 0033 800a 40f7 ba60 0005 8020 40f7
183-b2a0 0403 40fe fbe0 ff00 a000 0abb af3a
184-396f 419d 20ff f322 0380 3018 60f7 9447
185-58cf 20ff f362 6ca0 0102 136c 8000 6c41
186-7373 656d 626c 6564 0020 696e 2000 2062
187-7974 6573 2e0a 002d 2d20 556e 7573 6564
188-3a20 0052 6566 6572 656e 6365 7300 5265
189-6665 7265 6e63 6500 5379 6d62 6f6c 7300
190-5379 6d62 6f6c 004d 6163 726f 7300 4d61
191-6372 6f00 4e61 6d65 004e 756d 6265 7200
192-436f 6d6d 656e 7400 5772 6974 696e 6700
193-6578 6365 6564 6564 0069 6e76 616c 6964
194-0064 7570 6c69 6361 7465 0074 6f6f 2066
195-6172 007a 6572 6f2d 7061 6765 006f 7065
196-6e00 546f 7000 
+0, -1918
   1@@ -1,1918 +0,0 @@
   2-( 54K . M/PC )
   3-
   4-|00 @System/vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
   5-|10 @Console/vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
   6-|20 @Screen/vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
   7-|80 @Controller/vector $2 &button $1 &key $1
   8-|90 @Mouse/vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1
   9-|a0 @File/vector $2 &success $1 &success-lb $1 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
  10-|b0 @File2/vector $2 &success $1 &success-lb $1 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
  11-|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
  12-
  13-(
  14-@|Enums )
  15-
  16-|0050 @Varvara/version
  17-|00fd @loader/entry
  18-|0100 @loader/pagelen
  19-|0080 @path/buflen
  20-|0200 @bios/buflen
  21-|0800 @dir/buflen
  22-|0120 @meta/buflen
  23-|ff00 @dict/cap
  24-|0008 @bios/anchor-x
  25-|0028 @bios/anchor-y
  26-
  27-|000
  28-
  29-	@input/buf $80
  30-	@loader/buf
  31-
  32-|100
  33-
  34-@on-reset ( -> )
  35-	;meta #06 DEO2
  36-	theme/<load>
  37-	;dict/home-path path/<set>
  38-	window/<update>
  39-	window/<draw-spacer>
  40-	input/<bind>
  41-	bios/<welcome>
  42-	.Console/type DEI ?{ project/<load>
  43-		BRK }
  44-	loader/<set-instant>
  45-	BRK
  46-
  47-@meta 00
  48-	( name ) "M/PC 0a
  49-	( details ) "Monitor/Program 20 "Control 0a
  50-	( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
  51-	( date ) "15 20 "Aug 20 "2026 00
  52-	( . ) 03
  53-	( - ) 56 =Varvara/version
  54-	( - ) 83 =appicon
  55-	( - ) a0 =manifest/dat
  56-
  57-@manifest/dat ( . )
  58-	_{ =dict/m_pc
  59-	( ) 10 00 =scroll/<up> =dict/scroll-up
  60-	( ) 20 00 =scroll/<down> =dict/scroll-down
  61-	( ) 40 00 =sel/<prev> =dict/sel-prev
  62-	( ) 80 00 =sel/<next> =dict/sel-next
  63-	( ) 01 00 =sel/<use> =dict/sel-pick
  64-	( ) 02 00 =bios/<dir> =dict/directory }
  65-	_{ =dict/input
  66-	( ) 00 0d =input/<eval> =dict/eval
  67-	( ) 04 0d =input/<eval-partial> =dict/eval-partial
  68-	( ) 00 1b =input/<blank> =dict/clear }
  69-	00
  70-
  71-%Screen/<set-pos> ( x* y* -- ) {
  72-	.Screen/y DEO2
  73-	.Screen/x DEO2 }
  74-
  75-(
  76-@|Project )
  77-
  78-@project/<load> ( -- )
  79-	;&path .File2/name DEO2
  80-	#0001 .File2/length DEO2
  81-	&>w
  82-		;&c .File2/read DEO2
  83-		.File2/success-lb DEI ?{ JMP2r }
  84-		[ LIT &c $1 ] input/<handle-input> !/>w
  85-
  86-	&path ".m_pc 00
  87-
  88-(
  89-@|Input )
  90-
  91-@input/on-controller ( -> )
  92-	.Controller/button DEI2 DUP2 manifest/scan INC2k ORA ?{
  93-		POP2
  94-		( key ) /<handle-input>
  95-		( button ) POP BRK }
  96-	( * ) JSR2 POP2 BRK
  97-
  98-@input/on-console ( -> )
  99-	.Console/read DEI
 100-	( | mute arg spacers )
 101-	[ LIT2 03 -Console/type ] DEI NEQ ?{ POP #20 }
 102-	DUP LIT "\ NEQ ?{
 103-		POP ;&on-console-escape .Console/vector DEO2
 104-		BRK }
 105-	/<handle-input>
 106-	BRK
 107-
 108-@input/on-console-escape ( -> )
 109-	.Console/read ] DEI DUP #0a EQU ?{
 110-		LIT "\ /<handle-input>
 111-		DUP /<handle-input> }
 112-	;&on-console .Console/vector DEO2
 113-	BRK
 114-
 115-@input/<bind> ( -- )
 116-	;&on-controller .Controller/vector DEO2
 117-	;&on-console .Console/vector DEO2 !/<redraw>
 118-
 119-@input/<handle-input> ( c -- )
 120-	DUP ?{ POP JMP2r }
 121-	DUP #08 EQU ?/on-bs
 122-	DUP #09 EQU ?/on-tab
 123-	DUP #0a EQU ?/on-enter
 124-	DUP #7f EQU ?/on-del
 125-	DUP #20 GTH ?{ POP #20 }
 126-	sel/<reset-draw>
 127-	/<push>
 128-	autocomplete/<update> !/<redraw>
 129-
 130-	&on-bs ( c -- )
 131-	POP /<pop>
 132-	autocomplete/<reset> !/<redraw>
 133-
 134-	&on-tab ( c -- )
 135-	POP autocomplete/get INC2k ORA ?{ POP2 JMP2r }
 136-	/<push-str> !/<redraw>
 137-
 138-	&on-enter ( c -- )
 139-	POP autocomplete/<reset> !/<eval>
 140-
 141-	&on-del ( c -- )
 142-	POP !/<blank>
 143-
 144-@input/is-active ( -- t )
 145-	[ LIT2 -&buf _&+ptr ] LDR NEQ JMP2r
 146-
 147-@input/get-length ( -- length* )
 148-	[ LIT2 00 _&+ptr ] LDR .&buf SUB JMP2r
 149-
 150-@input/<reset> ( -- )
 151-	#0000 .&buf STZ2
 152-	[ LIT2 -&buf _&+ptr ] STR !autocomplete/<reset>
 153-
 154-@input/<push-str-quoted> ( str* -- )
 155-	DUP2 str/is-word ?/<push-str>
 156-	LIT "" /<push>
 157-	/<push-str>
 158-	LIT "" !/<push>
 159-
 160-@input/<push-str> ( str* -- )
 161-	&>w
 162-		LDAk DUP ?{ POP POP2 !/<redraw> }
 163-		str/escape /<push>
 164-		INC2 !/>w
 165-
 166-@input/<push> ( c -- )
 167-	[ LIT2 00 &+ptr -&buf ] INCk ,&+ptr STR
 168-	STZ2
 169-	JMP2r
 170-
 171-@input/<pop> ( -- )
 172-	,&+ptr LDR
 173-	( cap ) DUP .&buf NEQ ?{ POP JMP2r }
 174-	#01 SUB #00 OVR STZ
 175-	,&+ptr STR
 176-	JMP2r
 177-
 178-@input/<eval-partial> ( -- )
 179-	;&buf LDAk ?{ POP2 !bios/<welcome> }
 180-	bios/<parse-partial> !/<reset-draw>
 181-
 182-@input/<eval> ( -- )
 183-	sel/is-active ?sel/<pick>
 184-	( >> )
 185-
 186-@input/<eval-force> ( -- )
 187-	;&buf LDAk ?{ POP2 !bios/<welcome> }
 188-	bios/<parse> !/<reset-draw>
 189-
 190-@input/<blank> ( -- )
 191-	sel/is-active ?sel/<reset-draw>
 192-	bios/<redraw>
 193-	( >> )
 194-
 195-@input/<reset-draw> ( -- )
 196-	/<reset>
 197-	( >> )
 198-
 199-@input/<redraw> ( -- )
 200-	;bios/anchor-x #0018 Screen/<set-pos>
 201-	[ LIT2 e0 -Screen/pixel ] DEO
 202-	#0008 .Screen/y DEO2
 203-	path/<draw>
 204-	/get-origin #45 font/<draw-str-color>
 205-	autocomplete/<draw>
 206-	;&caret !font/<draw-sprite>
 207-
 208-@input/get-origin ( -- buf* )
 209-	/get-length window/get-margin #03 SFT2 #0002 SUB2 LTH2k ?{
 210-		( follow cursor ) SUB2 ;&buf ADD2 JMP2r }
 211-	POP2 POP2 ;&buf JMP2r
 212-
 213-@autocomplete/get ( -- str* )
 214-	,&addr LDR2 INC2k ORA ?{ JMP2r }
 215-	;input/buf str/len ADD2 JMP2r
 216-
 217-@autocomplete/<reset> ( -- )
 218-	#ffff ,&addr STR2
 219-	JMP2r
 220-
 221-@autocomplete/<update> ( -- )
 222-	;input/buf bios/find-seg INC2k ORA ?{ POP2 !/<reset> }
 223-	LDA2 ,&addr STR2
 224-	JMP2r
 225-
 226-@autocomplete/<draw> ( -- )
 227-	[ LIT2 &addr $2 ] INC2k ORA ?{ POP2 JMP2r }
 228-	input/get-length ADD2 #43 !font/<draw-str-color>
 229-
 230-(
 231-@|Bios )
 232-
 233-@bios/<parse> ( str* -- )
 234-	/<reset>
 235-	dict/<reset>
 236-	( >> )
 237-
 238-@bios/<parse-partial> ( str* -- )
 239-	sel/<reset>
 240-	str/walk-ws banner/<request>
 241-	&>w
 242-		/parse-symbol str/walk-ws LDAk ?/>w
 243-	POP2 reader/is-bound ?{ !/<redraw> }
 244-	JMP2r
 245-
 246-@bios/parse-symbol ( addr* -- next* )
 247-	LDAk LIT "~ EQU ?/parse-include
 248-	dict/alloc !/<push>
 249-
 250-@bios/parse-include ( addr* -- next* )
 251-	INC2 dict/alloc path/make dir/load-temp !/<parse-partial>
 252-
 253-@bios/<welcome> ( -- )
 254-	/<reset>
 255-	banner/<request>
 256-	now/<eval>
 257-	;dict/ready2 /<push> !/<redraw>
 258-
 259-@bios/<dir> ( -- )
 260-	sel/is-active ?sel/<reset-draw>
 261-	input/is-active ?input/<reset-draw>
 262-	/<reset>
 263-	dir/<eval> !/<redraw>
 264-
 265-@bios/find-seg ( str* -- <res>* )
 266-	,&t STR2
 267-	;&+ptr LDA2 ;&buf
 268-	&>lfs
 269-		NEQ2k ?{
 270-			POP2 #ffff &end NIP2 JMP2r }
 271-		LDA2k [ LIT2 &t $2 ] str/seg ?/end
 272-		INC2 INC2 !/>lfs
 273-
 274-@bios/get-symbol ( id -- sym* )
 275-	#00 SWP DUP ADD ;&buf ADD2 LDA2 JMP2r
 276-
 277-@bios/get-depth ( -- depth* )
 278-	,&+ptr LDR2 ;&buf SUB2 #01 SFT2 JMP2r
 279-
 280-@bios/is-empty ( -- fail )
 281-	,&+ptr LDR2 ;&buf EQU2 JMP2r
 282-
 283-@bios/is-thtwo ( -- fail )
 284-	/get-depth #0002 LTH2 JMP2r
 285-
 286-@bios/is-ththree ( -- fail )
 287-	/get-depth #0003 LTH2 JMP2r
 288-
 289-@bios/<reset> ( -- )
 290-	;&buf ,&+ptr STR2 !scroll/<reset>
 291-
 292-@bios/<run> ( str* cmd* -- )
 293-	NIP2
 294-	( get cmd ) LDA2
 295-	( get eval ) INC2 INC2 LDA2
 296-	( apply ) JMP2
 297-
 298-@bios/<push-bool> ( bool -- )
 299-	?{ ;dict/f !/<push> }
 300-	;dict/t
 301-	( >> )
 302-
 303-@bios/<push> ( str* -- )
 304-	DUP2 cmds/find INC2k ORA ?/<run>
 305-	POP2
 306-	( >> )
 307-
 308-@bios/<push-raw> ( str* -- )
 309-	( | put on stack )
 310-	[ LIT2 &+ptr =&buf ]
 311-	( clamp ) DUP2 ;&cap NEQ2 ?{ POP2 POP2 JMP2r }
 312-	INC2k INC2 ,&+ptr STR2
 313-	STA2
 314-	JMP2r
 315-
 316-@bios/pop ( -- addr* )
 317-	,&+ptr LDR2 #0002 SUB2 LDA2k SWP2 ,&+ptr STR2
 318-	JMP2r
 319-
 320-@bios/<push-err-underflow> ( -- )
 321-	;dict/err-underflow !/<push>
 322-
 323-@bios/<push-err-missing> ( -- )
 324-	;dict/err-missing !/<push>
 325-
 326-@bios/<push-err-binary> ( -- )
 327-	;dict/err-binary !/<push>
 328-
 329-@bios/<redraw> ( -- )
 330-	#0000 ;&anchor-y Screen/<set-pos>
 331-	[ LIT2 c0 -Screen/pixel ] DEO
 332-	;&anchor-y .Screen/y DEO2
 333-	,&+ptr LDR2 ;&buf scroll/get STHk DUP2 ADD2 ADD2
 334-	( | Draw scroll )
 335-	scroll/<draw>
 336-	&>l
 337-		NEQ2k ?{ POP2 POP2 POPr !banner/<draw> }
 338-		LDA2k symbol/make DUP2 /<draw-spacer>
 339-		STHkr sel/is-unselected symbol/<draw>
 340-		INCr INC2 INC2 !/>l
 341-
 342-@bios/<draw-spacer> ( symbol* -- )
 343-	font/get-width .Screen/x DEI2 ADD2 window/get-margin LTH2 ?{ !font/<draw-lb> }
 344-	.Screen/x DEI2k #0008 ADD2 ROT DEO2
 345-	JMP2r
 346-
 347-@bios/<use> ( id -- )
 348-	/get-symbol
 349-	( | handlers )
 350-	DUP2 str/is-dir ?/<use-mov>
 351-	DUP2 str/is-icn ?/<use-icn>
 352-	DUP2 str/is-rom ?/<use-run>
 353-	DUP2 path/make file/is-text ?/<use-txt>
 354-	POP2 JMP2r
 355-
 356-@bios/<use-mov> ( str* -- )
 357-	input/<push-str>
 358-	;&cmd-mov !input/<push-str>
 359-
 360-	&cmd-mov 20 "mov 00
 361-
 362-@bios/<use-icn> ( str* -- )
 363-	input/<push-str>
 364-	;&cmd-icn !input/<push-str>
 365-
 366-	&cmd-icn 20 "1 20 "icn 00
 367-
 368-@bios/<use-run> ( str* -- )
 369-	input/<push-str>
 370-	;&cmd-run !input/<push-str>
 371-
 372-	&cmd-run 20 "run 00
 373-
 374-@bios/<use-txt> ( name* -- )
 375-	input/<push-str>
 376-	;&cmd-txt !input/<push-str>
 377-
 378-	&cmd-txt 20 "0 20 "txt 00
 379-
 380-@symbol/<draw> ( str* unsel -- )
 381-	?{
 382-		DUP2 str/is-dir ?/<draw-dir>
 383-		DUP2 str/is-rom ?/<draw-use>
 384-		( selected ) #49 !font/<draw-str-color> }
 385-	( unselected ) #45 !font/<draw-str-color>
 386-
 387-@symbol/<draw-dir> ( str* -- )
 388-	#4d !font/<draw-str-color>
 389-
 390-@symbol/<draw-use> ( str* -- )
 391-	#44 !font/<draw-str-color>
 392-
 393-@symbol/make ( str* -- sym* )
 394-	;&buf DUP2 ,&+ptr STR2
 395-	SWP2 [ LIT2r 1c00 ]
 396-	&>w
 397-		NEQkr STHr ?{
 398-			[ LIT2 ".. ] /<push>
 399-			/<push> !/end }
 400-		LDAk DUP ?{
 401-			POP &end POP2r POP2 #00 !/<push> }
 402-		DUP #0a NEQ ?{ POP #20 }
 403-		/<push>
 404-		INCr INC2 !/>w
 405-
 406-@symbol/<push> ( c -- )
 407-	#00 [ LIT2 &+ptr =&buf ] INC2k ,&+ptr STR2
 408-	STA2
 409-	JMP2r
 410-
 411-(
 412-@|Path )
 413-
 414-@path/<move> ( str* -- )
 415-	DUP2 ;dict/out-path str/cmp ?/<pop>
 416-	( | Check if file is a folder )
 417-	LITr _&+ptr LDR2r /<push-str>
 418-	;&buf file/is-dir ?{
 419-		#00 STH2kr STA
 420-		LITr _&+ptr STR2r
 421-		JMP2r }
 422-	POP2r
 423-	( | Add missing slash )
 424-	/is-dir ?{ LIT "/ /<push> }
 425-	JMP2r
 426-
 427-@path/is-home ( -- t )
 428-	;&buf str/len #0002 EQU2 JMP2r
 429-
 430-@path/is-dir ( -- t )
 431-	,&+ptr LDR2 #0001 SUB2 LDA LIT "/ EQU JMP2r
 432-
 433-@path/<pop> ( str* -- )
 434-	POP2
 435-	( | find last slash )
 436-	;&buf ,&+ptr LDR2 #0001 SUB2
 437-	&>lp
 438-		#0001 SUB2 LDAk LIT "/ EQU ?{ LTH2k ?/>lp }
 439-	INC2 #0000 OVR2 STA2
 440-	,&+ptr STR2
 441-	POP2 JMP2r
 442-
 443-@path/<set> ( str* -- )
 444-	;&buf ,&+ptr STR2
 445-	( >> )
 446-
 447-@path/<push-str> ( str* -- )
 448-	&>w
 449-		LDAk DUP ?{ POP POP2 JMP2r }
 450-		/<push>
 451-		INC2 !/>w
 452-
 453-@path/<push> ( str* -- )
 454-	#00 [ LIT2 &+ptr =&buf ]
 455-	( clamp ) DUP2 ;&cap NEQ2 ?{ POP2 POP POP2 JMP2r }
 456-	INC2k ,&+ptr STR2
 457-	STA2
 458-	JMP2r
 459-
 460-@path/<draw> ( -- )
 461-	;&buf #45 !font/<draw-str-color>
 462-
 463-@path/make ( str* -- path* )
 464-	;&buf !dict/alloc-cat
 465-
 466-(
 467-@|Selection )
 468-
 469-@sel/<use> ( -- )
 470-	input/is-active ?input/<eval-force>
 471-	,&id LDR INCk ?bios/<use>
 472-	POP JMP2r
 473-
 474-@sel/<prev> ( -- )
 475-	,&id LDR
 476-	( clamp ) INCk ?{ POP JMP2r }
 477-	#01 SUB #00 OVR scroll/<follow> !/<set>
 478-
 479-@sel/<next> ( -- )
 480-	,&id LDR INC
 481-	( clamp ) DUP bios/get-depth NIP LTH ?/<set>
 482-	POP JMP2r
 483-
 484-@sel/has-meta ( -- t )
 485-	,&id LDR INCk ?{ POP #00 JMP2r }
 486-	bios/get-symbol DUP2 str/is-rom ?{ POP2 #00 JMP2r }
 487-	path/make file/get-meta ORAk ?{ POP2 #00 JMP2r }
 488-	meta/<load>
 489-	#01 JMP2r
 490-
 491-@sel/is-active ( -- bool )
 492-	#ff
 493-	( >> )
 494-
 495-@sel/is-unselected ( id -- bool )
 496-	[ LIT &id ff ] NEQ JMP2r
 497-
 498-@sel/<activate> ( -- )
 499-	#00
 500-	( >> )
 501-
 502-@sel/<set> ( id -- )
 503-	DUP ,&id LDR NEQ ?{ POP JMP2r }
 504-	,&id STR !bios/<redraw>
 505-
 506-@sel/<pick> ( -- )
 507-	,&id LDR INCk ?{ POP JMP2r }
 508-	bios/get-symbol
 509-	( clamp ) DUP2 str/len #0040 LTH2 ?{ POP2 !input/<redraw> }
 510-	input/<push-str-quoted>
 511-	#20 input/<push> !input/<redraw>
 512-
 513-@sel/<reset> ( -- )
 514-	[ LIT2 ff _&id ] STR
 515-	JMP2r
 516-
 517-@sel/<reset-draw> ( -- )
 518-	scroll/<reset>
 519-	,&id LDR /<reset>
 520-	,&id LDR NEQ ?bios/<redraw>
 521-	JMP2r
 522-
 523-@sel/<follow> ( id -- )
 524-	,&id LDR GTHk ?{ POP2 JMP2r }
 525-	POP ,&id STR
 526-	JMP2r
 527-
 528-(
 529-@|Scroll )
 530-
 531-@scroll/<up> ( -- )
 532-	,&+pos LDR2
 533-	( clamp ) ORAk ?{ POP2 JMP2r }
 534-	#0001 SUB2 /<set> !bios/<redraw>
 535-
 536-@scroll/<down> ( -- )
 537-	sel/is-active ?{ !sel/<activate> }
 538-	,&+pos LDR2
 539-	( clamp ) INC2k bios/get-depth LTH2 ?{ POP2 JMP2r }
 540-	INC2 DUP sel/<follow>
 541-	/<set> !bios/<redraw>
 542-
 543-@scroll/<follow> ( id* -- )
 544-	,&+pos LDR2 LTH2k ?{ POP2 POP2 JMP2r }
 545-	POP2 !/<set>
 546-
 547-@scroll/<reset> ( -- )
 548-	#0000
 549-	( >> )
 550-
 551-@scroll/<set> ( id* -- )
 552-	,&+pos STR2
 553-	JMP2r
 554-
 555-@scroll/get ( -- id* )
 556-	,&+pos LDR2 JMP2r
 557-
 558-@scroll/<draw> ( -- )
 559-	[ LIT2 &+pos $2 ] ORAk ?{ POP2 JMP2r }
 560-	;bios/anchor-x .Screen/x DEO2
 561-	bios/get-depth SWP2 INC2 SUB2 dec/make #43 font/<draw-str-color>
 562-	#09 !font/<draw-glyph>
 563-
 564-(
 565-@|Reader )
 566-
 567-@reader/on-controller ( -> )
 568-	.Controller/button DEI
 569-	( | handlers )
 570-	DUP #01 NEQ ?{ /<leave> }
 571-	DUP #10 NEQ ?{ /<select-prev> }
 572-	DUP #20 NEQ ?{ /<select-next> }
 573-	POP .Controller/key DEI DUP ?{ POP BRK }
 574-	/<leave>
 575-	input/<handle-input>
 576-	BRK
 577-
 578-@reader/<leave> ( -- )
 579-	input/<bind> !bios/<redraw>
 580-
 581-@reader/is-bound ( -- t )
 582-	.Controller/vector DEI2 ;&on-controller EQU2 JMP2r
 583-
 584-@reader/<bind> ( str* -- )
 585-	.File/name DEO2
 586-	;&on-controller .Controller/vector DEO2
 587-	( col ) window/get-cols #0001 SUB2 ,&col STR
 588-	POP
 589-	( row ) window/get-rows #01 SFT2 #0003 SUB2 ,&row STR
 590-	POP #0000 !/<select-line>
 591-
 592-@reader/<select-prev> ( -- )
 593-	,&line LDR2 ORAk ?{ POP2 JMP2r }
 594-	#0001 SUB2 !/<select-line>
 595-
 596-@reader/<select-next> ( -- )
 597-	[ LIT2 &line $2 ] INC2
 598-	( >> )
 599-
 600-@reader/<select-line> ( line* -- )
 601-	DUP2 file/seek-line ?{ POP2 JMP2r }
 602-	;bios/anchor-x ;bios/anchor-y Screen/<set-pos>
 603-	[ LIT2 c0 -Screen/pixel ] DEO
 604-	[ LIT2 15 -Screen/auto ] DEO
 605-	#0001 .File/length DEO2
 606-	( | Draw line number )
 607-	[ LITr &col $1 ] DUP2 dec/make
 608-	( store col ) DUP2 str/len #03 ADD STH
 609-	POP #43 font/<draw-str-color>
 610-	#09 font/<draw-glyph>
 611-	#20 font/<draw-glyph>
 612-	,&line STR2
 613-	( | Render )
 614-	#41 ;font/color STA
 615-	( | Stream )
 616-	[ LIT2 &row $1 00 ]
 617-	&>s
 618-		;&b .File/read DEO2
 619-		.File/success-lb DEI ?{
 620-			POP2 POP2r ;dict/eof #44 !font/<draw-str-color> }
 621-		( | hard-wrap )
 622-		GTHkr STHr ?{
 623-			;bios/anchor-x .Screen/y DEI2 #0010 ADD2 Screen/<set-pos>
 624-			INC POPr LITr 00 }
 625-		[ LIT &b $1 ] DUP #0a NEQ ?{
 626-			SWP INC SWP POPr LITr 00 }
 627-		font/<draw-glyph>
 628-		INCr GTHk ?/>s
 629-	POP2 POP2r JMP2r
 630-
 631-(
 632-@|Commands )
 633-
 634-@cmds/find ( str* -- <cmd>* )
 635-	,&fn STR2
 636-	;&lutend ;&lut
 637-	&>l
 638-		LDA2k LDA2 [ LIT2 &fn $2 ] str/cmp ?{
 639-			INC2 INC2 GTH2k ?/>l
 640-		POP2 #ffff }
 641-	NIP2 JMP2r
 642-
 643-@cmds/lut [ =cmd/api ]
 644-	&lut-clip [4
 645-	=dir/api =mov/api =now/api =run/api
 646-	=icn/api =txt/api =len/api =put/api
 647-	=get/api =cpy/api =era/api =ren/api
 648-	=pop/api =dup/api =ovr/api =swp/api
 649-	=rot/api =dec/api =hex/api =cat/api
 650-	=add/api =sub/api =cmp/api =and/api
 651-	=ora/api =rsz/api =out/api =bye/api
 652-	&lutend ]
 653-
 654-@cmd/<eval> ( -- )
 655-	;cmds/lutend ;cmds/lut-clip
 656-	&>l
 657-		LDA2k #0004 ADD2 bios/<push-raw>
 658-		INC2 INC2 GTH2k ?/>l
 659-	POP2 POP2 JMP2r
 660-	&api =dict/cmd =&<eval> "<cmd> 20 "( 20 09 20 ") 00
 661-
 662-@dir/<eval> ( -- )
 663-	;path/buf .File/name DEO2
 664-	;&buflen .File/length DEO2
 665-	;&buf .File/read DEO2
 666-	path/is-home ?{ ;dict/out-path bios/<push-raw> }
 667-	.File/success DEI2
 668-	( | Handlers )
 669-	DUP2 /<push-folders>
 670-	DUP2 /<push-files> !/<push-dotfiles>
 671-
 672-@dir/find-wallpaper ( -- size* )
 673-	;dict/home-path .File/name DEO2
 674-	;&buflen .File/length DEO2
 675-	;&buf .File/read DEO2
 676-	/<explode>
 677-	;&buf
 678-	&>w
 679-		str/is-wallpaper ?{
 680-			str/cap INC2 LDAk ?/>w
 681-		POP2 #ffff }
 682-	JMP2r
 683-
 684-@dir/<explode> ( -- )
 685-	;&buf
 686-	&>we
 687-		LDAk DUP ?{ POP POP2 JMP2r }
 688-		#1f GTH ?{ LITr 00 STH2k STAr }
 689-		INC2 !/>we
 690-
 691-@dir/<push-folders> ( length* -- )
 692-	;&buf ADD2 ;&buf
 693-	&>lfo
 694-		LDAk LIT "- NEQ STH
 695-		#0005 ADD2 STHr ?{
 696-			LDAk LIT ". EQU ?{ dict/alloc-line bios/<push-raw> } }
 697-		str/eol INC2 GTH2k ?/>lfo
 698-	POP2 POP2 JMP2r
 699-
 700-@dir/<push-files> ( length* -- )
 701-	;&buf ADD2 ;&buf
 702-	&>lfi
 703-		LDAk LIT "- EQU STH
 704-		#0005 ADD2 STHr ?{
 705-			LDAk LIT ". EQU ?{ dict/alloc-line bios/<push-raw> } }
 706-		str/eol INC2 GTH2k ?/>lfi
 707-	POP2 POP2 JMP2r
 708-
 709-@dir/<push-dotfiles> ( length* -- )
 710-	;&buf ADD2 ;&buf
 711-	&>ldf
 712-		#0005 ADD2 LDAk LIT ". NEQ ?{ dict/alloc-line bios/<push-raw> }
 713-		str/eol INC2 GTH2k ?/>ldf
 714-	POP2 POP2 JMP2r
 715-	&api =dict/dir =&<eval> "<dir> 20 "( 20 09 20 "[f] 20 ") 00
 716-
 717-@dir/load-temp ( addr* -- buf* )
 718-	.File/name DEO2
 719-	;&buflen .File/length DEO2
 720-	;&buf DUP2 .File/read DEO2
 721-	JMP2r
 722-
 723-@mov/<eval> ( -- )
 724-	bios/is-empty ?bios/<push-err-underflow>
 725-	bios/pop path/<move> !dir/<eval>
 726-	&api =dict/mov =&<eval> "<mov> 20 "( 20 "path 20 09 20 "[f] 20 ") 00
 727-
 728-@now/<eval> ( -- )
 729-	date/make bios/<push>
 730-	time/make !bios/<push>
 731-	&api =dict/now =&<eval> "<now> 20 "( 20 09 20 "date 20 "time 20 ") 00
 732-
 733-@run/<eval> ( -- )
 734-	bios/is-empty ?bios/<push-err-underflow>
 735-	bios/pop path/make
 736-	( ? ) DUP2 file/exists ?loader/<bind>
 737-	POP2 !bios/<push-err-missing>
 738-	&api =dict/run =&<eval> "<run> 20 "( 20 "f.rom 20 09 20 "ok 20 ") 00
 739-
 740-@txt/<eval> ( -- )
 741-	bios/is-thtwo ?bios/<push-err-underflow>
 742-	( line* ) bios/pop
 743-	( path* ) bios/pop path/make
 744-	( ? ) DUP2 file/exists ?{ POP2 POP2 !bios/<push-err-missing> }
 745-	( ? ) DUP2 file/is-text ?{ POP2 POP2 !bios/<push-err-binary> }
 746-	reader/<bind>
 747-	str/dec reader/<select-line>
 748-	;dict/ok !bios/<push>
 749-	&api =dict/txt =&<eval> "<txt> 20 "( 20 "f.txt 20 "line 20 09 20 "ok 20 ") 00
 750-
 751-@icn/<eval> ( -- )
 752-	bios/is-empty ?bios/<push-err-underflow>
 753-	( color ) bios/pop str/dec NIP
 754-	( path ) bios/pop path/make
 755-	( ? ) DUP2 file/exists ?{ POP2 POP !bios/<push-err-missing> }
 756-	ROT /<draw>
 757-	;dict/ok !bios/<push>
 758-
 759-@icn/<draw> ( name* blend -- )
 760-	#0f AND ,&blend STR
 761-	DUP2 .File/name DEO2
 762-	( | depth )
 763-	#0008 .File/length DEO2
 764-	[ LIT2r &blend 03 -Screen/sprite ] ;&buf .Screen/addr DEO2
 765-	( | size )
 766-	/read-size
 767-	( h ) #00 SWP SUBk ,&height STR
 768-	( y ) #31 SFT2 window/get-middle SWP2 SUB2 .Screen/y DEO2
 769-	( w ) #00 SWP SUBk ,&width STR
 770-	( x ) #31 SFT2 window/get-center SWP2 SUB2 ,&anchor STR2
 771-	( | draw )
 772-	[ LIT2 01 -Screen/auto ] DEO
 773-	[ LIT &height $1 ]
 774-	&>v
 775-		[ LIT2 &anchor $2 ] .Screen/x DEO2
 776-		[ LIT &width $1 ]
 777-		&>h
 778-			;&buf .File/read DEO2
 779-			DEOkr
 780-			INC DUP ?/>h
 781-		POP
 782-		( lb ) .Screen/y DEI2k #0008 ADD2 ROT DEO2
 783-		INC DUP ?/>v
 784-	POP POP2r JMP2r
 785-
 786-@icn/read-size ( str* -- w h )
 787-	str/cap #0009 SUB2
 788-	( no size ) INC2k INC2 LDA [ LIT "x ] EQU ?{ POP2 #1010 JMP2r }
 789-	LDA2k str/read-byte STH
 790-	#0003 ADD2 LDA2 str/read-byte STHr SWP JMP2r
 791-	&api =dict/icn =&<eval> "<icn> 20 "( 20 "f.icn 20 "blend 20 09 20 "ok 20 ") 00
 792-
 793-@put/<eval> ( -- )
 794-	bios/is-thtwo ?bios/<push-err-underflow>
 795-	bios/pop path/make .File/name DEO2
 796-	bios/pop DUP2 str/len .File/length DEO2
 797-	.File/write DEO2
 798-	;dict/ok !bios/<push>
 799-	&api =dict/put =&<eval> "<put> 20 "( 20 "body 20 "f 20 09 20 "ok 20 ") 00
 800-
 801-@get/<eval> ( -- )
 802-	bios/is-empty ?bios/<push-err-underflow>
 803-	bios/pop path/make
 804-	( ? ) DUP2 file/exists ?{ POP2 !bios/<push-err-missing> }
 805-	( ? ) DUP2 file/is-text ?{ POP2 !bios/<push-err-binary> }
 806-	dict/alloc-file !bios/<push>
 807-	&api =dict/get =&<eval> "<get> 20 "( 20 "f 20 09 20 "body 20 ") 00
 808-
 809-@cpy/<eval> ( -- )
 810-	bios/is-thtwo ?bios/<push-err-underflow>
 811-	( dst ) bios/pop path/make
 812-	( src ) bios/pop path/make
 813-	( ? ) DUP2 file/exists ?{ POP2 POP2 !bios/<push-err-missing> }
 814-	SWP2 file/<cpy>
 815-	;dict/ok !bios/<push>
 816-	&api =dict/cpy =&<eval> "<cpy> 20 "( 20 "fsrc 20 "fdst 20 09 20 "ok 20 ") 00
 817-
 818-@era/<eval> ( -- )
 819-	bios/is-empty ?bios/<push-err-underflow>
 820-	bios/pop path/make
 821-	( ? ) DUP2 file/exists ?{ POP2 !bios/<push-err-missing> }
 822-	.File/name DEO2
 823-	[ LIT2 01 -File/delete ] DEO
 824-	;dict/ok !bios/<push>
 825-	&api =dict/era =&<eval> "<era> 20 "( 20 "f 20 09 20 "ok 20 ") 00
 826-
 827-@ren/<eval> ( -- )
 828-	bios/is-thtwo ?bios/<push-err-underflow>
 829-	( dst ) bios/pop path/make
 830-	( src ) bios/pop path/make
 831-	( ? ) DUP2 file/exists ?{ POP2 POP2 !bios/<push-err-missing> }
 832-	DUP2 ROT2 file/<cpy>
 833-	.File/name DEO2
 834-	[ LIT2 01 -File/delete ] DEO
 835-	;dict/ok !bios/<push>
 836-	&api =dict/ren =&<eval> "<ren> 20 "( 20 "fsrc 20 "fdst 20 09 20 "ok 20 ") 00
 837-
 838-@len/<eval> ( -- )
 839-	bios/is-empty ?bios/<push-err-underflow>
 840-	bios/pop path/make
 841-	( ? ) DUP2 file/exists ?{ POP2 ;dict/zero !bios/<push> }
 842-	.File/name DEO2
 843-	#0004 .File/length DEO2
 844-	;&buf .File/stat DEO2
 845-	;&hb LDA2 str/read-byte ;&lb LDA2 str/read-byte hex/make dict/alloc NIP2 !bios/<push>
 846-	&api =dict/len =&<eval> "<len> 20 "( 20 "f 20 09 20 "hex 20 ") 00
 847-
 848-@dup/<eval> ( -- )
 849-	bios/is-empty ?bios/<push-err-underflow>
 850-	bios/pop DUP2 bios/<push> !bios/<push>
 851-	&api =dict/dup =&<eval> "<dup> 20 "( 20 "a 20 09 20 "a 20 "a 20 ") 00
 852-
 853-@ovr/<eval> ( -- )
 854-	bios/is-thtwo ?bios/<push-err-underflow>
 855-	( b ) bios/pop
 856-	( a ) bios/pop DUP2 bios/<push>
 857-	SWP2 bios/<push> !bios/<push>
 858-	&api =dict/ovr =&<eval> "<ovr> 20 "( 20 "a 20 "b 20 09 20 "a 20 "b 20 "a 20 ") 00
 859-
 860-@pop/<eval> ( -- )
 861-	bios/is-empty ?bios/<push-err-underflow>
 862-	bios/pop POP2 JMP2r
 863-	&api =dict/pop =&<eval> "<pop> 20 "( 20 "a 20 09 20 ") 00
 864-
 865-@swp/<eval> ( -- )
 866-	bios/is-thtwo ?bios/<push-err-underflow>
 867-	bios/pop bios/pop SWP2 bios/<push> !bios/<push>
 868-	&api =dict/swp =&<eval> "<swp> 20 "( 20 "a 20 "b 20 09 20 "b 20 "a 20 ") 00
 869-
 870-@rot/<eval> ( -- )
 871-	bios/is-ththree ?bios/<push-err-underflow>
 872-	bios/pop bios/pop bios/pop ROT2 ROT2 bios/<push>
 873-	bios/<push> !bios/<push>
 874-	&api =dict/rot =&<eval> "<rot> 20 "( 20 "a 20 "b 20 "c 20 09 20 "b 20 "a 20 "c 20 ") 00
 875-
 876-@cat/<eval> ( -- )
 877-	bios/is-thtwo ?bios/<push-err-underflow>
 878-	bios/pop bios/pop dict/alloc-cat !bios/<push-raw>
 879-	&api =dict/cat =&<eval> "<cat> 20 "( 20 "a 20 "b 20 09 20 "ab 20 ") 00
 880-
 881-@cmp/<eval> ( -- )
 882-	bios/is-thtwo ?bios/<push-err-underflow>
 883-	bios/pop bios/pop str/cmp !bios/<push-bool>
 884-	&api =&cmd =&<eval> "<cmp> 20 "( 20 "a 20 "b 20 09 20 "bool 20 ") 00
 885-	&cmd "cmp 00
 886-
 887-@and/<eval> ( -- )
 888-	bios/is-thtwo ?bios/<push-err-underflow>
 889-	( a ) bios/pop ;dict/t str/cmp
 890-	( b ) bios/pop ;dict/t str/cmp AND !bios/<push-bool>
 891-	&api =&cmd =&<eval> "<and> 20 "( 20 "a 20 "b 20 09 20 "bool 20 ") 00
 892-	&cmd "and 00
 893-
 894-@ora/<eval> ( -- )
 895-	bios/is-thtwo ?bios/<push-err-underflow>
 896-	( a ) bios/pop ;dict/t str/cmp
 897-	( b ) bios/pop ;dict/t str/cmp ORA !bios/<push-bool>
 898-	&api =&cmd =&<eval> "<ora> 20 "( 20 "a 20 "b 20 09 20 "bool 20 ") 00
 899-	&cmd "ora 00
 900-
 901-@add/<eval> ( -- )
 902-	bios/is-thtwo ?bios/<push-err-underflow>
 903-	( a ) bios/pop str/dec
 904-	( b ) bios/pop str/dec ADD2 dec/make !bios/<push-raw>
 905-	&api =&cmd =&<eval> "<add> 20 "( 20 "a 20 "b 20 09 20 "sum 20 ") 00
 906-	&cmd "add 00
 907-
 908-@sub/<eval> ( -- )
 909-	bios/is-thtwo ?bios/<push-err-underflow>
 910-	( a ) bios/pop str/dec
 911-	( b ) bios/pop str/dec SWP2 SUB2 dec/make !bios/<push-raw>
 912-	&api =&cmd =&<eval> "<sub> 20 "( 20 "a 20 "b 20 09 20 "dif 20 ") 00
 913-	&cmd "sub 00
 914-
 915-@dec/<eval> ( -- )
 916-	bios/is-empty ?bios/<push-err-underflow>
 917-	;&buf ,&+ptr STR2
 918-	bios/pop str/hex /make !bios/<push>
 919-
 920-@dec/make ( value* -- str* )
 921-	ORAk ?{ POP2 ;dict/zero JMP2r }
 922-	;&buf ,&+ptr STR2
 923-	OVR #80 AND #00 EQU ?/make-pos
 924-	[ LIT "- ] /<push>
 925-	#7fff AND2 #8000 SWP2 SUB2
 926-	( >> )
 927-
 928-@dec/make-pos ( value* -- str* )
 929-	#2710 [ LIT2r 00fb ]
 930-	&>wpd
 931-		DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?{
 932-			DUP LIT "0 ADD /<push>
 933-			INCr }
 934-		POP2 #000a DIV2 SWPr INCr STHkr ?/>wpd
 935-	POP2r POP2 POP2 ;&buf JMP2r
 936-
 937-@dec/<push> ( c -- )
 938-	#00 [ LIT2 &+ptr =&buf ] INC2k ,&+ptr STR2
 939-	STA2
 940-	JMP2r
 941-	&api =&cmd =&<eval> "<dec> 20 "( 20 "hex 20 09 20 "dec 20 ") 00
 942-	&cmd "dec 00
 943-
 944-@hex/<eval> ( -- )
 945-	bios/is-empty ?bios/<push-err-underflow>
 946-	bios/pop str/dec /make !bios/<push>
 947-
 948-@hex/make ( value* -- buf* )
 949-	;&buf ,&+ptr STR2
 950-	SWP /<push-byte>
 951-	/<push-byte>
 952-	;&buf !str/walk-zero
 953-
 954-@hex/<push-byte> ( byte -- )
 955-	DUP #04 SFT /<push-nibble>
 956-	( >> )
 957-	&<push-nibble> ( byte -- )
 958-	/chr #00 [ LIT2 &+ptr =&buf ] INC2k ,&+ptr STR2
 959-	STA2
 960-	JMP2r
 961-	&api =&cmd =&<eval> "<hex> 20 "( 20 "dec 20 09 20 "hex 20 ") 00
 962-	&cmd "hex 00
 963-
 964-@hex/chr ( hex -- char )
 965-	#0f AND DUP #09 GTH #27 MUL ADD LIT "0 ADD JMP2r
 966-
 967-@rsz/<eval> ( -- )
 968-	bios/is-thtwo ?bios/<push-err-underflow>
 969-	( h* ) bios/pop str/dec
 970-	( w* ) bios/pop str/dec SWP2k window/<set-size>
 971-	.Screen/width DEI2 EQU2 ROT ROT .Screen/height DEI2 EQU2 AND !bios/<push-bool>
 972-	&api =&cmd =&<eval> "<rsz> 20 "( 20 "w 20 "h 20 09 20 "bool 20 ") 00
 973-	&cmd "rsz 00
 974-
 975-@out/<eval> ( -- )
 976-	bios/is-empty ?bios/<push-err-underflow>
 977-	bios/pop !str/<print>
 978-	&api =&cmd =&<eval> "<out> 20 "( 20 "a 20 09 20 ") 00
 979-	&cmd "out 00
 980-
 981-@bye/<eval> ( -- )
 982-	;&callback !fade-out/<bind>
 983-	&api =&cmd =&<eval> "<bye> 20 "( 20 09 20 ") 00
 984-	&cmd "bye 00
 985-
 986-@bye/callback ( -> )
 987-	#800f DEO
 988-	BRK
 989-
 990-(
 991-@|Dict )
 992-
 993-@dict/<reset> ( -- )
 994-	;&buf ,&+ptr STR2
 995-	JMP2r
 996-
 997-@dict/<push-escaped> ( addr* -- addr* )
 998-	str/escape
 999-	( >> )
1000-
1001-@dict/<push> ( c -- )
1002-	[ LIT2 &+ptr =&buf ]
1003-	( clamp ) DUP2 ;&cap NEQ2 ?{ POP2 POP JMP2r }
1004-	INC2k ,&+ptr STR2
1005-	STA
1006-	JMP2r
1007-
1008-@dict/alloc ( str* -- str* addr* )
1009-	LDAk LIT "" EQU ?/alloc-string
1010-	LDAk LIT "( EQU ?/alloc-comment
1011-	[ LITr _&+ptr ] LDR2r
1012-	&>w
1013-		LDAk DUP #20 GTH ?{ POP STH2r #00 !/<push> }
1014-		/<push-escaped>
1015-		INC2 !/>w
1016-
1017-@dict/alloc-file ( name* -- addr* )
1018-	.File/name DEO2
1019-	#0001 .File/length DEO2
1020-	[ LITr _&+ptr ] LDR2r
1021-	&>s
1022-		;&b .File/read DEO2
1023-		.File/success-lb DEI ?{ STH2r #00 !/<push> }
1024-		[ LIT &b $1 ] /<push> !/>s
1025-
1026-@dict/alloc-cat ( a* b* -- addr* )
1027-	[ LIT2r =&+ptr ] LDA2r
1028-	&>wc1
1029-		LDAk DUP ?{
1030-			POP POP2
1031-			&>wc2
1032-				LDAk DUP ?{
1033-					POP POP2 STH2r #00 !/<push> }
1034-				/<push-escaped>
1035-				INC2 !/>wc2 }
1036-		/<push-escaped>
1037-		INC2 !/>wc1
1038-
1039-@dict/alloc-string ( str* -- str* addr* )
1040-	INC2 [ LIT2r =&+ptr ] LDA2r
1041-	&>was
1042-		LDAk DUP ?{ &end-s POP INC2 STH2r #00 !/<push> }
1043-		DUP LIT "" EQU ?/end-s
1044-		/<push-escaped>
1045-		INC2 !/>was
1046-
1047-@dict/alloc-comment ( str* -- str* addr* )
1048-	[ LIT2r =&+ptr ] LDA2r
1049-	&>wac
1050-		LDAk DUP ?{ &end-c /<push>
1051-			INC2 STH2r #00 !/<push> }
1052-		DUP LIT ") EQU ?/end-c
1053-		/<push-escaped>
1054-		INC2 !/>wac
1055-
1056-@dict/alloc-line ( str* -- str* addr* )
1057-	[ LIT2r =&+ptr ] LDA2r
1058-	&>wal
1059-		LDAk DUP #1f GTH ?{ POP STH2r #00 !/<push> }
1060-		/<push-escaped>
1061-		INC2 !/>wal
1062-
1063-(
1064-@|Font )
1065-
1066-@font/<draw-str-color> ( str* color -- )
1067-	,&color STR
1068-	( >> )
1069-
1070-@font/<draw-str> ( str* -- )
1071-	[ LIT2 15 -Screen/auto ] DEO
1072-	&>w
1073-		LDAk DUP ?{ POP POP2 JMP2r }
1074-		DUP LIT "< NEQ ?{ POP !kbd/<draw-str> }
1075-		/<draw-glyph>
1076-		INC2 !/>w
1077-
1078-@font/<draw-glyph> ( c -- )
1079-	DUP #0a NEQ ?{ POP !/<draw-lb> }
1080-	DUP #09 NEQ ?{ POP !/<draw-tab> }
1081-	#00 SWP #20 SUB #40 SFT2 ;&glyphs ADD2
1082-	( >> )
1083-
1084-@font/<draw-sprite> ( addr* -- )
1085-	.Screen/addr DEO2
1086-	[ LIT2 &color 45 -Screen/sprite ] DEO
1087-	JMP2r
1088-
1089-@font/<draw-lb> ( -- )
1090-	[ LIT2 &anchor =bios/anchor-x ] .Screen/y DEI2 #0010 ADD2 Screen/<set-pos>
1091-	JMP2r
1092-
1093-@font/<draw-tab> ( -- )
1094-	;&tab !/<draw-sprite>
1095-
1096-@font/get-width ( str* -- width* )
1097-	[ LIT2r 0000 ]
1098-	&>wgw
1099-		LDAk ?{ POP2 STH2r JMP2r }
1100-		LIT2r 0008 ADD2r INC2 !/>wgw
1101-
1102-@kbd/<draw-str> ( str* -- )
1103-	INC2 [ LIT2 15 -Screen/auto ] DEO
1104-	;&a font/<draw-sprite>
1105-	&>w
1106-		LDAk DUP ?{ POP POP2 JMP2r }
1107-		DUP LIT "> NEQ ?{
1108-			POP [ LIT2 15 -Screen/auto ] DEO
1109-			;&c font/<draw-sprite>
1110-			INC2 !font/<draw-str> }
1111-		/<draw-glyph>
1112-		INC2 !/>w
1113-
1114-@kbd/<draw-glyph> ( c -- )
1115-	[ LIT2 05 -Screen/auto ] DEO
1116-	[ LITr -Screen/x ] DEI2r .Screen/y DEI2 STH2k #0004 ADD2 .Screen/y DEO2
1117-	#00 SWP #20 SUB #30 SFT2 ;&glyphs ADD2 font/<draw-sprite>
1118-	[ LITr -Screen/y ] DEO2r
1119-	[ LITr -Screen/x ] DEO2r
1120-	[ LIT2 15 -Screen/auto ] DEO
1121-	;&b !font/<draw-sprite>
1122-
1123-(
1124-@|Loader )
1125-
1126-@loader/<load-expansion> ( -- )
1127-	#ff00 file/<seek>
1128-	;&pagelen .File/length DEO2
1129-	;&page .File/read DEO2
1130-	#0000
1131-	&>s
1132-		;&page .File/read DEO2
1133-		.File/success DEI2 ORA ?{ POP2 JMP2r }
1134-		DUP2k #80 SFT2 ,&a STR2
1135-		#08 SFT2 INC2 ,&p STR2
1136-		;&mmu-mov .System/expansion DEO2
1137-		INC2 !/>s
1138-
1139-	&mmu-mov [ 01 =&pagelen 0000 =&page &p $2 &a $2 ]
1140-
1141-@loader/<bind> ( path* -- )
1142-	;&buf ,&+ptr STR2
1143-	&>w
1144-		LDAk DUP ?{ POP POP2 !/<launch> }
1145-		#00 [ LIT2 &+ptr =&buf ] INC2k ,&+ptr STR2
1146-		STA2
1147-		INC2 !/>w
1148-
1149-@loader/<set-instant> ( -- )
1150-	[ LIT2 01 _loader/instant ] STR
1151-	JMP2r
1152-
1153-@loader/<launch> ( -- )
1154-	[ LIT &instant $1 ] ?{ ;&callback !fade-out/<bind> }
1155-	;&callback .Screen/vector DEO2
1156-	JMP2r
1157-
1158-@loader/callback ( -> )
1159-	;&buf file/is-oversized #00 EQU ?{ /<load-expansion> }
1160-	#0000 DUP2 Screen/<set-pos>
1161-	( | Clear screen )
1162-	[ LIT2 80 -Screen/pixel ] DEO
1163-	[ LIT2 c0 -Screen/pixel ] DEO
1164-	( | Blank vectors )
1165-	#0000 #00 &l DEO2k #10 ADD DUP [ ?/l POP POP2 ]
1166-	( | Blank arguments )
1167-	[ LIT2 00 -Console/type ] DEO
1168-	( | Setup file )
1169-	;&buf .File/name DEO2
1170-	#ff00 .File/length DEO2
1171-	( | Copy loader )
1172-	;&mmu .System/expansion DEO2
1173-	( 0pg ) #00f5 .System/expansion
1174-	( buf ) #0100 .File/read
1175-	( 1pg ) #00f1 .System/expansion !/entry
1176-
1177-	&mmu [ 01 000f 0000 =&rom 0000 00f1 ]
1178-	&rom [ 00ff 0000 0001 0000 0000 0000 3737 37 ]
1179-
1180-(
1181-@|Fade )
1182-
1183-@fade-out/<bind> ( callback* -- )
1184-	,&callback STR2
1185-	;&on-frame .Screen/vector DEO2
1186-	[ LIT2 00 _&f ] STR
1187-	JMP2r
1188-
1189-@fade-out/on-frame ( -> )
1190-	[ LIT &f $1 ] INCk ,&f STR
1191-	DUP #20 LTH ?{
1192-		POP [ LIT2 &callback $2 ] JMP2 }
1193-	( | Fill )
1194-	( color ) DUP #04 SFT #60 SFT
1195-	( addr* ) #00 ROT #0f AND #30 SFT2 ;curtain/out-short ADD2 window/<fill>
1196-	BRK
1197-
1198-@window/<set-size> ( w* h* -- )
1199-	.Screen/height DEO2
1200-	.Screen/width DEO2
1201-	input/<redraw>
1202-	/<update>
1203-	( >> )
1204-
1205-@window/<draw-spacer> ( -- )
1206-	#0000 #0018 Screen/<set-pos>
1207-	;&wave .Screen/addr DEO2
1208-	[ LIT2 01 -Screen/auto ] DEO
1209-	/get-cols SUB [ LIT2r 41 -Screen/sprite ]
1210-	&>l
1211-		DEOkr
1212-		INC DUP ?/>l
1213-	POP POP2r JMP2r
1214-
1215-@window/<update> ( -- )
1216-	.Screen/width DEI2 DUP2 #01 SFT2 ,&center STR2
1217-	DUP2 #0010 SUB2 ,&margin STR2
1218-	#03 SFT2 ,&cols STR2
1219-	.Screen/height DEI2 DUP2 #01 SFT2 ,&middle STR2
1220-	#03 SFT2 ,&rows STR2
1221-	( | Load wallpaper )
1222-	dir/find-wallpaper INC2k ORA ?{ POP2 JMP2r }
1223-	#0009 ADD2 LDA2k ,&w STR2
1224-	#0003 ADD2 LDA2 ,&h STR2
1225-	;&path #03 !icn/<draw>
1226-
1227-	&get-center [ LIT2 &center $2 ] JMP2r
1228-
1229-	&get-cols [ LIT2 &cols $2 ] JMP2r
1230-
1231-	&get-middle [ LIT2 &middle $2 ] JMP2r
1232-
1233-	&get-rows [ LIT2 &rows $2 ] JMP2r
1234-
1235-	&get-margin [ LIT2 &margin $2 ] JMP2r
1236-
1237-	&path "wallpaper [ &w "00 "x &h "00 ] ".icn 00
1238-
1239-@window/<fill> ( color addr* -- )
1240-	.Screen/addr DEO2
1241-	STH
1242-	[ LITr -Screen/sprite ]
1243-	( | Draw )
1244-	#0000 DUP2 Screen/<set-pos>
1245-	[ LIT2 01 -Screen/auto ] DEO
1246-	( h ) /get-cols SUB
1247-	( v ) /get-rows SUB
1248-	&>v
1249-		OVR
1250-		&>h
1251-			DEOkr
1252-			INC DUP ?/>h
1253-		POP
1254-		( | eos )
1255-		#0000 .Screen/x DEO2
1256-		.Screen/y DEI2k #0008 ADD2 ROT DEO2
1257-		INC DUP ?/>v
1258-	POP2 POP2r JMP2r
1259-
1260-(
1261-@|Stdlib )
1262-
1263-@manifest/scan ( but key -- fn* )
1264-	ORAk ?{ POP2 #ffff JMP2r }
1265-	,&bk STR2
1266-	;&dat
1267-	&>cat
1268-		DUP2 LDAk #00 SWP INC ADD2 SWP2 #0003 ADD2
1269-		&>opt
1270-			LDA2k [ LIT2 &bk $2 ] NEQ2 ?{
1271-				NIP2 INC2 INC2 LDA2 JMP2r }
1272-			#0006 ADD2 GTH2k ?/>opt
1273-		POP2 INC2 LDAk ?/>cat
1274-	POP2 #ffff JMP2r
1275-
1276-@file/get-meta ( path* -- addr* )
1277-	#0000 ,&port-deo2 STR2
1278-	( | lit2 addr* )
1279-	.File/name DEO2
1280-	#0001 .File/length DEO2
1281-	;&lit2 .File/read DEO2
1282-	#0002 .File/length DEO2
1283-	;&addr .File/read DEO2
1284-	.File/success-lb DEI ?{ #0000 JMP2r }
1285-	( | lit port-deo2* )
1286-	#0001 .File/length DEO2
1287-	;&lit .File/read DEO2
1288-	#0002 .File/length DEO2
1289-	;&port-deo2 .File/read DEO2
1290-	.File/success-lb DEI ?{ #0000 JMP2r }
1291-	( a ) [ LIT2 &lit2 $1 &lit $1 ] #a080 EQU2
1292-	( b ) [ LIT2 &port-deo2 $2 ] #0637 EQU2 AND ?{ #0000 JMP2r }
1293-	[ LIT2 &addr $2 ] JMP2r
1294-
1295-@file/<seek> ( addr* -- )
1296-	#0100 SUB2 .File/name DEI2k ROT DEO2
1297-	#0000 INC2k .File/length DEO2
1298-	&>lf
1299-		;&b .File/read DEO2
1300-		INC2 GTH2k ?/>lf
1301-	POP2 POP2 JMP2r
1302-
1303-@file/seek-line ( line* -- not-eof )
1304-	.File/name DEI2k ROT DEO2
1305-	ORAk ?{ POP2 #01 JMP2r }
1306-	#0001 .File/length DEO2
1307-	[ LIT2r =&bs ] [ LITr -File/read ] #0000
1308-	&>l
1309-		DEO2kr
1310-		[ LIT2 00 -File/success-lb ] DEI EQU ?{
1311-			[ LIT2 &bs $1 0a ] NEQ ?{ INC2 }
1312-			GTH2k ?/>l }
1313-	POP2 POP2 POPr POP2r .File/success-lb DEI JMP2r
1314-
1315-@file/is-dir ( path* -- t )
1316-	.File/name DEO2
1317-	#0001 .File/length DEO2
1318-	;&bf .File/stat DEO2
1319-	[ LIT2 "- &bf $1 ] EQU JMP2r
1320-
1321-@file/is-oversized ( path* -- t )
1322-	.File/name DEO2
1323-	#0004 .File/length DEO2
1324-	;&bufstat .File/stat DEO2
1325-	;&bufstat LDA LIT "? EQU JMP2r
1326-	&bufstat $5
1327-
1328-@file/is-text ( path* -- t )
1329-	.File/name DEO2
1330-	#0001 .File/length DEO2
1331-	#00
1332-	&>st
1333-		;&b .File/read DEO2
1334-		( | tests )
1335-		.File/success-lb DEI ?{ JMP2r }
1336-		POP #01 [ LIT &b $1 ] chr/is-ascii ?/>st
1337-	POP #00 JMP2r
1338-
1339-@file/exists ( path* -- t )
1340-	.File/name DEO2
1341-	#0001 .File/length DEO2
1342-	;&e .File/stat DEO2
1343-	[ LIT &e $1 ]
1344-	( not folder ) DUP LIT "- NEQ
1345-	( not missing ) SWP LIT "! NEQ AND JMP2r
1346-
1347-@file/<cpy> ( src* dst* -- )
1348-	.File2/name DEO2
1349-	#0001 .File2/length DEO2
1350-	.File/name DEO2
1351-	#0001 .File/length DEO2
1352-	&>s
1353-		;&b .File/read DEO2
1354-		.File/success-lb DEI ?{ JMP2r }
1355-		;&b .File2/write DEO2 !/>s
1356-
1357-@chr/hex ( c -- val )
1358-	( dec ) [ LIT "0 ] SUB DUP #09 GTH [ JMP JMP2r ]
1359-	( hex ) #27 SUB DUP #0a SUB #05 GTH [ JMP JMP2r ]
1360-	( nil ) POP #ff JMP2r
1361-
1362-@chr/n-0 ( c -- c )
1363-	POP #00 JMP2r
1364-
1365-@chr/t-tab ( c -- c )
1366-	POP #09 JMP2r
1367-
1368-@chr/n-lb ( c -- c )
1369-	POP #0a JMP2r
1370-
1371-@chr/t-ws ( c -- c )
1372-	POP #20 JMP2r
1373-
1374-@chr/is-ascii ( c -- t )
1375-	DUP #08 GTH SWP #7f LTH AND JMP2r
1376-
1377-@str/read-byte ( a b -- byte )
1378-	chr/hex SWP chr/hex #40 SFT ORA JMP2r
1379-
1380-@str/is-dir ( str* -- t )
1381-	/cap #0001 SUB2 LDA LIT "/ EQU JMP2r
1382-
1383-@str/is-icn ( str* -- t )
1384-	/cap #0004 SUB2 ;dict/icn-ext !/cmp
1385-
1386-@str/is-rom ( str* -- t )
1387-	/cap #0004 SUB2 ;dict/rom-ext !/cmp
1388-
1389-@str/is-wallpaper ( str* -- str* t )
1390-	DUP2 #0009 ;dict/wallpaper mem/cmp ?{ #00 JMP2r }
1391-	DUP2 /is-icn ?{ #00 JMP2r }
1392-	#01 JMP2r
1393-
1394-@str/<print> ( str* -- )
1395-	LDAk DUP ?{ POP POP2 JMP2r }
1396-	#18 DEO
1397-	INC2 !/<print>
1398-
1399-@str/escape ( addr* c -- addr* c )
1400-	DUP [ LIT "\ ] NEQ ?{
1401-		POP INC2 LDAk
1402-		( | handlers )
1403-		DUP [ LIT "0 ] EQU ?chr/n-0
1404-		DUP [ LIT "t ] EQU ?chr/t-tab
1405-		DUP [ LIT "n ] EQU ?chr/n-lb
1406-		DUP [ LIT "s ] EQU ?chr/t-ws }
1407-	JMP2r
1408-
1409-@str/is-word ( str* -- t )
1410-	&>wiw
1411-		LDAk DUP ?{ POP POP2 #01 JMP2r }
1412-		#20 GTH ?{ POP2 #00 JMP2r }
1413-		INC2 !/>wiw
1414-
1415-@str/eol ( str* -- eol* )
1416-	&>we
1417-		LDAk DUP ?{ POP JMP2r }
1418-		#0a NEQ ?{ JMP2r }
1419-		INC2 !/>we
1420-
1421-@str/cap ( str* -- end* )
1422-	LDAk ?{ JMP2r }
1423-	INC2 !/cap
1424-
1425-@str/len ( str* -- len* )
1426-	STH2k /cap STH2r SUB2 JMP2r
1427-
1428-@str/cmp ( a* b* -- f )
1429-	STH2
1430-	&>wc
1431-		LDAk ?{ &d LDA LDAr STHr EQU JMP2r }
1432-		LDAk LDAkr STHr NEQ ?/d
1433-		INC2 INC2r !/>wc
1434-
1435-@str/hex ( str* -- value* )
1436-	[ LIT2r 0000 ]
1437-	&>wh
1438-		[ LITr 40 ] SFT2r LDAk chr/hex [ LITr 00 ] STH
1439-		ADD2r INC2 LDAk ?/>wh
1440-	POP2 STH2r JMP2r
1441-
1442-@str/dec ( str* -- val* )
1443-	LDAk [ LIT "- ] NEQ ?/dec-unsigned
1444-	INC2 /dec-unsigned #0000 SWP2 SUB2 JMP2r
1445-
1446-@str/dec-unsigned ( str* -- val* )
1447-	[ LIT2r 0000 ] !{
1448-
1449-	&>ldec
1450-		[ LITr 00 ] STH
1451-		MUL2r [ LITr 00 ] STH
1452-		ADD2r INC2 }
1453-	( str* . val* ) LDAk [ LIT "0 ] SUB #0a LTHk ?/>ldec
1454-	POP2 POP2 STH2r JMP2r
1455-
1456-@str/walk-ws ( str* -- str* )
1457-	&>ws
1458-		LDAk ?{ JMP2r }
1459-		LDAk #20 GTH ?{ INC2 LDAk ?/>ws }
1460-	JMP2r
1461-
1462-@str/walk-zero ( str* -- str* )
1463-	&>wz
1464-		LDAk ?{ JMP2r }
1465-		LDAk LIT "0 NEQ ?{ INC2 LDAk ?/>wz }
1466-	JMP2r
1467-
1468-@str/seg ( str* seg* -- bool )
1469-	DUP2 /len SWP2 !mem/cmp
1470-
1471-@mem/cmp ( a* length* b* -- t )
1472-	STH2
1473-	OVR2 ADD2 SWP2
1474-	&>l
1475-		EQU2k ?{
1476-			LDAk LDAkr STHr NEQ ?{ INC2 INC2r !/>l } }
1477-	POP2r EQU2 JMP2r
1478-
1479-@date/make ( -- str* )
1480-	;&buf DUP2 ,&+ptr STR2
1481-	( | Make string )
1482-	[ LIT2 00 -DateTime/dotw ] DEI #20 SFT ;dict/days ADD2 /<push-str>
1483-	[ LIT ", ] /<push>
1484-	#20 /<push>
1485-	[ LIT2 00 -DateTime/day ] DEI /<push-dec>
1486-	#20 /<push>
1487-	[ LIT2 00 -DateTime/month ] DEI #20 SFT ;dict/months ADD2 /<push-str>
1488-	#20 /<push>
1489-	.DateTime/year DEI2 !/<push-dec>
1490-
1491-@date/<push-dec> ( short* -- )
1492-	#2710 [ LIT2r 00fb ]
1493-	&>wpd
1494-		DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?{ DUP /<push-digit>
1495-			INCr }
1496-		POP2 #000a DIV2 SWPr INCr STHkr ?/>wpd
1497-	POP2r POP2 POP2 JMP2r
1498-
1499-@date/<push-digit> ( d -- )
1500-	LIT "0 ADD
1501-	( >> )
1502-
1503-@date/<push> ( c -- )
1504-	#00 [ LIT2 &+ptr =&buf ] INC2k ,&+ptr STR2
1505-	STA2
1506-	JMP2r
1507-
1508-@date/<push-str> ( str* -- )
1509-	&>w
1510-		LDAk DUP ?{ POP POP2 JMP2r }
1511-		/<push>
1512-		INC2 !/>w
1513-
1514-@time/make ( -- str* )
1515-	;&buf DUP2 ,&+ptr STR2
1516-	( | Make string )
1517-	.DateTime/hour DEI /<push-dec>
1518-	LIT ": /<push>
1519-	.DateTime/minute DEI /<push-dec>
1520-	LIT ": /<push>
1521-	.DateTime/second DEI !/<push-dec>
1522-
1523-@time/<push-dec> ( u8 -- )
1524-	DUP #0a DIV /<push-digit>
1525-	#0a DIVk MUL SUB
1526-	( >> )
1527-
1528-@time/<push-digit> ( d -- )
1529-	LIT "0 ADD
1530-	( >> )
1531-
1532-@time/<push> ( c -- )
1533-	#00 [ LIT2 &+ptr =&buf ] INC2k ,&+ptr STR2
1534-	STA2
1535-	JMP2r
1536-
1537-@banner/<request> ( -- )
1538-	[ LIT2 00 _&skip ] STR
1539-	JMP2r
1540-
1541-@banner/<draw> ( -- )
1542-	;bios/anchor-x DUP2 ,&x STR2
1543-	.Screen/y DEI2 #0018 ADD2 DUP2 ,&y STR2
1544-	Screen/<set-pos>
1545-	sel/has-meta ?meta/<draw>
1546-	[ LIT2 66 -Screen/auto ] DEO
1547-	;&asset .Screen/addr DEO2
1548-	[ LIT2 45 -Screen/sprite ] DEOk DEO
1549-	.Screen/vector DEI2 ORA ?{
1550-		[ LIT &skip 00 ] ?{
1551-			[ LIT2 00 _&f ] STR
1552-			[ LIT2 01 _&skip ] STR
1553-			;&on-frame .Screen/vector DEO2 } }
1554-	JMP2r
1555-
1556-@banner/on-frame ( -> )
1557-	[ LIT &f $1 ] INCk ,&f STR
1558-	DUP #20 LTH ?{
1559-		POP #0000 .Screen/vector DEO2
1560-		BRK }
1561-	#01 SFT [ LIT2 &x $2 ] [ LIT2 &y $2 ] Screen/<set-pos>
1562-	[ LIT2 66 -Screen/auto ] DEO
1563-	;&asset .Screen/addr DEO2
1564-	[ LIT2 45 -Screen/sprite ] DEOk DEO
1565-	( | mask )
1566-	.Screen/y DEI2k #0010 SUB2 ROT DEO2
1567-	[ LIT2 15 -Screen/auto ] DEO
1568-	#0010 ROT SUB #30 SFT2 ;curtain/out ADD2 .Screen/addr DEO2
1569-	[ LIT2 40 -Screen/sprite ] DEOk DEOk DEOk DEOk DEOk DEOk DEO
1570-	BRK
1571-
1572-@banner/<load> ( -- )
1573-	#0070 .File/length DEO2
1574-	;&asset .File/read DEO2
1575-	JMP2r
1576-
1577-@meta/<load> ( addr* -- )
1578-	file/<seek>
1579-	;&buflen .File/length DEO2
1580-	;&buf .File/read DEO2
1581-	;&body str/cap INC2
1582-	( | parse fields )
1583-	[ LIT2 00 _&has-icon ] STR
1584-	LDAk #00 SWP #0003 MUL2 OVR2 INC2 ADD2 SWP2 INC2
1585-	&>l
1586-		LDAk #83 NEQ ?{
1587-			( | Load icon )
1588-			INC2k LDA2 file/<seek>
1589-			#0090 .File/length DEO2
1590-			;&icon .File/read DEO2
1591-			[ LIT2 90 -File/success-lb ] DEI EQU ,&has-icon STR }
1592-		#0003 ADD2 GTH2k ?/>l
1593-	POP2 POP2 JMP2r
1594-
1595-@meta/<draw> ( -- )
1596-	/<draw-icon>
1597-	.Screen/x DEI2 #0020 ADD2 .Screen/y DEI2 #0018 SUB2 Screen/<set-pos>
1598-	#0028 ;font/anchor STA2
1599-	;&body #41 font/<draw-str-color>
1600-	;bios/anchor-x ;font/anchor STA2
1601-	JMP2r
1602-
1603-@meta/<draw-icon> ( -- )
1604-	[ LIT &has-icon $1 ] ?{
1605-		;&no-icon .Screen/addr DEO2
1606-		[ LIT2 22 -Screen/auto ] DEO
1607-		[ LIT2 c5 -Screen/sprite ] DEOk DEOk DEO
1608-		JMP2r }
1609-	;&icon .Screen/addr DEO2
1610-	[ LIT2 26 -Screen/auto ] DEO
1611-	[ LIT2 c5 -Screen/sprite ] DEOk DEOk DEO
1612-	JMP2r
1613-
1614-@theme/<reset> ( -- )
1615-	#f0a8 #f0ec #f0b9
1616-	( >> )
1617-
1618-@theme/<set> ( r* g* b* -- )
1619-	.System/b DEO2
1620-	.System/g DEO2
1621-	.System/r DEO2
1622-	JMP2r
1623-
1624-@theme/<load> ( -- )
1625-	;&path .File/name DEO2
1626-	#0002 .File/length DEO2
1627-	;&r .File/read DEO2
1628-	;&g .File/read DEO2
1629-	;&b .File/read DEO2
1630-	.File/success-lb DEI ?{ !/<reset> }
1631-	banner/<load>
1632-	[ LIT2 &r $2 ] [ LIT2 &g $2 ] [ LIT2 &b $2 ] !/<set>
1633-
1634-	&path ".theme 00
1635-
1636-( 
1637-@|Assets )
1638-
1639-@dict/m_pc "M/PC 00
1640-	&ready2 "Type 20 "<cmd> 20 "to 20 "see 20 "options. 00
1641-	&home-path "./ 00
1642-	&sel-prev "Selection 20 "Previous 00
1643-	&sel-next "Selection 20 "Next 00
1644-	&sel-pick "Pick 20 "Selection 00
1645-	&clear "Clear 20 "Input 00
1646-	&directory "Directory 00
1647-	&wallpaper "wallpaper 00
1648-	&input "Input 00
1649-	&eval "Run 00
1650-	&eof "eof 00
1651-	&scroll-up "Scroll 20 "Up 00
1652-	&scroll-down "Scroll 20 "Down 00
1653-	&eval-partial "Non-Destructive 20 "Run 00
1654-	&out-path "../ 00
1655-	&icn-ext ".icn 00
1656-	&rom-ext ".rom 00
1657-	&dir "dir 00
1658-	&mov "mov 00
1659-	&run "run 00
1660-	&txt "txt 00
1661-	&put "put 00
1662-	&era "era 00
1663-	&ren "ren 00
1664-	&get "get 00
1665-	&cmd "cmd 00
1666-	&len "len 00
1667-	&dup "dup 00
1668-	&ovr "ovr 00
1669-	&swp "swp 00
1670-	&rot "rot 00
1671-	&pop "pop 00
1672-	&now "now 00
1673-	&cat "cat 00
1674-	&icn "icn 00
1675-	&cpy "cpy 00
1676-	&zero "0 00
1677-	&t "<true> 00
1678-	&f "<false> 00
1679-	&ok "<ok> 00
1680-	&err-underflow "<underflow> 00
1681-	&err-missing "<missing> 00
1682-	&err-binary "<binary> 00
1683-	&months [
1684-	"Jan $1 "Feb $1 "Mar $1 "Apr $1 "May $1 "Jun $1 "Jul $1 "Aug $1
1685-	"Sep $1 "Oct $1 "Nov $1 "Dec $1 ]
1686-	&days [
1687-	"Sun $1 "Mon $1 "Tue $1 "Wed $1 "Thu $1 "Fri $1 "Sat $1 ]
1688-
1689-@window/wave [ 0000 0000 0070 8807 ]
1690-
1691-@input/caret [ 0020 2020 2020 2020 2020 2020 2020 0000 ]
1692-
1693-@curtain/out [8
1694-	0000 0000 0000 0000 0000 0000 0000 0000
1695-	0000 0000 0000 0000 0000 0000 0000 0000
1696-	0000 0000 0000 0000 0000 0000 0000 0000
1697-	0000 0000 0000 0000 0000 0000 0000 0000
1698-	0000 0000 0000 0000 0000 0000 0000 0000
1699-	0000 0000 0000 0000 0000 0000 0000 0000
1700-	0000 0000 0000 0002 0000 0000 0000 0002 ]
1701-	&out-short [8
1702-	0000 0022 0000 0022 0000 0022 0000 0022
1703-	0088 0022 0088 0022 0088 0022 0088 0022
1704-	00aa 00aa 00aa 00aa 00aa 00aa 00aa 00aa
1705-	44aa 11aa 44aa 11aa 44aa 11aa 44aa 11aa
1706-	aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55
1707-	aa77 aadd aa77 aadd aa77 aadd aa77 aadd
1708-	aaff aaff aaff aaff aaff aaff aaff aaff
1709-	bbff eeff bbff eeff bbff eeff bbff eeff
1710-	bbff ffff bbff ffff bbff ffff bbff ffff
1711-	ffff ffff ffff ffff ffff ffff ffff ffff ]
1712-
1713-@appicon [8
1714-	0000 0000 0000 0001 0000 0000 0000 0000
1715-	0000 0000 0000 0080 0000 0000 0000 0000
1716-	0000 0000 0000 0038 0000 0000 0000 0000
1717-	070f 0f1f 1f0f 0f07 0000 0000 0000 0000
1718-	e0f0 f0f8 f8f1 f1e3 0000 0000 0000 0000
1719-	3870 70e0 e0c0 c080 0000 0000 0000 0000
1720-	0100 0000 0000 0000 0000 0000 0000 0000
1721-	8300 0000 0000 0000 0000 0000 0000 0000
1722-	8000 0000 0000 0000 0000 0000 0000 0000 ]
1723-
1724-@banner/asset [8
1725-	000f 3f7f 7fff ffff 00c0 f0f8 f8fc fcfc
1726-	000e 0e1c 1c38 3870 00ff ffff e0e0 e0e0
1727-	00f0 fcfc 1e0e 0e1e 001f 7f7f f0e0 e0e0
1728-	00f0 fcfc 1e0e 0e00 ffff ff7f 7f3f 0f00
1729-	fcfc fcf9 f9f3 c300 70e0 e0c0 c080 8000
1730-	ffff ffe0 e0e0 e000 fcfc f000 0000 0000
1731-	e0e0 e0f0 7f7f 1f00 000e 0e1e fcfc f000 ]
1732-
1733-@meta/no-icon [ cccc 3333 cccc 3333 ]
1734-
1735-@font/glyphs [8
1736-	0000 0000 0000 0000 0000 0000 0000 0000
1737-	0000 1010 1020 2020 2000 4040 0000 0000
1738-	0000 0050 5000 0000 0000 0000 0000 0000
1739-	0000 0024 24fc 4848 fc90 9000 0000 0000
1740-	0000 083c 4a50 5030 2828 48f0 4000 0000
1741-	0000 1129 2a14 0810 2854 9488 0000 0000
1742-	0000 1824 2428 3052 9488 8876 0000 0000
1743-	0000 0040 4000 0000 0000 0000 0000 0000
1744-	0004 0808 1010 2020 2020 2010 1000 0000
1745-	0020 2010 1010 1010 2020 4040 8000 0000
1746-	0000 0024 187e 1824 0000 0000 0000 0000
1747-	0000 0000 0010 107c 1010 0000 0000 0000
1748-	0000 0000 0000 0000 0000 0020 2040 0000
1749-	0000 0000 0000 007c 0000 0000 0000 0000
1750-	0000 0000 0000 0000 0000 0010 0000 0000
1751-	0001 0102 0404 0810 2020 4080 8000 0000
1752-	0000 1824 4444 8484 8888 9060 0000 0000
1753-	0000 0818 2810 1010 1020 2070 0000 0000
1754-	0000 1c22 0204 0810 2040 80f8 0000 0000
1755-	0000 1c22 0204 1804 0404 8870 0000 0000
1756-	0000 0408 0810 2848 fc10 1010 0000 0000
1757-	0000 3e20 2078 4404 0404 8870 0000 0000
1758-	0000 0c10 2040 58e4 8484 8870 0000 0000
1759-	0000 3e02 0408 1010 2020 4040 0000 0000
1760-	0000 1c22 4244 3844 8484 8870 0000 0000
1761-	0000 1c22 4242 463c 0408 1060 0000 0000
1762-	0000 0000 0000 4000 0000 0040 0000 0000
1763-	0000 0000 0000 2000 0000 0020 2040 0000
1764-	0000 0000 0008 1020 4020 1008 0000 0000
1765-	0000 0000 0000 007c 0000 7c00 0000 0000
1766-	0000 0000 0040 2010 0810 2040 0000 0000
1767-	0000 003c 4242 0408 1010 0010 0000 0000
1768-	0000 0000 1e21 4e52 524f 201c 0000 0000
1769-	0000 0c0c 1414 2424 7c44 8484 0000 0000
1770-	0000 1e11 1122 3c22 2242 4478 0000 0000
1771-	0000 0e11 2020 4040 4040 4438 0000 0000
1772-	0000 3c22 2242 4242 4484 88f0 0000 0000
1773-	0000 1f10 1020 3c20 2040 407c 0000 0000
1774-	0000 1f10 1020 3c20 2040 4040 0000 0000
1775-	0000 0e11 2020 404e 4244 443c 0000 0000
1776-	0000 2121 2142 7e42 4284 8484 0000 0000
1777-	0000 1f04 0408 0808 0810 107c 0000 0000
1778-	0000 0702 0204 0404 0488 8870 0000 0000
1779-	0000 2122 2448 7050 4888 8484 0000 0000
1780-	0000 1010 1020 2020 2040 407c 0000 0000
1781-	0000 2121 3356 5a5a 4284 8484 0000 0000
1782-	0000 2121 3152 524a 4a8c 8484 0000 0000
1783-	0000 0e11 2121 4141 4242 4438 0000 0000
1784-	0000 1e11 1121 223c 2040 4040 0000 0000
1785-	0000 0e11 2121 4141 4252 5438 0600 0000
1786-	0000 1e11 1122 3c30 2848 4444 0000 0000
1787-	0000 1e21 2020 1008 0404 8478 0000 0000
1788-	0000 7f08 0810 1010 1020 2020 0000 0000
1789-	0000 2121 4142 4242 8284 8478 0000 0000
1790-	0000 2121 2222 2424 2828 3030 0000 0000
1791-	0000 2121 2122 2a5a 6a6c 4444 0000 0000
1792-	0000 2121 1214 1818 2848 8484 0000 0000
1793-	0000 2121 1212 1408 0810 1010 0000 0000
1794-	0000 3f01 0204 0810 2040 80fc 0000 0000
1795-	001e 1010 1020 2020 2040 4040 7800 0000
1796-	0040 4040 2020 2010 1010 0808 0800 0000
1797-	0078 0808 0810 1010 1020 2020 e000 0000
1798-	0000 0020 5000 0000 0000 0000 0000 0000
1799-	0000 0000 0000 0000 0000 00f8 0000 0000
1800-	0000 0040 2000 0000 0000 0000 0000 0000
1801-	0000 0000 001e 2222 4444 4c32 0000 0000
1802-	0000 3010 102c 3222 2244 4438 0000 0000
1803-	0000 0000 001c 2220 4040 4438 0000 0000
1804-	0000 0101 011e 2222 4244 4c32 0000 0000
1805-	0000 0000 001c 2224 7840 4438 0000 0000
1806-	0000 0304 0808 3e08 1010 1010 2020 4000
1807-	0000 0000 001e 2222 4444 4c34 0848 7000
1808-	0000 3010 102e 3222 2244 4446 0000 0000
1809-	0000 0404 000c 1808 0810 121c 0000 0000
1810-	0000 0404 000c 1808 0808 1010 1020 c000
1811-	0000 1010 102e 3222 3c48 4442 0000 0000
1812-	0000 0c04 0408 0808 0810 1418 0000 0000
1813-	0000 0000 00b7 4949 4992 9293 0000 0000
1814-	0000 0000 006e 3222 2244 4446 0000 0000
1815-	0000 0000 001c 2222 4244 4438 0000 0000
1816-	0000 0000 002c 7222 2244 4478 4080 8000
1817-	0000 0000 001a 2622 4244 4c34 0808 0800
1818-	0000 0000 0016 3a10 1020 2020 0000 0000
1819-	0000 0000 001c 2220 1804 4438 0000 0000
1820-	0000 0008 083e 0810 1010 2418 0000 0000
1821-	0000 0000 0062 2222 4244 4c32 0000 0000
1822-	0000 0000 0062 2222 2224 2830 0000 0000
1823-	0000 0000 0061 2141 495a 6644 0000 0000
1824-	0000 0000 0031 120c 0818 2446 0000 0000
1825-	0000 0000 0062 2222 4444 4c34 0848 7000
1826-	0000 0000 001d 2204 0810 2052 0c00 0000
1827-	0006 0808 0810 6010 1020 2020 1800 0000
1828-	0000 1010 1020 2020 2040 4040 0000 0000
1829-	0030 0808 0810 100c 1020 2020 c000 0000
1830-	0000 0000 0000 0032 4c00 0000 0000 0000 ]
1831-	&tab [ 0000 0000 0008 0c7e 0c08 0000 0000 0000 ]
1832-
1833-@kbd/glyphs [8
1834-	0000 0000 0000 0000 0808 1010 1000 2000
1835-	2448 0000 0000 0000 0a14 7e28 fc50 a000
1836-	083c 5238 14a8 7020 44a8 4810 242a 4400
1837-	1824 4862 9c88 7000 1020 0000 0000 0000
1838-	0408 1020 2020 1008 2010 0808 0810 2040
1839-	0050 2050 0000 0000 0000 2020 f820 2000
1840-	0000 0000 0010 1020 0000 0000 7c00 0000
1841-	0000 0000 0000 1000 0808 1010 2020 4040
1842-	0c12 2242 4448 3000 0c04 0808 0810 1000
1843-	0c12 0408 1020 7800 0e02 0418 0448 3000
1844-	060a 1424 3e08 0800 1e20 3804 0448 3000
1845-	0c12 2038 4448 3000 3e04 0810 2040 4000
1846-	0c12 2418 2448 3000 0c12 221c 0448 3000
1847-	0000 1000 0010 0000 0000 1000 0010 1020
1848-	0000 0810 2010 0800 0000 7c00 7c00 0000
1849-	0000 2010 0810 2000 3844 0418 2000 4000
1850-	0c12 2e54 5844 3000 1c22 2244 7c88 8800
1851-	3c22 4478 4488 f000 1c22 4040 8088 7000
1852-	3c22 4244 4488 f000 3e20 4078 4080 f800
1853-	3e20 4078 4080 8000 1c22 4040 9c88 7000
1854-	2222 447c 4488 8800 1c08 1010 2020 7000
1855-	0e04 0808 1090 6000 2224 4870 5090 8800
1856-	1010 2020 2040 7c00 2236 4c44 4488 8800
1857-	2222 6454 4c88 8800 1c22 4244 8488 7000
1858-	3c22 4478 4080 8000 1c22 4244 9488 7400
1859-	3c22 4478 4488 8800 1c22 4038 0488 7000
1860-	7c10 2020 2040 4000 2222 4444 8888 7000
1861-	4444 4448 5020 2000 2222 4454 a8a8 5000
1862-	2224 2810 2848 8800 4448 5020 2040 4000
1863-	3e04 0810 2040 f800 0c08 0810 1020 2030
1864-	2020 2010 1008 0808 1808 1010 1020 2060
1865-	2050 8800 0000 0000 0000 0000 0000 f800
1866-	4020 1000 0000 0000 0000 1a24 4448 3400
1867-	1020 3824 4448 3000 0000 1824 4048 3000
1868-	0202 1a24 4448 3400 0000 1824 7840 3000
1869-	0608 3c10 1020 20c0 0000 1a24 4838 9060
1870-	1020 2834 2448 4800 0400 1808 1028 3000
1871-	0400 1808 1010 20c0 1020 2834 2850 4800
1872-	1808 1010 2028 3000 0000 542a 2a54 5400
1873-	0000 2c32 2244 4400 0000 1824 4448 3000
1874-	0000 2c12 2458 4040 0000 1a24 4c34 0408
1875-	0000 2834 2040 4000 0000 1824 1048 3000
1876-	0810 3c10 2028 3000 0000 2424 4858 2800
1877-	0000 6424 4850 6000 0000 622a 5454 2800
1878-	0000 2458 1034 4800 0000 2424 4838 9060
1879-	0000 3448 1024 5800 0c10 1060 2040 4020
1880-	1010 1010 1010 1010 0804 0408 0c10 1060
1881-	0000 0032 4c00 0000 0000 0000 0000 0000 ]
1882-	&a [ 0000 0001 0204 0810 1008 0402 0100 0000 ]
1883-	&b [ 0000 ff00 0000 0000 0000 0000 00ff 0000 ]
1884-	&c [ 0000 0080 4020 1008 0810 2040 8000 0000 ]
1885-
1886-(
1887-@|Buffer )
1888-
1889-@len/buf &hb $2 &lb $2 00
1890-
1891-@dec/buf $6
1892-
1893-@hex/buf $6
1894-
1895-@icn/buf $8
1896-
1897-@date/buf $12
1898-
1899-@time/buf $a
1900-
1901-@symbol/buf $20
1902-
1903-@loader/page $&pagelen
1904-
1905-@meta/buf $1 &body $&buflen
1906-	&cap 0000 &icon $90
1907-
1908-@path/buf $&buflen
1909-	&cap 0000
1910-
1911-@dir/buf $&buflen 0000
1912-
1913-@bios/buf $&buflen
1914-	&cap 0000
1915-
1916-@dict/buf
1917-
1918-
1919-
+0, -0
+0, -11
 1@@ -1,11 +0,0 @@
 2-( cat a.txt | uxncli xh.rom > b.rom )
 3-@on-reset ( -> )
 4-	;on-console #10 DEO2 BRK
 5-@on-console ( -> )
 6-	#0417 DEI EQU ?{
 7-		#12 DEI
 8-		LIT "0 SUB DUP #0a LTH ?{
 9-			#27 SUB DUP #10 LTH ?{ POP BRK } }
10-		LITr 40 EORr STHkr ?{ ORA #18 DEO BRK }
11-		STHkr SFT BRK }
12-	#800f DEO
+0, -273
  1@@ -1,273 +0,0 @@
  2-This document describes the UUID-based extensions. Not all of these are
  3-currently implemented, and some are currently a draft.
  4-
  5-I do not have any intention that any of these should be a part of the
  6-standard uxn/varvara, although some other emulator authors may choose to
  7-implement none, some, or all of them in their own emulators, as well as
  8-their own extensions.
  9-
 10-Most programs should not need these extensions, although some might be
 11-able to use them optionally. (More rarely, some programs might require
 12-one or more of these extensions, but this is generally discouraged.)
 13-
 14-
 15-=== 01231250-d878-4462-bc41-d0927645a2fa (Uxn11 Console) ===
 16-
 17-This is the uxn11 extensions to the console device. (Uxn11 itself
 18-unconditionally enables these extensions, although an implementation
 19-might only enable it when the program specifies this extension, in case
 20-it conflicts with other extensions.)
 21-
 22-See: https://git.phial.org/d6/uxn11/src/branch/d6/multiprocess/console.txt
 23-
 24-(This extension may be obsolete; see 9c5f1356-6bc5-11ef-a6c9-002618745416)
 25-
 26-
 27-=== 4105259c-e061-11f0-963f-002618745416 (Random number generator) ===
 28-
 29-This extension is for the random number generator. The current verison
 30-number is 1.
 31-
 32-Which device number is possible depends on the implementation; some might
 33-ignore the device number. You should specify a device number that your
 34-program does not otherwise use.
 35-
 36-The data of the extension is four bytes:
 37-
 38-* First is the flag byte, which has bit0 clear for 8-bit output or set for
 39-16-bit output. The other bits must be clear.
 40-
 41-* Second is the number of bytes within a subroutine which the extension is
 42-allowed to overwrite the contents of. These number of bytes will have an
 43-unspecified contents after this extension is loaded successfully, and you
 44-should not modify them (which might or might not affect the extension).
 45-
 46-* Third is the 16-bit address of the subroutine to override.
 47-
 48-If the subroutine is called at the specified address, it will push a random
 49-number to the data stack followed by the effect of JMP2r.
 50-
 51-
 52-=== 80175132-e263-11ed-b8c9-002618745416 (Colours) ===
 53-
 54-Allows setting separate foreground and background colours. The device
 55-number must be zero, and the version will be 1. The data is eight 16-bit
 56-numbers, for the colours in order background 0 to 3 and then foreground 0
 57-to 3 (although note that foreground 0 is not normally meaningful), with the
 58-high to low nybble of each being red, green, blue, unused (zero). What
 59-happens if you then try to change colours using the colour ports after
 60-doing this, is not specified.
 61-
 62-
 63-=== 970b5a0c-2c44-11ee-ac3b-002618745416 (Screen compatibility flags) ===
 64-
 65-This extension defines compatibility flags for the screen device for use
 66-with older varvara programs. It is not meant to be called by the uxn
 67-program itself (although it can be); it is meant for use with the -mu flag.
 68-
 69-The device number should be 0x20, although the screen device ports will
 70-continue to work as they do (except for the changes by the flags).
 71-
 72-There is one byte of data in this extension. It consists of a bit field,
 73-where a bit which is clear means the older behaviour and a bit which is
 74-set corresponds to newer behaviour, generally.
 75-
 76-* bit0 = clear if drawing sprites with colour mode 0 is opaque, or set if
 77-it is transparent.
 78-
 79-* bit1 = set if flipping will reverse the direction of auto advancement
 80-when drawing sprites.
 81-
 82-Other bits are currently unused.
 83-
 84-
 85-=== 9c5f1356-6bc5-11ef-a6c9-002618745416 (Subprocess) ===
 86-
 87-This is an extension for handling subprocesses. The device number must
 88-be 0x10 and the current version number is 1.
 89-
 90-15 = Subprocess status
 91-16 = Subprocess exit code
 92-1C = Subprocess command line *
 93-1E = Subprocess mode
 94-1F = Start subprocess
 95-
 96-(This documentation is incomplete)
 97-
 98-
 99-=== b076ddca-db5a-11ee-bddb-002618745416 (Extended text input) ===
100-
101-(DRAFT)
102-
103-This extension is used for extended text input with TRON character codes
104-and/or extended IBM code pages. The current version number is 1.
105-
106-(I am not sure how useful this actually is (since it is not needed for
107-output, nor to implement IME in ordinary uxn code), so it might be removed
108-in future, or might never end up being implemented.)
109-
110-The ports are:
111-
112-x0 - Vector *
113-x2 - TRON volume
114-x3 - TRON plane
115-x4 - TRON code *
116-x6 - Intended mode
117-x7 - Effective mode
118-x8 - Code page (hi) *
119-xA - Code page (lo) *
120-
121-The vector and intended mode (and possibly the code page, if applicable)
122-should be set by the program, and the emulator will set the other fields
123-to be read by the program.
124-
125-The mode flags are:
126-
127-* bit0 = Normal keyboard input (with the standard keyboard device). If
128-this is set in the intended mode, then keyboard events will trigger the
129-standard input device. In the effective mode, it is set if this event will
130-(or did) trigger the standard input device.
131-
132-* bit1 = Extended keyboard input. If this is set in the intended mode, then
133-it requests TRON character input, and will trigger this device's vector
134-when TRON character input is available; if this bit is clear then ASCII (or
135-extended ASCII) input is supported. In the effective mode, it is set if
136-this event will (or did) trigger this device, which it does if a TRON
137-character input is available.
138-
139-* bit2 = Bracketed paste. Setting it in the intended mode enables this
140-feature. In the effective mode, this bit will be set if it is currently
141-doing a bracketed paste.
142-
143-* bit3 = Code page. This means to use the specified code page with the
144-normal keyboard input. It is set in the effective mode if the keyboard
145-event is using the specified code page.
146-
147-The initial value for the intended mode is 0x01. Note that bit0 and bit1
148-are not mutually exclusive; if both are set, then it is possible (but not
149-necessarily) that a keyboard event will trigger both devices. If neither
150-bit is set, then text input is not requested (some implementations might
151-use this to hide the on-screen keyboard). Also, the effective mode is set
152-for both kinds of input events, regardless of the intended mode.
153-
154-The code page is an extended IBM code page number; an implementation may
155-have a default value (and if it does, might set the intended mode to 0x09).
156-It also might be limited as to what code pages it supports (possibly only
157-one or possibly none at all), in which case it only has those values; the
158-emulator may automatically change them to the supported values when setting
159-them to an unsupported values, so the program may wish to read them back.
160-(The code pages SHOULD be an extension of ASCII; you SHOULD NOT use EBCDIC
161-code pages, please. The emulator MUST NOT automatically set the code page
162-to any non-ASCII code page.)
163-
164-Code page number 65535 is not normally a valid code page number in the IBM
165-code page numbers, so instead code page 65535 is used here to mean whatever
166-code page is used for file names (the emulator might select a different one
167-instead if you specify code page 65535, but this is not guaranteed).
168-
169-
170-=== c7e5d57e-1201-11ee-bee4-002618745416 (Sequencer) ===
171-
172-(DRAFT)
173-
174-This will make available a audio sequencer device, which can be used for
175-music playback with precise timing. The current version number is 1.
176-
177-The ports are:
178-
179-x0 - Vector *
180-x2 - Sequencer channels / reset
181-x3 - Override channels
182-
183-The sequencer channels/reset port has the low four bits for the channels
184-that are used by the sequencer, where bit0 is the first channel; the high
185-four bits should be clear. Writing anything to this port will clear the
186-sequencer buffer and reset the sequencer.
187-
188-The override channels port has the same format as the sequencer channels
189-port, although in this case the bits are set to temporarily suppress the
190-sequencer for these channels. The sequencer will still run and those
191-channels can still be written by the sequencer vector and will fill up
192-the sequencer buffer, but the audio from those channels will not be played
193-from the sequencer buffer, instead acting like the sequencer is disabled
194-for the purpose of the audio output. Clearing those bits in this port will
195-then allow playback of those channels from the sequencer buffer. This does
196-not block timing; the corresponding channels in the sequencer buffer are
197-still "played" but will be muted.
198-
199-The vector will be called at unpredictable times, and the number of times
200-it will be called is also unpredictable (and may even be zero, e.g. if
201-the audio is disabled by the user). However, the contents of the audio
202-registers which the sequencer is enabled for will then be played back, at
203-a rate of one frame for each time this vector is called.
204-
205-The timing of the sequencer vector will be guaranteed to not interrupt any
206-other vectors and to be called as many times as necessary to fill up the
207-sequencer buffer for the amount of time that the music will be played.
208-
209-If the sequencer is enabled, then those channels should not be touched
210-outside of the sequencer vector unless the override bits are set.
211-
212-Also note that since the sequencer vector timing is unpredictable, you
213-should not use it to store stuff used by other parts of the program nor
214-read other timing-sensitive things, including the date/time device (which
215-will return the current date/time and not necessarily the time that the
216-music will be audible).
217-
218-An implementation should ensure that the values for the audio channels
219-which are assigned to the sequencer are retained for sequencer callbacks
220-independently from their access by code outside of sequencer callbacks,
221-so that channel overrides will work correctly. However, the initial values
222-after the sequencer has been reset might be either zero or the previously
223-set values by the sequencer or the values that have been set before the
224-sequencer was enabled.
225-
226-The sequencer callback itself should never touch the sequencer channels
227-port or the override channels port, although it is allowed to change the
228-vector so that the next call will be at a different address.
229-
230-If this extension is not available, then programs should use the screen
231-vector for audio timing.
232-
233-
234-=== d02b5508-db5d-11ee-bb94-002618745416 (Game Boy emulation) ===
235-
236-(DRAFT)
237-
238-This extension is only intended to be available for multi-system emulators
239-that includes varvara and Game Boy, although this is not required (it is
240-also possible to implement in an emulator that doesn't emulate the rest of
241-Game Boy). (This is not fully defined yet, and cannot be used at this time.
242-For example, there is currently no way to set colour/mono mode, and many
243-other things are also missing.)
244-
245-The ports are:
246-
247-x0 - Vector *
248-x2 - Register address
249-x3 - Register data
250-x4 - Display position X *
251-x6 - Display position Y *
252-x8 - VRAM bank 0 *
253-xA - VRAM bank 1 *
254-xF - Display flag
255-
256-The register address corresponds to addresses 0xFF00 to 0xFFFF of Game Boy
257-memory, and then you can read/write the data by the register data port.
258-
259-Display position is the top-left corner of the Game Boy display inside of
260-the varvara display.
261-
262-The display flag bits can be:
263-
264-* bit0 = Display Game Boy screen. The varvara foreground layer is displayed
265-in front of the Game Boy screen; the varvara background layer is suppressed
266-in the area where the Game Boy screen is displayed.
267-
268-* bit1 = Display objects outside of Game Boy bounding box. (If not set, the
269-objects cannot be displayed outside of this bounding box.)
270-
271-* bit2 = Use varvara palettes for Game Boy display.
272-
273-Note that the varvara audio and Game Boy audio can be mixed together.
274-
+0, -5
1@@ -1,5 +0,0 @@
2-http://100r.co/site/uxn.html
3-http://wiki.xxiivv.com/site/uxntal_reference.html
4-http://wiki.xxiivv.com/site/varvara.html
5-http://permacomputing.net/
6-
D main.c
+0, -1986
   1@@ -1,1986 +0,0 @@
   2-#if 0
   3-gcc -s -O2 -Wno-unused-result -fwrapv main.c `sdl-config --cflags --libs`
   4-exit
   5-#endif
   6-
   7-// This file is public domain.
   8-
   9-#include "SDL.h"
  10-#include <dirent.h>
  11-#include <err.h>
  12-#include <fcntl.h>
  13-#include <stdio.h>
  14-#include <stdlib.h>
  15-#include <string.h>
  16-#include <sys/stat.h>
  17-#include <sys/types.h>
  18-#include <time.h>
  19-#include <unistd.h>
  20-
  21-// Subprocess support
  22-#include <signal.h>
  23-#include <sys/wait.h>
  24-
  25-#ifdef __linux
  26-#include <pty.h>
  27-#include <sys/prctl.h>
  28-#endif
  29-
  30-#ifdef __NetBSD__
  31-#include <sys/ioctl.h>
  32-#include <util.h>
  33-#endif
  34-
  35-static const Uint8 fontdata[]={ // font for built-in menus
  36-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x78,0x78,0x30,0x30,0x00,0x30,0x00,
  37-  0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00,0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00,
  38-  0x30,0x7C,0xC0,0x78,0x0C,0xF8,0x30,0x00,0x00,0xC6,0xCC,0x18,0x30,0x66,0xC6,0x00,
  39-  0x38,0x6C,0x38,0x76,0xDC,0xCC,0x76,0x00,0x60,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,
  40-  0x18,0x30,0x60,0x60,0x60,0x30,0x18,0x00,0x60,0x30,0x18,0x18,0x18,0x30,0x60,0x00,
  41-  0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00,0x00,0x30,0x30,0xFC,0x30,0x30,0x00,0x00,
  42-  0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,
  43-  0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x00,
  44-  0x7C,0xC6,0xCE,0xDE,0xF6,0xE6,0x7C,0x00,0x30,0x70,0x30,0x30,0x30,0x30,0xFC,0x00,
  45-  0x78,0xCC,0x0C,0x38,0x60,0xCC,0xFC,0x00,0x78,0xCC,0x0C,0x38,0x0C,0xCC,0x78,0x00,
  46-  0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x1E,0x00,0xFC,0xC0,0xF8,0x0C,0x0C,0xCC,0x78,0x00,
  47-  0x38,0x60,0xC0,0xF8,0xCC,0xCC,0x78,0x00,0xFC,0xCC,0x0C,0x18,0x30,0x30,0x30,0x00,
  48-  0x78,0xCC,0xCC,0x78,0xCC,0xCC,0x78,0x00,0x78,0xCC,0xCC,0x7C,0x0C,0x18,0x70,0x00,
  49-  0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x60,
  50-  0x18,0x30,0x60,0xC0,0x60,0x30,0x18,0x00,0x00,0x00,0xFC,0x00,0x00,0xFC,0x00,0x00,
  51-  0x60,0x30,0x18,0x0C,0x18,0x30,0x60,0x00,0x78,0xCC,0x0C,0x18,0x30,0x00,0x30,0x00,
  52-  0x7C,0xC6,0xDE,0xDE,0xDE,0xC0,0x78,0x00,0x30,0x78,0xCC,0xCC,0xFC,0xCC,0xCC,0x00,
  53-  0xFC,0x66,0x66,0x7C,0x66,0x66,0xFC,0x00,0x3C,0x66,0xC0,0xC0,0xC0,0x66,0x3C,0x00,
  54-  0xF8,0x6C,0x66,0x66,0x66,0x6C,0xF8,0x00,0xFE,0x62,0x68,0x78,0x68,0x62,0xFE,0x00,
  55-  0xFE,0x62,0x68,0x78,0x68,0x60,0xF0,0x00,0x3C,0x66,0xC0,0xC0,0xCE,0x66,0x3E,0x00,
  56-  0xCC,0xCC,0xCC,0xFC,0xCC,0xCC,0xCC,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x78,0x00,
  57-  0x1E,0x0C,0x0C,0x0C,0xCC,0xCC,0x78,0x00,0xE6,0x66,0x6C,0x78,0x6C,0x66,0xE6,0x00,
  58-  0xF0,0x60,0x60,0x60,0x62,0x66,0xFE,0x00,0xC6,0xEE,0xFE,0xFE,0xD6,0xC6,0xC6,0x00,
  59-  0xC6,0xE6,0xF6,0xDE,0xCE,0xC6,0xC6,0x00,0x38,0x6C,0xC6,0xC6,0xC6,0x6C,0x38,0x00,
  60-  0xFC,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00,0x78,0xCC,0xCC,0xCC,0xDC,0x78,0x1C,0x00,
  61-  0xFC,0x66,0x66,0x7C,0x6C,0x66,0xE6,0x00,0x78,0xCC,0xE0,0x70,0x1C,0xCC,0x78,0x00,
  62-  0xFC,0xB4,0x30,0x30,0x30,0x30,0x78,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xFC,0x00,
  63-  0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x30,0x00,0xC6,0xC6,0xC6,0xD6,0xFE,0xEE,0xC6,0x00,
  64-  0xC6,0xC6,0x6C,0x38,0x38,0x6C,0xC6,0x00,0xCC,0xCC,0xCC,0x78,0x30,0x30,0x78,0x00,
  65-  0xFE,0xC6,0x8C,0x18,0x32,0x66,0xFE,0x00,0x78,0x60,0x60,0x60,0x60,0x60,0x78,0x00,
  66-  0xC0,0x60,0x30,0x18,0x0C,0x06,0x02,0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x78,0x00,
  67-  0x10,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
  68-  0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x0C,0x7C,0xCC,0x76,0x00,
  69-  0xE0,0x60,0x60,0x7C,0x66,0x66,0xDC,0x00,0x00,0x00,0x78,0xCC,0xC0,0xCC,0x78,0x00,
  70-  0x1C,0x0C,0x0C,0x7C,0xCC,0xCC,0x76,0x00,0x00,0x00,0x78,0xCC,0xFC,0xC0,0x78,0x00,
  71-  0x38,0x6C,0x60,0xF0,0x60,0x60,0xF0,0x00,0x00,0x00,0x76,0xCC,0xCC,0x7C,0x0C,0xF8,
  72-  0xE0,0x60,0x6C,0x76,0x66,0x66,0xE6,0x00,0x30,0x00,0x70,0x30,0x30,0x30,0x78,0x00,
  73-  0x0C,0x00,0x0C,0x0C,0x0C,0xCC,0xCC,0x78,0xE0,0x60,0x66,0x6C,0x78,0x6C,0xE6,0x00,
  74-  0x70,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00,0xCC,0xFE,0xFE,0xD6,0xC6,0x00,
  75-  0x00,0x00,0xF8,0xCC,0xCC,0xCC,0xCC,0x00,0x00,0x00,0x78,0xCC,0xCC,0xCC,0x78,0x00,
  76-  0x00,0x00,0xDC,0x66,0x66,0x7C,0x60,0xF0,0x00,0x00,0x76,0xCC,0xCC,0x7C,0x0C,0x1E,
  77-  0x00,0x00,0xDC,0x76,0x66,0x60,0xF0,0x00,0x00,0x00,0x7C,0xC0,0x78,0x0C,0xF8,0x00,
  78-  0x10,0x30,0x7C,0x30,0x30,0x34,0x18,0x00,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0x76,0x00,
  79-  0x00,0x00,0xCC,0xCC,0xCC,0x78,0x30,0x00,0x00,0x00,0xC6,0xD6,0xFE,0xFE,0x6C,0x00,
  80-  0x00,0x00,0xC6,0x6C,0x38,0x6C,0xC6,0x00,0x00,0x00,0xCC,0xCC,0xCC,0x7C,0x0C,0xF8,
  81-  0x00,0x00,0xFC,0x98,0x30,0x64,0xFC,0x00,0x1C,0x30,0x30,0xE0,0x30,0x30,0x1C,0x00,
  82-  0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,0xE0,0x30,0x30,0x1C,0x30,0x30,0xE0,0x00,
  83-  0x76,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,
  84-};
  85-
  86-#define EXPANDED_MEMORY 8
  87-#define MEMSIZE ((EXPANDED_MEMORY+1)*0x10000)
  88-
  89-#define GET16(p) (((p)[0]<<8)|(p)[1])
  90-#define PUT16(p,q) ((p)[0]=(q)>>8,(p)[1]=(q))
  91-
  92-typedef struct {
  93-  Uint8 p;
  94-  Uint8 d[256];
  95-} Stack;
  96-
  97-typedef struct Device {
  98-  Uint8 d[16];
  99-  Uint8(*in)(struct Device*,Uint8);
 100-  void(*out)(struct Device*,Uint8);
 101-  void(*exp)(struct Device*,Uint16);
 102-  void*aux;
 103-} Device;
 104-
 105-typedef struct {
 106-  FILE*file;
 107-  DIR*dir;
 108-  char name[4096];
 109-  struct dirent*de;
 110-  Uint8 mode;
 111-} UxnFile;
 112-
 113-typedef struct {
 114-  Uint32 envtime,phase,freq;
 115-  Uint32 length,end,pos;
 116-  Uint32 env[4];
 117-  Uint8 vol[2];
 118-} UxnAudio;
 119-
 120-typedef struct {
 121-  Uint8*data;
 122-  Uint32 addr;
 123-  Uint16 len;
 124-  Uint8 kind,stage;
 125-} Script;
 126-
 127-static SDL_Color colors[64]={
 128-  // 0
 129-  {0xFF,0xFF,0xFF,0},
 130-  {0x00,0x00,0x00,0},
 131-  {0x00,0xFF,0xFF,0},
 132-  {0xFF,0x00,0x00,0},
 133-  {0xAA,0xAA,0xAA,0},
 134-  {0x43,0x43,0x33,0},
 135-  {0x43,0xAA,0xAA,0},
 136-  {0xAA,0x43,0x33,0},
 137-  // 1
 138-  {0x00,0x00,0x00,0},
 139-  {0xFF,0xFF,0xFF,0},
 140-  {0x00,0xFF,0xFF,0},
 141-  {0xFF,0x00,0x00,0},
 142-  {0x43,0x43,0x33,0},
 143-  {0xAA,0xAA,0xAA,0},
 144-  {0x43,0xAA,0xAA,0},
 145-  {0xAA,0x43,0x33,0},
 146-  // 2
 147-  {0x10,0x30,0x10,0},
 148-  {0x60,0xE0,0x60,0},
 149-  {0x60,0x60,0xE0,0},
 150-  {0xE0,0x60,0x60,0},
 151-  {0x10,0x80,0x10,0},
 152-  {0x38,0xFF,0xF8,0},
 153-  {0xF8,0x38,0xFF,0},
 154-  {0xFF,0xF8,0x38,0},
 155-  // 3
 156-  {0x55,0x55,0x55,0},
 157-  {0xFF,0x55,0x00,0},
 158-  {0x00,0x00,0x00,0},
 159-  {0xFF,0xFF,0xFF,0},
 160-  {0x55,0x55,0x55,0},
 161-  {0xFF,0x55,0x00,0},
 162-  {0x00,0x00,0x00,0},
 163-  {0xFF,0xFF,0xFF,0},
 164-  // 4
 165-  {0x55,0x55,0x55,0},
 166-  {0xFF,0x55,0x00,0},
 167-  {0xFF,0xFF,0xFF,0},
 168-  {0x00,0x00,0x00,0},
 169-  {0x55,0x55,0x55,0},
 170-  {0xFF,0x55,0x00,0},
 171-  {0xFF,0xFF,0xFF,0},
 172-  {0x00,0x00,0x00,0},
 173-  // 5
 174-  {0xFF,0xFF,0xFF,0},
 175-  {0xAA,0xAA,0xAA,0},
 176-  {0x55,0x55,0x55,0},
 177-  {0x00,0x00,0x00,0},
 178-  {0xFF,0x80,0x00,0},
 179-  {0xC6,0x60,0x00,0},
 180-  {0x94,0x40,0x00,0},
 181-  {0x72,0x20,0x00,0},
 182-  // 6
 183-  {0xAA,0xAA,0xAA,0},
 184-  {0x00,0x00,0x00,0},
 185-  {0xAA,0xAA,0xAA,0},
 186-  {0x00,0x00,0x00,0},
 187-  {0x91,0xAA,0x9A,0},
 188-  {0x0D,0x0E,0x0E,0},
 189-  {0x91,0xAA,0x9A,0},
 190-  {0x19,0x15,0x00,0},
 191-  // 7
 192-  {0xFF,0xFF,0xFF,0},
 193-  {0x00,0x00,0x00,0},
 194-  {0x77,0xCC,0xAA,0},
 195-  {0x99,0x22,0x44,0},
 196-  {0xFF,0xFF,0xFF,0},
 197-  {0x00,0x00,0x00,0},
 198-  {0x77,0xCC,0xAA,0},
 199-  {0x99,0x22,0x44,0},
 200-};
 201-
 202-static Uint8 blend[4][16]={
 203-  {4,0,0,0,1,4,1,1,2,2,4,2,3,3,3,4},
 204-  {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3},
 205-  {1,2,3,1,1,2,3,1,1,2,3,1,1,2,3,1},
 206-  {2,3,1,2,2,3,1,2,2,3,1,2,2,3,1,2},
 207-};
 208-
 209-static const Uint32 notes[12]={
 210-  0x20000000,0x21e71f26,0x23eb3588,0x260dfc14,0x285145f3,0x2ab70212,
 211-  0x2d413ccd,0x2ff221af,0x32cbfd4a,0x35d13f33,0x39047c0f,0x3c686fce,
 212-};
 213-
 214-static Uint8 mem[MEMSIZE];
 215-static Stack ds,rs;
 216-static Device device[16];
 217-static Uint16 scr_w,scr_h;
 218-static Uint8*bglayer;
 219-static Uint8*fglayer;
 220-static UxnFile uxnfile0;
 221-static UxnFile uxnfile1;
 222-static FILE*inf;
 223-static FILE*outf;
 224-
 225-static const char*rom_name;
 226-static Uint8 use_console=1;
 227-static Uint8 use_screen=1;
 228-static Uint8 use_mouse=1;
 229-static Uint8 use_debug=0;
 230-static Uint8 use_utc=0;
 231-static Uint8 use_extension=0;
 232-static Uint8 use_thread=0;
 233-static Uint8 hide_cursor=0;
 234-static Uint8 allow_write=0;
 235-static Uint8 joypad_repeat=0;
 236-static Uint16 scroll_size=1;
 237-static Uint8 zoom=1;
 238-static Uint8 disallow_size_change=0;
 239-static Sint16 default_width=512;
 240-static Sint16 default_height=320;
 241-static Uint32 scrflags=SDL_SWSURFACE;
 242-static Uint16 timer_rate=16;
 243-static Uint8 paused=0;
 244-static Uint8 picture_changed=0;
 245-static Uint8 size_changed=0;
 246-static volatile Uint8 timer_expired=0;
 247-static SDL_Surface*screen;
 248-static Uint8 layers;
 249-static Uint8 palet=7;
 250-static Uint8 touch_mode=0;
 251-static SDL_cond*stdin_cond;
 252-static Uint8 screencompat=0x03;
 253-static int randomfd=-1;
 254-
 255-static Uint16 scriptc;
 256-static Script*scriptv;
 257-static FILE*scriptf;
 258-
 259-static Sint32*audio_option;
 260-static SDL_AudioSpec audiospec;
 261-
 262-static Uint8 joy_mask;
 263-static Uint8 joy_player[4];
 264-static Uint8 joy_hat,joy_hat_mode;
 265-static Uint8 joy_axis_x,joy_axis_y,joy_axis_mode;
 266-static Uint8 joy_button_map[128];
 267-static Uint16 joy_sensitivity=8192;
 268-
 269-static Uint8 debugger=0;
 270-static Uint16 breakpoint=0;
 271-static Uint16 break_pc=0x0100;
 272-static Uint8 debug_op=0;
 273-
 274-static void debug(int i) {
 275-  int j;
 276-  if(i) fprintf(stderr,"Debug(%02X)\n",i);
 277-  fprintf(stderr,"ds:");
 278-  for(i=0;i<ds.p;i++) fprintf(stderr," %02X",ds.d[i]);
 279-  fputc('\n',stderr);
 280-  fprintf(stderr,"rs:");
 281-  for(i=0;i<rs.p;i++) fprintf(stderr," %02X",rs.d[i]);
 282-  fputc('\n',stderr);
 283-  fprintf(stderr,"   0. 1. 2. 3. 4. 5. 6. 7. 8. 9. A. B. C. D. E. F.\n");
 284-  for(i=0;i<16;i++) {
 285-    fprintf(stderr,"%1X:",i);
 286-    for(j=0;j<16;j++) fprintf(stderr," %02X",device[i].d[j]);
 287-    if(device[i].aux) fprintf(stderr," *");
 288-    fputc('\n',stderr);
 289-  }
 290-}
 291-
 292-static void uxnerr(int n,int pc) {
 293-  if(use_debug) debug(-1);
 294-  fflush(outf);
 295-  fflush(stderr);
 296-  errx(2,"Uxn error %d at 0x%04X",n,pc);
 297-}
 298-
 299-#define Push8(z) ({ s->d[s->p++]=(z); })
 300-#define Push16(z) ({ s->d[s->p++]=(z)>>8; s->d[s->p++]=(z); })
 301-#define Push(z) ({ if(v&0x20) s->d[s->p++]=(z)>>8; s->d[s->p++]=(z); })
 302-#define Pop8(z) ({ z=s->d[0xFF&--k]; if(v<0x80) s->p=k; })
 303-#define Pop16(z) ({ z=s->d[0xFF&--k]; z|=s->d[0xFF&--k]<<8; if(v<0x80) s->p=k; })
 304-#define Pop(z) ({ if(v&0x20) Pop16(z); else Pop8(z); })
 305-
 306-static void run(Uint16 pc) {
 307-  Stack*s;
 308-  Uint8 k,v;
 309-  Uint16 x,y,z;
 310-  if(!pc) return;
 311-  start:
 312-  while(v=mem[pc++]) {
 313-    if(pc==breakpoint && use_screen) goto stop;
 314-    s=(v&0x40?&rs:&ds);
 315-    k=s->p;
 316-    switch(v&0x1F?:v) {
 317-      case 0x01: Pop(x); Push(x+1); break;
 318-      case 0x02: Pop(x); break;
 319-      case 0x03: Pop(x); Pop(y); Push(x); break;
 320-      case 0x04: Pop(x); Pop(y); Push(x); Push(y); break;
 321-      case 0x05: Pop(z); Pop(y); Pop(x); Push(y); Push(z); Push(x); break;
 322-      case 0x06: Pop(x); Push(x); Push(x); break;
 323-      case 0x07: Pop(x); Pop(y); Push(y); Push(x); Push(y); break;
 324-      case 0x08: Pop(x); Pop(y); Push8(y==x?1:0); break;
 325-      case 0x09: Pop(x); Pop(y); Push8(y!=x?1:0); break;
 326-      case 0x0A: Pop(x); Pop(y); Push8(y>x?1:0); break;
 327-      case 0x0B: Pop(x); Pop(y); Push8(y<x?1:0); break;
 328-      case 0x0C: Pop(x); jump: if(v&0x20) pc=x; else pc+=(Sint8)x; break;
 329-      case 0x0D: Pop(x); Pop8(y); if(y) goto jump; break;
 330-      case 0x0E: Pop(x); y=pc; goto stash;
 331-      case 0x0F: Pop(x); goto stash;
 332-      case 0x10: Pop8(x); peek: if(v&0x20) x=GET16(mem+x); else x=mem[x]; Push(x); break;
 333-      case 0x11: Pop8(x); Pop(y); poke: if(v&0x20) PUT16(mem+x,y); else mem[x]=y; break;
 334-      case 0x12: Pop8(x); x=pc+(Sint8)x; goto peek; break;
 335-      case 0x13: Pop8(x); Pop(y); x=pc+(Sint8)x; goto poke; break;
 336-      case 0x14: Pop16(x); goto peek; break;
 337-      case 0x15: Pop16(x); Pop(y); goto poke; break;
 338-      case 0x16:
 339-        Pop8(x);
 340-        z=(x>>4)&15; x&=15;
 341-        y=device[z].in(device+z,x);
 342-        if(v&0x20) y=(y<<8)|device[z].in(device+z,x+1);
 343-        Push(y);
 344-        break;
 345-      case 0x17:
 346-        Pop8(x); Pop(y);
 347-        z=(x>>4)&15; x&=15;
 348-        if(v&0x20) {
 349-          device[z].d[x]=y>>8;
 350-          device[z].d[(x+1)&15]=y;
 351-          device[z].out(device+z,x);
 352-          device[z].out(device+z,x+1);
 353-        } else {
 354-          device[z].d[x]=y;
 355-          device[z].out(device+z,x);
 356-        }
 357-        break;
 358-      case 0x18: Pop(x); Pop(y); Push(y+x); break;
 359-      case 0x19: Pop(x); Pop(y); Push(y-x); break;
 360-      case 0x1A: Pop(x); Pop(y); Push(y*x); break;
 361-      case 0x1B: Pop(x); Pop(y); Push(x?y/x:0); break;
 362-      case 0x1C: Pop(x); Pop(y); Push(y&x); break;
 363-      case 0x1D: Pop(x); Pop(y); Push(y|x); break;
 364-      case 0x1E: Pop(x); Pop(y); Push(y^x); break;
 365-      case 0x1F: Pop8(x); Pop(y); z=x>>4; x&=15; Push((y>>x)<<z); break;
 366-      case 0x20: Pop8(x); pc+=x?GET16(mem+pc)+2:2; break;
 367-      case 0x40: pc+=GET16(mem+pc)+2; break;
 368-      case 0x60: Push16(pc+2); pc+=GET16(mem+pc)+2; break;
 369-      case 0x80: case 0xC0: Push8(mem[pc++]); break;
 370-      case 0xA0: case 0xE0: Push8(mem[pc++]); Push8(mem[pc++]); break;
 371-    }
 372-    continue;
 373-    stash:
 374-    s=(v&0x40?&ds:&rs);
 375-    if(v&1) {
 376-      Push(x);
 377-    } else {
 378-      Push16(y);
 379-      if(v&0x20) pc=x; else pc+=(Sint8)x;
 380-    }
 381-  }
 382-  if(pc==breakpoint && use_screen) {
 383-    stop:
 384-    paused=debugger=picture_changed=1;
 385-    break_pc=pc-1;
 386-  }
 387-  fflush(outf);
 388-}
 389-
 390-static void load_rom(void) {
 391-  FILE*fp=fopen(rom_name,"r");
 392-  if(!fp) err(1,"Cannot load program file");
 393-  memset(mem,0,MEMSIZE);
 394-  fread(mem+0x0100,1,MEMSIZE-0x0100,fp);
 395-  if(ferror(fp)) err(1,"Cannot load program file");
 396-  fclose(fp);
 397-}
 398-
 399-static Uint8 default_in(Device*misc1,Uint8 misc2) { return misc1->d[misc2&15]; }
 400-static void default_out(Device*misc1,Uint8 misc2) {}
 401-static void default_exp(Device*misc1,Uint16 misc2) {}
 402-
 403-static Uint8 system_in(Device*dev,Uint8 id) {
 404-  switch(id) {
 405-    case 4: return ds.p;
 406-    case 5: return rs.p;
 407-    default: return dev->d[id];
 408-  }
 409-}
 410-
 411-static void system_out(Device*dev,Uint8 id) {
 412-  Uint16 x;
 413-  switch(id) {
 414-    case 3:
 415-      x=GET16(dev->d+2);
 416-      device[mem[x]>>4].exp(device+(mem[x]>>4),x);
 417-      break;
 418-    case 4:
 419-      ds.p=dev->d[4];
 420-      break;
 421-    case 5:
 422-      rs.p=dev->d[5];
 423-      break;
 424-    case 8 ... 13:
 425-      colors[070].r=colors[074].r=(dev->d[8]>>4)*0x11;
 426-      colors[071].r=colors[075].r=(dev->d[8]&15)*0x11;
 427-      colors[072].r=colors[076].r=(dev->d[9]>>4)*0x11;
 428-      colors[073].r=colors[077].r=(dev->d[9]&15)*0x11;
 429-      colors[070].g=colors[074].g=(dev->d[10]>>4)*0x11;
 430-      colors[071].g=colors[075].g=(dev->d[10]&15)*0x11;
 431-      colors[072].g=colors[076].g=(dev->d[11]>>4)*0x11;
 432-      colors[073].g=colors[077].g=(dev->d[11]&15)*0x11;
 433-      colors[070].b=colors[074].b=(dev->d[12]>>4)*0x11;
 434-      colors[071].b=colors[075].b=(dev->d[12]&15)*0x11;
 435-      colors[072].b=colors[076].b=(dev->d[13]>>4)*0x11;
 436-      colors[073].b=colors[077].b=(dev->d[13]&15)*0x11;
 437-      if(screen && palet==7) {
 438-        SDL_SetColors(screen,colors+palet*8,0,8);
 439-        picture_changed=1;
 440-      }
 441-      break;
 442-    case 14: if(dev->d[14] && use_debug) debug(dev->d[14]); break;
 443-    case 15: if(dev->d[15]) exit(dev->d[15]&0x7F); break;
 444-  }
 445-}
 446-
 447-// Subprocess support
 448-
 449-static char enable_subprocess=0;
 450-static char *fork_args[4] = {"/bin/sh", "-c", "", NULL};
 451-static int child_mode;
 452-static int to_child_fd[2];
 453-static int from_child_fd[2];
 454-static int saved_in;
 455-static int saved_out;
 456-static pid_t child_pid;
 457-
 458-/* call after we're sure the process has exited */
 459-static void console_clean_after_child(void) {
 460-  child_pid = 0;
 461-  if(child_mode & 0x01) {
 462-    close(to_child_fd[1]);
 463-    dup2(saved_out, 1);
 464-  }
 465-  if(child_mode & (0x04 | 0x02)) {
 466-    close(from_child_fd[0]);
 467-    dup2(saved_in, 0);
 468-  }
 469-  child_mode = 0;
 470-  saved_in = -1;
 471-  saved_out = -1;
 472-}
 473-
 474-static void console_start_fork_pipe(Device*dev) {
 475-  pid_t pid;
 476-  pid_t parent_pid = getpid();
 477-  int addr = GET16(dev->d+12);
 478-  fflush(stdout);
 479-  if(child_mode & 0x08) {
 480-    dev->d[6] = dev->d[5] = 0;
 481-    return;
 482-  }
 483-  if(child_mode & 0x01) {
 484-    /* parent writes to child's stdin */
 485-    if(pipe(to_child_fd) == -1) {
 486-      dev->d[6] = dev->d[5] = 255;
 487-      fprintf(stderr, "pipe error: to child\n");
 488-      return;
 489-    }
 490-  }
 491-  if(child_mode & (0x04 | 0x02)) {
 492-    /* parent reads from child's stdout and/or stderr */
 493-    if(pipe(from_child_fd) == -1) {
 494-      dev->d[6] = dev->d[5] = 255;
 495-      fprintf(stderr, "pipe error: from child\n");
 496-      return;
 497-    }
 498-  }
 499-
 500-  fork_args[2] = (char *)(mem + GET16(dev->d+12));
 501-  pid = fork();
 502-  if(pid < 0) { /* failure */
 503-    dev->d[6] = dev->d[5] = 255;
 504-    fprintf(stderr, "fork failure\n");
 505-  } else if(pid == 0) { /* child */
 506-
 507-#ifdef __linux__
 508-    int r = prctl(PR_SET_PDEATHSIG, SIGTERM);
 509-    if(r == -1) {
 510-      perror(0);
 511-      exit(6);
 512-    }
 513-    if(getppid() != parent_pid) exit(13);
 514-#endif
 515-
 516-    if(child_mode & 0x01) {
 517-      dup2(to_child_fd[0], 0);
 518-      close(to_child_fd[1]);
 519-    }
 520-    if(child_mode & (0x04 | 0x02)) {
 521-      if(child_mode & 0x02) dup2(from_child_fd[1], 1);
 522-      if(child_mode & 0x04) dup2(from_child_fd[1], 2);
 523-      close(from_child_fd[0]);
 524-    }
 525-    fflush(stdout);
 526-    execvp(fork_args[0], fork_args);
 527-    exit(1);
 528-  } else { /*parent*/
 529-    child_pid = pid;
 530-    dev->d[5] = 1;
 531-    dev->d[6] = 0;
 532-    if(child_mode & 0x01) {
 533-      saved_out = dup(1);
 534-      dup2(to_child_fd[1], 1);
 535-      close(to_child_fd[0]);
 536-    }
 537-    if(child_mode & (0x04 | 0x02)) {
 538-      saved_in = dup(0);
 539-      dup2(from_child_fd[0], 0);
 540-      close(from_child_fd[1]);
 541-    }
 542-  }
 543-}
 544-
 545-static void console_check_child(Device*dev) {
 546-  int wstatus;
 547-  if(child_pid) {
 548-    if(waitpid(child_pid, &wstatus, WNOHANG)) {
 549-      dev->d[5] = 255;
 550-      dev->d[6] = WEXITSTATUS(wstatus);
 551-      console_clean_after_child();
 552-    } else {
 553-      dev->d[5] = 1;
 554-      dev->d[6] = 0;
 555-    }
 556-  }
 557-}
 558-
 559-static void console_kill_child(Device*dev) {
 560-  int wstatus;
 561-  if(child_pid) {
 562-    kill(child_pid, 9);
 563-    if(waitpid(child_pid, &wstatus, WNOHANG)) {
 564-      dev->d[5] = 255;
 565-      dev->d[6] = WEXITSTATUS(wstatus);
 566-      console_clean_after_child();
 567-    }
 568-  }
 569-}
 570-
 571-static void console_start_fork(Device*dev) {
 572-  fflush(stderr);
 573-  console_kill_child(dev);
 574-  child_mode = dev->d[14];
 575-  console_start_fork_pipe(dev);
 576-}
 577-
 578-static void close_console(Device*dev) {
 579-  console_kill_child(dev);
 580-}
 581-
 582-static Uint8 subprocess_console_in(Device*dev,Uint8 id) {
 583-  switch(id) {
 584-    case 5: case 6: console_check_child(dev); break;
 585-  }
 586-  return dev->d[id];
 587-}
 588-
 589-// End of subprocess support
 590-
 591-static void console_out(Device*dev,Uint8 id) {
 592-  switch(id) {
 593-    case 8: fputc(dev->d[8],outf); break;
 594-    case 9: fputc(dev->d[9],stderr); break;
 595-    // Subprocess
 596-    case 15: if(enable_subprocess) console_start_fork(dev); break;
 597-  }
 598-}
 599-
 600-static Uint16 files_stat(int fd,char*name,Uint16 len,Uint8*out) {
 601-  struct stat st;
 602-  if(strlen(name)+7>len || fstatat(fd,name,&st,0)) return 0;
 603-  if(S_ISDIR(st.st_mode)) return snprintf(out,len,"---- %s\n",name);
 604-  else if(st.st_size<0x10000) return snprintf(out,len,"%04x %s\n",(unsigned int)st.st_size,name);
 605-  else return snprintf(out,len,"???? %s\n",name);
 606-  return 0;
 607-}
 608-
 609-static Uint32 files_seek(UxnFile*uf,Uint8 mode,Uint32 len) {
 610-  switch(uf->mode) {
 611-    case 1: case 2: case 4:
 612-      switch(mode) {
 613-        case 0: fseek(uf->file,len,SEEK_SET); break;
 614-        case 1: fseek(uf->file,(Sint32)len,SEEK_CUR); break;
 615-        case 2: fseek(uf->file,(Sint32)len,SEEK_END); break;
 616-        case 3: return ftell(uf->file);
 617-      }
 618-      break;
 619-    case 3:
 620-      if(!mode && !len) rewinddir(uf->dir);
 621-      uf->de=0;
 622-      break;
 623-  }
 624-  return 0;
 625-}
 626-
 627-static int files_set(Device*dev,int rw) {
 628-  // rw: 0(close) 1(read) 2(write) 3(both)
 629-  // return: 1 if file opened, 0 if not opened
 630-  Uint8 m=dev->d[7];
 631-  UxnFile*uf=dev->aux;
 632-  if(uf->file) fclose(uf->file);
 633-  if(uf->dir) closedir(uf->dir);
 634-  uf->file=0;
 635-  uf->dir=0;
 636-  uf->de=0;
 637-  uf->mode=0;
 638-  dev->d[2]=dev->d[3]=0;
 639-  if(!uf->name[0]) return 0;
 640-  if(rw==1) {
 641-    if(uf->dir=opendir(uf->name)) {
 642-      uf->mode=3;
 643-      return 1;
 644-    } else if(uf->file=fopen(uf->name,"r")) {
 645-      uf->mode=1;
 646-      return 1;
 647-    } else {
 648-      warn("Cannot open file '%s' for reading",uf->name);
 649-    }
 650-  } else if(rw==2 && allow_write) {
 651-    if(uf->file=fopen(uf->name,m?"a":"w")) {
 652-      uf->mode=2;
 653-      return 1;
 654-    } else {
 655-      warn("Cannot open file '%s' for writing",uf->name);
 656-    }
 657-  } else if(rw==3) {
 658-    if(allow_write && (uf->file=fopen(uf->name,"r+"))) {
 659-      uf->mode=4;
 660-      return 1;
 661-    } else if(uf->file=fopen(uf->name,"r")) {
 662-      uf->mode=1;
 663-      return 1;
 664-    } else {
 665-      warn("Cannot open file '%s' for reading/writing",uf->name);
 666-    }
 667-  }
 668-  return 0;
 669-}
 670-
 671-static void files_out(Device*dev,Uint8 id) {
 672-  UxnFile*uf=dev->aux;
 673-  Uint16 len=GET16(dev->d+10);
 674-  Uint16 addr,x,y;
 675-  int i;
 676-  switch(id) {
 677-    case 5:
 678-      addr=GET16(dev->d+4);
 679-      dev->d[2]=dev->d[3]=0;
 680-      if(!uf->name[0]) break;
 681-      y=files_stat(AT_FDCWD,uf->name,len,mem+addr);
 682-      if(y<=len) PUT16(dev->d+2,y);
 683-      break;
 684-    case 7:
 685-      if(use_extension) files_set(dev,0);
 686-      break;
 687-    case 9:
 688-      addr=GET16(dev->d+8);
 689-      files_set(dev,0);
 690-      x=GET16(dev->d+8);
 691-      for(i=0;i<4095;i++) {
 692-        if(!(uf->name[i]=mem[x+i])) break;
 693-        // if(mem[x+i]=='/') uf->name[i]=0;
 694-      }
 695-      if(use_debug) fprintf(stderr,"! File: %s\n",uf->name);
 696-      break;
 697-    case 13:
 698-      addr=GET16(dev->d+12);
 699-      dev->d[2]=dev->d[3]=0;
 700-      read:
 701-      if(uf->mode==1 || uf->mode==4) {
 702-        if(!len) break;
 703-        x=fread(mem+addr,1,len,uf->file);
 704-        PUT16(dev->d+2,x);
 705-        if(ferror(uf->file)) {
 706-          warn("Error reading file '%s'",uf->name);
 707-          clearerr(uf->file);
 708-        }
 709-      } else if(uf->mode==3) {
 710-        do {
 711-          if(uf->de) {
 712-            if(x=files_stat(dirfd(uf->dir),uf->de->d_name,len,mem+addr)) {
 713-              addr+=x;
 714-              len-=x;
 715-            } else {
 716-              break;
 717-            }
 718-          }
 719-        } while(uf->de=readdir(uf->dir));
 720-        PUT16(dev->d+2,addr-GET16(dev->d+12));
 721-      } else {
 722-        if(files_set(dev,1)) goto read;
 723-      }
 724-      break;
 725-    case 15:
 726-      addr=GET16(dev->d+14);
 727-      dev->d[2]=dev->d[3]=0;
 728-      if(!allow_write) {
 729-        disallow:
 730-        warnx("Not allowed to write to file '%s'.",uf->name);
 731-        break;
 732-      }
 733-      write:
 734-      if(uf->mode==2 || uf->mode==4) {
 735-        if(!len) break;
 736-        x=fwrite(mem+addr,1,len,uf->file);
 737-        PUT16(dev->d+2,x);
 738-        if(ferror(uf->file)) {
 739-          warn("Error writing file '%s'",uf->name);
 740-          clearerr(uf->file);
 741-        }
 742-      } else {
 743-        if(files_set(dev,2)) goto write;
 744-      }
 745-      break;
 746-  }
 747-}
 748-
 749-static Uint8 files_in(Device*dev,Uint8 id) {
 750-  UxnFile*uf=dev->aux;
 751-  int c;
 752-  switch(id) {
 753-    case 12: case 13:
 754-      dev->d[2]=dev->d[3]=0;
 755-      read:
 756-      if(uf->mode==1 || uf->mode==4) {
 757-        c=fgetc(uf->file);
 758-        if(c==EOF) {
 759-          if(ferror(uf->file)) {
 760-            warn("Error reading file '%s'",uf->name);
 761-            clearerr(uf->file);
 762-          }
 763-          c=0;
 764-        } else {
 765-          dev->d[3]=1;
 766-        }
 767-        return c;
 768-      } else if(uf->mode==3) {
 769-        return 0;
 770-      } else {
 771-        if(files_set(dev,1)) goto read;
 772-      }
 773-      return 0;
 774-    default: return dev->d[id];
 775-  }
 776-}
 777-
 778-static void files_exp(Device*dev,Uint16 addr) {
 779-  UxnFile*uf=dev->aux;
 780-  Uint32 x;
 781-  if(use_extension) switch(mem[addr]&15) {
 782-    case 0 ... 2:
 783-      x=GET16(mem+addr+1)<<16;
 784-      x|=GET16(mem+addr+3);
 785-      if(!uf->mode) files_set(dev,3);
 786-      files_seek(uf,mem[addr]&15,x);
 787-      break;
 788-    case 3:
 789-      x=files_seek(uf,3,0);
 790-      PUT16(mem+addr+1,x>>16);
 791-      PUT16(mem+addr+3,x);
 792-      break;
 793-  }
 794-}
 795-
 796-static Uint8 datetime_in(Device*dev,Uint8 id) {
 797-  time_t t=time(0);
 798-  struct tm r;
 799-  if(use_utc) gmtime_r(&t,&r); else localtime_r(&t,&r);
 800-  switch(id) {
 801-    case 0: return (r.tm_year+1900)>>8;
 802-    case 1: return r.tm_year+1900;
 803-    case 2: return r.tm_mon;
 804-    case 3: return r.tm_mday;
 805-    case 4: return r.tm_hour;
 806-    case 5: return r.tm_min;
 807-    case 6: return r.tm_sec;
 808-    case 7: return r.tm_wday;
 809-    case 8: return r.tm_yday>>8;
 810-    case 9: return r.tm_yday;
 811-    case 10: return r.tm_isdst;
 812-    default: return dev->d[id];
 813-  }
 814-}
 815-
 816-static Uint8 random_in(Device*dev,Uint8 id) {
 817-  Uint8 x[1];
 818-  if(read(randomfd,x,1)!=1) err(1,"Cannot read random numbers");
 819-  return *x;
 820-}
 821-
 822-static void set_cursor(void) {
 823-  if(hide_cursor) SDL_ShowCursor(paused || !use_mouse);
 824-}
 825-
 826-static Uint32 timer_callback(Uint32 interval) {
 827-  if(!timer_expired) {
 828-    SDL_Event e;
 829-    timer_expired=1;
 830-    e.type=SDL_USEREVENT;
 831-    SDL_PushEvent(&e);
 832-    timer_expired=1;
 833-  }
 834-  return interval;
 835-}
 836-
 837-static void set_screen_mode(int w,int h) {
 838-  picture_changed=size_changed=0;
 839-  free(bglayer);
 840-  if(screen) SDL_FreeSurface(screen);
 841-  if(w<1) w=1;
 842-  if(h<1) h=1;
 843-  scr_w=w;
 844-  scr_h=h;
 845-  screen=SDL_SetVideoMode(w*zoom,h*zoom,8,scrflags);
 846-  if(!screen) errx(1,"Cannot set screen mode: %s",SDL_GetError());
 847-  if(!bglayer) {
 848-    if(timer_rate) SDL_SetTimer(timer_rate,timer_callback);
 849-    if(audio_option) {
 850-      if(SDL_OpenAudio(&audiospec,0)) errx(1,"Cannot initialize SDL audio: %s",SDL_GetError());
 851-      SDL_PauseAudio(0);
 852-    }
 853-    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
 854-    SDL_WM_SetCaption(rom_name,rom_name);
 855-    set_cursor();
 856-    SDL_EnableUNICODE(1);
 857-  }
 858-  SDL_SetColors(screen,colors+palet*8,0,8);
 859-  bglayer=calloc(w*h,2);
 860-  if(!bglayer) err(1,"Memory allocation error");
 861-  fglayer=bglayer+w*h;
 862-}
 863-
 864-static void screen_fill(Uint8*p,Uint8 v,Uint16 x0,Uint16 y0,Uint16 x1,Uint16 y1) {
 865-  if(y1>scr_h) y1=scr_h;
 866-  if(x1>scr_w) x1=scr_w;
 867-  if(y0>=y1 || x0>=x1) return;
 868-  p+=y0*scr_w+x0;
 869-  x1-=x0;
 870-  while(y0++<y1) memset(p,v,x1),p+=scr_w;
 871-}
 872-
 873-static void draw_sprite(Uint16 x,Uint16 y,Uint16 addr,Uint8 v) {
 874-  Uint8 b=v&0x80;
 875-  Uint8 u;
 876-  Uint16 c;
 877-  Uint8*p=v&0x40?fglayer:bglayer;
 878-  Uint8*m;
 879-  if(x+8>scr_w || y+8>scr_h || addr>0x10000-(b?16:8)) return;
 880-  p+=y*scr_w+x;
 881-  m=mem+addr;
 882-  for(y=0;y<8;y++) {
 883-    c=m[y]|(b?m[y+8]<<8:0);
 884-    for(x=0;x<8;x++) {
 885-      u=(c&1)|((c>>7)&2);
 886-      c>>=1;
 887-      if((u=blend[u][v&0x0F])!=4) p[(y^(v&0x20?7:0))*scr_w+(x^(v&0x10?0:7))]=u;
 888-    }
 889-  }
 890-}
 891-
 892-static void screen_out(Device*dev,Uint8 id) {
 893-  int i,fx,fy;
 894-  Uint16 w;
 895-  Uint16 x=GET16(dev->d+8);
 896-  Uint16 y=GET16(dev->d+10);
 897-  Uint8 z=dev->d[id];
 898-  if(id<6 && disallow_size_change) {
 899-    PUT16(dev->d+2,scr_w);
 900-    PUT16(dev->d+4,scr_h);
 901-    return;
 902-  }
 903-  switch(id) {
 904-    case 2: case 3:
 905-      x=GET16(dev->d+2);
 906-      if(x!=scr_w) scr_w=x,size_changed=1;
 907-      break;
 908-    case 4: case 5:
 909-      x=GET16(dev->d+4);
 910-      if(x!=scr_h) scr_h=x,size_changed=1;
 911-      break;
 912-    case 14:
 913-      if(size_changed) set_screen_mode(scr_w,scr_h);
 914-      picture_changed=1;
 915-      if(z<0x80) {
 916-        if(x<scr_w && y<scr_h) (z&0x40?fglayer:bglayer)[x+y*scr_w]=z&3;
 917-        if(dev->d[6]&0x01) PUT16(dev->d+8,x+1);
 918-        if(dev->d[6]&0x02) PUT16(dev->d+10,y+1);
 919-      } else {
 920-        screen_fill(z&0x40?fglayer:bglayer,z&3,dev->d[14]&0x10?0:x,dev->d[14]&0x20?0:y,dev->d[14]&0x10?x:scr_w,dev->d[14]&0x20?y:scr_h);
 921-      }
 922-      break;
 923-    case 15:
 924-      if(size_changed) set_screen_mode(scr_w,scr_h);
 925-      picture_changed=1;
 926-      w=GET16(dev->d+12);
 927-      fx=((z&0x10)&&(screencompat&0x02)?-8:8);
 928-      fy=((z&0x20)&&(screencompat&0x02)?-8:8);
 929-      for(i=0;i<=(dev->d[6]>>4);i++) {
 930-        draw_sprite(x+i*(dev->d[6]&0x02?fx:0),y+i*(dev->d[6]&0x01?fy:0),w,z);
 931-        if(dev->d[6]&0x04) w+=z&0x80?16:8;
 932-      }
 933-      if(dev->d[6]&0x01) PUT16(dev->d+8,x+fx);
 934-      if(dev->d[6]&0x02) PUT16(dev->d+10,y+fy);
 935-      if(dev->d[6]&0x04) PUT16(dev->d+12,w);
 936-      break;
 937-  }
 938-}
 939-
 940-static void audio_out(Device*dev,Uint8 id) {
 941-  UxnAudio*a;
 942-  Uint32 s,n;
 943-  if(id!=15) return;
 944-  if(use_screen) SDL_LockAudio();
 945-  a=dev->aux;
 946-  a->env[0]=(dev->d[8]>>4)*audio_option['e'-'a'];
 947-  a->env[1]=(dev->d[8]&15)*audio_option['e'-'a'];
 948-  a->env[2]=(dev->d[9]>>4)*audio_option['e'-'a'];
 949-  a->env[3]=(dev->d[9]&15)*audio_option['e'-'a'];
 950-  a->length=n=GET16(dev->d+10);
 951-  a->pos=s=GET16(dev->d+12);
 952-  a->end=s+n;
 953-  if(dev->d[15]&0x80) a->length=0;
 954-  a->envtime=0;
 955-  a->phase=0;
 956-  s=(dev->d[15]&0x7F)+audio_option['n'-'a'];
 957-  s=notes[s%12]>>(10-s/12);
 958-  if(n<256) s=(n*(unsigned long long)s)>>8;
 959-  if(use_extension && (dev->d[6] || dev->d[7])) s=(((unsigned long long)s)*(0x10000+GET16(dev->d+6)))>>16;
 960-  a->freq=s;
 961-  if(audiospec.channels==1) {
 962-    a->vol[0]=a->vol[1]=((dev->d[14]&15)+(dev->d[14]>>4))/2;
 963-  } else {
 964-    a->vol[0]=dev->d[14]>>4;
 965-    a->vol[1]=dev->d[14]&15;
 966-  }
 967-  if(use_screen) SDL_UnlockAudio();
 968-}
 969-
 970-static Uint32 envelope(const UxnAudio*a) {
 971-  // Returns a number from 0 to 64.
 972-  Uint32 t=a->envtime;
 973-  if(!(a->env[0]|a->env[1]|a->env[2]|a->env[3])) return 64;
 974-  if(t<a->env[0]) return ((64*t)/a->env[0])?:1;
 975-  t-=a->env[0];
 976-  if(t<a->env[1]) return 64-((32*t)/a->env[1]);
 977-  t-=a->env[1];
 978-  if(t<a->env[2]) return 32;
 979-  t-=a->env[2];
 980-  if(t<a->env[3]) return 32-((32*t)/a->env[3]);
 981-  return 0;
 982-}
 983-
 984-static void audio_callback(void*userdata,Uint8*stream,int len) {
 985-  Uint8 c=audiospec.channels;
 986-  Uint32 vol=audio_option['m'-'a']?0:audio_option['v'-'a'];
 987-  Sint16*buf=(void*)stream;
 988-  UxnAudio*a;
 989-  Uint32 o0,o1,d,n,e;
 990-  len>>=1;
 991-  for(n=0;n<len;n+=c) {
 992-    o0=o1=0;
 993-    for(d=3;d<7;d++) {
 994-      a=device[d].aux;
 995-      if(a->pos>=a->end && !a->length) continue;
 996-      e=envelope(a);
 997-      if(!e) {
 998-        a->pos=a->length=a->end=0;
 999-        continue;
1000-      }
1001-      a->envtime++;
1002-      e*=(Sint8)(mem[a->pos]^0x80);
1003-      a->phase+=a->freq;
1004-      if(a->phase>=0x1000000) {
1005-        a->pos+=a->phase>>24;
1006-        a->phase&=0xFFFFFF;
1007-        while(a->pos>=a->end && a->length) a->pos-=a->length;
1008-      }
1009-      o0+=e*a->vol[0];
1010-      o1+=e*a->vol[1];
1011-    }
1012-    buf[n]=(o0*vol)>>12;
1013-    if(c==2) buf[n+1]=(o1*vol)>>12;
1014-  }
1015-}
1016-
1017-static void run_audio(void) {
1018-  Uint8 c=audiospec.channels;
1019-  Uint32 vol=audio_option['m'-'a']?0:audio_option['v'-'a'];
1020-  Uint32 fram=(timer_rate*(long long)audiospec.freq)/1000;
1021-  Uint8 q=0;
1022-  Uint32 f=0;
1023-  UxnAudio*a;
1024-  Uint32 o0,o1,d,e;
1025-  for(;;) {
1026-    if(++f==fram) {
1027-      f=0;
1028-      run(GET16(device[2].d));
1029-    }
1030-    if(q) {
1031-      for(d=3;d<7;d++) if(q&(1<<d)) run(GET16(device[d].d));
1032-      q=0;
1033-    }
1034-    //TODO: check for input from stdin
1035-    o0=o1=0;
1036-    for(d=3;d<7;d++) {
1037-      a=device[d].aux;
1038-      if(a->pos>=a->end && !a->length) {
1039-        end:
1040-        if(a->length) q|=1<<d;
1041-        a->pos=a->length=a->end=0;
1042-        continue;
1043-      }
1044-      e=envelope(a);
1045-      if(!e) goto end;
1046-      a->envtime++;
1047-      e*=(Sint8)(mem[a->pos]^0x80);
1048-      a->phase+=a->freq;
1049-      if(a->phase>=0x1000000) {
1050-        a->pos+=a->phase>>24;
1051-        a->phase&=0xFFFFFF;
1052-        while(a->pos>=a->end && a->length) a->pos-=a->length;
1053-      }
1054-      o0+=e*a->vol[0];
1055-      o1+=e*a->vol[1];
1056-    }
1057-    d=(o0*vol)>>12; putchar(d>>8); putchar(d);
1058-    if(c==2) {
1059-      d=(o1*vol)>>12; putchar(d>>8); putchar(d);
1060-    }
1061-  }
1062-}
1063-
1064-static void do_extension_by_uuid(Uint16 addr) {
1065-  static const Uint8 uuid_8color[]="\x80\x17\x51\x32\xE2\x63\x11\xED\xB8\xC9\x00\x26\x18\x74\x54\x16";
1066-  static const Uint8 uuid_screencompat[]="\x97\x0B\x5A\x0C\x2C\x44\x11\xEE\xAC\x3B\x00\x26\x18\x74\x54\x16";
1067-  static const Uint8 uuid_subprocess[]="\x9C\x5F\x13\x56\x6B\xC5\x11\xEF\xA6\xC9\x00\x26\x18\x74\x54\x16";
1068-  static const Uint8 uuid_random[]="\x41\x05\x25\x9C\xE0\x61\x11\xF0\x96\x3F\x00\x26\x18\x74\x54\x16";
1069-  int i;
1070-  if(mem[addr+1]==0x00 && use_screen && !memcmp(mem+addr+2,uuid_8color,16)) {
1071-    for(i=0;i<8;i++) {
1072-      colors[i+070].r=(mem[addr+19+i+i]>>4)*0x11;
1073-      colors[i+070].g=(mem[addr+19+i+i]&15)*0x11;
1074-      colors[i+070].b=(mem[addr+20+i+i]>>4)*0x11;
1075-    }
1076-    if(palet==7) {
1077-      SDL_SetColors(screen,colors+palet*8,0,8);
1078-      picture_changed=1;
1079-    }
1080-    mem[addr+18]=1;
1081-  } else if(mem[addr+1]==0x20 && use_screen && !memcmp(mem+addr+2,uuid_screencompat,16)) {
1082-    screencompat=mem[addr+19];
1083-    blend[0][0]=(screencompat&0x01?4:0);
1084-    mem[addr+18]=1;
1085-  } else if(mem[addr+1]==0x10 && use_thread && use_console && allow_write && !memcmp(mem+addr+2,uuid_subprocess,16)) {
1086-    device[1].in=subprocess_console_in;
1087-    enable_subprocess=mem[addr+18]=1;
1088-  } else if(device[mem[addr+1]>>4].in==default_in && mem[addr+19]<2 && mem[addr+20]>=4 && !memcmp(mem+addr+2,uuid_random,16)) {
1089-    if(randomfd==-1) randomfd=open("/dev/urandom",O_RDONLY|O_NOCTTY|O_CLOEXEC);
1090-    if(randomfd>=0) {
1091-      mem[addr+18]=1;
1092-      device[mem[addr+1]>>4].in=random_in;
1093-      i=(mem[addr+21]<<8)|mem[addr+22];
1094-      mem[i]=0x80;
1095-      mem[i+1]=mem[addr+1];
1096-      mem[i+2]=0x16+(mem[addr+19]<<5);
1097-      mem[i+3]=0x6C;
1098-    } else {
1099-      warn("Cannot open /dev/urandom");
1100-    }
1101-  }
1102-}
1103-
1104-static void system_exp(Device*dev,Uint16 addr) {
1105-  Uint32 src,dst;
1106-  Uint16 len,n;
1107-  switch(mem[addr]) {
1108-    case 0x00:
1109-      len=GET16(mem+addr+1);
1110-      dst=(GET16(mem+addr+3)<<16L)|(GET16(mem+addr+5));
1111-      if(dst<MEMSIZE && dst+len<=MEMSIZE) {
1112-        memset(mem+dst,mem[addr+7],len);
1113-      } else {
1114-        if(use_debug) fprintf(stderr,"! Access expanded memory out of range\n");
1115-      }
1116-      break;
1117-    case 0x01: case 0x02:
1118-      len=GET16(mem+addr+1);
1119-      src=(GET16(mem+addr+3)<<16L)|(GET16(mem+addr+5));
1120-      dst=(GET16(mem+addr+7)<<16L)|(GET16(mem+addr+9));
1121-      if(dst<MEMSIZE && src+len<=MEMSIZE && dst+len<=MEMSIZE) {
1122-        if(mem[addr]==0x01) {
1123-          for(n=0;n<len;n++) mem[dst+n]=mem[src+n];
1124-        } else {
1125-          for(n=len;n;n--) mem[dst+n-1]=mem[src+n-1];
1126-        }
1127-      } else {
1128-        if(use_debug) fprintf(stderr,"! Access expanded memory out of range\n");
1129-      }
1130-      break;
1131-    case 0x03:
1132-      if(!use_extension) break;
1133-      mem[addr+18]=0;
1134-      do_extension_by_uuid(addr);
1135-      break;
1136-    case 0x04:
1137-      if(!use_extension) break;
1138-      PUT16(mem+addr+1,EXPANDED_MEMORY);
1139-      break;
1140-  }
1141-}
1142-
1143-static void debug_screen(Uint8*s,Uint8 k) {
1144-  static Sint8 page=0;
1145-  static Uint8 port=0;
1146-  static Uint8 din;
1147-  static Uint32 addr=0;
1148-  static Uint32 scrol=0;
1149-  static const char opname[]=
1150-    "?IPNSRDOENGLJJJSLSLSLSDDASMDAOES"
1151-    "?NOIWOUVQETTMCSTDTDTDTEEDUUINROF"
1152-    "?CPPPTPRUQHHPNRHZZRRAAIODBLVDART"
1153-  ;
1154-  char buf[81];
1155-  int i,j;
1156-  Stack*z;
1157-  FILE*f;
1158-  UxnFile*u;
1159-  if(s) {
1160-    memset(s,32,80*25);
1161-    show:
1162-    switch(page) {
1163-      case 0:
1164-        memcpy(s+80*0,buf,snprintf(buf,81,"* %s",rom_name));
1165-        memcpy(s+80*1,buf,snprintf(buf,81,"<c> Console: %s",use_console?"On":"Off"));
1166-        memcpy(s+80*2,buf,snprintf(buf,81,"<d> Debug: %s",use_debug?"On":"Off"));
1167-        memcpy(s+80*3,buf,snprintf(buf,81,"<F2> Sound: %s",audio_option?(audio_option['m'-'a']?"Mute":"On"):"N/A"));
1168-        memcpy(s+80*4,buf,snprintf(buf,81,"<F3> Mouse: %s",use_mouse?"On":"Off"));
1169-        memcpy(s+80*5,buf,snprintf(buf,81,"<F4> Layers: %s",layers?(layers==1?"fg":"bg"):"fg/bg"));
1170-        memcpy(s+80*6,buf,snprintf(buf,81,"<F6/F7> Palette: %d",palet));
1171-        memcpy(s+80*7,buf,snprintf(buf,81,"<F9> Restart"));
1172-        memcpy(s+80*8,buf,snprintf(buf,81,"<F10> Quit"));
1173-        if(audio_option) memcpy(s+80*9,buf,snprintf(buf,81,"<-/+> Volume: %d",(int)audio_option['v'-'a']));
1174-        memcpy(s+80*10,buf,snprintf(buf,81,"<PAUSE> Resume"));
1175-        memcpy(s+80*13,buf,snprintf(buf,81,"Pages: CTRL+"));
1176-        memcpy(s+80*14,buf,snprintf(buf,81," A:Stack   B:Return  C:Device  D:Memory  E:Files "));
1177-        memcpy(s+80*15,buf,snprintf(buf,81," F:Code    G:        N:        O:        P:      "));
1178-        memcpy(s+80*16,buf,snprintf(buf,81," Q:        R:        S:        T:        U:      "));
1179-        memcpy(s+80*17,buf,snprintf(buf,81," V:        W:        X:        Y:        Z:Main  "));
1180-        break;
1181-      case 1: case 2:
1182-        if(page==1) z=&ds; else z=&rs;
1183-        memcpy(s,buf,snprintf(buf,81,"%s Stack (%02x)",page==1?"Data":"Return",z->p));
1184-        for(i=0;i<256;i++) memcpy(s+80*(i/16+1)+(i&15)*4,buf,snprintf(buf,81,"%c%02x%c",z->p==i?'[':' ',z->d[i],z->p==i?']':' '));
1185-        break;
1186-      case 3:
1187-        memcpy(s,buf,snprintf(buf,81,"--   -0  -1  -2  -3  -4  -5  -6  -7  -8  -9  -a  -b  -c  -d  -e  -f"));
1188-        for(i=0;i<16;i++) memcpy(s+80*(i+1),buf,snprintf(buf,81,"%x0:",i));
1189-        for(i=0;i<256;i++) memcpy(s+80*(i/16+1)+(i&15)*4+4,buf,snprintf(buf,81,"%c%02x%c",port==i?'[':' ',device[i>>4].d[i&15],port==i?']':' '));
1190-        memcpy(s+80*17,buf,snprintf(buf,81,"<i> In=%02x  <o> Out  <x> Execute",din));
1191-        break;
1192-      case 4:
1193-        if(addr<0) addr=0;
1194-        if(addr>=MEMSIZE) addr=MEMSIZE-1;
1195-        if(scrol<0) scrol=0;
1196-        if(addr>=0x100 && scrol<addr-0xF0) scrol=(addr-0xF0)&~15;
1197-        if(scrol>addr) scrol=addr&~15;
1198-        memcpy(s,buf,snprintf(buf,81,"-----   -0  -1  -2  -3  -4  -5  -6  -7  -8  -9  -a  -b  -c  -d  -e  -f"));
1199-        for(i=0;i<16;i++) memcpy(s+80*(i+1),buf,snprintf(buf,81,"%05x:",i*16+scrol));
1200-        for(i=0;i<256;i++) if(i+scrol<MEMSIZE) memcpy(s+80*(i/16+1)+(i&15)*4+7,buf,snprintf(buf,81,"%c%02x%c",addr==i+scrol?'[':' ',mem[i+scrol],addr==i+scrol?']':' '));
1201-        memcpy(s+80*17,buf,snprintf(buf,81,"<x> Execute  <s> Save"));
1202-        break;
1203-      case 5:
1204-        for(i=0;i<2;i++) {
1205-          u=i?&uxnfile1:&uxnfile0;
1206-          memcpy(s+80*(7*i+1),buf,snprintf(buf,81,"[File%d]",i));
1207-          memcpy(s+80*(7*i+2),buf,snprintf(buf,81," name=%s",u->name));
1208-          if(u->file) memcpy(s+80*(7*i+3),buf,snprintf(buf,81," File fd=%d offset=0x%lX",fileno(u->file),ftell(u->file)));
1209-          if(u->dir) memcpy(s+80*(7*i+4),buf,snprintf(buf,81," Dir fd=%d offset=0x%lX",dirfd(u->dir),telldir(u->dir)));
1210-          memcpy(s+80*(7*i+5),buf,snprintf(buf,81," mode=0x%02X",u->mode));
1211-          memcpy(s+80*(7*i+6),buf,snprintf(buf,81," <%c> Close  <%c> Rewind","cC"[i],"rR"[i]));
1212-        }
1213-        break;
1214-      case 6:
1215-        j=break_pc;
1216-        for(i=0;i<16 && j<0x10000;i++) {
1217-          memcpy(s+80*i,buf,snprintf(buf,81,"%04x: %c%c %c%c%c%c%c%c",j,breakpoint==j+1?'*':' ',i?' ':'>',
1218-           opname[mem[j]&0x1F],opname[(mem[j]&0x1F)+0x20],opname[(mem[j]&0x1F)+0x40]
1219-           ,mem[j]&0x20?'2':'_',mem[j]&0x40?'r':'_',mem[j]&0x80?'k':'_' ));
1220-          if(mem[j]==0x80 || mem[j]==0xC0) {
1221-            memcpy(s+80*i+9,buf,snprintf(buf,81,"LIT_%c  %02x",mem[j]&0x40?'r':'_',mem[j+1]));
1222-            j+=2;
1223-          } else if(mem[j]==0xA0 || mem[j]==0xE0) {
1224-            memcpy(s+80*i+9,buf,snprintf(buf,81,"LIT2%c  %02x%02x",mem[j]&0x40?'r':'_',mem[j+1],mem[j+2]));
1225-            j+=3;
1226-          } else {
1227-            if(!mem[j]) memcpy(s+80*i+9,"BRK",3);
1228-            j++;
1229-          }
1230-        }
1231-        memcpy(s+80*17,buf,snprintf(buf,81,"ds:%02x rs:%02x",ds.p,rs.p));
1232-        memcpy(s+80*19,buf,snprintf(buf,81,"<SPACE> Step  <RET> Continue  <x> Execute"));
1233-        memcpy(s+80*20,buf,snprintf(buf,81,"<,> Set Breakpoint  <.> Clear Breakpoint"));
1234-        break;
1235-      default:
1236-        if(page<0) page=6; else page=0;
1237-        goto show;
1238-    }
1239-  } else {
1240-    if(k==9 || k==']') {
1241-      ++page;
1242-    } else if(k=='[') {
1243-      --page;
1244-    } else if(k>=1 && k<=7) {
1245-      page=k;
1246-    } else if(k>=14 && k<=25) {
1247-      page=k-6;
1248-    } else if(k==26) {
1249-      page=0;
1250-    } else if(k==27) {
1251-      debugger=0;
1252-      return;
1253-    } else switch(page) {
1254-      case 0:
1255-        if(k=='c') use_console^=1;
1256-        if(k=='d') use_debug^=1;
1257-        if(audio_option) {
1258-          if((k=='-' || k==10) && audio_option['v'-'a']) --audio_option['v'-'a'];
1259-          if(k=='+' || k==11) ++audio_option['v'-'a'];
1260-          if(k==8) audio_option['v'-'a']/=10;
1261-          if(k>='0' && k<='9') audio_option['v'-'a']=10*audio_option['v'-'a']+k-'0';
1262-        }
1263-        break;
1264-      case 1: case 2:
1265-        if(page==1) z=&ds; else z=&rs;
1266-        if(k==8) z->p--;
1267-        if(k==12) z->p++;
1268-        if(k==10) z->p+=16;
1269-        if(k==11) z->p-=16;
1270-        if(k>='0' && k<='9') z->d[z->p]=(z->d[z->p]<<4)+(k-'0');
1271-        if(k>='a' && k<='f') z->d[z->p]=(z->d[z->p]<<4)+(k+10-'a');
1272-        break;
1273-      case 3:
1274-        i=port;
1275-        if(k==8) port--;
1276-        if(k==12) port++;
1277-        if(k==10) port+=16;
1278-        if(k==11) port-=16;
1279-        if(k>='0' && k<='9') device[i>>4].d[i&15]=(device[i>>4].d[i&15]<<4)+(k-'0');
1280-        if(k>='a' && k<='f') device[i>>4].d[i&15]=(device[i>>4].d[i&15]<<4)+(k+10-'a');
1281-        if(k=='i') din=device[i>>4].in(device+(i>>4),i&15);
1282-        if(k=='o') device[i>>4].out(device+(i>>4),i&15);
1283-        if(k=='x') run(GET16(device[i>>4].d));
1284-        break;
1285-      case 4:
1286-        if(k==8) addr--;
1287-        if(k==12) addr++;
1288-        if(k==10) addr+=16;
1289-        if(k==11) addr-=16;
1290-        if(k==',') scrol-=0x10,addr-=0x10;
1291-        if(k=='.') scrol+=0x10,addr+=0x10;
1292-        if(k=='<') scrol-=0x100,addr-=0x100;
1293-        if(k=='>') scrol+=0x100,addr+=0x100;
1294-        if(k=='q') scrol-=0x1000,addr-=0x1000;
1295-        if(k=='w') scrol+=0x1000,addr+=0x1000;
1296-        if(k=='Q') scrol-=0x10000,addr-=0x10000;
1297-        if(k=='W') scrol+=0x10000,addr+=0x10000;
1298-        if(k=='=') scrol=addr=0;
1299-        if(addr>=MEMSIZE+0x1000) scrol=addr=0;
1300-        if(k>='0' && k<='9') mem[addr]=(mem[addr]<<4)+(k-'0');
1301-        if(k>='a' && k<='f') mem[addr]=(mem[addr]<<4)+(k+10-'a');
1302-        if(k=='x' && addr<0x10000) run(addr);
1303-        if(k=='s') {
1304-          f=fopen("_uxn_memory","w");
1305-          if(f) {
1306-            fwrite(mem,1,MEMSIZE,f);
1307-            fprintf(stderr,"Saved 0x%X bytes to file _uxn_memory\n",(int)(MEMSIZE));
1308-            fclose(f);
1309-          } else {
1310-            warn("Cannot open file _uxn_memory");
1311-          }
1312-        }
1313-        break;
1314-      case 5:
1315-        if(k=='c') files_set(device+10,0);
1316-        if(k=='C') files_set(device+11,0);
1317-        if(k=='r') files_seek(&uxnfile0,0,0);
1318-        if(k=='R') files_seek(&uxnfile1,0,0);
1319-        break;
1320-      case 6:
1321-        if(k==8 || k==11) --break_pc;
1322-        if(k==12 || k==10) ++break_pc;
1323-        if(k>='0' && k<='9') break_pc=(break_pc<<4)+(k-'0');
1324-        if(k>='a' && k<='f') break_pc=(break_pc<<4)+(k+10-'a');
1325-        if(k==',') breakpoint=break_pc+1;
1326-        if(k=='.') breakpoint=0;
1327-        if(k=='x') run(break_pc);
1328-        if(k==' ') {
1329-          j=breakpoint;
1330-          breakpoint=break_pc+2;
1331-          i=mem[break_pc];
1332-          if(i==0x80 || i==0xC0) {
1333-            breakpoint=break_pc+3;
1334-          } else if(i==0xA0 || i==0xE0) {
1335-            breakpoint=break_pc+4;
1336-          } else if((i&0x1F)==0x0C || (i&0x1F)==0x0D || (i&0x1F)==0x0E) {
1337-            if((i&0x1F)==0x0D) {
1338-              i&=0x60;
1339-              if(i==0x00 && ds.p>1 && !ds.d[ds.p-2]) goto no_jump;
1340-              if(i==0x20 && ds.p>2 && !ds.d[ds.p-3]) goto no_jump;
1341-              if(i==0x40 && rs.p>1 && !rs.d[rs.p-2]) goto no_jump;
1342-              if(i==0x60 && rs.p>2 && !rs.d[rs.p-3]) goto no_jump;
1343-            }
1344-            i&=0x60;
1345-            if(i==0x00 && ds.p) breakpoint=break_pc+((Sint8)ds.d[ds.p-1])+2;
1346-            else if(i==0x20 && ds.p>1) breakpoint=GET16(ds.d+ds.p-2)+1;
1347-            else if(i==0x40 && rs.p) breakpoint=break_pc+((Sint8)rs.d[rs.p-1])+2;
1348-            else if(i==0x60 && rs.p>1) breakpoint=GET16(rs.d+rs.p-2)+1;
1349-            else goto no_run;
1350-          } else if(i) {
1351-            no_jump:
1352-            breakpoint=break_pc+2;
1353-          } else {
1354-            goto no_run;
1355-          }
1356-          run(break_pc);
1357-          no_run:
1358-          breakpoint=j;
1359-          break;
1360-        }
1361-        if(k==13) {
1362-          paused=debugger=0;
1363-          run(break_pc);
1364-          return;
1365-        }
1366-        break;
1367-    }
1368-  }
1369-}
1370-
1371-static void redraw(void) {
1372-  static Uint8*s=0;
1373-  int a,r,u,v,x,y;
1374-  Uint8*p;
1375-  if(debugger) {
1376-    if(!s) s=calloc(80,26);
1377-    if(!s) err(1,"Allocation failed");
1378-    debug_screen(s,0);
1379-  }
1380-  if(size_changed) set_screen_mode(scr_w,scr_h);
1381-  picture_changed=0;
1382-  SDL_LockSurface(screen);
1383-  a=0;
1384-  p=screen->pixels;
1385-  r=screen->pitch;
1386-  if(debugger) {
1387-    for(y=0;y<scr_h*zoom;y++) {
1388-      for(x=0;x<scr_w*zoom;x++) {
1389-        if(y>=25*8-7 || x>=80*8 || (v=s[(y/8)*80+x/8]-32)<=0) p[x]=0;
1390-        else p[x]=(fontdata[v*8+(y&7)]>>(7&~x))&1;
1391-      }
1392-      p+=r;
1393-    }
1394-    if(scr_h*zoom>9) {
1395-      p=screen->pixels+r*(scr_h*zoom-8);
1396-      for(y=0;y<8;y++) {
1397-        for(a=0;a<scr_w*zoom;a++) p[a]=(a>>4)&7;
1398-        p+=r;
1399-      }
1400-    }
1401-  } else if(layers) {
1402-    for(y=0;y<scr_h;y++) {
1403-      for(x=0;x<scr_w;x++) {
1404-        u=(layers==1?fglayer:bglayer)[a];
1405-        for(v=0;v<zoom;v++) memset(p+v*r+x*zoom,u,zoom);
1406-        a++;
1407-      }
1408-      p+=r*zoom;
1409-    }
1410-  } else {
1411-    for(y=0;y<scr_h;y++) {
1412-      for(x=0;x<scr_w;x++) {
1413-        u=fglayer[a]?fglayer[a]+4:bglayer[a];
1414-        for(v=0;v<zoom;v++) memset(p+v*r+x*zoom,u,zoom);
1415-        a++;
1416-      }
1417-      p+=r*zoom;
1418-    }
1419-  }
1420-  SDL_UnlockSurface(screen);
1421-  SDL_Flip(screen);
1422-}
1423-
1424-static inline int select_joystick(Uint8 n) {
1425-  if((joy_mask&1) && n==joy_player[0]) return 2;
1426-  if((joy_mask&2) && n==joy_player[1]) return 5;
1427-  if((joy_mask&4) && n==joy_player[2]) return 6;
1428-  if((joy_mask&8) && n==joy_player[3]) return 7;
1429-  return 0;
1430-}
1431-
1432-static int run_screen(void) {
1433-  SDL_Event e;
1434-  int i,j,k;
1435-  while(SDL_WaitEvent(&e)) {
1436-    switch(e.type) {
1437-      case SDL_QUIT: return 0;
1438-      case SDL_VIDEOEXPOSE: redraw(); break;
1439-      case SDL_USEREVENT: timer_expired=0; if(!paused) run(GET16(device[2].d)); break;
1440-      case SDL_KEYDOWN:
1441-        i=0;
1442-        switch(e.key.keysym.sym) {
1443-          case SDLK_LCTRL: case SDLK_END: i=0x01; break;
1444-          case SDLK_LALT: i=0x02; break;
1445-          case SDLK_LSHIFT: i=0x04; break;
1446-          case SDLK_HOME: i=0x08; break;
1447-          case SDLK_UP: i=0x10; break;
1448-          case SDLK_DOWN: i=0x20; break;
1449-          case SDLK_LEFT: i=0x40; break;
1450-          case SDLK_RIGHT: i=0x80; break;
1451-          case SDLK_PAGEUP: i=-scroll_size; goto scroll;
1452-          case SDLK_PAGEDOWN: i=scroll_size; goto scroll;
1453-          case SDLK_F1: run(GET16(device[2].d)); timer_expired=0; break;
1454-          case SDLK_F2: if(audio_option) audio_option['m'-'a']^=1; picture_changed=debugger; break;
1455-          case SDLK_F3: use_mouse^=1; set_cursor(); picture_changed=debugger; break;
1456-          case SDLK_F4: layers=(layers+1)%3; redraw(); break;
1457-          case SDLK_F5: redraw(); if(SDL_GetModState()&KMOD_RSHIFT) debug(-1); break;
1458-          case SDLK_F6: palet=(palet+1)&7; SDL_SetColors(screen,colors+palet*8,0,8); redraw(); break;
1459-          case SDLK_F7: palet=(palet-1)&7; SDL_SetColors(screen,colors+palet*8,0,8); redraw(); break;
1460-          case SDLK_F8: paused=picture_changed=debugger=1; break;
1461-          case SDLK_F9: return 1;
1462-          case SDLK_F10: return 0;
1463-          case SDLK_PAUSE: debugger=0; paused^=1; set_cursor(); picture_changed=1; break;
1464-        }
1465-        if(paused) {
1466-          if(debugger) {
1467-            if(i&0xF0) {
1468-              debug_screen(0,i==0x10?11:i==0x20?10:i==0x40?8:i==0x80?12:0);
1469-            } else if(i=e.key.keysym.unicode) {
1470-              debug_screen(0,i);
1471-            }
1472-            picture_changed=1;
1473-          }
1474-          break;
1475-        }
1476-        if(i) {
1477-          if(joypad_repeat || !(device[8].d[2]&i)) {
1478-            device[8].d[2]|=i;
1479-            run(GET16(device[8].d));
1480-          }
1481-        } else if(i=e.key.keysym.unicode) {
1482-          device[8].d[3]=i;
1483-          run(GET16(device[8].d));
1484-          if(!debugger) device[8].d[3]=0; else debug_op=8;
1485-        }
1486-        break;
1487-      scroll:
1488-        if(paused || !i) break;
1489-        PUT16(device[9].d+12,i);
1490-        run(GET16(device[9].d));
1491-        if(!debugger) PUT16(device[9].d+12,0); else debug_op=9;
1492-        break;
1493-      case SDL_KEYUP:
1494-        if(paused) break;
1495-        i=0;
1496-        switch(e.key.keysym.sym) {
1497-          case SDLK_LCTRL: case SDLK_END: i=0x01; break;
1498-          case SDLK_LALT: i=0x02; break;
1499-          case SDLK_LSHIFT: i=0x04; break;
1500-          case SDLK_HOME: i=0x08; break;
1501-          case SDLK_UP: i=0x10; break;
1502-          case SDLK_DOWN: i=0x20; break;
1503-          case SDLK_LEFT: i=0x40; break;
1504-          case SDLK_RIGHT: i=0x80; break;
1505-        }
1506-        if(device[8].d[2]&i) {
1507-          device[8].d[2]&=~i;
1508-          run(GET16(device[8].d));
1509-        }
1510-        break;
1511-      case SDL_MOUSEMOTION:
1512-      case SDL_MOUSEBUTTONDOWN:
1513-      case SDL_MOUSEBUTTONUP:
1514-        if(paused || !use_mouse) break;
1515-        k=SDL_GetMouseState(&i,&j);
1516-        i/=zoom; j/=zoom;
1517-        if(i<0 || i>=screen->w || j<0 || j>=screen->h) break;
1518-        if(touch_mode) {
1519-          if(e.type==SDL_MOUSEBUTTONDOWN && !device[9].d[6]) {
1520-            PUT16(device[9].d+2,i);
1521-            PUT16(device[9].d+4,j);
1522-            run(GET16(device[9].d));
1523-          } else if(e.type==SDL_MOUSEBUTTONUP && !k) {
1524-            device[9].d[6]=0;
1525-            run(GET16(device[9].d));
1526-            i=j=0x8000;
1527-          } else if(e.type==SDL_MOUSEMOTION && !k) {
1528-            break;
1529-          }
1530-        }
1531-        PUT16(device[9].d+2,i);
1532-        PUT16(device[9].d+4,j);
1533-        device[9].d[6]=k&7;
1534-        run(GET16(device[9].d));
1535-        break;
1536-      case SDL_USEREVENT+1:
1537-        device[1].d[2]=e.user.code;
1538-        device[1].d[7]=1;
1539-        if(e.user.data1) {
1540-          if(!(device[1].d[6]&1)) break;
1541-          device[1].d[7]=0;
1542-        }
1543-        run(GET16(device[1].d));
1544-        SDL_CondBroadcast(stdin_cond);
1545-        break;
1546-      case SDL_JOYAXISMOTION:
1547-        if(!joy_axis_mode) break;
1548-        if(j=select_joystick(e.jaxis.which)) {
1549-          k=device[8].d[j];
1550-          if(e.jaxis.axis==joy_axis_x) {
1551-            i=e.jaxis.value*(joy_axis_mode&1?-1:1);
1552-            k&=0x3F;
1553-            if(i>=joy_sensitivity) k|=0x80; else if(i<=-joy_sensitivity) k|=0x40;
1554-          } else if(e.jaxis.axis==joy_axis_y) {
1555-            i=e.jaxis.value*(joy_axis_mode&2?-1:1);
1556-            k&=0xCF;
1557-            if(i>=joy_sensitivity) k|=0x10; else if(i<=-joy_sensitivity) k|=0x20;
1558-          }
1559-          trigger:
1560-          if(k!=device[8].d[j]) {
1561-            device[8].d[j]=k;
1562-            if(!paused) run(GET16(device[8].d));
1563-          }
1564-        }
1565-        break;
1566-      case SDL_JOYBUTTONDOWN:
1567-      case SDL_JOYBUTTONUP:
1568-        if(e.jbutton.button&~127) break;
1569-        if(j=select_joystick(e.jbutton.which)) {
1570-          k=device[8].d[j];
1571-          i=joy_button_map[e.jbutton.button];
1572-          if(e.jbutton.state==SDL_PRESSED) k|=i; else k&=~i;
1573-          goto trigger;
1574-        }
1575-        break;
1576-      case SDL_JOYHATMOTION:
1577-        if(!joy_hat_mode) break;
1578-        if(j=select_joystick(e.jhat.which)) {
1579-          k=device[8].d[j]&0x0F;
1580-          // Note that the SDL_HAT_ values are bits counted clockwise from UP.
1581-          i=(e.jhat.value*0x1111)>>joy_hat_mode;
1582-          if(i&SDL_HAT_UP) k|=0x10;
1583-          if(i&SDL_HAT_DOWN) k|=0x20;
1584-          if(i&SDL_HAT_LEFT) k|=0x40;
1585-          if(i&SDL_HAT_RIGHT) k|=0x80;
1586-          goto trigger;
1587-        }
1588-        break;
1589-    }
1590-    if(picture_changed) redraw();
1591-  }
1592-  return 0;
1593-}
1594-
1595-static int stdin_thread_fn(void*unused) {
1596-  int c;
1597-  SDL_Event e;
1598-  SDL_mutex*mut=SDL_CreateMutex();
1599-  SDL_LockMutex(mut);
1600-  e.type=SDL_USEREVENT+1;
1601-  e.user.data1=0;
1602-  while((c=fgetc(inf))>=0) {
1603-    e.user.code=c;
1604-    while(SDL_PushEvent(&e)) SDL_CondWaitTimeout(stdin_cond,mut,timer_rate?:10);
1605-  }
1606-  if(use_extension) {
1607-    e.user.code=0;
1608-    e.user.data1="";
1609-    while(SDL_PushEvent(&e)) SDL_CondWaitTimeout(stdin_cond,mut,timer_rate?:10);
1610-  }
1611-  return 0;
1612-}
1613-
1614-static void set_datetime(char*s) {
1615-  int i=2;
1616-  if(*s=='@') {
1617-    struct tm r;
1618-    time_t t=strtoll(s+1,0,10);
1619-    if(use_utc) gmtime_r(&t,&r); else localtime_r(&t,&r);
1620-    PUT16(device[12].d,r.tm_year+1900);
1621-    device[12].d[2]=r.tm_mon;
1622-    device[12].d[3]=r.tm_mday;
1623-    device[12].d[4]=r.tm_hour;
1624-    device[12].d[5]=r.tm_min;
1625-    device[12].d[6]=r.tm_sec;
1626-    device[12].d[7]=r.tm_wday;
1627-    PUT16(device[12].d+8,r.tm_yday);
1628-    device[12].d[10]=r.tm_isdst;
1629-  } else {
1630-    i=strtol(s,&s,10);
1631-    PUT16(device[12].d,i);
1632-    if(*s) s++;
1633-    i=2;
1634-    while(*s && i<15) {
1635-      device[12].d[i++]=strtol(s,&s,10);
1636-      if(*s) s++;
1637-    }
1638-  }
1639-}
1640-
1641-static void set_audio(char*s) {
1642-  int i;
1643-  audio_option=calloc(sizeof(Sint32),26);
1644-  if(!audio_option) err(1,"Allocation failed");
1645-  audio_option['b'-'a']=2048;
1646-  audio_option['c'-'a']=2;
1647-  audio_option['r'-'a']=44100;
1648-  audio_option['v'-'a']=273;
1649-  while(*s && *s!='.') {
1650-    if(*s<'a' && *s>'z') errx(1,"Invalid audio option");
1651-    audio_option[*s-'a']=strtol(s+1,&s,10);
1652-  }
1653-  audiospec.freq=audio_option['r'-'a'];
1654-  audiospec.channels=audio_option['c'-'a'];
1655-  audiospec.samples=audio_option['b'-'a'];
1656-  audiospec.format=AUDIO_S16SYS;
1657-  audiospec.callback=audio_callback;
1658-  for(i=3;i<7;i++) {
1659-    device[i].aux=calloc(1,sizeof(UxnAudio));
1660-    if(!device[i].aux) err(1,"Allocation failed");
1661-    device[i].out=audio_out;
1662-  }
1663-  if(!audio_option['e'-'a']) audio_option['e'-'a']=audio_option['r'-'a']/15;
1664-}
1665-
1666-static void set_joystick(char*s) {
1667-  int c,i,n;
1668-  SDL_Joystick*j;
1669-  if(*s=='?') {
1670-    if(SDL_Init(SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) errx(1,"Cannot initialize SDL: %s",SDL_GetError());
1671-    atexit(SDL_Quit);
1672-    if(s[1]) {
1673-      j=SDL_JoystickOpen(i=strtol(s+1,0,10));
1674-      if(!j) errx(1,"Cannot open joystick %d",i);
1675-      printf("Opened Joystick %d\n",i);
1676-      printf("Name: %s\n",SDL_JoystickName(i));
1677-      printf("Axes: %d\n",SDL_JoystickNumAxes(j));
1678-      printf("Buttons: %d\n",SDL_JoystickNumButtons(j));
1679-      printf("Hats: %d\n",SDL_JoystickNumHats(j));
1680-      printf("Balls: %d\n",SDL_JoystickNumBalls(j));
1681-      SDL_JoystickClose(j);
1682-    } else {
1683-      n=SDL_NumJoysticks();
1684-      for(i=0;i<n;i++) printf("%d: %s\n",i,SDL_JoystickName(i));
1685-    }
1686-    exit(0);
1687-    return;
1688-  }
1689-  n=0;
1690-  while(*s) {
1691-    if(*s>='0' && *s<='9') {
1692-      if(n&~3) errx(1,"Too many players");
1693-      joy_player[n]=strtol(s,&s,10);
1694-      joy_mask|=1<<n;
1695-    } else if(*s==',') {
1696-      s++;
1697-      n++;
1698-    } else {
1699-      break;
1700-    }
1701-  }
1702-  if(*s=='/') ++s; else errx(1,"Improper joystick setting");
1703-  while(*s) {
1704-    c=*s++;
1705-    n=strtol(s,&s,10);
1706-    switch(c) {
1707-      case 'A': joy_button_map[n&0x7F]|=0x01; break;
1708-      case 'B': joy_button_map[n&0x7F]|=0x02; break;
1709-      case 'D': joy_button_map[n&0x7F]|=0x20; break;
1710-      case 'H': joy_hat=n; joy_hat_mode=6; break;
1711-      case 'h': joy_hat=n; joy_hat_mode=4; break;
1712-      case 'I': joy_hat=n; joy_hat_mode=5; break;
1713-      case 'i': joy_hat=n; joy_hat_mode=7; break;
1714-      case 'L': joy_button_map[n&0x7F]|=0x40; break;
1715-      case 'R': joy_button_map[n&0x7F]|=0x80; break;
1716-      case 'S': joy_button_map[n&0x7F]|=0x04; break;
1717-      case 'T': joy_button_map[n&0x7F]|=0x08; break;
1718-      case 'U': joy_button_map[n&0x7F]|=0x10; break;
1719-      case 'X': joy_axis_x=n; joy_axis_mode|=1; break;
1720-      case 'Y': joy_axis_y=n; joy_axis_mode|=2; break;
1721-      case 's': joy_sensitivity=n; break;
1722-      case 'x': joy_axis_x=n; joy_axis_mode|=4; break;
1723-      case 'y': joy_axis_y=n; joy_axis_mode|=8; break;
1724-      default: errx(1,"Improper joystick setting");
1725-    }
1726-  }
1727-}
1728-
1729-static void set_other_program(const char*s) {
1730-  int pf[4];
1731-  pid_t pi;
1732-  if(pipe(pf) || pipe(pf+2)) err(1,"Pipe failed");
1733-  pi=fork();
1734-  if(pi==(pid_t)(-1)) err(1,"Fork failed");
1735-  if(pi) {
1736-    // Parent
1737-    close(pf[1]);
1738-    close(pf[2]);
1739-    inf=fdopen(pf[0],"r");
1740-    if(!inf) err(1,"Cannot open pipe for input");
1741-    outf=fdopen(pf[3],"w");
1742-    if(!outf) err(1,"Cannot open pipe for output");
1743-  } else {
1744-    // Child
1745-    close(pf[0]);
1746-    close(pf[3]);
1747-    if(dup2(pf[1],1)<0 || dup2(pf[2],0)<0) err(1,"Cannot duplicate file descriptors");
1748-    close(pf[1]);
1749-    close(pf[2]);
1750-    execl("/bin/sh","/bin/sh","-c",s,(char*)0);
1751-    fprintf(stderr,"Cannot exec\n");
1752-    _exit(1);
1753-  }
1754-}
1755-
1756-static void set_palette(char*s) {
1757-  int p=palet<<3;
1758-  FILE*f=fmemopen(s,strlen(s),"r");
1759-  if(!f) err(1,"Error with fmemopen during parsing command-line arguments");
1760-  while(p<64 && fscanf(f,"%2hhX%2hhX%2hhX",&colors[p].r,&colors[p].g,&colors[p].b)) {
1761-    p++;
1762-    fscanf(f,"%*[, ]");
1763-  }
1764-  fclose(f);
1765-}
1766-
1767-static void set_script(char*s) {
1768-  static size_t siz;
1769-  Script o={0,0,0,0,0};
1770-  if(!scriptf) {
1771-    scriptf=open_memstream((char**)&scriptv,&siz);
1772-    if(!scriptf) err(1,"Error with open_memstream during parsing command-line arguments");
1773-  }
1774-  if(*s=='@') {
1775-    char*line=0;
1776-    size_t line_size=0;
1777-    FILE*fp=fopen(s+1,"r");
1778-    if(!fp) err(1,"Cannot open file \"%s\"",s+1);
1779-    while(getline(&line,&line_size,fp)>0) {
1780-      s=line+strlen(line);
1781-      while(s>line && (s[-1]=='\r' || s[-1]=='\n' || s[-1]==' ' || s[-1]=='\t')) *--s=0;
1782-      if(*s=='@') errx(1,"Nested file in -m not allowed");
1783-      if(*s && *s!='#') set_script(s);
1784-    }
1785-    fclose(fp);
1786-    free(line);
1787-  } else {
1788-    Uint8 b;
1789-    if(*s=='.') o.stage=1,s++;
1790-    if(*s>'f') o.kind=*s++;
1791-    o.addr=strtoll(s,&s,16);
1792-    if(*s=='=') {
1793-      s++;
1794-      if(strlen(s)>=0x1FFFF) errx(1,"Argument too long");
1795-      o.data=malloc(strlen(s)/2+1);
1796-      if(!o.data) err(1,"Allocation failed");
1797-      while(*s && s[1]) {
1798-        if(!sscanf(s,"%2hhX",&b)) break;
1799-        o.data[o.len++]=b;
1800-        s+=2;
1801-      }
1802-      if(*s) errx(1,"Syntax error in -m");
1803-    } else if(*s) {
1804-      errx(1,"Syntax error in -m");
1805-    }
1806-    if(o.kind || o.len) {
1807-      if(!fwrite(&o,sizeof(Script),1,scriptf)) err(1,"Cannot write to memory stream");
1808-      ++scriptc;
1809-    }
1810-  }
1811-}
1812-
1813-static void do_script(Uint8 stage) {
1814-  Uint8 u=use_extension;
1815-  Uint16 n,i,j;
1816-  Script*o;
1817-  use_extension=1;
1818-  for(n=0;n<scriptc;n++) if(scriptv[n].stage==stage) {
1819-    o=scriptv+n;
1820-    switch(o->kind) {
1821-      case 0: // Memory write
1822-        memcpy(mem+o->addr,o->data,o->len);
1823-        break;
1824-      case 'p': // Device port (including trigger)
1825-        j=o->addr;
1826-        for(i=0;i<o->len;i++) {
1827-          device[(j>>4)&15].d[j&15]=o->data[i];
1828-          device[(j>>4)&15].out(device+((j>>4)&15),j&15);
1829-          j++;
1830-        }
1831-        break;
1832-      case 's': // Device port (set only)
1833-        j=o->addr;
1834-        for(i=0;i<o->len;i++) {
1835-          device[(j>>4)&15].d[j&15]=o->data[i];
1836-          j++;
1837-        }
1838-        break;
1839-      case 'u': // Extension set
1840-        mem[o->addr]=3;
1841-        memcpy(mem+o->addr+1,o->data,o->len);
1842-        do_extension_by_uuid(o->addr);
1843-        break;
1844-      case 'x': // Execute
1845-        run(o->addr);
1846-        break;
1847-      case 'z': // Others
1848-        if(o->addr==2) {
1849-          if(o->len) screencompat=o->data[0];
1850-          blend[0][0]=(screencompat&0x01?4:0);
1851-        } else {
1852-          errx(1,"Unrecognized command -mz%X",o->addr);
1853-        }
1854-        break;
1855-      default: errx(1,"Unrecognized command -m%c",o->kind);
1856-    }
1857-  }
1858-  use_extension=u;
1859-}
1860-
1861-static void set_full_screen_size(void) {
1862-  SDL_Rect**m=SDL_ListModes(0,scrflags);
1863-  int i;
1864-  if(!m || m==(SDL_Rect**)(-1) || !*m) errx(1,"Cannot determine size to use for full screen mode");
1865-  default_width=m[0]->w/zoom;
1866-  default_height=m[0]->h/zoom;
1867-}
1868-
1869-int main(int argc,char**argv) {
1870-  int i,j;
1871-  for(i=0;i<16;i++) {
1872-    device[i].in=default_in;
1873-    device[i].out=default_out;
1874-    device[i].exp=default_exp;
1875-  }
1876-  device[0].in=system_in;
1877-  device[0].out=system_out;
1878-  device[0].exp=system_exp;
1879-  device[10].aux=&uxnfile0;
1880-  device[11].aux=&uxnfile1;
1881-  device[12].in=datetime_in;
1882-  inf=stdin; outf=stdout;
1883-  while((i=getopt(argc,argv,"+ADFIJ:NOQST:YZa:de:h:ijm:np:qs:t:w:xyz:"))>0) switch(i) {
1884-    case 'D': scrflags|=SDL_DOUBLEBUF; break;
1885-    case 'F': scrflags|=SDL_FULLSCREEN; default_width=default_height=0; break;
1886-    case 'I': use_thread=1; break;
1887-    case 'J': set_joystick(optarg); break;
1888-    case 'N': scrflags|=SDL_NOFRAME; break;
1889-    case 'O': touch_mode=1; device[9].d[2]=device[9].d[4]=0x80; break;
1890-    case 'Q': use_mouse=0; break;
1891-    case 'S': disallow_size_change=1; break;
1892-    case 'T': device[12].in=default_in; set_datetime(optarg); break;
1893-    case 'Y': allow_write=1; device[10].out=device[11].out=files_out; device[10].in=device[11].in=files_in; device[10].exp=device[11].exp=files_exp; break;
1894-    case 'Z': use_utc=1; break;
1895-    case 'a': set_audio(optarg); break;
1896-    case 'd': use_debug=1; break;
1897-    case 'e': set_other_program(optarg); break;
1898-    case 'h': default_height=strtol(optarg,0,10); break;
1899-    case 'i': hide_cursor=1; break;
1900-    case 'j': joypad_repeat=1; break;
1901-    case 'm': set_script(optarg); break;
1902-    case 'n': use_screen=0; break;
1903-    case 'p': palet=strtol(optarg,0,10)&7; if(*optarg && optarg[1]=='=') set_palette(optarg+2); break;
1904-    case 'q': use_console=0; break;
1905-    case 's': scroll_size=strtol(optarg,0,10); break;
1906-    case 't': timer_rate=strtol(optarg,0,10); break;
1907-    case 'w': default_width=strtol(optarg,0,10); break;
1908-    case 'x': use_extension=1; break;
1909-    case 'y': allow_write=0; device[10].out=device[11].out=files_out; device[10].in=device[11].in=files_in; device[10].exp=device[11].exp=files_exp; break;
1910-    case 'z': zoom=strtol(optarg,0,10); break;
1911-    default: return 1;
1912-  }
1913-  if(optind==argc) errx(1,"Required argument missing");
1914-  rom_name=argv[optind];
1915-  if(use_console) device[1].out=console_out;
1916-  if(scriptf) {
1917-    fclose(scriptf);
1918-    if(!scriptv) err(1,"Allocation failed");
1919-    do_script(0);
1920-  }
1921-  load_rom();
1922-  if(use_screen) {
1923-    if(zoom<1) errx(1,"Zoom out of range");
1924-    if((default_height<1 || default_width<1) && !(scrflags&SDL_FULLSCREEN)) errx(1,"Screen size out of range");
1925-    if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|(audio_option?SDL_INIT_AUDIO:0)|(joy_mask?SDL_INIT_JOYSTICK:0))) errx(1,"Cannot initialize SDL: %s",SDL_GetError());
1926-    atexit(SDL_Quit);
1927-    device[2].out=screen_out;
1928-    if(!default_width && !default_height && (scrflags&SDL_FULLSCREEN)) set_full_screen_size();
1929-    scr_w=default_width;
1930-    scr_h=default_height;
1931-    PUT16(device[2].d+2,scr_w);
1932-    PUT16(device[2].d+4,scr_h);
1933-    size_changed=1;
1934-    if(joy_mask) {
1935-      if((joy_mask&1) && !SDL_JoystickOpen(joy_player[0])) errx(1,"Cannot open joystick for player I");
1936-      if((joy_mask&2) && !SDL_JoystickOpen(joy_player[1])) errx(1,"Cannot open joystick for player II");
1937-      if((joy_mask&4) && !SDL_JoystickOpen(joy_player[2])) errx(1,"Cannot open joystick for player III");
1938-      if((joy_mask&8) && !SDL_JoystickOpen(joy_player[3])) errx(1,"Cannot open joystick for player IV");
1939-      SDL_JoystickEventState(SDL_ENABLE);
1940-    }
1941-  }
1942-  if(optind+1<argc) strncpy(uxnfile0.name,argv[optind+1],4095);
1943-  if(optind+2<argc) strncpy(uxnfile1.name,argv[optind+2],4095);
1944-  restart:
1945-  size_changed=1;
1946-  ds.p=rs.p=0;
1947-  device[1].d[7]=(optind+1==argc)?0:1;
1948-  if(scriptc) do_script(1);
1949-  run(0x0100);
1950-  if(device[1].d[0] || device[1].d[1]) for(i=optind+1;i<argc;i++) {
1951-    for(j=0;argv[i][j];j++) {
1952-      device[1].d[2]=argv[i][j];
1953-      device[1].d[7]=2;
1954-      run(GET16(device[1].d));
1955-    }
1956-    device[1].d[2]='\n';
1957-    device[1].d[7]=(i==argc-1?4:3);
1958-    run(GET16(device[1].d));
1959-  }
1960-  if(use_screen) {
1961-    if(size_changed) set_screen_mode(scr_w,scr_h);
1962-    if(use_thread) {
1963-      stdin_cond=SDL_CreateCond();
1964-      SDL_CreateThread(stdin_thread_fn,0);
1965-    }
1966-    while(run_screen()) {
1967-      for(i=0;i<15;i++) for(j=0;j<16;j++) device[i].d[j]=0;
1968-      if(scriptc) do_script(0);
1969-      load_rom();
1970-      goto restart;
1971-    }
1972-  } else if(audio_option) {
1973-    run_audio();
1974-  } else {
1975-    device[1].d[7]=1;
1976-    while((device[1].d[0] || device[1].d[1]) && ((i=fgetc(inf))>=0)) {
1977-      device[1].d[2]=i;
1978-      run(GET16(device[1].d));
1979-    }
1980-    if(use_extension && (device[1].d[6]&1)) {
1981-      device[1].d[2]=device[1].d[7]=0;
1982-      run(GET16(device[1].d));
1983-    }
1984-  }
1985-  return 0;
1986-}
1987-
+0, -359
  1@@ -1,359 +0,0 @@
  2-#if 0
  3-gcc -s -O2 -o ./mmlmake mmlmake.c
  4-exit
  5-#endif
  6-
  7-#include <err.h>
  8-#include <stdio.h>
  9-#include <stdlib.h>
 10-#include <string.h>
 11-
 12-#define OP_REST 0x03
 13-#define OP_WAIT 0x05
 14-#define OP_INSTRUMENT 0x07
 15-#define OP_GOTO 0x09
 16-#define OP_LOOPSTART 0x0B
 17-#define OP_LOOPEND 0x0D
 18-#define OP_VOLUME 0x0F
 19-
 20-typedef struct {
 21-  FILE*file;
 22-  char*data;
 23-  size_t size;
 24-  unsigned short loop;
 25-  unsigned short address;
 26-} Track;
 27-
 28-typedef struct {
 29-  const char*name;
 30-  void(*call)(char*);
 31-} Command;
 32-
 33-typedef struct {
 34-  char*data;
 35-  size_t size;
 36-  unsigned short address;
 37-  unsigned char env[2];
 38-  char loop;
 39-} Instrument;
 40-
 41-static const signed char notes[12]={9,11,0,2,4,5,7};
 42-
 43-static unsigned char*driver_data;
 44-static size_t driver_size;
 45-static int divisions=120;
 46-static char stereo=0;
 47-static Track tracks[4];
 48-static Instrument instrum[128];
 49-static int cur_op=0;
 50-static int cur_time=0;
 51-static int cur_track;
 52-static int rested=0;
 53-static int total_time=0;
 54-static char debug=0;
 55-
 56-static void cmd_debug(char*arg) {
 57-  debug=1;
 58-}
 59-
 60-static void cmd_divisions(char*arg) {
 61-  divisions=strtol(arg,&arg,10);
 62-  if(!divisions || (*arg!='\r' && *arg!='\n' && *arg)) errx(1,"Improper argument for #DIVISIONS");
 63-}
 64-
 65-static void cmd_driver(char*arg) {
 66-  FILE*fp=fopen(arg,"rb");
 67-  if(!fp) err(1,"Cannot open driver file (%s)",arg);
 68-  fseek(fp,0,SEEK_END);
 69-  driver_size=ftell(fp);
 70-  if(driver_size<32 || driver_size>0xFF00) errx(1,"Improper size of driver file");
 71-  fseek(fp,0,SEEK_SET);
 72-  driver_data=malloc(driver_size);
 73-  if(!driver_data) err(1,"Allocation failed");
 74-  if(!fread(driver_data,driver_size,1,fp)) err(1,"Error reading driver file");
 75-  fclose(fp);
 76-  if(memcmp(driver_data,"\xA0\x00\x00\xA0\xF8\x00\xA0\x00\xFA\xA0\x00\x00\xA0\xFC\x00\xA0\x00\xFE\x31\x31\x31\x31",0x16)) errx(1,"Wrong driver file");
 77-}
 78-
 79-static void cmd_stereo(char*arg) {
 80-  stereo=strtol(arg,&arg,10);
 81-  if(stereo<0 || stereo>15 || (*arg!='\r' && *arg!='\n' && *arg)) errx(1,"Improper argument for #STEREO");
 82-}
 83-
 84-static void cmd_tempo(char*arg) {
 85-  int x;
 86-  x=strtol(arg,&arg,10);
 87-  if(x>600 || x<12 || (*arg!='\r' && *arg!='\n' && *arg)) errx(1,"Improper argument for #TEMPO");
 88-  divisions=14400/x;
 89-}
 90-
 91-static const Command commands[]={
 92-  {"DEBUG",cmd_debug},
 93-  {"DIVISIONS",cmd_divisions},
 94-  {"DRIVER",cmd_driver},
 95-  {"STEREO",cmd_stereo},
 96-  {"TEMPO",cmd_tempo},
 97-  {0,0}
 98-};
 99-
100-static void do_command(char*c) {
101-  int i;
102-  char*s=strchr(c,' ');
103-  if(s) *s++=0; else errx(1,"Missing argument for #%s",c);
104-  for(i=0;commands[i].name;i++) if(!strcmp(commands[i].name,c)) {
105-    commands[i].call(s);
106-    return;
107-  }
108-  errx(1,"Bad command: #%s",c);
109-}
110-
111-static void do_music(char*line) {
112-  char*s=strchr(line,' ');
113-  int ch;
114-  if(!s) errx(1,"Improper music line");
115-  while(line<s) {
116-    if(*line<'A' || *line>'D') errx(1,"Improper music line");
117-    ch=*line++-'A';
118-    if(!tracks[ch].file) {
119-      tracks[ch].file=open_memstream(&tracks[ch].data,&tracks[ch].size);
120-      if(!tracks[ch].file) err(1,"Cannot open memory stream");
121-    }
122-    fprintf(tracks[ch].file,"%s ",s);
123-  }
124-}
125-
126-static void do_instrument(char*s) {
127-  int i;
128-  int n=strtol(s,&s,10);
129-  FILE*fp;
130-  if(n&~127) errx(1,"Instrument number out of range");
131-  if(instrum[n].data) errx(1,"Instrument %d already defined",n);
132-  while(*s==' ' || *s=='\t') ++s;
133-  if(*s=='[') {
134-    ++s;
135-    i=strtol(s,&s,10); if(i&~15) errx(1,"Improper envelope");
136-    instrum[n].env[0]=i>>4;
137-    i=strtol(s,&s,10); if(i&~15) errx(1,"Improper envelope");
138-    instrum[n].env[0]|=i;
139-    i=strtol(s,&s,10); if(i&~15) errx(1,"Improper envelope");
140-    instrum[n].env[1]=i>>4;
141-    i=strtol(s,&s,10); if(i&~15) errx(1,"Improper envelope");
142-    instrum[n].env[1]|=i;
143-    while(*s==' ' || *s=='\t') ++s;
144-    if(*s!=']') errx(1,"Improper instrument definition (%d): %s",n,s);
145-    ++s;
146-    while(*s==' ' || *s=='\t') ++s;
147-  }
148-  if(*s=='$') {
149-    ++s;
150-    instrum[n].loop=0x80;
151-    while(*s==' ' || *s=='\t') ++s;
152-  }
153-  if(*s!='=') errx(1,"Improper instrument definition (%d): %s",n,s);
154-  ++s;
155-  while(*s==' ' || *s=='\t') ++s;
156-  fp=fopen(s,"rb");
157-  if(!fp) err(1,"Cannot open data file for instrument %d",n);
158-  fseek(fp,0,SEEK_END);
159-  i=ftell(fp);
160-  if(i<2 || i>0xFF00) errx(1,"Improper size of data file for instrument %d",n);
161-  instrum[n].data=malloc(instrum[n].size=i);
162-  if(!instrum[n].data) err(1,"Allocation failed");
163-  fseek(fp,0,SEEK_SET);
164-  if(!fread(instrum[n].data,i,1,fp)) err(1,"Cannot read instrument data");
165-  fclose(fp);
166-}
167-
168-static void do_line(char*line) {
169-  char*s=line+strlen(line);
170-  while(s>line && (s[-1]=='\r' || s[-1]=='\n' || s[-1]==' ' || s[-1]=='\t')) *--s=0;
171-  switch(*line) {
172-    case 'A': case 'B': case 'C': case 'D': do_music(line); break;
173-    case '#': do_command(line+1); break;
174-    case '@': do_instrument(line+1); break;
175-    case 0: case ';': break;
176-    default: errx(1,"Bad command: %s",line);
177-  }
178-}
179-
180-static void instrument_address(void) {
181-  int n;
182-  int a=driver_size+0x0100;
183-  for(n=0;n<128;n++) if(instrum[n].data) {
184-    instrum[n].address=a;
185-    a+=instrum[n].size+5;
186-  }
187-}
188-
189-static void send_time(void) {
190-  int i;
191-  if(!cur_time) return;
192-  total_time+=cur_time;
193-  while(cur_time) {
194-    if(cur_time>255) i=255; else i=cur_time;
195-    cur_time-=i;
196-    fputc(cur_op,tracks[cur_track].file);
197-    fputc(-i,tracks[cur_track].file);
198-    cur_op=OP_WAIT;
199-  }
200-}
201-
202-static int note_length(char**ss,int n) {
203-  char*s=*ss;
204-  int i;
205-  if(i=strtol(s,&s,10)) n=divisions/i;
206-  i=n;
207-  while(*s=='.') n+=i/=2;
208-  *ss=s;
209-  if(n<1) errx(1,"Improper note length");
210-  return n;
211-}
212-
213-static char*add_note(char*s,int n,int t) {
214-  int v=notes[s[-1]-'a']+t;
215-  int i;
216-  send_time();
217-  while(*s=='-') s++,v--;
218-  while(*s=='+') s++,v++;
219-  while(*s==',' || *s=='_') s++,v-=12;
220-  while(*s=='\'') s++,v+=12;
221-  n=note_length(&s,n);
222-  if(v<0 || v>127) errx(1,"Note out of range");
223-  cur_op=v+0x80;
224-  cur_time=n;
225-  return s;
226-}
227-
228-static char*add_rest(char*s,int n) {
229-  send_time();
230-  n=note_length(&s,n);
231-  cur_op=OP_REST;
232-  cur_time=n;
233-  return s;
234-}
235-
236-static char*add_wait(char*s,int n) {
237-  n=note_length(&s,n);
238-  cur_time+=n;
239-  return s;
240-}
241-
242-static char*set_instrument(char*s,FILE*fp) {
243-  int n;
244-  if(*s<'0' || *s>'9') errx(1,"Improper music command (@%c)",*s);
245-  n=strtol(s,&s,10);
246-  if(n&~127) errx(1,"Instrument number out of range");
247-  if(!instrum[n].size || !instrum[n].address) errx(1,"Undefined instrument");
248-  n=instrum[n].address;
249-  fputc(OP_INSTRUMENT,fp);
250-  fputc(n>>8,fp);
251-  fputc(n&255,fp);
252-  return s;
253-}
254-
255-static char*set_volume(char*s,FILE*fp,int y) {
256-  int n;
257-  if(*s<'0' || *s>'9') errx(1,"Improper music command (v%c)",*s);
258-  n=strtol(s,&s,10);
259-  if(n&~15) errx(1,"Volume number out of range");
260-  fputc(OP_VOLUME,fp);
261-  fputc(n*0x11-(((stereo*n)/15)<<(y?0:4)),fp);
262-  return s;
263-}
264-
265-static void do_track(int ch) {
266-  int notelen=divisions/4;
267-  int octave=5;
268-  int transpose=0;
269-  int looptime=0;
270-  Track*tr=tracks+ch;
271-  char*s;
272-  if(tr->file) {
273-    fclose(tr->file);
274-    s=tr->data;
275-  } else {
276-    s="Lw1 ";
277-  }
278-  if(!s) err(1,"Unknown error");
279-  tr->data=0;
280-  tr->size=0;
281-  tr->file=open_memstream(&tr->data,&tr->size);
282-  if(!tr->file) err(1,"Cannot open memory stream");
283-  cur_track=ch;
284-  cur_time=total_time=0;
285-  cur_op=OP_WAIT;
286-  rested=0;
287-  while(*s) switch(*s++) {
288-    case ' ': case '\r': case '\n': case '\t': break;
289-    case 'a' ... 'g': rested=0; s=add_note(s,notelen,octave*12+transpose); break;
290-    case 'l': notelen=note_length(&s,notelen); break;
291-    case 'n': send_time(); cur_op=strtol(s,&s,10)+transpose+0x80; cur_time=notelen; break;
292-    case 'o': octave=strtol(s,&s,10); if(octave<0 || octave>9) errx(1,"Improper octave (%d)",octave); break;
293-    case 'r': s=rested?add_wait(s,notelen):add_rest(s,notelen); rested=1; break;
294-    case 'v': send_time(); s=set_volume(s,tr->file,ch&1); break;
295-    case 'w': case '^': s=add_wait(s,notelen); break;
296-    case 'K': transpose=strtol(s,&s,10); break;
297-    case 'L': send_time(); looptime=total_time; tr->loop=ftell(tr->file); rested=0; break;
298-    case 'X': send_time(); fputc(strtol(s,&s,0),tr->file); rested=0; break;
299-    case '<': if(octave) --octave; break;
300-    case '>': if(octave<9) ++octave; break;
301-    case '@': send_time(); s=set_instrument(s,tr->file); break;
302-    case '[': send_time(); rested=0; fputc(OP_LOOPSTART,tr->file); break;
303-    case ']': send_time(); rested=0; fputc(OP_LOOPEND,tr->file); fputc(strtol(s,&s,10)-2,tr->file); break;
304-    default: errx(1,"Improper music command (%c)",s[-1]);
305-  }
306-  send_time();
307-  fprintf(stderr,"%c %d %d\n",ch+'A',looptime,total_time);
308-  fclose(tr->file);
309-  if(!tr->data) err(1,"Allocation failed");
310-  if(tr->size<1 || tr->size>=0xFFFF) errx(1,"Too big output size");
311-}
312-
313-static void do_output(void) {
314-  static const char z[8]={1,5,10,14,2,7,11,16};
315-  int a=driver_size+0x0100;
316-  int n;
317-  if(debug) fprintf(stderr,"Data start address = 0x%04X\n",a);
318-  for(n=0;n<128;n++) if(instrum[n].data) a+=instrum[n].size+5;
319-  for(n=0;n<4;n++) {
320-    if(debug) fprintf(stderr,"Track %c address = 0x%04X\n",n+'A',a);
321-    tracks[n].address=a;
322-    driver_data[z[n]]=a>>8;
323-    driver_data[z[n+4]]=a&255;
324-    a+=tracks[n].size+3;
325-    if(a<0 || a>0xFFFF) errx(1,"Too big output size");
326-  }
327-  if(debug) fprintf(stderr,"Data end address = 0x%04X\n",a);
328-  fwrite(driver_data,1,driver_size,stdout);
329-  for(n=0;n<128;n++) if(instrum[n].data) {
330-    if(debug) fprintf(stderr,"Instrument %d address = 0x%04X\n",n,instrum[n].address);
331-    fwrite(instrum[n].env,1,2,stdout);
332-    putchar(instrum[n].size>>8);
333-    putchar(instrum[n].size&255);
334-    putchar(instrum[n].loop);
335-    fwrite(instrum[n].data,1,instrum[n].size,stdout);
336-  }
337-  for(n=0;n<4;n++) {
338-    fwrite(tracks[n].data,1,tracks[n].size,stdout);
339-    putchar(OP_GOTO);
340-    a=tracks[n].address+tracks[n].loop;
341-    putchar(a>>8);
342-    putchar(a&255);
343-  }
344-}
345-
346-int main(int argc,char**argv) {
347-  char*linebuf=0;
348-  size_t linesize=0;
349-  while(getline(&linebuf,&linesize,stdin)>0) do_line(linebuf);
350-  if(!driver_size) errx(1,"Missing #DRIVER command");
351-  free(linebuf);
352-  instrument_address();
353-  do_track(0);
354-  do_track(1);
355-  do_track(2);
356-  do_track(3);
357-  do_output();
358-  return 0;
359-}
360-
+0, -124
  1@@ -1,124 +0,0 @@
  2-MML maker for Uxn
  3-
  4-Reads the MML text from stdin and write output to stdout.
  5-
  6-Status is written to stderr. Each line is the number of frames before the
  7-loop start and then the total number of frames.
  8-
  9-
 10-=== Outer commands ===
 11-
 12-;
 13-  Comment; does nothing.
 14-
 15-#DIVISIONS
 16-  Set the number of frames per whole note. (Normally, there are sixty
 17-  frames in one second.)
 18-
 19-#DRIVER
 20-  The name of the driver file. This command is mandatory.
 21-
 22-#STEREO
 23-  Set the stereo amount, from 0 (mono only; default) to 15.
 24-
 25-#TEMPO
 26-  Set the number of quarter notes per minute. You should specify either
 27-  this command or #DIVISIONS, not both; if you specify both then only
 28-  the one that comes later in the file will be used.
 29-
 30-@
 31-  Define a instrument; see below section for details.
 32-
 33-A B C D
 34-  Add track commands. You can have any sequence of letters
 35-  A, B, C, and D, and then a space and then track commands,
 36-  which means the notes for the music; see below section.
 37-
 38-
 39-=== Instrument definition ===
 40-
 41-The instrument definition format can be one of:
 42-
 43-@number=filename
 44-@number$=filename
 45-@number[attack decay sustain release]=filename
 46-@number[attack decay sustain release]$=filename
 47-
 48-The number is 0 to 127.
 49-
 50-If $ is present then the sample will be looped.
 51-
 52-If [] is present then they are the time of each section of the envelope,
 53-in fifteenths of a second (each can be 0 to 15); if absent, or if all of
 54-the numbers are zero, then there is no envelope.
 55-
 56-The file contains the unsigned 8-bits sample data at 44100 Hz middle C.
 57-
 58-
 59-=== Track commands ===
 60-
 61-a b c d e f g
 62-  Play a note. You can optionally add any combination of of - + ' _ for
 63-  flat, sharp, high octave, and low octave, respectively. Optionally can
 64-  also specify the note duration (see l command for details). Any such
 65-  specifications of octave/duration apply to the current note only.
 66-
 67-l
 68-  Set note length for following notes (until changed by another l command).
 69-  It is a number of fraction of the note, e.g. 4 for a quarter note, 8 for
 70-  eighth note, etc. You can optionally add dots for longer durations, like
 71-  in ordinary music.
 72-
 73-n
 74-  Play a note by the MIDI note number.
 75-
 76-o
 77-  Set the octave; follow by a number 0 to 9 indicating which octave, where
 78-  5 is the default octave and is the octave containing the middle C note.
 79-
 80-r
 81-  Play a rest. Can optionally have the note length, like notes can be.
 82-
 83-v
 84-  Set volume for further notes, from 0 to 15.
 85-
 86-w
 87-  Wait for a specified duration without silencing the current note or
 88-  changing anything else.
 89-
 90-K
 91-  Set transpose amount, which is a signed number of semitones. This is
 92-  not relative to the previous transpose amount; it is reset each time.
 93-
 94-L
 95-  Set global loop point.
 96-
 97-X
 98-  Follow by a number to emit that byte directly. It is not meaningful
 99-  unless you are using a customized driver program which is capable of
100-  interpreting this number.
101-
102-^
103-  Tied note with a specified duration (as for rests and notes). (Actually,
104-  this command is same as w command.)
105-
106-<
107-  Low octave.
108-
109->
110-  High octave.
111-
112-@
113-  Follow by the instrument number 0 to 127, to set the instrument for any
114-  further notes being played in this channel.
115-
116-[
117-  Begin local loop. Loops cannot be nested.
118-
119-]
120-  End local loop; follow by the repeat count number, which must be at least
121-  2 and cannot exceed 255. You can have multiple ends for a local loop in
122-  which case later ones may have a higher number, which indicates the total
123-  number of times that it plays from the beginning of this loop, and is
124-  going backward only if the number of times specified is not reached yet.
125-
+0, -81
 1@@ -1,81 +0,0 @@
 2-|d0 @ch-loops $8
 3-|d8 @ch-loopc $8
 4-|e0 @ch-vol $8
 5-|e8 @ch-pitch $8
 6-|f0 @ch-time $8
 7-|f8 @ch-ptr $8
 8-
 9-|0100
10-  LIT2 0000
11-  LIT2 f800
12-  LIT2 00fa
13-  LIT2 0000
14-  LIT2 fc00
15-  LIT2 00fe
16-  STZ2 STZ2 STZ2 STZ2
17-  [; #20 DEO2 ]@
18-  LIT2r 00f8
19-@command
20-  STHrk #08 SUB LDZ
21-  DUP ,nxchan JCN POP
22-  ,readc JSR
23-  DUP #80 LTH [, JCN #01 ]@ LDR2 JMP2
24-    ( 01 ) :cmd-note
25-    ( 03 ) :cmd-rest
26-    ( 05 ) :cmd-wait
27-    ( 07 ) :cmd-instrument
28-    ( 09 ) :cmd-goto
29-    ( 0b ) :cmd-loopstart
30-    ( 0d ) :cmd-loopend
31-    ( 0f ) :cmd-volume
32-@nxchan
33-  INC STHrk #08 SUB STZ
34-  INCr INCr STHrk
35-  ,command JCN POP2r BRK
36-@readc
37-  OVR2r STH2r LDA2 INC2k OVR2r STH2r STA2 LDA JMP2r
38-@send
39-  OVR2r STH2r #30 SFT ADD ADD DEO2 JMP2r
40-
41-@cmd-note
42-  STHrk #18 SUB LDZ
43-  SWP STHrk #10 SUB LDZ ADD #7e ,send JSR
44-  ,cmd-wait JMP
45-
46-@cmd-rest
47-  #0000 #7e ,send JSR
48-  ( fall through )
49-@cmd-wait
50-  ,readc JSR
51-  STHrk #08 SUB STZ
52-  ,command JMP
53-
54-@cmd-instrument
55-  ,readc JSR ,readc JSR
56-  LDA2k #78 ,send JSR INC2 INC2
57-  LDA2k #7a ,send JSR INC2 INC2
58-  LDAk STHrk #10 SUB STZ INC2
59-  #7c ,send JSR
60-  ;command JMP2
61-
62-@cmd-goto
63-  ,readc JSR ,readc JSR
64-  STHrk STZ2
65-  ;command JMP2
66-
67-@cmd-loopstart
68-  STH2rk #20 SUB STZ
69-  STHrk LDZ2 STHrk #28 SUB STZ2
70-  ;command JMP2
71-
72-@cmd-loopend
73-  STHrk #20 SUB STHk LDZ
74-  INCk STHr STZ
75-  ;readc JSR2 GTH [, JCN STHrk #28 SUB LDZ2 STHrk STZ2 ]@
76-  ;command JMP2
77-
78-@cmd-volume
79-  ;readc JSR2
80-  STHrk #18 SUB STZ
81-  ;command JMP2
82-
+0, -7
1@@ -1,7 +0,0 @@
2-#DRIVER driver.bin
3-#DIVISIONS 120
4-
5-@0 [0 8 0 12]$ = square50.u8
6-
7-A v15@0L
8-A l4 [aab2]2 [abc'b ab8a8f2 ecef ee8c8<b2>]2 [aab2]2 efb8a8f e2r2
+0, -0
+0, -0
+0, -0
+0, -0
+0, -0
+0, -154
  1@@ -1,154 +0,0 @@
  2-\\ BLAKE2s (this implementation is public domain)
  3-\\ Requires a nonstandard feature of uxn38 (port #16).
  4-\\ Specify hash size in bytes (1 to 32) on command-line argument.
  5-\\ This implementation is limited to 4 gigabytes of input.
  6-\\ (See RFC 7693)
  7-
  8-|00
  9-  @hi $2 @lo $2 ( number of bytes of input )
 10-  @nn $2 ( number of bytes of hash )
 11-  @ax @ah $1 @al $1
 12-  @bx @bh $1 @bl $1
 13-  @cx @ch $1 @cl $1
 14-  @dx @dh $1 @dl $1
 15-|40 @h ( internal state, and copy of initialization vector )
 16-|80 @v ( local work vector )
 17-|c0 @m ( data of message block )
 18-
 19-|0100
 20-  #0116 DEO
 21-  { 01 0040 0000 :IV 0000 00 [@ 40 } LITr 02 DEO2rk #60 ]; STA DEO2r
 22-  \\ First figure out output block size (in bytes)
 23-  [; #10 DEO2 BRK ]@
 24-  #0a12 DEI EQU [? LIT2 0a -nn LDZ MUL #d012 DEI ADD ADD .nn STZ BRK ]@
 25-  LIT2 67 -nn LDZ EOR #43 STZ
 26-  #6b08 #40 STZ2
 27-  \\ Ready to receive data
 28-  LITr -m
 29-  [; #10 DEO2 BRK ]@
 30-  #17 DEI [?
 31-    \\ Final
 32-    #e07c #78 STZ2
 33-    #2654 #7a STZ2
 34-    F
 35-    .nn LDZ2 [@ DUP #43 EOR LDZ hex INC NEQk ]?
 36-    #0a18 DEO #800f DEO BRK
 37-  ]@
 38-  STHrk [? POPr LITr -m F ;ztom #02 DEO2 ]@
 39-  .lo LDZ2k INC2 ORAk [? .hi LDZ2k INC2 ROT STZ2 ]@ ROT STZ2
 40-  #12 DEI STHrk #03 EOR STZ INCr
 41-  BRK
 42-
 43-@F
 44-  \\ Initialization
 45-  ;htov #02 DEO2
 46-  .hi LDZ2 #510e EOR2 #b0 STZ2
 47-  .lo LDZ2 #527f EOR2 #b2 STZ2
 48-  \\ Mixing
 49-  ;SIGMA [@
 50-    #8082 #9092 #a0a2 #b0b2 G
 51-    #8486 #9496 #a4a6 #b4b6 G
 52-    #888a #989a #a8aa #b8ba G
 53-    #8c8e #9c9e #acae #bcbe G
 54-    #8082 #9496 #a8aa #bcbe G
 55-    #8486 #989a #acae #b0b2 G
 56-    #888a #9c9e #a0a2 #b4b6 G
 57-    #8c8e #9092 #a4a6 #b8ba G
 58-    DUP
 59-  ]? POP2
 60-  \\ Final XOR
 61-  LITr 40 [@
 62-    STHrk LDZ2
 63-    STHrk #40 ADD LDZ2
 64-    STHrk #60 ADD LDZ2
 65-    EOR2 EOR2 STHrk STZ2
 66-    INCr INCr STHrk #60 NEQ
 67-  ]? POPr JMP2r
 68-
 69-%gah { .ah LDZ LDZ2 } %pah { .ah LDZ STZ2 }
 70-%gal { .al LDZ LDZ2 } %pal { .al LDZ STZ2 }
 71-%gbh { .bh LDZ LDZ2 } %pbh { .bh LDZ STZ2 }
 72-%gbl { .bl LDZ LDZ2 } %pbl { .bl LDZ STZ2 }
 73-%gch { .ch LDZ LDZ2 } %pch { .ch LDZ STZ2 }
 74-%gcl { .cl LDZ LDZ2 } %pcl { .cl LDZ STZ2 }
 75-%gdh { .dh LDZ LDZ2 } %pdh { .dh LDZ STZ2 }
 76-%gdl { .dl LDZ LDZ2 } %pdl { .dl LDZ STZ2 }
 77-
 78-\\ v[a] := (v[a] + v[b] + x)
 79-\\ v[d] := (v[d] ^ v[a]) >>> 16
 80-\\ v[c] := (v[c] + v[d])
 81-\\ v[b] := (v[b] ^ v[c]) >>> 12
 82-\\ v[a] := (v[a] + v[b] + y)
 83-\\ v[d] := (v[d] ^ v[a]) >>> 8
 84-\\ v[c] := (v[c] + v[d])
 85-\\ v[b] := (v[b] ^ v[c]) >>> 7
 86-
 87-%rotate {
 88-  STH2k LITr \_:f^1+4<w SFT2r
 89-  LIT \_:w SFT2 SWP2
 90-  gbl EOR2
 91-  STH2k LITr \_:w SFT2r EOR2r
 92-  LIT \_f^1+4<w SFT2 ORA2
 93-  pbh LITr -bl LDZr STZ2r
 94-}
 95-
 96- ( hi1* lo1* hi2* lo2* -- lo* hi* )
 97- \\ Add 32-bit numbers and swap high/low halfs
 98-%asw {
 99-  ROT2 STH2k ADD2 STH2k ROT2 ROT2 GTH2r #00 STHr ADD2 ADD2
100-}
101-
102- ( sigma* -- sigma* adh* adl* )
103-%G1 {
104-  LDAk LDZ2k ROT INC INC LDZ2
105-  gah gal asw SWP2 gbh gbl asw
106-  SWP2k pal pah
107-  gdh EOR2 SWP2 gdl EOR2
108-}
109-
110- ( dh* dl* -- cl* cbh* )
111-%G2 {
112-  gch gcl asw SWP2k pcl pch
113-  gbh EOR2
114-}
115-
116-@G ( a* b* c* d* sigma* -- sigma* )
117-  .dx STZ2 .cx STZ2 .bx STZ2 .ax STZ2
118-  G1 SWP2k pdl pdh SWP2
119-  G2 \c rotate INC
120-  G1 ROT ROT STH2k pdl SWP DUP2 pdh STH2r
121-  G2 \7 rotate INC
122-  JMP2r
123-
124-@hex ( x -- )
125-  DUP #04 SFT [& #0f AND ]@
126-  DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO JMP2r
127-
128-@htov 01 0040 0000 :h 0000 :v
129-@ztom 01 0040 0000 :zero 0000 :m
130-
131-@dump ( -- )
132-  ( TEST ONLY )
133-  #00 [@ LDZk hex INC DUP #03 AND [? #2018 DEO ]@ DUP #0f AND [? #0a18 DEO ]@ DUP ]?
134-  POP #0a18 DEO JMP2r
135-
136-@Before-alignment
137-\_@ff'&[@ff00"&18<+!]  ( alignment )
138-@IV
139-  6a09 e667 bb67 ae85 3c6e f372 a54f f53a
140-  510e 527f 9b05 688c 1f83 d9ab 5be0 cd19
141-@zero
142-  $40
143-@SIGMA
144-  c0 c4 c8 cc d0 d4 d8 dc e0 e4 e8 ec f0 f4 f8 fc
145-  f8 e8 d0 e0 e4 fc f4 d8 c4 f0 c0 c8 ec dc d4 cc
146-  ec e0 f0 c0 d4 c8 fc f4 e8 f8 cc d8 dc c4 e4 d0
147-  dc e4 cc c4 f4 f0 ec f8 c8 d8 d4 e8 d0 c0 fc e0
148-  e4 c0 d4 dc c8 d0 e8 fc f8 c4 ec f0 d8 e0 cc f4
149-  c8 f0 d8 e8 c0 ec e0 cc d0 f4 dc d4 fc f8 c4 e4
150-  f0 d4 c4 fc f8 f4 d0 e8 c0 dc d8 cc e4 c8 e0 ec
151-  f4 ec dc f8 f0 c4 cc e4 d4 c0 fc d0 e0 d8 c8 e8
152-  d8 fc f8 e4 ec cc c0 e0 f0 c8 f4 dc c4 d0 e8 d4
153-  e8 c8 e0 d0 dc d8 c4 d4 fc ec e4 f8 cc f0 f4 c0
154-\_@ff00"&(1E)  ( assertion )
155-
+0, -57
 1@@ -1,57 +0,0 @@
 2-\\ Discordian date
 3-\\ (Public domain)
 4-
 5-|0100
 6-  say "Today 20 "is 20 00
 7-  #00c2 DEI2 DUP2
 8-  #011d NEQ2 [? say "St. 20 "Tib's 20 "Day 00 !skip ]@
 9-  \\ Convert Gregorian date to number of days, excluding St. Tib's Day
10-  SWP #0007 SFT2 ;days ADD2 LDA2 ADD2
11-  \\ Discordian day of week
12-  STH2k LIT2r 0005 DIV2rk MUL2r SUB2r
13-  lsay :wday
14-  say ", 20 00
15-  \\ Discordian month and day of month
16-  #0049 DIV2k STH2k MUL2 SUB2
17-  lsay :month
18-  INC2 number
19-@skip
20-  say ", 20 "YOLD 00
21-  \\ Convert AD to YOLD
22-  #c0 DEI2 #048e ADD2 number
23-  say ". 0a 00 #800f DEO
24-
25-@days
26-  ffff 001e 003a 0050 0077 0096 00b4 00d3 00f2 0110 012f 014d
27-
28-@wday :&0 :&1 :&2 :&3 :&4
29-  &0 "Sweetmorn 00 JMP2
30-  &1 "Boomtime 00 JMP2
31-  &2 "Pungenday 00 JMP2
32-  &3 "Prickle-Prickle 00 JMP2
33-  &4 "Setting 20 "Orange 00 JMP2
34-
35-@month :&0 :&1 :&2 :&3 :&4
36-  &0 "Chaos 00 JMP2
37-  &1 "Discord 00 JMP2
38-  &2 "Confusion 00 JMP2
39-  &3 "Bureaucracy 00 JMP2
40-  &4 "The 20 "Aftermath 00 JMP2
41-
42-@lsay
43-  STH2r DUP2r ADD2r STH2k LDA2r ADD2r LDA2r INC2 INC2
44-@say
45-  [@ LDArk LITr 18 DEOr INC2r LDArk STHr ]? INC2r JMP2r
46-
47-@number
48-  #2018 DEO
49-  LITr 00
50-  [@
51-    #000a DIV2k STH2k MUL2 SUB2
52-    STH2 SWP2r STH2r
53-    NIPr LITr 30 ADDr
54-  ORAk ]?
55-  POP2
56-  [@ STHr #18 DEO STHrk ]?
57-  POPr
58-  JMP2r
+0, -37
 1@@ -1,37 +0,0 @@
 2-\\ Deadfish in Uxn
 3-\\ (use in non-GUI mode)
 4-
 5-|0100
 6-  #0000 STH2k
 7-  [; #10 DEO2 BRK ]@
 8-
 9-\\ Replace with 0
10-  DUP2 #0100 NEQ2
11-  [? POP2 STH2rk ]@
12-
13-\\ Check input
14-  #12 DEI
15-  DUP LIT "i EQU ,i JCN
16-  DUP LIT "d EQU ,d JCN
17-  DUP LIT "s EQU ,s JCN
18-  LIT "o EQU ,o JCN BRK
19-
20-@i
21-  POP INC2 BRK
22-
23-@d
24-  POP ORAk STHrk NEQk ROT POP SUB2 BRK
25-
26-@s
27-  POP DUP2 MUL2 BRK
28-
29-@o
30-  DUP2
31-  [@
32-    #000a DIV2k STH2k MUL2 SUB2
33-    STH2 SWP2r STH2r
34-    NIPr LITr 30 ADDr
35-  ORAk ]?
36-  POP2
37-  [@ LITr 18 DEOr STHrk ]?
38-  #0a18 DEO BRK
+0, -46
 1@@ -1,46 +0,0 @@
 2-|0100
 3-  LIT2r ff33
 4-  #17c3 DEI2 INC2 ;random/x STA2
 5-  #c5 DEI2 #c1 DEI2 EOR2 INC2 ;random/y STA2
 6-  DEI ?input
 7-@begin
 8-  DUP2k EOR2 [@ DUPk STZ INC DUP ]?
 9-@loop
10-  \\ Select random card
11-  STHrk DUP #04 SFT ORA DUP #02 SFT ORA DUP EQUk SFT ORA
12-  DUP [@ POP random ADD OVR AND DUP STHrk GTH ]? NIP LDZk
13-  \\ Display card
14-  LIT2r =ranks STHk LITr 02 SFTr ADDr LDAr LITr 18 DEOr
15-  LIT2r =suits STH LITr 03 ANDr ADDr LDAr LITr 18 DEOr
16-  \\ Exchange card
17-  LDZrk STH STZr
18-  \\ Space
19-  STHrk #0d DIVk MUL NEQ #16 MUL #0a ADD #18 DEO
20-  \\ Next
21-  STHrk [? #800f DEO BRK ]@
22-  ADDrk NIPr !loop
23-
24-@suits "cdhs
25-@ranks "A23456789TJQK
26-
27-@input
28-  [; #10 DEO2 BRK ]@
29-  #0417 DEI EQU ?begin
30-  \\ Try to exchange cards at random due to input
31-  &re
32-  #3f3f random AND2
33-  DUP STHrk GTH ?/re SWP DUP STHrk GTH ?/re
34-  LDZk ROT LDZk STH SWP STZ STHr STZ
35-  \\ Change random number seed by input
36-  #12 DEI ;random/x STA
37-  BRK
38-
39-@random ( -- number* )
40-  ,&x LDR2
41-  DUP2 #50 SFT2 EOR2
42-  DUP2 #03 SFT2 EOR2
43-  ,&y LDR2 DUP2 ,&x STR2
44-  DUP2 #01 SFT2 EOR2 EOR2
45-  ,&y STR2k POP
46-  JMP2r
47-  &x $2 &y $2
+0, -17
 1@@ -1,17 +0,0 @@
 2-% This program make the diceware.data file to use with diceware.tal
 3-/In (eff_large_wordlist.txt) (r) file def
 4-/Out (diceware.data) (w) file def
 5-/S 32 string def
 6-{
 7-  In S readline not {quit} if
 8-  S exch length (`````````) putinterval
 9-  [S 6 3 getinterval S 9 3 getinterval S 12 3 getinterval] {
10-    {
11-      dup 45 eq {pop 27} {96 sub} ifelse
12-    } forall
13-    5 bitshift add 5 bitshift add
14-    Out 1 index -8 bitshift write
15-    Out exch 255 and write
16-  } forall
17-} bind loop
18-
+0, -31
 1@@ -1,31 +0,0 @@
 2-|100
 3-  DUP2rk EOR2rk
 4-  ;input #10 DEO2
 5-  #17 DEI [?
 6-    [; [@ LDAk #18 NEQk JMP BRK DEO INC2 ]! ]@
 7-    "Type 20 "five 20 "numbers 20 "1-6 20 "and 20 "then 20 "enter 0a18
 8-  ]@ BRK
 9-
10-@input
11-  #cf12 DEI ADD
12-  #d9 EQUk ?enter
13-  SWP #06 LTHk JMP BRK
14-  SWP LITr 00 STH ADD2r
15-  LITr 00 STH MUL2r BRK
16-
17-@enter
18-  STH2r ;data ADD2
19-  show show show
20-  DUP2rk EOR2rk
21-  #0a18 DEO
22-  #0417 DEI EQU #0f DEO BRK
23-
24-@show
25-  LDA2k
26-  [@
27-    DUPk [? POP POP2 INC2 INC2 JMP2r ]@
28-    #1f AND #60 ADD DUP #7b EQU #4e MUL SUB #18 DEO
29-    #05 SFT2
30-  ]!
31-
32-@data \~diceware.data
+0, -391
  1@@ -1,391 +0,0 @@
  2-|0000
  3-  @Spare $40
  4-  @Height $10 ( Height+(Y<<2)+X; note Height is aligned at 0x10 bytes )
  5-  @Score $1
  6-  @Mani $1
  7-  @Cursor &X $1 &Y $1
  8-  @Mark &X $1 &Y $1
  9-  @Tableau-1 $1 @Tableau
 10-  ( Tableau cards at: Tableau+(0xA*((Y<<2)+X)); Z(0=bottom) )
 11-  ( Set high bit of cards if it is face down )
 12-
 13-|0100
 14-  \\ Colours
 15-  #a0a1 #08 DEO2k #5402 ADD2 DEO2k #bb02 ADD2 DEO2
 16-  \\ Screen
 17-  #00a8 #22 DEO2k #d802 ADD2 DEO2
 18-  #0126 DEO
 19-  \\ Sound
 20-  DUP2k EOR2 #38 DEO2k #0402 ADD2 DEO2
 21-  ;Wave #3c DEO2
 22-  \\ Vectors
 23-  ;inputVec #80 DEO2
 24-  \\ Random numbers
 25-  #c1 DEI2 #c3 DEI2 EOR2 INC ;random/x STA2
 26-  #c5 DEI2 #c7 DEI2 ADD2 INC ;random/y STA2
 27-  ;RandomExt #02 DEO2
 28-  random random POP2 random random POP2
 29-@reset
 30-  \\ Initialize variables
 31-  ;Vinit #02 DEO2
 32-  LIT2 03 -Mani STZ
 33-  \\ Set up deck
 34-  #4000 [@ #01 OVR #03 AND #40 SFT SFT OVR STZ INC EORk ]?
 35-  \\ Mix up cards
 36-  #33 [@
 37-    DUPk #04 SFT ORA DUP #02 SFT ORA DUP EQUk SFT ORA random AND LTHk
 38-    [?
 39-      STH2k LDZ SWPr LDZr OVR STZ SWPr STZr
 40-      #01 SUB DUP
 41-    ]@
 42-  POP DUP #03 NEQ ]?
 43-  \\ Deal cards (now the stack has #03 on top)
 44-  LITr 01 [@
 45-    #04 STHrk .Height ADD STZ
 46-    STHrk #0a MUL deal2 deal2 POP
 47-    INCr DUPr LITr 03 EQUr ADDr DUPr LITr 0c EQUr ADDr
 48-  STHrk #0f NEQ ]?
 49-  \\ Ready
 50-  sound fd 54 4f 4c 43 4f 00
 51-@display
 52-  \\ Tableau
 53-  LITr 01 [@
 54-    STHrk #03 AND STHrk #02 SFT cursorxy
 55-    .Height STHrk ADD LDZ
 56-    DUP [? showcard ][ STHrk #0a MUL ADD .Tableau-1 ADD revealcard ]@
 57-    INCr DUPr LITr 03 EQUr ADDr DUPr LITr 0c EQUr ADDr
 58-  STHrk #0f NEQ ]?
 59-  \\ Spare
 60-  #0500 dispspare dispspare POP
 61-  \\ Status
 62-  #000d showixy [' "Score: ]' 00
 63-  .Score LDZk #0a DIVk DUP [' #30 ]' ADD showc MUL SUB [' #30 ]' ADD showc
 64-  #0f0d showixy [' "Mani: ]' 00
 65-  LIT2 [' 30 ]' -Mani LDZ ADD showc
 66-@showcursor ( -- )
 67-  \\ Contents of pile
 68-  #0029 DEO #702b DEO #802e DEO
 69-  LIT2 03 -Cursor/X LDZ LTH [?
 70-    LIT2 -Tableau -Cursor LDZ2 xym STHk #0a MUL ADD
 71-    LITr -Height ADDr LDZr STHk ADDr
 72-    [@
 73-      DUP STHrk EQU ?/x
 74-      LDZk DUP #80 LTH [? POP #07 ]@ showcard
 75-      INC
 76-    ]! &x
 77-  ]@
 78-  \\ Cursor position
 79-  cls2
 80-  LIT2 0d -Score LDZ GTH [? #000e showixy [' "You 20 "win! ]' 00 BRK ]@
 81-  .Cursor cursorat ;Cards/cursor showoverlay
 82-  .Mark LDZ2k ORA [? BRK ]@ cursorat ;Cards/mark showoverlay @brk BRK
 83-
 84-@deal2
 85-  [& ]@
 86-  STH INC LDZk #80 ORA
 87-  STHrk .Tableau ADD STZ
 88-  STHr INC JMP2r
 89-
 90-@RandomExt
 91-  03 f0
 92-  4105 259c e061 11f0 963f 0026 1874 5416
 93-  $1 00 10 =random
 94-
 95-@inputVec
 96-  LIT2 &mem ff82 DEI EQUk ?brk
 97-  DUPk ,&mem STR #08 EQU ?reset
 98-  LIT2 0c -Score LDZ LTH ?brk
 99-  LITr -Cursor
100-  DUPk #80 EQU ?/r #40 EQU ?/l
101-  INCrk
102-  DUPk #20 EQU ?/d #10 EQU ?/l
103-  DUPk #02 EQU ?/b EQUk EQU ?/a
104-  &sh showcursor
105-
106-  &r
107-    \r LDZk DUP #05 LTH ADD DUP #04 EQU &rsa ADD &rsh SWP STZ \r
108-  !/sh
109-
110-  &l
111-    \r LDZk DUPk DIV SUB DUP #04 EQU SUB \r
112-  !/rsh
113-
114-  &d
115-    \r LDZk DUP #03 LTH \r
116-  !/rsa
117-
118-  &b
119-    POPr LDZ2r DUP2r LITr 20 SFTr ADDr
120-    .Mark LDZ2 ORAk ?/un ( 00 00 )
121-    STHrk .Height ADD LDZ EQU ?/sh ( 00 )
122-    LIT2 05 -Cursor/X LDZ EQU ?/sh /nm
123-    LIT2 02 -Cursor LDZ2 #0303 ADD2 ORA AND [?
124-      \\ Move card aside
125-      LDZk NEQk LDZk DUP DIV ADD LDZk DUP DIV ADD LDZk DUP DIV ADD
126-      DUP #04 NEQ ?/s
127-    ][
128-      \\ Move top card only
129-      .Mani LDZ EQU [?
130-        STHrk topcard DUP #00 EQU ?/sh
131-        DUPr LIT2r 0009 SFT2r [& 0201 080b 0407 0e0d ]@ ADD2r LDAr
132-        STHrk topcard ?/sh
133-        #01 STHrk .Height ADD STZ
134-        STHr #0a MUL .Tableau ADD STZ
135-        LITr -Height ADDr LDZrk LITr 01 SUBr SWPr STZr
136-        decmani
137-        sound fe 4c 49 43 42 00
138-      ]@
139-    ]@
140-  &un DUP2k EOR2 .Mark STZ2 !display
141-
142-  &a
143-    .Cursor LDZ2
144-    .Mark LDZ2 ORAk [?
145-      \\ Not already marked, so set the mark
146-      SWP2
147-      OVR #05 NEQ [?
148-        ;Mani LDZ EQU ?/sh
149-        ;Cursor/Y LDZ LDZ
150-      ][
151-        DUP2 xym .Height ADD LDZ #00
152-      ]@
153-      EQU ?/sh .Mark STZ2
154-    ][
155-      EQU2k ?/un /nm
156-      OVR #05 NEQ [?
157-        \\ Check if card should be moved from outside into the tableau
158-        LITr 00 STH STH
159-        OVR STHr EQU ?/un
160-        xym
161-        DUP ,/ah STR
162-        .Height ADD LDZk
163-        DUP #0a EQU ?/un
164-        STHrk LDZ STZr ( height_address height_value card )
165-        decmani
166-        OVR LIT &ah $1 #0a MUL .Tableau ADD ADD STZ
167-        INC SWP STZ
168-        sound fe 4c 48 43 41 00
169-        !/un
170-      ]@
171-      OVR2 OVR #05 NEQ [?
172-        \\ Check if card should be moved to spare side
173-        LDZk ?/un
174-        POP2 xym STH !/s
175-      ]@
176-      xym
177-      ( cx cy mx my cxy )
178-      \\ Check for moving a pile to a adjacent empty cell
179-      DUP .Height ADD LDZ [?
180-        ;Mani LDZ EQU ?/un
181-        STHk #0a MUL .Tableau ADD ;movepile/d STA
182-        \\ Check if it is adjacent
183-        SUB2k ( cx-mx-[cy<my] cy-my ) \\ 0001 0100 ff00 ffff
184-        DUP2k INC2k SUB2 EQU2k STH INC EQU2 STHk INCk EQU2k STH SWP EQU2 STH2r STHr ORA2 ORA
185-        #00 EQU ?/un
186-        \\ It is OK
187-        xym
188-        DUP #0a MUL .Tableau ADD ;movepile/s STA
189-        .Height ADD LITr -Height ADDr
190-        LDZk STHr STZ #00 SWP STZ
191-        ;movepile #02 DEO2
192-        decmani
193-        sound ff 48 4a 00
194-        !/un
195-      ]@
196-      \\ Check for scoring
197-      LITr 00 STH
198-      \\ (Difference of X coordinates must be odd, and same with Y coordinates)
199-      EOR2k AND #01 ANDk NEQ NIP ?/un
200-      xym
201-      DUP topcard STHrk topcard ORA
202-      SWP STH STH2rk
203-      #030c AND2 ORA topcard STH2rk #0c03 AND2 ORA STHk topcard ORA ORA
204-      #0f NEQ ?/un
205-      ROTrk EORr EORr
206-      LIT2 0d -Score LDZ INC DUP2 EQU .Mani LDZ MUL ADD .Score STZ
207-      LIT2 03 -Mani STZ
208-      [@ LITr -Height ADDr LDZrk LITr 01 SUBr SWPr STZr STHrk ]?
209-      sound fe 3c 48 4f 54 5b 00
210-      LIT2 0d -Score LDZ GTH ?/un
211-      sound fd 30 3c 43 48 37 43 47 4a 4f 3c 48 4f 54 00
212-      !display
213-    ]@
214-  !/sh
215-
216-  &s
217-    \\ Move to spare
218-    \\ (Now the primary stack has the slot number #00 to #03)
219-    \\ (Now the secondary stack has the cursor position number #00 to #0f)
220-    STHrk INC topcard STHrk #01 SUB topcard
221-    STHrk #04 ADD topcard STHrk #04 SUB topcard
222-    ORA2 ORA #0f EOR [?
223-      LIT2 03 -Mani STZ
224-      STHrk .Height ADD LDZk DUP EQUk SUB ROT STZ ( spare height )
225-      LITr 0a MULr STH ADDr LITr -Tableau-1 ADDr LDZr STH STZr
226-      sound fd 48 4c 43 48 00
227-    ]@
228-  !/un
229-
230-  \\ Make sure cursor is not on a corner
231-  &nm .Cursor LDZ2 #03 DIVk MUL SUB SWP #03 DIVk MUL SUB ORA ?return !/un
232-
233-@movepile 01 000a 0000 00 &s 00 0000 00 &d 00
234-
235-@topcard ( position -- card )
236-  DUP #10 LTH [? DUP EOR JMP2r ]@
237-  DUP .Height ADD LDZ DUP [? NIP JMP2r ]@
238-  .Tableau-1 ADD SWP #0a MUL ADD LDZ JMP2r
239-
240-\\ @cls cls2 #802e DEO JMP2r
241-@cls2 DUP2k EOR2 #28 DEO2k INC INC DEO2 #c02e DEO @return JMP2r
242-
243-@dispspare [& ]@ DUP2 cursorxy LDZk showcard INC JMP2r
244-
245-@decmani .Mani LDZk NEQk SUB SWP STZ JMP2r
246-
247-@cursorat ( addr -- )
248-  LDZ2
249-@cursorxy ( x y -- )
250-  #03 MUL INC mul8 #2a DEO2
251-  #03 MUL INC INC mul8 #28 DEO2
252-  JMP2r
253-
254-@random ( -- number )
255-  LIT2 &x 0001
256-  DUP2 #50 SFT2 EOR2
257-  DUP2 #03 SFT2 EOR2
258-  LIT2 &y 0001 DUP2 ,&x STR2
259-  DUP2 #01 SFT2 EOR2 EOR2
260-  ,&y STR2k POP2
261-  JMP2r
262-
263-@showc ( char -- )
264-  mul8 ;Font ADD2 #2c DEO2
265-  #012f DEO
266-  JMP2r
267-
268-@showixy ( x y -- )
269-  mul8 #2a DEO2
270-  mul8 #28 DEO2
271-@showi ( -- )
272-  [@
273-    LDArk STHr INC2r DUP [? POP JMP2r ]@
274-    mul8 ;Font ADD2 #2c DEO2
275-    #012f DEO
276-  ]!
277-
278-@revealcard ( addr -- )
279-  LDZk #7f AND SWPk STZ NIP
280-@showcard ( card -- )
281-  mul8 ;Cards ADD2 #2c DEO2
282-  halfshow 01
283-  DEIk STHk #08 ADD SWP DEO
284-  halfshow 21
285-  STH DEOr #29 DEIk #10 ADD SWP DEO
286-  JMP2r
287-
288-@showoverlay ( picture* -- )
289-  #2c DEO2
290-  halfshow c5
291-  DEIk #08 ADD SWP DEO
292-  halfshow e5
293-  POP JMP2r
294-
295-@halfshow #2b LDArk LITr 2f DEOrk LIT2r 1000 ADD2r DEOr INC2r JMP2r
296-
297-@mul8 ( in -- out* ) #0005 SFT2 JMP2r
298-
299-@sound ( -- )
300-  #ee3e DEO
301-  STH2rk LDAk ,&len STR INC2 ,&addr STR2
302-  [@ STH2rk INC2r LDA ]?
303-  LIT2 00 _&time STR
304-  [; #20 DEO2 JMP2r ]@
305-  LIT &time $1 DUP [?
306-    LIT2 &addr $2 INC2k ,&addr STR2 LDA
307-    DUP [? DUP #3e DEO DUPk #20 DEO2 ]@
308-    #3f DEO
309-    POP LIT &len $1
310-  ]@ INC ,&time STR BRK
311-
312-@Cards
313-
314-@Cards/vacant
315-  \-01010101
316-  \-1.......
317-  \-0.......
318-  \-1.......
319-  \-0.......
320-  \-1.......
321-  \-0.......
322-  \-1.......;
323-
324-  \-11111111
325-  \-1.......
326-  \-1.......
327-  \-1......1
328-  \-1......1
329-  \-1......1
330-  \-1......1
331-  \-1..11111;
332-
333-  \-11111111
334-  \-1.......
335-  \-1.......
336-  \-1..11...
337-  \-1..111..
338-  \-1...111.
339-  \-1....111
340-  \-1.....11;
341-@Wave 00 7f ff @xym #20 SFT ADD JMP2r
342-
343-  \-11111111
344-  \-1.......
345-  \-1....111
346-  \-1...1111
347-  \-1..111..
348-  \-1.111...
349-  \-1.11....
350-  \-1.11....;
351-
352-@Cards/cursor
353-  \=2.......
354-  \=.3333332
355-  \=.3......
356-  \=.3......
357-  \=.3......
358-  \=.3......
359-  \=.3......
360-  \=.2......;
361-
362-@Cards/back
363-  \-11111111
364-  \-10010010
365-  \-10010010
366-  \-11111111
367-  \-10010010
368-  \-10010010
369-  \-11111111
370-  \-10010010;
371-
372-  \-11111111
373-  \-1.......
374-  \-1.......
375-  \-1......1
376-  \-1.....11
377-  \-1....111
378-  \-1...1111
379-  \-1..11111;
380-
381-@Cards/mark
382-  \=........
383-  \=........
384-  \=..232323
385-  \=..3.....
386-  \=..2.....
387-  \=..3.....
388-  \=..2.....
389-  \=..3.....;
390-
391-@Vinit 0001
392-\mk3039 \m20~ascii.font \@Font
+0, -61
 1@@ -1,61 +0,0 @@
 2-\\ Convert EUC-TRON to TRON-32BE
 3-\\ (public domain)
 4-
 5-\\ (Note: This program does not (currently) attempt to convert ASCII to
 6-\\ JIS, therefore resulting in the "JIS-hybrid TRON-32", rather than the
 7-\\ "pure TRON-32".
 8-
 9-|0100
10-  [& BRK STH2 #12 DEI JMP2r ]@ INC2rk LITr 10 DEO2r EQUrk JSRr
11-
12-  JSR2rk
13-  DUP #7f GTH [?
14-    \\ single byte
15-    @single
16-    #0018 DEOk DEOk DEOk NIP DEO
17-    JMP2k
18-  ]@
19-  DUP #a0 LTH [?
20-    \\ double byte JIS X 0208 or first plane of JIS X 0213
21-    #7f AND
22-    @double
23-    #0018 DEO #2118 DEOk NIP DEO
24-    JSR2rk
25-    #7f AND #18 DEO
26-    JMP2k
27-  ]@
28-  DUP #8e NEQ [?
29-    \\ katakana
30-    POP ;single JMP2rk
31-  ]@
32-  DUP #8f NEQ [?
33-    \\ double byte JIS X 0212 or second plane of JIS X 0213
34-    DUP EOR JSR2rk
35-    DUP #ee LTH [? #5e SUB @ndouble NIP !double ]@
36-    DUP #af GTH ?ndouble
37-    ;jisx ADD2 LDA !double
38-  ]@
39-  \\ TRON character (now the code #88 to #8d is on stack, to save for later)
40-  #8000  ( zone plane_add volume )
41-  JSR2rk DUP #fe AND #90 NEQ [? ROT INC EOR #c0 MUL SWP JSR2rk ]@
42-  [@ DUP #80 NEQ ?q POP INC JSR2rk ]!
43-  @q  ( zone plane_add volume plane )
44-  SWP #18 DEO
45-  ADD #18 DEO
46-  JSR2rk JSR2rk
47-  ROT #0007 SFT2 ;zone ADD2 LDA2 JSR2
48-  SUB2 SWP #18 DEOk NIP DEO JMP2k
49-
50-\_@a1'- \@jisx
51-(  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  )
52-     87 a2 88 89 8a a6 a7 8b a9 aa ab 8c 8d 8e 8f
53-
54-\_@0110"- \@zone :z8 :z9 :za :zb :zc :zd
55-
56-@z8 #8080 JMP2r
57-@z9 #0080 JMP2r
58-@za #8000 JMP2r
59-@zb DUP2k EOR2 JMP2r
60-@zc DUP #c0 LTH [? SWP #8040 JMP2r ]@ #2080 JMP2r
61-@zd DUP #bf GTH [? #2000 JMP2r ]@ DUP #df GTH [? SWP #0040 ]@ #6060 JMP2r
62-
+0, -22
 1@@ -1,22 +0,0 @@
 2-|0100
 3-  LIT2r :buff DUP2rk
 4-  #17 DEI [? INC2r !ready ]@
 5-  [; #10 DEO2 BRK ]@
 6-  #0217 DEI NEQ ?ready
 7-  #12 DEI STH2rk STA INC2r BRK
 8-@ready
 9-  DUP2rk EOR2r SWP2r STA2r
10-  LITr a8 DEO2r
11-  ;bufsiz #aa DEO2
12-[@
13-  STH2rk #ac DEO2
14-  #a2 DEI2 ORAk [? #800f DEO ]@
15-  STH2rk ADD2 STH2rk
16-  [@
17-    LDAk #18 DEO
18-    INC2 NEQ2k
19-  ]?
20-  POP2 POP2
21-]!
22-@buff \_0@-1- \@bufsiz ". 00
23-
+0, -100
  1@@ -1,100 +0,0 @@
  2-\\ Simulate energy accumulation for GURPS Ritual Path Magic
  3-\\ (TODO: handle critical hits)
  4-
  5-\\ Zero page usage:
  6-\\   00: Skill
  7-\\   01: Energy required *
  8-\\   03: Critical miss threshold
  9-\\   04: Time *
 10-\\   06: Energy acquired *
 11-\\   08: Quirks
 12-
 13-|0100
 14-  DUP2k EOR2 STH2k
 15-  ;RandomExt #02 DEO2
 16-  #c1 DEI2 #c3 DEI2 EOR2 INC ;random/x STA2
 17-  #c5 DEI2 #c7 DEI2 ADD2 INC ;random/y STA2
 18-  reseed reseed POP2
 19-\\ Read skill number (cannot exceed 128)
 20-  #17 DEI [? show "Skill? 2000 ]@
 21-  [; #10 DEO2 BRK ]@
 22-  #0a12 DEI EQU [? #0a MUL #d012 DEI ADD ADD BRK ]@
 23-  OVR STZk NIP
 24-\\ Read energy number
 25-  #0117 DEI LTH [? show "Energy? 2000 ]@
 26-  [; #10 DEO2 BRK ]@
 27-  #0a12 DEI EQU [? #000a MUL2 STHrk #d012 DEI ADD ADD2 BRK ]@
 28-  #01 STZ2
 29-\\ Secondary stack now has 00 00
 30-  STH2rk
 31-
 32-@main
 33-\\ Calculate the number needed for a critical miss
 34-\\ If x is effective skill number, then: min(x+10,max(x+2,17),18)
 35-  LDZk #0a ADD #12 LTHk JMP SWP POP
 36-  LDZrk STHr INC INC #11 GTHk JMP SWP POP
 37-  LTHk JMP SWP POP #03 STZ
 38-\\ Three tries
 39-  try try try
 40-\\ Decrement and loop
 41-  LDZk #01 SUB OVR STZ !main
 42-
 43-@show
 44-  STH2r [@ LDAk #18 DEO INC2 LDAk ]? INC2 JMP2
 45-
 46-@RandomExt
 47-  03 f0
 48-  4105 259c e061 11f0 963f 0026 1874 5416
 49-  $1 00 10 =random
 50-
 51-@number
 52-  LITr 00
 53-  [@ STH2 LIT2r 000a DIV2rk STH2rk MUL2r SUB2r NIPr LITr 30 ADDr ORAk ]?
 54-  [@ LITr 18 DEOr STHrk ]?
 55-  POPr #0a18 DEO JMP2r
 56-
 57-\_ff'@+8>8<! ( alignment )
 58-@Dice
 59-  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 60-  03 04 05 06 07 08 04 05 06 07 08 09 05 06 07 08
 61-  09 0a 06 07 08 09 0a 0b 07 08 09 0a 0b 0c 08 09
 62-  0a 0b 0c 0d 04 05 06 07 08 09 05 06 07 08 09 0a
 63-  06 07 08 09 0a 0b 07 08 09 0a 0b 0c 08 09 0a 0b
 64-  0c 0d 09 0a 0b 0c 0d 0e 05 06 07 08 09 0a 06 07
 65-  08 09 0a 0b 07 08 09 0a 0b 0c 08 09 0a 0b 0c 0d
 66-  09 0a 0b 0c 0d 0e 0a 0b 0c 0d 0e 0f 06 07 08 09
 67-  0a 0b 07 08 09 0a 0b 0c 08 09 0a 0b 0c 0d 09 0a
 68-  0b 0c 0d 0e 0a 0b 0c 0d 0e 0f 0b 0c 0d 0e 0f 10
 69-  07 08 09 0a 0b 0c 08 09 0a 0b 0c 0d 09 0a 0b 0c
 70-  0d 0e 0a 0b 0c 0d 0e 0f 0b 0c 0d 0e 0f 10 0c 0d
 71-  0e 0f 10 11 08 09 0a 0b 0c 0d 09 0a 0b 0c 0d 0e
 72-  0a 0b 0c 0d 0e 0f 0b 0c 0d 0e 0f 10 0c 0d 0e 0f
 73-  10 11 0d 0e 0f 10 11 12 00 00 00 00 00 00 00 00
 74-  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 75-
 76-@reseed
 77-  [& random POP2 ]@
 78-@random ( -- number )
 79-  ,&x LDR2
 80-  DUP2 #50 SFT2 EOR2
 81-  DUP2 #03 SFT2 EOR2
 82-  ,&y LDR2 DUP2 ,&x STR2
 83-  DUP2 #01 SFT2 EOR2 EOR2
 84-  ,&y STR2k POP ADD JMP2r
 85-  &x 0001 &y 0001
 86-
 87-@try
 88-  #04 LDZ2k INC2 ROT STZ2
 89-  LIT \:Dice \_8>w random LDA
 90-  DUP [? POP !try ]@
 91-  DUP #03 LDZ LTH [? show "Botched. 0a00 !done ]@
 92-  OVR LDZ SWP SUB EQUk ADD
 93-  DUP #80 LTH [? POP EQUk #08 LDZk INC SWP STZ ]@
 94-  LITr 06 LDZ2rk STH2 DUP ADD2r STH2rk ROTr STZ2r
 95-  #01 LDZ2 LTH2 STH2r JCN2
 96-  show "OK 0a00
 97-@done
 98-  show "Energy: 2000 #06 LDZ2 number
 99-  show "Time: 2000 #04 LDZ2 number
100-  show "Quirks: 2000 #0008 LDZ number
101-  #800f DEO BRK
+0, -6
1@@ -1,6 +0,0 @@
2-|100
3-LIT2r ={ LITr 10 DEO2rk BRK }
4-#2f12 DEI LTH JMP BRK
5-#4f12 DEI AND DUP #06 SFT #c9 MUL ADD
6-GTHrk JMPrk BRK
7-SWP #40 SFT ORA #18 DEO BRK
+0, -7
1@@ -1,7 +0,0 @@
2-|100
3-;{ #10 DEO2k LIT2r =x EQU JSR BRK }
4-#2018 DEO #12 DEI DUP #04 SFT
5-@x #0f AND #30 ADD
6-DUP #39 GTH #27 MUL ADD
7-#18 DEO
8-OVR2r JMP2rk
+0, -50
 1@@ -1,50 +0,0 @@
 2-|100
 3-  DUP2k EOR2 LITr 20
 4-  ;input/y #10 DEO2
 5-@main
 6-  input
 7-  STHrk [?
 8-    \\ Primitive
 9-    DUP #04 SFT hex #0f AND hex
10-  ][
11-    \\ Type
12-    STHk #00 SWP
13-    #1f AND INCk #1f AND ?{
14-      POP STH DUPr
15-      input
16-        LITr 70 SFT2r
17-        #7f ANDk
18-        STH ADDr
19-        INC LTH JMP @brk BRK
20-      STH2r
21-    }
22-    \\ Number
23-    LITr 00
24-    [@
25-      DUP2 #000a DIV2k MUL2 SUB2
26-      #30 ADD STH
27-      #0a DIV2 ORAk
28-    ]?
29-    POP2
30-    [@ LITr 18 DEOr STHrk ]? POPr
31-    \\ Class
32-    \r #06 SFTk ADD LDR #18 DEO !{ "UACP } #20 AND \r
33-    LIT "[ STHrk ?{ POP LIT "< } #18 DEO
34-    \\ Length
35-    input
36-    #7f GTHk ?{ GTHk NIP SWP !addlength }
37-    EOR INC DUP2rk EOR2r STH
38-    input
39-    ROTr POPr STH SWPr INCr STHrk ?brk POPr STH2r
40-    \\ Done
41-    @addlength #00 LDZ2 ADD2
42-  ]@
43-  \\ check for end of any number of items
44-  @done DUP2 #00 LDZ2 NEQ2 ?main
45-    POP2
46-    LIT "] STHr ?{ POP LIT "> } #18 DEO
47-  !done
48-
49-@hex #30 ADD DUP #39 GTH #07 MUL ADD #18 DEO JMP2r
50-
51-@input LITr _/x STR2r BRK &y #00 LDZ2 INC2 #00 STZ2 #12 DEI LIT2 &x =main JMP2
+0, -30
 1@@ -1,30 +0,0 @@
 2-\\ Miscellaneous stuff, which may be useful to use some of it in other programs.
 3-\\ This file is public domain.
 4-
 5-\\ Print a 16-bit signed number as decimal (without leading zeros).
 6-@printn ( number* -- )
 7-  DUP2k #1f SFT2 EQUk [? LIT2 "- 18 DEO ]@ MUL2 SUB2
 8-  LITr 00
 9-  [@
10-    #000a DIV2k STH2k MUL2 SUB2
11-    STH2 SWP2r STH2r
12-    NIPr LITr 30 ADDr
13-  ORAk ]?
14-  POP2
15-  [@ STHr #18 DEO STHrk ]?
16-  POPr
17-  JMP2r
18-
19-\\ Add together two 32-bit numbers.
20-@add32 ( hi1* lo1* hi2* lo2* -- hi* lo* )
21-  ROT2 STH2k ADD2 STH2k ROT2 ROT2 GTH2r #00 STHr ADD2 ADD2 SWP2
22-  JMP2r
23-
24-\\ Absolute value of 16-bits.
25-@abs ( in* -- out* )
26-  DUP2k #1f SFT2 MUL2 SUB2
27-  JMP2r
28-
29-\\ Macro for alignment.
30-%ALIGN2 { \_@:1&+! }
31-
+0, -35
 1@@ -1,35 +0,0 @@
 2-\_28'0p \\ This line should be set to the offset of the data table
 3-
 4-|0100
 5-  #0000 DUP2k #28 DEO2 #2a DEO2
 6-  #802e DEO #c02e DEO
 7-  #0126 DEO
 8-  [; #10 DEO2 BRK ]@
 9-  #0a12 DEI EQU ?nextline
10-  #0101 LIT2 \_0gw 12 DEI ADD LDA
11-  [@ LDAk INC [? POP2 BRK ]@ LDAk #2e DEO INC ]!
12-
13-@nextline
14-  DUP2 #28 DEO2
15-  #2a DEI2k INC2 ROT DEO2
16-  BRK
17-
18-\_0120"0g+! fd $3a
19-%x { \_@1-:::!#g0100"+0g+p }
20-  "0 x 01 01 01 01 01 ff
21-  "1 x 00 01 "O x 01 "M x 01 "T x 01 ff
22-  "2 x 00 "J x 00 01 01 01 ff
23-  "3 x 00 00 "W x 00 01 01 ff
24-  "4 x 00 "V x 00 "U x 00 "A x 00 01 ff
25-  "5 x 00 00 "S x 00 00 00 ff
26-  "6 x 01 "H x 00 00 "I x 00 00 ff
27-  "7 x 01 "B x 01 00 00 00 ff
28-  "8 x 01 "Z x 01 "D x 01 00 00 ff
29-  "9 x 01 01 "G x 01 "N x 01 "E x 00 ff
30-  "C x 01 "R x 00 01 00 ff
31-  "F x 00 00 01 00 ff
32-  "L x 00 01 00 00 ff
33-  "P x 00 01 01 00 ff
34-  "Q x 01 "K x 01 00 01 ff
35-  "X x 01 00 00 01 ff
36-  "Y x 01 00 01 01 20 x ff
+0, -15
 1@@ -1,15 +0,0 @@
 2-\\ Munching squares
 3-\\ Public domain
 4-
 5-|0100
 6-  ;frame #20 DEO2
 7-  #0001 OVRk #22 DEO2 #24 DEO2
 8-  #0226 DEO
 9-  DUP STHk BRK
10-
11-@frame
12-  DUPk #2a DEO2
13-  [@ EORk #29 DEO STHrk #2e DEO INC DUP ], JCN
14-  LITr 01 EORr SWP STHrk ADD SWP
15-  STHrk ,frame JCN BRK
16-
+0, -55
 1@@ -1,55 +0,0 @@
 2-\\ Program to convert symbol file from the unofficial format to the
 3-\\ official format. This file is public domain.
 4-
 5-%_error { LIT2r :error JSR2r }
 6-
 7-|0100
 8-
 9-  \\ Read input file name
10-  LIT2r 0000 [; #10 DEO2 BRK ]@
11-  #12 DEI
12-  DUP #0a EQU [, JCN STHrk STZ INCr BRK ]@
13-  STZrk POPr DUPr
14-  STH2rk #a8 DEO
15-
16-  \\ Read output file name
17-  [; #10 DEO2 BRK ]@
18-  #12 DEI
19-  DUP #0a EQU [, JCN STHrk STZ INCr BRK ]@
20-  STZr #0000 #b8 DEO
21-
22-@loop
23-
24-  \\ Address
25-  #ac DEI
26-  #a3 DEI [, JCN #800f DEO ]@
27-  LIT "| EQU [, JCN _error "Expected 20 "| 0a ]@
28-  ,rhex JSR ,rhex JSR #00 STZ2
29-  #0002 #ba DEO2
30-  #0000 #be DEO2
31-
32-  \\ Name
33-  #ac DEI #20 EQU [, JCN _error "Expected 20 "space 0a ]@
34-  #ac DEI "@ EQU [, JCN _error "Expected 20 "@ 0a ]@
35-  LIT2r 00ff
36-  [@ #ac DEI DUP INCr STHrk STZ #0a EOR ], JCN
37-  STH2rk STZr INC #ba DEO2 #0000 #be DEO2
38-
39-  \\ Next record
40-  ;loop JMP2
41-
42-@rhex ( -- number )
43-  ,rhex1 JSR #40 SFT ,rhex1 JSR ORA JMP2r
44-
45-@error
46-  #0001 SUB2 [@ INC2 LDAk DUP #19 DEO #0a EOR ], JCN
47-  #810f DEO
48-
49-@rhex1 ( -- number )
50-  #ac DEI
51-  DUP #30 LTH ,&bad JCN
52-  DUP #39 GTH [, JCN #30 SUB JMP2r ]@
53-  DUP #61 LTH ,&bad JCN
54-  DUP #66 GTH [, JCN #57 SUB JMP2r ]@
55-  &bad _error "Expected 20 "hex 20 "digit 0a
56-
+0, -22
 1@@ -1,22 +0,0 @@
 2-|100
 3-  [& #5b NEQ ?brk LIT2r =normal ]@
 4-  DUP2k EOR2 [; #10 DEO2 @brk BRK ]@ #12 DEI JMP2rk
 5-@string
 6-  DUP #18 DEO
 7-  #22 OVR EQU JMP DUP2r POP2r
 8-  #5c NEQ ?brk brk
 9-@escape
10-  POP2r !send
11-@normal
12-  DUP #2c NEQ [? ROTk NIP ORA ?send POP #0a18 DEO BRK ]@
13-  LIT2r =string #22 OVR EQU JMP POP2r
14-  DUP #1f AND
15-  DUP #1b EQU ?open #1d EQU ?close
16-@send
17-  #18 DEO BRK
18-@open
19-  POP #18 DEO INC2 BRK
20-@close
21-  ROTk NIP ORA [? #0a18 DEO #800f DEO ]@
22-  #18 DEOk
23-  EQU INCk SUB2 BRK
+0, -10
 1@@ -1,10 +0,0 @@
 2-UHS
 3-This hint file requires 91a or 95a reader
 4-5
 5-5
 6-dvHwIJpGJ GwJr
 7-3
 8-dvHwIJpGJ GwJr
 9-5
10-` ,,p wGF| DtGJ Ktr{rI ty GwJ qwvHpJtAFr {tJD JDty DtGJ CtFr'
11-** END OF 88A FORMAT **
+0, -49
 1@@ -1,49 +0,0 @@
 2-|0100
 3-  \\ Identification
 4-  LITr fd input INCr STHrk cinput
 5-  #18 STH2k DEO ( f )
 6-  #02f8 ADD2 STHrk DEO STHrk DEO ( ar )
 7-  #0f SUB STHrk DEO DEOr ( bf )
 8-  #6518 DEO #6c18 DEO #6418 DEO
 9-  \\ Width/height
10-  #f8 input #18 DEO INC DUP cinput
11-  \\ Two ignored bytes
12-  input #ff00 DUPk
13-@main
14-  input STHk #16 SFT INC LDR2 JMP2 =op_index =op_diff =op_luma =op_rgb
15-@op_rgb
16-  STHrk #fe LTH [?
17-    \\ RGB(A)
18-    POP POP2
19-    STHr INC
20-    input input STH2 input
21-    SWP [? input SWP ]@
22-    STHr STHr
23-    !send
24-  ]@
25-  \\ Run 1-62
26-  LITr 3f EORr
27-  LIT LIT2 ;send/op STA
28-  !send
29-@op_diff
30-  ( blue ) SWP2 STHrk #03 AND #02 SUB ADD ( graB )
31-  ( green ) SWP2 SWP STHrk #02 SFT #03 AND #02 SUB ADD ( aBrG )
32-  ( red ) SWP STHr #04 SFT #06 SUB ADD ( aBGR )
33-  !send
34-@op_luma
35-  LITr 60 ADDr
36-  ( green ) SWP STHrk ADD ( abrG )
37-  ( red ) SWP input STH STH2rk #04 SFT #08 SUB ADD ADD ( abGR )
38-  ( blue ) LITr 0f ANDr ADDr SWP2 STHr #08 SUB ADD SWP2 ( aBGR )
39-  !send
40-@op_index
41-  STHr #04 MUL LDZ2k ROT INC INC LDZ2 SWP2
42-@send
43-  OVR2 OVR2 OVR2 OVR2
44-  #67 MUL ADD #93 MUL ADD #75 MUL ADD #2c MUL
45-  STZ2k NIP NIP INC INC STZ2
46-  &loop OVR2 OVR2 sendpart sendpart
47-  &op !main POP2 INCr STHrk ?/loop LIT2 40 _/op STR BRK
48-
49-@cinput [? @input LITr _/x STR2r [; #10 DEO2 BRK ]@ #12 DEI LIT2 &x $2 JMP2 ]@ POP2r BRK
50-@sendpart [& ]@ #18 DEOk DEO JMP2r
+0, -387
  1@@ -1,387 +0,0 @@
  2-\\ "Robots" game (similar to the BSD games "robots" game)
  3-\\ (This file is public domain.)
  4-
  5-|0000
  6-  @PlayerX $1
  7-  @PlayerY $1
  8-  @NumRobots $1
  9-  @Level $1
 10-  @Score $2
 11-  @HiScore $2
 12-
 13-\\ Playfield size (including the border) is 0x28 by 0x22
 14-|d8de @Playfield \_@1-! @Playfield- $102 @Playfield+ $1 @Playfield++
 15-\:Playfield \_8> \@PlayfieldH
 16-
 17-|0100
 18-  \\ Colours
 19-  #1ef8 #08 DEO2
 20-  #1e7d #0a DEO2
 21-  #1e58 #0c DEO2
 22-  \\ Size
 23-  #0140 #22 DEO2
 24-  #0120 #24 DEO2
 25-  \\ Sound
 26-  #0000 #38 DEO2
 27-  #0004 #3a DEO2
 28-  ;Wave #3c DEO2
 29-  \\ Others
 30-  #0126 DEO
 31-  ;inputVec #80 DEO2
 32-  \\ Random number seed
 33-  #c4 DEI #c1 DEI ADD #c5 DEI INC2 ;prng64/x STA2
 34-  #c9 DEI #c6 DEI INC2 ;prng64/y STA2
 35-
 36-@title
 37-  cls
 38-  sound 33fc 35fc 37f8 3afc 00f9 3afc 0000
 39-  #1008 locate
 40-  #8202 showc
 41-  #01 showi 20 "ROBOTS 20 00
 42-  #8202 showc
 43-  #0b10 locate
 44-  #01 showi "Push 20 "space 20 "to 20 "begin 00
 45-  #0120 locate
 46-  #01 showi "Last 20 "score: 20 00
 47-  .Score LDZ2 #03 shown
 48-  #0121 locate
 49-  #01 showi "High 20 "score: 20 00
 50-  .HiScore LDZ2 #03 shown
 51-  [@ input #20 NEQ ]?
 52-  #00 DUPk .Score STZ2 .Level STZ
 53-
 54-@beginlevel
 55-  sound 2efc 33fc 35fc 37fc 3afc 3ffc 0000
 56-  \\ Add walls and floors
 57-  ;Playfield [@
 58-    STH2k ;Playfield+ LTH2
 59-    STH2rk #fefe GTH2
 60-    STHrk INC .Playfield++ LTH
 61-    ORA ORA DUP ADD STH2rk STA STH2r
 62-  INC2 DUP [? POP .Playfield ]@ OVR ]? POP2
 63-  ;NumRobots STZ
 64-  \\ Add robots
 65-  LIT2 f8 -Level LDZ SUB [@
 66-    #01
 67-    #253f random #1f3f random ;Playfield+ ADD2
 68-    LDAk [? .NumRobots LDZk INC SWP STZ ]@
 69-    STA
 70-  INC DUP ]? POP
 71-  \\ Add player
 72-  #253f random #1f3f random ;Playfield+ ADD2 STH2k .PlayerX STZ2
 73-  \\ If there is a robot where the player is, destroy the robot
 74-  .NumRobots LDZ LDArk STHr SUB .NumRobots STZ
 75-  #00 STH2r STA
 76-
 77-@game
 78-  redraw input #7f AND #0007 SFT2 ;KeyMap ADD2 LDA2 ORAk ROT ROT JCN2 !game
 79-
 80-@KeyMap $0100
 81-%Key { \:KeyMap \_@1-:!#@g:++@,P }
 82-
 83-"t Key
 84-  \\ Teleport player to a vacant cell
 85-  [@
 86-    #253f random #1f3f random ;Playfield+ ADD2 STH2k .PlayerX STZ2
 87-    STH2r LDA
 88-  ]?
 89-  step
 90-  sound 40fe 41fe 43fe 44fe 46fe 47fe 49fe 4afe 0000
 91-  !game
 92-
 93-"w Key
 94-  \\ Wait until all robots are broken; add extra points
 95-  .Score LDZ2 ;NumRobots LDZ ADD2 .Score STZ2
 96-  [@ step ]!
 97-
 98-"b Key "1 Key
 99-  #ff01 !move1
100-"j Key "2 Key
101-  #0001 !move1
102-"n Key "3 Key
103-  #0101 !move1
104-"h Key "4 Key
105-  #ff00 !move1
106-20 Key ". Key "5 Key
107-  #0000 @move1 move [? sound 37f8 30f8 0000 ]@ !game
108-"l Key "6 Key
109-  #0100 !move1
110-"y Key "7 Key
111-  #feff !move1
112-"k Key "8 Key
113-  #ffff !move1
114-"u Key "9 Key
115-  #00ff !move1
116-
117-"B Key
118-  #ff01 !moveM
119-"J Key
120-  #0001 !moveM
121-"N Key
122-  #0101 !moveM
123-"H Key
124-  #ff00 !moveM
125-"> Key
126-  #0000 @moveM [@ DUP2 move ]? POP2 !game
127-"L Key
128-  #0100 !moveM
129-"Y Key
130-  #feff !moveM
131-"K Key
132-  #ffff !moveM
133-"U Key
134-  #00ff !moveM
135-
136-"x Key
137-  .PlayerX LDZ2 ;Playfield- SUB2 locate #820d showc
138-  input POP !game
139-
140-"? Key
141-  cls
142-  #0101 locate #03 showi "yku 00
143-  #0102 locate #03 showi "h.l 00 #01 showi 20 "Walk 00
144-  #0103 locate #03 showi "bjn 00
145-  #1101 locate #03 showi "YKU 00
146-  #1102 locate #03 showi "H>L 00 #01 showi 20 "Run 00
147-  #1103 locate #03 showi "BJN 00
148-  #0105 locate LIT2 "t 03 showc #01 showi 20 "Teleport 20 "at 20 "random 00
149-  #0107 locate LIT2 "w 03 showc #01 showi 20 "Wait 20 "for 20 "next 20 "level 00
150-  #0109 locate LIT2 "x 03 showc #01 showi 20 "Reveal 20 "player 00
151-  input POP !game
152-
153-@move ( dir* -- ok )
154-  \\ New coordinates of player
155-  \\ (don't worry about carry, since the walls will take care of that)
156-  .PlayerX LDZ2 ADD2
157-  LDAk ?&bad \\ Cannot move into an occupied cell
158-  \\ Cannot move if cell in direction is robot
159-  ( south ) INC2k LDA #01 EQU ?&bad
160-  ( southwest ) DUP2 #ff01 ADD2 LDA #01 EQU ?&bad
161-  ( southeast ) OVR INC OVR INC LDA #01 EQU ?&bad
162-  ( north ) DUP2 #01 SUB LDA #01 EQU ?&bad
163-  ( northwest,west ) DUP2 #0101 SUB2 LDA2 ORA #01 AND ?&bad
164-  ( northeast,east ) DUP2 #00ff ADD2 LDA2 ORA #01 AND ?&bad
165-  \\ It is safe, so move the player
166-  .PlayerX STZ2
167-  #01 !step
168-  &bad POP2 #00 JMP2r
169-
170-@step ( -- )
171-  \\ Move robots by quadrants
172-  ( north ) #ffff lines
173-  ( south ) #0001 lines
174-  ( east ) #0100 lines
175-  ( west ) #ff00 lines
176-  ( northwest ) #ff00 #ffff quads
177-  ( northeast ) #ffff #0100 quads
178-  ( southeast ) #0100 #0001 quads
179-  ( southwest ) #0001 #ff00 quads
180-  \\ Check if game lost
181-  .PlayerX LDZ2 LDA #00 EQU [?
182-    redraw
183-    sound 3ffa 3afa 36fa 33fa 0000
184-    #0000 locate
185-    #02 showi 20 "GAME 20 "OVER 20 00
186-    #1c23 locate
187-    #01 showi "q=quit 00
188-    .PlayerX LDZ2 ;Playfield- SUB2 locate #8402 showc
189-    [@ input LIT "q EOR ]?
190-    POP2r
191-    .Score LDZ2 .HiScore LDZ2 LTH2 ?title
192-    .Score LDZ2 .HiScore STZ2 !title
193-  ]@
194-  \\ Check if game is completed
195-  .NumRobots LDZ [?
196-    .Level LDZk DUP #f7 LTH ADD SWP STZ
197-    POP2r !beginlevel
198-  ]@
199-  JMP2r
200-
201-@lines ( dir* -- )
202-  ,&dir STR2
203-  LITr -PlayerX LDZ2r
204-  &loop
205-    STH2rk LIT2 &dir $2 ADD2 LDAk
206-    DUP #02 EQU ?&stop
207-    #01 NEQ [?
208-      LITr 00 STH2k STAr
209-      STH2rk LDA [? #01 !&put ]@
210-      STH2rk LDA #01 NEQ [? addscore ]@
211-      addscore
212-      #04 &put STH2rk STA
213-    ]@
214-    POP2r STH2 !&loop
215-  &stop POP POP2 POP2r JMP2r
216-
217-@quads ( dir1* dir2* -- )
218-  ADD2k ,lines/dir STR2
219-  .PlayerX LDZ2 [& .PlayerX LDZ2 OVR2 ADD2 ]@
220-  STH2 ,&dir STR2
221-  &loop
222-    STH2rk LDA #02 EQU ?&stop
223-    DUP2r LIT2r &dir $2 ADD2r
224-    LIT2r :&loop ROT2r !lines/loop
225-  &stop POP2r JMP2r
226-
227-@addscore ( -- )
228-  .NumRobots LDZk #01 SUB SWP STZ
229-  .Score LDZ2k #000a ADD2 ROT STZ2
230-  sound 31fe 0000
231-  JMP2r
232-
233-@redraw ( -- )
234-  cls
235-  .Playfield [@
236-    #00 OVR .Playfield- SUB locate
237-    .PlayfieldH [@
238-      SWPk LDA #0007 SFT2 ;Tiles ADD2 LDA2 showc
239-    INC DUP ]? POP
240-  INC DUP ]? POP
241-  .PlayerX LDZ2 ;Playfield- SUB2 locate #8303 showc
242-  \\ fallthrough
243-@status ( -- )
244-  #0000 locate
245-  #01 showi "Level: 00
246-  ;Level LDZ #02 shown
247-  #1c00 locate
248-  #01 showi "Remain: 00
249-  ;NumRobots LDZ #02 shown
250-  #0023 locate
251-  #01 showi "Score: 00
252-  .Score LDZ2 #03 shown
253-  #1c23 locate
254-  #01 showi "?=help 00
255-  JMP2r
256-
257-@inputVec
258-  #c6 DEI ;prng64/x LDA SUB DUP #00 EQU ADD ;prng64/x STA
259-  #83 DEI DUP [? POP @input BRK ]@ JMP2r
260-
261-@cls ( -- )
262-  #0000 DUP2 #28 DEO2 #2a DEO2
263-  #802e DEO #c02e DEO
264-  JMP2r
265-
266-@locate ( x y -- )
267-  #0005 SFT2 #2a DEO2
268-  #0005 SFT2 #28 DEO2
269-  JMP2r
270-
271-@showc ( char color -- )
272-  SWP #0005 SFT2 ;Font ADD2 #2c DEO2
273-  #2f DEO
274-  JMP2r
275-
276-@showi ( color -- )
277-  ,&color STR
278-  [@
279-    LDArk STHr INC2r DUP [? POP JMP2r ]@
280-    #0005 SFT2 ;Font ADD2 #2c DEO2
281-    LIT2 &color 002f DEO
282-  ]!
283-
284-@shown ( number* color -- )
285-  ,showi/color STR
286-  LITr 00
287-  [@
288-    #000a DIV2k STH2k MUL2 SUB2
289-    STH2 SWP2r STH2r
290-    NIPr LITr 30 ADDr
291-  ORAk ]?
292-  POP2
293-  [@ STHr ,showi/color LDR showc STHrk ]?
294-  POPr
295-  JMP2r
296-
297-@sound ( -- )
298-  STH2rk ,&addr STR2
299-  #00 ,&time STR
300-  [@ LDA2rk STH2r ORA INC2r INC2r ]?
301-  [; #20 DEO2 JMP2r ]@
302-  LIT &time $1
303-  DUP [?
304-    POP LIT2 &addr $2 LDA2k
305-    ORAk [? NIP2 DUP2 #3e DEO2 #20 DEO2 BRK ]@
306-    STH
307-    DUP #00 EQU #01 SUB SWP
308-    #3e DEO2
309-    INC2 INC2 ,&addr STR2
310-    STHr
311-  ]@ INC ,&time STR BRK
312-
313-@prng64 ( -- number* )
314-  ( returns the next number in a (2^32-1)-long sequence )
315-  ( http://b2d-f9r.blogspot.com/2010/08/16-bit-xorshift-rng-now-with-more.html )
316-  LIT2 &x 0001
317-  DUP2 #50 SFT2 EOR2
318-  DUP2 #03 SFT2 EOR2
319-  LIT2 &y 0001 DUP2 ,&x STR2
320-  DUP2 #01 SFT2 EOR2 EOR2
321-  ,&y STR2k POP
322-  JMP2r
323-
324-@random ( limit mask -- number )
325-  ,&m STR STHk
326-  [@
327-    POP
328-    prng64 ADD LIT &m 00 AND
329-    DUP STHrk GTH
330-  ]?
331-  POPr JMP2r
332-
333-@Tiles
334-  8003 ( empty )
335-  8102 ( robot )
336-  7f01 ( wall )
337-  3f01 ( unused )
338-  8401 ( broken )
339-
340-@Wave 00 7f ff 80
341-
342-\_@20'8*- \@Font \~ascii.font
343-
344-  \-........ ( 80 )
345-  \-........
346-  \-........
347-  \-...11...
348-  \-...11...
349-  \-........
350-  \-........
351-  \-........;
352-
353-  \-........ ( 81 )
354-  \-.1....1.
355-  \-..1..1..
356-  \-...11...
357-  \-...11...
358-  \-..1..1..
359-  \-.1....1.
360-  \-........;
361-
362-  \-........ ( 82 )
363-  \-...11...
364-  \-..1111..
365-  \-.111111.
366-  \-.111111.
367-  \-..1111..
368-  \-...11...
369-  \-........;
370-
371-  \-........ ( 83 )
372-  \-...11...
373-  \-..1..1..
374-  \-.1....1.
375-  \-.1....1.
376-  \-..1..1..
377-  \-...11...
378-  \-........;
379-
380-  \-....1... ( 84 )
381-  \-.1..1.1.
382-  \-..1.11..
383-  \-11111...
384-  \-...11111
385-  \-..11.1..
386-  \-.1.1..1.
387-  \-...1....;
388-
+0, -4
1@@ -1,4 +0,0 @@
2-\\ (Public domain)
3-|0100 [; #10 DEO2 BRK ]@ #e685 #2012 DEI STHk ORA ADD GTH
4-[? STHrk #1f AND #0d STHk GTH [? ADDr LITr 00 ]@ SUBr ]@
5-LITr 18 DEOr #0417 DEI NEQ [? #800f DEO ]@ BRK
+0, -197
  1@@ -1,197 +0,0 @@
  2-\\ Show text using fonts with SCOBF format
  3-\\ (public domain)
  4-
  5-\\ This program is a rather simple one with several limitations:
  6-\\ - Only one plane is possible.
  7-\\ - The maximum raster size is 16x127.
  8-\\ - It does not properly deal with unrecognized characters.
  9-\\ - Possibly some others.
 10-
 11-\\ (If you really want to use this font format with uxn, then you might
 12-\\ instead want to write a conversion program, and use that instead.)
 13-
 14-|00
 15-  @head
 16-    &magic $8
 17-    &xsize $1
 18-    &ysize $1
 19-    &xadj $1
 20-    &yadj $1
 21-    &defl $1
 22-    &defh $1
 23-    &asc $1
 24-    &desc $1
 25-    &numl $1
 26-    &numh $1
 27-    &plane $1
 28-    &volume $1
 29-  @chead
 30-    &adv $1
 31-    &codel $1
 32-    &codeh $1
 33-    &xsize $1
 34-    &ysize $1
 35-    &xadj $1
 36-    &yadj $1
 37-  @indata
 38-    &adv $1
 39-    &offset $4
 40-    &xadj $1
 41-    &yadj $1
 42-    &size $1 \\ high bit set for 16 pixels width, low 7-bits is height
 43-
 44-|0100
 45-  #17 DEI [? error "usage: 20 "showscobf.tal 20 "<font-filename> 0a ]@
 46-  \\ Colours
 47-  #9000 #08 DEO2k INC INC DEO2k INC INC DEO2
 48-  \\ Screen
 49-  #0140 #22 DEO2
 50-  #00c8 #24 DEO2
 51-  \\ Read file name
 52-  LIT2r :memory DUP2r
 53-  [; #10 DEO2 BRK ]@
 54-  #0217 DEI LTH ?load
 55-  #12 DEI STH2rk STA INC2r BRK
 56-
 57-@load
 58-  #00 STH2r STA LITr a8 DEO2r
 59-  #0020 #aa DEO2
 60-  ;head #ac DEO2
 61-  \\ Check header
 62-  .head/magic
 63-  LDZ2k #ff01 NEQ2 ?badform
 64-  INC INC LDZ2k #7363 NEQ2 ?badform
 65-  INC INC LDZ2k #6f62 NEQ2 ?badform
 66-  INC INC LDZ2 #6600 NEQ2 ?badform
 67-  \\ Copy parts of header
 68-  .head/xsize LDZ2 .chead/xsize STZ2k POP2 #80 ADD .chead/adv STZ
 69-  .head/xadj LDZ2 .chead/xadj STZ2
 70-@bloc
 71-  \\ Read all blocks
 72-  #01ab DEO
 73-  [; #ac DEO2 #a3 DEI [? error "Unexpected 20 "end 20 "of 20 "file 0a ]@ LIT ]@ $1
 74-  DUP #f0 ( end of file ) EQU ?ready
 75-  DUP #80 ( non-mandatory extension ) LTH [?
 76-    #0f AND #ab DEO ;memory #ac DEO2 !bloc
 77-  ]@
 78-  \\ Character glyph definition
 79-  DUP #01 GTH ?badform
 80-  [? ;chead #07 ][ ;chead/codel #02 ]@ #ab DEO #ac DEO2
 81-  \\ Set address
 82-  .chead/codel LDZ2
 83-  DUP #05 SFT INC ,extcopy1/p STR
 84-  SWP #30 SFT2 ,extcopy1/a STR2
 85-  \\ Set offset and heading data
 86-  LIT2 a3 -indata/adv STZ ;indata #02 DEO2
 87-  .chead/adv LDZ .indata/adv STZ
 88-  ;chead/ysize LDZ .chead/yadj LDZ ADD SUB .indata/yadj STZ
 89-  .chead/xadj LDZ .indata/xadj STZ
 90-  \\ Size
 91-  LIT2 ff -chead/xsize LDZ ADD DUP #0f GTH ?badform #73 SFT
 92-  .chead/ysize LDZ DUP #80 AND ?badform
 93-  ORA .indata/size STZ
 94-  \\ Copy to expanded memory
 95-  ;extcopy1 #02 DEO2
 96-  \\ Skip raster data
 97-  .indata/size LDZ DUP #7f AND SWP #07 SFT INC MUL #ab DEO
 98-  ;memory #ac DEO2
 99-  \\ Next item
100-  !bloc
101-
102-@extcopy1
103-  01 0008 0000 :indata 00 &p 01 &a 0000
104-
105-@extcopy2
106-  01 0008 00 &p 00 &a 0000 0000 :indata
107-
108-@ready
109-  #0002 #28 DEO2 ;head/asc LDZ INC2 #2a DEO2 \\ X/Y coordinates
110-@next
111-  getc
112-  DUP #0a NEQ [?
113-    #0002 #28 DEO2
114-    #2a DEI2 ;head/asc LDZ ADD2 ;head/desc LDZ ADD2 #2a DEO2
115-    ?next
116-  ]@
117-  DUP #20 NEQ [?
118-    \\ This currently assumes the space width is always eight pixels
119-    #28 DEI2 #0008 ADD2 #28 DEO2
120-    ?next
121-  ]@
122-  DUP #fe NEQ [?
123-    [@ getc #fe NEQ ]? ?next
124-  ]@
125-  \\ Normal character
126-  getc
127-  \\ Find index entry for specified character
128-  OVR #05 SFT INC ,extcopy2/p STR
129-  #30 SFT2 ,extcopy2/a STR2
130-  ;extcopy2 #02 DEO2
131-  \\ Advancement
132-  ;indata/adv LDZ #0080 SUB2 #28 DEI2 ADD2 ( newx* : saved for later )
133-  \\ Adjust Y coordinate
134-  ;indata/yadj LDZ #0080 SUB2 #2a DEI2 STH2k ADD2 #2a DEO2
135-  \\ Read raster data from file
136-  LIT2 a0 -indata/adv STZ
137-  ;indata/adv #02 DEO2
138-  ;indata/size LDZ STHk #07 SFT INC STHrk #7f AND MUL #aa DEO2
139-  ;memory DUP2 #2c DEO2 #ac DEO2
140-  \\ Set graphics state
141-  STHrk #47 SFT #06 ADD #26 DEO
142-  \\ Convert glyph format if necessary
143-  STHrk #80 LTH [?
144-    ;memory
145-    LITr 81 OVRr SUBr LITr 03 SFTr LITr f8 ORAr [@
146-      DUP2 rearrange #0010 ADD2
147-    INCr STHrk ]? POPr POP2
148-  ]@
149-  \\ Draw character glyph
150-  #81 STHr SUB #03 SFT #f8 ORA
151-  [@ #012f DEO INC DUP ]? POP
152-  \\ Reset Y coordinate
153-  LITr 2a DEO2r
154-  \\ Update X coordinate
155-  #28 DEO2
156-  \\ Next character
157-  !next
158-
159-@rearrange
160-  \\ Read fourteen bytes
161-  INC2 STH2k DUP2r LDA
162-  INC2r STH2rk LDA2
163-  INC2r INC2r STH2rk LDA2
164-  INC2r INC2r STH2rk LDA2
165-  INC2r INC2r STH2rk LDA2
166-  INC2r INC2r STH2rk LDA2
167-  INC2r INC2r STH2rk LDA2
168-  INC2r INC2r STH2rk LDA
169-  ( 1 2 3 4 5 6 7 8 9 a b c d e -- 2 4 6 8 a c e 1 3 5 7 9 b d )
170-  \\ Write fourteen bytes
171-  SWP STH2r STA ( 1 2 3 4 5 6 7 8 9 a b c e )
172-  STH2rk #0006 ADD2 STA ( 1 2 3 4 5 6 7 8 9 a b c )
173-  STH2rk #0005 ADD2 STA ( 1 2 3 4 5 6 7 8 9 a b )
174-  STH2rk #000c ADD2 STA ( 1 2 3 4 5 6 7 8 9 a )
175-  STH2rk #0004 ADD2 STA ( 1 2 3 4 5 6 7 8 9 )
176-  STH2rk #000b ADD2 STA ( 1 2 3 4 5 6 7 8 )
177-  STH2rk #0003 ADD2 STA ( 1 2 3 4 5 6 7 )
178-  STH2rk #000a ADD2 STA ( 1 2 3 4 5 6 )
179-  STH2rk INC2 INC2 STA ( 1 2 3 4 5 )
180-  STH2rk #0009 ADD2 STA ( 1 2 3 4 )
181-  STH2rk INC2 STA ( 1 2 3 )
182-  STH2rk #0008 ADD2 STA ( 1 2 )
183-  STH2rk STA ( 1 )
184-  STH2r #0007 ADD2 STA
185-  \\ Done
186-  JMP2r
187-
188-@badform
189-  error "Improper 20 "file 20 "format 0a
190-
191-@error
192-  [@ LDArk STHrk #19 DEO STHr #0a EOR INC2r ]? #010f DEO
193-
194-@getc
195-  [; #10 DEO2 BRK ]@ #12 DEI JMP2r
196-
197-@memory
198-
+0, -9
 1@@ -1,9 +0,0 @@
 2-|0100
 3-  #c0c0 #08 DEO2k INC INC DEO2k INC INC DEO2
 4-  #0126 DEO
 5-  #0000 STH2k #28 DEO2k INC INC DEO2
 6-  [; #10 DEO2 BRK ]@
 7-  #12 DEI DUP #0a NEQ [? POP STH2rk #28 DEO2 #2a DEI2k #0008 ADD2 ROT DEO2 BRK ]@
 8-  #0005 SFT2 ;Font ADD2 #2c DEO2 #012f DEO BRK
 9-
10-\_@20'8*- \@Font \~ascii.font
+0, -1
1@@ -1 +0,0 @@
2-|100 [; #10 DEO2 BRK ]@ #8012 DEI EOR #18 DEO BRK
+0, -24
 1@@ -1,24 +0,0 @@
 2-\\ Thue-Morse
 3-\\ (public domain)
 4-
 5-|0100
 6-  LITr 30 LIT2r :hi [;
 7-    [@
 8-      LDAk STH2rk STA
 9-      INC2 INC2r
10-      STH2rk ORA
11-    ]?
12-    STHrk INCk STArk !hi
13-  ]@
14-  \_@
15-  [@
16-    [@
17-      LDArk LITr 18 DEOr
18-      LDArk LITr 01 EORr STH2k STAr
19-      INC2 INC2r
20-      STH2rk SUB2k NEQ2
21-    ]?
22-    POP2r #0a18 DEO
23-  ]&
24-  \_@,-0,- \@hi
25-
+0, -629
  1@@ -1,629 +0,0 @@
  2-\\ Timer program
  3-
  4-|0000
  5-  @Alarm &h $1 &m $1 ( hours, minutes )
  6-  @CountDir $1 ( 0=down, 1=up )
  7-  @TimerOn $1 ( 0=stop, 1=go )
  8-  @Timer &h $1 &m $1 &s $1 &f $1 \:Timer \_:+ \@2xTimer
  9-  @AlarmOn $1 ( 1=off, 0=on )
 10-  @ChimeSet $1 ( 0=off, 1=60min, 2=30min, 3=15min, 4=Westminster )
 11-  @Clock24 $1 ( 1 for 24-hour clock, 0 for 12-hour clock )
 12-  @Mode $1 ( 0=clock, 2=alarm-set, 4=timer, 6=sound-set )
 13-  @Cursor $1 ( must come next after Mode )
 14-  @Mark $1 ( timer mark address; must come next after Cursor )
 15-  @Volume $1 ( volume times seventeen; the next one must be SoundState )
 16-  @SoundState $1 ( 0=none, else MIDI note number; even=once, odd=repeating )
 17-  @SoundFrame $1 ( frame number; comes next after SoundState )
 18-  @LastSec $1 ( last observed value for seconds )
 19-  @Frame $1
 20-  @MissFrame $1 ( keep track of missed frames for timer mode )
 21-  @MouseX &hi $1 &lo $1
 22-  @MouseY &hi $1 &lo $1
 23-  @MouseState $1
 24-  @MusicAddr $2
 25-  @MusicState $1
 26-  @HourBells $1
 27-@saveSize
 28-
 29-|0100
 30-  \\ Load save data
 31-  LIT2 cc -Volume STZ filing ;Mode STZ
 32-  \\ Set up
 33-  #8090 #08 DEO2k INC INC DEO2k INC INC DEO2
 34-  #00a0 #24 DEO2
 35-  #00c0 #22 DEO2
 36-  #0126 DEOk
 37-  ;ScreenVec #20 DEO2
 38-  ;KeyVec #80 DEO2
 39-  ;MouseVec #90 DEO2
 40-  #0000 #38 DEO2
 41-  #0002 #3a DEO2
 42-  ;SqWave #3c DEO2
 43-  \\ JMP2rk outside of a subroutine call will be like "redraw-screen BRK"
 44-  EQU JSR redraw-screen BRK
 45-
 46-@kSave DUP2r
 47-@filing ( -- )
 48-  [& "timer.save 00 ]@ LITr a8 DEO2r
 49-  ;saveSize DUP2k #aa DEO2
 50-  EOR2 #ac DEO2 #aefa STR
 51-  JMP2r
 52-
 53-@locate ( x y -- )
 54-  #0005 SFT2 #2a DEO2
 55-  #0005 SFT2 #28 DEO2
 56-  JMP2r
 57-
 58-@drawnum ( number -- )
 59-  LDArk STHr INC2r
 60-  SWP #0a DIVk STHk MUL SUB OVR STHr [& ]@
 61-  ( row digit )
 62-  DUP ADD ADD #00 SWP ;Digits ADD2 LDA2 printc
 63-  \\ fall through
 64-@printc ( ch -- )
 65-  #0005 SFT2 ;Font ADD2 #2c DEO2
 66-  #012f DEO
 67-  JMP2r
 68-
 69-@printat ( x y -- )
 70-  locate !&0 [@ printc &0 LDArk STHr INC2r DUP ]? POP JMP2r
 71-
 72-@redraw-clock0 ( -- )
 73-  .AlarmOn LDZ [? #0102 printat 8400 ]@
 74-  #0110 printat 8920 "ALARM 2020 2020 8a20 "12/24 00
 75-@redraw-clock ( -- )
 76-  \\ Day of week
 77-  #0101 locate
 78-  #00c7 DEI #03 MUL ;Weekday ADD2
 79-  LDAk printc INC2 LDAk printc INC2 LDA printc
 80-  #2020 printc printc
 81-  \\ Time of day
 82-  #c4 DEI2 SWP ( minutes hours )
 83-  .Clock24 LDZ [?
 84-    #0c LTHk
 85-    DUP #f1 MUL #50 ADD
 86-    #1502 locate printc #4d printc #0601 locate
 87-    #01 EOR MUL SUB
 88-    DUP [? POP #0c ]@
 89-  ]@
 90-  DUP drawnum 00 #83 printc
 91-  OVR drawnum 00 #83 printc
 92-  .LastSec LDZ STHk drawnum 00
 93-  #0602 locate
 94-  DUP drawnum 14 #83 printc
 95-  OVR drawnum 14 #83 printc
 96-  STHrk drawnum 14
 97-  #0603 locate
 98-  drawnum 28 #20 printc
 99-  drawnum 28 #20 printc
100-  STHr drawnum 28
101-  JMP2r
102-
103-@redraw-alarm0 ( -- )
104-  #0110 printat 8920 "ON 20 2020 2020 2020 8a20 "OFF 00
105-  cursor-adjust
106-  #0101 printat "SET 00
107-  #0102 printat 8400
108-  draw-cursor
109-@redraw-alarm ( -- )
110-  .Alarm LDZ2 SWP ( minutes hours )
111-  .Clock24 LDZ [?
112-    #0c LTHk
113-    DUP #f1 MUL #50 ADD
114-    #1502 locate printc #4d printc
115-    #01 EOR MUL SUB
116-    DUP [? POP #0c ]@
117-  ]@
118-  #0601 locate
119-  DUP drawnum 00 #83 printc
120-  OVR drawnum 00
121-  #0602 locate
122-  DUP drawnum 14 #83 printc
123-  OVR drawnum 14
124-  #0603 locate
125-  drawnum 28 #20 printc
126-  drawnum 28
127-  JMP2r
128-
129-@redraw-timer0 ( -- )
130-  #0110 .TimerOn LDZ [?
131-    printat 8920 "GO 20 2020 2020 2020 8a20 "RESET 00
132-    draw-cursor
133-  ][
134-    #0202 locate
135-    LIT2 2d -CountDir LDZ DUP ADD SUB printc
136-    printat 8920 "MARK 20 2020 2020 8a20 "STOP 00
137-  ]@
138-  cursor-adjust
139-  LITr 06 .Mark LDZ [@
140-    DUP [? POP POPr !redraw-timer ]@
141-    #06 STHrk locate INCr
142-    draw-marked-time
143-  ]!
144-@redraw-timer ( -- )
145-  #8300 INC2k #2002
146-  LIT2r [: DUP2r ]@
147-  DUP #14 MUL ,&x STR
148-  INC ,&y STR ,&z STR
149-  LIT2 06 &y $1 locate
150-  .Timer/h
151-  &loop
152-    DUP LDZ drawnum &x $1
153-    INC DUP .Timer/f EQU [? LIT &z $1 printc !&loop ]@
154-  POP JMP2r
155-
156-@redraw-sound0 ( -- )
157-  #060c printat 8520 "CHIME 20 2086 00
158-  #060e printat 8820 "VOLUME 2087 00
159-  #0110 printat 8920 "TEST 2020 2020 20 8a20 "SAVE 00
160-@redraw-sound ( -- )
161-  #0204 locate
162-  .Volume LDZ [@ #7f printc #11 SUB DUP ]? POP
163-  LIT2 f0 -Volume LDZ ORA [@ LIT "_ printc INC DUP ]? POP
164-  #1104 printat 2000
165-  #0202 locate
166-  LIT2r :ChimeSet LDZr STHrk [?
167-    POP2r printat/0 "OFF 2020 2020 2020 2020 00 JMP2r
168-  ]@
169-  #04 STHrk EQU [?
170-    [& ""631 ]@ OVR2r ADD2r LDAr STHr printc
171-    STHr POPr #03 EQU #05 MUL #30 ADD printc
172-    printat/0 20 "MINUTES 20 00 JMP2r
173-    JMP2r
174-  ]@
175-  POP2r printat/0 "WESTMINSTER 00 JMP2r
176-
177-@cursor-adjust ( -- )
178-  #060c printat 8520 "CURSOR 2086 00
179-  #060e printat 8820 "ADJUST 2087 00
180-  JMP2r
181-
182-@draw-cursor ( -- )
183-  LIT2 06 -Cursor LDZ STHk DUP ADD ADD STHr #01 SFT ADD
184-  #04 locate LIT "^ !printc
185-
186-@draw-marked-time ( addr -- addr )
187-  [& LIT ": printc ]@ [& LIT ": printc ]@ [& ]@ LDZk printc INC JMP2r
188-
189-@redraw-screen ( -- )
190-  DUP2rk EOR2r LITr 28 DEO2rk INCr INCr DEO2r #802e DEO
191-  #0112 printat 8b8d 8f20 "MODE 2020 20 8c8e 8f20 "SILENCE 00
192-  .Mode LDZ INC LDR2 JMP2 :redraw-clock0 :redraw-alarm0 :redraw-timer0 :redraw-sound0
193-
194-@ScreenVec
195-  .LastSec LDZ #c6 DEI EQU [?
196-    #c6 DEI .LastSec STZ ;Frame STZ
197-    .Mode LDZ [? redraw-clock ]@
198-    .LastSec LDZ [?
199-      .AlarmOn LDZ [?
200-        ;Alarm LDZ2 #c4 DEI2 NEQ2 [? #61 setsound ]@
201-      ]@
202-      ;ChimeSet LDZ EQU [?
203-        .SoundState LDZ [?
204-          #c5 DEI
205-          LIT2 04 -ChimeSet LDZ EQU [?
206-            LIT2 78 -ChimeSet LDZ SFT DIVk MUL SUB [?
207-              #5c setsound
208-            ]@
209-          ][
210-            #0f DIVk STHk MUL SUB [?
211-              STHrk [?
212-                fullhour
213-              ][
214-                ;quarters STHrk #0007 SFT2 ADD2 LDA2
215-                STHrk #fb MUL setchimes
216-              ]@
217-            ]@ POPr
218-          ]@
219-        ]@
220-      ]@
221-    ]@
222-    .MissFrame
223-  ][
224-    .Frame
225-  ]@ LDZk INC SWP STZ
226-  .TimerOn LDZ ?TimerVec
227-  &sound
228-  .SoundState LDZ [?
229-    \\ Westminster Quarters
230-    .MusicState LDZ [?
231-      .HourBells LDZ [? BRK ]@
232-      .SoundFrame LDZk INC DUP [?
233-        POP #7f
234-        #0f0f #38 DEO2
235-        #343f DEO
236-        .HourBells LDZk INC SWP STZ
237-      ]@ SWP STZ
238-      BRK
239-    ]@
240-    .SoundFrame LDZk INC DUP [?
241-      STH .MusicAddr LDZ2k
242-      LDAk DUP STHr EQU [? DUP #3f DEO ]@ POP
243-      INC2 DUP2 ;change6 NEQ2 [? POP2 ;change1 ]@
244-      ROT STZ2
245-      .MusicState LDZk INC SWP STZ
246-      #df
247-    ]@ SWP STZ
248-    BRK
249-  ]@
250-  .SoundFrame LDZk INC #0f AND STHk SWP STZ
251-  STHr #07 AND [?
252-    LIT2 08 -SoundFrame LDZ AND [?
253-      .Volume LDZ2
254-    ][
255-      LIT2 01 -SoundState LDZ AND [? ;SoundState STZ ]@
256-      #00ff
257-    ]@ #3e DEO2
258-  ]@
259-  BRK
260-
261-@TimerVec
262-  LIT2 01 -MissFrame LDZ LTH [?
263-    .Frame LDZ .Timer/f LDZ NEQ ?ScreenVec/sound
264-  ]@
265-  .Frame LDZ .Timer/f STZ
266-  .CountDir LDZ [?
267-    &down
268-    .Timer/s downtime
269-    .Timer/m downtime
270-    .Timer/h downtime
271-    #5f setsound
272-    LIT2 01 -CountDir STZ
273-    #0202 printat "! 00
274-    #0000 .Timer/h STZk INC STZ2
275-  ][
276-    &up
277-    .Timer/s uptime
278-    .Timer/m uptime
279-    .Timer/h uptime
280-  ]@
281-  &done
282-  LIT2 04 -Mode LDZ NEQ [? redraw-timer ]@
283-  ;MissFrame STZ
284-  !ScreenVec/sound
285-
286-@uptime ( addr -- )
287-  LDZk INC DUP #3c LTH [? DUP EOR SWP STZ JMP2r ]@
288-  SWP STZ POP2r !TimerVec/done
289-
290-@downtime ( addr -- )
291-  LDZk [? #3b SWP STZ JMP2r ]@
292-  POP2r LDZk #01 SUB SWP STZ !TimerVec/done
293-
294-@setsound ( note -- )
295-  ;SoundState STZ2
296-  ;HourBells STZ
297-  #0000 #38 DEO2
298-  .Volume LDZ2 #3e DEO2
299-  JMP2r
300-
301-@setchimes ( address* 256-count -- )
302-  #00 setsound
303-  #0809 #38 DEO2
304-  .MusicState STZ
305-  .MusicAddr STZ2
306-  LIT2 ff -SoundFrame STZ
307-  JMP2r
308-
309-@change1 44 42 40 3b 00
310-@change2 40 44 42 3b 00
311-@change3 40 42 44 40 00
312-@change4 44 40 42 3b 00
313-@change5 3b 42 44 40 00
314-@change6 ( Big Ben: 34 )
315-
316-\_@2- \@quarters :change1 :change2 :change4
317-
318-@KeyVec
319-  ;Blank mousedraw 41
320-  #82 DEI [?
321-    #d083 DEI ADD #09 GTH [?
322-      \\ do numeric key command by mode
323-      #d083 DEI ADD .Cursor LDZ
324-      .Mode LDZ INC LDR2 JMP2
325-      :kNoD :kAlarmD :kTimerD :kNoD
326-    ]@
327-  ][
328-    #ff82 DEI ADDk AND NIP [?
329-      \\ do key command by mode
330-      #82 DEI LIT2r :KeyCodes [@
331-        #01 SFT DUP [?
332-          .Mode LDZ STH2r ADD2 LDA2 JMP2
333-        ]@
334-      LIT2r 0008 ADD2r ]!
335-    ]@
336-  ]@
337-  @kBrk BRK
338-
339-@KeyCodes
340-  ( A ) :kToggleAlarm :kAlarmOn :kGo :kTest
341-  ( B ) :kToggle24 :kAlarmOff :kStop :kSave
342-  ( SELECT ) :kMode :kMode :kMode :kMode
343-  ( START ) :kNoSound :kNoSound :kNoSound :kNoSound
344-  ( UP ) :kBrk :kAlUp :kTimerUp :kHighVolume
345-  ( DOWN ) :kBrk :kAlDown :kTimerDown :kLowVolume
346-  ( LEFT ) :kBrk :kCursorL :kCursorL :kPrevChime
347-  ( RIGHT ) :kBrk :kCursorR :kCursorR :kNextChime
348-
349-@kToggleAlarm .AlarmOn LDZ ?kAlarmOn ( fallthrough )
350-@kAlarmOff LIT2 01 -AlarmOn STZ LIT2 61 -SoundState LDZ NEQ [? #60 setsound ]@ @kMode0 ;Mode STZ JMP2rk
351-@kAlarmOn LIT2 00 -AlarmOn STZ #60 setsound !kMode0
352-@kNoSound ;SoundState STZ #00ff #3e DEO2 JMP2rk
353-@kMode LIT2 06 -Mode LDZ INC INC AND ;Mode STZ2 JMP2rk
354-@kToggle24 .Clock24 LDZk #01 EOR @kStore SWP STZ JMP2rk
355-@kLowVolume .Volume LDZk #11 SUB @kVolume DUP #0f AND [? POP2 BRK ]@ SWP STZ redraw-sound #50 setsound BRK
356-@kHighVolume .Volume LDZk #11 ADD !kVolume
357-@kPrevChime .ChimeSet LDZk DUP [? POP #05 ]@ #01 SUB !kChimeSet
358-@kNextChime .ChimeSet LDZk INC DUP #05 NEQ MUL @kChimeSet SWP STZ redraw-sound BRK
359-@kTest LIT2 04 -ChimeSet LDZ EQU [? #5c setsound ][ fullhour ]@ BRK
360-@kCursorL .Cursor LDZ [? BRK ]@ .Cursor LDZk #01 SUB !kStore
361-@kCursorR .Mode LDZ2 LTH ?kBrk .Cursor LDZk INC !kStore
362-
363-@kAlUp
364-  LIT2 02 -Cursor LDZ AND [? .Alarm LDZk INC DUP #18 NEQ MUL @kAlSet SWP STZ redraw-alarm BRK ]@
365-  alarmAdjAmount SUB #3c DIVk MUL SUB !kAlSet
366-
367-@kAlDown
368-  LIT2 02 -Cursor LDZ AND [? .Alarm LDZk DUP [? POP #18 ]@ #01 SUB !kAlSet ]@
369-  alarmAdjAmount ADD #3c GTHk MUL ADD !kAlSet
370-
371-@alarmAdjAmount .Alarm/m LDZk LIT2 09 -Cursor LDZ MUL #1c SUB JMP2r
372-
373-@kTimerUp LIT2 ff _kTimerAdj/x STR !kTimerAdj
374-@kTimerDown LIT2 00 _kTimerAdj/x STR ( fall through )
375-@kTimerAdj
376-  .TimerOn LDZ ?kBrk
377-  LIT2 -Timer -Cursor LDZ #01 STH2k SFT ADD LDZk
378-  STH2r AND #09 MUL #f6 ADD
379-  LIT &x 00 [? ADD #3c GTHk MUL ADD ][ SUB #3c DIVk MUL SUB ]@
380-  SWP STZ redraw-timer BRK
381-
382-@kNoD POP2 BRK
383-
384-@kAlarmD
385-  DUP INC #03 AND .Cursor STZ
386-  commonD
387-  OVR #24 MUL #18 ADD OVR GTH ?kStore
388-  &wrong POP #00 ;Cursor STZ #38 setsound !kStore
389-
390-@kTimerD
391-  .TimerOn LDZ ?kNoD
392-  DUP INC DUP #06 NEQ MUL .Cursor STZ .2xTimer ADD
393-  commonD
394-  DUP #3b GTH ?kAlarmD/wrong !kStore
395-
396-@commonD #01 SFTk SWP ROT AND [? SWP #0a MUL ][ LDZk ROT ADD ]@ JMP2r
397-
398-@write-mark ( value address -- )
399-  STH #0a DIVk STHk MUL SUB #30 STHk ADDr ADD STH ROTr STZ2r
400-  JMP2r
401-
402-@kGo
403-  #c6 setsound
404-  .TimerOn LDZ [?
405-    LIT2 01 -TimerOn STZ
406-    ;Timer LDZk SWP INC LDZ2 ORA ORA EQU DUP .CountDir STZ
407-    .Frame LDZ .Timer/f STZ
408-    ;MissFrame STZ
409-  ][
410-    #d8 DUPk .Mark LDZ EQU [? .Mark LDZk #08 SUB SWP STZ ]@
411-    [@ DUP #08 ADD LDZ OVR STZ INC DUP ]? POP
412-    .Timer LDZk #f8 write-mark
413-    INC LDZk #fa write-mark
414-    INC LDZ #fc write-mark
415-    .Frame LDZ .Timer/f LDZ SUB
416-    .CountDir LDZ [? #ff MUL ]@
417-    #3c DUP2 GTH MUL ADD #fe write-mark
418-  ]@
419-  redraw-screen
420-  [? !TimerVec/down ]@ BRK
421-
422-@kStop
423-  #c6 setsound
424-  .TimerOn LDZ [?
425-    ;Cursor STZk INC STZk POP ;Timer STZk INC STZ2
426-  ][
427-    ;TimerOn STZ
428-  ]@
429-  JMP2rk
430-
431-@MouseVec
432-  ;Blank mousedraw 41
433-  #92 DEI2 .MouseX STZ2
434-  #94 DEI2 .MouseY STZ2
435-  ;mouseshape mousedraw c1
436-  #0196 DEI AND .MouseState STH2k LDZ STZr INC AND [? BRK ]@
437-  .MouseX LDZ2 #00bf GTH2 ?kBrk
438-  .MouseY LDZ2 #005a SUB2 #0066 GTH2 ?kBrk
439-  ;KeyCodes ;Mode LDZ ADD2 #00
440-  LIT2 57 -MouseX/lo LDZ GTH LIT2 c6 -MouseY/lo LDZ ADD #14 SFT ADD
441-  LDR ADD2 LDA2 JMP2 00 38 30 20 28 08 00 18 10
442-
443-@mousedraw ( picture* -- )
444-  .MouseX LDZ2 #28 DEO2
445-  .MouseY LDZ2 #2a DEO2
446-  #2c DEO2
447-  LDArk LITr 2f DEOr INC2r JMP2r
448-
449-@Weekday
450-  "SUN
451-  "MON
452-  "TUE
453-  "WED
454-  "THU
455-  "FRI
456-  "SAT
457-
458-@SqWave 00ff
459-
460-@fullhour ( -- )
461-  ;change2 #ec setchimes
462-  #00c4 DEI
463-  #0c LTHk #01 EOR MUL SUB DUP [? POP #0c ]@
464-  SUB .HourBells STZ
465-  JMP2r
466-
467-@Digits
468-  ( .0.. .1.. .2.. .3.. .4.. .5.. .6.. .7.. .8.. .9.. )
469-    8182 8120 8180 8180 8181 2082 2082 8180 8182 8182
470-    8181 8120 2082 8180 8180 8180 8182 8120 8182 8180
471-    2080 2020 2080 2080 2020 2080 2080 2020 2080 2080
472-  ( .0.. .1.. .2.. .3.. .4.. .5.. .6.. .7.. .8.. .9.. )
473-
474-\_@0100"- \@Font @Blank \~ascii.font
475-
476-( 80 )
477-  \-..111111
478-  \-..111111
479-  \-........
480-  \-........
481-  \-........
482-  \-........
483-  \-........
484-  \-........;
485-( 81 )
486-  \-........
487-  \-........
488-  \-11......
489-  \-11......
490-  \-11......
491-  \-11......
492-  \-11......
493-  \-11......;
494-( 82 )
495-  \-..111111
496-  \-..111111
497-  \-11......
498-  \-11......
499-  \-11......
500-  \-11......
501-  \-11......
502-  \-11......;
503-( 83 )
504-  \-........
505-  \-........
506-  \-........
507-  \-........
508-  \-.11.....
509-  \-.11.....
510-  \-........
511-  \-........;
512-( 84 )
513-  \-...11...
514-  \-..1..1..
515-  \-..1..1..
516-  \-.1....1.
517-  \-11111111
518-  \-...1....
519-  \-....1...
520-  \-........;
521-( 85 )
522-  \-....1...
523-  \-...11...
524-  \-..111...
525-  \-.1111...
526-  \-..111...
527-  \-...11...
528-  \-....1...
529-  \-........;
530-( 86 )
531-  \-..1.....
532-  \-..11....
533-  \-..111...
534-  \-..1111..
535-  \-..111...
536-  \-..11....
537-  \-..1.....
538-  \-........;
539-( 87 )
540-  \-........
541-  \-........
542-  \-...1....
543-  \-..111...
544-  \-.11111..
545-  \-1111111.
546-  \-........
547-  \-........;
548-( 88 )
549-  \-........
550-  \-........
551-  \-1111111.
552-  \-.11111..
553-  \-..111...
554-  \-...1....
555-  \-........
556-  \-........;
557-( 89 )
558-  \-.11111..
559-  \-111.111.
560-  \-11.1.11.
561-  \-1.111.1.
562-  \-1.....1.
563-  \-1.111.1.
564-  \-1.111.1.
565-  \-.11111..;
566-( 8a )
567-  \-.11111..
568-  \-1...111.
569-  \-1.11.11.
570-  \-1...111.
571-  \-1.11.11.
572-  \-1.11.11.
573-  \-1...111.
574-  \-.11111..;
575-( 8b )
576-  \-.1111111
577-  \-1..1..1.
578-  \-1.11.11.
579-  \-1..1..1.
580-  \-11.1.11.
581-  \-1..1..1.
582-  \-.1111111
583-  \-........;
584-( 8c )
585-  \-.1111111
586-  \-1..1...1
587-  \-1.111.11
588-  \-1..11.11
589-  \-11.11.11
590-  \-1..11.11
591-  \-.1111111
592-  \-........;
593-( 8d )
594-  \-11111111
595-  \-11..1..1
596-  \-11.11.11
597-  \-11..1.11
598-  \-11.11.11
599-  \-.1..1..1
600-  \-11111111
601-  \-........;
602-( 8e )
603-  \-11111111
604-  \-1.11..11
605-  \-.1.1.1.1
606-  \-...1..11
607-  \-.1.1.1.1
608-  \-.1.1.1.1
609-  \-11111111
610-  \-........;
611-( 8f )
612-  \-1111....
613-  \-...11...
614-  \-1.111...
615-  \-1.111...
616-  \-1.111...
617-  \-1.111...
618-  \-1111....
619-  \-........;
620-
621-@mouseshape
622-  \=2222222.
623-  \=2333332.
624-  \=2332222.
625-  \=23232...
626-  \=232232..
627-  \=232.232.
628-  \=222..232
629-  \=......22;
630-
+0, -13
 1@@ -1,13 +0,0 @@
 2-\\ Converts TRON-32BE to TRON-16BE.
 3-\\ (This file is public domain.)
 4-
 5-|0100 ;input/0 #10 DEO2k
 6-[@
 7-  input EQU2k EQUk ORA [?
 8-    NIP2 OVRk #ff MUL [@ #fe18 DEO INCk SWP ]? POP
 9-    OVR INC #01 AND [? #0018 DEO ]@
10-    DUP #18 DEO
11-  ]@ POP2
12-  input SWP #18 DEO #18 DEO
13-]!
14-@input [& ]@ BRK &0 #12 DEI JMP2r
+0, -20
 1@@ -1,20 +0,0 @@
 2-\\ Converts TRON-8 or TRON-16BE to TRON-32BE. (Ignores nulls)
 3-\\ (This file is public domain.)
 4-
 5-|0100
 6-  ;read/0 #10 DEO2
 7-  #0000 ( current plane selection )
 8-@main
 9-  read
10-  DUP #fe EQU ?shift
11-  DUP #7f EQU OVR #21 LTH ORA ?control
12-  STH DUP2 STHr read write !main
13-@shift
14-  POP POP2 #ffff
15-  [@ POP INC read DUP #fe EQU ]? !main
16-@control
17-  #0000 ROT OVR SWP write !main
18-
19-[@ POP @read BRK &0 #12 DEI DUP #00 EQU ]? JMP2r
20-@write SWP2 [& ]@ SWP #18 DEO #18 DEO JMP2r
21-
+0, -51
 1@@ -1,51 +0,0 @@
 2-Give two command-line arguments, being the input file name and the output
 3-file name. (This program does not operate in GUI mode or interactive mode.)
 4-
 5-Each line of the input file contains a command, indicated by the first
 6-character. The possible commands are:
 7-
 8-#  Comment in the input file; not written to the output. (This is not the
 9-same as a comment block.)
10-
11-.  A line of text. Only allowed inside of a () or <> or [] block; cannot be
12-used at the top level or inside of a {} block.
13-
14-&  Define the title of the hint file. Should occur exactly once.
15-
16--  A separator line (which should not include any text). Only allowed
17-inside of a {} block or a [] block. In a [] block, it will hide all further
18-text in this block until the user tells to reveal the next part (you can
19-have more than one separator; each one stops output until the user tells to
20-continue further output). In a {} block, just makes a blank line.
21-
22-:  A link to some other block in the file. Follow by the target label name
23-(which is the label name of any block in the file) and then . and the text
24-of the link.
25-
26-There are also blocks. The characters [ ( < { indicate the beginning of a
27-block and ] ) > } indicate the end of a block. The begin block line will
28-also have the label name (which can be blank if there is no label name)
29-and then . and then the text which is the title of that block. The end
30-block line should not have any text.
31-
32-()  Comment: A block of text which is not a hint, but just text. Cannot
33-contain any other blocks, and cannot contain links. (This is not the same
34-as the # command.)
35-
36-<>  Credit: Works like comment blocks.
37-
38-{}  Subject: A menu block. Can include other blocks but not text lines.
39-(Normally used for grouping hints by the section in the game.)
40-
41-[]  Hint: This block can contain text and other blocks. This is used for a
42-game hint and the title is usually a question that will be answered by the
43-text in this block. You can add separator lines so that only one part of
44-the text is revealed at a time.
45-
46-Any line in the input file can optionally be indented by spaces and/or tabs
47-at the beginning of the line; any such indentation is ignored. (You can use
48-this to indent blocks if you wish.)
49-
50-This program will not calculate the checksum of the UHS file; however, the
51-FOSS implementations do not care about the checksum, so it isn't a problem.
52-
+0, -346
  1@@ -1,346 +0,0 @@
  2-\\ UHS make (public domain)
  3-\\ Requires some nonstandard features of uxn38.
  4-
  5-|0000
  6-  @X $1 @Y $1
  7-  $2 \\ padding, used when a block is not given a label name
  8-  @Name $2
  9-  @Line $2
 10-  @LineIn $2
 11-  @Tlength $1
 12-  @Tend $1
 13-|0028 \\ note that this number is on purpose, for purpose of making the key
 14-  @Title
 15-
 16-|0100
 17-  \\ Check arguments
 18-  #17 DEI [? error "usage: 20 "uhsmake.rom 20 "<inputfile> 20 "<outputfile> 0a ]@
 19-  \\ Input file name
 20-  LIT2r :filename DUP2r
 21-  [; #10 DEO2 BRK ]@
 22-  #17 DEI #02 GTH [? #12 DEI STH2rk INC2r STA BRK ]@
 23-  #00 STH2r STA
 24-  DUP2rk LITr a8 DEO2r
 25-  \\ Output file name
 26-  [; #10 DEO2 BRK ]@
 27-  #17 DEI #02 GTH [? #12 DEI STH2rk INC2r STA BRK ]@
 28-  #00 DUPk STH2r STA
 29-  LITr b8 DEO2r
 30-  #10 DEO2
 31-  \\ Write the 88a format heading of the hint file
 32-  ;uhshlen #ba DEO2
 33-  ;uhshead #be DEO2
 34-  \\ Initialize variables
 35-  ;firstname .Name STZ2
 36-
 37-\\ First pass
 38-  #0003 .Line STZ2
 39-  LIT2r :heap DUP2r \\ keep it for later too
 40-  #00 DUPk INC \\ the first entry has 0 to keep track of misnesting
 41-  \\ stack entry: ( line-number* block-entry* type )
 42-  \\ 00=hint/nesthint 01=subject ff=comment/credit
 43-@pass1
 44-  GTH2rk STHr ?overflow
 45-  nxline [:
 46-    ". :p1text
 47-    "- :p1brk
 48-    "( :p1cc
 49-    "< :p1cc
 50-    "{ :p1sub
 51-    "[ :p1hint
 52-    ": :p1link
 53-    ") :p1close
 54-    "} :p1close
 55-    "] :p1close
 56-    "> :p1close
 57-    "# :p1ign
 58-    "& :p1title
 59-  00 ]@
 60-
 61-\\ Second pass
 62-  POP2r
 63-  POP #0000 EQU [? error "Unterminated 20 "block 0a ]@
 64-  #00a7 DEO ( rewind )
 65-  \\ Send first block heading
 66-  ;typ/subject .Line LDZ2 #0001 SUB2 nodehead
 67-  \\ Send title
 68-  ;Tlength LDZ
 69-  DUP [? error "Missing 20 "title 0a ]@
 70-  #ba DEO2 ;Title #be DEO2 crlf
 71-  \\ Make key
 72-  \\  In C codes:  k[i]+="key"[i%3]^(i+40); while(k[i]>127) k[i]-=96;
 73-  LIT2 -Title -Tlength LDZ ADDk .Tend STZ POP
 74-  [@
 75-    LDZk STH LIT2r :key STHk LITr 03 DIVrk MULr SUBr ADDr LDAr STHk EORr ADDr
 76-    STHrk #80 LTH [? DUPr LITr df GTHr INCr LITr 60 MULr SUBr ]@ STHk STZr
 77-    INC DUP
 78-  ]?
 79-  \\ stack entry: ( type )
 80-  \\ 00=subject/comment/credit 01=hint ff=nesthint
 81-  \\ (The appropriate value is already in the stack)
 82-@pass2
 83-  nxline [:
 84-    ". :p2text
 85-    "- :p2brk
 86-    "( :p2com
 87-    "< :p2cred
 88-    "{ :p2sub
 89-    "[ :p2hint
 90-    ": :p2link
 91-    ") :p2close
 92-    "} :p2close
 93-    "] :p2close
 94-    "> :p2close
 95-    "# :p2ign
 96-    "& :p2ign
 97-  00 ]@
 98-
 99-\\ Finished
100-  ;verlen #ba DEO2
101-  ;version #be DEO2
102-  #800f DEO
103-
104-\_@2+fe'&(@2+!) \\ alignment
105-@key "yke
106-
107-@overflow
108-  error "Heap 20 "overflow 0a
109-
110-@error
111-  \\ Line number
112-  LIT2r 19 DEO LIT LIT ;number/em STH2k STA INC2r STA2r
113-  .LineIn LDZ2 number #2019 DEO
114-  \\ Text
115-  [@ STH2rk INC2r LDA DUP #19 DEO #0a EOR ]?
116-  #010f DEO BRK
117-
118-@p1link
119-  need95a
120-  DUP [? add1line STH LITr 01 STH2k STAr STHr ]@
121-  badcontext
122-  rname1 ORA [? error "Name 20 "required 20 "for 20 "link 0a ]@
123-  add2line
124-@p1text
125-  DUP #01 NEQ [? error "Text 20 "line 20 "not 20 "allowed 20 "in 20 "subject 20 "block 0a ]@
126-  add1line
127-@p1ign
128-  skline !pass1
129-@p1title
130-  LITr 00 .Title
131-  [@
132-    #ac DEI
133-    DUP #1f GTH [?
134-      LITr -Tlength STZr
135-      POP2 !pass1
136-    ]@
137-    OVR STZ INC INCr
138-  ]!
139-@p1cc
140-  #ff !p1open
141-@p1sub
142-  #01 !p1open
143-@p1hint
144-  #00
145-@p1open
146-  ,&kind STR
147-  badcontext
148-  DUP [? need95a add1line STH LITr 01 STH2k STAr STHr ]@
149-  .Line LDZ2 DUP2 rname1 INC2 INC2
150-  LDA2k DUP2k EOR2 EQU2 [? error "Duplicate 20 "label 0a ]@
151-  STA2 STH2rk LIT &kind $1
152-  #00 DUPk #02 STZ2 STH2rk STA ( nest flag )
153-  INC2r INC2r INC2r ( skip past the newly added record )
154-  add2line !p1ign
155-@p1close
156-  POP ORAk [? error "Block 20 "ended 20 "without 20 "beginning 0a ]@
157-  \\ Set the number of lines in the block record
158-  INC2 SWP2 LITr -Line LDZ2r STH2 SUB2r STH2 STA2r
159-  !p1ign
160-@p1brk
161-  badcontext
162-  LIT2r :p1ign DUP ?add2line !add1line
163-
164-@p2brk
165-  DUP [? ;typ/blank #0002 nodehead ]@
166-  LIT "- emit crlf
167-@p2ign
168-  skline !pass2
169-@p2com
170-  p2open :typ/comment
171-@p2cred
172-  p2open :typ/credit
173-@p2sub
174-  p2open :typ/subject
175-@p2hint
176-  p2open 0000
177-@p2open
178-  INCk [? LIT "= emit crlf ]@
179-  STH2r LDA2
180-  rname2 POP2 \\ ignore the label name, if any
181-  ORAk [?
182-    \\ Read nest flag of current record
183-    LDArk STHr [? POP INC ;typ/hint ][ INC SUB ;typ/nesthint ]@
184-  ][
185-    #00 ROT ROT
186-  ]@
187-  INC2r STH2rk LDA2 nodehead INC2r INC2r
188-@p2plain
189-  plain !pass2
190-@p2close
191-  POP !p2ign
192-@p2link
193-  INCk [? LIT "= emit crlf ]@
194-  ;typ/link #0003 nodehead
195-  rname2 plain
196-  INC2 INC2 LDA2 ORAk [? error "Undefined 20 "label 0a ]@
197-  number crlf !pass2
198-@p2text
199-  INCk [?
200-    \\ Encryption for "nesthint" block
201-    LIT2 -Tend -Title STHk
202-    [@
203-      #ac DEI DUP #20 LTH ?&n
204-      OVR LDZ STHrk EOR ADD
205-      DUP #20 SUB #60 DIVk MUL NIP SUB
206-      emit
207-      INCr INC EQUk .Tlength LDZ MUL SUB
208-    ]!
209-  ]@
210-  DUP ?&h !p2plain
211-  \\ Encryption for "hint" block
212-  [@ DUP #01 AND #5f MUL ADD #20 ADD #01 SFT emit
213-  &h #ac DEI DUP #1f GTH ]? &z POP crlf !pass2
214-  &n POP2 POPr !&z
215-
216-@add2line ( -- ) add1line ( fall through )
217-@add1line ( -- ) .Line LDZ2k INC2 ROT STZ2 JMP2r
218-
219-[@ emit @plain ( -- ) #ac DEI DUP #1f GTH ]? POP !crlf
220-
221-@badcontext ( type -- type )
222-  INCk STH2r JCN2
223-  error "Not 20 "valid 20 "in 20 "this 20 "context 0a
224-
225-@nxline
226-  ;LineIn LDZ2k INC2 ROT STZ2
227-  [@ POP #ac DEI DUP #00 EQU ?&zero DUP #21 LTH ]?
228-  [@ INC2r INC2r
229-    LDArk STHr [? error "Unrecognized 20 "command 0a ]@
230-    STH2rk INC2r LDA OVR NEQ
231-  ]? &zero POP LDA2r JMP2r
232-
233-@skline ( -- )
234-  #ac DEI DUP #0a NEQ MUL ?skline JMP2r
235-
236-@need95a ( -- )
237-  LIT "5 ;version/0 STA JMP2r
238-
239-@rname1 ( -- nameptr* )
240-  LIT2 ". ac DEI NEQk [? EOR DUP JMP2r ]@
241-  ( dot char // heap* return* )
242-  SWP2r DUP2r LIT2r 0006 ADD2r STH2rk ;&ns STA2
243-  ( dot char // return* heap* stringptr* )
244-  [@
245-    STH2rk INC2r STA #ac DEI
246-    DUP #20 GTH [? error "Invalid 20 "character 20 "in 20 "label 20 "name 0a ]@
247-    NEQk
248-  ]?
249-  EOR STH2rk STA ( null terminator )
250-  ( // return* heap* endstr* )
251-  ;firstname &find
252-  LDA2 ORAk [?
253-    \\ Not found; add a new one
254-    INC2r ROT2r ROT2r
255-    INC2rk INC2r SWP2r STA2rk LDA2r
256-    STH2rk STA2k INC2 INC2 STA2
257-    STH2rk .Name STHk LDZ2 STA2 STZ2r STH2r JMP2r
258-  ]@
259-  LIT2r &ns $2 INC2k INC2 INC2 INC2
260-  ( namerec* str1* // return* heap* endstr* str2* )
261-  [@
262-    INC2k SWP2 LDA LDArk STHr INC2r
263-    ( namerec* str1n* char1 char2 // return* heap* endstr* str2n* )
264-    EQUk [? POP2 POP2 POP2r !&find ]@
265-    POP
266-  ]?
267-  \\ Found
268-  POP2r POP2r POP2 DUP2 STH2rk STA2 INC2r INC2r SWP2r JMP2r
269-
270-@rname2 ( -- nameptr* )
271-  LIT2 ". ac DEI NEQ [? #0000 JMP2r ]@
272-  [@ LIT2 ". ac DEI NEQ ]?
273-  STH2r \\ save return address
274-  STH2rk INC2r INC2r LDA2
275-  ( return* nameptr* // newheap* )
276-  \\ Skip past the name record if it is this address
277-  DUP2 STH2rk NEQ2 [?
278-    LIT2r 0004 ADD2r
279-    [@ LDArk STHr INC2r ]?
280-  ]@
281-  SWP2 JMP2
282-
283-@number ( number* -- )
284-  LITr 00
285-  [@
286-    #000a DIV2k STH2k MUL2 SUB2
287-    STH2 SWP2r STH2r
288-    NIPr LITr 30 ADDr
289-  ORAk ]?
290-  POP2
291-  [@ STHr &em emit STHrk ]?
292-  POPr JMP2r
293-
294-@emit ( char -- ) LIT2r 0001 DUP2r STHrk STZ LITr ba DEO2r LITr be DEO2r JMP2r
295-
296-@nodehead ( type* lines* -- )
297-  number #2001 STZ #01bf DEO
298-  #bb DEO #00 SWP ;nodetypes ADD2 #be DEO2
299-  \\ Fallthrough
300-@crlf ( -- ) #0002 #ba DEO2 [; #be DEO2 JMP2r ]@ 0d0a
301-
302-@nodetypes
303-  "nesthint
304-  "subject
305-  "credit
306-  "comment
307-  "link
308-  "blank
309-
310-@version
311-  \_@
312-  "3 20 "version 0d0a
313-  "9 &0 "1a 0d0a
314-  "Compiled 20 "using 20 "uhsmake 20 "of 20 "uxn. 0d0a
315-  1a 0000 ( checksum )
316-  \_@,- \@verlen
317-
318-\\ Name entry format:
319-\\   next name entry address (16-bits)
320-\\   line number (16-bits)
321-\\   name (null-terminated text)
322-@firstname 0000 0001 ( this one doesn't need text )
323-\\ These following things share the same memory, since @uhshead and
324-\\ @filename are both only used once, so they can be reused to store
325-\\ the heap after initialization.
326-@heap
327-@uhshead \_@ \~not88aonly.uhs \_@,- \@uhshlen
328-@filename
329-
330-\\ Record types (in heap):
331-
332-\\ label/link:
333-\\   address of name entry (16-bits)
334-\\   (if the name entry immediately follows, skip past it)
335-\\ credit/comment/subject/hint/nesthint:
336-\\   nest flag (8-bits; 0=not nest, 1=nest)
337-\\   number of lines (16-bits)
338-
339-@typ
340-  |0008 &nesthint
341-  |0404 &hint
342-  |0807 &subject
343-  |0f06 &credit
344-  |1507 &comment
345-  |1c04 &link
346-  |2005 &blank
347-
+0, -456
  1@@ -1,456 +0,0 @@
  2-\\ UHS viewer (public domain)
  3-\\ Requires some nonstandard features of uxn38.
  4-
  5-\\ (This program is currently incomplete.)
  6-
  7-|0000
  8-  @Jstate $1
  9-  @Mstate $1
 10-  @MouseX $2
 11-  @MouseY $2
 12-  @Type $1
 13-  \\ Pointers into line index
 14-  @Active $2
 15-  @Scroll $2
 16-  @Cursor $2
 17-  @Break $2
 18-  @ActiveEnd $2
 19-|0022
 20-  @Width $1
 21-|0024
 22-  @Height $1
 23-  @Tend $1
 24-|0028
 25-  @Title
 26-
 27-|0100
 28-  started
 29-@makeindex
 30-  \\ Load the list of lines
 31-  LIT2r :line-1 LIT2r :lines
 32-  &go
 33-    \\ Update parent address if necessary
 34-    OVR2r STH2r #06 ADD LDA2 STH2rk GTH2 [?
 35-      SWP2r LDA2r
 36-      STH2rk #05 ADD LDA .typ/subject EOR ;&in STA
 37-      SWP2r !&go
 38-    ]@
 39-    \\ File position
 40-    #a3 STH2rk STA STH2rk #02 DEO2
 41-    \\ Parent address
 42-    STA2rk
 43-    \\ Number of lines, or - or =
 44-    #0000 #ac DEI
 45-    ( number* char // parent* addr* )
 46-    isword "- -typ/break 0d
 47-    isword "= -typ/inner 0d
 48-    DUP #1a EQU ?&eof
 49-  &ch
 50-    DUP #0a EQU ?&el
 51-    DUP #20 EQU ?&sp
 52-    #30 SUB DUP #09 GTH ?&nn
 53-    STH #000a MUL2 #00 STHr ADD2
 54-    #ac DEI !&ch
 55-  &sp
 56-    POP #ac DEI
 57-    DUP LIT "c NEQ [?
 58-      POP #ac DEI
 59-      isword "r -typ/credit "edit 0d
 60-      isword "o -typ/comment "mment 0d
 61-    ]@
 62-    isword "s -typ/subject "ubject 0d
 63-    isword "h -typ/hint "int 0d
 64-    isword "n -typ/nesthint "esthint 0d
 65-    isword "l -typ/link "ink 0d
 66-    isword "b -typ/blank "lank 0d
 67-    \\ None match, so fall through
 68-  &nn
 69-    POP #ac DEI DUP #0a NEQ ?&nn \\ fall through
 70-  &el
 71-    DUP EOR \\ fall through
 72-  &set
 73-    \\ Update parent address if applicable
 74-    LIT &in 00 [? NIP2r DUP2r DUP .typ/subject EOR ,&in STR ]@
 75-    DUP .typ/inner NEQ [? ,&in LDR DUP .subxnest NEQ MUL ,&in STR ]@
 76-    \\ Send record
 77-    STH2rk #05 ADD STA
 78-    ORAk [? INC ]@
 79-    #30 SFT2 STH2rk ADD2 STH2rk #06 ADD STA2
 80-    LIT2r 0008 ADD2r !&go
 81-  &eof
 82-    POP POP2 LIT2r :line-1/final STA2r POP2r \\ continue
 83-\\ Load and encrypt title
 84-  ;line2 seek
 85-  ;line3z LDA2 ;line2z LDA2 SUB2 #0002 SUB2
 86-  DUP .Title ADD .Tend STZ #aa DEO2
 87-  LIT2r :Title STHrk LITr ac DEO2r
 88-  [@
 89-    LDZk STH LIT2r :Tkey STHk LITr 03 DIVrk MULr SUBr ADDr LDAr STHk EORr ADDr
 90-    STHrk #80 LTH [? DUPr LITr df GTHr INCr LITr 60 MULr SUBr ]@ STHk STZr
 91-    INC DUP
 92-  ]?
 93-  POP ;lines
 94-\\ This must end not before 0x0200
 95-\_1@8>/[1E]
 96-\\ This fall through to gonode
 97-
 98-@gonode ( address* -- ) ( no return )
 99-  DUP2k .Active STZ2 #0010 ADD2 DUP2 .Scroll STZ2 .Cursor STZ2
100-  #05 ADD LDAk .Type STZ INC2 LDA2 .ActiveEnd STZ2
101-@shownode
102-  cls showtitle
103-  rvoff
104-  LITr -Scroll LDZ2r #01
105-  [@
106-    #00 OVR locate
107-    ( draw cursor ) #20 STH2rk .Cursor LDZ2 EQU2 OVR SFT SUB drawch
108-    STH2rk .ActiveEnd LDZ2 NEQ2 [?
109-      printi "--End-- 00
110-      !&end
111-    ]@
112-    STH2rk .Break LDZ2 NEQ2 [?
113-      printi "--More-- 00
114-      !&end
115-    ]@
116-    STH2rk #05 ADD LDA ( type )
117-    DUP .typ/inner NEQ [?
118-      LIT2r 0008 ADD2r \\ the actual item is the next line
119-    ][
120-      LIT2 -typ/subject -Type LDZ EQU [?
121-        \\ Not a subject or nesthint block; it contains text (possibly encrypted)
122-        DUP .typ/break EQU [?
123-          STH2rk seek
124-          plaintext \\ TODO
125-        ][
126-          printi "-- 00
127-        ]@
128-        POP !&next
129-      ]@
130-    ]@
131-    \\ It is an item in a subject or nesthint block
132-    typech STH2rk seek skipline plaintext
133-    &next \\ Next item
134-    LITr 06 ADDr LDA2r
135-    INC DUP .Height LDZ LTH
136-  ]?
137-  &end
138-  \\ Scroll indicator
139-  POP2r #0000 locate
140-  .Height LDZ NEQ DUP ADD
141-  .Active LDZ2 #0010 ADD2 .Scroll LDZ2 EQU2
142-  ADD #1d ADD drawch
143-  BRK
144-
145-@cls ( -- )
146-  #0000 #28 DEO2k INC INC DEO2 #802e DEO JMP2r
147-
148-@seek ( node* -- )
149-  STH2k LDA2 #a000 STH2rk STA2 STH2rk #02 DEO2 STH2r STA2 JMP2r
150-
151-@locate ( x y -- )
152-  #0005 SFT2 #2a DEO2 #0005 SFT2 #28 DEO2 JMP2r
153-
154-  85 80 81 81 82 83 84 2d 2d 84
155-@typech ( type -- )
156-  #0e SUB LDR
157-  \\ fall through
158-
159-@drawch ( char -- )
160-  #0005 SFT2 ;Font ADD2 #2c DEO2 LIT2 &ink 012f DEO JMP2r
161-
162-@printi ( -- )
163-  [@ LDArk STHr INC2r DUP [? POP JMP2r ]@ drawch ]!
164-
165-@rvon ( -- )
166-  LIT2 04 \,drawch/ink STR JMP2r
167-
168-@rvoff ( -- )
169-  LIT2 01 \,drawch/ink STR JMP2r
170-
171-@showtitle ( -- )
172-  rvon #0100 locate
173-  .Type LDZ typech
174-  .Active LDZ2 seek skipline
175-@plaintext ( -- )
176-  [@ #ac DEI DUP #0d NEQ [? POP JMP2r ]@ drawch ]!
177-
178-@error
179-  [@ STH2rk INC2r LDA DUP #19 DEO #0a EOR ]?
180-  #010f DEO BRK
181-
182-@skipline ( -- )
183-  [@ #0aac DEI NEQ ]? JMP2r
184-
185-@isword ( char -- )
186-  DUP LDArk STHr INC2r EQU [?
187-    [@ LDArk STHr INC2r #0d NEQ ]? JMP2r
188-  ]@
189-  POP LDArk STHr
190-  [@
191-    INC2r
192-    #ac DEI
193-    DUP #0a NEQ [? POP2r ?makeindex/el ]@
194-    DUP LDArk STHr EQU [? POP2r ?makeindex/nn ]@
195-    #0d NEQ [? POP2r #ac DEI ?makeindex/set ]@
196-  ]!
197-
198-@decode ( char -- char )
199-  DUP #21 LTH [?
200-    DUP ADD DUP #9f GTH #5f MUL SUB
201-  ]@ JMP2r
202-
203-@vkey
204-  hidemouse
205-  \\ Keyboard
206-  
207-  #82 DEI .Jstate STH2k LDZ STZr EQU ?brk
208-    \\ Joypad
209-    #0182 DEI EQU ?kEnter
210-    #0282 DEI EQU ?kExit
211-    #1082 DEI EQU ?kUp
212-    #2082 DEI EQU ?kDown
213-    
214-  @brk BRK
215-
216-@vmouse
217-  hidemouse
218-  #92 DEI2 DUP2 .MouseX STZ2 #28 DEO2
219-  #94 DEI2 DUP2 .MouseY STZ2 #2a DEO2
220-  ;mouseshape #2c DEO2 #c12f DEO
221-  #96 DEI .Mstate STH2k LDZ STZr EQU ?brk
222-    \\ If mouse button is pushed
223-    
224-  BRK
225-
226-@hidemouse ( -- )
227-  .MouseX LDZ2 #28 DEO2
228-  .MouseY LDZ2 #2a DEO2
229-  ;BlankFont #2c DEO2
230-  #412f DEO JMP2r
231-
232-@kEnter
233-  .Cursor LDZ2 .ActiveEnd LDZ2 EQU2 ?brk
234-  LIT2 -typ/subject -Type LDZ EQU [?
235-    LIT2 -typ/nesthint -Type LDZ NEQ ?brk
236-    LIT2 -typ/inner -Cursor LDZ2 #05 ADD LDA NEQ ?brk
237-    #0008
238-  ][
239-    #0000
240-  ]@
241-  .Cursor LDZ2 ADD2
242-  DUP2 #05 ADD LDA DUP .typ/blank LTH MUL [? POP2 BRK ]@
243-  !gonode
244-
245-@kExit
246-  .Active LDZ2 LDA2 !gonode
247-
248-@kUp
249-  LITr -Cursor LDZ2r
250-  .Active LDZ2 #0010 ADD2
251-  [@
252-    DUP2 STH2rk NEQ2 [? POP2 POP2r !shownode ]@
253-    DUP2 #05 ADD LDA .typ/inner EQU [? DUP2 .Cursor STZ2 ]@
254-    #06 ADD LDA2
255-  ]!
256-
257-@kDown
258-  .Cursor LDZ2 INC2 .ActiveEnd LDZ2 GTH2 ?brk
259-  .Cursor LDZ2 .Break LDZ2 EQU2 ?brk
260-  .Cursor LDZ2k
261-    LIT2 -typ/inner -Cursor LDZ2 #05 ADD LDA NEQ [? #0008 ADD2 ]@
262-  #06 ADD LDA2 ROT STZ2
263-  !shownode
264-
265-\_@2+fe'&(@2+!) \\ alignment
266-@Tkey "yke
267-
268-\_@8@7&-7&+! ( alignment )
269-
270-@mouseshape
271-  \=2222222.
272-  \=2333332.
273-  \=2332222.
274-  \=23232...
275-  \=232232..
276-  \=232.232.
277-  \=222..232
278-  \=......22;
279-
280-( 1c )
281-  \-........
282-  \-.11.....
283-  \-.1111...
284-  \-.111111.
285-  \-.1111...
286-  \-.11.....
287-  \-........
288-  \-........;
289-
290-( 1d )
291-  \-...1....
292-  \-..1.1...
293-  \-.1...1..
294-  \-1.....1.
295-  \-1.....1.
296-  \-.1...1..
297-  \-..1.1...
298-  \-...1....;
299-
300-( 1e )
301-  \-........
302-  \-........
303-  \-........
304-  \-........
305-  \-1.....1.
306-  \-.1...1..
307-  \-..1.1...
308-  \-...1....;
309-
310-( 1f )
311-  \-...1....
312-  \-..1.1...
313-  \-.1...1..
314-  \-1.....1.
315-  \-........
316-  \-........
317-  \-........
318-  \-........;
319-
320-\_@20'8*- \@Font @BlankFont \~ascii.font
321-
322-( 80 - subject )
323-  \-........
324-  \-........
325-  \-..1111..
326-  \-..1111..
327-  \-..1111..
328-  \-..1111..
329-  \-........
330-  \-........;
331-
332-( 81 - hint,nesthint )
333-  \-........
334-  \-...1....
335-  \-..111...
336-  \-.11111..
337-  \-1111111.
338-  \-.11111..
339-  \-..111...
340-  \-...1....;
341-
342-( 82 - comment )
343-  \-........
344-  \-..1111..
345-  \-.1....1.
346-  \-.1....1.
347-  \-.1....1.
348-  \-.1....1.
349-  \-..1111..
350-  \-........;
351-
352-( 83 - credit )
353-  \-........
354-  \-..1111..
355-  \-.1.1..1.
356-  \-.1..1.1.
357-  \-.1.1..1.
358-  \-.1..1.1.
359-  \-..1111..
360-  \-........;
361-
362-( 84 - link )
363-  \-........
364-  \-.1.1....
365-  \-..1.1...
366-  \-...1.1..
367-  \-.1111.1.
368-  \-...1.1..
369-  \-..1.1...
370-  \-.1.1....;
371-
372-( 85 - unknown type )
373-  \-........
374-  \-1111111.
375-  \-11...11.
376-  \-1.111.1.
377-  \-1111.11.
378-  \-111.111.
379-  \-1111111.
380-  \-111.111.;
381-
382-\\ Extra records (explained below)
383-@line-1 :line-1 00 00 00 -typ/subject &final ffff
384-@line0 0000 00 00 00 -typ/inner :lines
385-
386-@lines
387-  \\ List of lines of UHS file is stored in here.
388-  \\ (This area is also used for some things only used during initialization)
389-  \\ The format is:
390-  \\   Address of record for parent node (two bytes)
391-  \\   File offset (three bytes)
392-  \\   Item type (one byte)
393-  \\   Address of record for line following end of block (two bytes)
394-  \_@8+ \@line2
395-  \_@b+ \@line2z
396-  \_@8+b+ \@line3z
397-
398-@endof88a
399-  0a "** 20 "END 20 "OF 20 "88A 20 "FORMAT 20 "** 0d0a &end
400-
401-@notuhs
402-  error "Not 20 "a 20 "UHS 20 "file 0a
403-
404-@started
405-  #17 DEI [?
406-    error "usage: 20 "uhsview.rom 20 "<uhsfile> 0a
407-  ]@
408-  \\ Read file name
409-  LIT2r :filename DUP2r
410-  [; #10 DEO2 BRK ]@
411-  #17 DEI #02 GTH [? #12 DEI STH2rk INC2r STA BRK ]@
412-  \\ Finish with file name
413-  #00 DUPk STH2r STA #10 DEO2
414-  LITr a8 DEO2r
415-  \\ Check file existence and if it is UHS
416-  #ac DEI2
417-  #a3 DEI [? error "Cannot 20 "read 20 "file 0a ]@
418-  LIT2 "UH NEQ2 ?notuhs
419-  #ac DEI2 LIT2 "S 0d NEQ2 ?notuhs
420-  #ac DEI #0a NEQ ?notuhs
421-  \\ Find the "** END OF 88A FORMAT **"
422-  LIT2r :endof88a DUP2r
423-  [@
424-    #a3 DEI [?
425-      error "This 20 "program 20 "is 20 "not 20 "compatible 20 "with 20 "88a 20 "format 0a
426-    ]@
427-    #ac DEI STH2rk INC2r LDA EQU [? POP2r DUP2r ]@
428-    STH2rk ;endof88a/end NEQ2
429-  ]?
430-  POP2r POP2r
431-  \\ Device initialization
432-  #d0f0 #08 DEO2
433-  #d0f2 #0a DEO2
434-  #c0f1 #0c DEO2
435-  #0278 #22 DEO2
436-  #00c8 #24 DEO2
437-  #0126 DEO
438-  ;vkey #80 DEO2
439-  ;vmouse #90 DEO2
440-  #2224 [& ]@ DEI2k #03 SFT2 SWP #00 NEQ #ff MUL ORA SWP STZ JMP2r
441-
442-@filename
443-  \\ File name storage
444-
445-@typ |00
446-  &none $1
447-  &subject $1
448-  &hint $1
449-  &nesthint $1
450-  &comment $1
451-  &credit $1
452-  &link $1
453-  &blank $1
454-  &break $1
455-  &inner $1
456-  \:typ/subject \:typ/nesthint \_^ \@subxnest
457-
+0, -55
 1@@ -1,55 +0,0 @@
 2-\\ Extract files from a Hamster archive file.
 3-\\ (Public domain)
 4-
 5-|0100
 6-  LITr 00
 7-  [; #10 DEO2 BRK ]@
 8-
 9-  #12 DEI DUP #0a EQU [, JCN STHrk STZ INCr BRK ]@
10-
11-  #00 STHr STZ
12-  #0000 DUP2 #10 DEO2 #a8 DEO2
13-
14-@next-lump
15-  LITr 00
16-  [@
17-    #ac DEI
18-    #a3 DEI [, JCN #800f DEO ]@
19-    DUP #00 EQU ,end-name JCN
20-    DUP #18 DEO
21-    STHrk STZ INCr
22-  ], JMP
23-
24-@end-name
25-  STHr STZ
26-  #0a18 DEO
27-  #0000 #b8 DEO2
28-
29-\\ Lump data size
30-  #ac DEI2k ( Great )
31-  ROT DEI2 ( Small )
32-
33-\\ Small units
34-  DUP #80 LTH [, JCN
35-    #8000 ,copy JSR
36-    #7f AND
37-  ]@
38-  SWP ,copy JSR
39-
40-\\ Big units
41-  SWP
42-  ORAk #00 EQU [, JCN
43-    [@
44-      #8000 ,copy JSR
45-      #8000 ,copy JSR
46-      #0001 SUB2
47-    ORAk ], JCN
48-  ]@ POP2
49-
50-,next-lump JMP
51-
52-@copy
53-  DUP2 #aa DEO2 #ba DEO2
54-  #8000 DUP2 #ac DEO2 #be DEO2
55-  JMP2r
56-
+0, -119
  1@@ -1,119 +0,0 @@
  2-% Quick reference sheet for uxn/varvara.
  3-% (public domain)
  4-
  5-% Data
  6-/Data [
  7-  [() 0 (Exp) 0 (wst) (rst) (Meta) 0 (Red) 0 (Green) 0 (Blue) 0 (Debug) (Quit)] %00
  8-  [(Vector) 0 (In) () 0 0 0 (Type) (Out) (Err) () 0 0 0 0 0] %10
  9-  [(Vector) 0 (Width) 0 (Height) 0 (Auto) () (X) 0 (Y) 0 (Address) 0 (Pixel) (Sprit)] %20
 10-  [(Vector) 0 (Position) 0 (Out) () 0 0 (ADSR) 0 (Length) 0 (Address) 0 (Vol) (Note)] %30
 11-  dup %40
 12-  dup %50
 13-  dup %60
 14-  [16 {0} repeat] %70
 15-  [(Vector) 0 (P1) (Key) () 0 (P2) (P3) (P4) () 0 0 0 0 0 0 0] %80
 16-  [(Vector) 0 (MouseX) 0 (MouseY) 0 (Buttons) 0 () 0 (ScrollX) 0 (ScrollY) 0 () 0 0] %90
 17-  [() 0 (Success) 0 (Stat) 0 (Del) (Apend) (Name) 0 (Length) 0 (Read) 0 (Write) 0] %a0
 18-  dup %b0
 19-  [(Year) 0 (Month) (Day) (Hour) (Min) (Sec) (Wday) (Yday) 0 (DST) () 0 0 0 0] %c0
 20-  [16 {0} repeat] %d0
 21-  dup %e0
 22-  dup %f0
 23-] def
 24-/BitsData [
 25-  [(Count-1) 0 0 0 () (Addr) (Y) (X)  (Auto)]
 26-  [(Fill) (Fore) (Corner) 0 () 0 (Color) 0  (Pixel)]
 27-  [(2bpp) (Fore) (Vflip) (Hflip) (Color) 0 0 0  (Sprit)]
 28-  [(/Loop) (MIDI_Note) 0 0 0 0 0 0  (Note)]
 29-  [(Right) (Left) (Down) (Up) (Start) (Sel) (B) (A)  (P1)]
 30-] def
 31-
 32-% Page setup
 33-<< /PageSize [792 612] /UseFastColor true >> setpagedevice
 34-/Courier 14 selectfont
 35-.75 setlinewidth
 36-0 setgray
 37-
 38-% Draw devices
 39-0 1 15 {
 40-  /I exch def
 41-  % Columns
 42-  newpath 39 I 45 mul add 593 moveto
 43-  I 16 (?) cvrs show
 44-  % Rows
 45-  newpath 14 570 I 18 mul sub moveto
 46-  gsave
 47-    0 3 rmoveto I 16 (?) cvrs show
 48-  grestore
 49-  20 0 rmoveto
 50-  720 0 rlineto 0 18 rlineto -720 0 rlineto 0 -18 rlineto
 51-  stroke
 52-  0 1 15 {
 53-    /J exch def
 54-    /D Data I get J get def
 55-    newpath 34 J 45 mul add 570 I 18 mul sub moveto
 56-    D 0 eq {
 57-      0 2 rlineto 0 14 rmoveto 0 2 rlineto
 58-      stroke
 59-    } {
 60-      gsave
 61-        0 18 rlineto stroke
 62-      grestore
 63-      2 3 rmoveto D show
 64-    } ifelse
 65-  } for
 66-} bind for
 67-
 68-% Bits
 69-0 1 7 {
 70-  /I exch def
 71-  newpath 15 I 60 mul add 266 moveto
 72-  16#80 I neg bitshift 16 (??) cvrs dup length 1 eq {(0) show} if show
 73-} bind for
 74-newpath 14 264 moveto
 75-gsave 480 0 rlineto stroke grestore
 76-BitsData {
 77-  /D exch def
 78-  gsave
 79-    0 -18 rlineto 480 0 rlineto 0 18 rlineto stroke
 80-  grestore
 81-  0 -18 rmoveto
 82-  gsave
 83-    D {
 84-      gsave
 85-      dup 0 eq {
 86-        pop
 87-        0 2 rlineto 0 14 rmoveto 0 2 rlineto
 88-        stroke
 89-      } {
 90-        gsave 2 3 rmoveto show grestore
 91-        0 18 rlineto stroke
 92-      } ifelse
 93-      grestore
 94-      60 0 rmoveto
 95-    } forall
 96-  grestore
 97-} bind forall
 98-
 99-% Colours of sprites
100-newpath 622 282 moveto
101-[
102-  (Color)
103-  (0123456789ABCDEF)
104-  (-0001-1122-2333-)
105-  (0123012301230123)
106-  (1231123112311231)
107-  (2312231223122312)
108-] {0 -16 rmoveto gsave show grestore} forall
109-/I (0) stringwidth pop 16 mul 4 add def
110-  -2 -2 rmoveto
111-  I 0 rlineto
112-  0 96 rlineto
113-  I neg 0 rlineto
114-  0 -96 rlineto
115-  0 64 rmoveto
116-  I 0 rlineto
117-stroke
118-
119-% Done
120-showpage quit
+0, -152
  1@@ -1,152 +0,0 @@
  2-This document describes the Uxn virtual machine.
  3-
  4-
  5-=== Memory ===
  6-
  7-There is 64K of RAM, which stores both the program and data. (Devices use
  8-a separate memory; they are not stored in this RAM.)
  9-
 10-All numbers are big-endian unsigned, except where otherwise specified. All
 11-arithmetic will keep only the low 8-bits or low 16-bits of the result;
 12-there are no arithmetic overflow errors.
 13-
 14-
 15-=== Stacks ===
 16-
 17-There are two stacks, which are the data stack and return stack. Each
 18-stack stores 256 bytes of data, and is circular (so stack underflows and
 19-stack overflows are impossible).
 20-
 21-If a 16-bit value is in the stack, then the top will be the low 8-bits
 22-of that value and beneath that will be the high 8-bits of that value.
 23-
 24-
 25-=== Instruction encoding ===
 26-
 27-The low 5-bits are the opcode bits. The other bits are the mode bits:
 28-
 29-* bit5 = If set, then use 16-bit operands, if clear then 8-bit operands.
 30-
 31-* bit6 = If set, then operate on the return stack, but if clear then
 32-operate on the data stack. Some instructions use both stacks; in this
 33-case, this bit specifies which is the main stack to use, and the result
 34-is then stored in the other stack.
 35-
 36-* bit7 = If set, then the input operands are not removed from the stack.
 37-
 38-
 39-=== Instructions ===
 40-
 41-In the list below, entries with "8" means they are always 8-bits regardless
 42-of the instruction flags, and "16" means always 16-bits regardless of the
 43-instruction flags. If they are <> then it operates on the other stack. If
 44-marked ! then it is a branch address; if it is 16-bits then it is absolute
 45-but if 8-bits then it is a signed relative address.
 46-
 47-00 BRK ( -- )
 48-  Stops execution; all mode bits must be clear. Execution will continue
 49-  when a vector is called.
 50-01 INC ( old -- new )
 51-  Increment.
 52-02 POP ( x -- )
 53-  Stack operation.
 54-03 NIP ( x y -- y )
 55-  Stack operation.
 56-04 SWP ( x y -- y x )
 57-  Stack operation.
 58-05 ROT ( a b c -- b c a )
 59-  Stack operation.
 60-06 DUP ( a -- a a )
 61-  Stack operation.
 62-07 OVR ( a b -- a b a )
 63-  Stack operation.
 64-08 EQU ( a b -- bool8 )
 65-  Result is one if the inputs are equal or zero if unequal.
 66-09 NEQ ( a b -- bool8 )
 67-  Result is one if the inputs are unequal or zero if equal.
 68-0A GTH ( a b -- bool8 )
 69-  Result is one if (a) is greater than (b) or zero otherwise.
 70-0B LTH ( a b -- bool8 )
 71-  Result is one if (a) is less than (b) or zero otherwise.
 72-0C JMP ( addr! -- )
 73-  Unconditional jump.
 74-0D JCN ( cond8 addr! -- )
 75-  Jump if the condition is nonzero.
 76-0E JSR ( addr! -- <old_addr> )
 77-  Unconditional jump, but the address of the next instruction if it
 78-  would not jump is saved in the other stack.
 79-0F STH ( a -- <a> )
 80-  Moves a value between stacks.
 81-10 LDZ ( addr8 -- value )
 82-  Read from memory.
 83-11 STZ ( value addr8 -- )
 84-  Write to memory.
 85-12 LDR ( rel_addr8 -- value )
 86-  Read from memory given a signed relative address.
 87-13 STR ( value rel_addr8 -- )
 88-  Write to memory given a signed relative address.
 89-14 LDA ( addr16 -- value )
 90-  Read from memory. (Same as LDZ but using a 16-bit address.)
 91-15 STA ( value addr16 -- )
 92-  Write to memory. (Same as LDZ but using a 16-bit address.)
 93-16 DEI ( port8 -- value )
 94-  Read a value from a device. If it is a 16-bit read, then it reads the
 95-  specified port and also the next port. (See varvara.doc for an
 96-  explanation of what each port number means.)
 97-17 DEO ( value port8 -- )
 98-  Write a value to a device. If it is a 16-bit write, then it writes the
 99-  high octet to the specified port and then writes the low octet of the
100-  value to the next port.
101-18 ADD ( a b -- c )
102-  Addition (a+b).
103-19 SUB ( a b -- c )
104-  Subtraction (a-b).
105-1A MUL ( a b -- c )
106-  Multiplication.
107-1B DIV ( a b -- c )
108-  Division (a by b). If you try to divide by zero, then the result will be
109-  zero (in previous versions of this specification it was an error).
110-1C AND ( a b -- c )
111-  Bitwise AND.
112-1D ORA ( a b -- c )
113-  Bitwise OR.
114-1E EOR ( a b -- c )
115-  Bitwise XOR.
116-1F SFT ( a shift8 -- c )
117-  Bitwise shift. First shifts right by the number of bits indicated by the
118-  low nybble of the shift amount byte, and the shifts left by the number of
119-  bits indicated by the high nybble of the shift amount byte.
120-80 LIT ( -- x )
121-  This instruction must have the high (keep) bit set. It will push a
122-  following one-byte or two-byte number to the stack, which are skipped.
123-
124-A few instructions must have the exact opcode number and do not use the mode
125-bits in the usual way. With the exception of BRK, a 16-bit relative address
126-is read and skipped past. This relative address is relative to the PC
127-address immediately after, the two bytes giving the address, modulo 65536.
128-
129-00 BRK ( -- )
130-  Stops execution. Execution will continue when a vector is called.
131-20 JCI ( cond8 -- )
132-  If the value received from the stack is nonzero, jump to that relative
133-  address, otherwise continue from here.
134-40 JMI ( -- )
135-  Unconditionally jump to a relative address.
136-60 JSI ( -- <old_addr> )
137-  Unconditionally jump to a relative address, but also push the return
138-  address to the return stack.
139-
140-
141-=== Execution ===
142-
143-The contents of the program file are loaded starting at address 0x0100, and
144-then it starts executing from address 0x0100.
145-
146-After a BRK instruction is executed, then it will wait for the next event,
147-and start executing at the vector for that event, if it is nonzero. (If the
148-vector is zero, then that event is ignored.) Events will never interrupt
149-the program; if it is already running then it will wait until BRK before
150-the next event is processed.
151-
152-Stacks and memory are retained between events.
153-
D uxn.o
+0, -0
+0, -0
+0, -0
+0, -0
+0, -0
+0, -1054
   1@@ -1,1054 +0,0 @@
   2-#if 0
   3-gcc -s -O2 -o ./uxnasm uxnasm.c
   4-exit
   5-#endif
   6-
   7-#include <stdio.h>
   8-#include <string.h>
   9-#include <unistd.h>
  10-
  11-/*
  12-Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
  13-
  14-Permission to use, copy, modify, and distribute this software for any
  15-purpose with or without fee is hereby granted, provided that the above
  16-copyright notice and this permission notice appear in all copies.
  17-
  18-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  19-WITH REGARD TO THIS SOFTWARE.
  20-
  21-[This file has been modified from the original that the above copyright
  22-notice applies to. The same license conditions apply to the modified
  23-version, although the person who modified it is not the person who is
  24-named in the above copyright notice.]
  25-*/
  26-
  27-#define MAXLABELS 0x400
  28-#define MAXMACROS 0x100
  29-#define MAXREFS 0x800
  30-#define MAXEXPS 0x80
  31-#define MAXITEMS 0x40
  32-
  33-#define TRIM 0x0100
  34-#define LENGTH 0x10000
  35-
  36-typedef unsigned char Uint8;
  37-typedef signed char Sint8;
  38-typedef unsigned short Uint16;
  39-typedef unsigned int Uint32;
  40-
  41-typedef struct {
  42-	char name[0x40], items[MAXITEMS][0x40];
  43-	Uint8 len;
  44-} Macro;
  45-
  46-typedef struct {
  47-	char name[0x40];
  48-	Uint16 addr, refs;
  49-} Label;
  50-
  51-typedef struct {
  52-	char name[0x40], rune;
  53-	Uint16 addr;
  54-} Reference;
  55-
  56-typedef struct {
  57-	char name[0x40];
  58-	Uint32 offset,len;
  59-	Uint8 kind;
  60-} ExpItem;
  61-
  62-typedef struct {
  63-	Uint8 data[LENGTH];
  64-	Uint8 lambda_stack[256], lambda_ptr, lambda_count;
  65-	unsigned int ptr, length;
  66-	Uint16 llen, mlen, rlen, xlen;
  67-	Label labels[MAXLABELS];
  68-	Macro macros[MAXMACROS];
  69-	Reference refs[MAXREFS];
  70-	ExpItem exps[MAXEXPS];
  71-	char scope[0x40];
  72-	char lambda[0x10];
  73-	Uint32 total;
  74-} Program;
  75-
  76-static Program p;
  77-static char line_comment;
  78-static int ssptr;
  79-static Uint16 sstack[256];
  80-static int bsptr,bcnt;
  81-static Uint16 bstack[256];
  82-static char spec_rune[128];
  83-static Uint16 exstart;
  84-static FILE*subas;
  85-static Uint8 exchstack;
  86-
  87-static Uint8 fontkeep[LENGTH/8];
  88-static Uint8 fontmap[256];
  89-static Uint8 fontdone,fontbloc;
  90-
  91-/* clang-format off */
  92-
  93-static char ops[][4] = {
  94-	"LIT", "INC", "POP", "NIP", "SWP", "ROT", "DUP", "OVR",
  95-	"EQU", "NEQ", "GTH", "LTH", "JMP", "JCN", "JSR", "STH",
  96-	"LDZ", "STZ", "LDR", "STR", "LDA", "STA", "DEI", "DEO",
  97-	"ADD", "SUB", "MUL", "DIV", "AND", "ORA", "EOR", "SFT"
  98-};
  99-
 100-static int   scmp(char *a, char *b, int len) { int i = 0; while(a[i] == b[i]) if(!a[i] || ++i >= len) return 1; return 0; } /* string compare */
 101-static int   sihx(char *s) { int i = 0; char c; while((c = s[i++])) if(!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f')) return 0; return i > 1; } /* string is hexadecimal */
 102-static int   shex(char *s) { int n = 0, i = 0; char c; while((c = s[i++])) if(c >= '0' && c <= '9') n = n * 16 + (c - '0'); else if(c >= 'a' && c <= 'f') n = n * 16 + 10 + (c - 'a'); return n; } /* string to num */
 103-static int   slen(char *s) { int i = 0; while(s[i]) i++; return i; } /* string length */
 104-static int   spos(char *s, char c) { Uint8 i = 0, j; while((j = s[i++])) if(j == c) return i; return -1; } /* character position */
 105-static char *scpy(char *src, char *dst, int len) { int i = 0; while((dst[i] = src[i]) && i < len - 2) i++; dst[i + 1] = '\0'; return dst; } /* string copy */
 106-static char *scat(char *dst, const char *src) { char *ptr = dst + slen(dst); while(*src) *ptr++ = *src++; *ptr = '\0'; return dst; } /* string cat */
 107-
 108-/* clang-format on */
 109-
 110-static int parse(char *w, FILE *f);
 111-
 112-static int
 113-error(const char *name, const char *msg)
 114-{
 115-	fprintf(stderr, "%s: %s\n", name, msg);
 116-	return 0;
 117-}
 118-
 119-static char *
 120-sublabel(char *src, char *scope, char *name)
 121-{
 122-	return scat(scat(scpy(scope, src, 0x40), "/"), name);
 123-}
 124-
 125-static Macro *
 126-findmacro(char *name)
 127-{
 128-	int i;
 129-	for(i = 0; i < p.mlen; i++)
 130-		if(scmp(p.macros[i].name, name, 0x40))
 131-			return &p.macros[i];
 132-	return NULL;
 133-}
 134-
 135-static Label *
 136-findlabel(char *name)
 137-{
 138-	int i;
 139-	char x[0x80];
 140-	if(*name=='/') {
 141-	  snprintf(x,0x80,"%s%s",p.scope,name);
 142-	  name=x;
 143-	}
 144-	for(i = 0; i < p.llen; i++)
 145-		if(scmp(p.labels[i].name, name, 0x40))
 146-			return &p.labels[i];
 147-	return NULL;
 148-}
 149-
 150-static Uint8
 151-findopcode(char *s)
 152-{
 153-	int i;
 154-	for(i = 0; i < 0x20; i++) {
 155-		int m = 0;
 156-		if(!scmp(ops[i], s, 3))
 157-			continue;
 158-		if(!i) i |= (1 << 7); /* force keep for LIT */
 159-		while(s[3 + m]) {
 160-			if(s[3 + m] == '2')
 161-				i |= (1 << 5); /* mode: short */
 162-			else if(s[3 + m] == 'r')
 163-				i |= (1 << 6); /* mode: return */
 164-			else if(s[3 + m] == 'k')
 165-				i |= (1 << 7); /* mode: keep */
 166-			else
 167-				return 0; /* failed to match */
 168-			m++;
 169-		}
 170-		return i^exchstack;
 171-	}
 172-	return 0;
 173-}
 174-
 175-static int
 176-makemacro(char *name, FILE *f)
 177-{
 178-	Macro *m;
 179-	char word[0x40];
 180-	if(findmacro(name))
 181-		return error("Macro duplicate", name);
 182-	if(sihx(name) && slen(name) % 2 == 0)
 183-		return error("Macro name is hex number", name);
 184-	if(findopcode(name) || scmp(name, "BRK", 4) || !slen(name))
 185-		return error("Macro name is invalid", name);
 186-	if(p.mlen == MAXMACROS)
 187-		return error("Macros limit exceeded", name);
 188-	m = &p.macros[p.mlen++];
 189-	scpy(name, m->name, 0x40);
 190-	while(fscanf(f, "%63s", word) == 1) {
 191-		if(word[0] == '{') continue;
 192-		if(word[0] == '}') break;
 193-		if(word[0] == '%' || line_comment)
 194-			return error("Macro error", name);
 195-		if(m->len >= MAXITEMS)
 196-			return error("Macro size exceeded", name);
 197-		scpy(word, m->items[m->len++], 0x40);
 198-	}
 199-	return 1;
 200-}
 201-
 202-static int
 203-makelabel(char *name)
 204-{
 205-	Label *l;
 206-	if(findlabel(name))
 207-		return error("Label duplicate", name);
 208-	if(sihx(name) && (slen(name) == 2 || slen(name) == 4))
 209-		return error("Label name is hex number", name);
 210-	if(findopcode(name) || scmp(name, "BRK", 4) || !slen(name))
 211-		return error("Label name is invalid", name);
 212-	if(p.llen == MAXLABELS)
 213-		return error("Labels limit exceeded", name);
 214-	l = &p.labels[p.llen++];
 215-	l->addr = p.ptr;
 216-	l->refs = 0;
 217-	scpy(name, l->name, 0x40);
 218-	return 1;
 219-}
 220-
 221-static char*makelambda(int id) {
 222-	scpy("lambda", p.lambda, 7);
 223-	p.lambda[6] = '0' + (id >> 0x4);
 224-	p.lambda[7] = '0' + (id & 0xf);
 225-	return p.lambda;
 226-}
 227-
 228-static int
 229-makereference(char *scope, char *label, Uint16 addr)
 230-{
 231-	char subw[0x40], parent[0x40];
 232-	Reference *r;
 233-	if(p.rlen == MAXREFS)
 234-		return error("References limit exceeded", label);
 235-	r = &p.refs[p.rlen++];
 236-	if((label[1] == '&' || label[1] == '/') && scope) {
 237-		scpy(sublabel(subw, scope, label + 2), r->name, 0x40);
 238-	} else if(label[1] == '{') {
 239-		if(p.lambda_ptr==256) return error("Lambda stack overflow", label);
 240-		p.lambda_stack[p.lambda_ptr++] = p.lambda_count;
 241-		scpy(makelambda(p.lambda_count++), r->name, 0x40);
 242-	} else {
 243-		int pos = spos(label + 1, '/');
 244-		if(pos > 0) {
 245-			Label *l;
 246-			if((l = findlabel(scpy(label + 1, parent, pos))))
 247-				l->refs++;
 248-		}
 249-		scpy(label + 1, r->name, 0x40);
 250-	}
 251-	r->rune = label[0];
 252-	r->addr = addr;
 253-	return 1;
 254-}
 255-
 256-static int makeexp(Uint8 kind,char*name,Uint32 len,Uint8 misc) {
 257-  ExpItem*e;
 258-  if(p.xlen==MAXEXPS) return error("Expansion limit exceeded","");
 259-  e=p.exps+(p.xlen++);
 260-  if(name) scpy(name,e->name,0x40); else e->name[0]=misc,e->name[1]=0;
 261-  e->kind=kind;
 262-  e->len=len;
 263-  return 1;
 264-}
 265-
 266-static int
 267-writebyte(Uint8 b)
 268-{
 269-	if(p.ptr < TRIM)
 270-		return error("Writing in zero-page", "");
 271-	else if(p.ptr > 0xffff)
 272-		return error("Writing after the end of RAM", "");
 273-	else if(p.ptr < p.length)
 274-		return error("Memory overwrite", "");
 275-	p.data[p.ptr++] = b;
 276-	p.length = p.ptr;
 277-	return 1;
 278-}
 279-
 280-static inline int
 281-writebyte1(Uint8 b)
 282-{
 283-	if(p.ptr > 0xffff)
 284-		return error("Writing after the end of RAM", "");
 285-	if(fontbloc) fontkeep[p.ptr>>3]|=1<<(p.ptr&7);
 286-	return writebyte(b);
 287-}
 288-
 289-static int
 290-writeopcode(char *w)
 291-{
 292-	Uint8 res;
 293-	res = writebyte(findopcode(w));
 294-	return res;
 295-}
 296-
 297-static int
 298-writeshort(Uint16 s, int lit)
 299-{
 300-	if(lit)
 301-		if(!writebyte(findopcode("LIT2"))) return 0;
 302-	return writebyte(s >> 8) && writebyte(s & 0xff);
 303-}
 304-
 305-static inline int
 306-writeshort1(Uint16 s, int lit)
 307-{
 308-	if(lit)
 309-		if(!writebyte(findopcode("LIT2"))) return 0;
 310-	return writebyte1(s >> 8) && writebyte1(s & 0xff);
 311-}
 312-
 313-static int
 314-writelitbyte(Uint8 b)
 315-{
 316-	if(!writebyte(findopcode("LIT"))) return 0;
 317-	if(!writebyte(b)) return 0;
 318-	return 1;
 319-}
 320-
 321-static int
 322-writelitbyte1(Uint8 b)
 323-{
 324-	if(!writebyte(findopcode("LIT"))) return 0;
 325-	if(!writebyte1(b)) return 0;
 326-	return 1;
 327-}
 328-
 329-static int
 330-doinclude(const char *filename)
 331-{
 332-	FILE *f;
 333-	char w[0x40];
 334-	int c;
 335-	if(!(f = fopen(filename, "r")))
 336-		return error("Include missing", filename);
 337-	while(fscanf(f, "%63s", w) == 1) {
 338-		if(!parse(w, f))
 339-			return error("Unknown token", w);
 340-		if(line_comment) {
 341-		  while((c=fgetc(f))>0 && c!='\n');
 342-		  line_comment=0;
 343-		}
 344-	}
 345-	fclose(f);
 346-	line_comment=0;
 347-	return 1;
 348-}
 349-
 350-static int doinclude_binary(const char*filename) {
 351-  FILE*f;
 352-  int c;
 353-  if(!(f = fopen(filename, "r"))) return error("Include missing", filename);
 354-  while((c=fgetc(f))!=EOF) writebyte1(c);
 355-  fclose(f);
 356-  return 1;
 357-}
 358-
 359-static int doinclude_font(const char*filename,int first) {
 360-  FILE*f;
 361-  int i,j,m;
 362-  if(fontdone) return error("Cannot include multiple fonts",filename);
 363-  if(p.ptr < p.length) return error("Memory overwrite", "");
 364-  if(p.ptr>63486) return error("Not enough space for font",filename);
 365-  if(!(f = fopen(filename, "r"))) return error("Include missing", filename);
 366-  m=fread(p.data+p.ptr,8,256,f);
 367-  fclose(f);
 368-  for(i=0;i<256;i++) fontmap[i]=i;
 369-  for(i=0;i<first;i++) fontkeep[i>>3]|=1<<(i&7);
 370-  for(i=TRIM;i<p.length && i<LENGTH;i++) if(fontkeep[i>>3]&(1<<(i&7))) {
 371-    j=p.data[i];
 372-    fontkeep[j>>3]|=1<<(j&7);
 373-  }
 374-  for(i=first;i<first+m && i<256;i++) {
 375-    if(fontkeep[i>>3]&(1<<(i&7))) {
 376-      p.ptr+=8; p.length=p.ptr;
 377-    } else {
 378-      for(j=i;j<256;j++) fontmap[j]--;
 379-      memmove(p.data+p.ptr,p.data+p.ptr+8,(first+m-i)<<3);
 380-    }
 381-  }
 382-  fontdone=1;
 383-  return 1;
 384-}
 385-
 386-static int special_calc(const char*w) {
 387-  const char*loop=w;
 388-  Uint16 a,b;
 389-  while(*w) switch(*w++) {
 390-    case '_': loop=w+1; break;
 391-    case '0' ... '9': if(ssptr>255) return 0; sstack[ssptr++]=w[-1]-'0'; break;
 392-    case 'a' ... 'f': if(ssptr>255) return 0; sstack[ssptr++]=w[-1]+10-'a'; break;
 393-    case '\'': if(ssptr<2) return 0; a=sstack[--ssptr]; a+=sstack[--ssptr]<<4; sstack[ssptr++]=a; break;
 394-    case '\"': if(ssptr<4) return 0; a=sstack[--ssptr]; a+=sstack[--ssptr]<<4; a+=sstack[--ssptr]<<8; a+=sstack[--ssptr]<<12; sstack[ssptr++]=a; break;
 395-    case '!': if(ssptr<1) return 0; p.ptr=sstack[--ssptr]; break;
 396-    case '@': if(ssptr>255) return 0; sstack[ssptr++]=p.ptr; break;
 397-    case '#': if(ssptr<1) return 0; p.length=sstack[--ssptr]; break;
 398-    case '$': if(ssptr>255) return 0; sstack[ssptr++]=p.length; break;
 399-    case '+': if(ssptr<2) return 0; b=sstack[--ssptr]; a=sstack[--ssptr]; sstack[ssptr++]=a+b; break;
 400-    case '-': if(ssptr<2) return 0; b=sstack[--ssptr]; a=sstack[--ssptr]; sstack[ssptr++]=a-b; break;
 401-    case '*': if(ssptr<2) return 0; b=sstack[--ssptr]; a=sstack[--ssptr]; sstack[ssptr++]=a*b; break;
 402-    case '/': if(ssptr<2) return 0; b=sstack[--ssptr]; a=sstack[--ssptr]; if(!b) return 0; sstack[ssptr++]=a/b; break;
 403-    case '%': if(ssptr<2) return 0; b=sstack[--ssptr]; a=sstack[--ssptr]; if(!b) return 0; sstack[ssptr++]=a%b; break;
 404-    case '&': if(ssptr<2) return 0; b=sstack[--ssptr]; a=sstack[--ssptr]; sstack[ssptr++]=a&b; break;
 405-    case '|': if(ssptr<2) return 0; b=sstack[--ssptr]; a=sstack[--ssptr]; sstack[ssptr++]=a|b; break;
 406-    case '^': if(ssptr<2) return 0; b=sstack[--ssptr]; a=sstack[--ssptr]; sstack[ssptr++]=a^b; break;
 407-    case '<': if(ssptr<2) return 0; b=sstack[--ssptr]; a=sstack[--ssptr]; sstack[ssptr++]=(b&~15?0:a<<b); break;
 408-    case '>': if(ssptr<2) return 0; b=sstack[--ssptr]; a=sstack[--ssptr]; sstack[ssptr++]=(b&~15?0:a>>b); break;
 409-    case ':': if(ssptr<1 || ssptr>255) return 0; a=sstack[ssptr-1]; sstack[ssptr++]=a; break;
 410-    case ',': if(ssptr<2) return 0; b=sstack[--ssptr]; a=sstack[--ssptr]; sstack[ssptr++]=b; sstack[ssptr++]=a; break;
 411-    case '.': if(ssptr<1) return 0; --ssptr; break;
 412-    case 'D': fprintf(stderr,"Depth #%x\n",ssptr); if(ssptr) fprintf(stderr,"Debug #%x\n",sstack[ssptr-1]); break;
 413-    case 'E': if(ssptr) fprintf(stderr,"User error #%x\n",sstack[ssptr-1]); return 0;
 414-    case 'g': if(ssptr<1) return 0; a=sstack[--ssptr]; sstack[ssptr++]=p.data[a]; break;
 415-    case 'G': if(ssptr<1) return 0; a=sstack[--ssptr]; if(a==0xFFFF) return 0; sstack[ssptr++]=(p.data[a]<<8)|p.data[a+1]; break;
 416-    case 'k': if(ssptr<1) return 0; if(--sstack[ssptr-1]) w=loop; else --ssptr; break;
 417-    case 'L': if(ssptr<1) return 0; if(sstack[--ssptr]) w=loop; break;
 418-    case 'o': if(ssptr<1) return 0; if(sstack[ssptr-1]--) w=loop; else --ssptr; break;
 419-    case 'p': if(ssptr<2) return 0; a=sstack[--ssptr]; b=sstack[--ssptr]; p.data[a]=b; break;
 420-    case 'P': if(ssptr<2) return 0; a=sstack[--ssptr]; b=sstack[--ssptr]; if(a==0xFFFF) return 0; p.data[a]=b>>8; p.data[a+1]=b&255; break;
 421-    case 'w': if(ssptr<1) return 0; a=sstack[--ssptr]; writebyte(a); break;
 422-    case 'W': if(ssptr<1) return 0; a=sstack[--ssptr]; writeshort(a,0); break;
 423-    case 'x': if(ssptr<1) return 0; a=sstack[--ssptr]; if(!makeexp(0,0,a,0)) return 0; break;
 424-    case '(': if(ssptr<1) return 0; if(!sstack[--ssptr]) break; while(*w && *w!=')') w++; break;
 425-    case ')': /* do nothing */ break;
 426-    case '[': if(ssptr<1) return 0; if(sstack[--ssptr]) break; while(*w && *w!=']') w++; break;
 427-    case ']': /* do nothing */ break;
 428-    default: fprintf(stderr,"Unrecognized special calculation command: %c\n",w[-1]); return 0;
 429-  }
 430-  return 1;
 431-}
 432-
 433-static int make_tile(int h,const char*w) {
 434-  int i,c,v0,v1;
 435-  v0=v1=0;
 436-  for(i=0;i<8;i++) {
 437-    switch(w[i]) {
 438-      case '0': case '.': c=0; break;
 439-      case '1': case '#': c=1; break;
 440-      case '2': case 'X': c=2; break;
 441-      case '3': case '*': c=3; break;
 442-      default: return 0;
 443-    }
 444-    if(c>1 && !h) return 0;
 445-    if(c&1) v0|=0x80>>i;
 446-    if(c&2) v1|=0x80>>i;
 447-  }
 448-  if(p.ptr>0xFFF7) return error("Writing after the end of RAM","");
 449-  p.data[p.ptr]=v0;
 450-  if(h) p.data[p.ptr+8]=v1;
 451-  p.ptr++;
 452-  if(w[8]==';') {
 453-    if(h) p.ptr+=8;
 454-  } else if(w[8]) {
 455-    return 0;
 456-  }
 457-  if(p.length<p.ptr) p.length=p.ptr;
 458-  return 1;
 459-}
 460-
 461-static int exp_file(char*w) {
 462-  FILE*f=fopen(w,"rb");
 463-  if(!f) return error("Cannot open file",w);
 464-  fseek(f,0,SEEK_END);
 465-  if(!makeexp(2,w,ftell(f),0)) return 0;
 466-  fclose(f);
 467-  return 1;
 468-}
 469-
 470-static int
 471-parse(char *w, FILE *f)
 472-{
 473-	int i;
 474-	char word[0x40], subw[0x40], c;
 475-	Macro *m;
 476-	Label*l;
 477-	if(slen(w) >= 63)
 478-		return error("Invalid token", w);
 479-	if(spec_rune[*w]) goto defa;
 480-	switch(w[0]) {
 481-	case '(': /* comment */
 482-		i = 1; /* track nested comment depth */
 483-		while(fscanf(f, "%63s", word) == 1) {
 484-			if(slen(word) != 1)
 485-				continue;
 486-			else if(word[0] == '(')
 487-				i++;
 488-			else if(word[0] == ')' && --i < 1)
 489-				break;
 490-		}
 491-		break;
 492-	case '~': /* include */
 493-		if(!doinclude(w + 1))
 494-			return error("Invalid include", w);
 495-		break;
 496-	case '%': /* macro */
 497-		spec_rune[w[1]&127]=1;
 498-		if(!makemacro(w + 1, f))
 499-			return error("Invalid macro", w);
 500-		break;
 501-	case '|': /* pad-absolute */
 502-		if(sihx(w + 1))
 503-			p.ptr = shex(w + 1);
 504-		else if(w[1] == '&') {
 505-			if(!sublabel(subw, p.scope, w + 2) || !(l = findlabel(subw)))
 506-				return error("Invalid padding", w);
 507-			p.ptr = l->addr;
 508-		} else {
 509-			if(!(l = findlabel(w + 1)))
 510-				return error("Invalid padding", w);
 511-			p.ptr = l->addr;
 512-		}
 513-		break;
 514-	case '$': /* pad-relative */
 515-		if(sihx(w + 1))
 516-			p.ptr += shex(w + 1);
 517-		else if(w[1] == '&') {
 518-			if(!sublabel(subw, p.scope, w + 2) || !(l = findlabel(subw)))
 519-				return error("Invalid padding", w);
 520-			p.ptr += l->addr;
 521-		} else {
 522-			if(!(l = findlabel(w + 1)))
 523-				return error("Invalid padding", w);
 524-			p.ptr += l->addr;
 525-		}
 526-		break;
 527-	case '@': /* label */
 528-		if(w[1]=='\\') break;
 529-		if(!makelabel(w + 1))
 530-			return error("Invalid label", w);
 531-		scpy(w + 1, p.scope, 0x40);
 532-		for(i=0;p.scope[i];i++) if(p.scope[i]=='/') p.scope[i]=0;
 533-		break;
 534-	case '&': /* sublabel */
 535-		if(!makelabel(sublabel(subw, p.scope, w + 1)))
 536-			return error("Invalid sublabel", w);
 537-		break;
 538-	case '#': /* literals hex */
 539-		if(!sihx(w + 1) || (slen(w) != 3 && slen(w) != 5))
 540-			return error("Invalid hex literal", w);
 541-		if(slen(w) == 3) {
 542-			if(!writelitbyte1(shex(w + 1))) return 0;
 543-		} else if(slen(w) == 5) {
 544-			if(!writeshort1(shex(w + 1), 1)) return 0;
 545-		}
 546-		break;
 547-	case '.': /* literal byte zero-page */
 548-		makereference(p.scope, w, p.ptr);
 549-		if(!writelitbyte(0xff)) return 0;
 550-		break;
 551-	case ',': /* literal byte relative */
 552-		makereference(p.scope, w, p.ptr);
 553-		if(!writelitbyte(0xff)) return 0;
 554-		break;
 555-	case ';': /* literal short absolute */
 556-		makereference(p.scope, w, p.ptr);
 557-		if(!writeshort(0xffff, 1)) return 0;
 558-		break;
 559-	case ':': case '=': /* raw short absolute */
 560-		makereference(p.scope, w, p.ptr);
 561-		if(!writeshort(0xffff, 0)) return 0;
 562-		break;
 563-	case '-': /* raw byte zero-page */
 564-		makereference(p.scope, w, p.ptr);
 565-		if(!writebyte(0xff)) return 0;
 566-		break;
 567-	case '_': /* raw byte relative */
 568-		makereference(p.scope, w, p.ptr);
 569-		if(!writebyte(0xff)) return 0;
 570-		break;
 571-	case '"': /* raw string */
 572-		i = 0;
 573-		while((c = w[++i]))
 574-			if(!writebyte1(c)) return 0;
 575-		break;
 576-	case '?': /* JCI */
 577-		if(exchstack) return error("Cannot use JCI with \\r", w);
 578-		makereference(p.scope, w, p.ptr + 1);
 579-		return writebyte(0x20) && writeshort(0xffff, 0);
 580-	case '!': /* JMI */
 581-		makereference(p.scope, w, p.ptr + 1);
 582-		return writebyte(0x40) && writeshort(0xffff, 0);
 583-	case '\\': /* specials */
 584-		switch(w[1]) {
 585-		  case '\\': line_comment=1; break;
 586-		  case '~': if(!doinclude_binary(w+2)) return error("Invalid include",w); break;
 587-		  case '.': case ',': makereference(p.scope,w+1,p.ptr-1); if(!writebyte(0xff)) return 0; break;
 588-		  case ':': spec_ref:
 589-		    if(!(l=findlabel(w+2))) return error("Invalid reference",w);
 590-		    if(ssptr==256) return error("Stack overflow",w);
 591-		    sstack[ssptr++]=l->addr;
 592-		    break;
 593-		  case '0' ... '9': case 'a' ... 'f':
 594-		    if(!sihx(w+1)) return error("Invalid hex literal",w);
 595-		    if(ssptr==256) return error("Stack overflow",w);
 596-		    sstack[ssptr++]=shex(w+1);
 597-		    break;
 598-		  case '@':
 599-		    if(!ssptr) return error("Stack underflow",w);
 600-		    i=p.ptr;
 601-		    p.ptr=sstack[--ssptr];
 602-		    if(!makelabel(w+2)) return error("Invalid label",w);
 603-		    p.ptr=i;
 604-		    break;
 605-		  case '_': if(!special_calc(w+2)) return error("Special calculation error",w); break;
 606-		  case '-': case '=': if(!make_tile(w[1]=='=',w+2)) return error("Tile error",w); break;
 607-		  case '`': makereference(0,w+1,p.ptr); break;
 608-		  case '*': if(!makeexp('*',w+2,0,0)) return 0; break;
 609-		  case 'A': case 'C': case 'D':
 610-		    if(!sihx(w+1)) return error("Invalid hex literal",w);
 611-		    if(!makeexp(w[1],w+2,shex(w+2),0)) return 0;
 612-		    break;
 613-		  case 'B': case 'E': case 'F':
 614-		    if(w[2]>='0' && w[2]<='9') i=w[2]-'0';
 615-		    else if(w[2]>='a' && w[2]<='u') i=w[2]+10-'a';
 616-		    else return error("Invalid expanded memory alignment",w);
 617-		    if(!makeexp(w[1],0,0,i)) return 0;
 618-		    break;
 619-		  case '^':
 620-		    if(!exp_file(w+2)) return 0;
 621-		    break;
 622-		  case '+': w[1]='x'; makereference(0,w+1,1); break;
 623-		  case 'm':
 624-		    if(fontdone) return error("Cannot use \\m multiple times",w);
 625-		    if(w[2]=='k') {
 626-		      if(!sihx(w+3)) return error("Invalid special",w);
 627-		      if(slen(w+3)==2) {
 628-		        i=shex(w+3)&255;
 629-		        fontkeep[i>>3]|=1<<(i&7);
 630-		      } else if(slen(w+3)==4) {
 631-		        int j;
 632-		        i=shex(w+3)&0xFFFF; j=i&255; i>>=8;
 633-		        for(;i<=j;i++) fontkeep[i>>3]|=1<<(i&7);
 634-		      } else {
 635-		        return error("Invalid special",w);
 636-		      }
 637-		    } else {
 638-		      for(i=2;w[i] && w[i]!='~';i++);
 639-		      if(w[i]!='~') return error("Invalid special",w);
 640-		      w[i]=0;
 641-		      if(ssptr==256) return error("Stack overflow",w);
 642-	 	      if(!sihx(w+2)) return error("Invalid hex literal",w);
 643-		      sstack[ssptr++]=p.ptr-(shex(w+2)<<3);
 644-		      if(!doinclude_font(w+i+1,shex(w+2))) return 0;
 645-		    }
 646-		    break;
 647-		  case 'r': exchstack^=0x40; break;
 648-		  default: return error("Invalid special",w);
 649-		}
 650-		break;
 651-	case '^': /* sub-assembly */
 652-		if(!makeexp('^',w+1,0,0)) return 0;
 653-		p.exps[p.xlen-1].len=p.ptr;
 654-		break;
 655-	case '}': /* lambda end */
 656-		if(!p.lambda_ptr) return error("Lambda stack underflow", w);
 657-		if(!makelabel(makelambda(p.lambda_stack[--p.lambda_ptr]))) return error("Invalid label", w);
 658-		break;
 659-	case '[':
 660-	case ']':
 661-		if(slen(w) == 1) break;
 662-		if((w[1]=='.' || w[1]==',' || w[1]==':' || w[1]==';' || w[1]=='@' || w[1]=='\\' || w[1]=='?' || w[1]=='!' || w[1]=='&') && !w[2]) {
 663-		  if(*w=='[') {
 664-		    if(bsptr==256) return error("Stack overflow",w);
 665-		    bstack[bsptr++]=i=bcnt++;
 666-		  } else if(*w==']') {
 667-		    if(!bsptr) return error("Stack underflow",w);
 668-		    i=bstack[--bsptr];
 669-		  }
 670-		  snprintf(w+2,10,"\\%x\\",i);
 671-		  switch(w[1]) {
 672-		    case '@': if(!makelabel(w+2)) return error("Invalid label",w); break;
 673-		    case '\\': goto spec_ref;
 674-		    case '&': w[1]='!'; makereference(p.scope,w+1,p.ptr+1); return writebyte(0x60) && writeshort(0xffff, 0);
 675-		    default: return parse(w+1,f);
 676-		  }
 677-		  break;
 678-		} else if(w[1]=='[' && w[0]==']' && !w[2]) {
 679-		  if(!bsptr) return error("Stack underflow",w);
 680-		  i=bstack[bsptr-1];
 681-		  bstack[bsptr-1]=bcnt++;
 682-		  snprintf(w,10,"!\\%x\\",bstack[bsptr-1]);
 683-		  if(!parse(w,f)) return 0;
 684-		  snprintf(w,10,"\\%x\\",i);
 685-		  if(!makelabel(w)) return error("Invalid label",w);
 686-		  break;
 687-		} else if(w[1]=='^' && !w[2]) {
 688-		  if(*w=='[') {
 689-		    exstart=p.ptr;
 690-		  } else {
 691-		    if(p.ptr<exstart || p.ptr-exstart>0x40) return error("Too long inline expanded memory data",w);
 692-		    if(!makeexp(1,0,p.ptr-exstart,0)) return 0;
 693-		    memcpy(p.exps[p.xlen-1].name,p.data+exstart,p.ptr-exstart);
 694-		    p.ptr=p.length=exstart;
 695-		  }
 696-		  break;
 697-		} else if(w[1]=='\'' && !w[2]) {
 698-		  if((w[0]=='[')==fontbloc) return error("Misuse of [' or ]'",w);
 699-		  fontbloc=(w[0]=='[');
 700-		  break;
 701-		}
 702-		/* fall through */
 703-	default: defa:
 704-		/* opcode */
 705-		if(findopcode(w) || scmp(w, "BRK", 4)) {
 706-			if(!writeopcode(w)) return 0;
 707-		}
 708-		/* raw byte */
 709-		else if(sihx(w) && slen(w) == 2) {
 710-			if(!writebyte1(shex(w))) return 0;
 711-		}
 712-		/* raw short */
 713-		else if(sihx(w) && slen(w) == 4) {
 714-			if(!writeshort1(shex(w), 0)) return 0;
 715-		}
 716-		/* macro */
 717-		else if((m = findmacro(w))) {
 718-			for(i = 0; i < m->len; i++)
 719-				if(!parse(m->items[i], f))
 720-					return 0;
 721-			line_comment=0;
 722-			return 1;
 723-		} else {
 724-			if(exchstack) return error("Cannot use JSI with \\r", w);
 725-			*word='!';
 726-			scpy(w,word+1,62);
 727-			makereference(p.scope, word, p.ptr + 1);
 728-			return writebyte(0x60) && writeshort(0xffff, 0);
 729-			// return error("Unknown token", w);
 730-		}
 731-	}
 732-	return 1;
 733-}
 734-
 735-static int
 736-resolve(void)
 737-{
 738-	Label *l;
 739-	int i,a;
 740-	for(i = 0; i < p.rlen; i++) {
 741-		Reference *r = &p.refs[i];
 742-		switch(r->rune) {
 743-		case '_':
 744-			if(!(l = findlabel(r->name)))
 745-				return error("Unknown relative reference", r->name);
 746-			p.data[r->addr] = (Sint8)(l->addr - r->addr - 2);
 747-			if((Sint8)p.data[r->addr] != (l->addr - r->addr - 2))
 748-				return error("Relative reference is too far", r->name);
 749-			l->refs++;
 750-			break;
 751-		case '.':
 752-			if(!(l = findlabel(r->name)))
 753-				return error("Unknown zero-page reference", r->name);
 754-			p.data[r->addr + 1] = l->addr & 0xff;
 755-			l->refs++;
 756-			break;
 757-		case ',':
 758-			if(!(l = findlabel(r->name)))
 759-				return error("Unknown relative reference", r->name);
 760-			p.data[r->addr + 1] = (Sint8)(l->addr - r->addr - 3);
 761-			if((Sint8)p.data[r->addr + 1] != (l->addr - r->addr - 3))
 762-				return error("Relative reference is too far", r->name);
 763-			l->refs++;
 764-			break;
 765-		case '-':
 766-			if(!(l = findlabel(r->name)))
 767-				return error("Unknown absolute reference", r->name);
 768-			p.data[r->addr] = l->addr & 0xff;
 769-			l->refs++;
 770-			break;
 771-		case ';':
 772-			if(!(l = findlabel(r->name)))
 773-				return error("Unknown absolute reference", r->name);
 774-			p.data[r->addr + 1] = l->addr >> 0x8;
 775-			p.data[r->addr + 2] = l->addr & 0xff;
 776-			l->refs++;
 777-			break;
 778-		case ':': case '=':
 779-			if(!(l = findlabel(r->name)))
 780-				return error("Unknown absolute reference", r->name);
 781-			p.data[r->addr + 0] = l->addr >> 0x8;
 782-			p.data[r->addr + 1] = l->addr & 0xff;
 783-			l->refs++;
 784-			break;
 785-		case '!': case '?':
 786-			if(!(l = findlabel(r->name)))
 787-				return error("Unknown instant jump reference", r->name);
 788-			a = l->addr - r->addr - 2;
 789-			p.data[r->addr] = a >> 0x8;
 790-			p.data[r->addr + 1] = a & 0xff;
 791-			l->refs++;
 792-			break;
 793-		case '`':
 794-			p.ptr=r->addr;
 795-			if(!special_calc(r->name)) return error("Special calculation error", r->name);
 796-			break;
 797-		case 'x':
 798-			if(l=findlabel(r->name)) l->refs++;
 799-			break;
 800-		default:
 801-			return error("Unknown reference", r->name);
 802-		}
 803-	}
 804-	return 1;
 805-}
 806-
 807-static Uint32 expanded_block_length(int x) {
 808-  ExpItem*e;
 809-  Uint32 t=0;
 810-  int i;
 811-  for(i=x;i<p.xlen;i++) {
 812-    e=p.exps+i;
 813-    if(e->kind>='A' && e->kind<='F') break;
 814-    t+=e->len;
 815-  }
 816-  return t;
 817-}
 818-
 819-static int do_subassembly(ExpItem*e) {
 820-  Program ps=p;
 821-  Uint16 st=e->len;
 822-  Label*la;
 823-  int i,j;
 824-  if(!subas) {
 825-    subas=fopen(".uxn_subassembly","wb");
 826-    if(!subas) return error("Cannot open subassembly temporary file",".uxn_subassembly");
 827-  }
 828-  p.ptr=p.length=st;
 829-  p.llen=p.mlen=p.rlen=0;
 830-  for(i=0;i<ps.rlen;i++) if(ps.refs[i].rune=='x') {
 831-    for(j=0;j<ps.mlen;j++) if(scmp(ps.macros[j].name,ps.refs[i].name,0x40)) {
 832-      if(p.mlen==MAXMACROS) return error("Too many exports","");
 833-      p.macros[p.mlen++]=ps.macros[j];
 834-      goto found;
 835-    }
 836-    for(j=0;j<ps.llen;j++) if(scmp(ps.labels[j].name,ps.refs[i].name,0x40)) {
 837-      if(p.llen==MAXLABELS) return error("Too many exports","");
 838-      ps.labels[j].refs=1;
 839-      p.labels[p.llen++]=ps.labels[j];
 840-      goto found;
 841-    }
 842-    found: ;
 843-  }
 844-  if(!doinclude(e->name)) return error("Invalid include",e->name);
 845-  if(!resolve()) return error("Error resolving sub-assembly",e->name);
 846-  e->len=p.length-st;
 847-  if(e->len&~0xFFFF) return error("Length confusion error",e->name);
 848-  fwrite(p.data+st,e->len,1,subas);
 849-  for(i=0;i<p.rlen;i++) if(p.refs[i].rune=='x') {
 850-    la=findlabel(p.refs[i].name);
 851-    if(!la) return error("Invalid export from sub-assembly",p.refs[i].name);
 852-    if(ps.llen==MAXLABELS) return error("Too many exports from sub-assembly",e->name);
 853-    la->refs=1;
 854-    ps.labels[ps.llen++]=*la;
 855-  }
 856-  for(i=ps.xlen;i<p.xlen;i++) ps.exps[i]=p.exps[i];
 857-  ps.xlen=p.xlen;
 858-  st=e->len;
 859-  p=ps;
 860-  e->kind=3;
 861-  e->len=st;
 862-  return 1;
 863-}
 864-
 865-static int align_expanded(void) {
 866-  ExpItem*e;
 867-  Uint32 at=p.length-TRIM;
 868-  Uint32 x;
 869-  int i,j;
 870-  for(i=0;i<p.xlen;i++) {
 871-    e=p.exps+i;
 872-    e->offset=at;
 873-    if(e->kind>='A' && e->kind<='F') {
 874-      for(j=i+1;j<p.xlen;j++) {
 875-        if(p.exps[j].kind=='*') scpy(p.exps[j].name,p.scope,0x40);
 876-        if(p.exps[j].kind=='^' && !do_subassembly(p.exps+j)) return 0;
 877-        if(p.exps[j].kind>='A' && p.exps[j].kind<='F') break;
 878-      }
 879-    }
 880-    switch(e->kind) {
 881-      case '*': // label
 882-        p.ptr=at;
 883-        makelabel(e->name);
 884-        p.ptr=at>>16;
 885-        j=slen(e->name);
 886-        if(j>=0x3F) return error("Too long expanded memory label name",e->name);
 887-        e->name[j]='^';
 888-        e->name[j+1]=0;
 889-        makelabel(e->name);
 890-        break;
 891-      case '^': // sub-assembly
 892-        return error("Sub-assembly outside of expanded memory block",e->name);
 893-      case 'A': // absolute address
 894-        if(at>e->len) return error("Expanded memory absolute address overlapping",e->name);
 895-        at=e->len;
 896-        break;
 897-      case 'B': // align to beginning
 898-        if(at&((1<<*e->name)-1)) at=(at+(1<<*e->name))&-(1<<*e->name);
 899-        break;
 900-      case 'C': // fit into number of pages
 901-        x=expanded_block_length(i+1);
 902-        if(x>(e->len<<16)) return error("Expanded memory block is too big",e->name);
 903-        if(x+(at&0xFFFF)>(e->len<<16)) at=(at+0x10000)&-0x10000;
 904-        break;
 905-      case 'D': // start on page
 906-        if((at>>16)>e->len) return error("Expanded memory page overlapping",e->name);
 907-        if((at>>16)<e->len) at=e->len<<16;
 908-        break;
 909-      case 'E': // align to end
 910-        x=expanded_block_length(i+1);
 911-        if((at+x)&((1<<*e->name)-1)) at=((at+x+(1<<*e->name))&-(1<<*e->name))-x;
 912-        break;
 913-      case 'F': // align to fit
 914-        x=expanded_block_length(i+1);
 915-        if(x>(1<<*e->name)) return error("Expanded memory block does not fit in specified size","");
 916-        if((at&((1<<*e->name)-1))!=((at+x)&((1<<*e->name)-1))) at=(at+((1<<*e->name)-1))&-(1<<*e->name);
 917-        break;
 918-      default: at+=e->len;
 919-    }
 920-  }
 921-  p.total=at;
 922-  if(subas) {
 923-    fclose(subas);
 924-    subas=fopen(".uxn_subassembly","rb");
 925-    if(!subas) return error("Cannot open subassembly temporary file",".uxn_subassembly");
 926-  }
 927-  return 1;
 928-}
 929-
 930-static int resolve_fontmap(void) {
 931-  int i,j;
 932-  for(i=TRIM;i<p.length;i++) if(fontkeep[i>>3]&(1<<(i&7))) {
 933-    j=p.data[i];
 934-    if(!(fontkeep[j>>3]&(1<<(j&7)))) return error("Use of font character that has been deleted","");
 935-    p.data[i]=fontmap[j];
 936-  }
 937-  return 1;
 938-}
 939-
 940-static int
 941-assemble(FILE *f)
 942-{
 943-	char w[0x40];
 944-	int c;
 945-	scpy("on-reset", p.scope, 0x40);
 946-	while(fscanf(f, "%63s", w) == 1) {
 947-		if(!parse(w, f))
 948-			return error("Unknown token", w);
 949-		if(line_comment) {
 950-		  while((c=fgetc(f))>0 && c!='\n');
 951-		  line_comment=0;
 952-		}
 953-	}
 954-	if(fontbloc) return error("Misuse of [' and ]'", "");
 955-	p.total=p.length;
 956-	if(fontdone && !resolve_fontmap()) return 0;
 957-	if(p.xlen && !align_expanded()) return 0;
 958-	return resolve();
 959-}
 960-
 961-static void
 962-review(char *filename)
 963-{
 964-	int i;
 965-	for(i = 0; i < p.llen; i++)
 966-		if(p.labels[i].name[0] >= 'A' && p.labels[i].name[0] <= 'Z')
 967-			continue; /* Ignore capitalized labels(devices) */
 968-		else if(!p.labels[i].refs)
 969-			fprintf(stderr, "-- Unused label: %s\n", p.labels[i].name);
 970-	fprintf(stderr,
 971-		"Assembled %s in %d bytes(%.2f%% used), %d labels, %d macros, %d references.\n",
 972-		filename,
 973-		p.length<TRIM?0:p.length-TRIM,
 974-		p.length<TRIM?0:((p.length - TRIM) / 652.80),
 975-		p.llen,
 976-		p.mlen,
 977-		p.rlen);
 978-	if(p.xlen) fprintf(stderr,"Expanded memory: %u bytes (%u pages), %d items.\nTotal: %u bytes.\n",p.total-p.length,(((p.total+0xFFFF)>>16)?:1)-1,p.xlen,p.total-TRIM);
 979-}
 980-
 981-static void send_name_output(FILE*dst) {
 982-  int i;
 983-  for(i=0;i<p.llen;i++) fprintf(dst,"|%04x @%s\n",p.labels[i].addr,p.labels[i].name);
 984-}
 985-
 986-static void send_expanded(FILE*dst) {
 987-  FILE*f;
 988-  ExpItem*e;
 989-  Uint32 at=p.length;
 990-  Uint32 x;
 991-  int i;
 992-  for(i=0;i<p.xlen;i++) {
 993-    e=p.exps+i;
 994-    if(e->offset>at) {
 995-      x=e->offset-at;
 996-      while(x--) fputc(0,dst);
 997-    }
 998-    at=e->offset;
 999-    switch(e->kind) {
1000-      case 1: // inline data
1001-        fwrite(e->name,e->len,1,dst);
1002-        at+=e->len;
1003-        break;
1004-      case 2: // data from file
1005-        f=fopen(e->name,"rb");
1006-        if(f) {
1007-          x=e->len;
1008-          while(x--) fputc(fgetc(f),dst);
1009-          at+=e->len;
1010-          fclose(f);
1011-        } else {
1012-          error("Cannot open file",e->name);
1013-        }
1014-        break;
1015-      case 3: // sub-assembly
1016-        if(!fread(p.data,e->len,1,subas)) error("Error reading temporary file",".uxn_subassembly");
1017-        fwrite(p.data,e->len,1,dst);
1018-        at+=e->len;
1019-        break;
1020-    }
1021-  }
1022-}
1023-
1024-int
1025-main(int argc, char *argv[])
1026-{
1027-	FILE *src, *dst;
1028-	int c;
1029-	while((c=getopt(argc,argv,"+Yai:"))>0) switch(c) {
1030-	  case 'Y': printf("Program:%u Macro:%u Label:%u Reference:%u ExpItem:%u\n"
1031-	   ,(int)sizeof(Program),(int)sizeof(Macro),(int)sizeof(Label),(int)sizeof(Reference),(int)sizeof(ExpItem)); break;
1032-	  case 'a': p.ptr=0x100; break;
1033-	  case 'i': if(!parse(optarg,stdin)) return !error("Assembly", "Cannot parse command-line arguments"); break;
1034-	}
1035-	if(argc < optind+2)
1036-		return !error("usage", "[switches] input.tal output.rom [output.nam]");
1037-	if(!(src = fopen(argv[optind], "r")))
1038-		return !error("Invalid input", argv[optind]);
1039-	if(!assemble(src))
1040-		return !error("Assembly", "Failed to assemble rom.");
1041-	if(!(dst = fopen(argv[optind+1], "wb")))
1042-		return !error("Invalid output", argv[optind+1]);
1043-	if(p.length <= TRIM)
1044-		error("Assembly", "Output rom is empty.");
1045-	else
1046-		fwrite(p.data + TRIM, p.length - TRIM, 1, dst);
1047-	if(p.xlen) send_expanded(dst);
1048-	review(argv[optind+1]);
1049-	if(argc>optind+2 && argv[optind+2][0]) {
1050-	  fclose(dst);
1051-	  if(!(dst=fopen(argv[optind+2],"w"))) return !error("Invalid name output",argv[3]);
1052-	  send_name_output(dst);
1053-	}
1054-	return 0;
1055-}
+0, -343
  1@@ -1,343 +0,0 @@
  2-This document describes the devices of Uxn/Varvara virtual machine.
  3-
  4-The high nybble of the port number selects one of the following devices:
  5-  0 = System
  6-  1 = Standard I/O
  7-  2 = Screen
  8-  3 = Audio
  9-  4 = Audio
 10-  5 = Audio
 11-  6 = Audio
 12-  7 = MIDI
 13-  8 = Keyboard/joypad
 14-  9 = Mouse
 15-  A = File
 16-  B = File
 17-  C = Date/time
 18-  D = Implementation dependent
 19-  E = Implementation dependent
 20-  F = Implementation dependent
 21-
 22-Note that there are four audio channels, and two files can be opened at
 23-the same time.
 24-
 25-In the below lists, asterisks indicate 16-bit ports.
 26-
 27-
 28-=== System ===
 29-
 30-00 = Vector *
 31-02 = Expansion *
 32-04 = Primary stack count
 33-05 = Secondary stack count
 34-06 = Metadata *
 35-08 = Colours (red) *
 36-0A = Colours (green) *
 37-0C = Colours (blue) *
 38-0E = Debug
 39-0F = Quit
 40-
 41-The vector is unused. (In previous versions of this specification, the
 42-vector was used to signal errors, but no error conditions are possible in
 43-the current version of this specification.)
 44-
 45-Writing an address to the expansion port will execute an expansion
 46-operation, which is a record stored at that address; the first byte of
 47-that data is the operation code, and the rest are the arguments. See the
 48-below list of expansion operations.
 49-
 50-The stack counts are the number of bytes in the specified stack. They can
 51-be read and written; writing zero will clear the stack.
 52-
 53-The colours control the colours of the display, where the high nybble of
 54-each controls the value for colour index 0, and the low nybble of each
 55-controls the value for colour index 3.
 56-
 57-Writing nonzero to the debug port will display some debug info or break
 58-into the debugger; the exact meaning is implementation-dependent, but it
 59-is used for debugging functions.
 60-
 61-Writing nonzero to the quit port terminates the program; the low seven bits
 62-of the number written is the exit code (if exit code is meaningful for the
 63-operating system that it is running on) (writing 0x80 exits with code 0
 64-which means successful).
 65-
 66-
 67-=== Standard I/O ===
 68-
 69-10 = Vector *
 70-12 = Input
 71-17 = Type
 72-18 = Output
 73-19 = Error
 74-
 75-Each byte of input is received from stdin will result in setting the input
 76-port to the byte read and calls the vector. Immediately after the first
 77-BRK (and before any other events), any command-line arguments are also
 78-sent in this way as though each one is a line of input from stdin
 79-terminated by a line feed.
 80-
 81-On input, the type port is set to the type of input, where:
 82-  1 = stdin
 83-  2 = command-line argument text
 84-  3 = line break after command-line argument, other than the final one
 85-  4 = line break after the final command-line argument
 86-
 87-During the startup (call to 0x0100), the type port will be 1 if there are
 88-any command-line arguments and 0 if there are no arguments.
 89-
 90-Writing to the output and error ports write a byte to stdout or stderr.
 91-
 92-
 93-=== Screen ===
 94-
 95-20 = Vector *
 96-22 = Width *
 97-24 = Height *
 98-26 = Auto
 99-28 = X *
100-2A = Y *
101-2C = Sprite address *
102-2E = Pixel command
103-2F = Sprite command
104-
105-The screen has two layers (background and foreground), and can display four
106-colours. If the foreground colour is zero then the background is displayed.
107-
108-The vector is called during each video frame (60 frames per second).
109-
110-Writing the width and height will change the window size if possible (some
111-implementations might not be able to do so), and should clear the screen.
112-(If you read back then you can find the actual width/height.)
113-
114-The auto port works as follows:
115-  bit7-bit4 = One less than number of sprites to draw
116-  bit3 = Unused (should be clear)
117-  bit2 = Address
118-  bit1 = Y
119-  bit0 = X
120-
121-Writing to the pixel command port will change the pixel at the specified
122-coordinates, and will automatically increment X and/or Y if the
123-corresponding bits of the auto port are set. The bits of pixel port are:
124-  bit7 = Set for fill mode
125-  bit6 = Set for foreground layer, clear for background layer
126-  bit5-bit4 = Specify corner for fill mode (unused if not fill mode)
127-  bit3-bit2 = Unused (should be clear)
128-  bit1-bit0 = Colour
129-
130-If fill mode is set, then it will fill a part of the screen, in a rectangle
131-from the specified X and Y coordinates to one of the corners of the screen.
132-In this case, the X and Y are not automatically incremented. The corners of
133-the screen are numbered as follows:
134-  3 2
135-  1 0
136-
137-Writing to the sprite command port will draw one or more sprites. The bits
138-are as follows:
139-  bit7 = Set for 2bpp sprites, clear for 1bpp
140-  bit6 = Set for foreground layer, clear for background layer
141-  bit5 = Vertical flip
142-  bit4 = Horizontal flip
143-  bit3-bit0 = Colour
144-
145-The sprite address port must be set before writing to the sprite command
146-port; it is the address of the graphics data. The 2bpp graphics data is
147-stored in the NES/Famicom pattern tables format; the 1bpp graphics data
148-is similar but there is only one plane.
149-
150-The colours of sprites are mapped according to the table (the top row is
151-the data in the sprite, and the rest has the specified colour in the first
152-column and the result colour in the other columns (where - means it is
153-transparent); the last two columns are not used in 1bpp mode):
154-  DATA  0 1 2 3
155-     0  - 0 1 2
156-     1  0 1 2 3
157-     2  0 2 3 1
158-     3  0 3 1 2
159-     4  1 0 1 2
160-     5  - 1 2 3
161-     6  1 2 3 1
162-     7  1 3 1 2
163-     8  2 0 1 2
164-     9  2 1 2 3
165-     A  - 2 3 1
166-     B  2 3 1 2
167-     C  3 0 1 2
168-     D  3 1 2 3
169-     E  3 2 3 1
170-     F  - 3 1 2
171-
172-The working of auto port and sprites is working as follows: If the
173-auto X bit is set then it draws several sprites vertically, and if the
174-auto Y bit is set then it draws several sprites horizontally; either way,
175-the X (if the auto X bit is set) or the Y (if the auto Y bit is set) is
176-advanced by eight after all of the sprites are drawn (not after each one
177-individually). If the auto address bit is set, then the address is
178-advanced after each individual sprite (and remains advanced after it is
179-finished), by 8 for 1bpp sprites or 16 for 2bpp sprites.
180-
181-
182-=== Audio ===
183-
184-30 = Vector *
185-32 = Position *
186-34 = Output
187-38 = Envelope *
188-3A = Length *
189-3C = Address *
190-3E = Volume
191-3F = Pitch
192-
193-Each such device is one audio channel.
194-
195-The envelope can be zero for no envelope, or can be nonzero for a ADSR
196-envelope where the four nybbles (high to low) are the time of each part
197-of the envelope, in fifteenths of a second. The envelope is as follows:
198-  0% -A- 100% -D- 50% -S- 50% -R- 0%
199-
200-The length is the length of the sample data (in bytes), and the address
201-is the address of the sample data. The sample format is unsigned 8-bits.
202-
203-Volume has the high nybble for the left speaker and low nybble for the
204-right speaker, where fifteen is the maximum volume and zero is silence.
205-
206-Writing to the pitch port will read all parameters and will start a new
207-note playing. The high bit is set to disable looping, or clear to enable
208-looping (until the envelope ends, if there is any). The low 7-bits are a
209-MIDI note number (0x3C for middle C).
210-
211-If the length is greater than 256 bytes, then it is assumed to have a
212-sample rate of 44100 Hz for middle C (if a different note number is
213-specified, then it will be played at a different speed). If the length
214-is less than 256 then it is assumed to be one cycle of a middle C note.
215-
216-Vector is called when a note ends, and the position and output ports are
217-used to read back the status.
218-
219-
220-=== MIDI ===
221-
222-This does not seem to be fully defined at this time (and the existing
223-design is not very good in my opinion).
224-
225-
226-=== Keyboard/joypad ===
227-
228-80 = Vector *
229-82 = Joypad
230-83 = Key
231-85 = Player 2
232-86 = Player 3
233-87 = Player 4
234-
235-The vector is called if a key is pushed, or if any button on the joypad is
236-pushed or released.
237-
238-The joypad byte has bits as follows:
239-  bit7 = Right
240-  bit6 = Left
241-  bit5 = Down
242-  bit4 = Up
243-  bit3 = Start (or home)
244-  bit2 = Select (or left shift)
245-  bit1 = B (or left alt)
246-  bit0 = A (or left control)
247-
248-The key is the ASCII code of the key pushed. It can be any printable ASCII
249-character, as well as: backspace (0x08), tab (0x09), return (0x0D), escape
250-(0x1B), delete (0x7F).
251-
252-
253-=== Mouse ===
254-
255-90 = Vector *
256-92 = X *
257-94 = Y *
258-96 = Buttons
259-9A = Scroll X *
260-9C = Scroll Y *
261-
262-The vector is called when the mouse is moved or if any mouse buttons are
263-pushed or released.
264-
265-The buttons are: bit0 for the left button, bit1 for the middle button, and
266-bit2 for the right button.
267-
268-The scroll amounts are signed 16-bit numbers.
269-
270-
271-=== Files ===
272-
273-A2 = Number of bytes transferred *
274-A4 = Stat (address to store data) *
275-A6 = Delete
276-A7 = Append
277-A8 = Address of file name *
278-AA = Maximum number of bytes to transfer *
279-AC = Read (address to store data) *
280-AE = Write (address to take data from) *
281-
282-If the address of a null-terminated file name is written to that port,
283-then the device is reset and it remembers the file name (so the memory
284-used to store it can be reused afterward).
285-
286-All other operations need the maximum length in that port, and then
287-write the address of the data to the stat/read/write port. The 0xA2 port
288-(or 0xB2 for the second file) will then have the number of bytes which
289-have been successfully transferred, or zero if it is not successful.
290-
291-If there are multiple reads without other operations (including setting
292-the file name) in between, or multiple writes without other operations
293-(including setting the file name) in between, then it will continue from
294-where it left off in the file; otherwise it starts from the beginning.
295-
296-For the first write, it will truncate the file if the append byte is
297-zero, or will start writing at the end of the file if the append byte
298-is nonzero.
299-
300-Reading from either of the read ports will read a single byte from the
301-file (in this case, the address and max number of bytes is ignored). In
302-this case, you should write to both 0xAB and 0xAC if you want to do a
303-long read since if you write to only 0xAC then the address is undefined.
304-
305-Stat will result in a directory entry for the current file being written
306-to the specified address (or nothing if it does not fit). The format of
307-a directory entry is four characters being its size in lowercase
308-hexadecimal with leading zeros, or ???? if it is bigger than 64K, or ----
309-if it is a subdirectory; after that is a space, and then the file name,
310-and then a line feed.
311-
312-If the current file is a directory, then reading from it will read the
313-directory entries in the same format as above. Only full entries can be
314-read; you cannot read partial entries. Only as many full entries as will
315-fit in the allowed space will be retrieved.
316-
317-
318-=== Date/time ===
319-
320-C0 = Year *
321-C2 = Month (zero-based)
322-C3 = Day of month (one-based)
323-C4 = Hours
324-C5 = Minutes
325-C6 = Seconds
326-C7 = Day of the week (0=Sunday)
327-C8 = Day of the year *
328-CA = Daylight saving time
329-
330-Some programs use this device to seed a random number generator, and
331-will not work correctly if these values are all zero.
332-
333-
334-=== Expansion ===
335-
336-00 length* page* addr* value
337-  Fills the specified memory with a single-byte value.
338-
339-01 length* src_page* src_addr* dst_page* dst_addr*
340-  Copy memory forward.
341-
342-02 length* src_page* src_addr* dst_page* dst_addr*
343-  Copy memory backward.
344-
+0, -0
D x.diff
+0, -85
 1@@ -1,85 +0,0 @@
 2---- uxn2.c
 3-+++ uxn2.c
 4-@@ -66,7 +66,7 @@ typedef struct {
 5- /* ------------------------------------------------------------------ */
 6- /* Font data (unchanged)                                              */
 7- /* ------------------------------------------------------------------ */
 8--static const Uint8 fontdata[]={
 9-+static const Uint8 __attribute__((unused)) fontdata[]={
10-   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x78,0x78,0x30,0x30,0x00,0x30,0x00,
11-   0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00,0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00,
12-@@ -128,8 +128,8 @@ static Uint8 *fglayer = NULL;
13- static UxnFile uxnfile0;
14- static UxnFile uxnfile1;
15--static FILE *inf = NULL;
16--static FILE *outf = NULL;
17-+static FILE * __attribute__((unused)) inf = NULL;
18-+static FILE * __attribute__((unused)) outf = NULL;
19- 
20- static const char *rom_name = "uxn.rom";
21- static Uint8 use_console = 0;      /* keypad is limited */
22-@@ -190,7 +190,7 @@ static void err(int e, const char *str)
23-   exit(e);
24- }
25- 
26--static void warn(const char *fmt, ...)
27-+static void __attribute__((unused)) warn(const char *fmt, ...)
28- {
29-   /* silent on calculator – optional: use nspireio */
30-   (void)fmt;
31-@@ -210,7 +210,7 @@ static void debug(int i)
32-   (void)i;
33- }
34- 
35--static void uxnerr(int n, int pc)
36-+static void __attribute__((unused)) uxnerr(int n, int pc)
37- {
38-   (void)n; (void)pc;
39-   if (use_debug) debug(-1);
40-@@ -230,7 +230,6 @@ static void run(Uint16 pc)
41-   Stack *s;
42-   Uint8 k, v;
43-   Uint16 x, y, z;
44-   if (!pc) return;
45--start:
46-   while ((v = mem[pc++])) {
47-     if (pc == breakpoint && use_screen) goto stop;
48-     s = (v & 0x40) ? &rs : &ds;
49-@@ -385,6 +384,7 @@ static void system_out(Device *dev, Uint8 id)
50- /* ------------------------------------------------------------------ */
51- static void console_out(Device *dev, Uint8 id)
52- {
53-+  (void)dev;
54-   switch (id) {
55-     case 8: /* stdout – ignored on calc */ break;
56-     case 9: /* stderr – ignored */ break;
57-@@ -396,9 +396,9 @@ static void console_out(Device *dev, Uint8 id)
58- /* ------------------------------------------------------------------ */
59- /* File device                                                        */
60- /* ------------------------------------------------------------------ */
61--static Uint16 files_stat(int fd, char *name, Uint16 len, Uint8 *out)
62-+static Uint16 files_stat(char *name, Uint16 len, Uint8 *out)
63- {
64-   struct stat st;
65--  if (strlen(name) + 7 > len || fstat(fd, name, &st, 0)) return 0;
66-+  if (strlen(name) + 7 > len || stat(name, &st)) return 0;
67-   if (S_ISDIR(st.st_mode)) return snprintf((char*)out, len, "---- %s\n", name);
68-   else if (st.st_size < 0x10000) return snprintf((char*)out, len, "%04x %s\n", (unsigned)st.st_size, name);
69-   else return snprintf((char*)out, len, "???? %s\n", name);
70-@@ -470,7 +470,7 @@ static void files_out(Device *dev, Uint8 id)
71-       addr = GET16(dev->d + 4);
72-       dev->d[2] = dev->d[3] = 0;
73-       if (!uf->name[0]) break;
74--      y = files_stat(AT_FDCWD, uf->name, len, mem + addr);
75-+      y = files_stat(uf->name, len, mem + addr);
76-       if (y <= len) PUT16(dev->d + 2, y);
77-       break;
78-     case 7:
79-@@ -705,6 +705,7 @@ static void screen_out(Device *dev, Uint8 id)
80- /* ------------------------------------------------------------------ */
81- static void system_exp(Device *dev, Uint16 addr)
82- {
83-+  (void)dev;
84-   Uint32 src, dst;
85-   Uint16 len, n;
86-   switch (mem[addr]) {