Skip to content

Commit 564ad24

Browse files
committed
Improved conditions to protect system vars
1 parent 914ef02 commit 564ad24

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lstate.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ void main(char *argv[], int argc) {
289289
Read(fH, buffer, sizeof(buffer));
290290

291291
// Don't overwrite MSX-DOS variables area
292-
if (protect_system_vars && regs.im != 2 && segment == segments[3] && j >= 14) {
292+
if ((rom_selected_p0 || rom_selected_p1 || protect_system_vars) && regs.im != 2
293+
&& segment == segments[3]
294+
&& j >= 14) {
293295
from = (unsigned char *)(0xC000 + j*sizeof(buffer));
294296
#ifdef DEBUG_LSTATE
295297
printf("A");
@@ -308,7 +310,7 @@ void main(char *argv[], int argc) {
308310

309311
// If rom_selected_p0, we need to copy the
310312
// H.KEYI and H.TIMI hooks the game configured
311-
if (segment == segments[3] && j == 15) {
313+
if ((rom_selected_p0 || protect_system_vars) && segment == segments[3] && j == 15) {
312314
MemCopy((unsigned char*)(to + H_TIMI % sizeof(buffer)), (unsigned char*)(buffer + H_TIMI % sizeof(buffer)), 3);
313315
MemCopy((unsigned char*)(to + H_KEYI % sizeof(buffer)), (unsigned char*)(buffer + H_KEYI % sizeof(buffer)), 3);
314316
#ifdef DEBUG_LSTATE

0 commit comments

Comments
 (0)