Finally added character battle sprites
This commit is contained in:
parent
3044ed09a9
commit
9bb856c690
41
ff5reader.py
41
ff5reader.py
|
@ -187,7 +187,7 @@ class FF5Reader(QMainWindow):
|
||||||
npc_layers[-1].append("0x{:0{}X}".format(val, z[1]*2))
|
npc_layers[-1].append("0x{:0{}X}".format(val, z[1]*2))
|
||||||
j += z[1]
|
j += z[1]
|
||||||
|
|
||||||
battle_strips = make_character_battle_sprites(ROM_en)
|
self.battle_strips = make_character_battle_sprites(ROM_en)
|
||||||
|
|
||||||
self.tabwidget = QTabWidget()
|
self.tabwidget = QTabWidget()
|
||||||
strings_tab = QTabWidget()
|
strings_tab = QTabWidget()
|
||||||
|
@ -203,7 +203,7 @@ class FF5Reader(QMainWindow):
|
||||||
sprites_tab.addTab(make_pixmap_table(glyph_sprites_jp_small, scale=4), "Glyphs (JP)")
|
sprites_tab.addTab(make_pixmap_table(glyph_sprites_jp_small, scale=4), "Glyphs (JP)")
|
||||||
sprites_tab.addTab(make_pixmap_table(glyph_sprites_jp_large, scale=2), "Glyphs (Large JP)")
|
sprites_tab.addTab(make_pixmap_table(glyph_sprites_jp_large, scale=2), "Glyphs (Large JP)")
|
||||||
sprites_tab.addTab(make_pixmap_table(glyph_sprites_kanji, scale=2), "Glyphs (Kanji)")
|
sprites_tab.addTab(make_pixmap_table(glyph_sprites_kanji, scale=2), "Glyphs (Kanji)")
|
||||||
sprites_tab.addTab(make_pixmap_table(battle_strips, cols=88), "Character Battle Sprites")
|
sprites_tab.addTab(make_pixmap_table(self.battle_strips, cols=22), "Character Battle Sprites")
|
||||||
sprites_tab.addTab(self.enemy_sprites, "Enemy Sprites")
|
sprites_tab.addTab(self.enemy_sprites, "Enemy Sprites")
|
||||||
|
|
||||||
structs_tab.addTab(make_table(zone_headers, zone_data, True), "Zones")
|
structs_tab.addTab(make_table(zone_headers, zone_data, True), "Zones")
|
||||||
|
@ -229,15 +229,17 @@ def make_character_battle_sprites(rom):
|
||||||
tile_address = 0x120000
|
tile_address = 0x120000
|
||||||
palette_address = 0x14A3C0
|
palette_address = 0x14A3C0
|
||||||
battle_strips = []
|
battle_strips = []
|
||||||
for i in range(88):
|
for i in range(0, 110*32, 32):
|
||||||
palette = generate_palette(rom, palette_address + (i*32))
|
palette = generate_palette(rom, palette_address + i)
|
||||||
|
# We don't want the background drawn, so we'll make that colour transparent
|
||||||
|
palette[0] = 0
|
||||||
battle_strip = QImage(16, 192, QImage.Format_ARGB32_Premultiplied)
|
battle_strip = QImage(16, 192, QImage.Format_ARGB32_Premultiplied)
|
||||||
battle_strip.fill(QColor(0,0,0,0))
|
battle_strip.fill(QColor(0,0,0,0))
|
||||||
painter = QtGui.QPainter(battle_strip)
|
painter = QtGui.QPainter(battle_strip)
|
||||||
for j in range(24):
|
for j in range(0, 24*8, 8):
|
||||||
offset = tile_address+(i*48*32)+(j*32)
|
offset = tile_address+(i*48)+(j*8)
|
||||||
painter.drawPixmap(j*8, 0, create_tile(rom[offset:offset+32], palette))
|
painter.drawPixmap(0, j, create_tile(rom[offset:offset+32], palette))
|
||||||
painter.drawPixmap(j*8, 8, create_tile(rom[offset+32:offset+64], palette))
|
painter.drawPixmap(8, j, create_tile(rom[offset+32:offset+64], palette))
|
||||||
del painter
|
del painter
|
||||||
battle_strips.append(QPixmap.fromImage(battle_strip))
|
battle_strips.append(QPixmap.fromImage(battle_strip))
|
||||||
return battle_strips
|
return battle_strips
|
||||||
|
@ -385,6 +387,16 @@ def make_string_img_list(start, length, num, start_jp=None, len_jp=None, start_s
|
||||||
stringlist.append(["0x{:06X}".format(j1), "0x{:0{}X}".format(id, id_digits), str_en, img_en, str_jp, img_jp])
|
stringlist.append(["0x{:06X}".format(j1), "0x{:0{}X}".format(id, id_digits), str_en, img_en, str_jp, img_jp])
|
||||||
return stringlist
|
return stringlist
|
||||||
|
|
||||||
|
def table_size_to_contents(table):
|
||||||
|
# Stupid hack to get table to size correctly
|
||||||
|
table.hide()
|
||||||
|
geometry = table.viewport().geometry()
|
||||||
|
table.viewport().setGeometry(QtCore.QRect(0, 0, 0x7FFFFFFF, 0x7FFFFFFF))
|
||||||
|
table.resizeColumnsToContents()
|
||||||
|
table.resizeRowsToContents()
|
||||||
|
table.viewport().setGeometry(geometry)
|
||||||
|
table.show()
|
||||||
|
|
||||||
def make_table(headers, items, sortable=False, row_labels=True, scale=2):
|
def make_table(headers, items, sortable=False, row_labels=True, scale=2):
|
||||||
"""
|
"""
|
||||||
Helper function to tabulate 2d lists
|
Helper function to tabulate 2d lists
|
||||||
|
@ -408,16 +420,7 @@ def make_table(headers, items, sortable=False, row_labels=True, scale=2):
|
||||||
if item[:2] == "0x":
|
if item[:2] == "0x":
|
||||||
q_item.setFont(monofont)
|
q_item.setFont(monofont)
|
||||||
table.setItem(row, col, q_item)
|
table.setItem(row, col, q_item)
|
||||||
|
table_size_to_contents(table)
|
||||||
# Stupid hack to get table to size correctly
|
|
||||||
table.hide()
|
|
||||||
geometry = table.viewport().geometry()
|
|
||||||
table.viewport().setGeometry(QtCore.QRect(0, 0, 0x7FFFFFFF, 0x7FFFFFFF))
|
|
||||||
table.resizeColumnsToContents()
|
|
||||||
table.resizeRowsToContents()
|
|
||||||
table.viewport().setGeometry(geometry)
|
|
||||||
table.show()
|
|
||||||
|
|
||||||
if sortable:
|
if sortable:
|
||||||
table.setSortingEnabled(True)
|
table.setSortingEnabled(True)
|
||||||
table.sortItems(0)
|
table.sortItems(0)
|
||||||
|
@ -434,7 +437,7 @@ def make_pixmap_table(items, cols=16, scale=4):
|
||||||
lab = QLabel()
|
lab = QLabel()
|
||||||
lab.setPixmap(item.scaled(item.size() * scale))
|
lab.setPixmap(item.scaled(item.size() * scale))
|
||||||
table.setCellWidget(i // cols, i % cols, lab)
|
table.setCellWidget(i // cols, i % cols, lab)
|
||||||
table.resizeColumnsToContents()
|
table_size_to_contents(table)
|
||||||
return table
|
return table
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -139,8 +139,11 @@ def generate_glyphs_large(rom, offset, num=0x100):
|
||||||
spritelist.append(create_tritile(rom[j:j+24]))
|
spritelist.append(create_tritile(rom[j:j+24]))
|
||||||
return spritelist
|
return spritelist
|
||||||
|
|
||||||
def generate_palette(rom, offset, length=16):
|
def generate_palette(rom, offset, length=32):
|
||||||
# Need to convert BGR555 to ARGB32
|
'''
|
||||||
|
Length is in bytes not colors (2 bytes per color)
|
||||||
|
We need to convert BGR555 to ARGB32 for each 2 bytes
|
||||||
|
'''
|
||||||
palette = []
|
palette = []
|
||||||
for i in range(offset, offset+length, 2):
|
for i in range(offset, offset+length, 2):
|
||||||
if (i+2) < len(rom):
|
if (i+2) < len(rom):
|
||||||
|
|
Loading…
Reference in New Issue