Commit d1f3916b authored by pickle136's avatar pickle136

Add caanoo support

Made clearscreen a Video member for access to the surface pixels.
parent 131adf2e
# OpenJazz makefile
PROGRAM = OpenJazz
ifeq ($(BUILDTYPE),PANDORA)
PROGRAM = OpenJazz
PREFIX = /mythtv/media/devel/toolchains/pandora/arm-2007q3
TOOLS = bin
TARGET = arm-none-linux-gnueabi-
INCLUDE = $(PREFIX)/include
LIBRARY = $(PREFIX)/lib
else
ifeq ($(BUILDTYPE),CAANOO)
PROGRAM = OpenJazzCaanoo
PREFIX = /mythtv/media/devel/toolchains/caanoo/GPH_SDK
TOOLS = tools/gcc-4.2.4-glibc-2.7-eabi/bin
TARGET = arm-gph-linux-gnueabi-
INCLUDE = $(PREFIX)/DGE/include
LIBRARY = $(PREFIX)/DGE/lib/target
else
ifeq ($(BUILDTYPE),WIZ)
PROGRAM = OpenJazzWiz
PREFIX = /mythtv/media/devel/toolchains/openwiz/arm-openwiz-linux-gnu
TOOLS = bin
TARGET = arm-openwiz-linux-gnu-
INCLUDE = $(PREFIX)/include
LIBRARY = $(PREFIX)/lib
else
ifeq ($(BUILDTYPE),GP2X)
PROGRAM = OpenJazzGp2x
PREFIX = /mythtv/media/devel/toolchains/open2x/gcc-4.1.1-glibc-2.3.6
TOOLS = bin
TARGET = arm-open2x-linux-
INCLUDE = $(PREFIX)/include
LIBRARY = $(PREFIX)/lib
else # default linux
PROGRAM = OpenJazz
PREFIX = /usr
TOOLS = bin
TARGET =
INCLUDE = $(PREFIX)/include
LIBRARY = $(PREFIX)/lib
endif
endif
endif
endif
......@@ -49,12 +68,17 @@ OBJS = src/bonus/bonus.o \
src/scene/scene.o src/scene/sceneload.o \
src/baselevel.o src/main.o src/util.o
CXX = $(PREFIX)/bin/$(TARGET)g++
CXX = $(PREFIX)/$(TOOLS)/$(TARGET)g++
ifeq ($(BUILDTYPE),PANDORA)
CXXFLAGS += -DSCALE
LDFLAGS += -lts
else
ifeq ($(BUILDTYPE),CAANOO)
OBJS += src/platforms/wiz.o
CXXFLAGS += -DCAANOO -DFULLSCREEN_ONLY
LDFLAGS +=
else
ifeq ($(BUILDTYPE),WIZ)
OBJS += src/platforms/wiz.o
CXXFLAGS += -DWIZ -DFULLSCREEN_ONLY
......@@ -70,13 +94,15 @@ LDFLAGS +=
endif
endif
endif
endif
CXXFLAGS += -g -Wall -O3 -fsigned-char -DUSE_SOCKETS -I$(PREFIX)/include -I$(PREFIX)/include/SDL -Isrc
LDFLAGS += -L$(PREFIX)/lib -lSDL -lz
CXXFLAGS += -g -Wall -O3 -fsigned-char -DUSE_SOCKETS -DLOWERCASE_FILENAMES -DUPPERCASE_FILENAMES -I$(INCLUDE) -I$(INCLUDE)/SDL -Isrc
LDFLAGS += -L$(LIBRARY) -lSDL -lz
# Uncomment the following two lines for music (requires libmodplug)
CXXFLAGS += -DUSE_MODPLUG -I$(PREFIX)/include/libmodplug
LDFLAGS += -lmodplug
CXXFLAGS += -DUSE_MODPLUG -I$(INCLUDE)/libmodplug
LDFLAGS += $(LIBRARY)/libmodplug.a
#-lmodplug
$(PROGRAM): $(OBJS)
$(CXX) $(CXXFLAGS) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
......
......@@ -76,7 +76,7 @@ ClientGame::ClientGame (char* address) {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
fontmn2->showString("WAITING FOR REPLY", canvasW >> 2, (canvasH >> 1) - 16);
ret = net->recv(sock, buffer + count, MTL_G_PROPS - count);
......@@ -205,7 +205,7 @@ ClientGame::ClientGame (char* address) {
}
clearScreen(0);
video.clearScreen(0);
fontmn2->showString("JOINING GAME", canvasW >> 2, (canvasH >> 1) - 16);
ret = step(0);
......@@ -257,7 +257,7 @@ int ClientGame::setLevel (char* fileName) {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
fontmn2->showString("WAITING FOR SERVER", canvasW >> 2, (canvasH >> 1) - 16);
ret = step(0);
......@@ -275,7 +275,7 @@ int ClientGame::setLevel (char* fileName) {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
fontmn2->showString("downloaded", canvasW >> 2, (canvasH >> 1) - 16);
fontmn2->showNumber(file->tell(), (canvasW >> 2) + 56, canvasH >> 1);
fontmn2->showString("bytes", (canvasW >> 2) + 64, canvasH >> 1);
......
......@@ -28,7 +28,7 @@
#include "controls.h"
#include "loop.h"
#if defined(WIZ) || defined(GP2X)
#if defined(CAANOO) || defined(WIZ) || defined(GP2X)
#include "platforms/wiz.h"
#endif
......@@ -70,7 +70,7 @@ Controls::Controls () {
keys[C_SWIM].key = keys[C_JUMP].key;
#if defined(WIZ) || defined(GP2X)
#if defined(CAANOO) || 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;
......
......@@ -101,7 +101,7 @@ bool Video::create (int width, int height) {
if (canvas != screen) SDL_FreeSurface(canvas);
#endif
#if defined(WIZ) || defined(GP2X) || defined(DINGOO)
#if defined(CAANOO) || defined(WIZ) || defined(GP2X) || defined(DINGOO)
screen = SDL_SetVideoMode(320, 240, 8, FULLSCREEN_FLAGS);
#else
#ifdef FULLSCREEN_ONLY
......@@ -139,7 +139,7 @@ bool Video::create (int width, int height) {
}
#endif
#if !(defined(WIZ) || defined(GP2X))
#if !defined(CAANOO) && !(defined(WIZ) && defined(GP2X))
expose();
#endif
......@@ -163,7 +163,7 @@ bool Video::create (int width, int height) {
void Video::setPalette (SDL_Color *palette) {
// Make palette changes invisible until the next draw. Hopefully.
clearScreen(SDL_MapRGB(screen->format, 0, 0, 0));
video.clearScreen(SDL_MapRGB(screen->format, 0, 0, 0));
#ifndef SCALE
SDL_Flip(screen);
#endif
......@@ -315,11 +315,11 @@ void Video::flip (int mspf, PaletteEffect* paletteEffects) {
}
void clearScreen (int index) {
void Video::clearScreen (int index) {
#if defined(WIZ) || defined(GP2X)
#if defined(CAANOO) || defined(WIZ) || defined(GP2X)
// always 240 lines cleared to black
memset(video->pixels, index, 320*240);
memset(video.screen->pixels, index, 320*240);
#else
SDL_FillRect(canvas, NULL, index);
#endif
......
......@@ -37,7 +37,7 @@
#define WINDOWED_FLAGS (SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#if defined(WIZ) || defined(GP2X)
#if defined(CAANOO) || defined(WIZ) || defined(GP2X)
#define FULLSCREEN_FLAGS (SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE)
#elif defined(DINGOO)
#define FULLSCREEN_FLAGS 0
......@@ -93,7 +93,9 @@ class Video {
#endif
void expose ();
void flip (int mspf, PaletteEffect* paletteEffects);
void flip (int mspf, PaletteEffect* paletteEffects);
void clearScreen (int index);
};
......@@ -109,7 +111,6 @@ EXTERN Video video;
// Functions
EXTERN SDL_Surface* createSurface (unsigned char* pixels, int width, int height);
EXTERN void clearScreen (int index);
EXTERN void drawRect (int x, int y, int width, int height, int index);
#endif
......
......@@ -203,7 +203,7 @@ int Network::join (char *address) {
}
clearScreen(0);
video.clearScreen(0);
fontmn2->showString("CONNECTING TO SERVER", canvasW >> 2, (canvasH >> 1) - 16);
FD_ZERO(&writefds);
......@@ -234,7 +234,7 @@ int Network::join (char *address) {
return sock;
#elif defined USE_SDL_NET
clearScreen(0);
video.clearScreen(0);
fontmn2->showString("CONNECTING TO SERVER", canvasW >> 2, (canvasH >> 1) - 16);
loop(NORMAL_LOOP);
ipAddress.port = NET_PORT;
......
......@@ -51,7 +51,7 @@
#ifdef __SYMBIAN32__
#define MUSIC_RESAMPLEMODE MODPLUG_RESAMPLE_LINEAR
#define MUSIC_FLAGS MODPLUG_ENABLE_MEGABASS
#elif defined(WIZ) || defined(GP2X) || defined(DINGOO)
#elif defined(CAANOO) || defined(WIZ) || defined(GP2X) || defined(DINGOO)
#define MUSIC_RESAMPLEMODE MODPLUG_RESAMPLE_LINEAR
#define MUSIC_FLAGS 0
#else
......
......@@ -570,7 +570,7 @@ int JJ2Level::load (char *fileName, unsigned char diff, bool checkpoint) {
video.setPalette(menuPalette);
clearScreen(0);
video.clearScreen(0);
x = (canvasW >> 1) - ((strlen(string) + 6) << 2);
x = fontmn2->showString("LOADING ", x - 60, (canvasH >> 1) - 16);
......
......@@ -240,7 +240,7 @@ void Level::draw () {
// If there is no sky, draw a blank background
// This is only very occasionally actually visible
clearScreen(127);
video.clearScreen(127);
}
......
......@@ -523,7 +523,7 @@ int Level::load (char* fileName, unsigned char diff, bool checkpoint) {
video.setPalette(menuPalette);
clearScreen(0);
video.clearScreen(0);
x = (canvasW >> 1) - ((strlen(string) + strlen(ext)) << 2);
x = fontmn2->showString("LOADING ", x - 60, (canvasH >> 1) - 16);
......
......@@ -50,7 +50,7 @@
#include <string.h>
#if defined(WIZ) || defined(GP2X)
#if defined(CAANOO) || defined(WIZ) || defined(GP2X)
#include "platforms/wiz.h"
#endif
......@@ -533,7 +533,7 @@ int loop (LoopType type, PaletteEffect* paletteEffects) {
}
#endif
#if defined(WIZ) || defined(GP2X) || defined(DINGOO)
#if defined(CAANOO) || defined(WIZ) || defined(GP2X) || defined(DINGOO)
SDL_ShowCursor(SDL_DISABLE);
#endif
// Break statement intentionally omitted
......
......@@ -124,7 +124,7 @@ int GameMenu::newGameDifficulty (GameModeType mode, char* firstLevel) {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
for (count = 0; count < 4; count++) {
......@@ -250,7 +250,7 @@ int GameMenu::loadGame () {
SDL_Delay(T_FRAME);
clearScreen(15);
video.clearScreen(15);
if (option == 0) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString("choose world:", 32, canvasH / 3);
......@@ -375,7 +375,7 @@ int GameMenu::newGameEpisode (GameModeType mode) {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
dst.x = canvasW - 144;
dst.y = (canvasH - 110) >> 1;
......
......@@ -315,7 +315,7 @@ int MainMenu::main () {
//as long as we're drawing plasma, we don't need to clear the screen.
//clearScreen(28);
//video.clearScreen(28);
plasma.draw();
......
......@@ -59,7 +59,7 @@ int Menu::message (const char* text) {
SDL_Delay(T_FRAME);
clearScreen(15);
video.clearScreen(15);
// Draw the message
fontmn2->showString(text, canvasW >> 2, (canvasH >> 1) - 16);
......@@ -89,7 +89,7 @@ int Menu::generic (const char** optionNames, int options, int& chosen) {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
for (count = 0; count < options; count++) {
......@@ -200,7 +200,7 @@ int Menu::textInput (const char* request, char*& text) {
SDL_Delay(T_FRAME);
clearScreen(15);
video.clearScreen(15);
// Draw the prompt
fontmn2->showString(request, canvasW >> 2, (canvasH >> 1) - 16);
......
......@@ -84,7 +84,7 @@ int SetupMenu::setupKeyboard () {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
for (count = 0; count < PCONTROLS; count++) {
......@@ -226,7 +226,7 @@ int SetupMenu::setupJoystick () {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
for (count = 0; count < 7; count++) {
......@@ -277,7 +277,7 @@ int SetupMenu::setupResolution () {
resolutions = SDL_ListModes(NULL, FULLSCREEN_FLAGS);
#if defined(WIZ) || defined(GP2X) || defined(DINGOO)
#if defined(CAANOO) ||defined(WIZ) || defined(GP2X) || defined(DINGOO)
maxW = 320;
maxH = 240;
#else
......@@ -310,7 +310,7 @@ int SetupMenu::setupResolution () {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
// Show screen corners
......@@ -424,7 +424,7 @@ int SetupMenu::setupScaling () {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
// Show screen corners
......@@ -478,7 +478,7 @@ int SetupMenu::setupSound () {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
// Volume
......@@ -560,7 +560,7 @@ int SetupMenu::setup () {
case 1:
#if !defined(WIZ) && !defined(GP2X)
#if !defined(CAANOO) && !defined(WIZ) && !defined(GP2X)
setupKeyboard();
#else
message("FEATURE NOT AVAILABLE");
......
......@@ -128,7 +128,7 @@ int Planet::play () {
SDL_Delay(T_FRAME);
clearScreen(0);
video.clearScreen(0);
if (globalTicks - tickOffset < F2)
sprite.drawScaled(canvasW >> 1, canvasH >> 1, globalTicks - tickOffset);
......
#include "wiz.h"
#if defined(WIZ) || defined(GP2X)
#include <cstdio>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <fcntl.h>
#include <unistd.h>
#include "io/sound.h"
void WIZ_AdjustVolume( int direction )
{
if( direction != VOLUME_NOCHG )
......@@ -37,3 +36,4 @@ void WIZ_AdjustVolume( int direction )
close(soundDev);
}
}
#endif
#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
#if defined(CAANOO)
#define GP2X_BUTTON_UP (11) // Directional dummies for Caanoo (not used)
#define GP2X_BUTTON_DOWN (12)
#define GP2X_BUTTON_LEFT (13)
#define GP2X_BUTTON_RIGHT (14)
#define GP2X_BUTTON_UPLEFT (15)
#define GP2X_BUTTON_UPRIGHT (16)
#define GP2X_BUTTON_DOWNLEFT (17)
#define GP2X_BUTTON_DOWNRIGHT (18)
#define GP2X_BUTTON_CLICK (19)
#define GP2X_BUTTON_A (0)
#define GP2X_BUTTON_B (2)
#define GP2X_BUTTON_X (1)
#define GP2X_BUTTON_Y (3)
#define GP2X_BUTTON_L (4)
#define GP2X_BUTTON_R (5)
#define GP2X_BUTTON_START (9) // Help 2
#define GP2X_BUTTON_SELECT (8) // Help 1
#define GP2X_BUTTON_HOME (6) // Home (caanoo only)
#define GP2X_BUTTON_VOLUP (20) // doesnt exist on caanoo, but need a define
#define GP2X_BUTTON_VOLDOWN (21) // same as above
#else // WIZ || GP2X
#define GP2X_BUTTON_UP (0)
#define GP2X_BUTTON_DOWN (4)
#define GP2X_BUTTON_LEFT (2)
......@@ -27,7 +42,17 @@
#define GP2X_BUTTON_SELECT (9)
#define GP2X_BUTTON_VOLUP (16)
#define GP2X_BUTTON_VOLDOWN (17)
#endif
void WIZ_AdjustVolume( int direction );
#if defined(WIZ) || defined(GP2X)
#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
void WIZ_AdjustVolume( int direction );
#endif
#endif
......@@ -44,7 +44,7 @@ SceneFrame::SceneFrame(int frameType, unsigned char* frameData, int frameSize) {
soundId = -1;
this->frameData = frameData;
this->frameType = frameType;
this->frameSize = frameSize;
this->frameSize = frameSize;
prev = NULL;
next = NULL;
}
......@@ -62,7 +62,7 @@ void SceneAnimation::addFrame(int frameType, unsigned char* frameData, int frame
frame->prev = lastFrame;
lastFrame->next = frame;
}
lastFrame = frame;
frames++;
}
......@@ -93,7 +93,7 @@ SceneAnimation::SceneAnimation (SceneAnimation* newNext)
SceneAnimation::~SceneAnimation ()
{
if (next) delete next;
if(sceneFrames) {
SceneFrame* frame = sceneFrames;
SceneFrame* nextFrame = NULL;
......@@ -105,7 +105,7 @@ SceneAnimation::~SceneAnimation ()
frame = nextFrame;
}
}
if (background) SDL_FreeSurface(background);
}
......@@ -193,11 +193,11 @@ Scene::Scene (const char * fileName) {
throw e;
}
images = NULL;
palettes = NULL;
animations = NULL;
file->seek(ESignatureLength, true); // Skip Digital Dimensions header
signed long int dataOffset = file->loadInt(); //get offset pointer to first data block
......@@ -261,13 +261,13 @@ int Scene::play () {
int frameDelay = 0;
int prevFrame = 0;
int continueToNextPage = 0;
unsigned int pageTime = pages[sceneIndex].pageTime;
unsigned int lastTicks = globalTicks;
int newpage = true;
SDL_Rect textRect = {0, 0, SW, SH};
clearScreen(0);
video.clearScreen(0);
while (true) {
......@@ -291,16 +291,16 @@ int Scene::play () {
int upOrLeft = 0;
int downOrRight = 0;
if(pages[sceneIndex].askForYesNo) {
// Should check for Y also
downOrRight = controls.release(C_ENTER) || controls.release(C_YES);;
} else {
upOrLeft = (controls.release(C_UP) || controls.release(C_LEFT));
downOrRight = (controls.release(C_RIGHT) || controls.release(C_DOWN) || controls.release(C_ENTER));
downOrRight = (controls.release(C_RIGHT) || controls.release(C_DOWN) || controls.release(C_ENTER));
}
if ((sceneIndex > 0 && upOrLeft) ||
downOrRight || continueToNextPage ||
((globalTicks-lastTicks) >= pageTime * 1000 && pageTime != 256 && pageTime != 0)) {
......@@ -308,7 +308,7 @@ int Scene::play () {
if(pages[sceneIndex].stopMusic) {
stopMusic();
}
if (upOrLeft) sceneIndex--;
else sceneIndex++;
......@@ -351,10 +351,10 @@ int Scene::play () {
}
if(pages[sceneIndex].musicFile) {
if(pages[sceneIndex].musicFile) {
playMusic(pages[sceneIndex].musicFile);
}
}
newpage = 0;
}
......@@ -473,7 +473,7 @@ int Scene::play () {
}
} else clearScreen(0);
} else video.clearScreen(0);
// Draw the texts associated with this page
......
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