prepare: obj
@echo -e "\033[01;33m***\033[00;32m Preparing to compile Virtual Jaguar...\033[00m"
-# @echo "#define VJ_RELEASE_VERSION \"v2.0.2\"" > src/version.h
+# @echo "#define VJ_RELEASE_VERSION \"v2.0.3\"" > src/version.h
# @echo "#define VJ_RELEASE_SUBVERSION \"Final\"" >> src/version.h
@echo "#define VJ_RELEASE_VERSION \"SVN `svn info | grep -i revision`\"" > src/version.h
- @echo "#define VJ_RELEASE_SUBVERSION \"2.0.2 Prerelease\"" >> src/version.h
+ @echo "#define VJ_RELEASE_SUBVERSION \"2.0.3 Prerelease\"" >> src/version.h
virtualjaguar: sources libs makefile-qt
@echo -e "\033[01;33m***\033[00;32m Making Virtual Jaguar GUI...\033[00m"
----------------------------------------
-Virtual Jaguar v2.0.2 Qt release INSTALL
+Virtual Jaguar v2.0.3 Qt release INSTALL
----------------------------------------
-------------------------------------------
-Virtual Jaguar v2.0.2 GCC/Qt release README
+Virtual Jaguar v2.0.3 GCC/Qt release README
-------------------------------------------
--------------
The port was done by the SDLEMU crew (http://sdlemu.ngemu.com) and especially
by Niels Wagenaar and Carwin Jones. A major portion of the rewrite was done by
-James L. Hammons. You may contact us by e-mail (sdlemu@ngemu.com) or leave a
+James Hammons. You may contact us by e-mail (sdlemu@ngemu.com) or leave a
message on the SDLEMU Official Forum (see the website). Patches and bugfixes
are particularly welcome! :)
Stuff to add/fix for the next release of Virtual Jaguar
-------------------------------------------------------
+- Fix VC behavior to match what a real Jaguar does. Still not sure just what
+ the heck is going on there. [Shamus]
- Fix DSP code so that it doesn't hang in a spinlock waiting for the sound
buffer to empty. Probably a CS lock contention issue. [Shamus]
- Create an EEPROMs directory (or whatever is in EEPROMPath[]) if it doesn't
+Virtual Jaguar v2.0.3 GCC/Qt
+----------------------------
+
+* Kludged a fix into the audio handler to set the correct frequency for audio
+ playback. Note that there could still be problems with this approach, as it
+ can be easily fooled. Thanks to Dr. Typo for the initial analysis and insight
+ into this bug. :-) [Shamus]
+
+
Virtual Jaguar v2.0.2 GCC/Qt
----------------------------
real hardware. [Shamus]
* Fixed video frame timing for both NTSC *and* PAL. [Shamus]
* Improved OP logging, added emulation of OP bug. [Shamus]
-* Fixed VC behavior to match what a real Jaguar does. [Shamus]
+* Fixed addressing bug with UAE 68000 core. [Shamus]
Virtual Jaguar v2.0.1 GCC/Qt
#
# Makefile for Virtual Jaguar core library
#
-# by James L. Hammons
+# by James Hammons
#
# This software is licensed under the GPL v3 or any later version. See the
# file GPLv3 for details. ;-)
#
# Makefile for Musashi Portable 68000 Emulator
#
-# by James L. Hammons
+# by James Hammons
#
# This makefile is licensed under the GPL v3 or any later version. See the
# file GPLv3 for details. ;-)
//
// Blitter core
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// OS agnostic CDROM interface functions
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// Originally by David Raingeard
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Extensive rewrites/cleanups/fixes by James L. Hammons
+// Extensive rewrites/cleanups/fixes by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// by David Raingeard
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Cleanups by James L. Hammons
+// Cleanups by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// Originally by David Raingeard
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Rewritten by James L. Hammons
+// Rewritten by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
// Private function prototypes
void SDLSoundCallback(void * userdata, Uint8 * buffer, int length);
-int GetCalculatedFrequency(void);
//
// Initialize the SDL sound system
return systemClockFrequency / (32 * (2 * (SCLKFrequencyDivider + 1)));
}
+static int oldFreq = 0;
+
+void DACSetNewFrequency(int freq)
+{
+ if (freq == oldFreq)
+ return;
+
+ oldFreq = freq;
+
+ // Should do some sanity checking on the frequency...
+
+ if (SDLSoundInitialized)
+ SDL_CloseAudio();
+
+ desired.freq = freq;// SDL will do conversion on the fly, if it can't get the exact rate. Nice!
+ WriteLog("DAC: Changing sample rate to %u Hz!\n", desired.freq);
+
+ if (SDLSoundInitialized)
+ {
+ if (SDL_OpenAudio(&desired, NULL) < 0) // NULL means SDL guarantees what we want
+ {
+// This is bad, Bad, BAD !!! DON'T ABORT BECAUSE WE DIDN'T GET OUR FREQ! !!! FIX !!!
+#warning !!! FIX !!! Aborting because of SDL audio problem is bad!
+ WriteLog("DAC: Failed to initialize SDL sound: %s.\nDesired freq: %u\nShutting down!\n", SDL_GetError(), desired.freq);
+// LogDone();
+// exit(1);
+#warning "Reimplement GUICrashGracefully!"
+// GUICrashGracefully("Failed to initialize SDL sound!");
+ return;
+ }
+ }
+
+ DACReset();
+
+ if (SDLSoundInitialized)
+ SDL_PauseAudio(false); // Start playback!
+}
+
//
// LTXD/RTXD/SCLK/SMODE ($F1A148/4C/50/54)
//
void DACInit(void);
void DACReset(void);
void DACDone(void);
+int GetCalculatedFrequency(void);
+void DACSetNewFrequency(int);
// DAC memory access
//
// Originally by David Raingeard
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Extensive cleanups/rewrites by James L. Hammons
+// Extensive cleanups/rewrites by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
#include <SDL.h> // Used only for SDL_GetTicks...
#include <stdlib.h>
+#include "dac.h"
#include "gpu.h"
#include "jagdasm.h"
#include "jaguar.h"
DSPUpdateRegisterBanks();
dsp_control &= ~((dsp_flags & CINT04FLAGS) >> 3);
dsp_control &= ~((dsp_flags & CINT5FLAG) >> 1);
+
+// NB: This is just a wild hairy-assed guess as to what the playback frequency is.
+// It can be timed to anything really, anything that writes to L/RTXD at a regular
+// interval. Most things seem to use either the I2S interrupt or the TIMER 0
+// interrupt, so that's what we check for here. Just know that this approach
+// can be easily fooled!
+// Note also that if both interrupts are enabled, the I2S freq will win. :-P
+ if (data & INT_ENA1) // I2S interrupt
+ {
+ int freq = GetCalculatedFrequency();
+//This happens too often to be useful...
+// WriteLog("DSP: Setting audio freqency to %u Hz...\n", freq);
+ DACSetNewFrequency(freq);
+ }
+ else if (data & INT_ENA2) // TIMER 0 interrupt
+ {
+ int freq = JERRYGetPIT1Frequency();
+//This happens too often to be useful...
+// WriteLog("DSP: Setting audio freqency to %u Hz...\n", freq);
+ DACSetNewFrequency(freq);
+ }
+
/* if (IMASKCleared) // If IMASK was cleared,
#ifdef DSP_DEBUG_IRQ
{
// get the interrupt mask
int mask = ((dsp_flags >> 11) & 0x20) | ((dsp_flags >> 4) & 0x1F);
- WriteLog("DSP: pending=%08X enabled=%08X\n", bits, mask);
+ WriteLog("DSP: pending=$%X enabled=$%X (%s%s%s%s%s%s)\n", bits, mask,
+ (mask & 0x01 ? "CPU " : ""), (mask & 0x02 ? "I2S " : ""),
+ (mask & 0x04 ? "Timer0 " : ""), (mask & 0x08 ? "Timer1 " : ""),
+ (mask & 0x10 ? "Ext0 " : ""), (mask & 0x20 ? "Ext1" : ""));
WriteLog("\nRegisters bank 0\n");
for(int j=0; j<8; j++)
{
//
// by Cal2
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Cleanups/enhancements by James L. Hammons
+// Cleanups/enhancements by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// System time handlers
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
// FILE.CPP
//
// File support
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// filedb.cpp - File database
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// Originally by David Raingeard (Cal2)
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Cleanups, endian wrongness, and bad ASM amelioration by James L. Hammons
+// Cleanups, endian wrongness, and bad ASM amelioration by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// about.cpp - Credits
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
"<tr><td align='right'><b>Version: </b></td><td>"
VJ_RELEASE_VERSION " (" VJ_RELEASE_SUBVERSION ")"
"</td></tr>"
- "<tr><td align='right'><b>Coders: </b></td><td>James L. Hammons (shamus)<br>Niels Wagenaar (nwagenaar)<br>Carwin Jones (Caz)<br>Adam Green</td></tr>"
- "<tr><td align='right'><b>Testers: </b></td><td>Cyrano Jones, Robert R, TheUMan, Dissection,<br>overridex, geormetal</td></tr>"
+ "<tr><td align='right'><b>Coders: </b></td><td>James Hammons (shamus)<br>Niels Wagenaar (nwagenaar)<br>Carwin Jones (Caz)<br>Adam Green</td></tr>"
+ "<tr><td align='right'><b>Testers: </b></td><td>Cyrano Jones, LinkoVitch, neo-rg, Robert R,<br>TheUMan, Dissection, overridex, geormetal</td></tr>"
"<tr><td align='right'><b>Build Team: </b></td><td>ggn (win32)<br>LinkoVitch, goldenegg (MacOS)</td></tr>"
"<tr><td align='right'><b>Homepage: </b></td><td>http://icculus.org/virtualjaguar/</td></tr>"
"</table>"
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
//
// app.cpp - Qt-based GUI for Virtual Jaguar
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
{
printf("Virtual Jaguar 2.0.0 help\n");
printf("\n");
- printf("Command line interface is non-functional ATM, but may return if there is\n"
- "enough demand for it. :-)\n");
+ printf("Command line interface is mostly non-functional ATM, but may return if\n"
+ "there is enough demand for it. :-)\n");
return 0;
}
if (strcmp(argv[1], "--yarrr") == 0)
// This is so we can pass this stuff using signal/slot mechanism...
//ick int id = qRegisterMetaType<uint32>();
- LogInit("virtualjaguar.log"); // Init logfile
+ bool success = (bool)LogInit("virtualjaguar.log"); // Init logfile
int retVal = -1; // Default is failure
+ if (!success)
+ printf("Failed to open virtualjaguar.log for writing!\n");
+
// Set up SDL library
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
{
//
// configdialog.cpp - Configuration dialog
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
//
// filelistmodel.cpp - A ROM chooser
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// filepicker.cpp - A ROM chooser
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
// This sets it to the "too large size" as the minimum!
QScrollBar * vsb = new QScrollBar(Qt::Vertical, this);
int sbWidth = vsb->size().width();
- printf("VSB size width: %u\n", sbWidth);
+// printf("VSB size width: %u\n", sbWidth);
int sbWidth2 = vsb->sizeHint().width();
- printf("VSB sizeHint width: %u\n", sbWidth2);
+// printf("VSB sizeHint width: %u\n", sbWidth2);
int sbWidth3 = vsb->minimumSize().width();
- printf("VSB minimum width: %u\n", sbWidth3);
+// printf("VSB minimum width: %u\n", sbWidth3);
int sbWidth4 = vsb->frameSize().width();
- printf("VSB frame width: %u\n", sbWidth4);
+// printf("VSB frame width: %u\n", sbWidth4);
delete vsb;
// fileList->setFixedWidth((488/4) + 4);
int sbWidth5 = fileList->frameWidth();
- printf("List frame width: %u, (diff=%d)\n", sbWidth5, sbWidth5 - ((488/4) + 4));
+// printf("List frame width: %u, (diff=%d)\n", sbWidth5, sbWidth5 - ((488/4) + 4));
int sbWidth6 = fileList->sizeHint().width();
- printf("List sizeHint width: %u\n", sbWidth6);
+// printf("List sizeHint width: %u\n", sbWidth6);
int sbWidth7 = fileList->minimumSize().width();
- printf("List minimum width: %u\n", sbWidth7);
+// printf("List minimum width: %u\n", sbWidth7);
int sbWidth8 = fileList->minimumSizeHint().width();
- printf("List minimum hint width: %u\n", sbWidth8);
-// fileList->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
-// fileList->verticalScrollBar()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
+// printf("List minimum hint width: %u\n", sbWidth8);
+//// fileList->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
+//// fileList->verticalScrollBar()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
// (488/4) + 4 is the width of the object in the filelistmodel. Dunno why the QListView
// isn't picking that up. :-(
// 488/4 + 4 = 126
//
// filethread.cpp - File discovery thread
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// OpenGL implementation in Qt
// Parts of this are blantantly ripped off from BSNES (thanks Byuu!)
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// imagedelegate.cpp - Qt Model/View rendering class
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// keygrabber.cpp - Widget to grab a key and dismiss itself
//
-// by James L. Hammons
+// by James Hammons
// (C) 2011 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// mainwin.cpp - Qt-based GUI for Virtual Jaguar: Main Application Window
-// by James L. Hammons
+// by James Hammons
// (C) 2009 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
if (pauseForFileSelector)
{
pauseForFileSelector = false;
- ToggleRunState();
+
+ // Some nutter might have unpaused while in the file selector, so check for that
+ if (!running)
+ ToggleRunState();
}
}
//
-// This file was automagically generated by bin2c (by James L. Hammons)
+// This file was automagically generated by bin2c (by James Hammons)
//
char jaguarBootROM[0x20000] = {
//
-// This file was automagically generated by bin2c (by James L. Hammons)
+// This file was automagically generated by bin2c (by James Hammons)
//
char jaguarCDBootROM[0x40000] = {
return temp;
}
-unsigned dasmjag(int dsp_type, char * buffer, unsigned pc)
+unsigned dasmjag(int dsp_type, char * bufferOut, unsigned pc)
{
+ char buffer[64];
int op = ROPCODE(pc);
int reg1 = (op >> 5) & 31;
int reg2 = op & 31;
sprintf(buffer, "ADDQMOD $%X,R%02d", convert_zero[reg1], reg2);
break;
}
- sprintf(buffer,"%-24s (%04X)", buffer, op);
+ sprintf(bufferOut,"%-24s (%04X)", buffer, op);
return size;
}
//
-// This file was automagically generated by bin2c (by James L. Hammons)
+// This file was automagically generated by bin2c (by James Hammons)
//
char jaguarDevCDBootROM[0x40000] = {
//
-// This file was automagically generated by bin2c (by James L. Hammons)
+// This file was automagically generated by bin2c (by James Hammons)
//
char jaguarDevBootROM1[0x20000] = {
//
-// This file was automagically generated by bin2c (by James L. Hammons)
+// This file was automagically generated by bin2c (by James Hammons)
//
char jaguarDevBootROM2[0x20000] = {
//
// Originally by David Raingeard (Cal2)
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Carwin Jones (BeOS)
-// Cleanups and endian wrongness amelioration by James L. Hammons
+// Cleanups and endian wrongness amelioration by James Hammons
// Note: Endian wrongness probably stems from the MAME origins of this emu and
// the braindead way in which MAME handled memory when this was written. :-)
//
-// JLH = James L. Hammons
+// JLH = James Hammons
//
// WHO WHEN WHAT
// --- ---------- -----------------------------------------------------------
}
#endif
+void ShowM68KContext(void)
+{
+ printf("\t68K PC=%06X\n", m68k_get_reg(NULL, M68K_REG_PC));
+
+ for(int i=M68K_REG_D0; i<=M68K_REG_D7; i++)
+ {
+ printf("D%i = %08X ", i-M68K_REG_D0, m68k_get_reg(NULL, (m68k_register_t)i));
+
+ if (i == M68K_REG_D3 || i == M68K_REG_D7)
+ printf("\n");
+ }
+
+ for(int i=M68K_REG_A0; i<=M68K_REG_A7; i++)
+ {
+ printf("A%i = %08X ", i-M68K_REG_A0, m68k_get_reg(NULL, (m68k_register_t)i));
+
+ if (i == M68K_REG_A3 || i == M68K_REG_A7)
+ printf("\n");
+ }
+
+ uint32_t currpc = m68k_get_reg(NULL, M68K_REG_PC);
+ uint32_t disPC = currpc - 30;
+ char buffer[128];
+
+ do
+ {
+ uint32_t oldpc = disPC;
+ disPC += m68k_disassemble(buffer, disPC, 0);
+ printf("%s%08X: %s\n", (oldpc == currpc ? ">" : " "), oldpc, buffer);
+ }
+ while (disPC < (currpc + 10));
+}
+
//
// Musashi 68000 read/write/IRQ functions
//
unsigned int m68k_read_memory_8(unsigned int address)
{
+ // Musashi does this automagically for you, UAE core does not :-P
+ address &= 0x00FFFFFF;
#ifdef CPU_DEBUG_MEMORY
if ((address >= 0x000000) && (address <= 0x3FFFFF))
{
unsigned int m68k_read_memory_16(unsigned int address)
{
+ // Musashi does this automagically for you, UAE core does not :-P
+ address &= 0x00FFFFFF;
#ifdef CPU_DEBUG_MEMORY
/* if ((address >= 0x000000) && (address <= 0x3FFFFE))
{
unsigned int m68k_read_memory_32(unsigned int address)
{
+ // Musashi does this automagically for you, UAE core does not :-P
+ address &= 0x00FFFFFF;
//; So, it seems that it stores the returned DWORD at $51136 and $FB074.
/* if (address == 0x51136 || address == 0xFB074 || address == 0x1AF05E)
WriteLog("[RM32 PC=%08X] Addr: %08X, val: %08X\n", m68k_get_reg(NULL, M68K_REG_PC), address, (m68k_read_memory_16(address) << 16) | m68k_read_memory_16(address + 2));//*/
void m68k_write_memory_8(unsigned int address, unsigned int value)
{
+ // Musashi does this automagically for you, UAE core does not :-P
+ address &= 0x00FFFFFF;
#ifdef CPU_DEBUG_MEMORY
if ((address >= 0x000000) && (address <= 0x3FFFFF))
{
//$53D0
/*if (address >= 0x53D0 && address <= 0x53FF)
printf("M68K: Writing byte $%02X at $%08X, PC=$%08X\n", value, address, m68k_get_reg(NULL, M68K_REG_PC));//*/
+//Testing AvP on UAE core...
+//000075A0: FFFFF80E B6320220 (BITMAP)
+/*if (address == 0x75A0 && value == 0xFF)
+ printf("M68K: (8) Tripwire hit...\n");//*/
#ifndef USE_NEW_MMU
if ((address >= 0x000000) && (address <= 0x3FFFFF))
void m68k_write_memory_16(unsigned int address, unsigned int value)
{
+ // Musashi does this automagically for you, UAE core does not :-P
+ address &= 0x00FFFFFF;
#ifdef CPU_DEBUG_MEMORY
if ((address >= 0x000000) && (address <= 0x3FFFFE))
{
//$53D0
/*if (address >= 0x53D0 && address <= 0x53FF)
printf("M68K: Writing word $%04X at $%08X, PC=$%08X\n", value, address, m68k_get_reg(NULL, M68K_REG_PC));//*/
+//Testing AvP on UAE core...
+//000075A0: FFFFF80E B6320220 (BITMAP)
+/*if (address == 0x75A0 && value == 0xFFFF)
+{
+ printf("\nM68K: (16) Tripwire hit...\n");
+ ShowM68KContext();
+}//*/
#ifndef USE_NEW_MMU
if ((address >= 0x000000) && (address <= 0x3FFFFE))
void m68k_write_memory_32(unsigned int address, unsigned int value)
{
+ // Musashi does this automagically for you, UAE core does not :-P
+ address &= 0x00FFFFFF;
/*if (address == 0x4E00)
WriteLog("M68K: Writing %02X at %08X, PC=%08X\n", value, address, m68k_get_reg(NULL, M68K_REG_PC));//*/
//WriteLog("--> [WM32]\n");
doGPUDis = true;//*/
/* if (address == 0x51136 || address == 0xFB074)
WriteLog("[WM32 PC=%08X] Addr: %08X, val: %02X\n", m68k_get_reg(NULL, M68K_REG_PC), address, value);//*/
+//Testing AvP on UAE core...
+//000075A0: FFFFF80E B6320220 (BITMAP)
+/*if (address == 0x75A0 && (value & 0xFFFF0000) == 0xFFFF0000)
+{
+ printf("\nM68K: (32) Tripwire hit...\n");
+ ShowM68KContext();
+}//*/
#ifndef USE_NEW_MMU
m68k_write_memory_16(address, value >> 16);
void M68K_show_context(void)
{
- WriteLog("\t68K PC=%06X\n", m68k_get_reg(NULL, M68K_REG_PC));
+ WriteLog("68K PC=%06X\n", m68k_get_reg(NULL, M68K_REG_PC));
+
for(int i=M68K_REG_D0; i<=M68K_REG_D7; i++)
- WriteLog("\tD%i = %08X\n", i-M68K_REG_D0, m68k_get_reg(NULL, (m68k_register_t)i));
- WriteLog("\n");
+ {
+ WriteLog("D%i = %08X ", i-M68K_REG_D0, m68k_get_reg(NULL, (m68k_register_t)i));
+
+ if (i == M68K_REG_D3 || i == M68K_REG_D7)
+ WriteLog("\n");
+ }
+
for(int i=M68K_REG_A0; i<=M68K_REG_A7; i++)
- WriteLog("\tA%i = %08X\n", i-M68K_REG_A0, m68k_get_reg(NULL, (m68k_register_t)i));
+ {
+ WriteLog("A%i = %08X ", i-M68K_REG_A0, m68k_get_reg(NULL, (m68k_register_t)i));
+
+ if (i == M68K_REG_A3 || i == M68K_REG_A7)
+ WriteLog("\n");
+ }
WriteLog("68K disasm\n");
// jaguar_dasm(s68000readPC()-0x1000,0x20000);
//Seems to want $01010101... Dunno why. Investigate!
memset(jaguarMainROM, 0x01, 0x600000); // & set it to all 01s...
// memset(jaguar_mainRom, 0xFF, 0x600000); // & set it to all Fs...
- lowerField = false; // Reset the lower field flag
+ lowerField = false; // Reset the lower field flag
m68k_set_cpu_type(M68K_CPU_TYPE_68000);
+ m68k_pulse_reset(); // Need to do this so UAE disasm doesn't segfault on exit
GPUInit();
DSPInit();
TOMInit();
/* WriteLog("\n\nM68000 disassembly at $4000...\n");
JaguarDasm(0x4000, 10000);
WriteLog("\n");//*/
+// WriteLog("\n\nM68000 disassembly at $802000...\n");
+// JaguarDasm(0x800830, 0x1000);
+// WriteLog("\n\nM68000 disassembly at $4100...\n");
+// JaguarDasm(0x4100, 200);
+// WriteLog("\n\nM68000 disassembly at $800800...\n");
+// JaguarDasm(0x800800, 0x1000);
}
//
//
// Originally by David Raingeard
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Carwin Jones (BeOS)
-// Cleanups/rewrites/fixes by James L. Hammons
+// Cleanups/rewrites/fixes by James Hammons
//
-// JLH = James L. Hammons
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- -----------------------------------------------------------
#include "joystick.h"
#include "log.h"
#include "m68k.h"
+#include "settings.h"
#include "tom.h"
//#include "memory.h"
#include "wavetable.h"
WriteLog("JERRY: CLK2 word written by %s: %u\n", whoName[who], data);
else if (offset == 0xF10014)
WriteLog("JERRY: CLK3 word written by %s: %u\n", whoName[who], data);
+//else if (offset == 0xF1A100)
+// WriteLog("JERRY: D_FLAGS word written by %s: %u\n", whoName[who], data);
+//else if (offset == 0xF1A102)
+// WriteLog("JERRY: D_FLAGS+2 word written by %s: %u\n", whoName[who], data);
//else if (offset == 0xF10020)
// WriteLog("JERRY: JINTCTRL word written by %s: $%04X\n", whoName[who], data);
#endif
//NOTE: This should be taken care of in DAC...
else if (offset == 0xF1A152) // Bottom half of SCLK ($F1A150)
{
- WriteLog("JERRY: Writing %04X to SCLK (by %s)...\n", data, whoName[who]);
+ WriteLog("JERRY: Writing $%X to SCLK (by %s)...\n", data, whoName[who]);
//This should *only* be enabled when SMODE has its INTERNAL bit set! !!! FIX !!!
JERRYI2SInterruptDivide = (uint8)data;
JERRYI2SInterruptTimer = -1;
jerry_ram_8[(offset+0) & 0xFFFF] = (data >> 8) & 0xFF;
jerry_ram_8[(offset+1) & 0xFFFF] = data & 0xFF;
}
+
+int JERRYGetPIT1Frequency(void)
+{
+ int systemClockFrequency = (vjs.hardwareTypeNTSC ? RISC_CLOCK_RATE_NTSC : RISC_CLOCK_RATE_PAL);
+ return systemClockFrequency / ((JERRYPIT1Prescaler + 1) * (JERRYPIT1Divider + 1));
+}
+
+int JERRYGetPIT2Frequency(void)
+{
+ int systemClockFrequency = (vjs.hardwareTypeNTSC ? RISC_CLOCK_RATE_NTSC : RISC_CLOCK_RATE_PAL);
+ return systemClockFrequency / ((JERRYPIT2Prescaler + 1) * (JERRYPIT2Divider + 1));
+}
void JERRYExecPIT(uint32 cycles);
void JERRYI2SExec(uint32 cycles);
+int JERRYGetPIT1Frequency(void);
+int JERRYGetPIT2Frequency(void);
+
// 68000 Interrupt bit positions (enabled at $F10020)
//enum { IRQ2_EXTERNAL = 0, IRQ2_DSP, IRQ2_TIMER1, IRQ2_TIMER2, IRQ2_ASI, IRQ2_SSI };
//
// by cal2
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Cleanups/fixes by James L. Hammons
+// Cleanups/fixes by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// Originally by David Raingeard (Cal2)
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Cleanups/new stuff by James L. Hammons
+// Cleanups/new stuff by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
ARFLAGS := -rs
# Note that we use optimization level 2 instead of 3--3 doesn't seem to gain much over 2
-CFLAGS := -MMD -O2 -ffast-math -fomit-frame-pointer
+CFLAGS := -MMD -O2 -ffast-math -fomit-frame-pointer -g
INCS := -I. -I./obj `sdl-config --cflags`
/* Sommarhack 2010) (see m68000.h) */
-const char GenCpu_fileid[] = "Hatari gencpu.c : " __DATE__ " " __TIME__;
+//const char GenCpu_fileid[] = "Hatari gencpu.c : " __DATE__ " " __TIME__;
#include <ctype.h>
#include <string.h>
{
char f[256], str[256];
static const char * const ccnames[] =
- { "T ","F ","HI","LS","CC","CS","NE","EQ",
+ { "RA","RN","HI","LS","CC","CS","NE","EQ",
"VC","VS","PL","MI","GE","LT","GT","LE" };
str[0] = 0;
#else
switch (dp->size)
{
- case sz_byte: strcat(str, ".B "); break;
- case sz_word: strcat(str, ".W "); break;
- case sz_long: strcat(str, ".L "); break;
- default: strcat(str, " "); break;
+ case sz_byte: strcat(str, ".B\t"); break;
+ case sz_word: strcat(str, ".W\t"); break;
+ case sz_long: strcat(str, ".L\t"); break;
+ default: strcat(str, "\t"); break;
}
#endif
{
// sprintf(f, ",");
// strcat(str, f);
- strcat(str, ",");
+ strcat(str, ", ");
}
#endif
//
// m68kinterface.c: Code interface to the UAE 68000 core and support code
//
-// by James L. Hammons
+// by James Hammons
// (C) 2011 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
void Dasm(uint32_t offset, uint32_t qt)
{
#ifdef CPU_DEBUG
+// back up a few instructions...
+//offset -= 100;
static char buffer[2048];//, mem[64];
int pc = offset, oldpc;
uint32_t i;
#endif
}
+#ifdef CPU_DEBUG
+void DumpRegisters(void)
+{
+ uint32_t i;
+
+ for(i=0; i<16; i++)
+ {
+ printf("%s%i: %08X ", (i < 8 ? "D" : "A"), i & 0x7, regs.regs[i]);
+
+ if ((i & 0x03) == 3)
+ printf("\n");
+ }
+}
+#endif
+
void m68k_set_cpu_type(unsigned int type)
{
if (inRoutine)
instSeen++;
+#endif
+// AvP testing... (problem was: 32 bit addresses on 24 bit address cpu--FIXED)
+#if 0
+ static int go = 0;
+
+ if (regs.pc == 0x94BA)
+ {
+ go = 1;
+ printf("\n");
+ }
+
+ if (regs.pc == 0x94C6)
+ go = 0;
+
+// if (regs.regs[10] == 0xFFFFFFFF && go)
+ if (go)
+ {
+// printf("A2=-1, PC=%08X\n", regs.pc);
+// go = 0;
+// Dasm(regs.pc, 130);
+ Dasm(regs.pc, 1);
+ DumpRegisters();
+ }
+//94BA: 2468 0000 MOVEA.L (A0,$0000) == $0002328A, A2
+//94BE: 200A MOVE.L A2, D0
+//94C0: 6A02 BPL.B $94C4
+//94C2: 2452 MOVEA.L (A2), A2 ; <--- HERE
+//94C4: 4283 CLR.L D3
#endif
uint32_t opcode = get_iword(0);
//if ((opcode & 0xFFF8) == 0x31C0)
%
% Fields on a line:
% 16 chars bitpattern :
-% CPU level / privildge level :
+% CPU level / privilege level :
% CPU level 0: 68000
% 1: 68010
% 2: 68020
//
// Jaguar memory and I/O physical (hosted!) memory
//
-// by James L. Hammons
+// by James Hammons
//
-// JLH = James L. Hammons
+// JLH = James Hammons
//
// WHO WHEN WHAT
// --- ---------- -----------------------------------------------------------
//
// Jaguar Memory Manager Unit
//
-// by James L. Hammons
+// by James Hammons
//
-// JLH = James L. Hammons
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- -----------------------------------------------------------
//
// Original source by David Raingeard (Cal2)
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Extensive cleanups/fixes/rewrites by James L. Hammons
+// Extensive cleanups/fixes/rewrites by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// SETTINGS.CPP: Virtual Jaguar configuration loading/saving support
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// state.cpp: VJ machine state save/load support
//
-// by James L. Hammons
+// by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// Originally by David Raingeard (cal2)
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Cleanups and endian wrongness amelioration by James L. Hammons
+// Cleanups and endian wrongness amelioration by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
// Also note that VC is in *half* lines, i.e. divide by 2 to get the scanline
/*#define LEFT_VISIBLE_HC 208
#define RIGHT_VISIBLE_HC 1528//*/
-#define LEFT_VISIBLE_HC 208
-#define RIGHT_VISIBLE_HC 1488
+// These were right for Rayman, but that one is offset on a real TV too.
+//#define LEFT_VISIBLE_HC 208
+//#define RIGHT_VISIBLE_HC 1488
+// This is more like a real TV display...
+//#define LEFT_VISIBLE_HC (208 - 32)
+//#define RIGHT_VISIBLE_HC (1488 - 32)
+// Split the difference? (Seems to be OK for the most part...)
+#define LEFT_VISIBLE_HC (208 - 16)
+#define RIGHT_VISIBLE_HC (1488 - 16)
//#define TOP_VISIBLE_VC 25
//#define BOTTOM_VISIBLE_VC 503
#define TOP_VISIBLE_VC 31
//Are these PAL horizontals correct?
//They seem to be for the most part, but there are some games that seem to be
//shifted over to the right from this "window".
-#define LEFT_VISIBLE_HC_PAL 208
-#define RIGHT_VISIBLE_HC_PAL 1488
+#define LEFT_VISIBLE_HC_PAL (208 - 16)
+#define RIGHT_VISIBLE_HC_PAL (1488 - 16)
#define TOP_VISIBLE_VC_PAL 67
#define BOTTOM_VISIBLE_VC_PAL 579
//
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Removal of unsafe macros and addition of typdefs by James L. Hammons
+// Removal of unsafe macros and addition of typdefs by James Hammons
//
#ifndef __TYPES_H__
//
// (C) 2011 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
//
-// This file was automagically generated by bin2c (by James L. Hammons)
+// This file was automagically generated by bin2c (by James Hammons)
//
unsigned char universalCartHeader[0x2000] = {
// ZIP file support (mostly ripped from MAME--thx MAME team!)
// Mostly this is here to simplify interfacing to zlib...
//
-// Added by James L. Hammons
+// Added by James Hammons
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
//
// Original codebase by David Raingeard (Cal2)
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Cleanups/fixes/enhancements by James L. Hammons and Adam Green
+// Cleanups/fixes/enhancements by James Hammons and Adam Green
//
#include <SDL.h>
#endif
printf("Based upon Virtual Jaguar core v1.0.0 by David Raingeard.\n");
printf("Written by Niels Wagenaar (Linux/WIN32), Carwin Jones (BeOS),\n");
- printf("James L. Hammons (WIN32) and Adam Green (MacOS)\n");
+ printf("James Hammons (WIN32) and Adam Green (MacOS)\n");
printf("Contact: http://sdlemu.ngemu.com/ | sdlemu@ngemu.com\n");
bool haveCart = false; // Assume there is no cartridge...!
//
// (C) 2010 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
#
# Virtual Jaguar Qt project file
#
-# by James L. Hammons
+# by James Hammons
# Copyright (C) 2011 Underground Software
#
# See the README and GPLv3 files for licensing and warranty information
TARGET = virtualjaguar
CONFIG += qt warn_on release debug
RESOURCES += virtualjaguar.qrc
-#LIBS += -lz -Lobj -ljaguarcore -lmusashi
-LIBS += -lz -Lobj -ljaguarcore -lm68k
+#LIBS += -Lobj -ljaguarcore -lz -lmusashi
+LIBS += -Lobj -ljaguarcore -lz -lm68k
QT += opengl
# We stuff all the intermediate crap into obj/ so it won't confuse us mere mortals ;-)