|
|
1.1.1.2 ! root 1: /* Generator is (c) James Ponder, 1997-2001 http://www.squish.net/generator/ */ 1.1 root 2: 3: #include <stdio.h> 4: 5: #include "generator.h" 6: #include "mem68k.h" 7: #include "cpuz80.h" 8: #include "memz80.h" 9: #include "gensound.h" 1.1.1.2 ! root 10: #include "gensoundi.h" 1.1 root 11: #include "ui.h" 12: 13: /*** forward references ***/ 14: 15: uint8 memz80_fetch_bad_byte(uint32 addr); 16: uint8 memz80_fetch_sram_byte(uint32 addr); 17: uint8 memz80_fetch_yam_byte(uint32 addr); 18: uint8 memz80_fetch_bank_byte(uint32 addr); 19: uint8 memz80_fetch_mem_byte(uint32 addr); 20: uint8 memz80_fetch_psg_byte(uint32 addr); 21: 22: void memz80_store_bad_byte(uint32 addr, uint8 data); 23: void memz80_store_sram_byte(uint32 addr, uint8 data); 24: void memz80_store_yam_byte(uint32 addr, uint8 data); 25: void memz80_store_bank_byte(uint32 addr, uint8 data); 26: void memz80_store_mem_byte(uint32 addr, uint8 data); 27: void memz80_store_psg_byte(uint32 addr, uint8 data); 28: 29: /*** file scope variables */ 30: 31: /*** memory map ***/ 32: 33: t_memz80_def memz80_def[] = { 1.1.1.2 ! root 34: { 0x00, 0x40, memz80_fetch_sram_byte, memz80_store_sram_byte }, 1.1 root 35: { 0x40, 0x41, memz80_fetch_yam_byte, memz80_store_yam_byte }, 36: { 0x41, 0x60, memz80_fetch_bad_byte, memz80_store_bad_byte }, 1.1.1.2 ! root 37: { 0x60, 0x70, memz80_fetch_bank_byte, memz80_store_bank_byte }, ! 38: { 0x70, 0x7F, memz80_fetch_bad_byte, memz80_store_bad_byte }, 1.1 root 39: { 0x7F, 0x80, memz80_fetch_psg_byte, memz80_store_psg_byte }, 40: { 0x80, 0x100, memz80_fetch_mem_byte, memz80_store_mem_byte }, 41: { 0, 0, NULL, NULL } 42: }; 43: 44: uint8 (*memz80_fetch_byte[0x100])(uint32 addr); 45: void (*memz80_store_byte[0x100])(uint32 addr, uint8 data); 46: 47: /*** initialise memory tables ***/ 48: 49: int memz80_init(void) 50: { 51: int i = 0; 52: int j; 53: 54: do { 55: for (j = memz80_def[i].start; j < memz80_def[i].end; j++) { 56: memz80_fetch_byte[j] = memz80_def[i].fetch_byte; 57: memz80_store_byte[j] = memz80_def[i].store_byte; 58: } 59: i++; 60: } while ((memz80_def[i].start != 0) || (memz80_def[i].end != 0)); 61: return 0; 62: } 63: 64: /*** BAD fetch/store ***/ 65: 66: uint8 memz80_fetch_bad_byte(uint32 addr) 67: { 68: LOG_CRITICAL(("[Z80] Invalid memory fetch (byte) 0x%X", addr)); 69: return 0; 70: } 71: 72: void memz80_store_bad_byte(uint32 addr, uint8 data) 73: { 74: LOG_CRITICAL(("[Z80] Invalid memory store (byte) 0x%X", addr)); 75: } 76: 77: /*** SRAM fetch/store ***/ 78: 79: uint8 memz80_fetch_sram_byte(uint32 addr) 80: { 1.1.1.2 ! root 81: return (*(uint8 *)(cpuz80_ram+(addr & 0x1fff))); 1.1 root 82: } 83: 84: void memz80_store_sram_byte(uint32 addr, uint8 data) 85: { 1.1.1.2 ! root 86: *(uint8 *)(cpuz80_ram+(addr & 0x1fff)) = data; 1.1 root 87: return; 88: } 89: 90: /*** YAM fetch/store ***/ 91: 92: uint8 memz80_fetch_yam_byte(uint32 addr) 93: { 94: addr-= 0x4000; 95: if (addr < 4) { 1.1.1.2 ! root 96: return soundi_ym2612fetch(addr); 1.1 root 97: } else { 98: LOG_CRITICAL(("[Z80] invalid YAM fetch (byte) 0x%X", addr)); 99: return 0; 100: } 101: } 102: 103: void memz80_store_yam_byte(uint32 addr, uint8 data) 104: { 105: addr-= 0x4000; 106: /* LOG_USER(("[YAM] (z80) store (byte) 0x%X (%d)", addr, data)); */ 107: if (addr < 4) 1.1.1.2 ! root 108: soundi_ym2612store(addr, data); 1.1 root 109: else 110: LOG_CRITICAL(("[Z80] invalid YAM store (byte) 0x%X", addr)); 111: } 112: 113: /*** BANK fetch/store ***/ 114: 115: uint8 memz80_fetch_bank_byte(uint32 addr) 116: { 117: /* write only */ 118: LOG_CRITICAL(("[Z80] Bank fetch (Byte) 0x%X", addr)); 119: return 0; 120: } 121: 122: void memz80_store_bank_byte(uint32 addr, uint8 data) 123: { 124: /* set bank */ 125: cpuz80_bankwrite(data); 126: } 127: 128: /*** MEM (banked) fetch/store ***/ 129: 130: uint8 memz80_fetch_mem_byte(uint32 addr) 131: { 132: return (fetchbyte(cpuz80_bank | (addr-0x8000))); 133: } 134: 135: void memz80_store_mem_byte(uint32 addr, uint8 data) 136: { 137: /* LOG_USER(("WRITE whilst bank = %08X (%08X)", cpuz80_bank, 138: addr-0x8000)); */ 139: storebyte(cpuz80_bank | (addr-0x8000), data); 140: } 141: 142: /*** PSG fetch/store ***/ 143: 144: uint8 memz80_fetch_psg_byte(uint32 addr) 145: { 146: /* write only */ 147: LOG_CRITICAL(("[Z80] Invalid memory read (byte) 0x%X", addr)); 148: return 0; 149: } 150: 151: void memz80_store_psg_byte(uint32 addr, uint8 data) 152: { 153: if (addr == 0x7f11) 154: sound_psgwrite(data); 155: else 156: LOG_CRITICAL(("[Z80] Invalid memory store (byte) 0x%X", addr)); 157: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.