FreeCalypso > hg > fc-tourmaline
annotate src/ui/bmi/mmiBlkResources.c @ 162:0b97ee8bf778
mmiSatCall.c: bogotab fixes
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 18 Nov 2020 21:50:20 +0000 |
parents | 67b91d34f75e |
children |
rev | line source |
---|---|
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /******************************************************************************* |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
3 CONDAT (UK) |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
5 ******************************************************************************** |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 This software product is the property of Condat (UK) Ltd and may not be |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
8 disclosed to any third party without the express permission of the owner. |
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
9 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 ******************************************************************************** |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
12 $Project name: Basic MMI |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
13 $Project code: BMI (6349) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
14 $Module: PhoneBook |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
15 $File: MmiBlkResources.c |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
16 $Revision: 1.0 |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
17 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
18 $Author: Condat(UK) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
19 $Date: 25/10/00 |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
20 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 ******************************************************************************** |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
22 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 Description: |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 This modules provides, in conjunction with the MmiBlkManager module, |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
26 the resource management facilities for the MMI. |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
27 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 ******************************************************************************** |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 $History: MmiBlkResources.c |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
32 25/10/00 Original Condat(UK) BMI version. |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
33 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 $End |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 *******************************************************************************/ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 /******************************************************************************* |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
40 |
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
41 Include Files |
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
42 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 *******************************************************************************/ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 #define ENTITY_MFW |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 /* includes */ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 #include <string.h> |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 #include <stdio.h> |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 #include <stdlib.h> |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 #if defined (NEW_FRAME) |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 #include "typedefs.h" |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 #include "vsi.h" |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 #include "pei.h" |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 #include "custom.h" |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 #include "gsm.h" |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 #else |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 #include "STDDEFS.H" |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 #include "custom.h" |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 #include "gsm.h" |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 #include "vsi.h" |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 #endif |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 // #include <malloc.h> |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 #include "MmiBlkResources.h" |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 /******************************************************************************* |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
73 |
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
74 Local Structures |
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
75 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 *******************************************************************************/ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 /* Define the control structures used to implement the block resource |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 manager |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 */ |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
81 #define RESOURCE_MANAGER_KEY 0x00BABE02L |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
82 #define RESOURCE_SEARCH_LIMIT 4 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 typedef struct _tBlkEntry_ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 { |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
86 tBlkId BlkId; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
87 tBlkHandle BlkHandle; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 } tBlkEntry, *pBlkEntry; |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 typedef struct _tBlkControl_ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 { |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
92 long int BlkKey; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
93 tBlkHandle BlkBase; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
94 int BlkLength; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
95 pBlkEntry BlkStartPtr; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
96 tBlkHandle BlkMinAddress; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
97 tBlkHandle BlkMaxAddress; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 } tBlkControl, *pBlkControl; |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 /******************************************************************************* |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
102 |
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
103 Private Routines |
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
104 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 *******************************************************************************/ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 /******************************************************************************* |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
109 $Function: ValidBlockResource |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
111 $Description: Verifies that the resource indicated by the handle is a valid |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 resource. |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
114 $Returns: 0 If invalid, non-zero if valid. |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
116 $Arguments: BlkRsrc, handle of resource |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
117 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 *******************************************************************************/ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 static int ValidBlockResource( tBlkHandle BlkRsrc ) |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 { |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
123 pBlkControl BlkControl = (pBlkControl) BlkRsrc; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
125 /* Check for non-NULL handle |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
126 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
127 if ( BlkControl == NULL ) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
128 return 0; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
130 /* Check key has been set up correctly |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
131 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
132 return ( BlkControl->BlkKey == RESOURCE_MANAGER_KEY ); |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 } |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 /******************************************************************************* |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
137 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 Public Routines |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
139 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 *******************************************************************************/ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 /******************************************************************************* |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
144 $Function: mmibr_Initialise |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 $Description: |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 The initialisation routine must be called as part of the startup |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 phase of the system, it will allocate working space for the block |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 handler if required, and will initialise any structures required |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 to maintain the corect operation of the functions. This routine |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 must be called prior to invocation of any other block resource |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 function |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
155 $Returns: Handle to a resource block, NULL if unsuccessful |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
157 $Arguments: BlkBase, Base address of the block of data relating |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 to the resource |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
159 NumEntries, number of entries associated with the resource |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
160 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 *******************************************************************************/ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 tBlkHandle mmibr_Initialise( tBlkHandle BlkBase, int NumEntries ) |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 { |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
165 pBlkControl Blk; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
166 int i; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
168 /* As part of the initialisation process, we need to allocate a |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
169 block of memory in which to store the control information |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
170 associated with this block resource manager |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
171 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
172 if ( ( Blk = (pBlkControl) ALLOC_MEMORY( sizeof(tBlkControl) ) ) != NULL ) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
173 { |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
174 /* Store the things we know straight off |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
175 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
176 Blk->BlkKey = RESOURCE_MANAGER_KEY; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
177 Blk->BlkBase = BlkBase; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
178 Blk->BlkLength = NumEntries; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
179 Blk->BlkStartPtr = (pBlkEntry) BlkBase; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
181 /* In order to detect memory allocations, we scan the list |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
182 of known entries, storing the maximum and minimum addresses |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
183 in the list. This scan allows us to detect when allocated |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
184 memory is being returned, since the address will be outside |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
185 the contiguous memory block we are managing. |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
186 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
187 Blk->BlkMinAddress = Blk->BlkMaxAddress = BlkBase; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
188 for ( i = 0; i < NumEntries; i++ ) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
189 { |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
190 if ( Blk->BlkMaxAddress < Blk->BlkStartPtr[i].BlkHandle ) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
191 Blk->BlkMaxAddress = Blk->BlkStartPtr[i].BlkHandle; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
192 } |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
193 } |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
195 return Blk; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 } |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 /******************************************************************************* |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
200 $Function: mmibr_ShutDown |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 $Description: |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 The shutdown function can be called to free any allocations set up |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 by the Initialise routine. In a running system this is unlikely to |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 be called unless a catastrophic error has occurred and the system |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 needs to be restarted. |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
209 $Returns: none. |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
211 $Arguments: Pointer to a block resource handle (ie ptr to ptr) |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
212 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 *******************************************************************************/ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 void mmibr_ShutDown( tBlkHandle *BlkRsrc ) |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 { |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
217 /* Only allow the resource manager to be shutdown if the provided |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
218 handle is consistent |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
219 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
220 if ( ValidBlockResource( *BlkRsrc ) ) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
221 { |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
222 free( *BlkRsrc ); |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
223 *BlkRsrc = NULL; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
224 } |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 } |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 /******************************************************************************* |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
229 $Function: mmibr_Fetch |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 $Description: |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 We will adopt a mechanism where each block of data being provided |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 will need to be returned to the block resource manager when it |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 is no longer being used, this will provide an orthogonal approach |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 when dealing with data coming from either ROM or dynamically |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 allocated memory. |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
239 $Returns: pointer to resource, NULL if unsuccessful |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
241 $Arguments: BlkRsrc, resource handle created by mmibr_Initialise |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 Id, identifier of the resource to be returned |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
243 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 *******************************************************************************/ |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 tBlkHandle mmibr_Fetch( tBlkHandle BlkRsrc, tBlkId Id ) |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 { |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
248 int Start, End, Search; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
249 tBlkId CurrentId; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
250 tBlkHandle SearchPtr; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
252 /* convert the handle and verify it's valid |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
253 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
254 pBlkControl BlkControl = (pBlkControl) BlkRsrc; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
255 if ( ! ValidBlockResource( BlkRsrc ) ) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
256 return NULL; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
258 /* When locating a specific entry, we need to search the list of |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
259 ids for one matching the input value. Since the Ids will be |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
260 organised as an ordered list, very important that bit, we can |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
261 perform a simple binary search to locate the items. |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
262 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
263 Start = 0; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
264 End = BlkControl->BlkLength - 1; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
265 SearchPtr = NULL; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
266 do |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
267 { |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
268 /* grab the entry midway between the current start and end |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
269 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
270 Search = Start + ((End - Start) >> 1); |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
271 CurrentId = BlkControl->BlkStartPtr[Search].BlkId; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
273 /* Binary chop the search space |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
274 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
275 if ( CurrentId == Id ) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
276 { |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
277 /* Found a match, grab handle and terminate search |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
278 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
279 SearchPtr = BlkControl->BlkStartPtr[Search].BlkHandle; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
280 Start = End; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
281 } |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
282 else if ( CurrentId > Id ) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
283 { |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
284 /* Not got a match, but it's not in the top half so move |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
285 the End pointer down |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
286 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
287 End = Search; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
288 } |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
289 else |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
290 { |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
291 /* Not got a match, but it's not in the bottom half so |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
292 move the Start pointer up |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
293 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
294 Start = Search; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
295 } |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
297 /* when we get down to the last three or four entries, just |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
298 search linearly to solve it, this is generally quicker for |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
299 a small number of entries than continuing the binary chop |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
300 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
301 if ( ( End - Start ) < RESOURCE_SEARCH_LIMIT ) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
302 { |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
303 /* search quickly through the possibles |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
304 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
305 for ( Search = Start; Search <= End; Search++ ) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
306 if ( Id == BlkControl->BlkStartPtr[Search].BlkId ) |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
307 SearchPtr = BlkControl->BlkStartPtr[Search].BlkHandle; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
309 /* And terminate the binary chop |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
310 */ |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
311 Start = End; |
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
312 } |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
314 } while ( Start != End ); |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 |
141
67b91d34f75e
mmiBlkResources.c: bogotab fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
92
diff
changeset
|
316 return SearchPtr; |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 } |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 |
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 /******************************************************************************* |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
320 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 End of File |
92
c0052fe355d3
src/ui/bmi/*.[ch]: rm trailing white space
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
322 |
3
67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 *******************************************************************************/ |