-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtzxblock33.inc
92 lines (73 loc) · 1.86 KB
/
tzxblock33.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
// Copyright 2022-2025 Zoran Vučenović
// SPDX-License-Identifier: Apache-2.0
{$ifdef tzx_header_section}
TTzxBlock33 = class (TTzxBlock)
strict private
type
THWInfo =
packed record
HWType, HWId, HWInformation: Byte;
end;
PHWInfo = ^THWInfo;
strict private
FLen: Integer;
FHWInfo: PHWInfo;
public
constructor Create(ATapePlayer: TTapePlayer); override;
destructor Destroy; 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;
end;
{$else}
constructor TTzxBlock33.Create(ATapePlayer: TTapePlayer);
begin
inherited Create(ATapePlayer);
FHWInfo := nil;
FLen := 0;
end;
destructor {TTzxPlayer.}TTzxBlock33.Destroy;
begin
if Assigned(FHWInfo) then
FreeMem(FHWInfo);
inherited Destroy;
end;
class function {TTzxPlayer.}TTzxBlock33.GetBlockId: DWord;
begin
Result := $33;
end;
function {TTzxPlayer.}TTzxBlock33.GetBlockLength: Integer;
begin
Result := FLen;
end;
function {TTzxPlayer.}TTzxBlock33.LoadBlock(const Stream: TStream): Boolean;
var
B: Byte;
N: Integer;
begin
Result := False;
if Stream.Size > Stream.Position then begin
if Stream.Read(B{%H-}, 1) = 1 then begin
N := B;
if Stream.Size - Stream.Position >= N then begin
Result := N = 0;
N := N * SizeOf(THWInfo);
FLen := 1 + N;
if not Result then begin
if Stream.Size - Stream.Position >= N then begin
Getmem(FHWInfo, N);
if Stream.Read(FHWInfo^, N) = N then
Result := True;
end;
end;
end;
end;
end;
end;
class function {TTzxPlayer.}TTzxBlock33.GetBlockDescription: String;
begin
Result := 'Hardware type';
end;
{$endif}