Added a NO$GBA Style OAM Viewer. The OAM Viewer shows a previews every OAM and its location on the screen. Patch by StrepTeDa.

This commit is contained in:
skidau 2015-04-05 00:25:30 +00:00
parent 314f1bd8c5
commit 541b36f0f6
8 changed files with 825 additions and 656 deletions

View File

@ -44,6 +44,68 @@ static int (ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL;
static int (ZEXPORT *utilGzCloseFunc)(gzFile) = NULL; static int (ZEXPORT *utilGzCloseFunc)(gzFile) = NULL;
static z_off_t (ZEXPORT *utilGzSeekFunc)(gzFile, z_off_t, int) = NULL; static z_off_t (ZEXPORT *utilGzSeekFunc)(gzFile, z_off_t, int) = NULL;
void utilReadScreenPixels(u8* dest, int w, int h)
{
u8* b = dest;
int sizeX = w;
int sizeY = h;
switch (systemColorDepth) {
case 16:
{
u16 *p = (u16 *) (pix + (w + 2) * 2); // skip first black line
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
u16 v = *p++;
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
}
p++; // skip black pixel for filters
p++; // skip black pixel for filters
}
}
break;
case 24:
{
u8 *pixU8 = (u8 *) pix;
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
if (systemRedShift < systemBlueShift) {
*b++ = *pixU8++; // R
*b++ = *pixU8++; // G
*b++ = *pixU8++; // B
}
else {
int blue = *pixU8++;
int green = *pixU8++;
int red = *pixU8++;
*b++ = red;
*b++ = green;
*b++ = blue;
}
}
}
}
break;
case 32:
{
u32 *pixU32 = (u32 *) (pix + 4 * (w + 1));
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
u32 v = *pixU32++;
*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
}
pixU32++;
}
}
break;
}
}
bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix) bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)
{ {
#ifndef NO_PNG #ifndef NO_PNG

View File

@ -14,6 +14,7 @@ typedef struct {
void *address; void *address;
int size; int size;
} variable_desc; } variable_desc;
void utilReadScreenPixels(u8* dest, int w, int h);
bool utilWritePNGFile(const char *, int, int, u8 *); bool utilWritePNGFile(const char *, int, int, u8 *);
bool utilWriteBMPFile(const char *, int, int, u8 *); bool utilWriteBMPFile(const char *, int, int, u8 *);
void utilApplyIPS(const char *ips, uint8_t **rom, int *size); void utilApplyIPS(const char *ips, uint8_t **rom, int *size);

View File

@ -109,6 +109,12 @@ void BitmapControl::OnDraw(CDC* dc)
dc->BitBlt(0,0,w1,h1, dc->BitBlt(0,0,w1,h1,
&memDC,0,0,SRCCOPY); &memDC,0,0,SRCCOPY);
if (boxreigon.right != 0 && boxreigon.bottom != 0)
{
CBrush br = CBrush(RGB(255, 0, 0));
dc->FrameRect(&boxreigon, &br);
}
memDC.SelectObject(pOldBitmap); memDC.SelectObject(pOldBitmap);
bitmap.DeleteObject(); bitmap.DeleteObject();
@ -146,6 +152,10 @@ void BitmapControl::OnSize(UINT nType, int cx, int cy)
void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt) void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
{ {
GetParent()->SendMessage(WM_BITMAPCLICK,
GetDlgCtrlID(),
0);
if(!data) if(!data)
return; return;
int x = pt.x; int x = pt.x;
@ -200,6 +210,7 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
GetParent()->SendMessage(WM_MAPINFO, GetParent()->SendMessage(WM_MAPINFO,
point, point,
(LPARAM)colors); (LPARAM)colors);
} }
void BitmapControl::setBmpInfo(BITMAPINFO *info) void BitmapControl::setBmpInfo(BITMAPINFO *info)
@ -223,7 +234,13 @@ void BitmapControl::setSize(int w1, int h1)
SetScrollSizes(MM_TEXT, s); SetScrollSizes(MM_TEXT, s);
} }
} }
void BitmapControl::setSelectedRectangle(int x, int y, int width, int height)
{
boxreigon.left = x;
boxreigon.right = x + width;
boxreigon.top = y;
boxreigon.bottom = y + height;
}
void BitmapControl::refresh() void BitmapControl::refresh()
{ {
Invalidate(); Invalidate();

View File

@ -10,7 +10,9 @@
#ifndef WM_MAPINFO #ifndef WM_MAPINFO
#define WM_MAPINFO WM_APP+101 #define WM_MAPINFO WM_APP+101
#endif #endif
#ifndef WM_BITMAPCLICK
#define WM_BITMAPCLICK WM_APP+102
#endif
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// BitmapControl view // BitmapControl view
@ -29,6 +31,7 @@ class BitmapControl : public CScrollView
void setStretch(bool b); void setStretch(bool b);
void refresh(); void refresh();
void setSize(int w1, int h1); void setSize(int w1, int h1);
void setSelectedRectangle(int x, int y, int width, int height);
void setData(u8 *d); void setData(u8 *d);
void setBmpInfo(BITMAPINFO *info); void setBmpInfo(BITMAPINFO *info);
static bool isRegistered; static bool isRegistered;
@ -67,6 +70,7 @@ class BitmapControl : public CScrollView
u8 * data; u8 * data;
int h; int h;
int w; int w;
RECT boxreigon;
}; };
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View File

@ -1,16 +1,20 @@
// OamView.cpp : implementation file
//
#include "stdafx.h" #include "stdafx.h"
#include "vba.h"
#include "FileDlg.h"
#include "OamView.h" #include "OamView.h"
#include "Reg.h" #include "afxdialogex.h"
#include "Util.h"
#include "vba.h"
#include "WinResUtil.h" #include "WinResUtil.h"
#include "FileDlg.h"
#include "Reg.h"
#include "../System.h" #include "../System.h"
#include "../gba/GBA.h" #include "../gba/GBA.h"
#include "../gba/Globals.h" #include "../gba/Globals.h"
#include "../NLS.h" #include "../NLS.h"
#include "../Util.h" #include "../Util.h"
extern "C" { extern "C" {
#include <png.h> #include <png.h>
} }
@ -20,69 +24,62 @@ extern "C" {
#undef THIS_FILE #undef THIS_FILE
static char THIS_FILE[] = __FILE__; static char THIS_FILE[] = __FILE__;
#endif #endif
// OAM_VIEW dialog
///////////////////////////////////////////////////////////////////////////// IMPLEMENT_DYNAMIC(OamView, CDialog)
// OamView dialog OamViewable::OamViewable(int index, CDialog* parent)
{
RECT position;
int x = index % 16;
int y = index / 16;
position.left = 16 + 20 * x;
position.right = 16 + 20 * x + 19;
position.top = 16 + 20 * y;
position.bottom = 16 + 20 * y + 19;
oamView.Create("VbaBitmapControl", "OAM", WS_BORDER | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, position, parent, IDC_OAM1 + index);
memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader));
bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader);
bmpInfo.bmiHeader.biWidth = 64;
bmpInfo.bmiHeader.biHeight = 64;
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biBitCount = 24;
bmpInfo.bmiHeader.biCompression = BI_RGB;
w = 64;
h = 64;
data = (u8*)calloc(1, 3 * 64 * 64);
oamView.setSize(64, 64);
oamView.setData(data);
oamView.setBmpInfo(&bmpInfo);
}
OamViewable::~OamViewable()
{
free(data);
data = NULL;
}
OamView::OamView(CWnd* pParent /*=NULL*/) OamView::OamView(CWnd* pParent /*=NULL*/)
: ResizeDlg(OamView::IDD, pParent) : ResizeDlg(OamView::IDD, pParent)
{ {
//{{AFX_DATA_INIT(OamView)
m_stretch = FALSE;
//}}AFX_DATA_INIT
autoUpdate = false; autoUpdate = false;
selectednumber = 0;
memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader)); memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader));
bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader); bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader);
bmpInfo.bmiHeader.biWidth = 32; bmpInfo.bmiHeader.biWidth = 240;
bmpInfo.bmiHeader.biHeight = 32; bmpInfo.bmiHeader.biHeight = 160;
bmpInfo.bmiHeader.biPlanes = 1; bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biBitCount = 24; bmpInfo.bmiHeader.biBitCount = 24;
bmpInfo.bmiHeader.biCompression = BI_RGB; bmpInfo.bmiHeader.biCompression = BI_RGB;
data = (u8 *)calloc(1, 3 * 64 * 64); data_screen = (u8 *)calloc(1, 3 * 240 * 160);
oamScreen.setSize(240, 160);
oamView.setData(data); oamScreen.setData(data_screen);
oamView.setBmpInfo(&bmpInfo); oamScreen.setBmpInfo(&bmpInfo);
oamScreen.setStretch(false);
number = 0;
} }
void OamView::update()
void OamView::DoDataExchange(CDataExchange* pDX)
{ {
CDialog::DoDataExchange(pDX); paint();
//{{AFX_DATA_MAP(OamView)
DDX_Control(pDX, IDC_SPRITE, m_sprite);
DDX_Check(pDX, IDC_STRETCH, m_stretch);
//}}AFX_DATA_MAP
DDX_Control(pDX, IDC_COLOR, color);
DDX_Control(pDX, IDC_OAM_VIEW, oamView);
DDX_Control(pDX, IDC_OAM_VIEW_ZOOM, oamZoom);
}
BEGIN_MESSAGE_MAP(OamView, CDialog)
//{{AFX_MSG_MAP(OamView)
ON_BN_CLICKED(IDC_SAVE, OnSave)
ON_BN_CLICKED(IDC_STRETCH, OnStretch)
ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
ON_EN_CHANGE(IDC_SPRITE, OnChangeSprite)
ON_BN_CLICKED(IDC_CLOSE, OnClose)
ON_WM_HSCROLL()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_MAPINFO, OnMapInfo)
ON_MESSAGE(WM_COLINFO, OnColInfo)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// OamView message handlers
OamView::~OamView()
{
free(data);
data = NULL;
} }
void OamView::paint() void OamView::paint()
@ -91,102 +88,21 @@ void OamView::paint()
return; return;
render(); render();
oamView.setSize(w,h); utilReadScreenPixels(data_screen, 240, 160);
oamView.refresh(); oamScreen.refresh();
}
void OamView::update() for (int i = 0; i < 128; i++)
{ {
paint(); oamViews[i]->oamView.setSize(oamViews[i]->w, oamViews[i]->h);
oamViews[i]->oamView.refresh();
} }
oamPreview.refresh();
}
void OamView::UpdateOAM(int index)
void OamView::setAttributes(u16 a0, u16 a1, u16 a2)
{ {
CString buffer; u16 *sprites = &((u16 *)oam)[4 * index];
int y = a0 & 255;
int rot = a0 & 512;
int mode = (a0 >> 10) & 3;
int mosaic = a0 & 4096;
int color = a0 & 8192;
int duple = a0 & 1024;
int shape = (a0 >> 14) & 3;
int x = a1 & 511;
int rotParam = (a1 >> 9) & 31;
int flipH = a1 & 4096;
int flipV = a1 & 8192;
int size = (a1 >> 14) & 3;
int tile = a2 & 1023;
int prio = (a2 >> 10) & 3;
int pal = (a2 >> 12) & 15;
buffer.Format("%d,%d", x,y);
GetDlgItem(IDC_POS)->SetWindowText(buffer);
buffer.Format("%d", mode);
GetDlgItem(IDC_MODE)->SetWindowText(buffer);
GetDlgItem(IDC_COLORS)->SetWindowText(color ? "256" : "16");
buffer.Format("%d", pal);
GetDlgItem(IDC_PALETTE)->SetWindowText(buffer);
buffer.Format("%d", tile);
GetDlgItem(IDC_TILE)->SetWindowText(buffer);
buffer.Format("%d", prio);
GetDlgItem(IDC_PRIO)->SetWindowText(buffer);
buffer.Format("%d,%d", w,h);
GetDlgItem(IDC_SIZE2)->SetWindowText(buffer);
if(rot) {
buffer.Format("%d", rotParam);
} else
buffer.Empty();
GetDlgItem(IDC_ROT)->SetWindowText(buffer);
buffer.Empty();
if(rot)
buffer += 'R';
else buffer += ' ';
if(!rot) {
if(flipH)
buffer += 'H';
else
buffer += ' ';
if(flipV)
buffer += 'V';
else
buffer += ' ';
} else {
buffer += ' ';
buffer += ' ';
}
if(mosaic)
buffer += 'M';
else
buffer += ' ';
if(duple)
buffer += 'D';
else
buffer += ' ';
GetDlgItem(IDC_FLAGS)->SetWindowText(buffer);
}
void OamView::render()
{
int m=0;
if(oam == NULL || paletteRAM == NULL || vram == NULL)
return;
u16 *sprites = &((u16 *)oam)[4*number];
u16 *spritePalette = &((u16 *)paletteRAM)[0x100]; u16 *spritePalette = &((u16 *)paletteRAM)[0x100];
u8 *bmp = data; u8 *bmp = oamViews[index]->data;
u16 a0 = *sprites++; u16 a0 = *sprites++;
u16 a1 = *sprites++; u16 a1 = *sprites++;
@ -238,12 +154,8 @@ void OamView::render()
default: default:
return; return;
} }
oamViews[index]->w = sizeX;
w = sizeX; oamViews[index]->h = sizeY;
h = sizeY;
setAttributes(a0,a1,a2);
int sy = (a0 & 255); int sy = (a0 & 255);
if (a0 & 0x2000) { if (a0 & 0x2000) {
@ -267,7 +179,8 @@ void OamView::render()
*bmp++ = (color & 0x1f) << 3; *bmp++ = (color & 0x1f) << 3;
} }
} }
} else { }
else {
int c = (a2 & 0x3FF); int c = (a2 & 0x3FF);
// if((DISPCNT & 7) > 2 && (c < 512)) // if((DISPCNT & 7) > 2 && (c < 512))
// continue; // continue;
@ -293,10 +206,201 @@ void OamView::render()
} }
} }
} }
if (selectednumber == index)
{
oamPreview.setBmpInfo(&oamViews[index]->bmpInfo);
oamPreview.setData(oamViews[index]->data);
oamPreview.setSize(sizeX, sizeY);
}
}
void OamView::render()
{
if (oam == NULL || paletteRAM == NULL || vram == NULL)
return;
for (int i = 0; i < 128; i++)
{
UpdateOAM(i);
}
u16 *sprites = &((u16 *)oam)[4 * selectednumber];
u16 a0 = *sprites++;
u16 a1 = *sprites++;
u16 a2 = *sprites++;
setAttributes(a0, a1, a2);
} }
void OamView::setAttributes(u16 a0, u16 a1, u16 a2)
{
CString buffer;
int y = a0 & 255;
int rot = a0 & 512;
int mode = (a0 >> 10) & 3;
int mosaic = a0 & 4096;
int color = a0 & 8192;
int duple = a0 & 1024;
int shape = (a0 >> 14) & 3;
int x = a1 & 511;
int rotParam = (a1 >> 9) & 31;
int flipH = a1 & 4096;
int flipV = a1 & 8192;
int size = (a1 >> 14) & 3;
int tile = a2 & 1023;
int prio = (a2 >> 10) & 3;
int pal = (a2 >> 12) & 15;
int sizeY = 8;
int sizeX = 8;
switch (((a0 >> 12) & 0x0c) | (a1 >> 14)) {
case 0:
break;
case 1:
sizeX = sizeY = 16;
break;
case 2:
sizeX = sizeY = 32;
break;
case 3:
sizeX = sizeY = 64;
break;
case 4:
sizeX = 16;
break;
case 5:
sizeX = 32;
break;
case 6:
sizeX = 32;
sizeY = 16;
break;
case 7:
sizeX = 64;
sizeY = 32;
break;
case 8:
sizeY = 16;
break;
case 9:
sizeY = 32;
break;
case 10:
sizeX = 16;
sizeY = 32;
break;
case 11:
sizeX = 32;
sizeY = 64;
break;
default:
return;
}
oamScreen.setSelectedRectangle(x, y, sizeX, sizeY);
CListBox* attributelist = ((CListBox*)GetDlgItem(IDC_OAMATTRIBUTELIST));
attributelist->ResetContent();
buffer.Format("OAM No: %d", selectednumber);
attributelist->AddString(buffer);
buffer.Format("Position: %d,%d", x, y);
attributelist->AddString(buffer);
buffer.Format("Tile No: %d", tile);
attributelist->AddString(buffer);
buffer.Format("Size: %dx%d", sizeX, sizeY);
attributelist->AddString(buffer);
buffer.Format("OAM Dat: %04X,%04X,%04X", a0, a1, a2);
attributelist->AddString(buffer);
buffer.Format("OAM Addr: %08X", 0x07000000 + selectednumber * 8);
attributelist->AddString(buffer);
buffer.Format("Tile Addr: %08X", 0x06010000 + tile * (color ? 0x40 : 0x20));
attributelist->AddString(buffer);
buffer.Format("Mode: %d", mode);
attributelist->AddString(buffer);
buffer.Format("Palette: %d", pal);
attributelist->AddString(buffer);
buffer.Format("Prio: %d", prio);
attributelist->AddString(buffer);
if (rot) {
buffer.Format("RotP: %d", rotParam);
attributelist->AddString(buffer);
}
else
buffer.Empty();
buffer.Empty();
buffer += "Flag: ";
if (rot)
buffer += 'R';
else buffer += ' ';
if (!rot) {
if (flipH)
buffer += 'H';
else
buffer += ' ';
if (flipV)
buffer += 'V';
else
buffer += ' ';
}
else {
buffer += ' ';
buffer += ' ';
}
if (mosaic)
buffer += 'M';
else
buffer += ' ';
if (duple)
buffer += 'D';
else
buffer += ' ';
attributelist->AddString(buffer);
}
OamView::~OamView()
{
for (int i = 0; i < 128; i++)
{
delete oamViews[i];
}
}
void OamView::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_OAMSCREEN, oamScreen);
DDX_Control(pDX, IDC_OAMPREVIEW, oamPreview);
}
BEGIN_MESSAGE_MAP(OamView, CDialog)
ON_BN_CLICKED(IDC_CLOSE, OnClose)
ON_BN_CLICKED(IDC_SAVE, OnSave)
ON_BN_DOUBLECLICKED(IDC_OAMATTRIBUTELIST, OnListDoubleClick)
ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
ON_MESSAGE(WM_BITMAPCLICK, OnOAMClick)
END_MESSAGE_MAP()
// OamView message handlers
void OamView::saveBMP(const char *name) void OamView::saveBMP(const char *name)
{ {
OamViewable* ov = oamViews[selectednumber];
u8 writeBuffer[1024 * 3]; u8 writeBuffer[1024 * 3];
FILE *fp = fopen(name, "wb"); FILE *fp = fopen(name, "wb");
@ -329,32 +433,32 @@ void OamView::saveBMP(const char *name)
bmpheader.ident[0] = 'B'; bmpheader.ident[0] = 'B';
bmpheader.ident[1] = 'M'; bmpheader.ident[1] = 'M';
u32 fsz = sizeof(bmpheader) + w*h*3; u32 fsz = sizeof(bmpheader) + ov->w*ov->h * 3;
utilPutDword(bmpheader.filesize, fsz); utilPutDword(bmpheader.filesize, fsz);
utilPutDword(bmpheader.dataoffset, 0x38); utilPutDword(bmpheader.dataoffset, 0x38);
utilPutDword(bmpheader.headersize, 0x28); utilPutDword(bmpheader.headersize, 0x28);
utilPutDword(bmpheader.width, w); utilPutDword(bmpheader.width, ov->w);
utilPutDword(bmpheader.height, h); utilPutDword(bmpheader.height, ov->h);
utilPutDword(bmpheader.planes, 1); utilPutDword(bmpheader.planes, 1);
utilPutDword(bmpheader.bitsperpixel, 24); utilPutDword(bmpheader.bitsperpixel, 24);
utilPutDword(bmpheader.datasize, 3*w*h); utilPutDword(bmpheader.datasize, 3 * ov->w*ov->h);
fwrite(&bmpheader, 1, sizeof(bmpheader), fp); fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
u8 *b = writeBuffer; u8 *b = writeBuffer;
int sizeX = w; int sizeX = ov->w;
int sizeY = h; int sizeY = ov->h;
u8 *pixU8 = (u8 *)data+3*w*(h-1); u8 *pixU8 = (u8 *)ov->data + 3 * ov->w*(ov->h - 1);
for (int y = 0; y < sizeY; y++) { for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
*b++ = *pixU8++; // B *b++ = *pixU8++; // B
*b++ = *pixU8++; // G *b++ = *pixU8++; // G
*b++ = *pixU8++; // R *b++ = *pixU8++; // R
} }
pixU8 -= 2*3*w; pixU8 -= 2 * 3 * ov->w;
fwrite(writeBuffer, 1, 3*w, fp); fwrite(writeBuffer, 1, 3 * ov->w, fp);
b = writeBuffer; b = writeBuffer;
} }
@ -362,10 +466,9 @@ void OamView::saveBMP(const char *name)
fclose(fp); fclose(fp);
} }
void OamView::savePNG(const char *name) void OamView::savePNG(const char *name)
{ {
OamViewable* ov = oamViews[selectednumber];
u8 writeBuffer[1024 * 3]; u8 writeBuffer[1024 * 3];
FILE *fp = fopen(name, "wb"); FILE *fp = fopen(name, "wb");
@ -402,8 +505,8 @@ void OamView::savePNG(const char *name)
png_set_IHDR(png_ptr, png_set_IHDR(png_ptr,
info_ptr, info_ptr,
w, ov->w,
h, ov->h,
8, 8,
PNG_COLOR_TYPE_RGB, PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE, PNG_INTERLACE_NONE,
@ -414,10 +517,10 @@ void OamView::savePNG(const char *name)
u8 *b = writeBuffer; u8 *b = writeBuffer;
int sizeX = w; int sizeX = ov->w;
int sizeY = h; int sizeY = ov->h;
u8 *pixU8 = (u8 *)data; u8 *pixU8 = (u8 *)ov->data;
for (int y = 0; y < sizeY; y++) { for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
int blue = *pixU8++; int blue = *pixU8++;
@ -478,74 +581,55 @@ void OamView::OnSave()
} }
} }
BOOL OamView::OnInitDialog() BOOL OamView::OnInitDialog()
{ {
CDialog::OnInitDialog(); __super::OnInitDialog();
DIALOG_SIZER_START(sz) DIALOG_SIZER_START(sz)
DIALOG_SIZER_ENTRY( IDC_OAM_VIEW, DS_SizeX | DS_SizeY ) DIALOG_SIZER_ENTRY(IDC_OAMATTRIBUTELIST, DS_MoveX)
DIALOG_SIZER_ENTRY( IDC_OAM_VIEW_ZOOM, DS_MoveX) DIALOG_SIZER_ENTRY(IDC_OAMPREVIEW, DS_SizeX | DS_SizeY)
DIALOG_SIZER_ENTRY( IDC_REFRESH, DS_MoveY) DIALOG_SIZER_ENTRY(IDC_AUTO_UPDATE, DS_MoveX)
DIALOG_SIZER_ENTRY( IDC_SAVE, DS_MoveY) DIALOG_SIZER_ENTRY(IDC_SAVE, DS_MoveX | DS_MoveY)
DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveX | DS_MoveY)
DIALOG_SIZER_ENTRY( IDC_COLOR, DS_MoveY)
DIALOG_SIZER_ENTRY( IDC_R, DS_MoveY)
DIALOG_SIZER_ENTRY( IDC_G, DS_MoveY)
DIALOG_SIZER_ENTRY( IDC_B, DS_MoveY)
DIALOG_SIZER_END() DIALOG_SIZER_END()
for (int i = 0; i < 128; i++)
{
oamViews[i] = new OamViewable(i, this);
}
oamPreview.setBmpInfo(&oamViews[0]->bmpInfo);
oamPreview.setData(oamViews[0]->data);
SetData(sz, SetData(sz,
TRUE, TRUE,
HKEY_CURRENT_USER, HKEY_CURRENT_USER,
"Software\\Emulators\\VisualBoyAdvance\\Viewer\\OamView", "Software\\Emulators\\VisualBoyAdvance\\Viewer\\OamView",
NULL); NULL);
m_sprite.SetWindowText("0"); // TODO: Add extra initialization here
updateScrollInfo();
m_stretch = regQueryDwordValue("oamViewStretch", 0);
if(m_stretch)
oamView.setStretch(true);
UpdateData(FALSE); UpdateData(FALSE);
paint(); paint();
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE // EXCEPTION: OCX Property Pages should return FALSE
} }
void OamView::OnStretch() LRESULT OamView::OnOAMClick(WPARAM wParam, LPARAM lParam)
{ {
oamView.setStretch(!oamView.getStretch()); if ((wParam >= IDC_OAM1) && (wParam <= IDC_OAM128))
paint(); {
regSetDwordValue("oamViewStretch", oamView.getStretch()); selectednumber = wParam - IDC_OAM1;
update();
}
return TRUE;
} }
void OamView::OnAutoUpdate() void OamView::OnAutoUpdate()
{ {
autoUpdate = !autoUpdate; autoUpdate = !autoUpdate;
if (autoUpdate) { if (autoUpdate) {
theApp.winAddUpdateListener(this); theApp.winAddUpdateListener(this);
} else { }
else {
theApp.winRemoveUpdateListener(this); theApp.winRemoveUpdateListener(this);
} }
} }
void OamView::OnChangeSprite()
{
CString buffer;
m_sprite.GetWindowText(buffer);
int n = atoi(buffer);
if(n < 0 || n > 127) {
buffer.Format("%d", number);
m_sprite.SetWindowText(buffer);
return;
}
number = n;
paint();
updateScrollInfo();
}
void OamView::OnClose() void OamView::OnClose()
{ {
theApp.winRemoveUpdateListener(this); theApp.winRemoveUpdateListener(this);
@ -553,99 +637,9 @@ void OamView::OnClose()
DestroyWindow(); DestroyWindow();
} }
LRESULT OamView::OnMapInfo(WPARAM wParam, LPARAM lParam) void OamView::OnListDoubleClick()
{ {
u8 *colors = (u8 *)lParam; //theApp.winRemoveUpdateListener(this);
oamZoom.setColors(colors);
return TRUE; //DestroyWindow();
}
LRESULT OamView::OnColInfo(WPARAM wParam, LPARAM lParam)
{
u16 c = (u16)wParam;
color.setColor(c);
int r = (c & 0x1f);
int g = (c & 0x3e0) >> 5;
int b = (c & 0x7c00) >> 10;
CString buffer;
buffer.Format("R: %d", r);
GetDlgItem(IDC_R)->SetWindowText(buffer);
buffer.Format("G: %d", g);
GetDlgItem(IDC_G)->SetWindowText(buffer);
buffer.Format("B: %d", b);
GetDlgItem(IDC_B)->SetWindowText(buffer);
return TRUE;
}
void OamView::updateScrollInfo()
{
SCROLLINFO si;
ZeroMemory(&si, sizeof(si));
si.cbSize = sizeof(si);
si.fMask = SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL | SIF_POS;
si.nMin = 0;
si.nMax = 127;
si.nPage = 1;
si.nPos = number;
GetDlgItem(IDC_SCROLLBAR)->SetScrollInfo(SB_CTL,
&si,
TRUE);
}
void OamView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
switch(nSBCode) {
case SB_BOTTOM:
number = 127;
break;
case SB_LINEDOWN:
number++;
if(number > 127)
number = 127;
break;
case SB_LINEUP:
number--;
if(number < 0)
number = 0;
break;
case SB_PAGEDOWN:
number += 16;
if(number > 127)
number = 127;
break;
case SB_PAGEUP:
number -= 16;
if(number < 0)
number = 0;
break;
case SB_TOP:
number = 0;
break;
case SB_THUMBTRACK:
number = nPos;
if(number < 0)
number = 0;
if(number > 127)
number = 127;
break;
}
updateScrollInfo();
CString buffer;
buffer.Format("%d", number);
m_sprite.SetWindowText(buffer);
paint();
}
void OamView::PostNcDestroy()
{
delete this;
} }

View File

@ -1,81 +1,59 @@
#if !defined(AFX_OAMVIEW_H__E5369352_80F8_49C4_9F23_05EB6FC1345B__INCLUDED_)
#define AFX_OAMVIEW_H__E5369352_80F8_49C4_9F23_05EB6FC1345B__INCLUDED_
#if _MSC_VER > 1000
#pragma once #pragma once
#endif // _MSC_VER > 1000
// OamView.h : header file
//
#include "BitmapControl.h"
#include "ZoomControl.h"
#include "ColorControl.h"
#include "IUpdate.h" #include "IUpdate.h"
#include "ResizeDlg.h" #include "ResizeDlg.h"
#include "resource.h"
#include "BitmapControl.h"
#include "gba/Globals.h"
/////////////////////////////////////////////////////////////////////////////
// OamView dialog // OamView dialog
class OamViewable
{
public:
BITMAPINFO bmpInfo;
BitmapControl oamView;
u8* data;
OamViewable(int index, CDialog* parent);
int w;
int h;
~OamViewable();
};
class OamView : public ResizeDlg, IUpdateListener class OamView : public ResizeDlg, IUpdateListener
{ {
private: DECLARE_DYNAMIC(OamView)
BITMAPINFO bmpInfo;
u8 *data;
int w;
int h;
int number;
bool autoUpdate;
BitmapControl oamView;
ZoomControl oamZoom;
ColorControl color;
// Construction
public: public:
void updateScrollInfo();
afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam);
void savePNG(const char *name); void savePNG(const char *name);
void saveBMP(const char *name); void saveBMP(const char *name);
void render(); void render();
void setAttributes(u16 a0, u16 a1, u16 a2); void setAttributes(u16 a0, u16 a1, u16 a2);
void paint(); void paint();
~OamView();
virtual ~OamView();
OamView(CWnd* pParent = NULL); // standard constructor OamView(CWnd* pParent = NULL); // standard constructor
virtual void update(); virtual void update();
// Dialog Data // Dialog Data
//{{AFX_DATA(OamView)
enum { IDD = IDD_OAM_VIEW }; enum { IDD = IDD_OAM_VIEW };
CEdit m_sprite; private:
BOOL m_stretch; OamViewable* oamViews[128];
//}}AFX_DATA BITMAPINFO bmpInfo;
u8* data_screen;
BitmapControl oamScreen;
BitmapControl oamPreview;
void UpdateOAM(int index);
int selectednumber;
bool autoUpdate;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(OamView)
protected: protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void PostNcDestroy();
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(OamView)
afx_msg void OnSave();
virtual BOOL OnInitDialog(); virtual BOOL OnInitDialog();
afx_msg void OnStretch();
afx_msg void OnAutoUpdate(); afx_msg void OnAutoUpdate();
afx_msg void OnChangeSprite();
afx_msg void OnClose(); afx_msg void OnClose();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnSave();
//}}AFX_MSG afx_msg LRESULT OnOAMClick(WPARAM wParam, LPARAM lParam);
afx_msg void OnListDoubleClick();
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
public:
}; };
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_OAMVIEW_H__E5369352_80F8_49C4_9F23_05EB6FC1345B__INCLUDED_)

View File

@ -600,45 +600,6 @@ BEGIN
EDITTEXT IDC_CURRENT_ADDRESS,291,139,82,14,ES_RIGHT | ES_AUTOHSCROLL | WS_DISABLED EDITTEXT IDC_CURRENT_ADDRESS,291,139,82,14,ES_RIGHT | ES_AUTOHSCROLL | WS_DISABLED
END END
IDD_OAM_VIEW DIALOGEX 0, 0, 234, 185
STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "OAM Viewer"
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
EDITTEXT IDC_SPRITE,7,19,76,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
SCROLLBAR IDC_SCROLLBAR,7,33,76,11
CONTROL "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,138,79,10
PUSHBUTTON "&Refresh",IDC_REFRESH,7,164,50,14,WS_GROUP
PUSHBUTTON "&Save...",IDC_SAVE,91,164,50,14,WS_GROUP
PUSHBUTTON "&Close",IDC_CLOSE,177,164,50,14
CONTROL "MapView",IDC_OAM_VIEW,"VbaBitmapControl",WS_GROUP | WS_TABSTOP,87,7,64,64
CONTROL "Zoom",IDC_OAM_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | WS_TABSTOP,163,7,64,64
CONTROL "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,87,79,48,47
LTEXT "",IDC_POS,31,47,50,8,SS_NOPREFIX
LTEXT "",IDC_MODE,31,57,50,8,SS_NOPREFIX
LTEXT "",IDC_COLORS,31,67,50,8,SS_NOPREFIX
LTEXT "",IDC_PALETTE,31,77,50,8,SS_NOPREFIX
LTEXT "",IDC_TILE,31,87,50,8,SS_NOPREFIX
LTEXT "",IDC_PRIO,31,97,50,8,SS_NOPREFIX
LTEXT "",IDC_SIZE2,31,107,50,8,SS_NOPREFIX
LTEXT "",IDC_ROT,31,117,50,8,SS_NOPREFIX
LTEXT "",IDC_FLAGS,31,127,50,8,SS_NOPREFIX
LTEXT "",IDC_R,145,88,50,8,SS_NOPREFIX
LTEXT "",IDC_G,145,100,50,8,SS_NOPREFIX
LTEXT "",IDC_B,145,112,50,8,SS_NOPREFIX
LTEXT "Pos:",IDC_STATIC,7,47,24,8
LTEXT "Mode:",IDC_STATIC,7,57,24,8
LTEXT "Colors:",IDC_STATIC,7,67,24,8
LTEXT "Pal:",IDC_STATIC,7,77,24,8
LTEXT "Tile:",IDC_STATIC,7,87,24,8
LTEXT "Prio:",IDC_STATIC,7,97,24,8
LTEXT "Size:",IDC_STATIC,7,107,24,8
LTEXT "Sprite:",IDC_STATIC,7,7,50,8
LTEXT "Rot.:",IDC_STATIC,7,117,24,8
LTEXT "Flags:",IDC_STATIC,7,127,24,8
CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,150,71,10
END
IDD_ACCEL_EDITOR DIALOGEX 0, 0, 399, 121 IDD_ACCEL_EDITOR DIALOGEX 0, 0, 399, 121
STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Accelerator editor" CAPTION "Accelerator editor"
@ -1178,6 +1139,19 @@ BEGIN
COMBOBOX IDC_SAMPLE_RATE,66,54,66,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_SAMPLE_RATE,66,54,66,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END END
IDD_OAM_VIEW DIALOGEX 0, 0, 360, 220
STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "OAM Viewer"
FONT 8, "MS Sans Serif", 400, 0, 0x0
BEGIN
CONTROL "OamScreen",IDC_OAMSCREEN,"VbaBitmapControl",WS_GROUP | WS_TABSTOP,10,110,170,96
CONTROL "OamPreview",IDC_OAMPREVIEW,"VbaBitmapControl",WS_GROUP | WS_TABSTOP,180,110,64,64
DEFPUSHBUTTON "Save",IDC_SAVE,247,186,50,14
PUSHBUTTON "Close",IDC_CLOSE,303,185,50,14
LISTBOX IDC_OAMATTRIBUTELIST,248,7,104,177,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,248,203,71,10
END
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -1543,6 +1517,13 @@ BEGIN
TOPMARGIN, 7 TOPMARGIN, 7
BOTTOMMARGIN, 163 BOTTOMMARGIN, 163
END END
IDD_OAM_VIEW, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 347
TOPMARGIN, 7
END
END END
#endif // APSTUDIO_INVOKED #endif // APSTUDIO_INVOKED

View File

@ -563,13 +563,145 @@
#define IDC_SOUND_FILTERING 1294 #define IDC_SOUND_FILTERING 1294
#define IDC_COMBO1 1296 #define IDC_COMBO1 1296
#define IDC_SAMPLE_RATE 1296 #define IDC_SAMPLE_RATE 1296
#define IDC_LINK_MODE 1296 #define IDC_OAM1 1299
#define IDC_LINK_WITH 1300 #define IDC_OAM2 1300
#define IDC_STATIC_TIMEOUT 1301 #define IDC_OAM3 1301
#define IDC_LINK_SERVER 1302 #define IDC_OAM4 1302
#define IDC_LINK_CLIENT 1303 #define IDC_OAM5 1303
#define IDC_GROUP_NETWORK 1304 #define IDC_OAM6 1304
#define IDC_LINK_ROLE 1305 #define IDC_OAM7 1305
#define IDC_OAM8 1306
#define IDC_OAM9 1307
#define IDC_OAM10 1308
#define IDC_OAM11 1309
#define IDC_OAM12 1310
#define IDC_OAM13 1311
#define IDC_OAM14 1312
#define IDC_OAM15 1313
#define IDC_OAM16 1314
#define IDC_OAM17 1315
#define IDC_OAM18 1316
#define IDC_OAM19 1317
#define IDC_OAM20 1318
#define IDC_OAM21 1319
#define IDC_OAM22 1320
#define IDC_OAM23 1321
#define IDC_OAM24 1322
#define IDC_OAM25 1323
#define IDC_OAM26 1324
#define IDC_OAM27 1325
#define IDC_OAM28 1326
#define IDC_OAM29 1327
#define IDC_OAM30 1328
#define IDC_OAM31 1329
#define IDC_OAM32 1330
#define IDC_OAM33 1331
#define IDC_OAM34 1332
#define IDC_OAM35 1333
#define IDC_OAM36 1334
#define IDC_OAM37 1335
#define IDC_OAM38 1336
#define IDC_OAM39 1337
#define IDC_OAM40 1338
#define IDC_OAM41 1339
#define IDC_OAM42 1340
#define IDC_OAM43 1341
#define IDC_OAM44 1342
#define IDC_OAM45 1343
#define IDC_OAM46 1344
#define IDC_OAM47 1345
#define IDC_OAM48 1346
#define IDC_OAM49 1347
#define IDC_OAM50 1348
#define IDC_OAM51 1349
#define IDC_OAM52 1350
#define IDC_OAM53 1351
#define IDC_OAM54 1352
#define IDC_OAM55 1353
#define IDC_OAM56 1354
#define IDC_OAM57 1355
#define IDC_OAM58 1356
#define IDC_OAM59 1357
#define IDC_OAM60 1358
#define IDC_OAM61 1359
#define IDC_OAM62 1360
#define IDC_OAM63 1361
#define IDC_OAM64 1362
#define IDC_OAM65 1363
#define IDC_OAM66 1364
#define IDC_OAM67 1365
#define IDC_OAM68 1366
#define IDC_OAM69 1367
#define IDC_OAM70 1368
#define IDC_OAM71 1369
#define IDC_OAM72 1370
#define IDC_OAM73 1371
#define IDC_OAM74 1372
#define IDC_OAM75 1373
#define IDC_OAM76 1374
#define IDC_OAM77 1375
#define IDC_OAM78 1376
#define IDC_OAM79 1377
#define IDC_OAM80 1378
#define IDC_OAM81 1379
#define IDC_OAM82 1380
#define IDC_OAM83 1381
#define IDC_OAM84 1382
#define IDC_OAM85 1383
#define IDC_OAM86 1384
#define IDC_OAM87 1385
#define IDC_OAM88 1386
#define IDC_OAM89 1387
#define IDC_OAM90 1388
#define IDC_OAM91 1389
#define IDC_OAM92 1390
#define IDC_OAM93 1391
#define IDC_OAM94 1392
#define IDC_OAM95 1393
#define IDC_OAM96 1394
#define IDC_OAM97 1395
#define IDC_OAM98 1396
#define IDC_OAM99 1397
#define IDC_OAM100 1398
#define IDC_OAM101 1399
#define IDC_OAM102 1400
#define IDC_OAM103 1401
#define IDC_OAM104 1402
#define IDC_OAM105 1403
#define IDC_OAM106 1404
#define IDC_OAM107 1405
#define IDC_OAM108 1406
#define IDC_OAM109 1407
#define IDC_OAM110 1408
#define IDC_OAM111 1409
#define IDC_OAM112 1410
#define IDC_OAM113 1411
#define IDC_OAM114 1412
#define IDC_OAM115 1413
#define IDC_OAM116 1414
#define IDC_OAM117 1415
#define IDC_OAM118 1416
#define IDC_OAM119 1417
#define IDC_OAM120 1418
#define IDC_OAM121 1419
#define IDC_OAM122 1420
#define IDC_OAM123 1421
#define IDC_OAM124 1422
#define IDC_OAM125 1423
#define IDC_OAM126 1424
#define IDC_OAM127 1425
#define IDC_OAM128 1426
#define IDC_OAMSCREEN 1427
#define IDC_OAMATTRIBUTELIST 1428
#define IDC_OAMPREVIEW 1429
#define IDC_LINK_MODE 1430
#define IDC_LINK_WITH 1431
#define IDC_STATIC_TIMEOUT 1432
#define IDC_LINK_SERVER 1433
#define IDC_LINK_CLIENT 1434
#define IDC_GROUP_NETWORK 1435
#define IDC_LINK_ROLE 1436
#define IDS_OAL_NODEVICE 2000 #define IDS_OAL_NODEVICE 2000
#define IDS_OAL_NODLL 2001 #define IDS_OAL_NODLL 2001
#define IDS_AVI_CANNOT_CREATE_AVI 2002 #define IDS_AVI_CANNOT_CREATE_AVI 2002
@ -893,9 +1025,9 @@
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 166 #define _APS_NEXT_RESOURCE_VALUE 167
#define _APS_NEXT_COMMAND_VALUE 40381 #define _APS_NEXT_COMMAND_VALUE 40381
#define _APS_NEXT_CONTROL_VALUE 1299 #define _APS_NEXT_CONTROL_VALUE 1437
#define _APS_NEXT_SYMED_VALUE 103 #define _APS_NEXT_SYMED_VALUE 103
#endif #endif
#endif #endif