| ... | ... |
@@ -4028,7 +4028,7 @@ uxn_boot(Uxn *u) |
| 4028 | 4028 |
} |
| 4029 | 4029 |
|
| 4030 | 4030 |
Device * |
| 4031 |
-uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *d, Uint8 b0), void (*deofn)(Device *d, Uint8 b0)) |
|
| 4031 |
+uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *d, Uint8 port), void (*deofn)(Device *d, Uint8 port)) |
|
| 4032 | 4032 |
{
|
| 4033 | 4033 |
Device *d = &u->dev[id]; |
| 4034 | 4034 |
d->addr = id * 0x10; |
| ... | ... |
@@ -146,7 +146,7 @@ uxn_boot(Uxn *u) |
| 146 | 146 |
} |
| 147 | 147 |
|
| 148 | 148 |
Device * |
| 149 |
-uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *d, Uint8 b0), void (*deofn)(Device *d, Uint8 b0)) |
|
| 149 |
+uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *d, Uint8 port), void (*deofn)(Device *d, Uint8 port)) |
|
| 150 | 150 |
{
|
| 151 | 151 |
Device *d = &u->dev[id]; |
| 152 | 152 |
d->addr = id * 0x10; |
| ... | ... |
@@ -44,21 +44,21 @@ inspect(Stack *s, char *name) |
| 44 | 44 |
#pragma mark - Devices |
| 45 | 45 |
|
| 46 | 46 |
static Uint8 |
| 47 |
-system_dei(Device *d, Uint8 b0) |
|
| 47 |
+system_dei(Device *d, Uint8 port) |
|
| 48 | 48 |
{
|
| 49 |
- switch(b0) {
|
|
| 49 |
+ switch(port) {
|
|
| 50 | 50 |
case 0x2: return d->u->wst.ptr; |
| 51 | 51 |
case 0x3: return d->u->rst.ptr; |
| 52 |
- default: return d->dat[b0]; |
|
| 52 |
+ default: return d->dat[port]; |
|
| 53 | 53 |
} |
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 | 56 |
static void |
| 57 |
-system_deo(Device *d, Uint8 b0) |
|
| 57 |
+system_deo(Device *d, Uint8 port) |
|
| 58 | 58 |
{
|
| 59 |
- switch(b0) {
|
|
| 60 |
- case 0x2: d->u->wst.ptr = d->dat[b0]; break; |
|
| 61 |
- case 0x3: d->u->rst.ptr = d->dat[b0]; break; |
|
| 59 |
+ switch(port) {
|
|
| 60 |
+ case 0x2: d->u->wst.ptr = d->dat[port]; break; |
|
| 61 |
+ case 0x3: d->u->rst.ptr = d->dat[port]; break; |
|
| 62 | 62 |
case 0xe: |
| 63 | 63 |
inspect(&d->u->wst, "Working-stack"); |
| 64 | 64 |
inspect(&d->u->rst, "Return-stack"); |
| ... | ... |
@@ -67,23 +67,23 @@ system_deo(Device *d, Uint8 b0) |
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 | 69 |
static void |
| 70 |
-console_deo(Device *d, Uint8 b0) |
|
| 70 |
+console_deo(Device *d, Uint8 port) |
|
| 71 | 71 |
{
|
| 72 |
- if(b0 == 0x1) |
|
| 72 |
+ if(port == 0x1) |
|
| 73 | 73 |
d->vector = peek16(d->dat, 0x0); |
| 74 |
- if(b0 > 0x7) |
|
| 75 |
- write(b0 - 0x7, (char *)&d->dat[b0], 1); |
|
| 74 |
+ if(port > 0x7) |
|
| 75 |
+ write(port - 0x7, (char *)&d->dat[port], 1); |
|
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 | 78 |
static void |
| 79 |
-file_deo(Device *d, Uint8 b0) |
|
| 79 |
+file_deo(Device *d, Uint8 port) |
|
| 80 | 80 |
{
|
| 81 |
- Uint8 read = b0 == 0xd; |
|
| 82 |
- if(read || b0 == 0xf) {
|
|
| 81 |
+ Uint8 read = port == 0xd; |
|
| 82 |
+ if(read || port == 0xf) {
|
|
| 83 | 83 |
char *name = (char *)&d->mem[peek16(d->dat, 0x8)]; |
| 84 | 84 |
Uint16 result = 0, length = peek16(d->dat, 0xa); |
| 85 | 85 |
long offset = (peek16(d->dat, 0x4) << 16) + peek16(d->dat, 0x6); |
| 86 |
- Uint16 addr = peek16(d->dat, b0 - 1); |
|
| 86 |
+ Uint16 addr = peek16(d->dat, port - 1); |
|
| 87 | 87 |
FILE *f = fopen(name, read ? "rb" : (offset ? "ab" : "wb")); |
| 88 | 88 |
if(f) {
|
| 89 | 89 |
if(fseek(f, offset, SEEK_SET) != -1) |
| ... | ... |
@@ -95,11 +95,11 @@ file_deo(Device *d, Uint8 b0) |
| 95 | 95 |
} |
| 96 | 96 |
|
| 97 | 97 |
static Uint8 |
| 98 |
-datetime_dei(Device *d, Uint8 b0) |
|
| 98 |
+datetime_dei(Device *d, Uint8 port) |
|
| 99 | 99 |
{
|
| 100 | 100 |
time_t seconds = time(NULL); |
| 101 | 101 |
struct tm *t = localtime(&seconds); |
| 102 |
- switch(b0) {
|
|
| 102 |
+ switch(port) {
|
|
| 103 | 103 |
case 0x0: return (t->tm_year + 1900) >> 8; |
| 104 | 104 |
case 0x1: return (t->tm_year + 1900); |
| 105 | 105 |
case 0x2: return t->tm_mon; |
| ... | ... |
@@ -111,20 +111,20 @@ datetime_dei(Device *d, Uint8 b0) |
| 111 | 111 |
case 0x8: return t->tm_yday >> 8; |
| 112 | 112 |
case 0x9: return t->tm_yday; |
| 113 | 113 |
case 0xa: return t->tm_isdst; |
| 114 |
- default: return d->dat[b0]; |
|
| 114 |
+ default: return d->dat[port]; |
|
| 115 | 115 |
} |
| 116 | 116 |
} |
| 117 | 117 |
|
| 118 | 118 |
static Uint8 |
| 119 |
-nil_dei(Device *d, Uint8 b0) |
|
| 119 |
+nil_dei(Device *d, Uint8 port) |
|
| 120 | 120 |
{
|
| 121 |
- return d->dat[b0]; |
|
| 121 |
+ return d->dat[port]; |
|
| 122 | 122 |
} |
| 123 | 123 |
|
| 124 | 124 |
static void |
| 125 |
-nil_deo(Device *d, Uint8 b0) |
|
| 125 |
+nil_deo(Device *d, Uint8 port) |
|
| 126 | 126 |
{
|
| 127 |
- if(b0 == 0x1) d->vector = peek16(d->dat, 0x0); |
|
| 127 |
+ if(port == 0x1) d->vector = peek16(d->dat, 0x0); |
|
| 128 | 128 |
} |
| 129 | 129 |
|
| 130 | 130 |
#pragma mark - Generics |
| ... | ... |
@@ -290,51 +290,51 @@ doctrl(SDL_Event *event, int z) |
| 290 | 290 |
#pragma mark - Devices |
| 291 | 291 |
|
| 292 | 292 |
static Uint8 |
| 293 |
-system_dei(Device *d, Uint8 b0) |
|
| 293 |
+system_dei(Device *d, Uint8 port) |
|
| 294 | 294 |
{
|
| 295 |
- switch(b0) {
|
|
| 295 |
+ switch(port) {
|
|
| 296 | 296 |
case 0x2: return d->u->wst.ptr; |
| 297 | 297 |
case 0x3: return d->u->rst.ptr; |
| 298 |
- default: return d->dat[b0]; |
|
| 298 |
+ default: return d->dat[port]; |
|
| 299 | 299 |
} |
| 300 | 300 |
} |
| 301 | 301 |
|
| 302 | 302 |
static void |
| 303 |
-system_deo(Device *d, Uint8 b0) |
|
| 303 |
+system_deo(Device *d, Uint8 port) |
|
| 304 | 304 |
{
|
| 305 |
- switch(b0) {
|
|
| 306 |
- case 0x2: d->u->wst.ptr = d->dat[b0]; break; |
|
| 307 |
- case 0x3: d->u->rst.ptr = d->dat[b0]; break; |
|
| 305 |
+ switch(port) {
|
|
| 306 |
+ case 0x2: d->u->wst.ptr = d->dat[port]; break; |
|
| 307 |
+ case 0x3: d->u->rst.ptr = d->dat[port]; break; |
|
| 308 | 308 |
} |
| 309 |
- if(b0 > 0x7 && b0 < 0xe) |
|
| 309 |
+ if(port > 0x7 && port < 0xe) |
|
| 310 | 310 |
set_palette(&d->dat[0x8]); |
| 311 | 311 |
} |
| 312 | 312 |
|
| 313 | 313 |
static void |
| 314 |
-console_deo(Device *d, Uint8 b0) |
|
| 314 |
+console_deo(Device *d, Uint8 port) |
|
| 315 | 315 |
{
|
| 316 |
- if(b0 == 0x1) |
|
| 316 |
+ if(port == 0x1) |
|
| 317 | 317 |
d->vector = peek16(d->dat, 0x0); |
| 318 |
- if(b0 > 0x7) |
|
| 319 |
- write(b0 - 0x7, (char *)&d->dat[b0], 1); |
|
| 318 |
+ if(port > 0x7) |
|
| 319 |
+ write(port - 0x7, (char *)&d->dat[port], 1); |
|
| 320 | 320 |
} |
| 321 | 321 |
|
| 322 | 322 |
static Uint8 |
| 323 |
-screen_dei(Device *d, Uint8 b0) |
|
| 323 |
+screen_dei(Device *d, Uint8 port) |
|
| 324 | 324 |
{
|
| 325 |
- switch(b0) {
|
|
| 325 |
+ switch(port) {
|
|
| 326 | 326 |
case 0x2: return ppu.width >> 8; |
| 327 | 327 |
case 0x3: return ppu.width; |
| 328 | 328 |
case 0x4: return ppu.height >> 8; |
| 329 | 329 |
case 0x5: return ppu.height; |
| 330 |
- default: return d->dat[b0]; |
|
| 330 |
+ default: return d->dat[port]; |
|
| 331 | 331 |
} |
| 332 | 332 |
} |
| 333 | 333 |
|
| 334 | 334 |
static void |
| 335 |
-screen_deo(Device *d, Uint8 b0) |
|
| 335 |
+screen_deo(Device *d, Uint8 port) |
|
| 336 | 336 |
{
|
| 337 |
- switch(b0) {
|
|
| 337 |
+ switch(port) {
|
|
| 338 | 338 |
case 0x1: d->vector = peek16(d->dat, 0x0); break; |
| 339 | 339 |
case 0x5: |
| 340 | 340 |
if(!FIXED_SIZE) set_size(peek16(d->dat, 0x2), peek16(d->dat, 0x4), 1); |
| ... | ... |
@@ -368,14 +368,14 @@ screen_deo(Device *d, Uint8 b0) |
| 368 | 368 |
} |
| 369 | 369 |
|
| 370 | 370 |
static void |
| 371 |
-file_deo(Device *d, Uint8 b0) |
|
| 371 |
+file_deo(Device *d, Uint8 port) |
|
| 372 | 372 |
{
|
| 373 |
- Uint8 read = b0 == 0xd; |
|
| 374 |
- if(read || b0 == 0xf) {
|
|
| 373 |
+ Uint8 read = port == 0xd; |
|
| 374 |
+ if(read || port == 0xf) {
|
|
| 375 | 375 |
char *name = (char *)&d->mem[peek16(d->dat, 0x8)]; |
| 376 | 376 |
Uint16 result = 0, length = peek16(d->dat, 0xa); |
| 377 | 377 |
long offset = (peek16(d->dat, 0x4) << 16) + peek16(d->dat, 0x6); |
| 378 |
- Uint16 addr = peek16(d->dat, b0 - 1); |
|
| 378 |
+ Uint16 addr = peek16(d->dat, port - 1); |
|
| 379 | 379 |
FILE *f = fopen(name, read ? "rb" : (offset ? "ab" : "wb")); |
| 380 | 380 |
if(f) {
|
| 381 | 381 |
if(fseek(f, offset, SEEK_SET) != -1) |
| ... | ... |
@@ -387,23 +387,23 @@ file_deo(Device *d, Uint8 b0) |
| 387 | 387 |
} |
| 388 | 388 |
|
| 389 | 389 |
static Uint8 |
| 390 |
-audio_dei(Device *d, Uint8 b0) |
|
| 390 |
+audio_dei(Device *d, Uint8 port) |
|
| 391 | 391 |
{
|
| 392 | 392 |
Apu *c = &apu[d - devaudio0]; |
| 393 |
- if(!audio_id) return d->dat[b0]; |
|
| 394 |
- switch(b0) {
|
|
| 393 |
+ if(!audio_id) return d->dat[port]; |
|
| 394 |
+ switch(port) {
|
|
| 395 | 395 |
case 0x4: return apu_get_vu(c); |
| 396 | 396 |
case 0x2: poke16(d->dat, 0x2, c->i); /* fall through */ |
| 397 |
- default: return d->dat[b0]; |
|
| 397 |
+ default: return d->dat[port]; |
|
| 398 | 398 |
} |
| 399 | 399 |
} |
| 400 | 400 |
|
| 401 | 401 |
static void |
| 402 |
-audio_deo(Device *d, Uint8 b0) |
|
| 402 |
+audio_deo(Device *d, Uint8 port) |
|
| 403 | 403 |
{
|
| 404 | 404 |
Apu *c = &apu[d - devaudio0]; |
| 405 | 405 |
if(!audio_id) return; |
| 406 |
- if(b0 == 0xf) {
|
|
| 406 |
+ if(port == 0xf) {
|
|
| 407 | 407 |
SDL_LockAudioDevice(audio_id); |
| 408 | 408 |
c->len = peek16(d->dat, 0xa); |
| 409 | 409 |
c->addr = &d->mem[peek16(d->dat, 0xc)]; |
| ... | ... |
@@ -417,11 +417,11 @@ audio_deo(Device *d, Uint8 b0) |
| 417 | 417 |
} |
| 418 | 418 |
|
| 419 | 419 |
static Uint8 |
| 420 |
-datetime_dei(Device *d, Uint8 b0) |
|
| 420 |
+datetime_dei(Device *d, Uint8 port) |
|
| 421 | 421 |
{
|
| 422 | 422 |
time_t seconds = time(NULL); |
| 423 | 423 |
struct tm *t = localtime(&seconds); |
| 424 |
- switch(b0) {
|
|
| 424 |
+ switch(port) {
|
|
| 425 | 425 |
case 0x0: return (t->tm_year + 1900) >> 8; |
| 426 | 426 |
case 0x1: return (t->tm_year + 1900); |
| 427 | 427 |
case 0x2: return t->tm_mon; |
| ... | ... |
@@ -433,20 +433,20 @@ datetime_dei(Device *d, Uint8 b0) |
| 433 | 433 |
case 0x8: return t->tm_yday >> 8; |
| 434 | 434 |
case 0x9: return t->tm_yday; |
| 435 | 435 |
case 0xa: return t->tm_isdst; |
| 436 |
- default: return d->dat[b0]; |
|
| 436 |
+ default: return d->dat[port]; |
|
| 437 | 437 |
} |
| 438 | 438 |
} |
| 439 | 439 |
|
| 440 | 440 |
static Uint8 |
| 441 |
-nil_dei(Device *d, Uint8 b0) |
|
| 441 |
+nil_dei(Device *d, Uint8 port) |
|
| 442 | 442 |
{
|
| 443 |
- return d->dat[b0]; |
|
| 443 |
+ return d->dat[port]; |
|
| 444 | 444 |
} |
| 445 | 445 |
|
| 446 | 446 |
static void |
| 447 |
-nil_deo(Device *d, Uint8 b0) |
|
| 447 |
+nil_deo(Device *d, Uint8 port) |
|
| 448 | 448 |
{
|
| 449 |
- if(b0 == 0x1) d->vector = peek16(d->dat, 0x0); |
|
| 449 |
+ if(port == 0x1) d->vector = peek16(d->dat, 0x0); |
|
| 450 | 450 |
} |
| 451 | 451 |
|
| 452 | 452 |
static const char *errors[] = {"underflow", "overflow", "division by zero"};
|