2009-05-20 17:51:55 +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.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/system.h"
|
|
|
|
|
|
|
|
#include "sci/sci.h"
|
2009-06-04 11:28:05 +00:00
|
|
|
#include "sci/debug.h"
|
2009-12-04 17:38:24 +00:00
|
|
|
#include "sci/event.h"
|
2009-05-20 17:51:55 +00:00
|
|
|
#include "sci/engine/state.h"
|
|
|
|
#include "sci/engine/kernel.h"
|
|
|
|
#include "sci/engine/gc.h"
|
2010-01-05 01:22:16 +00:00
|
|
|
#include "sci/graphics/gui.h"
|
2010-05-24 17:21:11 +00:00
|
|
|
#include "sci/graphics/maciconbar.h"
|
2009-05-20 17:51:55 +00:00
|
|
|
|
|
|
|
namespace Sci {
|
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kRestartGame(EngineState *s, int argc, reg_t *argv) {
|
2009-05-20 17:51:55 +00:00
|
|
|
s->restarting_flags |= SCI_GAME_IS_RESTARTING_NOW;
|
2009-05-28 22:42:18 +00:00
|
|
|
|
2010-05-23 16:44:36 +00:00
|
|
|
s->shrinkStackToBase();
|
2009-05-28 22:42:18 +00:00
|
|
|
|
2009-05-20 17:51:55 +00:00
|
|
|
script_abort_flag = 1; // Force vm to abort ASAP
|
|
|
|
return NULL_REG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* kGameIsRestarting():
|
|
|
|
** Returns the restarting_flag in acc
|
|
|
|
*/
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kGameIsRestarting(EngineState *s, int argc, reg_t *argv) {
|
2009-05-20 17:51:55 +00:00
|
|
|
s->r_acc = make_reg(0, (s->restarting_flags & SCI_GAME_WAS_RESTARTED));
|
|
|
|
|
|
|
|
if (argc) { // Only happens during replay
|
2009-06-07 15:53:30 +00:00
|
|
|
if (!argv[0].toUint16()) // Set restarting flag
|
2009-05-20 17:51:55 +00:00
|
|
|
s->restarting_flags &= ~SCI_GAME_WAS_RESTARTED;
|
|
|
|
}
|
|
|
|
|
2010-05-17 09:32:16 +00:00
|
|
|
uint32 neededSleep = 30;
|
|
|
|
|
2010-01-17 20:23:11 +00:00
|
|
|
// WORKAROUND:
|
2010-01-17 20:17:00 +00:00
|
|
|
// LSL3 calculates a machinespeed variable during game startup (right after the filthy questions)
|
|
|
|
// This one would go through w/o throttling resulting in having to do 1000 pushups or something
|
|
|
|
// Another way of handling this would be delaying incrementing of "machineSpeed" selector
|
2010-05-23 10:28:03 +00:00
|
|
|
if (!strcmp(g_sci->getGameID(), "lsl3") && s->currentRoomNumber() == 290)
|
2010-01-17 20:17:00 +00:00
|
|
|
s->_throttleTrigger = true;
|
2010-05-23 10:28:03 +00:00
|
|
|
if (!strcmp(g_sci->getGameID(), "iceman") && s->currentRoomNumber() == 27) {
|
2010-05-17 09:32:16 +00:00
|
|
|
s->_throttleTrigger = true;
|
|
|
|
neededSleep = 60;
|
|
|
|
}
|
2010-01-17 20:17:00 +00:00
|
|
|
|
2010-01-17 18:41:28 +00:00
|
|
|
if (s->_throttleTrigger) {
|
2010-01-17 20:17:00 +00:00
|
|
|
// Some games seem to get the duration of main loop initially and then switch of animations for the whole game
|
|
|
|
// based on that (qfg2, iceman). We are now running full speed initially to avoid that.
|
|
|
|
// It seems like we dont need to do that anymore
|
2010-01-17 18:41:28 +00:00
|
|
|
//if (s->_throttleCounter < 50) {
|
|
|
|
// s->_throttleCounter++;
|
|
|
|
// return s->r_acc;
|
|
|
|
//}
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-01-17 18:41:28 +00:00
|
|
|
uint32 curTime = g_system->getMillis();
|
|
|
|
uint32 duration = curTime - s->_throttleLastTime;
|
2009-10-23 11:25:48 +00:00
|
|
|
|
2010-01-17 18:41:28 +00:00
|
|
|
if (duration < neededSleep) {
|
2010-02-23 22:47:53 +00:00
|
|
|
s->_event->sleep(neededSleep - duration);
|
2010-01-17 18:41:28 +00:00
|
|
|
s->_throttleLastTime = g_system->getMillis();
|
|
|
|
} else {
|
|
|
|
s->_throttleLastTime = curTime;
|
|
|
|
}
|
|
|
|
s->_throttleTrigger = false;
|
2009-10-22 21:30:30 +00:00
|
|
|
}
|
|
|
|
|
2009-05-20 17:51:55 +00:00
|
|
|
return s->r_acc;
|
|
|
|
}
|
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kHaveMouse(EngineState *s, int argc, reg_t *argv) {
|
2009-09-30 23:00:03 +00:00
|
|
|
return SIGNAL_REG;
|
2009-05-20 17:51:55 +00:00
|
|
|
}
|
|
|
|
|
2009-08-20 21:18:52 +00:00
|
|
|
enum kMemoryInfoFunc {
|
|
|
|
K_MEMORYINFO_LARGEST_HEAP_BLOCK = 0, // Largest heap block available
|
|
|
|
K_MEMORYINFO_FREE_HEAP = 1, // Total free heap memory
|
|
|
|
K_MEMORYINFO_LARGEST_HUNK_BLOCK = 2, // Largest available hunk memory block
|
|
|
|
K_MEMORYINFO_FREE_HUNK = 3, // Amount of free DOS paragraphs
|
|
|
|
K_MEMORYINFO_TOTAL_HUNK = 4 // Total amount of hunk memory (SCI01)
|
|
|
|
};
|
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kMemoryInfo(EngineState *s, int argc, reg_t *argv) {
|
2009-09-25 13:01:35 +00:00
|
|
|
const uint16 size = 0x7fff; // Must not be 0xffff, or some memory calculations will overflow
|
2009-08-20 21:18:52 +00:00
|
|
|
|
2009-05-20 17:51:55 +00:00
|
|
|
switch (argv[0].offset) {
|
2009-08-20 21:18:52 +00:00
|
|
|
case K_MEMORYINFO_LARGEST_HEAP_BLOCK:
|
|
|
|
// In order to prevent "Memory fragmented" dialogs from
|
|
|
|
// popping up in some games, we must return FREE_HEAP - 2 here.
|
|
|
|
return make_reg(0, size - 2);
|
|
|
|
case K_MEMORYINFO_FREE_HEAP:
|
|
|
|
case K_MEMORYINFO_LARGEST_HUNK_BLOCK:
|
|
|
|
case K_MEMORYINFO_FREE_HUNK:
|
|
|
|
case K_MEMORYINFO_TOTAL_HUNK:
|
|
|
|
return make_reg(0, size);
|
2009-05-20 17:51:55 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
warning("Unknown MemoryInfo operation: %04x", argv[0].offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL_REG;
|
|
|
|
}
|
|
|
|
|
2010-01-31 19:47:54 +00:00
|
|
|
enum kMemorySegmentFunc {
|
|
|
|
K_MEMORYSEGMENT_SAVE_DATA = 0,
|
|
|
|
K_MEMORYSEGMENT_RESTORE_DATA = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
reg_t kMemorySegment(EngineState *s, int argc, reg_t *argv) {
|
|
|
|
// MemorySegment provides access to a 256-byte block of memory that remains
|
|
|
|
// intact across restarts and restores
|
|
|
|
|
|
|
|
switch (argv[0].toUint16()) {
|
|
|
|
case K_MEMORYSEGMENT_SAVE_DATA: {
|
|
|
|
if (argc < 3)
|
|
|
|
error("Insufficient number of arguments passed to MemorySegment");
|
|
|
|
uint16 size = argv[2].toUint16();
|
|
|
|
|
|
|
|
if (!size)
|
|
|
|
size = s->_segMan->strlen(argv[1]) + 1;
|
|
|
|
|
|
|
|
if (size > EngineState::kMemorySegmentMax)
|
|
|
|
size = EngineState::kMemorySegmentMax;
|
|
|
|
|
|
|
|
s->_memorySegmentSize = size;
|
|
|
|
|
|
|
|
// We assume that this won't be called on pointers
|
|
|
|
s->_segMan->memcpy(s->_memorySegment, argv[1], size);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case K_MEMORYSEGMENT_RESTORE_DATA:
|
|
|
|
s->_segMan->memcpy(argv[1], s->_memorySegment, s->_memorySegmentSize);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("Unknown MemorySegment operation %04x", argv[0].toUint16());
|
|
|
|
}
|
|
|
|
|
|
|
|
return argv[1];
|
|
|
|
}
|
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kFlushResources(EngineState *s, int argc, reg_t *argv) {
|
2010-02-06 19:41:55 +00:00
|
|
|
run_gc(s);
|
2009-06-07 15:53:30 +00:00
|
|
|
debugC(2, kDebugLevelRoom, "Entering room number %d", argv[0].toUint16());
|
2009-05-20 17:51:55 +00:00
|
|
|
return s->r_acc;
|
|
|
|
}
|
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kSetDebug(EngineState *s, int argc, reg_t *argv) {
|
2009-07-06 10:39:22 +00:00
|
|
|
printf("Debug mode activated\n");
|
2009-05-20 17:51:55 +00:00
|
|
|
|
2009-09-17 13:21:19 +00:00
|
|
|
g_debugState.seeking = kDebugSeekNothing;
|
|
|
|
g_debugState.runningStep = 0;
|
2009-05-20 17:51:55 +00:00
|
|
|
return s->r_acc;
|
|
|
|
}
|
|
|
|
|
2009-05-20 17:52:12 +00:00
|
|
|
enum {
|
2009-09-25 13:01:35 +00:00
|
|
|
K_NEW_GETTIME_TICKS = 0,
|
|
|
|
K_NEW_GETTIME_TIME_12HOUR = 1,
|
|
|
|
K_NEW_GETTIME_TIME_24HOUR = 2,
|
|
|
|
K_NEW_GETTIME_DATE = 3
|
2009-05-20 17:52:12 +00:00
|
|
|
};
|
2009-05-20 17:51:55 +00:00
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kGetTime(EngineState *s, int argc, reg_t *argv) {
|
2009-10-08 19:41:38 +00:00
|
|
|
TimeDate loc_time;
|
2009-10-06 17:45:57 +00:00
|
|
|
uint32 elapsedTime;
|
2009-05-20 17:51:55 +00:00
|
|
|
int retval = 0; // Avoid spurious warning
|
|
|
|
|
|
|
|
g_system->getTimeAndDate(loc_time);
|
2009-10-06 17:45:57 +00:00
|
|
|
elapsedTime = g_system->getMillis() - s->game_start_time;
|
2009-05-20 17:51:55 +00:00
|
|
|
|
2009-06-07 16:50:34 +00:00
|
|
|
int mode = (argc > 0) ? argv[0].toUint16() : 0;
|
2009-05-20 17:51:55 +00:00
|
|
|
|
2009-10-09 23:15:54 +00:00
|
|
|
if (getSciVersion() <= SCI_VERSION_0_LATE && mode > 1)
|
|
|
|
warning("kGetTime called in SCI0 with mode %d (expected 0 or 1)", mode);
|
|
|
|
|
2009-05-20 17:51:55 +00:00
|
|
|
switch (mode) {
|
2009-09-25 13:01:35 +00:00
|
|
|
case K_NEW_GETTIME_TICKS :
|
2009-10-06 17:45:57 +00:00
|
|
|
retval = elapsedTime * 60 / 1000;
|
2009-05-20 17:51:55 +00:00
|
|
|
debugC(2, kDebugLevelTime, "GetTime(elapsed) returns %d", retval);
|
|
|
|
break;
|
2009-09-25 13:01:35 +00:00
|
|
|
case K_NEW_GETTIME_TIME_12HOUR :
|
2009-05-21 10:34:13 +00:00
|
|
|
retval = ((loc_time.tm_hour % 12) << 12) | (loc_time.tm_min << 6) | (loc_time.tm_sec);
|
2009-05-20 17:51:55 +00:00
|
|
|
debugC(2, kDebugLevelTime, "GetTime(12h) returns %d", retval);
|
|
|
|
break;
|
2009-09-25 13:01:35 +00:00
|
|
|
case K_NEW_GETTIME_TIME_24HOUR :
|
2009-05-21 10:34:13 +00:00
|
|
|
retval = (loc_time.tm_hour << 11) | (loc_time.tm_min << 5) | (loc_time.tm_sec >> 1);
|
2009-05-20 17:51:55 +00:00
|
|
|
debugC(2, kDebugLevelTime, "GetTime(24h) returns %d", retval);
|
|
|
|
break;
|
2009-09-25 13:01:35 +00:00
|
|
|
case K_NEW_GETTIME_DATE :
|
2009-05-21 10:34:13 +00:00
|
|
|
retval = loc_time.tm_mday | ((loc_time.tm_mon + 1) << 5) | (((loc_time.tm_year + 1900) & 0x7f) << 9);
|
2009-05-20 17:51:55 +00:00
|
|
|
debugC(2, kDebugLevelTime, "GetTime(date) returns %d", retval);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
warning("Attempt to use unknown GetTime mode %d", mode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return make_reg(0, retval);
|
|
|
|
}
|
|
|
|
|
2009-05-20 17:52:12 +00:00
|
|
|
enum {
|
|
|
|
K_MEMORY_ALLOCATE_CRITICAL = 1,
|
|
|
|
K_MEMORY_ALLOCATE_NONCRITICAL = 2,
|
|
|
|
K_MEMORY_FREE = 3,
|
|
|
|
K_MEMORY_MEMCPY = 4,
|
|
|
|
K_MEMORY_PEEK = 5,
|
|
|
|
K_MEMORY_POKE = 6
|
|
|
|
};
|
2009-05-20 17:51:55 +00:00
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kMemory(EngineState *s, int argc, reg_t *argv) {
|
2009-06-07 15:53:30 +00:00
|
|
|
switch (argv[0].toUint16()) {
|
2009-05-20 17:51:55 +00:00
|
|
|
case K_MEMORY_ALLOCATE_CRITICAL :
|
2009-10-04 18:38:18 +00:00
|
|
|
if (!s->_segMan->allocDynmem(argv[1].toUint16(), "kMemory() critical", &s->r_acc)) {
|
2009-05-27 00:24:32 +00:00
|
|
|
error("Critical heap allocation failed");
|
2009-05-20 17:51:55 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case K_MEMORY_ALLOCATE_NONCRITICAL :
|
2009-10-04 18:38:18 +00:00
|
|
|
s->_segMan->allocDynmem(argv[1].toUint16(), "kMemory() non-critical", &s->r_acc);
|
2009-05-20 17:51:55 +00:00
|
|
|
break;
|
|
|
|
case K_MEMORY_FREE :
|
2009-10-04 18:38:18 +00:00
|
|
|
if (s->_segMan->freeDynmem(argv[1])) {
|
2009-05-27 00:24:32 +00:00
|
|
|
error("Attempt to kMemory::free() non-dynmem pointer %04x:%04x", PRINT_REG(argv[1]));
|
2009-05-20 17:51:55 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case K_MEMORY_MEMCPY : {
|
2009-06-07 15:53:30 +00:00
|
|
|
int size = argv[3].toUint16();
|
2009-10-04 18:38:18 +00:00
|
|
|
s->_segMan->memcpy(argv[1], argv[2], size);
|
2009-05-20 17:51:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case K_MEMORY_PEEK : {
|
2009-10-04 18:38:18 +00:00
|
|
|
SegmentRef ref = s->_segMan->dereference(argv[1]);
|
2009-05-20 17:51:55 +00:00
|
|
|
|
2009-09-27 01:50:26 +00:00
|
|
|
if (!ref.isValid() || ref.maxSize < 2) {
|
2009-05-23 10:22:27 +00:00
|
|
|
// This occurs in KQ5CD when interacting with certain objects
|
2009-05-27 12:46:11 +00:00
|
|
|
warning("Attempt to peek invalid memory at %04x:%04x", PRINT_REG(argv[1]));
|
2009-05-20 17:51:55 +00:00
|
|
|
return s->r_acc;
|
|
|
|
}
|
2009-09-27 01:50:26 +00:00
|
|
|
if (ref.isRaw)
|
|
|
|
return make_reg(0, (int16)READ_LE_UINT16(ref.raw));
|
2010-01-26 19:51:08 +00:00
|
|
|
else {
|
|
|
|
if (ref.skipByte)
|
|
|
|
error("Attempt to peek memory at odd offset %04X:%04X", PRINT_REG(argv[1]));
|
2009-09-27 01:50:26 +00:00
|
|
|
return *(ref.reg);
|
2010-01-26 19:51:08 +00:00
|
|
|
}
|
2009-05-20 17:51:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case K_MEMORY_POKE : {
|
2009-10-04 18:38:18 +00:00
|
|
|
SegmentRef ref = s->_segMan->dereference(argv[1]);
|
2009-05-20 17:51:55 +00:00
|
|
|
|
2009-09-27 01:50:26 +00:00
|
|
|
if (!ref.isValid() || ref.maxSize < 2) {
|
2009-05-27 00:24:32 +00:00
|
|
|
warning("Attempt to poke invalid memory at %04x:%04x", PRINT_REG(argv[1]));
|
2009-05-20 17:51:55 +00:00
|
|
|
return s->r_acc;
|
|
|
|
}
|
|
|
|
|
2009-09-27 01:50:26 +00:00
|
|
|
if (ref.isRaw) {
|
2009-05-20 17:51:55 +00:00
|
|
|
if (argv[2].segment) {
|
2009-05-27 00:24:32 +00:00
|
|
|
error("Attempt to poke memory reference %04x:%04x to %04x:%04x", PRINT_REG(argv[2]), PRINT_REG(argv[1]));
|
2009-05-20 17:51:55 +00:00
|
|
|
return s->r_acc;
|
|
|
|
}
|
2009-09-27 01:50:26 +00:00
|
|
|
WRITE_LE_UINT16(ref.raw, argv[2].offset);
|
2010-01-26 19:51:08 +00:00
|
|
|
} else {
|
|
|
|
if (ref.skipByte)
|
|
|
|
error("Attempt to poke memory at odd offset %04X:%04X", PRINT_REG(argv[1]));
|
2009-09-27 01:50:26 +00:00
|
|
|
*(ref.reg) = argv[2];
|
2010-01-26 19:51:08 +00:00
|
|
|
}
|
2009-05-20 17:51:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return s->r_acc;
|
|
|
|
}
|
|
|
|
|
2010-05-18 04:17:58 +00:00
|
|
|
// kIconBar is really a subop of kPlatform for SCI1.1 Mac
|
|
|
|
reg_t kIconBar(EngineState *s, int argc, reg_t *argv) {
|
|
|
|
// TODO...
|
|
|
|
|
2010-05-24 17:21:11 +00:00
|
|
|
if (argv[0].toUint16() == 4 && argv[1].toUint16() == 0) {
|
2010-05-18 04:17:58 +00:00
|
|
|
for (int i = 0; i < argv[2].toUint16(); i++)
|
2010-05-24 17:21:11 +00:00
|
|
|
g_sci->_macIconBar->addIcon(argv[i + 3]);
|
|
|
|
|
|
|
|
g_sci->_macIconBar->drawIcons();
|
|
|
|
}
|
2010-05-18 04:17:58 +00:00
|
|
|
|
|
|
|
// Other calls seem to handle selecting/deselecting them
|
|
|
|
|
|
|
|
return NULL_REG;
|
|
|
|
}
|
|
|
|
|
2009-10-30 22:53:00 +00:00
|
|
|
enum kSciPlatforms {
|
|
|
|
kSciPlatformDOS = 1,
|
|
|
|
kSciPlatformWindows = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
enum kPlatformOps {
|
2009-12-27 19:16:06 +00:00
|
|
|
kPlatformUnk0 = 0,
|
|
|
|
kPlatformCDSpeed = 1,
|
|
|
|
kPlatformUnk2 = 2,
|
|
|
|
kPlatformCDCheck = 3,
|
2009-10-30 22:53:00 +00:00
|
|
|
kPlatformGetPlatform = 4,
|
|
|
|
kPlatformUnk5 = 5,
|
|
|
|
kPlatformIsHiRes = 6,
|
|
|
|
kPlatformIsItWindows = 7
|
|
|
|
};
|
|
|
|
|
- Changed the unimplemented debug SCI kernel functions (InspectObj, ShowSends, ShowObjs, ShowFree, StackUsage and Profiler) to be dummy functions - we have our own debugger, and don't use these functions for debugging
- Removed the function number parameter from all kernel functions, as it's no longer needed, and removed the FAKE_FUNCT_NR hack
- Removed kUnknown() and kStub()
- Dummy/unknown kernel functions are no longer invoked, and a warning is shown instead, with the paremeters passed to them
Note: there is an evil hack used for debugging scripts in invoke_selector(), which probably no longer works now
svn-id: r44461
2009-09-29 14:24:07 +00:00
|
|
|
reg_t kPlatform(EngineState *s, int argc, reg_t *argv) {
|
2010-02-13 17:42:49 +00:00
|
|
|
bool isWindows = g_sci->getPlatform() == Common::kPlatformWindows;
|
2010-01-02 03:44:40 +00:00
|
|
|
|
|
|
|
if (argc == 0 && getSciVersion() < SCI_VERSION_2) {
|
|
|
|
// This is called in KQ5CD with no parameters, where it seems to do some graphics
|
|
|
|
// driver check. This kernel function didn't have subfunctions then. If 0 is
|
2010-01-25 01:39:44 +00:00
|
|
|
// returned, the game functions normally, otherwise all the animations show up
|
2010-01-02 03:44:40 +00:00
|
|
|
// like a slideshow (e.g. in the intro). So we return 0. However, the behavior
|
|
|
|
// changed for kPlatform with no parameters in SCI32.
|
2010-01-01 17:16:12 +00:00
|
|
|
return NULL_REG;
|
|
|
|
}
|
2009-12-27 19:16:06 +00:00
|
|
|
|
2010-01-02 03:44:40 +00:00
|
|
|
uint16 operation = (argc == 0) ? 0 : argv[0].toUint16();
|
2009-10-30 22:53:00 +00:00
|
|
|
|
|
|
|
switch (operation) {
|
2009-12-27 19:16:06 +00:00
|
|
|
case kPlatformCDSpeed:
|
|
|
|
// TODO: Returns CD Speed?
|
|
|
|
warning("STUB: kPlatform(CDSpeed)");
|
|
|
|
break;
|
|
|
|
case kPlatformUnk2:
|
|
|
|
// Always returns 2
|
|
|
|
return make_reg(0, 2);
|
|
|
|
case kPlatformCDCheck:
|
|
|
|
// TODO: Some sort of CD check?
|
|
|
|
warning("STUB: kPlatform(CDCheck)");
|
|
|
|
break;
|
2010-02-01 04:14:16 +00:00
|
|
|
case kPlatformUnk0:
|
2010-05-18 04:17:58 +00:00
|
|
|
if (g_sci->getPlatform() == Common::kPlatformMacintosh && getSciVersion() == SCI_VERSION_1_1)
|
|
|
|
return kIconBar(s, argc - 1, argv + 1);
|
|
|
|
// Otherwise, fall through
|
2009-10-30 23:44:12 +00:00
|
|
|
case kPlatformGetPlatform:
|
|
|
|
return make_reg(0, (isWindows) ? kSciPlatformWindows : kSciPlatformDOS);
|
|
|
|
case kPlatformUnk5:
|
|
|
|
// This case needs to return the opposite of case 6 to get hires graphics
|
|
|
|
return make_reg(0, !isWindows);
|
|
|
|
case kPlatformIsHiRes:
|
|
|
|
return make_reg(0, isWindows);
|
|
|
|
case kPlatformIsItWindows:
|
|
|
|
return make_reg(0, isWindows);
|
|
|
|
default:
|
|
|
|
warning("Unsupported kPlatform operation %d", operation);
|
2009-08-30 19:47:47 +00:00
|
|
|
}
|
2009-12-27 19:16:06 +00:00
|
|
|
|
2009-08-30 19:47:47 +00:00
|
|
|
return NULL_REG;
|
|
|
|
}
|
|
|
|
|
2009-05-20 17:51:55 +00:00
|
|
|
} // End of namespace Sci
|