aboutsummaryrefslogtreecommitdiff
path: root/wince
diff options
context:
space:
mode:
authorNicolas Bacca2002-04-19 06:23:49 +0000
committerNicolas Bacca2002-04-19 06:23:49 +0000
commit44cc8c24a3e4d72e95620d45a7707d546258a3cc (patch)
tree84ece5e2879d70f2b63e4364926526bd352a8b77 /wince
parent6215c253d4f5605201109a075e90b3d1344a8d6e (diff)
downloadscummvm-rg350-44cc8c24a3e4d72e95620d45a7707d546258a3cc.tar.gz
scummvm-rg350-44cc8c24a3e4d72e95620d45a7707d546258a3cc.tar.bz2
scummvm-rg350-44cc8c24a3e4d72e95620d45a7707d546258a3cc.zip
Update minimalist (and broken) WinCE port
svn-id: r4000
Diffstat (limited to 'wince')
-rw-r--r--wince/pocketpc.cpp1025
1 files changed, 581 insertions, 444 deletions
diff --git a/wince/pocketpc.cpp b/wince/pocketpc.cpp
index 2cd7953ad4..edc174498f 100644
--- a/wince/pocketpc.cpp
+++ b/wince/pocketpc.cpp
@@ -20,33 +20,29 @@
#include "stdafx.h"
#include <assert.h>
-#include <aygshell.h>
-#include "resource.h"
-
#include "scumm.h"
#include "screen.h"
-
-#include "sound.h"
-
#include "gui.h"
+#include "mididrv.h"
+#include "gameDetector.h"
+#include "simon/simon.h"
+#include "gapi_keys.h"
-#include "commctrl.h"
+#include "commctrl.h"
#include <Winuser.h>
-
#include <Winnls.h>
#include <sipapi.h>
#include <Aygshell.h>
#include <gx.h>
-
-#include "gapi_keys.h"
+#include <aygshell.h>
+#include "resource.h"
#include "SDL.h"
#include "SDL_audio.h"
#include "SDL_timer.h"
#include "SDL_thread.h"
-
#define VERSION "(VM " SCUMMVM_CVS ")"
#define SHMenuBar_GetMenu(hWndMB,ID_MENU) (HMENU)SendMessage((hWndMB), SHCMBM_GETSUBMENU, (WPARAM)0, (LPARAM)ID_MENU)
@@ -100,6 +96,12 @@ static int old_mouse_x, old_mouse_y;
static int old_mouse_h, old_mouse_w;
static bool has_mouse, hide_mouse;
+GameDetector detector;
+Gui gui;
+
+Scumm *g_scumm;
+
+
#define BAK_WIDTH 40
#define BAK_HEIGHT 40
unsigned char old_backup[BAK_WIDTH * BAK_HEIGHT];
@@ -114,34 +116,6 @@ unsigned char old_backup[BAK_WIDTH * BAK_HEIGHT];
num_of_dirty_square++; \
}
-// Practically identical to the one in windows.cpp
-class WndMan
-{
- HMODULE hInst;
- HWND hWnd;
-
- bool terminated;
-
-public:
- byte *_vgabuf;
- Scumm *_scumm;
-
- HANDLE _event;
- DWORD _threadId;
- HWAVEOUT _handle;
- WAVEHDR _hdr[2];
-
-
-public:
- void init();
-
- bool handleMessage();
- void run();
- void setPalette(byte *ctab, int first, int num);
- void writeToScreen();
-
-};
-
// Similar to Error in windows.cpp but has to take Unicode in account
void Error(LPCTSTR msg)
{
@@ -152,14 +126,10 @@ void Error(LPCTSTR msg)
//{{
Scumm scumm;
-ScummDebugger debugger;
-Gui gui;
-IMuse sound;
-SOUND_DRIVER_TYPE snd_driv;
+//IMuse sound;
+//SOUND_DRIVER_TYPE snd_driv;
-
-WndMan wm[1];
byte veryFastMode;
//}}
@@ -283,12 +253,14 @@ void registry_save() {
/* Action functions */
+// FIX ACTIONS
+
void action_right_click() {
- wm->_scumm->_rightBtnPressed |= msDown|msClicked;
+ //wm->_scumm->_rightBtnPressed |= msDown|msClicked;
}
void action_pause() {
- wm->_scumm->_keyPressed = mapKey(VK_SPACE);
+ //wm->_scumm->_keyPressed = mapKey(VK_SPACE);
}
void action_save() {
@@ -298,7 +270,7 @@ void action_save() {
toolbar_drawn = false;
}
- wm->_scumm->_keyPressed = mapKey(VK_F5);
+ //wm->_scumm->_keyPressed = mapKey(VK_F5);
}
void action_quit() {
@@ -306,14 +278,14 @@ void action_quit() {
}
void action_skip() {
- wm->_scumm->_keyPressed = mapKey(VK_ESCAPE);
+ //wm->_scumm->_keyPressed = mapKey(VK_ESCAPE);
}
void action_hide() {
hide_toolbar = !hide_toolbar;
Cls();
toolbar_drawn = hide_toolbar;
- wm->writeToScreen();
+ //wm->writeToScreen();
}
void action_keyboard() {
@@ -326,7 +298,7 @@ void action_keyboard() {
void action_sound() {
sound_activated = !sound_activated;
- wm->_scumm->_soundsPaused2 = !sound_activated;
+ //wm->_scumm->_soundsPaused2 = !sound_activated;
}
/* Initialization */
@@ -344,22 +316,445 @@ void keypad_close() {
GXCloseInput();
}
-/* *************************************************************************** */
-/* SDL sound */
-/* *************************************************************************** */
+// This function is very similar to the one in windows.cpp except for
+// one line removed.
+
+// TODO : use dirty rects
+
+/*
+void blitToScreen(Scumm *s, byte *src,int x, int y, int w, int h) {
+ byte *dst;
+ //int i;
+
+ dst = (byte*)wm->_vgabuf + y*320 + x;
+
+ if (h<=0) return;
+
+ hide_mouse = true;
+ if (has_mouse) {
+ s->drawMouse();
+ }
+
+ AddDirtyRec(x, y, w, h);
+
+ do {
+ memcpy(dst, src, w);
+ dst += 320;
+ src += 320;
+ } while (--h);
+
+}
+*/
+
+//{{
+int clock;
+
+// TODO : use dirty rects for faster screen updates
+
+/*
+void updateScreen(Scumm *s) {
+
+ if (hide_mouse) {
+ hide_mouse = false;
+ s->drawMouse();
+ }
+
+ if (s->_palDirtyMax != -1) {
+ wm->setPalette(s->_currentPalette, 0, 256);
+ s->_palDirtyMax = -1;
+ }
+
+ wm->writeToScreen();
+}
+
+void waitForTimer(Scumm *s, int delay) {
+ wm->handleMessage();
+ if (!veryFastMode) {
+ assert(delay<5000);
+ if(!delay)
+ delay++;
+ Sleep(delay);
+ }
+}
+*/
+
+// Copy/Paste from X11
+// Dirty rects not managed now
+
+/*
+
+void drawMouse(int xdraw, int ydraw, int w, int h, byte *buf, bool visible) {
+ unsigned char *dst,*bak;
+
+ if ((xdraw >= 320) || ((xdraw + w) <= 0) ||
+ (ydraw >= 200) || ((ydraw + h) <= 0)) {
+ if (hide_mouse) visible = false;
+ if (has_mouse) has_mouse = false;
+ if (visible) has_mouse = true;
+ return;
+ }
+
+ if (hide_mouse)
+ visible = false;
+
+ assert(w<=BAK_WIDTH && h<=BAK_HEIGHT);
+
+ if (has_mouse) {
+ int old_h = old_mouse_h;
+
+ has_mouse = false;
+ AddDirtyRec(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h);
+
+ dst = wm->_vgabuf + (old_mouse_y * 320) + old_mouse_x;
+ bak = old_backup;
+
+ while (old_h > 0) {
+ memcpy(dst, bak, old_mouse_w);
+ bak += BAK_WIDTH;
+ dst += 320;
+ old_h--;
+ }
+ }
+
+ if (visible) {
+ int real_w;
+ int real_h;
+ int real_h_2;
+ unsigned char *dst2;
+
+ 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 = wm->_vgabuf + (ydraw * 320) + xdraw;
+ dst2 = dst;
+ bak = old_backup;
+
+ has_mouse = true;
+
+ AddDirtyRec(xdraw, ydraw, real_w, real_h);
+ old_mouse_x = xdraw;
+ old_mouse_y = ydraw;
+ old_mouse_w = real_w;
+ old_mouse_h = real_h;
+
+ real_h_2 = real_h;
+ while (real_h_2 > 0) {
+ memcpy(bak, dst, real_w);
+ bak += BAK_WIDTH;
+ dst += 320;
+ real_h_2--;
+ }
+ while (real_h > 0) {
+ int width = real_w;
+ while (width > 0) {
+ unsigned char color = *buf;
+ if (color != 0xFF) {
+ *dst2 = color;
+ }
+ buf++;
+ dst2++;
+ width--;
+ }
+ buf += w - real_w;
+ dst2 += 320 - real_w;
+ real_h--;
+ }
+ }
+}
+*/
+
+
+BOOL CALLBACK SelectDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch(uMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ TCHAR work[1024];
+ RECT rc; GetWindowRect(hwndDlg, &rc);
+ MoveWindow(hwndDlg,
+ (GetSystemMetrics(SM_CXSCREEN)-rc.right+rc.left)/2,
+ (GetSystemMetrics(SM_CYSCREEN)-rc.bottom+rc.top)/2,
+ rc.right-rc.left, rc.bottom-rc.top, TRUE);
+ BringWindowToTop(hwndDlg);
+ setFindGameDlgHandle(hwndDlg);
+ MultiByteToWideChar(CP_ACP, 0, VERSION, strlen(VERSION) + 1, work, sizeof(work));
+ SetDlgItemText(hwndDlg, IDC_GAMEDESC, work);
+ loadGameSettings();
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+
+ if (LOWORD(wParam) == IDC_LISTAVAILABLE && HIWORD(wParam) == LBN_SELCHANGE)
+ displayGameInfo();
-void fill_sound(void *userdata, Uint8 *stream, int len) {
- scumm.mixWaves((int16*)stream, len>>1);
+ if (wParam == IDC_SCAN)
+ startFindGame();
+
+ if (wParam == IDC_PLAY) {
+ int item;
+
+ item = SendMessage(GetDlgItem(hwndDlg, IDC_LISTAVAILABLE), LB_GETCURSEL, 0, 0);
+ if (item == LB_ERR) {
+ MessageBox(hwndDlg, TEXT("Please select a game"), TEXT("Error"), MB_OK);
+ }
+ else
+ EndDialog(hwndDlg, item + 1000);
+ }
+
+ if (wParam == IDC_EXIT)
+ EndDialog(hwndDlg, 0);
+ return TRUE;
+ default:
+ return FALSE;
+ }
}
+char* GameSelector()
+{
+ TCHAR directory[MAX_PATH];
+ static char id[100];
+
+ DWORD result = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_GAMESELECT), HWND_DESKTOP, SelectDlgProc);
+ if (result < 1000)
+ return NULL;
+ result -= 1000;
+
+ getSelectedGame(result, id, directory);
+
+ WideCharToMultiByte(CP_ACP, 0, directory, wcslen(directory) + 1, _directory, sizeof(_directory), NULL, NULL);
+
+ strcat(_directory, "\\");
+
+ return id;
+
+}
+
+// Directly corresponds to main in windows.cpp
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
+{
+
+ int argc = 3;
+ char* argv[3];
+ char argdir[MAX_PATH];
+ sound_activated = true;
+ hide_toolbar = false;
+
+ argv[0] = NULL;
+ argv[1] = GameSelector();
+ sprintf(argdir, "-p%s", _directory);
+ argv[2] = argdir;
+
+ if (!argv[1])
+ return 0;
+
+ if (detector.detectMain(argc, argv))
+ return (-1);
+
+ OSystem *system = detector.createSystem();
+
+ /* Simon the Sorcerer? */
+ if (detector._gameId >= GID_SIMON_FIRST && detector._gameId <= GID_SIMON_LAST) {
+ /* Simon the Sorcerer. Completely different initialization */
+ MidiDriver *midi = detector.createMidi();
+
+ SimonState *simon = SimonState::create(system, midi);
+ simon->_game = detector._gameId - GID_SIMON_FIRST;
+ simon->set_volume(detector._sfx_volume);
+ simon->_game_path = detector._gameDataPath;
+ simon->go();
+
+ } else {
+ Scumm *scumm = Scumm::createFromDetector(&detector, system);
+ g_scumm = scumm;
+
+ /* bind to Gui */
+ scumm->_gui = &gui;
+ gui.init(scumm); /* Reinit GUI after loading a game */
+
+ scumm->go();
+ }
+
+ return 0;
+}
+
+class OSystem_WINCE3 : public OSystem {
+public:
+ // Set colors of the palette
+ void set_palette(const byte *colors, uint start, uint num);
+
+ // Set the size of the video bitmap.
+ // Typically, 320x200
+ void init_size(uint w, uint h);
+
+ // Draw a bitmap to screen.
+ // The screen will not be updated to reflect the new bitmap
+ void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h);
+
+ // Update the dirty areas of the screen
+ void update_screen();
+
+ // Either show or hide the mouse cursor
+ bool show_mouse(bool visible);
+
+ // Set the position of the mouse cursor
+ void set_mouse_pos(int x, int y);
+
+ // Set the bitmap that's used when drawing the cursor.
+ void set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y);
+
+ // Shaking is used in SCUMM. Set current shake position.
+ void set_shake_pos(int shake_pos);
+
+ // Get the number of milliseconds since the program was started.
+ uint32 get_msecs();
+
+ // Delay for a specified amount of milliseconds
+ void delay_msecs(uint msecs);
+
+ // Create a thread
+ void *create_thread(ThreadProc *proc, void *param);
+
+ // Get the next event.
+ // Returns true if an event was retrieved.
+ bool poll_event(Event *event);
+
+ // Set function that generates samples
+ bool set_sound_proc(void *param, SoundProc *proc, byte sound);
+
+ // Poll cdrom status
+ // Returns true if cd audio is playing
+ bool poll_cdrom();
+
+ // Play cdrom audio track
+ void play_cdrom(int track, int num_loops, int start_frame, int end_frame);
+
+ // Stop cdrom audio track
+ void stop_cdrom();
+
+ // Update cdrom audio status
+ void update_cdrom();
+
+ // Quit
+ void quit();
+
+ // Set a parameter
+ uint32 property(int param, uint32 value);
+
+ // Windows callbacks & stuff
+
+ bool handleMessage();
+ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+ // Constructor
+
+ static OSystem *create();
+
+private:
+
+ byte *_vgabuf;
+ uint32 _start_time;
+ Event _event;
+ HMODULE hInst;
+ HWND hWnd;
+ bool terminated;
+};
+
+// Create class
+
+ OSystem* OSystem_WINCE3_create() {
+ return OSystem_WINCE3::create();
+}
+
+// Constructor
+
+OSystem* OSystem_WINCE3::create() {
+
+ OSystem_WINCE3 *syst = new OSystem_WINCE3();
+
+ syst->_vgabuf = (byte*)calloc(320,200);
+ syst->_event.event_code = -1;
+
+ /* Retrieve the handle of this module */
+ syst->hInst = GetModuleHandle(NULL);
+
+ /* Register the window class */
+ WNDCLASS wcex;
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = (WNDPROC)WndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = syst->hInst;
+ wcex.hIcon = 0;
+ wcex.hCursor = NULL;
+ wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
+ wcex.lpszMenuName = 0;
+ wcex.lpszClassName = TEXT("ScummVM");
+ if (!RegisterClass(&wcex))
+ Error(TEXT("Cannot register window class!"));
+
+ syst->hWnd = CreateWindow(TEXT("ScummVM"), TEXT("ScummVM"), WS_VISIBLE,
+ 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, syst->hInst, NULL);
+ hWnd_Window = syst->hWnd;
+ SetWindowLong(syst->hWnd, GWL_USERDATA, (long)syst);
+
+ ShowWindow(syst->hWnd, SW_SHOW);
+
+ SHMENUBARINFO smbi;
+ smbi.cbSize = sizeof(smbi);
+ smbi.hwndParent = syst->hWnd;
+ smbi.dwFlags = 0;
+ smbi.nToolBarId = IDM_MENU;
+ smbi.hInstRes = GetModuleHandle(NULL);
+ smbi.nBmpId = 0;
+ smbi.cBmpImages = 0;
+ smbi.hwndMB = NULL;
+ BOOL res = SHCreateMenuBar(&smbi);
+ hWnd_MainMenu = smbi.hwndMB;
+
+ /* Sound is activated on default - initialize it in the menu */
+ CheckMenuItem((HMENU)SHMenuBar_GetMenu (hWnd_MainMenu, IDM_POCKETSCUMM),
+ IDC_SOUND,
+ MF_BYCOMMAND | MF_CHECKED);
+
+ GraphicsOn(syst->hWnd);
+
+ SetWindowPos(syst->hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
+ SetForegroundWindow(syst->hWnd);
+// SHFullScreen(hWnd, SHFS_SHOWSIPBUTTON);
+ SHFullScreen(syst->hWnd, SHFS_HIDESIPBUTTON | SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
+
+ //Cls();
+
+// Mini SDL init
+
+ if (SDL_Init(SDL_INIT_AUDIO)==-1) {
+ exit(1);
+ }
+
+ return syst;
+}
-// TODO : check SIP state - menu seems to be not drawn on some devices
+// Windows specific callbacks
-static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK OSystem_WINCE3::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static SHACTIVATEINFO sai;
- WndMan *wm = (WndMan*)GetWindowLong(hWnd, GWL_USERDATA);
+ OSystem_WINCE3 *wm = (OSystem_WINCE3*)GetWindowLong(hWnd, GWL_USERDATA);
switch (message)
{
@@ -408,7 +803,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
}
// SHSipPreference(hWnd, SIP_UP); /* Hack! */
/* It does not happen often but I don't want to see tooltip traces */
- wm->writeToScreen();
+ wm->update_screen();
return 0;
case WM_ACTIVATE:
@@ -433,16 +828,17 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
case WM_COMMAND:
switch(wParam)
{
- case IDC_OPTIONS:
- wm->_scumm->_keyPressed = KEY_SET_OPTIONS;
+ case IDC_OPTIONS:
+ wm->_event.kbd.ascii = KEY_SET_OPTIONS;
+ wm->_event.event_code = EVENT_KEYDOWN;
break;
case IDC_EXIT:
DestroyWindow(hWnd);
do_quit();
break;
case IDC_SKIP:
- wParam = VK_ESCAPE;
- wm->_scumm->_keyPressed = mapKey(wParam);
+ wm->_event.kbd.ascii = mapKey(VK_ESCAPE);;
+ wm->_event.event_code = EVENT_KEYDOWN;
break;
case IDC_LOADSAVE:
if (GetScreenMode()) {
@@ -450,17 +846,18 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
if (!hide_toolbar)
toolbar_drawn = false;
}
- wParam = VK_F5;
- wm->_scumm->_keyPressed = mapKey(wParam);
+ wm->_event.kbd.ascii = mapKey(VK_F5);
+ wm->_event.event_code = EVENT_KEYDOWN;
break;
case IDC_SOUND:
+ // FIXME
sound_activated = !sound_activated;
CheckMenuItem (
SHMenuBar_GetMenu (hWnd_MainMenu, IDM_POCKETSCUMM),
IDC_SOUND,
MF_BYCOMMAND | (sound_activated ? MF_CHECKED : MF_UNCHECKED));
- wm->_scumm->_soundsPaused2 = !sound_activated;
+ //wm->_scumm->_soundsPaused2 = !sound_activated;
break;
break;
@@ -489,13 +886,16 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
GAPI_key = getGAPIKeyMapping((short)wParam);
if (GAPI_key) {
- if (get_key_mapping)
- wm->_scumm->_keyPressed = GAPI_KEY_BASE + GAPI_key;
+ if (get_key_mapping) {
+ wm->_event.kbd.ascii = GAPI_KEY_BASE + GAPI_key;
+ wm->_event.event_code = EVENT_KEYDOWN;
+ }
else
processAction((short)wParam);
}
else {
- wm->_scumm->_keyPressed = mapKey(wParam);
+ wm->_event.kbd.ascii = mapKey(wParam);
+ wm->_event.event_code = EVENT_KEYDOWN;
}
}
@@ -506,8 +906,9 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
int x = ((int16*)&lParam)[0];
int y = ((int16*)&lParam)[1];
Translate(&x, &y);
- wm->_scumm->mouse.x = x;
- wm->_scumm->mouse.y = y;
+ wm->_event.event_code = EVENT_MOUSEMOVE;
+ wm->_event.mouse.x = x;
+ wm->_event.mouse.y = y;
}
break;
case WM_LBUTTONDOWN:
@@ -522,7 +923,8 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
if (x<185 && y>=200) {
//Alpha selection
- wm->_scumm->_keyPressed =
+ wm->_event.event_code = EVENT_KEYDOWN;
+ wm->_event.kbd.ascii =
(y <= 220 ? KEYBOARD_MAPPING_ALPHA_HIGH[((x + 10) / 14) - 1] :
KEYBOARD_MAPPING_ALPHA_LOW[((x + 10) / 14) - 1]);
break;
@@ -530,7 +932,8 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
else
if (x>=186 && y>=200 && x<=255) {
// Numeric selection
- wm->_scumm->_keyPressed =
+ wm->_event.event_code = EVENT_KEYDOWN;
+ wm->_event.kbd.ascii =
(y <= 220 ? KEYBOARD_MAPPING_NUMERIC_HIGH[((x - 187 + 10) / 14) - 1] :
KEYBOARD_MAPPING_NUMERIC_LOW[((x - 187 + 10) / 14) - 1]);
break;
@@ -538,13 +941,14 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
else
if (x>=302 && x <= 316 && y >= 200 && y <= 220) {
// Backspace
- wm->_scumm->_keyPressed = mapKey(VK_BACK);
+ wm->_event.event_code = EVENT_KEYDOWN;
+ wm->_event.kbd.ascii = mapKey(VK_BACK);
break;
}
- wm->_scumm->mouse.x = x;
- wm->_scumm->mouse.y = y;
- wm->_scumm->_leftBtnPressed |= msClicked|msDown;
+ wm->_event.event_code = EVENT_LBUTTONDOWN;
+ wm->_event.mouse.x = x;
+ wm->_event.mouse.y = y;
break;
}
@@ -553,15 +957,16 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
toolbar_selection = (hide_toolbar || get_key_mapping ? ToolbarNone :
getToolbarSelection(x, y));
if (toolbar_selection == ToolbarNone) {
- wm->_scumm->mouse.x = x;
- wm->_scumm->mouse.y = y;
-
- wm->_scumm->_leftBtnPressed |= msClicked|msDown;
+ wm->_event.event_code = EVENT_LBUTTONDOWN;
+ wm->_event.mouse.x = x;
+ wm->_event.mouse.y = y;
if(y > 200 && !hide_toolbar)
{
- if(x<160)
- wm->_scumm->_keyPressed = VK_ESCAPE;
+ if(x<160) {
+ wm->_event.event_code = EVENT_KEYDOWN;
+ wm->_event.kbd.ascii = mapKey(VK_ESCAPE);
+ }
else
{
SetScreenMode(0); // restore normal tap logic
@@ -579,17 +984,21 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
if (!hide_toolbar)
toolbar_drawn = false;
}
- wm->_scumm->_keyPressed = mapKey(VK_F5);
+ wm->_event.event_code = EVENT_KEYDOWN;
+ wm->_event.kbd.ascii = mapKey(VK_F5);
break;
case ToolbarExit:
- wm->_scumm->_keyPressed = KEY_SET_OPTIONS;
+ wm->_event.event_code = EVENT_KEYDOWN;
+ wm->_event.kbd.ascii = KEY_SET_OPTIONS;
break;
case ToolbarSkip:
- wm->_scumm->_keyPressed = mapKey(VK_ESCAPE);
+ wm->_event.event_code = EVENT_KEYDOWN;
+ wm->_event.kbd.ascii = mapKey(VK_ESCAPE);
break;
case ToolbarSound:
+ // FIXME !!!!!
sound_activated = !sound_activated;
- wm->_scumm->_soundsPaused2 = !sound_activated;
+ //wm->_scumm->_soundsPaused2 = !sound_activated;
redrawSoundItem();
break;
default:
@@ -601,11 +1010,12 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
case WM_LBUTTONUP:
{
// pinched from the SDL code. Distinguishes between taps and not
- wm->_scumm->_leftBtnPressed &= ~msDown;
+ wm->_event.event_code = EVENT_LBUTTONUP;
+
}
break;
case WM_LBUTTONDBLCLK: // doesn't seem to work right now
- wm->_scumm->_rightBtnPressed |= msClicked | msDown;
+ //wm->_scumm->_rightBtnPressed |= msClicked | msDown;
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
@@ -613,79 +1023,8 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
return 0;
}
-// writeToScreen, setPalette and init are very port-specific
-void WndMan::writeToScreen()
-{
- Blt(_vgabuf);
-}
-
-void WndMan::setPalette(byte *ctab, int first, int num) {
- int i;
-
- for (i=0; i<256; i++)
- SetPalEntry(i, ctab[i*3+0], ctab[i*3+1], ctab[i*3+2]);
-
- palette_update();
-}
-
-
-void WndMan::init()
-{
- /* Retrieve the handle of this module */
- hInst = GetModuleHandle(NULL);
- /* Register the window class */
- WNDCLASS wcex;
- wcex.style = CS_HREDRAW | CS_VREDRAW;
- wcex.lpfnWndProc = (WNDPROC)WndProc;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
- wcex.hInstance = hInst;
- wcex.hIcon = 0;
- wcex.hCursor = NULL;
- wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
- wcex.lpszMenuName = 0;
- wcex.lpszClassName = TEXT("ScummVM");
- if (!RegisterClass(&wcex))
- Error(TEXT("Cannot register window class!"));
-
- hWnd = CreateWindow(TEXT("ScummVM"), TEXT("ScummVM"), WS_VISIBLE,
- 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInst, NULL);
- hWnd_Window = hWnd;
- SetWindowLong(hWnd, GWL_USERDATA, (long)this);
-
- ShowWindow(hWnd, SW_SHOW);
-
- SHMENUBARINFO smbi;
- smbi.cbSize = sizeof(smbi);
- smbi.hwndParent = hWnd;
- smbi.dwFlags = 0;
- smbi.nToolBarId = IDM_MENU;
- smbi.hInstRes = GetModuleHandle(NULL);
- smbi.nBmpId = 0;
- smbi.cBmpImages = 0;
- smbi.hwndMB = NULL;
- BOOL res = SHCreateMenuBar(&smbi);
- hWnd_MainMenu = smbi.hwndMB;
-
- /* Sound is activated on default - initialize it in the menu */
- CheckMenuItem((HMENU)SHMenuBar_GetMenu (hWnd_MainMenu, IDM_POCKETSCUMM),
- IDC_SOUND,
- MF_BYCOMMAND | MF_CHECKED);
-
- GraphicsOn(hWnd);
-
- SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
- SetForegroundWindow(hWnd);
-// SHFullScreen(hWnd, SHFS_SHOWSIPBUTTON);
- SHFullScreen(hWnd, SHFS_HIDESIPBUTTON | SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
-
- Cls();
-}
-
-
-//{{
-bool WndMan::handleMessage() {
+bool OSystem_WINCE3::handleMessage() {
MSG msg;
if (!PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
@@ -702,331 +1041,129 @@ bool WndMan::handleMessage() {
return true;
}
-//}}
-// This function is very similar to the one in windows.cpp except for
-// one line removed.
+void OSystem_WINCE3::set_palette(const byte *colors, uint start, uint num) {
+ int i;
-// TODO : use dirty rects
+ for (i=0; i<256; i++)
+ SetPalEntry(i, colors[i*3+0], colors[i*3+1], colors[i*3+2]);
-void blitToScreen(Scumm *s, byte *src,int x, int y, int w, int h) {
- byte *dst;
- //int i;
+ palette_update();
- dst = (byte*)wm->_vgabuf + y*320 + x;
+}
- if (h<=0) return;
+void OSystem_WINCE3::init_size(uint w, uint h) {
+}
- hide_mouse = true;
- if (has_mouse) {
- s->drawMouse();
- }
-
- AddDirtyRec(x, y, w, h);
+void OSystem_WINCE3::copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) {
+ byte *dst;
+ dst = _vgabuf + y * 320 + x;
do {
- memcpy(dst, src, w);
+ memcpy(dst, buf, w);
dst += 320;
- src += 320;
+ buf += pitch;
} while (--h);
-
+
}
-//{{
-int clock;
+void OSystem_WINCE3::update_screen() {
+ Blt(_vgabuf);
+}
-// TODO : use dirty rects for faster screen updates
+// FIXME : implement mouse functions
-void updateScreen(Scumm *s) {
+bool OSystem_WINCE3::show_mouse(bool visible) {
+ return false;
+}
+
- if (hide_mouse) {
- hide_mouse = false;
- s->drawMouse();
- }
+void OSystem_WINCE3::set_mouse_pos(int x, int y) {
+}
+
- if (s->_palDirtyMax != -1) {
- wm->setPalette(s->_currentPalette, 0, 256);
- s->_palDirtyMax = -1;
- }
+void OSystem_WINCE3::set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) {
+}
+
+void OSystem_WINCE3::set_shake_pos(int shake_pos) {
+}
+
- wm->writeToScreen();
+uint32 OSystem_WINCE3::get_msecs() {
+ return GetTickCount() - _start_time;
+}
+
+void OSystem_WINCE3::delay_msecs(uint msecs) {
+ handleMessage();
+ Sleep(msecs);
}
+
-void waitForTimer(Scumm *s, int delay) {
- wm->handleMessage();
- if (!veryFastMode) {
- assert(delay<5000);
- if(!delay)
- delay++;
- Sleep(delay);
- }
+void* OSystem_WINCE3::create_thread(ThreadProc *proc, void *param) {
+ // Implement if needed by Midi Music
+ return NULL;
}
+
+//FIXME : add a minimal queue (just testing here)
-void initGraphics(Scumm *s, bool fullScreen, unsigned int scaleFactor) {
- SDL_AudioSpec desired;
+bool OSystem_WINCE3::poll_event(Event *event) {
+ if (_event.event_code < 0)
+ return false;
- if(fullScreen)
- warning("Use SDL for fullscreen support");
+ *event = _event;
+ _event.event_code = -1;
- if (SDL_Init(SDL_INIT_AUDIO)==-1) {
- exit(1);
- }
+ return true;
+}
+
+
+bool OSystem_WINCE3::set_sound_proc(void *param, SoundProc *proc, byte sound) {
+ SDL_AudioSpec desired;
desired.freq = 11025;
desired.format = AUDIO_S16SYS;
desired.channels = 1;
desired.samples = 128; // seems correct
- desired.callback = fill_sound;
+ desired.callback = proc;
+ desired.userdata = param;
SDL_OpenAudio(&desired, NULL);
SDL_PauseAudio(0);
-}
-
-// Copy/Paste from X11
-// Dirty rects not managed now
-
-void drawMouse(int xdraw, int ydraw, int w, int h, byte *buf, bool visible) {
- unsigned char *dst,*bak;
-
- if ((xdraw >= 320) || ((xdraw + w) <= 0) ||
- (ydraw >= 200) || ((ydraw + h) <= 0)) {
- if (hide_mouse) visible = false;
- if (has_mouse) has_mouse = false;
- if (visible) has_mouse = true;
- return;
- }
-
- if (hide_mouse)
- visible = false;
-
- assert(w<=BAK_WIDTH && h<=BAK_HEIGHT);
-
- if (has_mouse) {
- int old_h = old_mouse_h;
-
- has_mouse = false;
- AddDirtyRec(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h);
-
- dst = wm->_vgabuf + (old_mouse_y * 320) + old_mouse_x;
- bak = old_backup;
-
- while (old_h > 0) {
- memcpy(dst, bak, old_mouse_w);
- bak += BAK_WIDTH;
- dst += 320;
- old_h--;
- }
- }
-
- if (visible) {
- int real_w;
- int real_h;
- int real_h_2;
- unsigned char *dst2;
-
- 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 = wm->_vgabuf + (ydraw * 320) + xdraw;
- dst2 = dst;
- bak = old_backup;
-
- has_mouse = true;
+ desired.userdata = param;
- AddDirtyRec(xdraw, ydraw, real_w, real_h);
- old_mouse_x = xdraw;
- old_mouse_y = ydraw;
- old_mouse_w = real_w;
- old_mouse_h = real_h;
-
- real_h_2 = real_h;
- while (real_h_2 > 0) {
- memcpy(bak, dst, real_w);
- bak += BAK_WIDTH;
- dst += 320;
- real_h_2--;
- }
- while (real_h > 0) {
- int width = real_w;
- while (width > 0) {
- unsigned char color = *buf;
- if (color != 0xFF) {
- *dst2 = color;
- }
- buf++;
- dst2++;
- width--;
- }
- buf += w - real_w;
- dst2 += 320 - real_w;
- real_h--;
- }
- }
+ return true;
}
+
+// No CD functions to implement
-
-
-BOOL CALLBACK SelectDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch(uMsg)
- {
- case WM_INITDIALOG:
- {
- TCHAR work[1024];
- RECT rc; GetWindowRect(hwndDlg, &rc);
- MoveWindow(hwndDlg,
- (GetSystemMetrics(SM_CXSCREEN)-rc.right+rc.left)/2,
- (GetSystemMetrics(SM_CYSCREEN)-rc.bottom+rc.top)/2,
- rc.right-rc.left, rc.bottom-rc.top, TRUE);
- BringWindowToTop(hwndDlg);
- setFindGameDlgHandle(hwndDlg);
- MultiByteToWideChar(CP_ACP, 0, VERSION, strlen(VERSION) + 1, work, sizeof(work));
- SetDlgItemText(hwndDlg, IDC_GAMEDESC, work);
- loadGameSettings();
- }
- return TRUE;
-
- case WM_COMMAND:
-
- if (LOWORD(wParam) == IDC_LISTAVAILABLE && HIWORD(wParam) == LBN_SELCHANGE)
- displayGameInfo();
-
- if (wParam == IDC_SCAN)
- startFindGame();
-
- if (wParam == IDC_PLAY) {
- int item;
-
- item = SendMessage(GetDlgItem(hwndDlg, IDC_LISTAVAILABLE), LB_GETCURSEL, 0, 0);
- if (item == LB_ERR) {
- MessageBox(hwndDlg, TEXT("Please select a game"), TEXT("Error"), MB_OK);
- }
- else
- EndDialog(hwndDlg, item + 1000);
- }
-
- if (wParam == IDC_EXIT)
- EndDialog(hwndDlg, 0);
- return TRUE;
- default:
- return FALSE;
- }
+bool OSystem_WINCE3::poll_cdrom() {
+ return false;
}
-char* GameSelector()
-{
- TCHAR directory[MAX_PATH];
- static char id[100];
-
- DWORD result = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_GAMESELECT), HWND_DESKTOP, SelectDlgProc);
- if (result < 1000)
- return NULL;
- result -= 1000;
-
- getSelectedGame(result, id, directory);
-
- WideCharToMultiByte(CP_ACP, 0, directory, wcslen(directory) + 1, _directory, sizeof(_directory), NULL, NULL);
-
- strcat(_directory, "\\");
-
- return id;
-
+void OSystem_WINCE3::play_cdrom(int track, int num_loops, int start_frame, int end_frame) {
}
-// Directly corresponds to main in windows.cpp
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
-{
- int delta;
- int tmp;
-
- int argc = 3;
- char* argv[3];
- char argdir[MAX_PATH];
- IMuse *se;
-
- sound_activated = true;
- hide_toolbar = false;
-
- argv[0] = NULL;
- argv[1] = GameSelector();
- sprintf(argdir, "-p%s", _directory);
- argv[2] = argdir;
- scumm._savegame_dir = _directory;
-// scumm._error_handler = error_handler;
-
- if(argv[1] == NULL)
- return 0;
-
- wm->init();
- wm->_vgabuf = (byte*)calloc(320,200);
- wm->_scumm = &scumm;
-
- sound.initialize(&scumm, &snd_driv);
- scumm._soundsPaused = false;
- scumm._soundsPaused2 = false;
-
- scumm._gui = &gui;
-
- scumm.scummMain(argc, argv);
- gui.init(&scumm);
-
- keypad_init();
- registry_init();
-
- se = scumm._imuse;
- se->set_music_volume(scumm._sound_volume_music);
- se->set_master_volume(scumm._sound_volume_master);
-
- delta = 0;
- tmp = 0;
- do
- {
- updateScreen(&scumm);
+void OSystem_WINCE3::stop_cdrom() {
+}
- waitForTimer(&scumm, tmp*10);
+void OSystem_WINCE3::update_cdrom() {
+}
- if(gui._active)
- {
- gui.loop();
- tmp = 5;
- }
- else
- {
- tmp = delta = scumm.scummLoop(delta);
+void OSystem_WINCE3::quit() {
+ do_quit();
+}
- tmp += tmp>>1;
-
- if(scumm._fastMode)
- tmp=1;
- }
+uint32 OSystem_WINCE3::property(int param, uint32 value) {
+ switch(param) {
+ case PROP_GET_SAMPLE_RATE:
+ return 11025;
}
- while(1);
return 0;
}
-/* Unsupported funcs */
-
-// TODO : implement
-void setShakePos(Scumm *s, int shake_pos) {}
-// TODO : switch to MP3 support
-void cd_playtrack(int track, int offset, int delay) {}
-
-// Never happening on Pocket version
+OSystem *OSystem_NULL_create() {
+ return NULL;
+}
-void launcherLoop() {;}
-void cd_playtrack(int track, int offset, int delay) {;}
-void cd_play(int track, int num_loops, int start_frame) {;}
-void cd_stop() {;}
-int cd_is_running() {return 0;} \ No newline at end of file
+void ScummDebugger::attach(Scumm *s) {
+}