2007-01-14 21:29:12 +00:00
/* ScummVM - Scumm Interpreter
* Copyright ( C ) 2006 The ScummVM project
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
* $ URL $
* $ Id $
*
*/
# include "parallaction/disk.h"
# include "parallaction/parallaction.h"
# include "parallaction/graphics.h"
# include "parallaction/inventory.h"
# include "parallaction/menu.h"
# include "parallaction/music.h"
# include "parallaction/zone.h"
# include "common/file.h"
namespace Parallaction {
static Zone * _moveSarcZones [ 5 ] ;
static Zone * _moveSarcExaZones [ 5 ] ;
void _c_null ( void * parm ) {
return ;
}
void _c_play_boogie ( void * parm ) {
static uint16 flag = 1 ;
2007-02-17 15:37:49 +00:00
if ( flag = = 0 )
return ;
2007-01-14 21:29:12 +00:00
flag = 0 ;
2007-02-21 21:42:37 +00:00
_vm - > _midiPlayer - > play ( " boogie2 " ) ;
2007-01-14 21:29:12 +00:00
return ;
}
void _c_score ( void * parm ) {
_score + = 5 ;
return ;
}
void _c_fade ( void * parm ) {
byte palette [ PALETTE_SIZE ] ;
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > getBlackPalette ( palette ) ;
_vm - > _gfx - > setPalette ( palette ) ;
2007-01-14 21:29:12 +00:00
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > swapBuffers ( ) ;
2007-01-14 21:29:12 +00:00
for ( uint16 _di = 0 ; _di < 64 ; _di + + ) {
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > fadePalette ( palette ) ;
_vm - > _gfx - > setPalette ( palette ) ;
2007-01-14 21:29:12 +00:00
}
_vm - > waitTime ( 1 ) ;
return ;
}
Zone * _moveSarcZone0 = NULL ;
int16 _introSarcData1 = 0 ;
Zone * _moveSarcZone1 = NULL ;
void _c_moveSarc ( void * parm ) {
Animation * a ;
if ( _introSarcData2 ! = 0 ) {
_introSarcData2 = 0 ;
if ( _moveSarcZones [ 0 ] = = NULL ) {
2007-03-18 19:35:54 +00:00
_moveSarcZones [ 0 ] = _vm - > findZone ( " sarc1 " ) ;
_moveSarcZones [ 1 ] = _vm - > findZone ( " sarc2 " ) ;
_moveSarcZones [ 2 ] = _vm - > findZone ( " sarc3 " ) ;
_moveSarcZones [ 3 ] = _vm - > findZone ( " sarc4 " ) ;
_moveSarcZones [ 4 ] = _vm - > findZone ( " sarc5 " ) ;
_moveSarcExaZones [ 0 ] = _vm - > findZone ( " sarc1exa " ) ;
_moveSarcExaZones [ 1 ] = _vm - > findZone ( " sarc2exa " ) ;
_moveSarcExaZones [ 2 ] = _vm - > findZone ( " sarc3exa " ) ;
_moveSarcExaZones [ 3 ] = _vm - > findZone ( " sarc4exa " ) ;
_moveSarcExaZones [ 4 ] = _vm - > findZone ( " sarc5exa " ) ;
2007-01-14 21:29:12 +00:00
}
2007-03-18 19:35:54 +00:00
a = _vm - > findAnimation ( " sposta " ) ;
2007-01-14 21:29:12 +00:00
_moveSarcZone1 = ( Zone * ) parm ;
for ( uint16 _si = 0 ; _si < 5 ; _si + + ) {
if ( _moveSarcZones [ _si ] = = _moveSarcZone1 ) {
_moveSarcZone0 = _moveSarcExaZones [ _si ] ;
}
}
2007-03-17 19:48:48 +00:00
_introSarcData1 = _introSarcData3 - _moveSarcZone1 - > _left ;
2007-01-14 21:29:12 +00:00
a - > _z = _introSarcData3 ;
2007-03-17 19:48:48 +00:00
a - > _frame = _moveSarcZone1 - > _top - ( _introSarcData1 / 20 ) ;
_introSarcData3 = _moveSarcZone1 - > _left ;
2007-01-14 21:29:12 +00:00
if ( _introSarcData1 > 0 ) {
2007-03-19 21:49:41 +00:00
a - > _left = _introSarcData1 / 2 ;
2007-01-14 21:29:12 +00:00
} else {
2007-03-19 21:49:41 +00:00
a - > _left = - _introSarcData1 / 2 ;
2007-01-14 21:29:12 +00:00
}
if ( _introSarcData1 > 0 ) {
2007-03-19 21:49:41 +00:00
a - > _top = 2 ;
2007-01-14 21:29:12 +00:00
} else {
2007-03-19 21:49:41 +00:00
a - > _top = - 2 ;
2007-01-14 21:29:12 +00:00
}
return ;
}
_introSarcData2 = 1 ;
2007-03-17 21:06:19 +00:00
_moveSarcZone1 - > translate ( _introSarcData1 , - _introSarcData1 / 20 ) ;
_moveSarcZone0 - > translate ( _introSarcData1 , - _introSarcData1 / 20 ) ;
2007-01-14 21:29:12 +00:00
2007-03-17 19:48:48 +00:00
if ( _moveSarcZones [ 0 ] - > _left = = 35 & &
_moveSarcZones [ 1 ] - > _left = = 68 & &
_moveSarcZones [ 2 ] - > _left = = 101 & &
_moveSarcZones [ 3 ] - > _left = = 134 & &
_moveSarcZones [ 4 ] - > _left = = 167 ) {
2007-01-14 21:29:12 +00:00
2007-03-18 19:35:54 +00:00
a = _vm - > findAnimation ( " finito " ) ;
2007-01-14 21:29:12 +00:00
2007-03-19 21:49:41 +00:00
a - > _flags | = ( kFlagsActive | kFlagsActing ) ;
2007-02-18 10:32:15 +00:00
_localFlags [ _vm - > _currentLocationIndex ] | = 0x20 ; // GROSS HACK: activates 'finito' flag in dinoit_museo.loc
2007-01-14 21:29:12 +00:00
}
return ;
}
static uint16 num_foglie = 0 ;
void _c_contaFoglie ( void * parm ) {
num_foglie + + ;
2007-02-17 15:37:49 +00:00
if ( num_foglie ! = 6 )
return ;
2007-01-14 21:29:12 +00:00
_commandFlags | = 0x1000 ;
return ;
}
void _c_zeroFoglie ( void * parm ) {
num_foglie = 0 ;
return ;
}
void _c_trasformata ( void * parm ) {
2007-03-10 22:56:32 +00:00
_engineFlags ^ = kEngineTransformedDonna ;
2007-01-14 21:29:12 +00:00
return ;
}
void _c_offMouse ( void * parm ) {
_mouseHidden = 1 ;
_engineFlags | = kEngineMouse ;
return ;
}
void _c_onMouse ( void * parm ) {
_engineFlags & = ~ kEngineMouse ;
_mouseHidden = 0 ;
return ;
}
void _c_setMask ( void * parm ) {
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > intGrottaHackMask ( ) ;
2007-01-14 21:29:12 +00:00
return ;
}
void _c_endComment ( void * parm ) {
}
void _c_frankenstein ( void * parm ) {
byte pal0 [ PALETTE_SIZE ] , pal1 [ PALETTE_SIZE ] ;
for ( uint16 i = 0 ; i < = PALETTE_COLORS ; i + + ) {
2007-03-15 21:56:21 +00:00
pal0 [ i ] = _vm - > _gfx - > _palette [ i ] ;
2007-01-14 21:29:12 +00:00
pal0 [ i * 3 + 1 ] = 0 ;
pal0 [ i * 3 + 2 ] = 0 ;
}
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > getBlackPalette ( pal1 ) ;
2007-01-14 21:29:12 +00:00
for ( uint16 _di = 0 ; _di < 30 ; _di + + ) {
g_system - > delayMillis ( 20 ) ;
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > setPalette ( pal0 ) ;
2007-01-14 21:29:12 +00:00
g_system - > delayMillis ( 20 ) ;
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > setPalette ( pal1 ) ;
2007-01-14 21:29:12 +00:00
}
2007-03-15 21:56:21 +00:00
_vm - > _gfx - > setPalette ( _vm - > _gfx - > _palette ) ;
2007-01-14 21:29:12 +00:00
return ;
}
// part completion messages
const char * endMsg0 [ ] = { " COMPLIMENTI! " , " BRAVO! " , " CONGRATULATIONS! " , " PRIMA! " } ;
const char * endMsg1 [ ] = { " HAI FINITO QUESTA PARTE " , " TU AS COMPLETE' CETTE AVENTURE " , " YOU HAVE COMPLETED THIS PART " , " DU HAST EIN ABENTEUER ERFOLGREICH " } ;
const char * endMsg2 [ ] = { " ORA COMPLETA IL RESTO " , " AVEC SUCCES. " , " NOW GO ON WITH THE REST OF " , " ZU ENDE GEFUHRT " } ;
const char * endMsg3 [ ] = { " DELL' AVVENTURA " , " CONTINUE AVEC LES AUTRES " , " THIS ADVENTURE " , " MACH' MIT DEN ANDEREN WEITER " } ;
// game completion messages
const char * endMsg4 [ ] = { " COMPLIMENTI! " , " BRAVO! " , " CONGRATULATIONS! " , " PRIMA! " } ;
const char * endMsg5 [ ] = { " HAI FINITO LE TRE PARTI " , " TU AS COMPLETE' LES TROIS PARTIES " , " YOU HAVE COMPLETED THE THREE PARTS " , " DU HAST DREI ABENTEURE ERFOLGREICH " } ;
const char * endMsg6 [ ] = { " DELL' AVVENTURA " , " DE L'AVENTURE " , " OF THIS ADVENTURE " , " ZU ENDE GEFUHRT " } ;
const char * endMsg7 [ ] = { " ED ORA IL GRAN FINALE " , " ET MAINTENANT LE GRAND FINAL " , " NOW THE GREAT FINAL " , " UND YETZT DER GROSSE SCHLUSS! " } ;
void _c_finito ( void * parm ) {
const char * * v8C = endMsg0 ;
const char * * v7C = endMsg1 ;
const char * * v6C = endMsg2 ;
const char * * v5C = endMsg3 ;
const char * * v4C = endMsg4 ;
const char * * v3C = endMsg5 ;
const char * * v2C = endMsg6 ;
const char * * v1C = endMsg7 ;
Common : : File stream ;
stream . open ( _vm - > _characterName , Common : : File : : kFileWriteMode ) ;
2007-02-17 15:37:49 +00:00
if ( stream . isOpen ( ) )
stream . close ( ) ;
2007-01-14 21:29:12 +00:00
Common : : File streamDino , streamDough , streamDonna ;
streamDino . open ( " dino " ) ;
streamDough . open ( " dough " ) ;
streamDonna . open ( " donna " ) ;
bool gameCompleted = streamDino . isOpen ( ) & & streamDough . isOpen ( ) & & streamDonna . isOpen ( ) ;
streamDino . close ( ) ;
streamDough . close ( ) ;
streamDonna . close ( ) ;
cleanInventory ( ) ;
refreshInventory ( _vm - > _characterName ) ;
2007-03-15 21:56:21 +00:00
_vm - > _gfx - > palUnk0 ( _vm - > _gfx - > _palette ) ;
2007-01-14 21:29:12 +00:00
if ( gameCompleted ) {
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > setFont ( " slide " ) ;
_vm - > _gfx - > _proportionalFont = false ;
uint16 _ax = _vm - > _gfx - > getStringWidth ( v4C [ _language ] ) ;
_vm - > _gfx - > displayString ( ( SCREEN_WIDTH - _ax ) / 2 , 70 , v4C [ _language ] ) ;
_ax = _vm - > _gfx - > getStringWidth ( v3C [ _language ] ) ;
_vm - > _gfx - > displayString ( ( SCREEN_WIDTH - _ax ) / 2 , 100 , v3C [ _language ] ) ;
_ax = _vm - > _gfx - > getStringWidth ( v2C [ _language ] ) ;
_vm - > _gfx - > displayString ( ( SCREEN_WIDTH - _ax ) / 2 , 130 , v2C [ _language ] ) ;
_ax = _vm - > _gfx - > getStringWidth ( v1C [ _language ] ) ;
_vm - > _gfx - > displayString ( ( SCREEN_WIDTH - _ax ) / 2 , 160 , v1C [ _language ] ) ;
_vm - > _gfx - > copyScreen ( Gfx : : kBitFront , Gfx : : kBitBack ) ;
_vm - > _gfx - > copyScreen ( Gfx : : kBitFront , Gfx : : kBit2 ) ;
2007-01-14 21:29:12 +00:00
waitUntilLeftClick ( ) ;
2007-03-11 14:14:08 +00:00
strcpy ( _vm - > _location . _name , " estgrotta.drki " ) ;
2007-01-14 21:29:12 +00:00
_engineFlags | = kEngineChangeLocation ;
} else {
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > setFont ( " slide " ) ;
_vm - > _gfx - > _proportionalFont = false ;
uint16 _ax = _vm - > _gfx - > getStringWidth ( v8C [ _language ] ) ;
_vm - > _gfx - > displayString ( ( SCREEN_WIDTH - _ax ) / 2 , 70 , v8C [ _language ] ) ;
_ax = _vm - > _gfx - > getStringWidth ( v7C [ _language ] ) ;
_vm - > _gfx - > displayString ( ( SCREEN_WIDTH - _ax ) / 2 , 100 , v7C [ _language ] ) ;
_ax = _vm - > _gfx - > getStringWidth ( v6C [ _language ] ) ;
_vm - > _gfx - > displayString ( ( SCREEN_WIDTH - _ax ) / 2 , 130 , v6C [ _language ] ) ;
_ax = _vm - > _gfx - > getStringWidth ( v5C [ _language ] ) ;
_vm - > _gfx - > displayString ( ( SCREEN_WIDTH - _ax ) / 2 , 160 , v5C [ _language ] ) ;
_vm - > _gfx - > copyScreen ( Gfx : : kBitFront , Gfx : : kBitBack ) ;
_vm - > _gfx - > copyScreen ( Gfx : : kBitFront , Gfx : : kBit2 ) ;
2007-01-14 21:29:12 +00:00
waitUntilLeftClick ( ) ;
_vm - > _menu - > selectCharacter ( ) ;
}
2007-03-19 21:49:41 +00:00
removeNode ( & _vm - > _char . _ani ) ;
2007-01-14 21:29:12 +00:00
_vm - > _locationNames [ 0 ] [ 0 ] = ' \0 ' ;
_vm - > _numLocations = 0 ;
_commandFlags = 0 ;
_engineFlags | = kEngineQuit ;
2007-03-18 19:35:54 +00:00
_vm - > freeZones ( _vm - > _zones . _next ) ;
freeNodeList ( _vm - > _zones . _next ) ;
_vm - > _zones . _next = NULL ;
2007-01-14 21:29:12 +00:00
2007-03-18 19:35:54 +00:00
_vm - > freeZones ( _vm - > _animations . _next ) ;
freeNodeList ( _vm - > _animations . _next ) ;
_vm - > _animations . _next = NULL ;
2007-01-14 21:29:12 +00:00
_engineFlags & = ~ kEngineQuit ;
2007-03-19 21:49:41 +00:00
addNode ( & _vm - > _animations , & _vm - > _char . _ani ) ;
2007-01-14 21:29:12 +00:00
_score = 0 ;
return ;
}
void _c_ridux ( void * parm ) {
2007-03-10 22:13:47 +00:00
_vm - > changeCharacter ( _minidinoName ) ;
2007-01-14 21:29:12 +00:00
return ;
}
void _c_testResult ( void * parm ) {
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > swapBuffers ( ) ;
2007-01-14 21:29:12 +00:00
_vm - > parseLocation ( " common " ) ;
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > setFont ( " slide " ) ;
_vm - > _gfx - > _proportionalFont = false ;
2007-01-14 21:29:12 +00:00
2007-03-12 20:41:25 +00:00
uint16 _ax = _vm - > _gfx - > getStringWidth ( _slideText [ 0 ] ) ;
_vm - > _gfx - > displayString ( ( SCREEN_WIDTH - _ax ) / 2 , 38 , _slideText [ 0 ] ) ;
_ax = _vm - > _gfx - > getStringWidth ( _slideText [ 1 ] ) ;
_vm - > _gfx - > displayString ( ( SCREEN_WIDTH - _ax ) / 2 , 58 , _slideText [ 1 ] ) ;
2007-01-14 21:29:12 +00:00
2007-03-12 20:41:25 +00:00
_vm - > _gfx - > copyScreen ( Gfx : : kBitFront , Gfx : : kBitBack ) ;
_vm - > _gfx - > copyScreen ( Gfx : : kBitFront , Gfx : : kBit2 ) ;
2007-01-14 21:29:12 +00:00
return ;
}
} // namespace Parallaction