src/mess/machine/galaxy.c
| r3581 | r3582 | |
| 22 | 22 | |
| 23 | 23 | if (offset == 0) |
| 24 | 24 | { |
| 25 | | double level = cassette_input(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" )); |
| 25 | double level = cassette_input(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" )); |
| 26 | 26 | return (level > 0) ? 0xfe : 0xff; |
| 27 | 27 | } |
| 28 | 28 | else |
| 29 | 29 | { |
| 30 | | return input_port_read(machine, keynames[(offset>>3) & 0x07]) & (0x01<<(offset & 0x07)) ? 0xfe : 0xff; |
| 30 | return input_port_read(space->machine, keynames[(offset>>3) & 0x07]) & (0x01<<(offset & 0x07)) ? 0xfe : 0xff; |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| r3581 | r3582 | |
| 37 | 37 | { |
| 38 | 38 | double val = (((data >>6) & 1 ) + ((data >> 2) & 1) - 1) * 32000; |
| 39 | 39 | gal_latch_value = data; |
| 40 | | cassette_output(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ), val); |
| 40 | cassette_output(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" ), val); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
| r3581 | r3582 | |
| 49 | 49 | |
| 50 | 50 | INTERRUPT_GEN( galaxy_interrupt ) |
| 51 | 51 | { |
| 52 | | cpu_set_input_line(machine->cpu[0], 0, HOLD_LINE); |
| 52 | cpu_set_input_line(device, 0, HOLD_LINE); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | static IRQ_CALLBACK ( galaxy_irq_callback ) |
| r3581 | r3582 | |
| 72 | 72 | switch (size) |
| 73 | 73 | { |
| 74 | 74 | case GALAXY_SNAPSHOT_V1_SIZE: |
| 75 | | cpunum_set_reg(0, Z80_AF, data[0x00] | data[0x01]<<8); |
| 76 | | cpunum_set_reg(0, Z80_BC, data[0x04] | data[0x05]<<8); |
| 77 | | cpunum_set_reg(0, Z80_DE, data[0x08] | data[0x09]<<8); |
| 78 | | cpunum_set_reg(0, Z80_HL, data[0x0c] | data[0x0d]<<8); |
| 79 | | cpunum_set_reg(0, Z80_IX, data[0x10] | data[0x11]<<8); |
| 80 | | cpunum_set_reg(0, Z80_IY, data[0x14] | data[0x15]<<8); |
| 81 | | cpunum_set_reg(0, Z80_PC, data[0x18] | data[0x19]<<8); |
| 82 | | cpunum_set_reg(0, Z80_SP, data[0x1c] | data[0x1d]<<8); |
| 83 | | cpunum_set_reg(0, Z80_AF2, data[0x20] | data[0x21]<<8); |
| 84 | | cpunum_set_reg(0, Z80_BC2, data[0x24] | data[0x25]<<8); |
| 85 | | cpunum_set_reg(0, Z80_DE2, data[0x28] | data[0x29]<<8); |
| 86 | | cpunum_set_reg(0, Z80_HL2, data[0x2c] | data[0x2d]<<8); |
| 87 | | cpunum_set_reg(0, Z80_IFF1, data[0x30]); |
| 88 | | cpunum_set_reg(0, Z80_IFF2, data[0x34]); |
| 89 | | cpunum_set_reg(0, Z80_HALT, data[0x38]); |
| 90 | | cpunum_set_reg(0, Z80_IM, data[0x3c]); |
| 91 | | cpunum_set_reg(0, Z80_I, data[0x40]); |
| 92 | | cpunum_set_reg(0, Z80_R, (data[0x44]&0x7f) | (data[0x48]&0x80)); |
| 75 | cpu_set_reg(machine->cpu[0], Z80_AF, data[0x00] | data[0x01]<<8); |
| 76 | cpu_set_reg(machine->cpu[0], Z80_BC, data[0x04] | data[0x05]<<8); |
| 77 | cpu_set_reg(machine->cpu[0], Z80_DE, data[0x08] | data[0x09]<<8); |
| 78 | cpu_set_reg(machine->cpu[0], Z80_HL, data[0x0c] | data[0x0d]<<8); |
| 79 | cpu_set_reg(machine->cpu[0], Z80_IX, data[0x10] | data[0x11]<<8); |
| 80 | cpu_set_reg(machine->cpu[0], Z80_IY, data[0x14] | data[0x15]<<8); |
| 81 | cpu_set_reg(machine->cpu[0], Z80_PC, data[0x18] | data[0x19]<<8); |
| 82 | cpu_set_reg(machine->cpu[0], Z80_SP, data[0x1c] | data[0x1d]<<8); |
| 83 | cpu_set_reg(machine->cpu[0], Z80_AF2, data[0x20] | data[0x21]<<8); |
| 84 | cpu_set_reg(machine->cpu[0], Z80_BC2, data[0x24] | data[0x25]<<8); |
| 85 | cpu_set_reg(machine->cpu[0], Z80_DE2, data[0x28] | data[0x29]<<8); |
| 86 | cpu_set_reg(machine->cpu[0], Z80_HL2, data[0x2c] | data[0x2d]<<8); |
| 87 | cpu_set_reg(machine->cpu[0], Z80_IFF1, data[0x30]); |
| 88 | cpu_set_reg(machine->cpu[0], Z80_IFF2, data[0x34]); |
| 89 | cpu_set_reg(machine->cpu[0], Z80_HALT, data[0x38]); |
| 90 | cpu_set_reg(machine->cpu[0], Z80_IM, data[0x3c]); |
| 91 | cpu_set_reg(machine->cpu[0], Z80_I, data[0x40]); |
| 92 | cpu_set_reg(machine->cpu[0], Z80_R, (data[0x44]&0x7f) | (data[0x48]&0x80)); |
| 93 | 93 | |
| 94 | 94 | memcpy (mess_ram, data+0x084c, (mess_ram_size < 0x1800) ? mess_ram_size : 0x1800); |
| 95 | 95 | |
| 96 | 96 | break; |
| 97 | 97 | case GALAXY_SNAPSHOT_V2_SIZE: |
| 98 | | cpunum_set_reg(0, Z80_AF, data[0x00] | data[0x01]<<8); |
| 99 | | cpunum_set_reg(0, Z80_BC, data[0x02] | data[0x03]<<8); |
| 100 | | cpunum_set_reg(0, Z80_DE, data[0x04] | data[0x05]<<8); |
| 101 | | cpunum_set_reg(0, Z80_HL, data[0x06] | data[0x07]<<8); |
| 102 | | cpunum_set_reg(0, Z80_IX, data[0x08] | data[0x09]<<8); |
| 103 | | cpunum_set_reg(0, Z80_IY, data[0x0a] | data[0x0b]<<8); |
| 104 | | cpunum_set_reg(0, Z80_PC, data[0x0c] | data[0x0d]<<8); |
| 105 | | cpunum_set_reg(0, Z80_SP, data[0x0e] | data[0x0f]<<8); |
| 106 | | cpunum_set_reg(0, Z80_AF2, data[0x10] | data[0x11]<<8); |
| 107 | | cpunum_set_reg(0, Z80_BC2, data[0x12] | data[0x13]<<8); |
| 108 | | cpunum_set_reg(0, Z80_DE2, data[0x14] | data[0x15]<<8); |
| 109 | | cpunum_set_reg(0, Z80_HL2, data[0x16] | data[0x17]<<8); |
| 98 | cpu_set_reg(machine->cpu[0], Z80_AF, data[0x00] | data[0x01]<<8); |
| 99 | cpu_set_reg(machine->cpu[0], Z80_BC, data[0x02] | data[0x03]<<8); |
| 100 | cpu_set_reg(machine->cpu[0], Z80_DE, data[0x04] | data[0x05]<<8); |
| 101 | cpu_set_reg(machine->cpu[0], Z80_HL, data[0x06] | data[0x07]<<8); |
| 102 | cpu_set_reg(machine->cpu[0], Z80_IX, data[0x08] | data[0x09]<<8); |
| 103 | cpu_set_reg(machine->cpu[0], Z80_IY, data[0x0a] | data[0x0b]<<8); |
| 104 | cpu_set_reg(machine->cpu[0], Z80_PC, data[0x0c] | data[0x0d]<<8); |
| 105 | cpu_set_reg(machine->cpu[0], Z80_SP, data[0x0e] | data[0x0f]<<8); |
| 106 | cpu_set_reg(machine->cpu[0], Z80_AF2, data[0x10] | data[0x11]<<8); |
| 107 | cpu_set_reg(machine->cpu[0], Z80_BC2, data[0x12] | data[0x13]<<8); |
| 108 | cpu_set_reg(machine->cpu[0], Z80_DE2, data[0x14] | data[0x15]<<8); |
| 109 | cpu_set_reg(machine->cpu[0], Z80_HL2, data[0x16] | data[0x17]<<8); |
| 110 | 110 | |
| 111 | | cpunum_set_reg(0, Z80_IFF1, data[0x18]&0x01); |
| 112 | | cpunum_set_reg(0, Z80_IFF2, 0); |
| 111 | cpu_set_reg(machine->cpu[0], Z80_IFF1, data[0x18]&0x01); |
| 112 | cpu_set_reg(machine->cpu[0], Z80_IFF2, 0); |
| 113 | 113 | |
| 114 | | cpunum_set_reg(0, Z80_HALT, 0); |
| 114 | cpu_set_reg(machine->cpu[0], Z80_HALT, 0); |
| 115 | 115 | |
| 116 | | cpunum_set_reg(0, Z80_IM, (data[0x18]>>1)&0x03); |
| 116 | cpu_set_reg(machine->cpu[0], Z80_IM, (data[0x18]>>1)&0x03); |
| 117 | 117 | |
| 118 | | cpunum_set_reg(0, Z80_I, data[0x19]); |
| 119 | | cpunum_set_reg(0, Z80_R, data[0x1a]); |
| 118 | cpu_set_reg(machine->cpu[0], Z80_I, data[0x19]); |
| 119 | cpu_set_reg(machine->cpu[0], Z80_R, data[0x1a]); |
| 120 | 120 | |
| 121 | 121 | memcpy (mess_ram, data+0x0834, (mess_ram_size < 0x1800) ? mess_ram_size : 0x1800); |
| 122 | 122 | |
| r3581 | r3582 | |
| 155 | 155 | |
| 156 | 156 | DRIVER_INIT( galaxy ) |
| 157 | 157 | { |
| 158 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2800, 0x2800+mess_ram_size-1, 0, 0, SMH_BANK1); |
| 159 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2800, 0x2800+mess_ram_size-1, 0, 0, SMH_BANK1); |
| 160 | | memory_set_bankptr(1, mess_ram); |
| 158 | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 159 | memory_install_read8_handler(space, 0x2800, 0x2800+mess_ram_size-1, 0, 0, SMH_BANK1); |
| 160 | memory_install_write8_handler(space, 0x2800, 0x2800+mess_ram_size-1, 0, 0, SMH_BANK1); |
| 161 | memory_set_bankptr(machine,1, mess_ram); |
| 161 | 162 | |
| 162 | 163 | if (mess_ram_size < (6+48)*1024) |
| 163 | 164 | { |
| 164 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2800+mess_ram_size, 0xffff, 0, 0, SMH_NOP); |
| 165 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2800+mess_ram_size, 0xffff, 0, 0, SMH_NOP); |
| 165 | memory_install_read8_handler(space, 0x2800+mess_ram_size, 0xffff, 0, 0, SMH_NOP); |
| 166 | memory_install_write8_handler(space, 0x2800+mess_ram_size, 0xffff, 0, 0, SMH_NOP); |
| 166 | 167 | } |
| 167 | 168 | } |
| 168 | 169 | |
| r3581 | r3582 | |
| 172 | 173 | |
| 173 | 174 | MACHINE_RESET( galaxy ) |
| 174 | 175 | { |
| 176 | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 177 | |
| 175 | 178 | /* ROM 2 enable/disable */ |
| 176 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x1000, 0x1fff, 0, 0, input_port_read(machine, "ROM2") ? SMH_BANK10 : SMH_NOP); |
| 177 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x1000, 0x1fff, 0, 0, SMH_NOP); |
| 178 | | memory_set_bankptr(10, memory_region(machine, "main") + 0x1000); |
| 179 | memory_install_read8_handler(space, 0x1000, 0x1fff, 0, 0, input_port_read(machine, "ROM2") ? SMH_BANK10 : SMH_NOP); |
| 180 | memory_install_write8_handler(space, 0x1000, 0x1fff, 0, 0, SMH_NOP); |
| 181 | memory_set_bankptr(machine,10, memory_region(machine, "main") + 0x1000); |
| 179 | 182 | |
| 180 | | cpunum_set_irq_callback(0, galaxy_irq_callback); |
| 183 | cpu_set_irq_callback(machine->cpu[0], galaxy_irq_callback); |
| 181 | 184 | galaxy_interrupts_enabled = TRUE; |
| 182 | 185 | |
| 183 | 186 | gal_video_timer = timer_alloc(gal_video, NULL); |
| r3581 | r3582 | |
| 192 | 195 | MACHINE_RESET( galaxyp ) |
| 193 | 196 | { |
| 194 | 197 | UINT8 *ROM = memory_region(machine, "main"); |
| 198 | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 199 | |
| 200 | cpu_set_irq_callback(machine->cpu[0], galaxy_irq_callback); |
| 195 | 201 | |
| 196 | | cpunum_set_irq_callback(0, galaxy_irq_callback); |
| 197 | | |
| 198 | 202 | ROM[0x0037] = 0x29; |
| 199 | 203 | ROM[0x03f9] = 0xcd; |
| 200 | 204 | ROM[0x03fa] = 0x00; |
| 201 | 205 | ROM[0x03fb] = 0xe0; |
| 202 | 206 | |
| 203 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xefff, 0, 0, SMH_BANK11); |
| 204 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xefff, 0, 0, SMH_NOP); |
| 205 | | memory_set_bankptr(11, memory_region(machine, "main") + 0xe000); |
| 207 | memory_install_read8_handler(space, 0xe000, 0xefff, 0, 0, SMH_BANK11); |
| 208 | memory_install_write8_handler(space, 0xe000, 0xefff, 0, 0, SMH_NOP); |
| 209 | memory_set_bankptr(machine,11, memory_region(machine, "main") + 0xe000); |
| 206 | 210 | galaxy_interrupts_enabled = TRUE; |
| 207 | 211 | |
| 208 | 212 | gal_video_timer = timer_alloc(gal_video, NULL); |