Skip to content

Commit

Permalink
Merge pull request #214 from trapexit/romselect
Browse files Browse the repository at this point in the history
Fix setting of Kanji ROM
  • Loading branch information
trapexit authored Apr 24, 2024
2 parents 35e1648 + e7ee27a commit cacba23
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
31 changes: 16 additions & 15 deletions libopera/opera_clio.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static
void
opera_clio_set_rom()
{
opera_mem_rom_select((CLIO.regs[0x84] & 0x4) ? ROM2 : ROM1);
opera_mem_rom_select((CLIO.regs[0x84] & ADBIO_OTHERROM) ? ROM2 : ROM1);
}

uint32_t
Expand Down Expand Up @@ -253,17 +253,18 @@ clio_handle_dma(uint32_t val_)

static
void
if_set_set_reset(uint32_t *output_,
uint32_t val_,
uint32_t mask_chk_,
uint32_t mask_set_)
adbio_set(uint32_t *output_,
uint32_t val_,
uint32_t bit_)
{
if((val_ & mask_chk_) == mask_chk_)
{
*output_ = ((val_ & mask_set_) ?
(*output_ | mask_set_) :
(*output_ & ~mask_set_));
}
uint32_t mask;

mask = (1 << bit_);

if((val_ & mask) == 0)
*output_ &= ~mask;
else if(val_ & (mask | (mask << 4)))
*output_ |= mask;
}

int
Expand Down Expand Up @@ -360,10 +361,10 @@ opera_clio_poke(uint32_t addr_,
}
else if(addr_ == 0x84)
{
if_set_set_reset(&CLIO.regs[0x84],val_,0x10,0x01);
if_set_set_reset(&CLIO.regs[0x84],val_,0x20,0x02);
if_set_set_reset(&CLIO.regs[0x84],val_,0x40,0x04);
if_set_set_reset(&CLIO.regs[0x84],val_,0x80,0x08);
adbio_set(&CLIO.regs[0x84],val_,0);
adbio_set(&CLIO.regs[0x84],val_,1);
adbio_set(&CLIO.regs[0x84],val_,2);
adbio_set(&CLIO.regs[0x84],val_,3);

opera_clio_set_rom();

Expand Down
3 changes: 3 additions & 0 deletions libopera/opera_clio.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@

#include <stdint.h>

#define ADBIO_OTHERROM 0x04
#define ADBIO_OTHERROM_EN (ADBIO_OTHERROM << 4)

EXTERN_C_BEGIN

void opera_clio_init(int reason_);
Expand Down
2 changes: 1 addition & 1 deletion libopera/opera_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ opera_mem_rom2_byteswap32_if_le()
void
opera_mem_rom_select(void *rom_)
{
if((rom_ != ROM1) || (rom_ != ROM2))
if((rom_ != ROM1) && (rom_ != ROM2))
rom_ = ROM1;

ROM = rom_;
Expand Down

0 comments on commit cacba23

Please sign in to comment.