Genesis core revive! Get it back to where loading a genesis rom doesnt crash everything immediately

This commit is contained in:
beirich 2011-10-01 17:06:25 +00:00
parent 2418947b69
commit 8fb8a35317
9 changed files with 84 additions and 60 deletions

View File

@ -123,7 +123,7 @@ namespace BizHawk.Emulation.CPUs.M68K
PendingCycles += cycles;
while (PendingCycles > 0)
{
Console.WriteLine(Disassemble(PC));
//Console.WriteLine(Disassemble(PC));
op = (ushort)ReadWord(PC);
PC += 2;
Opcodes[op]();

View File

@ -22,9 +22,9 @@ namespace BizHawk.Emulation.Consoles.Sega
}
private bool DmaFillModePending;
bool DmaFillModePending;
private void ExecuteDmaFill(ushort data)
void ExecuteDmaFill(ushort data)
{
Console.WriteLine("DMA FILL REQD, WRITE {0:X4}, {1:X4} times, at {2:X4}", data, DmaLength, VdpDataAddr);
@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Consoles.Sega
DmaFillModePending = false;
}
private void Execute68000VramCopy()
void Execute68000VramCopy()
{
Console.WriteLine("DMA 68000 -> VRAM COPY REQ'D. LENGTH {0:X4}, SOURCE {1:X4}", DmaLength, DmaSource);

View File

@ -19,21 +19,21 @@ namespace BizHawk.Emulation.Consoles.Sega
}
}
private void RenderPalette()
void RenderPalette()
{
for (int p = 0; p < 4; p++)
for (int i = 0; i < 16; i++)
FrameBuffer[(p*FrameWidth) + i] = Palette[(p*16) + i];
}
private void RenderPatterns()
void RenderPatterns()
{
for (int yi=0; yi<28; yi++)
for (int xi=0; xi<(Display40Mode?40:32); xi++)
RenderPattern(xi * 8, yi * 8, (yi * (Display40Mode ? 40 : 32)) + xi, 0);
}
private void RenderPattern(int x, int y, int pattern, int palette)
void RenderPattern(int x, int y, int pattern, int palette)
{
for (int yi = 0; yi < 8; yi++)
{
@ -46,7 +46,7 @@ namespace BizHawk.Emulation.Consoles.Sega
}
}
private void RenderScrollA()
void RenderScrollA()
{
for (int yc=0; yc<24; yc++)
{
@ -61,7 +61,7 @@ namespace BizHawk.Emulation.Consoles.Sega
}
}
private void RenderScrollB()
void RenderScrollB()
{
for (int yc = 0; yc < 24; yc++)
{
@ -77,14 +77,14 @@ namespace BizHawk.Emulation.Consoles.Sega
}
private void RenderSprites()
void RenderSprites()
{
Sprite sprite = FetchSprite(0);
/*if (sprite.X > 0)
Console.WriteLine("doot");*/
}
private Sprite FetchSprite(int spriteNo)
Sprite FetchSprite(int spriteNo)
{
int satbase = SpriteAttributeTableAddr + (spriteNo*8);
Sprite sprite = new Sprite();
@ -108,6 +108,4 @@ namespace BizHawk.Emulation.Consoles.Sega
public int PatternIndex;
}
}
}

View File

@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Consoles.Sega
public void WriteVdpControl(ushort data)
{
Console.WriteLine("[PC = {0:X6}] VDP: Control Write {1:X4}", /*Genesis._MainCPU.PC*/0, data);
//Console.WriteLine("[PC = {0:X6}] VDP: Control Write {1:X4}", /*Genesis._MainCPU.PC*/0, data);
if (ControlWordPending == false)
{
@ -49,15 +49,15 @@ namespace BizHawk.Emulation.Consoles.Sega
int reg = (data >> 8) & 0x1F;
byte value = (byte) (data & 0xFF);
WriteVdpRegister(reg, value);
VdpDataCode = 0; // should we just clone GenesisPlus behavior?
VdpDataCode = 0;
} else {
ControlWordPending = true;
VdpDataAddr &= 0xC000;
VdpDataAddr |= (ushort) (data & 0x3FFF);
VdpDataCode &= 0x3C;
VdpDataCode |= (byte) (data >> 14);
Console.WriteLine("Address = {0:X4}", VdpDataAddr);
Console.WriteLine("Code = {0:X2}", VdpDataCode);
//Console.WriteLine("Address = {0:X4}", VdpDataAddr);
//Console.WriteLine("Code = {0:X2}", VdpDataCode);
}
} else {
ControlWordPending = false;
@ -65,14 +65,14 @@ namespace BizHawk.Emulation.Consoles.Sega
// Update data address and code
VdpDataAddr &= 0x3FFF;
VdpDataAddr |= (ushort) ((data & 0x03) << 14);
Console.WriteLine("Address = {0:X4}", VdpDataAddr);
//Console.WriteLine("Address = {0:X4}", VdpDataAddr);
VdpDataCode &= 0x03;
VdpDataCode |= (byte) ((data >> 2) & 0x3C);
Console.WriteLine("Code = {0:X2}", VdpDataCode);
//Console.WriteLine("Code = {0:X2}", VdpDataCode);
if ((VdpDataCode & 0x20) != 0 && DmaEnabled) // DMA triggered
{
Console.WriteLine("DMA TIME!");
//Console.WriteLine("DMA TIME!");
// what type of DMA?
switch (Registers[23] >> 6)
@ -96,7 +96,7 @@ namespace BizHawk.Emulation.Consoles.Sega
public ushort ReadVdpControl()
{
Console.WriteLine("VDP: Control Read");
//Console.WriteLine("VDP: Control Read");
ushort value = 0;
value |= 0x8000; // Fifo empty
return value;
@ -122,18 +122,18 @@ namespace BizHawk.Emulation.Consoles.Sega
VRAM[(VdpDataAddr & 0xFFFE) + 1] = (byte) (data >> 8);
UpdatePatternBuffer(VdpDataAddr & 0xFFFE);
UpdatePatternBuffer((VdpDataAddr & 0xFFFE) + 1);
Console.WriteLine("Wrote VRAM[{0:X4}] = {1:X4}", VdpDataAddr, data);
//Console.WriteLine("Wrote VRAM[{0:X4}] = {1:X4}", VdpDataAddr, data);
VdpDataAddr += Registers[0x0F];
break;
case 3: // CRAM write
CRAM[(VdpDataAddr / 2) % 64] = data;
Console.WriteLine("Wrote CRAM[{0:X2}] = {1:X4}", (VdpDataAddr / 2) % 64, data);
//Console.WriteLine("Wrote CRAM[{0:X2}] = {1:X4}", (VdpDataAddr / 2) % 64, data);
ProcessPalette((VdpDataAddr/2)%64);
VdpDataAddr += Registers[0x0F];
break;
case 5: // VSRAM write
VSRAM[(VdpDataAddr / 2) % 40] = data;
Console.WriteLine("Wrote VSRAM[{0:X2}] = {1:X4}", (VdpDataAddr / 2) % 40, data);
//Console.WriteLine("Wrote VSRAM[{0:X2}] = {1:X4}", (VdpDataAddr / 2) % 40, data);
VdpDataAddr += Registers[0x0F];
break;
default:
@ -144,13 +144,13 @@ namespace BizHawk.Emulation.Consoles.Sega
public ushort ReadVdpData()
{
Console.WriteLine("VDP: Data Read");
//Console.WriteLine("VDP: Data Read");
return 0;
}
public void WriteVdpRegister(int register, byte data)
{
Console.WriteLine("Register {0}: {1:X2}", register, data);
//Console.WriteLine("Register {0}: {1:X2}", register, data);
switch (register)
{
case 0x00:

View File

@ -53,7 +53,7 @@ namespace BizHawk.Emulation.Consoles.Sega
// 320 are active display, the remaining 160 are horizontal blanking.
// A total of 3420 mclks per line, but 2560 mclks are active display and 860 mclks are blanking.
public Genesis()
public Genesis(GameInfo game, byte[] rom)
{
CoreOutputComm = new CoreOutputComm();
MainCPU = new M68000();
@ -77,20 +77,13 @@ namespace BizHawk.Emulation.Consoles.Sega
SoundCPU.ReadHardware = x => 0xFF;
SoundCPU.IRQCallback = () => SoundCPU.Interrupt = false;
Z80Reset = true;
RomData = new byte[0x400000];
for (int i = 0; i < rom.Length; i++)
RomData[i] = rom[i];
MainCPU.Reset();
}
/* TOO BAD genesis is broken until I finish turbocd
public void LoadGame(IGame game)
{
RomData = new byte[0x400000];
byte[] rom = game.GetRomData();
for (int i = 0; i < rom.Length; i++)
RomData[i] = rom[i];
if (MainCPU != null) MainCPU.Reset();
_MainCPU.Reset();
}*/
public void FrameAdvance(bool render)
{
Frame++;

View File

@ -146,7 +146,7 @@ namespace BizHawk.Emulation.Consoles.Sega
if (address >= 0xE00000) // Work RAM
{
Console.WriteLine("MEM[{0:X4}] change to {1:X4}", address & 0xFFFF, value);
//Console.WriteLine("MEM[{0:X4}] change to {1:X4}", address & 0xFFFF, value);
Ram[(address & 0xFFFF) + 0] = (byte)(value >> 8);
Ram[(address & 0xFFFF) + 1] = (byte)value;
return;
@ -188,7 +188,7 @@ namespace BizHawk.Emulation.Consoles.Sega
if (address >= 0xE00000) // Work RAM
{
Console.WriteLine("MEM[{0:X4}] change to {1:X8}", address & 0xFFFF, value);
//Console.WriteLine("MEM[{0:X4}] change to {1:X8}", address & 0xFFFF, value);
Ram[(address & 0xFFFF) + 0] = (byte)(value >> 24);
Ram[(address & 0xFFFF) + 1] = (byte)(value >> 16);
Ram[(address & 0xFFFF) + 2] = (byte)(value >> 8);

View File

@ -10,7 +10,7 @@
public void Write(int addr, byte value)
{
System.Console.WriteLine("YM2612: {0:X2} -> {1:X2}", addr, value);
}
public void Reset()

View File

@ -442,14 +442,8 @@
public PCEControllerTemplate[] PCEAutoController = new PCEControllerTemplate[5];
// Genesis Settings
public string GenP1Up = "UpArrow, J1 Up";
public string GenP1Down = "DownArrow, J1 Down";
public string GenP1Left = "LeftArrow, J1 Left";
public string GenP1Right = "RightArrow, J1 Right";
public string GenP1A = "Z, J1 B1";
public string GenP1B = "X, J1 B3";
public string GenP1C = "C, J1 B4";
public string GenP1Start = "Return, J1 B8";
public GenControllerTemplate GenesisController = new GenControllerTemplate(true);
public GenControllerTemplate GenesisAutoController = new GenControllerTemplate();
//GameBoy Settings
public NESControllerTemplate GameBoyController = new NESControllerTemplate(true);
@ -626,6 +620,34 @@
}
}
public class GenControllerTemplate
{
public string Up = "";
public string Down = "";
public string Left = "";
public string Right = "";
public string A = "";
public string B = "";
public string C = "";
public string Start = "";
public GenControllerTemplate() { }
public GenControllerTemplate(bool defaults)
{
if (defaults)
{
Up = "UpArrow, J1 Up";
Down = "DownArrow, J1 Down";
Left = "LeftArrow, J1 Left";
Right = "RightArrow, J1 Right";
A = "Z, J1 B1";
B = "X, J1 B3";
C = "C, J1 B4";
Start = "Return, J1 B8";
}
}
}
public class TI83ControllerTemplate
{
public string _0;

View File

@ -633,18 +633,29 @@ namespace BizHawk.MultiClient
agbControls.BindMulti("Start", Global.Config.GBAutoController.Start);
Global.AutofireGBControls = agbControls;
var genControls = new Controller(Genesis.GenesisController);
genControls.BindMulti("P1 Up", Global.Config.GenP1Up);
genControls.BindMulti("P1 Left", Global.Config.GenP1Left);
genControls.BindMulti("P1 Right", Global.Config.GenP1Right);
genControls.BindMulti("P1 Down", Global.Config.GenP1Down);
genControls.BindMulti("P1 A", Global.Config.GenP1A);
genControls.BindMulti("P1 B", Global.Config.GenP1B);
genControls.BindMulti("P1 C", Global.Config.GenP1C);
genControls.BindMulti("P1 Start", Global.Config.GenP1Start);
genControls.BindMulti("P1 Up", Global.Config.GenesisController.Up);
genControls.BindMulti("P1 Left", Global.Config.GenesisController.Left);
genControls.BindMulti("P1 Right", Global.Config.GenesisController.Right);
genControls.BindMulti("P1 Down", Global.Config.GenesisController.Down);
genControls.BindMulti("P1 A", Global.Config.GenesisController.A);
genControls.BindMulti("P1 B", Global.Config.GenesisController.B);
genControls.BindMulti("P1 C", Global.Config.GenesisController.C);
genControls.BindMulti("P1 Start", Global.Config.GenesisController.Start);
Global.GenControls = genControls;
var agenControls = new AutofireController(Genesis.GenesisController);
agbControls.Autofire = true;
genControls.BindMulti("P1 Up", Global.Config.GenesisAutoController.Up);
genControls.BindMulti("P1 Left", Global.Config.GenesisAutoController.Left);
genControls.BindMulti("P1 Right", Global.Config.GenesisAutoController.Right);
genControls.BindMulti("P1 Down", Global.Config.GenesisAutoController.Down);
genControls.BindMulti("P1 A", Global.Config.GenesisAutoController.A);
genControls.BindMulti("P1 B", Global.Config.GenesisAutoController.B);
genControls.BindMulti("P1 C", Global.Config.GenesisAutoController.C);
genControls.BindMulti("P1 Start", Global.Config.GenesisAutoController.Start);
Global.AutofireGenControls = agenControls;
var TI83Controls = new Controller(TI83.TI83Controller);
TI83Controls.BindMulti("0", Global.Config.TI83Controller[0]._0);
TI83Controls.BindMulti("1", Global.Config.TI83Controller[0]._1);
@ -1044,7 +1055,7 @@ namespace BizHawk.MultiClient
nextEmulator = new PCEngine(game, rom.RomData);
break;
case "GEN":
nextEmulator = new Genesis(); //TODO
nextEmulator = new Genesis(game, rom.RomData);
break;
case "TI83":
nextEmulator = new TI83(game, rom.RomData);