Пример #1
0
 private Z80CPU.Op DecodeOp(State state)
 {
     while (true)
     {
         var b = z80.Memory.ReadByte(state.Address++);
         switch (b)
         {
             case 0xDD:
                 manipulateDecoded = input => input.Replace("(HL)", "(IXx)").Replace("HL", "IX");
                 state.IndexerRegister = Z80CPU.IndexerRegister.IX;
                 continue;
             case 0xFD:
                 manipulateDecoded = input => input.Replace("(HL)", "(IYx)").Replace("HL", "IY");
                 state.IndexerRegister = Z80CPU.IndexerRegister.IY;
                 continue;
             case 0xCB:
                 if (state.IndexerRegister != Z80CPU.IndexerRegister.HL)
                     state.IndexerOffset = (SByte) z80.Memory.ReadByte(state.Address++);
                 return z80.opCB[z80.Memory.ReadByte(state.Address++)];
             case 0xED:
                 return z80.opED[z80.Memory.ReadByte(state.Address++)];
             default:
                 return z80.op[b];
         }
     }
 }
Пример #2
0
        private String DecodeText(State state, Z80CPU.Op op)
        {
            if (op == null)
                return String.Format("DEFB " + HexByte, z80.Memory.ReadByte(state.Address));

            var text = op.Name;
            if (manipulateDecoded != null)
            {
                text = manipulateDecoded.Invoke(text);
                manipulateDecoded = null;
            }

            if (text.Contains("x"))
            {
                var x = state.IndexerOffset ?? (SByte)z80.Memory.ReadByte(state.Address++);
                text = text.Replace("x", x.ToString("+;-;") + String.Format(HexByte, x));
            }

            if (text.Contains("e"))
            {
                var e = (SByte)(z80.Memory.ReadByte(state.Address++));
                text = text.Replace("e", "$" + new LEWord((UInt16)(state.Address + e)));
                // + " (" + e.ToString("+0;-0;0") + ")");
            }

            if (text.Contains("nn"))
            {
                var nn = z80.Memory.ReadWord(state.Address);
                state.Address += 2;
                text = text.Replace("nn", String.Format(HexWord, nn));
            }

            if (text.Contains("n"))
            {
                var n = z80.Memory.ReadByte(state.Address++);
                text = text.Replace("n", String.Format(HexByte, n));
            }

            return text;
        }