Metropoli BBS
VIEWER: textunit.pas MODE: TEXT (CP437)
unit textunit;
interface

procedure showcursor;
procedure hidecursor;
procedure mwrite(str:string; x,y:word; c:byte);
procedure text25;
procedure text50;
function ucase(str:string):string;
function strr(number:word):string;

implementation

function strr(number:word):string; assembler;
asm
les di,@result;
mov si,10;
mov ax,[number];
xor bh,bh;
mov bl,1;
cmp ax,10;
jb @tstend;
inc bl;
cmp ax,100;
jb @tstend
inc bl;
cmp ax,1000;
jb @tstend;
inc bl;
cmp ax,10000;
jb @tstend;
inc bl;
@tstend:
mov es:[di].byte[0],bl;
add di,bx;
@looppi:
xor dx,dx;
div si;
add dl,48;
mov es:[di],dl;
dec di;
dec bl;
jnz @looppi;
end;

function ucase(str:string):string; assembler;
asm
 mov dx,ds;
 les di,@result;
 lds si,[str];
 mov bl,ds:[si];
 mov es:[di],bl;
 inc si; inc di;
@looppi:
 mov al,ds:[si];
 cmp al,'a';
 jb @ei_pieni;
 cmp al,'z';
 ja @ei_pieni;
 sub al,32;
 mov es:[di],al;
 jmp @more;
@ei_pieni:
 cmp al,'ä';
 jnz @ei_ae;
 mov es:[di].byte,'Ä';
 jmp @more;
@ei_ae:
 cmp al,'ö';
 jnz @ei_oe;
 mov es:[di].byte[0],'Ö';
 jmp @more;
@ei_oe:
 cmp al,'å';
 jnz @ei_o;
 mov es:[di].byte[0],'Å';
 jmp @more;
@ei_o:
 mov es:[di],al;
@more:
 inc si;
 inc di;
 dec bl;
 jnz @looppi;
@loppu:
 mov ds,dx;
end;


procedure text25; assembler;
asm
 mov ax,3;
 int 10h;
end;

procedure text50; assembler;
asm
 mov ax,$1202; {400 scanlineä}
 mov bl,$30;
 int $10;
 mov ax,3; {8x16 fontti}
 int 10h;
 mov ax,$1112; {8x8 fontti}
 mov bl,$00;
 int $10;
end;

procedure hidecursor; assembler;
asm
 mov ax,$0100
 mov cx,$2607
 int $10
end;

procedure showcursor; assembler;
asm
 mov ax,$0100
 mov cx,$0506
 int $10
end;

procedure mwrite(str:string; x,y:word; c:byte); assembler;
 asm
  mov dx,ds;

  mov ax,$B800;
  mov es,ax;

  mov di,[y];
  shl di,5
  mov ax,di
  shl di,2
  add di,ax
  add di,[x];
  add di,[x];
  mov ah,[c].byte;

  lds si,[str];

  mov bl,ds:[si].byte;
  xor bh,bh;
  add si,bx;
  add bx,bx;
 @looppi:
  mov al,ds:[si].byte;
  mov es:[di+bx-2],ax

  dec si
  sub bx,2
  jnz @looppi;

  mov ds,dx
 end;

begin
end.
[ RETURN TO DIRECTORY ]