-
Notifications
You must be signed in to change notification settings - Fork 0
/
hierarchic.c
124 lines (99 loc) · 1.65 KB
/
hierarchic.c
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
#pragma noroot
#pragma optimize -1
#include <memory.h>
#include <locator.h>
#include "hierarchic.h"
static asm void __Hierarchic(void) {
jml 0xffffff
}
static int Hierarchic = 0;
int HierarchicStartUp(unsigned memID) {
static struct {
unsigned length;
char name[15];
} message = {15 + 2, "\pBSS:Hierarchic" };
ResponseRecord r; // message id / create flag
Handle h;
unsigned char *ptr;
Hierarchic = 0;
r = MessageByName(0, (Pointer)&message);
if (_toolErr) return 0;
h = NewHandle(0, memID, 0, 0);
if (_toolErr) return 0;
MessageCenter(getMessage, (word)r, h);
if (_toolErr) goto exit;
ptr = *(unsigned char **)h;
asm {
ldy #0x19
lda [ptr],y
xba
sta __Hierarchic+2
dey
dey
lda [ptr],y
sta __Hierarchic+1
lda #1 // StartUp
jsl __Hierarchic
}
Hierarchic = 1;
exit:
DisposeHandle(h);
return Hierarchic;
}
MenuRecHndl HierarchicNew(unsigned refDesc, Ref ref) {
MenuRecHndl rv = 0;
if (Hierarchic) {
asm {
pea 0
pea 0
pei refDesc
pei ref+2
pei ref
lda #4 // New
jsl __Hierarchic
pla
sta rv
pla
sta rv+2
}
}
return rv;
}
MenuRecHndl HierarchicGetMenuHandle(MenuRecHndl parent, unsigned menuID) {
MenuRecHndl rv = 0;
if (Hierarchic) {
asm {
pea 0
pea 0
pei parent+2
pei parent
pei menuID
lda #9 // GetMenuHandle
jsl __Hierarchic
pla
sta rv
pla
sta rv+2
}
}
return rv;
}
void HierarchicShutDown(void) {
if (Hierarchic) {
asm {
lda #2 // ShutDown
jsl __Hierarchic
}
Hierarchic = 0;
}
}
void HierarchicDispose(MenuRecHndl menu) {
if (Hierarchic) {
asm {
pei menu+2
pei menu
lda #5 // Dispose
jsl __Hierarchic
}
}
}