-
Notifications
You must be signed in to change notification settings - Fork 1
/
tzxblock14.inc
96 lines (81 loc) · 2.44 KB
/
tzxblock14.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
// Copyright 2022-2024 Zoran Vučenović
// SPDX-License-Identifier: Apache-2.0
{$ifdef tzx_header_section}
TTzxBlock14 = class (TTzxBlock11abstract)
public
constructor Create(ATapePlayer: TTapePlayer); override;
class function GetBlockId: DWord; override;
function LoadBlock(const Stream: TStream): Boolean; override;
class function GetBlockDescription: String; override;
end;
{$else}
constructor TTzxBlock14.Create(ATapePlayer: TTapePlayer);
begin
inherited Create(ATapePlayer);
PilotPulsesNeeded := 0;
PilotTicksNeeded := 0;
Sync1TicksNeeded := 0;
Sync2TicksNeeded := 0;
end;
class function {TTzxPlayer.}TTzxBlock14.GetBlockId: DWord;
begin
Result := $14;
end;
function {TTzxPlayer.}TTzxBlock14.LoadBlock(const Stream: TStream): Boolean;
var
L: Int32;
W: Word;
B: Byte;
begin
Result := False;
if Stream.Size - Stream.Position >= 10 then begin
if Stream.Read(W{%H-}, 2) = 2 then begin
W := LEtoN(W);
Bit0TicksNeeded := W;
if Stream.Read(W, 2) = 2 then begin
W := LEtoN(W);
Bit1TicksNeeded := W;
if (Stream.Read(B{%H-}, 1) = 1) then begin
if Stream.Read(W, 2) = 2 then begin
W := LEtoN(W);
PauseAfterBlock := W;
if ReadThreeBytes(Stream, L) then begin
if Stream.Size - Stream.Position >= L then begin
DataLen := L;
FLen := 10 + L;
if L = 0 then
Result := PauseAfterBlock > 0
else begin
Getmem(Data, L);
try
if Stream.Read(Data^, L) = L then begin
if B > 8 then
UsedBitsInLastByte := 8
else if B = 0 then begin
Dec(L);
UsedBitsInLastByte := 8;
end else
UsedBitsInLastByte := B;
if L > 0 then begin
PEnd := Data + (L - 1);
Result := True;
end;
end;
finally
if not Result then
FreeMemAndNil(Data);
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
class function {TTzxPlayer.}TTzxBlock14.GetBlockDescription: String;
begin
Result := 'Pure Data Block';
end;
{$endif}