Subversion Repositories spacemission

Rev

Rev 51 | Rev 61 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 51 Rev 54
1
unit Global;
1
unit Global;
2
 
2
 
3
interface
3
interface
4
 
4
 
5
const
5
const
6
  ProgramVersion = '1.2';
6
  ProgramVersion = '1.2';
7
  RasterW = 48;
7
  RasterW = 48;
8
  RasterH = 32;
8
  RasterH = 32;
9
  MaxPossibleEnemyLives = 999;
9
  MaxPossibleEnemyLives = 999;
10
  MaxPossibleLevels = 9999;
10
  MaxPossibleLevels = 9999;
11
  RegistrySettingsKey = 'SOFTWARE\ViaThinkSoft\SpaceMission\Settings';
11
  RegistrySettingsKey = 'SOFTWARE\ViaThinkSoft\SpaceMission\Settings';
12
  DefaultLevelLength = 1200;
12
  DefaultLevelLength = 1200;
-
 
13
  StartLives = 6;
-
 
14
  conleicht =  650 div 60; // 10
-
 
15
  conmittel = 1000 div 60; // 16
-
 
16
  conschwer = 1350 div 60; // 22
-
 
17
  conmaster = 2000 div 60; // 33
-
 
18
  DEFAULT_ANIMSPEED = 15/1000;
-
 
19
  ADDITIONAL_ENEMIES_PER_LEVEL = 75;
13
 
20
 
14
type
21
type
15
  // DirectX\Music.dxm
22
  // DirectX\Music.dxm
16
  TSpaceMissionMusicTrack = (
23
  TSpaceMissionMusicTrack = (
17
    smmNone,
24
    smmNone,
18
    smmBoss,   // dxmusic.Midis[0]
25
    smmBoss,   // dxmusic.Midis[0]
19
    smmGame,   // dxmusic.Midis[1]
26
    smmGame,   // dxmusic.Midis[1]
20
    smmScene,  // dxmusic.Midis[2]
27
    smmScene,  // dxmusic.Midis[2]
21
    smmTitle   // dxmusic.Midis[3]
28
    smmTitle   // dxmusic.Midis[3]
22
  );
29
  );
23
 
30
 
24
  // DirectX\Graphics.dxg
31
  // DirectX\Graphics.dxg
25
  TSpaceMissionGraphicSprite = (
32
  TSpaceMissionGraphicSprite = (
26
    smgNone,
33
    smgNone,
27
    smgEnemyDisk,         // ImageList.Items.Item[0]
34
    smgEnemyDisk,         // ImageList.Items.Item[0]
28
    smgEnemyAttacker,     // ImageList.Items.Item[1]
35
    smgEnemyAttacker,     // ImageList.Items.Item[1]
29
    smgEnemyBoss,         // ImageList.Items.Item[2]
36
    smgEnemyBoss,         // ImageList.Items.Item[2]
30
    smgBounce,            // ImageList.Items.Item[3]
37
    smgBounce,            // ImageList.Items.Item[3]
31
    smgMachine,           // ImageList.Items.Item[4]
38
    smgMachine,           // ImageList.Items.Item[4]
32
    smgEnemyAttacker2,    // ImageList.Items.Item[5]
39
    smgEnemyAttacker2,    // ImageList.Items.Item[5]
33
    smgEnemyAttacker3,    // ImageList.Items.Item[6]
40
    smgEnemyAttacker3,    // ImageList.Items.Item[6]
34
    smgEnemyMeteor,       // ImageList.Items.Item[7]
41
    smgEnemyMeteor,       // ImageList.Items.Item[7]
35
    smgBounce2,           // ImageList.Items.Item[8]
42
    smgBounce2,           // ImageList.Items.Item[8]
36
    smgEnemyDisk2,        // ImageList.Items.Item[9]
43
    smgEnemyDisk2,        // ImageList.Items.Item[9]
37
    smgLogo,              // ImageList.Items.Item[10]
44
    smgLogo,              // ImageList.Items.Item[10]
38
    smgExplosion,         // ImageList.Items.Item[11]
45
    smgExplosion,         // ImageList.Items.Item[11]
39
    smgBackgroundPlanet1, // ImageList.Items.Item[12]
46
    smgBackgroundPlanet1, // ImageList.Items.Item[12]
40
    smgMatrix,            // ImageList.Items.Item[13]
47
    smgMatrix,            // ImageList.Items.Item[13]
41
    smgStar1,             // ImageList.Items.Item[14]
48
    smgStar1,             // ImageList.Items.Item[14]
42
    smgStar2,             // ImageList.Items.Item[15]
49
    smgStar2,             // ImageList.Items.Item[15]
43
    smgStar3,             // ImageList.Items.Item[16]
50
    smgStar3,             // ImageList.Items.Item[16]
44
    smgBackgroundBlue,    // ImageList.Items.Item[17]
51
    smgBackgroundBlue,    // ImageList.Items.Item[17]
45
    smgBackgroundRed,     // ImageList.Items.Item[18]
52
    smgBackgroundRed,     // ImageList.Items.Item[18]
46
    smgBackgroundYellow,  // ImageList.Items.Item[19]
53
    smgBackgroundYellow,  // ImageList.Items.Item[19]
47
    smgHintergrundRot     // ImageList.Items.Item[20]
54
    smgHintergrundRot     // ImageList.Items.Item[20]
48
  );
55
  );
49
 
56
 
50
  // DirectX\Sound.dxw
57
  // DirectX\Sound.dxw
51
  TSpaceMissionSound = (
58
  TSpaceMissionSound = (
52
    smsNone,
59
    smsNone,
53
    smsSceneMov,      // WaveList.Items.Item[0]
60
    smsSceneMov,      // WaveList.Items.Item[0]
54
    smsExplosion,     // WaveList.Items.Item[1]
61
    smsExplosion,     // WaveList.Items.Item[1]
55
    smsHit,           // WaveList.Items.Item[2]
62
    smsHit,           // WaveList.Items.Item[2]
56
    smsShoot,         // WaveList.Items.Item[3]
63
    smsShoot,         // WaveList.Items.Item[3]
57
    smsDanger,        // WaveList.Items.Item[4]
64
    smsDanger,        // WaveList.Items.Item[4]
58
    smsEnde,          // WaveList.Items.Item[5]
65
    smsEnde,          // WaveList.Items.Item[5]
59
    smsFrage,         // WaveList.Items.Item[6]
66
    smsFrage,         // WaveList.Items.Item[6]
60
    smsLevIntro       // WaveList.Items.Item[7]
67
    smsLevIntro       // WaveList.Items.Item[7]
61
  );
68
  );
62
 
69
 
63
function OwnDirectory: string;
70
function OwnDirectory: string;
64
 
71
 
65
const
72
const
66
  FOLDERID_SavedGames: TGuid = '{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}';
73
  FOLDERID_SavedGames: TGuid = '{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}';
67
 
74
 
-
 
75
// Useful functions
68
function GetKnownFolderPath(const rfid: TGUID): string;
76
function GetKnownFolderPath(const rfid: TGUID): string;
-
 
77
function KillTask(ExeFileName: string): Integer;
69
 
78
 
70
implementation
79
implementation
71
 
80
 
72
uses
81
uses
73
  SysUtils, ActiveX, ShlObj;
82
  Windows, SysUtils, ActiveX, ShlObj, TlHelp32;
74
 
83
 
75
function GetKnownFolderPath(const rfid: TGUID): string;
84
function GetKnownFolderPath(const rfid: TGUID): string;
76
var
85
var
77
  OutPath: PWideChar;
86
  OutPath: PWideChar;
78
begin
87
begin
79
  // https://www.delphipraxis.net/135471-unit-zur-verwendung-von-shgetknownfolderpath.html
88
  // https://www.delphipraxis.net/135471-unit-zur-verwendung-von-shgetknownfolderpath.html
80
  if ShGetKnownFolderPath(rfid, 0, 0, OutPath) {>= 0} = S_OK then
89
  if ShGetKnownFolderPath(rfid, 0, 0, OutPath) {>= 0} = S_OK then
81
  begin
90
  begin
82
    Result := OutPath;
91
    Result := OutPath;
83
    // From MSDN
92
    // From MSDN
84
    // ppszPath [out]
93
    // ppszPath [out]
85
    // Type: PWSTR*
94
    // Type: PWSTR*
86
    // When this method returns, contains the address of a pointer to a null-terminated Unicode string that specifies the path of the known folder
95
    // When this method returns, contains the address of a pointer to a null-terminated Unicode string that specifies the path of the known folder
87
    // The calling process is responsible for freeing this resource once it is no longer needed by calling CoTaskMemFree.
96
    // The calling process is responsible for freeing this resource once it is no longer needed by calling CoTaskMemFree.
88
    // The returned path does not include a trailing backslash. For example, "C:\Users" is returned rather than "C:\Users\".
97
    // The returned path does not include a trailing backslash. For example, "C:\Users" is returned rather than "C:\Users\".
89
    CoTaskMemFree(OutPath);
98
    CoTaskMemFree(OutPath);
90
  end
99
  end
91
  else
100
  else
92
  begin
101
  begin
93
    Result := '';
102
    Result := '';
94
  end;
103
  end;
95
end;
104
end;
-
 
105
 
-
 
106
// https://stackoverflow.com/questions/43774320/how-to-kill-a-process-by-name
-
 
107
function KillTask(ExeFileName: string): Integer;
-
 
108
const
-
 
109
  PROCESS_TERMINATE = $0001;
-
 
110
var
-
 
111
  ContinueLoop: BOOL;
-
 
112
  FSnapshotHandle: THandle;
-
 
113
  FProcessEntry32: TProcessEntry32;
-
 
114
begin
-
 
115
  Result := 0;
-
 
116
  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
-
 
117
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
-
 
118
  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
-
 
119
 
-
 
120
  while Integer(ContinueLoop) <> 0 do
-
 
121
  begin
-
 
122
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
-
 
123
      UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
-
 
124
      UpperCase(ExeFileName))) then
-
 
125
      Result := Integer(TerminateProcess(
-
 
126
                        OpenProcess(PROCESS_TERMINATE,
-
 
127
                                    BOOL(0),
-
 
128
                                    FProcessEntry32.th32ProcessID),
-
 
129
                                    0));
-
 
130
     ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
-
 
131
  end;
-
 
132
  CloseHandle(FSnapshotHandle);
-
 
133
end;
96
 
134
 
97
function OwnDirectory: string;
135
function OwnDirectory: string;
98
begin
136
begin
99
  result := extractfilepath(paramstr(0));
137
  result := extractfilepath(paramstr(0));
100
end;
138
end;
101
 
139
 
102
end.
140
end.
103
 
141