use crate::gml::assembly::assemble_instruction;
use crate::gml::instruction::InstanceType;
use crate::gml::instruction::Instruction;
use crate::prelude::*;
pub fn toggle(data: &mut GMData, enable: bool) -> Result<()> {
let code_ref = data.scripts.code_ref_by_name("SCR_GAMESTART")?;
super::replace_debug(data, code_ref, enable, InstanceType::Global)?;
let code_ref = data
.codes
.ref_by_name("gml_Object_obj_debugcontroller_ch1_Create_0")?;
super::replace_debug(data, code_ref, enable, InstanceType::Self_)?;
let instructions = if enable {
let pushim = Instruction::PushImmediate { integer: 0 };
let pop = assemble_instruction("pop.v.i self.cutsceneshow", data)?;
vec![pushim, pop]
} else {
vec![]
};
let code = data
.codes
.by_name_mut("gml_Object_obj_debugProfiler_Create_0")?;
code.instructions = instructions;
Ok(())
}