mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-09-09 09:51:34 -07:00
figuring out where a script appears based on a known address
This commit is contained in:
parent
faa73c5a47
commit
6973ec82ba
@ -35,7 +35,7 @@ import crystal
|
||||
crystal.run_tests()
|
||||
```
|
||||
|
||||
#### Investigating scripts from a known address
|
||||
#### Parsing a script at a known address
|
||||
|
||||
Here is a demo of how to investigate a particular script, starting with only an address to a known script (0x58043). In this case, the script calls the `2writetext` command to show some dialog. This dialog will be shown at the end of the example.
|
||||
|
||||
@ -125,3 +125,29 @@ UnknownText_0x580c7: ; 0x580c7
|
||||
; 0x581e5
|
||||
```
|
||||
|
||||
#### Figuring out where a script appears based on a known address
|
||||
|
||||
Another approach is to parse the entire ROM, then check a script at a particular address. This has the advantage that the script object will have the `map_group` and `map_id` variables set.
|
||||
|
||||
```python
|
||||
import crystal
|
||||
|
||||
# parse the ROM
|
||||
crystal.run_main()
|
||||
|
||||
# get the parsed script
|
||||
script = crystal.script_parse_table[0x58043]
|
||||
|
||||
# read its attributes to figure out map group / map id
|
||||
map_group = script.map_group
|
||||
map_id = script.map_id
|
||||
|
||||
# MapHeader is not given all the info yet
|
||||
# in the mean time "map_names" contains some metadata
|
||||
map_dict = crystal.map_names[map_group][map_name]
|
||||
map_header = map_dict["header_new"]
|
||||
|
||||
print map_dict["name"]
|
||||
# Ruins of Alph Outside
|
||||
```
|
||||
|
||||
|
@ -2295,6 +2295,10 @@ class Script:
|
||||
if not label:
|
||||
label = self.base_label + hex(self.address)
|
||||
self.label = Label(name=label, address=address, object=self)
|
||||
if "map_group" in kwargs.keys():
|
||||
self.map_group = kwargs["map_group"]
|
||||
if "map_id" in kwargs.keys():
|
||||
self.map_id = kwargs["map_id"]
|
||||
#parse the script at the address
|
||||
if "use_old_parse" in kwargs.keys() and kwargs["use_old_parse"] == True:
|
||||
self.old_parse(**kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user