{컴컴컴컴컴컴컴컴커}
{ june'97 by Cazz �}
{컴컴컴컴컴컴컴컴켸}
{$A+,B-,D-,E-,F-,G+,I-,L-,N-,O-,P-,Q-,R-,S-,T-,V-,X+}
{$M 2048,0,655360}
unit creds;

     interface

procedure docreds;

     implementation

uses   misc,keyboard,dsm;

const  yres=350;
       lines=82;
       credit:array[1..lines] of string[45]=(
{0頰頰頰頰�0頰頰頰頰�0頰頰頰頰�0頰頰頰頰�0頰頰頰頰�0}
'o b s c e n e',
'',
'',
'my first demo ever',
'',
'coded by cazz, but',
'of coz there are also elses ideas used here',
'got from some other coders and net',
'greets later',
'',
'everything has been done in realtime',
'',
'the artwork (haha) you saw here',
'has also been made by cazz',
'',
'the music you heard before and',
'hear now is by terminus',
'',
'midas sound system has been coded by',
'sahara surfers. thanx!',
'',
'',
'it took a long time to make this demo.',
'a month, but i didn''t code it intensively.',
'it''s my first over 100kb product at all :-)',
'i promise, this is my first and last demo',
'in turbo pascal, assembler rulz!!!',
'ok, well... watcom rules too :)',
'',
'',
'and now the greetings, groups first:',
'',
'sahara surfers',
'theta',
'orpheas',
'otm',
'vla',
'asphyxia',
'',
'',
'...and now some persons:',
'',
'abbot',
'petteri kangaslampi &',
'jarno paananen  -  sahara surfers',
'niklas beisert/pascal  -  cubic team',
'helix  -  orpheas',
'phred  -  otm',
'tran',
'draeden  -  vla',
'denthor  -  asphyxia',
'theta membas',
'kimmo fredriksson',
'jeroen bouwens',
'lorenzo micheletto',
'bas van gaalen',
'bjarke viksoe',
'shawn hargreaves',
'and',
'especially all coders over',
'the small estonia.',
'',
'uhh, certainly I forgot someone, sorry',
'',
'',
'well, it''s time to finish this thing here',
'hope it wasn''t very boring',
'',
'be sure to watch my next production',
'',
'THE END',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'');

const   width:array[0..96] of byte=(
6,6,8,14,13,22,17,6,8,8,10,14,6,15,6,7,13,13,13,13,13,13,13,13,13,13,6,
6,15,15,15,12,25,17,17,18,18,16,14,19,18,8,13,18,14,21,18,18,16,18,17,16,
16,18,17,22,17,16,15,7,7,7,12,14,6,13,14,12,14,13,8,14,13,6,6,12,6,20,14,
13,14,14,9,12,8,14,13,18,12,13,12,8,6,8,14,6,0);

var  memforfont:word;
     font:pointer;
     tc,cc:longint;
     ypos:integer;
     offset:array[0..96] of word;
     vol:byte;
     scrsync:word;
     errnr:integer;

{ unpack font }
procedure init;
var       un:word;
          s1,s2,o1,o2:word;
          b,n,c:byte;
begin
  memforfont:=35873;
  getmem(font,memforfont);
  getmem(temp,index[8,2]+20);
  loaddata(temp,8);
  un:=0;
  s1:=seg(temp^);
  s2:=seg(font^);
  o1:=ofs(temp^);
  o2:=ofs(font^);
  while un<index[8,2] do
    begin
      b:=mem[s1:un+o1];
      inc(un);
      if (b and $c0)=$c0 then
        begin
          n:=b and $3f;
          b:=mem[s1:un+o1];
          inc(un);
          fillchar(mem[s2:o2],n,b);
          inc(o2,n);
        end
      else
        begin
          mem[s2:o2]:=b;
          inc(o2);
        end;
    end;

  offset[0]:=ofs(font^);
  for b:=0 to 95 do
    offset[b+1]:=offset[b]+width[b]*29;
  freemem(temp,index[8,2]+20);
  initkey;
  ypos:=0;
  cc:=0;
  tc:=1;
end;

procedure moveto; assembler;
asm
    mov    bx, [ypos]
    mov    ax,80
    imul   bx
    mov    bx,ax
    mov    ah, bh
    mov    al, 0ch

    mov    dx, 3d4h
    out    dx, ax

    mov    ah, bl
    mov    al, 0dh
    mov    dx, 3d4h
    out    dx, ax
end;

function center(t:string):word;
var      l:byte;
         wid:word;
begin
  wid:=0;
  for l:=1 to length(t) do
    if (ord(t[l])>=32) and (ord(t[l])<=128) then
      wid:=wid+width[ord(t[l])-32];
  center:=319-wid div 2;
end;

procedure writeline(x,y,ln:integer;t:string);
var       l:byte;
          b,ch,orr:byte;
          foff,xoff:word;
          yy,xx,ll:word;
          w:byte;
          sco1,sco2,scroff:word;
          uhh:integer;
begin
  if (ln>28) then exit;

  sco1:=word((y-1)*80);
  sco2:=word((y+yres)*80);

  xoff:=x;
  for l:=1 to length(t) do
    begin
      ch:=byte(ord(t[l])-32);
      if (ch<=96) then
        begin
          uhh:=round(sin(byte(cc shl 3+l shl 4)*0.02462745098)*2);
          foff:=offset[ch]+width[ch]*(ln+abs(uhh))+uhh div 2;
          for xx:=0 to width[ch]-1 do
            if mem[seg(font^):foff+xx]=15 then
              begin
                b:=mem[sega000:sco1+(xoff+xx) shr 3];
                orr:=(1 shl (7-((xoff+xx) and 7)));
                mem[sega000:sco1+(xoff+xx) shr 3]:=b or orr;
                b:=mem[sega000:sco2+(xoff+xx) shr 3];
                mem[sega000:sco2+(xoff+xx) shr 3]:=b or orr;
              end;
          xoff:=xoff+width[ch];
        end;
    end;
end;

procedure docreds;
begin
  setmode($10);
  init;
  asm
    mov dx,03c4h
    mov al,2
    out dx,al
    inc dx
    mov al,15
    out dx,al
    mov es,sega000
    xor di,di
    xor ax,ax
    mov cx,80*350/2
    rep stosw
  end;
  dsmgetmastervolume(@vol);
  repeat
    inc(ypos);
    moveto;
    lfrm:=frm;
    repeat until frm>(lfrm+1);
    if cc>300 then
      asm
        mov ax,$a000
        mov es,ax
        mov bx,ypos
        dec bx
        imul di,bx,80
        xor ax,ax
        mov cx,80/4
        db 66h; rep stosw
        add di,yres*80
        xor ax,ax
        mov cx,80/4
        db 66h; rep stosw
      end;
    writeline(center(credit[tc]),ypos,cc mod 32,credit[tc]);
    inc(cc);
    if cc mod 32=0 then inc(tc);
    if ypos>yres then ypos:=0;
    if key[1] then over:=true;
    if (tc>lines-4) and (cc mod 2=0) then
      begin
        if vol>0 then dec(vol);
        dsmsetmastervolume(vol);
      end;
  until (tc>lines) or over;
  disabkey;
  freemem(font,memforfont);
end;

end.