Ticket #8871: scummvm-wii-take5.diff
File scummvm-wii-take5.diff, 61.1 KB (added by , 16 years ago) |
---|
-
dists/wii/meta.xml
1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 2 <app version="1"> 3 <name>ScummVM</name> 4 <coder>The ScummVM Team</coder> 5 <version>rev FIXME</version> 6 <release_date>FIXME</release_date> 7 <short_description>Point & Click Adventures</short_description> 8 <long_description>ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed! 9 10 Some of the adventures ScummVM supports include Adventure Soft's Simon the Sorcerer 1 and 2; Revolution's Beneath A Steel Sky, Broken Sword 1 and Broken Sword 2; Flight of the Amazon Queen; Wyrmkeep's Inherit the Earth; Coktel Vision's Gobliiins; Westwood Studios' The Legend of Kyrandia and games based on LucasArts' SCUMM (Script Creation Utility for Maniac Mansion) system such as Monkey Island, Day of the Tentacle, Sam and Max and more.</long_description> 11 </app> 12 -
dists/wii/READMII
1 Wii port of ScummVM README 2 -------------------------- 3 4 features not compiled in: 5 - the AGI game engine 6 7 REQUIREMENTS 8 9 - sd card 10 - wiimote or gamecube controller in port 1 11 12 INSTALL 13 14 - copy the "apps" folder to the root of your sd card 15 - copy your demos and/or games onto the same sd card 16 each game goes into its own subdirectory, do not place those under 17 "/apps/scummvm", and do not set the "theme" or "extra" path to that folder 18 freeware versions: http://scummvm.org/downloads.php#extras 19 demos: http://scummvm.org/demos.php 20 21 RUN 22 23 either use the homebrew channel, available at 24 25 http://hbc.hackmii.com/ 26 27 or load "boot.dol" with your favorite loader 28 29 CONTROLS 30 31 wiimote 32 33 analog stick: mouse movement 34 a: left mouse button 35 b: right mouse button 36 minus: escape 37 plus: "." (skip current line of text) 38 2: enter 39 home: f5 (scummvm menu) 40 dpad up: shift (mass add for the gui) 41 dpad down: "0" 42 dpad left: "y" 43 dpad right: "n" 44 45 gamecube pad 46 47 analog stick: mouse movement 48 a: left mouse button 49 b: right mouse button 50 x: escape 51 y: "." (skip current line of text) 52 z: enter 53 start: f5 (scummvm menu) 54 dpad up: shift (mass add for the gui) 55 dpad down: "0" 56 dpad left: "y" 57 dpad right: "n" 58 59 THANKS 60 61 shagkur and WinterMute, for devkitppc/libogc and the coorperation 62 svpe, for fixing the libfat feof/thread bugs on the last minute 63 para, for making wiiuse available in libogc 64 -
common/scummsys.h
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: dists/wii/icon.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
369 369 #define STRINGBUFLEN 256 370 370 #define printf(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__) 371 371 372 #elif defined(__WII__) 373 374 #define scumm_stricmp strcasecmp 375 #define scumm_strnicmp strncasecmp 376 377 #define SCUMM_BIG_ENDIAN 378 #define SCUMM_NEED_ALIGNMENT 379 372 380 #else 373 381 #error No system type defined 374 382 -
common/system.cpp
137 137 #endif 138 138 139 139 FilesystemFactory *OSystem::getFilesystemFactory() { 140 #if defined(__amigaos4__) || defined(__DC__) || defined(__SYMBIAN32__) || defined(UNIX) || defined(WIN32) || defined(__ PSP__) || defined(__DS__)140 #if defined(__amigaos4__) || defined(__DC__) || defined(__SYMBIAN32__) || defined(UNIX) || defined(WIN32) || defined(__WII__) || defined(__PSP__) || defined(__DS__) 141 141 // These ports already implement this function, so it should never be called. 142 142 return 0; 143 143 #elif defined(PALMOS_MODE) -
backends/platform/wii/gecko_console.h
1 #ifndef _WII_GECKO_CONSOLE_H_ 2 #define _WII_GECKO_CONSOLE_H_ 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 void gecko_console_init(int chain); 9 10 #ifdef __cplusplus 11 } 12 #endif 13 14 #endif -
backends/platform/wii/osystem.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 */ 21 22 #include "osystem.h" 23 #include "backends/fs/wii/wii-fs-factory.h" 24 25 #include <unistd.h> 26 27 #include <ogc/mutex.h> 28 #include <ogc/lwp_watchdog.h> 29 30 OSystem_Wii::OSystem_Wii() : 31 _startup_time(0), 32 _alarm(-1), 33 34 _palette(NULL), 35 _cursorPalette(NULL), 36 _cursorPaletteDisabled(true), 37 38 _gameWidth(0), 39 _gameHeight(0), 40 _gamePixels(NULL), 41 42 _overlayVisible(false), 43 _overlayWidth(0), 44 _overlayHeight(0), 45 _overlaySize(0), 46 _overlayPixels(NULL), 47 48 _lastScreenUpdate(0), 49 _texture(NULL), 50 _currentWidth(0), 51 _currentHeight(0), 52 53 _supportedGraphicsModes(NULL), 54 _activeGraphicsMode(-1), 55 56 _mouseVisible(false), 57 _mouseX(0), 58 _mouseY(0), 59 _mouseWidth(0), 60 _mouseHeight(0), 61 _mouseHotspotX(0), 62 _mouseHotspotY(0), 63 _mouseKeyColor(0), 64 _mouseCursor(NULL), 65 66 _savefile(NULL), 67 _mixer(NULL), 68 _timer(NULL) { 69 } 70 71 OSystem_Wii::~OSystem_Wii() { 72 if (_savefile) { 73 delete _savefile; 74 _savefile = NULL; 75 } 76 77 if (_mixer) { 78 delete _mixer; 79 _mixer = NULL; 80 } 81 82 if (_timer) { 83 delete _timer; 84 _timer = NULL; 85 } 86 } 87 88 void OSystem_Wii::initBackend() { 89 _startup_time = gettime(); 90 91 _savefile = new DefaultSaveFileManager(); 92 _mixer = new Audio::Mixer(); 93 _timer = new DefaultTimerManager(); 94 95 initGfx(); 96 initSfx(); 97 initEvents(); 98 99 OSystem::initBackend(); 100 } 101 102 void OSystem_Wii::quit() { 103 deinitEvents(); 104 deinitSfx(); 105 deinitGfx(); 106 } 107 108 bool OSystem_Wii::hasFeature(Feature f) { 109 return f == kFeatureCursorHasPalette; 110 } 111 112 void OSystem_Wii::setFeatureState(Feature f, bool enable) { 113 } 114 115 bool OSystem_Wii::getFeatureState(Feature f) { 116 return false; 117 } 118 119 uint32 OSystem_Wii::getMillis() { 120 return ticks_to_millisecs(diff_ticks(_startup_time, gettime())); 121 } 122 123 void OSystem_Wii::delayMillis(uint msecs) { 124 usleep(msecs * 1000); 125 } 126 127 OSystem::MutexRef OSystem_Wii::createMutex() { 128 mutex_t *mutex = (mutex_t *) malloc(sizeof(mutex_t)); 129 s32 res = LWP_MutexInit(mutex, false); 130 131 if (res) { 132 printf("ERROR creating mutex\n"); 133 delete mutex; 134 return NULL; 135 } 136 137 return (MutexRef) mutex; 138 } 139 140 void OSystem_Wii::lockMutex(MutexRef mutex) { 141 s32 res = LWP_MutexLock(*(mutex_t *) mutex); 142 143 if (res) 144 printf("ERROR locking mutex %p (%d)\n", mutex, res); 145 } 146 147 void OSystem_Wii::unlockMutex(MutexRef mutex) { 148 s32 res = LWP_MutexUnlock(*(mutex_t *) mutex); 149 150 if (res) 151 printf("ERROR unlocking mutex %p (%d)\n", mutex, res); 152 } 153 154 void OSystem_Wii::deleteMutex(MutexRef mutex) { 155 s32 res = LWP_MutexDestroy(*(mutex_t *) mutex); 156 157 if (res) 158 printf("ERROR destroying mutex %p (%d)\n", mutex, res); 159 } 160 161 void OSystem_Wii::setWindowCaption(const char *caption) { 162 printf("window caption: %s\n", caption); 163 } 164 165 Common::SaveFileManager *OSystem_Wii::getSavefileManager() { 166 assert(_savefile); 167 return _savefile; 168 } 169 170 Audio::Mixer *OSystem_Wii::getMixer() { 171 assert(_mixer); 172 return _mixer; 173 } 174 175 Common::TimerManager *OSystem_Wii::getTimerManager() { 176 assert(_timer); 177 return _timer; 178 } 179 180 FilesystemFactory *OSystem_Wii::getFilesystemFactory() { 181 return &WiiFilesystemFactory::instance(); 182 } 183 184 void OSystem_Wii::getTimeAndDate(struct tm &t) const { 185 time_t curTime = time(0); 186 t = *localtime(&curTime); 187 } 188 -
backends/platform/wii/osystem_sfx.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 */ 21 22 #include <malloc.h> 23 24 #include "osystem.h" 25 26 #define SFX_THREAD_STACKSIZE (1024 * 128) 27 #define SFX_THREAD_PRIO 80 28 #define SFX_THREAD_FRAG_SIZE 4096 29 30 static lwpq_t sfx_queue; 31 static lwp_t sfx_thread; 32 static u8 *sfx_stack; 33 static bool sfx_thread_running = false; 34 static bool sfx_thread_quit = false; 35 36 static u8 sb = 0; 37 static u8 *sound_buffer[2]; 38 39 static OSystem_Wii::SoundProc sound_proc = NULL; 40 static void *proc_param = NULL; 41 42 static void audio_switch_buffers() { 43 AUDIO_StopDMA(); 44 AUDIO_InitDMA((u32) sound_buffer[sb], SFX_THREAD_FRAG_SIZE); 45 AUDIO_StartDMA(); 46 47 LWP_ThreadSignal(sfx_queue); 48 } 49 50 static void * sfx_thread_func(void *arg) { 51 u8 next_sb; 52 53 while (true) { 54 LWP_ThreadSleep(sfx_queue); 55 56 if (sfx_thread_quit) 57 break; 58 59 next_sb = sb ^ 1; 60 sound_proc(proc_param, sound_buffer[next_sb], SFX_THREAD_FRAG_SIZE); 61 DCFlushRange(sound_buffer[next_sb], SFX_THREAD_FRAG_SIZE); 62 63 sb = next_sb; 64 } 65 66 return NULL; 67 } 68 69 void OSystem_Wii::initSfx() { 70 sfx_thread_running = false; 71 sfx_thread_quit = false; 72 73 sfx_stack = (u8 *) memalign(32, SFX_THREAD_STACKSIZE); 74 memset(sfx_stack, 0, SFX_THREAD_STACKSIZE); 75 76 LWP_InitQueue(&sfx_queue); 77 78 s32 res = LWP_CreateThread(&sfx_thread, sfx_thread_func, NULL, sfx_stack, 79 SFX_THREAD_STACKSIZE, SFX_THREAD_PRIO); 80 81 if (res) { 82 printf("ERROR creating sfx thread: %d\n", res); 83 LWP_CloseQueue(sfx_queue); 84 return; 85 } 86 87 sfx_thread_running = true; 88 89 sound_buffer[0] = (u8 *) memalign(32, SFX_THREAD_FRAG_SIZE); 90 sound_buffer[1] = (u8 *) memalign(32, SFX_THREAD_FRAG_SIZE); 91 92 memset(sound_buffer[0], 0, SFX_THREAD_FRAG_SIZE); 93 memset(sound_buffer[1], 0, SFX_THREAD_FRAG_SIZE); 94 95 DCFlushRange(sound_buffer[0], SFX_THREAD_FRAG_SIZE); 96 DCFlushRange(sound_buffer[1], SFX_THREAD_FRAG_SIZE); 97 98 sound_proc = Audio::Mixer::mixCallback; 99 proc_param = _mixer; 100 101 _mixer->setReady(true); 102 103 AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); 104 AUDIO_RegisterDMACallback(audio_switch_buffers); 105 106 audio_switch_buffers(); 107 } 108 109 void OSystem_Wii::deinitSfx() { 110 if (_mixer) 111 _mixer->setReady(false); 112 113 AUDIO_StopDMA(); 114 AUDIO_RegisterDMACallback(NULL); 115 116 if (sfx_thread_running) { 117 sfx_thread_quit = true; 118 LWP_ThreadBroadcast(sfx_queue); 119 120 LWP_JoinThread(sfx_thread, NULL); 121 LWP_CloseQueue(sfx_queue); 122 123 sfx_thread_running = false; 124 125 free(sound_buffer[0]); 126 free(sound_buffer[1]); 127 } 128 } 129 130 int OSystem_Wii::getOutputSampleRate() const { 131 return 48000; 132 } 133 -
backends/platform/wii/main.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 */ 21 22 #include <fat.h> 23 #include <sys/stat.h> 24 #include <sys/types.h> 25 #include <errno.h> 26 #include <unistd.h> 27 28 #include "osystem.h" 29 30 #ifdef DEBUG_WII 31 #include <debug.h> 32 #include <gecko_console.h> 33 #endif 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 int main(int argc, char *argv[]) { 40 s32 res; 41 42 VIDEO_Init(); 43 PAD_Init(); 44 AUDIO_Init(NULL); 45 46 #ifdef DEBUG_WII 47 gecko_console_init(0); 48 //DEBUG_Init(GDBSTUB_DEVICE_USB, 1); 49 #endif 50 51 printf("startup\n"); 52 53 if (!fatInitDefault()) { 54 printf("fatInitDefault failed\n"); 55 } else { 56 // set the default path if libfat couldnt set it 57 // this allows loading over tcp/usbgecko 58 char buf[MAXPATHLEN]; 59 60 getcwd(buf, MAXPATHLEN); 61 if (!strcmp(buf, "fat:/")) 62 chdir("/apps/scummvm"); 63 64 //fatEnableReadAhead(PI_DEFAULT, 32, 128); 65 } 66 67 g_system = new OSystem_Wii(); 68 assert(g_system); 69 70 res = scummvm_main(argc, argv); 71 g_system->quit(); 72 73 printf("shutdown\n"); 74 75 if (!fatUnmount(PI_DEFAULT)) { 76 printf("fatUnmount failed\n"); 77 fatUnsafeUnmount(PI_DEFAULT); 78 } 79 80 printf("reloading\n"); 81 82 return res; 83 } 84 85 #ifdef __cplusplus 86 } 87 #endif 88 -
backends/platform/wii/gx_supp.cpp
1 /**************************************************************************** 2 * Generic GX Support for Emulators 3 * softdev 2007 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * NGC GX Video Functions 20 * 21 * These are pretty standard functions to setup and use GX scaling. 22 ****************************************************************************/ 23 24 #include <gccore.h> 25 #include <stdio.h> 26 #include <stdlib.h> 27 #include <string.h> 28 #include <malloc.h> 29 30 #define DEFAULT_FIFO_SIZE (256 * 1024) 31 32 #define HASPECT 320 33 #define VASPECT 240 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 /*** 2D ***/ 40 static u32 whichfb; 41 static u32 *xfb[2]; 42 static GXRModeObj *vmode; 43 44 /*** 3D GX ***/ 45 static u8 *gp_fifo; 46 47 /*** Texture memory ***/ 48 static u8 *texturemem; 49 static u32 texturesize; 50 51 GXTexObj texobj; 52 static Mtx view; 53 static u16 vwidth, vheight, oldvwidth, oldvheight; 54 55 /* New texture based scaler */ 56 typedef struct tagcamera { 57 Vector pos; 58 Vector up; 59 Vector view; 60 } camera; 61 62 static s16 square[] ATTRIBUTE_ALIGN(32) = { 63 -HASPECT, VASPECT, 0, 64 HASPECT, VASPECT, 0, 65 HASPECT, -VASPECT, 0, 66 -HASPECT, -VASPECT, 0, 67 }; 68 69 static camera cam = { 70 { 0.0f, 0.0f, 370.0f }, 71 { 0.0f, 0.5f, 0.0f }, 72 { 0.0f, 0.0f, -0.5f } 73 }; 74 75 void GX_InitVideo() { 76 vmode = VIDEO_GetPreferredMode(NULL); 77 VIDEO_Configure(vmode); 78 79 xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer(vmode)); 80 xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer(vmode)); 81 gp_fifo = (u8 *) memalign(32, DEFAULT_FIFO_SIZE); 82 83 VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK); 84 VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK); 85 86 whichfb = 0; 87 VIDEO_SetNextFramebuffer(xfb[whichfb]); 88 VIDEO_SetBlack(FALSE); 89 VIDEO_Flush(); 90 VIDEO_WaitVSync(); 91 92 if (vmode->viTVMode & VI_NON_INTERLACE) 93 VIDEO_WaitVSync(); 94 } 95 96 /**************************************************************************** 97 * Scaler Support Functions 98 ****************************************************************************/ 99 static void draw_init(void) { 100 GX_ClearVtxDesc(); 101 GX_SetVtxDesc(GX_VA_POS, GX_INDEX8); 102 GX_SetVtxDesc(GX_VA_CLR0, GX_INDEX8); 103 GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); 104 105 GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0); 106 GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); 107 GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); 108 109 GX_SetArray(GX_VA_POS, square, 3 * sizeof(s16)); 110 111 GX_SetNumTexGens(1); 112 GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); 113 114 GX_InvalidateTexAll(); 115 116 GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, 117 GX_CLAMP, GX_CLAMP, GX_FALSE); 118 } 119 120 static void draw_vert(u8 pos, u8 c, f32 s, f32 t) { 121 GX_Position1x8(pos); 122 GX_Color1x8(c); 123 GX_TexCoord2f32(s, t); 124 } 125 126 static void draw_square(Mtx v) { 127 Mtx m; 128 Mtx mv; 129 130 guMtxIdentity(m); 131 guMtxTransApply(m, m, 0, 0, -100); 132 guMtxConcat(v, m, mv); 133 134 GX_LoadPosMtxImm(mv, GX_PNMTX0); 135 GX_Begin(GX_QUADS, GX_VTXFMT0, 4); 136 draw_vert(0, 0, 0.0, 0.0); 137 draw_vert(1, 0, 1.0, 0.0); 138 draw_vert(2, 0, 1.0, 1.0); 139 draw_vert(3, 0, 0.0, 1.0); 140 GX_End(); 141 } 142 143 /**************************************************************************** 144 * StartGX 145 ****************************************************************************/ 146 void GX_Start(u16 width, u16 height, s16 haspect, s16 vaspect) { 147 Mtx p; 148 149 GX_AbortFrame(); 150 151 /*** Set new aspect ***/ 152 square[0] = square[9] = -haspect; 153 square[3] = square[6] = haspect; 154 square[1] = square[4] = vaspect; 155 square[7] = square[10] = -vaspect; 156 157 /*** Allocate 32byte aligned texture memory ***/ 158 texturesize = (width * height) * 2; 159 texturemem = (u8 *) memalign(32, texturesize); 160 161 GXColor gxbackground = { 0, 0, 0, 0xff }; 162 163 /*** Clear out FIFO area ***/ 164 memset(gp_fifo, 0, DEFAULT_FIFO_SIZE); 165 166 /*** Initialise GX ***/ 167 GX_Init(gp_fifo, DEFAULT_FIFO_SIZE); 168 GX_SetCopyClear(gxbackground, 0x00ffffff); 169 170 GX_SetViewport(0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1); 171 GX_SetDispCopyYScale((f32) vmode->xfbHeight / (f32) vmode->efbHeight); 172 GX_SetScissor(0, 0, vmode->fbWidth, vmode->efbHeight); 173 GX_SetDispCopySrc(0, 0, vmode->fbWidth, vmode->efbHeight); 174 GX_SetDispCopyDst(vmode->fbWidth, vmode->xfbHeight); 175 GX_SetCopyFilter(vmode->aa, vmode->sample_pattern, GX_TRUE, 176 vmode->vfilter); 177 GX_SetFieldMode(vmode->field_rendering, 178 ((vmode->viHeight == 2 * vmode->xfbHeight) ? 179 GX_ENABLE : GX_DISABLE)); 180 GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); 181 GX_SetCullMode(GX_CULL_NONE); 182 GX_CopyDisp(xfb[whichfb ^ 1], GX_TRUE); 183 GX_SetDispCopyGamma(GX_GM_1_0); 184 185 guPerspective(p, 60, 1.33f, 10.0f, 1000.0f); 186 GX_LoadProjectionMtx(p, GX_PERSPECTIVE); 187 memset(texturemem, 0, texturesize); 188 189 GX_Flush(); 190 191 /*** Setup for first call to scaler ***/ 192 vwidth = vheight = -1; 193 } 194 195 /**************************************************************************** 196 * GX_Render 197 * 198 * Pass in a buffer, width and height to update as a tiled RGB565 texture 199 ****************************************************************************/ 200 void GX_Render(u16 width, u16 height, u8 *buffer, u16 pitch) { 201 u16 h, w; 202 u64 *dst = (u64 *) texturemem; 203 u64 *src1 = (u64 *) buffer; 204 u64 *src2 = (u64 *) (buffer + pitch); 205 u64 *src3 = (u64 *) (buffer + (pitch * 2)); 206 u64 *src4 = (u64 *) (buffer + (pitch * 3)); 207 u16 rowpitch = (pitch >> 3) * 3 + pitch % 8; 208 209 vwidth = width; 210 vheight = height; 211 212 whichfb ^= 1; 213 214 if ((oldvheight != vheight) || (oldvwidth != vwidth)) { 215 /** Update scaling **/ 216 oldvwidth = vwidth; 217 oldvheight = vheight; 218 draw_init(); 219 memset(&view, 0, sizeof(Mtx)); 220 guLookAt(view, &cam.pos, &cam.up, &cam.view); 221 GX_SetViewport(0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1); 222 } 223 224 GX_InvVtxCache(); 225 GX_InvalidateTexAll(); 226 GX_SetTevOp(GX_TEVSTAGE0, GX_DECAL); 227 GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); 228 229 for (h = 0; h < vheight; h += 4) { 230 for (w = 0; w < (vwidth >> 2); w++) { 231 *dst++ = *src1++; 232 *dst++ = *src2++; 233 *dst++ = *src3++; 234 *dst++ = *src4++; 235 } 236 237 src1 += rowpitch; 238 src2 += rowpitch; 239 src3 += rowpitch; 240 src4 += rowpitch; 241 } 242 243 DCFlushRange(texturemem, texturesize); 244 245 GX_SetNumChans(1); 246 GX_LoadTexObj(&texobj, GX_TEXMAP0); 247 248 draw_square(view); 249 250 GX_DrawDone(); 251 252 GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); 253 GX_SetColorUpdate(GX_TRUE); 254 GX_CopyDisp(xfb[whichfb], GX_TRUE); 255 GX_Flush(); 256 257 VIDEO_SetNextFramebuffer(xfb[whichfb]); 258 VIDEO_Flush(); 259 } 260 261 #ifdef __cplusplus 262 } 263 #endif 264 -
backends/platform/wii/osystem_gfx.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 */ 21 22 #include <malloc.h> 23 24 #include "osystem.h" 25 #include "gx_supp.h" 26 27 #define MAX_FPS 30 28 29 enum GraphicModeID { 30 GM_DEFAULT 31 }; 32 33 void OSystem_Wii::initGfx() { 34 _surface.w = 0; 35 _surface.h = 0; 36 _surface.pitch = 0; 37 _surface.pixels = NULL; 38 _surface.bytesPerPixel = 0; 39 40 GX_InitVideo(); 41 42 _overlayWidth = 640; 43 _overlayHeight = 480; 44 45 _overlaySize = _overlayWidth * _overlayHeight * 2; 46 _overlayPixels = (OverlayColor *) memalign(32, _overlaySize); 47 48 _palette = (u16 *) memalign(32, 256 * 2); 49 memset(_palette, 0, 256 * 2); 50 51 _cursorPalette = (u16 *) memalign(32, 256 * 2); 52 memset(_cursorPalette, 0, 256 * 2); 53 54 _supportedGraphicsModes = new OSystem::GraphicsMode[2]; 55 _supportedGraphicsModes[0].name = strdup("gx"); 56 _supportedGraphicsModes[0].description = strdup("wii hardware scaler"); 57 _supportedGraphicsModes[0].id = GM_DEFAULT; 58 _supportedGraphicsModes[1].name = 0; 59 _supportedGraphicsModes[1].description = 0; 60 _supportedGraphicsModes[1].id = 0; 61 62 _texture = (u16 *) memalign(32, _overlaySize); 63 64 GX_Start(_overlayWidth, _overlayHeight, 320, 240); 65 } 66 67 void OSystem_Wii::deinitGfx() { 68 GX_AbortFrame(); 69 70 if (_supportedGraphicsModes) { 71 delete[] _supportedGraphicsModes; 72 _supportedGraphicsModes = NULL; 73 } 74 75 if (_gamePixels) { 76 free(_gamePixels); 77 _gamePixels = NULL; 78 } 79 80 if (_palette) { 81 free(_palette); 82 _palette = NULL; 83 } 84 85 if (_overlayPixels) { 86 free(_overlayPixels); 87 _overlayPixels = NULL; 88 } 89 90 if (_mouseCursor) { 91 free(_mouseCursor); 92 _mouseCursor = NULL; 93 } 94 95 if (_cursorPalette) { 96 free(_cursorPalette); 97 _cursorPalette = NULL; 98 } 99 100 if (_texture) { 101 free(_texture); 102 _texture = NULL; 103 } 104 } 105 106 const OSystem::GraphicsMode* OSystem_Wii::getSupportedGraphicsModes() const { 107 return _supportedGraphicsModes; 108 } 109 110 int OSystem_Wii::getDefaultGraphicsMode() const { 111 return GM_DEFAULT; 112 } 113 114 bool OSystem_Wii::setGraphicsMode(const char *mode) { 115 setGraphicsMode(GM_DEFAULT); 116 117 return true; 118 } 119 120 bool OSystem_Wii::setGraphicsMode(int mode) { 121 return true; 122 } 123 124 int OSystem_Wii::getGraphicsMode() const { 125 return _activeGraphicsMode; 126 } 127 128 void OSystem_Wii::initSize(uint width, uint height) { 129 if (_gameWidth != width || _gameHeight != height) { 130 printf("initSize %u %u\n", width, height); 131 132 _gameWidth = width; 133 _gameHeight = height; 134 135 if(_gamePixels) 136 free(_gamePixels); 137 138 _gamePixels = (u8 *) memalign(32, _gameWidth * _gameHeight); 139 140 if (!_overlayVisible) { 141 _currentWidth = _gameWidth; 142 _currentHeight = _gameHeight; 143 updateEventScreenResolution(); 144 } 145 } 146 } 147 148 int16 OSystem_Wii::getWidth() { 149 return _gameWidth; 150 } 151 152 int16 OSystem_Wii::getHeight() { 153 return _gameHeight; 154 } 155 156 void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) { 157 const byte *p = colors; 158 for (uint i = 0; i < num; ++i) { 159 _palette[start + i] = RGBToColor(p[0], p[1], p[2]); 160 p += 4; 161 } 162 } 163 164 void OSystem_Wii::grabPalette(byte *colors, uint start, uint num) { 165 byte *p = colors; 166 u8 r, g, b; 167 for (uint i = 0; i < num; ++i) { 168 colorToRGB(_palette[start + i], r, g, b); 169 p[0] = r; 170 p[1] = g; 171 p[2] = b; 172 p[3] = 0xff; 173 p += 4; 174 } 175 } 176 177 void OSystem_Wii::setCursorPalette(const byte *colors, uint start, uint num) { 178 const byte *p = colors; 179 for (uint i = 0; i < num; ++i) { 180 _cursorPalette[start + i] = RGBToColor(p[0], p[1], p[2]); 181 p += 4; 182 } 183 184 _cursorPaletteDisabled = false; 185 } 186 187 void OSystem_Wii::disableCursorPalette(bool disable) { 188 _cursorPaletteDisabled = disable; 189 } 190 191 void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y, 192 int w, int h) { 193 if (x < 0) { 194 w += x; 195 buf -= x; 196 x = 0; 197 } 198 199 if (y < 0) { 200 h += y; 201 buf -= y * pitch; 202 y = 0; 203 } 204 205 if (w > _gameWidth - x) 206 w = _gameWidth - x; 207 208 if (h > _gameHeight - y) 209 h = _gameHeight - y; 210 211 if (w <= 0 || h <= 0) 212 return; 213 214 byte *dst = _gamePixels + y * _gameWidth + x; 215 if (_gameWidth == pitch && pitch == w) { 216 memcpy(dst, buf, h * w); 217 } else { 218 do { 219 memcpy(dst, buf, w); 220 buf += pitch; 221 dst += _gameWidth; 222 } while (--h); 223 } 224 } 225 226 void OSystem_Wii::updateScreen() { 227 static u32 x, y, h, skip; 228 static s16 msx, msy, mox, moy, mskip; 229 static u16 mpx, mpy; 230 static u8 *s; 231 static u16 *d, *p; 232 233 u32 now = getMillis(); 234 if (now - _lastScreenUpdate < 1000 / MAX_FPS) 235 return; 236 237 _lastScreenUpdate = now; 238 239 h = 0; 240 if (_overlayVisible) { 241 memcpy(_texture, _overlayPixels, _overlaySize); 242 } else { 243 for (y = 0; y < _gameHeight; ++y) { 244 for (x = 0; x < _gameWidth; ++x) 245 _texture[h + x] = _palette[_gamePixels[h + x]]; 246 247 h += _gameWidth; 248 } 249 } 250 251 if (_mouseVisible) { 252 msx = _mouseX - _mouseHotspotX; 253 msy = _mouseY - _mouseHotspotY; 254 mox = 0; 255 moy = 0; 256 mpx = _mouseWidth; 257 mpy = _mouseHeight; 258 259 if (msx < 0) { 260 mox = -msx; 261 mpx -= mox; 262 msx = 0; 263 } else 264 if (msx + mpx > _currentWidth - 1) 265 mpx = _currentWidth - msx - 1; 266 267 if (msy < 0) { 268 moy = -msy; 269 mpy -= moy; 270 msy = 0; 271 } else 272 if (msy + mpy + 1 > _currentHeight - 1) 273 mpy = _currentHeight - msy - 1; 274 275 276 if (_cursorPaletteDisabled) 277 p = _palette; 278 else 279 p = _cursorPalette; 280 281 skip = _currentWidth - mpx; 282 mskip = _mouseWidth - mpx; 283 284 s = _mouseCursor + moy * _mouseWidth + mox; 285 d = _texture + (msy * _currentWidth + msx); 286 287 for (y = 0; y < mpy; ++y) { 288 for (x = 0; x < mpx; ++x) { 289 if (*s == _mouseKeyColor) { 290 s++; 291 d++; 292 293 continue; 294 } 295 296 *d++ = p[*s]; 297 s++; 298 } 299 300 d += skip; 301 s += mskip; 302 } 303 } 304 305 GX_Render(_currentWidth, _currentHeight, (u8 *) _texture, 306 _currentWidth * 2); 307 } 308 309 Graphics::Surface *OSystem_Wii::lockScreen() { 310 _surface.pixels = _gamePixels; 311 _surface.w = _gameWidth; 312 _surface.h = _gameHeight; 313 _surface.pitch = _gameWidth; 314 _surface.bytesPerPixel = 1; 315 316 return &_surface; 317 } 318 319 void OSystem_Wii::unlockScreen() { 320 } 321 322 void OSystem_Wii::setShakePos(int shakeOffset) { 323 } 324 325 void OSystem_Wii::showOverlay() { 326 _mouseX = _overlayWidth / 2; 327 _mouseY = _overlayHeight / 2; 328 _overlayVisible = true; 329 _currentWidth = _overlayWidth; 330 _currentHeight = _overlayHeight; 331 332 updateEventScreenResolution(); 333 } 334 335 void OSystem_Wii::hideOverlay() { 336 _mouseX = _gameWidth / 2; 337 _mouseY = _gameHeight / 2; 338 _overlayVisible = false; 339 _currentWidth = _gameWidth; 340 _currentHeight = _gameHeight; 341 342 updateEventScreenResolution(); 343 } 344 345 void OSystem_Wii::clearOverlay() { 346 memset(_overlayPixels, 0, _overlaySize); 347 } 348 349 void OSystem_Wii::grabOverlay(OverlayColor *buf, int pitch) { 350 int h = _overlayHeight; 351 OverlayColor *src = _overlayPixels; 352 353 do { 354 memcpy(buf, src, _overlayWidth * sizeof(OverlayColor)); 355 src += _overlayWidth; 356 buf += pitch; 357 } while (--h); 358 } 359 360 void OSystem_Wii::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, 361 int y, int w, int h) { 362 if (x < 0) { 363 w += x; 364 buf -= x; 365 x = 0; 366 } 367 368 if (y < 0) { 369 h += y; 370 buf -= y * pitch; 371 y = 0; 372 } 373 374 if (w > _overlayWidth - x) 375 w = _overlayWidth - x; 376 377 if (h > _overlayHeight - y) 378 h = _overlayHeight - y; 379 380 if (w <= 0 || h <= 0) 381 return; 382 383 OverlayColor *dst = _overlayPixels + (y * _overlayWidth + x); 384 if (_overlayWidth == pitch && pitch == w) { 385 memcpy(dst, buf, h * w * sizeof(OverlayColor)); 386 } else { 387 do { 388 memcpy(dst, buf, w * sizeof(OverlayColor)); 389 buf += pitch; 390 dst += _overlayWidth; 391 } while (--h); 392 } 393 } 394 395 int16 OSystem_Wii::getOverlayWidth() { 396 return _overlayWidth; 397 } 398 399 int16 OSystem_Wii::getOverlayHeight() { 400 return _overlayHeight; 401 } 402 403 OverlayColor OSystem_Wii::RGBToColor(uint8 r, uint8 g, uint8 b) { 404 return (((r >> 3) & 0x1f) << 11) | (((g >> 2) & 0x3f) << 5 ) | 405 ((b >> 3) & 0x1f); 406 } 407 408 void OSystem_Wii::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { 409 r = ((color >> 11) & 0x1f) << 3; 410 g = ((color >> 5) & 0x3f) << 2; 411 b = (color & 0x1f) << 3; 412 } 413 414 OverlayColor OSystem_Wii::ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) { 415 return RGBToColor(r, g, b); 416 } 417 418 void OSystem_Wii::colorToARGB(OverlayColor color, uint8 &a, uint8 &r, uint8 &g, 419 uint8 &b) { 420 a = 0xff; 421 colorToRGB(color, r, g, b); 422 } 423 424 bool OSystem_Wii::showMouse(bool visible) { 425 bool last = _mouseVisible; 426 _mouseVisible = visible; 427 428 return last; 429 } 430 431 void OSystem_Wii::warpMouse(int x, int y) { 432 _mouseX = x; 433 _mouseY = y; 434 } 435 436 void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, 437 int hotspotY, byte keycolor, 438 int cursorTargetScale) { 439 (void) cursorTargetScale; // TODO 440 441 _mouseWidth = w; 442 _mouseHeight = h; 443 _mouseHotspotX = hotspotX; 444 _mouseHotspotY = hotspotY; 445 _mouseKeyColor = keycolor; 446 447 if (_mouseCursor) 448 free(_mouseCursor); 449 450 _mouseCursor = (u8 *) memalign(32, w * h); 451 memcpy(_mouseCursor, buf, w * h); 452 } 453 -
backends/platform/wii/osystem_events.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 */ 21 22 #include <unistd.h> 23 #include <malloc.h> 24 25 #ifndef GAMECUBE 26 #include <wiiuse/wpad.h> 27 #endif 28 29 #include <ogc/lwp_watchdog.h> 30 31 #include "osystem.h" 32 33 #define TIMER_THREAD_STACKSIZE (1024 * 32) 34 #define TIMER_THREAD_PRIO 64 35 36 #define PAD_CHECK_TIME 40 37 38 #ifndef GAMECUBE 39 #define PADS_A (PAD_BUTTON_A | (WPAD_BUTTON_A << 16)) 40 #define PADS_B (PAD_BUTTON_B | (WPAD_BUTTON_B << 16)) 41 #define PADS_X (PAD_BUTTON_X | (WPAD_BUTTON_MINUS << 16)) 42 #define PADS_Y (PAD_BUTTON_Y | (WPAD_BUTTON_PLUS << 16)) 43 #define PADS_Z (PAD_TRIGGER_Z | (WPAD_BUTTON_2 << 16)) 44 #define PADS_START (PAD_BUTTON_START | (WPAD_BUTTON_HOME << 16)) 45 #define PADS_UP (PAD_BUTTON_UP | (WPAD_BUTTON_UP << 16)) 46 #define PADS_DOWN (PAD_BUTTON_DOWN | (WPAD_BUTTON_DOWN << 16)) 47 #define PADS_LEFT (PAD_BUTTON_LEFT | (WPAD_BUTTON_LEFT << 16)) 48 #define PADS_RIGHT (PAD_BUTTON_RIGHT | (WPAD_BUTTON_RIGHT << 16)) 49 #else 50 #define PADS_A PAD_BUTTON_A 51 #define PADS_B PAD_BUTTON_B 52 #define PADS_X PAD_BUTTON_X 53 #define PADS_Y PAD_BUTTON_Y 54 #define PADS_Z PAD_TRIGGER_Z 55 #define PADS_START PAD_BUTTON_START 56 #define PADS_UP PAD_BUTTON_UP 57 #define PADS_DOWN PAD_BUTTON_DOWN 58 #define PADS_LEFT PAD_BUTTON_LEFT 59 #define PADS_RIGHT PAD_BUTTON_RIGHT 60 #endif 61 62 static lwpq_t timer_queue; 63 static lwp_t timer_thread; 64 static u8 *timer_stack; 65 static bool timer_thread_running = false; 66 static bool timer_thread_quit = false; 67 68 static void * timer_thread_func(void *arg) { 69 while (!timer_thread_quit) { 70 DefaultTimerManager *tm = 71 (DefaultTimerManager *) g_system->getTimerManager(); 72 tm->handler(); 73 74 usleep(1000 * 10); 75 } 76 77 return NULL; 78 } 79 80 void OSystem_Wii::initEvents() { 81 timer_thread_quit = false; 82 83 timer_stack = (u8 *) memalign(32, TIMER_THREAD_STACKSIZE); 84 memset(timer_stack, 0, TIMER_THREAD_STACKSIZE); 85 86 LWP_InitQueue(&timer_queue); 87 88 s32 res = LWP_CreateThread(&timer_thread, timer_thread_func, NULL, 89 timer_stack, TIMER_THREAD_STACKSIZE, 90 TIMER_THREAD_PRIO); 91 92 if (res) { 93 printf("ERROR creating timer thread: %d\n", res); 94 LWP_CloseQueue(timer_queue); 95 } 96 97 timer_thread_running = res == 0; 98 99 #ifndef GAMECUBE 100 WPAD_Init(); 101 WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); 102 WPAD_SetIdleTimeout(120); 103 #endif 104 } 105 106 void OSystem_Wii::deinitEvents() { 107 if (timer_thread_running) { 108 timer_thread_quit = true; 109 LWP_ThreadBroadcast(timer_queue); 110 111 LWP_JoinThread(timer_thread, NULL); 112 LWP_CloseQueue(timer_queue); 113 114 timer_thread_running = false; 115 } 116 117 #ifndef GAMECUBE 118 WPAD_Shutdown(); 119 #endif 120 } 121 122 void OSystem_Wii::updateEventScreenResolution() { 123 #ifndef GAMECUBE 124 WPAD_SetVRes(WPAD_CHAN_0, _currentWidth + _currentWidth / 5, 125 _currentHeight + _currentHeight / 5); 126 #endif 127 } 128 129 #define KBD_EVENT(pad_button, kbd_keycode, kbd_ascii) \ 130 do { \ 131 if ((bd | bu) & pad_button) { \ 132 if (bd & pad_button) \ 133 event.type = Common::EVENT_KEYDOWN; \ 134 else \ 135 event.type = Common::EVENT_KEYUP; \ 136 event.kbd.keycode = kbd_keycode; \ 137 event.kbd.ascii = kbd_ascii; \ 138 return true; \ 139 } \ 140 } while (0) 141 142 bool OSystem_Wii::pollEvent(Common::Event &event) { 143 u32 bd, bh, bu; 144 145 PAD_ScanPads(); 146 147 bd = PAD_ButtonsDown(0); 148 bh = PAD_ButtonsHeld(0); 149 bu = PAD_ButtonsUp(0); 150 151 #ifndef GAMECUBE 152 WPAD_ScanPads(); 153 154 s32 res = WPAD_Probe(0, NULL); 155 156 if (res == WPAD_ERR_NONE) { 157 158 bd |= WPAD_ButtonsDown(0) << 16; 159 bh |= WPAD_ButtonsHeld(0) << 16; 160 bu |= WPAD_ButtonsUp(0) << 16; 161 } 162 #endif 163 164 if (bd || bu) { 165 if (bh & PADS_UP) 166 event.kbd.flags = Common::KBD_SHIFT; 167 168 KBD_EVENT(PADS_Z, Common::KEYCODE_RETURN, Common::ASCII_RETURN); 169 KBD_EVENT(PADS_X, Common::KEYCODE_ESCAPE, Common::ASCII_ESCAPE); 170 KBD_EVENT(PADS_Y, Common::KEYCODE_PERIOD, '.'); 171 KBD_EVENT(PADS_START, Common::KEYCODE_F5, Common::ASCII_F5); 172 KBD_EVENT(PADS_UP, Common::KEYCODE_LSHIFT, 0); 173 KBD_EVENT(PADS_DOWN, Common::KEYCODE_0, '0'); 174 KBD_EVENT(PADS_LEFT, Common::KEYCODE_y, 'y'); 175 KBD_EVENT(PADS_RIGHT, Common::KEYCODE_n, 'n'); 176 177 if ((bd | bu) & (PADS_A | PADS_B)) { 178 if (bd & PADS_A) 179 event.type = Common::EVENT_LBUTTONDOWN; 180 else if (bu & PADS_A) 181 event.type = Common::EVENT_LBUTTONUP; 182 else if (bd & PADS_B) 183 event.type = Common::EVENT_RBUTTONDOWN; 184 else if (bu & PADS_B) 185 event.type = Common::EVENT_RBUTTONUP; 186 187 event.mouse.x = _mouseX; 188 event.mouse.y = _mouseY; 189 190 return true; 191 } 192 } 193 194 s32 mx = _mouseX; 195 s32 my = _mouseY; 196 197 #ifndef GAMECUBE 198 if (res == WPAD_ERR_NONE) { 199 struct ir_t ir; 200 201 WPAD_IR(0, &ir); 202 203 if (ir.valid) { 204 mx = ir.x - _currentWidth / 10; 205 my = ir.y - _currentHeight / 10; 206 207 if (mx < 0) 208 mx = 0; 209 210 if (mx >= _currentWidth) 211 mx = _currentWidth - 1; 212 213 if (my < 0) 214 my = 0; 215 216 if (my >= _currentHeight) 217 my = _currentHeight - 1; 218 219 if ((mx != _mouseX) || (my != _mouseY)) { 220 event.type = Common::EVENT_MOUSEMOVE; 221 event.mouse.x = _mouseX = mx; 222 event.mouse.y = _mouseY = my; 223 224 return true; 225 } 226 } 227 } 228 #endif 229 230 uint32 time = getMillis(); 231 if (time - _lastPadCheck > PAD_CHECK_TIME) { 232 _lastPadCheck = time; 233 234 if (abs (PAD_StickX(0)) > 16) 235 mx += PAD_StickX(0) / (4 * _overlayWidth / _currentWidth); 236 if (abs (PAD_StickY(0)) > 16) 237 my -= PAD_StickY(0) / (4 * _overlayHeight / _currentHeight); 238 239 if (mx < 0) 240 mx = 0; 241 242 if (mx >= _currentWidth) 243 mx = _currentWidth - 1; 244 245 if (my < 0) 246 my = 0; 247 248 if (my >= _currentHeight) 249 my = _currentHeight - 1; 250 251 if ((mx != _mouseX) || (my != _mouseY)) { 252 event.type = Common::EVENT_MOUSEMOVE; 253 event.mouse.x = _mouseX = mx; 254 event.mouse.y = _mouseY = my; 255 256 return true; 257 } 258 } 259 260 return false; 261 } 262 -
backends/platform/wii/osystem.h
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 */ 21 22 #ifndef _WII_OSYSTEM_H_ 23 #define _WII_OSYSTEM_H_ 24 25 #include "common/system.h" 26 #include "base/main.h" 27 28 #include "common/rect.h" 29 #include "common/events.h" 30 31 #include "backends/saves/default/default-saves.h" 32 #include "backends/timer/default/default-timer.h" 33 #include "graphics/surface.h" 34 #include "sound/mixer.h" 35 36 #include <gctypes.h> 37 #include <gccore.h> 38 #include <ogcsys.h> 39 40 class OSystem_Wii : public OSystem { 41 private: 42 s64 _startup_time; 43 syswd_t _alarm; 44 45 u16 *_palette; 46 u16 *_cursorPalette; 47 bool _cursorPaletteDisabled; 48 49 u16 _gameWidth, _gameHeight; 50 u8 *_gamePixels; 51 Graphics::Surface _surface; 52 53 bool _overlayVisible; 54 u16 _overlayWidth, _overlayHeight; 55 u32 _overlaySize; 56 OverlayColor *_overlayPixels; 57 58 u32 _lastScreenUpdate; 59 u16 *_texture; 60 u16 _currentWidth, _currentHeight; 61 62 OSystem::GraphicsMode *_supportedGraphicsModes; 63 s32 _activeGraphicsMode; 64 65 bool _mouseVisible; 66 s32 _mouseX, _mouseY; 67 u32 _mouseWidth, _mouseHeight; 68 s32 _mouseHotspotX, _mouseHotspotY; 69 u8 _mouseKeyColor; 70 u8 *_mouseCursor; 71 72 u32 _lastPadCheck; 73 74 void initGfx(); 75 void deinitGfx(); 76 77 void initSfx(); 78 void deinitSfx(); 79 80 void initEvents(); 81 void deinitEvents(); 82 void updateEventScreenResolution(); 83 84 protected: 85 Common::SaveFileManager *_savefile; 86 Audio::Mixer *_mixer; 87 DefaultTimerManager *_timer; 88 89 public: 90 OSystem_Wii(); 91 virtual ~OSystem_Wii(); 92 93 virtual void initBackend(); 94 95 virtual bool hasFeature(Feature f); 96 virtual void setFeatureState(Feature f, bool enable); 97 virtual bool getFeatureState(Feature f); 98 virtual const GraphicsMode *getSupportedGraphicsModes() const; 99 virtual int getDefaultGraphicsMode() const; 100 bool setGraphicsMode(const char *name); 101 virtual bool setGraphicsMode(int mode); 102 virtual int getGraphicsMode() const; 103 virtual void initSize(uint width, uint height); 104 virtual int16 getWidth(); 105 virtual int16 getHeight(); 106 virtual void setPalette(const byte *colors, uint start, uint num); 107 virtual void grabPalette(byte *colors, uint start, uint num); 108 virtual void setCursorPalette(const byte *colors, uint start, uint num); 109 virtual void disableCursorPalette(bool disable); 110 virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, 111 int w, int h); 112 virtual void updateScreen(); 113 virtual Graphics::Surface *lockScreen(); 114 virtual void unlockScreen(); 115 virtual void setShakePos(int shakeOffset); 116 117 virtual void showOverlay(); 118 virtual void hideOverlay(); 119 virtual void clearOverlay(); 120 virtual void grabOverlay(OverlayColor *buf, int pitch); 121 virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, 122 int x, int y, int w, int h); 123 virtual int16 getOverlayWidth(); 124 virtual int16 getOverlayHeight(); 125 126 virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); 127 virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); 128 virtual OverlayColor ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b); 129 virtual void colorToARGB(OverlayColor color, uint8 &a, uint8 &r, 130 uint8 &g, uint8 &b); 131 132 virtual bool showMouse(bool visible); 133 134 virtual void warpMouse(int x, int y); 135 virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, 136 int hotspotY, byte keycolor = 255, 137 int cursorTargetScale = 1); 138 139 virtual bool pollEvent(Common::Event &event); 140 virtual uint32 getMillis(); 141 virtual void delayMillis(uint msecs); 142 143 virtual MutexRef createMutex(); 144 virtual void lockMutex(MutexRef mutex); 145 virtual void unlockMutex(MutexRef mutex); 146 virtual void deleteMutex(MutexRef mutex); 147 148 typedef void (*SoundProc)(void *param, byte *buf, int len); 149 virtual int getOutputSampleRate() const; 150 151 virtual void quit(); 152 153 virtual void setWindowCaption(const char *caption); 154 155 virtual Common::SaveFileManager *getSavefileManager(); 156 virtual Audio::Mixer *getMixer(); 157 virtual Common::TimerManager *getTimerManager(); 158 FilesystemFactory *getFilesystemFactory(); 159 void getTimeAndDate(struct tm &t) const; 160 }; 161 162 #endif 163 -
backends/platform/wii/gecko_console.cpp
1 /*------------------------------------------------------------- 2 3 Copyright (C) 2008 4 Hector Martin (marcan) 5 6 This software is provided 'as-is', without any express or implied 7 warranty. In no event will the authors be held liable for any 8 damages arising from the use of this software. 9 10 Permission is granted to anyone to use this software for any 11 purpose, including commercial applications, and to alter it and 12 redistribute it freely, subject to the following restrictions: 13 14 1. The origin of this software must not be misrepresented; you 15 must not claim that you wrote the original software. If you use 16 this software in a product, an acknowledgment in the product 17 documentation would be appreciated but is not required. 18 19 2. Altered source versions must be plainly marked as such, and 20 must not be misrepresented as being the original software. 21 22 3. This notice may not be removed or altered from any source 23 distribution. 24 25 -------------------------------------------------------------*/ 26 27 #include <stdio.h> 28 #include <sys/iosupport.h> 29 #include <ogcsys.h> 30 #include <gccore.h> 31 #include <reent.h> 32 33 #include "gecko_console.h" 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 static const devoptab_t *dotab_console; 40 int usb_sendbuffer_safe(s32 chn,const void *buffer,int size); 41 int usb_sendbuffer(s32 chn,const void *buffer,int size); 42 43 int __gecko_write(struct _reent *r,int fd,const char *ptr,int len) { 44 char *tmp = (char*)ptr; 45 u32 level; 46 if(dotab_console) 47 dotab_console->write_r(r,fd,ptr,len); 48 49 if(!tmp || len<=0) 50 return -1; 51 level = IRQ_Disable(); 52 usb_sendbuffer(1, ptr, len); 53 IRQ_Restore(level); 54 return len; 55 } 56 57 const devoptab_t dotab_gecko = { 58 "stdout", // device name 59 0, // size of file structure 60 NULL, // device open 61 NULL, // device close 62 __gecko_write, // device write 63 NULL, // device read 64 NULL, // device seek 65 NULL, // device fstat 66 NULL, // device stat 67 NULL, // device link 68 NULL, // device unlink 69 NULL, // device chdir 70 NULL, // device rename 71 NULL, // device mkdir 72 0, // dirStateSize 73 NULL, // device diropen_r 74 NULL, // device dirreset_r 75 NULL, // device dirnext_r 76 NULL, // device dirclose_r 77 NULL // device statvfs_r 78 }; 79 80 void gecko_console_init(int chain) { 81 dotab_console = NULL; 82 if(chain) 83 dotab_console = devoptab_list[STD_OUT]; 84 devoptab_list[STD_OUT] = &dotab_gecko; 85 devoptab_list[STD_ERR] = &dotab_gecko; 86 } 87 88 #ifdef __cplusplus 89 } 90 #endif 91 -
backends/platform/wii/gx_supp.h
1 /**************************************************************************** 2 * Generic GX Scaler 3 * softdev 2007 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * NGC GX Video Functions 20 * 21 * These are pretty standard functions to setup and use GX scaling. 22 ****************************************************************************/ 23 #ifndef _WII_GX_SUPP_H_ 24 #define _WII_GX_SUPP_H_ 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 void GX_InitVideo(); 31 32 void GX_Start(u16 width, u16 height, s16 haspect, s16 vaspect); 33 void GX_Render(u16 width, u16 height, u8 *buffer, u16 pitch); 34 35 #ifdef __cplusplus 36 } 37 #endif 38 39 #endif -
backends/platform/wii/Makefile
1 DEBUG_WII = 1 2 3 ENABLE_SCUMM = 1 4 ENABLE_SCUMM_7_8 = 1 5 ENABLE_HE = 1 6 # ENABLE_AGI = 1 7 ENABLE_AGOS = 1 8 ENABLE_CINE = 1 9 ENABLE_CRUISE = 1 10 ENABLE_DRASCULA = 1 11 ENABLE_GOB = 1 12 ENABLE_IGOR = 1 13 ENABLE_KYRA = 1 14 ENABLE_LURE = 1 15 ENABLE_M4 = 1 16 ENABLE_MADE = 1 17 ENABLE_PARALLACTION = 1 18 ENABLE_QUEEN = 1 19 ENABLE_SAGA = 1 20 ENABLE_SKY = 1 21 ENABLE_SWORD1 = 1 22 ENABLE_SWORD2 = 1 23 ENABLE_TOUCHE = 1 24 25 DISABLE_HQ_SCALERS = 1 26 DISABLE_SCALERS = 1 27 28 USE_ZLIB = 1 29 USE_MAD = 1 30 USE_TREMOR = 1 31 USE_FLAC = 1 32 USE_MPEG2 = 1 33 USE_MT32EMU = 1 34 35 srcdir = ../../.. 36 VPATH = $(srcdir) 37 HAVE_GCC3 = 1 38 39 DISTPATH = $(srcdir)/dists/wii 40 41 ifeq ($(strip $(DEVKITPPC)),) 42 $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC") 43 endif 44 45 PREFIX = $(DEVKITPPC)/bin/powerpc-gekko- 46 CXX = $(PREFIX)g++ 47 AS = $(PREFIX)gcc 48 LD = $(PREFIX)gcc 49 AR = $(PREFIX)ar cru 50 RANLIB = $(PREFIX)ranlib 51 STRIP = $(PREFIX)strip -g 52 OBJCOPY = $(PREFIX)objcopy 53 MKDIR = mkdir -p 54 RM = rm -f 55 CP = cp -f 56 57 TARGET = scummvm-wii 58 59 MACHDEP = -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float \ 60 -ffunction-sections -fdata-sections -fmodulo-sched 61 62 INCDIR = $(srcdir) . $(srcdir)/engines/ $(DEVKITPRO)/libogc/include 63 LIBDIR = $(DEVKITPRO)/libogc/lib/wii 64 65 CXXFLAGS = -g -Os -Wall $(MACHDEP) -D__WII__ \ 66 -Wno-multichar -fno-exceptions -fno-rtti 67 68 CXXFLAGS += $(addprefix -I,$(INCDIR)) 69 LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(TARGET).elf.map 70 LDFLAGS += $(addprefix -L,$(LIBDIR)) 71 LIBS = -lstdc++ -lfat -lwiiuse -lbte -logc -lm 72 73 CXXFLAGS += -I$(DEVKITPRO)/3rd/wii/include 74 LDFLAGS += -L$(DEVKITPRO)/3rd/wii/lib 75 76 ifdef DEBUG_WII 77 CXXFLAGS += -DDEBUG_WII 78 LIBS += -ldb 79 endif 80 81 ifdef USE_ZLIB 82 CXXFLAGS += -DUSE_ZLIB 83 LIBS += -lz 84 endif 85 86 ifdef USE_MAD 87 CXXFLAGS += -DUSE_MAD -I$(DEVKITPRO)/libogc/include/mad 88 LIBS += -lmad 89 endif 90 91 ifdef USE_TREMOR 92 CXXFLAGS += -DUSE_VORBIS -DUSE_TREMOR 93 LIBS += -lvorbisidec 94 endif 95 96 ifdef USE_FLAC 97 CXXFLAGS += -DUSE_FLAC 98 LIBS += -lFLAC 99 endif 100 101 ifdef USE_MPEG2 102 CXXFLAGS += -DUSE_MPEG2 103 LIBS += -lmpeg2 104 endif 105 106 ifdef USE_MT32EMU 107 CXXFLAGS += -DUSE_MT32EMU 108 endif 109 110 OBJS := backends/platform/wii/main.o \ 111 backends/platform/wii/gecko_console.o \ 112 backends/platform/wii/gx_supp.o \ 113 backends/platform/wii/osystem.o \ 114 backends/platform/wii/osystem_gfx.o \ 115 backends/platform/wii/osystem_sfx.o \ 116 backends/platform/wii/osystem_events.o 117 118 include $(srcdir)/Makefile.common 119 120 .PHONY: clean-wii distclean-wii upload dist 121 122 all: $(TARGET).dol 123 124 $(TARGET).dol: $(TARGET).elf 125 $(OBJCOPY) -O binary $< $@ 126 127 $(TARGET).elf: $(OBJS) 128 $(LD) $^ $(LDFLAGS) $(LIBS) -o $@ 129 130 clean: clean-wii 131 132 clean-wii: 133 @-$(RM) $(TARGET).elf $(TARGET).elf.map $(TARGET).dol 134 135 distclean: distclean-wii 136 137 distclean-wii: 138 @-$(RM) dist 139 140 upload: 141 $(DEVKITPPC)/bin/wiiload $(TARGET).dol 142 143 dist: 144 $(MKDIR) dist/apps/scummvm 145 $(CP) $(TARGET).dol dist/apps/scummvm/boot.dol 146 $(CP) $(DISTPATH)/meta.xml dist/apps/scummvm/ 147 $(CP) $(DISTPATH)/icon.png dist/apps/scummvm/ 148 $(CP) $(DISTPATH)/READMII dist/apps/scummvm/ 149 $(CP) $(srcdir)/AUTHORS dist/apps/scummvm/ 150 $(CP) $(srcdir)/COPYING dist/apps/scummvm/ 151 $(CP) $(srcdir)/COPYRIGHT dist/apps/scummvm/ 152 $(CP) $(srcdir)/NEWS dist/apps/scummvm/ 153 $(CP) $(srcdir)/README dist/apps/scummvm/ 154 $(CP) $(DIST_FILES_THEMES) dist/apps/scummvm/ 155 $(CP) $(DIST_FILES_ENGINEDATA) dist/apps/scummvm/ 156 -
backends/fs/wii/wii-fs.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #if defined(__WII__) 24 25 #include "backends/fs/abstract-fs.h" 26 27 #include <sys/dir.h> 28 29 #include <sys/types.h> 30 #include <sys/stat.h> 31 #include <unistd.h> 32 33 /** 34 * Implementation of the ScummVM file system API based on Wii. 35 * 36 * Parts of this class are documented in the base interface class, AbstractFilesystemNode. 37 */ 38 class WiiFilesystemNode : public AbstractFilesystemNode { 39 protected: 40 String _displayName; 41 String _path; 42 bool _isDirectory, _isReadable, _isWritable; 43 44 public: 45 /** 46 * Creates a WiiFilesystemNode with the root node as path. 47 */ 48 WiiFilesystemNode(); 49 50 /** 51 * Creates a WiiFilesystemNode for a given path. 52 * 53 * @param path String with the path the new node should point to. 54 * @param verify true if the isValid and isDirectory flags should be verified during the construction. 55 */ 56 WiiFilesystemNode(const String &path, bool verify); 57 58 virtual bool exists() const; 59 virtual String getDisplayName() const { return _displayName; } 60 virtual String getName() const { return _displayName; } 61 virtual String getPath() const { return _path; } 62 virtual bool isDirectory() const { return _isDirectory; } 63 virtual bool isReadable() const { return _isReadable; } 64 virtual bool isWritable() const { return _isWritable; } 65 66 virtual AbstractFilesystemNode *getChild(const String &n) const; 67 virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; 68 virtual AbstractFilesystemNode *getParent() const; 69 70 private: 71 virtual void setFlags(); 72 }; 73 74 /** 75 * Returns the last component of a given path. 76 * 77 * Examples: 78 * /foo/bar.txt would return /bar.txt 79 * /foo/bar/ would return /bar/ 80 * 81 * @param str String containing the path. 82 * @return Pointer to the first char of the last component inside str. 83 */ 84 const char *lastPathComponent(const Common::String &str) { 85 if(str.empty()) 86 return ""; 87 88 const char *start = str.c_str(); 89 const char *cur = start + str.size() - 2; 90 91 while (cur >= start && *cur != '/') { 92 --cur; 93 } 94 95 return cur + 1; 96 } 97 98 void WiiFilesystemNode::setFlags() { 99 struct stat st; 100 101 _isDirectory = false; 102 _isReadable = false; 103 _isWritable = false; 104 105 if (!stat(_path.c_str(), &st)) { 106 _isDirectory = S_ISDIR(st.st_mode); 107 _isReadable = (st.st_mode & S_IRUSR) > 0; 108 _isWritable = (st.st_mode & S_IWUSR) > 0; 109 } 110 } 111 112 113 WiiFilesystemNode::WiiFilesystemNode() { 114 // The root dir. 115 _path = "fat:/"; 116 _displayName = _path; 117 118 setFlags(); 119 } 120 121 WiiFilesystemNode::WiiFilesystemNode(const String &p, bool verify) { 122 assert(p.size() > 0); 123 124 _path = p; 125 126 _displayName = lastPathComponent(_path); 127 128 if (verify) 129 setFlags(); 130 } 131 132 bool WiiFilesystemNode::exists() const { 133 struct stat st; 134 return stat(_path.c_str (), &st) == 0; 135 } 136 137 AbstractFilesystemNode *WiiFilesystemNode::getChild(const String &n) const { 138 assert(_isDirectory); 139 140 String newPath(_path); 141 if (newPath.lastChar() != '/') 142 newPath += '/'; 143 newPath += n; 144 145 return new WiiFilesystemNode(newPath, true); 146 } 147 148 bool WiiFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const { 149 assert(_isDirectory); 150 151 DIR_ITER* dp = diropen (_path.c_str()); 152 153 if (dp == NULL) 154 return false; 155 156 char filename[MAXPATHLEN]; 157 struct stat st; 158 159 while (dirnext(dp, filename, &st) == 0) { 160 if (strcmp(filename, ".") == 0 || strcmp(filename, "..") == 0) 161 continue; 162 163 String newPath(_path); 164 if (newPath.lastChar() != '/') 165 newPath += '/'; 166 newPath += filename; 167 168 bool isDir = S_ISDIR(st.st_mode); 169 170 if ((mode == FilesystemNode::kListFilesOnly && isDir) || 171 (mode == FilesystemNode::kListDirectoriesOnly && !isDir)) 172 continue; 173 174 if (isDir) 175 newPath += '/'; 176 177 myList.push_back(new WiiFilesystemNode(newPath, true)); 178 } 179 180 dirclose(dp); 181 182 return true; 183 } 184 185 AbstractFilesystemNode *WiiFilesystemNode::getParent() const { 186 if (_path == "/") 187 return 0; 188 189 const char *start = _path.c_str(); 190 const char *end = lastPathComponent(_path); 191 192 return new WiiFilesystemNode(String(start, end - start), true); 193 } 194 195 #endif //#if defined(__WII__) 196 -
backends/fs/wii/wii-fs-factory.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #if defined(__WII__) 24 25 #include <unistd.h> 26 27 #include "backends/fs/wii/wii-fs-factory.h" 28 #include "backends/fs/wii/wii-fs.cpp" 29 30 DECLARE_SINGLETON(WiiFilesystemFactory); 31 32 AbstractFilesystemNode *WiiFilesystemFactory::makeRootFileNode() const { 33 return new WiiFilesystemNode(); 34 } 35 36 AbstractFilesystemNode *WiiFilesystemFactory::makeCurrentDirectoryFileNode() const { 37 char buf[MAXPATHLEN]; 38 39 if (getcwd(buf, MAXPATHLEN)) 40 return new WiiFilesystemNode(buf, true); 41 else 42 return new WiiFilesystemNode(); 43 } 44 45 AbstractFilesystemNode *WiiFilesystemFactory::makeFileNodePath(const String &path) const { 46 return new WiiFilesystemNode(path, true); 47 } 48 #endif 49 -
backends/fs/wii/wii-fs-factory.h
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef _WII_FILESYSTEM_FACTORY_H_ 24 #define _WII_FILESYSTEM_FACTORY_H_ 25 26 #include "common/singleton.h" 27 #include "backends/fs/fs-factory.h" 28 29 /** 30 * Creates WiiFilesystemNode objects. 31 * 32 * Parts of this class are documented in the base interface class, FilesystemFactory. 33 */ 34 class WiiFilesystemFactory : public FilesystemFactory, public Common::Singleton<WiiFilesystemFactory> { 35 public: 36 typedef Common::String String; 37 38 virtual AbstractFilesystemNode *makeRootFileNode() const; 39 virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; 40 virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; 41 42 protected: 43 WiiFilesystemFactory() {}; 44 45 private: 46 friend class Common::Singleton<SingletonBaseType>; 47 }; 48 49 #endif /*Wii_FILESYSTEM_FACTORY_H*/ 50 -
backends/module.mk
9 9 fs/psp/psp-fs-factory.o \ 10 10 fs/symbian/symbian-fs-factory.o \ 11 11 fs/windows/windows-fs-factory.o \ 12 fs/wii/wii-fs-factory.o \ 12 13 events/default/default-events.o \ 13 14 midi/alsa.o \ 14 15 midi/camd.o \