diff --git a/tools/nds_firmware_tool/ChangeLog b/tools/nds_firmware_tool/ChangeLog
new file mode 100644
index 000000000..9890a5f8c
--- /dev/null
+++ b/tools/nds_firmware_tool/ChangeLog
@@ -0,0 +1,12 @@
+NDS Firmware tools
+Copyright (C) 2009 by DeSmuME Team
+
+-= History =-
+0.0.3 (19/12/2009)
+- add WiFi settings viewer
+
+0.0.2 (18/12/2009)
+- add user settings viewer
+
+0.0.1 (17/12/2009)
+- initial version
\ No newline at end of file
diff --git a/tools/nds_firmware_tool/nds_firmware_tool_VS2008.sln b/tools/nds_firmware_tool/nds_firmware_tool_VS2008.sln
new file mode 100644
index 000000000..92a2ee039
--- /dev/null
+++ b/tools/nds_firmware_tool/nds_firmware_tool_VS2008.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nds_firmware_tool_VS2008", "nds_firmware_tool_VS2008.vcproj", "{6D076DD4-4000-4249-BDEA-F7AB407C813D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Devel|Win32 = Devel|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6D076DD4-4000-4249-BDEA-F7AB407C813D}.Devel|Win32.ActiveCfg = Devel|Win32
+ {6D076DD4-4000-4249-BDEA-F7AB407C813D}.Devel|Win32.Build.0 = Devel|Win32
+ {6D076DD4-4000-4249-BDEA-F7AB407C813D}.Release|Win32.ActiveCfg = Release|Win32
+ {6D076DD4-4000-4249-BDEA-F7AB407C813D}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/tools/nds_firmware_tool/nds_firmware_tool_VS2008.vcproj b/tools/nds_firmware_tool/nds_firmware_tool_VS2008.vcproj
new file mode 100644
index 000000000..fe0fe8a05
--- /dev/null
+++ b/tools/nds_firmware_tool/nds_firmware_tool_VS2008.vcproj
@@ -0,0 +1,222 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/nds_firmware_tool/src/common.h b/tools/nds_firmware_tool/src/common.h
new file mode 100644
index 000000000..af6bff3d5
--- /dev/null
+++ b/tools/nds_firmware_tool/src/common.h
@@ -0,0 +1,125 @@
+/* NDS Firmware tools
+
+ Copyright 2009 DeSmuME team
+
+ This file is part of DeSmuME
+
+ DeSmuME is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DeSmuME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DeSmuME; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef _COMMON_H__
+#define _COMMON_H__
+
+#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
+#pragma warning(disable: 4995)
+#pragma warning(disable: 4996)
+#endif
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned int u32;
+typedef unsigned __int64 u64;
+typedef signed char s8;
+typedef signed short s16;
+typedef signed int s32;
+typedef __int64 s64;
+
+char __forceinline *hex2(const u32 val)
+{
+ char buf[30] = {0};
+ sprintf(buf, "0x%02X", val);
+ return strdup(buf);
+}
+
+char __forceinline *hex2w(const u32 val)
+{
+ char buf[30] = {0};
+ sprintf(buf, "%02X", val);
+ return strdup(buf);
+}
+
+char __forceinline *hex4(const u32 val)
+{
+ char buf[30] = {0};
+ sprintf(buf, "0x%04X", val);
+ return strdup(buf);
+}
+
+char __forceinline *hex4w(const u32 val)
+{
+ char buf[30] = {0};
+ sprintf(buf, "%04X", val);
+ return strdup(buf);
+}
+
+char __forceinline *hex6(const u32 val)
+{
+ char buf[30] = {0};
+ sprintf(buf, "0x%06X", val);
+ return strdup(buf);
+}
+
+char __forceinline *hex6w(const u32 val)
+{
+ char buf[30] = {0};
+ sprintf(buf, "%06X", val);
+ return strdup(buf);
+}
+
+char __forceinline *hex8(const u32 val)
+{
+ char buf[30] = {0};
+ sprintf(buf, "0x%08X", val);
+ return strdup(buf);
+}
+
+#ifdef _WIN32
+char __forceinline *error()
+{
+ LPVOID lpMsgBuf = NULL;
+
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 512, NULL);
+
+ return strdup((char*)lpMsgBuf);
+}
+
+u8 __forceinline read8(u8 *mem, u32 offset)
+{
+ return (*(u8*)(mem + offset));
+}
+
+u16 __forceinline read16(u8 *mem, u32 offset)
+{
+ return (*(u16*)(mem + offset));
+}
+
+u32 __forceinline read24(u8 *mem, u32 offset)
+{
+ return (*(u16*)(mem + offset)) | (*(u8*)(mem + offset+2) << 16);
+}
+
+u32 __forceinline read32(u8 *mem, u32 offset)
+{
+ return (*(u32*)(mem + offset));
+}
+
+u64 __forceinline read64(u8 *mem, u32 offset)
+{
+ return (*(u64*)(mem + offset));
+}
+#endif
+
+#endif
diff --git a/tools/nds_firmware_tool/src/console.cpp b/tools/nds_firmware_tool/src/console.cpp
new file mode 100644
index 000000000..ed926752c
--- /dev/null
+++ b/tools/nds_firmware_tool/src/console.cpp
@@ -0,0 +1,111 @@
+/* NDS Firmware tools
+
+ Copyright 2009 DeSmuME team
+
+ This file is part of DeSmuME
+
+ DeSmuME is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DeSmuME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DeSmuME; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "console.h"
+#include "main.h"
+
+///////////////////////////////////////////////////////////////// Console
+#ifdef DEVEL_VERSION
+#include
+#include
+#include
+#include
+
+#define BUFFER_SIZE 100
+HANDLE hConsole;
+void OpenConsole()
+{
+ COORD csize;
+ CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
+ SMALL_RECT srect;
+ char buf[256];
+
+ //dont do anything if we're already attached
+ if (hConsole) return;
+
+ //attach to an existing console (if we can; this is circuitous because AttachConsole wasnt added until XP)
+ //remember to abstract this late bound function notion if we end up having to do this anywhere else
+ bool attached = false;
+ HMODULE lib = LoadLibrary("kernel32.dll");
+ if(lib)
+ {
+ typedef BOOL (WINAPI *_TAttachConsole)(DWORD dwProcessId);
+ _TAttachConsole _AttachConsole = (_TAttachConsole)GetProcAddress(lib,"AttachConsole");
+ if(_AttachConsole)
+ {
+ if(_AttachConsole(-1))
+ attached = true;
+ }
+ FreeLibrary(lib);
+ }
+
+ //if we failed to attach, then alloc a new console
+ if(!attached)
+ {
+ AllocConsole();
+ }
+
+ hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ //redirect stdio
+ long lStdHandle = (long)hConsole;
+ int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ if(hConHandle == -1)
+ return; //this fails from a visual studio command prompt
+
+#if 1
+ FILE *fp = _fdopen( hConHandle, "w" );
+#else
+ FILE *fp = fopen( "c:\\desmume.log", "w" );
+#endif
+ *stdout = *fp;
+ //and stderr
+ *stderr = *fp;
+
+ memset(buf,0,256);
+ sprintf(buf,"%s OUTPUT", _TITLE);
+ SetConsoleTitle(TEXT(buf));
+ csize.X = 60;
+ csize.Y = 800;
+ SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csize);
+ GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo);
+ srect = csbiInfo.srWindow;
+ srect.Right = srect.Left + 99;
+ srect.Bottom = srect.Top + 64;
+ SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &srect);
+ SetConsoleCP(GetACP());
+ SetConsoleOutputCP(GetACP());
+ if(attached) printf("\n");
+ printf("%s\n",_TITLE);
+ printf("- compiled: %s %s\n\n",__DATE__,__TIME__);
+}
+
+void CloseConsole()
+{
+ if (hConsole == NULL) return;
+ INFO("Closing...");
+ FreeConsole();
+ hConsole = NULL;
+}
+#else
+void OpenConsole() {}
+void CloseConsole() {}
+#endif
diff --git a/tools/nds_firmware_tool/src/console.h b/tools/nds_firmware_tool/src/console.h
new file mode 100644
index 000000000..4375eb94e
--- /dev/null
+++ b/tools/nds_firmware_tool/src/console.h
@@ -0,0 +1,33 @@
+/* NDS Firmware tools
+
+ Copyright 2009 DeSmuME team
+
+ This file is part of DeSmuME
+
+ DeSmuME is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DeSmuME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DeSmuME; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef __CONSOLE_H_
+#define __CONSOLE_H_
+
+#ifdef DEVEL_VERSION
+#define INFO(...) printf(__VA_ARGS__)
+#else
+#define INFO(...)
+#endif
+
+extern void OpenConsole();
+extern void CloseConsole();
+#endif
\ No newline at end of file
diff --git a/tools/nds_firmware_tool/src/main.cpp b/tools/nds_firmware_tool/src/main.cpp
new file mode 100644
index 000000000..aff4fc463
--- /dev/null
+++ b/tools/nds_firmware_tool/src/main.cpp
@@ -0,0 +1,1209 @@
+/* NDS Firmware tools
+
+ Copyright 2009 DeSmuME team
+
+ This file is part of DeSmuME
+
+ DeSmuME is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DeSmuME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DeSmuME; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+// first release: 17/12/2009
+
+#include
+#include
+#include
+#include "main.h"
+#include "templates.h"
+
+const char months[12][10] = { "January", "February", "March", "April", "May", "June", "July",
+ "August", "September", "October", "November", "December"};
+
+const COLORREF firmColor[16] = {RGB( 96,128,152), // 0 - Gray
+ RGB(184, 72, 0), // 1 - Brown
+ RGB(248, 0, 24), // 2 - Red
+ RGB(248,136,248), // 3 - Pink
+ RGB(248,144, 0), // 4 - Orange
+ RGB(240,224, 0), // 5 - Yellow
+ RGB(168,248, 0), // 6 - Lime Green
+ RGB( 0,248, 0), // 7 - Green
+ RGB( 0,160, 56), // 8 - Dark Green
+ RGB( 72,216,136), // 9 - Sea Green
+ RGB( 48,184,240), // 10 - Turquoise
+ RGB( 0, 80,240), // 11 - Blue
+ RGB( 0, 0,144), // 12 - Dark Blue
+ RGB(136, 0,208), // 13 - Dark Purple
+ RGB(208, 0,232), // 14 - Violet
+ RGB(248, 0,144) // 15 - Magenta
+};
+
+const char firmColorNames[16][16] = {"Gray","Brown","Red","Pink","Orange","Yellow","Lime Green",
+ "Green","Dark Green","Sea Green","Turquoise","Blue",
+ "Dark Blue","Dark Purple","Violet","Magenta"};
+
+HEADER header = {0};
+u8 *gFirmwareData = NULL;
+u32 gFFsize = 0;
+u8 currColor = 0;
+
+HINSTANCE gInstance = NULL;
+HWND gMainWnd = NULL;
+RECT gMainWndPos = { CW_USEDEFAULT, CW_USEDEFAULT, 700, 555 };
+HBRUSH hbBackground = NULL;
+HBRUSH hbEditBackground = NULL;
+HBRUSH hbColors[16] = { NULL };
+
+char firmware_path[MAX_PATH] = { 0 };
+
+//===============================================================================================
+char *getType(const u8 type)
+{
+ char buf[30] = {0};
+
+ switch (type)
+ {
+ case 0xFF:
+ strcpy(buf, "NDS");
+ break;
+
+ case 0x20:
+ strcpy(buf, "NDS-Lite");
+ break;
+
+ case 0x43:
+ strcpy(buf, "iQueDS");
+ break;
+
+ case 0x63:
+ strcpy(buf, "iQueDS-Lite");
+ break;
+
+ default:
+ strcpy(buf, "Unknown");
+ break;
+ }
+ return strdup(buf);
+}
+
+char *getTimeStamp(const u8 tm[])
+{
+ char buf[30] = {0};
+ if ((tm[2]>31)| (tm[3]>12)| (tm[1]>24)| (tm[0]>59))
+ {
+ strcpy(buf, "ERROR");
+ INFO("Error in timestamp: %02i/%02i/%02i %02i:%02i\n", tm[2], tm[3], tm[4], tm[1], tm[0]);
+ }
+ else
+ sprintf(buf, "%02i/%02i/%02i %02i:%02i", tm[2], tm[3], tm[4], tm[1], tm[0]);
+ return strdup(buf);
+}
+
+char *getVersion(const u8 ver[])
+{
+ char buf[30] = {0};
+ sprintf(buf, "%c%c%c%c", ver[0], ver[1], ver[2], ver[3]);
+ return strdup(buf);
+}
+
+char *getFlashMEversion(u8 vers, u16 vers_ex)
+{
+ char buf[10] = {0};
+ if (vers == 1)
+ strcpy(buf, "1..4");
+ else
+ sprintf(buf, "%i", vers_ex + 3);
+
+ return strdup(buf);
+}
+//===============================================================================================
+void clearMainDataWnd()
+{
+ for (int i = IDC_H_EDIT_START; i < IDC_H_EDIT_LAST; i++)
+ SetDlgItemText(gMainWnd, i, "");
+}
+
+void refreshMainData()
+{
+ u16 shift1 = 0, shift2 = 0, shift3 = 0, shift4 = 0;
+ u32 size_header = ((header.shift_amounts >> 12) & 0xF) * 128 * 1024;
+
+ shift1 = ((header.shift_amounts >> 0) & 0x07);
+ shift2 = ((header.shift_amounts >> 3) & 0x07);
+ shift3 = ((header.shift_amounts >> 6) & 0x07);
+ shift4 = ((header.shift_amounts >> 9) & 0x07);
+
+ clearMainDataWnd();
+ SetDlgItemText(gMainWnd, IDC_H1_TYPE, getType(header.console_type));
+ SetDlgItemText(gMainWnd, IDC_H1_VERSION, getVersion(header.fw_identifier));
+ SetDlgItemText(gMainWnd, IDC_H1_TIMESTAMP, getTimeStamp(header.fw_timestamp));
+ if (size_header != gFFsize)
+ SetDlgItemText(gMainWnd, IDC_H1_SIZE, "ERROR");
+ else
+ SetDlgItemInt(gMainWnd, IDC_H1_SIZE, size_header, false);
+ SetDlgItemText(gMainWnd, IDC_H1_CRC, hex4(header.part12_boot_crc16));
+ SetDlgItemText(gMainWnd, IDC_H1_ARM9_ROM, hex8(header.part1_rom_boot9_addr << (2 + shift1)));
+ SetDlgItemText(gMainWnd, IDC_H1_ARM9_RAM, hex8((0x02800000 - (header.part1_ram_boot9_addr << (2+shift2)))));
+ SetDlgItemText(gMainWnd, IDC_H1_ARM9_GUI, hex8((header.part2_rom_boot7_addr << (2+shift3))));
+ SetDlgItemText(gMainWnd, IDC_H1_ARM7_ROM, hex8((0x03810000 - (header.part2_ram_boot7_addr << (2+shift4)))));
+ SetDlgItemText(gMainWnd, IDC_H1_ARM7_RAM, hex8((header.part3_rom_gui9_addr << 3)));
+ SetDlgItemText(gMainWnd, IDC_H1_ARM7_WIFI, hex8((header.part4_rom_wifi7_addr << 3)));
+ //SetDlgItemText(gMainWnd, IDC_H1_ARM9_ROM, hex8((header.part5_gFirmwareData_gfx_addr << 3)));
+
+ if (gFirmwareData[0x17C] != 0xFF)
+ {
+ INFO("FlashME founded\n");
+ u32 patch_offset = 0x3FC80;
+ if (gFirmwareData[0x17C] > 1)
+ patch_offset = 0x3F680;
+
+ memcpy(&header, gFirmwareData + patch_offset, sizeof(header));
+
+ shift1 = ((header.shift_amounts >> 0) & 0x07);
+ shift2 = ((header.shift_amounts >> 3) & 0x07);
+ shift3 = ((header.shift_amounts >> 6) & 0x07);
+ shift4 = ((header.shift_amounts >> 9) & 0x07);
+
+ size_header = ((header.shift_amounts >> 12) & 0xF) * 128 * 1024;
+
+ SetDlgItemText(gMainWnd, IDC_H2_VERSION, getFlashMEversion(gFirmwareData[0x17C], (u16)gFirmwareData[0x3F7FC]));
+ if (size_header != gFFsize)
+ SetDlgItemText(gMainWnd, IDC_H2_SIZE, "ERROR");
+ else
+ SetDlgItemInt(gMainWnd, IDC_H2_SIZE, size_header, false);
+ SetDlgItemText(gMainWnd, IDC_H2_CRC, hex4(header.part12_boot_crc16));
+ SetDlgItemText(gMainWnd, IDC_H2_ARM9_ROM, hex8(header.part1_rom_boot9_addr << (2 + shift1)));
+ SetDlgItemText(gMainWnd, IDC_H2_ARM9_RAM, hex8((0x02800000 - (header.part1_ram_boot9_addr << (2+shift2)))));
+ SetDlgItemText(gMainWnd, IDC_H2_ARM9_GUI, hex8((header.part2_rom_boot7_addr << (2+shift3))));
+ SetDlgItemText(gMainWnd, IDC_H2_ARM7_ROM, hex8((0x03810000 - (header.part2_ram_boot7_addr << (2+shift4)))));
+ SetDlgItemText(gMainWnd, IDC_H2_ARM7_RAM, hex8((header.part3_rom_gui9_addr << 3)));
+ SetDlgItemText(gMainWnd, IDC_H2_ARM7_WIFI, hex8((header.part4_rom_wifi7_addr << 3)));
+ //SetDlgItemText(gMainWnd, IDC_H2_ARM9_ROM, hex8((header.part5_gFirmwareData_gfx_addr << 3)));
+ }
+ else
+ SetDlgItemText(gMainWnd, IDC_H2_VERSION, "not present ");
+}
+
+bool loadFirmware()
+{
+ FILE *fp = fopen(firmware_path, "rb");
+ u8 *data = NULL;
+
+ if (fp)
+ {
+ fseek(fp, 0, SEEK_END);
+ gFFsize = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ if( (gFFsize != 256*1024) && (gFFsize != 512*1024) )
+ {
+ INFO("Firmware: error size %i\n", gFFsize);
+ fclose(fp);
+ return false;
+ }
+
+ data = new u8 [gFFsize];
+ if (!data)
+ {
+ INFO("Firmware: error memory allocate\n");
+ fclose(fp);
+ return false;
+ }
+ memset(data, 0, gFFsize);
+
+ if (fread(data, 1, gFFsize, fp) != gFFsize)
+ {
+ INFO("Firmware: error reading\n");
+ delete [] data;
+ fclose(fp);
+ return false;
+ }
+ fclose(fp);
+
+
+ if ((data[0x08] != 'M') ||
+ (data[0x09] != 'A') ||
+ (data[0x0A] != 'C'))
+ {
+ INFO("Firmware: error ID string\n");
+ delete [] data;
+ fclose(fp);
+ return false;
+ }
+
+ SetWindowText(GetDlgItem(gMainWnd, IDC_BPATH), firmware_path);
+ memcpy(&header, data, sizeof(header));
+ memcpy(gFirmwareData, data, gFFsize);
+ refreshMainData();
+ delete [] data;
+ return true;
+ }
+ INFO("Error opening %s\n", firmware_path);
+ return false;
+}
+
+void refreshWiFiAPDlg(HWND hwnd)
+{
+ u8 *data = (u8*)(gFirmwareData + (header.user_settings_offset * 8 - 0x400));
+ char buf[256] = {0};
+
+ for (int i =0; i < 3; i++)
+ {
+ u16 ofsID = (i * 30);
+ u32 ofsMem = (i * 0x100);
+
+ strncpy(buf, (char*)(data+ofsMem+0x40), 32);
+ SetDlgItemText(hwnd, IDC_WIFI_AP_SSID + ofsID, buf);
+
+ strncpy(buf, (char*)(data+ofsMem+0x60), 32);
+ SetDlgItemText(hwnd, IDC_WIFI_AP_SSID2 + ofsID, buf);
+
+ sprintf(buf, "%X", read64(data, ofsMem+0xF0));
+ SetDlgItemText(hwnd, IDC_WIFI_AP_USER_ID + ofsID, buf);
+
+ strncpy(buf, (char*)(data+ofsMem+0x80), 16);
+ SetDlgItemText(hwnd, IDC_WIFI_AP_KEY1 + ofsID, buf);
+ strncpy(buf, (char*)(data+ofsMem+0x90), 16);
+ SetDlgItemText(hwnd, IDC_WIFI_AP_KEY2 + ofsID, buf);
+ strncpy(buf, (char*)(data+ofsMem+0xA0), 16);
+ SetDlgItemText(hwnd, IDC_WIFI_AP_KEY3 + ofsID, buf);
+ strncpy(buf, (char*)(data+ofsMem+0xB0), 16);
+ SetDlgItemText(hwnd, IDC_WIFI_AP_KEY4 + ofsID, buf);
+
+ u8 tmp8 = read8(data, ofsMem+0xE6);
+ if (tmp8 == 0)
+ {
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_AP_WEP_SIZE + ofsID), CB_SETCURSEL, 0, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_AP_WEP_EMETHOD + ofsID), CB_SETCURSEL, 0, 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_WIFI_AP_WEP_EMETHOD + ofsID), false);
+ }
+ else
+ {
+ u8 tmp = 0;
+ if (tmp8 > 3)
+ {
+ tmp = tmp8 - 4;
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_AP_WEP_EMETHOD + ofsID), CB_SETCURSEL, 0, 0);
+ }
+ else
+ {
+ tmp = tmp8;
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_AP_WEP_EMETHOD + ofsID), CB_SETCURSEL, 1, 0);
+ }
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_AP_WEP_SIZE + ofsID), CB_SETCURSEL, tmp, 0);
+ }
+
+ if (read32(data, ofsMem+0xC0) == 0)
+ {
+ SetDlgItemText(hwnd, IDC_WIFI_AP_IP + ofsID, "DHCP");
+ SetDlgItemText(hwnd, IDC_WIFI_AP_IPMASK + ofsID, "DHCP");
+ SetDlgItemText(hwnd, IDC_WIFI_AP_GATEWAY + ofsID, "DHCP");
+ }
+ else
+ {
+ sprintf(buf, "%i.%i.%i.%i", read8(data, ofsMem+0xC0), read8(data, ofsMem+0xC1), read8(data, ofsMem+0xC2), read8(data, ofsMem+0xC3));
+ SetDlgItemText(hwnd, IDC_WIFI_AP_IP + ofsID, buf);
+ sprintf(buf, "%i.%i.%i.%i", read8(data, ofsMem+0xD0), read8(data, ofsMem+0xD1), read8(data, ofsMem+0xD2), read8(data, ofsMem+0xD3));
+ SetDlgItemText(hwnd, IDC_WIFI_AP_IPMASK + ofsID, buf);
+ sprintf(buf, "%i.%i.%i.%i", read8(data, ofsMem+0xC4), read8(data, ofsMem+0xC5), read8(data, ofsMem+0xC6), read8(data, ofsMem+0xC7));
+ SetDlgItemText(hwnd, IDC_WIFI_AP_GATEWAY + ofsID, buf);
+ }
+
+ if (read32(data, ofsMem+0xC8) == 0)
+ {
+ SetDlgItemText(hwnd, IDC_WIFI_AP_DNS1 + ofsID, "DHCP");
+ }
+ else
+ {
+ sprintf(buf, "%i.%i.%i.%i", read8(data, ofsMem+0xC8), read8(data, ofsMem+0xC9), read8(data, ofsMem+0xCA), read8(data, ofsMem+0xCB));
+ SetDlgItemText(hwnd, IDC_WIFI_AP_DNS1 + ofsID, buf);
+ }
+
+ if (read32(data, ofsMem+0xCC) == 0)
+ {
+ SetDlgItemText(hwnd, IDC_WIFI_AP_DNS2 + ofsID, "DHCP");
+ }
+ else
+ {
+ sprintf(buf, "%i.%i.%i.%i", read8(data, ofsMem+0xC8), read8(data, ofsMem+0xC9), read8(data, ofsMem+0xCA), read8(data, ofsMem+0xCB));
+ SetDlgItemText(hwnd, IDC_WIFI_AP_DNS2 + ofsID, buf);
+ }
+
+ if (read8(data, ofsMem+0xE7) == 0)
+ SetDlgItemText(hwnd, IDC_WIFI_AP_STATUS + ofsID, "Normal");
+ else
+ if (read8(data, ofsMem+0xE7) == 0x01)
+ SetDlgItemText(hwnd, IDC_WIFI_AP_STATUS + ofsID, "AOSS");
+ else
+ if (read8(data, ofsMem+0xE7) == 0xFF)
+ SetDlgItemText(hwnd, IDC_WIFI_AP_STATUS + ofsID, "not configured");
+
+ SetDlgItemText(hwnd, IDC_WIFI_AP_CRC16 + ofsID, hex4(read16(data, ofsMem+0xFE)));
+ }
+}
+
+BOOL CALLBACK wifiAPDlgProc(HWND hdlg,UINT msg, WPARAM wParam,LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ HWND tmp_wnd = NULL;
+
+ SetWindowText(hdlg, "WiFi Access Points Settings");
+ u16 size = sizeof(TwifiAPDlg1)/sizeof(TwifiAPDlg1[0]);
+ for (int t = 0; t < 3; t++)
+ {
+ u32 tmp_id = NULL;
+
+ for (int i = 0; i < size; i++)
+ {
+ tmp_id = TwifiAPDlg1[i].id;
+
+ if (tmp_id != NULL)
+ tmp_id += (t*30);
+
+ CreateWindow(TwifiAPDlg1[i].wclass, TwifiAPDlg1[i].wtitle, WS_CHILD | WS_VISIBLE | TwifiAPDlg1[i].style,
+ TwifiAPDlg1[i].x, TwifiAPDlg1[i].y-10+t*220, TwifiAPDlg1[i].w, TwifiAPDlg1[i].h, hdlg, (HMENU)tmp_id, gInstance, NULL);
+ }
+
+ tmp_wnd = GetDlgItem(hdlg, IDC_WIFI_AP_WEP_SIZE + (t*30));
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"None");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"5 bytes");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"13 bytes");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"16 bytes");
+ SendMessage(tmp_wnd, CB_SETCURSEL, 0, 0);
+
+ tmp_wnd = GetDlgItem(hdlg, IDC_WIFI_AP_WEP_EMETHOD + (t*30));
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"ASCII");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Hex");
+ SendMessage(tmp_wnd, CB_SETCURSEL, 0, 0);
+ }
+
+ size = sizeof(TwifiAPDlg2)/sizeof(TwifiAPDlg2[0]);
+ for (int i = 0; i < size; i++)
+ {
+ CreateWindow(TwifiAPDlg2[i].wclass, TwifiAPDlg2[i].wtitle, WS_CHILD | WS_VISIBLE | TwifiAPDlg2[i].style,
+ TwifiAPDlg2[i].x, TwifiAPDlg2[i].y, TwifiAPDlg2[i].w, TwifiAPDlg2[i].h, hdlg, (HMENU)TwifiAPDlg2[i].id, gInstance, NULL);
+ }
+
+ refreshWiFiAPDlg(hdlg);
+ break;
+ }
+ case WM_CTLCOLORDLG:
+ {
+ HDC hdc = (HDC)wParam;
+ SetTextColor(hdc,RGB(200,200,200));
+ SetBkColor(hdc,RGB(60,60,60));
+ return (BOOL)hbBackground;
+ }
+
+ case WM_CTLCOLORBTN:
+ return (BOOL)hbBackground;
+
+ case WM_CTLCOLOREDIT:
+ {
+ HDC hdc = (HDC)wParam;
+ SetTextColor(hdc,RGB(200,200,200));
+ SetBkColor(hdc,RGB(60,60,60));
+ return (BOOL)hbEditBackground;
+ }
+
+ case WM_CTLCOLORSTATIC:
+ {
+ HDC hdc = (HDC)wParam;
+ u32 id = GetWindowLong((HWND)lParam, GWL_ID);
+ if (id >= IDC_WIFI_AP_STATUS)
+ {
+ SetTextColor(hdc,RGB(200,200,200));
+ SetBkColor(hdc,RGB(60,60,60));
+ return (LRESULT)hbEditBackground;
+ }
+ SetTextColor(hdc,RGB(0xFF,0xFF,0xFF));
+ SetBkColor(hdc,RGB(0x6D,0x70, 0xA0));
+ return (LRESULT)hbBackground;
+ }
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ EndDialog(hdlg, 1);
+ break;
+
+ case IDCANCEL:
+ EndDialog(hdlg, 0);
+ break;
+
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+//====================================================================================================
+bool refreshWiFiDlg(HWND hwnd)
+{
+ u8 *data = (u8*)gFirmwareData;
+ u16 tmp16 = 0;
+ char buf[256] = {0};
+
+ SetDlgItemText(hwnd, IDC_WIFI_CRC16, hex4(read16(data, 0x2A)));
+ SetDlgItemInt(hwnd, IDC_WIFI_VERSION, read8(data, 0x2F), false);
+
+ if (read8(data, 0x2F) > 5)
+ strcpy(buf, "001656");
+ else
+ strcpy(buf, "0009BF");
+ sprintf(buf, "%s%02X%02X%02X", buf, read8(data, 0x36), read8(data, 0x37), read8(data, 0x38));
+ SetDlgItemText(hwnd, IDC_WIFI_MACID, buf);
+ SetDlgItemInt(hwnd, IDC_WIFI_RFTYPE, read8(data, 0x40), false);
+
+
+ tmp16 = read16(data, 0x3C) & 0x7FFE;
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_01), BM_SETCHECK, (tmp16 & (1<<1))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_02), BM_SETCHECK, (tmp16 & (1<<2))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_03), BM_SETCHECK, (tmp16 & (1<<3))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_04), BM_SETCHECK, (tmp16 & (1<<4))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_05), BM_SETCHECK, (tmp16 & (1<<5))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_06), BM_SETCHECK, (tmp16 & (1<<6))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_07), BM_SETCHECK, (tmp16 & (1<<7))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_08), BM_SETCHECK, (tmp16 & (1<<8))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_09), BM_SETCHECK, (tmp16 & (1<<9))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_10), BM_SETCHECK, (tmp16 & (1<<10))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_11), BM_SETCHECK, (tmp16 & (1<<11))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_12), BM_SETCHECK, (tmp16 & (1<<12))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_13), BM_SETCHECK, (tmp16 & (1<<13))?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_WIFI_ECHANNEL_14), BM_SETCHECK, (tmp16 & (1<<14))?BST_CHECKED:BST_UNCHECKED, 0);
+
+ SetDlgItemText(hwnd, IDC_WIFI_044, hex4w(read16(data, 0x44)));
+ SetDlgItemText(hwnd, IDC_WIFI_046, hex4w(read16(data, 0x46)));
+ SetDlgItemText(hwnd, IDC_WIFI_048, hex4w(read16(data, 0x48)));
+ SetDlgItemText(hwnd, IDC_WIFI_04A, hex4w(read16(data, 0x4A)));
+ SetDlgItemText(hwnd, IDC_WIFI_04C, hex4w(read16(data, 0x4C)));
+ SetDlgItemText(hwnd, IDC_WIFI_04E, hex4w(read16(data, 0x4E)));
+ SetDlgItemText(hwnd, IDC_WIFI_050, hex4w(read16(data, 0x50)));
+ SetDlgItemText(hwnd, IDC_WIFI_052, hex4w(read16(data, 0x52)));
+ SetDlgItemText(hwnd, IDC_WIFI_054, hex4w(read16(data, 0x54)));
+ SetDlgItemText(hwnd, IDC_WIFI_056, hex4w(read16(data, 0x56)));
+ SetDlgItemText(hwnd, IDC_WIFI_058, hex4w(read16(data, 0x58)));
+ SetDlgItemText(hwnd, IDC_WIFI_05A, hex4w(read16(data, 0x5A)));
+ SetDlgItemText(hwnd, IDC_WIFI_05C, hex4w(read16(data, 0x5C)));
+ SetDlgItemText(hwnd, IDC_WIFI_05E, hex4w(read16(data, 0x5E)));
+ SetDlgItemText(hwnd, IDC_WIFI_060, hex4w(read16(data, 0x60)));
+ SetDlgItemText(hwnd, IDC_WIFI_062, hex4w(read16(data, 0x62)));
+
+ for (int i = 0; i < 0x69; i++)
+ SetDlgItemText(hwnd, IDC_WIFI_BB + i, hex2w(read8(data, 0x64+i)));
+
+ if (read8(data, 0x44) == 2)
+ {
+ for (int i = 0; i < (0x24 / 3); i++)
+ SetDlgItemText(hwnd, IDC_WIFI_RF2_INIT + i, hex6w(read24(data, 0xCE+(i*3))));
+
+ for (int i = 0; i < (0x54 / 3 / 2); i++)
+ {
+ // check
+ SetDlgItemText(hwnd, IDC_WIFI_RF2_56_CH + i, hex6w(read24(data, 0xF2+(i*3))));
+ SetDlgItemText(hwnd, IDC_WIFI_RF2_56_CH + i + 14, hex6w(read24(data, (0xF2+3*14)+(i*3))));
+ }
+
+ for (int i = 0; i < 0x0E; i++)
+ {
+ SetDlgItemText(hwnd, IDC_WIFI_RF2_BB_RF_CH + i, hex2w(read8(data, 0x146+i)));
+ SetDlgItemText(hwnd, IDC_WIFI_RF2_BB_RF_CH + i + 14, hex2w(read8(data, 0x154+i)));
+ }
+ }
+ else
+ if (read8(gFirmwareData, 0x44) == 3)
+ {
+ // TODO
+ }
+
+ return true;
+}
+
+BOOL CALLBACK wifiDlgProc(HWND hdlg,UINT msg, WPARAM wParam,LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ SetWindowText(hdlg, "WiFi Settings");
+ u16 size = sizeof(TwifiDlg1)/sizeof(TwifiDlg1[0]);
+ for (int i = 0; i < size; i++)
+ {
+ CreateWindow(TwifiDlg1[i].wclass, TwifiDlg1[i].wtitle, WS_CHILD | WS_VISIBLE | TwifiDlg1[i].style,
+ TwifiDlg1[i].x, TwifiDlg1[i].y, TwifiDlg1[i].w, TwifiDlg1[i].h, hdlg, (HMENU)TwifiDlg1[i].id, gInstance, NULL);
+ }
+
+ u32 x = 40, y = Y_WIFI_BB+15;
+ //=========================================================
+ for (int i = 0; i < 0x69; i++)
+ {
+ CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_CENTER,
+ x, y, 20, 20, hdlg, (HMENU)(IDC_WIFI_BB + i), gInstance, NULL);
+ x += 25;
+ if ((i > 20) && ((i % 26) == 0))
+ {
+ x = 40;
+ y +=25;
+ }
+ }
+
+ if (read8(gFirmwareData, 0x44) == 2)
+ {
+ u8 rfIndexes[] = {0, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 1, 2, 3};
+ CreateWindow("BUTTON", "RF chip Type 2", WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
+ 5, Y_WIFI_RF, 720, 290, hdlg, (HMENU)NULL, gInstance, NULL);
+ CreateWindow("BUTTON", "RFx Initial values...", WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
+ 15, Y_WIFI_RF+15, 700, 75, hdlg, (HMENU)NULL, gInstance, NULL);
+ y = 0; x = 60;
+ for (int i = 0; i < (0x24 / 3); i++)
+ {
+ char buf[10] = { 0 };
+ sprintf(buf, "%02X", rfIndexes[i]);
+ CreateWindow("STATIC", buf, WS_CHILD | WS_VISIBLE,
+ x, Y_WIFI_RF + 35 + y, 30, 18, hdlg, (HMENU)NULL, gInstance, NULL);
+ CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_CENTER,
+ x + 18, Y_WIFI_RF + 35 + y, 65, 18, hdlg, (HMENU)(IDC_WIFI_RF2_INIT + i), gInstance, NULL);
+ x += 105;
+ if (i == 5)
+ {
+ y = 25;
+ x = 60;
+ }
+ }
+
+ CreateWindow("BUTTON", "RF values (channel 1..14)", WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
+ 15, Y_WIFI_RF+95, 700, 115, hdlg, (HMENU)NULL, gInstance, NULL);
+ CreateWindow("STATIC", "RF5", WS_CHILD | WS_VISIBLE, 25, Y_WIFI_RF + 115, 30, 18, hdlg, (HMENU)NULL, gInstance, NULL);
+ CreateWindow("STATIC", "RF6", WS_CHILD | WS_VISIBLE, 25, Y_WIFI_RF + 160, 30, 18, hdlg, (HMENU)NULL, gInstance, NULL);
+ y = 0; x = 60;
+ for (int i = 0; i < 14; i++)
+ {
+ CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_CENTER,
+ x, Y_WIFI_RF + 115 + y, 65, 18, hdlg, (HMENU)(IDC_WIFI_RF2_56_CH + i), gInstance, NULL);
+ x += 95;
+ if (i == 6)
+ {
+ y = 22;
+ x = 60;
+ }
+ }
+
+ y = 0; x = 60;
+ for (int i = 0; i < 14; i++)
+ {
+ CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_CENTER,
+ x, Y_WIFI_RF + 160 + y, 65, 18, hdlg, (HMENU)(IDC_WIFI_RF2_56_CH + i + 14), gInstance, NULL);
+ x += 95;
+ if (i == 6)
+ {
+ y = 22;
+ x = 60;
+ }
+ }
+
+ CreateWindow("BUTTON", "BB/RF 8bit values (channel 1..14)", WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
+ 15, Y_WIFI_RF+210, 700, 70, hdlg, (HMENU)NULL, gInstance, NULL);
+ CreateWindow("STATIC", "BB", WS_CHILD | WS_VISIBLE, 25, Y_WIFI_RF + 230, 30, 18, hdlg, (HMENU)NULL, gInstance, NULL);
+ CreateWindow("STATIC", "RF9", WS_CHILD | WS_VISIBLE, 25, Y_WIFI_RF + 250, 30, 18, hdlg, (HMENU)NULL, gInstance, NULL);
+ for (int i = 0; i < 14; i++)
+ {
+ CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_CENTER,
+ 60+ (i*45), Y_WIFI_RF + 230, 35, 18, hdlg, (HMENU)(IDC_WIFI_RF2_BB_RF_CH + i), gInstance, NULL);
+ }
+ for (int i = 0; i < 14; i++)
+ {
+ CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_CENTER,
+ 60+ (i*45), Y_WIFI_RF + 250, 35, 18, hdlg, (HMENU)(IDC_WIFI_RF2_BB_RF_CH + i + 14), gInstance, NULL);
+ }
+ }
+ else
+ if (read8(gFirmwareData, 0x44) == 3)
+ {
+ // TODO
+ }
+
+ size = sizeof(TwifiDlg2)/sizeof(TwifiDlg2[0]);
+ for (int i = 0; i < size; i++)
+ {
+ CreateWindow(TwifiDlg2[i].wclass, TwifiDlg2[i].wtitle, WS_CHILD | WS_VISIBLE | TwifiDlg2[i].style,
+ TwifiDlg2[i].x, TwifiDlg2[i].y, TwifiDlg2[i].w, TwifiDlg2[i].h, hdlg, (HMENU)TwifiDlg2[i].id, gInstance, NULL);
+ }
+ refreshWiFiDlg(hdlg);
+ break;
+ }
+ case WM_CTLCOLORDLG:
+ {
+ HDC hdc = (HDC)wParam;
+ SetTextColor(hdc,RGB(200,200,200));
+ SetBkColor(hdc,RGB(60,60,60));
+ return (BOOL)hbBackground;
+ }
+
+ case WM_CTLCOLORBTN:
+ return (BOOL)hbBackground;
+
+ case WM_CTLCOLOREDIT:
+ {
+ HDC hdc = (HDC)wParam;
+ SetTextColor(hdc,RGB(200,200,200));
+ SetBkColor(hdc,RGB(60,60,60));
+ return (BOOL)hbEditBackground;
+ }
+
+ case WM_CTLCOLORSTATIC:
+ {
+ HDC hdc = (HDC)wParam;
+ u32 id = GetWindowLong((HWND)lParam, GWL_ID);
+ if ((id > IDC_WIFI_EDIT_STATIC) && (id < IDC_WIFI_EDIT_STATIC + 100))
+ {
+ SetTextColor(hdc,RGB(200,200,200));
+ SetBkColor(hdc,RGB(60,60,60));
+ return (LRESULT)hbEditBackground;
+ }
+ SetTextColor(hdc,RGB(0xFF,0xFF,0xFF));
+ SetBkColor(hdc,RGB(0x6D,0x70, 0xA0));
+ return (LRESULT)hbBackground;
+ }
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ EndDialog(hdlg, 1);
+ break;
+
+ case IDCANCEL:
+ EndDialog(hdlg, 0);
+ break;
+
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+bool refreshUserDlg(HWND hwnd)
+{
+ u8 *data = (u8*)(gFirmwareData + (header.user_settings_offset * 8));
+ char buf[256] = { 0 };
+
+ wcstombs(buf, (wchar_t *)(data+0x06), read16(data,0x1A));
+ SetDlgItemText(hwnd, IDC_NICKNAME, buf);
+
+ memset(buf, 0, sizeof(buf));
+ wcstombs(buf, (wchar_t *)(data+0x1C), read16(data,0x50));
+ SetDlgItemText(hwnd, IDC_MESSAGE, buf);
+
+ SendMessage(GetDlgItem(hwnd, IDC_BIRTH_DAY), CB_SETCURSEL, data[0x04]-1, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_BIRTH_MONTH), CB_SETCURSEL, data[0x03]-1, 0);
+
+ // lang
+ if ((header.console_type == 0x43) || (header.console_type == 0x63))
+ {
+ SendMessage(GetDlgItem(hwnd, IDC_LANGUAGE), CB_SETCURSEL, read16(data,0x75)&0x07, 0);
+ }
+ else
+ {
+ SendMessage(GetDlgItem(hwnd, IDC_LANGUAGE), CB_SETCURSEL, read16(data,0x64)&0x07, 0);
+ }
+
+ SendMessage(GetDlgItem(hwnd, IDC_ALARM_ON), BM_SETCHECK, data[0x56]?BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_ALARM_HOUR), CB_SETCURSEL, data[0x52], 0);
+ SendMessage(GetDlgItem(hwnd, IDC_ALARM_MIN), CB_SETCURSEL, data[0x53], 0);
+
+ currColor = read8(data, 0x02);
+
+ SendMessage(GetDlgItem(hwnd, IDC_GBA_MODE_SCREENS), CB_SETCURSEL, (read16(data,0x64) >> 3)&0x01, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_BRIGHTLIGHT_LEVEL), CB_SETCURSEL, (read16(data,0x64) >> 4)&0x03, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_BOOTMENU), CB_SETCURSEL, (read16(data,0x64) >> 6)&0x01, 0);
+
+ SetDlgItemText(hwnd, IDC_TADC_X1, hex2w(read16(data,0x58)&0xFFF));
+ SetDlgItemText(hwnd, IDC_TADC_Y1, hex2w(read16(data,0x5A)&0xFFF));
+ SetDlgItemText(hwnd, IDC_TADC_X2, hex2w(read16(data,0x5E)&0xFFF));
+ SetDlgItemText(hwnd, IDC_TADC_Y2, hex2w(read16(data,0x60)&0xFFF));
+
+ SetDlgItemText(hwnd, IDC_TSCR_X1, hex2w(read16(data,0x5C)&0xFF));
+ SetDlgItemText(hwnd, IDC_TSCR_Y1, hex2w(read16(data,0x5F)&0xFF));
+ SetDlgItemText(hwnd, IDC_TSCR_X2, hex2w(read16(data,0x62)&0xFF));
+ SetDlgItemText(hwnd, IDC_TSCR_Y2, hex2w(read16(data,0x64)&0xFF));
+
+ SetDlgItemInt(hwnd, IDC_RTC_OFFSET, read32(data,0x68), true);
+ SetDlgItemInt(hwnd, IDC_YEAR_BOOT, 2000+read8(data,0x66), false);
+ SetDlgItemInt(hwnd, IDC_UPDATE_COUNTER, read16(data,0x70), false);
+ SetDlgItemText(hwnd, IDC_USER_CRC16, hex4(read16(data,0x72)));
+
+ return true;
+}
+
+BOOL CALLBACK userDlgProc(HWND hdlg,UINT msg, WPARAM wParam,LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ SetWindowText(hdlg, "User settings");
+ u16 size = sizeof(TuserDlg1)/sizeof(TuserDlg1[0]);
+ for (int i = 0; i < size; i++)
+ {
+ CreateWindow(TuserDlg1[i].wclass, TuserDlg1[i].wtitle, WS_CHILD | WS_VISIBLE | TuserDlg1[i].style,
+ TuserDlg1[i].x, TuserDlg1[i].y, TuserDlg1[i].w, TuserDlg1[i].h, hdlg, (HMENU)TuserDlg1[i].id, gInstance, NULL);
+ }
+
+ u32 y_ofs = Y_FAV_COLOR + 15, x_ofs = 0;
+ for (int i = 0; i < 16; i++)
+ {
+ char buf[22] = { 0 };
+ sprintf(buf,"%02i",i);
+ CreateWindow("BUTTON", buf, WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_OWNERDRAW, 25 + x_ofs, 5 + y_ofs, 40, 40, hdlg, (HMENU)(IDC_COLOR+i), gInstance, NULL);
+ x_ofs += 45;
+ if (i == 7)
+ {
+ x_ofs = 0;
+ y_ofs += 45;
+ }
+ }
+
+ size = sizeof(TuserDlg2)/sizeof(TuserDlg2[0]);
+ for (int i = 0; i < size; i++)
+ {
+ CreateWindow(TuserDlg2[i].wclass, TuserDlg2[i].wtitle, WS_CHILD | WS_VISIBLE | TuserDlg2[i].style,
+ TuserDlg2[i].x, TuserDlg2[i].y, TuserDlg2[i].w, TuserDlg2[i].h, hdlg, (HMENU)TuserDlg2[i].id, gInstance, NULL);
+ }
+
+ HWND tmp_wnd = GetDlgItem(hdlg, IDC_BIRTH_DAY);
+ for (int i = 1; i < 32; i++)
+ {
+ char bf[10] = {0};
+ _itoa(i, bf, 10);
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)bf);
+ }
+
+ tmp_wnd = GetDlgItem(hdlg, IDC_BIRTH_MONTH);
+ for (int i = 1; i < 13; i++)
+ {
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)months[i-1]);
+ }
+
+ tmp_wnd = GetDlgItem(hdlg, IDC_ALARM_HOUR);
+ for (int i = 0; i < 24; i++)
+ {
+ char bf[10] = {0};
+ itoa(i, bf, 10);
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)bf);
+ }
+
+ tmp_wnd = GetDlgItem(hdlg, IDC_ALARM_MIN);
+ for (int i = 0; i < 60; i++)
+ {
+ char bf[10] = {0};
+ itoa(i, bf, 10);
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)bf);
+ }
+
+ tmp_wnd = GetDlgItem(hdlg, IDC_LANGUAGE);
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Japanese");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"English");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"French");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"German");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Italian");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Spanish");
+ if ((header.console_type == 0x43) || (header.console_type == 0x63))
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Chinese");
+
+ tmp_wnd = GetDlgItem(hdlg, IDC_GBA_MODE_SCREENS);
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Upper");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Lower");
+
+ tmp_wnd = GetDlgItem(hdlg, IDC_BRIGHTLIGHT_LEVEL);
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Low");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Med");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"High");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Max");
+
+ tmp_wnd = GetDlgItem(hdlg, IDC_BOOTMENU);
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Manual/bootmenu");
+ SendMessage(tmp_wnd, CB_ADDSTRING, 0, (LPARAM)"Autostart Cartridge");
+
+ refreshUserDlg(hdlg);
+ return TRUE;
+ }
+
+ case WM_DRAWITEM:
+ {
+ if ((wParam >= IDC_COLOR) && (wParam <= (IDC_COLOR + 15)))
+ {
+ LPDRAWITEMSTRUCT di = (LPDRAWITEMSTRUCT)lParam;
+ FillRect(di->hDC, &di->rcItem, hbColors[wParam - IDC_COLOR]);
+
+ if (di->itemState & ODS_FOCUS)
+ {
+ ExcludeClipRect(di->hDC, di->rcItem.left+4, di->rcItem.top+4, di->rcItem.right-4, di->rcItem.bottom-4);
+ HPEN pen = CreatePen(PS_DASH, 1, RGB(255,255,255));
+ SelectObject(di->hDC, pen);
+ Rectangle(di->hDC, di->rcItem.left+2, di->rcItem.top+2, di->rcItem.right-2, di->rcItem.bottom-2);
+ }
+ ExcludeClipRect(di->hDC, di->rcItem.left+2, di->rcItem.top+2, di->rcItem.right-2, di->rcItem.bottom-2);
+ if (di->itemState & ODS_FOCUS)
+ {
+ HPEN pen = CreatePen(PS_DASH, 3, RGB(0,0,0));
+ SelectObject(di->hDC, pen);
+ Rectangle(di->hDC, di->rcItem.left, di->rcItem.top, di->rcItem.right, di->rcItem.bottom);
+ }
+ else
+ {
+ if ((wParam - IDC_COLOR) == currColor)
+ {
+ HPEN pen = CreatePen(PS_DASH, 3, RGB(255,255,255));
+ SelectObject(di->hDC, pen);
+ Rectangle(di->hDC, di->rcItem.left, di->rcItem.top, di->rcItem.right, di->rcItem.bottom);
+ }
+ }
+ return TRUE;
+ }
+
+ break;
+ }
+ case WM_CTLCOLORDLG:
+ {
+ HDC hdc = (HDC)wParam;
+ SetTextColor(hdc,RGB(200,200,200));
+ SetBkColor(hdc,RGB(60,60,60));
+ return (BOOL)hbBackground;
+ }
+
+ case WM_CTLCOLORBTN:
+ return (BOOL)hbBackground;
+
+ case WM_CTLCOLOREDIT:
+ {
+ HDC hdc = (HDC)wParam;
+ SetTextColor(hdc,RGB(200,200,200));
+ SetBkColor(hdc,RGB(60,60,60));
+ return (BOOL)hbEditBackground;
+ }
+
+ case WM_CTLCOLORSTATIC:
+ {
+ HDC hdc = (HDC)wParam;
+ SetTextColor(hdc,RGB(0xFF,0xFF,0xFF));
+ SetBkColor(hdc,RGB(0x6D,0x70, 0xA0));
+ return (LRESULT)hbBackground;
+ }
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ EndDialog(hdlg, 1);
+ break;
+
+ case IDCANCEL:
+ EndDialog(hdlg, 0);
+ break;
+
+ }
+ break;
+ }
+ return FALSE;
+}
+
+BOOL Browse()
+{
+ static OPENFILENAME ofn={0};
+ static BOOL bSetInitialDir = FALSE;
+
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = gMainWnd;
+ ofn.lpstrFilter = NULL;
+ ofn.lpstrFilter = "Binary (*.bin,*.rom)\0*.bin; *.rom\0All files (*.*)\0*.*\0";
+ ofn.lpstrCustomFilter = NULL;
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = firmware_path;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.lpstrTitle = TEXT("Open firmware\0");
+ ofn.lpstrFileTitle = NULL;
+ ofn.lpstrDefExt = TEXT("*\0");
+ ofn.Flags = OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_HIDEREADONLY;
+ ofn.lpstrInitialDir = NULL;
+
+ return GetOpenFileName((LPOPENFILENAME)&ofn);
+}
+
+LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_CREATE:
+ {
+ u16 size = sizeof(TmainWnd)/sizeof(TmainWnd[0]);
+ for (int i = 0; i < size; i++)
+ {
+ if (!CreateWindow(TmainWnd[i].wclass, TmainWnd[i].wtitle, WS_CHILD | WS_VISIBLE | TmainWnd[i].style,
+ TmainWnd[i].x, TmainWnd[i].y, TmainWnd[i].w, TmainWnd[i].h, hwnd, (HMENU)TmainWnd[i].id, gInstance, NULL))
+ {
+ INFO("ERROR: %03i - %s: %s\n", i, TmainWnd[i].wtitle, error());
+ return -1;
+ }
+ }
+
+ return 0L;
+ }
+ case WM_DESTROY:
+ {
+ PostQuitMessage(0);
+ return 0L;
+ }
+
+ case WM_CTLCOLORSTATIC:
+ {
+ HDC hdc = (HDC)wParam;
+ u32 id = GetWindowLong((HWND)lParam, GWL_ID);
+
+ if (id == IDC_BPATH)
+ {
+ SetTextColor(hdc,RGB(200,200,200));
+ SetBkColor(hdc,RGB(60,60,60));
+ return (LRESULT)hbEditBackground;
+ }
+ if ((id > IDC_H_EDIT_START) && (id < IDC_H_EDIT_LAST))
+ {
+ char buf2[512] = {0};
+ GetWindowText((HWND)lParam, buf2, 512);
+ if (strcmp(buf2, "not present ") == 0)
+ {
+ SetTextColor(hdc,RGB(0xED,0xF5,0x11));
+ }
+ else
+ if (strcmp(buf2, "N/A") == 0)
+ {
+ SetTextColor(hdc,RGB(0xFF,0x0F,0xFF));
+ }
+ else
+ if (strcmp(buf2, "ERROR") == 0)
+ {
+ SetTextColor(hdc,RGB(0xFF,0x0F,0x0F));
+ }
+ else
+ {
+ SetTextColor(hdc,RGB(0xFF,0xFF,0xFF));
+ }
+ SetBkColor(hdc,RGB(60,60,60));
+ return (LRESULT)hbEditBackground;
+ }
+ else
+ {
+ SetTextColor(hdc,RGB(0xFF,0xFF,0xFF));
+ SetBkColor(hdc,RGB(0x6D,0x70, 0xA0));
+ return (LRESULT)hbBackground;
+ }
+ }
+
+ case WM_CTLCOLORBTN:
+ return (LRESULT)hbBackground;
+
+ case WM_CTLCOLOREDIT:
+ {
+ HDC hdc = (HDC)wParam;
+ SetTextColor(hdc,RGB(200,200,200));
+ SetBkColor(hdc,RGB(60,60,60));
+ return (LRESULT)hbEditBackground;
+ }
+
+ case WM_COMMAND:
+ {
+ u32 id = GetWindowLong((HWND)lParam, GWL_ID);
+ switch (id)
+ {
+ case IDC_BBROWSE:
+ if (HIWORD(wParam) == BN_CLICKED)
+ {
+ char tmp_buf[MAX_PATH] = { 0 };
+ strcpy(tmp_buf, firmware_path);
+ if (Browse())
+ {
+ if (loadFirmware())
+ {
+ EnableWindow(GetDlgItem(hwnd, IDC_BUSER), TRUE);
+ EnableWindow(GetDlgItem(hwnd, IDC_BWIFI), TRUE);
+ EnableWindow(GetDlgItem(hwnd, IDC_BWIFIAP), TRUE);
+ return 0L;
+ }
+ MessageBox(NULL, "Error loading firmware", _TITLE, MB_OK | MB_ICONERROR);
+ INFO("Error loading firmware\n");
+ }
+ strcpy(firmware_path, tmp_buf);
+ return 0L;
+ }
+ break;
+
+ case IDC_BEXIT:
+ if (HIWORD(wParam) == BN_CLICKED)
+ SendMessage(hwnd, WM_CLOSE, 0, 0);
+ break;
+
+ case IDC_BUSER:
+ {
+ LPDLGTEMPLATE dlgTemplate = (LPDLGTEMPLATE)malloc(1024);
+ if (dlgTemplate)
+ {
+ memset(dlgTemplate, 0, 1024);
+ dlgTemplate->style = DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU;
+ dlgTemplate->cx = 205;
+ dlgTemplate->cy = 300;
+ if (DialogBoxIndirect(gInstance, dlgTemplate, hwnd, userDlgProc) == -1)
+ INFO("ERROR: %s\n", error());
+ free(dlgTemplate);
+ return 0L;
+ }
+ INFO("ERROR: %s\n", error());
+ return 0L;
+ }
+ case IDC_BWIFI:
+ {
+ LPDLGTEMPLATE dlgTemplate = (LPDLGTEMPLATE)malloc(1024);
+ if (dlgTemplate)
+ {
+ memset(dlgTemplate, 0, 1024);
+ dlgTemplate->style = DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU;
+ dlgTemplate->cx = 365;
+ dlgTemplate->cy = 300;
+ if (DialogBoxIndirect(gInstance, dlgTemplate, hwnd, wifiDlgProc) == -1)
+ INFO("ERROR: %s\n", error());
+ free(dlgTemplate);
+ return 0L;
+ }
+ INFO("ERROR: %s\n", error());
+ return 0L;
+ }
+
+ case IDC_BWIFIAP:
+ {
+ LPDLGTEMPLATE dlgTemplate = (LPDLGTEMPLATE)malloc(1024);
+ if (dlgTemplate)
+ {
+ memset(dlgTemplate, 0, 1024);
+ dlgTemplate->style = DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU;
+ dlgTemplate->cx = 365;
+ dlgTemplate->cy = 350;
+ if (DialogBoxIndirect(gInstance, dlgTemplate, hwnd, wifiAPDlgProc) == -1)
+ INFO("ERROR: %s\n", error());
+ free(dlgTemplate);
+ return 0L;
+ }
+ INFO("ERROR: %s\n", error());
+ return 0L;
+ }
+ }
+ }
+ }
+ return DefWindowProc(hwnd,msg,wParam,lParam);
+}
+
+int RegClass(WNDPROC Proc, LPCTSTR szName)
+{
+ WNDCLASS wc = { 0 };
+
+ wc.style=CS_HREDRAW|CS_VREDRAW;
+ wc.cbClsExtra=wc.cbWndExtra=0;
+ wc.lpfnWndProc=Proc;
+ wc.hInstance=gInstance;
+ wc.hIcon=LoadIcon(gInstance, IDI_APPLICATION);
+ wc.hCursor=LoadCursor(NULL,IDC_ARROW);
+ wc.hbrBackground=(HBRUSH)hbBackground;
+ wc.lpszMenuName=(LPCTSTR)NULL;
+ wc.lpszClassName=szName;
+ return RegisterClass(&wc);
+}
+
+BOOL InitCommonCtrls()
+{
+ INITCOMMONCONTROLSEX CommCtrl;
+
+ CommCtrl.dwSize=sizeof INITCOMMONCONTROLSEX;
+ CommCtrl.dwICC=ICC_WIN95_CLASSES|ICC_COOL_CLASSES|ICC_USEREX_CLASSES;
+ return InitCommonControlsEx(&CommCtrl);
+}
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+ MSG msg;
+
+ InitCommonCtrls();
+ hbBackground = CreateSolidBrush(RGB(0x6D,0x70, 0xA0));
+ hbEditBackground = CreateSolidBrush(RGB(60, 60, 60));
+ OpenConsole();
+ gInstance = hInstance;
+ if (!RegClass(WndProc, MAINCLASS))
+ {
+ DeleteObject(hbEditBackground); DeleteObject(hbBackground);
+ MessageBox(NULL, "Error registering class", _TITLE, MB_OK | MB_ICONERROR);
+ return -1;
+ }
+
+ gFirmwareData = new u8 [512 * 1024];
+ if (!gFirmwareData)
+ {
+ DeleteObject(hbEditBackground); DeleteObject(hbBackground);
+ MessageBox(NULL, "Error allocating firmware data", _TITLE, MB_OK | MB_ICONERROR);
+ UnregisterClass(MAINCLASS, gInstance);
+ return -2;
+ }
+ memset(gFirmwareData, 0, 512*1024);
+
+ gMainWnd=CreateWindow(MAINCLASS, _TITLE,
+ WS_OVERLAPPED | WS_SYSMENU,
+ gMainWndPos.left,gMainWndPos.top,
+ gMainWndPos.right,gMainWndPos.bottom,
+ NULL, (HMENU)NULL, hInstance,NULL);
+
+ if (!gMainWnd)
+ {
+ DeleteObject(hbEditBackground); DeleteObject(hbBackground);
+ MessageBox(NULL, "Error creating main window", _TITLE, MB_OK | MB_ICONERROR);
+ UnregisterClass(MAINCLASS, gInstance);
+ delete [] gFirmwareData;
+ gFirmwareData = NULL;
+ return -3;
+ }
+
+ for (int t = 0; t < 16; t++)
+ hbColors[t] = CreateSolidBrush(firmColor[t]);
+
+ ShowWindow(gMainWnd, SW_NORMAL);
+ UpdateWindow(gMainWnd);
+ while (GetMessage(&msg, 0,0,0))
+ {
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ for (int t = 0; t < 16; t++)
+ {
+ DeleteObject(hbColors[t]);
+ }
+ DeleteObject(hbEditBackground);
+ DeleteObject(hbBackground);
+
+ delete [] gFirmwareData;
+ gFirmwareData = NULL;
+ UnregisterClass(MAINCLASS, gInstance);
+ CloseConsole();
+
+ return 0;
+}
\ No newline at end of file
diff --git a/tools/nds_firmware_tool/src/main.h b/tools/nds_firmware_tool/src/main.h
new file mode 100644
index 000000000..27dbcbee2
--- /dev/null
+++ b/tools/nds_firmware_tool/src/main.h
@@ -0,0 +1,55 @@
+/* NDS Firmware tools
+
+ Copyright 2009 DeSmuME team
+
+ This file is part of DeSmuME
+
+ DeSmuME is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DeSmuME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DeSmuME; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef __MAIN_H_
+#define __MAIN_H_
+#include
+#include
+#include "common.h"
+#include "console.h"
+
+#define _TITLE "NDS Firmware tool v0.0.3 by DeSmuME Team"
+#define MAINCLASS "NDS_FIRMWARE_TOOLS"
+
+typedef struct
+{
+ u16 part3_rom_gui9_addr; // 000h
+ u16 part4_rom_wifi7_addr; // 002h
+ u16 part34_gui_wifi_crc16; // 004h
+ u16 part12_boot_crc16; // 006h
+ u8 fw_identifier[4]; // 008h
+ u16 part1_rom_boot9_addr; // 00Ch
+ u16 part1_ram_boot9_addr; // 00Eh
+ u16 part2_rom_boot7_addr; // 010h
+ u16 part2_ram_boot7_addr; // 012h
+ u16 shift_amounts; // 014h
+ u16 part5_data_gfx_addr; // 016h
+
+ u8 fw_timestamp[5]; // 018h
+ u8 console_type; // 01Dh
+ u16 unused1; // 01Eh
+ u16 user_settings_offset; // 020h
+ u16 unknown1; // 022h
+ u16 unknown2; // 024h
+ u16 part5_crc16; // 026h
+ u16 unused2; // 028h - FFh filled
+} HEADER;
+#endif
\ No newline at end of file
diff --git a/tools/nds_firmware_tool/src/nds_firmware_tool.manifest b/tools/nds_firmware_tool/src/nds_firmware_tool.manifest
new file mode 100644
index 000000000..c9e0581f8
--- /dev/null
+++ b/tools/nds_firmware_tool/src/nds_firmware_tool.manifest
@@ -0,0 +1,23 @@
+
+
+
+NDS Firmware tools
+
+
+
+
+
+
diff --git a/tools/nds_firmware_tool/src/resource_ids.h b/tools/nds_firmware_tool/src/resource_ids.h
new file mode 100644
index 000000000..77b46b644
--- /dev/null
+++ b/tools/nds_firmware_tool/src/resource_ids.h
@@ -0,0 +1,146 @@
+/* NDS Firmware tools
+
+ Copyright 2009 DeSmuME team
+
+ This file is part of DeSmuME
+
+ DeSmuME is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DeSmuME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DeSmuME; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef _RESOURCE_IDS_H_
+#define _RESOURCE_IDS_H_
+
+#define IDC_H_EDIT_START 100000
+
+#define IDC_H1_TYPE 100001
+#define IDC_H1_VERSION 100002
+#define IDC_H1_TIMESTAMP 100003
+#define IDC_H1_SIZE 100004
+#define IDC_H1_CRC 100005
+#define IDC_H1_ARM9_ROM 100006
+#define IDC_H1_ARM9_RAM 100007
+#define IDC_H1_ARM9_GUI 100008
+#define IDC_H1_ARM7_ROM 100009
+#define IDC_H1_ARM7_RAM 100010
+#define IDC_H1_ARM7_WIFI 100011
+
+#define IDC_H2_TYPE 100021
+#define IDC_H2_VERSION 100022
+#define IDC_H2_SIZE 100023
+#define IDC_H2_CRC 100024
+#define IDC_H2_ARM9_ROM 100025
+#define IDC_H2_ARM9_RAM 100026
+#define IDC_H2_ARM9_GUI 100027
+#define IDC_H2_ARM7_ROM 100028
+#define IDC_H2_ARM7_RAM 100029
+#define IDC_H2_ARM7_WIFI 100030
+
+#define IDC_H_EDIT_LAST 100300
+
+#define IDC_COLOR 100500
+
+#define IDC_BBROWSE 300000
+#define IDC_BPATH 300001
+#define IDC_BEXIT 300002
+#define IDC_BUSER 300003
+#define IDC_BWIFI 300005
+#define IDC_BWIFIAP 300006
+
+#define IDC_NICKNAME 300020
+#define IDC_MESSAGE 300021
+#define IDC_BIRTH_DAY 300022
+#define IDC_BIRTH_MONTH 300023
+#define IDC_LANGUAGE 300024
+#define IDC_ALARM_ON 300025
+#define IDC_ALARM_HOUR 300026
+#define IDC_ALARM_MIN 300027
+#define IDC_GBA_MODE_SCREENS 300028
+#define IDC_BRIGHTLIGHT_LEVEL 300029
+#define IDC_BOOTMENU 300030
+#define IDC_TADC_X1 300031
+#define IDC_TADC_Y1 300032
+#define IDC_TADC_X2 300033
+#define IDC_TADC_Y2 300034
+#define IDC_TSCR_X1 300035
+#define IDC_TSCR_Y1 300036
+#define IDC_TSCR_X2 300037
+#define IDC_TSCR_Y2 300038
+#define IDC_RTC_OFFSET 300039
+#define IDC_YEAR_BOOT 300040
+#define IDC_UPDATE_COUNTER 300041
+#define IDC_USER_CRC16 300042
+
+#define IDC_WIFI_044 301000
+#define IDC_WIFI_046 301001
+#define IDC_WIFI_048 301002
+#define IDC_WIFI_04A 301003
+#define IDC_WIFI_04C 301004
+#define IDC_WIFI_04E 301005
+#define IDC_WIFI_050 301006
+#define IDC_WIFI_052 301007
+#define IDC_WIFI_054 301008
+#define IDC_WIFI_056 301009
+#define IDC_WIFI_058 301010
+#define IDC_WIFI_05A 301011
+#define IDC_WIFI_05C 301012
+#define IDC_WIFI_05E 301013
+#define IDC_WIFI_060 301014
+#define IDC_WIFI_062 301015
+
+#define IDC_WIFI_ECHANNEL_01 300200
+#define IDC_WIFI_ECHANNEL_02 300201
+#define IDC_WIFI_ECHANNEL_03 300202
+#define IDC_WIFI_ECHANNEL_04 300203
+#define IDC_WIFI_ECHANNEL_05 300204
+#define IDC_WIFI_ECHANNEL_06 300205
+#define IDC_WIFI_ECHANNEL_07 300206
+#define IDC_WIFI_ECHANNEL_08 300207
+#define IDC_WIFI_ECHANNEL_09 300208
+#define IDC_WIFI_ECHANNEL_10 300209
+#define IDC_WIFI_ECHANNEL_11 300210
+#define IDC_WIFI_ECHANNEL_12 300211
+#define IDC_WIFI_ECHANNEL_13 300212
+#define IDC_WIFI_ECHANNEL_14 300213
+
+#define IDC_WIFI_EDIT_STATIC 300400
+#define IDC_WIFI_CRC16 300401
+#define IDC_WIFI_VERSION 300402
+#define IDC_WIFI_MACID 300403
+#define IDC_WIFI_RFTYPE 300404
+
+#define IDC_WIFI_BB 300500
+
+#define IDC_WIFI_RF2_INIT 300700
+#define IDC_WIFI_RF2_56_CH 300750
+#define IDC_WIFI_RF2_BB_RF_CH 300800
+
+#define IDC_WIFI_AP_SSID 301000
+#define IDC_WIFI_AP_SSID2 301001
+#define IDC_WIFI_AP_WEP_SIZE 301002
+#define IDC_WIFI_AP_WEP_EMETHOD 301003
+#define IDC_WIFI_AP_KEY1 301004
+#define IDC_WIFI_AP_KEY2 301005
+#define IDC_WIFI_AP_KEY3 301006
+#define IDC_WIFI_AP_KEY4 301007
+#define IDC_WIFI_AP_USER_ID 301008
+#define IDC_WIFI_AP_IP 301009
+#define IDC_WIFI_AP_IPMASK 301010
+#define IDC_WIFI_AP_GATEWAY 301011
+#define IDC_WIFI_AP_DNS1 301012
+#define IDC_WIFI_AP_DNS2 301013
+#define IDC_WIFI_AP_STATUS 301014
+#define IDC_WIFI_AP_CRC16 301015
+
+#endif
\ No newline at end of file
diff --git a/tools/nds_firmware_tool/src/templates.h b/tools/nds_firmware_tool/src/templates.h
new file mode 100644
index 000000000..84baf28fc
--- /dev/null
+++ b/tools/nds_firmware_tool/src/templates.h
@@ -0,0 +1,324 @@
+/* NDS Firmware tools
+
+ Copyright 2009 DeSmuME team
+
+ This file is part of DeSmuME
+
+ DeSmuME is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DeSmuME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DeSmuME; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef __TEMPLATES_H_
+#include "common.h"
+#include "resource_ids.h"
+typedef struct
+{
+ char wclass[20];
+ char wtitle[50];
+ u32 style;
+ u32 x;
+ u32 y;
+ u32 w;
+ u32 h;
+ u32 id;
+} TEMPLATE;
+
+#define Y_HEADER 65
+#define Y_ARM9 250
+#define Y_ARM7 375
+#define Y_OTHERS 520
+#define X_SECOND_FW 350
+#define Y_BUTTONS 500
+
+const TEMPLATE TmainWnd[] = {
+ {"STATIC", "Firmware path:", 0, 5, 5, 100, 20, NULL},
+ {"EDIT", "", ES_READONLY, 5, 25, 595, 20, IDC_BPATH},
+ {"BUTTON", "Browse...", WS_TABSTOP | BS_DEFPUSHBUTTON, 610, 25, 80, 20, IDC_BBROWSE},
+
+ {"BUTTON", "Header data", BS_GROUPBOX, 4, Y_HEADER, 340, 180, NULL},
+ {"STATIC", "Console type", 0, 15, Y_HEADER + 30, 300, 20, NULL},
+ {"STATIC", "Version", 0, 15, Y_HEADER + 60, 300, 20, NULL},
+ {"STATIC", "Built timestamp (d/m/y h:m)", 0, 15, Y_HEADER + 90, 300, 20, NULL},
+ {"STATIC", "Size of firmware", 0, 15, Y_HEADER + 120, 300, 20, NULL},
+ {"STATIC", "CRC", 0, 15, Y_HEADER + 150, 300, 20, NULL},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, 230, Y_HEADER + 30, 100, 20, IDC_H1_TYPE},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, 230, Y_HEADER + 60, 100, 20, IDC_H1_VERSION},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, 230, Y_HEADER + 90, 100, 20, IDC_H1_TIMESTAMP},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, 230, Y_HEADER + 120, 100, 20, IDC_H1_SIZE},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, 230, Y_HEADER + 150, 100, 20, IDC_H1_CRC},
+
+ {"BUTTON", "ARM9", BS_GROUPBOX, 4, Y_ARM9, 340, 120, NULL},
+ {"STATIC", "ARM9 boot code address", 0, 15, Y_ARM9+30, 300, 20, NULL},
+ {"STATIC", "ARM9 boot code RAM address", 0, 15, Y_ARM9+60, 300, 20, NULL},
+ {"STATIC", "ARM9 GUI code address", 0, 15, Y_ARM9+90, 300, 20, NULL},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, 230, Y_ARM9 + 30, 100, 20, IDC_H1_ARM9_ROM},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, 230, Y_ARM9 + 60, 100, 20, IDC_H1_ARM9_RAM},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, 230, Y_ARM9 + 90, 100, 20, IDC_H1_ARM9_GUI},
+
+ {"BUTTON", "ARM7", BS_GROUPBOX, 4, Y_ARM7, 340, 120, NULL},
+ {"STATIC", "ARM7 boot code address", 0, 15, Y_ARM7+30, 300, 20, NULL},
+ {"STATIC", "ARM7 boot code RAM address", 0, 15, Y_ARM7+60, 300, 20, NULL},
+ {"STATIC", "ARM7 WiFi code address", 0, 15, Y_ARM7+90, 300, 20, NULL},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, 230, Y_ARM7 + 30, 100, 20, IDC_H1_ARM7_ROM},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, 230, Y_ARM7 + 60, 100, 20, IDC_H1_ARM7_RAM},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, 230, Y_ARM7 + 90, 100, 20, IDC_H1_ARM7_WIFI},
+
+ {"BUTTON", "FlashME: Header data", BS_GROUPBOX, X_SECOND_FW, Y_HEADER, 340, 120, NULL},
+ {"STATIC", "FlashME version", 0, X_SECOND_FW+11, Y_HEADER + 30, 300, 20, NULL},
+ {"STATIC", "Size of firmware", 0, X_SECOND_FW+11, Y_HEADER + 60, 300, 20, NULL},
+ {"STATIC", "CRC", 0, X_SECOND_FW+11, Y_HEADER + 90, 300, 20, NULL},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, X_SECOND_FW+230, Y_HEADER + 30, 100, 20, IDC_H2_VERSION},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, X_SECOND_FW+230, Y_HEADER + 60, 100, 20, IDC_H2_SIZE},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, X_SECOND_FW+230, Y_HEADER + 90, 100, 20, IDC_H2_CRC},
+
+ {"BUTTON", "FlashME: ARM9", BS_GROUPBOX, X_SECOND_FW, Y_ARM9, 340, 120, NULL},
+ {"STATIC", "ARM9 boot code address", 0, X_SECOND_FW+11, Y_ARM9+30, 300, 20, NULL},
+ {"STATIC", "ARM9 boot code RAM address", 0, X_SECOND_FW+11, Y_ARM9+60, 300, 20, NULL},
+ {"STATIC", "ARM9 GUI code address", 0, X_SECOND_FW+11, Y_ARM9+90, 300, 20, NULL},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, X_SECOND_FW+230, Y_ARM9 + 30, 100, 20, IDC_H2_ARM9_ROM},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, X_SECOND_FW+230, Y_ARM9 + 60, 100, 20, IDC_H2_ARM9_RAM},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, X_SECOND_FW+230, Y_ARM9 + 90, 100, 20, IDC_H2_ARM9_GUI},
+
+ {"BUTTON", "FlashME: ARM7", BS_GROUPBOX, X_SECOND_FW, Y_ARM7, 340, 120, NULL},
+ {"STATIC", "ARM7 boot code address", 0, X_SECOND_FW+11, Y_ARM7+30, 300, 20, NULL},
+ {"STATIC", "ARM7 boot code RAM address", 0, X_SECOND_FW+11, Y_ARM7+60, 300, 20, NULL},
+ {"STATIC", "ARM7 WiFi code address", 0, X_SECOND_FW+11, Y_ARM7+90, 300, 20, NULL},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, X_SECOND_FW+230, Y_ARM7 + 30, 100, 20, IDC_H2_ARM7_ROM},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, X_SECOND_FW+230, Y_ARM7 + 60, 100, 20, IDC_H2_ARM7_RAM},
+ {"EDIT", "", ES_READONLY | ES_RIGHT, X_SECOND_FW+230, Y_ARM7 + 90, 100, 20, IDC_H2_ARM7_WIFI},
+
+ {"BUTTON", "User", WS_TABSTOP | WS_DISABLED, 5, Y_BUTTONS, 100, 20, IDC_BUSER},
+ {"BUTTON", "WiFi", WS_TABSTOP | WS_DISABLED, 120, Y_BUTTONS, 100, 20, IDC_BWIFI},
+ {"BUTTON", "WiFi AP", WS_TABSTOP | WS_DISABLED, 235, Y_BUTTONS, 100, 20, IDC_BWIFIAP},
+ {"BUTTON", "Dump", WS_TABSTOP | WS_DISABLED, 350, Y_BUTTONS, 100, 20, NULL},
+ {"BUTTON", "Extract...", WS_TABSTOP | WS_DISABLED, 465, Y_BUTTONS, 100, 20, NULL},
+ {"BUTTON", "Exit", WS_TABSTOP, 620, Y_BUTTONS, 70, 20, IDC_BEXIT}
+};
+
+#define Y_BIRTH_LANG 105
+#define Y_FAV_COLOR 165
+#define Y_TCALIB 290
+#define Y_USR_MISC 385
+#define Y_USR_BUTTONS 570
+
+const TEMPLATE TuserDlg1[] = {
+ {"STATIC", "Nickname:", 0, 5, 5, 100, 17, NULL},
+ {"EDIT", "", WS_TABSTOP, 5, 25, 160, 17, IDC_NICKNAME},
+ {"STATIC", "Message:", 0, 5, 55, 100, 17, NULL},
+ {"EDIT", "", WS_TABSTOP, 5, 75, 400, 17, IDC_MESSAGE},
+
+ {"BUTTON", "Birthday", BS_GROUPBOX, 4, Y_BIRTH_LANG, 160, 55, NULL},
+ {"COMBOBOX", "Day", WS_TABSTOP | WS_VSCROLL | BS_GROUPBOX, 15, Y_BIRTH_LANG+20, 40, 120, IDC_BIRTH_DAY},
+ {"COMBOBOX", "Month", WS_TABSTOP | BS_GROUPBOX, 60, Y_BIRTH_LANG+20, 95, 120, IDC_BIRTH_MONTH},
+
+ {"BUTTON", "Language", BS_GROUPBOX, 170, Y_BIRTH_LANG, 110, 55, NULL},
+ {"COMBOBOX", "Language", WS_TABSTOP | BS_GROUPBOX, 180, Y_BIRTH_LANG+20, 90, 120, IDC_LANGUAGE},
+
+ {"BUTTON", "Alarm", BS_GROUPBOX, 285, Y_BIRTH_LANG, 120, 55, NULL},
+ {"BUTTON", "", WS_TABSTOP | BS_AUTOCHECKBOX, 295, Y_BIRTH_LANG+25, 13, 13, IDC_ALARM_ON},
+ {"COMBOBOX", "hour", WS_TABSTOP | WS_VSCROLL | BS_GROUPBOX, 315, Y_BIRTH_LANG+20, 40, 120, IDC_ALARM_HOUR},
+ {"COMBOBOX", "min", WS_TABSTOP | WS_VSCROLL | BS_GROUPBOX, 355, Y_BIRTH_LANG+20, 40, 120, IDC_ALARM_MIN},
+
+ {"BUTTON", "Favorite color", BS_GROUPBOX, 4, Y_FAV_COLOR, 400, 115, NULL}
+};
+
+
+const TEMPLATE TuserDlg2[] = {
+ {"BUTTON", "Touch-screen calibraion (HEX)",BS_GROUPBOX, 4, Y_TCALIB, 400, 95, NULL},
+
+ {"BUTTON", "ADC", BS_GROUPBOX, 14, Y_TCALIB+15, 190, 75, NULL},
+ {"STATIC", "X1", 0, 25, Y_TCALIB+35, 100, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT , 45, Y_TCALIB+35, 50, 17, IDC_TADC_X1},
+ {"STATIC", "Y1", 0, 25, Y_TCALIB+60, 40, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 45, Y_TCALIB+60, 50, 17, IDC_TADC_Y1},
+ {"STATIC", "X2", 0, 120, Y_TCALIB+35, 40, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 140, Y_TCALIB+35, 50, 17, IDC_TADC_X2},
+ {"STATIC", "Y2", 0, 120, Y_TCALIB+60, 40, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 140, Y_TCALIB+60, 50, 17, IDC_TADC_Y2},
+
+ {"BUTTON", "Screen", BS_GROUPBOX, 205, Y_TCALIB+15, 190, 75, NULL},
+ {"STATIC", "X1", 0, 215, Y_TCALIB+35, 40, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 235, Y_TCALIB+35, 50, 17, IDC_TSCR_X1},
+ {"STATIC", "Y1", 0, 215, Y_TCALIB+60, 40, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 235, Y_TCALIB+60, 50, 17, IDC_TSCR_Y1},
+ {"STATIC", "X2", 0, 310, Y_TCALIB+35, 40, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 330, Y_TCALIB+35, 50, 17, IDC_TSCR_X2},
+ {"STATIC", "Y2", 0, 310, Y_TCALIB+60, 40, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 330, Y_TCALIB+60, 50, 17, IDC_TSCR_Y2},
+
+ {"BUTTON", "Misc", BS_GROUPBOX, 4, Y_USR_MISC, 400, 180, NULL},
+ {"STATIC", "GBA mode screen selection",0, 15, Y_USR_MISC+20, 180, 17, NULL},
+ {"COMBOBOX","GBA", WS_TABSTOP | BS_GROUPBOX, 215, Y_USR_MISC+20, 180, 120, IDC_GBA_MODE_SCREENS},
+ {"STATIC", "Backlight level", 0, 15, Y_USR_MISC+50, 130, 17, NULL},
+ {"COMBOBOX","Backlight", WS_TABSTOP | BS_GROUPBOX, 215, Y_USR_MISC+50, 180, 120, IDC_BRIGHTLIGHT_LEVEL},
+ {"STATIC", "Boot menu", 0, 15, Y_USR_MISC+80, 100, 17, NULL},
+ {"COMBOBOX","boot", WS_TABSTOP | BS_GROUPBOX, 215, Y_USR_MISC+80, 180, 120, IDC_BOOTMENU},
+ {"STATIC", "RTC offset", 0, 15, Y_USR_MISC+120, 100, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 100, Y_USR_MISC+120, 90, 17, IDC_RTC_OFFSET},
+ {"STATIC", "First boot (year)", 0, 220, Y_USR_MISC+120, 120, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 345, Y_USR_MISC+120, 50, 17, IDC_YEAR_BOOT},
+ {"STATIC", "Update counter", ES_READONLY, 15, Y_USR_MISC+150, 120, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 140, Y_USR_MISC+150, 50, 17, IDC_UPDATE_COUNTER},
+ {"STATIC", "CRC16 (HEX)", ES_READONLY, 220, Y_USR_MISC+150, 90, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 345, Y_USR_MISC+150, 50, 17, IDC_USER_CRC16},
+ {"BUTTON", "Backup", WS_TABSTOP | WS_DISABLED, 15, Y_USR_BUTTONS, 70, 17, NULL},
+ {"BUTTON", "Restore", WS_TABSTOP | WS_DISABLED, 90, Y_USR_BUTTONS, 70, 17, NULL},
+ {"BUTTON", "Update", WS_TABSTOP | WS_DISABLED, 245, Y_USR_BUTTONS, 70, 17, NULL},
+ {"BUTTON", "Cancel", WS_TABSTOP | BS_DEFPUSHBUTTON, 320, Y_USR_BUTTONS, 70, 17, IDCANCEL}
+};
+
+#define Y_WIFI_GENERAL 5
+#define X_WIFI_CHANNELS 490
+#define Y_WIFI_CHANNELS 5
+#define Y_WIFI_REGS 55
+#define Y_WIFI_BB 155
+#define Y_WIFI_RF 275
+#define Y_WIFI_BUTTONS 575
+const TEMPLATE TwifiDlg1[] = {
+
+ {"BUTTON", "General", BS_GROUPBOX, 4, Y_WIFI_GENERAL, 485, 50, NULL},
+
+ {"STATIC", "CRC16", 0, 15, Y_WIFI_GENERAL+20, 45, 17, NULL},
+ {"EDIT", "", ES_RIGHT | ES_READONLY, 65, Y_WIFI_GENERAL+20, 55, 17, IDC_WIFI_CRC16},
+ {"STATIC", "Version", 0, 125, Y_WIFI_GENERAL+20, 55, 17, NULL},
+ {"EDIT", "", ES_RIGHT | ES_READONLY, 180, Y_WIFI_GENERAL+20, 25, 17, IDC_WIFI_VERSION},
+ {"STATIC", "MAC ID", 0, 215, Y_WIFI_GENERAL+20, 55, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 265, Y_WIFI_GENERAL+20, 110, 17, IDC_WIFI_MACID},
+ {"STATIC", "RF type", 0, 385, Y_WIFI_GENERAL+20, 55, 17, NULL},
+ {"EDIT", "", ES_READONLY| ES_RIGHT, 440, Y_WIFI_GENERAL+20, 35, 17, IDC_WIFI_RFTYPE},
+
+ {"BUTTON", "Enabled channels", BS_GROUPBOX, X_WIFI_CHANNELS + 4, Y_WIFI_CHANNELS, 230, 50, NULL},
+
+ {"BUTTON", "ch01", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 15, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_01},
+ {"BUTTON", "ch02", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 30, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_02},
+ {"BUTTON", "ch03", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 45, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_03},
+ {"BUTTON", "ch04", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 60, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_04},
+ {"BUTTON", "ch05", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 75, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_05},
+ {"BUTTON", "ch06", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 90, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_06},
+ {"BUTTON", "ch07", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 105, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_07},
+ {"BUTTON", "ch08", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 120, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_08},
+ {"BUTTON", "ch09", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 135, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_09},
+ {"BUTTON", "ch10", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 150, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_10},
+ {"BUTTON", "ch11", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 165, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_11},
+ {"BUTTON", "ch12", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 180, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_12},
+ {"BUTTON", "ch13", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 195, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_13},
+ {"BUTTON", "ch14", WS_TABSTOP | BS_AUTOCHECKBOX, X_WIFI_CHANNELS + 210, Y_WIFI_CHANNELS+25, 13, 13, IDC_WIFI_ECHANNEL_14},
+
+
+ {"BUTTON", "Initial values for... (HEX)", BS_GROUPBOX, 4, Y_WIFI_REGS, 720, 100, NULL},
+
+ {"STATIC", "0x4808146", 0, 15, Y_WIFI_REGS+15, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 15, Y_WIFI_REGS+30, 70, 17, IDC_WIFI_044},
+ {"STATIC", "0x4808148", 0, 105, Y_WIFI_REGS+15, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 105, Y_WIFI_REGS+30, 70, 17, IDC_WIFI_046},
+ {"STATIC", "0x480814A", 0, 195, Y_WIFI_REGS+15, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 195, Y_WIFI_REGS+30, 70, 17, IDC_WIFI_048},
+ {"STATIC", "0x480814C", 0, 285, Y_WIFI_REGS+15, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 285, Y_WIFI_REGS+30, 70, 17, IDC_WIFI_04A},
+ {"STATIC", "0x4808120", 0, 375, Y_WIFI_REGS+15, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 375, Y_WIFI_REGS+30, 70, 17, IDC_WIFI_04C},
+ {"STATIC", "0x4808122", 0, 465, Y_WIFI_REGS+15, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 465, Y_WIFI_REGS+30, 70, 17, IDC_WIFI_04E},
+ {"STATIC", "0x4808154", 0, 555, Y_WIFI_REGS+15, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 555, Y_WIFI_REGS+30, 70, 17, IDC_WIFI_050},
+ {"STATIC", "0x4808144", 0, 645, Y_WIFI_REGS+15, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 645, Y_WIFI_REGS+30, 70, 17, IDC_WIFI_052},
+ {"STATIC", "0x4808130", 0, 15, Y_WIFI_REGS+55, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 15, Y_WIFI_REGS+70, 70, 17, IDC_WIFI_054},
+ {"STATIC", "0x4808132", 0, 105, Y_WIFI_REGS+55, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 105, Y_WIFI_REGS+70, 70, 17, IDC_WIFI_056},
+ {"STATIC", "0x4808140", 0, 195, Y_WIFI_REGS+55, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 195, Y_WIFI_REGS+70, 70, 17, IDC_WIFI_058},
+ {"STATIC", "0x4808142", 0, 285, Y_WIFI_REGS+55, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 285, Y_WIFI_REGS+70, 70, 17, IDC_WIFI_05A},
+ {"STATIC", "0x4808038", 0, 375, Y_WIFI_REGS+55, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 375, Y_WIFI_REGS+70, 70, 17, IDC_WIFI_05C},
+ {"STATIC", "0x4808124", 0, 465, Y_WIFI_REGS+55, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 465, Y_WIFI_REGS+70, 70, 17, IDC_WIFI_05E},
+ {"STATIC", "0x4808128", 0, 555, Y_WIFI_REGS+55, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 555, Y_WIFI_REGS+70, 70, 17, IDC_WIFI_060},
+ {"STATIC", "0x4808150", 0, 645, Y_WIFI_REGS+55, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_RIGHT, 645, Y_WIFI_REGS+70, 70, 17, IDC_WIFI_062},
+
+ {"BUTTON", "Initial 8bit values for BB (HEX)", BS_GROUPBOX, 4, Y_WIFI_BB, 720, 120, NULL},
+ {"STATIC", " 0:", 0, 15, Y_WIFI_BB+15, 75, 17, NULL},
+ {"STATIC", "27:", 0, 15, Y_WIFI_BB+40, 75, 17, NULL},
+ {"STATIC", "53:", 0, 15, Y_WIFI_BB+65, 75, 17, NULL},
+ {"STATIC", "79:", 0, 15, Y_WIFI_BB+90, 75, 17, NULL}
+};
+
+const TEMPLATE TwifiDlg2[] = {
+ {"BUTTON", "Backup", WS_TABSTOP | WS_DISABLED, 15, Y_WIFI_BUTTONS, 70, 17, NULL},
+ {"BUTTON", "Restore", WS_TABSTOP | WS_DISABLED, 90, Y_WIFI_BUTTONS, 70, 17, NULL},
+ {"BUTTON", "Update", WS_TABSTOP | WS_DISABLED, 570, Y_WIFI_BUTTONS, 70, 17, NULL},
+ {"BUTTON", "Cancel", WS_TABSTOP | BS_DEFPUSHBUTTON, 645, Y_WIFI_BUTTONS, 70, 17, IDCANCEL}
+};
+
+#define Y_WIFI_AP_BUTTONS 670
+const TEMPLATE TwifiAPDlg1[] = {
+ {"BUTTON", "Connection Data", BS_GROUPBOX, 4, 15, 720, 215, NULL},
+ {"STATIC", "SSID", 0, 15, 35, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_LEFT, 50, 35, 150, 17, IDC_WIFI_AP_SSID},
+ {"STATIC", "SSID (WEP)", 0, 220, 35, 125, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_LEFT, 300, 35, 150, 17, IDC_WIFI_AP_SSID2},
+
+ {"STATIC", "User ID", 0, 470, 35, 95, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_CENTER, 525, 35, 185, 17, IDC_WIFI_AP_USER_ID},
+
+ {"BUTTON", "WEP", BS_GROUPBOX, 14, 55, 700, 80, NULL},
+
+ {"STATIC", "Key1", 0, 25, 75, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_LEFT, 65, 75, 150, 17, IDC_WIFI_AP_KEY1},
+ {"STATIC", "Key2", 0, 225, 75, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_LEFT, 265, 75, 150, 17, IDC_WIFI_AP_KEY2},
+ {"STATIC", "Key3", 0, 25, 105, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_LEFT, 65, 100, 150, 17, IDC_WIFI_AP_KEY3},
+ {"STATIC", "Key4", 0, 225, 105, 75, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_LEFT, 265, 100, 150, 17, IDC_WIFI_AP_KEY4},
+
+ {"STATIC", "WEP mode", 0, 445, 75, 75, 17, NULL},
+ {"COMBOBOX","WEPsize", WS_TABSTOP | WS_VSCROLL | BS_GROUPBOX, 535, 75, 80, 120, IDC_WIFI_AP_WEP_SIZE},
+ {"COMBOBOX","WEPmethod", WS_TABSTOP | WS_VSCROLL | BS_GROUPBOX, 620, 75, 80, 120, IDC_WIFI_AP_WEP_EMETHOD},
+
+ {"BUTTON", "IP", BS_GROUPBOX, 14, 140, 345, 80, NULL},
+
+ {"STATIC", "IP", 0, 25, 155, 95, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_CENTER, 165, 155, 150, 17, IDC_WIFI_AP_IP},
+ {"STATIC", "Subnet mask", 0, 25, 175, 95, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_CENTER, 165, 175, 150, 17, IDC_WIFI_AP_IPMASK},
+ {"STATIC", "Gateway", 0, 25, 195, 95, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_CENTER, 165, 195, 150, 17, IDC_WIFI_AP_GATEWAY},
+
+ {"BUTTON", "DNS", BS_GROUPBOX, 370, 140, 345, 60, NULL},
+
+ {"STATIC", "Primary", 0, 385, 155, 95, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_CENTER, 525, 155, 150, 17, IDC_WIFI_AP_DNS1},
+ {"STATIC", "Secondary", 0, 385, 175, 95, 17, NULL},
+ {"EDIT", "", WS_TABSTOP | ES_CENTER, 525, 175, 150, 17, IDC_WIFI_AP_DNS2},
+
+ {"STATIC", "Status", 0, 375, 205, 95, 17, NULL},
+ {"EDIT", "", ES_CENTER | ES_READONLY, 425, 205, 150, 17, IDC_WIFI_AP_STATUS},
+
+ {"STATIC", "CRC16", 0, 595, 205, 95, 17, NULL},
+ {"EDIT", "", ES_CENTER | ES_READONLY, 645, 205, 70, 17, IDC_WIFI_AP_CRC16},
+};
+
+const TEMPLATE TwifiAPDlg2[] = {
+
+ {"BUTTON", "Backup", WS_TABSTOP | WS_DISABLED, 15, Y_WIFI_AP_BUTTONS, 70, 20, NULL},
+ {"BUTTON", "Restore", WS_TABSTOP | WS_DISABLED, 90, Y_WIFI_AP_BUTTONS, 70, 20, NULL},
+ {"BUTTON", "Update", WS_TABSTOP | WS_DISABLED, 570, Y_WIFI_AP_BUTTONS, 70, 20, NULL},
+ {"BUTTON", "Cancel", WS_TABSTOP | BS_DEFPUSHBUTTON, 645, Y_WIFI_AP_BUTTONS, 70, 20, IDCANCEL}
+};
+#endif
\ No newline at end of file