Searching for map tile pathing flags

This commit is contained in:
Luke Hubmayer-Werner 2023-07-27 01:34:25 +09:30
parent 9d5d5b56f4
commit b8977c8fdc
5 changed files with 103 additions and 2 deletions

View File

@ -4,6 +4,18 @@ var PC = load('PC.tscn')
var PCs = []
var worldmap_blocks = []
var sfx_buttons = []
var block_labels = []
func bin2str(bin: int) -> String:
var string := ''
for i in 8:
if i == 4:
string += ' '
if ((bin >> 7-i) & 0x01) != 0:
string += '1'
else:
string += '0'
return string
func _ready():
Engine.set_target_fps(60)
@ -29,11 +41,36 @@ func _ready():
# worldmap_blocks[-1].texture = SpriteLoader.worldmap_tile_atlas_textures[i]
worldmap_blocks[-1].material = SpriteLoader.shader_material.duplicate()
worldmap_blocks[-1].material.set_shader_param('palette', SpriteLoader.worldmap_palette_textures[i])
# worldmap_blocks[-1].rect_scale *= 2
worldmap_blocks[-1].rect_position.x = i*256
worldmap_blocks[-1].rect_scale *= 3
worldmap_blocks[-1].rect_position.x = i*256*3
worldmap_blocks[-1].rect_position.y = 280
add_child(worldmap_blocks[-1])
var x0 = i*256*3 + 4
var y0 = 280 + 12
for block in 0xC0:
var label = Label.new()
var p = MapLoader.worldmap_block_properties[i][block]
label.text = '%s\n%s\n%s' % [bin2str(p&0xff), bin2str((p>>8)&0xff), bin2str(p>>16)]
label.add_color_override('font_color_shadow', Color.black)
label.add_constant_override('shadow_as_outline', true)
label.rect_position.x = x0 + (block%16) * 48
label.rect_position.y = y0 + (block/16) * 48
label.rect_scale /= 2
add_child(label)
block_labels.append(label)
_create_sfx_buttons()
$BitSelector.connect('value_changed', self, '_update_block_mask')
func _update_block_mask(value: int):
var mask = 0xFFFFFF if (value<0) else (1<<value)
$BitSelectorMask.text = '%s\n%s\n%s' % [bin2str(mask&0xff), bin2str((mask>>8)&0xff), bin2str(mask>>16)]
for i in block_labels.size():
var p = MapLoader.worldmap_block_properties[i/0xC0][i%0xC0]
if (p & mask) > 0:
block_labels[i].add_color_override('font_color', Color.white)
else:
block_labels[i].add_color_override('font_color', Color.black)
func _create_sfx_buttons():

View File

@ -23,6 +23,28 @@ text = "Stand"
items = [ "Stand", null, false, 0, null, "Guard", null, false, 1, null, "Walk", null, false, 2, null, "Down", null, false, 3, null, "R_Swing", null, false, 4, null, "L_Swing", null, false, 5, null, "Cheer", null, false, 6, null, "Recoil", null, false, 7, null, "Chant", null, false, 8, null ]
selected = 0
[node name="BitSelector" type="SpinBox" parent="Node2D"]
anchor_bottom = 0.67
margin_left = 60.0
margin_top = 180.0
margin_right = 160.0
margin_bottom = 204.0
rect_scale = Vector2( 0.5, 0.5 )
min_value = -1.0
max_value = 23.0
value = -1.0
[node name="BitSelectorMask" type="Label" parent="Node2D"]
anchor_bottom = 0.67
margin_left = 120.0
margin_top = 170.0
margin_right = 220.0
margin_bottom = 218.0
rect_scale = Vector2( 0.5, 0.5 )
text = "1111
1111
1111"
[node name="ColorRect" type="ColorRect" parent="."]
visible = false
anchor_right = 1.0

View File

@ -24,6 +24,7 @@ globals="*res://globals.gd"
CommonGBA="*res://scripts/loaders/common_gba.gd"
SoundLoader="*res://scripts/loaders/sound_loader.gd"
SpriteLoader="*res://scripts/loaders/sprite_loader.gd"
MapLoader="*res://scripts/loaders/map_loader.gd"
RomLoader="*res://scripts/loaders/rom_loader.gd"
[debug]

View File

@ -0,0 +1,40 @@
extends Node
# World Map Block Properties
# 3 bytes
# Byte0: movement properties
# 0x01 = passable on foot
# 0x02 = passable on chocobo??
# 0x04 = passable on black chocobo
# 0x08 = passable on hiryuu??
# 0x10 = set on deep water tiles, and all undersea tiles that aren't cliffs
# 0x20 = set on deep water tiles only (not undersea)
# 0x40 = Pretty much every tile aboveground has this. No undersea.
# 0x80 = only set on clear sea floor. Submarine pathable??
# Byte1: movement properties
# 0x01 = (water flips) can move from this block rightwards
# 0x02 = (water flips) can move from this block leftwards
# 0x04 = (water flips) can move from this block downwards
# 0x08 = (water flips) can move from this block upwards
# 0x10 = most aboveground water tiles
# 0x20 =
# 0x40 =
# 0x80 = Things airship can't land on??
# Byte2: movement properties
# 0x01 = Set on forests, deep water, void.
# 0x02 = Set on deep water, void, desert.
# 0x04 = Only set on diagonal land corners and Galuf World swamp
# 0x08 = No hits.
# 0x10 = Mountains and Exdeath's Castle
# 0x20 = Only set on forests. Can land Black Chocobo? ...also waterfall, but not lower bounds of forests
# 0x40 = Shallow water.
# 0x80 =
var worldmap_block_properties = []
func load_worldmap_block_properties(rom: File):
rom.seek(0x0FEA00)
for world_ts in 3:
var ts_properties = PoolIntArray()
for block in 0xC0:
ts_properties.append(rom.get_16() + (rom.get_8() << 16))
worldmap_block_properties.append(ts_properties)

View File

@ -10,6 +10,7 @@ func load_snes_rom(filename: String):
var error := rom_snes.open(filename, File.READ)
if error == OK:
SpriteLoader.load_snes_rom(rom_snes)
MapLoader.load_worldmap_block_properties(rom_snes)
var _thread_error = thread.start(SoundLoader, 'parse_rom', rom_snes)
func _ready():