-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from citee520/main
add mapper33
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {Mapper, MapperOptions} from './mapper' | ||
import {MirrorMode} from '../ppu/types' | ||
|
||
export class Mapper033 extends Mapper { | ||
public static create(options: MapperOptions): Mapper { | ||
return new Mapper033(options) | ||
} | ||
|
||
constructor(options: MapperOptions) { | ||
super(options) | ||
|
||
const BANK_BIT = 13 // 0x2000 | ||
const maxPrg = (options.cartridge!.prgRom.byteLength >> BANK_BIT) - 1 | ||
const kLast2Bank = maxPrg - 1 | ||
|
||
this.options.setPrgBank(0, 0) | ||
this.options.setPrgBank(1, 1) | ||
this.options.setPrgBank(2, kLast2Bank) | ||
this.options.setPrgBank(3, kLast2Bank+1) | ||
|
||
|
||
// Chr ROM bank | ||
this.options.setWriteMemory(0x8000, 0xffff, (adr, value) => { | ||
switch (adr & 0xa003) { | ||
case 0x8000: | ||
this.options.setPrgBank(0, value & 0x3f) | ||
this.options.setMirrorMode((value & 0x40) === 0x40 ? MirrorMode.HORZ : MirrorMode.VERT) | ||
break | ||
case 0x8001: | ||
this.options.setPrgBank(1, value & 0x3f) | ||
break | ||
case 0x8002: | ||
this.options.setChrBankOffset(0, value*2) | ||
this.options.setChrBankOffset(1, value*2+1) | ||
break | ||
case 0x8003: | ||
this.options.setChrBankOffset(2, value*2) | ||
this.options.setChrBankOffset(3, value*2+1) | ||
break | ||
case 0xa000: case 0xa001: case 0xa002: case 0xa003: | ||
this.options.setChrBankOffset(4 + (adr & 0x03), value) | ||
break | ||
} | ||
}) | ||
} | ||
} |
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