diff options
author | Tony Puccinelli | 2010-08-10 23:21:08 +0000 |
---|---|---|
committer | Tony Puccinelli | 2010-08-10 23:21:08 +0000 |
commit | 682807f0e916b189c69b60765418ee1ccc327cbf (patch) | |
tree | e8b220b934f6b14d4dac290181fce0c1b209579a /backends/platform/ds/arm9 | |
parent | 83f1531cb8fa5ba43c246143ecdde2cb1d140a8e (diff) | |
parent | fffec23a02cc88ed8daba0a3b50007b7e220c075 (diff) | |
download | scummvm-rg350-682807f0e916b189c69b60765418ee1ccc327cbf.tar.gz scummvm-rg350-682807f0e916b189c69b60765418ee1ccc327cbf.tar.bz2 scummvm-rg350-682807f0e916b189c69b60765418ee1ccc327cbf.zip |
merged trunk into branch, reverted Cruise Singleton changes
svn-id: r51961
Diffstat (limited to 'backends/platform/ds/arm9')
33 files changed, 709 insertions, 2466 deletions
diff --git a/backends/platform/ds/arm9/makefile b/backends/platform/ds/arm9/makefile index c43c28c223..c9a665c442 100644 --- a/backends/platform/ds/arm9/makefile +++ b/backends/platform/ds/arm9/makefile @@ -111,7 +111,7 @@ USE_ARM_COSTUME_ASM = 1 #WRAP_MALLOC = 1 ifdef DS_BUILD_A - DEFINES += -DDS_SCUMM_BUILD -DDS_BUILD_A -DUSE_ARM_GFX_ASM -DUSE_ARM_COSTUME_ASM + DEFINES = -DDS_BUILD_A -DUSE_ARM_GFX_ASM -DUSE_ARM_COSTUME_ASM LOGO = logoa.bmp ENABLE_SCUMM = $(ENABLED) USE_ARM_GFX_ASM = 1 @@ -119,7 +119,7 @@ ifdef DS_BUILD_A endif ifdef DS_BUILD_B - DEFINES += -DDS_NON_SCUMM_BUILD -DDS_BUILD_B + DEFINES = -DDS_BUILD_B LOGO = logob.bmp ENABLE_SKY = $(ENABLED) ENABLE_QUEEN = $(ENABLED) @@ -127,14 +127,14 @@ ifdef DS_BUILD_B endif ifdef DS_BUILD_C - DEFINES += -DDS_NON_SCUMM_BUILD -DDS_BUILD_C + DEFINES = -DDS_BUILD_C LOGO = logoc.bmp ENABLE_AGOS = $(ENABLED) BUILD=scummvm-C endif ifdef DS_BUILD_D - DEFINES += -DDS_NON_SCUMM_BUILD -DDS_BUILD_D + DEFINES = -DDS_BUILD_D LOGO = logod.bmp ENABLE_GOB = $(ENABLED) ENABLE_CINE = $(ENABLED) @@ -143,42 +143,42 @@ ifdef DS_BUILD_D endif ifdef DS_BUILD_E - DEFINES += -DDS_NON_SCUMM_BUILD -DDS_BUILD_E + DEFINES = -DDS_BUILD_E LOGO = logoe.bmp ENABLE_SAGA = $(ENABLED) BUILD=scummvm-E endif ifdef DS_BUILD_F - DEFINES += -DDS_NON_SCUMM_BUILD -DDS_BUILD_F + DEFINES = -DDS_BUILD_F LOGO = logof.bmp ENABLE_KYRA = $(ENABLED) BUILD=scummvm-F endif ifdef DS_BUILD_G - DEFINES += -DDS_NON_SCUMM_BUILD -DDS_BUILD_G + DEFINES = -DDS_BUILD_G LOGO = logog.bmp ENABLE_LURE = $(ENABLED) BUILD=scummvm-G endif ifdef DS_BUILD_H - DEFINES += -DDS_NON_SCUMM_BUILD -DDS_BUILD_H + DEFINES = -DDS_BUILD_H LOGO = logoh.bmp ENABLE_PARALLACTION = $(ENABLED) BUILD=scummvm-H endif ifdef DS_BUILD_I - DEFINES += -DDS_NON_SCUMM_BUILD -DDS_BUILD_I + DEFINES = -DDS_BUILD_I LOGO = logoi.bmp ENABLE_MADE = $(ENABLED) BUILD=scummvm-I endif ifdef DS_BUILD_K - DEFINES += -DDS_NON_SCUMM_BUILD -DDS_BUILD_K + DEFINES = -DDS_BUILD_K LOGO = logok.bmp ENABLE_CRUISE = $(ENABLED) BUILD=scummvm-K @@ -186,14 +186,14 @@ endif #ifdef DS_BUILD_L -# DEFINES = -DDS_NON_SCUMM_BUILD -DDS_BUILD_L +# DEFINES = -DDS_BUILD_L # LOGO = logog.bmp # ENABLE_DRASCULA = $(ENABLED) # BUILD=scummvm-K #endif #ifdef DS_BUILD_M -# DEFINES = -DDS_NON_SCUMM_BUILD -DDS_BUILD_M +# DEFINES = -DDS_BUILD_M # LOGO = logog.bmp # ENABLE_TUCKER = $(ENABLED) # BUILD=scummvm-K @@ -206,7 +206,6 @@ CXX = arm-eabi-g++ LD = arm-eabi-g++ CFLAGS = -Wno-multichar -Wall\ - -Wno-multichar -mcpu=arm9tdmi -mtune=arm9tdmi \ -mcpu=arm9tdmi -mtune=arm9tdmi -fomit-frame-pointer\ -mthumb-interwork -DUSE_ARM_COSTUME_ASM=1 -DDISABLE_SID @@ -252,9 +251,11 @@ ifdef WRAP_MALLOC DEFINES += -DWRAP_MALLOC endif +BACKEND := ds + INCLUDES= -I$(portdir) -I$(srcdir) -I$(srcdir)/engines \ -I$(portdir)/data -I$(portdir)/../commoninclude \ - -I$(portdir)/source -I$(portdir)/source/mad -I$(portdir)/source/libcartreset \ + -I$(portdir)/source -I$(portdir)/source/mad \ -I$(libndsdir)/include -include $(srcdir)/common/scummsys.h LIBS = -lm -L$(libndsdir)/lib -L$(portdir)/lib -lnds9 @@ -271,12 +272,13 @@ PRE_OBJS_FLAGS = -Wl,--whole-archive POST_OBJS_FLAGS = -Wl,--no-whole-archive endif -#-Lscumm -lscumm -Lbase -lbase -Lcommon -lcommon -Lgraphics -lgraphics -Lgui -lgui -Lsound -lsound EXECUTABLE = scummvm.elf + PLUGIN_PREFIX = PLUGIN_SUFFIX = .plg PLUGIN_EXTRA_DEPS = $(srcdir)/backends/plugins/ds/plugin.ld $(srcdir)/backends/plugins/plugin.syms $(EXECUTABLE) PLUGIN_LDFLAGS += -nostartfiles -Wl,-q,--target1-abs,--just-symbols,$(EXECUTABLE),-T$(srcdir)/backends/plugins/ds/plugin.ld,--retain-symbols-file,$(srcdir)/backends/plugins/plugin.syms -lstdc++ -lc -mthumb-interwork -mno-fpu#-Wl,--gc-sections -mno-crt0 $(DEVKITPRO)/devkitARM/arm-eabi/lib/ds_arm9_crt0.o + MKDIR = mkdir -p RM = rm -f RM_REC = rm -rf @@ -286,72 +288,77 @@ OBJCOPY = arm-eabi-objcopy AS = arm-eabi-as HAVE_GCC3 = true -PORT_OBJS := $(portdir)/source/blitters_arm.o $(portdir)/source/cdaudio.o $(portdir)/source/dsmain.o \ - $(portdir)/../../../fs/ds/ds-fs.o $(portdir)/source/gbampsave.o $(portdir)/source/scummhelp.o\ - $(portdir)/source/osystem_ds.o $(portdir)/source/ramsave.o\ - $(portdir)/source/touchkeyboard.o $(portdir)/source/zipreader.o\ - $(portdir)/source/dsoptions.o $(portdir)/source/keys.o $(portdir)/source/wordcompletion.o\ - $(portdir)/source/interrupt.o +PORT_OBJS := \ + $(portdir)/source/blitters_arm.o \ + $(portdir)/source/cdaudio.o \ + $(portdir)/source/dsmain.o \ + $(portdir)/source/gbampsave.o \ + $(portdir)/source/scummhelp.o \ + $(portdir)/source/osystem_ds.o \ + $(portdir)/source/touchkeyboard.o \ + $(portdir)/source/zipreader.o \ + $(portdir)/source/dsoptions.o \ + $(portdir)/source/keys.o \ + $(portdir)/source/wordcompletion.o \ + $(portdir)/source/interrupt.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 +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 + +FAT_OBJS := \ + $(portdir)/source/fat/disc_io.o \ + $(portdir)/source/fat/gba_nds_fat.o \ + $(portdir)/source/fat/io_fcsr.o \ + $(portdir)/source/fat/io_m3cf.o \ + $(portdir)/source/fat/io_mpcf.o \ + $(portdir)/source/fat/io_sccf.o \ + $(portdir)/source/fat/io_m3sd.o \ + $(portdir)/source/fat/io_nmmc.o \ + $(portdir)/source/fat/io_scsd.o \ + $(portdir)/source/fat/io_scsd_asm.o \ + $(portdir)/source/fat/io_njsd.o \ + $(portdir)/source/fat/io_mmcf.o \ + $(portdir)/source/fat/io_sd_common.o \ + $(portdir)/source/fat/io_m3_common.o \ + $(portdir)/source/fat/io_dldi.o \ + $(portdir)/source/fat/m3sd.o -FAT_OBJS := $(portdir)/source/fat/disc_io.o $(portdir)/source/fat/gba_nds_fat.o\ - $(portdir)/source/fat/io_fcsr.o $(portdir)/source/fat/io_m3cf.o\ - $(portdir)/source/fat/io_mpcf.o $(portdir)/source/fat/io_sccf.o\ - $(portdir)/source/fat/io_m3sd.o\ - $(portdir)/source/fat/io_nmmc.o $(portdir)/source/fat/io_scsd.o \ - $(portdir)/source/fat/io_scsd_asm.o \ - $(portdir)/source/fat/io_njsd.o \ - $(portdir)/source/fat/io_mmcf.o \ - $(portdir)/source/fat/io_sd_common.o \ - $(portdir)/source/fat/io_m3_common.o \ - $(portdir)/source/fat/io_dldi.o \ - $(portdir)/source/fat/m3sd.o - - -# $(portdir)/source/fat/io_cf_common.o $(portdir)/source/fat/io_m3_common.o\ -# $(portdir)/source/fat/io_sd_common.o $(portdir)/source/fat/io_scsd_s.o \ -# $(portdir)/source/fat/io_sc_common.o $(portdir)/source/fat/io_sd_common.o - -LIBCARTRESET_OBJS := -#$(portdir)/source/libcartreset/cartreset.o # Files in this list will be optimisied for speed, otherwise they will be optimised for space -OPTLIST := actor.cpp ds_main.cpp osystem_ds.cpp blitters.cpp mame.cpp rate.cpp isomap.cpp image.cpp gfx.cpp sprite.cpp actor_path.cpp actor_walk.cpp script.cpp +OPTLIST := actor.cpp dsmain.cpp osystem_ds.cpp blitters.cpp mame.cpp rate.cpp isomap.cpp image.cpp gfx.cpp sprite.cpp actor_path.cpp actor_walk.cpp script.cpp #OPTLIST := # Compiler options for files which should be optimised for speed ifdef DS_BUILD_E -# Another attempt to save some RAM in ITE -OPT_SPEED := -O3 -mthumb + # Another attempt to save some RAM in ITE + OPT_SPEED := -O3 -mthumb else -#OPT_SPEED := -O3 - -OPT_SPEED := -Os -mthumb - + OPT_SPEED := -O3 endif # Compiler options for files which should be optimised for space OPT_SIZE := -Os -mthumb -#-mthumb -fno-gcse -fno-schedule-insns2 - +OBJS := $(DATA_OBJS) $(PORT_OBJS) $(FAT_OBJS) -OBJS := $(DATA_OBJS) $(LIBCARTRESET_OBJS) $(PORT_OBJS) $(COMPRESSOR_OBJS) $(FAT_OBJS) MODULE_DIRS += . +#ndsall: plugins +# make -f makefile scummvm.nds + ndsall: plugins - make -f makefile scummvm.nds + make -f makefile scummvm.nds scummvm.ds.gba include $(srcdir)/Makefile.common @@ -360,26 +367,13 @@ semiclean: clean: $(RM) $(OBJS) $(EXECUTABLE) - rm -rf gui engines sound common plugins base backends graphics scummvm.nds scummvm.elf scummvm-stripped.elf scummvm.ds.gba *.h - -plugin_dist : - for p in $(PLUGINS); do \ - arm-elf-strip -g -o "`basename \"$$p\" | LC_CTYPE=C tr '[:lower:]' '[:upper:]'`" "$$p"; \ - done + rm -rf *.h engines plugins scummvm.nds scummvm.ds.gba dist : SCUMMVM.BIN plugins plugin_dist #--------------------------------------------------------------------------------- # canned command sequence for binary data #--------------------------------------------------------------------------------- -#define bin2o -# bin2s $< | $(AS) -mthumb -mthumb-interwork -o $(@) -# echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_raw_end[];" > `(echo $(<F) | tr . _)`.h -# echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_raw[];" >> `(echo $(<F) | tr . _)`.h -# echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_raw_size";" >> `(echo $(<F) | tr . _)`.h -#endef - - define bin2o bin2s $< | $(AS) -mthumb -mthumb-interwork -o $(@) echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h @@ -388,34 +382,10 @@ define bin2o endef -#define bin2o -# @echo $(*) -# cp $(<) $(*).tmp -# $(OBJCOPY) -I binary -O elf32-littlearm -B arm \ -# --rename-section .data=.rodata \ -# --redefine-sym _binary_$(subst .,_,$(subst /,_,$(*)))_tmp_start=$(notdir $*)\ -# --redefine-sym _binary_$(subst .,_,$(subst /,_,$(*)))_tmp_end=$(notdir $*)_end\ -# $(*).tmp $(@) -# echo "extern const u8" $(notdir $*)"[] __attribute__ ((aligned (4)));" > $(*).h -# echo "extern const u32" $(notdir $(*))_size[]";" >> $(*).h -# -# echo $(*).h -# rm $(*).tmp -#endef - - ############## # Replacement rule for the one in makefile.common ############## %.o: %.cpp -# 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 $(if $(findstring $(notdir $<), $(OPTLIST)), $(OPT_SPEED), $(OPT_SIZE)) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o @@ -423,12 +393,6 @@ endef #--------------------------------------------------------------------------------- #--------------------------------------------------------------------------------- -%.o : %.pcx -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - -#--------------------------------------------------------------------------------- %.o : %.bin #--------------------------------------------------------------------------------- @echo $(notdir $<) @@ -447,31 +411,17 @@ endef @$(bin2o) #--------------------------------------------------------------------------------- -%.o : %.map -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - -#--------------------------------------------------------------------------------- -%.o : %.mdl -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - -#--------------------------------------------------------------------------------- %.nds: %.bin - @echo ndstool -c $@ -9 scummvm.bin $(ARM7BIN) -b ../$(LOGO) "$(shell basename $@);ScummVM $(VERSION);DS Port" - ndstool -c $@ -9 scummvm.bin $(ARM7BIN) -b ../$(LOGO) "$(shell basename $@);ScummVM $(VERSION);DS Port" - dsbuild $@ -l ndsloader.bin + ndstool -c $@ -9 $< $(ARM7BIN) -b ../$(LOGO) "$(@F);ScummVM $(VERSION);DS Port" - padbin 16 $(basename $@).ds.gba +%.ds.gba: %.nds + dsbuild $< -o $@ -l $(portdir)/ndsloader.bin + padbin 16 $@ #--------------------------------------------------------------------------------- -# FIXME: The following rule hardcodes the input & output filename -- shouldn't it use $< and $@ instead? %.bin: %.elf - $(OBJCOPY) -S scummvm.elf scummvm-stripped.elf - $(OBJCOPY) -O binary scummvm-stripped.elf scummvm.bin + $(OBJCOPY) -S -O binary $< $@ #%.o: %.s # $(MKDIR) $(*D)/$(DEPDIR) diff --git a/backends/platform/ds/arm9/source/blitters.cpp b/backends/platform/ds/arm9/source/blitters.cpp index 07c6b3fee1..5d29672ef6 100644 --- a/backends/platform/ds/arm9/source/blitters.cpp +++ b/backends/platform/ds/arm9/source/blitters.cpp @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -27,13 +30,13 @@ namespace DS { -void asmDrawStripToScreen(int height, int width, byte const* text, byte const* src, byte* dst, +void asmDrawStripToScreen(int height, int width, byte const *text, byte const *src, byte *dst, int vsPitch, int vmScreenWidth, int textSurfacePitch) { - - if (height <= 0) height = 1; - if (width < 4) return; - + if (height <= 0) + height = 1; + if (width < 4) + return; width &= ~4; // src = (const byte *) (((int) (src)) & (~4)); @@ -111,7 +114,7 @@ void asmDrawStripToScreen(int height, int width, byte const* text, byte const* s -void asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height) { +void asmCopy8Col(byte *dst, int dstPitch, const byte *src, int height) { asm("ands r0, %3, #1\n" "addne %3, %3, #1\n" "bne roll2\n" @@ -141,22 +144,19 @@ void asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height) { static bool isDivBy5Ready = false; static u32 DIV_BY_5[160]; -void ComputeDivBy5TableIFN() -{ +void ComputeDivBy5TableIFN() { if (isDivBy5Ready) return; isDivBy5Ready = true; - for (int i=0; i<160; ++i) - { + for (int i = 0; i < 160; ++i) { DIV_BY_5[i] = (2*i+5)/10; } } #ifdef PERFECT_5_TO_4_RESCALING static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3, u16 s4, - u16* dest) -{ + u16 *dest) { u32 bs0 = s0 & 0x1F; u32 bs1 = s1 & 0x1F; u32 bs2 = s2 & 0x1F; @@ -230,8 +230,7 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3 } #else static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3, u16 s4, - u16* dest) -{ + u16 *dest) { static const u32 MASK = 0x03E07C1F; u32 argbargbs0 = u32(s0) | (u32(s0) << 16); @@ -279,8 +278,7 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3 #endif static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3, u32 s4, - u16* dest) -{ + u16 *dest) { u32 d0 = 4*s0 + s1; u32 d1 = 2*s1 + s1 + 2*s2; @@ -317,12 +315,10 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3 // Can't work in place #ifdef PERFECT_5_TO_4_RESCALING -static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16* dest, const u8* src, const u32* palette) -{ +static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16 *dest, const u8 *src, const u32 *palette) { ComputeDivBy5TableIFN(); - for (size_t i=0; i<64; ++i) - { + for (size_t i = 0; i < 64; ++i) { u32 s0 = palette[src[5*i+0]]; u32 s1 = palette[src[5*i+1]]; u32 s2 = palette[src[5*i+2]]; @@ -333,10 +329,8 @@ static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16* dest, const } } #else -static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16* dest, const u8* src, const u16* palette) -{ - for (size_t i=0; i<64; ++i) - { +static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16 *dest, const u8 *src, const u16 *palette) { + for (size_t i = 0; i < 64; ++i) { u16 s0 = palette[src[5*i+0]]; u16 s1 = palette[src[5*i+1]]; u16 s2 = palette[src[5*i+2]]; @@ -350,12 +344,10 @@ static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16* dest, const // Can work in place, because it's a contraction -static inline void Rescale_320x1555Scanline_To_256x1555Scanline(u16* dest, const u16* src) -{ +static inline void Rescale_320x1555Scanline_To_256x1555Scanline(u16 *dest, const u16 *src) { ComputeDivBy5TableIFN(); - for (size_t i=0; i<64; ++i) - { + for (size_t i = 0; i < 64; ++i) { u16 s0 = src[5*i+0]; u16 s1 = src[5*i+1]; u16 s2 = src[5*i+2]; @@ -367,13 +359,11 @@ static inline void Rescale_320x1555Scanline_To_256x1555Scanline(u16* dest, const } #ifdef PERFECT_5_TO_4_RESCALING -void Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, int destStride, int srcStride, const u16* palette) -{ +void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStride, int srcStride, const u16 *palette) { u32 fastRam[768]; // Palette lookup -> 0_888 - for (size_t i=0; i<256; ++i) - { + for (size_t i = 0; i < 256; ++i) { u32 col = palette[i]; u32 result = col & 0x0000001F; result |= (col << 3) & 0x00001F00; @@ -382,31 +372,26 @@ void Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, int destStri fastRam[i] = result; } - for (size_t i=0; i<200; ++i) - { + for (size_t i = 0; i < 200; ++i) { Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam); } } #else -void Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, int destStride, int srcStride, const u16* palette) -{ +void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStride, int srcStride, const u16 *palette) { u16 fastRam[256]; - for (size_t i=0; i<128; ++i) + for (size_t i = 0; i < 128; ++i) ((u32*)fastRam)[i] = ((const u32*)palette)[i]; - for (size_t i=0; i<200; ++i) - { + for (size_t i = 0; i < 200; ++i) { Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam); } } #endif -void Rescale_320x256x1555_To_256x256x1555(u16* dest, const u16* src, int destStride, int srcStride) -{ - for (size_t i=0; i<200; ++i) - { +void Rescale_320x256x1555_To_256x256x1555(u16 *dest, const u16 *src, int destStride, int srcStride) { + for (size_t i = 0; i < 200; ++i) { Rescale_320x1555Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride); } } -} +} // End of namespace DS diff --git a/backends/platform/ds/arm9/source/blitters.h b/backends/platform/ds/arm9/source/blitters.h index 5f541d1bd6..88506a4405 100644 --- a/backends/platform/ds/arm9/source/blitters.h +++ b/backends/platform/ds/arm9/source/blitters.h @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -29,23 +32,23 @@ namespace DS { -void asmDrawStripToScreen(int height, int width, byte const* text, byte const* src, byte* dst, +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, int destStride, int srcStride, const u16* palette); -void Rescale_320x256x1555_To_256x256x1555(u16* dest, const u16* src, int destStride, int srcStride); +void asmCopy8Col(byte *dst, int dstPitch, const byte *src, int height); +void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStride, int srcStride, const u16 *palette); +void Rescale_320x256x1555_To_256x256x1555(u16 *dest, const u16 *src, int destStride, int srcStride); -} +} // End of namespace DS #else extern "C" { -void ITCM_CODE asmDrawStripToScreen(int height, int width, byte const* text, byte const* src, byte* dst, +void ITCM_CODE asmDrawStripToScreen(int height, int width, byte const *text, byte const *src, byte *dst, int vsPitch, int vmScreenWidth, int textSurfacePitch); -void ITCM_CODE asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height); -void ITCM_CODE Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, int destStride, int srcStride, const u16* palette, u32 numLines); -void ITCM_CODE Rescale_320x256x1555_To_256x256x1555(u16* dest, const u16* src, int destStride, int srcStride); +void ITCM_CODE asmCopy8Col(byte *dst, int dstPitch, const byte *src, int height); +void ITCM_CODE Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStride, int srcStride, const u16 *palette, u32 numLines); +void ITCM_CODE Rescale_320x256x1555_To_256x256x1555(u16 *dest, const u16 *src, int destStride, int srcStride); } diff --git a/backends/platform/ds/arm9/source/cdaudio.cpp b/backends/platform/ds/arm9/source/cdaudio.cpp index 7756286117..5860dea4f2 100644 --- a/backends/platform/ds/arm9/source/cdaudio.cpp +++ b/backends/platform/ds/arm9/source/cdaudio.cpp @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -71,25 +74,25 @@ struct decoderFormat { unsigned char sample[1024]; } __attribute__ ((packed)); -bool active = false; -WaveHeader waveHeader; -Header blockHeader; -FILE* file; -int fillPos; -bool isPlayingFlag = false; +static bool s_active = false; +static WaveHeader waveHeader; +static Header blockHeader; +static FILE *s_file; +static int fillPos; +static bool isPlayingFlag = false; -s16* audioBuffer; -u32 sampleNum; -s16* decompressionBuffer; -int numLoops; -int blockCount; -int dataChunkStart; -int blocksLeft; -bool trackStartsAt2 = false; +static s16 *audioBuffer; +static u32 sampleNum; +static s16 *decompressionBuffer; +static int s_numLoops; +static int blockCount; +static int dataChunkStart; +static int blocksLeft; +static bool trackStartsAt2 = false; // These are from Microsoft's document on DVI ADPCM -const int stepTab[ 89 ] = { +static const int stepTab[ 89 ] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, @@ -103,7 +106,7 @@ const int stepTab[ 89 ] = { 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 }; -const int indexTab[ 16 ] = { -1, -1, -1, -1, 2, 4, 6, 8, +static const int indexTab[ 16 ] = { -1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8 }; void playNextBlock(); @@ -115,11 +118,11 @@ void allocBuffers() { } void setActive(bool active) { - DS::CD::active = active; + s_active = active; } bool getActive() { - return active; + return s_active; } void playTrack(int track, int numLoops, int startFrame, int duration) { @@ -145,21 +148,21 @@ void playTrack(int track, int numLoops, int startFrame, int duration) { sprintf(str, "track%d.wav", track); fname = path + str; - file = DS::std_fopen(fname.c_str(), "rb"); + s_file = DS::std_fopen(fname.c_str(), "rb"); - if (!file) { + if (!s_file) { sprintf(str, "track%02d.wav", track); fname = path + str; - file = DS::std_fopen(fname.c_str(), "rb"); + s_file = DS::std_fopen(fname.c_str(), "rb"); } - if (!file) { + if (!s_file) { consolePrintf("Failed to open %s!\n", path.c_str()); return; } - DS::std_fread((const void *) &waveHeader, sizeof(waveHeader), 1, file); + DS::std_fread(&waveHeader, sizeof(waveHeader), 1, s_file); consolePrintf("File: %s\n", fname.c_str()); @@ -171,7 +174,7 @@ void playTrack(int track, int numLoops, int startFrame, int duration) { if ((waveHeader.fmtFormatTag != 17) && (waveHeader.fmtFormatTag != 20)) { consolePrintf("Wave file is in the wrong format! You must use IMA-ADPCM 4-bit mono.\n"); - DS::std_fclose(file); + DS::std_fclose(s_file); return; } @@ -183,14 +186,14 @@ void playTrack(int track, int numLoops, int startFrame, int duration) { // Skip chunks until we reach the data chunk chunkHeader chunk; - DS::std_fread((const void *) &chunk, sizeof(chunkHeader), 1, file); + DS::std_fread(&chunk, sizeof(chunkHeader), 1, s_file); while (!((chunk.name[0] == 'd') && (chunk.name[1] == 'a') && (chunk.name[2] == 't') && (chunk.name[3] == 'a'))) { - DS::std_fseek(file, chunk.size, SEEK_CUR); - DS::std_fread((const void *) &chunk, sizeof(chunkHeader), 1, file); + DS::std_fseek(s_file, chunk.size, SEEK_CUR); + DS::std_fread(&chunk, sizeof(chunkHeader), 1, s_file); } - dataChunkStart = DS::std_ftell(file); + dataChunkStart = DS::std_ftell(s_file); static bool started = false; @@ -234,14 +237,14 @@ void playTrack(int track, int numLoops, int startFrame, int duration) { // No need to seek if we're starting from the beginning if (block != 0) { - DS::std_fseek(file, dataChunkStart + block * waveHeader.fmtBlockAlign, SEEK_SET); + DS::std_fseek(s_file, dataChunkStart + block * waveHeader.fmtBlockAlign, SEEK_SET); // consolePrintf("Startframe: %d msec: %d (%d,%d)\n", startFrame, tenthssec, samples, block); } //decompressBlock(); playNextBlock(); - DS::CD::numLoops = numLoops; + s_numLoops = numLoops; } void update() { @@ -263,20 +266,20 @@ void decompressBlock() { do { - DS::std_fread((const void *) &blockHeader, sizeof(blockHeader), 1, file); + DS::std_fread(&blockHeader, sizeof(blockHeader), 1, s_file); - DS::std_fread(&block[0], waveHeader.fmtBlockAlign - sizeof(blockHeader), 1, file); + DS::std_fread(&block[0], waveHeader.fmtBlockAlign - sizeof(blockHeader), 1, s_file); - if (DS::std_feof(file) ) { + if (DS::std_feof(s_file)) { // Reached end of file, so loop - if ((numLoops == -1) || (numLoops > 1)) { + if ((s_numLoops == -1) || (s_numLoops > 1)) { // Seek file to first packet - if (numLoops != -1) { - numLoops--; + if (s_numLoops != -1) { + s_numLoops--; } - DS::std_fseek(file, dataChunkStart, SEEK_SET); + DS::std_fseek(s_file, dataChunkStart, SEEK_SET); loop = true; } else { // Fill decompression buffer with zeros to prevent glitching @@ -325,45 +328,30 @@ void decompressBlock() { int offset = 0; switch (7 - (r & 0x0007)) { - case 0: { - offset = (word & 0xF0000000) >> 28; - break; - } - - case 1: { - offset = (word & 0x0F000000) >> 24; - break; - } - - case 2: { - offset = (word & 0x00F00000) >> 20; - break; - } - - case 3: { - offset = (word & 0x000F0000) >> 16; - break; - } - - case 4: { - offset = (word & 0x0000F000) >> 12; - break; - } - - case 5: { - offset = (word & 0x00000F00) >> 8; - break; - } - - case 6: { - offset = (word & 0x000000F0) >> 4; - break; - } - - case 7: { - offset = (word & 0x0000000F); - break; - } + case 0: + offset = (word & 0xF0000000) >> 28; + break; + case 1: + offset = (word & 0x0F000000) >> 24; + break; + case 2: + offset = (word & 0x00F00000) >> 20; + break; + case 3: + offset = (word & 0x000F0000) >> 16; + break; + case 4: + offset = (word & 0x0000F000) >> 12; + break; + case 5: + offset = (word & 0x00000F00) >> 8; + break; + case 6: + offset = (word & 0x000000F0) >> 4; + break; + case 7: + offset = (word & 0x0000000F); + break; } int diff = 0; @@ -406,7 +394,8 @@ void decompressBlock() { } void playNextBlock() { - if (!isPlayingFlag) return; + if (!isPlayingFlag) + return; int lastBlockId = -1; while (IPC->adpcm.semaphore); // Wait for buffer to become free if needed @@ -442,9 +431,6 @@ void playNextBlock() { // DC_FlushAll(); } - - - } @@ -460,9 +446,10 @@ void playNextBlock() { } void stopTrack() { - if (!isPlayingFlag) return; + if (!isPlayingFlag) + return; - DS::std_fclose(file); + DS::std_fclose(s_file); isPlayingFlag = false; @@ -470,7 +457,7 @@ void stopTrack() { audioBuffer[r] = 0; } - for (int r= 0; r < waveHeader.fmtExtra; r++) { + for (int r = 0; r < waveHeader.fmtExtra; r++) { decompressionBuffer[r] = 0; } // DS::stopSound(1); @@ -495,8 +482,8 @@ bool trackExists(int num) { } consolePrintf("Looking for %s...", path.c_str()); - FILE* file; - if ((file = DS::std_fopen(path.c_str(), "r"))) { + FILE *file = DS::std_fopen(path.c_str(), "r"); + if (file) { consolePrintf("Success!\n"); setActive(true); DS::std_fclose(file); @@ -548,4 +535,4 @@ bool isPlaying() { } } -} +} // End of namespace DS diff --git a/backends/platform/ds/arm9/source/cdaudio.h b/backends/platform/ds/arm9/source/cdaudio.h index aac303dd5e..6e53ef7bd2 100644 --- a/backends/platform/ds/arm9/source/cdaudio.h +++ b/backends/platform/ds/arm9/source/cdaudio.h @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -35,6 +38,6 @@ bool isPlaying(); void update(); } -} +} // End of namespace DS #endif diff --git a/backends/platform/ds/arm9/source/compressor/lz.cpp b/backends/platform/ds/arm9/source/compressor/lz.cpp deleted file mode 100644 index 47a36646c6..0000000000 --- a/backends/platform/ds/arm9/source/compressor/lz.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/************************************************************************* -* Name: lz.c -* Author: Marcus Geelnard -* Description: LZ77 coder/decoder implementation. -* Reentrant: Yes -* $Id$ -* -* The LZ77 compression scheme is a substitutional compression scheme -* proposed by Abraham Lempel and Jakob Ziv in 1977. It is very simple in -* its design, and uses no fancy bit level compression. -* -* This is my first attempt at an implementation of a LZ77 code/decoder. -* -* The principle of the LZ77 compression algorithm is to store repeated -* occurrences of strings as references to previous occurrences of the same -* string. The point is that the reference consumes less space than the -* string itself, provided that the string is long enough (in this -* implementation, the string has to be at least 4 bytes long, since the -* minimum coded reference is 3 bytes long). Also note that the term -* "string" refers to any kind of byte sequence (it does not have to be -* an ASCII string, for instance). -* -* The coder uses a brute force approach to finding string matches in the -* history buffer (or "sliding window", if you wish), which is very, very -* slow. I recon the complexity is somewhere between O(n^2) and O(n^3), -* depending on the input data. -* -* There is also a faster implementation that uses a large working buffer -* in which a "jump table" is stored, which is used to quickly find -* possible string matches (see the source code for LZ_CompressFast() for -* more information). The faster method is an order of magnitude faster, -* and also does a full string search in the entire input buffer (it does -* not use a sliding window). -* -* The upside is that decompression is very fast, and the compression ratio -* is often very good. -* -* The reference to a string is coded as a (length,offset) pair, where the -* length indicates the length of the string, and the offset gives the -* offset from the current data position. To distinguish between string -* references and literal strings (uncompressed bytes), a string reference -* is preceded by a marker byte, which is chosen as the least common byte -* symbol in the input data stream (this marker byte is stored in the -* output stream as the first byte). -* -* Occurrences of the marker byte in the stream are encoded as the marker -* byte followed by a zero byte, which means that occurrences of the marker -* byte have to be coded with two bytes. -* -* The lengths and offsets are coded in a variable length fashion, allowing -* values of any magnitude (up to 4294967295 in this implementation). -* -* With this compression scheme, the worst case compression result is -* (257/256)*insize + 1. -* -*------------------------------------------------------------------------- -* Copyright (c) 2003-2004 Marcus Geelnard -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would -* be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not -* be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any source -* distribution. -* -* Marcus Geelnard -* marcus.geelnard at home.se -*************************************************************************/ - - -/************************************************************************* -* Constants used for LZ77 coding -*************************************************************************/ - -/* Maximum offset (can be any size < 2^32). Lower values gives faster - compression, while higher values gives better compression. - NOTE: LZ_CompressFast does not use this constant. */ -#define LZ_MAX_OFFSET 512 - - - -/************************************************************************* -* INTERNAL FUNCTIONS * -*************************************************************************/ - - -/************************************************************************* -* _LZ_StringCompare() - Return maximum length string match. -*************************************************************************/ - -inline static unsigned int _LZ_StringCompare( unsigned char * str1, - unsigned char * str2, unsigned int minlen, unsigned int maxlen ) -{ - unsigned int len; - - for ( len = minlen; (len < maxlen) && (str1[len] == str2[len]); ++ len ); - - return len; -} - - -/************************************************************************* -* _LZ_WriteVarSize() - Write unsigned integer with variable number of -* bytes depending on value. -*************************************************************************/ - -inline static int _LZ_WriteVarSize( unsigned int x, unsigned char * buf ) -{ - unsigned int y; - int num_bytes, i, b; - - /* Determine number of bytes needed to store the number x */ - y = x >> 3; - for ( num_bytes = 5; num_bytes >= 2; -- num_bytes ) - { - if ( y & 0xfe000000 ) break; - y <<= 7; - } - - /* Write all bytes, seven bits in each, with 8:th bit set for all */ - /* but the last byte. */ - for ( i = num_bytes-1; i >= 0; -- i ) - { - b = (x >> (i*7)) & 0x0000007f; - if ( i > 0 ) - { - b |= 0x00000080; - } - *buf ++ = (unsigned char) b; - } - - /* Return number of bytes written */ - return num_bytes; -} - - -/************************************************************************* -* _LZ_ReadVarSize() - Read unsigned integer with variable number of -* bytes depending on value. -*************************************************************************/ - -inline static int _LZ_ReadVarSize( unsigned int * x, unsigned char * buf ) -{ - unsigned int y, b, num_bytes; - - /* Read complete value (stop when byte contains zero in 8:th bit) */ - y = 0; - num_bytes = 0; - do - { - b = (unsigned int) (*buf ++); - y = (y << 7) | (b & 0x0000007f); - ++ num_bytes; - } - while ( b & 0x00000080 ); - - /* Store value in x */ - *x = y; - - /* Return number of bytes read */ - return num_bytes; -} - - - -/************************************************************************* -* PUBLIC FUNCTIONS * -*************************************************************************/ - - -/************************************************************************* -* LZ_Compress() - Compress a block of data using an LZ77 coder. -* in - Input (uncompressed) buffer. -* out - Output (compressed) buffer. This buffer must be 0.4% larger -* than the input buffer, plus one byte. -* insize - Number of input bytes. -* The function returns the size of the compressed data. -*************************************************************************/ - -int LZ_Compress( unsigned char *in, unsigned char *out, - unsigned int insize ) -{ - unsigned char marker, symbol; - unsigned int inpos, outpos, bytesleft, i; - unsigned int maxoffset, offset, bestoffset; - unsigned int maxlength, length, bestlength; - unsigned int histogram[ 256 ]; - unsigned char *ptr1, *ptr2; - - /* Do we have anything to compress? */ - if ( insize < 1 ) - { - return 0; - } - - /* Create histogram */ - for ( i = 0; i < 256; ++ i ) - { - histogram[ i ] = 0; - } - for ( i = 0; i < insize; ++ i ) - { - ++ histogram[ in[ i ] ]; - } - - /* Find the least common byte, and use it as the code marker */ - marker = 0; - for ( i = 1; i < 256; ++ i ) - { - if ( histogram[ i ] < histogram[ marker ] ) - { - marker = i; - } - } - - /* Remember the repetition marker for the decoder */ - out[ 0 ] = marker; - - /* Start of compression */ - inpos = 0; - outpos = 1; - - /* Main compression loop */ - bytesleft = insize; - do - { - /* Determine most distant position */ - if ( inpos > LZ_MAX_OFFSET ) maxoffset = LZ_MAX_OFFSET; - else maxoffset = inpos; - - /* Get pointer to current position */ - ptr1 = &in[ inpos ]; - - /* Search history window for maximum length string match */ - bestlength = 3; - bestoffset = 0; - for ( offset = 3; offset <= maxoffset; ++ offset ) - { - /* Get pointer to candidate string */ - ptr2 = &ptr1[ -offset ]; - - /* Quickly determine if this is a candidate (for speed) */ - if ( (ptr1[ 0 ] == ptr2[ 0 ]) && - (ptr1[ bestlength ] == ptr2[ bestlength ]) ) - { - /* Determine maximum length for this offset */ - maxlength = (bytesleft < offset ? bytesleft : offset); - - /* Count maximum length match at this offset */ - length = _LZ_StringCompare( ptr1, ptr2, 0, maxlength ); - - /* Better match than any previous match? */ - if ( length > bestlength ) - { - bestlength = length; - bestoffset = offset; - } - } - } - - /* Was there a good enough match? */ - if ( (bestlength >= 8) || - ((bestlength == 4) && (bestoffset <= 0x0000007f)) || - ((bestlength == 5) && (bestoffset <= 0x00003fff)) || - ((bestlength == 6) && (bestoffset <= 0x001fffff)) || - ((bestlength == 7) && (bestoffset <= 0x0fffffff)) ) - { - out[ outpos ++ ] = (unsigned char) marker; - outpos += _LZ_WriteVarSize( bestlength, &out[ outpos ] ); - outpos += _LZ_WriteVarSize( bestoffset, &out[ outpos ] ); - inpos += bestlength; - bytesleft -= bestlength; - } - else - { - /* Output single byte (or two bytes if marker byte) */ - symbol = in[ inpos ++ ]; - out[ outpos ++ ] = symbol; - if ( symbol == marker ) - { - out[ outpos ++ ] = 0; - } - -- bytesleft; - } - } - while ( bytesleft > 3 ); - - /* Dump remaining bytes, if any */ - while ( inpos < insize ) - { - if ( in[ inpos ] == marker ) - { - out[ outpos ++ ] = marker; - out[ outpos ++ ] = 0; - } - else - { - out[ outpos ++ ] = in[ inpos ]; - } - ++ inpos; - } - - return outpos; -} - - -/************************************************************************* -* LZ_CompressFast() - Compress a block of data using an LZ77 coder. -* in - Input (uncompressed) buffer. -* out - Output (compressed) buffer. This buffer must be 0.4% larger -* than the input buffer, plus one byte. -* insize - Number of input bytes. -* work - Pointer to a temporary buffer (internal working buffer), which -* must be able to hold (insize+65536) unsigned integers. -* The function returns the size of the compressed data. -*************************************************************************/ - -int LZ_CompressFast( unsigned char *in, unsigned char *out, - unsigned int insize, unsigned int *work ) -{ - unsigned char marker, symbol; - unsigned int inpos, outpos, bytesleft, i, index, symbols; - unsigned int offset, bestoffset; - unsigned int maxlength, length, bestlength; - unsigned int histogram[ 256 ], *lastindex, *jumptable; - unsigned char *ptr1, *ptr2; - - /* Do we have anything to compress? */ - if ( insize < 1 ) - { - return 0; - } - - /* Assign arrays to the working area */ - lastindex = work; - jumptable = &work[ 65536 ]; - - /* Build a "jump table". Here is how the jump table works: - jumptable[i] points to the nearest previous occurrence of the same - symbol pair as in[i]:in[i+1], so in[i] == in[jumptable[i]] and - in[i+1] == in[jumptable[i]+1]. Following the jump table gives a - dramatic boost for the string search'n'match loop compared to doing - a brute force search. */ - for ( i = 0; i < 65536; ++ i ) - { - lastindex[ i ] = 0xffffffff; - } - for ( i = 0; i < insize-1; ++ i ) - { - symbols = (((unsigned int)in[i]) << 8) | ((unsigned int)in[i+1]); - index = lastindex[ symbols ]; - lastindex[ symbols ] = i; - jumptable[ i ] = index; - } - jumptable[ insize-1 ] = 0xffffffff; - - /* Create histogram */ - for ( i = 0; i < 256; ++ i ) - { - histogram[ i ] = 0; - } - for ( i = 0; i < insize; ++ i ) - { - ++ histogram[ in[ i ] ]; - } - - /* Find the least common byte, and use it as the code marker */ - marker = 0; - for ( i = 1; i < 256; ++ i ) - { - if ( histogram[ i ] < histogram[ marker ] ) - { - marker = i; - } - } - - /* Remember the repetition marker for the decoder */ - out[ 0 ] = marker; - - /* Start of compression */ - inpos = 0; - outpos = 1; - - /* Main compression loop */ - bytesleft = insize; - do - { - /* Get pointer to current position */ - ptr1 = &in[ inpos ]; - - /* Search history window for maximum length string match */ - bestlength = 3; - bestoffset = 0; - index = jumptable[ inpos ]; - while ( index != 0xffffffff ) - { - /* Get pointer to candidate string */ - ptr2 = &in[ index ]; - - /* Quickly determine if this is a candidate (for speed) */ - if ( ptr2[ bestlength ] == ptr1[ bestlength ] ) - { - /* Determine maximum length for this offset */ - offset = inpos - index; - maxlength = (bytesleft < offset ? bytesleft : offset); - - /* Count maximum length match at this offset */ - length = _LZ_StringCompare( ptr1, ptr2, 2, maxlength ); - - /* Better match than any previous match? */ - if ( length > bestlength ) - { - bestlength = length; - bestoffset = offset; - } - } - - /* Get next possible index from jump table */ - index = jumptable[ index ]; - } - - /* Was there a good enough match? */ - if ( (bestlength >= 8) || - ((bestlength == 4) && (bestoffset <= 0x0000007f)) || - ((bestlength == 5) && (bestoffset <= 0x00003fff)) || - ((bestlength == 6) && (bestoffset <= 0x001fffff)) || - ((bestlength == 7) && (bestoffset <= 0x0fffffff)) ) - { - out[ outpos ++ ] = (unsigned char) marker; - outpos += _LZ_WriteVarSize( bestlength, &out[ outpos ] ); - outpos += _LZ_WriteVarSize( bestoffset, &out[ outpos ] ); - inpos += bestlength; - bytesleft -= bestlength; - } - else - { - /* Output single byte (or two bytes if marker byte) */ - symbol = in[ inpos ++ ]; - out[ outpos ++ ] = symbol; - if ( symbol == marker ) - { - out[ outpos ++ ] = 0; - } - -- bytesleft; - } - } - while ( bytesleft > 3 ); - - /* Dump remaining bytes, if any */ - while ( inpos < insize ) - { - if ( in[ inpos ] == marker ) - { - out[ outpos ++ ] = marker; - out[ outpos ++ ] = 0; - } - else - { - out[ outpos ++ ] = in[ inpos ]; - } - ++ inpos; - } - - return outpos; -} - - -/************************************************************************* -* LZ_Uncompress() - Uncompress a block of data using an LZ77 decoder. -* in - Input (compressed) buffer. -* out - Output (uncompressed) buffer. This buffer must be large -* enough to hold the uncompressed data. -* insize - Number of input bytes. -*************************************************************************/ - -void LZ_Uncompress( unsigned char *in, unsigned char *out, - unsigned int insize ) -{ - unsigned char marker, symbol; - unsigned int i, inpos, outpos, length, offset; - - /* Do we have anything to compress? */ - if ( insize < 1 ) - { - return; - } - - /* Get marker symbol from input stream */ - marker = in[ 0 ]; - inpos = 1; - - /* Main decompression loop */ - outpos = 0; - do - { - symbol = in[ inpos ++ ]; - if ( symbol == marker ) - { - /* We had a marker byte */ - if ( in[ inpos ] == 0 ) - { - /* It was a single occurrence of the marker byte */ - out[ outpos ++ ] = marker; - ++ inpos; - } - else - { - /* Extract true length and offset */ - inpos += _LZ_ReadVarSize( &length, &in[ inpos ] ); - inpos += _LZ_ReadVarSize( &offset, &in[ inpos ] ); - - /* Copy corresponding data from history window */ - for ( i = 0; i < length; ++ i ) - { - out[ outpos ] = out[ outpos - offset ]; - ++ outpos; - } - } - } - else - { - /* No marker, plain copy */ - out[ outpos ++ ] = symbol; - } - } - while ( inpos < insize ); -} diff --git a/backends/platform/ds/arm9/source/compressor/lz.h b/backends/platform/ds/arm9/source/compressor/lz.h deleted file mode 100644 index e7ea1567ca..0000000000 --- a/backends/platform/ds/arm9/source/compressor/lz.h +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************************************* -* Name: lz.h -* Author: Marcus Geelnard -* Description: LZ77 coder/decoder interface. -* Reentrant: Yes -* $Id$ -*------------------------------------------------------------------------- -* Copyright (c) 2003-2004 Marcus Geelnard -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would -* be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not -* be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any source -* distribution. -* -* Marcus Geelnard -* marcus.geelnard at home.se -*************************************************************************/ - -#ifndef _lz_h_ -#define _lz_h_ - - - -/************************************************************************* -* Function prototypes -*************************************************************************/ - -int LZ_Compress( unsigned char *in, unsigned char *out, - unsigned int insize ); -int LZ_CompressFast( unsigned char *in, unsigned char *out, - unsigned int insize, unsigned int *work ); -void LZ_Uncompress( unsigned char *in, unsigned char *out, - unsigned int insize ); - - -#endif /* _lz_h_ */ diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp index ee9e4d7622..4c7d6b89ae 100644 --- a/backends/platform/ds/arm9/source/dsmain.cpp +++ b/backends/platform/ds/arm9/source/dsmain.cpp @@ -73,8 +73,6 @@ -//#define USE_LIBCARTRESET - #include <nds.h> #include <nds/registers_alt.h> #include <nds/arm9/exceptions.h> @@ -100,20 +98,15 @@ #ifdef USE_DEBUGGER #include "user_debugger.h" #endif -#include "ramsave.h" #include "blitters.h" -#include "libcartreset/cartreset_nolibfat.h" #include "keys.h" #ifdef USE_PROFILER #include "profiler/cyg-profile.h" #endif -#include "base/version.h" #include "engine.h" - -#include "backends/plugins/elf-provider.h" #include "backends/plugins/ds/ds-provider.h" - +#include "backends/plugins/elf-provider.h" #include "backends/fs/ds/ds-fs.h" #include "base/version.h" #include "common/util.h" @@ -388,6 +381,9 @@ void uploadSpriteGfx(); static TransferSound soundControl; +static bool isScrollingWithDPad() { + return (getKeysHeld() & (KEY_L | KEY_R)) != 0; +} bool isCpuScalerEnabled() { return cpuScalerEnable || !displayModeIs8Bit; @@ -1344,7 +1340,7 @@ void doScreenTapMode(OSystem_DS *system) { right = true; } - if (!(getKeysHeld() & (KEY_L | KEY_R))) { + if (!isScrollingWithDPad()) { if (getKeysDown() & KEY_LEFT) { event.type = Common::EVENT_LBUTTONDOWN; @@ -1381,7 +1377,7 @@ void doButtonSelectMode(OSystem_DS *system) { Common::Event event; - if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) { + if (!isScrollingWithDPad()) { event.type = Common::EVENT_MOUSEMOVE; event.mouse = Common::Point(getPenX(), getPenY()); system->addEvent(event); @@ -1404,7 +1400,7 @@ void doButtonSelectMode(OSystem_DS *system) { if ((mouseMode != MOUSE_HOVER) || (!displayModeIs8Bit)) { - if (getPenDown() && (!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) { + if (getPenDown() && !isScrollingWithDPad()) { if (mouseMode == MOUSE_LEFT) { event.type = Common::EVENT_LBUTTONDOWN; leftButtonDown = true; @@ -1446,7 +1442,7 @@ void doButtonSelectMode(OSystem_DS *system) { } } - if (!((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) && (!getIndyFightState()) && (!getKeyboardEnable())) { + if (!isScrollingWithDPad() && !getIndyFightState() && !getKeyboardEnable()) { if (!getPenHeld() || (mouseMode != MOUSE_HOVER)) { if (getKeysDown() & KEY_LEFT) { @@ -1542,7 +1538,7 @@ void addEventsToQueue() { if (!indyFightState) { - if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) && (getKeysDown() & KEY_B)) { + if (!isScrollingWithDPad() && (getKeysDown() & KEY_B)) { if (s_currentGame->control == CONT_AGI) { event.kbd.keycode = Common::KEYCODE_RETURN; event.kbd.ascii = 13; @@ -1614,7 +1610,7 @@ void addEventsToQueue() { } - if (!((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) && (!getIndyFightState()) && (!getKeyboardEnable())) { + if (!isScrollingWithDPad() && !getIndyFightState() && !getKeyboardEnable()) { if ((getKeysDown() & KEY_A) && (!indyFightState)) { gameScreenSwap = !gameScreenSwap; @@ -1653,7 +1649,7 @@ void addEventsToQueue() { } } - if (!getIndyFightState() && !((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) && (getKeysDown() & KEY_X)) { + if (!getIndyFightState() && !isScrollingWithDPad() && (getKeysDown() & KEY_X)) { setKeyboardEnable(!keyboardEnable); } @@ -1675,7 +1671,7 @@ void addEventsToQueue() { if (!keyboardEnable) { - if (((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) || (indyFightState)) && (displayModeIs8Bit)) { + if ((isScrollingWithDPad() || (indyFightState)) && (displayModeIs8Bit)) { // Controls specific to the control method if (s_currentGame->control == CONT_SKY) { @@ -2017,7 +2013,7 @@ void VBlankHandler(void) { soundUpdate(); - if ((!gameScreenSwap) && (!(getKeysHeld() & KEY_L) && !(getKeysHeld() & KEY_R))) { + if ((!gameScreenSwap) && !isScrollingWithDPad()) { if (s_currentGame) { if (s_currentGame->control != CONT_SCUMM_SAMNMAX) { if (getPenHeld() && (getPenY() < SCUMM_GAME_HEIGHT)) { @@ -2059,7 +2055,7 @@ void VBlankHandler(void) { callbackTimer -= FRAME_TIME; } - if ((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) { + if (isScrollingWithDPad()) { if ((!dragging) && (getPenHeld()) && (penDownFrames > 5)) { dragging = true; @@ -2113,7 +2109,7 @@ void VBlankHandler(void) { bool zooming = false; - if ((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) { + if (isScrollingWithDPad()) { if ((getKeysHeld() & KEY_A) && (subScreenScale < ratio)) { subScreenScale += 1; zooming = true; @@ -2190,7 +2186,7 @@ void VBlankHandler(void) { if (displayModeIs8Bit) { - if ((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) { + if (isScrollingWithDPad()) { int offsX = 0, offsY = 0; @@ -2777,31 +2773,6 @@ GLvector getPenPos() { return v; } -#ifdef GBA_SRAM_SAVE - -void formatSramOption() { - consolePrintf("The following files are present in save RAM:\n"); - DSSaveFileManager::instance()->listFiles(); - - consolePrintf("\nAre you sure you want to\n"); - consolePrintf("DELETE all files?\n"); - consolePrintf("A = Yes, X = No\n"); - - while (true) { - if (keysHeld() & KEY_A) { - DSSaveFileManager::instance()->formatSram(); - consolePrintf("SRAM cleared!\n"); - return; - } - - if (keysHeld() & KEY_X) { - consolePrintf("Whew, that was close!\n"); - return; - } - } -} -#endif - void setIndyFightState(bool st) { indyFightState = st; indyFightRight = true; @@ -2886,61 +2857,6 @@ void debug_print_stub(char *string) { } #endif -#ifdef USE_LIBCARTRESET - -struct cardTranslate { - int cartResetId; - int svmId; - char dldiId[5]; -}; - -cardTranslate cardReaderTable[] = { - {DEVICE_TYPE_M3SD, DEVICE_M3SD, "M3SD"}, - {DEVICE_TYPE_M3CF, DEVICE_M3CF, "M3CF"}, - {DEVICE_TYPE_MPCF, DEVICE_MPCF, "MPCF"}, - {DEVICE_TYPE_SCCF, DEVICE_SCCF, "SCCF"}, - {DEVICE_TYPE_SCSD, DEVICE_SCSD, "SCSD"}, - {DEVICE_TYPE_SCSD, DEVICE_SCSD, "SCLT"}, - {DEVICE_TYPE_NMMC, DEVICE_NMMC, "NMMC"}, -}; - -void reboot() { - int deviceType = -1; - - - if (disc_getDeviceId() == DEVICE_DLDI) { - - char id[6]; - disc_getDldiId(id); - - consolePrintf("DLDI Device ID: %s\n", id); - - for (int r = 0; r < ARRAYSIZE(cardReaderTable); r++) { - if (!stricmp(id, cardReaderTable[r].dldiId)) { - deviceType = cardReaderTable[r].cartResetId; - } - } - } else { - for (int r = 0; r < ARRAYSIZE(cardReaderTable); r++) { - if (disc_getDeviceId() == cardReaderTable[r].svmId) { - deviceType = cardReaderTable[r].cartResetId; - } - } - } - - - consolePrintf("Device number: %x\n", deviceType); - - if (deviceType == -1) { - IPC->reset = true; // Send message to ARM7 to turn power off - } else { - cartSetMenuMode(deviceType); - passmeloopEnter(); - } - - while (true); // Stop the program continuing beyond this point -} -#endif void powerOff() { while (keysHeld() != 0) { // Wait for all keys to be released. @@ -2955,12 +2871,10 @@ void powerOff() { while (true); } else { -#ifdef USE_LIBCARTRESET - reboot(); -#else IPC->reset = true; // Send message to ARM7 to turn power off - while (true); // Stop the program continuing beyond this point -#endif + while (true) { + // Stop the program from continuing beyond this point + } } } @@ -2981,7 +2895,7 @@ void dsExceptionHandler() { int offset = 8; - if ( currentMode == 0x17 ) { + if (currentMode == 0x17) { consolePrintf("\x1b[10Cdata abort!\n\n"); codeAddress = exceptionRegisters[15] - offset; if ( (codeAddress > 0x02000000 && codeAddress < 0x02400000) || @@ -3004,16 +2918,19 @@ void dsExceptionHandler() { int i; - for ( i=0; i < 8; i++ ) { + for (i = 0; i < 8; i++) { consolePrintf(" %s: %08X %s: %08X\n", registerNames[i], exceptionRegisters[i], registerNames[i+8],exceptionRegisters[i+8]); } - while(1); + + while(1) + ; // endles loop + u32 *stack = (u32 *)exceptionRegisters[13]; - for ( i=0; i<10; i++ ) { + for (i = 0; i < 10; i++) { consolePrintf("%08X %08X %08X\n", stack[i*3], stack[i*3+1], stack[(i*3)+2] ); } @@ -3264,12 +3181,6 @@ int main(void) { g_system = new OSystem_DS(); assert(g_system); -#ifdef GBA_SRAM_SAVE - if ((keysHeld() & KEY_L) && (keysHeld() & KEY_R)) { - formatSramOption(); - } -#endif - IPC->adpcm.semaphore = false; // printf("'%s'", Common::ConfigManager::kTransientDomain.c_str()); diff --git a/backends/platform/ds/arm9/source/dsmain.h b/backends/platform/ds/arm9/source/dsmain.h index beda592ba2..bd627fa620 100644 --- a/backends/platform/ds/arm9/source/dsmain.h +++ b/backends/platform/ds/arm9/source/dsmain.h @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -25,7 +28,6 @@ #include <nds.h> #include "osystem_ds.h" -#include "NDS/scummvm_ipc.h" namespace DS { @@ -38,7 +40,7 @@ enum controlType { CONT_FUTURE_WARS, CONT_AGI, CONT_GOBLINS, - CONT_NIPPON, + CONT_NIPPON }; struct gameListType { @@ -68,9 +70,6 @@ int leftHandedSwap(int keys); void setGameScreenSwap(bool enable); void setSensitivity(int sensitivity); -// Controls options -void setControls(char* gameName); - // Video void displayMode8Bit(); // Switch to 8-bit mode5 void displayMode16Bit(); // Switch to 16-bit mode5 @@ -79,8 +78,8 @@ void displayMode16Bit(); // Switch to 16-bit mode5 void displayMode16BitFlipBuffer(); // Get address of current back buffer -u16* get16BitBackBuffer(); -u16* get8BitBackBuffer(); +u16 * get16BitBackBuffer(); +u16 * get8BitBackBuffer(); s32 get8BitBackBufferStride(); u16* getScalerBuffer(); @@ -99,7 +98,7 @@ void doTimerCallback(); // Call callback function if required void doSoundCallback(); void startSound(int freq, int buffer); // Start sound hardware // Call function if sound buffers need more data -void playSound(const void* data, u32 length, bool loop, bool adpcm = false, int rate = 22050); // Start a sound +void playSound(const void *data, u32 length, bool loop, bool adpcm = false, int rate = 22050); // Start a sound void stopSound(int channel); int getSoundFrequency(); @@ -109,7 +108,7 @@ void VBlankHandler(); // Sam and Max Stuff void setGameID(int id); -void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor, int hotspotX, int hotspotY); +void setCursorIcon(const u8 *icon, uint w, uint h, byte keycolor, int hotspotX, int hotspotY); void setShowCursor(bool enable); void setMouseCursorVisible(bool visible); @@ -155,10 +154,10 @@ void fastRamReset(); void* fastRamAlloc(int size); void exitGame(); -gameListType* getCurrentGame(); -} +} // End of namespace DS + int cygprofile_getHBlanks(); diff --git a/backends/platform/ds/arm9/source/dsoptions.cpp b/backends/platform/ds/arm9/source/dsoptions.cpp index 9937e81e61..6721a4910a 100644 --- a/backends/platform/ds/arm9/source/dsoptions.cpp +++ b/backends/platform/ds/arm9/source/dsoptions.cpp @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -31,6 +34,8 @@ #include "touchkeyboard.h" #include "gui/PopUpWidget.h" +#include "common/translation.h" + #define ALLOW_CPU_SCALER namespace DS { @@ -51,27 +56,27 @@ static int confGetInt(Common::String key, int defaultVal) { DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(0, 0, 320 - 10, 230 - 40) { - new GUI::ButtonWidget(this, 10, 170, 72, 16, "Close", GUI::kCloseCmd, 'C'); - new GUI::ButtonWidget(this, 320 - 10 - 130, 170, 120, 16, "ScummVM Main Menu", 0x40000000, 'M'); + new GUI::ButtonWidget(this, 10, 170, 72, 16, _("~C~lose"), 0, GUI::kCloseCmd); + new GUI::ButtonWidget(this, 320 - 10 - 130, 170, 120, 16, _("ScummVM Main Menu"), 0, 0x40000000, 'M'); _tab = new GUI::TabWidget(this, 10, 5, 300, 230 - 20 - 40 - 20); _tab->addTab("Controls"); - _leftHandedCheckbox = new GUI::CheckboxWidget(_tab, 5, 5, 130, 20, "Left handed mode", 0, 'L'); - _indyFightCheckbox = new GUI::CheckboxWidget(_tab, 5, 20, 140, 20, "Indy fight controls", 0, 'I'); - _showCursorCheckbox = new GUI::CheckboxWidget(_tab, 150, 5, 130, 20, "Show mouse cursor", 0, 'T'); - _snapToBorderCheckbox = new GUI::CheckboxWidget(_tab, 150, 20, 130, 20, "Snap to edges", 0, 'T'); + _leftHandedCheckbox = new GUI::CheckboxWidget(_tab, 5, 5, 130, 20, _("~L~eft handed mode")); + _indyFightCheckbox = new GUI::CheckboxWidget(_tab, 5, 20, 140, 20, _("~I~ndy fight controls")); + _showCursorCheckbox = new GUI::CheckboxWidget(_tab, 150, 5, 130, 20, _("Show mouse cursor"), 0, 0, 'T'); + _snapToBorderCheckbox = new GUI::CheckboxWidget(_tab, 150, 20, 130, 20, _("Snap to edges"), 0, 0, 'T'); - new GUI::StaticTextWidget(_tab, 20, 35, 100, 15, "Touch X Offset", Graphics::kTextAlignLeft); - _touchX = new GUI::SliderWidget(_tab, 130, 35, 130, 12, 1); + new GUI::StaticTextWidget(_tab, 20, 35, 100, 15, _("Touch X Offset"), Graphics::kTextAlignLeft); + _touchX = new GUI::SliderWidget(_tab, 130, 35, 130, 12, "TODO: Add tooltip", 1); _touchX->setMinValue(-8); _touchX->setMaxValue(+8); _touchX->setValue(0); _touchX->setFlags(GUI::WIDGET_CLEARBG); - new GUI::StaticTextWidget(_tab, 20, 50, 100, 15, "Touch Y Offset", Graphics::kTextAlignLeft); - _touchY = new GUI::SliderWidget(_tab, 130, 50, 130, 12, 2); + new GUI::StaticTextWidget(_tab, 20, 50, 100, 15, _("Touch Y Offset"), Graphics::kTextAlignLeft); + _touchY = new GUI::SliderWidget(_tab, 130, 50, 130, 12, "TODO: Add tooltip", 2); _touchY->setMinValue(-8); _touchY->setMaxValue(+8); _touchY->setValue(0); @@ -82,11 +87,11 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(0, 0, 320 - 10, 230 - 40) { new GUI::StaticTextWidget(_tab, 130 - 20, 65, 20, 15, "-8", Graphics::kTextAlignCenter); - _touchPadStyle = new GUI::CheckboxWidget(_tab, 5, 80, 270, 20, "Use laptop trackpad-style cursor control", 0x20000001, 'T'); - _screenTaps = new GUI::CheckboxWidget(_tab, 5, 95, 285, 20, "Tap for left click, double tap right click", 0x20000002, 'T'); + _touchPadStyle = new GUI::CheckboxWidget(_tab, 5, 80, 270, 20, _("Use laptop trackpad-style cursor control"), 0, 0x20000001, 'T'); + _screenTaps = new GUI::CheckboxWidget(_tab, 5, 95, 285, 20, _("Tap for left click, double tap right click"), 0, 0x20000002, 'T'); - _sensitivityLabel = new GUI::StaticTextWidget(_tab, 20, 110, 110, 15, "Sensitivity", Graphics::kTextAlignLeft); - _sensitivity = new GUI::SliderWidget(_tab, 130, 110, 130, 12, 1); + _sensitivityLabel = new GUI::StaticTextWidget(_tab, 20, 110, 110, 15, _("Sensitivity"), Graphics::kTextAlignLeft); + _sensitivity = new GUI::SliderWidget(_tab, 130, 110, 130, 12, "TODO: Add tooltip", 1); _sensitivity->setMinValue(4); _sensitivity->setMaxValue(16); _sensitivity->setValue(8); @@ -94,20 +99,20 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(0, 0, 320 - 10, 230 - 40) { _tab->addTab("Graphics"); - new GUI::StaticTextWidget(_tab, 5, 67, 180, 15, "Initial top screen scale:", Graphics::kTextAlignLeft); + new GUI::StaticTextWidget(_tab, 5, 67, 180, 15, _("Initial top screen scale:"), Graphics::kTextAlignLeft); - _100PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 82, 80, 20, "100%", 0x30000001, 'T'); - _150PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 97, 80, 20, "150%", 0x30000002, 'T'); - _200PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 112, 80, 20, "200%", 0x30000003, 'T'); + _100PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 82, 80, 20, "100%", "TODO: Add tooltip", 0x30000001, 'T'); + _150PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 97, 80, 20, "150%", "TODO: Add tooltip", 0x30000002, 'T'); + _200PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 112, 80, 20, "200%", "TODO: Add tooltip", 0x30000003, 'T'); - new GUI::StaticTextWidget(_tab, 5, 5, 180, 15, "Main screen scaling:", Graphics::kTextAlignLeft); + new GUI::StaticTextWidget(_tab, 5, 5, 180, 15, _("Main screen scaling:"), Graphics::kTextAlignLeft); - _hardScaler = new GUI::CheckboxWidget(_tab, 5, 20, 270, 20, "Hardware scale (fast, but low quality)", 0x10000001, 'T'); - _cpuScaler = new GUI::CheckboxWidget(_tab, 5, 35, 270, 20, "Software scale (good quality, but slower)", 0x10000002, 'S'); - _unscaledCheckbox = new GUI::CheckboxWidget(_tab, 5, 50, 270, 20, "Unscaled (you must scroll left and right)", 0x10000003, 'S'); + _hardScaler = new GUI::CheckboxWidget(_tab, 5, 20, 270, 20, _("Hardware scale (fast, but low quality)"), 0, 0x10000001, 'T'); + _cpuScaler = new GUI::CheckboxWidget(_tab, 5, 35, 270, 20, _("Software scale (good quality, but slower)"), 0, 0x10000002, 'S'); + _unscaledCheckbox = new GUI::CheckboxWidget(_tab, 5, 50, 270, 20, _("Unscaled (you must scroll left and right)"), 0, 0x10000003, 'S'); - new GUI::StaticTextWidget(_tab, 5, 125, 110, 15, "Brightness:", Graphics::kTextAlignLeft); - _gammaCorrection = new GUI::SliderWidget(_tab, 130, 120, 130, 12, 1); + new GUI::StaticTextWidget(_tab, 5, 125, 110, 15, _("Brightness:"), Graphics::kTextAlignLeft); + _gammaCorrection = new GUI::SliderWidget(_tab, 130, 120, 130, 12, "TODO: Add tooltip", 1); _gammaCorrection->setMinValue(0); _gammaCorrection->setMaxValue(8); _gammaCorrection->setValue(0); @@ -116,24 +121,18 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(0, 0, 320 - 10, 230 - 40) { _tab->addTab("General"); - _highQualityAudioCheckbox = new GUI::CheckboxWidget(_tab, 5, 5, 250, 20, "High quality audio (slower) (reboot)", 0, 'T'); - _disablePowerOff = new GUI::CheckboxWidget(_tab, 5, 20, 200, 20, "Disable power off", 0, 'T'); + _highQualityAudioCheckbox = new GUI::CheckboxWidget(_tab, 5, 5, 250, 20, _("High quality audio (slower) (reboot)"), 0, 0, 'T'); + _disablePowerOff = new GUI::CheckboxWidget(_tab, 5, 20, 200, 20, _("Disable power off"), 0, 0, 'T'); _tab->setActiveTab(0); _radioButtonMode = false; -#ifdef DS_SCUMM_BUILD - if (!DS::isGBAMPAvailable()) { -// addButton(this, 100, 140, "Delete Save", 'dels', 'D'); - } -#endif - // new GUI::StaticTextWidget(this, 90, 10, 130, 15, "ScummVM DS Options", Graphics::kTextAlignCenter); //#ifdef ALLOW_CPU_SCALER -// _cpuScaler = new GUI::CheckboxWidget(this, 160, 115, 90, 20, "CPU scaler", 0, 'T'); +// _cpuScaler = new GUI::CheckboxWidget(this, 160, 115, 90, 20, "CPU scaler", 0, 0, 'T'); //#endif @@ -364,7 +363,7 @@ void showOptionsDialog() { DS::displayMode16Bit(); - DSOptionsDialog* d = new DSOptionsDialog(); + DSOptionsDialog *d = new DSOptionsDialog(); d->runModal(); delete d; @@ -418,7 +417,7 @@ void setOptions() { DS::setTrackPadStyleEnable(enable); - if ((enable) and (firstLoad)) { + if (enable && firstLoad) { // If we've just booted up, want to swap screens when trackpad mode is in use // but not every time we enter the options dialog. DS::setGameScreenSwap(true); @@ -436,4 +435,5 @@ void setOptions() { firstLoad = false; } -} +} // End of namespace DS + diff --git a/backends/platform/ds/arm9/source/dsoptions.h b/backends/platform/ds/arm9/source/dsoptions.h index 4b3ac36d45..1bdc7c1f27 100644 --- a/backends/platform/ds/arm9/source/dsoptions.h +++ b/backends/platform/ds/arm9/source/dsoptions.h @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -46,30 +49,30 @@ protected: virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); void updateConfigManager(); - GUI::TabWidget* _tab; + GUI::TabWidget *_tab; - GUI::StaticTextWidget* _sensitivityLabel; + GUI::StaticTextWidget *_sensitivityLabel; - GUI::SliderWidget* _touchX; - GUI::SliderWidget* _touchY; - GUI::SliderWidget* _sensitivity; - GUI::SliderWidget* _gammaCorrection; - GUI::CheckboxWidget* _leftHandedCheckbox; - GUI::CheckboxWidget* _unscaledCheckbox; - GUI::CheckboxWidget* _100PercentCheckbox; - GUI::CheckboxWidget* _150PercentCheckbox; - GUI::CheckboxWidget* _200PercentCheckbox; - GUI::CheckboxWidget* _indyFightCheckbox; - GUI::CheckboxWidget* _highQualityAudioCheckbox; - GUI::CheckboxWidget* _disablePowerOff; - GUI::CheckboxWidget* _showCursorCheckbox; - GUI::CheckboxWidget* _snapToBorderCheckbox; + GUI::SliderWidget *_touchX; + GUI::SliderWidget *_touchY; + GUI::SliderWidget *_sensitivity; + GUI::SliderWidget *_gammaCorrection; + GUI::CheckboxWidget *_leftHandedCheckbox; + GUI::CheckboxWidget *_unscaledCheckbox; + GUI::CheckboxWidget *_100PercentCheckbox; + GUI::CheckboxWidget *_150PercentCheckbox; + GUI::CheckboxWidget *_200PercentCheckbox; + GUI::CheckboxWidget *_indyFightCheckbox; + GUI::CheckboxWidget *_highQualityAudioCheckbox; + GUI::CheckboxWidget *_disablePowerOff; + GUI::CheckboxWidget *_showCursorCheckbox; + GUI::CheckboxWidget *_snapToBorderCheckbox; - GUI::CheckboxWidget* _hardScaler; - GUI::CheckboxWidget* _cpuScaler; + GUI::CheckboxWidget *_hardScaler; + GUI::CheckboxWidget *_cpuScaler; - GUI::CheckboxWidget* _touchPadStyle; - GUI::CheckboxWidget* _screenTaps; + GUI::CheckboxWidget *_touchPadStyle; + GUI::CheckboxWidget *_screenTaps; bool _radioButtonMode; @@ -78,6 +81,6 @@ protected: extern void showOptionsDialog(); extern void setOptions(); -} +} // End of namespace DS #endif diff --git a/backends/platform/ds/arm9/source/elf32.h b/backends/platform/ds/arm9/source/elf32.h deleted file mode 100644 index d72b71664d..0000000000 --- a/backends/platform/ds/arm9/source/elf32.h +++ /dev/null @@ -1,196 +0,0 @@ -/* 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. - * - * 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$ - * - */ - -#ifndef BACKENDS_ELF_H -#define BACKENDS_ELF_H - -/* ELF stuff */ - -typedef unsigned short Elf32_Half, Elf32_Section; -typedef unsigned int Elf32_Word, Elf32_Addr, Elf32_Off; -typedef signed int Elf32_Sword; -typedef Elf32_Half Elf32_Versym; - -#define EI_NIDENT (16) -#define SELFMAG 6 - -/* ELF File format structures. Look up ELF structure for more details */ - -// ELF header (contains info about the file) -typedef struct { - unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ - Elf32_Half e_type; /* Object file type */ - Elf32_Half e_machine; /* Architecture */ - Elf32_Word e_version; /* Object file version */ - Elf32_Addr e_entry; /* Entry point virtual address */ - Elf32_Off e_phoff; /* Program header table file offset */ - Elf32_Off e_shoff; /* Section header table file offset */ - Elf32_Word e_flags; /* Processor-specific flags */ - Elf32_Half e_ehsize; /* ELF header size in bytes */ - Elf32_Half e_phentsize; /* Program header table entry size */ - Elf32_Half e_phnum; /* Program header table entry count */ - Elf32_Half e_shentsize; /* Section header table entry size */ - Elf32_Half e_shnum; /* Section header table entry count */ - Elf32_Half e_shstrndx; /* Section header string table index */ -} Elf32_Ehdr; - -// Should be in e_ident -#define ELFMAG "\177ELF\1\1" /* ELF Magic number */ - -// e_type values -#define ET_NONE 0 /* no file type */ -#define ET_REL 1 /* relocatable */ -#define ET_EXEC 2 /* executable */ -#define ET_DYN 3 /* shared object */ -#define ET_CORE 4 /* core file */ - -// e_machine values -#define EM_ARM 40 - -// Program header (contains info about segment) -typedef struct { - Elf32_Word p_type; /* Segment type */ - Elf32_Off p_offset; /* Segment file offset */ - Elf32_Addr p_vaddr; /* Segment virtual address */ - Elf32_Addr p_paddr; /* Segment physical address */ - Elf32_Word p_filesz; /* Segment size in file */ - Elf32_Word p_memsz; /* Segment size in memory */ - Elf32_Word p_flags; /* Segment flags */ - Elf32_Word p_align; /* Segment alignment */ -} Elf32_Phdr; - -// p_type values -#define PT_NULL 0 /* ignored */ -#define PT_LOAD 1 /* loadable segment */ -#define PT_DYNAMIC 2 /* dynamic linking info */ -#define PT_INTERP 3 /* info about interpreter */ -#define PT_NOTE 4 /* note segment */ -#define PT_SHLIB 5 /* reserved */ -#define PT_PHDR 6 /* Program header table */ -#define PT_ARM_ARCHEXT 0x70000000 /* Platform architecture compatibility information */ -#define PT_ARM_EXIDX 0x70000001 /* Exception unwind tables */ - -// p_flags value -#define PF_X 1 /* execute */ -#define PF_W 2 /* write */ -#define PF_R 4 /* read */ - -// Section header (contains info about section) -typedef struct { - Elf32_Word sh_name; /* Section name (string tbl index) */ - Elf32_Word sh_type; /* Section type */ - Elf32_Word sh_flags; /* Section flags */ - Elf32_Addr sh_addr; /* Section virtual addr at execution */ - Elf32_Off sh_offset; /* Section file offset */ - Elf32_Word sh_size; /* Section size in bytes */ - Elf32_Word sh_link; /* Link to another section */ - Elf32_Word sh_info; /* Additional section information */ - Elf32_Word sh_addralign; /* Section alignment */ - Elf32_Word sh_entsize; /* Entry size if section holds table */ -} Elf32_Shdr; - -// sh_type values -#define SHT_NULL 0 /* Inactive section */ -#define SHT_PROGBITS 1 /* Proprietary */ -#define SHT_SYMTAB 2 /* Symbol table */ -#define SHT_STRTAB 3 /* String table */ -#define SHT_RELA 4 /* Relocation entries with addend */ -#define SHT_HASH 5 /* Symbol hash table */ -#define SHT_DYNAMIC 6 /* Info for dynamic linking */ -#define SHT_NOTE 7 /* Note section */ -#define SHT_NOBITS 8 /* Occupies no space */ -#define SHT_REL 9 /* Relocation entries without addend */ -#define SHT_SHLIB 10 /* Reserved */ -#define SHT_DYNSYM 11 /* Minimal set of dynamic linking symbols */ -#define SHT_ARM_EXIDX 0x70000001 /* Exception Index table */ -#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking pre-emption map */ -#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility attributes */ - -// sh_flags values -#define SHF_WRITE 0 /* writable section */ -#define SHF_ALLOC 2 /* section occupies memory */ -#define SHF_EXECINSTR 4 /* machine instructions */ - -// Symbol entry (contain info about a symbol) -typedef struct { - Elf32_Word st_name; /* Symbol name (string tbl index) */ - Elf32_Addr st_value; /* Symbol value */ - Elf32_Word st_size; /* Symbol size */ - unsigned char st_info; /* Symbol type and binding */ - unsigned char st_other; /* Symbol visibility */ - Elf32_Section st_shndx; /* Section index */ -} Elf32_Sym; - -// Extract from the st_info -#define SYM_TYPE(x) ((x)&0xF) -#define SYM_BIND(x) ((x)>>4) - -// Symbol binding values from st_info -#define STB_LOCAL 0 /* Symbol not visible outside object */ -#define STB_GLOBAL 1 /* Symbol visible to all object files */ -#define STB_WEAK 2 /* Similar to STB_GLOBAL */ - -// Symbol type values from st_info -#define STT_NOTYPE 0 /* Not specified */ -#define STT_OBJECT 1 /* Data object e.g. variable */ -#define STT_FUNC 2 /* Function */ -#define STT_SECTION 3 /* Section */ -#define STT_FILE 4 /* Source file associated with object file */ - -// Special section header index values from st_shndex -#define SHN_UNDEF 0 -#define SHN_LOPROC 0xFF00 /* Extended values */ -#define SHN_ABS 0xFFF1 /* Absolute value: don't relocate */ -#define SHN_COMMON 0xFFF2 /* Common block. Not allocated yet */ -#define SHN_HIPROC 0xFF1F -#define SHN_HIRESERVE 0xFFFF - -// Relocation entry (info about how to relocate) -typedef struct { - Elf32_Addr r_offset; /* Address */ - Elf32_Word r_info; /* Relocation type and symbol index */ -} Elf32_Rel; - -typedef struct -{ - Elf32_Addr r_offset; /* Address */ - Elf32_Word r_info; /* Relocation type and symbol index */ - Elf32_Sword r_addend; /* Addend */ -} Elf32_Rela; - -// Access macros for the relocation info -#define REL_TYPE(x) ((unsigned char) (x)) /* Extract relocation type */ -#define REL_INDEX(x) ((x)>>8) /* Extract relocation index into symbol table */ - -// ARM relocation types -#define R_ARM_NONE 0 -#define R_ARM_ABS32 2 -#define R_ARM_THM_CALL 10 -#define R_ARM_CALL 28 -#define R_ARM_JUMP24 29 -#define R_ARM_TARGET1 38 -#define R_ARM_V4BX 40 - -#endif /* BACKENDS_ELF_H */ 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 b70d9e7b99..07affd8839 100644 --- a/backends/platform/ds/arm9/source/fat/gba_nds_fat.c +++ b/backends/platform/ds/arm9/source/fat/gba_nds_fat.c @@ -294,9 +294,9 @@ u16 getRTCtoFileTime (void) { #ifdef NDS return ( - ( ( (IPC->rtc_hours > 11 ? IPC->rtc_hours - 40 : IPC->rtc_hours) & 0x1F) << 11) | - ( (IPC->rtc_minutes & 0x3F) << 5) | - ( (IPC->rtc_seconds >> 1) & 0x1F) ); + ( ( (IPC->rtc.hours > 11 ? IPC->rtc.hours - 40 : IPC->rtc.hours) & 0x1F) << 11) | + ( (IPC->rtc.minutes & 0x3F) << 5) | + ( (IPC->rtc.seconds >> 1) & 0x1F) ); #else return 0; #endif @@ -306,9 +306,9 @@ u16 getRTCtoFileDate (void) { #ifdef NDS return ( - ( ((IPC->rtc_year + 20) & 0x7F) <<9) | - ( (IPC->rtc_month & 0xF) << 5) | - (IPC->rtc_day & 0x1F) ); + ( ((IPC->rtc.year + 20) & 0x7F) <<9) | + ( (IPC->rtc.month & 0xF) << 5) | + (IPC->rtc.day & 0x1F) ); #else return 0; #endif diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp index 820e569555..d0fb8fff3b 100644 --- a/backends/platform/ds/arm9/source/gbampsave.cpp +++ b/backends/platform/ds/arm9/source/gbampsave.cpp @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -29,7 +32,7 @@ // GBAMP Save File ///////////////////////// -GBAMPSaveFile::GBAMPSaveFile(char* name, bool saveOrLoad) { +GBAMPSaveFile::GBAMPSaveFile(char *name, bool saveOrLoad) { handle = DS::std_fopen(name, saveOrLoad? "w": "r"); // consolePrintf("%s handle is %d\n", name, handle); // consolePrintf("Created %s\n", name); @@ -44,10 +47,10 @@ GBAMPSaveFile::~GBAMPSaveFile() { // consolePrintf("Closed file\n"); } -uint32 GBAMPSaveFile::read(void *buf, uint32 size) { - saveSize += size; -// consolePrintf("Read %d %d ", size, saveSize); - return DS::std_fread(buf, 1, size, handle); +uint32 GBAMPSaveFile::read(void *buf, uint32 length) { + saveSize += length; +// consolePrintf("Read %d %d ", length, saveSize); + return DS::std_fread(buf, 1, length, handle); } bool GBAMPSaveFile::eos() const { @@ -74,27 +77,27 @@ int32 GBAMPSaveFile::pos() const { int32 GBAMPSaveFile::size() const { int position = pos(); DS::std_fseek(handle, 0, SEEK_END); - int size = DS::std_ftell(handle); + int length = DS::std_ftell(handle); DS::std_fseek(handle, position, SEEK_SET); - return size; + return length; } -bool GBAMPSaveFile::seek(int32 pos, int whence) { - return DS::std_fseek(handle, pos, whence) == 0; +bool GBAMPSaveFile::seek(int32 newPos, int whence) { + return DS::std_fseek(handle, newPos, whence) == 0; } -uint32 GBAMPSaveFile::write(const void *buf, uint32 size) { - if (bufferPos + size > SAVE_BUFFER_SIZE) { +uint32 GBAMPSaveFile::write(const void *buf, uint32 length) { + if (bufferPos + length > SAVE_BUFFER_SIZE) { flushSaveBuffer(); - saveSize += size; -// consolePrintf("Writing %d bytes from %x", size, buf); -// DS::std_fwrite(buf, 1, size, handle); + saveSize += length; +// consolePrintf("Writing %d bytes from %x", length, buf); +// DS::std_fwrite(buf, 1, length, handle); - memcpy(buffer + bufferPos, buf, size); - bufferPos += size; + memcpy(buffer + bufferPos, buf, length); + bufferPos += length; - saveSize += size; + saveSize += length; /* int pos = 0; @@ -104,31 +107,31 @@ uint32 GBAMPSaveFile::write(const void *buf, uint32 size) { bufferPos = 512; pos += rest; flushSaveBuffer(); - size -= rest; + length -= rest; // consolePrintf("First section: %d\n", rest); - while (size >= 512) { + while (length >= 512) { DS::std_fwrite(((char *) (buf)) + pos, 1, 512, handle); - size -= 512; + length -= 512; pos += 512; -// consolePrintf("Full chunk, %d left ", size); +// consolePrintf("Full chunk, %d left ", length); } bufferPos = 0; - memcpy(buffer + bufferPos, ((char *) (buf)) + pos, size); - bufferPos += size; + memcpy(buffer + bufferPos, ((char *) (buf)) + pos, length); + bufferPos += length; // consolePrintf("%d left in buffer ", bufferPos);*/ } else { - memcpy(buffer + bufferPos, buf, size); - bufferPos += size; + memcpy(buffer + bufferPos, buf, length); + bufferPos += length; - saveSize += size; + saveSize += length; } -// if ((size > 100) || (size <= 0)) consolePrintf("Write %d bytes\n", size); - return size; +// if ((length > 100) || (length <= 0)) consolePrintf("Write %d bytes\n", length); + return length; } @@ -196,7 +199,7 @@ Common::StringArray GBAMPSaveFileManager::listSavefiles(const Common::String &pa // consolePrintf("Real cwd:%d\n", realName); - char* p = realName; + char *p = realName; while (*p) { if (*p == '\\') *p = '/'; p++; diff --git a/backends/platform/ds/arm9/source/gbampsave.h b/backends/platform/ds/arm9/source/gbampsave.h index bc4fdaa1a4..ad929236cd 100644 --- a/backends/platform/ds/arm9/source/gbampsave.h +++ b/backends/platform/ds/arm9/source/gbampsave.h @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -24,19 +27,20 @@ #define _GBAMPSAVE_H_ #include "common/system.h" +#include "common/savefile.h" #include "backends/fs/ds/ds-fs.h" #define SAVE_BUFFER_SIZE 100000 class GBAMPSaveFile : public Common::InSaveFile, public Common::OutSaveFile { - DS::fileHandle* handle; + DS::fileHandle *handle; char buffer[SAVE_BUFFER_SIZE]; int bufferPos; int saveSize; int flushed; public: - GBAMPSaveFile(char* name, bool saveOrLoad); + GBAMPSaveFile(char *name, bool saveOrLoad); virtual ~GBAMPSaveFile(); virtual uint32 read(void *buf, uint32 size); @@ -62,12 +66,12 @@ public: GBAMPSaveFileManager(); ~GBAMPSaveFileManager(); -// static GBAMPSaveFileManager* instance() { return instancePtr; } +// static GBAMPSaveFileManager *instance() { return instancePtr; } GBAMPSaveFile *openSavefile(const char *filename, bool saveOrLoad); - virtual Common::OutSaveFile* openForSaving(const Common::String &filename) { return openSavefile(filename.c_str(), true); } - virtual Common::InSaveFile* openForLoading(const Common::String &filename) { return openSavefile(filename.c_str(), false); } + virtual Common::OutSaveFile *openForSaving(const Common::String &filename) { return openSavefile(filename.c_str(), true); } + virtual Common::InSaveFile *openForLoading(const Common::String &filename) { return openSavefile(filename.c_str(), false); } virtual bool removeSavefile(const Common::String &filename) { return false; } // TODO: Implement this virtual Common::StringArray listSavefiles(const Common::String &pattern); diff --git a/backends/platform/ds/arm9/source/keys.cpp b/backends/platform/ds/arm9/source/keys.cpp index 63fae866e5..2f8497ab19 100644 --- a/backends/platform/ds/arm9/source/keys.cpp +++ b/backends/platform/ds/arm9/source/keys.cpp @@ -74,7 +74,6 @@ #include <nds/system.h> #include <nds/arm9/input.h> -//------------------------------------------------------------------------------ #define KEYS_CUR (( ((~REG_KEYINPUT)&0x3ff) | (((~IPC->buttons)&3)<<10) | (((~IPC->buttons)<<6) & (KEY_TOUCH|KEY_LID) ))^KEY_LID) @@ -89,63 +88,50 @@ static u8 delay = 60, repeat = 30, count = 60; static uint16 oldx = 0; static uint16 oldy = 0; -//------------------------------------------------------------------------------ void scanKeys(void) { -//------------------------------------------------------------------------------ keysold = keys; keys = KEYS_CUR; oldx = IPC->touchXpx; oldy = IPC->touchYpx; - if ( delay != 0 ) { - if ( keys != keysold ) { - count = delay ; - keysrepeat = keysDown() ; + if (delay != 0) { + if (keys != keysold) { + count = delay; + keysrepeat = keysDown(); } count--; - if ( count == 0 ) { + if (count == 0) { count = repeat; keysrepeat = keys; } } } -//------------------------------------------------------------------------------ uint32 keysHeld(void) { -//------------------------------------------------------------------------------ return keys; } -//------------------------------------------------------------------------------ uint32 keysDown(void) { -//------------------------------------------------------------------------------ return (keys ^ keysold) & keys; } -//------------------------------------------------------------------------------ uint32 keysDownRepeat(void) { -//------------------------------------------------------------------------------ uint32 tmp = keysrepeat; - keysrepeat = 0; - return tmp; } -//------------------------------------------------------------------------------ void keysSetRepeat( u8 setDelay, u8 setRepeat ) { -//------------------------------------------------------------------------------ - delay = setDelay ; - repeat = setRepeat ; - count = delay ; - keysrepeat = 0 ; + delay = setDelay; + repeat = setRepeat; + count = delay; + keysrepeat = 0; } -//------------------------------------------------------------------------------ uint32 keysUp(void) { -//------------------------------------------------------------------------------ return (keys ^ keysold) & (~keys); } -} // namespace ds +} // End of namespace DS + diff --git a/backends/platform/ds/arm9/source/keys.h b/backends/platform/ds/arm9/source/keys.h index e0f28a12cf..8d08014232 100644 --- a/backends/platform/ds/arm9/source/keys.h +++ b/backends/platform/ds/arm9/source/keys.h @@ -1,4 +1,27 @@ +/* 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. + * + * 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$ + * + */ namespace DS { @@ -7,7 +30,7 @@ void scanKeys(void); uint32 keysHeld(void); uint32 keysDown(void); uint32 keysDownRepeat(void); -void keysSetRepeat( u8 setDelay, u8 setRepeat ); +void keysSetRepeat(u8 setDelay, u8 setRepeat); uint32 keysUp(void); -} +} // End of namespace DS diff --git a/backends/platform/ds/arm9/source/libcartreset/cartreset.c b/backends/platform/ds/arm9/source/libcartreset/cartreset.c deleted file mode 100644 index 6fb906b86d..0000000000 --- a/backends/platform/ds/arm9/source/libcartreset/cartreset.c +++ /dev/null @@ -1,107 +0,0 @@ -/********************************** - Copyright (C) Rick Wong (Lick) - http://licklick.wordpress.com/ -***********************************/ -#include <cartreset_nolibfat.h> - - -#ifdef ARM9 - -bool cartSetMenuMode(u32 _deviceType) -{ - *(vu16*)(0x04000204) &= ~0x0880; //sysSetBusOwners(true, true); - u32 deviceType = _deviceType; - - *((vu32*)0x027FFFF8) = 0x080000C0; // ARM7 reset address - - if(deviceType == DEVICE_TYPE_EFA2) - { - *(u16 *)0x9FE0000 = 0xD200; - *(u16 *)0x8000000 = 0x1500; - *(u16 *)0x8020000 = 0xD200; - *(u16 *)0x8040000 = 0x1500; - *(u16 *)0x9880000 = 1 << 15; - *(u16 *)0x9FC0000 = 0x1500; - return true; - } - else if(deviceType == DEVICE_TYPE_MPCF) - { - return true; - } - else if(deviceType == DEVICE_TYPE_EZSD) - { - return true; - } - else if(deviceType == DEVICE_TYPE_M3CF || deviceType == DEVICE_TYPE_M3SD) - { - u32 mode = 0x00400004; - vu16 tmp; - tmp = *(vu16*)(0x08E00002); - tmp = *(vu16*)(0x0800000E); - tmp = *(vu16*)(0x08801FFC); - tmp = *(vu16*)(0x0800104A); - tmp = *(vu16*)(0x08800612); - tmp = *(vu16*)(0x08000000); - tmp = *(vu16*)(0x08801B66); - tmp = *(vu16*)(0x08000000 + (mode << 1)); - tmp = *(vu16*)(0x0800080E); - tmp = *(vu16*)(0x08000000); - - tmp = *(vu16*)(0x080001E4); - tmp = *(vu16*)(0x080001E4); - tmp = *(vu16*)(0x08000188); - tmp = *(vu16*)(0x08000188); - return true; - } - else if(deviceType == DEVICE_TYPE_SCCF || deviceType == DEVICE_TYPE_SCSD) - { - *(vu16*)0x09FFFFFE = 0xA55A; - *(vu16*)0x09FFFFFE = 0xA55A; - *(vu16*)0x09FFFFFE = 0; - *(vu16*)0x09FFFFFE = 0; - *((vu32*)0x027FFFF8) = 0x08000000; // Special ARM7 reset address - return true; - } - - return false; -} - - - -void passmeloopEnter() -{ - *(vu16*)(0x04000208) = 0; //REG_IME = IME_DISABLE; - *(vu16*)(0x04000204) |= 0x0880; //sysSetBusOwners(false, false); - *((vu32*)0x027FFFFC) = 0; - *((vu32*)0x027FFE04) = (u32)0xE59FF018; - *((vu32*)0x027FFE24) = (u32)0x027FFE04; - asm("swi 0x00"); //swiSoftReset(); - asm("bx lr"); -} - -#endif - - -#ifdef ARM7 - -bool passmeloopQuery() -{ - if(*((vu32*)0x027FFE24) == (u32)0x027FFE04) - return true; - return false; -} - - - -void cartExecute() -{ - *(vu16*)(0x04000208) = 0; //REG_IME = IME_DISABLE; - *((vu32*)0x027FFE34) = *((vu32*)0x027FFFF8); - asm("swi 0x00"); //swiSoftReset(); - asm("bx lr"); -} - -#endif - - - diff --git a/backends/platform/ds/arm9/source/libcartreset/cartreset_nolibfat.h b/backends/platform/ds/arm9/source/libcartreset/cartreset_nolibfat.h deleted file mode 100644 index ddc4b1d4c2..0000000000 --- a/backends/platform/ds/arm9/source/libcartreset/cartreset_nolibfat.h +++ /dev/null @@ -1,57 +0,0 @@ -/********************************** - Copyright (C) Rick Wong (Lick) - http://licklick.wordpress.com/ -***********************************/ -#ifndef CARTRESET_H -#define CARTRESET_H - -//#include <fat.h> -#include <nds.h> - - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef ARM9 -// Auto detect: -#define DEVICE_TYPE_AUTO 0x00000000 // doesn't work in libcartreset "nolibfat" version - -// Not supported: -#define DEVICE_TYPE_FCSR 0x52534346 -#define DEVICE_TYPE_MMCF 0x46434D4D -#define DEVICE_TYPE_NJSD 0x44534A4E -#define DEVICE_TYPE_NMMC 0x434D4D4E - -// Supported: -#define DEVICE_TYPE_EFA2 0x32414645 -#define DEVICE_TYPE_MPCF 0x4643504D -#define DEVICE_TYPE_M3CF 0x4643334D -#define DEVICE_TYPE_M3SD 0x4453334D -#define DEVICE_TYPE_SCCF 0x46434353 -#define DEVICE_TYPE_SCSD 0x44534353 - -// Supported, but libfat doesn't detect the device: -#define DEVICE_TYPE_EZSD 0x44535A45 - - -bool cartSetMenuMode(u32 _deviceType); -void passmeloopEnter(); - -#endif - - -#ifdef ARM7 - -bool passmeloopQuery(); -void cartExecute(); - -#endif - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 691fb2ec7a..c4ff241de0 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -66,9 +66,14 @@ #define DEFAULT_CONFIG_FILE "scummvmj.ini" #elif defined(DS_BUILD_K) #define DEFAULT_CONFIG_FILE "scummvmk.ini" +#else + // Use the "scummvm.ini" as config file if no build was specified. This + // currently only happens with builds made using the regular ScummVM build + // system (as opposed to the nds specific build system). +#define DEFAULT_CONFIG_FILE "scummvm.ini" #endif -OSystem_DS* OSystem_DS::_instance = NULL; +OSystem_DS *OSystem_DS::_instance = NULL; OSystem_DS::OSystem_DS() : eventNum(0), lastPenFrame(0), queuePos(0), _mixer(NULL), _timer(NULL), _frameBufferExists(false), @@ -128,7 +133,7 @@ bool OSystem_DS::getFeatureState(Feature f) { return false; } -const OSystem::GraphicsMode* OSystem_DS::getSupportedGraphicsModes() const { +const OSystem::GraphicsMode *OSystem_DS::getSupportedGraphicsModes() const { return s_supportedGraphicsModes; } @@ -203,8 +208,7 @@ void OSystem_DS::setPalette(const byte *colors, uint start, uint num) { } } -void OSystem_DS::restoreHardwarePalette() -{ +void OSystem_DS::restoreHardwarePalette() { // Set the hardware palette up based on the stored palette for (int r = 0; r < 255; r++) { @@ -238,13 +242,13 @@ void OSystem_DS::setCursorPalette(const byte *colors, uint start, uint num) { refreshCursor(); } -bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) { +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 - const u16* image = (const u16 *) DS::get8BitBackBuffer(); + const u16 *image = (const u16 *) DS::get8BitBackBuffer(); for (int y = 0; y < DS::getGameHeight(); y++) { DC_FlushRange(image + (y << 8), DS::getGameWidth()); for (int x = 0; x < DS::getGameWidth() >> 1; x++) { @@ -277,9 +281,9 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int // consolePrintf("CopyRectToScreen %d\n", w * h); - u16* bg; + u16 *bg; s32 stride; - u16* bgSub = (u16 *)BG_GFX_SUB; + u16 *bgSub = (u16 *)BG_GFX_SUB; // The DS video RAM doesn't support 8-bit writes because Nintendo wanted // to save a few pennies/euro cents on the hardware. @@ -304,14 +308,14 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int // the keyboard image uses the same VRAM addresses. for (int dy = y; dy < y + h; dy++) { - u8* dest = ((u8 *) (bg)) + (dy * stride) + x; - u8* src = (u8 *) buf + (pitch * by); + u8 *dest = ((u8 *) (bg)) + (dy * stride) + x; + const u8 *src = (const u8 *) buf + (pitch * by); u32 dx; u32 pixelsLeft = w; - if (MISALIGNED16(dest)) { + if (MISALIGNED16(dest)) { // Read modify write dest--; @@ -326,9 +330,9 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int } // We can now assume dest is aligned - u16* dest16 = (u16 *) dest; + u16 *dest16 = (u16 *) dest; - for (dx = 0; dx < pixelsLeft; dx+=2) { + for (dx = 0; dx < pixelsLeft; dx+=2) { u16 mix; mix = *src + (*(src + 1) << 8); @@ -355,15 +359,15 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int // When they keyboard is not on screen, update both vram copies for (int dy = y; dy < y + h; dy++) { - u8* dest = ((u8 *) (bg)) + (dy * stride) + x; - u8* destSub = ((u8 *) (bgSub)) + (dy * 512) + x; - u8* src = (u8 *) buf + (pitch * by); + u8 *dest = ((u8 *) (bg)) + (dy * stride) + x; + u8 *destSub = ((u8 *) (bgSub)) + (dy * 512) + x; + const u8 *src = (const u8 *) buf + (pitch * by); u32 dx; u32 pixelsLeft = w; - if (MISALIGNED16(dest)) { + if (MISALIGNED16(dest)) { // Read modify write dest--; @@ -380,10 +384,10 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int } // We can now assume dest is aligned - u16* dest16 = (u16 *) dest; - u16* destSub16 = (u16 *) destSub; + u16 *dest16 = (u16 *) dest; + u16 *destSub16 = (u16 *) destSub; - for (dx = 0; dx < pixelsLeft; dx+=2) { + for (dx = 0; dx < pixelsLeft; dx+=2) { u16 mix; mix = *src + (*(src + 1) << 8); @@ -417,12 +421,12 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int // Stuff is aligned to 16-bit boundaries, so it's safe to do DMA. - u16* src = (u16 *) buf; + u16 *src = (u16 *) buf; if (DS::getKeyboardEnable()) { for (int dy = y; dy < y + h; dy++) { - u16* dest = bg + (dy * (stride >> 1)) + (x >> 1); + u16 *dest = bg + (dy * (stride >> 1)) + (x >> 1); DC_FlushRange(src, w << 1); DC_FlushRange(dest, w << 1); @@ -435,8 +439,8 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int } else { for (int dy = y; dy < y + h; dy++) { - u16* dest1 = bg + (dy * (stride >> 1)) + (x >> 1); - u16* dest2 = bgSub + (dy << 8) + (x >> 1); + u16 *dest1 = bg + (dy * (stride >> 1)) + (x >> 1); + u16 *dest2 = bgSub + (dy << 8) + (x >> 1); DC_FlushRange(src, w << 1); DC_FlushRange(dest1, w << 1); @@ -458,7 +462,7 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int } void OSystem_DS::updateScreen() { - static int cnt = 0; +// static int cnt = 0; // consolePrintf("updatescr %d\n", cnt++); if ((_frameBufferExists) && (DS::getIsDisplayMode8Bit())) { @@ -498,13 +502,13 @@ void OSystem_DS::clearOverlay() { // consolePrintf("clearovl\n"); } -void OSystem_DS::grabOverlay(OverlayColor* buf, int pitch) { +void OSystem_DS::grabOverlay(OverlayColor *buf, int pitch) { // consolePrintf("grabovl\n") - u16* start = DS::get16BitBackBuffer(); + u16 *start = DS::get16BitBackBuffer(); for (int y = 0; y < 200; y++) { - u16* src = start + (y * 320); - u16* dest = ((u16 *) (buf)) + (y * pitch); + u16 *src = start + (y * 320); + u16 *dest = ((u16 *) (buf)) + (y * pitch); for (int x = 0; x < 320; x++) { *dest++ = *src++; @@ -514,8 +518,8 @@ void OSystem_DS::grabOverlay(OverlayColor* buf, int pitch) { } void OSystem_DS::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { - u16* bg = (u16 *) DS::get16BitBackBuffer(); - const u16* src = (const u16 *) buf; + u16 *bg = (u16 *) DS::get16BitBackBuffer(); + const u16 *src = (const u16 *) buf; // if (x + w > 256) w = 256 - x; //if (x + h > 256) h = 256 - y; @@ -586,7 +590,7 @@ void OSystem_DS::refreshCursor() { DS::setCursorIcon(_cursorImage, _cursorW, _cursorH, _cursorKey, _cursorHotX, _cursorHotY); } -void OSystem_DS::addEvent(Common::Event& e) { +void OSystem_DS::addEvent(const Common::Event& e) { eventQueue[queuePos++] = e; } @@ -724,31 +728,15 @@ void OSystem_DS::quit() { swiSoftReset();*/ } -Common::SaveFileManager* OSystem_DS::getSavefileManager() { - bool forceSram; - - if (ConfMan.hasKey("forcesramsave", "ds")) { - forceSram = ConfMan.getBool("forcesramsave", "ds"); - } else { - forceSram = false; - } - if (forceSram) { - consolePrintf("Using SRAM save method!\n"); - } - - if (DS::isGBAMPAvailable() && (!forceSram)) { +Common::SaveFileManager *OSystem_DS::getSavefileManager() { + if (DS::isGBAMPAvailable()) { return &mpSaveManager; - } else { -#ifdef GBA_SRAM_SAVE - return &saveManager; -#else - return NULL; -#endif } + return NULL; } -Graphics::Surface* OSystem_DS::createTempFrameBuffer() { +Graphics::Surface *OSystem_DS::createTempFrameBuffer() { // Ensure we copy using 16 bit quantities due to limitation of VRAM addressing @@ -773,13 +761,13 @@ Graphics::Surface* OSystem_DS::createTempFrameBuffer() { s32 width = DS::getGameWidth(); s32 stride = DS::get8BitBackBufferStride(); - u16* src = DS::get8BitBackBuffer(); - u16* dest = DS::getScalerBuffer(); + u16 *src = DS::get8BitBackBuffer(); + u16 *dest = DS::getScalerBuffer(); for (int y = 0; y < height; y++) { - u16* destLine = dest + (y * (width / 2)); - u16* srcLine = src + (y * (stride / 2)); + u16 *destLine = dest + (y * (width / 2)); + u16 *srcLine = src + (y * (stride / 2)); DC_FlushRange(srcLine, width); @@ -800,7 +788,7 @@ Graphics::Surface* OSystem_DS::createTempFrameBuffer() { size_t imageStrideInBytes = DS::get8BitBackBufferStride(); size_t imageStrideInWords = imageStrideInBytes / 2; - u16* image = (u16 *) DS::get8BitBackBuffer(); + u16 *image = (u16 *) DS::get8BitBackBuffer(); for (int y = 0; y < DS::getGameHeight(); y++) { DC_FlushRange(image + (y * imageStrideInWords), DS::getGameWidth()); for (int x = 0; x < DS::getGameWidth() >> 1; x++) { @@ -846,13 +834,13 @@ void OSystem_DS::setCharactersEntered(int count) { DS::setCharactersEntered(count); } -Common::SeekableReadStream* OSystem_DS::createConfigReadStream() { +Common::SeekableReadStream *OSystem_DS::createConfigReadStream() { Common::FSNode file(DEFAULT_CONFIG_FILE); // consolePrintf("R %s", DEFAULT_CONFIG_FILE); return file.createReadStream(); } -Common::WriteStream* OSystem_DS::createConfigWriteStream() { +Common::WriteStream *OSystem_DS::createConfigWriteStream() { Common::FSNode file(DEFAULT_CONFIG_FILE); // consolePrintf("W %s", DEFAULT_CONFIG_FILE); return file.createWriteStream(); diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index 10b4c87f66..65ac3f4f7e 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -27,7 +30,6 @@ #include "backends/base-backend.h" #include "common/events.h" #include "nds.h" -#include "ramsave.h" #include "gbampsave.h" #include "backends/saves/default/default-saves.h" #include "backends/timer/default/default-timer.h" @@ -44,17 +46,14 @@ protected: Common::Event eventQueue[96]; int queuePos; -#ifdef GBA_SRAM_SAVE - DSSaveFileManager saveManager; -#endif GBAMPSaveFileManager mpSaveManager; - Audio::MixerImpl* _mixer; - DefaultTimerManager* _timer; + Audio::MixerImpl *_mixer; + DefaultTimerManager *_timer; Graphics::Surface _framebuffer; bool _frameBufferExists; bool _graphicsEnable; - static OSystem_DS* _instance; + static OSystem_DS *_instance; u16 _palette[256]; u16 _cursorPalette[256]; @@ -68,7 +67,7 @@ protected: int _cursorScale; - Graphics::Surface* createTempFrameBuffer(); + Graphics::Surface *createTempFrameBuffer(); bool _disableCursorPalette; int _gammaValue; @@ -94,7 +93,7 @@ public: virtual int16 getHeight(); virtual int16 getWidth(); virtual void setPalette(const byte *colors, uint start, uint num); - virtual void grabPalette(unsigned char* colors, uint start, uint num); + virtual void grabPalette(unsigned char *colors, uint start, uint num); void restoreHardwarePalette(); virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); @@ -136,10 +135,10 @@ public: virtual Common::SaveFileManager *getSavefileManager(); - void addEvent(Common::Event& e); - bool isEventQueueEmpty() { return queuePos == 0; } + void addEvent(const Common::Event& e); + bool isEventQueueEmpty() const { return queuePos == 0; } - virtual bool grabRawScreen(Graphics::Surface* surf); + virtual bool grabRawScreen(Graphics::Surface *surf); virtual void setFocusRectangle(const Common::Rect& rect); @@ -150,10 +149,10 @@ public: virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); - virtual Audio::Mixer* getMixer() { return _mixer; } - Audio::MixerImpl* getMixerImpl() { return _mixer; } + virtual Audio::Mixer *getMixer() { return _mixer; } + Audio::MixerImpl *getMixerImpl() { return _mixer; } - virtual Common::TimerManager* getTimerManager() { return _timer; } + virtual Common::TimerManager *getTimerManager() { return _timer; } static int timerHandler(int t); @@ -161,8 +160,8 @@ public: virtual void clearAutoComplete(); virtual void setCharactersEntered(int count); - u16 getDSPaletteEntry(u32 entry) { return _palette[entry]; } - u16 getDSCursorPaletteEntry(u32 entry) { return !_disableCursorPalette? _cursorPalette[entry]: _palette[entry]; } + u16 getDSPaletteEntry(u32 entry) const { return _palette[entry]; } + u16 getDSCursorPaletteEntry(u32 entry) const { return !_disableCursorPalette? _cursorPalette[entry]: _palette[entry]; } virtual void setCursorPalette(const byte *colors, uint start, uint num); @@ -172,8 +171,8 @@ public: void refreshCursor(); - Common::WriteStream* createConfigWriteStream(); - Common::SeekableReadStream* createConfigReadStream(); + Common::WriteStream *createConfigWriteStream(); + Common::SeekableReadStream *createConfigReadStream(); u16 applyGamma(u16 colour); void setGammaValue(int gamma) { _gammaValue = gamma; } diff --git a/backends/platform/ds/arm9/source/portdefs.cpp b/backends/platform/ds/arm9/source/portdefs.cpp deleted file mode 100644 index 0dcdc1d5a3..0000000000 --- a/backends/platform/ds/arm9/source/portdefs.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* 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. - * - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#include <string.h> -#include "nds/dma.h" -#include "osystem_ds.h" - -/* -extern "C" time_t __wrap_time(time_t* t) { - if (t) { - *t = OSystem_DS::instance()->getMillis() / 1000; - } - - return OSystem_DS::instance()->getMillis() / 1000; -} -*/ diff --git a/backends/platform/ds/arm9/source/portdefs.h b/backends/platform/ds/arm9/source/portdefs.h index 5472b711b8..cc38d66a73 100644 --- a/backends/platform/ds/arm9/source/portdefs.h +++ b/backends/platform/ds/arm9/source/portdefs.h @@ -8,39 +8,29 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ #ifndef _PORTDEFS_H_ #define _PORTDEFS_H_ - - -/* -typedef unsigned char u8; -typedef signed char s8; - -typedef unsigned short u16; -typedef signed short s16; - -typedef unsigned int u32; -typedef signed int s32; -*/ - +// Include ndstypes.h for uint16 etc. typedefs #include "nds/ndstypes.h" - -// Somebody removed these from scummsys.h, but they're still required, so I'm adding them here -// in the hope that they'll stay. +// Somebody removed these from scummsys.h, but they're still required, so I'm +// adding them here in the hope that they'll stay. #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -50,18 +40,21 @@ typedef signed int s32; #define double float -#define CT_NO_TRANSPARENCY - +#ifndef DISABLE_TEXT_CONSOLE #define DISABLE_TEXT_CONSOLE +#endif + +#ifndef DISABLE_COMMAND_LINE #define DISABLE_COMMAND_LINE +#endif +#ifndef STREAM_AUDIO_FROM_DISK #define STREAM_AUDIO_FROM_DISK +#endif -//#undef assert -//#define assert(expr) consolePrintf("Asserted!") +// FIXME: What is "NO_DEBUG_MSGS" good for? #define NO_DEBUG_MSGS - // This is defined in dsmain.cpp #ifdef __cplusplus extern "C" { @@ -76,14 +69,22 @@ void consolePrintf(const char *format, ...); #undef assert #endif -#define assert(s) if (!(s)) consolePrintf("Assertion failed: '##s##' at file %s, line %d\n", __FILE__, __LINE__) +#ifdef NDEBUG -//#include "ds-fs.h" +#define assert(e) ((void)0) -//#define debug(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__) -//#define debug(fmt, ...) debug(0, fmt, ##__VA_ARGS__) +#else -#define ITCM_DATA __attribute__((section(".itcm"))) +// FIXME: Shouldn't assert() also bail out / exit / halt the program? Right now we just +// print an error message... +#define assert(s) \ + do { \ + if (!(s)) { \ + consolePrintf("Assertion failed: '##s##' at file %s, line %d\n", __FILE__, __LINE__); \ + } \ + } while (0) + +#endif // FIXME: Since I can't change the engine at the moment (post lockdown) this define can go here. // This define changes the mouse-relative motion which doesn't make sense on a touch screen to diff --git a/backends/platform/ds/arm9/source/ramsave.cpp b/backends/platform/ds/arm9/source/ramsave.cpp deleted file mode 100644 index a0f4633988..0000000000 --- a/backends/platform/ds/arm9/source/ramsave.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/* 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. - * - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ -#ifdef GBA_SRAM_SAVE - - -#include "ramsave.h" -#include "nds.h" -#include "compressor/lz.h" - -#define CART_RAM ((vu8 *) (0x0A000000)) -#define SRAM_SAVE_MAX (65533) - -DSSaveFile::DSSaveFile() { - ptr = 0; - saveCompressed = false; - save.isValid = false; - ownsData = false; - isOpenFlag = true; - isTempFile = false; -} - -DSSaveFile::DSSaveFile(SCUMMSave* s, bool compressed, u8* data) { - save = *s; - saveData = data; - ptr = 0; - saveCompressed = compressed; - isOpenFlag = true; - - if (saveCompressed) { - u8* uncompressed = new unsigned char[save.size]; - if (!uncompressed) consolePrintf("Out of memory allocating %d!\n", save.size); - LZ_Uncompress(saveData, uncompressed, save.compressedSize); - saveData = uncompressed; - ownsData = true; - saveCompressed = false; -// consolePrintf("Decompressed. name=%s size=%d (%d)", save.name, save.size, save.compressedSize); - - } else { - ownsData = false; - origHeader = s; - } - - if (save.magic == (int) 0xBEEFCAFE) { - save.isValid = true; - } else { - save.isValid = false; - } - - isTempFile = false; - eosReached = false; -} - -DSSaveFile::~DSSaveFile() { - if (!ownsData) { - *origHeader = save; - DSSaveFileManager::instance()->flushToSaveRAM(); - } - if (ownsData) { - delete[] saveData; - } -} - -bool DSSaveFile::loadFromSaveRAM(vu8* address) { - - SCUMMSave newSave; - - for (int t = 0; t < (int) sizeof(newSave); t++) { - ((char *) (&newSave))[t] = *(address + t); - } - - if (newSave.magic == 0xBEEFCAFE) { - newSave.isValid = true; - - *((u16 *) (0x4000204)) |= 0x3; - - saveData = new unsigned char[newSave.compressedSize]; - - for (int t = 0; t < (int) newSave.compressedSize; t++) { - ((char *) (saveData))[t] = *(address + t + sizeof(newSave)); - } - - if (ownsData) delete[] this->saveData; - save = newSave; - saveCompressed = true; - this->saveData = saveData; - ownsData = true; - ptr = 0; - - return true; - } - - return false; -} - -void DSSaveFile::compress() { - if (!saveCompressed) { - unsigned char* compBuffer = new unsigned char[(save.size * 110) / 100]; - int compSize = LZ_Compress((u8 *) saveData, compBuffer, save.size); - save.compressedSize = compSize; - - - - delete[] saveData; - - // Make the save smaller - saveData = (u8 *) realloc(compBuffer, save.compressedSize); - saveCompressed = true; - } -} - -int DSSaveFile::saveToSaveRAM(vu8* address) { - - unsigned char* compBuffer; - bool failed; - - - int compSize; - - compress(); - - compSize = save.compressedSize; - compBuffer = saveData; - - if (DSSaveFileManager::instance()->getBytesFree() >= getRamUsage()) { - - DSSaveFileManager::instance()->addBytesFree(-getRamUsage()); - - // Write header - for (int t = 0; t < sizeof(save); t++) { - while (*(address + t) != ((char *) (&save))[t]) { - *(address + t) = ((char *) (&save))[t]; - } - } - - // Write compressed buffer - for (int t = sizeof(save); t < (int) sizeof(save) + compSize; t++) { - while (*(address + t) != compBuffer[t - sizeof(save)]) { - *(address + t) = compBuffer[t - sizeof(save)]; - } - } - - failed = false; - } else { - failed = true; - } - - - return failed? 0: compSize + sizeof(save); - -} - -void DSSaveFile::reset() { - ptr = 0; - eosReached = false; -} - -uint32 DSSaveFile::read(void *buf, uint32 size) { - if (ptr + size > save.size) { - size = save.size - ptr; - eosReached = true; - if (size < 0) size = 0; - } - memcpy(buf, saveData + ptr, size); -// consolePrintf("byte: %d ", ((u8 *) (buf))[0]); - - ptr += size; - return size; -} - -int32 DSSaveFile::pos() const { - return ptr; -} - -int32 DSSaveFile::size() const { - return save.size; -} - -bool DSSaveFile::seek(int32 pos, int whence) { - switch (whence) { - case SEEK_SET: { - ptr = pos; - break; - } - case SEEK_CUR: { - ptr += pos; - break; - } - case SEEK_END: { - ptr = save.size + pos; - break; - } - } - eosReached = false; - return true; -} - -bool DSSaveFile::eos() const { - return eosReached; -} - -void DSSaveFile::clearErr() { - eosReached = false; -} - -bool DSSaveFile::skip(uint32 bytes) { - ptr = ptr + bytes; - if (ptr > (int) save.size) ptr = save.size; - return true; -} - -uint32 DSSaveFile::write(const void *buf, uint32 size) { - - if (ptr + size > DS_MAX_SAVE_SIZE) { - size = DS_MAX_SAVE_SIZE - ptr; - } - - memcpy(saveData + ptr, buf, size); - ptr += size; - save.size += size; - return size; -} - -bool DSSaveFile::matches(const char *prefix, int num) { - char str[16]; - if (isValid()) { - sprintf(str, "%s%02d", prefix, num); - if (!strcmp(str, save.name)) { - return true; - } else { - return false; - } - } else { - return false; - } -} - -bool DSSaveFile::matches(const char *filename) { - if (isValid()) { - return !strcmp(save.name, filename); - } else { - return false; - } -} - -void DSSaveFile::setName(char *name) { - save.isValid = true; - save.magic = 0xBEEFCAFE; - ownsData = true; - save.size = 0; - save.compressedSize = 0; - saveData = new unsigned char[DS_MAX_SAVE_SIZE]; - strcpy(save.name, name); - - if ((strstr(name, ".s99")) || (strstr(name, ".c"))) { - isTempFile = true; - } else { - isTempFile = false; - } -} - -void DSSaveFile::clearData() { - save.size = 0; - - if (saveCompressed) { - if (ownsData) { - delete[] saveData; - DSSaveFileManager::instance()->addBytesFree(getRamUsage()); - } - saveData = new unsigned char[DS_MAX_SAVE_SIZE]; - saveCompressed = false; - ownsData = true; - } - -} - -void DSSaveFile::deleteFile() { - if (isValid()) { - if (ownsData) { - DSSaveFileManager::instance()->addBytesFree(getRamUsage()); - delete[] saveData; - saveData = NULL; - } - ptr = 0; - saveCompressed = false; - save.isValid = false; - ownsData = false; - isOpenFlag = true; - } -} - -DSSaveFileManager::DSSaveFileManager() { - instancePtr = this; - - *((u16 *) (0x4000204)) |= 0x3; - swiWaitForVBlank(); - - loadAllFromSRAM(); -} - -DSSaveFileManager::~DSSaveFileManager() { - instancePtr = NULL; -} - -void DSSaveFileManager::loadAllFromSRAM() { - int addr = 1; - - for (int r = 0; r < 8; r++) { - gbaSave[r].deleteFile(); - } - - sramBytesFree = SRAM_SAVE_MAX; - - // Try to find saves in save RAM - for (int r = 0; r < 8; r++) { - if (gbaSave[r].loadFromSaveRAM(CART_RAM + addr)) { - addr += gbaSave[r].getRamUsage(); - sramBytesFree -= gbaSave[r].getRamUsage(); - } - } - -} - -void DSSaveFileManager::formatSram() { - for (int r = 0; r < SRAM_SAVE_MAX; r++) { - *(CART_RAM + r) = 0; - } - - loadAllFromSRAM(); -} - -void DSSaveFileManager::listFiles() { - for (int r = 0; r < 8; r++) { - if (gbaSave[r].isValid()) { - consolePrintf("'%s': %d bytes\n", gbaSave[r].getName(), gbaSave[r].getRamUsage()); - } - } - consolePrintf("SRAM free: %d bytes\n", getBytesFree()); -} - -DSSaveFileManager* DSSaveFileManager::instancePtr = NULL; - -DSSaveFile *DSSaveFileManager::openSavefile(const char *filename, bool saveOrLoad) { - for (int r = 0; r < 8; r++) { - if (gbaSave[r].isValid() && (gbaSave[r].matches(filename))) { -// consolePrintf("Matched save %d (%d)\n", r, gbaSave[r].getSize()); - gbaSave[r].reset(); - //consolePrintf("reset "); - if (saveOrLoad) gbaSave[r].clearData(); -// consolePrintf("cleared "); - return gbaSave[r].clone(); - } - } - - if (saveOrLoad) { - return makeSaveFile(filename, saveOrLoad); - } else { - return NULL; - } -} - - - -DSSaveFile* DSSaveFile::clone() { -// consolePrintf("Clone %s %d\n", save.name, save.size); - return new DSSaveFile(&save, saveCompressed, saveData); -} - -void DSSaveFileManager::deleteFile(const char* name) { -// consolePrintf("Deleting %s", name); - for (int r = 0; r < 8; r++) { - if (gbaSave[r].isValid() && (gbaSave[r].matches(name))) { - gbaSave[r].deleteFile(); - } - } - flushToSaveRAM(); -} - -bool DSSaveFileManager::removeSavefile(const Common::String &filename) { - consolePrintf("DSSaveFileManager::removeSavefile : Not implemented yet.\n"); - assert(false); - //TODO: Implement this. Most likely, you just have to use the code of deleteFile? - return false; -} - - -Common::StringArray DSSaveFileManager::listSavefiles(const Common::String &pattern) { - consolePrintf("DSSaveFileManager::listSavefiles : Not implemented yet.\n"); - assert(false); - return Common::StringArray(); - /* - TODO: Implement this. If you don't understand what it should do, just ask - (e.g. on scummvm-devel or Fingolfin). It should be pretty simple if you - use Common::matchString from common/util.h and read the Doxygen docs, - then combine this with the old code below... - */ -} - - -/* -void DSSaveFileManager::listSavefiles(const char *prefix, bool *marks, int num) { - memset(marks, true, num * sizeof(bool)); - return; - - memset(marks, false, num*sizeof(bool)); - - for (int saveNum = 0; saveNum < num; saveNum++) { - for (int r = 0; r < 8; r++) { - if (gbaSave[r].isValid() && (gbaSave[r].matches(prefix, saveNum))) { - marks[saveNum] = true; - } - } - } - -} -*/ - - -DSSaveFile *DSSaveFileManager::makeSaveFile(const char *filename, bool saveOrLoad) { - - // Find a free save slot - int r = 0; - - while ((r < 8) && (gbaSave[r].isValid())) { - r++; - } - - if ((r == 8) && (gbaSave[r].isValid())) { - // No more saves - return NULL; - } else { - // Allocate this save -// consolePrintf("Allocated save %d\n", r); - gbaSave[r].setName((char *) filename); - gbaSave[r].reset(); - return gbaSave[r].clone(); - } -} - -void DSSaveFileManager::flushToSaveRAM() { - int cartAddr = 1; - int s; - int extraData = DSSaveFileManager::getExtraData(); - - *((u16 *) (0x4000204)) |= 0x3; - - swiWaitForVBlank(); - - int size = 0; - for (int r = 0; (r < 8); r++) { - if (gbaSave[r].isValid()) { - gbaSave[r].compress(); - if (!gbaSave[r].isTemp()) size += gbaSave[r].getRamUsage(); - } - } - - if (size <= SRAM_SAVE_MAX) { - - for (int r = 0; r < SRAM_SAVE_MAX; r++) { - *(CART_RAM + r) = 0; - } - - sramBytesFree = SRAM_SAVE_MAX; - - for (int r = 0; (r < 8); r++) { - if (gbaSave[r].isValid() && (!gbaSave[r].isTemp())) { - - cartAddr += s = gbaSave[r].saveToSaveRAM(CART_RAM + cartAddr); - - /* if (s == 0) { - consolePrintf("WARNING: Save didn't fit in cart RAM and has been lost!! Delete files and save again.", gbaSave[r].getName()); - failed = true; - }*/ - } - } - } else { - - consolePrintf("WARNING: Save didn't fit in cart RAM and has been lost!! Delete files and save again."); - loadAllFromSRAM(); - - } - - DSSaveFileManager::setExtraData(extraData); -// consolePrintf("SRAM free: %d bytes\n", getBytesFree()); -} - -void DSSaveFileManager::setExtraData(int data) { - // Offset of extra data is 31. This overlaps the padding and reserved bytes of the first save entry. - // which have not been used up until now. So it should be safe. - - vu8* sram = CART_RAM + 31; - - *(sram + 0) = 0xF0; // This is an identifier to check - *(sram + 1) = 0x0D; // that extra data is present. - - *(sram + 2) = (data & 0xFF000000) >> 24; // Now write the actual data - *(sram + 3) = (data & 0x00FF0000) >> 16; // taking care to use single - *(sram + 4) = (data & 0x0000FF00) >> 8; // byte writes (it's an 8-bit bus) - *(sram + 5) = (data & 0x000000FF); -} - -bool DSSaveFileManager::isExtraDataPresent() { - vu8* sram = CART_RAM + 31; - - // Check for the identifier - return ((*(sram + 0) == 0xF0) && (*(sram + 1) == 0x0D)); -} - -int DSSaveFileManager::getExtraData() { - vu8* sram = CART_RAM + 31; - - if (isExtraDataPresent()) { - int value = (*(sram + 2) << 24) | (*(sram + 3) << 16) | (*(sram + 4) << 8) | (*(sram + 5)); - return value; - } else { - return 0; - } -} - -#endif diff --git a/backends/platform/ds/arm9/source/ramsave.h b/backends/platform/ds/arm9/source/ramsave.h deleted file mode 100644 index e74df94952..0000000000 --- a/backends/platform/ds/arm9/source/ramsave.h +++ /dev/null @@ -1,150 +0,0 @@ -/* 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. - * - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef _RAMSAVE_H_ -#define _RAMSAVE_H_ - -#include "common/system.h" -#include "common/savefile.h" - -// SaveFileManager class - -#define DS_MAX_SAVE_SIZE 150000 - -class DSSaveFile : public Common::InSaveFile, public Common::OutSaveFile { - int address; - int ptr; - bool ownsData; - bool saveCompressed; - - struct SCUMMSave { - u32 magic; // 4 - bool isValid; // 5 - bool pad; // 6 - char name[16]; // 22 - u32 size; // 26 - u32 compressedSize; // 30 - u16 extraMagic; // 32 - u32 reserved; // 36 - } __attribute__ ((packed)); - - SCUMMSave save; - u8* saveData; - SCUMMSave* origHeader; - bool isOpenFlag; - bool isTempFile; - bool eosReached; - -public: - DSSaveFile(); - DSSaveFile(SCUMMSave* s, bool saveCompressed, u8* data); - ~DSSaveFile(); - - void reset(); - - bool isOpen() const { return isOpenFlag; } - virtual bool eos() const; - virtual void clearErr(); - virtual bool skip(uint32 size); - - virtual int32 pos() const; - virtual int32 size() const; - virtual bool seek(int32 pos, int whence); - - uint32 read(void *buf, uint32 size); - uint32 write(const void *buf, uint32 size); - - void setName(char *name); - char* getName() { return save.name; } - - bool isValid() { return save.isValid; } - bool isTemp() { return isTempFile; } - bool matches(const char *prefix, int num); - bool matches(const char *filename); - - void clearData(); - void compress(); - - int getRamUsage() { return sizeof(save) + save.compressedSize; } - char* getRamImage() { return (char *) &save; } - - int getSize() { return save.size; } - - DSSaveFile* clone(); - - bool loadFromSaveRAM(vu8* address); - int saveToSaveRAM(vu8* address); - - - - void deleteFile(); - - void operator delete(void *p) { -// consolePrintf("Finished! size=%d\n", ((DSSaveFile *) (p))->save->size); - } - - - -}; - - - -class DSSaveFileManager : public Common::SaveFileManager { - - DSSaveFile gbaSave[8]; - static DSSaveFileManager* instancePtr; - int sramBytesFree; - -public: - DSSaveFileManager(); - ~DSSaveFileManager(); - - static DSSaveFileManager* instance() { return instancePtr; } - - DSSaveFile *openSavefile(const char *filename, bool saveOrLoad); - - virtual Common::OutSaveFile* openForSaving(const Common::String &filename) { return openSavefile(filename.c_str(), true); } - virtual Common::InSaveFile* openForLoading(const Common::String &filename) { return openSavefile(filename.c_str(), false); } - - virtual bool removeSavefile(const Common::String &filename); - virtual Common::StringArray listSavefiles(const Common::String &pattern); - - void flushToSaveRAM(); - - void addBytesFree(int size) { sramBytesFree += size; } - int getBytesFree() { return sramBytesFree; } - - void deleteFile(char* name); - void listFiles(); - void formatSram(); - - void loadAllFromSRAM(); - - static bool isExtraDataPresent(); - static int getExtraData(); - static void setExtraData(int data); - -protected: - DSSaveFile *makeSaveFile(const Common::String &filename, bool saveOrLoad); -}; - -#endif diff --git a/backends/platform/ds/arm9/source/scummhelp.cpp b/backends/platform/ds/arm9/source/scummhelp.cpp index e1ddaecc2c..f1e8ba4fb2 100644 --- a/backends/platform/ds/arm9/source/scummhelp.cpp +++ b/backends/platform/ds/arm9/source/scummhelp.cpp @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -91,7 +94,8 @@ void updateStrings(byte gameId, byte version, Common::Platform platform, } -} +} // End of namespace DS + #undef ADD_BIND diff --git a/backends/platform/ds/arm9/source/scummhelp.h b/backends/platform/ds/arm9/source/scummhelp.h index 602cb5f788..4be28dca6a 100644 --- a/backends/platform/ds/arm9/source/scummhelp.h +++ b/backends/platform/ds/arm9/source/scummhelp.h @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -31,6 +34,7 @@ namespace DS { void updateStrings(byte gameId, byte version, Common::Platform platform, int page, Common::String &title, Common::String *&key, Common::String *&dsc); -} +} // End of namespace DS + #endif diff --git a/backends/platform/ds/arm9/source/touchkeyboard.cpp b/backends/platform/ds/arm9/source/touchkeyboard.cpp index 2d4b6a94f4..71f4f93c27 100644 --- a/backends/platform/ds/arm9/source/touchkeyboard.cpp +++ b/backends/platform/ds/arm9/source/touchkeyboard.cpp @@ -20,6 +20,7 @@ * */ #include <nds.h> +#include "NDS/scummvm_ipc.h" #include "touchkeyboard.h" #include "keyboard_raw.h" #include "keyboard_pal_raw.h" @@ -43,124 +44,124 @@ struct key_data { #define DS_CAPSLOCK 1 -key_data keys[DS_NUM_KEYS] = { +static key_data keys[DS_NUM_KEYS] = { // Key number x y character // Numbers - {28, 3, 0, '1'}, - {29, 5, 0, '2'}, - {30, 7, 0, '3'}, - {31, 9, 0, '4'}, - {32, 11, 0, '5'}, - {33, 13, 0, '6'}, - {34, 15, 0, '7'}, - {35, 17, 0, '8'}, - {36, 19, 0, '9'}, - {27, 21, 0, '0'}, - {45, 23, 0, Common::KEYCODE_MINUS}, - {50, 25, 0, Common::KEYCODE_EQUALS}, - {52, 27, 0, Common::KEYCODE_BACKSPACE}, + {28, 3, 0, '1', false}, + {29, 5, 0, '2', false}, + {30, 7, 0, '3', false}, + {31, 9, 0, '4', false}, + {32, 11, 0, '5', false}, + {33, 13, 0, '6', false}, + {34, 15, 0, '7', false}, + {35, 17, 0, '8', false}, + {36, 19, 0, '9', false}, + {27, 21, 0, '0', false}, + {45, 23, 0, Common::KEYCODE_MINUS, false}, + {50, 25, 0, Common::KEYCODE_EQUALS, false}, + {52, 27, 0, Common::KEYCODE_BACKSPACE, false}, // Top row - {'Q'-'A' + 1, 4, 2, 'Q'}, - {'W'-'A' + 1, 6, 2, 'W'}, - {'E'-'A' + 1, 8, 2, 'E'}, - {'R'-'A' + 1, 10, 2, 'R'}, - {'T'-'A' + 1, 12, 2, 'T'}, - {'Y'-'A' + 1, 14, 2, 'Y'}, - {'U'-'A' + 1, 16, 2, 'U'}, - {'I'-'A' + 1, 18, 2, 'I'}, - {'O'-'A' + 1, 20, 2, 'O'}, - {'P'-'A' + 1, 22, 2, 'P'}, - {43, 24, 2, Common::KEYCODE_LEFTBRACKET}, - {44, 26, 2, Common::KEYCODE_RIGHTBRACKET}, + {'Q'-'A' + 1, 4, 2, 'Q', false}, + {'W'-'A' + 1, 6, 2, 'W', false}, + {'E'-'A' + 1, 8, 2, 'E', false}, + {'R'-'A' + 1, 10, 2, 'R', false}, + {'T'-'A' + 1, 12, 2, 'T', false}, + {'Y'-'A' + 1, 14, 2, 'Y', false}, + {'U'-'A' + 1, 16, 2, 'U', false}, + {'I'-'A' + 1, 18, 2, 'I', false}, + {'O'-'A' + 1, 20, 2, 'O', false}, + {'P'-'A' + 1, 22, 2, 'P', false}, + {43, 24, 2, Common::KEYCODE_LEFTBRACKET, false}, + {44, 26, 2, Common::KEYCODE_RIGHTBRACKET, false}, // Middle row - {55, 3, 4, DS_CAPSLOCK}, - {'A'-'A' + 1, 5, 4, 'A'}, - {'S'-'A' + 1, 7, 4, 'S'}, - {'D'-'A' + 1, 9, 4, 'D'}, - {'F'-'A' + 1, 11, 4, 'F'}, - {'G'-'A' + 1, 13, 4, 'G'}, - {'H'-'A' + 1, 15, 4, 'H'}, - {'J'-'A' + 1, 17, 4, 'J'}, - {'K'-'A' + 1, 19, 4, 'K'}, - {'L'-'A' + 1, 21, 4, 'L'}, - {42, 23, 4, Common::KEYCODE_SEMICOLON}, - {41, 25, 4, Common::KEYCODE_QUOTE}, - {46, 27, 4, Common::KEYCODE_RETURN}, + {55, 3, 4, DS_CAPSLOCK, false}, + {'A'-'A' + 1, 5, 4, 'A', false}, + {'S'-'A' + 1, 7, 4, 'S', false}, + {'D'-'A' + 1, 9, 4, 'D', false}, + {'F'-'A' + 1, 11, 4, 'F', false}, + {'G'-'A' + 1, 13, 4, 'G', false}, + {'H'-'A' + 1, 15, 4, 'H', false}, + {'J'-'A' + 1, 17, 4, 'J', false}, + {'K'-'A' + 1, 19, 4, 'K', false}, + {'L'-'A' + 1, 21, 4, 'L', false}, + {42, 23, 4, Common::KEYCODE_SEMICOLON, false}, + {41, 25, 4, Common::KEYCODE_QUOTE, false}, + {46, 27, 4, Common::KEYCODE_RETURN, false}, // Bottom row - {51, 4, 6, DS_SHIFT}, - {'Z'-'A' + 1, 6, 6, 'Z'}, - {'X'-'A' + 1, 8, 6, 'X'}, - {'C'-'A' + 1, 10, 6, 'C'}, - {'V'-'A' + 1, 12, 6, 'V'}, - {'B'-'A' + 1, 14, 6, 'B'}, - {'N'-'A' + 1, 16, 6, 'N'}, - {'M'-'A' + 1, 18, 6, 'M'}, - {38, 20, 6, Common::KEYCODE_COMMA}, - {39, 22, 6, Common::KEYCODE_PERIOD}, - {40, 24, 6, Common::KEYCODE_SLASH}, + {51, 4, 6, DS_SHIFT, false}, + {'Z'-'A' + 1, 6, 6, 'Z', false}, + {'X'-'A' + 1, 8, 6, 'X', false}, + {'C'-'A' + 1, 10, 6, 'C', false}, + {'V'-'A' + 1, 12, 6, 'V', false}, + {'B'-'A' + 1, 14, 6, 'B', false}, + {'N'-'A' + 1, 16, 6, 'N', false}, + {'M'-'A' + 1, 18, 6, 'M', false}, + {38, 20, 6, Common::KEYCODE_COMMA, false}, + {39, 22, 6, Common::KEYCODE_PERIOD, false}, + {40, 24, 6, Common::KEYCODE_SLASH, false}, // Space bar - {47, 9, 8, Common::KEYCODE_SPACE}, - {48, 11, 8, Common::KEYCODE_SPACE}, - {48, 13, 8, Common::KEYCODE_SPACE}, - {48, 15, 8, Common::KEYCODE_SPACE}, - {48, 17, 8, Common::KEYCODE_SPACE}, - {49, 19, 8, Common::KEYCODE_SPACE}, + {47, 9, 8, Common::KEYCODE_SPACE, false}, + {48, 11, 8, Common::KEYCODE_SPACE, false}, + {48, 13, 8, Common::KEYCODE_SPACE, false}, + {48, 15, 8, Common::KEYCODE_SPACE, false}, + {48, 17, 8, Common::KEYCODE_SPACE, false}, + {49, 19, 8, Common::KEYCODE_SPACE, false}, // Cursor arrows - {52, 27, 8, Common::KEYCODE_LEFT}, - {54, 29, 8, Common::KEYCODE_DOWN}, - {53, 31, 8, Common::KEYCODE_RIGHT}, - {51, 29, 6, Common::KEYCODE_UP}, + {52, 27, 8, Common::KEYCODE_LEFT, false}, + {54, 29, 8, Common::KEYCODE_DOWN, false}, + {53, 31, 8, Common::KEYCODE_RIGHT, false}, + {51, 29, 6, Common::KEYCODE_UP, false}, // Close button - {56, 30, 0, Common::KEYCODE_INVALID}, + {56, 30, 0, Common::KEYCODE_INVALID, false}, // Function keys (needed for AGI) - {57, 4, -2, Common::KEYCODE_F1}, - {58, 6, -2, Common::KEYCODE_F2}, - {59, 8, -2, Common::KEYCODE_F3}, - {60, 10, -2, Common::KEYCODE_F4}, - {61, 14, -2, Common::KEYCODE_F5}, - {62, 16, -2, Common::KEYCODE_F6}, - {63, 18, -2, Common::KEYCODE_F7}, - {64, 20, -2, Common::KEYCODE_F8}, - {65, 24, -2, Common::KEYCODE_F9}, - {66, 26, -2, Common::KEYCODE_F10}, - {67, 28, -2, Common::KEYCODE_F11}, - {68, 30, -2, Common::KEYCODE_F12}, + {57, 4, -2, Common::KEYCODE_F1, false}, + {58, 6, -2, Common::KEYCODE_F2, false}, + {59, 8, -2, Common::KEYCODE_F3, false}, + {60, 10, -2, Common::KEYCODE_F4, false}, + {61, 14, -2, Common::KEYCODE_F5, false}, + {62, 16, -2, Common::KEYCODE_F6, false}, + {63, 18, -2, Common::KEYCODE_F7, false}, + {64, 20, -2, Common::KEYCODE_F8, false}, + {65, 24, -2, Common::KEYCODE_F9, false}, + {66, 26, -2, Common::KEYCODE_F10, false}, + {67, 28, -2, Common::KEYCODE_F11, false}, + {68, 30, -2, Common::KEYCODE_F12, false}, }; -int keyboardX; -int keyboardY; +static int keyboardX; +static int keyboardY; -int mapBase; -int tileBase; +static int s_mapBase; +static int s_tileBase; -u16* baseAddress; +static u16 *baseAddress; -bool shiftState; -bool capsLockState; +static bool shiftState; +static bool capsLockState; -bool closed; +static bool closed; -char autoCompleteWord[NUM_WORDS][32]; -int autoCompleteCount; +static char autoCompleteWord[NUM_WORDS][32]; +static int autoCompleteCount; -char autoCompleteBuffer[128]; +static char autoCompleteBuffer[128]; -int selectedCompletion = -1; -int charactersEntered = 0; -int typingTimeout = 0; +static int selectedCompletion = -1; +static int charactersEntered = 0; +static int typingTimeout = 0; // Render text onto the tiled screen -void drawText(int tx, int ty, char* string, bool highlight) { +void drawText(int tx, int ty, const char *string, bool highlight) { u16 baseValue = 0; @@ -181,7 +182,7 @@ void drawText(int tx, int ty, char* string, bool highlight) { -void restoreVRAM(int tileBase, int mapBase, u16* saveSpace) { +void restoreVRAM(int tileBase, int mapBase, u16 *saveSpace) { /* for (int r = 0; r < 32 * 32; r++) { ((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase))[r] = *saveSpace++; } @@ -191,7 +192,7 @@ void restoreVRAM(int tileBase, int mapBase, u16* saveSpace) { }*/ } -void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) { +void drawKeyboard(int tileBase, int mapBase, u16 *saveSpace) { /* int keyboardDataSize = 4736 * 2; */ for (int r = 0; r < 32 * 32; r++) { @@ -211,8 +212,8 @@ void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) { // this is the font for (int tile = 0; tile < 94; tile++) { - u16* tileAddr = (u16 *) (CHAR_BASE_BLOCK_SUB(tileBase) + ((KEYBOARD_DATA_SIZE) + (tile * 32))); - u8* src = ((u8 *) (::_8x8font_tga_raw)) + 18 + tile * 8; + u16 *tileAddr = (u16 *) (CHAR_BASE_BLOCK_SUB(tileBase) + ((KEYBOARD_DATA_SIZE) + (tile * 32))); + const u8 *src = ((const u8 *) (::_8x8font_tga_raw)) + 18 + tile * 8; for (int y = 0 ; y < 8; y++) { for (int x = 0; x < 2; x++) { @@ -247,8 +248,8 @@ void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) { keyboardX = -2; keyboardY = 2; - DS::mapBase = mapBase; - DS::tileBase = tileBase; + DS::s_mapBase = mapBase; + DS::s_tileBase = tileBase; shiftState = false; capsLockState = false; @@ -256,7 +257,7 @@ void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) { int x = keyboardX; int y = keyboardY; - u16* base = ((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase)); + u16 *base = ((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase)); baseAddress = base; for (int r = 0; r < DS_NUM_KEYS; r++) { @@ -314,7 +315,7 @@ bool getKeyboardClosed() { } void setKeyHighlight(int key, bool highlight) { - u16* base = ((u16 *) SCREEN_BASE_BLOCK_SUB(DS::mapBase)); + u16 *base = ((u16 *) SCREEN_BASE_BLOCK_SUB(DS::s_mapBase)); if (highlight) { base[(keyboardY + keys[key].y) * 32 + keyboardX + keys[key].x] |= 0x1000; @@ -329,7 +330,7 @@ void setKeyHighlight(int key, bool highlight) { } } -void addAutoComplete(const char* word) { +void addAutoComplete(const char *word) { if (autoCompleteCount == NUM_WORDS) return; strcpy(&autoCompleteWord[autoCompleteCount++][0], word); drawAutoComplete(); @@ -353,7 +354,7 @@ void clearAutoComplete() { void typeCompletion(int current) { Common::Event event; - /* OSystem_DS* system = OSystem_DS::instance(); */ + /* OSystem_DS *system = OSystem_DS::instance(); */ strcat(autoCompleteBuffer, &autoCompleteWord[current][charactersEntered]); strcat(autoCompleteBuffer, " "); @@ -384,7 +385,7 @@ void typeCompletion(int current) { void updateTypeEvents() { if (autoCompleteBuffer[0] != '\0') { Common::Event event; - OSystem_DS* system = OSystem_DS::instance(); + OSystem_DS *system = OSystem_DS::instance(); event.kbd.keycode = (Common::KeyCode) autoCompleteBuffer[0]; event.kbd.ascii = autoCompleteBuffer[0]; @@ -395,8 +396,7 @@ void updateTypeEvents() { event.type = Common::EVENT_KEYUP; system->addEvent(event); - for (int r = 0; r < (int)strlen(autoCompleteBuffer); r++) - { + for (int r = 0; r < (int)strlen(autoCompleteBuffer); r++) { autoCompleteBuffer[r] = autoCompleteBuffer[r + 1]; } @@ -404,8 +404,7 @@ void updateTypeEvents() { } } -void createKeyEvent(int keyNum, Common::Event& event) -{ +void createKeyEvent(int keyNum, Common::Event& event) { event.kbd.flags = 0; if ((keys[keyNum].character >= '0') && (keys[keyNum].character <= '9')) { @@ -443,7 +442,7 @@ void releaseAllKeys() { if (keys[r].pressed) { DS::setKeyHighlight(r, false); - OSystem_DS* system = OSystem_DS::instance(); + OSystem_DS *system = OSystem_DS::instance(); Common::Event event; createKeyEvent(r, event); @@ -502,7 +501,7 @@ void addKeyboardEvents() { for (int r = 0; r < DS_NUM_KEYS; r++) { if (( (tx >= keys[r].x) && (tx <= keys[r].x + 1)) && (ty >= keys[r].y) && (ty <= keys[r].y + 1)) { - OSystem_DS* system = OSystem_DS::instance(); + OSystem_DS *system = OSystem_DS::instance(); Common::Event event; // consolePrintf("Key: %d\n", r); @@ -551,7 +550,7 @@ void addKeyboardEvents() { if (keys[r].pressed) { DS::setKeyHighlight(r, false); - OSystem_DS* system = OSystem_DS::instance(); + OSystem_DS *system = OSystem_DS::instance(); Common::Event event; if ((keys[r].character == Common::KEYCODE_INVALID)) { @@ -586,5 +585,4 @@ void addKeyboardEvents() { } -} - +} // End of namespace DS diff --git a/backends/platform/ds/arm9/source/touchkeyboard.h b/backends/platform/ds/arm9/source/touchkeyboard.h index 6ceb83bfc7..7644e48bff 100644 --- a/backends/platform/ds/arm9/source/touchkeyboard.h +++ b/backends/platform/ds/arm9/source/touchkeyboard.h @@ -8,15 +8,18 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ @@ -27,23 +30,25 @@ namespace DS { -static const int NUM_WORDS = 12; -static const int KEYBOARD_DATA_SIZE = 4736 * 2; -static const int KEYBOARD_BOTTOM_Y = 105; +enum { + NUM_WORDS = 12, + KEYBOARD_DATA_SIZE = 4736 * 2, + KEYBOARD_BOTTOM_Y = 105 +}; void createKeyEvent(int keyNum, Common::Event& event); -void drawKeyboard(int tileBase, int mapBase, u16* saveSpace); -void restoreVRAM(int tileBase, int mapBase, u16* saveSpace); +void drawKeyboard(int tileBase, int mapBase, u16 *saveSpace); +void restoreVRAM(int tileBase, int mapBase, u16 *saveSpace); void addKeyboardEvents(); bool getKeyboardClosed(); bool isInsideKeyboard(int x, int y); -void addAutoComplete(const char* word); +void addAutoComplete(const char *word); void clearAutoComplete(); void setCharactersEntered(int count); void releaseAllKeys(); -} +} // End of namespace DS #endif diff --git a/backends/platform/ds/arm9/source/wordcompletion.cpp b/backends/platform/ds/arm9/source/wordcompletion.cpp index 035f6a631d..43a16486c5 100644 --- a/backends/platform/ds/arm9/source/wordcompletion.cpp +++ b/backends/platform/ds/arm9/source/wordcompletion.cpp @@ -1,3 +1,28 @@ +/* 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. + * + * 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$ + * + */ + #include "wordcompletion.h" #include "osystem_ds.h" #include "engines/agi/agi.h" // Caution for #define for NUM_CHANNELS, causes problems in mixer_intern.h @@ -14,7 +39,7 @@ namespace DS { char wordBuffer[WORD_BUFFER_SIZE]; int wordBufferPos = 0; -char* wordBufferPtr[MAX_WORD_COUNT]; +char *wordBufferPtr[MAX_WORD_COUNT]; int wordBufferPtrPos = 0; void addAutoCompleteLine(const char *line) { @@ -53,7 +78,7 @@ void addAutoCompleteLine(const char *line) { } } -int stringCompare(const void* a, const void* b) { +int stringCompare(const void *a, const void *b) { const char** as = (const char **) a; const char** bs = (const char **) b; @@ -71,7 +96,7 @@ void sortAutoCompleteWordList() { } // Sends the current available words to the virtual keyboard code for display -bool findWordCompletions(const char* input) { +bool findWordCompletions(const char *input) { int min = 0; int max = wordBufferPtrPos - 1; char *word; @@ -82,7 +107,7 @@ bool findWordCompletions(const char* input) { if (wordBufferPtrPos == 0) return false; - OSystem_DS* system = (OSystem_DS *) g_system; + OSystem_DS *system = (OSystem_DS *) g_system; system->clearAutoComplete(); int start = 0; @@ -176,5 +201,6 @@ bool findWordCompletions(const char* input) { } -} +} // End of namespace DS + #endif diff --git a/backends/platform/ds/arm9/source/wordcompletion.h b/backends/platform/ds/arm9/source/wordcompletion.h index e50bade37b..55a0bc8b5a 100644 --- a/backends/platform/ds/arm9/source/wordcompletion.h +++ b/backends/platform/ds/arm9/source/wordcompletion.h @@ -1,3 +1,28 @@ +/* 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. + * + * 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$ + * + */ + namespace DS { extern void clearAutoCompleteWordList(); @@ -5,4 +30,4 @@ extern bool findWordCompletions(const char *input); extern void addAutoCompleteLine(const char *line); extern void sortAutoCompleteWordList(); -} +} // End of namespace DS diff --git a/backends/platform/ds/arm9/source/zipreader.cpp b/backends/platform/ds/arm9/source/zipreader.cpp index fd6da4e9b9..d4f055ee82 100644 --- a/backends/platform/ds/arm9/source/zipreader.cpp +++ b/backends/platform/ds/arm9/source/zipreader.cpp @@ -8,19 +8,23 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ +#include "common/scummsys.h" #include "zipreader.h" ZipFile::ZipFile() { @@ -28,7 +32,7 @@ ZipFile::ZipFile() { // consolePrintf("ZIP file check..."); - char* p = (char *) ZF_SEARCH_START; + char *p = (char *) ZF_SEARCH_START; bool found = false; _zipFile = NULL; @@ -75,7 +79,6 @@ bool ZipFile::restartFile() { bool more = true; while (!currentFileInFolder() && more) { - char name[128]; getFileName(name); more = skipFile(); } @@ -112,7 +115,7 @@ bool ZipFile::currentFileInFolder() { return false; } -void ZipFile::getFileName(char* name) { +void ZipFile::getFileName(char *name) { strncpy(name, (char *) (_currentFile + 1), _currentFile->nameLength); for (int r = 0; name[r] != 0; r++) { @@ -207,7 +210,7 @@ void ZipFile::changeToRoot() { _directory[0] = 0; } -void ZipFile::changeDirectory(const char* dir) { +void ZipFile::changeDirectory(const char *dir) { // consolePrintf("Current dir now '%s'\n", dir); assert(dir && *dir); diff --git a/backends/platform/ds/arm9/source/zipreader.h b/backends/platform/ds/arm9/source/zipreader.h index d1f70942ce..5429954088 100644 --- a/backends/platform/ds/arm9/source/zipreader.h +++ b/backends/platform/ds/arm9/source/zipreader.h @@ -8,21 +8,26 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ * */ #ifndef _ZIPREADER_H_ #define _ZIPREADER_H_ -#include "portdefs.h" + +#include <nds/ndstypes.h> + #define ZF_SEARCH_START 0x08000000 #define ZF_SEARCH_END 0x09000000 #define ZF_SEARCH_STRIDE 16 @@ -43,12 +48,12 @@ class ZipFile { u16 extraLength; // Length of any extra data } __attribute__ ((packed)); - char* _zipFile; + char *_zipFile; char _directory[128]; bool _allFilesVisible; - FileHeader* _currentFile; + FileHeader *_currentFile; public: ZipFile(); @@ -61,13 +66,13 @@ public: bool findFile(const char *search); // These return the file's data and information - char* getFile(); + char *getFile(); int getFileSize(); - void getFileName(char* name); + void getFileName(char *name); bool isDirectory(); // These set the current directory - void changeDirectory(const char* name); + void changeDirectory(const char *name); void changeToRoot(); void setAllFilesVisible(bool state) { _allFilesVisible = state; } |