Skip to content

Commit

Permalink
[C64] Fix bracket styling
Browse files Browse the repository at this point in the history
  • Loading branch information
SaxxonPike committed Jan 5, 2025
1 parent fb5904f commit 6d353f7
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,21 @@ public Mapper0013(IEnumerable<CartridgeChip> chips)
{
// Maximum 128 banks.
if (chip.Bank is > 0x7F or < 0x00)
{
throw new Exception("Cartridge image has an invalid bank");
}

// Addresses other than 0x8000 are not supported.
if (chip.Address != 0x8000)
{
continue;
}

// Bank wrap-around is based on powers of 2.
while (chip.Bank > _bankMask)
{
_bankMask = unchecked((byte) ((_bankMask << 1) | 1));
}

var bank = new byte[BankSize];

Expand All @@ -61,7 +67,9 @@ public Mapper0013(IEnumerable<CartridgeChip> chips)
_banks[chip.Bank] = bank;

if (chip.Bank > maxBank)
{
maxBank = chip.Bank;
}
}

_bankCount = maxBank + 1;
Expand All @@ -88,7 +96,9 @@ protected override void SyncStateInternal(Serializer ser)
ser.Sync("ROMEnable", ref _romEnable);

if (ser.IsReader)
{
BankSet(_bankNumber | (_romEnable ? 0x00 : 0x80));
}
}

private void BankSet(int index)
Expand All @@ -103,8 +113,10 @@ public override int Peek8000(int addr) =>

public override void PokeDE00(int addr, int val)
{
if (addr == 0x00)
if (addr == 0x00)
{
BankSet(val);
}
}

public override int Read8000(int addr) =>
Expand All @@ -121,8 +133,10 @@ private void UpdateState()

public override void WriteDE00(int addr, int val)
{
if (addr == 0x00)
if (addr == 0x00)
{
BankSet(val);
}
}
}
}

0 comments on commit 6d353f7

Please sign in to comment.