You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-09-08 08:13:02 -07:00
better movement command/macro support
This commit is contained in:
@@ -1916,73 +1916,31 @@ class MovementCommand(Command):
|
|||||||
# return []
|
# return []
|
||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
self.byte = ord(rom[self.address])
|
if ord(rom[self.address]) < 0x45:
|
||||||
#
|
# this is mostly handled in to_asm
|
||||||
#if ord(rom[self.address]) < 0x45:
|
pass
|
||||||
# # this is mostly handled in to_asm
|
else:
|
||||||
# pass
|
Command.parse(self)
|
||||||
#else:
|
|
||||||
# Command.parse(self)
|
|
||||||
|
|
||||||
def to_asm(self):
|
def to_asm(self):
|
||||||
return "db $%.2x"%(self.byte)
|
#return "db $%.2x"%(self.byte)
|
||||||
|
return Command.to_asm(self)
|
||||||
|
|
||||||
if ord(rom[self.address]) < 0x38:
|
class MovementDBCommand(Command):
|
||||||
byte = ord(rom[self.address])
|
end = False
|
||||||
|
macro_name = "db"
|
||||||
|
override_byte_check = True
|
||||||
|
id = None
|
||||||
|
byte = None
|
||||||
|
size = 1
|
||||||
|
param_types = {
|
||||||
|
0: {"name": "db value", "class": SingleByteParam},
|
||||||
|
}
|
||||||
|
params = []
|
||||||
|
|
||||||
if byte in self.base:
|
def to_asm(self):
|
||||||
modulator = "down"
|
asm = Command.to_asm(self)
|
||||||
elif byte in [x+1 for x in self.base]:
|
return asm + " ; movement"
|
||||||
modulator = "up"
|
|
||||||
elif byte in [x+2 for x in self.base]:
|
|
||||||
modulator = "left"
|
|
||||||
elif byte in [x+3 for x in self.base]:
|
|
||||||
modulator = "right"
|
|
||||||
else:
|
|
||||||
raise Exception, "can't figure out direction- this should never happen"
|
|
||||||
|
|
||||||
macro_name = self.make_name()
|
|
||||||
|
|
||||||
return macro_name+" "+modulator
|
|
||||||
else:
|
|
||||||
return Command.to_asm(self)
|
|
||||||
|
|
||||||
def make_name(self):
|
|
||||||
""" Makes a macro name based on the byte id.
|
|
||||||
"""
|
|
||||||
byte = ord(rom[self.address])
|
|
||||||
|
|
||||||
if byte in self.base:
|
|
||||||
modulator = "down"
|
|
||||||
elif byte in [x+1 for x in self.base]:
|
|
||||||
modulator = "up"
|
|
||||||
elif byte in [x+2 for x in self.base]:
|
|
||||||
modulator = "left"
|
|
||||||
elif byte in [x+3 for x in self.base]:
|
|
||||||
modulator = "right"
|
|
||||||
else:
|
|
||||||
raise Exception, "can't figure out direction- this should never happen"
|
|
||||||
|
|
||||||
x = byte
|
|
||||||
|
|
||||||
if 0x00 <= x < 0x04: name = "turn_head"
|
|
||||||
elif 0x04 <= x < 0x08: name = "half_step"
|
|
||||||
elif 0x08 <= x < 0x0C: name = "slow_step"
|
|
||||||
elif 0x0C <= x < 0x10: name = "step"
|
|
||||||
elif 0x10 <= x < 0x14: name = "big_step"
|
|
||||||
elif 0x14 <= x < 0x18: name = "slow_slide_step"
|
|
||||||
elif 0x18 <= x < 0x1C: name = "slide_step"
|
|
||||||
elif 0x1C <= x < 0x20: name = "fast_slide_step"
|
|
||||||
elif 0x20 <= x < 0x24: name = "turn_away"
|
|
||||||
elif 0x24 <= x < 0x28: name = "turn_in"
|
|
||||||
elif 0x28 <= x < 0x2C: name = "turn_waterfall"
|
|
||||||
elif 0x2C <= x < 0x30: name = "slow_jump_step"
|
|
||||||
elif 0x30 <= x < 0x34: name = "jump_step"
|
|
||||||
elif 0x34 <= x < 0x38: name = "fast_jump_step"
|
|
||||||
elif x >= 0x38:
|
|
||||||
raise Exception, "ApplyMovementData >$45 command found in <$45 namer?"
|
|
||||||
|
|
||||||
return name
|
|
||||||
|
|
||||||
# down, up, left, right
|
# down, up, left, right
|
||||||
movement_command_bases = {
|
movement_command_bases = {
|
||||||
@@ -2153,13 +2111,19 @@ class ApplyMovementData:
|
|||||||
# no matching command found
|
# no matching command found
|
||||||
xyz = None
|
xyz = None
|
||||||
if scripting_command_class == None:
|
if scripting_command_class == None:
|
||||||
scripting_command_class = MovementCommand
|
scripting_command_class = MovementDBCommand
|
||||||
|
#scripting_command_class = deepcopy(MovementCommand)
|
||||||
|
#scripting_command_class.id = scripting_command_class.byte = ord(rom[current_address])
|
||||||
|
#scripting_command_class.macro_name = "db"
|
||||||
|
#scripting_command_class.size = 1
|
||||||
|
#scripting_command_class.override_byte_check = True
|
||||||
|
#scripting_command_class.id = None
|
||||||
|
#scripting_command_class.param_types = {0: {"name": "db value", "class": DecimalParam}}
|
||||||
|
|
||||||
xyz = True
|
xyz = True
|
||||||
|
|
||||||
# create an instance of the command class and let it parse its parameter bytes
|
# create an instance of the command class and let it parse its parameter bytes
|
||||||
cls = scripting_command_class(address=current_address, map_group=self.map_group, map_id=self.map_id, debug=self.debug, force=self.force)
|
cls = scripting_command_class(address=current_address, map_group=self.map_group, map_id=self.map_id, debug=self.debug, force=self.force)
|
||||||
if xyz:
|
|
||||||
cls.byte = ord(rom[current_address])
|
|
||||||
|
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print cls.to_asm()
|
print cls.to_asm()
|
||||||
@@ -2198,6 +2162,12 @@ class ApplyMovementData:
|
|||||||
def get_dependencies(self, recompute=False, global_dependencies=set()):
|
def get_dependencies(self, recompute=False, global_dependencies=set()):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
def print_all_movements():
|
||||||
|
for each in all_movements:
|
||||||
|
print each.to_asm()
|
||||||
|
print "------------------"
|
||||||
|
print "done"
|
||||||
|
|
||||||
class TextCommand(Command):
|
class TextCommand(Command):
|
||||||
# an individual text command will not end it
|
# an individual text command will not end it
|
||||||
end = False
|
end = False
|
||||||
|
@@ -14,7 +14,8 @@ from extras.crystal import command_classes, \
|
|||||||
MoneyByteParam, \
|
MoneyByteParam, \
|
||||||
ItemFragment, \
|
ItemFragment, \
|
||||||
TextEndingCommand, \
|
TextEndingCommand, \
|
||||||
text_command_classes
|
text_command_classes, \
|
||||||
|
movement_command_classes
|
||||||
|
|
||||||
macros = command_classes + \
|
macros = command_classes + \
|
||||||
[
|
[
|
||||||
@@ -24,7 +25,8 @@ macros = command_classes + \
|
|||||||
PeopleEvent,
|
PeopleEvent,
|
||||||
DataByteWordMacro,
|
DataByteWordMacro,
|
||||||
ItemFragment,
|
ItemFragment,
|
||||||
] + [x[1] for x in text_command_classes]
|
] + [x[1] for x in text_command_classes] \
|
||||||
|
+ movement_command_classes
|
||||||
|
|
||||||
chars = {
|
chars = {
|
||||||
"ガ": 0x05,
|
"ガ": 0x05,
|
||||||
|
Reference in New Issue
Block a user