Mail has been fixed; you should now be able to confirm your e-mail address, watch pages, and the like.
Please report any issues on Discord.

Wayne Gretzky's 3D Hockey '98 (Nintendo 64)/Uncompiled Source Code

From The Cutting Room Floor
Jump to navigation Jump to search

This is a sub-page of Wayne Gretzky's 3D Hockey '98 (Nintendo 64).

In another unusual instance of loads of C code making its way into an N64 game, this game has a bunch of code for all sorts of things. This is primarily for the headers, so much of this is just setting up structures and establishing function prototypes. It begins at 0x7E1000 in the US ROM.

d     *soundArray[1];
} ALInstrument;

typedef struct ALBank_s {
    s16                 instCount;       
    u8                  flags;
    u8                  pad;
    s32                 sampleRate;      
    ALInstrument        *percussion;     
    ALInstrument        *instArray[1];   
} ALBank;

typedef struct {                 
    s16         revision;        
    s16         bankCount;       
    ALBank      *bankArray[1];   
} ALBankFile;

void    alBnkfNew(ALBankFile *f, u8 *table);

 




typedef struct {
    u8          *offset;
    s32         len;
} ALSeqData;

typedef struct {                 
    s16         revision;        
    s16         seqCount;        
    ALSeqData   seqArray[1];     
} ALSeqFile;

void    alSeqFileNew(ALSeqFile *f, u8 *base);

 


typedef ALMicroTime (*ALVoiceHandler)(void *);

typedef struct {
    s32                 maxVVoices;      
    s32                 maxPVoices;
    s32                 maxUpdates;
    s32                 maxFXbusses;
    void                *dmaproc;
    ALHeap              *heap;
    s32                 outputRate;      
    ALFxId              fxType;
    s32                 *params;
} ALSynConfig;

typedef struct ALPlayer_s {
    struct ALPlayer_s   *next;
    void                *clientData;     
    ALVoiceHandler      handler;         
    ALMicroTime         callTime;        
    s32                 samplesLeft;     
} ALPlayer;

typedef struct ALVoice_s {
    ALLink              node;
    struct PVoice_s     *pvoice;
    ALWaveTable         *table;
    void                *clientPrivate;
    s16                 state;
    s16                 priority;
    s16                 fxBus;
    s16                 unityPitch;
} ALVoice;

typedef struct ALVoiceConfig_s {
    s16                 priority;        
    s16                 fxBus;           
    u8                  unityPitch;      
} ALVoiceConfig;

typedef struct {
    ALPlayer    *head;           
    ALLink      pFreeList;       
    ALLink      pAllocList;      
    ALLink      pLameList;       
    s32         paramSamples;
    s32         curSamples;      
    ALDMANew    dma;
    ALHeap      *heap;
    
    struct ALParam_s    *paramList;
    
    struct ALMainBus_s  *mainBus;
    struct ALAuxBus_s   *auxBus;         
    struct ALFilter_s   *outputFilter;   

    s32                 numPVoices;
    s32                 maxAuxBusses;
    s32                 outputRate;      
    s32                 maxOutSamples;   

} ALSynth;

void    alSynNew(ALSynth *s, ALSynConfig *config);
void    alSynDelete(ALSynth *s);

void    alSynAddPlayer(ALSynth *s, ALPlayer *client);
void    alSynRemovePlayer(ALSynth *s, ALPlayer *client);

s32     alSynAllocVoice(ALSynth *s, ALVoice *v, ALVoiceConfig *vc);
void    alSynFreeVoice(ALSynth *s, ALVoice *voice);

void    alSynStartVoice(ALSynth *s, ALVoice *voice, ALWaveTable *w);
void    alSynStartVoiceParams(ALSynth *s, ALVoice *voice, ALWaveTable *w,
                              f32 pitch, s16 vol, ALPan pan, u8 fxmix,
                              ALMicroTime t);
void    alSynStopVoice(ALSynth *s, ALVoice *voice);

void    alSynSetVol(ALSynth *s, ALVoice *v, s16 vol, ALMicroTime delta);
void    alSynSetPitch(ALSynth *s, ALVoice *voice, f32 ratio);
void    alSynSetPan(ALSynth *s, ALVoice *voice, ALPan pan);
void    alSynSetFXMix(ALSynth *s, ALVoice *voice, u8 fxmix);
void    alSynSetPriority(ALSynth *s, ALVoice *voice, s16 priority);
s16     alSynGetPriority(ALSynth *s, ALVoice *voice);

ALFxRef *alSynAllocFX(ALSynth *s, s16 bus, ALSynConfig *c, ALHeap *hp);
ALFxRef alSynGetFXRef(ALSynth *s, s16 bus, s16 index);
void    alSynFreeFX(ALSynth *s, ALFxRef *fx);
void    alSynSetFXParam(ALSynth *s, ALFxRef fx, s16 paramID, void *param);

 


typedef struct {
    ALSynth     drvr;
} ALGlobals;

extern ALGlobals *alGlobals;

void    alInit(ALGlobals *glob, ALSynConfig *c);
void    alClose(ALGlobals *glob);

Acmd    *alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen);

 



 










 


enum ALMsg {
    AL_SEQ_REF_EVT,	 
    AL_SEQ_MIDI_EVT,
    AL_SEQP_MIDI_EVT,
    AL_TEMPO_EVT,
    AL_SEQ_END_EVT,
    AL_NOTE_END_EVT,
    AL_SEQP_ENV_EVT,
    AL_SEQP_META_EVT,
    AL_SEQP_PROG_EVT,
    AL_SEQP_API_EVT,
    AL_SEQP_VOL_EVT,
    AL_SEQP_LOOP_EVT,
    AL_SEQP_PRIORITY_EVT,
    AL_SEQP_SEQ_EVT,
    AL_SEQP_BANK_EVT,
    AL_SEQP_PLAY_EVT,
    AL_SEQP_STOP_EVT,
    AL_SEQP_STOPPING_EVT,
    AL_TRACK_END,
    AL_CSP_LOOPSTART,
    AL_CSP_LOOPEND,
    AL_CSP_NOTEOFF_EVT,
    AL_TREM_OSC_EVT,
    AL_VIB_OSC_EVT
};

 




enum AL_MIDIstatus {
     
    AL_MIDI_ChannelMask         = 0x0F,
    AL_MIDI_StatusMask          = 0xF0,

     
    AL_MIDI_ChannelVoice        = 0x80,
    AL_MIDI_NoteOff             = 0x80,
    AL_MIDI_NoteOn              = 0x90,
    AL_MIDI_PolyKeyPressure     = 0xA0,
    AL_MIDI_ControlChange       = 0xB0,
    AL_MIDI_ChannelModeSelect   = 0xB0,
    AL_MIDI_ProgramChange       = 0xC0,
    AL_MIDI_ChannelPressure     = 0xD0,
    AL_MIDI_PitchBendChange     = 0xE0,

     
    AL_MIDI_SysEx               = 0xF0,  

     
    AL_MIDI_SystemCommon            = 0xF1,
    AL_MIDI_TimeCodeQuarterFrame    = 0xF1,
    AL_MIDI_SongPositionPointer     = 0xF2,
    AL_MIDI_SongSelect              = 0xF3,
    AL_MIDI_Undefined1              = 0xF4,
    AL_MIDI_Undefined2              = 0xF5,
    AL_MIDI_TuneRequest             = 0xF6,
    AL_MIDI_EOX                     = 0xF7,  

     
    AL_MIDI_SystemRealTime  = 0xF8,
    AL_MIDI_TimingClock     = 0xF8,
    AL_MIDI_Undefined3      = 0xF9,
    AL_MIDI_Start           = 0xFA,
    AL_MIDI_Continue        = 0xFB,
    AL_MIDI_Stop            = 0xFC,
    AL_MIDI_Undefined4      = 0xFD,
    AL_MIDI_ActiveSensing   = 0xFE,
    AL_MIDI_SystemReset     = 0xFF,
    AL_MIDI_Meta            = 0xFF       
};

enum AL_MIDIctrl {
    AL_MIDI_VOLUME_CTRL         = 0x07,
    AL_MIDI_PAN_CTRL            = 0x0A,
    AL_MIDI_PRIORITY_CTRL       = 0x10,  
    AL_MIDI_FX_CTRL_0           = 0x14,
    AL_MIDI_FX_CTRL_1           = 0x15,
    AL_MIDI_FX_CTRL_2           = 0x16,
    AL_MIDI_FX_CTRL_3           = 0x17,
    AL_MIDI_FX_CTRL_4           = 0x18,
    AL_MIDI_FX_CTRL_5           = 0x19,
    AL_MIDI_FX_CTRL_6           = 0x1A,
    AL_MIDI_FX_CTRL_7           = 0x1B,
    AL_MIDI_FX_CTRL_8           = 0x1C,
    AL_MIDI_FX_CTRL_9           = 0x1D,
    AL_MIDI_SUSTAIN_CTRL        = 0x40,
    AL_MIDI_FX1_CTRL            = 0x5B,
    AL_MIDI_FX3_CTRL            = 0x5D
};

enum AL_MIDImeta {
    AL_MIDI_META_TEMPO          = 0x51,
    AL_MIDI_META_EOT            = 0x2f
};










typedef struct {
    u8          *curPtr;                 
    s32         lastTicks;               
    s32	       	curTicks;		 
    s16         lastStatus;              
} ALSeqMarker;

typedef struct {
    s32         ticks;     
    u8          status;
    u8          byte1; 
    u8          byte2;
    u32         duration;
} ALMIDIEvent;

typedef struct {
    s32         ticks;
    u8          status;
    u8          type;
    u8          len;
    u8          byte1;
    u8          byte2;
    u8          byte3;
} ALTempoEvent;

typedef struct {
    s32         ticks;
    u8          status;
    u8          type;
    u8          len;
} ALEndEvent;

typedef struct {
    struct ALVoice_s    *voice;
} ALNoteEvent;

typedef struct {
    struct ALVoice_s    *voice;
    ALMicroTime         delta;
    u8                  vol;
} ALVolumeEvent;

typedef struct {
    s16                 vol;
} ALSeqpVolEvent;

typedef struct {
    ALSeqMarker         *start;
    ALSeqMarker         *end;
    s32                 count;
} ALSeqpLoopEvent;

typedef struct {
    u8			chan;
    u8			priority;
} ALSeqpPriorityEvent;

typedef struct {
    void		*seq;	 
} ALSeqpSeqEvent;

typedef struct {
    ALBank		*bank;
} ALSeqpBankEvent;

typedef struct {
    struct ALVoiceState_s      *vs;
    void                       *oscState;
    u8                         chan;
} ALOscEvent;

typedef struct {
    s16                 	type;
    union {
        ALMIDIEvent     	midi;
        ALTempoEvent    	tempo;
        ALEndEvent      	end;
        ALNoteEvent     	note;
        ALVolumeEvent   	vol;
        ALSeqpLoopEvent 	loop;
        ALSeqpVolEvent  	spvol;
	ALSeqpPriorityEvent	sppriority;
	ALSeqpSeqEvent		spseq;
	ALSeqpBankEvent		spbank;
        ALOscEvent      	osc;
    } msg;
} ALEvent;

typedef struct {
    ALLink      node;
    ALMicroTime delta;
    ALEvent     evt;
} ALEventListItem;

typedef struct {
    ALLink      freeList;
    ALLink      allocList;
    s32         eventCount;
} ALEventQueue;

void            alEvtqNew(ALEventQueue *evtq, ALEventListItem *items,
                          s32 itemCount);
ALMicroTime     alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt);
void            alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt,
                                ALMicroTime delta);
void        	alEvtqFlush(ALEventQueue *evtq);
void        	alEvtqFlushType(ALEventQueue *evtq, s16 type);









typedef struct ALVoiceState_s {
    struct ALVoiceState_s *next; 
    ALVoice     voice;
    ALSound     *sound;
    ALMicroTime envEndTime;      
    f32         pitch;           
    f32         vibrato;         
    u8          envGain;         
    u8          channel;         
    u8          key;             
    u8          velocity;        
    u8          envPhase;        
    u8          phase;
    u8          tremelo;         
    u8          flags;           

} ALVoiceState;

typedef struct {
    ALInstrument        *instrument;     
    s16                 bendRange;       
    ALFxId              fxId;            
    ALPan               pan;             
    u8                  priority;        
    u8                  vol;             
    u8                  fxmix;           
    u8                  sustain;         
    f32                 pitchBend;       
} ALChanState;

typedef struct ALSeq_s {
    u8          *base;                   
    u8          *trackStart;             
    u8          *curPtr;                 
    s32         lastTicks;               
    s32         len;                     
    f32         qnpt;                    
    s16         division;                
    s16         lastStatus;              
} ALSeq;

typedef struct {
    u32      trackOffset[16];
    u32      division;
} ALCMidiHdr;

typedef struct ALCSeq_s {
    ALCMidiHdr    *base;              
    u32           validTracks;        
    f32           qnpt;               
    u32           lastTicks;          
    u32           lastDeltaTicks;     
    u32		  deltaFlag;	      
    u8            *curLoc[16];        
                                      
                                      
    u8            *curBUPtr[16];      
    u8            curBULen[16];       
    u8            lastStatus[16];     
    u32           evtDeltaTicks[16];  
} ALCSeq;

typedef struct {
    u32         validTracks;
    s32         lastTicks;
    u32         lastDeltaTicks;
    u8          *curLoc[16];
    u8          *curBUPtr[16];
    u8          curBULen[16];
    u8          lastStatus[16];
    u32         evtDeltaTicks[16];
} ALCSeqMarker;





typedef struct {
    s32         maxVoices;          
    s32         maxEvents;          
    u8          maxChannels;        
    u8          debugFlags;         
    ALHeap      *heap;              
    void        *initOsc;
    void        *updateOsc;
    void        *stopOsc;
} ALSeqpConfig;

typedef ALMicroTime   (*ALOscInit)(void **oscState,f32 *initVal, u8 oscType,
                                   u8 oscRate, u8 oscDepth, u8 oscDelay);
typedef ALMicroTime   (*ALOscUpdate)(void *oscState, f32 *updateVal);
typedef void          (*ALOscStop)(void *oscState);

typedef struct {
    ALPlayer            node;            
    ALSynth             *drvr;           
    ALSeq               *target;         
    ALMicroTime         curTime;
    ALBank              *bank;           
    s32                 uspt;            
    s32                 nextDelta;       
    s32                 state;
    u16                 chanMask;        
    s16                 vol;             
    u8                  maxChannels;     
    u8                  debugFlags;      
    ALEvent             nextEvent;
    ALEventQueue        evtq;
    ALMicroTime         frameTime;
    ALChanState         *chanState;      
    ALVoiceState        *vAllocHead;     
    ALVoiceState        *vAllocTail;     
    ALVoiceState        *vFreeList;      
    ALOscInit           initOsc;
    ALOscUpdate         updateOsc;
    ALOscStop           stopOsc;
    ALSeqMarker         *loopStart;
    ALSeqMarker         *loopEnd;
    s32                 loopCount;       
} ALSeqPlayer;

typedef struct {
    ALPlayer            node;            
    ALSynth             *drvr;           
    ALCSeq              *target;         
    ALMicroTime         curTime;
    ALBank              *bank;           
    s32                 uspt;            
    s32                 nextDelta;       
    s32                 state;
    u16                 chanMask;        
    s16                 vol;             
    u8                  maxChannels;     
    u8                  debugFlags;      
    ALEvent             nextEvent;
    ALEventQueue        evtq;
    ALMicroTime         frameTime;
    ALChanState         *chanState;      
    ALVoiceState        *vAllocHead;     
    ALVoiceState        *vAllocTail;     
    ALVoiceState        *vFreeList;      
    ALOscInit           initOsc;
    ALOscUpdate         updateOsc;
    ALOscStop           stopOsc;
} ALCSPlayer;

 


void    alSeqNew(ALSeq *seq, u8 *ptr, s32 len);
void    alSeqNextEvent(ALSeq *seq, ALEvent *event);
s32     alSeqGetTicks(ALSeq *seq);
f32     alSeqTicksToSec(ALSeq *seq, s32 ticks, u32 tempo);
u32     alSeqSecToTicks(ALSeq *seq, f32 sec, u32 tempo);
void    alSeqNewMarker(ALSeq *seq, ALSeqMarker *m, u32 ticks);
void    alSeqSetLoc(ALSeq *seq, ALSeqMarker *marker);
void    alSeqGetLoc(ALSeq *seq, ALSeqMarker *marker);
 


void    alCSeqNew(ALCSeq *seq, u8 *ptr);
void    alCSeqNextEvent(ALCSeq *seq,ALEvent *evt);
s32     alCSeqGetTicks(ALCSeq *seq);
f32     alCSeqTicksToSec(ALCSeq *seq, s32 ticks, u32 tempo);
u32     alCSeqSecToTicks(ALCSeq *seq, f32 sec, u32 tempo);
void    alCSeqNewMarker(ALCSeq *seq, ALCSeqMarker *m, u32 ticks);
void    alCSeqSetLoc(ALCSeq *seq, ALCSeqMarker *marker);
void    alCSeqGetLoc(ALCSeq *seq, ALCSeqMarker *marker); 

 


f32     alCents2Ratio(s32 cents);

void    alSeqpNew(ALSeqPlayer *seqp, ALSeqpConfig *config);
void    alSeqpDelete(ALSeqPlayer *seqp);
void    alSeqpSetSeq(ALSeqPlayer *seqp, ALSeq *seq);
ALSeq   *alSeqpGetSeq(ALSeqPlayer *seqp);
void    alSeqpPlay(ALSeqPlayer *seqp);
void    alSeqpStop(ALSeqPlayer *seqp);
s32	alSeqpGetState(ALSeqPlayer *seqp);
void    alSeqpSetBank(ALSeqPlayer *seqp, ALBank *b);
void    alSeqpSetTempo(ALSeqPlayer *seqp, s32 tempo);
s32     alSeqpGetTempo(ALSeqPlayer *seqp);
s16     alSeqpGetVol(ALSeqPlayer *seqp);		 
void    alSeqpSetVol(ALSeqPlayer *seqp, s16 vol);
void    alSeqpLoop(ALSeqPlayer *seqp, ALSeqMarker *start, ALSeqMarker *end, s32 count);

void    alSeqpSetChlProgram(ALSeqPlayer *seqp, u8 chan, u8 prog);
s32     alSeqpGetChlProgram(ALSeqPlayer *seqp, u8 chan);
void    alSeqpSetChlFXMix(ALSeqPlayer *seqp, u8 chan, u8 fxmix);
u8      alSeqpGetChlFXMix(ALSeqPlayer *seqp, u8 chan);
void	alSeqpSetChlVol(ALSeqPlayer *seqp, u8 chan, u8 vol);
u8	alSeqpGetChlVol(ALSeqPlayer *seqp, u8 chan);
void    alSeqpSetChlPan(ALSeqPlayer *seqp, u8 chan, ALPan pan);
ALPan   alSeqpGetChlPan(ALSeqPlayer *seqp, u8 chan);
void    alSeqpSetChlPriority(ALSeqPlayer *seqp, u8 chan, u8 priority);
u8      alSeqpGetChlPriority(ALSeqPlayer *seqp, u8 chan);
void    alSeqpSendMidi(ALSeqPlayer *seqp, s32 ticks, u8 status, u8 byte1, u8 byte2);


 











 


void    alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *config);
void    alCSPDelete(ALCSPlayer *seqp);
void    alCSPSetSeq(ALCSPlayer *seqp, ALCSeq *seq);
ALCSeq  *alCSPGetSeq(ALCSPlayer *seqp);
void    alCSPPlay(ALCSPlayer *seqp);
void    alCSPStop(ALCSPlayer *seqp);
s32	alCSPGetState(ALCSPlayer *seqp);
void    alCSPSetBank(ALCSPlayer *seqp, ALBank *b);
void    alCSPSetTempo(ALCSPlayer *seqp, s32 tempo);
s32     alCSPGetTempo(ALCSPlayer *seqp);
s16     alCSPGetVol(ALCSPlayer *seqp);
void    alCSPSetVol(ALCSPlayer *seqp, s16 vol);

void    alCSPSetChlProgram(ALCSPlayer *seqp, u8 chan, u8 prog);
s32     alCSPGetChlProgram(ALCSPlayer *seqp, u8 chan);
void    alCSPSetChlFXMix(ALCSPlayer *seqp, u8 chan, u8 fxmix);
u8      alCSPGetChlFXMix(ALCSPlayer *seqp, u8 chan);
void    alCSPSetChlPan(ALCSPlayer *seqp, u8 chan, ALPan pan);
ALPan   alCSPGetChlPan(ALCSPlayer *seqp, u8 chan);
void	alCSPSetChlVol(ALCSPlayer *seqp, u8 chan, u8 vol);
u8	alCSPGetChlVol(ALCSPlayer *seqp, u8 chan);
void    alCSPSetChlPriority(ALCSPlayer *seqp, u8 chan, u8 priority);
u8      alCSPGetChlPriority(ALCSPlayer *seqp, u8 chan);
void    alCSPSendMidi(ALCSPlayer *seqp, s32 ticks, u8 status,
                       u8 byte1, u8 byte2);


 











 



typedef struct {
    s32         maxSounds;
    s32         maxEvents;
    ALHeap      *heap;
} ALSndpConfig;

typedef struct {
    ALPlayer            node;            
    ALEventQueue        evtq;
    ALEvent             nextEvent;
    ALSynth             *drvr;           
    s32                 target;
    void                *sndState;
    s32                 maxSounds;
    ALMicroTime         frameTime;
    ALMicroTime         nextDelta;       
    ALMicroTime         curTime;
} ALSndPlayer;

typedef s16   ALSndId;
    
void            alSndpNew(ALSndPlayer *sndp, ALSndpConfig *c);
void            alSndpDelete(ALSndPlayer *sndp);

ALSndId         alSndpAllocate(ALSndPlayer *sndp, ALSound *sound);
void            alSndpDeallocate(ALSndPlayer *sndp, ALSndId id);

void            alSndpSetSound(ALSndPlayer *sndp, ALSndId id);
ALSndId         alSndpGetSound(ALSndPlayer *sndp);

void            alSndpPlay(ALSndPlayer *sndp);
void            alSndpPlayAt(ALSndPlayer *sndp, ALMicroTime delta);
void            alSndpStop(ALSndPlayer *sndp);

void            alSndpSetVol(ALSndPlayer *sndp, s16 vol);
void            alSndpSetPitch(ALSndPlayer *sndp, f32 pitch);
void            alSndpSetPan(ALSndPlayer *sndp, ALPan pan);
void            alSndpSetPriority(ALSndPlayer *sndp, ALSndId id, u8 priority);

void            alSndpSetFXMix(ALSndPlayer *sndp, u8 mix);
s32             alSndpGetState(ALSndPlayer *sndp);


void alParseAbiCL(Acmd *cmdList, u32 nbytes);









# 34 "c:\\n64\\include/ultra64.h" 2

# 1 "c:\\n64\\include/PR/gu.h" 1



 











 






























 


typedef struct {
	unsigned char   *base;
	int             fmt, siz;
	int             xsize, ysize;
	int             lsize;
	 
	int             addr;
	int             w, h;
	int             s, t;
} Image;

typedef struct {
	float	col[3];
	float	pos[3];
	float	a1, a2;		 
} PositionalLight;


 



extern int guLoadTextureBlockMipMap(Gfx **glist, unsigned char *tbuf, Image *im, 
		unsigned char startTile, unsigned char pal, unsigned char cms, 
		unsigned char cmt, unsigned char masks, unsigned char maskt, 
		unsigned char shifts, unsigned char shiftt, unsigned char cfs, 
		unsigned char cft);

extern int 	guGetDPLoadTextureTileSz (int ult, int lrt);
extern void 	guDPLoadTextureTile (Gfx *glistp, void *timg,
			int texl_fmt, int texl_size,
			int img_width, int img_height,
			int uls, int ult, int lrs, int lrt,
			int palette,
			int cms, int cmt,
			int masks, int maskt,
			int shifts, int shiftt);


 






extern void guMtxIdent(Mtx *m);
extern void guMtxIdentF(float mf[4][4]);
extern void guOrtho(Mtx *m, float l, float r, float b, float t, 
		    float n, float f, float scale);
extern void guOrthoF(float mf[4][4], float l, float r, float b, float t, 
		     float n, float f, float scale);
extern void guFrustum(Mtx *m, float l, float r, float b, float t, 
		      float n, float f, float scale);
extern void guFrustumF(float mf[4][4], float l, float r, float b, float t, 
		       float n, float f, float scale);
extern void guPerspective(Mtx *m, u16 *perspNorm, float fovy, 
			  float aspect, float near, float far, float scale);
extern void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, 
			   float aspect, float near, float far, float scale);
extern void guLookAt(Mtx *m, 
			float xEye, float yEye, float zEye,
			float xAt,  float yAt,  float zAt,
			float xUp,  float yUp,  float zUp);
extern void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye,
		      float xAt,  float yAt,  float zAt,
		      float xUp,  float yUp,  float zUp);
extern void guLookAtReflect(Mtx *m, LookAt *l,
			float xEye, float yEye, float zEye,
			float xAt,  float yAt,  float zAt,
			float xUp,  float yUp,  float zUp);
extern void guLookAtReflectF(float mf[4][4], LookAt *l, 
		      float xEye, float yEye, float zEye,
		      float xAt,  float yAt,  float zAt,
		      float xUp,  float yUp,  float zUp);
extern void guLookAtHilite(Mtx *m, LookAt *l, Hilite *h,
                float xEye, float yEye, float zEye,
                float xAt,  float yAt,  float zAt,
                float xUp,  float yUp,  float zUp,
                float xl1,  float yl1,  float zl1,
                float xl2,  float yl2,  float zl2,
		int   twidth, int theight);
extern void guLookAtHiliteF(float mf[4][4], LookAt *l, Hilite *h, 
		float xEye, float yEye, float zEye,
		float xAt,  float yAt,  float zAt,
		float xUp,  float yUp,  float zUp,
		float xl1,  float yl1,  float zl1,
		float xl2,  float yl2,  float zl2,
		int twidth, int theight);
extern void guLookAtStereo(Mtx *m, 
			float xEye, float yEye, float zEye,
			float xAt,  float yAt,  float zAt,
			float xUp,  float yUp,  float zUp, 
			float eyedist);
extern void guLookAtStereoF(float mf[4][4], 
		      	float xEye, float yEye, float zEye,
		      	float xAt,  float yAt,  float zAt,
		      	float xUp,  float yUp,  float zUp, 
			float eyedist);
extern void guRotate(Mtx *m, float a, float x, float y, float z);
extern void guRotateF(float mf[4][4], float a, float x, float y, float z);
extern void guRotateRPY(Mtx *m, float r, float p, float y);
extern void guRotateRPYF(float mf[4][4], float r, float p, float h);
extern void guAlign(Mtx *m, float a, float x, float y, float z);
extern void guAlignF(float mf[4][4], float a, float x, float y, float z);
extern void guScale(Mtx *m, float x, float y, float z);
extern void guScaleF(float mf[4][4], float x, float y, float z);
extern void guTranslate(Mtx *m, float x, float y, float z);
extern void guTranslateF(float mf[4][4], float x, float y, float z);
extern void guPosition(Mtx *m, float r, float p, float h, float s,
		       float x, float y, float z);
extern void guPositionF(float mf[4][4], float r, float p, float h, float s,
			float x, float y, float z);
extern void guMtxF2L(float mf[4][4], Mtx *m);
extern void guMtxL2F(float mf[4][4], Mtx *m);
extern void guMtxCatF(float m[4][4], float n[4][4], float r[4][4]);
extern void guMtxCatL(Mtx *m, Mtx *n, Mtx *res);
extern void guMtxXFMF(float mf[4][4], float x, float y, float z, 
		      float *ox, float *oy, float *oz);
extern void guMtxXFML(Mtx *m, float x, float y, float z, 
		      float *ox, float *oy, float *oz);

 
extern void guNormalize(float *x, float *y, float *z);

 
void guPosLight(PositionalLight *pl, Light *l,
                float xOb, float yOb, float zOb);
void guPosLightHilite(PositionalLight *pl1, PositionalLight *pl2,
                Light *l1, Light *l2,
                LookAt *l, Hilite *h,
                float xEye, float yEye, float zEye,
                float xOb,  float yOb,  float zOb,
                float xUp,  float yUp,  float zUp,
                int twidth, int theight);
extern int guRandom(void);

 


extern float sinf(float angle);
extern float cosf(float angle);
extern signed short sins (unsigned short angle);
extern signed short coss (unsigned short angle);
extern float sqrtf(float value);

 


 




                                            
                                            

extern void guParseRdpDL(u64 *rdp_dl, u64 nbytes, u8 flags);
extern void guParseString(char *StringPointer, u64 nbytes);

 



 

 



extern void
guBlinkRdpDL(u64 *rdp_dl_in, u64 nbytes_in,
             u64 *rdp_dl_out, u64 *nbytes_out,
             u32 x, u32 y, u32 radius,
             u8  red, u8 green, u8 blue,
             u8 flags);
 
 






 



extern void guParseGbiDL(u64 *gbi_dl, u32 nbytes, u8 flags);
extern void guDumpGbiDL(OSTask *tp,u8 flags);








typedef struct {
    int    dataSize;
    int    dlType;
    int    flags;
    u32    paddr;
} guDLPrintCB;

void guSprite2DInit(uSprite *SpritePointer,   
		    void *SourceImagePointer,
		    void *TlutPointer,
		    int Stride,
		    int SubImageWidth,
		    int SubImageHeight,
		    int SourceImageType,
		    int SourceImageBitSize,
		    int SourceImageOffsetS,
		    int SourceImageOffsetT);


# 35 "c:\\n64\\include/ultra64.h" 2

# 1 "c:\\n64\\include/PR/ramrom.h" 1



 











 







 


























 

 
















 





typedef struct {
    long type;
    long length;	     
    long magic;
    char userdata[(((4096) *6) - (3*sizeof(long)) ) ];
} RamRomBuffer;

 






























# 36 "c:\\n64\\include/ultra64.h" 2

# 1 "c:\\n64\\include/PR/sp.h" 1
 











 



















struct bitmap {
	s16	width;		 
				 

	s16	width_img;	 
				 

	s16	s;		 
				 

	s16	t;		 

	void	*buf;		 
				 
				 
				 

	s16	actualHeight;	 

	s16	LUToffset;	 
};

typedef struct bitmap Bitmap;

struct sprite {
	s16	x,y;		 

	s16	width, height;	 

	f32	scalex, scaley;	 

	s16	expx, expy;	 

	u16 	attr;		 
	s16	zdepth;		 

	u8	red;		 
	u8	green;		 
	u8	blue;		 
	u8	alpha;		 

	s16	startTLUT;	 
	s16	nTLUT;		 

	int	*LUT;		 

	s16	istart;		 
	s16	istep;		 
				 

	s16	nbitmaps;	 
	s16	ndisplist;	 

	s16	bmheight;	 
	s16	bmHreal;	 
	u8	bmfmt;		 
	u8	bmsiz;		 

	Bitmap	*bitmap;	 

	Gfx	*rsp_dl;	 

	Gfx	*rsp_dl_next;	 

	s16	frac_s,		 
		frac_t;		 
};

typedef struct sprite Sprite;

 






















 















 















 



void spSetAttribute (Sprite *sp, s32 attr);
void spClearAttribute (Sprite *sp, s32 attr);
void spMove (Sprite *sp, s32 x, s32 y);
void spScale (Sprite *sp, f32 sx, f32 sy);
void spSetZ  (Sprite *sp, s32 z );
void spColor (Sprite *sp, u8 red, u8 green, u8 blue, u8 alpha);
Gfx *spDraw (Sprite *sp);
void spInit( Gfx **glistp );
void spScissor( s32 xmin, s32 xmax, s32 ymin, s32 ymax );
void spFinish( Gfx **glistp );






# 37 "c:\\n64\\include/ultra64.h" 2

# 1 "c:\\n64\\include/PR/ucode.h" 1
 











 


















 





 







 







 






   

 





 







 
extern long long int	rspbootTextStart[], rspbootTextEnd[];

 
extern long long int	gspFast3DTextStart[], gspFast3DTextEnd[];
extern long long int	gspFast3DDataStart[], gspFast3DDataEnd[];

 
extern long long int	gspFast3D_dramTextStart[], gspFast3D_dramTextEnd[];
extern long long int	gspFast3D_dramDataStart[], gspFast3D_dramDataEnd[];

 
extern long long int	gspFast3D_fifoTextStart[], gspFast3D_fifoTextEnd[];
extern long long int	gspFast3D_fifoDataStart[], gspFast3D_fifoDataEnd[];

 
extern long long int	gspF3DNoNTextStart[], gspF3DNoNTextEnd[];
extern long long int	gspF3DNoNDataStart[], gspF3DNoNDataEnd[];

 
extern long long int	gspF3DNoN_dramTextStart[];
extern long long int	gspF3DNoN_dramTextEnd[];
extern long long int	gspF3DNoN_dramDataStart[];
extern long long int	gspF3DNoN_dramDataEnd[];

 
extern long long int	gspF3DNoN_fifoTextStart[];
extern long long int	gspF3DNoN_fifoTextEnd[];
extern long long int	gspF3DNoN_fifoDataStart[];
extern long long int	gspF3DNoN_fifoDataEnd[];

 
extern long long int	gspLine3DTextStart[], gspLine3DTextEnd[];
extern long long int	gspLine3DDataStart[], gspLine3DDataEnd[];

 
extern long long int	gspLine3D_dramTextStart[], gspLine3D_dramTextEnd[];
extern long long int	gspLine3D_dramDataStart[], gspLine3D_dramDataEnd[];

 
extern long long int	gspLine3D_fifoTextStart[], gspLine3D_fifoTextEnd[];
extern long long int	gspLine3D_fifoDataStart[], gspLine3D_fifoDataEnd[];

 
extern long long int	gspSprite2DTextStart[], gspSprite2DTextEnd[];
extern long long int	gspSprite2DDataStart[], gspSprite2DDataEnd[];

 
extern long long int	gspSprite2D_dramTextStart[], gspSprite2D_dramTextEnd[];
extern long long int	gspSprite2D_dramDataStart[], gspSprite2D_dramDataEnd[];

 
extern long long int	gspSprite2D_fifoTextStart[], gspSprite2D_fifoTextEnd[];
extern long long int	gspSprite2D_fifoDataStart[], gspSprite2D_fifoDataEnd[];

 
extern long long int 	aspMainTextStart[], aspMainTextEnd[];
extern long long int 	aspMainDataStart[], aspMainDataEnd[];

 
 
extern long long int  gspF3DEX_fifoTextStart[],     gspF3DEX_fifoTextEnd[];
extern long long int  gspF3DEX_fifoDataStart[],     gspF3DEX_fifoDataEnd[];
extern long long int  gspF3DEX_NoN_fifoTextStart[], gspF3DEX_NoN_fifoTextEnd[];
extern long long int  gspF3DEX_NoN_fifoDataStart[], gspF3DEX_NoN_fifoDataEnd[];

extern long long int  gspF3DLX_fifoTextStart[],     gspF3DLX_fifoTextEnd[];
extern long long int  gspF3DLX_fifoDataStart[],     gspF3DLX_fifoDataEnd[];
extern long long int  gspF3DLX_NoN_fifoTextStart[], gspF3DLX_NoN_fifoTextEnd[];
extern long long int  gspF3DLX_NoN_fifoDataStart[], gspF3DLX_NoN_fifoDataEnd[];
extern long long int  gspF3DLX_Rej_fifoTextStart[], gspF3DLX_Rej_fifoTextEnd[];
extern long long int  gspF3DLX_Rej_fifoDataStart[], gspF3DLX_Rej_fifoDataEnd[];

extern long long int  gspF3DLP_Rej_fifoTextStart[], gspF3DLP_Rej_fifoTextEnd[];
extern long long int  gspF3DLP_Rej_fifoDataStart[], gspF3DLP_Rej_fifoDataEnd[];
extern long long int  gspL3DEX_fifoTextStart[],     gspL3DEX_fifoTextEnd[];
extern long long int  gspL3DEX_fifoDataStart[],     gspL3DEX_fifoDataEnd[];

 












# 38 "c:\\n64\\include/ultra64.h" 2

# 1 "c:\\n64\\include/PR/ultraerror.h" 1
 



















 



















 


















































































































typedef	void (*OSErrorHandler)(s16, s16, ...);

OSErrorHandler	osSetErrorHandler(OSErrorHandler);







# 39 "c:\\n64\\include/ultra64.h" 2

# 1 "c:\\n64\\include/PR/ultralog.h" 1
 



















 




















    
typedef struct {
    u32 magic;           
    u32 len;             
    u32 *base;           
    s32 startCount;      
    s32 writeOffset;     
} OSLog;

typedef struct {
    u32 magic;
    u32 timeStamp;
    u16 argCount;
    u16 eventID;
} OSLogItem;

typedef struct {
    u32 magic;           
    u32 version;         
} OSLogFileHdr;

void    osCreateLog(OSLog *log, u32 *base, s32 len);
void    osLogEvent(OSLog *log, s16 code, s16 numArgs, ...);
void    osFlushLog(OSLog *log);
u32	osLogFloat(f32);

extern void osDelay(int count);






# 40 "c:\\n64\\include/ultra64.h" 2



# 7 "c:/WayneWork/pfs.c" 2

# 1 "c:/WayneWork/stdtypes.h" 1




 




typedef volatile signed char VS08;



typedef volatile unsigned char VU08;



typedef unsigned char U08;



typedef signed char S08;



typedef volatile long VS32;



typedef volatile short VS16;



typedef volatile signed char VS8;



typedef volatile unsigned long VU32;



typedef volatile unsigned short VU16;



typedef volatile unsigned char VU8;



typedef volatile float VF32;



typedef volatile double VF64;



typedef int m_int;



typedef unsigned int m_uint;



typedef unsigned char U8;



typedef signed char S8;



typedef unsigned short U16;



typedef short S16;



typedef unsigned long U32;



typedef long S32;



typedef float F32;



typedef double F64;



typedef long MBFLT;
typedef long ANG32;
typedef struct {
	S32 x,y,z;
} S32XYZ;








# 8 "c:/WayneWork/pfs.c" 2



# 1 "c:/WayneWork/pfs.h" 1




# 1 "c:\\n64\\include\\PR/os.h" 1

 



















 








# 979 "c:\\n64\\include\\PR/os.h"

# 5 "c:/WayneWork/pfs.h" 2

# 1 "c:/WayneWork/spentry.h" 1




 
 
 

typedef struct 					 
{
	S8 ctlID;					 
	U8 edge;					 
} SPENTRY;



# 6 "c:/WayneWork/pfs.h" 2



 
 
 













extern S16 practiceMode;


# 37 "c:/WayneWork/pfs.h"


 
 
 

typedef struct 					 
{
	S8	shot;					 
	S8	shot2;
	S8	pass;
	S8	unused[5];				 
	SPENTRY	kneel[4];			 
	SPENTRY	steal[4];
	SPENTRY dive[4];
	SPENTRY	turbo[4];
	SPENTRY check[4];
	SPENTRY hook[4];
	SPENTRY trip[4];
	SPENTRY onetimer[4];
	SPENTRY hotshot[4];
	SPENTRY swplayer[4];
	SPENTRY swcamera[4];
} CONTROLLER;

typedef struct 					 
{
	U8	history[24];			 
	U8	initteamseed[16];		 
	U8	seriestype;				 
	S8	startingdiv;			 
	U8	divisionsbeat;
	U8  teamsbeatindiv;
	S8  nextoteam;				 
	U8	winstreak;				 
	U8	lossstreak;
	U8	wins;					 
	U8	losses;					 
	U8	ties;					 
	U16 goals;					 
	U16 assists;				 
	S16 plusminus;
	U16 randomseed;				 
	U8	playoffwins;			 
	U8	playofflosses;			 
	U8	serieswins;				 
	U8	serieslosses;			 
	U8	city;					 
	U8	line_pos;				 
} LADDER;

typedef struct 					 
{
	U16			wins;						 
	U16			losses;
	U16			ties;
	U16			h2hwins;					 
	U16			h2hlosses;
	U16			h2hties;
	S16			plusminus;					 
	U16			unused[3];					 
	U32			shotsongoal;				 
	U32			goals;
	U32			assists;
} CSTATS;

typedef	struct 								 
{		
	char		name[4];					 
	CSTATS		cstats;						 
	U16			otwins;						 
	U16			otlosses;
	U16			otties;
	S16			plusminus;					 
	U16			fightswon;					 
	U16			fightslost;
	U16			h2hfightswon;				 
	U16			h2hfightslost;
	S16			powerchecks;				 
	S16			crosschecks;
	S16			hooks;
	S16			trips;
	U16			powergoals;					 
	U16			onetimergoals;
	U16			goalieinnet;				 
	U16			seasons;					 
	U16			divchamps;
	U16			confchamps;	
	U16			stanleycups;
	U16			penalties;					 

	 
	U8			tidx;						 
	U8			unused1;					 
	U8			kidx0[4];					 
	U8			kidx1[4];					 
	U16			unused[3];					 



	F32			penaltyseconds;				 
	LADDER		ladder;						 
	CONTROLLER	control;					 
} PFSPLAYER;
 
 
 
 
 


typedef	struct 								 
{		
	char		name1[4];					 
	char		name2[4];					 
	U16			wins;						 
	U16			losses;
	U16			ties;
	U16			age;						 
} PFSTEAM;

typedef struct 								 
{	
	char		sig[8 ];		 
	U32			checksum;					 
	U8			revision;					 
	S8			centerX;					 
	S8			centerY;					 
	S8			arcadeMode;					 
	S8			realRink;
	S8			nPlayers;
	S8			gameDifficulty;
	S8			gameTime;
	S8			penaltiesOn;
	S8			autoSwitchPlayer;
	U8			lineSwitching;
	S8			playSpeed;
	S8			noPuckStreak;
	S8			playerFatigue;
	U8			cameras;	
	S8			fightingOn;
	U8			language;
	U8			languagePicked;
	S8			unused[2];					 
} PFSGLOBAL;


typedef struct
{
	char AllanDataFlag[190];	 
	char CurrentTeamPrefix[510*5];	 
	U8 Stats[510*3];		 
	U16 Teams[26*17];		 
	U8 HatTricks[510];		 
	U8 PlayerOfGame[510];	 
} PFSALDATA;


typedef struct
{
	U8 GoalsAgainstTeam;		 
	U8 Goals;
	char GoalInitials[3];		 

	U8 AssistsAgainstTeam;		 
	U8 Assists;
	char AssistInitials[3];		 

	U8 HatTricksAgainstTeam;	 
	U8 HatTricks;
	char HatTricksInitials[3];	 
} PFSALRECORDS;


 
 
 
 
 
typedef struct 								 
{
	PFSGLOBAL	global;						 
	PFSTEAM		teams[14 ];			 
	PFSPLAYER	players[6 ];		 

	PFSALDATA	AllansData;					 
	PFSALRECORDS	AllansRecords[510];		 

} PFS;






											 

 
 
 




 	S8		pfsPak;						 
 	S8		pfsPaks;					 
 	U8		pfsCheck;					 
 	U8		pfsFailed;					 
 	S16		pfsReturn;					 
 	U8		pfsChanged[4 ];	 
 	S8		pfsController;				 



extern	PFS		pfs[4 ];		 


 
 
 
 

void	PfsSaveAllansData(PFS *p);
void	PfsRestoreAllansData(PFS *p);

void	PfsSaveGlobals(PFS *p);
void	PfsRestoreGlobals(PFS *p);
void	PfsSaveController(PFSPLAYER *player, int kidx);
void	PfsRestoreController(PFSPLAYER *player, int kidx);
void	PfsInit(void);
void	Ascii2Ncode(char *dest, char *src, int n);
int		Ncode2Ascii(char *dest, char *src, int n);
void	PfsLockIO(void);
void	PfsUnlockIO(void);
U32		PfsChecksum(int pak);
int		PfsGetPak(int n);
int		PfsPlayerCount(int pak);
PFSPLAYER *PfsWhichPlayer(int pak, char *name, int *index);
PFSTEAM *PfsAddTeam(int pak, int kid0, int kid1);
PFSPLAYER *PfsAddPlayer(int kidx, char *name);
int		PfsWriteFile(int pak);
void	PfsStatus(void);
void 	PfsStatsScreen(void);
void 	PfsDeleteScreen(void);
void	PfsRestoreStats(void);



# 11 "c:/WayneWork/pfs.c" 2


# 1 "c:/WayneWork/U64main.h" 1





# 1 "c:\\WayneWork/sched.h" 1
 



































typedef struct {
    short type;
    char  misc[30];
} OSScMsg;

typedef struct OSScTask_s {
    struct OSScTask_s   *next;           
    u32                 state;
    u32			flags;
    void		*framebuffer;	 

    OSTask              list;
    OSMesgQueue         *msgQ;
    OSMesg              msg;

} OSScTask;

 











 






typedef struct SCClient_s {
    struct SCClient_s   *next;   
    OSMesgQueue         *msgQ;   
} OSScClient;

typedef struct {
    OSScMsg     retraceMsg;
    OSScMsg     prenmiMsg;
    OSMesgQueue interruptQ;
    OSMesg      intBuf[8 ];
    OSMesgQueue cmdQ;
    OSMesg      cmdMsgBuf[8 ];
    OSThread    thread;
    OSScClient  *clientList;
    OSScTask    *audioListHead;
    OSScTask    *gfxListHead;
    OSScTask    *audioListTail;
    OSScTask    *gfxListTail;
    OSScTask    *curRSPTask;
    OSScTask    *curRDPTask;
    u32         frameCount;
    s32         doAudio;
} OSSched;

void            osCreateScheduler(OSSched *s, void *stack, OSPri priority,
                                  u8 mode, u8 numFields);
void            osScAddClient(OSSched *s, OSScClient *c, OSMesgQueue *msgQ);
void            osScRemoveClient(OSSched *s, OSScClient *c);
OSMesgQueue     *osScGetCmdQ(OSSched *s);



# 6 "c:/WayneWork/U64main.h" 2


# 1 "c:/WayneWork/config.h" 1












































void ROMPRINTF(char *fmt,...);
void ROMPRINTFERR(int errid, char *fmt,...);


# 8 "c:/WayneWork/U64main.h" 2


 
 
 
 











 
 
 








































 
 
 
typedef struct 
{
	Mtx	projection;
	Mtx	viewing;
	Mtx	identity;
	Mtx	mat[400 ];
	Gfx	glist[300 ];
	Gfx	clist[1700 ];
} Dynamic;


typedef union {    

    struct {
        short   type;
    } gen;
    
    struct {
        short   type;
    } done;
    
    OSScMsg      app;
    
} GFXMsg;


typedef struct 
{
    OSScTask	task;
    Dynamic		*dp;
    GFXMsg      msg;
    u16			*cfb;
} GFXInfo;


 
 
 




extern 	OSMesgQueue hockeyMsgQ;
extern 	OSMesg      hockeyMsgBuf[8 ];

extern 	OSMesgQueue	gfxFrameMsgQ;
extern 	OSMesg		gfxFrameMsgBuf[60 ];

extern 	Gfx			*glistp;
extern 	Gfx			*clistp;
extern 	Dynamic 	*dynamicp;
extern 	Mtx			*mtxp;

extern 	float		HFOV;					 
extern 	float		VFOV;
extern 	S16			centerX, centerY;		 

extern 	u32			frameTime;
extern 	OSTime		frameTimeCur;
extern 	u32			BGcolor;

extern 	vu32 		frameCount;				 
extern 	vu32		lastFrameCount;			 
extern 	vu32 		frameCounter;			 
extern 	vu32 		lastFrameCounter;		 
extern  	VF32		SPF;					 







extern 	s16			borderh;				 
extern 	s16			borderv;

extern  	vs8			msgSent;				 
extern  	vs8			msgWorking;				 
extern  	vs8			msgReply;				 

extern 	char 		*relocSegments[16];		 

extern 	vu8			controllerIO;			 
extern 	vu8			pfsIO;					 
extern 	vs8			check4NewControls;		 
extern 	vs8			ignoreControlRead;		 



extern	OSMesgQueue	serialMsgQ;				 

extern	u32			rspStartTime;
extern	u32			rspTime;
extern	u32			rdpTime;


 
 
 
extern char _yieldSegmentEnd[];
extern char _staticSegmentRomStart[], _staticSegmentRomEnd[];
extern char _tableSegmentRomStart[], _tableSegmentRomEnd[];
extern char _seqSegmentRomStart[], _seqSegmentRomEnd[];
extern char _bankSegmentRomStart[], _bankSegmentRomEnd[];


 
 
 
void change2HiresCFB(void);
void change2LoresCFB(void);
extern	void	guRotateRYP(Mtx *mtx, float r, float y, float p);
extern	void	guRotatePYR(Mtx *mtx, float p, float y, float r);

extern	void	Rotate(float m[4][4], float a, float x, float y, float z);
extern	void	RotatePYR(float m[4][4], float p, float y, float r);
extern	void	RotateRYP(float m[4][4], float p, float y, float r);

extern	void	Translate(float m[4][4], float x, float y, float z);

extern	void	MatrixMul3x3(float m[4][4], float mf[4][4]);
extern	void	MatrixMul4x3(float m[4][4], float mf[4][4]);
extern	void	MatrixMul4x4(float m[4][4], float mf[4][4]);

extern	void	StartGfxTask(GFXInfo *);
extern	void	EndGfxTask(GFXInfo *);


extern	void	wayne_main(void);							 




extern	void	cpu(u32 fspcr);

extern void     romCopy(char *src, char *dest, int len);
extern void     romCopy2(char *src, char *dest, int len);

extern void 	guMtxFX2L(float mf[4][4], Mtx *m);
extern void 	guMtxZoidX2L(float mf[3][4], Mtx *m);

extern void		doRelocSegments(void);

extern Gfx		setup_rdpstate[];					 
extern Gfx		setup_rspstate[];
extern Gfx		setup_rdpstate_hires[];
extern Gfx		setup_rspstate_hires[];

extern Dynamic	dynamic[2];							 
extern u64		dram_stack[];
extern u64		gfxYieldBuf[];
extern u64 		audYieldBuf[];

extern	u64		fifo[];					


extern u16 		cfb_16_a[];							 
extern u16		cfb_16_b[];
extern u16		*cfb_16hires_a;
extern u16		*cfb_16hires_b;

extern u16		zbuffer[];							 


# 13 "c:/WayneWork/pfs.c" 2

# 1 "c:/WayneWork/U64attract.h" 1
# 1 "c:/WayneWork/blit.h" 1




# 1 "c:/WayneWork/mbox.h" 1



# 1 "c:/WayneWork/struct.h" 1



# 1 "c:/WayneWork/fmath.h" 1




# 1 "c:\\n64\\include/math.h" 1








 
 
 
 
 
 
 
 

 

 













 















 



# 106 "c:\\n64\\include/math.h"


extern double	acos(double);
#pragma no side effects (acos)
extern float	acosf(float);
#pragma no side effects (acosf)

extern double	asin(double);
#pragma no side effects (asin)
extern float	asinf(float);
#pragma no side effects (asinf)

extern double	atan(double);
#pragma no side effects (atan)
extern float	atanf(float);
#pragma no side effects (atanf)

extern double	atan2(double, double);
#pragma no side effects (atan2)
extern float	atan2f(float, float);
#pragma no side effects (atan2f)

extern double	cos(double);
#pragma no side effects (cos)
extern float	cosf(float);
#pragma no side effects (cosf)

extern double	sin(double);
#pragma no side effects (sin)
extern float	sinf(float);
#pragma no side effects (sinf)

extern double	tan(double);
#pragma no side effects (tan)
extern float	tanf(float);
#pragma no side effects (tanf)

extern double	cosh(double);
#pragma no side effects (cosh)
extern float	coshf(float);
#pragma no side effects (coshf)

extern double	sinh(double);
#pragma no side effects (sinh)
extern float	sinhf(float);
#pragma no side effects (sinhf)

extern double	tanh(double);
#pragma no side effects (tanh)
extern float	tanhf(float);
#pragma no side effects (tanhf)

extern double	exp(double);
#pragma no side effects (exp)
extern float	expf(float);
#pragma no side effects (expf)

extern double	frexp(double, int *);





extern double	ldexp(double, int);





extern double	log(double);
#pragma no side effects (log)
extern float	logf(float);
#pragma no side effects (logf)

extern double	log10(double);
#pragma no side effects (log10)
extern float	log10f(float);
#pragma no side effects (log10f)

extern double	modf(double, double *);
 
extern float	modff(float, float *); 

extern double	pow(double, double);
#pragma no side effects (pow)
 
extern float	powf(float, float);
#pragma no side effects (powf)

extern double	sqrt(double);
#pragma no side effects (sqrt)
extern float	sqrtf(float);
#pragma no side effects (sqrtf)

extern double	ceil(double);
#pragma no side effects (ceil)
extern float	ceilf(float);
#pragma no side effects (ceilf)

extern double	fabs(double);
#pragma no side effects (fabs)
 
extern float	fabsf(float);
#pragma no side effects (fabsf)

extern double	floor(double);
#pragma no side effects (floor)
extern float	floorf(float);
#pragma no side effects (floorf)

extern double	fmod(double, double);
#pragma no side effects (fmod)
 
extern float	fmodf(float, float);
#pragma no side effects (fmodf)


# 239 "c:\\n64\\include/math.h"

 
extern const double __infinity;





extern int errno, signgam;

extern double	atof(const char *);
extern int	rand(void);
extern void	srand(unsigned);





enum version { c_issue_4, ansi_1, strict_ansi };
extern const enum version _lib_version;

 
extern double	rint(double);
#pragma no side effects (rint)
extern double	asinh(double);
#pragma no side effects (asinh)
extern double	acosh(double);
#pragma no side effects (acosh)
extern double	atanh(double);
#pragma no side effects (atanh)
extern double	log1p(double);
#pragma no side effects (log1p)
extern double	erf(double);
#pragma no side effects (erf)
extern double	erfc(double);
#pragma no side effects (erfc)
extern double	expm1(double);
#pragma no side effects (expm1)
extern double	gamma(double);
extern double	hypot(double, double);
#pragma no side effects (hypot)
struct __cabs_s { double a,b; };
extern double	cabs(struct __cabs_s);
#pragma no side effects (cabs)
extern double	copysign(double, double);
#pragma no side effects (copysign)
extern double	drem(double, double);
#pragma no side effects (drem)
extern double	logb(double);
#pragma no side effects (logb)






extern double	scalb(double, double);
#pragma no side effects (scalb)
extern int	finite(double);
#pragma no side effects (finite)
extern double	j0(double);
#pragma no side effects (j0)
extern double	j1(double);
#pragma no side effects (j1)
extern double	jn(int, double);
#pragma no side effects (jn)
extern double	y0(double);
#pragma no side effects (y0)
extern double	y1(double);
#pragma no side effects (y1)
extern double	yn(int, double);
#pragma no side effects (yn)
extern double	cbrt(double);
#pragma no side effects (cbrt)
extern double	atof(const char *);
extern double   strtod(const char *, char **);
extern double   trunc(double);
#pragma no side effects (trunc)

extern int	rand(void);
extern void	srand(unsigned);

extern long	random(void);
extern int	srandom(unsigned); 
extern char *	initstate(unsigned int, char *, int);
extern char *	setstate(char *);

extern double	drand48(void);
extern double	erand48(unsigned short [3]);
extern long	lrand48(void);
extern long	nrand48(unsigned short [3]);
extern long	mrand48(void);
extern long	jrand48(unsigned short [3]);
extern void	srand48(long);
extern unsigned short * seed48(const unsigned short [3]);
extern void	lcong48(const unsigned short [7]);

 


















 











 
extern float	fhypot(float, float);
#pragma no side effects (fhypot)
extern float	hypotf(float, float);
#pragma no side effects (hypotf)
struct __fcabs_s { float a,b; };
extern float	fcabs(struct __fcabs_s);
#pragma no side effects (fcabs)
extern float	fexpm1(float);
#pragma no side effects (fexpm1)
extern float	expm1f(float);
#pragma no side effects (expm1f)
extern float	log1pf(float);
#pragma no side effects (log1pf)
extern float	truncf(float);
#pragma no side effects (truncf)







# 410 "c:\\n64\\include/math.h"


 




































struct exception {
	int type;
	char *name;
	double arg1;
	double arg2;
	double retval;
};

extern int matherr(struct exception *p);


# 1 "c:\\n64\\include/svr4_math.h" 1
 
 















 




















# 460 "c:\\n64\\include/math.h" 2




# 480 "c:\\n64\\include/math.h"






# 5 "c:/WayneWork/fmath.h" 2

# 1 "c:\\WayneWork/ieeefp.h" 1






typedef union 
{
  double value;
  struct 
  {
    unsigned int sign : 1;
    unsigned int exponent: 11;
    unsigned int fraction0:4;
    unsigned int fraction1:16;
    unsigned int fraction2:16;
    unsigned int fraction3:16;
    
  } number;
  struct 
  {
    unsigned int sign : 1;
    unsigned int exponent: 11;
    unsigned int quiet:1;
    unsigned int function0:3;
    unsigned int function1:16;
    unsigned int function2:16;
    unsigned int function3:16;
  } nan;
  struct 
  {
    unsigned long msw;
    unsigned long lsw;
  } parts;
    long aslong[2];
} __ieee_double_shape_type;



# 84 "c:\\WayneWork/ieeefp.h"




typedef union
{
  float value;
  struct 
  {
    unsigned int sign : 1;
    unsigned int exponent: 8;
    unsigned int fraction0: 7;
    unsigned int fraction1: 16;
  } number;
  struct 
  {
    unsigned int sign:1;
    unsigned int exponent:8;
    unsigned int quiet:1;
    unsigned int function0:6;
    unsigned int function1:16;
  } nan;
  long p1;
  
} __ieee_float_shape_type;



# 136 "c:\\WayneWork/ieeefp.h"




# 176 "c:\\WayneWork/ieeefp.h"


int isnan(double);
int isinf(double);
int finite(double);


int isnanf(float);
int isinff(float);
int finitef(float);

double 	maxpowtwo(void);
float 	maxpowtwof(void);



























# 235 "c:\\WayneWork/ieeefp.h"



# 6 "c:/WayneWork/fmath.h" 2






 

 










typedef struct {		 
	F32 uvs[3][3];			 
	F32 pos[3];				 
}MAT3;

typedef struct {		 
	F32 uvs[4][3];			 
}MAT4;

typedef struct {		 
	F32 xuv[3];				 
	F32 yuv[3];				 
	F32 zuv[3];				 
 	F32 pos[3];				 
}MATV;


typedef union {			 
	MAT3 mat3;
	MAT4 mat4;
	MATV matv;
	F32 uvs[4][3];
}MATRIX;

 










 
extern 	F32			unitmatrix[4][3];		 




extern F32 uvector[3];		 
extern F32 dvector[3];		 
extern F32 rvector[3];		 
extern F32 lvector[3];		 
extern F32 fvector[3];		 
extern F32 bvector[3];		 
extern F32 hugevector[3];		 
extern MAT3 lrmat;			 
extern F32 unitquat[4];		 
extern F32 quatyaw180[4];		 

 





















 





































 






 
void CopyUV(F32 a[][3], F32 b[][3]);
void TransposeUV(F32 uv[][3]);
void ScaleUV(F32 a[][3], F32 b[][3], F32 sfactor);
void FixRowUV(F32 a[][3]);
void FixColumnUV(F32 a[][3]);
void RotateUV(F32 rpyv[3], F32 uvs[][3]);
void WYawUV(F32 angle, F32 uv[][3]);
void WPitchUV(F32 angle, F32 uv[][3]);
void WRollUV(F32 angle, F32 uv[][3]);
void YawUV(F32 angle, F32 uv[][3]);
void PitchUV(F32 angle, F32 uv[][3]);
void RollUV(F32 angle, F32 uv[][3]);
void MulMat(MATRIX *BB, MATRIX *AA, MATRIX *CC);
void BodyVector(F32 uvec[3], F32 bodvec[3], F32 uvs[][3]);
F32 BodyX(F32 uvec[3], F32 uvs[][3]);
F32 BodyY(F32 uvec[3], F32 uvs[][3]);
F32 BodyZ(F32 uvec[3], F32 uvs[][3]);
void WorldVector(F32 bodvec[3], F32 uvec[3], F32 uvs[][3]);
F32 WorldX(F32 bodvec[3], F32 uvs[][3]);
F32 WorldY(F32 bodvec[3], F32 uvs[][3]);
F32 WorldZ(F32 bodvec[3], F32 uvs[][3]);
void MulVecMat(F32 vin[3], F32 vout[3], F32 M[4][3]);
F32 NormalVector(F32 v[3]);
F32 SlowNormalVector(F32 v[3]);
F32 NormalVector2D(F32 v[3]);
F32 Det3Vectors(F32 v0[3], F32 v1[3], F32 v2[3]);
void GetYawPitch(F32 dvec[3], F32 *yawp, F32 *pitp);
F32 SubAngle(F32 a, F32 b);
F32 AddAngle(F32 a, F32 b);
F32 FixAngle(F32 a);
F32 SubAngleP(F32 a, F32 b);
F32 AddAngleP(F32 a, F32 b);
F32 FixAngleP(F32 a);
void CreatePYRMatrix(F32 mat[][3], F32 *pyr);
void CreateRYPMatrix(F32 mat[][3], F32 *pyr);
void CreateQuatMat(F32 *mat, F32 q[], int normal);
void NormalizeQuat(F32 *q);
void MulQuat(F32 *q1, F32 *q2, F32 *qr);
void InterpQuats(F32 frac, F32 *q1, F32 *q2, F32 *qr);
void ExtractRYP(F32 mat[][3], F32 *pyr);
void Randomize(U32 seed);
F32 Random(F32 max);
int RandInt(int max);
F32 fqdist(F32 x, F32 y);
int quadratic(F32 a,F32 b,F32 c,F32 *r1,F32 *r2);













	

# 4 "c:/WayneWork/struct.h" 2


 



typedef struct
{
	char	Name[16];			 
	F32		Radius;				 
	S16		Nanims;				
	S16		AnimIndex;
} ObjDef, OBJDEF;



typedef struct
{
	S16		type;				 
	S16		id;					 
	S16		lod;				 
	S16		fid;				 
	S16		odata[2];			 
	S16		udata[2];			 
} ObjAnim, OBJANIM;



 


typedef struct
{
	char	Name[16];
	U16		Width,Height;
 
 
	U16		size;				 
	U16		format;				 
	char	*TexBase;			 
	S16		palIndex;			 
} TexDef, TEXDEF;


 


typedef struct
{
	char	Name[16];
	U8		start,end;			 
 
 
	U16		format;				 
	char	*PalBase;			 
} PalDef, PALDEF;


 



typedef struct
{
	U16		texidx;				 
	U16		flags;				 
	F32		LodRad;				 
	char	*DisplayList;		 
} RomLOD, ROMLOD;







 


typedef struct
{
	S32		LodCount;			 
	ROMLOD	LOD[4];
} RomObject, ROMOBJECT;


 
 
 
 
 
 
 
 
 
 
 
 
 
typedef struct
{
	ObjDef	*ObjDefIdx;			 
	S32		ObjDefCount;		 
	ObjAnim	*ObjAnimIdx;		 
	S32		ObjAnimCount;		 
	TexDef	*TexDefIdx;			 
	S32		TexDefCount;		 
	PalDef	*PalDefIdx;			 
	S32		PalDefCount;		 
} RomObjectList, ROMOBJECTLIST;



# 4 "c:/WayneWork/mbox.h" 2

# 1 "c:/WayneWork/zoid.h" 1



# 1 "c:\\n64\\include\\PR/gbi.h" 1
 










 







# 4124 "c:\\n64\\include\\PR/gbi.h"


# 4 "c:/WayneWork/zoid.h" 2

























typedef struct
{
    F32	x,y,z;			 
    F32 r,g,b;			 
	S16	camlink;		 
} MBLIGHT;


typedef struct {
    U32 flags;			 
	F32 whviewang;		 
	F32 wvviewang;		 
	F32 whvangtan;		 
	F32 wvvangtan;		 
	F32 wihvangtan;		 
	F32 wivvangtan;		 
	F32 wwidth;			 
	F32 wheight;		 
	F32 whcenter;		 
	F32 wvcenter;		 
    F32 frontclip;
    F32 backclip;
    F32 ambient;
    F32 ambientrgb[3];
} MBWININFO;


typedef struct {
    PALDEF	*palette;		 
    TEXDEF	*texture;
	U16		texIndex;		 
    S16	X,Y;
    U16 Z;					 
    S16 Width,Height;
    U8	alpha;
	U8	Flags;				 
	S8	Hide;				 
    S16 top,bot,left,right;  
	U16 color;				 
} BlitInstance, BLITINSTANCE;


typedef struct
{
	U8	r,g,b,a;
} COLOR;


 






















typedef struct
{
    U32 	flags;			 
    MATRIX	*mat;			 
	F32		scale;			 
    S16		index; 			 	
    S16 	child;			 
    S16 	next[1 ]; 			 
	TEXDEF	*texture[4];	 
	PALDEF	*palette;		 
	COLOR	color;			 
} OBJINSTANCE;








typedef struct
{
	S16 	nverts;						 
	U16 	flags;						 
	S16		texidx;						 
	S16		unused;
	Vtx		verts[4 ];	 
} POLYINST;


extern 	OBJINSTANCE ObjInstanceList[];
extern 	MBWININFO 	ZoidWinInfo[1 ];
extern	S16			arenaActive;					 
extern	S16			arenaDlIndex[4 ][2];	 


void ZOID_Reset(void);
void ZOID_Init(void);
S16 ZOID_FindObjInstance(char *name);
S16 ZOID_ObjParent(S16 objnum);
S16 ZOID_ObjPrevObj(S16 objnum, S16 cam);
S16 ZOID_LastSibling(S16 objnum, S16 camlink);
void ZOID_InsertObject(S16 objnum, S16 parent, S16 camlink);
S16 ZOID_AddObject(S32 objidx, MATRIX *mat, S16 camlink, S16 parent, U32 flags);
void ZOID_RemoveObject(S16 objnum);
U32 ZOID_UpdateObject(S32 objnum, MATRIX *mat);
void ZOID_SetObjectDef(S16 objnum, S16 def);
void ZOID_SetObjectParent(S16 objnum, S16 newparent, U16 camlink);
void ZOID_EndFrame(void);
MBWININFO *ZOID_InitializeWindow(int idx, F32 hang, F32 vang, int parallel);
MBWININFO *ZOID_SetWindow(F32 hangle, F32 vangle, U32 winidx);
MBWININFO *ZOID_GetWindow(int winidx);
void ZOID_ProjectWindow(int widx, F32 point[3], MATRIX *mat, F32 *body, S16 screen[2]);
void ZOID_WindowTo3D(int widx, S16 screen[2], MATRIX *mat, F32 zdist, F32 point[3]);

void ZOID_SetAmbient(int idx, F32 ambient, const F32 *rgb);
void ZOID_SetBGColor(U16 rgb555);
U32 ZOID_ObjectFlags(S16 objnum);
U32 ZOID_SetObjectFlags(S32 objnum, U32 flags);

void ZOID_BuildCullingList(F32 *min, F32 *max, S16 dlindex);

void ZOID_SetColor(S16 objnum, COLOR *col);
void ZOID_SetPalette(S16 objnum, PALDEF *pal);
void ZOID_SetTexture(S16 objnum, TEXDEF *tex, int lod);
void ZOID_SetROMLODTexture(U16 mbidx, U16 texidx, int lod);

void ZOID_UpdateBlit(int bl_idx, int texIndex, TEXDEF *texture, PALDEF *palette, int x, int y, int width, int height);
void ZOID_CropBlit(int bl_idx, int top, int bot, int left, int right, U16 color);
void ZOID_SetBlitData(int bl_idx, int hide, int alpha, U16 z);
int ZOID_AddBlit(int texIndex, TEXDEF *texture, PALDEF *palette, int x, int y, int width, int height);
void ZOID_RemoveBlit(int bl_idx);
void ZOID_ReorderBlits(void);
void ZOID_FlipBlit(int bl_idx, int flip);
void ZOID_ColorBlit(int bl_idx, int tl, int tr, int bl, int br);

POLYINST *ZOID_NewPoly(int nverts, F32 xyz[][3], S16 texidx, COLOR *color, U16 flags);
void ZOID_UpdatePoly(POLYINST *poly, int nverts, F32 xyz[][3], S16 texidx, COLOR *color, U16 flags);
void ZOID_HidePoly(POLYINST *poly);
void ZOID_ShowPoly(POLYINST * poly);
void ZOID_RemovePoly(POLYINST * poly);

int ZOID_ChangeTexture(U32 romobjidx, U32 lod, S32 polyidx, U32 texidx);
int ZOID_ChangeXlu(U32 romobjidx, U32 lod, S32 polyidx, U32 xlu);

U32 ZOID_GetTextureAddr(U32 texidx);
void ZOID_SetTextureAddr(U32 texidx, U32 addr);
void ZOID_CopyTexture(U32 srcidx, U32 dstidx);

void ZOID_ChangeObjectTextureAddr(S32 objidx, char *dest, char *src, int lod, S16 skip);

void ZOID_InitLights(F32 ambient);
void ZOID_SetupLight(int idx, F32 vec[3], F32 rgb[3], S16 camlink);
U32 ZOID_AddLight(F32 vec[3], F32 rgb[3], S16 camlink);
void ZOID_DeleteLights(void);
void ZOID_AdjustLights(void);



# 5 "c:/WayneWork/mbox.h" 2









typedef struct
{
	ROMOBJECT	*RomObjDefs;
	S32		Count;
} ROMOBJDEF_LIST;


typedef struct
{
	OBJDEF	*ObjDefs;
	S32		Count;
} OBJDEF_LIST;


typedef struct
{
	OBJANIM *ObjAnims;
	S32		Count;
} OBJANIM_LIST;


typedef struct
{
	TEXDEF	*TexDefs;
	S32		Count;
} TEXDEF_LIST;


typedef struct
{
	PALDEF	*PalDefs;
	S32		Count;
} PALDEF_LIST;


typedef struct
{
	void (*animfunc)(S32 mbidx, S32 dlidx,OBJANIM *oanim);
} MBOXANIMFUNC;









enum
{
	HIDE_ALL = 0,		 
	HIDE_ONLY,			 
	HIDE_EACHCHILD,		 
	HIDE_RECURSIVE		 
};


enum
{
	SHOW_ALL = 0,		 
	SHOW_EACHCHILD,		 
	SHOW_RECURSIVE		 
};


enum
{
	XLU_ONLY = 0,		 
	XLU_CHILDREN,		 
	XLU_RECURSIVE		 
};


extern ROMOBJDEF_LIST	romobjdef_ptrs[16 ];
extern OBJDEF_LIST     	objdef_ptrs[16 ];
extern OBJANIM_LIST    	objanim_ptrs[16 ];
extern TEXDEF_LIST     	texdef_ptrs[16 ];
extern PALDEF_LIST     	paldef_ptrs[16 ];


S16 MBOX_NewObject(S32 obj, MATRIX *mat, S32 parent, U32 flags);
void MBOX_UpdateObject(S32 dlidx, MATRIX *mat);

S32 MBOX_GetMBIndex(S32 dlidx);
S32 MBOX_GetChild(S32 dlidx);
S32 MBOX_GetNext(S32 dlidx);
void MBOX_HideObject(S32 dlidx, int mode);
void MBOX_ShowObject(S32 dlidx, int mode);
void MBOX_ChangeXlu(S16 dlidx, U32 xlu, int mode);
char *MBOX_GetObjectName(int mbidx);
F32 MBOX_GetObjectRadius(int mbidx);
S32 MBOX_FindObject(const char *string);
void MBOX_ObjectAnimation(S32 obj, S32 dlidx);
U32 MBOX_GetObjectAnimInfo(const char *string, OBJANIM **anim);
char *MBOX_GetTextureName(int tidx);
TEXDEF	*MBOX_FindTexture(const char *name, U16 *index);
PALDEF	*MBOX_FindPalette(const char *name, U16 *index);



# 5 "c:/WayneWork/blit.h" 2



typedef struct _Blit
{
	const	char	*Name;
	PALDEF	*palette;
	TEXDEF	*texture;
	U16		TexIndex;
	S16		X,Y;
	U16		Z;
	S16		Width,Height;
	U08		Alpha;
	S08		Hide;
	S16		Top,Bot,Left,Right;
	S16		color; 					 
	int		(* AnimFunc)(struct _Blit *blit);
	U32		AnimID;
	S32 	AnimDTA;
	U16		BLIdx;
	void 	*data;					 
	struct _Blit *child;
} Blit,BLIT;


typedef struct
{
	const char *texname;			 
	S16 dulx,duly,width,height;		 
	S16 top,bot,left,right;			 
									 
	U16 zdepth;						 
	U8	alpha;						 
	U8 	ctlflags;					 
	int (* animfunc)(Blit *blit);	 
	S32 animid;						 
} MULTIBLIT;


 
void InitBlits(void);
void RemoveBlit(Blit *dbp);
void MoveBlitIdx(int from, int to);
void	DumpBlits(void);
void DrawBlits(void);
void InitBlit(Blit *blit);
void UpdateBlit(Blit *blit);
Blit *NewBlit(const char *name, int x, int y);
Blit *NewBlitRect(int x, int y, int width, int height, COLOR *color);
Blit *NewBlitRectNoClip(int x,int y,int w,int h,COLOR *c);
void RenameBlit(Blit *blit, const char *name, int preserve);
void SelectBlit(BLIT *blt, int index, int hSize, int vSize);
BLIT *NewMultiBlit(S16 ulx, S16 uly, const MULTIBLIT *mblit, S16 nblits);
void hideBlit(BLIT *blt);
void showBlit(BLIT *blt);
void MultiBlitHide(BLIT *blt);
void MultiBlitShow(BLIT *blt);
void MultiBlitMove(BLIT *blt, S16 dx, S16 dy);

extern TEXDEF * const TexTable;



# 1 "c:/WayneWork/U64attract.h" 2


void U64Attracts(U16 mode);
void attSetControls(void);
void attResetControls(void);
void initGameOptions(void);

extern U16 att_controls;
extern	U16	changed_options;

typedef struct
{
	u8	sfx;
	u8	announcer;
	u8	music;
	u8	crowd;
} GOPT;

 
 






























 
 







 

 
 

 




















extern char *nickname[];
extern Blit *atit_blits[];
void	TitleBlit(int show);
void	ShowHiscoreTitle(int number);

# 14 "c:/WayneWork/pfs.c" 2

# 1 "c:/WayneWork/main.h" 1




void OncePerFrame(void);

void OncePerFrame_NoPause(void);


void Process3D(S16 game);

void wayne_main(void);






# 15 "c:/WayneWork/pfs.c" 2

# 1 "c:/WayneWork/controls.h" 1



# 1 "c:\\n64\\include\\PR/os.h" 1

 



















 








# 979 "c:\\n64\\include\\PR/os.h"

# 4 "c:/WayneWork/controls.h" 2


# 1 "c:/WayneWork/gamedefs.h" 1




enum {
	MODE_ATTRACT=0,
	MODE_GAME=1,
	MODE_GETNAME,
	MODE_SELECT,
	MODE_CHALLENGE,
	MODE_ENDOFPERIOD,
	MODE_FACEOFF,
	MODE_SCORE,
	MODE_STATS,
	MODE_HISCORE,
	MODE_FIGHT,
	MODE_PENALTY
};







 
 
 











# 6 "c:/WayneWork/controls.h" 2

# 1 "c:/WayneWork/programmer.h" 1







# 7 "c:/WayneWork/controls.h" 2






typedef struct {			 
	F32 ctlupdate;				 
	
	 
	F32 joy[3];					 
	F32 cjoy[3];				 
	S16 joyactive;				 
	S16 shot;					 
	S16 pass;					 
	S16 check;					 
	F32 shottime;				 
	F32 tndm;					 
	F32 tljoy;					 
}CONTROL;



typedef struct {			 
	VS8 swstatebuf[8 ];	 
	VF32 swtimebuf[8 ];	 
	 
	U32 car_flags;				 
	F32 car_initial;			 
	F32 car_repeat;				 
	F32 car_time;				 
}SWITCH;

 












 
 
# 64 "c:/WayneWork/controls.h"












 









 




 
















 
enum {
	P1JOYLID,P1JOYRID,P1JOYUID,P1JOYDID,P1SHOTID,P1PASSID,P1CHECKID,P1STARTID,P1BBUTID,P1CBUTID,P1EBUTID,P1LEFTBID,P1RIGHTBID,P1TRIGID,
	P2JOYLID,P2JOYRID,P2JOYUID,P2JOYDID,P2SHOTID,P2PASSID,P2CHECKID,P2STARTID,P2BBUTID,P2CBUTID,P2EBUTID,P2LEFTBID,P2RIGHTBID,P2TRIGID,
	P3JOYLID,P3JOYRID,P3JOYUID,P3JOYDID,P3SHOTID,P3PASSID,P3CHECKID,P3STARTID,P3BBUTID,P3CBUTID,P3EBUTID,P3LEFTBID,P3RIGHTBID,P3TRIGID,
	P4JOYLID,P4JOYRID,P4JOYUID,P4JOYDID,P4SHOTID,P4PASSID,P4CHECKID,P4STARTID,P4BBUTID,P4CBUTID,P4EBUTID,P4LEFTBID,P4RIGHTBID,P4TRIGID
};

typedef struct {
	F32 maxtime;			 
	F32 holdtime;			 
	F32 dmdelay;			 
	const S16 *spactive;	 
	SPENTRY **spentry;		 
	S32 moveid;				 
	const char *name;
}SPMOVE;


extern 	VU16 	OS_ctl_levels[];
extern 	VU16 	OS_ctl_edges[];
extern	VS8		analog_inputs[4 ][2];
extern	VS8 	use_analog_inputs[4 ];

extern 	volatile F32 	CTLTIME;						 

extern	S16		shotbutton[4];							 
extern	S16		shot2button[4];						 
extern	S16		passbutton[4];							 
extern	SPENTRY kneel_lists[4][4];				 
extern	SPENTRY steal_lists[4][4];				 
extern	SPENTRY burst_lists[4][4];				 
extern	SPENTRY onetimer_lists[4][4];			 
extern	SPENTRY dive_lists[4][4];				 
extern	SPENTRY check_lists[4][4];				 
extern	SPENTRY trip_lists[4][4];				 
extern	SPENTRY hook_lists[4][4];				 
extern	SPENTRY hotshot_lists[4][4];			 
extern	SPENTRY playersw_lists[4][4];
extern	SPENTRY camerasw_lists[4][4];
extern	U8		changed_lists[4];				 


# 172 "c:/WayneWork/controls.h"
























# 1 "c:/WayneWork/player.h" 1



typedef struct player PLAYER;


# 1 "c:/WayneWork/anim.h" 1



typedef struct anim ANIM;
typedef struct animseqinfo ANIMSEQINFO;
typedef struct animseqinfo ANIMSEQ;					 
typedef struct animkey ANIMKEY;
typedef struct animseqheader ANIMSEQHEADER;
typedef struct animdesc ANIMDESC;

typedef struct animheader ANIMHEADER;
typedef struct animinfo ANIMINFO;
typedef struct animobj ANIMOBJ;

typedef struct partdesc PARTDESC;

 


 



















 
 
struct anim		
{
	F32	value;		 
};

 
 
struct animseqinfo
{
	U16	type;		 

	U16 size;		 
	U32 animidx;	 
};

 
struct animseqheader
{
	U08 keys;		 
	U08 control;	 
	U16 keyidx;		 
};

 
struct animkey
{
	U08 key;
};

struct animdesc
{
	char desc[32];
};

struct partdesc
{
	F32 pos[3];
	char desc[16];
	char parent[16];
	char objname[16];
};

 
 
struct animheader {
	F32 *CompressAng;
	F32 *CompressPos;
	F32 *CompressUnit;
	ANIM *blocks;
	ANIMSEQ *seqs;
	ANIMSEQHEADER *seqheader;
	ANIMKEY *keys;
	ANIMDESC *objdescs;
	S32 numseqs;
	S32 numobjs;
	S32 numjoints;
	S32 numsites;
};

 
struct animinfo {
	F32 *CompressAng;
	F32 *CompressPos;
	F32 *CompressUnit;
	ANIM *blocks;				 
	ANIMSEQHEADER *seqheader;	 
	ANIMKEY *keys;				 
	ANIMHEADER *header;			 
	S16 numseqs;				 
	S16 animseq0;				 
	S16 animseq;				 
	S16 transkey;				 
	S16	save0;					 
	S16 unused;
	F32 frac;					 
	S16 idx0;					 
	S16 idx1;					 
	S16 setpanim;				 
	S16 mirror;					 
	 
	S16 active;					 
	U16 prevkey;				 
	F32 starttime;				 
	F32 transtime;				 
	F32 scale;					 
	F32 atime;	
	S16 repeat;					 
	U16 stage;					 
};

struct animobj {
	S16 mbidx;					 
	S16 dlidx;					 
	MATRIX mat;					 
	F32 initpos[3];				 
	struct animobj *next;		 
	struct animobj *child;		 
	struct animobj *parent;		 
	ANIMSEQ	*seq;				 
	S16 pidx;					 
	F32 pyrq[4];				 
	F32 tpyrq[4];				 
	F32 ppos[3];				 
	F32 tpos[3];				 
	S32 objnum;					 
	struct objinfo *objinfo;
};

 
void AnimFixPos(ANIMOBJ *child, ANIMOBJ *parent, ANIMINFO *info);
int AnimateObj(ANIMOBJ *animobj, ANIMINFO *info, int update);
void FreezeAnim(ANIMINFO *info);
void UnFreezeAnim(ANIMINFO *info);
int AnimateTree(ANIMINFO *info, ANIMOBJ *root, int nextseq, int frame, F32 time, int interrupt, int update);
int AnimateTreeFrameInterp(ANIMINFO *info, ANIMOBJ *root, S16 seq, S16 frame0, S16 frame1, F32 frac, int update);
int AnimateTreeFrame(ANIMINFO *info, ANIMOBJ *root, S16 seq, S16 frame, int update);
int AnimateTreeFrameInterp2(ANIMINFO *info,ANIMOBJ *root,
							S16 seq0, S16 seq1, S16 frame0, S16 frame1, F32 frac, int update);
void InitAnimObjs(void);
void RemoveAnimObjParent(ANIMOBJ *animobj, S16 parentdlidx);
void RemoveAnimObj(ANIMOBJ *obj);
void RemoveAnimTree(ANIMOBJ *root);
void AddAnimObj(ANIMOBJ *obj, S32 parentidx, U32 dlflags);
void AddAnimTree(ANIMOBJ *obj, ANIMOBJ *parent, U32 dlflags, F32 *parpos);
void ResetAnimObj(ANIMOBJ *obj);
ANIMOBJ *NewAnimObj(char *objname, S16 objnum, ANIMHEADER *header);
void InsertAnimObj(ANIMOBJ *animobj, ANIMHEADER *header, S32 idx);
ANIMOBJ *BuildAnimTree(PARTDESC *parts, ANIMHEADER *header);
int InitAnim(ANIMINFO *info, int seq, int transframe, F32 transtime, int active);
void SetupAnimHeader(U32 addr, ANIMHEADER *new);
int GetAnimObjIdx(ANIMHEADER *header, const char *name);
char *GetAnimObjName(ANIMHEADER *header, int idx);
int GetPartIdx(PARTDESC *parts, const char *name);
ANIMOBJ *AnimTreeObj(ANIMHEADER *header, ANIMOBJ *root, const char *name);
void InitAnimInfo(ANIMHEADER *header, ANIMINFO *info, int mirror);
void SetAnimObjParent(ANIMOBJ *child, ANIMOBJ *parent);

extern F32 ATime;
extern ANIMOBJ *NewAnimobjs[24 ];







# 7 "c:/WayneWork/player.h" 2

# 1 "c:/WayneWork/animstate.h" 1



 
 
 
 
 
 

 
 




 
 
typedef struct seq {
	S16 idx;        
	U08 frame;      
	U08 time;       
} SEQ;

typedef struct animstate {
	SEQ sequence;   
	U16 special;    
	U16 intcurseq;  
}ANIMSTATE;

typedef struct animseqtrans {
	SEQ nextseq;    
	U16 special;    
	U16 interrupt;  
	U16 repeat;     
	U08 mirror;     
	U08 fixpos;     
	U16 xidx;       
	U16 xcount;     
} ANIMSEQTRANS;

typedef struct animexception {
	U32 state;      
	SEQ sequence;   
	U16 special;    
	U16 intcurseq;  
} ANIMEXCEPTION;

typedef struct desc32 {
	char desc[32];
} DESC32;

typedef struct stateheader {
	S32	nstates;
	S32	nseqs;
	S32	nfuncs;
	S32 firstfunc;
	S32	statedescs;		 
	S32	seqdescs;		 
	S32	funcdescs;		 
	S32 astates;		 
	S32 aseqtrans;		 
	S32 aexceptions;	 
} STATEHEADER;

typedef struct stateinfo {
	S32	nstates;
	S32	nseqs;
	DESC32 *statedescs;
	DESC32 *seqdescs;
	ANIMSTATE *astates;
	ANIMSEQTRANS *aseqtrans;
	ANIMEXCEPTION *aexceptions;
	S32 *astatelookup;		 
	S32 *astatelookupm;		 
} STATEINFO;

# 1 "c:/WayneWork/player.h" 1
# 209 "c:/WayneWork/player.h"

# 78 "c:/WayneWork/animstate.h" 2

# 1 "c:/WayneWork/Player1states.h" 1





typedef struct statetable {
	S32 state;
	char desc[28];
	char mirror[28];
} STATETABLE;

extern const STATETABLE Player1StateTable[];
extern const STATETABLE GoalieStateTable[];

enum {
	PATREST = 0,
	ATREST,
	WATREST,
	PGLIDE,
	GLIDE,
	PSTOPRIGHT,
	PSTOPLEFT,
	STOPLEFT,
	STOPRIGHT,
	BSTOP,
	PSTOPSLOW,
	STOPSLOW,
	WSTOPSLOW,
	PPIVOTLEFT,
	PPIVOTRIGHT,
	PIVOTLEFT,
	PIVOTRIGHT,
	WPIVOTLEFT,
	WPIVOTRIGHT,
	PTURNRIGHT,
	PTURNLEFT,
	TURNLEFT,
	TURNRIGHT,
	BTURNLEFT,
	BTURNRIGHT,
	TRANSRBTF,
	TRANSRFTB,
	TRANSLBTF,
	TRANSLFTB,
	PACCEL,
	ACCEL,
	BACCEL,
	WACCEL,
	WPACCELL,
	WPACCELR,
	HOOKGETUP,
	GETUPBACK,
	GETUPFRONT,
	GETUPBACKL,
	GETUPBACKR,
	CHKDFHRD,
	CHKDKHRD,
	CHKDLHRD,
	CHKDRHRD,
	CHKDFPWR,
	CHKDKPWR,
	CHKDLPWR,
	CHKDRPWR,
	CROSSCHECK,
	TRIPF,
	TRIPPED,
	SLAPSHOT,
	WRISTSHOT,
	FLIPSHOT,
	SNAPSHOT,
	QWRISTSHOT,
	KPUCKL,
	KPUCKR,
	PLYRCOLF,
	PLYRCOLK,
	PLYRCOLL,
	PLYRCOLR,
	REACHF,
	REACHR,
	REACHL,
	SIDESLAPR,
	SIDESNAPR,
	SIDESLAPL,
	SIDESNAPL,
	SIDEWRISTR,
	SIDEWRISTL,
	SCORE1,
	SCORE2,
	SCORE3,
	SCORE4,
	RELEASESHOT,
	ABORTSHOT,
	PASSFORWARD,
	PASSLEFT,
	PASSRIGHT,
	PASSBACKL,
	PASSBACKR,
	FATRESTL,
	FATRESTR,
	FPASSLEFT,
	FPASSRIGHT,
	REFATREST,
	REFREADY,
	RSTOP,
	RACCEL,
	REFDROP,
	REFGLIDE,
	FIGHTREADY,
	FIGHTTHROW,
	JABR,
	JABRREACT,
	JABL,
	JABLREACT,
	PUNCHR,
	PUNCHRREACT,
	PUNCHL,
	PUNCHLREACT,
	UPCUT,
	UPCUTREACT,
	GRAB,
	GRABPUNCH,
	GRABPUNCHREACT,
	COMB1,
	COMB1REACT,
	COMB2,
	COMB2REACT,
	DAZE,
	KNOCKOUT,
	KNOCKOUTHIT,
	TAUNT,
	TAUNT2,
	TAUNT3,
	VICTORY,
	CHALLENGE,
	MOPE1,
	MOPE2,
	MOPE3,
	HOOK,
	HOOKED,
	DIVEL,
	DIVER,
	KNEESAVE,
	KNEEGETUP,
	HITWALLF,
	HITWALLL,
	HITWALLR,
	HITWALLK,
	CHKDFSFT,		
	CHKDKSFT,		
	CHKDLSFT,		
	CHKDRSFT,		
 
 
 
 
 
 
 
 
 
 
	LAST_STATE
};

enum {
	GATREST = 0,
	TOPLEFT1,
	MIDLEFT1,
	BOTTOMLEFT1,
	BOTTOMLEFT2,
	BOTTOMLEFT3,
	TOP1,
	MID1,
	FIVEHOLE1,
	FIVEHOLE2,
	TOPRIGHT1,
	MIDRIGHT1,
	BOTTOMRIGHT1,
	BOTTOMRIGHT2,
	BOTTOMRIGHT3,
	GPASS1,
	GPOKEFORWARD,
	GPOKEFORWARD2,
	GSOB,
	GSOB2,
	GSOB3,
	GACCEL,
	GBACCEL,
	GSHUFFLEL,
	GSHUFFLER,
	GCHECKF,
	GCHECKL,
	GCHECKR,
	GSOFTCHECKL,
	GSOFTCHECKR,
	GSOFTCHECKF,
	GTAUNT,
	GSPLITS,
	GHITWALL,
	GCOVER,
	GFLOP,
	GSIT,
	LAST_GSTATE
};


# 79 "c:/WayneWork/animstate.h" 2


 

extern S32 Player1StateLookup[LAST_STATE];
extern STATEINFO Player1StateInfo;
extern DESC32 *Player1StateDescs;
extern DESC32 *Player1SeqDescs;

extern S32 GoalieStateLookup[LAST_STATE];
extern STATEINFO GoalieStateInfo;

 
char *AnimStateDesc(STATEINFO *stateinfo, S16 state, S16 mirror);
ANIMEXCEPTION *CheckAnimExceptions(ANIMEXCEPTION *exception, S16 base, S16 count, S16 dstate);
void InitAnimation(void);
int ProcessAnim(PLAYER *pp);
S32 AnimBeginShot(PLAYER *pp);
S32 AnimTriggerShot(PLAYER *pp);
S32 AnimTriggerPass(PLAYER *pp);
S32 AnimBackswing(PLAYER *pp);
S32 AnimDoStop(PLAYER *pp);
S32 AnimDoStopSlow(PLAYER *pp);
S32 AnimGoaliePass(PLAYER *pp);
S32 AnimForwards(PLAYER *pp);
S32 AnimBackwards(PLAYER *pp);
S32 FindFunc(STATEHEADER *header, char *s);
void AddAnimFunc(STATEHEADER *header, char *s, S32 (*func)(PLAYER *));
void InitAnimSeqTrans(void);
S16 AnimSeqIdx(char *s);
void BuildPlayer1StateTable(STATEHEADER *header);
void BuildGoalieStateTable(STATEHEADER *header);


# 8 "c:/WayneWork/player.h" 2

# 1 "c:/WayneWork/camera.h" 1









enum							 
{
	CAM_LOWSIDE,
	CAM_MEDIUMSIDE,
	CAM_HIGHSIDE,
	CAM_RIGHTGOAL1,
	CAM_RIGHTGOAL2,
	CAM_LEFTGOAL1,	
	CAM_LEFTGOAL2,
	MAX_CAMERAS					 
};

 

typedef struct {			 
	MATRIX mat;					 
	F32	mtx[4][4];				 
	F32 focus[3];				 
	S32 mode;					 
	S32	dir;					 
	F32 v[3];					 
	F32 sqmagv;					 
	F32 yaw;					 
	F32 pitch;					 
}CAMERA;

 



 
void CAMERA_Update(void);
void CAMERA_Init(const F32 campos[3], const F32 focus[3], void (*camfunc)());
void CAMERA_State(S32 state, void (*camfunc)());
void CAMERA_Hockey(int init);
void CAMERA_FaceoffZoom(int init);
void CAMERA_Faceoff(int init);
void CAMERA_Fight(int init);
void CAMERA_Scored(int init);
void CAMERA_Replay(int init);
void DroneCam(int init);
void PlayerCam(int init);
void SetupCamTarget(const F32 *eye, const F32 *target, const F32 *roll, int init);
void TargetCam(int init);
void JoyCAM(int init);
void JoystickCamera(F32 speed, F32 speeda, F32 *zDist, int replay);
void PuckCAM(int init);
void ChallengeCAM(int init);
void LowHorizCAM(int init);
void MedHorizCAM(int init);
void HighHorizCAM(int init);
void HomeZCam(int init);
void AwayZCam(int init);
void ToggleCamera(void);
void	U64_UpdateCamera(void);
void	ResetCamera(F32 pos[3], F32 focus[3]);


enum {
	XCAM=0,						 
	NXCAM,						 
	LOWHORIZCAM = NXCAM,		
	ZCAM,						 
	AWAYZCAM = ZCAM,
	LEFTGOALCAM = ZCAM,
	NZCAM,						 
	HOMEZCAM = NZCAM,
	RIGHTGOALCAM = NZCAM,
	PLAYERCAM,					 
	JOYCAM,						 
	PUCKCAM,					 
	MEDHORIZCAM,				 
	HIGHHORIZCAM,				 
	GPCAM,
	TGTCAM
};

enum {
	XDIR=0,						 
	NXDIR,						 
	ZDIR,						 
	NZDIR						 
};

extern	CAMERA Camera;							 
extern	S16		cameraView;						 
extern	S16		cameraDefault;					 
extern	S16		cameraToggle;					 
extern	S16		CAMERA_smooth;					 
extern	void 	(*CAMERA_Function)(int init);	 
extern	void 	(*CAMERA_default)(int init);
extern	void 	(*CAMERA_toggle)(int init);
extern	void 	(*cameras[])(int init);			 
extern	char	*cameraMsgs[1 ][7];	 


# 9 "c:/WayneWork/player.h" 2

# 1 "c:/WayneWork/physics.h" 1



typedef struct physics PHYSICS;




struct physics {	 
	F32 time;					 
	F32 dt;						 
	F32 V[3];					 
	F32 RWV[3];					 
	F32 F[3];					 
	F32 TF[3];					 
	F32 D[3];					 
	F32 A[3];					 
	F32 W[3];					 
	F32 GRW[3];					 
	F32 G[3];					 
	F32 mass;					 
	F32 invmass;				 
	F32 Vmag;					 
	MATRIX mat;					 

	 
	F32 vyaw;					 
	F32 pyaw;					 
	F32 jyaw;					 
	F32 dyaw;					 
	F32 yawref;					 
	S32 flags;					 
};



# 1 "c:/WayneWork/player.h" 1
# 209 "c:/WayneWork/player.h"

# 37 "c:/WayneWork/physics.h" 2

# 1 "c:/WayneWork/puck.h" 1






 

# 1 "c:/WayneWork/dobjs.h" 1









typedef struct dobj {		 
	S16 mbidx;					 
	S16 dlidx;					 
	MATRIX mat;					 
	S32 animarg;				 
	S32 lstate;					 
	F32 time;					 
	struct dobj *(*anim)(struct dobj*,S16); 
}DOBJ;


 
void InitMoveables(void);
void AddObject(DOBJ *dbp, S32 parent, U32 dlflags);
DOBJ *NewMoveableObject(const char *objname, char *errmsg, DOBJ *(*anim)(DOBJ*,S16), int animarg);
void RemoveMoveable(DOBJ *dbp);
void AnimateMoveables(void);
void HideMoveable(DOBJ *dobj);
void ShowMoveable(DOBJ *dobj);
void PrintMoveables(S16 x, S16 sy);

extern DOBJ *RootObj;


# 9 "c:/WayneWork/puck.h" 2






typedef struct af_physics {	 
	F32 time;					 
	F32 dt;						 
	F32 V[3];					 
	F32 RWV[3];					 
	F32 F[3];					 
	F32 TF[3];					 
	F32 D[3];					 
	F32 A[3];					 
	F32 W[3];					 
	F32 GRW[3];					 
	F32 G[3];					 
	F32 mass;					 
	F32 invmass;				 
	F32 Vmag;					 
	MATRIX mat;					 

	 
	F32 vyaw;					 
	F32 pyaw;					 
	F32 jyaw;					 
	F32 dyaw;					 
	F32 yawref;					 
	S32 flags;					 
} PUCK_PHYSICS;


typedef struct {			 
	S32 surf;					 
	MATRIX mat;					 
} PUCK_COLLIDE;

# 58 "c:/WayneWork/puck.h"











typedef struct puck {			 
	ANIMOBJ *puk;				 
	void *owner;				 
	void *hitter;				 
	void *hitplayer;			 
	void *lastowner;			 
	void *passreceiver;		 
	PUCK_PHYSICS physics;			 
	PUCK_COLLIDE collide;			 
	F32 lpos[3];				 
	S16 towner;					 
	S16 powner;					 
	S32 flags;					 
	F32 tlhit;					 
	F32 ctime;					 
	F32 tlposess;				 
	F32 radius;					 
	F32 drad;					 
	F32 vpitch;					 
} PUCK;

# 112 "c:/WayneWork/puck.h"









typedef struct shotacc {
	F32 base;
	F32 anglemod;
	F32 timemod;
	F32 power;
} SHOTACC;














extern PUCK Puck;					 
extern DOBJ *PuckShadow;
extern DOBJ *PuckArrow;
extern DOBJ *FlamingGoalObj;		 

extern	F32	puckpos[3];			 


 




 
enum
	{
	PUCKSTATE_LOOSE,
	PUCKSTATE_PASS,
	PUCKSTATE_SHOT,
	PUCKSTATE_OWNED
	};

 
void	PuckColorCycle(void);
void ShrinkPuck(F32 ppos[3], F32 biguvs[][3], F32 shrinkuvs[][3]);
void HitPuck(PLAYER *pp, F32 dir[3], F32 amt);
void NewPuckOwner(PLAYER *pp);
F32 OptimalShotTime(S32 shot);
F32 ApproximateShotBase(PLAYER *pp);
void PrintShotBase(PLAYER *pp);
int GetShotTarget(PLAYER *pp, F32 target[3], S16 shot, F32 *maxpower);   
int ShootThePuck(S16 shot);   
void PassThePuck(PLAYER *who);
void PuckInGoal(PUCK *puk);
DOBJ *FlamingGoal(DOBJ *dobj, S16 init);
void	SetFlamingGoal(int status);
void AnimatePuck(void);
int JoyPuck(void);
void KeepPuckOutOfGoal(void);
void ResetPuck(int init);
void InitPuck(void);
void InitPuckShadow(void);
ANIMOBJ *MakePuck(void);
void AttatchPuck(PLAYER *pp);
void DetatchPuck(PLAYER *pp, S16 removeparent);
void ShotOnGoal(int team,int score,int gteam, PLAYER *gp);
void POdebug(int on);
int PuckOwnershipRules(PLAYER *pp);
int PuckCollisionRules(PLAYER *pp);
void	StreakUpdate(void);
void	PuckFlameUpdate(void);




int	puckState(void);
void ShotOnGoal(int hitteam,int score,int gteam,PLAYER *goaliePlayer);

# 38 "c:/WayneWork/physics.h" 2

# 1 "c:/WayneWork/collide.h" 1



typedef struct bodycol BODYCOL;
































typedef struct colpart {
	U32 parts;		 
	U32 distpart;	 
	F32 dist;		 
	F32 vec[3];		 
} COLPART;

 

struct bodycol {
	U32 type;		 
	COLPART body,rarm,larm,stick,legs;
};

# 1 "c:/WayneWork/player.h" 1
# 209 "c:/WayneWork/player.h"

# 51 "c:/WayneWork/collide.h" 2

 
void SetupPuckBalloon(void);
void SetupCollisions(void);
void InitBodyCol(BODYCOL *bodycol);
void AddCBodyPart(COLPART *source, COLPART *dest);
F32 PointPointDist(F32 *pt1, F32 *pt2);
F32 PointPointDistXZ(F32 *pt1, F32 *pt2);
ANIMOBJ *GetColObj(ANIMOBJ *animobj, U32 puckcol);
int PuckCollide(PLAYER *pp);
void DoBodyCollisions(void);
F32 PointLineCollision(const F32 *cp, const F32 *pt1, const F32 *pt2, F32 *res);
F32 PointLineCollision2D(const F32 *cp, const F32 *pt1, const F32 *pt2, F32 *res);
void PrintCollisions(PLAYER *pp);
int PathIntersection(const F32 p1a[3], const F32 p1b[3], const F32 p2a[3], const F32 p2b[3], F32 ip[3]);
F32 LineLineCollision2D(const F32 p1a[3], const F32 p1b[3], const F32 p2a[3], const F32 p2b[3], F32 res[3]);


# 39 "c:/WayneWork/physics.h" 2

# 1 "c:/WayneWork/rink.h" 1




# 1 "c:/WayneWork/macros.h" 1







 





 





 



 







# 5 "c:/WayneWork/rink.h" 2


# 1 "c:/WayneWork/terrain.h" 1





typedef struct {		 
	F32 x,z;				 
}TVERTEX;

typedef struct {		 
	U8  surf;				 
	U8  flags;				 
	S16 nv;					 
	F32 v1[3];				 
	F32 uvs[3][3];			 
	const TVERTEX *vptr;	 
}TPOLYGON;

typedef struct {		 
	F32 sqrad;				 
	F32 min[3];				 
	F32 max[3];				 
	S16 npolys;				 
	const TPOLYGON *pdata;	 
}TOBJECT;

 



 






# 7 "c:/WayneWork/rink.h" 2




typedef struct {			 
	S32 surf;					 
	MATRIX mat;					 
} COLLIDE;


# 1 "c:/WayneWork/puck.h" 1
# 194 "c:/WayneWork/puck.h"


int	puckState(void);
void ShotOnGoal(int hitteam,int score,int gteam,PLAYER *goaliePlayer);

# 17 "c:/WayneWork/rink.h" 2



typedef struct {			 
	MATRIX initmat;				 
	MATRIX mat;					 
	TOBJECT *tobj;				 
	DOBJ *bottleobj;			 
	PUCK *bottle;				 
	DOBJ *dobj;					 
} GOAL;




extern	GOAL GoalA;
extern	GOAL GoalB;
extern	PUCK BottleA;
extern	PUCK BottleB;
extern 	F32 GoalAPos[3];
extern 	F32 GoalBPos[3];
extern 	F32 CornerOrigin[4][3];
extern 	GOAL * Goals[2];


 
 
 













extern	F32		rink_l;			 
extern	F32		rink_w;
extern	F32		rink_hl;		 
extern	F32		rink_hw;		 
extern	F32		rink_blueline;	 
extern	F32		rink_redline;	 
extern	F32		rink_odzone;	 
extern	F32		corner_radius;	 
extern	F32		corner_radius2;	 






























 
void SetRinkSizes(void);
int	OutsideRink(F32 pos[3], F32 *d);
int CloseToNet(F32 pos[3],F32 dist);
int InsideNet(F32 pA[3],F32 pB[3], F32 mindist);
void CreateWallUVS(F32 N[3], F32 uvs[3][3]);
void WallCollision(F32 spos[3], F32 epos[3], F32 wpos[3], F32 cp[3], F32 uvs[3][3]);
void CornerCollision(const F32 spos[3], const F32 epos[3], const F32 corner[3], F32 cp[3]);
void RinkCollision(int colcode, F32 spos[3], F32 epos[3], COLLIDE *col);
void InitGoals(void);




# 40 "c:/WayneWork/physics.h" 2



 
void InitPhysics(PHYSICS *phys, F32 lbs, int firsttime);
F32 ClosingVelocity(const F32 pA[3], const F32 vA[3], const F32 pB[3], const F32 vB[3], F32 u[3], F32 *dist);
F32 Intercept(PLAYER *pp, F32 pos[3], F32 rwv[3], F32 *d, F32 *v);
void ProjectPosition(PHYSICS *phys, F32 xtime, F32 pos[3]);
void PrintMotion(S16 x, S16 y, S16 motion, char *hdr);
void BufferMotion(S16 motion);
void PrintMotionBuffer(void);
void CoughUpPuck(PLAYER *pp, F32 rwv[3]);
int KickPuck(PLAYER *pp, F32 ppos[3], int kicktest);
void StopWhatImDoing(PLAYER *pp);
void DoCheck(PLAYER *p1, PLAYER *p2, int anim, F32 dyaw, int cough, int power, F32 cvel);
void CheckPlayer(PLAYER *p1, PLAYER *p2, F32 u[3], F32 cvel, int flags);
void ShovePlayer(PLAYER *pp, F32 rwv[3]);
void SetupPlayerPhysics(PLAYER *pp, int init, F32 yaw, const F32 pos[3]);
F32 GetForce(PLAYER *pp, F32 fmult);
void SpeedBurst(PLAYER *pp);
void PlayerPhysics(PLAYER *pp);
void FloorCollision(PUCK *puk);
void DeflectPuck(F32 deflect, F32 frict);
void PuckCollisions(PUCK *puk, F32 lpos[3]);
void NewPuckRotation(PUCK *puk, F32 v);
void PuckPhysics(PUCK *puk);
void SetupPuckPhysics(PUCK *puk, int init);
int CheckPhysics(PHYSICS *phys);



# 10 "c:/WayneWork/player.h" 2

# 1 "c:/WayneWork/sector.h" 1





typedef struct {			 
	S32 shotbits;				 
	S32 tgtidx;					 
	F32 slapacc;				 
	F32 snapflipacc;			 
	F32 wristacc;				 
	F32 sideacc;				 
}SECTOR;

 



























extern SECTOR SectorTable[24 ][14 ];


 
SECTOR *FindSector(F32 pos[3], S16 reverse);
void SectorTarget(SECTOR *secptr, F32 target[3], int reverse, int ongoal);
int GetSectorX(SECTOR *secptr);
int GetSectorZ(SECTOR *secptr);



# 11 "c:/WayneWork/player.h" 2

# 1 "c:/WayneWork/controls.h" 1
# 217 "c:/WayneWork/controls.h"

# 12 "c:/WayneWork/player.h" 2



# 1 "c:/WayneWork/drones.h" 1




# 1 "c:/WayneWork/kid.h" 1










typedef struct {			 
	S16 leftidx;				 
	S16 rightidx;				 
	S16 upidx;					 
	S16 downidx;				 
	S16 conaidx;				 
	S16 condidx;				 
	S16 confidx;				 
	S16 startidx;				 
	S16 conbidx;
	S16 concidx;
	S16 coneidx;
	S16 conlidx;
	S16 conridx;
	S16 congidx;
}KIDCONTROL;

typedef union
{
	KIDCONTROL kctl;
	S16 kctlarray[(sizeof(KIDCONTROL) / sizeof(S16))];
}KCTL;

 
enum
{
	SPJOYL=0,
	SPJOYR,
	SPJOYU,
	SPJOYD,
	SPCONA,
	SPCOND,
	SPCONF,
	SPSTART,
	SPCONB,
	SPCONC,
	SPCONE,
	SPCONL,
	SPCONR,
	SPCONG,
	SPMAXENTRIES
};

typedef struct			 
{
	S16 sog;					 
	S16 goals;					 
	S16 assists;				 

	S16 saved;				 



}GAMESTATS;

typedef struct
{
	S8 state;				 
	S8 position;			 
	S8 prefpos;				 
	S8 tidx;				 
	S8 unused;	
	S8 line;
	S8 gamechecks;
	S8 lastplayer;			 
	S8 pfsPak;				 
	U8 name[4];				 
	F32 saved_anger;
	const KIDCONTROL *kctl;
	PFSPLAYER *pfsplayer;	 
	CSTATS  cstats;			 
	GAMESTATS gstats;
	GAMESTATS pstats;

	void *SelectedPlayer;	 

} KIDINFO;

typedef struct
{
	const char *osarrowr;	 
	const char *osarrowl;	 
	const char *osarrowu;	 
	const char *osarrowd;	 
	const char *idcircle;	 
	const char *idcir;		 
	const char *idcirb;		 
	const char *idstr;		 
	const char *idstrb;		 
	const char *burston;	 
	const char *overtag;	 
} KIDOBJECTDATA;

typedef struct
{
	const KIDOBJECTDATA *kdata;	 
	DOBJ *idcircle;				 
	BLIT *arrow;				 
	BLIT *burstblit;			 
	BLIT *overtagblit;			 
	BLIT *nameblit;				 
	BLIT *angerblit;			 
	PALDEF *cir;				 
	PALDEF *cirb;				 
	PALDEF *str;				 
	PALDEF *strb;				 
	U16		arrowTexidx;		 
	U16		unused;
	TEXDEF *arrowr;				 
	TEXDEF *arrowl;				 
	TEXDEF *arrowu;				 
	TEXDEF *arrowd;				 
	TEXDEF *burston;			 
	TEXDEF *overtag;			 
} KIDOBJECTS;


extern const KIDCONTROL KIDcontrols[4 ];
extern COLOR KidColors[4 ];
extern U16	KidIntColors[4 ];

extern	KIDINFO Kids[4 ];
extern	KIDOBJECTS KIDobjects[4 ];


# 1 "c:/WayneWork/player.h" 1
# 209 "c:/WayneWork/player.h"

# 136 "c:/WayneWork/kid.h" 2

# 1 "c:/WayneWork/controls.h" 1
# 217 "c:/WayneWork/controls.h"

# 137 "c:/WayneWork/kid.h" 2



extern const SPMOVE * const OffensiveMoves[];
extern const int Noffmoves;
extern const SPMOVE * const DefensiveMoves[];
extern const int Ndefmoves;
extern const SPMOVE * const PuckCarrierMoves[];
extern const int Npcmoves;
extern const SPMOVE * const FightMoves[];
extern const int Nfightmoves;
extern const SPMOVE * const FaceoffMoves[];
extern const int Nfomoves;

extern	TEXDEF	*idcircleTex;
extern	TEXDEF	*idstarTex;
extern	PALDEF	*idcirDronePal0;
extern	PALDEF	*idcirDronePal1;


 
void InitControllerConfig(void);
void settoDefaultConfig(int kid);
void InitKids(void);
void InitKidStats(KIDINFO *kidp);
void ReinitKidPStats(KIDINFO *kidp);
void ReinitKidGStats(KIDINFO *kidp);
void ReinitKids(int overtime,short changeTeamsToDefault);
void ReInitKidObjects(PLAYER *pp);
void InitKidObjects(PLAYER *pp);
void ProcessKids(void);
void ResetKidsControl(const KIDCONTROL *kctl);
S32 DirtyMove(const KIDCONTROL *kctl, const SPMOVE * const dirtymoves[], int nmoves, F32 *dmtime, int knum);


# 5 "c:/WayneWork/drones.h" 2


# 1 "c:/WayneWork/polar.h" 1






# 1 "c:/WayneWork/llist.h" 1





 
 
 

typedef struct _LLNODE
{
	void *next;
} LLNODE;

typedef struct _LLIST
{
	LLNODE *head,*tail;
	U32 page_size;
	U32 max_pages;
} LLIST;

void llist_init(LLIST *buf,U32 len,U32 psize,U8 align);
void *llist_new(LLIST *ll);
void llist_prepend(LLIST *ll,void *n);
void llist_append(LLIST *ll,void *n);



# 7 "c:/WayneWork/polar.h" 2



 
typedef struct
{
	F32 d,a;
} POLAR;

 
typedef struct _ARC
{
	struct _ARC *next;
	F32 l,h;   
} ARC;







void arcset_add(LLIST *ll,ARC *a);
F32 best_angle(LLIST *ll,F32 a);
void vector_to_polar(F32 x,F32 z,POLAR *p);



# 7 "c:/WayneWork/drones.h" 2



typedef struct {
	PLAYER *jpp;			 
	F32 ptoj[3];			 
	F32 d;					 
	F32 jdtest;				 
	F32 juketime;			 
	S16 jukestate;			 
	S16 dummy;
}JUKE;

enum {
	JUKELEFT,				 
	JUKERIGHT				 
};

typedef struct {
	F32 pos[3];				 
	S32 decision;			 
}PLAYKEY;

typedef struct {
	const PLAYKEY *keys;
	S32 nkeys;
}PLAY;

typedef struct drone {		 
	F32 tnd;				 
	S16 mode;   
	S16 decision;			 
	S16 state;				 
	S16 newdecision;		 
	F32 target[3];			 
	F32 atarget[3];			 
	F32 targetv[3];			 
	F32 targetrad;   
	F32 relax;   
	S16 withintgtrad;		 
	S16 offmanidx;			 
	DOBJ *idcircle;			 
	JUKE juke;				 
	const PLAY *play;		 
	S32 playkey;			 
	F32 tofcheck;			 
	F32 tofsteal;			 
	 
	POLAR plyrpolar[2][5 ];
	POLAR goalpolar;
	PLAYER *check;   
	S8 zone[4];   
}DRONE;

enum {						 
	ONETIMER = 1,
	FS0,
	FS1,
	FS2,
	FS3
};

enum {						 
	REST,
	FREESKATE,
	PURSUIT,
	GOFORPUCK,
	SETUPFORSHOT,
	GETOPEN,
	SKATEPLAY,
	DEFEND,
	WATCHFIGHT,
	SKATE,
	IDLE
};


 
typedef struct {
	void (*bfunc)(PLAYER *pp);
	char const *desc;
}BEHAVEFUNC;

 
enum {
	BEHINDNET,
	GETPUCK,
	GUARDNET,
	OFORWARD,
	POINTMAN,
	STAYOPEN,
	OFFBEHAVIORS
};

 
enum {
	DEFNULL,
	CHECK,
	DEFENDGOAL,
	DEFENDZONE,
	PENALTYKILL,
	KILLZONE,
	DEFBEHAVIORS
};


# 1 "c:/WayneWork/player.h" 1
# 209 "c:/WayneWork/player.h"

# 113 "c:/WayneWork/drones.h" 2

 
void DroneTeamwork(void);
void Drone(PLAYER *pp);
PLAYER *NewDrone(S16 team, PLAYER *pp, int hires);
void ResetDrones(S16 team);
void PassToDrone(PLAYER *pp);
void CallForPass(PLAYER *to, PLAYER *from);
void CallForShot(PLAYER *caller, PLAYER *shooter);
void LookForDirtyMove(PLAYER *pp, PLAYER *cp);
int LineOfSite(PLAYER *p1, PLAYER *p2, F32 p1POS[3], F32 p2POS[3], F32 time, F32 howopen, F32 *opendist);
PLAYER *FindOpenMan(PLAYER *me, F32 time, F32 zbehind, F32 zforward, F32 howopen);
void ShowOpenMan(PLAYER *me);
int CloseOpponent(PLAYER *pp, int usestick, F32 back, F32 fwd, F32 side);
PLAYER *ChasePuck(S16 team, PLAYER *exclude);
void SkateToTarget(PLAYER *pp,F32 target[3],F32 radius,const F32 *focus,F32 relaxtime,int ap);
void AvoidPlayers(PLAYER *pp);
void AvoidPlayer(PLAYER *pp, PLAYER *ap);
void AvoidWalls(PLAYER *pp);
F32 GetPuckPosition(PLAYER *pp, F32 puckpos[3]);
void LookAhead(int team,F32 latime,int tref);
void DroneCAM(void);
void GetPolarData(PLAYER *d);
void ReenterDrone(PLAYER *pp);


extern F32 LookAheadPos[2 ][5 ][3];





# 15 "c:/WayneWork/player.h" 2



# 1 "c:/WayneWork/balloon.h" 1



typedef struct
{
	F32		BasePos[3];	 
	F32		UnitVec[3];	 
	F32		CurrPos[3];
	F32		CurrVec[3];
	F32		Length;		 
	F32		Radius;		 
} Balloon;

typedef struct
{
	char	Name[16];
	F32		Radius;
	S32 	Surface;
	F32		ShadowRadius;
	F32		Extend[2];
	F32 	LineSeg[2][3];
} BalloonInfo;


extern F32 BCDVec[3];
extern const BalloonInfo PuckBalloons;


F32 BalloonCollide(Balloon *b1, Balloon *b2);
void BalloonInit(Balloon *b, const F32 startp[3], const F32 endp[3], F32 radius);
void BalloonMove(Balloon *b, F32 m[4][3]);



# 18 "c:/WayneWork/player.h" 2

# 1 "c:/WayneWork/cbody.h" 1







typedef struct bodycollision
{
	Balloon		Balloon;
	int			HasBalloon;
	int			Surface;
	DOBJ		*obj0,*obj1;
} BALLOONCOL;

# 1 "c:/WayneWork/player.h" 1
# 209 "c:/WayneWork/player.h"

# 16 "c:/WayneWork/cbody.h" 2

 
void InitCollision(ANIMOBJ *obj, const BalloonInfo *bi);
void InitBodyCollisions(PLAYER *pp, int debug);
void PrintBodyCollisions(PLAYER *pp, int x, int y);
void InitBColObjs(ANIMOBJ *treeobj);
void UpdateBColTree(ANIMOBJ *treeobj, int vis);
U32 CheckPlayerCollision(PLAYER *p1, ANIMOBJ *colobj);
void MoveBalloonTree(MATRIX *mat, ANIMOBJ *obj);
void MakeDeltaBalloon(BALLOONCOL *bcol, F32 *dpos);

extern F32 TreeColVec[3];
extern F32 TreeColDist;
extern U32 TreeDistPart;


# 19 "c:/WayneWork/player.h" 2


# 1 "c:/WayneWork/player_stats.h" 1
















typedef struct
{
	char name[12 ];
	F32  save_perc; 	 
	F32  shot_perc_GAA;	 
	S8   shoots_1; 		 
	S8   shoots_2; 		 
	S8   number;
	S8   right_shot_hand;
	char initial;
	S8   blond;
	S8   speed; 		 
	S8   passing; 		 
	S8   shot_skill; 	 
	S8   defense; 		 
	S8   fight; 		 
	S8   goals;
	S8   assists;
	S8   plus_minus;	 
	S8   dummy;
	char team_prefix[5 ];  
} PLAYER__STATS;

typedef PLAYER__STATS PLAYER_STATS;




 
 
typedef struct
{
	char team_prefix[5 ];  
} PLAYER_CURRENT_TEAMS;


 
 
 
 
typedef struct
{
	U8 ShotOnGoal;		 
	U8 GameGoals;		 
	U8 GameAssists;		 
	U8 HatTricks;		 
	U8 PlayerOfGame;	 
	U8 PlusMinus;		 
	U8 GoalieOnIceGoals; 
	U16 GoalieSaves;	 
} PLAYER_EXTRA_STATS;


 
 
typedef struct
{
	U8 GoalsAgainstTeam;		 
	U8 Goals;
	char GoalInitials[3];		 

	U8 AssistsAgainstTeam;		 
	U8 Assists;
	char AssistInitials[3];		 

	U8 HatTricksAgainstTeam;	 
	U8 HatTricks;
	char HatTricksInitials[3];	 
} PlayerRecords;







 
 
typedef struct
{
	char name[32 ];
	char prefix[5 ];
	U8  dummy[3];
	U8  rgb[2 ][3];  
	U8  div;
	U8  rank_in_div;  
	union
	{
		S16 plyr[(2 + 5  * 3 ) ];  
		struct
		{
			S16 goalie;
			S16 goalie2;
			S16 player[3 ][5 ];
		}line;
	}idx;
} TEAM_STATS;

# 141 "c:/WayneWork/player_stats.h"




# 21 "c:/WayneWork/player.h" 2






typedef struct
{
	const char * const *parts;
	PARTDESC *partdesc;
} PLAYERINFO;

typedef struct
{
	F32 pos[3];
	F32 yaw;
}PLYRFACEOFF;

typedef struct			 
{
	S16 pmotion;				 
	S16 dmotion;				 
	S16 motion;					 
	S16 lmotion;				 
	S16 sequence;				 
	S16 curshot;				 
	S08 passthrough;			 	
	S08 backwards;				 
	S08 bszone;					 
	S08 transition;				 
	F32 transtime;				 
	struct
	{
		S32 powerburst;				 
		S32 powerflags;				 
		F32	powertime;				 
		F32 nextpowertime;			 
		S32 bursting;				 
		F32 addburstspeed;			 
	}power;
	F32 shotangle;				 
	S32 faceoffonetimer;		 
	S32 onetimer;				 
	F32 tofonetimer;			 
	POLYINST *streakid;			 
	F32 streaktime;				 
}STATE;







enum PlayerInjuryStates
{
	INJURY_NONE,
	INJURY_REST_OF_GAME,
	INJURY_REST_OF_PERIOD,
	INJURY_REPLACE,
};



struct player				 
{
	MATRIX	mat;				 
	ANIMOBJ *obj;				 
	ANIMOBJ *mid;				 
	ANIMOBJ *head;				 
	ANIMOBJ *spray;				 
	ANIMOBJ *blade;				 
	ANIMOBJ *handlobj;			 
	ANIMOBJ *handrobj;			 
	ANIMOBJ *stickobj;			 
	ANIMOBJ **puckptr;			 
	ANIMINFO *animinfo;			 
	PALDEF	*pal;				 
	S32	logodlidx;				 
	S32	facedlidx;				 
	S32	jerseydlidx1;			 
	S32	jerseydlidx2;			 

	short BlackPlayer;			 
	short GameFaceNumIdx;		 
	enum PlayerInjuryStates InjuryLevel;	 

	STATEINFO *stateinfo;		 
	BalloonInfo *balloons;		 
	PHYSICS physics;			 
	SECTOR *sector;				 
	STATE state;				 
	CONTROL controls;			 
	DRONE dronedata;			 
	GAMESTATS gstats;			 
	GAMESTATS pstats;			 
	PLAYER_STATS *stats;		 
	F32 tlposess;				 
	F32 speedup;				 
	F32 radius;					 
	S16 puckidx;				 
	S8 tidx;					 
	S8 pidx;					 
	 
	S8 otidx;					 
	S8 kidx;					 
	S8 stat_pos;				 
	S8 stat_line;				 
	S8 orig_stat_line;			 
	S8 caller;					 
	S16 stat_idx;				 
	F32 anger;					 
	struct
	{
		U8 ptype;				 
		U8 offpitch;			 
		U8 doshot;				 
		U8 haspuck;				 
		U8 animpuck;			 
		U8 setpos;				 
		U8 collide;				 
		U8 fighter;				 
		U8 didonetimer;			 
		U8 didcolsetup;			 
		U8 breakaway;			 
		U8 notvisible;			 
		U8 mirror;				 
		U8 AI;   
	} flags;
	const KIDCONTROL *kidctl;	 
	KIDOBJECTS *kidobjs;		 
	BODYCOL bodycol[2 ][5 +1];	 
	S32 tunelevel;
	 
	S16 position;   
	PLYRFACEOFF faceoff;   
};




 








typedef struct objinfo
{
	BALLOONCOL bcol;
} OBJINFO;


enum {				 
	OFFTYPE,
	KIDTYPE,
	DRONETYPE,
	GOALIETYPE,
	REFTYPE,
	BENCHTYPE
};




extern const PLAYERINFO PlayerParts[];


 
void ResetPlayerAnim(PLAYER *pp);
ANIMOBJ *MakePlayer(PLAYER *pp, int flags);
ANIMOBJ *MakeGoalie(PLAYER *pp, int tidx);
ANIMOBJ *MakeRef(PLAYER *pp);
void InitPlayerStreak(void);
void ClearPlayerStreak(PLAYER *);
void ClearPlayerStreaks(void);
void PlayerStreak(PLAYER *pp);
void PlayerStreakUpdate(PLAYER *pp);

void CheckPlayerColour(PLAYER *pp);
void InitGameFaceNumIdx();
void FindGameFaceNumIdx(PLAYER *pp);




# 196 "c:/WayneWork/controls.h" 2




void OS_ctl_upd_clear(void);
void OS_ctl_upd_sw(void);
void ClearControls(U32 skipmask);
void InitControls(void);
void ResetControl(S16 swidx);
void UpdateControls(void);
void ControlIRQ(void);
S16 ControlLevel(S16 swid);
S16 ControlTimedLevel(S16 swid, F32 starttime, F32 endtime);
S16 ControlFrameLevel(S16 swid);
S16 ControlTimedEdge(S16 swid, F32 starttime, F32 endtime, S16 edge, S16 htot, F32 *edgetime);
S16 ControlEdge(S16 swid, S16 edge);
S16 ControlAutoRepeat(S16 swid, F32 initial, F32 repeat);
void InitPlayerControls(void);
void PlayerControls(PLAYER *pp, S16 init);
S16 SpecialMove(const SPMOVE *spmove, const KIDCONTROL *kidctl, F32 *starttime, int knum);


# 16 "c:/WayneWork/pfs.c" 2

# 1 "c:/WayneWork/font.h" 1




# 1 "c:\\n64\\include\\PR/ultratypes.h" 1
# 78 "c:\\n64\\include\\PR/ultratypes.h"


# 5 "c:/WayneWork/font.h" 2

# 1 "c:\\n64\\include\\PR/mbi.h" 1
# 98 "c:\\n64\\include\\PR/mbi.h"

# 6 "c:/WayneWork/font.h" 2

# 1 "c:/WayneWork/U64blit.h" 1




# 1 "c:\\n64\\include\\PR/ultratypes.h" 1
# 78 "c:\\n64\\include\\PR/ultratypes.h"


# 5 "c:/WayneWork/U64blit.h" 2

# 1 "c:\\n64\\include\\PR/os.h" 1

 



















 








# 979 "c:\\n64\\include\\PR/os.h"

# 6 "c:/WayneWork/U64blit.h" 2

# 1 "c:\\n64\\include\\PR/mbi.h" 1
# 98 "c:\\n64\\include\\PR/mbi.h"

# 7 "c:/WayneWork/U64blit.h" 2




 






 











 
 
 
 







 
 








 





typedef struct
{
	unsigned char	r,g,b,a;
} RGBA;


 












 




void	BlitInit(void);
Gfx	*	BlitFinish(void);
void	BlitSetAttribute(u32 attributes);
void	BlitClearAttribute(u32 attributes);
void	BlitZDist(u16 zDist);
void	BlitXLU(u16 xlu);
void	BlitScissor(s32 xmin, s32 xmax, s32 ymin, s32 ymax);
void	BlitClearColors(void);
void	BlitColors(void *address, int format, int size, int pal);
void	BlitTexture(void *address, u16 format, u16 size, u16 width, u16 height, 
 					u16 uls, u16 ult, u16 lrs, u16 lrt, u16 pal, int tile);
void	BlitDraw(s32 x0, s32 y0, s32 x1, s32 y1, int s, int t);
void	BlitRect(s32 x0, s32 y0, s32 x1, s32 y1, u8 color[]);


# 7 "c:/WayneWork/font.h" 2



 




enum
{
	SAME_PAL = 0,
	GRY_PAL,
	BLU_PAL,
	GRN_PAL,
	CYN_PAL,
	RED_PAL,
	MAG_PAL,
	YEL_PAL,
	WHT_PAL,
	YEL_RED,
	RED_YEL,
	RED_RED,
	CYN_CYN,
	CYN_GRN,
	DRK_YEL,
	DRK_GRY,
	BLK_GRY,
	CYCLE_PAL,
	FLASH_PAL,
	LAST_PAL
};





 





typedef struct 
{										 
	s16		uls,ult;					 
	s16		lrs,lrt;					 
} Letter;

typedef struct 
{
    Letter	*letters;
    char 	*img;
	s16		width,height;				 
	s8		lineSize;					 
	s8		autospace;					 
	s8		xOverstrike;				 
	s8		yOverstrike;
} Font;


 






 




void 	FontInit(void);
Gfx	*	FontFinish(void);

void 	FontSetColor( u8 num, u8 r, u8 g, u8 b, u8 a);
void 	FontSetPos( int, int );

void 	FontSetAttribute( int );
void 	FontClearAttribute( int );
void	FontZDist(u16 zDist);
void	FontXLU(u16 xlu);

int 	FontStrSize(const char *str);
int		FontCenter(const char *);
int	 	FontSelect(unsigned int);

void 	FontPrint( const char * );
void	FontPrintf(const char *fmt, ...);

void 	FontXYPrint(int col, int row, int pal, const char *str);
void 	FontXYPrintf(int col, int row, int pal, const char *str, ...);

void 	TextureFontPrint(u16 *origtex, u16 *tex, int w, int h, int c, int r, int pal, char *val_str);


# 17 "c:/WayneWork/pfs.c" 2


# 1 "c:/WayneWork/tune.h" 1




enum {
	ENGLISH_LANG,
	FRENCH_LANG,
	GERMAN_LANG,
	SPANISH_LANG
};

enum {
	DIFF_VERYEASY,
	DIFF_EASY,
	DIFF_MEDIUM,
	DIFF_HARD,
	DIFF_VERYHARD,
	DIFF_MAX,
	TUNELEVELS,
	TOTALLEVELS
};



typedef struct {
	F32 forcetable[10][6];
	F32 spmovedelay;
	F32 statscale[2];
	
	struct {
		F32 slapspeed;
		F32 snapspeed;
		F32 wristspeed;
		F32 flipspeed;
	}shotspeeds;

	struct {
		F32 regburst;
		F32 poburst;
		F32 defburst;
		F32 dregburst;
		F32 dpoburst;
		F32 ddefburst;
		
		F32 capregburst;
		F32 cappoburst;
		F32 capdefburst;
		F32 capdregburst;
		F32 capdpoburst;
		F32 capddefburst;
	}burstspeeds;
	
	struct {
		F32 minmax[2];
		F32 timing;
	}passspeeds;

	struct {
		F32 baseadd[TOTALLEVELS];
		F32 dbaseadd[TOTALLEVELS];
		F32 overtimeadd[TOTALLEVELS];
		F32 dovertimeadd[TOTALLEVELS];
		F32 hotshotadd[TOTALLEVELS];
		F32 dhotshotadd[TOTALLEVELS];
		F32 breakawayadd[TOTALLEVELS];
		F32 dbreakawayadd[TOTALLEVELS];
		F32 angmod[TOTALLEVELS];
		F32 pctgpershot[TOTALLEVELS];
		F32 dpctgpershot[TOTALLEVELS];
		F32 pctgscorediff[TOTALLEVELS];
		F32 dpctgscorediff[TOTALLEVELS];
		F32 mintimingmod[TOTALLEVELS];
		F32 maxtimingmod[TOTALLEVELS];
		F32 gaamultiplier[TOTALLEVELS];
		F32 dgaamultiplier[TOTALLEVELS];
		F32 savepadd[TOTALLEVELS];
		F32 dsavepadd[TOTALLEVELS];
		F32 sweetspot[2][TOTALLEVELS];
		F32 dsweetspot[2][TOTALLEVELS];
		F32 joycontroladd[TOTALLEVELS];
	}shoteq;

	struct {
		F32 gspeed[TOTALLEVELS];
		F32 dgspeed[TOTALLEVELS];
		F32 proximity;
		F32 closingvel;
		F32 weakspotmod[2][TOTALLEVELS];
		F32 dweakspotmod[2][TOTALLEVELS];
		F32 faceoffsavemod;
	}goalie;

	struct {
		F32 doramping;
		F32 difficultyscale;
		F32 winscale;
		F32 lossstreakscale;
		F32 winstreakscale;
		F32 rampinglevels[TUNELEVELS];
		F32 winstreakcap;
		F32 wincap;
	}ramping;

	struct {
		F32 ambient;
		F32 dambient;
		F32 type;
		F32 intensity;
		F32 distance;
	}lighting;

	struct {
		F32 scale;
		F32 maxscale;
		F32 distance;
		F32 color[8];
		F32 intensity[8];
		F32 cycles;
		F32 cycletime;
	}puck;

	struct {
		F32 gametimes[5];
		F32 celebrate;
		F32 faceoff;
	}gametiming;

	struct {
		F32 burstfreq[TOTALLEVELS];
		F32 checkfreq[TOTALLEVELS];
		F32 hotshotfreq[TOTALLEVELS];
	}power;

	F32 goalbonus[3][TOTALLEVELS];

	F32 speedscale[TOTALLEVELS];
	F32 dspeedscale[TOTALLEVELS];
	F32 turnscale[TOTALLEVELS];
	F32 dturnscale[TOTALLEVELS];
	F32 checkfreq[TOTALLEVELS];
	F32 dcheckfreq[TOTALLEVELS];
	F32 passfreq[TOTALLEVELS];
	F32 shotfreq[TOTALLEVELS];
	F32 hotshotfreq[TOTALLEVELS];
	F32 faceoff[TOTALLEVELS];
	F32 droneseperation[TOTALLEVELS];
	F32 droneposition[TOTALLEVELS];
	F32 stealfreq[TOTALLEVELS];
	F32 dstealfreq[TOTALLEVELS];
	F32 tofpressure[TOTALLEVELS];
	F32 dtofpressure[TOTALLEVELS];
	F32 droneonetimerdelta[TOTALLEVELS];
	F32 breakawaydist[TOTALLEVELS];
	F32 dbreakawaydist[TOTALLEVELS];
	F32 fightmultiplier[TOTALLEVELS];
	F32 coughspeed;
	F32 defensemod;
	F32 dronefighttiming[TOTALLEVELS];
}TUNEVARS;




extern	TUNEVARS *tunedata;


extern	S16			oldArcadeMode;			 
extern	S16 		oldnPlayers;			 
extern	S16			oldPenaltiesOn;
extern	S16			arcadeMode;				 
extern	S16			realRink;				 
extern	S16 		nPlayers;				 
extern	S16 		GameDifficulty;			 
extern S16 calcDifficulty;  		 
extern	S16 		GameInitTimeIndex;		 
extern	F32 		GameInitTime;			 
extern	F32			GameTimes[2][4];		 
extern	S16			fightingOn;				 
extern	S16			penaltiesOn;			 
extern	S16			autoSwitchPlayer;		 
extern	S8			lineSwitching[2];			 
extern	S16			playSpeed;				 
extern	S16			noPuckStreak;			 
extern	S16			playerFatigue;			 
extern	S8			changeLine[2];			 
extern	S8			changeGoalie[2];		 
extern	S8			language;				 
extern	S8			languagePicked;			 

extern	F32			headScale;				 
extern	F32			bodyScale;				 
extern	F32			yScale;					 



 
void InitEERoptions(void);
void InitTuneData(void);
void InitTeamTuneData(int team, LADDER *ladder, int diffsetting);
void RampTuneData(void);
F32 TuneSetting(PLAYER *pp, const F32 *ksettings, const F32 *dsettings);
LADDER * GetLadder(int tidx);
void SetGameTuneData(void);


# 19 "c:/WayneWork/pfs.c" 2

# 1 "c:/WayneWork/error.h" 1




# 1 "c:/WayneWork/strings.h" 1



# 1 "c:\\n64\\include/stdarg.h" 1





 
 
 
 
 
 
 
 

 

 

















































 


typedef char *va_list;


 


# 126 "c:\\n64\\include/stdarg.h"


 

# 171 "c:\\n64\\include/stdarg.h"


 



























# 4 "c:/WayneWork/strings.h" 2


extern int (vfprintf)(char *fp, const char *fmt0, va_list ap);
extern int (sprintf)(char *str, char const *fmt, ...);


 


# 68 "c:/WayneWork/strings.h"


































# 5 "c:/WayneWork/error.h" 2













void Error(S16 errid, const char *msg);
void FatalError(S16 errid, const char *msg);
 
 
void WarnMsg(char const *fmt, ...);
void FatalMsg(char const *fmt, ...);



 
 










# 68 "c:/WayneWork/error.h"



# 20 "c:/WayneWork/pfs.c" 2

# 1 "c:/WayneWork/audio.h" 1




 
void AudioTimeInit(void);
void AudioQueResetTime(F32 time);
void AudioQueUpdate(void);
void AudioQueEmpty(void);
int AudioStatName(const char *name);
void AudioInitNames(int tidx);
void Audio(U16 ac);
void AudioInit(void);
void AudioAttract(void);
void AudioAttractSnds(S32 type);
void AudioZamboni(S32 idx, F32 *pos, S32 active);
void AudioGame(void);
void AudioBeginPeriod(void);
void AudioEndPeriod(int gameover);
void AudioEndGame(void);
void AudioGameLoop(F32 timeleft);
void AudioSelect(S32 type, int tidx, int kidx);
void AudioVersus1(S32 team0, S32 team1, F32 time);
void AudioPlayer(S32 type, F32 *pos, F32 cvel, int haspuck);
void AudioFight(S32 type, F32 *pos);
void AudioPuck(S32 type, F32 *pos, F32 vel);
void AudioShot(S32 motion, S32 type, S32 ptype);
void AudioCrowd(S32 level, S32 type, F32 timeleft);
void AudioGoal(S32 type, S32 team, F32 savep);
void AudioName(S32 tidx, S32 stat_pos, S32 stat_line);
void AudioGotPuck(S32 tidx, S32 stat_pos, S32 stat_line, F32 *pos);
void AudioCoin(int type);
void AudioRefWhistle(void);
void AudioBOO(void);
void AudioCHEER(void);
void AudioTITLE(void);
void AudioLineChange(int tidx1, int tidx2);
void AudioPowerPlay(int tidx);
void CheckAudioPenaltyFaceoff(int init);
void AudioPenaltyRelease(int tidx,int type);

extern U8 call_power_play;

enum {
	AUDIO_CHECK = 1,
	AUDIO_TRIP,
	AUDIO_WALL,
	AUDIO_POST,
	AUDIO_NET,
	AUDIO_GLASS,
	AUDIO_SKATE,
	AUDIO_STICK,
	AUDIO_BODY,
	AUDIO_WRISTSHOT,
	AUDIO_SNAPSHOT,
	AUDIO_SLAPSHOT,
	AUDIO_ONETIMER,
	AUDIO_BACKHAND,
	AUDIO_WIDEOPEN,
	AUDIO_POWERSHOT,
	AUDIO_DUMP,
	AUDIO_PASS,
	AUDIO_STOP,
	AUDIO_BOO,
	AUDIO_SAD,
	AUDIO_HAPSAD,
	AUDIO_CHEER,
	AUDIO_SCORE,
	AUDIO_CHANT,
	AUDIO_START,
	AUDIO_END,
	AUDIO_HILITE,
	AUDIO_CHOOSETEAM,
	AUDIO_TURN,
	AUDIO_CHOOSEPLAYER,
	AUDIO_CATCH,
	AUDIO_BLOCK,
	AUDIO_MISS,
	AUDIO_JAB,
	AUDIO_PUNCH,
	AUDIO_UPPERCUT,
	AUDIO_GRAB,
	AUDIO_COMB1,
	AUDIO_COMB2,
	AUDIO_KNOCKOUT,
	AUDIO_KNOCKOUTHIT,
	AUDIO_STEAL,
	AUDIO_SPEED,
	AUDIO_SWITCH,
	AUDIO_NOSWITCH,
	AUDIO_START2,
	AUDIO_END2,
    AUDIO_FIGHT,
	AUDIO_DROP,
	AUDIO_FIRENET,
	AUDIO_FIREPUCK,
	AUDIO_AMBULENCE,
	AUDIO_FIRETRUCK,
	AUDIO_SPECIAL1,
	AUDIO_SPECIAL2,
	AUDIO_SPECIAL3,
	AUDIO_SPECIAL4,
	AUDIO_SPECIAL5,
	AUDIO_NO,
	AUDIO_ENTER,
	AUDIO_EXIT,
	AUDIO_UP,
	AUDIO_DOWN,
	AUDIO_CAMERA1,
	AUDIO_CAMERA2,
	AUDIO_ENDGAME,
	AUDIO_EVEN_STRENGTH,
	AUDIO_FULL_STRENGTH,
	AUDIO_RELEASE_PLAYER,
};


# 21 "c:/WayneWork/pfs.c" 2

# 1 "c:/WayneWork/game.h" 1




# 1 "c:/WayneWork/team.h" 1











 
typedef S8 ZONE[4];
typedef struct _PLAYPOS
{
	S8 play;    
	S8 mode;    
	ZONE zone;   
} PLAYPOS;























typedef struct _CHOOSER
{
	struct _CHOOSER *next;
	F32 value;
	U32 mirror;
	void *data;
} CHOOSER;
typedef struct _PLAYDATA
{
	U32 tag;         
	ZONE *coverage;   
	PLAYPOS *ppos;   
	const char *name;
} PLAYDATA;

typedef struct _PLAYPTRS
{
	PLAYER *player;     
	PLAYPOS *playpos;   
	ZONE *coverage;   
	U8 mirror;   
} PLAYPTRS;


typedef struct				 
{
	PLAYER player[5 + 1 ];	 
	GOAL *goalp;					 
	F32 shotmod;					 
	S16 score;						 
	S16 sog;						 
	S16 shots;						 
	S16 fights;						 
	S16 penalties;   
	S8 city;						 
	S8 home_team;					 
	S8 line;						 
	S8 onIce;						 
	S16 rampval;					 
	struct
	{
		U8 celebrate;				 
		U8 gotkids;					 
		U8 lastSwitchPlayer;		 
		U8 dummy2;
	}flags;
	S8 scoringkid;					 
	S8 kidsonteam;					 
	S8 maxkidsonteam;				 
	S8 firstkid;					 
	S8 goalie;
	S8 lastplayer;					 
	S8 kid[4  ];
	PLAYER 	*passer;				 
	PLAYER 	*lastowner;				 

	TEAM_STATS *stats;
	LADDER	*ladder;				 
	PFSTEAM	*pfsteam0;				 
	PFSTEAM	*pfsteam1;				 

	 
	PLAYPTRS play[5];  				 
	U32 currentplay;    			 
	S32 onoffense;					 
	S32 lastpucker;					 
	PLAYER *FOdrawplayer;  			 

	 
	U8 pref_line[5 ];
	U8 goaliePulled;
} TEAM;












extern TEAM Team[2 ];
extern int changeTeams;

 
int	SwitchPlayer(PLAYER *pp);
void DoSwitchKid(PLAYER *kp,PLAYER *dp);
void DoSwapKids(PLAYER *pp,PLAYER *pp2);
void InitPlayer(PLAYER *pp, int tidx, int pidx);
void ReinitPlayerPStats(PLAYER *pp);
void ReinitPlayerGStats(PLAYER *pp);
void ReinitPlayer(PLAYER *pp, int tidx, int pidx, int overtime);
void InitTeams(void);
void InitTeamsNotFirstKid(void);
void ReinitTeams(int overtime,short changeteams);
void ProcessTeams(void);
void ResetPlayer(PLAYER *pp);
void ResetPlayers(void);
void SetNewPlayer(PLAYER *pp, int redo_physics, int alt_stat_pos, int alt_stat_line, int flags);
PLAYER *NewPlayer(KIDINFO *kidp, S16 tidx, int flags);
void UpdatePlayer(PLAYER *pp);
int WithinSlice(F32 pos[3], PLAYER *pp, F32 offd, F32 defd);
int DefensiveEnd(PLAYER *pp);
int GotKids(int tidx);
int ActivePlayer(PLAYER *pp);
void OffScreenArrows(void);
void SetPlayerID(DOBJ *idcircle, PLAYER *pp, int state);
void UpdatePlayerID(PLAYER *pp);
F32 GetStickYaw(PLAYER *pp);
void GetStickPosition(PLAYER *pp, F32 pos[3]);
void GetMidPosition(PLAYER *pp, F32 pos[3]);
void RebuildPlayers(void);


 


 
 
 
 



void TeamKidInit(void);
void TeamKidDefaultPositionsSet(void);
short TeamKidFind(short kidIndex, short *teamIndex,short *index);
short TeamKidAdd(short teamIndex,short kidIndex);
void TeamKidGetTeammates(short kidIndex,char *teamMates,short *numTeammates);
short TeamKidNumKidsPerTeam(short teamIndex);
short TeamKidAddProportional(short kidIndex);
short TeamKidRemove(short kidIndex);
short TeamKidSwap(short kidIndex,short maxNumberPerTeam);
short TeamKidGetFirstKid(short teamIndex);
short TeamKidGetKidFromIndex(short teamIndex,short index);


# 5 "c:/WayneWork/game.h" 2




enum {
	GTYPE_PLAY=0,
	GTYPE_SSEASON,
	GTYPE_LSEASON,
	GTYPE_ARCADE,
	GTYPE_PLAYOFF
};

extern S16 GameType;
extern S16 GameTimerON;		 
extern S16 GamePeriod;			 
extern F32 GameTimer;			 
extern F32 GameTimerTLU;		 
extern VS32 GameMode;
extern VS32 AttractMode;
extern S16 GameTie;			 
extern S16 GameEnd;			 
extern S8 PG_IcingFlag;
extern U8 PG_Firsttimeflag;
extern U8	InjuredPlayers[2 ][5 + 1 ];
extern U8 nokids_thisteam[2];



 
int TestWaitLoop(void);
void StartGameTimer(F32 inittime);
void StopGameTimer(void);
int EndGameRules(void);
int UpdateGameTimer(void);
int Hockey(void);
int StandbyMode(void);
int GameLoop(F32 timeonclock);
void InitChallengeScreen(PLAYER **p1guy, PLAYER **p2guy);
void ChallengeScreen(void);
void EndOfGame(void);
void UpdateEndOfPeriod(void);
void PatriceMode(void);

void	SetBillboardTextures(int team);






# 22 "c:/WayneWork/pfs.c" 2

# 1 "c:/WayneWork/stats.h" 1


















extern LADDER ram_ladder;
extern S32 num_teams;
extern S32 num_players;
extern TEAM_STATS * team_stats;
extern PLAYER_STATS * player_stats;

extern PLAYER_CURRENT_TEAMS *player_current_teams;
extern PLAYER_EXTRA_STATS *player_extra_stats;
extern PLAYER_EXTRA_STATS player_extra_game_stats[2][(2 + 5  * 3 ) ];
extern PLAYER_EXTRA_STATS player_period_stats[2][(2 + 5  * 3 ) ];
extern PlayerRecords *PlayerCardRecords;
extern short *GameFaceNum;

extern U8 teams_in_div[(4  + 1) ];
extern S8 city_from_rank[(4  + 1) ][7 ];
extern S16 mt_modcity[2];
extern S16 mt_plyrs[2][15];
extern S8 mt_teams[2][15];

extern const U8 div_order[4  ][(4  + 1)  ];

 
void CheckLadder(LADDER * ladderp);
void InitStats(void);
void resetPlayerStats(void);
S32 FindTeam(const char *string);
S32 FindPlayer(const char *string);
U16 FindTeamTexture(char *buf, const char *formatstr, int city, int lineno, int position);
int MakeVirtTeamNum(int div, int num);
void UseVirtTeamNum(int vteam, int *RET_div, int *RET_num);
DOBJ *STATSwanim(DOBJ *dobj, S16 oidx);
void Stats(void);



# 23 "c:/WayneWork/pfs.c" 2

# 1 "c:/WayneWork/timer.h" 1





extern VF32 TIME;			 
extern VU32 ITIME;			 


void TimerResetNearOverflow(void);
void TimerCalc(void);
void InitializeTimerIRQ(void);
void ResetTime(void);



# 24 "c:/WayneWork/pfs.c" 2



# 1 "c:/WayneWork/name.h" 1







 
DOBJ *NAMEwanim(DOBJ *dobj, S16 oidx);
int GetName(void);




enum {
	NOTPLAYING,
	SELECTING,
	INGAME,
	CONTINUING
};

enum {
	SDNOJOY,
	SDJOIN,
	SDSTART,
	SDINITIALS,
	SDPASSWORD,				 
	SDPAK,
	SDWAITING,
	SDVERIFY
};

extern char passarray[];

# 27 "c:/WayneWork/pfs.c" 2








 




extern char *RumblePackMessage[];
extern char *RumblePackMessage1[];



extern	char *W_strs[1 ];
extern	char *L_strs[1 ];
extern	char *T_strs[1 ];
extern	char *PTS_strs[1 ];
extern	char *goals_String[1 ];
extern	char *assist_strs[1 ];
extern	char *games_strs[1 ];
extern	char *overtime_strs[1 ];
extern	char *shots_String[1 ];
extern	char *assist_strs[1 ];
extern	char *points_strs[1 ];













extern	char *player_str[1 ];
extern	PfsHiScore(int pak);
extern	int cntstr(char *str, int n);

extern	volatile OSContStatus statusdata[4 ];
extern	U16		attract_state;
extern	GFXMsg	controllermsg;
extern	U16 	internal_state;
extern	F32		timer;
extern	PFSTEAM	pfsTeamRam[2 ];


GFXMsg	endpfsmsg;						 
OSMesgQueue	pfsMsgQ;					 
OSMesg		pfsMsgBuf[8 ];

OSPfs	pfsHeader[4 ];		 
S8		pfsFileNum[4 ];		 
S8		pfsError[4 ];		 
U8		pfsPattern;						 
S8	 	pfsDelete;						 
OSPfsState	pfsFiles[16 ];	 
S32 	pfsFree;						 
U16 	pfsFileCount;					 
S32		pfsFile;						 
char 	pfsFileName[16  + 1 + 4  + 1];	 

 


char	pfsName[] = 					 
{												 
	0x30, 0x20, 0x0F, 0x13, 
	0x1d, 0x21, 0x28, 0x1c,
	0x24, 0x1e, 0x32, 0x19,
	0x18, 0, 0, 0,	
};
# 114 "c:/WayneWork/pfs.c"

char	pfsExt[] = { 0, 0, 0, 0, };		 

PFSGLOBAL	pfsGlobalData = 
{
	"Ed Logg\0" ,
	0,											 
	1 , 
	0,
	0, 0,
};



 
 
void PfsSaveAllansData(PFS *p)
{
	int i,j,pos;










	 
	memcpy(p->AllansData.CurrentTeamPrefix, player_current_teams, num_players*5);

	 
	for(i = 0; i < num_players; i++)
	{
		 
		pos = FindPlayerTeamCityIdxFromPtr(&player_stats[i]);

		if(pos < 2)
		{
			 
			if(player_stats[i].dummy& 0x08 )
				p->AllansData.Stats[i*3+0] = ((player_extra_stats[i].GoalieSaves>>16)&0x7f)|0x80;
			else
				p->AllansData.Stats[i*3+0] = (player_extra_stats[i].GoalieSaves>>16);
			p->AllansData.Stats[i*3+1] = (player_extra_stats[i].GoalieSaves>>8)&0xff;
			p->AllansData.Stats[i*3+2] = (player_extra_stats[i].GoalieSaves&0xff);
		}
		else
		{
			if(player_stats[i].dummy& 0x08 )
				p->AllansData.Stats[i*3+0] = (player_stats[i].goals&0x7f)|0x80;
			else
				p->AllansData.Stats[i*3+0] = player_stats[i].goals;
			p->AllansData.Stats[i*3+1] = player_stats[i].assists;
			p->AllansData.Stats[i*3+2] = player_stats[i].plus_minus;
		}
		 
		 
		p->AllansData.HatTricks[i] = player_extra_stats[i].HatTricks;
		p->AllansData.PlayerOfGame[i] = player_extra_stats[i].PlayerOfGame;
	}

	 
	for(i = 0; i < 26; i++)
	{
		for(j = 0; j < (2 + 5  * 3 ) ; j++)
			p->AllansData.Teams[i*17+j] = team_stats[i].idx.plyr[j];
	}
}

void PfsRestoreAllansData(PFS *p)
{
	int i,j,pos;










	 
	memcpy(player_current_teams, p->AllansData.CurrentTeamPrefix, num_players*5);

	 
	for(i = 0; i < num_players; i++)
	{
		 
		pos = FindPlayerTeamCityIdxFromPtr(&player_stats[i]);

		if(pos < 2)
		{
			 
			if(p->AllansData.Stats[i*3+0]&0x80)
				player_stats[i].dummy |= 0x08 ;

			player_extra_stats[i].GoalieSaves = (p->AllansData.Stats[i*3+0]&0x7f)<<16;
			player_extra_stats[i].GoalieSaves |= p->AllansData.Stats[i*3+1]<<8;
			player_extra_stats[i].GoalieSaves |= p->AllansData.Stats[i*3+2];

			 
			player_stats[i].goals = 0;
			player_stats[i].assists = 0;
			player_stats[i].plus_minus = 0;
		}
		else
		{
			player_stats[i].goals = p->AllansData.Stats[i*3+0];
			if(player_stats[i].goals&0x80)
			{
				player_stats[i].dummy |= 0x08 ;
				player_stats[i].goals &= 0x7f;
			}
			player_stats[i].assists = p->AllansData.Stats[i*3+1];
			player_stats[i].plus_minus = p->AllansData.Stats[i*3+2];
		}
		player_extra_stats[i].HatTricks = p->AllansData.HatTricks[i];
		player_extra_stats[i].PlayerOfGame = p->AllansData.PlayerOfGame[i];
	}

	 
	for(i = 0; i < 26; i++)
	{
		for(j = 0; j < (2 + 5  * 3 ) ; j++)
			team_stats[i].idx.plyr[j] = p->AllansData.Teams[i*17+j];
	}
}


void PfsSaveRecords(PFS *p)
{
	int i,j;
	extern PlayerRecords *PlayerCardRecords;










	for(i = 0; i < num_players; i++)
	{
		p->AllansRecords[i].GoalsAgainstTeam |= (PlayerCardRecords[i].GoalsAgainstTeam&0x7f);
		p->AllansRecords[i].Goals = PlayerCardRecords[i].Goals;
		strncpy(p->AllansRecords[i].GoalInitials, PlayerCardRecords[i].GoalInitials, 3);

		p->AllansRecords[i].AssistsAgainstTeam = PlayerCardRecords[i].AssistsAgainstTeam;
		p->AllansRecords[i].Assists = PlayerCardRecords[i].Assists;
		strncpy(p->AllansRecords[i].AssistInitials, PlayerCardRecords[i].AssistInitials, 3);

		p->AllansRecords[i].HatTricksAgainstTeam = PlayerCardRecords[i].HatTricksAgainstTeam;
		p->AllansRecords[i].HatTricks = PlayerCardRecords[i].HatTricks;
		strncpy(p->AllansRecords[i].HatTricksInitials, PlayerCardRecords[i].HatTricksInitials, 3);
	}
}

void PfsRestoreRecords(PFS *p)
{
	int i,j;
	extern PlayerRecords *PlayerCardRecords;










	for(i = 0; i < num_players; i++)
	{
		PlayerCardRecords[i].GoalsAgainstTeam = (p->AllansRecords[i].GoalsAgainstTeam&0x7f);
		PlayerCardRecords[i].Goals = p->AllansRecords[i].Goals;
		strncpy(PlayerCardRecords[i].GoalInitials, p->AllansRecords[i].GoalInitials, 3);

		PlayerCardRecords[i].AssistsAgainstTeam = p->AllansRecords[i].AssistsAgainstTeam;
		PlayerCardRecords[i].Assists = p->AllansRecords[i].Assists;
		strncpy(PlayerCardRecords[i].AssistInitials, p->AllansRecords[i].AssistInitials, 3);

		PlayerCardRecords[i].HatTricksAgainstTeam = p->AllansRecords[i].HatTricksAgainstTeam;
		PlayerCardRecords[i].HatTricks = p->AllansRecords[i].HatTricks;
		strncpy(PlayerCardRecords[i].HatTricksInitials, p->AllansRecords[i].HatTricksInitials, 3);
	}
}




void PfsSaveGlobals(PFS *p)
{









	changed_options = 0;						 
	p->global.centerX = centerX;
	p->global.centerY = centerY;	
	p->global.arcadeMode = arcadeMode;
	p->global.realRink = realRink;
	p->global.nPlayers = nPlayers;
	p->global.gameDifficulty = GameDifficulty;
	p->global.gameTime = GameInitTimeIndex;
	p->global.penaltiesOn = penaltiesOn;
	p->global.autoSwitchPlayer = autoSwitchPlayer;
	p->global.lineSwitching = (lineSwitching[0] << 4) + (lineSwitching[1] & 0x0f); 
	p->global.playSpeed = playSpeed;
	p->global.noPuckStreak = noPuckStreak;
	p->global.playerFatigue = playerFatigue;
	p->global.cameras = (cameraToggle << 4) + (cameraDefault & 0x0f);	
	p->global.fightingOn = fightingOn;
	p->global.language = language;
	p->global.languagePicked = languagePicked;
}


void	PfsRestoreGlobals(PFS *p)
{









	changed_options = 0;							 
	centerX = p->global.centerX;					 
	if(osTvType  == 0 )
		centerY = 0;
	else
		centerY = p->global.centerY;
	arcadeMode = p->global.arcadeMode;
	realRink = p->global.realRink;
	nPlayers = p->global.nPlayers;
	GameDifficulty = p->global.gameDifficulty;
	GameInitTimeIndex = p->global.gameTime;
	GameInitTime = GameTimes[arcadeMode][GameInitTimeIndex];
	penaltiesOn = p->global.penaltiesOn;
	autoSwitchPlayer = p->global.autoSwitchPlayer;
	lineSwitching[0] = (p->global.lineSwitching >> 4) & 0x0f;
	lineSwitching[1] = (p->global.lineSwitching & 0x0f); 
	playSpeed = p->global.playSpeed;
	noPuckStreak = p->global.noPuckStreak;
	playerFatigue = p->global.playerFatigue;
	cameraDefault = p->global.cameras & 0x0f;
	cameraToggle = (p->global.cameras & 0xf0) >> 4;
	fightingOn = p->global.fightingOn;




}


static void PfsInitData(int pak)
{
	PFS	*p = &pfs[pak];
	int	i;
	









	memset(((U8 *)p) + sizeof(PFSGLOBAL), 0, sizeof(PFS)-sizeof(PFSGLOBAL));	 
	memcpy(&p->global, &pfsGlobalData, sizeof(pfsGlobalData));	 
	PfsSaveGlobals(p);				 

	 
	if(0)  
	{
		U8 *p1 = (U8 *)(p);

		p1 += sizeof(PFSGLOBAL);
		p1 += sizeof(PFSTEAM);
		p1 += sizeof(PFSPLAYER);
		p1 += sizeof(PFSALDATA);
		memset(p1, 0, sizeof(PFSALRECORDS));	 
	}


	 
	 
	PfsSaveRecords(p);				 

	p->global.checksum = PfsChecksum(pak);	 
}


void PfsSaveController(PFSPLAYER *player, int kid)
{









	changed_lists[kid] = 0;					 
	player->control.shot  		= shotbutton[kid];
	player->control.shot2		= shot2button[kid];
	player->control.pass  		= passbutton[kid];
	memcpy(player->control.turbo, burst_lists[kid], 4*sizeof(SPENTRY));
	memcpy(player->control.kneel, kneel_lists[kid], 4*sizeof(SPENTRY));
	memcpy(player->control.steal, steal_lists[kid], 4*sizeof(SPENTRY));
	memcpy(player->control.onetimer, onetimer_lists[kid], 4*sizeof(SPENTRY));
	memcpy(player->control.dive, dive_lists[kid], 4*sizeof(SPENTRY));
	memcpy(player->control.check, check_lists[kid], 4*sizeof(SPENTRY));
	memcpy(player->control.hook, trip_lists[kid], 4*sizeof(SPENTRY));
	memcpy(player->control.trip, hook_lists[kid], 4*sizeof(SPENTRY));
	memcpy(player->control.hotshot, hotshot_lists[kid], 4*sizeof(SPENTRY));
	memcpy(player->control.swplayer, playersw_lists[kid], 4*sizeof(SPENTRY));
	memcpy(player->control.swcamera, camerasw_lists[kid], 4*sizeof(SPENTRY));
}


void	PfsRestoreController(PFSPLAYER *player, int kid)
{









	if (changed_lists[kid])						 
		return;
	shotbutton[kid] = player->control.shot;
	shot2button[kid] = player->control.shot2;
	passbutton[kid] = player->control.pass;
	memcpy(burst_lists[kid], player->control.turbo, 4*sizeof(SPENTRY));
	memcpy(kneel_lists[kid], player->control.kneel, 4*sizeof(SPENTRY));
	memcpy(steal_lists[kid], player->control.steal, 4*sizeof(SPENTRY));
	memcpy(onetimer_lists[kid], player->control.onetimer, 4*sizeof(SPENTRY));
	memcpy(dive_lists[kid], player->control.dive, 4*sizeof(SPENTRY));
	memcpy(check_lists[kid], player->control.check, 4*sizeof(SPENTRY));
	memcpy(trip_lists[kid], player->control.hook, 4*sizeof(SPENTRY));
	memcpy(hook_lists[kid], player->control.trip, 4*sizeof(SPENTRY));
	memcpy(hotshot_lists[kid], player->control.hotshot, 4*sizeof(SPENTRY));
	memcpy(playersw_lists[kid], player->control.swplayer, 4*sizeof(SPENTRY));
	memcpy(camerasw_lists[kid], player->control.swcamera, 4*sizeof(SPENTRY));
}


char	ncode[256] = 					 
{
	   0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,	 
	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,	 
	0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,	 
	0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,	 
	0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E,	 
	0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,	 
	0x57, 0x58, 0x59, 0x5A, 0x21, 0x22, 0x23, 0x27,	 
	0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3D,	 
	0x3F, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,	 
	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,	 
	0x20, 0x20, 0x20, 0x20, 0x20, 0x20,AllanEnd


(Source: shygoo)