Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Trying to move some stuff out into platform/* files.
  • Loading branch information
Jimmy Christensen committed Jan 16, 2012
1 parent 46b5965 commit c1f03e2
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 204 deletions.
51 changes: 24 additions & 27 deletions defs.h
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions input.c
Expand Up @@ -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"

Expand Down
150 changes: 17 additions & 133 deletions main.c
Expand Up @@ -20,7 +20,8 @@

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>


#include "defs.h"
#include "board.h"
#include "cursor.h"
#include "draw.h"
Expand All @@ -40,44 +41,9 @@
#include "userfiles.h"
#include "strings.h"

#if !defined (GP2X) && !defined (PSP) && !defined (WIZ)
#include <math.h>
#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 <windows.h>
#include <GL/glew.h>
#else
#ifdef HAVE_GLES
#include <GLES/gl.h>
#include "eglport.h"
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#endif
GLuint texture;
GLuint dlist;
#endif

#ifdef PC
#include "dumplevelimages.h"
#endif

int main(int argc, char *argv[])
{
Expand Down Expand Up @@ -120,6 +86,8 @@ int main(int argc, char *argv[])
//Read settings
initSettings();

//Set scaling
setting()->scaleFactor=1.0;

atexit(SDL_Quit);

Expand Down Expand Up @@ -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 )
Expand All @@ -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!");
Expand Down Expand Up @@ -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) );
Expand Down Expand Up @@ -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.
Expand Down
17 changes: 14 additions & 3 deletions 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
Expand Down Expand Up @@ -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
15 changes: 13 additions & 2 deletions 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 <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
Expand All @@ -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);
Expand Down
14 changes: 12 additions & 2 deletions 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
Expand Down

0 comments on commit c1f03e2

Please sign in to comment.