Skip to content

Commit

Permalink
Default macro parameters use recursion; avoids repeating internal str…
Browse files Browse the repository at this point in the history
…ucture
  • Loading branch information
Rangi42 committed Feb 26, 2018
1 parent f964d04 commit 10173f2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
36 changes: 17 additions & 19 deletions macros/scripts/events.asm
Original file line number Diff line number Diff line change
Expand Up @@ -194,23 +194,23 @@ ENDM

enum giveitem_command ; $1f
giveitem: MACRO
if _NARG == 1
giveitem \1, 1
else
db giveitem_command
db \1 ; item
if _NARG == 2
db \2 ; quantity
else
db 1
endc
ENDM

enum takeitem_command ; $20
takeitem: MACRO
if _NARG == 1
takeitem \1, 1
else
db takeitem_command
db \1 ; item
if _NARG == 2
db \2 ; quantity
else
db 1
endc
ENDM

Expand Down Expand Up @@ -291,22 +291,20 @@ ENDM

enum givepoke_command ; $2d
givepoke: MACRO
if _NARG == 2
givepoke \1, \2, NO_ITEM, FALSE
elif _NARG == 3
givepoke \1, \2, \3, FALSE
else
db givepoke_command
db \1 ; pokemon
db \2 ; level
if _NARG >= 3
db \3 ; item
if _NARG >= 4
db \4 ; trainer
if \4
dw \5 ; trainer_name_pointer
dw \6 ; pkmn_nickname
endc
else
db 0
endc
else
db 0, 0
endc
ENDM

Expand Down Expand Up @@ -473,11 +471,11 @@ ENDM

enum refreshscreen_command ; $48
refreshscreen: MACRO
if _NARG == 0
refreshscreen 0
else
db refreshscreen_command
if _NARG == 1
db \1 ; dummy
else
db 0
endc
ENDM

Expand Down Expand Up @@ -982,12 +980,12 @@ ENDM

enum verbosegiveitem_command ; $9e
verbosegiveitem: MACRO
if _NARG == 1
verbosegiveitem \1, 1
else
db verbosegiveitem_command
db \1 ; item
if _NARG == 2
db \2 ; quantity
else
db 1
endc
ENDM

Expand Down
6 changes: 3 additions & 3 deletions macros/scripts/maps.asm
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ ENDM
itemball: MACRO
;\1: item: from constants/item_constants.asm
;\2: quantity: default 1
if _NARG == 2
db \1, \2
if _NARG == 1
itemball \1, 1
else
db \1, 1
db \1, \2
endc
ENDM

Expand Down
2 changes: 1 addition & 1 deletion maps/Route35GoldenrodGate.asm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ OfficerScript_0x69d37:
writetext UnknownText_0x69eb8
playsound SFX_KEY_ITEM
waitsfx
givepoke SPEAROW, 10, NO_ITEM, 1, GiftSpearowName, GiftSpearowOTName
givepoke SPEAROW, 10, NO_ITEM, TRUE, GiftSpearowName, GiftSpearowOTName
givepokeitem GiftSpearowMail
setevent EVENT_GOT_KENYA
.alreadyhavekenya
Expand Down

0 comments on commit 10173f2

Please sign in to comment.