From e71d519fe4fedfb0f9a04009073cfeb05539c8f1 Mon Sep 17 00:00:00 2001 From: "N.E.C" Date: Wed, 22 Jun 2022 17:05:19 -0700 Subject: [PATCH] Use LONG_PTR, DWORD_PTR etc. for x64 compatibility --- inc/portf.h | 2 +- inc/srec.h | 3 ++- kauai/src/appbwin.cpp | 18 ++++++++++++----- kauai/src/base.cpp | 7 +++++++ kauai/src/debug.h | 2 +- kauai/src/dlg.h | 2 +- kauai/src/dlgwin.cpp | 10 ++++----- kauai/src/gobmac.cpp | 6 +++--- kauai/src/gobwin.cpp | 2 +- kauai/src/mdev2pri.h | 46 +++++++++++++++++++++--------------------- kauai/src/menu.h | 6 +++--- kauai/src/mididev.cpp | 4 ++-- kauai/src/mididev2.cpp | 28 ++++++++++++------------- kauai/src/util.h | 4 ++-- kauai/src/utilmem.cpp | 7 +++++++ kauai/src/utilstr.cpp | 15 ++++++++------ kauai/src/utilstr.h | 2 +- kauai/src/video.cpp | 20 +++++++++--------- src/engine/modl.cpp | 4 ++-- src/engine/mtrl.cpp | 2 +- src/engine/srec.cpp | 7 ++++--- src/studio/portf.cpp | 33 +++++++++++++++--------------- 22 files changed, 129 insertions(+), 101 deletions(-) diff --git a/inc/portf.h b/inc/portf.h index 8179f742..9b53d6b6 100644 --- a/inc/portf.h +++ b/inc/portf.h @@ -19,7 +19,7 @@ bool FPortGetFniOpen(FNI *pfni, LPTSTR lpstrFilter, LPTSTR lpstrTitle, FNI *pfni bool FPortGetFniSave(FNI *pfni, LPTSTR lpstrFilter, LPTSTR lpstrTitle, LPTSTR lpstrDefExt, PSTN pstnDefFileName, ulong grfPrevType, CNO cnoWave); -UINT CALLBACK OpenHookProc(HWND hWnd, UINT msg, UINT wParam, LONG lParam); +UINT_PTR CALLBACK OpenHookProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); void OpenPreview(HWND hwnd, PGNV pgnvOff, RCS *prcsPreview); void RepaintPortfolio(HWND hwndCustom); diff --git a/inc/srec.h b/inc/srec.h index 169cb128..b46e245a 100644 --- a/inc/srec.h +++ b/inc/srec.h @@ -111,7 +111,8 @@ class SREC : public SREC_PAR bool _FOpenRecord(); bool _FCloseRecord(); - static void _WaveInProc(HWAVEIN hwi, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2); + static void CALLBACK _WaveInProc(HWAVEIN hwi, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, + DWORD_PTR dwParam2); protected: bool _FInit(long csampSec, long cchan, long cbSample, ulong dtsMax); diff --git a/kauai/src/appbwin.cpp b/kauai/src/appbwin.cpp index 96ea2d28..47fd858e 100644 --- a/kauai/src/appbwin.cpp +++ b/kauai/src/appbwin.cpp @@ -436,17 +436,18 @@ bool APPB::_FFrameWndProc(HWND hwnd, uint wm, WPARAM wParam, LPARAM lw, long *pl pmmi = (MINMAXINFO *)lw; - *plwRet = DefFrameProc(hwnd, vwig.hwndClient, wm, wParam, (long)pmmi); + *plwRet = DefFrameProc(hwnd, vwig.hwndClient, wm, wParam, (LPARAM)pmmi); dypFrame = GetSystemMetrics(SM_CYFRAME); dypScreen = GetSystemMetrics(SM_CYSCREEN); dypExtra = 0; - FGetProp(kpridFullScreen, &lw); - if (lw) + long fullscreen = 0; + FGetProp(kpridFullScreen, &fullscreen); + if (fullscreen) dypExtra = GetSystemMetrics(SM_CYCAPTION); pmmi->ptMaxPosition.y = -dypFrame - dypExtra; pmmi->ptMaxSize.y = pmmi->ptMaxTrackSize.y = dypScreen + 2 * dypFrame + dypExtra; - _FCommonWndProc(hwnd, wm, wParam, (long)pmmi, &lw); + _FCommonWndProc(hwnd, wm, wParam, (LPARAM)pmmi, &fullscreen); } return fTrue; @@ -803,7 +804,7 @@ STN *_rgpstn[3]; /*************************************************************************** Dialog proc for assert. ***************************************************************************/ -BOOL CALLBACK _FDlgAssert(HWND hdlg, UINT msg, WPARAM w, LPARAM lw) +INT_PTR CALLBACK _FDlgAssert(HWND hdlg, UINT msg, WPARAM w, LPARAM lw) { switch (msg) { @@ -874,6 +875,7 @@ bool APPB::FAssertProcApp(PSZS pszsFile, long lwLine, PSZS pszsMsg, void *pv, lo stn1 = PszLit("Some Header file"); stn0.FFormatSz(psz, &stn1, lwLine, &stn2); +#ifdef IN_80386 // call stack - follow the EBP chain.... __asm { mov plw,ebp } for (ilw = 0; ilw < kclwChain; ilw++) @@ -889,6 +891,12 @@ bool APPB::FAssertProcApp(PSZS pszsFile, long lwLine, PSZS pszsMsg, void *pv, lo plw = (long *)*plw; } } +#else + for (ilw = 0; ilw < kclwChain; ilw++) + { + rglw[ilw] = 0; + } +#endif // !IN_80386 for (cact = 0; cact < 2; cact++) { diff --git a/kauai/src/base.cpp b/kauai/src/base.cpp index 12f45126..8d34af0f 100644 --- a/kauai/src/base.cpp +++ b/kauai/src/base.cpp @@ -227,6 +227,7 @@ void *BASE::operator new(size_t cb) long *plw; long ilw; +#ifdef IN_80386 __asm { mov plw,ebp } for (ilw = 0; ilw < kclwStackDoi; ilw++) { @@ -241,6 +242,12 @@ void *BASE::operator new(size_t cb) plw = (long *)*plw; } } +#else + for (ilw = 0; ilw < kclwStackDoi; ilw++) + { + pdoi->rglwStack[ilw] = 0; + } +#endif // !IN_80386 #endif // WIN // update statistics diff --git a/kauai/src/debug.h b/kauai/src/debug.h index 525efe2f..72802e6f 100644 --- a/kauai/src/debug.h +++ b/kauai/src/debug.h @@ -19,7 +19,7 @@ #ifdef WIN inline void Debugger(void) { - __asm { int 3 } + DebugBreak(); } #endif // WIN diff --git a/kauai/src/dlg.h b/kauai/src/dlg.h index 5fc17fd8..e135b2f8 100644 --- a/kauai/src/dlg.h +++ b/kauai/src/dlg.h @@ -61,7 +61,7 @@ class DLG : public DLG_PAR void *_pv; #ifdef WIN - friend BOOL CALLBACK _FDlgCore(HWND hdlg, UINT msg, WPARAM w, LPARAM lw); + friend INT_PTR CALLBACK _FDlgCore(HWND hdlg, UINT msg, WPARAM w, LPARAM lw); #endif // WIN DLG(long rid); diff --git a/kauai/src/dlgwin.cpp b/kauai/src/dlgwin.cpp index f33ec158..f1843344 100644 --- a/kauai/src/dlgwin.cpp +++ b/kauai/src/dlgwin.cpp @@ -111,7 +111,7 @@ bool DLG::_FInit(void) for (csit = dtm.cdit, idit = 0; csit > 0; csit--) { // align to dword - if ((long)psw & 2) + if ((LONG_PTR)psw & 2) psw++; // get and skip the ditm @@ -238,7 +238,7 @@ bool DLG::_FInit(void) /*************************************************************************** Windows dialog proc. ***************************************************************************/ -BOOL CALLBACK _FDlgCore(HWND hdlg, UINT msg, WPARAM w, LPARAM lw) +INT_PTR CALLBACK _FDlgCore(HWND hdlg, UINT msg, WPARAM w, LPARAM lw) { PDLG pdlg; DIT dit; @@ -272,7 +272,7 @@ BOOL CALLBACK _FDlgCore(HWND hdlg, UINT msg, WPARAM w, LPARAM lw) goto LFail; // create a timer so we can do idle processing - if (SetTimer(hdlg, (uint)hdlg, 10, pvNil) == 0) + if (SetTimer(hdlg, (UINT_PTR)hdlg, 10, pvNil) == 0) goto LFail; // create a container gob and attach the hdlg @@ -361,7 +361,7 @@ BOOL CALLBACK _FDlgCore(HWND hdlg, UINT msg, WPARAM w, LPARAM lw) // remove the pdlg property and kill the timer RemoveProp(hdlg, _szDlgProp); - KillTimer(hdlg, (uint)hdlg); + KillTimer(hdlg, (UINT_PTR)hdlg); EndDialog(hdlg, idit); return fTrue; @@ -384,7 +384,7 @@ long DLG::IditDo(long iditFocus) dlgi.pdlg = this; dlgi.iditFocus = iditFocus; - idit = DialogBoxParam(vwig.hinst, MIR(_rid), vwig.hwndApp, &_FDlgCore, (long)&dlgi); + idit = DialogBoxParam(vwig.hinst, MIR(_rid), vwig.hwndApp, &_FDlgCore, (LONG_PTR)&dlgi); return idit; } diff --git a/kauai/src/gobmac.cpp b/kauai/src/gobmac.cpp index e14a82ec..dc32cdb0 100644 --- a/kauai/src/gobmac.cpp +++ b/kauai/src/gobmac.cpp @@ -123,7 +123,7 @@ HWND GOB::_HwndNewMdi(PSTZ pstzTitle) hwnd = (HWND)NewCWindow(pvNil, &rcs, (byte *)pstzTitle, fTrue, documentProc, GrafPtr(-1), fTrue, 0); if (hNil != hwnd && pvNil != vpmubCur) - vpmubCur->FAddListCid(cidChooseWnd, (long)hwnd, pstzTitle); + vpmubCur->FAddListCid(cidChooseWnd, (LONG_PTR)hwnd, pstzTitle); return hwnd; } @@ -133,7 +133,7 @@ HWND GOB::_HwndNewMdi(PSTZ pstzTitle) void GOB::_DestroyHwnd(HWND hwnd) { if (pvNil != vpmubCur) - vpmubCur->FRemoveListCid(cidChooseWnd, (long)hwnd); + vpmubCur->FRemoveListCid(cidChooseWnd, (LONG_PTR)hwnd); DisposeWindow((PPRT)hwnd); } @@ -241,7 +241,7 @@ void GOB::SetHwndName(PSTZ pstz) } if (pvNil != vpmubCur) { - vpmubCur->FChangeListCid(cidChooseWnd, (long)_hwnd, pvNil, (long)_hwnd, pstz); + vpmubCur->FChangeListCid(cidChooseWnd, (LONG_PTR)_hwnd, pvNil, (LONG_PTR)_hwnd, pstz); } SetWTitle(&_hwnd->port, (byte *)pstz); } diff --git a/kauai/src/gobwin.cpp b/kauai/src/gobwin.cpp index a910918a..a85e8047 100644 --- a/kauai/src/gobwin.cpp +++ b/kauai/src/gobwin.cpp @@ -131,7 +131,7 @@ HWND GOB::_HwndNewMdi(PSTN pstnTitle) hwnd = CreateMDIWindow(PszLit("MDI"), pstnTitle->Psz(), lwStyle, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, vwig.hwndClient, vwig.hinst, 0L); if (hNil != hwnd && pvNil != vpmubCur) - vpmubCur->FAddListCid(cidChooseWnd, (long)hwnd, pstnTitle); + vpmubCur->FAddListCid(cidChooseWnd, (LONG_PTR)hwnd, pstnTitle); return hwnd; } diff --git a/kauai/src/mdev2pri.h b/kauai/src/mdev2pri.h index 55658080..b11681b7 100644 --- a/kauai/src/mdev2pri.h +++ b/kauai/src/mdev2pri.h @@ -33,12 +33,12 @@ struct MH byte *lpData; DWORD dwBufferLength; DWORD dwBytesRecorded; - DWORD dwUser; + DWORD_PTR dwUser; DWORD dwFlags; MH *lpNext; - DWORD reserved; + DWORD_PTR reserved; DWORD dwOffset; - DWORD dwReserved[8]; + DWORD_PTR dwReserved[4]; }; typedef MH *PMH; @@ -171,10 +171,10 @@ class MSMIX : public MSMIX_PAR void _WaitForBuffers(void); void _SubmitBuffers(ulong tsCur); - static void _MidiProc(ulong luUser, void *pvData, ulong luData); + static void _MidiProc(ULONG_PTR luUser, void *pvData, ULONG_PTR luData); void _Notify(void *pvData, PMDWS pmdws); - static ulong __stdcall _ThreadProc(void *pv); + static DWORD WINAPI _ThreadProc(void *pv); ulong _LuThread(void); public: @@ -202,7 +202,7 @@ class MSMIX : public MSMIX_PAR /*************************************************************************** The midi stream interface. ***************************************************************************/ -typedef void (*PFNMIDI)(ulong luUser, void *pvData, ulong luData); +typedef void (*PFNMIDI)(ULONG_PTR luUser, void *pvData, ULONG_PTR luData); typedef class MISI *PMISI; #define MISI_PAR BASE @@ -212,9 +212,9 @@ class MISI : public MISI_PAR RTCLASS_DEC protected: - HMS _hms; // the midi stream handle - PFNMIDI _pfnCall; // call back function - ulong _luUser; // user data to send back + HMS _hms; // the midi stream handle + PFNMIDI _pfnCall; // call back function + ULONG_PTR _luUser; // user data to send back // system volume level - to be saved and restored. The volume we set // is always relative to this @@ -222,7 +222,7 @@ class MISI : public MISI_PAR ulong _luVolSys; long _vlmBase; // our current volume relative to _luVolSys. - MISI(PFNMIDI pfn, ulong luUser); + MISI(PFNMIDI pfn, ULONG_PTR luUser); virtual bool _FOpen(void) = 0; virtual bool _FClose(void) = 0; @@ -239,7 +239,7 @@ class MISI : public MISI_PAR virtual bool FActive(void); virtual bool FActivate(bool fActivate); - virtual bool FQueueBuffer(void *pvData, long cb, long ibStart, long cactPlay, ulong luData) = 0; + virtual bool FQueueBuffer(void *pvData, long cb, long ibStart, long cactPlay, ULONG_PTR luData) = 0; virtual void StopPlaying(void) = 0; }; @@ -273,7 +273,7 @@ class WMS : public WMS_PAR void *pvData; long cb; long cactPlay; - ulong luData; + ULONG_PTR luData; long ibNext; MH rgmh[kcmhMsir]; @@ -296,7 +296,7 @@ class WMS : public WMS_PAR bool _fDone : 1; // tells the aux thread to terminate MMRESULT(WINAPI *_pfnOpen) - (HMS *phms, LPUINT puDeviceID, DWORD cMidi, DWORD dwCallback, DWORD dwInstance, DWORD fdwOpen); + (HMS *phms, LPUINT puDeviceID, DWORD cMidi, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen); MMRESULT(WINAPI *_pfnClose)(HMS hms); MMRESULT(WINAPI *_pfnProperty)(HMS hms, LPBYTE lpb, DWORD dwProperty); MMRESULT(WINAPI *_pfnPosition)(HMS hms, LPMMTIME lpmmt, UINT cbmmt); @@ -305,7 +305,7 @@ class WMS : public WMS_PAR MMRESULT(WINAPI *_pfnRestart)(HMS hms); MMRESULT(WINAPI *_pfnStop)(HMS hms); - WMS(PFNMIDI pfn, ulong luUser); + WMS(PFNMIDI pfn, ULONG_PTR luUser); bool _FInit(void); virtual bool _FOpen(void); @@ -316,14 +316,14 @@ class WMS : public WMS_PAR long _CmhSubmitBuffers(void); void _ResetStream(void); - static void __stdcall _MidiProc(HMS hms, ulong msg, ulong luUser, ulong lu1, ulong lu2); + static void CALLBACK _MidiProc(HMS hms, ulong msg, DWORD_PTR luUser, DWORD_PTR lu1, DWORD_PTR lu2); void _Notify(HMS hms, PMH pmh); - static ulong __stdcall _ThreadProc(void *pv); + static DWORD WINAPI _ThreadProc(void *pv); ulong _LuThread(void); public: - static PWMS PwmsNew(PFNMIDI pfn, ulong luUser); + static PWMS PwmsNew(PFNMIDI pfn, ULONG_PTR luUser); ~WMS(void); #ifdef STREAM_BUG @@ -331,7 +331,7 @@ class WMS : public WMS_PAR virtual bool FActivate(bool fActivate); #endif // STREAM_BUG - virtual bool FQueueBuffer(void *pvData, long cb, long ibStart, long cactPlay, ulong luData); + virtual bool FQueueBuffer(void *pvData, long cb, long ibStart, long cactPlay, ULONG_PTR luData); virtual void StopPlaying(void); }; @@ -355,7 +355,7 @@ class OMS : public OMS_PAR long ibStart; long cactPlay; - ulong luData; + ULONG_PTR luData; }; MUTX _mutx; @@ -372,21 +372,21 @@ class OMS : public OMS_PAR PMEV _pmevLim; ulong _tsCur; - OMS(PFNMIDI pfn, ulong luUser); + OMS(PFNMIDI pfn, ULONG_PTR luUser); bool _FInit(void); virtual bool _FOpen(void); virtual bool _FClose(void); - static ulong __stdcall _ThreadProc(void *pv); + static DWORD WINAPI _ThreadProc(void *pv); ulong _LuThread(void); void _ReleaseBuffers(void); public: - static POMS PomsNew(PFNMIDI pfn, ulong luUser); + static POMS PomsNew(PFNMIDI pfn, ULONG_PTR luUser); ~OMS(void); - virtual bool FQueueBuffer(void *pvData, long cb, long ibStart, long cactPlay, ulong luData); + virtual bool FQueueBuffer(void *pvData, long cb, long ibStart, long cactPlay, ULONG_PTR luData); virtual void StopPlaying(void); }; diff --git a/kauai/src/menu.h b/kauai/src/menu.h index ba9853b6..499c9205 100644 --- a/kauai/src/menu.h +++ b/kauai/src/menu.h @@ -116,9 +116,9 @@ class MUB : public MUB_PAR virtual void EnqueueWcid(long wcid); #endif // WIN - virtual bool FAddListCid(long cid, long lw0, PSTN pstn); - virtual bool FRemoveListCid(long cid, long lw0, PSTN pstn = pvNil); - virtual bool FChangeListCid(long cid, long lwOld, PSTN pstnOld, long lwNew, PSTN pstnNew); + virtual bool FAddListCid(long cid, LONG_PTR lw0, PSTN pstn); + virtual bool FRemoveListCid(long cid, LONG_PTR lw0, PSTN pstn = pvNil); + virtual bool FChangeListCid(long cid, LONG_PTR lwOld, PSTN pstnOld, LONG_PTR lwNew, PSTN pstnNew); virtual bool FRemoveAllListCid(long cid); }; diff --git a/kauai/src/mididev.cpp b/kauai/src/mididev.cpp index ac632299..31d3e9f2 100644 --- a/kauai/src/mididev.cpp +++ b/kauai/src/mididev.cpp @@ -386,7 +386,7 @@ class MPQUE : public MPQUE_PAR virtual void _PauseQueue(long isndinMin); virtual void _ResumeQueue(long isndinMin); - static ulong __stdcall _ThreadProc(void *pv); + static DWORD WINAPI _ThreadProc(void *pv); ulong _LuThread(void); void _DoEvent(bool fRestart, long *pdtsWait); @@ -593,7 +593,7 @@ void MPQUE::_ResumeQueue(long isndinMin) /*************************************************************************** AT: Static method. Thread function for the midi thread object. ***************************************************************************/ -ulong __stdcall MPQUE::_ThreadProc(void *pv) +DWORD WINAPI MPQUE::_ThreadProc(void *pv) { PMPQUE pmpque = (PMPQUE)pv; diff --git a/kauai/src/mididev2.cpp b/kauai/src/mididev2.cpp index 750c0d55..d05b7bf4 100644 --- a/kauai/src/mididev2.cpp +++ b/kauai/src/mididev2.cpp @@ -580,8 +580,8 @@ bool MSMIX::_FInit(void) return fFalse; _pglmsos->SetMinGrow(1); - if (pvNil == (_pmisi = WMS::PwmsNew(_MidiProc, (ulong)this)) && - pvNil == (_pmisi = OMS::PomsNew(_MidiProc, (ulong)this))) + if (pvNil == (_pmisi = WMS::PwmsNew(_MidiProc, (ULONG_PTR)this)) && + pvNil == (_pmisi = OMS::PomsNew(_MidiProc, (ULONG_PTR)this))) { return fFalse; } @@ -867,7 +867,7 @@ void MSMIX::_SubmitBuffers(ulong tsCur) _cpvOut++; pvData = msos.pmdws->PvLockData(&cb); - if (_pmisi->FQueueBuffer(pvData, cb, cbSkip, msos.cactPlay, (ulong)msos.pmdws)) + if (_pmisi->FQueueBuffer(pvData, cb, cbSkip, msos.cactPlay, (ULONG_PTR)msos.pmdws)) { // it worked! _fPlaying = fTrue; @@ -1066,7 +1066,7 @@ bool MSMIX::_FGetKeyEvents(PMDWS pmdws, ulong dtsSeek, long *pcbSkip) /*************************************************************************** Call back from the midi stream stuff. ***************************************************************************/ -void MSMIX::_MidiProc(ulong luUser, void *pvData, ulong luData) +void MSMIX::_MidiProc(ULONG_PTR luUser, void *pvData, ULONG_PTR luData) { PMSMIX pmsmix; PMDWS pmdws; @@ -1138,7 +1138,7 @@ void MSMIX::_Notify(void *pvData, PMDWS pmdws) /*************************************************************************** AT: Static method. Thread function for the MSMIX object. ***************************************************************************/ -ulong __stdcall MSMIX::_ThreadProc(void *pv) +DWORD WINAPI MSMIX::_ThreadProc(void *pv) { PMSMIX pmsmix = (PMSMIX)pv; @@ -1222,7 +1222,7 @@ ulong MSMIX::_LuThread(void) /*************************************************************************** Constructor for the MIDI stream interface. ***************************************************************************/ -MISI::MISI(PFNMIDI pfn, ulong luUser) +MISI::MISI(PFNMIDI pfn, ULONG_PTR luUser) { AssertBaseThis(0); Assert(pvNil != pfn, 0); @@ -1375,7 +1375,7 @@ bool MISI::FActivate(bool fActivate) /*************************************************************************** Constructor for the Win95 Midi stream class. ***************************************************************************/ -WMS::WMS(PFNMIDI pfn, ulong luUser) : MISI(pfn, luUser) +WMS::WMS(PFNMIDI pfn, ULONG_PTR luUser) : MISI(pfn, luUser) { } @@ -1410,7 +1410,7 @@ WMS::~WMS(void) /*************************************************************************** Create a new WMS. ***************************************************************************/ -PWMS WMS::PwmsNew(PFNMIDI pfn, ulong luUser) +PWMS WMS::PwmsNew(PFNMIDI pfn, ULONG_PTR luUser) { PWMS pwms; @@ -1553,7 +1553,7 @@ bool WMS::_FOpen(void) if (hNil != _hms) goto LDone; - if (MMSYSERR_NOERROR != (*_pfnOpen)(&_hms, &uT, 1, (ulong)_MidiProc, (ulong)this, CALLBACK_FUNCTION)) + if (MMSYSERR_NOERROR != (*_pfnOpen)(&_hms, &uT, 1, (ULONG_PTR)_MidiProc, (ULONG_PTR)this, CALLBACK_FUNCTION)) { goto LFail; } @@ -1677,7 +1677,7 @@ void WMS::_ResetStream(void) This submits a buffer and restarts the midi stream. If the data is bigger than 64K, this (in conjunction with _Notify) deals with it. ***************************************************************************/ -bool WMS::FQueueBuffer(void *pvData, long cb, long ibStart, long cactPlay, ulong luData) +bool WMS::FQueueBuffer(void *pvData, long cb, long ibStart, long cactPlay, ULONG_PTR luData) { AssertThis(0); AssertPvCb(pvData, cb); @@ -1911,7 +1911,7 @@ void WMS::_Notify(HMS hms, PMH pmh) just waits for the event to be triggered, indicating that we got a callback from the midiStream stuff and it's time to do our callbacks. ***************************************************************************/ -ulong __stdcall WMS::_ThreadProc(void *pv) +DWORD WINAPI WMS::_ThreadProc(void *pv) { PWMS pwms = (PWMS)pv; @@ -2023,7 +2023,7 @@ OMS::~OMS(void) /*************************************************************************** Create a new OMS. ***************************************************************************/ -POMS OMS::PomsNew(PFNMIDI pfn, ulong luUser) +POMS OMS::PomsNew(PFNMIDI pfn, ULONG_PTR luUser) { POMS poms; @@ -2165,7 +2165,7 @@ bool OMS::_FClose(void) /*************************************************************************** Queue a buffer to the midi stream. ***************************************************************************/ -bool OMS::FQueueBuffer(void *pvData, long cb, long ibStart, long cactPlay, ulong luData) +bool OMS::FQueueBuffer(void *pvData, long cb, long ibStart, long cactPlay, ULONG_PTR luData) { AssertThis(0); AssertPvCb(pvData, cb); @@ -2228,7 +2228,7 @@ void OMS::StopPlaying(void) /*************************************************************************** AT: Static method. Thread function for the midi stream object. ***************************************************************************/ -ulong __stdcall OMS::_ThreadProc(void *pv) +DWORD WINAPI OMS::_ThreadProc(void *pv) { POMS poms = (POMS)pv; diff --git a/kauai/src/util.h b/kauai/src/util.h index 733f9a51..3daab2b2 100644 --- a/kauai/src/util.h +++ b/kauai/src/util.h @@ -60,8 +60,8 @@ typedef HCURSOR HCRS; #endif // WIN -#define size(foo) ((long)sizeof(foo)) -#define offset(FOO, field) ((int)&((FOO *)0)->field) +#define size(foo) ((size_t)sizeof(foo)) +#define offset(FOO, field) ((size_t) & ((FOO *)0)->field) #define CvFromRgv(rgv) (size(rgv) / size(rgv[0])) #define BLOCK diff --git a/kauai/src/utilmem.cpp b/kauai/src/utilmem.cpp index f4d50174..b9866394 100644 --- a/kauai/src/utilmem.cpp +++ b/kauai/src/utilmem.cpp @@ -206,6 +206,7 @@ bool FAllocPv(void **ppv, long cb, ulong grfmem, long mpr) long *plw; long ilw; +#ifdef IN_80386 __asm { mov plw,ebp } for (ilw = 0; ilw < kclwStackMbh; ilw++) { @@ -220,6 +221,12 @@ bool FAllocPv(void **ppv, long cb, ulong grfmem, long mpr) plw = (long *)*plw; } } +#else + for (ilw = 0; ilw < kclwStackMbh; ilw++) + { + pmbh->rglwStack[ilw] = 0; + } +#endif // !IN_80386 #endif // WIN // write the footer diff --git a/kauai/src/utilstr.cpp b/kauai/src/utilstr.cpp index 1e4545e5..2955d6ac 100644 --- a/kauai/src/utilstr.cpp +++ b/kauai/src/utilstr.cpp @@ -548,14 +548,15 @@ void STN::GetSzs(PSZS pszs) following needs a number also. So the above example would be "%<1>d %<0>d %<2>d %d", producing { 1, 0, 2, 3 }. - WARNING: all arguments should be 4 bytes long. + WARNING: all arguments should be sizeof(void*) bytes long. ***************************************************************************/ bool STN::FFormat(PSTN pstnFormat, ...) { AssertThis(0); AssertPo(pstnFormat, 0); - return FFormatRgch(pstnFormat->Prgch(), pstnFormat->Cch(), (ulong *)(&pstnFormat + 1)); + // FIXME: Use a standards-compliant way to pass params + return FFormatRgch(pstnFormat->Prgch(), pstnFormat->Cch(), (ULONG_PTR *)(&pstnFormat + 1)); } /*************************************************************************** @@ -566,13 +567,14 @@ bool STN::FFormatSz(PSZ pszFormat, ...) AssertThis(0); AssertSz(pszFormat); - return FFormatRgch(pszFormat, CchSz(pszFormat), (ulong *)(&pszFormat + 1)); + // FIXME: Use a standards-compliant way to pass params + return FFormatRgch(pszFormat, CchSz(pszFormat), (ULONG_PTR *)(&pszFormat + 1)); } /*************************************************************************** Core routine for sprintf functionality. ***************************************************************************/ -bool STN::FFormatRgch(achar *prgchFormat, long cchFormat, ulong *prgluData) +bool STN::FFormatRgch(achar *prgchFormat, long cchFormat, ULONG_PTR *prgluData) { AssertThis(0); AssertIn(cchFormat, 0, kcchMaxStn + 1); @@ -591,7 +593,8 @@ bool STN::FFormatRgch(achar *prgchFormat, long cchFormat, ulong *prgluData) long cch; long cchMin; long ivArg; - ulong lu, luRad; + ULONG_PTR lu; + ulong luRad; achar ch; achar rgchT[kcchMaxStn]; achar *prgchTerm; @@ -684,7 +687,7 @@ bool STN::FFormatRgch(achar *prgchFormat, long cchFormat, ulong *prgluData) // code after the switch assumes that prgchTerm points to the // characters to add to the stream and cch is the number of characters - AssertPvCb(prgluData, LwMul(ivArg + 1, size(ulong))); + AssertPvCb(prgluData, LwMul(ivArg + 1, size(ULONG_PTR))); lu = prgluData[ivArg++]; prgchTerm = rgchT; switch (ch) diff --git a/kauai/src/utilstr.h b/kauai/src/utilstr.h index 2c5712e5..e9b37c08 100644 --- a/kauai/src/utilstr.h +++ b/kauai/src/utilstr.h @@ -479,7 +479,7 @@ class STN bool FFormat(PSTN pstnFormat, ...); bool FFormatSz(PSZ pszFormat, ...); - bool FFormatRgch(achar *prgchFormat, long cchFormat, ulong *prgluData); + bool FFormatRgch(achar *prgchFormat, long cchFormat, ULONG_PTR *prgluData); bool FGetLw(long *plw, long lwBase = 0); bool FExpandControls(void); }; diff --git a/kauai/src/video.cpp b/kauai/src/video.cpp index 7e18689d..1a1eb3c5 100644 --- a/kauai/src/video.cpp +++ b/kauai/src/video.cpp @@ -372,7 +372,7 @@ GVDW::~GVDW(void) MCI_GENERIC_PARMS mci; PSNDV psndv; - mciSendCommand(_lwDevice, MCI_CLOSE, MCI_WAIT, (long)&mci); + mciSendCommand(_lwDevice, MCI_CLOSE, MCI_WAIT, (LONG_PTR)&mci); if (pvNil != vpsndm && pvNil != (psndv = vpsndm->PsndvFromCtg(kctgWave))) { psndv->Suspend(fFalse); @@ -406,7 +406,7 @@ bool GVDW::_FInit(PFNI pfni, PGOB pgobBase) mciOpen.dwStyle = WS_CHILD | WS_CLIPSIBLINGS | WS_DISABLED; mciOpen.hWndParent = _pgobBase->HwndContainer(); if (0 != mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT | MCI_ANIM_OPEN_PARENT | MCI_ANIM_OPEN_WS, - (long)&mciOpen)) + (LONG_PTR)&mciOpen)) { goto LFail; } @@ -422,7 +422,7 @@ bool GVDW::_FInit(PFNI pfni, PGOB pgobBase) // REVIEW shonk: mmsystem.h defines MCI_ANIM_STATUS_HWND as 0x00004003, // which doesn't give us the hwnd. 4001 does! mciStatus.dwItem = 0x00004001; - if (0 != mciSendCommand(_lwDevice, MCI_STATUS, MCI_STATUS_ITEM, (long)&mciStatus)) + if (0 != mciSendCommand(_lwDevice, MCI_STATUS, MCI_STATUS_ITEM, (LONG_PTR)&mciStatus)) { goto LFail; } @@ -432,14 +432,14 @@ bool GVDW::_FInit(PFNI pfni, PGOB pgobBase) ClearPb(&mciStatus, size(mciStatus)); mciStatus.dwItem = MCI_STATUS_LENGTH; mciStatus.dwTrack = 1; - if (0 != mciSendCommand(_lwDevice, MCI_STATUS, MCI_STATUS_ITEM, (long)&mciStatus)) + if (0 != mciSendCommand(_lwDevice, MCI_STATUS, MCI_STATUS_ITEM, (LONG_PTR)&mciStatus)) { goto LFail; } _nfrMac = mciStatus.dwReturn; // get the rectangle - if (0 != mciSendCommand(_lwDevice, MCI_WHERE, MCI_ANIM_WHERE_SOURCE, (long)&mciRect)) + if (0 != mciSendCommand(_lwDevice, MCI_WHERE, MCI_ANIM_WHERE_SOURCE, (LONG_PTR)&mciRect)) { goto LFail; } @@ -487,7 +487,7 @@ long GVDW::NfrCur(void) ClearPb(&mciStatus, size(mciStatus)); mciStatus.dwItem = MCI_STATUS_POSITION; mciStatus.dwTrack = 1; - if (0 != mciSendCommand(_lwDevice, MCI_STATUS, MCI_STATUS_ITEM, (long)&mciStatus)) + if (0 != mciSendCommand(_lwDevice, MCI_STATUS, MCI_STATUS_ITEM, (LONG_PTR)&mciStatus)) { Warn("getting position failed"); return 0; @@ -543,7 +543,7 @@ bool GVDW::FPlaying(void) ClearPb(&mciStatus, size(mciStatus)); mciStatus.dwItem = MCI_STATUS_MODE; mciStatus.dwTrack = 1; - if (0 == mciSendCommand(_lwDevice, MCI_STATUS, MCI_STATUS_ITEM, (long)&mciStatus) && + if (0 == mciSendCommand(_lwDevice, MCI_STATUS, MCI_STATUS_ITEM, (LONG_PTR)&mciStatus) && (MCI_MODE_STOP == mciStatus.dwReturn || MCI_MODE_PAUSE == mciStatus.dwReturn)) { _fPlaying = fFalse; @@ -580,7 +580,7 @@ bool GVDW::FPlay(RC *prc) // start the movie playing ClearPb(&mciPlay, size(mciPlay)); - if (0 != mciSendCommand(_lwDevice, MCI_PLAY, MCI_MCIAVI_PLAY_WINDOW, (long)&mciPlay)) + if (0 != mciSendCommand(_lwDevice, MCI_PLAY, MCI_MCIAVI_PLAY_WINDOW, (LONG_PTR)&mciPlay)) { return fFalse; } @@ -623,7 +623,7 @@ void GVDW::Stop(void) MCI_GENERIC_PARMS mciPause; ClearPb(&mciPause, size(mciPause)); - mciSendCommand(_lwDevice, MCI_PAUSE, 0, (long)&mciPause); + mciSendCommand(_lwDevice, MCI_PAUSE, 0, (LONG_PTR)&mciPause); #endif // WIN #ifdef MAC @@ -666,7 +666,7 @@ void GVDW::_SetRc(void) // show the playback window ClearPb(&mciWindow, size(mciWindow)); mciWindow.nCmdShow = SW_SHOW; - mciSendCommand(_lwDevice, MCI_WINDOW, MCI_ANIM_WINDOW_STATE, (long)&mciWindow); + mciSendCommand(_lwDevice, MCI_WINDOW, MCI_ANIM_WINDOW_STATE, (LONG_PTR)&mciWindow); _fVisible = fTrue; } #endif // WIN diff --git a/src/engine/modl.cpp b/src/engine/modl.cpp index da792cc2..8ca22b7e 100644 --- a/src/engine/modl.cpp +++ b/src/engine/modl.cpp @@ -235,7 +235,7 @@ PMODL MODL::PmodlReadFromDat(FNI *pfni) PMODL MODL::PmodlFromBmdl(PBMDL pbmdl) { AssertVarMem(pbmdl); - PMODL pmodl = (PMODL) * (long *)pbmdl->identifier; + PMODL pmodl = (PMODL) * (PMODL *)pbmdl->identifier; AssertPo(pmodl, 0); return pmodl; } @@ -422,7 +422,7 @@ void MODL::AssertValid(ulong grf) { MODL_PAR::AssertValid(fobjAllocated); AssertVarMem(_pbmdl); - Assert((PMODL) * (long *)_pbmdl->identifier == this, "Bad MODL identifier"); + Assert((PMODL) * (PMODL *)_pbmdl->identifier == this, "Bad MODL identifier"); } /*************************************************************************** diff --git a/src/engine/mtrl.cpp b/src/engine/mtrl.cpp index c1b3bdf2..0b990c38 100644 --- a/src/engine/mtrl.cpp +++ b/src/engine/mtrl.cpp @@ -305,7 +305,7 @@ PMTRL MTRL::PmtrlFromBmtl(PBMTL pbmtl) { AssertVarMem(pbmtl); - PMTRL pmtrl = (PMTRL) * (long *)pbmtl->identifier; + PMTRL pmtrl = (PMTRL) * (PMTRL *)pbmtl->identifier; AssertPo(pmtrl, 0); return pmtrl; } diff --git a/src/engine/srec.cpp b/src/engine/srec.cpp index 5d0f7974..e52ace76 100644 --- a/src/engine/srec.cpp +++ b/src/engine/srec.cpp @@ -124,14 +124,15 @@ bool SREC::_FOpenRecord(void) if (pvNil == _hwavein) { // open a wavein device - if (waveInOpen(&_hwavein, WAVE_MAPPER, _priff->PwfxGet(), (DWORD)_WaveInProc, (DWORD)this, CALLBACK_FUNCTION)) + if (waveInOpen(&_hwavein, WAVE_MAPPER, _priff->PwfxGet(), (DWORD_PTR)_WaveInProc, (DWORD_PTR)this, + CALLBACK_FUNCTION)) { // it doesn't support this format return fFalse; } // prepare header on block of data - _wavehdr.dwUser = (DWORD)this; + _wavehdr.dwUser = (DWORD_PTR)this; if (waveInPrepareHeader(_hwavein, &_wavehdr, sizeof(WAVEHDR))) { waveInClose(_hwavein); @@ -257,7 +258,7 @@ void SREC::_UpdateStatus(void) /*************************************************************************** Figure out if we're recording or not ***************************************************************************/ -void SREC::_WaveInProc(HWAVEIN hwi, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) +void CALLBACK SREC::_WaveInProc(HWAVEIN hwi, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) { // the psrec pointer is a pointer to the class which generated the event and owns the device SREC *psrec = (SREC *)dwInstance; diff --git a/src/studio/portf.cpp b/src/studio/portf.cpp index 3d5b95b5..a0ec7b90 100644 --- a/src/studio/portf.cpp +++ b/src/studio/portf.cpp @@ -154,7 +154,7 @@ bool FPortGetFniOpen(FNI *pfni, LPTSTR lpstrFilter, LPTSTR lpstrTitle, FNI *pfni diPortfolio.fDrawnBkgnd = fFalse; diPortfolio.grfPrevType = grfPrevType; diPortfolio.cnoWave = cnoWave; - ofn.lCustData = (DWORD)&diPortfolio; + ofn.lCustData = (LPARAM)&diPortfolio; ofn.lpstrFilter = lpstrFilter; ofn.lpstrTitle = lpstrTitle; @@ -288,7 +288,7 @@ bool FPortGetFniSave(FNI *pfni, LPTSTR lpstrFilter, LPTSTR lpstrTitle, LPTSTR lp diPortfolio.fDrawnBkgnd = fFalse; diPortfolio.grfPrevType = grfPrevType; diPortfolio.cnoWave = cnoWave; - ofn.lCustData = (DWORD)&diPortfolio; + ofn.lCustData = (DWORD_PTR)&diPortfolio; ofn.lpstrFilter = lpstrFilter; ofn.lpstrTitle = lpstrTitle; @@ -474,7 +474,7 @@ bool FPortGetFniSave(FNI *pfni, LPTSTR lpstrFilter, LPTSTR lpstrTitle, LPTSTR lp child of the common dlg. ***************************************************************************/ -UINT CALLBACK OpenHookProc(HWND hwndCustom, UINT msg, UINT wParam, LONG lParam) +UINT_PTR CALLBACK OpenHookProc(HWND hwndCustom, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { @@ -489,13 +489,13 @@ UINT CALLBACK OpenHookProc(HWND hwndCustom, UINT msg, UINT wParam, LONG lParam) lpOfn = (OPENFILENAME *)lParam; pdiPortfolio = (PDLGINFO)(lpOfn->lCustData); - SetWindowLong(hwndCustom, GWL_USERDATA, (LONG)pdiPortfolio); + SetWindowLongPtr(hwndCustom, GWLP_USERDATA, (LONG_PTR)pdiPortfolio); hwndDlg = GetParent(hwndCustom); // Give ourselves a way to access the custom dlg hwnd // from the common dlg subclass wndproc. - SetWindowLong(hwndDlg, GWL_USERDATA, (LONG)hwndCustom); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hwndCustom); // Hide common dlg controls that we're not interested in here. Use the Common Dialog // Message for hiding the control. The documentation on CDM_HIDECONTROL doesn't really @@ -563,24 +563,25 @@ UINT CALLBACK OpenHookProc(HWND hwndCustom, UINT msg, UINT wParam, LONG lParam) // the window anyway.. // Subclass the push btns to prevent the background flashing in the default color. - lpBtnProc = (WNDPROC)SetWindowLong(GetDlgItem(hwndCustom, IDC_BUTTON1), GWL_WNDPROC, (LONG)SubClassBtnProc); + lpBtnProc = + (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndCustom, IDC_BUTTON1), GWLP_WNDPROC, (LONG_PTR)SubClassBtnProc); lpOtherBtnProc = - (WNDPROC)SetWindowLong(GetDlgItem(hwndCustom, IDC_BUTTON2), GWL_WNDPROC, (LONG)SubClassBtnProc); + (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndCustom, IDC_BUTTON2), GWLP_WNDPROC, (LONG_PTR)SubClassBtnProc); Assert(lpBtnProc == lpOtherBtnProc, "Custom portfolio buttons (ok/cancel) have different window procs"); lpOtherBtnProc = - (WNDPROC)SetWindowLong(GetDlgItem(hwndCustom, IDC_BUTTON3), GWL_WNDPROC, (LONG)SubClassBtnProc); + (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndCustom, IDC_BUTTON3), GWLP_WNDPROC, (LONG_PTR)SubClassBtnProc); Assert(lpBtnProc == lpOtherBtnProc, "Custom portfolio buttons (ok/home) have different window procs"); // Subclass the preview window to allow custom draw. lpPreviewProc = - (WNDPROC)SetWindowLong(GetDlgItem(hwndCustom, IDC_PREVIEW), GWL_WNDPROC, (LONG)SubClassPreviewProc); + (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndCustom, IDC_PREVIEW), GWLP_WNDPROC, (LONG_PTR)SubClassPreviewProc); // Subclass the main common dlg window to stop static control backgrounds being // fill with the current system color. Instead use a color that matches our // custom background bitmap. - lpDlgProc = (WNDPROC)SetWindowLong(hwndDlg, GWL_WNDPROC, (LONG)SubClassDlgProc); + lpDlgProc = (WNDPROC)SetWindowLongPtr(hwndDlg, GWLP_WNDPROC, (LONG_PTR)SubClassDlgProc); // For the save portfolio we want the file name control to have focus when displayed. if (!pdiPortfolio->fIsOpen) @@ -796,7 +797,7 @@ UINT CALLBACK OpenHookProc(HWND hwndCustom, UINT msg, UINT wParam, LONG lParam) // Win95 has finished doing any resizing of the custom dlg and the controls. // So take any special action now to ensure the portfolio still looks good. - PDLGINFO pdiPortfolio = (PDLGINFO)GetWindowLong(hwndCustom, GWL_USERDATA); + PDLGINFO pdiPortfolio = (PDLGINFO)GetWindowLongPtr(hwndCustom, GWLP_USERDATA); RCS rcsApp; POINT ptBtn; int ypBtn; @@ -925,7 +926,7 @@ UINT CALLBACK OpenHookProc(HWND hwndCustom, UINT msg, UINT wParam, LONG lParam) // Do this if we ever have a way of querying the user with a help topic // from inside the portfolio. case CDN_FILEOK: { - PDLGINFO pdiPortfolio = (PDLGINFO)GetWindowLong(hwndCustom, GWL_USERDATA); + PDLGINFO pdiPortfolio = (PDLGINFO)GetWindowLongPtr(hwndCustom, GWLP_USERDATA); // User has hit OK or Save. Is the user trying to save over an existing file? if (pdiPortfolio->fIsOpen != fTrue) @@ -982,7 +983,7 @@ UINT CALLBACK OpenHookProc(HWND hwndCustom, UINT msg, UINT wParam, LONG lParam) case WM_PAINT: { PDLGINFO pdiPortfolio; - pdiPortfolio = (PDLGINFO)GetWindowLong(hwndCustom, GWL_USERDATA); + pdiPortfolio = (PDLGINFO)GetWindowLongPtr(hwndCustom, GWLP_USERDATA); // Repaint the entire portfolio. RepaintPortfolio(hwndCustom); @@ -1015,7 +1016,7 @@ void RepaintPortfolio(HWND hwndCustom) PAINTSTRUCT ps; TEXTMETRIC tmCaption; SZ szCaption; - PDLGINFO pdiPortfolio = (PDLGINFO)GetWindowLong(hwndCustom, GWL_USERDATA); + PDLGINFO pdiPortfolio = (PDLGINFO)GetWindowLongPtr(hwndCustom, GWLP_USERDATA); PMBMP pmbmp, pmbmpBtn; int iBtn; CNO cnoBack; @@ -1217,7 +1218,7 @@ void OpenPreview(HWND hwndCustom, PGNV pgnvOff, RCS *prcsPreview) SZ szFile; ERS ersT; ERS *pers; - PDLGINFO pdiPortfolio = (PDLGINFO)GetWindowLong(hwndCustom, GWL_USERDATA); + PDLGINFO pdiPortfolio = (PDLGINFO)GetWindowLongPtr(hwndCustom, GWLP_USERDATA); bool fPreviewed = fFalse; RC rcPreview(*prcsPreview); @@ -1487,7 +1488,7 @@ LRESULT CALLBACK SubClassDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l // custom dlg now, to prevent the common dlg controls appearing before // the portfolio background. Note that GetDlgItem(hwndDlg, ) // returns zero here, as the Menu part of the custom dlg is zero. - HWND hwndCustom = (HWND)GetWindowLong(hwndDlg, GWL_USERDATA); + HWND hwndCustom = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (hwndCustom != 0) UpdateWindow(hwndCustom);