static void PrepMObj(mobj_t *thing) { Fixed Trx,Try,Trz; Word lump; LongWord Offset; vissprite_t *vis; state_t *StatePtr; void **PatchHandle; patch_t *patch; int x1, x2; /* This is a HACK, so I don't draw the player for the 3DO version */ if (thing->player) { /* Don't draw the player */ return; } /* Transform the origin point */ vis = vissprite_p; if (vis == &vissprites[MAXVISSPRITES]) { /* Too many? */ return; /* sprite overload, don't draw it */ } Trx = thing->x - viewx; /* Get the point in 3 Space */ Try = thing->y - viewy; Trz = IMFixMul(Trx,viewcos); /* Rotate around the camera */ Trz += IMFixMul(Try,viewsin); /* Add together */ if (Trz < MINZ) { /* Too large? */ return; /* Exit now */ } Trx = IMFixMul(Trx,viewsin); /* Calc the 3Space x coord */ Trx -= IMFixMul(Try,viewcos); if (Trx > (Trz<<2) || Trx < -(Trz<<2) ) { return; /* Greater than 45 degrees off the side */ } /* Decide which patch to use for sprite relative to player */ StatePtr = thing->state; lump = StatePtr->SpriteFrame>>FF_SPRITESHIFT; /* Get the resource # */ PatchHandle = LoadAResourceHandle(lump); /* Get the sprite group */ patch = (patch_t *)*PatchHandle; /* Deref the handle */ Offset = ((LongWord *)patch)[StatePtr->SpriteFrame & FF_FRAMEMASK]; if (Offset&PT_NOROTATE) { /* Do I rotate? */ angle_t ang; angle_t rot; patch = (patch_t *)&((Byte *)patch)[Offset & 0x3FFFFFFF]; /* Get pointer to rotation list */ ang = PointToAngle(viewx,viewy,thing->x,thing->y); /* Get angle to critter */ ang -= thing->angle; /* Adjust for object's facing */ rot = (ang+(angle_t)((ANG45/2)*9U))>>29; /* Get rotation offset */ Offset = ((LongWord *)patch)[rot]; /* Use the rotated offset */ }
static void LoadBlockMap(Word lump) { Word Count; Word Entries; Byte *MyLumpPtr; void **BlockHandle; LongWord *StartIndex; BlockHandle = LoadAResourceHandle(lump); /* Load the data */ MyLumpPtr = (Byte *)LockAHandle(BlockHandle); BlockMapOrgX = ((Word *)MyLumpPtr)[0]; /* Get the orgx and y */ BlockMapOrgY = ((Word *)MyLumpPtr)[1]; BlockMapWidth = ((Word *)MyLumpPtr)[2]; /* Get the map size */ BlockMapHeight = ((Word *)MyLumpPtr)[3]; Entries = BlockMapWidth*BlockMapHeight; /* How many entries are there? */ /* Convert the loaded block map table into a huge array of block entries */ Count = Entries; /* Init the longword count */ StartIndex = &((LongWord *)MyLumpPtr)[4]; /* Index to the offsets! */ BlockMapLines = (line_t ***)StartIndex; /* Save in global */ do { StartIndex[0] = (LongWord)&MyLumpPtr[StartIndex[0]]; /* Convert to pointer */ ++StartIndex; /* Next offset entry */ } while (--Count); /* All done? */ /* Convert the lists appended to the array into pointers to lines */ Count = GetAHandleSize(BlockHandle)/4; /* How much memory is needed? (Longs) */ Count -= (Entries+4); /* Remove the header count */ do { if (StartIndex[0]!=-1) { /* End of a list? */ StartIndex[0] = (LongWord)&lines[StartIndex[0]]; /* Get the line pointer */ } else { StartIndex[0] = 0; /* Insert a null pointer */ } ++StartIndex; /* Next entry */ } while (--Count); /* Clear out mobj chains */ Count = sizeof(*BlockLinkPtr)*Entries; /* Get memory */ BlockLinkPtr = (mobj_t **)AllocAPointer(Count); /* Allocate memory */ memset(BlockLinkPtr,0,Count); /* Clear it out */ }
void G_DoLoadLevel(void) { Word Sky; if (players.playerstate == PST_DEAD) { players.playerstate = PST_REBORN; /* Force rebirth */ } /* Set the sky map for the episode */ if (gamemap < 9 || gamemap==24) { /* First 9 levels? */ Sky = rSKY1; } else if (gamemap < 18) { Sky = rSKY2; } else { Sky = rSKY3; } SkyTexture = &TextureInfo[Sky-FirstTexture]; /* Set pointer to sky texture record */ SkyTexture->data = LoadAResourceHandle(Sky); /* Preload the sky texture */ SetupLevel(gamemap); /* Load the level into memory */ gameaction = ga_nothing; /* Game in progress */ }