-
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
Showing
83 changed files
with
2,238 additions
and
1,488 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
12 changes: 7 additions & 5 deletions
12
core/src/main/kotlin/br/tiagohm/nestalgia/core/BandaiMicrophone.kt
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
58 changes: 58 additions & 0 deletions
58
core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc830425C4391T.kt
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,58 @@ | ||
package br.tiagohm.nestalgia.core | ||
|
||
// https://www.nesdev.org/wiki/NES_2.0_Mapper_320 | ||
|
||
class Bmc830425C4391T(console: Console) : Mapper(console) { | ||
|
||
override val prgPageSize = 0x4000 | ||
|
||
override val chrPageSize = 0x2000 | ||
|
||
@Volatile private var innerReg = 0 | ||
@Volatile private var outerReg = 0 | ||
@Volatile private var prgMode = false | ||
|
||
override fun initialize() { | ||
selectChrPage(0, 0) | ||
updateState() | ||
} | ||
|
||
private fun updateState() { | ||
if (prgMode) { | ||
// UNROM mode | ||
selectPrgPage(0, (innerReg and 0x07) or (outerReg shl 3)) | ||
selectPrgPage(1, 0x07 or (outerReg shl 3)) | ||
} else { | ||
// UOROM mode | ||
selectPrgPage(0, innerReg or (outerReg shl 3)) | ||
selectPrgPage(1, 0x0F or (outerReg shl 3)) | ||
} | ||
} | ||
|
||
override fun writeRegister(addr: Int, value: Int) { | ||
innerReg = value and 0x0F | ||
|
||
if (addr and 0xFFE0 == 0xF0E0) { | ||
outerReg = addr and 0x0F | ||
prgMode = (addr shr 4).bit0 | ||
} | ||
|
||
updateState() | ||
} | ||
|
||
override fun saveState(s: Snapshot) { | ||
super.saveState(s) | ||
|
||
s.write("innerReg", innerReg) | ||
s.write("outerReg", outerReg) | ||
s.write("prgMode", prgMode) | ||
} | ||
|
||
override fun restoreState(s: Snapshot) { | ||
super.restoreState(s) | ||
|
||
innerReg = s.readInt("innerReg") | ||
outerReg = s.readInt("outerReg") | ||
prgMode = s.readBoolean("prgMode") | ||
} | ||
} |
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,53 @@ | ||
package br.tiagohm.nestalgia.core | ||
|
||
// https://wiki.nesdev.com/w/index.php/INES_Mapper_366 | ||
|
||
class BmcGn45(console: Console) : MMC3(console) { | ||
|
||
@Volatile private var selectedBlock = 0 | ||
@Volatile private var wramEnabled = false | ||
|
||
override val registerStartAddress = 0x6000 | ||
|
||
override val registerEndAddress = 0xFFFF | ||
|
||
override fun reset(softReset: Boolean) { | ||
super.reset(softReset) | ||
|
||
if (softReset) { | ||
selectedBlock = 0 | ||
wramEnabled = false | ||
resetMMC3() | ||
updateState() | ||
} | ||
} | ||
|
||
override fun selectChrPage(slot: Int, page: Int, memoryType: ChrMemoryType) { | ||
super.selectChrPage(slot, (page and 0x7F) or (selectedBlock shl 3), memoryType) | ||
} | ||
|
||
override fun selectPrgPage(slot: Int, page: Int, memoryType: PrgMemoryType) { | ||
super.selectPrgPage(slot, (page and 0x0F) or selectedBlock, memoryType) | ||
} | ||
|
||
override fun writeRegister(addr: Int, value: Int) { | ||
if (addr < 0x7000) { | ||
if (!wramEnabled) { | ||
selectedBlock = addr and 0x30 | ||
wramEnabled = addr.bit7 | ||
updateState() | ||
} else { | ||
writePrgRam(addr, value) | ||
} | ||
} else if (addr < 0x8000) { | ||
if (!wramEnabled) { | ||
selectedBlock = value and 0x30 | ||
updateState() | ||
} else { | ||
writePrgRam(addr, value) | ||
} | ||
} else { | ||
super.writeRegister(addr, value) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.