delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/28/16:14:12

From: VANGEL AT VMREDIPN DOT IPN DOT MX
Message-Id: <199705282012.QAA06256@delorie.com>
Date: Wed, 28 May 97 14:46:45 EST
To: DJGPP AT delorie DOT com
Subject: Help about DJGPP V.2

Hi all!
I'm trying to run the program --> GAME.EXE but I get error message. About it,
DJ told me:

 >> The edi=d0000000 is a dead giveaway.  You're trying to build a program
 >> that relies on DJGPP V1's graphics hardware stuff.  That went away in
 >> DJGPP V2 (sorry).  It wouldn't work under Windows anyway.

And Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> told me:

  >> No, it means that you need to change the source of GAME.EXE so that it
  >> doesn't use techniques which blow up when compiled with DJGPP v2.


Well, this is the source code of GAME.EXE ..:

/** 3DGPL *************************************************\
 * A demo allowing to rotate a polygon rendering it as    *
 * either ambient, shaded or textured. ( <TAB> to change  *
 * rendering option ).                                    *
 *                                                        *
 *  If it doesn't work:                                   *
 *   1) make sure you are using right hardware interface  *
 *      source and your system sutisfies requirements     *
 *      described in it's head comment.                   *
 *   2) if this application does quit on <ENTER> but      *
 *      shows nothing, adjust colour intensities assigned *
 *      in main(), hardware interface function doesn't    *
 *      convert them.                                     *
 *   3) if the demo crashes recompile with bigger stack.  *
 *                                                        *
\**********************************************************/

#include <stdio.h>
#include <game/hardware.h>
#include <game/engine.h>
#include <game/graphics.h>
#include <game/trans.h>

unsigned char alp=0,bet=0,gam=0;
int x=0,y=0,z=200;

unsigned char texture16ู16ู=
{
 {0xef,0xee,0xed,0xec,0xeb,0xea,0xe9,0xe8,0xe7,0xe6,0xe5,0xe4,0xe3,0xe2,0xe1,0xe
0},
 {0xef,0x55,0x55,0x55,0x55,0x55,0x55,0xe8,0xe7,0x55,0x55,0x55,0x55,0x55,0xe1,0xe
0},
 {0xef,0xee,0xed,0xec,0xeb,0x55,0xe9,0xe8,0xe7,0x55,0xe5,0xe4,0xe3,0xe2,0x55,0xe
0},
 {0xef,0xee,0xed,0xec,0x55,0xea,0xe9,0xe8,0xe7,0x55,0xe5,0xe4,0xe3,0xe2,0x55,0xe
0},
 {0xef,0xee,0xed,0x55,0x55,0x55,0x55,0xe8,0xe7,0x55,0xe5,0xe4,0xe3,0xe2,0x55,0xe
0},
 {0xef,0xee,0xed,0xec,0xeb,0xea,0x55,0xe8,0xe7,0x55,0xe5,0xe4,0xe3,0xe2,0x55,0xe
0},
 {0xef,0x55,0x55,0x55,0x55,0x55,0xe9,0xe8,0xe7,0x55,0x55,0x55,0x55,0x55,0xe1,0xe
0},
 {0xef,0xee,0xed,0xec,0xeb,0xea,0xe9,0xe8,0xe7,0xe6,0xe5,0xe4,0xe3,0xe2,0xe1,0xe
0},
 {0xef,0xee,0x77,0x77,0xeb,0xea,0x76,0x76,0x76,0xe6,0xe5,0x75,0xe3,0xe2,0xe1,0xe
0},
 {0xef,0x77,0xed,0xec,0x77,0xea,0x76,0xe8,0xe7,0x76,0xe5,0x75,0xe3,0xe2,0xe1,0xe
0},
 {0xef,0x77,0xed,0xec,0xeb,0xea,0x76,0xe8,0xe7,0x76,0xe5,0x75,0xe3,0xe2,0xe1,0xe
0},
 {0xef,0x77,0xed,0xec,0xeb,0xea,0x76,0xe8,0xe7,0x76,0xe5,0x75,0xe3,0xe2,0xe1,0xe
0},
 {0xef,0x77,0xed,0x77,0x77,0xea,0x76,0x76,0x76,0xe6,0xe5,0x75,0xe3,0xe2,0x75,0xe
0},
 {0xef,0x77,0xed,0xec,0x77,0xea,0x76,0xe8,0xe7,0xe6,0xe5,0x75,0xe3,0xe2,0x75,0xe
0},
 {0xef,0xee,0x77,0x77,0x77,0xea,0x76,0xe8,0xe7,0xe6,0xe5,0x75,0x75,0x75,0x75,0xe
0},
 {0xef,0xee,0xed,0xec,0xeb,0xea,0xe9,0xe8,0xe7,0xe6,0xe5,0xe4,0xe3,0xe2,0xe1,0xe
0}
};

struct M_polygon a= {M_AMBIENT,56,NULL,0,0,0,0,4,{0,3,6,9,0}};
struct M_polygon s= {M_SHADED,0,NULL,0,0,0,0,4,{0,5,3,42,6,58,9,21,0,11}};
struct M_polygon t= {M_TEXTURED,0,(unsigned char*)texture,4,6,0,3,4,
                    {0,0,64,3,64,64,6,64,0,9,0,0,0,0,64}};
struct M_polygon *p=&t;
int m_no_verteces=4;
int vertecesู={-50,50,0,50,50,0,50,-50,0,-50,-50,0};
int m_no_vectors=2;
int vectorsู={100,0,0,0,100,0};

/**********************************************************\
 * being called to treat key press.                       *
\**********************************************************/

void app_handler(int kk)
{
 switch(kk)
 {
  case HW_KEY_ENTER:       HW_quit_event_loop(); break;
  case HW_KEY_ARROW_RIGHT: gam+=10; break;
  case HW_KEY_ARROW_LEFT:  gam-=10; break;
  case HW_KEY_ARROW_UP:    bet+=10; break;
  case HW_KEY_ARROW_DOWN:  bet-=10; break;
  case 'X': case 'x':      alp+=10; break;
  case 'S': case 's':      alp-=10; break;
  case 'A': case 'a':      z-=10;   break;
  case 'Z': case 'z':      z+=10;   break;
  case HW_KEY_TAB: if(p==&a) p=&s; else if(p==&s) p=&t; else p=&a;
 }
}

/**********************************************************\
 * being called to render a frame.                        *
\**********************************************************/

void app_main(void)
{
 int tmp_verteces50ู;
 int tmp_vectors50ู;
 char str100ู;

 G_clear();

 T_set_self_rotation(alp,bet,gam);
 T_self_rotation(verteces,tmp_verteces,m_no_verteces);
 T_translation(tmp_verteces,tmp_verteces,m_no_verteces,x,y,z);
 T_self_rotation(vectors,tmp_vectors,m_no_vectors);
 M_render_polygon(p,tmp_verteces,tmp_vectors);

 sprintf(str,"3DGPL <%d %d %d %d>",alp,bet,gam,z); G_text(0,0,str,63);
 if(p==&a) G_text(200,0,"AMBIENT",63);
 if(p==&s) G_text(200,0,"SHADED",63);
 if(p==&t) G_text(200,0,"TEXTURED",63);
 G_text(0,190,"<ARROWS> <TAB> <A> <Z> <S> <X> <ENTER>",63);

 HW_blit();
}

/**********************************************************\
 * assignes colours and starts the event loop.            *
\**********************************************************/

int main(void)
{
 struct HW_colour pal256ู;
 int i;

 for(i=0;i<256;i++) { paliู.hw_r=i; paliู.hw_g=0; paliู.hw_b=0; }
 HW_open_screen(NULL,"3DGPL",pal,G_init_graphics()); T_init_math();
 HW_run_event_loop(app_main,app_handler);
 HW_close_screen();

 return(1);
}

/**********************************************************/

บบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบ

And the code about files *.h is : ....

บบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบ


/************************ File ---> clipper.h     **********************/

#ifndef _CLIPPER_H_
#define _CLIPPER_H_

/** 3DGPL *************************************************\
 *  ()                                                    *
 *  Header for clipping functions.                        *
 *                                                        *
 *  clipp-2d.c               3-D volume and Z clipping;   *
 *  clipp-3d.c               2-D plane clipping.          *
 *                                                        *
\**********************************************************/

#include <game/hardware.h>           /* screen dimensions */

#define C_MAX_DIMENSIONS          5         /* dims in N-dimensional lines */
#define C_Z_CLIPPING_MIN         10         /* where viewing plane is */
#define C_X_CLIPPING_MIN          0         /* clipping cube */
#define C_X_CLIPPING_MAX   HW_SCREEN_X_MAX
#define C_Y_CLIPPING_MIN          0
#define C_Y_CLIPPING_MAX   HW_SCREEN_Y_MAX

int C_volume_clipping(int *from,int *to,int *vertex,int dimension,int length);

int C_line_z_clipping(int **vertex1,int **vertex2,int dimension);
int C_polygon_z_clipping(int *from,int *to,int dimension,int length);

int C_line_x_clipping(int **vertex1,int **vertex2,int dimension);
int C_line_y_clipping(int **vertex1,int **vertex2,int dimension);
int C_polygon_x_clipping(int *from,int *to,int dimension,int length);

/*****************************************/
#endif

/************************ End File ---> clipper.h     **********************/


/************************ File ---> engine.h     **********************/

#ifndef _ENGINE_H_
#define _ENGINE_H_

/** 3DGPL *************************************************\
 *  ()                                                    *
 *  Header for the 3D engine.                             *
 *                                                        *
 *  eng-base.c               polymorphic polygon.         *
 *                                                        *
\**********************************************************/

/**********************************************************\
 * Polygon:                                               *
 *                                                        *
 *  +--------------------+                                *
 *  | m_id               | M_AMBIENT|M_SHADED|M_TEXTURED  *
 *  |                    |                                *
 *  | m_colour           |        +-------------+         *
 *  | m_texture- - - - - - - - -> |texture bytes|         *
 *  | m_log_texure_size  |        |             |         *
 *  | m_log_texture_scale|        +-------------+         *
 *  |                    |                                *
 *  | m_u_index          |                                *
 *  | m_v_index          |                                *
 *  |                    |                                *
 *  | m_no_edges         |                                *
 *  | m_edges    +------------+                           *
 *  |            |   vertex   |                           *
 *  |            |   numbers  |                           *
 *  |            |& attributes|                           *
 *  |            |    ...     |                           *
 *  |            +------------+                           *
 *  +--------------------+                                *
\**********************************************************/

#define M_AMBIENT              0x3          /* constant colour polygon */
#define M_SHADED               0x4          /* Gouraud shaded polygon */
#define M_TEXTURED             0x5          /* texture mapped polygon */
#define M_POLYGON_LENGTH_LIMIT  50          /* length of tmp arrays */

#define M_SIZE_EDGE_ARRAY       15          /* coordinates + colours + etc */

struct M_polygon                            /* describes one polygon */
{
 int m_id;                                  /* M_AMBIENT|M_SHADED|M_TEXTURED */

 int m_colour;                              /* only for M_AMBIENT */
 unsigned char *m_texture;                  /* only for M_TEXTURED */
 int m_log_texture_size;                    /* log base 2 of texture size */
 int m_log_texture_scale;                   /* log base 2 texture scaling */

 int m_u_index;                             /* indexes of texture */
 int m_v_index;                             /* orientation vectors */

 int m_no_edges;                            /* number of edges in the polygn */
 int m_edgesM_SIZE_EDGE_ARRAYู;            /* numbers/attributes */
};

void M_render_polygon(struct M_polygon *polygon,int *vertexes,int *vectors);

/*******************************/

#endif

/************************ End File ---> engine.h     **********************/



/************************ End File ---> graphics.h     **********************/

#ifndef _GRAPHICS_H_
#define _GRAPHICS_H_

/** 3DGPL *************************************************\
 *  (8bit deep bitmap)                                    *
 *  Header for 2D graphics stuff.                         *
 *                                                        *
 *  grp-base.c               basic graphics;              *
 *  grp-text.c               text;                        *
 *  grp-poly.c               polygon rendering.           *
 *                                                        *
\**********************************************************/

#define G_MAX_TUPLES            50          /* big enough? */
#define G_MAX_SHADED_TUPLES    100
#define G_MAX_TEXTURED_TUPLES  120

unsigned char *G_init_graphics(void);
void G_clear(void);
void G_dot(int *vertex,unsigned char colour);
void G_line(int *vertex1,int *vertex2,unsigned char colour);

void G_text(int x,int y,char *string,unsigned char colour);

void G_ambient_polygon(int *edges,int length,unsigned char colour);
void G_shaded_polygon(int *edges,int length);
void G_textured_polygon(int *edges,int length,int *O,int *u,int *v,
                        unsigned char *texture,int log_texture_size,
                                               int log_texture_scale
                       );

/*******************************/

#endif

/********************** End File ---> graphics.h     **********************/


/********************** File ---> hardware.h     **********************/

#ifndef _HARDWARE_H_
#define _HARDWARE_H_

/** 3DGPL *************************************************\
 *  (MSDOS, i386+, VGA, DJGPP)                            *
 *  Header for hardware specific stuff.                   *
 *                                                        *
 *  hardware.c               hardware specific stuff.     *
 *                                                        *
\**********************************************************/

typedef short signed_16_bit;                /* compiler/mashine dependent */
typedef int   signed_32_bit;
typedef unsigned short unsigned_16_bit;
typedef unsigned int   unsigned_32_bit;

#define HW_set_int(dst,lng,val)   asm("movl  %0,%%eax \n"             \
                                      "movl  %1,%%edi \n"             \
                                      "movl  %2,%%ecx \n"             \
                                      "cld \n"                        \
                                      "rep \n"                        \
                                      "stosl %%eax,(%%edi) \n"        \
                                      ::"g" (val),"g" (dst),"g" (lng) \
                                      :"eax","edi","ecx"              \
                                     )

#define HW_set_char(dst,lng,val)  asm("movb  %0,%%al  \n"             \
                                      "movl  %1,%%edi \n"             \
                                      "movl  %2,%%ecx \n"             \
                                      "cld \n"                        \
                                      "rep \n"                        \
                                      "stosb %%al,(%%edi) \n"         \
                                      ::"g" (val),"g" (dst),"g" (lng) \
                                      :"al","edi","ecx"               \
                                     )

#define HW_copy_int(src,dst,lng)  asm("movl  %0,%%esi \n"             \
                                      "movl  %1,%%edi \n"             \
                                      "movl  %2,%%ecx \n"             \
                                      "cld \n"                        \
                                      "rep \n"                        \
                                      "movsl (%%esi),(%%edi) \n"      \
                                      ::"g" (src),"g" (dst),"g" (lng) \
                                      :"esi","edi","ecx"              \
                                     )

#define HW_copy_char(src,dst,lng) asm("movl  %0,%%esi \n"             \
                                      "movl  %1,%%edi \n"             \
                                      "movl  %2,%%ecx \n"             \
                                      "cld \n"                        \
                                      "rep \n"                        \
                                      "movsb (%%esi),(%%edi) \n"      \
                                      ::"g" (src),"g" (dst),"g" (lng) \
                                      :"esi","edi","ecx"              \
                                     )

#define HW_SCREEN_X_SIZE         320
#define HW_SCREEN_Y_SIZE         200        /* number of pixels total */

#define HW_SCREEN_X_MAX          319
#define HW_SCREEN_Y_MAX          199        /* number of maximum pixel */

#define HW_SCREEN_X_CENTRE       160
#define HW_SCREEN_Y_CENTRE       100        /* middle of the screen */

#define HW_COLOURMAP_SIZE_CHAR 64000        /* bytes in the colourmap */
#define HW_COLOURMAP_SIZE_INT  16000        /* ints in the colourmap */

struct HW_colour                            /* describes colour */
{
 int hw_r;
 int hw_g;
 int hw_b;                                  /* intensity components */
};

int HW_open_screen(char *display_name,
                   char *screen_name,
                   struct HW_colour palette256ู,
                   unsigned char *colourmap
                  );
void HW_blit(void);
void HW_close_screen(void);

#define HW_KEY_ARROW_LEFT  331
#define HW_KEY_ARROW_RIGHT 333
#define HW_KEY_ARROW_UP    328
#define HW_KEY_ARROW_DOWN  336

#define HW_KEY_PLUS         43
#define HW_KEY_MINUS        45

#define HW_KEY_ENTER        13
#define HW_KEY_SPACE        32
#define HW_KEY_TAB           9              /* all i can think of */

void HW_run_event_loop(void (*application_main)(void),
                       void (*application_key_handler)(int key_code)
                      );
void HW_quit_event_loop(void);

/********************************/

#endif

/********************** End File ---> hardware.h     **********************/


/********************** File ---> trans.h     **********************/

#ifndef _TRANS_H_
#define _TRANS_H_

/** 3DGPL *************************************************\
 *  ()                                                    *
 *  Header for basic 3-d math.                            *
 *                                                        *
 *  trans-fl.c               3-D transformations, float;  *
 *  trans-fx.c               same using fixed point math; *
 *                                                        *
\**********************************************************/

#define T_LOG_FOCUS 8                       /* log perspective foreshortening */

void T_init_math(void);

void T_translation(int *from,int *to,int length,int addx,int addy,int addz);
void T_scaling(int *from,int *to,int length,int mulx,int muly,int mulz);

void T_set_world_rotation(int alp,int bet,int gam);
void T_world_rotation(int *from,int *to,int length);
void T_set_self_rotation(int alp,int bet,int gam);
void T_self_rotation(int *from,int *to,int length);

void T_perspective(int *from,int *to,int dimension,int length);

/**************************/

#endif

/********************** End File ---> trans.h     **********************/


บบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบ


Then ... can anybody what lines I have to change ...?
The program GAME.EXE run whithout problems with DJGPP V.1  ....
What techniques I have to use for run this program with DJGPP V2. ...?

For the way, I learning to use DJGPP V.2 .......  :) ....

Thanks ....


บบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบ
บบบ                                บบบ
บบบ   Victor Angel Huerta          บบบ
บบบ                                บบบ
บบบ   I.P.N.  Mexico D.F.          บบบ
บบบ                                บบบ
บบบ   vangel AT vmredipn DOT ipn DOT mx       บบบ
บบบ                                บบบ
บบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบ

- Raw text -


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