-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93042ae
commit e8a8b8f
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using Hardware.Memory; | ||
using System.Drawing; | ||
|
||
namespace Commodore64 { | ||
public class VicIi { | ||
|
||
public enum TvSystem { | ||
NTSC, | ||
PAL | ||
} | ||
|
||
public TvSystem CurrentTvSystem = TvSystem.PAL; | ||
|
||
public const int FULL_WIDTH = 504; | ||
public const int FULL_WIDTH_CYCLES = 63; | ||
public const int USABLE_WIDTH_BORDER = 403; | ||
public const int USABLE_WIDTH = 320; | ||
public const int USABLE_WIDTH_CYCLES = 40; | ||
|
||
public const int FULL_HEIGHT_NTSC = 262; | ||
public const int FULL_HEIGHT_PAL = 312; | ||
public const int USABLE_HEIGHT = 200; | ||
public const int USABLE_HEIGHT_BORDER = 284; | ||
public int CurrentLine = 0; | ||
public int CurrentLineCycle = 0; | ||
|
||
public int TotalCycles = 0; | ||
|
||
public Color[] ScreenBufferPixels = new Color[USABLE_WIDTH_BORDER * USABLE_HEIGHT_BORDER]; | ||
|
||
public bool ScreenOn => (Read(0xD011) & 0b00010000) == 1; | ||
|
||
|
||
private readonly IMemory<byte> _bus; | ||
|
||
|
||
public VicIi(IMemory<byte> bus) { | ||
_bus = bus; | ||
} | ||
|
||
public void Cycle() { | ||
|
||
|
||
CurrentLineCycle++; | ||
|
||
if (CurrentLineCycle == 64) { | ||
CurrentLineCycle = 0; | ||
|
||
CurrentLine++; | ||
|
||
if ((CurrentTvSystem == TvSystem.PAL && CurrentLine == FULL_HEIGHT_PAL) || | ||
(CurrentTvSystem == TvSystem.NTSC && CurrentLine == FULL_HEIGHT_NTSC)) { | ||
|
||
CurrentLine = 0; | ||
} | ||
} | ||
|
||
UpdateScreenBufferPixels(); | ||
|
||
TotalCycles++; | ||
} | ||
|
||
private void UpdateScreenBufferPixels() { | ||
|
||
} | ||
|
||
public byte Read(int address) { | ||
return _bus[address]; | ||
} | ||
} | ||
} |