DumbGame is a video game I wrote in 2002 intended to serve as somewhat of a tutorial or map of how games were developed in years past, on the 80×86 architecture under DOS (Disk Operating System). Going through an old laptop hard-drive I recently rediscovered its source code, finally making an appearance on the Internet as intended, even more appropriate and nostalgic this many more years later.
Its name sake is due to the fact that the actual game play, graphics, levels etc. were minimally developed only to the extent needed to showcase the functionality of the game engine.
The game engine itself is of a skeleton development with only the platform game features most characteristic for the late’80 – early ’90 era. That being said it does have everything needed to design a full platform game around it, as well as illustrate how those features get implemented and ways to include additional ones.
The game was written in Turbo C for DOS. It accesses hardware directly as such in is not able to run on modern operating systems that invoke protected mode unless emulated. Luckily at the time of writing of this article there is still a version of Turbo C that has been ported for the MS Windows OS.
The source code is split up into 8 different modules:
- DGG.C and DGG.H which houses the graphics handling functions.
- DGK.C with some keyboard setup functions.
- DGT.C hardware timer handling.
- DGF.C whose functions handle the loading and saving of level maps from files.
- DGS.C housing the sprite handling functions.
- DGTEXT.C setting up a custom bitmap font and functions to print characters and strings.
- DGMACHINE.C with all the functions the drive the behavior of the different game pieces (referred to as machines by convetion).
- DGM.C And finally DGM which stands for DG Main and houses the setup code and main game loop.
DGG.C and its associated header file make up a very basic video graphics library. We use BIOS interrupts to set the video mode to VGA (320×200 pixels) and setup the desired colored palette. In the specific video mode we are using the color palette is stored in the video DAC and screen pixels are mapped out in memory, starting at location A000 HEXADECIMAL. We accomplish reading and writing pixels by simply reading or writing the corresponding byte of memory. On older hardware such functions would be optimized by being written in inline assembly to aid performance, this is no issue here of course on account of us being in the future.
https://en.wikipedia.org/wiki/Mode_13h , here is some further info on the video mode specifics.
#include <dos.h> void set320(void) { reg.x.ax=0x13; int86(0x10,®,®); } void set_pix(char color,int x,int y) { pokeb(0xA000,x+(320*y),color); } char get_pix(int x,int y) { return peekb(0xA000,x+(320*y)); } void setdac( int DAC,char r, char g,char b ) { reg.x.ax=0x1010; reg.x.bx=DAC; reg.h.ch=g; reg.h.cl=b; reg.h.dh=r; int86(0x10,®,®); }
#include <dos.h> //#define DBG 1 #define P 20 #define HIGHT 12 #define WIDTH 7 #define LHIGHT 15 #define LWIDTH 45 #define MACIDS 50 #define MSPIKE 20 #define MFATH 5 #define MYIPI 5 #define MAXB 6 #define DUDESPEED 1 #define DUDEX 14 #define DUDEY 12 //#define eatCPU 8 #define eatCPU 1 union REGS reg; void set320(void); void set_pix(char, int, int); char get_pix(int, int); void setdac( int, char, char,char b);
DGK.C houses only two functions, one that sets a higher key repeat rate for the keyboard and one that restores the default when the game exits. It is necessary to manipulate the key repeat rate because of the way the game handles keyboard input. This chosen method for keyboard handling is not as responsive as others and while used in some games it was not done so often. Having access to modern computing power we are able to slide by with it, I chose to do so since its ease of comprehension.
void kbdspeed(void) { reg.h.ah=0x03; reg.h.al=0x05; reg.h.bh=0x00; reg.h.bl=0x00; int86(0x16,®,®); } void kbdnormal(void) { reg.h.ah=0x03; reg.h.al=0x02; int86(0x16,®,®); }
The purpose of the timer module(DGT.C) is to give us access to a hardware timer … this allows to have events in the game take place at specific time intervals regardless of the CPU speed on which the game runs. This is later illustrated by having one of the game machines unlinked from the hardware timer and its movement on screen is visibly much quicker than the other machines. More on this later.
The way we accomplish the machine timing is through the use of counters that count down until a specific event should take place. For the hardware linked timers that is accomplished by attaching an interrupt handling routine that decrements the timers every time it is evoked by the Programmable Interval Timer aka PIT.
We program the PIT with our desired timing and attach our handler to the interrupter it calls, of course we also have to make sure we execute whatever other handler were attached to it previously by other software and make sure we execute it at the appropriate time since we have programmed the intervals for out purposes.
This is done by the hander() function. The uppit() function programs the PIT with our desired timing. The normpit() restores the PIT interval on the channel we are using to default, here again I take a liberty with simply resetting the interval to the default settings upon exiting the game since we are running in an emulated environment it does not make a difference. However the appropriate way to handle this if running on an actual DOS platform would be to store the settings that the PIT was programmed at before we set ours and then restore those at game exit. In this way we are able to avoid causing conflicts and interfering with the behavior of other software that uses the PIT.
For more info on the PIT referee to this, https://wiki.osdev.org/Programmable_Interval_Timer
#include <stdio.h> #include <dos.h> #include <conio.h> #define MGT 3+MACIDS+MSPIKE+MFATH+MYIPI #define INTR 0X8 /* The clock tick interrupt */ void interrupt ( *oldhandler)(void); int *count[MGT]; int bflag=1; void interrupt handler(void) { int i; for(i=0;i<MGT;i++) if((*count[i]>0)&&(count[i]!=NULL)) *count[i]-=1; if(bflag){ bflag=0; oldhandler(); } else { bflag=1; outportb(0x20,0x20);} } void uppit(void){ outportb(0x43,0x36); outportb(0x40,0x00); outportb(0x40,0x80); } void normpit(void){ outportb(0x43,0x36); outportb(0x40,0x00); outportb(0x40,0x00); }
DGF.C has two extremely simple functions, one that writes out the array structure that holds our level map information from memory to a file and an other that does the opposite.
int writelevel(char *name, char *board){ FILE *flev; if ((flev = fopen(name, "wb+")) == NULL) { fprintf(stderr, "Cannot open output file.\n"); return 1; } fwrite(board, LHIGHT*LWIDTH, 1, flev); fclose(flev); return 0; } int readlevel(char *name, char *board){ FILE *flev; if ((flev = fopen(name, "rb")) == NULL) { fprintf(stderr, "Cannot open input file.\n"); return 1; } fread(board, LHIGHT*LWIDTH, 1, flev); fclose(flev); return 0; }
DGS.C provides the functions for sprite handling. Sprites are the pixmaps of images that make up the animations for our in game characters, and in the case of this game engine the level terrain and text characters.
flipspritey() is used to generate a mirror image of a sprite, since all sprites are defined in code in the form of arrays it is much easier just to make the computer do the work of generating the sprites for machines that move in both directions.
putsprite() and putblock() are very similar, they both put a sprite on the screen. Only difference in the two is how they access the memory where the sprite data is stored. The putblock() function using a pointer, this is simply due to the fact of how the in game text fonts are setup.
killsprite() is used for erasing a sprite off the screen, it does so in the easiest way by filling that specific block on screen with a chosen color, as such it can also be used to place blocks of any chosen color on screen.
All of these functions utilize the set_pix() function from DGG.C to set pixels on the display. This a very inefficient way to handle video graphics in general functions for sprite handling would use direct memory writes, inline assembly, even using “word move” instruction if available. Using the set_pix() function does make the code much more illustrative and intuitive to grasp, so we go with that, and remember we are in the future so resources are abundant.
void flipspritey(char sprite[HIGHT][WIDTH],char sprite1[HIGHT][WIDTH]){ int y,x,i; for(y=0;y<HIGHT;y++){ i=WIDTH-1; for(x=0;x<WIDTH;x++,i--){ sprite1[y][x]=sprite[y][i]; #ifdef DBG printf("|X=%d I=%d| ",x,i); #endif } } } void putsprite(char sprite[HIGHT][WIDTH],int x, int y){ int i,j; for(i=0;i<HIGHT;i++) for(j=0;j<WIDTH;j++) set_pix(sprite[i][j],x+j,y+i); } void putblock(char *sprite,int x, int y){ int i,j; j=x; for(i=0;i<HIGHT*WIDTH;i++){ set_pix(*(sprite+i),x,y); x++; if( x>(j+(WIDTH-1)) ){ y++; x=j; } } } void killsprite(char color,int x, int y){ int i,j; for(i=0;i<HIGHT;i++) for(j=0;j<WIDTH;j++) set_pix(color,x+j,y+i); }
Text character pixmaps and font array are defined in DGTEXT.C, along with 3 functions one that initializes the array that stores the font, one for drawing a text character on screen and the third that uses the text character draw function to write out a character string to the display.
The putletter() function that draws a text character on screen is really just a wrapper. It calls the putblock() function that we defined in the sprite handling module and passes it the appropriate arguments.
#define MAXL 256 char nada[HIGHT][WIDTH]={{11,00,11,11,00,11,11}, {11,00,00,11,00,11,11}, {11,00,11,00,00,11,11}, {11,00,11,11,00,11,11}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}}; char nada0[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nada1[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,10,00,00,00}, {00,00,10,10,00,00,00}, {00,00,10,10,00,00,00}, {00,10,10,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,10,10,10,10,10,00}, {00,00,00,00,00,00,00}}; char nada2[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,00,10,10,00,00}, {00,00,10,00,00,00,00}, {00,10,10,10,10,10,00}, {00,00,00,00,00,00,00}}; char nada3[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,00,10,10,00,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nada4[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,00,00,10,00,00}, {00,10,00,00,10,00,00}, {00,10,00,00,10,00,00}, {00,10,00,00,10,00,00}, {00,10,10,10,10,10,00}, {00,00,00,00,10,00,00}, {00,00,00,00,10,00,00}, {00,00,00,00,10,00,00}, {00,00,00,00,10,00,00}, {00,00,00,00,10,00,00}, {00,00,00,00,00,00,00}}; char nada5[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nada6[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,10,10,00,00}, {00,10,10,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nada7[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,10,00,00}, {00,00,00,00,10,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,10,00,00,00,00}, {00,00,10,00,00,00,00}, {00,00,10,00,00,00,00}, {00,00,00,00,00,00,00}}; char nada8[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nada9[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadaA[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,10,10,10,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char nadaB[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadaC[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadaD[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadaE[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,00,00,00,00,00,00}}; char nadaF[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,00,00,00,00,00,00}}; char nadaG[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadaH[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,10,10,10,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char nadaI[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,10,10,10,10,10,00}, {00,00,00,00,00,00,00}}; char nadaJ[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,10,00}, {00,00,00,00,10,00,00}, {00,00,00,00,10,00,00}, {00,00,00,00,10,00,00}, {00,00,00,00,10,00,00}, {00,00,00,00,10,00,00}, {00,10,00,00,10,00,00}, {00,10,00,00,10,00,00}, {00,10,00,00,10,00,00}, {00,00,10,10,00,00,00}, {00,00,00,00,00,00,00}}; char nadaK[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,10,00,00}, {00,10,00,00,10,00,00}, {00,10,10,10,00,00,00}, {00,10,10,00,00,00,00}, {00,10,00,10,00,00,00}, {00,10,00,00,10,00,00}, {00,10,00,00,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char nadaL[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,00,00,00,00,00,00}}; char nadaM[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,10,00,10,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char nadaN[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,10,00,00,10,00}, {00,10,10,00,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,00,10,10,00}, {00,10,00,00,10,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char nadaO[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,10,00,00,00}, {00,00,10,00,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,00,10,00,00}, {00,00,00,10,00,00,00}, {00,00,00,00,00,00,00}}; char nadaP[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,00,00,00,00,00,00}}; char nadaQ[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,10,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,10}, {00,00,00,00,00,00,00}}; char nadaR[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char nadaS[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadaT[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,10,00,10,00,10,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadaU[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadaV[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,00,10,00,00}, {00,00,10,00,10,00,00}, {00,00,00,10,00,00,00}, {00,00,00,00,00,00,00}}; char nadaW[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,00,10,00,10,00,00}, {00,00,00,00,00,00,00}}; char nadaX[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,00,10,00,00}, {00,00,10,00,10,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,10,00,10,00,00}, {00,00,10,00,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char nadaY[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,00,10,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,00,00,00,00}}; char nadaZ[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,00,10,10,00,00}, {00,00,10,10,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,00,00,00,00,00,00}}; char nadaperiod[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,00,00,00}, {00,00,10,10,00,00,00}, {00,00,00,00,00,00,00}}; char nadaspace[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}}; char nadaa[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,10,10,00,10,00}, {00,10,00,00,10,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,10,10,00}, {00,00,10,10,00,10,00}, {00,00,00,00,00,00,00}}; char nadab[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,10,10,00,00}, {00,10,10,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,10,00,00,10,00}, {00,10,00,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadac[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadad[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,00,10,10,00,10,00}, {00,10,00,00,10,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,10,10,00}, {00,00,10,10,00,10,00}, {00,00,00,00,00,00,00}}; char nadae[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,10,00,00,10,00}, {00,10,00,10,10,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadaf[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,00,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,00,00,00,00,00,00}}; char nadag[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,00,10,00}, {00,10,00,00,10,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,10,10,00}, {00,00,10,10,00,10,00}, {00,00,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadah[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char nadai[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadaj[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,00,00,00}, {00,00,00,10,00,00,00}, {00,10,00,10,00,00,00}, {00,10,00,10,00,00,00}, {00,00,10,00,00,00,00}, {00,00,00,00,00,00,00}}; char nadak[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,10,00,00}, {00,10,10,10,00,00,00}, {00,10,10,10,00,00,00}, {00,10,00,00,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char nadal[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadam[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,00,10,00,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char nadan[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,00,10,10,00,00}, {00,10,10,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char nadao[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadap[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,10,10,10,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,00,00,00,00,00,00}}; char nadaq[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,10,00,00}, {00,10,00,00,10,00,00}, {00,10,00,00,10,00,00}, {00,00,10,10,10,00,00}, {00,00,00,00,10,00,00}, {00,00,00,00,10,00,00}, {00,00,00,00,10,10,00}, {00,00,00,00,00,00,00}}; char nadar[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,00,10,10,00,00}, {00,10,10,00,00,10,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,00,00,00,00,00,00}}; char nadas[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadat[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,10,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadau[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,10,10,00}, {00,00,10,10,00,10,00}, {00,00,00,00,00,00,00}}; char nadav[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,00,10,00,00}, {00,00,10,00,10,00,00}, {00,00,10,00,10,00,00}, {00,00,10,00,10,00,00}, {00,00,00,10,00,00,00}, {00,00,00,00,00,00,00}}; char nadaw[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,10,00,10,00,10,00}, {00,00,10,00,10,00,00}, {00,00,00,00,00,00,00}}; char nadax[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,00,10,00,10,00,00}, {00,00,10,00,10,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,10,00,10,00,00}, {00,00,10,00,10,00,00}, {00,10,00,00,00,10,00}, {00,00,00,00,00,00,00}}; char naday[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,00,10,00}, {00,10,00,00,00,10,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}}; char nadaz[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,00,00,00,00,10,00}, {00,00,00,00,10,00,00}, {00,00,00,10,00,00,00}, {00,00,00,10,00,00,00}, {00,00,10,00,00,00,00}, {00,10,00,00,00,00,00}, {00,10,10,10,10,10,00}, {00,00,00,00,00,00,00}}; char nadaminus[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,10,10,10,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}}; char nadaempty[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}}; char *font[MAXL]; void fontinit(void){ font[0]=(char *)&nada; font[1]=(char *)&nada; font[2]=(char *)&nada; font[3]=(char *)&nada; font[4]=(char *)&nada; font[5]=(char *)&nada; font[6]=(char *)&nada; font[7]=(char *)&nada; font[8]=(char *)&nada; font[9]=(char *)&nada; font[10]=(char *)&nada; font[11]=(char *)&nada; font[12]=(char *)&nada; font[13]=(char *)&nada; font[14]=(char *)&nada; font[15]=(char *)&nada; font[16]=(char *)&nada; font[17]=(char *)&nada; font[18]=(char *)&nada; font[19]=(char *)&nada; font[20]=(char *)&nada; font[21]=(char *)&nada; font[22]=(char *)&nada; font[23]=(char *)&nada; font[24]=(char *)&nada; font[25]=(char *)&nada; font[26]=(char *)&nada; font[27]=(char *)&nada; font[28]=(char *)&nada; font[29]=(char *)&nada; font[30]=(char *)&nada; font[31]=(char *)&nada; font[32]=(char *)&nadaspace; font[33]=(char *)&nada; font[34]=(char *)&nada; font[35]=(char *)&nada; font[36]=(char *)&nada; font[37]=(char *)&nada; font[38]=(char *)&nada; font[39]=(char *)&nada; font[40]=(char *)&nada; font[41]=(char *)&nada; font[42]=(char *)&nada; font[43]=(char *)&nada; font[44]=(char *)&nada; font[45]=(char *)&nadaminus; font[46]=(char *)&nadaperiod; font[47]=(char *)&nada; font[48]=(char *)&nada0; font[49]=(char *)&nada1; font[50]=(char *)&nada2; font[51]=(char *)&nada3; font[52]=(char *)&nada4; font[53]=(char *)&nada5; font[54]=(char *)&nada6; font[55]=(char *)&nada7; font[56]=(char *)&nada8; font[57]=(char *)&nada9; font[58]=(char *)&nada; font[59]=(char *)&nada; font[60]=(char *)&nada; font[61]=(char *)&nada; font[62]=(char *)&nada; font[63]=(char *)&nada; font[64]=(char *)&nada; font[65]=(char *)&nadaA; font[66]=(char *)&nadaB; font[67]=(char *)&nadaC; font[68]=(char *)&nadaD; font[69]=(char *)&nadaE; font[70]=(char *)&nadaF; font[71]=(char *)&nadaG; font[72]=(char *)&nadaH; font[73]=(char *)&nadaI; font[74]=(char *)&nadaJ; font[75]=(char *)&nadaK; font[76]=(char *)&nadaL; font[77]=(char *)&nadaM; font[78]=(char *)&nadaN; font[79]=(char *)&nadaO; font[80]=(char *)&nadaP; font[81]=(char *)&nadaQ; font[82]=(char *)&nadaR; font[83]=(char *)&nadaS; font[84]=(char *)&nadaT; font[85]=(char *)&nadaU; font[86]=(char *)&nadaV; font[87]=(char *)&nadaW; font[88]=(char *)&nadaX; font[89]=(char *)&nadaY; font[90]=(char *)&nadaZ; font[91]=(char *)&nada; font[92]=(char *)&nada; font[93]=(char *)&nada; font[94]=(char *)&nada; font[95]=(char *)&nada; font[96]=(char *)&nada; font[97]=(char *)&nadaa; font[98]=(char *)&nadab; font[99]=(char *)&nadac; font[100]=(char *)&nadad; font[101]=(char *)&nadae; font[102]=(char *)&nadaf; font[103]=(char *)&nadag; font[104]=(char *)&nadah; font[105]=(char *)&nadai; font[106]=(char *)&nadaj; font[107]=(char *)&nadak; font[108]=(char *)&nadal; font[109]=(char *)&nadam; font[110]=(char *)&nadan; font[111]=(char *)&nadao; font[112]=(char *)&nadap; font[113]=(char *)&nadaq; font[114]=(char *)&nadar; font[115]=(char *)&nadas; font[116]=(char *)&nadat; font[117]=(char *)&nadau; font[118]=(char *)&nadav; font[119]=(char *)&nadaw; font[120]=(char *)&nadax; font[121]=(char *)&naday; font[122]=(char *)&nadaz; font[123]=(char *)&nada; font[124]=(char *)&nada; font[125]=(char *)&nada; font[126]=(char *)&nada; font[127]=(char *)&nada; font[128]=(char *)&nada; font[129]=(char *)&nada; font[130]=(char *)&nada; font[131]=(char *)&nada; font[132]=(char *)&nada; font[133]=(char *)&nada; font[134]=(char *)&nada; font[135]=(char *)&nada; font[136]=(char *)&nada; font[137]=(char *)&nada; font[138]=(char *)&nada; font[139]=(char *)&nada; font[140]=(char *)&nada; font[141]=(char *)&nada; font[142]=(char *)&nada; font[143]=(char *)&nada; font[1414]=(char *)&nada; font[145]=(char *)&nada; font[146]=(char *)&nada; font[147]=(char *)&nada; font[148]=(char *)&nada; font[149]=(char *)&nada; font[150]=(char *)&nada; font[151]=(char *)&nada; font[152]=(char *)&nada; font[153]=(char *)&nada; font[154]=(char *)&nada; font[155]=(char *)&nada; font[156]=(char *)&nada; font[157]=(char *)&nada; font[158]=(char *)&nada; font[159]=(char *)&nada; font[160]=(char *)&nada; font[161]=(char *)&nada; font[162]=(char *)&nada; font[163]=(char *)&nada; font[164]=(char *)&nada; font[165]=(char *)&nada; font[166]=(char *)&nada; font[167]=(char *)&nada; font[168]=(char *)&nada; font[169]=(char *)&nada; font[170]=(char *)&nada; font[171]=(char *)&nada; font[172]=(char *)&nada; font[173]=(char *)&nada; font[174]=(char *)&nada; font[175]=(char *)&nada; font[176]=(char *)&nada; font[177]=(char *)&nada; font[178]=(char *)&nada; font[179]=(char *)&nada; font[180]=(char *)&nada; font[181]=(char *)&nada; font[182]=(char *)&nada; font[183]=(char *)&nada; font[184]=(char *)&nada; font[185]=(char *)&nada; font[186]=(char *)&nada; font[187]=(char *)&nada; font[188]=(char *)&nada; font[189]=(char *)&nada; font[190]=(char *)&nada; font[191]=(char *)&nada; font[192]=(char *)&nada; font[193]=(char *)&nada; font[194]=(char *)&nada; font[195]=(char *)&nada; font[196]=(char *)&nada; font[197]=(char *)&nada; font[198]=(char *)&nada; font[199]=(char *)&nada; font[200]=(char *)&nada; font[201]=(char *)&nada; font[202]=(char *)&nada; font[203]=(char *)&nada; font[204]=(char *)&nada; font[205]=(char *)&nada; font[206]=(char *)&nada; font[207]=(char *)&nada; font[208]=(char *)&nada; font[209]=(char *)&nada; font[210]=(char *)&nada; font[211]=(char *)&nada; font[212]=(char *)&nada; font[213]=(char *)&nada; font[214]=(char *)&nada; font[215]=(char *)&nada; font[216]=(char *)&nada; font[217]=(char *)&nada; font[218]=(char *)&nada; font[219]=(char *)&nada; font[220]=(char *)&nada; font[221]=(char *)&nada; font[222]=(char *)&nada; font[223]=(char *)&nada; font[224]=(char *)&nada; font[225]=(char *)&nada; font[226]=(char *)&nada; font[227]=(char *)&nada; font[228]=(char *)&nada; font[229]=(char *)&nada; font[230]=(char *)&nada; font[231]=(char *)&nada; font[232]=(char *)&nada; font[233]=(char *)&nada; font[234]=(char *)&nada; font[235]=(char *)&nada; font[236]=(char *)&nada; font[237]=(char *)&nada; font[238]=(char *)&nada; font[239]=(char *)&nada; font[240]=(char *)&nada; font[241]=(char *)&nada; font[242]=(char *)&nada; font[243]=(char *)&nada; font[244]=(char *)&nada; font[245]=(char *)&nada; font[246]=(char *)&nada; font[247]=(char *)&nada; font[248]=(char *)&nada; font[249]=(char *)&nada; font[250]=(char *)&nada; font[251]=(char *)&nada; font[252]=(char *)&nada; font[253]=(char *)&nada; font[254]=(char *)&nada; font[255]=(char *)&nada; } void putletter(char *fa[MAXL], char letter, int x, int y){ putblock(fa[(int)letter],x, y); } void putmsg(char *fa[MAXL], char string[MAXL],int x, int y){ int i=0; while(string[i]!='\0'){ putletter(fa, string[i],x , y); x+=WIDTH; i++; } }
DGMACHINE.C module contains all the functions responsible for the behavior of the in game characters. This would be a good time to discuss how a basic game engine operates.
A game engine in its essence is a collection of functions/methods/routines that implement the rules of behavior for all the active elements of game play. The active elements are generally referred to as “machines” as we stated previously.
Each of these machines (active game elements) has a function that handles its behavior, as well as data structure of some type that stores all relevant information for each instance of that specific machine type.
The main game loop calls on those “machine” behavior handling function, some functions that handle the passive elements and also ones that handle the user input.
Each run through of the main game loop has to handle user input, iterate through all instances of all machine types handling their behavior with the appropriate function, refresh any of the passive elements if needed and then render the collective graphics output of all game elements on the display.
While a game engine can be as simple as that, such as the one on display in this article, quite complex game systems and in game element behaviors can be derived by simply introducing more game machines and more instances of said machines. Just like in nature extremely complex behaviors and systems can arise form the interaction of elements that are individually guided by simple rules, however in totality the whole system’s behavior is anything but.
int acid(char sprite[HIGHT][WIDTH],char sprite2[HIGHT][WIDTH],int *mdelay,int *ms,int mx, int my, int x, int y){ if(*mdelay==0){ *mdelay=8*eatCPU; if(*ms){ putsprite(sprite,mx,my); *ms=0;} else { putsprite(sprite2,mx,my); *ms=1;} } // else { *mdelay-=1; } if((y+HIGHT>=my)&&(y+HIGHT<=my+HIGHT)) if((x<=mx+WIDTH)&&(x+WIDTH>=mx)) { return 1; } return 0; } int dspikef(char sprite[HIGHT][WIDTH],char sprite2[HIGHT][WIDTH],int *mdelay,int *ms,int mx, int my, int x, int y){ if(*mdelay==0){ *mdelay=3*eatCPU; if(*ms){ putsprite(sprite,mx,my); *ms=0;} else { putsprite(sprite2,mx,my); *ms=1;} } // else { *mdelay-=1; } if((y+HIGHT>my)&&(y+HIGHT<=my+HIGHT)) if((x<=mx+WIDTH)&&(x+WIDTH>=mx)) { return 2; } return 0; } int fathf(char sprite[HIGHT][WIDTH],char sprite2[HIGHT][WIDTH],int *mdelay,int *ms,int mx, int my, int x, int y){ if(*mdelay==0){ *mdelay=30*eatCPU; if(*ms){ putsprite(sprite,mx,my); *ms=0;} else { putsprite(sprite2,mx,my); *ms=1;} } // else { *mdelay-=1; } if((y+HIGHT>my)&&(y+HIGHT<=my+HIGHT)) if((x<=mx+WIDTH)&&(x+WIDTH>=mx)) { return 3; } return 0; } int yipif(char sprite[HIGHT][WIDTH],char sprite2[HIGHT][WIDTH],int *mdelay,int *ms,int *mx, int *my, int x, int y){ int temp=0; if(*mdelay==0){ *mdelay=500*eatCPU; if(*ms){ if( ( (temp=get_pix(*mx+WIDTH,*my+(HIGHT-1))) >=0)&&(temp<=10)){ if( ( (temp=get_pix(*mx+WIDTH,*my)) >=0)&&(temp<=10)){ killsprite(0,*mx,*my); *mx+=1; } } else *ms=0; putsprite(sprite,*mx,*my); } else{ if( ( (temp=get_pix(*mx-1,*my+(HIGHT-1))) >=0)&&(temp<=10) ){ if( ( (temp=get_pix(*mx-1,*my)) >=0)&&(temp<=10) ){ killsprite(0,*mx,*my); *mx-=1; } }else *ms=1; putsprite(sprite2,*mx,*my); } } else { *mdelay-=1; } if((y+HIGHT>*my)&&(y+HIGHT<=*my+HIGHT)) if((x<=*mx+WIDTH)&&(x+WIDTH>=*mx)) { return 4; } return 0; } int dinof(char sprite[HIGHT][WIDTH],char sprite2[HIGHT][WIDTH],int *mdelay,int *ms,int mx, int my, int x, int y){ if(*mdelay==0){ *mdelay=6000*eatCPU; if(*ms){ putsprite(sprite,mx,my); *ms=0;} else { putsprite(sprite2,mx,my); *ms=1;} } else { *mdelay-=1; } if((y+HIGHT>my)&&(y+HIGHT<=my+HIGHT)) if((x<=mx+WIDTH)&&(x+WIDTH>=mx)) { return 42; } return 0; }
In the DGM.C module we put it all together. Levels are loaded, machines setup, etc.
After everything is initialized we enter the main loop and proceed to iterate through it until the game is quit.
A small note: If you look at the animated image of game play you can clearly see the some machines move much faster than others, specifically if you notice what is supposed to be “guy on scooter”. We mentioned this earlier when we talked about in game timers, as an example of CPU clock dependent game timer, this specific machine was deliberately untied from the PIT timer.
Early on in PC-XT and some 8bit architecture game development it was more common to see for games to use timers/delays that were dependent on the CPU running at a specific speed. As PCs evolved it was necessary to write code that was independent from CPU clock speed as the game could end up running on numerous different processors.
This was sometimes done by adding controls to the game that allowed to increase or decrease the delays on the fly to adjust for different clock speeds. A much more elegant solution is the one we presented here, by tying the delay counters to the PIT we are able to ensure events in game happen at regular scheduled intervals no matter the processor clock speed.
#include "dos.h" #include #include #include #include ".\dgg.h" #include ".\dgg.c" #include ".\dgk.c" #include ".\dgs.c" #include ".\dgmachine.c" #include ".\dgt.c" #include ".\dgtext.c" #include ".\dgf.c" void loadlevel(char *sprite[MAXB], char level[LHIGHT][LWIDTH]){ int i=0,j=0,x=0,y=0; for(j=0;j<LHIGHT;j++){ for(i=0;i<LWIDTH;i++){ putblock(sprite[level[j][i]],x, y); x+=WIDTH; } y+=HIGHT; x=0; } } void loadlevels(char level[LHIGHT][LWIDTH]){ int i=0,j=0,x=0,y=0; for(j=0;j<LHIGHT;j++){ for(i=0;i<LWIDTH;i++){ if(level[j][i]) killsprite(level[j][i],x,y); x+=WIDTH; } y+=HIGHT; x=0; } } void showpallete(void){ int i=0,j=0,c; for(c=0;c<256;c++){ killsprite(c,i,j); if(i>305){ i=0; j+=12;} else i+=7; #ifdef DBG printf("%d",i); #endif } } int main(void) { int x,y,quit=0,pause=0,temp,jump=0,fall=0; int oldx=0,oldy=0; int i=0; int j=0; int left=0, dead=0; int mx,my,ms=0,mdelay=0; // int fathd=0, faths=0, fx=0, fy=0; int dinod=0, dinos=0; int fall_delay=0; int jump_delay=5; int dead_delay=0; char keyme; int acids[MACIDS][4]={{0,0,42,156}, {0,0,49,156}, {0,0,56,156}, {0,0,63,156}, {0,0,70,156}, {0,0,77,156}, {0,0,84,156}, {0,0,91,156}, {0,0,98,156}, {0,0,105,156}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}}; int dspikes[MSPIKE][4]={{0,0,104,120}, {0,0,70,60}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}, {-1,0,0,0}}; int fathos[MFATH][4]={{-1,0,203,156}, {-1,0,70,60}, {-1,0,56,156}, {-1,0,63,156}, {0,0,203,156}}; int yipis[MYIPI][4]={{0,0,196,156}, {-1,0,70,60}, {-1,0,56,156}, {-1,0,63,156}, {-1,0,70,156}}; char dude[HIGHT][WIDTH]={{17,12,12,12,17,17,17}, { 8,12,12,12,12,12,17}, {91,91,91, 9,91,17,17}, {17,91,91,91,17,17,17}, {17,91,17,17,17,17,17}, {17,04,12,17,23,23,23}, {17,12,04,91,24,17,17}, {17,34,34,17,17,17,17}, {17,34,34,17,17,17,17}, {17,34,17,17,17,17,17}, {17, 6, 6,17,17,17,17}, {17, 8, 8, 8,17,17,17}}; char dudel[HIGHT][WIDTH]; char dude1[HIGHT][WIDTH]={{17,12,12,12,17,17,17}, { 8,12,12,12,12,12,17}, {91,91,91, 9,91,17,17}, {17,91,91,91,17,17,17}, {17,91,17,17,17,17,17}, {17,04,12,17,23,23,23}, {17,12,04,91,24,17,17}, {17,34,34,17,17,17,17}, {17,34,34,17,17,17,17}, {17,34,17,34,17,17,17}, { 6, 6,17, 6, 6,17,17}, { 8, 8, 8, 8, 8, 8,17}}; char dudel1[HIGHT][WIDTH]; char dudej[HIGHT][WIDTH]={{17,12,12,12,17,17,17}, { 8,12,12,12,12,12,17}, {91,91,91, 9,91,17,17}, {17,91,91,91,17,17,17}, {17,91,17,17,17,17,17}, {17,04,12,17,23,23,23}, {17,12,04,91,24,17,17}, {17,34,34,17,17,17,17}, {17,34,34,34,17,17,17}, { 8, 6,34,34,17,17,17}, { 8, 6,17, 6, 6,17,17}, { 8,17,17, 8, 8, 8,17}}; char dudelj[HIGHT][WIDTH]; char dudead[HIGHT][WIDTH]={{17,19,19,17,17,17,19}, {19,21,20,19,17,19,19}, {17,20,19,17,19,20,19}, {17,19,17,17,19,21,17}, {17,12,12,12,17,19,17}, { 8,12,12,12,12,12,17}, {91,91,91, 9,91,17,17}, {17,91,91,91,17,17,17}, {17,91,17,17,17,17,17}, {17,04,12,17,23,23,23}, {17,12,04,91,24,17,17}, {17,34,34,17,17,17,17}}; char dudead1[HIGHT][WIDTH]={{17,21,21,17,17,17,17}, {21,22,22,21,17,17,17}, {21,22,23,17,21,17,17}, {17,24,23,21,17,17,17}, {21,22,24,21,17,17,17}, {21,22,22,21,23,17,17}, {17,21,21,17,17,17,17}, {17,21,23,17,17,17,17}, {17,12,12,12,17,17,17}, { 8,12,12,12,12,12,17}, {91,91,91, 9,91,17,17}, {17,91,91,91,17,17,17}}; char dudead2[HIGHT][WIDTH]={{21,21,21,17,17,21,17}, {21,22,23,21,21,21,21}, {17,21,22,23,23,22,21}, {17,22,23,21,24,21,17}, {17,21,22,24,23,22,21}, {21,22,23,24,24,21,17}, {21,22,23,23,24,17,21}, {17,21,22,24,23,21,21}, {21,22,23,24,23,21,17}, {21,22,22,23,23,21,17}, {17,21,21,17,21,17,17}, {17,17,17,21,17,17,17}}; char dudeb[HIGHT][WIDTH]={{17,12,12,12,17,17,27}, { 8,12,12,12,12,12,26}, {91,91,91, 9,91,17,25}, {17,91,91,91,15,15,42}, {17,91,17,17,17,17,17}, {17,04,12,17,17,17,17}, {17,12,04,91,17,17,17}, {17,34,34,17,17,17,17}, {17,34,34,17,17,17,17}, {17,34,17,17,17,17,17}, {17, 6, 6,17,17,17,17}, {17, 8, 8, 8,17,17,17}}; char dudeb1[HIGHT][WIDTH]={{17,12,12,12,17,17,25}, { 8,12,12,12,12,12,24}, {91,91,91,12,91,17,23}, {17,91,91,91,15,15,43}, {17,91,17,17,17,17,17}, {17,04,12,17,17,17,17}, {17,12,04,91,17,17,17}, {17,34,34,17,17,17,17}, {17,34,34,17,17,17,17}, {17,34,17,17,17,17,17}, {17, 6, 6,17,17,17,17}, {17, 8, 8, 8,17,17,17}}; char dudeb2[HIGHT][WIDTH]={{17,12,12,12,17,17,23}, { 8,12,12,12,12,12,24}, {91,91,91, 9,91,17,25}, {17,91,91,91,15,15,44}, {17,91,17,17,17,17,17}, {17,04,12,17,17,17,17}, {17,12,04,91,17,17,17}, {17,34,34,17,17,17,17}, {17,34,34,17,17,17,17}, {17,34,17,17,17,17,17}, {17, 6, 6,17,17,17,17}, {17, 8, 8, 8,17,17,17}}; char cube[HIGHT][WIDTH]={{19,19,19,19,19,19,19}, {20,20,20,20,20,20,20}, {21,21,21,21,21,21,21}, {22,22,22,22,22,22,22}, {23,23,23,23,23,23,23}, {24,24,24,24,24,24,24}, {24,24,24,24,24,24,24}, {23,23,23,23,23,23,23}, {22,22,22,22,22,22,22}, {21,21,21,21,21,21,21}, {20,20,20,20,20,20,20}, {19,19,19,19,19,19,19}}; char capr[HIGHT][WIDTH]={{17,19,19,19,19,19,19}, {19,19,20,20,20,20,20}, {19,20,21,21,21,21,21}, {19,21,22,22,22,22,22}, {19,22,23,23,23,23,23}, {19,23,24,24,24,24,24}, {19,23,24,24,24,24,24}, {19,22,23,23,23,23,23}, {19,21,22,22,22,22,22}, {19,20,21,21,21,21,21}, {19,19,20,20,20,20,20}, {17,19,19,19,19,19,19}}; char capl[HIGHT][WIDTH]={{17,19,19,19,19,19,19}, {19,19,20,20,20,20,20}, {19,20,21,21,21,21,21}, {19,21,22,22,22,22,22}, {19,22,23,23,23,23,23}, {19,23,24,24,24,24,24}, {19,23,24,24,24,24,24}, {19,22,23,23,23,23,23}, {19,21,22,22,22,22,22}, {19,20,21,21,21,21,21}, {19,19,20,20,20,20,20}, {17,19,19,19,19,19,19}}; char rock[HIGHT][WIDTH]={{22,23,21,23,24,25,21}, {24,23,23,21,24,25,23}, {23,23,24,23,21,23,24}, {21,23,24,23,22,23,25}, {22,21,23,23,21,21,24}, {25,22,21,22,23,22,23}, {24,23,23,23,24,25,23}, {21,25,24,21,23,23,25}, {22,24,23,24,25,24,21}, {24,23,23,23,23,23,24}, {21,23,23,22,24,21,23}, {23,21,22,24,25,23,22}}; char brock[HIGHT][WIDTH]={{41,40,41,40,41,40,41}, {41,40,41,41,41,41,40}, {41,40,136,40,41,136,41}, {136,41,136,136,41,136,136}, {136,41,136,23,136,21,24}, {25,136,21,22,23,22,23}, {24,23,23,23,24,25,23}, {21,25,24,21,23,23,25}, {22,24,23,24,25,24,21}, {24,23,23,23,23,23,24}, {21,23,23,22,24,21,23}, {23,21,22,24,25,23,22}}; char back[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}}; char dinoc[HIGHT][WIDTH]={{17,17,12,12,17,17,22}, {12,12,12,12,12,17,23}, {17,91,91, 9,91,00,24}, {17,91,91,91,06,43,17}, {17,91,17,17,17,17,17}, {17,39,12,17,10,10,17}, {17,12,39,91,120,120,17}, {17,12,12,17,17,17,17}, {17,12,12,12,17,17,17}, { 8,23,12,12,17,17,17}, { 8,23,17,23,24,17,17}, { 8,17,17, 8, 8, 8,17}}; char dinoc1[HIGHT][WIDTH]={{17,17,12,12,17,17,24}, {12,12,12,12,12,17,23}, {17,91,91, 9,91,00,22}, {17,91,91,91,06,42,17}, {17,91,17,17,17,17,17}, {17,39,12,17,17,17,17}, {17,12,39,91,120,120,17}, {17,12,12,17,10,10,17}, {17,12,12,12,17,17,17}, { 8,23,12,12,17,17,17}, { 8,23,17,23,24,17,17}, { 8,17,17, 8, 8, 8,17}}; char fath[HIGHT][WIDTH]={{17,00,44,44,00,00,17}, {00,44,91, 9,91,91,00}, {44,44,91,91,40,00,00}, {00,00,91,91,91,00,00}, {00,39,39,39,39,39,00}, {39,39,39,39,39,39,39}, {39,136,39,136,39,136,39}, {39,39,136,39,136,39,39}, {91,39,39,39,39,39,91}, {00,39,39,39,39,39,00}, {00,39,39,39,39,39,00}, {21, 8,39,39,39, 8,21}}; char fath1[HIGHT][WIDTH]; char yipi[HIGHT][WIDTH]={{00,00, 6, 6,00,00,00}, {00, 6,91, 9,91,00,00}, {00, 6,91,91,00,00,00}, {00,00,91,91,91,00,00}, {00,00,15,15,00,00,00}, {00,00,15,15,00,00,00}, {00,00,15,15,91,24,00}, {00,00,23,23,00,00,25}, {00,00,24,24,00,00,24}, {00,00, 6, 6, 6,00,23}, {23,23,24,25,24,23,23}, {00,12,00,00,00,12,00}}; char yipi1[HIGHT][WIDTH]; char testlogo_orb[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,00,00,00,00}, {00,00,46,46,46,00,00}, {00,46,47,45,47,46,00}, {46,47,45,45,45,47,46}, {24,24,24,24,24,24,24}, {24,25,26,27,26,25,24}, {24,25,26,27,26,25,24}, {24,25,26,27,26,25,24}, {00,24,26,27,26,24,00}, {00,00,24,24,24,00,00}, {00,00,00,00,00,00,00}}; char acidc[HIGHT][WIDTH]={{00,46,46,00,00,00,00}, {46,45,45,46,00,00,46}, {45,45,45,45,46,46,45}, {45,44,45,44,45,45,45}, {45,45,45,45,45,45,45}, {45,45,44,45,45,45,45}, {45,45,45,45,45,45,45}, {45,45,45,45,44,45,45}, {45,45,45,45,45,45,45}, {45,44,45,45,45,45,45}, {45,45,45,45,45,45,44}, {45,45,45,45,45,45,45}}; char acidc1[HIGHT][WIDTH]; char dspike[HIGHT][WIDTH]={{00,00,00,00,00,00,00}, {00,00,00,24,00,00,00}, {00,00,21,23,21,00,00}, {00,21,22,23,22,21,00}, {24,21,22,24,22,21,24}, {00,21,22,23,22,21,00}, {24,21,22,24,22,21,24}, {00,21,22,23,22,21,00}, {24,21,22,24,22,21,24}, {00,21,22,23,22,21,00}, {24,21,22,24,22,21,24}, {00,21,22,23,22,21,00}}; char dspike1[HIGHT][WIDTH]={{00,00,00,24,00,00,00}, {00,00,00,23,00,00,00}, {00,00,21,23,21,00,00}, {24,21,22,24,22,21,24}, {00,21,22,23,22,21,00}, {24,21,22,24,22,21,24}, {00,21,22,23,22,21,00}, {24,21,22,24,22,21,24}, {00,21,22,23,22,21,00}, {24,21,22,24,22,21,24}, {00,21,22,23,22,21,00}, {00,21,22,23,22,21,00}}; char level1[LHIGHT][LWIDTH]={{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, { 2,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 2}, { 2,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 2}, { 2,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 2}, { 2,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 1,00,00,00, 1,00,00,00,00,00,00,00, 2}, { 2,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 1,00, 1, 3, 1,00, 1,00,00,00,00,00,00, 2}, { 2,00,00,00,00,00,00,00,00, 4, 5,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 1,00, 1,00, 1,00, 1,00,00,00,00,00,00, 2}, { 2,00,00,00,00, 4, 5,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 1, 1, 1,00, 1,00, 1,00,00,00,00,00,00, 2}, { 2,00,00,00,00,00,00,00, 4, 1, 1, 5,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 1,00, 1,00, 1,00, 1,00,00,00,00,00,00, 2}, { 2,00,00,00,00,00,00,00,00,00,00,00, 1,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 1,00, 1,00,00, 1,00, 1,00,00,00,00,00, 2}, { 2,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 2}, { 2,00,00,00,00,00,00,00,00,00,00,00, 2, 3, 3, 3, 2,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 2}, { 2,00,00,00, 2, 2,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 2}, { 2,00, 4, 1, 1, 2,00,00,00,00,00,00,00,00,00,00, 2,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 2}, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}}; char *blocks[MAXB]; char *dd[3]; blocks[0]=(char *)back; blocks[1]=(char *)cube; blocks[2]=(char *)rock; blocks[3]=(char *)brock; blocks[4]=(char *)capr; blocks[5]=(char *)capl; flipspritey(dude, dudel); flipspritey(dude1, dudel1); flipspritey(dudej, dudelj); flipspritey(acidc, acidc1); flipspritey(capr, capl); flipspritey(fath, fath1); flipspritey(yipi, yipi1); #ifdef DBG getch(); #endif x=DUDEX; y=DUDEY; mx=x; my=y; if(readlevel("level2.map",(char *)level1)){ printf("Can not open input file. File missing or corupted.\n"); return 1; } //.oO Init Graph mode from here on Oo.\\ set320(); loadlevel(blocks,level1); putsprite(dude,x,y); putsprite(testlogo_orb,0,199-HIGHT); putsprite(dinoc,231,48); fontinit(); putmsg(font,"DumbGame Nostalgic DOS game dev.",7,199-HIGHT); kbdspeed(); getch(); for(i=0;i<MGT;i++) count[i]=NULL; count[0]=&jump_delay; count[1]=&dead_delay; count[2]=&fall_delay; for(i=0;i<MACIDS;i++) if(acids[i][0]>=0){ count[3+i]=&acids[i][0]; } else count[3+i]=NULL; for(i=0;i<MSPIKE;i++) if(dspikes[i][0]>=0){ count[3+MACIDS+i]=&dspikes[i][0]; } else count[3+MACIDS+i]=NULL; for(i=0;i<MFATH;i++) if(fathos[i][0]>=0){ count[3+MACIDS+MSPIKE+i]=&fathos[i][0]; } else count[3+MACIDS+MSPIKE+i]=NULL; oldhandler = getvect(INTR); setvect(INTR, handler); uppit(); do{ oldx=x; oldy=y; if(kbhit()) keyme=getch(); switch(keyme){ case 's': if( ( (temp=get_pix(x+WIDTH,y+(HIGHT-1))) >=0)&&(temp<=10)) if( ( (temp=get_pix(x+WIDTH,y)) >=0)&&(temp<=10)){ // killsprite(0,x,y); x+=DUDESPEED; } left=0; //putsprite(dude, x, y); break; case 'a': if( ( (temp=get_pix(x-1,y+(HIGHT-1))) >=0)&&(temp<=10) ) if( ( (temp=get_pix(x-1,y)) >=0)&&(temp<=10) ){ //killsprite(0,x,y); x-=DUDESPEED; } left=1; //putsprite(dudel, x, y); break; case 'w': if(jump==0) jump=24; break; case 't': y=0; break; case 'p': pause=1; break; case 'q': quit=1; } keyme=0; while(pause){ putmsg(font,"pAuSE",280,199-HIGHT); if(kbhit()){ pause=0; putmsg(font," ",280,199-HIGHT);} } /* Jumping */ if((jump!=0)&&(fall==0)) if( (get_pix(x,y-1)==0)&&(get_pix(x+WIDTH-1,y-1)==0)){ if(jump_delay==0){ //killsprite(0,x,y); y-=1; //if(left) putsprite(dudel, x, y); //else putsprite(dude, x, y); jump_delay=2*eatCPU; jump--; } // else ;//jump_delay--; } else jump=0; else jump=0; /* Falling */ if(jump==0) if( (get_pix(x,y+HIGHT)==0)&&(get_pix(x+WIDTH-1,y+HIGHT)==0)){ fall=1; if(fall_delay==0){ //killsprite(0,x,y); y+=1; //if(left) putsprite(dudel, x, y); //else putsprite(dude, x, y); fall_delay=1*eatCPU; } // else fall_delay--; } else{ fall_delay=0; fall=0;} /* Machines */ for(i=0;i<MACIDS;i++){ if(acids[i][0]>=0){ dead=acid(acidc,acidc1,&acids[i][0],&acids[i][1],acids[i][2],acids[i][3],x,y); if(dead) i=MACIDS; } } if(!dead) for(i=0;i<MSPIKE;i++){ if(dspikes[i][0]>=0){ dead=dspikef(dspike,dspike1,&dspikes[i][0],&dspikes[i][1],dspikes[i][2],dspikes[i][3],x,y); if(dead) i=MSPIKE; } } if(!dead) for(i=0;i<MFATH;i++){ if(fathos[i][0]>=0){ dead=fathf(fath,fath1,&fathos[i][0],&fathos[i][1],fathos[i][2],fathos[i][3],x,y); if(dead) i=MFATH; } } if(!dead) for(i=0;i<MYIPI;i++){ if(yipis[i][0]>=0){ dead=yipif(yipi,yipi1,&yipis[i][0],&yipis[i][1],&yipis[i][2],&yipis[i][3],x,y); if(dead) i=MYIPI; } } if(!dead) dead=dinof(dinoc,dinoc1,&dinod,&dinos,231,48,x,y); if(dead){ switch(dead){ case 1 : dd[0]=(char *)dudead; dd[1]=(char *)dudead1; dd[2]=(char *)dudead2; j=0; break; case 42: dd[0]=(char *)dudeb; dd[1]=(char *)dudeb1; dd[2]=(char *)dudeb2; j=10; putmsg(font,"80s Era appropriate ending. Cigarettes kill." ,0,100-HIGHT); break; default : dd[0]=(char *)dudead; dd[1]=(char *)dudead1; dd[2]=(char *)dudead2; j=0; } for(;j>=0;j--) for(i=0;i<3;) if(dead_delay==0){ killsprite(0,oldx,oldy); putblock(dd[i], oldx, oldy); dead_delay=5*eatCPU; i++; } dead_delay=6*eatCPU; while(dead_delay); dead_delay=0; dead=0; killsprite(0,oldx,oldy); x=mx; y=my; } if((x!=oldx)||(y!=oldy)){ if(jump||fall){ killsprite(0,oldx,oldy); if(left) putsprite(dudelj, x, y); else putsprite(dudej, x, y); } else{ if(x!=oldx) if(mdelay==0){ mdelay=2*eatCPU; if(ms){ ms=0;} else { ms=1;} } else { mdelay-=1; } killsprite(0,oldx,oldy); if(ms){ if(left) putsprite(dudel, x, y); else putsprite(dude, x, y); } else{ if(left) putsprite(dudel1, x, y); else putsprite(dude1, x, y); } } } }while(!quit); normpit(); setvect(INTR, oldhandler); kbdnormal(); showpallete(); return 0; }
DumbGame_Source here is the DG engine full source code for anyone curious.
I hope someone out here finds this interesting, possibly even informative. Until next time and may you always be IDKFA!