diff --git a/defs.h b/defs.h index 8f377a4..2bc536c 100644 --- a/defs.h +++ b/defs.h @@ -48,15 +48,25 @@ #define DIRUP -1 #define DIRDOWN 1 - -//Screen sizes -#ifdef PSP - #define SCREENW 480 - #define SCREENH 272 -#else - #define SCREENW 320 - #define SCREENH 240 -#endif + +//Data directory +#ifndef DATADIR + #define DATADIR "./" +#endif + +//Get defines from platform .h file +#if defined(PANDORA) //Pandora + #include "platform/pandora.h" +#elif defined(PSP) //PSP + #include "platform/pspspec.h" +#elif defined(GP2X) //GP2X + #include "platform/gp2x.h" +#elif defined(WIZ) //GP2X Wiz + #include "platform/wiz.h" +#else //Linux, Windows, Default + #include "platform/pc.h" +#endif + //Half the resolution is practical for centering content #define HSCREENW SCREENW/2 @@ -90,26 +100,13 @@ //To avoid crashing a new version trying to read old highscore files (hmm, as if it's ever gonna happen) #define STATS_FILE_FORMAT_VERSION 1 - -//Url where stats are -#define STATS_SERVER_URL "http://dusted.dk/wizznic" -#ifdef WIN32 - #define CURLBIN "curl\\curl.exe --user-agent wizznicWindows --connect-timeout 10 --fail --silent --url "STATS_SERVER_URL"/commit.php --data-ascii " -#else - #define CURLBIN "wget "STATS_SERVER_URL"/commit.php -O - -q --user-agent=wizznicLinux --timeout=10 --tries=1 --post-data=" -#endif -#ifndef PLATFORM - #if defined(WIN32) - #define PLATFORM "Windows" - #endif - - #if defined(linux) || defined(__linux) - #define PLATFORM "Linux" - #endif +//Url where stats are +#define STATS_SERVER_URL "http://dusted.dk/wizznic" - #ifndef PLATFORM - #define PLATFORM "Unknown" +#ifndef STR_PLATFORM + #ifndef STR_PLATFORM + #define STR_PLATFORM "Unknown" #endif #endif diff --git a/input.c b/input.c index 5f07573..5117804 100644 --- a/input.c +++ b/input.c @@ -18,13 +18,13 @@ #include "input.h" #include "ticks.h" -#if defined(PSP) - #include "platform/pspspec.h" -#elif defined(GP2X) - #include "platform/gp2x.h" -#elif defined(WIZ) - #include "platform/wiz.h" -#endif +//#if defined(PSP) +// #include "platform/pspspec.h" +//#elif defined(GP2X) +// #include "platform/gp2x.h" +//#elif defined(WIZ) +// #include "platform/wiz.h" +//#endif #include "settings.h" diff --git a/main.c b/main.c index 4ad25f1..7b40a45 100644 --- a/main.c +++ b/main.c @@ -20,7 +20,8 @@ #include #include - + +#include "defs.h" #include "board.h" #include "cursor.h" #include "draw.h" @@ -40,44 +41,9 @@ #include "userfiles.h" #include "strings.h" -#if !defined (GP2X) && !defined (PSP) && !defined (WIZ) - #include - #include "dumplevelimages.h" -#endif - -#ifndef DATADIR - #define DATADIR "." -#endif - -#ifdef PSP - #define MAJOR_VERSION 1 - #define MINOR_VERSION 0 - PSP_MODULE_INFO("Wizznic", 0, MAJOR_VERSION, MINOR_VERSION); - PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU); - PSP_HEAP_SIZE_KB(-256); - #define printf pspDebugScreenPrintf -#endif - -#if defined(WITH_OPENGL) - #ifdef WIN32 - #define GLEW_STATIC - #define WINDOWS_LEAN_AND_MEAN - #define NOMINMAX - #include - #include - #else - #ifdef HAVE_GLES - #include - #include "eglport.h" - #else - #include - #include - #endif - #endif - GLuint texture; - GLuint dlist; -#endif - +#ifdef PC + #include "dumplevelimages.h" +#endif int main(int argc, char *argv[]) { @@ -120,6 +86,8 @@ int main(int argc, char *argv[]) //Read settings initSettings(); + //Set scaling + setting()->scaleFactor=1.0; atexit(SDL_Quit); @@ -178,89 +146,13 @@ int main(int argc, char *argv[]) if(doScale) { - //OpenGL scaling + //Hardware accelerated scaling if( doScale == -1 ) - { - #if defined(WITH_OPENGL) - const SDL_VideoInfo* vidinfo = SDL_GetVideoInfo(); - int w=setting()->glWidth,h=setting()->glHeight; - if(sdlFullScrFlag==SDL_FULLSCREEN) - { - w = vidinfo->current_w; - h = vidinfo->current_h; - } else { - //Find largest resolution within screen - if(w==-1||h==-1) - { - int factor=(int)floor( (float)(vidinfo->current_h-1)/240.0 ); - w=320*factor; - h=240*factor; - } - } - #ifdef HAVE_GLES - scale = SDL_SetVideoMode(w,h,32, SDL_SWSURFACE | sdlVideoModeFlags | sdlFullScrFlag); - #else - scale = SDL_SetVideoMode(w,h,32, SDL_OPENGL | sdlVideoModeFlags | sdlFullScrFlag); - #endif - screen = SDL_CreateRGBSurface(SDL_SWSURFACE, 320,240,24, 0x00ff0000,0x0000ff00,0x000000ff,0xff000000); - - int vW = (GLint)h*(320.0f/240.0f); - - glViewport(w/2-vW/2, 0, vW, (GLint)h); - - glClearColor(1,0,0,1); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho( 0, SCREENW, SCREENH, 0, 0,1); - glColor4f(1,1,1,1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glDisable(GL_DEPTH_TEST); - glDisable( GL_CULL_FACE ); - glDisable(GL_LIGHTING); - - glEnable(GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glColor4f(1,1,1,1); - - - glEnable(GL_TEXTURE_2D); - glGenTextures( 1, &texture ); - glBindTexture( GL_TEXTURE_2D, texture ); - - if( setting()->glFilter ) - { - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - } else { - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - } - - #ifdef HAVE_GLES - // to do - #else - dlist = glGenLists (1); - glNewList(dlist, GL_COMPILE); - glBegin( GL_QUADS ); - glTexCoord2f(0,0); - glVertex2i(0,0); - glTexCoord2f(1,0); - glVertex2i(320,0); - glTexCoord2f(1,1); - glVertex2i(320,240); - glTexCoord2f(0,1); - glVertex2i(0,240); - glEnd(); - glEndList(); - #endif - - + { + #ifdef HAVE_ACCELERATION + screen = platformInitAccel(sdlVideoModeFlags); #else - printf("\nError:\nNo OpenGL support, recompile with -dWITH_GL or change scale setting.\nExiting...\n"); + printf("\nError:\nNo Accelerated scaling support.\nDisable hwscale in settings. Exiting...\n"); return(-1); #endif } else if( doScale > 0 ) @@ -275,9 +167,8 @@ int main(int argc, char *argv[]) screen=scale; } - //Set scaling - setting()->scaleFactor= (float)scale->h/240.0; printf("Scaling factor: %f\n", setting()->scaleFactor); + //Set window title SDL_WM_SetCaption("Wizznic!", "Wizznic!"); @@ -353,7 +244,7 @@ int main(int argc, char *argv[]) //Set Pack packSetByPath( setting()->packDir ); - #if !defined (GP2X) && !defined(PSP) && !defined (WIZ) + #if defined(PC) if( (setting()->uploadStats) && !(setting()->firstRun) ) { statsUpload(0,0,0,0,0,"check",1, &(setting()->session) ); @@ -409,17 +300,10 @@ int main(int argc, char *argv[]) #else //OpenGL scaling, scale is the screen and not used. - #if defined(WITH_OPENGL) + #if defined(HAVE_ACCELERATION) if( doScale==-1 ) - { - #ifdef HAVE_GLES - glTexImage2D( GL_TEXTURE_2D, 0, screen->format->BytesPerPixel, screen->w, screen->h, 0, GL_RGB, GL_UNSIGNED_BYTE, screen->pixels ); - glCallList(dlist); - #else - glTexImage2D( GL_TEXTURE_2D, 0, screen->format->BytesPerPixel, screen->w, screen->h, 0, GL_BGR, GL_UNSIGNED_BYTE, screen->pixels ); - glCallList(dlist); - SDL_GL_SwapBuffers(); - #endif + { + platformDrawScaled(screen); } else #endif //The pixel plotting seems to run faster than code usind SDL_Rect, so we still use that for 2x zoom. diff --git a/platform/gp2x.h b/platform/gp2x.h index 305e005..4e5dc9a 100644 --- a/platform/gp2x.h +++ b/platform/gp2x.h @@ -1,8 +1,20 @@ -/* This file was copied with little or no modification from the WizPort of OpenJazz */ - #ifndef _GP2X_H #define _GP2X_H +/* This file was copied with little or no modification from the WizPort of OpenJazz */ + + +//Video +#define SCREENW 320 +#define SCREENH 240 + +//Sound +#define SOUND_RATE 22050 +#define SOUND_FORMAT AUDIO_S16 +#define SOUND_BUFFERS 256 +#define SOUND_MIX_CHANNELS 8 + + #define VOLUME_MIN 0 #define VOLUME_MAX 100 #define VOLUME_CHANGE_RATE 4 @@ -35,6 +47,5 @@ void WIZ_ShowVolume(SDL_Surface* screen); void WIZ_SetVolume( int volumePercent ); int WIZ_GetVolume(); void WIZ_AdjustVolume( int direction ); -//int WIZ_SetClock(int mhz); #endif diff --git a/platform/pspspec.h b/platform/pspspec.h index 6c595fc..42af5b5 100644 --- a/platform/pspspec.h +++ b/platform/pspspec.h @@ -1,8 +1,11 @@ -// Sony PSP specific values and combatibility functions - #ifndef PSPSPEC_H #define PSPSPEC_H +// Sony PSP specific values and combatibility functions + +#define SCREENW 480 +#define SCREENH 272 + #include #include #include @@ -26,6 +29,14 @@ #define PSP_BUTTON_HOME 12 #define PSP_BUTTON_HOLD 13 +//DusteD: Might not work +#define MAJOR_VERSION 1 +#define MINOR_VERSION 0 +PSP_MODULE_INFO("Wizznic", 0, MAJOR_VERSION, MINOR_VERSION); +PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU); +PSP_HEAP_SIZE_KB(-256); +#define printf pspDebugScreenPrintf + int SetupCallbacks(void); int exit_callback(int arg1, int arg2, void *common); int CallbackThread(SceSize args, void *argp); diff --git a/platform/wiz.h b/platform/wiz.h index 5e6a1f0..2409153 100644 --- a/platform/wiz.h +++ b/platform/wiz.h @@ -1,8 +1,18 @@ -/* This file was copied with little or no modification from the WizPort of OpenJazz */ - #ifndef _WIZ_H #define _WIZ_H +/* This file was copied with little or no modification from the WizPort of OpenJazz */ + +//Video +#define SCREENW 320 +#define SCREENH 240 + +//Audio +#define SOUND_RATE 22050 +#define SOUND_FORMAT AUDIO_S16 +#define SOUND_BUFFERS 256 +#define SOUND_MIX_CHANNELS 16 + #define VOLUME_MIN 0 #define VOLUME_MAX 100 #define VOLUME_CHANGE_RATE 4 diff --git a/sound.c b/sound.c index 7232024..e617144 100644 --- a/sound.c +++ b/sound.c @@ -28,16 +28,6 @@ #include "defs.h" -#ifdef WIZ -#include "platform/wiz.h" -#elif defined(GP2X) - #include "platform/gp2x.h" -#endif - -#ifndef DATADIR - #define DATADIR "" -#endif - #define MUSIC_FADETIME 500 @@ -53,24 +43,18 @@ static int lastPlayed[NUMSAMPLES]; int initSound() { - //TODO: Move rates/buffers 'n stuff to be defined in platform, add "misc" or "pc" platform there too. - #ifdef GP2X - int audio_rate = 22050; - Uint16 audio_format = AUDIO_S16; //16 bit stereo - int audio_channels = 2; - int audio_buffers = 256; - #else - int audio_rate = 44100; - Uint16 audio_format = AUDIO_S16; //16 bit stereo + int audio_rate = SOUND_RATE; + Uint16 audio_format = SOUND_FORMAT; int audio_channels = 2; - int audio_buffers = 4096; - #endif + int audio_buffers = SOUND_BUFFERS; + if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) { printf("Couldn't open audio: '%s'\n", Mix_GetError()); return(0); } - Mix_AllocateChannels(16); + + Mix_AllocateChannels(SOUND_MIX_CHANNELS); //Set arrays of pointers to null. memset(samples, 0, sizeof(Mix_Chunk*)*NUMSAMPLES); diff --git a/stats.c b/stats.c index b444912..a261ec6 100644 --- a/stats.c +++ b/stats.c @@ -391,13 +391,13 @@ int upStatsThread(void * d) void statsUpload(int level, int time, int moves, int combos, int score, const char* action, int ignoreIfOnline, int* retVal) { - #if !defined (GP2X) || !defined (WIZ) + #if defined (UPLOAD_PROGRAM) if( (setting()->online || ignoreIfOnline) ) { printf("StatsUpload with session = %i\n",setting()->session ); int b = sprintf( curlbuf, "%s\"version=%s&pack=%s&level=%i&time=%i&moves=%i&combos=%i&score=%i&action=%s&session=%i&platform=%s\"",\ - CURLBIN, VERSION_STRING, packState()->cp->path,\ - level,time,moves,combos,score,action, setting()->session, PLATFORM ); + UPLOAD_PROGRAM, VERSION_STRING, packState()->cp->path,\ + level,time,moves,combos,score,action, setting()->session, STR_PLATFORM ); if(b > 0 && b < 2048) { thrDat_t* thrData=malloc(sizeof(thrDat_t)); diff --git a/text.c b/text.c index a8835bc..67bf3c0 100644 --- a/text.c +++ b/text.c @@ -16,15 +16,12 @@ ************************************************************************/ #include +#include "defs.h" #include "text.h" #include "sprite.h" #include "pack.h" -#ifndef DATADIR - #define DATADIR "" -#endif - static SDL_Surface* txtSurf[NUMFONTS]; static spriteType* txtSprites[NUMFONTS][91]; static int txtSize[NUMFONTS][2]; diff --git a/wizznic.cbp b/wizznic.cbp index 9021f49..52d371d 100644 --- a/wizznic.cbp +++ b/wizznic.cbp @@ -37,10 +37,11 @@ + + - @@ -129,6 +130,28 @@