BugFix: LDA (zp,X)

This commit is contained in:
Tamas Rudnai 2023-12-19 01:04:59 -08:00
parent 7b4f06ad70
commit ceeba2793d
7 changed files with 389 additions and 371 deletions

2
.gitignore vendored
View File

@ -24,3 +24,5 @@ Resources/rom/Downloads/apple_iie_rom.zip
Resources/rom/Downloads/077-0026-0027 for IIe.zip
**/Contents/**
.DS_Store
Brewfile

File diff suppressed because it is too large Load Diff

View File

@ -1102,10 +1102,13 @@ class ViewController: NSViewController {
if textNeedRender || shadowTxt != unicodeTextString {
shadowTxt = unicodeTextString
// display.stringValue = unicodeTextString
let selectedRange = textDisplay.selectedRange()
textDisplay.string = unicodeTextString
textDisplay.setSelectedRange(selectedRange)
// DispatchQueue.main.async { [self] in
textDisplay.string = unicodeTextString
textDisplay.setSelectedRange(selectedRange)
// }
// let bold14 = NSFont.boldSystemFont(ofSize: 14.0)
// let textColor = NSColor.red
@ -1125,6 +1128,7 @@ class ViewController: NSViewController {
func UpdateCPUspeed() {
// DispatchQueue.main.async { [self] in
// under ~1.5 MHz -- 3 decimals to be able to display 1.023 MHz
if ( (mhz < 1.4) && (mhz != floor(mhz)) ) {
speedometer.stringValue = String(format: "%0.3lf MHz", mhz);
@ -1141,6 +1145,7 @@ class ViewController: NSViewController {
else {
speedometer.stringValue = String(format: "%0.0lf MHz", mhz);
}
// }
}
@ -1193,6 +1198,7 @@ class ViewController: NSViewController {
// Rendering is happening in the main thread, which has two implications:
// 1. We can update UI elements
// 2. it is independent of the simulation, de that is running in the background thread while we are busy with rendering...
// DispatchQueue.global(qos: .userInitiated).async {
DispatchQueue.main.async {
self.UpdateText()
self.UpdateCPUspeed()
@ -1306,6 +1312,8 @@ class ViewController: NSViewController {
let UpdateSemaphore = DispatchSemaphore(value: 1)
func Update() {
// clk_6502_per_frm_max = 0
if UpdateSemaphore.wait(timeout: .now() + 0.001) == .timedOut {
// get back here next time...
return
@ -1376,13 +1384,15 @@ class ViewController: NSViewController {
m6502.interrupt = NO_INT
}
else {
m6502_Run()
// DispatchQueue.global(qos: .userInitiated).async {
m6502_Run()
// }
// cpuState = cpuState_running
}
// video rendering
if ( frameCounter % video_fps_divider == 0 ) {
self.Render()
Render()
}
// TODO: This should be in Debugger!

View File

@ -35,7 +35,12 @@
//#define INSTR INLINE static
//#endif
#define INSTR static inline
#ifdef DEBUG
#define INSTR static
#else
#define INSTR static inline __attribute__((always_inline)) UNUSED
//#define INSTR static inline __attribute__((always_inline)) __attribute__((regcall)) UNUSED
#endif
#define CRYSTAL_MHZ 14.31818 // NTSC version (original)
#define DEFAULT_MHZ_6502 (CRYSTAL_MHZ / 14) // 1.023 MHz

View File

@ -1401,13 +1401,13 @@ INLINE uint8_t _src_ind_dis(void) {
effective address is word in (LL + X, LL + X + 1), inc. without carry: C.w($00LL + X)
**/
INLINE uint16_t _addr_ind_X(void) {
return memread16( _fetch() + m6502.X );
return memread16( (uint8_t)(_fetch() + m6502.X) );
}
INLINE uint16_t _addr_ind_X_rd_dbg(void) {
return _memread16_dbg( _fetch() + m6502.X );
return _memread16_dbg( (uint8_t)(_fetch() + m6502.X) );
}
INLINE uint16_t _addr_ind_X_dbg(void) {
uint16_t addr = _memread16_dbg(_fetch() + m6502.X);
uint16_t addr = _memread16_dbg( (uint8_t)(_fetch() + m6502.X));
check_mem_wr_bp(addr); // write debug on the target address
return addr;
}
@ -1415,7 +1415,7 @@ INLINE uint16_t _addr_ind_X_dis(void) {
_disPrintf(disassembly.oper, sizeof(disassembly.oper), "($%02X,X)", memread8(m6502.PC) );
_disPrintf(disassembly.comment, sizeof(disassembly.comment), "ind_addr:%04X", memread16( memread8(m6502.PC) + m6502.X) );
return memread16( _fetch_dis() + m6502.X );
return memread16( (uint8_t)(_fetch_dis() + m6502.X) );
}
INLINE uint8_t _src_X_ind(void) {
return _memread( _addr_ind_X() );

View File

@ -32,8 +32,8 @@
#ifdef DEBUG
#define INLINE UNUSED
#else
// #define INLINE static __attribute__((always_inline))
#define INLINE __attribute__((always_inline)) UNUSED
#define INLINE __attribute__((always_inline)) UNUSED
//#define INLINE __attribute__((always_inline)) __attribute__((fastcall)) UNUSED
#endif