Commit 28f93b5d authored by alistert's avatar alistert

Applied zear's Dingoo A320 patch, with some minor modifications.

parent 14234cf3
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
#include "controls.h" #include "controls.h"
#include "loop.h" #include "loop.h"
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X)
#include "platforms/wiz.h" #include "platforms/wiz.h"
#endif #endif
Controls::Controls () { Controls::Controls () {
...@@ -57,17 +57,29 @@ Controls::Controls () { ...@@ -57,17 +57,29 @@ Controls::Controls () {
keys[C_YES].key = SDLK_y; keys[C_YES].key = SDLK_y;
keys[C_NO].key = SDLK_n; keys[C_NO].key = SDLK_n;
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X)
buttons[C_UP].button = GP2X_BUTTON_UP; buttons[C_UP].button = GP2X_BUTTON_UP;
buttons[C_DOWN].button = GP2X_BUTTON_DOWN; buttons[C_DOWN].button = GP2X_BUTTON_DOWN;
buttons[C_LEFT].button = GP2X_BUTTON_LEFT; buttons[C_LEFT].button = GP2X_BUTTON_LEFT;
buttons[C_RIGHT].button = GP2X_BUTTON_RIGHT; buttons[C_RIGHT].button = GP2X_BUTTON_RIGHT;
buttons[C_JUMP].button = GP2X_BUTTON_A; buttons[C_JUMP].button = GP2X_BUTTON_A;
buttons[C_FIRE].button = GP2X_BUTTON_X; buttons[C_FIRE].button = GP2X_BUTTON_X;
buttons[C_CHANGE].button = GP2X_BUTTON_Y; buttons[C_CHANGE].button = GP2X_BUTTON_Y;
buttons[C_ENTER].button = GP2X_BUTTON_R; buttons[C_ENTER].button = GP2X_BUTTON_R;
buttons[C_ESCAPE].button = GP2X_BUTTON_L; buttons[C_ESCAPE].button = GP2X_BUTTON_L;
buttons[C_STATS].button = GP2X_BUTTON_SELECT; buttons[C_STATS].button = GP2X_BUTTON_SELECT;
buttons[C_PAUSE].button = GP2X_BUTTON_START; buttons[C_PAUSE].button = GP2X_BUTTON_START;
#elif defined(DINGOO)
buttons[C_UP].button = SDLK_UP;
buttons[C_DOWN].button = SDLK_DOWN;
buttons[C_LEFT].button = SDLK_LEFT;
buttons[C_RIGHT].button = SDLK_RIGHT;
buttons[C_JUMP].button = SDLK_LCTRL;
buttons[C_FIRE].button = SDLK_LALT;
buttons[C_CHANGE].button = SDLK_LSHIFT;
buttons[C_ENTER].button = SDLK_RETURN;
buttons[C_ESCAPE].button = SDLK_ESCAPE;
buttons[C_STATS].button = SDLK_BACKSPACE;
buttons[C_PAUSE].button = SDLK_TAB;
#else #else
buttons[C_UP].button = -1; buttons[C_UP].button = -1;
buttons[C_DOWN].button = -1; buttons[C_DOWN].button = -1;
...@@ -290,7 +302,7 @@ bool Controls::getState (int control) { ...@@ -290,7 +302,7 @@ bool Controls::getState (int control) {
bool Controls::release (int control) { bool Controls::release (int control) {
if (!controls[control].state) return false; if (!controls[control].state) return false;
controls[control].time = globalTicks + T_KEY; controls[control].time = globalTicks + T_KEY;
......
...@@ -101,7 +101,7 @@ bool Video::create (int width, int height) { ...@@ -101,7 +101,7 @@ bool Video::create (int width, int height) {
if (canvas != screen) SDL_FreeSurface(canvas); if (canvas != screen) SDL_FreeSurface(canvas);
#endif #endif
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X) || defined(DINGOO)
screen = SDL_SetVideoMode(320, 240, 8, FULLSCREEN_FLAGS); screen = SDL_SetVideoMode(320, 240, 8, FULLSCREEN_FLAGS);
#else #else
#ifdef FULLSCREEN_ONLY #ifdef FULLSCREEN_ONLY
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X)
#define FULLSCREEN_FLAGS (SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE) #define FULLSCREEN_FLAGS (SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE)
#elif defined(DINGOO)
#define FULLSCREEN_FLAGS 0
#else #else
#define FULLSCREEN_FLAGS (SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE) #define FULLSCREEN_FLAGS (SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#endif #endif
......
...@@ -30,16 +30,16 @@ ...@@ -30,16 +30,16 @@
#include "file.h" #include "file.h"
#include "sound.h" #include "sound.h"
#include "util.h" #include "util.h"
#include <SDL/SDL_audio.h> #include <SDL/SDL_audio.h>
#ifdef USE_MODPLUG #ifdef USE_MODPLUG
#include <modplug.h> #include <modplug.h>
#endif #endif
#ifdef __SYMBIAN32__ #ifdef __SYMBIAN32__
#define SOUND_FREQ 22050 #define SOUND_FREQ 22050
#else #else
...@@ -51,16 +51,16 @@ ...@@ -51,16 +51,16 @@
#ifdef __SYMBIAN32__ #ifdef __SYMBIAN32__
#define MUSIC_RESAMPLEMODE MODPLUG_RESAMPLE_LINEAR #define MUSIC_RESAMPLEMODE MODPLUG_RESAMPLE_LINEAR
#define MUSIC_FLAGS MODPLUG_ENABLE_MEGABASS #define MUSIC_FLAGS MODPLUG_ENABLE_MEGABASS
#elif defined(WIZ) || defined(GP2X) #elif defined(WIZ) || defined(GP2X) || defined(DINGOO)
#define MUSIC_RESAMPLEMODE MODPLUG_RESAMPLE_LINEAR #define MUSIC_RESAMPLEMODE MODPLUG_RESAMPLE_LINEAR
#define MUSIC_FLAGS 0 #define MUSIC_FLAGS 0
#else #else
#define MUSIC_RESAMPLEMODE MODPLUG_RESAMPLE_FIR #define MUSIC_RESAMPLEMODE MODPLUG_RESAMPLE_FIR
#define MUSIC_FLAGS MODPLUG_ENABLE_NOISE_REDUCTION | MODPLUG_ENABLE_REVERB | MODPLUG_ENABLE_MEGABASS | MODPLUG_ENABLE_SURROUND #define MUSIC_FLAGS MODPLUG_ENABLE_NOISE_REDUCTION | MODPLUG_ENABLE_REVERB | MODPLUG_ENABLE_MEGABASS | MODPLUG_ENABLE_SURROUND
#endif #endif
ModPlugFile *musicFile; ModPlugFile *musicFile;
#endif #endif
SDL_AudioSpec audioSpec; SDL_AudioSpec audioSpec;
......
...@@ -40,13 +40,13 @@ ...@@ -40,13 +40,13 @@
#include "io/gfx/video.h" #include "io/gfx/video.h"
#include "io/network.h" #include "io/network.h"
#include "io/sound.h" #include "io/sound.h"
#include "jj2level/jj2level.h" #include "jj2level/jj2level.h"
#include "level/level.h" #include "level/level.h"
#include "menu/menu.h" #include "menu/menu.h"
#include "player/player.h" #include "player/player.h"
#include "scene/scene.h" #include "scene/scene.h"
#include "loop.h" #include "loop.h"
#include "util.h" #include "util.h"
#include <string.h> #include <string.h>
...@@ -55,24 +55,24 @@ ...@@ -55,24 +55,24 @@
#endif #endif
#ifdef __SYMBIAN32__ #ifdef __SYMBIAN32__
extern char KOpenJazzPath[256]; extern char KOpenJazzPath[256];
extern float sinf (float); extern float sinf (float);
#else #else
#include <math.h> #include <math.h>
#endif #endif
#define PI 3.141592f #define PI 3.141592f
int loadMain (int argc, char *argv[]) { int loadMain (int argc, char *argv[]) {
File* file; File* file;
unsigned char* pixels; unsigned char* pixels;
int count; int count;
int screenW, screenH; int screenW, screenH;
int scaleFactor; int scaleFactor;
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
bool fullscreen; bool fullscreen;
#endif #endif
...@@ -163,24 +163,24 @@ int loadMain (int argc, char *argv[]) { ...@@ -163,24 +163,24 @@ int loadMain (int argc, char *argv[]) {
// Default settings // Default settings
// Video settings // Video settings
screenW = SW; screenW = SW;
screenH = SH; screenH = SH;
#ifdef SCALE #ifdef SCALE
scaleFactor = 1; scaleFactor = 1;
#endif #endif
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
fullscreen = false; fullscreen = false;
#endif #endif
// Sound settings // Sound settings
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X)
volume = 40; volume = 40;
#endif #endif
soundsVolume = MAX_VOLUME >> 2; soundsVolume = MAX_VOLUME >> 2;
// Create the player's name // Create the player's name
characterName = createEditableString(CHAR_NAME); characterName = createEditableString(CHAR_NAME);
...@@ -218,9 +218,9 @@ int loadMain (int argc, char *argv[]) { ...@@ -218,9 +218,9 @@ int loadMain (int argc, char *argv[]) {
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
fullscreen = scaleFactor & 1; fullscreen = scaleFactor & 1;
#endif #endif
#ifdef SCALE #ifdef SCALE
scaleFactor >>= 1; scaleFactor >>= 1;
if (scaleFactor > 4) scaleFactor = 1; if (scaleFactor > 4) scaleFactor = 1;
#endif #endif
...@@ -246,10 +246,10 @@ int loadMain (int argc, char *argv[]) { ...@@ -246,10 +246,10 @@ int loadMain (int argc, char *argv[]) {
characterCols[2] = file->loadChar(); characterCols[2] = file->loadChar();
characterCols[3] = file->loadChar(); characterCols[3] = file->loadChar();
// Read the sound effect volume // Read the sound effect volume
soundsVolume = file->loadChar(); soundsVolume = file->loadChar();
if (soundsVolume > MAX_VOLUME) soundsVolume = MAX_VOLUME; if (soundsVolume > MAX_VOLUME) soundsVolume = MAX_VOLUME;
delete file; delete file;
} else { } else {
...@@ -278,18 +278,18 @@ int loadMain (int argc, char *argv[]) { ...@@ -278,18 +278,18 @@ int loadMain (int argc, char *argv[]) {
// Create the game's window // Create the game's window
canvas = NULL; canvas = NULL;
#ifdef SCALE #ifdef SCALE
video.setScaleFactor(scaleFactor); video.setScaleFactor(scaleFactor);
#endif #endif
#ifdef FULLSCREEN_ONLY #ifdef FULLSCREEN_ONLY
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
#else #else
if (fullscreen) video.flipFullscreen(); if (fullscreen) video.flipFullscreen();
#endif #endif
if (!video.create(screenW, screenH)) { if (!video.create(screenW, screenH)) {
logError("Could not set video mode", SDL_GetError()); logError("Could not set video mode", SDL_GetError());
...@@ -312,8 +312,8 @@ int loadMain (int argc, char *argv[]) { ...@@ -312,8 +312,8 @@ int loadMain (int argc, char *argv[]) {
// Load fonts // Load fonts
// Open the panel, which contains two fonts // Open the panel, which contains two fonts
try { try {
...@@ -332,9 +332,9 @@ int loadMain (int argc, char *argv[]) { ...@@ -332,9 +332,9 @@ int loadMain (int argc, char *argv[]) {
} }
pixels = file->loadRLE(46272); pixels = file->loadRLE(46272);
delete file; delete file;
panelBigFont = NULL; panelBigFont = NULL;
panelSmallFont = NULL; panelSmallFont = NULL;
...@@ -362,8 +362,8 @@ int loadMain (int argc, char *argv[]) { ...@@ -362,8 +362,8 @@ int loadMain (int argc, char *argv[]) {
if (fontiny) delete fontiny; if (fontiny) delete fontiny;
if (fontmn1) delete fontmn1; if (fontmn1) delete fontmn1;
delete[] pixels; delete[] pixels;
closeAudio(); closeAudio();
delete[] characterName; delete[] characterName;
...@@ -374,27 +374,27 @@ int loadMain (int argc, char *argv[]) { ...@@ -374,27 +374,27 @@ int loadMain (int argc, char *argv[]) {
} }
delete[] pixels; delete[] pixels;
// Establish arbitrary timing // Establish arbitrary timing
globalTicks = SDL_GetTicks() - 20; globalTicks = SDL_GetTicks() - 20;
// Fill trigonomatric function look-up tables // Fill trigonomatric function look-up tables
for (count = 0; count < 1024; count++) for (count = 0; count < 1024; count++)
sinLut[count] = fixed(sinf(2 * PI * float(count) / 1024.0f) * 1024.0f); sinLut[count] = fixed(sinf(2 * PI * float(count) / 1024.0f) * 1024.0f);
// Initiate networking // Initiate networking
net = new Network(); net = new Network();
baseLevel = NULL; baseLevel = NULL;
level = NULL; level = NULL;
jj2Level = NULL; jj2Level = NULL;
return E_NONE; return E_NONE;
} }
...@@ -407,7 +407,7 @@ void freeMain () { ...@@ -407,7 +407,7 @@ void freeMain () {
int scaleFactor; int scaleFactor;
delete net; delete net;
delete panelBigFont; delete panelBigFont;
delete panelSmallFont; delete panelSmallFont;
delete font2; delete font2;
...@@ -416,14 +416,14 @@ void freeMain () { ...@@ -416,14 +416,14 @@ void freeMain () {
delete fontmn1; delete fontmn1;
delete fontmn2; delete fontmn2;
#ifdef SCALE #ifdef SCALE
scaleFactor = video.getScaleFactor(); scaleFactor = video.getScaleFactor();
if (scaleFactor > 1) SDL_FreeSurface(canvas); if (scaleFactor > 1) SDL_FreeSurface(canvas);
#else #else
scaleFactor = 1; scaleFactor = 1;
#endif #endif
closeAudio(); closeAudio();
...@@ -446,7 +446,7 @@ void freeMain () { ...@@ -446,7 +446,7 @@ void freeMain () {
// Write video settings // Write video settings
file->storeShort(video.getWidth()); file->storeShort(video.getWidth());
file->storeShort(video.getHeight()); file->storeShort(video.getHeight());
scaleFactor <<= 1; scaleFactor <<= 1;
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
scaleFactor |= video.isFullscreen()? 1: 0; scaleFactor |= video.isFullscreen()? 1: 0;
...@@ -479,8 +479,8 @@ void freeMain () { ...@@ -479,8 +479,8 @@ void freeMain () {
file->storeChar(characterCols[3]); file->storeChar(characterCols[3]);
// Write the sound effect volume // Write the sound effect volume
file->storeChar(soundsVolume); file->storeChar(soundsVolume);
delete file; delete file;
} else { } else {
...@@ -494,114 +494,114 @@ void freeMain () { ...@@ -494,114 +494,114 @@ void freeMain () {
delete firstPath; delete firstPath;
SDL_Quit(); SDL_Quit();
return; return;
} }
int loop (LoopType type, PaletteEffect* paletteEffects) { int loop (LoopType type, PaletteEffect* paletteEffects) {
SDL_Event event; SDL_Event event;
int prevTicks, ret; int prevTicks, ret;
// Update tick count // Update tick count
prevTicks = globalTicks; prevTicks = globalTicks;
globalTicks = SDL_GetTicks(); globalTicks = SDL_GetTicks();
// Show what has been drawn // Show what has been drawn
video.flip(globalTicks - prevTicks, paletteEffects); video.flip(globalTicks - prevTicks, paletteEffects);
// Process system events // Process system events
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
switch (event.type) { switch (event.type) {
case SDL_KEYDOWN: case SDL_KEYDOWN:
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
// If Alt + Enter has been pressed, go to full screen // If Alt + Enter has been pressed, go to full screen
if ((event.key.keysym.sym == SDLK_RETURN) && if ((event.key.keysym.sym == SDLK_RETURN) &&
(event.key.keysym.mod & KMOD_ALT)) { (event.key.keysym.mod & KMOD_ALT)) {
video.flipFullscreen(); video.flipFullscreen();
} }
#endif #endif
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X) || defined(DINGOO)
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
#endif #endif
// Break statement intentionally omitted // Break statement intentionally omitted
case SDL_KEYUP: case SDL_KEYUP:
case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP: case SDL_JOYBUTTONUP:
case SDL_JOYAXISMOTION: case SDL_JOYAXISMOTION:
ret = controls.update(&event, type); ret = controls.update(&event, type);
if (ret != E_NONE) return ret; if (ret != E_NONE) return ret;
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X)
if (event.jbutton.button == GP2X_BUTTON_VOLUP ) { if (event.jbutton.button == GP2X_BUTTON_VOLUP ) {
if( event.type == SDL_JOYBUTTONDOWN ) if( event.type == SDL_JOYBUTTONDOWN )
volume_direction = VOLUME_UP; volume_direction = VOLUME_UP;
else else
volume_direction = VOLUME_NOCHG; volume_direction = VOLUME_NOCHG;
} }
if (event.jbutton.button == GP2X_BUTTON_VOLDOWN ) { if (event.jbutton.button == GP2X_BUTTON_VOLDOWN ) {
if( event.type == SDL_JOYBUTTONDOWN ) if( event.type == SDL_JOYBUTTONDOWN )
volume_direction = VOLUME_DOWN; volume_direction = VOLUME_DOWN;
else else
volume_direction = VOLUME_NOCHG; volume_direction = VOLUME_NOCHG;
} }
#endif #endif
break; break;
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
case SDL_VIDEORESIZE: case SDL_VIDEORESIZE:
video.create(event.resize.w, event.resize.h); video.create(event.resize.w, event.resize.h);
break; break;
case SDL_VIDEOEXPOSE: case SDL_VIDEOEXPOSE:
video.expose(); video.expose();
break; break;
#endif #endif
case SDL_QUIT: case SDL_QUIT:
return E_QUIT; return E_QUIT;
} }
} }
controls.loop(); controls.loop();
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X)
WIZ_AdjustVolume( volume_direction ); WIZ_AdjustVolume( volume_direction );
#endif #endif
return E_NONE; return E_NONE;
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
MainMenu *mainMenu = NULL; MainMenu *mainMenu = NULL;
Scene *scene = NULL; Scene *scene = NULL;
// Initialise SDL // Initialise SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_TIMER) < 0) { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_TIMER) < 0) {
...@@ -639,17 +639,17 @@ int main(int argc, char *argv[]) { ...@@ -639,17 +639,17 @@ int main(int argc, char *argv[]) {
} }
if (scene->play() == E_QUIT) { if (scene->play() == E_QUIT) {
delete scene; delete scene;
freeMain(); freeMain();
return 0; return 0;
} }
delete scene; delete scene;
// Load the menu // Load the menu
try { try {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "io/gfx/video.h" #include "io/gfx/video.h"
#include "io/sound.h" #include "io/sound.h"
#include "player/player.h" #include "player/player.h"
#include "loop.h" #include "loop.h"
int SetupMenu::setupKeyboard () { int SetupMenu::setupKeyboard () {
...@@ -263,10 +263,10 @@ int SetupMenu::setupResolution () { ...@@ -263,10 +263,10 @@ int SetupMenu::setupResolution () {
SDL_Rect **resolutions; SDL_Rect **resolutions;
int count, screenW, screenH, maxW, maxH; int count, screenW, screenH, maxW, maxH;
bool dimension; bool dimension;
screenW = video.getWidth(); screenW = video.getWidth();
screenH = video.getHeight(); screenH = video.getHeight();
dimension = false; dimension = false;
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
...@@ -277,7 +277,7 @@ int SetupMenu::setupResolution () { ...@@ -277,7 +277,7 @@ int SetupMenu::setupResolution () {
resolutions = SDL_ListModes(NULL, FULLSCREEN_FLAGS); resolutions = SDL_ListModes(NULL, FULLSCREEN_FLAGS);
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X) || defined(DINGOO)
maxW = 320; maxW = 320;
maxH = 240; maxH = 240;
#else #else
...@@ -287,7 +287,7 @@ int SetupMenu::setupResolution () { ...@@ -287,7 +287,7 @@ int SetupMenu::setupResolution () {
maxH = 1200; maxH = 1200;
} else { } else {
maxW = SW; maxW = SW;
maxH = SH; maxH = SH;
...@@ -408,9 +408,9 @@ int SetupMenu::setupResolution () { ...@@ -408,9 +408,9 @@ int SetupMenu::setupResolution () {
int SetupMenu::setupScaling () { int SetupMenu::setupScaling () {
int scaleFactor; int scaleFactor;
scaleFactor = video.getScaleFactor(); scaleFactor = video.getScaleFactor();
if ( scaleFactor < MIN_SCALE || scaleFactor > MAX_SCALE ) if ( scaleFactor < MIN_SCALE || scaleFactor > MAX_SCALE )
scaleFactor = 1; scaleFactor = 1;
...@@ -453,7 +453,7 @@ int SetupMenu::setupScaling () { ...@@ -453,7 +453,7 @@ int SetupMenu::setupScaling () {
// Check for a scaling change // Check for a scaling change
if (scaleFactor != video.getScaleFactor()) { if (scaleFactor != video.getScaleFactor()) {
playSound(S_ORB); playSound(S_ORB);
video.setScaleFactor(scaleFactor); video.setScaleFactor(scaleFactor);
} }
...@@ -570,8 +570,13 @@ int SetupMenu::setup () { ...@@ -570,8 +570,13 @@ int SetupMenu::setup () {
case 2: case 2:
#if !defined(DINGOO)
setupJoystick(); setupJoystick();
#else
message("FEATURE NOT AVAILABLE");
#endif
break; break;
case 3: case 3:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment