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 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)
{
#ifndef NO_PNG

View File

@ -14,6 +14,7 @@ typedef struct {
void *address;
int size;
} variable_desc;
void utilReadScreenPixels(u8* dest, int w, int h);
bool utilWritePNGFile(const char *, int, int, u8 *);
bool utilWriteBMPFile(const char *, int, int, u8 *);
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,
&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);
bitmap.DeleteObject();
@ -146,6 +152,10 @@ void BitmapControl::OnSize(UINT nType, int cx, int cy)
void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
{
GetParent()->SendMessage(WM_BITMAPCLICK,
GetDlgCtrlID(),
0);
if(!data)
return;
int x = pt.x;
@ -200,6 +210,7 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
GetParent()->SendMessage(WM_MAPINFO,
point,
(LPARAM)colors);
}
void BitmapControl::setBmpInfo(BITMAPINFO *info)
@ -223,7 +234,13 @@ void BitmapControl::setSize(int w1, int h1)
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()
{
Invalidate();

View File

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

File diff suppressed because it is too large Load Diff

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
#endif // _MSC_VER > 1000
// OamView.h : header file
//
#include "BitmapControl.h"
#include "ZoomControl.h"
#include "ColorControl.h"
#include "IUpdate.h"
#include "ResizeDlg.h"
#include "resource.h"
#include "BitmapControl.h"
#include "gba/Globals.h"
/////////////////////////////////////////////////////////////////////////////
// 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
{
private:
BITMAPINFO bmpInfo;
u8 *data;
int w;
int h;
int number;
bool autoUpdate;
BitmapControl oamView;
ZoomControl oamZoom;
ColorControl color;
DECLARE_DYNAMIC(OamView)
public:
void savePNG(const char *name);
void saveBMP(const char *name);
void render();
void setAttributes(u16 a0, u16 a1, u16 a2);
void paint();
// Construction
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 saveBMP(const char *name);
void render();
void setAttributes(u16 a0, u16 a1, u16 a2);
void paint();
~OamView();
OamView(CWnd* pParent = NULL); // standard constructor
virtual ~OamView();
OamView(CWnd* pParent = NULL); // standard constructor
virtual void update();
// Dialog Data
//{{AFX_DATA(OamView)
enum { IDD = IDD_OAM_VIEW };
CEdit m_sprite;
BOOL m_stretch;
//}}AFX_DATA
virtual void update();
// Dialog Data
enum { IDD = IDD_OAM_VIEW };
private:
OamViewable* oamViews[128];
BITMAPINFO bmpInfo;
u8* data_screen;
BitmapControl oamScreen;
BitmapControl oamPreview;
void UpdateOAM(int index);
int selectednumber;
bool autoUpdate;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(OamView)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void PostNcDestroy();
//}}AFX_VIRTUAL
virtual BOOL OnInitDialog();
afx_msg void OnAutoUpdate();
afx_msg void OnClose();
afx_msg void OnSave();
afx_msg LRESULT OnOAMClick(WPARAM wParam, LPARAM lParam);
afx_msg void OnListDoubleClick();
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(OamView)
afx_msg void OnSave();
virtual BOOL OnInitDialog();
afx_msg void OnStretch();
afx_msg void OnAutoUpdate();
afx_msg void OnChangeSprite();
afx_msg void OnClose();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{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_)
DECLARE_MESSAGE_MAP()
public:
};

View File

@ -600,45 +600,6 @@ BEGIN
EDITTEXT IDC_CURRENT_ADDRESS,291,139,82,14,ES_RIGHT | ES_AUTOHSCROLL | WS_DISABLED
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
STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Accelerator editor"
@ -1178,6 +1139,19 @@ BEGIN
COMBOBOX IDC_SAMPLE_RATE,66,54,66,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
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
BOTTOMMARGIN, 163
END
IDD_OAM_VIEW, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 347
TOPMARGIN, 7
END
END
#endif // APSTUDIO_INVOKED

View File

@ -563,13 +563,145 @@
#define IDC_SOUND_FILTERING 1294
#define IDC_COMBO1 1296
#define IDC_SAMPLE_RATE 1296
#define IDC_LINK_MODE 1296
#define IDC_LINK_WITH 1300
#define IDC_STATIC_TIMEOUT 1301
#define IDC_LINK_SERVER 1302
#define IDC_LINK_CLIENT 1303
#define IDC_GROUP_NETWORK 1304
#define IDC_LINK_ROLE 1305
#define IDC_OAM1 1299
#define IDC_OAM2 1300
#define IDC_OAM3 1301
#define IDC_OAM4 1302
#define IDC_OAM5 1303
#define IDC_OAM6 1304
#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_NODLL 2001
#define IDS_AVI_CANNOT_CREATE_AVI 2002
@ -893,9 +1025,9 @@
//
#ifdef APSTUDIO_INVOKED
#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_CONTROL_VALUE 1299
#define _APS_NEXT_CONTROL_VALUE 1437
#define _APS_NEXT_SYMED_VALUE 103
#endif
#endif