aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-05-21 19:30:08 +0200
committerBad Diode <bd@badd10de.dev>2021-05-21 19:30:08 +0200
commit3924524adf85914bbdb77f002d5443597ef154d8 (patch)
tree163a045016a19eebb71c20d661e953f8e9441ef2 /src/main.c
parent0cfa96f83d6c44b318cc0da0ec98e8e3bc97f7f9 (diff)
downloaduxngba-3924524adf85914bbdb77f002d5443597ef154d8.tar.gz
uxngba-3924524adf85914bbdb77f002d5443597ef154d8.zip
Fix filesystem read issues, load/save rom demo is working
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index a65b1fe..a414558 100644
--- a/src/main.c
+++ b/src/main.c
@@ -104,19 +104,16 @@ datetime_talk(Device *d, Uint8 b0, Uint8 w) {
104void 104void
105file_talk(Device *d, Uint8 b0, Uint8 w) { 105file_talk(Device *d, Uint8 b0, Uint8 w) {
106 Uint8 read = b0 == 0xd; 106 Uint8 read = b0 == 0xd;
107 txt_printf("FILE TALK\n"); // DEBUG: Remove when done
108 if(w && (read || b0 == 0xf)) { 107 if(w && (read || b0 == 0xf)) {
109 char *name = (char *)&d->mem[mempeek16(d->dat, 0x8)]; 108 char *name = (char *)&d->mem[mempeek16(d->dat, 0x8)];
110 Uint16 result = 0, length = mempeek16(d->dat, 0xa); 109 Uint16 result = 0, length = mempeek16(d->dat, 0xa);
111 Uint16 offset = mempeek16(d->dat, 0x4); 110 Uint16 offset = mempeek16(d->dat, 0x4);
112 Uint16 addr = mempeek16(d->dat, b0 - 1); 111 Uint16 addr = mempeek16(d->dat, b0 - 1);
113 int file_idx = fs_open_file(name); 112 int file_idx = fs_open_file(name, read ? OPEN_READ : OPEN_WRITE);
114 if (file_idx >= 0) { 113 if (file_idx >= 0) {
115 if (read) { 114 if (read) {
116 txt_printf("READING\n"); // DEBUG: Remove when done
117 result = fs_read(&d->mem[addr], length, file_idx, offset); 115 result = fs_read(&d->mem[addr], length, file_idx, offset);
118 } else { 116 } else {
119 txt_printf("WRITING\n"); // DEBUG: Remove when done
120 result = fs_write(&d->mem[addr], length, file_idx, offset, offset > 0); 117 result = fs_write(&d->mem[addr], length, file_idx, offset, offset > 0);
121 } 118 }
122 } 119 }