| To HD install:
| 1. Copy !Haunted to HD
| 2. Replace the contents of !Haunted.!Run with:
|  ADFBootFloppy F1061101 %*0
IF "<Obey$Dir>"="@" THEN Set Obey$Dir ADFS::Haunted.$.!Haunted

IF "<Haunt$Loaded>" <> "" THEN Error You can't run two copies of Haunted House at once
IconSprites <Obey$Dir>.!Sprites
Set File$Type_230 Ghostly
Set Haunt$Dir <Obey$Dir>
Set Alias$@RunType_230 <Haunt$Dir>.!Run %%*0
Set HauntData$Dir <Haunt$Dir>
Set Def1$Path <Obey$Dir>.
Set Disc1$dir <Def1$Path>

WimpSlot -min 1328K -max 1328K
IF ADFFS$CPUID>&A10 THEN GOARM4JIT 0
StoreCSD
RMLoad <Haunt$Dir>.SELECTION
RMLoad <Haunt$Dir>.hauntmod
| Fix issues in the BASIC code: pause correctly, don't nag about BPP, regulate blackbird speed, quit correctly, load file via variable
| PAGE=&81A00
Set Key$0 HIMEM=&134000:PAGE=&48000|MLOAD "|<Haunt$Dir>.!RunImage"|M10|M21PROCwiperuck:PROCdefault:SYS&20023,"Haunt$File",,-1,0TO,,A%|M22IF A%<0 THEN|M23DIM file% -A%+1|M24SYS&20023,"Haunt$File",file%,-A%+1,0TO,,A%:file%?A%=13|M25|M26E$=$file%|M

| Use SpriteOp instead of direct screen access in getdata/putdata
Set Key$1 313PROCA(x%,y%)|M872A%=x%:B%=y%|M1027PROCA(mx%,my%)|M1055PROCA(mx%,my%)|M1830PROCA(dx%,dy%):D%=Dhi%+1:CALLgetdata|M1866PROCA(dx%,dy%):D%=Dhi%+1:CALLgetdata|M1880PROCA(dx%,dy%):D%=Dhi%+1:CALLgetdata|M

| Use SpriteOp in getdata @ D9EC
Set Key$2 19P%=&D9F0:[OPT2:MOV R4,R0:MOV R5,R1:ADD R6,R4,#96<<xshift:ADD R7,R5,R3,LSL#yshift:MOV R3,#0:MOV R2,#&134000:ADD R1,R2,#4:MOV R0,#16+256:STMIA R1!,{R4,R5}:SWI "XOS_SpriteOp":LDMFD R13!,{R0-R12,PC}:]|M

| Use SpriteOp in putdata @ DAA4 (DAB0 dab4)
Set Key$3 20P%=&DAA8:[OPT2:MOV R0,#19:SWI "OS_Byte":MOV R5,#0:MOV R2,#&134000:ADD R1,R2,#4:MOV R0,#256:ADD R0,R0,#34:LDMIA R1!,{R3,R4}:SWI "XOS_SpriteOp":LDMFD R13!,{R0-R12,PC}:]|M

| Initialise Sprite area @ 134000
Set Key$4 3100DEFPROCA(Lx%,Ly%):A%=Lx%+Ofx%:B%=Ly%+Ofy%:ENDPROC|M3001A%=&134000:!A%=&41:A%!12=128*1024:A%!16=0:A%!20=16:A%!24=16:SYS "XOS_SpriteOp",9+256,A%+12|M289=t1%+t2%+8|M442ENDPROC|M1673WAIT:NEXT|M1687WAIT:NEXT|M3008QUIT|M

| Bugfix: Use local ColourTrans table
Set Key$5 409DEFPROCdoanim:LOCAL trans%,A%|M410SYS"ColourTrans_SelectTable",sprite%,"dr"+STR$anim%,-1,-1,0 TO,,,,A%:DIM trans% A%:SYS"ColourTrans_SelectTable",sprite%,"dr"+STR$anim%,-1,-1,trans%:CASEanim%OF|M

| Increase the size of sprite% and mag% to handle 32bit MODEs
Set Key$6 2997Z%=spriteF%-sprite%:spriteF%-=Z%:compsprites-=Z%:compwk-=Z%:DIM sprite% 250*1024:ENDPROC|M2237!sprite%=250*1024:!spriteF%=150*1024:spriteF%!8=16|M2227 DIM mag% 256*1024|M2228!mag%=256*1024|M*UnSet Key$*|MRUN|F|M

HideCommandWindow
ECHO <21>
FX 21,0
FX 138,0,128
FX 138,0,129
FX 138,0,130
FX 138,0,131
FX 138,0,132
FX 138,0,133
FX 138,0,134
BASIC
RestoreCSD
IF ADFFS$CPUID>&A10 THEN GOARM4JIT
UnSet HauntData$Dir
UnSet Def1$Path
UnSet Disc1$dir