Browse code

(boot.rom) Renamed to launcher.rom

neauoire authored on 11/01/2022 04:35:34
Showing 8 changed files
... ...
@@ -30,7 +30,7 @@ Build the assembler and emulator by running the `build.sh` script. The assembler
30 30
 If you wish to build the emulator without graphics mode:
31 31
 
32 32
 ```sh
33
-cc src/devices/file.c src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli
33
+cc src/devices/datetime.c src/devices/system.c src/devices/file.c src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli
34 34
 ```
35 35
 
36 36
 ### Plan 9 
... ...
@@ -94,7 +94,7 @@ uxnemu orca.rom | shim
94 94
 - `F1` toggle zoom
95 95
 - `F2` toggle debug
96 96
 - `F3` capture screen
97
-- `F4` load boot.rom
97
+- `F4` load launcher.rom
98 98
 
99 99
 ### Buttons
100 100
 
... ...
@@ -37,7 +37,7 @@ rm -f ./bin/uxnasm
37 37
 rm -f ./bin/uxnemu
38 38
 rm -f ./bin/uxncli
39 39
 rm -f ./bin/supervisor.rom
40
-rm -f ./bin/boot.rom
40
+rm -f ./bin/launcher.rom
41 41
 rm -f ./bin/asma.rom
42 42
 
43 43
 # When clang-format is present
... ...
@@ -110,8 +110,8 @@ fi
110 110
 
111 111
 echo "Assembling(supervisor).."
112 112
 ./bin/uxnasm projects/software/supervisor.tal bin/supervisor.rom
113
-echo "Assembling(boot).."
114
-./bin/uxnasm projects/software/boot.tal bin/boot.rom
113
+echo "Assembling(launcher).."
114
+./bin/uxnasm projects/software/launcher.tal bin/launcher.rom
115 115
 echo "Assembling(asma).."
116 116
 ./bin/uxnasm projects/software/asma.tal bin/asma.rom
117 117
 
... ...
@@ -6,7 +6,7 @@
6 6
 %<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
7 7
 %!~ { NEQk NIP }
8 8
 
9
-%HALT { #01 #0f DEO }
9
+%HALT { #010f DEO }
10 10
 
11 11
 %RTN  { JMP2r }
12 12
 %TOS  { #00 SWP }
13 13
similarity index 100%
14 14
rename from projects/software/boot.tal
15 15
rename to projects/software/launcher.tal
... ...
@@ -22,8 +22,11 @@
22 22
 %2//  { #01 SFT2 }
23 23
 %8**  { #30 SFT2 }
24 24
 
25
-%EADDR { #fd04 }
26
-%ECODE { #fd06 }
25
+%SYS_EADDR { #fd04 }
26
+%SYS_ECODE { #fd06 }
27
+%SYS_DEBUG { #fd0e }
28
+%WST { #fe00 }
29
+%RST { #ff00 }
27 30
 
28 31
 ( devices )
29 32
 
... ...
@@ -56,6 +59,11 @@
56 59
 	;on-frame .Screen/vector DEO2
57 60
 	;on-button .Controller/vector DEO2
58 61
 
62
+	( print initial memory )
63
+	SYS_DEBUG LDA #00 = ,&no-debug JCN
64
+		;print-stacks JSR2
65
+		&no-debug
66
+
59 67
 BRK
60 68
 
61 69
 @on-frame ( -> )
... ...
@@ -116,9 +124,9 @@ BRK
116 124
 
117 125
 	;at-txt #4f ;draw-str JSR2
118 126
 
119
-	EADDR LDA2 #47 ;draw-short JSR2
127
+	SYS_EADDR LDA2 #47 ;draw-short JSR2
120 128
 
121
-	#0000 EADDR STA2
129
+	#0000 SYS_EADDR STA2
122 130
 
123 131
 BRK
124 132
 
... ...
@@ -136,9 +144,8 @@ RTN
136 144
 
137 145
 	( load rom )
138 146
 
139
-
140 147
 RTN
141
-	&boot-path "boot.rom $1
148
+	&boot-path "launcher.rom $1
142 149
 
143 150
 @draw-stacks ( -- )
144 151
 
... ...
@@ -148,12 +155,12 @@ RTN
148 155
 		( working stack )
149 156
 		#0010 .Screen/y DEO2
150 157
 		DUP2 #0018 ** #0010 ++ .Screen/x DEO2
151
-		DUP #fe00 LDA ( ptr ) EQU #4b + STH
158
+		DUP #fe00 LDA ( ptr ) EQU #41 + STH
152 159
 		DUP2 #fe01 ++ LDA STHr ;draw-byte JSR2
153 160
 		( return stack )
154 161
 		#0028 .Screen/y DEO2
155 162
 		DUP2 #0018 ** #0010 ++ .Screen/x DEO2
156
-		DUP #ff00 LDA ( ptr ) EQU #4b + STH
163
+		DUP #ff00 LDA ( ptr ) EQU #41 + STH
157 164
 		DUP2 #ff01 ++ LDA STHr ;draw-byte JSR2
158 165
 		INC2 GTH2k ,&wst JCN
159 166
 	POP2 POP2
... ...
@@ -235,6 +242,39 @@ JMP2r
235 242
 
236 243
 JMP2r
237 244
 
245
+@print-stacks ( -- )
246
+
247
+	#0a EMIT
248
+	WST ;&wst-txt ,print-stack JSR
249
+	RST ;&rst-txt ,print-stack JSR
250
+
251
+RTN
252
+	&wst-txt "Working-stack $1
253
+	&rst-txt "Return-stack $1
254
+
255
+@print-stack ( addr* name* -- )
256
+
257
+	PRINT
258
+	( keep ptr ) LDAk STH
259
+	( keep counter ) LITr 00
260
+	( skip ptr ) INC2 
261
+	DUP2 #0020 ++ SWP2
262
+	&loop
263
+		( print cell )
264
+		EQUkr STHr #3b * #20 + EMIT
265
+		LDAk ;print-hex/byte JSR2
266
+		EQUkr STHr #3d * #20 + EMIT
267
+		( break into columns )
268
+		SUB2k #0001 -- #0007 AND2 #0000 !! ,&no-lb JCN
269
+			#0a EMIT 
270
+			&no-lb
271
+		INCr
272
+		INC2 GTH2k ,&loop JCN
273
+	POP2 POP2
274
+	POP2r
275
+
276
+RTN
277
+
238 278
 @print-hex ( value* -- )
239 279
 
240 280
 	SWP ,&byte JSR 
... ...
@@ -83,7 +83,6 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height)
83 83
 	if(bg && fg && pixels) {
84 84
 		p->width = width;
85 85
 		p->height = height;
86
-		p->pixels = pixels;
87 86
 		screen_clear(p, &p->bg);
88 87
 		screen_clear(p, &p->fg);
89 88
 	}
... ...
@@ -119,8 +118,6 @@ screen_dei(Device *d, Uint8 port)
119 118
 	case 0x3: return uxn_screen.width;
120 119
 	case 0x4: return uxn_screen.height >> 8;
121 120
 	case 0x5: return uxn_screen.height;
122
-	case 0x6:
123
-
124 121
 	default: return d->dat[port];
125 122
 	}
126 123
 }
... ...
@@ -13,8 +13,7 @@ WITH REGARD TO THIS SOFTWARE.
13 13
 #define FIXED_SIZE 0
14 14
 
15 15
 typedef struct Layer {
16
-	Uint8 *pixels;
17
-	Uint8 changed;
16
+	Uint8 *pixels, changed;
18 17
 } Layer;
19 18
 
20 19
 typedef struct UxnScreen {
... ...
@@ -255,15 +255,10 @@ start(Uxn *u, char *rom)
255 255
 	memory = (Uint8 *)calloc(0x10000, sizeof(Uint8));
256 256
 	supervisor_memory = (Uint8 *)calloc(0x10000, sizeof(Uint8));
257 257
 
258
-	if(!uxn_boot(&supervisor, supervisor_memory, supervisor_memory + VISOR_DEV, (Stack *)(supervisor_memory + VISOR_WST), (Stack *)(supervisor_memory + VISOR_RST)))
259
-		return error("Boot", "Failed to start uxn.");
260 258
 	if(!uxn_boot(u, memory, supervisor_memory + PAGE_DEV, (Stack *)(supervisor_memory + PAGE_WST), (Stack *)(supervisor_memory + PAGE_RST)))
261 259
 		return error("Boot", "Failed to start uxn.");
262
-	if(!load(&supervisor, "supervisor.rom"))
263
-		error("Supervisor", "No debugger found.");
264 260
 	if(!load(u, rom))
265 261
 		return error("Boot", "Failed to load rom.");
266
-
267 262
 	/* system   */ devsystem = uxn_port(u, 0x0, system_dei, system_deo);
268 263
 	/* console  */ devconsole = uxn_port(u, 0x1, nil_dei, console_deo);
269 264
 	/* screen   */ devscreen = uxn_port(u, 0x2, screen_dei, screen_deo);
... ...
@@ -282,16 +277,20 @@ start(Uxn *u, char *rom)
282 277
 	/* unused   */ uxn_port(u, 0xf, nil_dei, nil_deo);
283 278
 
284 279
 	/* Supervisor */
285
-	uxn_port(&supervisor, 0x0, system_dei, system_deo);
286
-	uxn_port(&supervisor, 0x1, nil_dei, console_deo);
287
-	uxn_port(&supervisor, 0x2, screen_dei, screen_deo);
288
-	uxn_port(&supervisor, 0x8, nil_dei, nil_deo);
289
-
290
-	uxn_eval(&supervisor, PAGE_PROGRAM);
280
+	if(!uxn_boot(&supervisor, supervisor_memory, supervisor_memory + VISOR_DEV, (Stack *)(supervisor_memory + VISOR_WST), (Stack *)(supervisor_memory + VISOR_RST)))
281
+		return error("Boot", "Failed to start uxn.");
282
+	if(!load(&supervisor, "supervisor.rom"))
283
+		error("Supervisor", "No debugger found.");
284
+	/* system   */ uxn_port(&supervisor, 0x0, system_dei, system_deo);
285
+	/* console  */ uxn_port(&supervisor, 0x1, nil_dei, console_deo);
286
+	/* screen   */ uxn_port(&supervisor, 0x2, screen_dei, screen_deo);
287
+	/* control  */ uxn_port(&supervisor, 0x8, nil_dei, nil_deo);
291 288
 
292 289
 	if(!uxn_eval(u, PAGE_PROGRAM))
293 290
 		return error("Boot", "Failed to start rom.");
294 291
 
292
+	uxn_eval(&supervisor, PAGE_PROGRAM);
293
+
295 294
 	return 1;
296 295
 }
297 296
 
... ...
@@ -330,7 +329,7 @@ static void
330 329
 restart(Uxn *u)
331 330
 {
332 331
 	set_size(WIDTH, HEIGHT, 1);
333
-	start(u, "boot.rom");
332
+	start(u, "launcher.rom");
334 333
 }
335 334
 
336 335
 static Uint8
... ...
@@ -527,7 +526,7 @@ main(int argc, char **argv)
527 526
 			console_input(&u, '\n');
528 527
 		}
529 528
 	}
530
-	if(!loaded && !start(&u, "boot.rom"))
529
+	if(!loaded && !start(&u, "launcher.rom"))
531 530
 		return error("usage", "uxnemu [-s scale] file.rom");
532 531
 	run(&u);
533 532
 	SDL_Quit();