Commit 2caeeb2

Nick committed on
Added timing to match speed of real gameboy
commit 2caeeb20ac487df4fe4bc2352b9da0ed51eee1b0 parent 5082da8
6 changed files +263−90
ModifiedGBEmu.lpi +7−4
@@ -40,7 +40,9 @@
40 <Unit1> 40 <Unit1>
41 <Filename Value="UnitMain.pas"/> 41 <Filename Value="UnitMain.pas"/>
42 <IsPartOfProject Value="True"/> 42 <IsPartOfProject Value="True"/>
43 <ComponentName Value="frmGameboy"/>
43 <HasResources Value="True"/> 44 <HasResources Value="True"/>
45 <ResourceBaseClass Value="Form"/>
44 </Unit1> 46 </Unit1>
45 <Unit2> 47 <Unit2>
46 <Filename Value="Debugger\debugger.pas"/> 48 <Filename Value="Debugger\debugger.pas"/>
@@ -55,15 +57,15 @@
55 <IsPartOfProject Value="True"/> 57 <IsPartOfProject Value="True"/>
56 </Unit4> 58 </Unit4>
57 <Unit5> 59 <Unit5>
58 <Filename Value="GPU\ddraw_out.pas"/> 60 <Filename Value="Gpu\ddraw_out.pas"/>
59 <IsPartOfProject Value="True"/> 61 <IsPartOfProject Value="True"/>
60 </Unit5> 62 </Unit5>
61 <Unit6> 63 <Unit6>
62 <Filename Value="GPU\dib_out.pas"/> 64 <Filename Value="Gpu\dib_out.pas"/>
63 <IsPartOfProject Value="True"/> 65 <IsPartOfProject Value="True"/>
64 </Unit6> 66 </Unit6>
65 <Unit7> 67 <Unit7>
66 <Filename Value="GPU\gfx.pas"/> 68 <Filename Value="Gpu\gfx.pas"/>
67 <IsPartOfProject Value="True"/> 69 <IsPartOfProject Value="True"/>
68 </Unit7> 70 </Unit7>
69 <Unit8> 71 <Unit8>
@@ -71,8 +73,9 @@
71 <IsPartOfProject Value="True"/> 73 <IsPartOfProject Value="True"/>
72 </Unit8> 74 </Unit8>
73 <Unit9> 75 <Unit9>
74 <Filename Value="CPU\z80cpu.pas"/> 76 <Filename Value="Cpu\z80cpu.pas"/>
75 <IsPartOfProject Value="True"/> 77 <IsPartOfProject Value="True"/>
78 <UnitName Value="Z80CPU"/>
76 </Unit9> 79 </Unit9>
77 <Unit10> 80 <Unit10>
78 <Filename Value="Sound\sound.pas"/> 81 <Filename Value="Sound\sound.pas"/>
ModifiedGBEmu.lps +212−67
@@ -4,33 +4,37 @@
4 <PathDelim Value="\"/> 4 <PathDelim Value="\"/>
5 <Version Value="10"/> 5 <Version Value="10"/>
6 <BuildModes Active="Default"/> 6 <BuildModes Active="Default"/>
7 <Units Count="27"> 7 <Units Count="30">
8 <Unit0> 8 <Unit0>
9 <Filename Value="GBEmu.lpr"/> 9 <Filename Value="GBEmu.lpr"/>
10 <IsPartOfProject Value="True"/> 10 <IsPartOfProject Value="True"/>
11 <EditorIndex Value="-1"/> 11 <EditorIndex Value="-1"/>
12 <TopLine Value="9"/> 12 <TopLine Value="2"/>
13 <CursorPos X="25" Y="12"/> 13 <CursorPos X="14" Y="7"/>
14 <UsageCount Value="21"/> 14 <UsageCount Value="27"/>
15 <DefaultSyntaxHighlighter Value="Delphi"/> 15 <DefaultSyntaxHighlighter Value="Delphi"/>
16 </Unit0> 16 </Unit0>
17 <Unit1> 17 <Unit1>
18 <Filename Value="UnitMain.pas"/> 18 <Filename Value="UnitMain.pas"/>
19 <IsPartOfProject Value="True"/> 19 <IsPartOfProject Value="True"/>
20 <ComponentName Value="frmGameboy"/>
20 <HasResources Value="True"/> 21 <HasResources Value="True"/>
21 <CursorPos X="49" Y="8"/> 22 <ResourceBaseClass Value="Form"/>
22 <UsageCount Value="21"/> 23 <IsVisibleTab Value="True"/>
24 <TopLine Value="286"/>
25 <CursorPos X="28" Y="311"/>
26 <UsageCount Value="27"/>
23 <Loaded Value="True"/> 27 <Loaded Value="True"/>
28 <LoadedDesigner Value="True"/>
24 <DefaultSyntaxHighlighter Value="Delphi"/> 29 <DefaultSyntaxHighlighter Value="Delphi"/>
25 </Unit1> 30 </Unit1>
26 <Unit2> 31 <Unit2>
27 <Filename Value="Debugger\debugger.pas"/> 32 <Filename Value="Debugger\debugger.pas"/>
28 <IsPartOfProject Value="True"/> 33 <IsPartOfProject Value="True"/>
29 <EditorIndex Value="-1"/> 34 <EditorIndex Value="-1"/>
30 <WindowIndex Value="-1"/> 35 <TopLine Value="1374"/>
31 <TopLine Value="-1"/> 36 <CursorPos X="22" Y="1374"/>
32 <CursorPos X="-1" Y="-1"/> 37 <UsageCount Value="27"/>
33 <UsageCount Value="21"/>
34 <DefaultSyntaxHighlighter Value="Delphi"/> 38 <DefaultSyntaxHighlighter Value="Delphi"/>
35 </Unit2> 39 </Unit2>
36 <Unit3> 40 <Unit3>
@@ -40,7 +44,7 @@
40 <WindowIndex Value="-1"/> 44 <WindowIndex Value="-1"/>
41 <TopLine Value="-1"/> 45 <TopLine Value="-1"/>
42 <CursorPos X="-1" Y="-1"/> 46 <CursorPos X="-1" Y="-1"/>
43 <UsageCount Value="21"/> 47 <UsageCount Value="27"/>
44 <DefaultSyntaxHighlighter Value="Delphi"/> 48 <DefaultSyntaxHighlighter Value="Delphi"/>
45 </Unit3> 49 </Unit3>
46 <Unit4> 50 <Unit4>
@@ -50,84 +54,85 @@
50 <WindowIndex Value="-1"/> 54 <WindowIndex Value="-1"/>
51 <TopLine Value="-1"/> 55 <TopLine Value="-1"/>
52 <CursorPos X="-1" Y="-1"/> 56 <CursorPos X="-1" Y="-1"/>
53 <UsageCount Value="21"/> 57 <UsageCount Value="27"/>
54 <DefaultSyntaxHighlighter Value="Delphi"/> 58 <DefaultSyntaxHighlighter Value="Delphi"/>
55 </Unit4> 59 </Unit4>
56 <Unit5> 60 <Unit5>
57 <Filename Value="GPU\ddraw_out.pas"/> 61 <Filename Value="Gpu\ddraw_out.pas"/>
58 <IsPartOfProject Value="True"/> 62 <IsPartOfProject Value="True"/>
59 <EditorIndex Value="-1"/> 63 <EditorIndex Value="-1"/>
60 <WindowIndex Value="-1"/> 64 <TopLine Value="210"/>
61 <TopLine Value="-1"/> 65 <CursorPos X="7" Y="227"/>
62 <CursorPos X="-1" Y="-1"/> 66 <UsageCount Value="27"/>
63 <UsageCount Value="21"/>
64 <DefaultSyntaxHighlighter Value="Delphi"/> 67 <DefaultSyntaxHighlighter Value="Delphi"/>
65 </Unit5> 68 </Unit5>
66 <Unit6> 69 <Unit6>
67 <Filename Value="GPU\dib_out.pas"/> 70 <Filename Value="Gpu\dib_out.pas"/>
68 <IsPartOfProject Value="True"/> 71 <IsPartOfProject Value="True"/>
69 <EditorIndex Value="-1"/> 72 <EditorIndex Value="3"/>
70 <WindowIndex Value="-1"/> 73 <TopLine Value="94"/>
71 <TopLine Value="-1"/> 74 <CursorPos Y="94"/>
72 <CursorPos X="-1" Y="-1"/> 75 <UsageCount Value="27"/>
73 <UsageCount Value="21"/> 76 <Loaded Value="True"/>
74 <DefaultSyntaxHighlighter Value="Delphi"/> 77 <DefaultSyntaxHighlighter Value="Delphi"/>
75 </Unit6> 78 </Unit6>
76 <Unit7> 79 <Unit7>
77 <Filename Value="GPU\gfx.pas"/> 80 <Filename Value="Gpu\gfx.pas"/>
78 <IsPartOfProject Value="True"/> 81 <IsPartOfProject Value="True"/>
79 <EditorIndex Value="-1"/> 82 <EditorIndex Value="-1"/>
80 <WindowIndex Value="-1"/> 83 <TopLine Value="332"/>
81 <TopLine Value="-1"/> 84 <CursorPos Y="332"/>
82 <CursorPos X="-1" Y="-1"/> 85 <UsageCount Value="27"/>
83 <UsageCount Value="21"/>
84 <DefaultSyntaxHighlighter Value="Delphi"/> 86 <DefaultSyntaxHighlighter Value="Delphi"/>
85 </Unit7> 87 </Unit7>
86 <Unit8> 88 <Unit8>
87 <Filename Value="CPU\machine.pas"/> 89 <Filename Value="CPU\machine.pas"/>
88 <IsPartOfProject Value="True"/> 90 <IsPartOfProject Value="True"/>
89 <EditorIndex Value="-1"/> 91 <EditorIndex Value="-1"/>
90 <WindowIndex Value="-1"/> 92 <TopLine Value="204"/>
91 <TopLine Value="-1"/> 93 <CursorPos Y="246"/>
92 <CursorPos X="-1" Y="-1"/> 94 <UsageCount Value="27"/>
93 <UsageCount Value="21"/>
94 <DefaultSyntaxHighlighter Value="Delphi"/> 95 <DefaultSyntaxHighlighter Value="Delphi"/>
95 </Unit8> 96 </Unit8>
96 <Unit9> 97 <Unit9>
97 <Filename Value="CPU\z80cpu.pas"/> 98 <Filename Value="Cpu\z80cpu.pas"/>
98 <IsPartOfProject Value="True"/> 99 <IsPartOfProject Value="True"/>
99 <EditorIndex Value="-1"/> 100 <UnitName Value="Z80CPU"/>
100 <WindowIndex Value="-1"/> 101 <EditorIndex Value="1"/>
101 <TopLine Value="-1"/> 102 <TopLine Value="7"/>
102 <CursorPos X="-1" Y="-1"/> 103 <CursorPos X="15" Y="17"/>
103 <UsageCount Value="21"/> 104 <UsageCount Value="27"/>
105 <Loaded Value="True"/>
104 <DefaultSyntaxHighlighter Value="Delphi"/> 106 <DefaultSyntaxHighlighter Value="Delphi"/>
105 </Unit9> 107 </Unit9>
106 <Unit10> 108 <Unit10>
107 <Filename Value="Sound\sound.pas"/> 109 <Filename Value="Sound\sound.pas"/>
108 <IsPartOfProject Value="True"/> 110 <IsPartOfProject Value="True"/>
109 <EditorIndex Value="-1"/> 111 <EditorIndex Value="2"/>
110 <TopLine Value="225"/> 112 <TopLine Value="628"/>
111 <UsageCount Value="21"/> 113 <CursorPos X="6" Y="631"/>
114 <UsageCount Value="27"/>
115 <Loaded Value="True"/>
112 <DefaultSyntaxHighlighter Value="Delphi"/> 116 <DefaultSyntaxHighlighter Value="Delphi"/>
113 </Unit10> 117 </Unit10>
114 <Unit11> 118 <Unit11>
115 <Filename Value="Global\vars.pas"/> 119 <Filename Value="Global\vars.pas"/>
116 <IsPartOfProject Value="True"/> 120 <IsPartOfProject Value="True"/>
117 <IsVisibleTab Value="True"/> 121 <EditorIndex Value="5"/>
118 <EditorIndex Value="1"/> 122 <TopLine Value="329"/>
119 <TopLine Value="319"/> 123 <CursorPos X="5" Y="339"/>
120 <CursorPos X="26" Y="77"/> 124 <UsageCount Value="27"/>
121 <UsageCount Value="21"/>
122 <Loaded Value="True"/> 125 <Loaded Value="True"/>
123 <DefaultSyntaxHighlighter Value="Delphi"/> 126 <DefaultSyntaxHighlighter Value="Delphi"/>
124 </Unit11> 127 </Unit11>
125 <Unit12> 128 <Unit12>
126 <Filename Value="mainloop.pas"/> 129 <Filename Value="mainloop.pas"/>
127 <IsPartOfProject Value="True"/> 130 <IsPartOfProject Value="True"/>
128 <EditorIndex Value="-1"/> 131 <EditorIndex Value="4"/>
129 <CursorPos X="33" Y="10"/> 132 <TopLine Value="3"/>
130 <UsageCount Value="21"/> 133 <CursorPos X="9" Y="21"/>
134 <UsageCount Value="27"/>
135 <Loaded Value="True"/>
131 <DefaultSyntaxHighlighter Value="Delphi"/> 136 <DefaultSyntaxHighlighter Value="Delphi"/>
132 </Unit12> 137 </Unit12>
133 <Unit13> 138 <Unit13>
@@ -135,56 +140,57 @@
135 <IsPartOfProject Value="True"/> 140 <IsPartOfProject Value="True"/>
136 <HasResources Value="True"/> 141 <HasResources Value="True"/>
137 <EditorIndex Value="-1"/> 142 <EditorIndex Value="-1"/>
138 <UsageCount Value="21"/> 143 <CursorPos Y="21"/>
144 <UsageCount Value="27"/>
139 <DefaultSyntaxHighlighter Value="Delphi"/> 145 <DefaultSyntaxHighlighter Value="Delphi"/>
140 </Unit13> 146 </Unit13>
141 <Unit14> 147 <Unit14>
142 <Filename Value="DirectX\Direct3DRM.pas"/> 148 <Filename Value="DirectX\Direct3DRM.pas"/>
143 <IsPartOfProject Value="True"/> 149 <IsPartOfProject Value="True"/>
144 <EditorIndex Value="-1"/> 150 <EditorIndex Value="-1"/>
145 <UsageCount Value="21"/> 151 <UsageCount Value="27"/>
146 <DefaultSyntaxHighlighter Value="Delphi"/> 152 <DefaultSyntaxHighlighter Value="Delphi"/>
147 </Unit14> 153 </Unit14>
148 <Unit15> 154 <Unit15>
149 <Filename Value="DirectX\DirectInput.pas"/> 155 <Filename Value="DirectX\DirectInput.pas"/>
150 <IsPartOfProject Value="True"/> 156 <IsPartOfProject Value="True"/>
151 <EditorIndex Value="-1"/> 157 <EditorIndex Value="-1"/>
152 <UsageCount Value="21"/> 158 <UsageCount Value="27"/>
153 <DefaultSyntaxHighlighter Value="Delphi"/> 159 <DefaultSyntaxHighlighter Value="Delphi"/>
154 </Unit15> 160 </Unit15>
155 <Unit16> 161 <Unit16>
156 <Filename Value="DirectX\DirectMusic.pas"/> 162 <Filename Value="DirectX\DirectMusic.pas"/>
157 <IsPartOfProject Value="True"/> 163 <IsPartOfProject Value="True"/>
158 <EditorIndex Value="-1"/> 164 <EditorIndex Value="-1"/>
159 <UsageCount Value="21"/> 165 <UsageCount Value="27"/>
160 <DefaultSyntaxHighlighter Value="Delphi"/> 166 <DefaultSyntaxHighlighter Value="Delphi"/>
161 </Unit16> 167 </Unit16>
162 <Unit17> 168 <Unit17>
163 <Filename Value="DirectX\DirectPlay.pas"/> 169 <Filename Value="DirectX\DirectPlay.pas"/>
164 <IsPartOfProject Value="True"/> 170 <IsPartOfProject Value="True"/>
165 <EditorIndex Value="-1"/> 171 <EditorIndex Value="-1"/>
166 <UsageCount Value="21"/> 172 <UsageCount Value="27"/>
167 <DefaultSyntaxHighlighter Value="Delphi"/> 173 <DefaultSyntaxHighlighter Value="Delphi"/>
168 </Unit17> 174 </Unit17>
169 <Unit18> 175 <Unit18>
170 <Filename Value="DirectX\DirectSetup.pas"/> 176 <Filename Value="DirectX\DirectSetup.pas"/>
171 <IsPartOfProject Value="True"/> 177 <IsPartOfProject Value="True"/>
172 <EditorIndex Value="-1"/> 178 <EditorIndex Value="-1"/>
173 <UsageCount Value="21"/> 179 <UsageCount Value="27"/>
174 <DefaultSyntaxHighlighter Value="Delphi"/> 180 <DefaultSyntaxHighlighter Value="Delphi"/>
175 </Unit18> 181 </Unit18>
176 <Unit19> 182 <Unit19>
177 <Filename Value="DirectX\DirectSound.pas"/> 183 <Filename Value="DirectX\DirectSound.pas"/>
178 <IsPartOfProject Value="True"/> 184 <IsPartOfProject Value="True"/>
179 <EditorIndex Value="-1"/> 185 <EditorIndex Value="-1"/>
180 <UsageCount Value="21"/> 186 <UsageCount Value="27"/>
181 <DefaultSyntaxHighlighter Value="Delphi"/> 187 <DefaultSyntaxHighlighter Value="Delphi"/>
182 </Unit19> 188 </Unit19>
183 <Unit20> 189 <Unit20>
184 <Filename Value="DirectX\Direct3D.pas"/> 190 <Filename Value="DirectX\Direct3D.pas"/>
185 <IsPartOfProject Value="True"/> 191 <IsPartOfProject Value="True"/>
186 <EditorIndex Value="-1"/> 192 <EditorIndex Value="-1"/>
187 <UsageCount Value="21"/> 193 <UsageCount Value="27"/>
188 <DefaultSyntaxHighlighter Value="Delphi"/> 194 <DefaultSyntaxHighlighter Value="Delphi"/>
189 </Unit20> 195 </Unit20>
190 <Unit21> 196 <Unit21>
@@ -192,8 +198,9 @@
192 <IsPartOfProject Value="True"/> 198 <IsPartOfProject Value="True"/>
193 <HasResources Value="True"/> 199 <HasResources Value="True"/>
194 <EditorIndex Value="-1"/> 200 <EditorIndex Value="-1"/>
195 <CursorPos X="12" Y="4"/> 201 <TopLine Value="372"/>
196 <UsageCount Value="21"/> 202 <CursorPos X="33" Y="405"/>
203 <UsageCount Value="27"/>
197 <DefaultSyntaxHighlighter Value="Delphi"/> 204 <DefaultSyntaxHighlighter Value="Delphi"/>
198 </Unit21> 205 </Unit21>
199 <Unit22> 206 <Unit22>
@@ -202,7 +209,7 @@
202 <EditorIndex Value="-1"/> 209 <EditorIndex Value="-1"/>
203 <TopLine Value="154"/> 210 <TopLine Value="154"/>
204 <CursorPos X="21" Y="182"/> 211 <CursorPos X="21" Y="182"/>
205 <UsageCount Value="21"/> 212 <UsageCount Value="27"/>
206 <DefaultSyntaxHighlighter Value="Delphi"/> 213 <DefaultSyntaxHighlighter Value="Delphi"/>
207 </Unit22> 214 </Unit22>
208 <Unit23> 215 <Unit23>
@@ -210,7 +217,7 @@
210 <EditorIndex Value="-1"/> 217 <EditorIndex Value="-1"/>
211 <TopLine Value="121"/> 218 <TopLine Value="121"/>
212 <CursorPos X="27" Y="126"/> 219 <CursorPos X="27" Y="126"/>
213 <UsageCount Value="10"/> 220 <UsageCount Value="9"/>
214 <DefaultSyntaxHighlighter Value="Delphi"/> 221 <DefaultSyntaxHighlighter Value="Delphi"/>
215 </Unit23> 222 </Unit23>
216 <Unit24> 223 <Unit24>
@@ -220,7 +227,7 @@
220 <ResourceBaseClass Value="Form"/> 227 <ResourceBaseClass Value="Form"/>
221 <EditorIndex Value="-1"/> 228 <EditorIndex Value="-1"/>
222 <WindowIndex Value="-1"/> 229 <WindowIndex Value="-1"/>
223 <UsageCount Value="10"/> 230 <UsageCount Value="9"/>
224 <DefaultSyntaxHighlighter Value="LFM"/> 231 <DefaultSyntaxHighlighter Value="LFM"/>
225 </Unit24> 232 </Unit24>
226 <Unit25> 233 <Unit25>
@@ -228,20 +235,158 @@
228 <EditorIndex Value="-1"/> 235 <EditorIndex Value="-1"/>
229 <TopLine Value="3881"/> 236 <TopLine Value="3881"/>
230 <CursorPos Y="3898"/> 237 <CursorPos Y="3898"/>
231 <UsageCount Value="10"/> 238 <UsageCount Value="9"/>
232 </Unit25> 239 </Unit25>
233 <Unit26> 240 <Unit26>
234 <Filename Value="..\..\UGE\UnitMain.lfm"/> 241 <Filename Value="..\..\UGE\UnitMain.lfm"/>
235 <EditorIndex Value="-1"/> 242 <EditorIndex Value="-1"/>
236 <UsageCount Value="10"/> 243 <UsageCount Value="9"/>
237 <DefaultSyntaxHighlighter Value="LFM"/> 244 <DefaultSyntaxHighlighter Value="LFM"/>
238 </Unit26> 245 </Unit26>
246 <Unit27>
247 <Filename Value="Gameboy.lpr"/>
248 <EditorIndex Value="-1"/>
249 <TopLine Value="60"/>
250 <CursorPos Y="60"/>
251 <UsageCount Value="9"/>
252 <DefaultSyntaxHighlighter Value="Delphi"/>
253 </Unit27>
254 <Unit28>
255 <Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\inc\systemh.inc"/>
256 <EditorIndex Value="-1"/>
257 <TopLine Value="764"/>
258 <CursorPos X="11" Y="777"/>
259 <UsageCount Value="9"/>
260 </Unit28>
261 <Unit29>
262 <Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\win\wininc\redef.inc"/>
263 <EditorIndex Value="-1"/>
264 <TopLine Value="727"/>
265 <CursorPos X="10" Y="745"/>
266 <UsageCount Value="9"/>
267 </Unit29>
239 </Units> 268 </Units>
240 <JumpHistory Count="1"> 269 <JumpHistory Count="30" HistoryIndex="29">
241 <Position1> 270 <Position1>
242 <Filename Value="Global\vars.pas"/> 271 <Filename Value="UnitMain.pas"/>
243 <Caret Line="90" Column="22" TopLine="73"/> 272 <Caret Line="241" Column="28" TopLine="232"/>
244 </Position1> 273 </Position1>
274 <Position2>
275 <Filename Value="UnitMain.pas"/>
276 <Caret Line="248" Column="29" TopLine="232"/>
277 </Position2>
278 <Position3>
279 <Filename Value="UnitMain.pas"/>
280 <Caret Line="285" Column="14" TopLine="272"/>
281 </Position3>
282 <Position4>
283 <Filename Value="mainloop.pas"/>
284 <Caret Line="21" Column="11" TopLine="12"/>
285 </Position4>
286 <Position5>
287 <Filename Value="UnitMain.pas"/>
288 <Caret Line="267" Column="11" TopLine="261"/>
289 </Position5>
290 <Position6>
291 <Filename Value="Sound\sound.pas"/>
292 <Caret Line="229" Column="12" TopLine="226"/>
293 </Position6>
294 <Position7>
295 <Filename Value="Sound\sound.pas"/>
296 <Caret Line="222" Column="44" TopLine="211"/>
297 </Position7>
298 <Position8>
299 <Filename Value="Sound\sound.pas"/>
300 <Caret Line="229" Column="11" TopLine="211"/>
301 </Position8>
302 <Position9>
303 <Filename Value="Sound\sound.pas"/>
304 <Caret Line="131" Column="11" TopLine="113"/>
305 </Position9>
306 <Position10>
307 <Filename Value="Sound\sound.pas"/>
308 <Caret Line="229" Column="11" TopLine="211"/>
309 </Position10>
310 <Position11>
311 <Filename Value="Sound\sound.pas"/>
312 <Caret Line="131" Column="11" TopLine="113"/>
313 </Position11>
314 <Position12>
315 <Filename Value="Sound\sound.pas"/>
316 <Caret Line="229" Column="11" TopLine="211"/>
317 </Position12>
318 <Position13>
319 <Filename Value="Sound\sound.pas"/>
320 <Caret Line="131" Column="11" TopLine="113"/>
321 </Position13>
322 <Position14>
323 <Filename Value="UnitMain.pas"/>
324 <Caret Line="277" Column="13" TopLine="269"/>
325 </Position14>
326 <Position15>
327 <Filename Value="Sound\sound.pas"/>
328 <Caret Line="455" Column="17" TopLine="451"/>
329 </Position15>
330 <Position16>
331 <Filename Value="Sound\sound.pas"/>
332 <Caret Line="457" Column="6" TopLine="448"/>
333 </Position16>
334 <Position17>
335 <Filename Value="UnitMain.pas"/>
336 <Caret Line="550" Column="6" TopLine="544"/>
337 </Position17>
338 <Position18>
339 <Filename Value="UnitMain.pas"/>
340 <Caret Line="283" Column="11" TopLine="267"/>
341 </Position18>
342 <Position19>
343 <Filename Value="mainloop.pas"/>
344 <Caret Line="21" Column="11" TopLine="3"/>
345 </Position19>
346 <Position20>
347 <Filename Value="UnitMain.pas"/>
348 <Caret Line="278" Column="27" TopLine="263"/>
349 </Position20>
350 <Position21>
351 <Filename Value="UnitMain.pas"/>
352 <Caret Line="294" Column="38" TopLine="278"/>
353 </Position21>
354 <Position22>
355 <Filename Value="Cpu\z80cpu.pas"/>
356 <Caret Line="217" Column="5" TopLine="204"/>
357 </Position22>
358 <Position23>
359 <Filename Value="mainloop.pas"/>
360 <Caret Line="415" Column="19" TopLine="392"/>
361 </Position23>
362 <Position24>
363 <Filename Value="mainloop.pas"/>
364 <Caret Line="293" TopLine="277"/>
365 </Position24>
366 <Position25>
367 <Filename Value="mainloop.pas"/>
368 <Caret Line="294" Column="20" TopLine="277"/>
369 </Position25>
370 <Position26>
371 <Filename Value="UnitMain.pas"/>
372 <Caret Line="280" Column="27" TopLine="263"/>
373 </Position26>
374 <Position27>
375 <Filename Value="UnitMain.pas"/>
376 <Caret Line="301" Column="32" TopLine="273"/>
377 </Position27>
378 <Position28>
379 <Filename Value="UnitMain.pas"/>
380 <Caret Line="305" Column="38" TopLine="281"/>
381 </Position28>
382 <Position29>
383 <Filename Value="UnitMain.pas"/>
384 <Caret Line="315" TopLine="290"/>
385 </Position29>
386 <Position30>
387 <Filename Value="UnitMain.pas"/>
388 <Caret Line="324" TopLine="296"/>
389 </Position30>
245 </JumpHistory> 390 </JumpHistory>
246 </ProjectSession> 391 </ProjectSession>
247 </CONFIG> 392 </CONFIG>
ModifiedGlobal/vars.pas +1−1
@@ -12,7 +12,7 @@ uses Windows, DirectDraw;
12 const 12 const
13 thr_f: integer = 1; 13 thr_f: integer = 1;
14 cart: pointer = nil; // Cartdridge 14 cart: pointer = nil; // Cartdridge
15 isddraw: boolean = False; // DirectDraw; 15 isddraw: boolean = True; // DirectDraw;
16 16
17 var 17 var
18 bdrop, dirname, dirload: string; 18 bdrop, dirname, dirload: string;
ModifiedUnitMain.lfm +3−2
@@ -1,7 +1,7 @@
1 object frmGameboy: TfrmGameboy 1 object frmGameboy: TfrmGameboy
2 Left = 387 2 Left = 2719
3 Height = 354 3 Height = 354
4 Top = 232 4 Top = 151
5 Width = 318 5 Width = 318
6 Caption = 'Gameboy' 6 Caption = 'Gameboy'
7 ClientHeight = 320 7 ClientHeight = 320
@@ -41,6 +41,7 @@ object frmGameboy: TfrmGameboy
41 Text = 'Company' 41 Text = 'Company'
42 Width = 50 42 Width = 50
43 end> 43 end>
44 ParentColor = False
44 SimplePanel = False 45 SimplePanel = False
45 end 46 end
46 object MainMenu: TMainMenu 47 object MainMenu: TMainMenu
ModifiedUnitMain.pas +36−13
@@ -260,40 +260,63 @@ begin
260 timervar := 0; 260 timervar := 0;
261 end; 261 end;
262 262
263 const
264 CyclesPerFrame : Integer = 70224;
265 TimePerFrame: Double = 1.0 / 60.0;
263 266
264 procedure TfrmGameboy.Emulation(var Msg: TMessage); 267 procedure TfrmGameboy.Emulation(var Msg: TMessage);
265 var 268 var
266 Count: DWord; 269 Count: DWord;
267 i: byte; 270 i: byte;
268 wasteTime: byte;
269 idx: integer; 271 idx: integer;
272 li: Large_Integer;
273 tickFreq, cycles: Integer;
274 frameStart, frameEnd: Integer;
275 frameElapsedInSec: Double;
270 begin 276 begin
271 idx := 0; 277 idx := 0;
272 wasteTime := 0;
273
274 lastTime := 0; 278 lastTime := 0;
275 Count := 0; 279 Count := 0;
276 i := 0; 280 i := 0;
277 281
282 cycles := 0;
283
284 QueryPerformanceFrequency(@li);
285 tickFreq := li.QuadPart;
286 QueryPerformanceCounter(@li);
287 frameStart := li.QuadPart;
288
278 repeat 289 repeat
290 application.ProcessMessages;
291
279 // Pause 292 // Pause
280 if f_stopped then 293 if f_stopped then
281 while f_stopped do 294 while f_stopped do
282 application.ProcessMessages; 295 application.ProcessMessages;
283 296
284 z80_decode; 297 while (cycles < CyclesPerFrame) do
298 cycles += z80_decode;
285 299
286 if Count = 0 then 300 cycles -= CyclesPerFrame;
287 application.ProcessMessages;
288 Count := (Count + 1) mod 10000;
289 301
290 if screen_updated > 0 then // onpaint :) 302 while True do begin
291 begin 303 QueryPerformanceCounter(@li);
292 screen_updated := 0; 304 frameEnd := li.QuadPart;
293 if i = 0 then 305
294 RealSpeedEmulation; 306 frameElapsedInSec := (frameEnd - frameStart) / tickFreq;
295 i := (i + 1) mod 31; 307 if frameElapsedInSec > TimePerFrame then
308 Break;
296 end; 309 end;
310
311 frameStart := frameEnd;
312
313 //if screen_updated > 0 then // onpaint :)
314 //begin
315 // screen_updated := 0;
316 // if i = 0 then
317 // RealSpeedEmulation;
318 // i := (i + 1) mod 31;
319 //end;
297 until application.Terminated; 320 until application.Terminated;
298 end; 321 end;
299 322
Modifiedmainloop.pas +4−3
@@ -18,7 +18,7 @@ uses Windows;
18 function main_loop(a: DWord): DWORD; 18 function main_loop(a: DWord): DWORD;
19 procedure setzewindow(h_wnd: HWND); 19 procedure setzewindow(h_wnd: HWND);
20 20
21 procedure z80_decode; pascal; 21 function z80_decode : Byte; pascal;
22 procedure z80_reset; 22 procedure z80_reset;
23 23
24 var 24 var
@@ -291,9 +291,9 @@ end;
291 const 291 const
292 cycles_per_hblank = 451; 292 cycles_per_hblank = 451;
293 293
294 procedure z80_decode; 294 function z80_decode : Byte;
295 var 295 var
296 Count: byte; 296 Count: Byte;
297 begin 297 begin
298 if (gbr_ime) and (m_iram[$ff0f] and 31 > 0) then 298 if (gbr_ime) and (m_iram[$ff0f] and 31 > 0) then
299 IFlags; // Start Interupt 299 IFlags; // Start Interupt
@@ -412,6 +412,7 @@ begin
412 end; 412 end;
413 end; 413 end;
414 414
415 Result := Count;
415 end; 416 end;
416 417
417 procedure z80_reset; 418 procedure z80_reset;