mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-21 01:08:25 +00:00
Replaced/removed KP_UINT, KP_SINT, SKPV and UKPV as well as the VIEW_PRIORITY and PRIORITY_BAND_FIRST wrappers
svn-id: r41338
This commit is contained in:
parent
a5ff6cc19d
commit
744323ca33
@ -1226,7 +1226,7 @@ bool Console::cmdDroppedViews(int argc, const char **argv) {
|
||||
bool Console::cmdPriorityBands(int argc, const char **argv) {
|
||||
if (argc != 2) {
|
||||
DebugPrintf("Priority bands start at y=%d. They end at y=%d\n", g_EngineState->priority_first, g_EngineState->priority_last);
|
||||
DebugPrintf("Use %d <priority band> to print the start of priority for the specified priority band (0 - 15)\n", argv[0]);
|
||||
DebugPrintf("Use %s <priority band> to print the start of priority for the specified priority band (0 - 15)\n", argv[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -204,16 +204,10 @@ bool is_object(EngineState *s, reg_t obj);
|
||||
|
||||
/* Returns the parameter value or (alt) if not enough parameters were supplied */
|
||||
|
||||
|
||||
#define KP_ALT(x, alt) ((x < argc)? argv[x] : (alt))
|
||||
#define KP_UINT(x) ((uint16) x.offset)
|
||||
#define KP_SINT(x) ((int16) x.offset)
|
||||
|
||||
|
||||
#define SKPV(x) KP_SINT(argv[x])
|
||||
#define UKPV(x) KP_UINT(argv[x])
|
||||
#define SKPV_OR_ALT(x,a) KP_SINT(KP_ALT(x, make_reg(0, a)))
|
||||
#define UKPV_OR_ALT(x,a) KP_UINT(KP_ALT(x, make_reg(0, a)))
|
||||
#define SKPV_OR_ALT(x,a) KP_ALT(x, make_reg(0, a)).toSint16()
|
||||
#define UKPV_OR_ALT(x,a) KP_ALT(x, make_reg(0, a)).toUint16()
|
||||
|
||||
reg_t *kernel_dereference_reg_pointer(EngineState *s, reg_t pointer, int entries);
|
||||
byte *kernel_dereference_bulk_pointer(EngineState *s, reg_t pointer, int entries);
|
||||
@ -257,11 +251,6 @@ int _find_view_priority(EngineState *s, int y);
|
||||
#define SCI0_PRIORITY_BAND_FIRST(nr) ((((nr) == 0)? 0 : \
|
||||
((s->priority_first) + (((nr)-1) * (s->priority_last - s->priority_first)) / 15)))
|
||||
|
||||
#define VIEW_PRIORITY(y) _find_view_priority(s, y)
|
||||
#define PRIORITY_BAND_FIRST(nr) _find_priority_band(s, nr)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/******************** Dynamic view list functions ********************/
|
||||
|
@ -38,7 +38,7 @@ int g_stop_on_event = 0;
|
||||
#define SCI_VARIABLE_GAME_SPEED 3
|
||||
|
||||
reg_t kGetEvent(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int mask = UKPV(0);
|
||||
int mask = argv[0].toUint16();
|
||||
reg_t obj = argv[1];
|
||||
sci_event_t e;
|
||||
int oldx, oldy;
|
||||
|
@ -197,7 +197,7 @@ void file_open(EngineState *s, const char *filename, int mode) {
|
||||
|
||||
reg_t kFOpen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
char *name = kernel_dereference_char_pointer(s, argv[0], 0);
|
||||
int mode = UKPV(1);
|
||||
int mode = argv[1].toUint16();
|
||||
|
||||
debug(3, "kFOpen(%s,0x%x)", name, mode);
|
||||
file_open(s, name, mode);
|
||||
@ -227,8 +227,8 @@ void file_close(EngineState *s, int handle) {
|
||||
}
|
||||
|
||||
reg_t kFClose(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
debug(3, "kFClose(%d)", UKPV(0));
|
||||
file_close(s, UKPV(0));
|
||||
debug(3, "kFClose(%d)", argv[0].toUint16());
|
||||
file_close(s, argv[0].toUint16());
|
||||
return s->r_acc;
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ void fwrite_wrapper(EngineState *s, int handle, char *data, int length) {
|
||||
}
|
||||
|
||||
reg_t kFPuts(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int handle = UKPV(0);
|
||||
int handle = argv[0].toUint16();
|
||||
char *data = kernel_dereference_char_pointer(s, argv[1], 0);
|
||||
|
||||
fwrite_wrapper(s, handle, data, strlen(data));
|
||||
@ -301,8 +301,8 @@ static void fseek_wrapper(EngineState *s, int handle, int offset, int whence) {
|
||||
|
||||
reg_t kFGets(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
char *dest = kernel_dereference_char_pointer(s, argv[0], 0);
|
||||
int maxsize = UKPV(1);
|
||||
int handle = UKPV(2);
|
||||
int maxsize = argv[1].toUint16();
|
||||
int handle = argv[2].toUint16();
|
||||
|
||||
debug(3, "kFGets(%d,%d)", handle, maxsize);
|
||||
fgets_wrapper(s, dest, maxsize, handle);
|
||||
@ -344,7 +344,7 @@ enum {
|
||||
};
|
||||
|
||||
reg_t kDeviceInfo(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int mode = UKPV(0);
|
||||
int mode = argv[0].toUint16();
|
||||
char *game_prefix, *input_s, *output_s;
|
||||
|
||||
switch (mode) {
|
||||
@ -394,7 +394,7 @@ reg_t kDeviceInfo(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case K_DEVICE_INFO_GET_SAVEFILE_NAME: {
|
||||
output_s = kernel_dereference_char_pointer(s, argv[1], 0);
|
||||
game_prefix = kernel_dereference_char_pointer(s, argv[2], 0);
|
||||
int savegame_id = UKPV(3);
|
||||
int savegame_id = argv[3].toUint16();
|
||||
sprintf(output_s, "__throwaway");
|
||||
debug(3, "K_DEVICE_INFO_GET_SAVEFILE_NAME(%s,%d) -> %s", game_prefix, savegame_id, output_s);
|
||||
delete_savegame(s, savegame_id);
|
||||
@ -474,7 +474,7 @@ void listSavegames(Common::Array<SavegameDesc> &saves) {
|
||||
|
||||
reg_t kCheckSaveGame(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
char *game_id = kernel_dereference_char_pointer(s, argv[0], 0);
|
||||
int savedir_nr = UKPV(1);
|
||||
int savedir_nr = argv[1].toUint16();
|
||||
|
||||
debug(3, "kCheckSaveGame(%s, %d)", game_id, savedir_nr);
|
||||
|
||||
@ -560,7 +560,7 @@ reg_t kGetSaveFiles(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
reg_t kSaveGame(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
char *game_id = kernel_dereference_char_pointer(s, argv[0], 0);
|
||||
int savedir_nr = UKPV(1);
|
||||
int savedir_nr = argv[1].toUint16();
|
||||
int savedir_id; // Savegame ID, derived from savedir_nr and the savegame ID list
|
||||
char *game_description = kernel_dereference_char_pointer(s, argv[2], 0);
|
||||
char *version = argc > 3 ? strdup(kernel_dereference_char_pointer(s, argv[3], 0)) : NULL;
|
||||
@ -633,7 +633,7 @@ reg_t kSaveGame(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
reg_t kRestoreGame(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
char *game_id = kernel_dereference_char_pointer(s, argv[0], 0);
|
||||
int savedir_nr = UKPV(1);
|
||||
int savedir_nr = argv[1].toUint16();
|
||||
|
||||
debug(3, "kRestoreGame(%s,%d)", game_id, savedir_nr);
|
||||
|
||||
@ -739,37 +739,37 @@ void DirSeeker::nextFile() {
|
||||
|
||||
|
||||
reg_t kFileIO(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int func_nr = UKPV(0);
|
||||
int func_nr = argv[0].toUint16();
|
||||
|
||||
switch (func_nr) {
|
||||
case K_FILEIO_OPEN : {
|
||||
char *name = kernel_dereference_char_pointer(s, argv[1], 0);
|
||||
int mode = UKPV(2);
|
||||
int mode = argv[2].toUint16();
|
||||
|
||||
file_open(s, name, mode);
|
||||
debug(3, "K_FILEIO_OPEN(%s,0x%x)", name, mode);
|
||||
break;
|
||||
}
|
||||
case K_FILEIO_CLOSE : {
|
||||
int handle = UKPV(1);
|
||||
int handle = argv[1].toUint16();
|
||||
debug(3, "K_FILEIO_CLOSE(%d)", handle);
|
||||
|
||||
file_close(s, handle);
|
||||
break;
|
||||
}
|
||||
case K_FILEIO_READ_RAW : {
|
||||
int handle = UKPV(1);
|
||||
int handle = argv[1].toUint16();
|
||||
char *dest = kernel_dereference_char_pointer(s, argv[2], 0);
|
||||
int size = UKPV(3);
|
||||
int size = argv[3].toUint16();
|
||||
debug(3, "K_FILEIO_READ_RAW(%d,%d)", handle, size);
|
||||
|
||||
fread_wrapper(s, dest, size, handle);
|
||||
break;
|
||||
}
|
||||
case K_FILEIO_WRITE_RAW : {
|
||||
int handle = UKPV(1);
|
||||
int handle = argv[1].toUint16();
|
||||
char *buf = kernel_dereference_char_pointer(s, argv[2], 0);
|
||||
int size = UKPV(3);
|
||||
int size = argv[3].toUint16();
|
||||
debug(3, "K_FILEIO_WRITE_RAW(%d,%d)", handle, size);
|
||||
|
||||
fwrite_wrapper(s, handle, buf, size);
|
||||
@ -788,16 +788,16 @@ reg_t kFileIO(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
case K_FILEIO_READ_STRING : {
|
||||
char *dest = kernel_dereference_char_pointer(s, argv[1], 0);
|
||||
int size = UKPV(2);
|
||||
int handle = UKPV(3);
|
||||
int size = argv[2].toUint16();
|
||||
int handle = argv[3].toUint16();
|
||||
debug(3, "K_FILEIO_READ_STRING(%d,%d)", handle, size);
|
||||
|
||||
fgets_wrapper(s, dest, size, handle);
|
||||
return argv[1];
|
||||
}
|
||||
case K_FILEIO_WRITE_STRING : {
|
||||
int handle = UKPV(1);
|
||||
int size = UKPV(3);
|
||||
int handle = argv[1].toUint16();
|
||||
int size = argv[3].toUint16();
|
||||
char *buf = kernel_dereference_char_pointer(s, argv[2], size);
|
||||
debug(3, "K_FILEIO_WRITE_STRING(%d,%d)", handle, size);
|
||||
|
||||
@ -810,9 +810,9 @@ reg_t kFileIO(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
break;
|
||||
}
|
||||
case K_FILEIO_SEEK : {
|
||||
int handle = UKPV(1);
|
||||
int offset = UKPV(2);
|
||||
int whence = UKPV(3);
|
||||
int handle = argv[1].toUint16();
|
||||
int offset = argv[2].toUint16();
|
||||
int whence = argv[3].toUint16();
|
||||
debug(3, "K_FILEIO_SEEK(%d,%d,%d)", handle, offset, whence);
|
||||
|
||||
fseek_wrapper(s, handle, offset, whence);
|
||||
@ -821,7 +821,7 @@ reg_t kFileIO(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case K_FILEIO_FIND_FIRST : {
|
||||
char *mask = kernel_dereference_char_pointer(s, argv[1], 0);
|
||||
reg_t buf = argv[2];
|
||||
int attr = UKPV(3); // We won't use this, Win32 might, though...
|
||||
int attr = argv[3].toUint16(); // We won't use this, Win32 might, though...
|
||||
debug(3, "K_FILEIO_FIND_FIRST(%s,0x%x)", mask, attr);
|
||||
|
||||
#ifndef WIN32
|
||||
|
@ -304,16 +304,16 @@ reg_t kSetCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
switch (argc) {
|
||||
case 1 :
|
||||
if (s->_version < SCI_VERSION_1_1) {
|
||||
if (SKPV(0) <= 1) {
|
||||
if (argv[0].toSint16() <= 1) {
|
||||
// Newer (SCI1.1) semantics: show/hide cursor
|
||||
g_system->showMouse(SKPV(0) != 0);
|
||||
g_system->showMouse(argv[0].toSint16() != 0);
|
||||
} else {
|
||||
// Pre-SCI1.1: set cursor according to the first parameter
|
||||
GFX_ASSERT(gfxop_set_pointer_cursor(s->gfx_state, SKPV(0)));
|
||||
GFX_ASSERT(gfxop_set_pointer_cursor(s->gfx_state, argv[0].toSint16()));
|
||||
}
|
||||
} else {
|
||||
// SCI1.1: Show/hide cursor
|
||||
g_system->showMouse(SKPV(0) != 0);
|
||||
g_system->showMouse(argv[0].toSint16() != 0);
|
||||
}
|
||||
break;
|
||||
case 2 :
|
||||
@ -329,26 +329,26 @@ reg_t kSetCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
// this would open the menu on top. LSL5 is an exception, as the game can open
|
||||
// the menu when the player presses a button during the intro, but the cursor is
|
||||
// not placed on (x, 0) or (x, 1)
|
||||
if (SKPV(1) <= 1) {
|
||||
if (argv[1].toSint16() <= 1) {
|
||||
GFX_ASSERT(gfxop_set_pointer_cursor(s->gfx_state,
|
||||
SKPV(1) == 0 ? GFXOP_NO_POINTER : SKPV(0)));
|
||||
argv[1].toSint16() == 0 ? GFXOP_NO_POINTER : argv[0].toSint16()));
|
||||
} else { // newer (SCI1.1) semantics: set pointer position
|
||||
GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state,
|
||||
Common::Point(UKPV(0), UKPV(1))));
|
||||
Common::Point(argv[0].toUint16(), argv[1].toUint16())));
|
||||
}
|
||||
} else {
|
||||
// SCI1.1 and newer: set pointer position
|
||||
GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state,
|
||||
Common::Point(UKPV(0), UKPV(1))));
|
||||
Common::Point(argv[0].toUint16(), argv[1].toUint16())));
|
||||
}
|
||||
break;
|
||||
case 4 :
|
||||
GFX_ASSERT(gfxop_set_pointer_cursor(s->gfx_state,
|
||||
UKPV(0) == 0 ? GFXOP_NO_POINTER : SKPV(0)));
|
||||
argv[0].toUint16() == 0 ? GFXOP_NO_POINTER : argv[0].toSint16()));
|
||||
|
||||
// Set pointer position, if requested
|
||||
if (argc > 2) {
|
||||
Common::Point newPos = Common::Point(SKPV(2) + s->port->_bounds.x, SKPV(3) + s->port->_bounds.y);
|
||||
Common::Point newPos = Common::Point(argv[2].toSint16() + s->port->_bounds.x, argv[3].toSint16() + s->port->_bounds.y);
|
||||
GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state, newPos));
|
||||
}
|
||||
break;
|
||||
@ -356,10 +356,10 @@ reg_t kSetCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case 5 :
|
||||
case 9 :
|
||||
if (argc > 3) {
|
||||
Common::Point hotspot = Common::Point(SKPV(3), SKPV(4));
|
||||
GFX_ASSERT(gfxop_set_pointer_view(s->gfx_state, UKPV(0), UKPV(1), UKPV(2), &hotspot));
|
||||
Common::Point hotspot = Common::Point(argv[3].toSint16(), argv[4].toSint16());
|
||||
GFX_ASSERT(gfxop_set_pointer_view(s->gfx_state, argv[0].toUint16(), argv[1].toUint16(), argv[2].toUint16(), &hotspot));
|
||||
} else {
|
||||
GFX_ASSERT(gfxop_set_pointer_view(s->gfx_state, UKPV(0), UKPV(1), UKPV(2), NULL));
|
||||
GFX_ASSERT(gfxop_set_pointer_view(s->gfx_state, argv[0].toUint16(), argv[1].toUint16(), argv[2].toUint16(), NULL));
|
||||
}
|
||||
break;
|
||||
default :
|
||||
@ -377,8 +377,8 @@ reg_t kMoveCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
if (argc == 1) {
|
||||
// Case ignored on IBM PC
|
||||
} else {
|
||||
newPos.x = SKPV(0) + s->port->zone.x;
|
||||
newPos.y = SKPV(1) + s->port->zone.y;
|
||||
newPos.x = argv[0].toSint16() + s->port->zone.x;
|
||||
newPos.y = argv[1].toSint16() + s->port->zone.y;
|
||||
|
||||
if (newPos.x > s->port->zone.x + s->port->zone.width)
|
||||
newPos.x = s->port->zone.x + s->port->zone.width;
|
||||
@ -427,7 +427,7 @@ reg_t kShow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
reg_t kPicNotValid(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
s->r_acc = make_reg(0, s->pic_not_valid);
|
||||
if (argc)
|
||||
s->pic_not_valid = (byte)UKPV(0);
|
||||
s->pic_not_valid = (byte)argv[0].toUint16();
|
||||
|
||||
return s->r_acc;
|
||||
}
|
||||
@ -488,12 +488,12 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
GfxPort *port = s->port;
|
||||
int redraw_port = 0;
|
||||
|
||||
area = gfx_rect(SKPV(2), SKPV(1) , SKPV(4), SKPV(3));
|
||||
area = gfx_rect(argv[2].toSint16(), argv[1].toSint16() , argv[4].toSint16(), argv[3].toSint16());
|
||||
|
||||
area.width = area.width - area.x; // Since the actual coordinates are absolute
|
||||
area.height = area.height - area.y;
|
||||
|
||||
switch (SKPV(0)) {
|
||||
switch (argv[0].toSint16()) {
|
||||
|
||||
case K_GRAPH_GET_COLORS_NR:
|
||||
|
||||
@ -502,10 +502,10 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
case K_GRAPH_DRAW_LINE: {
|
||||
|
||||
gfx_color_t gfxcolor = graph_map_color(s, SKPV(5), SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1));
|
||||
gfx_color_t gfxcolor = graph_map_color(s, argv[5].toSint16(), SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1));
|
||||
|
||||
debugC(2, kDebugLevelGraphics, "draw_line((%d, %d), (%d, %d), col=%d, p=%d, c=%d, mask=%d)\n",
|
||||
SKPV(2), SKPV(1), SKPV(4), SKPV(3), SKPV(5), SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1), gfxcolor.mask);
|
||||
argv[2].toSint16(), argv[1].toSint16(), argv[4].toSint16(), argv[3].toSint16(), argv[5].toSint16(), SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1), gfxcolor.mask);
|
||||
|
||||
redraw_port = 1;
|
||||
|
||||
@ -513,7 +513,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
// have negative width/height). The actual dirty rectangle is constructed in gfxdr_add_dirty().
|
||||
// FIXME/TODO: We need to change the semantics of this call, so that no fake rectangles are used. As it is, it's
|
||||
// not possible change rect_t to Common::Rect, as we assume that Common::Rect forms a *valid* rectangle.
|
||||
ADD_TO_CURRENT_PICTURE_PORT(gfxw_new_line(Common::Point(SKPV(2), SKPV(1)), Common::Point(SKPV(4), SKPV(3)),
|
||||
ADD_TO_CURRENT_PICTURE_PORT(gfxw_new_line(Common::Point(argv[2].toSint16(), argv[1].toSint16()), Common::Point(argv[4].toSint16(), argv[3].toSint16()),
|
||||
gfxcolor, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL));
|
||||
|
||||
}
|
||||
@ -552,12 +552,12 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
case K_GRAPH_FILL_BOX_ANY: {
|
||||
|
||||
gfx_color_t color = graph_map_color(s, SKPV(6), SKPV_OR_ALT(7, -1), SKPV_OR_ALT(8, -1));
|
||||
gfx_color_t color = graph_map_color(s, argv[6].toSint16(), SKPV_OR_ALT(7, -1), SKPV_OR_ALT(8, -1));
|
||||
|
||||
color.mask = (byte)UKPV(5);
|
||||
color.mask = (byte)argv[5].toUint16();
|
||||
|
||||
debugC(2, kDebugLevelGraphics, "fill_box_any((%d, %d), (%d, %d), col=%d, p=%d, c=%d, mask=%d)\n",
|
||||
SKPV(2), SKPV(1), SKPV(4), SKPV(3), SKPV(6), SKPV_OR_ALT(7, -1), SKPV_OR_ALT(8, -1), UKPV(5));
|
||||
argv[2].toSint16(), argv[1].toSint16(), argv[4].toSint16(), argv[3].toSint16(), argv[6].toSint16(), SKPV_OR_ALT(7, -1), SKPV_OR_ALT(8, -1), argv[5].toUint16());
|
||||
|
||||
// FIXME/TODO: this is not right, as some of the dialogs are drawn *behind* some widgets. But at least it works for now
|
||||
//ADD_TO_CURRENT_PICTURE_PORT(gfxw_new_box(s->gfx_state, area, color, color, GFX_BOX_SHADE_FLAT)); // old code
|
||||
@ -568,7 +568,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
case K_GRAPH_UPDATE_BOX: {
|
||||
|
||||
debugC(2, kDebugLevelGraphics, "update_box(%d, %d, %d, %d)\n", SKPV(1), SKPV(2), SKPV(3), SKPV(4));
|
||||
debugC(2, kDebugLevelGraphics, "update_box(%d, %d, %d, %d)\n", argv[1].toSint16(), argv[2].toSint16(), argv[3].toSint16(), argv[4].toSint16());
|
||||
|
||||
area.x += s->port->zone.x;
|
||||
area.y += s->port->zone.y;
|
||||
@ -581,7 +581,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case K_GRAPH_REDRAW_BOX: {
|
||||
|
||||
|
||||
debugC(2, kDebugLevelGraphics, "redraw_box(%d, %d, %d, %d)\n", SKPV(1), SKPV(2), SKPV(3), SKPV(4));
|
||||
debugC(2, kDebugLevelGraphics, "redraw_box(%d, %d, %d, %d)\n", argv[1].toSint16(), argv[2].toSint16(), argv[3].toSint16(), argv[4].toSint16());
|
||||
|
||||
area.x += s->port->zone.x;
|
||||
area.y += s->port->zone.y;
|
||||
@ -597,14 +597,14 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
case K_GRAPH_ADJUST_PRIORITY:
|
||||
|
||||
debugC(2, kDebugLevelGraphics, "adjust_priority(%d, %d)\n", SKPV(1), SKPV(2));
|
||||
s->priority_first = SKPV(1) - 10;
|
||||
s->priority_last = SKPV(2) - 10;
|
||||
debugC(2, kDebugLevelGraphics, "adjust_priority(%d, %d)\n", argv[1].toSint16(), argv[2].toSint16());
|
||||
s->priority_first = argv[1].toSint16() - 10;
|
||||
s->priority_last = argv[2].toSint16() - 10;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
warning("Unhandled Graph() operation %04x", SKPV(0));
|
||||
warning("Unhandled Graph() operation %04x", argv[0].toSint16());
|
||||
|
||||
}
|
||||
|
||||
@ -620,8 +620,8 @@ reg_t kTextSize(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int width, height;
|
||||
char *text = argv[1].segment ? (char *) kernel_dereference_bulk_pointer(s, argv[1], 0) : NULL;
|
||||
reg_t *dest = kernel_dereference_reg_pointer(s, argv[0], 4);
|
||||
int maxwidth = KP_UINT(KP_ALT(3, NULL_REG));
|
||||
int font_nr = KP_UINT(argv[2]);
|
||||
int maxwidth = KP_ALT(3, NULL_REG).toUint16();
|
||||
int font_nr = argv[2].toUint16();
|
||||
|
||||
if (maxwidth < 0)
|
||||
maxwidth = 0;
|
||||
@ -647,7 +647,7 @@ reg_t kTextSize(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
reg_t kWait(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
uint32 time;
|
||||
int sleep_time = UKPV(0);
|
||||
int sleep_time = argv[0].toUint16();
|
||||
|
||||
time = g_system->getMillis();
|
||||
s->r_acc = make_reg(0, ((long)time - (long)s->last_wait_time) * 60 / 1000);
|
||||
@ -663,15 +663,15 @@ reg_t kWait(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kCoordPri(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int y = SKPV(0);
|
||||
int y = argv[0].toSint16();
|
||||
|
||||
return make_reg(0, VIEW_PRIORITY(y));
|
||||
return make_reg(0, _find_view_priority(s, y));
|
||||
}
|
||||
|
||||
reg_t kPriCoord(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int priority = SKPV(0);
|
||||
int priority = argv[0].toSint16();
|
||||
|
||||
return make_reg(0, PRIORITY_BAND_FIRST(priority));
|
||||
return make_reg(0, _find_priority_band(s, priority));
|
||||
}
|
||||
|
||||
void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
@ -720,7 +720,7 @@ void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int funct_nr, int argc,
|
||||
}
|
||||
|
||||
reg_t kDirLoop(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
_k_dirloop(argv[0], UKPV(1), s, funct_nr, argc, argv);
|
||||
_k_dirloop(argv[0], argv[1].toUint16(), s, funct_nr, argc, argv);
|
||||
|
||||
return s->r_acc;
|
||||
}
|
||||
@ -863,11 +863,11 @@ reg_t kCanBeHere(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
} // CanBeHere
|
||||
|
||||
reg_t kIsItSkip(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int view = SKPV(0);
|
||||
int loop = SKPV(1);
|
||||
int cel = SKPV(2);
|
||||
int y = UKPV(3);
|
||||
int x = UKPV(4);
|
||||
int view = argv[0].toSint16();
|
||||
int loop = argv[1].toSint16();
|
||||
int cel = argv[2].toSint16();
|
||||
int y = argv[3].toUint16();
|
||||
int x = argv[4].toUint16();
|
||||
gfxr_view_t *res = NULL;
|
||||
gfx_pixmap_t *pxm = NULL;
|
||||
|
||||
@ -888,9 +888,9 @@ reg_t kIsItSkip(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kCelHigh(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int view = SKPV(0);
|
||||
int loop = SKPV(1);
|
||||
int cel = SKPV(2);
|
||||
int view = argv[0].toSint16();
|
||||
int loop = argv[1].toSint16();
|
||||
int cel = argv[2].toSint16();
|
||||
int height, width;
|
||||
Common::Point offset;
|
||||
|
||||
@ -906,9 +906,9 @@ reg_t kCelHigh(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kCelWide(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int view = SKPV(0);
|
||||
int loop = SKPV(1);
|
||||
int cel = SKPV(2);
|
||||
int view = argv[0].toSint16();
|
||||
int loop = argv[1].toSint16();
|
||||
int cel = argv[2].toSint16();
|
||||
int height, width;
|
||||
Common::Point offset;
|
||||
|
||||
@ -967,15 +967,15 @@ reg_t kOnControl(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
map = GFX_MASK_CONTROL;
|
||||
else {
|
||||
arg = 1;
|
||||
map = (gfx_map_mask_t) SKPV(0);
|
||||
map = (gfx_map_mask_t) argv[0].toSint16();
|
||||
}
|
||||
|
||||
ystart = SKPV(arg + 1);
|
||||
xstart = SKPV(arg);
|
||||
ystart = argv[arg + 1].toSint16();
|
||||
xstart = argv[arg].toSint16();
|
||||
|
||||
if (argc > 3) {
|
||||
ylen = SKPV(arg + 3) - ystart;
|
||||
xlen = SKPV(arg + 2) - xstart;
|
||||
ylen = argv[arg + 3].toSint16() - ystart;
|
||||
xlen = argv[arg + 2].toSint16() - xstart;
|
||||
}
|
||||
|
||||
return make_reg(0, gfxop_scan_bitmask(s->gfx_state, gfx_rect(xstart, ystart + 10, xlen, ylen), map));
|
||||
@ -991,10 +991,10 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
gfx_color_t transparent = s->wm_port->_bgcolor;
|
||||
int picFlags = DRAWPIC01_FLAG_FILL_NORMALLY;
|
||||
|
||||
dp.nr = SKPV(0);
|
||||
dp.nr = argv[0].toSint16();
|
||||
dp.palette = SKPV_OR_ALT(3, 0);
|
||||
|
||||
if ((argc > 1) && (UKPV(1) & K_DRAWPIC_FLAG_MIRRORED))
|
||||
if ((argc > 1) && (argv[1].toUint16() & K_DRAWPIC_FLAG_MIRRORED))
|
||||
picFlags |= DRAWPIC1_FLAG_MIRRORED;
|
||||
|
||||
if (s->_flags & GF_SCI0_OLDGFXFUNCS) {
|
||||
@ -1013,7 +1013,7 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
s->old_screen = gfxop_grab_pixmap(s->gfx_state, gfx_rect(0, 10, 320, 190));
|
||||
|
||||
debugC(2, kDebugLevelGraphics, "Drawing pic.%03d\n", SKPV(0));
|
||||
debugC(2, kDebugLevelGraphics, "Drawing pic.%03d\n", argv[0].toSint16());
|
||||
|
||||
if (add_to_pic) {
|
||||
s->_pics.push_back(dp);
|
||||
@ -1043,7 +1043,7 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
s->pic_priority_table = gfxop_get_pic_metainfo(s->gfx_state);
|
||||
|
||||
if (argc > 1)
|
||||
s->pic_animate = SKPV(1) & 0xff; // The animation used during kAnimate() later on
|
||||
s->pic_animate = argv[1].toSint16() & 0xff; // The animation used during kAnimate() later on
|
||||
|
||||
s->dyn_views = NULL;
|
||||
s->drop_views = NULL;
|
||||
@ -1157,9 +1157,9 @@ static Common::Rect nsrect_clip(EngineState *s, int y, Common::Rect retval, int
|
||||
int pri_top;
|
||||
|
||||
if (priority == -1)
|
||||
priority = VIEW_PRIORITY(y);
|
||||
priority = _find_view_priority(s, y);
|
||||
|
||||
pri_top = PRIORITY_BAND_FIRST(priority) + 1;
|
||||
pri_top = _find_priority_band(s, priority) + 1;
|
||||
// +1: Don't know why, but this seems to be happening
|
||||
|
||||
if (retval.top < pri_top)
|
||||
@ -1251,7 +1251,7 @@ reg_t kSetNowSeen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kPalette(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
switch (UKPV(0)) {
|
||||
switch (argv[0].toUint16()) {
|
||||
case 1:
|
||||
debug(5, "STUB: kPalette() effect 1, direct palette set");
|
||||
break;
|
||||
@ -1264,11 +1264,11 @@ reg_t kPalette(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case 4: { // Set palette intensity
|
||||
#if 0
|
||||
// Colors 0 (black) and 255 (white) cannot be changed
|
||||
int16 from = CLIP<int16>(1, 255, UKPV(2));
|
||||
int16 to = CLIP<int16>(1, 255, UKPV(3));
|
||||
int16 intensity = UKPV(4);
|
||||
int16 from = CLIP<int16>(1, 255, argv[2].toUint16());
|
||||
int16 to = CLIP<int16>(1, 255, argv[3].toUint16());
|
||||
int16 intensity = argv[4].toUint16();
|
||||
|
||||
if (argc < 5 || UKPV(5) == 0) {
|
||||
if (argc < 5 || argv[5].toUint16() == 0) {
|
||||
s->gfx_state->gfxResMan->setPaletteIntensity(from, to, intensity);
|
||||
} else {
|
||||
warning("kPalette: argv[5] != 0");
|
||||
@ -1280,9 +1280,9 @@ reg_t kPalette(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
break;
|
||||
}
|
||||
case 5: { // Find closest color
|
||||
int r = UKPV(1);
|
||||
int g = UKPV(2);
|
||||
int b = UKPV(3);
|
||||
int r = argv[1].toUint16();
|
||||
int g = argv[2].toUint16();
|
||||
int b = argv[3].toUint16();
|
||||
|
||||
int i, delta, bestindex = -1, bestdelta = 200000;
|
||||
|
||||
@ -1312,7 +1312,7 @@ reg_t kPalette(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
debug(5, "STUB: kPalette() effect 8, set stored palette");
|
||||
break;
|
||||
default:
|
||||
warning("kPalette(): Unimplemented subfunction: %d", UKPV(0));
|
||||
warning("kPalette(): Unimplemented subfunction: %d", argv[0].toUint16());
|
||||
}
|
||||
|
||||
return s->r_acc;
|
||||
@ -2275,13 +2275,13 @@ reg_t kAddToPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int view, cel, loop, x, y, priority, control;
|
||||
GfxWidget *widget;
|
||||
|
||||
view = KP_UINT(argv[0]);
|
||||
loop = KP_UINT(argv[1]);
|
||||
cel = KP_UINT(argv[2]);
|
||||
x = KP_SINT(argv[3]);
|
||||
y = KP_SINT(argv[4]) + 1 /* magic + 1 */;
|
||||
priority = KP_SINT(argv[5]);
|
||||
control = KP_SINT(argv[6]);
|
||||
view = argv[0].toUint16();
|
||||
loop = argv[1].toUint16();
|
||||
cel = argv[2].toUint16();
|
||||
x = argv[3].toSint16();
|
||||
y = argv[4].toSint16() + 1 /* magic + 1 */;
|
||||
priority = argv[5].toSint16();
|
||||
control = argv[6].toSint16();
|
||||
|
||||
widget = gfxw_new_dyn_view(s->gfx_state, Common::Point(x, y), 0, view, loop, cel, 0,
|
||||
priority, -1 /* No priority */ , ALIGN_CENTER, ALIGN_BOTTOM, 0);
|
||||
@ -2337,7 +2337,7 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
switch (argc) {
|
||||
case 1 : {
|
||||
unsigned int port_nr = SKPV(0);
|
||||
unsigned int port_nr = argv[0].toSint16();
|
||||
GfxPort *new_port;
|
||||
|
||||
/* We depart from official semantics here, sorry!
|
||||
@ -2360,10 +2360,10 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
return s->r_acc;
|
||||
}
|
||||
case 6 : {
|
||||
port_origin_y = SKPV(0);
|
||||
port_origin_x = SKPV(1);
|
||||
port_origin_y = argv[0].toSint16();
|
||||
port_origin_x = argv[1].toSint16();
|
||||
|
||||
if (SKPV(0) == -10) {
|
||||
if (argv[0].toSint16() == -10) {
|
||||
s->port->draw(gfxw_point_zero); // Update the port we're leaving
|
||||
s->port = s->iconbar_port;
|
||||
activated_icon_bar = true;
|
||||
@ -2371,20 +2371,20 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
// Notify the graphics resource manager that the pic port bounds changed
|
||||
s->gfx_state->gfxResMan->changePortBounds(UKPV(5), UKPV(4), UKPV(3) + UKPV(5), UKPV(2) + UKPV(4));
|
||||
s->gfx_state->gfxResMan->changePortBounds(argv[5].toUint16(), argv[4].toUint16(), argv[3].toUint16() + argv[5].toUint16(), argv[2].toUint16() + argv[4].toUint16());
|
||||
|
||||
// LSL6 calls kSetPort to extend the screen to draw the GUI. If we free all resources
|
||||
// here, the background picture is freed too, and this makes everything a big mess.
|
||||
// FIXME/TODO: This code really needs to be rewritten to conform to the original behavior
|
||||
if (s->_gameName != "LSL6") {
|
||||
s->gfx_state->pic_port_bounds = gfx_rect(UKPV(5), UKPV(4), UKPV(3), UKPV(2));
|
||||
s->gfx_state->pic_port_bounds = gfx_rect(argv[5].toUint16(), argv[4].toUint16(), argv[3].toUint16(), argv[2].toUint16());
|
||||
|
||||
// FIXME: Should really only invalidate all loaded pic resources here;
|
||||
// this is overkill
|
||||
s->gfx_state->gfxResMan->freeAllResources();
|
||||
} else {
|
||||
// WORKAROUND for LSL6
|
||||
printf("SetPort case 6 called in LSL6. Origin: %d, %d - Clip rect: %d, %d, %d, %d\n", SKPV(1), SKPV(0), UKPV(5), UKPV(4), UKPV(3), UKPV(2));
|
||||
printf("SetPort case 6 called in LSL6. Origin: %d, %d - Clip rect: %d, %d, %d, %d\n", argv[1].toSint16(), argv[0].toSint16(), argv[5].toUint16(), argv[4].toUint16(), argv[3].toUint16(), argv[2].toUint16());
|
||||
}
|
||||
|
||||
break;
|
||||
@ -2398,11 +2398,11 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kDrawCel(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int view = SKPV(0);
|
||||
int loop = SKPV(1);
|
||||
int cel = SKPV(2);
|
||||
int x = SKPV(3);
|
||||
int y = SKPV(4);
|
||||
int view = argv[0].toSint16();
|
||||
int loop = argv[1].toSint16();
|
||||
int cel = argv[2].toSint16();
|
||||
int x = argv[3].toSint16();
|
||||
int y = argv[4].toSint16();
|
||||
int priority = SKPV_OR_ALT(5, -1);
|
||||
GfxView *new_view;
|
||||
|
||||
@ -2430,7 +2430,7 @@ reg_t kDrawCel(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kDisposeWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
unsigned int goner_nr = SKPV(0);
|
||||
unsigned int goner_nr = argv[0].toSint16();
|
||||
GfxPort *goner;
|
||||
GfxPort *pred;
|
||||
|
||||
@ -2478,17 +2478,17 @@ reg_t kNewWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int priority;
|
||||
int argextra = argc == 13 ? 4 : 0; // Triggers in PQ3 and SCI1.1 games
|
||||
|
||||
y = SKPV(0);
|
||||
x = SKPV(1);
|
||||
yl = SKPV(2) - y;
|
||||
xl = SKPV(3) - x;
|
||||
y = argv[0].toSint16();
|
||||
x = argv[1].toSint16();
|
||||
yl = argv[2].toSint16() - y;
|
||||
xl = argv[3].toSint16() - x;
|
||||
|
||||
y += s->wm_port->_bounds.y;
|
||||
|
||||
if (x + xl > 319)
|
||||
x -= ((x + xl) - 319);
|
||||
|
||||
flags = SKPV(5 + argextra);
|
||||
flags = argv[5 + argextra].toSint16();
|
||||
|
||||
priority = SKPV_OR_ALT(6 + argextra, -1);
|
||||
bgcolor.mask = 0;
|
||||
@ -2507,7 +2507,7 @@ reg_t kNewWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
bgcolor.mask |= priority >= 0 ? GFX_MASK_PRIORITY : 0;
|
||||
bgcolor.alpha = 0;
|
||||
bgcolor.control = -1;
|
||||
debugC(2, kDebugLevelGraphics, "New window with params %d, %d, %d, %d\n", SKPV(0), SKPV(1), SKPV(2), SKPV(3));
|
||||
debugC(2, kDebugLevelGraphics, "New window with params %d, %d, %d, %d\n", argv[0].toSint16(), argv[1].toSint16(), argv[2].toSint16(), argv[3].toSint16());
|
||||
|
||||
fgcolor.visual = get_pic_color(s, SKPV_OR_ALT(7 + argextra, 0));
|
||||
fgcolor.mask = GFX_MASK_VISUAL;
|
||||
@ -2531,7 +2531,7 @@ reg_t kNewWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
// PQ3 and SCI1.1 games have the interpreter store underBits implicitly
|
||||
if (argextra)
|
||||
gfxw_port_auto_restore_background(s->visual, window, gfx_rect(SKPV(5), SKPV(4), SKPV(7) - SKPV(5), SKPV(6) - SKPV(4)));
|
||||
gfxw_port_auto_restore_background(s->visual, window, gfx_rect(argv[5].toSint16(), argv[4].toSint16(), argv[7].toSint16() - argv[5].toSint16(), argv[6].toSint16() - argv[4].toSint16()));
|
||||
|
||||
ADD_TO_WINDOW_PORT(window);
|
||||
FULL_REDRAW();
|
||||
@ -3163,24 +3163,24 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
while (argpt < argc) {
|
||||
switch (UKPV(argpt++)) {
|
||||
switch (argv[argpt++].toUint16()) {
|
||||
|
||||
case K_DISPLAY_SET_COORDS:
|
||||
|
||||
area.x = UKPV(argpt++);
|
||||
area.y = UKPV(argpt++);
|
||||
area.x = argv[argpt++].toUint16();
|
||||
area.y = argv[argpt++].toUint16();
|
||||
debugC(2, kDebugLevelGraphics, "Display: set_coords(%d, %d)\n", area.x, area.y);
|
||||
break;
|
||||
|
||||
case K_DISPLAY_SET_ALIGNMENT:
|
||||
|
||||
halign = (gfx_alignment_t)KP_SINT(argv[argpt++]);
|
||||
halign = (gfx_alignment_t)argv[argpt++].toSint16();
|
||||
debugC(2, kDebugLevelGraphics, "Display: set_align(%d)\n", halign);
|
||||
break;
|
||||
|
||||
case K_DISPLAY_SET_COLOR:
|
||||
|
||||
temp = KP_SINT(argv[argpt++]);
|
||||
temp = argv[argpt++].toSint16();
|
||||
debugC(2, kDebugLevelGraphics, "Display: set_color(%d)\n", temp);
|
||||
if ((s->resmgr->_sciVersion < SCI_VERSION_01_VGA) && temp >= 0 && temp <= 15)
|
||||
color0 = (s->ega_colors[temp]);
|
||||
@ -3197,7 +3197,7 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
case K_DISPLAY_SET_BGCOLOR:
|
||||
|
||||
temp = KP_SINT(argv[argpt++]);
|
||||
temp = argv[argpt++].toSint16();
|
||||
debugC(2, kDebugLevelGraphics, "Display: set_bg_color(%d)\n", temp);
|
||||
if (s->resmgr->_sciVersion < SCI_VERSION_01_VGA && temp >= 0 && temp <= 15)
|
||||
bg_color = s->ega_colors[temp];
|
||||
@ -3214,20 +3214,20 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
case K_DISPLAY_SET_GRAYTEXT:
|
||||
|
||||
gray = KP_SINT(argv[argpt++]);
|
||||
gray = argv[argpt++].toSint16();
|
||||
debugC(2, kDebugLevelGraphics, "Display: set_graytext(%d)\n", gray);
|
||||
break;
|
||||
|
||||
case K_DISPLAY_SET_FONT:
|
||||
|
||||
font_nr = KP_UINT(argv[argpt++]);
|
||||
font_nr = argv[argpt++].toUint16();
|
||||
|
||||
debugC(2, kDebugLevelGraphics, "Display: set_font(\"font.%03d\")\n", font_nr);
|
||||
break;
|
||||
|
||||
case K_DISPLAY_WIDTH:
|
||||
|
||||
area.width = UKPV(argpt++);
|
||||
area.width = argv[argpt++].toUint16();
|
||||
if (area.width == 0)
|
||||
area.width = MAX_TEXT_WIDTH_MAGIC_VALUE;
|
||||
|
||||
@ -3242,7 +3242,7 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
case K_DISPLAY_RESTORE_UNDER:
|
||||
|
||||
debugC(2, kDebugLevelGraphics, "Display: restore_under(%04x)\n", UKPV(argpt));
|
||||
debugC(2, kDebugLevelGraphics, "Display: restore_under(%04x)\n", argv[argpt].toUint16());
|
||||
graph_restore_box(s, argv[argpt++]);
|
||||
update_immediately = true;
|
||||
argpt++;
|
||||
@ -3256,7 +3256,7 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
break;
|
||||
|
||||
default:
|
||||
debugC(2, kDebugLevelGraphics, "Unknown Display() command %x\n", UKPV(argpt - 1));
|
||||
debugC(2, kDebugLevelGraphics, "Unknown Display() command %x\n", argv[argpt - 1].toUint16());
|
||||
return NULL_REG;
|
||||
}
|
||||
}
|
||||
@ -3320,7 +3320,7 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
reg_t kShowMovie(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
const char *filename = kernel_dereference_char_pointer(s, argv[0], 0);
|
||||
int framerate = UKPV(1); // FIXME: verify
|
||||
int framerate = argv[1].toUint16(); // FIXME: verify
|
||||
int frameNr = 0;
|
||||
SeqDecoder seq;
|
||||
|
||||
@ -3373,7 +3373,7 @@ reg_t kSetVideoMode(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
// (320x240 resolution, although the intro in KQ6 is 320x200).
|
||||
// Refer to http://en.wikipedia.org/wiki/Mode_X
|
||||
|
||||
warning("STUB: SetVideoMode %d", UKPV(0));
|
||||
warning("STUB: SetVideoMode %d", argv[0].toUint16());
|
||||
|
||||
return s->r_acc;
|
||||
}
|
||||
|
@ -29,18 +29,18 @@
|
||||
namespace Sci {
|
||||
|
||||
reg_t kRandom(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
return make_reg(0, SKPV(0) + (int)((SKPV(1) + 1.0 - SKPV(0)) * (rand() / (RAND_MAX + 1.0))));
|
||||
return make_reg(0, argv[0].toSint16() + (int)((argv[1].toSint16() + 1.0 - argv[0].toSint16()) * (rand() / (RAND_MAX + 1.0))));
|
||||
}
|
||||
|
||||
reg_t kAbs(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
// This is a hack, but so is the code in Hoyle1 that needs it.
|
||||
if (argv[0].segment)
|
||||
return make_reg(0, 0x3e8); // Yes people, this is an object
|
||||
return make_reg(0, abs(SKPV(0)));
|
||||
return make_reg(0, abs(argv[0].toSint16()));
|
||||
}
|
||||
|
||||
reg_t kSqrt(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
return make_reg(0, (int16) sqrt((float) abs(SKPV(0))));
|
||||
return make_reg(0, (int16) sqrt((float) abs(argv[0].toSint16())));
|
||||
}
|
||||
|
||||
int get_angle(int xrel, int yrel) {
|
||||
@ -66,10 +66,10 @@ int get_angle(int xrel, int yrel) {
|
||||
reg_t kGetAngle(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
// Based on behavior observed with a test program created with
|
||||
// SCI Studio.
|
||||
int x1 = SKPV(0);
|
||||
int y1 = SKPV(1);
|
||||
int x2 = SKPV(2);
|
||||
int y2 = SKPV(3);
|
||||
int x1 = argv[0].toSint16();
|
||||
int y1 = argv[1].toSint16();
|
||||
int x2 = argv[2].toSint16();
|
||||
int y2 = argv[3].toSint16();
|
||||
int xrel = x2 - x1;
|
||||
int yrel = y1 - y2; // y-axis is mirrored.
|
||||
int angle;
|
||||
@ -101,29 +101,29 @@ reg_t kGetAngle(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kGetDistance(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int xrel = (int)(((float) SKPV(1) - SKPV_OR_ALT(3, 0)) / cos(SKPV_OR_ALT(5, 0) * PI / 180.0)); // This works because cos(0)==1
|
||||
int yrel = SKPV(0) - SKPV_OR_ALT(2, 0);
|
||||
int xrel = (int)(((float) argv[1].toSint16() - SKPV_OR_ALT(3, 0)) / cos(SKPV_OR_ALT(5, 0) * PI / 180.0)); // This works because cos(0)==1
|
||||
int yrel = argv[0].toSint16() - SKPV_OR_ALT(2, 0);
|
||||
|
||||
return make_reg(0, (int16)sqrt((float) xrel*xrel + yrel*yrel));
|
||||
}
|
||||
|
||||
reg_t kTimesSin(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int angle = SKPV(0);
|
||||
int factor = SKPV(1);
|
||||
int angle = argv[0].toSint16();
|
||||
int factor = argv[1].toSint16();
|
||||
|
||||
return make_reg(0, (int)(factor * 1.0 * sin(angle * PI / 180.0)));
|
||||
}
|
||||
|
||||
reg_t kTimesCos(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int angle = SKPV(0);
|
||||
int factor = SKPV(1);
|
||||
int angle = argv[0].toSint16();
|
||||
int factor = argv[1].toSint16();
|
||||
|
||||
return make_reg(0, (int)(factor * 1.0 * cos(angle * PI / 180.0)));
|
||||
}
|
||||
|
||||
reg_t kCosDiv(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int angle = SKPV(0);
|
||||
int value = SKPV(1);
|
||||
int angle = argv[0].toSint16();
|
||||
int value = argv[1].toSint16();
|
||||
double cosval = cos(angle * PI / 180.0);
|
||||
|
||||
if ((cosval < 0.0001) && (cosval > 0.0001)) {
|
||||
@ -134,8 +134,8 @@ reg_t kCosDiv(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kSinDiv(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int angle = SKPV(0);
|
||||
int value = SKPV(1);
|
||||
int angle = argv[0].toSint16();
|
||||
int value = argv[1].toSint16();
|
||||
double sinval = sin(angle * PI / 180.0);
|
||||
|
||||
if ((sinval < 0.0001) && (sinval > 0.0001)) {
|
||||
@ -146,7 +146,7 @@ reg_t kSinDiv(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kTimesTan(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int param = SKPV(0);
|
||||
int param = argv[0].toSint16();
|
||||
int scale = SKPV_OR_ALT(1, 1);
|
||||
|
||||
param -= 90;
|
||||
@ -158,7 +158,7 @@ reg_t kTimesTan(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kTimesCot(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int param = SKPV(0);
|
||||
int param = argv[0].toSint16();
|
||||
int scale = SKPV_OR_ALT(1, 1);
|
||||
|
||||
if ((param % 90) == 0) {
|
||||
|
@ -46,11 +46,11 @@ reg_t kAddMenu(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
|
||||
reg_t kSetMenu(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int index = UKPV(0);
|
||||
int index = argv[0].toUint16();
|
||||
int i = 2;
|
||||
|
||||
while (i < argc) {
|
||||
s->_menubar->setAttribute(s, (index >> 8) - 1, (index & 0xff) - 1, UKPV(i - 1), argv[i]);
|
||||
s->_menubar->setAttribute(s, (index >> 8) - 1, (index & 0xff) - 1, argv[i - 1].toUint16(), argv[i]);
|
||||
i += 2;
|
||||
}
|
||||
|
||||
@ -58,9 +58,9 @@ reg_t kSetMenu(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kGetMenu(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int index = UKPV(0);
|
||||
int index = argv[0].toUint16();
|
||||
|
||||
return s->_menubar->getAttribute((index >> 8) - 1, (index & 0xff) - 1, UKPV(1));
|
||||
return s->_menubar->getAttribute((index >> 8) - 1, (index & 0xff) - 1, argv[1].toUint16());
|
||||
}
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ reg_t kDrawStatus(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
reg_t kDrawMenuBar(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
if (SKPV(0))
|
||||
if (argv[0].toSint16())
|
||||
sciw_set_menubar(s, s->titlebar_port, s->_menubar, -1);
|
||||
else
|
||||
sciw_set_status_bar(s, s->titlebar_port, "", 0, 0);
|
||||
|
@ -52,7 +52,7 @@ reg_t kGameIsRestarting(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
s->r_acc = make_reg(0, (s->restarting_flags & SCI_GAME_WAS_RESTARTED));
|
||||
|
||||
if (argc) { // Only happens during replay
|
||||
if (!UKPV(0)) // Set restarting flag
|
||||
if (!argv[0].toUint16()) // Set restarting flag
|
||||
s->restarting_flags &= ~SCI_GAME_WAS_RESTARTED;
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ reg_t k_Unknown(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
reg_t kFlushResources(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
run_gc(s);
|
||||
debugC(2, kDebugLevelRoom, "Entering room number %d", UKPV(0));
|
||||
debugC(2, kDebugLevelRoom, "Entering room number %d", argv[0].toUint16());
|
||||
return s->r_acc;
|
||||
}
|
||||
|
||||
@ -164,15 +164,15 @@ enum {
|
||||
};
|
||||
|
||||
reg_t kMemory(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
switch (UKPV(0)) {
|
||||
switch (argv[0].toUint16()) {
|
||||
case K_MEMORY_ALLOCATE_CRITICAL :
|
||||
if (!s->seg_manager->allocDynmem(UKPV(1), "kMemory() critical", &s->r_acc)) {
|
||||
if (!s->seg_manager->allocDynmem(argv[1].toUint16(), "kMemory() critical", &s->r_acc)) {
|
||||
error("Critical heap allocation failed");
|
||||
}
|
||||
return s->r_acc;
|
||||
break;
|
||||
case K_MEMORY_ALLOCATE_NONCRITICAL :
|
||||
s->seg_manager->allocDynmem(UKPV(1), "kMemory() non-critical", &s->r_acc);
|
||||
s->seg_manager->allocDynmem(argv[1].toUint16(), "kMemory() non-critical", &s->r_acc);
|
||||
break;
|
||||
case K_MEMORY_FREE :
|
||||
if (s->seg_manager->freeDynmem(argv[1])) {
|
||||
@ -180,7 +180,7 @@ reg_t kMemory(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
break;
|
||||
case K_MEMORY_MEMCPY : {
|
||||
int size = UKPV(3);
|
||||
int size = argv[3].toUint16();
|
||||
byte *dest = kernel_dereference_bulk_pointer(s, argv[1], size);
|
||||
byte *src = kernel_dereference_bulk_pointer(s, argv[2], size);
|
||||
|
||||
|
@ -70,9 +70,9 @@ used in an iterative stepping algorithm
|
||||
reg_t kSetJump(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
// Input data
|
||||
reg_t object = argv[0];
|
||||
int dx = SKPV(1);
|
||||
int dy = SKPV(2);
|
||||
int gy = SKPV(3);
|
||||
int dx = argv[1].toSint16();
|
||||
int dy = argv[2].toSint16();
|
||||
int gy = argv[3].toSint16();
|
||||
|
||||
// Derived data
|
||||
int c;
|
||||
@ -224,7 +224,7 @@ reg_t kInitBresen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int deltax = GET_SEL32SV(mover, x) - GET_SEL32SV(client, x);
|
||||
int deltay = GET_SEL32SV(mover, y) - GET_SEL32SV(client, y);
|
||||
|
||||
initialize_bresen(s, argc, argv, mover, KP_UINT(KP_ALT(1, make_reg(0, 1))), deltax, deltay);
|
||||
initialize_bresen(s, argc, argv, mover, KP_ALT(1, make_reg(0, 1)).toUint16(), deltax, deltay);
|
||||
|
||||
return s->r_acc;
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ static void POLY_SET_POINT(byte *p, int i, const Common::Point &pt) {
|
||||
}
|
||||
|
||||
static void POLY_GET_POINT_REG_T(const reg_t *p, int i, Common::Point &pt) {
|
||||
pt.x = KP_SINT((p)[(i) * 2]);
|
||||
pt.y = KP_SINT((p)[(i) * 2 + 1]);
|
||||
pt.x = (p)[(i) * 2].toUint16();
|
||||
pt.y = (p)[(i) * 2 + 1].toUint16();
|
||||
}
|
||||
|
||||
// SCI-defined polygon types
|
||||
@ -286,13 +286,13 @@ static Common::Point read_point(const byte *list, int is_reg_t, int offset) {
|
||||
*/
|
||||
static bool polygons_equal(EngineState *s, reg_t p1, reg_t p2) {
|
||||
// Check for same type
|
||||
if (KP_UINT(GET_SEL32(p1, type)) != KP_UINT(GET_SEL32(p2, type)))
|
||||
if (GET_SEL32(p1, type).toUint16() != GET_SEL32(p2, type).toUint16())
|
||||
return false;
|
||||
|
||||
int size = KP_UINT(GET_SEL32(p1, size));
|
||||
int size = GET_SEL32(p1, size).toUint16();
|
||||
|
||||
// Check for same number of points
|
||||
if (size != KP_UINT(GET_SEL32(p2, size)))
|
||||
if (size != GET_SEL32(p2, size).toUint16())
|
||||
return false;
|
||||
|
||||
const byte *p1_points = kernel_dereference_bulk_pointer(s, GET_SEL32(p1, points), size * POLY_POINT_SIZE);
|
||||
@ -356,8 +356,8 @@ static void draw_point(EngineState *s, Common::Point p, int start) {
|
||||
|
||||
static void draw_polygon(EngineState *s, reg_t polygon) {
|
||||
reg_t points = GET_SEL32(polygon, points);
|
||||
int size = KP_UINT(GET_SEL32(polygon, size));
|
||||
int type = KP_UINT(GET_SEL32(polygon, type));
|
||||
int size = GET_SEL32(polygon, size).toUint16();
|
||||
int type = GET_SEL32(polygon, type).toUint16();
|
||||
Common::Point first, prev;
|
||||
const byte *list = kernel_dereference_bulk_pointer(s, points, size * POLY_POINT_SIZE);
|
||||
int is_reg_t = polygon_is_reg_t(list, size);
|
||||
@ -403,8 +403,8 @@ static void draw_input(EngineState *s, reg_t poly_list, Common::Point start, Com
|
||||
|
||||
static void print_polygon(EngineState *s, reg_t polygon) {
|
||||
reg_t points = GET_SEL32(polygon, points);
|
||||
int size = KP_UINT(GET_SEL32(polygon, size));
|
||||
int type = KP_UINT(GET_SEL32(polygon, type));
|
||||
int size = GET_SEL32(polygon, size).toUint16();
|
||||
int type = GET_SEL32(polygon, type).toUint16();
|
||||
int i;
|
||||
const byte *point_array = kernel_dereference_bulk_pointer(s, points, size * POLY_POINT_SIZE);
|
||||
int is_reg_t = polygon_is_reg_t(point_array, size);
|
||||
@ -1228,9 +1228,9 @@ static Polygon *convert_polygon(EngineState *s, reg_t polygon) {
|
||||
// Returns : (Polygon *) The converted polygon
|
||||
int i;
|
||||
reg_t points = GET_SEL32(polygon, points);
|
||||
int size = KP_UINT(GET_SEL32(polygon, size));
|
||||
int size = GET_SEL32(polygon, size).toUint16();
|
||||
const byte *list = kernel_dereference_bulk_pointer(s, points, size * POLY_POINT_SIZE);
|
||||
Polygon *poly = new Polygon(KP_UINT(GET_SEL32(polygon, type)));
|
||||
Polygon *poly = new Polygon(GET_SEL32(polygon, type).toUint16());
|
||||
int is_reg_t = polygon_is_reg_t(list, size);
|
||||
|
||||
// WORKAROUND: broken polygon in LSL1VGA, room 350, after opening elevator
|
||||
@ -1388,7 +1388,7 @@ static PathfindingState *convert_polygon_set(EngineState *s, reg_t poly_list, Co
|
||||
// Polygon is not a duplicate, so convert it
|
||||
polygon = convert_polygon(s, node->value);
|
||||
pf_s->polygons.push_back(polygon);
|
||||
count += KP_UINT(GET_SEL32(node->value, size));
|
||||
count += GET_SEL32(node->value, size).toUint16();
|
||||
}
|
||||
|
||||
node = lookup_node(s, node->succ);
|
||||
@ -1642,7 +1642,7 @@ static reg_t output_path(PathfindingState *p, EngineState *s) {
|
||||
}
|
||||
|
||||
reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
Common::Point start = Common::Point(SKPV(0), SKPV(1));
|
||||
Common::Point start = Common::Point(argv[0].toSint16(), argv[1].toSint16());
|
||||
|
||||
#ifdef DEBUG_AVOIDPATH
|
||||
GfxPort *port = s->picture_port;
|
||||
@ -1669,9 +1669,9 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
case 6 :
|
||||
case 7 : {
|
||||
Common::Point end = Common::Point(SKPV(2), SKPV(3));
|
||||
Common::Point end = Common::Point(argv[2].toSint16(), argv[3].toSint16());
|
||||
reg_t poly_list = argv[4];
|
||||
//int poly_list_size = UKPV(5);
|
||||
//int poly_list_size = argv[5].toUint16();
|
||||
int opt = UKPV_OR_ALT(6, 1);
|
||||
reg_t output;
|
||||
PathfindingState *p;
|
||||
|
@ -114,8 +114,8 @@ bool is_object(EngineState *s, reg_t object) {
|
||||
// Loads arbitrary resources of type 'restype' with resource numbers 'resnrs'
|
||||
// This implementation ignores all resource numbers except the first one.
|
||||
reg_t kLoad(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int restype = KP_UINT(argv[0]);
|
||||
int resnr = KP_UINT(argv[1]);
|
||||
int restype = argv[0].toUint16();
|
||||
int resnr = argv[1].toUint16();
|
||||
|
||||
// Request to dynamically allocate hunk memory for later use
|
||||
if (restype == kResourceTypeMemory)
|
||||
@ -125,9 +125,9 @@ reg_t kLoad(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kLock(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int restype = UKPV(0) & 0x7f;
|
||||
int resnr = UKPV(1);
|
||||
int state = argc > 2 ? UKPV(2) : 1;
|
||||
int restype = argv[0].toUint16() & 0x7f;
|
||||
int resnr = argv[1].toUint16();
|
||||
int state = argc > 2 ? argv[2].toUint16() : 1;
|
||||
|
||||
Resource *which;
|
||||
|
||||
@ -145,7 +145,7 @@ reg_t kLock(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
// Unloads an arbitrary resource of type 'restype' with resource numbber 'resnr'
|
||||
reg_t kUnLoad(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int restype = KP_UINT(argv[0]);
|
||||
int restype = argv[0].toUint16();
|
||||
reg_t resnr = argv[1];
|
||||
|
||||
if (restype == kResourceTypeMemory)
|
||||
@ -155,24 +155,24 @@ reg_t kUnLoad(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kResCheck(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
ResourceType restype = (ResourceType)(UKPV(0) & 0x7f);
|
||||
ResourceType restype = (ResourceType)(argv[0].toUint16() & 0x7f);
|
||||
|
||||
switch (restype) {
|
||||
case kResourceTypeAudio36:
|
||||
case kResourceTypeSync36: {
|
||||
assert(argc >= 6);
|
||||
|
||||
uint module = UKPV(1);
|
||||
uint noun = UKPV(2);
|
||||
uint verb = UKPV(3);
|
||||
uint cond = UKPV(4);
|
||||
uint seq = UKPV(5);
|
||||
uint module = argv[1].toUint16();
|
||||
uint noun = argv[2].toUint16();
|
||||
uint verb = argv[3].toUint16();
|
||||
uint cond = argv[4].toUint16();
|
||||
uint seq = argv[5].toUint16();
|
||||
warning("ResCheck: checking for currently unsupported %s resource: module %i; tuple (%i, %i, %i, %i)",
|
||||
getResourceTypeName(restype), module, noun, verb, cond, seq);
|
||||
return make_reg(0, 1);
|
||||
}
|
||||
default:
|
||||
Resource *res = s->resmgr->testResource(restype, UKPV(1));
|
||||
Resource *res = s->resmgr->testResource(restype, argv[1].toUint16());
|
||||
return make_reg(0, res != NULL);
|
||||
}
|
||||
}
|
||||
@ -252,8 +252,8 @@ reg_t kDisposeClone(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
// Returns script dispatch address index in the supplied script
|
||||
reg_t kScriptID(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int script = KP_UINT(argv[0]);
|
||||
int index = KP_UINT(KP_ALT(1, NULL_REG));
|
||||
int script = argv[0].toUint16();
|
||||
int index = KP_ALT(1, NULL_REG).toUint16();
|
||||
|
||||
SegmentId scriptid = script_get_segment(s, script, SCRIPT_GET_LOAD);
|
||||
Script *scr;
|
||||
@ -313,7 +313,7 @@ reg_t kIsObject(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
reg_t kRespondsTo(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
reg_t obj = argv[0];
|
||||
int selector = KP_UINT(argv[1]);
|
||||
int selector = argv[1].toUint16();
|
||||
|
||||
return make_reg(0, is_heap_object(s, obj) && lookup_selector(s, obj, selector, NULL, NULL) != kSelectorNone);
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their
|
||||
|
||||
reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
reg_t obj = KP_ALT(1, NULL_REG);
|
||||
uint16 command = UKPV(0);
|
||||
uint16 command = argv[0].toUint16();
|
||||
song_handle_t handle = FROBNICATE_HANDLE(obj);
|
||||
int number = obj.segment ?
|
||||
GET_SEL32V(obj, number) :
|
||||
@ -381,7 +381,7 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
|
||||
reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
uint16 command = UKPV(0);
|
||||
uint16 command = argv[0].toUint16();
|
||||
reg_t obj = KP_ALT(1, NULL_REG);
|
||||
song_handle_t handle = FROBNICATE_HANDLE(obj);
|
||||
int number = obj.segment ?
|
||||
@ -487,7 +487,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int looping = GET_SEL32V(obj, loop);
|
||||
//int vol = GET_SEL32V(obj, vol);
|
||||
int pri = GET_SEL32V(obj, pri);
|
||||
RESTORE_BEHAVIOR rb = (RESTORE_BEHAVIOR) UKPV(2); /* Too lazy to look up a default value for this */
|
||||
RESTORE_BEHAVIOR rb = (RESTORE_BEHAVIOR) argv[2].toUint16(); /* Too lazy to look up a default value for this */
|
||||
|
||||
if (obj.segment) {
|
||||
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_PLAYING);
|
||||
@ -551,7 +551,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
break;
|
||||
}
|
||||
case _K_SCI01_SOUND_SUSPEND_HANDLE : {
|
||||
int state = UKPV(2);
|
||||
int state = argv[2].toUint16();
|
||||
int setstate = (state) ?
|
||||
SOUND_STATUS_SUSPENDED : SOUND_STATUS_PLAYING;
|
||||
|
||||
@ -647,12 +647,12 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
break;
|
||||
}
|
||||
case _K_SCI01_SOUND_MIDI_SEND : {
|
||||
int channel = SKPV(2);
|
||||
int midiCmd = UKPV(3) == 0xff ?
|
||||
int channel = argv[2].toSint16();
|
||||
int midiCmd = argv[3].toUint16() == 0xff ?
|
||||
0xe0 : /* Pitch wheel */
|
||||
0xb0; /* UKPV(3) is actually a controller number */
|
||||
int controller = UKPV(3);
|
||||
int param = UKPV(4);
|
||||
0xb0; /* argv[3].toUint16() is actually a controller number */
|
||||
int controller = argv[3].toUint16();
|
||||
int param = argv[4].toUint16();
|
||||
|
||||
s->_sound.sfx_send_midi(handle,
|
||||
channel, midiCmd, controller, param);
|
||||
@ -662,7 +662,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
break;
|
||||
}
|
||||
case _K_SCI01_SOUND_HOLD : {
|
||||
//int flag = SKPV(2);
|
||||
//int flag = argv[2].toSint16();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -671,7 +671,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
uint16 command = UKPV(0);
|
||||
uint16 command = argv[0].toUint16();
|
||||
reg_t obj = KP_ALT(1, NULL_REG);
|
||||
song_handle_t handle = FROBNICATE_HANDLE(obj);
|
||||
int number = obj.segment ?
|
||||
@ -866,10 +866,10 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case _K_SCI1_SOUND_FADE_HANDLE : {
|
||||
fade_params_t fade;
|
||||
if (obj.segment) {
|
||||
fade.final_volume = UKPV(2);
|
||||
fade.ticks_per_step = UKPV(3);
|
||||
fade.step_size = UKPV(4);
|
||||
fade.action = UKPV(5) ?
|
||||
fade.final_volume = argv[2].toUint16();
|
||||
fade.ticks_per_step = argv[3].toUint16();
|
||||
fade.step_size = argv[4].toUint16();
|
||||
fade.action = argv[5].toUint16() ?
|
||||
FADE_ACTION_FADE_AND_STOP :
|
||||
FADE_ACTION_FADE_AND_CONT;
|
||||
|
||||
@ -877,7 +877,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
/* FIXME: The next couple of lines actually STOP the handle, rather
|
||||
** than fading it! */
|
||||
if (UKPV(5)) {
|
||||
if (argv[5].toUint16()) {
|
||||
PUT_SEL32V(obj, signal, -1);
|
||||
PUT_SEL32V(obj, nodePtr, 0);
|
||||
PUT_SEL32V(obj, handle, 0);
|
||||
@ -890,7 +890,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
break;
|
||||
}
|
||||
case _K_SCI1_SOUND_HOLD_HANDLE : {
|
||||
int value = SKPV(2);
|
||||
int value = argv[2].toSint16();
|
||||
|
||||
s->_sound.sfx_song_set_hold(handle, value);
|
||||
break;
|
||||
@ -902,7 +902,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
break;
|
||||
}
|
||||
case _K_SCI1_SOUND_SET_HANDLE_PRIORITY : {
|
||||
int value = SKPV(2);
|
||||
int value = argv[2].toSint16();
|
||||
|
||||
script_set_priority(s, obj, value);
|
||||
break;
|
||||
@ -950,7 +950,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
case _K_SCI1_SOUND_MIDI_SEND : {
|
||||
s->_sound.sfx_send_midi(handle,
|
||||
UKPV(2), UKPV(3), UKPV(4), UKPV(5));
|
||||
argv[2].toUint16(), argv[3].toUint16(), argv[4].toUint16(), argv[5].toUint16());
|
||||
break;
|
||||
}
|
||||
case _K_SCI1_SOUND_REVERB : {
|
||||
@ -980,27 +980,27 @@ reg_t kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
if (!s->_sound._audioResource)
|
||||
s->_sound._audioResource = new AudioResource(s->resmgr, s->_version);
|
||||
|
||||
switch (UKPV(0)) {
|
||||
switch (argv[0].toUint16()) {
|
||||
case kSciAudioWPlay:
|
||||
case kSciAudioPlay:
|
||||
s->_sound._audioResource->stop();
|
||||
|
||||
if (argc == 2) { // KQ5CD, KQ6 floppy
|
||||
Audio::AudioStream *audioStream = s->_sound._audioResource->getAudioStream(UKPV(1), 65535, &sampleLen);
|
||||
Audio::AudioStream *audioStream = s->_sound._audioResource->getAudioStream(argv[1].toUint16(), 65535, &sampleLen);
|
||||
|
||||
if (audioStream)
|
||||
mixer->playInputStream(Audio::Mixer::kSpeechSoundType, s->_sound._audioResource->getAudioHandle(), audioStream);
|
||||
} else if (argc == 6) { // SQ4CD or newer
|
||||
//uint32 volume = UKPV(1);
|
||||
//uint32 volume = argv[1].toUint16();
|
||||
// Make a BE number
|
||||
uint32 audioNumber = (((UKPV(2) & 0xFF) << 24) & 0xFF000000) |
|
||||
(((UKPV(3) & 0xFF) << 16) & 0x00FF0000) |
|
||||
(((UKPV(4) & 0xFF) << 8) & 0x0000FF00) |
|
||||
( (UKPV(5) & 0xFF) & 0x000000FF);
|
||||
uint32 audioNumber = (((argv[2].toUint16() & 0xFF) << 24) & 0xFF000000) |
|
||||
(((argv[3].toUint16() & 0xFF) << 16) & 0x00FF0000) |
|
||||
(((argv[4].toUint16() & 0xFF) << 8) & 0x0000FF00) |
|
||||
( (argv[5].toUint16() & 0xFF) & 0x000000FF);
|
||||
|
||||
printf("%d %d %d %d -> %d\n", UKPV(2), UKPV(3), UKPV(4), UKPV(5), audioNumber); // debugging
|
||||
printf("%d %d %d %d -> %d\n", argv[2].toUint16(), argv[3].toUint16(), argv[4].toUint16(), argv[5].toUint16(), audioNumber); // debugging
|
||||
|
||||
Audio::AudioStream *audioStream = s->_sound._audioResource->getAudioStream(audioNumber, UKPV(1), &sampleLen);
|
||||
Audio::AudioStream *audioStream = s->_sound._audioResource->getAudioStream(audioNumber, argv[1].toUint16(), &sampleLen);
|
||||
|
||||
if (audioStream)
|
||||
mixer->playInputStream(Audio::Mixer::kSpeechSoundType, s->_sound._audioResource->getAudioHandle(), audioStream);
|
||||
@ -1020,28 +1020,28 @@ reg_t kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case kSciAudioPosition:
|
||||
return make_reg(0, s->_sound._audioResource->getAudioPosition());
|
||||
case kSciAudioRate:
|
||||
s->_sound._audioResource->setAudioRate(UKPV(1));
|
||||
s->_sound._audioResource->setAudioRate(argv[1].toUint16());
|
||||
break;
|
||||
case kSciAudioVolume:
|
||||
mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, UKPV(1));
|
||||
mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, argv[1].toUint16());
|
||||
break;
|
||||
case kSciAudioLanguage:
|
||||
if (argc == 1) {
|
||||
// In SCI1.1: tests for digital audio support
|
||||
return make_reg(0, 1);
|
||||
} else {
|
||||
s->_sound._audioResource->setAudioLang(SKPV(1));
|
||||
s->_sound._audioResource->setAudioLang(argv[1].toSint16());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
warning("kDoAudio: Unhandled case %d", UKPV(0));
|
||||
warning("kDoAudio: Unhandled case %d", argv[0].toUint16());
|
||||
}
|
||||
|
||||
return s->r_acc;
|
||||
}
|
||||
|
||||
reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
switch (UKPV(0)) {
|
||||
switch (argv[0].toUint16()) {
|
||||
case kSciAudioSyncStart:
|
||||
if (argc == 3) { // KQ5CD, KQ6 floppy
|
||||
if (s->_sound._soundSync) {
|
||||
@ -1049,7 +1049,7 @@ reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
// Load sound sync resource and lock it
|
||||
s->_sound._soundSync = (ResourceSync *)s->resmgr->findResource(kResourceTypeSync, UKPV(2), 1);
|
||||
s->_sound._soundSync = (ResourceSync *)s->resmgr->findResource(kResourceTypeSync, argv[2].toUint16(), 1);
|
||||
|
||||
if (s->_sound._soundSync) {
|
||||
s->_sound._soundSync->startSync(s, argv[1]);
|
||||
@ -1059,7 +1059,7 @@ reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
} else if (argc == 7) { // SQ4CD or newer
|
||||
// TODO
|
||||
warning("kDoSync: Start called with new semantics - 6 parameters: %d %d %d %d %d %d", UKPV(1), UKPV(2), UKPV(3), UKPV(4), UKPV(5), UKPV(6));
|
||||
warning("kDoSync: Start called with new semantics - 6 parameters: %d %d %d %d %d %d", argv[1].toUint16(), argv[2].toUint16(), argv[3].toUint16(), argv[4].toUint16(), argv[5].toUint16(), argv[6].toUint16());
|
||||
} else { // Hopefully, this should never happen
|
||||
warning("kDoSync: Start called with an unknown number of parameters (%d)", argc);
|
||||
}
|
||||
@ -1077,7 +1077,7 @@ reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
warning("kDoSync: Unhandled case %d", UKPV(0));
|
||||
warning("kDoSync: Unhandled case %d", argv[0].toUint16());
|
||||
}
|
||||
|
||||
return s->r_acc;
|
||||
|
@ -281,7 +281,7 @@ reg_t kStrCmp(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
char *s2 = kernel_dereference_char_pointer(s, argv[1], 0);
|
||||
|
||||
if (argc > 2)
|
||||
return make_reg(0, strncmp(s1, s2, UKPV(2)));
|
||||
return make_reg(0, strncmp(s1, s2, argv[2].toUint16()));
|
||||
else
|
||||
return make_reg(0, strcmp(s1, s2));
|
||||
}
|
||||
@ -304,7 +304,7 @@ reg_t kStrCpy(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
int length = SKPV(2);
|
||||
int length = argv[2].toSint16();
|
||||
|
||||
if (length >= 0)
|
||||
strncpy(dest, src, length);
|
||||
@ -376,19 +376,19 @@ reg_t kStrAt(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
((strlen(dst) < 2) || (!lsl5PasswordWorkaround && !is_print_str(dst)))) {
|
||||
// SQ4 array handling detected
|
||||
#ifndef SCUMM_BIG_ENDIAN
|
||||
int odd = KP_UINT(argv[1]) & 1;
|
||||
int odd = argv[1].toUint16() & 1;
|
||||
#else
|
||||
int odd = !(KP_UINT(argv[1]) & 1);
|
||||
int odd = !(argv[1].toUint16() & 1);
|
||||
#endif
|
||||
dest2 = ((reg_t *) dest) + (KP_UINT(argv[1]) / 2);
|
||||
dest2 = ((reg_t *) dest) + (argv[1].toUint16() / 2);
|
||||
dest = ((byte *)(&dest2->offset)) + odd;
|
||||
} else
|
||||
dest += KP_UINT(argv[1]);
|
||||
dest += argv[1].toUint16();
|
||||
|
||||
s->r_acc = make_reg(0, *dest);
|
||||
|
||||
if (argc > 2)
|
||||
*dest = KP_SINT(argv[2]); /* Request to modify this char */
|
||||
*dest = argv[2].toSint16(); /* Request to modify this char */
|
||||
|
||||
return s->r_acc;
|
||||
}
|
||||
@ -423,7 +423,7 @@ reg_t kFormat(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
reg_t dest = argv[0];
|
||||
char *target = (char *) kernel_dereference_bulk_pointer(s, dest, 0);
|
||||
reg_t position = argv[1]; /* source */
|
||||
int index = UKPV(2);
|
||||
int index = argv[2].toUint16();
|
||||
char *source;
|
||||
char *str_base = target;
|
||||
int mode = 0;
|
||||
@ -452,7 +452,7 @@ reg_t kFormat(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
#endif
|
||||
|
||||
for (i = startarg; i < argc; i++)
|
||||
arguments[i-startarg] = UKPV(i); /* Parameters are copied to prevent overwriting */
|
||||
arguments[i-startarg] = argv[i].toUint16(); /* Parameters are copied to prevent overwriting */
|
||||
|
||||
while ((xfer = *source++)) {
|
||||
if (xfer == '%') {
|
||||
@ -646,13 +646,13 @@ reg_t kStrLen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
|
||||
reg_t kGetFarText(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
Resource *textres = s->resmgr->findResource(kResourceTypeText, UKPV(0), 0);
|
||||
Resource *textres = s->resmgr->findResource(kResourceTypeText, argv[0].toUint16(), 0);
|
||||
char *seeker;
|
||||
int counter = UKPV(1);
|
||||
int counter = argv[1].toUint16();
|
||||
|
||||
|
||||
if (!textres) {
|
||||
error("text.%d does not exist", UKPV(0));
|
||||
error("text.%d does not exist", argv[0].toUint16());
|
||||
return NULL_REG;
|
||||
}
|
||||
|
||||
@ -693,18 +693,18 @@ reg_t kMessage(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
if (isGetMessage) {
|
||||
func = K_MESSAGE_GET;
|
||||
|
||||
tuple.noun = UKPV(0);
|
||||
tuple.verb = UKPV(2);
|
||||
tuple.noun = argv[0].toUint16();
|
||||
tuple.verb = argv[2].toUint16();
|
||||
tuple.cond = 0;
|
||||
tuple.seq = 1;
|
||||
} else {
|
||||
func = UKPV(0);
|
||||
func = argv[0].toUint16();
|
||||
|
||||
if (argc >= 6) {
|
||||
tuple.noun = UKPV(2);
|
||||
tuple.verb = UKPV(3);
|
||||
tuple.cond = UKPV(4);
|
||||
tuple.seq = UKPV(5);
|
||||
tuple.noun = argv[2].toUint16();
|
||||
tuple.verb = argv[3].toUint16();
|
||||
tuple.cond = argv[4].toUint16();
|
||||
tuple.seq = argv[5].toUint16();
|
||||
}
|
||||
}
|
||||
|
||||
@ -717,7 +717,7 @@ reg_t kMessage(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
reg_t retval;
|
||||
|
||||
if (func == K_MESSAGE_GET) {
|
||||
s->_msgState.loadRes(s->resmgr, UKPV(1), true);
|
||||
s->_msgState.loadRes(s->resmgr, argv[1].toUint16(), true);
|
||||
s->_msgState.findTuple(tuple);
|
||||
|
||||
if (isGetMessage)
|
||||
@ -762,7 +762,7 @@ reg_t kMessage(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case K_MESSAGE_SIZE: {
|
||||
MessageState tempState;
|
||||
|
||||
if (tempState.loadRes(s->resmgr, UKPV(1), false) && tempState.findTuple(tuple) && tempState.getMessage())
|
||||
if (tempState.loadRes(s->resmgr, argv[1].toUint16(), false) && tempState.findTuple(tuple) && tempState.getMessage())
|
||||
return make_reg(0, tempState.getText().size() + 1);
|
||||
else
|
||||
return NULL_REG;
|
||||
@ -772,7 +772,7 @@ reg_t kMessage(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case K_MESSAGE_REFNOUN: {
|
||||
MessageState tempState;
|
||||
|
||||
if (tempState.loadRes(s->resmgr, UKPV(1), false) && tempState.findTuple(tuple)) {
|
||||
if (tempState.loadRes(s->resmgr, argv[1].toUint16(), false) && tempState.findTuple(tuple)) {
|
||||
MessageTuple t = tempState.getRefTuple();
|
||||
switch (func) {
|
||||
case K_MESSAGE_REFCOND:
|
||||
|
@ -123,7 +123,7 @@ EngineState::~EngineState() {
|
||||
}
|
||||
|
||||
uint16 EngineState::currentRoomNumber() const {
|
||||
return KP_UINT(script_000->locals_block->_locals[13]);
|
||||
return script_000->locals_block->_locals[13].toUint16();
|
||||
}
|
||||
|
||||
} // End of namespace Sci
|
||||
|
@ -48,6 +48,14 @@ struct reg_t {
|
||||
bool operator!=(const reg_t &x) const {
|
||||
return (offset != x.offset) || (segment != x.segment);
|
||||
}
|
||||
|
||||
uint16 toUint16() const {
|
||||
return offset;
|
||||
}
|
||||
|
||||
int16 toSint16() const {
|
||||
return (int16) offset;
|
||||
}
|
||||
};
|
||||
|
||||
#define PRINT_REG(r) (0xffff) & (unsigned) (r).segment, (unsigned) (r).offset
|
||||
|
Loading…
Reference in New Issue
Block a user