-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtzxblock24.inc
76 lines (62 loc) · 1.7 KB
/
tzxblock24.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
// Copyright 2022-2025 Zoran Vučenović
// SPDX-License-Identifier: Apache-2.0
{$ifdef tzx_header_section}
{ TTzxBlock24 }
TTzxBlock24 = class (TTzxBlock)
strict private
NumberOfRepetitions: 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;
function GetNumberOfRepetitions: Integer; override;
procedure Details(out S: String); override;
end;
{$else}
constructor TTzxBlock24.Create(ATapePlayer: TTapePlayer);
begin
inherited Create(ATapePlayer);
NumberOfRepetitions := 0;
end;
class function TTzxBlock24.GetBlockId: DWord;
begin
Result := $24;
end;
function TTzxBlock24.GetBlockLength: Integer;
begin
Result := 2;
end;
function TTzxBlock24.LoadBlock(const Stream: TStream): Boolean;
var
W: Word;
begin
Result := False;
if Stream.Size >= Stream.Position + 2 then begin
if Stream.Read(W{%H-}, 2) = 2 then begin
W := LEtoN(W);
NumberOfRepetitions := W;
Result := True;
end;
end;
end;
class function TTzxBlock24.GetBlockDescription: String;
begin
Result := 'Loop start';
end;
function TTzxBlock24.GetNumberOfRepetitions: Integer;
begin
Result := NumberOfRepetitions;
if Result = 0 then // if loop count is zero, run through code once, as if it were 1
Result := 1;
end;
procedure TTzxBlock24.Details(out S: String);
begin
S := NumberOfRepetitions.ToString + ' repetitions';
if NumberOfRepetitions = 0 then begin
S := S + ' (passes once, as if it were 1)';
end;
end;
{$endif}