Skip to content

Commit

Permalink
Starting to add RevU code and timer registers.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtremblay committed Dec 30, 2020
1 parent f62bf7d commit feb2695
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Main/Devices/SDCard/GabeSDController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class GabeSDController : SDCardDevice
{
private byte[] mbr = new byte[512];
private byte[] boot_sector = new byte[512];
private byte[] fat = new byte[512];
private readonly byte[] fat = new byte[512];
private byte[] readBlock, writeBlock = new byte[512];
private byte[] root = new byte[32 * 512]; // root dir is always 32 sectors, except FAT32, which omits it.
private int blockPtr = 0;
Expand Down
24 changes: 24 additions & 0 deletions Main/Devices/TimerRegister.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FoenixIDE.Simulator.Devices
{
public class TimerRegister : MemoryLocations.MemoryRAM
{
public TimerRegister(int StartAddress, int Length) : base(StartAddress, Length)
{
}

public override void WriteByte(int Address, byte Value)
{
// Address 0 is control register
if (Address == 0)
{

}
}
}
}
1 change: 1 addition & 0 deletions Main/FoenixIDE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<Compile Include="Devices\Interrupts.cs" />
<Compile Include="Devices\KeyboardRegister.cs" />
<Compile Include="Devices\MathFloatRegister.cs" />
<Compile Include="Devices\TimerRegister.cs" />
<Compile Include="Devices\SDCard\GabeSDController.cs" />
<Compile Include="Devices\VDMA.cs" />
<Compile Include="Devices\MPU401.cs" />
Expand Down
7 changes: 5 additions & 2 deletions Main/FoenixSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public FoenixSystem(Gpu gpu, BoardVersion version, string DefaultKernel)
int memSize = MemoryMap.RAM_SIZE;
CodecRAM codec = null;
SDCardDevice sdcard = null;
if (boardVersion == BoardVersion.RevC)
if (boardVersion == BoardVersion.RevC || boardVersion == BoardVersion.RevU)
{
memSize *= 2;
codec = new CodecRAM(MemoryMap.CODEC_WR_CTRL_FMX, 2); // This register is only a single byte but we allow writing a word
Expand Down Expand Up @@ -62,7 +62,10 @@ public FoenixSystem(Gpu gpu, BoardVersion version, string DefaultKernel)
OPL2 = new OPL2(MemoryMap.OPL2_S_BASE, 256),
FLOAT = new MathFloatRegister(MemoryMap.FLOAT_START, MemoryMap.FLOAT_END - MemoryMap.FLOAT_START + 1),
MPU401 = new MPU401(MemoryMap.MPU401_REGISTERS, 2),
VDMA = new VDMA(MemoryMap.VDMA_START, MemoryMap.VDMA_SIZE)
VDMA = new VDMA(MemoryMap.VDMA_START, MemoryMap.VDMA_SIZE),
TIMER0 = new TimerRegister(MemoryMap.TIMER0_CTRL_REG, 8),
TIMER1 = new TimerRegister(MemoryMap.TIMER1_CTRL_REG, 8),
TIMER2 = new TimerRegister(MemoryMap.TIMER2_CTRL_REG, 8)
};
MemMgr.CODEC = codec;
MemMgr.KEYBOARD.SetKernel(this);
Expand Down
23 changes: 22 additions & 1 deletion Main/MemoryLocations/MemoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class MemoryManager : IMappable
public OPL2 OPL2 = null;
public MPU401 MPU401 = null;
public VDMA VDMA = null;
public TimerRegister TIMER0 = null;
public TimerRegister TIMER1 = null;
public TimerRegister TIMER2 = null;

public bool VectorPull = false;

Expand Down Expand Up @@ -93,12 +96,30 @@ public void GetDeviceAt(int Address, out IMappable Device, out int DeviceAddress
DeviceAddress = Address - MATH.StartAddress;
return;
}
if (Address >= INTERRUPT.StartAddress && Address <= INTERRUPT.StartAddress + INTERRUPT.Length - 1)
if (Address >= INTERRUPT.StartAddress && Address <= INTERRUPT.EndAddress)
{
Device = INTERRUPT;
DeviceAddress = Address - INTERRUPT.StartAddress;
return;
}
if (Address >= TIMER0.StartAddress && Address <= TIMER0.EndAddress)
{
Device = TIMER0;
DeviceAddress = Address - TIMER0.StartAddress;
return;
}
if (Address >= TIMER1.StartAddress && Address <= TIMER1.EndAddress)
{
Device = TIMER1;
DeviceAddress = Address - TIMER1.StartAddress;
return;
}
if (Address >= TIMER2.StartAddress && Address <= TIMER2.EndAddress)
{
Device = TIMER2;
DeviceAddress = Address - TIMER2.StartAddress;
return;
}
if (Address >= RAM.StartAddress && Address <= RAM.StartAddress + RAM.Length - 1)
{
Device = RAM;
Expand Down
16 changes: 16 additions & 0 deletions Main/MemoryLocations/MemoryMap_Page00.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ public static partial class MemoryMap
public const int INT_MASK_REG2 = 0x00_014E;
public const int INT_MASK_REG3 = 0x00_014F; // FMX Model

public const int TIMER0_CTRL_REG = 0x00_0160;
public const int TIMER0_CHARGE = 0x00_0161;
public const int TIMER0_CMP_REG = 0x00_0164;
public const int TIMER0_CMP = 0x00_0165;

public const int TIMER1_CTRL_REG = 0x00_0168;
public const int TIMER1_CHARGE = 0x00_0169;
public const int TIMER1_CMP_REG = 0x00_016C;
public const int TIMER1_CMP = 0x00_016D;

public const int TIMER2_CTRL_REG = 0x00_0170;
public const int TIMER2_CHARGE = 0x00_0171;
public const int TIMER2_CMP_REG = 0x00_0174;
public const int TIMER2_CMP = 0x00_0175;


public const int VECTOR_STATE = 0x0001FF; // 1 Byte Interrupt Vector State. See VECTOR_STATE_ENUM

#endregion GAVIN
Expand Down
4 changes: 2 additions & 2 deletions Main/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.3.8")]
[assembly: AssemblyFileVersion("0.5.3.8")]
[assembly: AssemblyVersion("0.5.4.0")]
[assembly: AssemblyFileVersion("0.5.4.0")]
13 changes: 13 additions & 0 deletions Main/UI/CPUWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,19 @@ private bool InterruptMatchesCheckboxes()
{
return true;
}
if (TMR0Checkbox.Checked && (reg0 & (byte)Register0.FNX0_INT02_TMR0) != 0)
{
return true;
}

if (TMR1Checkbox.Checked && (reg0 & (byte)Register0.FNX0_INT03_TMR1) != 0)
{
return true;
}
if (TMR2Checkbox.Checked && (reg0 & (byte)Register0.FNX0_INT04_TMR2) != 0)
{
return true;
}
if (MouseCheckbox.Checked && (reg0 & (byte)Register0.FNX0_INT07_MOUSE) != 0)
{
return true;
Expand Down
2 changes: 1 addition & 1 deletion Main/UI/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions Main/UI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,14 @@ private void DisplayBoardVersion()
{
toolStripRevision.Text = "Rev B";
}
else
else if (version == BoardVersion.RevC)
{
toolStripRevision.Text = "Rev C";
}
else
{
toolStripRevision.Text = "Rev U";
}
// force repaint
statusStrip1.Invalidate();
}
Expand All @@ -856,6 +860,10 @@ private void ToolStripRevision_Click(object sender, EventArgs e)
{
version = BoardVersion.RevC;
}
else if (version == BoardVersion.RevC)
{
version = BoardVersion.RevU;
}
else
{
version = BoardVersion.RevB;
Expand Down Expand Up @@ -891,7 +899,7 @@ private void DipSwitch_Paint(object sender, PaintEventArgs e)
{
base.OnPaint(e);

if (version == BoardVersion.RevC)
if (version != BoardVersion.RevB)
{
int textOffset = 24;
ToolStripStatusLabel label = (ToolStripStatusLabel)sender;
Expand Down
9 changes: 6 additions & 3 deletions Main/UI/UploaderWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public void SetBoardVersion(BoardVersion ver)
case BoardVersion.RevC:
RevModeLabel.Text = "Mode: RevC";
break;
case BoardVersion.RevU:
RevModeLabel.Text = "Mode: RevU";
break;
}
}

Expand Down Expand Up @@ -231,10 +234,10 @@ private void SendBinaryButton_Click(object sender, EventArgs e)
UploadProgressBar.Value = 0;
UploadProgressBar.Visible = true;

int BaseBankAddress = 0x18_0000;
if (boardVersion == BoardVersion.RevC)
int BaseBankAddress = 0x38_0000;
if (boardVersion != BoardVersion.RevB)
{
BaseBankAddress = 0x38_0000;
BaseBankAddress = 0x18_0000;
}

if (SendFileRadio.Checked)
Expand Down

0 comments on commit feb2695

Please sign in to comment.