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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#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,®,®); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 |
#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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |