mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-01-08 16:31:38 +00:00
5a7a3b5019
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
// <copyright file="CharacterDefinition.cs" company="Adrian Conlon">
|
|
// Copyright (c) Adrian Conlon. All rights reserved.
|
|
// </copyright>
|
|
namespace EightBit.GameBoy
|
|
{
|
|
public sealed class CharacterDefinition
|
|
{
|
|
private readonly Ram vram;
|
|
private readonly ushort address;
|
|
|
|
public CharacterDefinition(Ram vram, ushort address)
|
|
{
|
|
this.vram = vram;
|
|
this.address = address;
|
|
}
|
|
|
|
public int[] Get(int row)
|
|
{
|
|
var returned = new int[8];
|
|
|
|
var planeAddress = (ushort)(this.address + (row * 2));
|
|
|
|
var planeLow = this.vram.Peek(planeAddress);
|
|
var planeHigh = this.vram.Peek(++planeAddress);
|
|
|
|
for (var bit = 0; bit < 8; ++bit)
|
|
{
|
|
var mask = 1 << bit;
|
|
|
|
var bitLow = (planeLow & mask) != 0 ? 1 : 0;
|
|
var bitHigh = (planeHigh & mask) != 0 ? 0b10 : 0;
|
|
|
|
returned[7 - bit] = bitHigh | bitLow;
|
|
}
|
|
|
|
return returned;
|
|
}
|
|
}
|
|
}
|