Skip to content

Instantly share code, notes, and snippets.

@ShadowOne333
Created November 27, 2019 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShadowOne333/9a5526fc8be705c66d67c43ba8a05d60 to your computer and use it in GitHub Desktop.
Save ShadowOne333/9a5526fc8be705c66d67c43ba8a05d60 to your computer and use it in GitHub Desktop.
import ebpp
define FIRST_CAPSULE_ITEM = 1
define AMOUNT_OF_CAPSULE_ITEMS = 3
txt_liquid: "drank" eob
txt_capsule: "swallowed" eob
command drink_verb(item_number) {
// Store the contents of register 0 on the stack
push(0)
push(1)
// Store the item number in register 0
load32c(0, item_number)
// Call subroutine
call(_drink_verb)
// Restore registers 0,1
pull(1)
pull(0)
}
_drink_verb: {
// Set register 1 to 1 if register 0 < FIRST_CAPSULE_ITEM
ltc(1, 0, FIRST_CAPSULE_ITEM)
// If register 1 == 1, this is not a capsule
mov_reg_result(1)
if (result_is(1)) {
call(txt_liquid)
eob
}
// Register 0 = Register 0 - FIRST_CAPSULE_ITEM
subc(0, 0, FIRST_CAPSULE_ITEM)
// Set register 0 to 1 if this is a capsule item
ltc(0, 0, AMOUNT_OF_CAPSULE_ITEMS)
// Print the correct verb
mov_reg_result(0)
if (result_is(1)) {
call(txt_capsule)
eob
}
call(txt_liquid)
eob
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment