Hello,
Im trying to learn how to dos games programming in C to learn from the bottom up. I am getting lots of errors currently, from sample code i have used from the website:
http://www3.telus.net/alexander_russell/course/introduction.htmI would be very grateful for any help you could give to fix the program.
I am getting the following error messages:
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(15): error #2149: Undefined size for 'in' with type '(incomplete) union REGS'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(15): error #2149: Undefined size for 'out' with type '(incomplete) union REGS'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(18): error #2152: Unknown field 'h' of '(incomplete) union REGS'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(18): error #2113: Left operand of '.' has incompatible type 'int'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(19): warning #2027: Missing prototype for 'int86'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(20): error #2152: Unknown field 'h' of '(incomplete) union REGS'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(20): error #2113: Left operand of '.' has incompatible type 'int'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(23): error #2152: Unknown field 'h' of '(incomplete) union REGS'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(23): error #2113: Left operand of '.' has incompatible type 'int'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(24): error #2152: Unknown field 'h' of '(incomplete) union REGS'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(24): error #2113: Left operand of '.' has incompatible type 'int'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(30): error #2149: Undefined size for 'in' with type '(incomplete) union REGS'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(30): error #2149: Undefined size for 'out' with type '(incomplete) union REGS'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(33): error #2152: Unknown field 'h' of '(incomplete) union REGS'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(33): error #2113: Left operand of '.' has incompatible type 'int'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(34): error #2152: Unknown field 'h' of '(incomplete) union REGS'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(34): error #2113: Left operand of '.' has incompatible type 'int'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(35): warning #2027: Missing prototype for 'int86'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(39): error #2001: Syntax error: expected ';' but found '*'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(39): warning #2099: Missing type specifier; assuming 'int'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(40): error #2001: Syntax error: expected ';' but found '*'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(40): warning #2099: Missing type specifier; assuming 'int'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(46): warning #2027: Missing prototype for 'farmalloc'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(46): error #2168: Operands of '=' have incompatible types 'int *' and 'int'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(50): warning #2027: Missing prototype for 'MK_FP'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(50): error #2168: Operands of '=' have incompatible types 'int *' and 'int'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(55): warning #2027: Missing prototype for '_fmemset'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(55): error #2048: Undeclared identifier 'offscreen'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(55): error #2048: Undeclared identifier 'screensize'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(73): warning #2027: Missing prototype for 'inportb'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(75): warning #2027: Missing prototype for 'inportb'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(79): warning #2027: Missing prototype for '_fmemcpy'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(82): warning #2099: Missing type specifier; assuming 'int'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(82): error #2048: Undeclared identifier 'y'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(82): error #2048: Undeclared identifier 'x'.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(82): error #2069: Initializer must be constant.
C:\Users\Ford\Documents\Pelles C Projects\new\main.c(93): error #2048: Undeclared identifier 'screen_with'.
Code is below:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main()
{
}
int old_mode;
void enter_mode13h(void)
{
union REGS in, out;
// get old video mode
in.h.ah=0xf;
int86(0x10, &in, &out);
old_mode=out.h.al;
// enter mode 13h
in.h.ah=0;
in.h.al=0x13;
int86(0x10, &in, &out);
}
void leave_mode13h(void)
{
union REGS in, out;
// change to the video mode we were in before we switched to mode 13h
in.h.ah=0;
in.h.al=old_mode;
int86(0x10, &in, &out);
}
unsigned char far *screen; // pointer to the VGA video memory
unsigned char far *off_screen; // pointer to our off screen buffer
int screen_width, screen_height;
unsigned int screen_size;
int init_video_mode(void)
{
off_screen=farmalloc(64000u);
if ( off_screen )
{
screen=MK_FP(0xa000, 0);
screen_width=320;
screen_height=200;
screen_size=64000u;
enter_mode13h();
_fmemset(offscreen, 0, screensize);
return 0;
}
else
{
// no mem! Return error code!
leave_mode13h();
printf("Out of mem!\n");
return 1;
}
}
#define INPUT_STATUS_0 0x3da
// copy the off screen buffer to video memory
void update_buffer(void)
{
// wait for vertical re-trace
while ( inportb(INPUT_STATUS_0) & 8 )
;
while ( !(inportb(INPUT_STATUS_0) & 8) )
;
// copy everything to video memory
_fmemcpy(screen, off_screen, screen_size);
}
Offset=y*320 + x;
void draw_pixel(int x, int y, int colour)
{
*(off_screen + y*screen_width + x)=colour;
}
int get_pixel(int x, int y)
{
return *(off_screen + y*screen_with + x);
}
Thankyou for your time