src/mess/video/intv.c
| r1783 | r1784 | |
| 1 | 1 | #include "driver.h" |
| 2 | | #include "deprecat.h" |
| 3 | 2 | #include "includes/intv.h" |
| 4 | 3 | #include "video/stic.h" |
| 5 | | #include "mslegacy.h" |
| 6 | 4 | |
| 5 | |
| 7 | 6 | #define FOREGROUND_BIT 0x0010 |
| 8 | 7 | |
| 9 | 8 | INLINE void intv_plot_pixel(bitmap_t *bitmap, int x, int y, UINT32 color) |
| r1783 | r1784 | |
| 205 | 204 | } |
| 206 | 205 | } |
| 207 | 206 | |
| 208 | | static void render_line(mame_bitmap *bitmap, UINT8 nextByte, UINT16 x, UINT16 y, |
| 209 | | UINT8 fgcolor, UINT8 bgcolor) |
| 207 | static void render_line(running_machine *machine, mame_bitmap *bitmap, |
| 208 | UINT8 nextByte, UINT16 x, UINT16 y, UINT8 fgcolor, UINT8 bgcolor) |
| 210 | 209 | { |
| 211 | | UINT32 color = (nextByte & 0x80 ? Machine->pens[fgcolor] |
| 212 | | : Machine->pens[bgcolor]); |
| 210 | UINT32 color = (nextByte & 0x80 ? machine->pens[fgcolor] |
| 211 | : machine->pens[bgcolor]); |
| 213 | 212 | intv_plot_pixel(bitmap, x, y, color); |
| 214 | 213 | intv_plot_pixel(bitmap, x+1, y, color); |
| 215 | 214 | intv_plot_pixel(bitmap, x, y+1, color); |
| 216 | 215 | intv_plot_pixel(bitmap, x+1, y+1, color); |
| 217 | 216 | |
| 218 | | color = (nextByte & 0x40 ? Machine->pens[fgcolor] |
| 219 | | : Machine->pens[bgcolor]); |
| 217 | color = (nextByte & 0x40 ? machine->pens[fgcolor] |
| 218 | : machine->pens[bgcolor]); |
| 220 | 219 | intv_plot_pixel(bitmap, x+2, y, color); |
| 221 | 220 | intv_plot_pixel(bitmap, x+3, y, color); |
| 222 | 221 | intv_plot_pixel(bitmap, x+2, y+1, color); |
| 223 | 222 | intv_plot_pixel(bitmap, x+3, y+1, color); |
| 224 | 223 | |
| 225 | | color = (nextByte & 0x20 ? Machine->pens[fgcolor] |
| 226 | | : Machine->pens[bgcolor]); |
| 224 | color = (nextByte & 0x20 ? machine->pens[fgcolor] |
| 225 | : machine->pens[bgcolor]); |
| 227 | 226 | intv_plot_pixel(bitmap, x+4, y, color); |
| 228 | 227 | intv_plot_pixel(bitmap, x+5, y, color); |
| 229 | 228 | intv_plot_pixel(bitmap, x+4, y+1, color); |
| 230 | 229 | intv_plot_pixel(bitmap, x+5, y+1, color); |
| 231 | 230 | |
| 232 | | color = (nextByte & 0x10 ? Machine->pens[fgcolor] |
| 233 | | : Machine->pens[bgcolor]); |
| 231 | color = (nextByte & 0x10 ? machine->pens[fgcolor] |
| 232 | : machine->pens[bgcolor]); |
| 234 | 233 | intv_plot_pixel(bitmap, x+6, y, color); |
| 235 | 234 | intv_plot_pixel(bitmap, x+7, y, color); |
| 236 | 235 | intv_plot_pixel(bitmap, x+6, y+1, color); |
| 237 | 236 | intv_plot_pixel(bitmap, x+7, y+1, color); |
| 238 | 237 | |
| 239 | | color = (nextByte & 0x08 ? Machine->pens[fgcolor] |
| 240 | | : Machine->pens[bgcolor]); |
| 238 | color = (nextByte & 0x08 ? machine->pens[fgcolor] |
| 239 | : machine->pens[bgcolor]); |
| 241 | 240 | intv_plot_pixel(bitmap, x+8, y, color); |
| 242 | 241 | intv_plot_pixel(bitmap, x+9, y, color); |
| 243 | 242 | intv_plot_pixel(bitmap, x+8, y+1, color); |
| 244 | 243 | intv_plot_pixel(bitmap, x+9, y+1, color); |
| 245 | 244 | |
| 246 | | color = (nextByte & 0x04 ? Machine->pens[fgcolor] |
| 247 | | : Machine->pens[bgcolor]); |
| 245 | color = (nextByte & 0x04 ? machine->pens[fgcolor] |
| 246 | : machine->pens[bgcolor]); |
| 248 | 247 | intv_plot_pixel(bitmap, x+10, y, color); |
| 249 | 248 | intv_plot_pixel(bitmap, x+11, y, color); |
| 250 | 249 | intv_plot_pixel(bitmap, x+10, y+1, color); |
| 251 | 250 | intv_plot_pixel(bitmap, x+11, y+1, color); |
| 252 | 251 | |
| 253 | | color = (nextByte & 0x02 ? Machine->pens[fgcolor] |
| 254 | | : Machine->pens[bgcolor]); |
| 252 | color = (nextByte & 0x02 ? machine->pens[fgcolor] |
| 253 | : machine->pens[bgcolor]); |
| 255 | 254 | intv_plot_pixel(bitmap, x+12, y, color); |
| 256 | 255 | intv_plot_pixel(bitmap, x+13, y, color); |
| 257 | 256 | intv_plot_pixel(bitmap, x+12, y+1, color); |
| 258 | 257 | intv_plot_pixel(bitmap, x+13, y+1, color); |
| 259 | 258 | |
| 260 | | color = (nextByte & 0x01 ? Machine->pens[fgcolor] |
| 261 | | : Machine->pens[bgcolor]); |
| 259 | color = (nextByte & 0x01 ? machine->pens[fgcolor] |
| 260 | : machine->pens[bgcolor]); |
| 262 | 261 | intv_plot_pixel(bitmap, x+14, y, color); |
| 263 | 262 | intv_plot_pixel(bitmap, x+15, y, color); |
| 264 | 263 | intv_plot_pixel(bitmap, x+14, y+1, color); |
| 265 | 264 | intv_plot_pixel(bitmap, x+15, y+1, color); |
| 266 | 265 | } |
| 267 | 266 | |
| 268 | | static void render_colored_squares(mame_bitmap *bitmap, UINT16 x, UINT16 y, |
| 269 | | UINT8 color0, UINT8 color1, UINT8 color2, UINT8 color3) |
| 267 | static void render_colored_squares(running_machine *machine, mame_bitmap *bitmap, |
| 268 | UINT16 x, UINT16 y, UINT8 color0, UINT8 color1, UINT8 color2, UINT8 color3) |
| 270 | 269 | { |
| 271 | | plot_box(bitmap, x, y, 8, 8, Machine->pens[color0]); |
| 272 | | plot_box(bitmap, x+8, y, 8, 8, Machine->pens[color1]); |
| 273 | | plot_box(bitmap, x, y+8, 8, 8, Machine->pens[color2]); |
| 274 | | plot_box(bitmap, x+8, y+8, 8, 8, Machine->pens[color3]); |
| 270 | plot_box(bitmap, x, y, 8, 8, machine->pens[color0]); |
| 271 | plot_box(bitmap, x+8, y, 8, 8, machine->pens[color1]); |
| 272 | plot_box(bitmap, x, y+8, 8, 8, machine->pens[color2]); |
| 273 | plot_box(bitmap, x+8, y+8, 8, 8, machine->pens[color3]); |
| 275 | 274 | } |
| 276 | 275 | |
| 277 | | static void render_color_stack_mode(mame_bitmap *bitmap) |
| 276 | static void render_color_stack_mode(running_machine *machine, mame_bitmap *bitmap) |
| 278 | 277 | { |
| 279 | 278 | UINT8 h, csPtr = 0, nexty = 0; |
| 280 | 279 | UINT16 nextCard, nextx = 0; |
| r1783 | r1784 | |
| 289 | 288 | UINT8 color2 = (nextCard & 0x01C0) >> 6; |
| 290 | 289 | UINT8 color3 = ((nextCard & 0x2000) >> 11) | |
| 291 | 290 | ((nextCard & 0x0600) >> 9); |
| 292 | | render_colored_squares(bitmap, nextx, nexty, |
| 291 | render_colored_squares(machine, bitmap, nextx, nexty, |
| 293 | 292 | (color0 == 7 ? csColor : (color0 | FOREGROUND_BIT)), |
| 294 | 293 | (color1 == 7 ? csColor : (color1 | FOREGROUND_BIT)), |
| 295 | 294 | (color2 == 7 ? csColor : (color2 | FOREGROUND_BIT)), |
| r1783 | r1784 | |
| 314 | 313 | memoryLocation = 0x3000 + (nextCard & 0x07F8); |
| 315 | 314 | memory = memory_region(REGION_CPU1); |
| 316 | 315 | for (j = 0; j < 16; j+=2) |
| 317 | | render_line(bitmap, memory[(memoryLocation<<1)+j], |
| 316 | render_line(machine, bitmap, memory[(memoryLocation<<1)+j], |
| 318 | 317 | nextx, nexty+j, fgcolor, bgcolor); |
| 319 | 318 | } |
| 320 | 319 | else { |
| 321 | 320 | memoryLocation = (nextCard & 0x01F8); |
| 322 | 321 | memory = intv_gram; |
| 323 | 322 | for (j = 0; j < 16; j+=2) |
| 324 | | render_line(bitmap, memory[memoryLocation+(j>>1)], |
| 323 | render_line(machine, bitmap, memory[memoryLocation+(j>>1)], |
| 325 | 324 | nextx, nexty+j, fgcolor, bgcolor); |
| 326 | 325 | } |
| 327 | 326 | } |
| r1783 | r1784 | |
| 333 | 332 | } |
| 334 | 333 | } |
| 335 | 334 | |
| 336 | | static void render_fg_bg_mode(mame_bitmap *bitmap) |
| 335 | static void render_fg_bg_mode(running_machine *machine, mame_bitmap *bitmap) |
| 337 | 336 | { |
| 338 | 337 | UINT8 i, j, isGrom, fgcolor, bgcolor, nexty = 0; |
| 339 | 338 | UINT16 nextCard, memoryLocation, nextx = 0; |
| r1783 | r1784 | |
| 350 | 349 | memoryLocation = 0x3000 + (nextCard & 0x01F8); |
| 351 | 350 | memory = memory_region(REGION_CPU1); |
| 352 | 351 | for (j = 0; j < 16; j+=2) |
| 353 | | render_line(bitmap, memory[(memoryLocation<<1)+j], |
| 352 | render_line(machine, bitmap, memory[(memoryLocation<<1)+j], |
| 354 | 353 | nextx, nexty+j, fgcolor, bgcolor); |
| 355 | 354 | } |
| 356 | 355 | else { |
| 357 | 356 | memoryLocation = (nextCard & 0x01F8); |
| 358 | 357 | memory = intv_gram; |
| 359 | 358 | for (j = 0; j < 16; j+=2) |
| 360 | | render_line(bitmap, memory[memoryLocation+(j>>1)], |
| 359 | render_line(machine, bitmap, memory[memoryLocation+(j>>1)], |
| 361 | 360 | nextx, nexty+j, fgcolor, bgcolor); |
| 362 | 361 | } |
| 363 | 362 | |
| r1783 | r1784 | |
| 369 | 368 | } |
| 370 | 369 | } |
| 371 | 370 | |
| 372 | | static void copy_sprites_to_background(mame_bitmap *bitmap) |
| 371 | static void copy_sprites_to_background(running_machine *machine, mame_bitmap *bitmap) |
| 373 | 372 | { |
| 374 | 373 | UINT8 width, currentPixel; |
| 375 | 374 | UINT8 borderCollision, foregroundCollision; |
| r1783 | r1784 | |
| 419 | 418 | } |
| 420 | 419 | |
| 421 | 420 | if (s->visible) { |
| 422 | | intv_plot_pixel(bitmap, nextX, nextY, Machine->pens[s->color] | |
| 421 | intv_plot_pixel(bitmap, nextX, nextY, machine->pens[s->color] | |
| 423 | 422 | (currentPixel & FOREGROUND_BIT)); |
| 424 | | intv_plot_pixel(bitmap, nextX+1, nextY, Machine->pens[s->color] | |
| 423 | intv_plot_pixel(bitmap, nextX+1, nextY, machine->pens[s->color] | |
| 425 | 424 | (currentPixel & FOREGROUND_BIT)); |
| 426 | 425 | } |
| 427 | 426 | } |
| r1783 | r1784 | |
| 438 | 437 | } |
| 439 | 438 | } |
| 440 | 439 | |
| 441 | | static void render_background(mame_bitmap *bitmap) |
| 440 | static void render_background(running_machine *machine, mame_bitmap *bitmap) |
| 442 | 441 | { |
| 443 | 442 | if (intv_color_stack_mode) |
| 444 | | render_color_stack_mode(bitmap); |
| 443 | render_color_stack_mode(machine, bitmap); |
| 445 | 444 | else |
| 446 | | render_fg_bg_mode(bitmap); |
| 445 | render_fg_bg_mode(machine, bitmap); |
| 447 | 446 | } |
| 448 | 447 | |
| 449 | 448 | /* |
| r1783 | r1784 | |
| 700 | 699 | } |
| 701 | 700 | */ |
| 702 | 701 | |
| 703 | | static void draw_borders(mame_bitmap *bm) |
| 702 | static void draw_borders(running_machine *machine, mame_bitmap *bm) |
| 704 | 703 | { |
| 705 | 704 | if (intv_left_edge_inhibit) |
| 706 | 705 | { |
| 707 | | plot_box(bm,0,0,16-intv_col_delay*2,16*12,Machine->pens[intv_border_color]); |
| 706 | plot_box(bm, 0, 0, 16-intv_col_delay*2, 16*12, |
| 707 | machine->pens[intv_border_color]); |
| 708 | 708 | } |
| 709 | 709 | if (intv_top_edge_inhibit) |
| 710 | 710 | { |
| 711 | | plot_box(bm,0,0,16*20,16-intv_row_delay*2,Machine->pens[intv_border_color]); |
| 711 | plot_box(bm, 0, 0, 16*20, 16-intv_row_delay*2, |
| 712 | machine->pens[intv_border_color]); |
| 712 | 713 | } |
| 713 | 714 | } |
| 714 | 715 | |
| 715 | 716 | static int col_delay = 0; |
| 716 | 717 | static int row_delay = 0; |
| 717 | 718 | |
| 718 | | void stic_screenrefresh() |
| 719 | void stic_screenrefresh(running_machine *machine) |
| 719 | 720 | { |
| 720 | 721 | int i; |
| 721 | 722 | |
| r1783 | r1784 | |
| 723 | 724 | { |
| 724 | 725 | intv_stic_handshake = 0; |
| 725 | 726 | // Render the background |
| 726 | | render_background(tmpbitmap); |
| 727 | render_background(machine, tmpbitmap); |
| 727 | 728 | // Render the sprites into their buffers |
| 728 | 729 | render_sprites(); |
| 729 | 730 | for (i = 0; i < 8; i++) |
| 730 | 731 | intv_sprite[i].collision = 0; |
| 731 | 732 | // Copy the sprites to the background |
| 732 | | copy_sprites_to_background(tmpbitmap); |
| 733 | copy_sprites_to_background(machine, tmpbitmap); |
| 733 | 734 | determine_sprite_collisions(); |
| 734 | 735 | for (i = 0; i < 8; i++) |
| 735 | 736 | intv_collision_registers[i] |= intv_sprite[i].collision; |
| 736 | 737 | /* draw the screen borders if enabled */ |
| 737 | | draw_borders(tmpbitmap); |
| 738 | draw_borders(machine, tmpbitmap); |
| 738 | 739 | } |
| 739 | 740 | else |
| 740 | 741 | { |
| 741 | 742 | /* STIC disabled, just fill with border color */ |
| 742 | | fillbitmap(tmpbitmap,Machine->pens[intv_border_color],&Machine->screen[0].visarea); |
| 743 | fillbitmap(tmpbitmap, machine->pens[intv_border_color], &machine->screen[0].visarea); |
| 743 | 744 | } |
| 744 | 745 | col_delay = intv_col_delay; |
| 745 | 746 | row_delay = intv_row_delay; |
| 746 | 747 | } |
| 747 | 748 | |
| 748 | | VIDEO_UPDATE( intv ) |
| 749 | | { |
| 750 | | copybitmap(bitmap,tmpbitmap,0,0, |
| 751 | | col_delay*2,row_delay*2, |
| 752 | | cliprect); |
| 753 | | return 0; |
| 754 | | } |
| 755 | 749 | |
| 756 | 750 | VIDEO_START( intvkbd ) |
| 757 | 751 | { |
| 758 | | VIDEO_START_CALL(generic); |
| 759 | | video_start_intv(machine); |
| 752 | VIDEO_START_CALL(generic_bitmapped); |
| 753 | VIDEO_START_CALL(intv); |
| 760 | 754 | } |
| 761 | 755 | |
| 756 | |
| 762 | 757 | /* very rudimentary support for the tms9927 character generator IC */ |
| 763 | 758 | |
| 764 | 759 | static UINT8 tms9927_cursor_col; |
| r1783 | r1784 | |
| 819 | 814 | // char c; |
| 820 | 815 | |
| 821 | 816 | /* Draw the underlying INTV screen first */ |
| 822 | | VIDEO_UPDATE_CALL(intv); |
| 817 | VIDEO_UPDATE_CALL(generic_bitmapped); |
| 823 | 818 | |
| 824 | 819 | /* if the intvkbd text is not blanked, overlay it */ |
| 825 | 820 | if (!intvkbd_text_blanked) |