mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-27 08:13:01 +00:00
Fixed balancing flags
This commit is contained in:
parent
b52417b66c
commit
f792684b44
6 changed files with 112 additions and 27 deletions
|
@ -47,7 +47,7 @@ Program p;
|
||||||
char ops[][4] = {
|
char ops[][4] = {
|
||||||
"BRK", "NOP", "LIT", "LDR", "STR", "---", "JMP", "JSR",
|
"BRK", "NOP", "LIT", "LDR", "STR", "---", "JMP", "JSR",
|
||||||
"EQU", "NEQ", "GTH", "LTH", "AND", "XOR", "SHL", "SHR",
|
"EQU", "NEQ", "GTH", "LTH", "AND", "XOR", "SHL", "SHR",
|
||||||
"POP", "DUP", "SWP", "OVR", "ROT", "---", "CLN", "WSR",
|
"POP", "DUP", "SWP", "OVR", "ROT", "---", "CLN", "STH",
|
||||||
"ADD", "SUB", "MUL", "DIV", "---", "---", "---", "---"
|
"ADD", "SUB", "MUL", "DIV", "---", "---", "---", "---"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
|
||||||
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
||||||
|
|
||||||
# run
|
# run
|
||||||
./bin/assembler projects/software/left.usm bin/boot.rom
|
./bin/assembler projects/software/nasu.usm bin/boot.rom
|
||||||
./bin/emulator bin/boot.rom
|
./bin/emulator bin/boot.rom
|
||||||
|
|
|
@ -1,29 +1,21 @@
|
||||||
( blank )
|
( blank )
|
||||||
|
|
||||||
&Console { pad 8 stdio 1 }
|
;label2d { x 2 y 2 color 1 addr 2 }
|
||||||
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
;picture2d { x 2 y 2 width 2 height 2 color 1 addr 2 }
|
||||||
&Sprite { pad 8 y 2 x 2 addr 2 color 1 }
|
;rect2d { x1 2 y1 2 x2 2 y2 2 }
|
||||||
&Controller { buttons 1 }
|
;point2d { x 2 y 2 }
|
||||||
&Keyboard { key 1 }
|
|
||||||
&Mouse { x 2 y 2 state 1 chord 1 }
|
|
||||||
&File { rname 2 rlen 2 rbin 2 rtxt 2 wname 2 wlen 2 wbin 2 wtxt 2 }
|
|
||||||
|
|
||||||
&Label2d { x 2 y 2 color 1 addr 2 }
|
|
||||||
&Picture2d { x 2 y 2 width 2 height 2 color 1 addr 2 }
|
|
||||||
&Rect2d { x1 2 y1 2 x2 2 y2 2 }
|
|
||||||
&Point2d { x 2 y 2 }
|
|
||||||
|
|
||||||
|0100 @RESET BRK
|
|0100 @RESET BRK
|
||||||
|c000 @FRAME BRK
|
|c000 @FRAME BRK
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|FF00 ;dev/console Console
|
|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
|
||||||
|FF10 ;dev/screen Screen
|
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|FF20 ;dev/sprite Sprite
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|FF30 ;dev/ctrl Controller
|
|FF30 ;Controller { buttons 1 }
|
||||||
|FF40 ;dev/key Keyboard
|
|FF40 ;Keys { key 1 }
|
||||||
|FF50 ;dev/mouse Mouse
|
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|FF60 ;dev/file File
|
|FF60 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ f2ac 35bb 2b53 ] ( palette )
|
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )
|
|
@ -697,7 +697,7 @@ RTN
|
||||||
@load_icn [ feaa d6aa d4aa f400 ]
|
@load_icn [ feaa d6aa d4aa f400 ]
|
||||||
@save_icn [ fe82 8282 848a f400 ]
|
@save_icn [ fe82 8282 848a f400 ]
|
||||||
@filepath1 [ projects/examples/gui.hover.usm 00 ]
|
@filepath1 [ projects/examples/gui.hover.usm 00 ]
|
||||||
@filepath [ projects/software/left.usm 00 ]
|
@filepath [ projects/software/noodle.usm 00 ]
|
||||||
|
|
||||||
|3000 ;document { eof 2 body 8000 }
|
|3000 ;document { eof 2 body 8000 }
|
||||||
|c000 ;clip { len 2 body 256 }
|
|c000 ;clip { len 2 body 256 }
|
||||||
|
@ -709,7 +709,7 @@ RTN
|
||||||
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|FF30 ;Controller { buttons 1 }
|
|FF30 ;Controller { buttons 1 }
|
||||||
|FF40 ;Keys { key 1 }
|
|FF40 ;Keys { key 1 }
|
||||||
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 xt 1 yt 1 }
|
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|FF60 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
|FF60 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|
|
92
projects/software/noodle.usm
Normal file
92
projects/software/noodle.usm
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
(
|
||||||
|
app/noodle : illustration program
|
||||||
|
)
|
||||||
|
|
||||||
|
%RTN { JMP2r }
|
||||||
|
%RTN? { JMP2r? }
|
||||||
|
|
||||||
|
%ABS { DUP #07 SHR #ff SWP MUL? } ( abs )
|
||||||
|
%ABS2 { DUP2 #000f SHR2 #ffff SWP2 SWP POP MUL2? } ( abs2 )
|
||||||
|
|
||||||
|
;cursor { x 2 y 2 }
|
||||||
|
;a { x 2 y 2 }
|
||||||
|
;b { x 2 y 2 }
|
||||||
|
;d { x 2 y 2 }
|
||||||
|
;s { x 2 y 2 }
|
||||||
|
|
||||||
|
|0100 @RESET
|
||||||
|
|
||||||
|
#0020 #0020 #0090 #0070 ,draw-line JSR2
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@FRAME
|
||||||
|
|
||||||
|
,draw-cursor JSR2
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@draw-line ( x1 y1 x2 y2 )
|
||||||
|
|
||||||
|
=b.y =b.x ( target, b )
|
||||||
|
=a.y =a.x ( target, a )
|
||||||
|
|
||||||
|
( dx = abs[bx - ax] )
|
||||||
|
~b.x ~a.x SUB2 ABS2 =d.x
|
||||||
|
|
||||||
|
( dx = abs[bx - ax] )
|
||||||
|
~b.y ~a.y SUB2 ABS2 =d.y
|
||||||
|
|
||||||
|
( sx = ax < bx ? 1 : -1; )
|
||||||
|
#ffff #00 ~a.x ~b.x GTH2 #0002 MUL2 ADD2 =s.x
|
||||||
|
|
||||||
|
( sy = ay < by ? 1 : -1; )
|
||||||
|
#ffff #00 ~a.y ~b.y GTH2 #0002 MUL2 ADD2 =s.y
|
||||||
|
|
||||||
|
|
||||||
|
#01 =Screen.color
|
||||||
|
|
||||||
|
RTN
|
||||||
|
|
||||||
|
@draw-cursor
|
||||||
|
|
||||||
|
~cursor.x ~Mouse.x NEQU2
|
||||||
|
~cursor.y ~Mouse.y NEQU2
|
||||||
|
|
||||||
|
#0000 EQU2 RTN? ( Return if unchanged )
|
||||||
|
|
||||||
|
( clear last cursor )
|
||||||
|
~cursor.x =Sprite.x
|
||||||
|
~cursor.y =Sprite.y
|
||||||
|
,blank_icn =Sprite.addr
|
||||||
|
#10 =Sprite.color
|
||||||
|
|
||||||
|
( record cursor positions )
|
||||||
|
~Mouse.x =cursor.x
|
||||||
|
~Mouse.y =cursor.y
|
||||||
|
|
||||||
|
( draw new cursor )
|
||||||
|
~cursor.x =Sprite.x
|
||||||
|
~cursor.y =Sprite.y
|
||||||
|
,tool_pointer =Sprite.addr
|
||||||
|
#12 =Sprite.color
|
||||||
|
|
||||||
|
RTN
|
||||||
|
|
||||||
|
@tool_pointer [ 80c0 e0f0 f8e0 1000 ]
|
||||||
|
@tool_hand [ 4040 4070 f8f8 f870 ]
|
||||||
|
@tool_eraser [ 2050 b87c 3e1c 0800 ]
|
||||||
|
@blank_icn [ 0000 0000 0000 0000 ]
|
||||||
|
|
||||||
|
|F000 @ERROR BRK
|
||||||
|
|
||||||
|
|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
|
||||||
|
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|
|FF30 ;Controller { buttons 1 }
|
||||||
|
|FF40 ;Keys { key 1 }
|
||||||
|
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|
|FF60 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
||||||
|
|
||||||
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )
|
5
uxn.c
5
uxn.c
|
@ -103,12 +103,12 @@ void (*ops[])(Uxn *u) = {
|
||||||
Uint8 opr[][4] = { /* wstack-/+ rstack-/+ */
|
Uint8 opr[][4] = { /* wstack-/+ rstack-/+ */
|
||||||
{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,1,0,0}, {3,0,0,0}, {1,0,0,0}, {1,0,0,2}, {0,0,2,0},
|
{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,1,0,0}, {3,0,0,0}, {1,0,0,0}, {1,0,0,2}, {0,0,2,0},
|
||||||
{2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0},
|
{2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0},
|
||||||
{1,0,0,0}, {0,2,0,0}, {2,2,0,0}, {2,3,0,0}, {3,3,0,0}, {0,0,0,0}, {1,0,0,1}, {0,1,1,0},
|
{1,0,0,0}, {0,2,0,0}, {2,2,0,0}, {2,3,0,0}, {3,3,0,0}, {0,0,0,0}, {0,0,0,1}, {0,1,1,0},
|
||||||
{2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,2,0,0},
|
{2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,2,0,0},
|
||||||
/* 16-bit */
|
/* 16-bit */
|
||||||
{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,2,0,0}, {4,0,0,0}, {2,0,0,0}, {2,0,0,0}, {0,0,0,0}, /* TODO */
|
{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,2,0,0}, {4,0,0,0}, {2,0,0,0}, {2,0,0,0}, {0,0,0,0}, /* TODO */
|
||||||
{4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, /* TODO */
|
{4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, /* TODO */
|
||||||
{0,2,0,0}, {0,2,0,0}, {1,1,0,0}, {4,6,0,0}, {6,6,0,0}, {0,0,0,0}, {2,0,0,2}, {0,2,2,0}, /* TODO */
|
{0,2,0,0}, {0,2,0,0}, {1,1,0,0}, {4,6,0,0}, {6,6,0,0}, {0,0,0,0}, {0,0,0,2}, {0,2,2,0}, /* TODO */
|
||||||
{4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,2,0,0}
|
{4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,2,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -192,6 +192,7 @@ bootuxn(Uxn *u)
|
||||||
char *cptr = (char *)u;
|
char *cptr = (char *)u;
|
||||||
for(i = 0; i < sizeof(*u); i++)
|
for(i = 0; i < sizeof(*u); i++)
|
||||||
cptr[i] = 0;
|
cptr[i] = 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue