From 03d27cc616ecd14c738b08305621f808bd42fb65 Mon Sep 17 00:00:00 2001 From: Jonathan Campbell Date: Thu, 3 Jan 2019 00:23:33 -0800 Subject: [PATCH] more --- hw/8254/tpcrapi5.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/hw/8254/tpcrapi5.c b/hw/8254/tpcrapi5.c index a8aa1d2f6..1fb128605 100644 --- a/hw/8254/tpcrapi5.c +++ b/hw/8254/tpcrapi5.c @@ -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;