Remove old GB CPU core
This commit is contained in:
parent
8e1ba79e0a
commit
69170fb110
|
@ -1223,12 +1223,6 @@
|
|||
<Compile Include="CPUs\x86\Execute.cs" />
|
||||
<Compile Include="CPUs\x86\Timing.cs" />
|
||||
<Compile Include="CPUs\x86\x86.cs" />
|
||||
<Compile Include="CPUs\Z80-GB\Execute.cs" />
|
||||
<Compile Include="CPUs\Z80-GB\Interrupts.cs" />
|
||||
<Compile Include="CPUs\Z80-GB\NewDisassembler.cs" />
|
||||
<Compile Include="CPUs\Z80-GB\Registers.cs" />
|
||||
<Compile Include="CPUs\Z80-GB\Tables.cs" />
|
||||
<Compile Include="CPUs\Z80-GB\Z80.cs" />
|
||||
<Compile Include="CPUs\Z80A\NewDisassembler.cs" />
|
||||
<Compile Include="CPUs\Z80A\Execute.cs" />
|
||||
<Compile Include="CPUs\Z80A\Interrupts.cs" />
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,52 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components.Z80GB
|
||||
{
|
||||
public partial class Z80
|
||||
{
|
||||
private bool iff1;
|
||||
public bool IFF1 { get { return iff1; } set { iff1 = value; } }
|
||||
|
||||
private bool iff2;
|
||||
public bool IFF2 { get { return iff2; } set { iff2 = value; } }
|
||||
|
||||
private bool interrupt;
|
||||
public bool Interrupt { get { return interrupt; } set { interrupt = value; } }
|
||||
|
||||
private bool nonMaskableInterrupt;
|
||||
public bool NonMaskableInterrupt
|
||||
{
|
||||
get { return nonMaskableInterrupt; }
|
||||
set { if (value && !nonMaskableInterrupt) NonMaskableInterruptPending = true; nonMaskableInterrupt = value; }
|
||||
}
|
||||
|
||||
private bool nonMaskableInterruptPending;
|
||||
public bool NonMaskableInterruptPending { get { return nonMaskableInterruptPending; } set { nonMaskableInterruptPending = value; } }
|
||||
|
||||
private int interruptMode;
|
||||
public int InterruptMode
|
||||
{
|
||||
get { return interruptMode; }
|
||||
set { if (value < 0 || value > 2) throw new ArgumentOutOfRangeException(); interruptMode = value; }
|
||||
}
|
||||
|
||||
private bool halted;
|
||||
public bool Halted { get { return halted; } set { halted = value; } }
|
||||
|
||||
private void ResetInterrupts()
|
||||
{
|
||||
IFF1 = false;
|
||||
IFF2 = false;
|
||||
Interrupt = false;
|
||||
NonMaskableInterrupt = false;
|
||||
NonMaskableInterruptPending = false;
|
||||
InterruptMode = 1;
|
||||
Halted = false;
|
||||
}
|
||||
|
||||
private void Halt()
|
||||
{
|
||||
Halted = true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,587 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components.Z80GB
|
||||
{
|
||||
// adapted from the information at http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html
|
||||
public class NewDisassembler
|
||||
{
|
||||
static string[] table =
|
||||
{
|
||||
"NOP", // 00
|
||||
"LD BC,d16", // 01
|
||||
"LD (BC),A", // 02
|
||||
"INC BC", // 03
|
||||
"INC B", // 04
|
||||
"DEC B", // 05
|
||||
"LD B,d8", // 06
|
||||
"RLCA", // 07
|
||||
"LD (a16),SP", // 08
|
||||
"ADD HL,BC", // 09
|
||||
"LD A,(BC)", // 0a
|
||||
"DEC BC", // 0b
|
||||
"INC C", // 0c
|
||||
"DEC C", // 0d
|
||||
"LD C,d8", // 0e
|
||||
"RRCA", // 0f
|
||||
"STOP 0", // 10
|
||||
"LD DE,d16", // 11
|
||||
"LD (DE),A", // 12
|
||||
"INC DE", // 13
|
||||
"INC D", // 14
|
||||
"DEC D", // 15
|
||||
"LD D,d8", // 16
|
||||
"RLA", // 17
|
||||
"JR r8", // 18
|
||||
"ADD HL,DE", // 19
|
||||
"LD A,(DE)", // 1a
|
||||
"DEC DE", // 1b
|
||||
"INC E", // 1c
|
||||
"DEC E", // 1d
|
||||
"LD E,d8", // 1e
|
||||
"RRA", // 1f
|
||||
"JR NZ,r8", // 20
|
||||
"LD HL,d16", // 21
|
||||
"LD (HL+),A", // 22
|
||||
"INC HL", // 23
|
||||
"INC H", // 24
|
||||
"DEC H", // 25
|
||||
"LD H,d8", // 26
|
||||
"DAA", // 27
|
||||
"JR Z,r8", // 28
|
||||
"ADD HL,HL", // 29
|
||||
"LD A,(HL+)", // 2a
|
||||
"DEC HL", // 2b
|
||||
"INC L", // 2c
|
||||
"DEC L", // 2d
|
||||
"LD L,d8", // 2e
|
||||
"CPL", // 2f
|
||||
"JR NC,r8", // 30
|
||||
"LD SP,d16", // 31
|
||||
"LD (HL-),A", // 32
|
||||
"INC SP", // 33
|
||||
"INC (HL)", // 34
|
||||
"DEC (HL)", // 35
|
||||
"LD (HL),d8", // 36
|
||||
"SCF", // 37
|
||||
"JR C,r8", // 38
|
||||
"ADD HL,SP", // 39
|
||||
"LD A,(HL-)", // 3a
|
||||
"DEC SP", // 3b
|
||||
"INC A", // 3c
|
||||
"DEC A", // 3d
|
||||
"LD A,d8", // 3e
|
||||
"CCF", // 3f
|
||||
"LD B,B", // 40
|
||||
"LD B,C", // 41
|
||||
"LD B,D", // 42
|
||||
"LD B,E", // 43
|
||||
"LD B,H", // 44
|
||||
"LD B,L", // 45
|
||||
"LD B,(HL)", // 46
|
||||
"LD B,A", // 47
|
||||
"LD C,B", // 48
|
||||
"LD C,C", // 49
|
||||
"LD C,D", // 4a
|
||||
"LD C,E", // 4b
|
||||
"LD C,H", // 4c
|
||||
"LD C,L", // 4d
|
||||
"LD C,(HL)", // 4e
|
||||
"LD C,A", // 4f
|
||||
"LD D,B", // 50
|
||||
"LD D,C", // 51
|
||||
"LD D,D", // 52
|
||||
"LD D,E", // 53
|
||||
"LD D,H", // 54
|
||||
"LD D,L", // 55
|
||||
"LD D,(HL)", // 56
|
||||
"LD D,A", // 57
|
||||
"LD E,B", // 58
|
||||
"LD E,C", // 59
|
||||
"LD E,D", // 5a
|
||||
"LD E,E", // 5b
|
||||
"LD E,H", // 5c
|
||||
"LD E,L", // 5d
|
||||
"LD E,(HL)", // 5e
|
||||
"LD E,A", // 5f
|
||||
"LD H,B", // 60
|
||||
"LD H,C", // 61
|
||||
"LD H,D", // 62
|
||||
"LD H,E", // 63
|
||||
"LD H,H", // 64
|
||||
"LD H,L", // 65
|
||||
"LD H,(HL)", // 66
|
||||
"LD H,A", // 67
|
||||
"LD L,B", // 68
|
||||
"LD L,C", // 69
|
||||
"LD L,D", // 6a
|
||||
"LD L,E", // 6b
|
||||
"LD L,H", // 6c
|
||||
"LD L,L", // 6d
|
||||
"LD L,(HL)", // 6e
|
||||
"LD L,A", // 6f
|
||||
"LD (HL),B", // 70
|
||||
"LD (HL),C", // 71
|
||||
"LD (HL),D", // 72
|
||||
"LD (HL),E", // 73
|
||||
"LD (HL),H", // 74
|
||||
"LD (HL),L", // 75
|
||||
"HALT", // 76
|
||||
"LD (HL),A", // 77
|
||||
"LD A,B", // 78
|
||||
"LD A,C", // 79
|
||||
"LD A,D", // 7a
|
||||
"LD A,E", // 7b
|
||||
"LD A,H", // 7c
|
||||
"LD A,L", // 7d
|
||||
"LD A,(HL)", // 7e
|
||||
"LD A,A", // 7f
|
||||
"ADD A,B", // 80
|
||||
"ADD A,C", // 81
|
||||
"ADD A,D", // 82
|
||||
"ADD A,E", // 83
|
||||
"ADD A,H", // 84
|
||||
"ADD A,L", // 85
|
||||
"ADD A,(HL)", // 86
|
||||
"ADD A,A", // 87
|
||||
"ADC A,B", // 88
|
||||
"ADC A,C", // 89
|
||||
"ADC A,D", // 8a
|
||||
"ADC A,E", // 8b
|
||||
"ADC A,H", // 8c
|
||||
"ADC A,L", // 8d
|
||||
"ADC A,(HL)", // 8e
|
||||
"ADC A,A", // 8f
|
||||
"SUB B", // 90
|
||||
"SUB C", // 91
|
||||
"SUB D", // 92
|
||||
"SUB E", // 93
|
||||
"SUB H", // 94
|
||||
"SUB L", // 95
|
||||
"SUB (HL)", // 96
|
||||
"SUB A", // 97
|
||||
"SBC A,B", // 98
|
||||
"SBC A,C", // 99
|
||||
"SBC A,D", // 9a
|
||||
"SBC A,E", // 9b
|
||||
"SBC A,H", // 9c
|
||||
"SBC A,L", // 9d
|
||||
"SBC A,(HL)", // 9e
|
||||
"SBC A,A", // 9f
|
||||
"AND B", // a0
|
||||
"AND C", // a1
|
||||
"AND D", // a2
|
||||
"AND E", // a3
|
||||
"AND H", // a4
|
||||
"AND L", // a5
|
||||
"AND (HL)", // a6
|
||||
"AND A", // a7
|
||||
"XOR B", // a8
|
||||
"XOR C", // a9
|
||||
"XOR D", // aa
|
||||
"XOR E", // ab
|
||||
"XOR H", // ac
|
||||
"XOR L", // ad
|
||||
"XOR (HL)", // ae
|
||||
"XOR A", // af
|
||||
"OR B", // b0
|
||||
"OR C", // b1
|
||||
"OR D", // b2
|
||||
"OR E", // b3
|
||||
"OR H", // b4
|
||||
"OR L", // b5
|
||||
"OR (HL)", // b6
|
||||
"OR A", // b7
|
||||
"CP B", // b8
|
||||
"CP C", // b9
|
||||
"CP D", // ba
|
||||
"CP E", // bb
|
||||
"CP H", // bc
|
||||
"CP L", // bd
|
||||
"CP (HL)", // be
|
||||
"CP A", // bf
|
||||
"RET NZ", // c0
|
||||
"POP BC", // c1
|
||||
"JP NZ,a16", // c2
|
||||
"JP a16", // c3
|
||||
"CALL NZ,a16", // c4
|
||||
"PUSH BC", // c5
|
||||
"ADD A,d8", // c6
|
||||
"RST 00H", // c7
|
||||
"RET Z", // c8
|
||||
"RET", // c9
|
||||
"JP Z,a16", // ca
|
||||
"PREFIX CB", // cb
|
||||
"CALL Z,a16", // cc
|
||||
"CALL a16", // cd
|
||||
"ADC A,d8", // ce
|
||||
"RST 08H", // cf
|
||||
"RET NC", // d0
|
||||
"POP DE", // d1
|
||||
"JP NC,a16", // d2
|
||||
"???", // d3
|
||||
"CALL NC,a16", // d4
|
||||
"PUSH DE", // d5
|
||||
"SUB d8", // d6
|
||||
"RST 10H", // d7
|
||||
"RET C", // d8
|
||||
"RETI", // d9
|
||||
"JP C,a16", // da
|
||||
"???", // db
|
||||
"CALL C,a16", // dc
|
||||
"???", // dd
|
||||
"SBC A,d8", // de
|
||||
"RST 18H", // df
|
||||
"LDH (a8),A", // e0
|
||||
"POP HL", // e1
|
||||
"LD (C),A", // e2
|
||||
"???", // e3
|
||||
"???", // e4
|
||||
"PUSH HL", // e5
|
||||
"AND d8", // e6
|
||||
"RST 20H", // e7
|
||||
"ADD SP,r8", // e8
|
||||
"JP (HL)", // e9
|
||||
"LD (a16),A", // ea
|
||||
"???", // eb
|
||||
"???", // ec
|
||||
"???", // ed
|
||||
"XOR d8", // ee
|
||||
"RST 28H", // ef
|
||||
"LDH A,(a8)", // f0
|
||||
"POP AF", // f1
|
||||
"LD A,(C)", // f2
|
||||
"DI", // f3
|
||||
"???", // f4
|
||||
"PUSH AF", // f5
|
||||
"OR d8", // f6
|
||||
"RST 30H", // f7
|
||||
"LD HL,SP+r8", // f8
|
||||
"LD SP,HL", // f9
|
||||
"LD A,(a16)", // fa
|
||||
"EI ", // fb
|
||||
"???", // fc
|
||||
"???", // fd
|
||||
"CP d8", // fe
|
||||
"RST 38H", // ff
|
||||
"RLC B", // 00
|
||||
"RLC C", // 01
|
||||
"RLC D", // 02
|
||||
"RLC E", // 03
|
||||
"RLC H", // 04
|
||||
"RLC L", // 05
|
||||
"RLC (HL)", // 06
|
||||
"RLC A", // 07
|
||||
"RRC B", // 08
|
||||
"RRC C", // 09
|
||||
"RRC D", // 0a
|
||||
"RRC E", // 0b
|
||||
"RRC H", // 0c
|
||||
"RRC L", // 0d
|
||||
"RRC (HL)", // 0e
|
||||
"RRC A", // 0f
|
||||
"RL B", // 10
|
||||
"RL C", // 11
|
||||
"RL D", // 12
|
||||
"RL E", // 13
|
||||
"RL H", // 14
|
||||
"RL L", // 15
|
||||
"RL (HL)", // 16
|
||||
"RL A", // 17
|
||||
"RR B", // 18
|
||||
"RR C", // 19
|
||||
"RR D", // 1a
|
||||
"RR E", // 1b
|
||||
"RR H", // 1c
|
||||
"RR L", // 1d
|
||||
"RR (HL)", // 1e
|
||||
"RR A", // 1f
|
||||
"SLA B", // 20
|
||||
"SLA C", // 21
|
||||
"SLA D", // 22
|
||||
"SLA E", // 23
|
||||
"SLA H", // 24
|
||||
"SLA L", // 25
|
||||
"SLA (HL)", // 26
|
||||
"SLA A", // 27
|
||||
"SRA B", // 28
|
||||
"SRA C", // 29
|
||||
"SRA D", // 2a
|
||||
"SRA E", // 2b
|
||||
"SRA H", // 2c
|
||||
"SRA L", // 2d
|
||||
"SRA (HL)", // 2e
|
||||
"SRA A", // 2f
|
||||
"SWAP B", // 30
|
||||
"SWAP C", // 31
|
||||
"SWAP D", // 32
|
||||
"SWAP E", // 33
|
||||
"SWAP H", // 34
|
||||
"SWAP L", // 35
|
||||
"SWAP (HL)", // 36
|
||||
"SWAP A", // 37
|
||||
"SRL B", // 38
|
||||
"SRL C", // 39
|
||||
"SRL D", // 3a
|
||||
"SRL E", // 3b
|
||||
"SRL H", // 3c
|
||||
"SRL L", // 3d
|
||||
"SRL (HL)", // 3e
|
||||
"SRL A", // 3f
|
||||
"BIT 0,B", // 40
|
||||
"BIT 0,C", // 41
|
||||
"BIT 0,D", // 42
|
||||
"BIT 0,E", // 43
|
||||
"BIT 0,H", // 44
|
||||
"BIT 0,L", // 45
|
||||
"BIT 0,(HL)", // 46
|
||||
"BIT 0,A", // 47
|
||||
"BIT 1,B", // 48
|
||||
"BIT 1,C", // 49
|
||||
"BIT 1,D", // 4a
|
||||
"BIT 1,E", // 4b
|
||||
"BIT 1,H", // 4c
|
||||
"BIT 1,L", // 4d
|
||||
"BIT 1,(HL)", // 4e
|
||||
"BIT 1,A", // 4f
|
||||
"BIT 2,B", // 50
|
||||
"BIT 2,C", // 51
|
||||
"BIT 2,D", // 52
|
||||
"BIT 2,E", // 53
|
||||
"BIT 2,H", // 54
|
||||
"BIT 2,L", // 55
|
||||
"BIT 2,(HL)", // 56
|
||||
"BIT 2,A", // 57
|
||||
"BIT 3,B", // 58
|
||||
"BIT 3,C", // 59
|
||||
"BIT 3,D", // 5a
|
||||
"BIT 3,E", // 5b
|
||||
"BIT 3,H", // 5c
|
||||
"BIT 3,L", // 5d
|
||||
"BIT 3,(HL)", // 5e
|
||||
"BIT 3,A", // 5f
|
||||
"BIT 4,B", // 60
|
||||
"BIT 4,C", // 61
|
||||
"BIT 4,D", // 62
|
||||
"BIT 4,E", // 63
|
||||
"BIT 4,H", // 64
|
||||
"BIT 4,L", // 65
|
||||
"BIT 4,(HL)", // 66
|
||||
"BIT 4,A", // 67
|
||||
"BIT 5,B", // 68
|
||||
"BIT 5,C", // 69
|
||||
"BIT 5,D", // 6a
|
||||
"BIT 5,E", // 6b
|
||||
"BIT 5,H", // 6c
|
||||
"BIT 5,L", // 6d
|
||||
"BIT 5,(HL)", // 6e
|
||||
"BIT 5,A", // 6f
|
||||
"BIT 6,B", // 70
|
||||
"BIT 6,C", // 71
|
||||
"BIT 6,D", // 72
|
||||
"BIT 6,E", // 73
|
||||
"BIT 6,H", // 74
|
||||
"BIT 6,L", // 75
|
||||
"BIT 6,(HL)", // 76
|
||||
"BIT 6,A", // 77
|
||||
"BIT 7,B", // 78
|
||||
"BIT 7,C", // 79
|
||||
"BIT 7,D", // 7a
|
||||
"BIT 7,E", // 7b
|
||||
"BIT 7,H", // 7c
|
||||
"BIT 7,L", // 7d
|
||||
"BIT 7,(HL)", // 7e
|
||||
"BIT 7,A", // 7f
|
||||
"RES 0,B", // 80
|
||||
"RES 0,C", // 81
|
||||
"RES 0,D", // 82
|
||||
"RES 0,E", // 83
|
||||
"RES 0,H", // 84
|
||||
"RES 0,L", // 85
|
||||
"RES 0,(HL)", // 86
|
||||
"RES 0,A", // 87
|
||||
"RES 1,B", // 88
|
||||
"RES 1,C", // 89
|
||||
"RES 1,D", // 8a
|
||||
"RES 1,E", // 8b
|
||||
"RES 1,H", // 8c
|
||||
"RES 1,L", // 8d
|
||||
"RES 1,(HL)", // 8e
|
||||
"RES 1,A", // 8f
|
||||
"RES 2,B", // 90
|
||||
"RES 2,C", // 91
|
||||
"RES 2,D", // 92
|
||||
"RES 2,E", // 93
|
||||
"RES 2,H", // 94
|
||||
"RES 2,L", // 95
|
||||
"RES 2,(HL)", // 96
|
||||
"RES 2,A", // 97
|
||||
"RES 3,B", // 98
|
||||
"RES 3,C", // 99
|
||||
"RES 3,D", // 9a
|
||||
"RES 3,E", // 9b
|
||||
"RES 3,H", // 9c
|
||||
"RES 3,L", // 9d
|
||||
"RES 3,(HL)", // 9e
|
||||
"RES 3,A", // 9f
|
||||
"RES 4,B", // a0
|
||||
"RES 4,C", // a1
|
||||
"RES 4,D", // a2
|
||||
"RES 4,E", // a3
|
||||
"RES 4,H", // a4
|
||||
"RES 4,L", // a5
|
||||
"RES 4,(HL)", // a6
|
||||
"RES 4,A", // a7
|
||||
"RES 5,B", // a8
|
||||
"RES 5,C", // a9
|
||||
"RES 5,D", // aa
|
||||
"RES 5,E", // ab
|
||||
"RES 5,H", // ac
|
||||
"RES 5,L", // ad
|
||||
"RES 5,(HL)", // ae
|
||||
"RES 5,A", // af
|
||||
"RES 6,B", // b0
|
||||
"RES 6,C", // b1
|
||||
"RES 6,D", // b2
|
||||
"RES 6,E", // b3
|
||||
"RES 6,H", // b4
|
||||
"RES 6,L", // b5
|
||||
"RES 6,(HL)", // b6
|
||||
"RES 6,A", // b7
|
||||
"RES 7,B", // b8
|
||||
"RES 7,C", // b9
|
||||
"RES 7,D", // ba
|
||||
"RES 7,E", // bb
|
||||
"RES 7,H", // bc
|
||||
"RES 7,L", // bd
|
||||
"RES 7,(HL)", // be
|
||||
"RES 7,A", // bf
|
||||
"SET 0,B", // c0
|
||||
"SET 0,C", // c1
|
||||
"SET 0,D", // c2
|
||||
"SET 0,E", // c3
|
||||
"SET 0,H", // c4
|
||||
"SET 0,L", // c5
|
||||
"SET 0,(HL)", // c6
|
||||
"SET 0,A", // c7
|
||||
"SET 1,B", // c8
|
||||
"SET 1,C", // c9
|
||||
"SET 1,D", // ca
|
||||
"SET 1,E", // cb
|
||||
"SET 1,H", // cc
|
||||
"SET 1,L", // cd
|
||||
"SET 1,(HL)", // ce
|
||||
"SET 1,A", // cf
|
||||
"SET 2,B", // d0
|
||||
"SET 2,C", // d1
|
||||
"SET 2,D", // d2
|
||||
"SET 2,E", // d3
|
||||
"SET 2,H", // d4
|
||||
"SET 2,L", // d5
|
||||
"SET 2,(HL)", // d6
|
||||
"SET 2,A", // d7
|
||||
"SET 3,B", // d8
|
||||
"SET 3,C", // d9
|
||||
"SET 3,D", // da
|
||||
"SET 3,E", // db
|
||||
"SET 3,H", // dc
|
||||
"SET 3,L", // dd
|
||||
"SET 3,(HL)", // de
|
||||
"SET 3,A", // df
|
||||
"SET 4,B", // e0
|
||||
"SET 4,C", // e1
|
||||
"SET 4,D", // e2
|
||||
"SET 4,E", // e3
|
||||
"SET 4,H", // e4
|
||||
"SET 4,L", // e5
|
||||
"SET 4,(HL)", // e6
|
||||
"SET 4,A", // e7
|
||||
"SET 5,B", // e8
|
||||
"SET 5,C", // e9
|
||||
"SET 5,D", // ea
|
||||
"SET 5,E", // eb
|
||||
"SET 5,H", // ec
|
||||
"SET 5,L", // ed
|
||||
"SET 5,(HL)", // ee
|
||||
"SET 5,A", // ef
|
||||
"SET 6,B", // f0
|
||||
"SET 6,C", // f1
|
||||
"SET 6,D", // f2
|
||||
"SET 6,E", // f3
|
||||
"SET 6,H", // f4
|
||||
"SET 6,L", // f5
|
||||
"SET 6,(HL)", // f6
|
||||
"SET 6,A", // f7
|
||||
"SET 7,B", // f8
|
||||
"SET 7,C", // f9
|
||||
"SET 7,D", // fa
|
||||
"SET 7,E", // fb
|
||||
"SET 7,H", // fc
|
||||
"SET 7,L", // fd
|
||||
"SET 7,(HL)", // fe
|
||||
"SET 7,A", // ff
|
||||
};
|
||||
|
||||
public static string Disassemble(ushort addr, Func<ushort, byte> reader, out ushort size)
|
||||
{
|
||||
ushort origaddr = addr;
|
||||
List<byte> bytes = new List<byte>();
|
||||
bytes.Add(reader(addr++));
|
||||
|
||||
string result = table[bytes[0]];
|
||||
if (bytes[0] == 0xcb)
|
||||
{
|
||||
bytes.Add(reader(addr++));
|
||||
result = table[bytes[1] + 256];
|
||||
}
|
||||
|
||||
if (result.Contains("d8"))
|
||||
{
|
||||
byte d = reader(addr++);
|
||||
bytes.Add(d);
|
||||
result = result.Replace("d8", string.Format("#{0:X2}h", d));
|
||||
}
|
||||
else if (result.Contains("d16"))
|
||||
{
|
||||
byte dlo = reader(addr++);
|
||||
byte dhi = reader(addr++);
|
||||
bytes.Add(dlo);
|
||||
bytes.Add(dhi);
|
||||
result = result.Replace("d16", string.Format("#{0:X2}{1:X2}h", dhi, dlo));
|
||||
}
|
||||
else if (result.Contains("a16"))
|
||||
{
|
||||
byte dlo = reader(addr++);
|
||||
byte dhi = reader(addr++);
|
||||
bytes.Add(dlo);
|
||||
bytes.Add(dhi);
|
||||
result = result.Replace("a16", string.Format("#{0:X2}{1:X2}h", dhi, dlo));
|
||||
}
|
||||
else if (result.Contains("a8"))
|
||||
{
|
||||
byte d = reader(addr++);
|
||||
bytes.Add(d);
|
||||
result = result.Replace("a8", string.Format("#FF{0:X2}h", d));
|
||||
}
|
||||
else if (result.Contains("r8"))
|
||||
{
|
||||
byte d = reader(addr++);
|
||||
bytes.Add(d);
|
||||
int offs = d;
|
||||
if (offs >= 128)
|
||||
offs -= 256;
|
||||
result = result.Replace("r8", string.Format("{0:X4}h", (ushort)(addr + offs)));
|
||||
}
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.Append(string.Format("{0:X4}: ", origaddr));
|
||||
foreach (var b in bytes)
|
||||
ret.Append(string.Format("{0:X2} ", b));
|
||||
while (ret.Length < 17)
|
||||
ret.Append(' ');
|
||||
ret.Append(result);
|
||||
size = (ushort)(addr - origaddr);
|
||||
return ret.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components.Z80GB
|
||||
{
|
||||
public partial class Z80
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
[Serializable]
|
||||
public struct RegisterPair
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public ushort Word;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public byte Low;
|
||||
|
||||
[FieldOffset(1)]
|
||||
public byte High;
|
||||
|
||||
public RegisterPair(ushort value)
|
||||
{
|
||||
Word = value;
|
||||
Low = (byte)(Word);
|
||||
High = (byte)(Word >> 8);
|
||||
}
|
||||
|
||||
public static implicit operator ushort(RegisterPair rp)
|
||||
{
|
||||
return rp.Word;
|
||||
}
|
||||
|
||||
public static implicit operator RegisterPair(ushort value)
|
||||
{
|
||||
return new RegisterPair(value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool FlagC
|
||||
{
|
||||
get { return (RegAF.Low & 0x10) != 0; }
|
||||
set { RegAF.Low = (byte)((RegAF.Low & ~0x10) | (value ? 0x10 : 0x00)); }
|
||||
}
|
||||
|
||||
public bool FlagH
|
||||
{
|
||||
get { return (RegAF.Low & 0x20) != 0; }
|
||||
set { RegAF.Low = (byte)((RegAF.Low & ~0x20) | (value ? 0x20 : 0x00)); }
|
||||
}
|
||||
|
||||
public bool FlagN
|
||||
{
|
||||
get { return (RegAF.Low & 0x40) != 0; }
|
||||
set { RegAF.Low = (byte)((RegAF.Low & ~0x40) | (value ? 0x40 : 0x00)); }
|
||||
}
|
||||
|
||||
public bool FlagZ
|
||||
{
|
||||
get { return (RegAF.Low & 0x80) != 0; }
|
||||
set { RegAF.Low = (byte)((RegAF.Low & ~0x80) | (value ? 0x80 : 0x00)); }
|
||||
}
|
||||
|
||||
private RegisterPair RegAF;
|
||||
private RegisterPair RegBC;
|
||||
private RegisterPair RegDE;
|
||||
private RegisterPair RegHL;
|
||||
|
||||
private byte RegI; // I (interrupt vector)
|
||||
|
||||
private RegisterPair RegSP; // SP (stack pointer)
|
||||
private RegisterPair RegPC; // PC (program counter)
|
||||
|
||||
private void ResetRegisters()
|
||||
{
|
||||
RegAF = 0; RegBC = 0; RegDE = 0; RegHL = 0;
|
||||
RegI = 0;
|
||||
RegSP.Word = 0; RegPC.Word = 0;
|
||||
}
|
||||
|
||||
public byte RegisterA
|
||||
{
|
||||
get { return RegAF.High; }
|
||||
set { RegAF.High = value; }
|
||||
}
|
||||
|
||||
public byte RegisterF
|
||||
{
|
||||
get { return RegAF.Low; }
|
||||
set { RegAF.Low = (byte)(value & 0xF0); }
|
||||
}
|
||||
|
||||
public ushort RegisterAF
|
||||
{
|
||||
get { return RegAF.Word; }
|
||||
set { RegAF.Word = (byte)(value & 0xFFF0); }
|
||||
}
|
||||
|
||||
public byte RegisterB
|
||||
{
|
||||
get { return RegBC.High; }
|
||||
set { RegBC.High = value; }
|
||||
}
|
||||
|
||||
public byte RegisterC
|
||||
{
|
||||
get { return RegBC.Low; }
|
||||
set { RegBC.Low = value; }
|
||||
}
|
||||
|
||||
public ushort RegisterBC
|
||||
{
|
||||
get { return RegBC.Word; }
|
||||
set { RegBC.Word = value; }
|
||||
}
|
||||
|
||||
public byte RegisterD
|
||||
{
|
||||
get { return RegDE.High; }
|
||||
set { RegDE.High = value; }
|
||||
}
|
||||
|
||||
public byte RegisterE
|
||||
{
|
||||
get { return RegDE.Low; }
|
||||
set { RegDE.Low = value; }
|
||||
}
|
||||
public ushort RegisterDE
|
||||
{
|
||||
get { return RegDE.Word; }
|
||||
set { RegDE.Word = value; }
|
||||
}
|
||||
|
||||
public byte RegisterH
|
||||
{
|
||||
get { return RegHL.High; }
|
||||
set { RegHL.High = value; }
|
||||
}
|
||||
|
||||
public byte RegisterL
|
||||
{
|
||||
get { return RegHL.Low; }
|
||||
set { RegHL.Low = value; }
|
||||
}
|
||||
public ushort RegisterHL
|
||||
{
|
||||
get { return RegHL.Word; }
|
||||
set { RegHL.Word = value; }
|
||||
}
|
||||
|
||||
public ushort RegisterPC
|
||||
{
|
||||
get { return RegPC.Word; }
|
||||
set { RegPC.Word = value; }
|
||||
}
|
||||
public ushort RegisterSP
|
||||
{
|
||||
get { return RegSP.Word; }
|
||||
set { RegSP.Word = value; }
|
||||
}
|
||||
public byte RegisterI
|
||||
{
|
||||
get { return RegI; }
|
||||
set { RegI = value; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
namespace BizHawk.Emulation.Common.Components.Z80GB
|
||||
{
|
||||
public partial class Z80
|
||||
{
|
||||
private void InitializeTables()
|
||||
{
|
||||
InitTableDaa();
|
||||
}
|
||||
|
||||
private static readonly byte[] IncTable =
|
||||
{
|
||||
160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
private static readonly byte[] DecTable =
|
||||
{
|
||||
192, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,
|
||||
064, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96
|
||||
};
|
||||
|
||||
private static readonly byte[] SwapTable =
|
||||
{
|
||||
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
|
||||
0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1,
|
||||
0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2,
|
||||
0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3,
|
||||
0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4,
|
||||
0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5,
|
||||
0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6,
|
||||
0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7,
|
||||
0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8,
|
||||
0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9,
|
||||
0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA,
|
||||
0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB,
|
||||
0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC,
|
||||
0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD,
|
||||
0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE,
|
||||
0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF
|
||||
};
|
||||
|
||||
private static readonly byte[] mCycleTable = new byte[]
|
||||
{
|
||||
1, 3, 2, 2, 1, 1, 2, 1, 5, 2, 2, 2, 1, 1, 2, 1,
|
||||
1, 3, 2, 2, 1, 1, 2, 1, 3, 2, 2, 2, 1, 1, 2, 1,
|
||||
3, 3, 2, 2, 1, 1, 2, 1, 3, 2, 2, 2, 1, 1, 2, 1,
|
||||
3, 3, 2, 2, 1, 3, 3, 3, 3, 2, 2, 2, 1, 1, 2, 1,
|
||||
1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,
|
||||
1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,
|
||||
1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,
|
||||
2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1,
|
||||
1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,
|
||||
1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,
|
||||
1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,
|
||||
1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1,
|
||||
5, 3, 4, 4, 6, 4, 2, 4, 5, 4, 4, 1, 6, 6, 2, 4,
|
||||
5, 3, 4, 0, 6, 4, 2, 4, 5, 4, 4, 0, 6, 0, 2, 4,
|
||||
3, 3, 2, 0, 0, 4, 2, 4, 4, 1, 4, 0, 0, 0, 2, 4,
|
||||
3, 3, 2, 1, 0, 4, 2, 4, 3, 2, 4, 1, 0, 0, 2, 4,
|
||||
};
|
||||
|
||||
private static readonly byte[] cbMCycleTable = new byte[]
|
||||
{
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,
|
||||
2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,
|
||||
2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,
|
||||
2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2,
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
};
|
||||
|
||||
private ushort[] TableDaa;
|
||||
private void InitTableDaa()
|
||||
{
|
||||
TableDaa = new ushort[65536];
|
||||
for (int af = 0; af < 65536; ++af)
|
||||
{
|
||||
byte a = (byte)(af >> 8);
|
||||
byte tmp = a;
|
||||
|
||||
if (IsN(af))
|
||||
{
|
||||
if (IsH(af) || ((a & 0x0F) > 0x09)) tmp -= 0x06;
|
||||
if (IsC(af) || a > 0x99) tmp -= 0x60;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsH(af) || ((a & 0x0F) > 0x09)) tmp += 0x06;
|
||||
if (IsC(af) || a > 0x99) tmp += 0x60;
|
||||
}
|
||||
|
||||
TableDaa[af] = (ushort)((tmp * 256) + FlagByte(IsC(af) || a > 0x99, ((a ^ tmp) & 0x10) != 0, IsN(af), tmp == 0));
|
||||
}
|
||||
}
|
||||
|
||||
private static byte FlagByte(bool C, bool H, bool N, bool Z)
|
||||
{
|
||||
return (byte)(
|
||||
(C ? 0x10 : 0) +
|
||||
(H ? 0x20 : 0) +
|
||||
(N ? 0x40 : 0) +
|
||||
(Z ? 0x80 : 0)
|
||||
);
|
||||
}
|
||||
|
||||
private static bool IsC(int value) { return (value & 0x10) != 0; }
|
||||
private static bool IsH(int value) { return (value & 0x20) != 0; }
|
||||
private static bool IsN(int value) { return (value & 0x40) != 0; }
|
||||
private static bool IsZ(int value) { return (value & 0x80) != 0; }
|
||||
}
|
||||
}
|
|
@ -1,171 +0,0 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
// This Z80-Gameboy emulator is a modified version of Ben Ryves 'Brazil' emulator.
|
||||
// It is MIT licensed (not public domain). (See Licenses)
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components.Z80GB
|
||||
{
|
||||
public sealed partial class Z80
|
||||
{
|
||||
private static bool logging = false;
|
||||
private static StreamWriter log;
|
||||
|
||||
static Z80()
|
||||
{
|
||||
if (logging)
|
||||
log = new StreamWriter("log_Z80.txt");
|
||||
}
|
||||
|
||||
public Z80()
|
||||
{
|
||||
InitializeTables();
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
ResetRegisters();
|
||||
ResetInterrupts();
|
||||
PendingCycles = 0;
|
||||
TotalExecutedCycles = 0;
|
||||
}
|
||||
|
||||
// Memory Access
|
||||
|
||||
public Func<ushort, byte> ReadMemory;
|
||||
public Action<ushort, byte> WriteMemory;
|
||||
|
||||
public void UnregisterMemoryMapper()
|
||||
{
|
||||
ReadMemory = null;
|
||||
WriteMemory = null;
|
||||
}
|
||||
|
||||
// State Save/Load
|
||||
|
||||
public void SaveStateText(TextWriter writer)
|
||||
{
|
||||
writer.WriteLine("[Z80]");
|
||||
writer.WriteLine("AF {0:X4}", RegAF.Word);
|
||||
writer.WriteLine("BC {0:X4}", RegBC.Word);
|
||||
writer.WriteLine("DE {0:X4}", RegDE.Word);
|
||||
writer.WriteLine("HL {0:X4}", RegHL.Word);
|
||||
writer.WriteLine("I {0:X2}", RegI);
|
||||
writer.WriteLine("SP {0:X4}", RegSP.Word);
|
||||
writer.WriteLine("PC {0:X4}", RegPC.Word);
|
||||
writer.WriteLine("IRQ {0}", interrupt);
|
||||
writer.WriteLine("NMI {0}", nonMaskableInterrupt);
|
||||
writer.WriteLine("NMIPending {0}", nonMaskableInterruptPending);
|
||||
writer.WriteLine("IM {0}", InterruptMode);
|
||||
writer.WriteLine("IFF1 {0}", IFF1);
|
||||
writer.WriteLine("IFF2 {0}", IFF2);
|
||||
writer.WriteLine("Halted {0}", Halted);
|
||||
writer.WriteLine("ExecutedCycles {0}", TotalExecutedCycles);
|
||||
writer.WriteLine("PendingCycles {0}", PendingCycles);
|
||||
writer.WriteLine("[/Z80]");
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public void LoadStateText(TextReader reader)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
string[] args = reader.ReadLine().Split(' ');
|
||||
if (args[0].Trim() == "") continue;
|
||||
if (args[0] == "[/Z80]") break;
|
||||
if (args[0] == "AF")
|
||||
RegAF.Word = ushort.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "BC")
|
||||
RegBC.Word = ushort.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "DE")
|
||||
RegDE.Word = ushort.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "HL")
|
||||
RegHL.Word = ushort.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "I")
|
||||
RegI = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "SP")
|
||||
RegSP.Word = ushort.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "PC")
|
||||
RegPC.Word = ushort.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "IRQ")
|
||||
interrupt = bool.Parse(args[1]);
|
||||
else if (args[0] == "NMI")
|
||||
nonMaskableInterrupt = bool.Parse(args[1]);
|
||||
else if (args[0] == "NMIPending")
|
||||
nonMaskableInterruptPending = bool.Parse(args[1]);
|
||||
else if (args[0] == "IM")
|
||||
InterruptMode = int.Parse(args[1]);
|
||||
else if (args[0] == "IFF1")
|
||||
IFF1 = bool.Parse(args[1]);
|
||||
else if (args[0] == "IFF2")
|
||||
IFF2 = bool.Parse(args[1]);
|
||||
else if (args[0] == "Halted")
|
||||
Halted = bool.Parse(args[1]);
|
||||
else if (args[0] == "ExecutedCycles")
|
||||
TotalExecutedCycles = int.Parse(args[1]);
|
||||
else if (args[0] == "PendingCycles")
|
||||
PendingCycles = int.Parse(args[1]);
|
||||
|
||||
else
|
||||
Console.WriteLine("Skipping unrecognized identifier " + args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(RegAF.Word);
|
||||
writer.Write(RegBC.Word);
|
||||
writer.Write(RegDE.Word);
|
||||
writer.Write(RegHL.Word);
|
||||
writer.Write(RegI);
|
||||
writer.Write(RegSP.Word);
|
||||
writer.Write(RegPC.Word);
|
||||
writer.Write(interrupt);
|
||||
writer.Write(nonMaskableInterrupt);
|
||||
writer.Write(nonMaskableInterruptPending);
|
||||
writer.Write(InterruptMode);
|
||||
writer.Write(IFF1);
|
||||
writer.Write(IFF2);
|
||||
writer.Write(Halted);
|
||||
writer.Write(TotalExecutedCycles);
|
||||
writer.Write(PendingCycles);
|
||||
}
|
||||
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
{
|
||||
RegAF.Word = reader.ReadUInt16();
|
||||
RegBC.Word = reader.ReadUInt16();
|
||||
RegDE.Word = reader.ReadUInt16();
|
||||
RegHL.Word = reader.ReadUInt16();
|
||||
RegI = reader.ReadByte();
|
||||
RegSP.Word = reader.ReadUInt16();
|
||||
RegPC.Word = reader.ReadUInt16();
|
||||
interrupt = reader.ReadBoolean();
|
||||
nonMaskableInterrupt = reader.ReadBoolean();
|
||||
nonMaskableInterruptPending = reader.ReadBoolean();
|
||||
InterruptMode = reader.ReadInt32();
|
||||
IFF1 = reader.ReadBoolean();
|
||||
IFF2 = reader.ReadBoolean();
|
||||
Halted = reader.ReadBoolean();
|
||||
TotalExecutedCycles = reader.ReadInt32();
|
||||
PendingCycles = reader.ReadInt32();
|
||||
}
|
||||
|
||||
public void LogData()
|
||||
{
|
||||
if (!logging)
|
||||
return;
|
||||
log.WriteLine("AF {0:X4}", RegAF.Word);
|
||||
log.WriteLine("BC {0:X4}", RegBC.Word);
|
||||
log.WriteLine("DE {0:X4}", RegDE.Word);
|
||||
log.WriteLine("HL {0:X4}", RegHL.Word);
|
||||
log.WriteLine("SP {0:X4}", RegSP.Word);
|
||||
log.WriteLine("PC {0:X4}", RegPC.Word);
|
||||
log.WriteLine("------");
|
||||
log.WriteLine();
|
||||
log.Flush();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue