Commit 669fabbe authored by alistert's avatar alistert

Added Scott's GP2X Wiz support.

parent 53646b83
###############################################################################
# Makefile for a GP32 application.
###############################################################################
PREFIX =/mythtv/media/devel/toolchains/openwiz/arm-openwiz-linux-gnu
TARGET =arm-openwiz-linux-gnu
# Change the line below to the name of your program
PROGRAM = openjazz.gpe
# If you have any directories with include files, add them here with -I on
# the front of each
INCLUDES = -I. -I$(PREFIX)/include -I$(PREFIX)/include/modplug
# list all .c files here
CFILES = \
main.cpp \
planet.cpp \
scene.cpp \
util.cpp \
menu/gamemenu.cpp \
menu/menuutil.cpp \
menu/menu.cpp \
menu/setupmenu.cpp \
menu/mainmenu.cpp \
bonus/bonus.cpp \
io/file.cpp \
io/controls.cpp \
io/gfx/paletteeffects.cpp \
io/gfx/anim.cpp \
io/gfx/font.cpp \
io/gfx/sprite.cpp \
io/gfx/video.cpp \
io/sound.cpp \
io/network.cpp \
level/event/event.cpp \
level/event/eventframe.cpp \
level/levelframe.cpp \
level/bullet.cpp \
level/level.cpp \
level/levelload.cpp \
level/demolevel.cpp \
game/gamemode.cpp \
game/servergame.cpp \
game/clientgame.cpp \
game/game.cpp \
player/bird.cpp \
player/playerframe.cpp \
player/player.cpp \
platforms/wiz.cpp
##############################################################################
# You shouldn't need to change anything below here, really
##############################################################################
ALL_INCLUDES = $(INCLUDES)
ALL_LIBS = $(LIBS)
CFLAGS = -DWIZ -DUSE_MODPLUG -DFULLSCREEN_ONLY \
-Wall \
$(shell $(PREFIX)/bin/sdl-config --cflags) \
-O3 -ffast-math -fomit-frame-pointer \
LDFLAGS = -L$(PREFIX)/lib $(shell $(PREFIX)/bin/sdl-config --libs) -lmodplug
OFILES = $(CFILES:.cpp=.o)
CC = $(PREFIX)/bin/$(TARGET)-g++
$(PROGRAM): $(OFILES)
$(CC) $(OFILES) $(LDFLAGS) $(LIBDIRS) $(ALL_LIBS) -o $@
.PHONY: all clean
all: $(PROGRAM)
%.o: %.cpp
$(CC) $(ALL_INCLUDES) $(CFLAGS) -c $< -o $@
clean:
-rm -f $(OFILES) $(MAPFILE) $(PROGRAM)
install: all
$(CROSS)/bin/$(TARGET)-strip -o $(PROGRAM).gpe $(PROGRAM)
\ No newline at end of file
......@@ -27,6 +27,9 @@
#include "controls.h"
#ifdef WIZ
#include "platforms/wiz.h"
#endif
Controls::Controls () {
......@@ -49,6 +52,19 @@ Controls::Controls () {
keys[C_STATS].key = SDLK_F9;
keys[C_PAUSE].key = SDLK_p;
#ifdef WIZ
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;
#else
buttons[C_UP].button = -1;
buttons[C_DOWN].button = -1;
buttons[C_LEFT].button = -1;
......@@ -60,7 +76,7 @@ Controls::Controls () {
buttons[C_ESCAPE].button = -1;
buttons[C_STATS].button = -1;
buttons[C_PAUSE].button = -1;
#endif
axes[C_UP].axis = 1;
axes[C_UP].direction = false;
axes[C_DOWN].axis = 1;
......
......@@ -46,6 +46,12 @@
#include <string.h>
#ifdef WIZ
#include "platforms/wiz.h"
extern int volume;
extern int volume_direction;
#endif
int loadMain () {
......@@ -137,8 +143,14 @@ int loadMain () {
// Create the game's window
#ifdef FULLSCREEN_ONLY
#ifdef WIZ
screen = SDL_SetVideoMode(screenW, screenH, 8,
SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE);
SDL_ShowCursor(SDL_DISABLE);
#else
screen = SDL_SetVideoMode(screenW, screenH, 8,
SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE);
#endif
#else
screen = SDL_SetVideoMode(screenW, screenH, 8,
SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE);
......@@ -446,7 +458,9 @@ int loop (int type) {
if ((event.key.keysym.sym == SDLK_RETURN) &&
(event.key.keysym.mod & KMOD_ALT)) toggleFullscreen();
#endif
#ifdef WIZ
SDL_ShowCursor(SDL_DISABLE);
#endif
// Break statement intentionally omitted
case SDL_KEYUP:
......@@ -458,6 +472,20 @@ int loop (int type) {
if (ret != E_NONE) return ret;
#ifdef WIZ
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
......@@ -514,7 +542,9 @@ int loop (int type) {
}
}
#ifdef WIZ
WIZ_AdjustVolume( volume_direction );
#endif
return E_NONE;
}
......
#include "wiz.h"
#include <cstdio>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <fcntl.h>
#include <unistd.h>
int volume = 40;
int volume_direction;
void WIZ_AdjustVolume( int direction )
{
if( direction != VOLUME_NOCHG )
{
if( volume <= 10 )
{
if( direction == VOLUME_UP ) volume += VOLUME_CHANGE_RATE/2;
if( direction == VOLUME_DOWN ) volume -= VOLUME_CHANGE_RATE/2;
}
else
{
if( direction == VOLUME_UP ) volume += VOLUME_CHANGE_RATE;
if( direction == VOLUME_DOWN ) volume -= VOLUME_CHANGE_RATE;
}
if( volume < VOLUME_MIN ) volume = VOLUME_MIN;
if( volume > VOLUME_MAX ) volume = VOLUME_MAX;
printf( "Volume Change: %i\n", volume );
}
unsigned long soundDev = open("/dev/mixer", O_RDWR);
if(soundDev)
{
int vol = ((volume << 8) | volume);
ioctl(soundDev, SOUND_MIXER_WRITE_PCM, &vol);
close(soundDev);
}
}
#ifndef _WIZ_H
#define _WIZ_H
#define VOLUME_MIN 0
#define VOLUME_MAX 100
#define VOLUME_CHANGE_RATE 2
#define VOLUME_NOCHG 0
#define VOLUME_DOWN 1
#define VOLUME_UP 2
#define GP2X_BUTTON_UP (0)
#define GP2X_BUTTON_DOWN (4)
#define GP2X_BUTTON_LEFT (2)
#define GP2X_BUTTON_RIGHT (6)
#define GP2X_BUTTON_UPLEFT (1)
#define GP2X_BUTTON_UPRIGHT (7)
#define GP2X_BUTTON_DOWNLEFT (3)
#define GP2X_BUTTON_DOWNRIGHT (5)
#define GP2X_BUTTON_CLICK (18)
#define GP2X_BUTTON_A (12)
#define GP2X_BUTTON_B (13)
#define GP2X_BUTTON_X (14)
#define GP2X_BUTTON_Y (15)
#define GP2X_BUTTON_L (10)
#define GP2X_BUTTON_R (11)
#define GP2X_BUTTON_START (8)
#define GP2X_BUTTON_SELECT (9)
#define GP2X_BUTTON_VOLUP (16)
#define GP2X_BUTTON_VOLDOWN (17)
void WIZ_AdjustVolume( int direction );
#endif
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