Skip to content

Commit

Permalink
Merge pull request #34 from citee520/main
Browse files Browse the repository at this point in the history
add mapper33
  • Loading branch information
tyfkda committed Jul 20, 2023
2 parents 30a8363 + b789294 commit cba3329
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/nes/mapper/mapper033.ts
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
}
})
}
}
2 changes: 2 additions & 0 deletions src/nes/mapper/mapper_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {Mapper019} from './mapper019'
import {Mapper023, Mapper025} from './mapper023'
import {Mapper024, Mapper026} from './mapper024'
import {Mapper032} from './mapper032'
import {Mapper033} from './mapper033'
import {Mapper066} from './mapper066'
import {Mapper069} from './mapper069'
import {Mapper073} from './mapper073'
Expand All @@ -37,6 +38,7 @@ export const kMapperTable: Record<number, (options: MapperOptions) => Mapper> =
26: Mapper026.create,
30: Mapper030.create,
32: Mapper032.create,
33: Mapper033.create,
66: Mapper066.create,
69: Mapper069.create,
73: Mapper073.create, // INES Mapper 073: Konami VRC3
Expand Down

0 comments on commit cba3329

Please sign in to comment.