Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
joncampbell123 committed Jan 3, 2019
1 parent b0589c4 commit 03d27cc
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions hw/8254/tpcrapi5.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,69 @@ int main() {
}
}

printf("Again, without waiting for the first countdown.\n");
printf("The following test may be completely silent.\n");

for (freq=0x10000;freq >= 0x800;) {
t8254_pc_speaker_set_gate(PC_SPEAKER_GATE_OFF);
write_8254_pc_speaker((t8254_time_t)freq);
t8254_pc_speaker_set_gate(PC_SPEAKER_GATE_ON);

cyclesub = (0x100ul * (freq - 0x800ul)) / 0x10000ul;
if (cyclesub == 0) cyclesub = 1;

printf("Without waiting for first cycle, count 0x%lx sub=0x%lx... ",freq,cyclesub); fflush(stdout);

cc = read_8254(T8254_TIMER_PC_SPEAKER);
do {
pcc = cc;
cc = read_8254(T8254_TIMER_PC_SPEAKER);
} while (cc < pcc/*counts DOWN*/);

for (count=0;count < 1;count++) {
cc = read_8254(T8254_TIMER_PC_SPEAKER);
for (cycleout=0x400;cycleout < freq;cycleout += cyclesub) {
/* wait for countdown cycle to hit our threshhold */
do {
pcc = cc;
cc = read_8254(T8254_TIMER_PC_SPEAKER);
} while (cc >= cycleout);

write_8254_pc_speaker((t8254_time_t)freq);

/* wait for countdown cycle to complete */
do {
pcc = cc;
cc = read_8254(T8254_TIMER_PC_SPEAKER);
} while (cc < pcc/*counts DOWN*/);
}
}

printf("done\n");

if (kbhit()) {
c = getch();
if (c == 27) {
freq = 0;
break;
}
else if (c == 32) {
break;
}
}

if (freq > 0xFFFEu)
freq--;
else if (freq >= 0x4000u) {
freq -= 0x2000u;
freq &= ~0x1FFFu;
}
else if (freq != 0u) {
freq -= 0x400u;
freq &= ~0x3FFu;
}
}

t8254_pc_speaker_set_gate(PC_SPEAKER_GATE_OFF);
write_8254_system_timer(0); /* restore normal function to prevent BIOS from going crazy */
return 0;
Expand Down

0 comments on commit 03d27cc

Please sign in to comment.