当前位置: 首页>>代码示例>>Python>>正文


Python EbModule类代码示例

本文整理汇总了Python中EbModule的典型用法代码示例。如果您正苦于以下问题:Python EbModule类的具体用法?Python EbModule怎么用?Python EbModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EbModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: readFromRom

 def readFromRom(self, rom):
     # Read map tiles
     map_ptrs_addr = \
         EbModule.toRegAddr(rom.readMulti(self._MAP_PTRS_PTR_ADDR, 3))
     map_addrs = map(lambda x: \
         EbModule.toRegAddr(rom.readMulti(map_ptrs_addr+x*4,4)), \
         range(8))
     self._tiles = map(
             lambda y: rom.readList(map_addrs[y%8] + ((y>>3)<<8),
                 self._MAP_WIDTH).tolist(),
             range(self._MAP_HEIGHT))
     k = self._LOCAL_TSET_ADDR
     for i in range(self._MAP_HEIGHT>>3):
         for j in range(self._MAP_WIDTH):
             self._tiles[i<<3][j] |= (rom[k] & 3) << 8
             self._tiles[(i<<3)|1][j] |= ((rom[k] >> 2) & 3) << 8
             self._tiles[(i<<3)|2][j] |= ((rom[k] >> 4) & 3) << 8
             self._tiles[(i<<3)|3][j] |= ((rom[k] >> 6) & 3) << 8
             self._tiles[(i<<3)|4][j] |= (rom[k+0x3000] & 3) << 8
             self._tiles[(i<<3)|5][j] |= ((rom[k+0x3000] >> 2) & 3) << 8
             self._tiles[(i<<3)|6][j] |= ((rom[k+0x3000] >> 4) & 3) << 8
             self._tiles[(i<<3)|7][j] |= ((rom[k+0x3000] >> 6) & 3) << 8
             k += 1
     updateProgress(25)
     # Read sector data
     self._mapSecTsetPalsTbl.readFromRom(rom)
     updateProgress(25.0/4)
     self._mapSecMusicTbl.readFromRom(rom)
     updateProgress(25.0/4)
     self._mapSecMiscTbl.readFromRom(rom)
     updateProgress(25.0/4)
     self._mapSecTownMapTbl.readFromRom(rom)
     updateProgress(25.0/4)
开发者ID:NichtJens,项目名称:CoilSnake,代码行数:33,代码来源:MapModule.py

示例2: readFromProject

    def readFromProject(self, resourceOpener):
        # Clear the labels dict
        EbModule.labelsDict.clear()
        # Read the summary file
        sumFile = resourceOpener('ccscript/summary', 'txt')
        summary = sumFile.readlines()
        sumFile.close()
        # Only do anything if the summary file is not empty
        if len(summary) > 0:
            self._usedRange = (EbModule.toRegAddr(int(summary[7][30:36], 16)),
                    EbModule.toRegAddr(int(summary[8][30:36], 16)))

            modName = None
            inModuleSection = False # False = before section, True = in section
            for line in summary:
                line = line.rstrip()
                if inModuleSection:
                    if line.startswith('-'):
                        inModuleSection = False
                    else:
                        labelKey = modName + "." + line.split(' ',1)[0]
                        labelVal = int(line[-6:],16)
                        EbModule.labelsDict[labelKey] = labelVal
                elif line.startswith("-") and modName != None:
                    inModuleSection = True
                elif line.startswith("Labels in module "):
                    modName = line[17:]
        updateProgress(50)
开发者ID:NichtJens,项目名称:CoilSnake,代码行数:28,代码来源:CccInterfaceModule.py

示例3: readGasFromRom

 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)
开发者ID:NichtJens,项目名称:CoilSnake,代码行数:31,代码来源:CompressedGraphicsModule.py

示例4: writeToRom

 def writeToRom(self, rom):
     map_ptrs_addr = \
         EbModule.toRegAddr(rom.readMulti(self._MAP_PTRS_PTR_ADDR, 3))
     map_addrs = map(lambda x: \
         EbModule.toRegAddr(rom.readMulti(map_ptrs_addr+x*4,4)), \
         range(8))
     for i in range(self._MAP_HEIGHT):
         rom.write(map_addrs[i%8] + ((i>>3)<<8), map(lambda x: x & 0xff,
             self._tiles[i]))
     k = self._LOCAL_TSET_ADDR
     for i in range(self._MAP_HEIGHT>>3):
         for j in range(self._MAP_WIDTH):
             c = ((self._tiles[i<<3][j] >> 8)
                     | ((self._tiles[(i<<3)|1][j] >> 8) << 2)
                     | ((self._tiles[(i<<3)|2][j] >> 8) << 4)
                     | ((self._tiles[(i<<3)|3][j] >> 8) << 6))
             rom.write(k, c)
             c = ((self._tiles[(i<<3)|4][j] >> 8)
                     | ((self._tiles[(i<<3)|5][j] >> 8) << 2)
                     | ((self._tiles[(i<<3)|6][j] >> 8) << 4)
                     | ((self._tiles[(i<<3)|7][j] >> 8) << 6))
             rom.write(k+0x3000, c)
             k += 1
     updateProgress(25)
     # Write sector data
     self._mapSecTsetPalsTbl.writeToRom(rom)
     updateProgress(25.0/4)
     self._mapSecMusicTbl.writeToRom(rom)
     updateProgress(25.0/4)
     self._mapSecMiscTbl.writeToRom(rom)
     updateProgress(25.0/4)
     self._mapSecTownMapTbl.writeToRom(rom)
     updateProgress(25.0/4)
开发者ID:NichtJens,项目名称:CoilSnake,代码行数:33,代码来源:MapModule.py

示例5: writeToRom

 def writeToRom(self, rom):
     self._ptrTbl.clear(32*40)
     destWriteLoc = 0xF0000
     destRangeEnd = 0xF58EE # TODO Is this correct? Can we go more?
     destLocs = dict()
     emptyEntryPtr = EbModule.toSnesAddr(rom.writeToFree([0, 0]))
     pct = 45.0/(40*32)
     i=0
     for entry in self._entries:
         if (entry == None) or (not entry):
             self._ptrTbl[i,0].setVal(emptyEntryPtr)
         else:
             entryLen = len(entry)
             writeLoc = rom.getFreeLoc(2 + entryLen*5)
             self._ptrTbl[i,0].setVal(EbModule.toSnesAddr(writeLoc))
             rom[writeLoc] = entryLen & 0xff
             rom[writeLoc+1] = entryLen >> 8
             writeLoc += 2
             for door in entry:
                 destWriteLoc += door.writeToRom(rom, writeLoc, destWriteLoc,
                         destRangeEnd, destLocs)
                 writeLoc += 5
         i += 1
         updateProgress(pct)
     self._ptrTbl.writeToRom(rom)
     # Mark any remaining space as free
     if destWriteLoc < destRangeEnd:
         rom.addFreeRanges([(destWriteLoc, destRangeEnd)])
     updateProgress(5)
开发者ID:Herringway,项目名称:CoilSnake,代码行数:29,代码来源:DoorModule.py

示例6: writeToBlock

 def writeToBlock(self, block, loc=0):
     for t in self._tiles:
         if self._bpp == 2:
             loc += EbModule.write2BPPArea(
                     t, block._data, loc, 0, 0)
         elif self._bpp == 4:
             loc += EbModule.write4BPPArea(
                     t, block._data, loc, 0, 0)
开发者ID:jeffman,项目名称:CoilSnake,代码行数:8,代码来源:CompressedGraphicsModule.py

示例7: readCreditsFontFromRom

 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)
开发者ID:NichtJens,项目名称:CoilSnake,代码行数:8,代码来源:FontModule.py

示例8: setFromImage

    def setFromImage(self, img, x, y, pals, palNum, indexed=False):
        # Check for normal tile
        newTile = None
        imgData = img.load()
        if indexed:
            newTile = [
                    array('B',
                        [ imgData[i,j]
                            for j in xrange(y, self._tileSize + y) ])
                        for i in xrange(x, self._tileSize + x) ]
        else:
            newTile = [
                    array('B',
                        [ pals.getColorFromRGB(palNum,imgData[i,j])
                            for j in xrange(y, self._tileSize + y) ])
                        for i in xrange(x, self._tileSize + x) ]
        # Note: newTile is an array of columns

        # Check for non-flipped tile
        try:
            tIndex = self._usedDict[EbModule.hashArea(newTile)]
            return (False, False, tIndex)
        except KeyError:
            pass

        # Check for only horizontally flipped tile
        try:
            tIndex = self._usedDict[EbModule.hashArea(reversed(newTile))]
            return (False, True, tIndex)
        except KeyError:
            pass

        # Check for vertically and horizontally flipped tile
        for col in newTile:
            col.reverse()
        try:
            tIndex = self._usedDict[EbModule.hashArea(reversed(newTile))]
            return (True, True, tIndex)
        except KeyError:
            pass

        # Check for only vertically flipped tile
        tH = EbModule.hashArea(newTile)
        try:
            tIndex = self._usedDict[tH]
            return (True, False, tIndex)
        except KeyError:
            pass

        # We need to add a new tile
        if self._usedTiles >= self._numTiles:
            # TODO ERROR: Not enough room for a new tile
            return (False, False, 0)
        # Remember, newTile is still vflipped
        self._tiles.append(newTile)
        self._usedDict[tH] = self._usedTiles
        self._usedTiles += 1
        return (True, False, self._usedTiles-1)
开发者ID:jeffman,项目名称:CoilSnake,代码行数:58,代码来源:CompressedGraphicsModule.py

示例9: readFromBlock

 def readFromBlock(self, block, width, height, loc=0):
     self._w = width
     self._h = height
     self._data = map(lambda x: array('B', [0] * self._h),
             range(self._w))
     for i in range(self._h / 8):
         for j in range(self._w / 8):
             EbModule.read4BPPArea(self._data, block, loc, j*8, i*8)
             loc += 32
开发者ID:jeffman,项目名称:CoilSnake,代码行数:9,代码来源:SpriteGroupModule.py

示例10: writeToRom

 def writeToRom(self, rom):
     for (cat, items) in self.ENTRY_LOCS:
         catDict = self._data[cat]
         for (desc, loc, size) in items:
             EbModule.writeStandardText(rom, loc, catDict[desc], size)
             if (cat == "Status Window") and (len(catDict[desc]) < size):
                 rom.write(loc+len(catDict[desc]),
                         [00] * (size-len(catDict[desc])))
         updateProgress(self._pct)
开发者ID:NichtJens,项目名称:CoilSnake,代码行数:9,代码来源:MiscTextModule.py

示例11: writeToBlock

 def writeToBlock(self, block, loc=0):
     offset = loc
     for q in range(0, self._height/32):
         for r in range(0, self._width/32):
             for a in range(0, 4):
                 for j in range(0,4):
                     EbModule.write4BPPArea(
                             self._sprite, block, offset,
                             (j + r * 4) * 8, (a + q * 4) * 8)
                     offset += 32
开发者ID:jeffman,项目名称:CoilSnake,代码行数:10,代码来源:EnemyModule.py

示例12: readFromRom

    def readFromRom(self, rom):
        self._gfxPtrTbl.readFromRom(rom)
        updateProgress(2)
        self._arrPtrTbl.readFromRom(rom)
        updateProgress(2)
        self._colPtrTbl.readFromRom(rom)
        updateProgress(2)
        self._mapTsetTbl.readFromRom(rom)
        updateProgress(2)
        self._palPtrTbl.readFromRom(rom)
        updateProgress(2)

        # Read tilesets
        pct = 30.0/len(self._tsets)
        i=0
        for tset in self._tsets:
            # Read data
            tset.readMinitilesFromRom(rom,
                    EbModule.toRegAddr(self._gfxPtrTbl[i,0].val()))
            tset.readArrangementsFromRom(rom,
                    EbModule.toRegAddr(self._arrPtrTbl[i,0].val()))
            tset.readCollisionsFromRom(rom,
                    EbModule.toRegAddr(self._colPtrTbl[i,0].val()))
            i += 1
            updateProgress(pct)

        # Read palettes
        pct = 10.0/self._mapTsetTbl.height()
        for i in range(self._mapTsetTbl.height()):
            drawTset = self._mapTsetTbl[i,0].val()
            # Each map tset has 8 maximum palettes
            # We'll just assume they all use 8 and read the garbage
            #romLoc = self._palPtrTbl[i,0].val()
            #for j in xrange(8):
            #    # Read the palette
            #    self._tsets[drawTset].readPaletteFromRom(rom, i, j,
            #            EbModule.toRegAddr(romLoc))
            #    romLoc += 0xc0

            # OK, as it turns out, all palettes need to be in the 1A bank
            # So we actually need to conserve space and not read garbage
            # Estimate the number of palettes for this map tileset
            if i == 31:
                #k = 0xDAFAA7 - self._palPtrTbl[i,0].val()
                k = 7
            else:
                k = self._palPtrTbl[i+1,0].val() - self._palPtrTbl[i,0].val()
                k /= 0xc0
            # Add the palettes
            romLoc = EbModule.toRegAddr(self._palPtrTbl[i,0].val())
            for j in range(k):
                # Read the palette
                self._tsets[drawTset].readPaletteFromRom(rom, i, j, romLoc)
                romLoc += 0xc0
            updateProgress(pct)
开发者ID:Herringway,项目名称:CoilSnake,代码行数:55,代码来源:TilesetModule.py

示例13: writeToRom

    def writeToRom(self, rom):
        for f in self._fonts:
            f.writeToRom(rom)
            updateProgress(self._pct)

        self._cpal.writeToBlock(rom, loc=self._ADDR_CREDITS_PAL)
        with EbCompressedData(self._cfont.sizeBlock()) as cb:
            self._cfont.writeToBlock(cb)
            EbModule.writeAsmPointer(rom, self._ASMPTR_CREDITS_GFX,
                    EbModule.toSnesAddr(cb.writeToFree(rom)))
        updateProgress(self._pct)
开发者ID:NichtJens,项目名称:CoilSnake,代码行数:11,代码来源:FontModule.py

示例14: readTownMapIconsFromRom

 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)
开发者ID:NichtJens,项目名称:CoilSnake,代码行数:11,代码来源:CompressedGraphicsModule.py

示例15: writeToBlock

 def writeToBlock(self, block, addr):
     i=0
     for subp in self.subpals:
         EbModule.writePalette(block, addr + i, subp)
         i += 32
     #block.writeMulti(addr, self.flag, 2)
     #block.writeMulti(addr+0x20, self.flagPalPtr, 2)
     block[addr] = self.flag & 0xff
     block[addr+1] = self.flag >> 8
     block[addr+0x20] = self.flagPalPtr & 0xff
     block[addr+0x21] = self.flagPalPtr >> 8
     block[addr+0x40] = self.spritePalNum
     block[addr+0x60] = self.flashEffect
     return 0xc0
开发者ID:Herringway,项目名称:CoilSnake,代码行数:14,代码来源:TilesetModule.py


注:本文中的EbModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。