143 lines
3.0 KiB
NASM
143 lines
3.0 KiB
NASM
#define prgmmovsize prgmmov_end - prgmmov_start
|
|
|
|
prgmbasic:
|
|
|
|
prgmasm:
|
|
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
|
|
;bit isBasic,(iy+pgrmStatus)
|
|
;jp nz,RunBasicProgram
|
|
ld a, 's'
|
|
call _PutC
|
|
call prgm_to_usermem; the program is now stored at userMem -- Now we need to check and see what kind of file it is - C or assembly
|
|
push hl
|
|
ld hl, prgmunloader
|
|
call _PushErrorHandler
|
|
ld hl, prgmunloader
|
|
push hl
|
|
jp userMem ; simply call userMem to execute the program
|
|
|
|
RunBasicProgram:
|
|
call _RunIndicOn
|
|
call DeleteTempProgramGetName
|
|
;ld hl,(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,(prgmDataPtr)
|
|
;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,ReturnHereBASIC
|
|
;push hl
|
|
;sub a,a
|
|
;ld (kbdGetKy),a
|
|
ei
|
|
jp _ParseInp ; run program
|
|
|
|
prgmunloader:
|
|
ld hl, prgmFsh
|
|
call _Mov9ToOP1
|
|
call prgm_to_usermem
|
|
call _RunIndicOff
|
|
jp Fin
|
|
|
|
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
|
|
|
|
tmpPrgmName: .db tempProgObj,"ZTGP",0
|
|
prgmFsh: .db ProgObj, "FSHA", 0
|
|
prgmmov_end:
|
|
endrelocate()
|