Ion Libraries

Ion has eight built-in library routines to make programs smaller and easier to write. The function names are included in ion.inc and you may call them or jump to them at any time in your program provided that your program does not alter the data directly following your program. If you need memory allocation, I recommend creating a temporary program and deleting it after your program is finished. You may also use _insertmem (and _deletemem). However, if you use _insertmem and _deletemem, the library vector table may be destroyed thereby making it impossible to call a library function in your program. It is possible to restore the vector table, but this would require some effort. See the Ion source code if you need to see how the vector table works.

Library Functions

ionVersion

ionVersion:
   Returns version and compatibility numbers.
   Input:   nothing
   Output: hl=Ion version number (e.g 256=1.0)
      a=Ion compatibility number
      d=Library compatibility number
      e=number of library routines
   Destroys: a de hl

ionRandom

ionRandom:
   Generates an eight-bit random number.
   Input:   b=upper bound
   Output: a=answer (between 0 and b-1)
      b=0
   Destroys af b

ionPutSprite

ionPutSprite:
   Draw a sprite to the graph buffer (XOR).
   Input:   b=sprite height
      a=x coordinate
      l=y coordinate
      ix->sprite
   Output:   Sprite is XORed to the graph buffer.
      ix->next sprite
   Destroys: af bc de hl ix

ionLargeSprite

ionLargeSprite:
   Draw a variable width sprite to the graph buffer (XOR).
   Input:   ix->sprite
      a=x coordinate
      l=y coordinate
      b=sprite height
      c=sprite width (in bytes, so divide by 8)
   Output:   sprite is XORed to the graph buffer
      ix->next sprite
   Destroys: af bc de hl ix af'

ionGetPixel

ionGetPixel:
   Get pixel offset and mask.
   Input:   a=x coordinate
      e=y coordinate
   Output:   a=pixel mask
      hl->offset (in the graph buffer)
   Destroys: af bc de hl

ionFastCopy

ionFastCopy:
   Copy the graph buffer to the screen, FAST!
   Input:   nothing
   Output:   graph buffer is copied to the screen
   Destroys: af bc de hl

ionDetect

ionDetect:
   Find a file in the VAT.
   Input:   hl=place to begin search
      ix->detection string (zero terminated)
   Output:   de=place stopped + 1
      hl->program data (after detection string)
      z=0 for success, z=1 if failed
   Destroys: af bc de hl

ionDecompress

ionDecompress:
   Decompress data.
   Input:   hl->compressed data
      de->place to load uncompressed data
      b=length of compressed data
      c=compression factor {1,3,15}
   Output:   data is decompressed
      hl->next byte of compressed data
   Destroys: af bc de hl

History