src/mess/drivers/jr200.c
| r8758 | r8759 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | JR-200 |
| 3 | JR-200 (c) 1982 National / Panasonic |
| 4 | 4 | |
| 5 | | 12/05/2009 Skeleton driver. |
| 5 | preliminary driver by Roberto Zandoną and Angelo Salese |
| 6 | 6 | |
| 7 | 7 | http://www.armchairarcade.com/neo/node/1598 |
| 8 | 8 | |
| 9 | TODO: |
| 10 | - Timings are basically screwed, it's too fast in idle mode, too slow |
| 11 | when the beeper fires for a syntax error; |
| 12 | - MN1544 4-bit CPU core and ROM dump |
| 13 | |
| 9 | 14 | ****************************************************************************/ |
| 10 | 15 | |
| 11 | | /* |
| 12 | | |
| 13 | | TODO: |
| 14 | | |
| 15 | | - MN1544 4-bit CPU core and ROM dump |
| 16 | | |
| 17 | | */ |
| 18 | | |
| 19 | 16 | #include "emu.h" |
| 20 | 17 | #include "cpu/m6800/m6800.h" |
| 18 | #include "sound/beep.h" |
| 21 | 19 | |
| 22 | | static UINT8 *textram; |
| 20 | static UINT8 *jr200_vram,*jr200_cram; |
| 23 | 21 | static UINT8 *border; |
| 24 | 22 | static UINT8 io_reg[0x20] = { |
| 25 | 23 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| r8758 | r8759 | |
| 38 | 36 | { 0x66, 0x67, 0x68, 0x6a, 0x6b, 0x6c, 0x3b, 0x3a }, |
| 39 | 37 | { 0x0d, 0x0a, 0x1e, 0x31, 0x32, 0x33, 0x7a, 0x78 }, |
| 40 | 38 | { 0x63, 0x76, 0x62, 0x6e, 0x6d, 0x2c, 0x2e, 0x2f }, |
| 41 | | { 0x1d, 0x1f, 0x1c, 0x30, 0x2e, 0x20, 0x00, 0x00 } |
| 39 | { 0x1d, 0x1f, 0x1c, 0x30, 0x2e, 0x20, 0x03, 0x00 } |
| 42 | 40 | }, |
| 43 | 41 | |
| 44 | 42 | /* shifted */ |
| r8758 | r8759 | |
| 81 | 79 | } |
| 82 | 80 | }; |
| 83 | 81 | |
| 82 | |
| 83 | static VIDEO_START( jr200 ) |
| 84 | { |
| 85 | } |
| 86 | |
| 87 | static VIDEO_UPDATE( jr200 ) |
| 88 | { |
| 89 | int i,j; |
| 90 | const gfx_element *gfx = screen->machine->gfx[0]; |
| 91 | |
| 92 | bitmap_fill(bitmap, cliprect, border[0x0000] * 2 + 1); |
| 93 | |
| 94 | for (i = 0; i < 0x02ff; i += 0x20) |
| 95 | for (j = 0; j < 0x20; j++) |
| 96 | { |
| 97 | UINT8 code = jr200_vram[0x000 + i + j]; |
| 98 | UINT8 col = jr200_cram[0x000 + i + j]; |
| 99 | |
| 100 | if (col & 0x80) |
| 101 | { |
| 102 | UINT8 pixel01 = (jr200_vram[0x0000 + i + j] >> 3) & 0x07; |
| 103 | UINT8 pixel00 = (jr200_vram[0x0000 + i + j] >> 0) & 0x07; |
| 104 | UINT8 pixel11 = (jr200_cram[0x0000 + i + j] >> 3) & 0x07; |
| 105 | UINT8 pixel10 = (jr200_cram[0x0000 + i + j] >> 0) & 0x07; |
| 106 | plot_box(bitmap, 16 + j * 8 , 16 + (i >> 5) * 8 , 4, 4, pixel00 * 2 + 1); |
| 107 | plot_box(bitmap, 16 + j * 8 + 4, 16 + (i >> 5) * 8 , 4, 4, pixel01 * 2 + 1); |
| 108 | plot_box(bitmap, 16 + j * 8 , 16 + (i >> 5) * 8 + 4, 4, 4, pixel10 * 2 + 1); |
| 109 | plot_box(bitmap, 16 + j * 8 + 4, 16 + (i >> 5) * 8 + 4, 4, 4, pixel11 * 2 + 1); |
| 110 | } |
| 111 | else |
| 112 | { |
| 113 | drawgfx_opaque(bitmap, cliprect, gfx, code, col & 0x3f, 0, 0, 16 + j * 8, 16 + (i >> 5) * 8); |
| 114 | } |
| 115 | } |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 84 | 119 | #if 0 |
| 85 | 120 | static READ8_HANDLER( test_r ) |
| 86 | 121 | { |
| r8758 | r8759 | |
| 88 | 123 | } |
| 89 | 124 | #endif |
| 90 | 125 | |
| 91 | | static WRITE8_HANDLER( io_reg_w ) |
| 92 | | { |
| 93 | | io_reg[offset] = data; |
| 94 | | } |
| 95 | | |
| 96 | 126 | static READ8_HANDLER( io_reg_r ) |
| 97 | 127 | { |
| 98 | 128 | UINT8 value = 0x00; |
| r8758 | r8759 | |
| 168 | 198 | return value; |
| 169 | 199 | } |
| 170 | 200 | |
| 201 | static WRITE8_HANDLER( io_reg_w ) |
| 202 | { |
| 203 | io_reg[offset] = data; |
| 204 | |
| 205 | switch(offset) |
| 206 | { |
| 207 | /* set beeper active */ |
| 208 | case 0x19: |
| 209 | beep_set_state(space->machine->device("beeper"),(data == 0x0e) ? 1 : 0); |
| 210 | break; |
| 211 | /* set beeper frequency (TODO: correct frequency algorhythm) */ |
| 212 | case 0x1a: |
| 213 | case 0x1b: |
| 214 | { |
| 215 | UINT32 beep_freq; |
| 216 | |
| 217 | beep_freq = ((io_reg[0x1a]<<8) | (io_reg[0x1b] & 0xff)) + 1; |
| 218 | |
| 219 | beep_set_frequency(space->machine->device("beeper"),84000 / beep_freq); |
| 220 | } |
| 221 | break; |
| 222 | } |
| 223 | } |
| 224 | |
| 171 | 225 | /* |
| 172 | 226 | 0000-3fff RAM |
| 173 | 227 | 4000-4fff RAM ( 4k expansion) |
| 174 | 228 | 4000-7fff RAM (16k expansion) |
| 175 | 229 | 4000-bfff RAM (32k expansion) |
| 176 | | c100-c3FF text code |
| 177 | | c500-c7ff text color |
| 178 | | ca00 border color |
| 179 | 230 | */ |
| 180 | 231 | |
| 181 | 232 | static ADDRESS_MAP_START(jr200_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 182 | | AM_RANGE(0x0000, 0x000c) AM_RAM |
| 183 | | AM_RANGE(0x000d, 0x000d) AM_RAM |
| 184 | | AM_RANGE(0x000e, 0x3fff) AM_RAM |
| 233 | AM_RANGE(0x0000, 0x3fff) AM_RAM |
| 185 | 234 | AM_RANGE(0xa000, 0xbfff) AM_ROM |
| 186 | | AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_BASE(&textram) |
| 235 | // AM_RANGE(0xc000, 0xc0ff) AM_RAM //PCG area (1) |
| 236 | AM_RANGE(0xc100, 0xc3ff) AM_RAM AM_BASE(&jr200_vram) |
| 237 | // AM_RANGE(0xc400, 0xc4ff) AM_RAM //PCG area (2) |
| 238 | AM_RANGE(0xc500, 0xc7ff) AM_RAM AM_BASE(&jr200_cram) |
| 239 | // 0xc800 - 0xcfff I / O area |
| 187 | 240 | AM_RANGE(0xc800, 0xc81f) AM_READWRITE(io_reg_r, io_reg_w) |
| 188 | 241 | AM_RANGE(0xca00, 0xca00) AM_RAM AM_BASE(&border) |
| 242 | // AM_RANGE(0xd000, 0xd7ff) AM_ROM //BIOS PCG RAM |
| 189 | 243 | AM_RANGE(0xe000, 0xffff) AM_ROM |
| 190 | 244 | ADDRESS_MAP_END |
| 191 | 245 | |
| r8758 | r8759 | |
| 292 | 346 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RIGHT CTRL") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL)) |
| 293 | 347 | INPUT_PORTS_END |
| 294 | 348 | |
| 349 | static MACHINE_START(jr200) |
| 350 | { |
| 351 | beep_set_frequency(machine->device("beeper"),0); |
| 352 | beep_set_state(machine->device("beeper"),0); |
| 353 | } |
| 295 | 354 | |
| 296 | 355 | static MACHINE_RESET(jr200) |
| 297 | 356 | { |
| 357 | |
| 298 | 358 | } |
| 299 | 359 | |
| 300 | 360 | static PALETTE_INIT( jr200 ) |
| r8758 | r8759 | |
| 308 | 368 | } |
| 309 | 369 | } |
| 310 | 370 | |
| 311 | | static VIDEO_START( jr200 ) |
| 312 | | { |
| 313 | | } |
| 314 | | |
| 315 | | static VIDEO_UPDATE( jr200 ) |
| 316 | | { |
| 317 | | int i,j; |
| 318 | | const gfx_element *gfx = screen->machine->gfx[0]; |
| 319 | | |
| 320 | | bitmap_fill(bitmap, cliprect, border[0x0000] * 2 + 1); |
| 321 | | |
| 322 | | for (i = 0; i < 0x02ff; i += 0x20) |
| 323 | | for (j = 0; j < 0x20; j++) |
| 324 | | { |
| 325 | | UINT8 code = textram[0x0100 + i + j]; |
| 326 | | UINT8 col = textram[0x0500 + i + j]; |
| 327 | | |
| 328 | | if (col & 0x80) |
| 329 | | { |
| 330 | | UINT8 pixel01 = (textram[0x0100 + i + j] >> 3) & 0x07; |
| 331 | | UINT8 pixel00 = (textram[0x0100 + i + j] >> 0) & 0x07; |
| 332 | | UINT8 pixel11 = (textram[0x0500 + i + j] >> 3) & 0x07; |
| 333 | | UINT8 pixel10 = (textram[0x0500 + i + j] >> 0) & 0x07; |
| 334 | | plot_box(bitmap, 16 + j * 8 , 16 + (i >> 5) * 8 , 4, 4, pixel00 * 2 + 1); |
| 335 | | plot_box(bitmap, 16 + j * 8 + 4, 16 + (i >> 5) * 8 , 4, 4, pixel01 * 2 + 1); |
| 336 | | plot_box(bitmap, 16 + j * 8 , 16 + (i >> 5) * 8 + 4, 4, 4, pixel10 * 2 + 1); |
| 337 | | plot_box(bitmap, 16 + j * 8 + 4, 16 + (i >> 5) * 8 + 4, 4, 4, pixel11 * 2 + 1); |
| 338 | | } |
| 339 | | else |
| 340 | | { |
| 341 | | drawgfx_transpen(bitmap, cliprect, gfx, code, col & 0x3f, 0, 0, 16 + j * 8, 16 + (i >> 5) * 8, 15); |
| 342 | | } |
| 343 | | } |
| 344 | | return 0; |
| 345 | | } |
| 346 | | |
| 347 | 371 | static const gfx_layout tiles8x8_layout = |
| 348 | 372 | { |
| 349 | 373 | 8,8, |
| r8758 | r8759 | |
| 362 | 386 | |
| 363 | 387 | static INTERRUPT_GEN( jr200_nmi ) |
| 364 | 388 | { |
| 365 | | cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); |
| 389 | // cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); |
| 366 | 390 | } |
| 367 | 391 | |
| 368 | 392 | static INTERRUPT_GEN( jr200_irq ) |
| r8758 | r8759 | |
| 375 | 399 | MDRV_CPU_ADD("maincpu", M6802, 890000) /* MN1800A */ |
| 376 | 400 | MDRV_CPU_PROGRAM_MAP(jr200_mem) |
| 377 | 401 | MDRV_CPU_IO_MAP(jr200_io) |
| 378 | | // MDRV_CPU_VBLANK_INT("screen", jr200_irq) |
| 402 | MDRV_CPU_VBLANK_INT("screen", jr200_irq) |
| 379 | 403 | MDRV_CPU_PERIODIC_INT(jr200_nmi,20) |
| 380 | | MDRV_CPU_PERIODIC_INT(jr200_irq,20) |
| 381 | | /* |
| 382 | | MDRV_CPU_ADD("mn1544", MN1544, ?) |
| 383 | | */ |
| 404 | // MDRV_CPU_PERIODIC_INT(jr200_irq,20) |
| 405 | |
| 406 | // MDRV_CPU_ADD("mn1544", MN1544, ?) |
| 407 | |
| 408 | MDRV_MACHINE_START(jr200) |
| 384 | 409 | MDRV_MACHINE_RESET(jr200) |
| 385 | 410 | |
| 386 | 411 | /* video hardware */ |
| 387 | 412 | MDRV_SCREEN_ADD("screen", RASTER) |
| 388 | | MDRV_SCREEN_REFRESH_RATE(50) |
| 413 | MDRV_SCREEN_REFRESH_RATE(60) |
| 389 | 414 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 390 | 415 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 391 | 416 | MDRV_SCREEN_SIZE(16 + 256 + 16, 16 + 192 + 16) /* border size not accurate */ |
| r8758 | r8759 | |
| 394 | 419 | MDRV_GFXDECODE(jr200) |
| 395 | 420 | MDRV_PALETTE_LENGTH(128) |
| 396 | 421 | MDRV_PALETTE_INIT(jr200) |
| 422 | |
| 397 | 423 | MDRV_VIDEO_START(jr200) |
| 398 | 424 | MDRV_VIDEO_UPDATE(jr200) |
| 425 | |
| 426 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 427 | |
| 428 | // AY-8910 ? |
| 429 | |
| 430 | MDRV_SOUND_ADD("beeper", BEEP, 0) |
| 431 | MDRV_SOUND_ROUTE(ALL_OUTPUTS,"mono",0.50) |
| 399 | 432 | MACHINE_DRIVER_END |
| 400 | 433 | |
| 401 | | |
| 402 | 434 | |
| 435 | |
| 403 | 436 | /* ROM definition */ |
| 404 | 437 | ROM_START( jr200 ) |
| 405 | 438 | ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF ) |