-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtzxblock31.inc
83 lines (69 loc) · 1.93 KB
/
tzxblock31.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
// Copyright 2022-2025 Zoran Vučenović
// SPDX-License-Identifier: Apache-2.0
{$ifdef tzx_header_section}
{ TTzxBlock31 }
TTzxBlock31 = class (TTzxBlock)
strict private
FLen: Integer;
FTextDescription: AnsiString;
FTime: Integer;
public
constructor Create(ATapePlayer: TTapePlayer); override;
class function GetBlockId: DWord; override;
{returns whole block length, without id byte}
function GetBlockLength: Integer; override;
function LoadBlock(const Stream: TStream): Boolean; override;
class function GetBlockDescription: String; override;
procedure Details(out S: String); override;
end;
{$else}
constructor TTzxBlock31.Create(ATapePlayer: TTapePlayer);
begin
inherited Create(ATapePlayer);
FTime := 0;
FLen := 0;
FTextDescription := '';
end;
class function {TTzxPlayer.}TTzxBlock31.GetBlockId: DWord;
begin
Result := $31;
end;
function {TTzxPlayer.}TTzxBlock31.GetBlockLength: Integer;
begin
Result := FLen;
end;
function {TTzxPlayer.}TTzxBlock31.LoadBlock(const Stream: TStream): Boolean;
var
B: Byte;
begin
Result := False;
if Stream.Size > Stream.Position then begin
if Stream.Read(B{%H-}, 1) = 1 then begin
FTime := B;
if Stream.Size > Stream.Position then begin
if Stream.Read(B, 1) = 1 then begin
if Stream.Size - Stream.Position >= B then begin
Result := B = 0;
FLen := 2 + B;
SetLength(FTextDescription, B);
if not Result then begin
if Stream.Read(FTextDescription[1], B) = B then begin
TCommonFunctions.ConvertCodePageFromCp1252ToUtf8(FTextDescription);
Result := True;
end;
end;
end;
end;
end;
end;
end;
end;
class function {TTzxPlayer.}TTzxBlock31.GetBlockDescription: String;
begin
Result := 'Message block';
end;
procedure {TTzxPlayer.}TTzxBlock31.Details(out S: String);
begin
S := FTextDescription;
end;
{$endif}