DS: More formating, made more vars static

svn-id: r50708
This commit is contained in:
Max Horn 2010-07-05 20:36:11 +00:00
parent cffcc3d936
commit 429de8f6ef
9 changed files with 98 additions and 174 deletions

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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);
}

View file

@ -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

View file

@ -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++) {

View file

@ -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')) {

View file

@ -79,7 +79,6 @@ bool ZipFile::restartFile() {
bool more = true;
while (!currentFileInFolder() && more) {
char name[128];
getFileName(name);
more = skipFile();
}