src/mess/machine/hp48.c
| r6691 | r6692 | |
| 53 | 53 | read8_space_func read; |
| 54 | 54 | write8_space_func write; |
| 55 | 55 | void* data; /* non-NULL for banks */ |
| 56 | | |
| 56 | int isnop; |
| 57 | |
| 57 | 58 | /* configurable part */ |
| 58 | 59 | UINT8 state; /* one of HP48_MODULE_ */ |
| 59 | 60 | UINT32 base; /* base address */ |
| r6691 | r6692 | |
| 800 | 801 | UINT32 mirror = nselect_mask & ~off_mask; |
| 801 | 802 | UINT32 end = base + (off_mask & nselect_mask); |
| 802 | 803 | char bank[10]; |
| 803 | | |
| 804 | sprintf(bank,"bank%d",i); |
| 805 | |
| 804 | 806 | if ( hp48_modules[i].state != HP48_MODULE_CONFIGURED ) continue; |
| 805 | 807 | |
| 806 | 808 | if ( (i == 4) && !nce2_enable ) continue; |
| r6691 | r6692 | |
| 812 | 814 | select_mask, hp48_module_names[i] ); |
| 813 | 815 | continue; |
| 814 | 816 | } |
| 815 | | memory_install_read8_handler( space, base, end, 0, mirror, hp48_modules[i].read ); |
| 816 | | memory_install_write8_handler( space, base, end, 0, mirror, hp48_modules[i].write ); |
| 817 | | |
| 817 | if ((hp48_modules[i].data == NULL) && (hp48_modules[i].write == NULL) && (hp48_modules[i].read == NULL)) { |
| 818 | memory_unmap_readwrite(space, base, end, 0, mirror); |
| 819 | } else { |
| 820 | if (hp48_modules[i].data !=NULL) { |
| 821 | memory_install_read_bank( space, base, end, 0, mirror, bank ); |
| 822 | } else { |
| 823 | memory_install_read8_handler( space, base, end, 0, mirror, hp48_modules[i].read ); |
| 824 | } |
| 825 | if (hp48_modules[i].isnop == 1) { |
| 826 | memory_nop_write(space, base, end, 0, mirror); |
| 827 | } else { |
| 828 | if (hp48_modules[i].data !=NULL) { |
| 829 | memory_install_write_bank( space, base, end, 0, mirror, bank ); |
| 830 | } else { |
| 831 | memory_install_write8_handler( space, base, end, 0, mirror, hp48_modules[i].write ); |
| 832 | } |
| 833 | } |
| 834 | } |
| 818 | 835 | LOG(( "hp48_apply_modules: module %s configured at %05x-%05x, mirror %05x\n", |
| 819 | 836 | hp48_module_names[i], base, end, mirror )); |
| 820 | 837 | |
| 821 | 838 | if ( hp48_modules[i].data ) |
| 822 | 839 | { |
| 823 | | sprintf(bank,"bank%d",i); |
| 824 | 840 | memory_set_bankptr( space->machine, bank, hp48_modules[i].data ); |
| 825 | 841 | } |
| 826 | 842 | |
| r6691 | r6692 | |
| 1004 | 1020 | hp48_port_data[conf->port] = malloc( 2 * size ); |
| 1005 | 1021 | memset( hp48_port_data[conf->port], 0, 2 * size ); |
| 1006 | 1022 | hp48_modules[conf->module].off_mask = 2 * (( size > 128 * 1024 ) ? 128 * 1024 : size) - 1; |
| 1007 | | hp48_modules[conf->module].read = SMH_BANK((FPTR)conf->module); |
| 1008 | | hp48_modules[conf->module].write = hp48_port_write[conf->port] ? (void*)SMH_BANK((FPTR)conf->module) : SMH_NOP; |
| 1023 | hp48_modules[conf->module].read = NULL; |
| 1024 | hp48_modules[conf->module].write = NULL; |
| 1025 | hp48_modules[conf->module].isnop = 0; |
| 1026 | if (hp48_port_write[conf->port]) { |
| 1027 | hp48_modules[conf->module].isnop = 1; |
| 1028 | } |
| 1009 | 1029 | hp48_modules[conf->module].data = hp48_port_data[conf->port]; |
| 1010 | 1030 | hp48_apply_modules( image->machine, NULL ); |
| 1011 | 1031 | } |
| r6691 | r6692 | |
| 1015 | 1035 | { |
| 1016 | 1036 | struct hp48_port_config* conf = (struct hp48_port_config*) image->static_config; |
| 1017 | 1037 | hp48_modules[conf->module].off_mask = 0x00fff; /* 2 KB */ |
| 1018 | | hp48_modules[conf->module].read = SMH_UNMAP; |
| 1019 | | hp48_modules[conf->module].write = SMH_UNMAP; |
| 1038 | hp48_modules[conf->module].read = NULL; |
| 1039 | hp48_modules[conf->module].write = NULL; |
| 1020 | 1040 | hp48_modules[conf->module].data = NULL; |
| 1021 | 1041 | } |
| 1022 | 1042 | |
| r6691 | r6692 | |
| 1122 | 1142 | for ( i = 0; i < 6; i++ ) |
| 1123 | 1143 | { |
| 1124 | 1144 | hp48_modules[i].off_mask = 0x00fff; /* 2 KB */ |
| 1125 | | hp48_modules[i].read = SMH_UNMAP; |
| 1126 | | hp48_modules[i].write = SMH_UNMAP; |
| 1145 | hp48_modules[i].read = NULL; |
| 1146 | hp48_modules[i].write = NULL; |
| 1127 | 1147 | hp48_modules[i].data = NULL; |
| 1128 | 1148 | } |
| 1129 | 1149 | hp48_port_size[0] = 0; |
| r6691 | r6692 | |
| 1168 | 1188 | hp48_bank_switch = 0; |
| 1169 | 1189 | |
| 1170 | 1190 | /* static module configuration */ |
| 1171 | | |
| 1191 | memset(hp48_modules,0,sizeof(hp48_modules)); // to put all on 0 |
| 1172 | 1192 | /* I/O RAM */ |
| 1173 | 1193 | hp48_modules[0].off_mask = 0x0003f; /* 32 B */ |
| 1174 | 1194 | hp48_modules[0].read = hp48_io_r; |
| r6691 | r6692 | |
| 1176 | 1196 | |
| 1177 | 1197 | /* internal RAM */ |
| 1178 | 1198 | hp48_modules[1].off_mask = 2 * ram_size - 1; |
| 1179 | | hp48_modules[1].read = SMH_BANK(1); |
| 1180 | | hp48_modules[1].write = SMH_BANK(1); |
| 1199 | hp48_modules[1].read = NULL; |
| 1200 | hp48_modules[1].write = NULL; |
| 1181 | 1201 | hp48_modules[1].data = ram; |
| 1182 | 1202 | |
| 1183 | 1203 | if ( HP48_G_SERIES ) |
| r6691 | r6692 | |
| 1185 | 1205 | /* bank switcher */ |
| 1186 | 1206 | hp48_modules[2].off_mask = 0x00fff; /* 2 KB */ |
| 1187 | 1207 | hp48_modules[2].read = hp48_bank_r; |
| 1188 | | hp48_modules[2].write = SMH_NOP; |
| 1208 | hp48_modules[2].write = NULL; |
| 1189 | 1209 | } |
| 1190 | 1210 | |
| 1191 | 1211 | /* ROM */ |
| 1192 | 1212 | hp48_modules[5].off_mask = 2 * rom_size - 1; |
| 1193 | | hp48_modules[5].read = SMH_BANK(5); |
| 1194 | | hp48_modules[5].write = SMH_NOP; |
| 1213 | hp48_modules[5].read = NULL; |
| 1214 | hp48_modules[5].write = NULL; |
| 1215 | hp48_modules[5].isnop = 1; |
| 1195 | 1216 | hp48_modules[5].data = rom; |
| 1196 | 1217 | |
| 1197 | 1218 | /* timers */ |