diff options
Diffstat (limited to 'engines/groovie/script.cpp')
-rw-r--r-- | engines/groovie/script.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index 894e4d2c60..c1cdd1e7d4 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -1315,7 +1315,7 @@ void Script::o_sub() { void Script::o_cellmove() { uint16 arg = readScript8bits(); byte *scriptBoard = &_variables[0x19]; - byte board[7][7]; + byte *board = (byte*) malloc (BOARDSIZE * BOARDSIZE * sizeof(byte)); byte startX, startY, endX, endY; debugScript(1, true, "CELL MOVE var[0x%02X]", arg); @@ -1323,22 +1323,23 @@ void Script::o_cellmove() { // Arguments used by the original implementation: (2, arg, scriptBoard) for (int y = 0; y < 7; y++) { for (int x = 0; x < 7; x++) { - board[x][y] = 0; - if (*scriptBoard == 0x32) board[x][y] = 1; - if (*scriptBoard == 0x42) board[x][y] = 2; + uint8 offset = x + BOARDSIZE * y; + *(board + offset) = 0; + if (*scriptBoard == 0x32) *(board + offset) = CELL_BLUE; + if (*scriptBoard == 0x42) *(board + offset) = CELL_GREEN; scriptBoard++; - debugScript(1, false, "%d", board[x][y]); + debugScript(1, false, "%d", *(board + offset)); } debugScript(1, false, "\n"); } CellGame staufsMove((byte*) board); + staufsMove.calcMove((byte*) board, CELL_GREEN, 2); startX = staufsMove.getStartX(); startY = staufsMove.getStartY(); endX = staufsMove.getEndX(); endY = staufsMove.getEndY(); - //printf("Moving from %d,%d to %d,%d\n", startX, startY, endX, endY); // Set the movement origin setVariable(0, startY); // y @@ -1346,6 +1347,8 @@ void Script::o_cellmove() { // Set the movement destination setVariable(2, endY); setVariable(3, endX); + + free (board); } void Script::o_returnscript() { |