[CPCHawk] Some CRTC code tidy
This commit is contained in:
parent
ac25842689
commit
c64822680c
|
@ -239,6 +239,68 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// R3l: CRTC-type horizontal sync width independent helper function
|
||||
/// </summary>
|
||||
protected override int R3_HorizontalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
// Bits 3..0 define Horizontal Sync Width
|
||||
// on CRTC0, a zero value means no HSYNC is generated
|
||||
return Register[R3_SYNC_WIDTHS] & 0x0F;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R3h: CRTC-type vertical sync width independent helper function
|
||||
/// </summary>
|
||||
protected override int R3_VerticalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
// Bits 7..4 define Vertical Sync Width
|
||||
// on CRTC0 if 0 is programmed this gives 16 lines of VSYNC
|
||||
return ((Register[R3_SYNC_WIDTHS] >> 4) & 0x0F) == 0 ? 16 : Register[R3_SYNC_WIDTHS] >> 4 & 0x0F;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R8: CRTC-type CUDISP Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected override int R8_Skew_CUDISP
|
||||
{
|
||||
get
|
||||
{
|
||||
// CRTC0
|
||||
// Bits 7..6 define the skew (delay) of the CUDISP signal
|
||||
// 00 = 0
|
||||
// 01 = 1
|
||||
// 10 = 2
|
||||
// 11 = non-output
|
||||
return (Register[R8_INTERLACE_MODE] >> 6) & 0x03;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R8: CRTC-type CUDISP Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected override int R8_Skew_DISPTMG
|
||||
{
|
||||
get
|
||||
{
|
||||
// CRTC0
|
||||
// Bits 5..4 define the skew (delay) of the DISPTMG signal
|
||||
// 00 = 0
|
||||
// 01 = 1
|
||||
// 10 = 2
|
||||
// 11 = non-output
|
||||
return ((Register[R8_INTERLACE_MODE] & 0b0011_0000) >> 4) & 0x03;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to read from the currently selected register
|
||||
/// </summary>
|
||||
|
|
|
@ -244,6 +244,60 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// R3l: CRTC-type horizontal sync width independent helper function
|
||||
/// </summary>
|
||||
protected override int R3_HorizontalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
// Bits 3..0 define Horizontal Sync Width
|
||||
// on CRTC1, a zero value means no HSYNC is generated
|
||||
return Register[R3_SYNC_WIDTHS] & 0x0F;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R3h: CRTC-type vertical sync width independent helper function
|
||||
/// </summary>
|
||||
protected override int R3_VerticalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
// Bits 7..4 are ignored
|
||||
// on CRTC1 VSYNC is fixed at 16 lines
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R8: CRTC-type CUDISP Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected override int R8_Skew_CUDISP
|
||||
{
|
||||
get
|
||||
{
|
||||
// CRTC1
|
||||
// Bits 7..6 are ignored
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R8: CRTC-type CUDISP Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected override int R8_Skew_DISPTMG
|
||||
{
|
||||
get
|
||||
{
|
||||
// CRTC1
|
||||
// Bits 5..4 are ignored
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to read from the currently selected register
|
||||
/// </summary>
|
||||
|
|
|
@ -241,6 +241,60 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// R3l: CRTC-type horizontal sync width independent helper function
|
||||
/// </summary>
|
||||
protected override int R3_HorizontalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
// Bits 3..0 define Horizontal Sync Width
|
||||
// on CRTC2, a zero value means 16 characters of HSYNC are generated
|
||||
return (Register[R3_SYNC_WIDTHS] & 0x0F) == 0 ? 16 : Register[R3_SYNC_WIDTHS] & 0x0F;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R3h: CRTC-type vertical sync width independent helper function
|
||||
/// </summary>
|
||||
protected override int R3_VerticalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
// Bits 7..4 are ignored
|
||||
// on CRTC2 VSYNC is fixed at 16 lines
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R8: CRTC-type CUDISP Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected override int R8_Skew_CUDISP
|
||||
{
|
||||
get
|
||||
{
|
||||
// CRTC2
|
||||
// Bits 7..6 are ignored
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R8: CRTC-type CUDISP Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected override int R8_Skew_DISPTMG
|
||||
{
|
||||
get
|
||||
{
|
||||
// CRTC2
|
||||
// Bits 5..4 are ignored
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to read from the currently selected register
|
||||
/// </summary>
|
||||
|
|
|
@ -239,6 +239,68 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// R3l: CRTC-type horizontal sync width independent helper function
|
||||
/// </summary>
|
||||
protected override int R3_HorizontalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
// Bits 3..0 define Horizontal Sync Width
|
||||
// on CRTC3, a zero value means 16 characters of HSYNC are generated
|
||||
return (Register[R3_SYNC_WIDTHS] & 0x0F) == 0 ? 16 : Register[R3_SYNC_WIDTHS] & 0x0F;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R3h: CRTC-type vertical sync width independent helper function
|
||||
/// </summary>
|
||||
protected override int R3_VerticalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
// Bits 7..4 define Vertical Sync Width
|
||||
// on CRTC3 if 0 is programmed this gives 16 lines of VSYNC
|
||||
return ((Register[R3_SYNC_WIDTHS] >> 4) & 0x0F) == 0 ? 16 : Register[R3_SYNC_WIDTHS] >> 4 & 0x0F;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R8: CRTC-type CUDISP Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected override int R8_Skew_CUDISP
|
||||
{
|
||||
get
|
||||
{
|
||||
// CRTC3
|
||||
// Bits 7..6 define the skew (delay) of the CUDISP signal
|
||||
// 00 = 0
|
||||
// 01 = 1
|
||||
// 10 = 2
|
||||
// 11 = non-output
|
||||
return (Register[R8_INTERLACE_MODE] >> 6) & 0x03;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R8: CRTC-type CUDISP Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected override int R8_Skew_DISPTMG
|
||||
{
|
||||
get
|
||||
{
|
||||
// CRTC3
|
||||
// Bits 5..4 define the skew (delay) of the DISPTMG signal
|
||||
// 00 = 0
|
||||
// 01 = 1
|
||||
// 10 = 2
|
||||
// 11 = non-output
|
||||
return ((Register[R8_INTERLACE_MODE] & 0b0011_0000) >> 4) & 0x03;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to read from the currently selected register
|
||||
/// </summary>
|
||||
|
|
|
@ -240,6 +240,67 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// R3l: CRTC-type horizontal sync width independent helper function
|
||||
/// </summary>
|
||||
protected override int R3_HorizontalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
// Bits 3..0 define Horizontal Sync Width
|
||||
// on CRTC4, a zero value means 16 characters of HSYNC are generated
|
||||
return (Register[R3_SYNC_WIDTHS] & 0x0F) == 0 ? 16 : Register[R3_SYNC_WIDTHS] & 0x0F;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R3h: CRTC-type vertical sync width independent helper function
|
||||
/// </summary>
|
||||
protected override int R3_VerticalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
// Bits 7..4 define Vertical Sync Width
|
||||
// on CRTC4 if 0 is programmed this gives 16 lines of VSYNC
|
||||
return ((Register[R3_SYNC_WIDTHS] >> 4) & 0x0F) == 0 ? 16 : Register[R3_SYNC_WIDTHS] >> 4 & 0x0F;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R8: CRTC-type CUDISP Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected override int R8_Skew_CUDISP
|
||||
{
|
||||
get
|
||||
{
|
||||
// CRTC4
|
||||
// Bits 7..6 define the skew (delay) of the CUDISP signal
|
||||
// 00 = 0
|
||||
// 01 = 1
|
||||
// 10 = 2
|
||||
// 11 = non-output
|
||||
return (Register[R8_INTERLACE_MODE] >> 6) & 0x03;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R8: CRTC-type CUDISP Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected override int R8_Skew_DISPTMG
|
||||
{
|
||||
get
|
||||
{
|
||||
// CRTC4
|
||||
// Bits 5..4 define the skew (delay) of the DISPTMG signal
|
||||
// 00 = 0
|
||||
// 01 = 1
|
||||
// 10 = 2
|
||||
// 11 = non-output
|
||||
return ((Register[R8_INTERLACE_MODE] & 0b0011_0000) >> 4) & 0x03;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to read from the currently selected register
|
||||
/// </summary>
|
||||
|
|
|
@ -349,7 +349,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
protected byte StatusRegister;
|
||||
|
||||
/// <summary>
|
||||
/// CRTC-type horizontal total independent helper function
|
||||
/// R0: CRTC-type horizontal total independent helper function
|
||||
/// </summary>
|
||||
protected virtual int R0_HorizontalTotal
|
||||
{
|
||||
|
@ -361,7 +361,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// CRTC-type horizontal displayed independent helper function
|
||||
/// R1: CRTC-type horizontal displayed independent helper function
|
||||
/// </summary>
|
||||
protected virtual int R1_HorizontalDisplayed
|
||||
{
|
||||
|
@ -373,7 +373,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// CRTC-type horizontal sync position independent helper function
|
||||
/// R2: CRTC-type horizontal sync position independent helper function
|
||||
/// </summary>
|
||||
protected virtual int R2_HorizontalSyncPosition
|
||||
{
|
||||
|
@ -385,71 +385,17 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// CRTC-type horizontal sync width independent helper function
|
||||
/// R3l: CRTC-type horizontal sync width independent helper function
|
||||
/// </summary>
|
||||
protected virtual int R3_HorizontalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
int swr;
|
||||
|
||||
// Bits 3..0 define Horizontal Sync Width
|
||||
int sw = Register[R3_SYNC_WIDTHS] & 0x0F;
|
||||
|
||||
switch (CrtcType)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
// If 0 is programmed no HSYNC is generated
|
||||
swr = sw;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
default:
|
||||
// If 0 is programmed this gives a HSYNC width of 16
|
||||
swr = sw > 0 ? sw : 16;
|
||||
break;
|
||||
}
|
||||
|
||||
return swr;
|
||||
}
|
||||
}
|
||||
protected virtual int R3_HorizontalSyncWidth { get; }
|
||||
|
||||
/// <summary>
|
||||
/// CRTC-type vertical sync width independent helper function
|
||||
/// R3h: CRTC-type vertical sync width independent helper function
|
||||
/// </summary>
|
||||
protected virtual int R3_VerticalSyncWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
int swr;
|
||||
|
||||
//Bits 7..4 define Vertical Sync Width
|
||||
int sw = (Register[R3_SYNC_WIDTHS] >> 4) & 0x0F;
|
||||
|
||||
switch (CrtcType)
|
||||
{
|
||||
case 0:
|
||||
case 3:
|
||||
case 4:
|
||||
default:
|
||||
// If 0 is programmed this gives 16 lines of VSYNC
|
||||
swr = sw > 0 ? sw : 16;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
// Vertical Sync is fixed at 16 lines
|
||||
swr = 16;
|
||||
break;
|
||||
}
|
||||
|
||||
return swr;
|
||||
}
|
||||
}
|
||||
protected virtual int R3_VerticalSyncWidth { get; }
|
||||
|
||||
/// <summary>
|
||||
/// CRTC-type vertical total independent helper function
|
||||
/// R4: CRTC-type vertical total independent helper function
|
||||
/// </summary>
|
||||
protected virtual int R4_VerticalTotal
|
||||
{
|
||||
|
@ -461,7 +407,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// CRTC-type vertical total adjust independent helper function
|
||||
/// R5: CRTC-type vertical total adjust independent helper function
|
||||
/// </summary>
|
||||
protected virtual int R5_VerticalTotalAdjust
|
||||
{
|
||||
|
@ -473,7 +419,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// CRTC-type vertical displayed independent helper function
|
||||
/// R6: CRTC-type vertical displayed independent helper function
|
||||
/// </summary>
|
||||
protected virtual int R6_VerticalDisplayed
|
||||
{
|
||||
|
@ -485,7 +431,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// CRTC-type vertical sync position independent helper function
|
||||
/// R7: CRTC-type vertical sync position independent helper function
|
||||
/// </summary>
|
||||
protected virtual int R7_VerticalSyncPosition
|
||||
{
|
||||
|
@ -497,68 +443,31 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// CRTC-type DISPTMG Active Display Skew helper function
|
||||
/// R8: CRTC-type CUDISP Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected virtual int R8_Skew
|
||||
{
|
||||
get
|
||||
{
|
||||
int skew = 0;
|
||||
switch (CrtcType)
|
||||
{
|
||||
case 0:
|
||||
// For Hitachi HD6845:
|
||||
// 0 = no skew
|
||||
// 1 = one-character skew
|
||||
// 2 = two-character skew
|
||||
// 3 = non-output
|
||||
skew = (Register[R8_INTERLACE_MODE] >> 4) & 0x03;
|
||||
break;
|
||||
case 1:
|
||||
// skew not implemented
|
||||
break;
|
||||
case 2:
|
||||
// skew not implemented
|
||||
break;
|
||||
default:
|
||||
return skew;
|
||||
}
|
||||
return skew;
|
||||
}
|
||||
}
|
||||
protected virtual int R8_Skew_CUDISP { get; }
|
||||
|
||||
/// <summary>
|
||||
/// CRTC-type Interlace Mode helper function
|
||||
/// R8: CRTC-type DISPTMG Active Display Skew helper function
|
||||
/// </summary>
|
||||
protected virtual int R8_Skew_DISPTMG { get; }
|
||||
|
||||
/// <summary>
|
||||
/// R8: CRTC-type Interlace Mode helper function
|
||||
/// </summary>
|
||||
protected virtual int R8_Interlace
|
||||
{
|
||||
get
|
||||
{
|
||||
int interlace = 0;
|
||||
switch (CrtcType)
|
||||
{
|
||||
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
// 0 = Non-interlace
|
||||
// 1 = Interlace SYNC Raster Scan
|
||||
// 2 = Interlace SYNC and Video Raster Scan
|
||||
interlace = Register[R8_INTERLACE_MODE] & 0x03;
|
||||
if (!interlace.Bit(0))
|
||||
{
|
||||
interlace = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return interlace;
|
||||
// 0 = Non-interlace
|
||||
// 1 = Interlace SYNC Raster Scan
|
||||
// 2 = Interlace SYNC and Video Raster Scan
|
||||
return Register[R8_INTERLACE_MODE] & 0x03;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Max Scanlines
|
||||
/// R9: Max Scanlines
|
||||
/// </summary>
|
||||
protected virtual int R9_MaxScanline
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue