Commit 28f93b5d authored by alistert's avatar alistert

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

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