2007-09-01 14:58:46 +00:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers , whose names
* are too numerous to list here . Please refer to the COPYRIGHT
* file distributed with this source distribution .
*
* 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 .
2014-02-18 01:34:17 +00:00
*
2007-09-01 14:58:46 +00:00
* 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 .
2014-02-18 01:34:17 +00:00
*
2007-09-01 14:58:46 +00:00
* 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 .
*
*/
2008-10-06 12:48:52 +00:00
# include "common/events.h"
2007-09-03 01:55:56 +00:00
# include "common/savefile.h"
2011-04-24 08:34:27 +00:00
# include "common/textconsole.h"
2007-09-01 18:46:55 +00:00
2007-09-04 06:54:40 +00:00
# include "graphics/cursorman.h"
2007-09-18 16:20:44 +00:00
# include "agi/preagi.h"
2007-09-01 14:58:46 +00:00
# include "agi/preagi_mickey.h"
# include "agi/graphics.h"
2007-09-01 18:46:55 +00:00
namespace Agi {
2011-08-15 15:22:26 +00:00
int MickeyEngine : : getDat ( int iRoom ) {
2007-09-01 18:46:55 +00:00
if ( ( ( iRoom > 0 ) & & ( iRoom < 24 ) ) | | iRoom = = 154 | | iRoom = = 155 ) return IDI_MSA_PLANET_EARTH ;
if ( ( iRoom > = 30 ) & & ( iRoom < = 39 ) ) return IDI_MSA_PLANET_VENUS ;
if ( ( iRoom > = 40 ) & & ( iRoom < = 69 ) ) return IDI_MSA_PLANET_NEPTUNE ;
if ( ( iRoom > = 70 ) & & ( iRoom < = 82 ) ) return IDI_MSA_PLANET_MERCURY ;
if ( ( iRoom > = 83 ) & & ( iRoom < = 92 ) ) return IDI_MSA_PLANET_SATURN ;
if ( ( iRoom > = 93 ) & & ( iRoom < = 103 ) ) return IDI_MSA_PLANET_PLUTO ;
if ( ( iRoom > = 106 ) & & ( iRoom < = 120 ) ) return IDI_MSA_PLANET_JUPITER ;
if ( ( iRoom > = 121 ) & & ( iRoom < = 132 ) ) return IDI_MSA_PLANET_MARS ;
if ( ( iRoom > = 133 ) & & ( iRoom < = 145 ) ) return IDI_MSA_PLANET_URANUS ;
return IDI_MSA_PLANET_SPACESHIP ;
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : readExe ( int ofs , uint8 * buffer , long buflen ) {
2007-09-01 18:46:55 +00:00
Common : : File infile ;
2009-01-18 16:41:35 +00:00
if ( ! infile . open ( " mickey.exe " ) )
2007-09-01 18:46:55 +00:00
return ;
infile . seek ( ofs , SEEK_SET ) ;
infile . read ( buffer , buflen ) ;
infile . close ( ) ;
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : getDatFileName ( int iRoom , char * szFile ) {
2007-09-01 18:46:55 +00:00
sprintf ( szFile , IDS_MSA_PATH_DAT , IDS_MSA_NAME_DAT [ getDat ( iRoom ) ] ) ;
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : readDatHdr ( char * szFile , MSA_DAT_HEADER * hdr ) {
2007-09-01 18:46:55 +00:00
Common : : File infile ;
if ( ! infile . open ( szFile ) )
return ;
hdr - > filelen = infile . readByte ( ) ;
hdr - > filelen + = infile . readByte ( ) * 0x100 ;
2007-09-21 20:06:57 +00:00
2007-09-01 18:46:55 +00:00
for ( int i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + ) {
hdr - > ofsRoom [ i ] = infile . readByte ( ) ;
hdr - > ofsRoom [ i ] + = infile . readByte ( ) * 0x100 ;
}
for ( int i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + ) {
hdr - > ofsDesc [ i ] = infile . readByte ( ) ;
hdr - > ofsDesc [ i ] + = infile . readByte ( ) * 0x100 ;
}
for ( int i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + ) {
hdr - > ofsStr [ i ] = infile . readByte ( ) ;
hdr - > ofsStr [ i ] + = infile . readByte ( ) * 0x100 ;
}
infile . close ( ) ;
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : readOfsData ( int offset , int iItem , uint8 * buffer , long buflen ) {
2007-09-01 18:46:55 +00:00
uint16 ofs [ 256 ] ;
readExe ( offset , buffer , buflen ) ;
2007-09-03 00:47:51 +00:00
memcpy ( ofs , buffer , sizeof ( ofs ) ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
for ( int i = 0 ; i < 256 ; i + + )
ofs [ i ] = buffer [ i * 2 ] + 256 * buffer [ i * 2 + 1 ] ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
readExe ( ofs [ iItem ] + IDI_MSA_OFS_EXE , buffer , buflen ) ;
}
// User Interface
2011-08-15 15:22:26 +00:00
bool MickeyEngine : : chooseY_N ( int ofsPrompt , bool fErrorMsg ) {
2007-09-01 18:46:55 +00:00
printExeStr ( ofsPrompt ) ;
2011-08-15 15:22:26 +00:00
while ( ! shouldQuit ( ) ) {
switch ( getSelection ( kSelYesNo ) ) {
2008-01-13 23:43:17 +00:00
case 0 : return false ;
case 1 : return true ;
default :
if ( fErrorMsg ) {
printExeStr ( IDO_MSA_PRESS_YES_OR_NO ) ;
waitAnyKey ( ) ;
printExeStr ( ofsPrompt ) ;
}
break ;
2007-09-01 18:46:55 +00:00
}
}
2009-05-24 15:17:42 +00:00
2009-01-05 01:40:08 +00:00
return false ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
int MickeyEngine : : choose1to9 ( int ofsPrompt ) {
2007-11-20 20:25:37 +00:00
int answer = 0 ;
2007-09-01 18:46:55 +00:00
printExeStr ( ofsPrompt ) ;
2011-08-15 15:22:26 +00:00
while ( ! shouldQuit ( ) ) {
answer = getSelection ( kSelNumber ) ;
2007-11-20 20:25:37 +00:00
if ( answer = = 10 ) {
2007-09-01 18:46:55 +00:00
printExeStr ( IDO_MSA_PRESS_1_TO_9 ) ;
2011-08-15 15:22:26 +00:00
if ( getSelection ( kSelAnyKey ) = = 0 )
2007-09-01 18:46:55 +00:00
return 0 ;
printExeStr ( ofsPrompt ) ;
2007-11-20 20:25:37 +00:00
} else return answer ;
2007-09-01 18:46:55 +00:00
}
2009-01-05 01:40:08 +00:00
return 0 ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : printStr ( char * buffer ) {
2007-09-01 18:46:55 +00:00
int pc = 1 ;
int nRows , iCol , iRow ;
2007-09-19 08:40:12 +00:00
2007-09-01 18:46:55 +00:00
nRows = * buffer + IDI_MSA_ROW_MENU_0 ;
2011-08-15 15:22:26 +00:00
clearTextArea ( ) ;
2007-09-01 18:46:55 +00:00
for ( iRow = IDI_MSA_ROW_MENU_0 ; iRow < nRows ; iRow + + ) {
iCol = * ( buffer + pc + + ) ;
2011-08-15 15:22:26 +00:00
drawStr ( iRow , iCol , IDA_DEFAULT , buffer + pc ) ;
2007-09-01 18:46:55 +00:00
pc + = strlen ( buffer + pc ) + 1 ;
}
2007-11-20 20:25:37 +00:00
// Show the string on screen
2016-01-29 12:13:40 +00:00
_gfx - > updateScreen ( ) ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : printLine ( const char * buffer ) {
clearTextArea ( ) ;
2009-01-18 16:41:35 +00:00
2011-08-15 15:22:26 +00:00
drawStr ( 22 , 18 - strlen ( buffer ) / 2 , IDA_DEFAULT , buffer ) ;
2009-01-18 16:41:35 +00:00
// Show the string on screen
2016-01-29 12:13:40 +00:00
_gfx - > updateScreen ( ) ;
2009-01-18 22:02:22 +00:00
waitAnyKey ( true ) ;
2009-01-18 16:41:35 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : printExeStr ( int ofs ) {
2007-09-01 18:46:55 +00:00
uint8 buffer [ 256 ] = { 0 } ;
if ( ! ofs )
return ;
readExe ( ofs , buffer , sizeof ( buffer ) ) ;
printStr ( ( char * ) buffer ) ;
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : printExeMsg ( int ofs ) {
2007-09-01 18:46:55 +00:00
if ( ! ofs )
return ;
2007-09-21 20:06:57 +00:00
2007-09-01 18:46:55 +00:00
printExeStr ( ofs ) ;
2007-11-20 20:25:37 +00:00
waitAnyKey ( true ) ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : printDatString ( int iStr ) {
2009-01-18 16:41:35 +00:00
char buffer [ 256 ] ;
2011-08-15 15:22:26 +00:00
int iDat = getDat ( _gameStateMickey . iRoom ) ;
2007-09-22 11:31:46 +00:00
MSA_DAT_HEADER hdr ;
char szFile [ 256 ] = { 0 } ;
sprintf ( szFile , IDS_MSA_PATH_DAT , IDS_MSA_NAME_DAT [ iDat ] ) ;
readDatHdr ( szFile , & hdr ) ;
Common : : File infile ;
if ( ! infile . open ( szFile ) )
return ;
infile . seek ( hdr . ofsStr [ iStr ] + IDI_MSA_OFS_DAT , SEEK_SET ) ;
infile . read ( ( uint8 * ) buffer , 256 ) ;
infile . close ( ) ;
2007-09-01 18:46:55 +00:00
printStr ( buffer ) ;
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : printDesc ( int iRoom ) {
2007-09-22 11:31:46 +00:00
MSA_DAT_HEADER hdr ;
char szFile [ 256 ] = { 0 } ;
getDatFileName ( iRoom , szFile ) ;
readDatHdr ( szFile , & hdr ) ;
Common : : File infile ;
if ( ! infile . open ( szFile ) )
return ;
2009-10-01 12:09:02 +00:00
char * buffer = ( char * ) malloc ( 256 ) ;
2007-09-22 11:31:46 +00:00
memset ( buffer , 0 , 256 ) ;
infile . seek ( hdr . ofsDesc [ iRoom - 1 ] + IDI_MSA_OFS_DAT , SEEK_SET ) ;
infile . read ( buffer , 256 ) ;
infile . close ( ) ;
2007-09-01 18:46:55 +00:00
printStr ( buffer ) ;
free ( buffer ) ;
}
2011-08-15 15:22:26 +00:00
bool MickeyEngine : : checkMenu ( ) {
2008-01-09 10:31:52 +00:00
MSA_MENU menu ;
int iSel0 , iSel1 ;
MSA_DAT_HEADER hdr ;
char szFile [ 256 ] = { 0 } ;
Common : : File infile ;
2011-08-15 15:22:26 +00:00
getDatFileName ( _gameStateMickey . iRoom , szFile ) ;
2008-01-09 10:31:52 +00:00
readDatHdr ( szFile , & hdr ) ;
if ( ! infile . open ( szFile ) )
return false ;
2009-10-01 12:09:02 +00:00
char * buffer = new char [ sizeof ( MSA_MENU ) ] ;
2011-08-15 15:22:26 +00:00
infile . seek ( hdr . ofsRoom [ _gameStateMickey . iRoom - 1 ] + IDI_MSA_OFS_DAT , SEEK_SET ) ;
2008-01-09 10:31:52 +00:00
infile . read ( ( uint8 * ) buffer , sizeof ( MSA_MENU ) ) ;
infile . close ( ) ;
memcpy ( & menu , buffer , sizeof ( MSA_MENU ) ) ;
patchMenu ( & menu ) ;
memcpy ( buffer , & menu , sizeof ( MSA_MENU ) ) ;
getMenuSel ( buffer , & iSel0 , & iSel1 ) ;
2008-05-07 14:31:45 +00:00
delete [ ] buffer ;
2008-01-09 10:31:52 +00:00
return parse ( menu . cmd [ iSel0 ] . data [ iSel1 ] , menu . arg [ iSel0 ] . data [ iSel1 ] ) ;
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : drawMenu ( MSA_MENU menu , int sel0 , int sel1 ) {
2007-09-01 18:46:55 +00:00
int iWord ;
int iRow ;
int sel ;
uint8 attr ;
// draw menu
2011-08-15 15:22:26 +00:00
clearTextArea ( ) ;
2007-09-01 18:46:55 +00:00
for ( iRow = 0 ; iRow < 2 ; iRow + + ) {
for ( iWord = 0 ; iWord < menu . row [ iRow ] . count ; iWord + + ) {
if ( iRow )
2007-09-19 08:40:12 +00:00
sel = sel1 ;
else
2007-09-01 18:46:55 +00:00
sel = sel0 ;
2007-09-19 08:40:12 +00:00
if ( iWord = = sel )
attr = IDA_DEFAULT_REV ;
else
2007-09-01 18:46:55 +00:00
attr = IDA_DEFAULT ;
2011-08-15 15:22:26 +00:00
drawStr ( IDI_MSA_ROW_MENU_0 + iRow , menu . row [ iRow ] . entry [ iWord ] . x0 ,
2007-09-02 01:45:59 +00:00
attr , ( char * ) menu . row [ iRow ] . entry [ iWord ] . szText ) ;
2007-09-01 18:46:55 +00:00
}
}
2007-11-23 18:28:40 +00:00
// Menu created, show it on screen
2016-01-29 12:13:40 +00:00
_gfx - > updateScreen ( ) ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : getMouseMenuSelRow ( MSA_MENU menu , int * sel0 , int * sel1 , int iRow , int x , int y ) {
2007-09-01 18:46:55 +00:00
int iWord ;
int * sel = 0 ;
2009-09-30 16:16:53 +00:00
switch ( iRow ) {
2007-09-01 18:46:55 +00:00
case 0 :
if ( y ! = IDI_MSA_ROW_MENU_0 ) return ;
sel = sel0 ;
break ;
case 1 :
if ( y ! = IDI_MSA_ROW_MENU_1 ) return ;
sel = sel1 ;
break ;
2010-10-15 08:49:20 +00:00
default :
return ;
2007-09-01 18:46:55 +00:00
}
for ( iWord = 0 ; iWord < menu . row [ iRow ] . count ; iWord + + ) {
2007-09-19 08:40:12 +00:00
if ( ( x > = menu . row [ iRow ] . entry [ iWord ] . x0 ) & &
( x < ( int ) ( menu . row [ iRow ] . entry [ iWord ] . x0 +
2007-09-01 18:46:55 +00:00
strlen ( ( char * ) menu . row [ iRow ] . entry [ iWord ] . szText ) ) ) ) {
* sel = iWord ;
break ;
}
}
}
2011-08-15 15:22:26 +00:00
bool MickeyEngine : : getMenuSelRow ( MSA_MENU menu , int * sel0 , int * sel1 , int iRow ) {
2007-09-01 18:46:55 +00:00
Common : : Event event ;
int * sel = 0 ;
int nWords ;
int x , y ;
2007-09-05 15:43:56 +00:00
int goIndex = - 1 , northIndex = - 1 , southIndex = - 1 , eastIndex = - 1 , westIndex = - 1 ;
2007-09-01 18:46:55 +00:00
2009-09-30 16:16:53 +00:00
switch ( iRow ) {
2007-09-01 18:46:55 +00:00
case 0 :
sel = sel0 ;
break ;
case 1 :
sel = sel1 ;
break ;
}
nWords = menu . row [ iRow ] . count ;
2007-09-23 16:52:53 +00:00
_clickToMove = false ;
2007-09-05 15:43:56 +00:00
for ( int i = 0 ; i < = menu . row [ 0 ] . count ; i + + )
if ( menu . row [ 0 ] . entry [ i ] . szText [ 0 ] = = 71 & & menu . row [ 0 ] . entry [ i ] . szText [ 1 ] = = 79 ) // GO
goIndex = i ;
if ( goIndex > = 0 ) {
for ( int j = 0 ; j < = menu . row [ 1 ] . count ; j + + ) {
if ( menu . row [ 1 ] . entry [ j ] . szText [ 0 ] = = 78 & & menu . row [ 1 ] . entry [ j ] . szText [ 1 ] = = 79 & &
menu . row [ 1 ] . entry [ j ] . szText [ 2 ] = = 82 & & menu . row [ 1 ] . entry [ j ] . szText [ 3 ] = = 84 & &
menu . row [ 1 ] . entry [ j ] . szText [ 4 ] = = 72 )
northIndex = j ;
if ( menu . row [ 1 ] . entry [ j ] . szText [ 0 ] = = 83 & & menu . row [ 1 ] . entry [ j ] . szText [ 1 ] = = 79 & &
menu . row [ 1 ] . entry [ j ] . szText [ 2 ] = = 85 & & menu . row [ 1 ] . entry [ j ] . szText [ 3 ] = = 84 & &
menu . row [ 1 ] . entry [ j ] . szText [ 4 ] = = 72 )
southIndex = j ;
if ( menu . row [ 1 ] . entry [ j ] . szText [ 0 ] = = 69 & & menu . row [ 1 ] . entry [ j ] . szText [ 1 ] = = 65 & &
menu . row [ 1 ] . entry [ j ] . szText [ 2 ] = = 83 & & menu . row [ 1 ] . entry [ j ] . szText [ 3 ] = = 84 )
eastIndex = j ;
if ( menu . row [ 1 ] . entry [ j ] . szText [ 0 ] = = 87 & & menu . row [ 1 ] . entry [ j ] . szText [ 1 ] = = 69 & &
menu . row [ 1 ] . entry [ j ] . szText [ 2 ] = = 83 & & menu . row [ 1 ] . entry [ j ] . szText [ 3 ] = = 84 )
westIndex = j ;
}
}
2007-09-01 18:46:55 +00:00
drawMenu ( menu , * sel0 , * sel1 ) ;
2011-08-15 15:22:26 +00:00
while ( ! shouldQuit ( ) ) {
while ( _system - > getEventManager ( ) - > pollEvent ( event ) ) {
2009-09-30 16:16:53 +00:00
switch ( event . type ) {
2008-07-16 04:22:56 +00:00
case Common : : EVENT_RTL :
2007-09-01 18:46:55 +00:00
case Common : : EVENT_QUIT :
2008-07-08 01:33:57 +00:00
return 0 ;
2007-09-01 18:46:55 +00:00
case Common : : EVENT_MOUSEMOVE :
if ( iRow < 2 ) {
2007-09-01 23:30:37 +00:00
x = event . mouse . x / 8 ;
y = event . mouse . y / 8 ;
2007-09-04 06:54:40 +00:00
// If the mouse hovers over the menu, refresh the menu
if ( ( iRow = = 0 & & y = = IDI_MSA_ROW_MENU_0 ) | | ( iRow = = 1 & & y = = IDI_MSA_ROW_MENU_1 ) ) {
getMouseMenuSelRow ( menu , sel0 , sel1 , iRow , x , y ) ;
drawMenu ( menu , * sel0 , * sel1 ) ;
}
2007-09-05 15:43:56 +00:00
// Change cursor
if ( northIndex > = 0 & & ( event . mouse . x > = 20 & & event . mouse . x < = ( IDI_MSA_PIC_WIDTH + 10 ) * 2 ) & &
2009-06-06 17:39:13 +00:00
( event . mouse . y > = 0 & & event . mouse . y < = 10 ) ) {
2016-01-29 12:13:40 +00:00
//_gfx->setCursorPalette(true);
// TODO:?????
2007-09-05 15:43:56 +00:00
} else if ( southIndex > = 0 & & ( event . mouse . x > = 20 & & event . mouse . x < = ( IDI_MSA_PIC_WIDTH + 10 ) * 2 ) & &
2009-06-06 17:39:13 +00:00
( event . mouse . y > = IDI_MSA_PIC_HEIGHT - 10 & & event . mouse . y < = IDI_MSA_PIC_HEIGHT ) ) {
2016-01-29 12:13:40 +00:00
//_gfx->setCursorPalette(true);
2007-09-05 15:43:56 +00:00
} else if ( westIndex > = 0 & & ( event . mouse . y > = 0 & & event . mouse . y < = IDI_MSA_PIC_HEIGHT ) & &
2009-06-06 17:39:13 +00:00
( event . mouse . x > = 20 & & event . mouse . x < = 30 ) ) {
2016-01-29 12:13:40 +00:00
//_gfx->setCursorPalette(true);
2007-09-05 15:43:56 +00:00
} else if ( eastIndex > = 0 & & ( event . mouse . y > = 0 & & event . mouse . y < = IDI_MSA_PIC_HEIGHT ) & &
2009-06-06 17:39:13 +00:00
( event . mouse . x > = IDI_MSA_PIC_WIDTH * 2 & & event . mouse . x < = ( IDI_MSA_PIC_WIDTH + 10 ) * 2 ) ) {
2016-01-29 12:13:40 +00:00
//_gfx->setCursorPalette(true);
2007-09-05 15:43:56 +00:00
} else {
2016-01-29 12:13:40 +00:00
//_gfx->setCursorPalette(false);
2007-09-05 15:43:56 +00:00
}
2007-09-01 18:46:55 +00:00
}
break ;
case Common : : EVENT_LBUTTONUP :
2007-09-05 15:43:56 +00:00
// Click to move
if ( northIndex > = 0 & & ( event . mouse . x > = 20 & & event . mouse . x < = ( IDI_MSA_PIC_WIDTH + 10 ) * 2 ) & &
2009-06-06 17:39:13 +00:00
( event . mouse . y > = 0 & & event . mouse . y < = 10 ) ) {
* sel0 = goIndex ;
* sel1 = northIndex ;
2007-09-05 15:43:56 +00:00
drawMenu ( menu , * sel0 , * sel1 ) ;
2009-06-06 17:39:13 +00:00
2016-01-29 12:13:40 +00:00
//_gfx->setCursorPalette(false);
// TODO???
2007-09-23 16:52:53 +00:00
_clickToMove = true ;
2007-09-05 15:43:56 +00:00
} else if ( southIndex > = 0 & & ( event . mouse . x > = 20 & & event . mouse . x < = ( IDI_MSA_PIC_WIDTH + 10 ) * 2 ) & &
2009-06-06 17:39:13 +00:00
( event . mouse . y > = IDI_MSA_PIC_HEIGHT - 10 & & event . mouse . y < = IDI_MSA_PIC_HEIGHT ) ) {
* sel0 = goIndex ;
* sel1 = southIndex ;
2007-09-05 15:43:56 +00:00
drawMenu ( menu , * sel0 , * sel1 ) ;
2009-06-06 17:39:13 +00:00
2016-01-29 12:13:40 +00:00
//_gfx->setCursorPalette(false);
// TODO???
2007-09-23 16:52:53 +00:00
_clickToMove = true ;
2007-09-05 15:43:56 +00:00
} else if ( westIndex > = 0 & & ( event . mouse . y > = 0 & & event . mouse . y < = IDI_MSA_PIC_HEIGHT ) & &
2009-06-06 17:39:13 +00:00
( event . mouse . x > = 20 & & event . mouse . x < = 30 ) ) {
* sel0 = goIndex ;
* sel1 = westIndex ;
2007-09-05 15:43:56 +00:00
drawMenu ( menu , * sel0 , * sel1 ) ;
2009-06-06 17:39:13 +00:00
2016-01-29 12:13:40 +00:00
//_gfx->setCursorPalette(false);
// TODO???
2007-09-23 16:52:53 +00:00
_clickToMove = true ;
2007-09-05 15:43:56 +00:00
} else if ( eastIndex > = 0 & & ( event . mouse . y > = 0 & & event . mouse . y < = IDI_MSA_PIC_HEIGHT ) & &
2009-06-06 17:39:13 +00:00
( event . mouse . x > = IDI_MSA_PIC_WIDTH * 2 & & event . mouse . x < = ( IDI_MSA_PIC_WIDTH + 10 ) * 2 ) ) {
* sel0 = goIndex ;
* sel1 = eastIndex ;
2007-09-05 15:43:56 +00:00
drawMenu ( menu , * sel0 , * sel1 ) ;
2009-06-06 17:39:13 +00:00
2016-01-29 12:13:40 +00:00
//_gfx->setCursorPalette(false);
// TODO???
2007-09-23 16:52:53 +00:00
_clickToMove = true ;
2007-09-05 15:43:56 +00:00
} else {
2016-01-29 12:13:40 +00:00
//_gfx->setCursorPalette(false);
// TODO???
2007-09-05 15:43:56 +00:00
}
2007-09-01 18:46:55 +00:00
return true ;
case Common : : EVENT_RBUTTONUP :
2009-06-06 17:39:13 +00:00
* sel0 = 0 ;
* sel1 = - 1 ;
2007-09-01 18:46:55 +00:00
return false ;
case Common : : EVENT_WHEELUP :
if ( iRow < 2 ) {
* sel - = 1 ;
2009-06-06 17:39:13 +00:00
if ( * sel < 0 )
* sel = nWords - 1 ;
2007-09-01 18:46:55 +00:00
drawMenu ( menu , * sel0 , * sel1 ) ;
}
break ;
case Common : : EVENT_WHEELDOWN :
if ( iRow < 2 ) {
* sel + = 1 ;
2009-06-06 17:39:13 +00:00
if ( * sel = = nWords )
* sel = 0 ;
2007-09-01 18:46:55 +00:00
drawMenu ( menu , * sel0 , * sel1 ) ;
}
break ;
case Common : : EVENT_KEYDOWN :
2011-08-15 15:22:26 +00:00
if ( event . kbd . keycode = = Common : : KEYCODE_d & & ( event . kbd . flags & Common : : KBD_CTRL ) & & _console ) {
_console - > attach ( ) ;
_console - > onFrame ( ) ;
2008-01-09 09:19:17 +00:00
continue ;
}
2007-09-01 18:46:55 +00:00
switch ( event . kbd . keycode ) {
case Common : : KEYCODE_2 :
2007-09-22 13:27:10 +00:00
// Hidden message
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRoom = = IDI_MSA_PIC_MERCURY_CAVE_0 ) {
2007-09-22 13:27:10 +00:00
for ( int i = 0 ; i < 5 ; i + + ) {
printExeMsg ( IDO_MSA_HIDDEN_MSG [ i ] ) ;
}
2011-08-15 15:22:26 +00:00
clearTextArea ( ) ;
2007-09-22 13:27:10 +00:00
waitAnyKey ( ) ;
}
2007-09-01 18:46:55 +00:00
break ;
case Common : : KEYCODE_8 :
if ( event . kbd . flags & Common : : KBD_CTRL ) {
2009-06-06 17:39:13 +00:00
* sel0 = 0 ;
* sel1 = - 1 ;
return false ;
2007-09-01 18:46:55 +00:00
}
break ;
case Common : : KEYCODE_ESCAPE :
2009-06-06 17:39:13 +00:00
* sel0 = 0 ;
* sel1 = - 1 ;
return false ;
2007-09-01 18:46:55 +00:00
case Common : : KEYCODE_s :
2016-01-31 16:56:53 +00:00
flipFlag ( VM_FLAG_SOUND_ON ) ;
2007-09-01 18:46:55 +00:00
break ;
case Common : : KEYCODE_c :
inventory ( ) ;
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
* sel0 = 0 ;
* sel1 = - 1 ;
return false ;
2007-09-01 18:46:55 +00:00
case Common : : KEYCODE_b :
printRoomDesc ( ) ;
drawMenu ( menu , * sel0 , * sel1 ) ;
2009-06-06 17:39:13 +00:00
* sel0 = 0 ;
* sel1 = - 1 ;
return false ;
2007-09-01 18:46:55 +00:00
case Common : : KEYCODE_LEFT :
case Common : : KEYCODE_KP4 :
case Common : : KEYCODE_4 :
if ( iRow < 2 ) {
* sel - = 1 ;
2009-06-06 17:39:13 +00:00
if ( * sel < 0 )
* sel = nWords - 1 ;
2007-09-01 18:46:55 +00:00
drawMenu ( menu , * sel0 , * sel1 ) ;
}
break ;
case Common : : KEYCODE_RIGHT :
case Common : : KEYCODE_SPACE :
case Common : : KEYCODE_KP6 :
case Common : : KEYCODE_6 :
if ( iRow < 2 ) {
* sel + = 1 ;
2009-06-06 17:39:13 +00:00
if ( * sel = = nWords )
* sel = 0 ;
2007-09-01 18:46:55 +00:00
drawMenu ( menu , * sel0 , * sel1 ) ;
}
break ;
case Common : : KEYCODE_RETURN :
2007-09-04 06:54:40 +00:00
case Common : : KEYCODE_KP_ENTER :
2007-09-01 18:46:55 +00:00
return true ;
default :
break ;
}
break ;
2007-09-01 19:03:22 +00:00
default :
break ;
2007-09-01 18:46:55 +00:00
}
animate ( ) ;
drawMenu ( menu , * sel0 , * sel1 ) ;
}
animate ( ) ;
drawMenu ( menu , * sel0 , * sel1 ) ;
}
2009-05-24 15:17:42 +00:00
2009-01-05 01:40:08 +00:00
return false ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : getMenuSel ( char * buffer , int * sel0 , int * sel1 ) {
2007-09-01 18:46:55 +00:00
MSA_MENU menu ;
memcpy ( & menu , buffer , sizeof ( MSA_MENU ) ) ;
* sel0 = 0 ;
* sel1 = - 1 ;
2007-09-04 06:54:40 +00:00
// Show the mouse cursor for the menu
CursorMan . showMouse ( true ) ;
2011-08-15 15:22:26 +00:00
while ( ! shouldQuit ( ) ) {
while ( ! shouldQuit ( ) ) {
2007-09-01 18:46:55 +00:00
if ( getMenuSelRow ( menu , sel0 , sel1 , 0 ) ) {
2007-09-23 16:52:53 +00:00
if ( _clickToMove )
2007-09-05 15:43:56 +00:00
break ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
* sel1 = 0 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
if ( getMenuSelRow ( menu , sel0 , sel1 , 1 ) ) {
break ;
}
}
}
2009-05-24 15:17:42 +00:00
2007-09-23 16:52:53 +00:00
if ( _clickToMove | | getMenuSelRow ( menu , sel0 , sel1 , 2 ) ) {
2007-09-01 18:46:55 +00:00
break ;
}
}
2007-09-04 06:54:40 +00:00
// Menu selection made, hide the mouse cursor
CursorMan . showMouse ( false ) ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : centerMenu ( MSA_MENU * menu ) {
2007-09-01 18:46:55 +00:00
int iWord ;
int iRow ;
int w , x ;
for ( iRow = 0 ; iRow < 2 ; iRow + + ) {
w = 0 ;
for ( iWord = 0 ; iWord < menu - > row [ iRow ] . count ; iWord + + ) {
w + = strlen ( ( char * ) menu - > row [ iRow ] . entry [ iWord ] . szText ) ;
}
w + = menu - > row [ iRow ] . count - 1 ;
x = ( 40 - w ) / 2 ; // FIX
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
for ( iWord = 0 ; iWord < menu - > row [ iRow ] . count ; iWord + + ) {
menu - > row [ iRow ] . entry [ iWord ] . x0 = x ;
x + = strlen ( ( char * ) menu - > row [ iRow ] . entry [ iWord ] . szText ) + 1 ;
}
}
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : patchMenu ( MSA_MENU * menu ) {
2007-09-01 18:46:55 +00:00
uint8 buffer [ 512 ] ;
uint8 menubuf [ sizeof ( MSA_MENU ) ] ;
int nPatches ;
int pBuf = 0 ;
// change planet name in ship airlock menu
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRoom = = IDI_MSA_PIC_SHIP_AIRLOCK ) {
strcpy ( ( char * ) menu - > row [ 1 ] . entry [ 2 ] . szText , IDS_MSA_NAME_PLANET [ _gameStateMickey . iPlanet ] ) ;
2007-09-01 18:46:55 +00:00
}
// exit if fix unnecessary
2011-08-15 15:22:26 +00:00
if ( ! _gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] ) {
2007-09-01 18:46:55 +00:00
centerMenu ( menu ) ;
return ;
}
// copy menu to menubuf
memcpy ( menubuf , menu , sizeof ( menubuf ) ) ;
// read patches
readOfsData (
2007-09-19 08:40:12 +00:00
IDOFS_MSA_MENU_PATCHES ,
2011-08-15 15:22:26 +00:00
_gameStateMickey . nRmMenu [ _gameStateMickey . iRoom ] + _gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] - 1 ,
2007-09-01 18:46:55 +00:00
buffer , sizeof ( buffer )
) ;
// get number of patches
nPatches = buffer [ pBuf + + ] ;
// patch menubuf
for ( int iPatch = 0 ; iPatch < nPatches ; iPatch + + ) {
if ( buffer [ pBuf ] > sizeof ( menubuf ) ) {
// patch address out of bounds
}
menubuf [ buffer [ pBuf ] ] = buffer [ pBuf + 1 ] ;
pBuf + = 2 ;
}
// copy menubuf back to menu
memcpy ( menu , menubuf , sizeof ( MSA_MENU ) ) ;
// center menu
centerMenu ( menu ) ;
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : printDatMessage ( int iStr ) {
2007-09-01 18:46:55 +00:00
printDatString ( iStr ) ;
2007-11-20 20:25:37 +00:00
waitAnyKey ( true ) ;
2007-09-01 18:46:55 +00:00
}
// Sound
2011-08-15 15:22:26 +00:00
void MickeyEngine : : playNote ( MSA_SND_NOTE note ) {
2007-09-03 10:25:48 +00:00
if ( ! note . counter ) {
2007-11-20 00:26:36 +00:00
// Pause
2011-08-15 15:22:26 +00:00
_system - > delayMillis ( ( uint ) ( note . length / IDI_SND_TIMER_RESOLUTION ) ) ;
2007-09-03 10:25:48 +00:00
} else {
2011-08-15 15:22:26 +00:00
PreAgiEngine : : playNote ( IDI_SND_OSCILLATOR_FREQUENCY / note . counter , ( int32 ) ( note . length / IDI_SND_TIMER_RESOLUTION ) ) ;
2007-09-03 10:25:48 +00:00
}
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : playSound ( ENUM_MSA_SOUND iSound ) {
2016-01-31 16:56:53 +00:00
if ( ! getFlag ( VM_FLAG_SOUND_ON ) )
2007-09-01 18:46:55 +00:00
return ;
2007-09-03 01:33:17 +00:00
Common : : Event event ;
2007-09-01 18:46:55 +00:00
MSA_SND_NOTE note ;
uint8 * buffer = new uint8 [ 1024 ] ;
int pBuf = 1 ;
2009-09-30 16:16:53 +00:00
switch ( iSound ) {
2007-09-01 18:46:55 +00:00
case IDI_MSA_SND_XL30 :
for ( int iNote = 0 ; iNote < 6 ; iNote + + ) {
2011-08-15 15:22:26 +00:00
note . counter = rnd ( 59600 ) + 59 ;
2007-09-01 18:46:55 +00:00
note . length = 4 ;
2007-09-03 10:25:48 +00:00
playNote ( note ) ;
2007-09-01 18:46:55 +00:00
}
break ;
default :
readOfsData ( IDOFS_MSA_SOUND_DATA , iSound , buffer , 1024 ) ;
for ( ; ; ) {
memcpy ( & note , buffer + pBuf , sizeof ( note ) ) ;
if ( ! note . counter & & ! note . length )
break ;
2007-09-03 10:25:48 +00:00
playNote ( note ) ;
2007-09-01 18:46:55 +00:00
pBuf + = 3 ;
if ( iSound = = IDI_MSA_SND_THEME ) {
2011-08-15 15:22:26 +00:00
while ( _system - > getEventManager ( ) - > pollEvent ( event ) ) {
2009-09-30 16:16:53 +00:00
switch ( event . type ) {
2008-07-16 04:22:56 +00:00
case Common : : EVENT_RTL :
2007-09-03 01:33:17 +00:00
case Common : : EVENT_QUIT :
case Common : : EVENT_LBUTTONUP :
case Common : : EVENT_RBUTTONUP :
case Common : : EVENT_KEYDOWN :
2008-05-07 14:31:45 +00:00
delete [ ] buffer ;
2007-09-01 18:46:55 +00:00
return ;
2007-09-03 01:36:55 +00:00
default :
break ;
2007-09-01 18:46:55 +00:00
}
}
}
}
break ;
}
2008-05-07 14:31:45 +00:00
delete [ ] buffer ;
2007-09-01 18:46:55 +00:00
}
// Graphics
2011-08-15 15:22:26 +00:00
void MickeyEngine : : drawObj ( ENUM_MSA_OBJECT iObj , int x0 , int y0 ) {
2007-09-11 21:39:16 +00:00
char szFile [ 255 ] = { 0 } ;
sprintf ( szFile , IDS_MSA_PATH_OBJ , IDS_MSA_NAME_OBJ [ iObj ] ) ;
Common : : File file ;
if ( ! file . open ( szFile ) )
return ;
2009-06-06 17:39:13 +00:00
2009-10-01 12:09:02 +00:00
uint8 * buffer = new uint8 [ 4096 ] ;
2007-09-11 21:39:16 +00:00
uint32 size = file . size ( ) ;
file . read ( buffer , size ) ;
file . close ( ) ;
2007-09-05 15:43:56 +00:00
if ( iObj = = IDI_MSA_OBJECT_CRYSTAL )
2011-08-15 15:22:26 +00:00
_picture - > setPictureFlags ( kPicFStep ) ;
2008-01-27 19:47:41 +00:00
2011-08-15 15:22:26 +00:00
_picture - > setOffset ( x0 , y0 ) ;
_picture - > decodePicture ( buffer , size , false , IDI_MSA_PIC_WIDTH , IDI_MSA_PIC_HEIGHT ) ;
_picture - > setOffset ( 0 , 0 ) ;
_picture - > showPic ( 10 , 0 , IDI_MSA_PIC_WIDTH , IDI_MSA_PIC_HEIGHT ) ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : drawPic ( int iPic ) {
2007-09-11 21:39:16 +00:00
char szFile [ 255 ] = { 0 } ;
sprintf ( szFile , IDS_MSA_PATH_PIC , iPic ) ;
Common : : File file ;
if ( ! file . open ( szFile ) )
return ;
2009-06-06 17:39:13 +00:00
2009-10-01 12:09:02 +00:00
uint8 * buffer = new uint8 [ 4096 ] ;
2007-09-11 21:39:16 +00:00
uint32 size = file . size ( ) ;
file . read ( buffer , size ) ;
file . close ( ) ;
2007-09-02 13:44:37 +00:00
// Note that decodePicture clears the screen
2016-01-29 12:13:40 +00:00
_picture - > setOffset ( 10 , 0 ) ;
2011-08-15 15:22:26 +00:00
_picture - > decodePicture ( buffer , size , true , IDI_MSA_PIC_WIDTH , IDI_MSA_PIC_HEIGHT ) ;
2016-01-29 12:13:40 +00:00
_picture - > setOffset ( 0 , 0 ) ;
2011-08-15 15:22:26 +00:00
_picture - > showPic ( 10 , 0 , IDI_MSA_PIC_WIDTH , IDI_MSA_PIC_HEIGHT ) ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : drawRoomAnimation ( ) {
2007-09-01 18:46:55 +00:00
uint8 objLight [ ] = {
2007-09-05 19:36:13 +00:00
0xF0 , 1 , 0xF9 , 2 , 43 , 45 , 0xFF
2007-09-01 18:46:55 +00:00
} ;
2011-08-15 15:22:26 +00:00
switch ( _gameStateMickey . iRoom ) {
2007-09-01 18:46:55 +00:00
case IDI_MSA_PIC_EARTH_SHIP :
case IDI_MSA_PIC_VENUS_SHIP :
case IDI_MSA_PIC_NEPTUNE_SHIP :
case IDI_MSA_PIC_MERCURY_SHIP :
case IDI_MSA_PIC_SATURN_SHIP :
case IDI_MSA_PIC_PLUTO_SHIP :
case IDI_MSA_PIC_JUPITER_SHIP :
case IDI_MSA_PIC_MARS_SHIP :
case IDI_MSA_PIC_URANUS_SHIP :
case IDI_MSA_PIC_SHIP_VENUS :
case IDI_MSA_PIC_SHIP_NEPTUNE :
case IDI_MSA_PIC_SHIP_MERCURY :
case IDI_MSA_PIC_SHIP_SATURN :
case IDI_MSA_PIC_SHIP_PLUTO :
case IDI_MSA_PIC_SHIP_JUPITER :
case IDI_MSA_PIC_SHIP_MARS :
case IDI_MSA_PIC_SHIP_URANUS :
2007-09-03 15:03:50 +00:00
{
2009-06-06 17:39:13 +00:00
// draw blinking ship lights
2007-09-01 18:46:55 +00:00
2009-06-06 17:39:13 +00:00
uint8 iColor = 0 ;
2007-09-03 15:03:50 +00:00
2011-08-15 15:22:26 +00:00
_picture - > setPattern ( 2 , 0 ) ;
2007-09-01 18:46:55 +00:00
2009-06-06 17:39:13 +00:00
for ( int i = 0 ; i < 12 ; i + + ) {
2011-08-15 15:22:26 +00:00
iColor = _gameStateMickey . nFrame + i ;
2009-06-06 17:39:13 +00:00
if ( iColor > 15 )
iColor - = 15 ;
2007-09-01 18:46:55 +00:00
2009-06-06 17:39:13 +00:00
objLight [ 1 ] = iColor ;
objLight [ 4 ] + = 7 ;
2007-09-03 15:03:50 +00:00
2011-08-15 15:22:26 +00:00
_picture - > setPictureData ( objLight ) ;
_picture - > setPictureFlags ( kPicFCircle ) ;
_picture - > drawPicture ( ) ;
2009-06-06 17:39:13 +00:00
}
2011-08-15 15:22:26 +00:00
_picture - > showPic ( 10 , 0 , IDI_MSA_PIC_WIDTH , IDI_MSA_PIC_HEIGHT ) ;
2007-09-19 08:40:12 +00:00
2007-09-01 18:46:55 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . nFrame - - ;
if ( _gameStateMickey . nFrame < 0 )
_gameStateMickey . nFrame = 15 ;
2007-09-01 18:46:55 +00:00
2009-06-06 17:39:13 +00:00
playSound ( IDI_MSA_SND_PRESS_BLUE ) ;
2007-09-03 15:03:50 +00:00
}
2007-09-01 18:46:55 +00:00
break ;
case IDI_MSA_PIC_SHIP_CONTROLS :
// draw XL30 screen
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fAnimXL30 ) {
if ( _gameStateMickey . nFrame > 5 )
_gameStateMickey . nFrame = 0 ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
drawObj ( ( ENUM_MSA_OBJECT ) ( IDI_MSA_OBJECT_XL31 + _gameStateMickey . nFrame ) , 0 , 4 ) ;
_gameStateMickey . nFrame + + ;
2007-09-01 18:46:55 +00:00
} ;
break ;
default :
// draw crystal
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRoom = = IDI_MSA_XTAL_ROOM_XY [ _gameStateMickey . iPlanet ] [ 0 ] ) {
if ( ! _gameStateMickey . fHasXtal ) {
switch ( _gameStateMickey . iPlanet ) {
2007-09-01 18:46:55 +00:00
case IDI_MSA_PLANET_VENUS :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] ! = 2 )
2009-06-06 17:39:13 +00:00
break ;
2007-09-01 18:46:55 +00:00
default :
drawObj (
2007-09-19 08:40:12 +00:00
IDI_MSA_OBJECT_CRYSTAL ,
2011-08-15 15:22:26 +00:00
IDI_MSA_XTAL_ROOM_XY [ _gameStateMickey . iPlanet ] [ 1 ] ,
IDI_MSA_XTAL_ROOM_XY [ _gameStateMickey . iPlanet ] [ 2 ]
2007-09-01 18:46:55 +00:00
) ;
break ;
}
}
}
break ;
}
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : drawRoom ( ) {
2013-10-07 20:22:15 +00:00
uint8 buffer [ 512 ] ;
2007-09-22 13:27:10 +00:00
int pBuf = 0 ;
int nObjs ;
// Draw room picture
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRoom = = IDI_MSA_PIC_TITLE ) {
2008-01-09 09:46:26 +00:00
drawPic ( IDI_MSA_PIC_TITLE ) ;
} else {
2011-08-15 15:22:26 +00:00
drawPic ( _gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] ) ;
2007-09-22 13:27:10 +00:00
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRoom = = IDI_MSA_PIC_SHIP_CONTROLS ) {
2008-01-09 09:46:26 +00:00
// Draw ship control room window
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fFlying ) {
2008-01-09 09:46:26 +00:00
drawObj ( IDI_MSA_OBJECT_W_SPACE , 0 , 0 ) ;
} else {
2011-08-15 15:22:26 +00:00
drawObj ( ( ENUM_MSA_OBJECT ) ( IDI_MSA_OBJECT_W_EARTH + _gameStateMickey . iPlanet ) , 0 , 1 ) ;
2007-09-22 13:27:10 +00:00
}
}
}
// Draw room objects
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRoom > = IDI_MSA_MAX_PIC_ROOM ) {
2007-09-22 13:27:10 +00:00
drawRoomAnimation ( ) ;
return ;
}
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] ! = IDI_MSA_OBJECT_NONE ) {
2007-09-22 13:27:10 +00:00
readOfsData ( IDO_MSA_ROOM_OBJECT_XY_OFFSETS ,
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] , buffer , sizeof ( buffer ) ) ;
2007-09-22 13:27:10 +00:00
nObjs = buffer [ pBuf + + ] ;
for ( int iObj = 0 ; iObj < nObjs ; iObj + + ) {
drawObj ( ( ENUM_MSA_OBJECT ) buffer [ pBuf ] , buffer [ pBuf + 1 ] , buffer [ pBuf + 2 ] ) ;
pBuf + = 3 ;
}
}
// Draw room animation
2007-09-01 18:46:55 +00:00
drawRoomAnimation ( ) ;
}
2016-01-29 12:13:40 +00:00
// Straight mapping, CGA colors to CGA
const byte BCGColorMappingCGAToCGA [ 4 ] = {
0 , 1 , 2 , 3
} ;
// Mapping table to map CGA colors to EGA
const byte BCGColorMappingCGAToEGA [ 4 ] = {
0 , 11 , 13 , 15
2007-09-06 21:58:57 +00:00
} ;
2011-08-15 15:22:26 +00:00
void MickeyEngine : : drawLogo ( ) {
2016-01-29 12:13:40 +00:00
const int width = 80 ;
const int height = 85 * 2 ;
byte color1 , color2 , color3 , color4 ;
byte * fileBuffer = nullptr ;
uint32 fileBufferSize = 0 ;
byte * dataBuffer ;
byte curByte ;
const byte * BCGColorMapping = BCGColorMappingCGAToEGA ;
// disable color mapping in case we are in CGA mode
2016-01-29 14:43:45 +00:00
if ( _renderMode = = Common : : kRenderCGA )
2016-01-29 12:13:40 +00:00
BCGColorMapping = BCGColorMappingCGAToCGA ;
// read logos.bcg
2007-09-01 18:46:55 +00:00
Common : : File infile ;
2016-01-29 12:13:40 +00:00
if ( ! infile . open ( IDS_MSA_PATH_LOGO ) )
2007-09-01 18:46:55 +00:00
return ;
2009-06-06 17:39:13 +00:00
2016-01-29 12:13:40 +00:00
fileBufferSize = infile . size ( ) ;
fileBuffer = new byte [ fileBufferSize ] ;
infile . read ( fileBuffer , fileBufferSize ) ;
2007-09-01 18:46:55 +00:00
infile . close ( ) ;
2007-09-19 08:40:12 +00:00
2016-01-29 12:13:40 +00:00
if ( fileBufferSize < ( width * height / 4 ) )
error ( " logos.bcg: unexpected end of file " ) ;
2007-09-20 01:38:07 +00:00
// Show BCG picture
2016-01-29 12:13:40 +00:00
// It's basically uncompressed CGA 4-color data (4 pixels per byte)
dataBuffer = fileBuffer ;
for ( int y = 0 ; y < height ; y + + ) {
for ( int x = 0 ; x < width ; x + + ) {
curByte = * dataBuffer + + ;
color1 = BCGColorMapping [ ( curByte > > 6 ) & 0x03 ] ;
color2 = BCGColorMapping [ ( curByte > > 4 ) & 0x03 ] ;
color3 = BCGColorMapping [ ( curByte > > 2 ) & 0x03 ] ;
color4 = BCGColorMapping [ ( curByte > > 0 ) & 0x03 ] ;
_gfx - > putPixelOnDisplay ( x * 4 + 0 , y , color1 ) ;
_gfx - > putPixelOnDisplay ( x * 4 + 1 , y , color2 ) ;
_gfx - > putPixelOnDisplay ( x * 4 + 2 , y , color3 ) ;
_gfx - > putPixelOnDisplay ( x * 4 + 3 , y , color4 ) ;
2007-09-06 21:58:57 +00:00
}
}
2016-01-29 12:13:40 +00:00
_gfx - > copyDisplayRectToScreen ( 0 , 0 , DISPLAY_WIDTH , height ) ;
2008-01-27 19:47:41 +00:00
2016-01-29 12:13:40 +00:00
delete [ ] fileBuffer ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : animate ( ) {
_system - > delayMillis ( IDI_MSA_ANIM_DELAY ) ;
2007-09-03 15:03:50 +00:00
drawRoomAnimation ( ) ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : printRoomDesc ( ) {
2007-09-01 18:46:55 +00:00
// print room description
2011-08-15 15:22:26 +00:00
printDesc ( _gameStateMickey . iRoom ) ;
2007-11-20 20:25:37 +00:00
waitAnyKey ( true ) ;
2007-09-01 18:46:55 +00:00
// print extended room description
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . oRmTxt [ _gameStateMickey . iRoom ] ) {
printExeMsg ( _gameStateMickey . oRmTxt [ _gameStateMickey . iRoom ] + IDI_MSA_OFS_EXE ) ;
2007-09-01 18:46:55 +00:00
}
}
2011-08-15 15:22:26 +00:00
bool MickeyEngine : : loadGame ( ) {
2007-09-03 01:55:56 +00:00
Common : : InSaveFile * infile ;
2007-09-01 18:46:55 +00:00
char szFile [ 256 ] = { 0 } ;
bool diskerror = true ;
int sel ;
2007-12-08 17:51:23 +00:00
int saveVersion = 0 ;
int i = 0 ;
2007-09-01 18:46:55 +00:00
while ( diskerror ) {
sel = choose1to9 ( IDO_MSA_LOAD_GAME [ 1 ] ) ;
if ( ! sel )
return false ;
// load game
2011-08-15 15:22:26 +00:00
sprintf ( szFile , " %s.s%02d " , getTargetName ( ) . c_str ( ) , sel ) ;
if ( ! ( infile = getSaveFileMan ( ) - > openForLoading ( szFile ) ) ) {
2009-01-18 22:02:22 +00:00
printLine ( " PLEASE CHECK THE DISK DRIVE " ) ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
if ( getSelection ( kSelAnyKey ) = = 0 )
2007-09-01 18:46:55 +00:00
return false ;
} else {
2011-04-12 14:53:15 +00:00
if ( infile - > readUint32BE ( ) ! = MKTAG ( ' M ' , ' I ' , ' C ' , ' K ' ) ) {
2011-08-15 15:22:26 +00:00
warning ( " MickeyEngine::loadGame wrong save game format " ) ;
2008-08-26 12:34:05 +00:00
return false ;
}
2007-12-08 17:51:23 +00:00
saveVersion = infile - > readByte ( ) ;
2008-08-26 12:34:05 +00:00
if ( saveVersion < 2 ) {
warning ( " The planet data in this save game is corrupted. Load aborted " ) ;
return false ;
}
2007-12-08 18:19:09 +00:00
if ( saveVersion ! = MSA_SAVEGAME_VERSION )
warning ( " Old save game version (%d, current version is %d). Will try and read anyway, but don't be surprised if bad things happen " , saveVersion , MSA_SAVEGAME_VERSION ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = infile - > readByte ( ) ;
_gameStateMickey . iPlanet = infile - > readByte ( ) ;
_gameStateMickey . iDisk = infile - > readByte ( ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . nAir = infile - > readByte ( ) ;
_gameStateMickey . nButtons = infile - > readByte ( ) ;
_gameStateMickey . nRocks = infile - > readByte ( ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . nXtals = infile - > readByte ( ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_DAT ; i + + )
2011-08-15 15:22:26 +00:00
_gameStateMickey . iPlanetXtal [ i ] = infile - > readByte ( ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_PLANET ; i + + )
2011-08-15 15:22:26 +00:00
_gameStateMickey . iClue [ i ] = infile - > readUint16LE ( ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
infile - > read ( _gameStateMickey . szAddr , IDI_MSA_MAX_BUTTON + 1 ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . fHasXtal = infile - > readByte ( ) = = 1 ;
_gameStateMickey . fIntro = infile - > readByte ( ) = = 1 ;
_gameStateMickey . fSuit = infile - > readByte ( ) = = 1 ;
_gameStateMickey . fShipDoorOpen = infile - > readByte ( ) = = 1 ;
_gameStateMickey . fFlying = infile - > readByte ( ) = = 1 ;
_gameStateMickey . fStoryShown = infile - > readByte ( ) = = 1 ;
_gameStateMickey . fPlanetsInitialized = infile - > readByte ( ) = = 1 ;
_gameStateMickey . fTempleDoorOpen = infile - > readByte ( ) = = 1 ;
_gameStateMickey . fAnimXL30 = infile - > readByte ( ) = = 1 ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ITEM ; i + + )
2011-08-15 15:22:26 +00:00
_gameStateMickey . fItem [ i ] = infile - > readByte ( ) = = 1 ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ITEM ; i + + )
2011-08-15 15:22:26 +00:00
_gameStateMickey . fItemUsed [ i ] = infile - > readByte ( ) = = 1 ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ITEM ; i + + )
2011-08-15 15:22:26 +00:00
_gameStateMickey . iItem [ i ] = infile - > readSByte ( ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . nItems = infile - > readByte ( ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + )
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmObj [ i ] = infile - > readSByte ( ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + )
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmPic [ i ] = infile - > readByte ( ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + )
2011-08-15 15:22:26 +00:00
_gameStateMickey . oRmTxt [ i ] = infile - > readUint16LE ( ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + )
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ i ] = infile - > readByte ( ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + )
2011-08-15 15:22:26 +00:00
_gameStateMickey . nRmMenu [ i ] = infile - > readByte ( ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . nFrame = infile - > readSByte ( ) ;
2007-12-08 17:51:23 +00:00
2007-09-01 18:46:55 +00:00
diskerror = false ;
2007-09-19 08:40:12 +00:00
delete infile ;
2007-09-01 18:46:55 +00:00
}
}
printExeMsg ( IDO_MSA_LOAD_GAME [ 2 ] ) ;
return true ;
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : saveGame ( ) {
2007-09-03 01:55:56 +00:00
Common : : OutSaveFile * outfile ;
2007-09-03 00:47:51 +00:00
char szFile [ 256 ] = { 0 } ;
2007-09-01 18:46:55 +00:00
bool diskerror = true ;
int sel ;
2007-12-08 17:51:23 +00:00
int i = 0 ;
2007-09-01 18:46:55 +00:00
bool fOldDisk = chooseY_N ( IDO_MSA_SAVE_GAME [ 0 ] , false ) ;
if ( fOldDisk )
printExeStr ( IDO_MSA_SAVE_GAME [ 1 ] ) ;
else
printExeStr ( IDO_MSA_SAVE_GAME [ 2 ] ) ;
2011-08-15 15:22:26 +00:00
if ( getSelection ( kSelAnyKey ) = = 0 )
2007-09-01 18:46:55 +00:00
return ;
2007-09-19 08:40:12 +00:00
2007-09-01 18:46:55 +00:00
while ( diskerror ) {
sel = choose1to9 ( IDO_MSA_SAVE_GAME [ 3 ] ) ;
if ( ! sel )
return ;
if ( fOldDisk )
printExeStr ( IDO_MSA_SAVE_GAME [ 5 ] ) ;
else
printExeStr ( IDO_MSA_SAVE_GAME [ 4 ] ) ;
2011-08-15 15:22:26 +00:00
if ( getSelection ( kSelAnyKey ) = = 0 )
2007-09-01 18:46:55 +00:00
return ;
// save game
2011-08-15 15:22:26 +00:00
sprintf ( szFile , " %s.s%02d " , getTargetName ( ) . c_str ( ) , sel ) ;
if ( ! ( outfile = getSaveFileMan ( ) - > openForSaving ( szFile ) ) ) {
2009-01-18 22:02:22 +00:00
printLine ( " PLEASE CHECK THE DISK DRIVE " ) ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
if ( getSelection ( kSelAnyKey ) = = 0 )
2007-09-01 18:46:55 +00:00
return ;
} else {
2011-04-12 14:53:15 +00:00
outfile - > writeUint32BE ( MKTAG ( ' M ' , ' I ' , ' C ' , ' K ' ) ) ; // header
2007-12-08 18:19:09 +00:00
outfile - > writeByte ( MSA_SAVEGAME_VERSION ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
outfile - > writeByte ( _gameStateMickey . iRoom ) ;
outfile - > writeByte ( _gameStateMickey . iPlanet ) ;
outfile - > writeByte ( _gameStateMickey . iDisk ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
outfile - > writeByte ( _gameStateMickey . nAir ) ;
outfile - > writeByte ( _gameStateMickey . nButtons ) ;
outfile - > writeByte ( _gameStateMickey . nRocks ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
outfile - > writeByte ( _gameStateMickey . nXtals ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_DAT ; i + + )
2011-08-15 15:22:26 +00:00
outfile - > writeByte ( _gameStateMickey . iPlanetXtal [ i ] ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_PLANET ; i + + )
2011-08-15 15:22:26 +00:00
outfile - > writeUint16LE ( _gameStateMickey . iClue [ i ] ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
outfile - > write ( _gameStateMickey . szAddr , IDI_MSA_MAX_BUTTON + 1 ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
outfile - > writeByte ( _gameStateMickey . fHasXtal ? 1 : 0 ) ;
outfile - > writeByte ( _gameStateMickey . fIntro ? 1 : 0 ) ;
outfile - > writeByte ( _gameStateMickey . fSuit ? 1 : 0 ) ;
outfile - > writeByte ( _gameStateMickey . fShipDoorOpen ? 1 : 0 ) ;
outfile - > writeByte ( _gameStateMickey . fFlying ? 1 : 0 ) ;
outfile - > writeByte ( _gameStateMickey . fStoryShown ? 1 : 0 ) ;
outfile - > writeByte ( _gameStateMickey . fPlanetsInitialized ? 1 : 0 ) ;
outfile - > writeByte ( _gameStateMickey . fTempleDoorOpen ? 1 : 0 ) ;
outfile - > writeByte ( _gameStateMickey . fAnimXL30 ? 1 : 0 ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ITEM ; i + + )
2011-08-15 15:22:26 +00:00
outfile - > writeByte ( _gameStateMickey . fItem [ i ] ? 1 : 0 ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ITEM ; i + + )
2011-08-15 15:22:26 +00:00
outfile - > writeByte ( _gameStateMickey . fItemUsed [ i ] ? 1 : 0 ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ITEM ; i + + )
2011-08-15 15:22:26 +00:00
outfile - > writeSByte ( _gameStateMickey . iItem [ i ] ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
outfile - > writeByte ( _gameStateMickey . nItems ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + )
2011-08-15 15:22:26 +00:00
outfile - > writeSByte ( _gameStateMickey . iRmObj [ i ] ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + )
2011-08-15 15:22:26 +00:00
outfile - > writeByte ( _gameStateMickey . iRmPic [ i ] ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + )
2011-08-15 15:22:26 +00:00
outfile - > writeUint16LE ( _gameStateMickey . oRmTxt [ i ] ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + )
2011-08-15 15:22:26 +00:00
outfile - > writeByte ( _gameStateMickey . iRmMenu [ i ] ) ;
2007-12-08 17:51:23 +00:00
2009-01-29 05:26:12 +00:00
for ( i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + )
2011-08-15 15:22:26 +00:00
outfile - > writeByte ( _gameStateMickey . nRmMenu [ i ] ) ;
2007-12-08 17:51:23 +00:00
2011-08-15 15:22:26 +00:00
outfile - > writeSByte ( _gameStateMickey . nFrame ) ;
2007-12-08 17:51:23 +00:00
outfile - > finalize ( ) ;
2009-05-19 11:42:14 +00:00
if ( outfile - > err ( ) )
2007-12-08 17:51:23 +00:00
warning ( " Can't write file '%s'. (Disk full?) " , szFile ) ;
2007-09-01 18:46:55 +00:00
diskerror = false ;
2007-09-19 08:40:12 +00:00
delete outfile ;
2007-09-01 18:46:55 +00:00
}
}
printExeMsg ( IDO_MSA_SAVE_GAME [ 6 ] ) ;
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : showPlanetInfo ( ) {
2009-01-18 22:02:22 +00:00
for ( int i = 0 ; i < 4 ; i + + ) {
2011-08-15 15:22:26 +00:00
printExeStr ( IDO_MSA_PLANET_INFO [ _gameStateMickey . iPlanet ] [ i ] ) ;
2007-09-05 15:43:56 +00:00
waitAnyKey ( ) ;
2007-09-01 18:46:55 +00:00
}
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : printStory ( ) {
2007-09-01 18:46:55 +00:00
char buffer [ IDI_MSA_LEN_STORY ] = { 0 } ;
char szLine [ 41 ] = { 0 } ;
int iRow ;
int pBuf = 0 ;
2007-09-19 08:40:12 +00:00
2007-09-01 18:46:55 +00:00
readExe ( IDO_MSA_GAME_STORY , ( uint8 * ) buffer , sizeof ( buffer ) ) ;
2007-09-19 08:40:12 +00:00
2011-08-15 15:22:26 +00:00
clearScreen ( IDA_DEFAULT ) ;
2007-09-01 18:46:55 +00:00
for ( iRow = 0 ; iRow < 25 ; iRow + + ) {
strcpy ( szLine , buffer + pBuf ) ;
2011-08-15 15:22:26 +00:00
drawStr ( iRow , 0 , IDA_DEFAULT , szLine ) ;
2007-09-01 18:46:55 +00:00
pBuf + = strlen ( szLine ) + 1 ;
}
2007-09-05 15:43:56 +00:00
waitAnyKey ( ) ;
2007-09-01 18:46:55 +00:00
2011-08-15 15:22:26 +00:00
clearScreen ( IDA_DEFAULT ) ;
2007-09-01 18:46:55 +00:00
for ( iRow = 0 ; iRow < 21 ; iRow + + ) {
strcpy ( szLine , buffer + pBuf ) ;
2011-08-15 15:22:26 +00:00
drawStr ( iRow , 0 , IDA_DEFAULT , szLine ) ;
2007-09-01 18:46:55 +00:00
pBuf + = strlen ( szLine ) + 1 ;
}
2007-09-05 15:43:56 +00:00
waitAnyKey ( ) ;
2007-09-01 18:46:55 +00:00
2007-09-05 19:47:32 +00:00
//Set back to black
2016-01-29 12:13:40 +00:00
_gfx - > clearDisplay ( 0 ) ;
_gfx - > updateScreen ( ) ;
2007-09-05 19:47:32 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2011-08-15 15:22:26 +00:00
_gameStateMickey . fStoryShown = true ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
int MickeyEngine : : getPlanet ( ) {
if ( ! _gameStateMickey . nButtons )
2007-09-01 18:46:55 +00:00
return - 1 ;
2010-10-15 08:49:20 +00:00
for ( int iPlanet = 0 ; iPlanet < IDI_MSA_MAX_DAT - 1 ; iPlanet + + ) {
2011-08-15 15:22:26 +00:00
if ( ! strcmp ( IDS_MSA_ADDR_PLANET [ iPlanet ] , _gameStateMickey . szAddr ) ) {
2007-09-01 18:46:55 +00:00
return iPlanet ;
}
}
return - 1 ;
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : pressOB ( int iButton ) {
2007-09-01 18:46:55 +00:00
char szButtons [ 12 ] = { 0 } ;
// check if too many buttons pressed
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . nButtons = = IDI_MSA_MAX_BUTTON ) {
_gameStateMickey . nButtons = 0 ;
memset ( _gameStateMickey . szAddr , 0 , sizeof ( _gameStateMickey . szAddr ) ) ;
2007-09-01 18:46:55 +00:00
printExeMsg ( IDO_MSA_TOO_MANY_BUTTONS_PRESSED ) ;
return ;
}
2007-09-19 08:40:12 +00:00
2007-09-01 18:46:55 +00:00
// add button press to address
2011-08-15 15:22:26 +00:00
_gameStateMickey . nButtons + + ;
_gameStateMickey . szAddr [ _gameStateMickey . nButtons - 1 ] = ( char ) iButton ;
2007-09-01 18:46:55 +00:00
// format buttons string
for ( int i = 0 ; i < IDI_MSA_MAX_BUTTON ; i + + ) {
2011-08-15 15:22:26 +00:00
szButtons [ i * 2 ] = _gameStateMickey . szAddr [ i ] ;
if ( _gameStateMickey . szAddr [ i + 1 ] ) szButtons [ ( i * 2 ) + 1 ] = ' , ' ;
2007-09-01 18:46:55 +00:00
}
// print pressed buttons
2009-07-20 20:59:35 +00:00
printLine ( " MICKEY HAS PRESSED: " ) ;
2011-08-15 15:22:26 +00:00
drawStr ( 20 , 22 , IDA_DEFAULT , szButtons ) ;
2007-09-05 15:43:56 +00:00
waitAnyKey ( ) ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : insertDisk ( int iDisk ) {
clearTextArea ( ) ;
drawStr ( IDI_MSA_ROW_INSERT_DISK , IDI_MSA_COL_INSERT_DISK , IDA_DEFAULT , ( const char * ) IDS_MSA_INSERT_DISK [ iDisk ] ) ;
2007-09-05 15:43:56 +00:00
waitAnyKey ( ) ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : gameOver ( ) {
2009-01-05 01:40:08 +00:00
// We shouldn't run the game over segment if we're quitting.
2011-08-15 15:22:26 +00:00
if ( shouldQuit ( ) )
2009-01-05 01:40:08 +00:00
return ;
2007-09-01 18:46:55 +00:00
drawPic ( IDI_MSA_PIC_EARTH_SHIP_LEAVING ) ;
printExeMsg ( IDO_MSA_GAME_OVER [ 3 ] ) ;
2007-09-03 01:33:17 +00:00
playSound ( IDI_MSA_SND_GAME_OVER ) ;
2007-09-01 14:58:46 +00:00
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItemUsed [ IDI_MSA_ITEM_LETTER ] ) {
2007-09-01 18:46:55 +00:00
drawPic ( IDI_MSA_PIC_EARTH_MINNIE ) ;
printExeMsg ( IDO_MSA_GAME_OVER [ 4 ] ) ;
printExeMsg ( IDO_MSA_GAME_OVER [ 5 ] ) ;
} else {
printExeMsg ( IDO_MSA_GAME_OVER [ 6 ] ) ;
printExeMsg ( IDO_MSA_GAME_OVER [ 7 ] ) ;
}
2007-09-05 15:43:56 +00:00
waitAnyKey ( ) ;
2007-09-01 14:58:46 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : flipSwitch ( ) {
if ( _gameStateMickey . fHasXtal | | _gameStateMickey . nXtals ) {
if ( ! _gameStateMickey . fStoryShown )
2007-09-01 18:46:55 +00:00
printStory ( ) ;
2007-09-21 19:12:53 +00:00
2007-09-22 11:31:46 +00:00
// Initialize planet data
2011-08-15 15:22:26 +00:00
if ( ! _gameStateMickey . fPlanetsInitialized ) {
2007-09-22 11:31:46 +00:00
int iHint = 0 ;
int iPlanet = 0 ;
2011-08-15 15:22:26 +00:00
memset ( _gameStateMickey . iPlanetXtal , 0 , sizeof ( _gameStateMickey . iPlanetXtal ) ) ;
memset ( _gameStateMickey . iClue , 0 , sizeof ( _gameStateMickey . iClue ) ) ;
2007-09-22 11:31:46 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . iPlanetXtal [ 0 ] = IDI_MSA_PLANET_EARTH ;
_gameStateMickey . iPlanetXtal [ 8 ] = IDI_MSA_PLANET_URANUS ;
2007-09-22 11:31:46 +00:00
2010-10-15 08:49:20 +00:00
for ( int i = 1 ; i < IDI_MSA_MAX_PLANET ; i + + ) {
2007-11-23 18:28:40 +00:00
if ( i < 8 ) {
do {
// Earth (planet 0) and Uranus (planet 8) are excluded
2011-08-15 15:22:26 +00:00
iPlanet = rnd ( IDI_MSA_MAX_PLANET - 2 ) ;
2007-11-23 18:28:40 +00:00
} while ( planetIsAlreadyAssigned ( iPlanet ) ) ;
} else {
iPlanet = IDI_MSA_PLANET_URANUS ; // Uranus is always last
}
2007-09-22 11:31:46 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . iPlanetXtal [ i ] = iPlanet ;
iHint = rnd ( 5 ) - 1 ; // clues are 0-4
_gameStateMickey . iClue [ i ] = IDO_MSA_NEXT_PIECE [ iPlanet ] [ iHint ] ;
2007-09-22 11:31:46 +00:00
}
2011-08-15 15:22:26 +00:00
_gameStateMickey . fPlanetsInitialized = true ;
2007-09-22 11:31:46 +00:00
}
2007-09-01 18:46:55 +00:00
// activate screen animation
2011-08-15 15:22:26 +00:00
_gameStateMickey . fAnimXL30 = true ;
2007-09-01 18:46:55 +00:00
2011-08-15 15:22:26 +00:00
clearTextArea ( ) ;
2007-09-03 01:33:17 +00:00
playSound ( IDI_MSA_SND_XL30 ) ;
2007-09-01 18:46:55 +00:00
printExeMsg ( IDO_MSA_XL30_SPEAKING ) ;
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fHasXtal ) {
_gameStateMickey . fHasXtal = false ;
2007-09-01 18:46:55 +00:00
printExeMsg ( IDO_MSA_CRYSTAL_PIECE_FOUND ) ;
}
2007-09-19 08:40:12 +00:00
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . nXtals = = IDI_MSA_MAX_PLANET ) {
2007-09-01 18:46:55 +00:00
printExeMsg ( IDO_MSA_GAME_OVER [ 0 ] ) ;
printExeMsg ( IDO_MSA_GAME_OVER [ 1 ] ) ;
printExeMsg ( IDO_MSA_GAME_OVER [ 2 ] ) ;
2007-09-05 22:38:08 +00:00
#if 0
// DEBUG
2011-08-15 15:22:26 +00:00
strcpy ( _gameStateMickey . szAddr , ( char * ) IDS_MSA_ADDR_PLANET [ IDI_MSA_PLANET_EARTH ] ) ;
_gameStateMickey . nButtons = strlen ( _gameStateMickey . szAddr ) ;
2007-09-01 18:46:55 +00:00
# endif
} else {
2011-08-15 15:22:26 +00:00
printExeStr ( _gameStateMickey . iClue [ _gameStateMickey . nXtals ] ) ;
2007-09-01 18:46:55 +00:00
2007-09-05 22:38:08 +00:00
#if 0
// DEBUG
2011-08-15 15:22:26 +00:00
drawStr ( 24 , 12 , IDA_DEFAULT , ( char * ) IDS_MSA_NAME_PLANET_2 [ _gameStateMickey . iPlanetXtal [ _gameStateMickey . nXtals ] ] ) ;
drawStr ( 24 , 22 , IDA_DEFAULT , ( char * ) IDS_MSA_ADDR_PLANET [ _gameStateMickey . iPlanetXtal [ _gameStateMickey . nXtals ] ] ) ;
strcpy ( _gameStateMickey . szAddr , ( char * ) IDS_MSA_ADDR_PLANET [ _gameStateMickey . iPlanetXtal [ _gameStateMickey . nXtals ] ] ) ;
_gameStateMickey . nButtons = strlen ( _gameStateMickey . szAddr ) ;
_gfx - > doUpdate ( ) ;
2007-09-01 18:46:55 +00:00
# endif
2007-11-20 20:25:37 +00:00
waitAnyKey ( true ) ;
2007-09-01 18:46:55 +00:00
}
} else {
printStory ( ) ;
}
2007-09-01 14:58:46 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : inventory ( ) {
2007-09-02 01:45:59 +00:00
int iRow = IDI_MSA_ROW_INV_ITEMS ;
2007-09-01 18:46:55 +00:00
char szCrystals [ 12 ] = { 0 } ;
2011-08-15 15:22:26 +00:00
sprintf ( szCrystals , IDS_MSA_CRYSTALS , IDS_MSA_CRYSTAL_NO [ _gameStateMickey . nXtals ] ) ;
2007-09-01 18:46:55 +00:00
2007-09-04 06:54:40 +00:00
CursorMan . showMouse ( false ) ;
2011-08-15 15:22:26 +00:00
clearScreen ( IDA_DEFAULT ) ;
drawStr ( IDI_MSA_ROW_INV_TITLE , IDI_MSA_COL_INV_TITLE , IDA_DEFAULT , IDS_MSA_INVENTORY ) ;
drawStr ( IDI_MSA_ROW_INV_CRYSTALS , IDI_MSA_COL_INV_ITEMS , IDA_DEFAULT , szCrystals ) ;
2007-09-01 18:46:55 +00:00
for ( int iItem = 0 ; iItem < IDI_MSA_MAX_ITEM ; iItem + + ) {
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ _gameStateMickey . iItem [ iItem ] ] & & ( _gameStateMickey . iItem [ iItem ] ! = IDI_MSA_OBJECT_NONE ) ) {
drawStr ( iRow + + , IDI_MSA_COL_INV_ITEMS , IDA_DEFAULT , ( const char * ) IDS_MSA_NAME_ITEM [ _gameStateMickey . iItem [ iItem ] ] ) ;
2007-09-01 18:46:55 +00:00
}
}
2007-09-05 15:43:56 +00:00
waitAnyKey ( ) ;
2007-09-01 18:46:55 +00:00
2011-08-15 15:22:26 +00:00
clearScreen ( IDA_DEFAULT ) ;
2007-09-04 06:54:40 +00:00
CursorMan . showMouse ( true ) ;
2007-09-01 14:58:46 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : intro ( ) {
2007-11-23 18:28:40 +00:00
// Draw Sierra logo
2016-01-29 12:13:40 +00:00
drawLogo ( ) ; // Original does not even show this, so we skip it too
waitAnyKey ( ) ; // Not in the original, but needed so that the logo is visible
2007-09-01 18:46:55 +00:00
2007-09-01 14:58:46 +00:00
// draw title picture
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = IDI_MSA_PIC_TITLE ;
2007-09-01 14:58:46 +00:00
drawRoom ( ) ;
2007-09-19 08:40:12 +00:00
2007-09-01 14:58:46 +00:00
// show copyright and play theme
2007-09-01 18:46:55 +00:00
printExeMsg ( IDO_MSA_COPYRIGHT ) ;
2009-05-24 15:17:42 +00:00
2009-01-05 01:40:08 +00:00
// Quit if necessary
2011-08-15 15:22:26 +00:00
if ( shouldQuit ( ) )
2009-01-05 01:40:08 +00:00
return ;
2009-05-24 15:17:42 +00:00
2007-09-03 01:33:17 +00:00
playSound ( IDI_MSA_SND_THEME ) ;
2007-09-19 08:40:12 +00:00
2007-09-01 14:58:46 +00:00
// load game
2011-08-15 15:22:26 +00:00
_gameStateMickey . fIntro = true ;
2007-09-01 18:46:55 +00:00
if ( chooseY_N ( IDO_MSA_LOAD_GAME [ 0 ] , true ) ) {
if ( loadGame ( ) ) {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iPlanet = IDI_MSA_PLANET_EARTH ;
_gameStateMickey . fIntro = false ;
_gameStateMickey . iRoom = IDI_MSA_PIC_SHIP_CORRIDOR ;
2007-09-01 14:58:46 +00:00
return ;
}
}
2009-05-24 15:17:42 +00:00
2009-01-05 01:40:08 +00:00
// Quit if necessary
2011-08-15 15:22:26 +00:00
if ( shouldQuit ( ) )
2009-01-05 01:40:08 +00:00
return ;
2007-09-01 14:58:46 +00:00
// play spaceship landing scene
2011-08-15 15:22:26 +00:00
_gameStateMickey . iPlanet = IDI_MSA_PLANET_EARTH ;
_gameStateMickey . iRoom = IDI_MSA_PIC_EARTH_ROAD_4 ;
2007-09-01 14:58:46 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
printRoomDesc ( ) ;
2009-05-24 15:17:42 +00:00
2009-01-05 01:40:08 +00:00
// Quit if necessary
2011-08-15 15:22:26 +00:00
if ( shouldQuit ( ) )
2009-01-05 01:40:08 +00:00
return ;
2007-09-01 14:58:46 +00:00
2007-09-03 01:33:17 +00:00
playSound ( IDI_MSA_SND_SHIP_LAND ) ;
2007-09-01 14:58:46 +00:00
2007-09-22 11:31:46 +00:00
// Flash screen 3 times
2009-01-05 01:40:08 +00:00
for ( byte i = 0 ; i < 3 ; i + + ) {
2007-09-22 11:31:46 +00:00
playSound ( IDI_MSA_SND_PRESS_BLUE ) ;
//Set screen to white
2016-01-29 12:13:40 +00:00
_gfx - > clearDisplay ( 15 ) ;
_gfx - > updateScreen ( ) ;
2007-09-22 11:31:46 +00:00
2011-08-15 15:22:26 +00:00
_system - > delayMillis ( IDI_MSA_ANIM_DELAY ) ;
2007-09-22 11:31:46 +00:00
//Set back to black
2016-01-29 12:13:40 +00:00
_gfx - > clearDisplay ( 0 ) ;
_gfx - > updateScreen ( ) ;
2007-09-22 11:31:46 +00:00
drawRoom ( ) ;
2011-08-15 15:22:26 +00:00
printDesc ( _gameStateMickey . iRoom ) ;
2007-09-22 11:31:46 +00:00
}
2007-09-01 14:58:46 +00:00
2007-09-01 18:46:55 +00:00
printExeMsg ( IDO_MSA_INTRO ) ;
2007-09-01 14:58:46 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : getItem ( ENUM_MSA_ITEM iItem ) {
_gameStateMickey . fItem [ iItem ] = true ;
_gameStateMickey . iItem [ _gameStateMickey . nItems + + ] = iItem ;
_gameStateMickey . oRmTxt [ _gameStateMickey . iRoom ] = 0 ;
2007-09-03 01:33:17 +00:00
playSound ( IDI_MSA_SND_TAKE ) ;
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
}
2007-09-01 14:58:46 +00:00
2011-08-15 15:22:26 +00:00
void MickeyEngine : : getXtal ( int iStr ) {
_gameStateMickey . oRmTxt [ _gameStateMickey . iRoom ] = 0 ;
_gameStateMickey . fHasXtal = true ;
_gameStateMickey . nXtals + + ;
2007-09-03 01:33:17 +00:00
playSound ( IDI_MSA_SND_CRYSTAL ) ;
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
printDatMessage ( iStr ) ;
}
2011-08-15 15:22:26 +00:00
bool MickeyEngine : : parse ( int cmd , int arg ) {
2009-09-30 16:16:53 +00:00
switch ( cmd ) {
2007-09-01 18:46:55 +00:00
// BASIC
case IDI_MSA_ACTION_GOTO_ROOM :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = arg ;
2007-09-01 18:46:55 +00:00
return true ;
case IDI_MSA_ACTION_SHOW_INT_STR :
2009-01-18 16:41:35 +00:00
printLine ( IDS_MSA_ERRORS [ arg ] ) ;
2007-09-01 18:46:55 +00:00
break ;
case IDI_MSA_ACTION_SHOW_DAT_STR :
printDatMessage ( arg ) ;
break ;
// GENERAL
case IDI_MSA_ACTION_PLANET_INFO :
showPlanetInfo ( ) ;
break ;
case IDI_MSA_ACTION_SAVE_GAME :
saveGame ( ) ;
break ;
case IDI_MSA_ACTION_LOOK_MICKEY :
2009-01-18 22:02:22 +00:00
printLine ( " YOU CAN SEE MICKEY ALREADY " ) ;
2007-09-01 18:46:55 +00:00
break ;
// EARTH
case IDI_MSA_ACTION_GET_ROPE :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = = 2 ) {
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = IDI_MSA_OBJECT_NONE ;
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 3 ;
2007-09-01 18:46:55 +00:00
getItem ( IDI_MSA_ITEM_ROPE ) ;
2009-01-18 22:02:22 +00:00
printLine ( " MICKEY TAKES THE ROPE " ) ;
2007-09-01 18:46:55 +00:00
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
printDatMessage ( 11 ) ;
}
break ;
case IDI_MSA_ACTION_UNTIE_ROPE :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_EARTH_TIRE_SWING_1 ;
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = 0 ;
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 2 ;
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
printDatMessage ( 12 ) ;
break ;
case IDI_MSA_ACTION_GET_BONE :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = IDI_MSA_OBJECT_NONE ;
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
getItem ( IDI_MSA_ITEM_BONE ) ;
printDatMessage ( arg ) ;
break ;
case IDI_MSA_ACTION_GET_XTAL_EARTH :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
getXtal ( arg ) ;
break ;
case IDI_MSA_ACTION_LOOK_DESK :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = 2 ;
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
printDatMessage ( arg ) ;
break ;
case IDI_MSA_ACTION_WRITE_LETTER :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 3 ;
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_EARTH_MAILBOX ] = 1 ;
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = IDI_MSA_OBJECT_NONE ;
2007-09-01 18:46:55 +00:00
getItem ( IDI_MSA_ITEM_LETTER ) ;
printDatMessage ( arg ) ;
break ;
case IDI_MSA_ACTION_MAIL_LETTER :
2011-08-15 15:22:26 +00:00
_gameStateMickey . fItemUsed [ IDI_MSA_ITEM_LETTER ] = true ;
_gameStateMickey . fItem [ IDI_MSA_ITEM_LETTER ] = false ;
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 0 ;
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
break ;
case IDI_MSA_ACTION_OPEN_MAILBOX :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItemUsed [ IDI_MSA_ITEM_LETTER ] ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 110 ) ;
} else {
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_OPEN_CUPBOARD :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] ) {
if ( _gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = = IDI_MSA_OBJECT_NONE ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 78 ) ;
} else {
printDatMessage ( arg ) ;
}
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_EARTH_KITCHEN_1 ;
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = 3 ;
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GET_FLASHLIGHT :
2007-09-22 10:53:53 +00:00
if ( ! mickeyHasItem ( IDI_MSA_ITEM_FLASHLIGHT ) ) {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = IDI_MSA_OBJECT_NONE ;
2007-09-01 18:46:55 +00:00
getItem ( IDI_MSA_ITEM_FLASHLIGHT ) ;
drawRoom ( ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_OPEN_CABINET :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 109 ) ;
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_EARTH_GARAGE_1 ;
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = 15 ;
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GET_CROWBAR :
2007-09-22 10:53:53 +00:00
if ( ! mickeyHasItem ( IDI_MSA_ITEM_CROWBAR ) ) {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] - - ;
2007-09-01 18:46:55 +00:00
getItem ( IDI_MSA_ITEM_CROWBAR ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GET_WRENCH :
2007-09-22 10:53:53 +00:00
if ( ! mickeyHasItem ( IDI_MSA_ITEM_WRENCH ) ) {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] - = 2 ;
2007-09-01 18:46:55 +00:00
getItem ( IDI_MSA_ITEM_WRENCH ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_OPEN_CLOSET :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 99 ) ;
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_EARTH_BEDROOM_1 ;
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = 7 ;
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GET_MATTRESS :
2007-09-22 10:53:53 +00:00
if ( ! mickeyHasItem ( IDI_MSA_ITEM_MATTRESS ) ) {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] - - ;
2007-09-01 18:46:55 +00:00
getItem ( IDI_MSA_ITEM_MATTRESS ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GET_SCARF :
2007-09-22 10:53:53 +00:00
if ( ! mickeyHasItem ( IDI_MSA_ITEM_SCARF ) ) {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] - = 2 ;
2007-09-01 18:46:55 +00:00
getItem ( IDI_MSA_ITEM_SCARF ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GET_SUNGLASSES :
2007-09-22 10:53:53 +00:00
if ( ! mickeyHasItem ( IDI_MSA_ITEM_SUNGLASSES ) ) {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] - - ;
2007-09-01 18:46:55 +00:00
getItem ( IDI_MSA_ITEM_SUNGLASSES ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GET_SCALE :
2007-09-22 10:53:53 +00:00
if ( ! mickeyHasItem ( IDI_MSA_ITEM_SCALE ) ) {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_VENUS_WEIGH ] = 1 ;
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_NEPTUNE_WEIGH ] = 1 ;
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_MERCURY_WEIGH ] = 1 ;
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_SATURN_WEIGH ] = 1 ;
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_PLUTO_WEIGH ] = 1 ;
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_JUPITER_WEIGH ] = 1 ;
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_MARS_WEIGH ] = 1 ;
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_URANUS_WEIGH ] = 1 ;
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] - = 2 ;
2007-09-01 18:46:55 +00:00
getItem ( IDI_MSA_ITEM_SCALE ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GOTO_SPACESHIP :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = IDI_MSA_PIC_SHIP_AIRLOCK ;
if ( _gameStateMickey . iPlanet ! = IDI_MSA_PLANET_EARTH )
2007-09-01 18:46:55 +00:00
insertDisk ( 0 ) ;
return true ;
// VENUS
case IDI_MSA_ACTION_DOWN_CHASM :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_ROPE ] ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
}
printDatMessage ( arg ) ;
break ;
case IDI_MSA_ACTION_DOWN_ROPE :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItemUsed [ IDI_MSA_ITEM_ROPE ] ) {
_gameStateMickey . iRoom = IDI_MSA_PIC_VENUS_PROBE ;
2007-09-01 18:46:55 +00:00
return true ;
} else {
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_USE_ROPE :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItemUsed [ IDI_MSA_ITEM_ROPE ] ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 22 ) ;
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . fItemUsed [ IDI_MSA_ITEM_ROPE ] = true ;
_gameStateMickey . fItem [ IDI_MSA_ITEM_ROPE ] = false ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_VENUS_CHASM_1 ;
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_OPEN_HATCH :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItemUsed [ IDI_MSA_ITEM_WRENCH ] ) {
if ( ( _gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = = 3 ) | | ( _gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = = IDI_MSA_PIC_VENUS_PROBE_1 ) )
2007-09-01 18:46:55 +00:00
printDatMessage ( 39 ) ;
else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 2 ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_VENUS_PROBE_1 ;
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
printDatMessage ( 24 ) ;
}
} else {
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_WRENCH ] ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
}
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_USE_WRENCH :
2011-08-15 15:22:26 +00:00
_gameStateMickey . fItemUsed [ IDI_MSA_ITEM_WRENCH ] = true ;
2007-09-01 18:46:55 +00:00
printDatString ( arg ) ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = = IDI_MSA_PIC_VENUS_PROBE_1 ) {
clearRow ( 22 ) ;
2007-09-01 18:46:55 +00:00
}
2009-06-06 17:39:13 +00:00
2007-09-05 15:43:56 +00:00
waitAnyKey ( ) ;
2007-09-01 18:46:55 +00:00
break ;
case IDI_MSA_ACTION_GET_XTAL_VENUS :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 3 ;
2007-09-01 18:46:55 +00:00
getXtal ( arg ) ;
break ;
// TRITON (NEPTUNE)
case IDI_MSA_ACTION_LOOK_CASTLE :
2011-08-15 15:22:26 +00:00
if ( ! _gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
}
printDatMessage ( arg ) ;
break ;
case IDI_MSA_ACTION_ENTER_OPENING :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItemUsed [ IDI_MSA_ITEM_CROWBAR ] ) {
_gameStateMickey . iRoom = IDI_MSA_PIC_NEPTUNE_CASTLE_4 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
return true ;
} else {
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_CROWBAR ] ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 2 ;
2007-09-01 18:46:55 +00:00
}
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_USE_CROWBAR :
2011-08-15 15:22:26 +00:00
_gameStateMickey . fItemUsed [ IDI_MSA_ITEM_CROWBAR ] = true ;
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_NEPTUNE_ENTRANCE_1 ;
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
printDatMessage ( arg ) ;
break ;
case IDI_MSA_ACTION_GET_XTAL_NEPTUNE :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fHasXtal ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 71 ) ;
} else {
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_SCARF ] ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
}
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_TALK_LEADER :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = IDI_MSA_PIC_NEPTUNE_ENTRYWAY ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
return true ;
case IDI_MSA_ACTION_GIVE_SCARF :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = 18 ;
2007-09-01 18:46:55 +00:00
getXtal ( arg ) ;
2011-08-15 15:22:26 +00:00
_gameStateMickey . fItem [ IDI_MSA_ITEM_SCARF ] = false ;
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 0 ;
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_EARTH_BEDROOM ] = 2 ;
_gameStateMickey . iRoom = IDI_MSA_PIC_NEPTUNE_ENTRYWAY ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
return true ;
// MERCURY
case IDI_MSA_ACTION_GET_XTAL_MERCURY :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fHasXtal ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 2 ;
2007-09-01 18:46:55 +00:00
printDatMessage ( 32 ) ;
} else {
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_SUNGLASSES ] ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
}
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GIVE_SUNGLASSES :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = 17 ;
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 2 ;
_gameStateMickey . fItem [ IDI_MSA_ITEM_SUNGLASSES ] = false ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
getXtal ( arg ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
break ;
// TITAN (SATURN)
case IDI_MSA_ACTION_CROSS_LAKE :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_MATTRESS ] ) {
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_SATURN_LAKE_0 ] = 1 ;
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_SATURN_LAKE_1 ] = 1 ;
_gameStateMickey . iRmMenu [ IDI_MSA_PIC_SATURN_LAKE_2 ] = 1 ;
2007-09-01 18:46:55 +00:00
}
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
break ;
case IDI_MSA_ACTION_USE_MATTRESS :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = IDI_MSA_PIC_SATURN_ISLAND ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
return true ;
case IDI_MSA_ACTION_GET_XTAL_SATURN :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fHasXtal ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 29 ) ;
} else {
getXtal ( arg ) ;
}
break ;
case IDI_MSA_ACTION_LEAVE_ISLAND :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = IDI_MSA_PIC_SATURN_LAKE_1 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
return true ;
// PLUTO
case IDI_MSA_ACTION_GET_XTAL_PLUTO :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fHasXtal ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 19 ) ;
} else {
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_BONE ] ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
}
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GIVE_BONE :
2011-08-15 15:22:26 +00:00
_gameStateMickey . fItem [ IDI_MSA_ITEM_BONE ] = false ;
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 0 ;
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = 16 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
getXtal ( arg ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
break ;
// IO (JUPITER)
case IDI_MSA_ACTION_GET_ROCK_0 :
case IDI_MSA_ACTION_GET_ROCK_1 :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_ROCK ] ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 38 ) ;
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] = IDI_MSA_OBJECT_NONE ;
2007-09-01 18:46:55 +00:00
getItem ( IDI_MSA_ITEM_ROCK ) ;
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GET_XTAL_JUPITER :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fHasXtal ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 15 ) ;
} else {
2011-08-15 15:22:26 +00:00
switch ( _gameStateMickey . nRocks ) {
2007-09-01 18:46:55 +00:00
case 0 :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_ROCK ] ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
}
printDatMessage ( arg ) ;
break ;
case 1 :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_ROCK ] ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
}
printDatMessage ( 34 ) ;
break ;
case 2 :
getXtal ( 35 ) ;
break ;
}
}
break ;
case IDI_MSA_ACTION_THROW_ROCK :
2011-08-15 15:22:26 +00:00
_gameStateMickey . fItem [ IDI_MSA_ITEM_ROCK ] = false ;
_gameStateMickey . nItems - - ;
_gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] + + ;
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 0 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . nRocks ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 37 ) ;
} else {
printDatMessage ( arg ) ;
}
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . nRocks + + ;
2007-09-01 18:46:55 +00:00
break ;
// MARS
case IDI_MSA_ACTION_GO_TUBE :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_FLASHLIGHT ] ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
}
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
break ;
case IDI_MSA_ACTION_USE_FLASHLIGHT :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = IDI_MSA_PIC_MARS_TUBE_1 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( 15 ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
return true ;
case IDI_MSA_ACTION_PLUTO_DIG :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fHasXtal ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 21 ) ;
} else {
getXtal ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GET_XTAL_MARS :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fHasXtal ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 23 ) ;
} else {
printDatMessage ( arg ) ;
}
break ;
// OBERON (URANUS)
case IDI_MSA_ACTION_ENTER_TEMPLE :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = IDI_MSA_PIC_URANUS_TEMPLE ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
return true ;
case IDI_MSA_ACTION_USE_CRYSTAL :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 25 ) ;
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_URANUS_TEMPLE_1 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_URANUS_TEMPLE ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_OPEN_DOOR :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fTempleDoorOpen ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 36 ) ;
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . fTempleDoorOpen = 1 ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_URANUS_TEMPLE_2 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_ENTER_DOOR :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fTempleDoorOpen ) {
_gameStateMickey . iRoom = IDI_MSA_PIC_URANUS_STEPS ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
return true ;
} else {
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GET_XTAL_URANUS :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fHasXtal ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 34 ) ;
} else {
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fItem [ IDI_MSA_ITEM_CROWBAR ] ) {
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
2007-09-01 18:46:55 +00:00
}
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_USE_CROWBAR_1 :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 0 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
getXtal ( arg ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
break ;
// SPACESHIP
case IDI_MSA_ACTION_GO_NORTH :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fShipDoorOpen ) {
if ( _gameStateMickey . fSuit ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 45 ) ;
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = IDI_MSA_PIC_SHIP_CORRIDOR ;
2007-09-01 18:46:55 +00:00
return true ;
}
} else {
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_GO_PLANET :
2011-08-15 15:22:26 +00:00
if ( ! _gameStateMickey . fShipDoorOpen ) {
if ( ( _gameStateMickey . nXtals = = IDI_MSA_MAX_PLANET ) & & ( _gameStateMickey . iPlanet = = IDI_MSA_PLANET_EARTH ) )
2007-09-01 18:46:55 +00:00
gameOver ( ) ;
2011-08-15 15:22:26 +00:00
if ( ( _gameStateMickey . iPlanet = = _gameStateMickey . iPlanetXtal [ _gameStateMickey . nXtals ] ) | | ( _gameStateMickey . iPlanet = = IDI_MSA_PLANET_EARTH ) ) {
_gameStateMickey . fHasXtal = false ;
_gameStateMickey . iRoom = IDI_MSA_HOME_PLANET [ _gameStateMickey . iPlanet ] ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iPlanet ! = IDI_MSA_PLANET_EARTH )
2007-09-01 18:46:55 +00:00
insertDisk ( 1 ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
return true ;
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = IDI_MSA_SHIP_PLANET [ _gameStateMickey . iPlanet ] ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
return true ;
}
} else {
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_PRESS_BUTTON :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fShipDoorOpen ) { // inner door open
if ( _gameStateMickey . iPlanet & & ! _gameStateMickey . fSuit ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . fShipDoorOpen = false ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] - - ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( 2 ) ;
}
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . fShipDoorOpen = true ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] + + ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( 14 ) ;
}
break ;
case IDI_MSA_ACTION_WEAR_SPACESUIT :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fSuit ) {
if ( _gameStateMickey . fShipDoorOpen ) {
_gameStateMickey . fSuit = false ;
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 0 ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] - = 2 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( 13 ) ;
} else {
printDatMessage ( 3 ) ;
}
} else {
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iPlanet ) {
_gameStateMickey . fSuit = true ;
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] + = 2 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
} else {
printDatMessage ( 12 ) ;
}
}
break ;
case IDI_MSA_ACTION_READ_GAUGE :
printDatString ( arg ) ;
2011-08-15 15:22:26 +00:00
drawStr ( 21 , 15 , IDA_DEFAULT , ( const char * ) IDS_MSA_TEMP_C [ _gameStateMickey . iPlanet ] ) ;
drawStr ( 21 , 23 , IDA_DEFAULT , ( const char * ) IDS_MSA_TEMP_F [ _gameStateMickey . iPlanet ] ) ;
2009-06-06 17:39:13 +00:00
2007-09-05 15:43:56 +00:00
waitAnyKey ( ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
break ;
case IDI_MSA_ACTION_PRESS_ORANGE :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fFlying ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 4 ) ;
} else {
2007-09-03 01:33:17 +00:00
playSound ( IDI_MSA_SND_PRESS_ORANGE ) ;
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
pressOB ( IDI_MSA_BUTTON_ORANGE ) ;
}
break ;
case IDI_MSA_ACTION_PRESS_BLUE :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fFlying ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 4 ) ;
} else {
2007-09-03 01:33:17 +00:00
playSound ( IDI_MSA_SND_PRESS_BLUE ) ;
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
pressOB ( IDI_MSA_BUTTON_BLUE ) ;
}
break ;
case IDI_MSA_ACTION_FLIP_SWITCH :
flipSwitch ( ) ;
break ;
case IDI_MSA_ACTION_PUSH_THROTTLE :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fFlying ) {
_gameStateMickey . fFlying = false ;
_gameStateMickey . nButtons = 0 ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
memset ( _gameStateMickey . szAddr , 0 , sizeof ( _gameStateMickey . szAddr ) ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatString ( 22 ) ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
drawStr ( IDI_MSA_ROW_PLANET , IDI_MSA_COL_PLANET , IDA_DEFAULT ,
( const char * ) IDS_MSA_PLANETS [ _gameStateMickey . iPlanet ] ) ;
2009-06-06 17:39:13 +00:00
2007-11-20 20:25:37 +00:00
waitAnyKey ( true ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
showPlanetInfo ( ) ;
} else {
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_PULL_THROTTLE :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fFlying ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 18 ) ;
} else {
if ( getPlanet ( ) ! = - 1 ) {
2011-08-15 15:22:26 +00:00
_gameStateMickey . fFlying = true ;
_gameStateMickey . iPlanet = getPlanet ( ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( 16 ) ;
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . nButtons = 0 ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
memset ( _gameStateMickey . szAddr , 0 , sizeof ( _gameStateMickey . szAddr ) ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( 17 ) ;
}
}
break ;
case IDI_MSA_ACTION_LEAVE_ROOM :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fFlying ) {
2007-09-01 18:46:55 +00:00
printDatMessage ( 24 ) ;
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = arg ;
2007-09-01 18:46:55 +00:00
return true ;
}
break ;
case IDI_MSA_ACTION_OPEN_CABINET_1 :
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] ) {
2009-01-18 22:02:22 +00:00
printLine ( " THE CABINET IS ALREADY OPEN " ) ;
2007-09-01 18:46:55 +00:00
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmMenu [ _gameStateMickey . iRoom ] = 1 ;
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_SHIP_KITCHEN_1 ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( arg ) ;
}
break ;
case IDI_MSA_ACTION_READ_MAP :
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_STAR_MAP ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
printDatMessage ( 46 ) ;
printDatMessage ( 47 ) ;
printDatMessage ( 48 ) ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmPic [ _gameStateMickey . iRoom ] = IDI_MSA_PIC_SHIP_BEDROOM ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
drawRoom ( ) ;
break ;
case IDI_MSA_ACTION_GO_WEST :
2011-08-15 15:22:26 +00:00
_gameStateMickey . nButtons = 0 ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
memset ( _gameStateMickey . szAddr , 0 , sizeof ( _gameStateMickey . szAddr ) ) ;
2009-06-06 17:39:13 +00:00
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRoom = arg ;
2009-06-06 17:39:13 +00:00
2007-09-01 18:46:55 +00:00
return true ;
}
return false ;
}
2007-09-05 15:43:56 +00:00
// Keyboard
2011-08-15 15:22:26 +00:00
void MickeyEngine : : waitAnyKey ( bool anim ) {
2007-09-05 15:43:56 +00:00
Common : : Event event ;
2007-09-06 01:18:13 +00:00
2007-09-19 09:54:42 +00:00
if ( ! anim )
2016-01-29 12:13:40 +00:00
_gfx - > updateScreen ( ) ;
2007-09-06 01:18:13 +00:00
2011-08-15 15:22:26 +00:00
while ( ! shouldQuit ( ) ) {
while ( _system - > getEventManager ( ) - > pollEvent ( event ) ) {
2009-09-30 16:16:53 +00:00
switch ( event . type ) {
2008-07-16 04:22:56 +00:00
case Common : : EVENT_RTL :
2007-09-05 15:43:56 +00:00
case Common : : EVENT_QUIT :
case Common : : EVENT_KEYDOWN :
case Common : : EVENT_LBUTTONUP :
case Common : : EVENT_RBUTTONUP :
return ;
default :
break ;
}
}
2009-05-24 15:17:42 +00:00
2007-09-05 15:43:56 +00:00
if ( anim ) {
animate ( ) ;
}
2007-09-19 09:54:42 +00:00
2016-01-29 12:13:40 +00:00
_gfx - > updateScreen ( ) ;
2011-08-15 15:22:26 +00:00
_system - > delayMillis ( 10 ) ;
2007-09-05 15:43:56 +00:00
}
}
2008-01-09 09:19:17 +00:00
// Console-related functions
2011-08-15 15:22:26 +00:00
void MickeyEngine : : debugCurRoom ( ) {
2014-05-27 00:04:07 +00:00
_console - > debugPrintf ( " Current Room = %d \n " , _gameStateMickey . iRoom ) ;
2008-01-09 09:46:26 +00:00
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] ! = IDI_MSA_OBJECT_NONE ) {
2014-05-27 00:04:07 +00:00
_console - > debugPrintf ( " Object %d is in the room \n " , _gameStateMickey . iRmObj [ _gameStateMickey . iRoom ] ) ;
2008-01-09 09:46:26 +00:00
}
2008-01-09 09:19:17 +00:00
}
2007-09-01 18:46:55 +00:00
2011-08-15 15:22:26 +00:00
void MickeyEngine : : debugGotoRoom ( int room ) {
_gameStateMickey . iRoom = room ;
2008-01-09 10:31:52 +00:00
drawRoom ( ) ;
}
2011-08-15 15:22:26 +00:00
MickeyEngine : : MickeyEngine ( OSystem * syst , const AGIGameDescription * gameDesc ) : PreAgiEngine ( syst , gameDesc ) {
2011-08-16 02:03:58 +00:00
_console = new MickeyConsole ( this ) ;
2007-09-22 13:27:10 +00:00
}
2011-08-15 15:22:26 +00:00
MickeyEngine : : ~ MickeyEngine ( ) {
2011-08-16 02:03:58 +00:00
delete _console ;
2007-09-22 13:27:10 +00:00
}
2011-08-15 15:22:26 +00:00
void MickeyEngine : : init ( ) {
2007-09-01 18:46:55 +00:00
uint8 buffer [ 512 ] ;
// clear game struct
2011-08-15 15:22:26 +00:00
memset ( & _gameStateMickey , 0 , sizeof ( _gameStateMickey ) ) ;
memset ( & _gameStateMickey . iItem , IDI_MSA_OBJECT_NONE , sizeof ( _gameStateMickey . iItem ) ) ;
2007-09-01 18:46:55 +00:00
// read room extended desc flags
2007-09-22 10:10:01 +00:00
//readExe(IDO_MSA_ROOM_TEXT, buffer, sizeof(buffer));
2011-08-15 15:22:26 +00:00
//memcpy(_gameStateMickey.fRmTxt, buffer, sizeof(_gameStateMickey.fRmTxt));
2007-09-01 18:46:55 +00:00
// read room extended desc offsets
readExe ( IDO_MSA_ROOM_TEXT_OFFSETS , buffer , sizeof ( buffer ) ) ;
2011-08-15 15:22:26 +00:00
memcpy ( _gameStateMickey . oRmTxt , buffer , sizeof ( _gameStateMickey . oRmTxt ) ) ;
2007-09-01 18:46:55 +00:00
for ( int i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + )
2011-08-15 15:22:26 +00:00
_gameStateMickey . oRmTxt [ i ] = buffer [ i * 2 ] + 256 * buffer [ i * 2 + 1 ] ;
2007-09-01 18:46:55 +00:00
// read room object indices
2007-09-22 10:10:01 +00:00
//readExe(IDO_MSA_ROOM_OBJECT, buffer, sizeof(buffer));
2011-08-15 15:22:26 +00:00
//memcpy(_gameStateMickey.iRmObj, buffer, sizeof(_gameStateMickey.iRmObj));
2007-09-19 08:40:12 +00:00
2007-09-01 18:46:55 +00:00
// read room picture indices
2007-09-03 00:47:51 +00:00
//readExe(IDO_MSA_ROOM_PICTURE, buffer, sizeof(buffer));
2011-08-15 15:22:26 +00:00
//memcpy(_gameStateMickey.iRmPic, buffer, sizeof(_gameStateMickey.iRmPic));
2007-09-01 18:46:55 +00:00
// read room menu patch indices
readExe ( IDO_MSA_ROOM_MENU_FIX , buffer , sizeof ( buffer ) ) ;
2011-08-15 15:22:26 +00:00
memcpy ( _gameStateMickey . nRmMenu , buffer , sizeof ( _gameStateMickey . nRmMenu ) ) ;
2007-09-01 18:46:55 +00:00
2007-09-22 10:10:01 +00:00
// set room picture and room object indices
2007-09-01 18:46:55 +00:00
for ( int i = 0 ; i < IDI_MSA_MAX_ROOM ; i + + ) {
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmPic [ i ] = i ;
_gameStateMickey . iRmObj [ i ] = - 1 ;
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
_gameStateMickey . iRmPic [ IDI_MSA_PIC_SHIP_AIRLOCK ] = IDI_MSA_PIC_SHIP_AIRLOCK_0 ;
_gameStateMickey . iRmObj [ IDI_MSA_PIC_EARTH_BATHROOM ] = 11 ;
_gameStateMickey . iRmObj [ IDI_MSA_PIC_JUPITER_LAVA ] = 21 ;
_gameStateMickey . iRmObj [ IDI_MSA_PIC_JUPITER_ROCK_0 ] = 20 ;
_gameStateMickey . iRmObj [ IDI_MSA_PIC_JUPITER_ROCK_1 ] = 19 ;
_gameStateMickey . iRmObj [ IDI_MSA_PIC_EARTH_IN_DOGHOUSE ] = 1 ;
2007-09-01 18:46:55 +00:00
2007-09-05 22:38:08 +00:00
#if 0
// DEBUG
2011-08-15 15:22:26 +00:00
_gameStateMickey . iPlanet = IDI_MSA_PLANET_EARTH ;
_gameStateMickey . iRoom = IDI_MSA_PIC_SHIP_CONTROLS ;
_gameStateMickey . fHasXtal = true ;
_gameStateMickey . nXtals = 9 ;
_gameStateMickey . fItemUsed [ IDI_MSA_ITEM_LETTER ] = true ;
2007-09-01 18:46:55 +00:00
# endif
2015-07-19 09:51:46 +00:00
2016-01-31 16:56:53 +00:00
setFlag ( VM_FLAG_SOUND_ON , true ) ; // enable sound
2007-09-01 18:46:55 +00:00
}
2011-08-15 15:22:26 +00:00
Common : : Error MickeyEngine : : go ( ) {
init ( ) ;
2007-09-01 18:46:55 +00:00
2007-09-22 13:27:10 +00:00
// Game intro
intro ( ) ;
2007-09-01 18:46:55 +00:00
2007-09-22 13:27:10 +00:00
// Game loop
2011-08-15 15:22:26 +00:00
while ( ! shouldQuit ( ) ) {
2007-09-22 13:27:10 +00:00
drawRoom ( ) ;
2007-09-01 18:46:55 +00:00
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fIntro ) {
_gameStateMickey . fIntro = false ;
2007-09-22 13:27:10 +00:00
} else {
printRoomDesc ( ) ;
}
2011-08-15 15:22:26 +00:00
bool done ;
if ( _gameStateMickey . iRoom = = IDI_MSA_PIC_NEPTUNE_GUARD ) {
_gameStateMickey . iRoom = IDI_MSA_PIC_NEPTUNE_LEADER ;
2007-09-22 13:27:10 +00:00
done = true ;
} else {
done = false ;
}
2011-08-15 15:22:26 +00:00
while ( ! done & & ! shouldQuit ( ) ) {
2007-09-22 13:27:10 +00:00
// Check air supply
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . fSuit ) {
_gameStateMickey . nAir - = 1 ;
2007-09-22 13:27:10 +00:00
for ( int i = 0 ; i < 4 ; i + + ) {
2011-08-15 15:22:26 +00:00
if ( _gameStateMickey . nAir = = IDI_MSA_AIR_SUPPLY [ i ] ) {
2007-09-22 13:27:10 +00:00
playSound ( IDI_MSA_SND_XL30 ) ;
printExeMsg ( IDO_MSA_XL30_SPEAKING ) ;
printExeMsg ( IDO_MSA_AIR_SUPPLY [ i ] ) ;
2009-01-05 01:40:08 +00:00
if ( i = = 3 )
2011-08-15 15:22:26 +00:00
return Common : : kNoError ;
2007-09-22 13:27:10 +00:00
}
}
} else {
2011-08-15 15:22:26 +00:00
_gameStateMickey . nAir = 50 ; // max air supply
2007-09-22 13:27:10 +00:00
}
2008-01-09 10:31:52 +00:00
done = checkMenu ( ) ;
2007-09-22 13:27:10 +00:00
}
2011-08-15 15:22:26 +00:00
_gameStateMickey . nFrame = 0 ;
2007-09-22 13:27:10 +00:00
}
2007-09-01 18:46:55 +00:00
gameOver ( ) ;
2007-09-01 14:58:46 +00:00
2011-08-15 15:22:26 +00:00
return Common : : kNoError ;
2007-09-01 14:58:46 +00:00
}
2011-08-15 15:22:26 +00:00
} // End of namespace Agi