src/mess/video/kc.c
| r1937 | r1938 | |
| 9 | 9 | #include "driver.h" |
| 10 | 10 | #include "includes/kc.h" |
| 11 | 11 | #include "eventlst.h" |
| 12 | | #include "deprecat.h" |
| 13 | | #include "mslegacy.h" |
| 14 | 12 | |
| 15 | 13 | /* KC85/4 and KC85/3 common graphics hardware */ |
| 16 | 14 | |
| r1937 | r1938 | |
| 96 | 94 | /* Initialise the palette */ |
| 97 | 95 | PALETTE_INIT( kc85 ) |
| 98 | 96 | { |
| 99 | | palette_set_colors_rgb(machine, 0, kc85_palette, sizeof(kc85_palette) / 3); |
| 97 | int i; |
| 98 | |
| 99 | for ( i = 0; i < sizeof(kc85_palette) / 3; i++ ) { |
| 100 | palette_set_color_rgb(machine, i, kc85_palette[i*3], kc85_palette[i*3+1], kc85_palette[i*3+2]); |
| 101 | } |
| 100 | 102 | } |
| 101 | 103 | |
| 102 | 104 | static int kc85_blink_state; |
| r1937 | r1938 | |
| 114 | 116 | |
| 115 | 117 | |
| 116 | 118 | /* draw 8 pixels */ |
| 117 | | static void kc85_draw_8_pixels(bitmap_t *bitmap,int x,int y, unsigned char colour_byte, unsigned char gfx_byte) |
| 119 | static void kc85_draw_8_pixels(running_machine *machine, bitmap_t *bitmap,int x,int y, unsigned char colour_byte, unsigned char gfx_byte) |
| 118 | 120 | { |
| 119 | 121 | int a; |
| 120 | 122 | int background_pen; |
| r1937 | r1938 | |
| 142 | 144 | foreground_pen = background_pen; |
| 143 | 145 | } |
| 144 | 146 | |
| 145 | | pens[0] = Machine->pens[background_pen]; |
| 146 | | pens[1] = Machine->pens[foreground_pen]; |
| 147 | pens[0] = machine->pens[background_pen]; |
| 148 | pens[1] = machine->pens[foreground_pen]; |
| 147 | 149 | |
| 148 | 150 | px = x; |
| 149 | 151 | |
| r1937 | r1938 | |
| 286 | 288 | |
| 287 | 289 | /* process visible cycles within a line */ |
| 288 | 290 | /* the cycles will never span over the end of a line */ |
| 289 | | static void kc85_common_process_cycles(struct video_update_state *video_update, int cycles) |
| 291 | static void kc85_common_process_cycles(running_machine *machine, struct video_update_state *video_update, int cycles) |
| 290 | 292 | { |
| 291 | 293 | while (cycles!=0) |
| 292 | 294 | { |
| r1937 | r1938 | |
| 320 | 322 | /* grab colour and pixel information */ |
| 321 | 323 | video_update->pixel_grab_callback(&video_update->grab_data,video_update->x,video_update->y,&colour_byte, &gfx_byte); |
| 322 | 324 | /* draw to screen */ |
| 323 | | kc85_draw_8_pixels(video_update->bitmap, video_update->render_x, video_update->render_y,colour_byte, gfx_byte); |
| 325 | kc85_draw_8_pixels(machine, video_update->bitmap, video_update->render_x, video_update->render_y,colour_byte, gfx_byte); |
| 324 | 326 | /* update render coordinate */ |
| 325 | 327 | video_update->render_x+=8; |
| 326 | 328 | video_update->x++; |
| r1937 | r1938 | |
| 371 | 373 | } |
| 372 | 374 | |
| 373 | 375 | /* process a whole visible line */ |
| 374 | | static int kc85_common_vh_process_line(struct video_update_state *video_update, int cycles) |
| 376 | static int kc85_common_vh_process_line(running_machine *machine, struct video_update_state *video_update, int cycles) |
| 375 | 377 | { |
| 376 | 378 | int cycles_to_do; |
| 377 | 379 | |
| r1937 | r1938 | |
| 384 | 386 | //logerror("process line: cycles_to_do: %d\n",cycles_to_do); |
| 385 | 387 | |
| 386 | 388 | /* do the cycles - draw them */ |
| 387 | | kc85_common_process_cycles(video_update, cycles_to_do); |
| 389 | kc85_common_process_cycles(machine, video_update, cycles_to_do); |
| 388 | 390 | |
| 389 | 391 | video_update->horizontal.cycles_remaining -= cycles_to_do; |
| 390 | 392 | cycles -=cycles_to_do; |
| r1937 | r1938 | |
| 421 | 423 | return cycles; |
| 422 | 424 | } |
| 423 | 425 | |
| 424 | | static void kc85_common_vh_process_lines(struct video_update_state *video_update, int cycles) |
| 426 | static void kc85_common_vh_process_lines(running_machine *machine, struct video_update_state *video_update, int cycles) |
| 425 | 427 | { |
| 426 | 428 | while (cycles!=0) |
| 427 | 429 | { |
| r1937 | r1938 | |
| 449 | 451 | int cycles_remaining; |
| 450 | 452 | |
| 451 | 453 | /* update cycles with number of cycles not processed */ |
| 452 | | cycles_remaining = kc85_common_vh_process_line(video_update, cycles_to_do); |
| 454 | cycles_remaining = kc85_common_vh_process_line(machine, video_update, cycles_to_do); |
| 453 | 455 | |
| 454 | 456 | cycles_done = cycles_to_do - cycles_remaining; |
| 455 | 457 | |
| r1937 | r1938 | |
| 490 | 492 | |
| 491 | 493 | /* the kc85 screen is 320 pixels wide and 256 pixels tall */ |
| 492 | 494 | /* if we assume a 50hz display, there are 312 lines for the complete frame, leaving 56 lines not visible */ |
| 493 | | static void kc85_common_process_frame(bitmap_t *bitmap, void (*pixel_grab_callback)(struct grab_info *,int x,int y,unsigned char *, unsigned char *),struct grab_info *grab_data) |
| 495 | static void kc85_common_process_frame(running_machine *machine, bitmap_t *bitmap, void (*pixel_grab_callback)(struct grab_info *,int x,int y,unsigned char *, unsigned char *),struct grab_info *grab_data) |
| 494 | 496 | { |
| 495 | 497 | int cycles_remaining_in_frame = KC85_CYCLES_PER_FRAME; |
| 496 | 498 | |
| r1937 | r1938 | |
| 527 | 529 | delta_cycles = pItem->Event_Time - cycles_offset; |
| 528 | 530 | |
| 529 | 531 | //logerror("cycles between this event and next: %d\n",delta_cycles); |
| 530 | | kc85_common_vh_process_lines(&video_update, delta_cycles); |
| 532 | kc85_common_vh_process_lines(machine, &video_update, delta_cycles); |
| 531 | 533 | |
| 532 | 534 | /* update number of cycles remaining in frame */ |
| 533 | 535 | cycles_remaining_in_frame -= delta_cycles; |
| r1937 | r1938 | |
| 544 | 546 | |
| 545 | 547 | |
| 546 | 548 | /* process remainder */ |
| 547 | | kc85_common_vh_process_lines(&video_update, cycles_remaining_in_frame); |
| 549 | kc85_common_vh_process_lines(machine, &video_update, cycles_remaining_in_frame); |
| 548 | 550 | EventList_Reset(); |
| 549 | 551 | EventList_SetOffsetStartTime ( ATTOTIME_TO_CYCLES(0, attotime_mul(video_screen_get_scan_period(0), video_screen_get_vpos(0))) ); |
| 550 | 552 | } |
| r1937 | r1938 | |
| 671 | 673 | colour_byte = colour_ram[offset]; |
| 672 | 674 | gfx_byte = pixel_ram[offset]; |
| 673 | 675 | |
| 674 | | kc85_draw_8_pixels(bitmap,(x<<3),y, colour_byte, gfx_byte); |
| 676 | kc85_draw_8_pixels(machine, bitmap,(x<<3),y, colour_byte, gfx_byte); |
| 675 | 677 | |
| 676 | 678 | } |
| 677 | 679 | } |
| r1937 | r1938 | |
| 681 | 683 | grab_data.pixel_ram = kc85_4_display_video_ram; |
| 682 | 684 | grab_data.colour_ram = kc85_4_display_video_ram + 0x04000; |
| 683 | 685 | |
| 684 | | kc85_common_process_frame(bitmap, kc85_4_pixel_grab_callback,&grab_data); |
| 686 | kc85_common_process_frame(machine, bitmap, kc85_4_pixel_grab_callback,&grab_data); |
| 685 | 687 | |
| 686 | 688 | return 0; |
| 687 | 689 | } |
| r1937 | r1938 | |
| 768 | 770 | colour_byte = colour_ram[colour_offset]; |
| 769 | 771 | gfx_byte = pixel_ram[pixel_offset]; |
| 770 | 772 | |
| 771 | | kc85_draw_8_pixels(bitmap,(x<<3),y, colour_byte, gfx_byte); |
| 773 | kc85_draw_8_pixels(machine, bitmap,(x<<3),y, colour_byte, gfx_byte); |
| 772 | 774 | } |
| 773 | 775 | } |
| 774 | 776 | #endif |
| r1937 | r1938 | |
| 778 | 780 | grab_data.pixel_ram = mess_ram+0x08000; |
| 779 | 781 | grab_data.colour_ram = mess_ram+0x08000 + 0x02800; |
| 780 | 782 | |
| 781 | | kc85_common_process_frame(bitmap, kc85_3_pixel_grab_callback,&grab_data); |
| 783 | kc85_common_process_frame(machine, bitmap, kc85_3_pixel_grab_callback,&grab_data); |
| 782 | 784 | |
| 783 | 785 | return 0; |
| 784 | 786 | } |