Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Game sometimes crashes upon exit (Developers)

posted by tkchia Homepage, 29.05.2022, 09:53

Hello KarlG, hello Japheth,

> > Watcom C compiler). Any thoughts or suggestions would be welcome!
> Since the crash occurs after the "old" interrupt vector has been restored,
> this saved vector most likely has been inadvertently modified.

A few other thoughts that I have, regarding the sound handling:

(1) Why does KillSound() want to write to port 0x40? This port controls PIT 0, the timer that controls IRQ 0 — and has nothing to do with sound, which is controlled by PIT 2. The program should not need to reprogram PIT 0.

(2) At the same time, the program probably does need to temporarily disable interrupts while starting or stopping sound, so that an IRQ does not mess up the ongoing port I/O.

So this is what I would propose for the relevant portions:


void ProcessSound() {
    ...
    _disable();
    outp( 0x43, 0xB6 );
    outp( 0x42, Freq&0xFF );
    outp( 0x42, ( Freq>>8 ) );
    outp( 0x61, ( inp( 0x61 ) | 3 ) );
    _enable();
}

void KillSound() {
    _disable();
    outp( 0x61, ( inp( 0x61 ) & 0xFC ) );
    _enable();
}

Thank you!

---
https://gitlab.com/tkchia · https://codeberg.org/tkchia · 😴 "MOV AX,0D500H+CMOS_REG_D+NMI"

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 80 users online (0 registered, 80 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum