src/mess/drivers/iq151.c
| r12273 | r12274 | |
| 29 | 29 | - Line 32 does not scroll, should it show? |
| 30 | 30 | (could be reserved for a status line in a terminal mode) |
| 31 | 31 | |
| 32 | | - Sort out the issue with memory location 6. If it isn't zero the computer hangs. |
| 33 | | But if it is always forced to zero, the keys repeat way too fast. Timer |
| 34 | | currently set to 3Hz for reasonable repeat, but it is far from perfect. |
| 35 | | |
| 36 | 32 | - Note that the system checks for 3E at C000, if exist, jump to C000; |
| 37 | 33 | otherwise then checks for non-FF at C800, if so, jumps to C800. Could be |
| 38 | 34 | extra roms or some sort of boot device. |
| r12273 | r12274 | |
| 45 | 41 | |
| 46 | 42 | #include "emu.h" |
| 47 | 43 | #include "cpu/i8085/i8085.h" |
| 44 | #include "machine/pic8259.h" |
| 48 | 45 | #include "sound/speaker.h" |
| 49 | 46 | #include "imagedev/cartslot.h" |
| 50 | 47 | |
| r12273 | r12274 | |
| 59 | 56 | public: |
| 60 | 57 | iq151_state(const machine_config &mconfig, device_type type, const char *tag) |
| 61 | 58 | : driver_device(mconfig, type, tag), |
| 62 | | m_speaker(*this, SPEAKER_TAG) |
| 59 | m_maincpu(*this, "maincpu"), |
| 60 | m_pic(*this, "pic8259"), |
| 61 | m_speaker(*this, SPEAKER_TAG) |
| 63 | 62 | { } |
| 64 | 63 | |
| 64 | required_device<cpu_device> m_maincpu; |
| 65 | required_device<device_t> m_pic; |
| 65 | 66 | required_device<device_t> m_speaker; |
| 67 | |
| 66 | 68 | DECLARE_READ8_MEMBER(keyboard_r); |
| 67 | 69 | DECLARE_WRITE8_MEMBER(speaker_w); |
| 68 | | UINT8 *m_p_ram; |
| 70 | DECLARE_WRITE_LINE_MEMBER(pic_set_int_line); |
| 69 | 71 | UINT8 *m_p_videoram; |
| 72 | UINT8 m_vblank_irq_state; |
| 70 | 73 | const UINT8 *m_p_chargen; |
| 71 | | UINT8 m_framecnt; |
| 72 | 74 | UINT8 m_width; |
| 73 | 75 | virtual void machine_reset(); |
| 74 | 76 | virtual void video_start(); |
| 75 | 77 | virtual bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect); |
| 76 | 78 | |
| 77 | | |
| 78 | 79 | // AMOS |
| 79 | 80 | UINT8 *m_amos_banks[4]; |
| 80 | 81 | DECLARE_WRITE8_MEMBER(amos_bankswitch_w); |
| r12273 | r12274 | |
| 132 | 133 | AM_RANGE( 0x84, 0x85 ) AM_READ(keyboard_r) |
| 133 | 134 | AM_RANGE( 0x86, 0x86 ) AM_READ_PORT("X8") |
| 134 | 135 | AM_RANGE( 0x87, 0x87 ) AM_WRITE(speaker_w) |
| 136 | AM_RANGE( 0x88, 0x89 ) AM_DEVREADWRITE_LEGACY("pic8259", pic8259_r, pic8259_w ) |
| 135 | 137 | AM_RANGE( 0xfe, 0xfe ) AM_READ_PORT("FE") |
| 136 | 138 | ADDRESS_MAP_END |
| 137 | 139 | |
| r12273 | r12274 | |
| 236 | 238 | memory_set_bank(machine, "boot", 0); |
| 237 | 239 | } |
| 238 | 240 | |
| 239 | | static TIMER_DEVICE_CALLBACK( iq151a ) |
| 241 | WRITE_LINE_MEMBER( iq151_state::pic_set_int_line ) |
| 240 | 242 | { |
| 241 | | iq151_state *state = timer.machine().driver_data<iq151_state>(); |
| 242 | | state->m_p_ram[6]=0; // fixme |
| 243 | device_set_input_line(m_maincpu, 0, state ? HOLD_LINE : CLEAR_LINE); |
| 243 | 244 | } |
| 244 | 245 | |
| 246 | static INTERRUPT_GEN( iq151_vblank_interrupt ) |
| 247 | { |
| 248 | iq151_state *state = device->machine().driver_data<iq151_state>(); |
| 249 | |
| 250 | pic8259_ir6_w(state->m_pic, state->m_vblank_irq_state & 1); |
| 251 | state->m_vblank_irq_state ^= 1; |
| 252 | } |
| 253 | |
| 254 | static IRQ_CALLBACK(iq151_irq_callback) |
| 255 | { |
| 256 | iq151_state *state = device->machine().driver_data<iq151_state>(); |
| 257 | |
| 258 | return pic8259_acknowledge(state->m_pic); |
| 259 | } |
| 260 | |
| 245 | 261 | DRIVER_INIT( iq151 ) |
| 246 | 262 | { |
| 247 | 263 | iq151_state *state = machine.driver_data<iq151_state>(); |
| r12273 | r12274 | |
| 250 | 266 | memory_configure_bank(machine, "boot", 0, 2, &RAM[0x0000], 0xf800); |
| 251 | 267 | |
| 252 | 268 | memset(state->m_amos_banks, 0, sizeof(state->m_amos_banks)); |
| 269 | |
| 270 | device_set_irq_callback(state->m_maincpu, iq151_irq_callback); |
| 253 | 271 | } |
| 254 | 272 | |
| 255 | 273 | MACHINE_RESET_MEMBER( iq151_state ) |
| r12273 | r12274 | |
| 258 | 276 | machine().primary_screen->set_visible_area(0, (m_width == 32 ? 32*8 : 64*6)-1, 0, 32*8-1); |
| 259 | 277 | memory_set_bank(machine(), "boot", 1); |
| 260 | 278 | machine().scheduler().timer_set(attotime::from_usec(5), FUNC(iq151_boot)); |
| 279 | |
| 280 | m_vblank_irq_state = 0; |
| 261 | 281 | } |
| 262 | 282 | |
| 263 | 283 | VIDEO_START_MEMBER( iq151_state ) |
| 264 | 284 | { |
| 265 | 285 | m_p_chargen = machine().region("chargen")->base(); |
| 266 | | m_p_ram = machine().region("maincpu")->base(); |
| 267 | 286 | m_width = 32; |
| 268 | 287 | } |
| 269 | 288 | |
| r12273 | r12274 | |
| 275 | 294 | UINT8 y,ra,chr,gfx; |
| 276 | 295 | UINT16 sy=0,x; |
| 277 | 296 | UINT16 chrstart = (m_width == 32) ? 0x800 : 0; // choose which charrom to use |
| 278 | | UINT16 ma = m_p_ram[0x20] | ((m_p_ram[0x21] & 7) << 8); // start of videoram |
| 279 | | UINT16 cursor = m_p_ram[0x0c] | ((m_p_ram[0x0d] & 7) << 8); // cursor address |
| 297 | UINT16 ma = (m_width == 32) ? 0x400 : 0; // start of videoram |
| 280 | 298 | |
| 281 | | m_framecnt++; |
| 282 | | |
| 283 | 299 | for (y = 0; y < 32; y++) |
| 284 | 300 | { |
| 285 | 301 | for (ra = 0; ra < 8; ra++) |
| r12273 | r12274 | |
| 297 | 313 | if (m_width == 32 && m_p_videoram[x] > 0x7f) |
| 298 | 314 | gfx = ~gfx; |
| 299 | 315 | |
| 300 | | //display cursor if at cursor position and flash on |
| 301 | | if ( (x==cursor) && (m_framecnt & 0x08) ) |
| 302 | | gfx = 0xff; |
| 303 | | |
| 304 | 316 | /* Display a scanline of a character */ |
| 305 | 317 | if (m_width == 32) |
| 306 | 318 | { |
| r12273 | r12274 | |
| 328 | 340 | |
| 329 | 341 | WRITE8_MEMBER(iq151_state::amos_bankswitch_w) |
| 330 | 342 | { |
| 331 | | address_space *prog_space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 343 | address_space *prog_space = m_maincpu->memory().space(AS_PROGRAM); |
| 332 | 344 | |
| 333 | 345 | if (m_amos_banks[data & 3] != NULL) |
| 334 | 346 | prog_space->install_rom(0x8000, 0xbfff, m_amos_banks[data & 3]); |
| r12273 | r12274 | |
| 339 | 351 | |
| 340 | 352 | static DEVICE_IMAGE_LOAD( iq151_cart ) |
| 341 | 353 | { |
| 354 | iq151_state *state = image.device().machine().driver_data<iq151_state>(); |
| 355 | |
| 342 | 356 | if (image.software_entry() != NULL) |
| 343 | 357 | { |
| 344 | 358 | // get the cartridge type |
| 345 | 359 | const char *cart_type = image.get_feature("cart_type"); |
| 346 | | address_space *space = image.device().machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 360 | address_space *space = state->m_maincpu->memory().space(AS_PROGRAM); |
| 347 | 361 | |
| 348 | 362 | if (!strcmp(cart_type, "BASIC6")) |
| 349 | 363 | { |
| r12273 | r12274 | |
| 362 | 376 | else if (!strncmp(cart_type, "AMOS", 4)) |
| 363 | 377 | { |
| 364 | 378 | // AMOS cartridges |
| 365 | | iq151_state *state = image.device().machine().driver_data<iq151_state>(); |
| 366 | 379 | |
| 367 | 380 | switch ((const char)cart_type[4]) |
| 368 | 381 | { |
| r12273 | r12274 | |
| 379 | 392 | } |
| 380 | 393 | |
| 381 | 394 | // install AMOS bankswitch handler |
| 382 | | address_space *io = image.device().machine().device("maincpu")->memory().space(AS_IO); |
| 395 | address_space *io = state->m_maincpu->memory().space(AS_IO); |
| 383 | 396 | io->install_write_handler(0xec, 0xef, write8_delegate(FUNC(iq151_state::amos_bankswitch_w), state)); |
| 384 | 397 | |
| 385 | 398 | return IMAGE_INIT_PASS; |
| r12273 | r12274 | |
| 426 | 439 | GFXDECODE_ENTRY( "chargen", 0x0000, iq151_64_charlayout, 0, 1 ) |
| 427 | 440 | GFXDECODE_END |
| 428 | 441 | |
| 442 | const struct pic8259_interface iq151_pic8259_config = |
| 443 | { |
| 444 | DEVCB_DRIVER_LINE_MEMBER(iq151_state, pic_set_int_line), |
| 445 | DEVCB_LINE_VCC, |
| 446 | DEVCB_NULL |
| 447 | }; |
| 448 | |
| 429 | 449 | static MACHINE_CONFIG_START( iq151, iq151_state ) |
| 430 | 450 | /* basic machine hardware */ |
| 431 | 451 | MCFG_CPU_ADD("maincpu",I8080, XTAL_2MHz) |
| 432 | 452 | MCFG_CPU_PROGRAM_MAP(iq151_mem) |
| 433 | 453 | MCFG_CPU_IO_MAP(iq151_io) |
| 454 | MCFG_CPU_VBLANK_INT("screen", iq151_vblank_interrupt) |
| 434 | 455 | |
| 435 | 456 | /* video hardware */ |
| 436 | 457 | MCFG_SCREEN_ADD("screen", RASTER) |
| r12273 | r12274 | |
| 448 | 469 | MCFG_SOUND_ADD(SPEAKER_TAG, SPEAKER_SOUND, 0) |
| 449 | 470 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 450 | 471 | |
| 451 | | MCFG_TIMER_ADD_PERIODIC("iq151a", iq151a, attotime::from_hz(3) ) |
| 472 | MCFG_PIC8259_ADD("pic8259", iq151_pic8259_config) |
| 452 | 473 | |
| 453 | 474 | /* cartridge */ |
| 454 | 475 | // On real hardware only 4 slots are available, because one |