Previous 15994 Revisions Next

r7496 Friday 5th March, 2010 at 08:44:57 UTC by Fabio Priuli
[SNES] drawing routine rewrite, part 4:
* improved hires large tiles (more work is needed on these, but Desert Fighter and Bishojo Janshi Suchie-Pai are definitely better)
* simplified drawing routine
* slightly speed up to debug BG disabling/enabling
[src/mame/video]snes.c

src/mame/video/snes.c
r7495r7496
278278      /* Clip to windows */
279279      window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled;
280280      if (window_enabled)
281         colour &= snes_ppu.clipmasks[layer][ii];
281         colour &= snes_ppu.clipmasks[layer][ii >> hires];
282282
283283      /* Only draw if we have a colour (0 == transparent) */
284284      if (colour)
285285      {
286         if ((scanlines[screen].priority[ii] <= priority) && (ii >= 0))
286         if ((scanlines[screen].priority[ii >> hires] <= priority) && (ii >= 0))
287287         {
288288            if (direct_colors)
289289            {
r7495r7496
490490#ifdef SNES_LAYER_DEBUG
491491   if (debug_options.bg_disabled[layer])
492492      return;
493
494   if (debug_options.mode_disabled[snes_ppu.mode])
495      return;
496493#endif /* SNES_LAYER_DEBUG */
497494
498495   /* Handle Mosaic effects */
r7495r7496
558555        ppp  = Tile palette. The number of entries in the palette depends on the Mode and the BG.
559556        cccccccccc = Tile number.
560557      */
561      UINT32 addr = snes_get_tmap(layer, tile_size, tmap, ii + xoff, yoff);
558
559      UINT32 addr = snes_get_tmap(layer, tile_size, tmap, (ii << (tile_size * hires)) + xoff, yoff);
562560      UINT16 tilemap = snes_vram[addr] | (snes_vram[addr + 1] << 8);
563561      vflip = BIT(tilemap, 15);
564562      hflip = BIT(tilemap, 14);
r7495r7496
640638#ifdef SNES_LAYER_DEBUG
641639   if (debug_options.bg_disabled[layer])
642640      return;
643
644   if (debug_options.mode_disabled[snes_ppu.mode])
645      return;
646641#endif /* SNES_LAYER_DEBUG */
647642
648643   ma = snes_ppu.mode7.matrix_a;
r7495r7496
795790   };
796791
797792#ifdef SNES_LAYER_DEBUG
798   if (debug_options.bg_disabled[4])
793   if (debug_options.bg_disabled[SNES_OAM])
799794      return;
800795#endif /* SNES_LAYER_DEBUG */
801796
r7495r7496
907902   UINT8 *bg_enabled;
908903   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
909904
905#ifdef SNES_LAYER_DEBUG
906   if (debug_options.mode_disabled[0])
907      return;
908#endif /* SNES_LAYER_DEBUG */
909
910910   if (bg_enabled[3]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 3, SNES_BG4, curline, 0, 0);
911911   if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, 0, 0);
912912   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, 0, 0);
r7495r7496
919919   UINT8 *bg_enabled;
920920   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
921921
922#ifdef SNES_LAYER_DEBUG
923   if (debug_options.mode_disabled[1])
924      return;
925#endif /* SNES_LAYER_DEBUG */
926
922927   if (!snes_ppu.bg3_priority_bit)
923928   {
924929      if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, 0, 0);
r7495r7496
940945   UINT8 *bg_enabled;
941946   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
942947
948#ifdef SNES_LAYER_DEBUG
949   if (debug_options.mode_disabled[2])
950      return;
951#endif /* SNES_LAYER_DEBUG */
952
943953   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 1, 0);
944954   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, 1, 0);
945955   if (bg_enabled[4]) snes_update_objects(screen, 2, curline);
r7495r7496
950960   UINT8 *bg_enabled;
951961   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
952962
963#ifdef SNES_LAYER_DEBUG
964   if (debug_options.mode_disabled[3])
965      return;
966#endif /* SNES_LAYER_DEBUG */
967
953968   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 0, 0);
954969   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color);
955970   if (bg_enabled[4]) snes_update_objects(screen, 3, curline);
r7495r7496
960975   UINT8 *bg_enabled;
961976   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
962977
978#ifdef SNES_LAYER_DEBUG
979   if (debug_options.mode_disabled[4])
980      return;
981#endif /* SNES_LAYER_DEBUG */
982
963983   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, 0, 0);
964984   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color);
965985   if (bg_enabled[4]) snes_update_objects(screen, 4, curline);
r7495r7496
970990   UINT8 *bg_enabled;
971991   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
972992
993#ifdef SNES_LAYER_DEBUG
994   if (debug_options.mode_disabled[5])
995      return;
996#endif /* SNES_LAYER_DEBUG */
997
973998   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, 0, 0);
974999   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, 0, 0);
9751000   if (bg_enabled[4]) snes_update_objects(screen, 5, curline);
r7495r7496
9801005   UINT8 *bg_enabled;
9811006   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
9821007
1008#ifdef SNES_LAYER_DEBUG
1009   if (debug_options.mode_disabled[6])
1010      return;
1011#endif /* SNES_LAYER_DEBUG */
1012
9831013   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, 1, 0);
9841014   if (bg_enabled[4]) snes_update_objects(screen, 6, curline);
9851015}
r7495r7496
9891019   UINT8 *bg_enabled;
9901020   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
9911021
1022#ifdef SNES_LAYER_DEBUG
1023   if (debug_options.mode_disabled[7])
1024      return;
1025#endif /* SNES_LAYER_DEBUG */
1026
9921027   if (!snes_ppu.mode7.extbg)
9931028   {
9941029      if (bg_enabled[0]) snes_update_line_mode7(screen, 1, 1, SNES_BG1, curline);
r7495r7496
10071042 *
10081043 * Draw the whole screen (Mode 0 -> 7).
10091044 *********************************************/
1045
10101046static void snes_draw_screen( UINT8 screen, UINT16 curline )
10111047{
10121048   switch (snes_ppu.mode)
r7495r7496
11881224      /* Phew! Draw the line to screen */
11891225      fade = snes_ppu.screen_brightness;
11901226
1191      for (x = 0; x < SNES_SCR_WIDTH * 2; x += 2)
1227      for (x = 0; x < SNES_SCR_WIDTH * 2; x++)
11921228      {
11931229         int r, g, b, hires;
11941230         UINT16 temp_col;
r7495r7496
12051241         b = (((c & 0x7c00) >> 10) * fade) >> 4;
12061242
12071243         *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1244
12081245         if (!hires)
12091246            *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
12101247         else
r7495r7496
12211258
12221259            *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
12231260         }
1224
1225         c = scanline->buffer[x + 1];
1226         temp_col = scanline->buffer[x + 1];
1227
1228         /* perform color math if the layer wants it (except if it's an object > 192) */
1229         if (!scanlines[SNES_MAINSCREEN].blend_exception[x + 1] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x + 1]].color_math)
1230            snes_draw_blend_lores(x + 1, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
1231
1232         r = ((c & 0x1f) * fade) >> 4;
1233         g = (((c & 0x3e0) >> 5) * fade) >> 4;
1234         b = (((c & 0x7c00) >> 10) * fade) >> 4;
1235
1236         *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1237         if (!hires)
1238            *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1239         else
1240         {
1241            c = scanlines[SNES_SUBSCREEN].buffer[x + 1];
1242            scanlines[SNES_SUBSCREEN].buffer[x + 1] = temp_col;
1243
1244            if (!scanlines[SNES_MAINSCREEN].blend_exception[x + 1] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x + 1]].color_math)
1245               snes_draw_blend_lores(x + 1, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
1246
1247            r = ((c & 0x1f) * fade) >> 4;
1248            g = (((c & 0x3e0) >> 5) * fade) >> 4;
1249            b = (((c & 0x7c00) >> 10) * fade) >> 4;
1250
1251            *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1252         }
12531261      }
12541262   }
12551263

Previous 15994 Revisions Next


© 1998-2018 The MESS Team