aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/patches.cpp
blob: c0b057a158778e477870cd0b9a5ab008f0f55d1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2006 The ScummVM project
 *
 * Copyright (C) 1999-2001 Sarien Team
 *
 * 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/stdafx.h"

#include "agi/agi.h"
#include "agi/opcodes.h"

namespace Agi {

#ifdef PATCH_LOGIC

#define ip (_game.logics[n].cIP)
#define code (_game.logics[n].data)
#define size (_game.logics[n].size)

/*
 * Patches
 */

static const uint8 kq4dataFind[] = {
	0x0C, 0x04, 0xFF, 0x07, 0x05, 0xFF, 0x15, 0x00,
	0x03, 0x0A, 0x00, 0x77, 0x83, 0x71, 0x0D, 0x97,
	0x03, 0x98, 0xCE, 0x18, 0x98, 0x19, 0x98, 0x1B,
	0x98, 0x0C, 0x5A, 0x1A, 0x00
};

static const uint8 kq4dataFix[] = {
	/* v19 = 0
	 * new.room(96)
	 * return
	 */
	0x03, 0x13, 0x0, 0x12, 0x60, 0x00
};

static const uint8 grdataFind[] = {
	0x0C, 0x04, 0xFF, 0x07, 0x05, 0xFF, 0x16, 0x00,
	0x0C, 0x96, 0x03, 0x0A, 0x00, 0x77, 0x83, 0x71,
	0x0D, 0xD9, 0x03, 0xDC, 0xBF, 0x18, 0xDC, 0x19,
	0xDC, 0x1B, 0xDC, 0x0C, 0x95, 0x1A
};

static const uint8 grdataFix[] = {
	/* reset(227)
	 * v19 = 0
	 * v246 = 1
	 * set(15)
	 * new.room(73)
	 */
	0x0D, 0xE3, 0x03, 0x13, 0x00, 0x03, 0xF6, 0x01,
	0x0C, 0x0F, 0x12, 0x49
};

#if 0
static const uint8 lsl1dataFind[] = {
	0xFF, 0xFD, 0x07, 0x1E, 0xFC, 0x07, 0x6D, 0x01,
	0x5F, 0x03, 0xFC, 0xFF, 0x12, 0x00, 0x0C, 0x6D,
	0x78, 0x8A, 0x77, 0x69, 0x16, 0x18, 0x00, 0x0D,
	0x30, 0x0D, 0x55, 0x78, 0x65, 0x0A
};

static const uint8 lsl1dataFix[] = {
	/* set(109)
	 * reset(48)
	 * reset(85)
	 * accept.input()
	 * new.room(11)
	 */
	0x0C, 0x6D, 0x0D, 0x30, 0x0D, 0x55, 0x78, 0x12,
	0x0B
};
#endif

static const uint8 mh1dataFind[] = {
	0xFF, 0x07, 0x05, 0xFF, 0xE6, 0x00,
	0x03, 0x0A, 0x02, 0x77, 0x83, 0x71,
	0x6F, 0x01, 0x17, 0x00, 0x03, 0x00,
	0x9F, 0x03, 0x37, 0x00, 0x03, 0x32,
	0x03, 0x03, 0x3B, 0x00, 0x6C, 0x03
};

static const uint8 mh1dataFix[] = {
	0x0C, 0x05, 0x16, 0x5A, 0x12, 0x99
};

void AgiEngine::patchLogic(int n) {
	switch (n) {
#if 0
		/* ALT-X in the questions takes care of that */
	case 6:
		/* lsl1 bypass questions */
		if (!strcmp(_game.id, "LLLLL")) {
			if (!memcmp(lsl1dataFind, (code + ip), 30))
				memmove((code + ip), lsl1dataFix, 9);
		}
		break;
#endif
	case 125:
		/* gold rush code break */
		if (!strcmp(_game.id, "GR")) {
			if (!memcmp(grdataFind, (code + ip), 30))
				memmove((code + ip), grdataFix, 12);
		}
		break;
	case 140:
		/* kings quest 4 code break */
		if (!strcmp(_game.id, "KQ4")) {
			if (memcmp(kq4dataFind, (code + ip), 29) == 0)
				memmove((code + ip), kq4dataFix, 6);
		}
		break;
	case 159:
		/* manhunter 1 amiga */
		if (ip + 30 < size && !memcmp(mh1dataFind, (code + ip), 30)) {
			memmove((code + ip), mh1dataFix, 6);
		}
		break;
	}
}

#endif

} // End of namespace Agi