Skip to content

Commit 4f2f867

Browse files
Fix hooks
1 parent 44a2c1e commit 4f2f867

File tree

8 files changed

+46
-53
lines changed

8 files changed

+46
-53
lines changed

src/cesium.8xp

-23 Bytes
Binary file not shown.

src/data/textFrench.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ AutoBackupStr:
1414
.db "Sauver la RAM avant de lancer des prgms",0
1515
ListAppsStr:
1616
.db "les applications Flash",0
17-
RunOnBootStr:
18-
.db "Lancer Cesium au d",$82,"marrage",0
17+
ShortcutsStr:
18+
.db "Activer les raccourcis clavier",0
1919
ErrorStr:
2020
.db "ERREUR : Version",0
2121
LibStr:

src/routines/common.asm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,20 @@ FindAppStart:
105105
CesiumAppName:
106106
.db "Cesium",0
107107

108+
SetKeyHookPtr:
109+
call FindAppStart
110+
ld bc,0-CesiumStart
111+
add hl,bc
112+
push hl
113+
ld bc,GetKeyHook
114+
add hl,bc
115+
ld (rawKeyHookPtr),hl
116+
ld a,(shortcutKeys)
117+
or a,a
118+
call nz,_SetRawKeyHook
119+
pop hl
120+
ret
121+
108122
DeletePgrmFromUserMem:
109123
ld de,(asm_prgm_size) ; load total program totalPrgmSize
110124
or a,a

src/routines/exit.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ FullExit:
1111
ld a,(AutoBackup)
1212
or a,a
1313
call nz,ClearOldBackup
14+
call SetKeyHookPtr
15+
ld hl,appdata
16+
ld bc,200
17+
call _MemClear
1418
ld hl,WipeSafeRam_Start
1519
ld de,WipeSafeRam
1620
ld bc,WipeSafeRam_End-WipeSafeRam_Start

src/routines/hooks.asm

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ StopEverything:
2020
GetKeyHook:
2121
add a,e
2222
cp a,kPrgm
23-
ret nz
23+
jr z,StartCesium
24+
ret
25+
26+
StartCesium:
2427
di
2528
ld hl,$f0202c
2629
ld (hl),l
@@ -31,7 +34,14 @@ GetKeyHook:
3134
ld (menuCurrent),a
3235
res curAble, (iy + curFlags)
3336
call _CloseEditEqu
34-
ld hl,OP1 ; execute app
37+
ld de,(asm_prgm_size) ; load total program size
38+
or a,a
39+
sbc hl,hl
40+
ld (asm_prgm_size),hl ; delete whatever current program was there (in case someone uses getkey in a program)
41+
ld hl,userMem
42+
call _DelMem
43+
ld hl,OP1 ; execute app
44+
push hl
3545
ld (hl),'C'
3646
inc hl
3747
ld (hl),'e'
@@ -45,57 +55,26 @@ GetKeyHook:
4555
ld (hl),'m'
4656
inc hl
4757
ld (hl),0
48-
ld hl,OP1
49-
push hl
50-
ld de,(asm_prgm_size) ; load total program prgmSize
51-
or a,a
52-
sbc hl,hl
53-
ld (asm_prgm_size),hl ; delete whatever current program was there
54-
ld hl,userMem
55-
call _DelMem ; HL->place to delete, DE=amount to delete
56-
ld hl,$100
57-
call _EnoughMem
5858
pop hl
59-
jp c, _ErrMemory
6059
call _FindAppStart ; This locates the start of executable code for an app
6160
ld a,E_Validation
6261
jp c,_JError ; If we can't find it, that's a problem (throw a validation error)
63-
push hl ; push location of start of app
62+
push hl
6463
call _ReloadAppEntryVecs
6564
call _RunIndicOff
6665
call _AppSetup
6766
set appRunning,(iy+APIFlg) ; turn on apps
6867
set 6,(iy+$28)
6968
res 0,(iy+$2C) ; set some app flags
7069
set appAllowContext,(iy+APIFlg) ; turn on apps
71-
ld hl,$D1787C ; copy to ram data location
72-
ld bc,$FFF
73-
call _MemClear ; zero out the ram data section
7470
pop hl ; hl -> start of app
75-
push hl ; de -> start of code for app
76-
ld bc,$100 ; bypass header information
77-
add hl,bc
78-
ex de,hl
79-
ld hl,$18 ; find the start of the data to copy to ram
80-
add hl,de
81-
ld hl,(hl)
82-
call __icmpzero ; initialize the bss if it exists
83-
jr z,+_
84-
push hl
85-
pop bc
86-
ld hl,$15
87-
add hl,de
88-
ld hl,(hl)
89-
add hl,de
90-
ld de,$D1787C ; copy it in
91-
ldir
92-
_: pop hl ; hl -> start of app
9371
ld bc,$100 ; bypass some header info
9472
add hl,bc
9573
push hl
96-
pop de
9774
ld bc,$12 ; offset
9875
add hl,bc
9976
ld hl,(hl)
100-
add hl,de
77+
pop bc
78+
add hl,bc
79+
xor a,a
10180
jp (hl)

src/routines/main.asm

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CESIUM_OS_BEGIN:
2-
push af
2+
cp a,$aa
3+
jr z,LoadSettings
34
5+
xor a,a
6+
sbc hl,hl
7+
ld (currSelAbs),hl
8+
ld (scrollamt),hl
9+
ld (currSel),a ; op1 holds the name of this program
10+
411
LoadSettings:
512
ld hl,settingsAppVar
613
call _Mov9ToOP1
@@ -24,9 +31,7 @@ LoadSettings:
2431
ld de,TmpSettings
2532
ldir ; copy the temporary settings to the lower stack
2633
27-
call FindAppStart
28-
ld bc,0-CesiumStart
29-
add hl,bc
34+
call SetKeyHookPtr
3035
push hl
3136
ld bc,ParserHook
3237
add hl,bc
@@ -54,15 +59,6 @@ LoadSettings:
5459
ld bc,ErrCatchBASIC
5560
add hl,bc
5661
ld (BASICERROR_HANDLER+1),hl
57-
pop af
58-
cp a,$AA
59-
jr z,RELOADED_FROM_PRGM
60-
xor a,a
61-
sbc hl,hl
62-
ld (currSelAbs),hl
63-
ld (scrollamt),hl
64-
ld (currSel),a ; op1 holds the name of this program
65-
RELOADED_FROM_PRGM:
6662
res onInterrupt,(iy+OnFlags) ; this bit of stuff just enables the [on] key
6763
call ClearScreens
6864
call _GetBatteryStatus ;> 75%=4 ;50%-75%=3 ;25%-50%=2 ;5%-25%=1 ;< 5%=0

src/routines/reloader.asm

Whitespace-only changes.

src/routines/settings.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CreateDefaultSettings:
2-
ld hl,10
2+
ld hl,12
33
call _EnoughMem
44
jp c,FullExit
55
ld hl,10

0 commit comments

Comments
 (0)