delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/02/22/22:43:20

Date: Tue, 22 Feb 1994 21:42:23 -0500 (EST)
From: kenjordan AT BIX DOT com
Subject: GO32 interrupt woes
To: DJGPP AT sun DOT soe DOT clarkson DOT edu

/* DJGPP list subscribers,
   We would like to use GCC/GO32 for a real-time graphical program
   (read "game") but are having trouble getting interrupts when the program
   is in real mode (e.g., getkey in the BIOS).  This program demos the
   problem.  I believe this may also be the problem with the sound blaster
   example (oak.oakland.edu pub/msdos/djgpp/sblaster.zip).  I anyone can
   confirm that this is a GO32 problem or just stupidity on our part we
   would love to hear from you! - Thanx!

   Ken Jordan - Senior Software Engineer
   Philips Interactive Media
   POV Entertainment Group
   kenjordan AT bix DOT com  - P.S. comp.os.msdos.djgpp sounds great!
*/

/* Test program for GO32 interrupt handler                                  */
/* Shows problem with getting interrupts when in real mode (e.g. BIOS)      */
/* Usage: "inttest <test>" where test=1 to poll for key, 2=wait for key     */
/* ints get missed with test 1, and no ints occur with mode 2.               */

#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
#include <bios.h>
#include <dpmi.h>

_go32_dpmi_registers    GlobalDOSRegs;
_go32_dpmi_seginfo  OldInfo, NewInfo, OldDOSInfo, NewDOSInfo;
volatile int Ticks = 0, Protected = 0, Real = 0;

void MyInt(void) {  Ticks++; Protected++; } /* from prot mode int handler */
void MyOtherInt(void) { Ticks++; Real++; }  /* from real mode int handler */

void main(int argc, char **argv)
{
    struct time tm;
    unsigned long   count   = 0;
    int             seconds = 0;
    int             mode    = 1;
    unsigned int    t;

    if (argc != 1)
        if (sscanf(argv[1], "%d", &mode) != 1)
            mode = 1;

    if (mode < 1 || mode > 2)
        mode = 1;


/* setup prot mode handler (on 18 tps clock int) */
    _go32_dpmi_get_protected_mode_interrupt_vector(8, &OldInfo);
    NewInfo.pm_offset   = (int) MyInt;
    NewInfo.pm_selector = _go32_my_cs();
    _go32_dpmi_chain_protected_mode_interrupt_vector(8, &NewInfo);
/* setup (or at least try) prot mode int from real mode */  
    _go32_dpmi_get_real_mode_interrupt_vector(0x08, &OldDOSInfo);
    NewDOSInfo.pm_offset = (u_long)MyOtherInt;
    NewDOSInfo.pm_selector = _go32_my_cs();
    _go32_dpmi_allocate_real_mode_callback_iret(&NewDOSInfo, &GlobalDOSRegs);
    _go32_dpmi_set_real_mode_interrupt_vector(0x08, &NewDOSInfo);

    gettime(&tm);
    printf("\nCurrent time is: %02d:%02d:%02d:%03d - Press key to end test\n", tm.ti_hour, tm.ti_min, tm.ti_sec, tm.ti_hund);

    switch (mode)
    {
        case 1:
            while (bioskey(1) == 0)
                count++;
            bioskey(0);
            break;
        case 2:
            bioskey(0);
            break;
    }

    gettime(&tm);
    printf("\nCurrent time is: %02d:%02d:%02d:%03d\n", tm.ti_hour, tm.ti_min, tm.ti_sec, tm.ti_hund);
    printf("bioskey(1) called %u times\n", count);
    printf("Ticks tracked = %d\n", Ticks);

    printf("Real:  %d Protected: %d\n", Real, Protected);
    printf("Note, ticks were missed yet time appears to be correct....why?\n");
/* restore vectors */
	_go32_dpmi_set_protected_mode_interrupt_vector(8, &OldInfo);
    _go32_dpmi_set_real_mode_interrupt_vector(0x08, &OldDOSInfo);
    _go32_dpmi_free_real_mode_callback(&NewInfo);
}
/* EOF */

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019