Created a NO$GBA style OAM Viewer for the wx gui

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1383 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
skidau 2015-05-02 15:35:42 +00:00
parent 04926d67c0
commit 585a3da290
3 changed files with 206 additions and 155 deletions

View File

@ -725,7 +725,7 @@ namespace Viewers {
class OAMViewer : public GfxViewer class OAMViewer : public GfxViewer
{ {
public: public:
OAMViewer() : GfxViewer(wxT("OAMViewer"), 64, 64) OAMViewer() : GfxViewer(wxT("OAMViewer"), 544, 496)
{ {
sprite = 0; sprite = 0;
getspin(,"Sprite", sprite); getspin(,"Sprite", sprite);
@ -743,10 +743,22 @@ namespace Viewers {
} }
void Update() void Update()
{ {
u16 *sparms = &((u16 *)oam)[4 * sprite]; BMPSize(544, 496);
wxImage screen(240, 160);
systemRedShift = 19;
systemGreenShift = 11;
systemBlueShift = 3;
utilReadScreenPixels(screen.GetData(), 240, 160);
systemRedShift = 3;
systemGreenShift = 11;
systemBlueShift = 19;
for (int sprite_no = 0; sprite_no < 128; sprite_no++)
{
u16 *sparms = &((u16 *)oam)[4 * sprite_no];
u16 a0 = sparms[0], a1 = sparms[1], a2 = sparms[2]; u16 a0 = sparms[0], a1 = sparms[1], a2 = sparms[2];
u16 *pal = &((u16 *)paletteRAM)[0x100]; u16 *pal = &((u16 *)paletteRAM)[0x100];
u8 *bmp = image.GetData();
int sizeX = 8, sizeY = 8; int sizeX = 8, sizeY = 8;
@ -803,12 +815,11 @@ namespace Viewers {
size->SetLabel(wxEmptyString); size->SetLabel(wxEmptyString);
rot->SetLabel(wxEmptyString); rot->SetLabel(wxEmptyString);
flg->SetLabel(wxEmptyString); flg->SetLabel(wxEmptyString);
BMPSize(sizeX, sizeY); continue;
memset(bmp, 0, 8 * 8 * 3);
ChangeBMP();
return;
} }
BMPSize(sizeX, sizeY);
wxImage spriteData(64, 64);
u8 *bmp = spriteData.GetData();
int sy = (a0 & 255); int sy = (a0 & 255);
@ -834,7 +845,8 @@ namespace Viewers {
} }
bmp += (64 - sizeX) * 3; bmp += (64 - sizeX) * 3;
} }
} else { }
else {
int c = (a2 & 0x3FF); int c = (a2 & 0x3FF);
//if((DISPCNT & 7) > 2 && (c < 512)) //if((DISPCNT & 7) > 2 && (c < 512))
// return; // return;
@ -860,8 +872,9 @@ namespace Viewers {
bmp += (64 - sizeX) * 3; bmp += (64 - sizeX) * 3;
} }
} }
ChangeBMP();
if (sprite == sprite_no)
{
wxString s; wxString s;
s.Printf(wxT("%d,%d"), a1 & 511, a0 & 255); s.Printf(wxT("%d,%d"), a1 & 511, a0 & 255);
pos->SetLabel(s); pos->SetLabel(s);
@ -875,6 +888,7 @@ namespace Viewers {
s.Printf(wxT("%d"), (a2 >> 10) & 3); s.Printf(wxT("%d"), (a2 >> 10) & 3);
prio->SetLabel(s); prio->SetLabel(s);
s.Printf(wxT("%dx%d"), sizeX, sizeY); s.Printf(wxT("%dx%d"), sizeX, sizeY);
s.Printf(wxT("%dx%d"), 0, 0);
size->SetLabel(s); size->SetLabel(s);
if(a0 & 512) { if(a0 & 512) {
s.Printf(wxT("%d"), (a1 >> 9) & 31); s.Printf(wxT("%d"), (a1 >> 9) & 31);
@ -892,6 +906,49 @@ namespace Viewers {
s.append(a0 & 4096 ? wxT('M') : wxT('-')); s.append(a0 & 4096 ? wxT('M') : wxT('-'));
s.append(a0 & 1024 ? wxT('D') : wxT('-')); s.append(a0 & 1024 ? wxT('D') : wxT('-'));
flg->SetLabel(s); flg->SetLabel(s);
u8 *box = spriteData.GetData();
int sprite_posx = a1 & 511;
int sprite_posy = a0 & 255;
u8 *screen_box = screen.GetData();
if (sprite_posx >= 0 && sprite_posx <= (239 - sizeY) && sprite_posy >= 0 && sprite_posy <= (159 - sizeX))
screen_box += (sprite_posx * 3) + (sprite_posy * screen.GetWidth() * 3);
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
u32 color = 0;
if (y == 0 || y == sizeY - 1 || x == 0 || x == sizeX - 1)
{
color = 255;
*box++ = (color & 0x1f) << 3;
*box++ = ((color >> 5) & 0x1f) << 3;
*box++ = ((color >> 10) & 0x1f) << 3;
if (sprite_posx >= 0 && sprite_posx <= (239 - sizeY) && sprite_posy >= 0 && sprite_posy <= (159 - sizeX))
{
*screen_box++ = (color & 0x1f) << 3;
*screen_box++ = ((color >> 5) & 0x1f) << 3;
*screen_box++ = ((color >> 10) & 0x1f) << 3;
}
}
else
{
box += 3;
if (sprite_posx >= 0 && sprite_posx <= (239 - sizeY) && sprite_posy >= 0 && sprite_posy <= (159 - sizeX))
screen_box += 3;
}
}
box += (spriteData.GetWidth() - sizeX) * 3;
if (sprite_posx >= 0 && sprite_posx <= (239 - sizeY) && sprite_posy >= 0 && sprite_posy <= (159 - sizeX))
screen_box += (screen.GetWidth() - sizeX) * 3;
}
}
image.Paste(spriteData, (sprite_no % 16) * 34, (sprite_no / 16) * 34);
}
image.Paste(screen, 0, 304);
ChangeBMP();
} }
protected: protected:
int sprite; int sprite;

View File

@ -5220,11 +5220,8 @@
<object class="sizeritem"> <object class="sizeritem">
<object class="wxScrolledWindow"> <object class="wxScrolledWindow">
<object class="wxPanel" name="GfxView" subclass="GfxPanel"> <object class="wxPanel" name="GfxView" subclass="GfxPanel">
<size>128,128d</size> <size>544,496</size>
<style>wxFULL_REPAINT_ON_RESIZE</style>
</object> </object>
<size>128,128d</size>
<style>wxBORDER_SUNKEN|wxCLIP_CHILDREN</style>
</object> </object>
<flag>wxALL</flag> <flag>wxALL</flag>
<border>5</border> <border>5</border>

View File

@ -121,11 +121,8 @@
<object class="sizeritem"> <object class="sizeritem">
<object class="wxScrolledWindow"> <object class="wxScrolledWindow">
<object class="wxPanel" name="GfxView" subclass="GfxPanel"> <object class="wxPanel" name="GfxView" subclass="GfxPanel">
<size>64,64d</size> <size>544,496</size>
<style>wxFULL_REPAINT_ON_RESIZE</style>
</object> </object>
<size>64,64d</size>
<style>wxBORDER_SUNKEN|wxCLIP_CHILDREN</style>
</object> </object>
<flag>wxALL</flag> <flag>wxALL</flag>
<border>5</border> <border>5</border>