aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ds/arm9/source
diff options
context:
space:
mode:
authorMax Horn2010-07-05 20:36:11 +0000
committerMax Horn2010-07-05 20:36:11 +0000
commit429de8f6efc3d3dcbbdfbc9f7eb53d2d096ca925 (patch)
treecc94d2427cc629bd6b2047c6289c58b844efb5e9 /backends/platform/ds/arm9/source
parentcffcc3d9360dbbadec4a3e18c3b6ca64dfc27995 (diff)
downloadscummvm-rg350-429de8f6efc3d3dcbbdfbc9f7eb53d2d096ca925.tar.gz
scummvm-rg350-429de8f6efc3d3dcbbdfbc9f7eb53d2d096ca925.tar.bz2
scummvm-rg350-429de8f6efc3d3dcbbdfbc9f7eb53d2d096ca925.zip
DS: More formating, made more vars static
svn-id: r50708
Diffstat (limited to 'backends/platform/ds/arm9/source')
-rw-r--r--backends/platform/ds/arm9/source/blitters.cpp64
-rw-r--r--backends/platform/ds/arm9/source/cdaudio.cpp74
-rw-r--r--backends/platform/ds/arm9/source/dsmain.cpp61
-rw-r--r--backends/platform/ds/arm9/source/dsoptions.cpp2
-rw-r--r--backends/platform/ds/arm9/source/keys.cpp33
-rw-r--r--backends/platform/ds/arm9/source/keys.h2
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp3
-rw-r--r--backends/platform/ds/arm9/source/touchkeyboard.cpp32
-rw-r--r--backends/platform/ds/arm9/source/zipreader.cpp1
9 files changed, 98 insertions, 174 deletions
diff --git a/backends/platform/ds/arm9/source/blitters.cpp b/backends/platform/ds/arm9/source/blitters.cpp
index 559845cb18..5d29672ef6 100644
--- a/backends/platform/ds/arm9/source/blitters.cpp
+++ b/backends/platform/ds/arm9/source/blitters.cpp
@@ -33,10 +33,10 @@ namespace DS {
void asmDrawStripToScreen(int height, int width, byte const *text, byte const *src, byte *dst,
int vsPitch, int vmScreenWidth, int textSurfacePitch) {
-
- if (height <= 0) height = 1;
- if (width < 4) return;
-
+ if (height <= 0)
+ height = 1;
+ if (width < 4)
+ return;
width &= ~4;
// src = (const byte *) (((int) (src)) & (~4));
@@ -144,22 +144,19 @@ void asmCopy8Col(byte *dst, int dstPitch, const byte *src, int height) {
static bool isDivBy5Ready = false;
static u32 DIV_BY_5[160];
-void ComputeDivBy5TableIFN()
-{
+void ComputeDivBy5TableIFN() {
if (isDivBy5Ready)
return;
isDivBy5Ready = true;
- for (int i=0; i<160; ++i)
- {
+ for (int i = 0; i < 160; ++i) {
DIV_BY_5[i] = (2*i+5)/10;
}
}
#ifdef PERFECT_5_TO_4_RESCALING
static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3, u16 s4,
- u16 *dest)
-{
+ u16 *dest) {
u32 bs0 = s0 & 0x1F;
u32 bs1 = s1 & 0x1F;
u32 bs2 = s2 & 0x1F;
@@ -233,8 +230,7 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3
}
#else
static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3, u16 s4,
- u16 *dest)
-{
+ u16 *dest) {
static const u32 MASK = 0x03E07C1F;
u32 argbargbs0 = u32(s0) | (u32(s0) << 16);
@@ -282,8 +278,7 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3
#endif
static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3, u32 s4,
- u16 *dest)
-{
+ u16 *dest) {
u32 d0 = 4*s0 + s1;
u32 d1 = 2*s1 + s1 + 2*s2;
@@ -320,12 +315,10 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3
// Can't work in place
#ifdef PERFECT_5_TO_4_RESCALING
-static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16 *dest, const u8 *src, const u32 *palette)
-{
+static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16 *dest, const u8 *src, const u32 *palette) {
ComputeDivBy5TableIFN();
- for (size_t i=0; i<64; ++i)
- {
+ for (size_t i = 0; i < 64; ++i) {
u32 s0 = palette[src[5*i+0]];
u32 s1 = palette[src[5*i+1]];
u32 s2 = palette[src[5*i+2]];
@@ -336,10 +329,8 @@ static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16 *dest, const
}
}
#else
-static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16 *dest, const u8 *src, const u16 *palette)
-{
- for (size_t i=0; i<64; ++i)
- {
+static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16 *dest, const u8 *src, const u16 *palette) {
+ for (size_t i = 0; i < 64; ++i) {
u16 s0 = palette[src[5*i+0]];
u16 s1 = palette[src[5*i+1]];
u16 s2 = palette[src[5*i+2]];
@@ -353,12 +344,10 @@ static inline void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16 *dest, const
// Can work in place, because it's a contraction
-static inline void Rescale_320x1555Scanline_To_256x1555Scanline(u16 *dest, const u16 *src)
-{
+static inline void Rescale_320x1555Scanline_To_256x1555Scanline(u16 *dest, const u16 *src) {
ComputeDivBy5TableIFN();
- for (size_t i=0; i<64; ++i)
- {
+ for (size_t i = 0; i < 64; ++i) {
u16 s0 = src[5*i+0];
u16 s1 = src[5*i+1];
u16 s2 = src[5*i+2];
@@ -370,13 +359,11 @@ static inline void Rescale_320x1555Scanline_To_256x1555Scanline(u16 *dest, const
}
#ifdef PERFECT_5_TO_4_RESCALING
-void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStride, int srcStride, const u16 *palette)
-{
+void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStride, int srcStride, const u16 *palette) {
u32 fastRam[768];
// Palette lookup -> 0_888
- for (size_t i=0; i<256; ++i)
- {
+ for (size_t i = 0; i < 256; ++i) {
u32 col = palette[i];
u32 result = col & 0x0000001F;
result |= (col << 3) & 0x00001F00;
@@ -385,29 +372,24 @@ void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStri
fastRam[i] = result;
}
- for (size_t i=0; i<200; ++i)
- {
+ for (size_t i = 0; i < 200; ++i) {
Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam);
}
}
#else
-void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStride, int srcStride, const u16 *palette)
-{
+void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStride, int srcStride, const u16 *palette) {
u16 fastRam[256];
- for (size_t i=0; i<128; ++i)
+ for (size_t i = 0; i < 128; ++i)
((u32*)fastRam)[i] = ((const u32*)palette)[i];
- for (size_t i=0; i<200; ++i)
- {
+ for (size_t i = 0; i < 200; ++i) {
Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam);
}
}
#endif
-void Rescale_320x256x1555_To_256x256x1555(u16 *dest, const u16 *src, int destStride, int srcStride)
-{
- for (size_t i=0; i<200; ++i)
- {
+void Rescale_320x256x1555_To_256x256x1555(u16 *dest, const u16 *src, int destStride, int srcStride) {
+ for (size_t i = 0; i < 200; ++i) {
Rescale_320x1555Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride);
}
}
diff --git a/backends/platform/ds/arm9/source/cdaudio.cpp b/backends/platform/ds/arm9/source/cdaudio.cpp
index a5d38cb7e4..5860dea4f2 100644
--- a/backends/platform/ds/arm9/source/cdaudio.cpp
+++ b/backends/platform/ds/arm9/source/cdaudio.cpp
@@ -328,45 +328,30 @@ void decompressBlock() {
int offset = 0;
switch (7 - (r & 0x0007)) {
- case 0: {
- offset = (word & 0xF0000000) >> 28;
- break;
- }
-
- case 1: {
- offset = (word & 0x0F000000) >> 24;
- break;
- }
-
- case 2: {
- offset = (word & 0x00F00000) >> 20;
- break;
- }
-
- case 3: {
- offset = (word & 0x000F0000) >> 16;
- break;
- }
-
- case 4: {
- offset = (word & 0x0000F000) >> 12;
- break;
- }
-
- case 5: {
- offset = (word & 0x00000F00) >> 8;
- break;
- }
-
- case 6: {
- offset = (word & 0x000000F0) >> 4;
- break;
- }
-
- case 7: {
- offset = (word & 0x0000000F);
- break;
- }
+ case 0:
+ offset = (word & 0xF0000000) >> 28;
+ break;
+ case 1:
+ offset = (word & 0x0F000000) >> 24;
+ break;
+ case 2:
+ offset = (word & 0x00F00000) >> 20;
+ break;
+ case 3:
+ offset = (word & 0x000F0000) >> 16;
+ break;
+ case 4:
+ offset = (word & 0x0000F000) >> 12;
+ break;
+ case 5:
+ offset = (word & 0x00000F00) >> 8;
+ break;
+ case 6:
+ offset = (word & 0x000000F0) >> 4;
+ break;
+ case 7:
+ offset = (word & 0x0000000F);
+ break;
}
int diff = 0;
@@ -409,7 +394,8 @@ void decompressBlock() {
}
void playNextBlock() {
- if (!isPlayingFlag) return;
+ if (!isPlayingFlag)
+ return;
int lastBlockId = -1;
while (IPC->adpcm.semaphore); // Wait for buffer to become free if needed
@@ -445,9 +431,6 @@ void playNextBlock() {
// DC_FlushAll();
}
-
-
-
}
@@ -463,7 +446,8 @@ void playNextBlock() {
}
void stopTrack() {
- if (!isPlayingFlag) return;
+ if (!isPlayingFlag)
+ return;
DS::std_fclose(s_file);
@@ -473,7 +457,7 @@ void stopTrack() {
audioBuffer[r] = 0;
}
- for (int r= 0; r < waveHeader.fmtExtra; r++) {
+ for (int r = 0; r < waveHeader.fmtExtra; r++) {
decompressionBuffer[r] = 0;
}
// DS::stopSound(1);
diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp
index d1e30b93cd..dc52038cec 100644
--- a/backends/platform/ds/arm9/source/dsmain.cpp
+++ b/backends/platform/ds/arm9/source/dsmain.cpp
@@ -1026,8 +1026,9 @@ u16 *get16BitBackBuffer() {
}
s32 get8BitBackBufferStride() {
- // When the CPU scaler is enabled, the back buffer is in system RAM and is 320 pixels wide
- // When the CPU scaler is disabled, the back buffer is in video memory and therefore must have a 512 pixel stride
+ // When the CPU scaler is enabled, the back buffer is in system RAM and is
+ // 320 pixels wide. When the CPU scaler is disabled, the back buffer is in
+ // video memory and therefore must have a 512 pixel stride.
if (isCpuScalerEnabled()){
return 320;
@@ -1371,8 +1372,7 @@ void doScreenTapMode(OSystem_DS *system) {
system->addEvent(event);
}
-void doButtonSelectMode(OSystem_DS *system)
-{
+void doButtonSelectMode(OSystem_DS *system) {
Common::Event event;
@@ -1670,12 +1670,9 @@ void addEventsToQueue() {
if (!keyboardEnable) {
-
if (((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) || (indyFightState)) && (displayModeIs8Bit)) {
// Controls specific to the control method
-
-
if (s_currentGame->control == CONT_SKY) {
// Extra controls for Beneath a Steel Sky
if ((getKeysDown() & KEY_DOWN)) {
@@ -1686,7 +1683,6 @@ void addEventsToQueue() {
if (s_currentGame->control == CONT_AGI) {
// Extra controls for Leisure Suit Larry and KQ4
-
if ((getKeysHeld() & KEY_UP) && (getKeysHeld() & KEY_START)
/*&& (!strcmp(gameName, "LLLLL"))*/) {
consolePrintf("Cheat key!\n");
@@ -1699,11 +1695,8 @@ void addEventsToQueue() {
event.type = Common::EVENT_KEYUP;
system->addEvent(event);
}
-
}
-
-
if (s_currentGame->control == CONT_SIMON) {
// Extra controls for Simon the Sorcerer
if ((getKeysDown() & KEY_DOWN)) {
@@ -1719,8 +1712,6 @@ void addEventsToQueue() {
}
}
-
-
if (s_currentGame->control == CONT_SCUMM_ORIGINAL) {
// Extra controls for Scumm v1-5 games
if ((getKeysDown() & KEY_DOWN)) {
@@ -1803,9 +1794,7 @@ void addEventsToQueue() {
}
consumeKeys();
-
consumePenEvents();
-
}
}
@@ -1835,23 +1824,19 @@ void updateStatus() {
if (displayModeIs8Bit) {
if (!tapScreenClicks) {
switch (mouseMode) {
- case MOUSE_LEFT: {
- offs = 1;
- break;
- }
- case MOUSE_RIGHT: {
- offs = 2;
- break;
- }
- case MOUSE_HOVER: {
- offs = 0;
- break;
- }
- default: {
- // Nothing!
- offs = 0;
- break;
- }
+ case MOUSE_LEFT:
+ offs = 1;
+ break;
+ case MOUSE_RIGHT:
+ offs = 2;
+ break;
+ case MOUSE_HOVER:
+ offs = 0;
+ break;
+ default:
+ // Nothing!
+ offs = 0;
+ break;
}
setIcon(0, 208, 150, offs, 0, true);
@@ -1935,15 +1920,12 @@ void setMainScreenScale(int x, int y) {
SUB_BG3_YDX = 0;
SUB_BG3_YDY = y;
} else*/ {
- if (isCpuScalerEnabled() && (x==320))
- {
+ if (isCpuScalerEnabled() && (x==320)) {
BG3_XDX = 256;
BG3_XDY = 0;
BG3_YDX = 0;
BG3_YDY = y;
- }
- else
- {
+ } else {
BG3_XDX = x;
BG3_XDY = 0;
BG3_YDX = 0;
@@ -2030,8 +2012,6 @@ void VBlankHandler(void) {
soundUpdate();
-
-
if ((!gameScreenSwap) && (!(getKeysHeld() & KEY_L) && !(getKeysHeld() & KEY_R))) {
if (s_currentGame) {
if (s_currentGame->control != CONT_SCUMM_SAMNMAX) {
@@ -2607,9 +2587,6 @@ void penUpdate() {
}
}
- else
- {
- }
} else {
penDown = true;
diff --git a/backends/platform/ds/arm9/source/dsoptions.cpp b/backends/platform/ds/arm9/source/dsoptions.cpp
index 32b37abfbc..cc89c41017 100644
--- a/backends/platform/ds/arm9/source/dsoptions.cpp
+++ b/backends/platform/ds/arm9/source/dsoptions.cpp
@@ -423,7 +423,7 @@ void setOptions() {
DS::setTrackPadStyleEnable(enable);
- if ((enable) and (firstLoad)) {
+ if (enable && firstLoad) {
// If we've just booted up, want to swap screens when trackpad mode is in use
// but not every time we enter the options dialog.
DS::setGameScreenSwap(true);
diff --git a/backends/platform/ds/arm9/source/keys.cpp b/backends/platform/ds/arm9/source/keys.cpp
index 8c97b02716..2f8497ab19 100644
--- a/backends/platform/ds/arm9/source/keys.cpp
+++ b/backends/platform/ds/arm9/source/keys.cpp
@@ -74,7 +74,6 @@
#include <nds/system.h>
#include <nds/arm9/input.h>
-//------------------------------------------------------------------------------
#define KEYS_CUR (( ((~REG_KEYINPUT)&0x3ff) | (((~IPC->buttons)&3)<<10) | (((~IPC->buttons)<<6) & (KEY_TOUCH|KEY_LID) ))^KEY_LID)
@@ -89,61 +88,47 @@ static u8 delay = 60, repeat = 30, count = 60;
static uint16 oldx = 0;
static uint16 oldy = 0;
-//------------------------------------------------------------------------------
void scanKeys(void) {
-//------------------------------------------------------------------------------
keysold = keys;
keys = KEYS_CUR;
oldx = IPC->touchXpx;
oldy = IPC->touchYpx;
- if ( delay != 0 ) {
- if ( keys != keysold ) {
- count = delay ;
- keysrepeat = keysDown() ;
+ if (delay != 0) {
+ if (keys != keysold) {
+ count = delay;
+ keysrepeat = keysDown();
}
count--;
- if ( count == 0 ) {
+ if (count == 0) {
count = repeat;
keysrepeat = keys;
}
}
}
-//------------------------------------------------------------------------------
uint32 keysHeld(void) {
-//------------------------------------------------------------------------------
return keys;
}
-//------------------------------------------------------------------------------
uint32 keysDown(void) {
-//------------------------------------------------------------------------------
return (keys ^ keysold) & keys;
}
-//------------------------------------------------------------------------------
uint32 keysDownRepeat(void) {
-//------------------------------------------------------------------------------
uint32 tmp = keysrepeat;
-
keysrepeat = 0;
-
return tmp;
}
-//------------------------------------------------------------------------------
void keysSetRepeat( u8 setDelay, u8 setRepeat ) {
-//------------------------------------------------------------------------------
- delay = setDelay ;
- repeat = setRepeat ;
- count = delay ;
- keysrepeat = 0 ;
+ delay = setDelay;
+ repeat = setRepeat;
+ count = delay;
+ keysrepeat = 0;
}
-//------------------------------------------------------------------------------
uint32 keysUp(void) {
-//------------------------------------------------------------------------------
return (keys ^ keysold) & (~keys);
}
diff --git a/backends/platform/ds/arm9/source/keys.h b/backends/platform/ds/arm9/source/keys.h
index 0068dfeeb6..8d08014232 100644
--- a/backends/platform/ds/arm9/source/keys.h
+++ b/backends/platform/ds/arm9/source/keys.h
@@ -30,7 +30,7 @@ void scanKeys(void);
uint32 keysHeld(void);
uint32 keysDown(void);
uint32 keysDownRepeat(void);
-void keysSetRepeat( u8 setDelay, u8 setRepeat );
+void keysSetRepeat(u8 setDelay, u8 setRepeat);
uint32 keysUp(void);
} // End of namespace DS
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index d750dfbc07..09617c17b0 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -208,8 +208,7 @@ void OSystem_DS::setPalette(const byte *colors, uint start, uint num) {
}
}
-void OSystem_DS::restoreHardwarePalette()
-{
+void OSystem_DS::restoreHardwarePalette() {
// Set the hardware palette up based on the stored palette
for (int r = 0; r < 255; r++) {
diff --git a/backends/platform/ds/arm9/source/touchkeyboard.cpp b/backends/platform/ds/arm9/source/touchkeyboard.cpp
index 7b5e8c2b52..71f4f93c27 100644
--- a/backends/platform/ds/arm9/source/touchkeyboard.cpp
+++ b/backends/platform/ds/arm9/source/touchkeyboard.cpp
@@ -44,7 +44,7 @@ struct key_data {
#define DS_CAPSLOCK 1
-key_data keys[DS_NUM_KEYS] = {
+static key_data keys[DS_NUM_KEYS] = {
// Key number x y character
// Numbers
@@ -137,27 +137,27 @@ key_data keys[DS_NUM_KEYS] = {
};
-int keyboardX;
-int keyboardY;
+static int keyboardX;
+static int keyboardY;
static int s_mapBase;
static int s_tileBase;
-u16 *baseAddress;
+static u16 *baseAddress;
-bool shiftState;
-bool capsLockState;
+static bool shiftState;
+static bool capsLockState;
-bool closed;
+static bool closed;
-char autoCompleteWord[NUM_WORDS][32];
-int autoCompleteCount;
+static char autoCompleteWord[NUM_WORDS][32];
+static int autoCompleteCount;
-char autoCompleteBuffer[128];
+static char autoCompleteBuffer[128];
-int selectedCompletion = -1;
-int charactersEntered = 0;
-int typingTimeout = 0;
+static int selectedCompletion = -1;
+static int charactersEntered = 0;
+static int typingTimeout = 0;
// Render text onto the tiled screen
@@ -396,8 +396,7 @@ void updateTypeEvents() {
event.type = Common::EVENT_KEYUP;
system->addEvent(event);
- for (int r = 0; r < (int)strlen(autoCompleteBuffer); r++)
- {
+ for (int r = 0; r < (int)strlen(autoCompleteBuffer); r++) {
autoCompleteBuffer[r] = autoCompleteBuffer[r + 1];
}
@@ -405,8 +404,7 @@ void updateTypeEvents() {
}
}
-void createKeyEvent(int keyNum, Common::Event& event)
-{
+void createKeyEvent(int keyNum, Common::Event& event) {
event.kbd.flags = 0;
if ((keys[keyNum].character >= '0') && (keys[keyNum].character <= '9')) {
diff --git a/backends/platform/ds/arm9/source/zipreader.cpp b/backends/platform/ds/arm9/source/zipreader.cpp
index 0906123436..d4f055ee82 100644
--- a/backends/platform/ds/arm9/source/zipreader.cpp
+++ b/backends/platform/ds/arm9/source/zipreader.cpp
@@ -79,7 +79,6 @@ bool ZipFile::restartFile() {
bool more = true;
while (!currentFileInFolder() && more) {
- char name[128];
getFileName(name);
more = skipFile();
}