Move map blocks to a test scene
This commit is contained in:
parent
b8977c8fdc
commit
daf4c54cd5
48
Node2D.gd
48
Node2D.gd
|
@ -2,20 +2,7 @@ extends Node2D
|
||||||
|
|
||||||
var PC = load('PC.tscn')
|
var PC = load('PC.tscn')
|
||||||
var PCs = []
|
var PCs = []
|
||||||
var worldmap_blocks = []
|
|
||||||
var sfx_buttons = []
|
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():
|
func _ready():
|
||||||
Engine.set_target_fps(60)
|
Engine.set_target_fps(60)
|
||||||
|
@ -35,42 +22,7 @@ func _ready():
|
||||||
# PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[45])
|
# PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[45])
|
||||||
# PCs[-1].texture = SpriteLoader.weapon_textures['Fist']
|
# PCs[-1].texture = SpriteLoader.weapon_textures['Fist']
|
||||||
# add_child(PCs[-1])
|
# add_child(PCs[-1])
|
||||||
for i in 3:
|
|
||||||
worldmap_blocks.append(TextureRect.new())
|
|
||||||
worldmap_blocks[-1].texture = SpriteLoader.worldmap_block_atlas_textures[i]
|
|
||||||
# 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 *= 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()
|
_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():
|
func _create_sfx_buttons():
|
||||||
|
|
27
Node2D.tscn
27
Node2D.tscn
|
@ -23,31 +23,4 @@ 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 ]
|
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
|
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
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
|
|
||||||
[connection signal="item_selected" from="Node2D/OptionButton" to="Node2D" method="_on_OptionButton_item_selected"]
|
[connection signal="item_selected" from="Node2D/OptionButton" to="Node2D" method="_on_OptionButton_item_selected"]
|
||||||
|
|
|
@ -4,32 +4,47 @@ extends Node
|
||||||
# 3 bytes
|
# 3 bytes
|
||||||
# Byte0: movement properties
|
# Byte0: movement properties
|
||||||
# 0x01 = passable on foot
|
# 0x01 = passable on foot
|
||||||
# 0x02 = passable on chocobo??
|
# 0x02 = passable on chocobo?
|
||||||
# 0x04 = passable on black chocobo
|
# 0x04 = passable on black chocobo
|
||||||
# 0x08 = passable on hiryuu??
|
# 0x08 = passable on hiryuu?
|
||||||
# 0x10 = set on deep water tiles, and all undersea tiles that aren't cliffs
|
# 0x10 = passable in submarine? set on deep water tiles, and all undersea tiles that aren't cliffs
|
||||||
# 0x20 = set on deep water tiles only (not undersea)
|
# 0x20 = passable in ship? set on deep water tiles only (not undersea) - can submerge?
|
||||||
# 0x40 = Pretty much every tile aboveground has this. No undersea.
|
# 0x40 = passable in airship? Pretty much every tile aboveground has this. No undersea.
|
||||||
# 0x80 = only set on clear sea floor. Submarine pathable??
|
# 0x80 = only set on clear sea floor. Submarine pathable/can surface?
|
||||||
# Byte1: movement properties
|
# Byte1: movement properties
|
||||||
# 0x01 = (water flips) can move from this block rightwards
|
# 0x01 = (water flips) can move from this block rightwards
|
||||||
# 0x02 = (water flips) can move from this block leftwards
|
# 0x02 = (water flips) can move from this block leftwards
|
||||||
# 0x04 = (water flips) can move from this block downwards
|
# 0x04 = (water flips) can move from this block downwards
|
||||||
# 0x08 = (water flips) can move from this block upwards
|
# 0x08 = (water flips) can move from this block upwards
|
||||||
# 0x10 = most aboveground water tiles
|
# 0x10 = Chocobo can't land/dismount. most aboveground water tiles
|
||||||
# 0x20 =
|
# 0x20 = Black Chocobo can't land.
|
||||||
# 0x40 =
|
# 0x40 = Hiryuu can't land.
|
||||||
# 0x80 = Things airship can't land on??
|
# 0x80 = Airship can't land.
|
||||||
# Byte2: movement properties
|
# Byte2: movement properties
|
||||||
# 0x01 = Set on forests, deep water, void.
|
# 0x01 = Set on forests, deep water, void.
|
||||||
# 0x02 = Set on deep water, void, desert.
|
# 0x02 = Set on deep water, void, desert.
|
||||||
# 0x04 = Only set on diagonal land corners and Galuf World swamp
|
# 0x04 = Only set on diagonal land corners and Galuf World swamp
|
||||||
# 0x08 = No hits.
|
# 0x08 = No hits.
|
||||||
# 0x10 = Mountains and Exdeath's Castle
|
# 0x10 = Mountains and Exdeath's Castle
|
||||||
# 0x20 = Only set on forests. Can land Black Chocobo? ...also waterfall, but not lower bounds of forests
|
# 0x20 = Set on first two rows of forests, also waterfall, but not lower bounds of forests
|
||||||
# 0x40 = Shallow water.
|
# 0x40 = Shallow water.
|
||||||
# 0x80 =
|
# 0x80 =
|
||||||
|
|
||||||
|
# Vehicle landing bit masks: [00 10 20 40 00 00 80] - & with Byte1, if 1, can't land
|
||||||
|
# Vehicle IDs: [None, Chocobo, BlkChocobo, Hiryuu, Submarine, Ship, Airship]
|
||||||
|
|
||||||
|
# Worldmap animations
|
||||||
|
# World 1 (and probably 3)
|
||||||
|
# Sea tiles and waterfall tiles have a scrolling effect in tile data
|
||||||
|
# This may require setting up a proper tile indirect lookup shader
|
||||||
|
# Shifting sands and the portal have cycling palettes: $6C and $6D swap every frame, $51 through $55 scroll left (i.e. $55->$54, $51->$55)
|
||||||
|
# This will be best hardcoded as a 10 palette cycle
|
||||||
|
# World 2:
|
||||||
|
# Sea tiles have a horizontal scrolling effect in tile data (addresses $1880, $18C0, $1C80, $1CC0)
|
||||||
|
# ASM at C09660 BF 21 86 7F LDA $7F8621,X
|
||||||
|
# Probably going to shader this effect instead of storing hundreds of frames
|
||||||
|
# No palette cycling
|
||||||
|
|
||||||
var worldmap_block_properties = []
|
var worldmap_block_properties = []
|
||||||
func load_worldmap_block_properties(rom: File):
|
func load_worldmap_block_properties(rom: File):
|
||||||
rom.seek(0x0FEA00)
|
rom.seek(0x0FEA00)
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
extends Node2D
|
||||||
|
var worldmap_blocks = []
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
var _scale := 5
|
||||||
|
var _size = Vector2.ONE * 16 * _scale
|
||||||
|
for i in 3:
|
||||||
|
worldmap_blocks.append(TextureRect.new())
|
||||||
|
worldmap_blocks[-1].texture = SpriteLoader.worldmap_block_atlas_textures[i]
|
||||||
|
# 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 *= _scale
|
||||||
|
var pos = Vector2(i * 256 * _scale, 50)
|
||||||
|
worldmap_blocks[-1].rect_position = pos
|
||||||
|
add_child(worldmap_blocks[-1])
|
||||||
|
# x0 += 4 * _scale
|
||||||
|
# y0 += 12 * _scale
|
||||||
|
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 = pos + (Vector2(block%16, block/16) * _size)
|
||||||
|
label.rect_size = _size
|
||||||
|
label.align = Label.ALIGN_CENTER
|
||||||
|
label.valign = Label.VALIGN_CENTER
|
||||||
|
add_child(label)
|
||||||
|
block_labels.append(label)
|
||||||
|
$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)
|
|
@ -0,0 +1,23 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://test/worldmap_blocks.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="worldmap_blocks" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="BitSelector" type="SpinBox" parent="."]
|
||||||
|
anchor_bottom = 0.67
|
||||||
|
margin_right = 100.0
|
||||||
|
margin_bottom = 24.0
|
||||||
|
min_value = -1.0
|
||||||
|
max_value = 23.0
|
||||||
|
value = -1.0
|
||||||
|
|
||||||
|
[node name="BitSelectorMask" type="Label" parent="."]
|
||||||
|
anchor_bottom = 0.67
|
||||||
|
margin_left = 120.0
|
||||||
|
margin_right = 220.0
|
||||||
|
margin_bottom = 48.0
|
||||||
|
text = "1111
|
||||||
|
1111
|
||||||
|
1111"
|
Loading…
Reference in New Issue