예제 #1
0
        private void MakeTrace(long _cycleCount)
        {
            int[] regs = new int[12];
            LibEmu83.TI83_GetRegs(Context, regs);
            ushort PC = (ushort)regs[10];

            string disasm    = Z80A.Disassemble(PC, addr => LibEmu83.TI83_ReadMemory(Context, addr), out int bytes_read);
            string byte_code = null;

            for (ushort i = 0; i < bytes_read; i++)
            {
                byte_code += $"{LibEmu83.TI83_ReadMemory(Context, (ushort)(PC + i)):X2}";
                if (i < (bytes_read - 1))
                {
                    byte_code += " ";
                }
            }

            Tracer.Put(new(
                           disassembly:
                           $"{PC:X4}: {byte_code,-12} {disasm,-26}",
                           registerInfo:
                           $"AF:{regs[0]:X4} BC:{regs[1]:X4} DE:{regs[2]:X4} HL:{regs[3]:X4} IX:{regs[8]:X4} IY:{regs[9]:X4} SP:{regs[11]:X4} Cy:{_cycleCount}"
                           ));
        }
예제 #2
0
        static Emu83()
        {
            var resolver = new DynamicLibraryImportResolver(
                OSTailoredCode.IsUnixHost ? "libemu83.so" : "libemu83.dll", hasLimitedLifetime: false);

            LibEmu83 = BizInvoker.GetInvoker <LibEmu83>(resolver, CallingConventionAdapters.Native);
        }
예제 #3
0
 public void Dispose()
 {
     if (Context != IntPtr.Zero)
     {
         LibEmu83.TI83_DestroyContext(Context);
         Context = IntPtr.Zero;
     }
 }
예제 #4
0
        public void SaveStateBinary(BinaryWriter writer)
        {
            if (!LibEmu83.TI83_SaveState(Context, _stateBuf))
            {
                throw new Exception($"{nameof(LibEmu83.TI83_SaveState)}() returned false");
            }

            writer.Write(_stateBuf.Length);
            writer.Write(_stateBuf);

            // other variables
            writer.Write(IsLagFrame);
            writer.Write(LagCount);
            writer.Write(Frame);
        }
예제 #5
0
        public bool FrameAdvance(IController controller, bool render, bool renderSound)
        {
            _controller = controller;

            LibEmu83.TI83_SetTraceCallback(Context, Tracer.IsEnabled() ? _traceCallback : null);

            IsLagFrame = LibEmu83.TI83_Advance(Context, _controller.IsPressed("ON"), _controller.IsPressed("SEND"), render ? _videoBuffer : null, _settings.BGColor, _settings.ForeColor);

            Frame++;

            if (IsLagFrame)
            {
                LagCount++;
            }

            return(true);
        }
예제 #6
0
 public IDictionary <string, RegisterValue> GetCpuFlagsAndRegisters()
 {
     int[] regs = new int[12];
     LibEmu83.TI83_GetRegs(Context, regs);
     return(new Dictionary <string, RegisterValue>
     {
         ["AF"] = (ushort)regs[0],
         ["BC"] = (ushort)regs[1],
         ["DE"] = (ushort)regs[2],
         ["HL"] = (ushort)regs[3],
         ["AF'"] = (ushort)regs[4],
         ["BC'"] = (ushort)regs[5],
         ["DE'"] = (ushort)regs[6],
         ["HL'"] = (ushort)regs[7],
         ["IX"] = (ushort)regs[8],
         ["IY"] = (ushort)regs[9],
         ["PC"] = (ushort)regs[10],
         ["SP"] = (ushort)regs[11],
     });
 }
예제 #7
0
        public void LoadStateBinary(BinaryReader reader)
        {
            int length = reader.ReadInt32();

            if (length != _stateBuf.Length)
            {
                throw new InvalidOperationException("Savestate buffer size mismatch!");
            }

            reader.Read(_stateBuf, 0, _stateBuf.Length);

            if (!LibEmu83.TI83_LoadState(Context, _stateBuf))
            {
                throw new Exception($"{nameof(LibEmu83.TI83_LoadState)}() returned false");
            }

            // other variables
            IsLagFrame = reader.ReadBoolean();
            LagCount   = reader.ReadInt32();
            Frame      = reader.ReadInt32();
        }