Skip to content

Commit

Permalink
Added option to ignore palette index to nitro.readNCLR
Browse files Browse the repository at this point in the history
  • Loading branch information
Illidanz committed Mar 27, 2021
1 parent a166d5d commit 2973bfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions hacktools/nitro.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ class Cell:
layer = -1


def readNitroGraphic(palettefile, tilefile, mapfile, cellfile):
def readNitroGraphic(palettefile, tilefile, mapfile, cellfile, ignorepalindex=False):
if not os.path.isfile(palettefile):
common.logError("Palette", palettefile, "not found")
return [], None, None, None, 0, 0
palettes = readNCLR(palettefile)
palettes = readNCLR(palettefile, ignorepalindex)
# Read tiles
ncgr = readNCGR(tilefile)
width = ncgr.width
Expand All @@ -380,7 +380,7 @@ def readNitroGraphic(palettefile, tilefile, mapfile, cellfile):
return palettes, ncgr, nscr, ncer, width, height


def readNCLR(nclrfile):
def readNCLR(nclrfile, ignoreindex=False):
palettes = []
with common.Stream(nclrfile, "rb") as f:
# Read header
Expand All @@ -406,7 +406,7 @@ def readNCLR(nclrfile):
palette.append(common.readPalette(f.readUShort()))
palettes.append(palette)
# Read index
if sections == 2:
if sections == 2 and not ignoreindex:
f.seek(16, 1)
indexedpalettes = {}
for i in range(len(palettes)):
Expand Down Expand Up @@ -598,7 +598,7 @@ def readNCER(ncerfile):
maxy = max(maxy, cell.y + cell.height)
if ncer.tbank == 0x01 and (maxx - minx > bank.width or maxy - miny > bank.height):
malformedtbank = True
common.logWarning("Malformed tbank", ncerfile, bank.width, maxx, bank.height, maxy)
common.logWarning("Malformed tbank", ncerfile, bank.width, minx, maxx, bank.height, miny, maxy)
if ncer.tbank == 0x00 or malformedtbank:
bank.width = maxx - minx
bank.height = maxy - miny
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="hacktools",
version="0.17.3",
version="0.17.4",
author="Illidan",
description="A set of utilities and tools for rom hacking and translations.",
long_description=long_description,
Expand Down

0 comments on commit 2973bfa

Please sign in to comment.