Skip to content

Commit 03d27cc

Browse files
more
1 parent b0589c4 commit 03d27cc

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

hw/8254/tpcrapi5.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,69 @@ int main() {
110110
}
111111
}
112112

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+
113176
t8254_pc_speaker_set_gate(PC_SPEAKER_GATE_OFF);
114177
write_8254_system_timer(0); /* restore normal function to prevent BIOS from going crazy */
115178
return 0;

0 commit comments

Comments
 (0)