// Filename : YAROZE.C // Coded by : Scott Evans // Created/Modified : 16/9/97 // Description : This file contains various routines for Yaroze programs #include "yaroze.h" #include "gtypes.h" #include "console.h" // Global pointers to controller buffers static volatile u_byte *pad0,*pad1; // Function : SetDefDispEnv() // Coded by : Scott Evans // Created/Modified : 16/9/97 // Description : Set the default values of a DISPENV structure // Parameters : env - DISPENV to set // x,y,w,h - display area to set // Returns : Pointer to DISPENV that was used // Notes : None DISPENV *SetDefDispEnv(DISPENV *env,const u_word x,const u_word y,const u_word w,const u_word h) { // Set display area setRECT(&env->disp,x,y,w,h); // Set default screen size setRECT(&env->screen,0,0,256,240); // No interlace env->isinter=0; // Frame buffer mode 16 bit env->isrgb24=0; return(env); } // Function : SetDefDrawEnv() // Coded by : Scott Evans // Created/Modified : 16/9/97 // Description : Set default values of a DRAWENV structure // Parameters : env - DRAWENV to set // x,y,w,h - drawing area to set // Returns : Pointer to DRAWENV which was used // Notes : None DRAWENV *SetDefDrawEnv(DRAWENV *env,const u_word x,const u_word y,const u_word w,const u_word h) { // Set clipping area and drawing offsets setRECT(&env->clip,env->ofs[0]=x,env->ofs[1]=y,w,h); // Set default texture window and texture page setRECT(&env->tw,0,0,0,0); env->tpage=GetTPage(0,0,640,0); // Set dither on, drawing in display not allowed, clear background off env->dtd=1; env->dfe=(h>=480 ? 1 : 0); env->isbg=0; // Set background colour to black setRGB0(env,0,0,0); return(env); } // Function : PadInit() // Coded by : Scott Evans // Created/Modified : 16/9/97 // Description : Initialise controllers // Parameters : mode - does nothing // Returns : Nothing // Notes : None void PadInit(u_word mode) { GetPadBuf(&pad0,&pad1); } // Function : PadRead() // Coded by : Scott Evans // Created/Modified : 16/9/97 // Description : Reads controller pads // Parameters : id - does nothing // Returns : Status of pad0 in lower word, pad1 in upper word // Notes : None u_word PadRead(const u_word id) { return(~((*(u_byte *)(pad0+3)|(*(u_byte *)(pad0+2)<<8))|(*(u_byte *)(pad1+3)|(*(u_byte *)(pad1+2)<<8))<<16)); } // Function : Initialise() // Coded by : Scotte // History : Created 14/03/00 22:14:27 // // Description : Initialise a Yaroze program // // Parameters : mode - video mode // // Returns : None // // Notes : mode should be MODE_PAL or MODE_NTSC void Initialise(const u_word mode) { // Set the video mode (defaults to NTSC) SetVideoMode(mode); // Initialise the controllers PadInit(0); mMESSAGE("Video mode : %s\n",(mode==MODE_PAL ? "PAL" : "NTSC")); }