-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adding support for NES2.0 headers - IREM-G101 chip/board
- Loading branch information
Showing
6 changed files
with
163 additions
and
4 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
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,55 @@ | ||
struct IremG101 : Board { | ||
IremG101(Markup::Node& document) : Board(document), g101(*this, document) { | ||
if(!document["game/board/mirror"]) { | ||
settings.mirror = 0; | ||
} else { | ||
string mirror = document["game/board/mirror/mode"].text(); | ||
if(mirror == "screen-0") settings.mirror = 1; | ||
if(mirror == "screen-1") settings.mirror = 2; | ||
} | ||
} | ||
|
||
auto readPRG(uint addr) -> uint8 { | ||
if((addr & 0x8000) == 0x8000) return prgrom.read(g101.prgAddress(addr)); | ||
if((addr & 0xe000) == 0x6000) return prgram.read(addr & 0x1fff); | ||
return cpu.mdr(); | ||
} | ||
|
||
auto writePRG(uint addr, uint8 data) -> void { | ||
if((addr & 0x8000) == 0x8000) return g101.regWrite(addr, data); | ||
if((addr & 0xe000) == 0x6000) return prgram.write(addr & 0x1fff, data); | ||
} | ||
|
||
auto readCHR(uint addr) -> uint8 { | ||
if(addr & 0x2000) switch(settings.mirror) { | ||
case 0: return ppu.readCIRAM(g101.ciramAddress(addr)); | ||
case 1: return ppu.readCIRAM((addr & 0x03ff) | 0x0000); | ||
case 2: return ppu.readCIRAM((addr & 0x03ff) | 0x0400); | ||
} | ||
return Board::readCHR(g101.chrAddress(addr)); | ||
} | ||
|
||
auto writeCHR(uint addr, uint8 data) -> void { | ||
if(addr & 0x2000) switch(settings.mirror) { | ||
case 0: return ppu.writeCIRAM(g101.ciramAddress(addr), data); | ||
case 1: return ppu.writeCIRAM((addr & 0x03ff) | 0x0000, data); | ||
case 2: return ppu.writeCIRAM((addr & 0x03ff) | 0x0400, data); | ||
} | ||
return Board::writeCHR(g101.chrAddress(addr), data); | ||
} | ||
|
||
auto power(bool reset) -> void { | ||
g101.power(reset); | ||
} | ||
|
||
auto serialize(serializer& s) -> void { | ||
Board::serialize(s); | ||
g101.serialize(s); | ||
} | ||
|
||
struct Settings { | ||
uint2 mirror; //0 = G101-controlled, 1 = screen 0, 2 = screen 1 | ||
} settings; | ||
|
||
G101 g101; | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#include "g101.cpp" | ||
#include "n108.cpp" | ||
#include "n163.cpp" | ||
#include "mmc1.cpp" | ||
|
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,79 @@ | ||
struct G101 : Chip { | ||
G101(Board& board, Markup::Node& boardNode) : Chip(board) { | ||
} | ||
|
||
auto prgAddress(uint addr) const -> uint { | ||
switch(addr & 0xe000) { | ||
case 0x8000: | ||
if(prgMode == 1) return (0x1e << 13) | (addr & 0x1fff); | ||
return (prgBank[0] << 13) | (addr & 0x1fff); | ||
case 0xa000: | ||
return (prgBank[1] << 13) | (addr & 0x1fff); | ||
case 0xc000: | ||
if(prgMode == 0) return (0x1e << 13) | (addr & 0x1fff); | ||
return (prgBank[0] << 13) | (addr & 0x1fff); | ||
case 0xe000: | ||
return (0x1f << 13) | (addr & 0x1fff); | ||
} | ||
unreachable; | ||
} | ||
|
||
auto chrAddress(uint addr) const -> uint { | ||
return (chrBank[addr >> 10] << 10) | (addr & 0x03ff); | ||
} | ||
|
||
auto ciramAddress(uint addr) const -> uint { | ||
switch(mirror) { | ||
case 0: return (addr & 0x03ff) | ((addr & 0x0400) >> 0); | ||
case 1: return (addr & 0x03ff) | ((addr & 0x0800) >> 1); | ||
} | ||
unreachable; | ||
} | ||
|
||
auto regWrite(uint addr, uint8 data) -> void { | ||
switch(addr & 0xf000) { | ||
case 0x8000: | ||
prgBank[0] = data & 0x1f; | ||
break; | ||
case 0x9000: | ||
mirror = data & 0x01; | ||
prgMode = data & 0x02; | ||
break; | ||
case 0xa000: | ||
prgBank[1] = data & 0x1f; | ||
break; | ||
case 0xb000: | ||
chrBank[addr & 0x0007] = data; | ||
break; | ||
} | ||
} | ||
|
||
auto power(bool reset) -> void { | ||
if(!reset) { | ||
prgMode = 0; | ||
prgBank[0] = 0x00; | ||
prgBank[1] = 0x1e; | ||
chrBank[0] = 0; | ||
chrBank[1] = 0; | ||
chrBank[2] = 0; | ||
chrBank[3] = 0; | ||
chrBank[4] = 0; | ||
chrBank[5] = 0; | ||
chrBank[6] = 0; | ||
chrBank[7] = 0; | ||
mirror = 0; | ||
} | ||
} | ||
|
||
auto serialize(serializer& s) -> void { | ||
s.integer(prgMode); | ||
s.array(prgBank); | ||
s.array(chrBank); | ||
s.integer(mirror); | ||
} | ||
|
||
bool prgMode; | ||
uint5 prgBank[2]; | ||
uint8 chrBank[8]; | ||
bool mirror; | ||
}; |
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