PSP: Fix whitespace usage and code formatting

svn-id: r46126
This commit is contained in:
Max Horn 2009-11-24 14:18:46 +00:00
parent 7c90d8ff64
commit bfc553081c
4 changed files with 239 additions and 261 deletions

View file

@ -121,10 +121,10 @@ endif
# SDL Libs and Flags
SDLFLAGS := $(shell $(PSPBIN)/sdl-config --cflags)
SDLLIBS := $(shell $(PSPBIN)/sdl-config --libs)
SDLLIBS := $(shell $(PSPBIN)/sdl-config --libs)
# PSP LIBS
PSPLIBS = -lpspvfpu -lpspdebug -lpspgu -lpspge -lpspdisplay -lpspctrl -lpspsdk \
-lpsputility -lpspuser -lpsppower -lpsphprm -lpspsdk -lpsprtc -lpspaudio
-lpsputility -lpspuser -lpsppower -lpsphprm -lpspsdk -lpsprtc -lpspaudio
# Add in PSPSDK includes and libraries.
CXXFLAGS += $(SDLFLAGS)

View file

@ -210,8 +210,7 @@ bool PSPKeyboard::processInput(Common::Event &event, SceCtrlData &pad, bool &use
if (DOWN(PSP_4BUTTONS))
usedInput = true; // Make sure these button presses don't get through
}
else { /* _state == kCornersSelected */
} else { /* _state == kCornersSelected */
// We care about 4 buttons + triggers (for letter selection)
changed = CHANGED(PSP_4BUTTONS | PSP_CTRL_RTRIGGER | PSP_CTRL_LTRIGGER);
@ -226,48 +225,37 @@ bool PSPKeyboard::processInput(Common::Event &event, SceCtrlData &pad, bool &use
if (UNPRESSED(PSP_CTRL_TRIANGLE)) {
innerChoice = 0;
event.type = Common::EVENT_KEYUP; // We give priority to key_up
}
else if (UNPRESSED(PSP_CTRL_CIRCLE)) {
} else if (UNPRESSED(PSP_CTRL_CIRCLE)) {
innerChoice = 1;
event.type = Common::EVENT_KEYUP; // We give priority to key_up
}
else if (UNPRESSED(PSP_CTRL_CROSS)) {
} else if (UNPRESSED(PSP_CTRL_CROSS)) {
innerChoice = 2;
event.type = Common::EVENT_KEYUP; // We give priority to key_up
}
else if (UNPRESSED(PSP_CTRL_SQUARE)) {
} else if (UNPRESSED(PSP_CTRL_SQUARE)) {
innerChoice = 3;
event.type = Common::EVENT_KEYUP; // We give priority to key_up
}
else if (UNPRESSED(PSP_CTRL_LTRIGGER) && _state == kCornersSelected) {
} else if (UNPRESSED(PSP_CTRL_LTRIGGER) && _state == kCornersSelected) {
innerChoice = 4;
event.type = Common::EVENT_KEYUP; // We give priority to key_up
}
else if (UNPRESSED(PSP_CTRL_RTRIGGER) && _state == kCornersSelected) {
} else if (UNPRESSED(PSP_CTRL_RTRIGGER) && _state == kCornersSelected) {
innerChoice = 5;
event.type = Common::EVENT_KEYUP; // We give priority to key_up
}
else if (PRESSED(PSP_CTRL_TRIANGLE)) {
} else if (PRESSED(PSP_CTRL_TRIANGLE)) {
innerChoice = 0;
event.type = Common::EVENT_KEYDOWN;
}
else if (PRESSED(PSP_CTRL_CIRCLE)) {
} else if (PRESSED(PSP_CTRL_CIRCLE)) {
innerChoice = 1;
event.type = Common::EVENT_KEYDOWN;
}
else if (PRESSED(PSP_CTRL_CROSS)) {
} else if (PRESSED(PSP_CTRL_CROSS)) {
innerChoice = 2;
event.type = Common::EVENT_KEYDOWN;
}
else if (PRESSED(PSP_CTRL_SQUARE)) {
} else if (PRESSED(PSP_CTRL_SQUARE)) {
innerChoice = 3;
event.type = Common::EVENT_KEYDOWN;
}
else if (PRESSED(PSP_CTRL_LTRIGGER) && _state == kCornersSelected) {
} else if (PRESSED(PSP_CTRL_LTRIGGER) && _state == kCornersSelected) {
innerChoice = 4;
event.type = Common::EVENT_KEYDOWN; // We give priority to key_up
}
else /* (UNPRESSED(PSP_CTRL_RTRIGGER)) && _state == kCornersSelected */ {
} else /* (UNPRESSED(PSP_CTRL_RTRIGGER)) && _state == kCornersSelected */ {
innerChoice = 5;
event.type = Common::EVENT_KEYDOWN; // We give priority to key_up
}
@ -284,8 +272,7 @@ bool PSPKeyboard::processInput(Common::Event &event, SceCtrlData &pad, bool &use
if (IS_UPPERCASE(choice)) {
event.kbd.keycode = (Common::KeyCode) TO_LOWER(choice);
event.kbd.flags = Common::KBD_SHIFT;
}
else
} else
event.kbd.keycode = (Common::KeyCode) choice;
haveEvent = (choice != Common::KEYCODE_INVALID) ? true : false; // We have an event/don't if it's invalid
@ -335,7 +322,7 @@ bool PSPKeyboard::processInput(Common::Event &event, SceCtrlData &pad, bool &use
if (_state == kRTriggerDown) {
usedInput = true;
if (UNPRESSED(PSP_CTRL_RTRIGGER)) {
if (UNPRESSED(PSP_CTRL_RTRIGGER)) {
_dirty = true;
if(_mode > 1)
@ -348,11 +335,10 @@ bool PSPKeyboard::processInput(Common::Event &event, SceCtrlData &pad, bool &use
goto END;
}
}
else if (_state == kLTriggerDown) {
} else if (_state == kLTriggerDown) {
usedInput = true;
if (UNPRESSED(PSP_CTRL_LTRIGGER)) {
if (UNPRESSED(PSP_CTRL_LTRIGGER)) {
_dirty = true;
if(_mode < 2)
@ -396,26 +382,26 @@ void PSPKeyboard::render() {
int x, y;
switch(_oldCursor) {
case kUp:
x = 1;
y = 0;
break;
case kRight:
x = 2;
y = 1;
break;
case kDown:
x = 1;
y = 2;
break;
case kLeft:
x = 0;
y = 1;
break;
default:
x = 1;
y = 1;
break;
case kUp:
x = 1;
y = 0;
break;
case kRight:
x = 2;
y = 1;
break;
case kDown:
x = 1;
y = 2;
break;
case kLeft:
x = 0;
y = 1;
break;
default:
x = 1;
y = 1;
break;
}
// Draw the background letters
@ -548,8 +534,7 @@ bool PSPKeyboard::load() {
fprintf(stderr, "Can't open %s in kbd.zip for keyboard. No keyboard will load.\n", _guiStrings[a]);
goto ERROR;
}
}
else { // Couldn't find the file
} else { // Couldn't find the file
fprintf(stderr, "load(): Can't find %s for keyboard. No keyboard will load.\n", _guiStrings[a]);
goto ERROR;
}
@ -566,12 +551,10 @@ bool PSPKeyboard::load() {
if (paletteSize <= 16) { // 4 bit
paletteSize = 16;
textureSize = (width * height)>>1;
}
else if (paletteSize <= 256){ // 8-bit image
} else if (paletteSize <= 256){ // 8-bit image
paletteSize = 256;
textureSize = width * height;
}
else {
} else {
fprintf(stderr, "Error: palette of %d too big!\n", paletteSize);
goto ERROR;
}
@ -581,8 +564,7 @@ bool PSPKeyboard::load() {
temp_texture = (u8 *)malloc(textureSize);
temp_palette = (uint32 *)memalign(16, paletteSize<<2);
memset(temp_palette, 0, paletteSize<<2); // Set to 0 since we might only fill some of it
}
else { // 32-bit image
} else { // 32-bit image
temp_texture = (unsigned char *)malloc((width * height)<<2);
}
@ -615,7 +597,7 @@ bool PSPKeyboard::load() {
#ifdef PSP_KB_DEBUG
fprintf(stderr, "load(): perm texture width=%d, height=%d, size=%d\n", _keyTextures[a].surface_width, _keyTextures[a].surface_height, size);
#endif
_keyTextures[a].texture = (unsigned char *)memalign(16, size); // Allocate memory
_keyTextures[a].texture = (unsigned char *)memalign(16, size); // Allocate memory
block_copy(&_keyTextures[a], temp_texture); // Copy temp texture to permanent texture
@ -624,7 +606,7 @@ bool PSPKeyboard::load() {
free(temp_texture);
delete(file);
delete file;
}
}
else
@ -632,29 +614,26 @@ bool PSPKeyboard::load() {
} /* for loop */
_init = true;
delete(fileArchive);
delete(zipArchive);
delete fileArchive;
delete zipArchive;
return true;
ERROR:
{
// Error .. Couldn't get png info from one of the needed files
free(temp_texture);
delete(file);
delete(fileArchive);
delete(zipArchive);
// Error .. Couldn't get png info from one of the needed files
free(temp_texture);
delete file;
delete fileArchive;
delete zipArchive;
for (int b = 0; b < a; b++)
{
free(_keyTextures[b].texture);
free(_keyTextures[b].palette);
_keyTextures[b].texture = NULL;
}
_init = false;
return false;
for (int b = 0; b < a; b++) {
free(_keyTextures[b].texture);
free(_keyTextures[b].palette);
_keyTextures[b].texture = NULL;
}
_init = false;
return false;
}
// Copy texture from regular size image to power of 2 size image
@ -663,27 +642,27 @@ void PSPKeyboard::block_copy(gu_surface* surface, u8 *texture) {
u32 stride = 0, width = 0;
switch(surface->paletteSize) {
case 16: // 4-bit
width = surface->texture_width >> 1;
stride = (surface->surface_width - surface->texture_width)>>1;
break;
case 256: // 8-bit
width = surface->texture_width;
stride = surface->surface_width - surface->texture_width;
break;
case 0: // 32-bit
width = surface->texture_width << 2;
stride = (surface->surface_width - surface->texture_width)<<2;
break;
default:
fprintf(stderr, "Error in block_copy: bad value in paletteSize = %d\n", surface->paletteSize);
return;
case 16: // 4-bit
width = surface->texture_width >> 1;
stride = (surface->surface_width - surface->texture_width)>>1;
break;
case 256: // 8-bit
width = surface->texture_width;
stride = surface->surface_width - surface->texture_width;
break;
case 0: // 32-bit
width = surface->texture_width << 2;
stride = (surface->surface_width - surface->texture_width)<<2;
break;
default:
fprintf(stderr, "Error in block_copy: bad value in paletteSize = %d\n", surface->paletteSize);
return;
}
u8 *src = texture;
u8 *dest = surface->texture;
for (unsigned int y = 0 ; y < surface->texture_height ; y++) {
for (unsigned int y = 0; y < surface->texture_height; y++) {
memcpy(dest, src, width);
dest += width;
src += width;
@ -700,7 +679,7 @@ void PSPKeyboard::block_copy(gu_surface* surface, u8 *texture) {
void PSPKeyboard::flipNibbles(gu_surface* surface) {
u32 *dest = (u32 *)surface->texture;
for (u32 y = 0 ; y < surface->texture_height ; y++) {
for (u32 y = 0; y < surface->texture_height; y++) {
for (u32 x = 0; x < (surface->surface_width >> 3); x++) {
u32 val = *dest;
*dest++ = ((val >> 4) & 0x0F0F0F0F) | ((val << 4) & 0xF0F0F0F0);
@ -821,8 +800,7 @@ int PSPKeyboard::load_png_image(Common::SeekableReadStream *file, unsigned char
u32* Image = (u32 *)ImageBuffer;
for (y = 0; y < height; y++) {
png_read_row(png_ptr, (u8*) line, png_bytep_NULL);
for (x = 0; x < width; x++)
{
for (x = 0; x < width; x++) {
Image[y*width + x] = line[x];
}
}
@ -841,9 +819,9 @@ int PSPKeyboard::load_png_image(Common::SeekableReadStream *file, unsigned char
uint32 PSPKeyboard::convert_pow2(uint32 size) {
uint32 pow_counter = 0;
for ( ; pow_counter < 32 ; pow_counter++) {
for (; pow_counter < 32; pow_counter++) {
// Find the first value which is higher
if ((size >> pow_counter) == 0) {
if ((size >> pow_counter) == 0) {
// take already good values into account
if (((uint32) 1 << pow_counter) != size)
return ((uint32)1 << pow_counter);