Browse code

Added stack pointer position readouts to system device

Andrew Alderwick authored on 27/04/2021 20:10:58
Showing 3 changed files
... ...
@@ -193,9 +193,13 @@ doctrl(Uxn *u, SDL_Event *event, int z)
193 193
 void
194 194
 system_talk(Device *d, Uint8 b0, Uint8 w)
195 195
 {
196
-	if(!w) return;
197
-	putcolors(&ppu, &d->dat[0x8]);
198
-	reqdraw = 1;
196
+	if(!w) {
197
+		d->dat[0x2] = d->u->wst.ptr;
198
+		d->dat[0x3] = d->u->rst.ptr;
199
+	} else {
200
+		putcolors(&ppu, &d->dat[0x8]);
201
+		reqdraw = 1;
202
+	}
199 203
 	(void)b0;
200 204
 }
201 205
 
... ...
@@ -183,6 +183,7 @@ portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *d, Uint8 b0, Uint8
183 183
 {
184 184
 	Device *d = &u->dev[id];
185 185
 	d->addr = id * 0x10;
186
+	d->u = u;
186 187
 	d->mem = u->ram.dat;
187 188
 	d->talk = talkfn;
188 189
 	printf("Device added #%02x: %s, at 0x%04x \n", id, name, d->addr);
... ...
@@ -31,6 +31,7 @@ typedef struct {
31 31
 struct Uxn;
32 32
 
33 33
 typedef struct Device {
34
+	struct Uxn *u;
34 35
 	Uint8 addr, dat[16], *mem;
35 36
 	void (*talk)(struct Device *d, Uint8, Uint8);
36 37
 } Device;