I've just discovered a cool way to shift values in an array to the left.
In other words, moving all values in array[n] to array[n-1] and moving
the value of array[1] to
array[highest element]. Here is how I did it.
-----------------------------------------------------------------
program shift;
type line = array[1..10] of byte;
var a:line absolute 5499:82;
b:line absolute 5499:83;
i,v:byte;
begin
writeln(seg(a[1]),':',ofs(a[1]));
writeln(seg(b[1]),':',ofs(b[1]));
for i:=1 to 10 do begin
a[i]:=0;
b[i]:=0;
end;
for i:=1 to 10 do begin
a[i]:=i;
end;
writeln(a[1],' ',a[2],' ',a[3],' ',a[4],' ',a[5],' ',a[6],' ',a[7],'
',a[8],' ',a[9],' ',a[10]);
writeln(b[1],' ',b[2],' ',b[3],' ',b[4],' ',b[5],' ',b[6],' ',b[7],'
',b[8],' ',b[9],' ',b[10]);
writeln;
for v:=1 to 10 do begin
b[10]:=a[1];
a:=b;
writeln(a[1],' ',a[2],' ',a[3],' ',a[4],' ',a[5],' ',a[6],' ',a[7],'
',a[8],' ',a[9],' ',a[10]);
end;
end.
Array a starts out with values 1 2 3 4 5 6 7 8 9 10.
the next iteration gives it values of 2 3 4 5 6 7 8 9 10 1. Oh,
by the
way, I discovered that if I put in the statement b:=a, then EVERY
element of
a will be equal to a[1]. Seems like a good way to initialize an array.
Now, here is a question. I wrote the following program to display 256
different colors on the screen. Once they are displayed, I know that I
can
change the palette with setrgb(i,r,g,b) where 0<i<255 and i stands for
the
numerical value of the colors on the screen. For example, if I display
all
256 colors and then issure the command setrgb(57,23,45,90) then every
part of
the screen which was colored by the setcolor(i) command when i was equal
to
57 will be changed to the color that results when red = 23, green = 45,
and
blue = 90.
program svga;
uses graph,crt;
var x,y,i,k,Driver, Mode: Integer;
p:palettetype;
begin
Driver := InstallUserDriver('SVGA256',nil);
if Driver = grError then
Halt(1);
mode:=127;
driver:=16;
InitGraph(driver,Mode,'');
getpalette(p);
for i:=0 to 511 do begin
k:=i div 2;
setcolor(k);
line(0,i,1024,i);
end;
x:=getmaxx;
y:=getmaxy;
repeat
until keypressed;
closegraph;
end.
So now my question is this. How can I rotate the palette. Can I use the
method in the first program to do this? I know that graphics memory
starts at
$A000:0000, but if I'm right the values there just tell which pixels are
on
or off. It doesn't give color info. If I only knew where in memory the
screens color information was stored, I could use the absolute clause to
put
an array there and shift the palette in the same way that I can shift
the
values in an array. Any ideas?
-Patrick-