Added lineRect subroutine
This commit is contained in:
parent
f22e6b3837
commit
4693ae1c1c
24
README.md
24
README.md
|
@ -2,6 +2,26 @@
|
||||||
|
|
||||||
A [stack-based VM](https://wiki.xxiivv.com/site/uxn.html), written in ANSI C.
|
A [stack-based VM](https://wiki.xxiivv.com/site/uxn.html), written in ANSI C.
|
||||||
|
|
||||||
|
## 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
|
||||||
|
```
|
||||||
|
|
||||||
## Assembly Syntax
|
## Assembly Syntax
|
||||||
|
|
||||||
### Write
|
### Write
|
||||||
|
@ -67,6 +87,10 @@ BRK
|
||||||
- Auto-advance ldr?
|
- Auto-advance ldr?
|
||||||
- Getting rid of IOR/IOW would be nice..
|
- Getting rid of IOR/IOW would be nice..
|
||||||
- Sending from the wst to the rst, balance mode/flag?
|
- Sending from the wst to the rst, balance mode/flag?
|
||||||
|
- Device that works like an extra memory bank
|
||||||
|
- Line routine
|
||||||
|
- LineRect routine
|
||||||
|
- Draw a chr sprite.
|
||||||
|
|
||||||
## Refs
|
## Refs
|
||||||
|
|
||||||
|
|
11
emulator.c
11
emulator.c
|
@ -190,6 +190,12 @@ consolew(Device *d, Uint8 b)
|
||||||
Uint8
|
Uint8
|
||||||
screenr(Device *d, Uint8 b)
|
screenr(Device *d, Uint8 b)
|
||||||
{
|
{
|
||||||
|
switch(b) {
|
||||||
|
case 0: return (WIDTH >> 8) & 0xff;
|
||||||
|
case 1: return WIDTH & 0xff;
|
||||||
|
case 2: return (HEIGHT >> 8) & 0xff;
|
||||||
|
case 3: return HEIGHT & 0xff;
|
||||||
|
}
|
||||||
return d->mem[b];
|
return d->mem[b];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,11 +299,6 @@ main(int argc, char **argv)
|
||||||
devmouse = portuxn(&u, "mouse", mouser, mousew);
|
devmouse = portuxn(&u, "mouse", mouser, mousew);
|
||||||
devkey = portuxn(&u, "key", keyr, keyw);
|
devkey = portuxn(&u, "key", keyr, keyw);
|
||||||
|
|
||||||
devscreen->mem[0] = (WIDTH >> 8) & 0xff;
|
|
||||||
devscreen->mem[1] = WIDTH & 0xff;
|
|
||||||
devscreen->mem[2] = (HEIGHT >> 8) & 0xff;
|
|
||||||
devscreen->mem[3] = HEIGHT & 0xff;
|
|
||||||
|
|
||||||
start(&u);
|
start(&u);
|
||||||
|
|
||||||
echos(&u.wst, 0x40, "stack");
|
echos(&u.wst, 0x40, "stack");
|
||||||
|
|
|
@ -22,11 +22,22 @@
|
||||||
( fill rect x y w h )
|
( fill rect x y w h )
|
||||||
,0040 ,0040 ,0060 ,0040 ,fillrect JSR
|
,0040 ,0040 ,0060 ,0040 ,fillrect JSR
|
||||||
|
|
||||||
|
|
||||||
,01 ,color STR
|
,01 ,color STR
|
||||||
( fill rect x y w h )
|
( fill rect x y w h )
|
||||||
,00a0 ,0010 ,0020 ,0020 ,fillrect JSR
|
,00a0 ,0010 ,0020 ,0020 ,fillrect JSR
|
||||||
|
|
||||||
|
,02 ,color STR
|
||||||
|
( fill rect x y w h )
|
||||||
|
,00b0 ,0040 ,0020 ,0020 ,linerect JSR
|
||||||
|
|
||||||
|
,03 ,color STR
|
||||||
|
( fill rect x y w h )
|
||||||
|
,0058 ,0028 ,0050 ,0050 ,linerect JSR
|
||||||
|
|
||||||
|
,01 ,color STR
|
||||||
|
( fill rect x y w h )
|
||||||
|
,0028 ,0038 ,0050 ,0030 ,linerect JSR
|
||||||
|
|
||||||
,redraw JSR
|
,redraw JSR
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
@ -37,13 +48,28 @@ BRK
|
||||||
@fillrectrow
|
@fillrectrow
|
||||||
,x LDR^ ,x_ STR^
|
,x LDR^ ,x_ STR^
|
||||||
@fillrectcol
|
@fillrectcol
|
||||||
,x_ LDR^ ,y_ LDR^ ,putpixel JSR
|
( draw ) ,x_ LDR^ ,y_ LDR^ ,putpixel JSR
|
||||||
,x_ LDR^ ,0001 ADD^ ,x_ STR^
|
,x_ LDR^ ,0001 ADD^ ,x_ STR^
|
||||||
,x_ LDR^ ,w LDR^ ,x LDR^ ADD^ LTH^ ,fillrectcol ROT JMP? POP^
|
,x_ LDR^ ,w LDR^ ,x LDR^ ADD^ LTH^ ,fillrectcol ROT JMP? POP^
|
||||||
,y_ LDR^ ,0001 ADD^ ,y_ STR^
|
,y_ LDR^ ,0001 ADD^ ,y_ STR^
|
||||||
,y_ LDR^ ,h LDR^ ,y LDR^ ADD^ LTH^ ,fillrectrow ROT JMP? POP^
|
,y_ LDR^ ,h LDR^ ,y LDR^ ADD^ LTH^ ,fillrectrow ROT JMP? POP^
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@linerect
|
||||||
|
,h STR^ ,w STR^ ,y STR^ ,x STR^
|
||||||
|
,x LDR^ ,x_ STR^ ,y LDR^ ,y_ STR^
|
||||||
|
@linerectcol
|
||||||
|
( draw ) ,x LDR^ ,y_ LDR^ ,putpixel JSR
|
||||||
|
( draw ) ,x LDR^ ,w LDR^ ADD^ ,y_ LDR^ ,putpixel JSR
|
||||||
|
,y_ LDR^ ,0001 ADD^ ,y_ STR^
|
||||||
|
,y_ LDR^ ,h LDR^ ,y LDR^ ADD^ LTH^ ,linerectcol ROT JMP? POP^
|
||||||
|
@linerectrow
|
||||||
|
( draw ) ,x_ LDR^ ,y LDR^ ,putpixel JSR
|
||||||
|
( draw ) ,x_ LDR^ ,y LDR^ ,h LDR^ ADD^ ,putpixel JSR
|
||||||
|
,x_ LDR^ ,0001 ADD^ ,x_ STR^
|
||||||
|
,x_ LDR^ ,w LDR^ ,x LDR^ ADD^ ,0001 ADD^ LTH^ ,linerectrow ROT JMP? POP^
|
||||||
|
RTS
|
||||||
|
|
||||||
@redraw
|
@redraw
|
||||||
,0000 IOW^
|
,0000 IOW^
|
||||||
,0000 IOW^
|
,0000 IOW^
|
||||||
|
|
2
uxn.c
2
uxn.c
|
@ -199,8 +199,6 @@ loaduxn(Uxn *u, char *filepath)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* to start: evaluxn(u, u->vreset); */
|
|
||||||
|
|
||||||
Device *
|
Device *
|
||||||
portuxn(Uxn *u, char *name, Uint8 (*rfn)(Device *, Uint8), Uint8 (*wfn)(Device *, Uint8))
|
portuxn(Uxn *u, char *name, Uint8 (*rfn)(Device *, Uint8), Uint8 (*wfn)(Device *, Uint8))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue