(self)
| 599 | return True |
| 600 | |
| 601 | def init(self) -> bool: |
| 602 | try: |
| 603 | assert self.parent_view is not None |
| 604 | hdr = self.parent_view.read(0, 16) |
| 605 | self.rom_banks = struct.unpack("B", hdr[4:5])[0] |
| 606 | self.vrom_banks = struct.unpack("B", hdr[5:6])[0] |
| 607 | self.rom_flags = struct.unpack("B", hdr[6:7])[0] |
| 608 | self.mapper_index = struct.unpack("B", hdr[7:8])[0] | (self.rom_flags >> 4) |
| 609 | self.ram_banks = struct.unpack("B", hdr[8:9])[0] |
| 610 | self.rom_offset = 16 |
| 611 | if self.rom_flags & 4: |
| 612 | self.rom_offset += 512 |
| 613 | self.rom_length = self.rom_banks * 0x4000 |
| 614 | |
| 615 | # Add mapping for RAM and hardware registers, not backed by file contents |
| 616 | self.add_auto_segment( |
| 617 | 0, 0x8000, 0, 0, SegmentFlag.SegmentReadable | SegmentFlag.SegmentWritable | SegmentFlag.SegmentExecutable |
| 618 | ) |
| 619 | |
| 620 | # Add ROM mappings |
| 621 | assert self.__class__.bank is not None |
| 622 | self.add_auto_segment( |
| 623 | 0x8000, 0x4000, self.rom_offset + (self.__class__.bank * 0x4000), 0x4000, |
| 624 | SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable |
| 625 | ) |
| 626 | self.add_auto_segment( |
| 627 | 0xc000, 0x4000, self.rom_offset + self.rom_length - 0x4000, 0x4000, |
| 628 | SegmentFlag.SegmentReadable | SegmentFlag.SegmentExecutable |
| 629 | ) |
| 630 | |
| 631 | nmi = struct.unpack("<H", self.read(0xfffa, 2))[0] |
| 632 | start = struct.unpack("<H", self.read(0xfffc, 2))[0] |
| 633 | irq = struct.unpack("<H", self.read(0xfffe, 2))[0] |
| 634 | self.define_auto_symbol(Symbol(SymbolType.FunctionSymbol, nmi, "_nmi")) |
| 635 | self.define_auto_symbol(Symbol(SymbolType.FunctionSymbol, start, "_start")) |
| 636 | self.define_auto_symbol(Symbol(SymbolType.FunctionSymbol, irq, "_irq")) |
| 637 | self.add_function(nmi) |
| 638 | self.add_function(irq) |
| 639 | self.add_entry_point(start) |
| 640 | |
| 641 | # Hardware registers |
| 642 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x2000, "PPUCTRL")) |
| 643 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x2001, "PPUMASK")) |
| 644 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x2002, "PPUSTATUS")) |
| 645 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x2003, "OAMADDR")) |
| 646 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x2004, "OAMDATA")) |
| 647 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x2005, "PPUSCROLL")) |
| 648 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x2006, "PPUADDR")) |
| 649 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x2007, "PPUDATA")) |
| 650 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4000, "SQ1_VOL")) |
| 651 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4001, "SQ1_SWEEP")) |
| 652 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4002, "SQ1_LO")) |
| 653 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4003, "SQ1_HI")) |
| 654 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4004, "SQ2_VOL")) |
| 655 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4005, "SQ2_SWEEP")) |
| 656 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4006, "SQ2_LO")) |
| 657 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4007, "SQ2_HI")) |
| 658 | self.define_auto_symbol(Symbol(SymbolType.DataSymbol, 0x4008, "TRI_LINEAR")) |
no test coverage detected