In an attempt to produce a working "make bgitest" for bcc, I tried to
link the BGI test programs against Borland graphics.lib, but failed.
Albeit similar, Borland and GRX implementations of BGI are different,
so I decided to port GRX BGI to Borland C. What's in the patch below:
- all header and source files include libbcc.h and not graphics.h
- modename uses long color values
- GRX for BCC includes the GRX BGI modules
- fontplay "requires DJGPP/GRX", removed from test\bgi\makefile.bcc
- getch(), getkey() and kbhit() from test\bgi\* synced with test\keys
- some compatibility fixes
Compiled and tested with Borland C/C++ 5.01
- some of the static inline functions generate harmless warnings
- test\bgi\tellipse displays something... well, for sure not ellipse
- test\bgi\colortst displays black screen for some modes
- all other bgi tests work properly
More work is probably required, but this is still better (IMHO) than
having non-working/incompatible BGI for BCC, right? And GRX BGI can
not be ported to work on top of Borland BGI, they are too different.
diff -Nru3 grx245p3/include/bgiext.h grx/include/bgiext.h
--- grx245p3/include/bgiext.h Fri Jan 12 03:36:56 2001
+++ grx/include/bgiext.h Mon Jun 24 13:56:12 2002
@@ -24,12 +24,7 @@
#ifndef __BGIEXT_H
#define __BGIEXT_H
-#ifdef __TURBOC__
-# include <graphics.h>
-#endif
-#ifdef __GNUC__
-# include <libbcc.h>
-#endif
+#include <libbcc.h>
#ifdef __cplusplus
extern "C" {
diff -Nru3 grx245p3/src/bgi/modename.c grx/src/bgi/modename.c
--- grx245p3/src/bgi/modename.c Fri Jan 12 19:36:44 2001
+++ grx/src/bgi/modename.c Mon Jun 24 13:48:24 2002
@@ -47,9 +47,9 @@
if (!__gr_getmode_whc(mode_number, &xw, &yw, &nc))
return NULL;
switch (nc) {
- case 1<<15 : strcpy(cols,"32K"); break;
- case 1<<16 : strcpy(cols,"64K"); break;
- case 1<<24 : strcpy(cols,"16M"); break;
+ case 1L<<15 : strcpy(cols,"32K"); break;
+ case 1L<<16 : strcpy(cols,"64K"); break;
+ case 1L<<24 : strcpy(cols,"16M"); break;
default : sprintf(cols, "%ld", nc);
break;
}
diff -Nru3 grx245p3/src/bgi/text.h grx/src/bgi/text.h
--- grx245p3/src/bgi/text.h Sun Dec 23 03:15:42 2001
+++ grx/src/bgi/text.h Mon Jun 24 13:41:40 2002
@@ -33,7 +33,7 @@
typedef signed char schar;
typedef unsigned short _ushort;
-#if defined(_MSC_VER) && defined(_WIN32)
+#if defined(__TURBOC__) || (defined(_MSC_VER) && defined(_WIN32))
#include <io.h>
#else
#include <unistd.h>
diff -Nru3 grx245p3/src/makefile.bcc grx/src/makefile.bcc
--- grx245p3/src/makefile.bcc Sun Jun 16 02:04:16 2002
+++ grx/src/makefile.bcc Mon Jun 24 13:46:32 2002
@@ -28,10 +28,12 @@
GRX20STa= ..\lib\$(GRX_LIB_SUBDIR)\temp1.lib
GRX20STb= ..\lib\$(GRX_LIB_SUBDIR)\temp2.lib
GRX20STc= ..\lib\$(GRX_LIB_SUBDIR)\temp3.lib
+GRX20STd= ..\lib\$(GRX_LIB_SUBDIR)\temp4.lib
+GRX20STe= ..\lib\$(GRX_LIB_SUBDIR)\temp5.lib
TEMP_LIB= ..\lib\$(GRX_LIB_SUBDIR)\temp?.lib
INCDIR= -I. -I./include -I../include -I$(BCCROOT)/include\
- -I./vdrivers
+ -I./vdrivers -I./bgi
LIBDIR= -L$(BCCROOT)/lib
OP=+
@@ -83,7 +85,9 @@
LOBJ1=$(STD_1:/=\) $(STD_2:/=\) $(STD_3:/=\) $(STD_4:/=\)
LOBJ2=$(STD_5:/=\) $(STD_6:/=\) $(STD_7:/=\) $(STD_8:/=\)
LOBJ3=$(STD_9:/=\) $(STD_10:/=\)
-LOBJ4=$(STD_11:/=\) $(BCCOBJ) $(DBG_O)
+LOBJ4=$(BGI_1:/=\) $(BGI_2:/=\) $(BGI_3:/=\)
+LOBJ5=$(BGI_4:/=\) $(BGI_5:/=\) $(BGI_6:/=\)
+LOBJ6=$(STD_11:/=\) $(BCCOBJ) $(DBG_O)
UTILP = \
..\bin\vesaif16.exe \
@@ -126,13 +130,15 @@
if exist $(GRX20ST) del $(GRX20ST)
# the & tells TLIB to continue on next line
-$(GRX20ST): $(GRX20STa) $(GRX20STb) $(GRX20STc) $(LOBJ4:+=)
+$(GRX20ST): $(GRX20STa) $(GRX20STb) $(GRX20STc) $(GRX20STd) $(GRX20STe) $(LOBJ6:+=)
if exist $(GRX20ST) del $(GRX20ST)
$(TLIB) $(LIBPAGE) /C $(GRX20ST) @&&!
+$(GRX20STa) &
+$(GRX20STb) &
+$(GRX20STc) &
- $(LOBJ4)
+ +$(GRX20STd) &
+ +$(GRX20STe) &
+ $(LOBJ6)
!
$(GRX20STa): $(LOBJ1:+=)
@@ -151,6 +157,18 @@
if exist $(GRX20STc) del $(GRX20STc)
$(TLIB) $(LIBPAGE) /C $(GRX20STc) @&&!
$(LOBJ3)
+!
+
+$(GRX20STd): $(LOBJ4:+=)
+ if exist $(GRX20STd) del $(GRX20STd)
+ $(TLIB) $(LIBPAGE) /C $(GRX20STd) @&&!
+ $(LOBJ4)
+!
+
+$(GRX20STe): $(LOBJ5:+=)
+ if exist $(GRX20STe) del $(GRX20STe)
+ $(TLIB) $(LIBPAGE) /C $(GRX20STe) @&&!
+ $(LOBJ5)
!
..\bin\vesaif16.exe: utilprog\vesainfo.c $(GRX20ST) config.bcc
diff -Nru3 grx245p3/test/bgi/bccbgi.c grx/test/bgi/bccbgi.c
--- grx245p3/test/bgi/bccbgi.c Thu Nov 29 22:59:30 2001
+++ grx/test/bgi/bccbgi.c Mon Jun 24 14:43:12 2002
@@ -12,7 +12,10 @@
#if defined(__MSDOS__)
# include <dos.h>
-# include <pc.h>
+# if defined(__DJGPP__)
+# include <conio.h>
+# include <pc.h>
+# endif
#elif defined(__WIN32__)
# include "bccw32.h"
#else
diff -Nru3 grx245p3/test/bgi/bgilink.c grx/test/bgi/bgilink.c
--- grx245p3/test/bgi/bgilink.c Thu May 31 13:21:48 2001
+++ grx/test/bgi/bgilink.c Mon Jun 24 14:47:12 2002
@@ -2,6 +2,7 @@
* Copyright (C) 1993-97 by Hartmut Schirmer
*/
+#include <stdlib.h> /* NULL, exit() */
#include <string.h>
#include "libbcc.h"
diff -Nru3 grx245p3/test/bgi/colortst.c grx/test/bgi/colortst.c
--- grx245p3/test/bgi/colortst.c Sat Mar 10 17:02:20 2001
+++ grx/test/bgi/colortst.c Mon Jun 24 14:43:50 2002
@@ -4,11 +4,8 @@
#include <stdio.h>
#include <string.h>
-#ifdef __GNUC__
-# include "libbcc.h"
-#else
-# include <graphics.h>
-#endif
+
+#include "libbcc.h"
static void testmode(int mode) {
diff -Nru3 grx245p3/test/bgi/makefile.bcc grx/test/bgi/makefile.bcc
--- grx245p3/test/bgi/makefile.bcc Tue Jan 16 03:31:16 2001
+++ grx/test/bgi/makefile.bcc Mon Jun 24 14:16:28 2002
@@ -14,7 +14,6 @@
bgilink.exe \
bccbgi.exe \
colortst.exe \
- fontplay.exe \
small.exe \
tellipse.exe \
tfill.exe \
diff -Nru3 grx245p3/test/bgi/small.c grx/test/bgi/small.c
--- grx245p3/test/bgi/small.c Sat Mar 10 23:29:20 2001
+++ grx/test/bgi/small.c Mon Jun 24 14:42:12 2002
@@ -1,8 +1,4 @@
-#ifdef __GNUC__
-# include <libbcc.h>
-#else
-# include <graphics.h>
-#endif
+#include <libbcc.h>
#if defined(__WIN32__)
int GRXMain(void)
diff -Nru3 grx245p3/test/bgi/tellipse.c grx/test/bgi/tellipse.c
--- grx245p3/test/bgi/tellipse.c Thu Nov 29 22:59:30 2001
+++ grx/test/bgi/tellipse.c Mon Jun 24 14:44:40 2002
@@ -2,17 +2,15 @@
#include <stdlib.h>
#include <math.h>
-#ifdef __GNUC__
-# include <libbcc.h>
-# ifdef __MSDOS__
-# include <pc.h>
-# else
- extern int kbhit(void), getkey(void);
-# endif
-# define getch() getkey()
+#include <libbcc.h>
+
+#ifdef __DJGPP__
+#include <conio.h>
+#include <pc.h>
#else
-# include <graphics.h>
-# include <conio.h>
+extern int getch(void);
+extern int getkey(void);
+extern int kbhit(void);
#endif
#if defined(__WIN32__)
diff -Nru3 grx245p3/test/bgi/tfill.c grx/test/bgi/tfill.c
--- grx245p3/test/bgi/tfill.c Thu Nov 29 22:59:30 2001
+++ grx/test/bgi/tfill.c Mon Jun 24 14:45:34 2002
@@ -1,17 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef __GNUC__
-# include <libbcc.h>
-# ifdef __MSDOS__
-# include <pc.h>
-# else
- extern int kbhit(void);
- extern int getkey(void);
-# endif
-# define getch() getkey()
+
+#include <libbcc.h>
+
+#ifdef __DJGPP__
+#include <conio.h>
+#include <pc.h>
#else
-# include <graphics.h>
-# include <conio.h>
+extern int getch(void);
+extern int getkey(void);
+extern int kbhit(void);
#endif
#if defined(__WIN32__)
diff -Nru3 grx245p3/test/bgi/tpoly.c grx/test/bgi/tpoly.c
--- grx245p3/test/bgi/tpoly.c Thu Nov 29 22:59:30 2001
+++ grx/test/bgi/tpoly.c Mon Jun 24 14:45:18 2002
@@ -1,16 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef __GNUC__
-# include <libbcc.h>
-# ifdef __MSDOS__
-# include <pc.h>
-# else
- extern int kbhit(void), getkey(void);
-# endif
-# define getch() getkey()
+
+#include <libbcc.h>
+
+#ifdef __DJGPP__
+#include <conio.h>
+#include <pc.h>
#else
-# include <graphics.h>
-# include <conio.h>
+extern int getch(void);
+extern int getkey(void);
+extern int kbhit(void);
#endif
#if defined(__WIN32__)
diff -Nru3 grx245p3/test/bgi/ttext.c grx/test/bgi/ttext.c
--- grx245p3/test/bgi/ttext.c Thu Nov 29 22:59:30 2001
+++ grx/test/bgi/ttext.c Mon Jun 24 14:46:22 2002
@@ -1,16 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef __GNUC__
-# include <libbcc.h>
-# ifdef __MSDOS__
-# include <pc.h>
-# else
- extern int khbit(void), getkey(void);
-# endif
-# define getch() getkey()
+
+#include <libbcc.h>
+
+#ifdef __DJGPP__
+#include <conio.h>
+#include <pc.h>
#else
-# include <graphics.h>
-# include <conio.h>
+extern int getch(void);
+extern int getkey(void);
+extern int kbhit(void);
#endif
void play_font(char *name, char *file, int *x, int *y)