REM > <HeeHeeHee$Dir>.GameLib

DEF PROCAmnesia_Init(Size%)
LOCAL Block%
DIM Block% Size%
SYS"Amnesia_Init", Block%, Size%, 0
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCAmnesia_ClaimTable(Table%, Flags%, Objects%, Size%)
SYS"Amnesia_ClaimTable", Table%, Flags%,, Objects%, Size%
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCAmnesia_SetGravity(X_Gravity%, Y_Gravity%)
SYS"Amnesia_SetGravity", X_Gravity%, Y_Gravity%
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCAmnesia_SetWindow(Window%, MinX%, MinY%, MaxX%, MaxY%)
SYS"Amnesia_SetWindow", Window%, MinX%, MinY%, MaxX%, MaxY%
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCAmnesia_SetPlotOffset(X_Offset%, Y_Offset%)
SYS"Amnesia_SetPlotOffset", X_Offset%, Y_Offset%
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCAmnesia_MakeObject(Table%, Sprite%, Flags%, X%, Y%)
IF FNAmnesia_MakeObject(Table%, Sprite%, Flags%, X%, Y%)
ENDPROC

DEF FNAmnesia_MakeObject(Table%, Sprite%, Flags%, X%, Y%)
LOCAL Object%

SYS"Amnesia_MakeObject", Table%, Sprite%, Flags%, X%, Y% TO , Object%
IF Object% = 0 THEN ERROR 1, "Could not create object in table " + STR$Table%
=Object%

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCFastSpr_Load(FSP%, Name$)
LOCAL Addr%
SYS"FastSpr_GetPointer", FSP% TO Addr%
SYS"Amnesia_LoadFile", Addr%, Name$, 0
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCFastSpr_SetClipWindow(MinX%, MinY%, MaxX%, MaxY%)
SYS"FastSpr_SetClipWindow", MinX%, MinY%, MaxX%, MaxY%
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCFastSpr_SetBackdrop(Colour%)
SYS"FastSpr_SetBackdrop", Colour%
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCFastSpr_Plot(Sprite%, X%, Y%)
SYS"FastSpr_Plot", Sprite%, X%, Y%
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCFastSpr_Bank(Bank%)
SYS"FastSpr_ScreenBank", Bank% - 1
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCGameLib_Show(Pale%, Text$)
LOCAL Colo%, Hand%
SYS"FastSpr_SetClipWindow", 0, 0, 320, 256
SYS"OS_Byte", 113, 2
SYS"OS_Byte", 112, 1
SYS"ColourTrans_ReturnColourNumber", Pale% TO Colo%
SYS"FastSpr_SetBackdrop", Colo%
SYS"FastSpr_ScreenBank", 0
SYS"FastSpr_ClearWindow"
SYS"Font_FindFont",, "Homerton.Bold", 32 * 16, 32 * 16 TO Hand%
SYS"ColourTrans_SetFontColours",, Pale%, &FFFFFF00, 14
B%!00 = 0
B%!04 = 0
B%!08 = 0
B%!12 = 0
B%!16 = -1
SYS"Font_ScanString",, Text$, %1000000001000100000, -1, -1, B%
SYS"Font_Paint",, Text$, %1000000000, 640 * 400 - (B%!28 - B%!20) / 2, 512 * 400 - (B%!32 - B%!24) / 2
SYS"Font_LoseFont", Hand%
SYS"OS_Byte", 113, 1
Pale_Global% = Pale%
Fade_Pale% = (Pale% >> 8) AND &00FFFFFF
Row% = 0
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCGameLib_Text(Text$)
SYS"Font_FindFont",, "Homerton.Bold", 32 * 16, 32 * 16 TO Hand%
SYS"ColourTrans_SetFontColours",, Pale_Global%, &FFFFFF00, 14
SYS"Font_Paint",, Text$, %1000000000, 100 * 400, (900 - (Row% * 100)) * 400
SYS"Font_LoseFont", Hand%
Row% += 1
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCGameLib_Fade
LOCAL Colo%
Numb% = Fade_Pale%
 REPEAT
  BB% = Numb% AND &FF0000
  GG% = Numb% AND &00FF00
  RR% = Numb% AND &0000FF
  IF BB% > 0 THEN BB% -= &020000: IF BB% < 0 THEN BB% = 0
  IF GG% > 0 THEN GG% -= &000200: IF GG% < 0 THEN GG% = 0
  IF RR% > 0 THEN RR% -= &000002: IF RR% < 0 THEN RR% = 0
  Numb% = BB% + GG% + RR%
  SYS"ColourTrans_ReturnColourNumber", Numb% << 8 TO Colo%
  SYS"FastSpr_SetBackdrop", Colo%
  SYS"FastSpr_ClearWindow"
 UNTIL Numb% = 0
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCGameLib_Error
ON ERROR ON ERROR OFF: REPORT: PRINT ERL: END

SYS"Wimp_Initialise", 200, &4B534154, "Throwback"
SYS"XOS_SWINumberFromString",, "DDEUtils_ThrowbackStart" TO ;PFlg%
 IF (PFlg% AND 1) = 0 THEN
  T$ = "<HeeHeeHee$Dir>.!RunImage"
  T% = INSTR(REPORT$, "in """)
  IF T% THEN T$ = MID$(REPORT$, T% + 4, LEN(REPORT$) - T% - 4)
  SYS"DDEUtils_ThrowbackStart"
  SYS"DDEUtils_ThrowbackSend", 0,, T$
  SYS"DDEUtils_ThrowbackSend", 1,, T$, ERL, 1, REPORT$+" (Code &"+STR$~ERR+")"
  SYS"DDEUtils_ThrowbackEnd"
 ENDIF

ERROR 0, REPORT$ + " (" + STR$ERL + ")"
END
