| 1 |
|
| 2 |
#include "params.h" |
| 3 |
|
| 4 |
#include "loader_api.h" |
| 5 |
|
| 6 |
|
| 7 |
#define assert(expression) if (!(expression)) { Panic(); } |
| 8 |
|
| 9 |
// Irq |
| 10 |
extern void System_InstallIRQ_SimpleVbl(); |
| 11 |
extern void System_RestoreIRQ_SimpleVbl(); |
| 12 |
extern void WaitIRQ(); |
| 13 |
extern void Panic(); // Stop the program while blinking the bottom right corner with psychedelic colors |
| 14 |
|
| 15 |
extern unsigned char VblCounter; |
| 16 |
|
| 17 |
// Keyboard |
| 18 |
extern char WaitKey(); |
| 19 |
extern char ReadKey(); |
| 20 |
extern char ReadKeyNoBounce(); |
| 21 |
|
| 22 |
extern unsigned char KeyBank[8]; // .dsb 8 ; The virtual Key Matrix |
| 23 |
|
| 24 |
|
| 25 |
// Display |
| 26 |
extern void PrintFancyFont(); |
| 27 |
extern void DrawFilledRectangle(); |
| 28 |
extern void DrawVerticalLine(); |
| 29 |
extern void DrawHorizontalLine(); |
| 30 |
extern void BlitRectangle(); |
| 31 |
|
| 32 |
extern unsigned char ImageBuffer[]; // 240x128 compositing buffer, used to mix together the scene image, frame, arrows, etc... |
| 33 |
extern unsigned char SecondImageBuffer[]; // Second 240x128 buffer |
| 34 |
extern char gFlagDirections; // Bit flag containing all the possible directions for the current scene (used to draw the arrows on the scene) |
| 35 |
extern char gSevenDigitDisplay[]; // Bitmap to redefine a few characters so they look like an old style watch drawn with LED or LCD segments |
| 36 |
extern char gFont12x14[]; // The 12x14 italics font |
| 37 |
extern unsigned char gFont12x14Width[]; // Width (in pixel) of each of the characters in the fancy font |
| 38 |
extern unsigned char gTableModulo6[]; // Given a X value, returns the value modulo 6 (used to access the proper pixel in a graphical block) |
| 39 |
extern unsigned char gTableDivBy6[]; // Given a X value, returns the value divided by 6 (used to locate the proper byte in a scanline) |
| 40 |
extern unsigned char gTableMulBy40Low[]; // Given a x value, returns the low byte of the value multiplied by 40 (used to locate the proper scanline) |
| 41 |
extern unsigned char gTableMulBy40High[]; // Given a x value, returns the high byte of the value multiplied by 40 (used to locate the proper scanline) |
| 42 |
extern unsigned char gShiftBuffer[]; // Used to display graphics at any arbitrary position instead of on multiples of 6 |
| 43 |
extern unsigned char gBitPixelMask[]; // Bitmap with each possible combination of pixel to mask to draw a vertical line |
| 44 |
extern unsigned char gBitPixelMaskLeft[]; // Bitmap with each possible left endings - used to draw horizontal segments |
| 45 |
extern unsigned char gBitPixelMaskRight[]; // Bitmap with each possible right endings - used to draw horizontal segments |
| 46 |
|
| 47 |
extern unsigned char* gDrawAddress; |
| 48 |
extern unsigned char* gDrawSourceAddress; |
| 49 |
extern unsigned char* gDrawPatternAddress; |
| 50 |
extern const char* gDrawExtraData; |
| 51 |
extern unsigned char gDrawPosX; |
| 52 |
extern unsigned char gDrawPosY; |
| 53 |
extern unsigned char gDrawWidth; |
| 54 |
extern unsigned char gDrawHeight; |
| 55 |
extern unsigned char gDrawPattern; |
| 56 |
extern unsigned char gSourceStride; |
| 57 |
|
| 58 |
extern unsigned char gFlagCurrentSpriteSheet; // Index of the currently loaded "sprite" image |
| 59 |
|
| 60 |
// Audio |
| 61 |
extern void PlaySound(const char* registerList); |
| 62 |
|
| 63 |
extern const char* SoundDataPointer; |
| 64 |
extern unsigned char PsgPlayPosition; |
| 65 |
extern unsigned char PsgPlayLoopIndex; |
| 66 |
|
| 67 |
extern char PsgNeedUpdate; |
| 68 |
extern char PsgVirtualRegisters[]; |
| 69 |
extern char ExplodeData[]; |
| 70 |
extern char ShootData[]; |
| 71 |
extern char PingData[]; |
| 72 |
extern char ZapData[]; |
| 73 |
extern char KeyClickHData[]; |
| 74 |
extern char KeyClickLData[]; |
| 75 |
extern char TypeWriterData[]; |
| 76 |
extern char SpaceBarData[]; |
| 77 |
|
| 78 |
// Common |
| 79 |
extern void SetLineAddress(char* address); |
| 80 |
extern void PrintLine(const char* message); |
| 81 |
extern void PrintMultiLine(const char* message); |
| 82 |
extern void PrintWord(const char* message); |
| 83 |
|
| 84 |
extern void Text(char paperColor,char inkColor); |
| 85 |
extern void Hires(char paperColor,char inkColor); |
| 86 |
extern void WaitFrames(int frames); |
| 87 |
|
| 88 |
extern char gIsHires; |
| 89 |
extern char* gPrintAddress; |
| 90 |
|
| 91 |
|
| 92 |
// game_misc |
| 93 |
extern void HandleByteStream(); |
| 94 |
extern void SetByteStream(const char* byteStream); |
| 95 |
extern void PlayStream(const char* byteStream); |
| 96 |
|
| 97 |
extern const char* gCurrentStream; |
| 98 |
extern const unsigned int* gCurrentStreamInt; |
| 99 |
extern char gCurrentStreamStop; |
| 100 |
extern unsigned int gDelayStream; |
| 101 |
|
| 102 |
|
| 103 |
// game_text |
| 104 |
extern char gDescriptionTeenagerRoom[]; |
| 105 |
extern char gDescriptionDarkTunel[]; |
| 106 |
extern char gDescriptionMarketPlace[]; |
| 107 |
extern char gDescriptionDarkAlley[]; |
| 108 |
extern char gDescriptionRoad[]; |
| 109 |
extern char gDescriptionMainStreet[]; |
| 110 |
extern char gDescriptionNarrowPath[]; |
| 111 |
extern char gDescriptionInThePit[]; |
| 112 |
extern char gDescriptionTarmacArea[]; |
| 113 |
extern char gDescriptionOldWell[]; |
| 114 |
extern char gDescriptionWoodedAvenue[]; |
| 115 |
extern char gDescriptionGravelDrive[]; |
| 116 |
extern char gDescriptionZenGarden[]; |
| 117 |
extern char gDescriptionFrontLawn[]; |
| 118 |
extern char gDescriptionGreenHouse[]; |
| 119 |
extern char gDescriptionTennisCourt[]; |
| 120 |
extern char gDescriptionVegetableGarden[]; |
| 121 |
extern char gDescriptionFishPond[]; |
| 122 |
extern char gDescriptionTiledPatio[]; |
| 123 |
extern char gDescriptionAppleOrchard[]; |
| 124 |
extern char gDescriptionEntranceHall[]; |
| 125 |
extern char gDescriptionLibrary[]; |
| 126 |
extern char gDescriptionNarrowPassage[]; |
| 127 |
extern char gDescriptionEntranceLounge[]; |
| 128 |
extern char gDescriptionDiningRoom[]; |
| 129 |
extern char gDescriptionGamesRoom[]; |
| 130 |
extern char gDescriptionSunLounge[]; |
| 131 |
extern char gDescriptionKitchen[]; |
| 132 |
extern char gDescriptionNarrowStaircase[]; |
| 133 |
extern char gDescriptionCellar[]; |
| 134 |
extern char gDescriptionDarkerCellar[]; |
| 135 |
extern char gDescriptionStaircase[]; |
| 136 |
extern char gDescriptionMainLanding[]; |
| 137 |
extern char gDescriptionEastGallery[]; |
| 138 |
extern char gDescriptionChildBedroom[]; |
| 139 |
extern char gDescriptionGuestBedroom[]; |
| 140 |
extern char gDescriptionShowerRoom[]; |
| 141 |
extern char gDescriptionWestGallery[]; |
| 142 |
extern char gDescriptionBoxRoom[]; |
| 143 |
extern char gDescriptionClassyBathRoom[]; |
| 144 |
extern char gDescriptionTinyToilet[]; |
| 145 |
extern char gDescriptionMasterBedRoom[]; |
| 146 |
extern char gDescriptionPadlockedRoom[]; |
| 147 |
extern char gDescriptionOutsidePit[]; |
| 148 |
// |
| 149 |
extern char gDescriptionDogAttacking[]; |
| 150 |
extern char gDescriptionThugAttacking[]; |
| 151 |
extern char gDescriptionGameOverLost[]; |
| 152 |
|
| 153 |
/* |
| 154 |
; |
| 155 |
; Data generator for the high scores |
| 156 |
; |
| 157 |
; Each entry occupies 19 bytes: |
| 158 |
; 2 bytes for the score (+32768) |
| 159 |
; 1 byte for the game ending condition |
| 160 |
; 16 bytes for the name (padded with spaces) |
| 161 |
;------------------------------------------- |
| 162 |
; 19 bytes per entry * 24 entries = 456 bytes total |
| 163 |
; |
| 164 |
#define ENTRY(type,score,name) .word (score+32768) : .byt type : .asc name |
| 165 |
*/ |
| 166 |
#define SCORE_COUNT 24 |
| 167 |
|
| 168 |
enum SCORE_CONDITION |
| 169 |
{ |
| 170 |
e_SCORE_UNNITIALIZED = 0, |
| 171 |
e_SCORE_SOLVED_THE_CASE = 1, |
| 172 |
e_SCORE_MAIMED_BY_DOG = 2, |
| 173 |
e_SCORE_SHOT_BY_THUG = 3, |
| 174 |
e_SCORE_FELL_INTO_PIT = 4, |
| 175 |
e_SCORE_TRIPPED_ALARM = 5, |
| 176 |
e_SCORE_RAN_OUT_OF_TIME = 6, |
| 177 |
e_SCORE_BLOWN_INTO_BITS = 7, |
| 178 |
e_SCORE_SIMPLY_VANISHED = 8, |
| 179 |
e_SCORE_GAVE_UP = 9 |
| 180 |
}; |
| 181 |
|
| 182 |
typedef struct |
| 183 |
{ |
| 184 |
int score; // The score can actually be negative if the player is doing stupid things on purpose (plus or minus 32768 because of assembler reasons) |
| 185 |
unsigned char condition; // The reason why the game ended (victory, abandon, death, ...) |
| 186 |
unsigned char name[15]; // The name of the character |
| 187 |
} score_entry; |
| 188 |
|
| 189 |
extern score_entry gHighScores[SCORE_COUNT]; |
| 190 |
extern const char* gScoreConditionsArray[]; |