Browse code

Fixed balancing flags

neauoire authored on 17/03/2021 17:18:43
Showing 6 changed files
... ...
@@ -47,7 +47,7 @@ Program p;
47 47
 char ops[][4] = {
48 48
 	"BRK", "NOP", "LIT", "LDR", "STR", "---", "JMP", "JSR", 
49 49
 	"EQU", "NEQ", "GTH", "LTH", "AND", "XOR", "SHL", "SHR",
50
-	"POP", "DUP", "SWP", "OVR", "ROT", "---", "CLN", "WSR",
50
+	"POP", "DUP", "SWP", "OVR", "ROT", "---", "CLN", "STH",
51 51
 	"ADD", "SUB", "MUL", "DIV", "---", "---", "---", "---"
52 52
 };
53 53
 
... ...
@@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
20 20
 # cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
21 21
 
22 22
 # run
23
-./bin/assembler projects/software/left.usm bin/boot.rom
23
+./bin/assembler projects/software/nasu.usm bin/boot.rom
24 24
 ./bin/emulator bin/boot.rom
... ...
@@ -1,29 +1,21 @@
1 1
 ( blank )
2 2
 
3
-&Console    { pad 8 stdio 1 }
4
-&Screen     { width 2 height 2 pad 4 y 2 x 2 color 1 }
5
-&Sprite     { pad 8 y 2 x 2 addr 2 color 1 }
6
-&Controller { buttons 1 }
7
-&Keyboard   { key 1 }
8
-&Mouse      { x 2 y 2 state 1 chord 1 }
9
-&File       { rname 2 rlen 2 rbin 2 rtxt 2 wname 2 wlen 2 wbin 2 wtxt 2 }
10
-
11
-&Label2d { x 2 y 2 color 1 addr 2 }
12
-&Picture2d { x 2 y 2 width 2 height 2 color 1 addr 2 }
13
-&Rect2d { x1 2 y1 2 x2 2 y2 2 }
14
-&Point2d { x 2 y 2 }
3
+;label2d { x 2 y 2 color 1 addr 2 }
4
+;picture2d { x 2 y 2 width 2 height 2 color 1 addr 2 }
5
+;rect2d { x1 2 y1 2 x2 2 y2 2 }
6
+;point2d { x 2 y 2 }
15 7
 
16 8
 |0100 @RESET BRK
17
-|c000 @FRAME BRK 
9
+|c000 @FRAME BRK
18 10
 |d000 @ERROR BRK 
19 11
 
20
-|FF00 ;dev/console Console
21
-|FF10 ;dev/screen  Screen
22
-|FF20 ;dev/sprite  Sprite
23
-|FF30 ;dev/ctrl    Controller
24
-|FF40 ;dev/key     Keyboard
25
-|FF50 ;dev/mouse   Mouse
26
-|FF60 ;dev/file    File
12
+|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
13
+|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
14
+|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
15
+|FF30 ;Controller { buttons 1 }
16
+|FF40 ;Keys { key 1 }
17
+|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
18
+|FF60 ;File { pad 8 name 2 length 2 load 2 save 2 }
27 19
 
28 20
 |FFF0 .RESET .FRAME .ERROR ( vectors )
29
-|FFF8 [ f2ac 35bb 2b53 ] ( palette )
21
+|FFF8 [ 13fd 1ef3 1bf2 ]   ( palette )
30 22
\ No newline at end of file
... ...
@@ -697,7 +697,7 @@ RTN
697 697
 @load_icn      [ feaa d6aa d4aa f400 ]
698 698
 @save_icn      [ fe82 8282 848a f400 ]
699 699
 @filepath1     [ projects/examples/gui.hover.usm 00 ]
700
-@filepath      [ projects/software/left.usm 00 ]
700
+@filepath      [ projects/software/noodle.usm 00 ]
701 701
 
702 702
 |3000 ;document { eof 2 body 8000 }
703 703
 |c000 ;clip { len 2 body 256 }
... ...
@@ -709,7 +709,7 @@ RTN
709 709
 |FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
710 710
 |FF30 ;Controller { buttons 1 }
711 711
 |FF40 ;Keys { key 1 }
712
-|FF50 ;Mouse { x 2 y 2 state 1 chord 1 xt 1 yt 1 }
712
+|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
713 713
 |FF60 ;File { pad 8 name 2 length 2 load 2 save 2 }
714 714
 
715 715
 |FFF0 .RESET .FRAME .ERROR ( vectors )
716 716
new file mode 100644
... ...
@@ -0,0 +1,92 @@
1
+( 
2
+	app/noodle : illustration program
3
+)
4
+
5
+%RTN   { JMP2r }
6
+%RTN?  { JMP2r? }
7
+
8
+%ABS { DUP #07 SHR #ff SWP MUL? } ( abs )
9
+%ABS2 { DUP2 #000f SHR2 #ffff SWP2 SWP POP MUL2? } ( abs2 )
10
+
11
+;cursor { x 2 y 2 }
12
+;a { x 2 y 2 }
13
+;b { x 2 y 2 }
14
+;d { x 2 y 2 }
15
+;s { x 2 y 2 }
16
+
17
+|0100 @RESET 
18
+
19
+	#0020 #0020 #0090 #0070 ,draw-line JSR2
20
+
21
+BRK
22
+
23
+@FRAME 
24
+
25
+	,draw-cursor JSR2
26
+
27
+BRK
28
+
29
+@draw-line ( x1 y1 x2 y2 )
30
+
31
+	=b.y =b.x ( target, b )
32
+	=a.y =a.x ( target, a )
33
+
34
+	( dx = abs[bx - ax] )
35
+	~b.x ~a.x SUB2 ABS2 =d.x
36
+
37
+	( dx = abs[bx - ax] )
38
+	~b.y ~a.y SUB2 ABS2 =d.y
39
+
40
+	( sx = ax < bx ? 1 : -1; )
41
+	#ffff #00 ~a.x ~b.x GTH2 #0002 MUL2 ADD2 =s.x 
42
+	
43
+	( sy = ay < by ? 1 : -1; )
44
+	#ffff #00 ~a.y ~b.y GTH2 #0002 MUL2 ADD2 =s.y 
45
+	
46
+
47
+	#01 =Screen.color
48
+
49
+RTN
50
+
51
+@draw-cursor
52
+
53
+	~cursor.x ~Mouse.x NEQU2
54
+	~cursor.y ~Mouse.y NEQU2
55
+
56
+	#0000 EQU2 RTN? ( Return if unchanged )
57
+
58
+	( clear last cursor )
59
+	~cursor.x =Sprite.x
60
+	~cursor.y =Sprite.y
61
+	,blank_icn =Sprite.addr
62
+	#10 =Sprite.color
63
+
64
+	( record cursor positions )
65
+	~Mouse.x =cursor.x 
66
+	~Mouse.y =cursor.y
67
+
68
+	( draw new cursor )
69
+	~cursor.x =Sprite.x
70
+	~cursor.y =Sprite.y
71
+	,tool_pointer =Sprite.addr
72
+	#12 =Sprite.color
73
+
74
+RTN
75
+
76
+@tool_pointer [ 80c0 e0f0 f8e0 1000 ]
77
+@tool_hand    [ 4040 4070 f8f8 f870 ]
78
+@tool_eraser  [ 2050 b87c 3e1c 0800 ]
79
+@blank_icn    [ 0000 0000 0000 0000 ]
80
+
81
+|F000 @ERROR BRK 
82
+
83
+|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
84
+|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
85
+|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
86
+|FF30 ;Controller { buttons 1 }
87
+|FF40 ;Keys { key 1 }
88
+|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
89
+|FF60 ;File { pad 8 name 2 length 2 load 2 save 2 }
90
+
91
+|FFF0 .RESET .FRAME .ERROR ( vectors )
92
+|FFF8 [ 13fd 1ef3 1bf2 ]   ( palette )
0 93
\ No newline at end of file
... ...
@@ -103,12 +103,12 @@ void (*ops[])(Uxn *u) = {
103 103
 Uint8 opr[][4] = { /* wstack-/+ rstack-/+ */
104 104
 	{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}, 
105 105
 	{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},
106
-	{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},
106
+	{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},
107 107
 	{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},
108 108
 	/* 16-bit */
109 109
 	{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 */
110 110
 	{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 */
111
-	{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 */
111
+	{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 */
112 112
 	{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}
113 113
 };
114 114
 
... ...
@@ -192,6 +192,7 @@ bootuxn(Uxn *u)
192 192
 	char *cptr = (char *)u;
193 193
 	for(i = 0; i < sizeof(*u); i++)
194 194
 		cptr[i] = 0;
195
+
195 196
 	return 1;
196 197
 }
197 198