src/mame/machine/snes.c
| r5385 | r5386 | |
| 31 | 31 | static UINT8 vram_read_offset; /* VRAM read offset */ |
| 32 | 32 | UINT8 spc_port_in[4]; /* Port for sending data to the SPC700 */ |
| 33 | 33 | UINT8 spc_port_out[4]; /* Port for receiving data from the SPC700 */ |
| 34 | | static UINT8 ppu_last_scroll; /* as per Theme Park, this is shared by all scroll regs */ |
| 35 | 34 | static UINT8 snes_hdma_chnl; /* channels enabled for HDMA */ |
| 36 | 35 | static UINT8 joy1l, joy1h, joy2l, joy2h, joy3l, joy3h, joy4l, joy4h; |
| 37 | 36 | static UINT8 read_ophct = 0, read_opvct = 0; |
| r5385 | r5386 | |
| 340 | 339 | case CGDATA: |
| 341 | 340 | return snes_ram[offset]; |
| 342 | 341 | case MPYL: /* Multiplication result (low) */ |
| 342 | { |
| 343 | /* Perform 16bit * 8bit multiply */ |
| 344 | UINT32 c = snes_ppu.mode7.matrix_a * (INT8)(snes_ppu.mode7.matrix_b >> 8); |
| 345 | snes_ram[MPYL] = c & 0xff; |
| 346 | return snes_ram[MPYL]; |
| 347 | } |
| 343 | 348 | case MPYM: /* Multiplication result (mid) */ |
| 349 | { |
| 350 | /* Perform 16bit * 8bit multiply */ |
| 351 | UINT32 c = snes_ppu.mode7.matrix_a * (INT8)(snes_ppu.mode7.matrix_b >> 8); |
| 352 | snes_ram[MPYM] = (c >> 8) & 0xff; |
| 353 | return snes_ram[MPYM]; |
| 354 | } |
| 344 | 355 | case MPYH: /* Multiplication result (high) */ |
| 345 | 356 | { |
| 346 | 357 | /* Perform 16bit * 8bit multiply */ |
| 347 | | INT32 c = snes_ppu.mode7.matrix_a * (snes_ppu.mode7.matrix_b >> 8); |
| 348 | | snes_ram[MPYL] = c & 0xff; |
| 349 | | snes_ram[MPYM] = (c >> 8) & 0xff; |
| 358 | UINT32 c = snes_ppu.mode7.matrix_a * (INT8)(snes_ppu.mode7.matrix_b >> 8); |
| 350 | 359 | snes_ram[MPYH] = (c >> 16) & 0xff; |
| 351 | | return snes_ram[offset]; |
| 360 | return snes_ram[MPYH]; |
| 352 | 361 | } |
| 353 | 362 | case SLHV: /* Software latch for H/V counter */ |
| 354 | 363 | snes_latch_counters(space->machine); |
| r5385 | r5386 | |
| 680 | 689 | else |
| 681 | 690 | { |
| 682 | 691 | snes_oam[oam_addr] &= 0x00ff; |
| 683 | | snes_oam[oam_addr] |= (data<<8); |
| 692 | snes_oam[oam_addr] |= (data << 8); |
| 684 | 693 | } |
| 685 | 694 | } |
| 686 | 695 | else |
| r5385 | r5386 | |
| 692 | 701 | } |
| 693 | 702 | else |
| 694 | 703 | { |
| 695 | | snes_oam[oam_addr] = (data<<8) | snes_ppu.oam.write_latch; |
| 704 | snes_oam[oam_addr] = (data << 8) | snes_ppu.oam.write_latch; |
| 696 | 705 | } |
| 697 | 706 | } |
| 698 | 707 | snes_ram[OAMDATA] = (snes_ram[OAMDATA] + 1) % 2; |
| r5385 | r5386 | |
| 706 | 715 | return; |
| 707 | 716 | } |
| 708 | 717 | case BGMODE: /* BG mode and character size settings */ |
| 709 | | snes_ppu.mode = data & 0x7; |
| 718 | snes_ppu.mode = data & 0x07; |
| 710 | 719 | { |
| 711 | 720 | rectangle visarea = *video_screen_get_visible_area(space->machine->primary_screen); |
| 712 | 721 | |
| r5385 | r5386 | |
| 730 | 739 | else |
| 731 | 740 | video_screen_configure(space->machine->primary_screen, SNES_HTOTAL*snes_htmult, SNES_VTOTAL_PAL, &visarea, video_screen_get_frame_period(space->machine->primary_screen).attoseconds); |
| 732 | 741 | } |
| 733 | | |
| 742 | snes_ppu.bg3_priority_bit = data & 0x08; |
| 734 | 743 | snes_ppu.layer[0].tile_size = (data >> 4) & 0x1; |
| 735 | 744 | snes_ppu.layer[1].tile_size = (data >> 5) & 0x1; |
| 736 | 745 | snes_ppu.layer[2].tile_size = (data >> 6) & 0x1; |
| r5385 | r5386 | |
| 761 | 770 | snes_ppu.layer[3].data = (data & 0xf0) << 9; |
| 762 | 771 | break; |
| 763 | 772 | |
| 764 | | // Anomie says "H Current = (Byte<<8) | (Prev&~7) | ((Current>>8)&7); V Current = (Current<<8) | Prev;" |
| 773 | // Anomie says "H Current = (Byte<<8) | (Prev&~7) | ((Current>>8)&7); V Current = (Current<<8) | Prev;" and Prev is shared by all scrolls but in Mode 7! |
| 765 | 774 | case BG1HOFS: /* BG1 - horizontal scroll (DW) */ |
| 766 | | snes_ppu.layer[0].offset.horizontal = (data<<8) | (ppu_last_scroll & ~7) | ((snes_ppu.layer[0].offset.horizontal>>8) & 7); |
| 767 | | ppu_last_scroll = data; |
| 775 | /* In Mode 0->6 we use ppu_last_scroll as Prev */ |
| 776 | snes_ppu.layer[0].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[0].offset.horizontal >> 8) & 7); |
| 777 | snes_ppu.ppu_last_scroll = data; |
| 778 | /* In Mode 7 we use mode7_last_scroll as Prev */ |
| 779 | snes_ppu.mode7.hor_offset = (data << 8) | (snes_ppu.mode7_last_scroll & ~7) | ((snes_ppu.mode7.hor_offset >> 8) & 7); |
| 780 | snes_ppu.mode7_last_scroll = data; |
| 768 | 781 | snes_ppu.update_offsets = 1; |
| 769 | 782 | return; |
| 770 | 783 | case BG1VOFS: /* BG1 - vertical scroll (DW) */ |
| 771 | | snes_ppu.layer[0].offset.vertical = (data<<8) | (ppu_last_scroll); |
| 772 | | ppu_last_scroll = data; |
| 784 | /* In Mode 0->6 we use ppu_last_scroll as Prev */ |
| 785 | snes_ppu.layer[0].offset.vertical = (data << 8) | snes_ppu.ppu_last_scroll; |
| 786 | snes_ppu.ppu_last_scroll = data; |
| 787 | /* In Mode 7 we use mode7_last_scroll as Prev */ |
| 788 | snes_ppu.mode7.ver_offset = (data << 8) | snes_ppu.mode7_last_scroll; |
| 789 | snes_ppu.mode7_last_scroll = data; |
| 773 | 790 | snes_ppu.update_offsets = 1; |
| 774 | 791 | return; |
| 775 | 792 | case BG2HOFS: /* BG2 - horizontal scroll (DW) */ |
| 776 | | snes_ppu.layer[1].offset.horizontal = (data<<8) | (ppu_last_scroll & ~7) | ((snes_ppu.layer[1].offset.horizontal>>8) & 7); |
| 777 | | ppu_last_scroll = data; |
| 793 | snes_ppu.layer[1].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[1].offset.horizontal >> 8) & 7); |
| 794 | snes_ppu.ppu_last_scroll = data; |
| 778 | 795 | snes_ppu.update_offsets = 1; |
| 779 | 796 | return; |
| 780 | 797 | case BG2VOFS: /* BG2 - vertical scroll (DW) */ |
| 781 | | snes_ppu.layer[1].offset.vertical = (data<<8) | (ppu_last_scroll); |
| 782 | | ppu_last_scroll = data; |
| 798 | snes_ppu.layer[1].offset.vertical = (data << 8) | (snes_ppu.ppu_last_scroll); |
| 799 | snes_ppu.ppu_last_scroll = data; |
| 783 | 800 | snes_ppu.update_offsets = 1; |
| 784 | 801 | return; |
| 785 | 802 | case BG3HOFS: /* BG3 - horizontal scroll (DW) */ |
| 786 | | snes_ppu.layer[2].offset.horizontal = (data<<8) | (ppu_last_scroll & ~7) | ((snes_ppu.layer[2].offset.horizontal>>8) & 7); |
| 787 | | ppu_last_scroll = data; |
| 803 | snes_ppu.layer[2].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[2].offset.horizontal >> 8) & 7); |
| 804 | snes_ppu.ppu_last_scroll = data; |
| 788 | 805 | snes_ppu.update_offsets = 1; |
| 789 | 806 | return; |
| 790 | 807 | case BG3VOFS: /* BG3 - vertical scroll (DW) */ |
| 791 | | snes_ppu.layer[2].offset.vertical = (data<<8) | (ppu_last_scroll); |
| 792 | | ppu_last_scroll = data; |
| 808 | snes_ppu.layer[2].offset.vertical = (data << 8) | (snes_ppu.ppu_last_scroll); |
| 809 | snes_ppu.ppu_last_scroll = data; |
| 793 | 810 | snes_ppu.update_offsets = 1; |
| 794 | 811 | return; |
| 795 | 812 | case BG4HOFS: /* BG4 - horizontal scroll (DW) */ |
| 796 | | snes_ppu.layer[3].offset.horizontal = (data<<8) | (ppu_last_scroll & ~7) | ((snes_ppu.layer[3].offset.horizontal>>8) & 7); |
| 797 | | ppu_last_scroll = data; |
| 813 | snes_ppu.layer[3].offset.horizontal = (data << 8) | (snes_ppu.ppu_last_scroll & ~7) | ((snes_ppu.layer[3].offset.horizontal >> 8) & 7); |
| 814 | snes_ppu.ppu_last_scroll = data; |
| 798 | 815 | snes_ppu.update_offsets = 1; |
| 799 | 816 | return; |
| 800 | 817 | case BG4VOFS: /* BG4 - vertical scroll (DW) */ |
| 801 | | snes_ppu.layer[3].offset.vertical = (data<<8) | (ppu_last_scroll); |
| 802 | | ppu_last_scroll = data; |
| 818 | snes_ppu.layer[3].offset.vertical = (data << 8) | (snes_ppu.ppu_last_scroll); |
| 819 | snes_ppu.ppu_last_scroll = data; |
| 803 | 820 | snes_ppu.update_offsets = 1; |
| 804 | 821 | return; |
| 805 | 822 | case VMAIN: /* VRAM address increment value designation */ |
| r5385 | r5386 | |
| 898 | 915 | snes_ppu.mode7.vflip = data & 0x02; |
| 899 | 916 | snes_ppu.mode7.hflip = data & 0x01; |
| 900 | 917 | break; |
| 918 | /* As per Anomie's doc: Reg = (Current<<8) | Prev; and there is only one Prev, shared by these matrix regs and Mode 7 scroll regs */ |
| 901 | 919 | case M7A: /* Mode 7 COS angle/x expansion (DW) */ |
| 902 | | snes_ppu.mode7.matrix_a = ((snes_ppu.mode7.matrix_a >> 8) & 0xff) + (data << 8); |
| 920 | snes_ppu.mode7.matrix_a = snes_ppu.mode7_last_scroll + (data << 8); |
| 921 | snes_ppu.mode7_last_scroll = data; |
| 903 | 922 | break; |
| 904 | 923 | case M7B: /* Mode 7 SIN angle/ x expansion (DW) */ |
| 905 | | snes_ppu.mode7.matrix_b = ((snes_ppu.mode7.matrix_b >> 8) & 0xff) + (data << 8); |
| 924 | snes_ppu.mode7.matrix_b = snes_ppu.mode7_last_scroll + (data << 8); |
| 925 | snes_ppu.mode7_last_scroll = data; |
| 906 | 926 | break; |
| 907 | 927 | case M7C: /* Mode 7 SIN angle/y expansion (DW) */ |
| 908 | | snes_ppu.mode7.matrix_c = ((snes_ppu.mode7.matrix_c >> 8) & 0xff) + (data << 8); |
| 928 | snes_ppu.mode7.matrix_c = snes_ppu.mode7_last_scroll + (data << 8); |
| 929 | snes_ppu.mode7_last_scroll = data; |
| 909 | 930 | break; |
| 910 | 931 | case M7D: /* Mode 7 COS angle/y expansion (DW) */ |
| 911 | | snes_ppu.mode7.matrix_d = ((snes_ppu.mode7.matrix_d >> 8) & 0xff) + (data << 8); |
| 932 | snes_ppu.mode7.matrix_d = snes_ppu.mode7_last_scroll + (data << 8); |
| 933 | snes_ppu.mode7_last_scroll = data; |
| 912 | 934 | break; |
| 913 | 935 | case M7X: /* Mode 7 x center position (DW) */ |
| 914 | | snes_ppu.mode7.origin_x = ((snes_ppu.mode7.origin_x >> 8) & 0xff) + (data << 8); |
| 936 | snes_ppu.mode7.origin_x = snes_ppu.mode7_last_scroll + (data << 8); |
| 937 | snes_ppu.mode7_last_scroll = data; |
| 915 | 938 | break; |
| 916 | 939 | case M7Y: /* Mode 7 y center position (DW) */ |
| 917 | | snes_ppu.mode7.origin_y = ((snes_ppu.mode7.origin_y >> 8) & 0xff) + (data << 8); |
| 940 | snes_ppu.mode7.origin_y = snes_ppu.mode7_last_scroll + (data << 8); |
| 941 | snes_ppu.mode7_last_scroll = data; |
| 918 | 942 | break; |
| 919 | 943 | case CGADD: /* Initial address for colour RAM writing */ |
| 920 | 944 | /* CGRAM is 16-bit, but when reading/writing we treat it as |
| r5385 | r5386 | |
| 938 | 962 | snes_ppu.update_windows = 1; |
| 939 | 963 | break; |
| 940 | 964 | case TM: /* Main screen designation */ |
| 965 | snes_ppu.main_bg_enabled[0] = data & 0x01; |
| 966 | snes_ppu.main_bg_enabled[1] = data & 0x02; |
| 967 | snes_ppu.main_bg_enabled[2] = data & 0x04; |
| 968 | snes_ppu.main_bg_enabled[3] = data & 0x08; |
| 969 | snes_ppu.main_bg_enabled[4] = data & 0x10; |
| 970 | break; |
| 941 | 971 | case TS: /* Subscreen designation */ |
| 972 | snes_ppu.sub_bg_enabled[0] = data & 0x01; |
| 973 | snes_ppu.sub_bg_enabled[1] = data & 0x02; |
| 974 | snes_ppu.sub_bg_enabled[2] = data & 0x04; |
| 975 | snes_ppu.sub_bg_enabled[3] = data & 0x08; |
| 976 | snes_ppu.sub_bg_enabled[4] = data & 0x10; |
| 942 | 977 | break; |
| 943 | 978 | case TMW: /* Window mask for main screen designation */ |
| 944 | 979 | snes_ppu.layer[0].main_window_enabled = data & 0x01; |
src/mame/video/snes.c
| r5385 | r5386 | |
| 575 | 575 | { |
| 576 | 576 | UINT32 tiled; |
| 577 | 577 | INT16 ma, mb, mc, md; |
| 578 | | INT32 xc, yc, tx, ty, sx, sy, hs, vs, xpos, xdir; |
| 578 | INT32 xc, yc, tx, ty, sx, sy, hs, vs, xpos, xdir, x0, y0; |
| 579 | 579 | UINT8 priority = priority_a; |
| 580 | 580 | UINT8 colour = 0; |
| 581 | 581 | UINT16 *mosaic_x, *mosaic_y; |
| r5385 | r5386 | |
| 594 | 594 | md = snes_ppu.mode7.matrix_d; |
| 595 | 595 | xc = snes_ppu.mode7.origin_x; |
| 596 | 596 | yc = snes_ppu.mode7.origin_y; |
| 597 | | hs = snes_ppu.layer[layer].offset.horizontal; |
| 598 | | vs = snes_ppu.layer[layer].offset.vertical; |
| 597 | hs = snes_ppu.mode7.hor_offset; |
| 598 | vs = snes_ppu.mode7.ver_offset; |
| 599 | 599 | |
| 600 | 600 | /* Sign extend */ |
| 601 | 601 | xc <<= 19; |
| r5385 | r5386 | |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | /* Let's do some mode7 drawing huh? */ |
| 641 | /* These can be computed only once, since they do not depend on sx */ |
| 642 | x0 = ((ma * MODE7_CLIP(hs - xc)) & ~0x3f) + ((mb * mosaic_y[sy]) & ~0x3f) + ((mb * MODE7_CLIP(vs - yc)) & ~0x3f) + (xc << 8); |
| 643 | y0 = ((mc * MODE7_CLIP(hs - xc)) & ~0x3f) + ((md * mosaic_y[sy]) & ~0x3f) + ((md * MODE7_CLIP(vs - yc)) & ~0x3f) + (yc << 8); |
| 644 | |
| 641 | 645 | for (sx = 0; sx < 256; sx++, xpos += xdir) |
| 642 | 646 | { |
| 643 | | tx = (((ma * MODE7_CLIP(hs - xc)) & ~0x3f) + ((mb * MODE7_CLIP(vs - yc)) & ~0x3f) + (xc << 8) + (ma * mosaic_x[sx]) + ((mb * mosaic_y[sy]) & ~0x3f)) >> 8; |
| 644 | | ty = (((mc * MODE7_CLIP(hs - xc)) & ~0x3f) + ((md * MODE7_CLIP(vs - yc)) & ~0x3f) + (yc << 8) + (mc * mosaic_x[sx]) + ((md * mosaic_y[sy]) & ~0x3f)) >> 8; |
| 645 | | |
| 647 | tx = (x0 + (ma * mosaic_x[sx])) >> 8; |
| 648 | ty = (y0 + (mc * mosaic_x[sx])) >> 8; |
| 649 | |
| 646 | 650 | switch (snes_ppu.mode7.repeat) |
| 647 | 651 | { |
| 648 | 652 | case 0x00: /* Repeat if outside screen area */ |
| r5385 | r5386 | |
| 843 | 847 | *********************************************/ |
| 844 | 848 | static void snes_update_mode_0( UINT8 screen, UINT16 curline ) |
| 845 | 849 | { |
| 846 | | UINT16 bg_enable_reg = (screen == MAINSCREEN) ? TM : TS; |
| 847 | | if (snes_ram[bg_enable_reg] & 0x10) snes_update_objects(screen, 0, curline); |
| 848 | | if (snes_ram[bg_enable_reg] & 0x01) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 7, 10, 0, curline); |
| 849 | | if (snes_ram[bg_enable_reg] & 0x02) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, 1, curline); |
| 850 | | if (snes_ram[bg_enable_reg] & 0x04) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, 2, curline); |
| 851 | | if (snes_ram[bg_enable_reg] & 0x08) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 3, 3, curline); |
| 850 | UINT8 *bg_enabled; |
| 851 | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 852 | |
| 853 | if (bg_enabled[4]) snes_update_objects(screen, 0, curline); |
| 854 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 7, 10, 0, curline); |
| 855 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, 1, curline); |
| 856 | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, 2, curline); |
| 857 | if (bg_enabled[3]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 3, 3, curline); |
| 852 | 858 | } |
| 853 | 859 | |
| 854 | 860 | static void snes_update_mode_1( UINT8 screen, UINT16 curline ) |
| 855 | 861 | { |
| 856 | | UINT16 bg_enable_reg = (screen == MAINSCREEN) ? TM : TS; |
| 857 | | UINT8 bg3_pty = snes_ram[BGMODE] & 0x08; |
| 862 | UINT8 *bg_enabled; |
| 863 | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 858 | 864 | |
| 859 | | if (!bg3_pty) |
| 865 | if (!snes_ppu.bg3_priority_bit) |
| 860 | 866 | { |
| 861 | | if (snes_ram[bg_enable_reg] & 0x10) snes_update_objects(screen, 1, curline); |
| 862 | | if (snes_ram[bg_enable_reg] & 0x01) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 5, 8, 0, curline); |
| 863 | | if (snes_ram[bg_enable_reg] & 0x02) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, 1, curline); |
| 864 | | if (snes_ram[bg_enable_reg] & 0x04) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 2, 2, curline); |
| 867 | if (bg_enabled[4]) snes_update_objects(screen, 1, curline); |
| 868 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 5, 8, 0, curline); |
| 869 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, 1, curline); |
| 870 | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 2, 2, curline); |
| 865 | 871 | } |
| 866 | 872 | else |
| 867 | 873 | { |
| 868 | | if (snes_ram[bg_enable_reg] & 0x10) snes_update_objects(screen, 9, curline); |
| 869 | | if (snes_ram[bg_enable_reg] & 0x01) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, 0, curline); |
| 870 | | if (snes_ram[bg_enable_reg] & 0x02) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 3, 6, 1, curline); |
| 871 | | if (snes_ram[bg_enable_reg] & 0x04) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 9, 2, curline); |
| 874 | if (bg_enabled[4]) snes_update_objects(screen, 9, curline); |
| 875 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, 0, curline); |
| 876 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 3, 6, 1, curline); |
| 877 | if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 9, 2, curline); |
| 872 | 878 | } |
| 873 | 879 | } |
| 874 | 880 | |
| 875 | 881 | static void snes_update_mode_2( UINT8 screen, UINT16 curline ) |
| 876 | 882 | { |
| 877 | | UINT16 bg_enable_reg = (screen == MAINSCREEN) ? TM : TS; |
| 878 | | if (snes_ram[bg_enable_reg] & 0x10) snes_update_objects(screen, 2, curline); |
| 879 | | if (snes_ram[bg_enable_reg] & 0x01) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, 0, curline); |
| 880 | | if (snes_ram[bg_enable_reg] & 0x02) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, 1, curline); |
| 883 | UINT8 *bg_enabled; |
| 884 | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 885 | |
| 886 | if (bg_enabled[4]) snes_update_objects(screen, 2, curline); |
| 887 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, 0, curline); |
| 888 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, 1, curline); |
| 881 | 889 | } |
| 882 | 890 | |
| 883 | 891 | static void snes_update_mode_3( UINT8 screen, UINT16 curline ) |
| 884 | 892 | { |
| 885 | | UINT16 bg_enable_reg = (screen == MAINSCREEN) ? TM : TS; |
| 886 | | if (snes_ram[bg_enable_reg] & 0x10) snes_update_objects(screen, 3, curline); |
| 887 | | if (snes_ram[bg_enable_reg] & 0x01) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, 0, curline); |
| 888 | | if (snes_ram[bg_enable_reg] & 0x02) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, 1, curline); |
| 893 | UINT8 *bg_enabled; |
| 894 | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 895 | |
| 896 | if (bg_enabled[4]) snes_update_objects(screen, 3, curline); |
| 897 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, 0, curline); |
| 898 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, 1, curline); |
| 889 | 899 | } |
| 890 | 900 | |
| 891 | 901 | static void snes_update_mode_4( UINT8 screen, UINT16 curline ) |
| 892 | 902 | { |
| 893 | | UINT16 bg_enable_reg = (screen == MAINSCREEN) ? TM : TS; |
| 894 | | if (snes_ram[bg_enable_reg] & 0x10) snes_update_objects(screen, 4, curline); |
| 895 | | if (snes_ram[bg_enable_reg] & 0x01) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, 0, curline); |
| 896 | | if (snes_ram[bg_enable_reg] & 0x02) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 4, 1, curline); |
| 903 | UINT8 *bg_enabled; |
| 904 | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 905 | |
| 906 | if (bg_enabled[4]) snes_update_objects(screen, 4, curline); |
| 907 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, 0, curline); |
| 908 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 4, 1, curline); |
| 897 | 909 | } |
| 898 | 910 | |
| 899 | 911 | static void snes_update_mode_5( UINT8 screen, UINT16 curline ) |
| 900 | 912 | { |
| 901 | | UINT16 bg_enable_reg = (screen == MAINSCREEN) ? TM : TS; |
| 902 | | if (snes_ram[bg_enable_reg] & 0x10) snes_update_objects(screen, 5, curline); |
| 903 | | if (snes_ram[bg_enable_reg] & 0x01) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, 0, curline); |
| 904 | | if (snes_ram[bg_enable_reg] & 0x02) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 1, 0, 4, 1, curline); |
| 913 | UINT8 *bg_enabled; |
| 914 | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 915 | |
| 916 | if (bg_enabled[4]) snes_update_objects(screen, 5, curline); |
| 917 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, 0, curline); |
| 918 | if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 1, 0, 4, 1, curline); |
| 905 | 919 | } |
| 906 | 920 | |
| 907 | 921 | static void snes_update_mode_6( UINT8 screen, UINT16 curline ) |
| 908 | 922 | { |
| 909 | | UINT16 bg_enable_reg = (screen == MAINSCREEN) ? TM : TS; |
| 910 | | if (snes_ram[bg_enable_reg] & 0x10) snes_update_objects(screen, 6, curline); |
| 911 | | if (snes_ram[bg_enable_reg] & 0x01) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, 0, curline); |
| 923 | UINT8 *bg_enabled; |
| 924 | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 925 | |
| 926 | if (bg_enabled[4]) snes_update_objects(screen, 6, curline); |
| 927 | if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, 0, curline); |
| 912 | 928 | } |
| 913 | 929 | |
| 914 | 930 | static void snes_update_mode_7( UINT8 screen, UINT16 curline ) |
| 915 | 931 | { |
| 916 | | UINT16 bg_enable_reg = (screen == MAINSCREEN) ? TM : TS; |
| 917 | 932 | UINT8 extbg_mode = snes_ram[SETINI] & 0x40; |
| 933 | UINT8 *bg_enabled; |
| 934 | bg_enabled = (screen == MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled; |
| 918 | 935 | |
| 919 | 936 | if (!extbg_mode) |
| 920 | 937 | { |
| 921 | | if (snes_ram[bg_enable_reg] & 0x10) snes_update_objects(screen, 7, curline); |
| 922 | | if (snes_ram[bg_enable_reg] & 0x01) snes_update_line_mode7(screen, 1, 1, 0, curline); |
| 938 | if (bg_enabled[4]) snes_update_objects(screen, 7, curline); |
| 939 | if (bg_enabled[0]) snes_update_line_mode7(screen, 1, 1, 0, curline); |
| 923 | 940 | } |
| 924 | 941 | else |
| 925 | 942 | { |
| 926 | | if (snes_ram[bg_enable_reg] & 0x10) snes_update_objects(screen, 8, curline); |
| 927 | | if (snes_ram[bg_enable_reg] & 0x01) snes_update_line_mode7(screen, 2, 2, 0, curline); |
| 928 | | if (snes_ram[bg_enable_reg] & 0x02) snes_update_line_mode7(screen, 0, 4, 1, curline); |
| 943 | if (bg_enabled[4]) snes_update_objects(screen, 8, curline); |
| 944 | if (bg_enabled[0]) snes_update_line_mode7(screen, 2, 2, 0, curline); |
| 945 | if (bg_enabled[1]) snes_update_line_mode7(screen, 0, 4, 1, curline); |
| 929 | 946 | } |
| 930 | 947 | } |
| 931 | 948 | |