Remove legacy lag counting
As major series transition breaks savestates anyway, no need to support legacy mode anymore.
This commit is contained in:
parent
bb48143284
commit
c4b03bfcac
9 changed files with 29 additions and 73 deletions
|
@ -88,8 +88,8 @@ struct core_core_params
|
|||
void (*uninstall_handler)();
|
||||
void (*emulate)();
|
||||
void (*runtosave)();
|
||||
unsigned (*get_pflag)();
|
||||
void (*set_pflag)(unsigned pflag);
|
||||
bool (*get_pflag)();
|
||||
void (*set_pflag)(bool pflag);
|
||||
void (*request_reset)(long delay);
|
||||
port_type** port_types;
|
||||
framebuffer_raw& (*draw_cover)();
|
||||
|
@ -158,8 +158,8 @@ struct core_core
|
|||
void uninstall_handler();
|
||||
void emulate();
|
||||
void runtosave();
|
||||
unsigned get_pflag();
|
||||
void set_pflag(unsigned pflag);
|
||||
bool get_pflag();
|
||||
void set_pflag(bool pflag);
|
||||
void request_reset(long delay);
|
||||
framebuffer_raw& draw_cover();
|
||||
port_type** get_port_types() { return port_types; }
|
||||
|
@ -184,8 +184,8 @@ private:
|
|||
void (*_uninstall_handler)();
|
||||
void (*_emulate)();
|
||||
void (*_runtosave)();
|
||||
unsigned (*_get_pflag)();
|
||||
void (*_set_pflag)(unsigned pflag);
|
||||
bool (*_get_pflag)();
|
||||
void (*_set_pflag)(bool pflag);
|
||||
void (*_request_reset)(long delay);
|
||||
port_type** port_types;
|
||||
framebuffer_raw& (*_draw_cover)();
|
||||
|
@ -239,8 +239,8 @@ public:
|
|||
void uninstall_handler() { core->uninstall_handler(); }
|
||||
void emulate() { core->emulate(); }
|
||||
void runtosave() { core->runtosave(); }
|
||||
unsigned get_pflag() { return core->get_pflag(); }
|
||||
void set_pflag(unsigned pflag) { core->set_pflag(pflag); }
|
||||
bool get_pflag() { return core->get_pflag(); }
|
||||
void set_pflag(bool pflag) { core->set_pflag(pflag); }
|
||||
void request_reset(long delay) { core->request_reset(delay); }
|
||||
framebuffer_raw& draw_cover() { return core->draw_cover(); }
|
||||
private:
|
||||
|
|
|
@ -143,10 +143,6 @@ struct port_index_triple
|
|||
* The control number.
|
||||
*/
|
||||
unsigned control;
|
||||
/**
|
||||
* Does neutral poll of this index count as non-lag frame (non-neutral polls always do)?
|
||||
*/
|
||||
bool marks_nonlag;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -499,36 +495,6 @@ public:
|
|||
throw std::runtime_error("Bad legacy PCID");
|
||||
return legacy_pcids[pcid];
|
||||
}
|
||||
/**
|
||||
* Get "marks nonlag even if neutral" flag for specified index.
|
||||
*
|
||||
* Parameter index: The index.
|
||||
* Returns: The flag.
|
||||
*/
|
||||
bool marks_nonlag(unsigned index) const throw()
|
||||
{
|
||||
try {
|
||||
index_to_triple(index).marks_nonlag;
|
||||
} catch(...) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get "marks nonlag even if neutral" flag for specified triplet.
|
||||
*
|
||||
* Parameter port: The port
|
||||
* Parameter controller: The controller.
|
||||
* Parameter index: The index.
|
||||
* Returns: The flag.
|
||||
*/
|
||||
bool marks_nonlag(unsigned port, unsigned controller, unsigned index) const throw()
|
||||
{
|
||||
try {
|
||||
index_to_triple(triple_to_index(port, controller, index)).marks_nonlag;
|
||||
} catch(...) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private:
|
||||
port_type_set(std::vector<class port_type*> types, struct port_index_map control_map);
|
||||
size_t* port_offsets;
|
||||
|
|
|
@ -47,7 +47,6 @@ namespace
|
|||
{
|
||||
bool p1disable = false;
|
||||
long do_reset_flag = -1;
|
||||
bool pollflag_active = true;
|
||||
boolean_setting allow_inconsistent_saves(lsnes_set, "allow-inconsistent-saves", false);
|
||||
boolean_setting save_every_frame(lsnes_set, "save-every-frame", false);
|
||||
bool have_saved_this_frame = false;
|
||||
|
@ -531,7 +530,6 @@ namespace
|
|||
x.port = p;
|
||||
x.controller = c;
|
||||
x.control = i;
|
||||
x.marks_nonlag = nl;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -1195,11 +1193,10 @@ again2:
|
|||
stepping_into_save = false;
|
||||
},
|
||||
//Get poll flag.
|
||||
[]() -> unsigned { return pollflag_active ? (SNES::cpu.controller_flag ? 1 : 0) : 2; },
|
||||
[]() -> bool { return SNES::cpu.controller_flag; },
|
||||
//Set poll flag.
|
||||
[](unsigned pflag) -> void {
|
||||
SNES::cpu.controller_flag = (pflag != 0);
|
||||
pollflag_active = (pflag < 2);
|
||||
[](bool pflag) -> void {
|
||||
SNES::cpu.controller_flag = pflag;
|
||||
},
|
||||
//Request reset.
|
||||
[](long delay) -> void { do_reset_flag = delay; },
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace
|
|||
uint32_t accumulator_l = 0;
|
||||
uint32_t accumulator_r = 0;
|
||||
unsigned accumulator_s = 0;
|
||||
bool pflag = false;
|
||||
|
||||
core_setting_group gambatte_settings;
|
||||
|
||||
|
@ -174,6 +175,7 @@ namespace
|
|||
if(ecore_callbacks->get_input(0, 1, i))
|
||||
v |= (1 << i);
|
||||
}
|
||||
pflag = true;
|
||||
return v;
|
||||
};
|
||||
} getinput;
|
||||
|
@ -229,7 +231,6 @@ namespace
|
|||
x.port = p;
|
||||
x.controller = c;
|
||||
x.control = i;
|
||||
x.marks_nonlag = nl;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -524,9 +525,9 @@ namespace
|
|||
//Run to save.
|
||||
[]() -> void {},
|
||||
//Get poll flag.
|
||||
[]() -> unsigned { return 2; },
|
||||
[]() -> bool { return pflag; },
|
||||
//Set poll flag.
|
||||
[](unsigned pflag) -> void {},
|
||||
[](bool _pflag) -> void { pflag = _pflag; },
|
||||
//Request reset.
|
||||
[](long delay) -> void { do_reset_flag = true; },
|
||||
//Port types.
|
||||
|
|
|
@ -890,6 +890,7 @@ void main_loop(struct loaded_rom& rom, struct moviefile& initial, bool load_has_
|
|||
redraw_framebuffer(screen_corrupt);
|
||||
}
|
||||
|
||||
movb.get_movie().set_pflag_handler(&lsnes_pflag_handler);
|
||||
lua_callback_startup();
|
||||
|
||||
platform::set_paused(initial.start_paused);
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace
|
|||
} pnull;
|
||||
|
||||
port_type* port_types[] = {NULL};
|
||||
port_index_triple sync_triple = {true, 0, 0, 0, false };
|
||||
port_index_triple sync_triple = {true, 0, 0, 0 };
|
||||
|
||||
|
||||
core_setting_group null_settings;
|
||||
|
@ -126,9 +126,9 @@ namespace
|
|||
//Run to save.
|
||||
[]() -> void {},
|
||||
//Get poll flag.
|
||||
[]() -> unsigned { return 2; },
|
||||
[]() -> bool { return false; },
|
||||
//Set poll flag.
|
||||
[](unsigned pflag) -> void {},
|
||||
[](bool pflag) -> void {},
|
||||
//Request reset.
|
||||
[](long delay) -> void {},
|
||||
//Port types.
|
||||
|
|
|
@ -465,12 +465,12 @@ void core_core::runtosave()
|
|||
_runtosave();
|
||||
}
|
||||
|
||||
unsigned core_core::get_pflag()
|
||||
bool core_core::get_pflag()
|
||||
{
|
||||
return _get_pflag();
|
||||
}
|
||||
|
||||
void core_core::set_pflag(unsigned pflag)
|
||||
void core_core::set_pflag(bool pflag)
|
||||
{
|
||||
return _set_pflag(pflag);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,6 @@ port_type_set::port_type_set() throw()
|
|||
_indices[0].port = 0;
|
||||
_indices[0].controller = 0;
|
||||
_indices[0].control = 0;
|
||||
_indices[0].marks_nonlag = false;
|
||||
|
||||
port_multiplier = 1;
|
||||
controller_multiplier = 1;
|
||||
|
|
|
@ -155,19 +155,16 @@ uint64_t movie::get_frame_count() throw()
|
|||
void movie::next_frame() throw(std::bad_alloc)
|
||||
{
|
||||
//Adjust lag count. Frame 0 MUST NOT be considered lag.
|
||||
//If we don't have valid pflag handler, use the legacy behaviour.
|
||||
unsigned pflag = pflag_handler ? pflag_handler->get_pflag() : 2;
|
||||
if(current_frame && pflag == 0)
|
||||
bool pflag = pflag_handler ? pflag_handler->get_pflag() : false;
|
||||
if(current_frame && !pflag)
|
||||
lag_frames++;
|
||||
else if(pflag < 2 && pflag_handler)
|
||||
pflag_handler->set_pflag(0);
|
||||
else if(pflag_handler)
|
||||
pflag_handler->set_pflag(false);
|
||||
|
||||
//If all poll counters are zero for all real controls, this frame is lag.
|
||||
bool this_frame_lag = !pollcounters.has_polled();
|
||||
//Oh, frame 0 must not be considered lag.
|
||||
if(current_frame && this_frame_lag) {
|
||||
if(pflag == 2)
|
||||
lag_frames++; //Legacy compat. behaviour.
|
||||
//debuglog << "Frame " << current_frame << " is lag" << std::endl << std::flush;
|
||||
if(!readonly) {
|
||||
//If in read-write mode, write a dummy record for the frame. Force sync flag.
|
||||
|
@ -197,15 +194,13 @@ bool movie::get_DRDY(unsigned port, unsigned controller, unsigned ctrl) throw(st
|
|||
|
||||
short movie::next_input(unsigned port, unsigned controller, unsigned ctrl) throw(std::bad_alloc, std::logic_error)
|
||||
{
|
||||
bool do_neutral_update = movie_data.get_types().marks_nonlag(port, controller, ctrl);
|
||||
pollcounters.clear_DRDY(port, controller, ctrl);
|
||||
|
||||
if(readonly) {
|
||||
//In readonly mode...
|
||||
//If at the end of the movie, return released / neutral (but also record the poll)...
|
||||
if(current_frame_first_subframe >= movie_data.size()) {
|
||||
if(do_neutral_update)
|
||||
pollcounters.increment_polls(port, controller, ctrl);
|
||||
pollcounters.increment_polls(port, controller, ctrl);
|
||||
return 0;
|
||||
}
|
||||
//Before the beginning? Somebody screwed up (but return released / neutral anyway)...
|
||||
|
@ -216,8 +211,7 @@ short movie::next_input(unsigned port, unsigned controller, unsigned ctrl) throw
|
|||
uint32_t polls = pollcounters.get_polls(port, controller, ctrl);
|
||||
uint32_t index = (changes > polls) ? polls : changes - 1;
|
||||
int16_t data = movie_data[current_frame_first_subframe + index].axis3(port, controller, ctrl);
|
||||
if(data || do_neutral_update)
|
||||
pollcounters.increment_polls(port, controller, ctrl);
|
||||
pollcounters.increment_polls(port, controller, ctrl);
|
||||
return data;
|
||||
} else {
|
||||
//Readwrite mode.
|
||||
|
@ -229,8 +223,7 @@ short movie::next_input(unsigned port, unsigned controller, unsigned ctrl) throw
|
|||
if(current_frame_first_subframe >= movie_data.size()) {
|
||||
movie_data.append(current_controls.copy(true));
|
||||
//current_frame_first_subframe should be movie_data.size(), so it is right.
|
||||
if(current_controls.axis3(port, controller, ctrl) || do_neutral_update)
|
||||
pollcounters.increment_polls(port, controller, ctrl);
|
||||
pollcounters.increment_polls(port, controller, ctrl);
|
||||
frames_in_movie++;
|
||||
return movie_data[current_frame_first_subframe].axis3(port, controller, ctrl);
|
||||
}
|
||||
|
@ -253,8 +246,7 @@ short movie::next_input(unsigned port, unsigned controller, unsigned ctrl) throw
|
|||
movie_data[current_frame_first_subframe + pollcounter].axis3(port, controller, ctrl,
|
||||
new_value);
|
||||
}
|
||||
if(new_value || do_neutral_update)
|
||||
pollcounters.increment_polls(port, controller, ctrl);
|
||||
pollcounters.increment_polls(port, controller, ctrl);
|
||||
return new_value;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue