mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2024-09-29 13:54:40 +00:00
Merge branch 'master' of https://github.com/MoleskiCoder/EightBitNet
This commit is contained in:
commit
4a0d466171
@ -138,7 +138,7 @@ namespace EightBit
|
|||||||
{
|
{
|
||||||
this.MEMPTR.Low = address;
|
this.MEMPTR.Low = address;
|
||||||
this.MEMPTR.High = 0;
|
this.MEMPTR.High = 0;
|
||||||
this.Call(this.MEMPTR);
|
this.Call(this.MEMPTR.Word);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool CallConditional(bool condition)
|
protected bool CallConditional(bool condition)
|
||||||
@ -146,7 +146,7 @@ namespace EightBit
|
|||||||
this.MEMPTR.Word = this.FetchWord().Word;
|
this.MEMPTR.Word = this.FetchWord().Word;
|
||||||
if (condition)
|
if (condition)
|
||||||
{
|
{
|
||||||
this.Call(this.MEMPTR);
|
this.Call(this.MEMPTR.Word);
|
||||||
}
|
}
|
||||||
|
|
||||||
return condition;
|
return condition;
|
||||||
@ -157,7 +157,7 @@ namespace EightBit
|
|||||||
this.MEMPTR.Word = this.FetchWord().Word;
|
this.MEMPTR.Word = this.FetchWord().Word;
|
||||||
if (condition)
|
if (condition)
|
||||||
{
|
{
|
||||||
this.Jump(this.MEMPTR);
|
this.Jump(this.MEMPTR.Word);
|
||||||
}
|
}
|
||||||
|
|
||||||
return condition;
|
return condition;
|
||||||
@ -176,7 +176,7 @@ namespace EightBit
|
|||||||
protected void JumpRelative(sbyte offset)
|
protected void JumpRelative(sbyte offset)
|
||||||
{
|
{
|
||||||
this.MEMPTR.Word = (ushort)(this.PC.Word + offset);
|
this.MEMPTR.Word = (ushort)(this.PC.Word + offset);
|
||||||
this.Jump(this.MEMPTR);
|
this.Jump(this.MEMPTR.Word);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool JumpRelativeConditional(bool condition)
|
protected bool JumpRelativeConditional(bool condition)
|
||||||
|
@ -186,16 +186,12 @@ namespace EightBit
|
|||||||
|
|
||||||
protected void Jump(ushort destination) => this.PC.Word = destination;
|
protected void Jump(ushort destination) => this.PC.Word = destination;
|
||||||
|
|
||||||
protected void Jump(Register16 destination) => this.Jump(destination.Word);
|
|
||||||
|
|
||||||
protected void Call(ushort destination)
|
protected void Call(ushort destination)
|
||||||
{
|
{
|
||||||
this.PushWord(this.PC);
|
this.PushWord(this.PC);
|
||||||
this.Jump(destination);
|
this.Jump(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Call(Register16 destination) => this.Call(destination.Word);
|
|
||||||
|
|
||||||
protected virtual void Return() => this.Jump(this.PopWord().Word);
|
protected virtual void Return() => this.Jump(this.PopWord().Word);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
using System.Reflection;
|
// <copyright file="AssemblyInfo.cs" company="Adrian Conlon">
|
||||||
using System.Runtime.CompilerServices;
|
// Copyright (c) Adrian Conlon. All rights reserved.
|
||||||
|
// </copyright>
|
||||||
|
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
@ -479,7 +479,7 @@ namespace EightBit
|
|||||||
this.Tick(10);
|
this.Tick(10);
|
||||||
break;
|
break;
|
||||||
case 2: // JP HL
|
case 2: // JP HL
|
||||||
this.Jump(this.HL);
|
this.Jump(this.HL.Word);
|
||||||
this.Tick(4);
|
this.Tick(4);
|
||||||
break;
|
break;
|
||||||
case 3: // LD SP,HL
|
case 3: // LD SP,HL
|
||||||
@ -502,7 +502,7 @@ namespace EightBit
|
|||||||
switch (y)
|
switch (y)
|
||||||
{
|
{
|
||||||
case 0: // JP nn
|
case 0: // JP nn
|
||||||
this.Jump(this.FetchWord());
|
this.Jump(this.FetchWord().Word);
|
||||||
this.Tick(10);
|
this.Tick(10);
|
||||||
break;
|
break;
|
||||||
case 2: // OUT (n),A
|
case 2: // OUT (n),A
|
||||||
@ -551,7 +551,7 @@ namespace EightBit
|
|||||||
switch (p)
|
switch (p)
|
||||||
{
|
{
|
||||||
case 0: // CALL nn
|
case 0: // CALL nn
|
||||||
this.Call(this.FetchWord());
|
this.Call(this.FetchWord().Word);
|
||||||
this.Tick(17);
|
this.Tick(17);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ namespace EightBit
|
|||||||
case 0x49: this.A = this.EorR(this.A, this.AM_Immediate()); break; // EOR (immediate)
|
case 0x49: this.A = this.EorR(this.A, this.AM_Immediate()); break; // EOR (immediate)
|
||||||
case 0x4a: this.BusRead(); this.A = this.LSR(this.A); break; // LSR A (implied)
|
case 0x4a: this.BusRead(); this.A = this.LSR(this.A); break; // LSR A (implied)
|
||||||
case 0x4b: this.ASR(this.AM_Immediate()); break; // *ASR (immediate)
|
case 0x4b: this.ASR(this.AM_Immediate()); break; // *ASR (immediate)
|
||||||
case 0x4c: this.Jump(this.Address_Absolute()); break; // JMP (absolute)
|
case 0x4c: this.Jump(this.Address_Absolute().Word); break; // JMP (absolute)
|
||||||
case 0x4d: this.A = this.EorR(this.A, this.AM_Absolute()); break; // EOR (absolute)
|
case 0x4d: this.A = this.EorR(this.A, this.AM_Absolute()); break; // EOR (absolute)
|
||||||
case 0x4e: this.BusReadModifyWrite(this.LSR(this.AM_Absolute())); break; // LSR (absolute)
|
case 0x4e: this.BusReadModifyWrite(this.LSR(this.AM_Absolute())); break; // LSR (absolute)
|
||||||
case 0x4f: this.SRE(this.AM_Absolute()); break; // *SRE (absolute)
|
case 0x4f: this.SRE(this.AM_Absolute()); break; // *SRE (absolute)
|
||||||
@ -267,7 +267,7 @@ namespace EightBit
|
|||||||
case 0x69: this.A = this.ADC(this.A, this.AM_Immediate()); break; // ADC (immediate)
|
case 0x69: this.A = this.ADC(this.A, this.AM_Immediate()); break; // ADC (immediate)
|
||||||
case 0x6a: this.BusRead(); this.A = this.ROR(this.A); break; // ROR A (implied)
|
case 0x6a: this.BusRead(); this.A = this.ROR(this.A); break; // ROR A (implied)
|
||||||
case 0x6b: this.ARR(this.AM_Immediate()); break; // *ARR (immediate)
|
case 0x6b: this.ARR(this.AM_Immediate()); break; // *ARR (immediate)
|
||||||
case 0x6c: this.Jump(this.Address_Indirect()); break; // JMP (indirect)
|
case 0x6c: this.Jump(this.Address_Indirect().Word); break; // JMP (indirect)
|
||||||
case 0x6d: this.A = this.ADC(this.A, this.AM_Absolute()); break; // ADC (absolute)
|
case 0x6d: this.A = this.ADC(this.A, this.AM_Absolute()); break; // ADC (absolute)
|
||||||
case 0x6e: this.BusReadModifyWrite(this.ROR(this.AM_Absolute())); break; // ROR (absolute)
|
case 0x6e: this.BusReadModifyWrite(this.ROR(this.AM_Absolute())); break; // ROR (absolute)
|
||||||
case 0x6f: this.RRA(this.AM_Absolute()); break; // *RRA (absolute)
|
case 0x6f: this.RRA(this.AM_Absolute()); break; // *RRA (absolute)
|
||||||
@ -589,7 +589,7 @@ namespace EightBit
|
|||||||
|
|
||||||
this.P = SetFlag(this.P, StatusBits.IF); // Disable IRQ
|
this.P = SetFlag(this.P, StatusBits.IF); // Disable IRQ
|
||||||
var vector = reset ? RSTvector : (nmi ? NMIvector : IRQvector);
|
var vector = reset ? RSTvector : (nmi ? NMIvector : IRQvector);
|
||||||
this.Jump(this.GetWordPaged(0xff, vector));
|
this.Jump(this.GetWordPaged(0xff, vector).Word);
|
||||||
this.handlingRESET = this.handlingNMI = this.handlingINT = false;
|
this.handlingRESET = this.handlingNMI = this.handlingINT = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
using System.Reflection;
|
// <copyright file="AssemblyInfo.cs" company="Adrian Conlon">
|
||||||
using System.Runtime.CompilerServices;
|
// Copyright (c) Adrian Conlon. All rights reserved.
|
||||||
|
// </copyright>
|
||||||
|
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
46
Z80/Z80.cs
46
Z80/Z80.cs
@ -1222,7 +1222,7 @@ namespace EightBit
|
|||||||
this.Tick(4);
|
this.Tick(4);
|
||||||
break;
|
break;
|
||||||
case 2: // JP HL
|
case 2: // JP HL
|
||||||
this.Jump(this.HL2());
|
this.Jump(this.HL2().Word);
|
||||||
this.Tick(4);
|
this.Tick(4);
|
||||||
break;
|
break;
|
||||||
case 3: // LD SP,HL
|
case 3: // LD SP,HL
|
||||||
@ -1800,12 +1800,12 @@ namespace EightBit
|
|||||||
hl2.High = this.MEMPTR.High;
|
hl2.High = this.MEMPTR.High;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BlockCompare(Register16 source, Register16 counter)
|
private void BlockCompare(ushort source, ushort counter)
|
||||||
{
|
{
|
||||||
var value = this.BusRead(source);
|
var value = this.BusRead(source);
|
||||||
var result = (byte)(this.A - value);
|
var result = (byte)(this.A - value);
|
||||||
|
|
||||||
this.F = SetFlag(this.F, StatusBits.PF, --counter.Word);
|
this.F = SetFlag(this.F, StatusBits.PF, counter);
|
||||||
|
|
||||||
this.F = AdjustSZ(this.F, result);
|
this.F = AdjustSZ(this.F, result);
|
||||||
this.F = AdjustHalfCarrySub(this.F, this.A, value, result);
|
this.F = AdjustHalfCarrySub(this.F, this.A, value, result);
|
||||||
@ -1819,8 +1819,7 @@ namespace EightBit
|
|||||||
|
|
||||||
private void CPI()
|
private void CPI()
|
||||||
{
|
{
|
||||||
this.BlockCompare(this.HL, this.BC);
|
this.BlockCompare(this.HL.Word++, --this.BC.Word);
|
||||||
++this.HL.Word;
|
|
||||||
++this.MEMPTR.Word;
|
++this.MEMPTR.Word;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1832,8 +1831,7 @@ namespace EightBit
|
|||||||
|
|
||||||
private void CPD()
|
private void CPD()
|
||||||
{
|
{
|
||||||
this.BlockCompare(this.HL, this.BC);
|
this.BlockCompare(this.HL.Word--, --this.BC.Word);
|
||||||
--this.HL.Word;
|
|
||||||
--this.MEMPTR.Word;
|
--this.MEMPTR.Word;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1843,7 +1841,7 @@ namespace EightBit
|
|||||||
return ((this.F & (byte)StatusBits.PF) != 0) && ((this.F & (byte)StatusBits.ZF) == 0); // See CPD
|
return ((this.F & (byte)StatusBits.PF) != 0) && ((this.F & (byte)StatusBits.ZF) == 0); // See CPD
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BlockLoad(Register16 source, Register16 destination, Register16 counter)
|
private void BlockLoad(ushort source, ushort destination, ushort counter)
|
||||||
{
|
{
|
||||||
var value = this.BusRead(source);
|
var value = this.BusRead(source);
|
||||||
this.BusWrite(destination, value);
|
this.BusWrite(destination, value);
|
||||||
@ -1851,15 +1849,10 @@ namespace EightBit
|
|||||||
this.F = SetFlag(this.F, StatusBits.XF, xy & (int)Bits.Bit3);
|
this.F = SetFlag(this.F, StatusBits.XF, xy & (int)Bits.Bit3);
|
||||||
this.F = SetFlag(this.F, StatusBits.YF, xy & (int)Bits.Bit1);
|
this.F = SetFlag(this.F, StatusBits.YF, xy & (int)Bits.Bit1);
|
||||||
this.F = ClearFlag(this.F, StatusBits.NF | StatusBits.HC);
|
this.F = ClearFlag(this.F, StatusBits.NF | StatusBits.HC);
|
||||||
this.F = SetFlag(this.F, StatusBits.PF, --counter.Word);
|
this.F = SetFlag(this.F, StatusBits.PF, counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LDI()
|
private void LDI() => this.BlockLoad(this.HL.Word++, this.DE.Word++, --this.BC.Word);
|
||||||
{
|
|
||||||
this.BlockLoad(this.HL, this.DE, this.BC);
|
|
||||||
++this.HL.Word;
|
|
||||||
++this.DE.Word;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool LDIR()
|
private bool LDIR()
|
||||||
{
|
{
|
||||||
@ -1867,12 +1860,7 @@ namespace EightBit
|
|||||||
return (this.F & (byte)StatusBits.PF) != 0; // See LDI
|
return (this.F & (byte)StatusBits.PF) != 0; // See LDI
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LDD()
|
private void LDD() => this.BlockLoad(this.HL.Word--, this.DE.Word--, --this.BC.Word);
|
||||||
{
|
|
||||||
this.BlockLoad(this.HL, this.DE, this.BC);
|
|
||||||
--this.HL.Word;
|
|
||||||
--this.DE.Word;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool LDDR()
|
private bool LDDR()
|
||||||
{
|
{
|
||||||
@ -1880,7 +1868,7 @@ namespace EightBit
|
|||||||
return (this.F & (byte)StatusBits.PF) != 0; // See LDD
|
return (this.F & (byte)StatusBits.PF) != 0; // See LDD
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BlockIn(Register16 source, Register16 destination)
|
private void BlockIn(Register16 source, ushort destination)
|
||||||
{
|
{
|
||||||
this.MEMPTR.Word = this.Bus.Address.Word = source.Word;
|
this.MEMPTR.Word = this.Bus.Address.Word = source.Word;
|
||||||
var value = this.ReadPort();
|
var value = this.ReadPort();
|
||||||
@ -1891,8 +1879,7 @@ namespace EightBit
|
|||||||
|
|
||||||
private void INI()
|
private void INI()
|
||||||
{
|
{
|
||||||
this.BlockIn(this.BC, this.HL);
|
this.BlockIn(this.BC, this.HL.Word++);
|
||||||
++this.HL.Word;
|
|
||||||
++this.MEMPTR.Word;
|
++this.MEMPTR.Word;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1904,8 +1891,7 @@ namespace EightBit
|
|||||||
|
|
||||||
private void IND()
|
private void IND()
|
||||||
{
|
{
|
||||||
this.BlockIn(this.BC, this.HL);
|
this.BlockIn(this.BC, this.HL.Word--);
|
||||||
--this.HL.Word;
|
|
||||||
--this.MEMPTR.Word;
|
--this.MEMPTR.Word;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1915,7 +1901,7 @@ namespace EightBit
|
|||||||
return (this.F & (byte)StatusBits.ZF) == 0; // See IND
|
return (this.F & (byte)StatusBits.ZF) == 0; // See IND
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BlockOut(Register16 source, Register16 destination)
|
private void BlockOut(ushort source, Register16 destination)
|
||||||
{
|
{
|
||||||
var value = this.BusRead(source);
|
var value = this.BusRead(source);
|
||||||
this.Bus.Address.Word = destination.Word;
|
this.Bus.Address.Word = destination.Word;
|
||||||
@ -1929,8 +1915,7 @@ namespace EightBit
|
|||||||
|
|
||||||
private void OUTI()
|
private void OUTI()
|
||||||
{
|
{
|
||||||
this.BlockOut(this.HL, this.BC);
|
this.BlockOut(this.HL.Word++, this.BC);
|
||||||
++this.HL.Word;
|
|
||||||
++this.MEMPTR.Word;
|
++this.MEMPTR.Word;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1942,8 +1927,7 @@ namespace EightBit
|
|||||||
|
|
||||||
private void OUTD()
|
private void OUTD()
|
||||||
{
|
{
|
||||||
this.BlockOut(this.HL, this.BC);
|
this.BlockOut(this.HL.Word--, this.BC);
|
||||||
--this.HL.Word;
|
|
||||||
--this.MEMPTR.Word;
|
--this.MEMPTR.Word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user