Files
atari2600/source/atari2600.cpp
T
Raimon @ quifisraimon c3503a7a4b - [FIX] Quan RDY està actiu, passar cicles fins que la CPU desperte. Comptador de stall per si de cas.
- [FIX] arreglat el càlcul de adreces en opcodes que usen zero page
- [FIX] Arreglat el càlcul de flags en opcodes incrementadors, decrementadors i transfers
- [FIX] Si ja havem identificat una adreça de memòria com a instrucció, usar eixe tag al desensamblar cap enrere
- [NEW] Càrrega de simbols al principi
2026-09-18 13:34:26 +02:00

93 lines
1.9 KiB
C++

#include "atari2600.h"
#include "6502m.h"
#include "mem.h"
#include "tia.h"
#include "pia.h"
#include "display.h"
#include "speaker.h"
//#include "keyboard.h"
#include "6502debugger.h"
#define NTSC_CLOCK 1193182.0f
#define PAL_CLOCK 1182298.0f
#define SECAM_CLOCK 1187500.0f
#define PAL_M_CLOCK 1191870.0f
namespace atari2600
{
static bool should_exit = false;
static bool paused = false;
void init()
{
paused = false;
m6502::reset();
mem::reset();
tia::reset();
pia::reset();
display::init();
speaker::init(NTSC_CLOCK);
speaker::register_source(tia::audio::get_sample0);
speaker::register_source(tia::audio::get_sample1);
}
void quit()
{
should_exit = true;
}
void step()
{
uint8_t t_states=0;
// if (z80debugger::isbreak(pc, 9)) {
// msx::pause();
// z80debugger::show();
// return;
// } else {
uint8_t stall_counter = 100;
bool instruction_done = false;
while (!instruction_done) {
if (!tia::is_rdy_low()) {
instruction_done = m6502::tick();
} else {
stall_counter--;
if (stall_counter==0) instruction_done = true;
}
tia::tick();
tia::tick();
tia::tick();
pia::tick();
t_states++;
}
uint16_t pc = m6502::getPC();
m6502debugger::onInstructionExecute(pc);
speaker::update(t_states);
// }
}
void pause()
{
display::setTitle(" (paused)");
paused = true;
display::redraw();
}
void resume()
{
display::setTitle("");
paused = false;
}
bool is_paused()
{
return paused;
}
bool is_quitting()
{
return should_exit;
}
}