diff options
author | Bad Diode <bd@badd10de.dev> | 2023-04-12 10:17:48 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-04-12 10:17:48 +0200 |
commit | 1e87357d524cffa0fe5d9dc2bb22de1da4719f1e (patch) | |
tree | f8d2d51a584a8b8bab793af41ae5f5f3660027b2 | |
parent | f2646ec220a0a6ef197774101168a25099cc61de (diff) | |
download | uxnnst-main.tar.gz uxnnst-main.zip |
-rw-r--r-- | src/main.c | 47 |
1 files changed, 43 insertions, 4 deletions
@@ -535,7 +535,6 @@ load_uxn_rom(char *file_name) { | |||
535 | u8 | 535 | u8 |
536 | uxn_dei(Uxn *u, u8 addr) { | 536 | uxn_dei(Uxn *u, u8 addr) { |
537 | u8 p = addr & 0x0f, d = addr & 0xf0; | 537 | u8 p = addr & 0x0f, d = addr & 0xf0; |
538 | // printf("DEI: %x\n", d); | ||
539 | switch(d) { | 538 | switch(d) { |
540 | case 0x20: return screen_dei(&u->dev[d], p); | 539 | case 0x20: return screen_dei(&u->dev[d], p); |
541 | case 0xc0: return datetime_dei(u, p); | 540 | case 0xc0: return datetime_dei(u, p); |
@@ -544,6 +543,47 @@ uxn_dei(Uxn *u, u8 addr) { | |||
544 | } | 543 | } |
545 | 544 | ||
546 | void | 545 | void |
546 | file_deo_2(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port) { | ||
547 | UxnFile *c = &uxn_file[id]; | ||
548 | Uint16 addr, len, res; | ||
549 | switch(port) { | ||
550 | case 0x5: | ||
551 | addr = PEEK2(d + 0x4); | ||
552 | len = PEEK2(d + 0xa); | ||
553 | if(len > 0x10000 - addr) | ||
554 | len = 0x10000 - addr; | ||
555 | res = file_stat(c, &ram[addr], len); | ||
556 | POKE2(d + 0x2, res); | ||
557 | break; | ||
558 | case 0x6: | ||
559 | res = file_delete(c); | ||
560 | POKE2(d + 0x2, res); | ||
561 | break; | ||
562 | case 0x9: | ||
563 | addr = PEEK2(d + 0x8); | ||
564 | res = file_init(c, (char *)&ram[addr], 0x10000 - addr, 1); | ||
565 | POKE2(d + 0x2, res); | ||
566 | break; | ||
567 | case 0xd: | ||
568 | addr = PEEK2(d + 0xc); | ||
569 | len = PEEK2(d + 0xa); | ||
570 | if(len > 0x10000 - addr) | ||
571 | len = 0x10000 - addr; | ||
572 | res = file_read(c, &ram[addr], len); | ||
573 | POKE2(d + 0x2, res); | ||
574 | break; | ||
575 | case 0xf: | ||
576 | addr = PEEK2(d + 0xe); | ||
577 | len = PEEK2(d + 0xa); | ||
578 | if(len > 0x10000 - addr) | ||
579 | len = 0x10000 - addr; | ||
580 | res = file_write(c, &ram[addr], len, d[0x7]); | ||
581 | POKE2(d + 0x2, res); | ||
582 | break; | ||
583 | } | ||
584 | } | ||
585 | |||
586 | void | ||
547 | uxn_deo(Uxn *u, u8 addr) { | 587 | uxn_deo(Uxn *u, u8 addr) { |
548 | u8 p = addr & 0x0f, d = addr & 0xf0; | 588 | u8 p = addr & 0x0f, d = addr & 0xf0; |
549 | // printf("DEO: %x\n", d); | 589 | // printf("DEO: %x\n", d); |
@@ -555,9 +595,8 @@ uxn_deo(Uxn *u, u8 addr) { | |||
555 | break; | 595 | break; |
556 | case 0x10: console_deo(&u->dev[d], p); break; | 596 | case 0x10: console_deo(&u->dev[d], p); break; |
557 | case 0x20: screen_deo(u->ram, &u->dev[d], p); break; | 597 | case 0x20: screen_deo(u->ram, &u->dev[d], p); break; |
558 | // TODO: crash on file? | 598 | case 0xa0: file_deo_2(0, u->ram, &u->dev[d], p); break; |
559 | // case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break; | 599 | case 0xb0: file_deo_2(1, u->ram, &u->dev[d], p); break; |
560 | // case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break; | ||
561 | } | 600 | } |
562 | } | 601 | } |
563 | 602 | ||