BADA: Misc changes merged from appstore release

This commit is contained in:
Chris Warren-Smith 2011-10-17 22:35:48 +10:00
parent ca7bc71846
commit ed07b99b22
13 changed files with 145 additions and 151 deletions

View File

@ -83,3 +83,10 @@ Links:
A short turorial on implementing OpenGL ES 1.1 in BADA:
http://forums.badadev.com/viewtopic.php?f=7&t=208
HelvB14 font files:
http://www.cl.cam.ac.uk/~mgk25/ucs-fonts.html
http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts-75dpi100dpi.tar.gz
Then run the following command:
$ ./ucs2any.pl 100dpi/helvB14.bdf MAPPINGS/8859-1.TXT iso8859-1 \
MAPPINGS/8859-2.TXT iso8859-2 MAPPINGS/8859-3.TXT iso8859-3

View File

@ -99,11 +99,13 @@ void BadaScummVM::OnLowMemory(void) {
}
void BadaScummVM::pauseGame(bool pause) {
if (pause && _appForm && g_engine && !g_engine->isPaused()) {
_appForm->pushKey(Common::KEYCODE_SPACE);
}
if (g_system) {
((BadaSystem *)g_system)->setMute(pause);
if (_appForm) {
if (pause && g_engine && !g_engine->isPaused()) {
_appForm->pushKey(Common::KEYCODE_SPACE);
}
if (g_system) {
((BadaSystem *)g_system)->setMute(pause);
}
}
}

View File

@ -74,7 +74,7 @@ bool AudioThread::isSilentMode() {
}
void AudioThread::setMute(bool on) {
if (_audioOut && !isSilentMode()) {
if (_audioOut && _timer) {
_muted = on;
if (on) {
_timer->Cancel();
@ -88,7 +88,7 @@ int AudioThread::setVolume(bool up, bool minMax) {
int level = -1;
int numLevels = sizeof(levels) / sizeof(levels[0]);
if (_audioOut && !isSilentMode()) {
if (_audioOut) {
int volume = _audioOut->GetVolume();
if (minMax) {
level = up ? numLevels - 1 : 0;

View File

@ -49,9 +49,9 @@ using namespace Osp::Ui::Controls;
//
BadaAppForm::BadaAppForm() :
_gameThread(0),
_state(InitState),
_buttonState(LeftButton),
_shortcut(SetVolume) {
_state(kInitState),
_buttonState(kLeftButton),
_shortcut(kSetVolume) {
_eventQueueLock = new Mutex();
_eventQueueLock->Create();
}
@ -99,11 +99,11 @@ result BadaAppForm::Construct() {
BadaAppForm::~BadaAppForm() {
logEntered();
if (_gameThread && _state != ErrorState) {
if (_gameThread && _state != kErrorState) {
terminate();
_gameThread->Stop();
if (_state != ErrorState) {
if (_state != kErrorState) {
_gameThread->Join();
}
@ -123,7 +123,7 @@ BadaAppForm::~BadaAppForm() {
// abort the game thread
//
void BadaAppForm::terminate() {
if (_state == ActiveState) {
if (_state == kActiveState) {
((BadaSystem *)g_system)->setMute(true);
_eventQueueLock->Acquire();
@ -131,25 +131,25 @@ void BadaAppForm::terminate() {
Common::Event e;
e.type = Common::EVENT_QUIT;
_eventQueue.push(e);
_state = ClosingState;
_state = kClosingState;
_eventQueueLock->Release();
// block while thread ends
AppLog("waiting for shutdown");
for (int i = 0; i < EXIT_SLEEP_STEP && _state == ClosingState; i++) {
for (int i = 0; i < EXIT_SLEEP_STEP && _state == kClosingState; i++) {
Thread::Sleep(EXIT_SLEEP);
}
if (_state == ClosingState) {
if (_state == kClosingState) {
// failed to terminate - Join() will freeze
_state = ErrorState;
_state = kErrorState;
}
}
}
void BadaAppForm::exitSystem() {
_state = ErrorState;
_state = kErrorState;
if (_gameThread) {
_gameThread->Stop();
@ -200,8 +200,7 @@ bool BadaAppForm::pollEvent(Common::Event &event) {
return result;
}
void BadaAppForm::pushEvent(Common::EventType type,
const Point &currentPosition) {
void BadaAppForm::pushEvent(Common::EventType type, const Point &currentPosition) {
BadaSystem *system = (BadaSystem *)g_system;
BadaGraphicsManager *graphics = system->getGraphics();
if (graphics) {
@ -248,8 +247,8 @@ void BadaAppForm::pushKey(Common::KeyCode keycode) {
void BadaAppForm::OnOrientationChanged(const Control &source,
OrientationStatus orientationStatus) {
logEntered();
if (_state == InitState) {
_state = ActiveState;
if (_state == kInitState) {
_state = kActiveState;
_gameThread->Start();
}
}
@ -257,30 +256,30 @@ void BadaAppForm::OnOrientationChanged(const Control &source,
Object *BadaAppForm::Run(void) {
scummvm_main(0, 0);
if (_state == ActiveState) {
if (_state == kActiveState) {
Application::GetInstance()->SendUserEvent(USER_MESSAGE_EXIT, NULL);
}
_state = DoneState;
_state = kDoneState;
return NULL;
}
void BadaAppForm::setButtonShortcut() {
switch (_buttonState) {
case LeftButton:
case kLeftButton:
g_system->displayMessageOnOSD(_("Right Click Once"));
_buttonState = RightButtonOnce;
_buttonState = kRightButtonOnce;
break;
case RightButtonOnce:
case kRightButtonOnce:
g_system->displayMessageOnOSD(_("Right Click"));
_buttonState = RightButton;
_buttonState = kRightButton;
break;
case RightButton:
case kRightButton:
g_system->displayMessageOnOSD(_("Move Only"));
_buttonState = MoveOnly;
_buttonState = kMoveOnly;
break;
case MoveOnly:
case kMoveOnly:
g_system->displayMessageOnOSD(_("Left Click"));
_buttonState = LeftButton;
_buttonState = kLeftButton;
break;
}
}
@ -288,27 +287,27 @@ void BadaAppForm::setButtonShortcut() {
void BadaAppForm::setShortcut() {
// cycle to the next shortcut
switch (_shortcut) {
case ControlMouse:
case kControlMouse:
g_system->displayMessageOnOSD(_("Escape Key"));
_shortcut = EscapeKey;
_shortcut = kEscapeKey;
break;
case EscapeKey:
case kEscapeKey:
g_system->displayMessageOnOSD(_("Game Menu"));
_shortcut = GameMenu;
_shortcut = kGameMenu;
break;
case GameMenu:
case kGameMenu:
g_system->displayMessageOnOSD(_("Show Keypad"));
_shortcut = ShowKeypad;
_shortcut = kShowKeypad;
break;
case SetVolume:
case kSetVolume:
// fallthru
case ShowKeypad:
case kShowKeypad:
g_system->displayMessageOnOSD(_("Control Mouse"));
_shortcut = ControlMouse;
_shortcut = kControlMouse;
break;
}
}
@ -330,17 +329,17 @@ void BadaAppForm::setVolume(bool up, bool minMax) {
void BadaAppForm::showKeypad() {
// display the soft keyboard
_buttonState = LeftButton;
_buttonState = kLeftButton;
pushKey(Common::KEYCODE_F7);
}
void BadaAppForm::OnTouchDoublePressed(const Control &source,
const Point &currentPosition,
const TouchEventInfo &touchInfo) {
if (_buttonState != MoveOnly) {
pushEvent(_buttonState == LeftButton ? Common::EVENT_LBUTTONDOWN : Common::EVENT_RBUTTONDOWN,
if (_buttonState != kMoveOnly) {
pushEvent(_buttonState == kLeftButton ? Common::EVENT_LBUTTONDOWN : Common::EVENT_RBUTTONDOWN,
currentPosition);
pushEvent(_buttonState == LeftButton ? Common::EVENT_LBUTTONDOWN : Common::EVENT_RBUTTONDOWN,
pushEvent(_buttonState == kLeftButton ? Common::EVENT_LBUTTONDOWN : Common::EVENT_RBUTTONDOWN,
currentPosition);
}
}
@ -358,7 +357,7 @@ void BadaAppForm::OnTouchFocusOut(const Control &source,
void BadaAppForm::OnTouchLongPressed(const Control &source,
const Point &currentPosition,
const TouchEventInfo &touchInfo) {
if (_buttonState != LeftButton) {
if (_buttonState != kLeftButton) {
pushKey(Common::KEYCODE_RETURN);
}
}
@ -372,8 +371,8 @@ void BadaAppForm::OnTouchMoved(const Control &source,
void BadaAppForm::OnTouchPressed(const Control &source,
const Point &currentPosition,
const TouchEventInfo &touchInfo) {
if (_buttonState != MoveOnly) {
pushEvent(_buttonState == LeftButton ? Common::EVENT_LBUTTONDOWN : Common::EVENT_RBUTTONDOWN,
if (_buttonState != kMoveOnly) {
pushEvent(_buttonState == kLeftButton ? Common::EVENT_LBUTTONDOWN : Common::EVENT_RBUTTONDOWN,
currentPosition);
}
}
@ -381,11 +380,11 @@ void BadaAppForm::OnTouchPressed(const Control &source,
void BadaAppForm::OnTouchReleased(const Control &source,
const Point &currentPosition,
const TouchEventInfo &touchInfo) {
if (_buttonState != MoveOnly) {
pushEvent(_buttonState == LeftButton ? Common::EVENT_LBUTTONUP : Common::EVENT_RBUTTONUP,
if (_buttonState != kMoveOnly) {
pushEvent(_buttonState == kLeftButton ? Common::EVENT_LBUTTONUP : Common::EVENT_RBUTTONUP,
currentPosition);
if (_buttonState == RightButtonOnce) {
_buttonState = LeftButton;
if (_buttonState == kRightButtonOnce) {
_buttonState = kLeftButton;
}
// flick to skip dialog
if (touchInfo.IsFlicked()) {
@ -398,17 +397,17 @@ void BadaAppForm::OnKeyLongPressed(const Control &source, KeyCode keyCode) {
logEntered();
switch (keyCode) {
case KEY_SIDE_UP:
_shortcut = SetVolume;
_shortcut = kSetVolume;
setVolume(true, true);
return;
case KEY_SIDE_DOWN:
_shortcut = SetVolume;
_shortcut = kSetVolume;
setVolume(false, true);
return;
case KEY_CAMERA:
_shortcut = ShowKeypad;
_shortcut = kShowKeypad;
showKeypad();
return;
@ -420,8 +419,8 @@ void BadaAppForm::OnKeyLongPressed(const Control &source, KeyCode keyCode) {
void BadaAppForm::OnKeyPressed(const Control &source, KeyCode keyCode) {
switch (keyCode) {
case KEY_SIDE_UP:
if (_shortcut != SetVolume) {
_shortcut = SetVolume;
if (_shortcut != kSetVolume) {
_shortcut = kSetVolume;
} else {
setVolume(true, false);
}
@ -429,19 +428,20 @@ void BadaAppForm::OnKeyPressed(const Control &source, KeyCode keyCode) {
case KEY_SIDE_DOWN:
switch (_shortcut) {
case ControlMouse:
case kControlMouse:
setButtonShortcut();
break;
case EscapeKey:
case kEscapeKey:
pushKey(Common::KEYCODE_ESCAPE);
break;
case GameMenu:
case kGameMenu:
_buttonState = kLeftButton;
pushKey(Common::KEYCODE_F5);
break;
case ShowKeypad:
case kShowKeypad:
showKeypad();
break;

View File

@ -50,7 +50,7 @@ public:
result Construct();
bool pollEvent(Common::Event &event);
bool isClosing() { return _state == ClosingState; }
bool isClosing() { return _state == kClosingState; }
void pushKey(Common::KeyCode keycode);
void exitSystem();
@ -100,9 +100,9 @@ private:
Osp::Base::Runtime::Thread *_gameThread;
Osp::Base::Runtime::Mutex *_eventQueueLock;
Common::Queue<Common::Event> _eventQueue;
enum {InitState, ActiveState, ClosingState, DoneState, ErrorState} _state;
enum {LeftButton, RightButtonOnce, RightButton, MoveOnly} _buttonState;
enum {ControlMouse, EscapeKey, GameMenu, ShowKeypad, SetVolume} _shortcut;
enum { kInitState, kActiveState, kClosingState, kDoneState, kErrorState } _state;
enum { kLeftButton, kRightButtonOnce, kRightButton, kMoveOnly } _buttonState;
enum { kControlMouse, kEscapeKey, kGameMenu, kShowKeypad, kSetVolume } _shortcut;
};
#endif

View File

@ -345,7 +345,7 @@ bool BadaFilesystemNode::getChildren(AbstractFSList &myList,
// open directory
if (IsFailed(pDir->Construct(_unicodePath))) {
AppLog("Failed to open directory");
AppLog("Failed to open directory: %S", _unicodePath.GetPointer());
} else {
// read all directory entries
pDirEnum = pDir->ReadN();
@ -365,8 +365,7 @@ bool BadaFilesystemNode::getChildren(AbstractFSList &myList,
}
// skip '.' and '..' to avoid cycles
if ((fileName[0] == '.' && fileName[1] == 0) ||
(fileName[0] == '.' && fileName[1] == '.')) {
if (fileName == L"." || fileName == L"..") {
continue;
}

View File

@ -38,7 +38,6 @@ BadaGraphicsManager::BadaGraphicsManager(BadaAppForm *appForm) :
_initState(true) {
assert(appForm != NULL);
_videoMode.fullscreen = true;
_videoMode.antialiasing = true;
}
const Graphics::Font *BadaGraphicsManager::getFontOSD() {
@ -195,7 +194,6 @@ void BadaGraphicsManager::loadTextures() {
// prevent image skew in some games, see:
// http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall
// note: this did not solve the pixel border problem in refreshGameScreen()
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
}
@ -234,58 +232,6 @@ void BadaGraphicsManager::unloadGFXMode() {
logLeaving();
}
void BadaGraphicsManager::refreshGameScreen() {
if (_screenNeedsRedraw)
_screenDirtyRect = Common::Rect(0, 0, _screenData.w, _screenData.h);
int x = _screenDirtyRect.left;
int y = _screenDirtyRect.top;
int w = _screenDirtyRect.width();
int h = _screenDirtyRect.height();
if (_screenData.format.bytesPerPixel == 1) {
// Create a temporary RGB888 surface
int sw = w;
int sh = h;
if (_videoMode.screenWidth == w && _videoMode.screenHeight == h) {
// The extra border prevents random pixels from appearing in the right and bottom
// screen column/row. Not sure whether this should be applied to opengl-graphics.cpp
sw = w + 1;
sh = h + 1;
}
byte *surface = new byte[sw * sh * 3];
// Convert the paletted buffer to RGB888
const byte *src = (byte *)_screenData.pixels + y * _screenData.pitch;
src += x * _screenData.format.bytesPerPixel;
byte *dst = surface;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
dst[0] = _gamePalette[src[j] * 3];
dst[1] = _gamePalette[src[j] * 3 + 1];
dst[2] = _gamePalette[src[j] * 3 + 2];
dst += 3;
}
src += _screenData.pitch;
}
// Update the texture
_gameTexture->updateBuffer(surface, w * 3, x, y, sw, sh);
// Free the temp surface
delete[] surface;
} else {
// Update the texture
_gameTexture->updateBuffer((byte *)_screenData.pixels + y * _screenData.pitch +
x * _screenData.format.bytesPerPixel, _screenData.pitch, x, y, w, h);
}
_screenNeedsRedraw = false;
_screenDirtyRect = Common::Rect();
}
// display a simple splash screen until launcher is ready
void BadaGraphicsManager::showSplash() {
Canvas canvas;

View File

@ -57,7 +57,6 @@ private:
bool loadGFXMode();
void loadTextures();
void unloadGFXMode();
void refreshGameScreen();
void setInternalMousePosition(int x, int y) {}
void showSplash();

View File

@ -31,17 +31,32 @@
//
bool scanInt(const char **in, va_list *ap, int max) {
while (**in && (**in == ' ' || **in == '0')) {
// skip leading space characters
while (**in && **in == ' ') {
(*in)++;
}
// number optionally preceeded with a + or - sign.
bool negate = false;
if (**in == '-') {
(*in)++;
negate = true;
}
if (**in == '+') {
(*in)++;
}
int *arg = va_arg(*ap, int*);
char *end;
long n = strtol(*in, &end, 0);
long n = strtol(*in, &end, 10);
if (negate) {
n = -n;
}
bool err = false;
if (end == *in || (max > 0 && (end - *in) > max)) {
err = true;
err = true;
} else {
*arg = (int)n;
*in = end;
@ -162,21 +177,37 @@ extern "C" int simple_sscanf(const char *input, const char *format, ...) {
#if defined(TEST)
int main(int argc, char *pArgv[]) {
int x,y,h;
int x,y,xx,yy,h;
char buffer[100];
unsigned u;
char c;
strcpy(buffer, "hello");
char *b = buffer;
// strcpy(buffer, "in the buffer something");
if (simple_sscanf("CAT 123x-10 0x100 FONT large 1 enough\n 123456.AUD $",
"CAT %dx%d %x FONT %[^\n] %06u.AUD %c",
&x, &y, &h, b, &u, &c) != 6) {
if (simple_sscanf("BBX 00009 -1 +10 000",
"BBX %d %d %d %d",
&x, &y, &xx, &yy) != 4) {
printf("Failed\n");
} else {
printf("Success %d %d %d %s %d '%c'\n", x, y, h, buffer, u, c);
printf("Success %d %d %d %d\n", x, y, xx, yy);
}
if (simple_sscanf("CAT 123x-10 0x100h 123456.AUD $ ",
"CAT %dx%d %xh %06u.AUD %c",
&x, &y, &h, &u, &c) != 5) {
printf("Failed\n");
} else {
printf("Success %d %d %d %d '%c' \n", x, y, h, u, c);
}
if (simple_sscanf("COPYRIGHT \"Copyright (c) 1984, 1987 Foo Systems Incorporated",
"COPYRIGHT \"%[^\"]",
b) != 1) {
printf("Failed\n");
} else {
printf("Success %s\n", buffer);
}
return 0;
}
#endif

View File

@ -45,6 +45,7 @@ using namespace Osp::Base::Runtime;
using namespace Osp::Ui::Controls;
#define DEFAULT_CONFIG_FILE "/Home/scummvm.ini"
#define RESOURCE_PATH "/Res"
#define MUTEX_BUFFER_SIZE 5
//
@ -152,17 +153,17 @@ OSystem::MutexRef BadaMutexManager::createMutex() {
}
void BadaMutexManager::lockMutex(OSystem::MutexRef mutex) {
Mutex *m = (Mutex*)mutex;
Mutex *m = (Mutex *)mutex;
m->Acquire();
}
void BadaMutexManager::unlockMutex(OSystem::MutexRef mutex) {
Mutex *m = (Mutex*)mutex;
Mutex *m = (Mutex *)mutex;
m->Release();
}
void BadaMutexManager::deleteMutex(OSystem::MutexRef mutex) {
Mutex *m = (Mutex*)mutex;
Mutex *m = (Mutex *)mutex;
for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) {
if (buffer[i] == m) {
@ -245,7 +246,7 @@ result BadaSystem::initModules() {
return E_OUT_OF_MEMORY;
}
_graphicsManager = (GraphicsManager*) new BadaGraphicsManager(_appForm);
_graphicsManager = (GraphicsManager *)new BadaGraphicsManager(_appForm);
if (!_graphicsManager) {
return E_OUT_OF_MEMORY;
}
@ -266,7 +267,7 @@ result BadaSystem::initModules() {
return E_OUT_OF_MEMORY;
}
_audiocdManager = (AudioCDManager*) new DefaultAudioCDManager();
_audiocdManager = (AudioCDManager *)new DefaultAudioCDManager();
if (!_audiocdManager) {
return E_OUT_OF_MEMORY;
}
@ -283,9 +284,6 @@ result BadaSystem::initModules() {
void BadaSystem::initBackend() {
logEntered();
// allow translations and game .DAT files to be found
ConfMan.set("extrapath", "/Res");
// use the mobile device theme
ConfMan.set("gui_theme", "/Res/scummmobile");
@ -304,7 +302,7 @@ void BadaSystem::initBackend() {
}
ConfMan.registerDefault("fullscreen", true);
ConfMan.registerDefault("aspect_ratio", true);
ConfMan.registerDefault("aspect_ratio", false);
ConfMan.setBool("confirm_exit", false);
Osp::System::SystemTime::GetTicks(_epoch);
@ -317,7 +315,7 @@ void BadaSystem::initBackend() {
// replace kBigGUIFont using the large font from the scummmobile theme
Common::File fontFile;
Common::String fileName = "/Res/scummmobile/helvB14-ASCII.fcc";
Common::String fileName = "/Res/scummmobile/helvB14-iso-8859-1.fcc";
BadaFilesystemNode file(fileName);
if (file.exists()) {
Common::SeekableReadStream *stream = file.createReadStream();
@ -335,6 +333,11 @@ void BadaSystem::initBackend() {
logLeaving();
}
void BadaSystem::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
// allow translations.dat and game .DAT files to be found
s.addDirectory(RESOURCE_PATH, RESOURCE_PATH, priority);
}
void BadaSystem::destroyBackend() {
closeAudio();
@ -446,8 +449,12 @@ void BadaSystem::closeGraphics() {
}
void BadaSystem::setMute(bool on) {
// only change mute after eventManager init() has completed
if (_audioThread) {
_audioThread->setMute(on);
BadaGraphicsManager *graphics = getGraphics();
if (graphics && graphics->isReady()) {
_audioThread->setMute(on);
}
}
}

View File

@ -74,7 +74,7 @@ public:
bool isClosing() { return _appForm->isClosing(); }
BadaGraphicsManager *getGraphics() {
return (BadaGraphicsManager*)_graphicsManager;
return (BadaGraphicsManager *)_graphicsManager;
}
private:
@ -88,8 +88,9 @@ private:
void getTimeAndDate(TimeDate &t) const;
void fatalError();
void logMessage(LogMessageType::Type type, const char *message);
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
Common::EventSource *getDefaultEventSource() {return this;}
Common::EventSource *getDefaultEventSource() { return this; }
Common::SeekableReadStream *createConfigReadStream();
Common::WriteStream *createConfigWriteStream();

View File

@ -99,11 +99,13 @@ void SmushChannel::processBuffer() {
byte *old = _tbuffer;
int32 new_size = _tbufferSize - offset;
_tbuffer = (byte *)malloc(new_size);
// FIXME: _tbuffer might be 0 if new_size is 0.
// NB: Also check other "if (_tbuffer)" locations in smush
if (!_tbuffer)
error("smush channel failed to allocate memory");
memcpy(_tbuffer, old + offset, new_size);
if (!_tbuffer) {
if (new_size)
error("smush channel failed to allocate memory");
} else {
memcpy(_tbuffer, old + offset, new_size);
}
_tbufferSize = new_size;
free(old);
}

View File

@ -590,7 +590,7 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &file) {
#ifdef USE_TRANSLATION
TransMan.setLanguage("C");
#endif
warning("Failed to load localized font '%s'. Using non-localized font and default GUI language instead", file.c_str());
warning("Failed to load localized font '%s'. Using non-localized font and default GUI language instead", localized.c_str());
}
}
}