def readGasFromRom(self, rom): with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_GAS_GFX))) self._gas_gfx.readFromBlock(cb) with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_GAS_ARR))) self._gas_arr.readFromBlock(cb) with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_GAS_PAL1))) self._gas_pal1.readFromBlock(cb) with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_GAS_PAL2))) self._gas_pal2.readFromBlock(cb) with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_GAS_PAL3))) self._gas_pal3.readFromBlock(cb)
def readTownMapIconsFromRom(self, rom): self._townmap_icons_pal.readFromBlock(rom, loc=EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_TOWN_MAP_ICON_PAL))) with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_TOWN_MAP_ICON_GFX))) self._townmap_icons.readFromBlock(cb)
def readFromRom(self, rom): self._bbgTbl.readFromRom(rom) pct = 50.0/(6+self._bbgTbl.height()) self._bbgGfxPtrTbl.readFromRom(rom, EbModule.toRegAddr(EbModule.readAsmPointer(rom, self._ASMPTRS_GFX[0]))) updateProgress(pct) self._bbgArrPtrTbl.readFromRom(rom, EbModule.toRegAddr(EbModule.readAsmPointer(rom, self._ASMPTRS_ARR[0]))) updateProgress(pct) self._bbgPalPtrTbl.readFromRom(rom, EbModule.toRegAddr(EbModule.readAsmPointer(rom, self._ASMPTRS_PAL[0]))) updateProgress(pct) self._bbgGfxArrs = [ None for i in range(self._bbgGfxPtrTbl.height()) ] self._bbgPals = [ None for i in range(self._bbgPalPtrTbl.height()) ] updateProgress(pct) self._bbgScrollTbl.readFromRom(rom) updateProgress(pct) self._bbgDistorTbl.readFromRom(rom) updateProgress(pct) for i in range(self._bbgTbl.height()): gfxNum = self._bbgTbl[i,0].val() colorDepth = self._bbgTbl[i,2].val() if (self._bbgGfxArrs[gfxNum] == None): # Max size used in rom: 421 (2bpp) 442 (4bpp) tg = EbTileGraphics(512, 8, colorDepth) with EbCompressedData() as tgb: tgb.readFromRom(rom, EbModule.toRegAddr( self._bbgGfxPtrTbl[gfxNum,0].val())) tg.readFromBlock(tgb) a = EbArrangement(32, 32) with EbCompressedData() as ab: ab.readFromRom(rom, EbModule.toRegAddr( self._bbgArrPtrTbl[gfxNum,0].val())) a.readFromBlock(ab) self._bbgGfxArrs[gfxNum] = (tg, a) palNum = self._bbgTbl[i,1].val() if (self._bbgPals[palNum] == None): with DataBlock(32) as pb: pb.readFromRom(rom, EbModule.toRegAddr(self._bbgPalPtrTbl[palNum,0].val())) p = EbPalettes(1, 16) p.readFromBlock(pb) self._bbgPals[palNum] = p updateProgress(pct)
def readCreditsFontFromRom(self, rom): self._cpal.readFromBlock(rom, loc=self._ADDR_CREDITS_PAL) with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer( rom, self._ASMPTR_CREDITS_GFX))) self._cfont.readFromBlock(cb)
def readFromRom(self, rom): with EbCompressedData() as gb: gb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._gfxPtrLoc))) self._gfx.readFromBlock(gb) with EbCompressedData() as ab: ab.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._arrPtrLoc))) self._arr.readFromBlock(ab) with EbCompressedData() as pb: pb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._palPtrLoc))) self._pals.readFromBlock(pb) # The first color of every subpalette after subpal0 is ignored and # drawn as the first color of subpal0 instead c = self._pals[0,0] for i in range(1,len(self._pals)): self._pals[i,0] = c
def readFromRom(self, rom): self._bsPtrTbl.readFromRom(rom, EbModule.toRegAddr(EbModule.readAsmPointer(rom, self._ASMPTR_GFX))) self._bsPalsTable.readFromRom(rom, EbModule.toRegAddr(EbModule.readAsmPointer(rom, self._ASMPTR_PAL))) pct = 45.0/(self._bsPtrTbl.height() + self._bsPalsTable.height() + 1) self._enemyCfgTable.readFromRom(rom) updateProgress(pct) # Read the palettes for i in range(self._bsPalsTable.height()): pal = EbPalettes(1,16) pal.set(0, self._bsPalsTable[i,0].val()) self._bsPals.append(pal) updateProgress(pct) # Read the sprites for i in range(self._bsPtrTbl.height()): with EbCompressedData() as bsb: bsb.readFromRom(rom, EbModule.toRegAddr(self._bsPtrTbl[i,0].val())) bs = EbBattleSprite() bs.readFromBlock(bsb, self._bsPtrTbl[i,1].val()) self._bsprites.append(bs) updateProgress(pct) # Read the group data self._enemyGroupTbl.readFromRom(rom) self._enemyGroupBgTbl.readFromRom(rom) self._enemyGroups = [ ] pct = 5.0/self._enemyGroupTbl.height() for i in range(self._enemyGroupTbl.height()): group = [ ] ptr = EbModule.toRegAddr(self._enemyGroupTbl[i,0].val()) while(rom[ptr] != 0xff): group.append((rom.readMulti(ptr+1,2), rom[ptr])) ptr += 3 self._enemyGroups.append(group) updateProgress(pct)
def readFromRom(self, rom): with EbCompressedData() as tgb1: tgb1.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_1))) self._gfx1.readFromBlock(tgb1) updateProgress(20) with EbCompressedData() as tgb2: tgb2.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_2))) self._gfx2.readFromBlock(tgb2) updateProgress(20) # Read palettes loc = 0x201fc8 for pal in self._flavPals: pal.readFromBlock(rom, loc=loc) loc += 64 updateProgress(5) # Read names for ptr, field in self._flavNames: field.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, ptr))) updateProgress(5)
def readFromRom(self, rom): self._ptrTbl.readFromRom(rom, EbModule.toRegAddr(EbModule.readAsmPointer(rom, self._ASMPTR_PTR_TBL))) updateProgress(5) for i in range(self._ptrTbl.height()): loc = EbModule.toRegAddr(self._ptrTbl[i,0].val()) entry = [] while True: x = rom[loc] if x == 0xff: break y = rom[loc+1] icon = rom[loc+2] flag = rom.readMulti(loc+3, 2) entry.append((x, y, icon, flag)) loc += 5 self._entries.append(entry) i += 1 updateProgress(45)
def readProducedPresentedFromRom(self, rom): with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_PRODUCED_PAL))) self._produced_pal.readFromBlock(cb) with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_PRODUCED_GFX))) self._produced_gfx.readFromBlock(cb) with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_PRODUCED_ARR))) self._produced_arr.readFromBlock(cb) with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_PRESENTED_PAL))) self._presented_pal.readFromBlock(cb) with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_PRESENTED_GFX))) self._presented_gfx.readFromBlock(cb) with EbCompressedData() as cb: cb.readFromRom(rom, EbModule.toRegAddr( EbModule.readAsmPointer(rom, self._ASMPTR_PRESENTED_ARR))) self._presented_arr.readFromBlock(cb)