Browse code

About to move the device page

neauoire authored on 21/03/2021 20:52:38
Showing 4 changed files
... ...
@@ -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/noodle.usm bin/boot.rom
24 24
 ./bin/emulator bin/boot.rom
... ...
@@ -409,7 +409,7 @@ file_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1)
409 409
 Uint8
410 410
 system_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1)
411 411
 {
412
-	loadtheme(&m[0xfff8]);
412
+	loadtheme(&m[PAGE_DEVICE + 0x00f8]);
413 413
 	(void)ptr;
414 414
 	(void)b0;
415 415
 	return b1;
... ...
@@ -431,7 +431,7 @@ start(Uxn *u)
431 431
 {
432 432
 	int ticknext = 0;
433 433
 	evaluxn(u, u->vreset);
434
-	loadtheme(u->ram.dat + 0xfff8);
434
+	loadtheme(u->ram.dat + PAGE_DEVICE + 0x00f8);
435 435
 	if(screen.reqdraw)
436 436
 		redraw(pixels, u);
437 437
 	while(1) {
... ...
@@ -18,8 +18,8 @@ WITH REGARD TO THIS SOFTWARE.
18 18
 /* clang-format off */
19 19
 void   setflag(Uint8 *a, char flag, int b) { if(b) *a |= flag; else *a &= (~flag); }
20 20
 int    getflag(Uint8 *a, char flag) { return *a & flag; }
21
-Uint8  devpoke8(Uxn *u, Uint8 id, Uint8 b0, Uint8 b1){ return id < u->devices ? u->dev[id].poke(u->ram.dat, 0xff00 + id * 0x10, b0, b1) : b1; }
22
-void   mempoke8(Uxn *u, Uint16 a, Uint8 b) { u->ram.dat[a] = a >= 0xff00 ? devpoke8(u, (a & 0xff) >> 4, a & 0xf, b) : b; }
21
+Uint8  devpoke8(Uxn *u, Uint8 id, Uint8 b0, Uint8 b1){ return id < u->devices ? u->dev[id].poke(u->ram.dat, PAGE_DEVICE + id * 0x10, b0, b1) : b1; }
22
+void   mempoke8(Uxn *u, Uint16 a, Uint8 b) { u->ram.dat[a] = a >= PAGE_DEVICE ? devpoke8(u, (a & 0xff) >> 4, a & 0xf, b) : b; }
23 23
 Uint8  mempeek8(Uxn *u, Uint16 a) { return u->ram.dat[a]; }
24 24
 void   mempoke16(Uxn *u, Uint16 a, Uint16 b) { mempoke8(u, a, b >> 8); mempoke8(u, a + 1, b); }
25 25
 Uint16 mempeek16(Uxn *u, Uint16 a) { return (mempeek8(u, a) << 8) + mempeek8(u, a + 1); }
... ...
@@ -212,9 +212,9 @@ loaduxn(Uxn *u, char *filepath)
212 212
 	if(!(f = fopen(filepath, "rb")))
213 213
 		return haltuxn(u, "Missing input rom.", 0);
214 214
 	fread(u->ram.dat, sizeof(u->ram.dat), 1, f);
215
-	u->vreset = mempeek16(u, 0xfff0);
216
-	u->vframe = mempeek16(u, 0xfff2);
217
-	u->verror = mempeek16(u, 0xfff4);
215
+	u->vreset = mempeek16(u, PAGE_DEVICE + 0x00f0);
216
+	u->vframe = mempeek16(u, PAGE_DEVICE + 0x00f2);
217
+	u->verror = mempeek16(u, PAGE_DEVICE + 0x00f4);
218 218
 	printf("Uxn loaded[%s] vrst:%04x vfrm:%04x verr:%04x.\n",
219 219
 		filepath,
220 220
 		u->vreset,
... ...
@@ -227,7 +227,7 @@ Device *
227 227
 portuxn(Uxn *u, char *name, Uint8 (*pofn)(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1))
228 228
 {
229 229
 	Device *d = &u->dev[u->devices++];
230
-	d->addr = 0xff00 + (u->devices - 1) * 0x10;
230
+	d->addr = PAGE_DEVICE + (u->devices - 1) * 0x10;
231 231
 	d->poke = pofn;
232 232
 	printf("Device #%d: %s, at 0x%04x \n", u->devices - 1, name, d->addr);
233 233
 	return d;
... ...
@@ -20,6 +20,7 @@ typedef signed short Sint16;
20 20
 #define FLAG_SHORT 0x02
21 21
 #define FLAG_RETURN 0x04
22 22
 #define FLAG_COND 0x08
23
+#define PAGE_DEVICE 0xff00
23 24
 
24 25
 typedef struct {
25 26
 	Uint8 ptr;