Implemented OAM, SAT so sprites and background scrolling now work
This commit is contained in:
@@ -31,6 +31,10 @@ namespace Desktop
|
||||
_machine = new SmsMachine();
|
||||
|
||||
PopulateIncludedRomsMenu();
|
||||
|
||||
this.KeyPreview = true;
|
||||
this.KeyDown += Form1_KeyDown;
|
||||
this.KeyUp += Form1_KeyUp;
|
||||
}
|
||||
|
||||
private void DrawScreen()
|
||||
@@ -168,5 +172,45 @@ namespace Desktop
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void Form1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
UpdateJoypad(e.KeyCode, true);
|
||||
}
|
||||
|
||||
private void Form1_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
UpdateJoypad(e.KeyCode, false);
|
||||
}
|
||||
|
||||
private void UpdateJoypad(Keys key, bool isPressed)
|
||||
{
|
||||
if (_machine == null) return;
|
||||
|
||||
byte bitMask = 0;
|
||||
|
||||
// Map your keys to the Sega hardware bits
|
||||
switch (key)
|
||||
{
|
||||
case Keys.W: bitMask = 0x01; break; // Bit 0: Up
|
||||
case Keys.S: bitMask = 0x02; break; // Bit 1: Down
|
||||
case Keys.A: bitMask = 0x04; break; // Bit 2: Left
|
||||
case Keys.D: bitMask = 0x08; break; // Bit 3: Right
|
||||
case Keys.O: bitMask = 0x10; break; // Bit 4: Button 1 (Start/Action)
|
||||
case Keys.P: bitMask = 0x20; break; // Bit 5: Button 2
|
||||
default: return; // Ignore any other keys
|
||||
}
|
||||
|
||||
if (isPressed)
|
||||
{
|
||||
// Active-Low: Clear the specific bit to 0 using a bitwise AND with a NOT mask
|
||||
_machine.IoBus.Joypad1State &= (byte)~bitMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Active-Low: Reset the specific bit to 1 using a bitwise OR mask
|
||||
_machine.IoBus.Joypad1State |= bitMask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user