Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
The Macintosh Wolfenstein 3D as released.
Browse files Browse the repository at this point in the history
  • Loading branch information
Blzut3 committed Dec 20, 2013
0 parents commit 4ff692c
Show file tree
Hide file tree
Showing 46 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions Burger.c

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Burger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
typedef unsigned int Word;typedef unsigned long LongWord;#ifndef __MACTYPES__typedef unsigned char Byte;typedef unsigned char Boolean;#endif#define BLACK 255#define DARKGREY 250#define BROWN 101#define PURPLE 133#define BLUE 210#define DARKGREEN 229#define ORANGE 23#define RED 216#define BEIGE 14#define YELLOW 5#define GREEN 225#define LIGHTBLUE 150#define LILAC 48#define PERIWINKLE 120#define LIGHTGREY 43#define WHITE 0#define __MAC__#define __BIGENDIAN__#define SfxActive 1#define MusicActive 2#define VideoSize 64000#define SetAuxType(x,y)#define SetFileType(x,y)extern unsigned char *VideoPointer;extern Word KeyModifiers;extern Word ScanCode;extern Word KilledSong;extern Word SystemState;extern Word VideoWidth;extern LongWord LastTick;extern LongWord YTable[480];extern Handle RezHandle;void DLZSS(Byte *Dest, Byte *Src,LongWord Length);void DLZB(Byte *Dest, Byte *Src,LongWord Length);LongWord SwapLong(LongWord Val);unsigned short SwapUShort(unsigned short Val);short SwapShort(short Val);void WaitTick(void);void WaitTicks(Word TickCount);Word WaitTicksEvent(Word TickCount);Word WaitEvent(void);LongWord ReadTick(void);void *AllocSomeMem(LongWord Size);void FreeSomeMem(void *MemPtr);Word GetAKey(void);Word AllKeysUp(void);Word WaitKey(void);void FlushKeys(void);Word FixMacKey(EventRecord *MyRecord);void SoundOff(void);void PlaySound(Word SndNum);void StopSound(Word SndNum);void PlaySong(Word SongNum);void ClearTheScreen(Word Color);void ShowPic(Word PicNum);void InitYTable(void);void InstallAFont(Word FontNum);void FontUseMask(void);void FontUseZero(void);void SetFontXY(Word x,Word y);void FontSetColor(Word Index,Word Color);void DrawAString(char *TextPtr);void DrawAChar(Word Letter);void ultoa(LongWord Val,char *TextPtr);Word GetRandom(Word Range);void Randomize(void);void DrawShape(Word x,Word y,void *ShapePtr);void DrawXMShape(Word x,Word y,void *ShapePtr);void DrawMShape(Word x,Word y,void *ShapePtr);void EraseMBShape(Word x,Word y, void *ShapePtr,void *BackPtr);Word TestMShape(Word x,Word y,void *ShapePtr);Word TestMBShape(Word x,Word y,void *ShapePtr,void *BackPtr);void SetAPalette(Word PalNum);void SetAPalettePtr(unsigned char *PalPtr);void FadeTo(Word PalNum);void FadeToBlack(void);void FadeToPtr(unsigned char *PalPtr);void *LoadAResource(Word RezNum);void ReleaseAResource(Word RezNum);void KillAResource(Word RezNum);void *LoadAResource2(Word RezNum,LongWord Type);void ReleaseAResource2(Word RezNum,LongWord Type);void KillAResource2(Word RezNum,LongWord Type);void SaveJunk(void *AckPtr,Word Length);
Expand Down
1 change: 1 addition & 0 deletions Data.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "wolfdef.h"/********************************** Global data used by Wolfenstein 3-D **********************************/Word tilemap[MAPSIZE][MAPSIZE]; /* Main tile map */Word ConnectCount; /* Number of valid interconnects */connect_t areaconnect[MAXDOORS]; /* Is this area mated with another? */Boolean areabyplayer[MAXAREAS]; /* Which areas can I see into? */Word numstatics; /* Number of active static objects */static_t statics[MAXSTATICS]; /* Data for the static items */Word numdoors; /* Number of active door objects */door_t doors[MAXDOORS]; /* Data for the door items */Word nummissiles; /* Number of active missiles */missile_t missiles[MAXMISSILES]; /* Data for the missile items */Word numactors; /* Number of active actors */actor_t actors[MAXACTORS]; /* Data for the actors */unsigned char **GameShapes; /* Pointer to the game shape array */Word difficulty; /* 0 = easy, 1= normal, 2=hard*/gametype_t gamestate; /* Status of the game (Save game) */exit_t playstate; /* Current status of the game */Word killx,killy; /* X,Y of the thing that killed you! */Boolean madenoise; /* True when shooting or screaming*/Boolean playermoving; /* Is the player in motion? */Boolean useheld; /* Holding down the use key? */Boolean selectheld; /* Weapon select held down? */Boolean attackheld; /* Attack button held down? */Boolean buttonstate[NUMBUTTONS]; /* Current input */Word joystick1; /* Joystick value */int mousex; /* Mouse x movement */int mousey; /* Mouse y movement */int mouseturn; /* Mouse turn movement */Word nextmap; /* Next map to warp to */Word facecount; /* Time to show a specific head */Word faceframe; /* Head pic to show */Word elevatorx,elevatory; /* x,y of the elevator */Word firstframe; /* if non 0, the screen is still faded out */Word OldMapNum; /* Currently loaded map # */loadmap_t *MapPtr; /* Pointer to current loaded map */int clipshortangle; /* Angle for the left edge of the screen */int clipshortangle2; /* clipshortangle * 2 */Word viewx; /* X coord of camera */Word viewy; /* Y coord of camera */fixed_t viewsin; /* Base sine for viewing angle */fixed_t viewcos; /* Base cosine for viewing angle */Word normalangle; /* Normalized angle for view (NSEW) */Word centerangle; /* viewangle in fineangles*/Word centershort; /* viewangle in 64k angles*/Word topspritescale; /* Scale of topmost sprite */Word topspritenum; /* Shape of topmost sprite */Word xscale[1024]; /* Scale factor for width of the screen */Word numvisspr; /* Number of valid visible sprites */vissprite_t vissprites[MAXVISSPRITES]; /* Buffer for sprite records */Word xevents[MAXVISSPRITES]; /* Scale events for sprite sort */Word sortbuffer[MAXVISSPRITES]; /* mergesort requires an extra buffer*/Word *firstevent; /* First event in sorted list */Boolean areavis[MAXAREAS]; /* Area visible */Word bspcoord[4]; /* Rect for the BSP search */Word TicCount; /* Ticks since last screen draw */Word LastTicCount; /* Tick value at start of render */Boolean IntermissionHack; /* Hack for preventing double score drawing during intermission */Word rw_maxtex;Word rw_mintex;LongWord rw_scalestep;Word rw_midpoint;Boolean rw_downside;int rw_centerangle;Byte *rw_texture;LongWord rw_scale;Byte *ArtData[64];void *SpriteArray[S_LASTONE];Word MacVidSize = -1;Word SlowDown = 1; /* Force the game to 15 hz */Word MouseEnabled = 0; /* Allow mouse control */Word GameViewSize = 0; /* Size of the game screen */Word NoWeaponDraw=1; /* Flag to not draw the weapon on the screen */maplist_t *MapListPtr; /* Pointer to map info record */unsigned short *SongListPtr; /* Pointer to song list record */unsigned short *WallListPtr; /* Pointer to wall list record */Word MaxScaler = 1; /* Maximum number of VALID scalers */Boolean ShowPush; /* Cheat for pushwalls */Byte textures[MAPSIZE*2+5][MAPSIZE]; /* Texture indexes */Word NaziSound[] = {SND_ESEE,SND_ESEE2,SND_ESEE3,SND_ESEE4};classinfo_t classinfo[] = { /* Info for all the bad guys */ {SND_ESEE,SND_EDIE, /* Nazi */ ST_GRD_WLK1, ST_GRD_STND, ST_GRD_ATK1,ST_GRD_PAIN,ST_GRD_DIE, 100, 5, 0x0F, 6}, {SND_ESEE,SND_EDIE, /* Blue guard */ ST_OFC_WLK1, ST_OFC_STND, ST_OFC_ATK1,ST_OFC_PAIN,ST_OFC_DIE, 400, 10, 0x01, 12}, {SND_ESEE,SND_EDIE, /* White officer */ ST_SS_WLK1, ST_SS_STND, ST_SS_ATK1,ST_SS_PAIN,ST_SS_DIE, 500, 6, 0x07, 25}, {SND_DOGBARK,SND_DOGDIE, /* Dog */ ST_DOG_WLK1,ST_DOG_STND,ST_DOG_ATK1,ST_DOG_WLK1,ST_DOG_DIE, 200, 9, 0x07, 1}, {SND_NOSOUND,SND_EDIE, /* Mutant */ ST_MUTANT_WLK1, ST_MUTANT_STND, ST_MUTANT_ATK1,ST_MUTANT_PAIN,ST_MUTANT_DIE, 400, 7, 0x01, 18}, {SND_GUTEN,SND_EDIE, /* Hans */ ST_HANS_WLK1, ST_HANS_STND, ST_HANS_ATK1,ST_GRD_STND,ST_HANS_DIE, 5000,7, 0x01, 250}, {SND_SHITHEAD,SND_EDIE, /* Dr. Schabbs */ ST_SCHABBS_WLK1, ST_SCHABBS_STND, ST_SCHABBS_ATK1,ST_GRD_STND,ST_SCHABBS_DIE, 5000, 5,0x01, 350}, {SND_GUTEN,SND_EDIE, /* Trans */ ST_TRANS_WLK1, ST_TRANS_STND, ST_TRANS_ATK1,ST_GRD_STND,ST_TRANS_DIE, 5000, 7,0x01, 300}, {SND_DOGBARK,SND_EDIE, /* Uber knight */ ST_UBER_WLK1, ST_UBER_STND, ST_UBER_ATK1,ST_GRD_STND,ST_UBER_DIE, 5000, 8,0x01, 400}, {SND_COMEHERE,SND_EDIE, /* Dark knight */ ST_DKNIGHT_WLK1, ST_DKNIGHT_STND, ST_DKNIGHT_ATK1,ST_GRD_STND,ST_DKNIGHT_DIE, 5000, 7,0x01, 450}, {SND_SHIT,SND_EDIE, /* Mechahitler */ ST_MHITLER_WLK1, ST_MHITLER_STND, ST_MHITLER_ATK1,ST_GRD_STND, ST_HITLER_DIE, 5000, 7,0x01, 500}, {SND_HITLERSEE,SND_EDIE, /* Hitler */ ST_HITLER_WLK1, ST_MHITLER_STND, ST_HITLER_ATK1,ST_GRD_STND,ST_HITLER_DIE, 5000, 8,0x01, 500},};
Expand Down
1 change: 1 addition & 0 deletions Doors.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "Wolfdef.h"#include <string.h>/********************************** Rules for door operationdoor->position holds the amount the door is open, ranging from 0 to TILEGLOBAL-1The number of doors is limited to 64 because various fields are only 6 bitsOpen doors conect two areas, so sounds will travel between them and sight will be checked when the player is in a connected area.areaconnect has a list of connected area #'s, used to create the table areabyplayerEvery time a door opens or closes the areabyplayer matrix gets recalculated. An area is True if it connects with the player's current spor.**********************************//********************************** Insert a connection between two rooms Note: I can have MORE than one connection between rooms so it is VALID to have duplicate entries (1,6) & (1,6) Each call to AddConnection must be balanced with a call to RemoveConnection **********************************/void AddConnection(Word Area1,Word Area2){ connect_t *DestPtr; DestPtr = &areaconnect[ConnectCount]; /* Make pointer to the last record */ DestPtr->Area1 = Area1; /* Init the struct */ DestPtr->Area2 = Area2; ++ConnectCount; /* Add 1 to the valid list */}/********************************** Remove a connection between two rooms Note: I can have MORE than one connection between rooms so it is VALID to have duplicate entries (1,6) & (1,6) **********************************/void RemoveConnection(Word Area1,Word Area2){ Word i; connect_t *DestPtr; DestPtr = &areaconnect[0]; /* Init the scan pointer */ i = ConnectCount; /* Init the count */ if (!i) { return; } do { if (DestPtr->Area1 == Area1 && /* Match? */ DestPtr->Area2 == Area2) { --ConnectCount; /* Remove the count */ DestPtr[0] = areaconnect[ConnectCount]; /* Copy last to current */ break; /* I'm done! */ } ++DestPtr; /* Next entry to scan */ } while (--i); /* Should NEVER fall out! */}/********************************** Recursive routine to properly set the areabyplayer array by using the contents of the areaconnect array. Scans outward from playerarea, marking all connected areas. **********************************/void RecursiveConnect(Word areanumber){ Word i; Word j; connect_t *AreaPtr; areabyplayer[areanumber] = TRUE; /* Mark this spot (Prevent overflow) */ i = ConnectCount; /* Init index */ if (i) { /* No doors available? */ AreaPtr = &areaconnect[0]; /* Get a local pointer */ do { if (AreaPtr->Area1 == areanumber) { /* Am I in this pair? */ j = AreaPtr->Area2; /* Follow this path */ goto TryIt; } if (AreaPtr->Area2 == areanumber) { /* The other side? */ j = AreaPtr->Area1; /* Follow this side */TryIt: if (!areabyplayer[j]) { /* Already been here? */ RecursiveConnect(j); /* Link it in... */ } } ++AreaPtr; /* Next entry */ } while (--i); /* All done? */ }}/********************************** Properly set the areabyplayer record **********************************/void ConnectAreas(void){ memset(areabyplayer,0,sizeof(areabyplayer)); /* Zap the memory */ RecursiveConnect(MapPtr->areasoundnum[actors[0].areanumber]); /* Start here */}/********************************** Start a door opening **********************************/void OpenDoor(door_t *door){ if (door->action == DR_OPEN) { /* Already open? */ door->ticcount = 0; /* Reset open time (Keep open) */ } else { door->action = DR_OPENING; /* start it opening*/ } /* The door will be made passable when it is totally open */}/********************************** Start a door closing **********************************/void CloseDoor(door_t *door){ Word tile,tilex,tiley; Word *TilePtr; int delta;/* don't close on anything solid */ tilex = door->tilex; /* Get the current tile */ tiley = door->tiley; TilePtr = &tilemap[tiley][tilex]; /* Get pointer to tile map */ if (door->action != DR_OPENING) { /* In the middle of opening? */ /* don't close on an actor or bonus item */ tile = TilePtr[0]; /* What's the tile? */ if (tile & TI_BODY) { door->action = DR_WEDGEDOPEN; /* bodies never go away */ return; } if (tile & (TI_ACTOR | TI_GETABLE) ) { /* Removable? */ door->ticcount = 60; /* wait a while before trying to close again */ return; } /* Don't close on the player */ delta = actors[0].x - ((tilex<<8)|0x80); if (w_abs(delta) <= (0x82+PLAYERSIZE)) { delta = actors[0].y - ((tiley<<8)|0x80); if (w_abs(delta) <= (0x82+PLAYERSIZE)) { return; /* It's touching the player! */ } } } door->action = DR_CLOSING; /* Close the door */ TilePtr[0] |= (TI_BLOCKMOVE|TI_BLOCKSIGHT); /* make the door space a solid tile*/}/********************************** Open or Close a door (Press space at a door) **********************************/void OperateDoor(Word dooron){ Word type; door_t *door; door = &doors[dooron]; /* Which door? */ type = door->info>>1; /* Get the door type */ if ( (type==1 && !(gamestate.keys&1)) || (type==2 && !(gamestate.keys&2)) ) { PlaySound(SND_LOCKEDDOOR); /* The door is locked */ return; } switch (door->action) { case DR_CLOSED: case DR_CLOSING: OpenDoor(door); /* Open the door */ break; case DR_OPEN: case DR_OPENING: CloseDoor(door); /* Close the door */ }}/********************************** Close the door after a few seconds **********************************/void DoorOpen(door_t *door){ door->ticcount+=TicCount; /* Inc the tic value */ if (door->ticcount >= OPENTICS) { /* Time up? */ door->ticcount = OPENTICS-1; /* So if the door can't close it will keep trying*/ CloseDoor(door); /* Try to close the door */ }}/********************************** Step the door animation for open, mark as DR_OPEN if all the way open **********************************/void DoorOpening(door_t *door){ Word position; Word area1,area2; Byte *SoundNumPtr; position = door->position; /* Get the pixel position */ if (!position) { /* Fully closed? */ /* door is just starting to open, so connect the areas*/ SoundNumPtr = MapPtr->areasoundnum; area1 = SoundNumPtr[door->area1]; area2 = SoundNumPtr[door->area2]; AddConnection(area1,area2); /* Link the two together */ ConnectAreas(); /* Link the map */ if (areabyplayer[area1] || areabyplayer[area2]) { /* Can I hear it? */ PlaySound(SND_OPENDOOR); /* Play the door sound */ } }/* slide the door open a bit */ position += DOORSPEED*TicCount; /* Move the door a bit */ if (position >= TILEGLOBAL-1) { /* Fully open? */ /* Door is all the way open */ position = TILEGLOBAL-1; /* Set to maximum */ door->ticcount = 0; /* Reset the timer for closing */ door->action = DR_OPEN; /* Mark as open */ tilemap[door->tiley][door->tilex] &= ~(TI_BLOCKMOVE|TI_BLOCKSIGHT); /* Mark as enterable */ } door->position = position; /* Set the new position */}/********************************** Step the door animation for close, mark as DR_CLOSED if all the way closed **********************************/void DoorClosing(door_t *door){ int position; Byte *SoundNumPtr; position = door->position-(DOORSPEED*TicCount); /* Close a little more */ if (position <= 0) { /* Will I close now? */ /* door is closed all the way, so disconnect the areas*/ SoundNumPtr = MapPtr->areasoundnum; /* Unlink the sound areas */ RemoveConnection(SoundNumPtr[door->area1],SoundNumPtr[door->area2]); ConnectAreas(); /* Reset areabyplayer */ door->action = DR_CLOSED; /* It's closed */ position = 0; /* Mark as closed */ } door->position = position; /* Set the new position */}/********************************** Process all the doors each game loop **********************************/void MoveDoors(void){ Word dooron; /* Which door am I on? */ door_t *door; /* Pointer to current door */ dooron = numdoors; /* How many doors to scan? */ if (dooron) { /* Any doors at all? */ door = doors; /* Pointer to the first door */ do { switch (door->action) { /* Call the action code */ case DR_OPEN: DoorOpen(door); /* Check to close the door */ break; case DR_OPENING: /* Continue the door opening */ DoorOpening(door); break; case DR_CLOSING: /* Close the door */ DoorClosing(door); } ++door; /* Next pointer */ } while (--dooron); /* All doors done? */ }}
Expand Down
Loading

0 comments on commit 4ff692c

Please sign in to comment.