#pragma once //===========================================================================// // File: GameOS.hpp // // // // This is the main header file for GameOS // // // //---------------------------------------------------------------------------// // Copyright (C) Microsoft Corporation. All rights reserved. // //===========================================================================// // // Pragmas needed to compile at Warning 4 // #pragma pack(push,4) #pragma warning( disable: 4725 ) // fdiv generates a warning #pragma warning( disable: 4127 ) // conditional expression is constant eg: Asserts will not work otherwise #pragma warning( disable: 4200 ) // zero size array #pragma warning( disable: 4201 ) // Nameless struct or union #pragma warning( disable: 4514 ) // Unreferenced inline function #ifdef _ICECAP #include "icecap.h" #endif // // // // // ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // ************************** CODE ARMOR ****************************** // ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // // // Enter the visual C debugger // #define ENTER_DEBUGGER _asm int 3 // // Check !=0 only in debug builds (can be continued) // #ifdef _ARMOR #define gosASSERT(x) do { if(!(x)&&ErrorHandler(gos_ErrorVerify+gos_ErrorNoRegisters,#x)) ENTER_DEBUGGER } while(0) #else #define gosASSERT(x) ((void)0) #endif // // Report an error if the condition is false // #ifdef _ARMOR #define gosREPORT(x,Message) do { if(!(x)&&ErrorHandler(gos_ErrorMessage+gos_ErrorNoRegisters,Message)) ENTER_DEBUGGER } while(0) #else #define gosREPORT(x,Message) ((void)0) #endif // // Display a message and enter exception handler (can not be continued) // #define STOP(x) do { if(InternalFunctionStop x) ENTER_DEBUGGER } while(0) // // Display a message and enter exception handler (can be continued) // #define PAUSE(x) do { if(InternalFunctionPause x) ENTER_DEBUGGER } while(0) // // Displays a message to the debuglog or OutputDebugString - Three parameters are required. // // 1st parameter is the group of the message - different groups can be enabled or disabled by putting them in Environment.spew, 0 means all the time // // eg: "Stuff_Math" // // 2nd parameter is a printf style string // eg: "%d beans used.",BeansUsed // #ifdef _ARMOR #define SPEW(x) InternalFunctionSpew x #else #define SPEW(x) ((void)0) #endif // // Types used by GameOS // typedef unsigned long DWORD; typedef unsigned short WORD; typedef unsigned char BYTE; #define FALSE 0 #define TRUE 1 #ifndef GUID_DEFINED #define GUID_DEFINED typedef struct _GUID { unsigned long Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[8]; } GUID; #endif /* GUID_DEFINED */ // // Handles to internal structures // typedef struct SoundResource* HGOSAUDIO; typedef struct gos_Music* HGOSMUSIC; typedef struct gos_Video* HGOSVIDEO; typedef struct gosFileStream* HGOSFILE; typedef struct _FontInfo* HGOSFONT3D; typedef struct gosForceEffect* HGOSFORCEEFFECT; typedef struct gos_Heap* HGOSHEAP; ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // ********************** Environment Settings ****************************** // ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// typedef struct { // // Application title and version number // char* applicationName; // "TestApp" or "Pong" char* version; // Default is "00.00.00.0000" char* registryVersion; // If present, will be used to create a sub folder in the registry (ie: v1.1, v1.2) char* directoryPath; // If program path end in this directory, move up levels (ie: "\\Code\\AssassinEditor" or "\\Tools\\PixelWhIP"). "!" will force GameOS NOT to change directory at all (Including DEBUG/RELEASE/PROFILE....) char* defaultPlayerName; // used in lobby launch bool allowMultipleApps; // Allows the game to be run more than once on a single system (network testing) DWORD MegMemoryRequired; // Megabytes of virtual memory required to run game (default is 64Meg) bool dontClearRegistry; // When true, the registry is not cleared when the .exe is changed // // Current screen mode (application can check, but may change from frame to frame) // int screenWidth; // 640 int screenHeight; // 480 int bitDepth; // 16 or 32 int FullScreenDevice; // 0=Primary, 1=2nd video card (ie: 3Dfx) etc... int Renderer; // 0=Try hardware, fallback to software, 1=RGB, 2=Refrast, 3=Blade bool fullScreen; // Application start running full screen or in a window? bool disableZBuffer; // When true no Z buffer surface will be created bool AntiAlias; // When true full screen antialiasing will be enabled if possible bool RenderToVram; // When true Blade applications will render directly to video memory (speed-up if no alpha is used) bool Stencil; // When true an 8 bit stencil buffer will be enabled if possible bool TripleBuffer; // When true, full screen modes will be triple buffered, else double buffered bool MaxRefreshRate; // When true, full screen modes will use the maximum card refresh rate, else 60hz. int DirtyRectangle; // Bit 0=Enabled, Bit 1=Save Z buffer rectangles too, Bit 2=Save directly in system memory (don't try video memory). int DisableLowEndCard; // When set to 1 and video cards in VideoCard.cpp with the LowEndCard flag set will have hardware acceleration disabled DWORD MinimumTextureMemory; // If this value is !=0 it specifies the minimum TEXTURE memory required otherwise hardware acceleration is disabled // // Keys used by GameOS (Use 0 to disable them, or see keycodes later in this header) // DWORD Key_FullScreen; // Default is KEY_F4 (Enter/exit full screen mode) DWORD Key_SwitchMonitors; // Default is KEY_F5 (Change video cards - nvidia/voodoo etc...) DWORD Key_Exit; // Default is KEY_ESC (Exit full screen mode or exit game) // // Debugging settings // char* debugLog; // File to dump info to, or "debugger" to the debug console char* spew; // List of groups to dump to debuglog - eg: GameOS_Texture, GameOS_DirectDraw bool TimeStampSpew; // adds the current time stamp to all spews DWORD MemoryManager; // 0=custom memory manager, 1=windows memory manager, 2= DWORD memoryTraceLevel; // How many levels of stack to walk when tracing memory allocations // // Game related functions // float MaxTimeDelta; // Maximum time delta in seconds allowed between calls to gos_GetElapsedTime(); (Typical value = 1.0f) float MinimumTimeDelta; // If the time delta is greater than MaxTimeDelta, return this time to the application. (Typical value = 1.0f/30.0f) // // Sound-related application information // bool soundDisable; // false = disable all sound, true = enable all sound bool soundHiFi; // true = 44Khz sound, false = 22KHz int soundDevice; // 0 = primary/default, # = device enum int soundChannels; // Default number of sound channels, for example 8 int soundForceCache; // 0 = never force a stream resource into cached resource else # bytes under which to force resource to cached if streamed bool soundMixInHardware; // 0=no mixing sound in hardware (default), 1=mix sound in hardware, if available. // // Network settings // bool NetworkGame; // Is this game going to be network aware? bool DirectPlayProtocol; // If this instance is the server, should we use the DirectPlay protocol? union { BYTE NetworkGUID[16]; // This is the DirectPlay GUID that must be unique for the game GUID GameGUID; // Note that this union allows access as GUID but byte order will changing depending on initialization }; // All initialization of this code should use GameGUID from now on DWORD NetworkMaxPlayers; // The maximum number of players allowed in this game. BYTE NetGameInfo[16]; // Information about the current network game (this can be enumerated from other network games before you join them) char* (__stdcall *DecodeGameInfo)(void*Data); // GameOS will call this routine if present to decode the 16 bytes of network game information. char* ZoneMatchServerIP; // Typical value is ZoneMatch.zone.com int ZoneAdvertisePort; // Port games will be advertised on. This is the port ZoneMatch connects to to receive updates to a game's state. Don't // confuse this with the game's port, which would be the port that actual clients who want to play the game would connect // to. Typical value is APP_QUERY_PORT (27999) bool NetServerMigration; // When true, the server player can quit and the game will continue (another machine will become the server) // // Controller settings // bool ButtonsAsKeys; // when true, gos_GetKey will return events for controller button presses bool allowDoubleClicks; // make double-click messages available to the application (default is false) // // Raid Database settings // char* RaidFilePath; // The path where the exception files for your project should be stored. They will be referred to by hyperlink in the bug description. char* RaidCustomFields; // A string containing key-value pairs of Raid Database column name and the value for that record. the column must be of type var-char with a width of 32 (standard raid list) char* RaidDataSource; // The raid data source name (can be retrieved from your odbc control panel or the registry once an rdq has been opened on your machine. char* RaidDescTemplate; // A string sets the default text that appears in the description of the bug eg. Description: \n REPRO STEPS: \n etc. // // // // // These are legacy and will be deleted // DWORD NetworkMinPlayers; // The minimum number of player required to start a game DWORD AllowJoinInProgress; // When true 'join in progress' is enabled for this network game DWORD Texture_S_256; // Number of 256*256 Solid texture heap pages DWORD Texture_S_128; // Number of 128*128 Solid texture heap pages DWORD Texture_S_64; // Number of 64*64 Solid texture heap pages DWORD Texture_S_32; // Number of 32*32 Solid texture heap pages DWORD Texture_S_16; // Number of 16*16 Solid texture heap pages DWORD Texture_K_256; // Number of 256*256 Keyed texture heap pages DWORD Texture_K_128; // Number of 128*128 Keyed texture heap pages DWORD Texture_K_64; // Number of 64*64 Keyed texture heap pages DWORD Texture_K_32; // Number of 32*32 Keyed texture heap pages DWORD Texture_K_16; // Number of 16*16 Keyed texture heap pages DWORD Texture_A_256; // Number of 256*256 Alpha texture heap pages DWORD Texture_A_128; // Number of 128*128 Alpha texture heap pages DWORD Texture_A_64; // Number of 64*64 Alpha texture heap pages DWORD Texture_A_32; // Number of 32*32 Alpha texture heap pages DWORD Texture_A_16; // Number of 16*16 Alpha texture heap pages // // This flag suppresses the "No 3D Acceleration" message when not full screen. // MC2 needs this so that the initial MessageBox can display a warning about sniffing you machine. // At any time during the release builds, the game will be full screen. bool Suppress3DFullScreenWarning; // Now functions GameOS can call in the application // Returns custom data used in special places by GameOS void * (__cdecl *GetSpecialGameData)(int data_type, ...); // // Returns a string containing game data // This is called during error routines, so NO errors must be able to occur in this routine. // Do not assume DirectX or your memory heap etc.. are valid. // char* (__stdcall *GetGameInformation)(); // // Called ONCE only, after GameOS has been setup, just before main loop starts // All memory should be allocated and all structures should be cleared // void (__stdcall *InitializeGameEngine)(); // // Called each main loop, game should move 'one tick' if DoTimedGameLogic is not set // Do not update the display, just do the game logic. // void (__stdcall *DoGameLogic)(); // // Called each main loop, game should update it's sound and video renderers. // This is the only time draw or sound functions within the game are valid. // These are not allowed during DoGameLogic so renders may be skipped during // heavy loads or during 'fast playback' of a logfile. // void (__stdcall *UpdateRenderers)(); // // GameOS will call this once it comes out of the main loop, before it shuts down // No display updating should be attempted. This should be used to free all memory. // void (__stdcall *TerminateGameEngine)(); // // // // // Applications can use thie to 'hook into' the gos_GetFile function. // // This allows you to 'catch' all the gos_GetFile calls. If you wish to have a compressed file system, // or manage your own content directories, this API will allow you to catch all the access to the disk // that GameOS does. All texture reading and gosScript file access goes through this API. If this hook // function is 0 (default) then the calls will go to gos_GetFile. If you put the address of your own // function there, GameOS will jump to that function. GameOS will check for gos_GetFIle being called // again during this function and allow it to read from the disk normally. // void (__stdcall *HookGetFile)( const char* FileName, BYTE** MemoryImage, DWORD* Size ); // Other file API calls available to hook bool (__stdcall *HookDoesFileExist)( const char* FileName); } gosEnvironment; // // GameOS will call this function once, before it sets anything up. // NO errors must occur, or any GameOS functions called. // Only the environment structure should be setup. // The structure is cleared by GameOS, so any unused data or functions can be left empty. // // The command line that was used to start the game is passed // void __stdcall GetGameOSEnvironment( char* CommandLine ); // // Called by the Game to cause GameOS to quit and exit (at the end of the current frame - not immediatly) // void __stdcall gos_TerminateApplication(); // // In the Environment.TerminateGameEngine routine this function will tell you if you can prompt the user or if you must just terminate (for exmaple on log file playback) // bool __stdcall gos_UserExit(); // // While the application is inside the Environment.TerminateGameEngine routine it may execute this to make GameOS continue. // void __stdcall gos_AbortTermination(); // // This API can be used to create 'modal' dialogs. It will run the GameOS main lopp (reading input devices, rendering etc...) WITHOUT running the gamelogic. // This allows you to call this function in a loop from within your GameLogic to wait for a key, do a modal dialog etc.. Then continue with your game logic. // This API returns true if the user closed the window or called gos_TerminateApplication. The application will exit when it finishs it's GameLogic loop // It is passed the function to call in place of the original gamelogic. If this is passed 0, no game logic is called. If the original gamelogic loop should be used, pass Environment.DoGameLogic // Returns true if the game was terminated // bool __stdcall gos_RunMainLoop( void(__stdcall *DoGameLogic)()=0 ); ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // ****************************** VIDEO API ***************************** // ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // An enumeration of the various commands to the Video playback API. enum gosVideo_Command { gosVideo_SeekTime = 1, // Seek to a frame or timestamp in hVideo gosVideo_SetCoords = 2, // Set the destination coordinates of via gosVideo_SetScale = 4, // Change the scale of on the fly via gosVideo_Volume = 8, // Set the volume of the multiVideo gosVideo_Panning = 16 // Set the pan of the multiVideo }; ////////////////////////////////////////////////////////////////////////////////// // An enumeration of the various states the video playback can be in. enum gosVideo_PlayMode { gosVideo_PlayOnceHide, // The Video is currently playing (will hide when done) gosVideo_PlayOnceHold, // The Video is currently playing (will hold when done) gosVideo_Loop, // The Video is currently in continuous play mode gosVideo_Stop, // The Video is stopped gosVideo_Pause, // The Video has been paused gosVideo_Continue // SET ONLY: continue a paused Video }; ////////////////////////////////////////////////////////////////////////////////// // This structure is used to send and receive information about a particular video // resource. Each command (above) requires specific info to be initialized in the // structure below in order to properly carry out that command. For this data, // consult the comments listed under the appropriate command (listed above). typedef struct _gosVideo_Info { char * lpstrPath; // string specified path to data gosVideo_PlayMode ePlayMode; // the play mode (see above) gosVideo_PlayMode ePlayStatus; // the play mode (see above) DWORD dwOriginX; // x coord on dest. surf for video DWORD dwOriginY; // y coord on dest. surf for video float fScaleOfX; // ratio of displayed to orgininal width float fScaleOfY; // ratio of displayed to orgininal height float fDurationSec; // read-only duration of video (hundredth of a second) float fSoFarSec; // current play position (hundredth of a second) unsigned char * lpData; // RGB data DWORD dwSurfaceWidth; // read-only width of video surface DWORD dwSurfaceHeight;// read-only height of vidoe surface DWORD dwPitch; // read-only pitch of video surface DWORD dwWidth; // read-only width of video DWORD dwHeight; // read-only height of vidoe } gosVideo_ResourceInfo; ////////////////////////////////////////////////////////////////////////////////// // Send a command to an existing video resource or create a new video resource. // Consult the structures/enums listed above for more information. // void __stdcall gosVideo_CreateResource( HGOSVIDEO* Handle, char* filename ); void __stdcall gosVideo_CreateResourceAsTexture( HGOSVIDEO* Handle, DWORD* hTex, char* filename ); void __stdcall gosVideo_DestroyResource( HGOSVIDEO* Handle ); void __stdcall gosVideo_GetResourceInfo( HGOSVIDEO Handle, gosVideo_ResourceInfo* gvi ); void __stdcall gosVideo_SetPlayMode( HGOSVIDEO Handle, enum gosVideo_PlayMode gvpm ); void __stdcall gosVideo_Command( HGOSVIDEO Handle, enum gosVideo_Command vc, float x, float y = 0.0f ); ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // **************************** SOUND API ****************************** // ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // // This define serves as a reminder that access to global sound properties such as // overall volume and panning is handled on channel -1. Use the define below for // legibility. // #define gosAudio_Mixer -1 //////////////////////////////////////////////////////////////////////////////////////////////////////// // These properties can be assigned to any channel via the gosAudio_AllocateChannelSliders // function-- only allocate the sliders you intend to use on each channel-- this improves // both hardware and software performance. // enum gosAudio_Properties { gosAudio_Common = 1, // gosAudio_Volume = 2, // Volume can be adjusted independently of mixer (0.0 = silence, 1.0 = full volume) gosAudio_Panning = 4, // Panning can be adjusted independently of mixer (-1.0 = left, 0 = center, +1 = right) gosAudio_Frequency = 8, // Frequency can be adjust independently of mixer (< 1.0 = lower freq, 1.0 = normal, 2 = 2x, etc.) gosAudio_SeekTime = 16, // RESERVED gosAudio_Position = 32, // * The 3D position can be set gosAudio_Velocity = 64, // * The 3D velocity can be set gosAudio_FrontOrientation = 128, // Mixer only: set the front and top orientation of "ears." The front vector points in the direction gosAudio_TopOrientation = 256, // of the listener's nose, and the top vector points out the top of the listener's head. By default, // the front vector is (0,0,1.0) and the top vector is (0,1.0,0). gosAudio_MinMaxDistance = 512, // * Under minimum distance, volume is max; Over maximum distance, volume is zero gosAudio_Doppler = 1024, // Mixer only: 1.0f is real world, 2.0f is twice real world gosAudio_Rolloff = 2048, // Mixer only: 1.0f is real world, 2.0f is twice real world gosAudio_Distance = 4096, // Mixer only: position/velocity adjustment: 1.0f = same, 2.0f = double position/velocity gosAudio_Reverb = 8192, // .0f to 2.0f ( < 1.0 = muffled, > 1.0 = exagerated) gosAudio_Decay = 16384, // .1f to 20.0f (in seconds) gosAudio_ConeAngles = 32768, // expressed as degrees. 1st parameters is inner (full volume), second is outer (fully attenuated) gosAudio_ConeOrientation = 65536 // direction in which the cone points. }; //////////////////////////////////////////////////////////////////////////////////////////////////////// // This enum is used to set or return the client's speaker configuration. Note that gosAudio_DegreeArc may be bitwise OR'd into // the speaker type if the speaker type is gosAudio_Stereo. // enum gosAudio_SpeakerConfig { gosAudio_Headphones = 1, // The client system uses a pair of headphones for aural feedback gosAudio_Monaural = 2, // The client system has only one speaker attached gosAudio_Quadraphonic = 4, // The system is using a four-speaker system gosAudio_Stereo = 8, // This is a typical system configuration: two speakers, left and right gosAudio_Surround = 16, // The client system has several (more than four) speakers wired in gosAudio_DegreeArc5 = 32, // For a stereo system, the user may specify the arc over which the two speaker lie gosAudio_DegreeArc10 = 64, gosAudio_DegreeArc20 = 128, gosAudio_DegreeArc180 = 256 }; //////////////////////////////////////////////////////////////////////////////////////////////////////// // Sound Channels can be in one of the following states // enum gosAudio_PlayMode { gosAudio_PlayOnce, // Play the channel's resource once and then end gosAudio_Loop, // Continually play the channel's resource, looping after each iteration gosAudio_Pause, // Pause the sound, a Continue will resume the sound from where it was paused gosAudio_Continue, // SET ONLY: continue a sound that was paused. gosAudio_Stop, // Silence the channel and stop processing the resource }; //////////////////////////////////////////////////////////////////////////////////////////////////////// // Resource Types // typedef enum gosAudio_ResourceType { gosAudio_CachedFile, // Pull a WAV file from disk, parse it, and copy the raw sound data into system memory gosAudio_UserMemory, // Use a preloaded WAV already in the client's system memory. Note: This memory must remain intact until this resource is destroyed gosAudio_UserMemoryDecode, // Use a preloaded WAV already in the client's system memory. Note: Unlike UserMemory, UserMemoryDecode deciphers the waveformat itself. gosAudio_UserMemoryPlayList, // Play a series of same-format WAVs back to back, played from memory-mapped WAVs gosAudio_StreamedFile, // Leave the sound data on disk, streaming only the data when needed. Note: only volume and pan affect streamed files gosAudio_StreamedMusic, // Leave the sound data on disk, play a non-PCM/ADPCM song. gosAudio_StreamedFP // Streamed from a file pointer }; //////////////////////////////////////////////////////////////////////////////////////////////////////// // The format structure, for describing the format of sound resources // typedef struct _gosAudio_Format { WORD wFormatTag; // Waveform-audio format type. 1=PCM, 2=Microsoft ADPCM. WORD nChannels; // 1=Mono, 2=Stereo. DWORD nSamplesPerSec; // Sample rate, 11025Hz, 22050Hz or 44100Hz. DWORD nAvgBytesPerSec; // Normally, nBlockAlign * nSamplesPerSec WORD nBlockAlign; // Normally, wBitsPerSample / 8 * nChannels WORD wBitsPerSample; // Bits per sample for the wFormatTag format type. If wFormatTag is 1 (PCM), then wBitsPerSample should be equal to 8 or 16. WORD cbSize; // Size, in bytes, of extra format information appended to the end of the WAVEFORMATEX structure. For PCM's, this should be set to 0. For ADPCM, this should be set to 32. } gosAudio_Format; //////////////////////////////////////////////////////////////////////////////////////////////////////// // For gosAudio_UserMemoryPlayList resources, fill in the structure below and pass it in. The information // in the structure itself as well as the pointers within the arrays will be copied, so the structures // can be discarded once the resource has been created // typedef struct gosAudio_PlayList { DWORD m_dwListLength; // Number of sample in the playlist DWORD * m_lpSoundData; // A array of pointers pointing to the start of each memory-mapped WAV file. DWORD * m_lpDataLength; // The size of each corresponding sample in the playlist } gosAudio_PlayList; //////////////////////////////////////////////////////////////////////////////////////////////////////// // This structure is used to return important information about a particular resource. // typedef struct _gosAudio_ResourceInfo { char * lpstrPath; // the path or name of the resource queried gosAudio_ResourceType eType; // see above gosAudio_Format sFormat; // 1 = PCM, 2 = ADPCM DWORD dwSizeInBytes; // size of the data portion of the WAV float fDuration; // in seconds } gosAudio_ResourceInfo; //////////////////////////////////////////////////////////////////////////////////////////////////////// // GetChannelInfo returns all the following information when inquiring about a channel. Note that // the later portion is specific to the Mixer (channel -1) // typedef struct _gosAudio_ChannelInfo { HGOSAUDIO hAudio; DWORD dwProperties; // A bitwise flag field specifying which sliders have been allocated to it. gosAudio_PlayMode ePlayMode; // The current playmode of the channel float fVolume; // The current volume (0.0 - 1.0) of the channel float fPanning; // The current panning (-1.0 - +1.0) of the channel float fFrequency; // The current frequency (>0 - +#) of the channel float fCompletionRatio; // 0-100.0. float fPosX, fPosY, fPosZ; // If the channel is 3d, the position of the emitter/listener float fVelX, fVelY, fVelZ; // If the channel is 3d, the velocity of the emitter/listener float fMinDistance, fMaxDistance; // MinDistance under which sound is at full volume, MaxDistance after which sound too far away to be heard float fConeInner, fConeOuter; // The dimensions of the sound cone, in degrees float fConeX, fConeY, fConeZ; // The rotations applied to the sound cone, in radians ////////////////////////////////////////////////////////////////////////////////// // Mixer (channel -1) related // DWORD dwSpeakerConfig; // The speaker setup of the mixer float fFrontX, fFrontY, fFrontZ; // The forward-facing vector of the user's "ears" float fTopX, fTopY, fTopZ; // The top-pointing vector of the listener float fDoppler; // Typically 1.0, this can be manipulated for a desired effect float fRolloff; // Typically 1.0, this can be change to match a desired effect float fDistance; // Typically 1.0, this defines meters/unit within the sound system float fReverb; // If available, the reverbation factor of all channels float fDecay; // If available, the decay factor of all channels } gosAudio_ChannelInfo; ////////////////////////////////////////////////////////////////////////////////// // Creates a resource to be played later // void __stdcall gosAudio_CreateResource( HGOSAUDIO* hgosaudio, enum gosAudio_ResourceType, const char* file_name, gosAudio_Format* ga_wf = 0, void* data = 0, int size = 0, bool only2D = 0); void __stdcall gosAudio_CreateResource( HGOSAUDIO * hgosaudio, const char * identifier_name, HGOSFILE file, DWORD offset, bool only2D = 0); ////////////////////////////////////////////////////////////////////////////////// // Destroy a resource; any sounds currently playing using the ResourceID will be // stopped. // Any memory the SoundAPI associated with the resource will be freed. // void __stdcall gosAudio_DestroyResource( HGOSAUDIO* hgosaudio ); ////////////////////////////////////////////////////////////////////////////////// // This prepares the channel for a specific type of sound playback. Optimally, // allocate only the properties that will need modification. Use a bitwise'd group // of gosAudio_Properties to set what is needed. // void __stdcall gosAudio_AllocateChannelSliders( int Channel, DWORD properties); ////////////////////////////////////////////////////////////////////////////////// // Prepare a channel to play a resource of any type. // void __stdcall gosAudio_AssignResourceToChannel( int Channel, HGOSAUDIO hgosaudio); ////////////////////////////////////////////////////////////////////////////////// // Get and Set functions only operate if a channel has the property enabled // Channel number -1 used in SetVolume and SetPanning will alter the windows master // volume and balance void __stdcall gosAudio_SetChannelSlider( int Channel, enum gosAudio_Properties, float value1, float value2 = 0.0f, float value3 = 0.0f ); void __stdcall gosAudio_GetChannelSlider( int Channel, enum gosAudio_Properties, float* value1, float* value2 = 0, float* value3 = 0 ); ////////////////////////////////////////////////////////////////////////////////// // Set the speaker configuration. See enum above. // void __stdcall gosAudio_SetSpeakerConfig( DWORD config ); ////////////////////////////////////////////////////////////////////////////////// // Play, Loop, Stop, Pause, or Continue a particular channel // void __stdcall gosAudio_SetChannelPlayMode( int Channel, enum gosAudio_PlayMode ga_pm ); ////////////////////////////////////////////////////////////////////////////////// // Determine the current play mode of a channel // gosAudio_PlayMode __stdcall gosAudio_GetChannelPlayMode( int Channel ); ////////////////////////////////////////////////////////////////////////////////// // Get the filename, type, frequency and number of channels for a sound resource // void __stdcall gosAudio_GetResourceInfo( HGOSAUDIO hSound, gosAudio_ResourceInfo* sri ); void __stdcall gosAudio_GetChannelInfo( int Channel, gosAudio_ChannelInfo* sri ); ////////////////////////////////////////////////////////////////////////////////// // Reset the sound system if you wanna change the original sound device, // or the KHz of the mixer.... // void __stdcall gosAudio_Reset(); ////////////////////////////////////////////////////////////////////////////////// // Get a list of available sound devices. Returns possibilities as strings in // void __stdcall gosAudio_DeviceOptions( char names[8][128], int* available ); ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // ************************* LOCALIZATION API ***************************// ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////// // struct gosIME_Appearance // This structure is used to control appearance of IME UI. // // symbolColor(*): RGB Color of symbol. // If no symbol color is specified, the Henkan-kyu is grey when inactive and a rainbow sphere when active // symbolColorText(*): RGB Color of text in the symbol // symbolHeight: the size (in pixels) of the IME symbol // symbolTranslucence: the translucency level of the IME symbol (0-255 from invisible to opaque) // symbolPlacement: where the symbol is placed on the screen: // // 0 - to the right or left of the current print margins, centered vertically top to bottom (default) // 1 - the upper left corner of the screen // 2 - the upper right corner of the screen // 3 - the lower right corner of the screen // 4 - the lower left corner of the screen // // candColorBase: RGB background color of the candidate list // candColorBorder: RGB border & highlight color of the candidate list // candColorText: RGB the text color of the candidate list // If it's 0, the selected text color at last gos_PositionIME() call is used // // compColorInput(*): RGB Color for background of character currently being entered by the user // compColorTargetConv(*): RGB Color for background of portion of composition currently being converted // compColorConverted(*): RGB Color for background for converted portion of composition string // compColorTargetNotConv(*): RGB Color for background for unconverted portion of composition string // compColorInputErr(*): RGB Color for background for erroneous portion of composition string // compTranslucence: The translucency of composition string (0-255 from invisible to opaque) // compColorText: RGB Color for the string (effective only in level 2) // If it's 0, the selected text color at last gos_PositionIME() call is used // (* - transparency value is ignored ) // typedef struct _gosIME_Appearance { // symbol (Henkan-kyu) DWORD symbolColor; DWORD symbolColorText; BYTE symbolHeight; BYTE symbolTranslucence; BYTE symbolPlacement; // candidate list DWORD candColorBase; DWORD candColorBorder; DWORD candColorText; // composition string DWORD compColorInput; DWORD compColorTargetConv; DWORD compColorConverted; DWORD compColorTargetNotConv; DWORD compColorInputErr; BYTE compTranslucence; DWORD compColorText; } gosIME_Appearance; // // Opens a DLL and returns a handle // DWORD __stdcall gos_OpenResourceDLL( const char* FileName ); // // Use to close a resource DLL // void __stdcall gos_CloseResourceDLL( DWORD Handle ); // // Returns a string from a resource (or a place holder if string not defined) // // This returns a pointer to an internal GameOS 4K buffer. It is only valid until the next call to gos_GetResourceString // char* __stdcall gos_GetResourceString( DWORD Handle, DWORD Id ); // // Returns a void* to block of memory stored in the resource .dll. Resources // that are stored in this fashion must be a "custom" resource and their resource type // string must match that of the 2nd parameter. // // If the resource cannot be found, a NULL is returned. // // If the resource is found, size is set to the size of resource in // bytes and the resource data is copied into a freshly allocated memory block from the // currently designated heap. It is the responsibility of the client application to // release this memory when it is no longer needed. // void* __stdcall gos_GetResourceData( DWORD Handle, const char* type, DWORD id, size_t * size ); // // If the user's OS supports IME, this function will Enable/Disable the user's ability to interface with the IME for // in the GameOS application. If is false, the user will be unable to bring up the input // method editor's interface via ALT-~. // void _stdcall gos_EnableIME( bool enabledDisabled ); // // If the user's OS supports IME, and the IME is enabled (see above), the application can forcibly switch the IME to // the active state. When active, the user's keypresses will be fed to the IME for clarification via the IME interface // and candidate list. Note that this is the programatic equivalent of the user pressing ALT-~. // void _stdcall gos_ToggleIME( bool activeInactive ); // // If the user's OS supports IME, set text entry caret screen position (Used to enable the localization IME pop-up // at the correct place): // void _stdcall gos_PositionIME( DWORD x, DWORD y ); // // Finalize current composition string. An application should call this function when focused edit box is clicked // void _stdcall gos_FinalizeStringIME(); // // Sets IME support level (2 or 3) // 2 - Composition string is drawn by IME UI library. GOS application receives characters when composition string is finalized. // 3 - Composition string is drawn by GOS application (default). GOS application receives characters and control keys whenever composition string changes. // void _stdcall gos_SetIMELevel( DWORD dwImeLevel ); // // Sets appearance of IME UI // void _stdcall gos_SetIMEAppearance( const gosIME_Appearance* pia ); // // Gets appearance of IME UI // void _stdcall gos_GetIMEAppearance( gosIME_Appearance* pia ); // // Tell the IME whether or not the IME should process keystrokes in Overwrite mode // (bInsert = false) or in Insert mode (bInsert = true) // void _stdcall gos_SetIMEInsertMode(bool bInsert); // // Returns a localized string describing a date as either short form "02/03/2000" or Verbose form "Wednesday, May 3rd, 1999" // // If the Year, Month and Day are -1 the current time is used // char* __stdcall gos_GetFormattedDate( bool Verbose, WORD Year=-1, WORD Month=-1, WORD Day=-1 ); // // Returns the year month and day // void __stdcall gos_GetUnformattedDate( WORD *Year, WORD *Month, WORD *Day); // // Returns a localized string describing a time "11:45:32 PM" // // If the Hours, Minutes and Seconds are -1 the current time is used // char* __stdcall gos_GetFormattedTime( WORD Hour=-1, WORD Minute=-1, WORD Second=-1 ); ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // ************************** 3D FONT API ****************************** // ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // // Init font - reads a .TGA file and decodes it as a font // // Return value is a handle that can be passed to the font routines // // Rules for FONT.TGA files: // // Fonts must be drawn on a regular grid, ie: 6*8, 8*8, 8*12, 16*16 // // The grid must start at the top left of the .TGA file and go all the // way to the edge. The next letters must start directly below the top // line of letters. // // The first character must be a single pixel thick box, the same size // as the grid - this is how GOS measures grid size. // // The 2nd character must be character ascii code 33 (!) all the other // characters must be incrementing ascii characters up to character 127. // // The remainder of any .TGA file is used. See Ariel8.tga for an example // // A proportional font need not be centered in the grid squares. GameOS // will calculate the leading blank pixels and width of each character. // It is important the characters should be centered vertically properly // and if the font will be displayed as a fixed pich font then the letters // should be centered. Letters should not use the right or bottom row of // the grid as these rows do not render accuratly across all cards. So // and 8*8 font would have 7*7 sized letters aligned in the top left. // // The StartLine parameter is the Y position for the top of the font. There // maybe multiple fonts in a single texture. // // CharCount is the ASCII value of the last character in the font // texture plus one. // HGOSFONT3D __stdcall gos_LoadFont( const char* FontFile, DWORD StartLine = 0, int CharCount = 256, DWORD TextureHandle=0 ); // // This routine should be called to release storage and textures used by fonts. // void __stdcall gos_DeleteFont( HGOSFONT3D Fonthandle ); // // FontHandle - This must be a previously loaded font // Foreground - Foreground color (Background color should be done by drawing a quad) - Alpha must be FF for solid text // Size - If > 0, the desired scale of the font (in multiples of the point size). If < 0, the absolute point size (-8 = 8 Point Font) // WordWrap - If true words will be wraped within region, otherwise clipped // Proportional - If false words are displayed fixed pitch // Bold - If true text is bolded (Displays the text twice, shifted a pixel so is half the speed as normal text) - To display a lot of text use a bold font. // Italic - If true text is italiced // WrapType - 0=Left aligned, 1=Right aligned, 2=Centered, 3=Centered in region (X and Y) // // This API just updates internal variables, it's very fast to change any of these parameters // void __stdcall gos_TextSetAttributes( HGOSFONT3D FontHandle, DWORD Foreground, float Size, bool WordWrap, bool Proportional, bool Bold, bool Italic, DWORD WrapType=0, bool DisableEmbeddedCodes=0 ); // // Set the current position of the cursor. (Screen pixels) // // This API just updates internal variables, it's very fast to change any of these parameters // void __stdcall gos_TextSetPosition( int XPosition, int YPosition ); // // Returns the current print position // void __stdcall gos_TextGetPrintPosition( int* XPosition, int* YPosition ); // // Set the region that the cursor will be clipped to (in screen pixels) // The text will be clipped or wrap when the right edge is reached // // This API just updates internal variables, it's very fast to change any of these parameters // void __stdcall gos_TextSetRegion( int Left, int Top, int Right, int Bottom ); // // Draws a solid rectangle in the region specified (will be clipped to the TextSetRegion) // This can be used to draw the 'background' of any text. // Remember! - To set the alpha component of the color to FF if you want a solid background // void __stdcall gos_TextDrawBackground( int Left, int Top, int Right, int Bottom, DWORD Color ); // // Returns pixel height and width of string (Height=Height of charcters * number of /n found) // Make sure you have setup the Text attributes before calling this. // void __stdcall gos_TextStringLength( DWORD* Width, DWORD* Height, const char *Message, ... ); // // Draws string using current attributes and position // // Special Codes - // // \n Return to left edge of current region, move down a line // /color=AARRGGBB Sets the current color (AARRGGBB are in hex) - AA = FF for solid text // /proportional=? ? is 1 or 1 // /bold=? ? is 1 or 1 // /italic=? ? is 1 or 1 // // / character (/ not followed by a special code will be displayed as - // is only required to display strings like "//color" // void __stdcall gos_TextDraw( const char *Message, ... ); // // Same as above, but an arglist can be passed // void __stdcall gos_TextDrawV( const char *Message, char* arglist ); ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // **************************** FILE API ******************************** // ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // // // Read a whole file into memory. // // The whole file in read into memory, MemoryImage will point to the start of the file, // Size will be the size of the file. // void __stdcall gos_GetFile( const char* FileName, BYTE** MemoryImage, DWORD* Size ); // // Opens a memory mapped file - returns a handle that must be passed to the Close function below. // DWORD __stdcall gos_OpenMemoryMappedFile( const char* FileName, BYTE** MemoryImage, DWORD* Size ); // // Closes a memory mapped file // void __stdcall gos_CloseMemoryMappedFile( DWORD Handle ); // // Opens and reads in the whole file in a background thread. The MemoryImage pointer will be NULL until the file is read in completly. // When you are finished with the file, the Close function below must be called. // DWORD __stdcall gos_ReadFileInBackground( const char* FileName, BYTE** MemoryImage, DWORD* Size, DWORD Offset=0, DWORD MaxSize=0xffffffff ); // // Closes and releases the memory used by a file read in the background. // void __stdcall gos_CloseBackgroundFile( DWORD Handle ); ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // ************************** MEMORY API **************************** // ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: to gather information about memory leaks in your application, you // must have "GameOS_Memory" in your Environment.spew variable. Also, you can // adjust the call stack trace info via the Environment.memoryTraceLevel variable. // A good default level is 5. Also be aware that in Profile and Release // compilation modes, no call stack information is gathered. // ////////////////////////////////////////////////////////////////////////////////// // // By default, any gos_Malloc's or new's made by the client application will be dropped // into this heap: the ParentClientHeap. Use ParentClientHeap to explicitly tell the Memory Manager // to place allocated memory into client memory. // extern HGOSHEAP ParentClientHeap; // // When including GamePlatform, new and delete will map directly to gos_Malloc and gos_Free // // new also has an optional second parameter which specifies the heap to allocate from. // // // Not filling in the heap parameter on gos_Malloc's tells the Memory Manager to allocate memory in // the heap currently on top of the heap stack. // void* __stdcall gos_Malloc( size_t bytes, HGOSHEAP Heap = 0 ); void __stdcall gos_Free( void* ptr ); // // Not filling in the heap parameter on new's tells the Memory Manager to allocate memory in // the heap currently on top of the heap stack. // void* __cdecl operator new (size_t size, HGOSHEAP Heap); // // Allows an application to create a named memory heap. // // The DWORD returned is a heap number that can be the second parameter passed to new or gos_Malloc. // // If MaximumSize is specified, GameOS will assert when more than that number of bytes is allocated. // // The memory heaps and current sizes are visible in the GameOS debugger. // HGOSHEAP __stdcall gos_CreateMemoryHeap( char* HeapName, DWORD MaximumSize=0, HGOSHEAP parentHeap = ParentClientHeap); // // Allows the application to destroy a previously created memory heap. // Note that, at shutdown, the default heap is destroyed automatically. // // o Destroying a heap destroys all its children as well // o Setting shouldBeEmpty to false silences the deallocation of memory // still assigned to the heap or its children. We don't encourage this // as it can result in non-NULLed pointers within the client code. // void __stdcall gos_DestroyMemoryHeap( HGOSHEAP Heap, bool shouldBeEmpty = true ); // // Sets the current heap being used by new and delete (and any gos_Mallocs that don't specifiy a heap) // // The 'default heap' for all client memory is caught by ClientHeap. // void __stdcall gos_PushCurrentHeap( HGOSHEAP Heap ); HGOSHEAP __stdcall gos_GetCurrentHeap(); void __stdcall gos_PopCurrentHeap(); // // To verify that memory hasn't been corrupted during particularly dicey operations, the gos_WalkMemoryHeap // function has been provided. // // If a client application tries to write beyond the bounds of the memory allocated to it by the Memory Manager, // An exception will occur, notifying the user. Passing a NULL (or 0) as pHeap will check ALL heaps. // // o NOTE: if vociferous is set to true, the client application will receive information on the blocks allocated // in the specified heap at the time of the call. These SPEWs will occur only if Environment.memoryTraceLevel // is // void __stdcall gos_WalkMemoryHeap(HGOSHEAP pHeap, bool vociferous = false); ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // ************************** KEYBOARD API ****************************** // ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // A list of the "buttons" on a keyboard. typedef enum gosEnum_KeyIndex { KEY_ESCAPE = 0x1B, KEY_1 = '1', KEY_2 = '2', KEY_3 = '3', KEY_4 = '4', KEY_5 = '5', KEY_6 = '6', KEY_7 = '7', KEY_8 = '8', KEY_9 = '9', KEY_0 = '0', KEY_MINUS = 0xBD, // - on main keyboard KEY_EQUALS = 0xBB, KEY_BACK = 0x08, // Backspace KEY_TAB = 0x09, KEY_Q = 'Q', KEY_W = 'W', KEY_E = 'E', KEY_R = 'R', KEY_T = 'T', KEY_Y = 'Y', KEY_U = 'U', KEY_I = 'I', KEY_O = 'O', KEY_P = 'P', KEY_LBRACKET = 0xDB, KEY_RBRACKET = 0xDD, KEY_RETURN = 0x0D, // Enter on main keyboard KEY_LCONTROL = 0x11, // Both controls (not left) KEY_A = 'A', KEY_S = 'S', KEY_D = 'D', KEY_F = 'F', KEY_G = 'G', KEY_H = 'H', KEY_J = 'J', KEY_K = 'K', KEY_L = 'L', KEY_SEMICOLON = 0xBA, KEY_APOSTROPHE = 0xDE, KEY_GRAVE = 0xC0, // accent grave KEY_LSHIFT = 0x10, // Both shifts (not left) KEY_BACKSLASH = 0xDC, KEY_Z = 'Z', KEY_X = 'X', KEY_C = 'C', KEY_V = 'V', KEY_B = 'B', KEY_N = 'N', KEY_M = 'M', KEY_COMMA = 0xBC, KEY_PERIOD = 0xBE, // . on main keyboard KEY_SLASH = 0xBF, // / on main keyboard KEY_RSHIFT = 0x10, // Both shifts, not just right KEY_MULTIPLY = 0x6A, // * on numeric keypad KEY_LMENU = 0x12, // Both Alt keys KEY_SPACE = 0x20, KEY_CAPITAL = 0x14, KEY_F1 = 0x70, KEY_F2 = 0x71, KEY_F3 = 0x72, KEY_F4 = 0x73, KEY_F5 = 0x74, KEY_F6 = 0x75, KEY_F7 = 0x76, KEY_F8 = 0x77, KEY_F9 = 0x78, KEY_F10 = 0x79, KEY_NUMPAD7 = 0x67, KEY_NUMPAD8 = 0x68, KEY_NUMPAD9 = 0x69, KEY_SUBTRACT = 0x6d, // - on numeric keypad KEY_NUMPAD4 = 0x64, KEY_NUMPAD5 = 0x65, KEY_NUMPAD6 = 0x66, KEY_ADD = 0x6b, // + on numeric keypad KEY_NUMPAD1 = 0x61, KEY_NUMPAD2 = 0x62, KEY_NUMPAD3 = 0x63, KEY_NUMPAD0 = 0x60, KEY_DECIMAL = 0x6e, // . on numeric keypad KEY_F11 = 0x7a, KEY_F12 = 0x7b, KEY_F13 = 0x7c, // (NECPC98) KEY_F14 = 0x7d, // (NECPC98) KEY_F15 = 0x7e, // (NECPC98) KEY_KANA = 0x15, // (Japanese keyboard) KEY_CONVERT = 0x1c, // (Japanese keyboard) KEY_NOCONVERT = 0x1d, // (Japanese keyboard) KEY_YEN = 0xdc, // (Japanese keyboard) KEY_NUMPADEQUALS= 0x92, // = on numeric keypad (NECPC98) KEY_CIRCUMFLEX = 0xde, // (Japanese keyboard) KEY_AT = 0xc0, // (NECPC98) KEY_COLON = 0xba, // (NECPC98) KEY_UNDERLINE = 0xdf, // (NECPC98) KEY_KANJI = 0x19, // (Japanese keyboard) KEY_STOP = 0x13, // (NECPC98) KEY_AX = 0x96, // (JapanAX) KEY_UNLABELED = 0x97, // (J3100) KEY_NUMPADENTER = 0x0D, // Enter on numeric keypad KEY_RCONTROL = 0x11, // Both controls (not right), KEY_NUMPADCOMMA = 0x6c, // , on numeric keypad (NECPC98) KEY_DIVIDE = 0x6F, // / on numeric keypad KEY_SYSRQ = 0x2C, KEY_RMENU = 0x12, // Both Alt keys KEY_HOME = 0x24, // Home on arrow keypad KEY_CENTER = 0x0c, // Key 5 on the numeric keypad KEY_UP = 0x26, // Up Arrow on arrow keypad KEY_PRIOR = 0x21, // Pg Up on arrow keypad KEY_LEFT = 0x25, // Left Arrow on arrow keypad KEY_RIGHT = 0x27, // Right Arrow on arrow keypad KEY_END = 0x23, // End on arrow keypad KEY_DOWN = 0x28, // Down Arrow on arrow keypad KEY_NEXT = 0x22, // PgDn on arrow keypad KEY_INSERT = 0x2D, // Insert on arrow keypad KEY_DELETE = 0x2E, // Delete on arrow keypad KEY_LWIN = 0x5B, // Left Windows key KEY_RWIN = 0x5C, // Right Windows key KEY_APPS = 0x5D, // AppMenu key KEY_NUMLOCK = 0x90, // NUMLOCK KEY_PAUSE = 0x13, // PAUSE Key KEY_LMOUSE = 1, // Left mouse button KEY_RMOUSE = 2, // Right mouse button KEY_MMOUSE = 3, // Middle mouse button KEY_MOUSEX1 = 4, // New mouse button 1 KEY_MOUSEX2 = 5, // New mouse button 2 }; typedef enum gosEnum_KeyStatus { KEY_FREE, KEY_PRESSED, KEY_HELD, KEY_RELEASED, }; typedef enum gosEnum_KeyDeviceType { KEYDEV_KEYBOARD = 0x00000000, KEYDEV_JOYSTICK = 0x01000000, }; enum { KEYDEV_MASK = 0xff000000 }; ////////////////////////////////////////////////////////////////////////////////// // Get the status of key . TRUE means it is pressed, while FALSE means // it is unpressed. // // Mouse buttons are keys, 1,2,3,4 and 5 (1 is Left, 2 is right, 3 is middle, 4 and 5 are on the 5 button mice) // gosEnum_KeyStatus __stdcall gos_GetKeyStatus( gosEnum_KeyIndex index ); ////////////////////////////////////////////////////////////////////////////////// // Get extended keys from keyboard. // // NULL until a key is pressed // Low byte is ASCII key values - or 0 when high byte is an extended keycode that is not ASCII // High byte is a 'gosEnum_KeyIndex' code such as KEY_LEFT ) // // For example cursor left is KEY_LEFT<<8 // For example the enter key is KEY_ENTER<<8 + 13 // For example the 'a' key is KEY_A<<8 + 'a' // // There is an extra bit that may be added on some keyboards to signify an 'extended key'. This bit // is require to display the correct key name. Applications should only use this bit for the // gos_DescribeKey function. This extra bit is bit 16, i.e. 0x10000 - This bit SHOULD be masked off // unless you are going to use the value for gos_DescribeKey. // // If Environment.ButtonsAsKeys is set, then gos_GetKey will also get button presses. The high byte // of the dword will indicate the type of device (KEYDEV_KEYBOARD or KEYDEV_JOYSTICK); the second // byte will indicate the ID of the device (always 0 [or 1 for extended keys] for keyboard), ie // joystick #1 or #2, etc., and the third byte will indicate the button ID on the device. The low // byte will always be zero (since these buttons never map to ASCII). For example, a return value of // 0x01020300 is button 3 on joystick #2. // DWORD __stdcall gos_GetKey(); // // Returns the displayable name of a key press returned from gos_GetKey() eg: "A", "Cursor Left" or "Enter" // char* __stdcall gos_DescribeKey( DWORD Key ); ////////////////////////////////////////////////////////////////////////////////// // Clear the client keyboard buffer void __stdcall gos_KeyboardFlush(); ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // ************************** JOYSTICK API ****************************** // ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // // The various outputs that can be examined by GameOS. // typedef enum GOSJoystickAxis { JOY_XAXIS = 0, JOY_YAXIS = 1, JOY_ZAXIS = 2, JOY_THROTTLE = 2, JOY_RXAXIS = 3, JOY_RYAXIS = 4, JOY_RZAXIS = 5, JOY_RUDDER = 5, JOY_SLIDER1 = 6, JOY_SLIDER2 = 7, JOY_HAT1 = 8, JOY_POV1 = 8, JOY_HAT2 = 9, JOY_POV2 = 9, JOY_HAT3 = 10, JOY_POV3 = 10, JOY_HAT4 = 11, JOY_POV4 = 11, JOY_MAX = 12 }; // // Information returned about each joystick // struct gosJoystick_Info { const char* lpstrName; // the brand and model name DWORD bAxisValid:JOY_MAX; // yes/no bitflags. DWORD nAxes:4; // number of availab axes DWORD nButtons:5; // number of available buttons DWORD nSliders:4; // number of slidesr DWORD nPOVs:4; // number of point of view hats DWORD bIsPolled:1; // whether or not this stick is polled DWORD bIsForceFeedback:1; // 1 spare bit }; // // Used in defining a force feedback forces // typedef enum gosForce { gosForce_Constant, gosForce_Ramp, gosForce_Square, gosForce_Sine, gosForce_Triangle, gosForce_SawtoothUp, gosForce_SawtoothDown }; #define gosFOREVER -1.0f typedef struct { float fAttackLevel; float fAttackTime; float fFadeLevel; float fFadeTime; } gosJoystick_ForceEnvelope; typedef struct _gosJoystick_ForceEffect { gosForce eType; bool bAffectedAxes[12]; float fXOrigin, fYOrigin; float fMagnitude; float fDurationSec; float fScale; gosJoystick_ForceEnvelope * lpEnvelope; union { long lPhase; float fStart; }; union { float fOffset; float fEnd; }; float fPeriodSec; } gosJoystick_ForceEffect; // // Return the total number of joysticks detected when the application started. // This API may take up to 100ms to comlete, so should be called on a 'Refresh button' in an options screen. // When a joystick is unplugged during gameplay, you need to call this API to have GameOS 're-detect' it. // This will also detect any new joysticks plugged into the computer since the application started. // // If ReDetect is 0, the joysticks are not re-init'ed this can take up to two seconds on some hardware // DWORD __stdcall gosJoystick_CountJoysticks( bool ReDetect=1 ); // // Return joystick 's details in structure // void __stdcall gosJoystick_GetInfo( DWORD index, gosJoystick_Info* gji ); // // Turn the polling of joystick on or off. howOften variable details the // frequency of polling. A 'howOften' of .5 will poll twice per second, for // example. By default, it polls at 30Hz. // void __stdcall gosJoystick_SetPolling( DWORD index, bool yesNo, float howOften=0.03333f ); // // Return the current value of a particular joystick's particular axis. The // value is mapped internally to range between -1.0f and 1.0f. // except for POV which are at -1 when at rest, a %clockwise when engaged // float __stdcall gosJoystick_GetAxis( DWORD index, GOSJoystickAxis axis ); // // Return a value (FALSE unpressed, TRUE pressed) for the button