-Added Read/WriteMemory to the STIC so that it can access the RAM it needs to draw the screen.

--Did the same for the PSG because why not.
-Discovered that the Commando HLT happens after the CPU goes idle, so there's no point in further investigating the issue until I emulate that.
-Parsed the BACKTAB cards for the STIC's Draw().
-Attempted to draw the screen using the aforementioned cards.
--I'm only trying to apply color to the foreground.
---Instead of converting the FG color to RGBA, I'm making it all white for now.
--There's clearly some sanity to what's being drawn, so I think each 8x8 card is being drawn in the right place.
--I think the next step is trying to make each individual card draw properly.
--I believe the algorithm for populating the FrameBuffer is VERY inefficient in the way it accesses memory. Will need some suggestions as to how I can rewrite this.
This commit is contained in:
brandman211 2012-09-06 04:51:17 +00:00
parent a85dadcf7d
commit 06022c9076
5 changed files with 114 additions and 7 deletions

View File

@ -93,8 +93,8 @@ namespace BizHawk.Emulation.CPUs.CP1610
public int Execute()
{
/*
Take an interrupt if the previous instruction was interruptible,
interrupts are enabled, and IntRM has a falling edge.
Take an interrupt if the previous instruction was interruptible,
interrupts are enabled, and IntRM has a falling edge.
*/
if (FlagI && Interruptible && !IntRM && !Interrupted)
{

View File

@ -65,9 +65,13 @@ namespace BizHawk.Emulation.Consoles.Intellivision
Cpu.Reset();
Stic = new STIC();
Stic.ReadMemory = ReadMemory;
Stic.WriteMemory = WriteMemory;
Stic.Reset();
Psg = new PSG();
Psg.ReadMemory = ReadMemory;
Psg.WriteMemory = WriteMemory;
Connect();

View File

@ -45,7 +45,7 @@ namespace BizHawk.Emulation.Consoles.Intellivision
break;
break;
case 0x1000:
core = ExecutiveRom[addr - 0x1000];
core = (ushort)(ExecutiveRom[addr - 0x1000] & 0x3FF);
break;
case 0x3000:
if (addr <= 0x37FF)

View File

@ -9,6 +9,12 @@ namespace BizHawk.Emulation.Consoles.Intellivision
{
private ushort[] Register = new ushort[16];
public int TotalExecutedCycles;
public int PendingCycles;
public Func<ushort, ushort> ReadMemory;
public Func<ushort, ushort, bool> WriteMemory;
public ushort? ReadPSG(ushort addr)
{
if (addr >= 0x01F0 && addr <= 0x01FF)

View File

@ -13,10 +13,20 @@ namespace BizHawk.Emulation.Consoles.Intellivision
public int TotalExecutedCycles;
public int PendingCycles;
public int[] FrameBuffer = new int[160 * 96];
public int[] GetVideoBuffer() { return FrameBuffer; }
public int VirtualWidth { get { return 160; } }
public int BufferWidth { get { return 160; } }
public Func<ushort, ushort> ReadMemory;
public Func<ushort, ushort, bool> WriteMemory;
public int[] FrameBuffer = new int[159 * 96];
public int[] GetVideoBuffer()
{
Background();
Mobs();
return FrameBuffer;
}
public int VirtualWidth { get { return 159; } }
public int BufferWidth { get { return 159; } }
public int VirtualHeight { get { return 192; } }
public int BufferHeight { get { return 96; } }
public int BackgroundColor { get { return 0; } }
@ -160,5 +170,92 @@ namespace BizHawk.Emulation.Consoles.Intellivision
PendingCycles -= cycles;
TotalExecutedCycles += cycles;
}
public int ColorToRGBA(int color)
{
return 0xFFFFFF;
}
public void Background()
{
// The background is a 20x12 grid of "cards".
for (int card_row = 0; card_row < 12; card_row++)
{
for (int card_col = 0; card_col < 20; card_col++)
{
// The cards are stored sequentially in the System RAM.
ushort card = ReadMemory((ushort)(0x0200 +
(card_row * 20) + card_col));
// Parse data from the card.
bool gram = ((card & 0x0800) != 0);
int card_num = card >> 3;
int fg = card & 0x0004;
if (Fgbg)
{
int bg = ((card >> 9) & 0x0008) |
((card >> 11) & 0x0004) |
((card >> 9) & 0x0002);
/*
Only 64 of the GROM's cards can be used in FGBG
Mode.
*/
card_num &= 0x0020;
}
else
{
bool advance = ((card & 0x2000) != 0);
if (gram)
{
// GRAM only has 64 cards.
card_num &= 0x0020;
fg |= (card >> 9) & 0x0008;
}
else
/*
All of the GROM's 256 cards can be used in Color
Stack Mode.
*/
card_num &= 0x0080;
}
// Each picture is 8x8 pixels.
for (int pict_row = 0; pict_row < 8; pict_row++)
{
/*
Each picture is stored sequentially in the GROM / GRAM,
and so are their rows.
*/
int row_mem = (card_num * 8) + (pict_row * 8);
byte row;
if (gram)
row = (byte)ReadMemory((ushort)(0x3800 +
row_mem));
else
row = (byte)ReadMemory((ushort)(0x3000 +
row_mem));
for (int pict_col = 0; pict_col < 8; pict_col++)
{
// The rightmost column does not get displayed.
if (card_col == 19 && pict_col == 0)
continue;
// If the pixel is on, give it the FG color.
if ((row & 0x1) != 0)
/*
The pixels go right as the bits get less
significant.
*/
FrameBuffer[((card_row * 159 * 8) + (card_col * 8) +
(pict_row * 159) + (7 - pict_col))] =
ColorToRGBA(fg);
row >>= 1;
}
}
}
}
}
public void Mobs()
{
// TODO
}
}
}