Previous 15994 Revisions Next

r7495 Friday 5th March, 2010 at 08:24:41 UTC by Fabio Priuli
[SNES] drawing routine rewrite, part 3:
* fixed priority order and removed some more dead code
[src/mame/video]snes.c

src/mame/video/snes.c
r7494r7495
860860            {
861861               if ((x + (count << 3) < SNES_SCR_WIDTH + 8))
862862               {
863                  if (widemode)
864                     snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 1);
865                  else
866                     snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 0);
863                  snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, widemode);
867864               }
868865               time_over++;   /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */
869866            }
r7494r7495
874871            {
875872               if ((x + (xs << 3) < SNES_SCR_WIDTH + 8))
876873               {
877                  if (widemode)
878                     snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 1);
879                  else
880                     snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 0);
874                  snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, widemode);
881875               }
882876               time_over++;   /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */
883877            }
r7494r7495
913907   UINT8 *bg_enabled;
914908   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
915909
916   if (bg_enabled[4]) snes_update_objects(screen, 0, curline);
917   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 7, 10, SNES_BG1, curline, 0, 0);
918   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, 0, 0);
919   if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, 0, 0);
920910   if (bg_enabled[3]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 3, SNES_BG4, curline, 0, 0);
911   if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, 0, 0);
912   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, 0, 0);
913   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 7, 10, SNES_BG1, curline, 0, 0);
914   if (bg_enabled[4]) snes_update_objects(screen, 0, curline);
921915}
922916
923917static void snes_update_mode_1( UINT8 screen, UINT16 curline )
r7494r7495
927921
928922   if (!snes_ppu.bg3_priority_bit)
929923   {
930      if (bg_enabled[4]) snes_update_objects(screen, 1, curline);
931      if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 5, 8, SNES_BG1, curline, 0, 0);
932      if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, 0, 0);
933924      if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, 0, 0);
925      if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, 0, 0);
926      if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 5, 8, SNES_BG1, curline, 0, 0);
927      if (bg_enabled[4]) snes_update_objects(screen, 1, curline);
934928   }
935929   else
936930   {
937      if (bg_enabled[4]) snes_update_objects(screen, 9, curline);
938      if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG1, curline, 0, 0);
939      if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, 0, 0);
940931      if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 9, SNES_BG3, curline, 0, 0);
932      if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, 0, 0);
933      if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG1, curline, 0, 0);
934      if (bg_enabled[4]) snes_update_objects(screen, 9, curline);
941935   }
942936}
943937
r7494r7495
946940   UINT8 *bg_enabled;
947941   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
948942
949   if (bg_enabled[4]) snes_update_objects(screen, 2, curline);
950   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, 1, 0);
951943   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 1, 0);
944   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, 1, 0);
945   if (bg_enabled[4]) snes_update_objects(screen, 2, curline);
952946}
953947
954948static void snes_update_mode_3( UINT8 screen, UINT16 curline )
r7494r7495
956950   UINT8 *bg_enabled;
957951   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
958952
959   if (bg_enabled[4]) snes_update_objects(screen, 3, curline);
960   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color);
961953   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 0, 0);
954   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color);
955   if (bg_enabled[4]) snes_update_objects(screen, 3, curline);
962956}
963957
964958static void snes_update_mode_4( UINT8 screen, UINT16 curline )
r7494r7495
966960   UINT8 *bg_enabled;
967961   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
968962
969   if (bg_enabled[4]) snes_update_objects(screen, 4, curline);
970   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color);
971963   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, 0, 0);
964   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color);
965   if (bg_enabled[4]) snes_update_objects(screen, 4, curline);
972966}
973967
974968static void snes_update_mode_5( UINT8 screen, UINT16 curline )
r7494r7495
976970   UINT8 *bg_enabled;
977971   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
978972
979   if (bg_enabled[4]) snes_update_objects(screen, 5, curline);
980   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, 0, 0);
981973   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, 0, 0);
974   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, 0, 0);
975   if (bg_enabled[4]) snes_update_objects(screen, 5, curline);
982976}
983977
984978static void snes_update_mode_6( UINT8 screen, UINT16 curline )
r7494r7495
986980   UINT8 *bg_enabled;
987981   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
988982
989   if (bg_enabled[4]) snes_update_objects(screen, 6, curline);
990983   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, 1, 0);
984   if (bg_enabled[4]) snes_update_objects(screen, 6, curline);
991985}
992986
993987static void snes_update_mode_7( UINT8 screen, UINT16 curline )
r7494r7495
997991
998992   if (!snes_ppu.mode7.extbg)
999993   {
1000      if (bg_enabled[4]) snes_update_objects(screen, 7, curline);
1001994      if (bg_enabled[0]) snes_update_line_mode7(screen, 1, 1, SNES_BG1, curline);
995      if (bg_enabled[4]) snes_update_objects(screen, 7, curline);
1002996   }
1003997   else
1004998   {
1005      if (bg_enabled[4]) snes_update_objects(screen, 8, curline);
1006      if (bg_enabled[0]) snes_update_line_mode7(screen, 2, 2, SNES_BG1, curline);
1007999      if (bg_enabled[1]) snes_update_line_mode7(screen, 0, 4, SNES_BG2, curline);
1000      if (bg_enabled[0]) snes_update_line_mode7(screen, 2, 2, SNES_BG1, curline);
1001      if (bg_enabled[4]) snes_update_objects(screen, 8, curline);
10081002   }
10091003}
10101004
r7494r7495
11961190
11971191      for (x = 0; x < SNES_SCR_WIDTH * 2; x += 2)
11981192      {
1199//         if (snes_ppu.mode != 5 && snes_ppu.mode != 6)
1193         int r, g, b, hires;
1194         UINT16 temp_col;
1195         hires = (snes_ppu.mode != 5 && snes_ppu.mode != 6) ? 0 : 1;
1196         c = scanline->buffer[x];
1197         temp_col = scanline->buffer[x];
1198
1199         /* perform color math if the layer wants it (except if it's an object > 192) */
1200         if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
1201            snes_draw_blend_lores(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
1202
1203         r = ((c & 0x1f) * fade) >> 4;
1204         g = (((c & 0x3e0) >> 5) * fade) >> 4;
1205         b = (((c & 0x7c00) >> 10) * fade) >> 4;
1206
1207         *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1208         if (!hires)
1209            *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1210         else
12001211         {
1201            int r, g, b;
1202            c = scanline->buffer[x];
1212            c = scanlines[SNES_SUBSCREEN].buffer[x];
1213            scanlines[SNES_SUBSCREEN].buffer[x] = temp_col;
12031214
1204            /* perform color math if the layer wants it (except if it's an object > 192) */
12051215            if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
12061216               snes_draw_blend_lores(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
12071217
r7494r7495
12091219            g = (((c & 0x3e0) >> 5) * fade) >> 4;
12101220            b = (((c & 0x7c00) >> 10) * fade) >> 4;
12111221
1212            *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
12131222            *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1223         }
12141224
1215            c = scanline->buffer[x + 1];
1225         c = scanline->buffer[x + 1];
1226         temp_col = scanline->buffer[x + 1];
12161227
1217            /* perform color math if the layer wants it (except if it's an object > 192) */
1218            if (!scanlines[SNES_MAINSCREEN].blend_exception[x + 1] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x + 1]].color_math)
1219               snes_draw_blend_lores(x + 1, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
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);
12201231
1221            r = ((c & 0x1f) * fade) >> 4;
1222            g = (((c & 0x3e0) >> 5) * fade) >> 4;
1223            b = (((c & 0x7c00) >> 10) * fade) >> 4;
1232         r = ((c & 0x1f) * fade) >> 4;
1233         g = (((c & 0x3e0) >> 5) * fade) >> 4;
1234         b = (((c & 0x7c00) >> 10) * fade) >> 4;
12241235
1225            *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1236         *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1237         if (!hires)
12261238            *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1227
1228         }
1229#if 0
12301239         else
12311240         {
1232            int r, g, b;
1233            UINT16 temp_col;
1234            c = scanline->buffer[x];
1235            temp_col = scanline->buffer[x];
1241            c = scanlines[SNES_SUBSCREEN].buffer[x + 1];
1242            scanlines[SNES_SUBSCREEN].buffer[x + 1] = temp_col;
12361243
1237            /* perform color math if the layer wants it (except if it's an object > 192) */
1238            if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
1239               snes_draw_blend_hires(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
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);
12401246
12411247            r = ((c & 0x1f) * fade) >> 4;
12421248            g = (((c & 0x3e0) >> 5) * fade) >> 4;
12431249            b = (((c & 0x7c00) >> 10) * fade) >> 4;
12441250
1245            *BITMAP_ADDR32(bitmap, curline, x) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1246
1247            c = scanlines[SNES_SUBSCREEN].buffer[x];
1248            scanlines[SNES_SUBSCREEN].buffer[x] = temp_col;
1249
1250            /* perform color math only if it's been done on the previous pixel */
1251            if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
1252               snes_draw_blend_hires(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
1253
1254            r = ((c & 0x1f) * fade) >> 4;
1255            g = (((c & 0x3e0) >> 5) * fade) >> 4;
1256            b = (((c & 0x7c00) >> 10) * fade) >> 4;
1257
1258            *BITMAP_ADDR32(bitmap, curline, x + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1251            *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
12591252         }
1260#endif
12611253      }
12621254   }
12631255

Previous 15994 Revisions Next


© 1998-2018 The MESS Team