[Scummvm-cvs-logs] CVS: scummvm/wince findgame.cpp,1.3,1.4 pocketpc.cpp,1.12,1.13
Nicolas Bacca
arisme at users.sourceforge.net
Sun Apr 21 14:56:06 CEST 2002
Update of /cvsroot/scummvm/scummvm/wince
In directory usw-pr-cvs1:/tmp/cvs-serv4508
Modified Files:
findgame.cpp pocketpc.cpp
Log Message:
Fixed events, cursor, registry and hardware keys support, added new scan method for easier program install
Index: findgame.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/wince/findgame.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** findgame.cpp 15 Mar 2002 00:37:20 -0000 1.3
--- findgame.cpp 21 Apr 2002 21:55:48 -0000 1.4
***************
*** 4,8 ****
#include "stdafx.h"
! #include <Winuser.h>
#include <Winnls.h>
#include "resource.h"
--- 4,8 ----
#include "stdafx.h"
! #include <Winuser.h>
#include <Winnls.h>
#include "resource.h"
***************
*** 26,29 ****
--- 26,43 ----
static const ScummGame GameList[] = {
+ {
+ "Simon The Sorcerer 1 (win)",
+ "To be tested",
+ "", "SIMON.GME", "GAMEPC",
+ "simon1win",
+ 0
+ },
+ {
+ "Simon The Sorcerer 2 (win)",
+ "To be tested",
+ "", "SIMON2.GME", "GSPTR30",
+ "simon2win",
+ 0
+ },
{
"Indiana Jones 3 (new)",
***************
*** 56,60 ****
{
"Loom (VGA)",
! "Buggy, playable a bit",
"loomcd", "", "",
"loomcd",
--- 70,74 ----
{
"Loom (VGA)",
! "Completable",
"loomcd", "", "",
"loomcd",
***************
*** 138,141 ****
--- 152,157 ----
void findGame(TCHAR*);
int displayFoundGames(void);
+ void doScan();
+ void startFindGame();
char gamesFound[MAX_GAMES];
***************
*** 144,147 ****
--- 160,170 ----
int installedGamesNumber;
HWND hwndDlg;
+ TCHAR basePath[MAX_PATH];
+ TCHAR old_basePath[MAX_PATH];
+ BOOL prescanning;
+
+ BOOL isPrescanning() {
+ return prescanning;
+ }
void setFindGameDlgHandle(HWND x) {
***************
*** 157,160 ****
--- 180,185 ----
unsigned char references[MAX_PATH];
+ prescanning = FALSE;
+
if(RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\PocketSCUMM"),
0, NULL, 0, 0, NULL, &hkey, &disposition) == ERROR_SUCCESS) {
***************
*** 180,183 ****
--- 205,214 ----
keyType = REG_SZ;
+ keySize = MAX_PATH;
+ if (RegQueryValueEx(hkey, TEXT("BasePath"), NULL, &keyType, (unsigned char*)basePath, &keySize) != ERROR_SUCCESS) {
+ basePath[0] = '\0';
+ basePath[1] = '\0';
+ }
+
for (i=0; i<index; i++) {
char work[100];
***************
*** 247,253 ****
}
void startFindGame() {
! TCHAR fileName[MAX_PATH];
! TCHAR *tempo;
int i = 0;
int index = 0;
--- 278,369 ----
}
+ void changeScanPath() {
+ int item;
+ TCHAR path[MAX_PATH];
+
+ item = SendMessage(GetDlgItem(hwndDlg, IDC_LISTAVAILABLE), LB_GETCURSEL, 0, 0);
+ if (item == LB_ERR)
+ return;
+
+ SendMessage(GetDlgItem(hwndDlg, IDC_LISTAVAILABLE), LB_GETTEXT, item, (LPARAM)path);
+
+ if (wcscmp(path, TEXT("..")) != 0) {
+ wcscat(basePath, TEXT("\\"));
+ wcscat(basePath, path);
+ }
+ else {
+ TCHAR *work;
+
+ work = wcsrchr(basePath, '\\');
+ *work = 0;
+ *(work + 1) = 0;
+ }
+
+ doScan();
+ }
+
+ void doScan() {
+ WIN32_FIND_DATA desc;
+ TCHAR searchPath[MAX_PATH];
+ HANDLE x;
+
+ SendMessage(GetDlgItem(hwndDlg, IDC_LISTAVAILABLE), LB_RESETCONTENT, 0, 0);
+
+ if (wcslen(basePath) != 0)
+ SendMessage(GetDlgItem(hwndDlg, IDC_LISTAVAILABLE), LB_ADDSTRING, 0, (LPARAM)TEXT(".."));
+
+ wsprintf(searchPath, TEXT("%s\\*"), basePath);
+
+ x = FindFirstFile(searchPath, &desc);
+ if (x == INVALID_HANDLE_VALUE)
+ return;
+ if (desc.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ TCHAR *work;
+
+ work = wcsrchr(desc.cFileName, '\\');
+ SendMessage(GetDlgItem(hwndDlg, IDC_LISTAVAILABLE),
+ LB_ADDSTRING, 0, (LPARAM)(work ? work + 1 : desc.cFileName));
+ }
+ while (FindNextFile(x, &desc))
+ if (desc.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ TCHAR *work;
+
+ work = wcsrchr(desc.cFileName, '\\');
+ SendMessage(GetDlgItem(hwndDlg, IDC_LISTAVAILABLE),
+ LB_ADDSTRING, 0, (LPARAM)(work ? work + 1 : desc.cFileName));
+ }
+ FindClose(x);
+ }
+
+ void startScan() {
+ prescanning = TRUE;
+ wcscpy(old_basePath, basePath);
+ SetDlgItemText(hwndDlg, IDC_FILEPATH, TEXT("Choose the games root directory"));
+ SetDlgItemText(hwndDlg, IDC_SCAN, TEXT("OK"));
+ SetDlgItemText(hwndDlg, IDC_GAMEDESC, TEXT(""));
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PLAY), SW_HIDE);
+ doScan();
+ }
+
+ void endScanPath() {
+ prescanning = FALSE;
+ SetDlgItemText(hwndDlg, IDC_SCAN, TEXT("Scan"));
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PLAY), SW_SHOW);
+ startFindGame();
+ }
+
+ void abortScanPath() {
+ prescanning = FALSE;
+ wcscpy(basePath, old_basePath);
+ SetDlgItemText(hwndDlg, IDC_FILEPATH, TEXT(""));
+ SetDlgItemText(hwndDlg, IDC_SCAN, TEXT("Scan"));
+ SendMessage(GetDlgItem(hwndDlg, IDC_LISTAVAILABLE), LB_RESETCONTENT, 0, 0);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PLAY), SW_SHOW);
+ displayFoundGames();
+ }
+
void startFindGame() {
! //TCHAR fileName[MAX_PATH];
! //TCHAR *tempo;
int i = 0;
int index = 0;
***************
*** 256,259 ****
--- 372,377 ----
unsigned char references[MAX_GAMES];
+ prescanning = FALSE;
+
SetDlgItemText(hwndDlg, IDC_FILEPATH, TEXT("Scanning, please wait"));
***************
*** 261,271 ****
memset(gamesFound, 0, MAX_GAMES);
GetModuleFileName(NULL, fileName, MAX_PATH);
tempo = wcsrchr(fileName, '\\');
*tempo = '\0';
*(tempo + 1) = '\0';
installedGamesNumber = 0;
! findGame(fileName);
// Display the results
--- 379,392 ----
memset(gamesFound, 0, MAX_GAMES);
+ /*
GetModuleFileName(NULL, fileName, MAX_PATH);
tempo = wcsrchr(fileName, '\\');
*tempo = '\0';
*(tempo + 1) = '\0';
+ */
installedGamesNumber = 0;
! //findGame(fileName);
! findGame(basePath);
// Display the results
***************
*** 290,293 ****
--- 411,416 ----
keySize);
keyType = REG_SZ;
+ keySize = (wcslen(basePath) + 1) * 2;
+ RegSetValueEx(hkey, TEXT("BasePath"), 0, keyType, (unsigned char*)basePath, keySize);
for (i=0; i<index; i++) {
char work[100];
Index: pocketpc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/wince/pocketpc.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** pocketpc.cpp 19 Apr 2002 15:09:27 -0000 1.12
--- pocketpc.cpp 21 Apr 2002 21:55:48 -0000 1.13
***************
*** 28,33 ****
#define MAX(a,b) (((a)<(b)) ? (b) : (a))
#define MIN(a,b) (((a)>(b)) ? (b) : (a))
! #define SAMPLES_PER_SEC 11025
! #define VERSION "(VM " SCUMMVM_CVS ")"
GameDetector detector;
--- 28,34 ----
#define MAX(a,b) (((a)<(b)) ? (b) : (a))
#define MIN(a,b) (((a)>(b)) ? (b) : (a))
! #define POCKETSCUMM_BUILD "042102"
!
! #define VERSION "Build " POCKETSCUMM_BUILD " (VM " SCUMMVM_CVS ")"
GameDetector detector;
***************
*** 35,38 ****
--- 36,50 ----
Scumm *g_scumm;
+ extern void Cls();
+
+ extern BOOL isPrescanning();
+ extern void changeScanPath();
+ extern void startScan();
+ extern void endScanPath();
+ extern void abortScanPath();
+
+ void registry_init();
+ void keypad_init();
+
class OSystem_WINCE3 : public OSystem {
public:
***************
*** 100,106 ****
static OSystem *create(int gfx_mode, bool full_screen);
private:
// Windows callbacks & stuff
! bool handleMessage();
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
--- 112,124 ----
static OSystem *create(int gfx_mode, bool full_screen);
+ // Added for hardware keys mapping
+
+ void addEventKeyPressed(int ascii_code);
+
+ void addEventRightButtonClicked();
+
private:
// Windows callbacks & stuff
! //bool handleMessage();
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
***************
*** 108,113 ****
--- 126,133 ----
uint32 _start_time;
Event _event;
+ Event _last_mouse_event;
HMODULE hInst;
HWND hWnd;
+ bool _display_cursor;
***************
*** 189,192 ****
--- 209,213 ----
extern bool draw_keyboard;
bool hide_toolbar;
+ bool hide_cursor;
bool get_key_mapping;
***************
*** 256,265 ****
case WM_COMMAND:
! if (LOWORD(wParam) == IDC_LISTAVAILABLE && HIWORD(wParam) == LBN_SELCHANGE)
! displayGameInfo();
!
! if (wParam == IDC_SCAN)
! startFindGame();
if (wParam == IDC_PLAY) {
int item;
--- 277,294 ----
case WM_COMMAND:
! if (LOWORD(wParam) == IDC_LISTAVAILABLE && HIWORD(wParam) == LBN_SELCHANGE) {
! if (!isPrescanning())
! displayGameInfo();
! else
! changeScanPath();
! }
+ if (wParam == IDC_SCAN) {
+ if (!isPrescanning())
+ startScan();
+ else
+ endScanPath();
+ }
+
if (wParam == IDC_PLAY) {
int item;
***************
*** 273,278 ****
}
! if (wParam == IDC_EXIT)
! EndDialog(hwndDlg, 0);
return TRUE;
default:
--- 302,311 ----
}
! if (wParam == IDC_EXIT) {
! if (!isPrescanning())
! EndDialog(hwndDlg, 0);
! else
! abortScanPath();
! }
return TRUE;
default:
***************
*** 338,346 ****
g_scumm = scumm;
/* bind to Gui */
scumm->_gui = &gui;
- //Warning(TEXT("Initing GUI"));
gui.init(scumm); /* Reinit GUI after loading a game */
- //Warning(TEXT("ScummGO"));
scumm->go();
}
--- 371,384 ----
g_scumm = scumm;
+ registry_init();
+ keypad_init();
+
+ hide_cursor = TRUE;
+ if (scumm->_gameId == GID_SAMNMAX || scumm->_gameId == GID_FT || scumm->_gameId == GID_DIG)
+ hide_cursor = FALSE;
+
/* bind to Gui */
scumm->_gui = &gui;
gui.init(scumm); /* Reinit GUI after loading a game */
scumm->go();
}
***************
*** 452,456 ****
case IDC_SOUND:
- // FIXME
sound_activated = !sound_activated;
CheckMenuItem (
--- 490,493 ----
***************
*** 458,462 ****
IDC_SOUND,
MF_BYCOMMAND | (sound_activated ? MF_CHECKED : MF_UNCHECKED));
! //wm->_scumm->_soundsPaused2 = !sound_activated;
break;
--- 495,499 ----
IDC_SOUND,
MF_BYCOMMAND | (sound_activated ? MF_CHECKED : MF_UNCHECKED));
! g_scumm->pauseSounds(!sound_activated);
break;
***************
*** 510,513 ****
--- 547,551 ----
wm->_event.mouse.x = x;
wm->_event.mouse.y = y;
+ wm->_last_mouse_event = wm->_event;
}
break;
***************
*** 550,553 ****
--- 588,592 ----
wm->_event.mouse.x = x;
wm->_event.mouse.y = y;
+ wm->_last_mouse_event = wm->_event;
break;
***************
*** 561,564 ****
--- 600,604 ----
wm->_event.mouse.x = x;
wm->_event.mouse.y = y;
+ wm->_last_mouse_event = wm->_event;
if(y > 200 && !hide_toolbar)
***************
*** 597,603 ****
break;
case ToolbarSound:
- // FIXME !!!!!
sound_activated = !sound_activated;
! //wm->_scumm->_soundsPaused2 = !sound_activated;
redrawSoundItem();
break;
--- 637,642 ----
break;
case ToolbarSound:
sound_activated = !sound_activated;
! g_scumm->pauseSounds(!sound_activated);
redrawSoundItem();
break;
***************
*** 611,616 ****
{
// pinched from the SDL code. Distinguishes between taps and not
wm->_event.event_code = EVENT_LBUTTONUP;
!
}
break;
--- 650,659 ----
{
// pinched from the SDL code. Distinguishes between taps and not
+ int x = ((int16*)&lParam)[0];
+ int y = ((int16*)&lParam)[1];
+ Translate(&x, &y);
wm->_event.event_code = EVENT_LBUTTONUP;
! wm->_event.mouse.x = x;
! wm->_event.mouse.y = y;
}
break;
***************
*** 624,647 ****
}
-
- bool OSystem_WINCE3::handleMessage() {
- MSG msg;
-
- if (!PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
- return false;
-
- if (msg.message==WM_QUIT) {
- terminated=true;
- do_quit();
- return true;
- }
-
- TranslateMessage(&msg);
- DispatchMessage(&msg);
-
- return true;
- }
-
-
/*************** Registry support ***********/
--- 667,670 ----
***************
*** 721,724 ****
--- 744,834 ----
}
+ /*************** Hardware keys support ***********/
+
+ void OSystem_WINCE3::addEventKeyPressed(int ascii_code) {
+ _event.event_code = EVENT_KEYDOWN;
+ _event.kbd.ascii = ascii_code;
+ }
+
+ void OSystem_WINCE3::addEventRightButtonClicked() {
+ _last_mouse_event.event_code = EVENT_RBUTTONDOWN;
+ _event = _last_mouse_event;
+ }
+
+ void action_right_click() {
+ OSystem_WINCE3* system;
+ system = (OSystem_WINCE3*)g_scumm->_system;
+
+ system->addEventRightButtonClicked();
+ }
+
+ void action_pause() {
+ OSystem_WINCE3* system;
+ system = (OSystem_WINCE3*)g_scumm->_system;
+
+ system->addEventKeyPressed(mapKey(VK_SPACE));
+ }
+
+ void action_save() {
+ OSystem_WINCE3* system;
+ system = (OSystem_WINCE3*)g_scumm->_system;
+
+ if (GetScreenMode()) {
+ draw_keyboard = true;
+ if (!hide_toolbar)
+ toolbar_drawn = false;
+ }
+
+ system->addEventKeyPressed(mapKey(VK_F5));
+ }
+
+ void action_quit() {
+ do_quit();
+ }
+
+ void action_skip() {
+ OSystem_WINCE3* system;
+ system = (OSystem_WINCE3*)g_scumm->_system;
+
+ system->addEventKeyPressed(mapKey(VK_ESCAPE));
+ }
+
+ void action_hide() {
+ hide_toolbar = !hide_toolbar;
+ Cls();
+ toolbar_drawn = hide_toolbar;
+ g_scumm->_system->update_screen();
+ }
+
+ void action_keyboard() {
+ if (GetScreenMode()) {
+ draw_keyboard = !draw_keyboard;
+ if (!hide_toolbar)
+ toolbar_drawn = false;
+ }
+ }
+
+ void action_sound() {
+ sound_activated = !sound_activated;
+ g_scumm->pauseSounds(!sound_activated);
+ }
+
+ void action_cursoronoff() {
+ hide_cursor = !hide_cursor;
+ }
+
+ void keypad_init() {
+ static pAction actions[TOTAL_ACTIONS] =
+ { action_pause, action_save, action_quit, action_skip, action_hide,
+ action_keyboard, action_sound, action_right_click, action_cursoronoff };
+
+ GAPIKeysInit(actions);
+
+ }
+
+ void keypad_close() {
+ GXCloseInput();
+ }
+
/************* OSystem Main **********************/
***************
*** 728,731 ****
--- 838,842 ----
syst->_full_screen = full_screen;
syst->_event.event_code = -1;
+ syst->_start_time = GetTickCount();
/* Retrieve the handle of this module */
***************
*** 793,797 ****
const byte *b = colors;
uint i;
- //SDL_Color *base = _cur_pal + start;
for(i=0;i!=num;i++) {
SetPalEntry(i + start, b[0], b[1], b[2]);
--- 904,907 ----
***************
*** 806,809 ****
--- 916,920 ----
_gfx_buf = (byte*)malloc((320 * 240) * sizeof(byte));
+ _ms_backup = (byte*)malloc((40 * 40) * sizeof(byte));
}
***************
*** 819,822 ****
--- 930,936 ----
byte *dst;
+ if (!hide_cursor && _mouse_drawn)
+ undraw_mouse();
+
dst = _gfx_buf + y * 320 + x;
do {
***************
*** 827,833 ****
}
- void OSystem_WINCE3::update_screen() {
Blt(_gfx_buf);
}
--- 941,949 ----
}
+ void OSystem_WINCE3::update_screen() {
+ if (!hide_cursor)
+ draw_mouse();
Blt(_gfx_buf);
}
***************
*** 842,845 ****
--- 958,1054 ----
return last;
}
+
+ // From X11 port
+
+ void OSystem_WINCE3::draw_mouse() {
+ if (_mouse_drawn || !_mouse_visible)
+ return;
+ _mouse_drawn = true;
+
+ int xdraw = _ms_cur.x - _ms_hotspot_x;
+ int ydraw = _ms_cur.y - _ms_hotspot_y;
+ int w = _ms_cur.w;
+ int h = _ms_cur.h;
+ int real_w;
+ int real_h;
+ int real_h_2;
+
+ byte *dst;
+ byte *dst2;
+ const byte *buf = _ms_buf;
+ byte *bak = _ms_backup;
+
+ assert(w <= 40 && h <= 40);
+
+ if (ydraw < 0) {
+ real_h = h + ydraw;
+ buf += (-ydraw) * w;
+ ydraw = 0;
+ } else {
+ real_h = (ydraw + h) > 200 ? (200 - ydraw) : h;
+ }
+ if (xdraw < 0) {
+ real_w = w + xdraw;
+ buf += (-xdraw);
+ xdraw = 0;
+ } else {
+ real_w = (xdraw + w) > 320 ? (320 - xdraw) : w;
+ }
+
+ dst = _gfx_buf + (ydraw * 320) + xdraw;
+ dst2 = dst;
+
+ if ((real_h == 0) || (real_w == 0)) {
+ _mouse_drawn = false;
+ return;
+ }
+
+ _ms_old.x = xdraw;
+ _ms_old.y = ydraw;
+ _ms_old.w = real_w;
+ _ms_old.h = real_h;
+
+ real_h_2 = real_h;
+ while (real_h_2 > 0) {
+ memcpy(bak, dst, real_w);
+ bak += 40;
+ dst += 320;
+ real_h_2--;
+ }
+ while (real_h > 0) {
+ int width = real_w;
+ while (width > 0) {
+ byte color = *buf;
+ if (color != 0xFF) {
+ *dst2 = color;
+ }
+ buf++;
+ dst2++;
+ width--;
+ }
+ buf += w - real_w;
+ dst2 += 320 - real_w;
+ real_h--;
+ }
+ }
+
+ void OSystem_WINCE3::undraw_mouse() {
+ if (!_mouse_drawn)
+ return;
+ _mouse_drawn = false;
+
+ int old_h = _ms_old.h;
+
+ byte *dst = _gfx_buf + (_ms_old.y * 320) + _ms_old.x;
+ byte *bak = _ms_backup;
+
+ while (old_h > 0) {
+ memcpy(dst, bak, _ms_old.w);
+ bak += 40;
+ dst += 320;
+ old_h--;
+ }
+ }
+
void OSystem_WINCE3::set_mouse_pos(int x, int y) {
***************
*** 867,871 ****
void OSystem_WINCE3::delay_msecs(uint msecs) {
! handleMessage();
Sleep(msecs);
}
--- 1076,1080 ----
void OSystem_WINCE3::delay_msecs(uint msecs) {
! //handleMessage();
Sleep(msecs);
}
***************
*** 884,894 ****
bool OSystem_WINCE3::poll_event(Event *event) {
- if (_event.event_code < 0)
- return false;
! *event = _event;
! _event.event_code = -1;
! return true;
}
--- 1093,1120 ----
bool OSystem_WINCE3::poll_event(Event *event) {
! for (;;) {
! MSG msg;
! _event.event_code = -1;
!
! if (!PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
! return false;
!
! if (msg.message==WM_QUIT) {
! terminated=true;
! do_quit();
! return false;
! }
!
! TranslateMessage(&msg);
! DispatchMessage(&msg);
!
! *event = _event;
!
! return true;
! }
!
! return false;
}
***************
*** 943,947 ****
exit(1);
}
-
/* CDRom Audio */
--- 1169,1172 ----
More information about the Scummvm-git-logs
mailing list