Skip to content

Commit

Permalink
Release 0.6.0.1
Browse files Browse the repository at this point in the history
---------------
Implemented tiles for F256Jr.
Fixed the issue when resetting the CPU, also reset the MMU and VICKY Layer Manager Registers.
Fixed RTC issue in F256Jr where the time was written in RAM.
  • Loading branch information
Daniel Tremblay committed Oct 25, 2022
1 parent 63d6ffa commit af38f95
Show file tree
Hide file tree
Showing 10 changed files with 331 additions and 76 deletions.
56 changes: 54 additions & 2 deletions FoenixIDESetup/FoenixIDESetup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
}
"Entry"
{
"MsmKey" = "8:_7BD2B3A7DD6E4E0E81969BEC234D508C"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_81547FC2AD874EF680C5282428D55CD4"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -243,6 +249,12 @@
}
"Entry"
{
"MsmKey" = "8:_F1A01B2DDF0E458FB4CC621697DB5ED5"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_F5E33CFE52604F89ADF26B5E264648BA"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -762,6 +774,26 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_7BD2B3A7DD6E4E0E81969BEC234D508C"
{
"SourcePath" = "8:..\\Main\\roms\\kernel_F256jr.lst"
"TargetName" = "8:kernel_F256jr.lst"
"Tag" = "8:"
"Folder" = "8:_046CAC32C99040D4B711E42EEBA2C9FA"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_81547FC2AD874EF680C5282428D55CD4"
{
"SourcePath" = "8:..\\Main\\roms\\kernel_FMX.lst"
Expand Down Expand Up @@ -1133,6 +1165,26 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F1A01B2DDF0E458FB4CC621697DB5ED5"
{
"SourcePath" = "8:..\\Main\\roms\\kernel_F256jr.hex"
"TargetName" = "8:kernel_F256jr.hex"
"Tag" = "8:"
"Folder" = "8:_046CAC32C99040D4B711E42EEBA2C9FA"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F5E33CFE52604F89ADF26B5E264648BA"
{
"SourcePath" = "8:..\\Main\\roms\\kernel_FMX.hex"
Expand Down Expand Up @@ -1263,7 +1315,7 @@
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:FoenixIDE Setup"
"ProductCode" = "8:{0F09CD7A-6292-4AD4-B99E-D088A15D65C9}"
"PackageCode" = "8:{F4927D30-91A5-4E32-B1DC-4D213B55B18D}"
"PackageCode" = "8:{1C77F710-270E-4289-9C4C-FFA9E9979B1C}"
"UpgradeCode" = "8:{A91983FA-7F1D-495E-8BFB-CB92EECA466F}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
Expand Down Expand Up @@ -1812,7 +1864,7 @@
{
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_05BB69B027C149C699B0E2980589B4DF"
{
"SourcePath" = "8:..\\Main\\obj\\Debug\\FoenixIDE.exe"
"SourcePath" = "8:..\\Main\\obj\\Release\\FoenixIDE.exe"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_E6F0D81DDC2A4228B28F5AF3B10C767F"
Expand Down
15 changes: 10 additions & 5 deletions Main/Devices/MMU_JR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ public class MMU_JR : MemoryLocations.MemoryRAM

public MMU_JR(int StartAddress, int Length) : base(StartAddress, Length)
{
// At boot time, the last page of FLASH
LUTs[7] = 0x7F;
LUTs[15] = 0x7F;
LUTs[23] = 0x7F;
LUTs[31] = 0x7F;
}

public override byte ReadByte(int Address)
Expand Down Expand Up @@ -62,5 +57,15 @@ public void SetActiveLUT(byte LUT)
{
activeLUT = LUT;
}

public void Reset()
{
data[0] = 0;
data[1] = 0;
LUTs = new byte[]{ 0, 1, 2, 3, 4, 5, 6, 0x7F,
0, 1, 2, 3, 4, 5, 6, 0x7F,
0, 1, 2, 3, 4, 5, 6, 0x7F,
0, 1, 2, 3, 4, 5, 6, 0x7F };
}
}
}
94 changes: 76 additions & 18 deletions Main/Display/GPU_Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ public void SetCursorXAddress(int val)
{
CursorXAddress = val;
}
int TileMapBaseAddress;
public void SetTileMapBaseAddress(int val)
{
TileMapBaseAddress = val;
}
int TilesetBaseAddress;
public void SetTilesetBaseAddress(int val)
{
TilesetBaseAddress = val;
}

private int[] GetTextLUT(byte fg, byte bg, bool gamma)
{
Expand Down Expand Up @@ -296,11 +306,21 @@ private unsafe void DrawBitmapText(int* p, int MCR, bool gammaCorrection, byte T
}
}

private unsafe void DrawBitmap(int* p, bool gammaCorrection, int layer, bool bkgrnd, int bgndColor, int borderXSize, int borderYSize, int line, int width, int height)
int BitmapControlRegister;
public void SetBitmapControlRegister(int val)
{
BitmapControlRegister = val;
}
/**
*
* dX => double the horizontal pixels
* dY => double the vertical pixels
*/
private unsafe void DrawBitmap(int* p, bool gammaCorrection, int layer, bool bkgrnd, int bgndColor, int borderXSize, int borderYSize, int line, int width, bool dX, bool dY)
{

// Bitmap Controller is located at $AF:0100 and $AF:0108
int regAddr = MemoryMap.BITMAP_CONTROL_REGISTER_ADDR - VICKY.StartAddress + layer * 8;
int regAddr = BitmapControlRegister + layer * 8;
byte reg = VICKY.ReadByte(regAddr);
if ((reg & 0x01) == 00)
{
Expand All @@ -309,18 +329,41 @@ private unsafe void DrawBitmap(int* p, bool gammaCorrection, int layer, bool bkg
byte lutIndex = (byte)((reg >> 1) & 7); // 8 possible LUTs

int bitmapAddress = VICKY.ReadLong(regAddr + 1) & 0x3F_FFFF;
int xOffset = VICKY.ReadWord(regAddr + 4);
int yOffset = VICKY.ReadWord(regAddr + 6);
int xOffset = 0;
int yOffset = 0;
if (mode == 0)
{
xOffset = VICKY.ReadWord(regAddr + 4);
yOffset = VICKY.ReadWord(regAddr + 6);
}

int clrVal = 0;
int offsetAddress = bitmapAddress + line * width;
int offsetAddress;
if (!dY)
{
offsetAddress = bitmapAddress + line * width;
}
else
{
offsetAddress = bitmapAddress + (line/2) * (dX ? width/2 : width);
}

int pixelOffset = line * STRIDE;
int* ptr = p + pixelOffset;
//int col = borderXSize;
byte pixVal = 0;
VRAM.CopyIntoBuffer(offsetAddress, width, pixVals);

int lutAddress = MemoryMap.GRP_LUT_BASE_ADDR - VICKY.StartAddress + lutIndex * 1024;
if (!dX)
{
VRAM.CopyIntoBuffer(offsetAddress, width, pixVals);
}
else
{
for (int i=0;i < width/2; i++)
{
pixVals[i*2] = VRAM.ReadByte(offsetAddress + i);
pixVals[i*2+1] = pixVals[i * 2];
}
}

//while (col < width - borderXSize)
for (int col = borderXSize; col < width - borderXSize; col++)
Expand All @@ -335,10 +378,10 @@ private unsafe void DrawBitmap(int* p, bool gammaCorrection, int layer, bool bkg
}
}

private unsafe void DrawTiles(int* p, bool gammaCorrection, byte TextColumns, int layer, bool bkgrnd, in int borderXSize, in int line, in int width)
private unsafe void DrawTiles(int* p, bool gammaCorrection, byte TextColumns, int layer, bool bkgrnd, in int borderXSize, in int line, in int width, bool dX, bool dY)
{
// There are four possible tilemaps to choose from
int addrTileCtrlReg = MemoryMap.TILE_CONTROL_REGISTER_ADDR - VICKY.StartAddress + layer * 12;
int addrTileCtrlReg = TileMapBaseAddress + layer * 12;
int reg = VICKY.ReadByte(addrTileCtrlReg);
// if the set is not enabled, we're done.
if ((reg & 0x01) == 00)
Expand Down Expand Up @@ -381,15 +424,15 @@ private unsafe void DrawTiles(int* p, bool gammaCorrection, byte TextColumns, in
}
else
{
tilemapWindowY = tilemapWindowY & 0x3FF0 + scrollY;
tilemapWindowY = (tilemapWindowY & 0x3FF0) + scrollY;
}

int tileRow = (line + tilemapWindowY) / tileSize;
int tileYOffset = (line + tilemapWindowY) % tileSize;
int tileRow = ((dY ? line / 2: line) + tilemapWindowY) / tileSize;
int tileYOffset = ((dY ? line / 2 : line) + tilemapWindowY) % tileSize;
int maxX = width - borderXSize;

// we always read tiles 0 to width/TILE_SIZE + 1 - this is to ensure we can display partial tiles, with X,Y offsets
int tilemapItemCount = width / tileSize + 1;
int tilemapItemCount = (dX ? width / 2 : width) / tileSize + 1;
byte[] tiles = new byte[tilemapItemCount * 2];
int[] tilesetOffsets = new int[tilemapItemCount];
VRAM.CopyIntoBuffer(tilemapAddress + (1 + tilemapWindowX / tileSize) * 2 + (tileRow + 0) * tilemapWidth * 2, tilemapItemCount * 2, tiles);
Expand All @@ -399,9 +442,16 @@ private unsafe void DrawTiles(int* p, bool gammaCorrection, byte TextColumns, in
int[] strides = new int[8];
for (int i = 0; i < 8; i++)
{
tilesetPointers[i] = VICKY.ReadLong(MemoryMap.TILESET_BASE_ADDR - VICKY.StartAddress + i * 4) & 0x3F_FFFF;
byte tilesetConfig = VICKY.ReadByte(MemoryMap.TILESET_BASE_ADDR - VICKY.StartAddress + i * 4 + 3);
strides[i] = (tilesetConfig & 8) != 0 ? strideLine : tileSize;
tilesetPointers[i] = VICKY.ReadLong(TilesetBaseAddress + i * 4) & 0x3F_FFFF;
byte tilesetConfig = VICKY.ReadByte(TilesetBaseAddress + i * 4 + 3);
if (mode == 0)
{
strides[i] = (tilesetConfig & 8) != 0 ? strideLine : tileSize;
}
else
{
strides[i] = strideLine;
}
}
for (int i = 0; i < tilemapItemCount; i++)
{
Expand Down Expand Up @@ -443,7 +493,7 @@ private unsafe void DrawTiles(int* p, bool gammaCorrection, byte TextColumns, in
//}
// alternate display style - avoids repeating the loop so often
int startTileX = (borderXSize + tileXOffset) / tileSize;
int endTileX = (width - borderXSize + tileXOffset) / tileSize + 1;
int endTileX = ((dX ? width/2 : width) - borderXSize + tileXOffset) / tileSize + 1;
int startOffset = (borderXSize + tilemapWindowX) % tileSize;
int x = borderXSize;
byte[] tilepix = new byte[tileSize];
Expand All @@ -467,6 +517,14 @@ private unsafe void DrawTiles(int* p, bool gammaCorrection, byte TextColumns, in
x++;
startOffset++;
tilesetOffsetAddress++;
if (dX)
{
if (pixVal >0)
{
ptr[x] = clrVal;
}
x++;
}
} while (startOffset != tileSize && x < maxX);
startOffset = 0;
if (x == maxX)
Expand Down
Loading

0 comments on commit af38f95

Please sign in to comment.