diff --git a/project/jni/application/biniax2/AndroidAppSettings.cfg b/project/jni/application/biniax2/AndroidAppSettings.cfg new file mode 100644 index 000000000..dd8ae2d6e --- /dev/null +++ b/project/jni/application/biniax2/AndroidAppSettings.cfg @@ -0,0 +1,51 @@ +# The application settings for Android libSDL port +AppSettingVersion=17 +LibSdlVersion=1.2 +AppName="Biniax2" +AppFullName=com.biniax.sdl +ScreenOrientation=h +InhibitSuspend=n +AppDataDownloadUrl="!Game data|data.zip" +VideoDepthBpp=16 +NeedDepthBuffer=n +NeedStencilBuffer=n +NeedGles2=n +SwVideoMode=y +SdlVideoResize=y +SdlVideoResizeKeepAspect=n +CompatibilityHacks=n +CompatibilityHacksStaticInit=n +CompatibilityHacksTextInputEmulatesHwKeyboard=n +AppUsesMouse=n +AppNeedsTwoButtonMouse=n +ShowMouseCursor=n +ForceRelativeMouseMode=n +AppNeedsArrowKeys=y +AppNeedsTextInput=n +AppUsesJoystick=n +AppUsesAccelerometer=n +AppUsesMultitouch=n +NonBlockingSwapBuffers=n +RedefinedKeys="RETURN" +AppTouchscreenKeyboardKeysAmount=2 +AppTouchscreenKeyboardKeysAmountAutoFire=0 +RedefinedKeysScreenKb="RETURN SPACE" +StartupMenuButtonTimeout=0 +HiddenMenuOptions='' +FirstStartMenuOptions='' +MultiABI=n +AppVersionCode=1301 +AppVersionName="1.3.01" +ResetSdlConfigForThisVersion=n +DeleteFilesOnUpgrade="%" +CompiledLibraries="sdl_image sdl_mixer" +CustomBuildScript=n +AppCflags='' +AppLdflags='' +AppSubdirsBuild='src/*' +AppCmdline='' +ReadmeText='^.' +MinimumScreenSize=n +AdmobPublisherId=n +AdmobTestDeviceId= +AdmobBannerSize= diff --git a/project/jni/application/biniax2/AndroidData/data.zip b/project/jni/application/biniax2/AndroidData/data.zip new file mode 100644 index 000000000..98699c710 Binary files /dev/null and b/project/jni/application/biniax2/AndroidData/data.zip differ diff --git a/project/jni/application/biniax2/icon.png b/project/jni/application/biniax2/icon.png new file mode 100644 index 000000000..976b7a0b8 Binary files /dev/null and b/project/jni/application/biniax2/icon.png differ diff --git a/project/jni/application/biniax2/src/biniax.c b/project/jni/application/biniax2/src/biniax.c new file mode 100644 index 000000000..25afb9d46 --- /dev/null +++ b/project/jni/application/biniax2/src/biniax.c @@ -0,0 +1,1304 @@ +/****************************************************************************** + BINIAX 2 + by + Jordan Tuzsuzov + + http://www.biniax.com + +- VERSION : +Implements gameplay revision 2.0; +Game version 2.0 ( 4+1 keys control (directions+select/menu) ) +Program version 2.0 ( ANSI C ); +Biniax-2 ver. 1.30 + +- WHAT IS THIS : +This program is an ANSI C version of "Biniax-2" computer game. +For pure gameplay, check the Biniax Cassic game at www.biniax.com + +- LICENSE : + Biniax Copyright (C) 2005-2009 Jordan Tuzsuzov + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + + +- CONTACTS : +Email : jordan@biniax.com +Web : www.biniax.com +******************************************************************************/ + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include "game.h" +#include "lev.h" +#include "inc.h" + +/* Global instance of GAME structure */ +BNX_GAME Game; + +static BNX_INT16 cExtraBonus[ cMaxExtras ] = { 5, 10, 20, 40, 100, 0 }; + +/****************************************************************************** +ALL FUNCTIONS IN THE MODULE +******************************************************************************/ + +void initGame( BNX_GAME *game ); +void initGameKeepScore( BNX_GAME *game ); +void initPlayer( BNX_GAME *game ); +void initGrid( BNX_GAME *game, BNX_INT16 lines ); +BNX_UINT8 initPair( BNX_UINT8 maxel ); +void chooseLevel( BNX_GAME *game ); +void initLine( BNX_GAME *game, BNX_INT16 line ); +BNX_BOOL scrollDown( BNX_GAME *game ); +BNX_BOOL clearColumn( BNX_GAME *game ); +BNX_BOOL moveUp( BNX_GAME *game, BNX_INT16 pIndex ); +BNX_BOOL moveDown( BNX_GAME *game, BNX_INT16 pIndex ); +BNX_BOOL moveLeft( BNX_GAME *game, BNX_INT16 pIndex ); +BNX_BOOL moveRight( BNX_GAME *game, BNX_INT16 pIndex ); +BNX_BOOL takePair( BNX_GAME *game, BNX_INT16 x, BNX_INT16 y, BNX_INT16 pIndex ); + +BNX_INT16 gameSession( BNX_GAME *game ); +BNX_INT16 mainMenu( BNX_GAME *game ); +void showHelp( BNX_GAME *game ); +BNX_BOOL saveGame( BNX_GAME *game ); +BNX_BOOL loadGame( BNX_GAME *game ); +BNX_BOOL loadHiScore( BNX_GAME *game ); + +#define UNREF( A ) (A) = (A) +/****************************************************************************** +PROGRAM START +******************************************************************************/ + +int main( int argc, char *argv[] ) +{ + BNX_BOOL bquit = BNX_FALSE; + BNX_INT16 enterState = cStateMainMenu; + BNX_INT16 nmenu = 0; + BNX_INT16 mmenu = 0; + + UNREF( argc ); + UNREF( argv ); + + cfgInit(); + hofInit(); + if ( gfxInit() == BNX_FALSE ) + return -1; + if ( sysInit() == BNX_FALSE ) + return -2; + if ( inpInit() == BNX_FALSE ) + return -3; + if ( sndInit() == BNX_FALSE ) + return -4; + + /****************************************************************** + SHOW INITIAL WELCOME SCREEN + ******************************************************************/ + gfxRenderEntry(); + + /****************************************************************** + MAIN STATE MACHINE + ******************************************************************/ + while ( bquit == BNX_FALSE ) + { + /****************************************************************** + MAIN MENU STATE + ******************************************************************/ + if ( enterState == cStateMainMenu ) + { + sndPlayMusic( cSndMenu ); + nmenu = mainMenu( &Game ); + + switch ( nmenu ) + { + case cOptionContinue: + if ( loadGame( &Game ) == BNX_FALSE ) + { + enterState = cStateMainMenu; + } + else + { + loadHiScore( &Game ); + enterState = cStateGame; + } + break; + case cOptionNewRealtime: + initGame( &Game ); + Game.mode = cModeRealtime; + loadHiScore( &Game ); + enterState = cStateGame; + break; + case cOptionNewTurn: + initGame( &Game ); + Game.mode = cModeTurn; + loadHiScore( &Game ); + enterState = cStateGame; + break; + case cOptionNewMultiplayer: + initGame( &Game ); + Game.mode = cModeMultiplayer; + enterState = cStateGame; + break; + case cOptionHall: + enterState = cStateHallView; + break; + case cOptionHelp: + enterState = cStateHelp; + break; + case cOptionQuit: + bquit = BNX_TRUE; + continue; + default: + break; + } + } + /****************************************************************** + HALL OF FAME VIEW STATE + ******************************************************************/ + if ( enterState == cStateHallView ) + { + hofView(); + enterState = cStateMainMenu; + } + /****************************************************************** + HALL OF FAME ENTER STATE + ******************************************************************/ + if ( enterState == cStateHallEnter ) + { + hofEnter( &Game ); + hofSave(); + enterState = cStateHallView; + } + /****************************************************************** + HELP STATE + ******************************************************************/ + if ( enterState == cStateHelp ) + { + showHelp( &Game ); + enterState = cStateMainMenu; + } + /****************************************************************** + GAME STATE + ******************************************************************/ + if ( enterState == cStateGame ) + { + BNX_INT16 naction; + + sndPlayMusic( sysRand( cSndMaxMusic-1 ) ); + naction = gameSession( &Game ); + switch ( naction ) + { + case cDoNothing : + if ( Game.mode == cModeMultiplayer ) + { + enterState = cStateMainMenu; + } + else + { + enterState = cStateHallEnter; + } + break; + case cDoSave : + saveGame( &Game ); + enterState = cStateMainMenu; + break; + case cDoRestart : + initGameKeepScore( &Game ); + enterState = cStateGame; + break; + case cDoNetError : + enterState = cStateConnectionClosed; + break; + } + } + } + + return 0; +} + +/****************************************************************************** +GAME INIT +******************************************************************************/ + +void initGame( BNX_GAME *game ) +{ + game->wins[ cPlayer1 ] = 0; + game->wins[ cPlayer2 ] = 0; + + initGameKeepScore( game ); +} + +void initGameKeepScore( BNX_GAME *game ) +{ + + game->score[ cPlayer1 ] = 0; + game->score[ cPlayer2 ] = 0; + game->scroll = cMaxScroll; + game->speed = cMaxScroll; + game->message = cTextIngameScore; + game->level = cLevelInactive; + game->level_count = cLevelInactive; + game->lines = 0; + game->moment = 0; + game->clears = cClearInit; + game->ingame = BNX_TRUE; + + // Bad dependancy + game->ingame = BNX_FALSE; // NEEDED FOR initGrid() + initGrid( game, cInitLines ); + initPlayer( game ); // INIT PLAYER AFTER INIT GRID! + game->ingame = BNX_TRUE; // NEED TO BE AFTER initGrid() +} + +void initPlayer( BNX_GAME *game ) +{ + BNX_INT16 nearLine = cGridY - cInitLines; + BNX_INT16 i; + + nearLine = nearLine < 0 ? 0 : nearLine; + + game->player[ cPlayer1 ].x = 0; + game->player[ cPlayer1 ].y = 0; + for ( i = 0; i < cGridX; ++i ) + { + if ( game->grid[ i ][ nearLine ] != 0 ) + { + game->player[ cPlayer1 ].e = pairLeft( game->grid[ i ][ nearLine ] ); + game->grid[ game->player[ cPlayer1 ].x ][ game->player[ cPlayer1 ].y ] = cPlayerFlag; + break; + } + } + + game->player[ cPlayer2 ].x = cGridX - 1; + game->player[ cPlayer2 ].y = 0; + for ( i = cGridX-1; i >= 0; --i ) + { + if ( game->grid[ i ][ nearLine ] != 0 ) + { + game->player[ cPlayer2 ].e = pairRight( game->grid[ i ][ nearLine ] ); + game->grid[ game->player[ cPlayer2 ].x ][ game->player[ cPlayer2 ].y ] = cPlayerFlag; + break; + } + } +} + +void initGrid( BNX_GAME *game, BNX_INT16 lines ) +{ + BNX_INT16 x; + BNX_INT16 y; + + for ( y = 0; y < cGridY; ++y ) + { + for ( x = 0; x < cGridX; ++x ) + { + game->grid[ x ][ y ] = 0; + } + } + + for ( y = 0; y < lines; ++y ) + { + scrollDown( game ); + } +} + +BNX_UINT8 initPair( BNX_UINT8 maxel ) +{ + BNX_UINT8 left; + BNX_UINT8 right; + left = ( BNX_INT8 ) sysRand( maxel ); + do + { + right = ( BNX_UINT8 ) sysRand( maxel ); + } + while ( left == right ); + + return ((left << 4) | right); +} + +void chooseLevel( BNX_GAME *game ) +{ + switch ( game->mode ) + { + case cModeMultiplayer: + game->level = ( BNX_INT16 ) sysRand( cMaxLevelsMulti ); + break; + case cModeTurn: + game->level = ( BNX_INT16 ) sysRand( cMaxLevelsTurn ); + break; + default: + game->level = ( BNX_INT16 )sysRand( cMaxLevels ); + break; + } + + game->level_count = BNX_LEVEL_INFO[ game->level ]; +} + +void initLine( BNX_GAME *game, BNX_INT16 line ) +{ + BNX_INT16 x, i; + BNX_INT16 ofs = 0; + + for ( x = 0; x < cGridX; ++x ) + { + game->grid[ x ][ line ] = initPair( cMaxElements ); + } + game->grid[ sysRand( cGridX ) ][ line ] = 0; + + if ( game->level_count >= 0 ) + { + if ( game->level >= 0 && game->level < cMaxLevels && game->level_count < BNX_LEVEL_INFO[ game->level ] ) + { + ofs = 0; + for ( i = 0; i < game->level; ++i ) + { + ofs += BNX_LEVEL_INFO[ i ]; + } + + for ( x = 0; x < cGridX; ++x ) + { + if ( BNX_LEVEL[ ofs + game->level_count ][ x ] != 0 ) + { + game->grid[ x ][ line ] = cBrickFlag; + } + } + } + } +} + +BNX_BOOL scrollDown( BNX_GAME *game ) +{ + BNX_INT16 x; + BNX_INT16 y; + BNX_INT16 pl = 0; + BNX_INT16 endPlayer = 0; + BNX_BOOL ingame = BNX_TRUE; + + for ( y = 0; y < cGridY - 1; ++y ) + { + for ( x = 0; x < cGridX; ++x ) + { + game->grid[ x ][ y ] = game->grid[ x ][ y + 1 ]; + } + } + game->lines ++; + if ( ((game->lines % cClearIncrement) == 0) && (game->clears < cClearMax) ) + { + game->clears ++; + game->message = cTextExtraMessages + cExtraBrush; + } + if ( game->lines % cNextLevelAt == 0 ) + { + chooseLevel( game ); + } + initLine( game, cGridY - 1 ); + if ( game->level_count >= 0 ) + { + game->level_count --; + } + + if ( game->ingame == BNX_TRUE ) + { + endPlayer = game->mode == cModeMultiplayer ? cPlayer2 : cPlayer1; + + for ( pl = cPlayer1; pl <= endPlayer; ++pl ) + { + if ( game->player[ pl ].y > 0 ) + { + game->player[ pl ].y --; + } + else if ( takePair( game, game->player[ pl ].x, game->player[ pl ].y, pl )==BNX_FALSE ) + { + game->player[ pl ].y --; + ingame = BNX_FALSE; + } + } + } + + return ingame; +} + +/****************************************************************************** +ACTIONS +******************************************************************************/ + +BNX_BOOL canTake( BNX_GAME *game, BNX_INT16 x, BNX_INT16 y, BNX_INT16 pIndex ) +{ + BNX_UINT8 pair = game->grid[ x ][ y ]; + + if ( pair == 0 ) + return BNX_TRUE; + + if ( pairLeft( pair )==game->player[ pIndex ].e || pairRight( pair )==game->player[ pIndex ].e ) + return BNX_TRUE; + else + return BNX_FALSE; +} + +BNX_BOOL takePair( BNX_GAME *game, BNX_INT16 x, BNX_INT16 y, BNX_INT16 pIndex ) +{ + BNX_UINT8 pair = game->grid[ x ][ y ]; + BNX_BOOL cantake = BNX_FALSE; + + if ( pair == 0 ) + { + game->grid[ x ][ y ] = cPlayerFlag; + return BNX_TRUE; + } + + if ( pairLeft( pair ) == game->player[ pIndex ].e ) + { + game->player[ pIndex ].e = pairRight( pair ); + cantake = BNX_TRUE; + } + else if ( pairRight( pair ) == game->player[ pIndex ].e ) + { + game->player[ pIndex ].e = pairLeft( pair ); + cantake = BNX_TRUE; + } + else + { + cantake = BNX_FALSE; + } + + if ( cantake == BNX_TRUE ) + { + game->grid[ x ][ y ] = cPlayerFlag; + game->score[ pIndex ] += cScoreStep; + } + + return cantake; +} + +BNX_BOOL moveUp( BNX_GAME *game, BNX_INT16 pIndex ) +{ + BNX_PLAYER *p = &game->player[ pIndex ]; + BNX_INT8 newY = p->y + 1; + + if ( newY < cGridY ) + { + if ( takePair( game, p->x, newY, pIndex ) == BNX_TRUE ) + { + game->grid[ p->x ][ p->y ] = 0; + p->y = newY; + return BNX_TRUE; + } + } + + return BNX_FALSE; +} + +BNX_BOOL moveDown( BNX_GAME *game, BNX_INT16 pIndex ) +{ + BNX_PLAYER *p = &game->player[ pIndex ]; + BNX_INT8 newY = p->y - 1; + + if ( newY >= 0 ) + { + if ( takePair( game, p->x, newY, pIndex ) == BNX_TRUE ) + { + game->grid[ p->x ][ p->y ] = 0; + p->y = newY; + return BNX_TRUE; + } + } + + return BNX_FALSE; +} + +BNX_BOOL moveLeft( BNX_GAME *game, BNX_INT16 pIndex ) +{ + BNX_PLAYER *p = &game->player[ pIndex ]; + BNX_INT8 newX = p->x - 1; + + if ( newX >= 0 ) + { + if ( takePair( game, newX, p->y, pIndex ) == BNX_TRUE ) + { + game->grid[ p->x ][ p->y ] = 0; + p->x = newX; + return BNX_TRUE; + } + } + + return BNX_FALSE; +} + +BNX_BOOL moveRight( BNX_GAME *game, BNX_INT16 pIndex ) +{ + BNX_PLAYER *p = &game->player[ pIndex ]; + BNX_INT8 newX = p->x + 1; + + if ( newX < cGridX ) + { + if ( takePair( game, newX, p->y, pIndex ) == BNX_TRUE ) + { + game->grid[ p->x ][ p->y ] = 0; + p->x = newX; + return BNX_TRUE; + } + } + + return BNX_FALSE; +} + +void correctSpeed( BNX_GAME *game ) +{ + if ( game->mode == cModeMultiplayer ) + { + game->speed = cMultiScroll; + } + else if ( game->mode == cModeRealtime ) + { + BNX_INT32 scrollRange = cMaxScroll - cMinScroll; + BNX_INT32 speedIndex = (scrollRange << 8) / cMaxSpeedScore; + BNX_INT16 pIndex = game->score[ cPlayer1 ] > game->score[ cPlayer2 ] ? cPlayer1 : cPlayer2; + + if ( game->score[ pIndex ] < cMaxSpeedScore ) + { + game->speed = cMaxScroll - ( ( game->score[ pIndex ] * speedIndex ) >> 8 ); + } + else + { + game->speed = cMinScroll; + } + } +} + +BNX_BOOL checkBonus( BNX_GAME *game ) +{ + BNX_INT16 x, y; + + for ( y = 0; y < cGridY; ++y ) + { + for ( x = 0; x < cGridX; ++x ) + { + if ( game->grid[ x ][ y ] > 0 && game->grid[ x ][ y ] < cBeginFlag ) + { + return BNX_FALSE; + } + } + } + + return BNX_TRUE; +} + +BNX_BOOL clearColumn( BNX_GAME *game ) +{ + BNX_INT16 y; + + if ( game->clears > 0 ) + { + for ( y = 0; y < cGridY; ++y ) + { + if ( game->grid[ game->player[ cPlayer1 ].x ][ y ] != cPlayerFlag ) + { + game->grid[ game->player[ cPlayer1 ].x ][ y ] = 0; + } + } + } + return BNX_TRUE; +} + +/****************************************************************************** +GAME SESSION +******************************************************************************/ + +BNX_INT16 gameSession( BNX_GAME *game ) +{ + static BNX_INT16 countTakes = 0; + BNX_INT16 nTemp = 0; + BNX_BOOL bgameSes = BNX_TRUE; + BNX_INT16 naction = cDoSave; + BNX_INT32 startTime = 0; + BNX_INT32 prevScore = 0; + BNX_BOOL flagTake = BNX_FALSE; + BNX_BOOL flagMove = BNX_FALSE; + BNX_BOOL prevIngame = BNX_FALSE; + + inpInit(); + while ( bgameSes ) + { + startTime = sysGetTime(); + + flagTake = BNX_FALSE; + flagMove = BNX_TRUE; + game->sounds = cSndNone; + + inpUpdate(); + gfxGetVirtualKey( game, inpDirect() ); + if ( inpKeyA() ) + { + switch ( game->mode ) + { + case cModeRealtime : + case cModeTurn : + if ( game->ingame == BNX_FALSE ) + { + bgameSes = BNX_FALSE; + naction = cDoNothing; + } + break; + case cModeMultiplayer : + if ( game->ingame == BNX_FALSE ) + { + bgameSes = BNX_FALSE; + naction = cDoRestart; + } + break; + } + } + else if ( inpKeyB() ) + { + bgameSes = BNX_FALSE; + naction = cDoNothing; + + if ( game->mode != cModeMultiplayer ) + { + if ( game->ingame == BNX_TRUE ) + { + naction = cDoSave; + } + } + } + else if ( inpKeyC() ) + { + if ( game->mode != cModeMultiplayer ) + { + if ( game->clears > 0 ) + { + clearColumn( game ); + game->sounds |= soundMask( cSndSweep ); + game->clears --; + } + } + else + { + if ( game->ingame == BNX_FALSE ) + { + bgameSes = BNX_FALSE; + naction = cDoRestart; + } + } + } + + if ( game->ingame == BNX_TRUE ) + { + switch ( game->mode ) + { + /*************************************************************** + Classic realtime mode + ***************************************************************/ + case cModeRealtime: + { + // Player 1 + prevScore = game->score[ cPlayer1 ]; + if ( inpKeyLeft() ) + { + flagTake = moveLeft( game, cPlayer1 ); + } + else if ( inpKeyRight() ) + { + flagTake = moveRight( game, cPlayer1 ); + } + else if ( inpKeyUp() ) + { + flagTake = moveUp( game, cPlayer1 ); + } + else if ( inpKeyDown() ) + { + flagTake = moveDown( game, cPlayer1 ); + } + else + { + flagMove = BNX_FALSE; + } + + // Set bonus + if ( flagTake == BNX_TRUE && prevScore < game->score[ cPlayer1 ] ) + { + nTemp = -1; + countTakes ++; + switch ( countTakes ) + { + case cComboMinor: + nTemp = 0; + break; + case cComboNormal: + nTemp = 1; + break; + case cComboBig: + nTemp = 2; + break; + case cComboMega: + nTemp = 3; + break; + default: + nTemp = -1; + break; + } + if ( nTemp > 0 ) + { + game->score[ cPlayer1 ] += cExtraBonus[ nTemp ]; + game->message = cTextExtraMessages + nTemp; + } + } + else if ( flagMove == BNX_TRUE ) + { + countTakes = 0; + } + + if ( flagTake == BNX_TRUE ) + { + if ( checkBonus( game ) == BNX_TRUE && prevScore < game->score[ cPlayer1 ] ) + { + game->score[ cPlayer1 ] += cExtraBonus[ cExtraFieldMastered ]; + game->message = cTextExtraMessages + cExtraFieldMastered; + } + } + + if ( flagMove == BNX_TRUE && flagTake == BNX_TRUE ) + { + if ( prevScore < game->score[ cPlayer1 ] ) // TODO : correct sound + { + game->sounds |= soundMask( cSndTake ); + } + } + else if ( flagMove == BNX_TRUE && flagTake == BNX_FALSE ) + { + game->sounds |= soundMask( cSndFail ); + } + // Detect shake start. Don't *play* shake at high speed + if ( game->scroll == cShakeAfter && game->score[ cPlayer1 ] < cMaxSpeedScore ) // TODO : correct shake end + { + game->sounds |= soundMask( cSndShake ); + } + + // Move the field and determinate Game Over + if ( game->ingame == BNX_TRUE && ( -- ( game->scroll ) ) <= 0 ) + { + prevIngame = game->ingame; + game->ingame = scrollDown( game ); + + if ( prevIngame == BNX_TRUE && game->ingame == BNX_FALSE ) + { + if ( game->best[ game->mode ] < game->score[ cPlayer1 ] ) + { + game->best[ game->mode ] = game->score[ cPlayer1 ]; + game->message = cTextBestScore; + } + else + { + game->message = cTextGameOver; + } + } + + game->sounds |= soundMask( cSndScroll ); + game->scroll = game->speed; + correctSpeed( game ); + } + } + break; + + + /*************************************************************** + Turn-based mode + ***************************************************************/ + case cModeTurn: + { + // Player 1 + prevScore = game->score[ cPlayer1 ]; + if ( inpKeyLeft() ) + { + flagTake = moveLeft( game, cPlayer1 ); + } + else if ( inpKeyRight() ) + { + flagTake = moveRight( game, cPlayer1 ); + } + else if ( inpKeyUp() ) + { + flagTake = moveUp( game, cPlayer1 ); + } + else if ( inpKeyDown() ) + { + flagTake = moveDown( game, cPlayer1 ); + } + else + { + flagMove = BNX_FALSE; + } + // Set bonus + if ( flagTake == BNX_TRUE && prevScore < game->score[ cPlayer1 ] ) + { + nTemp = -1; + countTakes ++; + switch ( countTakes ) + { + case cComboMinor: + nTemp = 0; + break; + case cComboNormal: + nTemp = 1; + break; + case cComboBig: + nTemp = 2; + break; + case cComboMega: + nTemp = 3; + break; + default: + nTemp = -1; + break; + } + if ( nTemp > 0 ) + { + game->score[ cPlayer1 ] += cExtraBonus[ nTemp ]; + game->message = cTextExtraMessages + nTemp; + } + } + else if ( flagMove == BNX_TRUE ) + { + countTakes = 0; + } + + if ( flagTake == BNX_TRUE ) + { + if ( checkBonus( game ) == BNX_TRUE && prevScore < game->score[ cPlayer1 ] ) + { + game->score[ cPlayer1 ] += cExtraBonus[ cExtraFieldMastered ]; + game->message = cTextExtraMessages + cExtraFieldMastered; + } + } + + if ( flagMove == BNX_TRUE && flagTake == BNX_TRUE ) + { + if ( prevScore < game->score[ cPlayer1 ] ) + { + game->sounds |= soundMask( cSndTake ); + } + } + else if ( flagMove == BNX_TRUE && flagTake == BNX_FALSE ) + { + game->sounds |= soundMask( cSndFail ); + } + if ( flagMove == BNX_TRUE ) + { + -- ( game->moves ); + } + + // Move field and determinate Game Over + if ( game->ingame == BNX_TRUE && ( game->moves ) < 1 ) + { + game->moves = game->level_count < 0 ? cMaxMoves : cMaxMovesInLevel; + prevIngame = game->ingame; + game->ingame = scrollDown( game ); + + if ( prevIngame == BNX_TRUE && game->ingame == BNX_FALSE ) + { + if ( game->best[ game->mode ] < game->score[ cPlayer1 ] ) + { + game->best[ game->mode ] = game->score[ cPlayer1 ]; + game->message = cTextBestScore; + } + else + { + game->message = cTextGameOver; + } + } + + game->sounds |= soundMask( cSndScroll ); + game->scroll = game->speed; + correctSpeed( game ); + } + if ( --(game->scroll) <= 0 ) + { + game->scroll = game->speed; + } + } + break; + + + /*************************************************************** + Multiplayer modes + ***************************************************************/ + case cModeMultiplayer: + { + // Player 1 + prevScore = game->score[ cPlayer1 ]; + if ( inpKeyLeft() ) + { + flagTake = moveLeft( game, cPlayer1 ); + } + else if ( inpKeyRight() ) + { + flagTake = moveRight( game, cPlayer1 ); + } + else if ( inpKeyUp() ) + { + flagTake = moveUp( game, cPlayer1 ); + } + else if ( inpKeyDown() ) + { + flagTake = moveDown( game, cPlayer1 ); + } + else + { + flagMove = BNX_FALSE; + } + + if ( flagMove == BNX_TRUE && flagTake == BNX_TRUE ) + { + if ( prevScore < game->score[ cPlayer1 ] ) + { + game->sounds |= soundMask( cSndTake ); + } + } + else if ( flagMove == BNX_TRUE && flagTake == BNX_FALSE ) + { + game->sounds |= soundMask( cSndFail ); + } + + // Player 2 + flagMove = BNX_TRUE; + prevScore = game->score[ cPlayer2 ]; + if ( inpKeyAltLeft() ) + { + flagTake = moveLeft( game, cPlayer2 ); + } + else if ( inpKeyAltRight() ) + { + flagTake = moveRight( game, cPlayer2 ); + } + else if ( inpKeyAltUp() ) + { + flagTake = moveUp( game, cPlayer2 ); + } + else if ( inpKeyAltDown() ) + { + flagTake = moveDown( game, cPlayer2 ); + } + else + { + flagMove = BNX_FALSE; + } + // Play respective sound + if ( flagMove == BNX_TRUE && flagTake == BNX_TRUE ) + { + if ( prevScore < game->score[ cPlayer2 ] ) + { + game->sounds |= soundMask( cSndTake ); + } + } + else if ( flagMove == BNX_TRUE && flagTake == BNX_FALSE ) + { + game->sounds |= soundMask( cSndFail ); + } + + // Detect shake start. Don't *play* shake at high speed + if ( game->scroll == cShakeAfter && game->score[ cPlayer1 ] < cMaxSpeedScore ) + { + game->sounds |= soundMask( cSndShake ); + } + + // Move the field and determinate Game Over + if ( game->ingame == BNX_TRUE && ( -- ( game->scroll ) ) <= 0 ) + { + prevIngame = game->ingame; + game->ingame = scrollDown( game ); + + if ( prevIngame == BNX_TRUE && game->ingame == BNX_FALSE ) + { + int p1Out = ( game->player[ cPlayer1 ].y < 0 ); + int p2Out = ( game->player[ cPlayer2 ].y < 0 ); + if ( p1Out && p2Out ) + { + game->message = cTextMultiRoundN; + } + else if ( p1Out ) + { + game->message = cTextMultiRound2; + game->wins[ cPlayer2 ] ++; + } + else if ( p2Out ) + { + game->message = cTextMultiRound1; + game->wins[ cPlayer1 ] ++; + } + } + + game->sounds |= soundMask( cSndScroll ); + game->scroll = game->speed; + correctSpeed( game ); + } + } + break; + + default: + { + // Nothing + } + break; + } + } + + + // Render the game screen + gfxRenderGame( game ); + gfxUpdate(); + + // Play the sounds and music on this step + sndPlay( game ); + sndUpdateMusic( game, BNX_TRUE ); + sndUpdate(); + + // Synchronize with the clock + while ( sysGetTime() - startTime < cDeltaTime ) + { + sysUpdate(); + } + } + + return naction; +} + +/****************************************************************************** +MAIN MENU +******************************************************************************/ + +BNX_INT16 mainMenu( BNX_GAME *game ) +{ + BNX_INT16 option = 0; + BNX_INT16 gfxoption = -1; + BNX_INT32 startTime; + BNX_BOOL penchoice = BNX_FALSE; + + inpInit(); + do + { + startTime = sysGetTime(); + inpUpdate(); + gfxoption = gfxGetMenuOption( inpDirect() ); + if ( gfxoption >= 0 ) + { + if ( option == gfxoption ) + { + penchoice = BNX_TRUE; + } + else + { + option = gfxoption; + } + } + + if ( inpKeyLeft() || inpKeyUp() ) + { + option = ( option + cMaxOptions - 1 ) % cMaxOptions; + game->sounds |= soundMask( cSndFail ); + } + else if ( inpKeyRight() || inpKeyDown() ) + { + option = ( option + 1 ) % cMaxOptions; + game->sounds |= soundMask( cSndFail ); + } + + gfxRenderMenu( option ); + gfxUpdate(); + sndPlay( game ); + sndUpdate(); + sysUpdate(); + + while ( sysGetTime() - startTime < cDeltaTime ) + { + sysUpdate(); + } + } + while ( (inpKeyA() == BNX_FALSE) && (penchoice == BNX_FALSE) ); + + return option; +} + +void showHelp( BNX_GAME *game ) +{ + BNX_INT16 line = 0; + BNX_INT16 virtKey = 0; + + inpInit(); + do + { + inpUpdate(); + gfxGetHelpPen( inpDirect() ); + if ( inpKeyLeft() || inpKeyUp() ) + { + line --; + game->sounds |= soundMask( cSndFail ); + } + else if ( inpKeyRight() || inpKeyDown() ) + { + line ++; + game->sounds |= soundMask( cSndFail ); + } + else if ( inpKeyPageUp() ) + { + line -= cGfxHelpPage; + game->sounds |= soundMask( cSndFail ); + } + else if ( inpKeyPageDown() ) + { + line += cGfxHelpPage; + game->sounds |= soundMask( cSndFail ); + } + + gfxRenderHelp( &line ); + gfxUpdate(); + sndPlay( game ); + sndUpdate(); + sysUpdate(); + } + while ( inpKeyA() == BNX_FALSE && inpKeyB() == BNX_FALSE ); +} + +/****************************************************************************** +GAME AND HISCORE SAVE / RESTORE +******************************************************************************/ + +BNX_BOOL saveGame( BNX_GAME *game ) +{ + FILE *file; + BNX_INT32 i; + BNX_INT32 j; + + file = fopen( sysGetFullFileName( csSaveGameName ), "wb" ); + + if ( file == (FILE *) NULL ) + return BNX_FALSE; + + sysFPut32( game->moment, file ); + for ( i = 0; i < cMaxPlayers; ++i ) + { + sysFPut8( game->player[ i ].x, file ); + sysFPut8( game->player[ i ].y, file ); + sysFPut8( game->player[ i ].e, file ); + } + for ( j = 0; j < cGridX; ++j ) + { + for ( i = 0; i < cGridY; ++i ) + { + sysFPut8( game->grid[ j ][ i ], file ); + } + } + sysFPut1byte( file ); + sysFPut16( game->mode, file ); + for ( i = 0; i < cMaxPlayers; ++i ) + { + sysFPut32( game->score[ i ], file ); + } + for ( i = 0; i < cMaxPlayers; ++i ) + { + sysFPut32( game->wins[ i ], file ); + } + for ( i = 0; i < cMaxModes; ++i ) + { + sysFPut32( game->best[ i ], file ); + } + sysFPut16( game->scroll, file ); + sysFPut16( game->speed, file ); + sysFPut16( game->moves, file ); + sysFPut16( game->clears, file ); + sysFPut8( game->ingame, file ); + sysFPut3byte( file ); + sysFPut32( game->sounds, file ); + sysFPut8( game->message, file ); + sysFPut3byte( file ); + sysFPut3byte( file ); + sysFPut1byte( file ); + sysFPut16( game->level, file ); + sysFPut16( game->level_count, file ); + + fclose( file ); + + return BNX_TRUE; +} + +BNX_BOOL loadGame( BNX_GAME *game ) +{ + FILE *file; + BNX_INT32 i; + BNX_INT32 j; + + if ( sysGetFileLen( sysGetFullFileName( csSaveGameName ) ) != cSaveFileSize ) + return BNX_FALSE; + file = fopen( sysGetFullFileName( csSaveGameName ), "rb" ); + if ( file == (FILE *) NULL ) + return BNX_FALSE; + + game->moment = sysFGet32( file ); + for ( i = 0; i < cMaxPlayers; ++i ) + { + game->player[ i ].x = sysFGet8( file ); + game->player[ i ].y = sysFGet8( file ); + game->player[ i ].e = sysFGet8( file ); + } + for ( j = 0; j < cGridX; ++j ) + { + for ( i = 0; i < cGridY; ++i ) + { + game->grid[ j ][ i ] = sysFGet8( file ); + } + } + sysFGet1byte( file ); + game->mode = sysFGet16( file ); + for ( i = 0; i < cMaxPlayers; ++i ) + { + game->score[ i ] = sysFGet32( file ); + } + for ( i = 0; i < cMaxPlayers; ++i ) + { + game->wins[ i ] = sysFGet32( file ); + } + for ( i = 0; i < cMaxModes; ++i ) + { + game->best[ i ] = sysFGet32( file ); + } + game->scroll = sysFGet16( file ); + game->speed = sysFGet16( file ); + game->moves = sysFGet16( file ); + game->clears = sysFGet16( file ); + game->ingame = sysFGet8( file ); + sysFGet3byte( file ); + game->sounds = sysFGet32( file ); + game->message = sysFGet8( file ); + sysFGet3byte( file ); + sysFGet3byte( file ); + sysFGet1byte( file ); + game->level = sysFGet16( file ); + game->level_count = sysFGet16( file ); + + fclose( file ); + + return BNX_TRUE; +} + +BNX_BOOL loadHiScore( BNX_GAME *game ) +{ + game->best[ cModeRealtime ] = hofGet()->arcade[ 0 ].score; + game->best[ cModeTurn ] = hofGet()->tactic[ 0 ].score; + return BNX_TRUE; +} + diff --git a/project/jni/application/biniax2/src/cfg.c b/project/jni/application/biniax2/src/cfg.c new file mode 100644 index 000000000..3c104a8cd --- /dev/null +++ b/project/jni/application/biniax2/src/cfg.c @@ -0,0 +1,127 @@ +/****************************************************************************** +BINIAX SETUP IMPLEMENTATIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2007 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include "inc.h" + + +/****************************************************************************** +FUNCTIONS +******************************************************************************/ + +#define _Cfg_Buffer 255 +#define csConfigName "config.bnx2" + +struct BNX_SETUP +{ + BNX_BOOL sound; + BNX_BOOL music; + BNX_BOOL fullscreen; + BNX_BOOL touch; +} _Cfg; + +BNX_BOOL cfgCheckRegistered( char * RegCode ); + +BNX_BOOL cfgInit() +{ + FILE *f; + char buffer[ _Cfg_Buffer ]; + int nTemp; + + _Cfg.sound = BNX_TRUE; + _Cfg.music = BNX_TRUE; + _Cfg.fullscreen = BNX_FALSE; + _Cfg.touch = BNX_FALSE; + + f = fopen( sysGetFullFileName( csConfigName ), "rt" ); + if ( f == 0 ) + { + return BNX_FALSE; + } + + fgets( buffer, _Cfg_Buffer, f ); + sscanf( buffer, "SOUND=%d", &nTemp ); + _Cfg.sound = (BNX_BOOL) nTemp; + + fgets( buffer, _Cfg_Buffer, f ); + sscanf( buffer, "MUSIC=%d", &nTemp ); + _Cfg.music = (BNX_BOOL) nTemp; + + fgets( buffer, _Cfg_Buffer, f ); + sscanf( buffer, "FULLSCREEN=%d", &nTemp ); + _Cfg.fullscreen = (BNX_BOOL) nTemp; + + fgets( buffer, _Cfg_Buffer, f ); + sscanf( buffer, "TOUCH=%d", &nTemp ); + _Cfg.touch = (BNX_BOOL) nTemp; + + fclose( f ); + + return BNX_TRUE; +} + +BNX_BOOL cfgGetSound() +{ + return _Cfg.sound; +} + +BNX_BOOL cfgGetMusic() +{ + return _Cfg.music; +} + +BNX_BOOL cfgGetFullscreen() +{ + return _Cfg.fullscreen; +} + +BNX_BOOL cfgGetTouch() +{ + return _Cfg.touch; +} + +void cfgSetSound( BNX_BOOL v ) +{ + _Cfg.sound = v; +} + +void cfgSetMusic( BNX_BOOL v ) +{ + _Cfg.music = v; +} + +void cfgSetFullscreen( BNX_BOOL v ) +{ + _Cfg.fullscreen = v; +} + +void cfgSetTouch( BNX_BOOL v ) +{ + _Cfg.touch = v; +} diff --git a/project/jni/application/biniax2/src/cfg.h b/project/jni/application/biniax2/src/cfg.h new file mode 100644 index 000000000..671b14679 --- /dev/null +++ b/project/jni/application/biniax2/src/cfg.h @@ -0,0 +1,52 @@ +/****************************************************************************** +BINIAX CONFIG DEFINITIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2009 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +#ifndef _BNX_CFG_H +#define _BNX_CFG_H + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include "inc.h" + +/****************************************************************************** +FUNCTIONS +******************************************************************************/ + +BNX_BOOL cfgInit(); + +BNX_BOOL cfgGetSound(); +BNX_BOOL cfgGetMusic(); +BNX_BOOL cfgGetFullscreen(); +BNX_BOOL cfgGetTouch(); + +void cfgSetSound( BNX_BOOL v ); +void cfgSetMusic( BNX_BOOL v ); +void cfgSetFullscreen( BNX_BOOL v ); +void cfgSetTouch( BNX_BOOL v ); + +#endif diff --git a/project/jni/application/biniax2/src/game.h b/project/jni/application/biniax2/src/game.h new file mode 100644 index 000000000..6d5ded7f3 --- /dev/null +++ b/project/jni/application/biniax2/src/game.h @@ -0,0 +1,237 @@ +/****************************************************************************** +BINIAX GAME-RELATED DEFINITIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2009 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +#ifndef _BNX_GAME_H +#define _BNX_GAME_H + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include "types.h" + +/****************************************************************************** +DEFINITIONS +******************************************************************************/ + +#define csSaveGameName "autosave.bnx2" + +/****************************************************************************** +CONSTANTS +******************************************************************************/ + +#define cGridX 5 /* X size of the grid */ +#define cGridY 7 /* Y size of the grid */ +#define cMaxElements 4 /* Maximum num. of elements */ +#define cBeginFlag 254 /* Minimum flag index */ +#define cBrickFlag 254 /* Brick in game map */ +#define cPlayerFlag 255 /* Flag of the player in map*/ +#define cElementLimit 200 /* Less than this is a pair */ +#define cInitLines 3 /* Lines to add on start... */ +#define cDeltaTime 60 /* Time for game step in ms */ +#define cMaxScroll 70 /* Slowest scroll in steps. */ +#define cMinScroll 18 /* Fastest scroll in steps. */ +#define cMultiScroll 22 /* Constant speed in multi. */ +#define cScoreStep 10 /* How to increas the score */ +#define cClearInit 1 /* Initial clear counter */ +#define cClearMax 15 /* Maximum clears */ +#define cComboMinor 2 /* How long chain for c.min.*/ +#define cComboNormal 3 /* How long chain for c.nor.*/ +#define cComboBig 4 /* How long chain for c.big */ +#define cComboMega 5 /* How long chain for c.meg.*/ +#define cClearIncrement 100 /* Increment clear at every 100 lines */ +#define cMaxMoves 2 /* Max moves to scroll in turn mode. */ +#define cMaxMovesInLevel 4 /* Max moves to scroll in turn - in level. */ +#define cShakeAfter 8 /* Shake after X remainig ticks to scroll */ +#define cElCorrect 15 /* Elements to take to speed-up the game */ +#define cMaxSpeedScore 5000 /* Score, at each the max speed is reached */ +#define cFileVersion 130 /* File version for compatibility.130=1.30 */ +#define cSaveFileSize 116 /* Size of save game file in bytes */ + +enum BNX_Players +{ + cPlayer1 = 0, + cPlayer2, + cMaxPlayers +}; + +enum BNX_Modes +{ + cModeRealtime = 1, + cModeTurn, + cModeMultiplayer, + cModeNetworkServer, + cModeNetworkClient, + cMaxModes +}; + +enum BNX_Messages +{ + cTextIngameScore = 0, + cTextMultiScore, + cTextMultiRound1, + cTextMultiRound2, + cTextMultiRoundN, + cTextGameOver, + cTextBestScore, + cTextExtraMessages, +}; + +enum BNX_NetMessages +{ + cNetMessageStart = 0, + cNetMessageEnterIP, + cNetMessageConnecting, + cNetMessageError, + cMaxNetMessages +}; + +enum BNX_Extras +{ + cExtraMinorCombo = 0, + cExtraCombo, + cExtraBigCombo, + cExtraMegaCombo, + cExtraFieldMastered, + cExtraBrush, + cMaxExtras +}; + +enum BNX_Roadmap +{ + cRoadBeginnerScore = 2000, + cRoadRookieScore = 4000, + cRoadNoviceScore = 8000, + cRoadAdvancedScore = 16000, + cRoadExpertScore = 32000, + cRoadMasterScore = 64000, + cRoadKingScore = 128000, +}; + +enum BNX_Options +{ + cOptionContinue = 0, + cOptionNewRealtime, + cOptionNewTurn, + cOptionNewMultiplayer, + cOptionHall, + cOptionHelp, + cOptionQuit, + cMaxOptions +}; + +enum BNX_MultiOptions +{ + cOptionMultiSame = 0, + cOptionMultiServer, + cOptionMultiClient, + cOptionMultiBack, + cMaxMultiOptions +}; + +enum BNX_LoopResult +{ + cDoNothing = 0, + cDoSave, + cDoRestart, + cDoNetError +}; + +enum BNX_States +{ + cStateMainMenu = 0, + cStateMultiMenu, + cStateHelp, + cStateHallView, + cStateHallEnter, + cStateGame, + cStateConnectionClosed +}; + +/****************************************************************************** +GAME DATA +******************************************************************************/ + +/* Player definition */ +typedef struct BNX_PLAYER +{ + BNX_INT8 x; /* X position in grid */ + BNX_INT8 y; /* Y position in grid */ + BNX_INT8 e; /* Element index */ +} BNX_PLAYER; + +/* Game definition */ +typedef struct BNX_GAME +{ + BNX_UINT32 moment; /* Game moment */ + + BNX_PLAYER player[ cMaxPlayers ]; /* The players */ + + BNX_UINT8 grid[ cGridX ][ cGridY ]; /* Game field / grid */ + + BNX_UINT16 mode; /* Game mode - one of _BNX_Modes */ + + BNX_INT32 score[ cMaxPlayers ]; /* Score */ + BNX_INT32 wins[ cMaxPlayers ]; /* Multiplayer Score */ + BNX_INT32 best[ cMaxModes ]; /* Best score */ + + BNX_INT16 scroll; /* Current scroll step - realtime*/ + BNX_INT16 speed; /* Current game speed - realtime */ + + BNX_INT16 moves; /* Moves counter - turn mode only*/ + BNX_INT16 clears; /* Clear column counter */ + + BNX_BOOL ingame; /* Game is running */ + + BNX_UINT32 sounds; /* Flag with sounds to play */ + + BNX_UINT8 message; /* Type of message to show */ + + BNX_UINT32 lines; /* Lines counter */ + BNX_INT16 level; /* Last level */ + BNX_INT16 level_count; /* Count current level line */ + +} BNX_GAME; +/****************************************************************************** +For the grid definition assume, that indexes in grid are as follows : +........[ cGridX-1][ cGridY-1 ] +............................... +............................... +[ 0 ][ 0 ]..................... +The scroll down removes the first row (with index 0). + +Pairs are coded in the BYTE as xxxxyyyy. You can get left element of the +pair with (PAIR >> 4) and the right one with (PAIR & 0xf) +"Legal" pairs consists of two DIFFERENT elements ! +Pair 0-0 (or just 0) is an empty space. +******************************************************************************/ + +#define pairLeft( pair ) ( (pair) >> 4 ) +#define pairRight( pair ) ( (pair) & 0xf ) + +#define soundMask( index ) ( 1 << ( index ) ) + +#endif diff --git a/project/jni/application/biniax2/src/gfx.c b/project/jni/application/biniax2/src/gfx.c new file mode 100644 index 000000000..416087533 --- /dev/null +++ b/project/jni/application/biniax2/src/gfx.c @@ -0,0 +1,1089 @@ +/****************************************************************************** +BINIAX GRAPHICS-RELATED IMPLEMENTATIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2009 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include +#include + +#include "inc.h" +#include "txt.h" + +/****************************************************************************** +LOCALS +******************************************************************************/ +BNX_GFX _Gfx; + +/****************************************************************************** +FUNCTIONS +******************************************************************************/ + +BNX_BOOL gfxLoadImage( char *filename, SDL_Surface **img ); +BNX_BOOL gfxLoadResources(); + +void gfxUpdateJumpyText( void ); +void gfxRenderJumpyText( void ); + +void gfxInitParticles(); +void gfxNewParticle( BNX_INT16 x, BNX_INT16 y ); +void gfxUpdateParticles(); +void gfxRenderParticles(); + +void gfxRoadmap( BNX_INT32 prev, BNX_INT32 score ); + + +BNX_BOOL gfxInit() +{ + Uint32 flags = 0; + + SDL_putenv( "SDL_VIDEO_CENTERED=1" ); + + if ( SDL_Init( SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO ) < 0 ) + { + return BNX_FALSE; + } + + _Gfx.screen = 0; + if ( cfgGetFullscreen() == BNX_TRUE ) + { + flags = SDL_FULLSCREEN|SDL_SWSURFACE|SDL_ANYFORMAT; + } + else + { + flags = SDL_SWSURFACE|SDL_ANYFORMAT; + } + _Gfx.screen = SDL_SetVideoMode( cGfxScreenX, cGfxScreenY, cGfxColorDepth, flags ); + if ( _Gfx.screen == 0 ) + { + return BNX_FALSE; + } + + SDL_ShowCursor( SDL_DISABLE ); + SDL_WM_SetCaption("BINIAX-2", ""); + + if ( gfxLoadResources() != BNX_TRUE ) + { + return BNX_FALSE; + } + + gfxInitParticles(); + + return BNX_TRUE; +} + +void gfxRenderGame( BNX_GAME *game ) +{ + BNX_INT16 i; + BNX_INT16 j; + BNX_INT16 tmpx; + BNX_INT16 tmpy; + BNX_INT16 ofsx; + BNX_INT16 xpos; + BNX_INT16 ypos; + char text[ 128 ]; + SDL_Rect pos; + static BNX_BOOL prevIngame = BNX_TRUE; + static BNX_INT8 cursor = 0; + static BNX_INT32 prevScore[ cMaxPlayers ] = { 0, 0 }; + static BNX_INT32 fallOff = 0; + static BNX_INT16 prevClears = 0; + + if ( prevIngame == BNX_TRUE ) + { + /* Render In-game screen */ + SDL_BlitSurface( _Gfx.background[ game->mode ], NULL, _Gfx.screen, NULL ); + + pos.y = cGfxZeroY; + if ( game->mode != cModeTurn ) + { + if ( game->scroll <= 1 ) + { + fallOff = cGfxFall; + } + if ( fallOff != 0 ) + { + pos.y = pos.y + fallOff; + fallOff = - fallOff + ( fallOff / abs( fallOff ) ); + } + } + + ofsx = (cGfxShake >> 1) - (BNX_INT16) sysRand( cGfxShake ); + + for ( j = 0; j < cGridY; ++j ) + { + tmpy = pos.y; + + pos.x = cGfxZeroX; + if ( game->mode != cModeTurn && game->scroll <= cShakeAfter ) + { + pos.x = cGfxZeroX + ofsx; + } + if ( game->scroll % cGfxCursorSpeed == 0 ) + { + cursor = ( cursor + 1 ) % cGfxCursors; + } + + for ( i = 0; i < cGridX; ++i ) + { + if ( game->grid[ i ][ j ] != 0 && game->grid[ i ][ j ] < cElementLimit ) + { + tmpx = pos.x; + + SDL_BlitSurface(_Gfx.elements[pairLeft(game->grid[ i ][ j ])], + NULL, _Gfx.screen, &pos); + pos.x += cGfxNextPlusX; + SDL_BlitSurface(_Gfx.elements[pairRight(game->grid[ i ][ j ])], + NULL, _Gfx.screen, &pos); + pos.x = tmpx; + } + else + { + switch ( game->grid[ i ][ j ] ) + { + case cBrickFlag : + tmpx = pos.x; + tmpy = pos.y; + + pos.x -= (_Gfx.elements[ cGfxBrickElement ]->w - _Gfx.elements[ 0 ]->w - cGfxNextPlusX) >> 1; + pos.y -= (_Gfx.elements[ cGfxBrickElement ]->h - _Gfx.elements[ 0 ]->h) >> 1; + + SDL_BlitSurface(_Gfx.elements[ cGfxBrickElement ], + NULL, _Gfx.screen, &pos); + pos.x = tmpx; + pos.y = tmpy; + break; + default : + break; + } + } + + pos.x += cGfxPairPlusX; + } + + pos.y = tmpy; + pos.y += cGfxPairPlusY; + } + + /* RENDER MAIN (WHITE) PLAYER's CURSOR */ + pos.x = cGfxZeroX + game->player[ cPlayer1 ].x * cGfxPairPlusX; + pos.y = cGfxZeroY + game->player[ cPlayer1 ].y * cGfxPairPlusY; + if ( pos.y <= cGfxZeroY ) + { + SDL_BlitSurface( _Gfx.cursors[cursor], NULL, _Gfx.screen, &pos ); + } + + /* RENDER MAIN (WHITE) PLAYER */ + pos.x = cGfxZeroX + game->player[ cPlayer1 ].x * cGfxPairPlusX + cGfxPlayerPlusX; + pos.y = cGfxZeroY + game->player[ cPlayer1 ].y * cGfxPairPlusY; + if ( pos.y <= cGfxZeroY ) + { + SDL_BlitSurface( _Gfx.elements[game->player[ cPlayer1 ].e], NULL, _Gfx.screen, &pos ); + if ( game->score[ cPlayer1 ] != prevScore[ cPlayer1 ] ) + { + gfxNewParticle( pos.x + (cGfxNextPlusX >> 1), pos.y ); + gfxRoadmap( prevScore[ cPlayer1 ], game->score[ cPlayer1 ] ); + } + } + + if ( game->clears < prevClears ) + { + xpos = cGfxZeroX + game->player[ cPlayer1 ].x * cGfxPairPlusX + cGfxPlayerPlusX; + ypos = cGfxZeroY; + + for ( i = 0; i < cGridY; ++i ) + { + gfxNewParticle( xpos, ypos ); + ypos += cGfxPairPlusY; + } + } + + if ( game->mode == cModeMultiplayer || game->mode == cModeNetworkServer || game->mode == cModeNetworkClient ) + { + /* RENDER GREEN PLAYER's CURSOR */ + pos.x = cGfxZeroX + game->player[ cPlayer2 ].x * cGfxPairPlusX; + pos.y = cGfxZeroY + game->player[ cPlayer2 ].y * cGfxPairPlusY; + if ( pos.y <= cGfxZeroY ) + { + SDL_BlitSurface( _Gfx.cursors[cursor], NULL, _Gfx.screen, &pos ); + } + + /* RENDER GREEN PLAYER */ + pos.x = cGfxZeroX + game->player[ cPlayer2 ].x * cGfxPairPlusX + cGfxPlayerPlusX; + pos.y = cGfxZeroY + game->player[ cPlayer2 ].y * cGfxPairPlusY; + if ( pos.y <= cGfxZeroY ) + { + SDL_BlitSurface( _Gfx.elements[game->player[ cPlayer2 ].e], NULL, _Gfx.screen, &pos ); + if ( game->score[ cPlayer2 ] != prevScore[ cPlayer2 ] ) + { + gfxNewParticle( pos.x + (cGfxNextPlusX >> 1), pos.y ); + } + } + + /* RENDER BOTH MARKERS */ + for ( i = cPlayer1; i < cMaxPlayers; ++i ) + { + pos.x = cGfxZeroX + game->player[ i ].x * cGfxPairPlusX + cGfxMarkerPlusX; + pos.y = cGfxZeroY + game->player[ i ].y * cGfxPairPlusY + cGfxMarkerPlusY; + if ( pos.y <= cGfxZeroY ) + { + SDL_BlitSurface( _Gfx.markers[ i ], NULL, _Gfx.screen, &pos ); + } + } + + /* RENDER REMAINING TIME TO THE SCROLL */ + sprintf( text, "%06d", game->scroll ); + gfxPrintText( cGfxLegendX, cGfxLegendY, " TIME " ); + gfxPrintText( cGfxLegendX, cGfxLegendY + (cGfxFontSizeY<<1), text ); + + /* RENDER MULTIPLAYER SCORE */ + sprintf( text, "PLAYER-1 WINS: %d", game->wins[ cPlayer1 ] ); + gfxPrintText( cGfxScore1X, cGfxScore1Y, text ); + sprintf( text, "PLAYER-2 WINS: %d", game->wins[ cPlayer2 ] ); + gfxPrintText( cGfxScore2X, cGfxScore2Y, text ); + } + else if ( game->mode == cModeTurn ) + { + /* RENDER REMAINING MOVES TO THE SCROLL */ + pos.x = cGfxMoveCX; + pos.y = cGfxMoveCY; + for ( i = 0; i < game->moves; ++i ) + { + SDL_BlitSurface( _Gfx.movecount, NULL, _Gfx.screen, &pos ); + pos.y += _Gfx.movecount->h; + } + gfxPrintText( cGfxLegendX, cGfxLegendY, "MOVES:" ); + + /* RENDER SCORE FOR TACTIC GAME*/ + sprintf( text, "SCORE : %d", game->score[ cPlayer1 ] ); + gfxPrintText( cGfxScoreX, cGfxScoreY, text ); + sprintf( text, "BEST : %d", game->best[ cModeTurn ] ); + gfxPrintText( cGfxBestX, cGfxBestY, text ); + + /* RENDER CLEARS LEFT */ + sprintf( text, " %02d", game->clears ); + gfxPrintText( cGfxClearsTX, cGfxClearsTY, text ); + } + else if ( game->mode == cModeRealtime ) + { + /* RENDER REMAINING TIME TO THE SCROLL */ + sprintf( text, "%06d", game->scroll ); + gfxPrintText( cGfxLegendX, cGfxLegendY, " TIME " ); + gfxPrintText( cGfxLegendX, cGfxLegendY + (cGfxFontSizeY<<1), text ); + + /* RENDER SCORE FOR ARCADE GAME */ + sprintf( text, "SCORE : %d", game->score[ cPlayer1 ] ); + gfxPrintText( cGfxScoreX, cGfxScoreY, text ); + sprintf( text, "BEST : %d", game->best[ cModeRealtime ] ); + gfxPrintText( cGfxBestX, cGfxBestY, text ); + + /* RENDER CLEARS LEFT */ + sprintf( text, " %02d", game->clears ); + gfxPrintText( cGfxClearsAX, cGfxClearsAY, text ); + } + + /* PARTICLES */ + gfxRenderParticles(); + gfxUpdateParticles(); + + /* JUMPY TEXT */ + gfxUpdateJumpyText(); + gfxRenderJumpyText(); + + for ( i = 0; i < cMaxPlayers; ++i ) + { + prevScore[ i ] = game->score[ i ]; + } + + if ( game->message > cTextExtraMessages ) + { + _Gfx.jtext.downtime = cGfxJTextLive; + _Gfx.jtext.index = game->message - cTextExtraMessages; + _Gfx.jtext.x = cGfxZeroX + game->player[ cPlayer1 ].x * cGfxPairPlusX; + _Gfx.jtext.y = cGfxZeroY + game->player[ cPlayer1 ].y * cGfxPairPlusY; + game->message = 0; + } + else + { + switch ( game->message ) + { + /* SHOW MESSAGE BOX WITH THE TEXT */ + case cTextIngameScore : + break; + case cTextGameOver : + sprintf( text, "GAME OVER, SCORE : %d", game->score[ cPlayer1 ] ); + gfxMessageBox( cGfxMessageX, cGfxMessageY, text ); + break; + case cTextBestScore : + sprintf( text, "CONGRATULATIONS, BEST RESULT : %d", game->best[ game->mode ] ); + gfxMessageBox( cGfxMessageX, cGfxMessageY, text ); + break; + case cTextMultiRound1 : + gfxMessageBox( cGfxMessageX, cGfxMessageY, "PLAYER-1 WINS THE GAME" ); + break; + case cTextMultiRound2 : + gfxMessageBox( cGfxMessageX, cGfxMessageY, "PLAYER-2 WINS THE GAME" ); + break; + case cTextMultiRoundN : + gfxMessageBox( cGfxMessageX, cGfxMessageY, "BOTH PLAYERS LOST THE GAME" ); + break; + default : + break; + } + } + } + + + prevIngame = game->ingame; + prevClears = game->clears; +} + +void gfxRenderEntry( void ) +{ + BNX_INT16 alpha; + BNX_INT32 startTime; + + for ( alpha = 0; alpha < cGfxMaxAlpha; alpha+= cGfxAlphaStep ) + { + startTime = sysGetTime(); + + SDL_FillRect( _Gfx.screen, NULL, 0 ); + SDL_SetAlpha( _Gfx.logo, SDL_SRCALPHA /*| SDL_RLEACCEL*/, (Uint8) alpha ); + SDL_BlitSurface( _Gfx.logo, NULL, _Gfx.screen, NULL ); + + gfxUpdate(); + while ( sysGetTime() - startTime < cDeltaTime ) + { + sysUpdate(); + } + } + + SDL_BlitSurface( _Gfx.logo, NULL, _Gfx.screen, NULL ); + gfxUpdate(); + startTime = sysGetTime(); + while ( sysGetTime() - startTime < cGfxWelcomeWait ) + { + sysUpdate(); + } + + for ( alpha = cGfxMaxAlpha; alpha > 0; alpha-= cGfxAlphaStep ) + { + startTime = sysGetTime(); + + SDL_FillRect( _Gfx.screen, NULL, 0 ); + SDL_SetAlpha( _Gfx.logo, SDL_SRCALPHA /*| SDL_RLEACCEL*/, (Uint8) alpha ); + SDL_BlitSurface( _Gfx.logo, NULL, _Gfx.screen, NULL ); + + gfxUpdate(); + while ( sysGetTime() - startTime < cDeltaTime ) + { + sysUpdate(); + } + } + + startTime = sysGetTime(); + SDL_FillRect( _Gfx.screen, NULL, 0 ); + gfxUpdate(); + while ( sysGetTime() - startTime < (cGfxWelcomeWait>>1) ) + { + sysUpdate(); + } + + inpUpdate(); + inpInit(); +} + +void gfxRenderMenu( const BNX_INT16 option ) +{ + static BNX_INT16 partCount = 0; + static BNX_INT16 wave = 0; + BNX_INT16 i, x, y; + + char *ptrTxt; + char activeMenuTxt[ 0xff ]; + char menuTitle[] = "< MAIN MENU >"; + + x = cGfxOptionX; + y = cGfxOptionY; + + SDL_BlitSurface( _Gfx.splash, NULL, _Gfx.screen, NULL ); + + x = cGfxOptionX - ( ( (BNX_INT16) strlen( menuTitle ) * cGfxFontSizeX ) >> 1 ); + gfxPrintText( x, y, menuTitle ); + y += cGfxOptionDY + (cGfxOptionDY >> 2); + + for ( i = 0; i < cMaxOptions; ++i ) + { + if ( option == i ) + { + sprintf( activeMenuTxt, "= %s =", TXT_MenuMain[ i ] ); + ptrTxt = activeMenuTxt; + if ( partCount != option ) + { + gfxNewParticle( cGfxScreenX >> 1, y ); + partCount = option; + } + } + else + { + ptrTxt = TXT_MenuMain[ i ]; + } + + x = cGfxOptionX - ( ( (BNX_INT16) strlen( ptrTxt ) * cGfxFontSizeX ) >> 1 ); + + if ( option == i ) + { + gfxPrintTextWave( x, y, ptrTxt, wave++ ); + wave %= cGfxMaxWave; + } + else + { + gfxPrintText( x, y, ptrTxt ); + } + + y += cGfxOptionDY; + } + + gfxUpdateParticles(); + gfxRenderParticles(); +} + +void gfxRenderHelp( BNX_INT16 *line ) +{ + BNX_INT16 i, l, x, y; + + char *ptrTxt; + + x = cGfxHelpX; + y = cGfxHelpY; + + SDL_BlitSurface( _Gfx.help, NULL, _Gfx.screen, NULL ); + + l = *line < 0 ? 0 : *line > _Gfx.helplin - cGfxHelpLines - 1 ? _Gfx.helplin - cGfxHelpLines - 1 : *line; + for ( i = 0; i < cGfxHelpLines; ++i ) + { + ptrTxt = _Gfx.helptxt[ l + i ]; + x = cGfxHelpX - ( ( (BNX_INT16) (strlen( ptrTxt ) - 1) * cGfxFontSizeX ) >> 1 ); + gfxPrintText( x, y, ptrTxt ); + y += cGfxHelpDY; + } + *line = l; +} + +void gfxRenderHof( BNX_HALL *hof, BNX_INT16 hofview ) +{ + static BNX_INT16 count = 0; + + BNX_INT16 i; + BNX_INT16 x; + BNX_INT16 y; + SDL_Rect pos; + + char ptrTxt[ cGfxStrLen ]; + + x = cGfxHelpX; + y = cGfxHelpY + cGfxHelpDY; + + SDL_BlitSurface( _Gfx.help, NULL, _Gfx.screen, NULL ); + + x = cGfxHelpX - ( ( (BNX_INT16) (strlen( TXT_HofCase[ 0 ] ) - 1) * cGfxFontSizeX ) >> 1 ); + gfxPrintText( x, y, TXT_HofCase[ 0 ] ); + y += cGfxHelpDY; + + for ( i = 0; i < cHofEntries; ++i ) + { + sprintf( ptrTxt, "#%d - %s - %8d", i+1, hof->arcade[ i ].name, hof->arcade[ i ].score ); + x = cGfxHelpX - ( ( (BNX_INT16) (strlen( ptrTxt ) - 1) * cGfxFontSizeX ) >> 1 ); + gfxPrintText( x, y, ptrTxt ); + y += cGfxHelpDY; + } + + y += (cGfxHelpDY<<1); + x = cGfxHelpX - ( ( (BNX_INT16) (strlen( TXT_HofCase[ 1 ] ) - 1) * cGfxFontSizeX ) >> 1 ); + gfxPrintText( x, y, TXT_HofCase[ 1 ] ); + y += cGfxHelpDY; + + for ( i = 0; i < cHofEntries; ++i ) + { + sprintf( ptrTxt, "#%d - %s - %8d", i+1, hof->tactic[ i ].name, hof->tactic[ i ].score ); + x = cGfxHelpX - ( ( (BNX_INT16) (strlen( ptrTxt ) - 1) * cGfxFontSizeX ) >> 1 ); + gfxPrintText( x, y, ptrTxt ); + y += cGfxHelpDY; + } + + if ( cfgGetTouch() == BNX_TRUE ) + { + switch ( hofview ) + { + case cGfxHofKeyboardUp: + pos.x = cGfxKeyboardX; + pos.y = cGfxKeyboardY2; + SDL_BlitSurface( _Gfx.keyboard, NULL, _Gfx.screen, &pos ); + break; + case cGfxHofKeyboardDn: + pos.x = cGfxKeyboardX; + pos.y = cGfxKeyboardY1; + SDL_BlitSurface( _Gfx.keyboard, NULL, _Gfx.screen, &pos ); + break; + default: + break; + } + } + + if ( (count % cGfxFall) == 0 ) + { + gfxNewParticle( sysRand( cGfxScreenX ), sysRand( cGfxScreenY ) ); + count = 0; + } + count ++; + + gfxUpdateParticles(); + gfxRenderParticles(); +} + +void gfxPrintText( BNX_INT16 x, BNX_INT16 y, const char *text ) +{ + char c; + SDL_Rect tpos, ppos; + + ppos.x = x; + ppos.y = y; + ppos.w = cGfxFontSizeX; + ppos.h = cGfxFontSizeY; + tpos.w = cGfxFontSizeX; + tpos.h = cGfxFontSizeY; + + while ( *text != '\0' ) + { + c = *text - ' '; + tpos.x = ( ((BNX_INT16)(c)) % cGfxFontTileX ) * cGfxFontSizeX; + tpos.y = ( ((BNX_INT16)(c)) / cGfxFontTileX ) * cGfxFontSizeY; + SDL_BlitSurface( _Gfx.font, &tpos, _Gfx.screen, &ppos ); + ppos.x += cGfxFontSizeX; + text ++; + } +} + +void gfxPrintTextWave( BNX_INT16 x, BNX_INT16 y, const char *text, BNX_INT16 start ) +{ + char c; + SDL_Rect tpos, ppos; + static BNX_INT16 sinuz[] = { 0, 1, 2, 3, 4, 3, 2, 1, 0, -1, -2, -3, -4, -3, -2, -1 }; + + ppos.x = x; + ppos.y = y; + ppos.w = cGfxFontSizeX; + ppos.h = cGfxFontSizeY; + tpos.w = cGfxFontSizeX; + tpos.h = cGfxFontSizeY; + + while ( *text != '\0' ) + { + ppos.y = y + sinuz[ start % cGfxMaxWave ]; + c = *text - ' '; + tpos.x = ( ((BNX_INT16)(c)) % cGfxFontTileX ) * cGfxFontSizeX; + tpos.y = ( ((BNX_INT16)(c)) / cGfxFontTileX ) * cGfxFontSizeY; + SDL_BlitSurface( _Gfx.font, &tpos, _Gfx.screen, &ppos ); + ppos.x += cGfxFontSizeX; + text ++; + start ++; + } +} + +void gfxMessageBox( BNX_INT16 x, BNX_INT16 y, const char *text ) +{ + BNX_INT16 xt, yt; + SDL_Rect wpos = {0, 0, 0, 0}; + + wpos.x = x; + wpos.y = y; + SDL_BlitSurface( _Gfx.window, NULL, _Gfx.screen, &wpos ); + + xt = x + ( (BNX_INT16) _Gfx.window->w >> 1 ) - ( ( (BNX_INT16) strlen( text ) * cGfxFontSizeX ) >> 1 ); + yt = y + ( (BNX_INT16) _Gfx.window->h >> 1 ) - ( cGfxFontSizeY >> 1 ); + gfxPrintText( xt, yt, text ); +} + +void gfxUpdateJumpyText( void ) +{ + if ( _Gfx.jtext.downtime > 0 ) + { + _Gfx.jtext.downtime--; + _Gfx.jtext.y += cGfxJTextSpeed; + } +} + +void gfxRenderJumpyText( void ) +{ + static BNX_INT16 wave = 0; + if ( _Gfx.jtext.downtime > 0 ) + { + gfxPrintTextWave( _Gfx.jtext.x, _Gfx.jtext.y, TXT_Extras[ _Gfx.jtext.index ], wave++ ); + wave %= cGfxMaxWave; + } +} + +void gfxRoadmap( BNX_INT32 prev, BNX_INT32 score ) +{ + BNX_INT16 lev; + BNX_INT16 cur; + BNX_INT16 swi = 0; + BNX_INT32 startTime; + SDL_Rect pos; + + if ( prev < cRoadBeginnerScore && score >= cRoadBeginnerScore ) + { + lev = 0; + } + else if ( prev < cRoadRookieScore && score >= cRoadRookieScore ) + { + lev = 1; + } + else if ( prev < cRoadNoviceScore && score >= cRoadNoviceScore ) + { + lev = 2; + } + else if ( prev < cRoadAdvancedScore && score >= cRoadAdvancedScore ) + { + lev = 3; + } + else if ( prev < cRoadExpertScore && score >= cRoadExpertScore ) + { + lev = 4; + } + else if ( prev < cRoadMasterScore && score >= cRoadMasterScore ) + { + lev = 5; + } + else if ( prev < cRoadKingScore && score >= cRoadKingScore ) + { + lev = 6; + } + else + { + return; + } + + pos.x = (BNX_INT16) ( cGfxScreenX - _Gfx.roadmap->w ) >> 1; + pos.y = (BNX_INT16) ( cGfxScreenY - _Gfx.roadmap->h ) >> 1; + SDL_BlitSurface( _Gfx.roadmap, NULL, _Gfx.screen, &pos ); + + pos.x += cGfxRoadmapBX; + pos.y += cGfxRoadmapBY; + pos.w = cGfxRoadmapBSize; + pos.h = cGfxRoadmapBSize; + for ( cur = 0; cur < lev; ++cur ) + { + SDL_FillRect( _Gfx.screen, &pos, SDL_MapRGB( _Gfx.screen->format, 255, 0, 0 ) ); + pos.y += cGfxRoadmapDY; + } + + gfxUpdate(); + + for ( cur = 0; cur < cGfxRoadmapIter; ++cur ) + { + startTime = sysGetTime(); + + if ( (swi & 1) == 0 ) + { + SDL_FillRect( _Gfx.screen, &pos, SDL_MapRGB( _Gfx.screen->format, 255, 0, 0 ) ); + } + else + { + SDL_FillRect( _Gfx.screen, &pos, SDL_MapRGB( _Gfx.screen->format, 128, 0, 0 ) ); + } + + swi ++; + gfxUpdate(); + + while ( sysGetTime() - startTime < cDeltaTime ) + { + sysUpdate(); + } + } + + inpUpdate(); + inpInit(); +} + +void gfxUpdate() +{ + SDL_Flip( _Gfx.screen ); +} + +/****************************************************************************** +LOADING THE GRAPHICAL RESOURCES +******************************************************************************/ + +BNX_BOOL gfxLoadImage( char *filename, SDL_Surface **img ) +{ + SDL_Surface *temp = 0; + + temp = IMG_Load( filename ); + if ( temp != 0 ) + { + *img = SDL_DisplayFormat( temp ); + SDL_FreeSurface( temp ); + return BNX_TRUE; + } + else + { + *img = 0; + return BNX_FALSE; + } +} + +BNX_BOOL gfxLoadHelp( char *filename ) +{ + FILE *f = 0; + BNX_HELPLINE txtBuf; + BNX_INT32 nLines = 0; + + + f = fopen( filename, "rt" ); + if ( f != 0 ) + { + nLines = 0; + while ( fgets( txtBuf, cGfxMaxTextLine, f ) != 0 ) + { + nLines ++; + } + fclose( f ); + } + else + { + return BNX_FALSE; + } + + _Gfx.helptxt = 0; + _Gfx.helptxt = ( BNX_HELPLINE * ) malloc( (nLines + 1) * sizeof ( BNX_HELPLINE ) ); + if ( _Gfx.helptxt != 0 ) + { + f = fopen( filename, "rt" ); + if ( f != 0 ) + { + nLines = 0; + while ( fgets( _Gfx.helptxt[ nLines ], cGfxMaxTextLine, f ) != 0 ) + { + nLines ++; + } + _Gfx.helplin = nLines; + fclose( f ); + return BNX_TRUE; + } + else + { + return BNX_FALSE; + } + } + + return BNX_FALSE; +} + +BNX_BOOL gfxLoadResources() +{ + BNX_BOOL bLoad = BNX_TRUE; + + /* Load GUI related graphics data */ + bLoad &= gfxLoadImage( "data/graphics/background0.png", &_Gfx.background[ cModeRealtime ]); + bLoad &= gfxLoadImage( "data/graphics/background1.png", &_Gfx.background[ cModeTurn ]); + bLoad &= gfxLoadImage( "data/graphics/background2.png", &_Gfx.background[ cModeMultiplayer ] ); + + bLoad &= gfxLoadImage( "data/graphics/window.png", &_Gfx.window ); + bLoad &= gfxLoadImage( "data/graphics/splash.png", &_Gfx.splash ); + bLoad &= gfxLoadImage( "data/graphics/logo.png", &_Gfx.logo ); + bLoad &= gfxLoadImage( "data/graphics/help.png", &_Gfx.help ); + bLoad &= gfxLoadImage( "data/graphics/font.png", &_Gfx.font ); + bLoad &= gfxLoadImage( "data/graphics/roadmap.png", &_Gfx.roadmap ); + + // Loading Game Elements + bLoad &= gfxLoadImage( "data/graphics/element0.png", &_Gfx.elements[ 0 ] ); + bLoad &= gfxLoadImage( "data/graphics/element1.png", &_Gfx.elements[ 1 ] ); + bLoad &= gfxLoadImage( "data/graphics/element2.png", &_Gfx.elements[ 2 ] ); + bLoad &= gfxLoadImage( "data/graphics/element3.png", &_Gfx.elements[ 3 ] ); + bLoad &= gfxLoadImage( "data/graphics/elementB.png", &_Gfx.elements[ 4 ] ); + + bLoad &= gfxLoadImage( "data/graphics/movecount.png", &_Gfx.movecount ); + bLoad &= gfxLoadImage( "data/graphics/keyboard.png", &_Gfx.keyboard ); + bLoad &= gfxLoadImage( "data/graphics/cursor0.png", &_Gfx.cursors[ 0 ] ); + bLoad &= gfxLoadImage( "data/graphics/cursor1.png", &_Gfx.cursors[ 1 ] ); + bLoad &= gfxLoadImage( "data/graphics/marker0.png", &_Gfx.markers[ 0 ] ); + bLoad &= gfxLoadImage( "data/graphics/marker1.png", &_Gfx.markers[ 1 ] ); + + bLoad &= gfxLoadImage( "data/graphics/particle0.png", &_Gfx.part[ 0 ] ); + bLoad &= gfxLoadImage( "data/graphics/particle1.png", &_Gfx.part[ 1 ] ); + bLoad &= gfxLoadImage( "data/graphics/particle2.png", &_Gfx.part[ 2 ] ); + + // Set alpha + SDL_SetAlpha( _Gfx.window, SDL_SRCALPHA /*| SDL_RLEACCEL*/, cGfxWinBlending ); + + // Load Help Text + gfxLoadHelp( "data/text/help.txt" ); + + return bLoad; +} + +/****************************************************************************** +INPUT VIA TOUCH-SCREEN. NOT THE NICEST INCLUDE IN THE ARCHITECURE... +******************************************************************************/ + +BNX_BOOL gfxInBox( BNX_INT16 x, BNX_INT16 y, BNX_BOX *box ) +{ + if ( x >= box->x1 && y >= box->y1 && x <= box->x2 && y <= box->y2 ) + { + return BNX_TRUE; + } + else + { + return BNX_FALSE; + } +} + +void gfxGetVirtualKey( BNX_GAME *game, BNX_INP *inp ) +{ + BNX_INT16 nPlayerCenterX; + BNX_INT16 nPlayerCenterY; + + if ( inp->mousePress == BNX_TRUE && cfgGetTouch() == BNX_TRUE ) + { + inp->mousePress = BNX_FALSE; + + /* Proceed with ingame handling */ + if ( gfxInBox( inp->mouseX, inp->mouseY, &(_BNX_BOXES[ cGfxIndField ]) ) == BNX_TRUE ) + { + nPlayerCenterX = + cGfxZeroX + game->player[ cPlayer1 ].x * cGfxPairPlusX + (cGfxPairPlusX>>1); + nPlayerCenterY = + cGfxZeroY + game->player[ cPlayer1 ].y * cGfxPairPlusY - (cGfxPairPlusY>>1); + + if ( abs( nPlayerCenterX - inp->mouseX ) > abs( nPlayerCenterY - inp->mouseY ) ) + { + /* Move horizontally */ + if ( nPlayerCenterX > inp->mouseX ) + { + inp->keyLeft = BNX_TRUE; + } + else + { + inp->keyRight = BNX_TRUE; + } + } + else + { + /* Move vertically */ + if ( nPlayerCenterY > inp->mouseY ) + { + inp->keyUp = BNX_TRUE; + } + else + { + inp->keyDown = BNX_TRUE; + } + } + } + /* Detect Ingame Escape */ + else if ( gfxInBox( inp->mouseX, inp->mouseY, &(_BNX_BOXES[ cGfxIndEscape ]) ) == BNX_TRUE ) + { + inp->keyB = BNX_TRUE; + } + /* Try to detect Ingame Space press */ + else + { + if ( game->mode == cModeRealtime ) + { + if ( gfxInBox( inp->mouseX, inp->mouseY, &(_BNX_BOXES[ cGfxIndSpaceR ]) ) == BNX_TRUE ) + { + inp->keyC = BNX_TRUE; + } + } + else if ( game->mode == cModeTurn ) + { + if ( gfxInBox( inp->mouseX, inp->mouseY, &(_BNX_BOXES[ cGfxIndSpaceT ]) ) == BNX_TRUE ) + { + inp->keyC = BNX_TRUE; + } + } + } + } +} + +void gfxGetVirtualChar( BNX_GAME *game, BNX_INP *inp ) +{ + BNX_INT32 arx, ary; + char c = 0; + + if ( inp->mousePress == BNX_TRUE && cfgGetTouch() == BNX_TRUE ) + { + inp->mousePress = BNX_FALSE; + arx = ((inp->mouseX - cGfxKeyboardX) * cGfxKeyGridX) / _Gfx.keyboard->w; + switch ( game->mode ) + { + case cModeTurn: + ary = (((inp->mouseY - cGfxKeyboardY2) * cGfxKeyGridY) / _Gfx.keyboard->h); + break; + case cModeRealtime: + ary = (((inp->mouseY - cGfxKeyboardY1) * cGfxKeyGridY) / _Gfx.keyboard->h); + break; + default: + return; + } + if ( arx >=0 && arx < cGfxKeyGridX && ary >= 0 && ary < cGfxKeyGridY ) + { + c = virtualKBD[ ary ][ arx ]; + switch (c) + { + case 'e': + inp->keyA = BNX_TRUE; + break; + case 'b': + inp->keyDel = BNX_TRUE; + break; + default: + inp->letter = c; + break; + } + } + } +} + +BNX_INT16 gfxGetMenuOption( BNX_INP *inp ) +{ + BNX_INT16 i; + + if ( inp->mousePress == BNX_TRUE && cfgGetTouch() == BNX_TRUE ) + { + inp->mousePress = BNX_FALSE; + for ( i = 0; i < cMaxOptions; ++i ) + { + if ( gfxInBox( inp->mouseX, inp->mouseY, &(_BNX_MENU_BOXES[ i ]) ) == BNX_TRUE ) + { + return i; + } + } + } + return -1; +} + +void gfxGetHelpPen( BNX_INP *inp ) +{ + if ( inp->mousePress == BNX_TRUE && cfgGetTouch() == BNX_TRUE ) + { + inp->mousePress = BNX_FALSE; + if ( gfxInBox( inp->mouseX, inp->mouseY, &(_BNX_BOXES[ cGfxIndEscape ]) ) == BNX_TRUE ) + { + inp->keyA = BNX_TRUE; + } + else if ( inp->mouseY < (cGfxScreenY>>1) ) + { + inp->keyPageUp = BNX_TRUE; + } + else if ( inp->mouseY > (cGfxScreenY>>1) ) + { + inp->keyPageDown = BNX_TRUE; + } + } +} + +/****************************************************************************** +PARTICLE SYSTEM +******************************************************************************/ + +void gfxInitParticles() +{ + BNX_INT16 j; + + for ( j = 0; j < cGfxMaxParticles; ++j ) + { + _Gfx.particle[ j ].status = 0; + } +} + +void gfxNewParticle( BNX_INT16 x, BNX_INT16 y ) +{ + BNX_INT16 i; + BNX_INT16 j; + + for ( j = 0; j < cGfxMaxParticles; ++j ) + { + if ( _Gfx.particle[ j ].status <= 0 ) + { + break; + } + } + j %= cGfxMaxParticles; + _Gfx.particle[ j ].status = cGfxParticleLife; + for ( i = 0; i < cGfxParticleSet; ++i ) + { + _Gfx.particle[ j ].x[ i ] = x; + _Gfx.particle[ j ].y[ i ] = y; + _Gfx.particle[ j ].dx[ i ] = cGfxParticleSpeed - ( sysRand( cGfxParticleSpeed<<1 ) + cGfxParticleMinSp ); + _Gfx.particle[ j ].dy[ i ] = sysRand( cGfxParticleSpeed>>1 ) - cGfxParticleSpeed; + } +} + +void gfxUpdateParticles() +{ + BNX_INT16 i; + BNX_INT16 j; + + for ( j = 0; j < cGfxMaxParticles; ++j ) + { + if ( _Gfx.particle[ j ].status > 0 ) + { + _Gfx.particle[ j ].status --; + for ( i = 0; i < cGfxParticleSet; ++i ) + { + _Gfx.particle[ j ].x[ i ] += _Gfx.particle[ j ].dx[ i ]; + _Gfx.particle[ j ].y[ i ] += _Gfx.particle[ j ].dy[ i ]; + _Gfx.particle[ j ].dy[ i ] += cGfxParticleFall; + } + } + } +} + +void gfxRenderParticles() +{ + BNX_INT16 i; + BNX_INT16 j; + BNX_INT16 index; + SDL_Rect pos; + + for ( j = 0; j < cGfxMaxParticles; ++j ) + { + if ( _Gfx.particle[ j ].status > 0 ) + { + for ( i = 0; i < cGfxParticleSet; ++i ) + { + index = sysRand( cGfxParticleState ); + pos.x = _Gfx.particle[ j ].x[ i ] - (_Gfx.part[ index ]->w >> 1); + pos.y = _Gfx.particle[ j ].y[ i ] - (_Gfx.part[ index ]->h >> 1); + + SDL_BlitSurface( _Gfx.part[ index ], NULL, _Gfx.screen, &pos ); + } + } + } +} diff --git a/project/jni/application/biniax2/src/gfx.h b/project/jni/application/biniax2/src/gfx.h new file mode 100644 index 000000000..28927d953 --- /dev/null +++ b/project/jni/application/biniax2/src/gfx.h @@ -0,0 +1,280 @@ +/****************************************************************************** +BINIAX GRAPHICS-RELATED DEFINITIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2009 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +#ifndef _BNX_GFX_H +#define _BNX_GFX_H + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include "inc.h" + +#include +#include + +/****************************************************************************** +GRAPHICS CONSTANTS +******************************************************************************/ + +#define cGfxScreenX 800 +#define cGfxScreenY 600 +#define cGfxColorDepth 16 + +#define cGfxZeroX 32 +#define cGfxZeroY 527 +#define cGfxNextPlusX 48 +#define cGfxShieldPlusX 0 + +#define cGfxPairPlusX 128 +#define cGfxPairPlusY -64 + +#define cGfxPlayerPlusX 24 +#define cGfxMarkerPlusX 70 +#define cGfxMarkerPlusY -64 + +#define cGfxFontSizeX 16 +#define cGfxFontSizeY 32 +#define cGfxFontTileX 14 +#define cGfxFontTileY 10 + +#define cGfxInfoBar 30 +#define cGfxSpraySize 5 +#define cGfxSpray 300 + +#define cGfxScoreX 30 +#define cGfxScoreY 54 +#define cGfxBestX 330 +#define cGfxBestY 54 +#define cGfxScore1X 30 +#define cGfxScore1Y 28 +#define cGfxScore2X 30 +#define cGfxScore2Y 68 + +#define cGfxMoveCX 690 +#define cGfxMoveCY 185 +#define cGfxLegendX 683 +#define cGfxLegendY 150 + +#define cGfxOptionX 332 +#define cGfxOptionY 240 +#define cGfxOptionDY 36 +#define cGfxMenuEffect 500 +#define cGfxMessageX 75 +#define cGfxMessageY 210 +#define cGfxRunsLeftX ( cGfxScreenX >> 1 ) +#define cGfxRunsLeftY 570 +#define cGfxClearsAX 684 +#define cGfxClearsAY 330 +#define cGfxClearsTX 684 +#define cGfxClearsTY 545 + +#define cGfxHelpX ( cGfxScreenX >> 1 ) +#define cGfxHelpY 7 +#define cGfxHelpDY 30 +#define cGfxHelpLines (( cGfxScreenY - cGfxHelpY ) / cGfxHelpDY) +#define cGfxHelpPage (cGfxHelpLines >> 1) + +#define cGfxFall 4 +#define cGfxShake 3 +#define cGfxCursors 2 + +#define cGfxBrickElement 4 +#define cGfxMaxElements ( cMaxElements + 1 ) + +#define cGfxWinBlending 200 + +#define cGfxCursorSpeed 3 +#define cGfxMaxTextLine 128 + +#define cGfxMaxPartTime 60 +#define cGfxExePartTime 6 +#define cGfxParticleSet 4 +#define cGfxMaxParticles cGridX * cGridY +#define cGfxParticleLife 50 +#define cGfxParticleSpeed 30 +#define cGfxParticleMinSp 10 +#define cGfxParticleFall 4 +#define cGfxParticleState 3 + +#define cGfxMaxWave 16 +#define cGfxStrLen 200 + +#define cGfxMaxAlpha 255 +#define cGfxAlphaStep 16 +#define cGfxWelcomeWait 1200 + +#define cGfxJTextLive 30 +#define cGfxJTextSpeed -10 + +#define cGfxRoadmapBX 96 +#define cGfxRoadmapBY 329 +#define cGfxRoadmapDY -51 +#define cGfxRoadmapBSize 50 +#define cGfxRoadmapIter 32 + +#define cGfxKeyboardX 185 +#define cGfxKeyboardY1 315 +#define cGfxKeyboardY2 185 +#define cGfxKeyGridX 10 +#define cGfxKeyGridY 4 +#define cGfxHofNoKeyboard 0 +#define cGfxHofKeyboardUp 1 +#define cGfxHofKeyboardDn 2 + + +#define cGfxTutorialSteps 12 + +/* Stupid touch-screen patch */ +enum { + cGfxIndField = 0, + cGfxIndEscape, + cGfxIndSpaceR, + cGfxIndSpaceT, + cGfxIndMax, +}; +typedef struct BNX_BOX +{ + BNX_INT16 x1; + BNX_INT16 y1; + BNX_INT16 x2; + BNX_INT16 y2; +} BNX_BOX; + +static BNX_BOX _BNX_BOXES[ cGfxIndMax ] = { + { 18, 128, 656, 588 }, + { 715, 0, 800, 40 }, + { 680, 310, 780, 380 }, + { 680, 515, 780, 580 } +}; + +static BNX_BOX _BNX_MENU_BOXES[ cMaxOptions ] = { + { 183, 290, 475, 314 }, + { 210, 323, 450, 348 }, + { 209, 361, 450, 386 }, + { 241, 395, 420, 420 }, + { 232, 430, 426, 457 }, + { 296, 468, 364, 492 }, + { 295, 503, 362, 528 } +}; + +static char virtualKBD[ cGfxKeyGridY ][ cGfxKeyGridX ] = { + "1234567890", + "QWERTYUIOP", + "ASDFGHJKLe", + "ZXCVBNM b", +}; + +/****************************************************************************** +LOCAL GRAPHICS DATA (VIDEO BUFFERS, IMAGES, FONTS, ETC.) +******************************************************************************/ + +typedef char BNX_HELPLINE[ cGfxMaxTextLine ]; + +typedef struct BNX_PARTICLE +{ + BNX_INT16 x[ cGfxParticleSet ]; + BNX_INT16 y[ cGfxParticleSet ]; + BNX_INT16 dx[ cGfxParticleSet ]; + BNX_INT16 dy[ cGfxParticleSet ]; + BNX_INT16 status; + +} BNX_PARTICLE; + +typedef struct BNX_JUMPYTEXT +{ + BNX_INT16 x; + BNX_INT16 y; + BNX_INT16 index; + BNX_INT16 downtime; +} BNX_JUMPYTEXT; + +typedef struct BNX_GFX +{ + SDL_Surface *screen; + + SDL_Surface *logo; + SDL_Surface *splash; + SDL_Surface *roadmap; + SDL_Surface *help; + SDL_Surface *window; + + SDL_Surface *background[ cMaxModes ]; + SDL_Surface *elements[ cGfxMaxElements ]; + SDL_Surface *movecount; + SDL_Surface *cursors[ cGfxCursors ]; + SDL_Surface *markers[ cMaxPlayers ]; + SDL_Surface *part[ cGfxParticleState ]; + + SDL_Surface *font; + SDL_Surface *keyboard; + + BNX_HELPLINE *helptxt; + BNX_INT16 helplin; + + BNX_JUMPYTEXT jtext; + + BNX_PARTICLE particle[ cGfxMaxParticles ]; + +} BNX_GFX; + +/****************************************************************************** +PUBLIC FUNCTIONS +******************************************************************************/ + +BNX_BOOL gfxInit(); + +void gfxUpdate(); + +void gfxRenderEntry( void ); + +void gfxRenderMenu( const BNX_INT16 option ); + +void gfxRenderHelp( BNX_INT16 *line ); + +void gfxRenderHof( BNX_HALL *hof, BNX_INT16 hofview ); + +void gfxRenderGame( BNX_GAME *game ); + +void gfxPrintText( BNX_INT16 x, BNX_INT16 y, const char *text ); + +void gfxPrintTextWave( BNX_INT16 x, BNX_INT16 y, const char *text, BNX_INT16 start ); + +void gfxMessageBox( BNX_INT16 x, BNX_INT16 y, const char *text ); + +void gfxGetVirtualKey( BNX_GAME *game, BNX_INP *inp ); + +void gfxGetVirtualChar( BNX_GAME *game, BNX_INP *inp ); + +BNX_INT16 gfxGetMenuOption( BNX_INP *inp ); + +void gfxGetHelpPen( BNX_INP *inp ); + +/****************************************************************************** +HELPER FUNCTIONS +******************************************************************************/ + +#endif diff --git a/project/jni/application/biniax2/src/hof.c b/project/jni/application/biniax2/src/hof.c new file mode 100644 index 000000000..45de7bac1 --- /dev/null +++ b/project/jni/application/biniax2/src/hof.c @@ -0,0 +1,295 @@ +/****************************************************************************** +BINIAX HALL OF FAME IMPLEMENTATIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2006-2009 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +/****************************************************************************** +INCLUDES +******************************************************************************/ +#include + +#include "inc.h" + +#define chCursor '_' /* Cursor ON */ +#define chSpace ' ' /* Cursor OFF*/ + +#define csHOFName "hof.bnx2" /* File name */ +#define cHOFFileSize 504 /* File size */ + +BNX_HALL Hof; + +/****************************************************************************** +FUNCTIONS +******************************************************************************/ +void hofAddLetter( BNX_INT16 pos, char a, char *name ); +void hofBlinkCursor( BNX_INT16 pos, char *name ); +void hofResetCursor( BNX_INT16 pos, char *name ); + + +void hofAddLetter( BNX_INT16 pos, char a, char *name ) +{ + if ( pos < cHofNameLen-1 ) + { + name[ pos ] = a; + } +} + +void hofBlinkCursor( BNX_INT16 pos, char *name ) +{ + static BNX_INT16 delayer = 0; + + if ( pos < cHofNameLen-1 ) + { + if ( (delayer & 1) == 0 ) + { + if ( name[ pos ] == chSpace ) + { + name[ pos ] = chCursor; + } + else + { + name[ pos ] = chSpace; + } + delayer = 0; + } + delayer ++; + } +} + +void hofResetCursor( BNX_INT16 pos, char *name ) +{ + if ( pos < cHofNameLen-1 ) + { + name[ pos ] = chSpace; + } +} + + +BNX_BOOL hofInit() +{ + FILE *file; + BNX_INT16 i, j; + + + for ( i = 0; i < cHofEntries; ++i ) + { + strcpy( Hof.arcade[ i ].name, "JORDAN " ); + Hof.arcade[ i ].score = (cHofEntries - i) * cHofInitScore; + + strcpy( Hof.tactic[ i ].name, "JORDAN " ); + Hof.tactic[ i ].score = (cHofEntries - i) * cHofInitScore; + } + + if ( sysGetFileLen( sysGetFullFileName( csHOFName ) ) != cHOFFileSize ) + return BNX_FALSE; + file = fopen( sysGetFullFileName( csHOFName ), "rb" ); + if ( file == (FILE *) NULL ) + return BNX_FALSE; + + for ( i = 0; i < cHofEntries; ++i ) + { + for ( j = 0; j < cHofNameLen; ++j ) + { + Hof.arcade[ i ].name[ j ] = sysFGet8( file ); + } + sysFGet2byte( file ); + Hof.arcade[ i ].score = sysFGet32( file ); + } + + for ( i = 0; i < cHofEntries; ++i ) + { + for ( j = 0; j < cHofNameLen; ++j ) + { + Hof.tactic[ i ].name[ j ] = sysFGet8( file ); + } + sysFGet2byte( file ); + Hof.tactic[ i ].score = sysFGet32( file ); + } + + fclose( file ); + + return BNX_TRUE; +} + +BNX_BOOL hofSave() +{ + FILE *file; + int i, j; + + file = fopen( sysGetFullFileName( csHOFName ), "wb" ); + + if ( file == (FILE *) NULL ) + return BNX_FALSE; + + for ( i = 0; i < cHofEntries; ++i ) + { + for ( j = 0; j < cHofNameLen; ++j ) + { + sysFPut8( Hof.arcade[ i ].name[ j ], file ); + } + sysFPut2byte( file ); + sysFPut32( Hof.arcade[ i ].score, file ); + } + + for ( i = 0; i < cHofEntries; ++i ) + { + for ( j = 0; j < cHofNameLen; ++j ) + { + sysFPut8( Hof.tactic[ i ].name[ j ], file ); + } + sysFPut2byte( file ); + sysFPut32( Hof.tactic[ i ].score, file ); + } + + fclose( file ); + + return BNX_TRUE; +} + +BNX_BOOL hofEnter( BNX_GAME *game ) +{ + BNX_INT32 startTime; + BNX_INT16 viewoption = cGfxHofNoKeyboard; + BNX_INT16 curPos = 0; + BNX_INT16 i, j; + char cChar = 0; + BNX_HALL_ENTRY *recEntry = 0; + + switch ( game->mode ) + { + case cModeRealtime: + for ( i = 0; i < cHofEntries; ++i ) + { + if ( Hof.arcade[ i ].score < game->score[ cPlayer1 ] ) + { + recEntry = &Hof.arcade[ i ]; + viewoption = cGfxHofKeyboardDn; + break; + } + } + for ( j = cHofEntries-1; j > i; --j ) + { + strcpy( Hof.arcade[ j ].name, Hof.arcade[ j-1 ].name ); + Hof.arcade[ j ].score = Hof.arcade[ j-1 ].score; + } + break; + case cModeTurn: + for ( i = 0; i < cHofEntries; ++i ) + { + if ( Hof.tactic[ i ].score < game->score[ cPlayer1 ] ) + { + recEntry = &Hof.tactic[ i ]; + viewoption = cGfxHofKeyboardUp; + break; + } + } + for ( j = cHofEntries-1; j > i; --j ) + { + strcpy( Hof.tactic[ j ].name, Hof.tactic[ j-1 ].name ); + Hof.arcade[ j ].score = Hof.tactic[ j-1 ].score; + } + break; + default: + return BNX_TRUE; + } + + if ( recEntry == 0 ) + { + return BNX_FALSE; + } + + strcpy( recEntry->name, " " ); + recEntry->score = game->score[ cPlayer1 ]; + inpInit(); + do + { + startTime = sysGetTime(); + + gfxGetVirtualChar( game, inpDirect() ); + cChar = inpGetChar(); + if ( cChar > 0 ) + { + hofAddLetter( curPos, cChar, recEntry->name ); + if ( curPos < cHofNameLen - 1 ) + { + curPos++; + } + } + if ( inpKeyDel() == BNX_TRUE ) + { + hofResetCursor( curPos, recEntry->name ); + if ( curPos > 0 ) + { + curPos--; + } + } + hofBlinkCursor( curPos, recEntry->name ); + + inpUpdate(); + gfxRenderHof( &Hof, viewoption ); + gfxUpdate(); + sndUpdate(); + sysUpdate(); + + // Synchronize with the clock + while ( sysGetTime() - startTime < cDeltaTime ) + { + sysUpdate(); + } + } + while ( inpKeyA() == BNX_FALSE && inpKeyB() == BNX_FALSE ); + hofResetCursor( curPos, recEntry->name ); + + return BNX_TRUE; +} + +void hofView() +{ + BNX_INT32 startTime; + + inpInit(); + do + { + startTime = sysGetTime(); + + inpUpdate(); + gfxGetHelpPen( inpDirect() ); + gfxRenderHof( &Hof, cGfxHofNoKeyboard ); + gfxUpdate(); + sndUpdate(); + sysUpdate(); + + // Synchronize with the clock + while ( sysGetTime() - startTime < cDeltaTime ) + { + sysUpdate(); + } + } + while ( inpKeyA() == BNX_FALSE ); +} + +BNX_HALL *hofGet() +{ + return (BNX_HALL *) &Hof; +} \ No newline at end of file diff --git a/project/jni/application/biniax2/src/hof.h b/project/jni/application/biniax2/src/hof.h new file mode 100644 index 000000000..2b2fe61f7 --- /dev/null +++ b/project/jni/application/biniax2/src/hof.h @@ -0,0 +1,69 @@ +/****************************************************************************** +BINIAX HALL OF FAME DEFINITIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2009 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +#ifndef _BNX_HOF_H +#define _BNX_HOF_H + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include "inc.h" + +#define cHofEntries 7 +#define cHofNameLen 30 +#define cHofInitScore 1000 + +/****************************************************************************** +HALL OF FAME DATATYPES +******************************************************************************/ +typedef struct BNX_HALL_ENTRY +{ + char name[ cHofNameLen ]; + BNX_INT32 score; +} BNX_HALL_ENTRY; + +typedef struct BNX_HALL +{ + BNX_HALL_ENTRY arcade[ cHofEntries ]; + BNX_HALL_ENTRY tactic[ cHofEntries ]; +} BNX_HALL; + +/****************************************************************************** +FUNCTIONS +******************************************************************************/ + +BNX_BOOL hofInit(); + +BNX_BOOL hofSave(); + +void hofView(); + +BNX_BOOL hofEnter( BNX_GAME *game ); + +BNX_HALL *hofGet(); + +#endif diff --git a/project/jni/application/biniax2/src/inc.h b/project/jni/application/biniax2/src/inc.h new file mode 100644 index 000000000..e791ae01a --- /dev/null +++ b/project/jni/application/biniax2/src/inc.h @@ -0,0 +1,72 @@ +/****************************************************************************** +BINIAX ALL INCLUDES +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2007 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +#ifndef _BNX_INC_H +#define _BNX_INC_H + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include "game.h" +#include "hof.h" + +#define __WIN32 + +/* Desktop / SDL includes */ +#ifdef __WIN32 +#include "types.h" +#include "inp.h" +#include "gfx.h" +#include "snd.h" +#include "sys.h" +#include "cfg.h" +//#include "net.h" + +#include + +#endif + +/* WinCE / EasyCE includes */ +#ifdef __WINCE +#include "wince/types.h" +#include "wince/inp.h" +#include "wince/gfx.h" +#include "wince/snd.h" +#include "wince/sys.h" +#endif + +/* Symbain / Series60 includes */ +#ifdef __SERIES60 +#include "symbian/types.h" +#include "symbian/inp.h" +#include "symbian/gfx.h" +#include "symbian/snd.h" +#include "symbian/sys.h" +#endif + + +#endif diff --git a/project/jni/application/biniax2/src/inp.c b/project/jni/application/biniax2/src/inp.c new file mode 100644 index 000000000..f7451fc0f --- /dev/null +++ b/project/jni/application/biniax2/src/inp.c @@ -0,0 +1,333 @@ +/****************************************************************************** +BINIAX INPUT-RELATED IMPLEMENTATIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2009 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include + +#include "inc.h" + +/****************************************************************************** +FUNCTIONS +******************************************************************************/ + + +BNX_BOOL inpInit() +{ + _Inp.keyUp = BNX_FALSE; + _Inp.keyDown = BNX_FALSE; + _Inp.keyLeft = BNX_FALSE; + _Inp.keyRight = BNX_FALSE; + _Inp.keyAltUp = BNX_FALSE; + _Inp.keyAltDown = BNX_FALSE; + _Inp.keyAltLeft = BNX_FALSE; + _Inp.keyAltRight= BNX_FALSE; + _Inp.keyPageUp = BNX_FALSE; + _Inp.keyPageDown= BNX_FALSE; + _Inp.keyA = BNX_FALSE; + _Inp.keyB = BNX_FALSE; + _Inp.keyQuit = BNX_FALSE; + _Inp.keyDel = BNX_FALSE; + + _Inp.mousePress = BNX_FALSE; + _Inp.mouseX = 0; + _Inp.mouseY = 0; + + _Inp.letter = 0; + + return BNX_TRUE; +} + +void inpUpdate() +{ + SDL_Event event; + int x, y; + + while( SDL_PollEvent( &event ) ) + { + switch( event.type ) + { + case SDL_KEYDOWN: + switch( event.key.keysym.sym ) + { + case SDLK_SPACE : + _Inp.keyC = BNX_TRUE; + break; + case SDLK_RETURN : + _Inp.keyA = BNX_TRUE; + break; + case SDLK_ESCAPE : + _Inp.keyB = BNX_TRUE; + break; + case SDLK_KP8: + case SDLK_UP : + _Inp.keyUp = BNX_TRUE; + break; + case SDLK_KP2: + case SDLK_DOWN : + _Inp.keyDown = BNX_TRUE; + break; + case SDLK_KP4: + case SDLK_LEFT : + _Inp.keyLeft = BNX_TRUE; + break; + case SDLK_KP6: + case SDLK_RIGHT : + _Inp.keyRight = BNX_TRUE; + break; + + case SDLK_w : + _Inp.keyAltUp = BNX_TRUE; + break; + case SDLK_s : + _Inp.keyAltDown = BNX_TRUE; + break; + case SDLK_a : + _Inp.keyAltLeft = BNX_TRUE; + break; + case SDLK_d : + _Inp.keyAltRight= BNX_TRUE; + break; + + case SDLK_BACKSPACE : + case SDLK_DELETE : + _Inp.keyDel = BNX_TRUE; + break; + case SDLK_PAGEUP : + _Inp.keyPageUp = BNX_TRUE; + break; + case SDLK_PAGEDOWN : + _Inp.keyPageDown= BNX_TRUE; + break; + } + if ( event.key.keysym.sym >= SDLK_a && event.key.keysym.sym <= SDLK_z ) + { + _Inp.letter = (event.key.keysym.sym - SDLK_a) + 'A'; + } + else if ( event.key.keysym.sym >= SDLK_0 && event.key.keysym.sym <= SDLK_9 ) + { + _Inp.letter = (event.key.keysym.sym - SDLK_0) + '0'; + } + else if ( event.key.keysym.sym == SDLK_SPACE ) + { + _Inp.letter = ' '; + } + break; + + case SDL_MOUSEBUTTONDOWN : + _Inp.mousePress = BNX_TRUE; + break; + + case SDL_QUIT: + SDL_Quit(); + exit( 2 ); + break; + + } + } + + SDL_GetMouseState( &x, &y ); + _Inp.mouseX = x; + _Inp.mouseY = y; +} + +BNX_BOOL inpKeyLeft() +{ + if ( _Inp.keyLeft == BNX_TRUE ) + { + _Inp.keyLeft = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyRight() +{ + if ( _Inp.keyRight == BNX_TRUE ) + { + _Inp.keyRight = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyUp() +{ + if ( _Inp.keyUp == BNX_TRUE ) + { + _Inp.keyUp = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyDown() +{ + if ( _Inp.keyDown == BNX_TRUE ) + { + _Inp.keyDown = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyAltLeft() +{ + if ( _Inp.keyAltLeft == BNX_TRUE ) + { + _Inp.keyAltLeft = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyAltRight() +{ + if ( _Inp.keyAltRight == BNX_TRUE ) + { + _Inp.keyAltRight = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyAltUp() +{ + if ( _Inp.keyAltUp == BNX_TRUE ) + { + _Inp.keyAltUp = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyAltDown() +{ + if ( _Inp.keyAltDown == BNX_TRUE ) + { + _Inp.keyAltDown = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyA() +{ + if ( _Inp.keyA == BNX_TRUE ) + { + _Inp.keyA = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyB() +{ + if ( _Inp.keyB == BNX_TRUE ) + { + _Inp.keyB = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyC() +{ + if ( _Inp.keyC == BNX_TRUE ) + { + _Inp.keyC = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyPageUp() +{ + if ( _Inp.keyPageUp == BNX_TRUE ) + { + _Inp.keyPageUp = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyPageDown() +{ + if ( _Inp.keyPageDown == BNX_TRUE ) + { + _Inp.keyPageDown = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpKeyDel() +{ + if ( _Inp.keyDel == BNX_TRUE ) + { + _Inp.keyDel = BNX_FALSE; + return BNX_TRUE; + } + + return BNX_FALSE; +} + +BNX_BOOL inpExit() +{ + return _Inp.keyQuit; +} + +char inpGetChar() +{ + char ch = 0; + if ( _Inp.letter > 0 ) + { + ch = _Inp.letter; + _Inp.letter = 0; + } + + return ch; +} + +BNX_INP *inpDirect() +{ + return &_Inp; +} \ No newline at end of file diff --git a/project/jni/application/biniax2/src/inp.h b/project/jni/application/biniax2/src/inp.h new file mode 100644 index 000000000..89160ccd8 --- /dev/null +++ b/project/jni/application/biniax2/src/inp.h @@ -0,0 +1,103 @@ +/****************************************************************************** +BINIAX INPUT-RELATED DEFINITIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2007 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +#ifndef _BNX_INP_H +#define _BNX_INP_H + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include "inc.h" + +#define cInpKeyEnter SDLK_RETURN +#define cInpKeyBackspace SDLK_BACKSPACE + +/****************************************************************************** +LOCAL INPUT DATA (KEY FLAGS, POINTERS, ETC.) +******************************************************************************/ + +typedef struct BNX_INP +{ + + BNX_BOOL keyUp; + BNX_BOOL keyDown; + BNX_BOOL keyLeft; + BNX_BOOL keyRight; + BNX_BOOL keyAltUp; + BNX_BOOL keyAltDown; + BNX_BOOL keyAltLeft; + BNX_BOOL keyAltRight; + BNX_BOOL keyPageUp; + BNX_BOOL keyPageDown; + BNX_BOOL keyA; + BNX_BOOL keyB; + BNX_BOOL keyC; + BNX_BOOL keyQuit; + BNX_BOOL keyDel; + + BNX_BOOL mousePress; + BNX_INT16 mouseX; + BNX_INT16 mouseY; + + char letter; + + BNX_UINT32 moment; + +} BNX_INP; + +BNX_INP _Inp; + +/****************************************************************************** +FUNCTIONS +******************************************************************************/ + +BNX_BOOL inpInit(); + +void inpUpdate(); + +BNX_BOOL inpKeyLeft(); +BNX_BOOL inpKeyRight(); +BNX_BOOL inpKeyUp(); +BNX_BOOL inpKeyDown(); +BNX_BOOL inpKeyAltLeft(); +BNX_BOOL inpKeyAltRight(); +BNX_BOOL inpKeyAltUp(); +BNX_BOOL inpKeyAltDown(); +BNX_BOOL inpKeyPageUp(); +BNX_BOOL inpKeyPageDown(); +BNX_BOOL inpKeyA(); +BNX_BOOL inpKeyB(); +BNX_BOOL inpKeyC(); +BNX_BOOL inpKeyDel(); +BNX_BOOL inpExit(); + +char inpGetChar(); + +BNX_INP *inpDirect(); + + +#endif diff --git a/project/jni/application/biniax2/src/lev.h b/project/jni/application/biniax2/src/lev.h new file mode 100644 index 000000000..5a80bd48c --- /dev/null +++ b/project/jni/application/biniax2/src/lev.h @@ -0,0 +1,174 @@ +/****************************************************************************** +BINIAX 2 LEVEL DEFINITIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2006-2007 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +#ifndef _BNX_LEV_H +#define _BNX_LEV_H + +#include "types.h" +#include "game.h" + +#define cLinesPart01 3 +#define cLinesPart02 3 +#define cLinesPart03 4 +#define cLinesPart04 4 +#define cLinesPart05 6 +#define cLinesPart06 6 +#define cLinesPart07 6 +#define cLinesPart08 6 +#define cLinesPart09 4 +#define cLinesPart10 5 +#define cLinesPart11 5 +#define cLinesPart12 5 +#define cLinesPart13 10 +#define cLinesPart14 10 +#define cLinesAll cLinesPart01+cLinesPart02+cLinesPart03+cLinesPart04+cLinesPart05+\ + cLinesPart06+cLinesPart07+cLinesPart08+cLinesPart09+cLinesPart10+\ + cLinesPart11+cLinesPart12+cLinesPart13+cLinesPart14 + +#define cMaxLevels 14 /* All possibe levels */ +#define cMaxLevelsTurn 6 /* First N levels suitable for tactic mode */ +#define cMaxLevelsMulti 10 /* First N levels suitable for multiplayer */ +#define cStartLevelsAfter 100 /* Start the levels after 100 lines scroll */ +#define cNextLevelAt 30 /* Insert level at each N lines of scroll */ +#define cLevelInactive -1 /* Inacive value for all meanings */ + +static BNX_INT16 BNX_LEVEL_INFO[] = { cLinesPart01, cLinesPart02, cLinesPart03, + cLinesPart04, cLinesPart05, cLinesPart06, + cLinesPart07, cLinesPart08, cLinesPart09, + cLinesPart10, cLinesPart11, cLinesPart12, + cLinesPart13, cLinesPart13, cLinesPart14 + }; + +static char BNX_LEVEL[ cLinesAll ][ cGridX ] = +{ + // level 1 - 3 lines + { 0,1,0,1,0 }, + { 0,0,0,0,0 }, + { 1,0,0,0,1 }, + + // level 2 - 3 lines + { 0,1,0,0,0 }, + { 0,0,1,0,0 }, + { 0,0,0,1,0 }, + + // level 3 - 4 lines + { 1,0,0,0,1 }, + { 1,0,1,0,1 }, + { 1,0,0,0,1 }, + { 1,0,0,0,1 }, + + // level 4 - 4 lines + { 0,1,0,0,0 }, + { 0,0,0,1,0 }, + { 0,1,0,0,0 }, + { 0,0,0,1,0 }, + + // level 5 - 6 lines + { 1,0,0,0,1 }, + { 1,0,0,0,1 }, + { 0,0,0,0,0 }, + { 0,0,0,0,0 }, + { 0,1,0,1,0 }, + { 0,1,0,1,0 }, + + // level 6 - 6 lines + { 1,0,0,0,0 }, + { 0,0,0,1,1 }, + { 0,1,0,0,0 }, + { 0,0,0,1,1 }, + { 1,0,0,0,0 }, + { 0,0,0,1,1 }, + + // level 7 - 6 lines + { 0,1,0,1,0 }, + { 0,1,0,1,0 }, + { 0,0,0,1,0 }, + { 0,0,0,1,0 }, + { 0,1,0,0,0 }, + { 0,1,0,0,0 }, + + // level 8 - 6 lines + { 1,0,1,0,1 }, + { 1,0,0,0,1 }, + { 0,0,0,0,0 }, + { 0,1,0,1,0 }, + { 0,0,0,0,0 }, + { 1,0,1,0,1 }, + + // level 9 - 4 lines + { 0,0,1,0,0 }, + { 0,1,0,1,0 }, + { 0,1,0,1,0 }, + { 0,0,1,0,0 }, + + // level 10 - 5 lines + { 0,0,0,0,0 }, + { 0,0,1,0,0 }, + { 0,1,1,1,0 }, + { 0,0,1,0,0 }, + { 0,0,0,0,0 }, + + // level 11 - 5 lines + { 0,1,0,1,0 }, + { 0,0,1,0,0 }, + { 0,0,0,1,0 }, + { 0,0,1,0,0 }, + { 0,1,0,0,0 }, + + // level 12 - 5 lines + { 0,1,0,1,0 }, + { 0,0,0,0,0 }, + { 1,1,0,1,1 }, + { 0,0,0,0,0 }, + { 0,0,1,0,0 }, + + // level 13 - 10 lines + { 1,0,0,0,1 }, + { 0,1,0,1,0 }, + { 0,1,0,1,0 }, + { 0,0,0,0,0 }, + { 0,0,1,0,0 }, + { 0,0,1,0,0 }, + { 0,0,0,0,0 }, + { 0,1,0,1,0 }, + { 0,1,0,1,0 }, + { 1,0,0,0,1 }, + + // level 14 - 10 lines + { 0,0,1,0,0 }, + { 1,1,1,0,0 }, + { 0,0,0,0,0 }, + { 0,0,1,1,0 }, + { 0,0,1,0,0 }, + { 0,0,1,0,0 }, + { 1,0,1,0,0 }, + { 1,0,0,0,0 }, + { 1,1,0,1,1 }, + { 1,1,0,1,1 }, + +}; + +#endif \ No newline at end of file diff --git a/project/jni/application/biniax2/src/snd.c b/project/jni/application/biniax2/src/snd.c new file mode 100644 index 000000000..cf4178031 --- /dev/null +++ b/project/jni/application/biniax2/src/snd.c @@ -0,0 +1,151 @@ +/****************************************************************************** +BINIAX SOUND-RELATED IMPLEMENTATIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2009 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include +#include + +#include "inc.h" + +/****************************************************************************** +LOCALS +******************************************************************************/ + +BNX_SND _Snd; + +/****************************************************************************** +FUNCTIONS +******************************************************************************/ + +BNX_BOOL sndInit() +{ + BNX_INT32 audio_rate = 44000; + BNX_UINT16 audio_format = AUDIO_S16; + BNX_INT32 audio_channels = 2; + BNX_BOOL loaded = BNX_TRUE; + + if ( Mix_OpenAudio( audio_rate, audio_format, audio_channels, 1024 ) < 0 ) + { + cfgSetMusic( BNX_FALSE ); + cfgSetSound( BNX_FALSE ); + return BNX_TRUE; + } + else + { + Mix_QuerySpec( &audio_rate, &audio_format, &audio_channels ); + } + + Mix_VolumeMusic( MIX_MAX_VOLUME >> 1 ); + + _Snd.sounds[ 1 ] = Mix_LoadWAV( "data/sound/sfx1.wav" ); + _Snd.sounds[ 2 ] = Mix_LoadWAV( "data/sound/sfx2.wav" ); + _Snd.sounds[ 3 ] = Mix_LoadWAV( "data/sound/sfx3.wav" ); + _Snd.sounds[ 4 ] = Mix_LoadWAV( "data/sound/sfx4.wav" ); + _Snd.sounds[ 5 ] = Mix_LoadWAV( "data/sound/sfx5.wav" ); + + _Snd.music[ 0 ] = Mix_LoadMUS( "data/music/biniax_common00.it" ); + _Snd.music[ 1 ] = Mix_LoadMUS( "data/music/biniax_common01.it" ); + _Snd.music[ 2 ] = Mix_LoadMUS( "data/music/biniax_common02.it" ); + _Snd.music[ 3 ] = Mix_LoadMUS( "data/music/biniax_common03.it" ); + _Snd.music[ 4 ] = Mix_LoadMUS( "data/music/biniax_common04.it" ); + _Snd.music[ 5 ] = Mix_LoadMUS( "data/music/biniax_common05.it" ); + _Snd.music[ 6 ] = Mix_LoadMUS( "data/music/biniax_common06.it" ); + _Snd.music[ 7 ] = Mix_LoadMUS( "data/music/biniax_common07.it" ); + + return loaded; +} + +void sndUpdate() +{ + return; +} + +void sndPlay( BNX_GAME *game ) +{ + BNX_UINT32 snd = 0; + BNX_UINT32 sndmask = 1; + + if ( cfgGetSound() == BNX_FALSE ) + { + return; + } + + while ( game->sounds != cSndNone && snd <= cSndLast ) + { + sndmask = 1 << snd; + if ( (game->sounds & sndmask) != cSndNone ) + { + if ( _Snd.sounds[ snd ] != NULL ) + { + Mix_PlayChannel( snd % cSndChannels, _Snd.sounds[ snd ], 0 ); + } + } + game->sounds &= ~sndmask; + snd ++; + } +} + +void sndPlayMusic( BNX_INT16 index ) +{ + if ( cfgGetMusic() == BNX_FALSE ) + { + return; + } + + if ( index >= 0 && index < cSndMaxMusic ) + { + _Snd.curMusic = index; + Mix_PlayMusic( _Snd.music[ index ], 1 ); + } +} + +void sndUpdateMusic( BNX_GAME *game, BNX_BOOL change ) +{ + BNX_INT32 newMusic; + + if ( cfgGetMusic() == BNX_FALSE ) + { + return; + } + + if ( Mix_PlayingMusic() == 0 ) + { + if ( change == BNX_TRUE ) + { + do + { + newMusic = sysRand( cSndMaxMusic-1 ); + } while( _Snd.curMusic == newMusic ); + + _Snd.curMusic = newMusic; + } + + sndPlayMusic( _Snd.curMusic ); + } +} diff --git a/project/jni/application/biniax2/src/snd.h b/project/jni/application/biniax2/src/snd.h new file mode 100644 index 000000000..459b0685f --- /dev/null +++ b/project/jni/application/biniax2/src/snd.h @@ -0,0 +1,84 @@ +/****************************************************************************** +BINIAX SOUND-RELATED DEFINITIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2007 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +#ifndef _BNX_SND_H +#define _BNX_SND_H + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include + +#include "inc.h" + +/****************************************************************************** +CONSTANTS +******************************************************************************/ + +#define cSndChannels 8 +#define cSndMaxMusic 8 +#define cSndMenu 7 + +enum _BNX_Sounds { + cSndNone = 0, + cSndTake, + cSndFail, + cSndScroll, + cSndShake, + cSndSweep, + cSndLast, +}; + +/****************************************************************************** +LOCAL SOUND DATA (WAV SAMPLES, ETC.) +******************************************************************************/ + +typedef struct BNX_SND { + + BNX_INT32 curMusic; + Mix_Chunk *sounds[ cSndLast ]; + Mix_Music *music[ cSndMaxMusic ]; + +} BNX_SND; + +/****************************************************************************** +FUNCTIONS +******************************************************************************/ + +BNX_BOOL sndInit(); + +void sndUpdate(); + +void sndPlay( BNX_GAME *game ); + +void sndPlayMusic( BNX_INT16 index ); + +void sndUpdateMusic( BNX_GAME *game, BNX_BOOL change ); + +//void sndPlay( BNX_INT16 index ); + +#endif diff --git a/project/jni/application/biniax2/src/sys.c b/project/jni/application/biniax2/src/sys.c new file mode 100644 index 000000000..05dfc1e7f --- /dev/null +++ b/project/jni/application/biniax2/src/sys.c @@ -0,0 +1,135 @@ +/****************************************************************************** +BINIAX SYSTEM-RELATED IMPLEMENTATIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2009 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include + +#include "inc.h" + +/****************************************************************************** +FUNCTIONS +******************************************************************************/ + +BNX_BOOL sysInit() +{ + atexit( SDL_Quit ); + sysRandInit( sysGetTime() ); + + return BNX_TRUE; +} + +BNX_INT32 sysRand( BNX_INT32 max ) +{ + return ( BNX_INT32 ) rand() % max; +} + +void sysRandInit( BNX_UINT32 init ) +{ + srand( init ); +} + +BNX_UINT32 sysGetTime() +{ + return ( BNX_UINT32 ) SDL_GetTicks(); +} + +char* sysGetFullFileName( char *file ) +{ + return (char *) file; +} + +void sysUpdate() +{ + SDL_Delay( 1 ); +} + +/****************************************************************************** +FILE FUNCTIONS +******************************************************************************/ + +BNX_UINT32 sysGetFileLen( char *file ) +{ + BNX_UINT32 len = 0; + FILE *f; + + f = fopen( file, "rb" ); + if ( f == (FILE *) NULL ) + return 0; + while( !feof( f ) ) + { + fgetc( f ); + ++len; + } + fclose( f ); + return len-1; +} + +void sysFPut8( BNX_UINT8 n, FILE *f ) +{ + fputc( n, f ); +} + +void sysFPut16( BNX_UINT16 n, FILE *f ) +{ + fputc( (char) (n & 0xff), f ); + fputc( (char) (n >> 8), f ); +} + +void sysFPut32( BNX_UINT32 n, FILE *f ) +{ + fputc( (char) (n & 0xff), f ); + fputc( (char) ((n >> 8) & 0xff), f ); + fputc( (char) ((n >> 16) & 0xff), f ); + fputc( (char) ((n >> 24) & 0xff), f ); +} + +BNX_UINT8 sysFGet8( FILE *f ) +{ + BNX_INT8 n = 0; + n = fgetc( f ); + return n; +} + +BNX_UINT16 sysFGet16( FILE *f ) +{ + BNX_UINT16 n = 0; + n = (BNX_UINT16) fgetc( f ); + n |= (BNX_UINT16) fgetc( f ) << 8; + return n; +} + +BNX_UINT32 sysFGet32( FILE *f ) +{ + BNX_UINT32 n = 0; + n = (BNX_UINT32) fgetc( f ); + n |= (BNX_UINT32) fgetc( f ) << 8; + n |= (BNX_UINT32) fgetc( f ) << 16; + n |= (BNX_UINT32) fgetc( f ) << 24; + return n; +} diff --git a/project/jni/application/biniax2/src/sys.h b/project/jni/application/biniax2/src/sys.h new file mode 100644 index 000000000..67cf4c908 --- /dev/null +++ b/project/jni/application/biniax2/src/sys.h @@ -0,0 +1,87 @@ +/****************************************************************************** +BINIAX SYSTEM-RELATED DEFINITIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2009 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +#ifndef _BNX_SYS_H +#define _BNX_SYS_H + +/****************************************************************************** +INCLUDES +******************************************************************************/ + +#include "inc.h" + +/****************************************************************************** +MACRO +******************************************************************************/ + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define NORM16(X) (X) +#define NORM32(X) (X) +#else +#define NORM16(X) SDL_Swap16(X) +#define NORM32(X) SDL_Swap32(X) +#endif + +/****************************************************************************** +FUNCTIONS +******************************************************************************/ + +BNX_BOOL sysInit(); + +BNX_INT32 sysRand( BNX_INT32 max ); + +void sysRandInit( BNX_UINT32 init ); + +BNX_UINT32 sysGetTime(); + +char* sysGetFullFileName( char *file ); + +void sysUpdate(); + +/****************************************************************************** +FILE FUNCIONS +******************************************************************************/ + +BNX_UINT32 sysGetFileLen( char *file ); + +void sysFPut8( BNX_UINT8 n, FILE *f ); +void sysFPut16( BNX_UINT16 n, FILE *f ); +void sysFPut32( BNX_UINT32 n, FILE *f ); + +BNX_UINT8 sysFGet8( FILE *f ); +BNX_UINT16 sysFGet16( FILE *f ); +BNX_UINT32 sysFGet32( FILE *f ); + +/* File allignemt macro */ +#define sysFPut1byte(F) {sysFPut8(0,(F));} +#define sysFPut2byte(F) {sysFPut8(0,(F));sysFPut8(0,(F));} +#define sysFPut3byte(F) {sysFPut8(0,(F));sysFPut8(0,(F));sysFPut8(0,(F));} + +#define sysFGet1byte(F) {sysFGet8(F);} +#define sysFGet2byte(F) {sysFGet8(F);sysFGet8(F);} +#define sysFGet3byte(F) {sysFGet8(F);sysFGet8(F);sysFGet8(F);} + +#endif diff --git a/project/jni/application/biniax2/src/txt.h b/project/jni/application/biniax2/src/txt.h new file mode 100644 index 000000000..33914004a --- /dev/null +++ b/project/jni/application/biniax2/src/txt.h @@ -0,0 +1,63 @@ +/****************************************************************************** +BINIAX 2 TEXT MESSAGES +COPYRIGHT JORDAN TUZSUZOV, (C) 2006-2007 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +#ifndef _BNX_TXT_H +#define _BNX_TXT_H + +#include "game.h" + +char *TXT_HofCase[] = { + "BEST ARCADE SCORES", + "BEST TACTIC SCORES" +}; + +char *TXT_MenuMain[ cMaxOptions ] = { + "CONTINUE LAST GAME", + "NEW ARCADE GAME", + "NEW TACTIC GAME", + "MULTIPLAYER", + "HALL OF FAME", + "HELP", + "EXIT" +}; + +char *TXT_MenuMulti[ cMaxOptions ] = { + "SAME MACHINE MULTIPLAYER", + "START NETWORK GAME", + "JOIN NETWORK GAME", + "BACK" +}; + +char *TXT_Extras[ cMaxExtras ] = { + "MINOR COMBO +5", + "COMBO +10", + "BIG COMBO +20", + "MEGA COMBO +40", + "FIELD MASTERED +100", + "NEW BROOM", +}; + +#endif \ No newline at end of file diff --git a/project/jni/application/biniax2/src/types.h b/project/jni/application/biniax2/src/types.h new file mode 100644 index 000000000..1364754fc --- /dev/null +++ b/project/jni/application/biniax2/src/types.h @@ -0,0 +1,54 @@ +/****************************************************************************** +BINIAX TYPE DEFINITIONS +COPYRIGHT JORDAN TUZSUZOV, (C) 2005-2007 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +LICENSE ORIGIN : http://www.gzip.org/zlib/zlib_license.html + +For complete product license refer to LICENSE.TXT file + +******************************************************************************/ + +#ifndef _BNX_TYPES_H +#define _BNX_TYPES_H + +/****************************************************************************** +UNSIGNED TYPES +******************************************************************************/ + +typedef unsigned char BNX_UINT8; +typedef unsigned short int BNX_UINT16; +typedef unsigned int BNX_UINT32; + +/****************************************************************************** +SIGNED TYPES +******************************************************************************/ + +typedef char BNX_INT8; +typedef short int BNX_INT16; +typedef int BNX_INT32; + +/****************************************************************************** +LOGICAL TYPES +******************************************************************************/ + +typedef char BNX_BOOL; +#define BNX_TRUE 1 +#define BNX_FALSE 0 + +#endif diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h index 206223297..6a92df5f2 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h +++ b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h @@ -134,10 +134,10 @@ extern int SDL_ANDROID_isTouchscreenKeyboardUsed; #define SDL_ANDROID_KEYCODE_1 END #endif #ifndef SDL_ANDROID_KEYCODE_2 -#define SDL_ANDROID_KEYCODE_2 PAGEUP +#define SDL_ANDROID_KEYCODE_2 NO_REMAP #endif #ifndef SDL_ANDROID_KEYCODE_3 -#define SDL_ANDROID_KEYCODE_3 PAGEDOWN +#define SDL_ANDROID_KEYCODE_3 NO_REMAP #endif #ifndef SDL_ANDROID_KEYCODE_4 #define SDL_ANDROID_KEYCODE_4 LCTRL @@ -166,10 +166,10 @@ extern int SDL_ANDROID_isTouchscreenKeyboardUsed; #define SDL_ANDROID_SCREENKB_KEYCODE_1 SDL_ANDROID_KEYCODE_1 #endif #ifndef SDL_ANDROID_SCREENKB_KEYCODE_2 -#define SDL_ANDROID_SCREENKB_KEYCODE_2 SDL_ANDROID_KEYCODE_2 +#define SDL_ANDROID_SCREENKB_KEYCODE_2 PAGEUP #endif #ifndef SDL_ANDROID_SCREENKB_KEYCODE_3 -#define SDL_ANDROID_SCREENKB_KEYCODE_3 SDL_ANDROID_KEYCODE_3 +#define SDL_ANDROID_SCREENKB_KEYCODE_3 PAGEDOWN #endif #ifndef SDL_ANDROID_SCREENKB_KEYCODE_4 #define SDL_ANDROID_SCREENKB_KEYCODE_4 SDL_ANDROID_KEYCODE_6