From: quintero AT swbell DOT net Newsgroups: comp.os.msdos.djgpp Subject: HELP!! DJGPP WON'T WORK! Date: Sun, 12 Oct 1997 10:00:57 -0700 Organization: Southwestern Bell Internet Services, Richardson, TX Lines: 726 Message-ID: <34410249.2D03@swbell.net> Reply-To: quintero AT swbell DOT net NNTP-Posting-Host: ppp-207-193-27-136.snantx.swbell.net Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------28B24C3C2DA3" To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk This is a multi-part message in MIME format. --------------28B24C3C2DA3 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hello DJGPP users, I have a serious problem. I downloaded all the necessary files for DJGPP and downloaded RHIDE 1.3c as well. Everytime I use DJGPP under DOS, it won't compile my programs (not even the simple hello.cc). It always gives me errors about the and a couple others like e:/dj/bin/ld.exe can't find crt0.o. I don't understand it! I have everything in my paths (path=c:\dos;c:\pcci5(antivirus);d:\;e:\dj\bin;e:\) and the autoexec.bat and config.sys is configured to the way the FAQ told me. Here's a sample problem program that I have tried in vain to compile: /* Cheap program... */ #include int main() { clrscr(); // it also gives me : Warning: Implicit use of clrscr(..) cout<<"If this does not work, I am throwing my computer"; cout<<" Out the window!!"<<'\n'; // I am but a novice C++ programmer. :( return 0; } also, I can't compile Allegro 2.2 using the makefile. It gives me an error about "can't make use (something like that) of 'Badtarget'" I really need help on this! Many thanks to all who help me! Sergio Peņa P.S. attached is a 3d line program that one of my freinds gave me to test out my paths:k2.cpp. --------------28B24C3C2DA3 Content-Type: text/plain; charset=us-ascii; name="K2.CPP" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="K2.CPP" // line3d.cpp // program for first six weeks // include files // some are specific to DJGPP #include #include /* for _dos_ds */ #include #include #include #include // // // defines // // /* palette */ #define PALETTE_MASK 0x3c6 #define PALETTE_REGISTER_RD 0x3c7 #define PALETTE_REGISTER_WR 0x3c8 #define PALETTE_DATA 0x3c9 #define CHAR_WIDTH 8 #define CHAR_HEIGHT 8 #define GRAPHICS 0x013 #define TEXT 0x03 /* key_table indexes */ #define UP 0 #define DOWN 1 #define LEFT 2 #define RIGHT 3 #define LSTRAFE 4 #define RSTRAFE 5 #define INIT 6 #define ESCAPE 7 #define NUMLINES 20 // enum ptflags {INSIGHT,BEHIND,PERIPHERAL}; // // global vars // unsigned char raw_key, key_table[8]; _go32_dpmi_seginfo old_key_handler,new_key_handler; char *video_buffer = (char *)0xa0000; char *rom_char_set = (char *)0xffa6e; char *double_buffer; // // // classes and structures // // typedef struct rgb_color_type { unsigned char red; unsigned char green; unsigned char blue; } rgb_color; // structure for 3d coordinates struct PV3D { float x, y, z; }; // structure that holds information on the location and perspective // of the eye: the perspective from which the 3d objects are rendered struct Perspective { PV3D place, lsght, lx, ly; float ls_angle, lx_angle; } eye; // the class for 3d lines class Line3d { public: PV3D p1, p2; char color; void render(); }lines[NUMLINES]; // // // prototype section // // void do_keys(void); // I wrote void get_lines(void); // I wrote inline void init_eye(void); // I wrote void key_handler(void); // I altered void key_init(void); void key_delete(void); void clear(char*, char); void wait_for_vsync(void); void show_double_buffer(void); void char_blt(int,int,int,unsigned char); void string_blt(int,int,int,char*); void set_video_mode(int); void put_pixel(short int, short int, char); unsigned char get_pixel(short int, short int); void get_palette_register(unsigned char, rgb_color); void set_palette_register(unsigned char, rgb_color); void line(short int, short int, short int, short int, char); // end of prototypes // // // this is the data for the lines // in this format: x1, y1, z1, x2, y2, z2, color for a line from p1 to p2 // // float line_array [NUMLINES][7] = // a cube, blue {{10, 5, 5,10, 5,-5,1}, {10,-5, 5,10,-5,-5,1}, {10, 5, 5,10,-5, 5,1}, {10, 5,-5,10,-5,-5,1}, {20, 5, 5,20, 5,-5,1}, {20,-5, 5,20,-5,-5,1}, {20, 5, 5,20,-5, 5,1}, {20, 5,-5,20,-5,-5,1}, {10, 5, 5,20, 5, 5,1}, {10,-5, 5,20,-5, 5,1}, {10,-5,-5,20,-5,-5,1}, {10, 5,-5,20, 5,-5,1}, // a pyraymid, green {60, 5, 0,60,-3, 5,2}, {60,-3, 5,60,-3,-5,2}, {60,-3,-5,60, 5, 0,2}, {60, 5, 0,70, 0, 0,2}, {60,-3, 5,70, 0, 0,2}, {60,-3,-5,70, 0, 0,2}, // some lines, light blue {80, 5, 0,80, 10, 0,3}, {80,-5, 0,80,-10, 0,3}}; // rendering function for the line class // doesn't clip partially visible lines, but // that is the next thing I will do // this uses some 3d math to render a line to the sreen void Line3d::render() { PV3D pvect; // temporary vector to do all calculations with int x1, y1, x2, y2; // eventually will be screen coordinates // size of screen is 320*200 // makes pvect a vector from the eye to the point to be rendered pvect.x = p1.x - eye.place.x; pvect.y = p1.y - eye.place.y; pvect.z = p1.z - eye.place.z; // quits if point is behind the eye (angle >= 180) if ((pvect.x * eye.lsght.x + pvect.y * eye.lsght.y + pvect.z * eye.lsght.z) > 0) { // makes pvect a unit vector float mag = sqrt( pow(pvect.x,2) + pow(pvect.y,2) + pow(pvect.z,2) ); pvect.x /= mag; pvect.y /= mag; pvect.z /= mag; // projects pvect onto lx (the x orientation) then multiplies and // shifts for suitible sreen coordinates // note : projection values greater than .5 and less // than -.5 will be off the screen x1 = (int) (480 * (pvect.x * eye.lx.x + pvect.y * eye.lx.y + pvect.z * eye.lx.z) + 160); // projects pvect onto ly (the y orientation) then multiplies and // shifts for suitible sreen coordinates // note : projection values greater than .5 or less // than -.5 will be off the screen y1 = (int) (300 * (pvect.x * eye.ly.x + pvect.y * eye.ly.y + pvect.z * eye.ly.z) + 100); // second point pvect.x = p2.x - eye.place.x; pvect.y = p2.y - eye.place.y; pvect.z = p2.z - eye.place.z; if ((pvect.x * eye.lsght.x + pvect.y * eye.lsght.y + pvect.z * eye.lsght.z) > 0) { mag = sqrt( pow(pvect.x,2) + pow(pvect.y,2) + pow(pvect.z,2) ); pvect.x /= mag; pvect.y /= mag; pvect.z /= mag; x2 = (int) (480 * (pvect.x * eye.lx.x + pvect.y * eye.lx.y + pvect.z * eye.lx.z) + 160); y2 = (int) (300 * (pvect.x * eye.ly.x + pvect.y * eye.ly.y + pvect.z * eye.ly.z) + 100); // ensures that points are within bounds of the screen if ((x1 >= 0) && (x1 <= 320) && (x2 >= 0) && (x2 <= 320) && (y1 >= 0) && (y1 <= 200) && (y2 >= 0) && (y2 <= 200)) line(x1, y1, x2, y2, color); } } } void main(void) { // all the initialization unsigned count; __djgpp_nearptr_enable(); video_buffer += __djgpp_conventional_base; rom_char_set += __djgpp_conventional_base; set_video_mode(GRAPHICS); /* setup double buffer */ double_buffer = (char *)malloc(64000); // now for a 3d line demonstration init_eye(); get_lines(); // clear key table key_table[UP] = key_table[DOWN] = key_table[LEFT] = key_table[RIGHT] = key_table[LSTRAFE] = key_table[RSTRAFE] = key_table[ESCAPE] = key_table[INIT] = 0; // install keyboard handler key_init(); // instructions for (float i = 0; i <= 50; i += .3) { clear(double_buffer,0); string_blt(140,(int)(10+i),((int)i+1)%10+1,"WELCOME"); string_blt((int)(90+i),70,((int)i+2)%10+1,"TO"); string_blt((int)(210-i),70,((int)i+6)%10+1,"THE GREAT"); string_blt(150,(int)(130-i),((int)i+9)%10+1,"LINE3D.CPP"); show_double_buffer(); }; string_blt(30,100,1,"PUSH: I to go forward"); string_blt(30,110,2,"PUSH: K to go back"); string_blt(30,120,1,"PUSH: J to turn left"); string_blt(30,130,2,"PUSH: L to turn right"); string_blt(30,140,1,"PUSH: U to sidestep left"); string_blt(30,150,2,"PUSH: O to sidestep right"); string_blt(30,160,1,"PUSH: P to return to begining"); string_blt(30,170,1,"PUSH: Esc to exit"); string_blt(30,190,1,"PUSH: Esc now to begin"); show_double_buffer(); while (!key_table[ESCAPE]){}; key_table[ESCAPE] = 0; // here the real stuff begins while (!key_table[ESCAPE]) { clear(double_buffer,0); do_keys(); for(int l = 0; l < NUMLINES; l++) { lines[l].render(); } // shows lsght and lx orientation line(280,20,(int)(280+5*eye.lsght.z),(int)(20-5*eye.lsght.x),1); line(280,20,(int)(280+5*eye.lx.z),(int)(20-5*eye.lx.x),2); show_double_buffer(); }; key_delete(); set_video_mode(TEXT); __djgpp_nearptr_disable(); } // // // functions // // // makes changes on eye data according to keystrokes void do_keys() { if (key_table[UP]) { eye.place.x += .3 * eye.lsght.x; eye.place.y += .3 * eye.lsght.y; eye.place.z += .3 * eye.lsght.z; string_blt(10,10,1,"FORWARD"); }; if (key_table[DOWN]) { eye.place.x -= 0.3 * eye.lsght.x; eye.place.y -= 0.3 * eye.lsght.y; eye.place.z -= 0.3 * eye.lsght.z; string_blt(30,10,2,"BACK"); }; if (key_table[LSTRAFE]) { eye.place.x -= 0.3 * eye.lx.x; eye.place.y -= 0.3 * eye.lx.y; eye.place.z -= 0.3 * eye.lx.z; string_blt(250,10,2,"LSTRAFE"); }; if (key_table[RSTRAFE]) { eye.place.x += 0.3 * eye.lx.x; eye.place.y += 0.3 * eye.lx.y; eye.place.z += 0.3 * eye.lx.z; string_blt(180,10,2,"RSTRAFE"); }; if (key_table[INIT]) { init_eye(); string_blt(20,10,2,"CENTERING"); }; if (key_table[LEFT]) { eye.ls_angle -= .03; eye.lx_angle -= .03; eye.lsght.x = cos(eye.ls_angle); eye.lsght.z = sin(eye.ls_angle); eye.lx.x = cos(eye.lx_angle); eye.lx.z = sin(eye.lx_angle); string_blt(70,10,3,"LEFT"); }; if (key_table[RIGHT]) { eye.ls_angle += .03; eye.lx_angle += .03; eye.lsght.x = cos(eye.ls_angle); eye.lsght.z = sin(eye.ls_angle); eye.lx.x = cos(eye.lx_angle); eye.lx.z = sin(eye.lx_angle); string_blt(100,10,4,"RIGHT"); }; }; // reads data from line_array into the array of lines void get_lines(void) { for(int i = 0; i < NUMLINES; i++) { lines[i].p1.x = line_array[i][0]; lines[i].p1.y = line_array[i][1]; lines[i].p1.z = line_array[i][2]; lines[i].p2.x = line_array[i][3]; lines[i].p2.y = line_array[i][4]; lines[i].p2.z = line_array[i][5]; lines[i].color = (char)(line_array[i][6]); } } // initializes the eye to the origin, looking down the x axis, and upright inline void init_eye() { eye.ls_angle = 0; eye.lx_angle = asin(1); eye.place.x = 0; eye.place.y = 0; eye.place.z = 0; eye.lsght.x = 1; eye.lsght.y = 0; eye.lsght.z = 0; eye.lx.x = 0; eye.lx.y = 0; eye.lx.z = 1; eye.ly.x = 0; eye.ly.y = 1; eye.ly.z = 0; } // // // I took most of the following stuff from DJGPP tutorial pages on the // internet // // // I changed this one slightly. It now accepts more keystrokes // than it originally did void key_handler(void) { unsigned char al, ah; asm("cli; pusha"); raw_key = inportb(0x60); al = inportb(0x61); al |= 0x82; outportb(0x61, al); al &= 0x7f; outportb(0x61, al); /* you have the option of putting this outside */ switch(raw_key) { /* make codes */ case 23: /* up */ key_table[UP] = 1; break; case 37: /* down */ key_table[DOWN] = 1; break; case 36: /* left */ key_table[LEFT] = 1; break; case 38: /* right */ key_table[RIGHT] = 1; break; case 22: /* left strafe */ key_table[LSTRAFE] = 1; break; case 24: /* right strafe */ key_table[RSTRAFE] = 1; break; case 1: /* escape */ key_table[ESCAPE] = 1; break; case 25: /* center eye */ key_table[INIT] = 1; break; /* break codes = make code + 128 */ case 151: /* up release */ key_table[UP] = 0; break; case 165: /* down release */ key_table[DOWN] = 0; break; case 164: /* left release */ key_table[LEFT] = 0; break; case 166: /* right release */ key_table[RIGHT] = 0; break; case 150: /* stop lstrafe */ key_table[LSTRAFE] = 0; break; case 152: /* stop right strafe */ key_table[RSTRAFE] = 0; break; case 153: /* stop center*/ key_table[INIT] = 0; break; default: break; } outportb(0x20, 0x20); asm("popa; sti"); } void key_init(void) /* function to swap state */ { new_key_handler.pm_offset = (int)key_handler; new_key_handler.pm_selector = _go32_my_cs(); _go32_dpmi_get_protected_mode_interrupt_vector(0x9, &old_key_handler); _go32_dpmi_allocate_iret_wrapper(&new_key_handler); _go32_dpmi_set_protected_mode_interrupt_vector(0x9,&new_key_handler); } void key_delete(void) { _go32_dpmi_set_protected_mode_interrupt_vector(0x9,&old_key_handler); } void clear(char *buffer, char color) { memset(buffer,color,64000); } void wait_for_vsync(void) { while (inportb(0x3da) & 0x08); /* vga is in retrace */ while (!(inportb(0x3da) & 0x08)); /* wait for start of retrace */ } void show_double_buffer(void) { wait_for_vsync(); memcpy((char *)video_buffer,(char *)double_buffer,64000); } void char_blt(int x, int y, int color, unsigned char c) { int offset, x2, y2; char *work_char; unsigned char bit_mask = 0x80; work_char = rom_char_set + c * CHAR_HEIGHT; offset = (y << 8) + (y << 6) + x; for(y2=0; y2> 1); } offset += 320; work_char++; } } void string_blt(int x, int y, int color, char *string) { int index; for(index=0; string[index] != 0; index++) { char_blt(x+(index<<3),y,color,string[index]); } } void set_video_mode(int mode) { union REGS regs; regs.x.ax = mode; int86(0x10, ®s, ®s); } void put_pixel(short int x, short int y, char color) { double_buffer[(y << 8) + (y << 6) + x] = color; } unsigned char get_pixel(short int x, short int y) { return double_buffer[(y << 8) + (y << 6) + x]; } void get_palette_register(unsigned char index, rgb_color *color) { outportb(PALETTE_MASK,0xff); outportb(PALETTE_REGISTER_RD,index); color->red = inportb(PALETTE_DATA); color->green = inportb(PALETTE_DATA); color->blue = inportb(PALETTE_DATA); } void set_palette_register(unsigned char index, rgb_color *color) { outportb(PALETTE_MASK,0xff); outportb(PALETTE_REGISTER_WR,index); outportb(PALETTE_DATA,color->red); outportb(PALETTE_DATA,color->green); outportb(PALETTE_DATA,color->blue); } void line(short int x1, short int y1, short int x2, short int y2, char color) { short int dx, dy, sdx, sdy, x, y, px, py; /* the change in x and y */ dx = x2 - x1; dy = y2 - y1; /* signs of dx and dy, for getting absolute value */ /* and for moving our pen */ sdx = (dx < 0) ? -1 : 1; sdy = (dy < 0) ? -1 : 1; /* the values to be used for incrementing/decrementing counters */ dx = sdx * dx + 1; dy = sdy * dy + 1; /* the counters */ x = y = 0; /* the pen */ px = x1; py = y1; if (dx >= dy) { /* x axis s major */ for (x = 0; x < dx; x++) { double_buffer[(py << 8) + (py << 6) + px] = color; y += dy; if (y >= dx) { y -= dx; py += sdy; } px += sdx; } } else { /* y axis is major */ for (y = 0; y < dy; y++) { double_buffer[(py << 8) + (py << 6) + px] = color; x += dx; if (x >= dy) { x -= dy; px += sdx; } py += sdy; } } } --------------28B24C3C2DA3--