~rabbits/ornithologics

f6f159f8cad7326e24988c1ffb5a6fd79ceb616f — neauoire 2 years ago
Init
6 files changed, 324 insertions(+), 0 deletions(-)

A .gitignore
A LICENSE
A README.md
A build.sh
A etc/cons.tal
A src/ornithologics.tal
A  => .gitignore +8 -0
@@ 1,8 @@
.DS*
*jpg
*png
*bmp
/bin
*.chr
.snarf
.theme
\ No newline at end of file

A  => LICENSE +21 -0
@@ 1,21 @@
MIT License

Copyright (c) Devine Lu Linvega

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

A  => README.md +16 -0
@@ 1,16 @@
# Ornithologics

A [combinatory logic](https://wiki.xxiivv.com/site/logic.html) playground, written in [Uxntal](https://wiki.xxiivv.com/site/uxntal.html).

## Build

You must have the [Uxn](https://git.sr.ht/~rabbits/uxn/) assembler and emulator.

```
uxnasm src/ornithologics.tal bin/i.rom && uxnemu bin/i.rom
```

## Extra

- [Ask a question](https://llllllll.co/t/uxn-virtual-computer/46103)
- [Support](https://www.patreon.com/100)

A  => build.sh +24 -0
@@ 1,24 @@
#!/usr/bin/env bash

echo "Cleaning.."
rm -rf bin
mkdir bin

echo "Assembling.."
uxnasm src/ornithologics.tal bin/ornithologics.rom 

echo "Installing.."
if [ -d "$HOME/roms" ] && [ -e ./bin/ornithologics.rom ]
then
	cp ./bin/ornithologics.rom $HOME/roms
    echo "Installed in $HOME/roms" 
fi

if [ "${1}" = '--push' ]; 
then
	echo "Pushing.."
	~/Applications/butler push bin/ornithologics.rom hundredrabbits/ornithologics:uxn
fi

echo "Running.."
uxncli bin/ornithologics.rom

A  => etc/cons.tal +106 -0
@@ 1,106 @@
( uxnasm cons.tal cons.rom && uxncli cons.rom )

|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1

|0100

	;nil JSR2
		;cat ;cons JSR2
			;dog ;cons JSR2
				;owl ;cons JSR2
	;nil JSR2
		;ant ;cons JSR2
			;bat ;cons JSR2
				;cow ;cons JSR2
	;nil JSR2
		SWP2 ;cons JSR2
			SWP2 ;cons JSR2
	;echo JSR2
	
	#0a18 DEO
	#010e DEO
	#010f DEO

BRK

( cons )

@alloc ( -- cell* )

	[ LIT2 &next :memory ] DUP2 #0004 ADD2 ,&next STR2

JMP2r

@nil ( -- list* )

	,alloc JSR ;nil

@cons ( list* fn* -- list* )

	( car ) ,alloc JSR STH2k STA2
	( cdr ) STH2kr INC2 INC2 STA2
	STH2r

JMP2r

@eval ( list* -- )

	&w LDA2k JSR2 INC2 INC2 LDA2 LDA2k ;nil NEQ2 ,&w JCN
	POP2

JMP2r

@last ( list* -- cell* )

	&w INC2 INC2 LDA2 LDA2k ;nil NEQ2 ,&w JCN
	INC2 INC2

JMP2r

@join ( list-a* list-b* -- list-b* )

	STH2k ,last JSR INC2 INC2 STA2 STH2r

JMP2r

@length ( list* -- length* )

	LIT2r 0000
	&w INC2 INC2 INC2r LDA2 LDA2k ;nil NEQ2 ,&w JCN
	POP2 STH2r

JMP2r

@echo ( list* -- )

	#2818 DEO #2018 DEO
	&w
		LDA2k INC2 INC2 LDA2 ;nil EQU2 ,&value JCN
			( list ) LDA2k ;echo JSR2 ,&resume JMP
			&value LDA2k LDA2 ,print JSR #2018 DEO
		&resume
		INC2 INC2 LDA2
		LDA2k ;nil NEQ2 ,&w JCN
	POP2
	#2918 DEO #2018 DEO

JMP2r

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

( some functions )

@cat 0000 :nil
@dog 0001 :nil
@bat 0002 :nil
@ant 0003 :nil
@owl 0004 :nil
@cow 0005 :nil

@memory
\ No newline at end of file

A  => src/ornithologics.tal +149 -0
@@ 1,149 @@
( uxnasm cons.tal cons.rom && uxncli cons.rom )

|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1

|0100

	;nil JSR2
		;z ;cons JSR2
			;y ;cons JSR2
				;x ;cons JSR2
	;nil JSR2
		;c ;cons JSR2
			;b ;cons JSR2
				;a ;cons JSR2
	;nil JSR2
		SWP2 ;cons JSR2
			SWP2 ;cons JSR2
	;echo JSR2

	#0a18 DEO
	#010e DEO
	#010f DEO

BRK

( cons )

@alloc ( -- cell* )

	[ LIT2 &next :memory ] DUP2 #0004 ADD2 ,&next STR2

JMP2r

@nil ( -- list* )

	,alloc JSR ;nil

@cons ( list* fn* -- list* )

	( car ) ,alloc JSR STH2k STA2
	( cdr ) STH2kr INC2 INC2 STA2
	STH2r

JMP2r

@pop ( list* -- list* )

	INC2 INC2 LDA2

JMP2r

@dup ( list* -- list* )

	LDA2k ,cons JSR

JMP2r

@last ( list* -- cell* )

	&w INC2 INC2 LDA2 LDA2k ;nil NEQ2 ,&w JCN
	INC2 INC2

JMP2r

@join ( list-a* list-b* -- list-b* )

	STH2k ,last JSR INC2 INC2 STA2 STH2r

JMP2r

@length ( list* -- length* )

	LIT2r 0000
	&w INC2 INC2 INC2r LDA2 LDA2k ;nil NEQ2 ,&w JCN
	POP2 STH2r

JMP2r

@echo ( list* -- )

	#2818 DEO #2018 DEO
	&w
		LDA2k INC2 INC2 LDA2 ;nil EQU2 ,&fn JCN
			( list )
			LDA2k ;echo JSR2 ,&resume JMP
			&fn
			LDA2k LDA2 ,print JSR #2018 DEO
		&resume
		INC2 INC2 LDA2 LDA2k ;nil NEQ2 ,&w JCN
	POP2
	#2918 DEO #2018 DEO

JMP2r

@eval ( list* -- )
	
	DUP2 ;print JSR2 #0a18 DEO
	&w
		LDA2k INC2 INC2 LDA2 ;nil EQU2 ,&fn JCN
			( list )
			LDA2k ;eval JSR2 ,&resume JMP
			&fn
			LDA2k LDA2 OVR #07 SFT JMP JSR2k POP2
		&resume
		INC2 INC2 LDA2 LDA2k ;nil NEQ2 ,&w JCN
	POP2

JMP2r

@step ( list* -- )

	INC2k INC2 LDA2 SWP2 LDA2 LDA2 JSR2

JMP2r

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

( some functions )

@x 8000 :nil
@y 8001 :nil
@z 8002 :nil
@a 8003 :nil
@b 8004 :nil
@c 8005 :nil

@m :mockingbird :nil

( Bekimet )

@mockingbird ( list* fn* -- )

	OVR2
		DUP2 INC2 INC2 LDA2 LDA2 LDA2 ;print JSR2 #0a18 DEO

		DUP2 INC2 INC2 LDA2 INC2 INC2 LDA2 LDA2 LDA2 ;print JSR2 #0a18 DEO
	POP2
	( OVR2 INC2 INC2 LDA2 INC2 INC2 LDA2 LDA2 ;print JSR2 )
	

JMP2r

@memory
\ No newline at end of file