Skip to content

Commit

Permalink
#40: Converted ushort to int from CPU
Browse files Browse the repository at this point in the history
  • Loading branch information
saku-kaarakainen committed Sep 6, 2016
1 parent 19680e8 commit 2f3f4f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions WinBoyEmulator/GameBoy/CPU/IRegisters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ interface IRegisters
byte L { get; set; }

// 16-bit registers
ushort AF { get; set; }
ushort BC { get; set; }
ushort DE { get; set; }
ushort HL { get; set; }
int AF { get; set; }
int BC { get; set; }
int DE { get; set; }
int HL { get; set; }

ushort SP { get; set; }
ushort PC { get; set; }
int SP { get; set; }
int PC { get; set; }
}
}
28 changes: 14 additions & 14 deletions WinBoyEmulator/GameBoy/CPU/LR35902.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class LR35902 : Flag, IRegisters

// store registers values to these bytes.
private byte _a, _b, _c, _d, _e, _f, _h, _l;
private ushort _sp, _pc;
private int _sp, _pc;

#region Registers Accessors
/// <summary>8-bit register A. Value between 0x8000 - 0x0100.</summary>
Expand Down Expand Up @@ -67,11 +67,11 @@ public byte F
}
}
/// <summary>16-bit register AF. Combined register A with register F.</summary>
public ushort AF
public int AF
{
get
{
return (ushort)((_a << 8) | F);
return (_a << 8) | F;
}
set
{
Expand Down Expand Up @@ -105,11 +105,11 @@ public byte C
}
}
/// <summary>16-bit register BC. Combined register B with register C.</summary>
public ushort BC
public int BC
{
get
{
return (ushort)((_b << 8) | _c);
return (_b << 8) | _c;
}
set
{
Expand Down Expand Up @@ -143,11 +143,11 @@ public byte E
}
}
/// <summary>16-bit register DE. Combined register D with register E.</summary>
public ushort DE
public int DE
{
get
{
return (ushort)((_d << 8) | _e);
return (_d << 8) | _e;
}
set
{
Expand Down Expand Up @@ -181,11 +181,11 @@ public byte L
}
}
/// <summary>16-bit register HL. Combined register H with register L.</summary>
public ushort HL
public int HL
{
get
{
return (ushort)((_h << 8) | _l);
return (_h << 8) | _l;
}
set
{
Expand All @@ -195,7 +195,7 @@ public ushort HL
}

/// <summary>16-bit Stack Pointer register</summary>
public ushort SP
public int SP
{
get
{
Expand All @@ -208,7 +208,7 @@ public ushort SP
}

/// <summary>16-bit Program Counter. Initialize value 0x100.</summary>
public ushort PC
public int PC
{
get
{
Expand Down Expand Up @@ -258,7 +258,7 @@ private void _setByteToRegister(string register, byte value)
/// </summary>
/// <param name="register">Register. Use a const string of a static class Register.</param>
/// <param name="value"></param>
private void _setValueToRegister(string register, ushort value)
private void _setValueToRegister(string register, int value)
{
switch(register)
{
Expand Down Expand Up @@ -290,7 +290,7 @@ private byte _getByteFromRegister(string register)
}
}

private ushort _getValueFromRegister(string register)
private int _getValueFromRegister(string register)
{
switch (register)
{
Expand Down Expand Up @@ -363,7 +363,7 @@ private void _ld(Instruction opcode)
case Source.d16:
// When opcode.Value is: 0x01, 0x11, 0x21, 0x31
// How about redesign, to not to cast here?
SP = (ushort)MMU.Instance.ReadShort(PC);
SP = MMU.Instance.ReadShort(PC);
PC += 2;
break;
// case Source.a8: // a8 is used only with LDH
Expand Down

0 comments on commit 2f3f4f0

Please sign in to comment.