#define prgmmovsize prgmmov_end - prgmmov_start prgmrun: call _HomeUp call _RunIndicOn call _APDSetup call _EnableAPD jp prgmloader prgminstallload: ld hl, prgmloader_start ld de, SafeSScreen ld bc, prgmmovsize ldir ret prgmloader_start: relocate(SafeSScreen) prgmmov_start: prgmmov: prgmloader: call prgm_del_usermem; now we deleted ourselves. cool. call _boot_ClearVRAM ;ld a,$2D ;ld (mpLcdCtrl),a ; Set LCD to 16bpp call _DrawStatusBar ;ld hl,(prgmNamePtr) ;call NamePtrToOP1 call prgm_to_usermem ld hl, userMem inc hl inc hl ld a, (hl) cp a,tExtTok jr z, runBasicProgram ; is it a basic program ld hl, prgmunloader;ErrCatchBASIC call _PushErrorHandler ld hl, prgmunloader push hl jp userMem ; simply call userMem to execute the program runBasicProgram: call _RunIndicOn ;call DeleteTempProgramGetName ;ld hl,(asm_prgm_size);actualSizePrgm) ;push hl ;call _CreateProg ; create a temp program so we can execute ;inc de ;inc de ;pop bc ;call _ChkBCIs0 ;jr z,InROM ; there's nothing to copy ;ld hl,(userMem) ;ldi ;jp po,InROM ;ldir InROM: ;call _OP4ToOP1 GoodInRAM: ;ld de,apperr1 ;ld hl,StopError ;ld bc,StopErrorEnd-StopError ;ldir set graphdraw,(iy+graphFlags) ld hl,ErrCatchBASIC call _PushErrorHandler set progExecuting,(iy+newdispf) set allowProgTokens,(iy+newDispF) set cmdExec,(iy+cmdFlags) ;settheseflagsto execute BASIC prgm res onInterrupt,(iy+onflags) ld hl, prgmunloader push hl sub a,a ld (kbdGetKy),a ei halt jp _ParseInp ; run program ErrCatchBASIC: call _boot_ClearVRAM call _DrawStatusBar call _DispErrorScreen set textInverse, (iy + textFlags) ld hl,1 ld (curRow),hl ld hl,QuitStr1 call _PutS res textInverse, (iy + textFlags) ld hl,QuitStr2 call _PutS call _GetKey jr +_ QuitStr1: .db "1:",0 QuitStr2: .db "Quit",0 prgmunloader: call _PopErrorHandler _: ld hl, prgmFsh call _Mov9ToOP1 call _ChkFindSym call _ChkInRam ex de,hl jr z,ExistsInRAM ld de,9 add hl,de ld e,(hl) add hl,de inc hl ExistsInRAM: ; HL->totalPrgmSize bytes call prgm_to_usermem call _RunIndicOff jp userMem prgm_to_usermem: ld a, 09h ; 'add hl,bc' ld (offset_SMC),a call _ChkFindSym call _ChkInRam ex de,hl jr z,AlreadyInRAM xor a,a ld (offset_SMC),a ld de,9 add hl,de ld e,(hl) add hl,de inc hl AlreadyInRAM: ; HL->totalPrgmSize bytes call _LoadDEInd_s inc hl inc hl ; bypass bytes $EF,$7B (texttok,tasm84cecmp) push hl push de ex de,hl call _ErrNotEnoughMem; check and see if we have enough memory left for this operation pop hl ld (asm_prgm_size),hl; store the totalPrgmSize of the program to asm_prgm_size for later use ld de,userMem push de call _InsertMem ; insert memory into the userspace pop de pop hl ; HL->start of program ld bc,(asm_prgm_size) ; load totalPrgmSize of current program offset_SMC: add hl,bc ; if in ram, do this; otherwise, smc it so it doesn't execute ldir ; copy the program to userMem ret ; return prgm_del_usermem: ld de,(asm_prgm_size) ; load total program totalPrgmSize or a,a sbc hl,hl ld (asm_prgm_size),hl ; delete whatever current program was there ld hl,userMem jp _DelMem ; HL->place to delete, DE=amount to delete DeleteTempProgramGetName: ld hl,tmpPrgmName call _Mov9ToOP1 call _PushOP1 call _ChkFindSym call nc,_DelVarArc ; delete the temp prgm if it exists jp _PopOP1 prgmattributes: tmpPrgmName: .db tempProgObj,"ZTGP",0 prgmFsh: .db ProgObj, "FSHA", 0 prgmFlags: .db $00 ;basic #define isasm equ 0 #define isbasic equ 1 #define isice equ 2 prgmmov_end: endrelocate()