2021-01-29 14:17:59 -05:00
|
|
|
# Uxn
|
|
|
|
|
2021-02-08 17:49:45 -05:00
|
|
|
A [stack-based VM](https://wiki.xxiivv.com/site/uxn.html), written in ANSI C.
|
2021-01-29 14:35:59 -05:00
|
|
|
|
2021-02-11 21:48:45 -05:00
|
|
|
## Setup
|
|
|
|
|
|
|
|
If you wish to build your own emulator, you can create a new instance of Uxn like:
|
|
|
|
|
|
|
|
```
|
|
|
|
#include "uxn.h"
|
|
|
|
|
|
|
|
Uxn u;
|
|
|
|
|
|
|
|
if(!bootuxn(&u))
|
|
|
|
return error("Boot", "Failed");
|
|
|
|
if(!loaduxn(&u, argv[1]))
|
|
|
|
return error("Load", "Failed");
|
|
|
|
if(!init())
|
|
|
|
return error("Init", "Failed");
|
|
|
|
|
|
|
|
evaluxn(u, u->vreset); /* Once on start */
|
|
|
|
evaluxn(u, u->vframe); /* Each frame
|
|
|
|
```
|
|
|
|
|
2021-03-11 23:41:35 -05:00
|
|
|
## Uxambly
|
2021-01-29 14:35:59 -05:00
|
|
|
|
2021-03-11 23:41:35 -05:00
|
|
|
Read more in the [Uxambly Guide](https://wiki.xxiivv.com/site/uxambly.html).
|
2021-02-06 13:39:13 -05:00
|
|
|
|
2021-01-29 14:35:59 -05:00
|
|
|
```
|
2021-02-23 16:49:36 -05:00
|
|
|
( hello world )
|
2021-01-30 17:25:48 -05:00
|
|
|
|
2021-03-16 12:27:51 -04:00
|
|
|
%RTN { JMP2r }
|
|
|
|
|
2021-03-21 17:37:39 -04:00
|
|
|
( devices )
|
|
|
|
|
|
|
|
|0100 ;Console { pad 8 char 1 byte 1 short 2 }
|
|
|
|
|01F0 .RESET .FRAME .ERROR ( vectors )
|
|
|
|
|01F8 [ 13fd 1ef3 1bf2 ] ( palette )
|
|
|
|
|
|
|
|
( program )
|
|
|
|
|
|
|
|
|0200 @RESET
|
2021-02-23 16:49:36 -05:00
|
|
|
|
2021-03-11 15:19:59 -05:00
|
|
|
,text1 ,print-label JSR2
|
|
|
|
,text2 ,print-label JSR2
|
2021-03-13 20:34:08 -05:00
|
|
|
#ab =Console.byte
|
|
|
|
#cdef =Console.short
|
2021-02-07 23:49:00 -05:00
|
|
|
|
2021-02-13 16:21:05 -05:00
|
|
|
BRK
|
2021-02-05 17:01:34 -05:00
|
|
|
|
2021-02-23 16:49:36 -05:00
|
|
|
@print-label ( text )
|
2021-03-11 15:19:59 -05:00
|
|
|
|
2021-03-11 18:47:28 -05:00
|
|
|
$loop NOP
|
2021-03-13 20:34:08 -05:00
|
|
|
( send ) DUP2 LDR =Console.char
|
2021-03-11 18:47:28 -05:00
|
|
|
( incr ) #0001 ADD2
|
2021-03-16 12:27:51 -04:00
|
|
|
( loop ) DUP2 LDR #00 NEQ ^$loop MUL JMP
|
2021-02-23 16:49:36 -05:00
|
|
|
POP2
|
2021-03-01 12:38:54 -05:00
|
|
|
|
2021-03-14 17:26:17 -04:00
|
|
|
RTN
|
2021-02-23 16:49:36 -05:00
|
|
|
|
2021-03-11 18:47:28 -05:00
|
|
|
@text1 [ Welcome 20 to 20 UxnVM 0a00 ]
|
|
|
|
@text2 [ Hello 20 World 0a00 ]
|
2021-02-07 23:49:00 -05:00
|
|
|
|
2021-02-23 16:49:36 -05:00
|
|
|
|c000 @FRAME
|
|
|
|
|d000 @ERROR
|
2021-01-29 14:35:59 -05:00
|
|
|
```
|
|
|
|
|
2021-02-08 17:49:45 -05:00
|
|
|
## TODOs
|
2021-02-01 14:58:47 -05:00
|
|
|
|
2021-02-26 13:16:35 -05:00
|
|
|
### OS Boot Disk
|
2021-02-14 20:00:17 -05:00
|
|
|
|
2021-02-26 13:16:35 -05:00
|
|
|
- Load external disk in disk2
|
|
|
|
|
|
|
|
### Assembler
|
2021-02-14 20:00:17 -05:00
|
|
|
|
|
|
|
- Includes
|
|
|
|
- Defines
|
2021-03-10 22:41:46 -05:00
|
|
|
- Jump helpers
|
2021-03-22 12:56:33 -04:00
|
|
|
- Implement Peek/Pook to helpers
|
|
|
|
- Create a theme designer application
|
|
|
|
- DateTime device
|
|
|
|
- Document controller.player2
|
2021-03-14 16:30:17 -04:00
|
|
|
|
2021-03-11 15:19:59 -05:00
|
|
|
## Notes
|
|
|
|
|
2021-03-08 13:30:13 -05:00
|
|
|
## Palettes
|
|
|
|
|
|
|
|
- `[ 6a03 4a0d aa0c ]`, purple/cyan
|
|
|
|
- `[ a1f3 a14d a16c ]`, grey-pink/teal
|
|
|
|
|
2021-01-30 17:25:48 -05:00
|
|
|
## Refs
|
|
|
|
|
|
|
|
https://code.9front.org/hg/plan9front/file/a7f9946e238f/sys/src/games/nes/cpu.c
|
|
|
|
http://www.w3group.de/stable_glossar.html
|
|
|
|
http://www.emulator101.com/6502-addressing-modes.html
|
|
|
|
http://forth.works/8f0c04f616b6c34496eb2141785b4454
|
2021-02-05 23:18:30 -05:00
|
|
|
https://justinmeiners.github.io/lc3-vm/
|