// This file is distributed under a BSD license. See LICENSE.txt for details. #include "start_mobile.hpp" #define UNICODE 1 #include #include #if sPLATFORM==sPLAT_PDA #include #pragma comment(lib,"gx.lib") #else #include #include #pragma comment(lib,"winmm.lib") #endif /****************************************************************************/ /****************************************************************************/ static sU16 *Buffer; static sInt ScreenX,ScreenY,ScreenBPR; static sInt ProgressMax,ProgressCount,ProgressLastPixel,ProgressLastTime; static HWND Window; static sInt Initialized = 0; static sInt PrintLine; static sDInt MemoryUsedCount; static sInt WKeepRunning = 0; static sChar CmdLine[2048]; #define MAX_CMDPARA 16 static const sChar *CmdPara[MAX_CMDPARA]; HDC hdc; /****************************************************************************/ #if sPLATFORM!=sPLAT_PDA #undef new void * __cdecl operator new(unsigned int size) { void *p; #if !sRELEASE p = _malloc_dbg(size,_NORMAL_BLOCK,"unknown",1); #else p = malloc(size); #endif if(p==0) { sTerminate(L"ran out of virtual memory...\n"); } else { MemoryUsedCount+=_msize(p); // sDPrintF(L"%08x %2d.%03dMB ( +%08x = %08x )\n",MemoryUsedCount,MemoryUsedCount/1024/1024,MemoryUsedCount/1024%1024,_msize(p),size); } return p; } void * __cdecl operator new(unsigned int size,const char *file,int line) { void *p; #if !sRELEASE p = _malloc_dbg(size,_NORMAL_BLOCK,file,line); #else p = malloc(size); #endif if(p==0) { sTerminate(L"ran out of virtual memory...\n"); } else { MemoryUsedCount+=_msize(p); // sDPrintF(L"%08x %2d.%03dMB ( +%08x = %08x )\n",MemoryUsedCount,MemoryUsedCount/1024/1024,MemoryUsedCount/1024%1024,_msize(p),size); } return p; } void __cdecl operator delete(void *p) { if(p) { MemoryUsedCount-=_msize(p); // sDPrintF(L"%08x %2d.%03dMB ( -%08x )\n",MemoryUsedCount,MemoryUsedCount/1024/1024,MemoryUsedCount/1024%1024,_msize(p)); free(p); } } #define new new(__FILE__,__LINE__) #endif #if sPLATFORM==sPLAT_PDA static GXDisplayProperties Display; #else #define SCREENX 480 #define SCREENY 640 static sU16 ScreenBuffer[SCREENX*SCREENY]; static sU32 ScreenBuffer32[SCREENX*SCREENY]; void *GXBeginDraw() { ScreenX = SCREENX; ScreenY = SCREENY; ScreenBPR = SCREENX; return ScreenBuffer; } void GXEndDraw() { HDC dc = GetDC(Window); sU32 col; BITMAPINFO bmi; for(sInt i=0;iProgressMax) ProgressCount = 0; x1 = 12+ProgressCount*w/ProgressMax; // draw bar if it has changed if(x0!=x1) { #if sPLATFORM!=sPLAT_PDA sInt time = sGetTime(); if(time < ProgressLastTime+500) return; ProgressLastTime = time; #endif Buffer=(sU16 *)GXBeginDraw(); if(Buffer) { sDrawRect(x0,ScreenY/2-8,x1,ScreenY/2+8,col1); GXEndDraw(); } } } void sProgressEnd() { sDPrintF(L"progres: %d\n",ProgressCount); // Sleep(500); } sInt sProgressGet() { return ProgressCount; } /****************************************************************************/ void sExit() { PostMessage(Window,WM_CLOSE,0,0); } void sTerminate(sChar *message) { #if sPLATFORM==sPLAT_PDA GXCloseDisplay(); GXCloseInput(); #else _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)&~(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF)); #endif MessageBox(Window,message,L"werkkzeug mobile",MB_OK); TerminateProcess(0,0); } void sOutputDebugString(sChar *buffer) { OutputDebugString(buffer); } sInt sGetTime() { #if sPLATFORM==sPLAT_PDA return GetTickCount(); #else return timeGetTime(); #endif } /* void sFatal(sChar *message) { #if sPLATFORM==sPLAT_PDA GXCloseDisplay(); GXCloseInput(); #endif MessageBox(Window,message,L"werkkzeug mobile",MB_OK); TerminateProcess(0,0); } */ const sChar *sGetShellParameter(sInt i) { sVERIFY(i>=0 && i