commit a18193a
Devine Lu Linvega
·
2025-07-01 20:39:02 +0000 UTC
parent cb69573
Fixed issue with expansion port
5 files changed,
+211,
-10
+191,
-0
1@@ -0,0 +1,191 @@
2+( Controller: Buttons should highlight on press and display the button and key bytes. )
3+
4+|00 @System/vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
5+|20 @Screen/vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
6+|80 @Controller/vector $2 &button $1 &key $1
7+
8+|000
9+
10+ @center/x $2 &y $2
11+
12+|100
13+
14+@on-reset ( -> )
15+ ( | theme )
16+ #0fff .System/r DEO2
17+ #0f0f .System/g DEO2
18+ #0f0f .System/b DEO2
19+ ( | find center )
20+ .Screen/width DEI2 #01 SFT2 .center/x STZ2
21+ .Screen/height DEI2 #01 SFT2 .center/y STZ2
22+ controller/<draw>
23+ ;on-button .Controller/vector DEO2
24+ BRK
25+
26+@on-button ( -> )
27+ controller/<draw>
28+ ( | print stack on start button )
29+ [ LIT2 08 -Controller/button ] DEI NEQ ?{ #010e DEO }
30+ BRK
31+
32+(
33+@|Controller )
34+
35+@controller/<draw> ( -- )
36+ .Controller/button DEI2
37+ ( | background )
38+ .center/x LDZ2 #0040 SUB2 .Screen/x DEO2
39+ .center/y LDZ2 #0020 SUB2 .Screen/y DEO2
40+ #01f9 ;&icns #f6 <draw-times>
41+ ( | output )
42+ .Screen/x DEI2 #0010 ADD2 .Screen/x DEO2
43+ .Screen/y DEI2 #0050 SUB2 .Screen/y DEO2
44+ DUP2 hex/<draw-short>
45+ ( | A button )
46+ OVR #01 AND #00 EQU ?{
47+ .center/x LDZ2 #0028 ADD2 .Screen/x DEO2
48+ .center/y LDZ2 .Screen/y DEO2
49+ #01fe ;large/icns #16 <draw-times> }
50+ ( | B button )
51+ OVR #02 AND #00 EQU ?{
52+ .center/x LDZ2 #0010 ADD2 .Screen/x DEO2
53+ .center/y LDZ2 .Screen/y DEO2
54+ #01fe ;large/icns #16 <draw-times> }
55+ ( | C button )
56+ OVR #04 AND #00 EQU ?{
57+ .center/x LDZ2 #0008 SUB2 .Screen/x DEO2
58+ .center/y LDZ2 #0008 ADD2 .Screen/y DEO2
59+ #01ff ;small/icn #16 <draw-times> }
60+ ( | S button )
61+ OVR #08 AND #00 EQU ?{
62+ .center/x LDZ2 #0018 SUB2 .Screen/x DEO2
63+ .center/y LDZ2 #0008 ADD2 .Screen/y DEO2
64+ #01ff ;small/icn #16 <draw-times> }
65+ ( | Up arrow )
66+ OVR #10 AND #00 EQU ?{
67+ .center/x LDZ2 #0030 SUB2 .Screen/x DEO2
68+ .center/y LDZ2 #0008 SUB2 .Screen/y DEO2
69+ #05ff ;arrow/icn #00 <draw-times> }
70+ ( | Down arrow )
71+ OVR #20 AND #00 EQU ?{
72+ .center/x LDZ2 #0030 SUB2 .Screen/x DEO2
73+ .center/y LDZ2 #0008 ADD2 .Screen/y DEO2
74+ #05ff ;arrow/icn #00 <draw-times> }
75+ ( | Left arrow )
76+ OVR #40 AND #00 EQU ?{
77+ .center/x LDZ2 #0038 SUB2 .Screen/x DEO2
78+ .center/y LDZ2 .Screen/y DEO2
79+ #05ff ;arrow/icn #00 <draw-times> }
80+ ( | Right arrow )
81+ OVR #80 AND #00 EQU ?{
82+ .center/x LDZ2 #0028 SUB2 .Screen/x DEO2
83+ .center/y LDZ2 .Screen/y DEO2
84+ #05ff ;arrow/icn #00 <draw-times> }
85+ POP2 JMP2r
86+
87+@<draw-times> ( color times addr* auto -- )
88+ .Screen/auto DEO
89+ .Screen/addr DEO2
90+ SWP STH
91+ [ LITr -Screen/sprite ]
92+ &>l
93+ DEOkr
94+ INC DUP ?&>l
95+ POP POP2r JMP2r
96+
97+(
98+@|drawing )
99+
100+@hex/<draw-short> ( short* -- )
101+ [ LIT2 01 -Screen/auto ] DEO
102+ SWP /<draw-byte>
103+ ( >> )
104+
105+@hex/<draw-byte> ( byte -- )
106+ DUP #04 SFT /<draw-char>
107+ ( >> )
108+
109+@hex/<draw-char> ( char -- )
110+ #00 SWP #0f AND #30 SFT2 ;&icns ADD2 .Screen/addr DEO2
111+ [ LIT2 03 -Screen/sprite ] DEO
112+ JMP2r
113+
114+(
115+@|assets )
116+
117+@large/icns [
118+ 071f 3f7f 7fff ffff e0f8 fcfe feff ffff
119+ ffff ff7f 7f3f 1f07 ffff fffe fefc f8e0 ]
120+
121+@small/icn [ 0000 001f 3f3f 3f1f 0000 00f8 fcfc fcf8 ]
122+
123+@arrow/icn [ 187e 7eff ff7e 7e18 ]
124+
125+@controller/icns [
126+ 0000 0f30 4040 8080 0000 ff00 0000 0000
127+ 0042 8100 0000 0000 0000 ff00 0000 0000
128+ 0000 ff00 0000 0000 0000 ff00 0000 0000
129+ 0000 ff00 0000 0000 0000 ff00 0000 0000
130+ 0000 ff00 0000 0000 0000 ff00 0000 0000
131+ 0000 ff00 0000 0000 0000 ff00 0000 0000
132+ 0000 ff00 0000 0000 0000 ff00 0000 0000
133+ 0000 ff00 0000 0000 0000 f00c 0202 0101
134+ 8080 8080 8080 8080 0000 0000 0000 0000
135+ 0000 0000 0000 0000 0000 0000 0000 0000
136+ 0000 0000 0000 0000 0000 0000 0000 0000
137+ 0000 0000 0000 0000 0000 0000 0000 0000
138+ 0000 0000 0000 0000 0000 0000 0000 0000
139+ 0000 0000 0000 0000 0000 0000 0000 0000
140+ 0000 0000 0000 0000 0000 0000 0000 0000
141+ 0000 0000 0000 0000 0101 0101 0101 0101
142+ 8080 8080 8080 8080 0000 0000 0000 0000
143+ 0000 0000 0000 0018 0000 0000 0000 0000
144+ 0000 0000 0000 0000 0000 0000 0000 0000
145+ 0000 0000 0000 0000 0000 0000 0000 0000
146+ 0000 0000 0000 0000 0000 0000 0000 0000
147+ 0000 0000 0000 0302 0000 0000 0000 8040
148+ 0000 0000 0000 0000 0000 0000 0000 0102
149+ 0000 0000 0000 8040 0101 0101 0101 0101
150+ 8080 8080 8080 8080 0000 0001 0101 011f
151+ 6681 8100 0000 0000 0000 0080 8080 80f8
152+ 0000 0000 0000 0000 0000 0000 0000 0000
153+ 0000 0000 0000 0000 0000 0000 0000 0000
154+ 0000 0000 0000 0000 0000 0000 0000 0000
155+ 0203 0202 0300 0000 4080 4040 8000 0000
156+ 0000 0000 0000 0000 0203 0202 0200 0000
157+ 40c0 4040 4000 0000 0101 0101 0101 0101
158+ 8080 8081 8180 8080 6080 8000 0080 8060
159+ 0000 0000 0000 0000 0601 0100 0001 0106
160+ 0000 0080 8000 0000 0001 0202 0100 0201
161+ 0080 4000 8040 4080 0001 0202 0202 0201
162+ 0080 4000 0000 4080 0000 0000 0000 0000
163+ 0718 2040 4080 8080 e018 0402 0201 0101
164+ 0000 0000 0000 0000 0718 2040 4080 8080
165+ e018 0402 0201 0101 0101 0101 0101 0101
166+ 8080 8080 8080 8080 1f01 0101 0100 0000
167+ 0000 0000 0081 8166 f880 8080 8000 0000
168+ 0000 0000 0000 0000 0000 001f 2020 201f
169+ 0000 00f8 0404 04f8 0000 001f 2020 201f
170+ 0000 00f8 0404 04f8 0000 0000 0000 0000
171+ 8080 8040 4020 1807 0101 0102 0204 18e0
172+ 0000 0000 0000 0000 8080 8040 4020 1807
173+ 0101 0102 0204 18e0 0101 0101 0101 0101
174+ 8080 8080 4040 300f 0000 0000 0000 00ff
175+ 1800 0000 0000 00ff 0000 0000 0000 00ff
176+ 0000 0000 0000 00ff 0000 0000 0000 00ff
177+ 0000 0000 0000 00ff 0000 0000 0000 00ff
178+ 0000 0000 0000 00ff 0000 0000 0000 00ff
179+ 0000 0000 0000 00ff 0000 0000 0000 00ff
180+ 0000 0000 0000 00ff 0000 0000 0000 00ff
181+ 0000 0000 0000 00ff 0101 0101 0202 0cf0 ]
182+
183+@hex/icns [
184+ 0018 2424 2424 2418 0008 1808 0808 0808
185+ 0018 2404 1820 203c 0018 2404 1804 2418
186+ 0024 2424 1c04 0404 003c 2020 1804 2418
187+ 0018 2420 3824 2418 003c 0408 1010 1010
188+ 0018 2424 1824 2418 0018 2424 1c04 2418
189+ 0018 2424 3c24 2424 0038 2424 3824 2438
190+ 0018 2420 2020 2418 0038 2424 2424 2438
191+ 001c 2020 3820 201c 001c 2020 3820 2020 ]
192+
+3,
-3
1@@ -24,7 +24,7 @@
2 ;dict/fill ;buf #0013 ;res4 mem/cmp <test>
3 ( | boundary check )
4 ;mmu-over .System/expansion DEO2
5- ;dict/fill #0000 LDA #ffff LDA #8888 EQU2 <test>
6+ ;dict/over #0000 LDA #ffff LDA #8888 EQU2 <test>
7 BRK
8
9 @<test> ( name* f -- )
10@@ -49,7 +49,7 @@
11 &cpyl "Expansion/cpyl: 20 $1
12 &cpyr "Expansion/cpyr: 20 $1
13 &fill "Expansion/fill: 20 $1
14- &over "Expansion/Overflow: 20 $1
15+ &over "Expansion/overflow: 20 $1
16 &pass "pass 0a $1
17 &fail "FAIL 0a $1
18
19@@ -63,5 +63,5 @@
20 @mmu-cpyl [ 01 0007 0000 &a $2 0000 &b $2 ]
21 @mmu-cpyr [ 02 0007 0000 &a $2 0000 &b $2 ]
22
23-@mmu-over [ 00 0000 0002 ffff 88 ]
24+@mmu-over [ 00 0002 0000 ffff 88 ]
25
M
makefile
+11,
-1
1@@ -20,6 +20,12 @@ gui: all bin/uxn11-debug bin/screen.rom
2 bin/uxn11-debug -v
3 bin/uxn11-debug bin/screen.rom
4
5+mouse: bin/uxn11-debug bin/mouse.rom
6+ bin/uxn11-debug bin/mouse.rom
7+
8+controller: bin/uxn11-debug bin/controller.rom
9+ bin/uxn11-debug bin/controller.rom
10+
11 test: bin/uxncli-debug bin/uxn11-debug tests
12 bin/uxncli-debug bin/test_opcodes.rom
13 bin/uxncli-debug bin/test_system_exp.rom
14@@ -72,10 +78,14 @@ bin/test_opcodes.rom: etc/tests/opctest.tal
15 bin/test_system_exp.rom: etc/tests/system_exp.tal
16 @ bin/uxncli bin/drifblim.rom etc/tests/system_exp.tal bin/test_system_exp.rom
17
18-# Misc
19+# Devices
20
21 bin/mouse.rom: bin/uxncli bin/drifblim.rom etc/examples/mouse.tal
22 @ bin/uxncli bin/drifblim.rom etc/examples/mouse.tal bin/mouse.rom
23+
24+bin/controller.rom: bin/uxncli bin/drifblim.rom etc/examples/controller.tal
25+ @ bin/uxncli bin/drifblim.rom etc/examples/controller.tal bin/controller.rom
26+
27 bin/console.rom: bin/uxncli bin/drifblim.rom etc/examples/console.tal
28 @ bin/uxncli bin/drifblim.rom etc/examples/console.tal bin/console.rom
29 bin/screen.rom: bin/uxncli bin/drifblim.rom etc/examples/screen.tal
+3,
-3
1@@ -191,21 +191,21 @@ system_expansion(const Uint16 exp)
2 unsigned int dst_value = ram[exp + 7];
3 unsigned short a = addr;
4 if(bank < BANKS_CAP)
5- for(limit = a + length; a < limit; a++)
6+ for(limit = a + length; a != limit; a++)
7 ram[bank + a] = dst_value;
8 } else if(ram[exp] == 0x1) {
9 unsigned int dst_bank = PEEK2(aptr + 7) * 0x10000;
10 unsigned int dst_addr = PEEK2(aptr + 9);
11 unsigned short a = addr, c = dst_addr;
12 if(bank < BANKS_CAP && dst_bank < BANKS_CAP)
13- for(limit = a + length; a < limit; c++, a++)
14+ for(limit = a + length; a != limit; c++, a++)
15 ram[dst_bank + c] = ram[bank + a];
16 } else if(ram[exp] == 0x2) {
17 unsigned int dst_bank = PEEK2(aptr + 7) * 0x10000;
18 unsigned int dst_addr = PEEK2(aptr + 9);
19 unsigned short a = addr + length - 1, c = dst_addr + length - 1;
20 if(bank < BANKS_CAP && dst_bank < BANKS_CAP)
21- for(limit = addr - 1; a > limit; a--, c--)
22+ for(limit = addr - 1; a != limit; a--, c--)
23 ram[dst_bank + c] = ram[bank + a];
24 } else
25 fprintf(stderr, "Unknown command: %s\n", &ram[exp]);
+3,
-3
1@@ -168,21 +168,21 @@ system_expansion(const Uint16 exp)
2 unsigned int dst_value = ram[exp + 7];
3 unsigned short a = addr;
4 if(bank < BANKS_CAP)
5- for(limit = a + length; a < limit; a++)
6+ for(limit = a + length; a != limit; a++)
7 ram[bank + a] = dst_value;
8 } else if(ram[exp] == 0x1) {
9 unsigned int dst_bank = PEEK2(aptr + 7) * 0x10000;
10 unsigned int dst_addr = PEEK2(aptr + 9);
11 unsigned short a = addr, c = dst_addr;
12 if(bank < BANKS_CAP && dst_bank < BANKS_CAP)
13- for(limit = a + length; a < limit; c++, a++)
14+ for(limit = a + length; a != limit; c++, a++)
15 ram[dst_bank + c] = ram[bank + a];
16 } else if(ram[exp] == 0x2) {
17 unsigned int dst_bank = PEEK2(aptr + 7) * 0x10000;
18 unsigned int dst_addr = PEEK2(aptr + 9);
19 unsigned short a = addr + length - 1, c = dst_addr + length - 1;
20 if(bank < BANKS_CAP && dst_bank < BANKS_CAP)
21- for(limit = addr - 1; a > limit; a--, c--)
22+ for(limit = addr - 1; a != limit; a--, c--)
23 ram[dst_bank + c] = ram[bank + a];
24 } else
25 fprintf(stderr, "Unknown command: %s\n", &ram[exp]);