snesgfxdebugger-fix a bunch of bugs and half-baked things. no new features. (part 3 of N)

This commit is contained in:
zeromus 2012-12-02 23:58:20 +00:00
parent 5fcf41ebbc
commit 3dd1c5c493
3 changed files with 196 additions and 16 deletions

View File

@ -80,7 +80,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
public enum BGMode public enum BGMode
{ {
Unavailable, Text, Mode7, Mode7Ext, Mode7DC Unavailable, Text, Mode7, Mode7Ext, Mode7DC, OBJ
} }

View File

@ -201,6 +201,7 @@
this.lblDetailsOBJOrBG = new System.Windows.Forms.Label(); this.lblDetailsOBJOrBG = new System.Windows.Forms.Label();
this.pnDetailsPaletteColor = new System.Windows.Forms.Panel(); this.pnDetailsPaletteColor = new System.Windows.Forms.Panel();
this.tpTile = new System.Windows.Forms.TabPage(); this.tpTile = new System.Windows.Forms.TabPage();
this.txtTileNumber = new System.Windows.Forms.TextBox();
this.txtTileMode = new System.Windows.Forms.TextBox(); this.txtTileMode = new System.Windows.Forms.TextBox();
this.label18 = new System.Windows.Forms.Label(); this.label18 = new System.Windows.Forms.Label();
this.txtTileColors = new System.Windows.Forms.TextBox(); this.txtTileColors = new System.Windows.Forms.TextBox();
@ -223,10 +224,19 @@
this.txtMapEntryTileNum = new System.Windows.Forms.TextBox(); this.txtMapEntryTileNum = new System.Windows.Forms.TextBox();
this.viewerMapEntryTile = new BizHawk.MultiClient.SNESGraphicsViewer(); this.viewerMapEntryTile = new BizHawk.MultiClient.SNESGraphicsViewer();
this.tpOBJ = new System.Windows.Forms.TabPage(); this.tpOBJ = new System.Windows.Forms.TabPage();
this.txtObjNumber = new System.Windows.Forms.TextBox();
this.txtObjCoord = new System.Windows.Forms.TextBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.label43 = new System.Windows.Forms.Label();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.label44 = new System.Windows.Forms.Label();
this.viewerObj = new BizHawk.MultiClient.SNESGraphicsViewer();
this.viewerPanel = new System.Windows.Forms.Panel(); this.viewerPanel = new System.Windows.Forms.Panel();
this.viewer = new BizHawk.MultiClient.SNESGraphicsViewer(); this.viewer = new BizHawk.MultiClient.SNESGraphicsViewer();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.messagetimer = new System.Windows.Forms.Timer(this.components); this.messagetimer = new System.Windows.Forms.Timer(this.components);
this.txtTilePalette = new System.Windows.Forms.TextBox();
this.label45 = new System.Windows.Forms.Label();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
@ -244,6 +254,7 @@
this.tpPalette.SuspendLayout(); this.tpPalette.SuspendLayout();
this.tpTile.SuspendLayout(); this.tpTile.SuspendLayout();
this.tpMapEntry.SuspendLayout(); this.tpMapEntry.SuspendLayout();
this.tpOBJ.SuspendLayout();
this.viewerPanel.SuspendLayout(); this.viewerPanel.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -2123,6 +2134,9 @@
// //
// tpTile // tpTile
// //
this.tpTile.Controls.Add(this.label45);
this.tpTile.Controls.Add(this.txtTilePalette);
this.tpTile.Controls.Add(this.txtTileNumber);
this.tpTile.Controls.Add(this.txtTileMode); this.tpTile.Controls.Add(this.txtTileMode);
this.tpTile.Controls.Add(this.label18); this.tpTile.Controls.Add(this.label18);
this.tpTile.Controls.Add(this.txtTileColors); this.tpTile.Controls.Add(this.txtTileColors);
@ -2138,20 +2152,30 @@
this.tpTile.Text = "Tile"; this.tpTile.Text = "Tile";
this.tpTile.UseVisualStyleBackColor = true; this.tpTile.UseVisualStyleBackColor = true;
// //
// txtTileNumber
//
this.txtTileNumber.Location = new System.Drawing.Point(76, 6);
this.txtTileNumber.Multiline = true;
this.txtTileNumber.Name = "txtTileNumber";
this.txtTileNumber.ReadOnly = true;
this.txtTileNumber.Size = new System.Drawing.Size(54, 18);
this.txtTileNumber.TabIndex = 63;
this.txtTileNumber.Text = "#$DDD";
//
// txtTileMode // txtTileMode
// //
this.txtTileMode.Location = new System.Drawing.Point(132, 6); this.txtTileMode.Location = new System.Drawing.Point(139, 6);
this.txtTileMode.Multiline = true; this.txtTileMode.Multiline = true;
this.txtTileMode.Name = "txtTileMode"; this.txtTileMode.Name = "txtTileMode";
this.txtTileMode.ReadOnly = true; this.txtTileMode.ReadOnly = true;
this.txtTileMode.Size = new System.Drawing.Size(66, 18); this.txtTileMode.Size = new System.Drawing.Size(59, 18);
this.txtTileMode.TabIndex = 62; this.txtTileMode.TabIndex = 62;
this.txtTileMode.Text = "Text 8bpp"; this.txtTileMode.Text = "Text 8bpp";
// //
// label18 // label18
// //
this.label18.AutoSize = true; this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(172, 49); this.label18.Location = new System.Drawing.Point(169, 49);
this.label18.Name = "label18"; this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(36, 13); this.label18.Size = new System.Drawing.Size(36, 13);
this.label18.TabIndex = 61; this.label18.TabIndex = 61;
@ -2159,28 +2183,28 @@
// //
// txtTileColors // txtTileColors
// //
this.txtTileColors.Location = new System.Drawing.Point(132, 48); this.txtTileColors.Location = new System.Drawing.Point(139, 48);
this.txtTileColors.Multiline = true; this.txtTileColors.Multiline = true;
this.txtTileColors.Name = "txtTileColors"; this.txtTileColors.Name = "txtTileColors";
this.txtTileColors.ReadOnly = true; this.txtTileColors.ReadOnly = true;
this.txtTileColors.Size = new System.Drawing.Size(36, 17); this.txtTileColors.Size = new System.Drawing.Size(28, 17);
this.txtTileColors.TabIndex = 60; this.txtTileColors.TabIndex = 60;
this.txtTileColors.Text = "32768"; this.txtTileColors.Text = "256";
// //
// txtTileBpp // txtTileBpp
// //
this.txtTileBpp.Location = new System.Drawing.Point(132, 29); this.txtTileBpp.Location = new System.Drawing.Point(139, 28);
this.txtTileBpp.Multiline = true; this.txtTileBpp.Multiline = true;
this.txtTileBpp.Name = "txtTileBpp"; this.txtTileBpp.Name = "txtTileBpp";
this.txtTileBpp.ReadOnly = true; this.txtTileBpp.ReadOnly = true;
this.txtTileBpp.Size = new System.Drawing.Size(24, 17); this.txtTileBpp.Size = new System.Drawing.Size(28, 17);
this.txtTileBpp.TabIndex = 59; this.txtTileBpp.TabIndex = 59;
this.txtTileBpp.Text = "8"; this.txtTileBpp.Text = "8";
// //
// label42 // label42
// //
this.label42.AutoSize = true; this.label42.AutoSize = true;
this.label42.Location = new System.Drawing.Point(173, 31); this.label42.Location = new System.Drawing.Point(169, 30);
this.label42.Name = "label42"; this.label42.Name = "label42";
this.label42.Size = new System.Drawing.Size(32, 13); this.label42.Size = new System.Drawing.Size(32, 13);
this.label42.TabIndex = 58; this.label42.TabIndex = 58;
@ -2188,11 +2212,11 @@
// //
// txtTileAddress // txtTileAddress
// //
this.txtTileAddress.Location = new System.Drawing.Point(76, 6); this.txtTileAddress.Location = new System.Drawing.Point(76, 27);
this.txtTileAddress.Multiline = true; this.txtTileAddress.Multiline = true;
this.txtTileAddress.Name = "txtTileAddress"; this.txtTileAddress.Name = "txtTileAddress";
this.txtTileAddress.ReadOnly = true; this.txtTileAddress.ReadOnly = true;
this.txtTileAddress.Size = new System.Drawing.Size(50, 18); this.txtTileAddress.Size = new System.Drawing.Size(54, 18);
this.txtTileAddress.TabIndex = 57; this.txtTileAddress.TabIndex = 57;
this.txtTileAddress.Text = "@DDDD"; this.txtTileAddress.Text = "@DDDD";
// //
@ -2356,6 +2380,13 @@
// //
// tpOBJ // tpOBJ
// //
this.tpOBJ.Controls.Add(this.txtObjNumber);
this.tpOBJ.Controls.Add(this.txtObjCoord);
this.tpOBJ.Controls.Add(this.checkBox1);
this.tpOBJ.Controls.Add(this.label43);
this.tpOBJ.Controls.Add(this.checkBox2);
this.tpOBJ.Controls.Add(this.label44);
this.tpOBJ.Controls.Add(this.viewerObj);
this.tpOBJ.Location = new System.Drawing.Point(4, 22); this.tpOBJ.Location = new System.Drawing.Point(4, 22);
this.tpOBJ.Name = "tpOBJ"; this.tpOBJ.Name = "tpOBJ";
this.tpOBJ.Size = new System.Drawing.Size(206, 94); this.tpOBJ.Size = new System.Drawing.Size(206, 94);
@ -2363,6 +2394,73 @@
this.tpOBJ.Text = "OBJ"; this.tpOBJ.Text = "OBJ";
this.tpOBJ.UseVisualStyleBackColor = true; this.tpOBJ.UseVisualStyleBackColor = true;
// //
// txtObjNumber
//
this.txtObjNumber.Location = new System.Drawing.Point(76, 6);
this.txtObjNumber.Multiline = true;
this.txtObjNumber.Name = "txtObjNumber";
this.txtObjNumber.ReadOnly = true;
this.txtObjNumber.Size = new System.Drawing.Size(43, 18);
this.txtObjNumber.TabIndex = 68;
this.txtObjNumber.Text = "#$DD";
//
// txtObjCoord
//
this.txtObjCoord.Location = new System.Drawing.Point(125, 6);
this.txtObjCoord.Multiline = true;
this.txtObjCoord.Name = "txtObjCoord";
this.txtObjCoord.ReadOnly = true;
this.txtObjCoord.Size = new System.Drawing.Size(65, 18);
this.txtObjCoord.TabIndex = 67;
this.txtObjCoord.Text = "(-239,-239)";
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Enabled = false;
this.checkBox1.Location = new System.Drawing.Point(42, 76);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(15, 14);
this.checkBox1.TabIndex = 65;
this.checkBox1.UseVisualStyleBackColor = true;
//
// label43
//
this.label43.AutoSize = true;
this.label43.Location = new System.Drawing.Point(56, 76);
this.label43.Name = "label43";
this.label43.Size = new System.Drawing.Size(14, 13);
this.label43.TabIndex = 66;
this.label43.Text = "V";
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Enabled = false;
this.checkBox2.Location = new System.Drawing.Point(8, 76);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(15, 14);
this.checkBox2.TabIndex = 63;
this.checkBox2.UseVisualStyleBackColor = true;
//
// label44
//
this.label44.AutoSize = true;
this.label44.Location = new System.Drawing.Point(22, 76);
this.label44.Name = "label44";
this.label44.Size = new System.Drawing.Size(15, 13);
this.label44.TabIndex = 64;
this.label44.Text = "H";
//
// viewerObj
//
this.viewerObj.BackColor = System.Drawing.Color.Transparent;
this.viewerObj.Location = new System.Drawing.Point(6, 6);
this.viewerObj.Name = "viewerObj";
this.viewerObj.Size = new System.Drawing.Size(64, 64);
this.viewerObj.TabIndex = 21;
this.viewerObj.TabStop = false;
//
// viewerPanel // viewerPanel
// //
this.viewerPanel.AutoScroll = true; this.viewerPanel.AutoScroll = true;
@ -2398,6 +2496,25 @@
this.messagetimer.Interval = 5000; this.messagetimer.Interval = 5000;
this.messagetimer.Tick += new System.EventHandler(this.messagetimer_Tick); this.messagetimer.Tick += new System.EventHandler(this.messagetimer_Tick);
// //
// txtTilePalette
//
this.txtTilePalette.Location = new System.Drawing.Point(139, 68);
this.txtTilePalette.Multiline = true;
this.txtTilePalette.Name = "txtTilePalette";
this.txtTilePalette.ReadOnly = true;
this.txtTilePalette.Size = new System.Drawing.Size(29, 18);
this.txtTilePalette.TabIndex = 64;
this.txtTilePalette.Text = "$FF";
//
// label45
//
this.label45.AutoSize = true;
this.label45.Location = new System.Drawing.Point(169, 70);
this.label45.Name = "label45";
this.label45.Size = new System.Drawing.Size(22, 13);
this.label45.TabIndex = 65;
this.label45.Text = "Pal";
//
// SNESGraphicsDebugger // SNESGraphicsDebugger
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -2440,6 +2557,8 @@
this.tpTile.PerformLayout(); this.tpTile.PerformLayout();
this.tpMapEntry.ResumeLayout(false); this.tpMapEntry.ResumeLayout(false);
this.tpMapEntry.PerformLayout(); this.tpMapEntry.PerformLayout();
this.tpOBJ.ResumeLayout(false);
this.tpOBJ.PerformLayout();
this.viewerPanel.ResumeLayout(false); this.viewerPanel.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -2645,5 +2764,15 @@
private System.Windows.Forms.TextBox txtTileBpp; private System.Windows.Forms.TextBox txtTileBpp;
private System.Windows.Forms.Label label42; private System.Windows.Forms.Label label42;
private System.Windows.Forms.TextBox txtTileAddress; private System.Windows.Forms.TextBox txtTileAddress;
private SNESGraphicsViewer viewerObj;
private System.Windows.Forms.TextBox txtObjNumber;
private System.Windows.Forms.TextBox txtObjCoord;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Label label43;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.Label label44;
private System.Windows.Forms.TextBox txtTileNumber;
private System.Windows.Forms.Label label45;
private System.Windows.Forms.TextBox txtTilePalette;
} }
} }

View File

@ -449,6 +449,8 @@ namespace BizHawk.MultiClient
case eDisplayType.TilesMode7: return SNESGraphicsDecoder.BGMode.Mode7; case eDisplayType.TilesMode7: return SNESGraphicsDecoder.BGMode.Mode7;
case eDisplayType.TilesMode7Ext: return SNESGraphicsDecoder.BGMode.Mode7Ext; case eDisplayType.TilesMode7Ext: return SNESGraphicsDecoder.BGMode.Mode7Ext;
case eDisplayType.TilesMode7DC: return SNESGraphicsDecoder.BGMode.Mode7DC; case eDisplayType.TilesMode7DC: return SNESGraphicsDecoder.BGMode.Mode7DC;
case eDisplayType.OBJ0: return SNESGraphicsDecoder.BGMode.OBJ;
case eDisplayType.OBJ1: return SNESGraphicsDecoder.BGMode.OBJ;
default: throw new InvalidOperationException(); default: throw new InvalidOperationException();
} }
} }
@ -691,6 +693,7 @@ namespace BizHawk.MultiClient
{ {
if (mode == SNESGraphicsDecoder.BGMode.Unavailable) return "Unavailable"; if (mode == SNESGraphicsDecoder.BGMode.Unavailable) return "Unavailable";
if (mode == SNESGraphicsDecoder.BGMode.Text) return string.Format("Text{0}bpp", bpp); if (mode == SNESGraphicsDecoder.BGMode.Text) return string.Format("Text{0}bpp", bpp);
if (mode == SNESGraphicsDecoder.BGMode.OBJ) return string.Format("OBJ", bpp);
if (mode == SNESGraphicsDecoder.BGMode.Mode7) return "Mode7"; if (mode == SNESGraphicsDecoder.BGMode.Mode7) return "Mode7";
if (mode == SNESGraphicsDecoder.BGMode.Mode7Ext) return "Mode7Ext"; if (mode == SNESGraphicsDecoder.BGMode.Mode7Ext) return "Mode7Ext";
if (mode == SNESGraphicsDecoder.BGMode.Mode7DC) return "Mode7DC"; if (mode == SNESGraphicsDecoder.BGMode.Mode7DC) return "Mode7DC";
@ -706,7 +709,9 @@ namespace BizHawk.MultiClient
txtTileMode.Text = BGModeShortName(mode, bpp); txtTileMode.Text = BGModeShortName(mode, bpp);
txtTileBpp.Text = currTileDataState.Bpp.ToString(); txtTileBpp.Text = currTileDataState.Bpp.ToString();
txtTileColors.Text = (1 << currTileDataState.Bpp).ToString(); txtTileColors.Text = (1 << currTileDataState.Bpp).ToString();
txtTileNumber.Text = string.Format("#${0:X3}", currTileDataState.Tile);
txtTileAddress.Text = string.Format("@{0:X4}", currTileDataState.Address); txtTileAddress.Text = string.Format("@{0:X4}", currTileDataState.Address);
txtTilePalette.Text = string.Format("#{0:X2}", currTileDataState.Palette);
} }
void UpdateMapEntryDetails() void UpdateMapEntryDetails()
@ -779,6 +784,11 @@ namespace BizHawk.MultiClient
if (!valid) return; if (!valid) return;
selectedColorNum = pt.Y * 16 + pt.X; selectedColorNum = pt.Y * 16 + pt.X;
if (currTileDataState != null)
{
currTileDataState.Palette = currPaletteSelection.start;
}
SyncColorSelection(); SyncColorSelection();
UpdateValues(); UpdateValues();
} }
@ -912,9 +922,17 @@ namespace BizHawk.MultiClient
public int Bpp; public int Bpp;
public int Tile; public int Tile;
public int Address; public int Address;
public int Palette;
} }
TileDataState currTileDataState; TileDataState currTileDataState;
class ObjDataState
{
public int Number;
public SNESGraphicsDecoder.OAMInfo OAMInfo;
}
ObjDataState currObjDataState;
void RenderTileView() void RenderTileView()
{ {
if (currMapEntryState != null) if (currMapEntryState != null)
@ -955,6 +973,12 @@ namespace BizHawk.MultiClient
gd.RenderMode7TilesToScreen((int*)bmpdata.Scan0, bmpdata.Stride / 4, true, false, 1, currTileDataState.Tile, 1); gd.RenderMode7TilesToScreen((int*)bmpdata.Scan0, bmpdata.Stride / 4, true, false, 1, currTileDataState.Tile, 1);
else if (currTileDataState.Type == eDisplayType.TilesMode7DC) else if (currTileDataState.Type == eDisplayType.TilesMode7DC)
gd.RenderMode7TilesToScreen((int*)bmpdata.Scan0, bmpdata.Stride / 4, false, true, 1, currTileDataState.Tile, 1); gd.RenderMode7TilesToScreen((int*)bmpdata.Scan0, bmpdata.Stride / 4, false, true, 1, currTileDataState.Tile, 1);
else if (currTileDataState.Type == eDisplayType.OBJ0 || currTileDataState.Type == eDisplayType.OBJ1)
{
//render an obj tile
int tile = currTileDataState.Address / 32;
gd.RenderTilesToScreen((int*)bmpdata.Scan0, 1, 1, bmpdata.Stride / 4, bpp, currPaletteSelection.start, tile, 1);
}
else gd.RenderTilesToScreen((int*)bmpdata.Scan0, 1, 1, bmpdata.Stride / 4, bpp, currPaletteSelection.start, currTileDataState.Tile, 1); else gd.RenderTilesToScreen((int*)bmpdata.Scan0, 1, 1, bmpdata.Stride / 4, bpp, currPaletteSelection.start, currTileDataState.Tile, 1);
bmp.UnlockBits(bmpdata); bmp.UnlockBits(bmpdata);
@ -973,12 +997,24 @@ namespace BizHawk.MultiClient
int tilesTall = pxtall / 8; int tilesTall = pxtall / 8;
if (tx < 0 || ty < 0 || tx >= tilestride || ty >= tilesTall) if (tx < 0 || ty < 0 || tx >= tilestride || ty >= tilesTall)
return; return;
int tilenum = ty * tilestride + tx;
currTileDataState = new TileDataState(); currTileDataState = new TileDataState();
currTileDataState.Bpp = bpp; currTileDataState.Bpp = bpp;
currTileDataState.Type = CurrDisplaySelection; currTileDataState.Type = CurrDisplaySelection;
currTileDataState.Tile = ty * tilestride + tx; currTileDataState.Tile = tilenum;
currTileDataState.Address = (bpp==7?8:bpp) * 8 * currTileDataState.Tile; currTileDataState.Address = (bpp==7?8:bpp) * 8 * currTileDataState.Tile;
if (SNESGraphicsDecoder.BGModeIsMode7Type(BGModeForDisplayType(CurrDisplaySelection))) currTileDataState.Palette = currPaletteSelection.start;
if (CurrDisplaySelection == eDisplayType.OBJ0 || CurrDisplaySelection == eDisplayType.OBJ1)
{
//adjust address according to
if (tilenum < 256)
currTileDataState.Address += si.OBJTable0Addr;
else
currTileDataState.Address += si.OBJTable1Addr - (256*32);
currTileDataState.Address &= 0xFFFF;
}
else if (SNESGraphicsDecoder.BGModeIsMode7Type(BGModeForDisplayType(CurrDisplaySelection)))
{ {
currTileDataState.Address *= 2; currTileDataState.Address *= 2;
} }
@ -986,6 +1022,15 @@ namespace BizHawk.MultiClient
SetTab(tpTile); SetTab(tpTile);
} }
void HandleSpriteMouseOver(int px, int py)
{
//currViewingSprite = tx + ty * 16;
//RenderView(); //remember, we were going to highlight the selected sprite somehow as we hover over it
int ox = px / 64;
int oy = py / 64;
//if(ox<0 || oy<0 || ox>
}
void SetTab(TabPage tpSet) void SetTab(TabPage tpSet)
{ {
//doesnt work well //doesnt work well
@ -1002,13 +1047,19 @@ namespace BizHawk.MultiClient
{ {
currMapEntryState = null; currMapEntryState = null;
currTileDataState = null; currTileDataState = null;
currObjDataState = null;
int tx = loc.X / 8; int tx = loc.X / 8;
int ty = loc.Y / 8; int ty = loc.Y / 8;
switch (CurrDisplaySelection) switch (CurrDisplaySelection)
{ {
case eDisplayType.OBJ0:
case eDisplayType.OBJ1:
HandleTileViewMouseOver(128, 256, 4, tx, ty);
break;
case eDisplayType.Sprites: case eDisplayType.Sprites:
//currViewingSprite = tx + ty * 16; HandleSpriteMouseOver(loc.X, loc.Y);
RenderView();
break; break;
case eDisplayType.Tiles2bpp: case eDisplayType.Tiles2bpp:
HandleTileViewMouseOver(512, 512, 2, tx, ty); HandleTileViewMouseOver(512, 512, 2, tx, ty);