Category : C Source Code
Archive   : CADSRC.ZIP
Filename : T-1.C
t-1.c
FUNCTION: Demonstrates automatic configuration of the software at
run-time to match the graphics hardware.
Compatibility: Supports VGA/EGA/CGA/MCGA graphics adapters and monitors.
this software uses the 640x480, 16 color, if VGA,
" " 640x350, 16 color if EGA + ECD
" " 640x200, 16 color if EGA + std monitor
" " 320x200, 4 color if CGA or MCGA.
NOTE: You need the *.BGI files that come with Turbo-C for this to run.
___________________________________________________________________
INCLUDE FILES */
#include
#include
#include
#include
/*________________________________________________________________
DECLARATIONS */
float sx,sy;
int C0=0,C1=1,C2=2,C3=3,C4=4,C5=5,C6=6,C7=7,C8=8,C9=9,C10=10,
C11=11,C12=12,C13=13,C14=14,C15=15,CLR,mode_flag=0, t1=1;
float x_res=0,y_res=0;
void keyboard(void);void quit_pgm(void);void graphics_setup(void);
/*___________________________________________________________
MAIN ROUTINE */
main()
{
graphics_setup();
for (t1=1;t1!=2; ) keyboard();
quit_pgm();
}
/*_______________________________________________________________
SUBROUTINE: check the keyboard buffer */
void keyboard(void)
{
if (bioskey(1)==0) return; else quit_pgm();
}
/*____________________________________________________________________
SUBROUTINE: graceful exit from the program */
void quit_pgm(void)
{
cleardevice(); restorecrtmode();exit(0);
}
/*___________________________________________________________________
SUBROUTINE: vga/ega/cga/mcga compatibility module */
void graphics_setup(void)
{
int graphics_adapter,graphics_mode;
detectgraph(&graphics_adapter,&graphics_mode);
if (graphics_adapter==VGA) goto VGA_mode;
if (graphics_mode==EGAHI) goto EGA_ECD_mode;
if (graphics_mode==EGALO) goto EGA_SCD_mode;
if (graphics_adapter==CGA) goto CGA_mode;
if (graphics_adapter==MCGA) goto CGA_mode;
goto abort_message;
VGA_mode:
graphics_adapter=VGA;graphics_mode=VGAHI;
initgraph(&graphics_adapter,&graphics_mode,"");
x_res=640;y_res=480;mode_flag=1;
setcolor(C7);outtextxy(240,472,"640x480 16-color VGA mode");
return;
EGA_ECD_mode:
graphics_adapter=EGA;graphics_mode=EGAHI;
initgraph(&graphics_adapter,&graphics_mode,"");
x_res=640;y_res=350;mode_flag=2;
setcolor(C7);outtextxy(240,342,"640x350 16-color EGA w/ECD mode");
return;
EGA_SCD_mode:
graphics_adapter=EGA;graphics_mode=EGALO;
initgraph(&graphics_adapter,&graphics_mode,"");
x_res=640;y_res=200;;mode_flag=3;
setcolor(C7);outtextxy(240,192,"640x200 16-color EGA w/SCD mode");
return;
CGA_mode:
graphics_adapter=CGA;graphics_mode=CGAC3;
initgraph(&graphics_adapter,&graphics_mode,"");
x_res=320;y_res=200;C0=0;C1=3;C2=3;C3=3;C4=3;C5=3;C6=3;C7=3;
C8=2;C9=1;C10=3;C11=1;C12=3;C13=1;C14=3;C15=3;
mode_flag=4;
setcolor(C7);outtextxy(64,192,"320x200 4-color CGA mode");
return;
abort_message:
printf("\n\nUnable to proceed.\n");
printf("Requires VGA,EGA,MCGA or CGA adapter\n");
printf(" with appropriate monitor.\n");
printf("Please refer to the LEE ADAMS book, HIGH-Performance Graphics in TURBO C.\n\n");
exit(0);
}
/* END */
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/