-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathTDL_TSET.PAS
69 lines (54 loc) · 1.73 KB
/
TDL_TSET.PAS
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
{$I tdl_dire.inc}
{$IFDEF USEOVERLAYS}
{$O+,F+}
{$ENDIF}
unit tdl_tset;
{
Unit to handle "title sets": Data structures that contain a set of
16-bit word title IDs. The main menu screen "title picker" works
against a title set.
The initial title set contains all titleIDs in the index (ie. everything).
Later, if the user wants to see only favorites via CTRL-F, a new title set
is built from only titles marked as a favorite, and then that
title set becomes the active title set.
Title sets are also used with search-as-you-type:
Each successful word input by the user is used to build subsequent title sets
that narrow down the filter results. If the user's filter goes backwards
by the user backspacing, previous title sets can be cached so that the
results display updates instantly.
The intrepid coder will no doubt be wondering at this point why there are
no .insert() or .delete() or other routines in the TTitleSet object
other than init() and done: This is because we need to be able to build
and tear down title sets very quickly, and populating a 1000-item title set
using 1000 .insert() CALLs on a 4.77 MHz system is not going to fly here.
So, the object mostly serves to correctly alloc/dealloc title set arrays.
}
interface
uses
objects,
tdl_glob;
const
maxTitleSets=16;
activeSet:byte=0;
type
PTitleSet=^TTitleSet;
TTitleSet=object(TObject)
PUBLIC
numTitles:word;
TitleIDs:PTitleArray;
Constructor Init(numElements:word);
Destructor Done; VIRTUAL;
end;
implementation
Constructor TTitleSet.Init;
begin
Inherited Init;
numTitles:=numElements;
getmem(TitleIDs,numTitles * sizeof(word));
end;
Destructor TTitleSet.Done;
begin
freemem(TitleIDs,numTitles * sizeof(word));
Inherited Done;
end;
end.