src/mess/drivers/socrates.c
| r5324 | r5325 | |
| 5 | 5 | * with dumping help from Kevin 'kevtris' Horton |
| 6 | 6 | * |
| 7 | 7 | * (driver structure copied from vtech1.c) |
| 8 | | TODO: (practically everything!) |
| 9 | | hook up ram banking |
| 10 | | hook up rom banking |
| 11 | | fix layout to sane dimensions |
| 12 | | write renderer (composite ntsc fun!) and hook up scroll regs |
| 8 | TODO: |
| 9 | add waitstates for ram access (lack of this causes the system to run way too fast) |
| 13 | 10 | hook up cartridges using the bios system |
| 14 | 11 | hook up sound regs |
| 15 | 12 | find and hook up keyboard/mouse IR input |
| r5324 | r5325 | |
| 71 | 68 | E 0x8000-0xbfff 0xc000-0xffff |
| 72 | 69 | F 0xc000-0xffff 0xc000-0xffff |
| 73 | 70 | |
| 74 | | video output: |
| 75 | | 1. read byte at address in vram |
| 76 | | 2. compare the lower nybble >=8 or not |
| 77 | | 3. if 2 is false, go to 6; if it is true, go to 4 |
| 78 | | 4. retrieve the value from ram address 0xFNLL where N is the nybble and LL is the low 8 bits of the current display line offset. |
| 79 | | 5. take this newly retrieved byte and shift the bits out to video in the order 4 5 6 7 0 1 2 3 at the 2048-pixels-per-line rate. go to 7. |
| 80 | | 6. take the retrieved byte and shift the bits out to video in the order 0 1 2 3 at the 1024-pixels-per-line rate. |
| 81 | | 7. compare the upper nybble >= 8 or not |
| 82 | | 8. if 7 is false, go to 11; if it is true, go to 9 |
| 83 | | 9. retrieve the value from ram address 0xFNLL where N is the nybble and LL is the low 8 bits of the current display line offset. |
| 84 | | 10. take this newly retrieved byte and shift the bits out to video in the order 4 5 6 7 0 1 2 3 at the 2048-pixels-per-line rate. go to 12. |
| 85 | | 11. take the retrieved byte and shift the bits out to video in the order 4 5 6 7 at the 1024-pixels-per-line rate. |
| 86 | | 12. are we in hblank? if we are not in hblank or hblank is now over, increment the vram address and go to 1. otherwise, just go to 1. |
| 87 | | |
| 88 | | Yes, the above means that all colors, shades, etc produced by video are entirely composite ntsc artifacts. |
| 89 | | |
| 90 | 71 | ******************************************************************************/ |
| 91 | 72 | |
| 92 | 73 | /* Core includes */ |
| 93 | 74 | #include "driver.h" |
| 94 | 75 | #include "cpu/z80/z80.h" |
| 95 | 76 | #include "socrates.lh" |
| 77 | #include "sound/beep.h" |
| 96 | 78 | |
| 79 | |
| 97 | 80 | /* Components */ |
| 98 | 81 | |
| 99 | 82 | /* Devices */ |
| r5324 | r5325 | |
| 134 | 117 | /* fill vram with its init powerup bit pattern, so startup has the checkerboard screen */ |
| 135 | 118 | for (i = 0; i < 0x10000; i++) |
| 136 | 119 | gfx[i] = (((i&0x1)?0x00:0xFF)^((i&0x100)?0x00:0xff)); |
| 120 | // init sound channels to both be on lowest pitch and max volume |
| 137 | 121 | } |
| 138 | 122 | |
| 139 | 123 | READ8_HANDLER( socrates_rom_bank_r ) |
| r5324 | r5325 | |
| 290 | 274 | |
| 291 | 275 | static VIDEO_START( socrates ) |
| 292 | 276 | { |
| 293 | | // dunno what to do here if anything |
| 294 | 277 | socrates.videoram = memory_region(machine, "vram"); |
| 295 | 278 | socrates.scroll_offset = 0; |
| 296 | 279 | } |
| r5324 | r5325 | |
| 319 | 302 | return 0; |
| 320 | 303 | } |
| 321 | 304 | |
| 305 | /* below belongs in sound/socrates.c */ |
| 306 | |
| 307 | static WRITE8_HANDLER(socrates_sound_w) |
| 308 | { |
| 309 | switch(offset) |
| 310 | { |
| 311 | case 0: |
| 312 | //beep_set_frequency(channel1, (int)((13982.6)/(data+1))); |
| 313 | break; |
| 314 | case 1: |
| 315 | //beep_set_frequency(channel2, (int)((13982.6)/(data+1))); |
| 316 | break; |
| 317 | case 2: |
| 318 | //beep_set_volume(channel1, data/4); |
| 319 | break; |
| 320 | case 3: |
| 321 | //beep_set_volume(channel2, data/8); |
| 322 | break; |
| 323 | case 4: case 5: case 6: case 7: default: |
| 324 | break; |
| 325 | } |
| 326 | } |
| 327 | |
| 322 | 328 | /****************************************************************************** |
| 323 | 329 | Address Maps |
| 324 | 330 | ******************************************************************************/ |
| r5324 | r5325 | |
| 332 | 338 | ADDRESS_MAP_END |
| 333 | 339 | |
| 334 | 340 | static ADDRESS_MAP_START(z80_io, ADDRESS_SPACE_IO, 8) |
| 341 | ADDRESS_MAP_UNMAP_HIGH |
| 335 | 342 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 336 | 343 | AM_RANGE(0x00, 0x00) AM_READWRITE(socrates_rom_bank_r, socrates_rom_bank_w) AM_MIRROR(0x7) /* rom bank select - RW - 8 bits */ |
| 337 | 344 | AM_RANGE(0x08, 0x08) AM_READWRITE(socrates_ram_bank_r, socrates_ram_bank_w) AM_MIRROR(0x7) /* ram banks select - RW - 4 low bits; Format: 0b****HHLL where LL controls whether window 0 points at ram area: 0b00: 0x0000-0x3fff; 0b01: 0x4000-0x7fff; 0b10: 0x8000-0xbfff; 0b11: 0xc000-0xffff. HH controls the same thing for window 1 */ |
| 338 | | AM_RANGE(0x10, 0x17) AM_NOP AM_MIRROR (0x8) /* sound section: |
| 345 | AM_RANGE(0x10, 0x17) AM_WRITE(socrates_sound_w) AM_MIRROR (0x8) /* sound section: |
| 339 | 346 | 0x10 - W - frequency control for channel 1 (louder channel) - 01=high pitch, ff=low; time between 1->0/0->1 transitions = (XTAL_21_4772MHz/(512+256) / (freq_reg+1)) (note that this is double the actual frequency since each full low and high squarewave pulse is two transitions) |
| 340 | 347 | 0x11 - W - frequency control for channel 2 (softer channel) - 01=high pitch, ff=low; same equation as above |
| 341 | 348 | 0x12 - W - 0b****VVVV volume control for channel 1 |
| r5324 | r5325 | |
| 364 | 371 | /****************************************************************************** |
| 365 | 372 | Machine Drivers |
| 366 | 373 | ******************************************************************************/ |
| 374 | static TIMER_CALLBACK( clear_irq_cb ) |
| 375 | { |
| 376 | cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE); |
| 377 | } |
| 367 | 378 | |
| 379 | static INTERRUPT_GEN( assert_irq ) |
| 380 | { |
| 381 | cpu_set_input_line(device, 0, ASSERT_LINE); |
| 382 | timer_set(device->machine, cpu_clocks_to_attotime(device, 144), NULL, 0, clear_irq_cb); |
| 383 | // 144 is a complete and total guess, need to properly measure how many clocks/microseconds the int line is high for. |
| 384 | } |
| 385 | |
| 368 | 386 | static MACHINE_DRIVER_START(socrates) |
| 369 | 387 | /* basic machine hardware */ |
| 370 | | MDRV_CPU_ADD("maincpu", Z80, XTAL_21_4772MHz/6) /* Toshiba TMPZ84C00AP @ 3.579545 MHz, verified, xtal is divided by 6 */ |
| 388 | //MDRV_CPU_ADD("maincpu", Z80, XTAL_21_4772MHz/6) /* Toshiba TMPZ84C00AP @ 3.579545 MHz, verified, xtal is divided by 6 */ |
| 389 | MDRV_CPU_ADD("maincpu", Z80, XTAL_21_4772MHz/12) /* HACK to make system run at roughly the right speed until waitstates are done */ |
| 371 | 390 | MDRV_CPU_PROGRAM_MAP(z80_mem) |
| 372 | 391 | MDRV_CPU_IO_MAP(z80_io) |
| 373 | 392 | MDRV_QUANTUM_TIME(HZ(60)) |
| 393 | MDRV_CPU_VBLANK_INT("screen", assert_irq) |
| 374 | 394 | //MDRV_MACHINE_START(socrates) |
| 375 | 395 | MDRV_MACHINE_RESET(socrates) |
| 376 | 396 | |
| r5324 | r5325 | |
| 389 | 409 | |
| 390 | 410 | /* sound hardware */ |
| 391 | 411 | //MDRV_SPEAKER_STANDARD_MONO("mono") |
| 412 | //MDRV_SOUND_ADD("beep", BEEP, 0) |
| 413 | //MDRV_SOUND_ADD("beep2", BEEP, 0) |
| 392 | 414 | //MDRV_SOUND_ADD("soc_snd", SOCRATES, XTAL_21_4772MHz/(512+256)) /* this is correct, as strange as it sounds. */ |
| 393 | | //MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 415 | //MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15) |
| 394 | 416 | |
| 395 | 417 | |
| 396 | 418 | MACHINE_DRIVER_END |