home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug120.arc
/
PASCAL.LBR
/
PIXELS.PZS
/
PIXELS.PAS
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
10KB
|
197 lines
{ File PIXELS : sets, resets, inverts and tests pixels }
{ on a 160 x 72 pixel graphic screen on a Microbee only. }
{ Used by all line, arc and region filling procedures. }
{ Requires Include file LORES , ie will not run on its own. }
{ Written partly in Turbo Pascal and partly in Z80 machine language "Inline". }
{ Version 1.1 24.3.85 K OHare }
{ Version 1.2 13.4.85 K OHare }
{.PL59}
{.PA}
Procedure Setpixel (x,y: byte) ;
var
row, column, bit, mask, m, n,
old_character, new_character : byte;
address : integer;
begin
row := divthree[y]; column := divtwo[x];
bit := modtwo[x] + modthree[y] + modthree[y];
mask := twopower[bit] + 128;
{ Get character from screen and process }
{ address := screen_start + row*80 + column; }
{ old_character := mem[address]; }
{ }
{ if old_character < 128 then old_character := 0; }
{ new_character := old_character OR mask; }
{ mem[address] := new_character; }
Inline ( $26/$00/ { LD H,0 }
$3A/row/ { LD A,(row) }
$6F/ { LD L,A ;HL := row }
$44/ { LD B,H }
$4D/ { LD C,L ;BC := row }
$29/ { ADD HL,HL ;The next 7 lines }
$29/ { ADD HL,HL ;multiply row by 80 }
$09/ { ADD HL,BC ;leaving the result }
$29/ { ADD HL,HL ;in HL. }
$29/ { ADD HL,HL }
$29/ { ADD HL,HL }
$29/ { ADD HL,HL ;HL := row x 80 }
$3A/column/ { LD A,(column) }
$4F/ { LD C,A }
$06/$00/ { LD B,0 }
$09/ { ADD HL,BC ;add column to 80xrow }
$01/screen_start/ { LD BC,screen_start }
$09/ { ADD HL,BC ;and add screen base }
$7E/ { LD A,(HL) ;get old_character }
$CB/$7F/ { BIT 7,A ;Is it ROM or PCG? }
$20/$01/ { JR NZ,+1 ;If ROM then }
$AF/ { XOR A ;set old_character :=0 }
$4F/ { LD C,A }
$3A/mask/ { LD A,(mask) }
$47/ { LD B,A }
$79/ { LD A,C }
$B0/ { OR B ;old_character OR mask }
$77) { LD (HL),A ;new_character }
end; { Procedure Setpixel }
{.PA}
Procedure reset_pixel( x,y : byte);
var
row, column, bit, mask, m, n,
old_character, new_character : byte;
address : integer;
begin
row := divthree[y]; column := divtwo[x];
bit := modtwo[x] + modthree[y] + modthree[y];
mask := twopower[bit] + 128;
{ Get character from screen and process }
{ address := screen_start + row*80 + column;}
{ old_character := mem[address];}
{ if old_character < 128 then old_character := 0;}
{ new_character := (old_character AND (NOT mask)) OR 128;}
{ mem[address] := new_character;}
Inline ( $26/$00/ { LD H,0 }
$3A/row/ { LD A,(row) }
$6F/ { LD L,A ;HL := row }
$44/ { LD B,H }
$4D/ { LD C,L ;BC := row }
$29/ { ADD HL,HL ;The next 7 lines }
$29/ { ADD HL,HL ;multiply row by 80 }
$09/ { ADD HL,BC ;leaving the result }
$29/ { ADD HL,HL ;in HL. }
$29/ { ADD HL,HL }
$29/ { ADD HL,HL }
$29/ { ADD HL,HL ;HL := row x 80 }
$3A/column/ { LD A,(column) }
$4F/ { LD C,A }
$06/$00/ { LD B,0 }
$09/ { ADD HL,BC ;add column to 80xrow }
$01/screen_start/ { LD BC,screen_start }
$09/ { ADD HL,BC ;and add screen base }
$7E/ { LD A,(HL) ;get old_character }
$CB/$7F/ { BIT 7,A ;Is it ROM or PCG? }
$20/$01/ { JR NZ,+1 ;If ROM then }
$AF/ { XOR A ;set old_character :=0 }
$4F/ { LD C,A }
$3A/mask/ { LD A,(mask) }
$2F/ { CPL ;A := NOT MASK }
$47/ { LD B,A }
$79/ { LD A,C }
$A0/ { AND B ;old_character AND mask}
$77) { LD (HL),A ;new_character }
end; { Procedure reset_pixel }
{.PA}
Function Test_pixel (x,y : byte) : boolean;
var
row, column, bit, mask, m, n,
old_character, new_character : byte;
address : integer;
begin
row := divthree[y]; column := divtwo[x];
bit := modtwo[x] + modthree[y] + modthree[y];
mask := twopower[bit] + 128;
{ Get character from screen and process }
address := screen_start + row*80 + column;
old_character := mem[address];
if old_character < 128 then old_character := 0;
new_character := old_character AND mask;
if new_character = 0 then test_pixel := false { pixel not set }
else test_pixel := true; { pixel set }
end; { Function test_pixel }
{.PA}
Procedure invert_pixel (x,y : byte);
var
row, column, bit, mask, m, n,
old_character, new_character : byte;
address : integer;
begin
row := divthree[y]; column := divtwo[x];
bit := modtwo[x] + modthree[y] + modthree[y];
mask := twopower[bit] + 128;
{ Get character from screen and process }
{ address := screen_start + row*80 + column;}
{ old_character := mem[address];}
{ if old_character < 128 then old_character := 0;}
{ new_character := (old_character XOR mask) OR 128;}
{ mem[address] := new_character; }
Inline ( $26/$00/ { LD H,0 }
$3A/row/ { LD A,(row) }
$6F/ { LD L,A ;HL := row }
$44/ { LD B,H }
$4D/ { LD C,L ;BC := row }
$29/ { ADD HL,HL ;The next 7 lines }
$29/ { ADD HL,HL ;multiply row by 80 }
$09/ { ADD HL,BC ;leaving the result }
$29/ { ADD HL,HL ;in HL. }
$29/ { ADD HL,HL }
$29/ { ADD HL,HL }
$29/ { ADD HL,HL ;HL := row x 80 }
$3A/column/ { LD A,(column) }
$4F/ { LD C,A }
$06/$00/ { LD B,0 }
$09/ { ADD HL,BC ;add column to 80xrow }
$01/screen_start/ { LD BC,screen_start }
$09/ { ADD HL,BC ;and add screen base }
$7E/ { LD A,(HL) ;get old_character }
$CB/$7F/ { BIT 7,A ;Is it ROM or PCG? }
$20/$01/ { JR NZ,+1 ;If ROM then }
$AF/ { XOR A ;set old_character :=0 }
$4F/ { LD C,A }
$3A/mask/ { LD A,(mask) }
$47/ { LD B,A }
$79/ { LD A,C }
$A8/ { XOR B ;old_character XOR mask}
$F6/$80/ { OR $80 ;make sure its a PCG }
$E6/$BF/ { AND $BF }
$77) { LD (HL),A ;new_character }
end; { Procedure Invert_pixel }