Browse code

Removed ram helper in uxn

neauoire authored on 11/01/2022 22:51:25
Showing 4 changed files
... ...
@@ -151,7 +151,7 @@ screen_deo(Device *d, Uint8 port)
151 151
 		DEVPEEK16(x, 0x8);
152 152
 		DEVPEEK16(y, 0xa);
153 153
 		DEVPEEK16(addr, 0xc);
154
-		screen_blit(&uxn_screen, layer, x, y, &d->mem[addr], d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp);
154
+		screen_blit(&uxn_screen, layer, x, y, &d->u->ram[addr], d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp);
155 155
 		if(d->dat[0x6] & 0x04) DEVPOKE16(0xc, addr + 8 + twobpp * 8); /* auto addr+length */
156 156
 		if(d->dat[0x6] & 0x01) DEVPOKE16(0x8, x + 8);                 /* auto x+8 */
157 157
 		if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 8);                 /* auto y+8 */
... ...
@@ -108,14 +108,14 @@ err:
108 108
 /* clang-format on */
109 109
 
110 110
 int
111
-uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devpage, Stack *wst, Stack *rst)
111
+uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devices, Stack *wst, Stack *rst)
112 112
 {
113 113
 	Uint32 i;
114 114
 	char *cptr = (char *)u;
115 115
 	for(i = 0; i < sizeof(*u); i++)
116 116
 		cptr[i] = 0x00;
117 117
 	u->ram = ram;
118
-	u->devpage = devpage;
118
+	u->devices = devices;
119 119
 	u->wst = wst;
120 120
 	u->rst = rst;
121 121
 	return 1;
... ...
@@ -126,9 +126,8 @@ uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *d, Uint8 port), void (*deofn)(
126 126
 {
127 127
 	Device *d = &u->dev[id];
128 128
 	d->u = u;
129
-	d->mem = u->ram;
129
+	d->dat = u->devices + id * 0x10;
130 130
 	d->dei = deifn;
131 131
 	d->deo = deofn;
132
-	d->dat = u->devpage + id * 0x10;
133 132
 	return d;
134 133
 }
... ...
@@ -43,12 +43,12 @@ typedef struct Device {
43 43
 } Device;
44 44
 
45 45
 typedef struct Uxn {
46
-	Uint8 *ram, *devpage;
46
+	Uint8 *ram, *devices;
47 47
 	Stack *wst, *rst;
48 48
 	Device dev[16];
49 49
 } Uxn;
50 50
 
51
-int uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devpage, Stack *wst, Stack *rst);
51
+int uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devices, Stack *wst, Stack *rst);
52 52
 int uxn_eval(Uxn *u, Uint16 pc);
53 53
 int uxn_halt(Uxn *u, Uint8 error, Uint16 addr);
54 54
 Device *uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *, Uint8), void (*deofn)(Device *, Uint8));
... ...
@@ -210,7 +210,7 @@ audio_deo(Device *d, Uint8 port)
210 210
 		DEVPEEK16(adsr, 0x8);
211 211
 		DEVPEEK16(c->len, 0xa);
212 212
 		DEVPEEK16(addr, 0xc);
213
-		c->addr = &d->mem[addr];
213
+		c->addr = &d->u->ram[addr];
214 214
 		c->volume[0] = d->dat[0xe] >> 4;
215 215
 		c->volume[1] = d->dat[0xe] & 0xf;
216 216
 		c->repeat = !(d->dat[0xf] & 0x80);