Skip to content

Commit

Permalink
MEGA65: VIC-IV updates merging #29
Browse files Browse the repository at this point in the history
  • Loading branch information
lgblgblgb committed Sep 22, 2021
1 parent 31d1dc1 commit 831b366
Show file tree
Hide file tree
Showing 9 changed files with 414 additions and 637 deletions.
7 changes: 6 additions & 1 deletion targets/mega65/configdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ static const struct xemutools_configdef_switch_st switch_options[] = {
{ "syscon", "Keep system console open (Windows-specific effect only)", &configdb.syscon },
{ "besure", "Skip asking \"are you sure?\" on RESET or EXIT", &i_am_sure_override },
{ "skipunhandledmem", "Do not even ask on unhandled memory access (hides problems!!)", &configdb.skip_unhandled_mem },
{ "fullborders", "Show non-clipped display borders", &configdb.fullborders },
{ "nosound", "Disables audio output generation", &configdb.nosound },
{ "noopl3", "Disables OPL3 emulation", &configdb.noopl3 },
{ "soundresetbug", "Disables audio during reset (workaround)", &configdb.soundresetbug },
{ NULL }
};

Expand All @@ -96,13 +98,16 @@ static const struct xemutools_configdef_num_st num_options[] = {
{ "model", 0xFF, "Emulated MEGA65 model (255=custom/Xemu)", &configdb.mega65_model, 0, 0xFF },
{ "kicked", 0x0, "Answer to KickStart upgrade (128=ask user in a pop-up window)", &configdb.kicked, 0, 0xFF },
{ "prgmode", 0, "Override auto-detect option for -prg (64 or 65 for C64/C65 modes, 0 = default, auto detect)", &configdb.prgmode, 0, 65 },
{ "rtchofs", 0, "RTC (and CIA TOD) default offset to real-time (mostly for testing!)", &configdb.rtc_hour_offset, -24, 24 },
{ "rtchofs", 0, "RTC (and CIA TOD) default hour offset to real-time -24 ... 24 (for testing!)", &configdb.rtc_hour_offset, -24, 24 },
#ifdef HAVE_XEMU_UMON
{ "umon", 0, "TCP-based dual mode (http / text) monitor port number [NOT YET WORKING]", &configdb.umon, 0, 0xFFFF },
#endif
{ "sdlrenderquality", RENDER_SCALE_QUALITY, "Setting SDL hint for scaling method/quality on rendering (0, 1, 2)", &configdb.sdlrenderquality, 0, 2 },
{ "stereoseparation", AUDIO_DEFAULT_SEPARATION, "Audio stereo separation; 100(hard-stereo) ... 0(mono) ... -100(hard-reversed-stereo); default: " STRINGIFY(AUDIO_DEFAULT_SEPARATION), &configdb.stereoseparation, -100, 100 },
{ "mastervolume", AUDIO_DEFAULT_VOLUME, "Audio emulation mixing final volume (100=unchanged ... 0=silence); default: " STRINGIFY(AUDIO_DEFAULT_VOLUME), &configdb.mastervolume, 0, 100 },
{ "forcevideostd", -1, "Force video standard (0 = PAL, 1 = NTSC, -1 = default switchable by VIC-IV)", &configdb.force_videostd, -1, 1 },
// FIXME: as a workaround, I set this to "0" PAL, as newer MEGA65's default is this. HOWEVER this should be not handled this way but using a newer Hyppo!
{ "initvideostd", 0, "Use given video standard as the startup one (0 = PAL, 1 = NTSC, -1 = Hyppo default)", &configdb.init_videostd, -1, 1 },
{ "sidmask", 15, "Enabled SIDs of the four, in form of a bitmask", &configdb.sidmask, 0, 15 },
{ NULL }
};
Expand Down
4 changes: 4 additions & 0 deletions targets/mega65/configdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ struct configdb_st {
char *keymap;
#endif
char *selectedgui;
int force_videostd;
int init_videostd;
int fullborders;
int show_drive_led;
int hyperdebug;
int hyperserialascii;
Expand Down Expand Up @@ -87,6 +90,7 @@ struct configdb_st {
int nosound;
int noopl3;
int sidmask;
int soundresetbug;
};

extern struct configdb_st configdb;
Expand Down
31 changes: 19 additions & 12 deletions targets/mega65/hypervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */


int in_hypervisor; // mega65 hypervisor mode
int hypervisor_to_enable_audio = 0;

static char debug_lines[0x4000][2][INFO_MAX_SIZE]; // I know. UGLY! and wasting memory. But this is only a HACK :)
static int resolver_ok = 0;
Expand Down Expand Up @@ -152,7 +153,7 @@ void hypervisor_enter_via_write_trap ( int trapno )
if (do_nop_check) {
// FIXME: for real there should be a memory reading function independent to the one used by the CPU, since
// this has some side effects to just fetch a byte to check something, which is otherwise used normally to fetch CPU opcodes and such
const Uint8 skipped_byte = cpu65_read_callback(cpu65.pc);
Uint8 skipped_byte = cpu65_read_callback(cpu65.pc);
if (XEMU_UNLIKELY(skipped_byte != 0xEA)) { // $EA = opcode of NOP
char msg[256];
snprintf(msg, sizeof msg,
Expand Down Expand Up @@ -278,7 +279,7 @@ void hypervisor_leave ( void )
memory_set_vic3_rom_mapping(vic_registers[0x30]); // restore possible active VIC-III mapping
memory_set_do_map(); // restore mapping ...
if (XEMU_UNLIKELY(first_hypervisor_leave)) {
DEBUGPRINT("HYPERVISOR: first return after RESET." NL);
DEBUGPRINT("HYPERVISOR: first return after RESET, start of processing workarounds." NL);
first_hypervisor_leave = 0;
int new_pc = refill_c65_rom_from_preinit_cache(); // this function should decide then, if it's really a (forced) thing to do ...
if (new_pc >= 0) {
Expand All @@ -289,7 +290,20 @@ void hypervisor_leave ( void )
cpu65.pc = new_pc;
} else
DEBUGPRINT("MEM: no forced ROM re-apply policy was requested" NL);
dma_init_set_rev(configdb.dmarev, main_ram + 0x20000 + 0x16);
dma_init_set_rev(configdb.dmarev, main_ram + 0x20000);
if (configdb.init_videostd >= 0) {
DEBUGPRINT("VIC: setting %s mode as initial-default based on request" NL, configdb.init_videostd ? "NTSC" : "PAL");
if (configdb.init_videostd)
vic_registers[0x6F] |= 0x80;
else
vic_registers[0x6F] &= 0x7F;
}
if (hypervisor_to_enable_audio) {
hypervisor_to_enable_audio = 0;
configdb.nosound = 0;
DEBUGPRINT("HYPERVISOR: enabling audio (workaround)" NL);
}
DEBUGPRINT("HYPERVISOR: first return after RESET, end of processing workarounds." NL);
}
if (XEMU_UNLIKELY(hypervisor_queued_trap >= 0)) {
// Not so much used currently ...
Expand All @@ -299,20 +313,13 @@ void hypervisor_leave ( void )
}
}

void write_hypervisor_byte(char byte);


void hypervisor_serial_monitor_push_char ( Uint8 chr )
{
if (hypervisor_monout_p >= hypervisor_monout - 1 + sizeof hypervisor_monout)
{
// NOTE: For long mega65_ftp actions like 'get MYDISK.D81`, a lot of
// serial chars will be sent that are raw binary, and there's a good chance
// it could overflow the 'hypervisor_monout' buffer.
// So in such cases, I'll simply empty hypervisor_monout.
hypervisor_monout_p = hypervisor_monout;
}
return;
int flush = (chr == 0x0A || chr == 0x0D || chr == 0x8A || chr == 0x8D);
write_hypervisor_byte(chr);
if (hypervisor_monout_p == hypervisor_monout && flush)
return;
if (flush) {
Expand Down
3 changes: 2 additions & 1 deletion targets/mega65/hypervisor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define TRAP_RESTORE 0x42
#define TRAP_ALTTAB 0x43

extern int in_hypervisor;
extern int in_hypervisor;
extern int hypervisor_to_enable_audio;

extern int hypervisor_debug_init ( const char *fn, int hypervisor_debug, int use_hypervisor_serial_out_asciizer );
extern void hypervisor_debug ( void );
Expand Down
Loading

0 comments on commit 831b366

Please sign in to comment.