uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 400c49e96b836d5b1000305434ef17a7b9a5ee96
parent bbf05cb4ec1d557f713f717531cdba4655c5fbd7
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Wed, 21 Apr 2021 13:37:41 +0100

Fixed file_poke

Diffstat:
Msrc/debugger.c | 14++++++--------
Msrc/emulator.c | 16++++++----------
2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/src/debugger.c b/src/debugger.c @@ -54,22 +54,20 @@ console_poke(Device *d, Uint8 b0, Uint8 b1) Uint8 file_poke(Device *d, Uint8 b0, Uint8 b1) { - /* Uint8 read = b0 == 0xd; if(read || b0 == 0xf) { - char *name = (char *)&d->mem[mempeek16(m, 0x8)]; - Uint16 result = 0, length = mempeek16(m, 0xa); - Uint16 offset = mempeek16(m, 0x4); - Uint16 addr = (m[b0 - 1] << 8) | b1; + char *name = (char *)&d->mem[mempeek16(d->dat, 0x8)]; + Uint16 result = 0, length = mempeek16(d->dat, 0xa); + Uint16 offset = mempeek16(d->dat, 0x4); + Uint16 addr = (d->dat[b0 - 1] << 8) | b1; FILE *f = fopen(name, read ? "r" : (offset ? "a" : "w")); if(f) { - if(fseek(f, offset, SEEK_SET) != -1 && (result = read ? fread(&m[addr], 1, length, f) : fwrite(&m[addr], 1, length, f))) + if(fseek(f, offset, SEEK_SET) != -1 && (result = read ? fread(&d->mem[addr], 1, length, f) : fwrite(&d->mem[addr], 1, length, f))) printf("%s %d bytes, at %04x from %s\n", read ? "Loaded" : "Saved", length, addr, name); fclose(f); } - mempoke16(m, 0x2, result); + mempoke16(d->dat, 0x2, result); } - */ return b1; } diff --git a/src/emulator.c b/src/emulator.c @@ -225,24 +225,20 @@ screen_poke(Device *d, Uint8 b0, Uint8 b1) Uint8 file_poke(Device *d, Uint8 b0, Uint8 b1) { - /* TODO: Figure out why fwrite doesn't work with d->mem Uint8 read = b0 == 0xd; if(read || b0 == 0xf) { - char *name = (char *)&d->mem[mempeek16(m, 0x8)]; - Uint16 result = 0, length = mempeek16(m, 0xa); - Uint16 offset = mempeek16(m, 0x4); - Uint16 addr = (m[b0 - 1] << 8) | b1; + char *name = (char *)&d->mem[mempeek16(d->dat, 0x8)]; + Uint16 result = 0, length = mempeek16(d->dat, 0xa); + Uint16 offset = mempeek16(d->dat, 0x4); + Uint16 addr = (d->dat[b0 - 1] << 8) | b1; FILE *f = fopen(name, read ? "r" : (offset ? "a" : "w")); if(f) { - if(fseek(f, offset, SEEK_SET) != -1 && (result = read ? fread(d->mem[addr], 1, length, f) : fwrite(&d->mem[addr], 1, length, f))) + if(fseek(f, offset, SEEK_SET) != -1 && (result = read ? fread(&d->mem[addr], 1, length, f) : fwrite(&d->mem[addr], 1, length, f))) printf("%s %d bytes, at %04x from %s\n", read ? "Loaded" : "Saved", length, addr, name); fclose(f); } - mempoke16(m, 0x2, result); + mempoke16(d->dat, 0x2, result); } - */ - (void)d; - (void)b0; return b1; }