src/mess/drivers/pk8000.c
| r5339 | r5340 | |
| 14 | 14 | #include "formats/fmsx_cas.h" |
| 15 | 15 | #include "sound/speaker.h" |
| 16 | 16 | #include "sound/wave.h" |
| 17 | #include "includes/pk8000.h" |
| 17 | 18 | |
| 18 | | static UINT8 pk8000_text_start; |
| 19 | | static UINT8 pk8000_chargen_start; |
| 20 | | static UINT8 pk8000_video_start; |
| 21 | | static UINT8 pk8000_color_start; |
| 22 | | |
| 23 | | static UINT8 pk8000_video_mode; |
| 24 | | static UINT8 pk8000_video_color; |
| 25 | | static UINT8 pk8000_color[32]; |
| 26 | | static UINT8 pk8000_video_enable; |
| 27 | | |
| 28 | 19 | static UINT8 keyboard_line; |
| 29 | 20 | |
| 30 | 21 | static const device_config *cassette_device_image(running_machine *machine) |
| r5339 | r5340 | |
| 150 | 141 | DEVCB_HANDLER(pk8000_84_portc_w) |
| 151 | 142 | }; |
| 152 | 143 | |
| 153 | | static READ8_HANDLER(pk8000_video_color_r) |
| 154 | | { |
| 155 | | return pk8000_video_color; |
| 156 | | } |
| 157 | | |
| 158 | | static WRITE8_HANDLER(pk8000_video_color_w) |
| 159 | | { |
| 160 | | pk8000_video_color = data; |
| 161 | | } |
| 162 | | |
| 163 | | static READ8_HANDLER(pk8000_text_start_r) |
| 164 | | { |
| 165 | | return pk8000_text_start; |
| 166 | | } |
| 167 | | static WRITE8_HANDLER(pk8000_text_start_w) |
| 168 | | { |
| 169 | | pk8000_text_start = data; |
| 170 | | } |
| 171 | | static READ8_HANDLER(pk8000_chargen_start_r) |
| 172 | | { |
| 173 | | return pk8000_chargen_start; |
| 174 | | } |
| 175 | | static WRITE8_HANDLER(pk8000_chargen_start_w) |
| 176 | | { |
| 177 | | pk8000_chargen_start = data; |
| 178 | | } |
| 179 | | static READ8_HANDLER(pk8000_video_start_r) |
| 180 | | { |
| 181 | | return pk8000_video_start; |
| 182 | | } |
| 183 | | static WRITE8_HANDLER(pk8000_video_start_w) |
| 184 | | { |
| 185 | | pk8000_video_start = data; |
| 186 | | } |
| 187 | | static READ8_HANDLER(pk8000_color_start_r) |
| 188 | | { |
| 189 | | return pk8000_color_start; |
| 190 | | } |
| 191 | | static WRITE8_HANDLER(pk8000_color_start_w) |
| 192 | | { |
| 193 | | pk8000_color_start = data; |
| 194 | | } |
| 195 | | |
| 196 | | static READ8_HANDLER(pk8000_color_r) |
| 197 | | { |
| 198 | | return pk8000_color[offset]; |
| 199 | | } |
| 200 | | static WRITE8_HANDLER(pk8000_color_w) |
| 201 | | { |
| 202 | | pk8000_color[offset] = data; |
| 203 | | } |
| 204 | | |
| 205 | 144 | static READ8_HANDLER(pk8000_joy_1_r) |
| 206 | 145 | { |
| 207 | 146 | UINT8 retVal = (cassette_input(cassette_device_image(space->machine)) > 0.0038 ? 0x80 : 0); |
| r5339 | r5340 | |
| 372 | 311 | |
| 373 | 312 | static VIDEO_UPDATE( pk8000 ) |
| 374 | 313 | { |
| 375 | | int x,y,j,b; |
| 376 | | UINT16 offset = (pk8000_video_mode & 0xc0) << 8; |
| 377 | | rectangle my_rect; |
| 378 | | my_rect.min_x = 0; |
| 379 | | my_rect.max_x = 256+32-1; |
| 380 | | my_rect.min_y = 0; |
| 381 | | my_rect.max_y = 192+32-1; |
| 382 | | |
| 383 | | if (pk8000_video_enable) { |
| 384 | | bitmap_fill(bitmap, &my_rect, (pk8000_video_color >> 4) & 0x0f); |
| 385 | | |
| 386 | | if (BIT(pk8000_video_mode,4)==0){ |
| 387 | | // Text mode |
| 388 | | if (BIT(pk8000_video_mode,5)==0){ |
| 389 | | // 32 columns |
| 390 | | for (y = 0; y < 24; y++) |
| 391 | | { |
| 392 | | for (x = 0; x < 32; x++) |
| 393 | | { |
| 394 | | UINT8 chr = mess_ram[x +(y*32) + ((pk8000_text_start & 0x0f) << 10)+offset] ; |
| 395 | | UINT8 color= pk8000_color[chr>>3]; |
| 396 | | for (j = 0; j < 8; j++) { |
| 397 | | UINT8 code = mess_ram[((chr<<3) + j) + ((pk8000_chargen_start & 0x0e) << 10)+offset]; |
| 398 | | |
| 399 | | for (b = 0; b < 8; b++) |
| 400 | | { |
| 401 | | UINT8 col = (code >> b) & 0x01 ? (color & 0x0f) : ((color>>4) & 0x0f); |
| 402 | | *BITMAP_ADDR16(bitmap, (y*8)+j+16, x*8+(7-b)+16) = col; |
| 403 | | } |
| 404 | | } |
| 405 | | } |
| 406 | | } |
| 407 | | } else { |
| 408 | | // 40 columns |
| 409 | | for (y = 0; y < 24; y++) |
| 410 | | { |
| 411 | | for (x = 0; x < 42; x++) |
| 412 | | { |
| 413 | | UINT8 chr = mess_ram[x +(y*64) + ((pk8000_text_start & 0x0e) << 10)+offset] ; |
| 414 | | for (j = 0; j < 8; j++) { |
| 415 | | UINT8 code = mess_ram[((chr<<3) + j) + ((pk8000_chargen_start & 0x0e) << 10)+offset]; |
| 416 | | for (b = 2; b < 8; b++) |
| 417 | | { |
| 418 | | UINT8 col = ((code >> b) & 0x01) ? (pk8000_video_color) & 0x0f : (pk8000_video_color>>4) & 0x0f; |
| 419 | | *BITMAP_ADDR16(bitmap, (y*8)+j+16, x*6+(7-b)+16+8) = col; |
| 420 | | } |
| 421 | | } |
| 422 | | } |
| 423 | | } |
| 424 | | } |
| 425 | | } else { |
| 426 | | //Graphics |
| 427 | | for (y = 0; y < 24; y++) |
| 428 | | { |
| 429 | | UINT16 off_color = (((~pk8000_color_start) & 0x08) << 10)+offset + ((y>>3)<<11); |
| 430 | | UINT16 off_code = (((~pk8000_video_start) & 0x08) << 10)+offset + ((y>>3)<<11); |
| 431 | | for (x = 0; x < 32; x++) |
| 432 | | { |
| 433 | | UINT8 chr = mess_ram[x +(y*32) + ((pk8000_chargen_start & 0x0e) << 10)+offset] ; |
| 434 | | for (j = 0; j < 8; j++) { |
| 435 | | UINT8 color= mess_ram[((chr<<3) + j)+off_color]; |
| 436 | | UINT8 code = mess_ram[((chr<<3) + j)+off_code]; |
| 437 | | |
| 438 | | for (b = 0; b < 8; b++) |
| 439 | | { |
| 440 | | UINT8 col = (code >> b) & 0x01 ? (color & 0x0f) : ((color>>4) & 0x0f); |
| 441 | | *BITMAP_ADDR16(bitmap, (y*8)+j+16, x*8+(7-b)+16) = col; |
| 442 | | } |
| 443 | | } |
| 444 | | } |
| 445 | | } |
| 446 | | } |
| 447 | | } else { |
| 448 | | // Disabled video |
| 449 | | bitmap_fill(bitmap, &my_rect, 0); |
| 450 | | } |
| 451 | | return 0; |
| 314 | return pk8000_video_update(screen, bitmap, cliprect, memory_region(screen->machine, "maincpu")); |
| 452 | 315 | } |
| 453 | 316 | |
| 454 | | static const rgb_t pk8000_palette[16] = { |
| 455 | | MAKE_RGB(0x00, 0x00, 0x00), // 0 |
| 456 | | MAKE_RGB(0x00, 0x00, 0x00), // 1 |
| 457 | | MAKE_RGB(0x00, 0xc0, 0x00), // 2 |
| 458 | | MAKE_RGB(0x00, 0xff, 0x00), // 3 |
| 459 | | MAKE_RGB(0x00, 0x00, 0xc0), // 4 |
| 460 | | MAKE_RGB(0x00, 0x00, 0xff), // 5 |
| 461 | | MAKE_RGB(0x00, 0xc0, 0xc0), // 6 |
| 462 | | MAKE_RGB(0x00, 0xff, 0xff), // 7 |
| 463 | | MAKE_RGB(0xc0, 0x00, 0x00), // 8 |
| 464 | | MAKE_RGB(0xff, 0x00, 0x00), // 9 |
| 465 | | MAKE_RGB(0xc0, 0xc0, 0x00), // A |
| 466 | | MAKE_RGB(0xff, 0xff, 0x00), // B |
| 467 | | MAKE_RGB(0xc0, 0x00, 0xc0), // C |
| 468 | | MAKE_RGB(0xff, 0x00, 0xff), // D |
| 469 | | MAKE_RGB(0xc0, 0xc0, 0xc0), // E |
| 470 | | MAKE_RGB(0xff, 0xff, 0xff), // F |
| 471 | | }; |
| 472 | | |
| 473 | | PALETTE_INIT( pk8000 ) |
| 474 | | { |
| 475 | | palette_set_colors(machine, 0, pk8000_palette, ARRAY_LENGTH(pk8000_palette)); |
| 476 | | } |
| 477 | | |
| 478 | 317 | /* Machine driver */ |
| 479 | 318 | static const cassette_config pk8000_cassette_config = |
| 480 | 319 | { |