VBI i DLI w MadPascal-u.

Kiedyś eksperymentowałem z Action!, dziś analogiczny przykład w MadPascal:

uses crt;

const
dl: array [0..32] of byte = (
112, 112, 112, 66, 0, 64, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 130, 86, 72, 67, 65,
lo(word(@dl)), hi(word(@dl))
);

var
col0: byte absolute $2c4;
col1: byte absolute $2c5;
savmsc: word absolute $58;
nmien: byte absolute $d40e;
pc: ^byte; tmp: word;
hscrol: byte absolute $d404;
vcount: byte absolute $d40b;
colt: byte absolute $d017;
dlist: word absolute $230;
i,j,k,l,indx: byte;

procedure dli; interrupt;
begin
 asm { phr };
 inc(indx);
 for i:=0 to 7 do
  begin
   if indx>30 then indx:=0;
   colt:=vcount+indx;
  end;
 asm { plr };
end;

procedure scroll; interrupt;
begin
 j:=j+1;
 if j=16 then
  begin
   j:=0; dec(pc^,2); k:=k+1;
   if k=14 then
    begin
     k:=0; pc^:=tmp;
    end
  end;
  hscrol:=j;
 asm { jmp $E462 };
end;

begin
 i:=0; j:=0; k:=0; indx:=0;
 dlist:=word(@dl);

 SetIntVec(iVBL, @scroll);
 SetIntVec(iDLI, @dli);
 nmien:=$c0;

 pc := @dl;
 inc(pc, 28);

 tmp := pc^+6;
 col0 := 14; col1 := 14;
 savmsc := $4000;

 for l:=0 to 22 do
  writeln(' mp rulez! ');

 repeat until keypressed;
end.

mprulez

Niezaprzeczalną zaletą duetu mp+mads jest optymalizacja i wielkość pliku wynikowego:

$ mads -x -o:scroll.obx -i:/e/mp/base scroll.a65
SYSTEM: $205D..$205C
CRT: $205D..$2070
CODE: $2000..$226F
DATA: $2270..$2282
Writing listing file…
Writing object file…
3983 lines of source assembled in 5 pass
640 bytes written to the object file