more changes

This commit is contained in:
Asnivor 2024-11-01 17:24:36 +00:00
parent 42b1ae4a9e
commit a4bef0586c
4 changed files with 50 additions and 42 deletions

View File

@ -61,7 +61,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
public int LINE_HEIGHT => _regs[R_LCD_Y_SIZE];
private SuperVision _sv;
private byte[] _regs = new byte[0x30];
private byte[] _regs = new byte[0x2000];
/// <summary>
/// The inbuilt LCD screen
@ -114,8 +114,8 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
_sv._cpu.RDY = true;
bool lineEnd = _byteCounter == CLOCK_WIDTH - 1;
bool fieldEnd = _lineCounter == LINE_HEIGHT && lineEnd && _field == 0;
bool frameEnd = _lineCounter == LINE_HEIGHT && lineEnd && _field == 1;
bool fieldEnd = _lineCounter == LINE_HEIGHT - 1 && lineEnd && _field == 0;
bool frameEnd = _lineCounter == LINE_HEIGHT - 1 && lineEnd && _field == 1;
// vram pointer
if (fieldEnd)
@ -180,12 +180,13 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
break;
default:
_sv._cpu.RDY = !_dmaInProgress;
if (_dmaInProgress)
{
// perform DMA transfer
DoDMA();
_sv._cpu.RDY = !_dmaInProgress;
}
break;
}
@ -231,12 +232,16 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
// prescaler reset
_intTimer = 0;
}
if (_intTimerEnabled)
{
if (_regs[R_IRQ_TIMER] == 0)
{
if (_regs[R_SYSTEM_CONTROL].Bit(1))
{
// instant IRQ
// raise IRQ
// this handles IRQ after timer countdown AND instant IRQ when timer is set to 0
_intFlag = true;
_intTimerEnabled = false;
@ -244,35 +249,23 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
_regs[R_IRQ_STATUS] = (byte) (_regs[R_IRQ_STATUS] | 2);
}
}
}
else if (_regs[R_IRQ_TIMER] > 0)
{
// timer will be counting down clocked by the prescaler
if (_intTimer++ == IntPrescaler)
else
{
// prescaler clock
_intTimer = 0;
// timer should be counting down clocked by the prescaler
if (_intTimer++ == IntPrescaler)
{
// prescaler clock
_intTimer = 0;
// decrement timer
_regs[R_IRQ_TIMER]--;
}
}
else
{
// timer has expired
if (_intTimerEnabled)
{
_intFlag = true;
_intTimerEnabled = false;
// set IRQ Timer expired bit
_regs[R_IRQ_STATUS] = (byte) (_regs[R_IRQ_STATUS] | 2);
// decrement timer
_regs[R_IRQ_TIMER]--;
}
}
}
if (_intFlag && _regs[R_SYSTEM_CONTROL].Bit(1))
{
// IRQ enabled
// fire IRQ
_sv._cpu.IRQ = true;
_intFlag = false;
}
@ -399,12 +392,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
// 8bits
_regs[R_IRQ_TIMER] = value;
_intTimerEnabled = true;
// reset prescaler?
//_regs[R_SYSTEM_CONTROL] = (byte)(_regs[R_SYSTEM_CONTROL] & ~(1 << 4)); // Reset bit 4
_intTimer = value * IntPrescaler;
_intTimerChanged = true;
// Writing 00h to the IRQ Timer register results in an instant IRQ. It does not wrap to FFh and continue counting; it just stays at 00h and fires off an IRQ.
@ -425,6 +413,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
Screen.DisplayEnable = value.Bit(3);
// banking
var bank = value >> 5;
_sv.BankSelect = (value >> 5);
// writing to this register resets the LCD rendering system and makes it start rendering from the upper left corner, regardless of the bit pattern.
@ -446,6 +435,11 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
case 0x1E:
case 0x1F:
case 0x2B:
_regs[regIndex] = value;
break;
default:
_regs[regIndex] = value;
break;
}
}
@ -548,6 +542,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
break;
default:
result = _regs[regIndex];
break;
}

View File

@ -25,6 +25,14 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
Colors.ARGB(0x36, 0x4E, 0x54), // FULL DARK
];
public static readonly int[] Palette_AM =
[
Colors.ARGB(0xFC, 0xFE, 0x00), // OFF
Colors.ARGB(0xA8, 0x66, 0x00), // 1/3 DARKNESS
Colors.ARGB(0x54, 0x33, 0x00), // 2/3 DARKNESS
Colors.ARGB(0x00, 0x00, 0x00), // FULL DARK
];
private readonly int[] _palette = new int[4];
public const int PEN_BUFFER_WIDTH = 160 * 2;
@ -52,10 +60,13 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
case SuperVision.ScreenType.Green:
_palette = Palette_GR;
break;
case SuperVision.ScreenType.Monochrome:
case SuperVision.ScreenType.BlackAndWhite:
default:
_palette = Palette_BW;
break;
case SuperVision.ScreenType.Amber:
_palette = Palette_AM;
break;
}
}

View File

@ -18,11 +18,13 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
/// </summary>
public int BankSelect
{
get { return _bankSelect % (_cartridge.CartROMSize / 0x4000); }
get { return _bankSelect; }
set { _bankSelect = value; }
}
private int _bankSelect;
private int _bankOffset => BankSelect << 14;
/// <summary>
/// True when the CPU is accessing memory
@ -70,7 +72,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
// 1: 2nd 16k
// 2: 3rd 16k
// etc..
result = _cartridge.ReadByte((ushort) ((address % 0x4000) + (BankSelect * 0x4000)));
result = _cartridge.ReadByte((ushort) ((address % 0x4000) + (_bankOffset % _cartridge.CartROMSize)));
break;
// 0xC000 - 0xFFFF
@ -131,7 +133,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
case 6:
case 7:
// fixed to the last 16K in the cart address space
_cartridge.WriteByte((ushort) ((address % 0x4000) + (_cartridge.CartROMSize - 0x4000)), value);
_cartridge.WriteByte((ushort) ((address % 0x4000) + (_bankOffset % _cartridge.CartROMSize)), value);
break;
}
}

View File

@ -26,9 +26,9 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
public enum ScreenType
{
Monochrome,
Green,
TVLinkColor
BlackAndWhite,
Amber,
Green
}
[CoreSettings]
@ -36,7 +36,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SuperVision
{
[DisplayName("ScreenType")]
[Description("Color of LCD screen")]
[DefaultValue(ScreenType.Green)]
[DefaultValue(ScreenType.BlackAndWhite)]
public ScreenType ScreenType { get; set; }
public SuperVisionSyncSettings Clone()