diff --git a/stella/Makefile b/stella/Makefile index 235b79943..e8c478d30 100644 --- a/stella/Makefile +++ b/stella/Makefile @@ -13,7 +13,7 @@ ## See the file "license" for information on usage and redistribution of ## this file, and for a DISCLAIMER OF ALL WARRANTIES. ## -## $Id: Makefile,v 1.6 2005-07-01 13:59:40 stephena Exp $ +## $Id: Makefile,v 1.7 2005-08-25 15:19:17 stephena Exp $ ## ## Based on code from ScummVM - Scumm Interpreter ## Copyright (C) 2002-2004 The ScummVM project @@ -109,7 +109,7 @@ DEPFILES = # The build rule for the Stella executable $(EXECUTABLE): $(OBJS) - $(CXX) $(LDFLAGS) $(PRE_OBJS_FLAGS) $+ $(POST_OBJS_FLAGS) $(LIBS) -o $@ + $(LD) $(LDFLAGS) $(PRE_OBJS_FLAGS) $+ $(POST_OBJS_FLAGS) $(LIBS) -o $@ distclean: clean $(RM_REC) $(DEPDIRS) @@ -248,5 +248,39 @@ win32dist: scummvm$(EXEEXT) cp /usr/local/bin/SDL.dll $(WIN32PATH) u2d $(WIN32PATH)/*.txt +# Special target to create psp stuff +psp-package: $(EXECUTABLE) + $(MKSFO) 'Stella' PARAM.SFO + mkdir -p "psp/stella" + $(PSP-STRIP) stella.elf -o psp/stella/EBOOT.PBP + mkdir -p "psp/stella%" + $(PACK-PBP) "psp/stella%/EBOOT.PBP" PARAM.SFO src/psp/data/ICON0.PNG NULL NULL src/psp/data/PIC1.PNG NULL NULL NULL + rm -f PARAM.SFO + +psp-upload: psp-package + mount | grep $(PSP-MOUNTPOINT) || mount $(PSP-MOUNTPOINT) + cp -rv "psp/stella" "psp/stella%" $(PSP-MOUNTPOINT)/psp/game/ + umount $(PSP-MOUNTPOINT) + +psp-debug: + mount | grep \$(PSP-MOUNTPOINT) || mount $(PSP-MOUNTPOINT) + @cat $(PSP-MOUNTPOINT)/stderr.txt + @echo -e "\n\n------------------------------------------------------------" + @cat $(PSP-MOUNTPOINT)/stdout.txt + umount $(PSP-MOUNTPOINT) + +psp-cleanup: + rm -rf psp + mount | grep $(PSP-MOUNTPOINT) || mount $(PSP-MOUNTPOINT) + rm -rf $(PSP-MOUNTPOINT)/std* + umount $(PSP-MOUNTPOINT) + +psp-layout: + mount | grep $(PSP-MOUNTPOINT) || mount $(PSP-MOUNTPOINT) + mkdir -p $(PSP-MOUNTPOINT)/stella/roms + mkdir -p $(PSP-MOUNTPOINT)/stella/snapshots + cp -v src/psp/data/stellarc.psp $(PSP-MOUNTPOINT)/stella/stellarc + umount $(PSP-MOUNTPOINT) + .PHONY: deb bundle test osxsnap win32dist dist install uninstall diff --git a/stella/README-PSP.txt b/stella/README-PSP.txt new file mode 100644 index 000000000..d0ad94eac --- /dev/null +++ b/stella/README-PSP.txt @@ -0,0 +1,57 @@ + +STELLA port for the Sony PSP contributed by + David Voswinekl + + +Building +-------- +To build for the PSP, make sure psp-config is in the path and run: + + ./configure --host=psp + make + make psp-upload + make psp-layout + +Dependencies +------------ + o psp-toolchain + o pspsdk + o libsdl + o libpng + +Status +------ + + Video - Support for scaled software mode and framebuffer hardware mode + Audio - Working + Input - Mouse emulation via Joystick + Snapshot - Working + Lauchner - Working + Menu - Working + Debugger - Not useable + + +Keymap +------ + + Menu + Cross - Left Mouse Button + Circle - Right Mouse Button + + + Emulation + Cross - Fire + Circle - Snapshot + Square - toggle PAL/NTSC + Triangle - Pause + Select - toggle Menu + Start - back to Launcher + + +Known Bugs +---------- + o SDL video driver is in early stage, so expect flickering and update problems + o Stella will only compile/run with lastest sdl, pspskd and toolchain. + o Stella will crash if SDL is compiled with --disable-stdio-redirect. + Also you need a custom libSDLmain which has a debugHandler for stdout. + diff --git a/stella/configure b/stella/configure index 56820ec3d..11c0bfe22 100755 --- a/stella/configure +++ b/stella/configure @@ -112,15 +112,19 @@ find_sdlconfig() _sdlconfig= IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - + done=0 for path_dir in $_sdlpath; do for sdlconfig in $sdlconfigs; do if test -x "$path_dir/$sdlconfig" ; then _sdlconfig="$path_dir/$sdlconfig" - echo $_sdlconfig + done=1 break fi done + if test $done -eq 1 ; then + echo $_sdlconfig + break + fi done IFS="$ac_save_ifs" @@ -341,6 +345,14 @@ ppc-amigaos) _host_os=amigaos _host_cpu=ppc ;; +psp) + _host_os=psp + _host_cpu=mips + _png=yes + # force psp sdl path + _sdlpath=$(psp-config --pspdev-path)/psp/bin:$_sdlpath + PATH=$(psp-config --pspdev-path)/psp/bin:$(psp-config --pspdev-path)/bin:$PATH + ;; *) guessed_host=`$_srcdir/config.guess` _host_cpu=`echo $guessed_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` @@ -359,6 +371,9 @@ mingw* | cygwin*) arm-riscos-aof) EXEEXT=",ff8" ;; +psp) + EXEEXT=".elf" + ;; *) EXEEXT="" ;; @@ -375,6 +390,11 @@ else fi CXX= +if [ "$_host" = "psp" ] ; then + compilers="$CXX psp-g++ psp-c++" + CXX="psp-c++" +fi + for compiler in $compilers; do if test_compiler $compiler; then CXX=$compiler @@ -392,7 +412,7 @@ fi echocheck "compiler version" -cxx_name=`( $cc -v ) 2>&1 | tail -1 | cut -d ' ' -f 1` +cxx_name=`( $cc -v ) 2>&1 | tail -n 1 | cut -d ' ' -f 1` cxx_version=`( $CXX -dumpversion ) 2>&1` if test "$?" -gt 0; then cxx_version="not found" @@ -466,6 +486,8 @@ if test -n "$_host"; then CXXFLAGS="$CFLAGS -newlib -mstrict-align -mcpu=750 -mtune=7400" LDFLAGS="$LDFLAGS -newlib" ;; + psp) + ;; *) echo "Cross-compiling to unknown target, please add your target to configure." exit 1 @@ -669,7 +691,7 @@ else fi LIBS="$LIBS `$_sdlconfig $_sdl_conf_libs` -lz" - +LD=$CXX case $_host_os in unix) DEFINES="$DEFINES -DBSPF_UNIX -DHAVE_GETTIMEOFDAY -DHAVE_INTTYPES" @@ -693,6 +715,33 @@ case $_host_os in LIBS="$LIBS -lopengl32" fi ;; + psp) + # -O3 is need for speed + # -G0 to avoid c++ link problems + CXXFLAGS="-G0 -O3 -fomit-frame-pointer -funroll-loops" + # 2 times -lc to avoid link problems. psp-gcc seems to to forget the first -lc wiile stdc++ linking + LIBS="-L `psp-config --pspsdk-path`/lib -L`psp-config --pspsdk-path`/../lib " + LIBS="$LIBS -lSDLmain -lSDL -lpng -lm -lpspsdk -lpspdebug -lpspgu -lpspctrl " + LIBS="$LIBS -lpspaudio -lc -lz -lpspkernel -lpspuser -lpspge -lpspdisplay -lpsphprm -lstdc++ -lc" + # psp compiler + CC="psp-gcc" + LD="psp-gcc" + _ranlib="psp-ranlib" + _ar="psp-ar cru" + + MODULES="$MODULES src/psp" + + # psp specific tool + PSP_STRIP=`psp-config --pspdev-path`"/bin/psp-strip" + PACK_PBP=`psp-config --pspdev-path`"/bin/pack-pbp" + MKSFO="`psp-config --pspdev-path`/bin/mksfo" + + # mount point of psp + PSP_MOUNTPOINT="/mnt/psp" + + INCLUDES="$INCLUDES -Isrc/psp -I`psp-config --pspsdk-path`/include" + DEFINES="$DEFINES -Dmain=SDL_main -DPSP -DBSPF_PSP -DPSP_DEBUG" + ;; *) echo "WARNING: host system not currenty supported" exit @@ -726,6 +775,7 @@ cat > config.mak << EOF CXX := $CXX CXXFLAGS := $CXXFLAGS +LD := $LD LIBS += $LIBS RANLIB := $_ranlib INSTALL := $_install @@ -758,5 +808,16 @@ DEFINES += $DEFINES LDFLAGS += $LDFLAGS EOF +if test $_host_os = "psp" ; then +cat >> config.mak << EOF + +PSP-STRIP := $PSP_STRIP +PACK-PBP := $PACK_PBP +MKSFO := $MKSFO +PSP-MOUNTPOINT := $PSP_MOUNTPOINT +EOF +fi + + # This should be taken care of elsewhere, but I'm not sure where rm -f stella-conf* diff --git a/stella/src/common/FrameBufferSoft.cxx b/stella/src/common/FrameBufferSoft.cxx index f7dab2ce9..2336cdce3 100644 --- a/stella/src/common/FrameBufferSoft.cxx +++ b/stella/src/common/FrameBufferSoft.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBufferSoft.cxx,v 1.35 2005-08-24 01:07:36 stephena Exp $ +// $Id: FrameBufferSoft.cxx,v 1.36 2005-08-25 15:19:17 stephena Exp $ //============================================================================ #include @@ -97,7 +97,30 @@ bool FrameBufferSoft::createScreen() // In software mode, the image and screen dimensions are always the same myImageDim = myScreenDim; - + +#ifdef PSP + if (myUseHardSurface) + { + /* double buff is broken */ + mySDLFlags = SDL_HWSURFACE; + myScreenDim.w = myDesktopDim.w; + myScreenDim.h = myDesktopDim.w; + #ifdef PSP_DEBUG + fprintf(stdout, "FrameBufferSoft::createScreen Hardware Mode " + "myScreenDim.w='%i' myScreenDim.h='%i'\n", + myScreenDim.w,myScreenDim.h); + #endif + } + else + { + #ifdef PSP_DEBUG + fprintf(stdout, "FrameBufferSoft::createScreen Software Mode " + "myScreenDim.w='%i' myScreenDim.h='%i'\n", + myScreenDim.w,myScreenDim.h); + #endif + } +#endif + myScreen = SDL_SetVideoMode(myScreenDim.w, myScreenDim.h, 0, mySDLFlags); if(myScreen == NULL) { diff --git a/stella/src/common/Snapshot.cxx b/stella/src/common/Snapshot.cxx index 6af300843..98c44196e 100644 --- a/stella/src/common/Snapshot.cxx +++ b/stella/src/common/Snapshot.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Snapshot.cxx,v 1.7 2005-06-28 23:18:15 stephena Exp $ +// $Id: Snapshot.cxx,v 1.8 2005-08-25 15:19:17 stephena Exp $ //============================================================================ #ifdef SNAPSHOT_SUPPORT @@ -74,6 +74,12 @@ string Snapshot::savePNG(string filename) uInt32 width = myFrameBuffer.imageWidth(); uInt32 height = myFrameBuffer.imageHeight(); + // FIXME - this should really call something like OSystem::message() + // so we can get rid of annoying ifdefs everywhere +#ifdef PSP + fprintf(stdout,"ok w=%i h=%i\n",width,height); +#endif + ofstream* out = new ofstream(filename.c_str(), ios_base::binary); if(!out) return "Couldn't create snapshot file"; diff --git a/stella/src/common/SoundSDL.cxx b/stella/src/common/SoundSDL.cxx index 583350c7b..8b33c7c39 100644 --- a/stella/src/common/SoundSDL.cxx +++ b/stella/src/common/SoundSDL.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: SoundSDL.cxx,v 1.19 2005-06-28 23:18:15 stephena Exp $ +// $Id: SoundSDL.cxx,v 1.20 2005-08-25 15:19:17 stephena Exp $ //============================================================================ #ifdef SOUND_SUPPORT @@ -98,8 +98,14 @@ void SoundSDL::initialize(bool forcerestart) uInt32 fragsize = myOSystem->settings().getInt("fragsize"); SDL_AudioSpec desired; - desired.freq = 31400; +#ifndef PSP + desired.freq = 31400; desired.format = AUDIO_U8; +else + desired.freq = 44100; + desired.format = AUDIO_U16; +#endif + desired.channels = 1; desired.samples = fragsize; desired.callback = callback; @@ -138,7 +144,7 @@ void SoundSDL::initialize(bool forcerestart) */ // Now initialize the TIASound object which will actually generate sound - Tia_sound_init(31400, myHardwareSpec.freq); + Tia_sound_init(desired.freq, myHardwareSpec.freq); // And start the SDL sound subsystem ... SDL_PauseAudio(0); diff --git a/stella/src/common/mainSDL.cxx b/stella/src/common/mainSDL.cxx index 2ffa6f814..a976521ee 100644 --- a/stella/src/common/mainSDL.cxx +++ b/stella/src/common/mainSDL.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: mainSDL.cxx,v 1.48 2005-06-28 04:40:21 urchlay Exp $ +// $Id: mainSDL.cxx,v 1.49 2005-08-25 15:19:17 stephena Exp $ //============================================================================ #include @@ -45,9 +45,16 @@ #elif defined(MAC_OSX) #include "SettingsMACOSX.hxx" #include "OSystemMACOSX.hxx" -extern "C" { -int stellaMain(int argc, char* argv[]); -} + + extern "C" { + int stellaMain(int argc, char* argv[]); + } +#elif defined(PSP) + #include "SettingsPSP.hxx" + #include "OSystemPSP.hxx" + extern "C" { + int SDL_main(int argc, char* argv[]); + } #else #error Unsupported platform! #endif @@ -104,6 +111,8 @@ void Cleanup() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #if defined(MAC_OSX) int stellaMain(int argc, char* argv[]) +#elif defined(PSP) +int SDL_main(int argc, char* argv[]) #else int main(int argc, char* argv[]) #endif @@ -118,9 +127,15 @@ int main(int argc, char* argv[]) #elif defined(MAC_OSX) theOSystem = new OSystemMACOSX(); SettingsMACOSX settings(theOSystem); +#elif defined(PSP) + fprintf(stderr,"---------------- Stderr Begins ----------------\n"); + fprintf(stdout,"---------------- Stdout Begins ----------------\n"); + theOSystem = new OSystemPSP(); + SettingsPSP settings(theOSystem); #else #error Unsupported platform! #endif + theOSystem->settings().loadConfig(); // Take care of commandline arguments diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index 975295c7d..66f462412 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.cxx,v 1.86 2005-08-24 22:54:30 stephena Exp $ +// $Id: EventHandler.cxx,v 1.87 2005-08-25 15:19:17 stephena Exp $ //============================================================================ #include @@ -56,7 +56,12 @@ EventHandler::EventHandler(OSystem* osystem) myQuitFlag(false), myGrabMouseFlag(false), myUseLauncherFlag(false), - myPaddleMode(0) + myPaddleMode(0), + myMouseX(0), + myMouseY(0), + myLastMouseMoveX(0), + myLastMouseMoveY(0) + { // Add this eventhandler object to the OSystem myOSystem->attach(this); @@ -75,7 +80,7 @@ EventHandler::EventHandler(OSystem* osystem) for(Int32 i = 0; i < kNumJoysticks * kNumJoyButtons; ++i) myJoyTable[i] = Event::NoType; - // Erase the Message array + // Erase the Message array for(Int32 i = 0; i < Event::LastType; ++i) ourMessageTable[i] = ""; @@ -472,6 +477,7 @@ void EventHandler::poll(uInt32 time) break; // SDL_KEYUP, SDL_KEYDOWN } + case SDL_MOUSEMOTION: handleMouseMotionEvent(event); break; // SDL_MOUSEMOTION @@ -533,14 +539,19 @@ void EventHandler::poll(uInt32 time) code = event.jbutton.button; state = event.jbutton.state == SDL_PRESSED ? 1 : 0; - +#ifdef PSP + handleWarpMouseButton(code,state); +#endif handleJoyEvent(stick, code, state); break; case SDL_JOYAXISMOTION: axis = event.jaxis.axis; value = event.jaxis.value; - +#ifdef PSP + if (state!=S_EMULATE) + handleMouseWarp(stick,axis,value); +#endif if(axis == 0) // x-axis { handleJoyEvent(stick, kJAxisLeft, (value < -16384) ? 1 : 0); @@ -807,6 +818,126 @@ void EventHandler::handleMouseButtonEvent(SDL_Event& event, uInt8 state) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EventHandler::handleWarpMouseButton(uInt8 event_button, uInt8 state) +{ +#ifdef PSP + // Determine which mode we're in, then send the event to the appropriate place + switch(myState) + { + case S_EMULATE: + { + /* map joypad button to sdl key events*/ + if (event_button == 11){ /*start*/ + handleKeyEvent(0,SDLK_ESCAPE,(SDLMod)0,state); + } else if (event_button == 10){ /*select*/ + handleKeyEvent(0,SDLK_TAB,(SDLMod)0,state); + } else if (event_button == 6){ + handleKeyEvent(0,SDLK_UP,(SDLMod)0,state); + } else if (event_button == 8){ + handleKeyEvent(0,SDLK_DOWN,(SDLMod)0,state); + } else if (event_button == 9){ + handleKeyEvent(0,SDLK_RIGHT,(SDLMod)0,state); + } else if (event_button == 7){ + handleKeyEvent(0,SDLK_LEFT,(SDLMod)0,state); + } else if (event_button == 0){ /*triangle*/ + handleKeyEvent(0,SDLK_PAUSE,(SDLMod)0,state); + } else if (event_button == 2){ /*cross*/ + handleKeyEvent(0,SDLK_SPACE,(SDLMod)0,state); + } else if (event_button == 1){ /*circle*/ + handleKeyEvent(0,SDLK_F12,(SDLMod)0,state); + } else if (event_button == 3 && state){ /*square*/ + myOSystem->console().toggleFormat(); + } else if (event_button == 4){ /*left trigger*/ + handleKeyEvent(0,SDLK_F11,(SDLMod)0,state); + } else if (event_button == 5){ /*right trigger*/ + handleKeyEvent(0,SDLK_F9,(SDLMod)0,state); + } + break; + } + + case S_MENU: + case S_LAUNCHER: + case S_DEBUGGER: + { + /* map up and down buttions to sdl events */ + if (event_button == 8){ + handleKeyEvent(0,SDLK_UP,(SDLMod)0,state); + break; + } else if (event_button == 6){ + handleKeyEvent(0,SDLK_DOWN,(SDLMod)0,state); + break; + } + Int32 x = myMouseX; + Int32 y = myMouseY; + myOSystem->frameBuffer().translateCoords(&x, &y); + MouseButton button; + + /* enable 'select' button */ + if (event_button == 10 && state){ + handleKeyEvent(0,SDLK_TAB,(SDLMod)0,state); + break; + } + /* map the buttons to sdl mouse buttton events*/ + if(state) + { + if(event_button == 2) + button = EVENT_LBUTTONDOWN; + else if(event_button == 1) + button = EVENT_RBUTTONDOWN; + else + break; + } + else + { + if(event_button == 2) + button = EVENT_LBUTTONUP; + else if(event_button == 1) + button = EVENT_RBUTTONUP; + else + break; + } + + if(myState == S_MENU) + myOSystem->menu().handleMouseButtonEvent(button, x, y, state); + else if(myState == S_LAUNCHER) + myOSystem->launcher().handleMouseButtonEvent(button, x, y, state); + else + myOSystem->debugger().handleMouseButtonEvent(button, x, y, state); + break; + } + + default: + break; + } +#endif +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EventHandler::handleMouseWarp(uInt8 stick,uInt8 axis,Int16 value) +{ +#ifdef PSP + Int32 new_x = myMouseX; + Int32 new_y = myMouseY; + value = value / 4000; + if (axis == 0) + { + myLastMouseMoveX = value; + } + else if (axis == 1) + { + myLastMouseMoveY = value; + } + new_x += myLastMouseMoveX; + new_y += myLastMouseMoveY; + + if (new_x >=0 and new_x <= PSP_SCREEN_WIDTH) + myMouseX = new_x; + if (new_y >=0 and new_y <= PSP_SCREEN_HEIGHT) + myMouseY = new_y; + SDL_WarpMouse(myMouseX,myMouseY); +#endif +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EventHandler::handleJoyEvent(uInt8 stick, uInt32 code, uInt8 state) @@ -1293,17 +1424,22 @@ void EventHandler::loadState(int state) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EventHandler::takeSnapshot() { +#ifdef PSP_DEBUG + fprintf(stdout,"EventHandler::takeSnapshot\n"); +#endif + #ifdef SNAPSHOT_SUPPORT // Figure out the correct snapshot name string filename; string sspath = myOSystem->settings().getString("ssdir"); string ssname = myOSystem->settings().getString("ssname"); + char separator = ssname[ssname.length()-1] != '/' ? BSPF_PATH_SEPARATOR : ''; if(ssname == "romname") - sspath = sspath + BSPF_PATH_SEPARATOR + + sspath = sspath + separator + myOSystem->console().properties().get("Cartridge.Name"); else if(ssname == "md5sum") - sspath = sspath + BSPF_PATH_SEPARATOR + + sspath = sspath + separator + myOSystem->console().properties().get("Cartridge.MD5"); // Check whether we want multiple snapshots created @@ -1319,6 +1455,9 @@ void EventHandler::takeSnapshot() { buf.str(""); buf << sspath << "_" << i << ".png"; +#ifdef PSP_DEBUG + fprintf(stdout,"EventHandler::takeSnapshot '%s'\n",buf.str().c_str()); +#endif if(!FilesystemNode::fileExists(buf.str())) break; } @@ -1331,7 +1470,7 @@ void EventHandler::takeSnapshot() // Now create a Snapshot object and save the PNG myOSystem->frameBuffer().refresh(true); Snapshot snapshot(myOSystem->frameBuffer()); - string result = snapshot.savePNG(filename); + string result = snapshot.savePNG(filename); myOSystem->frameBuffer().showMessage(result); #else myOSystem->frameBuffer().showMessage("Snapshots unsupported"); diff --git a/stella/src/emucore/EventHandler.hxx b/stella/src/emucore/EventHandler.hxx index b75755039..81bac837b 100644 --- a/stella/src/emucore/EventHandler.hxx +++ b/stella/src/emucore/EventHandler.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.hxx,v 1.45 2005-08-11 19:12:38 stephena Exp $ +// $Id: EventHandler.hxx,v 1.46 2005-08-25 15:19:17 stephena Exp $ //============================================================================ #ifndef EVENTHANDLER_HXX @@ -74,7 +74,7 @@ struct Stella_Joystick { mapping can take place. @author Stephen Anthony - @version $Id: EventHandler.hxx,v 1.45 2005-08-11 19:12:38 stephena Exp $ + @version $Id: EventHandler.hxx,v 1.46 2005-08-25 15:19:17 stephena Exp $ */ class EventHandler { @@ -279,6 +279,8 @@ class EventHandler @param state state of code (pressed/released) */ void handleJoyEvent(uInt8 stick, uInt32 code, uInt8 state); + void handleMouseWarp(uInt8 stick, uInt8 axis, Int16 value); + void handleWarpMouseButton(uInt8 event_button, uInt8 state); /** The following methods take care of assigning action mappings. @@ -350,6 +352,11 @@ class EventHandler // The current joymap in string form string myJoymapString; + + Int32 myMouseX; + Int32 myMouseY; + Int32 myLastMouseMoveX; + Int32 myLastMouseMoveY; }; #endif diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index e82165089..8c5aadda0 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBuffer.cxx,v 1.64 2005-08-25 01:20:11 markgrebe Exp $ +// $Id: FrameBuffer.cxx,v 1.65 2005-08-25 15:19:17 stephena Exp $ //============================================================================ #include @@ -35,8 +35,10 @@ #include "Debugger.hxx" #endif -#ifdef MAC_OSX -#include "macOSXDisplay.h" +#if defined(MAC_OSX) + #include "macOSXDisplay.h" +#elif defined(PSP) + #include "DisplayPSP.hxx" #endif #include "stella.xpm" // The Stella icon @@ -85,31 +87,29 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height, } // Calculate the desktop size + // This is really the job of SDL myDesktopDim.w = myDesktopDim.h = 0; - - // Get the system-specific WM information +#if defined(UNIX) SDL_SysWMinfo myWMInfo; SDL_VERSION(&myWMInfo.version); - if(SDL_GetWMInfo(&myWMInfo) > 0) + if(SDL_GetWMInfo(&myWMInfo) > 0 && myWMInfo.subsystem == SDL_SYSWM_X11) { -#if defined(UNIX) - if(myWMInfo.subsystem == SDL_SYSWM_X11) - { - myWMInfo.info.x11.lock_func(); - myDesktopDim.w = DisplayWidth(myWMInfo.info.x11.display, - DefaultScreen(myWMInfo.info.x11.display)); - myDesktopDim.h = DisplayHeight(myWMInfo.info.x11.display, - DefaultScreen(myWMInfo.info.x11.display)); - myWMInfo.info.x11.unlock_func(); - } -#elif defined(WIN32) - myDesktopDim.w = (uInt16) GetSystemMetrics(SM_CXSCREEN); - myDesktopDim.h = (uInt16) GetSystemMetrics(SM_CYSCREEN); -#endif + myWMInfo.info.x11.lock_func(); + myDesktopDim.w = DisplayWidth(myWMInfo.info.x11.display, + DefaultScreen(myWMInfo.info.x11.display)); + myDesktopDim.h = DisplayHeight(myWMInfo.info.x11.display, + DefaultScreen(myWMInfo.info.x11.display)); + myWMInfo.info.x11.unlock_func(); } -#if defined(MAC_OSX) +#elif defined(WIN32) + myDesktopDim.w = (uInt16) GetSystemMetrics(SM_CXSCREEN); + myDesktopDim.h = (uInt16) GetSystemMetrics(SM_CYSCREEN); +#elif defined(MAC_OSX) myDesktopDim.w = macOSXDisplayWidth(); myDesktopDim.h = macOSXDisplayHeight(); +#elif defined(PSP) + myDesktopDim.w = PSP_SCREEN_WIDTH; + myDesktopDim.h = PSP_SCREEN_HEIGHT; #endif // Set fullscreen flag diff --git a/stella/src/emucore/OSystem.cxx b/stella/src/emucore/OSystem.cxx index 04ed17cf8..95db7a621 100644 --- a/stella/src/emucore/OSystem.cxx +++ b/stella/src/emucore/OSystem.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: OSystem.cxx,v 1.32 2005-08-24 22:54:30 stephena Exp $ +// $Id: OSystem.cxx,v 1.33 2005-08-25 15:19:17 stephena Exp $ //============================================================================ #include @@ -187,7 +187,6 @@ bool OSystem::createFrameBuffer(bool showmessage) // And recreate a new one string video = mySettings->getString("video"); -cout << " ==> video: " << video << endl; if(video == "soft") myFrameBuffer = new FrameBufferSoft(this); diff --git a/stella/src/emucore/Settings.cxx b/stella/src/emucore/Settings.cxx index dd1a33a04..d14febaa7 100644 --- a/stella/src/emucore/Settings.cxx +++ b/stella/src/emucore/Settings.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Settings.cxx,v 1.55 2005-08-24 01:07:36 stephena Exp $ +// $Id: Settings.cxx,v 1.56 2005-08-25 15:19:17 stephena Exp $ //============================================================================ #include @@ -84,6 +84,11 @@ void Settings::loadConfig() string line, key, value; string::size_type equalPos, garbage; + // FIXME - add infrastructure to print output +#ifdef PSP_DEBUG + fprintf(stdout,"Settings::loadConfig '%s'\n",myOSystem->configInputFilename().c_str()); +#endif + ifstream in(myOSystem->configInputFilename().c_str()); if(!in || !in.is_open()) { diff --git a/stella/src/emucore/m6502/src/bspf/src/bspf.hxx b/stella/src/emucore/m6502/src/bspf/src/bspf.hxx index 17ca5229e..c00af8314 100644 --- a/stella/src/emucore/m6502/src/bspf/src/bspf.hxx +++ b/stella/src/emucore/m6502/src/bspf/src/bspf.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: bspf.hxx,v 1.8 2005-07-20 17:49:26 stephena Exp $ +// $Id: bspf.hxx,v 1.9 2005-08-25 15:19:17 stephena Exp $ //============================================================================ #ifndef BSPF_HXX @@ -24,7 +24,7 @@ that need to be defined for different operating systems. @author Bradford W. Mott - @version $Id: bspf.hxx,v 1.8 2005-07-20 17:49:26 stephena Exp $ + @version $Id: bspf.hxx,v 1.9 2005-08-25 15:19:17 stephena Exp $ */ // Types for 8-bit signed and unsigned integers @@ -52,6 +52,10 @@ typedef unsigned int uInt32; using namespace std; #endif +#ifdef PSP + #include "pspstdint.h" +#endif + #ifdef HAVE_INTTYPES #include #endif @@ -63,6 +67,8 @@ typedef unsigned int uInt32; #define BSPF_PATH_SEPARATOR "\\" #elif defined BSPF_MAC_OSX #define BSPF_PATH_SEPARATOR "/" +#elif defined BSPF_PSP + #define BSPF_PATH_SEPARATOR "/" #endif // I wish Windows had a complete POSIX layer diff --git a/stella/src/gui/AboutDialog.cxx b/stella/src/gui/AboutDialog.cxx index ab36eaa78..775468caa 100644 --- a/stella/src/gui/AboutDialog.cxx +++ b/stella/src/gui/AboutDialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: AboutDialog.cxx,v 1.6 2005-08-11 21:57:30 stephena Exp $ +// $Id: AboutDialog.cxx,v 1.7 2005-08-25 15:19:17 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -111,6 +111,8 @@ void AboutDialog::updateStrings(int page, int lines, string& title, string* &dsc ADD_ATEXT("\\L\\c2"" Original author for OS/2 port"); ADD_ATEXT("\\L\\c0"" Doodle"); ADD_ATEXT("\\L\\c2"" Current maintainer for OS/2 port"); + ADD_ATEXT("\\L\\c0"" David Voswinkel"); + ADD_ATEXT("\\L\\c2"" Maintainer for PSP port"); break; case 4: diff --git a/stella/src/gui/VideoDialog.cxx b/stella/src/gui/VideoDialog.cxx index c3457819a..d68814584 100644 --- a/stella/src/gui/VideoDialog.cxx +++ b/stella/src/gui/VideoDialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: VideoDialog.cxx,v 1.22 2005-08-24 01:07:36 stephena Exp $ +// $Id: VideoDialog.cxx,v 1.23 2005-08-25 15:19:17 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -171,7 +171,6 @@ void VideoDialog::loadConfig() // Renderer setting s = instance()->settings().getString("video"); -cout << " ==> video: " << s << endl; if(s == "soft") myRendererPopup->setSelectedTag(1); else if(s == "hard") diff --git a/stella/src/psp/DisplayPSP.hxx b/stella/src/psp/DisplayPSP.hxx new file mode 100644 index 000000000..45d4ff98f --- /dev/null +++ b/stella/src/psp/DisplayPSP.hxx @@ -0,0 +1,27 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: DisplayPSP.hxx,v 1.1 2005-08-25 15:19:17 stephena Exp $ +//============================================================================ + +#ifndef DISPLAY_PSP_HXX +#define DISPLAY_PSP_HXX + +// FIXME - at some point, this should be integrated into either SDL or OSystem + +#define PSP_SCREEN_WIDTH 480 +#define PSP_SCREEN_HEIGHT 272 + +#endif diff --git a/stella/src/psp/FSNodePSP.cxx b/stella/src/psp/FSNodePSP.cxx new file mode 100644 index 000000000..038497cc0 --- /dev/null +++ b/stella/src/psp/FSNodePSP.cxx @@ -0,0 +1,285 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: FSNodePSP.cxx,v 1.1 2005-08-25 15:19:17 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#include "FSNode.hxx" + +#include +#include +#include +#include +#include + +/* + * Implementation of the Stella file system API based on POSIX for PSP + */ + +class PSPFilesystemNode : public AbstractFilesystemNode +{ + public: + PSPFilesystemNode(); + PSPFilesystemNode(const string& path); + PSPFilesystemNode(const PSPFilesystemNode* node); + + virtual string displayName() const { return _displayName; } + virtual bool isValid() const { return _isValid; } + virtual bool isDirectory() const { return _isDirectory; } + virtual string path() const { return _path; } + + virtual FSList listDir(ListMode mode = kListDirectoriesOnly) const; + virtual AbstractFilesystemNode* parent() const; + static void stripTailingSlashes(char * buf); + protected: + string _displayName; + bool _isDirectory; + bool _isValid; + string _path; +}; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +static const char* lastPathComponent(const string& str) +{ + const char *start = str.c_str(); + const char *cur = start + str.size() - 2; + + while (cur > start && *cur != '/') + --cur; + + return cur+1; +} + +static void stripTailingSlashes(char * buf) +{ + char * ptr; + ptr = buf + strlen(buf)-1; + while(*(ptr)=='/') *(ptr--)='\0'; +} +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +static string validatePath(const string& p) +{ + string path = p; + if(p.size() <= 0 || p[0] == '/') + path = "ms0:/"; + + return path; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +AbstractFilesystemNode* FilesystemNode::getRoot() +{ + return new PSPFilesystemNode(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +AbstractFilesystemNode* FilesystemNode::getNodeForPath(const string& path) +{ + return new PSPFilesystemNode(validatePath(path)); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +PSPFilesystemNode::PSPFilesystemNode() +{ + const char buf[] = "ms0:/stella/"; + _path = buf; + _displayName = string("stella"); + _isValid = true; + _isDirectory = true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +PSPFilesystemNode::PSPFilesystemNode(const string& p) +{ + string path = validatePath(p); + + Int32 len = 0, offset = path.size(); + SceIoStat st; + + _path = path; + + // Extract last component from path + const char *str = path.c_str(); + while (offset > 0 && str[offset-1] == '/') + offset--; + while (offset > 0 && str[offset-1] != '/') + { + len++; + offset--; + } + _displayName = string(str + offset, len); + + // Check whether it is a directory, and whether the file actually exists + //_isValid = (0 == stat(_path.c_str(), &st)); + //_isDirectory = S_ISDIR(st.st_mode); + _isValid = (0 == sceIoGetstat(_path.c_str(), &st)); + _isDirectory = FIO_S_ISDIR(st.st_mode); + +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +PSPFilesystemNode::PSPFilesystemNode(const PSPFilesystemNode* node) +{ + _displayName = node->_displayName; + _isValid = node->_isValid; + _isDirectory = node->_isDirectory; + _path = node->_path; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +FSList PSPFilesystemNode::listDir(ListMode mode) const +{ +// assert(_isDirectory); + FSList myList; + SceUID dfd = sceIoDopen (_path.c_str()); + SceIoDirent *dp; + dp = (SceIoDirent*)malloc(sizeof(SceIoDirent)); +#ifdef PSP_DEBUG + fprintf(stdout,"PSPFilesystemNode::listDir: dir='%s'\n",_path.c_str()); +#endif + + if (!dfd){ +#ifdef PSP_DEBUG + fprintf(stdout,"PSPFilesystemNode::listDir: no dir handle\n"); +#endif + return myList; + } + + while (sceIoDread(dfd,dp) > 0){ + + if (dp->d_name[0]=='.') + continue; + + PSPFilesystemNode entry; + entry._displayName = dp->d_name; + entry._path = _path; + if (entry._path.length() > 0 && entry._path[entry._path.length()-1] != '/') + entry._path += "/"; + + entry._path += dp->d_name; + entry._isDirectory = dp->d_stat.st_attr & FIO_SO_IFDIR; + + // Honor the chosen mode + if ((mode == kListFilesOnly && entry._isDirectory) || + (mode == kListDirectoriesOnly && !entry._isDirectory)) + continue; + + if (entry._isDirectory) + entry._path += "/"; + + myList.push_back(wrap(new PSPFilesystemNode(&entry))); + } + sceIoDclose(dfd); + free(dp); + return myList; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +AbstractFilesystemNode *PSPFilesystemNode::parent() const +{ + if (_path == "/") + return 0; + + PSPFilesystemNode* p = new PSPFilesystemNode(); + const char *start = _path.c_str(); + const char *end = lastPathComponent(_path); + + p->_path = string(start, end - start); + p->_displayName = lastPathComponent(p->_path); + + p->_isValid = true; + p->_isDirectory = true; + + return p; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool AbstractFilesystemNode::fileExists(const string& path) +{ + SceIoStat st; +#ifdef PSP_DEBUG + fprintf(stdout,"AbstractFilesystemNode::fileExists '%s'\n",path.c_str()); +#endif + if(sceIoGetstat(path.c_str(), &st) != 0){ +#ifdef PSP_DEBUG + fprintf(stdout,"AbstractFilesystemNode::fileExists error \n"); +#endif + return false; + } +#ifdef PSP_DEBUG + fprintf(stdout,"AbstractFilesystemNode::fileExists return '%i'\n", !FIO_SO_ISREG(st.st_mode)); +#endif + return !FIO_SO_ISREG(st.st_mode); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool AbstractFilesystemNode::dirExists(const string& in) +{ + char tmp_buf[1024]; + strncpy(tmp_buf,in.c_str(),1023); + stripTailingSlashes(tmp_buf); + string path = (char*)tmp_buf; +#ifdef PSP_DEBUG + fprintf(stdout,"AbstractFilesystemNode::dirExists '%s'\n", path.c_str()); +#endif + SceIoStat st; + if(sceIoGetstat(path.c_str(), &st) != 0) + return false; +#ifdef PSP_DEBUG + fprintf(stdout,"AbstractFilesystemNode::dirExists return '%i'\n", !FIO_SO_ISDIR(st.st_mode)); +#endif + return !FIO_SO_ISDIR(st.st_mode); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool AbstractFilesystemNode::makeDir(const string& path) +{ + return sceIoMkdir(path.c_str(), 0777) == 0; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string AbstractFilesystemNode::modTime(const string& in) +{ + char tmp_buf[1024]; + strncpy(tmp_buf,in.c_str(),1023); + stripTailingSlashes(tmp_buf); + string path = (char*)tmp_buf; + SceIoStat st; +#ifdef PSP_DEBUG + fprintf(stdout,"AbstractFilesystemNode::modTime '%s'\n",path.c_str()); +#endif + + if(sceIoGetstat(path.c_str(), &st) < 0){ +#ifdef PSP_DEBUG + fprintf(stdout,"AbstractFilesystemNode::modTime returns error\n"); +#endif + return ""; + } + ostringstream buf; + buf << (unsigned short)st.st_mtime.year + << (unsigned short)st.st_mtime.month + << (unsigned short)st.st_mtime.day + << (unsigned short)st.st_mtime.hour + << (unsigned short)st.st_mtime.minute + << (unsigned short)st.st_mtime.second; + +#ifdef PSP_DEBUG + fprintf(stdout,"AbstractFilesystemNode::modTime returns '%s'\n",buf.str().c_str()); +#endif + return buf.str(); +} diff --git a/stella/src/psp/OSystemPSP.cxx b/stella/src/psp/OSystemPSP.cxx new file mode 100644 index 000000000..cdc7601a6 --- /dev/null +++ b/stella/src/psp/OSystemPSP.cxx @@ -0,0 +1,168 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: OSystemPSP.cxx,v 1.1 2005-08-25 15:19:17 stephena Exp $ +//============================================================================ + +#include +#include +#include + +#include +#include +#include + +#include "bspf.hxx" +#include "OSystem.hxx" +#include "OSystemPSP.hxx" + +#ifdef HAVE_GETTIMEOFDAY + #include + #include +#endif + + +/** + Each derived class is responsible for calling the following methods + in its constructor: + + setBaseDir() + setStateDir() + setPropertiesFiles() + setConfigFiles() + setCacheFile() + + And for initializing the following variables: + + myDriverList (a StringList) + + See OSystem.hxx for a further explanation +*/ + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OSystemPSP::OSystemPSP() +{ + // First set variables that the OSystem needs + string basedir = string("ms0:/stella"); + setBaseDir(basedir); + + string statedir = basedir + "/state"; + setStateDir(statedir); + + string userPropertiesFile = basedir + "/stella.pro"; + string systemPropertiesFile = "/etc/stella.pro"; + setPropertiesFiles(userPropertiesFile, systemPropertiesFile); + + string userConfigFile = basedir + "/stellarc"; + string systemConfigFile = "/etc/stellarc"; + setConfigFiles(userConfigFile, systemConfigFile); + + string cacheFile = basedir + "/stella.cache"; + setCacheFile(cacheFile); + + // No drivers are specified for Unix +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OSystemPSP::~OSystemPSP() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void OSystemPSP::mainLoop() +{ + // These variables are common to both timing options + // and are needed to calculate the overall frames per second. + uInt32 frameTime = 0, numberOfFrames = 0; + + if(mySettings->getBool("accurate")) // normal, CPU-intensive timing + { + // Set up accurate timing stuff + uInt32 startTime, delta; + + // Set the base for the timers + frameTime = 0; + + // Main game loop + for(;;) + { + // Exit if the user wants to quit + if(myEventHandler->doQuit()){ + break; + } + startTime = getTicks(); + myEventHandler->poll(startTime); + myFrameBuffer->update(); + + // Now, waste time if we need to so that we are at the desired frame rate + for(;;) + { + delta = getTicks() - startTime; + + if(delta >= myTimePerFrame) + break; + } + + frameTime += getTicks() - startTime; + ++numberOfFrames; + } + } + else // less accurate, less CPU-intensive timing + { + // Set up less accurate timing stuff + uInt32 startTime, virtualTime, currentTime; + + // Set the base for the timers + virtualTime = getTicks(); + frameTime = 0; + + + // Main game loop + for(;;) + { + // Exit if the user wants to quit + if(myEventHandler->doQuit()){ + break; + } + + startTime = getTicks(); + myEventHandler->poll(startTime); + myFrameBuffer->update(); + currentTime = getTicks(); + virtualTime += myTimePerFrame; + if(currentTime < virtualTime) + { + SDL_Delay((virtualTime - currentTime)/1000); + } + currentTime = getTicks() - startTime; + frameTime += currentTime; + ++numberOfFrames; + } + } + +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +uInt32 OSystemPSP::getTicks() +{ +#if defined(HAVE_GETTIMEOFDAY) + timeval now; + gettimeofday(&now, 0); + return (uInt32) (now.tv_sec * 1000000 + now.tv_usec); +#else + return (uInt32) SDL_GetTicks() * 1000; +#endif +} + diff --git a/stella/src/psp/OSystemPSP.hxx b/stella/src/psp/OSystemPSP.hxx new file mode 100644 index 000000000..48f3d0bdc --- /dev/null +++ b/stella/src/psp/OSystemPSP.hxx @@ -0,0 +1,60 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: OSystemPSP.hxx,v 1.1 2005-08-25 15:19:17 stephena Exp $ +//============================================================================ + +#ifndef OSYSTEM_PSP_HXX +#define OSYSTEM_PSP_HXX + +#include "bspf.hxx" + + +/** + This class defines PSP-like OS's (Linux) system specific settings. + + @author Stephen Anthony + @version $Id: OSystemPSP.hxx,v 1.1 2005-08-25 15:19:17 stephena Exp $ +*/ +class OSystemPSP : public OSystem +{ + public: + /** + Create a new PSP-specific operating system object + */ + OSystemPSP(); + + /** + Destructor + */ + virtual ~OSystemPSP(); + + public: + /** + This method runs the main loop. Since different platforms + may use different timing methods and/or algorithms, this method has + been abstracted to each platform. + */ + virtual void mainLoop(); + + /** + This method returns number of ticks in microseconds. + + @return Current time in microseconds. + */ + virtual uInt32 getTicks(); +}; + +#endif diff --git a/stella/src/psp/SettingsPSP.cxx b/stella/src/psp/SettingsPSP.cxx new file mode 100644 index 000000000..64c790c3e --- /dev/null +++ b/stella/src/psp/SettingsPSP.cxx @@ -0,0 +1,39 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: SettingsPSP.cxx,v 1.1 2005-08-25 15:19:17 stephena Exp $ +//============================================================================ + +#include "bspf.hxx" +#include "Settings.hxx" +#include "SettingsPSP.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +SettingsPSP::SettingsPSP(OSystem* osystem) + : Settings(osystem) +{ + set("accurate", "false"); + set("zoom", "1"); + set("romdir", "ms0:/stella/roms/"); + set("ssdir", "ms0:/stella/snapshots/"); + set("grabmouse", "1"); + set("sound", "true"); + +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +SettingsPSP::~SettingsPSP() +{ +} diff --git a/stella/src/psp/SettingsPSP.hxx b/stella/src/psp/SettingsPSP.hxx new file mode 100644 index 000000000..302009e84 --- /dev/null +++ b/stella/src/psp/SettingsPSP.hxx @@ -0,0 +1,46 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: SettingsPSP.hxx,v 1.1 2005-08-25 15:19:17 stephena Exp $ +//============================================================================ + +#ifndef SETTINGS_PSP_HXX +#define SETTINGS_PSP_HXX + +class OSystem; + +#include "bspf.hxx" + +/** + This class defines PSP-like OS's (Linux) system specific settings. + + @author Stephen Anthony + @version $Id: SettingsPSP.hxx,v 1.1 2005-08-25 15:19:17 stephena Exp $ +*/ +class SettingsPSP : public Settings +{ + public: + /** + Create a new PSP settings object + */ + SettingsPSP(OSystem* osystem); + + /** + Destructor + */ + virtual ~SettingsPSP(); +}; + +#endif diff --git a/stella/src/psp/data/ICON0.PNG b/stella/src/psp/data/ICON0.PNG new file mode 100644 index 000000000..a8cdf9e54 Binary files /dev/null and b/stella/src/psp/data/ICON0.PNG differ diff --git a/stella/src/psp/data/PIC1.PNG b/stella/src/psp/data/PIC1.PNG new file mode 100644 index 000000000..7841d36e5 Binary files /dev/null and b/stella/src/psp/data/PIC1.PNG differ diff --git a/stella/src/psp/data/stellarc.psp b/stella/src/psp/data/stellarc.psp new file mode 100644 index 000000000..dae92dc21 --- /dev/null +++ b/stella/src/psp/data/stellarc.psp @@ -0,0 +1,40 @@ +; Stella configuration file +; +; Lines starting with ';' are comments and are ignored. +; Spaces and tabs are ignored. +; +; Format MUST be as follows: +; command = value +; +; Commmands are the same as those specified on the commandline, +; without the '-' character. +; +; Values are the same as those allowed on the commandline. +; Boolean values are specified as 1 (or true) and 0 (or false) +; +video = soft +video_driver = +gl_filter = nearest +gl_aspect = 2.0 +gl_fsmax = false +zoom = 1 +fullscreen = false +grabmouse = 1 +center = true +palette = standard +debugheight = 20 +sound = 1 +fragsize = 1024 +volume = 100 +keymap = 0:0:0:0:0:0:0:0:74:71:0:0:0:0:0:0:0:0:0:69:0:0:0:0:0:0:0:73:0:0:0:0:15:0:0:0:0:0:0:0:0:0:0:0:54:0:55:56:47:33:34:35:21:22:23:24:45:46:0:53:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:72:39:0:44:41:38:20:18:17:48:19:51:52:0:0:49:50:36:0:40:0:0:0:37:43:16:42:0:0:0:0:62:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:11:12:14:13:58:60:64:57:61:9:10:3:4:5:6:7:8:67:65:66:68:0:0:0:0:0:0:0:0:0:0:0:0:15:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0: +joymap = 15:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:11:12:13:14:20:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:16:17:18:19:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0: +paddle = 0 +showinfo = false +ssdir = ms0:/stella/snapshots/ +ssname = romname +sssingle = false +romdir = ms0:/stella/roms/ +lastrom = +modtime = 2005820191330 +accurate = false +break = diff --git a/stella/src/psp/module.mk b/stella/src/psp/module.mk new file mode 100644 index 000000000..06921040a --- /dev/null +++ b/stella/src/psp/module.mk @@ -0,0 +1,12 @@ +MODULE := src/psp + +MODULE_OBJS := \ + src/psp/FSNodePSP.o \ + src/psp/OSystemPSP.o \ + src/psp/SettingsPSP.o + +MODULE_DIRS += \ + src/psp + +# Include common rules +include $(srcdir)/common.rules diff --git a/stella/src/psp/pspstdint.h b/stella/src/psp/pspstdint.h new file mode 100644 index 000000000..32620ddee --- /dev/null +++ b/stella/src/psp/pspstdint.h @@ -0,0 +1,175 @@ +/* SCE CONFIDENTIAL + PSP(TM) Programmer Tool Runtime Library Release 1.5.0 + * + * Copyright (C) 2005 Sony Computer Entertainment Inc. + * All Rights Reserved. + * + */ +/* + * + * PSP(TM) integer types + * + * pspstdint.h + * + * Version Date Design Log + * -------------------------------------------------------------------- + * 0.00 2005-01-19 kono the first version + */ + + +#ifndef _SCE_PSPSTDINT_H +#define _SCE_PSPSTDINT_H + +/* Exact-width integer types */ +#ifndef _SCE_PSPSTDINT_int8_t_DEFINED +#define _SCE_PSPSTDINT_int8_t_DEFINED +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +typedef unsigned int uint32_t; +#if defined(__GNUC__) +__extension__ typedef long long int64_t __attribute__((mode(DI))); +__extension__ typedef unsigned long long uint64_t __attribute__((mode(DI))); +#else /* defined(__GNUC__) */ +typedef long long int64_t; +typedef unsigned long long uint64_t; +#endif /* defined(__GNUC__) */ +#endif /* _SCE_PSPSTDINT_int8_t_DEFINED */ + + +/* Minimum-width integer types */ +#ifndef _SCE_PSPSTDINT_int_least8_t_DEFINED +#define _SCE_PSPSTDINT_int_least8_t_DEFINED +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int_least16_t; +typedef unsigned short uint_least16_t; +typedef int int_least32_t; +typedef unsigned int uint_least32_t; +#if defined(__GNUC__) +__extension__ typedef long long int_least64_t __attribute__((mode(DI))); +__extension__ typedef unsigned long long uint_least64_t __attribute__((mode(DI))); +#else /* defined(__GNUC__) */ +typedef long long int_least64_t; +typedef unsigned long long uint_least64_t; +#endif /* defined(__GNUC__) */ +#endif /* _SCE_PSPSTDINT_int_least8_t_DEFINED */ + + +/* Fastest minimum-width integer types */ +#ifndef _SCE_PSPSTDINT_int_fast8_t_DEFINED +#define _SCE_PSPSTDINT_int_fast8_t_DEFINED +typedef char int_fast8_t; +typedef unsigned char uint_fast8_t; +typedef int int_fast16_t; +typedef unsigned int uint_fast16_t; +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; +#if defined(__GNUC__) +__extension__ typedef long long int_fast64_t __attribute__((mode(DI))); +__extension__ typedef unsigned long long uint_fast64_t __attribute__((mode(DI))); +#else /* defined(__GNUC__) */ +typedef long long int_fast64_t; +typedef unsigned long long uint_fast64_t; +#endif /* defined(__GNUC__) */ +#endif /* _SCE_PSPSTDINT_int_fast8_t_DEFINED */ + + +/* Integer types capable of holding object pointers */ +#ifndef _SCE_PSPSTDINT_intptr_t_DEFINED +#define _SCE_PSPSTDINT_intptr_t_DEFINED +typedef int intptr_t; +typedef unsigned int uintptr_t; +#endif /* _SCE_PSPSTDINT_intptr_t_DEFINED */ + + +/* Gereat-width integer types */ +#ifndef _SCE_PSPSTDINT_intmax_t_DEFINED +#define _SCE_PSPSTDINT_intmax_t_DEFINED +#if defined(__GNUC__) +typedef long long intmax_t __attribute__((mode(DI))); +typedef unsigned long long uintmax_t __attribute__((mode(DI))); +#else /* defined(__GNUC__) */ +typedef long long intmax_t; +typedef unsigned long long uintmax_t; +#endif /* defined(__GNUC__) */ +#endif /* _SCE_PSPSTDINT_intmax_t_DEFINED */ + + +/* Limits of specified-width intger types */ +#if (!(defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)))||defined(__STDC_CONSTANT_MACROS) + +/* Limits of exact-width integer types */ +#define INT8_MIN (-128) +#define INT16_MIN (-32767-1) +#define INT32_MIN (-2147483647-1) +#define INT64_MIN (-9223372036854775807LL-1) +#define INT8_MAX (127) +#define INT16_MAX (32767) +#define INT32_MAX (2147483647) +#define INT64_MAX (9223372036854775807LL) +#define UINT8_MAX (255) +#define UINT16_MAX (65535) +#define UINT32_MAX (4294967295U) +#define UINT64_MAX (18446744073709551615ULL) + +/* Limits of minimum-width integer types */ +#define INT_LEAST8_MIN (-128) +#define INT_LEAST16_MIN (-32767-1) +#define INT_LEAST32_MIN (-2147483647-1) +#define INT_LEAST64_MIN (-9223372036854775807LL-1) +#define INT_LEAST8_MAX (127) +#define INT_LEAST16_MAX (32767) +#define INT_LEAST32_MAX (2147483647) +#define INT_LEAST64_MAX (9223372036854775807LL) +#define UINT_LEAST8_MAX (255) +#define UINT_LEAST16_MAX (65535) +#define UINT_LEAST32_MAX (4294967295U) +#define UINT_LEAST64_MAX (18446744073709551615ULL) + +/* Limits of fastest minimum-width integer types */ +#define INT_FAST8_MIN (-128) +#define INT_FAST16_MIN (-2147483647-1) +#define INT_FAST32_MIN (-2147483647-1) +#define INT_FAST64_MIN (-9223372036854775807LL-1) +#define INT_FAST8_MAX (127) +#define INT_FAST16_MAX (2147483647) +#define INT_FAST32_MAX (2147483647) +#define INT_FAST64_MAX (9223372036854775807LL) +#define UINT_FAST8_MAX (255) +#define UINT_FAST16_MAX (4294967295U) +#define UINT_FAST32_MAX (4294967295U) +#define UINT_FAST64_MAX (18446744073709551615ULL) + +/* Limits of integer types capable of holding object pointers */ +#define INTPTR_MIN (-2147483647-1) +#define INTPTR_MAX (2147483647) +#define UINTPTR_MAX (4294967295U) + +/* Limits of greates-width intger types */ +#define INTMAX_MIN (-9223372036854775807LL-1) +#define INTMAX_MAX (9223372036854775807LL) +#define UINTMAX_MAX (18446744073709551615ULL) + + +/* Macros for minimum-width integer constants */ +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#define INT64_C(c) c ## LL +#define UINT8_C(c) c ## U +#define UINT16_C(c) c ## U +#define UINT32_C(c) c ## U +#define UINT64_C(c) c ## ULL + +/* Macros for greatest-width integer constants */ +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL + + +#endif /* (!(defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)))||defined(__STDC_CONSTANT_MACROS) */ + +#endif /* _SCE_PSPSTDINT_H */ +