@@ -110,6 +110,69 @@ int main() {
110
110
}
111
111
}
112
112
113
+ printf ("Again, without waiting for the first countdown.\n" );
114
+ printf ("The following test may be completely silent.\n" );
115
+
116
+ for (freq = 0x10000 ;freq >= 0x800 ;) {
117
+ t8254_pc_speaker_set_gate (PC_SPEAKER_GATE_OFF );
118
+ write_8254_pc_speaker ((t8254_time_t )freq );
119
+ t8254_pc_speaker_set_gate (PC_SPEAKER_GATE_ON );
120
+
121
+ cyclesub = (0x100ul * (freq - 0x800ul )) / 0x10000ul ;
122
+ if (cyclesub == 0 ) cyclesub = 1 ;
123
+
124
+ printf ("Without waiting for first cycle, count 0x%lx sub=0x%lx... " ,freq ,cyclesub ); fflush (stdout );
125
+
126
+ cc = read_8254 (T8254_TIMER_PC_SPEAKER );
127
+ do {
128
+ pcc = cc ;
129
+ cc = read_8254 (T8254_TIMER_PC_SPEAKER );
130
+ } while (cc < pcc /*counts DOWN*/ );
131
+
132
+ for (count = 0 ;count < 1 ;count ++ ) {
133
+ cc = read_8254 (T8254_TIMER_PC_SPEAKER );
134
+ for (cycleout = 0x400 ;cycleout < freq ;cycleout += cyclesub ) {
135
+ /* wait for countdown cycle to hit our threshhold */
136
+ do {
137
+ pcc = cc ;
138
+ cc = read_8254 (T8254_TIMER_PC_SPEAKER );
139
+ } while (cc >= cycleout );
140
+
141
+ write_8254_pc_speaker ((t8254_time_t )freq );
142
+
143
+ /* wait for countdown cycle to complete */
144
+ do {
145
+ pcc = cc ;
146
+ cc = read_8254 (T8254_TIMER_PC_SPEAKER );
147
+ } while (cc < pcc /*counts DOWN*/ );
148
+ }
149
+ }
150
+
151
+ printf ("done\n" );
152
+
153
+ if (kbhit ()) {
154
+ c = getch ();
155
+ if (c == 27 ) {
156
+ freq = 0 ;
157
+ break ;
158
+ }
159
+ else if (c == 32 ) {
160
+ break ;
161
+ }
162
+ }
163
+
164
+ if (freq > 0xFFFEu )
165
+ freq -- ;
166
+ else if (freq >= 0x4000u ) {
167
+ freq -= 0x2000u ;
168
+ freq &= ~0x1FFFu ;
169
+ }
170
+ else if (freq != 0u ) {
171
+ freq -= 0x400u ;
172
+ freq &= ~0x3FFu ;
173
+ }
174
+ }
175
+
113
176
t8254_pc_speaker_set_gate (PC_SPEAKER_GATE_OFF );
114
177
write_8254_system_timer (0 ); /* restore normal function to prevent BIOS from going crazy */
115
178
return 0 ;
0 commit comments