Skip to content

Commit

Permalink
Release 0.5.6.0
Browse files Browse the repository at this point in the history
---------------
Added the MIDI to VGM Converter form.
Fixed an issue with the Tile Editor that margins were not taken into account.
Fixed the mouse sensing code: we need to record the state of each mouse button and pass the state to the mouse interrupt.
  • Loading branch information
Daniel Tremblay committed Feb 19, 2022
1 parent 69de4e4 commit 6eb45c7
Show file tree
Hide file tree
Showing 7 changed files with 11,938 additions and 11,961 deletions.
4 changes: 0 additions & 4 deletions Main/Basic/MultimediaTimer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Diagnostics;

Expand Down
2 changes: 1 addition & 1 deletion Main/UI/AssetLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void BrowseFileButton_Click(object sender, EventArgs e)
{
Title = "Load Bitmap",
DefaultExt = ".bin",
Filter = "Asset Files (*.bmp *.png *.bin *.data *.pal *.aseprite)|*.bmp;*.png;*.bin;*.data;*.pal;*.aseprite|Binary Files|*.bin|Palette Files|*.pal|Bitmap Files|*.bmp;*.png|Data Files|*.data|Any File|*.*"
Filter = "Asset Files (*.bmp *.png *.bin *.data *.pal *.tls *.aseprite)|*.bmp;*.png;*.bin;*.data;*.pal;*.tls;*.aseprite|Binary Files|*.bin|Palette Files|*.pal|Bitmap Files|*.bmp;*.png|Data Files|*.data|Tilemap Files|*.tls|Any File|*.*"
};

// Load content of file in a TextBlock
Expand Down
43 changes: 39 additions & 4 deletions Main/UI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,12 @@ private void Gpu_MouseMove(object sender, MouseEventArgs e)
Point size = gpu.GetScreenSize();
double ratioW = gpu.Width / (double)size.X;
double ratioH = gpu.Height / (double)size.Y;
bool borderEnabled = kernel.MemMgr.ReadByte(MemoryLocations.MemoryMap.BORDER_CTRL_REG) == 1;
double borderWidth = borderEnabled ? kernel.MemMgr.ReadByte(MemoryLocations.MemoryMap.BORDER_X_SIZE) : 0;
double borderHeight = borderEnabled ? kernel.MemMgr.ReadByte(MemoryLocations.MemoryMap.BORDER_Y_SIZE) : 0;
if (gpu.TileEditorMode)
{
if ((e.X / ratioW > 32 && e.X / ratioW < size.X -32) && (e.Y / ratioH > 32 && e.Y / ratioH < size.Y -32))
if ((e.X / ratioW > borderWidth && e.X / ratioW < size.X - borderWidth) && (e.Y / ratioH > borderHeight && e.Y / ratioH < size.Y - borderHeight))
{
this.Cursor = Cursors.Hand;
if (e.Button == MouseButtons.Left)
Expand All @@ -778,6 +781,18 @@ private void Gpu_MouseDown(object sender, MouseEventArgs e)
Point size = gpu.GetScreenSize();
double ratioW = gpu.Width / (double)size.X;
double ratioH = gpu.Height / (double)size.Y;
switch (e.Button)
{
case MouseButtons.Left:
left = true;
break;
case MouseButtons.Right:
right = true;
break;
case MouseButtons.Middle:
middle = true;
break;
}
if (gpu.TileEditorMode && gpu.Cursor != Cursors.No)
{
TileClicked?.Invoke(new Point((int)(e.X / ratioW / 16), (int)(e.Y / ratioH / 16)));
Expand All @@ -791,22 +806,39 @@ private void Gpu_MouseDown(object sender, MouseEventArgs e)

private void Gpu_MouseUp(object sender, MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Left:
left = false;
break;
case MouseButtons.Right:
right = false;
break;
case MouseButtons.Middle:
middle = false;
break;
}
GenerateMouseInterrupt(e);
}

// Remember the state of the mouse buttons
bool left = false;
bool right = false;
bool middle = false;

private void GenerateMouseInterrupt(MouseEventArgs e)
{
Point size = gpu.GetScreenSize();
double ratioW = gpu.Width / (double)size.X;
double ratioH = gpu.Height / (double)size.Y;
int X = (int)(e.X / ratioW);
int Y = (int)(e.Y / ratioH);
bool middle = e.Button == MouseButtons.Middle;
bool left = e.Button == MouseButtons.Left;
bool right = e.Button == MouseButtons.Right;

byte buttons = (byte)((left ? 1 : 0) + (right ? 2 : 0) + (middle ? 4 : 0));

kernel.MemMgr.VICKY.WriteWord(0x702, X);
kernel.MemMgr.VICKY.WriteWord(0x704, Y);
kernel.MemMgr.VICKY.WriteByte(0x706, buttons);

// Generate three interrupts - to emulate how the PS/2 controller works
byte mask = kernel.MemMgr.ReadByte(MemoryLocations.MemoryMap.INT_MASK_REG0);
Expand All @@ -819,6 +851,9 @@ private void GenerateMouseInterrupt(MouseEventArgs e)

private void Gpu_MouseLeave(object sender, EventArgs e)
{
left = false;
right = false;
middle = false;
if (gpu.IsMousePointerVisible() || gpu.TileEditorMode)
{
Cursor.Show();
Expand Down
2 changes: 1 addition & 1 deletion Main/UI/TileEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private void SaveTilemapButton_Click(object sender, EventArgs e)
Resource resource = new Resource()
{
Name = "Tile Editor Map",
Length = width * height,
Length = width * height * 2,
FileType = ResourceType.tilemap,
StartAddress = tilemapAddress
};
Expand Down
Binary file modified bin/Release/FoenixIDE.exe
Binary file not shown.
Loading

0 comments on commit 6eb45c7

Please sign in to comment.