-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathparserhook.inc
146 lines (144 loc) · 2.62 KB
/
parserhook.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
;-----------------------------------------------------------
; Filename: parserhook.asm
; Long name: HomeRun Hook for homescreen execution
; Authors: Kerm Martian aka Christopher Mitchell
; Last Update: Unknown
;
;
;Please consult license.txt for the fair use agreement
;implicitly binding by you continuing to read past this
;point. Close and delete this file if you do not agree
;to the terms of the agreement.
;-----------------------------------------------------------
ParserHook:
add a,e
or a
jr z,ParserHookChkPrgm
cp a
ret
ParserHookChkPrgm:
ld hl,parseVar
push hl
rst 20h
pop hl
ld a,(hl)
cp 5 ;ProgObj
jr z,ParserHookRunPrgm
cp 6 ;ProtProgObj
jr nz,ParserHookExit
ParserHookRunPrgm:
bcall(_chkfindsym)
jr c,ParserHookExit
ld a,(parseVar+1)
cp '#'
jr z,ParserHookHomescreen
push hl
bcall(_DisableParserHook)
bcall(_DisableLaunchKeyhook)
res indicRun,(iy+IndicFlags)
pop hl
bcall(_RunProgFromHook)
push af
set CurAble,(iy+CurFlags)
res textWrite,(iy+SgrFlags)
ld a,%11010000
out (0),a
im 1
ei
bcall(_getcsc)
; ld a,40h \ bcall(_newContext) ;homescreen context
bcall(_EnableLaunchKeyhook)
bcall(_EnableMyParserhook)
pop af
jr c,ParserHookFullExit
; res plotDisp,(iy+plotFlags)
or 1 ;reset zero flag
ret
ParserHookFullExit:
bcall(_clrtxtshd)
bcall(_homeup)
ld a,kClear
bjump(_jforcecmd)
ParserHookExit:
bcall(_EnableMyParserHook)
xor a
ret
ParserHookHomescreen:
;HL points to size bytes
ex de,hl
ld c,(hl)
inc hl
ld b,(hl)
inc hl
ld (wByteCount),bc
ParserHookHomescreenFindLoop:
call getHomescreenToken
jr c,ParserHookExit
cp 5Fh
jr z,prgmTokenFound
ParserHookHomescreenParseLoop:
call getHomescreenToken
jr c,ParserHookExit
cp 3Eh
jr z,ParserHookHomescreenFindLoop
cp 3Fh
jr z,ParserHookHomescreenFindLoop
jr ParserHookHomescreenParseLoop
prgmTokenFound:
push hl
ld hl,parseVar
ld de,basicProgBackup
ld bc,9
ldir
pop hl
ld ix,parseVar+1
call getHomescreenByte
jr c,ParserHookExit
cp '#'
jr z,ParserHookExit
prgmTokenLoop:
ld (ix+0),a
inc ix
call getHomescreenByte
jr c,prgmTokenLoopOut
cp 3Eh
jr z,prgmTokenLoopOut
cp 3Fh
jr z,prgmTokenLoopOut
jr prgmTokenLoop
prgmTokenLoopOut:
xor a
ld (ix+0),a
call ParserHookChkPrgm
ret nz
ld hl,basicProgBackup
ld de,parseVar
ld bc,9
ldir
ret
getHomescreenToken:
call getHomescreenByte
ret c
B_CALL(_isA2ByteTok)
scf
ccf
ret nz
push af
call getHomescreenByte
ld e,a
pop bc
ld a,b
ret
getHomescreenByte:
ld d,(hl)
inc hl
ld bc,(wByteCount)
dec bc
ld (wByteCount),bc
inc bc
ld a,b
or c
ld a,d
ret nz
scf
ret