Closed odflor closed 1 year ago
Hi. The FOR range from 0 to 255, with variables Byte, is always problematic for compilers. I remember some other compiler for 6502, have the same problem.
Anyway, I have created an option in the compiler to can have a secure FOR i:=0 to 255. It's fixed changing the FOR to a REPEAT and an IF sentences.
Now the problem is solved when activated that option.
Just for information. In new version of the compiler, you can fill all the content of an array using the clear() method, like:
var
buffer: array[256] of byte;
begin
//Fill all the array with the $FF value
buffer.clear($FF);
end.
With this method you can fill, with an optimized code, arrays as big as 1024 bytes.
If I define a variable as byte only can assign values from 0 to 254 or $0 to $FE.
Normally a byte value varies from 0 to 255 or $0 to $FF.
This way is impossible to poke a 255 or $FF value on the screen with variables.
test this program and change from 254 to 255 to see compiler error:
program Hello; //uses Commodore128; uses Commodore64; var i : byte; p : byte;
screen1: [255]byte absolute 1024; screen2: [255]byte absolute 1279; screen3: [255]byte absolute 1534; screen4: [255]byte absolute 1789;
color1: [255]byte absolute 55296; color2: [255]byte absolute 55551; color3: [255]byte absolute 55806; color4: [255]byte absolute 56061; begin screenBack := 0; screenBorder := 12;
p := 0;
for i := 0 to 254 do screen1[i] := p; screen2[i] := p; screen3[i] := p;
end; // for
asm RTS end end.