From 7e50df392b0ee52b14118f51e3bc9805ec2c03a6 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 6 Aug 1994 11:22:41 +0000 Subject: [PATCH] Release 940804 Thu Aug 4 07:18:02 1994 Michael Patra * [windows/message.c] Implemented WaitMessage() (USER.112). * [if1632/user.spec] Added WaitMessage. * [windows/defwnd.c] WM_ERASEBKGND: Added support for hbrBackground=COLOR_xxx. * [miscemu/int{13,21,2a}.c] * [miscemu/Imakefile] * [signal/loader.c] Added a few basic disk information and diagnostic functions to prevent programs using this function from crashing. All drives are claimed to be remote ones, so direct I/O isn't allowed. * [controls/edit.c] EDIT_WriteText(): Added code to correctly erase the remaining space of the edit-control if the size of the control has changed sinced it's creation. Tue Jul 26 22:05:54 MET DST 1994 Erik Bos * [if1632/mouse.spec] Added mouse.dll entry, no functions. * [loader/resource.c] Bug fix in AccessResource(). * [misc/keyboard.c], added [include/keyboard.h] Changed functions to return more useful values. * [windows/dialog.c] Hacked DIALOG_GetControl() to support resources which have 0xff00 - 0xffff as id. ** Needs to be done properly by someone who knows the NE fileformat ** Jul 29, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [windows/event.c] Add new stub for EnableHGardwareInput() function. * [windows/message.c] Add coding for HWND_BROADCAST in PostMessage(). * [misc/file.c] Add coding for OpenFile() also search in WindowPaths. * [misc/mmsystem.c] * [misc/audio.c] * [misc/mmaux.c] * [misc/mcicda.c] Change #include "linux/soundcard.h" by #include "sys/soundcard.h" Add coding in MMIO functions. Now, mmioDescend() can find WAV chunks. SndPlaySound & MCI_ELEMENT now use MMIO and adjust to proper formats. --- ChangeLog | 58 +++++++++++++ controls/edit.c | 8 ++ controls/static.c | 2 +- debugger/dbg.y | 2 +- if1632/Imakefile | 2 + if1632/mouse.spec | 11 +++ if1632/relay.c | 1 + if1632/user.spec | 18 ++-- include/dlls.h | 3 +- include/keyboard.h | 114 +++++++++++++++++++++++++ include/mmsystem.h | 4 + loader/resource.c | 8 +- loader/signal.c | 2 + misc/audio.c | 74 +++++++++++++--- misc/driver.c | 43 ++++++++-- misc/file.c | 25 +++++- misc/keyboard.c | 130 +++++++++++++++------------- misc/mcicda.c | 17 ++-- misc/mmaux.c | 9 +- misc/mmsystem.c | 246 +++++++++++++++++++++++++++++++++++++++++++---------- miscemu/Imakefile | 2 + miscemu/int13.c | 54 ++++++++++++ miscemu/int1a.c | 8 ++ miscemu/int21.c | 14 ++- miscemu/int2a.c | 17 ++++ miscemu/int2f.c | 4 + windows/defwnd.c | 14 ++- windows/dialog.c | 24 ++++-- windows/event.c | 14 +++ windows/message.c | 91 ++++++++++++++++++-- 30 files changed, 857 insertions(+), 162 deletions(-) create mode 100644 if1632/mouse.spec create mode 100644 include/keyboard.h create mode 100644 miscemu/int13.c create mode 100644 miscemu/int2a.c diff --git a/ChangeLog b/ChangeLog index e1c6f0a8b02..59d5518746c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,62 @@ ---------------------------------------------------------------------- +Thu Aug 4 07:18:02 1994 Michael Patra + + * [windows/message.c] + Implemented WaitMessage() (USER.112). + + * [if1632/user.spec] + Added WaitMessage. + + * [windows/defwnd.c] + WM_ERASEBKGND: Added support for hbrBackground=COLOR_xxx. + + * [miscemu/int{13,21,2a}.c] + * [miscemu/Imakefile] + * [signal/loader.c] + Added a few basic disk information and diagnostic functions to + prevent programs using this function from crashing. All drives + are claimed to be remote ones, so direct I/O isn't allowed. + + * [controls/edit.c] + EDIT_WriteText(): Added code to correctly erase the remaining space + of the edit-control if the size of the control has changed sinced it's + creation. + +Tue Jul 26 22:05:54 MET DST 1994 Erik Bos + + * [if1632/mouse.spec] + Added mouse.dll entry, no functions. + + * [loader/resource.c] + Bug fix in AccessResource(). + + * [misc/keyboard.c], added [include/keyboard.h] + Changed functions to return more useful values. + + * [windows/dialog.c] + Hacked DIALOG_GetControl() to support resources which + have 0xff00 - 0xffff as id. ** Needs to be done properly by + someone who knows the NE fileformat ** + +Jul 29, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) + + * [windows/event.c] + Add new stub for EnableHGardwareInput() function. + + * [windows/message.c] + Add coding for HWND_BROADCAST in PostMessage(). + + * [misc/file.c] + Add coding for OpenFile() also search in WindowPaths. + + * [misc/mmsystem.c] + * [misc/audio.c] + * [misc/mmaux.c] + * [misc/mcicda.c] + Change #include "linux/soundcard.h" by #include "sys/soundcard.h" + Add coding in MMIO functions. Now, mmioDescend() can find WAV chunks. + SndPlaySound & MCI_ELEMENT now use MMIO and adjust to proper formats. +---------------------------------------------------------------------- Mon Jul 18 23:55:13 MET DST 1994 * [if1632/call.S] diff --git a/controls/edit.c b/controls/edit.c index 977923073f1..7f00cb85589 100644 --- a/controls/edit.c +++ b/controls/edit.c @@ -1026,6 +1026,14 @@ void EDIT_WriteText(HWND hwnd, char *lp, int off, int len, int row, SetTextColor(hdc, oldBkgdColor); } + if (strlen(blanks) < (ClientWidth(wndPtr) / charWidths[32]) + 2) + { + es->hBlankLine = EDIT_HeapReAlloc(hwnd, es->hBlankLine, + (ClientWidth(wndPtr) / charWidths[32]) + 2); + blanks = EDIT_HeapAddr(hwnd, es->hBlankLine); + memset(blanks, ' ', (ClientWidth(wndPtr) / charWidths[32]) + 2); + } + if (!(cp = strchr(str, VK_TAB))) TextOut(hdc, col - diff, row * es->txtht, str, strlen(str)); else diff --git a/controls/static.c b/controls/static.c index a78fd770412..0f8419532b6 100644 --- a/controls/static.c +++ b/controls/static.c @@ -292,7 +292,7 @@ static LONG PaintIconfn(HWND hwnd) GetClientRect(hwnd, &rc); FillRect(hdc, &rc, GetStockObject(WHITE_BRUSH)); textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText); - printf("SS_ICON : textPtr='%s' / left=%d top=%d right=%d bottom=%d \n", + printf("SS_ICON : textPtr='%8x' / left=%d top=%d right=%d bottom=%d \n", textPtr, rc.left, rc.top, rc.right, rc.bottom); /* SetWindowPos(hwnd, (HWND)NULL, 0, 0, 32, 32, diff --git a/debugger/dbg.y b/debugger/dbg.y index b4783089382..907fd0fde43 100644 --- a/debugger/dbg.y +++ b/debugger/dbg.y @@ -147,11 +147,11 @@ static int loaded_symbols = 0; void wine_debug(int signal, int * regs) { + static int dummy_regs[32]; int i; #ifdef YYDEBUG yydebug = 0; #endif - static int dummy_regs[32]; yyin = stdin; regval = regs ? regs : dummy_regs; diff --git a/if1632/Imakefile b/if1632/Imakefile index f686a92c522..cc922a05a4a 100644 --- a/if1632/Imakefile +++ b/if1632/Imakefile @@ -19,6 +19,7 @@ DLLOBJS = \ dll_kernel.o \ dll_keyboard.o \ dll_mmsystem.o \ + dll_mouse.o \ dll_shell.o \ dll_sound.o \ dll_stress.o \ @@ -49,6 +50,7 @@ MakeDllFromSpec(kernel,$(TOP)/$(MODULE)) MakeDllFromSpec(keyboard,$(TOP)/$(MODULE)) MakeDllFromSpec(shell,$(TOP)/$(MODULE)) MakeDllFromSpec(mmsystem,$(TOP)/$(MODULE)) +MakeDllFromSpec(mouse,$(TOP)/$(MODULE)) MakeDllFromSpec(sound,$(TOP)/$(MODULE)) MakeDllFromSpec(stress,$(TOP)/$(MODULE)) MakeDllFromSpec(system,$(TOP)/$(MODULE)) diff --git a/if1632/mouse.spec b/if1632/mouse.spec new file mode 100644 index 00000000000..6d1526870ba --- /dev/null +++ b/if1632/mouse.spec @@ -0,0 +1,11 @@ +name mouse +id 14 +length 8 + +#1 pascal INQUIRE +#2 pascal ENABLE +#3 pascal DISABLE +#4 pascal MOUSEGETINTVECT +#5 pascal GETSETMOUSEDATA +#6 pascal CPLAPPLET +#7 pascal POWEREVENTPROC diff --git a/if1632/relay.c b/if1632/relay.c index 9de76558c71..070a58a2f6d 100644 --- a/if1632/relay.c +++ b/if1632/relay.c @@ -45,6 +45,7 @@ struct dll_name_table_entry_s dll_builtin_table[N_BUILTINS] = { "MMSYSTEM",WineLibSkip(MMSYSTEM_table),1226,11}, { "SYSTEM", WineLibSkip(SYSTEM_table), 20 ,12}, { "TOOLHELP",WineLibSkip(TOOLHELP_table), 83, 13}, + { "MOUSE", WineLibSkip(MOUSE_table), 8, 14}, }; /* don't forget to increase N_BUILTINS in dll.h if you add a dll */ diff --git a/if1632/user.spec b/if1632/user.spec index a8e55975832..88c5d9de110 100644 --- a/if1632/user.spec +++ b/if1632/user.spec @@ -115,7 +115,7 @@ length 540 109 pascal PeekMessage(ptr word word word word) PeekMessage(1 2 3 4 5) 110 pascal PostMessage(word word word long) PostMessage(1 2 3 4) 111 pascal SendMessage(word word word long) SendMessage(1 2 3 4) -#112 WAITMESSAGE +112 pascal WaitMessage() WaitMessage() 113 pascal TranslateMessage(ptr) TranslateMessage(1) 114 pascal DispatchMessage(ptr) DispatchMessage(1) #115 REPLYMESSAGE @@ -261,13 +261,13 @@ length 540 248 pascal GetOpenClipboardWindow() GetOpenClipboardWindow() 249 pascal GetAsyncKeyState(word) GetAsyncKeyState(1) 250 pascal GetMenuState(word word word) GetMenuState(1 2 3) -#251 SENDDRIVERMESSAGE -#252 OPENDRIVER -#253 CLOSEDRIVER -#254 GETDRIVERMODULEHANDLE -#255 DEFDRIVERPROC -#256 GETDRIVERINFO -#257 GETNEXTDRIVER +251 pascal SendDriverMessage(word word long long) SendDriverMessage(1 2 3 4) +252 pascal OpenDriver(ptr ptr long) OpenDriver(1 2 3) +253 pascal CloseDriver(word word long) CloseDriver(1 2 3) +254 pascal GetDriverModuleHandle(word) GetDriverModuleHandle(1) +255 pascal DefDriverProc(long word word long long) DefDriverProc(1 2 3 4 5) +256 pascal GetDriverInfo(word ptr) GetDriverInfo(1 2) +257 pascal GetNextDriver(word long) GetNextDriver(1 2) 258 pascal MapWindowPoints(word word ptr word) MapWindowPoints(1 2 3 4) #259 BEGINDEFERWINDOWPOS #260 DEFERWINDOWPOS @@ -319,7 +319,7 @@ length 540 324 pascal FillWindow(word word word word) FillWindow(1 2 3 4) 325 pascal PaintRect(word word word word ptr) PaintRect(1 2 3 4 5) #326 GETCONTROLBRUSH -#331 ENABLEHARDWAREINPUT +331 pascal EnableHardwareInput(word) EnableHardwareInput(1) 332 return UserYield 0 0 #333 ISUSERIDLE 334 pascal GetQueueStatus(word) GetQueueStatus(1) diff --git a/include/dlls.h b/include/dlls.h index 979695570c9..292b57f2b5d 100644 --- a/include/dlls.h +++ b/include/dlls.h @@ -96,7 +96,8 @@ extern struct dll_table_entry_s WINSOCK_table[]; extern struct dll_table_entry_s STRESS_table[]; extern struct dll_table_entry_s SYSTEM_table[]; extern struct dll_table_entry_s TOOLHELP_table[]; +extern struct dll_table_entry_s MOUSE_table[]; -#define N_BUILTINS 13 +#define N_BUILTINS 14 #endif /* DLLS_H */ diff --git a/include/keyboard.h b/include/keyboard.h new file mode 100644 index 00000000000..c9f784f859f --- /dev/null +++ b/include/keyboard.h @@ -0,0 +1,114 @@ +#ifndef __WINE_KEYBOARD_H +#define __WINE_KEYBOARD_H + +struct KeyTableEntry { + int virtualkey; + int ASCII; + int scancode; + char *name; +}; + +struct KeyTableEntry KeyTable[] = { + { 0x3, 0x3, 0x0, "" }, + { 0x8, 0x8, 0xe, "Backspace" }, + { 0x9, 0x9, 0xf, "Tab" }, + { 0xc, 0x0, 0x4c, "Num 5" }, + { 0xd, 0xd, 0x1c, "Enter" }, + { 0x10, 0x0, 0x2a, "Shift" }, + { 0x11, 0x0, 0x1d, "Ctrl" }, + { 0x12, 0x0, 0x38, "Alt" }, + { 0x14, 0x0, 0x3a, "Caps Lock" }, + { 0x1b, 0x1b, 0x1, "Esc" }, + { 0x20, 0x20, 0x39, "Space" }, + { 0x21, 0x0, 0x49, "Num 9" }, + { 0x22, 0x0, 0x51, "Num 3" }, + { 0x23, 0x0, 0x4f, "Num 1" }, + { 0x24, 0x0, 0x47, "Num 7" }, + { 0x25, 0x0, 0x4b, "Num 4" }, + { 0x26, 0x0, 0x48, "Num 8" }, + { 0x27, 0x0, 0x4d, "Num 6" }, + { 0x28, 0x0, 0x50, "Num 2" }, + { 0x2d, 0x0, 0x52, "Num 0" }, + { 0x2e, 0x0, 0x53, "Num Del" }, + { 0x30, 0x30, 0xb, "0" }, + { 0x31, 0x31, 0x2, "1" }, + { 0x32, 0x32, 0x3, "2" }, + { 0x33, 0x33, 0x4, "3" }, + { 0x34, 0x34, 0x5, "4" }, + { 0x35, 0x35, 0x6, "5" }, + { 0x36, 0x36, 0x7, "6" }, + { 0x37, 0x37, 0x8, "7" }, + { 0x38, 0x38, 0x9, "8" }, + { 0x39, 0x39, 0xa, "9" }, + { 0x41, 0x41, 0x1e, "A" }, + { 0x42, 0x42, 0x30, "B" }, + { 0x43, 0x43, 0x2e, "C" }, + { 0x44, 0x44, 0x20, "D" }, + { 0x45, 0x45, 0x12, "E" }, + { 0x46, 0x46, 0x21, "F" }, + { 0x47, 0x47, 0x22, "G" }, + { 0x48, 0x48, 0x23, "H" }, + { 0x49, 0x49, 0x17, "I" }, + { 0x4a, 0x4a, 0x24, "J" }, + { 0x4b, 0x4b, 0x25, "K" }, + { 0x4c, 0x4c, 0x26, "L" }, + { 0x4d, 0x4d, 0x32, "M" }, + { 0x4e, 0x4e, 0x31, "N" }, + { 0x4f, 0x4f, 0x18, "O" }, + { 0x50, 0x50, 0x19, "P" }, + { 0x51, 0x51, 0x10, "Q" }, + { 0x52, 0x52, 0x13, "R" }, + { 0x53, 0x53, 0x1f, "S" }, + { 0x54, 0x54, 0x14, "T" }, + { 0x55, 0x55, 0x16, "U" }, + { 0x56, 0x56, 0x2f, "V" }, + { 0x57, 0x57, 0x11, "W" }, + { 0x58, 0x58, 0x2d, "X" }, + { 0x59, 0x59, 0x15, "Y" }, + { 0x5a, 0x5a, 0x2c, "Z" }, + { 0x60, 0x0, 0x52, "Num 0" }, + { 0x61, 0x0, 0x4f, "Num 1" }, + { 0x62, 0x0, 0x50, "Num 2" }, + { 0x63, 0x0, 0x51, "Num 3" }, + { 0x64, 0x0, 0x4b, "Num 4" }, + { 0x65, 0x0, 0x4c, "Num 5" }, + { 0x66, 0x0, 0x4d, "Num 6" }, + { 0x67, 0x0, 0x47, "Num 7" }, + { 0x68, 0x0, 0x48, "Num 8" }, + { 0x69, 0x0, 0x49, "Num 9" }, + { 0x6a, 0x2a, 0x37, "Num *" }, + { 0x6b, 0x2b, 0x4e, "Num +" }, + { 0x6c, 0x0, 0x0, "" }, + { 0x6d, 0x2d, 0x4a, "Num -" }, + { 0x6e, 0x2e, 0x53, "Num Del" }, + { 0x6f, 0x2f, 0x0, "" }, + { 0x70, 0x0, 0x3b, "F1" }, + { 0x71, 0x0, 0x3c, "F2" }, + { 0x72, 0x0, 0x3d, "F3" }, + { 0x73, 0x0, 0x3e, "F4" }, + { 0x74, 0x0, 0x3f, "F5" }, + { 0x75, 0x0, 0x40, "F6" }, + { 0x76, 0x0, 0x41, "F7" }, + { 0x77, 0x0, 0x42, "F8" }, + { 0x78, 0x0, 0x43, "F9" }, + { 0x79, 0x0, 0x44, "F10" }, + { 0x7a, 0x0, 0x57, "F11" }, + { 0x7b, 0x0, 0x58, "F12" }, + { 0x90, 0x0, 0x45, "Pause" }, + { 0x91, 0x0, 0x46, "Scroll Lock" }, + { 0xba, 0x3b, 0x27, ";" }, + { 0xbb, 0x3d, 0xd, "=" }, + { 0xbc, 0x2c, 0x33, "," }, + { 0xbd, 0x2d, 0xc, "-" }, + { 0xbe, 0x2e, 0x34, "." }, + { 0xbf, 0x2f, 0x35, "/" }, + { 0xc0, 0x60, 0x29, "`" }, + { 0xdb, 0x5b, 0x1a, "[" }, + { 0xdc, 0x5c, 0x2b, "\\" }, + { 0xdd, 0x5d, 0x1b, "]" }, + { 0xde, 0x27, 0x28, "\'" }, + { 0xe2, 0x5c, 0x56, "\\" }, +}; +#define KeyTableSize sizeof(KeyTable) / sizeof(struct KeyTableEntry) + +#endif /* __WINE_KEYBOARD_H */ diff --git a/include/mmsystem.h b/include/mmsystem.h index feb2eda5614..815f4319c50 100644 --- a/include/mmsystem.h +++ b/include/mmsystem.h @@ -623,6 +623,10 @@ typedef MMCKINFO FAR *LPMMCKINFO; #define MMIO_CREATERIFF 0x0020 /* mmioCreateChunk: make a LIST chunk */ #define MMIO_CREATELIST 0x0040 /* mmioCreateChunk: make a RIFF chunk */ +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + #define MMIOM_READ MMIO_READ /* read */ #define MMIOM_WRITE MMIO_WRITE /* write */ #define MMIOM_SEEK 2 /* seek to a new position in file */ diff --git a/loader/resource.c b/loader/resource.c index 421170453bf..662fa34ce6e 100644 --- a/loader/resource.c +++ b/loader/resource.c @@ -493,7 +493,7 @@ int GetRsrcCount(HINSTANCE hInst, int type_id) off_t rtoff; if (hInst == 0) return 0; #ifdef DEBUG_RESOURCE - printf("GetRsrcCount hInst=%04X typename=%08X\n", hInst, type_name); + printf("GetRsrcCount hInst=%04X typename=%08X\n", hInst, type_id); #endif if (OpenResourceFile(hInst) < 0) return 0; @@ -978,7 +978,7 @@ int AccessResource(HANDLE instance, HANDLE hResInfo) lseek(resfile, ((int) r->nameinfo.offset << r->size_shift), SEEK_SET); GlobalUnlock(hResInfo); - return resfile; + return dup(resfile); } /********************************************************************** @@ -1049,9 +1049,9 @@ RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret) } if (size_shift == -1) { if ((LONG)rsc_name >= 0x00010000L) - printf("RSC_LoadResource / Resource '%s' not Found !\n", rsc_name); + printf("RSC_LoadResource inst (%x)/ Resource '%s' not Found !\n", instance, rsc_name); else - printf("RSC_LoadResource / Resource '%X' not Found !\n", rsc_name); + printf("RSC_LoadResource inst (%x)/ Resource '0x%X' not Found !\n", instance, rsc_name); return 0; } /* diff --git a/loader/signal.c b/loader/signal.c index 9b8e851e148..d9eb7172190 100644 --- a/loader/signal.c +++ b/loader/signal.c @@ -59,6 +59,7 @@ int do_int(int intnum, struct sigcontext_struct *scp) scp->sc_eax = (scp->sc_eax & 0xffff0000L) | 640L; return 1; /* get base mem size */ + case 0x13: return do_int13(scp); case 0x15: return do_int15(scp); case 0x16: return do_int16(scp); case 0x1A: return do_int1A(scp); @@ -73,6 +74,7 @@ int do_int(int intnum, struct sigcontext_struct *scp) case 0x25: return do_int25(scp); case 0x26: return do_int26(scp); + case 0x2a: return do_int2a(scp); case 0x2f: return do_int2f(scp); case 0x31: return do_int31(scp); } diff --git a/misc/audio.c b/misc/audio.c index 98ab81cb001..2d81e375108 100644 --- a/misc/audio.c +++ b/misc/audio.c @@ -3,10 +3,15 @@ * * Copyright 1994 Martin Ayotte */ +static char Copyright[] = "Copyright Martin Ayotte, 1994"; + #ifndef WINELIB -#define DEBUG_MCIWAVE +#define BUILTIN_MMSYSTEM +#endif -static char Copyright[] = "Copyright Martin Ayotte, 1994"; +#ifdef BUILTIN_MMSYSTEM + +#define DEBUG_MCIWAVE #include "stdio.h" #include "win.h" @@ -60,7 +65,7 @@ typedef struct { BOOL fShareable; /* TRUE if first open was shareable */ WORD wNotifyDeviceID; /* MCI device ID with a pending notification */ HANDLE hCallback; /* Callback handle for pending notification */ - int hFile; /* file handle open as Element */ + HMMIO hFile; /* mmio file handle open as Element */ MCI_WAVE_OPEN_PARMS openParms; PCMWAVEFORMAT WaveFormat; WAVEHDR WaveHdr; @@ -207,13 +212,13 @@ DWORD WAVE_mciOpen(DWORD dwFlags, LPMCI_WAVE_OPEN_PARMS lpParms) if (dwFlags & MCI_OPEN_ELEMENT) { printf("WAVE_mciOpen // MCI_OPEN_ELEMENT '%s' !\n", lpParms->lpstrElementName); - printf("WAVE_mciOpen // cdw='%s'\n", DOS_GetCurrentDir(DOS_GetDefaultDrive())); +/* printf("WAVE_mciOpen // cdw='%s'\n", DOS_GetCurrentDir(DOS_GetDefaultDrive())); */ if (strlen(lpParms->lpstrElementName) > 0) { strcpy(str, lpParms->lpstrElementName); AnsiUpper(str); - MCIWavDev[wDevID].hFile = _lopen(str, OF_READWRITE); - if (MCIWavDev[wDevID].hFile < 1) { - MCIWavDev[wDevID].hFile = 0; + MCIWavDev[wDevID].hFile = mmioOpen(str, NULL, + MMIO_ALLOCBUF | MMIO_READWRITE | MMIO_EXCLUSIVE); + if (MCIWavDev[wDevID].hFile == 0) { printf("WAVE_mciOpen // can't find file='%s' !\n", str); return MCIERR_FILE_NOT_FOUND; } @@ -233,6 +238,49 @@ DWORD WAVE_mciOpen(DWORD dwFlags, LPMCI_WAVE_OPEN_PARMS lpParms) lpWaveFormat->wf.nSamplesPerSec = 11025; lpWaveFormat->wf.nAvgBytesPerSec = 11025; lpWaveFormat->wf.nBlockAlign = 1; + if (MCIWavDev[wDevID].hFile != 0) { + MMCKINFO mmckInfo; + MMCKINFO ckMainRIFF; + if (mmioDescend(MCIWavDev[wDevID].hFile, &ckMainRIFF, NULL, 0) != 0) { + return MCIERR_INTERNAL; + } +#ifdef DEBUG_MCIWAVE + printf("WAVE_mciOpen // ParentChunk ckid=%.4s fccType=%.4s cksize=%08lX \n", + (LPSTR)&ckMainRIFF.ckid, (LPSTR)&ckMainRIFF.fccType, + ckMainRIFF.cksize); +#endif + if ((ckMainRIFF.ckid != FOURCC_RIFF) || + (ckMainRIFF.fccType != mmioFOURCC('W', 'A', 'V', 'E'))) { + return MCIERR_INTERNAL; + } + mmckInfo.ckid = mmioFOURCC('f', 'm', 't', ' '); + if (mmioDescend(MCIWavDev[wDevID].hFile, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK) != 0) { + return MCIERR_INTERNAL; + } +#ifdef DEBUG_MCIWAVE + printf("WAVE_mciOpen // Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX \n", + (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, + mmckInfo.cksize); +#endif + if (mmioRead(MCIWavDev[wDevID].hFile, (HPSTR) lpWaveFormat, + (long) sizeof(PCMWAVEFORMAT)) != (long) sizeof(PCMWAVEFORMAT)) { + return MCIERR_INTERNAL; + } + mmckInfo.ckid = mmioFOURCC('d', 'a', 't', 'a'); + if (mmioDescend(MCIWavDev[wDevID].hFile, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK) != 0) { + return MCIERR_INTERNAL; + } +#ifdef DEBUG_MCIWAVE + printf("WAVE_mciOpen // Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX \n", + (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, + mmckInfo.cksize); + printf("WAVE_mciOpen // nChannels=%d nSamplesPerSec=%d\n", + lpWaveFormat->wf.nChannels, lpWaveFormat->wf.nSamplesPerSec); +#endif + lpWaveFormat->wBitsPerSample = 0; + } + lpWaveFormat->wf.nAvgBytesPerSec = + lpWaveFormat->wf.nSamplesPerSec * lpWaveFormat->wf.nBlockAlign; dwRet = wodMessage(0, WODM_OPEN, 0, (DWORD)&WaveDesc, CALLBACK_NULL); dwRet = widMessage(0, WIDM_OPEN, 0, (DWORD)&WaveDesc, CALLBACK_NULL); return 0; @@ -318,20 +366,18 @@ DWORD WAVE_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms) lpWaveHdr->dwFlags = 0L; lpWaveHdr->dwLoops = 0L; dwRet = wodMessage(0, WODM_PREPARE, 0, (DWORD)lpWaveHdr, sizeof(WAVEHDR)); - printf("WAVE_mciPlay // after WODM_PREPARE \n"); +/* printf("WAVE_mciPlay // after WODM_PREPARE \n"); */ while(TRUE) { -/* printf("WAVE_mciPlay // before 'read' hFile=%u lpData=%08X dwBufferLength=%u\n", - MCIWavDev[wDevID].hFile, lpWaveHdr->lpData, lpWaveHdr->dwBufferLength); */ - count = _lread(MCIWavDev[wDevID].hFile, lpWaveHdr->lpData, lpWaveHdr->dwBufferLength); + count = mmioRead(MCIWavDev[wDevID].hFile, lpWaveHdr->lpData, lpWaveHdr->dwBufferLength); if (count < 1) break; lpWaveHdr->dwBytesRecorded = count; +#ifdef DEBUG_MCIWAVE printf("WAVE_mciPlay // before WODM_WRITE lpWaveHdr=%08X dwBytesRecorded=%u\n", lpWaveHdr, lpWaveHdr->dwBytesRecorded); +#endif dwRet = wodMessage(0, WODM_WRITE, 0, (DWORD)lpWaveHdr, sizeof(WAVEHDR)); } - printf("WAVE_mciPlay // before WODM_UNPREPARE \n"); dwRet = wodMessage(0, WODM_UNPREPARE, 0, (DWORD)lpWaveHdr, sizeof(WAVEHDR)); - printf("WAVE_mciPlay // after WODM_UNPREPARE \n"); if (lpWaveHdr->lpData != NULL) { free(lpWaveHdr->lpData); lpWaveHdr->lpData = NULL; @@ -1642,4 +1688,4 @@ DWORD modMessage(WORD wDevID, WORD wMsg, DWORD dwUser, return MMSYSERR_NOTENABLED; } -#endif /* !WINELIB */ +#endif /* #ifdef BUILTIN_MMSYSTEM */ diff --git a/misc/driver.c b/misc/driver.c index 28888b5245f..436daf74f6b 100644 --- a/misc/driver.c +++ b/misc/driver.c @@ -15,6 +15,26 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994"; LPDRIVERITEM lpDrvItemList = NULL; +void LoadStartupDrivers() +{ + HDRVR hDrv; + char str[256]; + LPSTR ptr = str; + LPSTR file = "SYSTEM.INI"; + if (GetPrivateProfileString("drivers", NULL, + "", str, sizeof(str), file) < 2) { + printf("LoadStartupDrivers // can't find drivers section in '%s'\n", file); + return; + } + while(strlen(ptr) != 0) { + printf("LoadStartupDrivers // str='%s'\n", ptr); + hDrv = OpenDriver(ptr, "drivers", 0L); + printf("LoadStartupDrivers // hDrv=%04X\n", hDrv); + ptr += strlen(ptr) + 1; + } + printf("LoadStartupDrivers // end of list !\n"); +} + /************************************************************************** * SendDriverMessage [USER.251] */ @@ -48,12 +68,13 @@ HDRVR OpenDriver(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam) lpnewdrv = (LPDRIVERITEM) GlobalLock(hDrvr); if (lpnewdrv == NULL) return 0; lpnewdrv->dis.length = sizeof(DRIVERINFOSTRUCT); - lpnewdrv->dis.hModule = LoadImage("DrvName", DLL, 0); + lpnewdrv->dis.hModule = 0; +/* lpnewdrv->dis.hModule = LoadImage(DrvName, DLL, 0); if (lpnewdrv->dis.hModule == 0) { GlobalUnlock(hDrvr); GlobalFree(hDrvr); return 0; - } + } */ lpnewdrv->dis.hDriver = hDrvr; strcpy(lpnewdrv->dis.szAliasName, lpDriverName); lpnewdrv->count = 0; @@ -165,18 +186,30 @@ HDRVR GetNextDriver(HDRVR hDrvr, DWORD dwFlags) LPDRIVERITEM lpdrv; HDRVR hRetDrv = 0; printf("GetNextDriver(%04X, %08X);\n", hDrvr, dwFlags); + if (hDrvr == 0) { + if (lpDrvItemList == NULL) { + printf("GetNextDriver // drivers list empty !\n"); + LoadStartupDrivers(); + if (lpDrvItemList == NULL) return 0; + } + printf("GetNextDriver // return first %04X !\n", + lpDrvItemList->dis.hDriver); + return lpDrvItemList->dis.hDriver; + } lpdrv = (LPDRIVERITEM) GlobalLock(hDrvr); if (lpdrv != NULL) { - if (dwFlags & GND_REVERSE) + if (dwFlags & GND_REVERSE) { if (lpdrv->lpPrevItem) hRetDrv = ((LPDRIVERITEM)lpdrv->lpPrevItem)->dis.hDriver; - if (dwFlags & GND_FORWARD) + } + else { if (lpdrv->lpNextItem) hRetDrv = ((LPDRIVERITEM)lpdrv->lpNextItem)->dis.hDriver; + } GlobalUnlock(hDrvr); } + printf("GetNextDriver // return %04X !\n", hRetDrv); return hRetDrv; - } diff --git a/misc/file.c b/misc/file.c index 29ed1734b11..92359fd6487 100644 --- a/misc/file.c +++ b/misc/file.c @@ -28,6 +28,7 @@ /* #define DEBUG_FILE /* */ char WindowsDirectory[256], SystemDirectory[256], TempDirectory[256]; +extern char WindowsPath[256]; /*************************************************************************** _lopen @@ -123,9 +124,10 @@ INT OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle) { int base, flags; int handle; + char buf[256]; #ifdef DEBUG_FILE - fprintf(stderr,"Openfile(%s,,%d) ",lpFileName,wStyle); + fprintf(stderr,"OpenFile(%s,,%04X)\n",lpFileName,wStyle); #endif base = wStyle & 0xF; @@ -150,6 +152,12 @@ INT OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle) { printf("OpenFile // OF_EXIST '%s' !\n", lpFileName); handle = _lopen (lpFileName, wStyle); + if (handle == -1) { + /* Try again with WindowsPath */ + if (FindFile(buf, sizeof(buf), lpFileName, NULL, WindowsPath) != NULL) { + handle = _lopen (buf, wStyle); + } + } close(handle); return handle; } @@ -160,12 +168,21 @@ INT OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle) } else { - int handle; - char *UnixFileName; - + int handle; + char *UnixFileName; if ((UnixFileName = GetUnixFileName(lpFileName)) == NULL) return HFILE_ERROR; handle = open(UnixFileName, base, 0666); + if (handle == -1) { + /* Try again with WindowsPath */ + if (FindFile(buf, sizeof(buf), lpFileName, NULL, WindowsPath) != NULL) { +#ifdef DEBUG_FILE + printf("OpenFile // file '%s' found !\n", buf); +#endif + UnixFileName = buf; + handle = open(UnixFileName, base, 0666); + } + } #ifdef DEBUG_FILE fprintf(stderr, "OpenFile: returning %04.4x\n", handle); diff --git a/misc/keyboard.c b/misc/keyboard.c index 178a74fbc6c..d7c9ce274ad 100644 --- a/misc/keyboard.c +++ b/misc/keyboard.c @@ -1,49 +1,53 @@ static char RCSId[] = "$Id: keyboard.c,v 1.2 1993/09/13 18:52:02 scott Exp $"; -static char Copyright[] = "Copyright Scott A. Laird, 1993"; +static char Copyright[] = "Copyright Scott A. Laird, Erik Bos 1993, 1994"; #include #include #include "prototypes.h" #include "windows.h" +#include "keyboard.h" int ToAscii(WORD wVirtKey, WORD wScanCode, LPSTR lpKeyState, - LPVOID lpChar, WORD wFlags) + LPVOID lpChar, WORD wFlags) { - printf("ToAscii (%d,%d)\n",wVirtKey, wScanCode); - return -1; -} + int i; -#ifdef BOGUS_ANSI_OEM + printf("ToAscii (%d,%d)\n",wVirtKey, wScanCode); -int AnsiToOem(LPSTR lpAnsiStr, LPSTR lpOemStr) -{ - printf("AnsiToOem (%s)\n",lpAnsiStr); - strcpy(lpOemStr,lpAnsiStr); /* Probably not the right thing to do, but... */ - return -1; -} + /* FIXME: this is not sufficient but better than returing -1 */ -BOOL OemToAnsi(LPSTR lpOemStr, LPSTR lpAnsiStr) -{ - printf("OemToAnsi (%s)\n",lpOemStr); - strcpy(lpAnsiStr,lpOemStr); /* Probably not the right thing to do, but... */ - return -1; -} + for (i = 0 ; i != KeyTableSize ; i++) + if (KeyTable[i].virtualkey == wVirtKey) { + *(BYTE*)lpChar++ = *KeyTable[i].name; + *(BYTE*)lpChar = 0; + return 1; + } -#endif + *(BYTE*)lpChar = 0; + return 0; +} DWORD OemKeyScan(WORD wOemChar) { - printf("*OemKeyScan (%d)\n",wOemChar); - return 0; + printf("*OemKeyScan (%d)\n",wOemChar); + + return wOemChar; } /* VkKeyScan translates an ANSI character to a virtual-key and shift code - * for the current keyboard. For now we return -1, which is fail. */ + * for the current keyboard. */ WORD VkKeyScan(WORD cChar) { - printf("VkKeyScan (%d)\n",cChar); - return -1; + int i; + + printf("VkKeyScan (%d)\n",cChar); + + for (i = 0 ; i != KeyTableSize ; i++) + if (KeyTable[i].ASCII == cChar) + return KeyTable[i].virtualkey; + + return -1; } int GetKeyboardType(int nTypeFlag) @@ -61,58 +65,64 @@ int GetKeyboardType(int nTypeFlag) return 12; /* We're doing an 101 for now, so return 12 F-keys */ break; default: - printf(" Unknown type on GetKeyboardType\n"); + fprintf(stderr, "Unknown type on GetKeyboardType\n"); return 0; /* The book says 0 here, so 0 */ } } -/* MapVirtualKey translates keycodes from one format to another. This - * is a total punt. */ +/* MapVirtualKey translates keycodes from one format to another. */ WORD MapVirtualKey(WORD wCode, WORD wMapType) { - printf("*MapVirtualKey(%d,%d)\n",wCode,wMapType); - return 0; + int i; + + switch(wMapType) { + case 0: + for (i = 0 ; i != KeyTableSize ; i++) + if (KeyTable[i].virtualkey == wCode) + return KeyTable[i].scancode; + return 0; + + case 1: + for (i = 0 ; i != KeyTableSize ; i++) + if (KeyTable[i].scancode == wCode) + return KeyTable[i].virtualkey; + return 0; + + case 2: + for (i = 0 ; i != KeyTableSize ; i++) + if (KeyTable[i].virtualkey == wCode) + return KeyTable[i].ASCII; + return 0; + + default: + fprintf(stderr, "MapVirtualKey: unknown wMapType!\n"); + return 0; + } + return 0; } int GetKbCodePage(void) { - printf("GetKbCodePage()\n"); - return 437; /* US -- probably should be 850 from time to time */ + printf("GetKbCodePage()\n"); + return 850; } -/* This should distinguish key names. Maybe later */ - int GetKeyNameText(LONG lParam, LPSTR lpBuffer, int nSize) { - printf("GetKeyNameText(%d,, %d)\n",lParam,nSize); - lpBuffer[0]=0; /* This key has no name */ - return 0; -} + int i; + + printf("GetKeyNameText(%d,, %d)\n",lParam,nSize); -#ifdef BOGUS_ANSI_OEM + lParam >>= 16; + lParam &= 0xff; -void AnsiToOemBuff(LPSTR lpAnsiStr, LPSTR lpOemStr, int nLength) -{ - printf("AnsiToOemBuff(%s,,%d)\n",lpAnsiStr,nLength); - strncpy(lpOemStr,lpAnsiStr,nLength); /* should translate... */ -} + for (i = 0 ; i != KeyTableSize ; i++) + if (KeyTable[i].scancode == lParam) { + strncpy(lpBuffer, KeyTable[i].name, nSize); + return strlen(lpBuffer); + } -void OemToAnsiBuff(LPSTR lpOemStr, LPSTR lpAnsiStr, int nLength) -{ - printf("OemToAnsiBuff(%s,,%d)\n",lpOemStr,nLength); - strncpy(lpAnsiStr,lpOemStr,nLength); /* should translate... */ + *lpBuffer = 0; + return 0; } - -#endif - - - - - - - - - - - diff --git a/misc/mcicda.c b/misc/mcicda.c index c96fb279cd9..93096f28992 100644 --- a/misc/mcicda.c +++ b/misc/mcicda.c @@ -3,9 +3,14 @@ * * Copyright 1994 Martin Ayotte */ -#ifndef WINELIB static char Copyright[] = "Copyright Martin Ayotte, 1994"; +#ifndef WINELIB +#define BUILTIN_MMSYSTEM +#endif + +#ifdef BUILTIN_MMSYSTEM + /* #define DEBUG_CDAUDIO */ @@ -158,7 +163,7 @@ DWORD CDAUDIO_mciGetDevCaps(UINT wDevID, DWORD dwFlags, #endif if (lpParms == NULL) return MCIERR_INTERNAL; if (dwFlags & MCI_GETDEVCAPS_ITEM) { - printf("CDAUDIO_mciGetDevCaps // MCI_GETDEVCAPS_ITEM dwItem=%08X);\n", + printf("CDAUDIO_mciGetDevCaps // MCI_GETDEVCAPS_ITEM dwItem=%08X;\n", lpParms->dwItem); switch(lpParms->dwItem) { case MCI_GETDEVCAPS_CAN_RECORD: @@ -192,7 +197,7 @@ DWORD CDAUDIO_mciGetDevCaps(UINT wDevID, DWORD dwFlags, return MCIERR_UNRECOGNIZED_COMMAND; } } - printf("CDAUDIO_mciGetDevCaps // lpParms->dwReturn=%08X);\n", lpParms->dwReturn); + printf("CDAUDIO_mciGetDevCaps // lpParms->dwReturn=%08X;\n", lpParms->dwReturn); return 0; #else return MCIERR_INTERNAL; @@ -486,6 +491,7 @@ BOOL CDAUDIO_GetTracksInfo(UINT wDevID) if (CDADev[wDevID].nTracks == 0) { if (CDAUDIO_GetNumberOfTracks(wDevID) == (WORD)-1) return FALSE; } + printf("CDAUDIO_GetTracksInfo // nTracks=%u\n", CDADev[wDevID].nTracks); if (CDADev[wDevID].lpdwTrackLen != NULL) free(CDADev[wDevID].lpdwTrackLen); CDADev[wDevID].lpdwTrackLen = (LPDWORD)malloc( @@ -533,6 +539,7 @@ BOOL CDAUDIO_GetTracksInfo(UINT wDevID) } CDADev[wDevID].dwTotalLen = total_length; printf("CDAUDIO_GetTracksInfo // total_len=%u\n", total_length); + fflush(stdout); return TRUE; #else return FALSE; @@ -552,7 +559,7 @@ BOOL CDAUDIO_GetCDStatus(UINT wDevID) #ifdef DEBUG_CDAUDIO printf("CDAUDIO_GetCDStatus // opened or no_media !\n"); #endif - CDADev[wDevID].mode = MCI_MODE_OPEN; + CDADev[wDevID].mode = MCI_MODE_NOT_READY; return TRUE; } switch (CDADev[wDevID].sc.cdsc_audiostatus) { @@ -923,4 +930,4 @@ LRESULT CDAUDIO_DriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg, /*-----------------------------------------------------------------------*/ -#endif +#endif /* #ifdef BUILTIN_MMSYSTEM */ diff --git a/misc/mmaux.c b/misc/mmaux.c index a83bf459b1b..36a2d740b48 100644 --- a/misc/mmaux.c +++ b/misc/mmaux.c @@ -3,9 +3,14 @@ * * Copyright 1994 Martin Ayotte */ -#ifndef WINELIB static char Copyright[] = "Copyright Martin Ayotte, 1994"; +#ifndef WINELIB +#define BUILTIN_MMSYSTEM +#endif + +#ifdef BUILTIN_MMSYSTEM + #include "stdio.h" #include "win.h" #include "user.h" @@ -128,4 +133,4 @@ DWORD auxMessage(WORD wDevID, WORD wMsg, DWORD dwUser, } -#endif /* !WINELIB */ +#endif /* #ifdef BUILTIN_MMSYSTEM */ diff --git a/misc/mmsystem.c b/misc/mmsystem.c index 0e1eb91b9d6..ef8d5ca28e0 100644 --- a/misc/mmsystem.c +++ b/misc/mmsystem.c @@ -3,9 +3,10 @@ * * Copyright 1993 Martin Ayotte */ -#ifndef WINELIB static char Copyright[] = "Copyright Martin Ayotte, 1993"; +#ifndef WINELIB + #include "stdio.h" #include #include @@ -38,6 +39,8 @@ static MCI_OPEN_DRIVER_PARMS mciDrv[MAXMCIDRIVERS]; UINT WINAPI midiGetErrorText(UINT uError, LPSTR lpText, UINT uSize); UINT WINAPI waveGetErrorText(UINT uError, LPSTR lpText, UINT uSize); +LRESULT DrvDefDriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg, + DWORD dwParam1, DWORD dwParam2); /************************************************************************** @@ -55,66 +58,91 @@ int MMSYSTEM_WEP(HANDLE hInstance, WORD wDataSeg, */ BOOL WINAPI sndPlaySound(LPCSTR lpszSoundName, UINT uFlags) { - int hFile; - int count; - WAVEHDR WaveHdr; - PCMWAVEFORMAT WaveFormat; + HMMIO hmmio; + MMCKINFO mmckInfo; + MMCKINFO ckMainRIFF; + PCMWAVEFORMAT pcmWaveFormat; + int count; + WAVEHDR WaveHdr; WAVEOPENDESC WaveDesc; - DWORD dwRet; - char str[128]; - LPSTR ptr; + DWORD dwRet; + char str[128]; + LPSTR ptr; printf("sndPlaySound // SoundName='%s' uFlags=%04X !\n", lpszSoundName, uFlags); if (lpszSoundName == NULL) { printf("sndPlaySound // Stop !\n"); return FALSE; } - hFile = open(lpszSoundName, O_RDONLY); - if (hFile == 0) { + hmmio = mmioOpen((LPSTR)lpszSoundName, NULL, + MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); + if (hmmio == 0) { printf("sndPlaySound // searching in SystemSound List !\n"); GetProfileString("Sounds", (LPSTR)lpszSoundName, "", str, sizeof(str)); if (strlen(str) == 0) return FALSE; - if ((ptr = strchr(str, ',')) != NULL) *ptr = '\0'; - hFile = open(str, O_RDONLY); - if (hFile == 0) { + if ( (ptr = (LPSTR)strchr(str, ',')) != NULL) *ptr = '\0'; + hmmio = mmioOpen(str, NULL, MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); + if (hmmio == 0) { printf("sndPlaySound // can't find SystemSound='%s' !\n", str); return FALSE; } } + if (mmioDescend(hmmio, &ckMainRIFF, NULL, 0) != 0) { +ErrSND: if (hmmio != 0) mmioClose(hmmio, 0); + return FALSE; + } + printf("sndPlaySound // ParentChunk ckid=%.4s fccType=%.4s cksize=%08lX \n", + (LPSTR)&ckMainRIFF.ckid, (LPSTR)&ckMainRIFF.fccType, + ckMainRIFF.cksize); + if ((ckMainRIFF.ckid != FOURCC_RIFF) || + (ckMainRIFF.fccType != mmioFOURCC('W', 'A', 'V', 'E'))) goto ErrSND; + mmckInfo.ckid = mmioFOURCC('f', 'm', 't', ' '); + if (mmioDescend(hmmio, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK) != 0) goto ErrSND; + printf("sndPlaySound // Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX \n", + (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, + mmckInfo.cksize); + if (mmioRead(hmmio, (HPSTR) &pcmWaveFormat, + (long) sizeof(PCMWAVEFORMAT)) != (long) sizeof(PCMWAVEFORMAT)) goto ErrSND; + mmckInfo.ckid = mmioFOURCC('d', 'a', 't', 'a'); + if (mmioDescend(hmmio, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK) != 0) goto ErrSND; + printf("sndPlaySound // Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX \n", + (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, + mmckInfo.cksize); WaveDesc.hWave = 0; - WaveDesc.lpFormat = (LPWAVEFORMAT)&WaveFormat; - WaveFormat.wf.wFormatTag = WAVE_FORMAT_PCM; - WaveFormat.wBitsPerSample = 8; - WaveFormat.wf.nChannels = 1; - WaveFormat.wf.nSamplesPerSec = 11025; - WaveFormat.wf.nAvgBytesPerSec = 11025; - WaveFormat.wf.nBlockAlign = 1; + WaveDesc.lpFormat = (LPWAVEFORMAT)&pcmWaveFormat; + pcmWaveFormat.wf.wFormatTag = WAVE_FORMAT_PCM; +/* pcmWaveFormat.wBitsPerSample = 8; + pcmWaveFormat.wf.nChannels = 1; + pcmWaveFormat.wf.nSamplesPerSec = 11025; + pcmWaveFormat.wf.nBlockAlign = 1; */ + pcmWaveFormat.wf.nAvgBytesPerSec = + pcmWaveFormat.wf.nSamplesPerSec * pcmWaveFormat.wf.nBlockAlign; dwRet = wodMessage(0, WODM_OPEN, 0, (DWORD)&WaveDesc, CALLBACK_NULL); if (dwRet != MMSYSERR_NOERROR) { printf("sndPlaySound // can't open WaveOut device !\n"); - return FALSE; + goto ErrSND; } WaveHdr.lpData = (LPSTR) malloc(64000); - WaveHdr.dwBufferLength = 64000; + WaveHdr.dwBufferLength = 32000; WaveHdr.dwUser = 0L; WaveHdr.dwFlags = 0L; WaveHdr.dwLoops = 0L; dwRet = wodMessage(0, WODM_PREPARE, 0, (DWORD)&WaveHdr, sizeof(WAVEHDR)); if (dwRet != MMSYSERR_NOERROR) { printf("sndPlaySound // can't prepare WaveOut device !\n"); - return FALSE; + free(WaveHdr.lpData); + goto ErrSND; } while(TRUE) { - count = read(hFile, WaveHdr.lpData, WaveHdr.dwBufferLength); - if (count == 0) break; + count = mmioRead(hmmio, WaveHdr.lpData, WaveHdr.dwBufferLength); + if (count < 1) break; WaveHdr.dwBytesRecorded = count; wodMessage(0, WODM_WRITE, 0, (DWORD)&WaveHdr, sizeof(WAVEHDR)); } wodMessage(0, WODM_UNPREPARE, 0, (DWORD)&WaveHdr, sizeof(WAVEHDR)); wodMessage(0, WODM_CLOSE, 0, 0L, 0L); free(WaveHdr.lpData); - close(hFile); - + if (hmmio != 0) mmioClose(hmmio, 0); return TRUE; } @@ -561,6 +589,7 @@ msg# 543 : tmsf BOOL WINAPI mciDriverNotify(HWND hWndCallBack, UINT wDevID, UINT wStatus) { printf("mciDriverNotify(%04X, %u, %04X)\n", hWndCallBack, wDevID, wStatus); + if (!IsWindow(hWndCallBack)) return FALSE; PostMessage(hWndCallBack, MM_MCINOTIFY, wStatus, MAKELONG(mciDrv[wDevID].wDeviceID, 0)); return TRUE; @@ -1653,6 +1682,10 @@ WORD FAR PASCAL MMSysTimeCallback(HWND hWnd, WORD wMsg, int nID, DWORD dwTime) if (lpTimer->wCurTime == 0) { lpTimer->wCurTime = lpTimer->wDelay; if (lpTimer->lpFunc != NULL) { +#ifdef DEBUG_MMTIME + printf("MMSysTimeCallback // before CallBack16 !\n"); + fflush(stdout); +#endif #ifdef WINELIB (*lpTimer->lpFunc)(lpTimer->wTimerID, (WORD)0, lpTimer->dwUser, (DWORD)0, (DWORD)0); @@ -1661,12 +1694,17 @@ WORD FAR PASCAL MMSysTimeCallback(HWND hWnd, WORD wMsg, int nID, DWORD dwTime) 0, (int)lpTimer->wTimerID, 0, (int)0, 2, lpTimer->dwUser, 2, 0, 2, 0); #endif +#ifdef DEBUG_MMTIME + printf("MMSysTimeCallback // after CallBack16 !\n"); + fflush(stdout); +#endif } if (lpTimer->wFlags & TIME_ONESHOT) timeKillEvent(lpTimer->wTimerID); } lpTimer = lpTimer->Next; } + return 0; } /************************************************************************** @@ -1727,12 +1765,12 @@ WORD timeSetEvent(WORD wDelay, WORD wResol, lpTimer->Next == lpNewTimer; lpNewTimer->Prev == lpTimer; } - lpNewTimer->Next == NULL; + lpNewTimer->Next = NULL; lpNewTimer->wTimerID = wNewID + 1; lpNewTimer->wCurTime = wDelay; lpNewTimer->wDelay = wDelay; lpNewTimer->wResol = wResol; - lpNewTimer->lpFunc = lpFunc; + lpNewTimer->lpFunc = (FARPROC)lpFunc; lpNewTimer->dwUser = dwUser; lpNewTimer->wFlags = wFlags; return lpNewTimer->wTimerID; @@ -1801,9 +1839,20 @@ DWORD timeGetTime() HMMIO WINAPI mmioOpen(LPSTR szFileName, MMIOINFO FAR* lpmmioinfo, DWORD dwOpenFlags) { int hFile; + HANDLE hmmio; + OFSTRUCT ofs; + LPMMIOINFO lpmminfo; printf("mmioOpen('%s', %08X, %08X);\n", szFileName, lpmmioinfo, dwOpenFlags); - hFile = _lopen(szFileName, dwOpenFlags); - return (HMMIO)hFile; + hFile = OpenFile(szFileName, &ofs, dwOpenFlags); + if (hFile == -1) return 0; + hmmio = GlobalAlloc(GMEM_MOVEABLE, sizeof(MMIOINFO)); + lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); + if (lpmminfo == NULL) return 0; + memset(lpmminfo, 0, sizeof(MMIOINFO)); + lpmminfo->hmmio = hmmio; + lpmminfo->dwReserved2 = MAKELONG(hFile, 0); + GlobalUnlock(hmmio); + return (HMMIO)hmmio; } @@ -1813,8 +1862,13 @@ HMMIO WINAPI mmioOpen(LPSTR szFileName, MMIOINFO FAR* lpmmioinfo, DWORD dwOpenFl */ UINT WINAPI mmioClose(HMMIO hmmio, UINT uFlags) { + LPMMIOINFO lpmminfo; printf("mmioClose(%04X, %04X);\n", hmmio, uFlags); - _lclose(hmmio); + lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); + if (lpmminfo == NULL) return 0; + _lclose(LOWORD(lpmminfo->dwReserved2)); + GlobalUnlock(hmmio); + GlobalFree(hmmio); return 0; } @@ -1825,9 +1879,16 @@ UINT WINAPI mmioClose(HMMIO hmmio, UINT uFlags) */ LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch) { - printf("mmioRead\n"); - _lread(hmmio, pch, cch); - return 0; + int count; + LPMMIOINFO lpmminfo; +#ifdef DEBUG_MMIO + printf("mmioRead(%04X, %08X, %ld);\n", hmmio, pch, cch); +#endif + lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); + if (lpmminfo == NULL) return 0; + count = _lread(LOWORD(lpmminfo->dwReserved2), pch, cch); + GlobalUnlock(hmmio); + return count; } @@ -1837,8 +1898,14 @@ LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch) */ LONG WINAPI mmioWrite(HMMIO hmmio, HPCSTR pch, LONG cch) { - printf("mmioWrite\n"); - return 0; + int count; + LPMMIOINFO lpmminfo; + printf("mmioWrite(%04X, %08X, %ld);\n", hmmio, pch, cch); + lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); + if (lpmminfo == NULL) return 0; + count = _lwrite(LOWORD(lpmminfo->dwReserved2), (LPSTR)pch, cch); + GlobalUnlock(hmmio); + return count; } /************************************************************************** @@ -1846,8 +1913,14 @@ LONG WINAPI mmioWrite(HMMIO hmmio, HPCSTR pch, LONG cch) */ LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, int iOrigin) { - printf("mmioSeek\n"); - return 0; + int count; + LPMMIOINFO lpmminfo; + printf("mmioSeek(%04X, %08X, %d);\n", hmmio, lOffset, iOrigin); + lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); + if (lpmminfo == NULL) return 0; + count = _llseek(LOWORD(lpmminfo->dwReserved2), lOffset, iOrigin); + GlobalUnlock(hmmio); + return count; } /************************************************************************** @@ -1855,16 +1928,25 @@ LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, int iOrigin) */ UINT WINAPI mmioGetInfo(HMMIO hmmio, MMIOINFO FAR* lpmmioinfo, UINT uFlags) { + LPMMIOINFO lpmminfo; printf("mmioGetInfo\n"); + lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); + if (lpmminfo == NULL) return 0; + memcpy(lpmmioinfo, lpmminfo, sizeof(MMIOINFO)); + GlobalUnlock(hmmio); return 0; } /************************************************************************** -* mmioGetInfo [MMSYSTEM.1216] +* mmioSetInfo [MMSYSTEM.1216] */ UINT WINAPI mmioSetInfo(HMMIO hmmio, const MMIOINFO FAR* lpmmioinfo, UINT uFlags) { + LPMMIOINFO lpmminfo; printf("mmioSetInfo\n"); + lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); + if (lpmminfo == NULL) return 0; + GlobalUnlock(hmmio); return 0; } @@ -1883,7 +1965,11 @@ UINT WINAPI mmioSetBuffer(HMMIO hmmio, LPSTR pchBuffer, */ UINT WINAPI mmioFlush(HMMIO hmmio, UINT uFlags) { - printf("mmioFlush\n"); + LPMMIOINFO lpmminfo; + printf("mmioFlush(%04X, %04X)\n", hmmio, uFlags); + lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); + if (lpmminfo == NULL) return 0; + GlobalUnlock(hmmio); return 0; } @@ -1892,7 +1978,22 @@ UINT WINAPI mmioFlush(HMMIO hmmio, UINT uFlags) */ UINT WINAPI mmioAdvance(HMMIO hmmio, MMIOINFO FAR* lpmmioinfo, UINT uFlags) { + int count = 0; + LPMMIOINFO lpmminfo; printf("mmioAdvance\n"); + lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); + if (lpmminfo == NULL) return 0; + if (uFlags == MMIO_READ) { + count = _lread(LOWORD(lpmminfo->dwReserved2), + lpmmioinfo->pchBuffer, lpmmioinfo->cchBuffer); + } + if (uFlags == MMIO_WRITE) { + count = _lwrite(LOWORD(lpmminfo->dwReserved2), + lpmmioinfo->pchBuffer, lpmmioinfo->cchBuffer); + } + lpmmioinfo->pchNext += count; + GlobalUnlock(hmmio); + lpmminfo->lDiskOffset = _llseek(LOWORD(lpmminfo->dwReserved2), 0, SEEK_CUR); return 0; } @@ -1931,7 +2032,66 @@ LRESULT WINAPI mmioSendMessage(HMMIO hmmio, UINT uMessage, UINT WINAPI mmioDescend(HMMIO hmmio, MMCKINFO FAR* lpck, const MMCKINFO FAR* lpckParent, UINT uFlags) { - printf("mmioDescend\n"); + DWORD dwfcc, dwOldPos; + LPMMIOINFO lpmminfo; +#ifdef DEBUG_MMIO + printf("mmioDescend(%04X, %08X, %08X, %04X);\n", + hmmio, lpck, lpckParent, uFlags); +#endif + if (lpck == NULL) return 0; + lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); + if (lpmminfo == NULL) return 0; + dwfcc = lpck->ckid; + dwOldPos = _llseek(LOWORD(lpmminfo->dwReserved2), 0, SEEK_CUR); + if (lpckParent != NULL) { +#ifdef DEBUG_MMIO + printf("mmioDescend // seek inside parent at %ld !\n", lpckParent->dwDataOffset); +#endif + dwOldPos = _llseek(LOWORD(lpmminfo->dwReserved2), + lpckParent->dwDataOffset, SEEK_SET); + } + if ((uFlags & MMIO_FINDCHUNK) || (uFlags & MMIO_FINDRIFF) || + (uFlags & MMIO_FINDLIST)) { +#ifdef DEBUG_MMIO + printf("mmioDescend // MMIO_FINDxxxx dwfcc=%08X !\n", dwfcc); +#endif + while (TRUE) { + if (_lread(LOWORD(lpmminfo->dwReserved2), (LPSTR)lpck, + sizeof(MMCKINFO)) < sizeof(MMCKINFO)) { + _llseek(LOWORD(lpmminfo->dwReserved2), dwOldPos, SEEK_SET); + GlobalUnlock(hmmio); + return MMIOERR_CHUNKNOTFOUND; + } +#ifdef DEBUG_MMIO + printf("mmioDescend // dwfcc=%08X ckid=%08X cksize=%08X !\n", + dwfcc, lpck->ckid, lpck->cksize); +#endif + if (dwfcc == lpck->ckid) break; + dwOldPos += lpck->cksize + 2 * sizeof(DWORD); + if (lpck->ckid == FOURCC_RIFF || lpck->ckid == FOURCC_LIST) + dwOldPos += sizeof(DWORD); + _llseek(LOWORD(lpmminfo->dwReserved2), dwOldPos, SEEK_SET); + } + } + else { + if (_lread(LOWORD(lpmminfo->dwReserved2), (LPSTR)lpck, + sizeof(MMCKINFO)) < sizeof(MMCKINFO)) { + _llseek(LOWORD(lpmminfo->dwReserved2), dwOldPos, SEEK_SET); + GlobalUnlock(hmmio); + return MMIOERR_CHUNKNOTFOUND; + } + } + GlobalUnlock(hmmio); + lpck->dwDataOffset = dwOldPos + 2 * sizeof(DWORD); + if (lpck->ckid == FOURCC_RIFF || lpck->ckid == FOURCC_LIST) + lpck->dwDataOffset += sizeof(DWORD); + lpmminfo->lDiskOffset = _llseek(LOWORD(lpmminfo->dwReserved2), + lpck->dwDataOffset, SEEK_SET); +#ifdef DEBUG_MMIO + printf("mmioDescend // lpck->ckid=%08X lpck->cksize=%ld !\n", + lpck->ckid, lpck->cksize); + printf("mmioDescend // lpck->fccType=%08X !\n", lpck->fccType); +#endif return 0; } @@ -2018,5 +2178,5 @@ LRESULT DrvDefDriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg, } +#endif /* #ifdef WINELIB */ -#endif diff --git a/miscemu/Imakefile b/miscemu/Imakefile index 27798bbe358..7caac55df7c 100644 --- a/miscemu/Imakefile +++ b/miscemu/Imakefile @@ -5,12 +5,14 @@ MODULE = miscemu SRCS = \ emulate.c \ int10.c \ + int13.c \ int15.c \ int16.c \ int1a.c \ int21.c \ int25.c \ int26.c \ + int2a.c \ int2f.c \ int31.c \ ioports.c \ diff --git a/miscemu/int13.c b/miscemu/int13.c new file mode 100644 index 00000000000..55fb5b23e1b --- /dev/null +++ b/miscemu/int13.c @@ -0,0 +1,54 @@ +#include +#include +#include "msdos.h" +#include "wine.h" + +int do_int13(struct sigcontext_struct *context) +{ + switch((context->sc_eax >> 8) & 0xff) + { + case 0x00: /* RESET DISK SYSTEM */ + case 0x04: /* VERIFY DISK SECTOR(S) */ + EAX = (EAX & 0xffff00ff); + break; + + case 0x05: /* FORMAT TRACK */ + EAX = (EAX & 0xffff00ff) | 0x0c; + SetCflag; + break; + + case 0x06: /* FORMAT TRACK AND SET BAD SECTOR FLAGS */ + case 0x07: /* FORMAT DRIVE STARTING AT GIVEN TRACK */ + EAX = (EAX & 0xffff00ff) | 0x0c; + break; + + case 0x08: /* GET DRIVE PARAMETERS */ + EAX = (EAX & 0xffff00ff) | ((EDX & 0x00000080)? 0x07: 0x01); + SetCflag; + break; + + case 0x09: /* INITIALIZE CONTROLLER WITH DRIVE PARAMETERS */ + case 0x0c: /* SEEK TO CYLINDER */ + case 0x0d: /* RESET HARD DISKS */ + case 0x10: /* CHECK IF DRIVE READY */ + case 0x11: /* RECALIBRATE DRIVE */ + case 0x14: /* CONTROLLER INTERNAL DIAGNOSTIC */ + EAX = (EAX & 0xffff00ff); + break; + + case 0x0e: /* READ SECTOR BUFFER (XT only) */ + case 0x0f: /* WRITE SECTOR BUFFER (XT only) */ + case 0x12: /* CONTROLLER RAM DIAGNOSTIC (XT,PS) */ + case 0x13: /* DRIVE DIAGNOSTIC (XT,PS) */ + EAX = (EAX & 0xffff00ff) | 0x01; + SetCflag; + break; + + + + + default: + IntBarf(0x13, context); + }; + return 1; +} diff --git a/miscemu/int1a.c b/miscemu/int1a.c index 235138ed397..95b19bdd2bc 100644 --- a/miscemu/int1a.c +++ b/miscemu/int1a.c @@ -3,6 +3,7 @@ #include #include "msdos.h" #include "wine.h" +#include "options.h" #ifdef linux #include /* needed for HZ */ @@ -16,6 +17,12 @@ int do_int1A(struct sigcontext_struct * context){ struct tm *bdtime; int ticks; + if (Options.relay_debug) { + printf("int1A: AX %04x, BX %04x, CX %04x, DX %04x, " + "SI %04x, DI %04x, DS %04x, ES %04x\n", + AX, BX, CX, DX, SI, DI, DS, ES); + } + switch((context->sc_eax >> 8) & 0xff){ case 0: ltime = time(NULL); @@ -23,6 +30,7 @@ int do_int1A(struct sigcontext_struct * context){ context->sc_ecx = ticks >> 16; context->sc_edx = ticks & 0x0000FFFF; context->sc_eax = 0; /* No midnight rollover */ + printf("int1a_00 // ltime=%ld ticks=%ld\n", ltime, ticks); break; case 2: diff --git a/miscemu/int21.c b/miscemu/int21.c index 3cc4080385d..2485f59a607 100644 --- a/miscemu/int21.c +++ b/miscemu/int21.c @@ -1169,7 +1169,16 @@ int do_int21(struct sigcontext_struct * context) case 0x00: ioctlGetDeviceInfo(context); break; - + + case 0x09: /* CHECK IF BLOCK DEVICE REMOTE */ + EDX = (EDX & 0xffff0000) | (1<<9) | (1<<12); + ResetCflag; + break; + + case 0x0b: /* SET SHARING RETRY COUNT */ + ResetCflag; + break; + case 0x0d: ioctlGenericBlkDevReq(context); break; @@ -1364,6 +1373,9 @@ int do_int21(struct sigcontext_struct * context) ResetCflag; break; + case 0xea: /* NOVELL NETWARE - RETURN SHELL VERSION */ + break; + default: IntBarf(0x21, context); return 1; diff --git a/miscemu/int2a.c b/miscemu/int2a.c new file mode 100644 index 00000000000..ba25c2f44b2 --- /dev/null +++ b/miscemu/int2a.c @@ -0,0 +1,17 @@ +#include +#include +#include "msdos.h" +#include "wine.h" + +int do_int2a(struct sigcontext_struct *context) +{ + switch((context->sc_eax >> 8) & 0xff) + { + case 0x00: /* NETWORK INSTALLATION CHECK */ + break; + + default: + IntBarf(0x2a, context); + }; + return 1; +} diff --git a/miscemu/int2f.c b/miscemu/int2f.c index 046337c6959..c652bba689a 100644 --- a/miscemu/int2f.c +++ b/miscemu/int2f.c @@ -10,6 +10,10 @@ int do_int2f(struct sigcontext_struct *context) { switch((context->sc_eax >> 8) & 0xff) { + case 0x10: /* share isn't installed */ + EAX = (EAX & 0xffffff00) | 0x01; + break; + case 0x15: /* mscdex */ /* ignore requests */ return 1; diff --git a/windows/defwnd.c b/windows/defwnd.c index 8ae88a0f553..1adc1e3ec14 100644 --- a/windows/defwnd.c +++ b/windows/defwnd.c @@ -14,6 +14,9 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include "user.h" #include "syscolor.h" + /* Last COLOR id */ +#define COLOR_MAX COLOR_BTNHIGHLIGHT + extern LONG NC_HandleNCPaint( HWND hwnd, HRGN hrgn ); extern LONG NC_HandleNCActivate( HWND hwnd, WORD wParam ); extern LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params ); @@ -149,7 +152,16 @@ LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam ) { if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return 1; if (!classPtr->wc.hbrBackground) return 1; - FillWindow( GetParent(hwnd), hwnd, (HDC)wParam, + if (classPtr->wc.hbrBackground <= COLOR_MAX+1) + { + HBRUSH hbrush; + hbrush = CreateSolidBrush( + GetSysColor(classPtr->wc.hbrBackground-1)); + FillWindow( GetParent(hwnd), hwnd, (HDC)wParam, hbrush); + DeleteObject (hbrush); + } + else + FillWindow( GetParent(hwnd), hwnd, (HDC)wParam, classPtr->wc.hbrBackground ); return 0; } diff --git a/windows/dialog.c b/windows/dialog.c index 47ad5b4e56f..e91d95a33b0 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -54,8 +54,10 @@ BOOL DIALOG_Init() static DLGCONTROLHEADER * DIALOG_GetControl( DLGCONTROLHEADER * ptr, char ** class, char ** text ) { + int i; unsigned char * p = (unsigned char *)ptr; p += 14; /* size of control header */ + if (*p & 0x80) { switch(*p++) @@ -74,8 +76,15 @@ static DLGCONTROLHEADER * DIALOG_GetControl( DLGCONTROLHEADER * ptr, *class = p; p += strlen(p) + 1; } - *text = p; - p += strlen(p) + 2; +/* FIXME: how can I determine if the resource id is an integer or a string ? */ + if (*p == 0xff) { +/* *(DWORD*)text = (*p << 8) | *p;*/ + *(DWORD*)text = 0xebeb; + p += 4; + } else { + *text = p; + p += strlen(p) + 2; + } return (DLGCONTROLHEADER *)p; } @@ -285,9 +294,14 @@ HWND CreateDialogIndirectParam( HINSTANCE hInst, LPCSTR dlgTemplate, next_header = DIALOG_GetControl( header, &class, &text ); #ifdef DEBUG_DIALOG - printf( " %s '%s' %d, %d, %d, %d, %d, %08x\n", - class, text, header->id, header->x, header->y, header->cx, - header->cy, header->style ); + printf( " %s ", class); + if ((DWORD*)text < 0x10000) + printf("'%4X'", (DWORD*)text); + else + printf("'%s'", text); + + printf(" %d, %d, %d, %d, %d, %08x\n", header->id, header->x, header->y, + header->cx, header->cy, header->style ); #endif if ((strcmp(class, "STATIC") == 0) & ((header->style & SS_ICON) == SS_ICON)) { header->cx = 32; diff --git a/windows/event.c b/windows/event.c index 04358df5928..4b6b3fd7029 100644 --- a/windows/event.c +++ b/windows/event.c @@ -44,6 +44,7 @@ BYTE KeyStateTable[256]; BYTE AsyncKeyStateTable[256]; static WORD ALTKeyState; static HWND captureWnd = 0; +static BOOL InputEnabled = TRUE; Window winHasCursor = 0; /* Keyboard translation tables */ @@ -517,3 +518,16 @@ HWND GetCapture() { return captureWnd; } + + +/********************************************************************** + * EnableHardwareInput [USER.331] + */ +BOOL EnableHardwareInput(BOOL bEnable) +{ + BOOL bOldState = InputEnabled; + printf("EMPTY STUB !!! EnableHardwareInput(%d);\n", bEnable); + InputEnabled = bEnable; + return (bOldState && !bEnable); +} + diff --git a/windows/message.c b/windows/message.c index dfafcdef88d..dcb8e5c8efe 100644 --- a/windows/message.c +++ b/windows/message.c @@ -21,6 +21,8 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include "sysmetrics.h" #include "hook.h" +#define HWND_BROADCAST ((HWND)0xffff) + #define MAX_QUEUE_SIZE 120 /* Max. size of a message queue */ @@ -115,8 +117,10 @@ static int MSG_AddMsg( MESSAGEQUEUE * msgQueue, MSG * msg, DWORD extraInfo ) pos = msgQueue->nextFreeMessage; /* Check if queue is full */ - if ((pos == msgQueue->nextMessage) && (msgQueue->msgCount > 0)) - return FALSE; + if ((pos == msgQueue->nextMessage) && (msgQueue->msgCount > 0)) { + printf("MSG_AddMsg // queue is full !\n"); + return FALSE; + } /* Store message */ msgQueue->messages[pos].msg = *msg; @@ -724,16 +728,44 @@ BOOL GetMessage( LPMSG msg, HWND hwnd, WORD first, WORD last ) } + /*********************************************************************** * PostMessage (USER.110) */ BOOL PostMessage( HWND hwnd, WORD message, WORD wParam, LONG lParam ) { - MSG msg; - WND *wndPtr = WIN_FindWndPtr( hwnd ); + MSG msg; + WND *wndPtr; - if (!wndPtr || !wndPtr->hmemTaskQ) return FALSE; + if (hwnd == HWND_BROADCAST) { +#ifdef DEBUG_MSG + printf("PostMessage // HWND_BROADCAST !\n"); +#endif + hwnd = GetTopWindow(GetDesktopWindow()); + while (hwnd) { + if (!(wndPtr = WIN_FindWndPtr(hwnd))) break; + if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) { +#ifdef DEBUG_MSG + printf("BROADCAST Message to hWnd=%04X m=%04X w=%04X l=%08X !\n", + hwnd, message, wParam, lParam); +#endif + PostMessage(hwnd, message, wParam, lParam); + } +/* { + char str[128]; + GetWindowText(hwnd, str, sizeof(str)); + printf("BROADCAST GetWindowText()='%s' !\n", str); + }*/ + hwnd = wndPtr->hwndNext; + } +#ifdef DEBUG_MSG + printf("PostMessage // End of HWND_BROADCAST !\n"); +#endif + return TRUE; + } + wndPtr = WIN_FindWndPtr( hwnd ); + if (!wndPtr || !wndPtr->hmemTaskQ) return FALSE; msg.hwnd = hwnd; msg.message = message; msg.wParam = wParam; @@ -760,6 +792,51 @@ LONG SendMessage( HWND hwnd, WORD msg, WORD wParam, LONG lParam ) /*********************************************************************** + * WaitMessage (USER.112) + */ +void WaitMessage( void ) +{ + MSG msg; + LONG nextExp; /* Next timer expiration time */ + XEvent event; + + while (XPending( display )) + { + XNextEvent( display, &event ); + EVENT_ProcessEvent( &event ); + } + + while(1) + { + if ((appMsgQueue->wPostQMsg) || + (appMsgQueue->status & (QS_SENDMESSAGE | QS_PAINT)) || + (appMsgQueue->msgCount) || (sysMsgQueue->msgCount) ) + break; + if ((appMsgQueue->status & QS_TIMER) && + TIMER_CheckTimer( &nextExp, &msg, 0, FALSE)) + break; + else + nextExp=-1; + + if (!XPending( display ) && (nextExp != -1)) + { + fd_set read_set; + struct timeval timeout; + int fd = ConnectionNumber(display); + FD_ZERO( &read_set ); + FD_SET( fd, &read_set ); + timeout.tv_sec = nextExp / 1000; + timeout.tv_usec = (nextExp % 1000) * 1000; + if (select( fd+1, &read_set, NULL, NULL, &timeout ) != 1) + continue; /* On timeout or error, restart from the start */ + } + XNextEvent( display, &event ); + EVENT_ProcessEvent( &event ); + } +} + + +/*********************************************************************** * TranslateMessage (USER.113) */ BOOL TranslateMessage( LPMSG msg ) @@ -851,10 +928,12 @@ LONG GetMessageExtraInfo(void) */ WORD RegisterWindowMessage( LPCSTR str ) { + WORD wRet; #ifdef DEBUG_MSG printf( "RegisterWindowMessage: '%s'\n", str ); #endif - return GlobalAddAtom( str ); + wRet = GlobalAddAtom( str ); + return wRet; } -- 2.11.4.GIT