src/mess/machine/hp48.c
| r3855 | r3856 | |
| 8 | 8 | |
| 9 | 9 | #include "driver.h" |
| 10 | 10 | #include "timer.h" |
| 11 | | #include "state.h" |
| 11 | #include "state.h" |
| 12 | 12 | #include "device.h" |
| 13 | 13 | #include "sound/dac.h" |
| 14 | 14 | #include "cpu/saturn/saturn.h" |
| r3855 | r3856 | |
| 186 | 186 | /* end of send event */ |
| 187 | 187 | static TIMER_CALLBACK( hp48_rs232_byte_sent_cb ) |
| 188 | 188 | { |
| 189 | | const device_config *xmodem = device_list_find_by_tag( machine->config->devicelist, XMODEM, "rs232-x" ); |
| 190 | | const device_config *kermit = device_list_find_by_tag( machine->config->devicelist, KERMIT, "rs232-k" ); |
| 189 | const device_config *xmodem = device_list_find_by_tag( machine->config->devicelist, XMODEM, "rs232_x" ); |
| 190 | const device_config *kermit = device_list_find_by_tag( machine->config->devicelist, KERMIT, "rs232_k" ); |
| 191 | 191 | |
| 192 | 192 | LOG_SERIAL(( "%f hp48_rs232_byte_sent_cb: end of send, data=%02x\n", |
| 193 | 193 | attotime_to_double(timer_get_time(machine)), param )); |
| r3855 | r3856 | |
| 211 | 211 | /* CPU initiates a send event */ |
| 212 | 212 | static void hp48_rs232_send_byte( running_machine *machine ) |
| 213 | 213 | { |
| 214 | | const device_config *xmodem = device_list_find_by_tag( machine->config->devicelist, XMODEM, "rs232-x" ); |
| 215 | | const device_config *kermit = device_list_find_by_tag( machine->config->devicelist, KERMIT, "rs232-k" ); |
| 216 | | |
| 214 | const device_config *xmodem = device_list_find_by_tag( machine->config->devicelist, XMODEM, "rs232_x" ); |
| 215 | const device_config *kermit = device_list_find_by_tag( machine->config->devicelist, KERMIT, "rs232_k" ); |
| 217 | 216 | UINT8 data = HP48_IO_8(0x16); /* byte to send */ |
| 218 | 217 | |
| 219 | | // LOG_SERIAL(( "%05x %f hp48_rs232_send_byte: start sending, data=%02x\n", |
| 220 | | // activecpu_get_previouspc(), attotime_to_double(timer_get_time(machine)), data )); |
| 218 | LOG_SERIAL(( "%05x %f hp48_rs232_send_byte: start sending, data=%02x\n", |
| 219 | cpu_get_previouspc(machine->cpu[0]), attotime_to_double(timer_get_time(machine)), data )); |
| 221 | 220 | |
| 222 | 221 | hp48_io[0x12] |= 3; /* set byte sending and send buffer full */ |
| 223 | 222 | |
| r3855 | r3856 | |
| 272 | 271 | } |
| 273 | 272 | |
| 274 | 273 | /* schedule end of reception */ |
| 275 | | timer_set( RS232_DELAY, NULL, 0, hp48_chardev_byte_recv_cb ); |
| 274 | timer_set( machine, RS232_DELAY, NULL, 0, hp48_chardev_byte_recv_cb ); |
| 276 | 275 | } |
| 277 | 276 | |
| 278 | 277 | static void hp48_chardev_ready_to_send( running_machine *machine ) |
| r3855 | r3856 | |
| 298 | 297 | /* CPU sets OUT register (keyboard + beeper) */ |
| 299 | 298 | void hp48_reg_out( running_machine* machine, int out ) |
| 300 | 299 | { |
| 301 | | // LOG(( "%05x %f hp48_reg_out: %03x\n", |
| 302 | | // activecpu_get_previouspc(), attotime_to_double(timer_get_time(machine)), out )); |
| 300 | LOG(( "%05x %f hp48_reg_out: %03x\n", |
| 301 | cpu_get_previouspc(machine->cpu[0]), attotime_to_double(timer_get_time(machine)), out )); |
| 303 | 302 | |
| 304 | 303 | /* bits 0-8: keyboard lines */ |
| 305 | 304 | hp48_out = out & 0x1ff; |
| r3855 | r3856 | |
| 335 | 334 | int hp48_reg_in( running_machine* machine ) |
| 336 | 335 | { |
| 337 | 336 | int in = hp48_get_in( machine ); |
| 338 | | // LOG(( "%05x %f hp48_reg_in: %04x\n", |
| 339 | | // activecpu_get_previouspc(), attotime_to_double(timer_get_time(machine)), in )); |
| 337 | LOG(( "%05x %f hp48_reg_in: %04x\n", |
| 338 | cpu_get_previouspc(machine->cpu[0]), attotime_to_double(timer_get_time(machine)), in )); |
| 340 | 339 | return in; |
| 341 | 340 | } |
| 342 | 341 | |
| r3855 | r3856 | |
| 378 | 377 | /* RSI opcode */ |
| 379 | 378 | void hp48_rsi( running_machine *machine ) |
| 380 | 379 | { |
| 381 | | // LOG(( "%05x %f hp48_rsi\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time(machine)) )); |
| 380 | LOG(( "%05x %f hp48_rsi\n", cpu_get_previouspc(machine->cpu[0]), attotime_to_double(timer_get_time(machine)) )); |
| 382 | 381 | |
| 383 | 382 | /* enables interrupts on key repeat |
| 384 | 383 | (normally, there is only one interrupt, when the key is pressed) |
| r3855 | r3856 | |
| 464 | 463 | /* cards */ |
| 465 | 464 | case 0x0e: |
| 466 | 465 | LOG(( "%05x: card control write %02x\n", cpu_get_previouspc(space->cpu), data )); |
| 466 | |
| 467 | 467 | /* bit 0: software interrupt */ |
| 468 | 468 | if ( data & 1 ) |
| 469 | 469 | { |
| r3855 | r3856 | |
| 596 | 596 | { |
| 597 | 597 | /* second nibble of received data */ |
| 598 | 598 | |
| 599 | | const device_config *xmodem = device_list_find_by_tag( space->machine->config->devicelist, XMODEM, "rs232-x" ); |
| 600 | | const device_config *kermit = device_list_find_by_tag( space->machine->config->devicelist, KERMIT, "rs232-k" ); |
| 599 | const device_config *xmodem = device_list_find_by_tag( space->machine->config->devicelist, XMODEM, "rs232_x" ); |
| 600 | const device_config *kermit = device_list_find_by_tag( space->machine->config->devicelist, KERMIT, "rs232_k" ); |
| 601 | 601 | |
| 602 | 602 | hp48_io[0x11] &= ~1; /* clear byte received */ |
| 603 | 603 | data = hp48_io[offset]; |
| r3855 | r3856 | |
| 714 | 714 | /* --------- memory controller ----------- */ |
| 715 | 715 | |
| 716 | 716 | /* |
| 717 | | Clark (S series) and York (G series) CPUs have 6 daisy-chainedmodules |
| 717 | Clark (S series) and York (G series) CPUs have 6 daisy-chained modules |
| 718 | 718 | |
| 719 | 719 | |
| 720 | 720 | <-- highest --------- priority ------------- lowest --> |
| r3855 | r3856 | |
| 754 | 754 | { |
| 755 | 755 | int i; |
| 756 | 756 | int nce2_enable = 1; |
| 757 | const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 757 | 758 | |
| 758 | 759 | hp48_io_addr = 0x100000; |
| 759 | 760 | |
| r3855 | r3856 | |
| 812 | 813 | select_mask, hp48_module_names[i] ); |
| 813 | 814 | continue; |
| 814 | 815 | } |
| 815 | | memory_install_read8_handler( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), base, end, 0, mirror, hp48_modules[i].read ); |
| 816 | | memory_install_write8_handler( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), base, end, 0, mirror, hp48_modules[i].write ); |
| 816 | memory_install_read8_handler( space, base, end, 0, mirror, hp48_modules[i].read ); |
| 817 | memory_install_write8_handler( space, base, end, 0, mirror, hp48_modules[i].write ); |
| 817 | 818 | |
| 818 | 819 | LOG(( "hp48_mem_config: module %s configured at %05x-%05x, mirror %05x\n", |
| 819 | 820 | hp48_module_names[i], base, end, mirror )); |
| 820 | 821 | |
| 821 | 822 | if ( hp48_modules[i].data ) |
| 822 | 823 | { |
| 823 | | memory_set_bankptr( machine, i, hp48_modules[i].data ); |
| 824 | memory_set_bankptr( space->machine, i, hp48_modules[i].data ); |
| 824 | 825 | } |
| 825 | 826 | |
| 826 | 827 | if ( i == 0 ) |
| r3855 | r3856 | |
| 856 | 857 | /* RESET opcode */ |
| 857 | 858 | void hp48_mem_reset( running_machine* machine ) |
| 858 | 859 | { |
| 859 | | // LOG(( "%05x %f hp48_mem_reset\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time(machine)) )); |
| 860 | LOG(( "%05x %f hp48_mem_reset\n", cpu_get_previouspc(machine->cpu[0]), attotime_to_double(timer_get_time(machine)) )); |
| 860 | 861 | hp48_reset_modules( machine ); |
| 861 | 862 | } |
| 862 | 863 | |
| r3855 | r3856 | |
| 866 | 867 | { |
| 867 | 868 | int i; |
| 868 | 869 | |
| 869 | | // LOG(( "%05x %f hp48_mem_config: %05x\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time(machine)), v )); |
| 870 | LOG(( "%05x %f hp48_mem_config: %05x\n", cpu_get_previouspc(machine->cpu[0]), attotime_to_double(timer_get_time(machine)), v )); |
| 870 | 871 | |
| 871 | 872 | /* find the highest priority unconfigured module (except non-configurable NCE1)... */ |
| 872 | 873 | for ( i = 0; i < 5; i++ ) |
| r3855 | r3856 | |
| 897 | 898 | void hp48_mem_unconfig( running_machine* machine, int v ) |
| 898 | 899 | { |
| 899 | 900 | int i; |
| 900 | | // LOG(( "%05x %f hp48_mem_unconfig: %05x\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time(machine)), v )); |
| 901 | LOG(( "%05x %f hp48_mem_unconfig: %05x\n", cpu_get_previouspc(machine->cpu[0]), attotime_to_double(timer_get_time(machine)), v )); |
| 901 | 902 | |
| 902 | 903 | /* find the highest priority fully configured module at address v (except NCE1)... */ |
| 903 | 904 | for ( i = 0; i < 5; i++ ) |
| r3855 | r3856 | |
| 939 | 940 | } |
| 940 | 941 | } |
| 941 | 942 | |
| 942 | | // LOG(( "%05x %f hp48_mem_id = %02x\n", |
| 943 | | // activecpu_get_previouspc(), attotime_to_double(timer_get_time(machine)), data )); |
| 943 | LOG(( "%05x %f hp48_mem_id = %02x\n", |
| 944 | cpu_get_previouspc(machine->cpu[0]), attotime_to_double(timer_get_time(machine)), data )); |
| 944 | 945 | |
| 945 | 946 | return data; /* everything is configured */ |
| 946 | 947 | } |
| r3855 | r3856 | |
| 1151 | 1152 | generic_nvram_size = 2 * ram_size; |
| 1152 | 1153 | generic_nvram = auto_malloc( generic_nvram_size ); |
| 1153 | 1154 | ram = (UINT8*) generic_nvram; |
| 1154 | | memset( generic_nvram, 0, generic_nvram_size ); |
| 1155 | 1155 | |
| 1156 | 1156 | /* ROM load */ |
| 1157 | 1157 | rom_size = HP48_S_SERIES ? (256 * 1024) : (512 * 1024); |
| r3855 | r3856 | |
| 1186 | 1186 | /* bank switcher */ |
| 1187 | 1187 | hp48_modules[2].off_mask = 0x00fff; /* 2 KB */ |
| 1188 | 1188 | hp48_modules[2].read = hp48_bank_r; |
| 1189 | hp48_modules[2].write = SMH_NOP; |
| 1189 | 1190 | } |
| 1190 | 1191 | |
| 1191 | 1192 | /* ROM */ |
| 1192 | 1193 | hp48_modules[5].off_mask = 2 * rom_size - 1; |
| 1193 | 1194 | hp48_modules[5].read = SMH_BANK5; |
| 1195 | hp48_modules[5].write = SMH_NOP; |
| 1194 | 1196 | hp48_modules[5].data = rom; |
| 1195 | 1197 | |
| 1196 | 1198 | /* timers */ |