diff options
| author | David Corrales | 2007-07-08 16:58:54 +0000 |
|---|---|---|
| committer | David Corrales | 2007-07-08 16:58:54 +0000 |
| commit | 9bfe5d53540af7dc9bf0214202f4e35b272320ea (patch) | |
| tree | 69dcaf6f735e9fd0913a3e2f163852d4b9af87e3 /backends | |
| parent | 256e4d9521b79160d1f9ed670656097a96dc5a34 (diff) | |
| parent | 17da12ca07a1f18f3fe1ef5b0c2c0cd9fd8359b4 (diff) | |
| download | scummvm-rg350-9bfe5d53540af7dc9bf0214202f4e35b272320ea.tar.gz scummvm-rg350-9bfe5d53540af7dc9bf0214202f4e35b272320ea.tar.bz2 scummvm-rg350-9bfe5d53540af7dc9bf0214202f4e35b272320ea.zip | |
Merged the FSNode branch with trunk r27681:27969
svn-id: r27970
Diffstat (limited to 'backends')
48 files changed, 1394 insertions, 398 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index ad21b09070..6bd97c7f71 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -26,9 +26,13 @@ #if !defined(DISABLE_DEFAULT_EVENTMANAGER) #include "common/stdafx.h" +#include "common/config-manager.h" #include "common/system.h" #include "backends/events/default/default-events.h" +#include "engines/engine.h" +#include "gui/message.h" + DefaultEventManager::DefaultEventManager(OSystem *boss) : _boss(boss), _buttonState(0), @@ -93,7 +97,15 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { break; case Common::EVENT_QUIT: - _shouldQuit = true; + if (ConfMan.getBool("confirm_exit")) { + if (g_engine) + g_engine->pauseEngine(true); + GUI::MessageDialog alert("Do you really want to quit?", "Yes", "No"); + result = _shouldQuit = (alert.runModal() == GUI::kMessageOK); + if (g_engine) + g_engine->pauseEngine(false); + } else + _shouldQuit = true; break; default: diff --git a/backends/platform/PalmOS/Src/be_base.h b/backends/platform/PalmOS/Src/be_base.h index a5891b99c8..7881275358 100644 --- a/backends/platform/PalmOS/Src/be_base.h +++ b/backends/platform/PalmOS/Src/be_base.h @@ -196,10 +196,6 @@ public: virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); - virtual int screenToOverlayX(int x); - virtual int screenToOverlayY(int y); - virtual int overlayToScreenX(int x); - virtual int overlayToScreenY(int y); virtual OverlayColor ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b); virtual void colorToARGB(OverlayColor color, uint8 &a, uint8 &r, uint8 &g, uint8 &b); diff --git a/backends/platform/PalmOS/Src/launcher/launch.cpp b/backends/platform/PalmOS/Src/launcher/launch.cpp index 7bc07c4fdf..9613abf1cc 100644 --- a/backends/platform/PalmOS/Src/launcher/launch.cpp +++ b/backends/platform/PalmOS/Src/launcher/launch.cpp @@ -424,7 +424,7 @@ Boolean StartScummVM(Int16 engine) { toLauncher= (gPrefs->exitLauncher); // gVars values - // (gVars->HRrefNum defined in checkHRmode on Clié) + // (gVars->HRrefNum defined in checkHRmode on Clie) #ifndef _DEBUG_ENGINE gVars->VFS.volRefNum = (gPrefs->card.autoDetect ? vfsInvalidVolRef : gPrefs->card.volRefNum); #else diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index fa47ed21f5..aa2f7b2f92 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -144,10 +144,6 @@ class OSystem_Dreamcast : public OSystem { // Overlay int16 getOverlayHeight(); int16 getOverlayWidth(); - int screenToOverlayX(int x); - int screenToOverlayY(int y); - int overlayToScreenX(int x); - int overlayToScreenY(int y); void showOverlay(); void hideOverlay(); void clearOverlay(); diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index da9f6e83ff..1790785b67 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -585,7 +585,7 @@ void OSystem_Dreamcast::copyRectToOverlay(const int16 *buf, int pitch, static const OSystem::GraphicsMode gfxmodes[] = { - { "default", "640×480 16bpp", 0 }, + { "default", "640x480 16bpp", 0 }, { NULL, NULL, 0 } }; @@ -645,23 +645,3 @@ int16 OSystem_Dreamcast::getOverlayWidth() return OVL_W; } -int OSystem_Dreamcast::screenToOverlayX(int x) -{ - return x - _overlay_x; -} - -int OSystem_Dreamcast::screenToOverlayY(int y) -{ - return y - _overlay_y; -} - -int OSystem_Dreamcast::overlayToScreenX(int x) -{ - return x + _overlay_x; -} - -int OSystem_Dreamcast::overlayToScreenY(int y) -{ - return y + _overlay_y; -} - diff --git a/backends/platform/dc/input.cpp b/backends/platform/dc/input.cpp index f3638a28db..aa0d9efa21 100644 --- a/backends/platform/dc/input.cpp +++ b/backends/platform/dc/input.cpp @@ -48,7 +48,7 @@ int handleInput(struct mapledev *pad, int &mouse_x, int &mouse_y, if(!(buttons & 4)) lmb++; if(!(buttons & 2)) rmb++; - if(!(buttons & 8)) newkey = Common::ASCII_F5; + if(!(buttons & 8)) newkey = Common::KEYCODE_F5; else if(!(buttons & 512)) newkey = ' '; else if(!(buttons & 1024)) newkey = numpadmap[(buttons>>4)&15]; @@ -69,7 +69,7 @@ int handleInput(struct mapledev *pad, int &mouse_x, int &mouse_y, if(!(buttons & 4)) lmb++; if(!(buttons & 2)) rmb++; - if(!(buttons & 8)) newkey = Common::ASCII_F5; + if(!(buttons & 8)) newkey = Common::KEYCODE_F5; mouse_x += pad->cond.mouse.axis1; mouse_y += pad->cond.mouse.axis2; @@ -98,10 +98,10 @@ int handleInput(struct mapledev *pad, int &mouse_x, int &mouse_y, newkey = key+('1'-0x59); else if(key >= 0x2d && key <= 0x38 && key != 0x31) newkey = ((shift & 0x22)? - "=¯`{ }+*½<>?" : - "-^@[ ];:§,./")[key - 0x2d]; + "=?`{ }+*?<>?" : + "-^@[ ];:?,./")[key - 0x2d]; else if(key >= 0x3a && key <= 0x43) - newkey = key+(Common::ASCII_F1-0x3a); + newkey = key+(Common::KEYCODE_F1-0x3a); else if(key >= 0x54 && key <= 0x57) newkey = "/*-+"[key-0x54]; else switch(key) { @@ -134,7 +134,7 @@ int handleInput(struct mapledev *pad, int &mouse_x, int &mouse_y, case 0x64: case 0x87: newkey = ((shift & 0x22)? '_' : '\\'); break; case 0x89: - newkey = ((shift & 0x22)? '|' : '¥'); break; + newkey = ((shift & 0x22)? '|' : '?'); break; } } } diff --git a/backends/platform/dc/selector.cpp b/backends/platform/dc/selector.cpp index 8262a39614..b082afabf5 100644 --- a/backends/platform/dc/selector.cpp +++ b/backends/platform/dc/selector.cpp @@ -364,7 +364,7 @@ int gameMenu(Game *games, int num_games) event = handleInput(locked_get_pads(), mousex, mousey, shiftFlags); setimask(mask); - if(event==-Common::EVENT_LBUTTONDOWN || event==13 || event==Common::ASCII_F5) { + if(event==-Common::EVENT_LBUTTONDOWN || event==Common::KEYCODE_ENTER || event==Common::KEYCODE_F5) { int selected_game = top_game + selector_pos; for(int fade=0; fade<=256; fade+=4) { diff --git a/backends/platform/dc/softkbd.cpp b/backends/platform/dc/softkbd.cpp index 58b492f6db..79363713a5 100644 --- a/backends/platform/dc/softkbd.cpp +++ b/backends/platform/dc/softkbd.cpp @@ -52,7 +52,7 @@ static const char key_names[] = static const short key_codes[] = { - Common::KEYCODE_ESCAPE, Common::ASCII_F1, Common::ASCII_F2, Common::ASCII_F3, Common::ASCII_F4, Common::ASCII_F5, Common::ASCII_F6, Common::ASCII_F7, Common::ASCII_F8, Common::ASCII_F9, Common::ASCII_F10, + Common::KEYCODE_ESCAPE, Common::KEYCODE_F1, Common::KEYCODE_F2, Common::KEYCODE_F3, Common::KEYCODE_F4, Common::KEYCODE_F5, Common::KEYCODE_F6, Common::KEYCODE_F7, Common::KEYCODE_F8, Common::KEYCODE_F9, Common::KEYCODE_F10, K('1','!'), K('2','"'), K('3','#'), K('4','$'), K('5','%'), K('6','&'), K('7','\''), K('8','('), K('9',')'), K('0','~'), K('-','='), K('q','Q'), K('w','W'), K('e','E'), K('r','R'), K('t','T'), diff --git a/backends/platform/ds/arm9/data/icons.raw b/backends/platform/ds/arm9/data/icons.raw Binary files differindex c2915b2914..c8fbfd6e9a 100644 --- a/backends/platform/ds/arm9/data/icons.raw +++ b/backends/platform/ds/arm9/data/icons.raw diff --git a/backends/platform/ds/arm9/makefile b/backends/platform/ds/arm9/makefile index cb41774064..c9ca5467f3 100644 --- a/backends/platform/ds/arm9/makefile +++ b/backends/platform/ds/arm9/makefile @@ -4,18 +4,32 @@ libndsdir = /home/neil/devkitpro/libnds # Select the build you want by uncommenting one of the following lines: -DS_BUILD_A = 1 + +#DS_BUILD_A = 1 #DS_BUILD_B = 1 #DS_BUILD_C = 1 -#DS_BUILD_D = 1 +DS_BUILD_D = 1 +#DS_BUILD_E = 1 +#DS_BUILD_F = 1 # Uncomment the following line to build in support for MP3 audio # using libmad: -USE_MAD = 1 + +ifdef DS_BUILD_F + # TODO: Fix this. When libmad is compiled in, the Kyrandia resource loading + # searches through it's entire index to find an mp3 each time a voice sample is requested + # this causes a nasty pause. +else + USE_MAD = 1 +endif # Uncomment the following line to enable support for the # ace DS Debugger (remembering to make the same change in the arm7 makefile): #USE_DEBUGGER = 1 + +# Uncomment the following line to enable the profiler +#USE_PROFILER = 1 + # NOTE: The header and libs for the debugger is assumed to be in the libnds # folder. @@ -24,6 +38,7 @@ VPATH = $(srcdir) # Command to build libmad is: # ./configure --host=arm-elf --enable-speed --enable-sso -enable-fpm=arm CFLAGS='-specs=ds_arm9.specs -mthumb-interwork' +ARM = 1 ifdef DS_BUILD_A DEFINES = -DDS_SCUMM_BUILD -DDS_BUILD_A @@ -44,6 +59,7 @@ ifdef DS_BUILD_A DISABLE_AGI = 1 DISABLE_TOUCHE = 1 DISABLE_PARALLACTION = 1 + DISABLE_CRUISE = 1 BUILD=scummvm-A endif @@ -66,6 +82,7 @@ ifdef DS_BUILD_B DISABLE_AGI = 1 DISABLE_TOUCHE = 1 DISABLE_PARALLACTION = 1 + DISABLE_CRUISE = 1 BUILD=scummvm-B endif @@ -81,13 +98,14 @@ ifdef DS_BUILD_C DISABLE_SWORD2 = 1 DISABLE_QUEEN = 1 DISABLE_SAGA = 1 - #DISABLE_KYRA = 1 - #DISABLE_GOB = 1 + DISABLE_KYRA = 1 + DISABLE_GOB = 1 DISABLE_LURE = 1 DISABLE_CINE = 1 DISABLE_AGI = 1 DISABLE_TOUCHE = 1 DISABLE_PARALLACTION = 1 + DISABLE_CRUISE = 1 BUILD=scummvm-C endif @@ -104,15 +122,62 @@ ifdef DS_BUILD_D DISABLE_QUEEN = 1 DISABLE_SAGA = 1 DISABLE_KYRA = 1 - DISABLE_GOB = 1 + #DISABLE_GOB = 1 DISABLE_LURE = 1 #DISABLE_CINE = 1 #DISABLE_AGI = 1 DISABLE_TOUCHE = 1 DISABLE_PARALLACTION = 1 - BUILD=scummvm-A + DISABLE_CRUISE = 1 + BUILD=scummvm-D endif +ifdef DS_BUILD_E + DEFINES = -DDS_NON_SCUMM_BUILD -DDS_BUILD_E + LOGO = logoc.bmp + DISABLE_HE = 1 + DISABLE_SCUMM = 1 + DISABLE_SCUMM_7_8 = 1 + DISABLE_AGOS = 1 + DISABLE_SKY = 1 + DISABLE_SWORD1 = 1 + DISABLE_SWORD2 = 1 + DISABLE_QUEEN = 1 + #DISABLE_SAGA = 1 + DISABLE_KYRA = 1 + DISABLE_GOB = 1 + DISABLE_LURE = 1 + DISABLE_CINE = 1 + DISABLE_AGI = 1 + DISABLE_TOUCHE = 1 + DISABLE_PARALLACTION = 1 + DISABLE_CRUISE = 1 + BUILD=scummvm-E +endif + +ifdef DS_BUILD_F + DEFINES = -DDS_NON_SCUMM_BUILD -DDS_BUILD_F + LOGO = logoc.bmp + DISABLE_HE = 1 + DISABLE_SCUMM = 1 + DISABLE_SCUMM_7_8 = 1 + DISABLE_AGOS = 1 + DISABLE_SKY = 1 + DISABLE_SWORD1 = 1 + DISABLE_SWORD2 = 1 + DISABLE_QUEEN = 1 + DISABLE_SAGA = 1 + #DISABLE_KYRA = 1 + DISABLE_GOB = 1 + DISABLE_LURE = 1 + DISABLE_CINE = 1 + DISABLE_AGI = 1 + DISABLE_TOUCHE = 1 + DISABLE_PARALLACTION = 1 + DISABLE_CRUISE = 1 + BUILD=scummvm-F + +endif ARM7BIN := -7 $(CURDIR)/../../arm7/arm7.bin ICON := -b ../../../logo.bmp "ScummVM;By Neil Millstone;" @@ -120,7 +185,7 @@ ICON := -b ../../../logo.bmp "ScummVM;By Neil Millstone;" CC = arm-eabi-gcc CXX = arm-eabi-g++ -CFLAGS = -Wno-multichar -Wall -Os\ +CFLAGS = -Wno-multichar -Wall\ -Wno-multichar -mcpu=arm9tdmi -mtune=arm9tdmi \ -mcpu=arm9tdmi -mtune=arm9tdmi -fomit-frame-pointer\ -ffast-math -mthumb-interwork @@ -129,12 +194,17 @@ ifdef USE_DEBUGGER DEFINES += -DUSE_DEBUGGER CFLAGS += -g endif + +ifdef USE_PROFILER + CFLAGS += -mpoke-function-name -finstrument-functions -g + DEFINES += -DUSE_PROFILER +endif CXXFLAGS= $(CFLAGS) -Wno-non-virtual-dtor -Wno-non-virtual-dtor \ -fno-exceptions -fno-rtti ASFLAGS = -mcpu=arm9tdmi -mthumb-interwork -DEFINES += -D__DS__ -DNDS -DARM9 -DNONSTANDARD_PORT -DDISABLE_FANCY_THEMES -DDISABLE_DEFAULT_SAVEFILEMANAGER +DEFINES += -D__DS__ -DNDS -DARM9 -DNONSTANDARD_PORT -DDISABLE_FANCY_THEMES -DDISABLE_DEFAULT_SAVEFILEMANAGER -DARM ifdef USE_MAD DEFINES += -DUSE_MAD endif @@ -182,9 +252,14 @@ PORT_OBJS := $(portdir)/source/blitters.o $(portdir)/source/cdaudio.o $(portdir) $(portdir)/../../../fs/ds/ds-fs.o $(portdir)/source/gbampsave.o $(portdir)/source/scummhelp.o\ $(portdir)/source/osystem_ds.o $(portdir)/source/portdefs.o $(portdir)/source/ramsave.o\ $(portdir)/source/scummconsole.o $(portdir)/source/touchkeyboard.o $(portdir)/source/zipreader.o\ - $(portdir)/source/dsoptions.o $(portdir)/source/keys.o + $(portdir)/source/dsoptions.o $(portdir)/source/keys.o $(portdir)/source/wordcompletion.o -DATA_OBJS := $(portdir)/data/icons.o $(portdir)/data/keyboard.o $(portdir)/data/keyboard_pal.o $(portdir)/data/default_font.o +ifdef USE_PROFILER + PORT_OBJS += $(portdir)/source/profiler/cyg-profile.o +endif + + +DATA_OBJS := $(portdir)/data/icons.o $(portdir)/data/keyboard.o $(portdir)/data/keyboard_pal.o $(portdir)/data/default_font.o $(portdir)/data/8x8font_tga.o COMPRESSOR_OBJS := $(portdir)/source/compressor/lz.o @@ -209,7 +284,9 @@ FAT_OBJS := $(portdir)/source/fat/disc_io.o $(portdir)/source/fat/gba_nds_fat.o LIBCARTRESET_OBJS := $(portdir)/source/libcartreset/cartreset.o - +# Files in this list will be compiled with -O2, otherwise they will be compiled with -Os +OPTLIST := actor.cpp ds_main.cpp osystem_ds.cpp blitters.cpp fmopl.cpp rate.cpp mixer.cpp +#OPTLIST := OBJS := $(DATA_OBJS) $(LIBCARTRESET_OBJS) $(PORT_OBJS) $(COMPRESSOR_OBJS) $(FAT_OBJS) @@ -269,6 +346,7 @@ endef # rm $(*).tmp #endef + ############## # Replacement rule for the one in makefile.common ############## @@ -276,6 +354,7 @@ ifndef HAVE_GCC3 # If you use GCC, disable the above and enable this for intelligent # dependency tracking. .cpp.o: + $(MKDIR) $(*D)/$(DEPDIR) $(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d2" $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o # $(ECHO) "$(*D)/" > $(*D)/$(DEPDIR)/$(*F).d @@ -287,9 +366,19 @@ else # Also, with this GCC inserts additional dummy rules for the involved headers, # which ensures a smooth compilation even if said headers become obsolete. .cpp.o: +# echo !!!!!!!!!!!! $(notdir $<) +# ifeq ( $(notdir $<), $(findstring $(notdir $<), $(OPTLIST)) ) +# OPTFLAG=-O3 +# else +# OPTFLAG=-Os +# endif + +# export OPTFLAG = ; +# echo !!!!!!!! $(OPTFLAG) + $(MKDIR) $(*D)/$(DEPDIR) -# $(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o - $(CXX) -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o + $(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o + $(CXX) -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o $(if $(findstring $(notdir $<), $(OPTLIST)), -O2, -Os) endif @@ -333,8 +422,8 @@ endif #--------------------------------------------------------------------------------- %.nds: %.bin - @echo ndstool -c $@ -9 scummvm.bin $(ARM7BIN) -b ../../$(LOGO) "$(shell basename $@);ScummVM 0.11.0svn;DS Port" - ndstool -c $@ -9 scummvm.bin $(ARM7BIN) -b ../../$(LOGO) "$(shell basename $@);ScummVM 0.11.0svn;DS Port" + @echo ndstool -c $@ -9 scummvm.bin $(ARM7BIN) -b ../../$(LOGO) "$(shell basename $@);ScummVM 0.10.0;DS Port" + ndstool -c $@ -9 scummvm.bin $(ARM7BIN) -b ../../$(LOGO) "$(shell basename $@);ScummVM 0.10.0;DS Port" dsbuild $@ -l ../ndsloader.bin padbin 16 $(basename $@).ds.gba diff --git a/backends/platform/ds/arm9/source/blitters.cpp b/backends/platform/ds/arm9/source/blitters.cpp index 9af3c5d611..ec33a5aab4 100644 --- a/backends/platform/ds/arm9/source/blitters.cpp +++ b/backends/platform/ds/arm9/source/blitters.cpp @@ -1,8 +1,6 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. +/* ScummVM - Scumm Interpreter + * Copyright (C) 2005-2006 Neil Millstone + * Copyright (C) 2006 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/backends/platform/ds/arm9/source/blitters.h b/backends/platform/ds/arm9/source/blitters.h index 9fb50cdf0d..fe6966fdae 100644 --- a/backends/platform/ds/arm9/source/blitters.h +++ b/backends/platform/ds/arm9/source/blitters.h @@ -23,6 +23,10 @@ #ifndef _BLITTERS_H_ #define _BLITTERS_H_ +#define USING_ARM_BLITTERS + +#ifndef USING_ARM_BLITTERS + namespace DS { void asmDrawStripToScreen(int height, int width, byte const* text, byte const* src, byte* dst, @@ -33,4 +37,18 @@ void Rescale_320x256x1555_To_256x256x1555(u16* dest, const u16* src, int destStr } +#else + +extern "C" { + +void asmDrawStripToScreen(int height, int width, byte const* text, byte const* src, byte* dst, + int vsPitch, int vmScreenWidth, int textSurfacePitch); +void asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height); +void Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, const u16* palette, int destStride, int srcStride); +void Rescale_320x256x1555_To_256x256x1555(u16* dest, const u16* src, int destStride, int srcStride); + +} + +#endif + #endif diff --git a/backends/platform/ds/arm9/source/blitters.s b/backends/platform/ds/arm9/source/blitters.s new file mode 100644 index 0000000000..2f14c5a140 --- /dev/null +++ b/backends/platform/ds/arm9/source/blitters.s @@ -0,0 +1,339 @@ +@ ScummVM Scumm Interpreter +@ Copyright (C) 2007 The ScummVM project +@ +@ This program is free software@ you can redistribute it and/or +@ modify it under the terms of the GNU General Public License +@ as published by the Free Software Foundation@ either version 2 +@ of the License, or (at your option) any later version. +@ +@ This program is distributed in the hope that it will be useful, +@ but WITHOUT ANY WARRANTY; without even the implied warranty of +@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +@ GNU General Public License for more details. +@ +@ You should have received a copy of the GNU General Public License +@ along with this program@ if not, write to the Free Software +@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +@ +@ $URL: $ +@ $Id: $ +@ +@ @author Robin Watts (robin@wss.co.uk) + + .text + + .global asmDrawStripToScreen + .global asmCopy8Col + .global Rescale_320x256xPAL8_To_256x256x1555 + .global Rescale_320x256x1555_To_256x256x1555 + + @ ARM implementation of asmDrawStripToScreen. + @ + @ C prototype would be: + @ + @ extern "C" void asmDrawStripToScreen(int height, + @ int width, + @ byte const *text, + @ byte const *src, + @ byte *dst, + @ int vsPitch, + @ int vsScreenWidth, + @ int textSurfacePitch); + @ + @ In addition, we assume that text, src and dst are all word (4 byte) + @ aligned. This is the same assumption that the old 'inline' version + @ made. +asmDrawStripToScreen: + @ r0 = height + @ r1 = width + @ r2 = text + @ r3 = src + MOV r12,r13 + STMFD r13!,{r4-r7,r9-r11,R14} + LDMIA r12,{r4,r5,r6,r7} + @ r4 = dst + @ r5 = vsPitch + @ r6 = vmScreenWidth + @ r7 = textSurfacePitch + + CMP r0,#0 @ If height<=0 + MOVLE r0,#1 @ height=1 + CMP r1,#4 @ If width<4 + BLT end @ return + + @ Width &= ~4 ? What's that about then? Width &= ~3 I could have + @ understood... + BIC r1,r1,#4 + + SUB r5,r5,r1 @ vsPitch -= width + SUB r6,r6,r1 @ vmScreenWidth -= width + SUB r7,r7,r1 @ textSurfacePitch -= width + MOV r10,#253 + ORR r10,r10,r10,LSL #8 + ORR r10,r10,r10,LSL #16 @ r10 = mask +yLoop: + MOV r14,r1 @ r14 = width +xLoop: + LDR r12,[r2],#4 @ r12 = [text] + LDR r11,[r3],#4 @ r11 = [src] + CMP r12,r10 + BNE singleByteCompare + SUBS r14,r14,#4 + STR r11,[r4], #4 @ r4 = [dst] + BGT xLoop + + ADD r2,r2,r7 @ text += textSurfacePitch + ADD r3,r3,r5 @ src += vsPitch + ADD r4,r4,r6 @ dst += vmScreenWidth + SUBS r0,r0,#1 + BGT yLoop + LDMFD r13!,{r4-r7,r9-r11,PC} + +singleByteCompare: + MOV r9,r12,LSR #24 @ r9 = 1st byte of [text] + CMP r9,r10,LSR #24 @ if (r9 == mask) + MOVEQ r9,r11,LSR #24 @ r9 = 1st byte of [src] + ORR r12,r9,r12,LSL #8 @ r12 = combine r9 and r12 + + MOV r9,r12,LSR #24 @ r9 = 1st byte of [text] + CMP r9,r10,LSR #24 @ if (r9 == mask) + MOVEQ r9,r11,LSR #24 @ r9 = 1st byte of [src] + ORR r12,r9,r12,LSL #8 @ r12 = combine r9 and r12 + + MOV r9,r12,LSR #24 @ r9 = 1st byte of [text] + CMP r9,r10,LSR #24 @ if (r9 == mask) + MOVEQ r9,r11,LSR #24 @ r9 = 1st byte of [src] + ORR r12,r9,r12,LSL #8 @ r12 = combine r9 and r12 + + MOV r9,r12,LSR #24 @ r9 = 1st byte of [text] + CMP r9,r10,LSR #24 @ if (r9 == mask) + MOVEQ r9,r11,LSR #24 @ r9 = 1st byte of [src] + ORR r12,r9,r12,LSL #8 @ r12 = combine r9 and r12 + + STR r12,[r4],#4 + SUBS r14,r14,#4 + BGT xLoop + + ADD r2,r2,r7 @ text += textSurfacePitch + ADD r3,r3,r5 @ src += vsPitch + ADD r4,r4,r6 @ dst += vmScreenWidth + SUBS r0,r0,#1 + BGT yLoop +end: + LDMFD r13!,{r4-r7,r9-r11,PC} + + + @ ARM implementation of asmCopy8Col + @ + @ C prototype would be: + @ + @ extern "C" void asmCopy8Col(byte *dst, + @ int dstPitch, + @ const byte *src, + @ int height); + @ + @ In addition, we assume that src and dst are both word (4 byte) + @ aligned. This is the same assumption that the old 'inline' version + @ made. +asmCopy8Col: + @ r0 = dst + @ r1 = dstPitch + @ r2 = src + @ r3 = height + STMFD r13!,{r14} + SUB r1,r1,#4 + + TST r3,#1 + ADDNE r3,r3,#1 + BNE roll2 +yLoop2: + LDR r12,[r2],#4 + LDR r14,[r2],r1 + STR r12,[r0],#4 + STR r14,[r0],r1 +roll2: + LDR r12,[r2],#4 + LDR r14,[r2],r1 + SUBS r3,r3,#2 + STR r12,[r0],#4 + STR r14,[r0],r1 + BNE yLoop2 + + LDMFD r13!,{PC} + + + @ ARM implementation of Rescale_320x256x1555_To_256x256x1555 + @ + @ C prototype would be: + @ + @ extern "C" void Rescale_320x256x1555_To_256x256x1555( + @ u16 *dst, + @ const u16 *src, + @ int dstStride, + @ int srcStride); +Rescale_320x256x1555_To_256x256x1555: + @ r0 = dst + @ r1 = src + @ r2 = dstStride + @ r3 = srcStride + STMFD r13!,{r4-r5,r8-r11,r14} + + SUB r2,r2,#64*5 @ srcStride -= line length + SUB r3,r3,#64*4 @ dstStride -= line length + + MOV r8, #0x0000001F + ORR r8, r8,#0x00007C00 + ORR r8, r8,#0x03E00000 @ r8 = mask + MOV r5, #200 @ r5 = y +yLoop3: + MOV r4, #64 @ r4 = x +xLoop3: + LDRH r9, [r0],#2 @ r9 = src0 + LDRH r10,[r0],#2 @ r10= src1 + LDRH r11,[r0],#2 @ r11= src2 + LDRH r12,[r0],#2 @ r12= src3 + LDRH r14,[r0],#2 @ r14= src4 + + ORR r9, r9, r9, LSL #16 @ r9 = src0 | src0 + ORR r10,r10,r10,LSL #16 @ r10= src1 | src1 + ORR r11,r11,r11,LSL #16 @ r11= src2 | src2 + ORR r12,r12,r12,LSL #16 @ r12= src3 | src3 + ORR r14,r14,r14,LSL #16 @ r13= src4 | src4 + + AND r9, r9, r8 @ r9 = 0 | G0 | 0 | B0 | 0 | R0 + AND r10,r10,r8 @ r10= 0 | G1 | 0 | B1 | 0 | R1 + AND r11,r11,r8 @ r11= 0 | G2 | 0 | B2 | 0 | R2 + AND r12,r12,r8 @ r12= 0 | G3 | 0 | B3 | 0 | R3 + AND r14,r14,r8 @ r14= 0 | G4 | 0 | B4 | 0 | R4 + + ADD r9, r9, r9, LSL #1 @ r9 = 3*src0 + ADD r9, r9, r10 @ r9 = dst0<<2 + ADD r10,r10,r11 @ r10= dst1 + ADD r11,r11,r12 @ r11= dst2 + ADD r12,r12,r14 @ r12= src3 + src4 + ADD r12,r12,r14,LSL #1 @ r12= src3 + src4*3 = dst3<<2 + + AND r9, r8, r9, LSR #2 @ r9 = dst0 (split) + AND r10,r8, r10,LSR #1 @ r10= dst1 (split) + AND r11,r8, r11,LSR #1 @ r11= dst2 (split) + AND r12,r8, r12,LSR #2 @ r12= dst3 (split) + + ORR r9, r9, r9, LSR #16 @ r9 = dst0 + ORR r10,r10,r10,LSR #16 @ r10= dst1 + ORR r11,r11,r11,LSR #16 @ r11= dst2 + ORR r12,r12,r12,LSR #16 @ r12= dst3 + + ORR r9, r9, #0x8000 + ORR r10,r10,#0x8000 + ORR r11,r11,#0x8000 + ORR r12,r12,#0x8000 + + STRH r9, [r1],#2 + STRH r10,[r1],#2 + STRH r11,[r1],#2 + STRH r12,[r1],#2 + + SUBS r4,r4,#1 + BGT xLoop3 + + ADD r0,r0,r2,LSL #1 + ADD r1,r2,r3,LSL #1 + SUBS r5,r5,#1 + BGT yLoop3 + + LDMFD r13!,{r4-r5,r8-r11,PC} + + @ ARM implementation of Rescale_320x256xPAL8_To_256x256x1555 + @ + @ C prototype would be: + @ + @ extern "C" void Rescale_320x256xPAL8_To_256x256x1555( + @ u16 *dst, + @ const u8 *src, + @ int dstStride, + @ int srcStride, + @ const u16 *pal); + @ + @ This is a slight reordering of the params from the existing C one. + @ Sorry, but it makes the code easier. +Rescale_320x256xPAL8_To_256x256x1555: + @ r0 = dst + @ r1 = src + @ r2 = dstStride + @ r3 = srcStride + STMFD r13!,{r4-r5,r8-r11,r14} + MOV r8, #0x0000001F + ORR r8, r8,#0x00007C00 + ORR r8, r8,#0x03E00000 @ r8 = mask + LDR r9, [r13,#7*4] @ r9 = palette + + SUB r13,r13,#256*4 @ r13 = 1K of space on the stack. + MOV r5, r13 @ r5 points to this space + MOV r14,#256 +palLoop: + LDRH r10,[r9],#2 @ r10 = palette entry + SUBS r14,r14,#1 + ORR r10,r10,r10,LSL #16 + AND r10,r10,r8 @ r10 = separated palette entry + STR r10,[r5], #4 + BGT palLoop + + SUB r2,r2,#64*5 @ srcStride -= line length + SUB r3,r3,#64*4 @ dstStride -= line length + + MOV r5,#200 @ r5 = y +yLoop4: + MOV r4,#64 @ r4 = x +xLoop4: + LDRB r9, [r0],#1 @ r9 = src0 + LDRB r10,[r0],#1 @ r10= src1 + LDRB r11,[r0],#1 @ r11= src2 + LDRB r12,[r0],#1 @ r12= src3 + LDRB r14,[r0],#1 @ r14= src4 + + LDR r9, [r13,r9, LSL #2] @ r9 = pal[src0] + LDR r10,[r13,r10,LSL #2] @ r10= pal[src1] + LDR r11,[r13,r11,LSL #2] @ r11= pal[src2] + LDR r12,[r13,r12,LSL #2] @ r12= pal[src3] + LDR r14,[r13,r14,LSL #2] @ r13= pal[src4] + + ADD r9, r9, r9, LSL #1 @ r9 = 3*src0 + ADD r9, r9, r10 @ r9 = dst0<<2 + ADD r10,r10,r11 @ r10= dst1 + ADD r11,r11,r12 @ r11= dst2 + ADD r12,r12,r14 @ r12= src3 + src4 + ADD r12,r12,r14,LSL #1 @ r12= src3 + src4*3 = dst3<<2 + + AND r9, r8, r9, LSR #2 @ r9 = dst0 (split) + AND r10,r8, r10,LSR #1 @ r10= dst1 (split) + AND r11,r8, r11,LSR #1 @ r11= dst2 (split) + AND r12,r8, r12,LSR #2 @ r12= dst3 (split) + + ORR r9, r9, r9, LSR #16 @ r9 = dst0 + ORR r10,r10,r10,LSR #16 @ r10= dst1 + ORR r11,r11,r11,LSR #16 @ r11= dst2 + ORR r12,r12,r12,LSR #16 @ r12= dst3 + + ORR r9, r9, #0x8000 + ORR r10,r10,#0x8000 + ORR r11,r11,#0x8000 + ORR r12,r12,#0x8000 + + STRH r9, [r1],#2 + STRH r10,[r1],#2 + STRH r11,[r1],#2 + STRH r12,[r1],#2 + + SUBS r4,r4,#1 + BGT xLoop4 + + ADD r0,r0,r2 + ADD r1,r2,r3,LSL #1 + SUBS r5,r5,#1 + BGT yLoop4 + + ADD r13,r13,#256*4 + + LDMFD r13!,{r4-r5,r8-r11,PC} + + diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp index af5addac66..aafa54e347 100644 --- a/backends/platform/ds/arm9/source/dsmain.cpp +++ b/backends/platform/ds/arm9/source/dsmain.cpp @@ -44,9 +44,32 @@ // - Delete saves? // - Software scaler? // - 100% scale + +// - Arrow keys cause key events when keyboard enabled - Done +// - Mouse cursor display - Done +// - Disable scaler on options menu - Done +// - Fix scale icons on top screen - Done +// - Fseek optimisation? - No need +// - Fix agi hack to be cleaner - done +// - Fix not typing looong words - Done +// - Show keyboard by default in AGI games +// - Fix mouse moving when cursor on keyboard screen - Done +// - Fix 'fit' thingy always appearing - Done +// - check cine backbuffer code - Done +// - Add long filename support - Done +// - New icons +// - Add key config for gob engine: Start:F1, Shift-numbers: F keys - Done +// - Fix [ds] appearing in game menu + // - Find out what's going wrong when you turn the console off +// - enable console when asserting + +// - AGI: Adding keyboard hack +// - CINE: Framebuffer modification should check if it works without, fix for overwrite crash +// - KYRA: GetFileSize modification + -#define USE_LIBCARTRESET +//#define USE_LIBCARTRESET //#define USE_BUILT_IN_DRIVER_SELECTION #include <nds.h> @@ -78,6 +101,8 @@ #include "blitters.h" #include "cartreset_nolibfat.h" #include "keys.h" +#include "profiler/cyg-profile.h" +//test namespace DS { @@ -151,13 +176,16 @@ bool displayModeIs8Bit = false; // Game id u8 gameID; -bool consoleEnable = true; +bool consoleEnable = false; bool gameScreenSwap = false; bool isCpuScalerEnabled(); //#define HEAVY_LOGGING MouseMode mouseMode; +int storedMouseX = 0; +int storedMouseY = 0; + // Sprites SpriteEntry sprites[128]; SpriteEntry spritesMain[128]; @@ -173,6 +201,9 @@ bool keyboardIcon = false; // Touch int touchScX, touchScY, touchX, touchY; +int mouseHotspotX, mouseHotspotY; +bool cursorEnable = false; +bool mouseCursorVisible = true; // Dragging int dragStartX, dragStartY; @@ -188,20 +219,12 @@ int gameHeight = 200; // Scale bool twoHundredPercentFixedScale = false; +#define NUM_SUPPORTED_GAMES 17 -enum controlType { - CONT_SCUMM_ORIGINAL, - CONT_SCUMM_SAMNMAX, - CONT_SKY, - CONT_SIMON, -}; - -struct gameListType { - char gameId[16]; - controlType control; -}; +#ifdef USE_PROFILER +int hBlankCount = 0; +#endif -#define NUM_SUPPORTED_GAMES 15 gameListType gameList[NUM_SUPPORTED_GAMES] = { // Unknown game - use normal SCUMM controls @@ -222,8 +245,10 @@ gameListType gameList[NUM_SUPPORTED_GAMES] = { {"sky", CONT_SKY}, {"simon1", CONT_SIMON}, {"simon2", CONT_SIMON}, - {"gob1", CONT_SCUMM_ORIGINAL}, - {"queen", CONT_SCUMM_ORIGINAL} + {"gob", CONT_GOBLINS}, + {"queen", CONT_SCUMM_ORIGINAL}, + {"cine", CONT_FUTURE_WARS}, + {"agi", CONT_AGI} }; gameListType* currentGame = NULL; @@ -259,9 +284,11 @@ int getKeysChanged(); void updateStatus(); void triggerIcon(int imageNum); void setIcon(int num, int x, int y, int imageNum, int flags, bool enable); +void setIconMain(int num, int x, int y, int imageNum, int flags, bool enable); TransferSound soundControl; + bool isCpuScalerEnabled() { return (ConfMan.hasKey("cpu_scaler", "ds") && ConfMan.getBool("cpu_scaler", "ds")); @@ -332,20 +359,21 @@ void initSprites() { void saveGameBackBuffer() { #ifdef DISABLE_SCUMM - if (savedBuffer == NULL) savedBuffer = new u8[gameWidth * gameHeight]; + if (savedBuffer == NULL) savedBuffer = new u8[gameWidth * gameHeight]; for (int r = 0; r < gameHeight; r++) { memcpy(savedBuffer + (r * gameWidth), ((u8 *) (get8BitBackBuffer())) + (r * 512), gameWidth); + } #endif } void restoreGameBackBuffer() { #ifdef DISABLE_SCUMM if (savedBuffer) { - for (int r = 0; r < gameHeight; r++) { - memcpy(((u8 *) (BG_GFX_SUB)) + (r * 512), savedBuffer + (r * gameWidth), gameWidth); - memcpy(((u8 *) (get8BitBackBuffer())) + (r * 512), savedBuffer + (r * gameWidth), gameWidth); - } - + for (int r = 0; r < gameHeight; r++) { + memcpy(((u8 *) (BG_GFX_SUB)) + (r * 512), savedBuffer + (r * gameWidth), gameWidth); + memcpy(((u8 *) (get8BitBackBuffer())) + (r * 512), savedBuffer + (r * gameWidth), gameWidth); + } + delete savedBuffer; savedBuffer = NULL; } @@ -413,7 +441,7 @@ void initGame() { //strcpy(gameName, ConfMan.getActiveDomain().c_str()); strcpy(gameName, ConfMan.get("gameid").c_str()); -// consolePrintf("\n\n\n\nCurrent game: '%s' %d\n", gameName, gameName[0]); + //consolePrintf("\n\n\n\nCurrent game: '%s' %d\n", gameName, gameName[0]); currentGame = &gameList[0]; // Default game @@ -590,7 +618,51 @@ void checkSleepMode() { } } -void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor) { +void setShowCursor(bool enable) +{ + if (currentGame->control == CONT_SCUMM_SAMNMAX) + { + if (cursorEnable) { + sprites[1].attribute[0] = ATTR0_BMP | 150; + } else { + sprites[1].attribute[0] = ATTR0_DISABLED; + } + + } + + cursorEnable = enable; +} + +void setMouseCursorVisible(bool enable) +{ + mouseCursorVisible = enable; +} + +void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor, int hotspotX, int hotspotY) { + + mouseHotspotX = hotspotX; + mouseHotspotY = hotspotY; + + { + int off = 128*64; + + + memset(SPRITE_GFX + off, 0, 32 * 32 * 2); + + for (uint y=0; y<h; y++) { + for (uint x=0; x<w; x++) { + int color = icon[y*w+x]; + + if (color == keycolor) { + SPRITE_GFX[off+(y)*32+x] = 0x0000; // black background + } else { + SPRITE_GFX[off+(y)*32+x] = BG_PALETTE[color] | 0x8000; + } + } + } + + } + if (currentGame->control != CONT_SCUMM_SAMNMAX) return; @@ -619,6 +691,7 @@ void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor) { for (uint y=0; y<h; y++) { for (uint x=0; x<w; x++) { int color = icon[y*w+x]; + if (color == keycolor) { SPRITE_GFX_SUB[off+(y+1+offset)*64+(x+1)] = 0x8000; // black background } else { @@ -626,10 +699,18 @@ void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor) { } } } - - sprites[1].attribute[0] = ATTR0_BMP | 150; - sprites[1].attribute[1] = ATTR1_SIZE_64 | pos; - sprites[1].attribute[2] = ATTR2_ALPHA(1) | 48; + + + if ((cursorEnable)) + { + sprites[1].attribute[0] = ATTR0_BMP | 150; + sprites[1].attribute[1] = ATTR1_SIZE_64 | pos; + sprites[1].attribute[2] = ATTR2_ALPHA(1) | 48; + } else { + sprites[1].attribute[0] = ATTR0_DISABLED | 150; + sprites[1].attribute[1] = ATTR1_SIZE_64 | pos; + sprites[1].attribute[2] = ATTR2_ALPHA(1) | 48; + } } @@ -734,7 +815,7 @@ void displayMode16BitFlipBuffer() { #endif const u8* back = (const u8*)get8BitBackBuffer(); u16* base = BG_GFX + 0x10000; - DS::Rescale_320x256xPAL8_To_256x256x1555( base, + Rescale_320x256xPAL8_To_256x256x1555( base, back, BG_PALETTE, 256, @@ -867,7 +948,7 @@ void addIndyFightingKeys() { event.type = Common::EVENT_KEYDOWN; event.kbd.flags = 0; - consolePrintf("Fight keys\n"); +// consolePrintf("Fight keys\n"); if ((getKeysDown() & KEY_L)) { indyFightRight = false; @@ -877,7 +958,7 @@ void addIndyFightingKeys() { indyFightRight = true; } - consolePrintf("ifr:%d\n", indyFightRight); +// consolePrintf("ifr:%d\n", indyFightRight); if ((getKeysChanged() & KEY_UP)) { event.type = getKeyEvent(KEY_UP); @@ -966,10 +1047,10 @@ void setKeyboardEnable(bool en) { if (keyboardEnable) { - DS::drawKeyboard(1, 12, backupBank); + DS::drawKeyboard(1, 14, backupBank); - SUB_BG1_CR = BG_TILE_BASE(1) | BG_MAP_BASE(12); + SUB_BG1_CR = BG_TILE_BASE(1) | BG_MAP_BASE(14); if (displayModeIs8Bit) { SUB_DISPLAY_CR |= DISPLAY_BG1_ACTIVE; // Turn on keyboard layer @@ -1025,6 +1106,16 @@ void addEventsToQueue() { Common::Event event; +#ifdef USE_PROFILER + if (keysDown() & KEY_R) { + cygprofile_begin(); + cygprofile_enable(); + } + if (keysDown() & KEY_L) { + cygprofile_disable(); + cygprofile_end(); + } +#endif if (system->isEventQueueEmpty()) { @@ -1051,7 +1142,7 @@ void addEventsToQueue() { if (!indyFightState) { - if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) { + if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) && (getKeysChanged() & KEY_B)) { event.kbd.keycode = 27; event.kbd.ascii = 27; event.kbd.flags = 0; @@ -1073,8 +1164,37 @@ void addEventsToQueue() { } } + if (!((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) && (getKeyboardEnable())) { + event.kbd.flags = 0; + + if (getKeysChanged() & KEY_LEFT) { + event.kbd.keycode = SDLK_LEFT; + event.kbd.ascii = SDLK_LEFT; + event.type = getKeyEvent(KEY_LEFT); + } + + if (getKeysChanged() & KEY_RIGHT) { + event.kbd.keycode = SDLK_RIGHT; + event.kbd.ascii = SDLK_RIGHT; + event.type = getKeyEvent(KEY_RIGHT); + } + + if (getKeysChanged() & KEY_UP) { + event.kbd.keycode = SDLK_UP; + event.kbd.ascii = SDLK_UP; + event.type = getKeyEvent(KEY_UP); + } + + if (getKeysChanged() & KEY_DOWN) { + event.kbd.keycode = SDLK_DOWN; + event.kbd.ascii = SDLK_DOWN; + event.type = getKeyEvent(KEY_DOWN); + } + + system->addEvent(event); + } - if (!((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) && (!getIndyFightState())) { + if (!((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) && (!getIndyFightState()) && (!getKeyboardEnable())) { if ((getKeysDown() & KEY_A) && (!indyFightState)) { gameScreenSwap = !gameScreenSwap; @@ -1084,16 +1204,25 @@ void addEventsToQueue() { if (getKeysDown() & KEY_LEFT) { mouseMode = MOUSE_LEFT; } + if (getKeysDown() & KEY_RIGHT) { - if (currentGame->control != CONT_SCUMM_SAMNMAX) { + if ((currentGame->control != CONT_SCUMM_SAMNMAX) && (currentGame->control != CONT_FUTURE_WARS)) { mouseMode = MOUSE_RIGHT; } else { // If we're playing sam and max, click and release the right mouse // button to change verb Common::Event event; + + if (currentGame->control == CONT_FUTURE_WARS) { + event.mouse = Common::Point(320 - 128, 200 - 128); + event.type = Common::EVENT_MOUSEMOVE; + system->addEvent(event); + } else { + event.mouse = Common::Point(getPenX(), getPenY()); + } + event.type = Common::EVENT_RBUTTONDOWN; - event.mouse = Common::Point(getPenX(), getPenY()); system->addEvent(event); event.type = Common::EVENT_RBUTTONUP; @@ -1126,14 +1255,16 @@ void addEventsToQueue() { Common::Event event; - if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) { - event.type = Common::EVENT_MOUSEMOVE; - event.mouse = Common::Point(getPenX(), getPenY()); - system->addEvent(event); - //consolePrintf("x=%d y=%d \n", getPenX(), getPenY()); - } if (!keyboardEnable) { + + if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) { + event.type = Common::EVENT_MOUSEMOVE; + event.mouse = Common::Point(getPenX(), getPenY()); + system->addEvent(event); + //consolePrintf("x=%d y=%d \n", getPenX(), getPenY()); + } + if ((mouseMode != MOUSE_HOVER) || (!displayModeIs8Bit)) { if (getPenDown() && (!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) { event.type = ((mouseMode == MOUSE_LEFT) || (!displayModeIs8Bit))? Common::EVENT_LBUTTONDOWN: Common::EVENT_RBUTTONDOWN; @@ -1179,7 +1310,7 @@ void addEventsToQueue() { if (currentGame->control == CONT_SKY) { - // Extra controls for Benieth a Steel Sky + // Extra controls for Beneath a Steel Sky if ((getKeysDown() & KEY_DOWN)) { penY = 0; penX = 160; // Show inventory by moving mouse onto top line @@ -1253,8 +1384,18 @@ void addEventsToQueue() { if ((getKeysChanged() & KEY_START)) { event.type = getKeyEvent(KEY_START); - event.kbd.keycode = Common::KEYCODE_F5; - event.kbd.ascii = Common::ASCII_F5; + if (currentGame->control == CONT_FUTURE_WARS) { + event.kbd.keycode = Common::KEYCODE_F10; + event.kbd.ascii = Common::ASCII_F10; + } else if (currentGame->control == CONT_GOBLINS) { + event.kbd.keycode = Common::KEYCODE_F1; + event.kbd.ascii = Common::ASCII_F1; +// consolePrintf("!!!!!F1!!!!!"); + } else { + event.kbd.keycode = Common::KEYCODE_F5; + event.kbd.ascii = Common::ASCII_F5; +// consolePrintf("!!!!!F5!!!!!"); + } event.kbd.flags = 0; system->addEvent(event); } @@ -1280,11 +1421,17 @@ void triggerIcon(int imageNum) { void setIcon(int num, int x, int y, int imageNum, int flags, bool enable) { - sprites[num].attribute[0] = ATTR0_BMP | y | (!enable? ATTR0_DISABLED: 0); + sprites[num].attribute[0] = ATTR0_BMP | (enable? y: 192) | (!enable? ATTR0_DISABLED: 0); sprites[num].attribute[1] = ATTR1_SIZE_32 | x | flags; sprites[num].attribute[2] = ATTR2_ALPHA(1)| (imageNum * 16); } +void setIconMain(int num, int x, int y, int imageNum, int flags, bool enable) { + spritesMain[num].attribute[0] = ATTR0_BMP | (y & 0x1FF) | (!enable? ATTR0_DISABLED: 0); + spritesMain[num].attribute[1] = ATTR1_SIZE_32 | (x & 0x1FF) | flags; + spritesMain[num].attribute[2] = ATTR2_ALPHA(1)| (imageNum * 16); +} + void updateStatus() { int offs; @@ -1313,7 +1460,7 @@ void updateStatus() { if (indyFightState) { setIcon(1, (190 - 32), 150, 3, (indyFightRight? 0: ATTR1_FLIP_X), true); - consolePrintf("%d\n", indyFightRight); +// consolePrintf("%d\n", indyFightRight); } else { // setIcon(1, 0, 0, 0, 0, false); } @@ -1324,7 +1471,7 @@ void updateStatus() { } else { setIcon(4, 0, 0, 0, 0, false); } - + } else { setIcon(0, 0, 0, 0, 0, false); setIcon(1, 0, 0, 0, 0, false); @@ -1334,14 +1481,16 @@ void updateStatus() { } if ((keyboardIcon) && (!keyboardEnable) && (!displayModeIs8Bit)) { - spritesMain[0].attribute[0] = ATTR0_BMP | 160; - spritesMain[0].attribute[1] = ATTR1_SIZE_32 | 0; - spritesMain[0].attribute[2] = ATTR2_ALPHA(1) | 64; +// spritesMain[0].attribute[0] = ATTR0_BMP | 160; +// spritesMain[0].attribute[1] = ATTR1_SIZE_32 | 0; +// spritesMain[0].attribute[2] = ATTR2_ALPHA(1) | 64; + setIconMain(0, 0, 160, 4, 0, true); } else { - spritesMain[0].attribute[0] = ATTR0_DISABLED; - spritesMain[0].attribute[1] = 0; - spritesMain[0].attribute[2] = 0; - spritesMain[0].attribute[3] = 0; +// spritesMain[0].attribute[0] = ATTR0_DISABLED; +// spritesMain[0].attribute[1] = 0; +// spritesMain[0].attribute[2] = 0; +// spritesMain[0].attribute[3] = 0; + setIconMain(0, 0, 0, 0, 0, false); } } @@ -1428,6 +1577,10 @@ void setZoomedScreenScale(int x, int y) { } } +#ifdef USE_PROFILER +void VBlankHandler(void) __attribute__ ((no_instrument_function)); +#endif + void VBlankHandler(void) { // BG_PALETTE[0] = RGB15(31, 31, 31); // if (*((int *) (0x023FFF00)) != 0xBEEFCAFE) { @@ -1473,6 +1626,19 @@ void VBlankHandler(void) { frameCount++; + if ((cursorEnable) && (mouseCursorVisible)) + { + if (!keyboardEnable) { + storedMouseX = penX; + storedMouseY = penY; + } + + setIconMain(3, storedMouseX - mouseHotspotX, storedMouseY - mouseHotspotY, 8, 0, true); + } + else + { + setIconMain(3, 0, 0, 0, 0, false); + } if (callback) { @@ -1563,7 +1729,7 @@ void VBlankHandler(void) { if (zooming) { subScX = subScTargetX; subScY = subScTargetY; - triggerIcon(0); + triggerIcon(5); } } else if ( ((subScreenWidth) > 128 - 8) && ((subScreenWidth) < 128 + 8) ) { subScreenWidth = 128; @@ -1571,7 +1737,7 @@ void VBlankHandler(void) { if (zooming) { subScX = subScTargetX; subScY = subScTargetY; - triggerIcon(1); + triggerIcon(6); } } else if (subScreenWidth > 256) { subScreenWidth = 320; @@ -1579,10 +1745,10 @@ void VBlankHandler(void) { if (zooming) { subScX = subScTargetX; subScY = subScTargetY; - triggerIcon(2); + triggerIcon(7); } } else { - triggerIcon(-1); + //triggerIcon(-1); } } @@ -1745,6 +1911,14 @@ void setTopScreenTarget(int x, int y) { subScTargetY <<=8; } +#ifdef USE_PROFILER +void hBlankHanlder() __attribute__ ((no_instrument_function)); + +void hBlankHandler() { + hBlankCount++; +} +#endif + void initHardware() { // Guard band //((int *) (0x023FFF00)) = 0xBEEFCAFE; @@ -1757,7 +1931,7 @@ void initHardware() { vramSetBankB(VRAM_B_MAIN_BG); vramSetBankC(VRAM_C_SUB_BG); */ vramSetBankI(VRAM_I_SUB_SPRITE); - vramSetBankG(VRAM_G_MAIN_SPRITE); + vramSetBankE(VRAM_E_MAIN_SPRITE); currentTimeMillis = 0; @@ -1825,6 +1999,11 @@ void initHardware() { irqEnable(IRQ_VBLANK); irqEnable(IRQ_TIMER0); irqEnable(IRQ_TIMER2); + +#ifdef USE_PROFILER + irqSet(IRQ_HBLANK, hBlankHandler); + irqEnable(IRQ_HBLANK); +#endif // Set up a millisecond timer @@ -1847,14 +2026,22 @@ void initHardware() { // Convert texture from 24bit 888 to 16bit 1555, remembering to set top bit! u8* srcTex = (u8 *) icons_raw; - for (int r = 32 * 160 ; r >= 0; r--) { + for (int r = 32 * 256 ; r >= 0; r--) { SPRITE_GFX_SUB[r] = 0x8000 | (srcTex[r * 3] >> 3) | ((srcTex[r * 3 + 1] >> 3) << 5) | ((srcTex[r * 3 + 2] >> 3) << 10); SPRITE_GFX[r] = 0x8000 | (srcTex[r * 3] >> 3) | ((srcTex[r * 3 + 1] >> 3) << 5) | ((srcTex[r * 3 + 2] >> 3) << 10); } + + + + WAIT_CR &= ~(0x0080); // REG_WRAM_CNT = 0; + // This is a bodge to get around the fact that the cursor is turned on before it's image is set + // during startup in Sam & Max. This bodge moves the cursor offscreen so it is not seen. + sprites[1].attribute[1] = ATTR1_SIZE_64 | 192; + } @@ -2067,23 +2254,28 @@ bool getIndyFightState() { return indyFightState; } +gameListType* getCurrentGame() { + return currentGame; +} + /////////////////// // Fast Ram /////////////////// -#define FAST_RAM_SIZE (30000) +#define FAST_RAM_SIZE (24000) u8* fastRamPointer; u8 fastRamData[FAST_RAM_SIZE] ITCM_DATA; void* fastRamAlloc(int size) { +// return malloc(size); void* result = (void *) fastRamPointer; fastRamPointer += size; return (void *) (result); } void fastRamReset() { - fastRamPointer = fastRamData; + fastRamPointer = &fastRamData[0]; } @@ -2308,24 +2500,34 @@ int main(void) // } - + //2372 consolePrintf("-------------------------------\n"); consolePrintf("ScummVM DS\n"); consolePrintf("Ported by Neil Millstone\n"); - FIXME: Change this code to make use of base/internal_version.h - resp. uses gScummVMVersion from base/version.h - consolePrintf("Version 0.10.0SVN "); + consolePrintf("Version 0.10.0 beta1 "); #if defined(DS_BUILD_A) consolePrintf("build A\n"); - consolePrintf("Supports: Lucasarts SCUMM\n"); + consolePrintf("Lucasarts SCUMM games (SCUMM)\n"); consolePrintf("-------------------------------\n"); #elif defined(DS_BUILD_B) consolePrintf("build B\n"); - consolePrintf("Supports: BASS, QUEEN\n"); + consolePrintf("BASS, QUEEN\n"); consolePrintf("-------------------------------\n"); #elif defined(DS_BUILD_C) consolePrintf("build C\n"); - consolePrintf("Supports: SIMON, KYRA, GOB\n"); + consolePrintf("Simon the Sorcerer 1/2 (SIMON)\n"); + consolePrintf("-------------------------------\n"); +#elif defined(DS_BUILD_D) + consolePrintf("build D\n"); + consolePrintf("AGI, CINE, GOB\n"); + consolePrintf("-------------------------------\n"); +#elif defined(DS_BUILD_E) + consolePrintf("build E\n"); + consolePrintf("Inherit the earth (SAGA)\n"); + consolePrintf("-------------------------------\n"); +#elif defined(DS_BUILD_F) + consolePrintf("build F\n"); + consolePrintf("The Legend of Kyrandia (KYRA)\n"); consolePrintf("-------------------------------\n"); #endif consolePrintf("L/R + D-pad/pen: Scroll view\n"); @@ -2333,7 +2535,7 @@ int main(void) consolePrintf("D-pad right: Right mouse button\n"); consolePrintf("D-pad up: Hover mouse\n"); consolePrintf("B button: Skip cutscenes\n"); - consolePrintf("Select: DS Options menu\n"); + consolePrintf("Select: DS Options menu\n"); consolePrintf("Start: Game menu (some games)\n"); consolePrintf("Y (in game): Toggle console\n"); consolePrintf("X: Toggle keyboard\n"); @@ -2457,10 +2659,13 @@ int main(void) #elif defined(DS_BUILD_C) char* argv[2] = {"/scummvmds", "--config=scummvmc.ini"}; #elif defined(DS_BUILD_D) - char* argv[2] = {"/scummvmds", "--config=scummvmd.ini"}; + char* argv[3] = {"/scummvmds", "--config=scummvmd.ini"}; +#elif defined(DS_BUILD_E) + char* argv[3] = {"/scummvmds", "--config=scummvme.ini"}; +#elif defined(DS_BUILD_F) + char* argv[3] = {"/scummvmds", "--config=scummvmf.ini"}; #endif - #ifdef DS_NON_SCUMM_BUILD while (1) { @@ -2482,3 +2687,13 @@ int main(void) int main() { DS::main(); } + + +#ifdef USE_PROFILER +int cygprofile_getHBlanks() __attribute__ ((no_instrument_function)); + + +int cygprofile_getHBlanks() { + return DS::hBlankCount; +} +#endif diff --git a/backends/platform/ds/arm9/source/dsmain.h b/backends/platform/ds/arm9/source/dsmain.h index 58a5be9240..94f02145a2 100644 --- a/backends/platform/ds/arm9/source/dsmain.h +++ b/backends/platform/ds/arm9/source/dsmain.h @@ -31,6 +31,22 @@ namespace DS { + +enum controlType { + CONT_SCUMM_ORIGINAL, + CONT_SCUMM_SAMNMAX, + CONT_SKY, + CONT_SIMON, + CONT_FUTURE_WARS, + CONT_AGI, + CONT_GOBLINS +}; + +struct gameListType { + char gameId[16]; + controlType control; +}; + // Pen reading functions void penInit(); void penUpdate(); @@ -83,7 +99,9 @@ void VBlankHandler(); // Sam and Max Stuff void setGameID(int id); -void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor); +void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor, int hotspotX, int hotspotY); +void setShowCursor(bool enable); +void setMouseCursorVisible(bool visible); // Shake void setShakePos(int shakePos); @@ -123,7 +141,12 @@ void fastRamReset(); void* fastRamAlloc(int size); +gameListType* getCurrentGame(); + + } +int cygprofile_getHBlanks(); + #endif diff --git a/backends/platform/ds/arm9/source/dsoptions.cpp b/backends/platform/ds/arm9/source/dsoptions.cpp index 171d1e044c..b29b1d9fa7 100644 --- a/backends/platform/ds/arm9/source/dsoptions.cpp +++ b/backends/platform/ds/arm9/source/dsoptions.cpp @@ -55,7 +55,8 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(20, 0, 320 - 40, 200 - 20) { _twoHundredPercentCheckbox = new GUI::CheckboxWidget(this, 20, 70, 230, 20, "Zoomed screen at fixed 200% zoom", 0, 'T'); _highQualityAudioCheckbox = new GUI::CheckboxWidget(this, 20, 85, 250, 20, "High quality audio (slower) (reboot)", 0, 'T'); _disablePowerOff = new GUI::CheckboxWidget(this, 20, 100, 250, 20, "Disable power off on quit", 0, 'T'); - _cpuScaler = new GUI::CheckboxWidget(this, 20, 115, 250, 20, "CPU scaler", 0, 'T'); +// _cpuScaler = new GUI::CheckboxWidget(this, 20, 115, 250, 20, "CPU scaler", 0, 'T'); + _showCursorCheckbox = new GUI::CheckboxWidget(this, 20, 115, 250, 20, "Show mouse cursor", 0, 'T'); new GUI::StaticTextWidget(this, 20, 130, 110, 15, "Touch X Offset", GUI::kTextAlignLeft); _touchX = new GUI::SliderWidget(this, 130, 130, 130, 12, 1); @@ -79,6 +80,12 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(20, 0, 320 - 40, 200 - 20) { _delDialog = new Scumm::SaveLoadChooser("Delete game:", "Delete", false, Scumm::g_scumm); #endif + if (ConfMan.hasKey("showcursor", "ds")) { + _showCursorCheckbox->setState(ConfMan.getBool("showcursor", "ds")); + } else { + _showCursorCheckbox->setState(false); + } + if (ConfMan.hasKey("lefthanded", "ds")) { _leftHandedCheckbox->setState(ConfMan.getBool("lefthanded", "ds")); } else { @@ -108,13 +115,13 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(20, 0, 320 - 40, 200 - 20) { } else { _disablePowerOff->setState(false); } - +/* if (ConfMan.hasKey("cpu_scaler", "ds")) { _cpuScaler->setState(ConfMan.getBool("cpu_scaler", "ds")); } else { _cpuScaler->setState(false); } - +*/ _indyFightCheckbox->setState(DS::getIndyFightState()); if (ConfMan.hasKey("xoffset", "ds")) { @@ -137,9 +144,10 @@ DSOptionsDialog::~DSOptionsDialog() { ConfMan.setBool("twohundredpercent", _twoHundredPercentCheckbox->getState(), "ds"); ConfMan.setBool("22khzaudio", _highQualityAudioCheckbox->getState(), "ds"); ConfMan.setBool("disablepoweroff", _disablePowerOff->getState(), "ds"); - ConfMan.setBool("cpu_scaler", _cpuScaler->getState(), "ds"); +// ConfMan.setBool("cpu_scaler", _cpuScaler->getState(), "ds"); ConfMan.setInt("xoffset", _touchX->getValue(), "ds"); ConfMan.setInt("yoffset", _touchY->getValue(), "ds"); + ConfMan.setBool("showcursor", _showCursorCheckbox->getState(), "ds"); DS::setOptions(); DS::setIndyFightState(_indyFightCheckbox->getState()); ConfMan.flushToDisk(); @@ -181,15 +189,27 @@ void DSOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint } +void togglePause() { + // Toggle pause mode by simulating pressing 'p'. Not a good way of doing things! + + if (getCurrentGame()->control == CONT_SCUMM_ORIGINAL) { + Common::Event event; + OSystem_DS* system = OSystem_DS::instance(); + + event.type = Common::EVENT_KEYDOWN; + event.kbd.keycode = 'p'; + event.kbd.ascii = 'p'; + event.kbd.flags = 0; + system->addEvent(event); + + event.type = Common::EVENT_KEYUP; + system->addEvent(event); + } +} + void showOptionsDialog() { - OSystem_DS* system = OSystem_DS::instance(); - Common::Event event; - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = 'P'; // F5 - event.kbd.ascii = 'P'; - event.kbd.flags = 0; - system->addEvent(event); + togglePause(); DS::displayMode16Bit(); @@ -201,11 +221,7 @@ void showOptionsDialog() { DS::displayMode8Bit(); - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = 'P'; // F5 - event.kbd.ascii = 'P'; - event.kbd.flags = 0; - system->addEvent(event); + togglePause(); } void setOptions() { @@ -217,6 +233,12 @@ void setOptions() { DS::setLeftHanded(false); } + if (ConfMan.hasKey("showcursor", "ds")) { + DS::setMouseCursorVisible(ConfMan.getBool("showcursor", "ds")); + } else { + DS::setMouseCursorVisible(true); + } + if (ConfMan.hasKey("unscaled", "ds")) { DS::setUnscaledMode(ConfMan.getBool("unscaled", "ds")); } else { diff --git a/backends/platform/ds/arm9/source/dsoptions.h b/backends/platform/ds/arm9/source/dsoptions.h index 8dde086f57..6976fb1a59 100644 --- a/backends/platform/ds/arm9/source/dsoptions.h +++ b/backends/platform/ds/arm9/source/dsoptions.h @@ -43,7 +43,7 @@ public: protected: virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); - + void togglePause(); GUI::SliderWidget* _touchX; GUI::SliderWidget* _touchY; @@ -54,6 +54,7 @@ protected: GUI::CheckboxWidget* _highQualityAudioCheckbox; GUI::CheckboxWidget* _disablePowerOff; GUI::CheckboxWidget* _cpuScaler; + GUI::CheckboxWidget* _showCursorCheckbox; #ifdef DS_SCUMM_BUILD Scumm::SaveLoadChooser* _delDialog; diff --git a/backends/platform/ds/arm9/source/fat/disc_io.c b/backends/platform/ds/arm9/source/fat/disc_io.c index c706cf8b3e..3cb70f510b 100644 --- a/backends/platform/ds/arm9/source/fat/disc_io.c +++ b/backends/platform/ds/arm9/source/fat/disc_io.c @@ -358,7 +358,7 @@ void disc_getDldiId(char* id) { bool disc_setDsSlotInterface (void) { #ifdef ARM9 - REG_EXMEMCNT &= ~(1<<11); + REG_EXEMEMCNT &= ~(1<<11); #endif #ifdef ARM7 REG_EXEMEMCNT |= (1<<11); diff --git a/backends/platform/ds/arm9/source/fat/disc_io.h b/backends/platform/ds/arm9/source/fat/disc_io.h index 1fbcc78c19..06804afec7 100644 --- a/backends/platform/ds/arm9/source/fat/disc_io.h +++ b/backends/platform/ds/arm9/source/fat/disc_io.h @@ -33,7 +33,11 @@ // Disk caching is disabled on GBA to conserve memory #define DISC_CACHE // uncomment this line to enable disc caching +#ifdef DS_BUILD_F +#define DISC_CACHE_COUNT 128 // maximum number of sectors to cache (512 bytes per sector) +#else #define DISC_CACHE_COUNT 32 // maximum number of sectors to cache (512 bytes per sector) +#endif //#define DISK_CACHE_DMA // use DMA for cache copies. If this is enabled, the data buffers must be word aligned diff --git a/backends/platform/ds/arm9/source/fat/gba_nds_fat.c b/backends/platform/ds/arm9/source/fat/gba_nds_fat.c index f343c4b997..b5fdd665df 100644 --- a/backends/platform/ds/arm9/source/fat/gba_nds_fat.c +++ b/backends/platform/ds/arm9/source/fat/gba_nds_fat.c @@ -1362,9 +1362,18 @@ DIR_ENT FAT_DirEntFromPath (const char* path) DIR_ENT dirEntry; u32 dirCluster; bool flagLFN, dotSeen; - // Start at beginning of path pathPos = 0; + +#ifdef DS_BUILD_F + // Problems with Kyrandia doing a load of path lookups are reduced by this hack. + if (strstr(path, ".voc") || strstr(path, ".voc")) + { + dirEntry.name[0] = FILE_FREE; + dirEntry.attrib = 0x00; + return; + } +#endif if (path[pathPos] == '/') { @@ -2499,6 +2508,7 @@ int FAT_fseek(FAT_FILE* file, s32 offset, int origin) u32 position; u32 curPos; + if ((file == NULL) || (file->inUse == false)) // invalid file { return -1; @@ -2613,6 +2623,7 @@ int FAT_fseek(FAT_FILE* file, s32 offset, int origin) } return 0; + } /*----------------------------------------------------------------- diff --git a/backends/platform/ds/arm9/source/fat/io_dldi.h b/backends/platform/ds/arm9/source/fat/io_dldi.h index 86c3407374..053de3a94c 100644 --- a/backends/platform/ds/arm9/source/fat/io_dldi.h +++ b/backends/platform/ds/arm9/source/fat/io_dldi.h @@ -30,7 +30,7 @@ extern u8 _dldi_driver_name; static inline LPIO_INTERFACE DLDI_GetInterface(void) { #ifdef NDS // NDM: I'm really not sure about this change ARM9 - ARM7 - REG_EXMEMCNT &= ~(ARM7_OWNS_ROM | ARM7_OWNS_CARD); + REG_EXEMEMCNT &= ~(ARM7_OWNS_ROM | ARM7_OWNS_CARD); #endif // defined NDS return &_io_dldi; } diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp index 7f7bf958df..0131040e1d 100644 --- a/backends/platform/ds/arm9/source/gbampsave.cpp +++ b/backends/platform/ds/arm9/source/gbampsave.cpp @@ -29,7 +29,7 @@ GBAMPSaveFile::GBAMPSaveFile(char* name, bool saveOrLoad) { handle = DS::std_fopen(name, saveOrLoad? "w": "r"); -// consolePrintf("%s handle is %d\n", name, handle); + consolePrintf("%s handle is %d\n", name, handle); // consolePrintf("Created %s\n", name); bufferPos = 0; saveSize = 0; @@ -39,6 +39,7 @@ GBAMPSaveFile::GBAMPSaveFile(char* name, bool saveOrLoad) { GBAMPSaveFile::~GBAMPSaveFile() { flushSaveBuffer(); if (handle) DS::std_fclose(handle); + consolePrintf("Closed file\n"); } uint32 GBAMPSaveFile::read(void *buf, uint32 size) { @@ -57,7 +58,7 @@ void GBAMPSaveFile::skip(uint32 bytes) { void GBAMPSaveFile::flushSaveBuffer() { if (bufferPos != 0) { - consolePrintf("Flushing %d bytes from %x\n", bufferPos, buffer); +// consolePrintf("Flushing %d bytes from %x\n", bufferPos, buffer); flushed += bufferPos; DS::std_fwrite(buffer, 1, bufferPos, handle); bufferPos = 0; @@ -174,8 +175,10 @@ void GBAMPSaveFileManager::listSavefiles(char const* prefix, bool* marks, int nu char path[128]; DS::std_cwd((char *) getSavePath()); + + consolePrintf("Save path: %s\n", getSavePath()); - int fileType = FAT_FindFirstFile(name); + int fileType = FAT_FindFirstFileLFN(name); for (int r = 0; r < num; r++) { marks[r] = false; @@ -192,17 +195,17 @@ void GBAMPSaveFileManager::listSavefiles(char const* prefix, bool* marks, int nu sprintf(str, "%s%02d", prefix, r); -// consolePrintf("%s != %s", str, name); + consolePrintf("%s != %s", str, name); if (!stricmp(str, name)) { marks[r] = true; -// consolePrintf("Matched %d", r); + consolePrintf("Matched %d", r); } } } - } while ((fileType = FAT_FindNextFile(name))); + } while ((fileType = FAT_FindNextFileLFN(name))); FAT_chdir("/"); } diff --git a/backends/platform/ds/arm9/source/gbampsave.h b/backends/platform/ds/arm9/source/gbampsave.h index 1580533f66..c7d9732d4c 100644 --- a/backends/platform/ds/arm9/source/gbampsave.h +++ b/backends/platform/ds/arm9/source/gbampsave.h @@ -37,7 +37,7 @@ class GBAMPSaveFile : public Common::InSaveFile, public Common::OutSaveFile { public: GBAMPSaveFile(char* name, bool saveOrLoad); - ~GBAMPSaveFile(); + virtual ~GBAMPSaveFile(); virtual uint32 read(void *buf, uint32 size); virtual uint32 write(const void *buf, uint32 size); diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index cad6ad6b78..32eafe1af7 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -37,6 +37,7 @@ #include "common/str.h" #include "cdaudio.h" #include "graphics/surface.h" +#include "touchkeyboard.h" OSystem_DS* OSystem_DS::_instance = NULL; @@ -138,9 +139,12 @@ void OSystem_DS::setPalette(const byte *colors, uint start, uint num) { green >>= 3; blue >>= 3; - BG_PALETTE[r] = red | (green << 5) | (blue << 10); - if (!DS::getKeyboardEnable()) { - BG_PALETTE_SUB[r] = red | (green << 5) | (blue << 10); +// if (r != 255) + { + BG_PALETTE[r] = red | (green << 5) | (blue << 10); + if (!DS::getKeyboardEnable()) { + BG_PALETTE_SUB[r] = red | (green << 5) | (blue << 10); + } } // if (num == 16) consolePrintf("pal:%d r:%d g:%d b:%d\n", r, red, green, blue); @@ -173,8 +177,8 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int u16* src = (u16 *) buf; if (DS::getKeyboardEnable()) { - for (int dy = y; dy < y + h; dy++) - { + + for (int dy = y; dy < y + h; dy++) { u16* dest = bg + (dy << 8) + (x >> 1); DC_FlushRange(src, w << 1); @@ -185,8 +189,7 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int } } else { - for (int dy = y; dy < y + h; dy++) - { + for (int dy = y; dy < y + h; dy++) { u16* dest1 = bg + (dy << 8) + (x >> 1); u16* dest2 = bgSub + (dy << 8) + (x >> 1); @@ -294,6 +297,7 @@ int16 OSystem_DS::getOverlayWidth() bool OSystem_DS::showMouse(bool visible) { + DS::setShowCursor(visible); return true; } @@ -302,7 +306,7 @@ void OSystem_DS::warpMouse(int x, int y) } void OSystem_DS::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetCursorScale) { - DS::setCursorIcon(buf, w, h, keycolor); + DS::setCursorIcon(buf, w, h, keycolor, hotspotX, hotspotY); } void OSystem_DS::addEvent(Common::Event& e) { @@ -323,11 +327,11 @@ bool OSystem_DS::pollEvent(Common::Event &event) event.kbd.ascii = 0; event.kbd.keycode = 0; event.kbd.flags = 0; - consolePrintf("type: %d\n", event.type); +// consolePrintf("type: %d\n", event.type); return false; } else { event = eventQueue[eventNum++]; - consolePrintf("type: %d\n", event.type); +// consolePrintf("type: %d\n", event.type); return true; } } @@ -474,36 +478,25 @@ Common::SaveFileManager* OSystem_DS::getSavefileManager() } } -Graphics::Surface *OSystem_DS::lockScreen() { - // For now, we create a full temporary screen surface, to which we copy the - // the screen content. Later unlockScreen will copy everything back. - // Not very nice nor efficient, but at least works, and is not worse - // than in the bad old times where we used grabRawScreen + copyRectToScreen. - - _framebuffer.create(DS::getGameWidth(), DS::getGameHeight(), 1); +bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) { + surf->create(DS::getGameWidth(), DS::getGameHeight(), 1); // Ensure we copy using 16 bit quantities due to limitation of VRAM addressing + size_t imageStrideInBytes = DS::isCpuScalerEnabled()? DS::getGameWidth() : 512; + size_t imageStrideInWords = imageStrideInBytes / 2; u16* image = (u16 *) DS::get8BitBackBuffer(); for (int y = 0; y < DS::getGameHeight(); y++) { - DC_FlushRange(image + (y << 8), DS::getGameWidth()); + DC_FlushRange(image + (y * imageStrideInWords), DS::getGameWidth()); for (int x = 0; x < DS::getGameWidth() >> 1; x++) { - *(((u16 *) (_framebuffer.pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[y << 8 + x]; + *(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[y * imageStrideInWords + x]; } } - return &_framebuffer; -} - -void OSystem_DS::unlockScreen() { - // Copy temp framebuffer back to screen - copyRectToScreen((byte *)_framebuffer.pixels, _framebuffer.pitch, 0, 0, _framebuffer.w, _framebuffer.h); - - // Free memory - _framebuffer.free(); + return true; } void OSystem_DS::setFocusRectangle(const Common::Rect& rect) { @@ -515,6 +508,18 @@ void OSystem_DS::clearFocusRectangle() { } +void OSystem_DS::addAutoComplete(const char *word) { + DS::addAutoComplete((char *) word); +} + +void OSystem_DS::clearAutoComplete() { + DS::clearAutoComplete(); +} + +void OSystem_DS::setCharactersEntered(int count) { + DS::setCharactersEntered(count); +} + OSystem *OSystem_DS_create() { return new OSystem_DS(); } diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index 58b940af2c..d943a362ca 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -41,11 +41,12 @@ class DSTimerManager : public DefaultTimerManager { class OSystem_DS : public OSystem { public: + static OSystem_DS *instance() { return _instance; } int eventNum; int lastPenFrame; - Common::Event eventQueue[64]; + Common::Event eventQueue[96]; int queuePos; DSSaveFileManager saveManager; @@ -53,9 +54,8 @@ public: DSAudioMixer* _mixer; DSTimerManager* _timer; - Graphics::Surface _framebuffer; - static OSystem_DS* _instance; + typedef void (*SoundProc)(void *param, byte *buf, int len); typedef int (*TimerProc)(int interval); @@ -129,8 +129,7 @@ public: void addEvent(Common::Event& e); bool isEventQueueEmpty() { return queuePos == 0; } - virtual Graphics::Surface *lockScreen(); - virtual void unlockScreen(); + virtual bool grabRawScreen(Graphics::Surface* surf); virtual void setFocusRectangle(const Common::Rect& rect); @@ -141,6 +140,14 @@ public: virtual Audio::Mixer* getMixer() { return _mixer; } virtual Common::TimerManager* getTimerManager() { return _timer; } static int timerHandler(int t); + + + virtual void addAutoComplete(const char *word); + virtual void clearAutoComplete(); + virtual void setCharactersEntered(int count); + + + }; static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { @@ -162,9 +169,4 @@ void OSystem_DS::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) //consolePrintf("coltorgb\n"); } -namespace DS -{ -bool isCpuScalerEnabled(); -} - #endif diff --git a/backends/platform/ds/arm9/source/touchkeyboard.cpp b/backends/platform/ds/arm9/source/touchkeyboard.cpp index 8f7af668d8..26f03ca9d1 100644 --- a/backends/platform/ds/arm9/source/touchkeyboard.cpp +++ b/backends/platform/ds/arm9/source/touchkeyboard.cpp @@ -23,6 +23,7 @@ #include "touchkeyboard.h" #include "keyboard_raw.h" #include "keyboard_pal_raw.h" +#include "8x8font_tga_raw.h" #include "dsmain.h" #include "osystem_ds.h" @@ -127,11 +128,22 @@ int keyboardY; int mapBase; int tileBase; +u16* baseAddress; + bool shiftState; bool capsLockState; bool closed; +char autoCompleteWord[NUM_WORDS][32]; +int autoCompleteCount; + +char autoCompleteBuffer[128]; + +int selectedCompletion = -1; +int charactersEntered = 0; + + void restoreVRAM(int tileBase, int mapBase, u16* saveSpace) { /* for (int r = 0; r < 32 * 32; r++) { ((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase))[r] = *saveSpace++; @@ -159,6 +171,26 @@ void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) { BG_PALETTE_SUB[r] = ((u16 *) (keyboard_pal_raw))[r]; } + // this is the font + for (int tile = 0; tile < 94; tile++) { + + u16* tileAddr = (u16 *) (CHAR_BASE_BLOCK_SUB(tileBase) + (8192 + (tile * 32))); + u8* src = ((u8 *) (_8x8font_tga_raw)) + 18 + tile * 8; + + for (int y = 0 ; y < 8; y++) { + for (int x = 0; x < 2; x++) { + *(tileAddr + (y * 2) + x) =(*(src + (y * 752) + (x * 4) + 0) & 0x0F) + | ((*(src + (y * 752) + (x * 4) + 1) & 0x0F) << 4) + | ((*(src + (y * 752) + (x * 4) + 2) & 0x0F) << 8) + | ((*(src + (y * 752) + (x * 4) + 3) & 0x0F) << 12); + + } + } + } + + + + for (int r = 0; r < 16; r++) { int col = ((u16 *) (keyboard_pal_raw))[r]; @@ -167,17 +199,19 @@ void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) { int blue = (col & 0x7C00) >> 10; red = (red * 8) / 16; - green = (green * 8) / 16; + green = (green * 24) / 16; blue = (blue * 8) / 16; + + if (green > 31) green = 31; BG_PALETTE_SUB[16 + r] = red | (green << 5) | (blue << 10); } keyboardX = -2; - keyboardY = 2; + keyboardY = 1; - mapBase = mapBase; - tileBase = tileBase; + DS::mapBase = mapBase; + DS::tileBase = tileBase; shiftState = false; capsLockState = false; @@ -186,6 +220,7 @@ void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) { int y = keyboardY; u16* base = ((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase)); + baseAddress = base; for (int r = 0; r < DS_NUM_KEYS; r++) { base[(y + keys[r].y) * 32 + x + keys[r].x] = keys[r].keyNum * 2; @@ -198,6 +233,36 @@ void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) { } closed = false; + clearAutoComplete(); +} + +void drawAutoComplete() { + + for (int y = 12; y < 24; y++) { + for (int x = 0; x < 32; x++) { + baseAddress[y * 32 + x] = 127; + } + } + + + for (int r = 0; r < autoCompleteCount; r++) { + int y = 12 + (r % 6) * 2; + int x = 0 + ((r / 6) * 16); + + for (int p = 0; p < strlen(autoCompleteWord[r]); p++) { + char c = autoCompleteWord[r][p]; + + int tile = c - 32 + 255; + + if (selectedCompletion == r) { + tile |= 0x1000; + } + + baseAddress[y * 32 + x + p] = tile; + + + } + } } bool getKeyboardClosed() { @@ -220,13 +285,106 @@ void setKeyHighlight(int key, bool highlight) { } } +void addAutoComplete(char* word) { + if (autoCompleteCount == NUM_WORDS) return; + strcpy(&autoCompleteWord[autoCompleteCount++][0], word); + drawAutoComplete(); +} + +void setCharactersEntered(int count) { + charactersEntered = count; +} + +void clearAutoComplete() { + autoCompleteCount = 0; + selectedCompletion = -1; + drawAutoComplete(); +} + +void typeCompletion(int current) { + Common::Event event; + OSystem_DS* system = OSystem_DS::instance(); + + strcat(autoCompleteBuffer, &autoCompleteWord[current][charactersEntered]); + strcat(autoCompleteBuffer, " "); + +/* consolePrintf("Typing word: %s\n", autoCompleteWord[current]); + + for (int r = charactersEntered; r < strlen(autoCompleteWord[current]); r++) { + event.kbd.keycode = autoCompleteWord[current][r]; + event.kbd.ascii = autoCompleteWord[current][r]; + event.type = Common::EVENT_KEYDOWN; + event.kbd.flags = 0; + system->addEvent(event); + + event.type = Common::EVENT_KEYUP; + system->addEvent(event); + } + + event.kbd.keycode = ' '; + event.kbd.ascii = ' '; + + event.type = Common::EVENT_KEYDOWN; + system->addEvent(event); + + event.type = Common::EVENT_KEYUP; + system->addEvent(event);*/ +} + +void updateTypeEvents() +{ + if (autoCompleteBuffer[0] != '\0') + { + Common::Event event; + OSystem_DS* system = OSystem_DS::instance(); + + event.kbd.keycode = autoCompleteBuffer[0]; + event.kbd.ascii = autoCompleteBuffer[0]; + event.type = Common::EVENT_KEYDOWN; + event.kbd.flags = 0; + system->addEvent(event); + + event.type = Common::EVENT_KEYUP; + system->addEvent(event); + + for (int r = 0; r < strlen(autoCompleteBuffer); r++) + { + autoCompleteBuffer[r] = autoCompleteBuffer[r + 1]; + } + } +} + + void addKeyboardEvents() { + updateTypeEvents(); + if (DS::getPenDown()) { int x = IPC->touchXpx; int y = IPC->touchYpx; - int tx = (x >> 3) - keyboardX; - int ty = (y >> 3) - keyboardY; + int tx = (x >> 3); + int ty = (y >> 3); + + if (ty >= 12) { + int current = -1; + + if (tx < 12) { + current = (ty - 12) / 2; + } else { + current = 6 + (ty - 12) / 2; + } + + if (selectedCompletion == current) { + typeCompletion(current); + } else { + selectedCompletion = current; + } + + drawAutoComplete(); + } + + tx -= keyboardX; + ty -= keyboardY; // consolePrintf("x=%d y=%d\n", tx, ty); @@ -241,8 +399,14 @@ void addKeyboardEvents() { // Close button DS::closed = true; } else if ((keys[r].character >= '0') && (keys[r].character <= '9')) { - event.kbd.ascii = keys[r].character; - event.kbd.keycode = 0; + + if (!DS::shiftState) { + event.kbd.ascii = keys[r].character; + event.kbd.keycode = 0; + } else { + event.kbd.keycode = SDLK_F1 - (keys[r].character - '1'); + event.kbd.ascii = 0; + } } else if ((keys[r].character >= 'A') && (keys[r].character <= 'Z')) { diff --git a/backends/platform/ds/arm9/source/touchkeyboard.h b/backends/platform/ds/arm9/source/touchkeyboard.h index e8f5fda37e..42051a1f11 100644 --- a/backends/platform/ds/arm9/source/touchkeyboard.h +++ b/backends/platform/ds/arm9/source/touchkeyboard.h @@ -25,11 +25,18 @@ namespace DS { +static const int NUM_WORDS = 12; + + void drawKeyboard(int tileBase, int mapBase, u16* saveSpace); void restoreVRAM(int tileBase, int mapBase, u16* saveSpace); void addKeyboardEvents(); bool getKeyboardClosed(); +void addAutoComplete(char* word); +void clearAutoComplete(); +void setCharactersEntered(int count); + } #endif diff --git a/backends/platform/ds/arm9/source/wordcompletion.cpp b/backends/platform/ds/arm9/source/wordcompletion.cpp new file mode 100644 index 0000000000..a73656ea61 --- /dev/null +++ b/backends/platform/ds/arm9/source/wordcompletion.cpp @@ -0,0 +1,67 @@ +#include "wordcompletion.h" +#include "engines/agi/agi.h" +#include "osystem_ds.h" + +#ifndef DISABLE_AGI + +namespace DS { + +void findWordCompletions(char* input) { + int start = 0; + for (int r = strlen(input) - 1; r>0; r--) { + if (input[r] == ' ') { + start = r + 1; + break; + } + } + + char word[32]; + strcpy(word, &input[start]); + + int fchr = word[0] - 'a'; + int len = strlen(word); + + OSystem_DS* system = (OSystem_DS *) g_system; + system->clearAutoComplete(); + system->setCharactersEntered(strlen(word)); + + if (strlen(word) == 0) { + return; + } + + uint8 *wordList = Agi::AgiEngine::getWordsData(); + uint8 *wordListEnd = Agi::AgiEngine::getWordsData() + Agi::AgiEngine::getWordsDataSize(); + + /* Get the offset to the first word beginning with the + * right character + */ + wordList += READ_BE_UINT16(wordList + 2 * fchr); + + char currentWord[32]; + + + while (wordList < wordListEnd) { + int pos = *wordList++; // Number of chars to keep from previous word + + if (wordList == wordListEnd) + break; + + char c; + do { + c = *wordList++; + currentWord[pos++] = (~c) & 0x7F; + } while ((c & 0x80) == 0); // Top bit indicates end of word + currentWord[pos++] = '\0'; + + if (!strncmp(currentWord, word, strlen(word))) { + system->addAutoComplete(currentWord); + } + + wordList += 2; // Skip the two byte word id. + + } + +} + +} +#endif diff --git a/backends/platform/ds/arm9/source/wordcompletion.h b/backends/platform/ds/arm9/source/wordcompletion.h new file mode 100644 index 0000000000..b0d43713cc --- /dev/null +++ b/backends/platform/ds/arm9/source/wordcompletion.h @@ -0,0 +1,8 @@ + + + +namespace DS { + +extern void findWordCompletions(char* input); + +}
\ No newline at end of file diff --git a/backends/platform/ds/arm9/source/zipreader.cpp b/backends/platform/ds/arm9/source/zipreader.cpp index 59f695ebce..0c86bd97ae 100644 --- a/backends/platform/ds/arm9/source/zipreader.cpp +++ b/backends/platform/ds/arm9/source/zipreader.cpp @@ -31,7 +31,7 @@ ZipFile::ZipFile() { // Locate a zip file in cartridge memory space - consolePrintf("ZIP file check..."); +// consolePrintf("ZIP file check..."); char* p = (char *) ZF_SEARCH_START; bool found = false; @@ -52,9 +52,9 @@ ZipFile::ZipFile() { } if (_zipFile) { - consolePrintf("Ok!\n"); + consolePrintf("ZIP File found Ok!\n"); } else { - consolePrintf("Not in use!\n"); +// consolePrintf("Not in use!\n"); return; } diff --git a/backends/platform/gp2x/build/build.sh b/backends/platform/gp2x/build/build.sh index dc2f56cb18..1ea77f4937 100644 --- a/backends/platform/gp2x/build/build.sh +++ b/backends/platform/gp2x/build/build.sh @@ -10,6 +10,7 @@ export CXX=arm-open2x-linux-g++ export CC=arm-open2x-linux-gcc export CXXFLAGS=-march=armv4t export LDFLAGS=-static +export ASFLAGS=-mfloat-abi=soft cd ../../../.. diff --git a/backends/platform/gp2x/build/bundle.sh b/backends/platform/gp2x/build/bundle.sh index 93ae45f0e3..526742e2e7 100644 --- a/backends/platform/gp2x/build/bundle.sh +++ b/backends/platform/gp2x/build/bundle.sh @@ -19,6 +19,7 @@ cp ./scummvm.gpe ./scummvm-gp2x-`date '+%Y-%m-%d'`/ cp ./scummvm.png ./scummvm-gp2x-`date '+%Y-%m-%d'`/ cp ./README-GP2X.html ./scummvm-gp2x-`date '+%Y-%m-%d'`/ cp ./README-GP2X ./scummvm-gp2x-`date '+%Y-%m-%d'`/ +cp ./mmuhack.o ./scummvm-gp2x-`date '+%Y-%m-%d'`/ cp ../../../../scummvm.gp2x ./scummvm-gp2x-`date '+%Y-%m-%d'`/ cp ../../../../AUTHORS ./scummvm-gp2x-`date '+%Y-%m-%d'`/ cp ../../../../README ./scummvm-gp2x-`date '+%Y-%m-%d'`/ @@ -27,10 +28,22 @@ cp ../../../../COPYRIGHT ./scummvm-gp2x-`date '+%Y-%m-%d'`/ cp ../../../../NEWS ./scummvm-gp2x-`date '+%Y-%m-%d'`/ cp ../../../../gui/themes/modern.ini ./scummvm-gp2x-`date '+%Y-%m-%d'`/ cp ../../../../gui/themes/modern.zip ./scummvm-gp2x-`date '+%Y-%m-%d'`/ - +cp ../../../../dists/pred.dic ./scummvm-gp2x-`date '+%Y-%m-%d'`/ echo Making Stripped GPE. arm-open2x-linux-strip ./scummvm-gp2x-`date '+%Y-%m-%d'`/scummvm.gp2x echo Building ZIP bundle. -echo You should have a "scummvm-gp2x-`date '+%Y-%m-%d'`.zip" for the GP2X port ready to go. +if [ -f /usr/bin/zip ] + then + rm ./"gp2xkernel-open2x-`date '+%Y-%m-%d'`.zip" + cd "scummvm-gp2x-`date '+%Y-%m-%d'`" + zip -r -9 "../scummvm-gp2x-`date '+%Y-%m-%d'`.zip" * + echo You should have a "scummvm-gp2x-`date '+%Y-%m-%d'`.zip" for the GP2X port ready to go. + cd .. + rm -R ./"scummvm-gp2x-`date '+%Y-%m-%d'`" + else + echo - /usr/bin/zip not found, ZIP bundle not created. + echo All included files can also be found in ./"scummvm-gp2x-`date '+%Y-%m-%d'`" + echo - Please use you preferred archive tool to bundle these files. +fi diff --git a/backends/platform/gp2x/build/config.sh b/backends/platform/gp2x/build/config.sh index 193210a1b8..f899c7665a 100644 --- a/backends/platform/gp2x/build/config.sh +++ b/backends/platform/gp2x/build/config.sh @@ -17,6 +17,6 @@ export DEFINES=-DNDEBUG # Edit the configure line to suit. cd ../../../.. -./configure --backend=gp2x --disable-mt32emu --host=gp2x --disable-mpeg2 --disable-flac --disable-nasm --disable-hq-scalers --with-sdl-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin --enable-tremor --with-tremor-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-zlib --with-zlib-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-mad --with-mad-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 +./configure --backend=gp2x --disable-mt32emu --host=gp2x --disable-flac --disable-nasm --disable-hq-scalers --with-sdl-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin --with-mpeg2-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-tremor --with-tremor-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-zlib --with-zlib-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-mad --with-mad-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 echo Generating config for GP2X complete. Check for errors. diff --git a/backends/platform/gp2x/build/mmuhack.o b/backends/platform/gp2x/build/mmuhack.o Binary files differnew file mode 100644 index 0000000000..475f4a54ae --- /dev/null +++ b/backends/platform/gp2x/build/mmuhack.o diff --git a/backends/platform/gp2x/events.cpp b/backends/platform/gp2x/events.cpp index 72b188afd2..ef39ab333e 100644 --- a/backends/platform/gp2x/events.cpp +++ b/backends/platform/gp2x/events.cpp @@ -72,7 +72,7 @@ static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) return key; } else if (unicode) { return unicode; - } else if (key >= 'a' && key <= 'z' && mod & KMOD_SHIFT) { + } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) { return key & ~0x20; } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) { return 0; @@ -168,17 +168,10 @@ void OSystem_GP2X::handleKbdMouse() { static byte SDLModToOSystemKeyFlags(SDLMod mod) { byte b = 0; -#ifdef LINUPY - // Yopy has no ALT key, steal the SHIFT key - // (which isn't used much anyway) - if (mod & KMOD_SHIFT) - b |= Common::KBD_ALT; -#else if (mod & KMOD_SHIFT) b |= Common::KBD_SHIFT; if (mod & KMOD_ALT) b |= Common::KBD_ALT; -#endif if (mod & KMOD_CTRL) b |= Common::KBD_CTRL; @@ -246,7 +239,7 @@ void OSystem_GP2X::moveStick() { //int GP2X_BUTTON_STATE_B = FALSE; //int GP2X_BUTTON_STATE_Y = FALSE; //int GP2X_BUTTON_STATE_X = FALSE; - int GP2X_BUTTON_STATE_L = FALSE; + int GP2X_BUTTON_STATE_L = FALSE; //int GP2X_BUTTON_STATE_R = FALSE; //int GP2X_BUTTON_STATE_START = FALSE; //int GP2X_BUTTON_STATE_SELECT = FALSE; @@ -306,6 +299,7 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) { GP2X_BUTTON_VOLUP & GP2X_BUTTON_VOLDOWN 0 (For Monkey 2 CP) GP2X_BUTTON_L & GP2X_BUTTON_SELECT Common::EVENT_QUIT (Calls Sync() to make sure SD is flushed) GP2X_BUTTON_L & GP2X_BUTTON_Y Toggles setZoomOnMouse() for larger then 320*240 games to scale to the point + raduis. + GP2X_BUTTON_L & GP2X_BUTTON_A Common::EVENT_PREDICTIVE_DIALOG for predictive text entry box (AGI games) */ while(SDL_PollEvent(&ev)) { @@ -341,45 +335,13 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) { break; } - // Ctrl-m toggles mouse capture - //if (b == Common::KBD_CTRL && ev.key.keysym.sym == 'm') { - // toggleMouseGrab(); - // break; - //} - -//#ifdef MACOSX -// // On Macintosh', Cmd-Q quits -// if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym == 'q') { -// event.type = Common::EVENT_QUIT; -// return true; -// } -//#elif defined(UNIX) -// // On other unices, Control-Q quits -// if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'q') { -// event.type = Common::EVENT_QUIT; -// return true; -// } -//#else -// // Ctrl-z and Alt-X quit -// if ((b == Common::KBD_CTRL && ev.key.keysym.sym == 'z') || (b == Common::KBD_ALT && ev.key.keysym.sym == 'x')) { -// event.type = Common::EVENT_QUIT; -// return true; -// } -//#endif -// -// // Ctrl-Alt-<key> will change the GFX mode -// if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { -// -// handleScalerHotkeys(ev.key); -// break; -// } const bool event_complete = remapKey(ev,event); if (event_complete) return true; event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = ev.key.keysym.sym; + event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); return true; @@ -392,7 +354,7 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) { return true; event.type = Common::EVENT_KEYUP; - event.kbd.keycode = ev.key.keysym.sym; + event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState()); @@ -484,8 +446,15 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) { } break; case GP2X_BUTTON_A: + if (GP2X_BUTTON_STATE_L == TRUE) { + event.type = Common::EVENT_PREDICTIVE_DIALOG; + } else { event.kbd.keycode = Common::KEYCODE_PERIOD; event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0); + } +// event.kbd.keycode = Common::KEYCODE_PERIOD; +// event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0); + break; case GP2X_BUTTON_Y: if (GP2X_BUTTON_STATE_L == TRUE) { @@ -606,10 +575,6 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) { axis = 0; if ( ev.jaxis.axis == JOY_XAXIS) { -#ifdef JOY_ANALOG - _km.x_vel = axis/2000; - _km.x_down_count = 0; -#else if (axis != 0) { _km.x_vel = (axis > 0) ? 1:-1; _km.x_down_count = 1; @@ -617,7 +582,6 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) { _km.x_vel = 0; _km.x_down_count = 0; } -#endif } else if (ev.jaxis.axis == JOY_YAXIS) { #ifndef JOY_INVERT_Y diff --git a/backends/platform/gp2x/gp2x-common.h b/backends/platform/gp2x/gp2x-common.h index 68f2fb997e..a48239222b 100644 --- a/backends/platform/gp2x/gp2x-common.h +++ b/backends/platform/gp2x/gp2x-common.h @@ -181,7 +181,6 @@ public: virtual bool setGraphicsMode(int mode); virtual int getGraphicsMode() const; - //virtual void setWindowCaption(const char *caption); virtual bool openCD(int drive); virtual int getOutputSampleRate() const; @@ -267,6 +266,9 @@ protected: int _mode; int _transactionMode; bool _fullscreen; + + bool _screenIsLocked; + Graphics::Surface _framebuffer; /** Current video mode flags (see DF_* constants) */ uint32 _modeFlags; @@ -382,14 +384,13 @@ protected: /** Set the position of the virtual mouse cursor. */ void setMousePos(int x, int y); - virtual void fillMouseEvent(Common::Event &event, int x, int y); - //void toggleMouseGrab(); + void fillMouseEvent(Common::Event &event, int x, int y); - virtual void internUpdateScreen(); + void internUpdateScreen(); - virtual void loadGFXMode(); - virtual void unloadGFXMode(); - virtual void hotswapGFXMode(); + void loadGFXMode(); + void unloadGFXMode(); + void hotswapGFXMode(); void setFullscreenMode(bool enable); void setAspectRatioCorrection(bool enable); diff --git a/backends/platform/gp2x/gp2x-hw.cpp b/backends/platform/gp2x/gp2x-hw.cpp index d1b6f80a1e..d322aa5d08 100644 --- a/backends/platform/gp2x/gp2x-hw.cpp +++ b/backends/platform/gp2x/gp2x-hw.cpp @@ -33,17 +33,20 @@ #include "gp2x-common.h" #include "gp2x-hw.h" +#include "gp2x-mem.h" -// Linux includes to let us goof about with the system. +// Linux includes to let us goof about with the system in a 'standard' way. +#include <fcntl.h> +#include <pthread.h> +#include <signal.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> #include <sys/mman.h> #include <sys/ioctl.h> #include <sys/soundcard.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -static unsigned long gp2x_dev[8]={0,0,0,0,0,0,0,0};//, gp2x_ticks_per_second; -static volatile unsigned short *gp2x_memregs; +#include <sys/time.h> +#include <unistd.h> /* system registers */ static struct @@ -67,19 +70,27 @@ void GP2X_device_init() { void GP2X_device_deinit() { // Close devices - if (gp2x_dev[0]) close(gp2x_dev[0]); - if (gp2x_dev[1]) close(gp2x_dev[1]); - if (gp2x_dev[2]) close(gp2x_dev[2]); - - MEM_REG[0x91c>>1]=system_reg.SYSCSETREG; - MEM_REG[0x910>>1]=system_reg.FPLLVSETREG; - MEM_REG[0x3B40>>1]=system_reg.DUALINT920; - MEM_REG[0x3B42>>1]=system_reg.DUALINT940; - MEM_REG[0x3B48>>1]=system_reg.DUALCTRL940; - MEM_REG[0x904>>1]=system_reg.SYSCLKENREG; - MEM_REG[0x924>>1]=dispclockdiv; -} + { + int i; + for(i=0;i<8;i++) + { + if(gp2x_dev[i]) + { + close(gp2x_dev[i]); + } + } + } + + MEM_REG[0x91c>>1] = system_reg.SYSCSETREG; + MEM_REG[0x910>>1] = system_reg.FPLLVSETREG; + MEM_REG[0x3B40>>1] = system_reg.DUALINT920; + MEM_REG[0x3B42>>1] = system_reg.DUALINT940; + MEM_REG[0x3B48>>1] = system_reg.DUALCTRL940; + MEM_REG[0x904>>1] = system_reg.SYSCLKENREG; + MEM_REG[0x924>>1] = dispclockdiv; + unpatchMMU(); +} // Vairous mixer level fudges. // TODO: Clean up and merge quick hacks. diff --git a/backends/platform/gp2x/gp2x-hw.h b/backends/platform/gp2x/gp2x-hw.h index bb681154d7..0427698bc4 100644 --- a/backends/platform/gp2x/gp2x-hw.h +++ b/backends/platform/gp2x/gp2x-hw.h @@ -65,7 +65,6 @@ extern void GP2X_mixer_move_volume(int); extern void GP2X_setCpuspeed(unsigned int cpuspeed); extern int GP2X_getBattLevel(); - extern void save_system_regs(void); /* save some registers */ extern void set_display_clock_div(unsigned div); extern void set_FCLK(unsigned MHZ); /* adjust the clock frequency (in Mhz units) */ diff --git a/backends/platform/gp2x/gp2x-mem.c b/backends/platform/gp2x/gp2x-mem.c index f129deb783..1c2c1562a8 100644 --- a/backends/platform/gp2x/gp2x-mem.c +++ b/backends/platform/gp2x/gp2x-mem.c @@ -39,20 +39,22 @@ #include "gp2x-mem.h" -void InitRam (void) -{ - if(!gp2x_dev) - { - gp2x_dev = open("/dev/mem", O_RDWR); - gp2x_ram = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0x03000000); - gp2x_memregs = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0xc0000000); - } -} - -void CloseRam (void) -{ - if(gp2x_dev) close(gp2x_dev); -} +char uname[256]; + +//void InitRam (void) +//{ +// if(!gp2x_dev) +// { +// gp2x_dev = open("/dev/mem", O_RDWR); +// gp2x_ram = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0x03000000); +// gp2x_memregs = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0xc0000000); +// } +//} + +//void CloseRam (void) +//{ +// if(gp2x_dev) close(gp2x_dev); +//} /* ****** [BEGIN] Squidge's MMU hack code ****** @@ -201,34 +203,30 @@ int hackpgtable (void) // do this in user mode, so we have to patch the kernel to get it to run it for us in supervisor mode. We dothis // at the moment by overwriting the sys_newuname function and then calling it. - lseek (gp2x_dev, 0x6ec00, SEEK_SET); // fixme: We should ask the kernel for this address rather than assuming it... - read (gp2x_dev, &oldc1, 4); - read (gp2x_dev, &oldc2, 4); - read (gp2x_dev, &oldc3, 4); - read (gp2x_dev, &oldc4, 4); - - printf ("0:%08X %08X - %08X %08X\n", oldc1, oldc2, newc1, newc2); - + lseek (gp2x_dev[2], 0x6ec00, SEEK_SET); // fixme: We should ask the kernel for this address rather than assuming it... + read (gp2x_dev[2], &oldc1, 4); + read (gp2x_dev[2], &oldc2, 4); + read (gp2x_dev[2], &oldc3, 4); + read (gp2x_dev[2], &oldc4, 4); + //printf ("0:%08X %08X - %08X %08X\n", oldc1, oldc2, newc1, newc2); + //printf ("point1 %d\n",a); - printf ("point1 %d\n",a); do { - lseek (gp2x_dev, 0x6ec00, SEEK_SET); - a+=write (gp2x_dev, &newc1, 4); - a+=write (gp2x_dev, &newc2, 4); + lseek (gp2x_dev[2], 0x6ec00, SEEK_SET); + a+=write (gp2x_dev[2], &newc1, 4); + a+=write (gp2x_dev[2], &newc2, 4); SDL_Delay(200); try++; - ttb = myuname(name); - printf ("2:%08X try %d\n", ttb,try); + ttb = myuname(uname); + //printf ("2:%08X try %d\n", ttb,try); } while (ttb==0 && try<4); + lseek (gp2x_dev[2], 0x6ec00, SEEK_SET); + a+=write (gp2x_dev[2], &oldc1, 4); + a+=write (gp2x_dev[2], &oldc2, 4); - - lseek (gp2x_dev, 0x6ec00, SEEK_SET); - a+=write (gp2x_dev, &oldc1, 4); - a+=write (gp2x_dev, &oldc2, 4); - - printf ("2:%08X %d\n", ttb,a); + //printf ("2:%08X %d\n", ttb,a); if (ttb!=0) { @@ -243,28 +241,28 @@ int hackpgtable (void) unsigned int tlbc3 = 0xee080f17; // mcr 15, 0, r0, cr8, cr7, 0 unsigned int tlbc4 = 0xe1a0f00e; // mov pc, lr - lseek (gp2x_dev, 0x6ec00, SEEK_SET); - write (gp2x_dev, &tlbc1, 4); - write (gp2x_dev, &tlbc2, 4); - write (gp2x_dev, &tlbc3, 4); - write (gp2x_dev, &tlbc4, 4); + lseek (gp2x_dev[2], 0x6ec00, SEEK_SET); + write (gp2x_dev[2], &tlbc1, 4); + write (gp2x_dev[2], &tlbc2, 4); + write (gp2x_dev[2], &tlbc3, 4); + write (gp2x_dev[2], &tlbc4, 4); SDL_Delay(200); - ttx = myuname(name); + ttx = myuname(uname); printf ("Return from uname: %08X\n", ttx); - lseek (gp2x_dev, 0x6ec00, SEEK_SET); - write (gp2x_dev, &oldc1, 4); - write (gp2x_dev, &oldc2, 4); - write (gp2x_dev, &oldc3, 4); - write (gp2x_dev, &oldc4, 4); - lseek (gp2x_dev, 0x0, SEEK_SET); + lseek (gp2x_dev[2], 0x6ec00, SEEK_SET); + write (gp2x_dev[2], &oldc1, 4); + write (gp2x_dev[2], &oldc2, 4); + write (gp2x_dev[2], &oldc3, 4); + write (gp2x_dev[2], &oldc4, 4); + lseek (gp2x_dev[2], 0x0, SEEK_SET); return 0; } - lseek (gp2x_dev, 0x0, SEEK_SET); + lseek (gp2x_dev[2], 0x0, SEEK_SET); return 1; //printf ("Restored contents\n"); @@ -292,10 +290,34 @@ void SetClock (unsigned c) gp2x_memregs[0x910>>1] = v; } -void MMUpatch (void) +void patchMMU (void) { - volatile unsigned int *secbuf = (unsigned int *)malloc (204800); + //volatile unsigned int *secbuf = (unsigned int *)malloc (204800); - // Squidge's MMU hack - hackpgtable(); + printf ("Reconfiguring cached memory regions...\n"); + + //hackpgtable(); + //printf ("Sucess...\n"); + + system("/sbin/rmmod mmuhack"); + system("/sbin/insmod -f mmuhack.o"); + + int mmufd = open("/dev/mmuhack", O_RDWR); + + if(mmufd < 0) + { + printf ("Upper memory uncached (attempt failed, access to upper memory will be slower)...\n"); + } + else + { + printf ("Upper memory cached...\n"); + close(mmufd); + } +} + +void unpatchMMU (void) +{ + printf ("Restoreing cached memory regions...\n"); + system("/sbin/rmmod mmuhack"); + return 1; } diff --git a/backends/platform/gp2x/gp2x-mem.h b/backends/platform/gp2x/gp2x-mem.h index bf2d050623..b4df7b3a00 100644 --- a/backends/platform/gp2x/gp2x-mem.h +++ b/backends/platform/gp2x/gp2x-mem.h @@ -39,17 +39,20 @@ extern "C" { // Use Squidge's MMU patch rather then myown (his is neater). // The effect if not that great but cacheing the upper RAM is no bad thing (tm) ;). -void InitRam (void); -void CloseRam (void); +//extern void InitRam (void); +//extern void CloseRam (void); // Set ARM920t clock frequency -void SetClock (unsigned c); -void MMUpatch (void); +extern void SetClock (unsigned c); +extern void patchMMU (void); +extern void unpatchMMU (void); #define SYS_CLK_FREQ 7372800 -char name[256]; -unsigned long gp2x_dev; -volatile unsigned short *gp2x_ram, *gp2x_memregs; +//unsigned long gp2x_dev; +//volatile unsigned short *gp2x_ram, *gp2x_memregs; + +static unsigned long gp2x_dev[8]={0,0,0,0,0,0,0,0};//, gp2x_ticks_per_second; +static volatile unsigned short *gp2x_ram, *gp2x_memregs; #ifdef __cplusplus } diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp index 42a9345762..3cf5df2e3a 100644 --- a/backends/platform/gp2x/gp2x.cpp +++ b/backends/platform/gp2x/gp2x.cpp @@ -60,11 +60,6 @@ static Uint32 timer_handler(Uint32 interval, void *param) { } int main(int argc, char *argv[]) { - - // Setup GP2X upper 32MB caching - //InitRam(); - //MMUpatch(); - extern OSystem *OSystem_GP2X_create(); g_system = OSystem_GP2X_create(); assert(g_system); @@ -82,7 +77,7 @@ OSystem *OSystem_GP2X_create() { void OSystem_GP2X::initBackend() { assert(!_inited); - ConfMan.set("joystick_num", 0); + ConfMan.setInt("joystick_num", 0); int joystick_num = ConfMan.getInt("joystick_num"); uint32 sdlFlags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER; @@ -96,6 +91,7 @@ void OSystem_GP2X::initBackend() { error("Could not initialize SDL: %s", SDL_GetError()); } + SDL_ShowCursor(SDL_DISABLE); // Setup default save path to be workingdir/saves #ifndef PATH_MAX @@ -187,19 +183,10 @@ void OSystem_GP2X::initBackend() { // enable joystick if (joystick_num > -1 && SDL_NumJoysticks() > 0) { - printf("Using joystick: %s\n", SDL_JoystickName(0)); + //printf("Using joystick: %s\n", SDL_JoystickName(0)); _joystick = SDL_JoystickOpen(joystick_num); } - // Initialise any GP2X specific stuff we may want (Volume, Batt Status etc.) - GP2X_device_init(); - - // Set Default hardware mixer volume to a plesent level. - // This is done to 'reset' volume level if set by other apps. - GP2X_mixer_set_volume(70, 70); - - SDL_ShowCursor(SDL_DISABLE); - // Create the savefile manager, if none exists yet (we check for this to // allow subclasses to provide their own). if (_savefile == 0) { @@ -225,6 +212,14 @@ void OSystem_GP2X::initBackend() { // switch. But it's a long term goal to do just that! _timer = new DefaultTimerManager(); _timerID = SDL_AddTimer(10, &timer_handler, _timer); + + // Initialise any GP2X specific stuff we may want (Volume, Batt Status etc.) + GP2X_device_init(); + + // Set Default hardware mixer volume to a plesent level. + // This is done to 'reset' volume level if set by other apps. + GP2X_mixer_set_volume(70, 70); + } OSystem::initBackend(); @@ -321,6 +316,9 @@ void OSystem_GP2X::setFeatureState(Feature f, bool enable) { else _modeFlags &= ~DF_WANT_RECT_OPTIM; break; + case kFeatureDisableKeyFiltering: + // TODO: Extend as more support for this is added to engines. + return; default: break; } diff --git a/backends/platform/gp2x/graphics.cpp b/backends/platform/gp2x/graphics.cpp index c3ed5c627c..1aa7519f86 100644 --- a/backends/platform/gp2x/graphics.cpp +++ b/backends/platform/gp2x/graphics.cpp @@ -29,10 +29,10 @@ */ #include "backends/platform/gp2x/gp2x-common.h" -#include "graphics/scaler.h" #include "common/util.h" #include "graphics/font.h" #include "graphics/fontman.h" +#include "graphics/scaler.h" #include "graphics/surface.h" static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { @@ -236,17 +236,12 @@ void OSystem_GP2X::initSize(uint w, uint h){ } void OSystem_GP2X::loadGFXMode() { - - //enable 320x240 image to fit the 320x240 display area (aka, disable scaling) - //gp2x_video_RGB_setscaling(320,240); - assert(_inited); _forceFull = true; _modeFlags |= DF_UPDATE_EXPAND_1_PIXEL; int hwW, hwH; -#ifndef __MAEMO__ _overlayWidth = _screenWidth * _scaleFactor; _overlayHeight = _screenHeight * _scaleFactor; @@ -258,10 +253,6 @@ void OSystem_GP2X::loadGFXMode() { hwW = _screenWidth * _scaleFactor; hwH = effectiveScreenHeight(); -#else - hwW = _overlayWidth; - hwH = _overlayHeight; -#endif // // Create the surface that contains the 8 bit game data @@ -349,7 +340,6 @@ void OSystem_GP2X::loadGFXMode() { _km.y_max = effectiveScreenHeight() - 1; _km.delay_time = 25; _km.last_time = 0; - } void OSystem_GP2X::unloadGFXMode() { @@ -691,8 +681,10 @@ void OSystem_GP2X::copyRectToScreen(const byte *src, int pitch, int x, int y, in assert (_transactionMode == kTransactionNone); assert(src); - if (_screen == NULL) + if (_screen == NULL) { + warning("OSystem_GP2X::copyRectToScreen: _screen == NULL"); return; + } Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends @@ -757,6 +749,19 @@ void OSystem_GP2X::copyRectToScreen(const byte *src, int pitch, int x, int y, in } Graphics::Surface *OSystem_GP2X::lockScreen() { + assert (_transactionMode == kTransactionNone); + + // Lock the graphics mutex + lockMutex(_graphicsMutex); + + // paranoia check + assert(!_screenIsLocked); + _screenIsLocked = true; + + // Try to lock the screen surface + if (SDL_LockSurface(_screen) == -1) + error("SDL_LockSurface failed: %s", SDL_GetError()); + _framebuffer.pixels = _screen->pixels; _framebuffer.w = _screen->w; _framebuffer.h = _screen->h; @@ -767,8 +772,20 @@ Graphics::Surface *OSystem_GP2X::lockScreen() { } void OSystem_GP2X::unlockScreen() { - // Force screen update + assert (_transactionMode == kTransactionNone); + + // paranoia check + assert(_screenIsLocked); + _screenIsLocked = false; + + // Unlock the screen surface + SDL_UnlockSurface(_screen); + + // Trigger a full screen update _forceFull = true; + + // Finally unlock the graphics mutex + unlockMutex(_graphicsMutex); } void OSystem_GP2X::addDirtyRect(int x, int y, int w, int h, bool realCoordinates) { @@ -818,11 +835,9 @@ void OSystem_GP2X::addDirtyRect(int x, int y, int w, int h, bool realCoordinates h = height - y; } -#ifndef DISABLE_SCALERS if (_adjustAspectRatio && !_overlayVisible && !realCoordinates) { makeRectStretchable(x, y, w, h); } -#endif if (w == width && h == height) { _forceFull = true; @@ -851,7 +866,7 @@ void OSystem_GP2X::makeChecksums(const byte *buf) { /* the 8x8 blocks in buf are enumerated starting in the top left corner and * reading each line at a time from left to right */ for (y = 0; y != last_y; y++, buf += _screenWidth * (8 - 1)) - for (x = 0; x != last_x; x++, buf += 8) { // Adler32 checksum algorithm (from RFC1950, used by gzip and zlib). + for (x = 0; x != last_x; x++, buf += 8) { // Adler32 checksum algorithm (from RFC1950, used by gzip and zlib). // This computes the Adler32 checksum of a 8x8 pixel block. Note // that we can do the modulo operation (which is the slowest part) @@ -1165,8 +1180,6 @@ bool OSystem_GP2X::showMouse(bool visible) { bool last = _mouseVisible; _mouseVisible = visible; - //updateScreen(); - return last; } @@ -1174,7 +1187,6 @@ void OSystem_GP2X::setMousePos(int x, int y) { if (x != _mouseCurState.x || y != _mouseCurState.y) { _mouseCurState.x = x; _mouseCurState.y = y; - //updateScreen(); } } @@ -1521,7 +1533,6 @@ void OSystem_GP2X::drawMouse() { zoomdst.h = (tmpScreenHeight); SDL_GP2X_Display(&zoomdst); - }; @@ -1545,6 +1556,8 @@ void OSystem_GP2X::displayMessageOnOSD(const char *msg) { assert (_transactionMode == kTransactionNone); assert(msg); + Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends + uint i; // Lock the OSD surface for drawing @@ -1696,7 +1709,5 @@ void OSystem_GP2X::handleScalerHotkeys(const SDL_KeyboardEvent &key) { displayMessageOnOSD(buffer); } } - } - } diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index 32290bddea..6572166e91 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -332,6 +332,16 @@ OSystem_PS2::OSystem_PS2(const char *elfPath) { OSystem_PS2::~OSystem_PS2(void) { } +void OSystem_PS2::initBackend() { + // FIXME: Should probably move lots of stuff from the constructor to here + _mixer = new Audio::Mixer(); + _timer = new DefaultTimerManager(); + setSoundCallback(Audio::Mixer::mixCallback, _mixer); + setTimerCallback(&timer_handler, 10); + + OSystem::initBackend(); +} + void OSystem_PS2::initTimer(void) { // first setup the two threads that get activated by the timer: // the timerthread and the soundthread diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h index b5c84d3b95..033431a6fd 100644 --- a/backends/platform/ps2/systemps2.h +++ b/backends/platform/ps2/systemps2.h @@ -48,6 +48,9 @@ class OSystem_PS2 : public OSystem { public: OSystem_PS2(const char *elfPath); virtual ~OSystem_PS2(void); + + virtual void initBackend(); + virtual void initSize(uint width, uint height); virtual int16 getHeight(void); @@ -103,6 +106,8 @@ public: virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); virtual Common::SaveFileManager *getSavefileManager(); + virtual Audio::Mixer *getMixer() { return _mixer; } + virtual Common::TimerManager *getTimerManager() { return _timer; } void timerThread(void); void soundThread(void); @@ -129,6 +134,8 @@ private: bool _useMouse, _useKbd, _useHdd, _usbMassLoaded, _usbMassConnected; Ps2SaveFileManager *_saveManager; + Audio::Mixer *_mixer; + Common::TimerManager *_timer; Gs2dScreen *_screen; Ps2Input *_input; diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index d5d3669a22..7c0932dc20 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -38,15 +38,6 @@ enum GraphicModeID { CENTERED_362X272 }; -namespace Graphics { - struct Surface; -} - -namespace Common { - class SaveFileManager; - class TimerManager; -} - class OSystem_PSP : public OSystem { public: static const OSystem::GraphicsMode s_supportedGraphicsModes[]; diff --git a/backends/platform/sdl/events.cpp b/backends/platform/sdl/events.cpp index 2b3c2c18fe..19fb2372df 100644 --- a/backends/platform/sdl/events.cpp +++ b/backends/platform/sdl/events.cpp @@ -259,7 +259,7 @@ bool OSystem_SDL::pollEvent(Common::Event &event) { handleScalerHotkeys(ev.key); break; } - const bool event_complete = remapKey(ev,event); + const bool event_complete = remapKey(ev, event); if (event_complete) return true; @@ -445,7 +445,7 @@ bool OSystem_SDL::pollEvent(Common::Event &event) { return false; } -bool OSystem_SDL::remapKey(SDL_Event &ev,Common::Event &event) { +bool OSystem_SDL::remapKey(SDL_Event &ev, Common::Event &event) { #ifdef LINUPY // On Yopy map the End button to quit if ((ev.key.keysym.sym == 293)) { diff --git a/backends/platform/wince/Makefile b/backends/platform/wince/Makefile index 0d9556e967..a4b4fa4f12 100644 --- a/backends/platform/wince/Makefile +++ b/backends/platform/wince/Makefile @@ -51,7 +51,7 @@ USE_ZLIB = 1 #DISABLE_HQ_SCALERS = 1 USE_ARM_SOUND_ASM = 1 -USE_ARM_SMUSH = 1 +USE_ARM_SMUSH_ASM = 1 ######################################################################## diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp index 8c9b0ffd2a..b58dd87d93 100644 --- a/backends/saves/default/default-saves.cpp +++ b/backends/saves/default/default-saves.cpp @@ -187,16 +187,21 @@ void DefaultSaveFileManager::listSavefiles(const char *prefix , bool *marks, int search += '*'; //match all files that start with the given prefix search.c_str(); //FIXME: subtle bug? removing this line will break things. Looks like the string isn't getting updated. + assert(marks); memset(marks, false, num * sizeof(bool)); //assume no savegames for this title if(savePath.lookupFile(savefiles, savePath, search, false, true)) { char slot[2]; + int slotNum; for(FSList::const_iterator file = savefiles.begin(); file != savefiles.end(); file++) { //TODO: check if this is the behavior for all engines //Obtain the last 2 digits of the filename, since they correspond to the save slot slot[0] = file->getName()[file->getName().size()-2]; slot[1] = file->getName()[file->getName().size()-1]; - marks[atoi(slot)] = true; //mark this slot as valid + + slotNum = atoi(slot); + if(slotNum >= 0 && slotNum < num) + marks[slotNum] = true; //mark this slot as valid } } } |
