aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-02-20 17:46:34 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-02-20 17:46:34 +0000
commite2fea8646f72081d75fbad367be6ced68c82fb4c (patch)
tree146558b630d0cdeea1153ec6463c962e194936bb /Game/Code
parentb4d9e59f54100db2cbfc18368004f28f34aee11b (diff)
downloadusdx-e2fea8646f72081d75fbad367be6ced68c82fb4c.tar.gz
usdx-e2fea8646f72081d75fbad367be6ced68c82fb4c.tar.xz
usdx-e2fea8646f72081d75fbad367be6ced68c82fb4c.zip
Made the midi-stuff FPC (for windows) compatible.
Now (in windows) FPC contains all functionalities of the delphi build. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@872 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code')
-rw-r--r--Game/Code/UltraStar.dpr3
-rw-r--r--Game/Code/lib/midi/CIRCBUF.PAS20
-rw-r--r--Game/Code/lib/midi/DELPHMCB.PAS27
-rw-r--r--Game/Code/lib/midi/MIDIDEFS.PAS5
-rw-r--r--Game/Code/lib/midi/MIDITYPE.PAS8
-rw-r--r--Game/Code/lib/midi/MidiFile.pas32
-rw-r--r--Game/Code/lib/midi/Midiin.pas24
-rw-r--r--Game/Code/lib/midi/Midiout.pas27
-rw-r--r--Game/Code/switches.inc10
9 files changed, 93 insertions, 63 deletions
diff --git a/Game/Code/UltraStar.dpr b/Game/Code/UltraStar.dpr
index d624e809..c0825d2f 100644
--- a/Game/Code/UltraStar.dpr
+++ b/Game/Code/UltraStar.dpr
@@ -29,8 +29,7 @@ uses
portmixer in 'lib\portmixer\delphi\portmixer.pas',
{$ENDIF}
- //{$IFDEF MSWINDOWS}
- {$IFDEF Delphi}
+ {$IFDEF MSWINDOWS}
midiout in 'lib\midi\midiout.pas',
midiin in 'lib\midi\midiin.pas',
CIRCBUF in 'lib\midi\CIRCBUF.PAS',
diff --git a/Game/Code/lib/midi/CIRCBUF.PAS b/Game/Code/lib/midi/CIRCBUF.PAS
index e84fc2c4..9f1f8390 100644
--- a/Game/Code/lib/midi/CIRCBUF.PAS
+++ b/Game/Code/lib/midi/CIRCBUF.PAS
@@ -21,17 +21,11 @@ Unit Circbuf;
interface
-Uses Wintypes, WinProcs, MMSystem;
+Uses
+ Windows,
+ MMSystem;
type
- {$IFNDEF WIN32}
- { API types not defined in Delphi 1 }
- DWORD = Longint;
- HGLOBAL = THandle;
- UINT = Word;
- TFNTimeCallBack = procedure(uTimerID, uMessage: UINT; dwUser, dw1, dw2: DWORD);
- {$ENDIF}
-
{ MIDI input event }
TMidiBufferItem = record
timestamp: DWORD; { Timestamp in milliseconds after midiInStart }
@@ -83,19 +77,11 @@ begin
GlobalFree(hMem);
end;
-{$IFNDEF WIN32}
- if (ptr <> Nil) then
- GlobalPageLock(HIWORD(DWORD(ptr)));
-{$ENDIF}
GlobalSharedLockedAlloc := Ptr;
end;
procedure GlobalSharedLockedFree( hMem: HGLOBAL; ptr: Pointer );
begin
-{$IFNDEF WIN32}
- if (ptr <> Nil) then
- GlobalPageUnlock(HIWORD(DWORD(ptr)));
-{$ENDIF}
if (hMem <> 0) then
begin
GlobalUnlock(hMem);
diff --git a/Game/Code/lib/midi/DELPHMCB.PAS b/Game/Code/lib/midi/DELPHMCB.PAS
index 23ce0e1a..e8b732fa 100644
--- a/Game/Code/lib/midi/DELPHMCB.PAS
+++ b/Game/Code/lib/midi/DELPHMCB.PAS
@@ -9,30 +9,25 @@ unit Delphmcb;
interface
-uses WinProcs, WinTypes, MMsystem, Circbuf, MidiDefs, MidiCons;
+uses
+ Windows,
+ MMsystem,
+ Circbuf,
+ MidiDefs,
+ MidiCons;
-{$IFDEF WIN32}
procedure midiHandler(
hMidiIn: HMidiIn;
wMsg: UINT;
dwInstance: DWORD;
dwParam1: DWORD;
- dwParam2: DWORD); stdcall export;
-function CircbufPutEvent(PBuffer: PCircularBuffer; PTheEvent: PMidiBufferItem): Boolean; stdcall; export;
-{$ELSE}
-procedure midiHandler(
- hMidiIn: HMidiIn;
- wMsg: Word;
- dwInstance: DWORD;
- dwParam1: DWORD;
- dwParam2: DWORD); export;
-function CircbufPutEvent(PBuffer: PCircularBuffer; PTheEvent: PMidiBufferItem): Boolean; export;
-{$ENDIF}
+ dwParam2: DWORD); stdcall; export;
+function CircbufPutEvent(PBuffer: PCircularBuffer; PTheEvent: PMidiBufferItem): Boolean; stdcall; export;
implementation
{ Add an event to the circular input buffer. }
-function CircbufPutEvent(PBuffer: PCircularBuffer; PTheEvent: PMidiBufferItem): Boolean;
+function CircbufPutEvent(PBuffer: PCircularBuffer; PTheEvent: PMidiBufferItem): Boolean; stdcall;
begin
If (PBuffer^.EventCount < PBuffer^.Capacity) Then
begin
@@ -66,13 +61,11 @@ procedure midiHandler(
wMsg: UINT;
dwInstance: DWORD;
dwParam1: DWORD;
- dwParam2: DWORD);
-
+ dwParam2: DWORD); stdcall;
var
thisEvent: TMidiBufferItem;
thisCtlInfo: PMidiCtlInfo;
thisBuffer: PCircularBuffer;
-
Begin
case wMsg of
diff --git a/Game/Code/lib/midi/MIDIDEFS.PAS b/Game/Code/lib/midi/MIDIDEFS.PAS
index 4024c547..8e351a07 100644
--- a/Game/Code/lib/midi/MIDIDEFS.PAS
+++ b/Game/Code/lib/midi/MIDIDEFS.PAS
@@ -11,7 +11,10 @@ unit Mididefs;
interface
-uses WinProcs, WinTypes, MMsystem, Circbuf;
+uses
+ Windows,
+ MMsystem,
+ Circbuf;
type
diff --git a/Game/Code/lib/midi/MIDITYPE.PAS b/Game/Code/lib/midi/MIDITYPE.PAS
index 0aa9cec3..18d05ec4 100644
--- a/Game/Code/lib/midi/MIDITYPE.PAS
+++ b/Game/Code/lib/midi/MIDITYPE.PAS
@@ -8,7 +8,13 @@ unit Miditype;
interface
-uses Classes, Wintypes, Messages, MMSystem, MidiDefs, Circbuf;
+uses
+ Classes,
+ Windows,
+ Messages,
+ MMSystem,
+ MidiDefs,
+ Circbuf;
type
{-------------------------------------------------------------------}
diff --git a/Game/Code/lib/midi/MidiFile.pas b/Game/Code/lib/midi/MidiFile.pas
index 10b64a80..e6306bec 100644
--- a/Game/Code/lib/midi/MidiFile.pas
+++ b/Game/Code/lib/midi/MidiFile.pas
@@ -90,17 +90,19 @@ unit MidiFile;
interface
+{$IFDEF FPC}
+ {$MODE Delphi}
+{$ENDIF}
+
uses
Windows,
+ Forms,
Messages,
SysUtils,
- Classes,
- Graphics,
- Controls,
- Forms,
- stdctrls,
- ExtCtrls,
- WinProcs;
+ {$IFDEF LCL}
+ LCLIntf, // used for AllocateHWnd
+ {$ENDIF}
+ Classes;
type
TChunkType = (illegal, header, track);
@@ -235,7 +237,13 @@ implementation
uses mmsystem;
-type TTimerProc=procedure(uTimerID,uMsg: Integer; dwUser,dwParam1,dwParam2:DWORD);stdcall;
+type
+{$IFDEF FPC}
+ TTimerProc = TTIMECALLBACK;
+ TTimeCaps = TIMECAPS;
+{$ELSE}
+ TTimerProc = TFNTimeCallBack;
+{$ENDIF}
const TIMER_RESOLUTION=10;
const WM_MULTIMEDIA_TIMER=WM_USER+127;
@@ -245,13 +253,13 @@ var MIDIFileHandle : HWND;
MIDITimerID : Integer;
TimerPeriod : Integer;
-procedure TimerCallBackProc(uTimerID,uMsg: Integer; dwUser,dwParam1,dwParam2:DWORD);stdcall;
+procedure TimerCallBackProc(uTimerID,uMsg: Cardinal; dwUser,dwParam1,dwParam2:DWORD);stdcall;
begin
PostMessage(HWND(dwUser),WM_MULTIMEDIA_TIMER,0,0);
end;
procedure SetMIDITimer;
- var TimeCaps : TTimeCaps ;
+ var TimeCaps : TTimeCaps;
begin
timeGetDevCaps(@TimeCaps,SizeOf(TimeCaps));
if TIMER_RESOLUTION < TimeCaps.wPeriodMin then
@@ -262,7 +270,7 @@ begin
TimerPeriod:=TIMER_RESOLUTION;
timeBeginPeriod(TimerPeriod);
- MIDITimerID:=timeSetEvent(TimerPeriod,TimerPeriod,@TimerProc,
+ MIDITimerID:=timeSetEvent(TimerPeriod,TimerPeriod,TimerProc,
DWORD(MIDIFileHandle),TIME_PERIODIC);
if MIDITimerID=0 then
timeEndPeriod(TimerPeriod);
@@ -428,7 +436,7 @@ begin
chunkData := nil;
chunkType := illegal;
Tracks := TList.Create;
- TimerProc:=TimerCallBackProc;
+ TimerProc:=@TimerCallBackProc;
FPriority:=GetPriorityClass(MIDIFileHandle);
end;
diff --git a/Game/Code/lib/midi/Midiin.pas b/Game/Code/lib/midi/Midiin.pas
index 32a17c51..6820a740 100644
--- a/Game/Code/lib/midi/Midiin.pas
+++ b/Game/Code/lib/midi/Midiin.pas
@@ -101,9 +101,24 @@ unit MidiIn;
interface
+{$IFDEF FPC}
+ {$MODE Delphi}
+{$ENDIF}
+
uses
- Classes, SysUtils, WinTypes, Messages, WinProcs, MMSystem, MidiDefs, MidiType,
- MidiCons, Circbuf, Delphmcb;
+ Classes,
+ SysUtils,
+ Messages,
+ Windows,
+ MMSystem,
+ {$IFDEF LCL}
+ LCLIntf, // used for AllocateHWnd
+ {$ENDIF}
+ MidiDefs,
+ MidiType,
+ MidiCons,
+ Circbuf,
+ Delphmcb;
type
MidiInputState = (misOpen, misClosed, misCreating, misDestroying);
@@ -121,7 +136,7 @@ type
FSysexOnly: Boolean;
{ Stuff from MIDIINCAPS }
- FDriverVersion: Version;
+ FDriverVersion: MMVERSION;
FProductName: string;
FMID: Word; { Manufacturer ID }
FPID: Word; { Product ID }
@@ -161,7 +176,7 @@ type
property MIDIHandle: HMIDIIn read FMIDIHandle;
- property DriverVersion: Version read FDriverVersion;
+ property DriverVersion: MMVERSION read FDriverVersion;
property MID: Word read FMID; { Manufacturer ID }
property PID: Word read FPID; { Product ID }
@@ -213,7 +228,6 @@ procedure Register;
implementation
uses Controls,
- Forms,
Graphics;
(* Not used in Delphi 3
diff --git a/Game/Code/lib/midi/Midiout.pas b/Game/Code/lib/midi/Midiout.pas
index 91b75073..7cab5c09 100644
--- a/Game/Code/lib/midi/Midiout.pas
+++ b/Game/Code/lib/midi/Midiout.pas
@@ -96,9 +96,28 @@ unit MidiOut;
interface
+{$IFDEF FPC}
+ {$MODE Delphi}
+{$ENDIF}
+
uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Controls, Forms,
- MMSystem, Circbuf, MidiType, MidiDefs, Delphmcb;
+ SysUtils,
+ Windows,
+ Messages,
+ Classes,
+ //Controls,
+ MMSystem,
+ {$IFDEF LCL}
+ LCLIntf, // used for AllocateHWnd
+ {$ENDIF}
+ Circbuf,
+ MidiType,
+ MidiDefs,
+ Delphmcb;
+
+{$IFDEF FPC}
+type TmidioutCaps = MIDIOUTCAPS;
+{$ENDIF}
type
midioutputState = (mosOpen, mosClosed);
@@ -136,7 +155,7 @@ type
FError: Word; { Last MMSYSTEM error }
{ Stuff from midioutCAPS }
- FDriverVersion: Version; { Driver version from midioutGetDevCaps }
+ FDriverVersion: MMVERSION; { Driver version from midioutGetDevCaps }
FProductName: string; { product name }
FTechnology: OutPortTech; { Type of MIDI output device }
FVoices: Word; { Number of voices (internal synth) }
@@ -159,7 +178,7 @@ type
public
{ Properties }
property MIDIHandle: Hmidiout read FMIDIHandle;
- property DriverVersion: Version { Driver version from midioutGetDevCaps }
+ property DriverVersion: MMVERSION { Driver version from midioutGetDevCaps }
read FDriverVersion;
property Technology: OutPortTech { Type of MIDI output device }
read FTechnology
diff --git a/Game/Code/switches.inc b/Game/Code/switches.inc
index d0cc9525..d0f187bb 100644
--- a/Game/Code/switches.inc
+++ b/Game/Code/switches.inc
@@ -24,12 +24,10 @@
{$DEFINE DLL_CDECL}
{$UNDEF UseSerialPort}
- {$UNDEF UseMIDIPort}
{$ELSE}
{$DEFINE Delphi}
{$DEFINE DLL_STDCALL}
{$UNDEF UseSerialPort}
- {$DEFINE UseMIDIPort}
{$ENDIF}
@@ -44,8 +42,8 @@
{$DEFINE UseBASSInput}
{$ELSE}
{$DEFINE UseFFMpegDecoder}
- {$DEFINE HaveAvcodecDecodeAudio2}
{$DEFINE UsePortaudioPlayback}
+ //{$DEFINE UseSDLPlayback}
{$DEFINE UsePortaudioInput}
{$DEFINE UsePortmixer}
{$ENDIF}
@@ -70,7 +68,11 @@
{$IFDEF DEBUG}
{$IFNDEF DARWIN}
{$APPTYPE CONSOLE}
- {$ENDIF}
+ {$ENDIF}
+ {$ENDIF}
+
+ {$IFDEF MSWINDOWS}
+ {$DEFINE UseMIDIPort}
{$ENDIF}
{$ELSEIF Defined(Linux)}
// include defines but no constants