Compare commits
No commits in common. "f2d3f5ec071a2ae4a69b047fd49e7827c11a700c" and "54edfbc1117c6818106f0f087e11f5f9bc6f7da0" have entirely different histories.
f2d3f5ec07
...
54edfbc111
|
@ -291,26 +291,6 @@ impl Emulator {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn frame_advance(&mut self) {
|
|
||||||
if self
|
|
||||||
.state
|
|
||||||
.compare_exchange(
|
|
||||||
EmulatorState::Paused,
|
|
||||||
EmulatorState::Stepping,
|
|
||||||
Ordering::AcqRel,
|
|
||||||
Ordering::Acquire,
|
|
||||||
)
|
|
||||||
.is_err_and(|s| s == EmulatorState::Running)
|
|
||||||
{
|
|
||||||
let _ = self.state.compare_exchange(
|
|
||||||
EmulatorState::Running,
|
|
||||||
EmulatorState::Stepping,
|
|
||||||
Ordering::AcqRel,
|
|
||||||
Ordering::Relaxed,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn save_sram(&mut self, sim_id: SimId) -> Result<()> {
|
fn save_sram(&mut self, sim_id: SimId) -> Result<()> {
|
||||||
let sim = self.sims.get_mut(sim_id.to_index());
|
let sim = self.sims.get_mut(sim_id.to_index());
|
||||||
let cart = self.carts[sim_id.to_index()].as_mut();
|
let cart = self.carts[sim_id.to_index()].as_mut();
|
||||||
|
@ -386,7 +366,6 @@ impl Emulator {
|
||||||
debugger.stop_reason = None;
|
debugger.stop_reason = None;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_step(&mut self, sim_id: SimId) {
|
fn debug_step(&mut self, sim_id: SimId) {
|
||||||
if self.debug_continue(sim_id) {
|
if self.debug_continue(sim_id) {
|
||||||
let Some(sim) = self.sims.get_mut(sim_id.to_index()) else {
|
let Some(sim) = self.sims.get_mut(sim_id.to_index()) else {
|
||||||
|
@ -449,7 +428,7 @@ impl Emulator {
|
||||||
// Don't emulate if the state is "paused", or if any sim is paused in the debugger
|
// Don't emulate if the state is "paused", or if any sim is paused in the debugger
|
||||||
let running = match state {
|
let running = match state {
|
||||||
EmulatorState::Paused => false,
|
EmulatorState::Paused => false,
|
||||||
EmulatorState::Running | EmulatorState::Stepping => true,
|
EmulatorState::Running => true,
|
||||||
EmulatorState::Debugging => self.debuggers.values().all(|d| d.stop_reason.is_none()),
|
EmulatorState::Debugging => self.debuggers.values().all(|d| d.stop_reason.is_none()),
|
||||||
};
|
};
|
||||||
let p1_running = running && p1_state == SimState::Ready;
|
let p1_running = running && p1_state == SimState::Ready;
|
||||||
|
@ -463,10 +442,6 @@ impl Emulator {
|
||||||
self.sims[SimId::Player2.to_index()].emulate();
|
self.sims[SimId::Player2.to_index()].emulate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if state == EmulatorState::Stepping {
|
|
||||||
self.state.store(EmulatorState::Paused, Ordering::Release);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debug state
|
// Debug state
|
||||||
if state == EmulatorState::Debugging {
|
if state == EmulatorState::Debugging {
|
||||||
for sim_id in SimId::values() {
|
for sim_id in SimId::values() {
|
||||||
|
@ -564,9 +539,6 @@ impl Emulator {
|
||||||
EmulatorCommand::Resume => {
|
EmulatorCommand::Resume => {
|
||||||
self.resume_sims();
|
self.resume_sims();
|
||||||
}
|
}
|
||||||
EmulatorCommand::FrameAdvance => {
|
|
||||||
self.frame_advance();
|
|
||||||
}
|
|
||||||
EmulatorCommand::StartDebugging(sim_id, debugger) => {
|
EmulatorCommand::StartDebugging(sim_id, debugger) => {
|
||||||
self.start_debugging(sim_id, debugger);
|
self.start_debugging(sim_id, debugger);
|
||||||
}
|
}
|
||||||
|
@ -693,7 +665,6 @@ pub enum EmulatorCommand {
|
||||||
StopSecondSim,
|
StopSecondSim,
|
||||||
Pause,
|
Pause,
|
||||||
Resume,
|
Resume,
|
||||||
FrameAdvance,
|
|
||||||
StartDebugging(SimId, DebugSender),
|
StartDebugging(SimId, DebugSender),
|
||||||
StopDebugging(SimId),
|
StopDebugging(SimId),
|
||||||
DebugInterrupt(SimId),
|
DebugInterrupt(SimId),
|
||||||
|
@ -729,7 +700,6 @@ pub enum SimState {
|
||||||
pub enum EmulatorState {
|
pub enum EmulatorState {
|
||||||
Paused,
|
Paused,
|
||||||
Running,
|
Running,
|
||||||
Stepping,
|
|
||||||
Debugging,
|
Debugging,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,6 @@ impl GameWindow {
|
||||||
let is_ready = self.client.sim_state(self.sim_id) == SimState::Ready;
|
let is_ready = self.client.sim_state(self.sim_id) == SimState::Ready;
|
||||||
let can_pause = is_ready && state == EmulatorState::Running;
|
let can_pause = is_ready && state == EmulatorState::Running;
|
||||||
let can_resume = is_ready && state == EmulatorState::Paused;
|
let can_resume = is_ready && state == EmulatorState::Paused;
|
||||||
let can_frame_advance = is_ready && state != EmulatorState::Debugging;
|
|
||||||
if state == EmulatorState::Running {
|
if state == EmulatorState::Running {
|
||||||
if ui.add_enabled(can_pause, Button::new("Pause")).clicked() {
|
if ui.add_enabled(can_pause, Button::new("Pause")).clicked() {
|
||||||
self.client.send_command(EmulatorCommand::Pause);
|
self.client.send_command(EmulatorCommand::Pause);
|
||||||
|
@ -101,14 +100,6 @@ impl GameWindow {
|
||||||
.send_command(EmulatorCommand::Reset(self.sim_id));
|
.send_command(EmulatorCommand::Reset(self.sim_id));
|
||||||
ui.close_menu();
|
ui.close_menu();
|
||||||
}
|
}
|
||||||
ui.separator();
|
|
||||||
if ui
|
|
||||||
.add_enabled(can_frame_advance, Button::new("Frame Advance"))
|
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
self.client.send_command(EmulatorCommand::FrameAdvance);
|
|
||||||
ui.close_menu();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
ui.menu_button("Options", |ui| self.show_options_menu(ctx, ui));
|
ui.menu_button("Options", |ui| self.show_options_menu(ctx, ui));
|
||||||
ui.menu_button("Multiplayer", |ui| {
|
ui.menu_button("Multiplayer", |ui| {
|
||||||
|
|
|
@ -643,15 +643,6 @@ impl WorldRenderer {
|
||||||
shades.map(|s| shade(s, params.right_color)),
|
shades.map(|s| shade(s, params.right_color)),
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
let palettes = {
|
|
||||||
let palettes = self.palettes.borrow().read::<[u8; 8]>(0);
|
|
||||||
[
|
|
||||||
utils::parse_palette(palettes[0]),
|
|
||||||
utils::parse_palette(palettes[2]),
|
|
||||||
utils::parse_palette(palettes[4]),
|
|
||||||
utils::parse_palette(palettes[6]),
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
let chardata = self.chardata.borrow();
|
let chardata = self.chardata.borrow();
|
||||||
let bgmaps = self.bgmaps.borrow();
|
let bgmaps = self.bgmaps.borrow();
|
||||||
|
@ -676,8 +667,7 @@ impl WorldRenderer {
|
||||||
let row = (sy & 0x7) as usize;
|
let row = (sy & 0x7) as usize;
|
||||||
let col = (sx & 0x7) as usize;
|
let col = (sx & 0x7) as usize;
|
||||||
let pixel = utils::read_char_pixel(char, cell.hflip, cell.vflip, row, col);
|
let pixel = utils::read_char_pixel(char, cell.hflip, cell.vflip, row, col);
|
||||||
let shade = palettes[cell.palette_index][pixel as usize];
|
image.add((dx as usize, dy as usize), colors[0][pixel as usize]);
|
||||||
image.add((dx as usize, dy as usize), colors[0][shade as usize]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let dx = x + world.dst_x + world.dst_parallax;
|
let dx = x + world.dst_x + world.dst_parallax;
|
||||||
|
@ -690,8 +680,7 @@ impl WorldRenderer {
|
||||||
let row = (sy & 0x7) as usize;
|
let row = (sy & 0x7) as usize;
|
||||||
let col = (sx & 0x7) as usize;
|
let col = (sx & 0x7) as usize;
|
||||||
let pixel = utils::read_char_pixel(char, cell.hflip, cell.vflip, row, col);
|
let pixel = utils::read_char_pixel(char, cell.hflip, cell.vflip, row, col);
|
||||||
let shade = palettes[cell.palette_index][pixel as usize];
|
image.add((dx as usize, dy as usize), colors[1][pixel as usize]);
|
||||||
image.add((dx as usize, dy as usize), colors[1][shade as usize]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -987,8 +976,8 @@ impl<'a> SourceCoordCalculator<'a> {
|
||||||
(sx, sy)
|
(sx, sy)
|
||||||
}
|
}
|
||||||
SourceParam::Affine(affine) => {
|
SourceParam::Affine(affine) => {
|
||||||
let sx = affine_coord(affine.src_x, x, affine.dx, affine.src_parallax.min(0));
|
let sx = affine_coord(affine.src_x, x, affine.dx, affine.src_parallax.min(0).abs());
|
||||||
let sy = affine_coord(affine.src_y, x, affine.dy, affine.src_parallax.min(0));
|
let sy = affine_coord(affine.src_y, x, affine.dy, affine.src_parallax.min(0).abs());
|
||||||
(sx, sy)
|
(sx, sy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1008,8 +997,8 @@ impl<'a> SourceCoordCalculator<'a> {
|
||||||
(sx, sy)
|
(sx, sy)
|
||||||
}
|
}
|
||||||
SourceParam::Affine(affine) => {
|
SourceParam::Affine(affine) => {
|
||||||
let sx = affine_coord(affine.src_x, x, affine.dx, affine.src_parallax.max(0));
|
let sx = affine_coord(affine.src_x, x, affine.dx, -affine.src_parallax.max(0));
|
||||||
let sy = affine_coord(affine.src_y, x, affine.dy, affine.src_parallax.max(0));
|
let sy = affine_coord(affine.src_y, x, affine.dy, -affine.src_parallax.max(0));
|
||||||
(sx, sy)
|
(sx, sy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue