delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/18/10:54:31

From: tbelius AT algonet DOT se
Newsgroups: comp.os.msdos.djgpp
Subject: Graphics in djgpp and inline asm in djgpp
Date: Sat, 18 Sep 1999 14:11:24 GMT
Organization: Telenordia
Lines: 134
Message-ID: <363f3759.2670843@news.algonet.se>
NNTP-Posting-Host: sdu183-75.ppp.algonet.se
X-Trace: zingo.tninet.se 937664150 25292 195.163.75.183 (18 Sep 1999 14:15:50 GMT)
X-Complaints-To: abuse AT algo DOT net
NNTP-Posting-Date: 18 Sep 1999 14:15:50 GMT
X-Newsreader: Forte Free Agent 1.11/32.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I need help with 2 things:

1. I need to convert this asm code for waiting for the vertical
retrace converted to a function that djgpp accepts.
I am trying to learn asm but i havnt come so long
that i can do it myself. I did notice one thing thow.
Are the in al,dx instructions valid? The lx and dx
regs are of different size right?
What does the in intruction do anyway?
Can you use this function under windows?

mov dx,3DAh
l1:
    in al,dx
    and al,08h
    jnz l1
l2:
    in al,dx
    and al,08h
    jz  l2

2. I used these routines(below) for graphics before 
i changed to djgpp. When i use djgpp they dont 
work(execept set_mode). I have figured out its beacause you cant
use far pointers and different memory models in djgpp.
If some1 could help me to port this code to djgpp code
or has any other code for graphics in djgpp it would be very help full
if you sent them to my(i dont want to use allergo).

- David Belius

#define VIDEO_INT           0x10      /* the BIOS video interrupt. */
#define VIDEO_INT           0x10      /* the BIOS video interrupt. */
#define SET_MODE            0x00      /* BIOS func to set the video
mode. */
#define VGA_MODE            0x13      /* use to set 256-color mode. */
#define TEXT_MODE           0x03      /* use to set 80x25 text mode.
*/

#define VGA_SCREEN_WIDTH        320       /* width in pixels of mode
0x13 */
#define VGA_SCREEN_HEIGHT       200       /* height in pixels of mode
0x13 */
#define VGA_NUM_COLORS          256       /* number of colors in mode
0x13 */


unsigned char *screen=(unsigned char*)0xA0000000L;        /* this
points to video memory. */
unsigned short *my_clock=(unsigned short*)0x0000046C;    /* this
points to the 18.2hz system*/


void set_mode(unsigned char mode)
{
  union REGS regs;

  regs.h.ah = SET_MODE;
  regs.h.al = mode;
  int86(VIDEO_INT, &regs, &regs);
}

void put_pix(unsigned char *scr,int x,int y,unsigned char color)
{
  scr[y*VGA_SCREEN_WIDTH+x]=color;
}

void get_pix(unsigned char *scr,int x,int y,unsigned char *color)
{
  *color=scr[y*VGA_SCREEN_WIDTH+x];
}

void get_pal(unsigned char c,unsigned char *r,unsigned char
*g,unsigned char *b)
{
outp(0x03C7,c);
*r=inp(0x03C9);
*g=inp(0x03C9);
*b=inp(0x03C9);
}

void set_pal(unsigned char c,unsigned char r,unsigned char g,unsigned
char b)
{
outp(0x03C8,c);
outp(0x03C9,r);
outp(0x03C9,b);
outp(0x03C9,g);
}

int sgn(double a)
{
     if(a>0) return(1);
     if(a<0) return(-1);
     if(a=0) return(0);
}

void line(unsigned char *scr,int a,int b,int c,int d,int col)
{
double u,s,v,d1x,d1y,d2x,d2y,m,n;
int  i;
u=c-a;
v=d-b;
d1x=sgn(u);
d1y=sgn(v);
d2x=sgn(u);
d2y=0;
m=fabs(u);
n=fabs(v);
if(!(m>n))
{
  d2x=0 ;
  d2y=sgn(v);
  m=fabs(v);
  n=fabs(u);
}
s=m/2;
for(i=0;i<=m;i++) 
{
  put_pix(scr,a,b,col);
  s=s+n;
  if(!(s<m))
  {
    s=s-m;
    a=a+d1x;
    b=b+d1y;
  }else{
    a=a+d2x;
    b=b+d2y;
  }
}
}


- Raw text -


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