Commit 580a938

Nick committed on
Fixing sound bug (or feature?) where first channel played a tone on reset
commit 580a938a27f63bdb577967ccb4d9e1a8b699c291 parent 0c3510d
4 changed files +51−19
ModifiedSound/sound.pas +22−0
@@ -128,6 +128,7 @@ Bit0 Sound 1 on[1]/off[0]
128 128
129 procedure EnableSound; 129 procedure EnableSound;
130 procedure DisableSound; 130 procedure DisableSound;
131 procedure ResetSound;
131 procedure SoundUpdate(cycles: integer); 132 procedure SoundUpdate(cycles: integer);
132 procedure SoundSetCycles(n: integer); 133 procedure SoundSetCycles(n: integer);
133 134
@@ -165,6 +166,25 @@ var
165 playStream: HStream; 166 playStream: HStream;
166 bufCycles, bufLVal, bufRVal: integer; 167 bufCycles, bufLVal, bufRVal: integer;
167 168
169 procedure ResetSound;
170 var
171 i: Integer;
172 begin
173 for i := 0 to High(snd) do begin
174 with snd[i] do begin
175 ChannelOFF := False;
176 enable := False;
177 Freq := 0;
178 Vol := 0;
179 Len := 0;
180 swpCnt := 0;
181 EnvCnt := 0;
182 bit := 0;
183 cnt := 0;
184 end;
185 end;
186 end;
187
168 function SoundBufferTooFull: Boolean; 188 function SoundBufferTooFull: Boolean;
169 begin 189 begin
170 Result := BASS_ChannelGetData(PlayStream, nil, BASS_DATA_AVAILABLE) > TooFullThreshold; 190 Result := BASS_ChannelGetData(PlayStream, nil, BASS_DATA_AVAILABLE) > TooFullThreshold;
@@ -573,4 +593,6 @@ begin
573 sampleCycles := n; 593 sampleCycles := n;
574 end; 594 end;
575 595
596 begin
597 ResetSound
576 end. 598 end.
ModifiedUnitMain.lfm +26−17
@@ -1,17 +1,16 @@
1 object frmGameboy: TfrmGameboy 1 object frmGameboy: TfrmGameboy
2 Left = 3306 2 Left = 3306
3 Height = 354 3 Height = 236
4 Top = 338 4 Top = 338
5 Width = 318 5 Width = 212
6 Caption = 'Gameboy' 6 Caption = 'Gameboy'
7 ClientHeight = 324 7 ClientHeight = 216
8 ClientWidth = 318 8 ClientWidth = 212
9 Color = clYellow 9 Color = clYellow
10 DefaultMonitor = dmMainForm 10 DefaultMonitor = dmMainForm
11 DesignTimePPI = 144
12 Font.CharSet = ANSI_CHARSET 11 Font.CharSet = ANSI_CHARSET
13 Font.Color = clWindowText 12 Font.Color = clWindowText
14 Font.Height = -12 13 Font.Height = -8
15 Font.Name = 'Arial' 14 Font.Name = 'Arial'
16 Menu = MainMenu 15 Menu = MainMenu
17 OnActivate = FormActivate 16 OnActivate = FormActivate
@@ -22,38 +21,48 @@ object frmGameboy: TfrmGameboy
22 OnMouseDown = FormMouseDown 21 OnMouseDown = FormMouseDown
23 OnResize = FormResize 22 OnResize = FormResize
24 Position = poScreenCenter 23 Position = poScreenCenter
25 LCLVersion = '1.8.4.0' 24 LCLVersion = '2.0.2.0'
26 object StatusBar: TStatusBar 25 object StatusBar: TStatusBar
27 Left = 0 26 Left = 0
28 Height = 36 27 Height = 23
29 Top = 288 28 Top = 193
30 Width = 318 29 Width = 212
30 Font.CharSet = ANSI_CHARSET
31 Font.Color = clWindowText
32 Font.Height = -8
33 Font.Name = 'Arial'
31 Panels = < 34 Panels = <
32 item 35 item
33 Text = 'Memory' 36 Text = 'Memory'
34 Width = 80 37 Width = 53
35 end 38 end
36 item 39 item
37 Text = 'Gameboy' 40 Text = 'Gameboy'
38 Width = 145 41 Width = 97
39 end 42 end
40 item 43 item
41 Text = 'Company' 44 Text = 'Company'
42 Width = 50 45 Width = 33
43 end> 46 end>
44 ParentColor = False 47 ParentColor = False
48 ParentFont = False
45 SimplePanel = False 49 SimplePanel = False
46 end 50 end
47 object PaintBox1: TPaintBox 51 object PaintBox1: TPaintBox
48 Left = 0 52 Left = 0
49 Height = 288 53 Height = 193
50 Top = 0 54 Top = 0
51 Width = 318 55 Width = 212
52 Align = alClient 56 Align = alClient
57 Font.CharSet = ANSI_CHARSET
58 Font.Color = clWindowText
59 Font.Height = -8
60 Font.Name = 'Arial'
61 ParentFont = False
53 OnPaint = PaintBox1Paint 62 OnPaint = PaintBox1Paint
54 end 63 end
55 object MainMenu: TMainMenu 64 object MainMenu: TMainMenu
56 left = 56 65 left = 37
57 object File1: TMenuItem 66 object File1: TMenuItem
58 Caption = '&File' 67 Caption = '&File'
59 object Load1: TMenuItem 68 object Load1: TMenuItem
@@ -388,6 +397,6 @@ object frmGameboy: TfrmGameboy
388 Enabled = False 397 Enabled = False
389 Interval = 17 398 Interval = 17
390 OnTimer = TimerTimer 399 OnTimer = TimerTimer
391 left = 112 400 left = 75
392 end 401 end
393 end 402 end
ModifiedUnitMain.pas +1−0
@@ -263,6 +263,7 @@ begin
263 statusbar.panels[0].Text := romname; 263 statusbar.panels[0].Text := romname;
264 z80_reset; 264 z80_reset;
265 z80_reset; 265 z80_reset;
266 ResetSound;
266 f_stopped := False; 267 f_stopped := False;
267 gb_speed := 1; 268 gb_speed := 1;
268 loadstat.Enabled := True; 269 loadstat.Enabled := True;
Modifiedmainloop.pas +2−2
@@ -440,10 +440,10 @@ begin
440 spokeb($ff06, 0); 440 spokeb($ff06, 0);
441 spokeb($ff07, 0); 441 spokeb($ff07, 0);
442 spokeb($ff0f, $e1); 442 spokeb($ff0f, $e1);
443 spokeb($ff10, $80); 443 {spokeb($ff10, $80);
444 spokeb($ff11, $bf); 444 spokeb($ff11, $bf);
445 spokeb($ff12, $f3); 445 spokeb($ff12, $f3);
446 spokeb($ff14, $bf); 446 spokeb($ff14, $bf);}
447 spokeb($ff16, $3f); 447 spokeb($ff16, $3f);
448 spokeb($ff17, 0); 448 spokeb($ff17, 0);
449 spokeb($ff19, $bf); 449 spokeb($ff19, $bf);