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

Fixed balancing flags

This commit is contained in:
neauoire 2021-03-17 10:18:43 -07:00
parent b52417b66c
commit f792684b44
6 changed files with 112 additions and 27 deletions

View file

@ -47,7 +47,7 @@ Program p;
char ops[][4] = {
"BRK", "NOP", "LIT", "LDR", "STR", "---", "JMP", "JSR",
"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", "---", "---", "---", "---"
};

View file

@ -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
# run
./bin/assembler projects/software/left.usm bin/boot.rom
./bin/assembler projects/software/nasu.usm bin/boot.rom
./bin/emulator bin/boot.rom

View file

@ -1,29 +1,21 @@
( blank )
&Console { pad 8 stdio 1 }
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
&Sprite { pad 8 y 2 x 2 addr 2 color 1 }
&Controller { buttons 1 }
&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 }
;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
|c000 @FRAME BRK
|c000 @FRAME BRK
|d000 @ERROR BRK
|FF00 ;dev/console Console
|FF10 ;dev/screen Screen
|FF20 ;dev/sprite Sprite
|FF30 ;dev/ctrl Controller
|FF40 ;dev/key Keyboard
|FF50 ;dev/mouse Mouse
|FF60 ;dev/file File
|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 [ f2ac 35bb 2b53 ] ( palette )
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )

View file

@ -697,7 +697,7 @@ RTN
@load_icn [ feaa d6aa d4aa f400 ]
@save_icn [ fe82 8282 848a f400 ]
@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 }
|c000 ;clip { len 2 body 256 }
@ -709,7 +709,7 @@ RTN
|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 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 }
|FFF0 .RESET .FRAME .ERROR ( vectors )

View 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
View file

@ -103,12 +103,12 @@ void (*ops[])(Uxn *u) = {
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},
{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},
/* 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 */
{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}
};
@ -192,6 +192,7 @@ bootuxn(Uxn *u)
char *cptr = (char *)u;
for(i = 0; i < sizeof(*u); i++)
cptr[i] = 0;
return 1;
}