9 /* Story files do not have access to memory beyond 64K. If they do
10 * something that would cause such access, wrap appropriately. This is
11 * the approach Frotz uses (at least for @loadw/@loadb), and is endorsed
12 * by Andrew Plotkin (see http://www.intfiction.org/forum/viewtopic.php?f=38&t=2052).
13 * The standard isn’t exactly clear on the issue, and this appears to be
14 * the most sensible way to deal with the problem.
17 extern uint8_t *memory, *dynamic_memory;
18 extern uint32_t memory_size;
20 #define BYTE(addr) (memory[addr])
21 #define STORE_BYTE(addr, val) ((void)(memory[addr] = (val)))
23 static inline uint16_t WORD(uint32_t addr)
25 #ifndef ZTERP_NO_CHEAT
27 if(cheat_find_freezew(addr, &cheat_val)) return cheat_val;
29 return (memory[addr] << 8) | memory[addr + 1];
32 static inline void STORE_WORD(uint32_t addr, uint16_t val)
34 memory[addr + 0] = val >> 8;
35 memory[addr + 1] = val & 0xff;
38 static inline uint8_t user_byte(uint16_t addr)
40 ZASSERT(addr < header.static_end, "attempt to read out-of-bounds address 0x%lx", (unsigned long)addr);
45 static inline uint16_t user_word(uint16_t addr)
47 ZASSERT(addr < header.static_end - 1, "attempt to read out-of-bounds address 0x%lx", (unsigned long)addr);
52 void user_store_byte(uint16_t, uint8_t);
53 void user_store_word(uint16_t, uint16_t);