Skip to content

Commit

Permalink
Fix hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
mateoconlechuga committed Oct 12, 2017
1 parent 44a2c1e commit 4f2f867
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 53 deletions.
Binary file modified src/cesium.8xp
Binary file not shown.
4 changes: 2 additions & 2 deletions src/data/textFrench.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ AutoBackupStr:
.db "Sauver la RAM avant de lancer des prgms",0
ListAppsStr:
.db "les applications Flash",0
RunOnBootStr:
.db "Lancer Cesium au d",$82,"marrage",0
ShortcutsStr:
.db "Activer les raccourcis clavier",0
ErrorStr:
.db "ERREUR : Version",0
LibStr:
Expand Down
14 changes: 14 additions & 0 deletions src/routines/common.asm
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ FindAppStart:
CesiumAppName:
.db "Cesium",0

SetKeyHookPtr:
call FindAppStart
ld bc,0-CesiumStart
add hl,bc
push hl
ld bc,GetKeyHook
add hl,bc
ld (rawKeyHookPtr),hl
ld a,(shortcutKeys)
or a,a
call nz,_SetRawKeyHook
pop hl
ret

DeletePgrmFromUserMem:
ld de,(asm_prgm_size) ; load total program totalPrgmSize
or a,a
Expand Down
4 changes: 4 additions & 0 deletions src/routines/exit.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ FullExit:
ld a,(AutoBackup)
or a,a
call nz,ClearOldBackup
call SetKeyHookPtr
ld hl,appdata
ld bc,200
call _MemClear
ld hl,WipeSafeRam_Start
ld de,WipeSafeRam
ld bc,WipeSafeRam_End-WipeSafeRam_Start
Expand Down
53 changes: 16 additions & 37 deletions src/routines/hooks.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ StopEverything:
GetKeyHook:
add a,e
cp a,kPrgm
ret nz
jr z,StartCesium
ret

StartCesium:
di
ld hl,$f0202c
ld (hl),l
Expand All @@ -31,7 +34,14 @@ GetKeyHook:
ld (menuCurrent),a
res curAble, (iy + curFlags)
call _CloseEditEqu
ld hl,OP1 ; execute app
ld de,(asm_prgm_size) ; load total program size
or a,a
sbc hl,hl
ld (asm_prgm_size),hl ; delete whatever current program was there (in case someone uses getkey in a program)
ld hl,userMem
call _DelMem
ld hl,OP1 ; execute app
push hl
ld (hl),'C'
inc hl
ld (hl),'e'
Expand All @@ -45,57 +55,26 @@ GetKeyHook:
ld (hl),'m'
inc hl
ld (hl),0
ld hl,OP1
push hl
ld de,(asm_prgm_size) ; load total program prgmSize
or a,a
sbc hl,hl
ld (asm_prgm_size),hl ; delete whatever current program was there
ld hl,userMem
call _DelMem ; HL->place to delete, DE=amount to delete
ld hl,$100
call _EnoughMem
pop hl
jp c, _ErrMemory
call _FindAppStart ; This locates the start of executable code for an app
ld a,E_Validation
jp c,_JError ; If we can't find it, that's a problem (throw a validation error)
push hl ; push location of start of app
push hl
call _ReloadAppEntryVecs
call _RunIndicOff
call _AppSetup
set appRunning,(iy+APIFlg) ; turn on apps
set 6,(iy+$28)
res 0,(iy+$2C) ; set some app flags
set appAllowContext,(iy+APIFlg) ; turn on apps
ld hl,$D1787C ; copy to ram data location
ld bc,$FFF
call _MemClear ; zero out the ram data section
pop hl ; hl -> start of app
push hl ; de -> start of code for app
ld bc,$100 ; bypass header information
add hl,bc
ex de,hl
ld hl,$18 ; find the start of the data to copy to ram
add hl,de
ld hl,(hl)
call __icmpzero ; initialize the bss if it exists
jr z,+_
push hl
pop bc
ld hl,$15
add hl,de
ld hl,(hl)
add hl,de
ld de,$D1787C ; copy it in
ldir
_: pop hl ; hl -> start of app
ld bc,$100 ; bypass some header info
add hl,bc
push hl
pop de
ld bc,$12 ; offset
add hl,bc
ld hl,(hl)
add hl,de
pop bc
add hl,bc
xor a,a
jp (hl)
22 changes: 9 additions & 13 deletions src/routines/main.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CESIUM_OS_BEGIN:
push af
cp a,$aa
jr z,LoadSettings
xor a,a
sbc hl,hl
ld (currSelAbs),hl
ld (scrollamt),hl
ld (currSel),a ; op1 holds the name of this program

LoadSettings:
ld hl,settingsAppVar
call _Mov9ToOP1
Expand All @@ -24,9 +31,7 @@ LoadSettings:
ld de,TmpSettings
ldir ; copy the temporary settings to the lower stack
call FindAppStart
ld bc,0-CesiumStart
add hl,bc
call SetKeyHookPtr
push hl
ld bc,ParserHook
add hl,bc
Expand Down Expand Up @@ -54,15 +59,6 @@ LoadSettings:
ld bc,ErrCatchBASIC
add hl,bc
ld (BASICERROR_HANDLER+1),hl
pop af
cp a,$AA
jr z,RELOADED_FROM_PRGM
xor a,a
sbc hl,hl
ld (currSelAbs),hl
ld (scrollamt),hl
ld (currSel),a ; op1 holds the name of this program
RELOADED_FROM_PRGM:
res onInterrupt,(iy+OnFlags) ; this bit of stuff just enables the [on] key
call ClearScreens
call _GetBatteryStatus ;> 75%=4 ;50%-75%=3 ;25%-50%=2 ;5%-25%=1 ;< 5%=0
Expand Down
Empty file removed src/routines/reloader.asm
Empty file.
2 changes: 1 addition & 1 deletion src/routines/settings.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CreateDefaultSettings:
ld hl,10
ld hl,12
call _EnoughMem
jp c,FullExit
ld hl,10
Expand Down

0 comments on commit 4f2f867

Please sign in to comment.