Previous 15994 Revisions Next

r7313 Wednesday 10th February, 2010 at 17:53:45 UTC by Fabio Priuli
[SNES] fixed the remaining debug functionalities
[src/mame/includes]snes.h
[src/mame/video]snes.c
[src/mess/drivers]snes.c

src/mame/includes/snes.h
r7312r7313
2323#define DOTCLK_NTSC   (MCLK_NTSC/4)
2424#define DOTCLK_PAL   (MCLK_PAL/4)
2525
26#define SNES_LAYER_DEBUG  0
27
2628/* Debug definitions */
2729#ifdef MAME_DEBUG
2830/* #define SNES_DBG_GENERAL*/      /* Display general debug info */
29/* #define SNES_DBG_video*/      /* Display video debug info */
31/* #define SNES_DBG_VIDEO */      /* Display video debug info */
3032/* #define SNES_DBG_GDMA*/         /* Display GDMA debug info */
3133/* #define SNES_DBG_HDMA*/         /* Display HDMA debug info */
3234/* #define SNES_DBG_REG_R*/         /* Display register read info */
src/mame/video/snes.c
r7312r7313
8181#define SNES_CLIP_OUT      2
8282#define SNES_CLIP_ALL2     3
8383
84#ifdef MAME_DEBUG
84#ifdef SNES_LAYER_DEBUG
8585struct DEBUGOPTS
8686{
8787   UINT8 input_count;
r7312r7313
9595/*                                    red   green  blue    purple  yellow cyan    grey    white */
9696static const UINT16 dbg_mode_colours[8] = { 0x1f, 0x3e0, 0x7c00, 0x7c1f, 0x3ff, 0x7fe0, 0x4210, 0x7fff };
9797static UINT8 snes_dbg_video(running_machine *machine, bitmap_t *bitmap, UINT16 curline);
98#endif /* MAME_DEBUG */
98#endif /* SNES_LAYER_DEBUG */
9999
100100static const UINT16 table_obj_offset[8][8] =
101101{
r7312r7313
146146   if (clip == SNES_CLIP_ALL2) // blending mode 3 == always OFF
147147      return;
148148
149#ifdef MAME_DEBUG
149#ifdef SNES_LAYER_DEBUG
150150   if (!debug_options.transparency_disabled)
151#endif /* MAME_DEBUG */
151#endif /* SNES_LAYER_DEBUG */
152152   if ((clip == SNES_CLIP_ALL) ||
153153      (clip == SNES_CLIP_IN  && !snes_ppu.clipmasks[SNES_COLOR][offset]) ||
154154      (clip == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset]))
r7312r7313
264264         mask >>= 1;
265265      }
266266
267#ifdef MAME_DEBUG
267#ifdef SNES_LAYER_DEBUG
268268      if (!debug_options.windows_disabled)
269#endif /* MAME_DEBUG */
269#endif /* SNES_LAYER_DEBUG */
270270      /* Clip to windows */
271271      window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled;
272272      if (window_enabled)
r7312r7313
372372         mask >>= 1;
373373      }
374374
375#ifdef MAME_DEBUG
375#ifdef SNES_LAYER_DEBUG
376376      if (!debug_options.windows_disabled)
377#endif /* MAME_DEBUG */
377#endif /* SNES_LAYER_DEBUG */
378378      /* Clip to windows */
379      window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[4].main_window_enabled : snes_ppu.layer[SNES_OAM].sub_window_enabled;
379      window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[SNES_OAM].main_window_enabled : snes_ppu.layer[SNES_OAM].sub_window_enabled;
380380      if (window_enabled)
381381         colour &= snes_ppu.clipmasks[SNES_OAM][ii];
382382
r7312r7313
426426   UINT8 tile_divider = 1;
427427   UINT8 wrap_around_x; //helper for wrap-around
428428
429#ifdef MAME_DEBUG
429#ifdef SNES_LAYER_DEBUG
430430   if (debug_options.bg_disabled[layer])
431431      return;
432432
433433   if (debug_options.mode_disabled[snes_ppu.mode])
434434      return;
435#endif /* MAME_DEBUG */
435#endif /* SNES_LAYER_DEBUG */
436436
437437   /* Handle Mosaic effects */
438438   if (snes_ppu.layer[layer].mosaic_enabled)
r7312r7313
599599   UINT8 colour = 0, window_enabled = 0;
600600   UINT16 *mosaic_x, *mosaic_y;
601601
602#ifdef MAME_DEBUG
602#ifdef SNES_LAYER_DEBUG
603603   if (debug_options.bg_disabled[layer])
604604      return;
605605
606606   if (debug_options.mode_disabled[snes_ppu.mode])
607607      return;
608#endif /* MAME_DEBUG */
608#endif /* SNES_LAYER_DEBUG */
609609
610610   ma = snes_ppu.mode7.matrix_a;
611611   mb = snes_ppu.mode7.matrix_b;
r7312r7313
756756                  {1, 2, 5, 8}   // mode 1 + BG3 priority bit
757757   };
758758
759#ifdef MAME_DEBUG
759#ifdef SNES_LAYER_DEBUG
760760   if (debug_options.bg_disabled[4])
761761      return;
762#endif /* MAME_DEBUG */
762#endif /* SNES_LAYER_DEBUG */
763763
764764   if (snes_ppu.mode == 5 || snes_ppu.mode == 6)
765765      widemode = 1;
r7312r7313
874874   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
875875
876876   if (bg_enabled[4]) snes_update_objects(screen, 0, curline);
877   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 7, 10, 0, curline, 0, 0);
878   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, 1, curline, 0, 0);
879   if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, 2, curline, 0, 0);
880   if (bg_enabled[3]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 3, 3, curline, 0, 0);
877   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 7, 10, SNES_BG1, curline, 0, 0);
878   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, 0, 0);
879   if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, 0, 0);
880   if (bg_enabled[3]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 3, SNES_BG4, curline, 0, 0);
881881}
882882
883883static void snes_update_mode_1( UINT8 screen, UINT16 curline )
r7312r7313
888888   if (!snes_ppu.bg3_priority_bit)
889889   {
890890      if (bg_enabled[4]) snes_update_objects(screen, 1, curline);
891      if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 5, 8, 0, curline, 0, 0);
892      if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, 1, curline, 0, 0);
893      if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 2, 2, curline, 0, 0);
891      if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 5, 8, SNES_BG1, curline, 0, 0);
892      if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, 0, 0);
893      if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, 0, 0);
894894   }
895895   else
896896   {
897897      if (bg_enabled[4]) snes_update_objects(screen, 9, curline);
898      if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, 0, curline, 0, 0);
899      if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 3, 6, 1, curline, 0, 0);
900      if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 9, 2, curline, 0, 0);
898      if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG1, curline, 0, 0);
899      if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, 0, 0);
900      if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 9, SNES_BG3, curline, 0, 0);
901901   }
902902}
903903
r7312r7313
907907   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
908908
909909   if (bg_enabled[4]) snes_update_objects(screen, 2, curline);
910   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, 0, curline, 1, 0);
911   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, 1, curline, 1, 0);
910   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, 1, 0);
911   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 1, 0);
912912}
913913
914914static void snes_update_mode_3( UINT8 screen, UINT16 curline )
r7312r7313
917917   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
918918
919919   if (bg_enabled[4]) snes_update_objects(screen, 3, curline);
920   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, 0, curline, 0, snes_ppu.direct_color);
921   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, 1, curline, 0, 0);
920   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color);
921   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 0, 0);
922922}
923923
924924static void snes_update_mode_4( UINT8 screen, UINT16 curline )
r7312r7313
927927   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
928928
929929   if (bg_enabled[4]) snes_update_objects(screen, 4, curline);
930   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, 0, curline, 0, snes_ppu.direct_color);
931   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 4, 1, curline, 0, 0);
930   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color);
931   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, 0, 0);
932932}
933933
934934static void snes_update_mode_5( UINT8 screen, UINT16 curline )
r7312r7313
937937   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
938938
939939   if (bg_enabled[4]) snes_update_objects(screen, 5, curline);
940   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, 0, curline, 0, 0);
941   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 1, 0, 4, 1, curline, 0, 0);
940   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, 0, 0);
941   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, 0, 0);
942942}
943943
944944static void snes_update_mode_6( UINT8 screen, UINT16 curline )
r7312r7313
947947   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
948948
949949   if (bg_enabled[4]) snes_update_objects(screen, 6, curline);
950   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, 0, curline, 1, 0);
950   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, 1, 0);
951951}
952952
953953static void snes_update_mode_7( UINT8 screen, UINT16 curline )
r7312r7313
958958   if (!snes_ppu.mode7.extbg)
959959   {
960960      if (bg_enabled[4]) snes_update_objects(screen, 7, curline);
961      if (bg_enabled[0]) snes_update_line_mode7(screen, 1, 1, 0, curline);
961      if (bg_enabled[0]) snes_update_line_mode7(screen, 1, 1, SNES_BG1, curline);
962962   }
963963   else
964964   {
965965      if (bg_enabled[4]) snes_update_objects(screen, 8, curline);
966      if (bg_enabled[0]) snes_update_line_mode7(screen, 2, 2, 0, curline);
967      if (bg_enabled[1]) snes_update_line_mode7(screen, 0, 4, 1, curline);
966      if (bg_enabled[0]) snes_update_line_mode7(screen, 2, 2, SNES_BG1, curline);
967      if (bg_enabled[1]) snes_update_line_mode7(screen, 0, 4, SNES_BG2, curline);
968968   }
969969}
970970
r7312r7313
11891189      /* Draw SNES_SUBSCREEN */
11901190      snes_draw_screen(SNES_SUBSCREEN, curline);
11911191
1192
11931192      /* Draw SNES_MAINSCREEN */
11941193      snes_draw_screen(SNES_MAINSCREEN, curline);
11951194
1196#ifdef MAME_DEBUG
1195#ifdef SNES_LAYER_DEBUG
11971196      if (snes_dbg_video(machine, bitmap, curline))
11981197      {
11991198         profiler_mark_end();
r7312r7313
12041203      if (debug_options.draw_subscreen)
12051204         scanline = &scanlines[SNES_SUBSCREEN];
12061205      else
1207#endif /* MAME_DEBUG */
1206#endif /* SNES_LAYER_DEBUG */
12081207         scanline = &scanlines[SNES_MAINSCREEN];
12091208
12101209      /* Phew! Draw the line to screen */
r7312r7313
12121211
12131212      for (x = 0; x < SNES_SCR_WIDTH * 2; x++)
12141213      {
1214         int r, g, b;
12151215         c = scanline->buffer[x];
1216
12161217         /* perform color math if the layer wants it (except if it's an object > 192) */
12171218         if (!scanlines[SNES_MAINSCREEN].blend_exception[x] &&
12181219            ((scanlines[SNES_MAINSCREEN].layer[x] != SNES_COLOR && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
12191220            || (scanlines[SNES_MAINSCREEN].layer[x] == SNES_COLOR && snes_ppu.colour.color_math)))
12201221            snes_draw_blend(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
12211222
1222         int r = ((c & 0x1f) * fade) >> 4;
1223         int g = (((c & 0x3e0) >> 5) * fade) >> 4;
1224         int b = (((c & 0x7c00) >> 10) * fade) >> 4;
1223         r = ((c & 0x1f) * fade) >> 4;
1224         g = (((c & 0x3e0) >> 5) * fade) >> 4;
1225         b = (((c & 0x7c00) >> 10) * fade) >> 4;
12251226
12261227         if (snes_htmult == 1)
12271228         {
1228            *BITMAP_ADDR32(bitmap, curline, x*2+0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1229            *BITMAP_ADDR32(bitmap, curline, x*2+1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1229            *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1230            *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
12301231         }
12311232         else
12321233            *BITMAP_ADDR32(bitmap, curline, x) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
r7312r7313
12381239
12391240VIDEO_START( snes )
12401241{
1241#ifdef MAME_DEBUG
1242#ifdef SNES_LAYER_DEBUG
12421243   memset(&debug_options, 0, sizeof(debug_options));
12431244   debug_options.input_count = 5;
12441245#endif
r7312r7313
12501251
12511252   /*NTSC SNES draw range is 1-225. */
12521253   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
1253      snes_refresh_scanline(screen->machine, bitmap, y+1);
1254      snes_refresh_scanline(screen->machine, bitmap, y + 1);
12541255   return 0;
12551256}
12561257
12571258
12581259/***** Debug Functions *****/
12591260
1260#ifdef MAME_DEBUG
1261#ifdef SNES_LAYER_DEBUG
12611262
12621263static UINT8 snes_dbg_video( running_machine *machine, bitmap_t *bitmap, UINT16 curline )
12631264{
12641265   /* Check if the user has enabled or disabled stuff */
1265   if (curline == 0)
1266   if (curline == 1)
12661267   {
12671268      //UINT16 y = 1;
12681269      static const char WINLOGIC[4] = { '|', '&', '^', '!' };
r7312r7313
14151416   return 0;
14161417}
14171418
1418#endif /* MAME_DEBUG */
1419#endif /* SNES_LAYER_DEBUG */
src/mess/drivers/snes.c
r7312r7313
158158   PORT_CONFSETTING(   0x0, DEF_STR( No ) )
159159   PORT_CONFSETTING(   0x1, DEF_STR( Yes ) )
160160
161#ifdef MAME_DEBUG
161#ifdef SNES_LAYER_DEBUG
162162   PORT_START("DEBUG1")   /* debug switches */
163163   PORT_DIPNAME( 0x3, 0x0, "Browse tiles" )
164164   PORT_DIPSETTING(   0x0, DEF_STR( Off ) )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team