src/mess/video/fmtowns.c
| r6707 | r6708 | |
| 101 | 101 | extern UINT32* towns_vram; |
| 102 | 102 | extern UINT8* towns_gfxvram; |
| 103 | 103 | extern UINT8* towns_txtvram; |
| 104 | extern UINT8* towns_sprram; |
| 104 | 105 | |
| 105 | 106 | extern UINT32 towns_mainmem_enable; |
| 106 | 107 | extern UINT32 towns_ankcg_enable; |
| r6707 | r6708 | |
| 388 | 389 | case 0x00: // 0x5c8 - disable TVRAM? |
| 389 | 390 | if(towns_tvram_enable != 0) |
| 390 | 391 | { |
| 391 | | //towns_tvram_enable = 0; |
| 392 | towns_tvram_enable = 0; |
| 392 | 393 | return 0x80; |
| 393 | 394 | } |
| 394 | 395 | else |
| r6707 | r6708 | |
| 487 | 488 | |
| 488 | 489 | /* |
| 489 | 490 | * Sprite RAM, low memory |
| 490 | | * Writing to 0xc8xxx or 0xcaxxx activates TVRAM mode |
| 491 | | * Writing to I/O port 0x5c8 disables TVRAM mode |
| 492 | | * (bit 7 returns high if TVRAM mode was previously active) |
| 491 | * Writing to 0xc8xxx or 0xcaxxx activates TVRAM |
| 492 | * Writing to I/O port 0x5c8 disables TVRAM |
| 493 | * (bit 7 returns high if TVRAM was previously active) |
| 493 | 494 | * |
| 494 | 495 | * In TVRAM mode: |
| 495 | 496 | * 0xc8000-0xc8fff: ASCII text (2 bytes each: ISO646 code, then attribute) |
| r6707 | r6708 | |
| 503 | 504 | if(offset < 0x1000) |
| 504 | 505 | { // 0xc8000-0xc8fff |
| 505 | 506 | if(towns_mainmem_enable == 0) |
| 506 | | return towns_txtvram[offset]; |
| 507 | { |
| 508 | if(towns_tvram_enable == 0) |
| 509 | return towns_sprram[offset]; |
| 510 | else |
| 511 | return towns_txtvram[offset]; |
| 512 | } |
| 507 | 513 | else |
| 508 | 514 | return RAM[offset + 0xc8000]; |
| 509 | 515 | } |
| r6707 | r6708 | |
| 517 | 523 | { |
| 518 | 524 | if(towns_ankcg_enable != 0 && offset < 0x2800) |
| 519 | 525 | return ROM[0x180000 + 0x3d000 + (offset-0x2000)]; |
| 520 | | return towns_txtvram[offset]; |
| 526 | if(towns_tvram_enable == 0) |
| 527 | return towns_sprram[offset]; |
| 528 | else |
| 529 | return towns_txtvram[offset]; |
| 521 | 530 | } |
| 522 | 531 | else |
| 523 | 532 | return RAM[offset + 0xca000]; |
| r6707 | r6708 | |
| 550 | 559 | } |
| 551 | 560 | } |
| 552 | 561 | |
| 562 | // Should this area return TVRAM if enabled? |
| 563 | READ8_HANDLER( towns_spriteram_r) |
| 564 | { |
| 565 | return towns_sprram[offset]; |
| 566 | } |
| 567 | |
| 568 | WRITE8_HANDLER( towns_spriteram_w) |
| 569 | { |
| 570 | towns_sprram[offset] = data; |
| 571 | } |
| 572 | |
| 553 | 573 | void towns_crtc_draw_scan_layer_hicolour(bitmap_t* bitmap,const rectangle* rect,int layer,int line,int scanline) |
| 554 | 574 | { |
| 555 | 575 | UINT32 off = 0; |
| r6707 | r6708 | |
| 694 | 714 | int x; |
| 695 | 715 | UINT8 colour; |
| 696 | 716 | int hzoom = 1; |
| 717 | int linesize; |
| 697 | 718 | |
| 698 | | if(towns_vram_page_sel != 0) |
| 699 | | off = 0x20000; |
| 719 | // if(towns_vram_page_sel != 0) |
| 720 | // off = 0x20000; |
| 721 | if(layer == 0) |
| 722 | linesize = towns_crtc_reg[20] * 4; |
| 723 | else |
| 724 | linesize = towns_crtc_reg[24] * 4; |
| 725 | |
| 700 | 726 | if(layer != 0) |
| 701 | 727 | { |
| 702 | 728 | if(!(towns_video_reg[0] & 0x10)) |
| 703 | 729 | return; |
| 704 | | off += 0x40000; |
| 705 | 730 | off += towns_crtc_reg[21]; // initial offset |
| 706 | 731 | if(towns_crtc_reg[27] & 0x0100) |
| 707 | 732 | hzoom = 2; |
| r6707 | r6708 | |
| 713 | 738 | hzoom = 2; |
| 714 | 739 | } |
| 715 | 740 | |
| 716 | | off += (line * ((rect->max_x - rect->min_x) / 2)); // offset at this scanline |
| 741 | off += line * linesize; |
| 717 | 742 | |
| 718 | 743 | if(hzoom == 1) |
| 719 | 744 | { |
| 720 | 745 | for(x=rect->min_x;x<rect->max_x;x+=2) |
| 721 | 746 | { |
| 722 | | colour = towns_gfxvram[off] >> 4; |
| 747 | colour = towns_gfxvram[off+(layer*0x40000)] >> 4; |
| 723 | 748 | if(colour != 0) |
| 724 | 749 | { |
| 725 | 750 | *BITMAP_ADDR32(bitmap,scanline,x+1) = |
| r6707 | r6708 | |
| 727 | 752 | | (towns_palette_g[colour] << 8) |
| 728 | 753 | | (towns_palette_b[colour]); |
| 729 | 754 | } |
| 730 | | colour = towns_gfxvram[off] & 0x0f; |
| 755 | colour = towns_gfxvram[off+(layer*0x40000)] & 0x0f; |
| 731 | 756 | if(colour != 0) |
| 732 | 757 | { |
| 733 | 758 | *BITMAP_ADDR32(bitmap,scanline,x) = |
| r6707 | r6708 | |
| 742 | 767 | { // x2 horizontal zoom |
| 743 | 768 | for(x=rect->min_x;x<rect->max_x;x+=4) |
| 744 | 769 | { |
| 745 | | colour = towns_gfxvram[off] >> 4; |
| 770 | if(towns_video_reg[0] & 0x10) |
| 771 | off &= 0x3ffff; // 2 layers |
| 772 | else |
| 773 | off &= 0x7ffff; // 1 layer |
| 774 | colour = towns_gfxvram[off+(layer*0x40000)] >> 4; |
| 746 | 775 | if(colour != 0) |
| 747 | 776 | { |
| 748 | 777 | *BITMAP_ADDR32(bitmap,scanline,x+2) = |
| r6707 | r6708 | |
| 754 | 783 | | (towns_palette_g[colour] << 8) |
| 755 | 784 | | (towns_palette_b[colour]); |
| 756 | 785 | } |
| 757 | | colour = towns_gfxvram[off] & 0x0f; |
| 786 | colour = towns_gfxvram[off+(layer*0x40000)] & 0x0f; |
| 758 | 787 | if(colour != 0) |
| 759 | 788 | { |
| 760 | 789 | *BITMAP_ADDR32(bitmap,scanline,x) = |
| r6707 | r6708 | |
| 871 | 900 | } |
| 872 | 901 | } |
| 873 | 902 | |
| 874 | | VIDEO_START( towns ) |
| 903 | void draw_text_layer(running_machine* machine,bitmap_t* bitmap, const rectangle* rect) |
| 875 | 904 | { |
| 876 | | towns_vram_wplane = 0x00; |
| 877 | | } |
| 878 | | |
| 879 | | VIDEO_UPDATE( towns ) |
| 880 | | { |
| 881 | | int x,y; |
| 882 | | UINT8 colour; |
| 883 | | UINT32 colourcode; |
| 884 | | UINT8 row; // JIS row number |
| 885 | | UINT16 code; |
| 886 | | int off = 0; |
| 887 | | |
| 888 | | bitmap_fill(bitmap,cliprect,0x00000000); |
| 889 | | |
| 890 | | if(!(towns_video_reg[1] & 0x01)) |
| 891 | | { |
| 892 | | if(!input_code_pressed(screen->machine,KEYCODE_Q)) |
| 893 | | towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1); |
| 894 | | if(!input_code_pressed(screen->machine,KEYCODE_W)) |
| 895 | | towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0); |
| 896 | | } |
| 897 | | else |
| 898 | | { |
| 899 | | if(!input_code_pressed(screen->machine,KEYCODE_Q)) |
| 900 | | towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0); |
| 901 | | if(!input_code_pressed(screen->machine,KEYCODE_W)) |
| 902 | | towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1); |
| 903 | | } |
| 904 | | |
| 905 | | |
| 906 | | // draw text layer |
| 907 | 905 | /* |
| 908 | 906 | * Text layer format |
| 909 | 907 | * 2 bytes per character at both 0xc8000 and 0xca000 |
| r6707 | r6708 | |
| 919 | 917 | * at this location. The character displayed is represented by a 2-byte |
| 920 | 918 | * JIS code at the same offset at 0xca000. |
| 921 | 919 | */ |
| 922 | | if(towns_tvram_enable != 0) |
| 920 | int x,y; |
| 921 | UINT8 colour; |
| 922 | UINT32 colourcode; |
| 923 | UINT8 row; // JIS row number |
| 924 | UINT16 code; |
| 925 | int off = 0; |
| 926 | |
| 927 | for(y=0;y<40;y++) |
| 923 | 928 | { |
| 924 | | for(y=0;y<40;y++) |
| 929 | off = 160 * y; |
| 930 | for(x=0;x<80;x++) |
| 925 | 931 | { |
| 926 | | off = 160 * y; |
| 927 | | for(x=0;x<80;x++) |
| 932 | colour = towns_txtvram[off+1] & 0x07; |
| 933 | if(towns_txtvram[off+1] & 0x20) |
| 934 | { // Bright |
| 935 | colourcode = (((colour & 0x02) ? 0xfe : 0x00) << 16) |
| 936 | | (((colour & 0x04) ? 0xfe : 0x00) << 8) |
| 937 | | ((colour & 0x01) ? 0xfe : 0x00); |
| 938 | } |
| 939 | else |
| 928 | 940 | { |
| 929 | | colour = towns_txtvram[off+1] & 0x07; |
| 930 | | if(towns_txtvram[off+1] & 0x20) |
| 931 | | { // Bright |
| 932 | | colourcode = (((colour & 0x02) ? 0xfe : 0x00) << 16) |
| 933 | | | (((colour & 0x04) ? 0xfe : 0x00) << 8) |
| 934 | | | ((colour & 0x01) ? 0xfe : 0x00); |
| 935 | | } |
| 936 | | else |
| 941 | colourcode = (((colour & 0x02) ? 0x7f : 0x00) << 16) |
| 942 | | (((colour & 0x04) ? 0x7f : 0x00) << 8) |
| 943 | | ((colour & 0x01) ? 0x7f : 0x00); |
| 944 | } |
| 945 | |
| 946 | if((towns_txtvram[off+1] & 0xc0) != 0) |
| 947 | { // double width |
| 948 | if(towns_txtvram[off+1] & 0x40) |
| 937 | 949 | { |
| 938 | | colourcode = (((colour & 0x02) ? 0x7f : 0x00) << 16) |
| 939 | | | (((colour & 0x04) ? 0x7f : 0x00) << 8) |
| 940 | | | ((colour & 0x01) ? 0x7f : 0x00); |
| 941 | | } |
| 942 | | |
| 943 | | if((towns_txtvram[off+1] & 0xc0) != 0) |
| 944 | | { // double width |
| 945 | | if(towns_txtvram[off+1] & 0x40) |
| 950 | row = (towns_txtvram[off+0x2000] - 32); |
| 951 | code = 0; |
| 952 | if(row <= 8) |
| 946 | 953 | { |
| 947 | | row = (towns_txtvram[off+0x2000] - 32); |
| 948 | | code = 0; |
| 949 | | if(row <= 8) |
| 950 | | { |
| 951 | | code = (row & 0x07) * 0x20; |
| 952 | | code += ((towns_txtvram[off+0x2001]-32) & 0x1f) |
| 953 | | | (((towns_txtvram[off+0x2001]-32) & 0x40) << 2) |
| 954 | | | (((towns_txtvram[off+0x2001]-32) & 0x20) << 4); |
| 955 | | } |
| 956 | | if(row >= 16) // Kanji |
| 957 | | { |
| 958 | | code = 0x400; |
| 959 | | code += ((towns_txtvram[off+0x2001]) & 0x1f) |
| 960 | | + (((towns_txtvram[off+0x2001]-32) & 0x60) << 4) |
| 961 | | + ((row & 0x0f) << 5) |
| 962 | | + (((row-16) & 0x70) * 0x60); |
| 963 | | } |
| 964 | | drawgfx_transpen_raw(bitmap,cliprect,screen->machine->gfx[1],code, |
| 965 | | colourcode, 0,0,towns_crtc_layerscr[0].min_x+(x*8),towns_crtc_layerscr[0].min_y+(y*16),0); |
| 954 | code = (row & 0x07) * 0x20; |
| 955 | code += ((towns_txtvram[off+0x2001]-32) & 0x1f) |
| 956 | | (((towns_txtvram[off+0x2001]-32) & 0x40) << 2) |
| 957 | | (((towns_txtvram[off+0x2001]-32) & 0x20) << 4); |
| 966 | 958 | } |
| 967 | | } |
| 968 | | else |
| 969 | | { |
| 970 | | drawgfx_transpen_raw(bitmap,cliprect,screen->machine->gfx[0],towns_txtvram[off], |
| 959 | if(row >= 16) // Kanji |
| 960 | { |
| 961 | code = 0x400; |
| 962 | code += ((towns_txtvram[off+0x2001]) & 0x1f) |
| 963 | + (((towns_txtvram[off+0x2001]-32) & 0x60) << 4) |
| 964 | + ((row & 0x0f) << 5) |
| 965 | + (((row-16) & 0x70) * 0x60); |
| 966 | } |
| 967 | drawgfx_transpen_raw(bitmap,rect,machine->gfx[1],code, |
| 971 | 968 | colourcode, 0,0,towns_crtc_layerscr[0].min_x+(x*8),towns_crtc_layerscr[0].min_y+(y*16),0); |
| 972 | 969 | } |
| 973 | | off += 2; |
| 974 | 970 | } |
| 971 | else |
| 972 | { |
| 973 | drawgfx_transpen_raw(bitmap,rect,machine->gfx[0],towns_txtvram[off], |
| 974 | colourcode, 0,0,towns_crtc_layerscr[0].min_x+(x*8),towns_crtc_layerscr[0].min_y+(y*16),0); |
| 975 | } |
| 976 | off += 2; |
| 975 | 977 | } |
| 976 | 978 | } |
| 979 | } |
| 977 | 980 | |
| 981 | VIDEO_START( towns ) |
| 982 | { |
| 983 | towns_vram_wplane = 0x00; |
| 984 | } |
| 985 | |
| 986 | VIDEO_UPDATE( towns ) |
| 987 | { |
| 988 | bitmap_fill(bitmap,cliprect,0x00000000); |
| 989 | |
| 990 | if(!(towns_video_reg[1] & 0x01)) |
| 991 | { |
| 992 | if(!input_code_pressed(screen->machine,KEYCODE_Q)) |
| 993 | towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1); |
| 994 | if(!input_code_pressed(screen->machine,KEYCODE_W)) |
| 995 | towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0); |
| 996 | } |
| 997 | else |
| 998 | { |
| 999 | if(!input_code_pressed(screen->machine,KEYCODE_Q)) |
| 1000 | towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0); |
| 1001 | if(!input_code_pressed(screen->machine,KEYCODE_W)) |
| 1002 | towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1); |
| 1003 | } |
| 1004 | |
| 1005 | draw_text_layer(screen->machine,bitmap,cliprect); |
| 1006 | |
| 978 | 1007 | #ifdef CRTC_REG_DISP |
| 979 | 1008 | popmessage("CRTC: %i %i %i %i %i %i %i %i %i\n%i %i %i %i | %i %i %i %i\n%i %i %i %i | %i %i %i %i\nZOOM: %04x\nVideo: %02x %02x\nText=%i", |
| 980 | 1009 | towns_crtc_reg[0],towns_crtc_reg[1],towns_crtc_reg[2],towns_crtc_reg[3], |