Ejemplo n.º 1
0
        /*
         * are these really not needed anymore?
         * protected override void onPartDestroy()
         * {
         *  if (partActive) {
         *      vessel.OnFlyByWire -= new FlightInputCallback(performManouvers);
         *
         *      //remove manouver-stuff when the part is destroyed
         *      if (this.vessel.isActiveVessel) {
         *          RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI)); //close the GUI
         *          RenderingManager.RemoveFromPostDrawQueue(3, new Callback(monitor.draw));
         *          RenderingManager.RemoveFromPostDrawQueue(3, new Callback(keyb.draw));//start the keyboard
         *      }
         *  }
         * }
         *
         * protected override void onDisconnect()
         * {
         *  //remove manouver sFlyByWire stuff when the part is disconnected
         *  if (this.vessel.isActiveVessel && partActive) {
         *      vessel.OnFlyByWire -= new FlightInputCallback(performManouvers);//this is in here to avoid potential nastiness related to removing nonexistant FlightInputCallbacks.
         *      RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI)); //close the GUI
         *      RenderingManager.RemoveFromPostDrawQueue(3, new Callback(monitor.draw));
         *      RenderingManager.RemoveFromPostDrawQueue(3, new Callback(keyb.draw));//start the keyboard
         *  }
         * }
         */

        private void init()
        {
            //print("PROGCOM INITIALISING");
            //initialise cpu-emulator
            //lastLoaded = 128;
            CPU = new CPUem();

            windowID = Util.random();

            //connect various peripherals to the CPU
            //when possible, separate these out as normal partmodules

            //connect the console memory wrapper
            CPU.hwConnect(ConsoleMemWrapper);

            running = false;

            //iterate through all partmodules connected to the part, make sure all partmodules are aware of this part.
            print("scanning for local progCom hardware...");
            foreach (PartModule pm in this.part.Modules)
            {
                if (pm == this)
                {
                    continue;
                }
                //connect all hardware to this part
                if (pm is IPCHardware)
                {
                    //print("HARDWARE IS FOUND");
                    print("found " + pm.GetType().ToString());
                    try {
                        CPU.hwConnect((IPCHardware)pm);
                    }
                    catch (ArgumentException e) {
                        consoleWrite("Error when connecting hardware:");
                        consoleWrite(e.Message);
                    }
                    catch (Exception e) {
                        consoleWrite("Unexpected error when connecting hardware:");
                        consoleWrite(e.Message);
                    }
                }
                //make sure all partmodules can read the gui state
                if (pm is PCGUIListener)
                {
                    //print("GUIListener found!");
                    try {
                        ((PCGUIListener)pm).recGUIState(GUIstate);
                    }
                    catch (Exception e) {
                        consoleWrite("Error when connecting gui:");
                        consoleWrite(e.Message);
                    }
                }
            }

            //initialise the assembler
            assembler = new Assembler2();
        }
Ejemplo n.º 2
0
 public InterruptHandle(CPUem c)
 {
     cpu = c;
 }
Ejemplo n.º 3
0
        private void init()
        {
            //initialise cpu-emulator
            lastLoaded = 128;
            CPU = new CPUem();

            removeExternalGUI();
            monitor = new Monitor(CPU.Memory, 63488, 65024, 63472, 42);
            keyb = new Keyboard();
            initExternalGUI();

            //connect keyboard to serial port
            connect(keyb, 1);

            running = false;
            //init default values in memory
            CPU.Memory[41] = 1024;//init vector precision
            CPU.Memory[43] = 16;//default speed precision
            int i = 65024;
            foreach (UInt32 font in monitor.getDefaultFont()) {
                CPU.Memory[i] = (Int32)font;
                ++i;
            }
            i = 63472;
            foreach (Int32 col in monitor.getDefaultColors()) {
                CPU.Memory[i] = col;
                ++i;
            }

            //initialise the assembler
            assembler = CPU.getCompatibleAssembler();
            assembler.bindGlobalCall("GLOBAL_MAINTHROTTLE", 0);//init all globaly shared memory positions
            assembler.bindGlobalCall("GLOBAL_YAW", 1);
            assembler.bindGlobalCall("GLOBAL_PITCH", 2);
            assembler.bindGlobalCall("GLOBAL_ROLL", 3);
            assembler.bindGlobalCall("GLOBAL_SURFACE_EAST", 4);
            assembler.bindGlobalCall("GLOBAL_SURFACE_UP", 7);
            assembler.bindGlobalCall("GLOBAL_SURFACE_NORTH", 10);
            assembler.bindGlobalCall("GLOBAL_VESSEL_X", 13);
            assembler.bindGlobalCall("GLOBAL_VESSEL_Y", 16);
            assembler.bindGlobalCall("GLOBAL_VESSEL_HEADING", 16);//ALTERNATE
            assembler.bindGlobalCall("GLOBAL_VESSEL_Z", 19);
            assembler.bindGlobalCall("GLOBAL_ORBITSPEED", 22);
            assembler.bindGlobalCall("GLOBAL_SURFACESPEED", 25);
            assembler.bindGlobalCall("GLOBAL_ANGULARVELOCITY", 28);
            assembler.bindGlobalCall("GLOBAL_ALTITUDE", 31);
            assembler.bindGlobalCall("GLOBAL_NUMPAD_OUT", 32);
            assembler.bindGlobalCall("GLOBAL_NUMPAD_MSG", 36);
            assembler.bindGlobalCall("GLOBAL_NUMPAD_IN", 37);
            assembler.bindGlobalCall("GLOBAL_NUMPAD_NEWIN", 38);
            assembler.bindGlobalCall("GLOBAL_NUMPAD_FORMAT", 39);
            assembler.bindGlobalCall("GLOBAL_TIMER", 40);
            assembler.bindGlobalCall("GLOBAL_VECTORACCURACY", 41);
            assembler.bindGlobalCall("GLOBAL_SCREEN_MODE", 42);
            assembler.bindGlobalCall("GLOBAL_SPEEDACCURACY", 43);
            assembler.bindGlobalCall("GLOBAL_IENABLE", 44);
            assembler.bindGlobalCall("GLOBAL_CLOCK", 45);
            assembler.bindGlobalCall("GLOBAL_IADRESS", 46);
            assembler.bindGlobalCall("GLOBAL_TIMER_MAX", 47);
            assembler.bindGlobalCall("GLOBAL_PILOT_THROTTLE", 48);
            assembler.bindGlobalCall("GLOBAL_PILOT_YAW", 49);
            assembler.bindGlobalCall("GLOBAL_PILOT_PITCH", 50);
            assembler.bindGlobalCall("GLOBAL_PILOT_ROLL", 51);
            assembler.bindGlobalCall("GLOBAL_PILOT_RCS_RIGHT", 52);
            assembler.bindGlobalCall("GLOBAL_PILOT_RCS_UP", 53);
            assembler.bindGlobalCall("GLOBAL_PILOT_RCS_FORWARD", 54);
            assembler.bindGlobalCall("GLOBAL_RCS_RIGHT", 52);
            assembler.bindGlobalCall("GLOBAL_RCS_UP", 53);
            assembler.bindGlobalCall("GLOBAL_RCS_FORWARD", 54);
            assembler.bindGlobalCall("GLOBAL_ACTIONGROUP", 55);

            //serial buses
            assembler.bindGlobalCall("GLOBAL_GSB0", 64);
            assembler.bindGlobalCall("GLOBAL_GSB1", 68);
            assembler.bindGlobalCall("GLOBAL_GSB2", 72);
            assembler.bindGlobalCall("GLOBAL_GSB3", 76);
            assembler.bindGlobalCall("GLOBAL_GSB4", 80);
            assembler.bindGlobalCall("GLOBAL_GSB5", 84);
            assembler.bindGlobalCall("GLOBAL_GSB6", 88);
            assembler.bindGlobalCall("GLOBAL_GSB7", 92);

            //monitor stuff
            assembler.bindGlobalCall("GLOBAL_SCREEN", 63488);
            assembler.bindGlobalCall("GLOBAL_SCREEN_COLOR", 63472);
            assembler.bindGlobalCall("GLOBAL_SCREEN_FONT", 65024);

            //other stuff
            assembler.bindGlobalCall("CPU_CLOCKRATE", CPU.ClockRate);
            assembler.bindGlobalCall("CPU_RAM", CPU.Memory.Length);
            assembler.bindGlobalCall("CPU_MAXADDRESS", CPU.Memory.Length-1);
        }
Ejemplo n.º 4
0
 public InterruptHandle(CPUem c)
 {
     cpu = c;
 }
Ejemplo n.º 5
0
        /*
         * are these really not needed anymore?
        protected override void onPartDestroy()
        {
            if (partActive) {
                vessel.OnFlyByWire -= new FlightInputCallback(performManouvers);

                //remove manouver-stuff when the part is destroyed
                if (this.vessel.isActiveVessel) {
                    RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI)); //close the GUI
                    RenderingManager.RemoveFromPostDrawQueue(3, new Callback(monitor.draw));
                    RenderingManager.RemoveFromPostDrawQueue(3, new Callback(keyb.draw));//start the keyboard
                }
            }
        }

        protected override void onDisconnect()
        {
            //remove manouver sFlyByWire stuff when the part is disconnected
            if (this.vessel.isActiveVessel && partActive) {
                vessel.OnFlyByWire -= new FlightInputCallback(performManouvers);//this is in here to avoid potential nastiness related to removing nonexistant FlightInputCallbacks.
                RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI)); //close the GUI
                RenderingManager.RemoveFromPostDrawQueue(3, new Callback(monitor.draw));
                RenderingManager.RemoveFromPostDrawQueue(3, new Callback(keyb.draw));//start the keyboard
            }
        }
        */
        private void init()
        {
            //print("PROGCOM INITIALISING");
            //initialise cpu-emulator
            //lastLoaded = 128;
            CPU = new CPUem();

            windowID = Util.random();

            //connect various peripherals to the CPU
            //when possible, separate these out as normal partmodules

            //connect the console memory wrapper
            CPU.hwConnect(ConsoleMemWrapper);

            running = false;

            //iterate through all partmodules connected to the part, make sure all partmodules are aware of this part.
            print("scanning for local progCom hardware...");
            foreach (PartModule pm in this.part.Modules) {
                if (pm == this) continue;
                //connect all hardware to this part
                if (pm is IPCHardware) {
                    //print("HARDWARE IS FOUND");
                    print("found " + pm.GetType().ToString());
                    try {
                        CPU.hwConnect((IPCHardware)pm);
                    }
                    catch (ArgumentException e) {
                        consoleWrite("Error when connecting hardware:");
                        consoleWrite(e.Message);
                    }
                    catch (Exception e) {
                        consoleWrite("Unexpected error when connecting hardware:");
                        consoleWrite(e.Message);
                    }
                }
                //make sure all partmodules can read the gui state
                if (pm is PCGUIListener) {
                    //print("GUIListener found!");
                    try {
                        ((PCGUIListener)pm).recGUIState(GUIstate);
                    }
                    catch (Exception e) {
                        consoleWrite("Error when connecting gui:");
                        consoleWrite(e.Message);
                    }
                }
            }

            //initialise the assembler
            assembler = new Assembler2();
        }