You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-09-08 08:13:02 -07:00
move allowed_lengths for music macros out
This moves the allowed_lengths setting out of the preprocessor. Special cases should not be hardcoded in the preprocessor.
This commit is contained in:
@@ -2990,8 +2990,6 @@ music_commands_new = {
|
|||||||
music_command_enders = [0xEA, 0xEB, 0xEE, 0xFC, 0xFF,]
|
music_command_enders = [0xEA, 0xEB, 0xEE, 0xFC, 0xFF,]
|
||||||
# special case for 0xFD (if loopchannel.count = 0, break)
|
# special case for 0xFD (if loopchannel.count = 0, break)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create_music_command_classes(debug=False):
|
def create_music_command_classes(debug=False):
|
||||||
klasses = [GivePoke]
|
klasses = [GivePoke]
|
||||||
for (byte, cmd) in music_commands_new.items():
|
for (byte, cmd) in music_commands_new.items():
|
||||||
@@ -3010,6 +3008,10 @@ def create_music_command_classes(debug=False):
|
|||||||
klass_name = cmd_name+"Command"
|
klass_name = cmd_name+"Command"
|
||||||
klass = classobj(klass_name, (Command,), params)
|
klass = classobj(klass_name, (Command,), params)
|
||||||
globals()[klass_name] = klass
|
globals()[klass_name] = klass
|
||||||
|
if klass.macro_name == "notetype":
|
||||||
|
klass.allowed_lengths = [1, 2]
|
||||||
|
elif klass.macro_name in ["togglenoise", "sfxtogglenoise"]:
|
||||||
|
klass.allowed_lengths = [0, 1]
|
||||||
klasses.append(klass)
|
klasses.append(klass)
|
||||||
# later an individual klass will be instantiated to handle something
|
# later an individual klass will be instantiated to handle something
|
||||||
return klasses
|
return klasses
|
||||||
|
@@ -490,12 +490,6 @@ def macro_translator(macro, token, line):
|
|||||||
else:
|
else:
|
||||||
allowed_lengths = [allowed_length]
|
allowed_lengths = [allowed_length]
|
||||||
|
|
||||||
if macro.macro_name == "notetype":
|
|
||||||
allowed_lengths = [1,2]
|
|
||||||
elif macro.macro_name == "togglenoise" \
|
|
||||||
or macro.macro_name == "sfxtogglenoise":
|
|
||||||
allowed_lengths = [0,1]
|
|
||||||
|
|
||||||
assert len(params) in allowed_lengths, \
|
assert len(params) in allowed_lengths, \
|
||||||
"mismatched number of parameters on this line: " + \
|
"mismatched number of parameters on this line: " + \
|
||||||
original_line
|
original_line
|
||||||
|
Reference in New Issue
Block a user