diff --git a/FoenixIDESetup/FoenixIDESetup.vdproj b/FoenixIDESetup/FoenixIDESetup.vdproj index b9b01be..798ce11 100644 --- a/FoenixIDESetup/FoenixIDESetup.vdproj +++ b/FoenixIDESetup/FoenixIDESetup.vdproj @@ -135,6 +135,12 @@ } "Entry" { + "MsmKey" = "8:_7BD2B3A7DD6E4E0E81969BEC234D508C" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_81547FC2AD874EF680C5282428D55CD4" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" @@ -243,6 +249,12 @@ } "Entry" { + "MsmKey" = "8:_F1A01B2DDF0E458FB4CC621697DB5ED5" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_F5E33CFE52604F89ADF26B5E264648BA" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" @@ -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" @@ -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" @@ -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" @@ -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" diff --git a/Main/Devices/MMU_JR.cs b/Main/Devices/MMU_JR.cs index 61a2de1..b0d2a91 100644 --- a/Main/Devices/MMU_JR.cs +++ b/Main/Devices/MMU_JR.cs @@ -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) @@ -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 }; + } } } diff --git a/Main/Display/GPU_Common.cs b/Main/Display/GPU_Common.cs index 5dbb6bb..e900614 100644 --- a/Main/Display/GPU_Common.cs +++ b/Main/Display/GPU_Common.cs @@ -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) { @@ -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) { @@ -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++) @@ -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) @@ -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); @@ -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++) { @@ -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]; @@ -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) diff --git a/Main/Display/Gpu.cs b/Main/Display/Gpu.cs index 7179e8b..e4b7ce6 100644 --- a/Main/Display/Gpu.cs +++ b/Main/Display/Gpu.cs @@ -148,7 +148,7 @@ unsafe void Gpu_Paint(object sender, PaintEventArgs e) // Read the Master Control Register Point res; - if (VRAM != null) + if (mode == 0) { res = GetScreenSize(); } @@ -322,7 +322,7 @@ unsafe void Gpu_Paint(object sender, PaintEventArgs e) // Layer 11 - bitmap 1 if ((MCRegister & 0x8) == 0x8) { - DrawBitmap(bitmapPointer, gammaCorrection, 1, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, res.Y); + DrawBitmap(bitmapPointer, gammaCorrection, 1, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, false, false); } // Layer 10 - sprite layer 5 if ((MCRegister & 0x20) != 0) @@ -332,7 +332,7 @@ unsafe void Gpu_Paint(object sender, PaintEventArgs e) // Layer 9 - tilemap layer 3 if ((MCRegister & 0x10) == 0x10) { - DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 3, displayBorder, borderXSize, line, res.X); + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 3, displayBorder, borderXSize, line, res.X, false, false); } // Layer 8 - sprite layer 4 if ((MCRegister & 0x20) != 0) @@ -342,7 +342,7 @@ unsafe void Gpu_Paint(object sender, PaintEventArgs e) // Layer 7 - tilemap layer 2 if ((MCRegister & 0x10) == 0x10) { - DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 2, displayBorder, borderXSize, line, res.X); + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 2, displayBorder, borderXSize, line, res.X, false, false); } // Layer 6 - sprite layer 3 if ((MCRegister & 0x20) != 0) @@ -352,7 +352,7 @@ unsafe void Gpu_Paint(object sender, PaintEventArgs e) // Layer 5 - tilemap layer 1 if ((MCRegister & 0x10) == 0x10) { - DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 1, displayBorder, borderXSize, line, res.X); + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 1, displayBorder, borderXSize, line, res.X, false, false); } // Layer 4 - sprite layer 2 if ((MCRegister & 0x20) != 0) @@ -362,7 +362,7 @@ unsafe void Gpu_Paint(object sender, PaintEventArgs e) // Layer 3 - tilemap layer 0 if ((MCRegister & 0x10) == 0x10) { - DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 0, displayBorder, borderXSize, line, res.X); + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 0, displayBorder, borderXSize, line, res.X, false, false); } // Layer 2 - sprite layer 1 if ((MCRegister & 0x20) != 0) @@ -372,7 +372,7 @@ unsafe void Gpu_Paint(object sender, PaintEventArgs e) // Layer 1 - bitmap layer 0 if ((MCRegister & 0x8) == 0x8) { - DrawBitmap(bitmapPointer, gammaCorrection, 0, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, res.Y); + DrawBitmap(bitmapPointer, gammaCorrection, 0, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, false, false); } // Layer 0 - sprite layer 0 if ((MCRegister & 0x20) != 0) @@ -383,6 +383,104 @@ unsafe void Gpu_Paint(object sender, PaintEventArgs e) else { // Tiny Vicky Layers for Bitmaps, Tilemaps and sprites + byte LayerMgr0 = (byte)(VICKY.ReadByte(0xD002 - 0xC000) & 0x7); + byte LayerMgr1 = (byte)(VICKY.ReadByte(0xD002 - 0xC000) >> 4); + byte LayerMgr2 = (byte)(VICKY.ReadByte(0xD003 - 0xC000) & 0x7); + bool doubleY = (MCRHigh & 4) == 0; + bool doubleX = (MCRHigh & 2) == 0; + int BitmapY = (MCRHigh & 4) != 0 ? res.Y : res.Y >> 1; + + if ((MCRegister & 0x20) != 0) + { + DrawSprites(bitmapPointer, gammaCorrection, 0, displayBorder, borderXSize, borderYSize, line, 320, BitmapY); + } + if ((MCRegister & 0x8) != 0 || (MCRegister & 0x10) != 0) + { + switch (LayerMgr0) + { + case 0: + DrawBitmap(bitmapPointer, gammaCorrection, 0, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, doubleX, doubleY); + break; + case 1: + DrawBitmap(bitmapPointer, gammaCorrection, 1, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, doubleX, doubleY); + break; + case 2: + DrawBitmap(bitmapPointer, gammaCorrection, 1, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, doubleX, doubleY); + break; + case 4: + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 0, displayBorder, borderXSize, line, res.X, doubleX, doubleY); + break; + case 5: + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 1, displayBorder, borderXSize, line, res.X, doubleX, doubleY); + break; + case 6: + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 2, displayBorder, borderXSize, line, res.X, doubleX, doubleY); + break; + } + + } + if ((MCRegister & 0x20) != 0) + { + DrawSprites(bitmapPointer, gammaCorrection, 1, displayBorder, borderXSize, borderYSize, line, res.X, BitmapY); + } + if ((MCRegister & 0x8) != 0 || (MCRegister & 0x10) != 0) + { + switch (LayerMgr1) + { + case 0: + DrawBitmap(bitmapPointer, gammaCorrection, 0, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, doubleX, doubleY); + break; + case 1: + DrawBitmap(bitmapPointer, gammaCorrection, 1, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, doubleX, doubleY); + break; + case 2: + DrawBitmap(bitmapPointer, gammaCorrection, 1, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, doubleX, doubleY); + break; + case 4: + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 0, displayBorder, borderXSize, line, res.X, doubleX, doubleY); + break; + case 5: + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 1, displayBorder, borderXSize, line, res.X, doubleX, doubleY); + break; + case 6: + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 2, displayBorder, borderXSize, line, res.X, doubleX, doubleY); + break; + } + + } + if ((MCRegister & 0x20) != 0) + { + DrawSprites(bitmapPointer, gammaCorrection, 2, displayBorder, borderXSize, borderYSize, line, res.X, BitmapY); + } + if ((MCRegister & 0x8) != 0 || (MCRegister & 0x10) != 0) + { + switch (LayerMgr2) + { + case 0: + DrawBitmap(bitmapPointer, gammaCorrection, 0, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, doubleX, doubleY); + break; + case 1: + DrawBitmap(bitmapPointer, gammaCorrection, 1, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, doubleX, doubleY); + break; + case 2: + DrawBitmap(bitmapPointer, gammaCorrection, 1, displayBorder, backgroundColor, borderXSize, borderYSize, line, res.X, doubleX, doubleY); + break; + case 4: + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 0, displayBorder, borderXSize, line, res.X, doubleX, doubleY); + break; + case 5: + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 1, displayBorder, borderXSize, line, res.X, doubleX, doubleY); + break; + case 6: + DrawTiles(bitmapPointer, gammaCorrection, ColumnsVisible, 2, displayBorder, borderXSize, line, res.X, doubleX, doubleY); + break; + } + + } + if ((MCRegister & 0x20) != 0) + { + DrawSprites(bitmapPointer, gammaCorrection, 3, displayBorder, borderXSize, borderYSize, line, res.X, BitmapY); + } } } // Draw the text diff --git a/Main/FoenixSystem.cs b/Main/FoenixSystem.cs index a8f2274..ad6f2a2 100644 --- a/Main/FoenixSystem.cs +++ b/Main/FoenixSystem.cs @@ -178,6 +178,8 @@ public FoenixSystem(BoardVersion version, string DefaultKernel) else { MemMgr.WriteByte(MemoryMap.REVOFJR, 0x2); + MemMgr.VICKY.WriteWord(0xD000 - 0xC000, 1); + MemMgr.VICKY.WriteWord(0xD002 - 0xC000, 0x1540); } if (MemMgr.TIMER0.TimerInterruptDelegate == null) @@ -279,10 +281,10 @@ public bool ResetCPU(string filename) } if (boardVersion == BoardVersion.RevJr) { - byte[] tempBuffer = new byte[0xFFFF]; - MemMgr.RAM.CopyIntoBuffer(0, 0xFFFF, tempBuffer); + byte[] tempBuffer = new byte[0x1_0000]; + MemMgr.RAM.CopyIntoBuffer(0, 0x1_0000, tempBuffer); //MemMgr.RAM.Zero(); - MemMgr.RAM.CopyBuffer(tempBuffer, 0, 0xF_0000, 0xFFFF); + MemMgr.RAM.CopyBuffer(tempBuffer, 0, 0xF_0000, 0x1_0000); } } else if (extension.Equals(".PGX")) diff --git a/Main/Properties/AssemblyInfo.cs b/Main/Properties/AssemblyInfo.cs index 8faff45..684eb5e 100644 --- a/Main/Properties/AssemblyInfo.cs +++ b/Main/Properties/AssemblyInfo.cs @@ -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.6.0.0")] -[assembly: AssemblyFileVersion("0.6.0.0")] +[assembly: AssemblyVersion("0.6.0.1")] +[assembly: AssemblyFileVersion("0.6.0.1")] diff --git a/Main/UI/MainWindow.Designer.cs b/Main/UI/MainWindow.Designer.cs index 1d010a4..9fe94e4 100644 --- a/Main/UI/MainWindow.Designer.cs +++ b/Main/UI/MainWindow.Designer.cs @@ -42,9 +42,9 @@ private void InitializeComponent() this.SDCardPath = new System.Windows.Forms.ToolStripStatusLabel(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.menuOpenHexFile = new System.Windows.Forms.ToolStripMenuItem(); this.loadFNXMLFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.menuOpenHexFile = new System.Windows.Forms.ToolStripMenuItem(); this.loadWatchListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveWatchListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -92,10 +92,10 @@ private void InitializeComponent() this.cpsPerf, this.fpsPerf, this.SDCardPath}); - this.statusStrip1.Location = new System.Drawing.Point(0, 543); + this.statusStrip1.Location = new System.Drawing.Point(0, 519); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.ShowItemToolTips = true; - this.statusStrip1.Size = new System.Drawing.Size(670, 28); + this.statusStrip1.Size = new System.Drawing.Size(669, 22); this.statusStrip1.Stretch = false; this.statusStrip1.TabIndex = 1; this.statusStrip1.Text = "statusStrip1"; @@ -109,7 +109,7 @@ private void InitializeComponent() this.toolStripRevision.BorderStyle = System.Windows.Forms.Border3DStyle.Sunken; this.toolStripRevision.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); this.toolStripRevision.Name = "toolStripRevision"; - this.toolStripRevision.Size = new System.Drawing.Size(64, 23); + this.toolStripRevision.Size = new System.Drawing.Size(64, 17); this.toolStripRevision.Text = "Rev B"; this.toolStripRevision.ToolTipText = "Board Version"; this.toolStripRevision.Click += new System.EventHandler(this.ToolStripRevision_Click); @@ -120,7 +120,7 @@ private void InitializeComponent() this.dipSwitch.BackColor = System.Drawing.SystemColors.ActiveCaption; this.dipSwitch.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.None; this.dipSwitch.Name = "dipSwitch"; - this.dipSwitch.Size = new System.Drawing.Size(129, 23); + this.dipSwitch.Size = new System.Drawing.Size(129, 17); this.dipSwitch.Text = "toolStripStatusLabel1"; this.dipSwitch.ToolTipText = "DIP Switches"; this.dipSwitch.MouseDown += new System.Windows.Forms.MouseEventHandler(this.DipSwitch_MouseDown); @@ -129,14 +129,14 @@ private void InitializeComponent() // ModeText // this.ModeText.Name = "ModeText"; - this.ModeText.Size = new System.Drawing.Size(26, 23); + this.ModeText.Size = new System.Drawing.Size(26, 17); this.ModeText.Text = "Key"; // // lastKeyPressed // this.lastKeyPressed.AutoSize = false; this.lastKeyPressed.Name = "lastKeyPressed"; - this.lastKeyPressed.Size = new System.Drawing.Size(30, 23); + this.lastKeyPressed.Size = new System.Drawing.Size(30, 17); this.lastKeyPressed.Text = "$00"; // // cpsPerf @@ -150,7 +150,7 @@ private void InitializeComponent() this.cpsPerf.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cpsPerf.Name = "cpsPerf"; this.cpsPerf.Padding = new System.Windows.Forms.Padding(2); - this.cpsPerf.Size = new System.Drawing.Size(110, 23); + this.cpsPerf.Size = new System.Drawing.Size(110, 17); this.cpsPerf.Text = "CPS: 0"; this.cpsPerf.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.cpsPerf.ToolTipText = "Cycles Per Second"; @@ -165,7 +165,7 @@ private void InitializeComponent() this.fpsPerf.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.fpsPerf.Name = "fpsPerf"; this.fpsPerf.Padding = new System.Windows.Forms.Padding(2); - this.fpsPerf.Size = new System.Drawing.Size(55, 23); + this.fpsPerf.Size = new System.Drawing.Size(55, 17); this.fpsPerf.Text = "FPS: 0"; this.fpsPerf.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.fpsPerf.ToolTipText = "Frames Per Second"; @@ -180,7 +180,7 @@ private void InitializeComponent() this.SDCardPath.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); this.SDCardPath.Name = "SDCardPath"; this.SDCardPath.Overflow = System.Windows.Forms.ToolStripItemOverflow.Always; - this.SDCardPath.Size = new System.Drawing.Size(241, 23); + this.SDCardPath.Size = new System.Drawing.Size(240, 17); this.SDCardPath.Spring = true; this.SDCardPath.Text = "SD Card Disabled"; this.SDCardPath.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -199,7 +199,7 @@ private void InitializeComponent() this.helpToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(670, 24); + this.menuStrip1.Size = new System.Drawing.Size(669, 24); this.menuStrip1.TabIndex = 2; this.menuStrip1.Text = "menuStrip1"; // @@ -216,13 +216,6 @@ private void InitializeComponent() this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.fileToolStripMenuItem.Text = "&File"; // - // menuOpenHexFile - // - this.menuOpenHexFile.Name = "menuOpenHexFile"; - this.menuOpenHexFile.Size = new System.Drawing.Size(184, 22); - this.menuOpenHexFile.Text = "&Open Executable File"; - this.menuOpenHexFile.Click += new System.EventHandler(this.MenuOpenExecutableFile_Click); - // // loadFNXMLFileToolStripMenuItem // this.loadFNXMLFileToolStripMenuItem.Name = "loadFNXMLFileToolStripMenuItem"; @@ -237,6 +230,13 @@ private void InitializeComponent() this.saveProjectToolStripMenuItem.Text = "&Save Project..."; this.saveProjectToolStripMenuItem.Click += new System.EventHandler(this.SaveProjectToolStripMenuItem_Click); // + // menuOpenHexFile + // + this.menuOpenHexFile.Name = "menuOpenHexFile"; + this.menuOpenHexFile.Size = new System.Drawing.Size(184, 22); + this.menuOpenHexFile.Text = "&Open Executable File"; + this.menuOpenHexFile.Click += new System.EventHandler(this.MenuOpenExecutableFile_Click); + // // loadWatchListToolStripMenuItem // this.loadWatchListToolStripMenuItem.Name = "loadWatchListToolStripMenuItem"; @@ -495,7 +495,7 @@ private void InitializeComponent() this.gpu.Margin = new System.Windows.Forms.Padding(4); this.gpu.MinimumSize = new System.Drawing.Size(640, 480); this.gpu.Name = "gpu"; - this.gpu.Size = new System.Drawing.Size(670, 519); + this.gpu.Size = new System.Drawing.Size(669, 495); this.gpu.TabIndex = 0; this.gpu.TabStop = false; this.gpu.TileEditorMode = false; @@ -510,7 +510,7 @@ private void InitializeComponent() this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(670, 571); + this.ClientSize = new System.Drawing.Size(669, 541); this.Controls.Add(this.gpu); this.Controls.Add(this.menuStrip1); this.Controls.Add(this.statusStrip1); diff --git a/Main/UI/MainWindow.cs b/Main/UI/MainWindow.cs index 5eff5fe..61d1361 100644 --- a/Main/UI/MainWindow.cs +++ b/Main/UI/MainWindow.cs @@ -199,10 +199,16 @@ private void BasicWindow_Load(object sender, EventArgs e) gpu.SetSOL0Address(MemoryMap.VKY_LINE0_CMP_VALUE_LO); gpu.SetSOL1Address(MemoryMap.VKY_LINE1_CMP_VALUE_LO); gpu.SetMousePointerRegister(0x700); + + gpu.SetBitmapControlRegister(MemoryMap.BITMAP_CONTROL_REGISTER_ADDR - gpu.VICKY.StartAddress); + gpu.SetTileMapBaseAddress(MemoryMap.TILE_CONTROL_REGISTER_ADDR - gpu.VICKY.StartAddress); + gpu.SetTilesetBaseAddress(MemoryMap.TILESET_BASE_ADDR - gpu.VICKY.StartAddress); } else { gpu.SetMode(1); + gpu.VRAM = kernel.MemMgr.RAM; + // Addresses for VICKY in Junior are zero-based gpu.SetMCRAddress(0x1000); gpu.SetFGLUTAddress(MemoryMap.FG_CHAR_LUT_PTR_JR - 0xC000); // IO Page 0 @@ -219,6 +225,10 @@ private void BasicWindow_Load(object sender, EventArgs e) gpu.SetLineIRQRegister(MemoryMap.VKY_LINE_IRQ_CTRL_REG_JR - 0xC000); // IO Page 0 gpu.SetSOL0Address(MemoryMap.VKY_LINE_CMP_VALUE_JR - 0xC000); // IO Page 0 gpu.SetMousePointerRegister(0x1000); // IO Page 0 + + gpu.SetBitmapControlRegister(0xD100 - 0xC000); // IO Page 0 + gpu.SetTileMapBaseAddress(0xD200 - 0xC000); + gpu.SetTilesetBaseAddress(0xD280 - 0xC000); } if (disabledIRQs) @@ -401,14 +411,9 @@ public void LoadImageToolStripMenuItem_Click(object sender, EventArgs e) } } - DateTime pSof; public void SOFRoutine() { // Check if the interrupt is enabled - DateTime currentDT = DateTime.Now; - TimeSpan ts = currentDT - pSof; - //System.Console.WriteLine(ts.TotalMilliseconds); - pSof = currentDT; byte mask = kernel.MemMgr.ReadByte(MemoryLocations.MemoryMap.INT_MASK_REG0); if (version == BoardVersion.RevJr) { @@ -459,7 +464,6 @@ public void SOLRoutine() public void setGpuPeriod(uint time) { - gpu.SetRefreshPeriod(time); } @@ -685,6 +689,7 @@ private void Write_CPS_FPS_Safe(string CPS, string FPS) statusStrip1.Update(); } } + int previousCounter = 0; int previousFrame = 0; DateTime previousTime = DateTime.Now; @@ -733,14 +738,14 @@ private void WriteRTCTime(DateTime currentTime) } else { - kernel.MemMgr.RAM.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR, BCD(currentTime.Second)); - kernel.MemMgr.RAM.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 2, BCD(currentTime.Minute)); - kernel.MemMgr.RAM.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 4, BCD(currentTime.Hour)); - kernel.MemMgr.RAM.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 6, BCD(currentTime.Day)); - kernel.MemMgr.RAM.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 8, BCD(currentTime.Month)); - kernel.MemMgr.RAM.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 10, BCD(currentTime.Year % 100)); - kernel.MemMgr.RAM.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 12, BCD(currentTime.Year / 100)); - kernel.MemMgr.RAM.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 14, (byte)(currentTime.DayOfWeek + 1)); + kernel.MemMgr.VICKY.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR - 0xC000, BCD(currentTime.Second)); + kernel.MemMgr.VICKY.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 2 - 0xC000, BCD(currentTime.Minute)); + kernel.MemMgr.VICKY.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 4 - 0xC000, BCD(currentTime.Hour)); + kernel.MemMgr.VICKY.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 6 - 0xC000, BCD(currentTime.Day)); + kernel.MemMgr.VICKY.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 8 - 0xC000, BCD(currentTime.Month)); + kernel.MemMgr.VICKY.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 10 - 0xC000, BCD(currentTime.Year % 100)); + kernel.MemMgr.VICKY.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 12 - 0xC000, BCD(currentTime.Year / 100)); + kernel.MemMgr.VICKY.WriteByte(MemoryLocations.MemoryMap.RTC_SEC_JR + 14 - 0xC000, (byte)(currentTime.DayOfWeek + 1)); } } @@ -778,6 +783,13 @@ public void RestartMenuItemClick(object sender, EventArgs e) debugWindow.ClearTrace(); SetDipSwitchMemory(); memoryWindow.Memory = kernel.CPU.MemMgr; + if (version == BoardVersion.RevJr) + { + // Now update other registers + kernel.MemMgr.MMU.Reset(); + kernel.MemMgr.VICKY.WriteWord(0xD000 - 0xC000, 1); + kernel.MemMgr.VICKY.WriteWord(0xD002 - 0xC000, 0x1540); + } memoryWindow.UpdateMCRButtons(); ResetSDCard(); @@ -799,6 +811,13 @@ private void DebugToolStripMenuItem_Click(object sender, EventArgs e) debugWindow.ClearTrace(); SetDipSwitchMemory(); memoryWindow.Memory = kernel.CPU.MemMgr; + if (version == BoardVersion.RevJr) + { + // Now update other registers + kernel.MemMgr.MMU.Reset(); + kernel.MemMgr.VICKY.WriteWord(0xD000 - 0xC000, 1); + kernel.MemMgr.VICKY.WriteWord(0xD002 - 0xC000, 0x1540); + } memoryWindow.UpdateMCRButtons(); ResetSDCard(); @@ -817,6 +836,13 @@ private void DefaultKernelToolStripMenuItem_Click(object sender, EventArgs e) debugWindow.ClearTrace(); SetDipSwitchMemory(); memoryWindow.Memory = kernel.CPU.MemMgr; + if (version == BoardVersion.RevJr) + { + // Now update other registers + kernel.MemMgr.MMU.Reset(); + kernel.MemMgr.VICKY.WriteWord(0xD000 - 0xC000, 1); + kernel.MemMgr.VICKY.WriteWord(0xD002 - 0xC000, 0x1540); + } memoryWindow.UpdateMCRButtons(); ResetSDCard(); @@ -876,6 +902,13 @@ private void LoadFNXMLFileToolStripMenuItem_Click(object sender, EventArgs e) debugWindow.Pause(); SetDipSwitchMemory(); ShowDebugWindow(); + if (version == BoardVersion.RevJr) + { + // Now update other registers + kernel.MemMgr.MMU.Reset(); + kernel.MemMgr.VICKY.WriteWord(0xD000 - 0xC000, 1); + kernel.MemMgr.VICKY.WriteWord(0xD002 - 0xC000, 0x1540); + } ShowMemoryWindow(); EnableMenuItems(); assetWindow.UpdateAssets(); @@ -1395,7 +1428,6 @@ private void SetDipSwitchMemory() byte userMode = (byte)((switches[4] ? 0 : 1) + (switches[5] ? 0 : 2) + (switches[6] ? 0 : 4)); if (kernel.MemMgr != null && kernel.MemMgr.VICKY != null) { - // switch 6 - Gamma byte MCR = kernel.MemMgr.VICKY.ReadByte(MemoryMap.VICKY_START_JR - 0xC000); if (switches[7]) @@ -1406,20 +1438,22 @@ private void SetDipSwitchMemory() { MCR &= 0b1011_1111; } - kernel.MemMgr.VICKY.WriteByte(kernel.MemMgr.VICKY.StartAddress, MCR); + kernel.MemMgr.VICKY.WriteByte(MemoryMap.VICKY_START_JR - 0xC000, MCR); } } } public void WriteMCRBytesToVicky(byte low, byte high) { - kernel.MemMgr.VICKY.WriteByte(0, low); - kernel.MemMgr.VICKY.WriteByte(1, high); + int baseAddr = version == BoardVersion.RevJr ? 0xD000 - 0xC000 : 0; + + kernel.MemMgr.VICKY.WriteByte(baseAddr, low); + kernel.MemMgr.VICKY.WriteByte(baseAddr + 1, high); } public ushort ReadMCRBytesFromVicky() { - return (ushort)kernel.MemMgr.VICKY.ReadWord(0); + return (ushort)kernel.MemMgr.VICKY.ReadWord(version == BoardVersion.RevJr ? 0xD000 - 0xC000 : 0); } public void UpdateGamma(bool gamma) diff --git a/Release Notes.txt b/Release Notes.txt index 7b53a48..734894e 100644 --- a/Release Notes.txt +++ b/Release Notes.txt @@ -1,3 +1,9 @@ +Release 0.6.0.1 +--------------- +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. + Release 0.6.0.0 --------------- Fixed an issue where CPS/FPS display was showing zeroes after switching Board type. diff --git a/bin/Release/FoenixIDE.exe b/bin/Release/FoenixIDE.exe index 29a5ef1..246b974 100644 Binary files a/bin/Release/FoenixIDE.exe and b/bin/Release/FoenixIDE.exe differ