Game sometimes crashes upon exit (Developers)
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:
- Game sometimes crashes upon exit - KarlG, 28.05.2022, 21:59 (Developers)
- Game sometimes crashes upon exit - Japheth, 29.05.2022, 06:21
- Game sometimes crashes upon exit - tkchia, 29.05.2022, 09:53
- Game sometimes crashes upon exit - KarlG, 29.05.2022, 15:26
- Game sometimes crashes upon exit - KarlG, 29.05.2022, 15:24
- Game sometimes crashes upon exit - tkchia, 29.05.2022, 09:53
- Game sometimes crashes upon exit - Japheth, 29.05.2022, 06:21