Permalink
Browse files

Woopsie.

  • Loading branch information...
1 parent a4e20a5 commit 58d427b6e89a64308e92488ae6f065ec30284c20 @DusteDdk committed Jan 16, 2012
Showing with 358 additions and 0 deletions.
  1. +201 −0 Wizznic_pandora.cbp
  2. +117 −0 platform/gp2x.c
  3. +40 −0 platform/gp2x.h
View
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+ <FileVersion major="1" minor="6" />
+ <Project>
+ <Option title="Wizznic_pandora" />
+ <Option pch_mode="2" />
+ <Option compiler="djwillis_open_pandora" />
+ <Build>
+ <Target title="Pandora">
+ <Option output="bin\Wizznic.bin" prefix_auto="0" extension_auto="0" />
+ <Option object_output="obj\" />
+ <Option type="1" />
+ <Option compiler="djwillis_open_pandora" />
+ <Compiler>
+ <Add option="-O2" />
+ <Add option="-mcpu=cortex-a8" />
+ <Add option="-mfloat-abi=softfp" />
+ <Add option="-mfpu=neon" />
+ <Add option="-ftree-vectorize" />
+ <Add option="-DPANDORA" />
+ <Add option="-DPER_USER_FILES" />
+ </Compiler>
+ <Linker>
+ <Add option="-s" />
+ <Add option="-lSDL -lSDL_image -lSDL_mixer" />
+ <Add option="-lpng -lm -lz -lts-1.0 -ltiff -ljpeg" />
+ <Add option="-lmad -lpthread" />
+ </Linker>
+ </Target>
+ <Target title="GP2X">
+ <Option output="bin\Wizznic" prefix_auto="0" extension_auto="0" />
+ <Option object_output="obj\" />
+ <Option type="1" />
+ <Option compiler="devkitgp2x" />
+ <Compiler>
+ <Add option="-O3" />
+ <Add option="-mcpu=arm920t" />
+ <Add option="-mtune=arm920" />
+ <Add option="-msoft-float" />
+ <Add option="-ffast-math" />
+ <Add option="-fstrict-aliasing" />
+ <Add option="-mstructure-size-boundary=32" />
+ <Add option="-fweb" />
+ <Add option="-frename-registers" />
+ <Add option="-fomit-frame-pointer" />
+ <Add option="-falign-functions=32" />
+ <Add option="-falign-loops" />
+ <Add option="-falign-labels" />
+ <Add option="-falign-jumps" />
+ <Add option="-finline" />
+ <Add option="-finline-functions" />
+ <Add option="-fno-builtin" />
+ <Add option="-fno-common" />
+ <Add option="-DGP2X" />
+ </Compiler>
+ <Linker>
+ <Add option="-s" />
+ <Add option="-static -lSDL -lSDL_image -lSDL_mixer" />
+ <Add option="-lpng -lm -lz -ltiff -ljpeg -lmikmod" />
+ <Add option="-lvorbisidec" />
+ <Add option="-lmad -lpthread" />
+ </Linker>
+ </Target>
+ </Build>
+ <Compiler>
+ <Add option="-Wall" />
+ </Compiler>
+ <Unit filename="board.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="board.h" />
+ <Unit filename="credits.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="credits.h" />
+ <Unit filename="cursor.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="cursor.h" />
+ <Unit filename="defs.h" />
+ <Unit filename="draw.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="draw.h" />
+ <Unit filename="dumplevelimages.c">
+ <Option compilerVar="CC" />
+ <Option target="Pandora" />
+ </Unit>
+ <Unit filename="dumplevelimages.h">
+ <Option target="Pandora" />
+ </Unit>
+ <Unit filename="game.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="game.h" />
+ <Unit filename="input.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="input.h" />
+ <Unit filename="leveleditor.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="leveleditor.h" />
+ <Unit filename="levels.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="levels.h" />
+ <Unit filename="levelselector.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="levelselector.h" />
+ <Unit filename="list.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="list.h" />
+ <Unit filename="loader.h" />
+ <Unit filename="main.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="mbrowse.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="mbrowse.h" />
+ <Unit filename="menu.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="menu.h" />
+ <Unit filename="pack.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="pack.h" />
+ <Unit filename="particle.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="particles.h" />
+ <Unit filename="pixel.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="pixel.h" />
+ <Unit filename="platform\gp2x.c">
+ <Option compilerVar="CC" />
+ <Option target="GP2X" />
+ </Unit>
+ <Unit filename="platform\gp2x.h">
+ <Option target="GP2X" />
+ </Unit>
+ <Unit filename="player.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="player.h" />
+ <Unit filename="settings.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="settings.h" />
+ <Unit filename="sound.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="sound.h" />
+ <Unit filename="sprite.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="sprite.h" />
+ <Unit filename="stars.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="stars.h" />
+ <Unit filename="states.h" />
+ <Unit filename="stats.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="stats.h" />
+ <Unit filename="strings.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="strings.h" />
+ <Unit filename="teleport.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="teleport.h" />
+ <Unit filename="text.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="text.h" />
+ <Unit filename="ticks.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="ticks.h" />
+ <Unit filename="userfiles.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="userfiles.h" />
+ <Unit filename="waveimg.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="waveimg.h" />
+ <Extensions>
+ <code_completion />
+ <debugger />
+ </Extensions>
+ </Project>
+</CodeBlocks_project_file>
View
@@ -0,0 +1,117 @@
+/* This file was copied with little or no modification from the WizPort of OpenJazz */
+/* There's also some bits from libcastor in here (Copyright (c) 2009 Adan Scotney) */
+//#include "settings.h"
+
+#include "gp2x.h"
+
+#ifdef GP2X
+
+#include <sys/ioctl.h>
+#include <sys/soundcard.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "../settings.h"
+#include "../ticks.h"
+
+//For clock code
+//#include <sys/mman.h>
+
+
+static int volume = 100;
+static int volume_direction;
+
+void WIZ_SetVolume( int volumePercent )
+{
+ if(volume==volumePercent) return;
+
+ volume=volumePercent;
+ WIZ_AdjustVolume( VOLUME_NOCHG );
+}
+
+int WIZ_GetVolume()
+{
+ return(volume);
+}
+
+static int countDown=0;
+static int lastVol = 0;
+void WIZ_ShowVolume(SDL_Surface* screen)
+{
+ char buf[11]; //vol: xxx%\0 = 10.
+
+ if(countDown > 0)
+ {
+ countDown-=getTicks();
+ sprintf(buf, "vol: %i", setting()->wizVol);
+ txtWriteCenter(screen, FONTSMALL, buf, 160, 200);
+ }
+}
+
+
+void WIZ_AdjustVolume( int direction )
+{
+ if( direction != VOLUME_NOCHG )
+ {
+ countDown=1500;
+ 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;
+ }
+ unsigned long soundDev = open("/dev/mixer", O_RDWR);
+ if(soundDev)
+ {
+ int vol = ((volume << 8) | volume);
+ ioctl(soundDev, SOUND_MIXER_WRITE_PCM, &vol);
+ close(soundDev);
+ }
+ setting()->wizVol=volume;
+ saveSettings();
+}
+
+/* this is WIZ code.....
+#define PLLSETREG0 (memregs32[0xF004>>2])
+#define PWRMODE (memregs32[0xF07C>>2])
+#define SYS_CLK_FREQ 27
+static int omhz=533;
+int WIZ_SetClock(int mhz)
+{
+ if(mhz==omhz) return;
+ omhz=mhz;
+ // Open CPU reg //
+ volatile uint32_t *memregs32;
+ int memfd;
+ memfd = open("/dev/mem", O_RDWR);
+ if(memfd < 0) return(0);
+
+ memregs32 = (volatile uint32_t*)mmap(0, 0x20000, PROT_READ|PROT_WRITE, MAP_SHARED, memfd, 0xC0000000);
+ if(memregs32 == (volatile uint32_t*)0xFFFFFFFF) return(0);
+
+ // Set CPU Freq //
+ unsigned long v;
+ unsigned mdiv, pdiv=9, sdiv=0;
+
+ mdiv= (mhz * pdiv) / SYS_CLK_FREQ;
+ mdiv &= 0x3FF;
+ v= pdiv<<18 | mdiv<<8 | sdiv;
+
+ PLLSETREG0 = v;
+ PWRMODE |= 0x8000;
+
+ // Close CPU reg //
+
+ memregs32 = NULL;
+ close(memfd);
+ return(1);
+}
+*/
+#endif
View
@@ -0,0 +1,40 @@
+/* This file was copied with little or no modification from the WizPort of OpenJazz */
+
+#ifndef _GP2X_H
+#define _GP2X_H
+
+#define VOLUME_MIN 0
+#define VOLUME_MAX 100
+#define VOLUME_CHANGE_RATE 4
+#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)
+
+#include "../text.h"
+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

0 comments on commit 58d427b

Please sign in to comment.