-
Notifications
You must be signed in to change notification settings - Fork 4
/
fnote.inc
188 lines (176 loc) · 4.75 KB
/
fnote.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
const maxfnoten0=12;
const maxfnoten=1 shl maxfnoten0;
const maxfnotem0=4;
const maxfnotem=1 shl maxfnotem0;
var fnote:file of tnotemap;
var fnotew:boolean;
var bfnote:array[0..maxfnotem-1,0..maxfnoten-1]of tnotemap;
var bfnote_:array[0..maxfnoten-1]of tnotemap;
var bifnote:longint;
var bjfnote:array[0..maxfnotem-1]of longint;
var bjfnotei,bjfnotej:longint;
var bjfnotek:longint;
procedure FlushFNote();
begin
if bjfnote[bjfnotej]>=0 then
begin
seek(fnote,bjfnote[bjfnotej] shl maxfnoten0);
blockwrite(fnote,bfnote[bjfnotej],maxfnoten);
end;
end;
procedure FlushFNoteAll();
begin for bjfnotej:=0 to maxfnotem-1 do FlushFNote();end;
procedure GetFNoteBlock(i:longint);
begin
bjfnotej:=-1;
for bjfnotei:=0 to maxfnotem-1 do
if bjfnote[bjfnotei]=i shr maxfnoten0 then
bjfnotej:=bjfnotei;
if bjfnotej=-1 then
begin
bjfnotek:=(bjfnotek+1)and(maxfnotem-1);
bjfnotej:=bjfnotek;
if fnotew then FlushFNote();
bjfnote[bjfnotej]:=i shr maxfnoten0;
if fnotew then
if filesize(fnote)<=(bjfnote[bjfnotej] shl maxfnoten0) then
begin
seek(fnote,bjfnote[bjfnotej] shl maxfnoten0);
blockwrite(fnote,bfnote_,maxfnoten);
end;
seek(fnote,bjfnote[bjfnotej] shl maxfnoten0);
blockread(fnote,bfnote[bjfnotej],maxfnoten);
end;
end;
function GetFNote(i:longint):tnotemap;
begin
if fb then
begin
GetFNoteBlock(i);
bifnote:=i and (maxfnoten-1);
GetFNote:=bfnote[bjfnotej,bifnote];
end
else
GetFNote:=notemap[i];
end;
procedure SetFNote(e:tnotemap;i:longint);
begin
if fb then
begin
GetFNoteBlock(i);
bifnote:=i and (maxfnoten-1);
bfnote[bjfnotej,bifnote]:=e;
end
else
notemap[i]:=e;
end;
procedure SetFNoteNote1(i:longint;note1:double);
var e:tnotemap;
begin
e:=GetFNote(i);
if e.note1<>note1 then
begin
e.note1:=note1;
SetFNote(e,i);
end;
end;
function GetFNoteNote1(i:longint):double;
var e:tnotemap;
begin
e:=GetFNote(i);
GetFNoteNote1:=e.note1;
end;
const maxnotemapdraw=$1000;
var notemapdraw:array[-3..maxnotemapdraw-1+3]of longint;
var notemapdrawn:longword;
var notemapdrawi:longint;
var notemapdrawa:longint;
var notemapdrawb:longint;
var notemapdraw0:array[-3..maxnotemapdraw-1+3]of longint;
var notemapdrawn0:longword;
var notemapdrawi0:longint;
var notemapdrawa0:longint;
var notemapdrawb0:longint;
procedure InitFNoteDraw(a,b:longint);
begin
notemapdraw[0]:=a-3;
notemapdraw[1]:=a-2;
notemapdraw[2]:=b+2;
notemapdraw[3]:=b+3;
notemapdrawn:=4;
end;
procedure SetFNoteDraw(a,b:longint);
begin
notemapdrawa:=0;
while notemapdrawa<notemapdrawn do
begin
if (a>=notemapdraw[notemapdrawa]) and (a<=notemapdraw[notemapdrawa+1]) then break;
notemapdrawa:=notemapdrawa+1;
end;
notemapdrawb:=0;
while notemapdrawb<notemapdrawn do
begin
if (b>=notemapdraw[notemapdrawb]) and (b<=notemapdraw[notemapdrawb+1]) then break;
notemapdrawb:=notemapdrawb+1;
end;
notemapdrawi0:=0;
for notemapdrawi:=0 to notemapdrawa do
begin
notemapdraw0[notemapdrawi0]:=notemapdraw[notemapdrawi];
notemapdrawi0:=notemapdrawi0+1;
end;
notemapdraw0[notemapdrawi0]:=a;
notemapdrawa0:=notemapdrawi0;
notemapdrawi0:=notemapdrawi0+1;
for notemapdrawi:=notemapdrawa+1 to notemapdrawb do
begin
notemapdraw0[notemapdrawi0]:=notemapdraw[notemapdrawi];
notemapdrawi0:=notemapdrawi0+1;
end;
notemapdraw0[notemapdrawi0]:=b;
notemapdrawb0:=notemapdrawi0;
notemapdrawi0:=notemapdrawi0+1;
for notemapdrawi:=notemapdrawb+1 to notemapdrawn-1 do
begin
notemapdraw0[notemapdrawi0]:=notemapdraw[notemapdrawi];
notemapdrawi0:=notemapdrawi0+1;
end;
notemapdrawn0:=notemapdrawi0;
notemapdrawa0:=(notemapdrawa0 shr 1 shl 1);
notemapdrawb0:=(notemapdrawb0 shr 1 shl 1)+1;
if notemapdraw0[notemapdrawa0]-notemapdraw0[notemapdrawa0-1]=1 then notemapdrawa0:=notemapdrawa0-2;
if notemapdraw0[notemapdrawb0+1]-notemapdraw0[notemapdrawb0]=1 then notemapdrawb0:=notemapdrawb0+2;
notemapdrawi:=0;
for notemapdrawi0:=0 to notemapdrawa0 do
begin
notemapdraw[notemapdrawi]:=notemapdraw0[notemapdrawi0];
notemapdrawi:=notemapdrawi+1;
end;
for notemapdrawi0:=notemapdrawb0 to notemapdrawn0-1 do
begin
notemapdraw[notemapdrawi]:=notemapdraw0[notemapdrawi0];
notemapdrawi:=notemapdrawi+1;
end;
notemapdrawn:=notemapdrawi;
end;
function GetFNoteDraw(i:longint):boolean;
begin
GetFNoteDraw:=false;
notemapdrawi:=0;
while notemapdrawi<notemapdrawn do
begin
if (i>=notemapdraw[notemapdrawi]) and (i<=notemapdraw[notemapdrawi+1]) then GetFNoteDraw:=true;
if GetFNoteDraw then break;
notemapdrawi:=notemapdrawi+2;
end;
end;
procedure GetFNoteDraw(var a,b:longint);
begin
notemapdrawi:=0;
while notemapdrawi<notemapdrawn do
begin
if (a>=notemapdraw[notemapdrawi]) and (a<=notemapdraw[notemapdrawi+1]) then a:=notemapdraw[notemapdrawi+1];
if (b>=notemapdraw[notemapdrawi]) and (b<=notemapdraw[notemapdrawi+1]) then b:=notemapdraw[notemapdrawi];
notemapdrawi:=notemapdrawi+2;
end;
end;