aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ds/arm9
diff options
context:
space:
mode:
authorJordi Vilalta Prat2008-01-27 19:47:41 +0000
committerJordi Vilalta Prat2008-01-27 19:47:41 +0000
commit66e9d4f5e8f35b28f8abd9ce53a0da4da3ce8985 (patch)
treee27aadabecd8dd910884280e6559ff9c94c3d73c /backends/platform/ds/arm9
parent278857698dc7b1623096fe1ad12511dc4c886c7e (diff)
downloadscummvm-rg350-66e9d4f5e8f35b28f8abd9ce53a0da4da3ce8985.tar.gz
scummvm-rg350-66e9d4f5e8f35b28f8abd9ce53a0da4da3ce8985.tar.bz2
scummvm-rg350-66e9d4f5e8f35b28f8abd9ce53a0da4da3ce8985.zip
Removed trailing spaces.
svn-id: r30664
Diffstat (limited to 'backends/platform/ds/arm9')
-rw-r--r--backends/platform/ds/arm9/makefile48
-rw-r--r--backends/platform/ds/arm9/source/blitters.cpp108
-rw-r--r--backends/platform/ds/arm9/source/blitters.h8
-rw-r--r--backends/platform/ds/arm9/source/blitters.s28
-rw-r--r--backends/platform/ds/arm9/source/cdaudio.cpp166
-rw-r--r--backends/platform/ds/arm9/source/cdaudio.h2
-rw-r--r--backends/platform/ds/arm9/source/console2.h4
-rw-r--r--backends/platform/ds/arm9/source/dsmain.cpp542
-rw-r--r--backends/platform/ds/arm9/source/dsmain.h2
-rw-r--r--backends/platform/ds/arm9/source/dsoptions.cpp26
-rw-r--r--backends/platform/ds/arm9/source/dsoptions.h6
-rw-r--r--backends/platform/ds/arm9/source/fat/disc_io.c40
-rw-r--r--backends/platform/ds/arm9/source/fat/disc_io.h6
-rw-r--r--backends/platform/ds/arm9/source/fat/gba_nds_fat.c510
-rw-r--r--backends/platform/ds/arm9/source/fat/gba_nds_fat.h28
-rw-r--r--backends/platform/ds/arm9/source/fat/io_dldi.h4
-rw-r--r--backends/platform/ds/arm9/source/fat/io_dldi.s14
-rw-r--r--backends/platform/ds/arm9/source/fat/io_efa2.c28
-rw-r--r--backends/platform/ds/arm9/source/fat/io_fcsr.c16
-rw-r--r--backends/platform/ds/arm9/source/fat/io_fcsr.h4
-rw-r--r--backends/platform/ds/arm9/source/fat/io_m3_common.c10
-rw-r--r--backends/platform/ds/arm9/source/fat/io_m3_common.h6
-rw-r--r--backends/platform/ds/arm9/source/fat/io_m3cf.c54
-rw-r--r--backends/platform/ds/arm9/source/fat/io_m3cf.h4
-rw-r--r--backends/platform/ds/arm9/source/fat/io_m3sd.c4
-rw-r--r--backends/platform/ds/arm9/source/fat/io_m3sd_asm.s26
-rw-r--r--backends/platform/ds/arm9/source/fat/io_mmcf.c26
-rw-r--r--backends/platform/ds/arm9/source/fat/io_mmcf.h2
-rw-r--r--backends/platform/ds/arm9/source/fat/io_mpcf.c52
-rw-r--r--backends/platform/ds/arm9/source/fat/io_mpcf.h4
-rw-r--r--backends/platform/ds/arm9/source/fat/io_njsd.c78
-rw-r--r--backends/platform/ds/arm9/source/fat/io_njsd.h4
-rw-r--r--backends/platform/ds/arm9/source/fat/io_nmmc.c58
-rw-r--r--backends/platform/ds/arm9/source/fat/io_nmmc.h4
-rw-r--r--backends/platform/ds/arm9/source/fat/io_sccf.c2
-rw-r--r--backends/platform/ds/arm9/source/fat/io_sccf.h4
-rw-r--r--backends/platform/ds/arm9/source/fat/io_scsd.c10
-rw-r--r--backends/platform/ds/arm9/source/fat/io_scsd.h8
-rw-r--r--backends/platform/ds/arm9/source/fat/io_scsd_asm.s112
-rw-r--r--backends/platform/ds/arm9/source/fat/io_sd_common.c58
-rw-r--r--backends/platform/ds/arm9/source/fat/io_sd_common.h10
-rw-r--r--backends/platform/ds/arm9/source/gbampsave.cpp48
-rw-r--r--backends/platform/ds/arm9/source/gbampsave.h18
-rw-r--r--backends/platform/ds/arm9/source/keys.cpp16
-rw-r--r--backends/platform/ds/arm9/source/libcartreset/cartreset.c2
-rw-r--r--backends/platform/ds/arm9/source/libcartreset/cartreset_nolibfat.h2
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp82
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h30
-rw-r--r--backends/platform/ds/arm9/source/portdefs.h2
-rw-r--r--backends/platform/ds/arm9/source/ramsave.cpp82
-rw-r--r--backends/platform/ds/arm9/source/ramsave.h46
-rw-r--r--backends/platform/ds/arm9/source/scummconsole.c76
-rw-r--r--backends/platform/ds/arm9/source/scummconsole.h2
-rw-r--r--backends/platform/ds/arm9/source/scummhelp.cpp2
-rw-r--r--backends/platform/ds/arm9/source/scummhelp.h4
-rw-r--r--backends/platform/ds/arm9/source/touchkeyboard.cpp102
-rw-r--r--backends/platform/ds/arm9/source/touchkeyboard.h2
-rw-r--r--backends/platform/ds/arm9/source/wordcompletion.cpp16
-rw-r--r--backends/platform/ds/arm9/source/zipreader.cpp62
-rw-r--r--backends/platform/ds/arm9/source/zipreader.h16
60 files changed, 1368 insertions, 1368 deletions
diff --git a/backends/platform/ds/arm9/makefile b/backends/platform/ds/arm9/makefile
index a64de889ad..bc3d532e8d 100644
--- a/backends/platform/ds/arm9/makefile
+++ b/backends/platform/ds/arm9/makefile
@@ -54,10 +54,10 @@ ifdef DS_BUILD_F
# TODO: Fix this. When libmad is compiled in, the Kyrandia resource loading
# searches through it's entire index to find an mp3 each time a voice sample is requested
# this causes a nasty pause.
-else
+else
ifdef DS_BUILD_E
# TODO: Inherit the earth uses so much RAM that I have removed libmad in order to
- # claw some back.
+ # claw some back.
else
@@ -135,7 +135,7 @@ ifdef DS_BUILD_B
BUILD=scummvm-B
endif
-ifdef DS_BUILD_C
+ifdef DS_BUILD_C
DEFINES = -DDS_NON_SCUMM_BUILD -DDS_BUILD_C
LOGO = logoc.bmp
DISABLE_HE = 1
@@ -287,7 +287,7 @@ ifdef USE_PROFILER
CFLAGS += -mpoke-function-name -finstrument-functions -g
DEFINES += -DUSE_PROFILER
endif
-
+
CXXFLAGS= $(CFLAGS) -Wno-non-virtual-dtor -Wno-non-virtual-dtor \
-fno-exceptions -fno-rtti -mthumb-interwork
@@ -315,7 +315,7 @@ INCLUDES= -I./ -I$(portdir)/$(BUILD) -I$(srcdir) -I$(srcdir)/common -I$(portdir)
-I$(srcdir)/backends/fs -I$(srcdir)/backends/fs/ds -I$(portdir)/data -I$(libndsdir)/include -I$(portdir)/../commoninclude\
-I$(srcdir)/scumm -I$(libndsdir)/include -I$(libndsdir)/include/nds -I$(srcdir)/engines -I$(portdir)/source/mad\
-I$(portdir)/source/libcartreset -include $(srcdir)/common/scummsys.h
-
+
LIBS = -lm -L$(libndsdir)/lib -L$(portdir)/lib -lnds9
ifdef USE_MAD
@@ -352,15 +352,15 @@ PORT_OBJS := $(portdir)/source/blitters_arm.o $(portdir)/source/cdaudio.o $(port
$(portdir)/source/osystem_ds.o $(portdir)/source/portdefs.o $(portdir)/source/ramsave.o\
$(portdir)/source/scummconsole.o $(portdir)/source/touchkeyboard.o $(portdir)/source/zipreader.o\
$(portdir)/source/dsoptions.o $(portdir)/source/keys.o $(portdir)/source/wordcompletion.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
FAT_OBJS := $(portdir)/source/fat/disc_io.o $(portdir)/source/fat/gba_nds_fat.o\
@@ -379,13 +379,13 @@ FAT_OBJS := $(portdir)/source/fat/disc_io.o $(portdir)/source/fat/gba_nds_fat.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
+# $(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 fmopl.cpp rate.cpp mixer.cpp isomap.cpp image.cpp gfx.cpp sprite.cpp actor_path.cpp actor_walk.cpp
-#OPTLIST :=
+#OPTLIST :=
# Compiler options for files which should be optimised for speed
OPT_SPEED := -O3
@@ -394,11 +394,11 @@ OPT_SPEED := -O3
OPT_SIZE := -Os -mthumb -fno-gcse -fno-schedule-insns2
-
-OBJS := $(DATA_OBJS) $(LIBCARTRESET_OBJS) $(PORT_OBJS) $(COMPRESSOR_OBJS) $(FAT_OBJS)
-
-
+OBJS := $(DATA_OBJS) $(LIBCARTRESET_OBJS) $(PORT_OBJS) $(COMPRESSOR_OBJS) $(FAT_OBJS)
+
+
+
MODULE_DIRS += .
ndsall:
@@ -448,7 +448,7 @@ endef
# $(*).tmp $(@)
# echo "extern const u8" $(notdir $*)"[] __attribute__ ((aligned (4)));" > $(*).h
# echo "extern const u32" $(notdir $(*))_size[]";" >> $(*).h
-#
+#
# echo $(*).h
# rm $(*).tmp
#endef
@@ -459,7 +459,7 @@ endef
##############
ifndef HAVE_GCC3
# If you use GCC, disable the above and enable this for intelligent
-# dependency tracking.
+# dependency tracking.
.cpp.o:
$(MKDIR) $(*D)/$(DEPDIR)
@@ -485,36 +485,36 @@ else
$(MKDIR) $(*D)/$(DEPDIR)
$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
- $(CXX) -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" $(if $(findstring $(notdir $<), $(OPTLIST)), $(OPT_SPEED), $(OPT_SIZE)) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
+ $(CXX) -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" $(if $(findstring $(notdir $<), $(OPTLIST)), $(OPT_SPEED), $(OPT_SIZE)) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
endif
#---------------------------------------------------------------------------------
-
+
#---------------------------------------------------------------------------------
%.o : %.pcx
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-
+
#---------------------------------------------------------------------------------
%.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-
+
#---------------------------------------------------------------------------------
%.o : %.raw
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-
+
#---------------------------------------------------------------------------------
%.o : %.pal
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-
+
#---------------------------------------------------------------------------------
%.o : %.map
#---------------------------------------------------------------------------------
@@ -543,4 +543,4 @@ endif
#%.o: %.s
# $(MKDIR) $(*D)/$(DEPDIR)
# $(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
-
+
diff --git a/backends/platform/ds/arm9/source/blitters.cpp b/backends/platform/ds/arm9/source/blitters.cpp
index 582e15eb13..07c6b3fee1 100644
--- a/backends/platform/ds/arm9/source/blitters.cpp
+++ b/backends/platform/ds/arm9/source/blitters.cpp
@@ -27,25 +27,25 @@
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;
-
-
+
+
width &= ~4;
// src = (const byte *) (((int) (src)) & (~4));
// dst = (byte *) (((int) (dst)) & (~4));
// text = (const byte *) (((int) (text)) & (~4));
-
+
asm ( "mov r5, %0\n" // Height
- "yLoop:\n"
+ "yLoop:\n"
"mov r3, #0\n" // X pos
-
+
"xLoop:\n"
-
+
"ldr r4, [%2, r3]\n" // Load text layer word
"cmp r4, %5\n"
"bne singleByteCompare\n"
@@ -54,7 +54,7 @@ void asmDrawStripToScreen(int height, int width, byte const* text, byte const* s
"add r3, r3, #4\n"
"cmp r3, %1\n" // x == width?
"blt xLoop\n"
-
+
"add %2, %2, %8\n" // src += vs->pitch
"add %3, %3, %6\n" // dst += _vm->_screenWidth
"add %4, %4, %7\n" // text += _textSurface.pitch
@@ -62,8 +62,8 @@ void asmDrawStripToScreen(int height, int width, byte const* text, byte const* s
"cmp r5, #0\n" // y == 0?
"bne yLoop\n"
"b end\n"
-
-
+
+
"singleByteCompare:\n"
"ldrb r4, [%2, r3]\n" // Load text byte
"cmps r4, %5, lsr #24\n" // Compare with mask
@@ -78,7 +78,7 @@ void asmDrawStripToScreen(int height, int width, byte const* text, byte const* s
"ldreqb r4, [%3, r3]\n" // Otherwise Load src byte
"streqb r4, [%4, r3]\n" // Store it
"add r3, r3, #1\n"
-
+
"ldrb r4, [%2, r3]\n" // Load text byte
"cmps r4, %5, lsr #24\n" // Compare with mask
"strneb r4, [%4, r3]\n" // Store if not equal
@@ -91,7 +91,7 @@ void asmDrawStripToScreen(int height, int width, byte const* text, byte const* s
"strneb r4, [%4, r3]\n" // Store if not equal
"ldreqb r4, [%3, r3]\n" // Otherwise Load src byte
"streqb r4, [%4, r3]\n" // Store it
- "add r3, r3, #1\n"
+ "add r3, r3, #1\n"
"cmps r3, %1\n" // x == width?
"blt xLoop\n" // Repeat
@@ -101,10 +101,10 @@ void asmDrawStripToScreen(int height, int width, byte const* text, byte const* s
"sub r5, r5, #1\n" // y -= 1
"cmp r5, #0\n" // y == 0?
"bne yLoop\n"
-
+
"end:\n"
: /* no output registers */
- : "r" (height), "r" (width), "r" (text), "r" (src), "r" (dst), "r" (CHARSET_MASK_TRANSPARENCY | (CHARSET_MASK_TRANSPARENCY << 8) | (CHARSET_MASK_TRANSPARENCY << 16) | (CHARSET_MASK_TRANSPARENCY << 24)),
+ : "r" (height), "r" (width), "r" (text), "r" (src), "r" (dst), "r" (CHARSET_MASK_TRANSPARENCY | (CHARSET_MASK_TRANSPARENCY << 8) | (CHARSET_MASK_TRANSPARENCY << 16) | (CHARSET_MASK_TRANSPARENCY << 24)),
"r" (vsPitch), "r" (vmScreenWidth), "r" (textSurfacePitch)
: "r5", "r3", "r4", "%2", "%3", "%4", "memory");
}
@@ -115,7 +115,7 @@ 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"
-
+
"yLoop2:\n"
"ldr r0, [%2, #0]\n"
"str r0, [%0, #0]\n"
@@ -131,7 +131,7 @@ void asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height) {
"add %0, %0, %1\n"
"add %2, %2, %1\n"
"subs %3, %3, #2\n"
- "bne yLoop2\n"
+ "bne yLoop2\n"
: /* no output registers */
: "r" (dst), "r" (dstPitch), "r" (src), "r" (height)
@@ -150,7 +150,7 @@ void ComputeDivBy5TableIFN()
for (int i=0; i<160; ++i)
{
DIV_BY_5[i] = (2*i+5)/10;
- }
+ }
}
#ifdef PERFECT_5_TO_4_RESCALING
@@ -163,13 +163,13 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3
u32 bs3 = s3 & 0x1F;
u32 bs4 = s4 & 0x1F;
-#if 0
+#if 0
u32 gs0 = (s0 >> 5) & 0x1F;
u32 gs1 = (s1 >> 5) & 0x1F;
u32 gs2 = (s2 >> 5) & 0x1F;
u32 gs3 = (s3 >> 5) & 0x1F;
u32 gs4 = (s4 >> 5) & 0x1F;
-
+
u32 rs0 = (s0 >> 10) & 0x1F;
u32 rs1 = (s1 >> 10) & 0x1F;
u32 rs2 = (s2 >> 10) & 0x1F;
@@ -191,22 +191,22 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3
asm("and %0, %2, %1, lsr #10" : "=r"(rs3) : "r"(s3), "r"(mask) : );
asm("and %0, %2, %1, lsr #10" : "=r"(rs4) : "r"(s4), "r"(mask) : );
#endif
-
+
u32 rd0 = 4*rs0 + rs1;
u32 rd1 = 2*rs1 + rs1 + 2*rs2;
u32 rd2 = 2*rs2 + 2*rs3 + rs3;
u32 rd3 = rs3 + 4*rs4;
-
+
u32 gd0 = 4*gs0 + gs1;
u32 gd1 = 2*gs1 + gs1 + 2*gs2;
u32 gd2 = 2*gs2 + 2*gs3 + gs3;
u32 gd3 = gs3 + 4*gs4;
-
+
u32 bd0 = 4*bs0 + bs1;
u32 bd1 = 2*bs1 + bs1 + 2*bs2;
u32 bd2 = 2*bs2 + 2*bs3 + bs3;
u32 bd3 = bs3 + 4*bs4;
-
+
#if 0
// Offsetting for correct rounding
rd0 = rd0*2+5; rd1 = rd1*2+5; rd2 = rd2*2+5; rd3 = rd3*2+5;
@@ -217,14 +217,14 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3
gd0 = (gd0 * 51) >> 9; gd1 = (gd1 * 51) >> 9; gd2 = (gd2 * 51) >> 9; gd3 = (gd3 * 51) >> 9;
bd0 = (bd0 * 51) >> 9; bd1 = (bd1 * 51) >> 9; bd2 = (bd2 * 51) >> 9; bd3 = (bd3 * 51) >> 9;
#else
- rd0 = DIV_BY_5[rd0]; rd1 = DIV_BY_5[rd1]; rd2 = DIV_BY_5[rd2]; rd3 = DIV_BY_5[rd3];
- gd0 = DIV_BY_5[gd0]; gd1 = DIV_BY_5[gd1]; gd2 = DIV_BY_5[gd2]; gd3 = DIV_BY_5[gd3];
- bd0 = DIV_BY_5[bd0]; bd1 = DIV_BY_5[bd1]; bd2 = DIV_BY_5[bd2]; bd3 = DIV_BY_5[bd3];
+ rd0 = DIV_BY_5[rd0]; rd1 = DIV_BY_5[rd1]; rd2 = DIV_BY_5[rd2]; rd3 = DIV_BY_5[rd3];
+ gd0 = DIV_BY_5[gd0]; gd1 = DIV_BY_5[gd1]; gd2 = DIV_BY_5[gd2]; gd3 = DIV_BY_5[gd3];
+ bd0 = DIV_BY_5[bd0]; bd1 = DIV_BY_5[bd1]; bd2 = DIV_BY_5[bd2]; bd3 = DIV_BY_5[bd3];
#endif
-
+
u32 d10 = 0x80008000 | (rd1 << 26) | (gd1 << 21) | (bd1 << 16) | (rd0 << 10) | (gd0 << 5) | bd0;
u32 d32 = 0x80008000 | (rd3 << 26) | (gd3 << 21) | (bd3 << 16) | (rd2 << 10) | (gd2 << 5) | bd2;
-
+
((u32*)dest)[0] = d10;
((u32*)dest)[1] = d32;
}
@@ -233,7 +233,7 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3
u16* dest)
{
static const u32 MASK = 0x03E07C1F;
-
+
u32 argbargbs0 = u32(s0) | (u32(s0) << 16);
u32 argbargbs1 = u32(s1) | (u32(s1) << 16);
u32 argbargbs2 = u32(s2) | (u32(s2) << 16);
@@ -245,32 +245,32 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3
u32 grbs2 = argbargbs2 & MASK;
u32 grbs3 = argbargbs3 & MASK;
u32 grbs4 = argbargbs4 & MASK;
-
+
u32 grbd0 = (3*grbs0 + grbs1) >> 2;
u32 grbd1 = ( grbs1 + grbs2) >> 1;
u32 grbd2 = ( grbs2 + grbs3) >> 1;
u32 grbd3 = ( grbs3 + 3*grbs4) >> 2;
-
+
grbd0 &= MASK;
grbd1 &= MASK;
grbd2 &= MASK;
grbd3 &= MASK;
-
+
u32 d0 = grbd0 | (grbd0 >> 16);
u32 d1 = grbd1 | (grbd1 >> 16);
u32 d2 = grbd2 | (grbd2 >> 16);
u32 d3 = grbd3 | (grbd3 >> 16);
-
- d0 &= 0xFFFF;
- d1 &= 0xFFFF;
- d2 &= 0xFFFF;
- d3 &= 0xFFFF;
-
- d0 |= 0x8000;
- d1 |= 0x8000;
- d2 |= 0x8000;
- d3 |= 0x8000;
-
+
+ d0 &= 0xFFFF;
+ d1 &= 0xFFFF;
+ d2 &= 0xFFFF;
+ d3 &= 0xFFFF;
+
+ d0 |= 0x8000;
+ d1 |= 0x8000;
+ d2 |= 0x8000;
+ d3 |= 0x8000;
+
dest[0] = d0;
dest[1] = d1;
dest[2] = d2;
@@ -287,13 +287,13 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3
u32 bd0 = (d0 << 24) >> 24;
u32 bd1 = (d1 << 24) >> 24;
u32 gd0 = (d0 << 16) >> 24;
- u32 gd1 = (d1 << 16) >> 24;
+ u32 gd1 = (d1 << 16) >> 24;
u32 rd0 = (d0 >> 16);
u32 rd1 = (d1 >> 16);
-
+
rd0 = DIV_BY_5[rd0]; rd1 = DIV_BY_5[rd1];
gd0 = DIV_BY_5[gd0]; gd1 = DIV_BY_5[gd1];
- bd0 = DIV_BY_5[bd0]; bd1 = DIV_BY_5[bd1];
+ bd0 = DIV_BY_5[bd0]; bd1 = DIV_BY_5[bd1];
u32 d10 = 0x80008000 | (rd1 << 26) | (gd1 << 21) | (bd1 << 16) | (rd0 << 10) | (gd0 << 5) | bd0;
((u32*)dest)[0] = d10;
@@ -307,11 +307,11 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3
u32 rd2 = (d2 >> 16);
u32 rd3 = (d3 >> 16);
- rd2 = DIV_BY_5[rd2]; rd3 = DIV_BY_5[rd3];
- gd2 = DIV_BY_5[gd2]; gd3 = DIV_BY_5[gd3];
- bd2 = DIV_BY_5[bd2]; bd3 = DIV_BY_5[bd3];
+ rd2 = DIV_BY_5[rd2]; rd3 = DIV_BY_5[rd3];
+ gd2 = DIV_BY_5[gd2]; gd3 = DIV_BY_5[gd3];
+ bd2 = DIV_BY_5[bd2]; bd3 = DIV_BY_5[bd3];
u32 d32 = 0x80008000 | (rd3 << 26) | (gd3 << 21) | (bd3 << 16) | (rd2 << 10) | (gd2 << 5) | bd2;
-
+
((u32*)dest)[1] = d32;
}
@@ -320,7 +320,7 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3
static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16* dest, const u8* src, const u32* palette)
{
ComputeDivBy5TableIFN();
-
+
for (size_t i=0; i<64; ++i)
{
u32 s0 = palette[src[5*i+0]];
@@ -353,7 +353,7 @@ static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16* dest, const
static inline void Rescale_320x1555Scanline_To_256x1555Scanline(u16* dest, const u16* src)
{
ComputeDivBy5TableIFN();
-
+
for (size_t i=0; i<64; ++i)
{
u16 s0 = src[5*i+0];
@@ -384,7 +384,7 @@ void Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, int destStri
for (size_t i=0; i<200; ++i)
{
- Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam);
+ Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam);
}
}
#else
@@ -396,7 +396,7 @@ void Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, int destStri
for (size_t i=0; i<200; ++i)
{
- Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam);
+ Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam);
}
}
#endif
diff --git a/backends/platform/ds/arm9/source/blitters.h b/backends/platform/ds/arm9/source/blitters.h
index f8c65ed167..7434a58efd 100644
--- a/backends/platform/ds/arm9/source/blitters.h
+++ b/backends/platform/ds/arm9/source/blitters.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#ifndef _BLITTERS_H_
#define _BLITTERS_H_
@@ -29,19 +29,19 @@
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);
}
-
+
#else
extern "C" {
-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);
diff --git a/backends/platform/ds/arm9/source/blitters.s b/backends/platform/ds/arm9/source/blitters.s
index 2f14c5a140..40b8782eec 100644
--- a/backends/platform/ds/arm9/source/blitters.s
+++ b/backends/platform/ds/arm9/source/blitters.s
@@ -21,7 +21,7 @@
@ @author Robin Watts (robin@wss.co.uk)
.text
-
+
.global asmDrawStripToScreen
.global asmCopy8Col
.global Rescale_320x256xPAL8_To_256x256x1555
@@ -142,7 +142,7 @@ asmCopy8Col:
@ r3 = height
STMFD r13!,{r14}
SUB r1,r1,#4
-
+
TST r3,#1
ADDNE r3,r3,#1
BNE roll2
@@ -177,7 +177,7 @@ Rescale_320x256x1555_To_256x256x1555:
@ r2 = dstStride
@ r3 = srcStride
STMFD r13!,{r4-r5,r8-r11,r14}
-
+
SUB r2,r2,#64*5 @ srcStride -= line length
SUB r3,r3,#64*4 @ dstStride -= line length
@@ -187,7 +187,7 @@ Rescale_320x256x1555_To_256x256x1555:
MOV r5, #200 @ r5 = y
yLoop3:
MOV r4, #64 @ r4 = x
-xLoop3:
+xLoop3:
LDRH r9, [r0],#2 @ r9 = src0
LDRH r10,[r0],#2 @ r10= src1
LDRH r11,[r0],#2 @ r11= src2
@@ -212,7 +212,7 @@ xLoop3:
ADD r11,r11,r12 @ r11= dst2
ADD r12,r12,r14 @ r12= src3 + src4
ADD r12,r12,r14,LSL #1 @ r12= src3 + src4*3 = dst3<<2
-
+
AND r9, r8, r9, LSR #2 @ r9 = dst0 (split)
AND r10,r8, r10,LSR #1 @ r10= dst1 (split)
AND r11,r8, r11,LSR #1 @ r11= dst2 (split)
@@ -227,7 +227,7 @@ xLoop3:
ORR r10,r10,#0x8000
ORR r11,r11,#0x8000
ORR r12,r12,#0x8000
-
+
STRH r9, [r1],#2
STRH r10,[r1],#2
STRH r11,[r1],#2
@@ -235,7 +235,7 @@ xLoop3:
SUBS r4,r4,#1
BGT xLoop3
-
+
ADD r0,r0,r2,LSL #1
ADD r1,r2,r3,LSL #1
SUBS r5,r5,#1
@@ -266,7 +266,7 @@ Rescale_320x256xPAL8_To_256x256x1555:
ORR r8, r8,#0x00007C00
ORR r8, r8,#0x03E00000 @ r8 = mask
LDR r9, [r13,#7*4] @ r9 = palette
-
+
SUB r13,r13,#256*4 @ r13 = 1K of space on the stack.
MOV r5, r13 @ r5 points to this space
MOV r14,#256
@@ -277,14 +277,14 @@ palLoop:
AND r10,r10,r8 @ r10 = separated palette entry
STR r10,[r5], #4
BGT palLoop
-
+
SUB r2,r2,#64*5 @ srcStride -= line length
SUB r3,r3,#64*4 @ dstStride -= line length
MOV r5,#200 @ r5 = y
yLoop4:
MOV r4,#64 @ r4 = x
-xLoop4:
+xLoop4:
LDRB r9, [r0],#1 @ r9 = src0
LDRB r10,[r0],#1 @ r10= src1
LDRB r11,[r0],#1 @ r11= src2
@@ -303,7 +303,7 @@ xLoop4:
ADD r11,r11,r12 @ r11= dst2
ADD r12,r12,r14 @ r12= src3 + src4
ADD r12,r12,r14,LSL #1 @ r12= src3 + src4*3 = dst3<<2
-
+
AND r9, r8, r9, LSR #2 @ r9 = dst0 (split)
AND r10,r8, r10,LSR #1 @ r10= dst1 (split)
AND r11,r8, r11,LSR #1 @ r11= dst2 (split)
@@ -318,7 +318,7 @@ xLoop4:
ORR r10,r10,#0x8000
ORR r11,r11,#0x8000
ORR r12,r12,#0x8000
-
+
STRH r9, [r1],#2
STRH r10,[r1],#2
STRH r11,[r1],#2
@@ -326,7 +326,7 @@ xLoop4:
SUBS r4,r4,#1
BGT xLoop4
-
+
ADD r0,r0,r2
ADD r1,r2,r3,LSL #1
SUBS r5,r5,#1
@@ -336,4 +336,4 @@ xLoop4:
LDMFD r13!,{r4-r5,r8-r11,PC}
-
+
diff --git a/backends/platform/ds/arm9/source/cdaudio.cpp b/backends/platform/ds/arm9/source/cdaudio.cpp
index 9569a820f2..2897a9364b 100644
--- a/backends/platform/ds/arm9/source/cdaudio.cpp
+++ b/backends/platform/ds/arm9/source/cdaudio.cpp
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#include "cdaudio.h"
#include "ds-fs.h"
#include "config-manager.h"
@@ -53,9 +53,9 @@ struct WaveHeader {
u16 fmtExtraData; // Number of extra fmt bytes
u16 fmtExtra; // Samples per block (only for IMA-ADPCM files)
} __attribute__ ((packed));
-
+
struct chunkHeader {
- char name[4];
+ char name[4];
u32 size;
} __attribute__ ((packed));
@@ -112,7 +112,7 @@ void decompressBlock();
void allocBuffers() {
-
+
}
void setActive(bool active) {
@@ -125,17 +125,17 @@ bool getActive() {
void playTrack(int track, int numLoops, int startFrame, int duration) {
Common::String path = ConfMan.get("path");
-
+
if (isPlayingFlag) {
stopTrack();
}
-
+
if (trackStartsAt2) {
track++;
}
-
-
-
+
+
+
char str[100];
if (path[strlen(path.c_str()) - 1] == '/') {
@@ -145,50 +145,50 @@ void playTrack(int track, int numLoops, int startFrame, int duration) {
sprintf(str, "/track%d.wav", track);
path = path + str;
}
-
-
+
+
//1820160
-
+
file = DS::std_fopen(path.c_str(), "rb");
-
+
if (!file) {
consolePrintf("Failed to open %s!\n", path.c_str());
return;
}
-
-
+
+
DS::std_fread((const void *) &waveHeader, sizeof(waveHeader), 1, file);
-
+
consolePrintf("Playing track %d\n", track);
consolePrintf("Format: %d\n", waveHeader.fmtFormatTag);
consolePrintf("Rate : %d\n", waveHeader.fmtSamPerSec);
consolePrintf("Bits : %d\n", waveHeader.fmtBitsPerSam);
consolePrintf("BlkSz : %d\n", waveHeader.fmtExtra);
-
+
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);
return;
}
-
+
for (int r = 0; r < 8; r++) {
IPC->adpcm.buffer[r] = (u8 * volatile) (decoderFormat *) malloc(waveHeader.fmtBlockAlign);
IPC->adpcm.filled[r] = false;
IPC->adpcm.arm7Dirty[r] = false;
}
-
+
// Skip chunks until we reach the data chunk
chunkHeader chunk;
DS::std_fread((const void *) &chunk, sizeof(chunkHeader), 1, 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);
}
-
+
dataChunkStart = DS::std_ftell(file);
-
-
+
+
static bool started = false;
sampleNum = 0;
blockCount = 0;
@@ -206,35 +206,35 @@ void playTrack(int track, int numLoops, int startFrame, int duration) {
memset(audioBuffer, 0, BUFFER_SIZE * 2);
memset(decompressionBuffer, 0, waveHeader.fmtExtra * 2);
DS::playSound(audioBuffer, BUFFER_SIZE * 2, false, false, waveHeader.fmtSamPerSec);
-
- }
+
+ }
fillPos = (IPC->streamPlayingSection + 1) & 3;
isPlayingFlag = true;
-
-
+
+
// Startframe is a 75Hz timer. Dunno why, since nothing else
// seems to run at that rate.
int tenths = (startFrame * 10) / 75;
-
+
// Seek to the nearest block start to the start time
int samples = (tenths * waveHeader.fmtSamPerSec) / 10;
int block = samples / waveHeader.fmtExtra;
-
-
+
+
if (duration == 0) {
blocksLeft = 0;
} else {
blocksLeft = ((((duration * 100) / 75) * (waveHeader.fmtSamPerSec)) / (waveHeader.fmtExtra) / 100) + 10;
}
// consolePrintf("Playing %d blocks (%d)\n\n", blocksLeft, 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);
// consolePrintf("Startframe: %d msec: %d (%d,%d)\n", startFrame, tenthssec, samples, block);
}
-
-
+
+
//decompressBlock();
playNextBlock();
DS::CD::numLoops = numLoops;
@@ -252,21 +252,21 @@ extern "C" void ARM_adcpm(int *block, int len, int stepTableIndex,
void decompressBlock() {
int block[2048];
bool loop = false;
-
+
blockCount++;
-
+
if (blockCount < 10) return;
-
-
+
+
do {
DS::std_fread((const void *) &blockHeader, sizeof(blockHeader), 1, file);
-
+
DS::std_fread(&block[0], waveHeader.fmtBlockAlign - sizeof(blockHeader), 1, file);
if (DS::std_feof(file) ) {
// Reached end of file, so loop
-
-
+
+
if ((numLoops == -1) || (numLoops > 1)) {
// Seek file to first packet
if (numLoops != -1) {
@@ -283,14 +283,14 @@ void decompressBlock() {
stopTrack();
return;
}
-
+
} else {
loop = false;
}
-
+
} while (loop);
-
-
+
+
if (blocksLeft > 0) {
blocksLeft--;
// consolePrintf("%d ", blocksLeft);
@@ -305,37 +305,37 @@ void decompressBlock() {
blockHeader.stepTableIndex,
blockHeader.firstSample,
decompressionBuffer);
-#else
+#else
// First sample is in header
decompressionBuffer[0] = blockHeader.firstSample;
-
+
// Set up initial table indeces
int stepTableIndex = blockHeader.stepTableIndex;
int prevSample = blockHeader.firstSample;
-
+
// consolePrintf("Decompressing block step=%d fs=%d\n", stepTableIndex, prevSample);
for (int r = 0; r < waveHeader.fmtExtra - 1; r++) {
-
+
int word = block[r >> 3];
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;
@@ -361,41 +361,41 @@ void decompressBlock() {
break;
}
}
-
+
int diff = 0;
-
+
if (offset & 4) {
diff = diff + stepTab[stepTableIndex];
}
-
+
if (offset & 2) {
diff = diff + (stepTab[stepTableIndex] >> 1);
}
-
+
if (offset & 1) {
diff = diff + (stepTab[stepTableIndex] >> 2);
}
-
+
diff = diff + (stepTab[stepTableIndex] >> 3);
-
+
if (offset & 8) {
- diff = -diff;
+ diff = -diff;
}
-
+
int newSample = prevSample + diff;
-
+
if (newSample > 32767) newSample = 32767;
if (newSample < -32768) newSample = -32768;
-
+
decompressionBuffer[r + 1] = newSample;
-
+
prevSample = newSample;
-
+
stepTableIndex += indexTab[offset];
-
+
if (stepTableIndex > 88) stepTableIndex = 88;
if (stepTableIndex < 0) stepTableIndex = 0;
-
+
}
#endif
@@ -404,21 +404,21 @@ void decompressBlock() {
void playNextBlock() {
if (!isPlayingFlag) return;
int lastBlockId = -1;
-
+
while (IPC->adpcm.semaphore); // Wait for buffer to become free if needed
IPC->adpcm.semaphore = true; // Lock the buffer structure to prevent clashing with the ARM7
// DC_FlushAll();
-
+
//-8644, 25088
for (int block = fillPos + 1; block < fillPos + 4; block++) {
int blockId = block & 3;
-
+
if (IPC->streamFillNeeded[blockId]) {
-
+
IPC->streamFillNeeded[blockId] = false;
// DC_FlushAll();
-
+
/* if (!(REG_KEYINPUT & KEY_R)) {
//consolePrintf("Align: %d First: %d Step:%d Res:%d\n", waveHeader.fmtBlockAlign, blockHeader.firstSample, blockHeader.stepTableIndex, blockHeader.reserved);
consolePrintf("Filling buffer %d\n", blockId);
@@ -432,19 +432,19 @@ void playNextBlock() {
}
}
}
-
+
lastBlockId = blockId;
IPC->streamFillNeeded[blockId] = false;
// DC_FlushAll();
}
-
-
-
+
+
+
}
-
-
-
+
+
+
if (lastBlockId != -1) {
fillPos = lastBlockId;
/* if (!(REG_KEYINPUT & KEY_R)) {
@@ -459,18 +459,18 @@ void stopTrack() {
if (!isPlayingFlag) return;
DS::std_fclose(file);
-
+
isPlayingFlag = false;
-
+
for (int r = 0; r < BUFFER_SIZE; r++) {
audioBuffer[r] = 0;
}
-
+
for (int r= 0; r < waveHeader.fmtExtra; r++) {
decompressionBuffer[r] = 0;
}
// DS::stopSound(1);
-
+
// free(audioBuffer);
// free(decompressionBuffer);
@@ -507,7 +507,7 @@ bool trackExists(int num) {
bool checkCD() {
// Need to check whethe CD audio files are present - do this by trying to open Track1.wav.
consolePrintf("Attempted to open cd drive\n");
-
+
if (trackExists(1)) {
trackStartsAt2 = false;
return true;
diff --git a/backends/platform/ds/arm9/source/cdaudio.h b/backends/platform/ds/arm9/source/cdaudio.h
index d237569bb7..a4a1a0bce9 100644
--- a/backends/platform/ds/arm9/source/cdaudio.h
+++ b/backends/platform/ds/arm9/source/cdaudio.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#ifndef _CDAUDIO_H_
#define _CDAUDIO_H_
diff --git a/backends/platform/ds/arm9/source/console2.h b/backends/platform/ds/arm9/source/console2.h
index 6b9a677cc7..86434dcb93 100644
--- a/backends/platform/ds/arm9/source/console2.h
+++ b/backends/platform/ds/arm9/source/console2.h
@@ -25,7 +25,7 @@
//
// Changelog:
// 0.1: First version
-// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
+// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
// Changed some register defines for consistency.
//
//////////////////////////////////////////////////////////////////////
@@ -87,7 +87,7 @@ void consoleClear(void);
//
// Changelog:
// 0.1: First version
-// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
+// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
// Changed some register defines for consistency.
//
//////////////////////////////////////////////////////////////////////
diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp
index 07eb222dfb..45b76fe0f1 100644
--- a/backends/platform/ds/arm9/source/dsmain.cpp
+++ b/backends/platform/ds/arm9/source/dsmain.cpp
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
// - Remove scummconsole.c
// - Delete files
@@ -221,7 +221,7 @@ int hBlankCount = 0;
gameListType gameList[NUM_SUPPORTED_GAMES] = {
// Unknown game - use normal SCUMM controls
{"unknown", CONT_SCUMM_ORIGINAL},
-
+
// SCUMM games
{"maniac", CONT_SCUMM_ORIGINAL},
{"zak", CONT_SCUMM_ORIGINAL},
@@ -232,7 +232,7 @@ gameListType gameList[NUM_SUPPORTED_GAMES] = {
{"monkey2", CONT_SCUMM_ORIGINAL},
{"tentacle", CONT_SCUMM_ORIGINAL},
{"samnmax", CONT_SCUMM_SAMNMAX},
-
+
// Non-SCUMM games
{"sky", CONT_SKY},
{"simon1", CONT_SIMON},
@@ -298,11 +298,11 @@ void setCpuScalerEnable(bool enable) {
//plays an 8 bit mono sample at 11025Hz
void playSound(const void* data, u32 length, bool loop, bool adpcm, int rate)
{
-
+
if (!IPC->soundData) {
soundControl.count = 0;
}
-
+
soundControl.data[soundControl.count].data = data;
soundControl.data[soundControl.count].len = length | (loop? 0x80000000: 0x00000000);
soundControl.data[soundControl.count].rate = rate; // 367 samples per frame
@@ -346,14 +346,14 @@ void initSprites() {
sprites[i].attribute[2] = 0;
sprites[i].attribute[3] = 0;
}
-
+
for (int i = 0; i < 128; i++) {
spritesMain[i].attribute[0] = ATTR0_DISABLED;
spritesMain[i].attribute[1] = 0;
spritesMain[i].attribute[2] = 0;
spritesMain[i].attribute[3] = 0;
}
-
+
updateOAM();
}
@@ -388,7 +388,7 @@ void restoreGameBackBuffer() {
*dst++ = *src;
*dst2++ = *src++;
}
-
+
}
delete savedBuffer;
@@ -414,22 +414,22 @@ void startSound(int freq, int buffer) {
bufferFirstHalf = false;
bufferSecondHalf = true;
-
+
int bytes = (2 * (bufferSamples)) + 100;
-
+
soundBuffer = (s16 *) malloc(bytes * 2);
if (!soundBuffer)
consolePrintf("Sound buffer alloc failed\n");
soundHiPart = true;
-
+
for (int r = 0; r < bytes; r++) {
soundBuffer[r] = 0;
}
soundFrequency = freq;
-
+
swiWaitForVBlank();
swiWaitForVBlank();
@@ -461,14 +461,14 @@ void initGame() {
consolePrintf("\n\n\n\nCurrent game: '%s' %d\n", gameName, gameName[0]);
currentGame = &gameList[0]; // Default game
-
+
for (int r = 0; r < NUM_SUPPORTED_GAMES; r++) {
if (!stricmp(gameName, gameList[r].gameId)) {
currentGame = &gameList[r];
// consolePrintf("Game list num: %d\n", currentGame);
}
}
-
+
if (firstTime) {
firstTime = false;
@@ -515,7 +515,7 @@ void displayMode8Bit() {
consolePrintf("displayMode8Bit...");
#endif
u16 buffer[32 * 32];
-
+
setKeyboardEnable(false);
if (!displayModeIs8Bit) {
@@ -523,20 +523,20 @@ void displayMode8Bit() {
buffer[r] = ((u16 *) SCREEN_BASE_BLOCK_SUB(4))[r];
}
}
-
+
if (isCpuScalerEnabled())
{
- videoSetMode(MODE_5_2D | (consoleEnable? DISPLAY_BG0_ACTIVE: 0) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP);
+ videoSetMode(MODE_5_2D | (consoleEnable? DISPLAY_BG0_ACTIVE: 0) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP);
videoSetModeSub(MODE_3_2D /*| DISPLAY_BG0_ACTIVE*/ | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); //sub bg 0 will be used to print text
-
+
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
vramSetBankB(VRAM_B_MAIN_BG_0x06020000);
-
+
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
vramSetBankD(VRAM_D_MAIN_BG_0x06040000);
-
+
vramSetBankH(VRAM_H_LCD);
-
+
BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(8);
BG3_XDX = 256;
@@ -546,27 +546,27 @@ void displayMode8Bit() {
}
else
{
- videoSetMode(MODE_5_2D | (consoleEnable? DISPLAY_BG0_ACTIVE: 0) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP);
+ videoSetMode(MODE_5_2D | (consoleEnable? DISPLAY_BG0_ACTIVE: 0) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP);
videoSetModeSub(MODE_3_2D /*| DISPLAY_BG0_ACTIVE*/ | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); //sub bg 0 will be used to print text
-
+
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
vramSetBankB(VRAM_B_MAIN_BG_0x06020000);
-
+
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
vramSetBankD(VRAM_D_MAIN_BG_0x06040000);
-
+
vramSetBankH(VRAM_H_LCD);
-
+
BG3_CR = BG_BMP8_512x256 | BG_BMP_BASE(8);
-
+
BG3_XDX = (int) (((float) (gameWidth) / 256.0f) * 256);
BG3_XDY = 0;
BG3_YDX = 0;
BG3_YDY = (int) ((200.0f / 192.0f) * 256);
- }
-
+ }
+
SUB_BG3_CR = BG_BMP8_512x256;
-
+
SUB_BG3_XDX = (int) (subScreenWidth / 256.0f * 256);
SUB_BG3_XDY = 0;
SUB_BG3_YDX = 0;
@@ -578,24 +578,24 @@ void displayMode8Bit() {
BG0_CR = BG_MAP_BASE(2) | BG_TILE_BASE(0);
BG0_Y0 = 0;
-
- // Restore palette entry used by text in the front-end
+
+ // Restore palette entry used by text in the front-end
// PALETTE_SUB[255] = savedPalEntry255;
-
+
consoleInitDefault((u16*)SCREEN_BASE_BLOCK(2), (u16*)CHAR_BASE_BLOCK(0), 16);
consolePrintSet(0, 23);
-
+
if (!displayModeIs8Bit) {
for (int r = 0; r < 32 * 32; r++) {
((u16 *) SCREEN_BASE_BLOCK(2))[r] = buffer[r];
}
// dmaCopyHalfWords(3, (u16 *) SCREEN_BASE_BLOCK(0), buffer, 32 * 32 * 2);
}
-
+
initGame();
-
+
if (!displayModeIs8Bit) restoreGameBackBuffer();
displayModeIs8Bit = true;
#ifdef HEAVY_LOGGING
@@ -604,9 +604,9 @@ void displayMode8Bit() {
POWER_CR &= ~POWER_SWAP_LCDS;
-
+
keyboardEnable = false;
-
+
}
void setGameID(int id) {
@@ -619,22 +619,22 @@ void dummyHandler() {
void checkSleepMode() {
if (IPC->performArm9SleepMode) {
-
+
consolePrintf("ARM9 Entering sleep mode\n");
-
+
int intSave = REG_IE;
irqSet(IRQ_VBLANK, dummyHandler);
// int irqHandlerSave = (int) IRQ_HANDLER;
REG_IE = IRQ_VBLANK;
//IRQ_HANDLER = dummyHandler;
-
+
int powerSave = POWER_CR;
POWER_CR &= ~POWER_ALL;
-
+
while (IPC->performArm9SleepMode) {
swiWaitForVBlank();
}
-
+
POWER_CR = powerSave;
// IRQ_HANDLER = (void (*)()) irqHandlerSave;
irqSet(IRQ_VBLANK, VBlankHandler);
@@ -671,14 +671,14 @@ void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor, int hotspotX,
{
int off = 128*64;
-
-
+
+
memset(SPRITE_GFX + off, 0, 32 * 32 * 2);
-
+
for (uint y=0; y<h; y++) {
for (uint x=0; x<w; x++) {
int color = icon[y*w+x];
-
+
if (color == keycolor) {
SPRITE_GFX[off+(y)*32+x] = 0x0000; // black background
} else {
@@ -686,22 +686,22 @@ void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor, int hotspotX,
}
}
}
-
+
}
if (currentGame->control != CONT_SCUMM_SAMNMAX)
return;
uint16 border = RGB15(24,24,24) | 0x8000;
-
-
+
+
int off = 48*64;
memset(SPRITE_GFX_SUB+off, 0, 64*64*2);
-
+
int pos = 190 - (w+2);
-
-
+
+
// make border
for (uint i=0; i<w+2; i++) {
SPRITE_GFX_SUB[off+i] = border;
@@ -711,7 +711,7 @@ void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor, int hotspotX,
SPRITE_GFX_SUB[off+(i*64)] = border;
SPRITE_GFX_SUB[off+(i*64)+(w+1)] = border;
}
-
+
int offset = (32 - h) >> 1;
for (uint y=0; y<h; y++) {
@@ -725,8 +725,8 @@ void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor, int hotspotX,
}
}
}
-
-
+
+
if ((cursorEnable))
{
sprites[1].attribute[0] = ATTR0_BMP | 150;
@@ -758,7 +758,7 @@ void displayMode16Bit() {
}
- videoSetMode(MODE_5_2D | /*DISPLAY_BG0_ACTIVE |*/ DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP);
+ videoSetMode(MODE_5_2D | /*DISPLAY_BG0_ACTIVE |*/ DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP);
videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE |/* DISPLAY_BG1_ACTIVE |*/ DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); //sub bg 0 will be used to print text
vramSetBankA(VRAM_A_MAIN_BG);
@@ -769,14 +769,14 @@ void displayMode16Bit() {
BG3_CR = BG_BMP16_512x256;
highBuffer = false;
-
+
BG3_XDX = isCpuScalerEnabled() ? 256 : (int) (1.25f * 256);
BG3_XDY = 0;
BG3_YDX = 0;
BG3_YDY = (int) ((200.0f / 192.0f) * 256);
memset(BG_GFX, 0, 512 * 256 * 2);
-
+
savedPalEntry255 = PALETTE_SUB[255];
PALETTE_SUB[255] = RGB15(31,31,31);//by default font will be rendered with color 255
@@ -795,11 +795,11 @@ void displayMode16Bit() {
consolePrintSet(0, 23);
consolePrintf("\n");
-
+
// Show keyboard
SUB_BG1_CR = BG_TILE_BASE(1) | BG_MAP_BASE(12);
//drawKeyboard(1, 12);
-
+
POWER_CR &= ~POWER_SWAP_LCDS;
displayModeIs8Bit = false;
@@ -816,10 +816,10 @@ void displayMode16BitFlipBuffer() {
#endif
if (!displayModeIs8Bit) {
u16* back = get16BitBackBuffer();
-
+
// highBuffer = !highBuffer;
// BG3_CR = BG_BMP16_512x256 | BG_BMP_RAM(highBuffer? 1: 0);
-
+
if (isCpuScalerEnabled())
{
Rescale_320x256x1555_To_256x256x1555(BG_GFX, back, 512, 512);
@@ -842,11 +842,11 @@ void displayMode16BitFlipBuffer() {
const u8* back = (const u8*)get8BitBackBuffer();
u16* base = BG_GFX + 0x10000;
Rescale_320x256xPAL8_To_256x256x1555( base,
- back,
+ back,
256,
512,
BG_PALETTE );
-
+
#ifdef SCALER_PROFILE
// 10 pixels : 1ms
u16 t1 = TIMER1_DATA;
@@ -899,10 +899,10 @@ void doSoundCallback() {
if (soundCallback) {
lastCallbackFrame = frameCount;
-
+
for (int r = IPC->playingSection; r < IPC->playingSection + 4; r++) {
int chunk = r & 3;
-
+
if (IPC->fillNeeded[chunk]) {
IPC->fillNeeded[chunk] = false;
DC_FlushAll();
@@ -910,9 +910,9 @@ void doSoundCallback() {
IPC->fillNeeded[chunk] = false;
DC_FlushAll();
}
-
+
}
-
+
}
#ifdef HEAVY_LOGGING
consolePrintf("done\n");
@@ -924,7 +924,7 @@ void doTimerCallback() {
if (callbackTimer <= 0) {
callbackTimer += callbackInterval;
callback(callbackInterval);
- }
+ }
}
}
@@ -933,15 +933,15 @@ void soundUpdate() {
// playSound(soundBuffer, (bufferSamples * 2), true);
}
// consolePrintf("%x\n", IPC->test);
-
-
+
+
if (bufferFrame == 0) {
// bufferFirstHalf = true;
- }
+ }
if (bufferFrame == bufferSize >> 1) {
//bufferSecondHalf = true;
- }
-
+ }
+
bufferFrame++;
if (bufferFrame == bufferSize) {
bufferFrame = 0;
@@ -954,20 +954,20 @@ void memoryReport() {
do {
p = (int *) malloc(r * 8192);
free(p);
- r++;
+ r++;
} while ((p) && (r < 512));
-
+
int t = -1;
void* block[1024];
do {
t++;
block[t] = (int *) malloc(4096);
- } while ((t < 1024) && (block[t]));
-
+ } while ((t < 1024) && (block[t]));
+
for (int q = 0; q < t; q++) {
free(block[q]);
}
-
+
consolePrintf("Free: %dK, Largest: %dK\n", t * 4, r * 8);
}
@@ -978,7 +978,7 @@ void addIndyFightingKeys() {
event.type = Common::EVENT_KEYDOWN;
event.kbd.flags = 0;
-
+
// consolePrintf("Fight keys\n");
if ((getKeysDown() & KEY_L)) {
@@ -1008,16 +1008,16 @@ void addIndyFightingKeys() {
event.kbd.keycode = Common::KEYCODE_6;
event.kbd.ascii = '6';
system->addEvent(event);
- }
+ }
if ((getKeysChanged() & KEY_DOWN)) {
event.type = getKeyEvent(KEY_DOWN);
event.kbd.keycode = Common::KEYCODE_2;
event.kbd.ascii = '2';
system->addEvent(event);
}
-
+
if (indyFightRight) {
-
+
if ((getKeysChanged() & KEY_X)) {
event.type = getKeyEvent(KEY_X);
event.kbd.keycode = Common::KEYCODE_9;
@@ -1035,7 +1035,7 @@ void addIndyFightingKeys() {
event.kbd.keycode = Common::KEYCODE_3;
event.kbd.ascii = '3';
system->addEvent(event);
- }
+ }
} else {
@@ -1056,18 +1056,18 @@ void addIndyFightingKeys() {
event.kbd.keycode = Common::KEYCODE_1;
event.kbd.ascii = '1';
system->addEvent(event);
- }
-
+ }
+
}
-
-
+
+
if ((getKeysChanged() & KEY_Y)) {
event.type = getKeyEvent(KEY_Y);
event.kbd.keycode = Common::KEYCODE_5;
event.kbd.ascii = '5';
system->addEvent(event);
}
-}
+}
void setKeyboardEnable(bool en) {
@@ -1079,8 +1079,8 @@ void setKeyboardEnable(bool en) {
DS::drawKeyboard(1, 15, backupBank);
-
-
+
+
SUB_BG1_CR = BG_TILE_BASE(1) | BG_MAP_BASE(15);
if (displayModeIs8Bit) {
@@ -1098,25 +1098,25 @@ void setKeyboardEnable(bool en) {
for (int r = 0; r < 256; r++) {
BG_PALETTE_SUB[r] = BG_PALETTE[r];
}
-
-
+
+
//restoreVRAM(1, 12, backupBank);
-
+
if (displayModeIs8Bit) {
// Copy the sub screen VRAM from the top screen - they should always be
// the same.
u16* buffer = get8BitBackBuffer();
-
+
for (int r = 0; r < (512 * 256) >> 1; r++)
BG_GFX_SUB[r] = buffer[r];
-
+
SUB_DISPLAY_CR &= ~DISPLAY_BG1_ACTIVE; // Turn off keyboard layer
SUB_DISPLAY_CR |= DISPLAY_BG3_ACTIVE; // Turn on game layer
} else {
SUB_DISPLAY_CR &= ~DISPLAY_BG1_ACTIVE; // Turn off keyboard layer
SUB_DISPLAY_CR |= DISPLAY_BG0_ACTIVE; // Turn on console layer
}
-
+
lcdSwap();
}
}
@@ -1136,7 +1136,7 @@ void addEventsToQueue() {
OSystem_DS* system = OSystem_DS::instance();
Common::Event event;
-
+
#ifdef USE_PROFILER
if (keysDown() & KEY_R) {
cygprofile_begin();
@@ -1148,7 +1148,7 @@ void addEventsToQueue() {
}
#endif
-
+
if (system->isEventQueueEmpty()) {
/*
@@ -1157,7 +1157,7 @@ void addEventsToQueue() {
consolePrintf("Tweak: %d\n", tweak);
IPC->tweakChanged = true;
}
-
+
if (getKeysDown() & KEY_R) {
tweak++;
@@ -1173,14 +1173,14 @@ void addEventsToQueue() {
if (!indyFightState) {
- if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) && (getKeysDown() & KEY_B)) {
+ if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) && (getKeysDown() & KEY_B)) {
if (currentGame->control == CONT_AGI) {
event.kbd.keycode = Common::KEYCODE_RETURN;
event.kbd.ascii = 13;
event.kbd.flags = 0;
} else {
- event.kbd.keycode = Common::KEYCODE_ESCAPE;
- event.kbd.ascii = 27;
+ event.kbd.keycode = Common::KEYCODE_ESCAPE;
+ event.kbd.ascii = 27;
event.kbd.flags = 0;
}
@@ -1190,11 +1190,11 @@ void addEventsToQueue() {
event.type = Common::EVENT_KEYUP;
system->addEvent(event);
}
-
+
}
-
-
-
+
+
+
if ((!getIndyFightState()) && (getKeysDown() & KEY_Y)) {
consoleEnable = !consoleEnable;
if (displayModeIs8Bit) {
@@ -1203,7 +1203,7 @@ void addEventsToQueue() {
displayMode16Bit();
}
}
-
+
if ((getKeyboardEnable())) {
event.kbd.flags = 0;
@@ -1211,30 +1211,30 @@ void addEventsToQueue() {
bool release = getKeysReleased() & (KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN);
bool shoulders = getKeysHeld() & (KEY_L | KEY_R);
- if ( (down && (!shoulders)) || release)
+ if ( (down && (!shoulders)) || release)
{
-
+
if (getKeysChanged() & KEY_LEFT) {
event.kbd.keycode = Common::KEYCODE_LEFT;
event.kbd.ascii = 0;
event.type = getKeyEvent(KEY_LEFT);
system->addEvent(event);
}
-
+
if (getKeysChanged() & KEY_RIGHT) {
event.kbd.keycode = Common::KEYCODE_RIGHT;
event.kbd.ascii = 0;
event.type = getKeyEvent(KEY_RIGHT);
system->addEvent(event);
}
-
+
if (getKeysChanged() & KEY_UP) {
event.kbd.keycode = Common::KEYCODE_UP;
event.kbd.ascii = 0;
event.type = getKeyEvent(KEY_UP);
system->addEvent(event);
}
-
+
if (getKeysChanged() & KEY_DOWN) {
event.kbd.keycode = Common::KEYCODE_DOWN;
event.kbd.ascii = 0;
@@ -1242,15 +1242,15 @@ void addEventsToQueue() {
system->addEvent(event);
}
}
-
+
}
-
+
if (!((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) && (!getIndyFightState()) && (!getKeyboardEnable())) {
if ((getKeysDown() & KEY_A) && (!indyFightState)) {
gameScreenSwap = !gameScreenSwap;
}
-
+
if (!getPenHeld() || (mouseMode != MOUSE_HOVER)) {
if (getKeysDown() & KEY_LEFT) {
mouseMode = MOUSE_LEFT;
@@ -1264,7 +1264,7 @@ void addEventsToQueue() {
system->addEvent(event);
rightButtonDown = false;
}
-
+
if (getKeysDown() & KEY_RIGHT) {
if ((currentGame->control != CONT_SCUMM_SAMNMAX) && (currentGame->control != CONT_FUTURE_WARS) && (currentGame->control != CONT_GOBLINS)) {
@@ -1281,13 +1281,13 @@ void addEventsToQueue() {
} else {
event.mouse = Common::Point(getPenX(), getPenY());
}
-
+
rightButtonDown = true;
-
+
event.type = Common::EVENT_RBUTTONDOWN;
system->addEvent(event);
-
+
//event.type = Common::EVENT_RBUTTONUP;
//system->addEvent(event);
}
@@ -1299,9 +1299,9 @@ void addEventsToQueue() {
mouseMode = MOUSE_HOVER;
}
}
-
-
-
+
+
+
}
if ((getKeysDown() & KEY_SELECT)) {
@@ -1310,18 +1310,18 @@ void addEventsToQueue() {
showOptionsDialog();
}
-
+
}
-
+
if (!getIndyFightState() && !((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) && (getKeysDown() & KEY_X)) {
setKeyboardEnable(!keyboardEnable);
}
-
- updateStatus();
-
+
+ updateStatus();
+
Common::Event event;
-
+
if (!keyboardEnable) {
if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) {
@@ -1332,12 +1332,12 @@ void addEventsToQueue() {
}
if ((mouseMode != MOUSE_HOVER) || (!displayModeIs8Bit)) {
- if (getPenDown() && (!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) {
+ if (getPenDown() && (!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) {
event.type = ((mouseMode == MOUSE_LEFT) || (!displayModeIs8Bit))? Common::EVENT_LBUTTONDOWN: Common::EVENT_RBUTTONDOWN;
event.mouse = Common::Point(getPenX(), getPenY());
system->addEvent(event);
}
-
+
if (getPenReleased()) {
event.type = mouseMode == MOUSE_LEFT? Common::EVENT_LBUTTONUP: Common::EVENT_RBUTTONUP;
event.mouse = Common::Point(getPenX(), getPenY());
@@ -1345,7 +1345,7 @@ void addEventsToQueue() {
}
} else {
// In hover mode, D-pad left and right click the mouse when the pen is on the screen
-
+
if (getPenHeld()) {
if (getKeysDown() & KEY_LEFT) {
event.type = Common::EVENT_LBUTTONDOWN;
@@ -1357,7 +1357,7 @@ void addEventsToQueue() {
event.mouse = Common::Point(getPenX(), getPenY());
system->addEvent(event);
}*/
-
+
if (getKeysDown() & KEY_RIGHT) {
event.type = Common::EVENT_RBUTTONDOWN;
event.mouse = Common::Point(getPenX(), getPenY());
@@ -1370,11 +1370,11 @@ void addEventsToQueue() {
}*/
}
}
-
+
if (((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) || (indyFightState)) && (displayModeIs8Bit)) {
// Controls specific to the control method
-
-
+
+
if (currentGame->control == CONT_SKY) {
// Extra controls for Beneath a Steel Sky
if ((getKeysDown() & KEY_DOWN)) {
@@ -1387,7 +1387,7 @@ void addEventsToQueue() {
// Extra controls for Simon the Sorcerer
if ((getKeysDown() & KEY_DOWN)) {
Common::Event event;
-
+
event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = Common::KEYCODE_F10; // F10 or # - show hotspots
event.kbd.ascii = Common::ASCII_F10;
@@ -1400,13 +1400,13 @@ void addEventsToQueue() {
}
}
-
-
+
+
if (currentGame->control == CONT_SCUMM_ORIGINAL) {
// Extra controls for Scumm v1-5 games
if ((getKeysDown() & KEY_DOWN)) {
Common::Event event;
-
+
event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = Common::KEYCODE_PERIOD; // Full stop - skips current dialogue line
event.kbd.ascii = '.';
@@ -1416,19 +1416,19 @@ void addEventsToQueue() {
event.type = Common::EVENT_KEYUP;
system->addEvent(event);
}
-
+
if (indyFightState) {
addIndyFightingKeys();
}
-
+
}
-
+
}
}
-
+
if (!displayModeIs8Bit) {
// Front end controls
-
+
if (leftHandedSwap(getKeysChanged()) & KEY_UP) {
event.type = getKeyEvent(leftHandedSwap(KEY_UP));
event.kbd.keycode = Common::KEYCODE_UP;
@@ -1455,10 +1455,10 @@ void addEventsToQueue() {
event.type = Common::EVENT_KEYUP;
system->addEvent(event);
}
-
+
}
-
+
if ((getKeysChanged() & KEY_START)) {
event.type = getKeyEvent(KEY_START);
if (currentGame->control == CONT_FUTURE_WARS) {
@@ -1481,34 +1481,34 @@ void addEventsToQueue() {
system->addEvent(event);
}
-
+
if (keyboardEnable) {
DS::addKeyboardEvents();
}
-
+
consumeKeys();
-
+
consumePenEvents();
}
}
-
+
void triggerIcon(int imageNum) {
triggeredIcon = imageNum;
- triggeredIconTimeout = 120;
+ triggeredIconTimeout = 120;
}
-
+
void setIcon(int num, int x, int y, int imageNum, int flags, bool enable) {
- sprites[num].attribute[0] = ATTR0_BMP | (enable? y: 192) | (!enable? ATTR0_DISABLED: 0);
+ sprites[num].attribute[0] = ATTR0_BMP | (enable? y: 192) | (!enable? ATTR0_DISABLED: 0);
sprites[num].attribute[1] = ATTR1_SIZE_32 | x | flags;
sprites[num].attribute[2] = ATTR2_ALPHA(1)| (imageNum * 16);
}
void setIconMain(int num, int x, int y, int imageNum, int flags, bool enable) {
- spritesMain[num].attribute[0] = ATTR0_BMP | (y & 0xFF) | (!enable? ATTR0_DISABLED: 0);
+ spritesMain[num].attribute[0] = ATTR0_BMP | (y & 0xFF) | (!enable? ATTR0_DISABLED: 0);
spritesMain[num].attribute[1] = ATTR1_SIZE_32 | (x & 0x1FF) | flags;
spritesMain[num].attribute[2] = ATTR2_ALPHA(1)| (imageNum * 16);
}
@@ -1536,16 +1536,16 @@ void updateStatus() {
break;
}
}
-
+
setIcon(0, 208, 150, offs, 0, true);
-
+
if (indyFightState) {
setIcon(1, (190 - 32), 150, 3, (indyFightRight? 0: ATTR1_FLIP_X), true);
// consolePrintf("%d\n", indyFightRight);
} else {
// setIcon(1, 0, 0, 0, 0, false);
}
-
+
if (triggeredIconTimeout > 0) {
triggeredIconTimeout--;
setIcon(4, 16, 150, triggeredIcon, 0, true);
@@ -1584,7 +1584,7 @@ void soundBufferEmptyHandler() {
} else {
// bufferFirstHalf = true;
}
-
+
soundHiPart = !soundHiPart;
}
@@ -1595,7 +1595,7 @@ void setMainScreenScroll(int x, int y) {
} else {
BG3_CX = x + (((frameCount & 1) == 0)? 64: 0);
BG3_CY = y;
-
+
touchX = x >> 8;
touchY = y >> 8;
}
@@ -1616,13 +1616,13 @@ void setMainScreenScale(int x, int y) {
BG3_YDY = y;
}
else
- {
+ {
BG3_XDX = x;
BG3_XDY = 0;
BG3_YDX = 0;
BG3_YDY = y;
}
-
+
touchScX = x;
touchScY = y;
}
@@ -1632,7 +1632,7 @@ void setZoomedScreenScroll(int x, int y, bool shake) {
if (gameScreenSwap) {
BG3_CX = x + ((shake && ((frameCount & 1) == 0))? 64: 0);
BG3_CY = y;
-
+
touchX = x >> 8;
touchY = y >> 8;
} else {
@@ -1684,7 +1684,7 @@ void VBlankHandler(void) {
soundUpdate();
-
+
if ((!gameScreenSwap) && (!(getKeysHeld() & KEY_L) && !(getKeysHeld() & KEY_R))) {
if (currentGame) {
@@ -1699,14 +1699,14 @@ void VBlankHandler(void) {
}
}
}
-
+
penUpdate();
keysUpdate();
frameCount++;
-
+
if ((cursorEnable) && (mouseCursorVisible))
{
if (!keyboardEnable) {
@@ -1725,31 +1725,31 @@ void VBlankHandler(void) {
if (callback) {
callbackTimer -= FRAME_TIME;
}
-
+
if ((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) {
-
+
if ((!dragging) && (getPenHeld()) && (penDownFrames > 5)) {
dragging = true;
dragStartX = penX;
dragStartY = penY;
-
+
if (gameScreenSwap) {
dragScX = subScTargetX;
dragScY = subScTargetY;
} else {
dragScX = scX;
- dragScY = scY;
- }
-
-
+ dragScY = scY;
+ }
+
+
}
-
+
if ((dragging) && (!getPenHeld())) {
dragging = false;
}
-
+
if (dragging) {
-
+
if (gameScreenSwap) {
subScTargetX = dragScX + ((dragStartX - penX) << 8);
subScTargetY = dragScY + ((dragStartY - penY) << 8);
@@ -1757,18 +1757,18 @@ void VBlankHandler(void) {
scX = dragScX + ((dragStartX - penX));
scY = dragScY + ((dragStartY - penY));
}
-
+
// consolePrintf("X:%d Y:%d\n", dragStartX - penX, dragStartY - penY);
}
- }
-
-
+ }
+
+
/* if ((frameCount & 1) == 0) {
SUB_BG3_CX = subScX;
} else {
SUB_BG3_CX = subScX + 64;
}
-
+
SUB_BG3_CY = subScY + (shakePos << 8);*/
/*SUB_BG3_XDX = (int) (subScreenWidth / 256.0f * 256);
@@ -1777,33 +1777,33 @@ void VBlankHandler(void) {
SUB_BG3_YDY = (int) (subScreenHeight / 192.0f * 256);*/
static int ratio = ( 320 << 8) / SCUMM_GAME_WIDTH;
-
+
bool zooming = false;
-
+
if ((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) {
if ((getKeysHeld() & KEY_A) && (subScreenScale < ratio)) {
subScreenScale += 1;
zooming = true;
}
-
+
if ((getKeysHeld() & KEY_B) && (subScreenScale > 128)) {
subScreenScale -=1;
zooming = true;
}
}
-
+
int xCenter = subScTargetX + ((subScreenWidth >> 1) << 8);
int yCenter = subScTargetY + ((subScreenHeight >> 1) << 8);
-
+
if (twoHundredPercentFixedScale) {
subScreenWidth = 256 >> 1;
subScreenHeight = 192 >> 1;
} else {
subScreenWidth = (((SCUMM_GAME_HEIGHT * 256) / 192) * subScreenScale) >> 8;
subScreenHeight = SCUMM_GAME_HEIGHT * subScreenScale >> 8;
-
+
if ( ((subScreenWidth) > 256 - 8) && ((subScreenWidth) < 256 + 8) ) {
subScreenWidth = 256;
subScreenHeight = 192;
@@ -1832,13 +1832,13 @@ void VBlankHandler(void) {
//triggerIcon(-1);
}
}
-
+
subScTargetX = xCenter - ((subScreenWidth >> 1) << 8);
subScTargetY = yCenter - ((subScreenHeight >> 1) << 8);
-
-
+
+
if (subScTargetX < 0) subScTargetX = 0;
if (subScTargetX > (gameWidth - subScreenWidth) << 8) subScTargetX = (gameWidth - subScreenWidth) << 8;
@@ -1850,30 +1850,30 @@ void VBlankHandler(void) {
subScX += (subScTargetX - subScX) >> 2;
subScY += (subScTargetY - subScY) >> 2;
-
+
if (displayModeIs8Bit) {
-
+
if ((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) {
-
+
int offsX = 0, offsY = 0;
if (getKeysHeld() & KEY_LEFT) {
offsX -= 1;
}
-
+
if (getKeysHeld() & KEY_RIGHT) {
offsX += 1;
}
-
+
if (getKeysHeld() & KEY_UP) {
offsY -= 1;
}
-
+
if (getKeysHeld() & KEY_DOWN) {
offsY += 1;
}
-
+
if (((gameScreenSwap) && (getKeysHeld() & KEY_L)) || ((!gameScreenSwap) && (getKeysHeld() & KEY_R))) {
subScTargetX += offsX << 8;
subScTargetY += offsY << 8;
@@ -1884,32 +1884,32 @@ void VBlankHandler(void) {
}
if (!scaledMode) {
-
+
if (scX + 256 > gameWidth - 1) {
scX = gameWidth - 1 - 256;
}
-
+
if (scX < 0) {
scX = 0;
}
-
+
if (scY + 192 > gameHeight - 1) {
scY = gameHeight - 1 - 192;
}
-
+
if (scY < 0) {
scY = 0;
}
-
+
setZoomedScreenScroll(subScX, subScY, (subScreenWidth != 256) && (subScreenWidth != 128));
setZoomedScreenScale(subScreenWidth, ((subScreenHeight * (256 << 8)) / 192) >> 8);
-
-
+
+
setMainScreenScroll(scX << 8, (scY << 8) + (shakePos << 8));
setMainScreenScale(256, 256); // 1:1 scale
-
+
} else {
-
+
if (scY > gameHeight - 192 - 1) {
scY = gameHeight - 192 - 1;
}
@@ -1917,13 +1917,13 @@ void VBlankHandler(void) {
if (scY < 0) {
scY = 0;
}
-
+
setZoomedScreenScroll(subScX, subScY, (subScreenWidth != 256) && (subScreenWidth != 128));
setZoomedScreenScale(subScreenWidth, ((subScreenHeight * (256 << 8)) / 192) >> 8);
-
+
setMainScreenScroll(64, (scY << 8) + (shakePos << 8));
setMainScreenScale(320, 256); // 1:1 scale
-
+
}
} else {
setZoomedScreenScroll(0, 0, true);
@@ -1932,12 +1932,12 @@ void VBlankHandler(void) {
setMainScreenScroll(0, 0);
setMainScreenScale(320, 256); // 1:1 scale
}
-
+
// Enable on screen keyboard when pen taps icon
if ((keyboardIcon) && (penX < 32) && (penY > 160) && (penHeld)) {
setKeyboardEnable(true);
}
-
+
if (keyboardEnable) {
if (DS::getKeyboardClosed()) {
setKeyboardEnable(false);
@@ -1987,7 +1987,7 @@ void setTopScreenTarget(int x, int y) {
if (subScTargetY < 0) subScTargetY = 0;
if (subScTargetY > gameHeight - subScreenHeight) subScTargetY = gameHeight - subScreenHeight;
-
+
subScTargetX <<=8;
subScTargetY <<=8;
}
@@ -2008,12 +2008,12 @@ void initHardware() {
penInit();
powerON(POWER_ALL);
-/* vramSetBankA(VRAM_A_MAIN_BG);
- vramSetBankB(VRAM_B_MAIN_BG);
+/* vramSetBankA(VRAM_A_MAIN_BG);
+ vramSetBankB(VRAM_B_MAIN_BG);
vramSetBankC(VRAM_C_SUB_BG); */
- vramSetBankI(VRAM_I_SUB_SPRITE);
- vramSetBankE(VRAM_E_MAIN_SPRITE);
-
+ vramSetBankI(VRAM_I_SUB_SPRITE);
+ vramSetBankE(VRAM_E_MAIN_SPRITE);
+
currentTimeMillis = 0;
@@ -2041,8 +2041,8 @@ void initHardware() {
// Allocate save buffer for game screen
// savedBuffer = new u8[320 * 200];
displayMode16Bit();
-
- memset(BG_GFX, 0, 512 * 256 * 2);
+
+ memset(BG_GFX, 0, 512 * 256 * 2);
scaledMode = true;
scX = 0;
scY = 0;
@@ -2050,33 +2050,33 @@ void initHardware() {
subScY = 0;
subScTargetX = 0;
subScTargetY = 0;
-
+
//lcdSwap();
POWER_CR &= ~POWER_SWAP_LCDS;
-
+
frameCount = 0;
callback = NULL;
-
-// vramSetBankH(VRAM_H_SUB_BG);
-
+
+// vramSetBankH(VRAM_H_SUB_BG);
+
// // Do text stuff
//BG0_CR = BG_MAP_BASE(0) | BG_TILE_BASE(1);
// BG0_Y0 = 48;
-
+
PALETTE[255] = RGB15(31,31,31);//by default font will be rendered with color 255
-
+
//consoleInit() is a lot more flexible but this gets you up and running quick
// consoleInitDefault((u16*)SCREEN_BASE_BLOCK(0), (u16*)CHAR_BASE_BLOCK(1), 16);
//consolePrintSet(0, 6);
-
+
//irqs are nice
irqInit();
// irqInitHandler();
irqSet(IRQ_VBLANK, VBlankHandler);
irqSet(IRQ_TIMER0, timerTickHandler);
irqSet(IRQ_TIMER2, soundBufferEmptyHandler);
-
+
irqEnable(IRQ_VBLANK);
irqEnable(IRQ_TIMER0);
irqEnable(IRQ_TIMER2);
@@ -2085,15 +2085,15 @@ void initHardware() {
irqSet(IRQ_HBLANK, hBlankHandler);
irqEnable(IRQ_HBLANK);
#endif
-
-
+
+
// Set up a millisecond timer
#ifdef HEAVY_LOGGING
consolePrintf("Setting up timer...");
#endif
TIMER0_CR = 0;
TIMER0_DATA = (u32) TIMER_FREQ(1000);
- TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1 | TIMER_IRQ_REQ;
+ TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1 | TIMER_IRQ_REQ;
REG_IME = 1;
#ifdef HEAVY_LOGGING
consolePrintf("done\n");
@@ -2102,9 +2102,9 @@ void initHardware() {
PALETTE[255] = RGB15(0,0,31);
initSprites();
-
+
// videoSetModeSub(MODE_3_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); //sub bg 0 will be used to print text
-
+
// Convert texture from 24bit 888 to 16bit 1555, remembering to set top bit!
u8* srcTex = (u8 *) icons_raw;
for (int r = 32 * 256 ; r >= 0; r--) {
@@ -2112,7 +2112,7 @@ void initHardware() {
SPRITE_GFX[r] = 0x8000 | (srcTex[r * 3] >> 3) | ((srcTex[r * 3 + 1] >> 3) << 5) | ((srcTex[r * 3 + 2] >> 3) << 10);
}
-
+
@@ -2199,27 +2199,27 @@ void penUpdate() {
penDownLastFrame = false;
penDownFrames = 0;
}
-
+
}
int leftHandedSwap(int keys) {
// Start and select are unchanged
if (leftHandedMode) {
int result = keys & (~(KEY_R | KEY_L | KEY_Y | KEY_A | KEY_B | KEY_X | KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN));
-
+
if (keys & KEY_L) result |= KEY_R;
if (keys & KEY_R) result |= KEY_L;
-
+
if (keys & KEY_LEFT) result |= KEY_Y;
if (keys & KEY_RIGHT) result |= KEY_A;
if (keys & KEY_DOWN) result |= KEY_B;
if (keys & KEY_UP) result |= KEY_X;
-
+
if (keys & KEY_Y) result |= KEY_LEFT;
if (keys & KEY_A) result |= KEY_RIGHT;
if (keys & KEY_B) result |= KEY_DOWN;
if (keys & KEY_X) result |= KEY_UP;
-
+
return result;
} else {
return keys;
@@ -2310,28 +2310,28 @@ int getPenY() {
GLvector getPenPos() {
GLvector v;
-
+
v.x = (penX * inttof32(1)) / SCREEN_WIDTH;
v.y = (penY * inttof32(1)) / SCREEN_HEIGHT;
-
+
return v;
}
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;
@@ -2380,7 +2380,7 @@ void fastRamReset() {
bool GBAMPAvail = false;
-bool initGBAMP(int mode) {
+bool initGBAMP(int mode) {
if (FAT_InitFiles()) {
if (mode == 2) {
disc_IsInserted();
@@ -2405,14 +2405,14 @@ void initDebugger() {
set_verbosity(VERBOSE_INFO | VERBOSE_ERROR);
wireless_init(0);
wireless_connect();
-
+
// This is where the address of the computer running the Java
// stub goes.
debugger_connect_tcp(192, 168, 0, 1);
- debugger_init();
-
+ debugger_init();
+
// Update function - should really call every frame
- user_debugger_update();
+ user_debugger_update();
}
@@ -2447,7 +2447,7 @@ cardTranslate cardReaderTable[] = {
void reboot() {
int deviceType = -1;
-
+
if (disc_getDeviceId() == DEVICE_DLDI) {
char id[6];
@@ -2525,13 +2525,13 @@ int main(void)
initDebugger();
}
#endif
-
+
// Let arm9 read cartridge
*((u16 *) (0x04000204)) &= ~0x0080;
-
+
lastCallbackFrame = 0;
tweak = 0;
-
+
indyFightState = false;
indyFightRight = true;
@@ -2544,25 +2544,25 @@ int main(void)
// bufferSize = 10;
-
+
/*bufferRate = 44100;
bufferFrame = 0;
bufferSamples = 8192;
bufferFirstHalf = false;
bufferSecondHalf = true;
-
+
int bytes = (2 * (bufferSamples)) + 100;
-
+
soundBuffer = (s16 *) malloc(bytes * 2);
soundHiPart = true;
-
+
for (int r = 0; r < bytes; r++) {
soundBuffer[r] = 0;
}
-
+
swiWaitForVBlank();
swiWaitForVBlank();
@@ -2571,29 +2571,29 @@ int main(void)
swiWaitForVBlank();
swiWaitForVBlank();
*/
-
+
lastEventFrame = 0;
mouseMode = MOUSE_LEFT;
-
+
/*
TIMER1_CR = 0;
TIMER1_DATA = TIMER_FREQ(bufferRate);
TIMER1_CR = TIMER_ENABLE | TIMER_DIV_1;
-
+
TIMER2_CR = 0;
TIMER2_DATA = 0xFFFF - (bufferSamples / 2);
TIMER2_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_CASCADE;
*/
// 2945 - 2947
-
-
+
+
// for (int r = 2946; r < 3000; r++) {
// soundBuffer[r] = 30000;
// }
-
+
//2372
consolePrintf("-------------------------------\n");
@@ -2649,7 +2649,7 @@ int main(void)
consolePrintf("\n");
#endif
-
+
#ifdef USE_BUILT_IN_DRIVER_SELECTION
// Do M3 detection selectioon
int extraData = DSSaveFileManager::getExtraData();
@@ -2688,7 +2688,7 @@ int main(void)
disc_setEnable(mode);
DSSaveFileManager::setExtraData(mode);
#else
-
+
int mode = 0;
#endif
@@ -2734,11 +2734,11 @@ int main(void)
}
delete node;
-
+
updateStatus();
-
-
+
+
// OSystem_DS::instance();
g_system = new OSystem_DS();
@@ -2769,7 +2769,7 @@ int main(void)
char* argv[3] = {"/scummvmds", "--config=scummvmg.ini"};
#endif
-#ifdef DS_NON_SCUMM_BUILD
+#ifdef DS_NON_SCUMM_BUILD
while (1) {
scummvm_main(2, (char **) &argv);
diff --git a/backends/platform/ds/arm9/source/dsmain.h b/backends/platform/ds/arm9/source/dsmain.h
index 314ec97a44..04be57f2eb 100644
--- a/backends/platform/ds/arm9/source/dsmain.h
+++ b/backends/platform/ds/arm9/source/dsmain.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#ifndef _DSMAIN_H
#define _DSMAIN_H
diff --git a/backends/platform/ds/arm9/source/dsoptions.cpp b/backends/platform/ds/arm9/source/dsoptions.cpp
index 07fd121f05..d23201f745 100644
--- a/backends/platform/ds/arm9/source/dsoptions.cpp
+++ b/backends/platform/ds/arm9/source/dsoptions.cpp
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#include "dsoptions.h"
#include "dsmain.h"
#include "gui/dialog.h"
@@ -42,7 +42,7 @@ namespace DS {
DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(20, 0, 320 - 40, 230 - 20) {
addButton(this, 10, 175, "Close", GUI::kCloseCmd, 'C');
-
+
#ifdef DS_SCUMM_BUILD
if (!DS::isGBAMPAvailable()) {
// addButton(this, 100, 140, "Delete Save", 'dels', 'D');
@@ -152,7 +152,7 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(20, 0, 320 - 40, 230 - 20) {
} else {
_touchY->setValue(0);
}
-
+
}
DSOptionsDialog::~DSOptionsDialog() {
@@ -186,7 +186,7 @@ void DSOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint
/* if (cmd == 'dels') {
_delDialog->setList(Scumm::generateSavegameList(Scumm::g_scumm, false));
_delDialog->handleCommand(NULL, GUI::kListSelectionChangedCmd, 0);
-
+
Common::Event event;
event.type = Common::EVENT_KEYDOWN;
event.kbd.ascii = 0;
@@ -195,9 +195,9 @@ void DSOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint
event.type = Common::EVENT_KEYUP;
OSystem_DS::instance()->addEvent(event);
-
+
int idx = _delDialog->runModal();
-
+
if (idx >= 0) {
char name[256];
Scumm::g_scumm->makeSavegameName(name, idx, false);
@@ -205,10 +205,10 @@ void DSOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint
((DSSaveFileManager *) (OSystem_DS::instance()->getSavefileManager()))->deleteFile(name);
}
}
-
+
}*/
#endif
-
+
}
@@ -220,11 +220,11 @@ void togglePause() {
OSystem_DS* system = OSystem_DS::instance();
event.type = Common::EVENT_KEYDOWN;
- event.kbd.keycode = Common::KEYCODE_p;
+ event.kbd.keycode = Common::KEYCODE_p;
event.kbd.ascii = 'p';
event.kbd.flags = 0;
system->addEvent(event);
-
+
event.type = Common::EVENT_KEYUP;
system->addEvent(event);
}
@@ -235,13 +235,13 @@ void showOptionsDialog() {
togglePause();
DS::displayMode16Bit();
-
+
DSOptionsDialog* d = new DSOptionsDialog();
d->runModal();
consolePrintf("deleting dialog\n");
delete d;
-
+
consolePrintf("going to 8 bit\n");
DS::displayMode8Bit();
@@ -303,7 +303,7 @@ void setOptions() {
} else {
DS::setCpuScalerEnable(false);
}
-#endif
+#endif
}
}
diff --git a/backends/platform/ds/arm9/source/dsoptions.h b/backends/platform/ds/arm9/source/dsoptions.h
index 9a345feb3b..3c9da82a83 100644
--- a/backends/platform/ds/arm9/source/dsoptions.h
+++ b/backends/platform/ds/arm9/source/dsoptions.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#ifndef _DSOPTIONS_H_
#define _DSOPTIONS_H_
@@ -39,7 +39,7 @@ class DSOptionsDialog : public GUI::Dialog {
public:
DSOptionsDialog();
~DSOptionsDialog();
-
+
protected:
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
void togglePause();
@@ -56,7 +56,7 @@ protected:
GUI::CheckboxWidget* _cpuScaler;
GUI::CheckboxWidget* _showCursorCheckbox;
GUI::CheckboxWidget* _snapToBorderCheckbox;
-
+
#ifdef DS_SCUMM_BUILD
Scumm::SaveLoadChooser* _delDialog;
#endif
diff --git a/backends/platform/ds/arm9/source/fat/disc_io.c b/backends/platform/ds/arm9/source/fat/disc_io.c
index 4128c769e1..f456343a2c 100644
--- a/backends/platform/ds/arm9/source/fat/disc_io.c
+++ b/backends/platform/ds/arm9/source/fat/disc_io.c
@@ -5,7 +5,7 @@
uniformed io-interface to work with Chishm's FAT library
Written by MightyMax
-
+
Modified by Chishm:
2005-11-06
* Added WAIT_CR modifications for NDS
@@ -87,7 +87,7 @@ LPIO_INTERFACE active_interface = 0;
Disc Cache functions
2006-02-03:
- Added by www.neoflash.com
+ Added by www.neoflash.com
*/
int discDetect = 0;
@@ -99,7 +99,7 @@ int dldiFound = FALSE;
#include <string.h>
#define CACHE_FREE 0xFFFFFFFF
-
+
static u8 cacheBuffer[ DISC_CACHE_COUNT * 512 ];
static struct {
@@ -112,20 +112,20 @@ FATDevice currentDevice;
static u32 disc_CacheFind(u32 sector) {
u32 i;
-
+
for( i = 0; i < DISC_CACHE_COUNT; i++ ) {
if( cache[ i ].sector == sector )
return i;
}
-
+
return CACHE_FREE;
}
static u32 disc_CacheFindFree(void) {
-
+
u32 i = 0, j;
u32 count = -1;
-
+
for( j = 0; j < DISC_CACHE_COUNT; j++ ) {
if( cache[ j ].sector == CACHE_FREE ) {
@@ -142,7 +142,7 @@ static u32 disc_CacheFindFree(void) {
if( cache[ i ].sector != CACHE_FREE && cache[i].dirty != 0 ) {
active_interface->fn_WriteSectors( cache[ i ].sector, 1, &cacheBuffer[ i * 512 ] );
- /* todo: handle write error here
+ /* todo: handle write error here
cache[ i ].sector = CACHE_FREE;
cache[ i ].dirty = 0;
@@ -431,7 +431,7 @@ bool disc_setDsSlotInterface (void)
#endif
-bool disc_Init(void)
+bool disc_Init(void)
{
#ifdef DISC_CACHE
disc_CacheInit();
@@ -455,15 +455,15 @@ bool disc_Init(void)
// could not find a working IO Interface
active_interface = 0 ;
return false ;
-}
+}
-bool disc_IsInserted(void)
+bool disc_IsInserted(void)
{
if (active_interface) return active_interface->fn_IsInserted() ;
return false ;
-}
+}
-bool disc_ReadSectors(u32 sector, u8 numSecs, void* buffer)
+bool disc_ReadSectors(u32 sector, u8 numSecs, void* buffer)
{
#ifdef DISC_CACHE
u8 *p=(u8*)buffer;
@@ -480,9 +480,9 @@ bool disc_ReadSectors(u32 sector, u8 numSecs, void* buffer)
if (active_interface) return active_interface->fn_ReadSectors(sector,numSecs,buffer) ;
return false ;
#endif
-}
+}
-bool disc_WriteSectors(u32 sector, u8 numSecs, void* buffer)
+bool disc_WriteSectors(u32 sector, u8 numSecs, void* buffer)
{
/*#ifdef DISC_CACHE
u8 *p=(u8*)buffer;
@@ -502,15 +502,15 @@ bool disc_WriteSectors(u32 sector, u8 numSecs, void* buffer)
if (active_interface) return active_interface->fn_WriteSectors(sector,numSecs,buffer) ;
return false ;
//#endif
-}
+}
-bool disc_ClearStatus(void)
+bool disc_ClearStatus(void)
{
if (active_interface) return active_interface->fn_ClearStatus() ;
return false ;
-}
+}
-bool disc_Shutdown(void)
+bool disc_Shutdown(void)
{
#ifdef DISC_CACHE
disc_CacheFlush();
@@ -518,7 +518,7 @@ bool disc_Shutdown(void)
if (active_interface) active_interface->fn_Shutdown() ;
active_interface = 0 ;
return true ;
-}
+}
u32 disc_HostType (void)
{
diff --git a/backends/platform/ds/arm9/source/fat/disc_io.h b/backends/platform/ds/arm9/source/fat/disc_io.h
index 05d4c020bd..b2317ca110 100644
--- a/backends/platform/ds/arm9/source/fat/disc_io.h
+++ b/backends/platform/ds/arm9/source/fat/disc_io.h
@@ -7,7 +7,7 @@
// Use DMA to read the card, remove this line to use normal reads/writes
// #define _CF_USE_DMA
-// Allow buffers not aligned to 16 bits when reading files.
+// Allow buffers not aligned to 16 bits when reading files.
// Note that this will slow down access speed, so only use if you have to.
// It is also incompatible with DMA
#define _CF_ALLOW_UNALIGNED
@@ -43,7 +43,7 @@
// This allows the code to build on an earlier version of libnds, before the register was renamed
#ifndef REG_EXMEMCNT
-#define REG_EXMEMCNT REG_EXEMEMCNT
+#define REG_EXMEMCNT REG_EXEMEMCNT
#endif
#ifndef REG_EXEMEMCNT
@@ -70,7 +70,7 @@
#endif
// Disable NDS specific hardware and features if running on a GBA
-#ifndef NDS
+#ifndef NDS
#undef SUPPORT_NMMC
#undef DISC_CACHE
#endif
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 b5fdd665df..9594066f03 100644
--- a/backends/platform/ds/arm9/source/fat/gba_nds_fat.c
+++ b/backends/platform/ds/arm9/source/fat/gba_nds_fat.c
@@ -42,7 +42,7 @@
//---------------------------------------------------------------
// Appropriate placement of CF functions and data
#ifdef NDS
- #define _VARS_IN_RAM
+ #define _VARS_IN_RAM
#else
#define _VARS_IN_RAM __attribute__ ((section (".sbss")))
#endif
@@ -74,7 +74,7 @@
#ifdef __GNUC__
#define __PACKED __attribute__ ((__packed__))
#else
- #define __PACKED
+ #define __PACKED
#pragma pack(1)
#endif
@@ -98,7 +98,7 @@ typedef struct
u32 numSectors;
union // Different types of extended BIOS Parameter Block for FAT16 and FAT32
{
- struct
+ struct
{
// Ext BIOS Parameter Block for FAT16
u8 driveNumber;
@@ -110,7 +110,7 @@ typedef struct
// Bootcode
u8 bootCode[448];
} __PACKED fat16;
- struct
+ struct
{
// FAT32 extended block
u32 sectorsPerFAT32;
@@ -158,7 +158,7 @@ typedef struct
typedef struct
{
u8 ordinal; // Position within LFN
- u16 char0;
+ u16 char0;
u16 char1;
u16 char2;
u16 char3;
@@ -177,7 +177,7 @@ typedef struct
u16 char12;
} __PACKED DIR_ENT_LFN;
-const char lfn_offset_table[13]={0x01,0x03,0x05,0x07,0x09,0x0E,0x10,0x12,0x14,0x16,0x18,0x1C,0x1E};
+const char lfn_offset_table[13]={0x01,0x03,0x05,0x07,0x09,0x0E,0x10,0x12,0x14,0x16,0x18,0x1C,0x1E};
// End of packed structs
#ifdef __PACKED
@@ -190,7 +190,7 @@ const char lfn_offset_table[13]={0x01,0x03,0x05,0x07,0x09,0x0E,0x10,0x12,0x14,0x
//-----------------------------------------------------------------
// Global Variables
-// _VARS_IN_RAM variables are stored in the largest section of WRAM
+// _VARS_IN_RAM variables are stored in the largest section of WRAM
// available: IWRAM on NDS ARM7, EWRAM on NDS ARM9 and GBA
// Files
@@ -305,7 +305,7 @@ u16 getRTCtoFileTime (void)
u16 getRTCtoFileDate (void)
{
#ifdef NDS
- return (
+ return (
( ((IPC->rtc_year + 20) & 0x7F) <<9) |
( (IPC->rtc_month & 0xF) << 5) |
(IPC->rtc_day & 0x1F) );
@@ -330,13 +330,13 @@ u32 FAT_NextCluster(u32 cluster)
u32 nextCluster = CLUSTER_FREE;
u32 sector;
int offset;
-
- switch (filesysType)
+
+ switch (filesysType)
{
case FS_UNKNOWN:
nextCluster = CLUSTER_FREE;
break;
-
+
case FS_FAT12:
sector = filesysFAT + (((cluster * 3) / 2) / BYTE_PER_READ);
offset = ((cluster * 3) / 2) % BYTE_PER_READ;
@@ -351,32 +351,32 @@ u32 FAT_NextCluster(u32 cluster)
nextCluster = ((u8*)fatBuffer)[offset];
offset++;
-
+
if (offset >= BYTE_PER_READ) {
offset = 0;
fatBufferCurSector++;
disc_ReadSector(fatBufferCurSector, fatBuffer);
}
-
+
nextCluster |= (((u8*)fatBuffer)[offset]) << 8;
-
+
if (cluster & 0x01) {
nextCluster = nextCluster >> 4;
} else {
nextCluster &= 0x0FFF;
}
-
+
if (nextCluster >= 0x0FF7)
{
nextCluster = CLUSTER_EOF;
}
break;
-
+
case FS_FAT16:
sector = filesysFAT + ((cluster << 1) / BYTE_PER_READ);
offset = cluster % (BYTE_PER_READ >> 1);
-
+
// If FAT buffer contains wrong sector
if (sector != fatBufferCurSector)
{
@@ -387,17 +387,17 @@ u32 FAT_NextCluster(u32 cluster)
// read the nextCluster value
nextCluster = ((u16*)fatBuffer)[offset];
-
+
if (nextCluster >= 0xFFF7)
{
nextCluster = CLUSTER_EOF;
}
break;
-
+
case FS_FAT32:
sector = filesysFAT + ((cluster << 2) / BYTE_PER_READ);
offset = cluster % (BYTE_PER_READ >> 2);
-
+
// If FAT buffer contains wrong sector
if (sector != fatBufferCurSector)
{
@@ -408,18 +408,18 @@ u32 FAT_NextCluster(u32 cluster)
// read the nextCluster value
nextCluster = (((u32*)fatBuffer)[offset]) & 0x0FFFFFFF;
-
+
if (nextCluster >= 0x0FFFFFF7)
{
nextCluster = CLUSTER_EOF;
}
break;
-
+
default:
nextCluster = CLUSTER_FREE;
break;
}
-
+
return nextCluster;
}
@@ -437,13 +437,13 @@ bool FAT_WriteFatEntry (u32 cluster, u32 value)
{
return false;
}
-
- switch (filesysType)
+
+ switch (filesysType)
{
case FS_UNKNOWN:
return false;
break;
-
+
case FS_FAT12:
sector = filesysFAT + (((cluster * 3) / 2) / BYTE_PER_READ);
offset = ((cluster * 3) / 2) % BYTE_PER_READ;
@@ -465,32 +465,32 @@ bool FAT_WriteFatEntry (u32 cluster, u32 value)
offset = 0;
// write the buffer back to disc
disc_WriteSector(fatBufferCurSector, fatBuffer);
- // read the next sector
+ // read the next sector
fatBufferCurSector++;
disc_ReadSector(fatBufferCurSector, fatBuffer);
}
-
+
((u8*)fatBuffer)[offset] = (value & 0x0FF0) >> 4;
} else {
-
+
((u8*)fatBuffer)[offset] = value & 0xFF;
-
+
offset++;
if (offset >= BYTE_PER_READ) {
offset = 0;
// write the buffer back to disc
disc_WriteSector(fatBufferCurSector, fatBuffer);
- // read the next sector
+ // read the next sector
fatBufferCurSector++;
disc_ReadSector(fatBufferCurSector, fatBuffer);
}
-
+
((u8*)fatBuffer)[offset] = (((u8*)fatBuffer)[offset] & 0xF0) | ((value >> 8) & 0x0F);
}
break;
-
+
case FS_FAT16:
sector = filesysFAT + ((cluster << 1) / BYTE_PER_READ);
offset = cluster % (BYTE_PER_READ >> 1);
@@ -507,11 +507,11 @@ bool FAT_WriteFatEntry (u32 cluster, u32 value)
((u16*)fatBuffer)[offset] = (value & 0xFFFF);
break;
-
+
case FS_FAT32:
sector = filesysFAT + ((cluster << 2) / BYTE_PER_READ);
offset = cluster % (BYTE_PER_READ >> 2);
-
+
// If FAT buffer contains wrong sector
if (sector != fatBufferCurSector)
{
@@ -524,15 +524,15 @@ bool FAT_WriteFatEntry (u32 cluster, u32 value)
(((u32*)fatBuffer)[offset]) = value;
break;
-
+
default:
return false;
break;
}
-
+
// write the buffer back to disc
disc_WriteSector(fatBufferCurSector, fatBuffer);
-
+
return true;
}
#endif
@@ -540,8 +540,8 @@ bool FAT_WriteFatEntry (u32 cluster, u32 value)
#ifdef CAN_WRITE_TO_DISC
/*-----------------------------------------------------------------
FAT_ReadWriteFatEntryBuffered
-Internal function - writes FAT information about a cluster to a
- buffer that should then be flushed to disc using
+Internal function - writes FAT information about a cluster to a
+ buffer that should then be flushed to disc using
FAT_WriteFatEntryFlushBuffer()
Call FAT_WriteFatEntry first so as not to ruin the disc.
Also returns the entry being replaced
@@ -555,13 +555,13 @@ u32 FAT_ReadWriteFatEntryBuffered (u32 cluster, u32 value)
if ((cluster < 0x0002) || (cluster > fatLastCluster))
return CLUSTER_FREE;
-
- switch (filesysType)
+
+ switch (filesysType)
{
case FS_UNKNOWN:
oldValue = CLUSTER_FREE;
break;
-
+
case FS_FAT12:
sector = filesysFAT + (((cluster * 3) / 2) / BYTE_PER_READ);
offset = ((cluster * 3) / 2) % BYTE_PER_READ;
@@ -587,40 +587,40 @@ u32 FAT_ReadWriteFatEntryBuffered (u32 cluster, u32 value)
offset = 0;
// write the buffer back to disc
disc_WriteSector(fatBufferCurSector, fatBuffer);
- // read the next sector
+ // read the next sector
fatBufferCurSector++;
disc_ReadSector(fatBufferCurSector, fatBuffer);
}
-
+
oldValue |= ((((u8*)fatBuffer)[offset]) << 4) & 0x0FF0;
((u8*)fatBuffer)[offset] = (value & 0x0FF0) >> 4;
} else {
-
+
oldValue = ((u8*)fatBuffer)[offset] & 0xFF;
((u8*)fatBuffer)[offset] = value & 0xFF;
-
+
offset++;
if (offset >= BYTE_PER_READ) {
offset = 0;
// write the buffer back to disc
disc_WriteSector(fatBufferCurSector, fatBuffer);
- // read the next sector
+ // read the next sector
fatBufferCurSector++;
disc_ReadSector(fatBufferCurSector, fatBuffer);
}
-
+
oldValue |= (((u8*)fatBuffer)[offset] & 0x0F) << 8;
((u8*)fatBuffer)[offset] = (((u8*)fatBuffer)[offset] & 0xF0) | ((value >> 8) & 0x0F);
}
- if (oldValue >= 0x0FF7)
+ if (oldValue >= 0x0FF7)
{
oldValue = CLUSTER_EOF;
}
break;
-
+
case FS_FAT16:
sector = filesysFAT + ((cluster << 1) / BYTE_PER_READ);
offset = cluster % (BYTE_PER_READ >> 1);
@@ -634,23 +634,23 @@ u32 FAT_ReadWriteFatEntryBuffered (u32 cluster, u32 value)
// Load correct sector to buffer
fatBufferCurSector = sector;
disc_ReadSector(fatBufferCurSector, fatBuffer);
- }
+ }
// write the value to the FAT buffer
oldValue = ((u16*)fatBuffer)[offset];
((u16*)fatBuffer)[offset] = value;
- if (oldValue >= 0xFFF7)
+ if (oldValue >= 0xFFF7)
{
oldValue = CLUSTER_EOF;
}
break;
-
+
case FS_FAT32:
sector = filesysFAT + ((cluster << 2) / BYTE_PER_READ);
offset = cluster % (BYTE_PER_READ >> 2);
-
+
// If FAT buffer contains wrong sector
if (sector != fatBufferCurSector)
{
@@ -666,18 +666,18 @@ u32 FAT_ReadWriteFatEntryBuffered (u32 cluster, u32 value)
oldValue = ((u32*)fatBuffer)[offset];
((u32*)fatBuffer)[offset] = value;
- if (oldValue >= 0x0FFFFFF7)
+ if (oldValue >= 0x0FFFFFF7)
{
oldValue = CLUSTER_EOF;
}
break;
-
+
default:
oldValue = CLUSTER_FREE;
break;
}
-
+
return oldValue;
}
#endif
@@ -727,7 +727,7 @@ u32 FAT_FirstFreeCluster(void)
/*-----------------------------------------------------------------
FAT_LinkFreeCluster
Internal function - gets the first available free cluster, sets it
-to end of file, links the input cluster to it then returns the
+to end of file, links the input cluster to it then returns the
cluster number
-----------------------------------------------------------------*/
u32 FAT_LinkFreeCluster(u32 cluster)
@@ -746,7 +746,7 @@ u32 FAT_LinkFreeCluster(u32 cluster)
{
return curLink; // Return the current link - don't allocate a new one
}
-
+
// Get a free cluster
firstFree = FAT_FirstFreeCluster();
@@ -777,7 +777,7 @@ Internal function - frees any cluster used by a file
bool FAT_ClearLinks (u32 cluster)
{
u32 nextCluster;
-
+
if ((cluster < 0x0002) || (cluster > fatLastCluster))
return false;
@@ -793,7 +793,7 @@ bool FAT_ClearLinks (u32 cluster)
while ((cluster != CLUSTER_EOF) && (cluster != CLUSTER_FREE))
{
cluster = FAT_ReadWriteFatEntryBuffered (cluster, CLUSTER_FREE);
- }
+ }
// Flush fat write buffer
FAT_WriteFatEntryFlushBuffer ();
@@ -814,7 +814,7 @@ bool FAT_InitFiles (void)
int i;
int bootSector;
BOOT_SEC* bootSec;
-
+
if (!disc_Init())
{
return (false);
@@ -830,7 +830,7 @@ bool FAT_InitFiles (void)
return false;
}*/
-
+
// Check if there is a FAT string, which indicates this is a boot sector
if ((globalBuffer[0x36] == 'F') && (globalBuffer[0x37] == 'A') && (globalBuffer[0x38] == 'T'))
@@ -848,9 +848,9 @@ bool FAT_InitFiles (void)
// First check for an active partition
for (i=0x1BE; (i < 0x1FE) && (globalBuffer[i] != 0x80); i+= 0x10);
// If it didn't find an active partition, search for any valid partition
- if (i == 0x1FE)
+ if (i == 0x1FE)
for (i=0x1BE; (i < 0x1FE) && (globalBuffer[i+0x04] == 0x00); i+= 0x10);
-
+
// Go to first valid partition
if ( i != 0x1FE) // Make sure it found a partition
{
@@ -865,7 +865,7 @@ bool FAT_InitFiles (void)
if (!disc_ReadSector (bootSector, bootSec)) {
return false;
}
-
+
// Store required information about the file system
if (bootSec->sectorsPerFAT != 0)
{
@@ -875,7 +875,7 @@ bool FAT_InitFiles (void)
{
filesysSecPerFAT = bootSec->extBlock.fat32.sectorsPerFAT32;
}
-
+
if (bootSec->numSectorsSmall != 0)
{
filesysNumSec = bootSec->numSectorsSmall;
@@ -987,7 +987,7 @@ Return the file info structure of the next valid file entry
u32 dirCluster: IN cluster of subdirectory table
int entry: IN the desired file entry
int origin IN: relative position of the entry
-DIR_ENT return OUT: desired dirEntry. First char will be FILE_FREE if
+DIR_ENT return OUT: desired dirEntry. First char will be FILE_FREE if
the entry does not exist.
-----------------------------------------------------------------*/
DIR_ENT FAT_GetDirEntry ( u32 dirCluster, int entry, int origin)
@@ -1011,8 +1011,8 @@ DIR_ENT FAT_GetDirEntry ( u32 dirCluster, int entry, int origin)
{
return (dir);
}
-
- switch (origin)
+
+ switch (origin)
{
case SEEK_SET:
wrkDirCluster = dirCluster;
@@ -1022,7 +1022,7 @@ DIR_ENT FAT_GetDirEntry ( u32 dirCluster, int entry, int origin)
case SEEK_CUR: // Don't change anything
break;
case SEEK_END: // Find entry signifying end of directory
- // Subtraction will never reach 0, so it keeps going
+ // Subtraction will never reach 0, so it keeps going
// until reaches end of directory
wrkDirCluster = dirCluster;
wrkDirSector = 0;
@@ -1055,7 +1055,7 @@ DIR_ENT FAT_GetDirEntry ( u32 dirCluster, int entry, int origin)
{
notFound = true;
}
- firstSector = FAT_ClustToSect(wrkDirCluster);
+ firstSector = FAT_ClustToSect(wrkDirCluster);
}
else if ((wrkDirCluster == FAT16_ROOT_DIR_CLUSTER) && (wrkDirSector == (filesysData - filesysRootDir)))
{
@@ -1082,7 +1082,7 @@ DIR_ENT FAT_GetDirEntry ( u32 dirCluster, int entry, int origin)
lfnName[0] = '\0';
}
}
- if (entry == 0)
+ if (entry == 0)
{
if (!lfnExists)
{
@@ -1128,7 +1128,7 @@ DIR_ENT FAT_GetDirEntry ( u32 dirCluster, int entry, int origin)
}
}
} while (!found && !notFound);
-
+
// If no file is found, return FILE_FREE
if (notFound)
{
@@ -1141,7 +1141,7 @@ DIR_ENT FAT_GetDirEntry ( u32 dirCluster, int entry, int origin)
/*-----------------------------------------------------------------
FAT_GetLongFilename
-Get the long name of the last file or directory retrived with
+Get the long name of the last file or directory retrived with
GetDirEntry. Also works for FindFirstFile and FindNextFile.
If a long name doesn't exist, it returns the short name
instead.
@@ -1156,14 +1156,14 @@ bool FAT_GetLongFilename (char* filename)
strncpy (filename, lfnName, MAX_FILENAME_LENGTH - 1);
filename[MAX_FILENAME_LENGTH - 1] = '\0';
-
+
return true;
}
/*-----------------------------------------------------------------
FAT_GetFilename
-Get the alias (short name) of the file or directory stored in
+Get the alias (short name) of the file or directory stored in
dirEntry
DIR_ENT dirEntry: IN a valid directory table entry
char* alias OUT: will be filled with the alias (short filename),
@@ -1192,7 +1192,7 @@ bool FAT_GetFilename (DIR_ENT dirEntry, char* alias)
}
}
else
- {
+ {
// Copy the filename from the dirEntry to the string
for (i = 0; (i < 8) && (dirEntry.name[i] != ' '); i++)
{
@@ -1230,7 +1230,7 @@ bool FAT_GetAlias (char* alias)
}
// Read in the last accessed directory entry
disc_ReadSector ((wrkDirCluster == FAT16_ROOT_DIR_CLUSTER ? filesysRootDir : FAT_ClustToSect(wrkDirCluster)) + wrkDirSector, globalBuffer);
-
+
return FAT_GetFilename (((DIR_ENT*)globalBuffer)[wrkDirOffset], alias);
}
@@ -1244,7 +1244,7 @@ u32 FAT_GetFileSize (void)
{
// Read in the last accessed directory entry
disc_ReadSector ((wrkDirCluster == FAT16_ROOT_DIR_CLUSTER ? filesysRootDir : FAT_ClustToSect(wrkDirCluster)) + wrkDirSector, globalBuffer);
-
+
return ((DIR_ENT*)globalBuffer)[wrkDirOffset].fileSize;
}
@@ -1257,7 +1257,7 @@ u32 FAT_GetFileCluster (void)
{
// Read in the last accessed directory entry
disc_ReadSector ((wrkDirCluster == FAT16_ROOT_DIR_CLUSTER ? filesysRootDir : FAT_ClustToSect(wrkDirCluster)) + wrkDirSector, globalBuffer);
-
+
return (((DIR_ENT*)globalBuffer)[wrkDirOffset].startCluster) | (((DIR_ENT*)globalBuffer)[wrkDirOffset].startClusterHigh << 16);
}
@@ -1270,7 +1270,7 @@ u8 FAT_GetFileAttributes (void)
{
// Read in the last accessed directory entry
disc_ReadSector ((wrkDirCluster == FAT16_ROOT_DIR_CLUSTER ? filesysRootDir : FAT_ClustToSect(wrkDirCluster)) + wrkDirSector, globalBuffer);
-
+
return ((DIR_ENT*)globalBuffer)[wrkDirOffset].attrib;
}
@@ -1294,7 +1294,7 @@ u8 FAT_SetFileAttributes (const char* filename, u8 attributes, u8 mask)
disc_ReadSector ((wrkDirCluster == FAT16_ROOT_DIR_CLUSTER ? filesysRootDir : FAT_ClustToSect(wrkDirCluster)) + wrkDirSector, globalBuffer);
((DIR_ENT*)globalBuffer)[wrkDirOffset].attrib = (((DIR_ENT*)globalBuffer)[wrkDirOffset].attrib & ~(mask & 0x27)) | (attributes & 0x27); // 0x27 is he settable attributes
-
+
disc_WriteSector ((wrkDirCluster == FAT16_ROOT_DIR_CLUSTER ? filesysRootDir : FAT_ClustToSect(wrkDirCluster)) + wrkDirSector, globalBuffer);
return ((DIR_ENT*)globalBuffer)[wrkDirOffset].attrib;
@@ -1305,7 +1305,7 @@ u8 FAT_SetFileAttributes (const char* filename, u8 attributes, u8 mask)
time_t FAT_FileTimeToCTime (u16 fileTime, u16 fileDate)
{
struct tm timeInfo;
-
+
timeInfo.tm_year = (fileDate >> 9) + 80; // years since midnight January 1970
timeInfo.tm_mon = ((fileDate >> 5) & 0xf) - 1; // Months since january
timeInfo.tm_mday = fileDate & 0x1f; // Day of the month
@@ -1326,7 +1326,7 @@ time_t FAT_GetFileCreationTime (void)
{
// Read in the last accessed directory entry
disc_ReadSector ((wrkDirCluster == FAT16_ROOT_DIR_CLUSTER ? filesysRootDir : FAT_ClustToSect(wrkDirCluster)) + wrkDirSector, globalBuffer);
-
+
return FAT_FileTimeToCTime(((DIR_ENT*)globalBuffer)[wrkDirOffset].cTime, ((DIR_ENT*)globalBuffer)[wrkDirOffset].cDate);
}
@@ -1339,7 +1339,7 @@ time_t FAT_GetFileLastWriteTime (void)
{
// Read in the last accessed directory entry
disc_ReadSector ((wrkDirCluster == FAT16_ROOT_DIR_CLUSTER ? filesysRootDir : FAT_ClustToSect(wrkDirCluster)) + wrkDirSector, globalBuffer);
-
+
return FAT_FileTimeToCTime(((DIR_ENT*)globalBuffer)[wrkDirOffset].mTime, ((DIR_ENT*)globalBuffer)[wrkDirOffset].mDate);
}
#endif
@@ -1374,8 +1374,8 @@ DIR_ENT FAT_DirEntFromPath (const char* path)
return;
}
#endif
-
- if (path[pathPos] == '/')
+
+ if (path[pathPos] == '/')
{
dirCluster = filesysRootDirClus; // Start at root directory
}
@@ -1383,13 +1383,13 @@ DIR_ENT FAT_DirEntFromPath (const char* path)
{
dirCluster = curWorkDirCluster; // Start at current working dir
}
-
+
// Eat any slash /
while ((path[pathPos] == '/') && (path[pathPos] != '\0'))
{
pathPos++;
}
-
+
// Search until can't continue
found = false;
notFound = false;
@@ -1437,7 +1437,7 @@ DIR_ENT FAT_DirEntFromPath (const char* path)
flagLFN = true;
}
}
-
+
// Add end of string char
name[namePos] = '\0';
@@ -1497,7 +1497,7 @@ DIR_ENT FAT_DirEntFromPath (const char* path)
dirEntry = FAT_GetDirEntry (dirCluster, 1, SEEK_CUR);
}
}
-
+
if (found && ((dirEntry.attrib & ATTRIB_DIR) == ATTRIB_DIR) && (path[pathPos] != '\0'))
// It has found a directory from within the path that needs to be followed
{
@@ -1505,7 +1505,7 @@ DIR_ENT FAT_DirEntFromPath (const char* path)
dirCluster = dirEntry.startCluster | (dirEntry.startClusterHigh << 16);
}
}
-
+
if (notFound)
{
dirEntry.name[0] = FILE_FREE;
@@ -1534,11 +1534,11 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
bool flagLFN, dotSeen;
char fileAlias[13] = {0};
int tailNum;
-
+
unsigned char chkSum = 0;
-
+
u32 oldWorkDirCluster;
-
+
DIR_ENT* dirEntries = (DIR_ENT*)globalBuffer;
u32 dirCluster;
int secOffset;
@@ -1566,7 +1566,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
{
curWorkDirCluster = filesysRootDirClus;
}
-
+
pathPos = 0;
filePos = 0;
flagLFN = false;
@@ -1576,7 +1576,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
if (path[pathPos + filePos] == '/')
{
filename[filePos] = '\0';
- if (FAT_chdir(filename) == false)
+ if (FAT_chdir(filename) == false)
{
curWorkDirCluster = oldWorkDirCluster;
return false; // Couldn't change directory
@@ -1587,17 +1587,17 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
filename[filePos] = path[pathPos + filePos];
filePos++;
}
-
+
// Skip over last slashes
while (path[pathPos] == '/')
pathPos++;
-
+
// Check if the filename has a leading "."
// If so, it is an LFN
if (path[pathPos] == '.') {
flagLFN = true;
}
-
+
// Copy name from path
filePos = 0;
dotSeen = false;
@@ -1622,12 +1622,12 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
flagLFN = true;
}
}
-
+
if (filePos == 0) // No filename
{
return false;
}
-
+
// Check if a long filename was specified
if (filePos > 12)
{
@@ -1638,7 +1638,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
if (!flagLFN && (strrchr (filename, '.') != NULL) && (strlen(strrchr(filename, '.')) > 4)) {
flagLFN = true;
}
-
+
lfnPos = (filePos - 1) / 13;
// Add end of string char
@@ -1646,8 +1646,8 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
// Clear remaining chars
while (filePos < MAX_FILENAME_LENGTH)
filename[filePos++] = 0x01; // Set for LFN compatibility
-
-
+
+
if (flagLFN)
{
// Generate short filename - always a 2 digit number for tail
@@ -1666,7 +1666,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
// Pad Alias with underscores
while (aliasPos < 5)
fileAlias[aliasPos++] = '_';
-
+
fileAlias[5] = '~';
fileAlias[8] = '.';
fileAlias[9] = ' ';
@@ -1692,14 +1692,14 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
} else {
aliasPos = 9;
}
-
+
// Pad Alias extension with spaces
while (aliasPos < 12)
fileAlias[aliasPos++] = ' ';
-
+
fileAlias[12] = '\0';
-
-
+
+
// Get a valid tail number
tailNum = 0;
do {
@@ -1707,7 +1707,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
fileAlias[6] = 0x30 + ((tailNum / 10) % 10); // 10's digit
fileAlias[7] = 0x30 + (tailNum % 10); // 1's digit
} while ((FAT_DirEntFromPath(fileAlias).name[0] != FILE_FREE) && (tailNum < 100));
-
+
if (tailNum < 100) // Found an alias not being used
{
// Calculate file checksum
@@ -1725,7 +1725,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
{
return false;
}
-
+
dirEntryLength = lfnPos + 2;
}
else // Its not a long file name
@@ -1743,7 +1743,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
dirEntryLength = 1;
}
-
+
// Change dirEntry name to match alias
for (aliasPos = 0; ((fileAlias[aliasPos] != '.') && (fileAlias[aliasPos] != '\0') && (aliasPos < 8)); aliasPos++)
{
@@ -1775,12 +1775,12 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
maxSectors = (dirCluster == FAT16_ROOT_DIR_CLUSTER ? (filesysData - filesysRootDir) : filesysSecPerClus);
firstSector = (dirCluster == FAT16_ROOT_DIR_CLUSTER ? filesysRootDir : FAT_ClustToSect(dirCluster));
disc_ReadSector (firstSector + secOffset, dirEntries);
-
+
dirEntryRemain = dirEntryLength;
tempDirCluster = dirCluster;
tempSecOffset = secOffset;
tempEntryOffset = entryOffset;
-
+
// Search for a large enough space to fit in new directory entry
while ((dirEntries[entryOffset].name[0] != FILE_LAST) && (dirEntryRemain > 0))
{
@@ -1803,7 +1803,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
{
dirCluster = FAT_NextCluster(dirCluster);
}
- firstSector = FAT_ClustToSect(dirCluster);
+ firstSector = FAT_ClustToSect(dirCluster);
}
else if ((dirCluster == FAT16_ROOT_DIR_CLUSTER) && (secOffset == (filesysData - filesysRootDir)))
{
@@ -1824,7 +1824,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
}
// Modifying the last directory is a special case - have to erase following entries
- if (dirEntries[entryOffset].name[0] == FILE_LAST)
+ if (dirEntries[entryOffset].name[0] == FILE_LAST)
{
dirEndFlag = true;
}
@@ -1843,7 +1843,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
}
// Add new directory entry
- while (dirEntryRemain > 0)
+ while (dirEntryRemain > 0)
{
// Move to next entry, first pass advances from last used entry
entryOffset++;
@@ -1868,7 +1868,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
{
dirCluster = FAT_NextCluster(dirCluster);
}
- firstSector = FAT_ClustToSect(dirCluster);
+ firstSector = FAT_ClustToSect(dirCluster);
}
else if ((dirCluster == FAT16_ROOT_DIR_CLUSTER) && (secOffset == (filesysData - filesysRootDir)))
{
@@ -1900,7 +1900,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
lfnEntry.flag = ATTRIB_LFN;
lfnEntry.reserved1 = 0;
lfnEntry.reserved2 = 0;
-
+
*((DIR_ENT_LFN*)&dirEntries[entryOffset]) = lfnEntry;
lfnPos --;
lfnEntry.ordinal = 0;
@@ -1914,7 +1914,7 @@ bool FAT_AddDirEntry (const char* path, DIR_ENT newDirEntry)
dirEntryRemain--;
}
-
+
// Write directory back to disk
disc_WriteSector (firstSector + secOffset, dirEntries);
@@ -1930,7 +1930,7 @@ FAT_FindNextFile
Gets the name of the next directory entry
(can be a file or subdirectory)
char* filename: OUT filename, must be at least 13 chars long
-FILE_TYPE return: OUT returns FT_NONE if failed,
+FILE_TYPE return: OUT returns FT_NONE if failed,
FT_FILE if it found a file and FT_DIR if it found a directory
-----------------------------------------------------------------*/
FILE_TYPE FAT_FindNextFile(char* filename)
@@ -1963,7 +1963,7 @@ FAT_FindFirstFile
Gets the name of the first directory entry and resets the count
(can be a file or subdirectory)
char* filename: OUT filename, must be at least 13 chars long
-FILE_TYPE return: OUT returns FT_NONE if failed,
+FILE_TYPE return: OUT returns FT_NONE if failed,
FT_FILE if it found a file and FT_DIR if it found a directory
-----------------------------------------------------------------*/
FILE_TYPE FAT_FindFirstFile(char* filename)
@@ -1971,7 +1971,7 @@ FILE_TYPE FAT_FindFirstFile(char* filename)
// Get the first directory entry
DIR_ENT file;
file = FAT_GetDirEntry (curWorkDirCluster, 1, SEEK_SET);
-
+
if (file.name[0] == FILE_FREE)
{
return FT_NONE; // Did not find a file
@@ -1996,7 +1996,7 @@ FAT_FindFirstFileLFN
Gets the long file name of the first directory entry and resets
the count (can be a file or subdirectory)
char* lfn: OUT long file name, must be at least 256 chars long
-FILE_TYPE return: OUT returns FT_NONE if failed,
+FILE_TYPE return: OUT returns FT_NONE if failed,
FT_FILE if it found a file and FT_DIR if it found a directory
-----------------------------------------------------------------*/
FILE_TYPE FAT_FindFirstFileLFN(char* lfn)
@@ -2012,7 +2012,7 @@ FAT_FindNextFileLFN
Gets the long file name of the next directory entry
(can be a file or subdirectory)
char* lfn: OUT long file name, must be at least 256 chars long
-FILE_TYPE return: OUT returns FT_NONE if failed,
+FILE_TYPE return: OUT returns FT_NONE if failed,
FT_FILE if it found a file and FT_DIR if it found a directory
-----------------------------------------------------------------*/
FILE_TYPE FAT_FindNextFileLFN(char* lfn)
@@ -2026,29 +2026,29 @@ FILE_TYPE FAT_FindNextFileLFN(char* lfn)
/*-----------------------------------------------------------------
FAT_FileExists
-Returns the type of file
+Returns the type of file
char* filename: IN filename of the file to look for
-FILE_TYPE return: OUT returns FT_NONE if there is now file with
+FILE_TYPE return: OUT returns FT_NONE if there is now file with
that name, FT_FILE if it is a file and FT_DIR if it is a directory
-----------------------------------------------------------------*/
FILE_TYPE FAT_FileExists(const char* filename)
{
- DIR_ENT dirEntry;
- // Get the dirEntry for the path specified
- dirEntry = FAT_DirEntFromPath (filename);
-
- if (dirEntry.name[0] == FILE_FREE)
- {
- return FT_NONE;
- }
- else if (dirEntry.attrib & ATTRIB_DIR)
- {
- return FT_DIR;
- }
- else
- {
- return FT_FILE;
- }
+ DIR_ENT dirEntry;
+ // Get the dirEntry for the path specified
+ dirEntry = FAT_DirEntFromPath (filename);
+
+ if (dirEntry.name[0] == FILE_FREE)
+ {
+ return FT_NONE;
+ }
+ else if (dirEntry.attrib & ATTRIB_DIR)
+ {
+ return FT_DIR;
+ }
+ else
+ {
+ return FT_FILE;
+ }
}
/*-----------------------------------------------------------------
@@ -2074,7 +2074,7 @@ u32 FAT_GetFileSystemTotalSize (void)
/*-----------------------------------------------------------------
FAT_chdir
Changes the current working directory
-const char* path: IN null terminated string of directory separated by
+const char* path: IN null terminated string of directory separated by
forward slashes, / is root
bool return: OUT returns true if successful
-----------------------------------------------------------------*/
@@ -2090,7 +2090,7 @@ bool FAT_chdir (const char* path)
{
return true;
}
-
+
dir = FAT_DirEntFromPath (path);
if (((dir.attrib & ATTRIB_DIR) == ATTRIB_DIR) && (dir.name[0] != FILE_FREE))
@@ -2111,7 +2111,7 @@ bool FAT_chdir (const char* path)
return true;
}
else
- {
+ {
// Couldn't change directory - wrong path specified
return false;
}
@@ -2120,12 +2120,12 @@ bool FAT_chdir (const char* path)
/*-----------------------------------------------------------------
FAT_fopen(filename, mode)
Opens a file
-const char* path: IN null terminated string of filename and path
+const char* path: IN null terminated string of filename and path
separated by forward slashes, / is root
const char* mode: IN mode to open file in
Supported modes: "r", "r+", "w", "w+", "a", "a+", don't use
"b" or "t" in any mode, as all files are openned in binary mode
-FAT_FILE* return: OUT handle to open file, returns NULL if the file
+FAT_FILE* return: OUT handle to open file, returns NULL if the file
couldn't be openned
-----------------------------------------------------------------*/
FAT_FILE* FAT_fopen(const char* path, const char* mode)
@@ -2149,10 +2149,10 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
{
return NULL;
}
-
+
// Get the dirEntry for the path specified
dirEntry = FAT_DirEntFromPath (path);
-
+
// Check that it is not a directory
if (dirEntry.attrib & ATTRIB_DIR)
{
@@ -2174,7 +2174,7 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
// Find a free file buffer
for (fileNum = 0; (fileNum < MAX_FILES_OPEN) && (openFiles[fileNum].inUse == true); fileNum++);
-
+
if (fileNum == MAX_FILES_OPEN) // No free files
{
return NULL;
@@ -2191,7 +2191,7 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
{
return NULL;
}
-
+
file->read = true;
#ifdef CAN_WRITE_TO_DISC
file->write = ( strchr(mode, '+') != NULL ); //(mode[1] == '+');
@@ -2199,13 +2199,13 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
file->write = false;
#endif
file->append = false;
-
+
// Store information about position within the file, for use
// by FAT_fread, FAT_fseek, etc.
file->firstCluster = dirEntry.startCluster | (dirEntry.startClusterHigh << 16);
-
+
#ifdef CAN_WRITE_TO_DISC
- // Check if file is openned for random. If it is, and currently has no cluster, one must be
+ // Check if file is openned for random. If it is, and currently has no cluster, one must be
// assigned to it.
if (file->write && file->firstCluster == CLUSTER_FREE)
{
@@ -2223,7 +2223,7 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
disc_WriteSector (file->dirEntSector, globalBuffer);
}
#endif
-
+
file->length = dirEntry.fileSize;
file->curPos = 0;
file->curClus = dirEntry.startCluster | (dirEntry.startClusterHigh << 16);
@@ -2234,7 +2234,7 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
file->appByte = 0;
file->appClus = 0;
file->appSect = 0;
-
+
disc_ReadSector( FAT_ClustToSect( file->curClus), file->readBuffer);
file->inUse = true; // We're using this file now
@@ -2248,7 +2248,7 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
{
dirEntry.attrib = ATTRIB_ARCH;
dirEntry.reserved = 0;
-
+
// Time and date set to system time and date
dirEntry.cTime_ms = 0;
dirEntry.cTime = getRTCtoFileTime();
@@ -2257,12 +2257,12 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
dirEntry.mTime = getRTCtoFileTime();
dirEntry.mDate = getRTCtoFileDate();
}
- else // Already a file entry
+ else // Already a file entry
{
// Free any clusters used
FAT_ClearLinks (dirEntry.startCluster | (dirEntry.startClusterHigh << 16));
}
-
+
// Get a cluster to use
startCluster = FAT_LinkFreeCluster (CLUSTER_FREE);
if (startCluster == CLUSTER_FREE) // Couldn't get a free cluster
@@ -2298,13 +2298,13 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
((DIR_ENT*) globalBuffer)[file->dirEntOffset] = dirEntry;
disc_WriteSector (file->dirEntSector, globalBuffer);
}
-
+
// Now that file is created, open it
file->read = ( strchr(mode, '+') != NULL ); //(mode[1] == '+');
file->write = true;
file->append = false;
-
+
// Store information about position within the file, for use
// by FAT_fread, FAT_fseek, etc.
file->firstCluster = startCluster;
@@ -2318,7 +2318,7 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
file->appByte = 0;
file->appClus = 0;
file->appSect = 0;
-
+
// Empty file, so empty read buffer
memset (file->readBuffer, 0, BYTE_PER_READ);
file->inUse = true; // We're using this file now
@@ -2332,7 +2332,7 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
{
dirEntry.attrib = ATTRIB_ARCH;
dirEntry.reserved = 0;
-
+
// Time and date set to system time and date
dirEntry.cTime_ms = 0;
dirEntry.cTime = getRTCtoFileTime();
@@ -2352,13 +2352,13 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
}
dirEntry.startCluster = (startCluster & 0xFFFF);
dirEntry.startClusterHigh = ((startCluster >> 16) & 0xFFFF);
-
+
if(!FAT_AddDirEntry (path, dirEntry))
return NULL;
-
+
// Get the newly created dirEntry
dirEntry = FAT_DirEntFromPath (path);
-
+
// Store append cluster
file->appClus = startCluster;
@@ -2377,7 +2377,7 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
{
return NULL;
}
-
+
// Store cluster position into the directory entry
dirEntry.startCluster = (file->firstCluster & 0xFFFF);
dirEntry.startClusterHigh = ((file->firstCluster >> 16) & 0xFFFF);
@@ -2387,7 +2387,7 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
// Store append cluster
file->appClus = startCluster;
-
+
} else {
// Follow cluster list until last one is found
@@ -2410,7 +2410,7 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
file->read = ( strchr(mode, '+') != NULL );
file->write = false;
file->append = true;
-
+
// Calculate the sector and byte of the current position,
// and store them
file->appSect = (dirEntry.fileSize % filesysBytePerClus) / BYTE_PER_READ;
@@ -2424,7 +2424,7 @@ FAT_FILE* FAT_fopen(const char* path, const char* mode)
file->curClus = file->appClus;
file->curSect = file->appSect;
file->curByte = file->appByte;
-
+
// Read into buffer
disc_ReadSector( FAT_ClustToSect(file->curClus) + file->curSect, file->readBuffer);
file->inUse = true; // We're using this file now
@@ -2464,7 +2464,7 @@ bool FAT_fclose (FAT_FILE* file)
disc_CacheFlush();
}
#endif
- file->inUse = false;
+ file->inUse = false;
return true;
}
else
@@ -2515,14 +2515,14 @@ int FAT_fseek(FAT_FILE* file, s32 offset, int origin)
}
// Can't seek in append only mode
- if (!file->read && !file->write)
+ if (!file->read && !file->write)
{
return -1;
}
curPos = file->curPos;
- switch (origin)
+ switch (origin)
{
case SEEK_SET:
if (offset >= 0)
@@ -2537,13 +2537,13 @@ int FAT_fseek(FAT_FILE* file, s32 offset, int origin)
if (offset >= 0)
{
position = curPos + offset;
- }
+ }
else if ( (u32)(offset * -1) >= curPos )
{
// Tried to seek before start of file
position = 0;
}
- else
+ else
{
// Using u32 to maintain 32 bits of accuracy
position = curPos - (u32)(offset * -1);
@@ -2560,7 +2560,7 @@ int FAT_fseek(FAT_FILE* file, s32 offset, int origin)
// Tried to seek before start of file
position = 0;
}
- else
+ else
{
// Using u32 to maintain 32 bits of accuracy
position = file->length - (u32)(offset * -1);
@@ -2575,7 +2575,7 @@ int FAT_fseek(FAT_FILE* file, s32 offset, int origin)
// Tried to go past end of file
position = file->length;
}
-
+
// Save position
file->curPos = position;
@@ -2608,14 +2608,14 @@ int FAT_fseek(FAT_FILE* file, s32 offset, int origin)
nextCluster = FAT_NextCluster (cluster);
}
// Check if ran out of clusters, and the file is being written to
- if ((clusCount >= 0) && (file->write || file->append))
+ if ((clusCount >= 0) && (file->write || file->append))
{
// Set flag to allocate a new cluster
file->curSect = filesysSecPerClus;
file->curByte = 0;
}
file->curClus = cluster;
-
+
// Reload sector buffer for new position in file, if it is a different sector
if ((curPos ^ position) >= BYTE_PER_READ)
{
@@ -2645,7 +2645,7 @@ u32 FAT_fread (void* buffer, u32 size, u32 count, FAT_FILE* file)
int curSect;
u32 curClus;
u32 tempNextCluster;
-
+
int tempVar;
char* data = (char*)buffer;
@@ -2678,14 +2678,14 @@ u32 FAT_fread (void* buffer, u32 size, u32 count, FAT_FILE* file)
if (tempVar > remain)
tempVar = remain;
- if ((tempVar < BYTE_PER_READ) && flagNoError)
+ if ((tempVar < BYTE_PER_READ) && flagNoError)
{
memcpy(data, &(file->readBuffer[curByte]), tempVar);
remain -= tempVar;
data += tempVar;
curByte += tempVar;
- if (curByte >= BYTE_PER_READ)
+ if (curByte >= BYTE_PER_READ)
{
curByte = 0;
curSect++;
@@ -2694,7 +2694,7 @@ u32 FAT_fread (void* buffer, u32 size, u32 count, FAT_FILE* file)
// align to cluster
// tempVar is number of sectors to read
- if (remain > (filesysSecPerClus - curSect) * BYTE_PER_READ)
+ if (remain > (filesysSecPerClus - curSect) * BYTE_PER_READ)
{
tempVar = filesysSecPerClus - curSect;
} else {
@@ -2789,7 +2789,7 @@ u32 FAT_fread (void* buffer, u32 size, u32 count, FAT_FILE* file)
FAT_fwrite(buffer, size, count, file)
Writes size * count bytes into file from buffer, starting
from current position. It then sets the current position to the
- byte after the last byte written. If the file was openned in
+ byte after the last byte written. If the file was openned in
append mode it always writes to the end of the file.
const void* buffer IN: Pointer to buffer containing data. Should be
at least as big as the number of bytes to be written.
@@ -2870,7 +2870,7 @@ u32 FAT_fwrite (const void* buffer, u32 size, u32 count, FAT_FILE* file)
disc_ReadSector( FAT_ClustToSect( curClus), writeBuffer);
}
}
-
+
// Align to sector
tempVar = BYTE_PER_READ - curByte;
if (tempVar > remain)
@@ -2885,9 +2885,9 @@ u32 FAT_fwrite (const void* buffer, u32 size, u32 count, FAT_FILE* file)
// Write buffer back to disk
disc_WriteSector (curSect + FAT_ClustToSect(curClus), writeBuffer);
-
+
// Move onto next sector
- if (curByte >= BYTE_PER_READ)
+ if (curByte >= BYTE_PER_READ)
{
curByte = 0;
curSect++;
@@ -2896,7 +2896,7 @@ u32 FAT_fwrite (const void* buffer, u32 size, u32 count, FAT_FILE* file)
// Align to cluster
// tempVar is number of sectors to write
- if (remain > (filesysSecPerClus - curSect) * BYTE_PER_READ)
+ if (remain > (filesysSecPerClus - curSect) * BYTE_PER_READ)
{
tempVar = filesysSecPerClus - curSect;
} else {
@@ -2964,7 +2964,7 @@ u32 FAT_fwrite (const void* buffer, u32 size, u32 count, FAT_FILE* file)
remain -= tempVar * BYTE_PER_READ;
curSect += tempVar;
}
-
+
// Last remaining sector
// Check if sector wanted is different to the one started with
if ( (( (file->append ? file->appByte : file->curByte) + length) >= BYTE_PER_READ) && flagNoError)
@@ -2984,7 +2984,7 @@ u32 FAT_fwrite (const void* buffer, u32 size, u32 count, FAT_FILE* file)
disc_WriteSector( curSect + FAT_ClustToSect( curClus), writeBuffer);
}
}
-
+
// Amount read is the originally requested amount minus stuff remaining
length = length - remain;
@@ -3041,14 +3041,14 @@ int FAT_remove (const char* path)
u32 oldWorkDirCluster;
char checkFilename[13];
FILE_TYPE checkFiletype;
-
+
dirEntry = FAT_DirEntFromPath (path);
if (dirEntry.name[0] == FILE_FREE)
{
return -1;
}
-
+
// Only delete directories if the directory is entry
if (dirEntry.attrib & ATTRIB_DIR)
{
@@ -3062,10 +3062,10 @@ int FAT_remove (const char* path)
{
checkFiletype = FAT_FindNextFile (checkFilename);
}
-
+
// Change back to working directory
curWorkDirCluster = oldWorkDirCluster;
-
+
// Check that the directory is empty
if (checkFiletype != FT_NONE)
{
@@ -3084,7 +3084,7 @@ int FAT_remove (const char* path)
disc_ReadSector ( (wrkDirCluster == FAT16_ROOT_DIR_CLUSTER ? filesysRootDir : FAT_ClustToSect(wrkDirCluster)) + wrkDirSector , globalBuffer);
((DIR_ENT*)globalBuffer)[wrkDirOffset].name[0] = FILE_FREE;
disc_WriteSector ( (wrkDirCluster == FAT16_ROOT_DIR_CLUSTER ? filesysRootDir : FAT_ClustToSect(wrkDirCluster)) + wrkDirSector , globalBuffer);
-
+
// Flush any sectors in disc cache
disc_CacheFlush();
@@ -3095,7 +3095,7 @@ int FAT_remove (const char* path)
#ifdef CAN_WRITE_TO_DISC
/*-----------------------------------------------------------------
FAT_mkdir (path)
-Makes a new directory, so long as no other directory or file has
+Makes a new directory, so long as no other directory or file has
the same name.
const char* path IN: Path and filename of directory to make
int return OUT: zero if successful, non-zero if not
@@ -3123,7 +3123,7 @@ int FAT_mkdir (const char* path)
{
curWorkDirCluster = filesysRootDirClus;
}
-
+
pathPos = 0;
filePos = 0;
@@ -3132,7 +3132,7 @@ int FAT_mkdir (const char* path)
if (path[pathPos + filePos] == '/')
{
pathname[filePos] = '\0';
- if (FAT_chdir(pathname) == false)
+ if (FAT_chdir(pathname) == false)
{
curWorkDirCluster = oldDirCluster;
return -1; // Couldn't change directory
@@ -3236,9 +3236,9 @@ FAT_fgets (char *tgtBuffer, int num, FAT_FILE* file)
Gets a up to num bytes from file, stopping at the first
newline.
-CAUTION: does not do strictly streaming. I.e. it's
+CAUTION: does not do strictly streaming. I.e. it's
reading more then needed bytes and seeking back.
- shouldn't matter for random access
+ shouldn't matter for random access
char *tgtBuffer OUT: buffer to write to
int num IN: size of target buffer
@@ -3250,62 +3250,62 @@ bool return OUT: character if successful, EOF if not
* Added check for unix style text files
* Removed seek when no newline is found, since it isn't necessary
-------------------------------------------------------------------*/
-char *FAT_fgets(char *tgtBuffer, int num, FAT_FILE* file)
-{
+char *FAT_fgets(char *tgtBuffer, int num, FAT_FILE* file)
+{
u32 curPos;
u32 readLength;
char *returnChar;
-
- // invalid filehandle
+
+ // invalid filehandle
if (file == NULL)
{
- return NULL ;
+ return NULL ;
}
-
- // end of file
+
+ // end of file
if (FAT_feof(file)==true)
{
- return NULL ;
- }
-
- // save current position
- curPos = FAT_ftell(file);
-
- // read the full buffer (max string chars is num-1 and one end of string \0
- readLength = FAT_fread(tgtBuffer,1,num-1,file) ;
-
- // mark least possible end of string
- tgtBuffer[readLength] = '\0' ;
-
- if (readLength==0) {
- // return error
- return NULL ;
- }
-
- // get position of first return '\r'
- returnChar = strchr(tgtBuffer,'\r');
-
+ return NULL ;
+ }
+
+ // save current position
+ curPos = FAT_ftell(file);
+
+ // read the full buffer (max string chars is num-1 and one end of string \0
+ readLength = FAT_fread(tgtBuffer,1,num-1,file) ;
+
+ // mark least possible end of string
+ tgtBuffer[readLength] = '\0' ;
+
+ if (readLength==0) {
+ // return error
+ return NULL ;
+ }
+
+ // get position of first return '\r'
+ returnChar = strchr(tgtBuffer,'\r');
+
// if no return is found, search for a newline
if (returnChar == NULL)
{
returnChar = strchr(tgtBuffer,'\n');
}
-
- // Mark the return, if existant, as end of line/string
- if (returnChar!=NULL) {
- *returnChar++ = 0 ;
- if (*returnChar=='\n') { // catch newline too when jumping over the end
- // return to location after \r\n (strlen+2)
- FAT_fseek(file,curPos+strlen(tgtBuffer)+2,SEEK_SET) ;
- return tgtBuffer ;
- } else {
- // return to location after \r (strlen+1)
- FAT_fseek(file,curPos+strlen(tgtBuffer)+1,SEEK_SET) ;
- return tgtBuffer ;
+
+ // Mark the return, if existant, as end of line/string
+ if (returnChar!=NULL) {
+ *returnChar++ = 0 ;
+ if (*returnChar=='\n') { // catch newline too when jumping over the end
+ // return to location after \r\n (strlen+2)
+ FAT_fseek(file,curPos+strlen(tgtBuffer)+2,SEEK_SET) ;
+ return tgtBuffer ;
+ } else {
+ // return to location after \r (strlen+1)
+ FAT_fseek(file,curPos+strlen(tgtBuffer)+1,SEEK_SET) ;
+ return tgtBuffer ;
}
}
-
- return tgtBuffer ;
+
+ return tgtBuffer ;
}
#ifdef CAN_WRITE_TO_DISC
@@ -3322,20 +3322,20 @@ bool return OUT: number of characters written if successful,
* Uses FAT_FILE instead of int
* writtenBytes is now u32 instead of int
-------------------------------------------------------------------*/
-int FAT_fputs (const char *string, FAT_FILE* file)
-{
+int FAT_fputs (const char *string, FAT_FILE* file)
+{
u32 writtenBytes;
- // save string except end of string '\0'
- writtenBytes = FAT_fwrite((void *)string, 1, strlen(string), file);
+ // save string except end of string '\0'
+ writtenBytes = FAT_fwrite((void *)string, 1, strlen(string), file);
- // check if we had an error
- if (writtenBytes != strlen(string))
- {
- // return EOF error
+ // check if we had an error
+ if (writtenBytes != strlen(string))
+ {
+ // return EOF error
return EOF;
}
- // return the charcount written
- return writtenBytes ;
+ // return the charcount written
+ return writtenBytes ;
}
#endif
diff --git a/backends/platform/ds/arm9/source/fat/gba_nds_fat.h b/backends/platform/ds/arm9/source/fat/gba_nds_fat.h
index b238182e14..c554cc80f6 100644
--- a/backends/platform/ds/arm9/source/fat/gba_nds_fat.h
+++ b/backends/platform/ds/arm9/source/fat/gba_nds_fat.h
@@ -147,7 +147,7 @@ bool FAT_GetAlias (char* alias);
/*-----------------------------------------------------------------
FAT_GetLongFilename
-Get the long name of the last file or directory retrived with
+Get the long name of the last file or directory retrived with
GetDirEntry. Also works for FindFirstFile and FindNextFile
char* filename: OUT will be filled with the filename, should be at
least 256 bytes long
@@ -210,7 +210,7 @@ FAT_FindNextFile
Gets the name of the next directory entry
(can be a file or subdirectory)
char* filename: OUT filename, must be at least 13 chars long
-FILE_TYPE return: OUT returns FT_NONE if failed,
+FILE_TYPE return: OUT returns FT_NONE if failed,
FT_FILE if it found a file and FT_DIR if it found a directory
-----------------------------------------------------------------*/
FILE_TYPE FAT_FindNextFile (char* filename);
@@ -220,7 +220,7 @@ FAT_FindFirstFile
Gets the name of the first directory entry and resets the count
(can be a file or subdirectory)
char* filename: OUT filename, must be at least 13 chars long
-FILE_TYPE return: OUT returns FT_NONE if failed,
+FILE_TYPE return: OUT returns FT_NONE if failed,
FT_FILE if it found a file and FT_DIR if it found a directory
-----------------------------------------------------------------*/
FILE_TYPE FAT_FindFirstFile (char* filename);
@@ -230,7 +230,7 @@ FAT_FindFirstFileLFN
Gets the long file name of the first directory entry and resets
the count (can be a file or subdirectory)
char* lfn: OUT long file name, must be at least 256 chars long
-FILE_TYPE return: OUT returns FT_NONE if failed,
+FILE_TYPE return: OUT returns FT_NONE if failed,
FT_FILE if it found a file and FT_DIR if it found a directory
-----------------------------------------------------------------*/
FILE_TYPE FAT_FindFirstFileLFN(char* lfn);
@@ -240,16 +240,16 @@ FAT_FindNextFileLFN
Gets the long file name of the next directory entry
(can be a file or subdirectory)
char* lfn: OUT long file name, must be at least 256 chars long
-FILE_TYPE return: OUT returns FT_NONE if failed,
+FILE_TYPE return: OUT returns FT_NONE if failed,
FT_FILE if it found a file and FT_DIR if it found a directory
-----------------------------------------------------------------*/
FILE_TYPE FAT_FindNextFileLFN(char* lfn);
/*-----------------------------------------------------------------
FAT_FileExists
-Returns the type of file
+Returns the type of file
char* filename: IN filename of the file to look for
-FILE_TYPE return: OUT returns FT_NONE if there is now file with
+FILE_TYPE return: OUT returns FT_NONE if there is now file with
that name, FT_FILE if it is a file and FT_DIR if it is a directory
-----------------------------------------------------------------*/
FILE_TYPE FAT_FileExists (const char* filename);
@@ -269,7 +269,7 @@ u32 FAT_GetFileSystemTotalSize (void);
/*-----------------------------------------------------------------
FAT_chdir
Changes the current working directory
-const char* path: IN null terminated string of directory separated by
+const char* path: IN null terminated string of directory separated by
forward slashes, / is root
bool return: OUT returns true if successful
-----------------------------------------------------------------*/
@@ -282,12 +282,12 @@ bool FAT_chdir (const char* path);
/*-----------------------------------------------------------------
FAT_fopen(filename, mode)
Opens a file
-const char* path: IN null terminated string of filename and path
+const char* path: IN null terminated string of filename and path
separated by forward slashes, / is root
const char* mode: IN mode to open file in
Supported modes: "r", "r+", "w", "w+", "a", "a+", don't use
"b" or "t" in any mode, as all files are openned in binary mode
-FAT_FILE* return: OUT handle to open file, returns -1 if the file
+FAT_FILE* return: OUT handle to open file, returns -1 if the file
couldn't be openned
-----------------------------------------------------------------*/
FAT_FILE* FAT_fopen(const char* path, const char* mode);
@@ -338,7 +338,7 @@ u32 FAT_fread (void* buffer, u32 size, u32 count, FAT_FILE* file);
FAT_fwrite(buffer, size, count, file)
Writes size * count bytes into file from buffer, starting
from current position. It then sets the current position to the
- byte after the last byte written. If the file was openned in
+ byte after the last byte written. If the file was openned in
append mode it always writes to the end of the file.
const void* buffer IN: Pointer to buffer containing data. Should be
at least as big as the number of bytes to be written.
@@ -371,7 +371,7 @@ int FAT_remove (const char* path);
#ifdef CAN_WRITE_TO_DISC
/*-----------------------------------------------------------------
FAT_mkdir (path)
-Makes a new directory, so long as no other directory or file has
+Makes a new directory, so long as no other directory or file has
the same name.
const char* path IN: Path and filename of directory to make
int return OUT: zero if successful, non-zero if not
@@ -403,9 +403,9 @@ FAT_fgets (char *tgtBuffer, int num, FAT_FILE* file)
Gets a up to num bytes from file, stopping at the first
newline.
-CAUTION: does not do strictly streaming. I.e. it's
+CAUTION: does not do strictly streaming. I.e. it's
reading more then needed bytes and seeking back.
- shouldn't matter for random access
+ shouldn't matter for random access
char *tgtBuffer OUT: buffer to write to
int num IN: size of target buffer
diff --git a/backends/platform/ds/arm9/source/fat/io_dldi.h b/backends/platform/ds/arm9/source/fat/io_dldi.h
index 053de3a94c..034c6aace3 100644
--- a/backends/platform/ds/arm9/source/fat/io_dldi.h
+++ b/backends/platform/ds/arm9/source/fat/io_dldi.h
@@ -1,8 +1,8 @@
/*
- io_dldi.h
+ io_dldi.h
Reserved space for new drivers
-
+
This software is completely free. No warranty is provided.
If you use it, please give me credit and email me about your
project at chishm@hotmail.com
diff --git a/backends/platform/ds/arm9/source/fat/io_dldi.s b/backends/platform/ds/arm9/source/fat/io_dldi.s
index c2314e772d..311d43f3ff 100644
--- a/backends/platform/ds/arm9/source/fat/io_dldi.s
+++ b/backends/platform/ds/arm9/source/fat/io_dldi.s
@@ -18,7 +18,7 @@
.byte 0x0F @32KiB @ Log [base-2] of the size of this driver in bytes.
.byte 0x00 @ Sections to fix
.byte 0x0F @32KiB @ Log [base-2] of the allocated space in bytes.
-
+
@---------------------------------------------------------------------------------
@ Text identifier - can be anything up to 47 chars + terminating null -- 16 bytes
.align 4
@@ -42,13 +42,13 @@ _dldi_driver_name:
_io_dldi:
.ascii "DLDI" @ ioType
.word 0x00000000 @ Features
- .word _DLDI_startup @
- .word _DLDI_isInserted @
+ .word _DLDI_startup @
+ .word _DLDI_isInserted @
.word _DLDI_readSectors @ Function pointers to standard device driver functions
- .word _DLDI_writeSectors @
- .word _DLDI_clearStatus @
- .word _DLDI_shutdown @
-
+ .word _DLDI_writeSectors @
+ .word _DLDI_clearStatus @
+ .word _DLDI_shutdown @
+
@---------------------------------------------------------------------------------
_DLDI_startup:
diff --git a/backends/platform/ds/arm9/source/fat/io_efa2.c b/backends/platform/ds/arm9/source/fat/io_efa2.c
index f3aa65cfcb..468361969e 100644
--- a/backends/platform/ds/arm9/source/fat/io_efa2.c
+++ b/backends/platform/ds/arm9/source/fat/io_efa2.c
@@ -47,7 +47,7 @@ See gba_nds_fat.txt for help and license details.
// ID of Samsung K9K1G NAND flash chip
#define EFA2_NAND_ID 0xEC79A5C0
-// first sector of udisk
+// first sector of udisk
#define EFA2_UDSK_START 0x40
//
@@ -101,7 +101,7 @@ void efa2_nand_lock(void) {
//
// Set NAND Flash chip enable and write protection bits ?
-//
+//
// val | ~CE | ~WP |
// -----+-----+-----+
// 0 | 0 | 0 |
@@ -125,7 +125,7 @@ inline void efa2_nand_reset(void) {
//
// Read out NAND ID information, could be used for card detection
-//
+//
// | EFA2 1GBit |
// ------------------+------------+
// maker code | 0xEC |
@@ -166,7 +166,7 @@ EFA2_ClearStatus
Reads and checks NAND status information
bool return OUT: true if NAND is idle
-----------------------------------------------------------------*/
-bool EFA2_ClearStatus (void)
+bool EFA2_ClearStatus (void)
{
// tbd: currently there is no write support, so always return
// true, there is no possibility for pending operations
@@ -178,7 +178,7 @@ EFA2_IsInserted
Checks to see if the NAND chip used by the EFA2 is present
bool return OUT: true if the correct NAND chip is found
-----------------------------------------------------------------*/
-bool EFA2_IsInserted (void)
+bool EFA2_IsInserted (void)
{
EFA2_ClearStatus();
return (efa2_nand_id() == EFA2_NAND_ID);
@@ -223,7 +223,7 @@ bool EFA2_ReadSectors (u32 sector, u8 numSecs, void* buffer)
efa2_nand_reset();
// set NAND to READ1 operation mode and transfer page address
- REG_EFA2_NAND_CMD = 0x00; // write READ1 command
+ REG_EFA2_NAND_CMD = 0x00; // write READ1 command
REG_EFA2_NAND_WR = 0x00; // write address [7:0]
REG_EFA2_NAND_WR = (page ) & 0xff; // write address [15:8]
REG_EFA2_NAND_WR = (page >> 8 ) & 0xff; // write address[23:16]
@@ -280,7 +280,7 @@ bool EFA2_WriteSectors (u32 sector, u8 numSecs, void* buffer)
EFA2_Shutdown
unload the EFA2 interface
-----------------------------------------------------------------*/
-bool EFA2_Shutdown(void)
+bool EFA2_Shutdown(void)
{
return EFA2_ClearStatus();
}
@@ -368,7 +368,7 @@ See gba_nds_fat.txt for help and license details.
// ID of Samsung K9K1G NAND flash chip
#define EFA2_NAND_ID 0xEC79A5C0
-// first sector of udisk
+// first sector of udisk
#define EFA2_UDSK_START 0x40
//
@@ -422,7 +422,7 @@ void efa2_nand_lock(void) {
//
// Set NAND Flash chip enable and write protection bits ?
-//
+//
// val | ~CE | ~WP |
// -----+-----+-----+
// 0 | 0 | 0 |
@@ -446,7 +446,7 @@ inline void efa2_nand_reset(void) {
//
// Read out NAND ID information, could be used for card detection
-//
+//
// | EFA2 1GBit |
// ------------------+------------+
// maker code | 0xEC |
@@ -487,7 +487,7 @@ EFA2_ClearStatus
Reads and checks NAND status information
bool return OUT: true if NAND is idle
-----------------------------------------------------------------*/
-bool EFA2_ClearStatus (void)
+bool EFA2_ClearStatus (void)
{
// tbd: currently there is no write support, so always return
// true, there is no possibility for pending operations
@@ -499,7 +499,7 @@ EFA2_IsInserted
Checks to see if the NAND chip used by the EFA2 is present
bool return OUT: true if the correct NAND chip is found
-----------------------------------------------------------------*/
-bool EFA2_IsInserted (void)
+bool EFA2_IsInserted (void)
{
EFA2_ClearStatus();
return (efa2_nand_id() == EFA2_NAND_ID);
@@ -544,7 +544,7 @@ bool EFA2_ReadSectors (u32 sector, u8 numSecs, void* buffer)
efa2_nand_reset();
// set NAND to READ1 operation mode and transfer page address
- REG_EFA2_NAND_CMD = 0x00; // write READ1 command
+ REG_EFA2_NAND_CMD = 0x00; // write READ1 command
REG_EFA2_NAND_WR = 0x00; // write address [7:0]
REG_EFA2_NAND_WR = (page ) & 0xff; // write address [15:8]
REG_EFA2_NAND_WR = (page >> 8 ) & 0xff; // write address[23:16]
@@ -601,7 +601,7 @@ bool EFA2_WriteSectors (u32 sector, u8 numSecs, void* buffer)
EFA2_Shutdown
unload the EFA2 interface
-----------------------------------------------------------------*/
-bool EFA2_Shutdown(void)
+bool EFA2_Shutdown(void)
{
return EFA2_ClearStatus();
}
diff --git a/backends/platform/ds/arm9/source/fat/io_fcsr.c b/backends/platform/ds/arm9/source/fat/io_fcsr.c
index d576dfbb0f..7a67a6b1b0 100644
--- a/backends/platform/ds/arm9/source/fat/io_fcsr.c
+++ b/backends/platform/ds/arm9/source/fat/io_fcsr.c
@@ -4,7 +4,7 @@
compact_flash.c
By chishm (Michael Chisholm)
- Hardware Routines for using a GBA Flash Cart and SRAM as a
+ Hardware Routines for using a GBA Flash Cart and SRAM as a
block device.
This software is completely free. No warranty is provided.
@@ -57,7 +57,7 @@ FCSR_IsInserted
Is a GBA Flash Cart with a valid file system inserted?
bool return OUT: true if a GBA FC card is inserted
-----------------------------------------------------------------*/
-bool FCSR_IsInserted (void)
+bool FCSR_IsInserted (void)
{
bool flagFoundFileSys = false;
@@ -85,7 +85,7 @@ FCSR_ClearStatus
Finish any pending operations
bool return OUT: always true for GBA FC
-----------------------------------------------------------------*/
-bool FCSR_ClearStatus (void)
+bool FCSR_ClearStatus (void)
{
return true;
}
@@ -101,7 +101,7 @@ void* buffer OUT: pointer to 512 byte buffer to store data in
bool return OUT: true if successful
-----------------------------------------------------------------*/
bool FCSR_ReadSectors (u32 sector, u8 numSecs, void* buffer)
-{
+{
int i;
bool flagSramSector = false;
int numSectors = (numSecs > 0 ? numSecs : 256);
@@ -208,14 +208,14 @@ bool FCSR_WriteSectors (u32 sector, u8 numSecs, void* buffer)
FCSR_Shutdown
unload the Flash Cart interface
-----------------------------------------------------------------*/
-bool FCSR_Shutdown(void)
+bool FCSR_Shutdown(void)
{
int i;
if (FCSR_ClearStatus() == false)
return false;
FCSR_FileSysPointer = 0;
-
+
for (i=0; i < 4; i++)
{
FCSR_SramSectorPointer[i] = 0;
@@ -262,11 +262,11 @@ bool FCSR_StartUp(void)
// Get SRAM sector regions from header block
for (i = 0; i < 4; i++)
{
- FCSR_SramSectorStart[i] = fileSysPointer[i+4];
+ FCSR_SramSectorStart[i] = fileSysPointer[i+4];
SramRegionSize[i] = fileSysPointer[i+8];
FCSR_SramSectorEnd[i] = FCSR_SramSectorStart[i] + SramRegionSize[i];
}
-
+
// Calculate SRAM region pointers
FCSR_SramSectorPointer[0] = (u8*)(SRAM_START + 4);
for (i = 1; i < 4; i++)
diff --git a/backends/platform/ds/arm9/source/fat/io_fcsr.h b/backends/platform/ds/arm9/source/fat/io_fcsr.h
index 2f87c1c8aa..ef390a8ad6 100644
--- a/backends/platform/ds/arm9/source/fat/io_fcsr.h
+++ b/backends/platform/ds/arm9/source/fat/io_fcsr.h
@@ -1,5 +1,5 @@
/*
- io_fcsr.h
+ io_fcsr.h
Hardware Routines for using a GBA Flash Cart with SRAM
@@ -23,7 +23,7 @@ extern LPIO_INTERFACE FCSR_GetInterface(void) ;
#endif // define IO_FCSR_H
/*
- io_fcsr.h
+ io_fcsr.h
Hardware Routines for using a GBA Flash Cart with SRAM
diff --git a/backends/platform/ds/arm9/source/fat/io_m3_common.c b/backends/platform/ds/arm9/source/fat/io_m3_common.c
index ab2c143327..9c8280c808 100644
--- a/backends/platform/ds/arm9/source/fat/io_m3_common.c
+++ b/backends/platform/ds/arm9/source/fat/io_m3_common.c
@@ -1,13 +1,13 @@
/*
- io_m3_common.c
+ io_m3_common.c
Routines common to all version of the M3
-
+
Some code based on M3 SD drivers supplied by M3Adapter.
Some code written by SaTa may have been unknowingly used.
Copyright (c) 2006 Michael "Chishm" Chisholm
-
+
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -47,7 +47,7 @@ void _M3_changeMode (u32 mode) {
_M3_readHalfword (0x08000000 + (mode << 1));
_M3_readHalfword (0x0800080e);
_M3_readHalfword (0x08000000);
-
+
if ((mode & 0x0f) != 4) {
_M3_readHalfword (0x09000000);
} else {
@@ -56,5 +56,5 @@ void _M3_changeMode (u32 mode) {
_M3_readHalfword (0x08000188);
_M3_readHalfword (0x08000188);
}
-}
+}
diff --git a/backends/platform/ds/arm9/source/fat/io_m3_common.h b/backends/platform/ds/arm9/source/fat/io_m3_common.h
index 92e6bed980..6d0c669783 100644
--- a/backends/platform/ds/arm9/source/fat/io_m3_common.h
+++ b/backends/platform/ds/arm9/source/fat/io_m3_common.h
@@ -1,5 +1,5 @@
/*
- io_m3_common.h
+ io_m3_common.h
Routines common to all version of the M3
@@ -7,7 +7,7 @@
Some code written by SaTa may have been unknowingly used.
Copyright (c) 2006 Michael "Chishm" Chisholm
-
+
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -40,7 +40,7 @@
// Values for changing mode
#define M3_MODE_ROM 0x00400004
-#define M3_MODE_MEDIA 0x00400003
+#define M3_MODE_MEDIA 0x00400003
extern void _M3_changeMode (u32 mode);
diff --git a/backends/platform/ds/arm9/source/fat/io_m3cf.c b/backends/platform/ds/arm9/source/fat/io_m3cf.c
index 910f01097e..968d83ae33 100644
--- a/backends/platform/ds/arm9/source/fat/io_m3cf.c
+++ b/backends/platform/ds/arm9/source/fat/io_m3cf.c
@@ -73,7 +73,7 @@ M3CF_IsInserted
Is a compact flash card inserted?
bool return OUT: true if a CF card is inserted
-----------------------------------------------------------------*/
-bool M3CF_IsInserted (void)
+bool M3CF_IsInserted (void)
{
// Change register, then check if value did change
M3_REG_STS = CF_STS_INSERTED;
@@ -86,17 +86,17 @@ M3CF_ClearStatus
Tries to make the CF card go back to idle mode
bool return OUT: true if a CF card is idle
-----------------------------------------------------------------*/
-bool M3CF_ClearStatus (void)
+bool M3CF_ClearStatus (void)
{
int i;
-
+
// Wait until CF card is finished previous commands
i=0;
while ((M3_REG_CMD & CF_STS_BUSY) && (i < CARD_TIMEOUT))
{
i++;
}
-
+
// Wait until card is ready for commands
i = 0;
while ((!(M3_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT))
@@ -128,7 +128,7 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer)
u8 *buff_u8 = (u8*)buffer;
int temp;
#endif
-
+
#if defined _CF_USE_DMA && defined NDS && defined ARM9
DC_FlushRange( buffer, j * BYTE_PER_READ);
#endif
@@ -139,7 +139,7 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer)
{
i++;
}
-
+
// Wait until card is ready for commands
i = 0;
while ((!(M3_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT))
@@ -148,20 +148,20 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer)
}
if (i >= CARD_TIMEOUT)
return false;
-
+
// Set number of sectors to read
- M3_REG_SEC = numSecs;
-
+ M3_REG_SEC = numSecs;
+
// Set read sector
M3_REG_LBA1 = sector & 0xFF; // 1st byte of sector number
M3_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number
M3_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number
M3_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number
-
+
// Set command to read
M3_REG_CMD = CF_CMD_READ;
-
-
+
+
while (j--)
{
// Wait until card is ready for reading
@@ -172,7 +172,7 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer)
}
if (i >= CARD_TIMEOUT)
return false;
-
+
// Read data
#ifdef _CF_USE_DMA
#ifdef NDS
@@ -194,12 +194,12 @@ bool M3CF_ReadSectors (u32 sector, u8 numSecs, void* buffer)
}
} else {
while(i--)
- *buff++ = *M3_DATA;
+ *buff++ = *M3_DATA;
}
#else
i=256;
while(i--)
- *buff++ = *M3_DATA;
+ *buff++ = *M3_DATA;
#endif
}
#if defined _CF_USE_DMA && defined NDS
@@ -230,7 +230,7 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
u8 *buff_u8 = (u8*)buffer;
int temp;
#endif
-
+
#if defined _CF_USE_DMA && defined NDS && defined ARM9
DC_FlushRange( buffer, j * BYTE_PER_READ);
#endif
@@ -241,7 +241,7 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
{
i++;
}
-
+
// Wait until card is ready for commands
i = 0;
while ((!(M3_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT))
@@ -250,19 +250,19 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
}
if (i >= CARD_TIMEOUT)
return false;
-
+
// Set number of sectors to write
- M3_REG_SEC = numSecs;
-
+ M3_REG_SEC = numSecs;
+
// Set write sector
M3_REG_LBA1 = sector & 0xFF; // 1st byte of sector number
M3_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number
M3_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number
M3_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number
-
+
// Set command to write
M3_REG_CMD = CF_CMD_WRITE;
-
+
while (j--)
{
// Wait until card is ready for writing
@@ -273,7 +273,7 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
}
if (i >= CARD_TIMEOUT)
return false;
-
+
// Write data
#ifdef _CF_USE_DMA
#ifdef NDS
@@ -295,19 +295,19 @@ bool M3CF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
}
} else {
while(i--)
- *M3_DATA = *buff++;
+ *M3_DATA = *buff++;
}
#else
i=256;
while(i--)
- *M3_DATA = *buff++;
+ *M3_DATA = *buff++;
#endif
}
#if defined _CF_USE_DMA && defined NDS
// Wait for end of transfer before returning
while(DMA3_CR & DMA_BUSY);
#endif
-
+
return true;
}
@@ -317,7 +317,7 @@ M3_Unlock
Returns true if M3 was unlocked, false if failed
Added by MightyMax
-----------------------------------------------------------------*/
-bool M3_Unlock(void)
+bool M3_Unlock(void)
{
// run unlock sequence
volatile unsigned short tmp ;
diff --git a/backends/platform/ds/arm9/source/fat/io_m3cf.h b/backends/platform/ds/arm9/source/fat/io_m3cf.h
index bade53f511..006c283adc 100644
--- a/backends/platform/ds/arm9/source/fat/io_m3cf.h
+++ b/backends/platform/ds/arm9/source/fat/io_m3cf.h
@@ -1,5 +1,5 @@
/*
- io_m3cf.h
+ io_m3cf.h
Hardware Routines for reading a compact flash card
using the M3 CF
@@ -24,7 +24,7 @@ extern LPIO_INTERFACE M3CF_GetInterface(void) ;
#endif // define IO_M3CF_H
/*
- io_m3cf.h
+ io_m3cf.h
Hardware Routines for reading a compact flash card
using the M3 CF
diff --git a/backends/platform/ds/arm9/source/fat/io_m3sd.c b/backends/platform/ds/arm9/source/fat/io_m3sd.c
index 914b83e06e..2bbda37a5a 100644
--- a/backends/platform/ds/arm9/source/fat/io_m3sd.c
+++ b/backends/platform/ds/arm9/source/fat/io_m3sd.c
@@ -218,7 +218,7 @@ void M3SD_writesector(u16 * p,u32 sectorn)
}
} while ((verify > 0) && (tries < 16));
-
+
free(data);
free(check);
} // */
@@ -356,7 +356,7 @@ bool M3SD_Shutdown(void)
bool M3SD_StartUp(void)
{
vu16* waitCr = (vu16*)0x4000204;
-
+
*waitCr |= 0x6000;
// *(vu16*)0x4000204=0x6000;
// Try unlocking 3 times, because occationally it fails to detect the reader.
diff --git a/backends/platform/ds/arm9/source/fat/io_m3sd_asm.s b/backends/platform/ds/arm9/source/fat/io_m3sd_asm.s
index ffaa971aca..a6bb8dc187 100644
--- a/backends/platform/ds/arm9/source/fat/io_m3sd_asm.s
+++ b/backends/platform/ds/arm9/source/fat/io_m3sd_asm.s
@@ -54,7 +54,7 @@ sd_write_loop2:
sd_write_busy:
bl clkin
- ldrh r0,[r1]
+ ldrh r0,[r1]
tst r0,#0x100
beq sd_write_busy
ldmfd r13!,{r0-r1}
@@ -68,10 +68,10 @@ SD_crc16:
stmfd r13!,{r4-r9}
mov r9,r2
- mov r3,#0
- mov r4,#0
- mov r5,#0
- mov r6,#0
+ mov r3,#0
+ mov r4,#0
+ mov r5,#0
+ mov r6,#0
ldr r7,=0x80808080
ldr r8,=0x1021
@@ -86,19 +86,19 @@ sd_crc16_loop:
eorne r3,r3,r8
tst r2,r7,lsr #24
eorne r3,r3,r8
-
+
mov r4,r4,lsl #1
tst r4,#0x10000
eorne r4,r4,r8
tst r2,r7,lsr #25
eorne r4,r4,r8
-
+
mov r5,r5,lsl #1
tst r5,#0x10000
eorne r5,r5,r8
tst r2,r7,lsr #26
eorne r5,r5,r8
-
+
mov r6,r6,lsl #1
tst r6,#0x10000
eorne r6,r6,r8
@@ -107,7 +107,7 @@ sd_crc16_loop:
mov r7,r7,ror #4
subs r1,r1,#4
- bne sd_crc16_loop
+ bne sd_crc16_loop
mov r2,r9
mov r8,#16
@@ -145,7 +145,7 @@ SD_data_write:
mov r2,#SDODA
sd_data_write_busy:
bl clkin
- ldrh r3,[r2]
+ ldrh r3,[r2]
tst r3,#0x100
beq sd_data_write_busy
@@ -169,7 +169,7 @@ sd_data_write_loop:
bl clkout
subs r5, r5, #2
- bne sd_data_write_loop
+ bne sd_data_write_loop
cmp r1,#0
movne r0,r1
@@ -184,10 +184,10 @@ sd_data_write_loop2:
bl clkout
subs r5, r5, #1
bne sd_data_write_loop2
-
+
sd_data_write_busy2:
bl clkin
- ldrh r3,[r2]
+ ldrh r3,[r2]
tst r3,#0x100
beq sd_data_write_busy2
diff --git a/backends/platform/ds/arm9/source/fat/io_mmcf.c b/backends/platform/ds/arm9/source/fat/io_mmcf.c
index 3034afe311..5ccb3122e4 100644
--- a/backends/platform/ds/arm9/source/fat/io_mmcf.c
+++ b/backends/platform/ds/arm9/source/fat/io_mmcf.c
@@ -74,14 +74,14 @@ static bool cf_block_ready(void)
do
{
while (!(CF_RD_STATUS & 0x40));
- } while (CF_RD_STATUS & 0x80);
+ } while (CF_RD_STATUS & 0x80);
*/
do
{
i++;
- while ( (!(CF_RD_STATUS & 0x40)) && (i < CARD_TIMEOUT) ) i++;
- } while ( (CF_RD_STATUS & 0x80) && (i < CARD_TIMEOUT) );
+ while ( (!(CF_RD_STATUS & 0x40)) && (i < CARD_TIMEOUT) ) i++;
+ } while ( (CF_RD_STATUS & 0x80) && (i < CARD_TIMEOUT) );
if (i >= CARD_TIMEOUT) {
return false;
@@ -110,7 +110,7 @@ MMCF_IsInserted
Is a compact flash card inserted?
bool return OUT: true if a CF card is inserted
-----------------------------------------------------------------*/
-bool MMCF_IsInserted (void)
+bool MMCF_IsInserted (void)
{
if ( !cf_set_features(0xAA) ) return false;
@@ -123,7 +123,7 @@ MMCF_ClearStatus
Tries to make the CF card go back to idle mode
bool return OUT: true if a CF card is idle
-----------------------------------------------------------------*/
-bool MMCF_ClearStatus (void)
+bool MMCF_ClearStatus (void)
{
return true;
}
@@ -185,7 +185,7 @@ bool MMCF_ReadSectors (u32 sector, u8 numSecs, void* buffer)
}
} else {
while(i--)
- *buff++ = *MP_DATA;
+ *buff++ = *MP_DATA;
}
#else
i=256;
@@ -222,15 +222,15 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
u8 *buff_u8 = (u8*)buffer;
int temp;
#endif
-
+
#if defined _CF_USE_DMA && defined NDS && defined ARM9
DC_FlushRange( buffer, j * BYTE_PER_READ);
#endif
- if (numSecs > 1)
+ if (numSecs > 1)
{
int r = 0;
-
+
for (r = 0; r < numSecs; r++)
{
MMCF_WriteSectors(sector + r, 1, ((unsigned char *) (buffer)) + 512);
@@ -270,12 +270,12 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
}
} else {
while(i--)
- *MP_DATA = *buff++;
+ *MP_DATA = *buff++;
}
#else
i=256;
while(i--)
- *MP_DATA = *buff++;
+ *MP_DATA = *buff++;
#endif
}
@@ -283,7 +283,7 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
#if defined _CF_USE_DMA && defined NDS
// Wait for end of transfer before returning
while(DMA3_CR & DMA_BUSY);
-#endif
+#endif
//#define _CF_VERIFY
@@ -312,7 +312,7 @@ bool MMCF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
MMCF_Shutdown
unload the GBAMP CF interface
-----------------------------------------------------------------*/
-bool MMCF_Shutdown(void)
+bool MMCF_Shutdown(void)
{
return MMCF_ClearStatus() ;
}
diff --git a/backends/platform/ds/arm9/source/fat/io_mmcf.h b/backends/platform/ds/arm9/source/fat/io_mmcf.h
index baa43ac59f..fa9e6536ee 100644
--- a/backends/platform/ds/arm9/source/fat/io_mmcf.h
+++ b/backends/platform/ds/arm9/source/fat/io_mmcf.h
@@ -1,5 +1,5 @@
/*
- io_mmcf.h
+ io_mmcf.h
Hardware Routines for reading a compact flash card
using the GBA Movie Player
diff --git a/backends/platform/ds/arm9/source/fat/io_mpcf.c b/backends/platform/ds/arm9/source/fat/io_mpcf.c
index a12b6e8e1e..6b56e29291 100644
--- a/backends/platform/ds/arm9/source/fat/io_mpcf.c
+++ b/backends/platform/ds/arm9/source/fat/io_mpcf.c
@@ -73,7 +73,7 @@ MPCF_IsInserted
Is a compact flash card inserted?
bool return OUT: true if a CF card is inserted
-----------------------------------------------------------------*/
-bool MPCF_IsInserted (void)
+bool MPCF_IsInserted (void)
{
// Change register, then check if value did change
MP_REG_STS = CF_STS_INSERTED;
@@ -86,17 +86,17 @@ MPCF_ClearStatus
Tries to make the CF card go back to idle mode
bool return OUT: true if a CF card is idle
-----------------------------------------------------------------*/
-bool MPCF_ClearStatus (void)
+bool MPCF_ClearStatus (void)
{
int i;
-
+
// Wait until CF card is finished previous commands
i=0;
while ((MP_REG_CMD & CF_STS_BUSY) && (i < CARD_TIMEOUT))
{
i++;
}
-
+
// Wait until card is ready for commands
i = 0;
while ((!(MP_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT))
@@ -139,7 +139,7 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer)
{
i++;
}
-
+
// Wait until card is ready for commands
i = 0;
while ((!(MP_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT))
@@ -148,20 +148,20 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer)
}
if (i >= CARD_TIMEOUT)
return false;
-
+
// Set number of sectors to read
- MP_REG_SEC = numSecs;
-
+ MP_REG_SEC = numSecs;
+
// Set read sector
MP_REG_LBA1 = sector & 0xFF; // 1st byte of sector number
MP_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number
MP_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number
MP_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number
-
+
// Set command to read
MP_REG_CMD = CF_CMD_READ;
-
-
+
+
while (j--)
{
// Wait until card is ready for reading
@@ -172,7 +172,7 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer)
}
if (i >= CARD_TIMEOUT)
return false;
-
+
// Read data
#ifdef _CF_USE_DMA
#ifdef NDS
@@ -194,12 +194,12 @@ bool MPCF_ReadSectors (u32 sector, u8 numSecs, void* buffer)
}
} else {
while(i--)
- *buff++ = *MP_DATA;
+ *buff++ = *MP_DATA;
}
#else
i=256;
while(i--)
- *buff++ = *MP_DATA;
+ *buff++ = *MP_DATA;
#endif
}
#if (defined _CF_USE_DMA) && (defined NDS)
@@ -229,7 +229,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
u8 *buff_u8 = (u8*)buffer;
int temp;
#endif
-
+
#if defined _CF_USE_DMA && defined NDS && defined ARM9
DC_FlushRange( buffer, j * BYTE_PER_READ);
#endif
@@ -240,7 +240,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
{
i++;
}
-
+
// Wait until card is ready for commands
i = 0;
while ((!(MP_REG_STS & CF_STS_INSERTED)) && (i < CARD_TIMEOUT))
@@ -249,19 +249,19 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
}
if (i >= CARD_TIMEOUT)
return false;
-
+
// Set number of sectors to write
- MP_REG_SEC = numSecs;
-
+ MP_REG_SEC = numSecs;
+
// Set write sector
MP_REG_LBA1 = sector & 0xFF; // 1st byte of sector number
MP_REG_LBA2 = (sector >> 8) & 0xFF; // 2nd byte of sector number
MP_REG_LBA3 = (sector >> 16) & 0xFF; // 3rd byte of sector number
MP_REG_LBA4 = ((sector >> 24) & 0x0F )| CF_CMD_LBA; // last nibble of sector number
-
+
// Set command to write
MP_REG_CMD = CF_CMD_WRITE;
-
+
while (j--)
{
// Wait until card is ready for writing
@@ -272,7 +272,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
}
if (i >= CARD_TIMEOUT)
return false;
-
+
// Write data
#ifdef _CF_USE_DMA
#ifdef NDS
@@ -294,19 +294,19 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
}
} else {
while(i--)
- *MP_DATA = *buff++;
+ *MP_DATA = *buff++;
}
#else
i=256;
while(i--)
- *MP_DATA = *buff++;
+ *MP_DATA = *buff++;
#endif
}
#if defined _CF_USE_DMA && defined NDS
// Wait for end of transfer before returning
while(DMA3_CR & DMA_BUSY);
#endif
-
+
return true;
}
@@ -314,7 +314,7 @@ bool MPCF_WriteSectors (u32 sector, u8 numSecs, void* buffer)
MPCF_Shutdown
unload the GBAMP CF interface
-----------------------------------------------------------------*/
-bool MPCF_Shutdown(void)
+bool MPCF_Shutdown(void)
{
return MPCF_ClearStatus() ;
}
diff --git a/backends/platform/ds/arm9/source/fat/io_mpcf.h b/backends/platform/ds/arm9/source/fat/io_mpcf.h
index 58cab41b4c..8ec8859097 100644
--- a/backends/platform/ds/arm9/source/fat/io_mpcf.h
+++ b/backends/platform/ds/arm9/source/fat/io_mpcf.h
@@ -1,5 +1,5 @@
/*
- io_mpcf.h
+ io_mpcf.h
Hardware Routines for reading a compact flash card
using the GBA Movie Player
@@ -24,7 +24,7 @@ extern LPIO_INTERFACE MPCF_GetInterface(void) ;
#endif // define IO_MPCF_H
/*
- io_mpcf.h
+ io_mpcf.h
Hardware Routines for reading a compact flash card
using the GBA Movie Player
diff --git a/backends/platform/ds/arm9/source/fat/io_njsd.c b/backends/platform/ds/arm9/source/fat/io_njsd.c
index fbb223d560..12388da8e9 100644
--- a/backends/platform/ds/arm9/source/fat/io_njsd.c
+++ b/backends/platform/ds/arm9/source/fat/io_njsd.c
@@ -3,11 +3,11 @@
Hardware Routines for reading an SD card using
a NinjaDS SD adapter.
-
+
Original code supplied by NinjaMod
-
+
Copyright (c) 2006 Michael "Chishm" Chisholm
-
+
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -28,7 +28,7 @@
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
2006-08-05 - Chishm
* First release
*/
@@ -84,7 +84,7 @@ static u32 _NJSD_relativeCardAddress = 0;
static inline bool _NJSD_waitIRQ(void) {
/*#ifdef _NJSD_SYNC
int i = IRQ_TIMEOUT;
- while (!(REG_IF & 0x100000) && --i);
+ while (!(REG_IF & 0x100000) && --i);
REG_IF = 0x100000;
if (i <= 0) {
return false;
@@ -96,7 +96,7 @@ static inline bool _NJSD_waitIRQ(void) {
//if (!(REG_IME & 1))
//{
// irq's disabled...
- while (!(REG_IF & 0x100000) && (!(_NJSD_irqFlag)) && --i);
+ while (!(REG_IF & 0x100000) && (!(_NJSD_irqFlag)) && --i);
_NJSD_irqFlag = 0;
REG_IF = 0x100000;
if (i <= 0) {
@@ -106,7 +106,7 @@ static inline bool _NJSD_waitIRQ(void) {
}
//} else {
// irq's enabled
- // while (!(_NJSD_irqFlag) && --i);
+ // while (!(_NJSD_irqFlag) && --i);
// _NJSD_irqFlag = 0;
// REG_IF = 0x100000;
// if (i <= 0) {
@@ -118,8 +118,8 @@ static inline bool _NJSD_waitIRQ(void) {
//#endif
}
-static inline void _NJSD_writeCardCommand
- (u8 cmd0, u8 cmd1, u8 cmd2, u8 cmd3, u8 cmd4, u8 cmd5, u8 cmd6, u8 cmd7)
+static inline void _NJSD_writeCardCommand
+ (u8 cmd0, u8 cmd1, u8 cmd2, u8 cmd3, u8 cmd4, u8 cmd5, u8 cmd6, u8 cmd7)
{
CARD_COMMAND[0] = cmd0;
CARD_COMMAND[1] = cmd1;
@@ -142,7 +142,7 @@ static bool _NJSD_reset (void) {
if (i <= 0) {
return false;
}
-
+
return true;
}
@@ -179,7 +179,7 @@ static bool _NJSD_sendCMDR (int speed, u8 *rsp_buf, int type, u8 cmd, u32 param)
REG_IME = 0;
#endif
- REG_IE &= ~0x100000;
+ REG_IE &= ~0x100000;
REG_IF = 0x100000;
CARD_CR1H = CARD_CR1_ENABLE;
@@ -191,7 +191,7 @@ static bool _NJSD_sendCMDR (int speed, u8 *rsp_buf, int type, u8 cmd, u32 param)
} else {
CARD_COMMAND[0] = 0xF0 | (speed << 2) | 0 | (1 << 1);
}
-
+
CARD_COMMAND[1] = (type & 0x40) | ((( type >> 2) & 7) << 3);
CARD_COMMAND[2] = 0x40 | cmd;
CARD_COMMAND[3] = (param>>24) & 0xFF;
@@ -301,7 +301,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) {
}
- REG_IE &= ~0x100000;
+ REG_IE &= ~0x100000;
REG_IF = 0x100000;
CARD_CR1H = CARD_CR1_ENABLE;
@@ -334,7 +334,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) {
i++;
}
} while (CARD_CR2 & CARD_BUSY);
-
+
i = WRITE_TIMEOUT;
responseBuffer[3] = 0;
do {
@@ -352,7 +352,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) {
#ifdef _NJSD_SYNC
REG_IME = old_REG_IME;
#endif
-
+
return true;
}
@@ -365,12 +365,12 @@ static bool _NJSD_sendCLK (int speed, int count) {
REG_IME = 0;
#endif
- REG_IE &= ~0x100000;
+ REG_IE &= ~0x100000;
REG_IF = 0x100000;
//CARD_CR1H = CARD_CR1_ENABLE; // | CARD_CR1_IRQ;
_NJSD_writeCardCommand (0xE0 | ((speed & 3) << 2), 0, (count - 1), 0, 0, 0, 0, 0);
-
+
CARD_CR2 = _NJSD_cardFlags;
i = COMMAND_TIMEOUT;
while ((CARD_CR2 & CARD_BUSY) && --i);
@@ -404,7 +404,7 @@ static bool _NJSD_sendCMDN (int speed, u8 cmd, u32 param) {
REG_IME = 0;
#endif
- REG_IE &= ~0x100000;
+ REG_IE &= ~0x100000;
REG_IF = 0x100000;
CARD_CR1H = CARD_CR1_ENABLE; // | CARD_CR1_IRQ;
@@ -438,22 +438,22 @@ static bool _NJSD_sendCMDN (int speed, u8 cmd, u32 param) {
static bool _NJSD_cardInit (void) {
u8 responseBuffer[17];
int i;
-
+
// If the commands succeed the first time, assume they'll always succeed
if (! _NJSD_sendCLK (SD_CLK_200KHz, 256) ) return false;
if (! _NJSD_sendCMDN (SD_CLK_200KHz, GO_IDLE_STATE, 0) ) return false;
_NJSD_sendCLK (SD_CLK_200KHz, 8);
-
+
_NJSD_sendCLK (SD_CLK_200KHz, 256);
_NJSD_sendCMDN (SD_CLK_200KHz, GO_IDLE_STATE, 0);
_NJSD_sendCLK (SD_CLK_200KHz, 8);
-
+
for (i = 0; i < MAX_STARTUP_TRIES ; i++) {
_NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, APP_CMD, 0);
- if (
+ if (
_NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SD_APP_OP_COND, SD_OCR_VALUE) &&
((responseBuffer[1] & 0x80) != 0))
- {
+ {
// Card is ready to receive commands now
break;
}
@@ -461,10 +461,10 @@ static bool _NJSD_cardInit (void) {
if (i >= MAX_STARTUP_TRIES) {
return false;
}
-
+
// The card's name, as assigned by the manufacturer
_NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_136, ALL_SEND_CID, 0);
-
+
// Get a new address
for (i = 0; i < MAX_STARTUP_TRIES ; i++) {
_NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SEND_RELATIVE_ADDR, 0);
@@ -479,17 +479,17 @@ static bool _NJSD_cardInit (void) {
// Some cards won't go to higher speeds unless they think you checked their capabilities
_NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_136, SEND_CSD, _NJSD_relativeCardAddress);
-
+
// Only this card should respond to all future commands
_NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SELECT_CARD, _NJSD_relativeCardAddress);
-
+
// Set a 4 bit data bus
_NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, APP_CMD, _NJSD_relativeCardAddress);
_NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SET_BUS_WIDTH, 2); // 4-bit mode.
// Use 512 byte blocks
_NJSD_sendCMDR (SD_CLK_200KHz, responseBuffer, SD_RSP_48, SET_BLOCKLEN, 512); // 512 byte blocks
-
+
return true;
}
@@ -521,7 +521,7 @@ bool _NJSD_startup(void) {
return false;
}
return true;
-}
+}
bool _NJSD_writeSectors (u32 sector, u32 numSectors, const void* buffer) {
@@ -531,7 +531,7 @@ bool _NJSD_writeSectors (u32 sector, u32 numSectors, const void* buffer) {
while (numSectors--) {
_SD_CRC16 ( data, BYTES_PER_READ, crc);
-
+
if (! _NJSD_writeSector (data, crc, offset)) {
return false;
}
@@ -549,7 +549,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) {
#ifdef _NJSD_SYNC
u32 old_REG_IME;
#endif
-
+
u8* tbuf = (u8*)buffer;
if (numSectors == 0) {
@@ -573,7 +573,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) {
if (!_NJSD_waitIRQ ()) {
#ifdef _NJSD_SYNC
REG_IME = old_REG_IME;
-#endif
+#endif
return false;
}
}
@@ -586,10 +586,10 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) {
if (!_NJSD_waitIRQ ()) {
#ifdef _NJSD_SYNC
REG_IME = old_REG_IME;
-#endif
+#endif
return false;
}
-
+
if (((int)buffer & 0x03) != 0){
cardPolledTransfer (0xA1406000, tmp, BYTES_PER_READ, (u8*)_NJSD_read_cmd);
memcpy (tbuf + (numSectors - 1) * BYTES_PER_READ, tmp, BYTES_PER_READ);
@@ -618,7 +618,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) {
#ifdef _NJSD_SYNC
u32 old_REG_IME;
#endif
-
+
u8* tbuf = (u8*)buffer;
if (numSectors == 0) {
@@ -637,7 +637,7 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) {
if (!_NJSD_waitIRQ ()) {
#ifdef _NJSD_SYNC
REG_IME = old_REG_IME;
-#endif
+#endif
return false;
}
}
@@ -645,10 +645,10 @@ bool _NJSD_readSectors (u32 sector, u32 numSectors, void* buffer) {
if (!_NJSD_waitIRQ ()) {
#ifdef _NJSD_SYNC
REG_IME = old_REG_IME;
-#endif
+#endif
return false;
}
-
+
cardPolledTransfer (0xA1406000, (u32*)(tbuf + (numSectors - 1) * BYTES_PER_READ), BYTES_PER_READ, (u8*)_NJSD_read_cmd);
} else {
_NJSD_sendCMDR (_NJSD_speed, NULL, SD_RSP_STREAM, READ_SINGLE_BLOCK, sector * BYTES_PER_READ);
@@ -678,4 +678,4 @@ LPIO_INTERFACE NJSD_GetInterface(void) {
} ;
#endif // defined NDS
-#endif \ No newline at end of file
+#endif
diff --git a/backends/platform/ds/arm9/source/fat/io_njsd.h b/backends/platform/ds/arm9/source/fat/io_njsd.h
index a297cda112..dce469cad6 100644
--- a/backends/platform/ds/arm9/source/fat/io_njsd.h
+++ b/backends/platform/ds/arm9/source/fat/io_njsd.h
@@ -1,11 +1,11 @@
/*
- io_njsd.h
+ io_njsd.h
Hardware Routines for reading an SD card using
a NinjaDS SD adapter.
Copyright (c) 2006 Michael "Chishm" Chisholm
-
+
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
diff --git a/backends/platform/ds/arm9/source/fat/io_nmmc.c b/backends/platform/ds/arm9/source/fat/io_nmmc.c
index a29c26e43a..261096a27b 100644
--- a/backends/platform/ds/arm9/source/fat/io_nmmc.c
+++ b/backends/platform/ds/arm9/source/fat/io_nmmc.c
@@ -13,10 +13,10 @@
project at chishm@hotmail.com
See gba_nds_fat.txt for help and license details.
-
+
2006-02-09 - www.neoflash.com:
* First stable release
-
+
2006-02-13 - Chishm
* Added ReadMK2Config function
* Added read config test to init function so no unnecessary card commands are sent
@@ -87,7 +87,7 @@ void Neo_WriteMK2Config(u8 config) {
Neo_EnableEEPROM(false);
}
-u8 Neo_ReadMK2Config(void)
+u8 Neo_ReadMK2Config(void)
{
u8 config;
Neo_EnableEEPROM(true);
@@ -104,7 +104,7 @@ u8 Neo_ReadMK2Config(void)
u8 selectMMC_command [8] = {0xFF, 0x00, 0x6A, 0xDF, 0x37, 0x59, 0x33, 0xA3};
-void Neo_SelectMMC (u8 dataByte)
+void Neo_SelectMMC (u8 dataByte)
{
selectMMC_command[1] = dataByte; // Set enable / disable byte
cardWriteCommand (selectMMC_command); // Send "5. Use the EEPROM CS to access the MK2 MMC/SD card"
@@ -154,12 +154,12 @@ bool Neo_CheckMMCResponse( u8 response, u8 mask ) {
bool Neo_InitMMC() {
Neo_MK2GameMode();
Neo_WriteMK2Config( MK2_CONFIG_ZIP_RAM_CLOSE | MK2_CONFIG_GAME_FLASH_CLOSE);
-
+
// Make sure the configuration was accepted
if (Neo_ReadMK2Config() != (MK2_CONFIG_ZIP_RAM_CLOSE | MK2_CONFIG_GAME_FLASH_CLOSE)) {
return false; // If not, then it wasn't initialised properly
}
-
+
return true;
}
@@ -167,7 +167,7 @@ bool Neo_InitMMC() {
bool NMMC_IsInserted(void) {
int i;
-
+
Neo_EnableMMC( true ); // Open SPI port to MMC card
Neo_SendMMCCommand(MMC_SEND_CSD, 0);
if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured
@@ -183,13 +183,13 @@ bool NMMC_IsInserted(void) {
for (i = 0; i < 28; i++) {
Neo_SPI(0xff);
}
-
+
return true;
}
bool NMMC_ClearStatus (void) {
u32 i;
-
+
Neo_EnableMMC( true ); // Open SPI port to MMC card
for (i = 0; i < 10; i++) {
Neo_SPI(0xFF); // Send 10 0xFF bytes to MMC card
@@ -224,14 +224,14 @@ bool NMMC_StartUp(void) {
return false;
}
Neo_EnableMMC( true ); // Open SPI port to MMC card
-
+
// Set block length
Neo_SendMMCCommand(MMC_SET_BLOCKLEN, BYTE_PER_READ );
if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured
Neo_EnableMMC( false );
return false;
}
-
+
// Check if we can use a higher SPI frequency
Neo_SendMMCCommand(MMC_SEND_CSD, 0);
if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured
@@ -252,77 +252,77 @@ bool NMMC_StartUp(void) {
if ((transSpeed & 0xf0) >= 0x30) {
spi_freq = 0;
}
-
+
Neo_EnableMMC( false );
return true;
-}
+}
-bool NMMC_WriteSectors (u32 sector, u8 numSecs, void* buffer)
+bool NMMC_WriteSectors (u32 sector, u8 numSecs, void* buffer)
{
u32 i;
u8 *p=buffer;
-
+
int totalSecs = (numSecs == 0) ? 256 : numSecs;
sector *= BYTE_PER_READ;
-
+
Neo_EnableMMC( true ); // Open SPI port to MMC card
Neo_SendMMCCommand( 25, sector );
if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured
Neo_EnableMMC( false );
return false;
}
-
+
while (totalSecs--) {
Neo_SPI( 0xFC ); // Send Start Block token
for( i = 0; i < BYTE_PER_READ; i++ ) // Send a block of data
Neo_SPI( *p++ );
Neo_SPI( 0xFF ); // Send fake CRC16
Neo_SPI( 0xFF ); // Send fake CRC16
-
+
if( ( Neo_SPI( 0xFF ) & 0x0F ) != 0x05 ) { // Make sure the block was accepted
Neo_EnableMMC( false );
return false;
}
while( Neo_SPI( 0xFF ) == 0x00 ); // Wait for the block to be written
}
-
+
// Stop transmission block
Neo_SPI( 0xFD ); // Send Stop Transmission Block token
for( i = 0; i < BYTE_PER_READ; i++ ) // Send a block of fake data
Neo_SPI( 0xFF );
Neo_SPI( 0xFF ); // Send fake CRC16
Neo_SPI( 0xFF ); // Send fake CRC16
-
+
Neo_SPI (0xFF); // Send 8 clocks
while( Neo_SPI( 0xFF ) == 0x00 ); // Wait for the busy signal to clear
-
- for ( i = 0; i < 0x10; i++) {
+
+ for ( i = 0; i < 0x10; i++) {
Neo_SPI (0xFF); // Send clocks for the MMC card to finish what it's doing
}
-
+
Neo_EnableMMC( false ); // Close SPI port to MMC card
return true;
}
-bool NMMC_ReadSectors (u32 sector, u8 numSecs, void* buffer)
+bool NMMC_ReadSectors (u32 sector, u8 numSecs, void* buffer)
{
u32 i;
u8 *p=buffer;
-
+
int totalSecs = (numSecs == 0) ? 256 : numSecs;
sector *= BYTE_PER_READ;
-
+
Neo_EnableMMC( true ); // Open SPI port to MMC card
-
+
while (totalSecs--) {
Neo_SendMMCCommand(MMC_READ_BLOCK, sector );
if( Neo_CheckMMCResponse( 0x00, 0xFF ) == false ) { // Make sure no errors occured
Neo_EnableMMC( false );
return false;
}
-
+
if( Neo_CheckMMCResponse( 0xFE, 0xFF ) == false ) { // Check for Start Block token
Neo_EnableMMC( false );
return false;
@@ -333,7 +333,7 @@ bool NMMC_ReadSectors (u32 sector, u8 numSecs, void* buffer)
Neo_SPI( 0xFF ); // Ignore CRC16
sector += BYTE_PER_READ;
}
-
+
Neo_EnableMMC( false ); // Close SPI port to MMC card
return true;
}
diff --git a/backends/platform/ds/arm9/source/fat/io_nmmc.h b/backends/platform/ds/arm9/source/fat/io_nmmc.h
index 5244d21868..0249e3a864 100644
--- a/backends/platform/ds/arm9/source/fat/io_nmmc.h
+++ b/backends/platform/ds/arm9/source/fat/io_nmmc.h
@@ -1,5 +1,5 @@
/*
- io_NMMC.h
+ io_NMMC.h
Hardware Routines for reading an SD or MMC card using
a Neoflash MK2 or MK3.
@@ -26,7 +26,7 @@ extern LPIO_INTERFACE NMMC_GetInterface(void) ;
#endif // define IO_NMMC_H
/*
- io_NMMC.h
+ io_NMMC.h
Hardware Routines for reading an SD or MMC card using
a Neoflash MK2 or MK3.
diff --git a/backends/platform/ds/arm9/source/fat/io_sccf.c b/backends/platform/ds/arm9/source/fat/io_sccf.c
index 0c77f4673c..bda628fdaa 100644
--- a/backends/platform/ds/arm9/source/fat/io_sccf.c
+++ b/backends/platform/ds/arm9/source/fat/io_sccf.c
@@ -57,7 +57,7 @@ bool SCCF_Unlock(void)
temp = (~temp & 0xFF);
return (CF_REG_LBA1 == temp);
#undef CF_REG_LBA1
-}
+}
bool SCCF_Shutdown(void) {
return MPCF_ClearStatus() ;
diff --git a/backends/platform/ds/arm9/source/fat/io_sccf.h b/backends/platform/ds/arm9/source/fat/io_sccf.h
index 961909fbce..2270c4eab1 100644
--- a/backends/platform/ds/arm9/source/fat/io_sccf.h
+++ b/backends/platform/ds/arm9/source/fat/io_sccf.h
@@ -1,5 +1,5 @@
/*
- io_sccf.h
+ io_sccf.h
Hardware Routines for reading a compact flash card
using the Supercard CF
@@ -24,7 +24,7 @@ extern LPIO_INTERFACE SCCF_GetInterface(void) ;
#endif // define IO_SCCF_H
/*
- io_sccf.h
+ io_sccf.h
Hardware Routines for reading a compact flash card
using the Supercard CF
diff --git a/backends/platform/ds/arm9/source/fat/io_scsd.c b/backends/platform/ds/arm9/source/fat/io_scsd.c
index 9359fefb6d..270691436d 100644
--- a/backends/platform/ds/arm9/source/fat/io_scsd.c
+++ b/backends/platform/ds/arm9/source/fat/io_scsd.c
@@ -1,8 +1,8 @@
/*
io_scsd.c by SaTa.
based on io_sccf.c
-
-
+
+
*/
/*
@@ -43,7 +43,7 @@ extern void InitSCMode(void); // CF‚Æ“¯‚¶
extern void ReadSector(u16 *buff,u32 sector,u8 ReadNumber);
extern void WriteSector(u16 *buff,u32 sector,u8 writeNumber);
extern bool MemoryCard_IsInserted(void); // CF‚ƈႤ
-//
+//
/*-----------------------------------------------------------------
SCSD_Unlock
@@ -55,7 +55,7 @@ bool SCSD_Unlock(void)
{
InitSCMode();
return MemoryCard_IsInserted();
-}
+}
bool SCSD_Shutdown(void) {
return MPCF_ClearStatus() ;
@@ -103,4 +103,4 @@ LPIO_INTERFACE SCSD_GetInterface(void) {
return &io_scsd ;
} ;
-#endif \ No newline at end of file
+#endif
diff --git a/backends/platform/ds/arm9/source/fat/io_scsd.h b/backends/platform/ds/arm9/source/fat/io_scsd.h
index 75115b8d62..492492f619 100644
--- a/backends/platform/ds/arm9/source/fat/io_scsd.h
+++ b/backends/platform/ds/arm9/source/fat/io_scsd.h
@@ -1,12 +1,12 @@
/*
io_scsd.h by SaTa.
based on io_sccf.h
-
-
+
+
*/
/*
- io_sccf.h
+ io_sccf.h
Hardware Routines for reading a compact flash card
using the GBA Movie Player
@@ -26,4 +26,4 @@
// export interface
extern LPIO_INTERFACE SCSD_GetInterface(void) ;
-#endif // define IO_SCSD_H \ No newline at end of file
+#endif // define IO_SCSD_H
diff --git a/backends/platform/ds/arm9/source/fat/io_scsd_asm.s b/backends/platform/ds/arm9/source/fat/io_scsd_asm.s
index 498cbb96c2..390d36afeb 100644
--- a/backends/platform/ds/arm9/source/fat/io_scsd_asm.s
+++ b/backends/platform/ds/arm9/source/fat/io_scsd_asm.s
@@ -1,22 +1,22 @@
.TEXT
@--------------------------------sd data--------------------------------
.equ sd_comadd,0x9800000
-.equ sd_dataadd,0x9000000
+.equ sd_dataadd,0x9000000
.equ sd_dataradd,0x9100000
@-----------------viod sd_data_write_s(u16 *buff,u16* crc16buff)-------------------
.ALIGN
- .GLOBAL sd_data_write_s
+ .GLOBAL sd_data_write_s
.CODE 32
sd_data_write_s:
stmfd r13!,{r4-r5}
mov r5,#512
mov r2,#sd_dataadd
sd_data_write_busy:
- ldrh r3,[r2]
+ ldrh r3,[r2]
tst r3,#0x100
beq sd_data_write_busy
- ldrh r3,[r2]
+ ldrh r3,[r2]
mov r3,#0 @star bit
strh r3,[r2]
@@ -24,10 +24,10 @@ sd_data_write_loop:
ldrh r3,[r0],#2
add r3,r3,r3,lsl #20
mov r4,r3,lsl #8
- stmia r2,{r3-r4}
-
- subs r5, r5, #2
- bne sd_data_write_loop
+ stmia r2,{r3-r4}
+
+ subs r5, r5, #2
+ bne sd_data_write_loop
cmp r1,#0
movne r0,r1
@@ -38,11 +38,11 @@ sd_data_write_loop:
mov r3,#0xff @end bit
strh r3,[r2]
sd_data_write_loop2:
- ldrh r3,[r2]
+ ldrh r3,[r2]
tst r3,#0x100
bne sd_data_write_loop2
- ldmia r2,{r3-r4}
+ ldmia r2,{r3-r4}
ldmfd r13!,{r4-r5}
bx r14
@@ -50,7 +50,7 @@ sd_data_write_loop2:
@----------void sd_data_read_s(u16 *buff)-------------
.ALIGN
- .GLOBAL sd_data_read_s
+ .GLOBAL sd_data_read_s
.CODE 32
sd_data_read_s:
stmfd r13!,{r4}
@@ -61,62 +61,62 @@ sd_data_read_loop1:
bne sd_data_read_loop1
mov r2,#512
sd_data_read_loop:
- ldmia r1,{r3-r4}
+ ldmia r1,{r3-r4}
mov r3,r4,lsr #16
strh r3 ,[r0],#2
- ldmia r1,{r3-r4}
+ ldmia r1,{r3-r4}
mov r3,r4,lsr #16
strh r3 ,[r0],#2
- ldmia r1,{r3-r4}
+ ldmia r1,{r3-r4}
mov r3,r4,lsr #16
strh r3 ,[r0],#2
- ldmia r1,{r3-r4}
+ ldmia r1,{r3-r4}
mov r3,r4,lsr #16
strh r3 ,[r0],#2
- ldmia r1,{r3-r4}
+ ldmia r1,{r3-r4}
mov r3,r4,lsr #16
strh r3 ,[r0],#2
- ldmia r1,{r3-r4}
+ ldmia r1,{r3-r4}
mov r3,r4,lsr #16
strh r3 ,[r0],#2
- ldmia r1,{r3-r4}
+ ldmia r1,{r3-r4}
mov r3,r4,lsr #16
strh r3 ,[r0],#2
- ldmia r1,{r3-r4}
+ ldmia r1,{r3-r4}
mov r3,r4,lsr #16
strh r3 ,[r0],#2
- subs r2, r2, #16
- bne sd_data_read_loop
+ subs r2, r2, #16
+ bne sd_data_read_loop
ldmia r1,{r3-r4} @crc 16
- ldmia r1,{r3-r4}
- ldmia r1,{r3-r4}
- ldmia r1,{r3-r4}
+ ldmia r1,{r3-r4}
+ ldmia r1,{r3-r4}
+ ldmia r1,{r3-r4}
ldrh r3,[r1] @end bit
- ldmfd r13!,{r4}
+ ldmfd r13!,{r4}
bx r14
@----------end sd_data_read_s-------------
@------void sd_com_crc16_s(u16* buff,u16 num,u16* crc16buff)
.ALIGN
- .GLOBAL sd_crc16_s
+ .GLOBAL sd_crc16_s
.CODE 32
sd_crc16_s:
stmfd r13!,{r4-r9}
mov r9,r2
- mov r3,#0
- mov r4,#0
- mov r5,#0
- mov r6,#0
+ mov r3,#0
+ mov r4,#0
+ mov r5,#0
+ mov r6,#0
ldr r7,=0x80808080
ldr r8,=0x1021
@@ -131,19 +131,19 @@ sd_crc16_loop:
eorne r3,r3,r8
tst r2,r7,lsr #24
eorne r3,r3,r8
-
+
mov r4,r4,lsl #1
tst r4,#0x10000
eorne r4,r4,r8
tst r2,r7,lsr #25
eorne r4,r4,r8
-
+
mov r5,r5,lsl #1
tst r5,#0x10000
eorne r5,r5,r8
tst r2,r7,lsr #26
eorne r5,r5,r8
-
+
mov r6,r6,lsl #1
tst r6,#0x10000
eorne r6,r6,r8
@@ -152,7 +152,7 @@ sd_crc16_loop:
mov r7,r7,ror #4
subs r1,r1,#4
- bne sd_crc16_loop
+ bne sd_crc16_loop
mov r2,r9
mov r8,#16
@@ -184,7 +184,7 @@ sd_crc16_write_data:
@--------------u8 sd_crc7_s(u16* buff,u16 num)----------------------------
.ALIGN
- .GLOBAL sd_crc7_s
+ .GLOBAL sd_crc7_s
.CODE 32
sd_crc7_s:
stmfd r13!,{r4}
@@ -206,7 +206,7 @@ sd_crc7_loop:
mov r4,r4,ror #1
subs r1,r1,#1
- bne sd_crc7_loop
+ bne sd_crc7_loop
mov r3,r3,lsl #1
add r0,r3,#1
@@ -216,7 +216,7 @@ sd_crc7_loop:
@--------------sd_com_read_s(u16* buff,u32 num)------------------
.ALIGN
- .GLOBAL sd_com_read_s
+ .GLOBAL sd_com_read_s
.CODE 32
sd_com_read_s:
@@ -229,8 +229,8 @@ sd_com_read_loop1:
sd_com_read_loop:
ldmia r2,{r3-r6}
- subs r1, r1, #1
- bne sd_com_read_loop
+ subs r1, r1, #1
+ bne sd_com_read_loop
ldmfd r13!,{r4-r6}
bx r14
@--------------end sd_com_read_s------------------
@@ -242,14 +242,14 @@ sd_com_read_loop:
.CODE 32
sd_com_write_s:
stmfd r13!,{r4-r6}
-
+
mov r2,#sd_comadd
sd_com_write_busy:
- ldrh r3,[r2]
+ ldrh r3,[r2]
tst r3,#0x1
beq sd_com_write_busy
- ldrh r3,[r2]
+ ldrh r3,[r2]
sd_com_write_loop:
ldrb r3,[r0],#1
@@ -257,9 +257,9 @@ sd_com_write_loop:
mov r4,r3,lsl #2
mov r5,r4,lsl #2
mov r6,r5,lsl #2
- stmia r2,{r3-r6}
- subs r1, r1, #1
- bne sd_com_write_loop
+ stmia r2,{r3-r6}
+ subs r1, r1, #1
+ bne sd_com_write_loop
ldmfd r13!,{r4-r6}
bx r14
@@ -267,7 +267,7 @@ sd_com_write_loop:
@-----------------void send_clk(u32 num)---------
.ALIGN
- .GLOBAL send_clk
+ .GLOBAL send_clk
.CODE 32
send_clk:
@@ -281,7 +281,7 @@ send_clk_loop1:
@---------------------------void SDCommand(u8 command,u8 num,u32 sector)--------------------
.ALIGN
- .GLOBAL SDCommand
+ .GLOBAL SDCommand
.CODE 32
@void SDCommand(u8 command,u8 num,u32 sector )
@{
@@ -338,12 +338,12 @@ SDCommand:
@ register u16 i,j;
@ i=readnum;
@ sectno<<=9;
-@ SDCommand(18,0,sector);
+@ SDCommand(18,0,sector);
@ for (j=0;j<i ; j++)
@ {
@ sd_data_read_s((u32)buff+j*512);
@ }
-@ SDCommand(12,0,0);
+@ SDCommand(12,0,0);
@ get_resp();
@ send_clk(0x10);
@
@@ -363,7 +363,7 @@ beginforj_ReadSector:
cmp r6,r5
bge endforj_ReadSector
mov r0,r4
- add r0,r0,r6,lsl #9
+ add r0,r0,r6,lsl #9
bl sd_data_read_s
add r6,r6,#1
b beginforj_ReadSector
@@ -408,17 +408,17 @@ get_resp:
@
@ sectno<<=9;
@
-@ SDCommand(25,0,sector);
+@ SDCommand(25,0,sector);
@ get_resp();
-@ send_clk(0x10);
+@ send_clk(0x10);
@
@ for (j=0;j<i ; j++)
@ {
@ sd_crc16_s((u32)(u32)buff+j*512,512,(u32)crc16);
@ sd_data_write_s((u32)buff+j*512,(u32)crc16);
-@ send_clk(0x10);
+@ send_clk(0x10);
@ }
-@ SDCommand(12,0,0);
+@ SDCommand(12,0,0);
@ get_resp();
@ send_clk(0x10);
@ while((*(u16*)sd_dataadd &0x0100)==0);
@@ -451,7 +451,7 @@ beginforj_WriteSector:
add r2,r13,#4
bl sd_crc16_s
mov r0,r4
- add r0,r0,r6,lsl #9
+ add r0,r0,r6,lsl #9
add r1,r13,#4
bl sd_data_write_s
mov r0,#0x10
@@ -481,7 +481,7 @@ beginwhile_WriteSector:
.GLOBAL InitSCMode
.CODE 32
InitSCMode:
- mvn r0,#0x0F6000000
+ mvn r0,#0x0F6000000
sub r0,r0,#0x01
mov r1,#0x0A500
add r1,r1,#0x5A
diff --git a/backends/platform/ds/arm9/source/fat/io_sd_common.c b/backends/platform/ds/arm9/source/fat/io_sd_common.c
index 0a38e6277c..ade9df0d80 100644
--- a/backends/platform/ds/arm9/source/fat/io_sd_common.c
+++ b/backends/platform/ds/arm9/source/fat/io_sd_common.c
@@ -5,10 +5,10 @@
Common SD card routines
- SD routines partially based on sd.s by Romman
+ SD routines partially based on sd.s by Romman
Copyright (c) 2006 Michael "Chishm" Chisholm
-
+
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -29,7 +29,7 @@
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
2006-08-07 - Chishm
* Moved the SD initialization to a common function
* Increased timeouts for slower cards
@@ -61,10 +61,10 @@ u8 _SD_CRC7(u8* data, int cnt) {
}
crc = (crc << 1) | 1;
return(crc);
-}
+}
/*
-Calculates the CRC16 for a sector of data. Calculates it
+Calculates the CRC16 for a sector of data. Calculates it
as 4 separate lots, merged into one buffer. This is used
for 4 SD data lines, not for 1 data line alone.
*/
@@ -79,53 +79,53 @@ void _SD_CRC16 (u8* buff, int buffLength, u8* crc16buff) {
b = 0; // r4
c = 0; // r5
d = 0; // r6
-
+
buffLength = buffLength * 8;
-
-
+
+
do {
if (bitPattern & 0x80) dataByte = *buff++;
-
+
a = a << 1;
if ( a & 0x10000) a ^= crcConst;
if (dataByte & (bitPattern >> 24)) a ^= crcConst;
-
+
b = b << 1;
if (b & 0x10000) b ^= crcConst;
if (dataByte & (bitPattern >> 25)) b ^= crcConst;
-
+
c = c << 1;
if (c & 0x10000) c ^= crcConst;
if (dataByte & (bitPattern >> 26)) c ^= crcConst;
-
+
d = d << 1;
if (d & 0x10000) d ^= crcConst;
if (dataByte & (bitPattern >> 27)) d ^= crcConst;
-
+
bitPattern = (bitPattern >> 4) | (bitPattern << 28);
} while (buffLength-=4);
-
+
count = 16; // r8
-
+
do {
bitPattern = bitPattern << 4;
if (a & 0x8000) bitPattern |= 8;
if (b & 0x8000) bitPattern |= 4;
if (c & 0x8000) bitPattern |= 2;
if (d & 0x8000) bitPattern |= 1;
-
+
a = a << 1;
b = b << 1;
c = c << 1;
d = d << 1;
-
+
count--;
-
+
if (!(count & 0x01)) {
*crc16buff++ = (u8)(bitPattern & 0xff);
}
} while (count != 0);
-
+
return;
}
@@ -136,20 +136,20 @@ cmd_17byte_response: a pointer to a function that sends the SD card a command an
use4bitBus: initialise card to use a 4 bit data bus when communicating with the card
RCA: a pointer to the location to store the card's Relative Card Address, preshifted up by 16 bits.
*/
-bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response,
+bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response,
_SD_FN_CMD_17BYTE_RESPONSE cmd_17byte_response,
bool use4bitBus,
u32 *RCA)
{
u8 responseBuffer[17] = {0};
int i;
-
+
for (i = 0; i < MAX_STARTUP_TRIES ; i++) {
cmd_6byte_response (responseBuffer, APP_CMD, 0);
- if (
+ if (
cmd_6byte_response (responseBuffer, SD_APP_OP_COND, SD_OCR_VALUE) &&
((responseBuffer[1] & 0x80) != 0))
- {
+ {
// Card is ready to receive commands now
break;
}
@@ -157,10 +157,10 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response,
if (i >= MAX_STARTUP_TRIES) {
return false;
}
-
+
// The card's name, as assigned by the manufacturer
cmd_17byte_response (responseBuffer, ALL_SEND_CID, 0);
-
+
// Get a new address
for (i = 0; i < MAX_STARTUP_TRIES ; i++) {
cmd_6byte_response (responseBuffer, SEND_RELATIVE_ADDR, 0);
@@ -175,10 +175,10 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response,
// Some cards won't go to higher speeds unless they think you checked their capabilities
cmd_17byte_response (responseBuffer, SEND_CSD, *RCA);
-
+
// Only this card should respond to all future commands
cmd_6byte_response (responseBuffer, SELECT_CARD, *RCA);
-
+
if (use4bitBus) {
// Set a 4 bit data bus
cmd_6byte_response (responseBuffer, APP_CMD, *RCA);
@@ -187,7 +187,7 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response,
// Use 512 byte blocks
cmd_6byte_response (responseBuffer, SET_BLOCKLEN, 512); // 512 byte blocks
-
+
// Wait until card is ready for data
i = 0;
do {
@@ -196,7 +196,7 @@ bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response,
}
i++;
} while (!cmd_6byte_response (responseBuffer, SEND_STATUS, *RCA) && ((responseBuffer[3] & 0x1f) != ((SD_STATE_TRAN << 1) | READY_FOR_DATA)));
-
+
return true;
}
diff --git a/backends/platform/ds/arm9/source/fat/io_sd_common.h b/backends/platform/ds/arm9/source/fat/io_sd_common.h
index 09abffab39..8962d88890 100644
--- a/backends/platform/ds/arm9/source/fat/io_sd_common.h
+++ b/backends/platform/ds/arm9/source/fat/io_sd_common.h
@@ -8,7 +8,7 @@
SD routines partially based on sd.s by Romman
Copyright (c) 2006 Michael "Chishm" Chisholm
-
+
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -32,7 +32,7 @@
2006-07-11 - Chishm
* Original release
-
+
2006-07-28 - Chishm
* Changed voltage range that the SD card can use
*/
@@ -76,7 +76,7 @@
#define SD_STATE_IDENT 2 // Identification state, after ALL_SEND_CID
#define SD_STATE_STBY 3 // Standby state, when card is deselected
#define SD_STATE_TRAN 4 // Transfer state, after card is selected and ready for data transfer
-#define SD_STATE_DATA 5 //
+#define SD_STATE_DATA 5 //
#define SD_STATE_RCV 6 // Receive data state
#define SD_STATE_PRG 7 // Programming state
#define SD_STATE_DIS 8 // Disconnect state
@@ -85,7 +85,7 @@
#define READY_FOR_DATA 1 // bit 8 in card status
/*
-Calculate the CRC7 of a command and return it preshifted with
+Calculate the CRC7 of a command and return it preshifted with
an end bit added
*/
extern u8 _SD_CRC7(u8* data, int size);
@@ -106,7 +106,7 @@ cmd_17byte_response: a pointer to a function that sends the SD card a command an
use4bitBus: initialise card to use a 4 bit data bus when communicating with the card
RCA: a pointer to the location to store the card's Relative Card Address, preshifted up by 16 bits.
*/
-extern bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response,
+extern bool _SD_InitCard (_SD_FN_CMD_6BYTE_RESPONSE cmd_6byte_response,
_SD_FN_CMD_17BYTE_RESPONSE cmd_17byte_response,
bool use4bitBus,
u32 *RCA);
diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp
index b03a1334f7..fbe0c69944 100644
--- a/backends/platform/ds/arm9/source/gbampsave.cpp
+++ b/backends/platform/ds/arm9/source/gbampsave.cpp
@@ -92,40 +92,40 @@ uint32 GBAMPSaveFile::write(const void *buf, uint32 size) {
memcpy(buffer + bufferPos, buf, size);
bufferPos += size;
-
+
saveSize += size;
/* int pos = 0;
-
+
int rest = SAVE_BUFFER_SIZE - bufferPos;
memcpy(buffer + bufferPos, buf, rest);
bufferPos = 512;
pos += rest;
- flushSaveBuffer();
+ flushSaveBuffer();
size -= rest;
// consolePrintf("First section: %d\n", rest);
-
+
while (size >= 512) {
DS::std_fwrite(((char *) (buf)) + pos, 1, 512, handle);
size -= 512;
pos += 512;
// consolePrintf("Full chunk, %d left ", size);
}
-
+
bufferPos = 0;
memcpy(buffer + bufferPos, ((char *) (buf)) + pos, size);
bufferPos += size;
// consolePrintf("%d left in buffer ", bufferPos);*/
-
+
} else {
-
+
memcpy(buffer + bufferPos, buf, size);
bufferPos += size;
-
+
saveSize += size;
}
-
+
// if ((size > 100) || (size <= 0)) consolePrintf("Write %d bytes\n", size);
return size;
}
@@ -145,41 +145,41 @@ GBAMPSaveFileManager::~GBAMPSaveFileManager() {
GBAMPSaveFile* GBAMPSaveFileManager::openSavefile(char const* name, bool saveOrLoad) {
char fileSpec[128];
-
+
strcpy(fileSpec, getSavePath());
-
+
if (fileSpec[strlen(fileSpec) - 1] == '/') {
sprintf(fileSpec, "%s%s", getSavePath(), name);
} else {
sprintf(fileSpec, "%s/%s", getSavePath(), name);
}
-
+
// consolePrintf(fileSpec);
GBAMPSaveFile* sf = new GBAMPSaveFile(fileSpec, saveOrLoad);
if (sf->isOpen()) {
- return sf;
+ return sf;
} else {
delete sf;
- return NULL;
+ return NULL;
}
}
-Common::StringList GBAMPSaveFileManager::listSavefiles(const char *pattern) {
+Common::StringList GBAMPSaveFileManager::listSavefiles(const char *pattern) {
enum { TYPE_NO_MORE = 0, TYPE_FILE = 1, TYPE_DIR = 2 };
char name[256];
-
+
DS::std_cwd((char *) getSavePath());
// consolePrintf("Save path: '%s', pattern: '%s'\n", getSavePath(),pattern);
-
+
int fileType = FAT_FindFirstFileLFN(name);
Common::StringList list;
-
-
+
+
do {
-
+
if (fileType == TYPE_FILE) {
FAT_GetLongFilename(name);
@@ -187,18 +187,18 @@ Common::StringList GBAMPSaveFileManager::listSavefiles(const char *pattern) {
for (int r = 0; r < strlen(name); r++) {
name[r] = tolower(name[r]);
}
-
-
+
+
if (Common::matchString(name, pattern)) {
list.push_back(name);
}
}
} while ((fileType = FAT_FindNextFileLFN(name)));
-
+
FAT_chdir("/");
return list;
-}
+}
diff --git a/backends/platform/ds/arm9/source/gbampsave.h b/backends/platform/ds/arm9/source/gbampsave.h
index b46c9bd53b..40dcde0b26 100644
--- a/backends/platform/ds/arm9/source/gbampsave.h
+++ b/backends/platform/ds/arm9/source/gbampsave.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#ifndef _GBAMPSAVE_H_
#define _GBAMPSAVE_H_
@@ -39,19 +39,19 @@ class GBAMPSaveFile : public Common::InSaveFile, public Common::OutSaveFile {
public:
GBAMPSaveFile(char* name, bool saveOrLoad);
virtual ~GBAMPSaveFile();
-
+
virtual uint32 read(void *buf, uint32 size);
virtual uint32 write(const void *buf, uint32 size);
-
+
virtual bool eos() const;
virtual void skip(uint32 bytes);
virtual uint32 pos() const;
virtual uint32 size() const;
virtual void seek(int32 pos, int whence);
-
+
void flushSaveBuffer();
-
+
virtual bool isOpen() const {
return handle != 0;
}
@@ -62,17 +62,17 @@ class GBAMPSaveFileManager : public DefaultSaveFileManager {
public:
GBAMPSaveFileManager();
~GBAMPSaveFileManager();
-
+
// static GBAMPSaveFileManager* instance() { return instancePtr; }
GBAMPSaveFile *openSavefile(const char *filename, bool saveOrLoad);
-
+
virtual Common::OutSaveFile* openForSaving(const char* filename) { return openSavefile(filename, true); }
virtual Common::InSaveFile* openForLoading(const char* filename) { return openSavefile(filename, false); }
-
+
virtual bool removeSavefile(const char *filename) { return false; } // TODO: Implement this
virtual Common::StringList listSavefiles(const char *pattern);
-
+
void deleteFile(char* name);
void listFiles();
};
diff --git a/backends/platform/ds/arm9/source/keys.cpp b/backends/platform/ds/arm9/source/keys.cpp
index dcec2287b9..8bfc983565 100644
--- a/backends/platform/ds/arm9/source/keys.cpp
+++ b/backends/platform/ds/arm9/source/keys.cpp
@@ -27,26 +27,26 @@
$Log: keys.c,v $
Revision 1.13 2006/01/12 09:10:47 wntrmute
Added key repeat as suggested by pepsiman
-
+
Revision 1.12 2005/11/27 12:30:25 wntrmute
reverted to correct hardware REGisters
-
+
Revision 1.11 2005/11/27 07:48:45 joatski
Renamed REG_KEYINPUT and REG_KEYCNT back to KEYS and KEYS_CR, as the alternatives are defined in registers_alt.h.
Changed function returns to uint32
-
+
Revision 1.10 2005/11/03 23:38:49 wntrmute
don't use enum for key function returns
-
+
Revision 1.9 2005/10/13 16:30:11 dovoto
Changed KEYPAD_BITS to a typedef enum, this resolved some issues with multiple redefinition of KEYPAD_BITS (although this error did not allways occur).
-
+
Revision 1.8 2005/10/03 21:21:59 wntrmute
use enum types
-
+
Revision 1.7 2005/09/07 18:06:27 wntrmute
use new register names
-
+
Revision 1.6 2005/08/23 17:06:10 wntrmute
converted all endings to unix
@@ -148,4 +148,4 @@ uint32 keysUp(void) {
}
-} // namespace ds \ No newline at end of file
+} // namespace ds
diff --git a/backends/platform/ds/arm9/source/libcartreset/cartreset.c b/backends/platform/ds/arm9/source/libcartreset/cartreset.c
index 01ba33736a..6fb906b86d 100644
--- a/backends/platform/ds/arm9/source/libcartreset/cartreset.c
+++ b/backends/platform/ds/arm9/source/libcartreset/cartreset.c
@@ -43,7 +43,7 @@ bool cartSetMenuMode(u32 _deviceType)
tmp = *(vu16*)(0x08800612);
tmp = *(vu16*)(0x08000000);
tmp = *(vu16*)(0x08801B66);
- tmp = *(vu16*)(0x08000000 + (mode << 1));
+ tmp = *(vu16*)(0x08000000 + (mode << 1));
tmp = *(vu16*)(0x0800080E);
tmp = *(vu16*)(0x08000000);
diff --git a/backends/platform/ds/arm9/source/libcartreset/cartreset_nolibfat.h b/backends/platform/ds/arm9/source/libcartreset/cartreset_nolibfat.h
index 6a3f045840..ddc4b1d4c2 100644
--- a/backends/platform/ds/arm9/source/libcartreset/cartreset_nolibfat.h
+++ b/backends/platform/ds/arm9/source/libcartreset/cartreset_nolibfat.h
@@ -53,5 +53,5 @@ void cartExecute();
}
#endif
-#endif
+#endif
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index 455327f530..2044448923 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -63,7 +63,7 @@ int OSystem_DS::timerHandler(int t)
tm->handler();
return t;
}
-
+
void OSystem_DS::initBackend() {
ConfMan.setInt("autosave_period", 0);
ConfMan.setBool("FM_medium_quality", true);
@@ -72,7 +72,7 @@ void OSystem_DS::initBackend() {
_timer = new DSTimerManager;
DS::setSoundProc(Audio::Mixer::mixCallback, _mixer);
DS::setTimerCallback(&OSystem_DS::timerHandler, 10);
-
+
OSystem::initBackend();
}
@@ -135,20 +135,20 @@ void OSystem_DS::setPalette(const byte *colors, uint start, uint num) {
int red = *colors;
int green = *(colors + 1);
int blue = *(colors + 2);
-
+
red >>= 3;
green >>= 3;
blue >>= 3;
-
+
// if (r != 255)
- {
+ {
BG_PALETTE[r] = red | (green << 5) | (blue << 10);
if (!DS::getKeyboardEnable()) {
BG_PALETTE_SUB[r] = red | (green << 5) | (blue << 10);
}
}
// if (num == 16) consolePrintf("pal:%d r:%d g:%d b:%d\n", r, red, green, blue);
-
+
colors += 4;
}
}
@@ -157,7 +157,7 @@ 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
-
+
u16* image = (u16 *) DS::get8BitBackBuffer();
for (int y = 0; y < DS::getGameHeight(); y++)
@@ -174,7 +174,7 @@ bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) {
void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) {
// consolePrintf("Grabpalette");
-
+
for (unsigned int r = start; r < start + num; r++) {
*colors++ = (BG_PALETTE[r] & 0x001F) << 3;
*colors++ = (BG_PALETTE[r] & 0x03E0) >> 5 << 3;
@@ -186,47 +186,47 @@ void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) {
void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h)
{
// consolePrintf("Copy rect %d, %d %d, %d ", x, y, w, h);
-
+
if (w <= 1) return;
if (h < 0) return;
if (!DS::getIsDisplayMode8Bit()) return;
-
+
u16* bgSub = (u16 *) BG_GFX_SUB;
u16* bg = (u16 *) DS::get8BitBackBuffer();
u16* src = (u16 *) buf;
-
+
if (DS::getKeyboardEnable()) {
-
+
for (int dy = y; dy < y + h; dy++) {
u16* dest = bg + (dy << 8) + (x >> 1);
-
+
DC_FlushRange(src, w << 1);
DC_FlushRange(dest, w << 1);
dmaCopyHalfWords(3, src, dest, w);
-
+
src += pitch >> 1;
}
-
+
} else {
for (int dy = y; dy < y + h; dy++) {
u16* dest1 = bg + (dy << 8) + (x >> 1);
u16* dest2 = bgSub + (dy << 8) + (x >> 1);
-
+
DC_FlushRange(src, w << 1);
DC_FlushRange(dest1, w << 1);
DC_FlushRange(dest2, w << 1);
-
+
dmaCopyHalfWords(3, src, dest1, w);
dmaCopyHalfWords(3, src, dest2, w);
-
+
src += pitch >> 1;
}
}
-
+
// consolePrintf("Done\n");
-
-
-
+
+
+
}
void OSystem_DS::updateScreen()
@@ -236,7 +236,7 @@ void OSystem_DS::updateScreen()
{
// Copy temp framebuffer back to screen
copyRectToScreen((byte *)_framebuffer.pixels, _framebuffer.pitch, 0, 0, _framebuffer.w, _framebuffer.h);
-
+
// Free memory
_framebuffer.free();
@@ -279,36 +279,36 @@ void OSystem_DS::copyRectToOverlay (const OverlayColor *buf, int pitch, int x, i
{
u16* bg = (u16 *) DS::get16BitBackBuffer();
u16* src = (u16 *) buf;
-
+
// if (x + w > 256) w = 256 - x;
//if (x + h > 256) h = 256 - y;
// consolePrintf("Copy rect ovl %d, %d %d, %d %d\n", x, y, w, h, pitch);
-
-
+
+
for (int dy = y; dy < y + h; dy++) {
-
-
+
+
// Slow but save copy:
for (int dx = x; dx < x + w; dx++) {
-
+
*(bg + (dy * 512) + dx) = *src;
//if ((*src) != 0) consolePrintf("%d,%d: %d ", dx, dy, *src);
//consolePrintf("%d,", *src);
src++;
}
src += (pitch - w);
-
+
// Fast but broken copy: (why?)
/*
REG_IME = 0;
dmaCopy(src, bg + (dy << 9) + x, w * 2);
REG_IME = 1;
-
+
src += pitch;*/
}
-
+
// consolePrintf("Copy rect ovl done");
}
@@ -325,7 +325,7 @@ int16 OSystem_DS::getOverlayWidth()
return getWidth();
}
-
+
bool OSystem_DS::showMouse(bool visible)
{
DS::setShowCursor(visible);
@@ -366,7 +366,7 @@ bool OSystem_DS::pollEvent(Common::Event &event)
return true;
}
}
-
+
return false;
/* if (lastPenFrame != DS::getMillis()) {
@@ -379,7 +379,7 @@ bool OSystem_DS::pollEvent(Common::Event &event)
if (eventNum == 1) {
eventNum = 0;
lastPenFrame = DS::getMillis();
- if (DS::getPenDown()) {
+ if (DS::getPenDown()) {
event.type = Common::EVENT_LBUTTONDOWN;
event.mouse = Common::Point(DS::getPenX(), DS::getPenY());
consolePrintf("Down %d, %d ", event.mouse.x, event.mouse.y);
@@ -408,12 +408,12 @@ void OSystem_DS::delayMillis(uint msecs)
int st = getMillis();
DS::addEventsToQueue();
DS::CD::update();
-
+
DS::doSoundCallback();
while (st + msecs >= getMillis()) {
DS::doSoundCallback();
}
-
+
DS::doTimerCallback();
DS::checkSleepMode();
DS::addEventsToQueue();
@@ -476,7 +476,7 @@ void OSystem_DS::quit()
/* consolePrintf("Soft resetting...");
IPC->reset = 1;
REG_IE = 0;
-
+
asm("swi 0x26\n");
swiSoftReset();*/
}
@@ -498,10 +498,10 @@ Common::SaveFileManager* OSystem_DS::getSavefileManager()
} else {
forceSram = false;
}
- if (forceSram) {
+ if (forceSram) {
consolePrintf("Using SRAM save method!\n");
}
-
+
if (DS::isGBAMPAvailable() && (!forceSram)) {
return &mpSaveManager;
} else {
@@ -519,7 +519,7 @@ Graphics::Surface* OSystem_DS::createTempFrameBuffer() {
_framebuffer.create(DS::getGameWidth(), DS::getGameHeight(), 1);
// Ensure we copy using 16 bit quantities due to limitation of VRAM addressing
-
+
size_t imageStrideInBytes = DS::isCpuScalerEnabled()? DS::getGameWidth() : 512;
size_t imageStrideInWords = imageStrideInBytes / 2;
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index cae40be634..9d6454d02d 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -19,8 +19,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
-
+
+
#ifndef _OSYSTEM_DS_H_
#define _OSYSTEM_DS_H_
#include "common/system.h"
@@ -33,10 +33,10 @@
#include "sound/mixer.h"
#include "graphics/surface.h"
-class DSAudioMixer : public Audio::Mixer {
+class DSAudioMixer : public Audio::Mixer {
};
-class DSTimerManager : public DefaultTimerManager {
+class DSTimerManager : public DefaultTimerManager {
};
@@ -45,10 +45,10 @@ protected:
int eventNum;
int lastPenFrame;
-
+
Common::Event eventQueue[96];
int queuePos;
-
+
DSSaveFileManager saveManager;
GBAMPSaveFileManager mpSaveManager;
DSAudioMixer* _mixer;
@@ -58,7 +58,7 @@ protected:
static OSystem_DS* _instance;
-
+
Graphics::Surface* createTempFrameBuffer();
public:
@@ -98,7 +98,7 @@ public:
inline virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b);
inline virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b);
-
+
virtual bool showMouse(bool visible);
virtual void warpMouse(int x, int y);
@@ -130,21 +130,21 @@ public:
virtual void displayMessageOnOSD(const char *msg);
virtual Common::SaveFileManager *getSavefileManager();
-
+
void addEvent(Common::Event& e);
bool isEventQueueEmpty() { return queuePos == 0; }
-
+
virtual bool grabRawScreen(Graphics::Surface* surf);
-
+
virtual void setFocusRectangle(const Common::Rect& rect);
-
+
virtual void clearFocusRectangle();
-
+
virtual void initBackend();
-
+
virtual Graphics::Surface *lockScreen();
virtual void unlockScreen();
-
+
virtual Audio::Mixer* getMixer() { return _mixer; }
virtual Common::TimerManager* getTimerManager() { return _timer; }
static int timerHandler(int t);
diff --git a/backends/platform/ds/arm9/source/portdefs.h b/backends/platform/ds/arm9/source/portdefs.h
index b4bd15252a..12d53a332f 100644
--- a/backends/platform/ds/arm9/source/portdefs.h
+++ b/backends/platform/ds/arm9/source/portdefs.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#ifndef _PORTDEFS_H_
#define _PORTDEFS_H_
diff --git a/backends/platform/ds/arm9/source/ramsave.cpp b/backends/platform/ds/arm9/source/ramsave.cpp
index 24eea80c5c..8bcc34f9af 100644
--- a/backends/platform/ds/arm9/source/ramsave.cpp
+++ b/backends/platform/ds/arm9/source/ramsave.cpp
@@ -17,7 +17,7 @@
* 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.
- *
+ *
*/
// Save in order 1,2,3,4,larger 2,5
#include "system.h"
@@ -52,18 +52,18 @@ DSSaveFile::DSSaveFile(SCUMMSave* s, bool compressed, u8* data) {
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;
}
@@ -78,7 +78,7 @@ DSSaveFile::~DSSaveFile() {
}
bool DSSaveFile::loadFromSaveRAM(vu8* address) {
-
+
SCUMMSave newSave;
for (int t = 0; t < (int) sizeof(newSave); t++) {
@@ -89,13 +89,13 @@ bool DSSaveFile::loadFromSaveRAM(vu8* address) {
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;
@@ -105,7 +105,7 @@ bool DSSaveFile::loadFromSaveRAM(vu8* address) {
return true;
}
-
+
return false;
}
@@ -114,11 +114,11 @@ void DSSaveFile::compress() {
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;
@@ -129,39 +129,39 @@ 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);
}
@@ -177,7 +177,7 @@ uint32 DSSaveFile::read(void *buf, uint32 size) {
}
memcpy(buf, saveData + ptr, size);
// consolePrintf("byte: %d ", ((u8 *) (buf))[0]);
-
+
ptr += size;
return size;
}
@@ -249,7 +249,7 @@ bool DSSaveFile::matches(char* filename) {
return false;
}
}
-
+
void DSSaveFile::setName(char *name) {
save.isValid = true;
save.magic = 0xBEEFCAFE;
@@ -258,7 +258,7 @@ void DSSaveFile::setName(char *name) {
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 {
@@ -298,10 +298,10 @@ void DSSaveFile::deleteFile() {
DSSaveFileManager::DSSaveFileManager() {
instancePtr = this;
-
+
*((u16 *) (0x4000204)) |= 0x3;
swiWaitForVBlank();
-
+
loadAllFromSRAM();
}
@@ -311,7 +311,7 @@ DSSaveFileManager::~DSSaveFileManager() {
void DSSaveFileManager::loadAllFromSRAM() {
int addr = 1;
-
+
for (int r = 0; r < 8; r++) {
gbaSave[r].deleteFile();
}
@@ -332,7 +332,7 @@ void DSSaveFileManager::formatSram() {
for (int r = 0; r < SRAM_SAVE_MAX; r++) {
*(CART_RAM + r) = 0;
}
-
+
loadAllFromSRAM();
}
@@ -358,7 +358,7 @@ DSSaveFile *DSSaveFileManager::openSavefile(const char* filename, bool saveOrLoa
return gbaSave[r].clone();
}
}
-
+
if (saveOrLoad) {
return makeSaveFile(filename, saveOrLoad);
} else {
@@ -408,21 +408,21 @@ void DSSaveFileManager::listSavefiles(const char *prefix, bool *marks, int num)
}
}
}
-
+
}
*/
}
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;
@@ -439,9 +439,9 @@ void DSSaveFileManager::flushToSaveRAM() {
int cartAddr = 1;
int s;
int extraData = DSSaveFileManager::getExtraData();
-
+
*((u16 *) (0x4000204)) |= 0x3;
-
+
swiWaitForVBlank();
int size = 0;
@@ -451,20 +451,20 @@ void DSSaveFileManager::flushToSaveRAM() {
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;
@@ -475,7 +475,7 @@ void DSSaveFileManager::flushToSaveRAM() {
consolePrintf("WARNING: Save didn't fit in cart RAM and has been lost!! Delete files and save again.");
loadAllFromSRAM();
-
+
}
DSSaveFileManager::setExtraData(extraData);
diff --git a/backends/platform/ds/arm9/source/ramsave.h b/backends/platform/ds/arm9/source/ramsave.h
index d7ba6b5d68..abf225e598 100644
--- a/backends/platform/ds/arm9/source/ramsave.h
+++ b/backends/platform/ds/arm9/source/ramsave.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#ifndef _RAMSAVE_H_
#define _RAMSAVE_H_
@@ -46,56 +46,56 @@ class DSSaveFile : public Common::InSaveFile, public Common::OutSaveFile {
u16 extraMagic; // 32
u32 reserved; // 36
} __attribute__ ((packed));
-
+
SCUMMSave save;
u8* saveData;
SCUMMSave* origHeader;
bool isOpenFlag;
bool isTempFile;
-
+
public:
DSSaveFile();
DSSaveFile(SCUMMSave* s, bool saveCompressed, u8* data);
~DSSaveFile();
-
+
void reset();
-
+
bool isOpen() const { return isOpenFlag; }
virtual bool eos() const;
virtual void skip(uint32 size);
-
+
virtual uint32 pos() const;
virtual uint32 size() const;
virtual void 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(char* prefix, int num);
bool matches(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);
}
@@ -107,34 +107,34 @@ public:
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 char* filename) { return openSavefile(filename, true); }
virtual Common::InSaveFile* openForLoading(const char* filename) { return openSavefile(filename, false); }
virtual bool removeSavefile(const char *filename);
virtual Common::StringList listSavefiles(const char *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();
diff --git a/backends/platform/ds/arm9/source/scummconsole.c b/backends/platform/ds/arm9/source/scummconsole.c
index 2145b47353..980dea7bc4 100644
--- a/backends/platform/ds/arm9/source/scummconsole.c
+++ b/backends/platform/ds/arm9/source/scummconsole.c
@@ -25,7 +25,7 @@
//
// Changelog:
// 0.1: First version
-// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
+// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
// Changed some register defines for consistency.
//
//////////////////////////////////////////////////////////////////////
@@ -52,7 +52,7 @@ u16* fontMap;
u8 row, col;
//font may not start on a character base boundry
-u16 fontOffset;
+u16 fontOffset;
//the first character in the set (0 if you have a full set)
u16 fontStart;
@@ -65,7 +65,7 @@ u16 fontPal;
///////////////////////////////////////////////////////////
//consoleInit
-// param:
+// param:
// font: 16 color font
// charBase: the location the font data will be loaded to
// numCharacters: count of characters in the font
@@ -79,7 +79,7 @@ void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16*
int i;
row = col = 0;
-
+
fontStart = charStart;
fontOffset = 0;
@@ -111,9 +111,9 @@ void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16*
temp |= 0xF00;
if(font[i] & 0xF000)
temp |= 0xF000;
-
+
charBase[i] = temp;
- }
+ }
}
}//end if bitdepth
else
@@ -140,7 +140,7 @@ void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16*
void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth)
{
- consoleInit((u16 *) default_font_bin, charBase, 128, 0, map, CONSOLE_USE_COLOR255, bitDepth);
+ consoleInit((u16 *) default_font_bin, charBase, 128, 0, map, CONSOLE_USE_COLOR255, bitDepth);
}
void consolePrintSet(int x, int y)
@@ -164,9 +164,9 @@ void consolePrintChar(char c)
{
col = 0;
- row++;
+ row++;
}
-
+
if(row >= CONSOLE_HEIGHT)
{
row--;
@@ -178,7 +178,7 @@ void consolePrintChar(char c)
}
-
+
switch(c)
{
@@ -199,7 +199,7 @@ void consolePrintChar(char c)
}
-
+
}
@@ -207,16 +207,16 @@ void printX(int w, unsigned d)
{
int loop = 0;
int i = 0;
-
+
char buf[20] = {0};
while(d > 0)
{
buf[loop++] = d & 0xF;
- d = d>>4;
+ d = d>>4;
}
-
+
for (i = 7; i >= 0; i--)
{
if(buf[i] || i < loop)
@@ -235,15 +235,15 @@ void printx(int w, unsigned int d)
{
int loop = 0;
int i = 0;
-
+
char buf[20] = {0};
while(d > 0)
{
buf[loop++] = d & 0xF;
- d = d>>4;
+ d = d>>4;
}
-
+
for (i = 7; i >= 0; i--)
{
if(buf[i] || i < loop)
@@ -262,8 +262,8 @@ void printInt(int w, int d)
{
int loop = 0;
int i = 0;
-
- char buf[20] = {0};
+
+ char buf[20] = {0};
if(d < 0)
{
@@ -276,9 +276,9 @@ void printInt(int w, int d)
else while (d > 0)
{
buf[loop++] = d % 10;
- d /= 10;
+ d /= 10;
}
-
+
for (i = 7; i >= 0; i--)
{
if(buf[i] || i < loop)
@@ -310,16 +310,16 @@ void print0X(int w, unsigned d)
{
int loop = 0;
int i = 0;
-
+
char buf[] = {0,0,0,0,0,0,0,0}; //set to zero cause I may add formatted output someday
-
+
while(d > 0)
{
buf[loop++] = d & 0xF;
- d = d>>4;
+ d = d>>4;
}
-
+
for (i = 7; i >= 0; i--)
{
if(buf[i] || i < w || i < loop)
@@ -336,16 +336,16 @@ void print0x(int w, unsigned int d)
{
int loop = 0;
int i = 0;
-
+
char buf[] = {0,0,0,0,0,0,0,0}; //set to zero cause I may add formatted output someday
-
+
while(d > 0)
{
buf[loop++] = d & 0xF;
- d = d>>4;
+ d = d>>4;
}
-
+
for (i = 7; i >= 0; i--)
{
if(buf[i] || i < w || i < loop)
@@ -362,9 +362,9 @@ void print0Int(int w, int d)
{
int loop = 0;
int i = 0;
-
+
char buf[] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; //set to zero cause I may add formatted output someday
-
+
if(d < 0)
{
consolePrintChar('-');
@@ -374,9 +374,9 @@ void print0Int(int w, int d)
while(d > 0)
{
buf[loop++] = d % 10;
- d /= 10;
+ d /= 10;
}
-
+
for (i = 15; i >= 0; i--)
if(buf[i] || i < w || i < loop)
consolePrintChar(buf[i] + '0');
@@ -414,14 +414,14 @@ void printF(int w, float f)
if(*t & BIT(31))
consolePrintChar('-');
-
+
print0Bin(32, fraction);
-
+
printInt(1, fraction);
consolePrintChar('e');
printInt(1, exp - 127);
-
+
/*
if(exp == 0 && fraction == 0)
{
@@ -447,7 +447,7 @@ void consolePrintf(const char* s, ...)
va_list argp;
va_start(argp, s);
-
+
while(*s)
{
@@ -474,7 +474,7 @@ void consolePrintf(const char* s, ...)
case 'I':
case 'd':
case 'D':
- if(z)print0Int(w, va_arg(argp, int));
+ if(z)print0Int(w, va_arg(argp, int));
else printInt(w, va_arg(argp, int));
s++;
break;
diff --git a/backends/platform/ds/arm9/source/scummconsole.h b/backends/platform/ds/arm9/source/scummconsole.h
index 01fdfc2f04..d8ccf34c62 100644
--- a/backends/platform/ds/arm9/source/scummconsole.h
+++ b/backends/platform/ds/arm9/source/scummconsole.h
@@ -25,7 +25,7 @@
//
// Changelog:
// 0.1: First version
-// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
+// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
// Changed some register defines for consistency.
//
//////////////////////////////////////////////////////////////////////
diff --git a/backends/platform/ds/arm9/source/scummhelp.cpp b/backends/platform/ds/arm9/source/scummhelp.cpp
index 452f782dc5..f9efd58276 100644
--- a/backends/platform/ds/arm9/source/scummhelp.cpp
+++ b/backends/platform/ds/arm9/source/scummhelp.cpp
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#include "scummhelp.h"
#define ADD_BIND(k,d) do { key[i] = k; dsc[i] = d; i++; } while (0)
diff --git a/backends/platform/ds/arm9/source/scummhelp.h b/backends/platform/ds/arm9/source/scummhelp.h
index e79c863cbd..602cb5f788 100644
--- a/backends/platform/ds/arm9/source/scummhelp.h
+++ b/backends/platform/ds/arm9/source/scummhelp.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#ifndef _SCUMMHELP_H_
#define _SCUMMHELP_H_
@@ -30,7 +30,7 @@ namespace DS {
void updateStrings(byte gameId, byte version, Common::Platform platform,
int page, Common::String &title, Common::String *&key, Common::String *&dsc);
-
+
}
#endif
diff --git a/backends/platform/ds/arm9/source/touchkeyboard.cpp b/backends/platform/ds/arm9/source/touchkeyboard.cpp
index 9ac8361985..5927f204da 100644
--- a/backends/platform/ds/arm9/source/touchkeyboard.cpp
+++ b/backends/platform/ds/arm9/source/touchkeyboard.cpp
@@ -45,7 +45,7 @@ struct key_data {
key_data keys[DS_NUM_KEYS] = {
// Key number x y character
-
+
// Numbers
{28, 3, 0, '1'},
{29, 5, 0, '2'},
@@ -116,7 +116,7 @@ key_data keys[DS_NUM_KEYS] = {
{54, 29, 8, Common::KEYCODE_DOWN},
{53, 31, 8, Common::KEYCODE_RIGHT},
{51, 29, 6, Common::KEYCODE_UP},
-
+
// Close button
{56, 30, 0, Common::KEYCODE_INVALID},
@@ -133,7 +133,7 @@ key_data keys[DS_NUM_KEYS] = {
{66, 26, -2, Common::KEYCODE_F10},
{67, 28, -2, Common::KEYCODE_F11},
{68, 30, -2, Common::KEYCODE_F12},
-
+
};
int keyboardX;
@@ -162,7 +162,7 @@ void restoreVRAM(int tileBase, int mapBase, u16* saveSpace) {
/* for (int r = 0; r < 32 * 32; r++) {
((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase))[r] = *saveSpace++;
}
-
+
for (int r = 0; r < 4096; r++) {
((u16 *) CHAR_BASE_BLOCK_SUB(tileBase))[r] = *saveSpace++;
}*/
@@ -175,19 +175,19 @@ void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) {
// *saveSpace++ = ((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase))[r];
((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase))[r] = 0;
}
-
+
for (int r = 0; r < KEYBOARD_DATA_SIZE / 2; r++) {
// *saveSpace++ = ((u16 *) CHAR_BASE_BLOCK_SUB(tileBase))[r];
((u16 *) CHAR_BASE_BLOCK_SUB(tileBase))[r] = ((u16 *) (keyboard_raw))[r];
}
-
+
for (int r = 0; r < 16; r++) {
BG_PALETTE_SUB[r] = ((u16 *) (keyboard_pal_raw))[r];
}
// this is the font
for (int tile = 0; tile < 94; tile++) {
-
+
u16* tileAddr = (u16 *) (CHAR_BASE_BLOCK_SUB(tileBase) + ((KEYBOARD_DATA_SIZE) + (tile * 32)));
u8* src = ((u8 *) (_8x8font_tga_raw)) + 18 + tile * 8;
@@ -197,55 +197,55 @@ void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) {
| ((*(src + (y * 752) + (x * 4) + 1) & 0x0F) << 4)
| ((*(src + (y * 752) + (x * 4) + 2) & 0x0F) << 8)
| ((*(src + (y * 752) + (x * 4) + 3) & 0x0F) << 12);
-
+
}
}
}
-
+
for (int r = 0; r < 16; r++) {
int col = ((u16 *) (keyboard_pal_raw))[r];
-
+
int red = col & 0x001F;
int green = (col & 0x03E0) >> 5;
int blue = (col & 0x7C00) >> 10;
-
+
red = (red * 8) / 16;
green = (green * 24) / 16;
blue = (blue * 8) / 16;
if (green > 31) green = 31;
-
+
BG_PALETTE_SUB[16 + r] = red | (green << 5) | (blue << 10);
}
-
+
keyboardX = -2;
keyboardY = 2;
-
+
DS::mapBase = mapBase;
DS::tileBase = tileBase;
-
+
shiftState = false;
capsLockState = false;
-
+
int x = keyboardX;
int y = keyboardY;
-
+
u16* base = ((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase));
baseAddress = base;
-
+
for (int r = 0; r < DS_NUM_KEYS; r++) {
base[(y + keys[r].y) * 32 + x + keys[r].x] = 10 + keys[r].keyNum * 2;
base[(y + keys[r].y) * 32 + x + keys[r].x + 1] = 10 + keys[r].keyNum * 2 + 1;
-
+
base[(y + keys[r].y + 1) * 32 + x + keys[r].x] = 10 + 148 + keys[r].keyNum * 2;
base[(y + keys[r].y + 1) * 32 + x + keys[r].x + 1] = 10 + 148 + keys[r].keyNum * 2 + 1;
-
+
keys[r].pressed = false;
}
-
+
closed = false;
clearAutoComplete();
}
@@ -257,7 +257,7 @@ void drawAutoComplete() {
baseAddress[y * 32 + x] = 0;
}
}
-
+
for (int r = 0; r < autoCompleteCount; r++) {
int y = 12 + (r % 6) * 2;
@@ -265,15 +265,15 @@ void drawAutoComplete() {
for (int p = 0; p < strlen(autoCompleteWord[r]); p++) {
char c = autoCompleteWord[r][p];
-
+
int tile = c - 33 + (KEYBOARD_DATA_SIZE / 32);
if (selectedCompletion == r) {
tile |= 0x1000;
}
- baseAddress[y * 32 + x + p] = tile;
-
+ baseAddress[y * 32 + x + p] = tile;
+
}
}
@@ -330,7 +330,7 @@ void typeCompletion(int current) {
event.type = Common::EVENT_KEYDOWN;
event.kbd.flags = 0;
system->addEvent(event);
-
+
event.type = Common::EVENT_KEYUP;
system->addEvent(event);
}
@@ -351,13 +351,13 @@ void updateTypeEvents()
{
Common::Event event;
OSystem_DS* system = OSystem_DS::instance();
-
+
event.kbd.keycode = (Common::KeyCode) autoCompleteBuffer[0];
event.kbd.ascii = autoCompleteBuffer[0];
event.type = Common::EVENT_KEYDOWN;
event.kbd.flags = 0;
system->addEvent(event);
-
+
event.type = Common::EVENT_KEYUP;
system->addEvent(event);
@@ -380,21 +380,21 @@ void createKeyEvent(int keyNum, Common::Event& event)
} else {
event.kbd.keycode = (Common::KeyCode) (Common::KEYCODE_F1 - (keys[keyNum].character - '1'));
event.kbd.ascii = 0;
- }
-
+ }
+
} else if ((keys[keyNum].character >= 'A') && (keys[keyNum].character <= 'Z')) {
-
+
if ((!DS::shiftState) && (!DS::capsLockState)) {
event.kbd.ascii = keys[keyNum].character + 32; // Make key lowercase.
} else {
event.kbd.ascii = keys[keyNum].character;
}
-
+
event.kbd.keycode = (Common::KeyCode) event.kbd.ascii;
} else {
event.kbd.ascii = keys[keyNum].character;
event.kbd.keycode = (Common::KeyCode) keys[keyNum].character;
- }
+ }
}
void addKeyboardEvents() {
@@ -403,7 +403,7 @@ void addKeyboardEvents() {
if (DS::getPenDown()) {
int x = IPC->touchXpx;
int y = IPC->touchYpx;
-
+
int tx = (x >> 3);
int ty = (y >> 3);
@@ -427,48 +427,48 @@ void addKeyboardEvents() {
tx -= keyboardX;
ty -= keyboardY;
-
+
// consolePrintf("x=%d y=%d\n", tx, ty);
-
+
for (int r = 0; r < DS_NUM_KEYS; r++) {
- if (( (tx >= keys[r].x) && (tx <= keys[r].x + 1)) &&
+ 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();
Common::Event event;
-
+
// consolePrintf("Key: %d\n", r);
if ((keys[r].character == Common::KEYCODE_INVALID)) {
// Close button
DS::closed = true;
} else {
createKeyEvent(r, event);
- }
-
- //event.kbd.keycode = keys[r].character;
- //event.kbd.ascii = keys[r].character;
+ }
+
+ //event.kbd.keycode = keys[r].character;
+ //event.kbd.ascii = keys[r].character;
event.type = Common::EVENT_KEYDOWN;
system->addEvent(event);
// event.type = Common::EVENT_KEYUP;
// system->addEvent(event);
-
+
switch (keys[r].character) {
case DS_SHIFT: {
DS::shiftState = !DS::shiftState;
DS::setKeyHighlight(r, DS::shiftState);
break;
}
-
+
case DS_CAPSLOCK: {
DS::capsLockState = !DS::capsLockState;
DS::setKeyHighlight(r, DS::capsLockState);
break;
}
-
+
default: {
DS::setKeyHighlight(r, true);
keys[r].pressed = true;
-
+
if (DS::shiftState) {
DS::shiftState = false;
for (int t = 0; t < DS_NUM_KEYS; t++) {
@@ -480,19 +480,19 @@ void addKeyboardEvents() {
break;
}
}
-
+
}
}
}
-
+
if (DS::getPenReleased()) {
-
+
for (int r = 0; r < DS_NUM_KEYS; r++) {
if (keys[r].pressed) {
DS::setKeyHighlight(r, false);
OSystem_DS* system = OSystem_DS::instance();
-
+
Common::Event event;
createKeyEvent(r, event);
event.type = Common::EVENT_KEYUP;
@@ -500,7 +500,7 @@ void addKeyboardEvents() {
keys[r].pressed = false;
}
- }
+ }
}
}
diff --git a/backends/platform/ds/arm9/source/touchkeyboard.h b/backends/platform/ds/arm9/source/touchkeyboard.h
index 8a5fc728ce..e4aa102ab4 100644
--- a/backends/platform/ds/arm9/source/touchkeyboard.h
+++ b/backends/platform/ds/arm9/source/touchkeyboard.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#ifndef _TOUCHKEYBOARD_H_
#define _TOUCHKEYBOARD_H_
diff --git a/backends/platform/ds/arm9/source/wordcompletion.cpp b/backends/platform/ds/arm9/source/wordcompletion.cpp
index b8fbf6c5cd..b5bebddb54 100644
--- a/backends/platform/ds/arm9/source/wordcompletion.cpp
+++ b/backends/platform/ds/arm9/source/wordcompletion.cpp
@@ -23,7 +23,7 @@ void addAutoCompleteLine(char* line) {
{
char word[32];
int length;
-
+
// Skip the T9-style numbers
while (*line != ' ')
{
@@ -37,7 +37,7 @@ void addAutoCompleteLine(char* line) {
if (*line == ' ') line++;
- // Copy the new word
+ // Copy the new word
do {
word[length++] = *line++;
} while ((*line != '\0') && (*line != ' ') && (*line != '\n'));
@@ -47,7 +47,7 @@ void addAutoCompleteLine(char* line) {
// Store a pointer to the start of the word
wordBufferPtr[wordBufferPtrPos++] = &wordBuffer[wordBufferPos];
-
+
// copy the new word into the buffer
strcpy(&wordBuffer[wordBufferPos], word);
wordBufferPos += strlen(word) + 1;
@@ -104,11 +104,11 @@ bool findWordCompletions(char* input)
// Get the word from the dictonary line
word = wordBufferPtr[position];
-
+
// Now check to see if the word is before or after the stub we're after
int result = scumm_stricmp((const char *) partialWord, (const char *) word);
-
+
if (result == 0) {
// We've found the whole word. Aren't we good.
break;
@@ -128,10 +128,10 @@ bool findWordCompletions(char* input)
word = wordBufferPtr[position];
//consolePrintf("Final word: %s\n", word);
-
+
system->setCharactersEntered(strlen(partialWord));
-
+
bool match = true;
@@ -161,7 +161,7 @@ bool findWordCompletions(char* input)
break;
}
}
-
+
if (match) {
system->addAutoComplete(word);
}
diff --git a/backends/platform/ds/arm9/source/zipreader.cpp b/backends/platform/ds/arm9/source/zipreader.cpp
index 01321f44f5..7af0718a44 100644
--- a/backends/platform/ds/arm9/source/zipreader.cpp
+++ b/backends/platform/ds/arm9/source/zipreader.cpp
@@ -17,7 +17,7 @@
* 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.
- *
+ *
*/
@@ -29,25 +29,25 @@
ZipFile::ZipFile() {
// Locate a zip file in cartridge memory space
-
+
// consolePrintf("ZIP file check...");
-
+
char* p = (char *) ZF_SEARCH_START;
bool found = false;
-
+
_zipFile = NULL;
-
+
while ((p != (char *) ZF_SEARCH_END) && (!found)) {
// Zip file header is: 0x504B0304
-
+
if ( (*p == 0x50) && (*(p + 1) == 0x4B) && (*(p + 2) == 0x03) && (*(p + 3) == 0x04) ) {
// Found header!
found = true;
_zipFile = p;
}
-
+
if (!found) p += ZF_SEARCH_STRIDE;
-
+
}
if (_zipFile) {
@@ -56,14 +56,14 @@ ZipFile::ZipFile() {
// consolePrintf("Not in use!\n");
return;
}
-
+
changeToRoot();
restartFile();
-
+
if (_currentFile->compSize != (u32) getFileSize()) {
consolePrintf("Error: ZIP file contains compression!\n");
}
-
+
_allFilesVisible = false;
}
@@ -83,19 +83,19 @@ bool ZipFile::restartFile() {
getFileName(name);
more = skipFile();
}
-
+
return more;
}
bool ZipFile::currentFileInFolder() {
char name[128];
-
+
if (_allFilesVisible) return true;
-
+
getFileName(name);
// consolePrintf("N:'%s'D:'%s'\n", name, _directory);
-
+
if (_directory[0] == 0) { // Root directory
name[strlen(name) - 1] = 0;
return !strchr(name, '\\'); // Not in root if contains a / character before the last character
@@ -104,52 +104,52 @@ bool ZipFile::currentFileInFolder() {
&& (no slashes after the directory || it's the last character)
&& (slash follows directory)
*/
- if ((strstr(name, _directory) == name) && (strlen(name) != strlen(_directory))
+ if ((strstr(name, _directory) == name) && (strlen(name) != strlen(_directory))
&& ((strchr(name + strlen(_directory) + 1, '\\') == NULL)
|| (strchr(name + strlen(_directory) + 1, '\\') == name + strlen(name) - 1))
&& (*(name + strlen(_directory)) == '\\')) {
return true;
}
}
-
+
return false;
}
void ZipFile::getFileName(char* name) {
strncpy(name, (char *) (_currentFile + 1), _currentFile->nameLength);
-
+
for (int r = 0; r < (int) strlen(name); r++) {
if (name[r] == '/') name[r] = '\\';
}
name[_currentFile->nameLength] = 0;
-
+
if (name[strlen(name) - 1] == '\\') {
name[strlen(name) - 1] = 0;
- }
+ }
}
bool ZipFile::skipFile() {
bool valid;
do {
-
+
// Move on to the next file
_currentFile = (FileHeader *) (
((char *) (_currentFile)) + sizeof(*_currentFile) + _currentFile->nameLength + _currentFile->fileSize + _currentFile->extraLength
);
-
+
// Return true if there are more files. Check this by looking for the magic number
valid = (_currentFile->magic[0] == 0x50) &&
(_currentFile->magic[1] == 0x4B) &&
(_currentFile->magic[2] == 0x03) &&
(_currentFile->magic[3] == 0x04);
-
-
+
+
} while (valid && !currentFileInFolder());
-
+
return valid;
-
+
// Currently doesn't handle data descriptors!
}
@@ -180,7 +180,7 @@ char* ZipFile::getFile() {
bool ZipFile::findFile(char* search) {
changeToRoot();
restartFile();
-
+
char searchName[128];
strcpy(searchName, search);
for (int r = 0; r < (int) strlen(searchName); r++) {
@@ -191,15 +191,15 @@ bool ZipFile::findFile(char* search) {
*(searchName + strlen(searchName) - 1) = '\0'; // which we need to dispose of.
}
-
+
do {
char name[128];
getFileName(name);
if (*(name + strlen(name) - 1) == '\\') { // Directories have a terminating slash
*(name + strlen(name) - 1) = '\0'; // which we need to dispose of.
}
-
-
+
+
if (!stricmp(name, searchName)) {
// consolePrintf("'%s'=='%s'\n", name, searchName);
return true; // Got it!
@@ -222,7 +222,7 @@ void ZipFile::changeDirectory(char* dir) {
for (int r = 0; r < (int) strlen(_directory); r++) {
if (_directory[r] == '/') _directory[r] = '\\';
}
-
+
if (_directory[strlen(_directory) - 1] == '\\') {
_directory[strlen(_directory) - 1] = '\0';
}
diff --git a/backends/platform/ds/arm9/source/zipreader.h b/backends/platform/ds/arm9/source/zipreader.h
index 19aa3d9f31..cd7244dba5 100644
--- a/backends/platform/ds/arm9/source/zipreader.h
+++ b/backends/platform/ds/arm9/source/zipreader.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#ifndef _ZIPREADER_H_
#define _ZIPREADER_H_
#include "portdefs.h"
@@ -45,9 +45,9 @@ class ZipFile {
char* _zipFile;
char _directory[128];
-
+
bool _allFilesVisible;
-
+
FileHeader* _currentFile;
public:
@@ -55,25 +55,25 @@ public:
~ZipFile();
bool isReady();
-
+
// These operations set the current file
bool restartFile();
bool skipFile();
- bool findFile(char* search);
+ bool findFile(char* search);
// These return the file's data and information
char* getFile();
int getFileSize();
void getFileName(char* name);
bool isDirectory();
-
+
// These set the current directory
void changeDirectory(char* name);
void changeToRoot();
void setAllFilesVisible(bool state) { _allFilesVisible = state; }
-
+
bool currentFileInFolder();
-
+
u16 misaligned16(u16* v);
u32 misaligned32(u32* v);