MyFunctions.lib 702 B

123456789101112131415161718192021222324252627
  1. #importonce // <-- This is a library, we only want it included once
  2. .filenamespace MyFunctions // <-- Sets up a 'MyFunctions' namespace for this file
  3. //-----------------------------
  4. // Help functions
  5. //-----------------------------
  6. .function failOnOverflow(x, limit) { //<-- This function can only be seen within the MyFunctions namespace
  7. .if (x>=limit)
  8. .error("value too high: " + x)
  9. .if (x<0)
  10. .error("value too low:x " + x)
  11. }
  12. //-----------------------------
  13. // Library functions
  14. //-----------------------------
  15. .function @toSpritePtr(addr) { // <-- @ puts this function in the root scope so everyone can see it
  16. .eval failOnOverflow(addr,$10000)
  17. .return (addr&$3fff)/$40
  18. }