/* * Copyright (c) 2024 Scott Duensing, scott@kangaroopunch.com * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /* * Z-Machine for the Foenix F256 computers. * * F256 machines are 65c02 based systems with 512k of banked RAM. * As such, this ZIP is going to load the story entirely into "high" * memory (above the 64k accessable to the CPU) and page things in * and out as needed. * * To keep library code at a minimum, we'll also statically allocate * as much as possible and do other "bad" things now frowned upon in * modern development. :-) */ #include "f256.h" #include "portme.h" #include "story.h" #include "memory.h" #include "state.h" #include "interpreter.h" #define BASE_ADDRESS 0x10000 uint8_t portByteGet(uint16_t address) { return FAR_PEEK(BASE_ADDRESS + address); } void portByteSet(uint16_t address, uint8_t value) { FAR_POKE(BASE_ADDRESS + address, value); } void portCharPrint(char c) { static char ch[2] = { 0, 0 }; ch[0] = c; textPrint(ch); } void portDie(char *fmt, ...) { exit(1); } bool portFileRestore(void) { FILE *in; bool ok = false; uint32_t i; byte b; in = fopen("save.dat", "rb"); if (in) { ok = true; // Read in PC. ok &= (fread(&__state.pc, sizeof(__state.pc), 1, in) == 1); // Read in SP. ok &= (fread(&__state.sp, sizeof(__state.sp), 1, in) == 1); // Read in BP. ok &= (fread(&__state.bp, sizeof(__state.bp), 1, in) == 1); // Read in dynamic game RAM. for (i=0; i