Fix banked 16-bit assignments; fixes #245

This commit is contained in:
Lior Halphon 2020-04-08 19:17:45 +03:00
parent 0ed5cf6b38
commit d8e89f5114
1 changed files with 3 additions and 1 deletions

View File

@ -220,7 +220,8 @@ static value_t read_lvalue(GB_gameboy_t *gb, lvalue_t lvalue)
banking_state_t state; banking_state_t state;
save_banking_state(gb, &state); save_banking_state(gb, &state);
switch_banking_state(gb, lvalue.memory_address.bank); switch_banking_state(gb, lvalue.memory_address.bank);
value_t r = VALUE_16(GB_read_memory(gb, lvalue.memory_address.value)); value_t r = VALUE_16(GB_read_memory(gb, lvalue.memory_address.value) |
(GB_read_memory(gb, lvalue.memory_address.value + 1) * 0x100));
restore_banking_state(gb, &state); restore_banking_state(gb, &state);
return r; return r;
} }
@ -261,6 +262,7 @@ static void write_lvalue(GB_gameboy_t *gb, lvalue_t lvalue, uint16_t value)
save_banking_state(gb, &state); save_banking_state(gb, &state);
switch_banking_state(gb, lvalue.memory_address.bank); switch_banking_state(gb, lvalue.memory_address.bank);
GB_write_memory(gb, lvalue.memory_address.value, value); GB_write_memory(gb, lvalue.memory_address.value, value);
GB_write_memory(gb, lvalue.memory_address.value + 1, value >> 8);
restore_banking_state(gb, &state); restore_banking_state(gb, &state);
return; return;
} }