public double Distance(ISystemBase s2) { if (s2 != null && HasCoordinate && s2.HasCoordinate) { return(Math.Sqrt((X - s2.X) * (X - s2.X) + (Y - s2.Y) * (Y - s2.Y) + (Z - s2.Z) * (Z - s2.Z))); } else { return(-1); } }
public bool Distance(ISystemBase s2, double min, double max) { if (s2 != null && HasCoordinate && s2.HasCoordinate) { double distsq = (X - s2.X) * (X - s2.X) + (Y - s2.Y) * (Y - s2.Y) + (Z - s2.Z) * (Z - s2.Z); return(distsq >= min * min && distsq <= max * max); } else { return(false); } }
public bool SetSystemState(ISystemBase system, ModuleState state) { var index = this.systems.IndexOf(system); if (index >= 0) { this.statesSystems.arr[index] = state; return(true); } return(false); }
public bool GetSystemState(ISystemBase system, out ModuleState state) { var index = this.systems.IndexOf(system); if (index >= 0) { state = this.statesSystems.arr[index]; return(true); } state = ModuleState.AllActive; return(false); }
public bool Cuboid(ISystemBase s2, double min, double max) { if (s2 != null && HasCoordinate && s2.HasCoordinate) { double xd = Math.Abs(X - s2.X); double yd = Math.Abs(Y - s2.Y); double zd = Math.Abs(Z - s2.Z); return(xd >= min && xd <= max && yd >= min && yd <= max && zd >= min && zd <= max); } else { return(false); } }
/// <summary> /// Remove system manually /// Pool will not be used, OnDeconstruct() call /// </summary> /// <param name="instance"></param> public void RemoveSystem(ISystemBase instance) { if (this.world == null) { SystemGroupRegistryException.Throw(); } if (this.runtimeSystem.Remove(instance) == true) { if (instance is ISystemFilter systemFilter) { systemFilter.filter = Filter.Empty; } instance.world = null; instance.OnDeconstruct(); this.world.UpdateGroup(this); } }
/// <summary> /// Apple1: /// http://myapplecomputer.net/Apple-1/Apple-1_Specs.html /// http://www.applefritter.com/book/export/html/22 /// /// PET: /// source of ROMs: /// http://www.zimmers.net/anonftp/pub/cbm/firmware/computers/pet/ /// /// EHBASIC 6502 - simple basic interpreter /// http://codegolf.stackexchange.com/questions/12844/emulate-a-mos-6502-cpu /// </summary> static void Emulator(string sSystem) { ISystemBase system = null; switch (sSystem) { case "APPLE1": system = new Apple1(); break; case "CBM2001N_B1": system = new CBM2001N_B1(); break; case "CBM2001N": case "CBM2001N_B2": system = new CBM2001N_B2(); break; case "EHBASIC": system = new EHBASIC6502(); break; case "TRS80M1": system = new TRS80M1(); break; case "ZX80": system = new ZX80(); break; case "SIMPLEZ80": system = new SimpleZ80(); break; default: throw new ApplicationException("Emulator not implemented:" + sSystem); } EmulatorScreen screen = new EmulatorScreen(system); }
/// <summary> /// Add system manually /// Pool will not be used, OnConstruct() call /// </summary> /// <param name="instance"></param> public bool AddSystem(ISystemBase instance) { if (this.world == null) { SystemGroupRegistryException.Throw(); } WorldUtilities.SetWorld(this.world); instance.world = this.world; if (instance is ISystemValidation instanceValidate) { if (instanceValidate.CouldBeAdded() == false) { instance.world = null; return(false); } } var k = this.length; ArrayUtils.Resize(in k, ref this.systems, resizeWithOffset: false); ArrayUtils.Resize(in k, ref this.statesSystems, resizeWithOffset: false); ++this.length; this.systems.arr[k] = instance; this.statesSystems.arr[k] = ModuleState.AllActive; instance.OnConstruct(); if (instance is ISystemFilter systemFilter) { systemFilter.filter = systemFilter.CreateFilter(); } this.world.UpdateGroup(this); return(true); }
public EmulatorScreen(ISystemBase system) { InitializeComponent(); m_System = system; Text = m_System.Title; m_System.setupBase(); VideoInfoStruct vi = m_System.VideoInfo; int iPixelSize = 2; if (vi.CharHeight > 8) { iPixelSize = 1; } int iBorder = 2; // setup system screen canvas m_Canvas = new Canvas(vi.Rows, vi.Cols, iBorder, iPixelSize, vi.CharHeight, vi.CharWidth, vi.FontColor, vi.BackColor); Controls.Add(m_Canvas); // setup form with borders ClientSize = new Size(m_Canvas.Width + iBorder * 2, m_Canvas.Height + iBorder * 2); BackColor = vi.BackColor; m_System.setupVideo(m_Canvas.renderCharacter, m_Canvas.drawScanLine); Utilities.SetForegroundWindow(this.Handle.ToInt32()); Show(); m_System.run(); }
/// <summary> /// Remove system manually /// Pool will not be used, OnDeconstruct() call /// </summary> /// <param name="instance"></param> public void RemoveSystem(ISystemBase instance) { if (this.world == null) { SystemGroupRegistryException.Throw(); } var idx = this.systems.IndexOf(instance); if (idx >= 0) { if (instance is ISystemFilter systemFilter) { systemFilter.filter = null; } instance.world = null; this.systems = this.systems.RemoveAt(idx); this.statesSystems = this.statesSystems.RemoveAt(idx); instance.OnDeconstruct(); this.world.UpdateGroup(this); } }
public bool IsSystemActive(ISystemBase system, RuntimeSystemFlag state) { return(this.runtimeSystem.IsSystemActive(system, state)); }
void processCommand(string cmd) { // evaluate command string[] CommandTokens = cmd.Split(' '); if (CommandTokens.Length > 0) { switch (CommandTokens[0].ToUpper()) { case "EXIT": case "QUIT": m_bRun = false; break; case "HELP": print("UNABLE TO COMPLY\r"); break; case "LAUNCH": if (CommandTokens.Length < 2) { print("ERROR\rPLEASE ENTER SYSTEM CODE\r"); } else { m_LaunchSystem = null; switch (CommandTokens[1].ToUpper()) { case "APPLE1": if (CommandTokens.Length > 2) { m_LaunchSystem = new Apple1(CommandTokens[2].ToUpper()); } else { m_LaunchSystem = new Apple1(); } break; case "CBM2001N_B1": m_LaunchSystem = new CBM2001N_B1(); break; case "CBM2001N": case "CBM2001N_B2": m_LaunchSystem = new CBM2001N_B2(); break; case "EHBASIC": m_LaunchSystem = new EHBASIC6502(); break; case "TRS80M1": m_LaunchSystem = new TRS80M1(); break; case "SIMPLEZ80": m_LaunchSystem = new SimpleZ80(); break; case "ZX80": m_LaunchSystem = new ZX80(); break; default: print("ERROR\rSYSTEM CODE UNKNOWN\r"); break; } if (m_LaunchSystem != null) { Thread tSystem = new Thread(new ThreadStart(launchSystem)); tSystem.Start(); } } break; default: print("ERROR!\r"); break; } } prompt(); }