diff --git a/data/5/addresses_SNES_PSX.tsv b/data/5/addresses_SNES_PSX.tsv index 4f9e473..3ef7da5 100644 --- a/data/5/addresses_SNES_PSX.tsv +++ b/data/5/addresses_SNES_PSX.tsv @@ -1,7 +1,7 @@ Label SNES PSX_file PSX_offset format Comment -character_battle_sprite_stone_palette 0x00F807 N/A N/A Palette16Of555 Also 0x199835 -character_battle_sprite_disabled_palette 0x00F867 /mnu/memsave.bin 0x000034 Palette16Of555 -locations_bg_palettes 0x03BB00 /nar/ff5_binx.bin 0x03BF80 43 of Palette128Of555 +character_battle_sprite_stone_palette 0x00F807 N/A N/A 16 of ColorBGR555 Also 0x199835 +character_battle_sprite_disabled_palette 0x00F867 /mnu/memsave.bin 0x000034 16 of ColorBGR555 +locations_bg_palettes 0x03BB00 /nar/ff5_binx.bin 0x03BF80 43 of 128 of ColorBGR555 font_glyphs_dialogue 0x03E800 256 of SNESTritile length 0x1800 sfx_brr_data 0x041E3F Use the below SPC pointers sfx_brr_pointers 0x041F4F 8 of 2 of u16 SPC memory addresses not ROM. Start address followed by loop address. @@ -17,7 +17,7 @@ bgm_instrument_indices 0x043DAA 72 of 16 of u16 length 0x900 enemy_battle_sprite_palettes 0x0ED000 See enemy_battle_sprite_data for pointers. Some are 8 colours instead of 16. worldmap_blocks 0x0FF0C0 /nar/ff5_binx.bin 0x040300 3 of 4 of 192 of u8 # Top-left corners, top-right corners, bottom-left corners, bottom-right corners worldmap_tiles.bias 0x0FF9C0 /nar/ff5_bin3.bin 0x03FB00 3 of 256 of u8 Add to each pixel of the mode7c tiles -worldmap_palettes 0x0FFCC0 /nar/ff5_binx.bin 0x040000 3 of Palette128Of555 +worldmap_palettes 0x0FFCC0 /nar/ff5_binx.bin 0x040000 3 of 128 of ColorBGR555 tbl_enemy_stats 0x100000 384 of EnemyStats enemy_battle_sprite_layouts_small 0x10D004 102 of 8 of u8 length 0x330 enemy_battle_sprite_layouts_large 0x10D334 72 of 16 of u16 length 0x900 @@ -49,15 +49,15 @@ tbl_ability_stats_passives 0x116308 33 of 4 of u8 length 0x84 character_initial_data 0x117000 4 of Character length 0x140 attack_layouts 0x117FA0 5 of 2048 of u8 length 0x2400 weapon_palettes 0x11A3A0 -enemy_battle_status_sprite_palette 0x11A400 Palette16Of555 +enemy_battle_status_sprite_palette 0x11A400 16 of ColorBGR555 tiles_fist 0x11D710 /btl/ff5_btl.bin 0x021D10 TileSNES3bpp Also /mnu/men_bin.eng:0x00D910 font_glyphs_small 0x11F000 256 of TileSNES2bpp length 0x1000 character_battle_sprite_tiles 0x120000 /mnu/men_bin.eng 0x010200 5 of 22 of 48 of TileSNES4bpp -character_battle_sprite_palettes 0x14A3C0 /btl/ff5_btl.bin 0x0273C0 5 of 22 of Palette16Of555 Also /mnu/men_bin.eng:0x03A5C0 +character_battle_sprite_palettes 0x14A3C0 /btl/ff5_btl.bin 0x0273C0 5 of 22 of 16 of ColorBGR555 Also /mnu/men_bin.eng:0x03A5C0 enemy_battle_sprite_data 0x14B180 384 of EnemySpriteData length 0x780 character_battle_sprite_layouts 0x14B997 /btl/ff5_btl.bin 0x028997 11 of 6 of u8 tbl_battle_backgrounds 0x14BA21 34 of BattleBackgroundData -battle_background_palettes 0x14BB31 84 of Palette16Of555 +battle_background_palettes 0x14BB31 84 of 16 of ColorBGR555 ptrs_battle_background_tile_animations 0x14C5B1 8 of u16 bank 0x140000 (0xD40000) battle_background_tile_animations_data 0x14C5C1 see above ptrs_battle_background_palette_animations 0x14C6CD 3 of u16 bank 0x140000 (0xD40000) diff --git a/data/structs_SNES_stubs.tsv b/data/structs_SNES_stubs.tsv index 90e3fdd..e26faa1 100644 --- a/data/structs_SNES_stubs.tsv +++ b/data/structs_SNES_stubs.tsv @@ -20,10 +20,7 @@ struct SNESTritile 24 of u8 data struct ColorBGR555 -u16 data - -struct Palette16Of555 # Typed PoolColorArray in GDscript -16 of ColorBGR555 data - -struct Palette128Of555 # Typed PoolColorArray in GDscript -128 of ColorBGR555 data +u5 r5 +u5 g5 +u5 b5 +u1 0 diff --git a/scripts/loaders/SpriteLoader.gd b/scripts/loaders/SpriteLoader.gd index 695d805..0e96569 100644 --- a/scripts/loaders/SpriteLoader.gd +++ b/scripts/loaders/SpriteLoader.gd @@ -319,7 +319,6 @@ var monster_battle_sprite_textures := {} # "tiles_offset:layout_id:large:bpp" - func load_enemy_battle_sprites(data: Dictionary, buffer: StreamPeerBuffer): var PAL: int = Common.SNES_PSX_addresses.enemy_battle_sprite_palettes.SNES var TILES: int = Common.SNES_PSX_addresses.enemy_battle_sprite_tiles.SNES - var Palette16Of555 = RomLoader.structdefs.Palette16Of555 data.monster_battle_sprites = [] for monster in data.enemy_battle_sprite_data: var entry = {} diff --git a/scripts/loaders/snes/structs.gd b/scripts/loaders/snes/structs.gd index ccc9776..e16e836 100644 --- a/scripts/loaders/snes/structs.gd +++ b/scripts/loaders/snes/structs.gd @@ -33,19 +33,11 @@ class SNESTritile extends STRUCT.StructType: # Not TileSNESTritile as these are return GRAPHICS.get_tritile(buffer) class ColorBGR555 extends STRUCT.StructType: + func _init(): + self.primitive_type = TYPE_COLOR func get_value(buffer: StreamPeer, leftover_bits: Array): return GRAPHICS.bgr555_to_color(buffer.get_u16()) -class PaletteOf555 extends STRUCT.StructType: - var length: int = 16 - func _init(length: int): - self.length = length - func get_value(buffer: StreamPeer, leftover_bits: Array): - var array := PoolColorArray() - for i in self.length: - array.append(GRAPHICS.bgr555_to_color(buffer.get_u16())) - return array - class ItemCost extends STRUCT.StructType: func get_value(buffer: StreamPeer, leftover_bits: Array): var b0 := buffer.get_u8() @@ -108,8 +100,6 @@ static func get_structtypes() -> Dictionary: 'TileSNES1bpp': TileSNES1bpp.new(), 'SNESTritile': SNESTritile.new(), 'ColorBGR555': ColorBGR555.new(), - 'Palette16Of555': PaletteOf555.new(16), - 'Palette128Of555': PaletteOf555.new(128), 'ItemCost': ItemCost.new(), 'EquipStatBonus': EquipStatBonus.new(), } diff --git a/scripts/struct.gd b/scripts/struct.gd index 2f3e9c2..7fe39e4 100644 --- a/scripts/struct.gd +++ b/scripts/struct.gd @@ -3,6 +3,7 @@ # leftover_bits is array of form [count, value] # array is used for reference semantics as get and put operations may mutate it class StructType: + var primitive_type := TYPE_NIL func get_value(buffer: StreamPeer, leftover_bits: Array): assert(false, 'Deserialization not implemented') func put_value(buffer: StreamPeer, value, leftover_bits: Array): @@ -92,31 +93,31 @@ class Struct extends StructType: var result = {} for member in members: var key: String = member[0] - var structType: StructType = member[1] - result[key] = structType.get_value(buffer, leftover_bits) + var struct_type: StructType = member[1] + result[key] = struct_type.get_value(buffer, leftover_bits) return result func put_value(buffer: StreamPeer, value, leftover_bits: Array): for member in members: var key: String = member[0] - var structType: StructType = member[1] + var struct_type: StructType = member[1] if not (key in value): print_debug('Key "%s" missing from value supplied' % key) return - structType.put_value(buffer, value[key], leftover_bits) + struct_type.put_value(buffer, value[key], leftover_bits) class StructArrayType extends StructType: var count: int - var structType: StructType + var contained_struct_type: StructType - func _init(count, structType) -> void: + func _init(count, contained_struct_type) -> void: self.count = count - self.structType = structType + self.contained_struct_type = contained_struct_type func get_value(buffer: StreamPeer, leftover_bits: Array): # Might be a bit too much branching but oh well - if self.structType is U8: + if self.contained_struct_type is U8: var result = PoolByteArray() # Slight optimization over calling the method for i in self.count: @@ -125,7 +126,9 @@ class StructArrayType extends StructType: var result = [] for i in self.count: - result.append(self.structType.get_value(buffer, leftover_bits)) + result.append(self.contained_struct_type.get_value(buffer, leftover_bits)) + if self.contained_struct_type.primitive_type == TYPE_COLOR: + return PoolColorArray(result) return result func put_value(buffer: StreamPeer, value, leftover_bits: Array): @@ -133,7 +136,7 @@ class StructArrayType extends StructType: print_debug('Not enough values supplied') return for i in self.count: - self.structType.put_value(buffer, value[i], leftover_bits) + self.contained_struct_type.put_value(buffer, value[i], leftover_bits) static func get_base_structarraytypes() -> Dictionary: