... | ... |
@@ -38,12 +38,12 @@ printstack(Stack *s) |
38 | 38 |
#pragma mark - Devices |
39 | 39 |
|
40 | 40 |
Uint8 |
41 |
-console_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
|
41 |
+console_poke(Device *d, Uint8 b0, Uint8 b1) |
|
42 | 42 |
{ |
43 | 43 |
switch(b0) { |
44 | 44 |
case 0x08: printf("%c", b1); break; |
45 | 45 |
case 0x09: printf("0x%02x\n", b1); break; |
46 |
- case 0x0b: printf("0x%04x\n", (m[0x0a] << 8) + b1); break; |
|
46 |
+ case 0x0b: printf("0x%04x\n", (d->dat[0x0a] << 8) + b1); break; |
|
47 | 47 |
} |
48 | 48 |
fflush(stdout); |
49 | 49 |
(void)d; |
... | ... |
@@ -52,8 +52,9 @@ console_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
Uint8 |
55 |
-file_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
|
55 |
+file_poke(Device *d, Uint8 b0, Uint8 b1) |
|
56 | 56 |
{ |
57 |
+ /* |
|
57 | 58 |
Uint8 read = b0 == 0xd; |
58 | 59 |
if(read || b0 == 0xf) { |
59 | 60 |
char *name = (char *)&d->mem[mempeek16(m, 0x8)]; |
... | ... |
@@ -68,14 +69,14 @@ file_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
68 | 69 |
} |
69 | 70 |
mempoke16(m, 0x2, result); |
70 | 71 |
} |
72 |
+ */ |
|
71 | 73 |
return b1; |
72 | 74 |
} |
73 | 75 |
|
74 | 76 |
Uint8 |
75 |
-ppnil(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
|
77 |
+ppnil(Device *d, Uint8 b0, Uint8 b1) |
|
76 | 78 |
{ |
77 | 79 |
(void)d; |
78 |
- (void)m; |
|
79 | 80 |
(void)b0; |
80 | 81 |
return b1; |
81 | 82 |
} |
... | ... |
@@ -182,9 +182,9 @@ doctrl(Uxn *u, SDL_Event *event, int z) |
182 | 182 |
#pragma mark - Devices |
183 | 183 |
|
184 | 184 |
Uint8 |
185 |
-system_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
|
185 |
+system_poke(Device *d, Uint8 b0, Uint8 b1) |
|
186 | 186 |
{ |
187 |
- putcolors(&ppu, &m[0x8]); |
|
187 |
+ putcolors(&ppu, &d->dat[0x8]); |
|
188 | 188 |
reqdraw = 1; |
189 | 189 |
(void)d; |
190 | 190 |
(void)b0; |
... | ... |
@@ -192,25 +192,25 @@ system_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
192 | 192 |
} |
193 | 193 |
|
194 | 194 |
Uint8 |
195 |
-console_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
|
195 |
+console_poke(Device *d, Uint8 b0, Uint8 b1) |
|
196 | 196 |
{ |
197 | 197 |
switch(b0) { |
198 | 198 |
case 0x8: printf("%c", b1); break; |
199 | 199 |
case 0x9: printf("0x%02x\n", b1); break; |
200 |
- case 0xb: printf("0x%04x\n", (m[0xa] << 8) + b1); break; |
|
201 |
- case 0xd: printf("%s\n", &d->mem[(m[0xc] << 8) + b1]); break; |
|
200 |
+ case 0xb: printf("0x%04x\n", (d->dat[0xa] << 8) + b1); break; |
|
201 |
+ case 0xd: printf("%s\n", &d->mem[(d->dat[0xc] << 8) + b1]); break; |
|
202 | 202 |
} |
203 | 203 |
fflush(stdout); |
204 | 204 |
return b1; |
205 | 205 |
} |
206 | 206 |
|
207 | 207 |
Uint8 |
208 |
-screen_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
|
208 |
+screen_poke(Device *d, Uint8 b0, Uint8 b1) |
|
209 | 209 |
{ |
210 | 210 |
if(b0 == 0xe) { |
211 |
- Uint16 x = mempeek16(m, 0x8); |
|
212 |
- Uint16 y = mempeek16(m, 0xa); |
|
213 |
- Uint8 *addr = &d->mem[mempeek16(m, 0xc)]; |
|
211 |
+ Uint16 x = mempeek16(d->dat, 0x8); |
|
212 |
+ Uint16 y = mempeek16(d->dat, 0xa); |
|
213 |
+ Uint8 *addr = &d->mem[mempeek16(d->dat, 0xc)]; |
|
214 | 214 |
Uint8 *layer = b1 >> 4 & 0x1 ? ppu.fg : ppu.bg; |
215 | 215 |
switch(b1 >> 5) { |
216 | 216 |
case 0: putpixel(&ppu, layer, x, y, b1 & 0x3); break; |
... | ... |
@@ -223,7 +223,7 @@ screen_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
223 | 223 |
} |
224 | 224 |
|
225 | 225 |
Uint8 |
226 |
-file_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
|
226 |
+file_poke(Device *d, Uint8 b0, Uint8 b1) |
|
227 | 227 |
{ |
228 | 228 |
/* TODO: Figure out why fwrite doesn't work with d->mem |
229 | 229 |
Uint8 read = b0 == 0xd; |
... | ... |
@@ -242,28 +242,27 @@ file_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
242 | 242 |
} |
243 | 243 |
*/ |
244 | 244 |
(void)d; |
245 |
- (void)m; |
|
246 | 245 |
(void)b0; |
247 | 246 |
return b1; |
248 | 247 |
} |
249 | 248 |
|
250 | 249 |
static Uint8 |
251 |
-audio_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
|
250 |
+audio_poke(Device *d, Uint8 b0, Uint8 b1) |
|
252 | 251 |
{ |
253 | 252 |
if(b0 == 0xa) { |
254 | 253 |
if(b1 >= apu.n_notes) apu.notes = SDL_realloc(apu.notes, (b1 + 1) * sizeof(Note)); |
255 | 254 |
while(b1 >= apu.n_notes) SDL_zero(apu.notes[apu.n_notes++]); |
256 |
- apu_play_note(&apu.notes[b1], mempeek16(m, 0x0), mempeek16(m, 0x2), m[0x8], m[0x9] & 0x7f, m[0x9] > 0x7f); |
|
255 |
+ apu_play_note(&apu.notes[b1], mempeek16(d->dat, 0x0), mempeek16(d->dat, 0x2), d->dat[0x8], d->dat[0x9] & 0x7f, d->dat[0x9] > 0x7f); |
|
257 | 256 |
} else if(b0 == 0xe && apu.queue != NULL) { |
258 | 257 |
if(apu.queue->n == apu.queue->sz) { |
259 | 258 |
apu.queue->sz = apu.queue->sz < 4 ? 4 : apu.queue->sz * 2; |
260 | 259 |
apu.queue->dat = SDL_realloc(apu.queue->dat, apu.queue->sz * sizeof(*apu.queue->dat)); |
261 | 260 |
} |
262 | 261 |
if(apu.queue->is_envelope) |
263 |
- apu.queue->dat[apu.queue->n++] = mempeek16(m, 0xb) >> 1; |
|
262 |
+ apu.queue->dat[apu.queue->n++] = mempeek16(d->dat, 0xb) >> 1; |
|
264 | 263 |
else |
265 |
- apu.queue->dat[apu.queue->n++] = mempeek16(m, 0xb) + 0x8000; |
|
266 |
- apu.queue->dat[apu.queue->n++] = (m[0xd] << 8) + b1; |
|
264 |
+ apu.queue->dat[apu.queue->n++] = mempeek16(d->dat, 0xb) + 0x8000; |
|
265 |
+ apu.queue->dat[apu.queue->n++] = (d->dat[0xd] << 8) + b1; |
|
267 | 266 |
} else if(b0 == 0xf && apu.queue != NULL) |
268 | 267 |
apu.queue->finishes = 1; |
269 | 268 |
(void)d; |
... | ... |
@@ -271,30 +270,29 @@ audio_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
271 | 270 |
} |
272 | 271 |
|
273 | 272 |
Uint8 |
274 |
-datetime_poke(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
|
273 |
+datetime_poke(Device *d, Uint8 b0, Uint8 b1) |
|
275 | 274 |
{ |
276 | 275 |
time_t seconds = time(NULL); |
277 | 276 |
struct tm *t = localtime(&seconds); |
278 | 277 |
t->tm_year += 1900; |
279 |
- mempoke16(m, 0x0, t->tm_year); |
|
280 |
- m[0x2] = t->tm_mon; |
|
281 |
- m[0x3] = t->tm_mday; |
|
282 |
- m[0x4] = t->tm_hour; |
|
283 |
- m[0x5] = t->tm_min; |
|
284 |
- m[0x6] = t->tm_sec; |
|
285 |
- m[0x7] = t->tm_wday; |
|
286 |
- mempoke16(m, 0x08, t->tm_yday); |
|
287 |
- m[0xa] = t->tm_isdst; |
|
278 |
+ mempoke16(d->dat, 0x0, t->tm_year); |
|
279 |
+ d->dat[0x2] = t->tm_mon; |
|
280 |
+ d->dat[0x3] = t->tm_mday; |
|
281 |
+ d->dat[0x4] = t->tm_hour; |
|
282 |
+ d->dat[0x5] = t->tm_min; |
|
283 |
+ d->dat[0x6] = t->tm_sec; |
|
284 |
+ d->dat[0x7] = t->tm_wday; |
|
285 |
+ mempoke16(d->dat, 0x08, t->tm_yday); |
|
286 |
+ d->dat[0xa] = t->tm_isdst; |
|
288 | 287 |
(void)d; |
289 | 288 |
(void)b0; |
290 | 289 |
return b1; |
291 | 290 |
} |
292 | 291 |
|
293 | 292 |
Uint8 |
294 |
-ppnil(Device *d, Uint8 *m, Uint8 b0, Uint8 b1) |
|
293 |
+ppnil(Device *d, Uint8 b0, Uint8 b1) |
|
295 | 294 |
{ |
296 | 295 |
(void)d; |
297 |
- (void)m; |
|
298 | 296 |
(void)b0; |
299 | 297 |
return b1; |
300 | 298 |
} |
... | ... |
@@ -21,7 +21,7 @@ Uint8 pop8(Stack *s) { if (s->ptr == 0) { s->error = 1; return 0; } return s->d |
21 | 21 |
Uint8 peek8(Stack *s, Uint8 a) { if (s->ptr < a + 1) s->error = 1; return s->dat[s->ptr - a - 1]; } |
22 | 22 |
void mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; } |
23 | 23 |
Uint8 mempeek8(Uint8 *m, Uint16 a) { return m[a]; } |
24 |
-void devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->poke(d, d->dat, a & 0x0f, b); } |
|
24 |
+void devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->poke(d, a & 0x0f, b); } |
|
25 | 25 |
Uint8 devpeek8(Device *d, Uint8 a) { return d->dat[a & 0xf]; } |
26 | 26 |
void push16(Stack *s, Uint16 a) { push8(s, a >> 8); push8(s, a); } |
27 | 27 |
Uint16 pop16(Stack *s) { return pop8(s) + (pop8(s) << 8); } |
... | ... |
@@ -179,7 +179,7 @@ loaduxn(Uxn *u, char *filepath) |
179 | 179 |
} |
180 | 180 |
|
181 | 181 |
Device * |
182 |
-portuxn(Uxn *u, Uint8 id, char *name, Uint8 (*pofn)(Device *d, Uint8 *devmem, Uint8 b0, Uint8 b1)) |
|
182 |
+portuxn(Uxn *u, Uint8 id, char *name, Uint8 (*pofn)(Device *d, Uint8 b0, Uint8 b1)) |
|
183 | 183 |
{ |
184 | 184 |
Device *d = &u->dev[id]; |
185 | 185 |
d->addr = id * 0x10; |
... | ... |
@@ -32,7 +32,7 @@ struct Uxn; |
32 | 32 |
|
33 | 33 |
typedef struct Device { |
34 | 34 |
Uint8 addr, dat[16], *mem; |
35 |
- Uint8 (*poke)(struct Device *d, Uint8 *devmem, Uint8, Uint8); |
|
35 |
+ Uint8 (*poke)(struct Device *d, Uint8, Uint8); |
|
36 | 36 |
} Device; |
37 | 37 |
|
38 | 38 |
typedef struct Uxn { |
... | ... |
@@ -47,4 +47,4 @@ int evaluxn(Uxn *u, Uint16 vec); |
47 | 47 |
void mempoke16(Uint8 *m, Uint16 a, Uint16 b); |
48 | 48 |
Uint16 mempeek16(Uint8 *m, Uint16 a); |
49 | 49 |
|
50 |
-Device *portuxn(Uxn *u, Uint8 id, char *name, Uint8 (*pofn)(Device *, Uint8 *, Uint8, Uint8)); |
|
51 | 50 |
\ No newline at end of file |
51 |
+Device *portuxn(Uxn *u, Uint8 id, char *name, Uint8 (*pofn)(Device *, Uint8, Uint8)); |
|
52 | 52 |
\ No newline at end of file |