commit 18058c1
neauoire
·
2022-04-06 02:13:14 +0000 UTC
parent c9ad8e9
Fixed issue with uxncli
5 files changed,
+169,
-40
M
build.sh
+6,
-3
1@@ -26,7 +26,10 @@ else
2 gcc -std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli
3 fi
4
5-echo "Done."
6+echo "Assembling polycat.."
7+bin/uxncli etc/drifblim.rom etc/polycat.tal && mv etc/polycat.rom bin/
8
9-# echo "Running.."
10-bin/uxn11 ~/roms/left.rom README.md
11+echo "Running.."
12+bin/uxn11 bin/polycat.rom
13+
14+echo "Done."
+0,
-0
+146,
-0
1@@ -0,0 +1,146 @@
2+( Polycat:
3+ A cat with one eye, and the hind and tail of a lizard.
4+ Original character by Rekka Bellum )
5+
6+|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
7+|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixeld $1 &sprite $1
8+|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2
9+
10+|0000
11+
12+@cat &x $2 &y $2 &timer $1
13+@pointer &x $2 &y $2
14+
15+|0100 ( -> )
16+
17+ ( theme )
18+ #0a3f .System/r DEO2
19+ #05df .System/g DEO2
20+ #0caf .System/b DEO2
21+ ( DOS resolution )
22+ #0140 .Screen/width DEO2
23+ #00c8 .Screen/height DEO2
24+ ( vectors )
25+ ;on-mouse .Mouse/vector DEO2
26+ ( find center )
27+ .Screen/width DEI2 #01 SFT2 .cat/x STZ2
28+ .Screen/height DEI2 #01 SFT2 .cat/y STZ2
29+ ( draw ground )
30+ #f6 .Screen/auto DEO
31+ .cat/y LDZ2 #0018 ADD2 .Screen/y DEO2
32+ .cat/x LDZ2 #0010 SUB2 .Screen/x DEO2
33+ ;ground .Screen/addr DEO2
34+ #01 .Screen/sprite DEO
35+ ( init )
36+ #ff ;draw-eye/last STA
37+ #ff ;draw-tail/last STA
38+ ( set screen mode auto-x )
39+ #05 .Screen/auto DEO
40+ ,draw-polycat JSR
41+
42+BRK
43+
44+@draw-polycat ( -- )
45+
46+ ( ears )
47+ .cat/y LDZ2 .Screen/y DEO2
48+ .cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
49+ ;ears .Screen/addr DEO2
50+ #81 .Screen/sprite DEOk DEO
51+ ( body )
52+ .cat/y LDZ2 #0010 ADD2 .Screen/y DEO2
53+ .cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
54+ ;body .Screen/addr DEO2
55+ #81 .Screen/sprite DEO
56+ ( eye/tail )
57+ #00 ,draw-eye JSR
58+ #00 ,draw-tail JSR
59+
60+JMP2r
61+
62+@on-mouse ( -> )
63+
64+ .Mouse/x DEI2 .cat/x LDZ2 GTH2 #50 SFT
65+ .Mouse/y DEI2 .cat/y LDZ2 GTH2 #60 SFT
66+ ADD ,draw-eye JSR
67+ .cat/timer LDZ INC [ DUP ] .cat/timer STZ
68+ #04 SFT ,draw-tail JSR
69+ ,draw-cursor JSR
70+
71+BRK
72+
73+@draw-eye ( quad -- )
74+
75+ DUP ,&last LDR NEQ ,&changed JCN
76+ POP JMP2r &changed
77+ ( only redraw on change )
78+ DUP
79+ #00 SWP ;eye ADD2 .Screen/addr DEO2
80+ .cat/y LDZ2 #0008 ADD2 .Screen/y DEO2
81+ .cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
82+ #81 .Screen/sprite DEOk DEO
83+ ,&last STR
84+
85+JMP2r
86+ &last $1
87+
88+@draw-tail ( frame -- )
89+
90+ STHk ,&last LDR NEQ ,&changed JCN
91+ POPr JMP2r &changed
92+ ( only redraw on change )
93+ STHr #00 OVR ;frames ADD2 LDA
94+ #00 SWP #40 SFT2 ;body/tail ADD2
95+ .Screen/addr DEO2
96+ .cat/x LDZ2 .Screen/x DEO2
97+ .cat/y LDZ2 #0010 ADD2 .Screen/y DEO2
98+ #81 .Screen/sprite DEO
99+ ,&last STR
100+
101+JMP2r
102+ &last $1
103+
104+@draw-cursor ( -- )
105+
106+ ( last cursor )
107+ ;cursor STH2k .Screen/addr DEO2
108+ .pointer/x LDZ2 .Screen/x DEO2
109+ .pointer/y LDZ2 .Screen/y DEO2
110+ #40 .Screen/sprite DEO
111+ ( new cursor )
112+ STH2r .Screen/addr DEO2
113+ .Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
114+ .Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
115+ #41 .Mouse/state DEI #00 NEQ ADD .Screen/sprite DEO
116+
117+JMP2r
118+
119+@cursor
120+ 80c0 e0f0 f8e0 1000
121+@frames
122+ 00 01 02 03 02 01 00 00
123+ 00 00 00 00 00 00 00 00
124+@ears
125+ 081c 3e3e 7f7f ffff 081c 3e3e 7f7f fffc
126+ 081c 3c3e 7e7e ffff 081c 3c3e 7e7e ff1f
127+@eye
128+ ffff ffff ff7f 3f0f f7ef cfe7 f07c 3f0f
129+ ffff ffff fffe fcf0 87c3 c183 071e fcf0
130+ ffff ffff ff7f 3f0f f0e1 c1e0 f07c 3f0f
131+ ffff ffff fffe fcf0 f7fb f9f3 071e fcf0
132+ ffff ffff ff7f 3f0f f0e7 cfef f77c 3f0f
133+ ffff ffff fffe fcf0 0783 c1c3 871e fcf0
134+ ffff ffff ff7f 3f0f f0e0 c1e1 f07c 3f0f
135+ ffff ffff fffe fcf0 07f3 f9fb f71e fcf0
136+@body
137+ 0707 0707 0302 0200 0107 0707 0300 0000
138+ &tail
139+ e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
140+ e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
141+ e0f0 f0e0 e080 8000 c0f2 faf9 fef8 b000
142+ e0f0 f0e0 e080 8000 c0f1 faf9 fef8 b000
143+ 0707 0707 0f08 1000 0307 0707 0f00 0000
144+ e0e0 e0e0 e080 8000 f2f9 f9fe b884 8400
145+@ground
146+ bf00 5c02 0202 020c ef10 6f90 8080 8074
147+ ff00 fe01 0100 0116 fd00 3c40 4040 4028
+1,
-1
1@@ -138,7 +138,7 @@ processEvent(Uxn *u)
2 char buf[7];
3 XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
4 controller_down(u, &u->dev[0x80], get_button(sym));
5- controller_key(u, &u->dev[0x80], sym < 0x80 ? sym : buf[0]);
6+ controller_key(u, &u->dev[0x80], sym < 0x80 ? sym : (Uint8)buf[0]);
7 } break;
8 case KeyRelease: {
9 KeySym sym;
+16,
-36
1@@ -18,7 +18,7 @@ WITH REGARD TO THIS SOFTWARE.
2 */
3
4 static int
5-error(char *msg, const char *err)
6+emu_error(char *msg, const char *err)
7 {
8 fprintf(stderr, "Error %s: %s\n", msg, err);
9 return 0;
10@@ -44,7 +44,7 @@ console_deo(Uint8 *d, Uint8 port)
11 }
12
13 static Uint8
14-uxn11_dei(struct Uxn *u, Uint8 addr)
15+emu_dei(struct Uxn *u, Uint8 addr)
16 {
17 Uint8 p = addr & 0x0f, d = addr & 0xf0;
18 switch(d) {
19@@ -56,7 +56,7 @@ uxn11_dei(struct Uxn *u, Uint8 addr)
20 }
21
22 static void
23-uxn11_deo(Uxn *u, Uint8 addr, Uint8 v)
24+emu_deo(Uxn *u, Uint8 addr, Uint8 v)
25 {
26 Uint8 p = addr & 0x0f, d = addr & 0xf0;
27 u->dev[addr] = v;
28@@ -68,51 +68,31 @@ uxn11_deo(Uxn *u, Uint8 addr, Uint8 v)
29 }
30 }
31
32-static void
33-run(Uxn *u)
34-{
35- while(!u->dev[0x0f]) {
36- int c = fgetc(stdin);
37- if(c != EOF)
38- console_input(u, (Uint8)c);
39- }
40-}
41-
42-int
43-uxn_interrupt(void)
44-{
45- return 1;
46-}
47-
48-static int
49-start(Uxn *u)
50-{
51- if(!uxn_boot(u, (Uint8 *)calloc(0x10200, sizeof(Uint8))))
52- return error("Boot", "Failed");
53- u->dei = uxn11_dei;
54- u->deo = uxn11_deo;
55- return 1;
56-}
57-
58 int
59 main(int argc, char **argv)
60 {
61 Uxn u;
62 int i;
63 if(argc < 2)
64- return error("Usage", "uxncli game.rom args");
65- if(!start(&u))
66- return error("Start", "Failed");
67+ return emu_error("Usage", "uxncli game.rom args");
68+ if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8))))
69+ return emu_error("Boot", "Failed");
70+ u.dei = emu_dei;
71+ u.deo = emu_deo;
72 if(!load_rom(&u, argv[1]))
73- return error("Load", "Failed");
74- fprintf(stderr, ">> Loaded %s\n", argv[1]);
75+ return emu_error("Load", "Failed");
76+ fprintf(stderr, "Loaded %s\n", argv[1]);
77 if(!uxn_eval(&u, PAGE_PROGRAM))
78- return error("Init", "Failed");
79+ return emu_error("Init", "Failed");
80 for(i = 2; i < argc; i++) {
81 char *p = argv[i];
82 while(*p) console_input(&u, *p++);
83 console_input(&u, '\n');
84 }
85- run(&u);
86+ while(!u.dev[0x0f]) {
87+ int c = fgetc(stdin);
88+ if(c != EOF)
89+ console_input(&u, (Uint8)c);
90+ }
91 return 0;
92 }