0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-16 11:15:06 +00:00

Compare commits

..

54 commits

Author SHA1 Message Date
Sigrid Solveig Haflínudóttir
123dc07136 android: stay compatible with the current android studio release 2022-01-16 20:38:21 +01:00
Sigrid Solveig Haflínudóttir
361cedfc7f android: clean up and update for new release 2022-01-16 20:31:38 +01:00
Sigrid Solveig Haflínudóttir
e29943e644 Merge remote-tracking branch 'origin/main' into android 2022-01-16 20:30:27 +01:00
Sigrid Solveig Haflínudóttir
ebed3e05b1 update android instructions 2022-01-16 20:24:51 +01:00
Sigrid Solveig Haflínudóttir
1cbc9cd849 android: fix the crash on startup 2022-01-16 20:24:10 +01:00
Sigrid Solveig Haflínudóttir
e92fec2c4d android: cut another release 2022-01-16 01:57:21 +01:00
Sigrid Solveig Haflínudóttir
1b37052b29 add more roms 2022-01-16 01:39:28 +01:00
Sigrid Solveig Haflínudóttir
fa569a6e1e android: fix to build updated sources 2022-01-16 01:25:12 +01:00
Sigrid Solveig Haflínudóttir
6a770dcd5a android: add back unistd.h 2022-01-16 01:07:02 +01:00
Sigrid Solveig Haflínudóttir
e878b06c1c android: put gSrcDst into a proper ifdef 2022-01-16 01:01:40 +01:00
Sigrid Solveig Haflínudóttir
357aa65fd0 Merge branch 'main' into android 2022-01-16 00:58:02 +01:00
Sigrid Solveig Haflínudóttir
11a7c1ed22 android: include system.c in the build 2022-01-05 23:47:33 +01:00
Sigrid Solveig Haflínudóttir
544d2f2a86 Merge remote-tracking branch 'origin/main' into android 2022-01-05 22:55:23 +01:00
Sigrid Solveig Haflínudóttir
2272fd653f android: new release 2022-01-05 01:07:20 +01:00
Sigrid Solveig Haflínudóttir
35f63c5d6e android: add more information to the readme, to use as a guide 2022-01-04 23:51:18 +01:00
Sigrid Solveig Haflínudóttir
3384591f5d android: update SDL 2022-01-04 23:07:43 +01:00
Sigrid Solveig Haflínudóttir
822e23b69b android: disable fullscreen mode and simplify/cleanup a few things 2022-01-04 22:42:07 +01:00
Sigrid Solveig Haflínudóttir
42de14cd8a android: do not use cache to store roms (nor any files) 2022-01-04 21:39:36 +01:00
Sigrid Solveig Haflínudóttir
6494261426 android: keep compatibility with older java by not using nio :( 2022-01-04 21:26:34 +01:00
Sigrid Solveig Haflínudóttir
f441163965 android: uxn-fast.c → uxn.c 2022-01-04 20:44:39 +01:00
Sigrid Solveig Haflínudóttir
dd9bd1532d Merge remote-tracking branch 'origin/main' into android 2022-01-04 20:31:10 +01:00
Sigrid Solveig Haflínudóttir
b581e59f62 android: sync SDL android parts 2022-01-04 16:43:03 +01:00
Sigrid Solveig Haflínudóttir
eba4a601be android: update sdk and make a new release 2022-01-01 20:42:14 +01:00
Sigrid Solveig Haflínudóttir
e153943fe0 android: screen orientation → fullSensor 2022-01-01 20:41:42 +01:00
Sigrid Solveig Haflínudóttir
e4d9f08ede android: include more roms by default 2022-01-01 20:08:03 +01:00
Sigrid Solveig Haflínudóttir
467d99ee39 android: build demos 2022-01-01 20:07:25 +01:00
Sigrid Solveig Haflínudóttir
5137db7df0 android: enable deprecation warnings 2022-01-01 19:46:58 +01:00
Sigrid Solveig Haflínudóttir
a00a17badd android: copy all roms from assets to cache dir 2022-01-01 19:46:18 +01:00
Sigrid Solveig Haflínudóttir
c86854a562 android: add private policy 2021-12-31 19:05:38 +01:00
Sigrid Solveig Haflínudóttir
6f5f104367 android: put the screen at the top in portrait mode 2021-12-31 18:18:57 +01:00
Sigrid Solveig Haflínudóttir
a95208bfe0 ignore app/{debug,release} 2021-12-30 01:47:29 +01:00
Sigrid Solveig Haflínudóttir
1a217f9fbf update gradle dep 2021-12-30 00:52:26 +01:00
Sigrid Solveig Haflínudóttir
1a8ba3435b ignore various android garbage 2021-12-30 00:52:07 +01:00
Sigrid Solveig Haflínudóttir
666b576761 emu: make sure to handle key down event if the same key is up at the same frame 2021-12-29 23:31:08 +01:00
Sigrid Solveig Haflínudóttir
173f6f8678 clear screen on start of rom 2021-12-29 23:30:11 +01:00
Sigrid Solveig Haflínudóttir
4651d07e57 android: only real joysticks allowed, no accelerometer 2021-12-29 23:29:51 +01:00
Sigrid Solveig Haflínudóttir
72a26cb0c9 once again... 2021-12-29 23:01:11 +01:00
Sigrid Solveig Haflínudóttir
67a9b1a4b0 android: fix all the merging/rebasing mess 2021-12-29 22:32:27 +01:00
Sigrid Solveig Haflínudóttir
69baac4646 android: add readme 2021-12-29 22:15:00 +01:00
Sigrid Solveig Haflínudóttir
b38e22f711 android: fix a typo 2021-12-29 22:15:00 +01:00
Sigrid Solveig Haflínudóttir
4086354ad3 android: remove piano from assets, it's only boot rom that can be accessed anyway 2021-12-29 22:15:00 +01:00
Sigrid Solveig Haflínudóttir
a4fb725982 android: add boot and piano roms to assets, link the ones in bin/ folder 2021-12-29 22:15:00 +01:00
Sigrid Solveig Haflínudóttir
e24912ee66 android: orientations hint doesn't seem to be needed 2021-12-29 22:15:00 +01:00
Sigrid Solveig Haflínudóttir
539a6fe8d6 android: fix portrait/landscape by redrawing twice 2021-12-29 22:14:58 +01:00
Sigrid Solveig Haflínudóttir
dce68e0e41 android: set current dir to cache so boot.rom and file i/o are usable 2021-12-29 21:02:24 +01:00
Sigrid Solveig Haflínudóttir
20a6f050fc android: file open: use display name of the file itself 2021-12-29 21:01:51 +01:00
Sigrid Solveig Haflínudóttir
e0642b6091 android: replace fprintf with android logging 2021-12-29 21:01:51 +01:00
Sigrid Solveig Haflínudóttir
c541d4f56b android: steal out-of-screen mouse activity and use it to toggle on-screen keyboard 2021-12-29 21:01:49 +01:00
Sigrid Solveig Haflínudóttir
939f7bb546 android: disable zoom, allow portrait/landscape rotation 2021-12-29 20:59:40 +01:00
Sigrid Solveig Haflínudóttir
b645fcb14a android: sync sdl activity with upstream 2021-12-29 20:57:48 +01:00
Sigrid Solveig Haflínudóttir
f6e48c482c add basic gamepad support 2021-12-29 20:57:46 +01:00
Sigrid Solveig Haflínudóttir
8e04040958 add files to build an APK fort Android 2021-12-29 20:52:52 +01:00
Sigrid Solveig Haflínudóttir
2c98eff255 ppu aarch64: __aarch64__-guard the code 2021-12-29 20:52:52 +01:00
Sigrid Solveig Haflínudóttir
94985be51b go full-on aarch64 mode, with clang as the default (and only supported) compiler 2021-12-29 20:52:52 +01:00
203 changed files with 15211 additions and 8787 deletions

View file

@ -4,33 +4,35 @@ packages:
- build-essential
- libsdl2-dev
- rsync
- wget
- zip
oauth: pages.sr.ht/PAGES:RW
environment:
SITE: rabbits.srht.site/uxn
SITE: rabbits.srht.site
SSH_HOST_KEYS: |
[w1-uxn.build.alderwick.co.uk]:2222 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP+IYCB4JrKklFjWSMRkPBTqUjBqUuhlDQy6/X3l8xj5
[m1-uxn.build.alderwick.co.uk]:2223 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDvWVqlHh3XQ5ziEbT55K896/mW2BVDdkU6hWgIfU9md
[p1-uxn.build.alderwick.co.uk]:2224 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAgduGa60Tx3PsnEaJDyUzmPmpzGYmDeLFtLcVoU5tJs
[w1.uxn-build.ald.nu]:2222 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP+IYCB4JrKklFjWSMRkPBTqUjBqUuhlDQy6/X3l8xj5
[m1.uxn-build.ald.nu]:2223 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDvWVqlHh3XQ5ziEbT55K896/mW2BVDdkU6hWgIfU9md
[p1.uxn-build.ald.nu]:2224 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAgduGa60Tx3PsnEaJDyUzmPmpzGYmDeLFtLcVoU5tJs
secrets:
- 138ad607-a4ec-4d74-88a1-8f3be2ba2d03
sources:
- https://git.sr.ht/~rabbits/uxn
tasks:
- prepare: |
rm -f out build
mkdir -p out build/uxn-lin64 build/uxn-win64 build/uxn-mac64 build/essentials/uxn
rm -f out
mkdir -p out
umask 077
mkdir -p ~/.ssh
printf '%s\n' "${SSH_HOST_KEYS}" > ~/.ssh/known_hosts
printf 'User build\nStrictHostKeyChecking yes\nCheckHostIP no\nHost win\nHostName w1-uxn.build.alderwick.co.uk\nPort 2222\nHost mac\nHostName m1-uxn.build.alderwick.co.uk\nPort 2223\nHost 9front\nHostName p1-uxn.build.alderwick.co.uk\nPort 2224\n' > ~/.ssh/config
printf 'User build\nStrictHostKeyChecking yes\nCheckHostIP no\nHost win\nHostName w1.uxn-build.ald.nu\nPort 2222\nHost mac\nHostName m1.uxn-build.ald.nu\nPort 2223\nHost 9front\nHostName p1.uxn-build.ald.nu\nPort 2224\n' > ~/.ssh/config
- build-linux: |
cd uxn
./build.sh --no-run
mv bin ../build/uxn-lin64/uxn
- build-essentials: |
for F in uxn/projects/software/calc.tal uxn/projects/software/launcher.tal uxn/projects/examples/demos/piano.tal uxn/projects/examples/software/clock.tal catclock/src/catclock.tal dexe/src/dexe.tal donsol/src/main.tal left/src/left.tal nasu/src/nasu.tal noodle/src/noodle.tal orca-toy/src/orca.tal:orca.rom turye/src/turye.tal; do
mv bin uxn
tar -czf ../out/uxn-linux-amd64.tar.gz uxn
cd ..
- build-rompack: |
mkdir -p rompack/uxn
for F in uxn/projects/software/calc.tal uxn/projects/software/launcher.tal uxn/projects/examples/demos/piano.tal uxn/projects/examples/demos/clock.tal catclock/src/main.tal dexe/src/main.tal donsol/src/main.tal left/src/main.tal nasu/src/main.tal noodle/src/main.tal orca-toy/src/main.tal:orca.rom turye/src/main.tal; do
PROJECT="${F%%/*}"
if [ "${F}" = "${F%:*}" ]; then
ROMNAME="${F##*/}"
@ -41,39 +43,20 @@ tasks:
F="${F%:*}"
fi
[ -d "${PROJECT}" ] || git clone "https://git.sr.ht/~rabbits/${PROJECT}"
( cd "${PROJECT}" && ../build/uxn-lin64/uxn/uxnasm "${F#*/}" "../build/essentials/uxn/${ROMNAME}" || rm -f "../build/essentials/uxn/${ROMNAME}" )
( cd "${PROJECT}" && ../uxn/uxn/uxnasm "${F#*/}" "../rompack/uxn/${ROMNAME}" || rm -f "../rompack/uxn/${ROMNAME}" )
done
tar -czf out/uxn-rompack.tar.gz -C rompack uxn
( cd rompack && zip -qr ../out/uxn-rompack.zip uxn )
[ -e ~/.ssh/id_rsa ] || complete-build
- build-windows: |
if ssh -o ConnectTimeout=10 win true; then
ssh win "export PATH=\"\${PATH}:/mingw64/bin\"; set -ex; cd uxn; git fetch; git checkout .; git clean -xfd; git checkout $(cd uxn && git rev-parse HEAD); MSYSTEM=MSYS ./build.sh --no-run"
rsync -rp win:uxn/bin/ build/uxn-win64/uxn/
else
wget -nv -NP out "https://${SITE}/"uxn{,-essentials}-win64.{tar.gz,zip} || true
touch out/needs-solar-build
fi
ssh win "rm -f uxn-windows-64bit.zip; export PATH=\"\${PATH}:/mingw64/bin\"; set -ex; cd uxn; git fetch; git checkout .; git clean -xfd; git checkout $(cd uxn && git rev-parse HEAD); MSYSTEM=MSYS ./build.sh --no-run; mv bin uxn; zip -qr ../uxn-windows-64bit.zip uxn"
rsync win:uxn-windows-64bit.zip out/
- build-macos: |
if ssh -o ConnectTimeout=10 mac true; then
ssh mac "export PATH=\"\${PATH}:/usr/local/bin\"; set -ex; cd uxn; git fetch; git checkout .; git clean -xfd; git checkout $(cd uxn && git rev-parse HEAD); ./build.sh --no-run"
rsync -rp mac:uxn/bin/ build/uxn-mac64/uxn/
else
wget -nv -NP out "https://${SITE}/"uxn{,-essentials}-mac64.{tar.gz,zip} || true
touch out/needs-solar-build
fi
- archive: |
for PROJECT in uxn-lin64 uxn-win64 uxn-mac64 essentials; do
[ -d "build/${PROJECT}/uxn" ] || continue
tar -czf "out/${PROJECT}.tar.gz" -C "build/${PROJECT}" uxn
( cd "build/${PROJECT}" && zip -qr "../../out/${PROJECT}.zip" uxn )
if [ "${PROJECT}" != essentials ]; then
cp build/essentials/uxn/* "build/${PROJECT}/uxn/"
tar -czf "out/uxn-essentials-${PROJECT#uxn-}.tar.gz" -C "build/${PROJECT}" uxn
( cd "build/${PROJECT}" && zip -qr "../../out/uxn-essentials-${PROJECT#uxn-}.zip" uxn )
fi
done
ssh mac "rm -f uxn-macos.tar.gz; export PATH=\"\${PATH}:/usr/local/bin\"; set -ex; cd uxn; git fetch; git checkout .; git clean -xfd; git checkout $(cd uxn && git rev-parse HEAD); ./build.sh --no-run; mv bin uxn; tar -zcf ../uxn-macos.tar.gz uxn"
rsync mac:uxn-macos.tar.gz out/
- upload: |
ls -l out
if [ "$(cd uxn && git rev-parse HEAD)" != "$(cd uxn && git rev-parse origin/main)" ]; then exit; fi
ls -l out
tar -czf out.tar.gz -C out .
acurl() {
set +x
@ -83,6 +66,4 @@ tasks:
acurl -fsS "https://pages.sr.ht/publish/${SITE}" -Fcontent=@out.tar.gz
acurl -fsS "https://pages.sr.ht/publish/${SITE}" -Fcontent=@out.tar.gz -Fprotocol=GEMINI
- build-9front: |
if ssh -o ConnectTimeout=10 9front true; then
ssh 9front "$(cd uxn && git rev-parse HEAD)"
fi

2
.gitignore vendored
View file

@ -12,6 +12,6 @@
*snarf
*theme
*.rom.sym
*.rom
*.[o0125678vqki]

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "src/android/app/jni/SDL/SDL"]
path = src/android/app/jni/SDL/SDL
url = git://github.com/libsdl-org/SDL

Binary file not shown.

39
README.android.md Normal file
View file

@ -0,0 +1,39 @@
# Uxn on Android
This is a working port of Uxn to run on Android.
## Guide
To get a proper on-screen keyboard, install
[Hacker's Keyboard](https://play.google.com/store/apps/details?id=org.pocketworkstation.pckeyboard).
Use it naturally, as you would use a physical keyboard,
including pressing and holding modifiers (Ctrl, Alt, etc) with letters
if a ROM requires it (like Noodle, to load or save an image).
Another alternative keyboard is [Multiling O](https://play.google.com/store/apps/details?id=kl.ime.oh).
Tapping anywhere outside of ROM screen area will toggle the keyboard.
`F4` will invoke "boot" ROM, which displays all the ROMs available for loading,
including those you once downloaded with a browser and then opened using Uxn.
## Building yourself
Easiest way to start is to install JDK first, then [Android
Studio](https://developer.android.com/studio) and make sure NDK is
there to use on your computer. Your OS package manager might already
have the packages required, if you're willing to go that route.
Make sure environment is properly configured:
; ls $ANDROID_HOME
build-tools emulator licenses ndk patcher platform-tools platforms tools
You should be able to build now:
; ./prepare-android.sh
; cd src/android; ./gradlew assembleDebug
; find app -name *.apk
app/build/outputs/apk/debug/app-debug.apk
Refer to Android development documentation for more details.

View file

@ -4,7 +4,7 @@ An assembler and emulator for the [Uxn stack-machine](https://wiki.xxiivv.com/si
## Download binaries
Binaries are available for 64-bit x86 computers running [Linux](https://drive.100r.co/uxn/uxn-essentials-lin64.tar.gz), [Windows](https://drive.100r.co/uxn/uxn-essentials-win64.zip) and [macOS](https://drive.100r.co/uxn/uxn-essentials-mac64.tar.gz).
Binaries are available for 64-bit x86 computers running [Linux](https://rabbits.srht.site/uxn-linux-amd64.tar.gz), [Windows](https://rabbits.srht.site/uxn-windows-64bit.zip) and [macOS](https://rabbits.srht.site/uxn-macos.tar.gz).
## Build
@ -25,21 +25,20 @@ Build the assembler and emulator by running the `build.sh` script. The assembler
./build.sh
--debug # Add debug flags to compiler
--format # Format source code
--install # Copy to ~/bin
```
If you wish to build the emulator without graphics mode:
```sh
cc src/devices/datetime.c src/devices/system.c src/devices/console.c src/devices/file.c src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli
cc src/devices/datetime.c src/devices/system.c src/devices/file.c src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli
```
### Plan 9
To build and install the Uxn emulator on [9front](http://9front.org/), via [npe](https://git.sr.ht/~ft/npe):
To build the Uxn emulator on [9front](http://9front.org/), via [npe](https://git.sr.ht/~ft/npe):
```rc
mk install
mk
```
If the build fails on 9front because of missing headers or functions, try again after `rm -r /sys/include/npe`.
@ -86,24 +85,18 @@ You can send events from Uxn to another application, or another instance of uxn,
uxnemu orca.rom | shim
```
## GUI Emulator Options
## Emulator Options
- `-2x` Force medium scale
- `-3x` Force large scale
- `-f` Force fullscreen mode
- `--` Force next argument to be read as ROM name. (This is useful if your ROM file is named `-v`, `-2x`, and so forth.)
- `-s 1`, `-s 2` or `-s 3` set zoom (default 1)
## GUI Emulator Controls
## Emulator Controls
- `F1` toggle zoom
- `F2` toggle debugger
- `F3` quit
- `F4` reboot
- `F5` reboot(soft)
- `F11` toggle fullscreen
- `F12` toggle decorations
- `F2` toggle debug
- `F3` capture screen
- `F4` load launcher.rom
### GUI Buttons
### Buttons
- `LCTRL` A
- `LALT` B
@ -115,9 +108,11 @@ uxnemu orca.rom | shim
The following resources are a good place to start:
* [XXIIVV — uxntal](https://wiki.xxiivv.com/site/uxntal.html)
* [XXIIVV — uxntal cheatsheet](https://wiki.xxiivv.com/site/uxntal_cheatsheet.html)
* [XXIIVV — uxntal reference](https://wiki.xxiivv.com/site/uxntal_reference.html)
* [compudanzas — uxn tutorial](https://compudanzas.net/uxn_tutorial.html)
* [Fediverse — #uxn tag](https://merveilles.town/tags/uxn)
You can also find us in [`#uxn` on irc.esper.net](ircs://irc.esper.net:6697/#uxn).
## Contributing

BIN
boot.rom

Binary file not shown.

View file

@ -2,7 +2,6 @@
format=0
console=0
install=0
debug=0
norun=0
@ -18,11 +17,6 @@ while [ $# -gt 0 ]; do
shift
;;
--install)
install=1
shift
;;
--debug)
debug=1
shift
@ -38,24 +32,44 @@ while [ $# -gt 0 ]; do
esac
done
rm -f bin/*
echo "Cleaning.."
rm -f ./bin/uxnasm
rm -f ./bin/uxnemu
rm -f ./bin/uxncli
rm -f ./bin/launcher.rom
rm -f ./bin/asma.rom
# When clang-format is present
if [ $format = 1 ];
then
echo "Formatting.."
clang-format -i src/uxn.h
clang-format -i src/uxn.c
clang-format -i src/devices/system.h
clang-format -i src/devices/system.c
clang-format -i src/devices/screen.h
clang-format -i src/devices/screen.c
clang-format -i src/devices/audio.h
clang-format -i src/devices/audio.c
clang-format -i src/devices/file.h
clang-format -i src/devices/file.c
clang-format -i src/devices/mouse.h
clang-format -i src/devices/mouse.c
clang-format -i src/devices/controller.h
clang-format -i src/devices/controller.c
clang-format -i src/devices/datetime.h
clang-format -i src/devices/datetime.c
clang-format -i src/uxnasm.c
clang-format -i src/uxncli.c
clang-format -i src/uxnemu.c
clang-format -i src/devices/*
clang-format -i src/uxncli.c
fi
mkdir -p bin
CC="${CC:-cc}"
CC="${CC:-clang}"
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')"
@ -64,8 +78,8 @@ MSYS_NT*|MINGW*) # MSYS2 on Windows
fi
;;
Darwin) # macOS
CFLAGS="${CFLAGS} -Wno-typedef-redefinition -D_C99_SOURCE"
UXNEMU_LDFLAGS="$(sdl2-config --cflags --static-libs)"
CFLAGS="${CFLAGS} -Wno-typedef-redefinition"
UXNEMU_LDFLAGS="$(brew --prefix)/lib/libSDL2.a $(sdl2-config --cflags --static-libs | sed -e 's/-lSDL2 //')"
;;
Linux|*)
UXNEMU_LDFLAGS="-L/usr/local/lib $(sdl2-config --cflags --libs)"
@ -76,27 +90,39 @@ 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"
CORE='src/uxn.c'
else
CFLAGS="${CFLAGS} -DNDEBUG -O2 -g0 -s"
CFLAGS="${CFLAGS} -DNDEBUG -Os -g0 -s"
CORE='src/uxn.c'
fi
echo "Building.."
${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
${CC} ${CFLAGS} ${CORE} src/devices/system.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} -o bin/uxnemu
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli
if [ $install = 1 ]
if [ -d "$HOME/bin" ]
then
echo "Installing in $HOME/bin"
cp bin/uxnemu bin/uxnasm bin/uxncli $HOME/bin/
fi
echo "Assembling(launcher).."
./bin/uxnasm projects/software/launcher.tal bin/launcher.rom
echo "Assembling(asma).."
./bin/uxnasm projects/software/asma.tal bin/asma.rom
echo "Assembling roms.."
for f in projects/examples/demos/*.tal
do
bin/uxncli bin/asma.rom $f bin/`basename ${f%.tal}`.rom 2> /dev/null
done
if [ $norun = 1 ]; then exit; fi
# Test version
echo "Running.."
cd bin
./uxnemu piano.rom
bin/uxnasm -v
bin/uxncli -v
bin/uxnemu -v
# Start potato
bin/uxnemu -2x
echo "Done."
cd ..

View file

@ -10,16 +10,11 @@ expect_failure() {
if ! grep -qF "${1}" asma-test/asma.log; then
echo "error: asma didn't report error ${1} in faulty code"
cat asma-test/asma.log
exit 1
fi
}
echo 'Assembling asma with uxnasm'
if ! bin/uxnasm projects/software/asma.tal asma-test/asma.rom > asma-test/uxnasm.log; then
echo 'Failed to assemble asma!'
cat asma-test/uxnasm.log
exit 1
fi
bin/uxnasm projects/software/asma.tal asma-test/asma.rom > asma-test/uxnasm.log
for F in $(find projects -path projects/library -prune -false -or -path projects/assets -prune -false -or -type f -name '*.tal' | sort); do
echo "Comparing assembly of ${F}"
@ -57,25 +52,21 @@ EOD
expect_failure 'Invalid hexadecimal: #000' <<'EOD'
|1000 #000
EOD
expect_failure 'Label not found: 0' <<'EOD'
expect_failure 'Unrecognised token: 0' <<'EOD'
|1000 0
EOD
expect_failure 'Label not found: 000' <<'EOD'
expect_failure 'Unrecognised token: 000' <<'EOD'
|1000 000
EOD
expect_failure 'Address not in zero page: .hello' <<'EOD'
|1000 @hello
.hello
EOD
expect_failure 'Address not in zero page: -hello' <<'EOD'
|1000 @hello
-hello
EOD
expect_failure 'Address outside range: ,hello' <<'EOD'
|1000 @hello
|2000 ,hello
EOD
expect_failure 'Label not found: hello' <<'EOD'
expect_failure 'Unrecognised token: hello' <<'EOD'
hello
EOD
expect_failure 'Macro already exists: %me' <<'EOD'
@ -86,34 +77,22 @@ expect_failure 'Memory overwrite: SUB' <<'EOD'
|2000 ADD
|1000 SUB
EOD
# expect_failure 'Recursion level too deep:' <<'EOD'
# %me { you }
# %you { me }
# |1000 me
# EOD
# expect_failure 'Recursion level too deep: ~asma-test/in.tal' <<'EOD'
# ~asma-test/in.tal
# EOD
expect_failure 'Recursion level too deep:' <<'EOD'
%me { you }
%you { me }
|1000 me
EOD
expect_failure 'Recursion level too deep: ~asma-test/in.tal' <<'EOD'
~asma-test/in.tal
EOD
expect_failure 'Label not found: ;blah' <<'EOD'
|1000 ;blah
EOD
expect_failure 'Label not found: :blah' <<'EOD'
|1000 :blah
EOD
expect_failure 'Label not found: =blah' <<'EOD'
|1000 =blah
EOD
expect_failure 'Label not found: -blah' <<'EOD'
|1000 -blah
EOD
expect_failure 'Label not found: ,blah' <<'EOD'
|1000 ,blah
EOD
expect_failure 'Label not found: .blah' <<'EOD'
|1000 .blah
EOD
expect_failure "Label not found: 'a" <<'EOD'
|1000 'a
EOD
echo 'All OK'

View file

@ -1,103 +1,196 @@
local output = assert(io.open('.asma.tal', 'w'))
local process_subtree
process_subtree = function(items)
local middle = math.floor(#items / 2 + 1.25)
local node = items[middle]
if not node then
return
end
node.left = process_subtree((function()
local _accum_0 = { }
local _len_0 = 1
for i, item in ipairs(items) do
if i < middle then
_accum_0[_len_0] = item
_len_0 = _len_0 + 1
end
end
return _accum_0
end)())
node.right = process_subtree((function()
local _accum_0 = { }
local _len_0 = 1
for i, item in ipairs(items) do
if i > middle then
_accum_0[_len_0] = item
_len_0 = _len_0 + 1
end
end
return _accum_0
end)())
return node
end
local process_tree
process_tree = function(items)
local sorted_items
local spairs
spairs = function(t)
local keys
do
local _accum_0 = { }
local _len_0 = 1
for _index_0 = 1, #items do
local item = items[_index_0]
_accum_0[_len_0] = item
for k in pairs(t) do
_accum_0[_len_0] = k
_len_0 = _len_0 + 1
end
sorted_items = _accum_0
keys = _accum_0
end
table.sort(sorted_items, function(a, b)
return a.order < b.order
end);
(process_subtree(sorted_items)).label = '&_entry'
for _index_0 = 1, #items do
local item = items[_index_0]
output:write(('\t%-11s %-10s %-12s %s%s\n'):format(item.label, item.left and item.left.ref or ' $2', (item.right and item.right.ref or ' $2') .. item.extra, item.key, item.rest))
table.sort(keys)
local i = 0
return function()
i = i + 1
return keys[i], t[keys[i]]
end
end
local parse_tree
parse_tree = function(it)
local items = { }
for l in it do
if l == '' then
process_tree(items)
output:write('\n')
return
local trees = {
['asma-opcodes'] = { }
}
local opcodes_in_order = { }
do
local wanted = false
for l in assert(io.lines('src/uxnasm.c')) do
if l == 'static char ops[][4] = {' then
wanted = true
elseif wanted then
if l == '};' then
break
end
local item = {
extra = ''
for w in l:gmatch('[^%s",][^%s",][^%s",]') do
if w ~= '---' then
trees['asma-opcodes'][w] = {
('"%s 00'):format(w),
''
}
item.key, item.rest = l:match('^%s*%S+%s+%S+%s+%S+%s+(%S+)(.*)')
if item.key:match('^%&') then
item.extra = (' %s'):format(item.key)
item.key, item.rest = item.rest:match('^%s+(%S+)(.*)')
end
if item.key:match('^%"') then
item.order = item.key:sub(2)
elseif item.key:match('^%x%x') then
item.order = string.char(tonumber(item.key, 16))
else
error(('unknown key: %q'):format(item.key))
table.insert(opcodes_in_order, w)
end
if item.order:match('^%a') then
item.label = ('&%s'):format(item.order)
elseif item.order:match('^.$') then
item.label = ('&%x'):format(item.order:byte())
else
error(('unknown label: %q'):format(item.order))
end
item.ref = (':%s'):format(item.label)
table.insert(items, item)
end
assert(#opcodes_in_order == 32, 'didn\'t find 32 opcodes in assembler code!')
end
do
local representation = setmetatable({
['&'] = '26 00 ( & )'
}, {
__index = function(self, c)
return ("'%s 00"):format(c)
end
})
local process
process = function(label, t)
trees[label] = { }
for k, v in pairs(t) do
trees[label][('%02x'):format(k:byte())] = {
representation[k],
(':%s'):format(v)
}
end
end
process('asma-first-char-normal', {
['%'] = 'asma-macro-define',
['|'] = 'asma-pad-absolute',
['$'] = 'asma-pad-relative',
['@'] = 'asma-label-define',
['&'] = 'asma-sublabel-define',
['#'] = 'asma-literal-hex',
['.'] = 'asma-literal-zero-addr',
[','] = 'asma-literal-rel-addr',
[';'] = 'asma-literal-abs-addr',
[':'] = 'asma-abs-addr',
["'"] = 'asma-raw-char',
['"'] = 'asma-raw-word',
['{'] = 'asma-ignore',
['}'] = 'asma-ignore',
['['] = 'asma-ignore',
[']'] = 'asma-ignore',
['('] = 'asma-comment-start',
[')'] = 'asma-comment-end',
['~'] = 'asma-include'
})
process('asma-first-char-macro', {
['('] = 'asma-comment-start',
[')'] = 'asma-comment-end',
['{'] = 'asma-ignore',
['}'] = 'asma-macro-end'
})
process('asma-first-char-comment', {
['('] = 'asma-comment-more',
[')'] = 'asma-comment-less'
})
end
local traverse_node
traverse_node = function(t, min, max, lefts, rights)
local i = math.ceil((min + max) / 2)
if min < i then
lefts[t[i]] = (':&%s'):format(traverse_node(t, min, i - 1, lefts, rights))
end
if i < max then
rights[t[i]] = (':&%s'):format(traverse_node(t, i + 1, max, lefts, rights))
end
return t[i]
end
local traverse_tree
traverse_tree = function(t)
local lefts, rights = { }, { }
local keys
do
local _accum_0 = { }
local _len_0 = 1
for k in pairs(t) do
_accum_0[_len_0] = k
_len_0 = _len_0 + 1
end
keys = _accum_0
end
table.sort(keys)
return lefts, rights, traverse_node(keys, 1, #keys, lefts, rights)
end
local ptr
ptr = function(s)
if s then
return (':&%s'):format(s)
end
return ' $2'
end
local ordered_opcodes
ordered_opcodes = function(t)
local i = 0
return function()
i = i + 1
local v = opcodes_in_order[i]
if t[v] then
return v, t[v]
elseif v then
return false, {
'"--- 00',
''
}
end
end
end
local it = assert(io.lines('projects/library/asma.tal'))
local waiting_for_cut = true
for l in it do
output:write(l)
output:write('\n')
if l:find('--- cut here ---', 1, true) then
waiting_for_cut = false
end
if not waiting_for_cut and '@' == l:sub(1, 1) then
parse_tree(it)
end
local printout = true
local fmt
fmt = function(...)
return (('\t%-11s %-10s %-12s %-14s %s '):format(...):gsub(' +$', '\n'))
end
output:close()
return os.execute('mv .asma.tal projects/library/asma.tal')
do
local _with_0 = assert(io.open('projects/library/asma.tal.tmp', 'w'))
for l in assert(io.lines('projects/library/asma.tal')) do
if l:match('--- cut here ---') then
break
end
_with_0:write(l)
_with_0:write('\n')
end
_with_0:write('( --- 8< ------- 8< --- cut here --- 8< ------- 8< --- )\n')
_with_0:write('( automatically generated code below )\n')
_with_0:write('( see etc/asma.moon for instructions )\n')
_with_0:write('\n(')
_with_0:write(fmt('label', 'less', 'greater', 'key', 'binary'))
_with_0:write(fmt('', 'than', 'than', 'string', 'data )'))
_with_0:write('\n')
for name, tree in spairs(trees) do
_with_0:write(('@%s\n'):format(name))
local lefts, rights, entry = traverse_tree(tree)
local sort_fn
if name == 'asma-opcodes' then
if rights[opcodes_in_order[1]] then
rights[opcodes_in_order[1]] = rights[opcodes_in_order[1]] .. ' &_disasm'
else
rights[opcodes_in_order[1]] = ' $2 &_disasm'
end
sort_fn = ordered_opcodes
else
sort_fn = spairs
end
for k, v in sort_fn(tree) do
local label
if k == entry then
label = '&_entry'
elseif k then
label = ('&%s'):format(k)
else
label = ''
end
_with_0:write(fmt(label, lefts[k] or ' $2', rights[k] or ' $2', unpack(v)))
end
_with_0:write('\n')
end
_with_0:close()
end
return os.execute('mv projects/library/asma.tal.tmp projects/library/asma.tal')

View file

@ -1,7 +1,10 @@
--
-- Asma tree helper script
--
-- This script balances the trees at the end of projects/library/asma.tal.
-- This script updates the trees at the end of projects/library/asma.tal when
-- Uxn's opcode set changes or new runes (first character of tokens) are
-- created, so that new changes in the C assembler can be incorporated rapidly
-- into asma.
--
-- To run, you need Lua or LuaJIT, and just run etc/asma.lua from the top
-- directory of Uxn's git repository:
@ -15,60 +18,145 @@
-- file changes.
--
output = assert io.open '.asma.tal', 'w'
spairs = (t) ->
keys = [ k for k in pairs t ]
table.sort keys
i = 0
->
i = i + 1
keys[i], t[keys[i]]
process_subtree = (items) ->
middle = math.floor #items / 2 + 1.25
node = items[middle]
if not node
return
node.left = process_subtree [ item for i, item in ipairs items when i < middle ]
node.right = process_subtree [ item for i, item in ipairs items when i > middle ]
node
trees = {
['asma-opcodes']: {}
}
process_tree = (items) ->
sorted_items = [ item for item in *items ]
table.sort sorted_items, (a, b) -> a.order < b.order
(process_subtree sorted_items).label = '&_entry'
for item in *items
output\write '\t%-11s %-10s %-12s %s%s\n'\format item.label, item.left and item.left.ref or ' $2', (item.right and item.right.ref or ' $2') .. item.extra, item.key, item.rest
opcodes_in_order = {}
parse_tree = (it) ->
items = {}
for l in it
if l == ''
process_tree items
output\write '\n'
return
item = { extra: '' }
item.key, item.rest = l\match '^%s*%S+%s+%S+%s+%S+%s+(%S+)(.*)'
if item.key\match '^%&'
item.extra = ' %s'\format item.key
item.key, item.rest = item.rest\match '^%s+(%S+)(.*)'
if item.key\match '^%"'
item.order = item.key\sub 2
elseif item.key\match '^%x%x'
item.order = string.char tonumber item.key, 16
do -- opcodes
wanted = false
for l in assert io.lines 'src/uxnasm.c'
if l == 'static char ops[][4] = {'
wanted = true
elseif wanted
if l == '};'
break
for w in l\gmatch '[^%s",][^%s",][^%s",]'
if w != '---'
trees['asma-opcodes'][w] = {
'"%s 00'\format w
''
}
table.insert opcodes_in_order, w
assert #opcodes_in_order == 32, 'didn\'t find 32 opcodes in assembler code!'
do -- first characters
representation = setmetatable {
'&': '26 00 ( & )'
},
__index: (c) => "'%s 00"\format c
process = (label, t) ->
trees[label] = {}
for k, v in pairs t
trees[label]['%02x'\format k\byte!] = {
representation[k]
':%s'\format v
}
process 'asma-first-char-normal',
'%': 'asma-macro-define'
'|': 'asma-pad-absolute'
'$': 'asma-pad-relative'
'@': 'asma-label-define'
'&': 'asma-sublabel-define'
'#': 'asma-literal-hex'
'.': 'asma-literal-zero-addr'
',': 'asma-literal-rel-addr'
';': 'asma-literal-abs-addr'
':': 'asma-abs-addr'
"'": 'asma-raw-char'
'"': 'asma-raw-word'
'{': 'asma-ignore'
'}': 'asma-ignore'
'[': 'asma-ignore'
']': 'asma-ignore'
'(': 'asma-comment-start'
')': 'asma-comment-end'
'~': 'asma-include'
process 'asma-first-char-macro',
'(': 'asma-comment-start'
')': 'asma-comment-end'
'{': 'asma-ignore'
'}': 'asma-macro-end'
process 'asma-first-char-comment',
'(': 'asma-comment-more'
')': 'asma-comment-less'
traverse_node = (t, min, max, lefts, rights) ->
i = math.ceil (min + max) / 2
if min < i
lefts[t[i]] = ':&%s'\format traverse_node t, min, i - 1, lefts, rights
if i < max
rights[t[i]] = ':&%s'\format traverse_node t, i + 1, max, lefts, rights
return t[i]
traverse_tree = (t) ->
lefts, rights = {}, {}
keys = [ k for k in pairs t ]
table.sort keys
lefts, rights, traverse_node keys, 1, #keys, lefts, rights
ptr = (s) ->
if s
return ':&%s'\format s
return ' $2'
ordered_opcodes = (t) ->
i = 0
->
i = i + 1
v = opcodes_in_order[i]
if t[v]
return v, t[v]
elseif v
return false, { '"--- 00', '' }
printout = true
fmt = (...) ->
('\t%-11s %-10s %-12s %-14s %s '\format(...)\gsub ' +$', '\n')
with assert io.open 'projects/library/asma.tal.tmp', 'w'
for l in assert io.lines 'projects/library/asma.tal'
if l\match '--- cut here ---'
break
\write l
\write '\n'
\write '( --- 8< ------- 8< --- cut here --- 8< ------- 8< --- )\n'
\write '( automatically generated code below )\n'
\write '( see etc/asma.moon for instructions )\n'
\write '\n('
\write fmt 'label', 'less', 'greater', 'key', 'binary'
\write fmt '', 'than', 'than', 'string', 'data )'
\write '\n'
for name, tree in spairs trees
\write '@%s\n'\format name
lefts, rights, entry = traverse_tree tree
sort_fn = if name == 'asma-opcodes'
if rights[opcodes_in_order[1]]
rights[opcodes_in_order[1]] ..= ' &_disasm'
else
error 'unknown key: %q'\format item.key
if item.order\match '^%a'
item.label = '&%s'\format item.order
elseif item.order\match '^.$'
item.label = '&%x'\format item.order\byte!
rights[opcodes_in_order[1]] = ' $2 &_disasm'
ordered_opcodes
else
error 'unknown label: %q'\format item.order
item.ref = ':%s'\format item.label
table.insert items, item
it = assert io.lines 'projects/library/asma.tal'
waiting_for_cut = true
for l in it
output\write l
output\write '\n'
if l\find '--- cut here ---', 1, true
waiting_for_cut = false
if not waiting_for_cut and '@' == l\sub 1, 1
parse_tree it
output\close!
os.execute 'mv .asma.tal projects/library/asma.tal'
spairs
for k, v in sort_fn tree
label = if k == entry
'&_entry'
elseif k
'&%s'\format k
else
''
\write fmt label, lefts[k] or ' $2', rights[k] or ' $2', unpack v
\write '\n'
\close!
os.execute 'mv projects/library/asma.tal.tmp projects/library/asma.tal'

View file

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

View file

@ -1,85 +0,0 @@
#include "uxn.h"
/*
Copyright (u) 2022-2023 Devine Lu Linvega, Andrew Alderwick, Andrew Richards
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 FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
#define JUMP(x) { if(m2) pc = (x); else pc += (Sint8)(x); }
#define POP1(o) { o = s->dat[--*sp]; }
#define POP2(o) { o = s->dat[--*sp] | (s->dat[--*sp] << 0x8); }
#define POPx(o) { if(m2) { POP2(o) } else POP1(o) }
#define PUSH1(y) { s->dat[s->ptr++] = (y); }
#define PUSH2(y) { tt = (y); s->dat[s->ptr++] = tt >> 0x8; s->dat[s->ptr++] = tt; }
#define PUSHx(y) { if(m2) { PUSH2(y) } else PUSH1(y) }
#define PEEK(o, x, r) { if(m2) { r = (x); o = ram[r++] << 8 | ram[r]; } else o = ram[(x)]; }
#define POKE(x, y, r) { if(m2) { r = (x); ram[r++] = y >> 8; ram[r] = y; } else ram[(x)] = (y); }
#define DEVR(o, p) { if(m2) { o = (emu_dei(u, p) << 8) | emu_dei(u, p + 1); } else o = emu_dei(u, p); }
#define DEVW(p, y) { if(m2) { emu_deo(u, p, y >> 8); emu_deo(u, p + 1, y); } else emu_deo(u, p, y); }
#define next { ins = ram[pc++]; \
m2 = ins & 0x20; \
s = ins & 0x40 ? &u->rst : &u->wst; \
if(ins & 0x80) kp = s->ptr, sp = &kp; else sp = &s->ptr; \
goto *lut[ins & 0x1f]; }
int
uxn_eval(Uxn *u, Uint16 pc)
{
Uint8 t, kp, *sp, ins, m2, *ram = u->ram;
Uint16 tt, a, b, c;
Stack *s;
static void* lut[] = {
&&_imm, &&_inc, &&_pop, &&_nip, &&_swp, &&_rot, &&_dup, &&_ovr,
&&_equ, &&_neq, &&_gth, &&_lth, &&_jmp, &&_jcn, &&_jsr, &&_sth,
&&_ldz, &&_stz, &&_ldr, &&_str, &&_lda, &&_sta, &&_dei, &&_deo,
&&_add, &&_sub, &&_mul, &&_div, &&_and, &&_ora, &&_eor, &&_sft };
if(!pc || u->dev[0x0f]) return 0;
next
_imm:
switch(ins) {
case 0x00: /* BRK */ return 1;
case 0x20: /* JCI */ POP1(b) if(!b) { pc += 2; break; }
case 0x40: /* JMI */ a = ram[pc++] << 8 | ram[pc++]; pc += a; break;
case 0x60: /* JSI */ PUSH2(pc + 2) a = ram[pc++] << 8 | ram[pc++]; pc += a; break;
case 0x80: case 0xc0: /* LIT */ PUSH1(ram[pc++]) break;
case 0xa0: case 0xe0: /* LIT2 */ PUSH1(ram[pc++]) PUSH1(ram[pc++]) break;
} next
_inc: POPx(a) PUSHx(a + 1) next
_pop: POPx(a) next
_nip: POPx(a) POPx(b) PUSHx(a) next
_swp: POPx(a) POPx(b) PUSHx(a) PUSHx(b) next
_rot: POPx(a) POPx(b) POPx(c) PUSHx(b) PUSHx(a) PUSHx(c) next
_dup: POPx(a) PUSHx(a) PUSHx(a) next
_ovr: POPx(a) POPx(b) PUSHx(b) PUSHx(a) PUSHx(b) next
_equ: POPx(a) POPx(b) PUSH1(b == a) next
_neq: POPx(a) POPx(b) PUSH1(b != a) next
_gth: POPx(a) POPx(b) PUSH1(b > a) next
_lth: POPx(a) POPx(b) PUSH1(b < a) next
_jmp: POPx(a) JUMP(a) next
_jcn: POPx(a) POP1(b) if(b) JUMP(a) next
_jsr: POPx(a) FLIP PUSH2(pc) JUMP(a) next
_sth: POPx(a) FLIP PUSHx(a) next
_ldz: POP1(a) PEEK(b, a, t) PUSHx(b) next
_stz: POP1(a) POPx(b) POKE(a, b, t) next
_ldr: POP1(a) PEEK(b, pc + (Sint8)a, tt) PUSHx(b) next
_str: POP1(a) POPx(b) POKE(pc + (Sint8)a, b, tt) next
_lda: POP2(a) PEEK(b, a, tt) PUSHx(b) next
_sta: POP2(a) POPx(b) POKE(a, b, tt) next
_dei: POP1(a) DEVR(b, a) PUSHx(b) next
_deo: POP1(a) POPx(b) DEVW(a, b) next
_add: POPx(a) POPx(b) PUSHx(b + a) next
_sub: POPx(a) POPx(b) PUSHx(b - a) next
_mul: POPx(a) POPx(b) PUSHx(b * a) next
_div: POPx(a) POPx(b) PUSHx(a ? b / a : 0) next
_and: POPx(a) POPx(b) PUSHx(b & a) next
_ora: POPx(a) POPx(b) PUSHx(b | a) next
_eor: POPx(a) POPx(b) PUSHx(b ^ a) next
_sft: POP1(a) POPx(b) PUSHx(b >> (a & 0xf) << (a >> 4)) next
}

View file

@ -1,81 +0,0 @@
#include "uxn.h"
/*
Copyright (u) 2022-2023 Devine Lu Linvega, Andrew Alderwick, Andrew Richards
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 FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
#define JUMP(x) { if(m2) pc = (x); else pc += (Sint8)(x); }
#define POP1(o) { o = s->dat[--*sp]; }
#define POP2(o) { o = s->dat[--*sp] | (s->dat[--*sp] << 0x8); }
#define POPx(o) { if(m2) { POP2(o) } else POP1(o) }
#define PUSH1(y) { s->dat[s->ptr++] = (y); }
#define PUSH2(y) { tt = (y); s->dat[s->ptr++] = tt >> 0x8; s->dat[s->ptr++] = tt; }
#define PUSHx(y) { if(m2) { PUSH2(y) } else PUSH1(y) }
#define PEEK(o, x, r) { if(m2) { r = (x); o = ram[r++] << 8 | ram[r]; } else o = ram[(x)]; }
#define POKE(x, y, r) { if(m2) { r = (x); ram[r++] = y >> 8; ram[r] = y; } else ram[(x)] = (y); }
#define DEVR(o, p) { if(m2) { o = (emu_dei(u, p) << 8) | emu_dei(u, p + 1); } else o = emu_dei(u, p); }
#define DEVW(p, y) { if(m2) { emu_deo(u, p, y >> 8); emu_deo(u, p + 1, y); } else emu_deo(u, p, y); }
int
uxn_eval(Uxn *u, Uint16 pc)
{
Uint8 t, kp, *sp, *ram = u->ram;
Uint16 tt, a, b, c;
if(!pc || u->dev[0x0f]) return 0;
for(;;) {
Uint8 ins = ram[pc++];
/* 2 */ Uint8 m2 = ins & 0x20;
/* r */ Stack *s = ins & 0x40 ? &u->rst : &u->wst;
/* k */ if(ins & 0x80) kp = s->ptr, sp = &kp; else sp = &s->ptr;
switch(ins & 0x1f) {
case 0x00:
switch(ins) {
case 0x00: /* BRK */ return 1;
case 0x20: /* JCI */ POP1(b) if(!b) { pc += 2; break; }
case 0x40: /* JMI */ a = ram[pc++] << 8 | ram[pc++]; pc += a; break;
case 0x60: /* JSI */ PUSH2(pc + 2) a = ram[pc++] << 8 | ram[pc++]; pc += a; break;
case 0x80: case 0xc0: /* LIT */ PUSH1(ram[pc++]) break;
case 0xa0: case 0xe0: /* LIT2 */ PUSH1(ram[pc++]) PUSH1(ram[pc++]) break;
} break;
case 0x01: /* INC */ POPx(a) PUSHx(a + 1) break;
case 0x02: /* POP */ POPx(a) break;
case 0x03: /* NIP */ POPx(a) POPx(b) PUSHx(a) break;
case 0x04: /* SWP */ POPx(a) POPx(b) PUSHx(a) PUSHx(b) break;
case 0x05: /* ROT */ POPx(a) POPx(b) POPx(c) PUSHx(b) PUSHx(a) PUSHx(c) break;
case 0x06: /* DUP */ POPx(a) PUSHx(a) PUSHx(a) break;
case 0x07: /* OVR */ POPx(a) POPx(b) PUSHx(b) PUSHx(a) PUSHx(b) break;
case 0x08: /* EQU */ POPx(a) POPx(b) PUSH1(b == a) break;
case 0x09: /* NEQ */ POPx(a) POPx(b) PUSH1(b != a) break;
case 0x0a: /* GTH */ POPx(a) POPx(b) PUSH1(b > a) break;
case 0x0b: /* LTH */ POPx(a) POPx(b) PUSH1(b < a) break;
case 0x0c: /* JMP */ POPx(a) JUMP(a) break;
case 0x0d: /* JCN */ POPx(a) POP1(b) if(b) JUMP(a) break;
case 0x0e: /* JSR */ POPx(a) FLIP PUSH2(pc) JUMP(a) break;
case 0x0f: /* STH */ POPx(a) FLIP PUSHx(a) break;
case 0x10: /* LDZ */ POP1(a) PEEK(b, a, t) PUSHx(b) break;
case 0x11: /* STZ */ POP1(a) POPx(b) POKE(a, b, t) break;
case 0x12: /* LDR */ POP1(a) PEEK(b, pc + (Sint8)a, tt) PUSHx(b) break;
case 0x13: /* STR */ POP1(a) POPx(b) POKE(pc + (Sint8)a, b, tt) break;
case 0x14: /* LDA */ POP2(a) PEEK(b, a, tt) PUSHx(b) break;
case 0x15: /* STA */ POP2(a) POPx(b) POKE(a, b, tt) break;
case 0x16: /* DEI */ POP1(a) DEVR(b, a) PUSHx(b) break;
case 0x17: /* DEO */ POP1(a) POPx(b) DEVW(a, b) break;
case 0x18: /* ADD */ POPx(a) POPx(b) PUSHx(b + a) break;
case 0x19: /* SUB */ POPx(a) POPx(b) PUSHx(b - a) break;
case 0x1a: /* MUL */ POPx(a) POPx(b) PUSHx(b * a) break;
case 0x1b: /* DIV */ POPx(a) POPx(b) PUSHx(a ? b / a : 0) break;
case 0x1c: /* AND */ POPx(a) POPx(b) PUSHx(b & a) break;
case 0x1d: /* ORA */ POPx(a) POPx(b) PUSHx(b | a) break;
case 0x1e: /* EOR */ POPx(a) POPx(b) PUSHx(b ^ a) break;
case 0x1f: /* SFT */ POP1(a) POPx(b) PUSHx(b >> (a & 0xf) << (a >> 4)) break;
}
}
}

View file

@ -1,123 +0,0 @@
#include "uxn.h"
/*
Copyright (u) 2022-2023 Devine Lu Linvega, Andrew Alderwick, Andrew Richards
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.
*/
/* Registers
[ Z ][ Y ][ X ][ L ][ N ][ T ] <
[ . ][ . ][ . ][ H2 ][ . ] <
[ L2 ][ N2 ][ T2 ] <
*/
#define T *(s->dat + s->ptr)
#define N *(s->dat + (Uint8)(s->ptr - 1))
#define L *(s->dat + (Uint8)(s->ptr - 2))
#define X *(s->dat + (Uint8)(s->ptr - 3))
#define Y *(s->dat + (Uint8)(s->ptr - 4))
#define Z *(s->dat + (Uint8)(s->ptr - 5))
#define T2 (N << 8 | T)
#define H2 (L << 8 | N)
#define N2 (X << 8 | L)
#define L2 (Z << 8 | Y)
#define T2_(v) { r = (v); T = r; N = r >> 8; }
#define N2_(v) { r = (v); L = r; X = r >> 8; }
#define L2_(v) { r = (v); Y = r; Z = r >> 8; }
#define FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
#define SHIFT(y) { s->ptr += (y); }
#define SET(x, y) { SHIFT((ins & 0x80) ? x + y : y) }
int
uxn_eval(Uxn *u, Uint16 pc)
{
Uint16 t, n, l, r;
Uint8 *ram = u->ram, *rr;
if(!pc || u->dev[0x0f]) return 0;
for(;;) {
Uint8 ins = ram[pc++];
Stack *s = ins & 0x40 ? &u->rst : &u->wst;
switch(ins & 0x3f) {
/* IMM */
case 0x00: case 0x20:
switch(ins) {
case 0x00: /* BRK */ return 1;
case 0x20: /* JCI */ t=T; SHIFT(-1) if(!t) { pc += 2; break; } /* fall-through */
case 0x40: /* JMI */ rr = ram + pc; pc += 2 + PEEK2(rr); break;
case 0x60: /* JSI */ SHIFT( 2) rr = ram + pc; pc += 2; T2_(pc); pc += PEEK2(rr); break;
case 0x80: /* LIT */ case 0xc0: SHIFT( 1) T = ram[pc++]; break;
case 0xa0: /* LIT2 */ case 0xe0: SHIFT( 2) N = ram[pc++]; T = ram[pc++]; break;
} break;
/* ALU */
case 0x01: /* INC */ t=T; SET(1, 0) T = t + 1; break;
case 0x21: /* INC2 */ t=T2; SET(2, 0) T2_(t + 1) break;
case 0x02: /* POP */ SET(1,-1) break;
case 0x22: /* POP2 */ SET(2,-2) break;
case 0x03: /* NIP */ t=T; SET(2,-1) T = t; break;
case 0x23: /* NIP2 */ t=T2; SET(4,-2) T2_(t) break;
case 0x04: /* SWP */ t=T;n=N; SET(2, 0) T = n; N = t; break;
case 0x24: /* SWP2 */ t=T2;n=N2; SET(4, 0) T2_(n) N2_(t) break;
case 0x05: /* ROT */ t=T;n=N;l=L; SET(3, 0) T = l; N = t; L = n; break;
case 0x25: /* ROT2 */ t=T2;n=N2;l=L2; SET(6, 0) T2_(l) N2_(t) L2_(n) break;
case 0x06: /* DUP */ t=T; SET(1, 1) T = t; N = t; break;
case 0x26: /* DUP2 */ t=T2; SET(2, 2) T2_(t) N2_(t) break;
case 0x07: /* OVR */ t=T;n=N; SET(2, 1) T = n; N = t; L = n; break;
case 0x27: /* OVR2 */ t=T2;n=N2; SET(4, 2) T2_(n) N2_(t) L2_(n) break;
case 0x08: /* EQU */ t=T;n=N; SET(2,-1) T = n == t; break;
case 0x28: /* EQU2 */ t=T2;n=N2; SET(4,-3) T = n == t; break;
case 0x09: /* NEQ */ t=T;n=N; SET(2,-1) T = n != t; break;
case 0x29: /* NEQ2 */ t=T2;n=N2; SET(4,-3) T = n != t; break;
case 0x0a: /* GTH */ t=T;n=N; SET(2,-1) T = n > t; break;
case 0x2a: /* GTH2 */ t=T2;n=N2; SET(4,-3) T = n > t; break;
case 0x0b: /* LTH */ t=T;n=N; SET(2,-1) T = n < t; break;
case 0x2b: /* LTH2 */ t=T2;n=N2; SET(4,-3) T = n < t; break;
case 0x0c: /* JMP */ t=T; SET(1,-1) pc += (Sint8)t; break;
case 0x2c: /* JMP2 */ t=T2; SET(2,-2) pc = t; break;
case 0x0d: /* JCN */ t=T;n=N; SET(2,-2) if(n) pc += (Sint8)t; break;
case 0x2d: /* JCN2 */ t=T2;n=L; SET(3,-3) if(n) pc = t; break;
case 0x0e: /* JSR */ t=T; SET(1,-1) FLIP SHIFT(2) T2_(pc) pc += (Sint8)t; break;
case 0x2e: /* JSR2 */ t=T2; SET(2,-2) FLIP SHIFT(2) T2_(pc) pc = t; break;
case 0x0f: /* STH */ t=T; SET(1,-1) FLIP SHIFT(1) T = t; break;
case 0x2f: /* STH2 */ t=T2; SET(2,-2) FLIP SHIFT(2) T2_(t) break;
case 0x10: /* LDZ */ t=T; SET(1, 0) T = ram[t]; break;
case 0x30: /* LDZ2 */ t=T; SET(1, 1) N = ram[t++]; T = ram[(Uint8)t]; break;
case 0x11: /* STZ */ t=T;n=N; SET(2,-2) ram[t] = n; break;
case 0x31: /* STZ2 */ t=T;n=H2; SET(3,-3) ram[t++] = n >> 8; ram[(Uint8)t] = n; break;
case 0x12: /* LDR */ t=T; SET(1, 0) r = pc + (Sint8)t; T = ram[r]; break;
case 0x32: /* LDR2 */ t=T; SET(1, 1) r = pc + (Sint8)t; N = ram[r++]; T = ram[r]; break;
case 0x13: /* STR */ t=T;n=N; SET(2,-2) r = pc + (Sint8)t; ram[r] = n; break;
case 0x33: /* STR2 */ t=T;n=H2; SET(3,-3) r = pc + (Sint8)t; ram[r++] = n >> 8; ram[r] = n; break;
case 0x14: /* LDA */ t=T2; SET(2,-1) T = ram[t]; break;
case 0x34: /* LDA2 */ t=T2; SET(2, 0) N = ram[t++]; T = ram[t]; break;
case 0x15: /* STA */ t=T2;n=L; SET(3,-3) ram[t] = n; break;
case 0x35: /* STA2 */ t=T2;n=N2; SET(4,-4) ram[t++] = n >> 8; ram[t] = n; break;
case 0x16: /* DEI */ t=T; SET(1, 0) T = emu_dei(u, t); break;
case 0x36: /* DEI2 */ t=T; SET(1, 1) N = emu_dei(u, t++); T = emu_dei(u, t); break;
case 0x17: /* DEO */ t=T;n=N; SET(2,-2) emu_deo(u, t, n); break;
case 0x37: /* DEO2 */ t=T;n=N;l=L; SET(3,-3) emu_deo(u, t++, l); emu_deo(u, t, n); break;
case 0x18: /* ADD */ t=T;n=N; SET(2,-1) T = n + t; break;
case 0x38: /* ADD2 */ t=T2;n=N2; SET(4,-2) T2_(n + t) break;
case 0x19: /* SUB */ t=T;n=N; SET(2,-1) T = n - t; break;
case 0x39: /* SUB2 */ t=T2;n=N2; SET(4,-2) T2_(n - t) break;
case 0x1a: /* MUL */ t=T;n=N; SET(2,-1) T = n * t; break;
case 0x3a: /* MUL2 */ t=T2;n=N2; SET(4,-2) T2_(n * t) break;
case 0x1b: /* DIV */ t=T;n=N; SET(2,-1) T = t ? n / t : 0; break;
case 0x3b: /* DIV2 */ t=T2;n=N2; SET(4,-2) T2_(t ? n / t : 0) break;
case 0x1c: /* AND */ t=T;n=N; SET(2,-1) T = n & t; break;
case 0x3c: /* AND2 */ t=T2;n=N2; SET(4,-2) T2_(n & t) break;
case 0x1d: /* ORA */ t=T;n=N; SET(2,-1) T = n | t; break;
case 0x3d: /* ORA2 */ t=T2;n=N2; SET(4,-2) T2_(n | t) break;
case 0x1e: /* EOR */ t=T;n=N; SET(2,-1) T = n ^ t; break;
case 0x3e: /* EOR2 */ t=T2;n=N2; SET(4,-2) T2_(n ^ t) break;
case 0x1f: /* SFT */ t=T;n=N; SET(2,-1) T = n >> (t & 0xf) << (t >> 4); break;
case 0x3f: /* SFT2 */ t=T;n=H2; SET(3,-1) T2_(n >> (t & 0xf) << (t >> 4)) break;
}
}
}

View file

@ -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

View file

@ -118,9 +118,9 @@ contexts:
- match: '\}'
pop: true
- match: '\s\(\s'
- match: '\( '
scope: comment
push:
- meta_scope: comment.line
- match: '\s\)\s'
- match: ' \)'
pop: true

16
etc/tables/build.sh Executable file
View file

@ -0,0 +1,16 @@
#!/bin/bash
echo "Formatting.."
clang-format -i tables.c
echo "Cleaning.."
rm -f ../../bin/tables
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 tables.c -o ../../bin/tables
echo "Assembling.."
../../bin/tables
echo "Done."

View file

@ -2,7 +2,7 @@
#include <math.h>
/*
Copyright (c) 2020-2023 Devine Lu Linvega
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
@ -23,31 +23,14 @@ clamp(int val, int min, int max)
}
int
sint(char *s)
main()
{
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;
int i;
printf("60 points on a circle128(bytex,bytey):\n\n");
for(i = 0; i < 60; ++i) {
double cx = 128, cy = 128, r = 128;
double pos = (i - 15) % 60;
double deg = (pos / 60.0) * 360.0;
double rad = deg * (PI / 180);
double x = cx + r * cos(rad);
double y = cy + r * sin(rad);

14
mkfile
View file

@ -1,10 +1,9 @@
</$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
CFLAGS=$CFLAGS -D__plan9__ -I/sys/include/npe -I/sys/include/npe/SDL2
HFILES=\
/sys/include/npe/stdio.h\
src/devices/audio.h\
@ -14,7 +13,6 @@ HFILES=\
src/devices/mouse.h\
src/devices/screen.h\
src/devices/system.h\
src/devices/console.h\
src/uxn.h\
CLEANFILES=$TARG $ROM
@ -35,19 +33,19 @@ bin:
%.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
bin/uxncli: file.$O datetime.$O system.$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
bin/uxnemu: audio.$O controller.$O datetime.$O file.$O mouse.$O screen.$O system.$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
(audio|controller|datetime|file|mouse|screen|system)\.$O:R: src/devices/\1.c
$CC $CFLAGS -Isrc -o $target src/devices/$stem1.c
nuke:V: clean
@ -58,7 +56,7 @@ clean:V:
%.clean:V:
rm -f $stem.[$OS] [$OS].$stem $stem
install:V: all
cp $TARG $BIN/
install:QV: all
exit 'Sorry, there is no install rule yet'
#LDFLAGS=-p

13
prepare-android.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
set -e
# need launcher.rom to be included
./build.sh --no-run
# duplicate? already have a piano
rm -f bin/asma-piano.rom
# get more roms
curl https://rabbits.srht.site/uxn-rompack.tar.gz | tar -C bin -xzf -
mv bin/uxn/*.rom bin
rm -r bin/uxn

View file

@ -1,5 +1,27 @@
( a blank file )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 }
%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 }
%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 }
%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 }
%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 }
%2MOD { #01 AND } %2MOD2 { #0001 AND2 }
%4MOD { #03 AND } %4MOD2 { #0003 AND2 }
%8MOD { #07 AND } %8MOD2 { #0007 AND2 }
%10MOD { #0f AND } %10MOD2 { #000f AND2 }
%DEBUG { ;print-hex/byte JSR2 #0a18 DEO }
%DEBUG2 { ;print-hex JSR2 #0a18 DEO }
%RTN { JMP2r }
( devices )
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &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
@ -9,9 +31,8 @@
|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 &func $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2
|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
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|b0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
( variables )
@ -28,19 +49,33 @@
BRK
@print ( short* -- )
@print-hex ( value* -- )
SWP ,&byte JSR
&byte ( byte -- ) DUP #04 SFT ,&char JSR
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
&byte ( byte -- )
STHk #04 SFT ,&parse JSR #18 DEO
STHr #0f AND ,&parse JSR #18 DEO
RTN
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 + RTN
&above #57 + RTN
JMP2r
RTN
@print-str ( str* -- )
@print-dec ( value* -- )
#2710 DIV2k DUP #30 ADD #18 DEO MUL2 SUB2
#03e8 DIV2k DUP #30 ADD #18 DEO MUL2 SUB2
#0064 DIV2k DUP #30 ADD #18 DEO MUL2 SUB2
#000a DIV2k DUP #30 ADD #18 DEO MUL2 SUB2
#30 ADD #18 DEO POP
RTN
@print-str ( string* -- )
#0001 --
&while
LDAk #18 DEO
INC2 LDAk ,&while JCN
INC2 LDAk DUP #18 DEO ,&while JCN
POP2
JMP2r
RTN

View file

@ -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

View file

@ -0,0 +1,102 @@
( devices )
|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 ]
|a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ]
( vectors )
|0100 @reset
(
Set the log level for helping to debug stuff.
Its value is the bitwise OR of all the following output types:
#01 prints the number of lines in the source code,
#04 dumps all defined labels at end, and
#08 prints the heap usage.
)
#0d ;asma/log-level STA
;asma-heap ;heap STA2
(
Assemble the source code into an output ROM file.
If all you want is to use asma.tal to assemble files, insert a BRK
after this statement.
)
;&source-file ;&dest-file ;asma-assemble-file JSR2
(
If an error has occurred, BRK here, otherwise continue. (The error
message will already have been printed to the Console in
asma-assemble-file.)
)
;asma/error LDA2 #0000 EQU2 JMP BRK
(
Load the output ROM over the currently running program, almost as if
we loaded the ROM with uxnemu directly!
It's not a totally pristine environment, as File/read doesn't zero out
memory beyond the end of the file. So if the assembled program assumes
that all memory above it is zero, it may misbehave.
Asma itself doesn't use the zero page, but this example code writes a
DEO2 instruction to 0x00ff. In order to execute File/read and have the
CPU continue at memory location 0x0100, we write the final DEO2
instruction there and jump there as our final act.
Just in case the assembled code is zero-length (which can occur when
assembling an empty source file), we write a BRK to the reset vector so
that will prevent an infinite loop.
)
;&dest-file .File/name DEO2
#ff00 .File/length DEO2
#0100 .File/read
LIT DEO2 #00ff STA
LIT BRK #0100 STA
#00ff JMP2
&source-file
"projects/examples/demos/piano.tal 00
&dest-file
"bin/asma-boot.rom 00
~projects/library/asma.tal
(
Heap, a large temporary area for keeping track of labels. More complex
programs need more of this space. If there's insufficient space then the
assembly process will fail, but having extra space above what the most
complex program needs provides no benefit.
This heap, and the buffers below, are free to be used to hold temporary
data between assembly runs, and do not need to be initialized with any
particular contents to use the assembler.
)
@asma-heap
|e000 &end
(
Buffer for use with loading source code.
The minimum size is the length of the longest token plus one, which is
0x21 to keep the same capability of the C assembler.
Larger sizes are more efficient, provided there is enough
heap space to keep track of all the labels.
)
@asma-read-buffer
|f800 &end
(
Buffer for use with writing output.
The minimum size is 1, and larger sizes are more efficient.
)
@asma-write-buffer
|ffff &end

View file

@ -0,0 +1,119 @@
( Project by Alex Schroeder - https://alexschroeder.ch )
%RTN { JMP2r }
%INCR { SWP INC SWP }
%CELL { #1000 }
%NEXT { #2000 }
( 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 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
|0000
( program )
@seed [ &x $1 &w $2 &s $2 ]
|0100 ( -> )
( theme )
#2aac .System/r DEO2
#269b .System/g DEO2
#378d .System/b DEO2
;seed-line JSR2
( run for a few generations )
#00 #ff
&loop
OVR #00 SWP ;print-line JSR2
;compute-next JSR2
;copy-next JSR2
( incr ) INCR
( loop ) LTHk ,&loop JCN
POP2
BRK
@print-line ( y -- )
( set ) .Screen/y DEO2
( loop through cells )
#00 #ff
&loop
( copy ) OVR #00 SWP DUP2
( pos ) .Screen/x DEO2
( addr ) CELL ADD2
( draw ) LDA .Screen/pixel DEO
( incr ) INCR
( loop ) LTHk ,&loop JCN
POP2
RTN
@compute-next ( -- )
( loop through 62 cells )
#01 #fe
&loop
OVR DUP DUP ( three copies of the counter )
#01 SUB #00 SWP CELL ADD2 LDA
SWP
INC #00 SWP CELL ADD2 LDA
( the cell dies if the neighbors are either both dead or both alive, i.e. Rule 90 )
NEQ
( one copy of the counter and the life value )
SWP #00 SWP NEXT ADD2 STA
( incr ) INCR
( loop ) LTHk ,&loop JCN
POP2
RTN
@copy-next ( -- )
( loop through cells )
#00 #ff
&loop
OVR DUP ( two copies of the counter )
#00 SWP NEXT ADD2 LDA ( one copy of the counter and the value )
SWP #00 SWP CELL ADD2 STA
( incr ) INCR
( loop ) LTHk ,&loop JCN
POP2
RTN
@seed-line ( -- )
.DateTime/second DEI .seed/x STZ
#0000 .seed/w STZ2
#e2a9 .seed/s STZ2
( loop through cells )
#01 #fe
&loop
OVR ( one copy of the counter )
;rand JSR2
#10 AND ( pick a bit )
SWP #00 SWP CELL ADD2 STA
( incr ) INCR
( loop ) LTHk ,&loop JCN
POP2
RTN
( https://en.wikipedia.org/wiki/Middle-square_method )
@rand ( -- 1 )
.seed/x LDZ #00 SWP DUP2 MUL2
.seed/w LDZ2 .seed/s LDZ2 ADD2
DUP2 .seed/w STZ2
ADD2
#04 SFT SWP #40 SFT ADD
DUP .seed/x STZ
RTN

View file

@ -1,131 +1,185 @@
( Bifurcan )
(
Bifurcan
Every second, the Labyrinth reorganize itself to display the time.
)
|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
%RTN { JMP2r }
%MOD { DUP2 DIV MUL SUB }
%TOS { #00 SWP }
%2// { #01 SFT2 }
%8** { #30 SFT2 }
@last $1
@style $1
@center &x $2 &y $2
( devices )
|100
|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 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
|b0 @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 ]
@on-reset ( -> )
( | theme )
( variables )
|0000
@last $1
@style $1
@pointer [ &x $2 &y $2 ]
@center [ &x $2 &y $2 ]
@anchor [ &x $2 &y $2 ]
( program )
|0100 ( -> )
( theme )
#0f3a .System/r DEO2
#0fda .System/g DEO2
#0faa .System/b DEO2
( | vectors )
( 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
( find center )
.Screen/width DEI2 2// .center/x STZ2
.Screen/height DEI2 2// .center/y STZ2
( background )
;tiles ;cover-pattern JSR2
;redraw JSR2
BRK
@on-frame ( -> )
( | only draw once per second )
.DateTime/second DEI .last LDZ NEQk ?{ POP2 BRK }
.last STZ
POP <redraw>
BRK
( only draw once per second )
.DateTime/second DEI .last LDZ NEQ #01 JCN [ BRK ]
.DateTime/second DEI .last STZ
;redraw JSR2
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
;draw-cursor JSR2
.Mouse/state DEI #00 EQU ,&no-touch JCN
( incr ) .style LDZ INC #03 MOD .style STZ
( bg ) ;tiles .style LDZ #40 SFT TOS ADD2 ;cover-pattern JSR2
( fg ) ;redraw JSR2
( release ) #00 .Mouse/state DEO
&no-touch
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>
( >> )
.Controller/button DEI #00 EQU ,&no-touch JCN
( incr ) .style LDZ INC #03 MOD .style STZ
( bg ) ;tiles .style LDZ #40 SFT TOS ADD2 ;cover-pattern JSR2
( fg ) ;redraw JSR2
( release ) #00 .Mouse/state DEO
&no-touch
(
@|drawing )
BRK
@<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
@redraw ( -- )
@<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
( hrs )
[ .center/x LDZ2 #0018 SUB2 ]
[ .center/y LDZ2 #0048 SUB2 ]
.DateTime/hour DEI #0a DIV ;draw-number JSR2
[ .center/x LDZ2 #0008 ADD2 ]
[ .center/y LDZ2 #0048 SUB2 ]
.DateTime/hour DEI #0a MOD ;draw-number JSR2
( min )
[ .center/x LDZ2 #0018 SUB2 ]
[ .center/y LDZ2 #0018 SUB2 ]
.DateTime/minute DEI #0a DIV ;draw-number JSR2
[ .center/x LDZ2 #0008 ADD2 ]
[ .center/y LDZ2 #0018 SUB2 ]
.DateTime/minute DEI #0a MOD ;draw-number JSR2
( sec )
[ .center/x LDZ2 #0018 SUB2 ]
[ .center/y LDZ2 #0018 ADD2 ]
.DateTime/second DEI #0a DIV
;draw-number JSR2
[ .center/x LDZ2 #0008 ADD2 ]
[ .center/y LDZ2 #0018 ADD2 ]
.DateTime/second DEI #0a MOD
;draw-number JSR2
RTN
@draw-number ( x* y* n -- )
STH
( save pos ) .anchor/y STZ2 .anchor/x STZ2
#00 #0f
&loop
( save-x ) OVR #03 MOD TOS 8** .anchor/x LDZ2 ADD2 .Screen/x DEO2
( save-y ) OVR #03 DIV TOS 8** .anchor/y LDZ2 ADD2 .Screen/y DEO2
( get digit* ) OVR STHkr DUP ADD TOS ;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* -- )
( set tile ) 8** ;tiles ADD2
( set style ) .style LDZ #40 SFT TOS ADD2
.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
( draw ) #01 .Screen/sprite DEO
( incr ) SWP INC SWP
LTHk ,&loop JCN
POP2
POPr
@<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
( >> )
RTN
@<draw-cursor> ( color -- )
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEO
JMP2r
@cover-pattern ( addr* -- )
(
@|assets )
( load ) .Screen/addr DEO2
#0000 .Screen/height DEI2
&ver
( save ) OVR2 .Screen/y DEO2
#0000 .Screen/width DEI2
&hor
( save ) OVR2 .Screen/x DEO2
( draw ) #01 .Screen/sprite DEO
( incr ) SWP2 #0008 ADD2 SWP2
LTH2k ,&hor JCN
POP2 POP2
( incr ) SWP2 #0008 ADD2 SWP2
LTH2k ,&ver JCN
POP2 POP2
@cursor-icn [ 80c0 e0f0 f8e0 1000 ]
RTN
@fill-icn [ ffff ffff ffff ffff ]
@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 )
#41 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/sprite DEO
RTN
@cursor [
80c0 e0f0 f8e0 1000 ]
@digits [
7b6f 2492 73e7 73cf 5bc9 79cf 49ef 7249
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 ]
0102 0408 1020 4080
8040 2010 0804 0201
0718 2040 4080 8080
0101 0102 0204 18e0
0808 0810 e304 0808
0808 0804 e310 0808 ]

View file

@ -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

View file

@ -1,9 +1,41 @@
( simple graphical clock )
( Dev/Time )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%4* { #20 SFT }
%10* { #40 SFT }
%2** { #10 SFT2 } %2// { #01 SFT2 }
%4// { #02 SFT2 }
%10** { #40 SFT2 }
%20** { #50 SFT2 }
%TOS { #00 SWP }
%RTN { JMP2r }
%MOD { DUP2 DIV MUL SUB }
%ABS2 { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 -- }
%LTS2 { #8000 ++ SWP2 #8000 ++ GTH2 }
%GTS2 { #8000 ++ SWP2 #8000 ++ LTH2 }
%RADIUS { #0040 }
%SCALEX { 2// .center/x LDZ2 ++ RADIUS -- }
%SCALEY { 2// .center/y LDZ2 ++ RADIUS -- }
%12HOURS { #0c MOD }
%IS-UC { DUP #40 > SWP #5b < AND }
%IS-LC { DUP #60 > SWP #7b < AND }
%IS-NUM { DUP #2f > SWP #3a < AND }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|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 ]
|c0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables )
|0000
@ -23,7 +55,10 @@
@buf
&d $3 &h $2 &s1 $1 &m $2 &s2 $1 &s $3
@line
&x $2 &y $2 &dx $2 &dy $2 &e1 $2
&x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2
&dx $2 &dy $2 &e1 $2 &e2 $2 &color $1
( program )
|0100 ( -> )
@ -31,23 +66,28 @@
#0ff8 .System/r DEO2
#0f08 .System/g DEO2
#0f08 .System/b DEO2
( resize )
#00d0 .Screen/width DEO2
#00f0 .Screen/width DEO2
#0120 .Screen/height DEO2
( vectors )
;on-frame .Screen/vector DEO2
( center )
.Screen/width DEI2 #01 SFT2
.Screen/width DEI2 2//
DUP2 .center/x STZ2
DUP2 #0028 SUB2 .date/x STZ2
#0020 SUB2 .time/x STZ2
.Screen/height DEI2 #01 SFT2
DUP2 #0028 -- .date/x STZ2
#0020 -- .time/x STZ2
.Screen/height DEI2 2//
DUP2 .center/y STZ2
DUP2 #0078 SUB2 .date/y STZ2
#006c ADD2 .time/y STZ2
DUP2 #0078 -- .date/y STZ2
#006c ++ .time/y STZ2
;draw-watchface JSR2
( time buffer )
LIT ":
LIT ':
DUP .buf/s1 STZ
.buf/s2 STZ
@ -57,7 +97,7 @@
( once per second )
.DateTime/second DEI
DUP .last/sec LDZ EQU ,&same-sec JCN
DUP .last/sec LDZ = ,&same-sec JCN
( make time )
.DateTime/hour DEI .buf/h ;decimal JSR2
.DateTime/minute DEI .buf/m ;decimal JSR2
@ -76,14 +116,14 @@
( once per day )
.DateTime/day DEI
DUP .last/day LDZ EQU ,&same-day JCN
DUP .last/day LDZ = ,&same-day JCN
( make date )
DUP .buf/d ;decimal JSR2
( draw label )
.date/x LDZ2 .Screen/x DEO2
.date/y LDZ2 .Screen/y DEO2
[ #00 .DateTime/dotw DEI #20 SFT ] ;week-txt ADD2 ;draw-text JSR2
[ #00 .DateTime/month DEI #20 SFT ] ;month-txt ADD2 ;draw-text JSR2
.DateTime/dotw DEI 4* TOS ;week-txt ++ ;draw-text JSR2
.DateTime/month DEI 4* TOS ;month-txt ++ ;draw-text JSR2
;buf/d ;draw-text JSR2
DUP .last/day STZ
&same-day
@ -96,88 +136,87 @@ BRK
STH
.center/x LDZ2 .center/y LDZ2
OVR2 OVR2
.needles/mx LDZ2 .needles/my LDZ2 #01 STHkr MUL
;draw-line JSR2
.needles/zx LDZ2 .needles/zy LDZ2 #02 STHkr * ;draw-line JSR2
OVR2 OVR2
.needles/hx LDZ2 .needles/hy LDZ2 #01 STHkr MUL
;draw-line JSR2
.needles/sx LDZ2 .needles/sy LDZ2
.needles/zx LDZ2 .needles/zy LDZ2 #02 STHr MUL
;draw-line JSR2
.needles/sx LDZ2 .needles/sy LDZ2 #02 STHkr * ;draw-line JSR2
OVR2 OVR2
.needles/mx LDZ2 .needles/my LDZ2 #01 STHkr * ;draw-line JSR2
OVR2 OVR2
.needles/hx LDZ2 .needles/hy LDZ2 #01 STHr * ;draw-line JSR2
( middle )
#0001 SUB2 .Screen/y DEO2
#0001 SUB2 .Screen/x DEO2
#0001 -- .Screen/y DEO2 #0001 -- .Screen/x DEO2
;middle-icn .Screen/addr DEO2
#0a .Screen/sprite DEO
JMP2r
RTN
@draw-text ( addr* -- )
( auto addr ) #15 .Screen/auto DEO
( auto addr ) #06 .Screen/auto DEO
&while
LDAk
DUP ;is-lc JSR2 ,&lc JCN
DUP ;is-uc JSR2 ,&uc JCN
DUP ;is-num JSR2 ,&num JCN
DUP LIT "/ EQU ,&slash JCN
DUP LIT ": EQU ,&colon JCN
DUP IS-LC ,&lc JCN
DUP IS-UC ,&uc JCN
DUP IS-NUM ,&num JCN
DUP LIT '/ = ,&slash JCN
DUP LIT ': = ,&colon JCN
POP ;font/blank
&end
.Screen/addr DEO2
#03 .Screen/sprite DEO
#0303 .Screen/sprite DEO .Screen/sprite DEO
.Screen/y DEI2 #0010 -- .Screen/y DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
INC2 LDAk ,&while JCN
POP2
#00 .Screen/sprite DEO
( auto none ) #00 .Screen/auto DEO
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
JMP2r
&lc #61 SUB #00 SWP #40 SFT2 ;font/lc ADD2 ,&end JMP
&uc #41 SUB #00 SWP #40 SFT2 ;font/uc ADD2 ,&end JMP
&num #30 SUB #00 SWP #40 SFT2 ;font/num ADD2 ,&end JMP
RTN
&lc #61 - TOS 10** ;font/lc ++ ,&end JMP
&uc #41 - TOS 10** ;font/uc ++ ,&end JMP
&num #30 - TOS 10** ;font/num ++ ,&end JMP
&slash POP ;font/slash ,&end JMP
&colon POP ;font/colon ,&end JMP
@draw-line ( x1* y1* x2* y2* color -- )
( load ) STH ,&y STR2 ,&x STR2 .line/y STZ2 .line/x STZ2
,&x LDR2 .line/x LDZ2 SUB2 ;abs2 JSR2 .line/dx STZ2
#0000 ,&y LDR2 .line/y LDZ2 SUB2 ;abs2 JSR2 SUB2 .line/dy STZ2
#ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sx STR2
#ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sy STR2
.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
( load ) .line/color STZ .line/y0 STZ2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2
.line/x0 LDZ2 .line/x LDZ2 -- ABS2 .line/dx STZ2
.line/y0 LDZ2 .line/y LDZ2 -- ABS2 #0000 SWP2 -- .line/dy STZ2
#ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ++ .line/sx STZ2
#ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 2** ++ .line/sy STZ2
.line/dx LDZ2 .line/dy LDZ2 ++ .line/e1 STZ2
&loop
.line/x LDZ2 DUP2 .Screen/x DEO2 [ LIT2 &x $2 ] EQU2
.line/y LDZ2 DUP2 .Screen/y DEO2 [ LIT2 &y $2 ] EQU2
STHkr .Screen/pixel DEO
AND ,&end JCN
.line/e1 LDZ2 DUP2 ADD2 DUP2
.line/dy LDZ2 ;lts2 JSR2 ,&skipy JCN
.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
.line/x LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x STZ2
.line/x LDZ2 .Screen/x DEO2
.line/y LDZ2 .Screen/y DEO2
.line/color LDZ .Screen/pixel DEO
[ .line/x LDZ2 .line/x0 LDZ2 == ]
[ .line/y LDZ2 .line/y0 LDZ2 == ] AND ,&end JCN
.line/e1 LDZ2 2** .line/e2 STZ2
.line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN
.line/e1 LDZ2 .line/dy LDZ2 ++ .line/e1 STZ2
.line/x LDZ2 .line/sx LDZ2 ++ .line/x STZ2
&skipy
.line/dx LDZ2 ;gts2 JSR2 ,&skipx JCN
.line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2
.line/y LDZ2 [ LIT2 &sy $2 ] ADD2 .line/y STZ2
.line/e2 LDZ2 .line/dx LDZ2 GTS2 ,&skipx JCN
.line/e1 LDZ2 .line/dx LDZ2 ++ .line/e1 STZ2
.line/y LDZ2 .line/sy LDZ2 ++ .line/y STZ2
&skipx
,&loop JMP
;&loop JMP2
&end
POPr
JMP2r
RTN
@draw-watchface ( -- )
#3c00
&loop
( dots )
#00 OVRk ADD2 ;table ADD2 LDA2
DUP TOS 2** ;table ++ LDA2
#0018 ;circle JSR2
.Screen/x DEO2 .Screen/y DEO2 #01 .Screen/pixel DEO
( markers )
DUP #05 ;mod JSR2 ,&no-marker JCN
#00 OVRk ADD2 ;table ADD2 LDA2
DUP #05 MOD ,&no-marker JCN
DUP TOS 2** ;table ++ LDA2
STH2k #0018 ;circle JSR2 SWP2
STH2r #001c ;circle JSR2 SWP2
#01 ;draw-line JSR2
@ -185,47 +224,39 @@ JMP2r
INC GTHk ;&loop JCN2
POP2
JMP2r
RTN
@make-needles ( -- )
[ #00 .DateTime/second DEI #1e ADD #3c ;mod JSR2 ] DUP2 ADD2 ;table ADD2 LDA2
[ #00 .DateTime/second DEI #1e + #3c MOD ] 2** ;table ++ LDA2
#00a0 ,circle JSR .needles/zx STZ2 .needles/zy STZ2
[ #00 .DateTime/second DEI ] DUP2 ADD2 ;table ADD2 LDA2
[ #00 .DateTime/second DEI ] 2** ;table ++ LDA2
#0020 ,circle JSR .needles/sx STZ2 .needles/sy STZ2
[ #00 .DateTime/minute DEI ] DUP2 ADD2 ;table ADD2 LDA2
[ #00 .DateTime/minute DEI ] 2** ;table ++ LDA2
#0022 ,circle JSR .needles/mx STZ2 .needles/my STZ2
[ #00 .DateTime/hour DEI #0c ;mod JSR2 #20 SFTk NIP ADD ]
( minute offset ) [ #00 .DateTime/minute DEI #0f DIV ADD2 ] DUP2 ADD2 ;table ADD2 LDA2
[ #00 .DateTime/hour DEI 12HOURS #20 SFTk NIP ADD ]
( minute offset ) [ #00 .DateTime/minute DEI #0f / ++ ] 2** ;table ++ LDA2
#002a ,circle JSR .needles/hx STZ2 .needles/hy STZ2
JMP2r
RTN
@circle ( cx cy radius* -- y* x* )
STH2 SWP
#00 SWP #40 SFT2 STH2kr DIV2 .center/x LDZ2 ADD2 #0800 STH2kr DIV2 SUB2
TOS 10** STH2kr // .center/x LDZ2 ++ #0080 10** STH2kr // --
STH2 SWP2r
#00 SWP #40 SFT2 STH2kr DIV2 .center/y LDZ2 ADD2 #0800 STH2kr DIV2 SUB2
TOS 10** STH2kr // .center/y LDZ2 ++ #0080 10** STH2kr // --
POP2r STH2r
JMP2r
RTN
@decimal ( value* zp-label -- )
STH
DUP #0a DIV #30 ADD STHkr STZ
#0a ;mod JSR2 #30 ADD STHr INC STZ
DUP #0a DIV #30 + STHkr STZ
#0a MOD #30 + STHr INC STZ
JMP2r
@mod DIVk MUL SUB JMP2r
@abs2 DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 JMP2r
@lts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r
@gts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 JMP2r
@is-uc DUP #40 GTH SWP #5b LTH AND JMP2r
@is-lc DUP #60 GTH SWP #7b LTH AND JMP2r
@is-num DUP #2f GTH SWP #3a LTH AND JMP2r
RTN
@week-txt
"Sun $1 "Mon $1 "Tue $1 "Wed $1 "Thu $1 "Fri $1

View file

@ -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 ]

View file

@ -0,0 +1,543 @@
( darena.tal )
( an open-ended game of rocks and sand )
( contributed by and cc0 sejo 12021 )
( parameters )
%nrocks { #1f }
%nrocks-1 { #1e }
%nrocks_mask { #1f }
%minposx { #0f }
%minposy { #0f }
%maxposx { #f1 }
%maxposy { #f1 }
%anispeedmask_normal { #03 }
%anispeedmask_slow { #07 }
%c_color_normal { #43 }
%c_color_flipx { #53 }
%index_norock { #ff }
( output macros )
%out_screen_x { LDA #00 SWP .Screen/x DEO2 } ( ;addr )
%out_screen_y { LDA #00 SWP .Screen/y DEO2 } ( ;addr )
( helper macros )
%get_bit_n { SFT #01 AND }
%get_nibble_h { #04 SFT #0f AND }
%get_nibble_l { #0f AND }
%is_bit_n_set { get_bit_n #01 EQU }
%set_animate { #01 ;c_state LDA ORA ;c_state STA }
%rst_animate { #00 ;c_state STA }
( devices )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &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 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
( variables )
|0000
@c_pos [ &x $1 &y $1 ] ( character position )
@c_speed [ &x $1 &y $1 ] ( character speed )
@c_color [ $1 ] ( character color )
@c_sprite [ $2 ] ( character sprite addr )
@c_state [ $1 ] ( high_nibble: animation pointer, bit0: is_animated )
@f_count [ $1 ] ( frame counter )
@ani_speedmask [ $1 ] ( animation speed mask )
@r_speed_x [ $f ]
@r_speed_y [ $f ]
@tog [ &x $1 &y $1 &state $1 ] ( toggle station state )
( program )
|0100 @reset ( -> )
#f396 .System/r DEO2
#e263 .System/g DEO2
#9030 .System/b DEO2
;on_frame .Screen/vector DEO2
( init character )
#50 ;c_pos/x STA
#10 ;c_pos/y STA
#00 ;c_speed/x STA
#00 ;c_speed/y STA
c_color_normal ;c_color STA
;s_monitx_stepfront0 ;c_sprite STA2
rst_animate
anispeedmask_normal ;ani_speedmask STA
( init toggler )
#27 ;tog/x STA
#27 ;tog/y STA
#00 ;tog/state STA
( init background )
;init_bg JSR2
BRK
@on_frame ( -> )
;f_count LDA INC DUP ;f_count STA ( increase frame counter )
;ani_speedmask LDA ( mask with animation speed mask )
AND #00 EQU ,update_frame JCN ( jump to update if it's time )
BRK
@update_frame
( check keyboard )
;check_keys JSR2
( animate character sprite )
;animate_c JSR2
( clear sprites )
;clear JSR2
( update character vars )
;update_c/run JSR2
( update rocks + stand )
;update_r/run JSR2
( draw )
;draw JSR2
BRK
@clear
( clear rocks )
;s_clear .Screen/addr DEO2
nrocks #00
&rocks_loop
DUP ( get rocks_x[i] )
;rocks_x ROT #00 SWP ADD2 out_screen_x
DUP ( get rocks_y[i] )
;rocks_y ROT #00 SWP ADD2 out_screen_y
#40 .Screen/sprite DEO
INC
DUP2
NEQ ,&rocks_loop JCN
POP2
( clear character )
;clear_c JSR2
JMP2r
@draw
( draw toggler )
;tog/x out_screen_x
;tog/x out_screen_y
;s_stand .Screen/addr DEO2
#03 .Screen/sprite DEO
( draw rocks )
;s_bola .Screen/addr DEO2
nrocks #00
&rocks_loop
DUP ( get rocks_x[i] )
;rocks_x ROT #00 SWP ADD2 out_screen_x
DUP ( get rocks_y[i] )
;rocks_y ROT #00 SWP ADD2 out_screen_y
DUP ( get color )
;r_color ROT #00 SWP ADD2 LDA #41 ADD .Screen/sprite DEO
INC
DUP2
NEQ ,&rocks_loop JCN
POP2
( draw character )
;draw_c JSR2
JMP2r
@check_keys
#00 ;c_speed/x STA
#00 ;c_speed/y STA
.Controller/button DEI #07 is_bit_n_set ,&der JCN
.Controller/button DEI #06 is_bit_n_set ,&izq JCN
.Controller/button DEI #05 is_bit_n_set ,&aba JCN
.Controller/button DEI #04 is_bit_n_set ,&arr JCN
rst_animate
JMP2r
&der
#01 ;c_speed/x STA
set_animate
c_color_normal ;c_color STA
;s_monitx_stepside0 ;c_sprite STA2
JMP2r
&izq
#ff ;c_speed/x STA
set_animate
c_color_flipx ;c_color STA
;s_monitx_stepside0 ;c_sprite STA2
JMP2r
&aba
#01 ;c_speed/y STA
set_animate
c_color_normal ;c_color STA
;s_monitx_stepfront0 ;c_sprite STA2
JMP2r
&arr
#ff ;c_speed/y STA
set_animate
c_color_normal ;c_color STA
;s_monitx_stepback0 ;c_sprite STA2
JMP2r
&end
JMP2r
( sub-routines )
( in: sourcex, source y, index, rangex, rangey )
( puts in the stack the index of rock collisioned with )
@collision_rocks
&range_y $1
&range_x $1
&src_i $1
&src_x $1
&src_y $1
&rock_x $1
&rock_y $1
&run
,&range_y STR
,&range_x STR
,&src_i STR
,&src_y STR
,&src_x STR
( check collision with rocks )
( nrocks #00 )
,&src_i LDR nrocks_mask AND DUP INC nrocks_mask AND
&rocks_loop
DUP ( get rocks_x[i] )
;rocks_x ROT #00 SWP ADD2 LDA ,&rock_x STR
DUP ( get rocks_y[i] )
;rocks_y ROT #00 SWP ADD2 LDA ,&rock_y STR
,&src_x LDR ,&rock_x LDR ,&range_x LDR SUB GTH ( if sx > rx - 8 )
,&src_x LDR ,&rock_x LDR ,&range_x LDR ADD LTH ( if sx < rx + 8 )
,&src_y LDR ,&rock_y LDR ,&range_y LDR SUB GTH ( if sy > ry - 8 )
,&src_y LDR ,&rock_y LDR ,&range_y LDR ADD LTH ( if sy < ry + 8 )
ADD ADD ADD #04 EQU ,&found JCN
INC nrocks_mask AND
DUP2
NEQ ,&rocks_loop JCN
POP2
#ff
JMP2r
&found
NIP ( remove loop limit )
DUP ;&src_i LDA NEQ ,&end JCN ( check if result is the same as index )
POP #ff
JMP2r
&end
JMP2r
@update_c ( update character position )
&new_x $1
&new_y $1
&rock_i $1
&rock_x $1
&rock_y $1
&run
;c_speed/x LDA ;c_pos/x LDA ADD
,&new_x STR
;c_speed/y LDA ;c_pos/y LDA ADD
,&new_y STR
anispeedmask_normal ;ani_speedmask STA
&check_x
( check collision with borders )
,&new_x LDR minposx EQU ;&noup_x JCN2
,&new_x LDR maxposx EQU ;&noup_x JCN2
( check collision with rocks )
,&new_x LDR ,&new_y LDR index_norock #09 #06
;collision_rocks/run JSR2
( if it is colliding with rock, check further )
DUP #ff NEQ ,&check_x_collision JCN
POP
,&update_x JMP
&check_x_collision
( DUP DEBUG )
( slow down and save rock index )
anispeedmask_slow ;ani_speedmask STA
,&rock_i STR
( check if rock collides with others )
;rocks_x #00 ,&rock_i LDR ADD2 LDA ,&rock_x STR
;rocks_y #00 ,&rock_i LDR ADD2 LDA ,&rock_y STR
,&rock_x LDR ,&rock_y LDR ,&rock_i LDR #09 #06
;collision_rocks/run JSR2
( DUP DEBUG )
( if it is colliding, then skip adding x )
DUP #ff NEQ ,&check_y JCN
POP
( if not, check for borders )
;&rock_x LDA minposx EQU ;&noup_x JCN2
;&rock_x LDA maxposx EQU ;&noup_x JCN2
( move rock with same speed as c )
;&rock_x LDA ;c_speed/x LDA ADD
;rocks_x #00 ;&rock_i LDA ADD2
STA
&update_x
;&new_x LDA ;c_pos/x STA
,&check_y JMP
&noup_x
&check_y
( check collision with borders )
;&new_y LDA minposy EQU ;&noup_y JCN2
;&new_y LDA maxposy EQU ;&noup_y JCN2
( check collision with rocks )
;&new_x LDA ;&new_y LDA index_norock #06 #09
;collision_rocks/run JSR2
( if it is colliding with rock, check further )
DUP #ff NEQ ,&check_y_collision JCN
POP
,&update_y JMP
&check_y_collision
( DUP DEBUG )
anispeedmask_slow ;ani_speedmask STA
;&rock_i STA
( check if rock collides with others )
;rocks_x #00 ;&rock_i LDA ADD2 LDA ;&rock_x STA
;rocks_y #00 ;&rock_i LDA ADD2 LDA ;&rock_y STA
;&rock_x LDA ;&rock_y LDA ;&rock_i LDA #06 #09
;collision_rocks/run JSR2
( DUP DEBUG )
( if it is colliding, then skip adding y )
DUP #ff NEQ ,&noup_y JCN
POP
( if not, check for borders )
;&rock_y LDA minposx EQU ;&noup_y JCN2
;&rock_y LDA maxposx EQU ;&noup_y JCN2
( if not colliding, then move rock with same speed as c )
;&rock_y LDA ;c_speed/y LDA ADD
;rocks_y #00 ;&rock_i LDA ADD2
STA
&update_y
;&new_y LDA ;c_pos/y STA
JMP2r
&noup_y
JMP2r
@update_r
&rock_i $1
&run
( check collision with rocks )
;tog/x LDA ;tog/y LDA index_norock #02 #02
;collision_rocks/run JSR2
( if it is colliding with rock, check if it needs to change state )
DUP #ff NEQ ,&change_state JCN
( DUP DEBUG )
( if there's no collision, reset toggler )
POP
#00 ;tog/state STA
JMP2r
&change_state
( DUP DEBUG )
,&rock_i STR
;tog/state LDA ,&done JCN ( don't toggle if state is active )
;r_color #00 ,&rock_i LDR ADD2 DUP2 STH2
LDA #01 EOR STH2r STA
#01 ;tog/state STA
&done
JMP2r
@animate_c
( is bit0 -animate- on? )
;c_state LDA DUP #00 get_bit_n #01 NEQ ,&s_no_animate JCN
( increment and save animation pointer )
&s_animate
DUP
get_nibble_h INC #03 AND #40 SFT
SWP get_nibble_l ORA
;c_state STA
JMP2r
&s_no_animate
get_nibble_h #0f AND ;c_state STA
JMP2r
@draw_c ( draw character )
#00 ;c_state LDA get_nibble_h #30 SFT
;c_sprite LDA2 ADD2 .Screen/addr DEO2
;c_pos/x out_screen_x
;c_pos/y out_screen_y
;c_color LDA .Screen/sprite DEO
JMP2r
@clear_c ( clear character )
;s_clear .Screen/addr DEO2
;c_pos/x out_screen_x
;c_pos/y out_screen_y
#40 .Screen/sprite DEO
JMP2r
@init_bg
( init bg )
;s_border .Screen/addr DEO2
.Screen/height DEI2 #0000 STH2
&vertical0loop
DUP2
STH2r
DUP2 .Screen/y DEO2
.Screen/width DEI2 #0000 STH2
&horizontal0loop
DUP2
STH2r
DUP2 .Screen/x DEO2
#03 .Screen/sprite DEO
#0008 ADD2 DUP2 STH2
GTH2 ,&horizontal0loop JCN
STH2r POP2 POP2
#0008 ADD2 DUP2 STH2
GTH2 ,&vertical0loop JCN
STH2r
POP2 POP2
( arena )
;s_clear .Screen/addr DEO2
#00 maxposy #00 minposy STH2
&vertical0loop_clear
DUP2
STH2r
DUP2 .Screen/y DEO2
#00 maxposx #00 minposx STH2
&horizontal0loop_clear
DUP2
STH2r
DUP2 .Screen/x DEO2
#00 .Screen/sprite DEO
#0008 ADD2 DUP2 STH2
GTH2 ,&horizontal0loop_clear JCN
STH2r POP2 POP2
#0008 ADD2 DUP2 STH2 GTH2 ,&vertical0loop_clear JCN
STH2r
POP2 POP2
JMP2r
( rocks )
@rocks_x [ 25 30 42 50 67 90 98 e8 20 43 43 57 5a 7f bc a5
e5 dd a2 20 b7 9b 38 e8 33 43 63 b7 aa cf bc ]
@rocks_y [ 60 48 34 56 23 65 65 65 ba e9 24 22 72 91 22 c5
25 30 42 50 67 90 98 e8 20 43 43 57 5a 7f bc ]
@r_color [ 00 01 01 00 00 00 01 01 01 01 00 00 01 01 00 00
01 00 01 00 00 01 00 01 01 01 01 01 00 00 00 ]
( sprites )
@s_clear [ 0000 0000 0000 0000 ]
@s_border [ 3288 7e83 780d e013 ]
@s_bola [ 3c4e 9ffd f962 3c00 ]
@s_stand [ 0000 0000 0024 7eff ]
@s_stand_original [ 0000 0000 0000 3c7e ]
@s_monitx [ 3c7e 5a7f 1b3c 5a18 ]
@s_monitx_back [ 3c7e 7efe d83c 5a18 ]
@s_monitx_stepfront0 [ 3c7e 5a7f 1b3c 5a18 ]
@s_monitx_stepfront1 [ 3c7e 5a7f 1b3c 5a10 ]
@s_monitx_stepfront2 [ 3c7e 5a7f 1b3c 5a18 ]
@s_monitx_stepfront3 [ 3c7e 5a7f 1b3c 5a08 ]
@s_monitx_stepback0 [ 3c7e 7efe d83c 5a18 ]
@s_monitx_stepback1 [ 3c7e 7efe d83c 5a10 ]
@s_monitx_stepback2 [ 3c7e 7efe d83c 5a18 ]
@s_monitx_stepback3 [ 3c7e 7efe d83c 5a08 ]
@s_monitx_stepside0 [ 1c3c 7afc d81c 1818 ]
@s_monitx_stepside1 [ 1c3c 7afc d81c 1828 ]
@s_monitx_stepside2 [ 1c3c 7afc d81c 3810 ]
@s_monitx_stepside3 [ 1c3c 7afc d81c 1814 ]

View file

@ -8,7 +8,7 @@
|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 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables )
@ -22,12 +22,12 @@
#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/day DEI #10 SFT2 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
;rabbits STH2 #0f05 &loop-x
#0f05 &loop-y
ROTk SWP STH2kr STA2 POP
INC2r INC2r
@ -93,7 +93,7 @@
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 #01 ADD ,&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* )
@ -160,7 +160,7 @@
( 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* )
#00 SWP #10 SFT2 ;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
@ -181,7 +181,7 @@
&static ( color n counter / frame )
INCr
POP
#00 SWP DUP2 ADD2 ;rabbits ADD2 #00c8 #00 STHr MUL2 ADD2
#00 SWP #10 SFT2 ;rabbits ADD2 #00c8 #00 STHr MUL2 ADD2
LDA2 STH2k
,&draw JMP

View file

@ -0,0 +1,726 @@
( drum rack )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%2** { #10 SFT2 } %2// { #01 SFT2 }
%4** { #20 SFT2 } %4// { #02 SFT2 }
%8** { #30 SFT2 } %8// { #03 SFT2 }
%10** { #40 SFT2 }
%TOB { NIP } %TOS { #00 SWP }
%RTN { JMP2r }
%MOD { DUP2 / * - }
%LTS2 { #8000 ++ SWP2 #8000 ++ >> } %GTS2 { #8000 ++ SWP2 #8000 ++ << }
%PAD-WIDTH { #0030 }
%PAD-HEIGHT { #0020 }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
|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 ]
|70 @Midi [ &vector $2 &channel $1 &note $1 &velocity $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 ]
( variables )
|0000
@center [ &x $2 &y $2 ]
@pointer [ &x $2 &y $2 ]
@piano [ &last $1 &octave $1 ]
@pads [ &last $1 ]
@frame [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@pad-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@mix-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@oct-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@wav-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
( TODO: remove )
@color $1
@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@modes [ $1 $1 $1 $1 ] ( single/repeat )
( program )
|0100 ( -> )
( theme )
#0fe5 .System/r DEO2
#0fc5 .System/g DEO2
#0f25 .System/b DEO2
( vectors )
;on-control .Controller/vector DEO2
;on-mouse .Mouse/vector DEO2
;on-frame .Screen/vector DEO2
;on-message .Console/vector DEO2
( channel defaults )
#dd .Audio0/volume DEO
#0118 .Audio0/adsr DEO2
#0200 .Audio0/length DEO2
#ce .Audio1/volume DEO
#0334 .Audio1/adsr DEO2
#0800 .Audio1/length DEO2
#ec .Audio2/volume DEO
#0414 .Audio2/adsr DEO2
#0800 .Audio2/length DEO2
#ee .Audio3/volume DEO
#022c .Audio3/adsr DEO2
#1000 .Audio3/length DEO2
( defaults )
#01 .modes STZ
#01 .piano/octave STZ
( find center )
.Screen/width DEI2 2// .center/x STZ2
.Screen/height DEI2 2// .center/y STZ2
( place frame )
.center/x LDZ2 PAD-WIDTH #0003 ** -- #0010 -- .frame/x1 STZ2
.center/y LDZ2 #0050 -- .frame/y1 STZ2
.center/x LDZ2 PAD-WIDTH #0003 ** ++ #0010 ++ .frame/x2 STZ2
.frame/y1 LDZ2 PAD-HEIGHT 4** ++ #0028 ++ .frame/y2 STZ2
( place pad-view )
.frame/x1 LDZ2 .pad-view/x1 STZ2
.frame/y1 LDZ2 .pad-view/y1 STZ2
.pad-view/x1 LDZ2 #0004 PAD-WIDTH ** ++ .pad-view/x2 STZ2
.pad-view/y1 LDZ2 #0004 PAD-HEIGHT ** ++ .pad-view/y2 STZ2
( place mix-view )
.pad-view/x2 LDZ2 #0006 ++ .mix-view/x1 STZ2
.pad-view/y1 LDZ2 .mix-view/y1 STZ2
.mix-view/x1 LDZ2 #007a ++ .mix-view/x2 STZ2
.pad-view/y2 LDZ2 .mix-view/y2 STZ2
( place oct-view )
.frame/x1 LDZ2 .oct-view/x1 STZ2
.mix-view/y2 LDZ2 #0004 ++ .oct-view/y1 STZ2
.oct-view/x1 LDZ2 #0050 ++ .oct-view/x2 STZ2
.oct-view/y1 LDZ2 #0018 ++ .oct-view/y2 STZ2
( place wav-view )
.oct-view/x2 LDZ2 .wav-view/x1 STZ2
.mix-view/y2 LDZ2 #0004 ++ .wav-view/y1 STZ2
.frame/x2 LDZ2 .wav-view/x2 STZ2
.wav-view/y1 LDZ2 #0020 ++ .wav-view/y2 STZ2
( draw outlines )
.mix-view/x1 LDZ2 #0004 --
.mix-view/y1 LDZ2 #0000 --
.mix-view/x2 LDZ2 #0002 --
.mix-view/y2 LDZ2 #0002 --
#01 ;line-rect JSR2
.wav-view/x1 LDZ2 #0000 --
.wav-view/y1 LDZ2 #0002 --
.wav-view/x2 LDZ2 #0002 --
.wav-view/y2 LDZ2 #0002 ++
#01 ;line-rect JSR2
( initial draw )
#00 #10
&draw-pads
( load sample )
OVR TOS #0019 ** ;pad-path ++ .File/name DEO2
OVR #04 / #40 SFT .Audio0/length + DEI2 .File/length DEO2
OVR TOS 2** ;pad-addr ++ LDA2 .File/read DEO2
( draw pad )
OVR #01 ;draw-pad JSR2
( draw mixer )
OVR #04 / ;draw-mixer JSR2
( incr ) SWP INC SWP
LTHk ,&draw-pads JCN
POP2
;draw-octave JSR2
BRK
@on-message ( -> )
.Console/read DEI #0f AND ;play-pad JSR2
BRK
@on-frame ( -> )
( update VU monitors )
#00 #04
&loop
OVR STH
( x ) .mix-view/x1 LDZ2 #0074 ++
( y ) .mix-view/y1 LDZ2 PAD-HEIGHT STHkr TOS ** ++ #0002 ++
( output ) .Audio0/output STHr #40 SFT + DEI
;draw-monitor JSR2
( incr ) SWP INC SWP
LTHk ,&loop JCN
POP2
BRK
@on-mouse ( -> )
;draw-cursor JSR2
.Mouse/state DEI #00 ! #01 JCN [ BRK ]
.Mouse/x DEI2 DUP2 .pad-view/x1 LDZ2 >> ROT ROT .pad-view/x2 LDZ2 INC2 << #0101 ==
.Mouse/y DEI2 DUP2 .pad-view/y1 LDZ2 >> ROT ROT .pad-view/y2 LDZ2 << #0101 ==
#0101 == ;on-touch-pad JCN2
.Mouse/x DEI2 DUP2 .mix-view/x1 LDZ2 >> ROT ROT .mix-view/x2 LDZ2 INC2 << #0101 ==
.Mouse/y DEI2 DUP2 .mix-view/y1 LDZ2 >> ROT ROT .mix-view/y2 LDZ2 << #0101 ==
#0101 == ;on-touch-mix JCN2
.Mouse/x DEI2 DUP2 .oct-view/x1 LDZ2 >> ROT ROT .oct-view/x2 LDZ2 INC2 << #0101 ==
.Mouse/y DEI2 DUP2 .oct-view/y1 LDZ2 >> ROT ROT .oct-view/y2 LDZ2 << #0101 ==
#0101 == ;on-touch-oct JCN2
BRK
@on-control ( -> )
.Controller/key DEI #00 ! #01 JCN [ BRK ]
.Controller/key DEI
DUP #31 ! ,&no-0 JCN #00 ;play-pad JSR2 &no-0
DUP #32 ! ,&no-1 JCN #01 ;play-pad JSR2 &no-1
DUP #33 ! ,&no-2 JCN #02 ;play-pad JSR2 &no-2
DUP #34 ! ,&no-3 JCN #03 ;play-pad JSR2 &no-3
DUP #71 ! ,&no-4 JCN #04 ;play-pad JSR2 &no-4
DUP #77 ! ,&no-5 JCN #05 ;play-pad JSR2 &no-5
DUP #65 ! ,&no-6 JCN #06 ;play-pad JSR2 &no-6
DUP #72 ! ,&no-7 JCN #07 ;play-pad JSR2 &no-7
DUP #61 ! ,&no-8 JCN #08 ;play-pad JSR2 &no-8
DUP #73 ! ,&no-9 JCN #09 ;play-pad JSR2 &no-9
DUP #64 ! ,&no-a JCN #0a ;play-pad JSR2 &no-a
DUP #66 ! ,&no-b JCN #0b ;play-pad JSR2 &no-b
DUP #7a ! ,&no-c JCN #0c ;play-pad JSR2 &no-c
DUP #78 ! ,&no-d JCN #0d ;play-pad JSR2 &no-d
DUP #63 ! ,&no-e JCN #0e ;play-pad JSR2 &no-e
DUP #76 ! ,&no-f JCN #0f ;play-pad JSR2 &no-f
POP
BRK
@on-touch-pad ( -> )
( x ) .Mouse/x DEI2 .pad-view/x1 LDZ2 -- PAD-WIDTH // TOB
( y ) .Mouse/y DEI2 .pad-view/y1 LDZ2 -- PAD-HEIGHT // TOB #20 SFT +
DUP SWP ;play-pad JSR2
;draw-waveform JSR2
( release ) #00 .Mouse/state DEO
BRK
@on-touch-mix ( -> )
( channel ) .Mouse/y DEI2 .mix-view/y1 LDZ2 -- PAD-HEIGHT // TOB STH
( knob ) .Mouse/x DEI2 .mix-view/x1 LDZ2 -- #0010 // TOB
( adsr )
DUP #00 ! ,&no-a JCN
.Audio0/adsr [ STHkr #40 SFT + ] DEI
#10 .Mouse/state DEI #10 = #e0 * + +
.Audio0/adsr [ STHkr #40 SFT + ] DEO &no-a
DUP #01 ! ,&no-d JCN
.Audio0/adsr [ STHkr #40 SFT + ] DEI
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
.Audio0/adsr [ STHkr #40 SFT + ] DEO &no-d
DUP #02 ! ,&no-s JCN
.Audio0/adsr [ STHkr #40 SFT + ] INC DEI
#10 .Mouse/state DEI #10 = #e0 * + +
.Audio0/adsr [ STHkr #40 SFT + ] INC DEO &no-s
DUP #03 ! ,&no-r JCN
.Audio0/adsr [ STHkr #40 SFT + ] INC DEI
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
.Audio0/adsr [ STHkr #40 SFT + ] INC DEO &no-r
( modes )
DUP #04 ! ,&no-repeat JCN
.modes [ STHkr + ] LDZ
#00 =
.modes [ STHkr + ] STZ &no-repeat
( volume )
DUP #05 ! ,&no-left JCN
.Audio0/volume [ STHkr #40 SFT + ] DEI
#10 .Mouse/state DEI #10 = #e0 * + +
.Audio0/volume [ STHkr #40 SFT + ] DEO &no-left
DUP #06 ! ,&no-right JCN
.Audio0/volume [ STHkr #40 SFT + ] DEI
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
.Audio0/volume [ STHkr #40 SFT + ] DEO &no-right
POP
( release ) #00 .Mouse/state DEO
STHkr ;draw-mixer JSR2
POPr
BRK
@on-touch-oct ( -> )
.Mouse/x DEI2 .oct-view/x1 LDZ2 -- 8// TOB #08 ! ,&no-mod JCN
.Mouse/y DEI2 .oct-view/y1 LDZ2 -- 8// TOB
DUP #00 ! ,&no-incr JCN
.piano/octave LDZ INC .piano/octave STZ &no-incr
DUP #02 ! ,&no-decr JCN
.piano/octave LDZ #01 - .piano/octave STZ &no-decr
POP
( release ) #00 .Mouse/state DEO
;draw-octave JSR2
BRK
&no-mod
.Mouse/x DEI2 .oct-view/x1 LDZ2 -- 8// TOB #06 GTH ,&no-key JCN
.Mouse/x DEI2 .oct-view/x1 LDZ2 -- 8//
( set pitch of pad )
DUP2 ;notes ++ LDA .pads/last LDZ SWP .piano/octave LDZ #02 - #0c * +
( save ) SWP TOS ;pad-pitch ++ STA
( record last note )
TOB .piano/last STZ
.pads/last LDZ ;play-pad JSR2
( release ) #00 .Mouse/state DEO
;draw-octave JSR2
&no-key
BRK
@play-pad ( pad -- )
( unselect last )
.pads/last LDZ #01 ;draw-pad JSR2
DUP .pads/last STZ
( highlight )
DUP #02 ;draw-pad JSR2
( addr )
DUP TOS 2** ;pad-addr ++ LDA2 STH2
DUP #04 / #40 SFT .Audio0/addr + STH2r ROT DEO2
( pitch )
DUP TOS ;pad-pitch ++ LDA STH
DUP #04 / .modes + LDZ #00 = #70 SFT STH ADDr
DUP #04 / #40 SFT .Audio0/pitch + STHr SWP DEO
#04 / ;draw-mixer JSR2
RTN
@draw-waveform ( pad -- )
( stash address )
DUP ADD #00 SWP ;pad-addr ++ LDA2 STH2
( clear )
.wav-view/x1 LDZ2 #0002 ++
.wav-view/y1 LDZ2
.wav-view/x2 LDZ2 #0002 --
.wav-view/y2 LDZ2
#00 ;fill-rect JSR2
.wav-view/x1 LDZ2 #0002 ++ .Screen/x DEO2
( waveform )
#00 #e8
&loop
( dotted line )
OVR #01 AND ,&no-dot JCN
.wav-view/y1 LDZ2 #0010 ++ .Screen/y DEO2
#01 .Screen/pixel DEO
&no-dot
OVR TOS 10** [ DUP2r STH2r ] ++ LDA
#02 /
TOS 4// .wav-view/y1 LDZ2 ++ .Screen/y DEO2
.Screen/x DEI2 INC2 .Screen/x DEO2
( draw ) #02 .Screen/pixel DEO
( incr ) SWP INC SWP
LTHk ,&loop JCN
POP2
POP2r
RTN
@draw-mixer ( mixer -- )
STHk #00 SWP PAD-HEIGHT ** .mix-view/y1 LDZ2 ++ #0003 ++
( adsr )
DUP2 .mix-view/x1 LDZ2 SWP2
.Audio0/adsr [ STHkr #40 SFT + ] DEI #04 SFT ;draw-knob JSR2
DUP2 .mix-view/x1 LDZ2 #0010 ++ SWP2
.Audio0/adsr [ STHkr #40 SFT + ] DEI #0f AND ;draw-knob JSR2
DUP2 .mix-view/x1 LDZ2 #0020 ++ SWP2
.Audio0/adsr [ STHkr #40 SFT + ] INC DEI #04 SFT ;draw-knob JSR2
DUP2 .mix-view/x1 LDZ2 #0030 ++ SWP2
.Audio0/adsr [ STHkr #40 SFT + ] INC DEI #0f AND ;draw-knob JSR2
( once/repeat )
DUP2 .mix-view/x1 LDZ2 #0040 ++ SWP2
.modes [ STHkr + ] LDZ ;draw-switch JSR2
( volume )
DUP2 .mix-view/x1 LDZ2 #0050 ++ SWP2
.Audio0/volume [ STHkr #40 SFT + ] DEI #04 SFT ;draw-knob JSR2
DUP2 .mix-view/x1 LDZ2 #0060 ++ SWP2
.Audio0/volume [ STHkr #40 SFT + ] DEI #0f AND ;draw-knob JSR2
POP2
POPr
RTN
@draw-pad ( pad color -- )
STH STH
STHkr
DUP #04 / SWP #03 AND TOS PAD-WIDTH ** ( center ) .pad-view/x1 LDZ2 ++
ROT TOS PAD-HEIGHT ** ( center ) .pad-view/y1 LDZ2 ++
( draw outline )
OVR2 OVR2
OVR2 PAD-WIDTH #0002 -- ++
OVR2 PAD-HEIGHT #0002 -- ++
OVRr STHr ;line-rect JSR2
( draw name )
OVR2 #0002 ++
OVR2 #0002 ++
;pad-name STHkr TOS #0005 ** ++
#00 OVRr STHr +
;draw-label JSR2
( draw note )
OVR2 #0003 ++ .Screen/x DEO2
DUP2 #0014 ++ .Screen/y DEO2
( get pitch ) STHkr TOS ;pad-pitch ++ LDA
#0c / TOS 8** ;font-hex ++ .Screen/addr DEO2
#01 .Screen/sprite DEO
( draw octave )
OVR2 #000b ++ .Screen/x DEO2
DUP2 #0014 ++ .Screen/y DEO2
( get pitch ) STHkr TOS ;pad-pitch ++ LDA
#0c MOD TOS 8** ;font-notes ++ .Screen/addr DEO2
#01 .Screen/sprite DEO
POP2 POP2
POPr POPr
RTN
@draw-octave ( -- )
.oct-view/x1 LDZ2 .oct-view/y1 LDZ2
OVR2 OVR2 ;keys-left-icns #01 .piano/last LDZ #00 = + ;draw-key JSR2
OVR2 #0008 ++ OVR2 ;keys-middle-icns #01 .piano/last LDZ #01 = + ;draw-key JSR2
OVR2 #0010 ++ OVR2 ;keys-right-icns #01 .piano/last LDZ #02 = + ;draw-key JSR2
OVR2 #0018 ++ OVR2 ;keys-left-icns #01 .piano/last LDZ #03 = + ;draw-key JSR2
OVR2 #0020 ++ OVR2 ;keys-middle-icns #01 .piano/last LDZ #04 = + ;draw-key JSR2
OVR2 #0028 ++ OVR2 ;keys-middle-icns #01 .piano/last LDZ #05 = + ;draw-key JSR2
SWP2 #0030 ++ SWP2 ;keys-right-icns #01 .piano/last LDZ #06 = + ;draw-key JSR2
.oct-view/x1 LDZ2 #0040 ++ .Screen/x DEO2
;arrow-icns .Screen/addr DEO2
.oct-view/y1 LDZ2 .Screen/y DEO2
#01 .Screen/sprite DEO
;arrow-icns #0008 ++ .Screen/addr DEO2
.oct-view/y1 LDZ2 #0010 ++ .Screen/y DEO2
#01 .Screen/sprite DEO
;font-hex .piano/octave LDZ #03 + #00 SWP 8** ++ .Screen/addr DEO2
.oct-view/y1 LDZ2 #0008 ++ .Screen/y DEO2
#03 .Screen/sprite DEO
RTN
@draw-monitor ( x* y* stereo -- )
STH
.Screen/y DEO2
.Screen/x DEO2
#00 #0f
&loop
OVR #10 SWP - STHkr #0f AND < INC .Screen/pixel DEO
.Screen/x DEI2 #0002 ++ .Screen/x DEO2
OVR #10 SWP - STHkr #04 SFT < INC .Screen/pixel DEO
.Screen/x DEI2 #0002 -- .Screen/x DEO2
.Screen/y DEI2 #0002 ++ .Screen/y DEO2
( incr ) SWP INC SWP
LTHk ,&loop JCN
POP2
POPr
RTN
@draw-key ( x* y* addr* color -- )
STH
.Screen/addr DEO2
SWP2 .Screen/x DEO2
DUP2 #0018 ++
&loop
( move ) OVR2 .Screen/y DEO2
( draw ) STHkr .Screen/sprite DEO
( incr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
( incr ) SWP2 #0008 ++ SWP2
LTH2k ,&loop JCN
POP2 POP2
POPr
RTN
@draw-cursor ( -- )
( clear last cursor )
;cursor-icn .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 )
#43 [ .Mouse/state DEI #00 ! ] - .Screen/sprite DEO
RTN
@draw-knob ( x* y* value -- )
( load ) STH .Screen/y DEO2 .Screen/x DEO2
;knob-icns .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
;knob-icns #0008 ++ .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
;knob-icns #0018 ++ .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
.Screen/x DEI2 #0008 -- .Screen/x DEO2
;knob-icns #0010 ++ .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
.Screen/x DEI2 #0004 ++ .Screen/x DEO2
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
;font-hex #00 STHkr #30 SFT ++ .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
.Screen/x DEI2 #0004 -- #00 #00 STHkr ;knob-offsetx ++ LDA ++ .Screen/x DEO2
.Screen/y DEI2 #0010 -- #00 #00 STHr ;knob-offsety ++ LDA ++ .Screen/y DEO2
;knob-icns #0020 ++ .Screen/addr DEO2
( draw ) #05 .Screen/sprite DEO
RTN
@draw-switch ( x* y* value -- )
STH .Screen/y DEO2 .Screen/x DEO2
STHkr #50 SFT #00 SWP ;switch-icns ++
DUP2 .Screen/addr DEO2
( draw ) #01 STHkr + .Screen/sprite DEO
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
DUP2 #0008 ++ .Screen/addr DEO2
( draw ) #01 STHkr + .Screen/sprite DEO
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
.Screen/x DEI2 #0008 -- .Screen/x DEO2
DUP2 #0010 ++ .Screen/addr DEO2
( draw ) #01 STHkr + .Screen/sprite DEO
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
#0018 ++ .Screen/addr DEO2
( draw ) #01 STHr + .Screen/sprite DEO
RTN
@line-rect ( x1* y1* x2* y2* color -- )
( load ) .color STZ STH2k .rect/y2 STZ2 .rect/x2 STZ2 STH2k .rect/y1 STZ2 .rect/x1 STZ2
STH2r INC2 STH2r
&ver
( save ) OVR2 .Screen/y DEO2
( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/pixel DEO
( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .Screen/pixel DEO
( incr ) SWP2 INC2 SWP2
OVR2 OVR2 LTS2 ,&ver JCN
POP2 POP2
.rect/x1 LDZ2 INC2 .rect/x2 LDZ2 #0001 --
&hor
( save ) OVR2 .Screen/x DEO2
( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/pixel DEO
( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/pixel DEO
( incr ) SWP2 INC2 SWP2
OVR2 OVR2 INC2 LTS2 ,&hor JCN
POP2 POP2
RTN
@draw-label ( x* y* addr* color -- )
( load ) STH STH2 .Screen/y DEO2 .Screen/x DEO2
STH2r
&loop
LDAk #00 SWP #0030 -- 8** ;font-num-uc ++ .Screen/addr DEO2
( draw ) STHkr .Screen/sprite DEO
( incr ) INC2
( incr ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2
LDAk #00 ! ,&loop JCN
POP2
POPr
RTN
@fill-rect ( x1* y1* x2* y2* color -- )
.color STZ
( x1 x2 y1 y2 ) ROT2 SWP2
&ver
( save ) OVR2 .Screen/y DEO2
STH2 STH2 OVR2 OVR2
&hor
( save ) OVR2 .Screen/x DEO2
( draw ) .color LDZ .Screen/pixel DEO
( incr ) SWP2 INC2 SWP2
OVR2 OVR2 LTS2 ,&hor JCN
POP2 POP2 STH2r STH2r
( incr ) SWP2 INC2 SWP2
OVR2 OVR2 LTS2 ,&ver JCN
POP2 POP2 POP2 POP2
RTN
@pad-name [
"PAD1 $1 "SYN1 $1 "SYN2 $1 "CYM1 $1 ( short )
"HHAT $1 "OHAT $1 "CHAT $1 "RIDE $1
"SID1 $1 "SNR1 $1 "SNR2 $1 "SID2 $1 ( long )
"BDR1 $1 "KCK1 $1 "KCK2 $1 "SUB1 $1 ]
@pad-addr [
6000 6400 6800 6c00
7000 7800 8000 8800
9000 9800 a000 a800
b000 c000 d000 e000 $2 ]
@pad-pitch [
30 30 30 30
30 30 30 30
30 30 30 30
30 30 30 30 ]
@pad-path [
"projects/sounds/pad1.pcm $1 "projects/sounds/syn1.pcm $1 "projects/sounds/syn2.pcm $1 "projects/sounds/pad2.pcm $1
"projects/sounds/hhat.pcm $1 "projects/sounds/ohat.pcm $1 "projects/sounds/chat.pcm $1 "projects/sounds/ride.pcm $1
"projects/sounds/sid1.pcm $1 "projects/sounds/snr1.pcm $1 "projects/sounds/snr2.pcm $1 "projects/sounds/sid2.pcm $1
"projects/sounds/bdr1.pcm $1 "projects/sounds/kck1.pcm $1 "projects/sounds/kck2.pcm $1 "projects/sounds/sub1.pcm $1 ]
@notes [
3c 3e 40 41 43 45 47
48 4a 4c 4d 4f 51 53 ]
@cursor-icn [
80c0 e0f0 f8e0 1000 ]
@keys-left-icns [
7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7e7f
7f7f 7f7f 7f7f 3e00 ]
@keys-middle-icns [
1c1c 1c1c 1c1c 1c1c
1c1c 1c1c 1c1c 3e7f
7f7f 7f7f 7f7f 3e00 ]
@keys-right-icns [
1f1f 1f1f 1f1f 1f1f
1f1f 1f1f 1f1f 3f7f
7f7f 7f7f 7f7f 3e00 ]
@arrow-icns [
0010 387c fe10 1000
0010 1010 fe7c 3810 ]
@switch-icns [
001f 2040 4040 4040
00f8 0402 0202 0202
404f 5f5f 4f20 1f00
02f2 fafa f204 f800
001f 204f 5f5f 4f40
00f8 04f2 fafa f202
4040 4040 4020 1f00
0202 0202 0204 f800 ]
@knob-icns [
0003 0c10 2020 4040
00c0 3008 0404 0202
4040 2020 100c 0300
0202 0404 0830 c000
0000 183c 3c18 0000 ]
@knob-offsetx [
01 00 00 00 00 01 02 03
05 06 07 08 08 08 08 07 ]
@knob-offsety [
07 06 05 03 02 01 00 00
00 00 01 02 03 05 06 07 ]
@font-notes [
003e 4140 4040 413e 40ae 4100 4040 413e
007e 4141 4141 417e 40ae 4101 4141 417e
003e 4140 7c40 413e 003f 4040 7e40 4040
40af 4000 7e40 4040 003e 4140 5f41 413e
40ae 4100 5f41 413e 003e 4141 7f41 4141
40ae 4101 7f41 4141 007e 4141 7e41 417e
]
@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
]
@font-num-uc [
003e 4141 4141 413e 0018 0808 0808 081c
003e 4101 3e40 407f 003e 4101 1f01 413e
0011 2141 7f01 0101 007f 4040 7e01 413e
003e 4140 7e41 413e 003e 4101 0102 0408
003e 4141 3e41 413e 003e 4141 3f01 0102
0000 0800 0000 0800 0000 0800 0000 0800
0000 0800 0000 0810 0000 0408 1008 0400
0000 001c 001c 0000 0000 1008 0408 1000
0000 0000 0000 0000 003e 4101 3f41 413f
007e 4141 7e41 417e 003e 4140 4040 413e
007e 4141 4141 417e 007f 4040 7e40 407f
007f 4040 7e40 4040 003e 4140 5e41 413e
0041 4141 7f41 4141 0008 0808 0808 0808
007f 0101 0101 413e 0041 4244 7844 4241
0040 4040 4040 403f 0076 4949 4949 4949
005e 6141 4141 4141 003e 4141 4141 413e
007e 4141 7e40 4040 003e 4141 4145 423d
007e 4141 7e41 4141 003e 4140 3e01 413e
007f 0808 0808 0808 0041 4141 4141 433d
0041 4141 4122 1408 0049 4949 4949 4976
0041 2214 0814 2241 0041 4141 3f01 413e
007f 0101 3e40 407f ]

View file

@ -0,0 +1,543 @@
( art by @ritualdust )
%+ { ADD } %- { SUB } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%8** { #30 SFT2 }
%10** { #40 SFT2 }
%DEBUG { ;print-hex JSR2 #0a .Console/write DEO }
%DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO }
%RTN { JMP2r }
%TOS { #00 SWP }
%DEC { #01 - }
%MOUSE { #82 }
( devices )
|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 &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 ]
|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 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
|0000
@room
&x $2 &y $2
@player
&x $1 &y $1 &d $1
|0100
( theme )
#067f .System/r DEO2
#036f .System/g DEO2
#003f .System/b DEO2
.Screen/width DEI2 #01 SFT2 #0040 -- .room/x STZ2
.Screen/height DEI2 #01 SFT2 #0040 -- .room/y STZ2
( vectors )
;on-frame .Screen/vector DEO2
;on-button .Controller/vector DEO2
;entrance ;draw-dungeon JSR2
#05 .player/x STZ
#06 .player/y STZ
MOUSE ;draw-mouse JSR2
BRK
@on-button ( -> )
.Controller/button DEI
DUP #00 ! ,&no-null JCN
POP BRK
&no-null
DUP #10 ! ,&no-up JCN
#00 .player/d STZ
#00 ;draw-mouse JSR2
.player/y LDZk DEC SWP STZ
MOUSE ;draw-mouse JSR2
&no-up
DUP #20 ! ,&no-down JCN
#01 .player/d STZ
#00 ;draw-mouse JSR2
.player/y LDZk INC SWP STZ
MOUSE ;draw-mouse JSR2
&no-down
DUP #40 ! ,&no-left JCN
#02 .player/d STZ
#00 ;draw-mouse JSR2
.player/x LDZk DEC SWP STZ
MOUSE ;draw-mouse JSR2
&no-left
DUP #80 ! ,&no-right JCN
#03 .player/d STZ
#00 ;draw-mouse JSR2
.player/x LDZk INC SWP STZ
MOUSE ;draw-mouse JSR2
&no-right
POP
BRK
@on-frame ( -> )
BRK
@draw-mouse ( color -- )
;spritesheet #29 .player/d LDZ + TOS DUP2 DEBUG2 10** ++ .Screen/addr DEO2
.player/x LDZ TOS 8** .room/x LDZ2 ++ .Screen/x DEO2
.player/y LDZ TOS 8** .room/y LDZ2 ++ .Screen/y DEO2
#40 + .Screen/sprite DEO
RTN
@draw-dungeon ( stage* -- )
STH2
#1000
&ver
DUP TOS 8** .room/y LDZ2 ++ .Screen/y DEO2
#1000
&hor
DUP TOS 8** .room/x LDZ2 ++ .Screen/x DEO2
( get id ) STH2 DUP STH2r ROT OVR SWP #40 SFT + TOS
( tile ) DUP2 STH2kr ++ LDA TOS 10** ;spritesheet ++ .Screen/addr DEO2
( color ) STH2kr #0100 ++ ++ LDA .Screen/sprite DEO
INC GTHk ,&hor JCN
POP2
INC GTHk ,&ver JCN
POP2
POP2r
RTN
@print-hex ( value -- )
STHk #04 SFT ,&parse JSR .Console/write DEO
STHr #0f AND ,&parse JSR .Console/write DEO
RTN
&parse ( value -- char )
DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN
RTN
@mouse-icn
ffff ffff ffff ffff 0000 0000 0000 0000
@spritesheet
1111 11f1 1111 111f eeee ee0e eeee eee0
f5bb 55bb 51b1 51ff 0a44 aa44 ae4e ae00
55bb 55bb 1111 1111 aa44 aa44 eeee eeee
ff11 11f1 1111 111f 00ee ee0e eeee eee0
1111 1111 1111 1111 eeee eeee eeee eeee
ff80 8080 80ff 8080 00ff ffff ffff ffff
ff01 0101 01ff 0101 00fe fefe fefe fefe
ffff 11ff 0ffd 71ff 00ee ee00 fa02 ee00
ffff 11ff cffd f9ff 00ee ee00 7a02 6600
ff8c 8f9f 9f8e ff00 0cff fcfe fefd ffff
ff82 820a 390a ff00 007d 7df5 c6f5 ffff
ff7d 7f6f 3d01 ff01 38fe d4fc fafe fefe
0000 0000 0007 0808 0000 0000 0007 0f0f
0000 0000 00ff 9191 0000 0000 006e 6e6e
0000 0000 00ff 1111 0000 0000 00ee eeee
0000 0000 00c0 0000 0000 0000 00c0 e0e0
1111 1111 1111 111f eeee eeee eeee eee0
51b1 51bf 51b1 51f1 ae4e ae40 ae4e ae0e
bb55 3b15 111f 1111 44aa c4ea eee0 eeee
bf55 bb55 1111 1111 40aa 44aa eeee eeee
51b1 51b1 51b1 51f1 ae4e ae4e ae4e ae0e
dfba afbf bfbf 9f80 a0c5 d5d5 d5c0 ffff
f5fd cdfd 8dfd f901 0a06 7606 7606 fefe
ffff 11ff f785 87ff 00ee ee00 7a7a 7800
ffff 11ff cffd fdff 00ee ee00 7a02 6200
381f 0520 2038 7000 0020 3a38 3800 7c00
00ff 0000 0000 0000 0000 ff00 0000 0000
1cec 2010 101c 3800 0010 dc1c 1c00 3e00
0808 0000 0000 0000 0f0f 0700 0000 0000
ff91 9100 0000 0000 6e6e 6e00 0000 0000
ff11 1100 0000 0000 eeee ee00 0000 0000
8000 0000 0000 0000 e0e0 c000 0000 0000
1111 11f1 1111 11ff eeee ee0e eeee ee00
51b1 51b1 1111 1111 ae4e ae4e eeee eeee
aa55 ab95 8181 817f 55aa d4ea fefe fe80
ffab 55ab 51a1 51ff 0054 aa54 ae5e ae00
d5ab d5ab d1a1 d1ff 2a54 2a54 2e5e 2e00
ffbe aaaa bf9f 80bf 80d5 d5d5 c0ff ffc0
fdfd 6d2d fdf9 01f9 0216 96d6 06fe fe06
ffff 817e ffff ffff 007e ff81 0000 0000
ffff 91ff cffd f9ff 006e 6e00 7a02 6600
0000 1c04 1830 303a 0a0e 1f0e 1e2e 2e55
2838 3878 004c 4c00 283a 297d 3e7a 32ff
1070 7878 0123 1200 1172 5375 1c3c 0c7e
080e 1e1e 98c4 4800 884e caae 203c 307e
80e0 8080 80e7 8888 e000 e0e0 e007 efef
0000 0000 00c7 0808 0000 0000 00c7 efef
080e 0808 08ce 0808 0e00 0e0e 0ec0 eeee
55ab 55ab 51a1 51ff aa54 aa54 ae5e ae00
ab55 ab55 8181 817f 54aa 54aa fefe fe80
ab55 ab55 8181 817f 54aa 54aa fefe fe80
bf7f bf77 9f81 817f 5cbe 6abe fcfe fe80
ab55 ab95 8181 817f 54aa d4ea fefe fe80
ffc0 8083 80c0 ffff ffff ffff ffff ff00
ff00 80ff 8000 ffff ffff ffff ffff ff00
ff07 03c3 0307 ffff fefe fefe fefe fe00
ffff 91ff f785 ffd9 006e 6e00 7a7a 006e
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
080e 0808 080e 0808 0e00 0e0e 0e00 0e0e
80e0 8080 80e0 8080 e000 e0e0 e000 e0e0
ee88 88ee 8890 8000 00ee ee00 eefe fe7c
0000 0000 0000 0000 0000 0000 0000 0000
5ea1 51a1 51a1 51ae af5e ae5e ae5e ae5f
7e81 8181 8181 817f fffe fefe fefe fe80
7e81 41a1 51a1 51ff ff7e be5e ae5e ae00
7e81 8185 8783 817f fffe fefa fcfe fefe
7e81 8185 8783 817f fffe fefa fcfe fe80
eaea eaea ffea ffaa 5555 5555 00ff 0055
aaaa aaaa ff00 ffaa 5555 5555 00ff 0055
afaf afaf ff17 ffab 5454 5454 00fe 0054
ffff 11ff cffd c5ff 00ee ee00 7a02 7a00
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0e0e 040a 040e 0808 0000 0a04 0a00 0e0e
e0e0 40a0 40e0 8080 0000 a040 a000 e0e0
80e0 8080 e09f 9191 e000 e0e0 00ee ee6e
080e 0808 0ef0 1012 0e00 0e0e 00ee eeec
5ea1 51a1 51a1 51fe af5e ae5e ae5e ae01
7f80 8080 8080 807f ffff ffff ffff ffff
7e8d 8f9f f1e1 817f f7f6 f0ee 1efe fe80
5ea1 51a1 51a1 51ff af5e ae5e ae5e ae00
7e81 41a1 51a9 51fe ff7e be5e ae56 ae07
ffff 18ff 7873 7474 00e7 e700 c7cc cbcb
ffff 14ff 00ff 0000 00eb eb00 ff00 ffff
ffff 18ff 1ece 2e2e 00e7 e700 e333 d3d3
ffff 11ff ff85 ffd9 00ee ee00 7a7a 006e
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
ff91 91e0 8080 e080 6eee ee00 e0e0 00e0
fe10 100e 0808 0e08 ecee ee00 0e0e 000e
0000 0000 0000 55aa 0000 0000 0000 aa55
552a ff80 efff 80ff aad5 00ff ff00 ffff
55aa ff00 ffff 00ff aa55 00ff ff00 ffff
55ab ff01 dfff 01ff aa54 00fe fe00 fefe
ffff d700 00ff ffff 0000 ffff ff00 7ce2
7474 7474 7000 00ff cbcb cbcb cfff ff00
0000 0000 0000 00ff ffff ffff ffff ff00
2e2e 2e2e 2e0e 0cff d3d3 d3d3 d3f3 f300
ffff 817e ffff fbeb 007e ff81 0004 1414
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
00ff 4444 00ff 4444 00bb bbbb 00bb bbbb
00fc 4848 00fc 4848 00b4 b6b6 02b6 b6b4
ff01 1fff 011f ff01 00fe fe00 fefe 00fe
ff80 ffff 80ff ffff 00ff ff00 ffff 0000
ff00 afff 00fd ffff 00ff ff00 ffff 0000
ff01 ffff 01ff ffff 00fe fe00 fefe 0000
ffff ffff ffff ffff 3e2e ab3d efff d8f7
ffa0 ffa8 58ff a8ff 005f 0057 a700 5700
ff81 ff09 09ff 81ff 007e 00f6 f600 7e00
ff57 5617 270c 0cff 00a9 a9e8 d9f3 f300
ffff b9ef e9ef ffe7 0046 5610 5610 3c18
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
007f 8484 e080 8080 007b fbfb 00e0 e0e0
00ff 4444 0003 0404 00bb bbbb 0003 0707
0000 0000 0000 0000 0000 0000 0000 0000
1fff 011f ff01 1dff fe00 fefe 00fe fe00
5ea3 55ab 55ab 55ff af5c aa54 aa54 aa00
7e81 55ab 55ab 55ff fffe aa54 aa54 aa00
0101 ffff ffff ffff fefe 00ff c7b9 ff67
81c1 ffff ffff ffff 7e3e 00ff 1de7 fff9
ffff 8080 8080 ff55 00ff ffff ffff 00aa
fffe 0101 0101 ff55 00ff fefe fefe 00aa
3f18 181f 4e4e 26ff c7e7 e7e0 b3b1 d900
efef adef efed fdff 185a 5a18 5a1a 5200
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
0000 0000 0000 0000 8080 00e0 8000 8101
0000 0000 0000 0000 0000 0606 3636 b6b6
1e01 0181 8181 817f fffe fefe fefe fe80
ffff ffff ffff ffff ffff ae71 ffff c7fb
ffff ffff ffff ffff fefe fe1c eefe c2be
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
ffff 817e ffff ffff 007e ff81 0008 347e
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
817e ff00 ff18 0081 7eff ffff 00e7 ffff
fe81 c1a1 c1a1 c1ff 7f7e 3e5e 3e5e 3e00
aa55 ab55 01c3 7d01 55aa 54aa febe 82fe
0101 ffff ffff ffff fefe 00fe 78a6 fefa
55ab f51b 11e1 817f aa54 eae4 ee1e fe80
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
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
ff55 ab81 8181 817f 00aa d4fe fefe fe80
be41 a181 8181 817f 5fbe 5efe fefe fe80
7d7d 017d 7d01 7dff 8282 fe82 82fe 8200
7d7d 017d 7d01 7d7d 8282 fe82 82fe 8282
d5ab 5db0 908f 837f 2a54 af4f eff0 fc80
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
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
ff88 ce96 f4f0 f695 fff8 def7 fdf1 f7b5
ff0e a634 8270 32c1 ff4f ffff 9ff9 fff7
898d 38fd 4f53 44d1 9fff fdff 7fff dffd
017d 7d01 7d7d 017d fe82 82fe 8282 fe82
ffff ffff ffff ffff ffaa ff55 ffaa 55aa
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
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
8d85 90b8 f2b7 848d bfc7 91f8 f6ff 9fef
ffff ffff ffff ffff 5fbf 5fa7 59bf 47b8
ffff ffff ffff ffff 55aa 55ff fff9 cfff
ffff ffff ffff ffff 55aa 55bf 53bc 5fbf
ffff ffff ffff ffff feaa fe54 feaa 54aa
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
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
ffff ffff ffff ffff 5faa 5fb5 5faa 55aa
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
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
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
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
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
42ff 7d41 82fa 6100 7cfc 027e fcfc 7e00
@sewers
0c0d 0ea2 0e0e 0f00 0000 0000 0000 0000
3c07 58b3 3858 3d00 0000 0000 0000 0000
3c17 18c3 3828 3d00 0000 0000 0000 0000
3c30 3132 3231 4e0e 0e0e 0e0e 0e0e 0f00
3c50 8483 a344 2858 1858 6838 6828 3d00
1c1d 1e5f 9441 0718 2718 5818 1858 3d00
0000 003c 9441 22b4 64a4 3232 3232 3d00
0000 003c 93a3 4183 9383 8383 8341 3d00
0000 001c 5f94 5294 7d7e 6e6e 6f41 3d00
000c 0e0e 4f94 4194 3d3c 5858 1841 3d00
003c 1758 1894 4194 3d3c 1818 1850 3d00
003c 1898 1894 4194 3d3c a024 33b1 3d00
003c d374 d294 4494 3d3c 23b1 4144 3d00
003c d193 9394 4194 3d3c 5052 4141 3d00
004c e0c4 c4d4 82d4 4d1c 1d1e 1e1e 1f00
00bc 0000 0000 00ca 0000 0000 0000 0000
&colors
8080 8080 8080 8000 0000 0000 0000 0000
8080 8080 8080 8000 0000 0000 0000 0000
8080 8080 8080 8000 0000 0000 0000 0000
8080 8080 8080 8080 8080 8080 8080 8000
8080 8080 8080 8080 8080 8080 8080 8000
8080 8080 8080 8080 8080 8080 8080 8000
0000 0080 8080 8080 8080 8080 8080 8000
0000 0080 8080 8080 8080 8080 8080 8000
0000 0080 8080 80a0 8080 8080 8080 8000
0080 8080 8080 80a0 8080 8080 8080 8000
0080 8080 8080 80a0 8080 8080 8080 8000
0080 8080 8080 80a0 8080 8080 8080 8000
0080 8080 8080 80a0 8080 8080 8080 8000
0080 8080 8080 80a0 8080 8080 8080 8000
00a0 8080 8080 8080 a080 8080 8080 8000
00a0 0000 0000 0080 0000 0000 0000 0000
@crypt
0000 0c0d 0e0e 0f00 0000 0000 0000 0000
0c0d 4f55 5657 4e0e 0f00 0000 0000 0000
3c55 5765 6667 5557 3d00 0000 0000 0000
3c65 6732 3232 6567 3d00 0000 0000 0000
3c30 3235 3637 3233 3d00 0000 0000 0000
3c40 4345 4647 5451 3d00 0000 0000 0000
3c75 7661 6263 7576 3d4c 604d 0000 0000
3c30 3171 7273 3232 3d3c 703d 0000 0000
3c50 4441 4141 4141 4e4f 803d 0000 0000
3c50 ff41 4152 4141 9091 923d 0000 0000
3c50 4141 4141 4141 5e1e 1e1f 0000 0000
3c50 5241 4141 4441 3d00 0000 0000 0000
1c1d 1e5f 415e 1e1e 1f00 0000 0000 0000
0000 004c 824d 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
&colors
0000 8080 8080 8000 0000 0000 0000 0000
8080 8080 8080 8080 8000 0000 0000 0000
8080 8080 8080 8080 8000 0000 0000 0000
8080 8080 8080 8080 8000 0000 0000 0000
8080 8080 8080 8080 8000 0000 0000 0000
8080 8080 8080 8080 8000 0000 0000 0000
8080 8080 8080 8080 8080 8080 0000 0000
8080 8080 8080 8080 8080 8080 0000 0000
8080 8080 8080 8080 8080 8080 0000 0000
8080 8080 8080 8080 8080 8080 0000 0000
8080 8080 8080 8080 8080 8080 0000 0000
8080 8080 8080 8080 8000 0000 0000 0000
8080 8080 8080 8080 8000 0000 0000 0000
0000 00a0 80a0 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
@entrance
0c0d 0e0e 0e0e 0e0e 0f0c 0d0e 0e0f 0000
3c07 0727 2807 0506 3d3c 1717 173d 0000
3c17 287b 0728 1516 4e4f 1717 173d 0000
3c30 3131 3131 2526 1717 31a2 313d 0000
3c50 a0a1 4141 3432 1717 41b2 443d 0000
3c50 b0b1 5241 4144 3431 4141 413d 0000
3c50 4141 4141 4141 4141 5241 413d 0000
1c1d 1e1e 5f41 5e1e 1e1e 1e1e 1e1f 0000
0000 0000 4c81 4d00 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 9d00 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
&colors
8080 8080 8080 8080 8080 8080 8080 0000
8080 8080 8080 8080 8080 8080 8080 0000
8080 8081 8080 8080 8080 8080 8080 0000
8080 8080 8080 8080 8080 8080 8080 0000
8080 8080 8080 8080 8080 8080 8080 0000
8080 8080 8080 8080 8080 8080 8080 0000
8080 8080 8080 8080 8080 8080 8080 0000
8080 8080 8080 8080 8080 8080 8080 0000
0000 0000 a080 a000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 8000 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
@upper
007b 7b7b 7b7b 7b7b 7b0c 0e0e 0e0e 0f7b
cfcf cfcf cfcf cfcf 7b3c 7758 7858 3d00
0c0d 0e2e 0d0e 0e0e 0e2f 8707 8808 3d00
3c05 063e 3868 3807 283e 0102 0202 3d00
3c15 1628 090a 0b17 2828 1100 0010 3d00
3c25 2628 191a 1b01 a028 1100 0020 3d00
3c01 1313 1213 1321 1312 2100 5e1e 1f00
3c14 c0c1 c1c1 c000 1010 1004 3dcf 7e00
3c14 d0c2 c2c2 d010 1000 1041 3d00 0000
3c11 c0c1 c1c1 c004 1010 0419 3d00 0000
3c11 0404 0400 1004 0004 0412 3d00 0000
3c85 8685 865e 5f70 5e5f 8586 3d00 0000
1c1d 1e1e 1e1f 3c80 3d1c 1d1e 1f00 0000
8e8e 8e8e 8e8e 4c60 4d00 0000 0000 0000
0000 0000 00ef efef 0000 0000 0000 0000
&colors
0000 0000 0000 0000 0000 0000 0000 0000
0080 8080 8080 8080 8080 8080 8080 8080
8080 8080 8080 8080 8080 8080 8080 8000
8080 8080 8080 8080 8080 8080 8080 8000
8080 8080 8080 8080 8080 8080 8080 8000
8080 8080 8080 8080 8080 8080 8080 8000
8080 8080 8080 8080 8080 8080 8080 8000
8080 8080 8080 8080 8080 8080 8080 8000
8080 8080 8080 9080 8080 8080 8080 8000
8080 80a0 80a0 9080 8080 8080 8000 0000
8080 a0a0 a0a0 b080 8080 8080 8000 0000
8080 8080 8080 8080 8080 8080 8000 0000
8080 8080 8080 8080 8080 8080 8000 0000
8080 8080 8080 8080 8080 8080 8000 0000
8080 8080 8080 a0b0 a000 0000 0000 0000
0000 0000 0080 8080 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000

View file

@ -1,61 +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
|000
@dvd &x $2 &y $2
|100
@on-reset ( -> )
( | theme )
#4cfd .System/r DEO2
#4cf3 .System/g DEO2
#dcf2 .System/b DEO2
( | vectors )
;on-frame .Screen/vector DEO2
( | starting position )
.Screen/width DEI2 DUP2 #01 SFT2 .dvd/x STZ2
#0020 SUB2 ;on-frame/hit-hor STA2
.Screen/height DEI2 DUP2 #01 SFT2 .dvd/y STZ2
#0010 SUB2 ;on-frame/hit-ver STA2
( | drawing mode )
[ LIT2 36 -Screen/auto ] DEO
#01 <draw-dvd>
BRK
@on-frame ( -> )
#00 <draw-dvd>
( | x )
.dvd/x LDZ2
( left ) ORAk ?{
[ LIT2 ADD2 _&x ] STR }
( right ) DUP2 [ LIT2 &hit-hor $2 ] NEQ2 ?{
[ LIT2 SUB2 _&x ] STR }
#0001 [ &x ADD2 ] .dvd/x STZ2
( | y )
.dvd/y LDZ2
( top ) ORAk ?{
[ LIT2 ADD2 _&y ] STR }
( bottom ) DUP2 [ LIT2 &hit-ver $2 ] NEQ2 ?{
[ LIT2 SUB2 _&y ] STR }
#0001 [ &y ADD2 ] .dvd/y STZ2
#01 <draw-dvd>
BRK
@<draw-dvd> ( color -- )
;dvd-icn .Screen/addr DEO2
.dvd/x LDZ2 .Screen/x DEO2
.dvd/y LDZ2 .Screen/y DEO2
.Screen/sprite DEOk DEO
JMP2r
@dvd-icn ( 4 x 2 )
[
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 ]

View file

@ -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

View file

@ -1,221 +1,356 @@
( 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. )
( Game Of Life
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
%+ { ADD } %- { SUB }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
@world &count $2
@anchor &x $2 &y $2 &x2 $2 &y2 $2
%2/ { #01 SFT }
%8/ { #03 SFT }
%2// { #01 SFT2 } %8// { #03 SFT2 }
%2** { #10 SFT2 } %8** { #30 SFT2 }
%40** { #60 SFT2 }
%8MOD { #07 AND } %2MOD { #01 AND }
|100
%TOS { #00 SWP }
%RTN { JMP2r }
%SFL { #40 SFT SFT }
@on-reset ( -> )
( | theme )
%WIDTH { #40 } %HEIGHT { #40 }
%WIDTH-MOD { #3f AND } %HEIGHT-MOD { #3f AND }
%IN-RANGE { INCk SWP SUB2 GTH }
%BANK1 { #8000 } %BANK2 { #a000 }
%GET-SIZE { WIDTH TOS 8// 40** }
%GET-ITERATORS { SWP2k POP NIP }
%GET-ITER { OVR2 NIP OVR SWP }
( devices )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
|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 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
( variables )
|0000
@world [ &frame $1 &count $2 ]
@anchor [ &x $2 &y $2 ]
@pointer [ &x $2 &y $2 ]
@rle [ &x $1 &y $1 &n $1 ]
( program )
|0100 ( -> )
( theme )
#02cf .System/r DEO2
#02ff .System/g DEO2
#024f .System/b DEO2
( | resize )
#00c0 DUP2 .Screen/width DEO2
.Screen/height DEO2
( | vectors )
( vectors )
;on-input .Console/vector DEO2
;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
( glider )
#07 #03 ;set-cell JSR2
#07 #04 ;set-cell JSR2
#05 #04 ;set-cell JSR2
#07 #05 ;set-cell JSR2
#06 #05 ;set-cell JSR2
.Screen/width DEI2 2// WIDTH TOS -- .anchor/x STZ2
.Screen/height DEI2 2// HEIGHT TOS -- .anchor/y STZ2
BRK
@on-frame-paused ( -> )
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
.Mouse/state DEI #00 = #01 JCN [ BRK ]
( incr frame ) .world/frame LDZ INC [ DUP ] .world/frame STZ
( reset count ) #0000 .world/count STZ2
#03 AND #00 = #01 JCN [ BRK ]
( clear buffer )
BANK2 STH2k GET-SIZE ++ STH2r
&clear-loop
DUP2 #0000 SWP2 STA2
INC2 INC2 GTH2k ,&clear-loop JCN
POP2 POP2
( run grid )
#00 HEIGHT
&ver
#00 WIDTH
&hor
GET-ITERATORS
( x y ) DUP2
( neighbours ) DUP2 ;get-neighbours JSR2
( state ) ROT ROT ;get-cell JSR2
,run-cell JSR
SWP INC SWP
LTHk ,&hor JCN
POP2
SWP INC SWP
LTHk ,&ver JCN
POP2
( move buffer )
BANK2 DUP2 GET-SIZE ++ SWP2
&copy-loop
DUP2 LDA2k
SWP2 #2000 -- STA2
INC2 INC2 GTH2k ,&copy-loop JCN
POP2 POP2
;draw-grid JSR2
BRK
@run-cell ( x y neighbours state -- )
#00 = ,&dead JCN
&alive
DUP #02 < ,&dies JCN
DUP #03 > ,&dies JCN
&lives POP ,save-cell JSR RTN
&dies POP POP2 RTN
&dead
DUP #03 = ,&birth JCN POP POP2 RTN
&birth POP ,save-cell JSR RTN
RTN
@save-cell ( x y -- )
( get index )
HEIGHT-MOD SWP WIDTH-MOD SWP
TOS 8** ROT 8/ TOS ++ [ BANK2 ++ ]
( incr count )
.world/count LDZ2 INC2 .world/count STZ2
( save in buffer )
STH2
DUP2 POP 8MOD #01 SWP SFL
LDAkr STHr SWP ORA
STH2r STA
RTN
@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
( 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 ! ] + .Screen/sprite DEO
.Mouse/state DEI #00 ! #01 JCN [ BRK ]
.Mouse/x DEI2 DUP2 .anchor/x LDZ2 >> ROT ROT .anchor/x LDZ2 WIDTH DUP ADD TOS ++ INC2 << #0101 ==
.Mouse/y DEI2 DUP2 .anchor/y LDZ2 >> ROT ROT .anchor/y LDZ2 HEIGHT DUP ADD TOS ++ << #0101 ==
#0101 == #01 JCN [ BRK ]
.Mouse/x DEI2 .anchor/x LDZ2 SUB2 2/ NIP
.Mouse/y DEI2 .anchor/y LDZ2 SUB2 2/ NIP
;set-cell JSR2
;draw-grid JSR2
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 )
.Controller/key DEI #00 ! #01 JCN [ BRK ]
@<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
.Controller/key DEI #20 ! ,&no-toggle JCN
;on-frame
.Screen/vector DEI2 ;on-frame-paused == ,&swap JCN
POP2 ;on-frame-paused
&swap
.Screen/vector DEO2
&no-toggle
BRK
@draw-grid ( -- )
( draw cell count )
.anchor/x LDZ2 .Screen/x DEO2
.anchor/y LDZ2 HEIGHT DUP ADD TOS ++ .Screen/y DEO2
.world/count LDZ2 #03 ;draw-short JSR2
HEIGHT #00
&ver
DUP TOS 2** .anchor/y LDZ2 ++ .Screen/y DEO2
WIDTH #00
&hor
DUP TOS 2** .anchor/x LDZ2 ++ .Screen/x DEO2
GET-ITER ,get-cell JSR INC .Screen/pixel DEO
INC GTHk ,&hor JCN
POP2
INC GTHk ,&ver JCN
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
RTN
@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
HEIGHT-MOD SWP WIDTH-MOD SWP
TOS 8** ROT 8/ TOS ++ [ BANK1 ++ ]
RTN
@set-cell ( x y -- )
DUP2 ,get-index JSR STH2
POP 8MOD #01 SWP SFL
LDAkr STHr SWP ORA
STH2r STA
RTN
@unset-cell ( x y -- )
DUP2 ,get-index JSR STH2
POP 8MOD #01 SWP SFL #ff EOR
LDAkr STHr SWP AND
STH2r STA
RTN
@get-cell ( x y -- cell )
DUP2 ,get-index JSR LDA
NIP SWP
8MOD
SFT 2MOD
RTN
@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
( -1,-1 ) DUP2 #01 - [ SWP #01 - SWP ] ,get-cell JSR STH
( 0,-1 ) DUP2 #01 - ,get-cell JSR STH ADDr
( +1,-1 ) DUP2 #01 - [ SWP INC SWP ] ,get-cell JSR STH ADDr
( -1, 0 ) DUP2 [ SWP #01 - SWP ] ,get-cell JSR STH ADDr
( +1, 0 ) DUP2 [ SWP INC SWP ] ,get-cell JSR STH ADDr
( -1,+1 ) DUP2 INC [ SWP #01 - SWP ] ,get-cell JSR STH ADDr
( 0,+1 ) DUP2 INC ,get-cell JSR STH ADDr
( +1,+1 ) INC [ SWP INC SWP ] ,get-cell JSR STH ADDr
STHr
(
@|drawing )
RTN
@<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* color -- )
@<draw-short> ( short* -- )
SWP <draw-byte>
( >> )
STH SWP
DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2
( draw ) STHkr .Screen/sprite DEO
#0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
#0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHr .Screen/sprite DEO
@<draw-byte> ( byte color -- )
DUP #04 SFT <draw-hex>
#0f AND
( >> )
RTN
@<draw-hex> ( char color -- )
#00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
[ LIT2 03 -Screen/sprite ] DEO
@on-input ( -> )
,&main JSR
BRK
&main
.Console/read DEI #20 GTH JMP JMP2r ( ignore whitespace )
.Console/read DEI LIT 'b EQU ,unset-run JCN
.Console/read DEI LIT 'o EQU ,set-run JCN
.Console/read DEI LIT '$ EQU ,input-eol JCN
.Console/read DEI LIT '! EQU ,input-eop JCN
LIT2 '0 '9 .Console/read DEI IN-RANGE ,input-number JCN
;on-ignore-until-eol .Console/vector DEO2
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
( >> )
@unset-run ( -- )
;unset-cell ,run JMP ( tail call )
@<draw-cursor> ( color -- )
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEO
@set-run ( -- )
;set-cell ( fall through )
@run ( cell-fn* -- )
STH2
;on-frame-paused .Screen/vector DEO2
.rle/n LDZk #00 ROT STZ
DUP #00 NEQ JMP INC
&loop ( count / cell-fn* )
DUP #00 EQU ,&end JCN
.rle/x LDZ .rle/y LDZ STH2kr JSR2
.rle/x LDZk INC SWP STZ
#01 SUB
,&loop JMP
&end
POP POP2r
JMP2r
(
@|assets )
@input-number ( -- )
.rle/n LDZk #0a MUL
.Console/read DEI LIT '0 SUB
ADD SWP STZ
JMP2r
@MMU ( programs )
&clear1 [ 01 1000 0000 =bank3 0000 =bank1 ]
&clear2 [ 01 1000 0000 =bank3 0000 =bank2 ]
&move21 [ 01 1000 0000 =bank2 0000 =bank1 ]
@input-eol ( -- )
WIDTH .rle/x LDZ SUB .rle/n STZ
,unset-run JSR
#00 .rle/x STZ
.rle/y LDZk INC SWP STZ
JMP2r
@cursor-icn [ 80c0 e0f0 f8e0 1000 ]
@input-eop ( -- )
,input-eol JSR
HEIGHT .rle/y LDZ GTH ,input-eop JCN
;on-frame .Screen/vector DEO2
#00 .rle/y STZ
BRK
@fill-icn [ ffff ffff ffff ffff ]
@on-ignore-until-eol ( -> )
.Console/read DEI #0a EQU JMP BRK
;on-input .Console/vector DEO2
BRK
@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
@cursor
80c0 e0f0 f8e0 1000
@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

View file

@ -1,4 +1,31 @@
( bitwise )
( a blank file )
%+ { ADD } %- { SUB } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%2* { #10 SFT } %2/ { #01 SFT }
%4* { #20 SFT } %4/ { #02 SFT }
%8* { #30 SFT } %8/ { #03 SFT }
%10* { #40 SFT } %10/ { #04 SFT }
%20* { #50 SFT } %20/ { #05 SFT }
%2** { #10 SFT2 } %2// { #01 SFT2 }
%4** { #20 SFT2 } %4// { #02 SFT2 }
%8** { #30 SFT2 } %8// { #03 SFT2 }
%10** { #40 SFT2 } %10// { #04 SFT2 }
%20** { #50 SFT2 } %20// { #05 SFT2 }
%RELEASE-MOUSE { #0096 DEO }
%AUTO-X { #01 .Screen/auto DEO }
%AUTO-X-ADDR { #05 .Screen/auto DEO }
%AUTO-NONE { #00 .Screen/auto DEO }
%RTN { JMP2r }
%TOS { #00 SWP }
( devices )
|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 ]
@ -10,7 +37,7 @@
|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 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables )
@ -36,13 +63,13 @@
;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/width DEI2 2//
DUP2 #0040 -- .a-frame/x STZ2 DUP2 #0040 ++ .a-frame/x2 STZ2
DUP2 #0040 -- .b-frame/x STZ2 #0040 ++ .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
.Screen/height DEI2 2// #0020 --
DUP2 #0010 -- .a-frame/y STZ2 DUP2 #0000 ++ .a-frame/y2 STZ2
DUP2 .b-frame/y STZ2 #0010 ++ .b-frame/y2 STZ2
;redraw JSR2
@ -52,7 +79,7 @@ BRK
;draw-cursor JSR2
.Mouse/state DEI #00 NEQ JMP [ BRK ]
.Mouse/state DEI #00 ! JMP [ BRK ]
.Mouse/x DEI2 .Mouse/y DEI2 .a-frame ;within-rect JSR2
;on-touch-a JCN2
@ -63,29 +90,29 @@ BRK
@on-touch-a ( -> )
.Mouse/x DEI2 .a-frame/x LDZ2 SUB2
#04 SFT2 NIP #07 SWP SUB STH
.Mouse/x DEI2 .a-frame/x LDZ2 --
10// NIP #07 SWP - STH
.input/a LDZ
#01 [ STHr #40 SFT ] SFT EOR
.input/a STZ
;redraw JSR2
#00 .Mouse/state DEO
RELEASE-MOUSE
BRK
@on-touch-b ( -> )
.Mouse/x DEI2 .b-frame/x LDZ2 SUB2
#04 SFT2 NIP #07 SWP SUB STH
.Mouse/x DEI2 .b-frame/x LDZ2 --
10// NIP #07 SWP - STH
.input/b LDZ
#01 [ STHr #40 SFT ] SFT EOR
.input/b STZ
;redraw JSR2
#00 .Mouse/state DEO
RELEASE-MOUSE
BRK
@ -100,82 +127,82 @@ BRK
.input/b LDZ #01 ;draw-byte JSR2
.b-frame/x LDZ2 .Screen/x DEO2
.Screen/y DEI2 #000d ADD2 .Screen/y DEO2
.Screen/y DEI2 #000d ++ .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
.Screen/y DEI2 #000d ++ .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
.Screen/y DEI2 #000d ++ .Screen/y DEO2
.input LDZ2 EOR #03 ;draw-byte JSR2
( labels )
#05 .Screen/auto DEO
.b-frame/x LDZ2 #0020 SUB2 .Screen/x DEO2
AUTO-X-ADDR
.b-frame/x LDZ2 #0020 -- .Screen/x DEO2
;names-icn/and .Screen/addr DEO2
.b-frame/y2 LDZ2 #0004 ADD2 .Screen/y DEO2
.b-frame/y2 LDZ2 #0004 ++ .Screen/y DEO2
,&draw-label JSR
.b-frame/y2 LDZ2 #0014 ADD2 .Screen/y DEO2
.b-frame/y2 LDZ2 #0014 ++ .Screen/y DEO2
,&draw-label JSR
.b-frame/y2 LDZ2 #0024 ADD2 .Screen/y DEO2
.b-frame/y2 LDZ2 #0024 ++ .Screen/y DEO2
,&draw-label JSR
#00 .Screen/auto DEO
AUTO-NONE
JMP2r
RTN
&draw-label
.b-frame/x LDZ2 #0020 SUB2 .Screen/x DEO2
.b-frame/x LDZ2 #0020 -- .Screen/x DEO2
#03 .Screen/sprite DEOk DEOk DEO
JMP2r
RTN
@draw-byte ( value -- )
STH STH
#0800
&loop
#07 OVR SUB
DUP #07 SWP -
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
.Screen/y DEI2 #0003 ++ .Screen/y DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
STHr ;draw-hex JSR2
POPr
JMP2r
RTN
@draw-bit ( value color -- )
STH STH
#05 .Screen/auto DEO
;button-icns/off [ #00 STHkr #50 SFT ADD2 ] .Screen/addr DEO2
AUTO-X-ADDR
;button-icns/off [ #00 STHkr 20* ++ ] .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
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
.Screen/x DEI2 #0010 -- .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
AUTO-NONE
.Screen/y DEI2 #0008 -- .Screen/y DEO2
POP2r
POPr POPr
JMP2r
RTN
@draw-hex ( value -- )
#01 .Screen/auto DEO
AUTO-X
DUP #04 SFT ,&draw JSR
#0f AND ,&draw JSR
#01 .Screen/auto DEO
AUTO-X
JMP2r
RTN
&draw
#00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
TOS 8** ;font-hex ++ .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
JMP2r
RTN
@draw-cursor ( -- )
@ -188,26 +215,26 @@ JMP2r
.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
#42 [ .Mouse/state DEI #00 ! ] + .Screen/sprite DEO
JMP2r
RTN
@within-rect ( x* y* rect -- flag )
STH
( y < rect.y1 ) DUP2 STHkr INC INC LDZ2 LTH2 ,&skip JCN
( y < rect.y1 ) DUP2 STHkr #02 ADD 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
RTN
&skip
POP2 POP2 POPr
#00
JMP2r
RTN
@cursor
80c0 e0f0 f8e0 1000

View file

@ -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

View file

@ -1,63 +1,89 @@
( Move: Use controller arrows, leave a slime. )
( dev/controller/buttons )
|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
%++ { INC2 }
%-- { #0001 SUB2 }
%2// { #01 SFT2 }
@hello &x $2 &y $2
( devices )
|100
|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 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
@on-reset ( -> )
( | theme )
#c0f4 .System/r DEO2
#c0fc .System/g DEO2
#c0f7 .System/b DEO2
( | vectors )
( variables )
|0000
@slime $1
( init )
|0100 ( -> )
( theme )
#0daf .System/r DEO2
#02ff .System/g DEO2
#035f .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
( set origin )
.Screen/width DEI2 2// .Screen/x DEO2
.Screen/height DEI2 2// .Screen/y DEO2
;default_icn .Screen/addr DEO2
#41 .Screen/sprite DEO
#0a .slime STZ
BRK
@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
#0a .slime STZ
;default_icn .Screen/addr DEO2
@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 ]
( hold ctrl key to change slime color )
.Controller/button DEI #0f AND
DUP #01 NEQ ,&no-ctrl JCN #05 .slime STZ &no-ctrl
DUP #02 NEQ ,&no-alt JCN #0f .slime STZ &no-alt
POP
@slime-icn [
0000 0000 0003 0707 0000 0000 00c0 e0e0
0707 0300 0000 0000 e0e0 c000 0000 0000 ]
( clear ) #40 .Screen/sprite DEO
( detect movement )
.Controller/button DEI #f0 AND
DUP #04 SFT #01 AND #01 NEQ ,&no-up JCN
( move )
.Screen/y DEI2 -- .Screen/y DEO2
;up_icn .Screen/addr DEO2 &no-up
DUP #05 SFT #01 AND #01 NEQ ,&no-down JCN
( move )
.Screen/y DEI2 ++ .Screen/y DEO2
;down_icn .Screen/addr DEO2 &no-down
DUP #06 SFT #01 AND #01 NEQ ,&no-left JCN
( move )
.Screen/x DEI2 -- .Screen/x DEO2
;left_icn .Screen/addr DEO2 &no-left
DUP #07 SFT #01 AND #01 NEQ ,&no-right JCN
( move )
.Screen/x DEI2 ++ .Screen/x DEO2
;right_icn .Screen/addr DEO2 &no-right
POP
( draw face )
#41 .Screen/sprite DEO
( draw slime )
;slime_icn .Screen/addr DEO2
.slime LDZ .Screen/sprite DEO
BRK
@default_icn [ 3c7e ffdb ffe7 7e3c ]
@up_icn [ 2466 e7db ffff 7e3c ]
@down_icn [ 3c7e ffff dbe7 6624 ]
@left_icn [ 3c7e ef1f 1fef 7e3c ]
@right_icn [ 3c7e f7f8 f8f7 7e3c ]
@slime_icn [ 0000 183c 3c18 0000 ]

View file

@ -0,0 +1,232 @@
(
uxnasm projects/examples/demos/nametable.tal bin/nametable.rom
uxnemu bin/nametable.rom
)
%+ { ADD } %- { SUB } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%2** { #10 SFT2 } %2// { #01 SFT2 }
%8** { #30 SFT2 } %8// { #03 SFT2 }
%10** { #40 SFT2 } %10// { #04 SFT2 }
%MOD2 { DIV2k MUL2 SUB2 }
%MOD { DIVk MUL SUB }
%RTN { JMP2r }
%WIDTH { #0037 }
%HEIGHT { #0029 } ( 08cf )
%LENGTH { WIDTH HEIGHT MUL2 10** }
( devices )
|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 ]
|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 ]
( variables )
|0000
( program )
@tiles-frame
&x $2 &y $2
@nametable-frame
&x $2 &y $2
@buffer $10
|0100 ( -> )
( theme )
#34cd .System/r DEO2
#28ac .System/g DEO2
#297b .System/b DEO2
WIDTH 8** #0010 ++ .Screen/width DEO2
#01e8 .Screen/height DEO2
#0008 .tiles-frame/x STZ2
HEIGHT 8** #0008 ++ .tiles-frame/y STZ2
#0008 .nametable-frame/x STZ2
#0008 .nametable-frame/y STZ2
;input-name
DUP2 ,load JSR
;assoc JSR2
;draw-tiles JSR2
;draw-nametable JSR2
;draw-short JSR2
BRK
@load ( filename* -- )
LIT2r 0000
.File/name DEO2
&stream
#0010 .File/length DEO2
;buffer
DUP2 .File/read DEO2
,find-tile JSR #ffff !! ,&skip JCN
;buffer ;add-tile JSR2
&skip
INC2r
.File/success DEI2 #0000 !! ,&stream JCN
STH2r #0001 -- ;result/tiles STA2
RTN
@find-tile ( addr* -- addr* )
STH2
;result/length LDA2 #0000
&loop
DUP2 10** ;result/data ++ STH2kr ;tiles-equal JSR2 #00 = ,&continue JCN
NIP2 POP2r RTN
&continue
INC2 GTH2k ,&loop JCN
POP2 POP2 POP2r
( default ) #ffff
RTN
@tiles-equal ( a* b* -- bool )
STH2
DUP2 #0010 ++ SWP2
&loop
LDAk LDAkr STHr = ,&continue JCN
POP2 POP2 POP2r #00 RTN
&continue
INC2r
INC2 GTH2k ,&loop JCN
POP2 POP2 POP2r #01
RTN
@add-tile ( addr* -- addr* )
STH2
#0010 #0000
&loop
( addr* ) DUP2 ;result/length LDA2 10** ;result/data ++ ++
( data ) OVR2 STH2kr ++ LDA
( order ) ROT ROT STA
INC2 GTH2k ,&loop JCN
POP2 POP2
POP2r
( incr ) ;result/length LDA2 INC2 ;result/length STA2
RTN
@assoc ( -- length )
LIT2r 0000
.File/name DEO2
&stream
#0010 .File/length DEO2
;buffer
DUP2 .File/read DEO2
;find-tile JSR2 STH2kr SWP2 ;set-tile JSR2
INC2r
.File/success DEI2 #0000 !! ,&stream JCN
POP2r
RTN
( draw )
@draw-tiles ( -- )
.tiles-frame/x LDZ2 .Screen/x DEO2
.tiles-frame/y LDZ2 .Screen/y DEO2
;result/data .Screen/addr DEO2
( width ) LITr 00
( auto x addr ) #05 .Screen/auto DEO
;result/data ;result/length LDA2 10** ++ ;result/data
&loop
STHkr WIDTH NIP MOD ,&continue JCN
.tiles-frame/x LDZ2 .Screen/x DEO2
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
POPr LITr 00
&continue
INCr
#81 .Screen/sprite DEO
#0010 ++ GTH2k ,&loop JCN
POP2 POP2
( auto none ) #00 .Screen/auto DEO
POPr
RTN
@set-tile ( id* addr* -- )
SWP2 2** ;result/data ++ ;result/length LDA2 10** ++ STA2
RTN
@get-tile ( id* -- addr* )
2** ;result/length LDA2 10** ;result/data ++ ++ LDA2
RTN
@draw-nametable ( -- )
;result/tiles LDA2 #0000
&loop
DUP2 WIDTH MOD2 8** .nametable-frame/x LDZ2 ++ .Screen/x DEO2
DUP2 WIDTH DIV2 8** .nametable-frame/y LDZ2 ++ .Screen/y DEO2
DUP2 ;get-tile JSR2 10** ;result/data ++ .Screen/addr DEO2
#81 .Screen/sprite DEO
INC2 GTH2k ,&loop JCN
POP2 POP2
RTN
@draw-short ( -- )
#0008 .Screen/x DEO2
#0008 .Screen/y DEO2
#01 .Screen/auto DEO
;result/length LDA2 SWP
( high ) ,&draw-byte JSR
( low ) ,&draw-byte JSR
#05 .Screen/auto DEO
RTN
&draw-byte ( byte -- )
DUP
( high ) #04 SFT ,&draw-char JSR
( low ) #0f AND ,&draw-char JSR
RTN
&draw-char ( num -- )
#30 SFT #00 SWP ;font-hex ADD2 .Screen/addr DEO2
#01 .Screen/sprite DEO
RTN
@input-name "projects/pictures/bulma37x29.chr $1
@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
@result
&length $2
&tiles $2
&data

View file

@ -0,0 +1,619 @@
( piano )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%!~ { NEQk NIP }
%HALT { #010f DEO }
%RTN { JMP2r }
%TOS { #00 SWP }
%MOD { DUP2 / * - }
%GTS2 { #8000 ++ SWP2 #8000 ++ << }
%2/ { #01 SFT }
%2// { #01 SFT2 }
%4// { #02 SFT2 }
%8// { #03 SFT2 }
%8** { #30 SFT2 }
( devices )
|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 &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
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &modx $2 &mody $2
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
( variables )
|0000
@last-note $1
@octave $1
@pointer
&x $2 &y $2
@center
&x $2 &y $2
@adsr-view
&x1 $2 &y1 $2 &x2 $2 &y2 $2
@wave-view
&x1 $2 &y1 $2 &x2 $2 &y2 $2
@octave-view
&x1 $2 &y1 $2 &x2 $2 &y2 $2
( program )
|0100 ( -> )
( theme )
#0fe5 .System/r DEO2
#0fc5 .System/g DEO2
#0f25 .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
;on-control .Controller/vector DEO2
;on-mouse .Mouse/vector DEO2
;on-message .Console/vector DEO2
( find center )
.Screen/width DEI2 2// .center/x STZ2
.Screen/height DEI2 2// .center/y STZ2
( place octave )
.center/x LDZ2 #0080 -- .octave-view/x1 STZ2
.center/y LDZ2 #0008 ++ .octave-view/y1 STZ2
.octave-view/x1 LDZ2 #0050 ++ .octave-view/x2 STZ2
.octave-view/y1 LDZ2 #0018 ++ .octave-view/y2 STZ2
( place adsr )
.center/x LDZ2 #0020 -- .adsr-view/x1 STZ2
.center/y LDZ2 #0008 ++ .adsr-view/y1 STZ2
.adsr-view/x1 LDZ2 #00a0 ++ .adsr-view/x2 STZ2
.adsr-view/y1 LDZ2 #0018 ++ .adsr-view/y2 STZ2
( place waveform )
.center/x LDZ2 #0080 -- .wave-view/x1 STZ2
.center/y LDZ2 #0020 -- .wave-view/y1 STZ2
.wave-view/x1 LDZ2 #0100 ++ .wave-view/x2 STZ2
.wave-view/y1 LDZ2 #0020 ++ .wave-view/y2 STZ2
( default settings )
#ff .last-note STZ
#041c .Audio0/adsr DEO2
#dd .Audio0/volume DEO
;sin-pcm .Audio0/addr DEO2
#0100 .Audio0/length DEO2
( inital drawing )
;draw-octave JSR2
;draw-adsr JSR2
;draw-wave JSR2
BRK
@on-frame ( -> )
.adsr-view/y2 LDZ2 #0020 -- .Screen/y DEO2
#10 #00
&loop
.adsr-view/x2 LDZ2 #003a -- .Screen/x DEO2
#10 OVR - .Audio0/output DEI #0f AND < .Screen/pixel DEO
.adsr-view/x2 LDZ2 #003a -- INC2 INC2 .Screen/x DEO2
#10 OVR - .Audio0/output DEI #04 SFT < .Screen/pixel DEO
.Screen/y DEI2 INC2 INC2 .Screen/y DEO2
INC GTHk ,&loop JCN
POP2
BRK
@on-control ( -> )
( clear last cursor )
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#40 .Screen/sprite DEO
.Controller/key DEI
[ LIT 'a ] !~ ,&no-c JCN
#30 .octave LDZ #0c * + ;play JSR2 &no-c
[ LIT 's ] !~ ,&no-d JCN
#32 .octave LDZ #0c * + ;play JSR2 &no-d
[ LIT 'd ] !~ ,&no-e JCN
#34 .octave LDZ #0c * + ;play JSR2 &no-e
[ LIT 'f ] !~ ,&no-f JCN
#35 .octave LDZ #0c * + ;play JSR2 &no-f
[ LIT 'g ] !~ ,&no-g JCN
#37 .octave LDZ #0c * + ;play JSR2 &no-g
[ LIT 'h ] !~ ,&no-a JCN
#39 .octave LDZ #0c * + ;play JSR2 &no-a
[ LIT 'j ] !~ ,&no-b JCN
#3b .octave LDZ #0c * + ;play JSR2 &no-b
[ LIT 'k ] !~ ,&no-c2 JCN
#3c .octave LDZ #0c * + ;play JSR2 &no-c2
[ #1b ] !~ ,&no-esc JCN HALT &no-esc
POP
( release )
#00 .Controller/key DEO
.Controller/button DEI
DUP #11 ! ,&cu JCN #3c ;play JSR2 &cu
DUP #21 ! ,&cd JCN #3d ;play JSR2 &cd
DUP #41 ! ,&cl JCN #3e ;play JSR2 &cl
DUP #81 ! ,&cr JCN #3f ;play JSR2 &cr
DUP #12 ! ,&au JCN #40 ;play JSR2 &au
DUP #22 ! ,&ad JCN #41 ;play JSR2 &ad
DUP #42 ! ,&al JCN #42 ;play JSR2 &al
DUP #82 ! ,&ar JCN #43 ;play JSR2 &ar
DUP #14 ! ,&su JCN #44 ;play JSR2 &su
DUP #24 ! ,&sd JCN #45 ;play JSR2 &sd
DUP #44 ! ,&sl JCN #46 ;play JSR2 &sl
DUP #84 ! ,&sr JCN #47 ;play JSR2 &sr
DUP #40 ! ,&l JCN .Audio0/addr DEI2 #0010 -- .Audio0/addr DEO2 &l
DUP #80 ! ,&r JCN .Audio0/addr DEI2 #0010 ++ .Audio0/addr DEO2 &r
POP
;draw-octave JSR2
;draw-wave JSR2
BRK
@on-message ( -> )
.Console/read DEI ;play JSR2
;draw-octave JSR2
BRK
@on-mouse ( -> )
;draw-cursor JSR2
.Mouse/state DEI #00 ! #01 JCN [ BRK ]
.Mouse/x DEI2 .Mouse/y DEI2 .wave-view ;within-rect JSR2
;on-touch-wave-view JCN2
.Mouse/x DEI2 .Mouse/y DEI2 .adsr-view ;within-rect JSR2
;on-touch-adsr-view JCN2
.Mouse/x DEI2 .Mouse/y DEI2 .octave-view ;within-rect JSR2
;on-touch-octave-view JCN2
BRK
@on-touch-wave-view ( -> )
.Mouse/x DEI2 .wave-view/x1 LDZ2 -- .Audio0/length DEO2
;draw-wave JSR2
;draw-cursor JSR2
BRK
@on-touch-octave-view ( -> )
.Mouse/x DEI2 .octave-view/x1 LDZ2 -- 8// NIP #09 ! ,&no-mod JCN
.Mouse/y DEI2 .octave-view/y1 LDZ2 -- 8// NIP
[ #00 ] !~ ,&no-incr JCN
.octave LDZ #03 = ,&no-incr JCN
.octave LDZ INC .octave STZ &no-incr
[ #02 ] !~ ,&no-decr JCN
.octave LDZ #ff = ,&no-decr JCN
.octave LDZ #01 - .octave STZ &no-decr
POP
( release ) #00 .Mouse/state DEO
;draw-octave JSR2
BRK
&no-mod
.Mouse/x DEI2 .octave-view/x1 LDZ2 -- 8// NIP #06 > ,&no-key JCN
.Mouse/x DEI2 .octave-view/x1 LDZ2 -- 8// ;notes ++ LDA .octave LDZ #0c * + ;play JSR2
( release ) #00 .Mouse/state DEO
;draw-octave JSR2
&no-key
BRK
@on-touch-adsr-view ( -> )
.Mouse/x DEI2 .adsr-view/x1 LDZ2 -- 8// NIP #03 /
[ #00 ] !~ ,&no-a JCN
.Audio0/adsr DEI
#10 .Mouse/state DEI #10 = #e0 * + +
.Audio0/adsr DEO &no-a
[ #01 ] !~ ,&no-d JCN
.Audio0/adsr DEI
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
.Audio0/adsr DEO &no-d
[ #02 ] !~ ,&no-s JCN
.Audio0/adsr INC DEI
#10 .Mouse/state DEI #10 = #e0 * + +
.Audio0/adsr INC DEO &no-s
[ #03 ] !~ ,&no-r JCN
.Audio0/adsr INC DEI
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
.Audio0/adsr INC DEO &no-r
[ #05 ] !~ ,&no-left JCN
.Audio0/volume DEI
#10 .Mouse/state DEI #10 = #e0 * + +
.Audio0/volume DEO &no-left
[ #06 ] !~ ,&no-right JCN
.Audio0/volume DEI
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
.Audio0/volume DEO &no-right
POP
( release ) #00 .Mouse/state DEO
;draw-adsr JSR2
;draw-cursor JSR2
BRK
@play ( pitch -- )
DUP #0c MOD .last-note STZ
.Audio0/pitch DEO
RTN
@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 )
#41 [ .Mouse/state DEI #00 ! ] + .Screen/sprite DEO
RTN
@draw-octave ( -- )
.octave-view/x1 LDZ2 .octave-view/y1 LDZ2
OVR2 OVR2 ;keys-left-icns .last-note LDZ #00 = INC ;draw-key JSR2
OVR2 #0008 ++ OVR2 ;keys-middle-icns .last-note LDZ #02 = INC ;draw-key JSR2
OVR2 #0010 ++ OVR2 ;keys-right-icns .last-note LDZ #04 = INC ;draw-key JSR2
OVR2 #0018 ++ OVR2 ;keys-left-icns .last-note LDZ #05 = INC ;draw-key JSR2
OVR2 #0020 ++ OVR2 ;keys-middle-icns .last-note LDZ #07 = INC ;draw-key JSR2
OVR2 #0028 ++ OVR2 ;keys-middle-icns .last-note LDZ #09 = INC ;draw-key JSR2
SWP2 #0030 ++ SWP2 ;keys-right-icns .last-note LDZ #0b = INC ;draw-key JSR2
.octave-view/x1 LDZ2 #0048 ++ .Screen/x DEO2
;arrow-icns .Screen/addr DEO2
.octave-view/y1 LDZ2 .Screen/y DEO2
#01 .Screen/sprite DEO
;arrow-icns #0008 ++ .Screen/addr DEO2
.octave-view/y1 LDZ2 #0010 ++ .Screen/y DEO2
#01 .Screen/sprite DEO
;font-hex .octave LDZ #03 + #00 SWP 8** ++ .Screen/addr DEO2
.octave-view/y1 LDZ2 #0008 ++ .Screen/y DEO2
#03 .Screen/sprite DEO
RTN
@draw-key ( x* y* addr* color -- )
STH
.Screen/addr DEO2
SWP2 .Screen/x DEO2
DUP2 #0018 ++ SWP2
&loop
( move ) DUP2 .Screen/y DEO2
( draw ) STHkr .Screen/sprite DEO
( incr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
#0008 ++ GTH2k ,&loop JCN
POP2 POP2
POPr
RTN
@draw-adsr ( -- )
( adsr )
.adsr-view/x1 LDZ2 .adsr-view/y1 LDZ2
.Audio0/adsr DEI #04 SFT
;draw-knob JSR2
.adsr-view/x1 LDZ2 #0018 ++ .adsr-view/y1 LDZ2
.Audio0/adsr DEI #0f AND
;draw-knob JSR2
.adsr-view/x1 LDZ2 #0030 ++ .adsr-view/y1 LDZ2
.Audio0/adsr INC DEI #04 SFT
;draw-knob JSR2
.adsr-view/x1 LDZ2 #0048 ++ .adsr-view/y1 LDZ2
.Audio0/adsr INC DEI #0f AND
;draw-knob JSR2
( volume )
.adsr-view/x2 LDZ2 #0028 -- .adsr-view/y1 LDZ2
.Audio0/volume DEI #04 SFT
;draw-knob JSR2
.adsr-view/x2 LDZ2 #0010 -- .adsr-view/y1 LDZ2
.Audio0/volume DEI #0f AND
;draw-knob JSR2
RTN
@draw-wave ( -- )
( clear )
.wave-view/x1 LDZ2
.wave-view/y1 LDZ2
.wave-view/x2 LDZ2 INC2
.wave-view/y2 LDZ2
#00 ;fill-rect JSR2
#01 ;draw-wave-length JSR2
.wave-view/x1 LDZ2 .Screen/x DEO2
( waveform )
#ff #00
&loop
( dotted line )
DUP #01 AND ,&no-dot JCN
.wave-view/y1 LDZ2 #0010 ++ .Screen/y DEO2
#03 .Screen/pixel DEO
&no-dot
DUP TOS .Audio0/addr DEI2 ++ LDA
2/
TOS 4// .wave-view/y1 LDZ2 ++ .Screen/y DEO2
.Screen/x DEI2 INC2 .Screen/x DEO2
( draw ) DUP
.Audio0/length DEI2 NIP >
.Audio0/length DEI2 #0100 !! #0101 == DUP ADD INC .Screen/pixel DEO
INC GTHk ,&loop JCN
POP2
( range )
.wave-view/x1 LDZ2 .Screen/x DEO2
.wave-view/y1 LDZ2 #0010 -- .Screen/y DEO2
.Audio0/addr DEI2 #02 ;draw-short JSR2
.wave-view/x2 LDZ2 #0020 -- .Screen/x DEO2
.Audio0/length DEI2 #02 ;draw-short JSR2
RTN
@draw-wave-length ( color -- )
STH
.wave-view/x1 LDZ2 .Audio0/length DEI2 ++ .Screen/x DEO2
.wave-view/y1 LDZ2 DUP2 #0020 ++ SWP2
&loop
DUP2 .Screen/y DEO2
( draw ) STHkr .Screen/pixel DEO
INC2 GTH2k ,&loop JCN
POP2 POP2
POPr
RTN
@draw-knob ( x* y* value -- )
( load ) STH .Screen/y DEO2 .Screen/x DEO2
;knob-icns .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
;knob-icns #0008 ++ .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
;knob-icns #0018 ++ .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
.Screen/x DEI2 #0008 -- .Screen/x DEO2
;knob-icns #0010 ++ .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
.Screen/x DEI2 #0004 ++ .Screen/x DEO2
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
;font-hex #00 STHkr #30 SFT ++ .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
.Screen/x DEI2 #0004 -- #00 #00 STHkr ;knob-offsetx ++ LDA ++ .Screen/x DEO2
.Screen/y DEI2 #0010 -- #00 #00 STHr ;knob-offsety ++ LDA ++ .Screen/y DEO2
;knob-icns #0020 ++ .Screen/addr DEO2
( draw ) #05 .Screen/sprite DEO
RTN
@draw-short ( short* color -- )
STH SWP
DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2
( draw ) STHkr .Screen/sprite DEO
#0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
#0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHr .Screen/sprite DEO
RTN
@fill-rect ( x1* y1* x2* y2* color -- )
,&color STR
( x1 x2 y1 y2 ) ROT2
&ver
( save ) DUP2 .Screen/y DEO2
STH2 STH2 OVR2 OVR2 SWP2
&hor
( save ) DUP2 .Screen/x DEO2
( draw ) ,&color LDR .Screen/pixel DEO
( incr ) INC2
OVR2 OVR2 GTS2 ,&hor JCN
POP2 POP2 STH2r STH2r
( incr ) INC2
OVR2 OVR2 GTS2 ,&ver JCN
POP2 POP2 POP2 POP2
RTN
&color $1
@within-rect ( x* y* rect -- flag )
STH
( y < rect.y1 ) DUP2 STHkr #02 ADD 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
RTN
&skip
POP2 POP2 POPr
#00
RTN
@cursor
80c0 e0f0 f8e0 1000
@arrow-icns
0010 387c fe10 1000
0010 1010 fe7c 3810
@notes
30 32 34 35
37 39 3b 3c
@keys-left-icns
7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7e7f
7f7f 7f7f 7f7f 3e00
@keys-middle-icns
1c1c 1c1c 1c1c 1c1c
1c1c 1c1c 1c1c 3e7f
7f7f 7f7f 7f7f 3e00
@keys-right-icns
1f1f 1f1f 1f1f 1f1f
1f1f 1f1f 1f1f 3f7f
7f7f 7f7f 7f7f 3e00
@knob-icns
0003 0c10 2020 4040
00c0 3008 0404 0202
4040 2020 100c 0300
0202 0404 0830 c000
0000 183c 3c18 0000
@knob-offsetx
01 00 00 00 00 01 02 03
05 06 07 08 08 08 08 07
@knob-offsety
07 06 05 03 02 01 00 00
00 00 01 02 03 05 06 07
@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
@piano-pcm
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
@violin-pcm
8186 8d94 9ba0 a3a7 acb1 b5bc c2c7 cacc
cecf d0d1 d3d5 d8db dee1 e3e5 e6e5 e5e3
dfdc d7d0 c8c2 bbb2 a99f 968c 847c 746e
675f 5851 4b43 3e3a 3533 312e 2c2b 2826
2422 2122 2327 2d34 3c44 4c57 5f68 7075
7b80 8487 8789 8a8c 8d90 9397 999c 9ea0
a2a2 a2a0 9c97 9491 8f8e 908f 918f 8e88
827a 726a 6058 5047 423f 3f40 4245 4748
4949 4746 4545 4a4f 5863 717f 8b9a a6b1
b8be c1c1 bfbd bab5 b1af acac aeb1 b7bc
c2c9 cfd3 d5d4 d3d3 d1ce cbc6 c0ba b3ab
a39a 8f85 7b72 6c67 6462 605f 5e5d 5b58
5550 4d49 4848 4949 4a4d 5052 5558 5b5e
6164 686c 7074 7677 7979 7a7b 7b7a 7977
7473 6f6e 6b69 696b 6f72 7576 7574 716b
655d 554e 4742 3f3f 4045 4b52 5a62 6b74
@sin-pcm
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
@tri-pcm
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
@saw-pcm
8282 8183 8384 8685 8888 8889 8a8b 8c8c
8e8e 8f90 9092 9193 9494 9596 9699 9899
9b9a 9c9c 9c9d 9ea0 a1a0 a2a2 a3a5 a4a6
a7a7 a9a8 a9aa aaac adad aeae b0b0 b1b3
b2b4 b5b5 b6b7 b9b8 b9bb babc bdbc bdbe
bfc1 bfc1 c3c1 c4c5 c5c6 c6c7 c9c7 cbca
cbcc cdcd cfcf d2d0 d2d2 d2d5 d4d5 d6d7
d8d8 d9dc d9df dadf dce1 dde5 dce6 dceb
cb1f 1b1e 1c21 1c21 1f23 2025 2127 2329
2529 2829 2a2b 2b2e 2d2f 302f 3231 3234
3334 3536 3836 3939 3a3b 3b3d 3e3d 3f40
4042 4242 4444 4646 4748 474a 4a4b 4d4c
4e4e 4f50 5052 5252 5554 5557 5759 5959
5b5b 5c5d 5d5f 5e60 6160 6264 6365 6566
6867 6969 6a6c 6c6d 6d6e 706f 7071 7174
7475 7576 7777 797a 7a7c 7b7c 7e7d 7f7f

View file

@ -1,15 +1,25 @@
( Polycat:
A cat with one eye, and the hind and tail of a lizard.
Original character by Rekka Bellum )
( polycat )
%2// { #01 SFT2 }
%!~ { NEQk NIP }
%AUTO-XADDR { #05 .Screen/auto DEO }
( 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 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixeld $1 &sprite $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 &scrollx $2 &scrolly $2
( variables )
|0000
@cat &x $2 &y $2 &timer $1
@pointer &x $2 &y $2
@cat
&x $2 &y $2 &timer $1
@pointer
&x $2 &y $2
( program )
|0100 ( -> )
@ -23,23 +33,31 @@
( 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
.Screen/width DEI2 2// .cat/x STZ2
.Screen/height DEI2 2// .cat/y STZ2
( set screen mode )
AUTO-XADDR
( init )
#ff ;draw-eye/last STA
#ff ;draw-tail/last STA
( set screen mode auto-x )
#05 .Screen/auto DEO
,draw-polycat JSR
,draw-ground JSR
BRK
@draw-ground ( -- )
.cat/y LDZ2 #0018 ADD2 .Screen/y DEO2
.cat/x LDZ2 #0010 SUB2 .Screen/x DEO2
;ground .Screen/addr DEO2
#1000
&loop
#01 .Screen/sprite DEO
INC GTHk ,&loop JCN
POP2
JMP2r
@draw-polycat ( -- )
( ears )
@ -54,9 +72,9 @@ BRK
#81 .Screen/sprite DEO
( eye/tail )
#00 ,draw-eye JSR
#00 ;draw-tail ( .. )
#00 ,draw-tail JSR
JMP2
JMP2r
@on-mouse ( -> )
@ -74,7 +92,8 @@ BRK
DUP ,&last LDR NEQ ,&changed JCN
POP JMP2r &changed
( only redraw on change )
#00 OVR ;eye ADD2 .Screen/addr DEO2
DUP
#00 SWP ;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
@ -85,10 +104,11 @@ JMP2r
@draw-tail ( frame -- )
STHk ,&last LDR NEQ ,&changed JCN
POPr JMP2r &changed
DUP ,&last LDR NEQ ,&changed JCN
POP JMP2r &changed
( only redraw on change )
STHr #00 OVR ;frames ADD2 LDA
DUP
;frames ROT #00 SWP ADD2 LDA
#00 SWP #40 SFT2 ;body/tail ADD2
.Screen/addr DEO2
.cat/x LDZ2 .Screen/x DEO2

View file

@ -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

View file

@ -0,0 +1,82 @@
( pseudo-random number generator,
based on two 16-bit xorshift algorithms by George Marsaglia
http://www.jstatsoft.org/v08/i14/paper )
( 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 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables )
|0000
( program )
|0100 ( -> )
( init )
;on-frame .Screen/vector DEO2
( seed prng (must be nonzero) )
#00 .DateTime/second DEI
#00 .DateTime/minute DEI #60 SFT2 EOR2
#00 .DateTime/hour DEI #c0 SFT2 EOR2 ;prng2/x STA2
#00 .DateTime/hour DEI #04 SFT2
#00 .DateTime/day DEI #10 SFT2 EOR2
#00 .DateTime/month DEI #60 SFT2 EOR2
.DateTime/year DEI2 #a0 SFT2 EOR2 ;prng2/y STA2
;prng2/x LDA2 ;prng2/y LDA2 EOR2
ORAk ,&non-zero JCN INC2 &non-zero
;prng/seed STA2
( theme )
#0fe5 .System/r DEO2
#0fc5 .System/g DEO2
#0f25 .System/b DEO2
BRK
@on-frame ( -> )
#c0
&loop
,draw-pixel JSR
INC
DUP ,&loop JCN
POP
BRK
@draw-pixel
,prng2 JSR
#00 SWP .Screen/x DEO2
#00 SWP .Screen/y DEO2
#01 .Screen/pixel DEO
JMP2r
@prng ( -- number* )
( returns the next number in a 65,535-long sequence,
which is never zero but every other 16-bit number
appears once before the sequence repeats )
( http://www.retroprogramming.com/2017/07/xorshift-pseudorandom-numbers-in-z80.html )
,&seed LDR2
DUP2 #70 SFT2 EOR2
DUP2 #09 SFT2 EOR2
DUP2 #80 SFT2 EOR2
,&seed STR2k POP
JMP2r
&seed $2
@prng2 ( -- number* )
( returns the next number in a (2^32-1)-long sequence )
( http://b2d-f9r.blogspot.com/2010/08/16-bit-xorshift-rng-now-with-more.html )
,&x LDR2
DUP2 #50 SFT2 EOR2
DUP2 #03 SFT2 EOR2
,&y LDR2 DUP2 ,&x STR2
DUP2 #01 SFT2 EOR2 EOR2
,&y STR2k POP
JMP2r
&x $2
&y $2

View file

@ -0,0 +1,159 @@
( devices )
( uxnasm rule110.tal rule110.rom && uxnemu rule110.rom )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 }
%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 }
%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 }
%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 }
%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 }
%2MOD { #01 AND } %2MOD2 { #0001 AND2 }
%4MOD { #03 AND } %4MOD2 { #0003 AND2 }
%8MOD { #07 AND } %8MOD2 { #0007 AND2 }
%10MOD { #0f AND } %10MOD2 { #000f AND2 }
%ROL2 { DUP2 #0f SFT2 SWP2 #10 SFT2 ++ }
%ROR2 { DUP2 #f0 SFT2 SWP2 #01 SFT2 ++ }
%DEBUG { ;print-hex/byte JSR2 #0a18 DEO }
%DEBUG2 { ;print-hex JSR2 #0a18 DEO }
%RTN { JMP2r }
%WIDTH { #0020 }
%STEPS { #30 }
|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 ]
|0000
@input
|0100
( set system colors )
#0ff7 .System/r DEO2
#0f0e .System/g DEO2
#0f0c .System/b DEO2
;on-mouse .Mouse/vector DEO2
( set size )
#0080 .Screen/width DEO2
#0180 .Screen/height DEO2
( seed ) #0001 ;input STA2
,render JSR
BRK
@render ( -- )
STEPS #00
&loop
( update )
DUP 2* LDZ2k
;rule-110 JSR2
ROT INC INC STZ2
( draw )
DUP ,draw-line JSR
INC GTHk ,&loop JCN
POP2
RTN
@draw-line ( line -- )
STHk #00 SWP 8** .Screen/y DEO2
#1000
&loop
DUP #00 SWP 8** .Screen/x DEO2
( shift ) INCk #10 SWP -
( get address ) STHkr 2* LDZ2
( bit ) ROT SFT2 #0001 AND2
( get sprite ) 8** ;cell-icns ++ .Screen/addr DEO2
#01 STHkr #00 = + .Screen/sprite DEO
INC GTHk ,&loop JCN
POP2
POPr
RTN
@rule-110 ( value* -- value* )
#0000 ,&res STR2
ROL2 STH2
#1000
&loop
( get 3-bits ) STH2kr #e000 AND2 #0d SFT2 ;rule ++ LDA STH
( get result ) DUP #40 SFT #00 STHr ROT SFT2
( reset ) ROR2 ROR2 ROR2
( save ) ,&res LDR2 ++ ,&res STR2
STH2r ROR2 STH2
INC GTHk ,&loop JCN
POP2
POP2r
,&res LDR2
RTN
&res $2
@rule
00 01 01 01 00 01 01 00
@on-mouse ( -> )
( clear last cursor )
;mouse-icn .Screen/addr DEO2
,&x LDR2 .Screen/x DEO2
,&y LDR2 .Screen/y DEO2
#40 .Screen/sprite DEO
( record pointer positions )
.Mouse/x DEI2 DUP2 ,&x STR2 .Screen/x DEO2
.Mouse/y DEI2 DUP2 ,&y STR2 .Screen/y DEO2
( colorize on state )
#43 [ .Mouse/state DEI #00 ! ] - .Screen/sprite DEO
( on click )
.Mouse/state DEI #00 ! JMP BRK
( toggle bit )
.input LDZ2k
#0001 .Mouse/x DEI2 8// #000f SWP2 -- NIP #40 SFT SFT2 EOR2
ROT STZ2
;render JSR2
( release ) #00 .Mouse/state DEO
BRK
&x $2 &y $2
@print-hex ( value* -- )
SWP ,&byte JSR
&byte ( byte -- )
STHk #04 SFT ,&parse JSR #18 DEO
STHr #0f AND ,&parse JSR #18 DEO
RTN
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 + RTN
&above #57 + RTN
RTN
@mouse-icn
80c0 e0f0 f8e0 1000
@cell-icns
7c82 8282 8282 7c00
7cfe fefe fefe 7c00

View file

@ -1,165 +1,229 @@
( uxnemu snake.rom )
( uxnasm projects/examples/demos/snake.tal bin/snake.rom && uxnemu bin/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
%+ { ADD } %- { SUB } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%2/ { #01 SFT } %2* { #10 SFT }
%8// { #03 SFT2 } %8** { #30 SFT2 }
%MOD { DIVk MUL SUB }
%MAX { LTHk JMP SWP POP }
%RTN { JMP2r }
%TOS { #00 SWP }
%BRK? { #01 JCN BRK }
@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
%DIFFICULTY { #06 }
@on-reset ( -> )
( | theme )
( devices )
|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 &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 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables )
|0000
( program )
@arena
&w $1 &h $1 &timer $1
@apple
&x $1 &y $1
@snake
&direction $1 &length $1 &dead $1
&x $1 &y $1
&tail
|0100 ( -> )
( theme )
#0f7e .System/r DEO2
#0fe6 .System/g DEO2
#0f62 .System/b DEO2
( | vectors )
( vectors )
;on-frame .Screen/vector DEO2
;on-button .Controller/vector DEO2
( | resize )
( 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
( set arena )
.Screen/width DEI2 8// NIP .arena/w STZ
.Screen/height DEI2 8// NIP .arena/h STZ
;reset JSR2
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
.arena/timer LDZ INC DUP .arena/timer STZ
DIFFICULTY = BRK?
( clear ) #00 ;draw-snake JSR2
( update ) ;move JSR2
( draw ) #02 .snake/dead LDZ + ;draw-snake JSR2
#83 ;draw-apple JSR2
( score ) .snake/length LDZ #41 ;draw-score JSR2
( reset ) #00 .arena/timer STZ
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
DUP #08 ! ,&no-escape JCN
;reset JSR2
&no-escape
#04 SFT DUP #00 = ,&skip JCN
DUP .snake/direction STZ
&skip
POP
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
#00 ;draw-snake JSR2
#00 ;draw-apple JSR2
@set-pos ( z mod max -- )
LDZ OVR INC ?{ ROT STZ
POP JMP2r }
DIVk MUL SUB SWP STZ
JMP2r
.arena/w LDZ 2/ #01 - .snake/x STZ
.arena/h LDZ 2/ #01 - .snake/y STZ
#00 .snake/dead STZ
#00 .snake/length STZ
#00 .snake/direction STZ
@<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
#03 ;draw-snake JSR2
;add-apple JSR2
(
@|drawing )
RTN
@<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
@move ( -- )
( tail )
.snake/x LDZ2 STH2
.snake/length LDZ #00
&loop
( pop ) DUP 2* .snake/tail + LDZ2 STH2 SWP2r
( push ) DUP 2* .snake/tail + STH2r ROT STZ2
INC GTHk ,&loop JCN
POP2
( | draw head )
.snake/pos LDZ2 #0005 SFT2 .Screen/y DEO2
#0005 SFT2 .Screen/x DEO2
POP2r
.snake/dead LDZ #00 = JMP RTN
.snake/direction LDZ
DUP #01 ! ,&no-up JCN
.snake/y LDZ #01 -
.arena/h LDZ MAX
.snake/y STZ
&no-up
DUP #02 ! ,&no-down JCN
.snake/y LDZ INC
.arena/h LDZ MOD
.snake/y STZ
&no-down
DUP #04 ! ,&no-left JCN
.snake/x LDZ #01 -
.arena/w LDZ MAX
.snake/x STZ
&no-left
DUP #08 ! ,&no-right JCN
.snake/x LDZ INC
.arena/w LDZ MOD
.snake/x STZ
&no-right
POP
( detect collision with apple )
.snake/x LDZ2 .apple/x LDZ2 NEQ2 ,&no-collision-apple JCN
#00 ;draw-apple JSR2
.snake/length LDZ INC .snake/length STZ
;add-apple JSR2
;move JSR2
&no-collision-apple
.snake/length LDZ #01
&loop-body
( pop ) DUP 2* .snake/tail + LDZ2
.snake/x LDZ2 NEQ2 ,&no-collision-body JCN
#01 .snake/dead STZ
#03 ;draw-snake JSR2
&no-collision-body
INC GTHk ,&loop-body JCN
POP2
RTN
@add-apple ( -- )
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2 #1234 MUL2 +
.arena/w LDZ MOD .apple/x STZ
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2 #abcd MUL2 +
.arena/h LDZ MOD .apple/y STZ
RTN
@draw-snake ( color -- )
STH
( draw tail )
;snake-icns .Screen/addr DEO2
.snake/length LDZ #00
&loop
DUP 2* .snake/tail + LDZ TOS 8** .Screen/x DEO2
DUP 2* .snake/tail + INC LDZ TOS 8** .Screen/y DEO2
STHkr .Screen/sprite DEO
INC GTHk ,&loop JCN
POP2
( draw head )
.snake/x LDZ TOS 8** .Screen/x DEO2
.snake/y LDZ TOS 8** .Screen/y DEO2
;snake-icns/face .Screen/addr DEO2
[ LITr -Screen/sprite ] DEOr
JMP2r
STHr .Screen/sprite DEO
@<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
RTN
@draw-apple ( color -- )
.apple/x LDZ TOS 8** .Screen/x DEO2
.apple/y LDZ TOS 8** .Screen/y DEO2
;apple-chr .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>
( >> )
RTN
@<draw-num> ( num -- )
#000f ROT AND #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
[ LIT2 41 -Screen/sprite ] DEO
JMP2r
@draw-score ( score color -- )
(
@|assets )
STH
#0010 .Screen/x DEO2
#0010 .Screen/y DEO2
DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
#0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHr .Screen/sprite DEO
@snake-icns [ 7eff ffff ffff ff7e ]
&face [ 7eff ffdb ffe7 ff7e ]
RTN
@apple-chr [
0000 76ff ffff 7e3c 1008 0000 0000 0000 ]
( assets )
@fill-icn [ ffff ffff ffff ffff ]
@font-hex [
@snake-icns
7eff ffff ffff ff7e
&face
7eff ffdb ffe7 ff7e
@apple-chr
0000 76ff ffff 7e3c
1008 0000 0000 0000
@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
@ -167,5 +231,5 @@
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 ]
007c 8280 f080 827c 007c 8280 f080 8080

View file

@ -0,0 +1,417 @@
( Dev/Screen )
%RTN { JMP2r }
%++ { INC2 }
%2// { #01 SFT2 }
%4// { #02 SFT2 }
%4** { #20 SFT2 }
%8** { #30 SFT2 }
%8+ { #0008 ADD2 }
%STEP8 { #33 SFT2 }
( 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 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
( variables )
|0000
@color $1
@selection $1
@center [ &x $2 &y $2 ]
@pointer [ &x $2 &y $2 ]
@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@window [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &w $2 &h $2 ]
@slider [ &x1 $2 &y $2 &x2 $2 &pos $2 ]
@theme [
&r1 $1 &r2 $1 &r3 $1 &r4 $1
&g1 $1 &g2 $1 &g3 $1 &g4 $1
&b1 $1 &b2 $1 &b3 $1 &b4 $1
]
( program )
|0100 ( -> )
( theme )
#027f .System/r DEO2
#04e7 .System/g DEO2
#06c4 .System/b DEO2
( vectors )
;on-mouse .Mouse/vector DEO2
( size window )
#00b0 .window/w STZ2
#0050 .window/h STZ2
( center window )
.Screen/width DEI2 2// .window/w LDZ2 2// SUB2 .window/x1 STZ2
.Screen/height DEI2 2// .window/h LDZ2 2// SUB2 .window/y1 STZ2
#01 .theme/r1 STZ #02 .theme/g1 STZ #03 .theme/b1 STZ
#04 .theme/r2 STZ #06 .theme/g2 STZ #07 .theme/b2 STZ
#0a .theme/r3 STZ #09 .theme/g3 STZ #08 .theme/b3 STZ
#0c .theme/r4 STZ #0b .theme/g4 STZ #0d .theme/b4 STZ
( find screen center )
.Screen/width DEI2 2// .center/x STZ2
.Screen/height DEI2 2// .center/y STZ2
;update-theme JSR2
;draw-background JSR2
;draw-window JSR2
BRK
@on-mouse ( -> )
;draw-cursor JSR2
.Mouse/state DEI #01 JCN [ BRK ]
.Mouse/y DEI2 .window/y1 LDZ2 SUB2 STEP8
DUP2 #0010 NEQ2 ,&no-touch-red JCN
.Mouse/x DEI2 .window/x1 LDZ2 #0060 ADD2 LTH2 ,&no-touch-red JCN
.Mouse/x DEI2 .window/x1 LDZ2 #009c ADD2 GTH2 ,&no-touch-red JCN
( get new value ) .Mouse/x DEI2 .window/x1 LDZ2 SUB2 #0060 SUB2 4// NIP ;theme/r1 #00 .selection LDZ ADD2 STA
&no-touch-red
DUP2 #0020 NEQ2 ,&no-touch-green JCN
.Mouse/x DEI2 .window/x1 LDZ2 #0060 ADD2 LTH2 ,&no-touch-green JCN
.Mouse/x DEI2 .window/x1 LDZ2 #009c ADD2 GTH2 ,&no-touch-green JCN
( get new value ) .Mouse/x DEI2 .window/x1 LDZ2 SUB2 #0060 SUB2 4// NIP ;theme/g1 #00 .selection LDZ ADD2 STA
&no-touch-green
DUP2 #0030 NEQ2 ,&no-touch-blue JCN
.Mouse/x DEI2 .window/x1 LDZ2 #0060 ADD2 LTH2 ,&no-touch-blue JCN
.Mouse/x DEI2 .window/x1 LDZ2 #009c ADD2 GTH2 ,&no-touch-blue JCN
( get new value ) .Mouse/x DEI2 .window/x1 LDZ2 SUB2 #0060 SUB2 4// NIP ;theme/b1 #00 .selection LDZ ADD2 STA
&no-touch-blue
DUP2 #0040 NEQ2 ,&no-touch-radio JCN
.Mouse/x DEI2 .window/x1 LDZ2 #0050 ADD2 LTH2 ,&no-touch-radio JCN
.Mouse/x DEI2 .window/x1 LDZ2 #008c ADD2 GTH2 ,&no-touch-radio JCN
.Mouse/x DEI2 .window/x1 LDZ2 SUB2 #0050 SUB2 STEP8 2// #0008 DIV2 NIP .selection STZ
&no-touch-radio
POP2
;update-theme JSR2
;draw-cursor JSR2
;draw-background JSR2
;draw-window JSR2
BRK
@update-theme ( -- )
#08 DEI #0f AND .theme/r1 LDZ #40 SFT ADD #08 DEO
#0a DEI #0f AND .theme/g1 LDZ #40 SFT ADD #0a DEO
#0c DEI #0f AND .theme/b1 LDZ #40 SFT ADD #0c DEO
#08 DEI #f0 AND .theme/r2 LDZ ADD #08 DEO
#0a DEI #f0 AND .theme/g2 LDZ ADD #0a DEO
#0c DEI #f0 AND .theme/b2 LDZ ADD #0c DEO
#09 DEI #0f AND .theme/r3 LDZ #40 SFT ADD #09 DEO
#0b DEI #0f AND .theme/g3 LDZ #40 SFT ADD #0b DEO
#0d DEI #0f AND .theme/b3 LDZ #40 SFT ADD #0d DEO
#09 DEI #f0 AND .theme/r4 LDZ ADD #09 DEO
#0b DEI #f0 AND .theme/g4 LDZ ADD #0b DEO
#0d DEI #f0 AND .theme/b4 LDZ ADD #0d DEO
RTN
@draw-background ( -- )
( draw hor line )
#0000 .Screen/x DEO2 .center/y LDZ2 .Screen/y DEO2
.Screen/width DEI2 #0000 ( to/from )
&draw-hor
( draw ) #01 .Screen/pixel DEO
( incr ) #0002 ADD2 DUP2 .Screen/x DEO2
GTH2k ,&draw-hor JCN
POP2 POP2
( draw ver line )
.center/x LDZ2 .Screen/x DEO2 #0000 .Screen/y DEO2
.Screen/height DEI2 #0000 ( to/from )
&draw-ver
( draw ) #02 .Screen/pixel DEO
( incr ) #0002 ADD2 DUP2 .Screen/y DEO2
GTH2k ,&draw-ver JCN
POP2 POP2
( draw blending modes )
;preview_icn .Screen/addr DEO2
#0010 .Screen/y DEO2
#0800
&draw-pixel1
( move ) #00 OVR #30 SFT #0010 ADD2 .Screen/x DEO2
( draw ) DUP .Screen/pixel DEO
( incr ) INC
GTHk ,&draw-pixel1 JCN
POP2
#0018 .Screen/y DEO2
#0800
&draw-pixel2
( move ) #00 OVR #30 SFT #0010 ADD2 .Screen/x DEO2
( draw ) DUP #08 ADD .Screen/pixel DEO
( incr ) INC
GTHk ,&draw-pixel2 JCN
POP2
#0020 .Screen/y DEO2
#0800
&draw-icn1
( move ) #00 OVR #30 SFT #0010 ADD2 .Screen/x DEO2
( draw ) DUP .Screen/sprite DEO
( incr ) INC
GTHk ,&draw-icn1 JCN
POP2
#0028 .Screen/y DEO2
#0800
&draw-icn2
( move ) #00 OVR #30 SFT #0010 ADD2 .Screen/x DEO2
( draw ) DUP #08 ADD .Screen/sprite DEO
( incr ) INC
GTHk ,&draw-icn2 JCN
POP2
#0030 .Screen/y DEO2
#0800
&draw-chr1
( move ) #00 OVR #30 SFT #0010 ADD2 .Screen/x DEO2
( draw ) DUP #80 ADD .Screen/sprite DEO
( incr ) INC
GTHk ,&draw-chr1 JCN
POP2
#0038 .Screen/y DEO2
#0800
&draw-chr2
( move ) #00 OVR #30 SFT #0010 ADD2 .Screen/x DEO2
( draw ) DUP #88 ADD .Screen/sprite DEO
( incr ) INC
GTHk ,&draw-chr2 JCN
POP2
RTN
@draw-window ( -- )
.window/x1 LDZ2 .window/w LDZ2 ADD2 .window/x2 STZ2
.window/y1 LDZ2 .window/h LDZ2 ADD2 .window/y2 STZ2
.window/x1 LDZ2 .window/y1 LDZ2 .window/x2 LDZ2 .window/y2 LDZ2 #02 ;fill-rect JSR2
.window/x1 LDZ2 .window/y1 LDZ2 .window/x2 LDZ2 .window/y2 LDZ2 #01 ;line-rect JSR2
.window/x1 LDZ2 #0002 SUB2 .window/y1 LDZ2 #0002 SUB2 .window/x2 LDZ2 #0002 ADD2 .window/y2 LDZ2 #0002 ADD2 #01 ;line-rect JSR2
.window/x1 LDZ2 #0008 ADD2 .window/y1 LDZ2 #0010 ADD2 ;red_txt #05 ;draw-label JSR2
.window/x1 LDZ2 #0038 ADD2 .Screen/x DEO2
.System/r DEI2 #08 ;draw-short JSR2
.window/x1 LDZ2 #0008 ADD2 .window/y1 LDZ2 #0020 ADD2 ;green_txt #05 ;draw-label JSR2
.window/x1 LDZ2 #0038 ADD2 .Screen/x DEO2
.System/g DEI2 #08 ;draw-short JSR2
.window/x1 LDZ2 #0008 ADD2 .window/y1 LDZ2 #0030 ADD2 ;blue_txt #05 ;draw-label JSR2
.window/x1 LDZ2 #0038 ADD2 .Screen/x DEO2
.System/b DEI2 #08 ;draw-short JSR2
.window/x1 LDZ2 #0060 ADD2 .window/y1 LDZ2 #0010 ADD2 .window/x1 LDZ2 #0090 ADD2 #00 ;theme/r1 .selection LDZ ADD LDA 4** #01 ;draw-slider JSR2
.window/x1 LDZ2 #0060 ADD2 .window/y1 LDZ2 #0020 ADD2 .window/x1 LDZ2 #0090 ADD2 #00 ;theme/g1 .selection LDZ ADD LDA 4** #01 ;draw-slider JSR2
.window/x1 LDZ2 #0060 ADD2 .window/y1 LDZ2 #0030 ADD2 .window/x1 LDZ2 #0090 ADD2 #00 ;theme/b1 .selection LDZ ADD LDA 4** #01 ;draw-slider JSR2
.window/x1 LDZ2 #0050 ADD2 .Screen/x DEO2
.window/y1 LDZ2 #0040 ADD2 .Screen/y DEO2
;radio_icns #00 .selection LDZ #00 EQU 8** ADD2 .Screen/addr DEO2
#05 .Screen/sprite DEO
.window/x1 LDZ2 #0060 ADD2 .Screen/x DEO2
.window/y1 LDZ2 #0040 ADD2 .Screen/y DEO2
;radio_icns #00 .selection LDZ #01 EQU 8** ADD2 .Screen/addr DEO2
#05 .Screen/sprite DEO
.window/x1 LDZ2 #0070 ADD2 .Screen/x DEO2
.window/y1 LDZ2 #0040 ADD2 .Screen/y DEO2
;radio_icns #00 .selection LDZ #02 EQU 8** ADD2 .Screen/addr DEO2
#05 .Screen/sprite DEO
.window/x1 LDZ2 #0080 ADD2 .Screen/x DEO2
.window/y1 LDZ2 #0040 ADD2 .Screen/y DEO2
;radio_icns #00 .selection LDZ #03 EQU 8** ADD2 .Screen/addr DEO2
#05 .Screen/sprite DEO
RTN
@draw-cursor ( -- )
( clear last cursor )
;pointer_icn .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
#43 .Mouse/state DEI #00 NEQ DUP ADD SUB .Screen/sprite DEO
RTN
@draw-slider ( x1* y* x2* pos* color -- )
( load ) .color STZ .slider/pos STZ2 .slider/x2 STZ2 .slider/y STZ2 .slider/x1 STZ2
.slider/x1 LDZ2 .Screen/x DEO2
.slider/y LDZ2 .Screen/y DEO2
;halftone_icn .Screen/addr DEO2
;slidera_icn .Screen/addr DEO2
( draw ) #05 .Screen/sprite DEO
;sliderb_icn .Screen/addr DEO2
&loop
( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
( draw ) #05 .Screen/sprite DEO
.Screen/x DEI2 .slider/x2 LDZ2 #0008 ADD2 LTH2 ,&loop JCN
( incr ) .Screen/x DEI2 #0004 ADD2 .Screen/x DEO2
;sliderc_icn .Screen/addr DEO2
( draw ) #05 .Screen/sprite DEO
.slider/x1 LDZ2 .slider/pos LDZ2 ADD2 .Screen/x DEO2
;sliderd_icn .Screen/addr DEO2
( draw ) #0a .Screen/sprite DEO
RTN
@fill-rect ( x1* y1* x2* y2* color -- )
.color STZ
STH2 ROT2 ROT2 STH2 ( x2 x1 / y2 y1 )
&ver
( save ) STH2kr .Screen/y DEO2
OVR2 OVR2
&hor
( save ) DUP2 .Screen/x DEO2
( draw ) .color LDZ .Screen/pixel DEO
( incr ) INC2
GTH2k ,&hor JCN
POP2 POP2
( incr ) INC2r
GTH2kr STHr ,&ver JCN
POP2 POP2 POP2r POP2r
RTN
@line-rect ( x1* y1* x2* y2* color -- )
( load ) .color STZ .rect/y2 STZ2 .rect/x2 STZ2 DUP2 .Screen/y DEO2 .rect/y1 STZ2 DUP2 .Screen/x DEO2 .rect/x1 STZ2
&hor
( incr ) .Screen/x DEI2 ++ .Screen/x DEO2
( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO
( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO
.Screen/x DEI2 .rect/x2 LDZ2 LTH2 ,&hor JCN
.rect/y1 LDZ2 .Screen/y DEO2
&ver
( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ .Screen/pixel DEO
( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .color LDZ .Screen/pixel DEO
( incr ) .Screen/y DEI2 ++ .Screen/y DEO2
.Screen/y DEI2 .rect/y2 LDZ2 ++ LTH2 ,&ver JCN
RTN
@draw-label ( x* y* addr* color -- )
STH STH2
.Screen/y DEO2
.Screen/x DEO2
STH2r
&loop
LDAk #00 SWP 8**
;font ADD2 .Screen/addr DEO2
( draw ) STHkr .Screen/sprite DEO
( incr ) ++
( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
LDAk ,&loop JCN
POP2 POPr
RTN
@draw-short ( short* color -- )
STH SWP
DUP #04 SFT #00 SWP 8** ;font-hex ADD2 .Screen/addr DEO2
( draw ) STHkr .Screen/sprite DEO
#0f AND #00 SWP 8** ;font-hex ADD2 .Screen/addr DEO2
.Screen/x DEI2 8+ .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
DUP #04 SFT #00 SWP 8** ;font-hex ADD2 .Screen/addr DEO2
.Screen/x DEI2 8+ .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
#0f AND #00 SWP 8** ;font-hex ADD2 .Screen/addr DEO2
.Screen/x DEI2 8+ .Screen/x DEO2
( draw ) STHr .Screen/sprite DEO
RTN
@red_txt [ "Red 00 ]
@green_txt [ "Green 00 ]
@blue_txt [ "Blue 00 ]
@pointer_icn [ 80c0 e0f0 f8e0 1000 ]
@halftone_icn [ aa55 aa55 aa55 aa55 ]
@slidera_icn [ 3f7f ffff ffff 7f3f ]
@sliderb_icn [ ffff ffff ffff ffff ]
@sliderc_icn [ fcfe ffff ffff fefc ]
@sliderd_icn [ 003c 7e7e 7e7e 3c00 ]
@preview_icn
183c 66db db66 3c18
0000 183c 3c18 0000
@radio_icns
3c42 8181 8181 423c
3c42 99bd bd99 423c
@font-hex
003c 464a 5262 3c00 0018 0808 0808 1c00
003c 4202 3c40 7e00 003c 421c 0242 3c00
000c 1424 447e 0400 007e 407c 0242 3c00
003c 407c 4242 3c00 007e 0204 0810 1000
003c 423c 4242 3c00 003c 4242 3e02 3c00
003c 4242 7e42 4200 007c 427c 4242 7c00
003c 4240 4042 3c00 007c 4242 4242 7c00
007e 4078 4040 7e00 007e 4078 4040 4000
@font ( spectrum-zx font )
0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000
007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000
0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800
0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800
003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038
0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000
0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000
0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400
0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000
0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800
0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000
003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00
0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000
003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810
0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800
003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00
0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00
0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200
0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00
007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00
00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200
0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00
0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00
0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00
0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c
0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400
0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800
0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800
0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800
0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c

View file

@ -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

View file

@ -1,5 +1,7 @@
( dev/audio )
%MOD { DUP2 DIV MUL SUB }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
@ -55,7 +57,7 @@ BRK
( skip ) .timer LDZ #10 EQU #01 JCN [ BRK ]
( get note )
.counter LDZ #18 DIVk MUL SUB #30 ADD
.counter LDZ #18 MOD #30 ADD
.Audio0/pitch .counter LDZ #03 AND #40 SFT ADD DEO
.counter LDZ INC .counter STZ

View file

@ -1,7 +1,13 @@
( dev/audio )
%2// { #01 SFT2 }
%4** { #20 SFT2 }
%8** { #30 SFT2 }
%20MOD { #1f AND }
%RTN { JMP2r }
%GET-NOTE { #00 SWP ;melody ADD2 LDA }
%GET-HEXCHAR { #00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2 }
%GET-HEXCHAR { #00 SWP 8** ;font-hex ADD2 .Screen/addr DEO2 }
( devices )
@ -38,8 +44,8 @@
#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
.Screen/width DEI2 2// #0080 SUB2 .offset/x STZ2
.Screen/height DEI2 2// #0040 SUB2 .offset/y STZ2
;draw JSR2
#02 ;draw-selector JSR2
@ -65,12 +71,12 @@ BRK
&no-down
[ #04 ] NEQk NIP ,&no-left JCN
#00 ;draw-selector JSR2
.selection LDZ #01 SUB #1f AND .selection STZ
.selection LDZ #01 SUB 20MOD .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
.selection LDZ INC 20MOD .selection STZ
#02 ;draw-selector JSR2
&no-right
POP
@ -83,9 +89,9 @@ BRK
( 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
( erase last ) DUP #01 SUB 20MOD #01 ,draw-note JSR
( draw current ) #01 ,draw-note JSR
( incr ) .progress LDZ INC #1f AND .progress STZ
( incr ) .progress LDZ INC 20MOD .progress STZ
#00 .timer STZ
BRK
@ -98,30 +104,30 @@ BRK
INC GTHk ,&loop JCN
POP2
JMP2r
RTN
@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 x ) [ #00 STHkr ] 8** .offset/x LDZ2 ADD2 .Screen/x DEO2
( set y ) [ #00 #00 STHkr ;melody ADD2 LDA ] 4** #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
RTN
@draw-selector ( color -- )
STH
[ #00 .selection LDZ ] #30 SFT2 .offset/x LDZ2 ADD2 .Screen/x DEO2
[ #00 .selection LDZ ] 8** .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
.Screen/y DEI2 #0008 ADD2 .Screen/y DEO2
.selection LDZ GET-NOTE STHr ,draw-byte JSR
JMP2r
RTN
@draw-byte ( byte color -- )
@ -133,7 +139,7 @@ JMP2r
#0f AND GET-HEXCHAR
( draw ) STHr .Screen/sprite DEO
JMP2r
RTN
@melody
54 52 54 4f 4b 4f 48 ff

View file

@ -0,0 +1,23 @@
( dev/console )
(
Copies data from stdin to both stdout and stderr.
)
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
( init )
|0100 ( -> )
;on-stdin .Console/vector DEO2
BRK
@on-stdin ( -> )
.Console/read DEI
DUP .Console/write DEO
.Console/error DEO
BRK

View file

@ -0,0 +1,94 @@
( dev/console )
%RTN { JMP2r }
%PRINT { ;print JSR2 }
%BR { #0a .Console/write DEO }
( devices )
|10 @Console [ &pad $8 &write $1 ]
( variables )
|0000
@number [ &started $1 ]
( init )
|0100 ( -> )
;char-txt PRINT #42 .Console/write DEO BR
;byte-txt PRINT #ab ;print-byte JSR2 BR
;short-txt PRINT #cdef ;print-short JSR2 BR
;string-txt PRINT ;hello-word ;print JSR2 BR
;hello-word ;print JSR2
#ffff ;print-short JSR2
;is-word ;print JSR2
#ffff ;print-short-decimal JSR2
BRK
@print ( addr* -- )
&loop
( send ) LDAk .Console/write DEO
( incr ) INC2
( loop ) LDAk ,&loop JCN
POP2
RTN
@print-short ( short* -- )
LIT '0 .Console/write DEO
LIT 'x .Console/write DEO
OVR #04 SFT ,&hex JSR
SWP #0f AND ,&hex JSR
DUP #04 SFT ,&hex JSR
#0f AND ,&hex JMP
&hex
#30 ADD DUP #3a LTH ,&not-alpha JCN
#27 ADD
&not-alpha
.Console/write DEO
RTN
@print-byte ( byte -- )
LIT '0 .Console/write DEO
LIT 'x .Console/write DEO
DUP #04 SFT ,&hex JSR
#0f AND ,&hex JMP
&hex
#30 ADD DUP #39 GTH #27 MUL ADD .Console/write DEO
RTN
@print-short-decimal ( short -- )
#00 .number/started STZ
DUP2 #2710 DIV2 DUP2 ,&digit JSR #2710 MUL2 SUB2
DUP2 #03e8 DIV2 DUP2 ,&digit JSR #03e8 MUL2 SUB2
DUP2 #0064 DIV2 DUP2 ,&digit JSR #0064 MUL2 SUB2
DUP2 #000a DIV2 DUP2 ,&digit JSR #000a MUL2 SUB2
,&digit JSR
.number/started LDZ ,&end JCN
LIT '0 .Console/write DEO
&end
RTN
&digit
NIP
DUP .number/started LDZ ORA #02 JCN
POP JMP2r
LIT '0 ADD .Console/write DEO
#01 .number/started STZ
RTN
@char-txt "char: 20 $1
@byte-txt "byte: 20 $1
@short-txt "short: 20 $1
@string-txt "string: 20 $1
@hello-word "hello 20 "World! 0a 00
@is-word 20 "is 20 00

View file

@ -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

View file

@ -1,108 +1,19 @@
( usage: uxncli console.rom arg1 arg2 arg3 Prints Hello Uxn!, and listens for incoming stdin events on enter. )
( dev/console )
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
%HALT { #010f DEO }
%EMIT { #18 DEO }
|0000
( init )
@buf
|0100 ( -> )
|0100
;hello-word
&while
( send ) LDAk EMIT
INC2 LDAk ,&while JCN
POP2
( stop ) HALT
@on-reset ( -> )
;on-argument .Console/vector DEO2
.Console/type DEI ?{ ;on-stdin .Console/vector DEO2 }
;dict/hello <print-str>
BRK
@on-argument ( -> )
.Console/read DEI .buf skey ?{ BRK }
<print-type>
;dict/yousent <print-str>
LIT "" #18 DEO
;buf <print-str>/
LIT "" #18 DEO
#0a18 DEO
;buf sclr/ .Console/type DEI #04 NEQ ?{
;dict/argend <print-str>
;on-stdin .Console/vector DEO2 }
BRK
@on-stdin ( -> )
.Console/read DEI .buf skey ?{ BRK }
;buf ;dict/quit scmp ?&quit
<print-type>
;dict/yousaid <print-str>
LIT "" #18 DEO
;buf <print-str>/
LIT "" #18 DEO
#0a18 DEO
;buf sclr/ BRK
&quit ( buf* -> )
#800f DEO
BRK
@<print-type> ( -- )
[ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2
( ) LDA2 !<print-str>/
(
@|stdlib )
@<print-str> ( str* -- )
&w ( -- )
LDAk #18 DEO
INC2 & LDAk ?&w
POP2 JMP2r
@sclr ( str* -- )
&w ( -- )
STH2k #00 STH2r STA
INC2 & LDAk ?&w
POP2 JMP2r
@skey ( key buf -- proc )
OVR #20 LTH ?{
#00 SWP sput #00 JMP2r }
POP2 #01 JMP2r
@scap ( str* -- end* )
&w ( -- )
INC2 & LDAk ?&w
JMP2r
@sput ( chr str* -- )
scap/ STA
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
@<phex> ( short* -- )
SWP <phex>/b
&b ( -- )
DUP #04 SFT <phex>/c
&c ( -- )
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
JMP2r
(
@|assets )
@types
=dict/std =dict/arg
@dict ( )
&hello "Welcome 20 "to 20 "Uxn! 0a $1
&yousaid "You 20 "said: 20 $1
&yousent "You 20 "sent: 20 $1
&std "(std) $1
&arg "(arg) $1
&quit "quit $1
&argend "(argend) 0a $1
BRK
@hello-word "Hello 20 "Uxn! $1

View file

@ -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

View file

@ -1,162 +1,185 @@
( Controller: Buttons should highlight on press and display the button and key bytes. )
( dev/controller/keys )
|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
%+ { ADD } %- { SUB } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%RTN { JMP2r }
%TOS { #00 SWP }
%LTS2 { #8000 ++ SWP2 #8000 ++ >> }
( 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 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
( variables )
|0000
@center &x $2 &y $2
@frame &w $2 &h $2 &x0 $2 &y0 $2 &x1 $2 &y1 $2
@center
&x $2
&y $2
@frame
&w $2 &h $2
&x0 $2 &y0 $2
&x1 $2 &y1 $2
@color $1
@rect
&x1 $2 &y1 $2
&x2 $2 &y2 $2
|0100
( init )
@on-reset ( -> )
( | theme )
#0fff .System/r DEO2
#0f0f .System/g DEO2
#0f0f .System/b DEO2
( | find center )
|0100 ( -> )
( theme )
#0ff7 .System/r DEO2
#0f07 .System/g DEO2
#0f07 .System/b DEO2
( find center )
.Screen/width DEI2 #01 SFT2 .center/x STZ2
.Screen/height DEI2 #01 SFT2 .center/y STZ2
( | place controller )
( place controller )
#0068 .frame/w STZ2
#0030 .frame/h STZ2
.center/x LDZ2 .frame/w LDZ2 #01 SFT2 SUB2 .frame/x0 STZ2
.center/y LDZ2 .frame/h LDZ2 #01 SFT2 SUB2 .frame/y0 STZ2
.frame/x0 LDZ2 .frame/w LDZ2 ADD2 .frame/x1 STZ2
.frame/y0 LDZ2 .frame/h LDZ2 ADD2 .frame/y1 STZ2
( | vectors )
.center/x LDZ2 .frame/w LDZ2 #0002 // -- .frame/x0 STZ2
.center/y LDZ2 .frame/h LDZ2 #0002 // -- .frame/y0 STZ2
.frame/x0 LDZ2 .frame/w LDZ2 ++ .frame/x1 STZ2
.frame/y0 LDZ2 .frame/h LDZ2 ++ .frame/y1 STZ2
( vectors )
;on-button .Controller/vector DEO2
( | frame )
.frame/x0 LDZ2 .frame/y0 LDZ2 .frame/x1 LDZ2 .frame/y1 LDZ2 #03 <line-rect>
<draw-controller>
BRK
;draw-controller JSR2
BRK
@on-button ( -> )
<draw-controller>
( | print stack on start button )
[ LIT2 08 -Controller/button ] DEI NEQ ?{ #010e DEO }
BRK
(
@|drawing )
;draw-controller JSR2
BRK
@draw-controller ( -- )
@<draw-controller> ( -- )
.Controller/button DEI STH
( | d-pad )
.frame/x0 LDZ2 #0010 ADD2 .Screen/x DEO2
.frame/y0 LDZ2 #0010 ADD2 .Screen/y DEO2
;dpad-up-icn .Screen/addr DEO2
#03 STHkr #04 SFT #01 AND SUB .Screen/sprite DEO
.Screen/y DEI2 #0010 ADD2 .Screen/y DEO2
;dpad-down-icn .Screen/addr DEO2
#03 STHkr #05 SFT #01 AND SUB .Screen/sprite DEO
.Screen/y DEI2 #0008 SUB2 .Screen/y DEO2
.Screen/x DEI2 #0008 SUB2 .Screen/x DEO2
;dpad-left-icn .Screen/addr DEO2
#03 STHkr #06 SFT #01 AND SUB .Screen/sprite DEO
.Screen/x DEI2 #0010 ADD2 .Screen/x DEO2
;dpad-right-icn .Screen/addr DEO2
#03 STHkr #07 SFT #01 AND SUB .Screen/sprite DEO
.Screen/x DEI2 #0008 SUB2 .Screen/x DEO2
;fill-icn .Screen/addr DEO2
[ LIT2 03 -Screen/sprite ] DEO
( | options )
.center/y LDZ2 #0009 ADD2 .Screen/y DEO2
.center/x LDZ2 #0009 SUB2 .Screen/x DEO2
;option-icn .Screen/addr DEO2
#03 STHkr #03 SFT #01 AND SUB .Screen/sprite DEO
.center/x LDZ2 #0004 ADD2 .Screen/x DEO2
;option-icn .Screen/addr DEO2
#03 STHkr #02 SFT #01 AND SUB .Screen/sprite DEO
( | buttons )
.center/y LDZ2 .Screen/y DEO2
.center/x LDZ2 #0018 ADD2 .Screen/x DEO2
;button-icn .Screen/addr DEO2
#03 STHkr #01 SFT #01 AND SUB .Screen/sprite DEO
.Screen/y DEI2 #000a ADD2 .Screen/y DEO2
;font-hex/b .Screen/addr DEO2
[ LIT2 03 -Screen/sprite ] DEO
.center/y LDZ2 .Screen/y DEO2
.center/x LDZ2 #0024 ADD2 .Screen/x DEO2
;button-icn .Screen/addr DEO2
#03 STHr #01 AND SUB .Screen/sprite DEO
.Screen/y DEI2 #000a ADD2 .Screen/y DEO2
;font-hex/a .Screen/addr DEO2
[ LIT2 03 -Screen/sprite ] DEO
.center/x LDZ2 #0010 SUB2 .Screen/x DEO2
.center/y LDZ2 #0010 SUB2 .Screen/y DEO2
[ LIT2 01 -Screen/auto ] DEO
.Controller/button DEI2 <draw-short>
[ LIT2 00 -Screen/auto ] DEO
JMP2r
@<draw-short> ( short* -- )
SWP <draw-byte>
( frame )
.frame/x0 LDZ2 .frame/y0 LDZ2
.frame/x1 LDZ2 .frame/y1 LDZ2
#01 ;line-rect JSR2
( d-pad )
.frame/x0 LDZ2 #0010 ++ .Screen/x DEO2
.frame/y0 LDZ2 #0010 ++ .Screen/y DEO2
;controller-icn/dpad-up .Screen/addr DEO2
#03 [ STHkr #04 SFT #01 AND DUP + - ] .Screen/sprite DEO
.Screen/y DEI2 #0010 ++ .Screen/y DEO2
;controller-icn/dpad-down .Screen/addr DEO2
#03 [ STHkr #05 SFT #01 AND DUP + - ] .Screen/sprite DEO
.Screen/y DEI2 #0008 -- .Screen/y DEO2
.Screen/x DEI2 #0008 -- .Screen/x DEO2
;controller-icn/dpad-left .Screen/addr DEO2
#03 [ STHkr #06 SFT #01 AND DUP + - ] .Screen/sprite DEO
.Screen/x DEI2 #0010 ++ .Screen/x DEO2
;controller-icn/dpad-right .Screen/addr DEO2
#03 [ STHkr #07 SFT #01 AND DUP + - ] .Screen/sprite DEO
.Screen/x DEI2 #0008 -- .Screen/x DEO2
;controller-icn/dpad .Screen/addr DEO2
#03 .Screen/sprite DEO
@<draw-byte> ( byte -- )
DUP #04 SFT <draw-hex>
( options )
.center/y LDZ2 #0009 ++ .Screen/y DEO2
.center/x LDZ2 #0009 -- .Screen/x DEO2
;controller-icn/option .Screen/addr DEO2
#03 [ STHkr #02 SFT #01 AND DUP + - ] .Screen/sprite DEO
.center/x LDZ2 #0004 ++ .Screen/x DEO2
;controller-icn/option .Screen/addr DEO2
#03 [ STHkr #03 SFT #01 AND DUP + - ] .Screen/sprite DEO
@<draw-hex> ( char -- )
#00 SWP #0f AND #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
[ LIT2 03 -Screen/sprite ] DEO
JMP2r
( buttons )
.center/y LDZ2 #0000 ++ .Screen/y DEO2
.center/x LDZ2 #0018 ++ .Screen/x DEO2
;controller-icn/button .Screen/addr DEO2
#03 [ STHkr #01 SFT #01 AND - ] .Screen/sprite DEO
.Screen/y DEI2 #000a ++ .Screen/y DEO2
;font-hex #000b #30 SFT2 ++ .Screen/addr DEO2
#03 .Screen/sprite DEO
@<line-rect> ( x1* y1* x2* y2* color -- )
STH
DUP2 ,&ver-y2 STR2
,&hor-y2 STR2
DUP2 ,&ver-x2 STR2
,&hor-x2 STR2
DUP2 ,&ver-y1 STR2
,&hor-y1 STR2
DUP2 ,&ver-x1 STR2
,&hor-x1 STR2
( | horizontal )
[ LIT2 &hor-x2 $2 ] INC2 [ LIT2 &hor-x1 $2 ]
&hor ( -- )
DUP2 .Screen/x DEO2
[ LIT2 &hor-y1 $2 ] .Screen/y DEO2
STHkr .Screen/pixel DEOk [ LIT2 &hor-y2 $2 ] .Screen/y DEO2
DEO
INC2 GTH2k ?&hor
.center/y LDZ2 #0000 ++ .Screen/y DEO2
.center/x LDZ2 #0024 ++ .Screen/x DEO2
;controller-icn/button .Screen/addr DEO2
#03 [ STHr #01 AND - ] .Screen/sprite DEO
.Screen/y DEI2 #000a ++ .Screen/y DEO2
;font-hex #000a #30 SFT2 ++ .Screen/addr DEO2
#03 .Screen/sprite DEO
.center/x LDZ2 #0010 -- .Screen/x DEO2
.center/y LDZ2 #0010 -- .Screen/y DEO2
.Controller/button DEI2 #03 ;draw-short JSR2
RTN
( generics )
@draw-short ( short* color -- )
STH SWP
DUP #04 SFT TOS #30 SFT2 ;font-hex ++ .Screen/addr DEO2
( draw ) STHkr .Screen/sprite DEO
#0f AND TOS #30 SFT2 ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
DUP #04 SFT TOS #30 SFT2 ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
#0f AND TOS #30 SFT2 ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHr .Screen/sprite DEO
RTN
@line-rect ( x1* y1* x2* y2* color -- )
( load ) .color STZ DUP2 STH2 .rect/y2 STZ2 .rect/x2 STZ2 DUP2 STH2 .rect/y1 STZ2 .rect/x1 STZ2
STH2r INC2 STH2r
&ver
( save ) OVR2 .Screen/y DEO2
( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/pixel DEO
( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .Screen/pixel DEO
( incr ) SWP2 INC2 SWP2
OVR2 OVR2 LTS2 ,&ver JCN
POP2 POP2
.rect/x1 LDZ2 INC2 .rect/x2 LDZ2 #0001 --
&hor
( save ) OVR2 .Screen/x DEO2
( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/pixel DEO
( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/pixel DEO
( incr ) SWP2 INC2 SWP2
OVR2 OVR2 INC2 LTS2 ,&hor JCN
POP2 POP2
( | vertical )
[ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ]
&ver ( -- )
DUP2 .Screen/y DEO2
[ LIT2 &ver-x1 $2 ] .Screen/x DEO2
STHkr .Screen/pixel DEOk [ LIT2 &ver-x2 $2 ] .Screen/x DEO2
DEO
INC2 GTH2k ?&ver
POP2 POP2 POPr JMP2r
(
@|assets )
RTN
@fill-icn [ ffff ffff ffff ffff ]
@dpad-up-icn [ 7eff e7c3 ffff ffff ]
@dpad-down-icn [ ffff ffff c3e7 ff7e ]
@dpad-left-icn [ 7fff efcf cfef ff7f ]
@dpad-right-icn [ feff f7f3 f3f7 fffe ]
@option-icn [ 0000 7eff ff7e 0000 ]
@button-icn [ 3c7e ffff ffff 7e3c ]
@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 00fe 0202 0408 1010
007c 8282 7c82 827c 007c 8282 7e02 827c
&a 007c 8202 7e82 827e &b 00fc 8282
fc82 82fc 007c 8280 8080 827c 00fc 8282
8282 82fc 00fe 8080 fe80 80fe 00fe 8080
f080 8080 ]
@controller-icn
&dpad ffff ffff ffff ffff
&dpad-up 7eff e7c3 ffff ffff
&dpad-down ffff ffff c3e7 ff7e
&dpad-left 7fff efcf cfef ff7f
&dpad-right feff f7f3 f3f7 fffe
&option 0000 7eff ff7e 0000
&button 3c7e ffff ffff 7e3c
@font-hex
003c 4242 4242 3c00 0018 0808 0808 1c00
003c 4202 3c40 7e00 003c 421c 0242 3c00
000c 1424 447e 0400 007e 407c 0242 3c00
003c 407c 4242 3c00 007e 0204 0810 1000
003c 423c 4242 3c00 003c 4242 3e02 3c00
003c 4242 7e42 4200 007c 427c 4242 7c00
003c 4240 4042 3c00 007c 4242 4242 7c00
007e 4078 4040 7e00 007e 4078 4040 4000

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,133 @@
( simple Dev/File reading example )
( 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 ]
|a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ]
( variables )
|0000
( program )
|0100 ( -> )
;try-load JSR2
BRK
@try-load ( -- )
( load contents from file )
#1000 .File/length DEO2
;filename .File/name DEO2
;contents .File/read DEO2
.File/success DEI2 ORA ,&success JCN
( failed to read: bright yellow background )
#f0f7 .System/r DEO2
#f0f7 .System/g DEO2
#00f7 .System/b DEO2
JMP2r
&success
( read successful: dark blue background, show contents )
#00f7 .System/r DEO2
#00f7 .System/g DEO2
#40f7 .System/b DEO2
;contents DUP2 .File/success DEI2 ADD2 SWP2 ;draw JSR2
JMP2r
@draw ( end-ptr* ptr* -- )
EQU2k ,&end JCN
LDAk
DUP #0a EQU ,&linefeed JCN
#0005 SFT2 ;font ADD2
.Screen/addr DEO2
#09 .Screen/sprite DEO
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
&next
INC2
,draw JMP
&linefeed
POP
#0000 .Screen/x DEO2
.Screen/y DEI2 #0008 ADD2 .Screen/y DEO2
,&next JMP
&end
POP2 POP2
JMP2r
@get-x-advance ( font-char-addr* -- advance* )
( Save two 00 bytes for later use )
#0000 SWP2
( First, load the eight bytes that make up the character )
LDA2k SWP2 #0002 ADD2
LDA2k SWP2 #0002 ADD2
LDA2k SWP2 #0002 ADD2
LDA2
( OR all the bytes together, so we know which columns contain filled pixels )
ORA2 ORA2 ORA2 ORA
( Find the lowest set bit (using one of the 00 bytes at the top, but not consuming it) )
SUBk AND
( Convert the nine possible values (00-80) into an offset into the magic table (00-08). )
( They get jumbled up with these two operations, but each possible value remains unique )
#a3 MUL #16 DIV
( Load the byte from the magic table, return a short (consuming/returning the 00 bytes at the top) )
;&magic ADD2 LDA
JMP2r
( The magic table performs the last bit of arithmetic we want:
* the advance in x should be one more than the number of columns with filled pixels,
* with a maximum of 8, and
* a minimum of 3. )
&magic
03 ( lowest set bit is 00, 0 columns wide )
06 ( lowest set bit is 08, 5 columns wide )
05 ( lowest set bit is 10, 4 columns wide )
08 ( lowest set bit is 02, 7 columns wide )
04 ( lowest set bit is 20, 3 columns wide )
03 ( lowest set bit is 80, 1 column wide )
07 ( lowest set bit is 04, 6 columns wide )
08 ( lowest set bit is 01, 8 columns wide )
03 ( lowest set bit is 40, 2 columns wide )
@font ( spectrum-zx font )
[
0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000
007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000
0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800
0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800
003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038
0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000
0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000
0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400
0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000
0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800
0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000
003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00
0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000
003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810
0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800
003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00
0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00
0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200
0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00
007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00
00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200
0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00
0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00
0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00
0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c
0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400
0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800
0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800
0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800
0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
]
@filename "hello.txt 00
@contents

View file

@ -0,0 +1,41 @@
( simple Dev/File writing example )
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ]
( variables )
|0000
( init )
|0100 ( -> )
;try-save JSR2
BRK
@try-save ( -- )
( save contents to file )
;contents/end ;contents SUB2 .File/length DEO2
;filename .File/name DEO2
;contents .File/write DEO2
.File/success DEI2 ORA ,&success JCN
( failed to write: bright yellow background )
#f0f7 .System/r DEO2
#f0f7 .System/g DEO2
#00f7 .System/b DEO2
JMP2r
&success
( write successful: dark blue background )
#00f7 .System/r DEO2
#00f7 .System/g DEO2
#40f7 .System/b DEO2
JMP2r
@filename "hello.txt 00
@contents "Hello 20 "world, 0a "how 20 "are 20 "you? 0a
&end

View file

@ -1,97 +1,78 @@
( File:
Creates a temporary file called file-output.txt,
then read it back in console, print length and delete it. )
( Dev/File )
|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
%8+ { #0008 ADD2 }
%MEMORY { #1000 }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &pad $8 &write $1 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ]
( variables )
|0000
( init )
|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
( theme )
#0efc .System/r DEO2
#03cc .System/g DEO2
#03ac .System/b DEO2
( load file )
#1000 .File/length DEO2
;srcpath .File/name DEO2
MEMORY .File/read DEO2
.File/success DEI2 ORA ;on-success JCN2
;failedtxt ;print-string JSR2
BRK
@append ( part* -- )
@on-success ( -> )
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
;successtxt ;print-string JSR2
JMP2r
( draw image )
MEMORY .Screen/addr DEO2
#0000 #0080
&ver
( save ) OVR2 .Screen/y DEO2
#0000 #0080
&hor
( save ) OVR2 .Screen/x DEO2
( draw ) #81 .Screen/sprite DEO
( incr ) .Screen/addr DEI2 #0010 ADD2 .Screen/addr DEO2
( incr ) SWP2 8+ SWP2
LTH2k ,&hor JCN
POP2 POP2
( incr ) SWP2 8+ SWP2
LTH2k ,&ver JCN
POP2 POP2
@stream ( -- )
( save file )
#1000 .File/length DEO2
;dstpath .File/name DEO2
MEMORY .File/write DEO2
#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
BRK
JMP2r
&buf $1
@print-string ( ptr* -- )
LDAk DUP ,&keep-going JCN
POP POP2 JMP2r
@slen ( str* -- len* )
&keep-going
.Console/write DEO
INC2
,print-string JMP
DUP2 ,scap JSR SWP2 SUB2
@successtxt "Success! 09 $1
@failedtxt "Failed. 09 $1
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
@srcpath "projects/pictures/ako10x10.chr $1
@dstpath "bin/image-copy.chr $1

View file

@ -1,186 +1,120 @@
( Mouse: Paint with 3 colors with each mouse button. )
( dev/mouse )
%RTN { JMP2r }
%ABS2 { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 }
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
%2** { #10 SFT2 }
( 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 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|20 @Screen &vector $2 &width $2 &height $2 &pad $2 &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
@color $1
@line
&x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2
@pointer
&x $2 &y $2 &lastx $2 &lasty $2 &state $1
|0100
( program )
@on-reset ( -> )
( | theme )
#48af .System/r DEO2
#59bf .System/g DEO2
#6ace .System/b DEO2
( | vectors )
|0100 ( -> )
( theme )
#f030 .System/r DEO2
#f04f .System/g DEO2
#f050 .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
BRK
@on-mouse ( -> )
( | clear last cursor )
;draw-cursor JSR2
( on down )
.Mouse/state DEI #00 NEQ .pointer/state LDZ #00 EQU #0101 EQU2 ,on-mouse-down JCN
( on drag )
.Mouse/state DEI ,on-mouse-drag JCN
.Mouse/state DEI .pointer/state STZ
BRK
@on-mouse-down ( -> )
( 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
@on-mouse-drag ( -> )
( draw line )
.pointer/lastx LDZ2
.pointer/lasty LDZ2
.pointer/x LDZ2
.pointer/y LDZ2
#01 [ .Mouse/state DEI #10 EQU DUP ADD ADD ]
;draw-line JSR2
( record last position )
.Mouse/x DEI2 .pointer/lastx STZ2
.Mouse/y DEI2 .pointer/lasty STZ2
.Mouse/state DEI .pointer/state STZ
BRK
@draw-cursor ( -- )
;pointer-icn .Screen/addr DEO2
( 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
#40 .Screen/sprite DEO
(
@|main )
( draw new cursor )
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
#43 .Mouse/state DEI #00 NEQ DUP ADD SUB .Screen/sprite DEO
@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
RTN
@<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 -- )
@<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
( load ) .color STZ .line/y0 STZ2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2
.line/x0 LDZ2 .line/x LDZ2 SUB2 ABS2 .line/dx STZ2
.line/y0 LDZ2 .line/y LDZ2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy STZ2
#ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ADD2 .line/sx STZ2
#ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 2** ADD2 .line/sy STZ2
.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
&loop
.line/x LDZ2 .Screen/x DEO2
.line/y LDZ2 .Screen/y DEO2
.color LDZ .Screen/pixel DEO
[ .line/x LDZ2 .line/x0 LDZ2 EQU2 ]
[ .line/y LDZ2 .line/y0 LDZ2 EQU2 ] #0101 EQU2 ,&end JCN
.line/e1 LDZ2 2** .line/e2 STZ2
.line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN
.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
.line/x LDZ2 .line/sx LDZ2 ADD2 .line/x STZ2
&skipy
.line/e2 LDZ2 .line/dx LDZ2 GTS2 ,&skipx JCN
.line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2
.line/y LDZ2 .line/sy LDZ2 ADD2 .line/y STZ2
&skipx
;&loop JMP2
&end
RTN
@pointer-icn 80c0 e0f0 f8e0 1000

View file

@ -1,152 +0,0 @@
( All five portraits should look right )
|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
( | size )
#00a0 .Screen/width DEO2
#0020 .Screen/height DEO2
( | theme )
#05ae .System/r DEO2
#0a9f .System/g DEO2
#097f .System/b DEO2
( | normal horizontal )
#0000 .Screen/x DEO2
#0000 .Screen/y DEO2
[ LIT2 35 -Screen/auto ] DEO
;img-hor .Screen/addr DEO2
#85 <draw-4times>
( | normal vertical )
#0020 .Screen/x DEO2
#0000 .Screen/y DEO2
[ LIT2 36 -Screen/auto ] DEO
;img-ver .Screen/addr DEO2
#85 <draw-4times>
( | flipped horizontal )
#0058 .Screen/x DEO2
#0000 .Screen/y DEO2
[ LIT2 36 -Screen/auto ] DEO
;img-x-flipped .Screen/addr DEO2
#95 <draw-4times>
( | flipped vertical )
#0060 .Screen/x DEO2
#0018 .Screen/y DEO2
[ LIT2 36 -Screen/auto ] DEO
;img-y-flipped .Screen/addr DEO2
#a5 <draw-4times>
( | flipped horizontal/vertical )
#0098 .Screen/x DEO2
#0018 .Screen/y DEO2
[ LIT2 36 -Screen/auto ] DEO
;img-xy-flipped .Screen/addr DEO2
#b5 <draw-4times>
BRK
@<draw-4times> ( color -- )
.Screen/sprite DEOk DEOk DEOk DEO
JMP2r
@draw-fast ( w h addr* color -- )
,&color STR
.Screen/addr DEO2
SWP #01 SUB #40 SFT #06 ORA .Screen/auto DEO
#00 SWP SUB
&times ( -- )
[ LIT2 &color $1 -Screen/sprite ] DEO
INC DUP ?&times
POP JMP2r
(
@|assets )
@img-ver [
0000 0008 0404 0501 ffff fff7 fbfa f9f9
0000 1000 21ff ffff ffff efde 21ff ffff
2020 0060 f8ff fffc dfdf 9f67 f8ff fffc
0703 2110 0888 c851 e7fb ddee 76b6 d64d
0307 0617 172f 080c fbf7 f6e5 e7cf e8ec
ffef 1fff ff1f 0f37 f7ef 1fff 8f07 0733
fbff ffff fcf8 f3f7 fbf7 fff8 f0f0 f1f1
d3d7 c783 0100 0040 8bc7 d79b 1d3e 3e5e
0e06 0301 0101 0505 eef6 fbfd fdfd f9f9
7bfb 3fff ffff ffff 3b3b 3fff ffff ffff
f7f7 f7ff fff7 fffb f3ff fff3 fbff ffe3
c0e0 e0e4 e5e3 c7cf feee eeea e9eb f7cf
3800 0103 c7ff ffff c6fe fd3b c7ff ffff
ff7f 3f0f a0b8 bebf ff7f 3f5f b1bf bfbf
dfbf fefd fb07 0fdf c387 fefd fb07 efdf
bf7f ffff ffff ffff bf7f ffff ffff ffff ]
@img-hor [
0000 0008 0404 0501 ffff fff7 fbfa f9f9
0307 0617 172f 080c fbf7 f6e5 e7cf e8ec
0e06 0301 0101 0505 eef6 fbfd fdfd f9f9
3800 0103 c7ff ffff c6fe fd3b c7ff ffff
0000 1000 21ff ffff ffff efde 21ff ffff
ffef 1fff ff1f 0f37 f7ef 1fff 8f07 0733
7bfb 3fff ffff ffff 3b3b 3fff ffff ffff
ff7f 3f0f a0b8 bebf ff7f 3f5f b1bf bfbf
2020 0060 f8ff fffc dfdf 9f67 f8ff fffc
fbff ffff fcf8 f3f7 fbf7 fff8 f0f0 f1f1
f7f7 f7ff fff7 fffb f3ff fff3 fbff ffe3
dfbf fefd fb07 0fdf c387 fefd fb07 efdf
0703 2110 0888 c851 e7fb ddee 76b6 d64d
d3d7 c783 0100 0040 8bc7 d79b 1d3e 3e5e
c0e0 e0e4 e5e3 c7cf feee eeea e9eb f7cf
bf7f ffff ffff ffff bf7f ffff ffff ffff ]
@img-x-flipped [
e0c0 8408 1011 138a e7df bb77 6e6d 6bb2
0404 0006 1fff ff3f fbfb f9e6 1fff ff3f
0000 0800 84ff ffff ffff f77b 84ff ffff
0000 0010 2020 a080 ffff ffef df5f 9f9f
cbeb e3c1 8000 0002 d1e3 ebd9 b87c 7c7a
dfff ffff 3f1f cfef dfef ff1f 0f0f 8f8f
fff7 f8ff fff8 f0ec eff7 f8ff f1e0 e0cc
c0e0 60e8 e8f4 1030 dfef 6fa7 e7f3 1737
0307 0727 a7c7 e3f3 7f77 7757 97d7 eff3
efef efff ffef ffdf cfff ffcf dfff ffc7
dedf fcff ffff ffff dcdc fcff ffff ffff
7060 c080 8080 a0a0 776f dfbf bfbf 9f9f
fdfe ffff ffff ffff fdfe ffff ffff ffff
fbfd 7fbf dfe0 f0fb c3e1 7fbf dfe0 f7fb
fffe fcf0 051d 7dfd fffe fcfa 8dfd fdfd
1c00 80c0 e3ff ffff 637f bfdc e3ff ffff ]
@img-y-flipped [
ffff ffc7 0301 0038 ffff ffc7 3bfd fec6
bfbe b8a0 0f3f 7fff bfbf bfb1 5f3f 7fff
df0f 07fb fdfe bfdf dfef 07fb fdfe 87c3
ffff ffff ffff 7fbf ffff ffff ffff 7fbf
0505 0101 0103 060e f9f9 fdfd fdfb f6ee
ffff ffff ff3f fb7b ffff ffff ff3f 3b3b
fbff f7ff fff7 f7f7 e3ff fffb f3ff fff3
cfc7 e3e5 e4e0 e0c0 cff7 ebe9 eaee eefe
0c08 2f17 1706 0703 ece8 cfe7 e5f6 f7fb
370f 1fff ff1f efff 3307 078f ff1f eff7
f7f3 f8fc ffff fffb f1f1 f0f0 f8ff f7fb
4000 0001 83c7 d7d3 5e3e 3e1d 9bd7 c78b
0105 0404 0800 0000 f9f9 fafb f7ff ffff
ffff ff21 0010 0000 ffff ff21 deef ffff
fcff fff8 6000 2020 fcff fff8 679f dfdf
51c8 8808 1021 0307 4dd6 b676 eedd fbe7 ]
@img-xy-flipped [
ffff ffff ffff fefd ffff ffff ffff fefd
fbf0 e0df bf7f fdfb fbf7 e0df bf7f e1c3
fd7d 1d05 f0fc feff fdfd fd8d fafc feff
ffff ffe3 c080 001c ffff ffe3 dcbf 7f63
f3e3 c7a7 2707 0703 f3ef d797 5777 777f
dfff efff ffef efef c7ff ffdf cfff ffcf
ffff ffff fffc dfde ffff ffff fffc dcdc
a0a0 8080 80c0 6070 9f9f bfbf bfdf 6f77
0200 0080 c1e3 ebcb 7a7c 7cb8 d9eb e3d1
efcf 1f3f ffff ffdf 8f8f 0f0f 1fff efdf
ecf0 f8ff fff8 f7ff cce0 e0f1 fff8 f7ef
3010 f4e8 e860 e0c0 3717 f3e7 a76f efdf
8a13 1110 0884 c0e0 b26b 6d6e 77bb dfe7
3fff ff1f 0600 0404 3fff ff1f e6f9 fbfb
ffff ff84 0008 0000 ffff ff84 7bf7 ffff
80a0 2020 1000 0000 9f9f 5fdf efff ffff ]

View file

@ -1,94 +0,0 @@
( screen blending modes )
|00 @System &catch $2 &expansion $2 &pad $2 &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
|0100
@on-reset ( -> )
( | theme )
#f07f .System/r DEO2
#f0d6 .System/g DEO2
#f0b2 .System/b DEO2
( | size )
#0100 .Screen/width DEO2
#010c .Screen/height DEO2
( | background )
#02 <draw-strippes>
#0080 .Screen/x DEO2
#0000 .Screen/y DEO2
#03 <draw-strippes>
( | 1bpp )
#1000
&l1bg ( -- )
#00 OVR #03 AND #50 SFT2 #0008 ADD2 .Screen/x DEO2
#00 OVR #02 SFT #50 SFT2 #0008 ADD2 .Screen/y DEO2
DUP <draw-circle>
INC GTHk ?&l1bg
POP2
#1000
&l1fg ( -- )
#00 OVR #03 AND #50 SFT2 #0088 ADD2 .Screen/x DEO2
#00 OVR #02 SFT #50 SFT2 #0008 ADD2 .Screen/y DEO2
DUP #40 ORA <draw-circle>
INC GTHk ?&l1fg
POP2
( | 2bpp )
#1000
&l2bg ( -- )
#00 OVR #03 AND #50 SFT2 #0008 ADD2 .Screen/x DEO2
#00 OVR #02 SFT #50 SFT2 #0088 ADD2 .Screen/y DEO2
DUP #80 ORA <draw-circle>
INC GTHk ?&l2bg
POP2
#1000
&l2fg ( -- )
#00 OVR #03 AND #50 SFT2 #0088 ADD2 .Screen/x DEO2
#00 OVR #02 SFT #50 SFT2 #0088 ADD2 .Screen/y DEO2
DUP #c0 ORA <draw-circle>
INC GTHk ?&l2fg
POP2
BRK
@<draw-strippes> ( color -- )
,&color STR
#f2 .Screen/auto DEO
;check-icn .Screen/addr DEO2
#2200
&times ( -- )
[ LIT &color $1 ] .Screen/sprite DEO
INC GTHk ?&times
POP2
JMP2r
@<draw-circle> ( color -- )
#01 .Screen/auto DEO
;circle-chr .Screen/addr DEO2
DUP .Screen/sprite DEO
DUP #10 ORA .Screen/sprite DEO
.Screen/y DEI2k #0008 ADD2 ROT DEO2
DUP #20 ORA .Screen/sprite DEO
DUP #30 ORA .Screen/sprite DEO
@<draw-hex> ( color -- )
.Screen/y DEI2k #000c ADD2 ROT DEO2
#00 SWP #30 SFT ;font-icn ADD2 .Screen/addr DEO2
#09 .Screen/sprite DEO
JMP2r
@check-icn [ 0306 0c18 3060 c081 ]
@circle-chr [
071f 3c70 60e3 c7c7 0000 030f 1f1f 3f3f ]
@font-icn ( 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 ]

View file

@ -1,141 +0,0 @@
|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 &scrollx $2 &scrolly $2
|0100
@on-reset ( -> )
#375e .System/r DEO2
#286c .System/g DEO2
#2358 .System/b DEO2
;on-mouse .Mouse/vector DEO2
<draw-guide>
BRK
@on-mouse ( -> )
( | clear background )
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
#80 .Screen/pixel DEO
<draw-guide>
( | cursor )
#41 ;cursor-icn <update-cursor>
( | draw portrait )
.Screen/x DEI2k #0008 ADD2 ROT DEO2
.Screen/y DEI2k #0020 SUB2 ROT DEO2
[ LIT2 36 -Screen/auto ] DEO
#81 <draw-portrait>
.Screen/x DEI2k #0010 SUB2 ROT DEO2
.Screen/y DEI2k #0020 SUB2 ROT DEO2
#91 <draw-portrait>
.Screen/x DEI2k #0000 SUB2 ROT DEO2
.Screen/y DEI2k #0020 ADD2 ROT DEO2
#b1 <draw-portrait>
.Screen/x DEI2k #0010 ADD2 ROT DEO2
.Screen/y DEI2k #0020 ADD2 ROT DEO2
#a1 <draw-portrait>
( <draw-box>
.Screen/y DEI2k #0060 SUB2 ROT DEO2
<draw-box> )
BRK
@<draw-portrait> ( color -- )
;portrait-chr .Screen/addr DEO2
.Screen/sprite DEOk DEOk DEOk DEO
JMP2r
@<draw-box> ( -- )
;box-icn .Screen/addr DEO2
#05 .Screen/sprite DEOk DEOk DEOk DEO
JMP2r
@<draw-circle> ( color -- )
#01 .Screen/auto DEO
;circle-chr .Screen/addr DEO2
DUP .Screen/sprite DEO
DUP #10 ORA .Screen/sprite DEO
.Screen/y DEI2k #0008 ADD2 ROT DEO2
DUP #20 ORA .Screen/sprite DEO
#30 ORA .Screen/sprite DEO
JMP2r
@<draw-guide> ( -- )
#0000 DUP2 .Screen/x DEO2 .Screen/y DEO2
#f2 .Screen/auto DEO
;guide-icn .Screen/addr DEO2
#1000
&l ( -- )
#01 .Screen/sprite DEO
INC GTHk ?&l
POP2
( | circles )
#0010 DUP2 .Screen/x DEO2 .Screen/y DEO2
#02 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#82 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#05 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#85 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#03 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#83 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#0a <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#8a <draw-circle>
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
@guide-icn [ 0101 0101 0101 01ff ]
@fill-icn [ ffff ffff ffff ffff ]
@cursor-icn [ 80c0 e0f0 f8e0 1000 ]
@portrait-chr [
070f 1e1d 1b3b 3b3b f0e0 c0c0 d08b 8080
f76f cf9f 9f5f 5f5f 0000 0007 1c40 4040
fffb f975 7576 7667 0000 3164 0406 0607
efef efef eddd 9e1e 0060 8000 0000 0000
3b2b 280d 0105 0506 8080 8081 e1f1 f1f0
5f6c 639b 0f27 77ab 4060 639b 0f27 67ab
0dc8 b0e5 cded fdfc 0dc8 b0e4 ccec fcfc
5e1e 1c9c 9d1d 5d59 4000 0080 8000 4040
0607 0707 070e 0e0e f0f0 f0f0 f0e0 e0e0
fb73 7fb7 bbbf bfdd f373 7b37 3b3f 3f1c
ffff ffff ffff ffff ffff ffff ffff ff7f
dba7 97f7 f7ed dd9d c080 90f0 f0e0 c080
1e0e 0000 0000 0000 c0c0 f0ff ffff ffff
ee03 0000 0000 0000 0e12 fcff ffff ffff
fffc f30f 1f1f 1f3f 9f3c f30f dfdf dfbf
3c80 8080 80c0 c0e0 0003 3fbf bfbf dfef ]
@box-icn [
001f 2050 4844 4241 00ff 0000 0000 0000
00ff 0000 0000 0000 00f8 040a 1222 4282
4040 4040 4040 4040 8040 2010 0804 0201
0102 0408 1020 4080 0202 0202 0202 0202
4040 4040 4040 4040 0102 0408 1020 4080
8040 2010 0804 0201 0202 0202 0202 0202
4142 4448 5020 1f00 0000 0000 0000 ff00
0000 0000 0000 ff00 8242 2212 0a04 f800 ]
@circle-chr [
071f 3c70 60e3 c7c7 0000 030f 1f1f 3f3f ]

View file

@ -1,96 +0,0 @@
( Screen.pixel: test rom for screen pixel drawing )
|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
|0000
@center &x $2 &y $2
|0100
@on-reset ( -> )
( | theme )
#f07f .System/r DEO2
#f0d6 .System/g DEO2
#f0b2 .System/b DEO2
( | resize )
#00c8 DUP2 .Screen/width DEO2
.Screen/height DEO2
( | find screen center )
.Screen/width DEI2 #01 SFT2 .center/x STZ2
.Screen/height DEI2 #01 SFT2 .center/y STZ2
( | draw )
<draw-bg-fill>
<draw-bg-corners>
<draw-fg-corners>
<draw-pixels>
BRK
@<draw-bg-fill> ( -- )
.center/x LDZ2 .Screen/x DEO2
.center/x LDZ2 .Screen/y DEO2
( | 4-way backgrounds )
#0400
&l ( -- )
DUP DUP #40 SFT #80 ADD ORA .Screen/pixel DEO
INC GTHk ?&l
POP2 JMP2r
@<draw-bg-corners> ( -- )
.center/x LDZ2 #01 SFT2 .Screen/x DEO2
.center/y LDZ2 #01 SFT2 .Screen/y DEO2
#b0 .Screen/pixel DEO
.center/x LDZ2 #01 SFT2 #0003 MUL2 .Screen/x DEO2
.center/y LDZ2 #01 SFT2 .Screen/y DEO2
#a1 .Screen/pixel DEO
.center/x LDZ2 #01 SFT2 #0003 MUL2 .Screen/x DEO2
.center/y LDZ2 #01 SFT2 #0003 MUL2 .Screen/y DEO2
#83 .Screen/pixel DEO
.center/x LDZ2 #01 SFT2 .Screen/x DEO2
.center/y LDZ2 #01 SFT2 #0003 MUL2 .Screen/y DEO2
#92 .Screen/pixel DEO
JMP2r
@<draw-fg-corners> ( -- )
.center/x LDZ2 #02 SFT2 .Screen/x DEO2
.center/y LDZ2 #02 SFT2 .Screen/y DEO2
#f1 .Screen/pixel DEO
.center/x LDZ2 #02 SFT2 #0007 MUL2 .Screen/x DEO2
.center/y LDZ2 #02 SFT2 .Screen/y DEO2
#e3 .Screen/pixel DEO
( clear ) #e0 .Screen/pixel DEO
.center/x LDZ2 #02 SFT2 #0007 MUL2 .Screen/x DEO2
.center/y LDZ2 #02 SFT2 #0007 MUL2 .Screen/y DEO2
#c2 .Screen/pixel DEO
.center/x LDZ2 #02 SFT2 .Screen/x DEO2
.center/y LDZ2 #02 SFT2 #0007 MUL2 .Screen/y DEO2
#d0 .Screen/pixel DEO
JMP2r
@<draw-pixels> ( -- )
( | bottom-left, background )
.center/x LDZ2 #0010 SUB2 .Screen/x DEO2
.center/y LDZ2 .Screen/y DEO2
( auto-x ) #01 .Screen/auto DEO
#00
&bl ( -- )
#00 OVR EQU OVR #0f AND ORA ?{
.center/x LDZ2 #0010 SUB2 .Screen/x DEO2
.Screen/y DEI2k INC2 ROT DEO2 }
DUP #04 SFT OVR #0f AND LTH INC .Screen/pixel DEO
INC DUP ?&bl
POP
( | bottom-right, foreground )
.center/x LDZ2 .Screen/x DEO2
.center/y LDZ2 #0010 SUB2 .Screen/y DEO2
( auto-y ) #02 .Screen/auto DEO
#00
&br ( -- )
#00 OVR EQU OVR #0f AND ORA ?{
.center/y LDZ2 #0010 SUB2 .Screen/y DEO2
.Screen/x DEI2k INC2 ROT DEO2 }
DUP #04 SFT OVR #0f AND GTH INC #40 ORA .Screen/pixel DEO
INC DUP ?&br
POP JMP2r

View file

@ -1,201 +1,172 @@
( Screen:
Draws a table of all possible sprite arrangements. )
( dev/screen )
|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 &chord $1
%RTN { JMP2r }
%2/ { #01 SFT }
%4/ { #02 SFT }
( 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 ]
( variables )
|0000
@center &x $2 &y $2
@count $2
@center
&x $2 &y $2
( init )
|0100 ( -> )
( vector )
;on-frame .Screen/vector DEO2
( theme )
#f07f .System/r DEO2
#f0e0 .System/g DEO2
#f0c0 .System/b DEO2
( gba screen size 00f0 x 00a0 )
( nds screen size 0100 x 00c0 )
#0100 .Screen/width DEO2
#00b0 .Screen/height DEO2
( find screen center )
.Screen/width DEI2 #01 SFT2 .center/x STZ2
.Screen/width DEI2 #01 SFT2 #0020 SUB2 .center/x STZ2
.Screen/height DEI2 #01 SFT2 .center/y STZ2
( draw )
draw-size
draw-sprites
draw-1bpp
draw-2bpp
;draw-table JSR2
;draw-sprites JSR2
;draw-1bpp JSR2
;draw-2bpp JSR2
;draw-pixels JSR2
BRK
(
@|vectors )
@on-frame ( -> )
( scroll background )
[ LIT2 &f $2 ] INC2k ,&f STR2
#01 SFT2
#001f AND2
#0040 SUB2
DUP2 .Screen/x DEO2
.Screen/y DEO2
;patt-icn draw-fill
.count LDZ2 INC2 [ DUP2 ] .count STZ2
.center/x LDZ2 #0070 SUB2 .Screen/x DEO2
.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
;anim-chr ,&f LDR2 #00ff AND2 #02 SFT #07 AND #40 SFT ADD2 .Screen/addr DEO2
#8f .Screen/sprite DEO
.center/x LDZ2 #0048 ADD2 .Screen/x DEO2
.center/y LDZ2 #0050 SUB2 .Screen/y DEO2
draw-size
draw-sprites
draw-1bpp
draw-2bpp
( color ) #01 STH
SWP
DUP #04 SFT [ #00 SWP ] #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
( draw ) STHkr .Screen/sprite DEO
#0f AND [ #00 SWP ] #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
DUP #04 SFT [ #00 SWP ] #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
#0f AND [ #00 SWP ] #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
( draw ) STHr .Screen/sprite DEO
BRK
(
@|drawing )
@draw-table ( -- )
#10 #00
&loop
DUP #30 SFT #00 SWP ;font-hex ADD2 .Screen/addr DEO2
( x-axis )
DUP #30 SFT #00 SWP
.center/x LDZ2 #0040 SUB2 ADD2 .Screen/x DEO2
.center/y LDZ2 #0050 SUB2 .Screen/y DEO2
( draw ) #01 .Screen/sprite DEO
( y-axis )
DUP #30 SFT #00 SWP
.center/y LDZ2 #0040 SUB2 ADD2 .Screen/y DEO2
.center/x LDZ2 #0050 SUB2 .Screen/x DEO2
( draw ) #01 .Screen/sprite DEO
INC GTHk ,&loop JCN
POP2
RTN
@draw-sprites ( -- )
( horizontal )
.center/x LDZ2 #0060 SUB2 .Screen/x DEO2
.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
;font-icn .Screen/addr DEO2
#f6 .Screen/auto DEO
#05 .Screen/sprite DEO
( vertical )
.center/x LDZ2 #0070 SUB2 .Screen/x DEO2
.center/y LDZ2 #0038 SUB2 .Screen/y DEO2
;font-icn .Screen/addr DEO2
#f5 .Screen/auto DEO
#05 .Screen/sprite DEO
( table )
#00 .Screen/auto DEO
;preview-chr .Screen/addr DEO2
#00
;preview_icn .Screen/addr DEO2
#00 #00
&loop
( move ) #00 OVR #0f AND #30 SFT
.center/x LDZ2 #0060 SUB2 ADD2 .Screen/x DEO2
( move ) #00 OVR #f0 AND #01 SFT
.center/y LDZ2 #0038 SUB2 ADD2 .Screen/y DEO2
( move ) DUP #0f AND #40 SFT 2/ #00 SWP
.center/x LDZ2 #0040 SUB2 ADD2 .Screen/x DEO2
( move ) DUP #f0 AND 2/ #00 SWP
.center/y LDZ2 #0040 SUB2 ADD2 .Screen/y DEO2
( draw ) DUP .Screen/sprite DEO
INC DUP ?&loop
POP
INC NEQk ,&loop JCN
POP2
JMP2r
RTN
@draw-1bpp ( -- )
#1000
#10 #00
&loop
( color ) STHk
( y ) #00 OVR #42 SFT2
.center/y LDZ2 #0038 SUB2 ADD2 STH2
( x ) #00 OVR #03 AND #40 SFT2 #0040 ADD2
.center/x LDZ2 #0010 SUB2 ADD2
STH2r STHr #00 draw-circle
INC GTHk ?&loop
( y ) DUP 4/ [ #00 SWP ] #40 SFT2
[ .center/y LDZ2 #0040 SUB2 ADD2 ] STH2
( x ) DUP #03 AND [ #00 SWP ] #40 SFT2 #0040 ADD2
[ .center/x LDZ2 #0008 ADD2 ADD2 ]
STH2r STHr #00 ;draw-circle JSR2
INC GTHk ,&loop JCN
POP2
JMP2r
RTN
@draw-2bpp ( -- )
#1000
#10 #00
&loop
( color ) STHk
( y ) #00 OVR #42 SFT2
.center/y LDZ2 #0008 ADD2 ADD2 STH2
( x ) #00 OVR #03 AND #40 SFT2 #0040 ADD2
.center/x LDZ2 #0010 SUB2 ADD2
STH2r STHr #80 draw-circle
INC GTHk ?&loop
( y ) DUP 4/ [ #00 SWP ] #40 SFT2
[ .center/y LDZ2 ADD2 ] STH2
( x ) DUP #03 AND [ #00 SWP ] #40 SFT2 #0040 ADD2
[ .center/x LDZ2 #0008 ADD2 ADD2 ]
STH2r STHr #80 ;draw-circle JSR2
INC GTHk ,&loop JCN
POP2
JMP2r
RTN
@draw-circle ( x* y* color depth -- )
ADD STH
;preview-chr .Screen/addr DEO2
;preview_icn .Screen/addr DEO2
.Screen/y DEO2
.Screen/x DEO2
#01 .Screen/auto DEO
STHr .Screen/sprite DEOk
#02 .Screen/auto DEO
SWP #10 ADD SWP DEOk
.Screen/x DEI2k #0008 SUB2 ROT DEO2
#01 .Screen/auto DEO
SWP #10 ADD SWP DEOk
SWP #10 ADD SWP DEO
JMP2r
#00 STHkr ADD .Screen/sprite DEO
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
#10 STHkr ADD .Screen/sprite DEO
.Screen/x DEI2 #0008 SUB2 .Screen/x DEO2
.Screen/y DEI2 #0008 ADD2 .Screen/y DEO2
#20 STHkr ADD .Screen/sprite DEO
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
#30 STHr ADD .Screen/sprite DEO
@draw-fill ( patt* color -- )
RTN
.Screen/addr DEO2
[ LIT2 01 -Screen/auto ] DEO
.Screen/x DEI2 ,&anchor STR2
.Screen/width DEI2 #03 SFT2 NIP #08 ADD ,&x STR
.Screen/height DEI2 #03 SFT2 NIP #08 ADD #00
&h
DUP #02 SFT STH
[ LIT &x $1 ] #00
&w
DUP #02 SFT STHkr ADD #01 AND .Screen/sprite DEO
INC GTHk ?&w
.Screen/y DEI2k #0008 ADD2 ROT DEO2
[ LIT2 &anchor $2 ] .Screen/x DEO2
POP2 POPr
INC GTHk ?&h
POP2
@draw-pixels ( -- )
JMP2r
.center/y LDZ2 #0040 SUB2 .Screen/y DEO2
.center/x LDZ2 #0048 ADD2 .Screen/x DEO2
#00 .Screen/pixel DEO
.center/x LDZ2 #0049 ADD2 .Screen/x DEO2
#01 .Screen/pixel DEO
.center/x LDZ2 #004a ADD2 .Screen/x DEO2
#02 .Screen/pixel DEO
.center/x LDZ2 #004b ADD2 .Screen/x DEO2
#03 .Screen/pixel DEO
@draw-size ( -- )
RTN
#01 .Screen/auto DEO
.center/x LDZ2 #0030 ADD2 .Screen/x DEO2
.center/y LDZ2 #0048 SUB2 .Screen/y DEO2
.Screen/width DEI2 draw-dec
;x-icn .Screen/addr DEO2
#01 .Screen/sprite DEO
.Screen/height DEI2
@preview_icn [
0f38 675f dfbf bfbf 0007 1820 2344 4848
@draw-dec ( short* -- )
#00 ,&z STR
#2710 draw-dec/parse
#03e8 draw-dec/parse
#0064 draw-dec/parse
#000a draw-dec/parse
NIP
&emit
DUP [ LIT &z $1 ] EQU ?&skip
#ff ,&z STR #00 OVR #30 SFT ;font-icn ADD2 .Screen/addr DEO2
#01 .Screen/sprite DEO
&skip
POP
JMP2r
&parse DIV2k DUP ,&emit JSR MUL2 SUB2 JMP2r
(
@|assets )
@patt-icn [
aa55 aa55 aa55 aa55 ]
@x-icn [
0000 0018 1800 0000 ]
@preview-chr [
0f38 675f dfbf bfbf 0007 1820 2344 4848 ]
@font-icn ( 0-f ) [
@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
@ -203,15 +174,4 @@ JMP2r
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 [
@anim-chr [
0000 0018 1800 0000 c381 0000 0000 81c3
0000 183c 3c18 0000 0000 0000 0000 0000
0018 3c7e 7e3c 1800 0000 0000 0000 0000
3c7e ffe7 e7ff 7e3c 0000 0018 1800 0000
ffff e7c3 c3e7 ffff 0000 183c 3c18 0000
ffe7 c381 81c3 e7ff 0018 3c7e 7e3c 1800
c381 0000 0000 81c3 3c7e ffe7 e7ff 7e3c
0000 0000 0000 0000 ffff e7c3 c3e7 ffff
0000 0000 0000 0000 ffe7 c381 81c3 e7ff ]
007c 8280 f080 827c 007c 8280 f080 8080

View file

@ -0,0 +1,16 @@
( devices )
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
( program )
|0100 @Reset ( -> )
~projects/library/debugger.tal
#0123 #4567 #89ab #cdef
LIT2r 1234 LIT2r 5678 LIT2r 9abc LIT2r def0
( BREAKPOINT )
( LIT2r 0000 DIVr )
&loop INCk ,&loop JMP
BRK

View file

@ -1,56 +0,0 @@
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|100
@on-reset ( -> )
;buf <pstr>
#2018 DEO
;buf <pstr>
#0a18 DEO
( | copy left )
;buf #0006 ADD2 ;mmu-cpyl/a STA2
;buf #0003 ADD2 ;mmu-cpyl/b STA2
;mmu-cpyl .System/expansion DEO2
;buf <pstr>
#2018 DEO
;res1 <pstr>
#0a18 DEO
( | copy right )
;buf #0003 ADD2 ;mmu-cpyr/a STA2
;buf #0009 ADD2 ;mmu-cpyr/b STA2
;mmu-cpyr .System/expansion DEO2
;buf <pstr>
#2018 DEO
;res2 <pstr>
#0a18 DEO
( | copy left )
;buf #0009 ADD2 ;mmu-cpyl/a STA2
;buf #0006 ADD2 ;mmu-cpyl/b STA2
;mmu-cpyl .System/expansion DEO2
;buf <pstr>
#2018 DEO
;res3 <pstr>
#0a18 DEO
( | memset )
;buf #0003 ADD2 ;mmu-fill/a STA2
;mmu-fill .System/expansion DEO2
;buf <pstr>
#2018 DEO
;res4 <pstr>
#0a18 DEO
BRK
@<pstr> ( str* -- )
LDAk #18 DEO
INC2 LDAk ?<pstr>
POP2 JMP2r
@buf [ "......[hello]..... $1 ]
@res1 [ "...[hello]lo]..... $1 ]
@res2 [ "...[hello[hello].. $1 ]
@res3 [ "...[he[hello]lo].. $1 ]
@res4 [ "...-------------.. $1 ]
@mmu-fill [ 00 000d 0000 &a $2 2d ]
@mmu-cpyl [ 01 0007 0000 &a $2 0000 &b $2 ]
@mmu-cpyr [ 02 0007 0000 &a $2 0000 &b $2 ]

View file

@ -1,56 +1,92 @@
( usage: cat program.bf | uxncli brainfuck.rom )
( brainfuck interpreter )
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
%!~ { NEQk NIP }
%DEC { #01 SUB }
%DEC2 { #0001 SUB2 }
%DECr { LITr 01 SUBr }
%RTN { JMP2r }
%HALT { #0101 #0e DEO2 }
%EMIT { #18 DEO }
|0100
%MEMORY { #8000 }
@on-reset ( -> )
;on-console .Console/vector DEO2
BRK
|0000
@on-console ( -> )
.Console/read DEI DUP #20 GTH ?{
POP <eval>
#0000 .Console/vector DEO2
#010f DEO
BRK }
[ LIT2 &ptr =program ] INC2k ,&ptr STR2
STA
BRK
@ptr $2
@<eval> ( -- )
[ LIT2r =on-console/ptr ] LDA2r ;program
&while ( -- )
LDAk [ LIT "+ ] NEQ ?{ LDAkr STHr INC STH2kr STA }
LDAk [ LIT "- ] NEQ ?{ LDAkr STHr #01 SUB STH2kr STA }
LDAk [ LIT "> ] NEQ ?{ INC2r }
LDAk [ LIT "< ] NEQ ?{ [ LIT2r 0001 ] SUB2r }
LDAk [ LIT ". ] NEQ ?{ LDAkr [ LITr 18 ] DEOr }
LDAk [ LIT "[ ] NEQ ?{ goto-next }
LDAk [ LIT "] ] NEQ ?{ goto-back }
INC2 LDAk ?&while
POP2 POP2r JMP2r
|0100 ( -> )
@goto-next ( `mem* prg* -- )
OVR2r LDAr STHr ?{ JMP2r }
[ LITr 00 ] INC2
&loop ( -- )
LDAk [ LIT "[ ] NEQ ?{ INCr }
LDAk [ LIT "] ] NEQ ?{
STHkr ?{ POPr JMP2r }
[ LITr 01 ] SUBr }
INC2 !&loop
MEMORY .ptr STZ2
@goto-back ( `mem* prg* -- )
OVR2r LDAr STHr ?{ JMP2r }
[ LITr 00 ] #0001 SUB2
&loop ( -- )
LDAk [ LIT "] ] NEQ ?{ INCr }
LDAk [ LIT "[ ] NEQ ?{
STHkr ?{ POPr JMP2r }
[ LITr 01 ] SUBr }
#0001 SUB2 !&loop
;program
&while
LDAk ,op JSR
INC2 LDAk ,&while JCN
POP2
@program
HALT
BRK
@op ( op -- )
( Move the pointer to the right )
LIT '> !~ ,&movr JCN [ .ptr LDZ2k INC2 ROT STZ2 POP RTN ] &movr
( Move the pointer to the left )
LIT '< !~ ,&movl JCN [ .ptr LDZ2k DEC2 ROT STZ2 POP RTN ] &movl
( Increment the memory cell at the pointer )
LIT '+ !~ ,&incr JCN [ .ptr LDZ2 STH2k LDA INC STH2r STA POP RTN ] &incr
( Decrement the memory cell at the pointer )
LIT '- !~ ,&decr JCN [ .ptr LDZ2 STH2k LDA DEC STH2r STA POP RTN ] &decr
( Output the character signified by the cell at the pointer )
LIT '. !~ ,&emit JCN [ .ptr LDZ2 LDA EMIT POP RTN ] &emit
( Jump past the matching ] if the cell at the pointer is 0 )
LIT '[ !~ ,&next JCN [ POP ,goto-next JSR RTN ] &next
( Jump back to the matching [ if the cell at the pointer is nonzero )
LIT '] !~ ,&prev JCN [ POP ,goto-back JSR RTN ] &prev
POP
RTN
@goto-next ( -- )
.ptr LDZ2 LDA #00 EQU JMP RTN
( depth ) LITr 00
INC2
&loop
LDAk LIT '[ NEQ JMP INCr
LDAk LIT '] NEQ ,&no-end JCN
STHkr #00 EQU ,&end JCN
DECr
&no-end
INC2 LDAk ,&loop JCN
&end
( depth ) POPr
RTN
@goto-back ( -- )
.ptr LDZ2 LDA #00 NEQ JMP RTN
( depth ) LITr 00
DEC2
&loop
LDAk LIT '] NEQ JMP INCr
LDAk LIT '[ NEQ ,&no-end JCN
STHkr #00 EQU ,&end JCN
DECr
&no-end
DEC2 LDAk ,&loop JCN
&end
( depth ) POPr
RTN
@program ( Hello World! )
"++++++++[>++++[>++>+++>+++>+<<<<
"-]>+>+>->>+[<]<-]>>.>---.+++++++
"..+++.>>.<-.<.+++.------.-------
"-.>>+.>++.

View file

@ -1,47 +0,0 @@
( Fibonacci: Numbers made of the two numbers before it )
|0100
@on-reset
#0019 #0001
&l ( -- )
( index ) DUP2 pdec #2018 DEO
( recursive ) DUP2 fib pdec #2018 DEO
( tail-recursive ) DUP2 #0000 #0001 ROT2 fibr pdec
( lb ) #0a18 DEO
POP2 POP2 INC2 GTH2k ?&l
POP2 POP2
( end ) #800f DEO
BRK
(
@|recursive )
@fib ( num* -- numfib* )
#0001 GTH2k ?&>ok
POP2 JMP2r &>ok
SUB2k fib STH2
INC2 SUB2 fib STH2r
ADD2 JMP2r
(
@|tail-recursive )
@fibr ( a* b* num* -- a* b* numfib* )
#0001 NEQ2k ?&>no-1
POP2 POP2 DUP2 JMP2r &>no-1
SUB2 STH2
SWP2 OVR2 ADD2 STH2r !fibr
(
@|stdlib )
@pdec ( short* -- )
#2710 LIT2r 00fb
&w ( -- )
DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?&>skip
DUP LIT "0 ADD #18 DEO
INCr &>skip
POP2 #000a DIV2 SWPr INCr STHkr ?&w
POP2r POP2 POP2 JMP2r

View file

@ -1,20 +1,43 @@
( Print the first 30 numbers using the following rules:
| If n is divisible by 3, print "fizz"
| If n is divisible by 5, print "buzz"
| If n is divisible by both, print "fizzbuzz"
| Else, print the number )
( FizzBuzz: a program that prints the integers from 1 to 100.
for multiples of three, print "Fizz"
for multiples of five, print "Buzz"
for multiples of both three and five, print "FizzBuzz" )
@fizzbuzz ( -> )
#1e00
&>loop ( length i -- )
DUP fizz OVR buzz ORA ?{ DUP <dec> }
#0a18 DEO
INC GTHk ?&>loop
POP2 BRK
%MOD { DIVk MUL SUB }
%HALT { #01 #0f DEO }
%EMIT { #18 DEO }
%RTN { JMP2r }
@fizz ( n -- ) #03 DIVk MUL SUB ?{ #01 ;Dict/fizz !<str> } #00 JMP2r
@buzz ( n -- ) #05 DIVk MUL SUB ?{ #01 ;Dict/buzz !<str> } #00 JMP2r
@<dec> ( n -- ) DUP #0a DIV /d #0a DIVk MUL SUB &d #30 ADD #18 DEO JMP2r
@<str> ( s* -- ) LDAk #18 DEO INC2 LDAk ?<str> POP2 JMP2r
@Dict &fizz "Fizz $1 &buzz "Buzz $1
@program
|0100 ( -> )
#6400
&loop
LITr 00
DUP #03 MOD ,&no3 JCN ;fizz-txt ;print-str JSR2 INCr &no3
DUP #05 MOD ,&no5 JCN ;buzz-txt ;print-str JSR2 INCr &no5
STHr ,&resume JCN
( print decimal )
DUPk #0a DIV #30 ADD EMIT
#0a MOD #30 ADD EMIT
&resume
( add linebreak ) #0a EMIT
INC GTHk ,&loop JCN
POP2
HALT
BRK
@print-str ( addr* -- )
&loop
LDAk EMIT
INC2 LDAk ,&loop JCN
POP2
RTN
@fizz-txt "Fizz $1
@buzz-txt "Buzz $1

View file

@ -1,2 +0,0 @@
>++++++++[<+++++++++>-]<.>++++[<+++++++>-]<+.+++++++..+++.>>++++++[<+++++++>-]<++.------------.>++++++[<+++++++++>-]<+.<.+++.------.--------.>>>++++[<++++++++>-]<+.

View file

@ -1,70 +0,0 @@
( Pig:
Each turn you roll a die and add the total to your points.
You can stop at any time and keep that total, or keep rolling.
If you ever roll a 1 you lose all the points you accrued. )
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
|0000 @t $1 ( Total saved )
|0100 @game ( -> )
#00 .t STZ
;input-main .Console/vector DEO2
,input-main/main JMP
@roll ( -- dice )
[ LIT2 &r f793 ]
( 5*R+35 ) #0005 MUL2 #0023 ADD2
( R-R/6547*6547 ) DUP2 #1993 DIV2 #1993 MUL2 SUB2
DUP2 #c5 DEI2 ADD2 ,&r STR2 ADD ( mod ) #06 DIVk MUL SUB
JMP2r
@input-main ( -> )
.Console/read DEI
LIT "0 EQUk NIP ,&no JCN
LIT "1 EQUk NIP ,&yes JCN
( ignore other inputs )
POP
BRK
&no ( char -- )
POP ;score-txt ,pstr JSR .t LDZ ,pdec JSR ;byte-txt ,&halt JMP
&yes ( char -- )
POP ,roll JSR ;rolled-txt ,pstr JSR INCk ,pdec/d JSR DUP ,&not-bust JCN
&bust ( char -- )
POP ;bust-txt
&halt ( msg* -- )
,pstr JSR #0a .Console/write DEO #010f DEO BRK
&not-bust ( dice -- )
INC .t LDZ ADD .t STZ
&main ( -- )
;total-txt ,pstr JSR .t LDZ ,pdec JSR ;roll-txt ,pstr JSR BRK
@pdec ( value -- )
DUP #0a DIV ,&emit JSR
&d #0a DIVk MUL SUB ,&emit JSR
#0a .Console/write DEO
JMP2r
&emit #30 ADD .Console/write DEO JMP2r
@pstr ( str* -- )
&while
LDAk DUP LIT "_ EQU #3f MUL SUB .Console/write DEO
INC2 LDAk ,&while JCN
POP2
JMP2r
@total-txt "Your_current_total_is:_ $1
@roll-txt "Would_you_like_to_roll?_(0_no,_1_yes)_ $1
@score-txt "Your_score_is:_ $1
@rolled-txt "You_rolled:_ $1
@bust-txt "Busted! $1
@byte-txt "Goodbye. $1

View file

@ -1,36 +1,57 @@
( Primes:
(
An integer greater than one is called a prime number
if its only positive divisors are one and itself. )
|0100 ( -> ) @reset
%RTN { JMP2r }
%HALT { #0101 #0e DEO2 }
%MOD2 { DIV2k MUL2 SUB2 }
%EMIT { #18 DEO }
#0000 INC2k
|0100 ( -> ) @main
#0000 #0001
&loop
DUP2 not-prime ?&skip
DUP2 print/short #2018 DEO
DUP2 ,is-prime JSR #00 EQU ,&skip JCN
DUP2 ,print-hex/short JSR
#20 EMIT
&skip
INC2 NEQ2k ?&loop
INC2 NEQ2k ,&loop JCN
POP2 POP2
( halt ) #010f DEO
HALT
BRK
@not-prime ( number* -- flag )
@is-prime ( number* -- flag )
DUP2 ,&t STR2
( range ) #01 SFT2 #0002 LTH2k ?&fail
DUP2 #0001 NEQ2 ,&not-one JCN
POP2 #00 RTN
&not-one
STH2k
( range ) #01 SFT2 #0002
&loop
[ LIT2 &t $2 ] OVR2 ( mod2 ) DIV2k MUL2 SUB2 ORA ?&continue
&fail POP2 POP2 #01 JMP2r &continue
INC2 GTH2k ?&loop
POP2 POP2 #00
STH2kr OVR2 MOD2 #0000 NEQ2 ,&continue JCN
POP2 POP2
POP2r #00 RTN
&continue
INC2 GTH2k ,&loop JCN
POP2 POP2
POP2r #01
JMP2r
RTN
@print ( short* -- )
@print-hex ( value* -- )
&short ( short* -- ) SWP print/byte
&byte ( byte -- ) DUP #04 SFT print/char
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
&short ( value* -- )
SWP ,&echo JSR
&byte ( value -- )
,&echo JSR
RTN
JMP2r
&echo ( value -- )
STHk #04 SFT ,&parse JSR EMIT
STHr #0f AND ,&parse JSR EMIT
RTN
&parse ( value -- char )
DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN
RTN

View file

@ -1 +0,0 @@
a001 38a0 0100 b460 0011 a020 1817 2121 aa20 fff2 2222 a080 0f17 0004 6000 0006 8004 1f60 0000 800f 1c06 8009 0a80 271a 1880 3018 8018 176c

View file

@ -1,17 +0,0 @@
( uxncli sierpinski.rom )
@sierpinski ( -> )
( mask ) [ LIT2r 0a18 ] [ LIT2r 2018 ]
( size ) [ LIT2 &size 1001 ] SUB
&>ver ( -- )
DUP INCk
&>pad ( length -- )
DEOkr
#01 SUB DUP ?&>pad
&>fill ( length i -- )
ANDk DUP2r ?{ POP2r ORA2kr } DEOr DEOkr
INC ADDk ,&size LDR LTH ?&>fill
POP2 OVR2r DEOr
#01 SUB INCk ?&>ver
POP POP2r POP2r BRK

View file

@ -1,41 +1,45 @@
( Subleq: The subleq instruction subtracts the contents at address a from the contents at address b, stores the result at address b, and then, if the result is not positive, jumps to address c. If the result is positive, execution proceeds to the next instruction in sequence. )
( uxnasm subleq.tal subleq.rom && uxncli subleq.rom )
%EMIT { #18 DEO }
%HALT { #0101 #0e DEO2 }
%RTN { JMP2r }
%GET { #10 SFT2 ;program ADD2 LDA2 }
%SET { #10 SFT2 ;program ADD2 STA2 }
|0000 @a $2 @b $2 @c $2
|0100
@on-reset ( -> )
#0000
&while ( -- )
eval DUP2 #8000 LTH2 ?&while
( pointer ) #0000
&while
,eval JSR
DUP2 #8000 LTH2 ,&while JCN
POP2
( halt ) #010f DEO
BRK
HALT
BRK
@eval ( ip* -- ip* )
DUP2 get ,&a STR2
INC2 DUP2 get ,&b STR2
INC2 DUP2 get ,&c STR2
INC2
( | I/O )
[ LIT2 &a $2 ] #ffff EQU2 ?&input
[ LIT2 &b $2 ] #ffff EQU2 ?&output
( | SUBLEQ )
( sub ) ,&b LDR2 get ,&a LDR2 get SUB2 DUP2
( write ) ,&b LDR2 DUP2 ADD2 ;program ADD2 STA2
( leq ) #0001 SUB2 #8000 LTH2 ?&end
POP2 [ LIT2 &c $2 ] &end JMP2r
&input ( -- )
( TODO ) JMP2r
&output ( -- )
,&a LDR2 get NIP #18 DEO
JMP2r
@get ( a* -- b* )
DUP2 ADD2 ;program ADD2 LDA2 JMP2r
DUP2 GET .a STZ2
INC2 DUP2 GET .b STZ2
INC2 DUP2 GET .c STZ2
INC2
( I/O )
.a LDZ2 #ffff NEQ2 ,&noin JCN
( nothing. ) ,&end JMP2 &noin
.b LDZ2 #ffff NEQ2 ,&noout JCN
.a LDZ2 GET NIP EMIT ,&end JMP &noout
( SUBLEQ )
.b LDZ2 GET .a LDZ2 GET SUB2 .b LDZ2 SET
( SET )
.b LDZ2 GET #0001 SUB2 #8000 LTH2 ,&end JCN
POP2 .c LDZ2 &end
RTN
@program ( hello world )
[
000f 0011 ffff 0011 ffff ffff 0010 0001
ffff 0010 0003 ffff 000f 000f 0000 0000
ffff 0048 0065 006c 006c 006f 002c 0020
0077 006f 0072 006c 0064 0021 000a 0000 ]
0077 006f 0072 006c 0064 0021 000a 0000

View file

@ -1,12 +0,0 @@
@on-reset ( -> )
#0b #14 #18 tak
#010e DEO
BRK
@tak ( z y x -- res )
LTHk ?{ POP2 JMP2r }
ROT ROTk ROTk
( x-1 ) #01 SUB tak STH
( y-1 ) #01 SUB tak STH
( z-1 ) #01 SUB tak STHr STHr !tak

View file

@ -0,0 +1,83 @@
( GUI Animation )
%2// { #01 SFT2 }
%AUTO-XADDR { #05 .Screen/auto DEO }
( devices )
|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
@dvd
&x $2 &y $2
&dx $1 &dy $1
( program )
|0100 ( -> )
( theme )
#4cfd .System/r DEO2
#4cf3 .System/g DEO2
#dcf2 .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
( starting position )
.Screen/width DEI2 2// .dvd/x STZ2
.Screen/height DEI2 2// .dvd/y STZ2
AUTO-XADDR
#01 ;draw-dvd JSR2
BRK
@on-frame ( -> )
#00 ;draw-dvd JSR2
( case: hit-right ) .dvd/x LDZ2 .Screen/width DEI2 #0020 SUB2 EQU2
( case: hit-left ) .dvd/x LDZ2 #0000 EQU2
#0000 EQU2 ,&no-flipx JCN
.dvd/dx LDZk #00 EQU SWP STZ &no-flipx
( case: hit-bottom ) .dvd/y LDZ2 .Screen/height DEI2 #0010 SUB2 EQU2
( case: hit-top ) .dvd/y LDZ2 #0000 EQU2
#0000 EQU2 ,&no-flipy JCN
.dvd/dy LDZk #00 EQU SWP STZ &no-flipy
( incr ) .dvd/x LDZ2 #0001 #00 .dvd/dx LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/x STZ2
( incr ) .dvd/y LDZ2 #0001 #00 .dvd/dy LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/y STZ2
#01 ;draw-dvd JSR2
BRK
@draw-dvd ( color -- )
STH
;dvd_icn .Screen/addr DEO2
.dvd/x LDZ2 .Screen/x DEO2
.dvd/y LDZ2 .Screen/y DEO2
#0800
&loop
DUP #04 NEQ ,&no-lb JCN
.Screen/x DEI2k #0020 SUB2 ROT DEO2
.Screen/y DEI2k #0008 ADD2 ROT DEO2
&no-lb
STHkr .Screen/sprite DEO
INC GTHk ,&loop JCN
POP2
POPr
JMP2r
@dvd_icn ( 4 x 2 )
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

View file

@ -1,93 +0,0 @@
|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
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1
|0100
@on-reset ( -> )
#5c0f .System/r DEO2
#6d0f .System/g DEO2
#6d0f .System/b DEO2
#0038 DUP2 .Screen/width DEO2
.Screen/height DEO2
;on-mouse .Mouse/vector DEO2
;button-chr <draw-button>
BRK
@on-frame ( -> )
[ LIT2 18 &time 00 ] INCk ,&time STR
EQU ?{ BRK }
#0000 .Screen/vector DEO2
;button-chr/up <draw-button>
[ LIT2 "! 18 ] DEO
BRK
@on-mouse ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #42 ADD ;pointer-icn <update-pointer>
.Mouse/state DEI ?{ BRK }
.Mouse/x DEI2 .Mouse/y DEI2 within-button ?{ BRK }
;button-chr/down <draw-button>
;on-frame .Screen/vector DEO2
#10 ;on-frame/time STA
[ LIT2 00 -Mouse/state ] DEO
BRK
@within-button ( x* y* -- f )
#0010 SUB2 #0018 LTH2 STH
#0010 SUB2 #0018 LTH2 STHr AND JMP2r
(
@|drawing )
@<draw-button> ( addr* -- )
[ LIT2 26 -Screen/auto ] DEO
#0010 DUP2 .Screen/x DEO2
.Screen/y DEO2
.Screen/addr DEO2
[ LIT2 81 -Screen/sprite ] DEOk DEOk DEO
JMP2r
@<update-pointer> ( color addr* -- )
[ LIT2 00 -Screen/auto ] DEO
;fill-icn .Screen/addr DEO2
#40 <draw-pointer>
.Mouse/x DEI2 ,<draw-pointer>/x STR2
.Mouse/y DEI2 ,<draw-pointer>/y STR2
.Screen/addr DEO2
@<draw-pointer> ( color -- )
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEO
JMP2r
(
@|assets )
@fill-icn [ ffff ffff ffff ffff ]
@pointer-icn [ 80c0 e0f0 f8e0 1000 ]
@button-chr
&up [
0000 1f3f 3f3f 3f3f 001f 3f7f 7f7f 7f7f
0000 ffff ffff ffff 00ff ffff ffff ffff
0000 f8fc fcfc fcfc 00f8 fcfe fefe fefe
3f3f 3f3f 3f3f 3f3f 7f7f 7f7f 7f7f 7f7f
e7e7 e781 c3e7 ffff ffff ffff ffff ffff
fcfc fcfc fcfc fcfc fefe fefe fefe fefe
3f3f 3f3f 3f1f 0000 7f7f 7f5f 4020 1f00
ffff ffff ffff 0000 ffff ffff 0000 ff00
fcfc fcfc fcf8 0000 fefe fefa 0204 f800 ]
&down [
0000 001f 3f3f 3f3f 0000 1f3f 7f7f 7f7f
0000 00ff ffff ffff 0000 ffff ffff ffff
0000 00f8 fcfc fcfc 0000 f8fc fefe fefe
3f3f 3f3f 3f3f 3f3f 7f7f 7f7f 7f7f 7f7f
ffe7 e7e7 81c3 e7ff ffff ffff ffff ffff
fcfc fcfc fcfc fcfc fefe fefe fefe fefe
3f3f 3f3f 3f1f 0000 7f7f 7f7f 5f20 1f00
ffff ffff ffff 0000 ffff ffff ff00 ff00
fcfc fcfc fcf8 0000 fefe fefe fa04 f800 ]

View file

@ -1,5 +1,10 @@
( GUI Hover )
%RTN { JMP2r }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
( 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 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
@ -10,6 +15,7 @@
@color $1
@pointer [ &x $2 &y $2 &sprite $2 ]
@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@r1 [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@r2 [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@r3 [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@ -74,46 +80,43 @@ BRK
@within-rect ( x* y* rect -- flag )
STH
( y < rect.y1 ) DUP2 STHkr INC INC LDZ2 LTH2 ,&skip JCN
( y < rect.y1 ) DUP2 STHkr #02 ADD 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
RTN
&skip
POP2 POP2 POPr
#00
JMP2r
RTN
@line-rect ( x1* y1* x2* y2* color -- )
STH
DUP2 ,&ver-y2 STR2 ,&hor-y2 STR2
DUP2 ,&ver-x2 STR2 ,&hor-x2 STR2
DUP2 ,&ver-y1 STR2 ,&hor-y1 STR2
DUP2 ,&ver-x1 STR2 ,&hor-x1 STR2
( horizontal )
[ LIT2 &hor-x2 $2 ] INC2 [ LIT2 &hor-x1 $2 ]
&hor
DUP2 .Screen/x DEO2
[ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk
[ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO
INC2 GTH2k ,&hor JCN
POP2 POP2
( vertical )
[ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ]
( load ) .color STZ
STH2k .rect/y2 STZ2 .rect/x2 STZ2
STH2k .rect/y1 STZ2 .rect/x1 STZ2
STH2r STH2r SWP2
&ver
DUP2 .Screen/y DEO2
[ LIT2 &ver-x1 $2 ] .Screen/x DEO2 STHkr .Screen/pixel DEOk
[ LIT2 &ver-x2 $2 ] .Screen/x DEO2 DEO
INC2 GTH2k ,&ver JCN
( save ) DUP2 .Screen/y DEO2
( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/pixel DEO
( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .Screen/pixel DEO
( incr ) INC2
OVR2 OVR2 GTS2 ,&ver JCN
POP2 POP2
.rect/x1 LDZ2 .rect/x2 LDZ2 SWP2
&hor
( save ) DUP2 .Screen/x DEO2
( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/pixel DEO
( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/pixel DEO
( incr ) INC2
OVR2 OVR2 GTS2 ,&hor JCN
POP2 POP2
POPr
JMP2r
RTN
@pointer_icn [ 80c0 e0f0 f8e0 1000 ]
@hand_icn [ 4040 4070 f8f8 f870 ]

View file

@ -1,83 +1,167 @@
( GUI Labels )
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%=~ { EQUk NIP } %!~ { NEQk NIP }
%<~ { LTHk NIP } %>~ { GTHk NIP }
%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 }
%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 }
%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 }
%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 }
%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 }
%IS-VALID { DUP #1f > SWP #7f < AND }
%RTN { JMP2r }
%TOS { #00 SWP }
%AUTO-NONE { #00 .Screen/auto DEO }
%AUTO-Y { #02 .Screen/auto DEO }
%AUTO-YADDR { #06 .Screen/auto DEO }
%HALT { #010f DEO }
%EMIT { #18 DEO }
%PRINT { ;print-str JSR2 #0a EMIT }
%DEBUG { ;print-hex/byte JSR2 #0a EMIT }
%DEBUG2 { ;print-hex JSR2 #0a EMIT }
( devices )
|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
( variables )
|0000
@center &x $2 &y $2
@label [ &x $2 &y $2 &color $1 &addr $2 ]
@center [ &x $2 &y $2 ]
( program )
|0100
( theme )
#a0dc .System/r DEO2
#a0dc .System/g DEO2
#a0dc .System/b DEO2
#f0d7 .System/r DEO2
#f0de .System/g DEO2
#f0dc .System/b DEO2
( find screen center )
.Screen/width DEI2 #01 SFT2 .center/x STZ2
.Screen/height DEI2 #01 SFT2 .center/y STZ2
.Screen/width DEI2 2// .center/x STZ2
.Screen/height DEI2 2// .center/y STZ2
( dashed line )
#02 .Screen/auto DEO
( ver )
AUTO-Y
#0000 .Screen/y DEO2
.center/x LDZ2 .Screen/x DEO2
.Screen/height DEI2 #0000
&ver
DUP #01 AND .Screen/pixel DEO
#43 .Screen/pixel DEO
.Screen/y DEI2k INC2 ROT DEO2
INC2 GTH2k ,&ver JCN
POP2 POP2
( left )
.center/x LDZ2 .Screen/x DEO2
.center/y LDZ2 #0018 SUB2 .Screen/y DEO2
;left-txt ,draw-uf2 JSR
.center/y LDZ2 #0020 -- .Screen/y DEO2
;left-txt #09 ;draw-uf2 JSR2
( center )
.center/x LDZ2 .Screen/x DEO2
.center/y LDZ2 .Screen/y DEO2
;center-txt ,draw-uf2-center JSR
;center-txt #09 ;draw-uf2-center JSR2
( right )
.center/x LDZ2 .Screen/x DEO2
.center/y LDZ2 #0018 ADD2 .Screen/y DEO2
;right-txt ,draw-uf2-right JSR
.center/y LDZ2 #0020 ++ .Screen/y DEO2
;right-txt #09 ;draw-uf2-right JSR2
BRK
@get-uf2-width ( text* -- width* )
@draw-uf2-center ( text* color -- )
STH
DUP2 ,get-width JSR 2// .Screen/x DEI2 SWP2 -- .Screen/x DEO2
STHr ,draw-uf2 JSR
RTN
@draw-uf2-right ( text* color -- )
STH
DUP2 ,get-width JSR .Screen/x DEI2 SWP2 -- .Screen/x DEO2
STHr ,draw-uf2 JSR
RTN
@get-width ( text* -- width* )
LIT2r 0000
&while
LDAk #0000 ROT ;font ADD2 LDA STH2 ADD2r
LDAk TOS ;font ++ LDA TOS STH2 ADD2r
INC2 LDAk ,&while JCN
POP2
STH2r
JMP2r
RTN
@draw-uf2-center ( text* -- )
@draw-uf2 ( text* color -- )
DUP2 ,get-uf2-width JSR #01 SFT2 STH2
.Screen/x DEI2k STH2r SUB2 ROT DEO2
,draw-uf2 JMP
@draw-uf2-right ( text* -- )
DUP2 ,get-uf2-width JSR STH2
.Screen/x DEI2k STH2r SUB2 ROT DEO2
@draw-uf2 ( text* -- )
#15 .Screen/auto DEO
STH
AUTO-YADDR
&while
LDAk #20 SUB #00 SWP
DUP2 #50 SFT2 ;font/glyphs ADD2 .Screen/addr DEO2
;font ADD2 LDA STHk #00 SWP .Screen/x DEI2 ADD2
#01 .Screen/sprite DEOk STHr #08 LTH ,&thin JCN DEOk &thin POP2
.Screen/x DEO2
LDAk STHkr ,draw-glyph JSR
INC2 LDAk ,&while JCN
POP2
POP2 POPr
AUTO-NONE
RTN
@draw-glyph ( char color -- )
.Screen/x DEI2 STH2
.Screen/y DEI2 STH2
( glyph ) OVR ,get-glyph JSR .Screen/addr DEO2
DUP .Screen/sprite DEOk DEO
STH2kr .Screen/y DEO2
( get width ) SWP TOS ;font ++ LDA
DUP #09 < ,&narrow JCN
.Screen/x DEI2k #0008 ++ ROT DEO2
OVR .Screen/sprite DEOk DEO
STH2kr .Screen/y DEO2
&narrow
POP2r
( width ) TOS STH2r ++ .Screen/x DEO2
POP
RTN
@get-glyph ( char -- addr* )
#09 =~ ,&tab JCN ( tab )
#0a =~ ,&linebreak JCN ( linebreak )
#0d =~ ,&linebreak JCN ( linebreak )
DUP IS-VALID ,&valid JCN
POP ;unknown-icn RTN
&linebreak
POP ;linebreak-icn RTN
&tab
POP ;tab-icn RTN
&valid
TOS 20** ;font
#0100 ++ ++
RTN
@print-hex ( value* -- )
SWP ,&byte JSR
&byte ( byte -- )
STHk #04 SFT ,&parse JSR #18 DEO
STHr #0f AND ,&parse JSR #18 DEO
JMP2r
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r
&above #57 ADD JMP2r
JMP2r
@ -85,7 +169,25 @@ JMP2r
@center-txt "Center 20 "Aligned 20 "Label $1
@right-txt "Right 20 "Aligned 20 "Label $1
@unknown-icn
aa55 aa55 aa55 aa55
aa55 aa55 aa55 aa55
aa55 aa55 aa55 aa55
aa55 aa55 aa55 aa55
@tab-icn
0000 0000 0000 1008
1000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
@linebreak-icn
0000 0000 0000 1028
1000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
@font ( venice14 )
0000 0000 0000 0000 0009 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0505 0809 080c 0d05 0707 0a09 0609 0608
0808 0808 0908 0808 0808 0505 0708 0709
000d 0a08 0b0a 090a 0c08 070c 090e 0c09
@ -100,7 +202,70 @@ JMP2r
090c 0808 0505 0000 0907 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
&glyphs ( starting at #20 )
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
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
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
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
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
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
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
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
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
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 3030 3030 3030 3000 3030 0000 0000

View file

@ -1,4 +1,13 @@
( GUI Monospace )
( Draw a 8x8 font )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%AUTO-X { #01 .Screen/auto DEO }
( devices )
|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
@ -30,34 +39,32 @@ BRK
@draw-uf1 ( string* color -- )
#01 .Screen/auto DEO
AUTO-X
STH
&while
( get sprite ) LDAk #20 SUB #00 SWP #30 SFT2 ;font ADD2 .Screen/addr DEO2
( get sprite ) LDAk #20 - #00 SWP #30 SFT2 ;font ++ .Screen/addr DEO2
( draw ) STHkr .Screen/sprite DEO
INC2 LDAk ,&while JCN
POPr
POP2
JMP2r
@draw-uf1-linebreaks ( string* color -- )
.Screen/x DEI2 ,&anchor STR2
#01 .Screen/auto DEO
AUTO-X
STH
&while
LDAk #0a NEQ ,&no-lb JCN
LDAk #0a ! ,&no-lb JCN
( rewind ) LIT2 &anchor $2 .Screen/x DEO2
( skip line ) .Screen/y DEI2k #0008 ADD2 ROT DEO2
( skip line ) .Screen/y DEI2k #0008 ++ ROT DEO2
,&end JMP
&no-lb
( get sprite ) LDAk #20 SUB #00 SWP #30 SFT2 ;font ADD2 .Screen/addr DEO2
( get sprite ) LDAk #20 - #00 SWP #30 SFT2 ;font ++ .Screen/addr DEO2
( draw ) STHkr .Screen/sprite DEO
&end
INC2 LDAk ,&while JCN
POPr
POP2
JMP2r

View file

@ -1,66 +1,60 @@
( GUI Picture )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%AUTO-NONE { #00 .Screen/auto DEO }
%AUTO-XADDR { #05 .Screen/auto DEO }
( devices )
|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
( variables )
|0000
( program )
|0100
( theme )
#f0f7 .System/r DEO2
#f00e .System/g DEO2
#f00c .System/b DEO2
#f0d7 .System/r DEO2
#f0de .System/g DEO2
#f0dc .System/b DEO2
#0010
DUP2 .Screen/x DEO2
.Screen/y DEO2
;akane20x10 #20 #10 #01 draw-icn
#0100 .Screen/x DEO2
#0028 .Screen/y DEO2
#1010 ;dafu10x10 #0a draw-fast
#0030 .Screen/x DEO2
#0030 .Screen/y DEO2
;picture-icn #20 #10 #01 ;draw-icn JSR2
BRK
@draw-icn ( addr* width height color -- )
#05 .Screen/auto DEO
,&color STR
,&height STR
,&width STR
.Screen/addr DEO2
.Screen/x DEI2
,&x STR2
[ LIT2 00 &height $1 ] SUB
AUTO-XADDR
STH
( set bounds ) ,&height STR ,&width STR .Screen/addr DEO2
( set origin ) .Screen/x DEI2 ,&x STR2
LIT &height $1 #00
&ver
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 00 &width $1 ] SUB
LIT2 &x $2 .Screen/x DEO2
LIT &width $1 #00
&hor
[ LIT &color $1 ] .Screen/sprite DEO
INC DUP ?&hor
POP
.Screen/y DEI2k #0008 ADD2 ROT DEO2
INC DUP ?&ver
POP
#00 .Screen/auto DEO
STHkr .Screen/sprite DEO
INC GTHk ,&hor JCN
POP2
.Screen/y DEI2k #0008 ++ ROT DEO2
INC GTHk ,&ver JCN
POP2
POPr
AUTO-NONE
JMP2r
( makes use of the auto byte )
@draw-fast ( w h addr* color -- )
,&color STR
.Screen/addr DEO2
SWP #01 SUB #40 SFT #06 ORA .Screen/auto DEO
#00 SWP SUB
&loop
[ LIT2 &color $1 -Screen/sprite ] DEO
INC DUP ?&loop
POP
JMP2r
@akane20x10
@picture-icn ( akane2010.bit 20 x 10 )
0000 0000 0000 0000 2b41 2341 2b41 2341
8881 8081 8880 8080 0a00 2000 8800 2000
8004 2004 8804 2a04 0000 0000 8000 0000
@ -317,133 +311,3 @@ JMP2r
ffff ffff ffff ffff faff ffff ffff fbf7
bafd ffff bfdf ff5f ef7f ffff af5f af5f
ffff ffff ffff ffff ffff ffff ffff ffff
@dafu10x10
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0001 0000 0000 010f 7fff
0000 002f ffff ffff 0000 00fd ffff ffff
0000 0000 e0fc ffff 0000 0000 0000 00e0
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 0107 071f
071f 3fff fffc f3cf ffff f8c7 3fff ffff
e82f fbfb fbfb fbfb 02ff ffff ffff ffff
bf41 feff ffff ffff fcff 1fe3 fcff ffff
00d0 fcff 7fd2 ffff 0000 00c0 f0f8 5efe
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 0103 0f1f 3f7e 5f7e f9f3 cf9f 7fff
3f7f ffff ffff ffff ffff ffff ffff ffff
f9fb fbf9 fdf9 fdfd ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff feff fefe
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0001 002f 1f1f 1f1f
e907 ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
fdfd fdfd fcff fd45 ffff ffff ffff ed37
ffff ffff ffff b76c ffff ffff ffff ff0b
ffff ffff ffff ffff fefc fcfc f8fc f8f8
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 1f1f 1f0f 0f07 0703
ffff ffff ffff ffff ffff ffff fffe fdf5
ffff fceb 8fbf 7fff f48b 7fff ffff ffff
bffe fefa f8fc fdff ffff 7f3f 3f7f bfff
ffff ffff ffff ffff f8ff ffff ffff ffff
7fd7 ffff ffff ffff f0f0 f0e0 e0e0 e0e0
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0301 0100 0000 0000
ffff fffc 7d33 3f1f ef9f 7fff ffff ffff
ffff ffff ffff f4cb ffff ffff e807 ffff
ffff ffa0 00c0 0197 ffff 5007 1f03 5eff
ffff a5ff ff6d bfff ffff 4de8 ff7f 6fff
ffff ffbf a7fe fefe f0e0 f0e0 f0e0 b0d0
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
1f0f 0f0f 0f0e 0e12 fefa f5cf bfff ffff
3fff ffff ffff ffff ffff ffff ffff ffff
f8e0 e0c0 e040 c040 7f7f 5f2f 7b1b 0f0f
ffff ffff ffff ffff ffff ffff ffff ffff
ffff fcfd fbf5 f9d4 50f0 f0e0 f0f0 e060
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
1a1a 150f 0d07 1100 7fff ffff fdff ffe1
ffff ffff baff ff55 ffff ffaa fdff fe00
c040 d708 f0eb a800 0fa6 7f2f 3fd0 021a
d7bf fff7 086a b8b0 feff e914 a000 0000
ab20 e078 0000 0000 e0c0 d6e1 4084 0204
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0402 010a 0200 0000 7876 39b0 5078 9018
0892 71a9 2112 1210 aa00 ff01 7692 0000
a01e 3628 8488 4484 a5a0 0000 0080 8000
2003 070d 3815 0260 feff 7b69 9e60 0000
90e0 8080 0000 0000 c004 8020 8890 8888
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0300 0000 0000 0000 2848 8008 4428 0c04
1211 1201 1d14 2a29 1200 0016 dd55 22a9
4084 44ca 8a0d 5800 0000 0800 a02e d105
1000 0000 0080 6a11 0000 0000 0000 8865
0100 0100 0101 005e 2080 2040 4000 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 0600 0a05 0303 0300
50a0 8040 8000 8000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
ad00 0000 0000 0000 510a 0000 0000 0000
2214 0002 0200 0406 0000 0000 0000 0080
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 0021 010f 0407 0812 2e5c de3e
4000 c060 f0f0 f878 0000 0000 0000 0000
0000 0000 0000 0000 0000 502d 0200 157f
0040 a000 0000 e0f8 0000 0000 0000 0000
060f 0f1f 1737 336b a01c e3f0 feff ffff
0000 407a 05c0 f0fc 0000 0000 807c 0300
0000 0000 0000 a05a 0000 0000 0000 0004
0000 0000 0000 030c 0001 0514 53a7 0f3f
265c 5df9 f3e7 c7cf fbfd fbfb fbfb fbfb
7c7e 7fbf bfff bfff 0000 0090 c0e0 f0f8
0101 0101 0001 0020 7fc8 ff1b c6f0 7f78
fc5c ec08 b858 30e0 0108 0001 0103 0707
6b5b dbdf bbbf bb7f ffff ffff ffff ffff
fefe fcfc f9f3 f3f7 6079 fffe fcfc f9f3
0540 823f 7fff ffff d02c 03f8 feff ffff
3040 800e 3f7f ffff 7f7f 7fff 7f7f 7f7f
9fdf 9f9f df9f 9fdf fbfb fbf3 fbfb fbfb
efff fff7 fffd ffff fefe ffff ffff ff7f
0000 80e0 f0fc ffff 1f02 0000 0001 01e1
c000 00a8 b050 590b 0f1f 1e7d 7dff ffff
7f7f ffff ffff ffff ffff ffff ffff ffff
e7ef cfdf 9f3f 7f3f f3e7 efcf dfbf bf3f
ffff ffff ffff ffff fffe fcf8 f0f0 e0c0
ffff ffff ffff ffff bfbf bfbf dfdf dfcf
9fcf 9fcf dfcf dfcf f7fb fbf7 fbfb fbfb
ffff ffff ffff ffff ffd7 f7fd feff ffff
ffff ffff 7f9e e8e0 ffff fff5 8000 0001
4f47 66a4 7056 4b43 fffe 8001 015f ffff
ffbf 1f7f ffff ffff fefe fcfe fdf9 fbfb
7fff feff fefe fcfe 7f7f 7f7f ffff ffff
ffff fffe fefc f8f8 8183 070f 1f3f 3f7f
ffff ffff 7f3f 9f8f efef eff7 f7f7 f7f7
dfcf efdf cfff cfef fbfb fbf9 fdfd fbfc
ffff fffe f4c0 8000 fffc e080 0000 0000
8000 0000 0000 0000 0506 0802 0300 0000
4925 2365 a2b2 1191 ffff ffff ff05 0000
ffff ffff ff7f 0307 fbfb ffff ffff ffff
fcfd fcfe fdfd fdfd ffff ffff ffff ffff
f0e0 e1c3 8387 0f1f ffff ffff ffff fffe

View file

@ -1,8 +1,19 @@
( GUI Shapes )
%RTN { JMP2r }
%8++ { #0008 ADD2 }
%2** { #10 SFT2 }
%4** { #20 SFT2 }
%2// { #01 SFT2 }
%4// { #02 SFT2 }
%ABS2 { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 }
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
%SIZE-TO-RECT {
STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2
} ( x y w h -- x1 y1 x2 y2 )
%WIDTH { #0100 } %HEIGHT { #00a0 }
( devices )
@ -30,24 +41,24 @@
#f03c .System/g DEO2
#f03f .System/b DEO2
( background ) ;checker-icn #03 ;cover-pattern JSR2
( background ) ;checker_icn #03 ;cover-pattern JSR2
.Screen/width DEI2 #01 SFT2 WIDTH #01 SFT2 SUB2 #0008 ADD2
.Screen/height DEI2 #01 SFT2 HEIGHT #01 SFT2 SUB2 #0008 ADD2
.Screen/width DEI2 2// WIDTH 2// SUB2 #0008 ADD2
.Screen/height DEI2 2// HEIGHT 2// SUB2 #0008 ADD2
WIDTH HEIGHT
STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2 #02 ;fill-rect JSR2
SIZE-TO-RECT #02 ;fill-rect JSR2
.Screen/width DEI2 #01 SFT2 WIDTH #01 SFT2 SUB2
.Screen/height DEI2 #01 SFT2 HEIGHT #01 SFT2 SUB2
.Screen/width DEI2 2// WIDTH 2// SUB2
.Screen/height DEI2 2// HEIGHT 2// SUB2
WIDTH HEIGHT
STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2 #01 ;fill-rect JSR2
SIZE-TO-RECT #01 ;fill-rect JSR2
.Screen/width DEI2 #01 SFT2 WIDTH #01 SFT2 SUB2 #0008 ADD2
.Screen/height DEI2 #01 SFT2 HEIGHT #01 SFT2 SUB2 #0008 ADD2
.Screen/width DEI2 2// WIDTH 2// SUB2 #0008 ADD2
.Screen/height DEI2 2// HEIGHT 2// SUB2 #0008 ADD2
WIDTH #0010 SUB2 HEIGHT #0010 SUB2
STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2 #03 ;line-rect JSR2
SIZE-TO-RECT #03 ;line-rect JSR2
.Screen/width DEI2 #01 SFT2 .Screen/height DEI2 #01 SFT2 WIDTH #02 SFT2 #02 ;draw-circle JSR2
.Screen/width DEI2 2// .Screen/height DEI2 2// WIDTH 4// #02 ;draw-circle JSR2
#0010 #0030 #0068 #02 ;line-hor JSR2
#0020 #0058 #0078 #02 ;line-ver JSR2
@ -59,13 +70,13 @@ BRK
( load ) .color STZ #0001 SUB2 .line/y0 STZ2 #0001 SUB2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2
.line/x0 LDZ2 .line/x LDZ2 SUB2 ABS2 .line/dx STZ2
.line/y0 LDZ2 .line/y LDZ2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy STZ2
#ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 #10 SFT2 ADD2 .line/sx STZ2
#ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 #10 SFT2 ADD2 .line/sy STZ2
#ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ADD2 .line/sx STZ2
#ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 2** ADD2 .line/sy STZ2
.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
&loop
.line/x LDZ2 .Screen/x DEO2 .line/y LDZ2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO
.line/x LDZ2 .line/x0 LDZ2 EQU2 .line/y LDZ2 .line/y0 LDZ2 EQU2 AND ,&end JCN
.line/e1 LDZ2 #10 SFT2 .line/e2 STZ2
.line/x LDZ2 .line/x0 LDZ2 EQU2 .line/y LDZ2 .line/y0 LDZ2 EQU2 #0101 EQU2 ,&end JCN
.line/e1 LDZ2 2** .line/e2 STZ2
.line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN
.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
.line/x LDZ2 .line/sx LDZ2 ADD2 .line/x STZ2
@ -78,34 +89,32 @@ BRK
&end
JMP2r
RTN
@line-rect ( x1* y1* x2* y2* color -- )
STH
DUP2 ,&ver-y2 STR2 ,&hor-y2 STR2
DUP2 ,&ver-x2 STR2 ,&hor-x2 STR2
DUP2 ,&ver-y1 STR2 ,&hor-y1 STR2
DUP2 ,&ver-x1 STR2 ,&hor-x1 STR2
( horizontal )
[ LIT2 &hor-x2 $2 ] INC2 [ LIT2 &hor-x1 $2 ]
&hor
DUP2 .Screen/x DEO2
[ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk
[ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO
INC2 GTH2k ,&hor JCN
POP2 POP2
( vertical )
[ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ]
( load ) STH
STH2k ,&y2 STR2 ,&x2 STR2
STH2k ,&y1 STR2 ,&x1 STR2
STH2r STH2r SWP2
&ver
DUP2 .Screen/y DEO2
[ LIT2 &ver-x1 $2 ] .Screen/x DEO2 STHkr .Screen/pixel DEOk
[ LIT2 &ver-x2 $2 ] .Screen/x DEO2 DEO
INC2 GTH2k ,&ver JCN
( save ) DUP2 .Screen/y DEO2
( draw ) ,&x1 LDR2 .Screen/x DEO2 STHkr .Screen/pixel DEO
( draw ) ,&x2 LDR2 .Screen/x DEO2 STHkr .Screen/pixel DEO
( incr ) INC2
OVR2 OVR2 GTS2 ,&ver JCN
POP2 POP2
POPr
,&x1 LDR2 ,&x2 LDR2 SWP2
&hor
( save ) DUP2 .Screen/x DEO2
( draw ) ,&y1 LDR2 .Screen/y DEO2 STHkr .Screen/pixel DEO
( draw ) ,&y2 LDR2 .Screen/y DEO2 STHkr .Screen/pixel DEO
( incr ) INC2
OVR2 INC2 OVR2 GTS2 ,&hor JCN
POP2 POP2 POPr
JMP2r
RTN
&x1 $2 &y1 $2 &x2 $2 &y2 $2
@fill-rect ( x1* y1* x2* y2* color -- )
@ -124,27 +133,27 @@ JMP2r
OVR2 OVR2 GTS2 ,&ver JCN
POP2 POP2 POP2 POP2
JMP2r
RTN
&color $1
@draw-circle ( xc yc r color -- )
( load ) .color STZ .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
.circle/r LDZ2 2** .circle/d STZ2
( draw ) ;&seg JSR2
&loop
( incr ) .circle/x LDZ2 INC2 .circle/x STZ2
.circle/d LDZ2 #0001 LTS2 ,&else JCN
( 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
.circle/x LDZ2 .circle/y LDZ2 SUB2 4** .circle/d LDZ2 ADD2 .circle/d STZ2
;&end JMP2
&else
.circle/x LDZ2 #20 SFT2 .circle/d LDZ2 ADD2 .circle/d STZ2
.circle/x LDZ2 4** .circle/d LDZ2 ADD2 .circle/d STZ2
&end
( draw ) ;&seg JSR2
.circle/y LDZ2 .circle/x LDZ2 #0001 SUB2 GTS2 ,&loop JCN
JMP2r
RTN
&seg
.circle/xc LDZ2 .circle/x LDZ2 ADD2 .Screen/x DEO2 .circle/yc LDZ2 .circle/y LDZ2 ADD2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO
.circle/xc LDZ2 .circle/x LDZ2 SUB2 .Screen/x DEO2 .circle/yc LDZ2 .circle/y LDZ2 ADD2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO
@ -155,7 +164,7 @@ JMP2r
.circle/xc LDZ2 .circle/y LDZ2 ADD2 .Screen/x DEO2 .circle/yc LDZ2 .circle/x LDZ2 SUB2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO
.circle/xc LDZ2 .circle/y LDZ2 SUB2 .Screen/x DEO2 .circle/yc LDZ2 .circle/x LDZ2 SUB2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO
JMP2r
RTN
@cover-pattern ( addr* color -- )
@ -173,7 +182,7 @@ JMP2r
POP2 POP2
POPr
JMP2r
RTN
@line-hor ( x0* x1* y* color -- )
@ -185,7 +194,7 @@ JMP2r
INC2 GTH2k ,&loop JCN
POP2 POP2 POPr
JMP2r
RTN
@line-ver ( x* y0* y1* color -- )
@ -197,7 +206,6 @@ JMP2r
INC2 GTH2k ,&loop JCN
POP2 POP2 POPr
JMP2r
RTN
@checker-icn
f0f0 f0f0 0f0f 0f0f
@checker_icn [ f0f0 f0f0 0f0f 0f0f ]

View file

@ -1,4 +1,9 @@
( GUI Terminal )
( gui/terminal )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
( devices )
@ -19,7 +24,7 @@
( theme )
#0f0f .System/r DEO2
#0ff0 .System/g DEO2
#0fff .System/b DEO2
#00ff .System/b DEO2
( vectors )
;on-button .Controller/vector DEO2
@ -34,22 +39,22 @@ BRK
@on-button ( -> )
.Controller/key DEI
DUP ,&no-null JCN
DUP #00 ! ,&no-null JCN
POP BRK
&no-null
DUP #0d NEQ ,&no-enter JCN
DUP #0d ! ,&no-enter JCN
#00 ;draw-input JSR2
;validate JSR2
;buffer #0080 ;mclr JSR2
#01 ;draw-input JSR2
&no-enter
DUP #08 NEQ ,&no-backspace JCN
DUP #08 ! ,&no-backspace JCN
#00 ;draw-input JSR2
;buffer ;spop JSR2
#01 ;draw-input JSR2
&no-backspace
DUP STHk #1f GTH STHr #7b LTH #0101 NEQ2 ,&no-valid JCN
;buffer ;slen JSR2 #007f GTH2 ,&no-valid JCN
DUP STHk #1f > STHr #7b < #0101 !! ,&no-valid JCN
;buffer ;slen JSR2 #007f >> ,&no-valid JCN
STHk ;buffer STHr ;sput JSR2
#01 ;draw-input JSR2
&no-valid
@ -60,7 +65,7 @@ BRK
@validate ( -- )
#0010 .Screen/x DEO2
.Screen/height DEI2 #0040 SUB2 .Screen/y DEO2
.Screen/height DEI2 #0040 -- .Screen/y DEO2
( clear )
#8000
@ -75,7 +80,7 @@ BRK
LIT 22 #02 ;draw-char JSR2
;buffer #03 ;draw-str JSR2
LIT 22 #02 ;draw-char JSR2
LIT ". #02 ;draw-char JSR2
LIT '. #02 ;draw-char JSR2
JMP2r
@ -83,9 +88,9 @@ JMP2r
STH
#0010 .Screen/x DEO2
.Screen/height DEI2 #0020 SUB2 .Screen/y DEO2
.Screen/height DEI2 #0020 -- .Screen/y DEO2
( marker ) LIT "> #03 ;draw-char JSR2
( marker ) LIT '> #03 ;draw-char JSR2
;buffer STHr ;draw-str JSR2
@ -105,10 +110,10 @@ JMP2r
@draw-char ( char color -- )
SWP
[ #20 SUB #00 SWP #40 SFT2 ;font ADD2 ] .Screen/addr DEO2
[ #20 - #00 SWP #40 SFT2 ;font ++ ] .Screen/addr DEO2
.Screen/sprite DEOk DEO
.Screen/y DEI2 #0010 SUB2 .Screen/y DEO2
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
.Screen/y DEI2 #0010 -- .Screen/y DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
JMP2r
@ -116,13 +121,13 @@ JMP2r
@slen ( str* -- len* )
DUP2 ,scap JSR SWP2 SUB2
DUP2 ,scap JSR SWP2 --
JMP2r
@scap ( str* -- str-end* )
( clamp ) LDAk #00 NEQ JMP JMP2r
( clamp ) LDAk #00 ! JMP JMP2r
&while INC2 LDAk ,&while JCN
JMP2r
@ -135,14 +140,14 @@ JMP2r
@spop ( str* -- )
( clamp ) LDAk #00 NEQ JMP JMP2r
#00 ROT ROT ,scap JSR #0001 SUB2 STA
( clamp ) LDAk #00 ! JMP JMP2r
#00 ROT ROT ,scap JSR #0001 -- STA
JMP2r
@mclr ( addr* len* -- )
OVR2 ADD2 SWP2
OVR2 ++ SWP2
&loop
STH2k #00 STH2r STA
INC2 GTH2k ,&loop JCN

View file

@ -1,83 +0,0 @@
( uxnemu timer.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
|100
@on-reset ( -> )
;on-control .Controller/vector DEO2
#0080 DUP2 .Screen/width DEO2
.Screen/height DEO2
#f074 DUP2 .System/r DEO2
DUP2 .System/g DEO2
.System/b DEO2
Timer/start BRK
@on-control ( -> )
.Controller/button DEI
( A ) DUP #01 NEQ ?{ Timer/pause }
( B ) DUP #02 NEQ ?{ Timer/start }
POP BRK
(
@|Objects )
@Timer ( * )
&on-frame ( -> )
[ LIT &paused $1 ] ?{
[ LIT2 3c &frame 00 ] INCk ,&frame STR
EQU ?&on-second }
BRK
&on-second ( -> )
[ LIT2 00 _&frame ] STR
[ LIT2 ff &time $1 ] ADD DUP ?{ /end }
,&time STR
/<draw> BRK
&start ( -- )
[ LIT2 0f _&time ] STR
[ LIT2 00 _&paused ] STR
[ LIT2 0f _&frame ] STR
;&on-frame .Screen/vector DEO2
!&<draw>
&pause ( -- )
[ LIT2 00 _&paused ] LDR EQU
( ) INCk <set-dec-color>
,&paused STR
!&<draw>
&end ( -- )
#0000 .Screen/vector DEO2
#06 <set-dec-color>
!&<draw>
&<draw> ( -- )
,&time LDR !<draw-dec>
(
@|drawing )
@<set-dec-color> ( color -- )
;<draw-num>/color STA
JMP2r
@<draw-dec> ( dec -- )
#0010 DUP2 .Screen/x DEO2
.Screen/y DEO2
[ LIT2 01 -Screen/auto ] DEO
DUP
( x0 ) #0a DIV <draw-num>
( 0x ) #0a DIVk MUL SUB
( >> )
@<draw-num> ( num -- )
#00 SWP #30 SFT2 ;numbers-icns ADD2 .Screen/addr DEO2
[ LIT2 &color 01 -Screen/sprite ] DEO
JMP2r
@numbers-icns [
38c6 c6c6 c6c6 c638 8c78 1818 1818 187e
3c4e 860e 1c38 72fe 807e 0c10 7c0e 8e7c
0e1c 1c3c 6cff 0c1e c6f8 40c0 fc0e ce7c
3ac4 c0c0 fcce ce7c 807e 3e0c 1830 60c0
807c cece 7cce ce7c 807c cece 7c18 3060 ]

View file

@ -0,0 +1,63 @@
( 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 ]
( variables )
|0000
@scroll [ &x $2 &y $2 &wait $1 ]
|0100 ( -> )
#90ff .System/r DEO2 #9000 .System/g DEO2 #900f .System/b DEO2
#08e0 .Screen/width DEI2 #01 SFT2 SUB2 .scroll/x STZ2
#09b0 .scroll/y STZ2
;frame .Screen/vector DEO2
#30 .scroll/wait STZ
BRK
@frame ( -> )
#ffff
&loop
DUP2 ,row JSR
INC2
DUP2 .Screen/height DEI2 LTH2 ,&loop JCN
POP2
.scroll/wait LDZ ,&noscroll JCN
.scroll/y LDZ2 INC2 .scroll/y STZ2
BRK
&noscroll
.scroll/wait LDZ #01 SUB .scroll/wait STZ
BRK
@row ( y* -- )
DUP2 .Screen/y DEO2
.scroll/y LDZ2 ADD2
.Screen/width DEI2
&loop
#0001 SUB2
OVR2 OVR2 .scroll/x LDZ2 ADD2 EOR2 DUP2 #0013 DIV2 #0013 MUL2 SUB2
DUP #00 EQU ,&draw JCN
DUP #05 EQU ,&draw JCN
POP2
&rest
DUP2 ORA ,&loop JCN
POP2 POP2
JMP2r
#15 .Screen/pixel DEO
JMP2r
&draw
OVR2 .Screen/x DEO2
#05 ADD .Screen/pixel DEO
.Screen/y DEI2
DUP2 INC2 .Screen/y DEO2
#00 .Screen/pixel DEO
.Screen/y DEO2
POP
,&rest JMP

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

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