www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/25/14:57:34

From: csantill AT lausd DOT k12 DOT ca DOT us
Message-ID: <33D8F6AC.4BD6@lausd.k12.ca.us>
Date: Fri, 25 Jul 1997 11:56:48 -0700
MIME-Version: 1.0
To: goober AT mail DOT net, djgpp AT delorie DOT com
Subject: Re: Is the FAQ wrong about FAR/NEAR ptr speed

This is a multi-part message in MIME format.

--------------2AF85C5F328B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

from: csantill AT lausd DOT k12 DOT ca DOT us

Well that's great because I didn't the type of pointer made a
difference.
I did the farnspokel optimizations on my own that you were talking about
& I found a 212% speed increase(from 90 FPS to 192 FPS) on my system. 
If
you could, & it wouldn't be too much trouble, could you test my code for
me
on your 486.  Thanx!

--------------2AF85C5F328B
Content-Type: text/plain; charset=us-ascii; name="Vga_pix.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Vga_pix.c"

#include <sys/farptr.h>
#include <sys/nearptr.h>
#include <dpmi.h>
#include <go32.h>

#include <time.h>

#include <stdlib.h>

#include <string.h>
#include <stdio.h>

enum GR_MODE{GR_INVALID=-1, GR_TEXT=0x03, GR_VGA=0x13};

enum GR_MODE Set_GR_Mode(enum GR_MODE mode)
{
  __dpmi_regs r;

  memset(&r, 0, sizeof(r));
  r.x.ax=mode;

  return(__dpmi_int(0x10,&r) ? GR_INVALID:mode);
}

void Put_Pix_Far(int x, int y, int c)
{
  _farpokeb(_dos_ds, 0xA0000+y*320+x,c);
  return;
}

void Put_Pix_Near(int x, int y, char c)
{
  char *v_m=(char *)(0xA0000+__djgpp_conventional_base);
  v_m[(y<<8)+(y<<6)+x] = c;
}

void fill_screen(char c)
{
  int x,y;
  unsigned long color=c+(long)(c<<8)+(long)(c<<16)+(long)(c<<24);

  _farsetsel(_dos_ds);

  for(y=0; y<200; y++)
    for(x=0; x<320; x=x+4)
      _farnspokel(0xA0000+(y<<8)+(y<<6)+x, color);
}
// ********************************************************************
int main(void)
{
  int x, y, co;

  uclock_t st[3], et[3];

  if(GR_INVALID==Set_GR_Mode(GR_VGA))
  {
    printf("Error setting mode 13h\n");
    exit(8);
  }

  st[0]=uclock();
  for(co=0; co<7680; co++)
    for(y=0; y<200; y++)
      for(x=0; x<320; x++)
        Put_Pix_Far(x,y,co%256);
  et[0]=uclock();

  st[1]=uclock();
  __djgpp_nearptr_enable();
  for(co=0; co<7680; co++)
    for(y=0; y<200; y++)
      for(x=0; x<320; x++)
        Put_Pix_Near(x,y,co%256);
  __djgpp_nearptr_disable();
  et[1]=uclock();

  st[2]=uclock();
  for(co=0; co<7680; co++)
    fill_screen(co % 256);
  et[2]=uclock();

  getchar();

  Set_GR_Mode(GR_TEXT);

  for(co=0; co<3; co++)
    printf("%i. FPS = %3.2f\n",co+1, (float)7680/((float)((et[co]-
            st[co])/UCLOCKS_PER_SEC)));

  printf("1 = Far Ptr\n2 = Near Ptr\n3 = FarnspokeL Fill screen\n");

  getchar();

  return 0;

}

--------------2AF85C5F328B--

- Raw text -


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