Skip to content

Commit

Permalink
MEGA65: allow OPL work on slow-dev space, too #380
Browse files Browse the repository at this point in the history
Note, currently I don't know why the slow device space is used for OPL
why not the native I/O space, or the MEGA65 specific OPL regs
at $FE000xx which is intended for that very purpose!

btoschi on Discord has great success to make OPL working on MEGA65 but
requires this access mode, so this quick hack is intended to serve that
holy purpose :)
lgblgblgb committed Mar 4, 2024
1 parent 322db3f commit 6a71a49
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions targets/mega65/cart.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* A work-in-progess MEGA65 (Commodore 65 clone origins) emulator
Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu
Copyright (C)2016-2023 LGB (Gábor Lénárt) <[email protected]>
Copyright (C)2016-2024 LGB (Gábor Lénárt) <[email protected]>
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
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "xemu/emutools.h"
#include "cart.h"
#include "xemu/emutools_files.h"
#include "audio65.h"

static Uint8 cart_mem[0x10000];
static int loaded = 0;
@@ -35,13 +36,25 @@ Uint8 cart_read_byte ( unsigned int addr )
Uint8 data = 0xFF;
if (addr < sizeof(cart_mem))
data = cart_mem[addr];
DEBUGPRINT("CART: reading byte ($%02X) at $%X" NL, data, addr + 0x4000000);
if (loaded && addr != 0x3FFDF60) // see the comment about OPL at cart_write_byte()
DEBUGPRINT("CART: reading byte ($%02X) at $%X" NL, data, addr + 0x4000000);
return data;
}


void cart_write_byte ( unsigned int addr, Uint8 data )
{
if (!loaded) {
// a hack OPL to be able to work in the "slow device area" [if no cartridge is loaded]
static Uint8 opl_reg_sel = 0;
if (addr == 0x3FFDF40) {
opl_reg_sel = data;
return;
} else if (addr == 0x3FFDF50) {
audio65_opl3_write(opl_reg_sel, data);
return;
}
}
DEBUGPRINT("CART: writing byte ($%02X) at $%X" NL, data, addr + 0x4000000);
}

2 changes: 1 addition & 1 deletion targets/mega65/cart.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* A work-in-progess MEGA65 (Commodore 65 clone origins) emulator
Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu
Copyright (C)2016-2023 LGB (Gábor Lénárt) <[email protected]>
Copyright (C)2016-2024 LGB (Gábor Lénárt) <[email protected]>
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

0 comments on commit 6a71a49

Please sign in to comment.