diff options
author | Franklin Wei <frankhwei536@gmail.com> | 2016-11-03 22:27:01 -0400 |
---|---|---|
committer | Gerrit Rockbox <gerrit@rockbox.org> | 2016-11-19 19:17:14 +0100 |
commit | 05733649bce2623acfad7b163501c6fdefea985a (patch) | |
tree | 8db235af25ae7e72f9793879bd1119db90990cf4 /apps/plugins/xworld/vm.c | |
parent | deaeb73912c1bb9fd4d3498e59d1789761f3e322 (diff) | |
download | rockbox-05733649bce2623acfad7b163501c6fdefea985a.tar.gz rockbox-05733649bce2623acfad7b163501c6fdefea985a.zip |
XWorld: some fixes
Fixes sound on most platforms, original root cause was bad menu code
as well as DMA callbacks taking too long. Worked around with smaller
chunk sizes. Permanent fix would include moving mixing out of the
callback. Rewrites input with code from rockboy/doom. Cherry-picks a
change from Gregory Montoir's `rawgl' to patch the code wheel
screen. Finally, adds a motion blur filter on select targets.
Change-Id: I8df549c923c5075800c6625c36c8202e53de1d27
Diffstat (limited to 'apps/plugins/xworld/vm.c')
-rw-r--r-- | apps/plugins/xworld/vm.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/apps/plugins/xworld/vm.c b/apps/plugins/xworld/vm.c index de632d710d..10c3957ad7 100644 --- a/apps/plugins/xworld/vm.c +++ b/apps/plugins/xworld/vm.c | |||
@@ -52,7 +52,13 @@ void vm_init(struct VirtualMachine* m) { | |||
52 | 52 | ||
53 | rb->memset(m->vmVariables, 0, sizeof(m->vmVariables)); | 53 | rb->memset(m->vmVariables, 0, sizeof(m->vmVariables)); |
54 | m->vmVariables[0x54] = 0x81; | 54 | m->vmVariables[0x54] = 0x81; |
55 | m->vmVariables[VM_VARIABLE_RANDOM_SEED] = *rb->current_tick; | 55 | m->vmVariables[VM_VARIABLE_RANDOM_SEED] = *rb->current_tick % 0x10000; |
56 | |||
57 | /* rawgl has these, but they don't seem to do anything */ | ||
58 | //m->vmVariables[0xBC] = 0x10; | ||
59 | //m->vmVariables[0xC6] = 0x80; | ||
60 | //m->vmVariables[0xF2] = 4000; | ||
61 | //m->vmVariables[0xDC] = 33; | ||
56 | 62 | ||
57 | m->_fastMode = false; | 63 | m->_fastMode = false; |
58 | m->player->_markVar = &m->vmVariables[VM_VARIABLE_MUS_MARK]; | 64 | m->player->_markVar = &m->vmVariables[VM_VARIABLE_MUS_MARK]; |
@@ -81,7 +87,7 @@ void vm_op_add(struct VirtualMachine* m) { | |||
81 | 87 | ||
82 | void vm_op_addConst(struct VirtualMachine* m) { | 88 | void vm_op_addConst(struct VirtualMachine* m) { |
83 | if (m->res->currentPartId == 0x3E86 && m->_scriptPtr.pc == m->res->segBytecode + 0x6D48) { | 89 | if (m->res->currentPartId == 0x3E86 && m->_scriptPtr.pc == m->res->segBytecode + 0x6D48) { |
84 | warning("vm_op_addConst() hack for non-stop looping gun sound bug"); | 90 | //warning("vm_op_addConst() hack for non-stop looping gun sound bug"); |
85 | // the script 0x27 slot 0x17 doesn't stop the gun sound from looping, I | 91 | // the script 0x27 slot 0x17 doesn't stop the gun sound from looping, I |
86 | // don't really know why ; for now, let's play the 'stopping sound' like | 92 | // don't really know why ; for now, let's play the 'stopping sound' like |
87 | // the other scripts do | 93 | // the other scripts do |
@@ -152,10 +158,9 @@ void vm_op_jnz(struct VirtualMachine* m) { | |||
152 | #define BYPASS_PROTECTION | 158 | #define BYPASS_PROTECTION |
153 | void vm_op_condJmp(struct VirtualMachine* m) { | 159 | void vm_op_condJmp(struct VirtualMachine* m) { |
154 | 160 | ||
155 | //printf("Jump : %X \n",m->_scriptPtr.pc-m->res->segBytecode); | 161 | //debug(DBG_VM, "Jump : %X \n",m->_scriptPtr.pc-m->res->segBytecode); |
156 | //FCS Whoever wrote this is patching the bytecode on the fly. This is ballzy !! | 162 | //FCS Whoever wrote this is patching the bytecode on the fly. This is ballzy !! |
157 | #ifdef BYPASS_PROTECTION | 163 | #if 0 |
158 | |||
159 | if (m->res->currentPartId == GAME_PART_FIRST && m->_scriptPtr.pc == m->res->segBytecode + 0xCB9) { | 164 | if (m->res->currentPartId == GAME_PART_FIRST && m->_scriptPtr.pc == m->res->segBytecode + 0xCB9) { |
160 | 165 | ||
161 | // (0x0CB8) condJmp(0x80, VAR(41), VAR(30), 0xCD3) | 166 | // (0x0CB8) condJmp(0x80, VAR(41), VAR(30), 0xCD3) |
@@ -168,6 +173,8 @@ void vm_op_condJmp(struct VirtualMachine* m) { | |||
168 | debug(DBG_VM, "vm_op_condJmp() bypassing protection"); | 173 | debug(DBG_VM, "vm_op_condJmp() bypassing protection"); |
169 | debug(DBG_VM, "bytecode has been patched"); | 174 | debug(DBG_VM, "bytecode has been patched"); |
170 | 175 | ||
176 | //warning("bypassing protection"); | ||
177 | |||
171 | //vm_bypassProtection(m); | 178 | //vm_bypassProtection(m); |
172 | } | 179 | } |
173 | 180 | ||
@@ -175,7 +182,8 @@ void vm_op_condJmp(struct VirtualMachine* m) { | |||
175 | #endif | 182 | #endif |
176 | 183 | ||
177 | uint8_t opcode = scriptPtr_fetchByte(&m->_scriptPtr); | 184 | uint8_t opcode = scriptPtr_fetchByte(&m->_scriptPtr); |
178 | int16_t b = m->vmVariables[scriptPtr_fetchByte(&m->_scriptPtr)]; | 185 | uint8_t var = scriptPtr_fetchByte(&m->_scriptPtr); |
186 | int16_t b = m->vmVariables[var]; | ||
179 | uint8_t c = scriptPtr_fetchByte(&m->_scriptPtr); | 187 | uint8_t c = scriptPtr_fetchByte(&m->_scriptPtr); |
180 | int16_t a; | 188 | int16_t a; |
181 | 189 | ||
@@ -193,6 +201,22 @@ void vm_op_condJmp(struct VirtualMachine* m) { | |||
193 | switch (opcode & 7) { | 201 | switch (opcode & 7) { |
194 | case 0: // jz | 202 | case 0: // jz |
195 | expr = (b == a); | 203 | expr = (b == a); |
204 | |||
205 | #ifdef BYPASS_PROTECTION | ||
206 | /* always succeed in code wheel verification */ | ||
207 | if (m->res->currentPartId == GAME_PART_FIRST && var == 0x29 && (opcode & 0x80) != 0) { | ||
208 | |||
209 | m->vmVariables[0x29] = m->vmVariables[0x1E]; | ||
210 | m->vmVariables[0x2A] = m->vmVariables[0x1F]; | ||
211 | m->vmVariables[0x2B] = m->vmVariables[0x20]; | ||
212 | m->vmVariables[0x2C] = m->vmVariables[0x21]; | ||
213 | // counters | ||
214 | m->vmVariables[0x32] = 6; | ||
215 | m->vmVariables[0x64] = 20; | ||
216 | expr = true; | ||
217 | //warning("Script::op_condJmp() bypassing protection"); | ||
218 | } | ||
219 | #endif | ||
196 | break; | 220 | break; |
197 | case 1: // jnz | 221 | case 1: // jnz |
198 | expr = (b != a); | 222 | expr = (b != a); |
@@ -605,8 +629,6 @@ void vm_executeThread(struct VirtualMachine* m) { | |||
605 | { | 629 | { |
606 | (vm_opcodeTable[opcode])(m); | 630 | (vm_opcodeTable[opcode])(m); |
607 | } | 631 | } |
608 | |||
609 | rb->yield(); | ||
610 | } | 632 | } |
611 | } | 633 | } |
612 | 634 | ||