Browse Source

Archived uxnasm

main
Devine Lu Linvega 3 months ago
parent
commit
64e9f46f79
  1. 6
      README.md
  2. 0
      archive/uxnasm.c
  3. 0
      assets/logo05x05.tal
  4. 0
      assets/mascot0cx0c.tal
  5. 0
      assets/msx01x02.tal
  6. 0
      assets/terminus01x02.tal
  7. BIN
      boot.rom
  8. 102
      build.sh
  9. 6
      etc/circle128/build.sh
  10. 60
      etc/circle128/circle128.c
  11. 28
      etc/hello.tal
  12. 51
      etc/syntax-highlight/tal.nanorc
  13. 126
      etc/syntax-highlight/tal.sublime-syntax
  14. 16
      etc/wavpcm/build.sh
  15. 63
      etc/wavpcm/wavpcm.c
  16. 0
      fonts/816.uf1
  17. 0
      fonts/acorn8-italic.uf1
  18. 0
      fonts/acorn8-regular.uf1
  19. 0
      fonts/atari8.uf1
  20. 0
      fonts/bbcmicro8.uf1
  21. 0
      fonts/chicago12.uf2
  22. 0
      fonts/courier12.uf2
  23. 0
      fonts/cream.uf2
  24. 0
      fonts/diamond12.uf2
  25. 0
      fonts/diamond20.uf3
  26. 0
      fonts/geneva12.uf2
  27. 0
      fonts/geneva14.uf2
  28. 0
      fonts/geneva24.uf3
  29. 0
      fonts/helvetica12.uf2
  30. 0
      fonts/helvetica14.uf2
  31. 0
      fonts/helvetica24.uf3
  32. 0
      fonts/left8.uf1
  33. 0
      fonts/losangeles12.uf2
  34. 0
      fonts/monaco12.uf2
  35. 0
      fonts/msx816.uf2
  36. 0
      fonts/newyork12.uf2
  37. 0
      fonts/newyork14.uf2
  38. 0
      fonts/newyork24.uf3
  39. 0
      fonts/orca8.uf1
  40. 0
      fonts/palatino12.uf2
  41. 0
      fonts/palatino14.uf2
  42. 0
      fonts/palatino24.uf3
  43. 0
      fonts/sans10-bold.uf2
  44. 0
      fonts/sans10-regular.uf2
  45. 0
      fonts/sans12-bold.uf2
  46. 0
      fonts/sans12-regular.uf2
  47. 0
      fonts/sans14-bold.uf2
  48. 0
      fonts/sans14-regular.uf2
  49. 0
      fonts/sapphire14.uf2
  50. 0
      fonts/sapphire19.uf3
  51. 0
      fonts/specter8.uf1
  52. 0
      fonts/terminal12.uf2
  53. 0
      fonts/times12.uf2
  54. 0
      fonts/times15.uf2
  55. 0
      fonts/times24.uf3
  56. 0
      fonts/venice14.uf2
  57. 64
      mkfile
  58. 0
      pictures/akane20x10.icn
  59. 0
      pictures/ako10x10.chr
  60. 0
      pictures/bulma37x29.chr
  61. 0
      pictures/cibo10x10.icn
  62. 0
      pictures/cyr0cx08.chr
  63. 0
      pictures/dafu10x10.icn
  64. 0
      pictures/daria10x10.chr
  65. 0
      pictures/ergo20x1a.icn
  66. 0
      pictures/felix0cx0c.chr
  67. 0
      pictures/logo02x02.icn
  68. 0
      pictures/logo04x04.chr
  69. 0
      pictures/logo08x08.icn
  70. 0
      pictures/pc9820x10.chr
  71. 0
      pictures/pjw20x20.icn
  72. 0
      pictures/tima2ax1a.icn
  73. 0
      pictures/zerotwo10x10.chr
  74. 0
      pictures/zerotwo20x20.chr
  75. 314
      projects/examples/demos/amiga.tal
  76. 131
      projects/examples/demos/bifurcan.tal
  77. 250
      projects/examples/demos/bitwise.tal
  78. 221
      projects/examples/demos/bunnymark.tal
  79. 45
      projects/examples/demos/circles.tal
  80. 127
      projects/examples/demos/cube3d.tal
  81. 236
      projects/examples/demos/drool.tal
  82. 56
      projects/examples/demos/dvd.tal
  83. 71
      projects/examples/demos/hilbert.tal
  84. 221
      projects/examples/demos/life.tal
  85. 172
      projects/examples/demos/mandelbrot.tal
  86. 63
      projects/examples/demos/move.tal
  87. 145
      projects/examples/demos/polycat.tal
  88. 145
      projects/examples/demos/pond.tal
  89. 171
      projects/examples/demos/snake.tal
  90. 430
      projects/examples/devices/audio-tests.tal
  91. 139
      projects/examples/devices/audio.channels.tal
  92. 177
      projects/examples/devices/audio.tal
  93. 16
      projects/examples/devices/console.read.tal
  94. 83
      projects/examples/devices/console.tal
  95. 22
      projects/examples/devices/console.write.tal
  96. 191
      projects/examples/devices/controller.tal
  97. 94
      projects/examples/devices/datetime.tal
  98. 14
      projects/examples/devices/file.cat.tal
  99. 97
      projects/examples/devices/file.tal
  100. 186
      projects/examples/devices/mouse.tal
  101. Some files were not shown because too many files have changed in this diff Show More

6
README.md

@ -7,10 +7,10 @@ So you're interested in find a Varvara emulator for your system.
First, based on what you're trying to do, you can pick one of these emulators:
- [uxn2](https://git.sr.ht/~rabbits/uxn2)(recommended), a graphical emulator, written in SDL2.
- Recommended: [uxn2](https://git.sr.ht/~rabbits/uxn2), a portable graphical emulator, written in SDL2.
- [uxn11](https://git.sr.ht/~rabbits/uxn11), a partial graphical emulator, ideal for productivity.
- [uxncli](https://git.sr.ht/~rabbits/uxncli), a terminal emulator, ideal for running cli tools.
- [uxnmin](https://git.sr.ht/~rabbits/uxnmin), a minimal terminal emulator, ideal for bootstrapping.
- [uxnmin](https://git.sr.ht/~rabbits/uxnmin), a minimal terminal emulator, ideal for [bootstrapping](https://git.sr.ht/~rabbits/drifblim#bootstrap).
## Use the emulator
@ -22,7 +22,7 @@ uxnemu program.rom argument1 argument2
## Write programs
Lastly, to turn a source file into a rom, you need a compiler, like [Drifblim](https://git.sr.ht/~rabbits/uxnmin), it comes in 3 flavors.
Lastly, to turn a source file into a rom you need a compiler, like [Drifblim](https://git.sr.ht/~rabbits/drifblim)([download it](https://rabbits.srht.site/drifblim/drifblim.rom)):
```sh
uxnemu drifblim.rom source.tal program.rom

0
src/uxnasm.c → archive/uxnasm.c

0
projects/assets/logo05x05.tal → assets/logo05x05.tal

0
projects/assets/mascot0cx0c.tal → assets/mascot0cx0c.tal

0
projects/assets/msx01x02.tal → assets/msx01x02.tal

0
projects/assets/terminus01x02.tal → assets/terminus01x02.tal

BIN
boot.rom

Binary file not shown.

102
build.sh

@ -1,102 +0,0 @@
#!/bin/sh -e
format=0
console=0
install=0
debug=0
norun=0
while [ $# -gt 0 ]; do
case $1 in
--format)
format=1
shift
;;
--console)
console=1
shift
;;
--install)
install=1
shift
;;
--debug)
debug=1
shift
;;
--no-run)
norun=1
shift
;;
*)
shift
esac
done
rm -f bin/*
# When clang-format is present
if [ $format = 1 ];
then
clang-format -i src/uxnasm.c
clang-format -i src/uxncli.c
clang-format -i src/uxnemu.c
clang-format -i src/devices/*
fi
mkdir -p bin
CC="${CC:-cc}"
CFLAGS="${CFLAGS:--std=c89 -Wall -Wno-unknown-pragmas}"
case "$(uname -s 2>/dev/null)" in
MSYS_NT*|MINGW*) # MSYS2 on Windows
FILE_LDFLAGS="-liberty"
if [ $console = 1 ];
then
UXNEMU_LDFLAGS="-static $(sdl2-config --cflags --static-libs | sed -e 's/ -mwindows//g')"
else
UXNEMU_LDFLAGS="-static $(sdl2-config --cflags --static-libs)"
fi
;;
Darwin) # macOS
CFLAGS="${CFLAGS} -Wno-typedef-redefinition -D_C99_SOURCE -D_DARWIN_BETTER_REALPATH"
UXNEMU_LDFLAGS="$(sdl2-config --cflags --static-libs)"
;;
Linux|*)
UXNEMU_LDFLAGS="-L/usr/local/lib $(sdl2-config --cflags --libs)"
;;
esac
if [ $debug = 1 ];
then
echo "[debug]"
CFLAGS="${CFLAGS} -DDEBUG -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined"
else
CFLAGS="${CFLAGS} -DNDEBUG -O2 -g0 -s"
fi
${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
${CC} ${CFLAGS} src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} ${FILE_LDFLAGS} -o bin/uxnemu
${CC} ${CFLAGS} src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c src/uxncli.c ${FILE_LDFLAGS} -o bin/uxncli
if [ $install = 1 ]
then
cp bin/uxnemu bin/uxnasm bin/uxncli $HOME/bin/
fi
if [ $norun = 1 ]; then exit; fi
# Test version
bin/uxnasm -v
bin/uxncli -v
bin/uxnemu -v
# Start potato
bin/uxnemu -2x

6
etc/circle128/build.sh

@ -1,6 +0,0 @@
#!/bin/sh -e
clang-format -i circle128.c
rm -f circle128
cc -lm -o circle128 circle128.c
./circle128 64

60
etc/circle128/circle128.c

@ -1,60 +0,0 @@
#include <stdio.h>
#include <math.h>
/*
Copyright (c) 2020-2023 Devine Lu Linvega
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
#define PI 3.14159265358979323846
typedef unsigned char Uint8;
int
clamp(int val, int min, int max)
{
return (val >= min) ? (val <= max) ? val : max : min;
}
int
sint(char *s)
{
int i = 0, num = 0;
while(s[i] && s[i] >= '0' && s[i] <= '9')
num = num * 10 + (s[i++] - '0');
return num;
}
int
main(int argc, char *argv[])
{
int seg, offset, i;
double segf, cx = 128, cy = 128, r;
if(argc < 2) {
printf("usage: circle128 length [radius]\n", argc);
return 1;
}
seg = sint(argv[1]);
segf = (double)seg;
offset = seg / 4;
r = argc < 3 ? 128 : (double)sint(argv[2]);
printf("%d points on a circle%d:\n\n", seg, (int)r);
for(i = 0; i < seg; ++i) {
double pos = (i - offset) % seg;
double deg = (pos / segf) * 360.0;
double rad = deg * (PI / 180);
double x = cx + r * cos(rad);
double y = cy + r * sin(rad);
if(i > 0 && i % 8 == 0)
printf("\n");
printf("%02x%02x ", (Uint8)clamp(x, 0x00, 0xff), (Uint8)clamp(y, 0x00, 0xff));
}
printf("\n\n");
return 0;
}

28
etc/hello.tal

@ -1,28 +0,0 @@
( init )
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
%emit ( byte -- ) { ( hey ) #18 DEO }
|0100 @program
#1234 SWP
#010e DEO
#010f DEO
#1234 #5678 SWP2
;hello-word
&while
( send ) LDAk emit
( loop ) INC2 LDAk ?&while
POP2
#010f DEO
BRK
@program/extend BRK
@hello-word "Hello 20 "World? 00

51
etc/syntax-highlight/tal.nanorc

@ -1,51 +0,0 @@
# include this file in your ~/.nanorc:
# include "path/to/uxntal.nanorc"
syntax "uxntal" "\.tal$"
# numbers
color lightblue "[0-9a-f]{2}(\s|$)"
color lightblue "[0-9a-f]{4}(\s|$)"
# literal hex
color cyan "#[0-9a-f]{2}(\s|$)"
color cyan "#[0-9a-f]{4}(\s|$)"
# absolute pad
color bold,blue "\|[0-9a-f]{2}"
color bold,blue "\|[0-9a-f]{4}"
# labels
# label define
color green "@\S+"
# sub-label define
color green "&\S+"
# literal addr absolute
color magenta ";\S+"
# literal addr relative
color magenta ",\S+"
# literal addr zero page
color lightmagenta "\.\S+"
# raw
# character
color lightred "'\S"
# string
color lightred ""\S+"
# addr
color lightyellow ":\S+"
# include
color lightcyan "~\S+"
# macros definition
color yellow "\%\S+"
color yellow "[{}]"
# instructions
color bold,cyan "(BRK|LIT|INC|POP|DUP|NIP|SWP|OVR|ROT|EQU|NEQ|GTH|LTH|JMP|JCN|JSR|STH|LDZ|STZ|LDR|STR|LDA|STA|DEI|DEO|ADD|SUB|MUL|DIV|AND|ORA|EOR|SFT)[2kr]{,3}(\s|$)"
# comments
comment "( | )"
color blue start="\(" end="\)"

126
etc/syntax-highlight/tal.sublime-syntax

@ -1,126 +0,0 @@
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: Uxn Assembly
scopeName: tal.
fileTypes: [tal]
file_extensions:
- tal
scope: source.tal
contexts:
main:
# get
- match: '\.(\S+)\sDEI2'
scope: entity.name.type.typedef
pop: true
- match: '\.(\S+)\sDEI'
scope: entity.name.type.typedef
pop: true
- match: '\.(\S+)\sLDZ2'
scope: entity.name.type.typedef
pop: true
- match: '\.(\S+)\sLDZ'
scope: entity.name.type.typedef
pop: true
- match: '\,(\S+)\sLDR2'
scope: entity.name.type.typedef
pop: true
- match: '\,(\S+)\sLDR'
scope: entity.name.type.typedef
pop: true
- match: '\;(\S+)\sLDA2'
scope: entity.name.type.typedef
pop: true
- match: '\;(\S+)\sLDA'
scope: entity.name.type.typedef
pop: true
# set
- match: '\.(\S+)\sDEO2'
scope: constant.numeric
pop: true
- match: '\.(\S+)\sDEO'
scope: constant.numeric
pop: true
- match: '\.(\S+)\sSTZ2'
scope: constant.numeric
pop: true
- match: '\.(\S+)\sSTZ'
scope: constant.numeric
pop: true
- match: '\,(\S+)\sSTR2'
scope: constant.numeric
pop: true
- match: '\,(\S+)\sSTR'
scope: constant.numeric
pop: true
- match: '\;(\S+)\sSTA2'
scope: constant.numeric
pop: true
- match: '\;(\S+)\sSTA'
scope: constant.numeric
pop: true
# label
- match: '\@(\S+)\s?'
scope: string.control
pop: true
# sublabel
- match: '\&(\S+)\s?'
scope: string.control
pop: true
# include
- match: 'include'
scope: string.control
pop: true
# jump
- match: '\|(\S+)\s?'
scope: entity.name.tag.structure.any
pop: true
# pad
- match: '\$(\S+)\s?'
scope: entity.name.tag.structure.any
pop: true
# Pushing to stack
- match: '\"(\S+)\s?'
scope: constant.numeric
pop: true
# Addressing
- match: '\.(\S+)\s?' # zero-page
scope: variable.function.shell
pop: true
- match: '\,(\S+)\s?' # relative
scope: entity.name.tag.yaml
pop: true
- match: '\;(\S+)\s?' # absolute
scope: keyword.control
pop: true
- match: '\:(\S+)\s?' # raw
scope: keyword.control
pop: true
# Blocks
- match: '\[\s?'
scope: comment
pop: true
- match: '\]\s?'
scope: comment
pop: true
- match: '\{'
scope: variable.control
push:
- meta_scope: variable.control
- match: '\}'
pop: true
- match: '\s\(\s'
scope: comment
push:
- meta_scope: comment.line
- match: '\s\)\s'
pop: true

16
etc/wavpcm/build.sh

@ -1,16 +0,0 @@
#!/bin/bash
echo "Formatting.."
clang-format -i wavpcm.c
echo "Cleaning.."
rm -f ../../bin/wavpcm
echo "Building.."
mkdir -p ../../bin
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined -lm wavpcm.c -o ../../bin/wavpcm
echo "Running.."
../../bin/wavpcm
echo "Done."

63
etc/wavpcm/wavpcm.c

@ -1,63 +0,0 @@
#include <stdio.h>
#include <math.h>
/*
Copyright (c) 2020 Devine Lu Linvega
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
#define PI 3.14159265358979323846
#define SAMPLES 256
#define RATE 1
typedef unsigned char Uint8;
int
clamp(int val, int min, int max)
{
return (val >= min) ? (val <= max) ? val : max : min;
}
Uint8
sinw(int i)
{
return 0x7f * sin(i * RATE * 2 * PI / SAMPLES);
}
Uint8
triw(int i)
{
if(i < 0x40)
return i * 2;
if(i >= 0xc0)
return (i - 0xc0) * 2 - 0x7f;
return 0x7f - (i - 0x40) * 2;
}
Uint8
sqrw(int i)
{
return ((i * RATE) % 0xff) < 0x80 ? 0x7f : 0x80;
}
int
main()
{
int i;
printf("%d:\n\n", SAMPLES);
for(i = 0; i < SAMPLES; ++i) {
if(i % 0x10 == 0)
printf("\n");
else if(i % 2 == 0)
printf(" ");
printf("%02x", (triw(i) + sinw(i)) / 2);
}
printf("\n\n");
return 0;
}

0
projects/fonts/816.uf1 → fonts/816.uf1

0
projects/fonts/acorn8-italic.uf1 → fonts/acorn8-italic.uf1

0
projects/fonts/acorn8-regular.uf1 → fonts/acorn8-regular.uf1

0
projects/fonts/atari8.uf1 → fonts/atari8.uf1

0
projects/fonts/bbcmicro8.uf1 → fonts/bbcmicro8.uf1

0
projects/fonts/chicago12.uf2 → fonts/chicago12.uf2

0
projects/fonts/courier12.uf2 → fonts/courier12.uf2

0
projects/fonts/cream.uf2 → fonts/cream.uf2

0
projects/fonts/diamond12.uf2 → fonts/diamond12.uf2

0
projects/fonts/diamond20.uf3 → fonts/diamond20.uf3

0
projects/fonts/geneva12.uf2 → fonts/geneva12.uf2

0
projects/fonts/geneva14.uf2 → fonts/geneva14.uf2

0
projects/fonts/geneva24.uf3 → fonts/geneva24.uf3

0
projects/fonts/helvetica12.uf2 → fonts/helvetica12.uf2

0
projects/fonts/helvetica14.uf2 → fonts/helvetica14.uf2

0
projects/fonts/helvetica24.uf3 → fonts/helvetica24.uf3

0
projects/fonts/left8.uf1 → fonts/left8.uf1

0
projects/fonts/losangeles12.uf2 → fonts/losangeles12.uf2

0
projects/fonts/monaco12.uf2 → fonts/monaco12.uf2

0
projects/fonts/msx816.uf2 → fonts/msx816.uf2

0
projects/fonts/newyork12.uf2 → fonts/newyork12.uf2

0
projects/fonts/newyork14.uf2 → fonts/newyork14.uf2

0
projects/fonts/newyork24.uf3 → fonts/newyork24.uf3

0
projects/fonts/orca8.uf1 → fonts/orca8.uf1

0
projects/fonts/palatino12.uf2 → fonts/palatino12.uf2

0
projects/fonts/palatino14.uf2 → fonts/palatino14.uf2

0
projects/fonts/palatino24.uf3 → fonts/palatino24.uf3

0
projects/fonts/sans10-bold.uf2 → fonts/sans10-bold.uf2

0
projects/fonts/sans10-regular.uf2 → fonts/sans10-regular.uf2

0
projects/fonts/sans12-bold.uf2 → fonts/sans12-bold.uf2

0
projects/fonts/sans12-regular.uf2 → fonts/sans12-regular.uf2

0
projects/fonts/sans14-bold.uf2 → fonts/sans14-bold.uf2

0
projects/fonts/sans14-regular.uf2 → fonts/sans14-regular.uf2

0
projects/fonts/sapphire14.uf2 → fonts/sapphire14.uf2

0
projects/fonts/sapphire19.uf3 → fonts/sapphire19.uf3

0
projects/fonts/specter8.uf1 → fonts/specter8.uf1

0
projects/fonts/terminal12.uf2 → fonts/terminal12.uf2

0
projects/fonts/times12.uf2 → fonts/times12.uf2

0
projects/fonts/times15.uf2 → fonts/times15.uf2

0
projects/fonts/times24.uf3 → fonts/times24.uf3

0
projects/fonts/venice14.uf2 → fonts/venice14.uf2

64
mkfile

@ -1,64 +0,0 @@
</$objtype/mkfile
BIN=/$objtype/bin/games
TARG=bin/uxncli bin/uxnasm bin/uxnemu
USM=`{walk -f projects/ | grep '\.tal$' | grep -v blank.tal | grep -v /assets/ | grep -v /library/}
ROM=${USM:%.tal=%.rom}
CFLAGS=$CFLAGS -p -D__plan9__ -I/sys/include/npe -I/sys/include/npe/SDL2
HFILES=\
/sys/include/npe/stdio.h\
src/devices/audio.h\
src/devices/controller.h\
src/devices/datetime.h\
src/devices/file.h\
src/devices/mouse.h\
src/devices/screen.h\
src/devices/system.h\
src/devices/console.h\
src/uxn.h\
CLEANFILES=$TARG $ROM
default:V: all
all:V: bin $TARG $ROM
bin:
mkdir -p bin
/sys/include/npe/stdio.h:
hget https://git.sr.ht/~ft/npe/archive/master.tar.gz | tar xz &&
cd npe-master &&
mk install &&
rm -r npe-master
%.rom:Q: %.tal bin/uxnasm
bin/uxnasm $stem.tal $target >/dev/null
bin/uxncli: file.$O datetime.$O system.$O console.$O uxncli.$O uxn.$O
$LD $LDFLAGS -o $target $prereq
bin/uxnasm: uxnasm.$O
$LD $LDFLAGS -o $target $prereq
bin/uxnemu: audio.$O controller.$O datetime.$O file.$O mouse.$O screen.$O system.$O console.$O uxn.$O uxnemu.$O
$LD $LDFLAGS -o $target $prereq
(uxnasm|uxncli|uxnemu|uxn)\.$O:R: src/\1.c
$CC $CFLAGS -Isrc -o $target src/$stem1.c
(audio|controller|datetime|file|mouse|screen|system|console)\.$O:R: src/devices/\1.c
$CC $CFLAGS -Isrc -o $target src/devices/$stem1.c
nuke:V: clean
clean:V:
rm -f *.[$OS] [$OS].??* $TARG $CLEANFILES
%.clean:V:
rm -f $stem.[$OS] [$OS].$stem $stem
install:V: all
cp $TARG $BIN/
#LDFLAGS=-p

0
projects/pictures/akane20x10.icn → pictures/akane20x10.icn

0
projects/pictures/ako10x10.chr → pictures/ako10x10.chr

0
projects/pictures/bulma37x29.chr → pictures/bulma37x29.chr

0
projects/pictures/cibo10x10.icn → pictures/cibo10x10.icn

0
projects/pictures/cyr0cx08.chr → pictures/cyr0cx08.chr

0
projects/pictures/dafu10x10.icn → pictures/dafu10x10.icn

0
projects/pictures/daria10x10.chr → pictures/daria10x10.chr

0
projects/pictures/ergo20x1a.icn → pictures/ergo20x1a.icn

0
projects/pictures/felix0cx0c.chr → pictures/felix0cx0c.chr

0
projects/pictures/logo02x02.icn → pictures/logo02x02.icn

0
projects/pictures/logo04x04.chr → pictures/logo04x04.chr

0
projects/pictures/logo08x08.icn → pictures/logo08x08.icn

0
projects/pictures/pc9820x10.chr → pictures/pc9820x10.chr

0
projects/pictures/pjw20x20.icn → pictures/pjw20x20.icn

0
projects/pictures/tima2ax1a.icn → pictures/tima2ax1a.icn

0
projects/pictures/zerotwo10x10.chr → pictures/zerotwo10x10.chr

0
projects/pictures/zerotwo20x20.chr → pictures/zerotwo20x20.chr

314
projects/examples/demos/amiga.tal

@ -1,314 +0,0 @@
( Boing )
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|0000
@ball &x $2 &y $2 &vx $2 &vy $2
@timer $1
@frame $1
@direction $1
(
@|vectors )
|0100
( variables )
[ LIT2 01 -direction ] STZ
( vectors )
;on-frame .Screen/vector DEO2
( theme )
#aff5 .System/r DEO2
#af00 .System/g DEO2
#af05 .System/b DEO2
( screen size )
#0140 .Screen/width DEO2
#0100 .Screen/height DEO2
( inital position )
#0020 .ball/x STZ2
#0020 .ball/y STZ2
( initial velocity )
#0003 .ball/vx STZ2
#0000 .ball/vy STZ2
( once )
make-shadow
draw-background
BRK
@on-frame ( -> )
( 12 frames animation )
.frame LDZk .direction LDZ ADD #0c DIVk MUL SUB SWP STZ
move-ball
BRK
(
@|core )
@flip-direction ( zp^ -- )
LDZ2k #ffff EOR2 INC2 ROT STZ2
JMP2r
@check-flip-vx ( x -- x )
( left ) DUP2 #0010 LTH2 ?&flip
( right ) DUP2 .Screen/width DEI2 #0050 SUB2 GTH2 ?&flip
JMP2r
&flip
.direction LDZk #0a EOR SWP STZ
.ball/vx !flip-direction
@check-flip-vy ( y -- y )
( bottom ) DUP2 .Screen/height DEI2 #0050 SUB2 GTH2 ?&flip !&else
&flip .ball/vy !flip-direction
&else
JMP2r
@move-ball ( -- )
( clear )
.ball/x LDZ2 .Screen/x DEO2
.ball/y LDZ2 .Screen/y DEO2
;fill-icn .Screen/addr DEO2
[ LIT2 71 -Screen/auto ] DEO
#f8
&loop-bg
[ LIT2 40 -Screen/sprite ] DEO
INC DUP ?&loop-bg
POP
[ LIT2 76 -Screen/auto ] DEO
.ball/vx LDZ2k STH2k ROT STZ2
.ball/x LDZ2k STH2r ADD2 check-flip-vx ROT STZ2
.timer LDZk INC DUP ROT STZ #06 EQU ?&pull
!&pass
&pull [ LIT2 00 -timer ] STZ .ball/vy LDZ2k INC2 STH2k ROT STZ2 !&end
&pass .ball/vy LDZ2k STH2k ROT STZ2 !&end
&end .ball/y LDZ2k STH2r ADD2 check-flip-vy ROT STZ2
@draw-ball ( -- )
( shadow )
.ball/x LDZ2 #0008 ADD2 .Screen/x DEO2
.ball/y LDZ2 #0008 ADD2 .Screen/y DEO2
;shadow .Screen/addr DEO2
[ LIT2 66 -Screen/auto ] DEO
#f9
&loop-shadow
[ LIT2 4f -Screen/sprite ] DEO
INC DUP ?&loop-shadow
POP
.frame LDZ
( bg )
DUP #06 DIV INC #05 MUL #40 ADD ,&bg STR
.ball/x LDZ2 .Screen/x DEO2
.ball/y LDZ2 .Screen/y DEO2
;bg .Screen/addr DEO2
[ LIT2 66 -Screen/auto ] DEO
#f9
&loop-bg
[ LIT2 &bg $1 -Screen/sprite ] DEO
INC DUP ?&loop-bg
POP
( fg )
DUP #06 DIV #00 EQU INC #05 MUL #40 ADD ,&fg STR
.ball/x LDZ2 .Screen/x DEO2
.ball/y LDZ2 .Screen/y DEO2
#06 DIVk MUL SUB #00 SWP #0188 MUL2 ;ball-icn ADD2 .Screen/addr DEO2
[ LIT2 66 -Screen/auto ] DEO
#f9
&loop-fg
[ LIT2 &fg $1 -Screen/sprite ] DEO
INC DUP ?&loop-fg
POP
JMP2r
@draw-background ( -- )
( hor lines )
[ LIT2 01 -Screen/auto ] DEO
;hor-icn .Screen/addr DEO2
.Screen/height DEI2 #04 SFT2 NIP #04 SUB #00
&horver
#0020 .Screen/x DEO2
#00 OVR #40 SFT2 #0020 ADD2 .Screen/y DEO2
.Screen/width DEI2 #03 SFT2 NIP #08 SUB #00
&horhor
[ LIT2 0f -Screen/sprite ] DEO
INC GTHk ?&horhor
POP2
INC GTHk ?&horver
POP2
( ver lines )
[ LIT2 02 -Screen/auto ] DEO
;ver-icn .Screen/addr DEO2
.Screen/width DEI2 #04 SFT2 NIP #03 SUB #00
&verver
#0027 .Screen/y DEO2
#00 OVR #40 SFT2 #0019 ADD2 .Screen/x DEO2
.Screen/height DEI2 #03 SFT2 NIP #0a SUB #00
&verhor
[ LIT2 0f -Screen/sprite ] DEO
INC GTHk ?&verhor
POP2
INC GTHk ?&verver
POP2
JMP2r
@make-shadow ( -- )
;bg ;shadow #0188 mcpy
#0188 #0000
&loop
DUP2 ;shadow ADD2 LDA2k #aa55 AND2 SWP2 STA2
INC2 INC2 GTH2k ?&loop
POP2 POP2
JMP2r
@mcpy ( src* dst* len* -- )
SWP2 STH2
OVR2 ADD2 SWP2
&loop
LDAk STH2kr STA INC2r
INC2 GTH2k ?&loop
POP2 POP2
POP2r
JMP2r
(
@|assets )
@fill-icn
ffff ffff ffff ffff
@hor-icn
0000 0000 0000 00ff
@ver-icn
0101 0101 0101 0101
@ball-icn ( 56 x 56 )
( 00 )
0000 0000 0000 0000 0000 0000 0304 0830 0000 073f 180c 1f3f 00f4 c103 070f bf8f
0040 0cfc e2c1 c1c1 0000 0000 80a0 e0e4 0000 0000 0000 0000 0000 0000 0101 0303
60c0 01e3 fbf0 f0e0 7fff fefe fc78 000f 8100 0000 0001 0103 8040 f8ff ffff ffff
f2f1 f9f8 1c00 0303 0000 8080 4020 b0e0 0707 0f1f 2720 2060 e0c0 c080 8000 e0fc
0f1f 1f3f 3f3f 7f7f e3ff f8f8 f8f0 f0f0 fefe 7e0e 0001 0103 0101 0101 01c1 f9fe
e0e0 e0f0 f0f0 f0f8 6060 4041 4141 0139 ffff ffff fefe fefe 7f0f 0100 0000 0000
e0e0 e000 3c3f 7f7f 0303 0707 0787 fff1 fefe fefc fcfc fcfc 1804 0606 0e0e 0e0e
3e1e 1e1e 1e0e 0f0f fe1c 0003 0303 0303 0000 0080 f1ff fefe 7fff ffff ffff 3f07
f0e0 e0e0 c0c0 8080 3800 070f 0f1f 1f3f 0e0c 0cfc e0c0 c080 0f09 0400 0001 0000
0303 c37b 3c3c 9e1e fcfc fcfc f818 040f 0000 0101 0303 078f 80e0 feff fffe fcf8
3f7f 7f3e 0603 070e 8000 0000 0000 0000 0000 0000 0000 0000 0e1e 0500 0000 0000
0f0f 0f4f 2703 0200 ffe1 c080 030f 1e00 f0e0 00f9 f8c0 0000 3c70 e0c0 0000 0000
0000 0000 0000 0000
( 01 )
0000 0000 0000 0000 0000 0000 0204 0800 0001 0f7c 101c 3fff 00e7 8307 0f3f ff0f
0040 0cdc c083 8101 0000 0000 80a0 c0e4 0000 0000 0000 0000 0000 0003 0103 0307
4183 07ef f3e0 e0c0 fefe fcf8 f070 181f 0101 0103 0303 0707 01c1 f9fe fefc fcfc
e2f3 f1f8 1804 0707 0000 0080 4060 b0c0 070f 3f1f 2721 0101 c080 8000 0000 e1fd
3f3f 7f7f ffff ffff eff3 f0e0 e0c0 c0c0 fcfc 7c0c 0607 0707 0303 0303 03c3 fbfc
c0e0 e0e4 e0e0 f0f0 4141 4343 4343 433b fefe fcfc fcfc f8f8 7f0f 0100 0000 0001
8080 80c0 fcff ffff 0f0f 0f1f 1f9f efc1 fcf8 f8f8 f8f8 f0f0 100c 0e0e 0e1e 1e1e
3c3c 3c1c 3c1e 0e0e f818 0407 0707 0707 0101 0383 f3f9 f8f8 ffff ffff ffff 3f06
c0c0 8080 0000 0000 3008 1f1f 3f3f 7f7f 1c1c 1cfc c0c4 8000 0e08 0400 0000 0000
0707 c7ff 7838 bc1c f8f8 f0f0 f010 1c1f 0103 0307 070f 0f9f 00e0 fefe fcf8 f0e0
7ffe fe3c 0407 0f1e 0000 0000 4000 0000 0000 0000 0000 0000 0c1e 0400 0000 0000
1f1f 1fdf 2607 0200 cfc1 8001 071f 1c00 e0c0 41fb f080 0000 38f0 e0c0 0000 0000
0000 0000 0000 0000
( 02 )
0000 0000 0000 0000 0000 0000 0000 0001 0001 1ff8 003c fefe 00e7 030f 3f7f 7f0e
0000 1cd8 8003 0303 0000 0000 80c0 c0c4 0000 0000 0000 0000 0000 0103 0307 070f
0307 0fff e3c0 c080 fcf8 f0f0 e040 787f 0203 0707 0f0f 1f1f 03c3 fbf8 f8f8 f8f8
e6e3 e1f1 100c 0f0f 0000 0080 c060 e0c0 0f1f 3f3e 0403 0303 8000 0001 0103 e3fb
7fff ffff ffff ffff ffc3 c080 8080 0000 f8f0 7000 0e1f 1f1f 0f0f 0707 07c7 fff0
c8c0 c0c4 e0e0 e0e2 0303 0707 0707 477f f8f8 f8f8 f0f0 f0f0 7f0e 0001 0303 0307
0000 00c0 fcff ffff 1f3f 3f3f 7fff 8f01 f0f0 f0f0 e0e0 e0e0 001c 1e1e 1e1c 3c3c
7838 3838 3c1c 1c1c f000 1c1f 1f1f 0f0f 0707 078f fff1 f0e0 ffff fefe fefc 3c00
0000 0000 0000 0001 2038 3f7f 7fff fffe 3c3c 3cdc 8004 0800 0c00 0100 0000 0000
0f0f cff7 7078 3818 e0e0 e0e0 e020 3c3f 0707 0f0f 1f1f 3fbf 01e1 fdf8 f0f0 e0c0
fefc fc38 000f 1e3c 1000 2000 4000 0000 0000 0000 0000 0000 1c1c 0400 0000 0000
3f3f 3ffe 6407 0300 8f01 0103 0f3f 1800 8080 c3ff e008 0000 78f0 c080 0000 0000
0000 0000 0000 0000
( 03 )
0000 0000 0000 0000 0000 0000 0000 0003 0001 1ef0 207d fcf8 00c7 071f 7ffe 7c0c
0080 1c9a 0407 0707 0000 0000 80c0 80cc 0000 0000 0000 0000 0000 0103 0307 070f
070f 1fdf c380 8001 f8f0 e0c0 8080 f8ff 060f 0f1f 1f3f 3f7f 07c7 f7f0 f0f0 e0e0
c6c2 e3e1 001c 1f1f 0000 0080 c0c0 e080 0f1e 3c3c 0007 0707 0101 0303 0707 eff3
ffff ffff fefe fcfc 9f03 0000 0000 0000 e0e0 6030 3e3f 7f7f 1f1f 1f1f 1fdf e7e0
8888 80c4 c4c0 c0c2 0707 070f 0f0f 4f77 f0f0 e0e0 e0e0 e0c0 7c08 0607 070f 0f0f
0000 00c0 fcfe fefe 7fff ffff ff7f 0f01 e0e0 c0c0 c0c0 8080 223c 3c3c 3c3c 7c7c
7030 3838 3818 181c c020 3c3f 3f3f 3f3f 1f1f 1f9f cfc1 c0c0 fcfc fcf8 f8f0 3008
0000 0000 0101 0303 4078 ffff fffe fefc 7c7c 7818 0404 0810 0c02 0101 0000 0000
1f1f dfe7 e070 3038 c0c0 c080 8060 7c7f 1f1f 3f3f 3f7f 7f7f 07e7 f1f0 e0c0 8080
fcf8 f830 081f 3e7c 1020 2040 4080 0000 0000 0000 0000 0000 181c 0200 0000 0000
7f7e 3efc 440f 0100 0f00 030f 1f3e 1800 0003 c7f7 c108 0000 f8e0 c080 0000 0000
0000 0000 0000 0000
( 04 )
0000 0000 0000 0000 0000 0000 0000 0103 0001 1ce0 60ff f8f0 0087 0f3f fefc 7800
0080 3c1a 0d0f 0f0f 0000 0000 8040 808c 0000 0000 0000 0000 0000 0103 0307 070e
0f1f 3f9f 8301 0103 e0c0 8000 0080 f8fe 0e1f 3f3f 7f7f ffff 0fdf e7e0 c0c0 c0c0
8686 c3c3 213c 3f3f 0000 0080 c0c0 6000 0e1c 3c38 000f 0f0f 0307 070f 0f1f ffe3
fefe fcfc f8f8 f8f0 1f03 0000 0000 0001 8080 0070 feff ffff 3f3f 3f3f 3fff c780
0808 8884 8484 8482 0f0f 0f0f 1f1f 5f67 c0c0 c0c0 c080 8080 7000 1e1f 1f1f 3f3f
0101 03c3 fff8 f8f8 ffff ffff ff7f 0f01 8080 8080 0000 0000 627e 7c7c 7cfc f8f8
6030 3030 3018 1818 8060 7c7f 7f7f 7f7f 3f7f 7fff 8f81 8080 f0f0 f0e0 e0e0 0038
0101 0303 0307 070f c0f8 fffe fefc fcf8 f8f8 f818 040c 1810 0802 0301 0000 0000
3f3f ffc7 e060 7030 0000 0000 00e0 fdfe 3f7f 7fff ffff ff7e 0fff e1c0 8080 0001
f8f0 f020 387f fcf8 3020 6040 c080 0000 0000 0000 0000 0000 1818 0200 0000 0000
7c7c 7cb8 400f 0100 0e02 0f1f 3f7c d000 0307 cfe7 0318 8000 f0e0 c000 0000 0000
0000 0000 0000 0000
( 05 )
0000 0000 0000 0000 0000 0000 0001 0307 0001 18c0 e1fb f0e0 0087 1f7e fcf8 7010
0080 7012 0d1f 1f1f 0000 0000 0040 100c 0000 0000 0000 0000 0000 0103 0306 060c
0f3f 7f9e 0003 0707 c080 0000 0081 fbfc 3e7f 7fff ffff ffff 3fff c780 8080 0000
0c86 8783 637d 7e7e 0000 0080 80c0 6010 0c18 3830 080f 0f1f 0f0f 1f1f 3f3f 9f83
f8f8 f8f0 f0e0 e0e0 1f02 0101 0303 0307 0000 80f0 feff ffff 7e7f 7f7f 7f3f 0700
1808 080c 0c04 0406 1f1f 1f1f 1f1f 7f67 8080 8080 0000 0000 4030 3e7f 7f7f 7fff
0707 0fcf f3f0 e0e0 fffe fefe fe7c 0c02 0000 0000 0101 0101 e6fe f8f8 f8f8 f8f8
6020 2030 3010 1018 00e0 fcfe fefe fe7e ffff ff7f 0f01 0000 e0c0 c0c0 8080 40f8
0707 070f 0f1f 1f1f c1f9 fcfc f8f8 f0f0 f8f0 f010 0c1c 1830 0806 0301 0100 0000
7e7e bec6 c1e1 6130 0000 0101 01e3 fffc ffff ffff fffe fe7c 3fdf 8100 0000 0103
e0e0 c000 79fe fcf0 3060 60c0 c080 0000 0000 0000 0000 0000 3008 0200 0000 0000
f8f8 f8b0 480e 0100 080e 1f3f 7ef8 e100 070f df87 0318 8000 e0c0 8000 0000 0000
0000 0000 0000 0000
@bg
0000 0000 0000 0000 0000 0000 0307 0f3f
0001 1fff ffff ffff 00ff ffff ffff ffff
00c0 fcfe ffff ffff 0000 0000 80e0 f8fc
0000 0000 0000 0000 0000 0103 0307 070f
7fff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
feff ffff ffff ffff 0000 8080 c0e0 f0f0
0f1f 3f3f 3f3f 7f7f ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
f8f8 f8fc fcfc fcfe 7f7f 7f7f 7f7f 7f7f
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff fefe fefe fefe fefe
7f3f 3f3f 3f1f 1f1f ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
fefe fcfc fcfc f8f0 0f0f 0703 0101 0000
ffff ffff ffff ff7f ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff fffe f0e0 e0c0 c080 0000
0000 0000 0000 0000 3f1f 0701 0000 0000
ffff ffff 7f3f 0300 ffff ffff ffff ff00
ffff ffff fff8 8000 fcf0 e0c0 0000 0000
0000 0000 0000 0000
@shadow $0188

131
projects/examples/demos/bifurcan.tal

@ -1,131 +0,0 @@
( Bifurcan )
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &wheel $1
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
|80 @Controller &vector $2 &button $1 &key $1
|000
@last $1
@style $1
@center &x $2 &y $2
|100
@on-reset ( -> )
( | theme )
#0f3a .System/r DEO2
#0fda .System/g DEO2
#0faa .System/b DEO2
( | vectors )
;on-frame .Screen/vector DEO2
;on-mouse .Mouse/vector DEO2
;on-button .Controller/vector DEO2
( | find center )
.Screen/width DEI2 #01 SFT2 #33 SFT2 .center/x STZ2
.Screen/height DEI2 #01 SFT2 #33 SFT2 .center/y STZ2
( | background )
;tiles <cover-pattern>
<redraw>
BRK
@on-frame ( -> )
( | only draw once per second )
.DateTime/second DEI .last LDZ NEQk ?{ POP2 BRK }
.last STZ
POP <redraw>
BRK
@on-mouse ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;cursor-icn <update-cursor>
.Mouse/state DEI ?{ BRK }
select [ LIT2 00 -Mouse/state ] DEO
BRK
@on-button ( -> )
.Controller/button DEI ?{ BRK }
select [ LIT2 00 -Controller/button ] DEO
BRK
@select ( -- )
.style LDZ INC #03 DIVk MUL SUB .style STZ
;tiles [ LIT2 00 -style ] LDZ #40 SFT ADD2 <cover-pattern>
( >> )
(
@|drawing )
@<redraw> ( -- )
( | hrs )
[ .center/x LDZ2 #0018 SUB2 ] [ .center/y LDZ2 #0048 SUB2 ] .DateTime/hour DEI #0a DIV <draw-number>
[ .center/x LDZ2 #0008 ADD2 ] [ .center/y LDZ2 #0048 SUB2 ] .DateTime/hour DEI #0a DIVk MUL SUB <draw-number>
( | min )
[ .center/x LDZ2 #0018 SUB2 ] [ .center/y LDZ2 #0018 SUB2 ] .DateTime/minute DEI #0a DIV <draw-number>
[ .center/x LDZ2 #0008 ADD2 ] [ .center/y LDZ2 #0018 SUB2 ] .DateTime/minute DEI #0a DIVk MUL SUB <draw-number>
( | sec )
[ .center/x LDZ2 #0018 SUB2 ] [ .center/y LDZ2 #0018 ADD2 ] .DateTime/second DEI #0a DIV <draw-number>
[ .center/x LDZ2 #0008 ADD2 ] [ .center/y LDZ2 #0018 ADD2 ] .DateTime/second DEI #0a DIVk MUL SUB
@<draw-number> ( x* y* n -- )
,&digit STR
,&y STR2
,&x STR2
#0f00
&>loop ( -- )
( save-x ) DUP #03 DIVk MUL SUB #00 SWP #30 SFT2 [ LIT2 &x $2 ] ADD2 .Screen/x DEO2
( save-y ) DUP #03 DIV #00 SWP #30 SFT2 [ LIT2 &y $2 ] ADD2 .Screen/y DEO2
( get digit* ) DUP [ LIT &digit $1 ] DUP ADD #00 SWP ;digits ADD2 LDA2
( get bit ) ROT #0e SWP SUB SFT2 #0001 AND2
( set tile ) #30 SFT2 ;tiles ADD2
( set style ) .style LDZ #40 SFT #00 SWP ADD2 .Screen/addr DEO2
( draw ) [ LIT2 01 -Screen/sprite ] DEO
INC GTHk ?&>loop
POP2 JMP2r
@<cover-pattern> ( addr* -- )
.Screen/addr DEO2
.Screen/height DEI2 #03 SFT2 ,&h STR
POP .Screen/width DEI2 #03 SFT2 ,&w STR
POP [ LIT &h $1 ] #00
&>ver ( -- )
#00 OVR #30 SFT2 .Screen/y DEO2
[ LIT &w $1 ] #00
&>hor ( -- )
#00 OVR #30 SFT2 .Screen/x DEO2
[ LIT2 01 -Screen/sprite ] DEO
INC GTHk ?&>hor
POP2 INC GTHk ?&>ver
POP2 JMP2r
@<update-cursor> ( color addr* -- )
[ LIT2 00 -Screen/auto ] DEO
;fill-icn .Screen/addr DEO2
#40 <draw-cursor>
.Mouse/x DEI2 ,<draw-cursor>/x STR2
.Mouse/y DEI2 ,<draw-cursor>/y STR2
.Screen/addr DEO2
( >> )
@<draw-cursor> ( color -- )
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEO
JMP2r
(
@|assets )
@cursor-icn [ 80c0 e0f0 f8e0 1000 ]
@fill-icn [ ffff ffff ffff ffff ]
@digits [
7b6f 2492 73e7 73cf 5bc9 79cf 49ef 7249
7bef 7bc9 ]
@tiles [
0102 0408 1020 4080 8040 2010 0804 0201
0718 2040 4080 8080 0101 0102 0204 18e0
0808 0810 e304 0808 0808 0804 e310 0808 ]

250
projects/examples/demos/bitwise.tal

@ -1,250 +0,0 @@
( bitwise )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ]
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|50 @Audio2 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
|a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ]
|c0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables )
|0000
@a-frame
&x $2 &y $2 &x2 $2 &y2 $2
@b-frame
&x $2 &y $2 &x2 $2 &y2 $2
@input
&a $1 &b $1
@pointer
&x $2 &y $2
( program )
|0100 ( -> )
( theme )
#0fe7 .System/r DEO2
#0fce .System/g DEO2
#0f2c .System/b DEO2
;on-mouse .Mouse/vector DEO2
.Screen/width DEI2 #01 SFT2
DUP2 #0040 SUB2 .a-frame/x STZ2 DUP2 #0040 ADD2 .a-frame/x2 STZ2
DUP2 #0040 SUB2 .b-frame/x STZ2 #0040 ADD2 .b-frame/x2 STZ2
.Screen/height DEI2 #01 SFT2 #0020 SUB2
DUP2 #0010 SUB2 .a-frame/y STZ2 DUP2 .a-frame/y2 STZ2
DUP2 .b-frame/y STZ2 #0010 ADD2 .b-frame/y2 STZ2
;redraw JSR2
BRK
@on-mouse ( -> )
;draw-cursor JSR2
.Mouse/state DEI #00 NEQ JMP [ BRK ]
.Mouse/x DEI2 .Mouse/y DEI2 .a-frame ;within-rect JSR2
;on-touch-a JCN2
.Mouse/x DEI2 .Mouse/y DEI2 .b-frame ;within-rect JSR2
;on-touch-b JCN2
BRK
@on-touch-a ( -> )
.Mouse/x DEI2 .a-frame/x LDZ2 SUB2
#04 SFT2 NIP #07 SWP SUB STH
.input/a LDZ
#01 [ STHr #40 SFT ] SFT EOR
.input/a STZ
;redraw JSR2
#00 .Mouse/state DEO
BRK
@on-touch-b ( -> )
.Mouse/x DEI2 .b-frame/x LDZ2 SUB2
#04 SFT2 NIP #07 SWP SUB STH
.input/b LDZ
#01 [ STHr #40 SFT ] SFT EOR
.input/b STZ
;redraw JSR2
#00 .Mouse/state DEO
BRK
@redraw ( -- )
.a-frame/x LDZ2 .Screen/x DEO2
.a-frame/y LDZ2 .Screen/y DEO2
.input/a LDZ #01 ;draw-byte JSR2
.b-frame/x LDZ2 .Screen/x DEO2
.b-frame/y LDZ2 .Screen/y DEO2
.input/b LDZ #01 ;draw-byte JSR2
.b-frame/x LDZ2 .Screen/x DEO2
.Screen/y DEI2 #000d ADD2 .Screen/y DEO2
.input LDZ2 AND #03 ;draw-byte JSR2
.b-frame/x LDZ2 .Screen/x DEO2
.Screen/y DEI2 #000d ADD2 .Screen/y DEO2
.input LDZ2 ORA #03 ;draw-byte JSR2
.b-frame/x LDZ2 .Screen/x DEO2
.Screen/y DEI2 #000d ADD2 .Screen/y DEO2
.input LDZ2 EOR #03 ;draw-byte JSR2
( labels )
#05 .Screen/auto DEO
.b-frame/x LDZ2 #0020 SUB2 .Screen/x DEO2
;names-icn/and .Screen/addr DEO2
.b-frame/y2 LDZ2 #0004 ADD2 .Screen/y DEO2
,&draw-label JSR
.b-frame/y2 LDZ2 #0014 ADD2 .Screen/y DEO2
,&draw-label JSR
.b-frame/y2 LDZ2 #0024 ADD2 .Screen/y DEO2
,&draw-label JSR
#00 .Screen/auto DEO
JMP2r
&draw-label
.b-frame/x LDZ2 #0020 SUB2 .Screen/x DEO2
#03 .Screen/sprite DEOk DEOk DEO
JMP2r
@draw-byte ( value -- )
STH STH
#0800
&loop
#07 OVR SUB
STHkr SWP SFT #01 AND OVRr STHr ;draw-bit JSR2
INC GTHk ,&loop JCN
POP2
.Screen/y DEI2 #0003 ADD2 .Screen/y DEO2
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
STHr ;draw-hex JSR2
POPr
JMP2r
@draw-bit ( value color -- )
STH STH
#05 .Screen/auto DEO
;button-icns/off [ #00 STHkr #50 SFT ADD2 ] .Screen/addr DEO2
OVRr STHr .Screen/sprite DEO
OVRr STHr .Screen/sprite DEO
.Screen/y DEI2 #0008 ADD2 .Screen/y DEO2
.Screen/x DEI2 #0010 SUB2 .Screen/x DEO2
OVRr STHr .Screen/sprite DEO
OVRr STHr .Screen/sprite DEO
#00 .Screen/auto DEO
.Screen/y DEI2 #0008 SUB2 .Screen/y DEO2
POP2r
JMP2r
@draw-hex ( value -- )
#01 .Screen/auto DEO
DUP #04 SFT ,&draw JSR
#0f AND ,&draw JSR
#01 .Screen/auto DEO
JMP2r
&draw
#00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
JMP2r
@draw-cursor ( -- )
( clear last cursor )
;cursor .Screen/addr DEO2
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#40 .Screen/sprite DEO
( record pointer positions )
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
( colorize on state )
#42 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/sprite DEO
JMP2r
@within-rect ( x* y* rect -- flag )
STH
( y < rect.y1 ) DUP2 STHkr INC INC LDZ2 LTH2 ,&skip JCN
( y > rect.y2 ) DUP2 STHkr #06 ADD LDZ2 GTH2 ,&skip JCN
SWP2
( x < rect.x1 ) DUP2 STHkr LDZ2 LTH2 ,&skip JCN
( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ,&skip JCN
POP2 POP2 POPr
#01
JMP2r
&skip
POP2 POP2 POPr
#00
JMP2r
@cursor
80c0 e0f0 f8e0 1000
@button-icns
&off
3f40 8080 8080 8080
f804 0202 0202 0202
8080 8080 8040 3f00
0202 0202 0204 f800
&on
3f40 9fbf bfbf bfbf
f804 f2fa fafa fafa
bfbf bfbf 9f40 3f00
fafa fafa f204 f800
@names-icn
&and
fc02 027e 8286 fa00
bcc2 8282 8282 8200
fc82 8282 8282 fc00
&ora
7c82 8282 8282 7c00
fc82 82fc 8282 8200
fc02 027e 8286 fa00
&eor
8282 4438 4482 8200
7c82 8282 8282 7c00
fc82 82fc 8282 8200
@font-hex ( 0-F )
007c 8282 8282 827c 0030 1010 1010 1010
007c 8202 7c80 80fe 007c 8202 1c02 827c
000c 1424 4484 fe04 00fe 8080 7c02 827c
007c 8280 fc82 827c 007c 8202 1e02 0202
007c 8282 7c82 827c 007c 8282 7e02 827c
007c 8202 7e82 827e 00fc 8282 fc82 82fc
007c 8280 8080 827c 00fc 8282 8282 82fc
007c 8280 f080 827c 007c 8280 f080 8080

221
projects/examples/demos/bunnymark.tal

@ -1,221 +0,0 @@
( bunnymark.tal )
( November 2021, Kira Oakley )
( March 2022, Devine Lu Linvega )
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|80 @Controller &vector $2 &button $1 &key $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &wheel $1
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
|0000
@frames $2
@last $1
|0100
@on-reset ( -> )
( | theme )
#2ce9 .System/r DEO2
#01c0 .System/g DEO2
#2ce5 .System/b DEO2
( | interrupts )
;on-frame .Screen/vector DEO2
( | fps label )
.Screen/width DEI2 #0046 SUB2 .Screen/x DEO2
#0008 .Screen/y DEO2
;text/fps #42 <draw-str>
( | bunnies label )
#0004 .Screen/x DEO2
;text/bunnies #42 <draw-str>
( | instructions label )
.Screen/width DEI2 #01 SFT2 #0050 SUB2 .Screen/x DEO2
;text/instructions #43 <draw-str>
#0028 #0008 #0000 <draw-dec>
( | seed prng )
prng-init BRK
@on-frame ( -> )
.frames LDZ2k INC2 ROT STZ2
.DateTime/second DEI .last LDZ EQU ?{
.DateTime/second DEI .last STZ
.Screen/width DEI2 #002b SUB2 #0008 .frames LDZ2 <draw-dec>
#0000 .frames STZ2 }
( | mouse handling )
.Mouse/state DEI
( ) DUP #01 NEQ ?{ add-bunny }
( ) #02 LTH ?{ remove-bunny }
( | controller handling )
.Controller/button DEI
( ) DUP #01 NEQ ?{ add-bunny }
( ) #02 LTH ?{ remove-bunny }
( | clear )
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
[ LIT2 80 -Screen/pixel ] DEO
;sprite/length LDA2 #0000
&loop ( -- )
EQU2k ?&bail
DUP2 <draw-bunny>
INC2 !&loop
&bail ( -- )
POP2 POP2 BRK
@add-bunny ( -- )
;sprite/length LDA2
( | cap bunny count at 65535 )
DUP2 #ffff EQU2 ?&bail
( | compute the offset to the beginning of this new bunny's data )
DUP2 #30 SFT2 ;sprite/array ADD2
( | populate the new bunny's x/y/xvel/yvel with random values )
#00 rand OVR2 STA2
rand #1f AND rand OVR2 INC2 INC2 STA2
#00 rand #7f AND OVR2 #0004 ADD2 STA2
#00 rand #7f AND OVR2 #0006 ADD2 STA2
( | pop ptr to bunny data )
POP2
( | write new increased array length )
INC2 DUP2 ;sprite/length STA2
( | update label )
STH2k #0028 #0008 STH2r <draw-dec>
&bail ( pop sprite/length )
POP2 JMP2r
@remove-bunny ( -- )
;sprite/length LDA2
( don't let length go below 0 ) ORAk #00 EQU ?&bail
#0001 SUB2 DUP2 ;sprite/length STA2
( update label ) STH2k #0028 #0008 STH2r <draw-dec>
&bail POP2 JMP2r
(
@|drawing )
@<draw-bunny> ( idx -- )
( | compute the offset to the beginning of this bunny's data )
#30 SFT2 ;sprite/array ADD2
( | move the sprite by its velocity )
LDA2k OVR2 #0004 ADD2 LDA2 ADD2 OVR2 STA2
INC2k INC2 LDA2 OVR2 #0006 ADD2 LDA2 ADD2 OVR2 INC2 INC2 STA2
( | check for right wall collision + bounce x )
DUP2 #0004 ADD2 LDA2 #0f SFT2 #0001 EQU2 ?&skip-max-x
LDA2k #05 SFT2 #0008 ADD2 .Screen/width DEI2 LTH2 ?&skip-max-x
DUP2 #0004 ADD2 LDA2 #ffff MUL2 OVR2 #0004 ADD2 STA2
&skip-max-x ( check for left wall collision + bounce x )
LDA2k #0f SFT2 #0000 EQU2 ?&skip-min-x
DUP2 #0004 ADD2 LDA2 #ffff MUL2 OVR2 #0004 ADD2 STA2
&skip-min-x ( check for bottom wall collision + bounce y )
DUP2 #0006 ADD2 LDA2 #0f SFT2 #0001 EQU2 ?&skip-max-y
INC2k INC2 LDA2 #05 SFT2 #0010 ADD2 .Screen/height DEI2 LTH2 ?&skip-max-y
DUP2 #0006 ADD2 LDA2 #ffff MUL2 OVR2 #0006 ADD2 STA2
!&skip-gravity
&skip-max-y ( check for top wall collision + bounce x )
INC2k INC2 LDA2 #0f SFT2 #0000 EQU2 ?&skip-min-y
DUP2 #0006 ADD2 LDA2 #ffff MUL2 OVR2 #0006 ADD2 STA2
!&skip-gravity
&skip-min-y ( apply gravity )
DUP2 #0006 ADD2 LDA2 #0004 ADD2 OVR2 #0006 ADD2 STA2
&skip-gravity ( draw the sprite )
( top ) LDA2k #05 SFT2 .Screen/x DEO2
INC2 INC2 LDA2 #05 SFT2 .Screen/y DEO2
( draw ) [ LIT2 15 -Screen/auto ] DEO
;bunny-chr .Screen/addr DEO2
[ LIT2 85 -Screen/sprite ] DEO
[ LIT2 00 -Screen/auto ] DEO
JMP2r
@<draw-str> ( x* y* text* color -- )
,&t STR
[ LIT2 01 -Screen/auto ] DEO
&loop ( -- )
LDAk #20 SUB #00 SWP #30 SFT2 ;font ADD2 .Screen/addr DEO2
[ LIT2 &t $1 -Screen/sprite ] DEO
INC2 LDAk ?&loop
POP2 JMP2r
@<draw-dec> ( x* y* num* -- )
[ LIT2 01 -Screen/auto ] DEO
SWP2 .Screen/y DEO2
SWP2 .Screen/x DEO2
#2710 DIV2k DUP <draw-digit>
MUL2 SUB2 #03e8 DIV2k DUP <draw-digit>
MUL2 SUB2 #0064 DIV2k DUP <draw-digit>
MUL2 SUB2 NIP #0a DIVk DUP <draw-digit>
MUL SUB <draw-digit>
[ LIT2 00 -Screen/auto ] DEO
JMP2r
@<draw-digit> ( num -- )
#30 SFT #00 SWP ;font/num ADD2 .Screen/addr DEO2
[ LIT2 41 -Screen/sprite ] DEO
JMP2r
(
@|random )
@prng-init ( -- )
[ LIT2 00 -DateTime/second ] DEI [ LIT2 00 -DateTime/minute ] DEI #60 SFT2 EOR2 [ LIT2 00 -DateTime/hour ] DEI #c0 SFT2 EOR2 ,prng/x STR2
[ LIT2 00 -DateTime/hour ] DEI #04 SFT2 [ LIT2 00 -DateTime/day ] DEI #10 SFT2 EOR2 [ LIT2 00 -DateTime/month ] DEI #60 SFT2 EOR2 .DateTime/year DEI2 #a0 SFT2 EOR2 ,prng/y STR2
JMP2r
@prng ( -- number* )
[ LIT2 &x $2 ] DUP2 #50 SFT2 EOR2 DUP2 #03 SFT2 EOR2 [ LIT2 &y $2 ] DUP2 ,&x STR2
DUP2 #01 SFT2 EOR2 EOR2 ,&y STR2k POP JMP2r
@rand ( -- number )
prng ADD JMP2r
( static string data )
(
@|assets )
@text &fps "FPS: $1
&bunnies "BUNS: $1
&instructions "CLICK 20 "TO 20 "ADD 20 "BUNNIES! $1
@font ( atari8.uf1 )
[
0000 0000 0000 0000 6060 6060 6000 6000
6666 6600 0000 0000 006c fe6c 6cfe 6c00
183e 603c 067c 1800 0066 6c18 3066 4600
386c 3870 decc 7600 6060 6000 0000 0000
0e1c 1818 181c 0e00 7038 1818 1838 7000
0066 3cff 3c66 0000 0018 187e 1818 0000
0000 0000 0030 3060 0000 007e 0000 0000
0000 0000 0018 1800 0206 0c18 3060 4000 ] &num [
3c66 6e76 6666 3c00 1838 1818 1818 7e00
3c66 060c 1830 7e00 7e0c 180c 0666 3c00
0c1c 3c6c 7e0c 0c00 7e60 7c06 0666 3c00
3c60 607c 6666 3c00 7e06 0c18 3030 3000
3c66 663c 6666 3c00 3c66 663e 060c 3800
0060 6000 6060 0000 0030 3000 3030 6000
0c18 3060 3018 0c00 0000 7e00 007e 0000
6030 180c 1830 6000 3c66 060c 1800 1800
3c66 6e6a 6e60 3e00 183c 6666 7e66 6600
7c66 667c 6666 7c00 3c66 6060 6066 3c00
786c 6666 666c 7800 7e60 607c 6060 7e00
7e60 607c 6060 6000 3e60 606e 6666 3e00
6666 667e 6666 6600 7830 3030 3030 7800
0606 0606 0666 3c00 666c 7870 786c 6600
6060 6060 6060 7e00 c6ee fed6 c6c6 c600
6676 7e7e 6e66 6600 3c66 6666 6666 3c00
7c66 667c 6060 6000 3c66 6666 766c 3600
7c66 667c 6c66 6600 3c66 603c 0666 3c00
7e18 1818 1818 1800 6666 6666 6666 3e00
6666 6666 663c 1800 c6c6 c6d6 feee c600
6666 3c18 3c66 6600 6666 663c 1818 1800
7e06 0c18 3060 7e00 7860 6060 6060 7800 ]
@fill-icn [ ffff ffff ffff ffff ]
@bunny-chr [
2466 6600 2424 003c 4200 007e 7e7e 7e7e
1818 3c3c 1800 0000 ff66 4242 667e 4242 ]
(
@|memory )
@sprite &length $2
&array &x 0600 &y 0500 &xvel 0060 &yvel 0010

45
projects/examples/demos/circles.tal

@ -1,45 +0,0 @@
( draw a circle at the center of the screen )
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|100
@on-reset ( -> )
#f0ff .System/r DEO2
#f0f6 .System/g DEO2
#f0f2 .System/b DEO2
#300c
&>l ( -- )
STHk
( x ) #00 STHkr DUP2 MUL2 #03 SFT2 #00c0 ADD2
( y ) #00a0
( radius ) #00 #30 STHkr SUB #20 SFT
( color ) STHr #01 AND INC <draw-circle>
INC GTHk ?&>l
POP2 BRK
@<draw-circle> ( x* y* r* color -- )
,&color STR
DUP2k MUL2 ,&r STR2
[ LIT2r 0000 ] STH2
,&y STR2
,&x STR2
STH2kr SUB2kr STH2r INC2
&>y ( -- )
DUP2 [ LIT2 &y $2 ] ADD2 .Screen/y DEO2
STH2kr SUB2kr STH2r INC2
&>x ( -- )
( x ) ROT2k ABS2-SQ
( y ) SWP2 ABS2-SQ
( + ) ADD2 NIP2 [ LIT2 &r $2 ] GTH2 ?{
DUP2 [ LIT2 &x $2 ] ADD2 .Screen/x DEO2
[ LIT2 &color 02 -Screen/pixel ] DEO }
( ) INC2 NEQ2k ?&>x
POP2 POP2
( ) INC2 NEQ2k ?&>y
POP2 POP2 POP2r POP2r JMP2r
@ABS2-SQ ( a* -- res* )
DUP2k #1f SFT2 MUL2 SUB2 DUP2 MUL2 JMP2r

127
projects/examples/demos/cube3d.tal

@ -1,127 +0,0 @@
( Cube3d: Just a cube, y'know )
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|000
@cube &v0 $8 &v4 $8
@center &x $2 &y $2
@timer $1
|100
@on-reset ( -> )
( | theme )
#4fcd .System/r DEO2
#4fc3 .System/g DEO2
#dfc2 .System/b DEO2
( | center )
.Screen/width DEI2 #01 SFT2 #0040 SUB2 .center/x STZ2
.Screen/height DEI2 #01 SFT2 #0040 SUB2 .center/y STZ2
( | begin. )
;on-frame .Screen/vector DEO2
@on-frame ( -> )
[ LIT &f $1 ] INCk ,&f STR
DUP #01 AND ?{ POP BRK }
#01 SFT .timer STZ
( | clear )
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
[ LIT2 80 -Screen/pixel ] DEO
( | draw )
<draw-cube>
BRK
@<draw-cube> ( frame -- )
( | create box )
#0800
&>loop ( -- )
STHk [ LIT2 00 -timer ] LDZ #00 STHkr INC #07 AND #60 SFT ADD2 #00ff AND2 ;table ADD2 LDA #01 SFT #00 .timer LDZ #00 STHkr #60 SFT ADD2 #00ff AND2 ;table ADD2 LDA #02 SFT #00 STHkr #62 SFT2 ADD2 .cube/v0 STHr DUP ADD ADD STZ2
INC GTHk ?&>loop
POP2
( | vertices )
#0800
&>ver-loop ( -- )
DUP DUP ADD LDZ2 <draw-vertex>
INC GTHk ?&>ver-loop
POP2
( lines ) #0400
&>line-loop ( -- )
STHk .cube/v0 STHkr DUP ADD ADD .cube/v0 STHkr INC #03 AND DUP ADD ADD <draw-edge>
.cube/v0 STHkr DUP ADD ADD .cube/v4 STHkr DUP ADD ADD <draw-edge>
.cube/v4 STHkr DUP ADD ADD .cube/v4 STHr INC #03 AND DUP ADD ADD <draw-edge>
INC GTHk ?&>line-loop
POP2 JMP2r
@<draw-edge> ( a b -- )
STH
STH
( ) #00 STHkr LDZ .center/x LDZ2 ADD2
( ) #00 STHr INC LDZ .center/y LDZ2 ADD2
( ) #00 STHkr LDZ .center/x LDZ2 ADD2
( ) #00 STHr INC LDZ .center/y LDZ2 ADD2 #05 !<draw-line>
@<draw-vertex> ( x y -- )
#00 SWP #0004 SUB2 .center/y LDZ2 ADD2 .Screen/y DEO2
#00 SWP #0003 SUB2 .center/x LDZ2 ADD2 .Screen/x DEO2
;&icn .Screen/addr DEO2
[ LIT2 05 -Screen/sprite ] DEO
JMP2r
&icn [ 0000 387c 7c7c 3800 ]
@<draw-line> ( x1* y1* x2* y2* color -- )
,&color STR
,&y STR2
,&x STR2
,&y2 STR2
,&x2 STR2
,&x LDR2 ,&x2 LDR2 SUB2 abs2 ,&dx STR2
#0000 ,&y LDR2 ,&y2 LDR2 SUB2 abs2 SUB2 ,&dy STR2
#ffff [ LIT2 00 _&x2 ] LDR2 ,&x LDR2 lts2 DUP2 ADD2 ADD2 ,&sx STR2
#ffff [ LIT2 00 _&y2 ] LDR2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2
[ LIT2 &dx $2 ] [ LIT2 &dy $2 ] ADD2 STH2
&while ( -- )
[ LIT2 &x2 $2 ] DUP2 .Screen/x DEO2
[ LIT2 &x $2 ] EQU2 [ LIT2 &y2 $2 ] DUP2 .Screen/y DEO2
[ LIT2 &y $2 ] EQU2 [ LIT2 &color $1 -Screen/pixel ] DEO
AND ?&end
STH2kr DUP2 ADD2 DUP2 ,&dy LDR2 lts2 ?&skipy
STH2r ,&dy LDR2 ADD2 STH2
,&x2 LDR2 [ LIT2 &sx $2 ] ADD2 ,&x2 STR2
&skipy ( -- )
,&dx LDR2 gts2 ?&while
STH2r ,&dx LDR2 ADD2 STH2
,&y2 LDR2 [ LIT2 &sy $2 ] ADD2 ,&y2 STR2
!&while
&end POP2r JMP2r
@abs2 ( a* -- f )
DUP2 #0f SFT2 EQU ?{ #0000 SWP2 SUB2 }
JMP2r
@lts2 ( a* b* -- f )
#8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r
@gts2 ( a* b* -- f )
#8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 JMP2r
@table ( 256 xy )
[
f7f8 f9fa fbfc fcfd fefe ffff ffff ffff
ffff ffff fffe fefd fcfc fbfa f9f8 f7f6
f5f3 f2f0 efed ecea e8e6 e4e2 e0de dcda
d8d5 d3d1 cecc c9c7 c4c1 bfbc b9b6 b3b0
aeab a8a5 a29f 9c98 9592 8f8c 8986 8380
7c79 7673 706d 6a67 6360 5d5a 5754 514f
4c49 4643 403e 3b38 3633 312e 2c2a 2725
2321 1f1d 1b19 1715 1312 100f 0d0c 0a09
0807 0605 0403 0302 0101 0000 0000 0000
0000 0000 0001 0102 0303 0405 0607 0809
0a0c 0d0f 1012 1315 1719 1b1d 1f21 2325
272a 2c2e 3133 3638 3b3e 4043 4649 4c4f
5154 575a 5d60 6367 6a6d 7073 7679 7c7f
8386 898c 8f92 9598 9c9f a2a5 a8ab aeb0
b3b6 b9bc bfc1 c4c7 c9cc ced1 d3d5 d8da
dcde e0e2 e4e6 e8ea eced eff0 f2f3 f5f6 ]

236
projects/examples/demos/drool.tal

@ -1,236 +0,0 @@
(
100r animated logo splash screen
by Andrew Alderwick, 2021
based on artwork by Hundred Rabbits
)
( devices )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|c0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables )
|0000
( program )
|0100 @Reset ( -> )
( seed prng (must be nonzero) )
#00 .DateTime/second DEI
#00 .DateTime/minute DEI #60 SFT2 EOR2
#00 .DateTime/hour DEI #c0 SFT2 EOR2 ;prng/x STA2
#00 .DateTime/hour DEI #04 SFT2
#00 .DateTime/day DEI DUP2 ADD2 EOR2
#00 .DateTime/month DEI #60 SFT2 EOR2
.DateTime/year DEI2 #a0 SFT2 EOR2 ;prng/y STA2
;prng/x LDA2 ;prng/y LDA2 EOR2
LIT2r =rabbits #0f05 &loop-x
#0f05 &loop-y
ROTk SWP STH2kr STA2 POP
INC2r INC2r
INC
GTHk ,&loop-y JCN
POP2
INC
GTHk ,&loop-x JCN
POP2 POP2r
( fall through )
@repeat
;init-occupancy JSR2
#00 ;precalc-frame STA
;precalculate-vector .Screen/vector DEO2
BRK
@init-occupancy ( -- )
#1400 &loop-y
#1400 &loop-x
ROTk #00 ;set-occupied JSR2 POP
INC
GTHk ,&loop-x JCN
POP2
INC
GTHk ,&loop-y JCN
POP2
;rabbits
DUP2 #00c8 ADD2 SWP2 &loop-rabbits
LDA2k #01 ;set-occupied JSR2
INC2 INC2
GTH2k ,&loop-rabbits JCN
POP2 POP2
JMP2r
@precalculate-vector ( -> )
,precalculate JSR BRK
@precalculate ( -- )
;rabbits #00c8 OVR ,precalc-frame LDR MUL2 ADD2 ( first rabbit address )
DUP2 #00c8 ADD2 SWP2 &loop-rabbits
DUP2 ,move-rabbit JSR
INC2 INC2
GTH2k ,&loop-rabbits JCN
POP2 POP2
,precalc-frame LDR INC DUP ,precalc-frame STR
#05 EQU JMP JMP2r
;display-init JSR2
;display .Screen/vector DEO2
JMP2r
@precalc-frame $1
@set-occupied ( x y value -- )
STH
#00 SWP #0014 MUL2 ( x yoffset* / value )
ROT #00 SWP ADD2 ( offset* / value )
;occupied ADD2 STH2 STAr
JMP2r
@move-rabbit ( addr* -- )
STH2k LDA2 ( x y / addr* )
DUP2 #00 ,set-occupied JSR
;&possible-moves ( x y possible* / addr* )
OVR2 #01 SUB ,&check-move JSR ( up )
OVR2 INC INC ,&check-move JSR ( down )
OVR2 #0100 SUB2 ,&check-move JSR ( left )
OVR2 #0100 ADD2 ,&check-move JSR ( right )
;&possible-moves SUB2 ( x y num-possible-times-2* / addr* )
DUP ,&can-move JCN
POP2
&write ( x y / addr* )
DUP2 #01 ,set-occupied JSR
STH2r #00c8 ADD2 STA2
JMP2r
&can-move ( x y num-possible-times-2* / addr* )
NIP2 ( num-possible-times-2* / addr* )
,prng JSR SWP2 DIV2k MUL2 SUB2 #fe AND ( chosen-move* / addr* )
;&possible-moves ADD2 LDA2
,&write JMP
&check-move ( possible* new-x new-y -- possible'* )
DUP2 ,get-occupied JSR ,&blocked JCN
OVR2r LIT2r 00c8 SUB2r ( possible* new-x new-y / previous-frame-addr* )
&check-history-loop
;rabbits INC2 STH2kr GTH2 ,&history-okay JCN
DUP2 STH2kr LDA2 EQU2 ,&history-clash JCN
LIT2r 00c8 SUB2r
,&check-history-loop JMP
&history-okay
POP2r
OVR2 STA2 INC2 INC2
JMP2r
&history-clash ( possible* new-x new-y / previous-frame-addr* )
POP2r
&blocked ( possible* new-x new-y )
POP2
JMP2r
&possible-moves $10
@get-occupied ( x y -- value )
#00 SWP #0014 MUL2 ( x yoffset* )
ROT #00 SWP ADD2 ( offset* )
;occupied ADD2 LDA
JMP2r
@prng ( -- number* )
LIT2 &x $2
DUP2 #50 SFT2 EOR2
DUP2 #03 SFT2 EOR2
LIT2 &y $2 DUP2 ,&x STR2
DUP2 #01 SFT2 EOR2 EOR2
,&y STR2k POP
JMP2r
@display-init ( -- )
.Screen/width DEI2 #01 SFT2 #0050 SUB2 ;display-rabbit/xoffset STA2
.Screen/height DEI2 #01 SFT2 #0050 SUB2 ;display-rabbit/yoffset STA2
;rabbit-sprite .Screen/addr DEO2
JMP2r
@display-rabbit ( color n counter -- )
OVR LTHk ,&finish JCN
SUB ( color n timeline )
DUP #63 GTH ,&start JCN
#17 DIVk STHk MUL SUB ( color n stage-timeline / frame )
DUP #07 GTH ,&static JCN
( rabbit is in-between two frames )
#08 OVR SUB ,&from-weight STR
,&to-weight STR ( color n / frame )
#00 SWP DUP2 ADD2 ;rabbits ADD2 #00c8 #00 STHr MUL2 ADD2 ( color from-addr* )
LDA2k STH2 #00c8 ADD2 LDA2
&draw ( color to-x to-y / from-x from-y )
STHr ,&mix JSR LIT2 &yoffset $2 ADD2 .Screen/y DEO2
STHr ,&mix JSR LIT2 &xoffset $2 ADD2 .Screen/x DEO2
.Screen/sprite DEO
JMP2r
&mix ( to-z from-z -- mixed* )
#00 SWP LIT2 00 &from-weight 00 MUL2 ( to-n from-mixed* )
ROT #00 SWP LIT2 00 &to-weight 00 MUL2 ADD2
JMP2r
&finish ( color n counter n )
POP
LITr ff ,&static JMP
&start ( color n counter )
LITr 04
&static ( color n counter / frame )
INCr
POP
#00 SWP DUP2 ADD2 ;rabbits ADD2 #00c8 #00 STHr MUL2 ADD2
LDA2 STH2k
,&draw JMP
@display-counter $1
@display ( -> )
,display-counter LDR #01 SUB DUP ,display-counter STR
DUP #f0 LTH ,&skip-palette JCN
#ff OVR SUB #00
DUP2 .System/r DEO2
DUP2 .System/g DEO2
.System/b DEO2
&skip-palette
INCk #0000 &clear-loop
ROTk ;display-rabbit JSR2
INC
DUP #64 LTH ,&clear-loop JCN
POP2 POP
#0500 &draw-loop
ROTk ;display-rabbit JSR2
INC
DUP #64 LTH ,&draw-loop JCN
POP2
,&no-finish JCN
;sunset .Screen/vector DEO2
&no-finish
BRK
@sunset ( -> )
;display-counter LDA #02 SUB DUP ;display-counter STA
DUP #1f GTH ,&skip-palette JCN
DUP #01 SFT #00
DUP2 .System/r DEO2
DUP2 .System/g DEO2
.System/b DEO2
#6400 &draw-loop
#05 OVR #00 ;display-rabbit JSR2
INC
GTHk ,&draw-loop JCN
POP2
&skip-palette
,&no-finish JCN
;repeat JMP2
&no-finish
BRK
@rabbit-sprite 003c 7e7e 7e7e 3c00
@occupied $190
@rabbits

56
projects/examples/demos/dvd.tal

@ -1,56 +0,0 @@
( DVD Bounce )
|00 @System/vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen/vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|100
@on-reset ( -> )
( | theme )
#4cfd .System/r DEO2
#4cf3 .System/g DEO2
#dcf2 .System/b DEO2
;dvd/on-frame .Screen/vector DEO2
( collision x* ) .Screen/width DEI2 DUP2 #0020 SUB2 ,dvd/cox STR2
#01 SFT2
( collision y* ) .Screen/height DEI2 DUP2 #0010 SUB2 ,dvd/coy STR2
#01 SFT2 dvd/<set-pos>
BRK
@dvd/on-frame ( -> )
( | x )
,&x LDR2
( left ) ORAk ?{ LIT2 ADD2 _&opx STR }
( right ) DUP2 LIT2 &cox $2 NEQ2 ?{ LIT2 SUB2 _&opx STR }
#0001 [ &opx ADD2 ]
( | y )
,&y LDR2
( top ) ORAk ?{ LIT2 ADD2 _&opy STR }
( bottom ) DUP2 LIT2 &coy $2 NEQ2 ?{ LIT2 SUB2 _&opy STR }
#0001 [ &opy ADD2 ] dvd/<move>
BRK
@dvd/<move> ( x* y* -- )
#00 /<draw>
( >> )
@dvd/<set-pos> ( x* y* -- )
,&y STR2
,&x STR2
#01
( >> )
@dvd/<draw> ( color -- )
[ LIT2 36 -Screen/auto ] DEO
;&sprite-icn .Screen/addr DEO2
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEOk DEO
JMP2r
@dvd/sprite-icn [
001f 3f38 3838 787f 00fe fe7e 7777 e3c3
000f 1f3b 7b77 e7c7 00fc fe8f 8707 0efc
7f00 000f ff7f 0700 0301 00ff f0f8 ff00
8700 00ff 7f7f ff00 f000 00e0 fcfc 8000 ]

71
projects/examples/demos/hilbert.tal

@ -1,71 +0,0 @@
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|100
@on-reset ( -> )
( | theme )
#6f04 .System/r DEO2
#7f00 .System/g DEO2
#8f00 .System/b DEO2
( | screen size )
#00c0
( ) DUP2 .Screen/width DEO2
( ) .Screen/height DEO2
( | pen )
#0020
( ) DUP2 .Screen/x DEO2
( ) .Screen/y DEO2
( | vector )
;on-frame .Screen/vector DEO2
BRK
@on-frame ( -> )
[ LIT2 &f $2 ] INC2 DUP2 ,&f STR2
( | end )
DUP2 #0400 LTH2 ?{
POP2 #0000 .Screen/vector DEO2
BRK }
d2xy
( | draw line )
.Screen/y DEI2 diff ,&y STR2
.Screen/x DEI2 diff ,&x STR2
#0400
&>l ( -- )
.Screen/x DEI2k [ LIT2 &x $2 ] ADD2 ROT DEO2
.Screen/y DEI2k [ LIT2 &y $2 ] ADD2 ROT DEO2
[ LIT2 01 -Screen/pixel ] DEO
INC GTHk ?&>l
POP2 BRK
@diff ( a* b* -- dir* )
EQU2k ?{ LTH2 ?{ #0001 JMP2r }
#ffff JMP2r }
POP2 POP2 #0000 JMP2r
@d2xy ( d* -- x* y* )
,&t STR2
#0000
( ) DUP2 ,&x STR2
( ) ,&y STR2
#2001
&>l ( -- )
#00 OVR STH2
[ LIT2 &t $2 ] DUP2 #02 SFT2 ,&t STR2
( ) DUP2 #01 SFT2 #0001 AND2 DUP2 ,&rx STR2
( ) EOR2 #0001 AND2 ,&ry STR2
[ LIT2 &x $2 ] [ LIT2 &y $2 ] [ LIT2 &ry $2 ]
( ) DUP2r [ LIT2r 0001 ] SUB2r
( | rot )
ORA ?{
[ LIT2 &rx $2 ] #0001 NEQ2 ?{
( rx-n-1 ) SWP2 STH2kr SWP2 SUB2
( ry-n-1 ) SWP2 STH2kr SWP2 SUB2 }
( swap ) SWP2 }
POP2r
( ) STH2kr ,&ry LDR2 MUL2 ADD2 ,&y STR2
( ) STH2r ,&rx LDR2 MUL2 ADD2 ,&x STR2
DUP ADD GTHk ?&>l
POP2
( ) ,&x LDR2 #20 SFT2 #0020 ADD2
( ) ,&y LDR2 #20 SFT2 #0020 ADD2 JMP2r

221
projects/examples/demos/life.tal

@ -1,221 +0,0 @@
( uxnemu life.rom )
( Any live cell with fewer than two live neighbours dies, as if by underpopulation. )
( Any live cell with two or three live neighbours lives on to the next generation. )
( Any live cell with more than three live neighbours dies, as if by overpopulation. )
( Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. )
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|30 @Audio0 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1
|80 @Controller &vector $2 &button $1 &key $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &wheel $1
|000
@world &count $2
@anchor &x $2 &y $2 &x2 $2 &y2 $2
|100
@on-reset ( -> )
( | theme )
#02cf .System/r DEO2
#02ff .System/g DEO2
#024f .System/b DEO2
( | resize )
#00c0 DUP2 .Screen/width DEO2
.Screen/height DEO2
( | vectors )
;on-frame .Screen/vector DEO2
;on-mouse .Mouse/vector DEO2
;on-control .Controller/vector DEO2
( | glider )
#0703 <set-cell>
#0704 <set-cell>
#0504 <set-cell>
#0705 <set-cell>
#0605 <set-cell>
( | center )
.Screen/width DEI2 #01 SFT2 #0040 SUB2 DUP2 .anchor/x STZ2
#007e ADD2 .anchor/x2 STZ2
.Screen/height DEI2 #01 SFT2 #0040 SUB2 DUP2 .anchor/y STZ2
#007e ADD2 .anchor/y2 STZ2
BRK
@on-frame ( -> )
[ LIT2 00 -Mouse/state ] DEI EQU ?{ BRK }
#0000 .world/count STZ2
[ LIT &f $1 ] INCk ,&f STR
( ) #03 AND #00 EQU ?{ BRK }
<run>
BRK
@on-mouse ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #42 ADD ;cursor-icn <update-cursor>
( | on touch in rect )
.Mouse/state DEI ?{ BRK }
.Mouse/x DEI2 .Mouse/y DEI2 .anchor within-rect ?{ BRK }
( | paint )
.Mouse/x DEI2 .anchor/x LDZ2 SUB2 #01 SFT NIP
( ) .Mouse/y DEI2 .anchor/y LDZ2 SUB2 #01 SFT NIP <set-cell>
<redraw>
BRK
@on-control ( -> )
.Controller/key DEI
( ) DUP #20 NEQ ?{
#0000 ;on-frame .Screen/vector DEI2 ORA ?{ SWP2 }
POP2 .Screen/vector DEO2 }
( ) #1b NEQ ?{ ;MMU/clear1 .System/expansion DEO2 }
BRK
(
@|core )
@<run> ( -- )
;MMU/clear2 .System/expansion DEO2
#4000
&ver ( -- )
DUP ,&y STR
#4000
&hor ( -- )
DUP [ LIT &y $1 ] <run-cell>
INC GTHk ?&hor
POP2 INC GTHk ?&ver
POP2
( move ) ;MMU/move21 .System/expansion DEO2
!<redraw>
@<run-cell> ( x y -- )
( x y ) DUP2 STH2k
( neighbours ) get-neighbours
( state ) STH2r get-index LDA #00 EQU ?&dead
DUP #02 LTH ?&dies
DUP #03 GTH ?&dies
POP !&save
&dies POP POP2 JMP2r
&dead ( -- )
DUP #03 EQU ?&birth
POP POP2 JMP2r
&birth POP !&save
&save ( x y -- )
STH2
#01 STH2r get-index #1000 ADD2 STA
.world/count LDZ2 INC2 .world/count STZ2
JMP2r
@get-index ( x y -- index* )
( y ) #3f AND #00 SWP #60 SFT2 ROT
( x ) #3f AND #00 SWP ADD2 ;bank1 ADD2 JMP2r
@<set-cell> ( x y -- )
get-index STH2
#01 STH2r STA
JMP2r
@get-neighbours ( x y -- neighbours )
,&y STR
,&x STR
[ LITr 00 ] #0800
&l ( -- )
#00 OVRk ADD2 ;&mask ADD2 LDA2
( ) [ LIT &y $1 ] ADD SWP
( ) [ LIT &x $1 ] ADD SWP get-index LDA [ STH ADDr ]
( stop at 3 ) DUPr [ LITr 03 ] GTHr [ LITr _&end ] JCNr
( ) INC GTHk ?&l
&end POP2 STHr JMP2r
&mask [
ffff 00ff 01ff ff00 0100 ff01 0001 0101 ]
@within-rect ( x* y* rect -- flag )
STH
( y < rect.y1 ) DUP2 STHkr INC INC LDZ2 LTH2 ?&skip
( y > rect.y2 ) DUP2 STHkr #06 ADD LDZ2 GTH2 ?&skip
SWP2
( x < rect.x1 ) DUP2 STHkr LDZ2 LTH2 ?&skip
( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ?&skip
POP2 POP2 POPr #01 JMP2r
&skip POP2 POP2 POPr #00 JMP2r
(
@|drawing )
@<redraw> ( -- )
( | draw count )
.anchor/x LDZ2 .Screen/x DEO2
.anchor/y2 LDZ2 #0008 ADD2 .Screen/y DEO2
[ LIT2 01 -Screen/auto ] DEO
.world/count LDZ2 <draw-short>
( | draw grid )
[ LIT2 01 -Screen/auto ] DEO
.anchor/y LDZ2 .Screen/y DEO2
;bank2 ;bank1
&l ( -- )
DUP #3f AND ?{
.Screen/y DEI2k INC2 INC2 ROT DEO2
.anchor/x LDZ2 .Screen/x DEO2 }
LDAk INC .Screen/pixel DEO
[ LIT2 00 -Screen/pixel ] DEO
INC2 GTH2k ?&l
POP2 POP2 JMP2r
@<draw-short> ( short* -- )
SWP <draw-byte>
( >> )
@<draw-byte> ( byte color -- )
DUP #04 SFT <draw-hex>
#0f AND
( >> )
@<draw-hex> ( char color -- )
#00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
[ LIT2 03 -Screen/sprite ] DEO
JMP2r
@<update-cursor> ( color addr* -- )
[ LIT2 00 -Screen/auto ] DEO
;fill-icn .Screen/addr DEO2
#40 <draw-cursor>
.Mouse/x DEI2 ,<draw-cursor>/x STR2
.Mouse/y DEI2 ,<draw-cursor>/y STR2
.Screen/addr DEO2
( >> )
@<draw-cursor> ( color -- )
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEO
JMP2r
(
@|assets )
@MMU ( programs )
&clear1 [ 01 1000 0000 =bank3 0000 =bank1 ]
&clear2 [ 01 1000 0000 =bank3 0000 =bank2 ]
&move21 [ 01 1000 0000 =bank2 0000 =bank1 ]
@cursor-icn [ 80c0 e0f0 f8e0 1000 ]
@fill-icn [ ffff ffff ffff ffff ]
@font-hex [
7c82 8282 8282 7c00 3010 1010 1010 3800
7c82 027c 8080 fe00 7c82 021c 0282 7c00
2242 82fe 0202 0200 fe80 807c 0282 7c00
7c82 80fc 8282 7c00 fe82 0408 0810 1000
7c82 827c 8282 7c00 7c82 827e 0202 0200
7c82 82fe 8282 8200 fc82 82fc 8282 fc00
7c82 8080 8082 7c00 fc82 8282 8282 fc00
fe80 80f0 8080 fe00 fe80 80f0 8080 8000 ]
(
@|memory )
|8000 @bank1 $1000
@bank2 $1000
@bank3 $1000

172
projects/examples/demos/mandelbrot.tal

@ -1,172 +0,0 @@
( mandelbrot.tal )
( )
( by alderwick and d_m )
( )
( uses 4.12 fixed point arithmetic. )
( SCALE LOGICAL SCREENSIZE )
( #0001 21x16 42x32 )
( #0002 42x32 84x64 )
( #0004 84x64 168x128 )
( #0008 168x128 336x256 )
( #0010 336x256 672x512 )
( #0020 672x512 1344x1024 )
%SCALE { #0009 } ( 32 )
%WIDTH { #0015 } ( 21 )
%HEIGHT { #0010 } ( 16 )
%XMIN { #de69 } ( -8601 => -8601/4096 => -2.100 )
%XMAX { #0b33 } ( 2867 => 2867/4096 => 0.700 )
%YMIN { #ecc7 } ( -4915 => -4915/4096 => -1.200 )
%YMAX { #1333 } ( 4915 => 4915/4096 => 1.200 )
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|0100 ( -> )
( set colors )
#00ff .System/r DEO2
#0ff0 .System/g DEO2
#0f0f .System/b DEO2
( set window size )
width #10 SFT2 .Screen/width DEO2
height #10 SFT2 .Screen/height DEO2
( run )
draw-mandel BRK
( logical width )
@width ( -> w* )
WIDTH SCALE MUL2 JMP2r
( logical height )
@height ( -> h* )
HEIGHT SCALE MUL2 JMP2r
( draw the mandelbrot set using 4.12 fixed point numbers )
@draw-mandel ( -> )
XMAX XMIN SUB2 width DIV2 ,&dx STR2 ( ; &dx<-{xmax-min}/width )
YMAX YMIN SUB2 height DIV2 ,&dy STR2 ( ; &dy<-{ymax-ymin}/height )
[ LIT2 01 -Screen/auto ] DEO ( ; auto<-1 )
LIT2r 8000 ( [8000] )
YMAX YMIN ( ymax* ymin* [8000] )
&yloop ( ymax* y* [8000] )
XMAX XMIN ( ymax* y* xmax* xmin* [8000] )
&xloop ( ymax* y* xmax* x* [8000] )
ROT2k evaluate ( ymax* y* xmax* x* xmax* count^ [8000] )
draw-px POP2 ( ymax* y* xmax* x* [8000] )
[ LIT2 &dx $2 ] ADD2 ( ymax* y* xmax* x+dx* [8000] )
OVR2 STH2kr ADD2 ( ymax* y* xmax* x+dx* 8000+xmax* [8000] )
OVR2 STH2kr ADD2 ( ymax* y* xmax* x+dx* 8000+xmax* 8000+x+dx* [8000] )
GTH2 ?&xloop ( ymax* y* xmax* x+dx* [8000] )
POP2 POP2 ( ymax* y* [8000] )
#0000 .Screen/x DEO2 ( ymax* y* [8000] ; sc/x<-0 )
.Screen/y ;inc2 adjust ( ymax* y* [8000] ; sc/y<-sy+1 )
[ LIT2 &dy $2 ] ADD2 ( ymax* y+dy* [8000] )
OVR2 STH2kr ADD2 ( ymax* y+dy* 8000+ymax* [8000] )
OVR2 STH2kr ADD2 ( ymax* y+dy* 8000+ymax* 8000+y+dy* [8000] )
GTH2 ?&yloop ( ymax* y+dy* [8000] )
POP2 POP2 POP2r JMP2r ( )
( dithering pattern for 2x2 pixels: )
( )
( |o o| -> |x o| -> |x o| -> |x x| -> |x x| )
( |o o| -> |o o| -> |o x| -> |o x| -> |x x| )
( )
( |[p+3]/4 [px+1]/4| )
( |[p+0]/4 [px+2]/4| )
@draw-px ( px^ -> )
INCk INCk INC ( p+0 p+1 p+3 )
draw-quad draw-quad ( p+0 ; draw NW, NE )
.Screen/y ;inc1 adjust ( ; y<-y+1 )
.Screen/x ;sub2 adjust ( ; x<-x-2 )
INCk INC SWP ( p+2 p+0 )
draw-quad draw-quad ( ; draw SW, SE )
.Screen/y ;sub1 !adjust ( ; y<-y-1 )
( draw one quadrant of a 2x2 area )
@draw-quad ( p^ -> )
#02 SFT .Screen/pixel DEO JMP2r ( ; pixel<-p/4 )
( evaluate the mandelbrot function at one point )
@evaluate ( x* y* -> count^ )
#0000 DUP2 ,&x1 STR2 ( x* y* ; x1<-0 )
DUP2 ,&y1 STR2 ( x* y* ; y1<-0 )
DUP2 ,&x2 STR2 ( x* y* ; x2<-0 )
,&y2 STR2 ( x* y* ; y2<-0 )
LIT2r 2000 ( x* y* [20 00] )
&loop ( x* y* [20 n^] )
[ LIT2 &x1 $2 ] ( x* y* x1* [20 n^] )
[ LIT2 &y1 $2 ] ( x* y* x1* y1* [20 n^] )
smul2 DUP2 ADD2 ( x* y* 2x1y1* [20 n^] )
OVR2 ADD2 ,&y1 STR2 ( x* y* [20 n^] ; y1<-2x1y1+y* )
SWP2 [ LIT2 &x2 $2 ] ( y* x* x2* [20 n^] )
[ LIT2 &y2 $2 ] SUB2 ( y* x* x2-y2* [20 n^] )
OVR2 ADD2 ,&x1 STR2 SWP2 ( x* y* [20 n^] ; x1<-x2-y2+x* )
,&x1 LDR2 square ( x* y* x1^2* [20 n^] )
DUP2 ,&x2 STR2 ( x* y* x1^2* [20 n^] ; x2<-x1^2* )
,&y1 LDR2 square ( x* y* x1^2* y1^2* [20 n^] )
DUP2 ,&y2 STR2 ( x* y* x1^2* y1^2* [20 n^] ; y2<-y1^2* )
ADD2 #4000 GTH2 ?&end ( x* y* [20 n^] )
INCr GTHkr STHr ?&loop ( x* y* [20 n+1*] )
&end ( x* y* [20 count^] )
POP2 POP2 NIPr STHr JMP2r ( count^ )
( is x a non-negative signed value? )
@non-negative ( x* -> x* x>=0^ )
DUP2 #8000 LTH2 JMP2r
( multiply two signed 4.12 fixed point numbers )
@smul2 ( a* b* -> ab* )
LIT2r 0001 non-negative ?{ negate SWPr } ( a* |b|* [sign*] )
SWP2 non-negative ?{ negate SWPr } ( |b|* |a|* [sign*] )
smul2-pos STHr ?{ negate } POPr JMP2r ( ab* )
( multiply two non-negative fixed point numbers )
( )
( a * b = {a0/16 + a1/4096} * {b0/16 + b1/4096} )
( = a0b0/256 + a1b0/65536 + a0b1/65536 + a1b1/16777216 )
( = x + y + z + 0 ; the last term is too small to represent, i.e. zero )
( )
( x = a0b0 << 4 )
( y = a1b0 >> 4 )
( z = a0b1 >> 4 )
@smul2-pos ( a* b* -> ab* )
aerate ROT2 aerate ( b0* b1* a0* a1* )
STH2 ROT2k STH2 MUL2r ( b0* b1* a0* b1* a0* [a1b0*] )
MUL2 STH2 ADD2r ( b0* b1* a0* [a1b0+a0b1*] )
NIP2 MUL2 #07ff min #40 SFT2 ( a0b0* [y+z*] )
STH2r #04 SFT2 ADD2 ( x* [y+z*] )
#7fff !min ( ab* )
( equivalent to DUP2 smul2 but faster )
@square ( a* -> aa* )
non-negative ?{ negate } ( |a|* )
aerate ( 00 ahi^ 00 alo^ )
OVR2 MUL2 #03 SFT2 SWP2 ( yz* ahi* )
DUP2 MUL2 #07ff min #40 SFT2 ( x* yz* )
ADD2 #7fff !min ( aa* )
( update a device d^ given a function f: x* -> f[x]* )
@adjust ( d^ f* -> )
STH2 DEI2k STH2r JSR2 ROT DEO2 JMP2r
( return the minimum of two non-negative numbers. )
@min ( x* y* )
GTH2k [ JMP SWP2 ] NIP2 JMP2r
( convert each byte of a a short into a short )
@aerate ( x* -> 00 xhi^ 00 xlo^ )
SWP #0000 ROT SWP2 SWP JMP2r
( negate a fixed point number. doesn't work for #8000 )
@negate ( x* -> -x* )
DUP2k EOR2 SWP2 SUB2 JMP2r
( useful arithmetic operations )
@inc2 ( n* -> n+2* ) INC2
@inc1 ( n* -> n+1* ) INC2 JMP2r
@sub1 ( n* -> n-1* ) #0001 SUB2 JMP2r
@sub2 ( n* -> n-2* ) #0002 SUB2 JMP2r

63
projects/examples/demos/move.tal

@ -1,63 +0,0 @@
( Move: Use controller arrows, leave a slime. )
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|80 @Controller &vector $2 &button $1 &key $1
|000
@hello &x $2 &y $2
|100
@on-reset ( -> )
( | theme )
#c0f4 .System/r DEO2
#c0fc .System/g DEO2
#c0f7 .System/b DEO2
( | vectors )
;on-frame .Screen/vector DEO2
( | set origin )
.Screen/width DEI2 #01 SFT2 .hello/x STZ2
.Screen/height DEI2 #01 SFT2 .hello/y STZ2
[ LIT2 16 -Screen/auto ] DEO
#00 !on-frame/draw
@on-frame ( -> )
.Controller/button DEI DUP ?{ POP BRK }
( flip ) #ff EOR
( | movement )
DUP #10 AND ?{
.hello/y LDZ2k #0001 SUB2 ROT STZ2 }
DUP #20 AND ?{
.hello/y LDZ2k INC2 ROT STZ2 }
DUP #40 AND ?{
.hello/x LDZ2k #0001 SUB2 ROT STZ2 }
DUP #80 AND ?{
.hello/x LDZ2k INC2 ROT STZ2 }
&draw ( button -> )
.hello/x LDZ2 STH2k .Screen/x DEO2
.hello/y LDZ2 STH2k .Screen/y DEO2
;hello-chr .Screen/addr DEO2
[ LIT2 c1 -Screen/sprite ] DEOk DEO
( | draw slime )
[ LITr -Screen/y ] DEO2r
[ LITr -Screen/x ] DEO2r
;slime-icn .Screen/addr DEO2
get-slime .Screen/sprite DEOk DEO
BRK
@get-slime ( button -- color )
DUP #01 AND ?{ POP #05 JMP2r }
#02 AND ?{ #0a JMP2r }
#0f JMP2r
@hello-chr [
0007 1820 2040 4044 0000 071f 1f3f 3f3b
00e0 1804 0402 0222 0000 e0f8 f8fc fcdc
4040 4423 2018 0700 3f3f 3b1c 1f07 0000
0202 22c4 0418 e000 fcfc dc38 f8e0 0000 ]
@slime-icn [
0000 0000 0003 0707 0000 0000 00c0 e0e0
0707 0300 0000 0000 e0e0 c000 0000 0000 ]

145
projects/examples/demos/polycat.tal

@ -1,145 +0,0 @@
( Polycat:
A cat with one eye, and the hind and tail of a lizard.
Original character by Rekka Bellum )
|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixeld $1 &sprite $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2
|0000
@cat &x $2 &y $2 &timer $1
@pointer &x $2 &y $2
|0100 ( -> )
( theme )
#0a3f .System/r DEO2
#05df .System/g DEO2
#0caf .System/b DEO2
( DOS resolution )
#0140 .Screen/width DEO2
#00c8 .Screen/height DEO2
( vectors )
;on-mouse .Mouse/vector DEO2
( find center )
.Screen/width DEI2 #01 SFT2 .cat/x STZ2
.Screen/height DEI2 #01 SFT2 .cat/y STZ2
( draw ground )
#f6 .Screen/auto DEO
.cat/y LDZ2 #0018 ADD2 .Screen/y DEO2
.cat/x LDZ2 #0010 SUB2 .Screen/x DEO2
;ground .Screen/addr DEO2
#01 .Screen/sprite DEO
( init )
#ff ;draw-eye/last STA
#ff ;draw-tail/last STA
( set screen mode auto-x )
#05 .Screen/auto DEO
,draw-polycat JSR
BRK
@draw-polycat ( -- )
( ears )
.cat/y LDZ2 .Screen/y DEO2
.cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
;ears .Screen/addr DEO2
#81 .Screen/sprite DEOk DEO
( body )
.cat/y LDZ2 #0010 ADD2 .Screen/y DEO2
.cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
;body .Screen/addr DEO2
#81 .Screen/sprite DEO
( eye/tail )
#00 ,draw-eye JSR
#00 ;draw-tail ( .. )
JMP2
@on-mouse ( -> )
.Mouse/x DEI2 .cat/x LDZ2 GTH2 #50 SFT
.Mouse/y DEI2 .cat/y LDZ2 GTH2 #60 SFT
ADD ,draw-eye JSR
.cat/timer LDZ INC [ DUP ] .cat/timer STZ
#04 SFT ,draw-tail JSR
,draw-cursor JSR
BRK
@draw-eye ( quad -- )
DUP ,&last LDR NEQ ,&changed JCN
POP JMP2r &changed
( only redraw on change )
#00 OVR ;eye ADD2 .Screen/addr DEO2
.cat/y LDZ2 #0008 ADD2 .Screen/y DEO2
.cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
#81 .Screen/sprite DEOk DEO
,&last STR
JMP2r
&last $1
@draw-tail ( frame -- )
STHk ,&last LDR NEQ ,&changed JCN
POPr JMP2r &changed
( only redraw on change )
STHr #00 OVR ;frames ADD2 LDA
#00 SWP #40 SFT2 ;body/tail ADD2
.Screen/addr DEO2
.cat/x LDZ2 .Screen/x DEO2
.cat/y LDZ2 #0010 ADD2 .Screen/y DEO2
#81 .Screen/sprite DEO
,&last STR
JMP2r
&last $1
@draw-cursor ( -- )
( last cursor )
;cursor STH2k .Screen/addr DEO2
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#40 .Screen/sprite DEO
( new cursor )
STH2r .Screen/addr DEO2
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
#41 .Mouse/state DEI #00 NEQ ADD .Screen/sprite DEO
JMP2r
@cursor
80c0 e0f0 f8e0 1000
@frames
00 01 02 03 02 01 00 00
00 00 00 00 00 00 00 00
@ears
081c 3e3e 7f7f ffff 081c 3e3e 7f7f fffc
081c 3c3e 7e7e ffff 081c 3c3e 7e7e ff1f
@eye
ffff ffff ff7f 3f0f f7ef cfe7 f07c 3f0f
ffff ffff fffe fcf0 87c3 c183 071e fcf0
ffff ffff ff7f 3f0f f0e1 c1e0 f07c 3f0f
ffff ffff fffe fcf0 f7fb f9f3 071e fcf0
ffff ffff ff7f 3f0f f0e7 cfef f77c 3f0f
ffff ffff fffe fcf0 0783 c1c3 871e fcf0
ffff ffff ff7f 3f0f f0e0 c1e1 f07c 3f0f
ffff ffff fffe fcf0 07f3 f9fb f71e fcf0
@body
0707 0707 0302 0200 0107 0707 0300 0000
&tail
e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
e0f0 f0e0 e080 8000 c0f2 faf9 fef8 b000
e0f0 f0e0 e080 8000 c0f1 faf9 fef8 b000
0707 0707 0f08 1000 0307 0707 0f00 0000
e0e0 e0e0 e080 8000 f2f9 f9fe b884 8400
@ground
bf00 5c02 0202 020c ef10 6f90 8080 8074
ff00 fe01 0100 0116 fd00 3c40 4040 4028

145
projects/examples/demos/pond.tal

@ -1,145 +0,0 @@
( pond.tal )
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &modx $2 &mody $2
|000
@circle &xc $2 &yc $2 &x $2 &y $2 &r $2 &d $2
|100
@on-reset ( -> )
( | theme )
#2c2c DUP2 .System/r DEO2
DUP2 .System/g DEO2
.System/b DEO2
;on-mouse .Mouse/vector DEO2
;on-frame .Screen/vector DEO2
BRK
@on-mouse ( -> )
#c1 ;touch-chr/down ;touch-chr .Mouse/state DEI ?{ SWP2 }
POP2 <update-cursor>
BRK
@on-frame ( -> )
( | 30 fps )
[ LIT &f $1 ] INCk ,&f STR
?{ BRK }
( | clear )
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
[ LIT2 80 -Screen/pixel ] DEO
( | draw )
;particles/end ;particles
&>l ( -- )
( | animate particle )
DUP2 <draw-particle>
( | increase size )
DUP2 #0004 ADD2 LDA2k INC2 SWP2 STA2
#0006 ADD2 GTH2k ?&>l
POP2 POP2
( | add particle )
[ LIT &lock $1 ] DUP ?{
.Mouse/state DEI ?{ POP BRK }
( | touch )
.Mouse/x DEI2 #0004 ADD2 .Mouse/y DEI2 #0004 ADD2 <add-particle>
[ LIT2 08 _&lock ] STR
POP BRK }
#01 SUB ,&lock STR
BRK
@<add-particle> ( x* y* -- )
SWP2 [ LIT2r &ptr =particles ] STH2kr INC2r INC2r STA2
STH2kr INC2r INC2r STA2
#0001 STH2kr INC2r INC2r STA2
STH2r DUP2 ;particles/end LTH2 ?{ POP2 ;particles }
,&ptr STR2
JMP2r
@<update-cursor> ( color addr* -- )
;fill-icn .Screen/addr DEO2
#40 <draw-cursor>
.Screen/addr DEO2
.Mouse/x DEI2 ,<draw-cursor>/x STR2
.Mouse/y DEI2 ,<draw-cursor>/y STR2
( >> )
@<draw-cursor> ( color -- )
[ LIT2 16 -Screen/auto ] DEO
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEOk DEO
JMP2r
@<draw-particle> ( addr* -- )
LDA2k ,&x STR2
INC2 INC2 LDA2k ,&y STR2
INC2 INC2 LDA2 [ LIT2 &x $2 ] [ LIT2 &y $2 ] ROT2
( >> )
@<draw-circle> ( xc* yc* r* -- )
.circle/r STZ2
.circle/yc STZ2
.circle/xc STZ2
#0000 .circle/x STZ2
.circle/r LDZ2 .circle/y STZ2
.circle/r LDZ2 #10 SFT2 .circle/d STZ2
( draw ) <draw-seg>
&>loop ( -- )
( incr ) .circle/x LDZ2 INC2 .circle/x STZ2
.circle/d LDZ2 #0001 LTS2 ?{
( decr ) .circle/y LDZ2 #0001 SUB2 .circle/y STZ2
.circle/x LDZ2 .circle/y LDZ2 SUB2 #20 SFT2 .circle/d LDZ2 ADD2 .circle/d STZ2 !&end }
.circle/x LDZ2 #20 SFT2 .circle/d LDZ2 ADD2 .circle/d STZ2
&end ( draw )
<draw-seg>
.circle/y LDZ2 .circle/x LDZ2 #0001 SUB2 GTS2 ?&>loop
JMP2r
@LTS2 ( a* b* -- f )
#8000 ADD2 SWP2 #8000 ADD2 GTH2 JMP2r
@GTS2 ( a* b* -- f )
#8000 ADD2 SWP2 #8000 ADD2 LTH2 JMP2r
@<draw-seg> ( -- )
.circle/xc LDZ2 .circle/x LDZ2 ADD2 .circle/yc LDZ2 .circle/y LDZ2 ADD2 <draw-pixel>
.circle/xc LDZ2 .circle/x LDZ2 SUB2 .circle/yc LDZ2 .circle/y LDZ2 ADD2 <draw-pixel>
.circle/xc LDZ2 .circle/x LDZ2 ADD2 .circle/yc LDZ2 .circle/y LDZ2 SUB2 <draw-pixel>
.circle/xc LDZ2 .circle/x LDZ2 SUB2 .circle/yc LDZ2 .circle/y LDZ2 SUB2 <draw-pixel>
.circle/xc LDZ2 .circle/y LDZ2 ADD2 .circle/yc LDZ2 .circle/x LDZ2 ADD2 <draw-pixel>
.circle/xc LDZ2 .circle/y LDZ2 SUB2 .circle/yc LDZ2 .circle/x LDZ2 ADD2 <draw-pixel>
.circle/xc LDZ2 .circle/y LDZ2 ADD2 .circle/yc LDZ2 .circle/x LDZ2 SUB2 <draw-pixel>
.circle/xc LDZ2 .circle/y LDZ2 SUB2 .circle/yc LDZ2 .circle/x LDZ2 SUB2
( >> )
@<draw-pixel> ( x* y* -- )
DUP2 .Screen/height DEI2 GTH2 ?{
.Screen/y DEO2
DUP2 .Screen/width DEI2 GTH2 ?{
.Screen/x DEO2
[ LIT2r 01 -Screen/pixel ] DEOr
JMP2r }
POP2 JMP2r }
POP2 POP2 JMP2r
@touch-chr [
0000 0000 0814 1417 0000 0000 0008 0808
0000 0000 0000 00c0 0000 0000 0000 0000
1010 2010 1008 0700 0f0f 1f0f 0f07 0000
2010 1010 2020 c000 c0e0 e0e0 c0c0 0000 ]
&down [
0000 0000 0000 0817 0000 0000 0000 0008
0000 0000 0000 00c0 0000 0000 0000 0000
1010 2010 1008 0700 0f0f 1f0f 0f07 0000
2010 1010 2020 c000 c0e0 e0e0 c0c0 0000 ]
@fill-icn [
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff ]
@particles $60 &end

171
projects/examples/demos/snake.tal

@ -1,171 +0,0 @@
( uxnemu snake.rom )
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|80 @Controller &vector $2 &button $1 &key $1
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
|000
@arena &w $1 &h $1
@apple &pos &x $1 &y $1
@snake &pos &x $1 &y $1 &direction $1 &length $1 &dead $1 &tail $40
|100
@on-reset ( -> )
( | theme )
#0f7e .System/r DEO2
#0fe6 .System/g DEO2
#0f62 .System/b DEO2
( | vectors )
;on-frame .Screen/vector DEO2
;on-button .Controller/vector DEO2
( | resize )
#00c8 .Screen/width DEO2
#0100 .Screen/height DEO2
( | set arena )
.Screen/width DEI2 #03 SFT2 .arena/w STZ
POP .Screen/height DEI2 #03 SFT2 .arena/h STZ
POP [ LIT2 01 -Screen/auto ] DEO
reset BRK
@on-frame ( -> )
[ LIT &f $1 ] INCk ,&f STR
#04 GTH ?{ BRK }
[ LIT2 00 _&f ] STR
#00 <draw-snake>
<move>
[ LIT2 02 -snake/dead ] LDZ ADD <draw-snake>
#83 <draw-apple>
<draw-score>
BRK
@on-button ( -> )
.Controller/button DEI
( ) DUP #f0 AND ?&arrow
( ) #0f AND ?&button
BRK
&arrow ( button -> )
#04 SFT .snake/direction STZ
BRK
&button ( -> )
reset BRK
@reset ( -- )
#00 <draw-snake>
#00 <draw-apple>
[ LIT2 00 -snake/dead ] STZ
[ LIT2 00 -snake/length ] STZ
[ LIT2 00 -snake/direction ] STZ
.arena/w LDZ #01 SFT #01 SUB .snake/x STZ
.arena/h LDZ #01 SFT #01 SUB .snake/y STZ
#03 <draw-snake>
!<add-apple>
@<move> ( -- )
( | copy tail )
[ LITr -snake/pos ] LDZ2r .snake/length LDZ #00
&>loop ( -- )
DUPk ADD .snake/tail ADD LDZ2k STH2
SWP2r STH2r ROT STZ2
INC GTHk ?&>loop
POP2 POP2r
( ) .snake/dead LDZ ?&end
.snake/direction LDZ
( ) DUP #01 NEQ ?{
.snake/y LDZk #01 SUB .arena/h set-pos }
DUP #02 NEQ ?{
.snake/y LDZk INC .arena/h set-pos }
DUP #04 NEQ ?{
.snake/x LDZk #01 SUB .arena/w set-pos }
DUP #08 NEQ ?{
.snake/x LDZk INC .arena/w set-pos }
POP
( | detect collision with apple )
.snake/pos LDZ2 .apple/pos LDZ2 NEQ2 ?{
#00 <draw-apple>
.snake/length LDZk INC SWP STZ
<add-apple>
!<move> }
( | detect collision with body )
.snake/length LDZ #01
&>loop-body ( -- )
DUPk ADD .snake/tail ADD LDZ2 .snake/pos LDZ2 NEQ2 ?{
[ LIT2 01 -snake/dead ] STZ
#03 <draw-snake> }
INC GTHk ?&>loop-body
POP2 &end JMP2r
@set-pos ( z mod max -- )
LDZ OVR INC ?{ ROT STZ
POP JMP2r }
DIVk MUL SUB SWP STZ
JMP2r
@<add-apple> ( -- )
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2
( ) DUP2 #1234 MUL2 ADD .arena/w LDZ DIVk MUL SUB .apple/x STZ
( ) #abcd MUL2 ADD .arena/h LDZ DIVk MUL SUB .apple/y STZ
JMP2r
(
@|drawing )
@<draw-snake> ( color -- )
STH
( | draw tail )
;snake-icns .Screen/addr DEO2
[ LIT2 -snake/tail -snake/length ] LDZ DUP ADD OVR ADD SWP
&>loop ( -- )
LDZ2k #0005 SFT2 .Screen/y DEO2
#0005 SFT2 .Screen/x DEO2
DUPr [ LITr -Screen/sprite ] DEOr
INC INC GTHk ?&>loop
POP2
( | draw head )
.snake/pos LDZ2 #0005 SFT2 .Screen/y DEO2
#0005 SFT2 .Screen/x DEO2
;snake-icns/face .Screen/addr DEO2
[ LITr -Screen/sprite ] DEOr
JMP2r
@<draw-apple> ( color -- )
.apple/x LDZ #0005 SFT2 .Screen/x DEO2
.apple/y LDZ #0005 SFT2 .Screen/y DEO2
STHk ;apple-chr ;fill-icn [ LITr 01 JCNr SWP2 POP2 ] .Screen/addr DEO2
.Screen/sprite DEO
JMP2r
@<draw-score> ( -- )
#0010 DUP2 .Screen/x DEO2
.Screen/y DEO2
.snake/length LDZ
( x0 ) DUP #04 SFT <draw-num>
( >> )
@<draw-num> ( num -- )
#000f ROT AND #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
[ LIT2 41 -Screen/sprite ] DEO
JMP2r
(
@|assets )
@snake-icns [ 7eff ffff ffff ff7e ]
&face [ 7eff ffdb ffe7 ff7e ]
@apple-chr [
0000 76ff ffff 7e3c 1008 0000 0000 0000 ]
@fill-icn [ ffff ffff ffff ffff ]
@font-hex [
007c 8282 8282 827c 0030 1010 1010 1010
007c 8202 7c80 80fe 007c 8202 1c02 827c
000c 1424 4484 fe04 00fe 8080 7c02 827c
007c 8280 fc82 827c 007c 8202 1e02 0202
007c 8282 7c82 827c 007c 8282 7e02 827c
007c 8202 7e82 827e 00fc 8282 fc82 82fc
007c 8280 8080 827c 00fc 8282 8282 82fc
007c 8280 f080 827c 007c 8280 f080 8080 ]

430
projects/examples/devices/audio-tests.tal

@ -1,430 +0,0 @@
( dev/audio-tests )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &duration $2 &pad $1 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|40 @Audio1 [ &vector $2 &position $2 &output $1 &duration $2 &pad $1 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|50 @Audio2 [ &vector $2 &position $2 &output $1 &duration $2 &pad $1 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|60 @Audio3 [ &vector $2 &position $2 &output $1 &duration $2 &pad $1 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|80 @Controller &vector $2 &button $1 &key $1
|0100 @on-reset ( -> )
( | theme )
#0f8f .System/r DEO2
#0f8f .System/g DEO2
#0f80 .System/b DEO2
( | vectors )
;on-frame .Screen/vector DEO2
;on-button .Controller/vector DEO2
#0000 .Audio0/vector DEO2
;on-audio1 .Audio1/vector DEO2
;on-audio2 .Audio2/vector DEO2
;on-audio3 .Audio3/vector DEO2
( | setup kick )
;kick .Audio0/addr DEO2
;kick/end ;kick SUB2 .Audio0/length DEO2
#ff .Audio0/volume DEO
#00ff .Audio0/adsr DEO2
( | setup sine )
;sine .Audio1/addr DEO2
;sine/end ;sine SUB2
.Audio1/length DEO2
#ff .Audio1/volume DEO
#01ff .Audio1/adsr DEO2
#00c0 .Audio1/duration DEO2
( | setup sine )
;sine .Audio2/addr DEO2
;sine/end ;sine SUB2
.Audio2/length DEO2
#ff .Audio2/volume DEO
#2200 .Audio2/adsr DEO2
#00c0 .Audio2/duration DEO2
( | setup sine )
;sine .Audio3/addr DEO2
;sine/end ;sine SUB2
.Audio3/length DEO2
#ff .Audio3/volume DEO
#0fff .Audio3/adsr DEO2
#00c0 .Audio3/duration DEO2
( | start )
#00 .Audio0/pitch DEO
BRK
@on-button ( -> )
.Controller/button DEI #02 AND ?play-kick
BRK
@play-kick ( -> )
#3c #80 ORA .Audio0/pitch DEO
BRK
@get-note ( offset* -- )
#001f AND2 ;melody ADD2 LDA
JMP2r
@on-audio1 ( -> )
[ LIT2 00 &f $1 ] INCk ,&f STR
get-note .Audio1/pitch DEO
BRK
@on-audio2 ( -> )
[ LIT2 00 &f $1 ] INCk ,&f STR
get-note #0c SUB .Audio2/pitch DEO
BRK
@on-audio3 ( -> )
[ LIT2 00 &f $1 ] INCk ,&f STR
get-note #18 SUB .Audio3/pitch DEO
BRK
@on-frame ( -> )
BRK
@melody [
54 52 54 4f 4b 4f 48 00
54 52 54 4f 4b 4f 48 00
54 56 57 56 57 54 56 54
56 52 54 52 54 50 54 00 ]
@sine [
8083 8689 8c8f 9295 989b 9ea1 a4a7 aaad
b0b3 b6b9 bbbe c1c3 c6c9 cbce d0d2 d5d7
d9db dee0 e2e4 e6e7 e9eb ecee f0f1 f2f4
f5f6 f7f8 f9fa fbfb fcfd fdfe fefe fefe
fffe fefe fefe fdfd fcfb fbfa f9f8 f7f6
f5f4 f2f1 f0ee eceb e9e7 e6e4 e2e0 dedb
d9d7 d5d2 d0ce cbc9 c6c3 c1be bbb9 b6b3
b0ad aaa7 a4a1 9e9b 9895 928f 8c89 8683
807d 7a77 7471 6e6b 6865 625f 5c59 5653
504d 4a47 4542 3f3d 3a37 3532 302e 2b29
2725 2220 1e1c 1a19 1715 1412 100f 0e0c
0b0a 0908 0706 0505 0403 0302 0202 0202
0102 0202 0202 0303 0405 0506 0708 090a
0b0c 0e0f 1012 1415 1719 1a1c 1e20 2225
2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d
5053 5659 5c5f 6265 686b 6e71 7477 7a7d ] &end
@kick [
7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7e7f 7e7e
7e7e 7e7e 7e7e 7e7e 7d7d 7d7d 7c7c 7c7c
7c7c 7c7c 7b7b 787a 7576 7775 7a78 7a7a
7b7a 7c7b 7a7c 7879 7a78 7d7b 7f7e 7b7d
6e75 6c6d 8779 a799 949e 5a72 5451 8975
9b9e 657e 3f4a 403f 4e42 725f 9386 a09c
999f 8290 6675 585b 6157 7168 7475 6d73
6f6d 7c74 807e 727a 626a 5e60 6863 7a72
8682 8486 737b 6569 6864 7b74 8786 8186
7579 7372 7875 7b7b 7d7b 837e 8a86 888c
7c85 7077 706f 8076 968a a29c 9ba0 8b94
7d84 7f7d 8984 9790 a19c a4a3 9ea1 9a9c
999a 9999 9a99 9b99 a49f aeaa b2b4 a8ae
9ea1 9f9c a9a3 b3af b7b6 b6b8 b2b4 b1b1
b1b0 b4b2 b4b4 b3b4 b5b4 bab7 bdbb bdbd
bebe bebe babc b9b9 bdbb c0bf c3c2 c2c3
bebf bdbd c0bf c0c2 bbbc bdb9 c5c2 c7c8
c3c6 bec0 bbbb bdbb bfbd c0c0 bcbf b9bb
b9b9 bdba bebe b8bc b1b5 b1b1 b3b2 b2b2
abae a9aa acab b2af b4b3 b2b3 acb0 a4a8
9ca0 9499 8a8f 8184 837f 9288 a09b a1a4
969d 8c90 8989 8a88 8789 8084 777c 6c72
6468 6563 6665 6a68 6d6c 6d6e 696b 6266
5d5f 5b5c 5b5b 5a5b 5658 5354 5152 4e4f
4b4c 494a 4647 4445 4142 3f40 3c3d 3b3c
383a 3637 3535 3234 3031 2f2f 2d2e 2c2c
292a 2728 2626 2425 2324 2222 2121 1f20
1e1f 1d1e 1c1c 1f1e 1e1e 1f1f 1f1f 1c1d
1b1c 1b1b 1a1a 1a1a 1c1b 1b1c 1b1a 1b1b
1b1b 1a1b 1b1b 1c1c 1d1c 1d1d 201e 2121
2021 2020 2020 2221 2222 2423 2524 2827
2929 2929 2a29 2b2a 2d2d 2e2e 2f2e 3231
3434 3334 3533 3836 3c3a 3d3d 3e3d 3f3e
4241 4543 4645 4646 4746 4a48 4f4c 5351
5554 5555 5656 5957 5b5a 5d5c 605e 6462
6766 6968 6a69 6e6c 7371 7676 7476 7171
7572 7e78 8682 8889 8588 8283 8483 8a86
8f8d 9191 9593 9896 9b99 9e9d a09f a1a1
a1a1 a4a3 a8a6 acaa afad b2b1 b4b3 b7b5
bbba bcbb bdbc bebe bfbf c0bf c4c2 c7c6
c8c7 c9c9 cbca cdcc cfcf d1d0 d3d2 d5d4
d6d6 d7d7 dad8 dcdb dddc dedd dfde e0df
e1e1 e2e2 e5e4 e6e5 e7e6 e8e7 e8e8 e9e9
eaea ebeb eceb edec eded eeee efee f0ef
eff0 efef f0ef f0f0 f1f1 f1f1 f2f2 f1f2
eff0 eeef eced edec eded eded eeee eeee
edee ecec ebeb ebeb eaea e9ea e9e9 e7e8
e6e7 e3e4 e3e3 e3e3 e2e3 e1e2 e0e0 dee0
dddd dbdc dadb d9da d7d8 d6d6 d4d5 d2d3
d1d1 ced0 cccd cbcc c9ca c7c8 c5c6 c4c5
c2c3 c0c1 bfc0 bcbd babb b8b9 b7b7 b5b6
b2b3 b0b1 adae abac a9aa a7a8 a6a7 a3a5
a1a2 9fa0 9d9e 9a9b 9899 9596 9293 9091
8e8f 8d8d 8b8c 888a 8486 8082 7d7f 7b7c
7a7b 7a7a 797a 7678 7274 6e70 6a6d 6568
6263 6261 6362 6464 6264 5c60 5659 5254
4e50 4a4c 4b4a 4e4c 4d4e 4c4d 4a4b 4347
3c3f 3638 3535 3635 3938 3939 3637 3335
2e30 292b 2627 2625 2727 2627 2525 2324
2021 1f1f 1d1e 1a1b 191a 1819 1718 1516
1314 1213 1112 1011 0f10 0e0f 0c0d 0a0b
0a0a 0909 0809 0708 0707 0606 0505 0405
0404 0303 0203 0202 0101 0101 0202 0202
0101 0101 0000 0000 0000 0000 0201 0403
0404 0404 0303 0203 0302 0504 0405 0505
0606 0707 0808 0808 0a09 0c0b 0c0c 0c0c
0c0d 0c0c 0e0d 1110 1312 1515 1515 1615
1616 1817 1919 1b1a 1d1c 1f1d 2120 2322
2424 2625 2727 2827 2a29 2c2a 2e2d 302f
3231 3433 3635 3837 3a39 3a3a 3c3b 3f3e
4241 4443 4645 4847 4a49 4b4a 4d4c 4f4e
5150 5453 5655 5958 5b5a 5c5c 5e5d 6160
6362 6564 6766 6968 6b6a 6d6c 6f6e 7271
7574 7777 7878 7979 7b7a 7d7c 7f7e 8281
8584 8786 8988 8b8a 8c8c 8e8d 8f8e 9291
9694 9897 9a99 9a9a 9b9a 9d9c 9f9e a1a0
a3a2 a6a4 a8a7 abaa aead aeae adad aeae
b0af b3b1 b6b4 b8b6 bcba bebd bdbd bcbc
bcbb bebc c0bf c2c1 c5c4 c8c6 cbc9 cbcb
cbcb cccb cdcc cecd cfce d0cf d1d0 d5d3
d6d6 d5d6 d6d5 d6d6 d7d7 d8d8 d9d8 dad9
dada dbdb dedd dfdf dedf dddd dfdd e0e0
e3e1 e4e4 e4e4 e3e3 e0e2 e0e0 e4e2 e6e5
e6e6 e5e6 e2e4 e2e2 e4e2 e6e5 e7e6 e7e7
e7e7 e7e7 e7e7 e8e8 e7e8 e4e5 e4e4 e6e5
e6e6 e6e6 e6e6 e6e6 e6e6 e5e6 e3e5 e2e3
e3e2 e4e4 e4e4 e4e4 e4e4 e4e4 e3e3 e2e3
e1e1 e0e0 dfdf dfdf dfdf dbdd dbdb dcdb
dadb dada dbda dadb d8d9 d6d7 d6d5 d7d7
d6d7 d4d5 d1d2 d1d1 d1d1 d0d1 cecf cdcd
cdcd cbcc cacb c9ca c7c8 c6c6 c5c6 c5c5
c5c5 c4c4 c1c3 bfc0 bfbf bfbf bebf babc
b8b9 b7b7 b7b7 b6b6 b5b5 b3b4 b3b3 b1b2
afb0 aeae adad acad aaab a9a9 a9a9 a8a9
a5a7 a2a3 a1a1 a1a1 a2a1 a1a1 9ea0 9b9c
9899 9797 9797 9897 9999 9999 9798 9495
9192 8e8f 8b8c 8a8a 8a8a 8a8a 8a8a 898a
8889 8586 8183 7f80 7e7e 7f7e 7f7f 7f7f
7d7e 7b7c 797a 7778 7677 7676 7676 7676
7475 7273 7071 6f6f 6e6e 6c6d 6b6c 696a
6969 6969 6969 6969 6768 6667 6465 6364
6263 6061 5f60 5f5f 5f5f 5f5f 5e5f 5d5d
5b5c 595a 5859 5757 5757 5858 5858 5757
5757 5657 5455 5454 5354 5353 5253 5152
5050 4f50 4f4f 5050 4f4f 4e4f 4e4e 4d4d
4e4e 4e4e 4e4e 4d4e 4c4c 4a4b 494a 4949
4949 4949 4949 4949 4949 4848 4747 4847
4848 4748 4747 4647 4646 4646 4546 4445
4444 4444 4444 4444 4343 4343 4343 4343
4343 4343 4242 4141 4040 3f3f 3f3f 4040
4141 4041 3e3f 3d3d 3d3d 3d3d 3d3d 3e3e
3d3d 3d3d 3c3d 3b3c 3a3b 393a 3939 3a39
3b3a 3b3b 3a3b 3839 3838 3738 3637 3636
3736 3838 3838 3738 3637 3435 3333 3534
3435 3233 3332 3333 3534 3334 3233 3132
3131 3232 3232 3232 3232 3232 3132 2e2f
2e2e 2f2e 3030 3030 3030 3030 3030 3030
3030 3030 3030 3030 3030 3030 3030 3030
3030 3030 3030 3030 3030 3030 3030 3030
3030 3030 3131 3332 3434 3435 3333 3333
3333 3433 3635 3737 3636 3636 3636 3837
3a39 3a3a 3939 3a3a 3c3b 3c3c 3b3b 3c3b
3e3d 403f 4040 4040 4140 4242 4343 4443
4544 4746 4847 4848 4948 4a4a 4b4a 4c4c
4d4c 4f4e 504f 5151 5151 5251 5453 5554
5656 5857 5a59 5b5b 5c5c 5d5d 5f5e 605f
6160 6261 6463 6564 6666 6867 6968 6a69
6c6b 6e6d 6f6f 7070 7171 7372 7574 7676
7877 7978 7a7a 7c7b 7e7d 7f7f 8180 8281
8483 8584 8686 8887 8a89 8b8a 8c8c 8e8d
908f 9190 9392 9493 9695 9897 9998 9a9a
9b9a 9d9c 9f9e a1a0 a2a2 a4a3 a5a5 a6a6
a7a7 a9a8 aaa9 acab aead b0af b1b0 b2b1
b4b3 b5b4 b6b5 b8b7 bab9 bcbb bdbc bebd
bfbe c1c0 c3c3 c3c3 c4c3 c5c4 c7c6 c9c8
cbca cccb cccc cecd cfcf cfcf d1cf d4d3
d5d4 d5d5 d6d6 d8d7 dad9 dcdb dcdc dddd
dedd dddd dddd dfde e2e1 e3e2 e3e3 e3e3
e3e3 e4e3 e4e4 e7e5 e9e8 e9e9 eaea eaea
ebea ebeb ebeb ecec edec eeee efef eeef
eeee eeee efef efef efef f0f0 f0f0 f0f0
f1f0 f1f1 f1f1 f1f1 f1f1 f1f1 f1f1 f2f1
f2f2 f2f2 f2f2 f2f2 f2f2 f1f2 f0f0 efef
f0ef f0f0 eff0 eeef eeee efee efef efef
eeef eced ebeb ebeb ebeb e9ea e9e9 e8e8
e7e7 e6e6 e5e6 e5e5 e4e5 e3e4 e2e2 e1e2
e0e0 dfdf dede ddde dcdc dbdb dadb d8d9
d7d7 d6d7 d4d5 d3d4 d1d2 d0d0 cecf cccd
cbcc cacb caca c8c9 c6c7 c4c5 c2c3 c0c1
bfc0 bebf bdbd bbbc b9ba b8b9 b6b7 b4b5
b2b3 b0b1 afaf adae acac aaab a8a9 a5a7
a3a4 a2a3 a0a1 9fa0 9d9e 9b9c 999a 9899
9697 9495 9293 9091 8f8f 8d8e 8b8c 898a
8788 8586 8484 8283 8081 7e7f 7d7e 7b7c
797a 7878 7677 7475 7273 7172 6f70 6e6f
6c6d 6a6b 6869 6767 6566 6465 6262 6061
5f60 5d5e 5c5d 5a5b 595a 5859 5758 5556
5455 5354 5252 5051 4f50 4d4e 4c4d 4b4c
4a4a 4849 4748 4647 4646 4545 4344 4242
4142 4041 3f40 3f3f 3e3e 3d3e 3b3c 3a3b
3a3a 3a3a 3a3a 393a 3939 3738 3636 3536
3334 3333 3433 3434 3334 3333 3233 3232
3132 3131 3131 3132 2f31 2e2e 2d2e 2e2e
2f2f 302f 3030 3030 2f30 2e2e 2e2e 2e2e
2e2e 2e2d 2f2e 2f2f 2f2f 2f2f 2f2f 2f2f
2f2f 2f2f 3030 3131 3131 3131 3131 3131
3131 3232 3332 3433 3434 3535 3434 3434
3535 3635 3736 3737 3838 3838 3838 3939
3a3a 3b3b 3c3c 3d3c 3d3d 3e3d 3e3e 3f3f
403f 4140 4241 4342 4444 4544 4545 4645
4746 4747 4848 4949 4a4a 4b4b 4c4c 4d4c
4e4e 4f4f 5050 5150 5251 5353 5454 5554
5655 5756 5857 5959 5a59 5b5a 5c5b 5d5c
5e5e 5f5e 6060 6161 6262 6362 6463 6565
6666 6767 6868 6969 6a6a 6b6b 6d6c 6e6d
6f6e 706f 7170 7171 7272 7373 7574 7675
7676 7777 7978 7a79 7b7a 7b7b 7c7c 7d7d
7e7e 7f7f 8080 8181 8281 8382 8483 8484
8585 8686 8787 8888 8989 8a8a 8b8a 8b8b
8c8b 8d8c 8e8d 8f8e 8f8f 9090 9090 9191
9191 9292 9393 9494 9594 9595 9695 9696
9796 9797 9898 9998 9999 9a99 9a9a 9a9a
9a9a 9b9b 9c9b 9c9c 9c9c 9d9d 9e9d 9e9e
9f9e 9f9f 9f9f 9f9f 9f9f 9f9f 9f9f a0a0
a0a0 a1a1 a1a1 a1a1 a1a1 a1a1 a2a2 a2a2
a2a2 a2a2 a2a2 a2a2 a3a2 a3a3 a2a2 a2a2
a2a2 a2a2 a2a2 a2a2 a3a3 a3a3 a3a3 a3a3
a3a3 a2a3 a2a2 a2a2 a2a2 a2a2 a2a2 a2a2
a2a2 a1a1 a1a1 a1a1 a1a1 a1a1 a1a1 a1a1
a1a1 a0a1 a0a0 a0a0 a0a0 9f9f 9f9f 9f9f
9e9f 9e9e 9e9e 9e9e 9e9e 9d9d 9d9d 9d9d
9c9d 9c9c 9c9c 9b9b 9b9b 9b9b 9a9b 9a9a
9a9a 9a9a 9999 9999 9899 9898 9898 9898
9798 9797 9697 9696 9596 9595 9595 9595
9495 9494 9394 9393 9393 9393 9292 9292
9191 9191 9191 9091 9090 9090 8f8f 8e8f
8e8e 8e8e 8d8e 8d8d 8d8d 8d8d 8c8d 8c8c
8b8c 8b8b 8b8b 8a8a 8a8a 8a8a 8989 8989
8989 8888 8888 8788 8787 8787 8787 8687
8686 8686 8585 8585 8585 8485 8484 8484
8484 8383 8383 8383 8283 8282 8282 8282
8282 8282 8181 8181 8181 8080 8080 8080
8080 8080 8080 8080 7f7f 7f7f 7f7f 7f7f
7e7f 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7d7e 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7e7d 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7f7f 7f7f 7f7f 7f7f 7f7f
7f7f 7f7f 7f7f 7f7f 8080 8080 8080 8080
8080 8080 8080 8080 8080 8181 8181 8181
8181 8181 8181 8181 8181 8181 8181 8181
8282 8282 8282 8282 8282 8282 8282 8282
8282 8282 8282 8282 8282 8282 8382 8383
8383 8383 8383 8383 8383 8383 8383 8383
8383 8383 8383 8383 8484 8484 8484 8484
8484 8484 8484 8484 8484 8484 8484 8484
8484 8484 8484 8484 8484 8484 8484 8484
8484 8484 8484 8484 8484 8484 8484 8484
8484 8484 8484 8484 8484 8484 8484 8484
8484 8484 8384 8383 8383 8383 8383 8383
8383 8383 8383 8383 8383 8383 8383 8282
8282 8282 8282 8282 8282 8282 8282 8282
8181 8181 8181 8181 8181 8181 8181 8181
8181 8080 8080 8080 8080 8080 8080 8080
7f80 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
7e7f 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7d7e
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7c7d
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7b7c
7b7b 7b7b 7b7b 7b7b 7b7b 7b7b 7b7b 7b7b
7a7a 7a7a 7a7a 7a7a 7a7a 7a7a 7a7a 7a7a
7a7a 7a7a 7a7a 7979 7979 7979 7979 7979
7979 7979 7979 7979 7979 7979 7979 7979
7979 7979 7979 7979 7979 7979 7878 7878
7878 7878 7878 7878 7878 7878 7878 7878
7878 7878 7878 7878 7878 7978 7879 7979
7878 7878 7878 7878 7979 7979 7979 7979
7979 7979 7979 7979 7979 7979 7979 7979
7979 7979 7979 7979 7979 7979 7979 7979
7979 7979 7979 7a79 7a7a 7a7a 7a7a 7a7a
7a7a 7a7a 7a7a 7a7a 7a7a 7a7a 7a7a 7a7a
7a7a 7a7a 7a7a 7a7a 7a7a 7a7a 7a7a 7a7a
7b7b 7b7b 7b7b 7b7b 7b7b 7b7b 7b7b 7b7b
7b7b 7b7b 7b7b 7b7b 7b7b 7b7b 7b7b 7b7b
7b7b 7b7b 7b7b 7b7b 7c7b 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7d7c 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7f7f 7f7f 7f7f
7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 8080
8080 8080 8080 8080 8080 8080 8080 8080
8080 8080 8080 8080 8080 8080 8080 8080
8181 8181 8181 8181 8181 8181 8181 8181
8181 8181 8181 8181 8181 8181 8181 8282
8282 8282 8282 8282 8282 8282 8282 8282
8282 8282 8282 8282 8282 8282 8282 8282
8383 8383 8383 8383 8383 8383 8383 8383
8383 8383 8383 8383 8383 8383 8383 8383
8383 8383 8383 8383 8484 8484 8484 8484
8484 8484 8484 8484 8484 8484 8484 8484
8484 8484 8484 8484 8484 8484 8484 8484
8484 8484 8484 8484 8584 8585 8585 8585
8585 8585 8585 8585 8585 8585 8585 8585
8585 8585 8585 8585 8585 8585 8585 8585
8585 8585 8585 8585 8585 8585 8585 8585
8585 8585 8585 8585 8585 8585 8585 8585
8585 8585 8585 8585 8585 8585 8585 8585
8585 8585 8585 8585 8585 8585 8585 8585
8585 8585 8585 8585 8585 8585 8585 8585
8585 8585 8585 8585 8585 8585 8484 8484
8484 8484 8484 8484 8484 8484 8484 8484
8484 8484 8484 8484 8484 8484 8484 8484
8383 8383 8383 8383 8383 8383 8383 8383
8383 8383 8383 8383 8383 8383 8383 8383
8283 8282 8282 8282 8282 8282 8282 8282
8282 8282 8282 8282 8282 8282 8182 8181
8181 8181 8181 8181 8181 8181 8181 8181
8181 8181 8181 8181 8181 8080 8080 8080
8080 8080 8080 8080 8080 8080 8080 8080
8080 8080 8080 8080 8080 7f7f 7f7f 7f7f
7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
7f7f 7f7f 7f7f 7f7f 7f7f 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7d7e
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7c7c 7c7c 7d7d 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d 7d7d
7d7d 7d7d 7e7d 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7e7e
7e7e 7e7e 7e7e 7e7e 7e7e 7e7e 7f7f 7f7f
7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f 7f7f
7f7f 7f7f 7f7f 7f7f
] &end

139
projects/examples/devices/audio.channels.tal

@ -1,139 +0,0 @@
( dev/audio )
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|50 @Audio2 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
( variables )
|0000
@timer $1
@counter $1
|0100 ( -> )
( theme )
#00ff .System/r DEO2
#0f0f .System/g DEO2
#0ff0 .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
( setup synth )
#1202 .Audio0/adsr DEO2
;saw .Audio0/addr DEO2
#0100 .Audio0/length DEO2
#88 .Audio0/volume DEO
#0101 .Audio1/adsr DEO2
;tri .Audio1/addr DEO2
#0100 .Audio1/length DEO2
#88 .Audio1/volume DEO
#0112 .Audio2/adsr DEO2
;sin .Audio2/addr DEO2
#0100 .Audio2/length DEO2
#88 .Audio2/volume DEO
#0022 .Audio3/adsr DEO2
;piano .Audio3/addr DEO2
#0100 .Audio3/length DEO2
#88 .Audio3/volume DEO
BRK
@on-frame ( -> )
( incr ) .timer LDZ INC .timer STZ
( skip ) .timer LDZ #10 EQU #01 JCN [ BRK ]
( get note )
.counter LDZ #18 DIVk MUL SUB #30 ADD
.Audio0/pitch .counter LDZ #03 AND #40 SFT ADD DEO
.counter LDZ INC .counter STZ
#00 .timer STZ
BRK
@saw
0003 0609 0c0f 1215 181b 1e21 2427 2a2d
3033 3639 3b3e 4143 4649 4b4e 5052 5557
595b 5e60 6264 6667 696b 6c6e 7071 7274
7576 7778 797a 7b7b 7c7d 7d7e 7e7e 7e7e
7f7e 7e7e 7e7e 7d7d 7c7b 7b7a 7978 7776
7574 7271 706e 6c6b 6967 6664 6260 5e5b
5957 5552 504e 4b49 4643 413e 3b39 3633
302d 2a27 2421 1e1b 1815 120f 0c09 0603
00fd faf7 f4f1 eeeb e8e5 e2df dcd9 d6d3
d0cd cac7 c5c2 bfbd bab7 b5b2 b0ae aba9
a7a5 a2a0 9e9c 9a99 9795 9492 908f 8e8c
8b8a 8988 8786 8585 8483 8382 8282 8282
8182 8282 8282 8383 8485 8586 8788 898a
8b8c 8e8f 9092 9495 9799 9a9c 9ea0 a2a5
a7a9 abae b0b2 b5b7 babd bfc2 c5c7 cacd
d0d3 d6d9 dcdf e2e5 e8eb eef1 f4f7 fafd
@tri
8082 8486 888a 8c8e 9092 9496 989a 9c9e
a0a2 a4a6 a8aa acae b0b2 b4b6 b8ba bcbe
c0c2 c4c6 c8ca ccce d0d2 d4d6 d8da dcde
e0e2 e4e6 e8ea ecee f0f2 f4f6 f8fa fcfe
fffd fbf9 f7f5 f3f1 efed ebe9 e7e5 e3e1
dfdd dbd9 d7d5 d3d1 cfcd cbc9 c7c5 c3c1
bfbd bbb9 b7b5 b3b1 afad aba9 a7a5 a3a1
9f9d 9b99 9795 9391 8f8d 8b89 8785 8381
7f7d 7b79 7775 7371 6f6d 6b69 6765 6361
5f5d 5b59 5755 5351 4f4d 4b49 4745 4341
3f3d 3b39 3735 3331 2f2d 2b29 2725 2321
1f1d 1b19 1715 1311 0f0d 0b09 0705 0301
0103 0507 090b 0d0f 1113 1517 191b 1d1f
2123 2527 292b 2d2f 3133 3537 393b 3d3f
4143 4547 494b 4d4f 5153 5557 595b 5d5f
6163 6567 696b 6d6f 7173 7577 797b 7d7f
@sin
8083 8689 8c8f 9295 989b 9ea1 a4a7 aaad
b0b3 b6b9 bbbe c1c3 c6c9 cbce d0d2 d5d7
d9db dee0 e2e4 e6e7 e9eb ecee f0f1 f2f4
f5f6 f7f8 f9fa fbfb fcfd fdfe fefe fefe
fffe fefe fefe fdfd fcfb fbfa f9f8 f7f6
f5f4 f2f1 f0ee eceb e9e7 e6e4 e2e0 dedb
d9d7 d5d2 d0ce cbc9 c6c3 c1be bbb9 b6b3
b0ad aaa7 a4a1 9e9b 9895 928f 8c89 8683
807d 7a77 7471 6e6b 6865 625f 5c59 5653
504d 4a47 4542 3f3d 3a37 3532 302e 2b29
2725 2220 1e1c 1a19 1715 1412 100f 0e0c
0b0a 0908 0706 0505 0403 0302 0202 0202
0102 0202 0202 0303 0405 0506 0708 090a
0b0c 0e0f 1012 1415 1719 1a1c 1e20 2225
2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d
5053 5659 5c5f 6265 686b 6e71 7477 7a7d
@piano
8182 8588 8d91 959b a1a6 aaad b2b5 b8bd
c1c7 cbd0 d5d9 dde1 e5e5 e4e4 e1dc d7d1
cbc5 bfb8 b2ac a6a2 9c97 928d 8884 807c
7977 7574 7372 7272 7273 7372 706d 6964
605b 5650 4d49 4643 4342 4244 4548 4a4d
5052 5556 5758 5554 5150 4c4a 4744 423f
3d3c 3a38 3835 3431 3030 2f31 3336 393e
4449 4e54 5a60 666b 7175 7b82 8990 989e
a6ab b1b6 babd bebf bfbe bbb9 b6b3 b0ae
aaa8 a6a3 a19e 9c9a 9997 9696 9798 9b9e
a1a4 a6a9 a9ac adad adae aeaf b0b0 b1b1
b3b3 b4b4 b4b3 b3b1 b0ad abab a9a9 a8a8
a7a5 a19d 9891 8b84 7e77 726e 6b6b 6b6c
6f71 7477 7776 7370 6c65 5e56 4e48 423f
3d3c 3b3a 3a39 3838 3839 393a 3c3e 4146
4a50 575b 6064 686a 6e70 7274 7677 7a7d
@melody [
54 52 54 4f 4b 4f 48 ff
54 52 54 4f 4b 4f 48 ff
54 56 57 56 57 54 56 54
56 52 54 52 54 50 54 ff ]

177
projects/examples/devices/audio.tal

@ -1,177 +0,0 @@
( dev/audio )
%GET-NOTE { #00 SWP ;melody ADD2 LDA }
%GET-HEXCHAR { #00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2 }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
( variables )
|0000
@timer $1
@progress $1
@selection $1
@offset
&x $2 &y $2
|0100 ( -> )
( theme )
#0f8f .System/r DEO2
#0f8f .System/g DEO2
#0f80 .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
;on-button .Controller/vector DEO2
( setup synth )
#0208 .Audio0/adsr DEO2
;saw .Audio0/addr DEO2
#0100 .Audio0/length DEO2
#dd .Audio0/volume DEO ( TODO: turn ON )
( center )
.Screen/width DEI2 #01 SFT2 #0080 SUB2 .offset/x STZ2
.Screen/height DEI2 #01 SFT2 #0040 SUB2 .offset/y STZ2
;draw JSR2
#02 ;draw-selector JSR2
BRK
@on-button ( -> )
.Controller/button DEI #04 SFT
[ #01 ] NEQk NIP ,&no-up JCN
.selection LDZ STHk
#00 ;draw-note JSR2
[ STHkr GET-NOTE INC ] #00 STHkr ;melody ADD2 STA
STHr #01 ;draw-note JSR2
#02 ;draw-selector JSR2
&no-up
[ #02 ] NEQk NIP ,&no-down JCN
.selection LDZ STHk
#00 ;draw-note JSR2
[ STHkr GET-NOTE #01 SUB ] #00 STHkr ;melody ADD2 STA
STHr #01 ;draw-note JSR2
#02 ;draw-selector JSR2
&no-down
[ #04 ] NEQk NIP ,&no-left JCN
#00 ;draw-selector JSR2
.selection LDZ #01 SUB #1f AND .selection STZ
#02 ;draw-selector JSR2
&no-left
[ #08 ] NEQk NIP ,&no-right JCN
#00 ;draw-selector JSR2
.selection LDZ INC #1f AND .selection STZ
#02 ;draw-selector JSR2
&no-right
POP
BRK
@on-frame ( -> )
( incr ) .timer LDZ INC .timer STZ
( skip ) .timer LDZ #10 EQU #01 JCN [ BRK ]
.progress LDZ
( play note ) DUP GET-NOTE .Audio0/pitch DEO
( erase last ) DUP #01 SUB #1f AND #01 ,draw-note JSR
( draw current ) #01 ,draw-note JSR
( incr ) .progress LDZ INC #1f AND .progress STZ
#00 .timer STZ
BRK
@draw ( -- )
#20 #00
&loop
DUP #01 ,draw-note JSR
INC GTHk ,&loop JCN
POP2
JMP2r
@draw-note ( id color -- )
STH STH
( set x ) [ #00 STHkr ] #30 SFT2 .offset/x LDZ2 ADD2 .Screen/x DEO2
( set y ) [ #00 #00 STHkr ;melody ADD2 LDA ] #20 SFT2 #0100 SWP2 SUB2 .offset/y LDZ2 ADD2 #0080 ADD2 .Screen/y DEO2
( set addr ) ;marker-icn [ #00 .progress LDZ STHr EQU #08 MUL ADD2 ] .Screen/addr DEO2
( draw ) STHr .Screen/sprite DEO
JMP2r
@draw-selector ( color -- )
STH
[ #00 .selection LDZ ] #30 SFT2 .offset/x LDZ2 ADD2 .Screen/x DEO2
#0070 .offset/y LDZ2 ADD2 .Screen/y DEO2
;selector-icn .Screen/addr DEO2
STHkr .Screen/sprite DEO
.Screen/y DEI2k #0008 ADD2 ROT DEO2
.selection LDZ GET-NOTE STHr ,draw-byte JSR
JMP2r
@draw-byte ( byte color -- )
STH
DUP
#04 SFT GET-HEXCHAR
( draw ) STHkr .Screen/sprite DEO
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
#0f AND GET-HEXCHAR
( draw ) STHr .Screen/sprite DEO
JMP2r
@melody
54 52 54 4f 4b 4f 48 ff
54 52 54 4f 4b 4f 48 ff
54 56 57 56 57 54 56 54
56 52 54 52 54 50 54 ff
@selector-icn
0000 0010 387c 0000
@marker-icn
3844 8282 8244 3800
387c fefe fe7c 3800
@saw
0003 0609 0c0f 1215 181b 1e21 2427 2a2d
3033 3639 3b3e 4143 4649 4b4e 5052 5557
595b 5e60 6264 6667 696b 6c6e 7071 7274
7576 7778 797a 7b7b 7c7d 7d7e 7e7e 7e7e
7f7e 7e7e 7e7e 7d7d 7c7b 7b7a 7978 7776
7574 7271 706e 6c6b 6967 6664 6260 5e5b
5957 5552 504e 4b49 4643 413e 3b39 3633
302d 2a27 2421 1e1b 1815 120f 0c09 0603
00fd faf7 f4f1 eeeb e8e5 e2df dcd9 d6d3
d0cd cac7 c5c2 bfbd bab7 b5b2 b0ae aba9
a7a5 a2a0 9e9c 9a99 9795 9492 908f 8e8c
8b8a 8988 8786 8585 8483 8382 8282 8282
8182 8282 8282 8383 8485 8586 8788 898a
8b8c 8e8f 9092 9495 9799 9a9c 9ea0 a2a5
a7a9 abae b0b2 b5b7 babd bfc2 c5c7 cacd
d0d3 d6d9 dcdf e2e5 e8eb eef1 f4f7 fafd
@font-hex ( 0-F )
007c 8282 8282 827c 0030 1010 1010 1010
007c 8202 7c80 80fe 007c 8202 1c02 827c
000c 1424 4484 fe04 00fe 8080 7c02 827c
007c 8280 fc82 827c 007c 8202 1e02 0202
007c 8282 7c82 827c 007c 8282 7e02 827c
007c 8202 7e82 827e 00fc 8282 fc82 82fc
007c 8280 8080 827c 00fc 8282 8282 82fc
007c 8280 f080 827c 007c 8280 f080 8080

16
projects/examples/devices/console.read.tal

@ -1,16 +0,0 @@
( usage: uxncli console.read.rom )
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|0100
@on-reset ( -> )
;on-console .Console/vector DEO2
( type something in the console )
BRK
@on-console ( -> )
.Console/read DEI .Console/write DEO
#0a .Console/write DEO
BRK

83
projects/examples/devices/console.tal

@ -1,83 +0,0 @@
( usage: uxncli console.rom foo "bar baz"
| Prints Welcome to Uxn!, and listens for incoming stdin events on enter. )
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|000
@arg $40
@std $40
|100
@on-reset ( -> )
;Dict/hello <print-str>
.Console/type DEI ?{
( | no arguments )
;on-std .Console/vector DEO2
BRK }
;on-arg .Console/vector DEO2
BRK
@on-arg ( -> )
[ LIT2 02 -Console/type ] DEI NEQ ?{
.Console/read DEI [ LIT2 00 &ptr -arg ] INCk ,&ptr STR
STZ2
BRK }
;arg ;Dict/yousent <print-result>
[ LIT2 -arg _&ptr ] STR
[ LIT2 04 -Console/type ] DEI NEQ ?{ ;on-std .Console/vector DEO2 }
BRK
@on-std ( -> )
[ LIT2 0a -Console/read ] DEI EQU ?{
.Console/read DEI [ LIT2 00 &ptr -std ] INCk ,&ptr STR
STZ2
BRK }
;std DUP2 ;Dict/yousaid <print-result>
;Dict/quit scmp ?{
[ LIT2 -std _&ptr ] STR
BRK }
( quit ) #800f DEO
BRK
@<print-result> ( buf* name* -- )
<print-str>
[ LIT2 "" 18 ] DEO
<print-str>/
[ LIT2 "" 18 ] DEO
[ LIT2 00 -Console/type ] DEI DUP ADD ;Types ADD2 LDA2 <print-str>/
#0a18 DEO
JMP2r
@<print-str> ( str* -- )
LDAk #18 DEO
INC2 & LDAk ?<print-str>
POP2 JMP2r
@scmp ( a* b* -- f )
STH2
&l ( a* b* -- f )
LDAk LDAkr STHr NEQk ?&d
DUP EOR EQUk ?&d
POP2 INC2 INC2r !&l
&d ( a* c1 c2 b* -- f )
NIP2 POP2r EQU JMP2r
(
@|assets )
@Types =Dict/arg-none =Dict/arg-stdin =Dict/arg-data =Dict/arg-spacer =Dict/arg-end
@Dict
&hello "Welcome 20 "to 20 "Uxn! 0a $1
&yousaid "You 20 "said: 20 $1
&yousent "You 20 "sent: 20 $1
&quit "quit $1
&arg-none "<none> $1
&arg-stdin "<stdin> $1
&arg-data "<data> $1
&arg-spacer "<spacer> $1
&arg-end "<end> $1

22
projects/examples/devices/console.write.tal

@ -1,22 +0,0 @@
( usage: uxncli console.write.rom )
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|0100
@on-reset ( -> )
( | write )
{ "Hello 20 "Write 0a 00 }
STH2r
&wa ( -- )
LDAk .Console/write DEO
INC2 LDAk ?&wa
POP2
( | error )
{ "Hello 20 "Error 0a 00 }
STH2r
&wb ( -- )
LDAk .Console/error DEO
INC2 LDAk ?&wb
POP2 BRK

191
projects/examples/devices/controller.tal

@ -1,191 +0,0 @@
( Controller: Buttons should highlight on press and display the button and key bytes. )
|00 @System/vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen/vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|80 @Controller/vector $2 &button $1 &key $1
|000
@center/x $2 &y $2
|100
@on-reset ( -> )
( | theme )
#0fff .System/r DEO2
#0f0f .System/g DEO2
#0f0f .System/b DEO2
( | find center )
.Screen/width DEI2 #01 SFT2 .center/x STZ2
.Screen/height DEI2 #01 SFT2 .center/y STZ2
controller/<draw>
;on-button .Controller/vector DEO2
BRK
@on-button ( -> )
controller/<draw>
( | print stack on start button )
[ LIT2 08 -Controller/button ] DEI NEQ ?{ #010e DEO }
BRK
(
@|Controller )
@controller/<draw> ( -- )
.Controller/button DEI2
( | background )
.center/x LDZ2 #0040 SUB2 .Screen/x DEO2
.center/y LDZ2 #0020 SUB2 .Screen/y DEO2
#01f9 ;&icns #f6 <draw-times>
( | output )
.Screen/x DEI2 #0010 ADD2 .Screen/x DEO2
.Screen/y DEI2 #0050 SUB2 .Screen/y DEO2
DUP2 hex/<draw-short>
( | A button )
OVR #01 AND #00 EQU ?{
.center/x LDZ2 #0028 ADD2 .Screen/x DEO2
.center/y LDZ2 .Screen/y DEO2
#01fe ;large/icns #16 <draw-times> }
( | B button )
OVR #02 AND #00 EQU ?{
.center/x LDZ2 #0010 ADD2 .Screen/x DEO2
.center/y LDZ2 .Screen/y DEO2
#01fe ;large/icns #16 <draw-times> }
( | C button )
OVR #04 AND #00 EQU ?{
.center/x LDZ2 #0008 SUB2 .Screen/x DEO2
.center/y LDZ2 #0008 ADD2 .Screen/y DEO2
#01ff ;small/icn #16 <draw-times> }
( | S button )
OVR #08 AND #00 EQU ?{
.center/x LDZ2 #0018 SUB2 .Screen/x DEO2
.center/y LDZ2 #0008 ADD2 .Screen/y DEO2
#01ff ;small/icn #16 <draw-times> }
( | Up arrow )
OVR #10 AND #00 EQU ?{
.center/x LDZ2 #0030 SUB2 .Screen/x DEO2
.center/y LDZ2 #0008 SUB2 .Screen/y DEO2
#05ff ;arrow/icn #00 <draw-times> }
( | Down arrow )
OVR #20 AND #00 EQU ?{
.center/x LDZ2 #0030 SUB2 .Screen/x DEO2
.center/y LDZ2 #0008 ADD2 .Screen/y DEO2
#05ff ;arrow/icn #00 <draw-times> }
( | Left arrow )
OVR #40 AND #00 EQU ?{
.center/x LDZ2 #0038 SUB2 .Screen/x DEO2
.center/y LDZ2 .Screen/y DEO2
#05ff ;arrow/icn #00 <draw-times> }
( | Right arrow )
OVR #80 AND #00 EQU ?{
.center/x LDZ2 #0028 SUB2 .Screen/x DEO2
.center/y LDZ2 .Screen/y DEO2
#05ff ;arrow/icn #00 <draw-times> }
POP2 JMP2r
@<draw-times> ( color times addr* auto -- )
.Screen/auto DEO
.Screen/addr DEO2
SWP STH
[ LITr -Screen/sprite ]
&>l
DEOkr
INC DUP ?&>l
POP POP2r JMP2r
(
@|drawing )
@hex/<draw-short> ( short* -- )
[ LIT2 01 -Screen/auto ] DEO
SWP /<draw-byte>
( >> )
@hex/<draw-byte> ( byte -- )
DUP #04 SFT /<draw-char>
( >> )
@hex/<draw-char> ( char -- )
#00 SWP #0f AND #30 SFT2 ;&icns ADD2 .Screen/addr DEO2
[ LIT2 03 -Screen/sprite ] DEO
JMP2r
(
@|assets )
@large/icns [
071f 3f7f 7fff ffff e0f8 fcfe feff ffff
ffff ff7f 7f3f 1f07 ffff fffe fefc f8e0 ]
@small/icn [ 0000 001f 3f3f 3f1f 0000 00f8 fcfc fcf8 ]
@arrow/icn [ 187e 7eff ff7e 7e18 ]
@controller/icns [
0000 0f30 4040 8080 0000 ff00 0000 0000
0042 8100 0000 0000 0000 ff00 0000 0000
0000 ff00 0000 0000 0000 ff00 0000 0000
0000 ff00 0000 0000 0000 ff00 0000 0000
0000 ff00 0000 0000 0000 ff00 0000 0000
0000 ff00 0000 0000 0000 ff00 0000 0000
0000 ff00 0000 0000 0000 ff00 0000 0000
0000 ff00 0000 0000 0000 f00c 0202 0101
8080 8080 8080 8080 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0101 0101 0101 0101
8080 8080 8080 8080 0000 0000 0000 0000
0000 0000 0000 0018 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0302 0000 0000 0000 8040
0000 0000 0000 0000 0000 0000 0000 0102
0000 0000 0000 8040 0101 0101 0101 0101
8080 8080 8080 8080 0000 0001 0101 011f
6681 8100 0000 0000 0000 0080 8080 80f8
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0203 0202 0300 0000 4080 4040 8000 0000
0000 0000 0000 0000 0203 0202 0200 0000
40c0 4040 4000 0000 0101 0101 0101 0101
8080 8081 8180 8080 6080 8000 0080 8060
0000 0000 0000 0000 0601 0100 0001 0106
0000 0080 8000 0000 0001 0202 0100 0201
0080 4000 8040 4080 0001 0202 0202 0201
0080 4000 0000 4080 0000 0000 0000 0000
0718 2040 4080 8080 e018 0402 0201 0101
0000 0000 0000 0000 0718 2040 4080 8080
e018 0402 0201 0101 0101 0101 0101 0101
8080 8080 8080 8080 1f01 0101 0100 0000
0000 0000 0081 8166 f880 8080 8000 0000
0000 0000 0000 0000 0000 001f 2020 201f
0000 00f8 0404 04f8 0000 001f 2020 201f
0000 00f8 0404 04f8 0000 0000 0000 0000
8080 8040 4020 1807 0101 0102 0204 18e0
0000 0000 0000 0000 8080 8040 4020 1807
0101 0102 0204 18e0 0101 0101 0101 0101
8080 8080 4040 300f 0000 0000 0000 00ff
1800 0000 0000 00ff 0000 0000 0000 00ff
0000 0000 0000 00ff 0000 0000 0000 00ff
0000 0000 0000 00ff 0000 0000 0000 00ff
0000 0000 0000 00ff 0000 0000 0000 00ff
0000 0000 0000 00ff 0000 0000 0000 00ff
0000 0000 0000 00ff 0000 0000 0000 00ff
0000 0000 0000 00ff 0101 0101 0202 0cf0 ]
@hex/icns [
0018 2424 2424 2418 0008 1808 0808 0808
0018 2404 1820 203c 0018 2404 1804 2418
0024 2424 1c04 0404 003c 2020 1804 2418
0018 2420 3824 2418 003c 0408 1010 1010
0018 2424 1824 2418 0018 2424 1c04 2418
0018 2424 3c24 2424 0038 2424 3824 2438
0018 2420 2020 2418 0038 2424 2424 2438
001c 2020 3820 201c 001c 2020 3820 2020 ]

94
projects/examples/devices/datetime.tal

@ -1,94 +0,0 @@
( usage: uxncli datetime.rom )
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
|0100
@on-reset ( -> )
<print-date-num>
#0a .Console/write DEO
<print-date-str>
#0a .Console/write DEO
<print-time-num>
#0a .Console/write DEO
<print-doty>
#0a .Console/write DEO
#800f DEO
BRK
@<print-date-num> ( -- )
.DateTime/year DEI2k <print-dec>
[ LIT "- ] .Console/write DEO
INC INC DEIk INC <print-dec-pad>
[ LIT "- ] .Console/write DEO
INC DEI !<print-dec-pad>
@<print-date-str> ( -- )
;dict/date <print-str>
[ LIT2 00 -DateTime/dotw ] DEI #20 SFT ;week-txt ADD2 <print-str>
[ LIT2 20 ", ] #18 DEO
#18 DEO
[ LIT2 00 -DateTime/month ] DEI #20 SFT ;month-txt ADD2 <print-str>
#2018 DEO
[ LIT2 00 -DateTime/day ] DEI <print-dec>
[ LIT2 20 ", ] #18 DEO
#18 DEO
.DateTime/year DEI2 !<print-dec>
@<print-time-num> ( -- )
;dict/time <print-str>
.DateTime/hour DEIk <print-dec-pad>
[ LIT2 ": 18 ] DEO
INC DEIk <print-dec-pad>
[ LIT2 ": 18 ] DEO
INC DEI !<print-dec-pad>
@<print-str> ( str* -- )
&w ( -- )
LDAk #18 DEO
INC2 LDAk ?&w
POP2 JMP2r
@<print-doty> ( -- )
;dict/doty <print-str>
.DateTime/doty DEI2
( >> )
@<print-dec> ( short* -- )
#2710 [ LIT2r 00fb ]
&w ( -- )
DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?&>skip
DUP <emit-dec>
INCr &>skip
POP2 #000a DIV2 SWPr INCr STHkr ?&w
POP2r POP2 POP2 JMP2r
@<print-dec-pad> ( byte -- )
#0a DIVk <emit-dec>
DIVk MUL SUB
( >> )
@<emit-dec> ( byte -- )
LIT "0 ADD #18 DEO
JMP2r
(
@|assets )
@week-txt
[
"Sun $1 "Mon $1 "Tue $1 "Wed $1
"Thu $1 "Fri $1 "Sat $1 ]
@month-txt
[
"Jan $1 "Feb $1 "Mar $1 "Apr $1
"May $1 "Jun $1 "Jul $1 "Aug $1
"Sep $1 "Oct $1 "Nov $1 "Dec $1 ]
@dict ( )
&date "The 20 "date 20 "is: 20 $1
&time "The 20 "time 20 "is: 20 $1
&doty "The 20 "day 20 "of 20 "the 20 "year 20 "is: 20 $1

14
projects/examples/devices/file.cat.tal

@ -1,14 +0,0 @@
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|0100
@on-reset ( -> )
;filename .File/name DEO2
#0001 .File/length DEO2
&while ( -- )
;&byte .File/read DEO2
.File/success DEI2 ORA ?{ #010f DEO BRK }
[ LIT2 &byte $1 18 ] DEO
!&while
@filename "cat.tal $1

97
projects/examples/devices/file.tal

@ -1,97 +0,0 @@
( File:
Creates a temporary file called file-output.txt,
then read it back in console, print length and delete it. )
|a0 @File0 &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|b0 @File1 &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|0100 ( -> )
( write a file with file0 )
;filepath-txt .File0/name DEO2
;part1 ,append JSR
;part2 ,append JSR
( close file before changing device )
.File0/name DEI2k ROT DEO2
( read a file with file1 )
;filepath-txt .File1/name DEO2
,stream JSR
( delete file with file0 )
;filepath-txt .File0/delete DEO2
BRK
@append ( part* -- )
DUP2 ;print-str JSR2
DUP2 ;slen JSR2 STH2k .File0/length DEO2
.File0/write DEO2
( print result )
;saved-txt ;print-str JSR2
STH2r ;print JSR2 #2018 DEO
;bytes-txt ;print-str JSR2 #0a18 DEO
JMP2r
@stream ( -- )
#0001 .File1/length DEO2
LIT2r 0000
&stream
;&buf DUP2 .File1/read DEO2 LDA #18 DEO INC2r
.File1/success DEI2 #0000 NEQ2 ,&stream JCN
( print result )
;loaded-txt ;print-str JSR2
STH2r ;print JSR2 #2018 DEO
;bytes-txt ;print-str JSR2 #0a18 DEO
JMP2r
&buf $1
@slen ( str* -- len* )
DUP2 ,scap JSR SWP2 SUB2
JMP2r
@scap ( str* -- end* )
LDAk #00 NEQ JMP JMP2r
&while INC2 LDAk ,&while JCN
JMP2r
@print ( short* -- )
&short ( short* -- ) SWP ,&byte JSR
&byte ( byte -- ) DUP #04 SFT ,&char JSR
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
JMP2r
@print-str ( str* -- )
&while
LDAk #18 DEO
INC2 LDAk ,&while JCN
POP2
JMP2r
@saved-txt "Saved 20 $1
@loaded-txt "Loaded 20 $1
@bytes-txt "bytes. $1
@filepath-txt "file-output.txt $1
@part1
596f 7572 2073 6163 7265 6420 706c 616e
7473 2c20 6966 2068 6572 6520 6265 6c6f
772c 0a4f 6e6c 7920 616d 6f6e 6720 7468
6520 706c 616e 7473 2077 696c 6c20 6772
6f77 2e0a 00
@part2
536f 6369 6574 7920 6973 2061 6c6c 2062
7574 2072 7564 652c 0a54 6f20 7468 6973
2064 656c 6963 696f 7573 2073 6f6c 6974
7564 652e 0a

186
projects/examples/devices/mouse.tal

@ -1,186 +0,0 @@
( Mouse: Paint with 3 colors with each mouse button. )
|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &modx $2 &mody $2
|0000
@length $2
@frame $2
@pen &x $2 &y $2 &x2 $2 &y2 $2
@pointer &x $2 &y $2 &lastx $2 &lasty $2 &state $1
|0100
@on-reset ( -> )
( | theme )
#48af .System/r DEO2
#59bf .System/g DEO2
#6ace .System/b DEO2
( | vectors )
;on-mouse .Mouse/vector DEO2
;on-frame .Screen/vector DEO2
<draw-mouse>
BRK
(
@|vectors )
@on-frame ( -> )
.Mouse/state DEI ?{
;run DUP2 JSR2 JSR2 }
BRK
@on-mouse ( -> )
( | clear last cursor )
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
;fill-icn .Screen/addr DEO2
[ LIT2 40 -Screen/sprite ] DEO
<draw-mouse>
( | draw new cursor )
;pointer-icn .Screen/addr DEO2
#00 .Screen/auto DEO
.Mouse/x DEI2 DUP2 .pointer/x STZ2
.Screen/x DEO2
.Mouse/y DEI2 DUP2 .pointer/y STZ2
.Screen/y DEO2
#45 .Mouse/state DEI #00 NEQ #05 MUL ADD .Screen/sprite DEO
( | on down )
.Mouse/state DEI #00 NEQ .pointer/state LDZ #00 EQU AND ?&down
( | on drag )
.Mouse/state DEI ?&drag
.Mouse/state DEI .pointer/state STZ
BRK
&down ( -> )
#0000 DUP2 .length STZ2
.frame STZ2
<clear-screen>
( | record start position )
.Mouse/x DEI2 DUP2 .pointer/x STZ2
.pointer/lastx STZ2
.Mouse/y DEI2 DUP2 .pointer/y STZ2
.pointer/lasty STZ2
.Mouse/state DEI .pointer/state STZ
BRK
&drag ( -> )
( | record )
;stroke .length LDZ2 #20 SFT2 ADD2 STH2 .pointer/x LDZ2 .pointer/lastx LDZ2 SUB2 STH2kr STA2
.pointer/y LDZ2 .pointer/lasty LDZ2 SUB2 STH2r INC2 INC2 STA2
( | move ptr )
.length LDZ2 INC2 .length STZ2
( | draw line )
.pointer/lastx LDZ2 .pointer/lasty LDZ2 .pointer/x LDZ2 .pointer/y LDZ2 #01 <draw-line>
( | record last position )
.Mouse/x DEI2 DUP2 .pointer/lastx STZ2
DUP2 .pen/x STZ2
.pen/x2 STZ2
.Mouse/y DEI2 DUP2 .pointer/lasty STZ2
DUP2 .pen/y STZ2
.pen/y2 STZ2
.Mouse/state DEI DUP #01 NEQ INC ;run/color STA
.pointer/state STZ
BRK
(
@|main )
@run ( -- )
( | read )
;stroke .frame LDZ2 #20 SFT2 ADD2 STH2 .pen/x LDZ2 STH2kr LDA2 ADD2 .pen/x STZ2
.pen/y LDZ2 STH2r INC2 INC2 LDA2 ADD2 .pen/y STZ2
( | line )
.pen/x LDZ2 .pen/y LDZ2 .pen/x2 LDZ2 .pen/y2 LDZ2 .frame LDZ2 #01 SFT2 NIP #01 AND [ LIT &color $1 ] ADD INC <draw-line>
( | history )
.pen/x LDZ2 .pen/x2 STZ2
.pen/y LDZ2 .pen/y2 STZ2
( | incr frame )
.frame LDZ2 INC2 .length LDZ2 INC2
( mod2 ) DIV2k MUL2 SUB2 .frame STZ2
JMP2r
@<draw-mouse> ( -- )
( | clear )
#0010 DUP2 .Screen/x DEO2
.Screen/y DEO2
#16 .Screen/auto DEO
;fill-icn .Screen/addr DEO2
#40 .Screen/sprite DEOk
DEO
( | buttons )
#0300
&l ( -- )
#01 OVR #40 SFT SFT .Mouse/state DEI AND #00 EQU ?{
#0010 .Screen/y DEO2
#00 OVR #40 SFT2 ;button-icn ADD2 .Screen/addr DEO2
#45 .Screen/sprite DEO }
INC GTHk ?&l
POP2
( | outline )
#0010 .Screen/y DEO2
;mouse-icn .Screen/addr DEO2
#16 .Screen/auto DEO
#4a .Screen/sprite DEOk
DEO
JMP2r
@<draw-line> ( x1* y1* x2* y2* color -- )
,&color STR
,&y STR2
,&x STR2
,&y2 STR2
,&x2 STR2
,&x LDR2 ,&x2 LDR2 SUB2 abs2 ,&dx STR2
#0000 ,&y LDR2 ,&y2 LDR2 SUB2 abs2 SUB2 ,&dy STR2
#ffff [ LIT2 00 _&x2 ] LDR2 ,&x LDR2 lts2 DUP2 ADD2 ADD2 ,&sx STR2
#ffff [ LIT2 00 _&y2 ] LDR2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2
[ LIT2 &dx $2 ] [ LIT2 &dy $2 ] ADD2 STH2
&while ( -- )
[ LIT2 &x2 $2 ] DUP2 .Screen/x DEO2
[ LIT2 &x $2 ] EQU2 [ LIT2 &y2 $2 ] DUP2 .Screen/y DEO2
[ LIT2 &y $2 ] EQU2 [ LIT2 &color $1 -Screen/pixel ] DEO
AND ?&end
STH2kr DUP2 ADD2 DUP2 ,&dy LDR2 lts2 ?&skipy
STH2r ,&dy LDR2 ADD2 STH2 ,&x2 LDR2 [ LIT2 &sx $2 ] ADD2 ,&x2 STR2
&skipy ( -- )
,&dx LDR2 gts2 ?&while
STH2r ,&dx LDR2 ADD2 STH2 ,&y2 LDR2 [ LIT2 &sy $2 ] ADD2 ,&y2 STR2
!&while
&end POP2r JMP2r
@abs2 ( a* -- f )
DUP2 #0f SFT2 EQU ?{ #0000 SWP2 SUB2 }
JMP2r
@lts2 ( a* b* -- f )
#8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r
@gts2 ( a* b* -- f )
#8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 JMP2r
@<clear-screen> ( -- )
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
#80 .Screen/pixel DEO
JMP2r
@fill-icn [ ffff ffff ffff ffff ]
@pointer-icn [ 80c0 e0f0 f8e0 1000 ]
@mouse-icn [
000d 1212 1212 121d 00b0 4848 4848 48b8
1010 1010 1008 0700 0808 0808 0810 e000 ]
@button-icn [
000c 1e1e 1e1e 1e0c 0000 0000 0000 0000
0001 0303 0303 0301 0080 c0c0 c0c0 c080
0000 0000 0000 0000 0030 7878 7878 7830 ]
(
@|memory )
@stroke

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save