src/mess/machine/zx.c
| r12595 | r12596 | |
| 6 | 6 | |
| 7 | 7 | ****************************************************************************/ |
| 8 | 8 | |
| 9 | | #include "emu.h" |
| 10 | | #include "cpu/z80/z80.h" |
| 11 | 9 | #include "includes/zx.h" |
| 12 | | #include "imagedev/cassette.h" |
| 13 | | #include "sound/speaker.h" |
| 14 | | #include "machine/ram.h" |
| 15 | 10 | |
| 16 | 11 | #define video_screen_get_refresh(screen) (((screen_config *)(screen)->inline_config)->refresh) |
| 17 | 12 | |
| r12595 | r12596 | |
| 41 | 36 | } |
| 42 | 37 | |
| 43 | 38 | /* I know this looks really pointless... but it has to be here */ |
| 44 | | READ8_HANDLER( zx_ram_r ) |
| 39 | READ8_MEMBER( zx_state::zx_ram_r ) |
| 45 | 40 | { |
| 46 | | UINT8 *RAM = space->machine().region("maincpu")->base(); |
| 41 | UINT8 *RAM = machine().region("maincpu")->base(); |
| 47 | 42 | return RAM[offset | 0xc000]; |
| 48 | 43 | } |
| 49 | 44 | |
| 50 | | DRIVER_INIT ( zx ) |
| 45 | DRIVER_INIT( zx ) |
| 51 | 46 | { |
| 52 | 47 | address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 53 | 48 | |
| r12595 | r12596 | |
| 56 | 51 | memory_set_bankptr(machine, "bank1", machine.region("maincpu")->base() + 0x4000); |
| 57 | 52 | } |
| 58 | 53 | |
| 59 | | DIRECT_UPDATE_HANDLER ( zx_setdirect ) |
| 54 | DIRECT_UPDATE_HANDLER( zx_setdirect ) |
| 60 | 55 | { |
| 61 | 56 | if (address & 0xc000) |
| 62 | 57 | zx_ula_r(machine, address, "maincpu", 0); |
| 63 | 58 | return address; |
| 64 | 59 | } |
| 65 | 60 | |
| 66 | | DIRECT_UPDATE_HANDLER ( pc8300_setdirect ) |
| 61 | DIRECT_UPDATE_HANDLER( pc8300_setdirect ) |
| 67 | 62 | { |
| 68 | 63 | if (address & 0xc000) |
| 69 | 64 | zx_ula_r(machine, address, "gfx1", 0); |
| 70 | 65 | return address; |
| 71 | 66 | } |
| 72 | 67 | |
| 73 | | DIRECT_UPDATE_HANDLER ( pow3000_setdirect ) |
| 68 | DIRECT_UPDATE_HANDLER( pow3000_setdirect ) |
| 74 | 69 | { |
| 75 | 70 | if (address & 0xc000) |
| 76 | 71 | zx_ula_r(machine, address, "gfx1", 1); |
| 77 | 72 | return address; |
| 78 | 73 | } |
| 79 | 74 | |
| 80 | | MACHINE_RESET ( zx80 ) |
| 75 | MACHINE_RESET( zx80 ) |
| 81 | 76 | { |
| 82 | 77 | zx_state *state = machine.driver_data<zx_state>(); |
| 83 | 78 | machine.device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(direct_update_delegate(FUNC(zx_setdirect), &machine)); |
| 84 | 79 | state->m_tape_bit = 0x80; |
| 85 | 80 | } |
| 86 | 81 | |
| 87 | | MACHINE_RESET ( pow3000 ) |
| 82 | MACHINE_RESET( pow3000 ) |
| 88 | 83 | { |
| 89 | 84 | zx_state *state = machine.driver_data<zx_state>(); |
| 90 | 85 | machine.device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(direct_update_delegate(FUNC(pow3000_setdirect), &machine)); |
| 91 | 86 | state->m_tape_bit = 0x80; |
| 92 | 87 | } |
| 93 | 88 | |
| 94 | | MACHINE_RESET ( pc8300 ) |
| 89 | MACHINE_RESET( pc8300 ) |
| 95 | 90 | { |
| 96 | 91 | zx_state *state = machine.driver_data<zx_state>(); |
| 97 | 92 | machine.device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(direct_update_delegate(FUNC(pc8300_setdirect), &machine)); |
| r12595 | r12596 | |
| 104 | 99 | state->m_tape_bit = 0x80; |
| 105 | 100 | } |
| 106 | 101 | |
| 107 | | READ8_HANDLER ( zx80_io_r ) |
| 102 | READ8_MEMBER( zx_state::zx80_io_r ) |
| 108 | 103 | { |
| 109 | | zx_state *state = space->machine().driver_data<zx_state>(); |
| 110 | 104 | /* port FE = read keyboard, NTSC/PAL diode, and cass bit; turn off HSYNC-generator/cass-out |
| 111 | | The upper 8 bits are used to select a keyboard scan line |
| 105 | The upper 8 bits are used to select a keyboard scan line */ |
| 112 | 106 | |
| 113 | | The diode doesn't make any visual difference, but it's in the schematic, and used by the code. */ |
| 114 | | |
| 115 | 107 | UINT8 data = 0xff; |
| 116 | 108 | UINT8 offs = offset & 0xff; |
| 117 | 109 | |
| 118 | 110 | if (offs == 0xfe) |
| 119 | 111 | { |
| 120 | 112 | if ((offset & 0x0100) == 0) |
| 121 | | data &= input_port_read(space->machine(), "ROW0"); |
| 113 | data &= input_port_read(machine(), "ROW0"); |
| 122 | 114 | if ((offset & 0x0200) == 0) |
| 123 | | data &= input_port_read(space->machine(), "ROW1"); |
| 115 | data &= input_port_read(machine(), "ROW1"); |
| 124 | 116 | if ((offset & 0x0400) == 0) |
| 125 | | data &= input_port_read(space->machine(), "ROW2"); |
| 117 | data &= input_port_read(machine(), "ROW2"); |
| 126 | 118 | if ((offset & 0x0800) == 0) |
| 127 | | data &= input_port_read(space->machine(), "ROW3"); |
| 119 | data &= input_port_read(machine(), "ROW3"); |
| 128 | 120 | if ((offset & 0x1000) == 0) |
| 129 | | data &= input_port_read(space->machine(), "ROW4"); |
| 121 | data &= input_port_read(machine(), "ROW4"); |
| 130 | 122 | if ((offset & 0x2000) == 0) |
| 131 | | data &= input_port_read(space->machine(), "ROW5"); |
| 123 | data &= input_port_read(machine(), "ROW5"); |
| 132 | 124 | if ((offset & 0x4000) == 0) |
| 133 | | data &= input_port_read(space->machine(), "ROW6"); |
| 125 | data &= input_port_read(machine(), "ROW6"); |
| 134 | 126 | if ((offset & 0x8000) == 0) |
| 135 | | data &= input_port_read(space->machine(), "ROW7"); |
| 127 | data &= input_port_read(machine(), "ROW7"); |
| 136 | 128 | |
| 137 | | if (!input_port_read(space->machine(), "CONFIG")) |
| 129 | if (!input_port_read(machine(), "CONFIG")) |
| 138 | 130 | data &= ~0x40; |
| 139 | 131 | |
| 140 | | space->machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0); |
| 132 | machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0); |
| 141 | 133 | |
| 142 | | if (state->m_ula_irq_active) |
| 134 | if (m_ula_irq_active) |
| 143 | 135 | { |
| 144 | | zx_ula_bkgnd(space->machine(), 0); |
| 145 | | state->m_ula_irq_active = 0; |
| 146 | | |
| 147 | | // LOG_ZX81_IOR("ULA IRQs off"); |
| 136 | zx_ula_bkgnd(0); |
| 137 | m_ula_irq_active = 0; |
| 148 | 138 | } |
| 149 | 139 | // else |
| 150 | 140 | // { |
| 151 | | if (((space->machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && state->m_tape_bit) |
| 141 | if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit) |
| 152 | 142 | { |
| 153 | | state->m_tape_bit = 0x00; |
| 154 | | space->machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); |
| 143 | m_tape_bit = 0x00; |
| 144 | machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); |
| 155 | 145 | } |
| 156 | 146 | |
| 157 | | data &= ~state->m_tape_bit; |
| 158 | | |
| 159 | | // LOG_ZX81_IOR("Tape"); |
| 147 | data &= ~m_tape_bit; |
| 160 | 148 | // } |
| 161 | | if (state->m_ula_frame_vsync == 3) |
| 149 | if (m_ula_frame_vsync == 3) |
| 162 | 150 | { |
| 163 | | state->m_ula_frame_vsync = 2; |
| 164 | | // LOG_ZX81_VSYNC; |
| 151 | m_ula_frame_vsync = 2; |
| 165 | 152 | } |
| 166 | 153 | } |
| 167 | | else |
| 168 | | LOG_ZX81_IOR("Unmapped port"); |
| 169 | 154 | |
| 170 | 155 | return data; |
| 171 | 156 | } |
| 172 | 157 | |
| 173 | | READ8_HANDLER ( zx81_io_r ) |
| 158 | READ8_MEMBER( zx_state::zx81_io_r ) |
| 174 | 159 | { |
| 175 | | zx_state *state = space->machine().driver_data<zx_state>(); |
| 176 | 160 | /* port FB = read printer status, not emulated |
| 177 | 161 | FE = read keyboard, NTSC/PAL diode, and cass bit; turn off HSYNC-generator/cass-out |
| 178 | 162 | The upper 8 bits are used to select a keyboard scan line */ |
| r12595 | r12596 | |
| 183 | 167 | if (offs == 0xfe) |
| 184 | 168 | { |
| 185 | 169 | if ((offset & 0x0100) == 0) |
| 186 | | data &= input_port_read(space->machine(), "ROW0"); |
| 170 | data &= input_port_read(machine(), "ROW0"); |
| 187 | 171 | if ((offset & 0x0200) == 0) |
| 188 | | data &= input_port_read(space->machine(), "ROW1"); |
| 172 | data &= input_port_read(machine(), "ROW1"); |
| 189 | 173 | if ((offset & 0x0400) == 0) |
| 190 | | data &= input_port_read(space->machine(), "ROW2"); |
| 174 | data &= input_port_read(machine(), "ROW2"); |
| 191 | 175 | if ((offset & 0x0800) == 0) |
| 192 | | data &= input_port_read(space->machine(), "ROW3"); |
| 176 | data &= input_port_read(machine(), "ROW3"); |
| 193 | 177 | if ((offset & 0x1000) == 0) |
| 194 | | data &= input_port_read(space->machine(), "ROW4"); |
| 178 | data &= input_port_read(machine(), "ROW4"); |
| 195 | 179 | if ((offset & 0x2000) == 0) |
| 196 | | data &= input_port_read(space->machine(), "ROW5"); |
| 180 | data &= input_port_read(machine(), "ROW5"); |
| 197 | 181 | if ((offset & 0x4000) == 0) |
| 198 | | data &= input_port_read(space->machine(), "ROW6"); |
| 182 | data &= input_port_read(machine(), "ROW6"); |
| 199 | 183 | if ((offset & 0x8000) == 0) |
| 200 | | data &= input_port_read(space->machine(), "ROW7"); |
| 184 | data &= input_port_read(machine(), "ROW7"); |
| 201 | 185 | |
| 202 | | if (!input_port_read(space->machine(), "CONFIG")) |
| 186 | if (!input_port_read(machine(), "CONFIG")) |
| 203 | 187 | data &= ~0x40; |
| 204 | 188 | |
| 205 | | space->machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0); |
| 189 | machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0); |
| 206 | 190 | |
| 207 | | if (state->m_ula_irq_active) |
| 191 | if (m_ula_irq_active) |
| 208 | 192 | { |
| 209 | | zx_ula_bkgnd(space->machine(), 0); |
| 210 | | state->m_ula_irq_active = 0; |
| 211 | | |
| 212 | | // LOG_ZX81_IOR("ULA IRQs off"); |
| 193 | zx_ula_bkgnd(0); |
| 194 | m_ula_irq_active = 0; |
| 213 | 195 | } |
| 214 | 196 | else |
| 215 | 197 | { |
| 216 | | if (((space->machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && state->m_tape_bit) |
| 198 | if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit) |
| 217 | 199 | { |
| 218 | | state->m_tape_bit = 0x00; |
| 219 | | space->machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); |
| 200 | m_tape_bit = 0x00; |
| 201 | machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); |
| 220 | 202 | } |
| 221 | 203 | |
| 222 | | data &= ~state->m_tape_bit; |
| 223 | | |
| 224 | | // LOG_ZX81_IOR("Tape"); |
| 204 | data &= ~m_tape_bit; |
| 225 | 205 | } |
| 226 | | if (state->m_ula_frame_vsync == 3) |
| 206 | if (m_ula_frame_vsync == 3) |
| 227 | 207 | { |
| 228 | | state->m_ula_frame_vsync = 2; |
| 229 | | // LOG_ZX81_VSYNC; |
| 208 | m_ula_frame_vsync = 2; |
| 230 | 209 | } |
| 231 | 210 | } |
| 232 | | else |
| 233 | | LOG_ZX81_IOR("Unmapped port"); |
| 234 | 211 | |
| 235 | 212 | return data; |
| 236 | 213 | } |
| 237 | 214 | |
| 238 | | READ8_HANDLER ( pc8300_io_r ) |
| 215 | READ8_MEMBER( zx_state::pc8300_io_r ) |
| 239 | 216 | { |
| 240 | | zx_state *state = space->machine().driver_data<zx_state>(); |
| 241 | 217 | /* port F5 = sound |
| 242 | 218 | F6 = unknown |
| 243 | 219 | FB = read printer status, not emulated |
| r12595 | r12596 | |
| 247 | 223 | |
| 248 | 224 | UINT8 data = 0xff; |
| 249 | 225 | UINT8 offs = offset & 0xff; |
| 250 | | device_t *speaker = space->machine().device(SPEAKER_TAG); |
| 226 | device_t *speaker = machine().device(SPEAKER_TAG); |
| 251 | 227 | |
| 252 | 228 | if (offs == 0xf5) |
| 253 | 229 | { |
| 254 | | state->m_speaker_state ^= 1; |
| 255 | | speaker_level_w(speaker, state->m_speaker_state); |
| 230 | m_speaker_state ^= 1; |
| 231 | speaker_level_w(speaker, m_speaker_state); |
| 256 | 232 | } |
| 257 | 233 | else |
| 258 | 234 | if (offs == 0xfe) |
| 259 | 235 | { |
| 260 | 236 | if ((offset & 0x0100) == 0) |
| 261 | | data &= input_port_read(space->machine(), "ROW0"); |
| 237 | data &= input_port_read(machine(), "ROW0"); |
| 262 | 238 | if ((offset & 0x0200) == 0) |
| 263 | | data &= input_port_read(space->machine(), "ROW1"); |
| 239 | data &= input_port_read(machine(), "ROW1"); |
| 264 | 240 | if ((offset & 0x0400) == 0) |
| 265 | | data &= input_port_read(space->machine(), "ROW2"); |
| 241 | data &= input_port_read(machine(), "ROW2"); |
| 266 | 242 | if ((offset & 0x0800) == 0) |
| 267 | | data &= input_port_read(space->machine(), "ROW3"); |
| 243 | data &= input_port_read(machine(), "ROW3"); |
| 268 | 244 | if ((offset & 0x1000) == 0) |
| 269 | | data &= input_port_read(space->machine(), "ROW4"); |
| 245 | data &= input_port_read(machine(), "ROW4"); |
| 270 | 246 | if ((offset & 0x2000) == 0) |
| 271 | | data &= input_port_read(space->machine(), "ROW5"); |
| 247 | data &= input_port_read(machine(), "ROW5"); |
| 272 | 248 | if ((offset & 0x4000) == 0) |
| 273 | | data &= input_port_read(space->machine(), "ROW6"); |
| 249 | data &= input_port_read(machine(), "ROW6"); |
| 274 | 250 | if ((offset & 0x8000) == 0) |
| 275 | | data &= input_port_read(space->machine(), "ROW7"); |
| 251 | data &= input_port_read(machine(), "ROW7"); |
| 276 | 252 | |
| 277 | | space->machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0); |
| 253 | machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0); |
| 278 | 254 | |
| 279 | | if (state->m_ula_irq_active) |
| 255 | if (m_ula_irq_active) |
| 280 | 256 | { |
| 281 | | zx_ula_bkgnd(space->machine(), 0); |
| 282 | | state->m_ula_irq_active = 0; |
| 283 | | |
| 284 | | // LOG_ZX81_IOR("ULA IRQs off"); |
| 257 | zx_ula_bkgnd(0); |
| 258 | m_ula_irq_active = 0; |
| 285 | 259 | } |
| 286 | 260 | else |
| 287 | 261 | { |
| 288 | | if (((space->machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && state->m_tape_bit) |
| 262 | if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit) |
| 289 | 263 | { |
| 290 | | state->m_tape_bit = 0x00; |
| 291 | | space->machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); |
| 264 | m_tape_bit = 0x00; |
| 265 | machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); |
| 292 | 266 | } |
| 293 | 267 | |
| 294 | | data &= ~state->m_tape_bit; |
| 295 | | |
| 296 | | // LOG_ZX81_IOR("Tape"); |
| 268 | data &= ~m_tape_bit; |
| 297 | 269 | } |
| 298 | | if (state->m_ula_frame_vsync == 3) |
| 270 | if (m_ula_frame_vsync == 3) |
| 299 | 271 | { |
| 300 | | state->m_ula_frame_vsync = 2; |
| 301 | | // LOG_ZX81_VSYNC; |
| 272 | m_ula_frame_vsync = 2; |
| 302 | 273 | } |
| 303 | 274 | } |
| 304 | | else |
| 305 | | LOG_ZX81_IOR("Unmapped port"); |
| 306 | 275 | |
| 307 | 276 | return data; |
| 308 | 277 | } |
| 309 | 278 | |
| 310 | | READ8_HANDLER ( pow3000_io_r ) |
| 279 | READ8_MEMBER( zx_state::pow3000_io_r ) |
| 311 | 280 | { |
| 312 | | zx_state *state = space->machine().driver_data<zx_state>(); |
| 313 | 281 | /* port 7E = read NTSC/PAL diode |
| 314 | 282 | F5 = sound |
| 315 | 283 | F6 = unknown |
| r12595 | r12596 | |
| 319 | 287 | |
| 320 | 288 | UINT8 data = 0xff; |
| 321 | 289 | UINT8 offs = offset & 0xff; |
| 322 | | device_t *speaker = space->machine().device(SPEAKER_TAG); |
| 290 | device_t *speaker = machine().device(SPEAKER_TAG); |
| 323 | 291 | |
| 324 | 292 | if (offs == 0x7e) |
| 325 | 293 | { |
| 326 | | data = (input_port_read(space->machine(), "CONFIG")); |
| 294 | data = (input_port_read(machine(), "CONFIG")); |
| 327 | 295 | } |
| 328 | 296 | else |
| 329 | 297 | if (offs == 0xf5) |
| 330 | 298 | { |
| 331 | | state->m_speaker_state ^= 1; |
| 332 | | speaker_level_w(speaker, state->m_speaker_state); |
| 299 | m_speaker_state ^= 1; |
| 300 | speaker_level_w(speaker, m_speaker_state); |
| 333 | 301 | } |
| 334 | 302 | else |
| 335 | 303 | if (offs == 0xfe) |
| 336 | 304 | { |
| 337 | 305 | if ((offset & 0x0100) == 0) |
| 338 | | data &= input_port_read(space->machine(), "ROW0"); |
| 306 | data &= input_port_read(machine(), "ROW0"); |
| 339 | 307 | if ((offset & 0x0200) == 0) |
| 340 | | data &= input_port_read(space->machine(), "ROW1"); |
| 308 | data &= input_port_read(machine(), "ROW1"); |
| 341 | 309 | if ((offset & 0x0400) == 0) |
| 342 | | data &= input_port_read(space->machine(), "ROW2"); |
| 310 | data &= input_port_read(machine(), "ROW2"); |
| 343 | 311 | if ((offset & 0x0800) == 0) |
| 344 | | data &= input_port_read(space->machine(), "ROW3"); |
| 312 | data &= input_port_read(machine(), "ROW3"); |
| 345 | 313 | if ((offset & 0x1000) == 0) |
| 346 | | data &= input_port_read(space->machine(), "ROW4"); |
| 314 | data &= input_port_read(machine(), "ROW4"); |
| 347 | 315 | if ((offset & 0x2000) == 0) |
| 348 | | data &= input_port_read(space->machine(), "ROW5"); |
| 316 | data &= input_port_read(machine(), "ROW5"); |
| 349 | 317 | if ((offset & 0x4000) == 0) |
| 350 | | data &= input_port_read(space->machine(), "ROW6"); |
| 318 | data &= input_port_read(machine(), "ROW6"); |
| 351 | 319 | if ((offset & 0x8000) == 0) |
| 352 | | data &= input_port_read(space->machine(), "ROW7"); |
| 320 | data &= input_port_read(machine(), "ROW7"); |
| 353 | 321 | |
| 354 | | space->machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0); |
| 322 | machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0); |
| 355 | 323 | |
| 356 | | if (state->m_ula_irq_active) |
| 324 | if (m_ula_irq_active) |
| 357 | 325 | { |
| 358 | | zx_ula_bkgnd(space->machine(), 0); |
| 359 | | state->m_ula_irq_active = 0; |
| 360 | | LOG_ZX81_IOR("ULA IRQs off"); |
| 326 | zx_ula_bkgnd(0); |
| 327 | m_ula_irq_active = 0; |
| 361 | 328 | } |
| 362 | 329 | else |
| 363 | 330 | { |
| 364 | | if (((space->machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && state->m_tape_bit) |
| 331 | if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit) |
| 365 | 332 | { |
| 366 | | state->m_tape_bit = 0x00; |
| 367 | | space->machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); |
| 333 | m_tape_bit = 0x00; |
| 334 | machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); |
| 368 | 335 | } |
| 369 | 336 | |
| 370 | | data &= ~state->m_tape_bit; |
| 371 | | |
| 372 | | // LOG_ZX81_IOR("Tape"); |
| 337 | data &= ~m_tape_bit; |
| 373 | 338 | } |
| 374 | | if (state->m_ula_frame_vsync == 3) |
| 339 | if (m_ula_frame_vsync == 3) |
| 375 | 340 | { |
| 376 | | state->m_ula_frame_vsync = 2; |
| 377 | | // LOG_ZX81_VSYNC; |
| 341 | m_ula_frame_vsync = 2; |
| 378 | 342 | } |
| 379 | 343 | } |
| 380 | | else |
| 381 | | LOG_ZX81_IOR("Unknown port"); |
| 382 | 344 | |
| 383 | 345 | return data; |
| 384 | 346 | } |
| 385 | 347 | |
| 386 | | WRITE8_HANDLER( zx80_io_w ) |
| 348 | WRITE8_MEMBER( zx_state::zx80_io_w ) |
| 387 | 349 | { |
| 388 | 350 | /* port FF = write HSYNC and cass data */ |
| 389 | 351 | |
| 390 | 352 | UINT8 offs = offset & 0xff; |
| 391 | 353 | |
| 392 | 354 | if (offs == 0xff) |
| 393 | | space->machine().device<cassette_image_device>(CASSETTE_TAG)->output(-1.0); |
| 394 | | else |
| 395 | | LOG_ZX81_IOR("Unmapped port"); |
| 355 | machine().device<cassette_image_device>(CASSETTE_TAG)->output(-1.0); |
| 396 | 356 | } |
| 397 | 357 | |
| 398 | | WRITE8_HANDLER ( zx81_io_w ) |
| 358 | WRITE8_MEMBER( zx_state::zx81_io_w ) |
| 399 | 359 | { |
| 400 | | zx_state *state = space->machine().driver_data<zx_state>(); |
| 360 | address_space *mem = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 401 | 361 | /* port F5 = unknown, pc8300/pow3000/lambda only |
| 402 | 362 | F6 = unknown, pc8300/pow3000/lambda only |
| 403 | 363 | FB = write data to printer, not emulated |
| r12595 | r12596 | |
| 405 | 365 | FE = turn on NMI generator |
| 406 | 366 | FF = write HSYNC and cass data */ |
| 407 | 367 | |
| 408 | | screen_device *screen = space->machine().first_screen(); |
| 368 | screen_device *screen = machine().first_screen(); |
| 409 | 369 | int height = screen->height(); |
| 410 | 370 | UINT8 offs = offset & 0xff; |
| 411 | 371 | |
| 412 | 372 | if (offs == 0xfd) |
| 413 | 373 | { |
| 414 | | state->m_ula_nmi->reset(); |
| 415 | | |
| 416 | | LOG_ZX81_IOW("ULA NMIs off"); |
| 374 | m_ula_nmi->reset(); |
| 417 | 375 | } |
| 418 | 376 | else |
| 419 | 377 | if (offs == 0xfe) |
| 420 | 378 | { |
| 421 | | state->m_ula_nmi->adjust(attotime::zero, 0, space->machine().device<cpu_device>("maincpu")->cycles_to_attotime(207)); |
| 379 | m_ula_nmi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(207)); |
| 422 | 380 | |
| 423 | | LOG_ZX81_IOW("ULA NMIs on"); |
| 424 | | |
| 425 | 381 | /* remove the IRQ */ |
| 426 | | state->m_ula_irq_active = 0; |
| 382 | m_ula_irq_active = 0; |
| 427 | 383 | } |
| 428 | 384 | else |
| 429 | 385 | if (offs == 0xff) |
| 430 | 386 | { |
| 431 | | space->machine().device<cassette_image_device>(CASSETTE_TAG)->output(-1.0); |
| 432 | | zx_ula_bkgnd(space->machine(), 1); |
| 433 | | if (state->m_ula_frame_vsync == 2) |
| 387 | machine().device<cassette_image_device>(CASSETTE_TAG)->output(-1.0); |
| 388 | zx_ula_bkgnd(1); |
| 389 | if (m_ula_frame_vsync == 2) |
| 434 | 390 | { |
| 435 | | device_spin_until_time(&space->device(),space->machine().primary_screen->time_until_pos(height - 1, 0)); |
| 436 | | state->m_ula_scanline_count = height - 1; |
| 437 | | logerror ("S: %d B: %d\n", space->machine().primary_screen->vpos(), space->machine().primary_screen->hpos()); |
| 391 | device_spin_until_time(&mem->device(),machine().primary_screen->time_until_pos(height - 1, 0)); |
| 392 | m_ula_scanline_count = height - 1; |
| 393 | logerror ("S: %d B: %d\n", machine().primary_screen->vpos(), machine().primary_screen->hpos()); |
| 438 | 394 | } |
| 439 | | |
| 440 | | LOG_ZX81_IOW("ULA IRQs on"); |
| 441 | 395 | } |
| 442 | | else |
| 443 | | LOG_ZX81_IOR("Unmapped port"); |
| 444 | 396 | } |
| 445 | 397 | |
src/mess/drivers/zx.c
| r12595 | r12596 | |
| 17 | 17 | - Applied NTSC timings to pc8300 only, all others depend on the diode. |
| 18 | 18 | - Many keyboard fixes, and descriptions added to keys. |
| 19 | 19 | - Fixed .O files from causing an access violation. |
| 20 | | - Enabled cassette saving (wav only). |
| 20 | - Enabled cassette saving. |
| 21 | 21 | - Many general fixes to pow3000/lambda. |
| 22 | 22 | - Added sound to pc8300/pow3000/lambda. |
| 23 | 23 | |
| r12595 | r12596 | |
| 25 | 25 | - Added rom mirror, this fixes ringo470 |
| 26 | 26 | - Added back the F4 character display |
| 27 | 27 | |
| 28 | 14/08/2011 (Robbbert) |
| 29 | - Modernised. |
| 30 | |
| 28 | 31 | To do / problems: |
| 29 | 32 | - Some memory areas are not mirrored as they should. |
| 30 | 33 | - Video hardware is not fully emulated, so it does not support pseudo hi-res and hi-res modes. |
| r12595 | r12596 | |
| 32 | 35 | - lambda/pow3000 32k memory pack is unemulated, because where is the upper 16k mirror going to be? |
| 33 | 36 | - h4th and tree4th need their address maps worked out (eg, the stack is set to FB80) |
| 34 | 37 | - lambda/pow3000 joystick, connected in parallel with the 4,R,F,7,U keys, but the directions are unknown. |
| 35 | | - Currently, cassettes will be saved in .wav format, even if you choose something else. |
| 36 | 38 | - Many games don't work. |
| 37 | 39 | |
| 38 | 40 | |
| 39 | 41 | ****************************************************************************/ |
| 42 | #define ADDRESS_MAP_MODERN |
| 40 | 43 | |
| 41 | | #include "emu.h" |
| 42 | | #include "cpu/z80/z80.h" |
| 43 | | #include "sound/speaker.h" |
| 44 | | #include "sound/wave.h" |
| 45 | 44 | #include "includes/zx.h" |
| 46 | | #include "imagedev/cassette.h" |
| 47 | | #include "formats/zx81_p.h" |
| 48 | | #include "machine/ram.h" |
| 49 | 45 | |
| 50 | 46 | /* Memory Maps */ |
| 51 | 47 | |
| 52 | | static ADDRESS_MAP_START( zx80_map, AS_PROGRAM, 8 ) |
| 48 | static ADDRESS_MAP_START( zx80_map, AS_PROGRAM, 8, zx_state ) |
| 53 | 49 | AM_RANGE(0x0000, 0x1fff) AM_ROM AM_MIRROR(0x2000) |
| 54 | 50 | AM_RANGE(0xc000, 0xffff) AM_RAM_READ(zx_ram_r) |
| 55 | 51 | ADDRESS_MAP_END |
| 56 | 52 | |
| 57 | | static ADDRESS_MAP_START( zx80_io_map, AS_IO, 8 ) |
| 53 | static ADDRESS_MAP_START( zx80_io_map, AS_IO, 8, zx_state ) |
| 58 | 54 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(zx80_io_r, zx80_io_w) |
| 59 | 55 | ADDRESS_MAP_END |
| 60 | 56 | |
| 61 | | static ADDRESS_MAP_START( zx81_io_map, AS_IO, 8 ) |
| 57 | static ADDRESS_MAP_START( zx81_io_map, AS_IO, 8, zx_state ) |
| 62 | 58 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(zx81_io_r, zx81_io_w) |
| 63 | 59 | ADDRESS_MAP_END |
| 64 | 60 | |
| 65 | | static ADDRESS_MAP_START( pc8300_io_map, AS_IO, 8 ) |
| 61 | static ADDRESS_MAP_START( pc8300_io_map, AS_IO, 8, zx_state ) |
| 66 | 62 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(pc8300_io_r, zx81_io_w) |
| 67 | 63 | ADDRESS_MAP_END |
| 68 | 64 | |
| 69 | | static ADDRESS_MAP_START( pow3000_io_map, AS_IO, 8 ) |
| 65 | static ADDRESS_MAP_START( pow3000_io_map, AS_IO, 8, zx_state ) |
| 70 | 66 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(pow3000_io_r, zx81_io_w) |
| 71 | 67 | ADDRESS_MAP_END |
| 72 | 68 | |
| r12595 | r12596 | |
| 565 | 561 | COMP( 1981, zx81, 0, 0, zx81, zx81, zx, "Sinclair Research Ltd", "ZX-81", 0 ) |
| 566 | 562 | COMP( 1982, ts1000, zx81, 0, ts1000, zx81, zx, "Timex Sinclair", "Timex Sinclair 1000", 0 ) |
| 567 | 563 | COMP( 1983, ts1500, zx81, 0, ts1500, zx81, zx, "Timex Sinclair", "Timex Sinclair 1500", 0 ) |
| 568 | | COMP( 1983, tk85, zx81, 0, ts1000, zx81, zx, "Microdigital", "TK85", 0 ) |
| 564 | COMP( 1983, tk85, zx81, 0, ts1000, zx81, zx, "Microdigital", "TK85", 0 ) |
| 569 | 565 | COMP( 1983, ringo470, zx81, 0, ts1000, zx81, zx, "Ritas do Brasil Ltda", "Ringo 470", 0 ) |
| 570 | 566 | COMP( 1984, pc8300, zx81, 0, pc8300, pc8300, zx, "Your Computer", "PC8300", 0 ) |
| 571 | 567 | COMP( 1983, pow3000, zx81, 0, pow3000, pow3000, zx, "Creon Enterprises", "Power 3000", 0 ) |
| 572 | 568 | COMP( 1982, lambda, zx81, 0, pow3000, pow3000, zx, "Lambda Electronics Ltd", "Lambda 8300", 0 ) |
| 573 | | COMP( 1997, zx97, zx81, 0, zx81, zx81, zx, "Wilf Rigter", "ZX97", GAME_NOT_WORKING | GAME_UNOFFICIAL ) |
| 569 | COMP( 1997, zx97, zx81, 0, zx81, zx81, zx, "Wilf Rigter", "ZX97", GAME_NOT_WORKING | GAME_UNOFFICIAL ) |