diff --git a/src/MMU.cpp b/src/MMU.cpp index c4490f9aa..7f9e8f6f4 100644 --- a/src/MMU.cpp +++ b/src/MMU.cpp @@ -4205,7 +4205,7 @@ void FASTCALL MMU_write8(u32 proc, u32 adr, u8 val) } void mmu_select_savetype(int type, int *bmemtype, u32 *bmemsize) { - if (type<0 || type > 5) return; + if (type<0 || type > 6) return; *bmemtype=save_types[type][0]; *bmemsize=save_types[type][1]; mc_realloc(&MMU.bupmem, *bmemtype, *bmemsize); diff --git a/src/OGLRender.cpp b/src/OGLRender.cpp index e88e48336..da136c3b0 100644 --- a/src/OGLRender.cpp +++ b/src/OGLRender.cpp @@ -702,8 +702,6 @@ static void OGLRender() xglDepthMask(GL_TRUE); - glViewport(gfx3d.viewport.x,gfx3d.viewport.y,gfx3d.viewport.width,gfx3d.viewport.height); - float clearColor[4] = { ((float)(gfx3d.clearColor&0x1F))/31.0f, ((float)((gfx3d.clearColor>>5)&0x1F))/31.0f, @@ -723,7 +721,7 @@ static void OGLRender() //TODO - properly doublebuffer the display lists { - u32 lastTextureFormat = 0, lastTexturePalette = 0, lastPolyAttr = 0; + u32 lastTextureFormat = 0, lastTexturePalette = 0, lastPolyAttr = 0, lastViewport = 0xFFFFFFFF; // int lastProjIndex = -1; for(int i=0;icount;i++) { @@ -775,6 +773,15 @@ static void OGLRender() glVertex4fv(vert->coord); } glEnd();*/ + + if(lastViewport != poly->viewport) + { + VIEWPORT viewport; + viewport.decode(poly->viewport); + glViewport(viewport.x,viewport.y,viewport.width,viewport.height); + lastViewport = poly->viewport; + } + glBegin(GL_TRIANGLES); for(int j = 1; j < (type-1); j++) diff --git a/src/ROMReader.cpp b/src/ROMReader.cpp index d1b757503..96d4767ac 100644 --- a/src/ROMReader.cpp +++ b/src/ROMReader.cpp @@ -195,6 +195,8 @@ void * ZIPROMReaderInit(const char * filename) { char tmp1[1024]; char tmp2[1024]; + memset(tmp1,0,sizeof(tmp1)); + memset(tmp2,0,sizeof(tmp2)); strncpy(tmp1, filename, strlen(filename) - 4); sprintf(tmp2, "%s/%s", tmp1, dirent->d_name); return zzip_fopen(tmp2, "rb"); diff --git a/src/addons/compactFlash.cpp b/src/addons/compactFlash.cpp index 18d4a7a7b..9b2989a42 100644 --- a/src/addons/compactFlash.cpp +++ b/src/addons/compactFlash.cpp @@ -3,7 +3,7 @@ yopyop156.ifrance.com Copyright (C) 2006 Mic - Copyright (C) 2009 CrazyMax + Copyright (C) 2009 CrazyMax Copyright (C) 2009 DeSmuME team This file is part of DeSmuME diff --git a/src/gfx3d.cpp b/src/gfx3d.cpp index 7fd0521ec..cf3d3f383 100644 --- a/src/gfx3d.cpp +++ b/src/gfx3d.cpp @@ -137,6 +137,7 @@ static CACHE_ALIGN float trans[4] = {0.0, 0.0, 0.0, 0.0}; static int transind = 0; static CACHE_ALIGN float scale[4] = {0.0, 0.0, 0.0, 0.0}; static int scaleind = 0; +static u32 viewport; //various other registers static float _t=0, _s=0; @@ -295,17 +296,22 @@ void gfx3d_reset() _s=0; last_t = 0; last_s = 0; + viewport = 0xBFFF0000; GFX_FIFOclear(); } void gfx3d_glViewPort(u32 v) { - //zero: NHerve messed with this in mod2 and mod3, but im still not sure its perfect. need to research this. - gfx3d.viewport.x = (v&0xFF); - gfx3d.viewport.y = (v&0xFF); - gfx3d.viewport.width = (((v>>16)&0xFF)+1)-(v&0xFF); - gfx3d.viewport.height = ((v>>24)+1)-((v>>8)&0xFF); + viewport = v; +} + +void VIEWPORT::decode(u32 v) +{ + x = (v&0xFF); + y = std::min(191,(int)(((v>>8)&0xFF))); + width = (((v>>16)&0xFF)+1)-(v&0xFF); + height = ((v>>24)+1)-((v>>8)&0xFF); } @@ -731,6 +737,7 @@ static void SetVertex() poly.polyAttr = polyAttr; poly.texParam = textureFormat; poly.texPalette = texturePalette; + poly.viewport = viewport; polylist->count++; } } @@ -2205,10 +2212,7 @@ SFORMAT SF_GFX3D[]={ { "GSWB", 4, 1, &gfx3d.wbuffer}, { "GSSM", 4, 1, &gfx3d.sortmode}, { "GSAR", 1, 1, &gfx3d.alphaTestRef}, - { "GSVX", 4, 1, &gfx3d.viewport.x}, - { "GSVY", 4, 1, &gfx3d.viewport.y}, - { "GSVW", 4, 1, &gfx3d.viewport.width}, - { "GSVH", 4, 1, &gfx3d.viewport.height}, + { "GSVP", 4, 1, &viewport}, { "GSCC", 4, 1, &gfx3d.clearColor}, { "GSCD", 4, 1, &gfx3d.clearDepth}, { "GSFC", 4, 4, gfx3d.fogColor}, diff --git a/src/gfx3d.h b/src/gfx3d.h index 33f3f343b..4d9dbbecd 100644 --- a/src/gfx3d.h +++ b/src/gfx3d.h @@ -64,6 +64,7 @@ struct POLY { u32 polyAttr, texParam, texPalette; //the hardware rendering params // int projIndex; //the index into the projlist that this poly uses u32 pad; + u32 viewport; bool isTranslucent() { @@ -118,6 +119,12 @@ struct VERTLIST { int count; }; + +struct VIEWPORT { + int x, y, width, height; + void decode(u32 v); +}; + //used to communicate state to the renderer struct GFX3D { @@ -153,13 +160,6 @@ struct GFX3D u8 alphaTestRef; - struct VIEWPORT { - VIEWPORT() - : x(0), y(0), width(256), height(256) - {} - int x, y, width, height; - } viewport; - u32 clearDepth; u32 clearColor; float fogColor[4]; diff --git a/src/gtk/main.cpp b/src/gtk/main.cpp index fb8f7eaa8..57e1b3634 100644 --- a/src/gtk/main.cpp +++ b/src/gtk/main.cpp @@ -1003,7 +1003,7 @@ static gboolean Stylus_Release(GtkWidget *w, GdkEventButton *e, gpointer data) return TRUE; } -void loadgame(int num){ +static void loadgame(int num){ if (desmume_running()) { Pause(); @@ -1014,7 +1014,7 @@ void loadgame(int num){ loadstate_slot(num); } -void savegame(int num){ +static void savegame(int num){ if (desmume_running()) { Pause(); diff --git a/src/rasterize.cpp b/src/rasterize.cpp index 6fe6a81cb..ddfef3aea 100644 --- a/src/rasterize.cpp +++ b/src/rasterize.cpp @@ -760,12 +760,21 @@ static void drawscanline(edge_fx_fl *pLeft, edge_fx_fl *pRight) //CONSIDER: in case some other math is wrong (shouldve been clipped OK), we might go out of bounds here. //better check the Y value. - //but, we think the math is always right + if(pLeft->Y<0 || pLeft->Y>191) { + printf("rasterizer rendering at y=%d! oops!\n",pLeft->Y); + return; + } + + int x = XStart; while(width-- > 0) { + if(x<0 || x>255) { + printf("rasterizer rendering at x=%d! oops!\n",x); + } pixel(adr,color[0],color[1],color[2],u,v,1.0f/invw,z); adr++; + x++; invw += dinvw_dx; u += du_dx; @@ -1173,6 +1182,8 @@ static void SoftRastRender() clipPoly(&gfx3d.polylist->list[gfx3d.indexlist[i]]); } + //printf("%d %d %d %d\n",gfx3d.viewport.x,gfx3d.viewport.y,gfx3d.viewport.width,gfx3d.viewport.height); + //viewport transforms for(int i=0;iviewport); + vert.coord[0] *= viewport.width; + vert.coord[0] += viewport.x; + vert.coord[1] *= viewport.height; + vert.coord[1] += viewport.y; + if(vert.coord[1]>192||vert.color[1]<0) { + int zzz=9; + } vert.coord[1] = 192 - vert.coord[1]; } } diff --git a/src/wifi.cpp b/src/wifi.cpp index 5f120871f..0214262f4 100644 --- a/src/wifi.cpp +++ b/src/wifi.cpp @@ -1149,27 +1149,27 @@ int WIFI_SoftAP_Init(wifimac_t *wifi) SoftAP_CRC32Table[i] = reflect(SoftAP_CRC32Table[i], 32); } - if(pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) + if(PCAP::pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) { printf("SoftAP: PCAP error with pcap_findalldevs_ex(): %s\n", errbuf); return 0; } - wifi->SoftAP.bridge = pcap_open(WIFI_index_device(alldevs,CommonSettings.wifiBridgeAdapterNum)->name, PACKET_SIZE, 0, 1, NULL, errbuf); + wifi->SoftAP.bridge = PCAP::pcap_open(WIFI_index_device(alldevs,CommonSettings.wifiBridgeAdapterNum)->name, PACKET_SIZE, 0, 1, NULL, errbuf); if(wifi->SoftAP.bridge == NULL) { printf("SoftAP: PCAP error with pcap_open(): %s\n", errbuf); return 0; } - pcap_freealldevs(alldevs); + PCAP::pcap_freealldevs(alldevs); return 1; } void WIFI_SoftAP_Shutdown(wifimac_t *wifi) { - pcap_close(wifi->SoftAP.bridge); + PCAP::pcap_close(wifi->SoftAP.bridge); } void WIFI_SoftAP_RecvPacketFromDS(wifimac_t *wifi, u8 *packet, int len) @@ -1327,7 +1327,7 @@ void WIFI_SoftAP_RecvPacketFromDS(wifimac_t *wifi, u8 *packet, int len) /* Checksum */ /* TODO ? */ - pcap_sendpacket(wifi->SoftAP.bridge, ethernetframe, eflen); + PCAP::pcap_sendpacket(wifi->SoftAP.bridge, ethernetframe, eflen); delete ethernetframe; } diff --git a/src/wifi.h b/src/wifi.h index 0cd56ac03..9494dface 100644 --- a/src/wifi.h +++ b/src/wifi.h @@ -31,6 +31,7 @@ #include #define socket_t SOCKET #define sockaddr_t SOCKADDR + #include "windriver.h" #else #include #include @@ -51,8 +52,6 @@ #define PACKET_SIZE 65535 #define _INC_STDIO -#include -#include //uh? #define REG_WIFI_ID 0x000 #define REG_WIFI_MODE 0x004 diff --git a/src/windows/DeSmuME_2005.vcproj b/src/windows/DeSmuME_2005.vcproj index 8a42bda41..7f5ab95e1 100644 --- a/src/windows/DeSmuME_2005.vcproj +++ b/src/windows/DeSmuME_2005.vcproj @@ -140,8 +140,8 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" - AdditionalIncludeDirectories=".;..;.\zlib123;.\zziplib;" - PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX;NDEBUG" + AdditionalIncludeDirectories=".;..;.\zlib123;.\zziplib;.\winpcap" + PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX;NDEBUG;EXPERIMENTAL_WIFI" StringPooling="true" ExceptionHandling="1" BufferSecurityCheck="false" @@ -163,7 +163,7 @@ /> - - - + + + @@ -850,6 +842,14 @@ Name="MASM" /> + + + #include #include -#ifdef EXPERIMENTAL_WIFI -#include -#endif #include "CWindow.h" #include "../MMU.h" #include "../armcpu.h" @@ -1587,6 +1584,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, MainWindow->checkMenu(IDC_SAVETYPE4, MF_BYCOMMAND | MF_UNCHECKED); MainWindow->checkMenu(IDC_SAVETYPE5, MF_BYCOMMAND | MF_UNCHECKED); MainWindow->checkMenu(IDC_SAVETYPE6, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_SAVETYPE7, MF_BYCOMMAND | MF_UNCHECKED); MainWindow->Show(SW_NORMAL); run(); @@ -2148,9 +2146,20 @@ void RunConfig(CONFIGSCREEN which) break; case CONFIGSCREEN_EMULATION: DialogBox(hAppInst, MAKEINTRESOURCE(IDD_EMULATIONSETTINGS), hwnd, (DLGPROC)EmulationSettingsDlgProc); - break; + break; case CONFIGSCREEN_WIFI: - DialogBox(hAppInst,MAKEINTRESOURCE(IDD_WIFISETTINGS), hwnd, (DLGPROC) WifiSettingsDlgProc); +#ifdef EXPERIMENTAL_WIFI + if(wifiMac.netEnabled) + { + DialogBox(hAppInst,MAKEINTRESOURCE(IDD_WIFISETTINGS), hwnd, (DLGPROC) WifiSettingsDlgProc); + } + else + { +#endif + MessageBox(MainWindow->getHWnd(),"winpcap failed to initialize, and so wifi cannot be configured.","wifi system failure",0); +#ifdef EXPERIMENTAL_WIFI + } +#endif break; } @@ -3287,7 +3296,7 @@ LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM int i; HWND cur; - if(pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) + if(PCAP::pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) { EndDialog(hDlg, TRUE); return TRUE; diff --git a/src/windows/windriver.h b/src/windows/windriver.h index 025244b85..a8d99ee8f 100644 --- a/src/windows/windriver.h +++ b/src/windows/windriver.h @@ -5,6 +5,24 @@ #include "../common.h" #include "CWindow.h" +#ifdef EXPERIMENTAL_WIFI +#include +#include //uh? + +//because the pcap headers are written poorly, we need to declare these as cdecl +//this may cause the code to fail to compile on non-windows platforms; +//we may have to use a macro to call these functions which chooses whether to call them +//through the namespace +namespace PCAP { + extern "C" __declspec(dllexport) int __cdecl pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf); + extern "C" __declspec(dllexport) int __cdecl pcap_sendpacket(pcap_t *, const u_char *, int); + extern "C" __declspec(dllexport) void __cdecl pcap_close(pcap_t *); + extern "C" __declspec(dllexport) pcap_t* __cdecl pcap_open(const char *source, int snaplen, int flags, int read_timeout, struct pcap_rmtauth *auth, char *errbuf); + extern "C" __declspec(dllexport) void __cdecl pcap_freealldevs(pcap_if_t *); +} + +#endif + extern WINCLASS *MainWindow; class Lock {