Skip to content

Commit

Permalink
Release 0.7.0.0
Browse files Browse the repository at this point in the history
---------------
Fixed bug in CPU for 65816 INC A when the B portion is non-zero.
F256K emulator now supports Math Co-pro functions.
F256K emulator now supports DMA functions.
The kernel can now be loaded with a bulk.csv file located in roms\F256 instead of a .hex file.  The binary files most be located there too.
Added the debug port command $90 and $91 for boot to RAM and FLASH, respectively.
Add machine CHIP version and sub-version.
Implemented Start of Line (SOL) register for F256.
Flash using multiple bin files, based on CSV master file.
When uploading PGZ, PGX and HEX for the F256, execute the program on machine.
Added rectype 5 to HexFile.load to set the start address - this is used by the Calypsi compiler.
  • Loading branch information
Daniel Tremblay committed Jan 2, 2024
1 parent 794aa70 commit 104aeec
Show file tree
Hide file tree
Showing 24 changed files with 1,193 additions and 4,602 deletions.
491 changes: 485 additions & 6 deletions FoenixIDESetup/FoenixIDESetup.vdproj

Large diffs are not rendered by default.

106 changes: 106 additions & 0 deletions Main/Devices/DMA_JR.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FoenixIDE.Simulator.Devices
{
public class DMA_JR : MemoryLocations.MemoryRAM
{
private MemoryLocations.MemoryRAM System;

public DMA_JR(int StartAddress, int Length) : base(StartAddress, Length)
{
}

public void setSystemRam(MemoryLocations.MemoryRAM ram)
{
System = ram;
}

public override void WriteByte(int Address, byte Value)
{
data[Address] = Value;
// The only address that matters is the register
// If the Enable and Transfer bits are set then do the transfer
if ((Address == 0) && (Value & 0x81) == 0x81)
{
// Read the Fill Byte
bool isFillTransfer = (Value & 4) != 0;
byte fillByte = 0;
if (isFillTransfer)
{
fillByte = ReadByte(1);
}
// Indicate that DMA is busy
data[1] = 0x80;
int srcAddr = ReadLong(4);
int destAddr = ReadLong(8);

bool is2DTransfer = (Value & 2) != 0;
int size1DTransfer = ReadLong(0xC);

// Setup variables
int width2DTransfer = ReadWord(0xC);
int height2DTransfer = ReadWord(0xE);
int srcStride = ReadWord(0x10);
int destStride = ReadWord(0x12);

if (isFillTransfer)
{
if (is2DTransfer)
{
// Copy the fillbyte in the rectangle
for (int y = 0; y < height2DTransfer; y++)
{
for (int x = 0; x < width2DTransfer; x++)
{
System.WriteByte(destAddr + x + y * destStride, fillByte);
}
}
}
else
{
// This is the easiest use case. Just fill the same byte in to destination
for (int i = 0; i < size1DTransfer; i++)
{
System.WriteByte(destAddr + i, fillByte);
}
}
}
else
{
if (is2DTransfer)
{
for (int y = 0; y < height2DTransfer; y++)
{
for (int x = 0; x < width2DTransfer; x++)
{
byte srcByte = System.ReadByte(srcAddr + x + y * srcStride);
System.WriteByte(destAddr + x + y * destStride, srcByte);
}
}
}
else
{
// Copy the memory from source to destination
byte[] buffer = new byte[size1DTransfer];
System.CopyIntoBuffer(srcAddr, size1DTransfer, buffer);
System.CopyBuffer(buffer, 0, destAddr, size1DTransfer);
}
}

// Set the status to not busy
data[1] = 0;

// Raise an interrupt
if ((Value & 8) == 8)
{

}
}
}
}
}
76 changes: 76 additions & 0 deletions Main/Devices/SOL.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FoenixIDE.Simulator.Devices
{

/**
* The SOL Register in F256 allows for
* - writing values for LINT_CTRL and LINT_L
* - reading values for RAST_COL and RAST_ROW
*
*/
public class SOL : MemoryLocations.MemoryRAM
{
bool lineInterrupt = false;
int lineNumber = 0; // 12 bit value for the line number to raise the interrupt on

int rasterColum = 0;
int rasterRow = 0;

public SOL(int StartAddress, int Length) : base(StartAddress, Length)
{
}

public override byte ReadByte(int Address)
{
switch (Address)
{
case 0:
return (byte)(rasterColum & 0xFF);
case 1:
return (byte)(rasterColum >> 8);
case 2:
return (byte)(rasterRow & 0xFF);
case 3:
return (byte)(rasterRow >> 8);
}
return 0;
}
public override void WriteByte(int Address, byte Value)
{
switch (Address)
{
case 0:
lineInterrupt = (Value & 1) > 0;
break;
case 1:
lineNumber |= Value;
break;
case 2:
lineNumber |= (Value << 8);
break;
}
}

// This method is called from the GPU class while drawing.
public void SetRasterRow(int value)
{
rasterRow = value;
}

public bool IsInterruptEnabled()
{
return lineInterrupt;
}

public int GetSOLLineNumber()
{
return lineNumber;
}

}
}
35 changes: 25 additions & 10 deletions Main/Display/Gpu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Drawing.Imaging;
using FoenixIDE.MemoryLocations;
using KGySoft.CoreLibraries;
using FoenixIDE.Simulator.Devices;

namespace FoenixIDE.Display
{
Expand All @@ -20,6 +21,7 @@ public unsafe partial class Gpu : UserControl

public MemoryRAM VRAM = null;
public MemoryRAM VICKY = null;
public SOL F256SOLReg = null;
public int paintCycle = 0;
private bool tileEditorMode = false;

Expand Down Expand Up @@ -280,24 +282,37 @@ unsafe void Gpu_Paint(object sender, PaintEventArgs e)
for (int line = 0; line < res.Y; line++)
{
// Handle SOL interrupts
byte SOLRegister = VICKY.ReadByte(SOLRegAddr);
if ((SOLRegister & 1) != 0)
if (mode == 0)
{
int SOLLine0 = VICKY.ReadWord(SOLLine0Addr);
if (line == SOLLine0)
byte SOLRegister = VICKY.ReadByte(SOLRegAddr);
if ((SOLRegister & 1) != 0)
{
StartOfLine?.Invoke();
int SOLLine0 = VICKY.ReadWord(SOLLine0Addr);
if (line == SOLLine0)
{
StartOfLine?.Invoke();
}
}
if ((SOLRegister & 2) != 0)
{
int SOLLine1 = VICKY.ReadWord(SOLLine1Addr);
if (line == SOLLine1)
{
StartOfLine?.Invoke();
}
}
}
if ((SOLRegister & 2) != 0)
else
{
int SOLLine1 = VICKY.ReadWord(SOLLine1Addr);
if (line == SOLLine1)
F256SOLReg.SetRasterRow(line);
if (F256SOLReg.IsInterruptEnabled())
{
StartOfLine?.Invoke();
if (line == F256SOLReg.GetSOLLineNumber())
{
StartOfLine?.Invoke();
}
}
}

bool gammaCorrection = (MCRegister & 0x40) == 0x40;

// Default background color to border color
Expand Down
9 changes: 7 additions & 2 deletions Main/FileFormat/HexFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,14 @@ static public bool Load(MemoryRAM ram, FlashJr romJr, string Filename, int gabeA
bank = GetByte(data, 0, 2) << 16;
break;

// extended linear start address
// set the initial bank register value. Not used in the simulator.
// set the start address
case "05":
startAddress = GetByte(data, 0, 4);
// If running on a F256, set the start address
if (romJr != null)
{
ram.WriteWord(0xFFFC, startAddress);
}
break;

default:
Expand Down
36 changes: 17 additions & 19 deletions Main/FoenixIDE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<Compile Include="Devices\Interrupts.cs" />
<Compile Include="Devices\MathCoproRegister_JR.cs" />
<Compile Include="Devices\MatrixKeyboardRegister.cs" />
<Compile Include="Devices\SOL.cs" />
<Compile Include="Devices\PS2KeyboardRegister.cs" />
<Compile Include="Devices\MathFloatRegister.cs" />
<Compile Include="Devices\RNGRegister.cs" />
Expand All @@ -98,6 +99,7 @@
<Compile Include="Devices\SDCard\FakeFATSDCardDevice.cs" />
<Compile Include="Devices\TimerRegister.cs" />
<Compile Include="Devices\SDCard\GabeSDController.cs" />
<Compile Include="Devices\DMA_JR.cs" />
<Compile Include="Devices\VDMA.cs" />
<Compile Include="Devices\MPU401.cs" />
<Compile Include="Devices\OPL2.cs" />
Expand Down Expand Up @@ -150,11 +152,11 @@
<Compile Include="UI\AccumulatorControl.Designer.cs">
<DependentUpon>AccumulatorControl.cs</DependentUpon>
</Compile>
<Compile Include="UI\AssetWindow.cs">
<Compile Include="UI\AssetDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\AssetWindow.Designer.cs">
<DependentUpon>AssetWindow.cs</DependentUpon>
<Compile Include="UI\AssetDialog.Designer.cs">
<DependentUpon>AssetDialog.cs</DependentUpon>
</Compile>
<Compile Include="UI\BreakpointWindow.cs">
<SubType>Form</SubType>
Expand Down Expand Up @@ -204,11 +206,11 @@
<Compile Include="UI\MidiVGMForm.Designer.cs">
<DependentUpon>MidiVGMForm.cs</DependentUpon>
</Compile>
<Compile Include="UI\SDCardWindow.cs">
<Compile Include="UI\SDCardDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\SDCardWindow.Designer.cs">
<DependentUpon>SDCardWindow.cs</DependentUpon>
<Compile Include="UI\SDCardDialog.Designer.cs">
<DependentUpon>SDCardDialog.cs</DependentUpon>
</Compile>
<Compile Include="UI\MainWindow.cs">
<SubType>Form</SubType>
Expand Down Expand Up @@ -261,11 +263,11 @@
<Compile Include="UI\TileEditor.Designer.cs">
<DependentUpon>TileEditor.cs</DependentUpon>
</Compile>
<Compile Include="UI\UploaderWindow.cs">
<Compile Include="UI\UploaderDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\UploaderWindow.Designer.cs">
<DependentUpon>UploaderWindow.cs</DependentUpon>
<Compile Include="UI\UploaderDialog.Designer.cs">
<DependentUpon>UploaderDialog.cs</DependentUpon>
</Compile>
<Compile Include="UI\CharEditor\ViewControl.cs">
<SubType>UserControl</SubType>
Expand All @@ -282,7 +284,6 @@
<Content Include="roms\kernel_B.lst">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="roms\kernel_F256jr.lst" />
<Content Include="roms\kernel_FMX.lst">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand All @@ -295,8 +296,8 @@
<EmbeddedResource Include="UI\AccumulatorControl.resx">
<DependentUpon>AccumulatorControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\AssetWindow.resx">
<DependentUpon>AssetWindow.cs</DependentUpon>
<EmbeddedResource Include="UI\AssetDialog.resx">
<DependentUpon>AssetDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\BreakpointWindow.resx">
<DependentUpon>BreakpointWindow.cs</DependentUpon>
Expand Down Expand Up @@ -347,17 +348,17 @@
<EmbeddedResource Include="UI\AssetLoader.resx">
<DependentUpon>AssetLoader.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\SDCardWindow.resx">
<DependentUpon>SDCardWindow.cs</DependentUpon>
<EmbeddedResource Include="UI\SDCardDialog.resx">
<DependentUpon>SDCardDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\SerialTerminal.resx">
<DependentUpon>SerialTerminal.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\TileEditor.resx">
<DependentUpon>TileEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\UploaderWindow.resx">
<DependentUpon>UploaderWindow.cs</DependentUpon>
<EmbeddedResource Include="UI\UploaderDialog.resx">
<DependentUpon>UploaderDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\CharEditor\ViewControl.resx">
<DependentUpon>ViewControl.cs</DependentUpon>
Expand Down Expand Up @@ -462,9 +463,6 @@
<None Include="roms\kernel_B.hex">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="roms\kernel_F256jr.hex">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="roms\kernel_FMX.hex">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Loading

0 comments on commit 104aeec

Please sign in to comment.