REM >>>HACKLIB<<<
REM Library Version 1.0.0
REM Copyright (C) Joshua Beck.
REM Email: mikeosdeveloper@gmail.com
REM Licenced under the GNU General Public Licence revision 3.
REM Requires MikeOS version 4.3 or greater.

PRINT "HACKLIB 1.0.0"
END

XGET:
  POKEINT X 65424
  CALL 65184
  PEEK V 65422
RETURN

XPUT:
  POKEINT X 65424
  POKE V 65422
  CALL 65168
RETURN

XMEM:
  GOSUB SAVEVAR
  POKEINT V 65436
  Y = 65168
  FOR X = 1 TO 32
    READ XMEMASM X W
    POKE W Y
    Y = Y + 1
  NEXT X
  GOSUB LOADVAR
RETURN  

XMEMASM:
6 161 156 255 142 192 160 142 255 139 62 144 255 170 7 195
30 139 54 144 255 161 156 255 142 216 172 31 162 142 255 195

RAWKEYASM:
180 17 205 22 116 8 180 16 205 22 163 254 253 195 199 6 254
253 0 0 195

SAVEVAR:
  POKEINT Y 65426
  PEEK Y 65421
  IF Y > 198 THEN PRINT "HACKLIB: No more variable storage."
  IF Y > 198 THEN END
  Y = Y + 65200
  POKEINT J Y
  Y = Y + 2
  POKEINT W Y
  Y = Y + 2
  POKEINT V Y
  Y = Y + 2
  POKEINT X Y
  Y = Y + 2
  Y = Y - 65200
  POKE Y 65421
  PEEKINT Y 65426
  POKEINT X 65426
  PEEK X 65421
  X = X + 65200
  POKEINT Y X
  X = X + 2
  X = X - 65200
  POKE X 65421
  PEEKINT X 65426
RETURN

LOADVAR:
  POKEINT J 65426
  PEEK J 65421
  IF J = 0 THEN PRINT "HACKLIB: No variables stored."
  IF J = 0 THEN END
  J = J + 65198
  PEEKINT Y J
  J = J - 2
  PEEKINT X J
  J = J - 2
  PEEKINT V J
  J = J - 2
  PEEKINT W J
  J = J - 65202
  POKE J 65421
  J = J + 65200
  PEEKINT J J
RETURN

RAWKEY:
  GOSUB SAVEVAR
  Y = 65000
  FOR X = 1 TO 21
    READ RAWKEYASM X V
    POKE V Y
    Y = Y + 1
  NEXT X

  CALL 65000
  GOSUB LOADVAR
  PEEKINT V 65022
RETURN
