Mail Archives: djgpp/2003/04/30/03:46:14
Hi, April 30, 2003
I am writing a music sequencer program for DOS using djgpp 2.01
and gcc 2.7.2.1, and it works well. However, I have a small
problem: Because I use my own timer interrupt,
the PC clock will not be updated during the time I run
the sequencer. Is it possible to jump from my interrupt routine
to the PC timer interrupt once in a while, to update the PC clock
at 18.2 Hz? Or is there another way to solve the problem?
Here is a sample of my code:
#include <dpmi.h>
#include <pc.h>
static int timer;
/*
* Timer interrupt
*/
void int08() {
timer++;
/*
* Is it possible to once in a while
* jump from here to the standard PC timer interrupt,
* so the PC clock will be updated to show correct value?
* If so, how do I do that?
*/
outportb(0x20,0x20); /* Send End of Interrupt */
}
int main(int argc,char *argv[]) {
static _go32_dpmi_seginfo oldint08,newint08;
static int i1=0;
/*
* Init timer interrupts
*/
_go32_dpmi_get_protected_mode_interrupt_vector(0x08,&oldint08);
newint08.pm_selector = _my_cs();
newint08.pm_offset = (unsigned)&int08;
_go32_dpmi_allocate_iret_wrapper(&newint08);
_go32_dpmi_set_protected_mode_interrupt_vector(0x08,&newint08);
i1 = 1193180.0/480.0;
outportb(0x40,i1 & 0xff);
outportb(0x40,i1 >> 8);
/*
* Run sequencer
*/
...
/*
* Reset timer interrupts
*/
outportb(0x40,0);
outportb(0x40,0);
_go32_dpmi_set_protected_mode_interrupt_vector(0x08,&oldint08);
_go32_dpmi_free_iret_wrapper(&newint08);
return(0);
}
Erik Berglund
Gothenbrug, Sweden
erik2 DOT berglund AT telia DOT com
- Raw text -