src/mess/drivers/fk1.c
| r5203 | r5204 | |
| 8 | 8 | |
| 9 | 9 | #include "driver.h" |
| 10 | 10 | #include "cpu/z80/z80.h" |
| 11 | #include "machine/8255ppi.h" |
| 12 | #include "machine/pit8253.h" |
| 13 | #include "machine/msm8251.h" |
| 11 | 14 | |
| 15 | UINT8 fk1_video_rol; |
| 16 | /* |
| 17 | Port A: |
| 18 | Printer |
| 19 | Port B: |
| 20 | Keyboard |
| 21 | Port C: |
| 22 | READING : |
| 23 | 7 - / OBF(buffer overflow for the printer) |
| 24 | 6 - INTE printer |
| 25 | 5 - ERROR printer |
| 26 | 4 - /PEND, lack of paper |
| 27 | 3 - INTR printer |
| 28 | 2 - INTE keyboard |
| 29 | 1 - IBF (data from the keyboard) |
| 30 | 0 - INTR keyboard |
| 31 | WRITING : |
| 32 | 6 - INTE printer |
| 33 | 2 - INTE keyboard |
| 34 | */ |
| 35 | |
| 36 | static WRITE8_DEVICE_HANDLER (fk1_ppi_1_a_w ) |
| 37 | { |
| 38 | // logerror("fk1_ppi_1_a_w %02x\n",data); |
| 39 | } |
| 40 | static WRITE8_DEVICE_HANDLER (fk1_ppi_1_b_w ) |
| 41 | { |
| 42 | // logerror("fk1_ppi_1_b_w %02x\n",data); |
| 43 | } |
| 44 | static WRITE8_DEVICE_HANDLER (fk1_ppi_1_c_w ) |
| 45 | { |
| 46 | //logerror("fk1_ppi_1_c_w %02x\n",data); |
| 47 | } |
| 48 | |
| 49 | static READ8_DEVICE_HANDLER (fk1_ppi_1_a_r ) |
| 50 | { |
| 51 | //logerror("fk1_ppi_1_a_r\n"); |
| 52 | return 0xff; |
| 53 | } |
| 54 | static READ8_DEVICE_HANDLER (fk1_ppi_1_b_r ) |
| 55 | { |
| 56 | // logerror("fk1_ppi_1_b_r\n"); |
| 57 | return 0; |
| 58 | } |
| 59 | static READ8_DEVICE_HANDLER (fk1_ppi_1_c_r ) |
| 60 | { |
| 61 | // logerror("fk1_ppi_1_c_r\n"); |
| 62 | return 0; |
| 63 | } |
| 64 | const ppi8255_interface fk1_ppi8255_interface_1 = |
| 65 | { |
| 66 | DEVCB_HANDLER(fk1_ppi_1_a_r), |
| 67 | DEVCB_HANDLER(fk1_ppi_1_b_r), |
| 68 | DEVCB_HANDLER(fk1_ppi_1_c_r), |
| 69 | DEVCB_HANDLER(fk1_ppi_1_a_w), |
| 70 | DEVCB_HANDLER(fk1_ppi_1_b_w), |
| 71 | DEVCB_HANDLER(fk1_ppi_1_c_w) |
| 72 | }; |
| 73 | |
| 74 | /* |
| 75 | Port A: |
| 76 | Writing data to disk |
| 77 | Port B: |
| 78 | Reading data from disk |
| 79 | Port C: |
| 80 | READING: |
| 81 | 7 - / OF A data write to disk, |
| 82 | 6 - INTE A, |
| 83 | 5 - Select the drive A, B, |
| 84 | 4 - Not connected |
| 85 | 3 - INTR A |
| 86 | 2 - INTE B read data, |
| 87 | 1 - IBF B read data, |
| 88 | 0 - INTR B |
| 89 | |
| 90 | WRITING: |
| 91 | 6 - INTE A - reading data |
| 92 | 2 - INTE B - writing data |
| 93 | */ |
| 94 | static WRITE8_DEVICE_HANDLER (fk1_ppi_2_a_w ) |
| 95 | { |
| 96 | // logerror("write to disk %02x\n",data); |
| 97 | } |
| 98 | |
| 99 | static WRITE8_DEVICE_HANDLER (fk1_ppi_2_c_w ) |
| 100 | { |
| 101 | // logerror("fk1_ppi_2_c_w %02x\n",data); |
| 102 | } |
| 103 | |
| 104 | static READ8_DEVICE_HANDLER (fk1_ppi_2_b_r ) |
| 105 | { |
| 106 | // logerror("read from disk\n"); |
| 107 | return 0; |
| 108 | } |
| 109 | static READ8_DEVICE_HANDLER (fk1_ppi_2_c_r ) |
| 110 | { |
| 111 | // logerror("fk1_ppi_2_c_r\n"); |
| 112 | return 0; |
| 113 | } |
| 114 | const ppi8255_interface fk1_ppi8255_interface_2 = |
| 115 | { |
| 116 | DEVCB_NULL, |
| 117 | DEVCB_HANDLER(fk1_ppi_2_b_r), |
| 118 | DEVCB_HANDLER(fk1_ppi_2_c_r), |
| 119 | DEVCB_HANDLER(fk1_ppi_2_a_w), |
| 120 | DEVCB_NULL, |
| 121 | DEVCB_HANDLER(fk1_ppi_2_c_w) |
| 122 | }; |
| 123 | |
| 124 | |
| 125 | /* |
| 126 | |
| 127 | Port A: |
| 128 | 6 - / disk, authorization disk operations, |
| 129 | 3 - INTE MOUSE, permit suspension from mouse, |
| 130 | 2 - INTE RTC from the system clock of 50 Hz, |
| 131 | 1 and 0 - to set the type for hours write to the disk (01 index, 11 address mark, mark the date, 00 other). |
| 132 | |
| 133 | Port B: |
| 134 | Video ROL register |
| 135 | Port C |
| 136 | |
| 137 | READING: |
| 138 | 7 - INDEX ( index mark on the disk) |
| 139 | 6 - I do not know, |
| 140 | 5 - WRITE_PROTECT the protected disk, |
| 141 | 4 - TRAC_00 as a sign of trace |
| 142 | |
| 143 | WRITING: |
| 144 | 3 - HEAD LOAD |
| 145 | 2 - TRACK_43 |
| 146 | 1 - DIRC - direction to set the direction of stepping disk |
| 147 | 0 - STEP, move disk (0 1 .. 0.). |
| 148 | |
| 149 | */ |
| 150 | static WRITE8_DEVICE_HANDLER (fk1_ppi_3_a_w ) |
| 151 | { |
| 152 | // logerror("fk1_ppi_3_a_w %02x\n",data); |
| 153 | } |
| 154 | static WRITE8_DEVICE_HANDLER (fk1_ppi_3_b_w ) |
| 155 | { |
| 156 | fk1_video_rol = data; |
| 157 | } |
| 158 | static WRITE8_DEVICE_HANDLER (fk1_ppi_3_c_w ) |
| 159 | { |
| 160 | // logerror("fk1_ppi_3_c_w %02x\n",data); |
| 161 | } |
| 162 | |
| 163 | static READ8_DEVICE_HANDLER (fk1_ppi_3_a_r ) |
| 164 | { |
| 165 | // logerror("fk1_ppi_3_a_r\n"); |
| 166 | return 0; |
| 167 | } |
| 168 | static READ8_DEVICE_HANDLER (fk1_ppi_3_b_r ) |
| 169 | { |
| 170 | return fk1_video_rol; |
| 171 | } |
| 172 | static READ8_DEVICE_HANDLER (fk1_ppi_3_c_r ) |
| 173 | { |
| 174 | // logerror("fk1_ppi_3_c_r\n"); |
| 175 | return 0; |
| 176 | } |
| 177 | const ppi8255_interface fk1_ppi8255_interface_3 = |
| 178 | { |
| 179 | DEVCB_HANDLER(fk1_ppi_3_a_r), |
| 180 | DEVCB_HANDLER(fk1_ppi_3_b_r), |
| 181 | DEVCB_HANDLER(fk1_ppi_3_c_r), |
| 182 | DEVCB_HANDLER(fk1_ppi_3_a_w), |
| 183 | DEVCB_HANDLER(fk1_ppi_3_b_w), |
| 184 | DEVCB_HANDLER(fk1_ppi_3_c_w) |
| 185 | }; |
| 186 | |
| 187 | static PIT8253_OUTPUT_CHANGED(fk1_pit_out0) |
| 188 | { |
| 189 | // System time |
| 190 | logerror("PIT8253_OUTPUT_CHANGED(fk1_pit_out0)\n"); |
| 191 | } |
| 192 | |
| 193 | static PIT8253_OUTPUT_CHANGED(fk1_pit_out1) |
| 194 | { |
| 195 | // Timeout for disk operation |
| 196 | logerror("PIT8253_OUTPUT_CHANGED(fk1_pit_out1)\n"); |
| 197 | } |
| 198 | |
| 199 | static PIT8253_OUTPUT_CHANGED(fk1_pit_out2) |
| 200 | { |
| 201 | // Overflow for disk operations |
| 202 | logerror("PIT8253_OUTPUT_CHANGED(fk1_pit_out2)\n"); |
| 203 | } |
| 204 | |
| 205 | |
| 206 | const struct pit8253_config fk1_pit8253_intf = |
| 207 | { |
| 208 | { |
| 209 | { |
| 210 | 50, |
| 211 | fk1_pit_out0 |
| 212 | }, |
| 213 | { |
| 214 | 1000000, |
| 215 | fk1_pit_out1 |
| 216 | }, |
| 217 | { |
| 218 | 0, |
| 219 | fk1_pit_out2 |
| 220 | } |
| 221 | } |
| 222 | }; |
| 223 | |
| 224 | /* |
| 225 | 0 no interrupt allowed, |
| 226 | 1 allowed INTR-7, |
| 227 | 2 allowed INTR-7 and INTR-6, |
| 228 | 8 any interruption allowed. |
| 229 | */ |
| 230 | |
| 231 | WRITE8_HANDLER( fk1_intr_w ) |
| 232 | { |
| 233 | logerror("fk1_intr_w %02x\n",data); |
| 234 | } |
| 235 | |
| 236 | READ8_HANDLER( fk1_bank_ram_r ) |
| 237 | { |
| 238 | const address_space *space_mem = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 239 | memory_install_write8_handler(space_mem, 0x0000, 0x3fff, 0, 0, SMH_BANK(1)); |
| 240 | memory_set_bankptr(space->machine, 1, mess_ram); |
| 241 | memory_set_bankptr(space->machine, 2, mess_ram + 0x4000); |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | READ8_HANDLER( fk1_bank_rom_r ) |
| 246 | { |
| 247 | const address_space *space_mem = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 248 | memory_install_write8_handler(space_mem, 0x0000, 0x3fff, 0, 0, SMH_UNMAP); |
| 249 | memory_set_bankptr(space->machine, 1, memory_region(space->machine, "maincpu")); |
| 250 | memory_set_bankptr(space->machine, 2, mess_ram + 0x10000); |
| 251 | return 0; |
| 252 | } |
| 253 | |
| 254 | /* |
| 255 | 4 - FORMAT authorization |
| 256 | 3 - READ_ADDRESS_MARK |
| 257 | 2 - READ_DATA_MARK |
| 258 | 1 - WRITE |
| 259 | 0 - READ |
| 260 | Functions are allowed in one. |
| 261 | */ |
| 262 | WRITE8_HANDLER( fk1_disk_w ) |
| 263 | { |
| 264 | // logerror("fk1_disk_w %02x\n",data); |
| 265 | } |
| 266 | |
| 267 | /* |
| 268 | 7 and 6 - 1 to connected mouse and 0 if not connected, |
| 269 | 5 - / T2, right-click |
| 270 | 4 - / T1, left-click |
| 271 | 3 - / BY, Y-axis |
| 272 | 2 - / AY, Y-axis |
| 273 | 1 - / BX, X-axis |
| 274 | 0 - / AX, X-axis |
| 275 | */ |
| 276 | READ8_HANDLER( fk1_mouse_r ) |
| 277 | { |
| 278 | // logerror("fk1_mouse_r\n"); |
| 279 | return 0; |
| 280 | } |
| 281 | |
| 282 | /*Write to port 70 resets the interrupt from the system clock of 50 Hz. */ |
| 283 | |
| 284 | WRITE8_HANDLER( fk1_reset_int_w ) |
| 285 | { |
| 286 | logerror("fk1_reset_int_w\n"); |
| 287 | } |
| 288 | |
| 12 | 289 | static ADDRESS_MAP_START(fk1_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 13 | | ADDRESS_MAP_UNMAP_HIGH |
| 14 | | AM_RANGE( 0x0000, 0x07ff ) AM_ROM |
| 15 | | AM_RANGE( 0x0800, 0xffff ) AM_RAM |
| 290 | AM_RANGE(0x0000, 0x3fff) AM_RAMBANK(1) |
| 291 | AM_RANGE(0x4000, 0x7fff) AM_RAMBANK(2) |
| 292 | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK(3) |
| 293 | AM_RANGE(0xc000, 0xffff) AM_RAMBANK(4) |
| 16 | 294 | ADDRESS_MAP_END |
| 17 | 295 | |
| 18 | 296 | static ADDRESS_MAP_START( fk1_io , ADDRESS_SPACE_IO, 8) |
| 297 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 19 | 298 | ADDRESS_MAP_UNMAP_HIGH |
| 299 | AM_RANGE( 0x00, 0x03 ) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w) |
| 300 | AM_RANGE( 0x10, 0x13 ) AM_DEVREADWRITE("pit8253", pit8253_r,pit8253_w) |
| 301 | AM_RANGE( 0x20, 0x23 ) AM_DEVREADWRITE("ppi8255_2", ppi8255_r, ppi8255_w) |
| 302 | AM_RANGE( 0x30, 0x30 ) AM_READWRITE(fk1_bank_ram_r,fk1_intr_w) |
| 303 | AM_RANGE( 0x40, 0x40 ) AM_DEVREADWRITE("uart", msm8251_data_r,msm8251_data_w) |
| 304 | AM_RANGE( 0x41, 0x41 ) AM_DEVREADWRITE("uart", msm8251_status_r,msm8251_control_w) |
| 305 | AM_RANGE( 0x50, 0x50 ) AM_READWRITE(fk1_bank_rom_r,fk1_disk_w) |
| 306 | AM_RANGE( 0x60, 0x63 ) AM_DEVREADWRITE("ppi8255_3", ppi8255_r, ppi8255_w) |
| 307 | AM_RANGE( 0x70, 0x70 ) AM_READWRITE(fk1_mouse_r,fk1_reset_int_w) |
| 20 | 308 | ADDRESS_MAP_END |
| 21 | 309 | |
| 22 | 310 | /* Input ports */ |
| 23 | 311 | static INPUT_PORTS_START( fk1 ) |
| 312 | PORT_START("LINE0") |
| 313 | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 314 | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') |
| 315 | PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('\"') |
| 316 | PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') |
| 317 | PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('\xA4') |
| 318 | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| 319 | PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| 320 | PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 24 | 321 | INPUT_PORTS_END |
| 25 | 322 | |
| 323 | UINT8 int_vector; |
| 26 | 324 | |
| 325 | static TIMER_CALLBACK(keyboard_callback) |
| 326 | { |
| 327 | if (input_port_read(machine, "LINE0")) { |
| 328 | int_vector = 6; |
| 329 | cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | /* |
| 334 | 7 – DATA_READY |
| 335 | 6 – TIMEOUT |
| 336 | 5 – OVERFLOW |
| 337 | 4 – RTC_50HZ |
| 338 | 3 – MOUSE |
| 339 | 2 – SIO |
| 340 | 1 – KEYBOARD |
| 341 | 0 – PRINTER |
| 342 | */ |
| 343 | |
| 344 | static IRQ_CALLBACK (fk1_irq_callback) |
| 345 | { |
| 346 | logerror("IRQ %02x\n",int_vector*2); |
| 347 | return int_vector * 2; |
| 348 | } |
| 349 | |
| 350 | static TIMER_CALLBACK( vsync_callback ) |
| 351 | { |
| 352 | int_vector = 3; |
| 353 | cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); |
| 354 | } |
| 355 | |
| 356 | |
| 27 | 357 | static MACHINE_RESET(fk1) |
| 28 | 358 | { |
| 359 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 360 | memory_install_write8_handler(space, 0x0000, 0x3fff, 0, 0, SMH_UNMAP); |
| 361 | memory_set_bankptr(machine, 1, memory_region(machine, "maincpu")); // ROM |
| 362 | memory_set_bankptr(machine, 2, mess_ram + 0x10000); // VRAM |
| 363 | memory_set_bankptr(machine, 3, mess_ram + 0x8000); |
| 364 | memory_set_bankptr(machine, 4, mess_ram + 0xc000); |
| 365 | |
| 366 | cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), fk1_irq_callback); |
| 367 | timer_pulse(machine, ATTOTIME_IN_HZ(24000), NULL, 0, keyboard_callback); |
| 368 | timer_pulse(machine, ATTOTIME_IN_HZ(50), NULL, 0, vsync_callback); |
| 29 | 369 | } |
| 30 | 370 | |
| 31 | 371 | static VIDEO_START( fk1 ) |
| r5203 | r5204 | |
| 34 | 374 | |
| 35 | 375 | static VIDEO_UPDATE( fk1 ) |
| 36 | 376 | { |
| 37 | | return 0; |
| 377 | UINT8 code; |
| 378 | int y, x, b; |
| 379 | |
| 380 | for (x = 0; x < 64; x++) |
| 381 | { |
| 382 | for (y = 0; y < 256; y++) |
| 383 | { |
| 384 | code = mess_ram[x * 0x100 + ((y + fk1_video_rol) & 0xff) + 0x10000]; |
| 385 | for (b = 0; b < 8; b++) |
| 386 | { |
| 387 | *BITMAP_ADDR16(bitmap, y, x*8+b) = ((code << b) & 0x80) ? 1 : 0; |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | return 0; |
| 38 | 392 | } |
| 39 | 393 | |
| 40 | 394 | static MACHINE_DRIVER_START( fk1 ) |
| 41 | 395 | /* basic machine hardware */ |
| 42 | | MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz) |
| 396 | MDRV_CPU_ADD("maincpu",Z80, XTAL_8MHz / 2) |
| 43 | 397 | MDRV_CPU_PROGRAM_MAP(fk1_mem) |
| 44 | 398 | MDRV_CPU_IO_MAP(fk1_io) |
| 45 | 399 | |
| r5203 | r5204 | |
| 50 | 404 | MDRV_SCREEN_REFRESH_RATE(50) |
| 51 | 405 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 52 | 406 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 53 | | MDRV_SCREEN_SIZE(640, 480) |
| 54 | | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 407 | MDRV_SCREEN_SIZE(512, 256) |
| 408 | MDRV_SCREEN_VISIBLE_AREA(0, 512-1, 0, 256-1) |
| 55 | 409 | MDRV_PALETTE_LENGTH(2) |
| 56 | 410 | MDRV_PALETTE_INIT(black_and_white) |
| 57 | 411 | |
| 58 | 412 | MDRV_VIDEO_START(fk1) |
| 59 | 413 | MDRV_VIDEO_UPDATE(fk1) |
| 414 | |
| 415 | MDRV_PIT8253_ADD( "pit8253", fk1_pit8253_intf ) |
| 416 | MDRV_PPI8255_ADD( "ppi8255_1", fk1_ppi8255_interface_1 ) |
| 417 | MDRV_PPI8255_ADD( "ppi8255_2", fk1_ppi8255_interface_2 ) |
| 418 | MDRV_PPI8255_ADD( "ppi8255_3", fk1_ppi8255_interface_3 ) |
| 419 | /* uart */ |
| 420 | MDRV_MSM8251_ADD("uart", default_msm8251_interface) |
| 60 | 421 | MACHINE_DRIVER_END |
| 61 | 422 | |
| 62 | 423 | static SYSTEM_CONFIG_START(fk1) |
| 424 | CONFIG_RAM_DEFAULT((64+16) * 1024) |
| 63 | 425 | SYSTEM_CONFIG_END |
| 64 | 426 | |
| 65 | 427 | /* ROM definition */ |
| 66 | 428 | ROM_START( fk1 ) |
| 67 | 429 | ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF ) |
| 68 | | ROM_LOAD( "fk1.rom", 0x0000, 0x0800, CRC(145561f8) SHA1(a4eb17d773e51b34620c508b6cebcb4531ae99c2)) |
| 69 | | |
| 430 | ROM_SYSTEM_BIOS( 0, "orig", "Original BIOS" ) |
| 431 | ROMX_LOAD( "fk1.u65", 0x0000, 0x0800, CRC(145561f8) SHA1(a4eb17d773e51b34620c508b6cebcb4531ae99c2), ROM_BIOS(1)) |
| 432 | ROM_SYSTEM_BIOS( 1, "diag", "Diag BIOS" ) |
| 433 | ROMX_LOAD( "fk1-diag.u65", 0x0000, 0x0800, CRC(e0660ae1) SHA1(6ad609049b28f27126af0a8a6224362351073dee), ROM_BIOS(2)) |
| 70 | 434 | ROM_END |
| 71 | 435 | |
| 72 | 436 | /* Driver */ |