]> 4ch.mooo.com Git - 16.git/blobdiff - 16/ADT2PLAY/TXTSCRIO.PAS
refresh wwww
[16.git] / 16 / ADT2PLAY / TXTSCRIO.PAS
diff --git a/16/ADT2PLAY/TXTSCRIO.PAS b/16/ADT2PLAY/TXTSCRIO.PAS
new file mode 100755 (executable)
index 0000000..d187824
--- /dev/null
@@ -0,0 +1,1683 @@
+unit TxtScrIO;\r
+interface\r
+\r
+const\r
+  Black   = $00;  DGray    = $08;\r
+  Blue    = $01;  LBlue    = $09;\r
+  Green   = $02;  LGreen   = $0a;\r
+  Cyan    = $03;  LCyan    = $0b;\r
+  Red     = $04;  LRed     = $0c;\r
+  Magenta = $05;  LMagenta = $0d;\r
+  Brown   = $06;  Yellow   = $0e;\r
+  LGray   = $07;  White    = $0f;\r
+  Blink   = $80;\r
+\r
+procedure ShowStr(var dest; x,y: Byte; str: String; attr: Byte);\r
+procedure ShowVStr(var dest; x,y: Byte; str: String; attr: Byte);\r
+procedure ShowCStr(var dest; x,y: Byte; str: String; atr1,atr2: Byte);\r
+procedure ShowVCStr(var dest; x,y: Byte; str: String; atr1,atr2: Byte);\r
+procedure ShowC3Str(var dest; x,y: Byte; str: String; atr1,atr2,atr3: Byte);\r
+procedure ShowVC3Str(var dest; x,y: Byte; str: String; atr1,atr2,atr3: Byte);\r
+function CStrLen(str: String): Byte;\r
+function AbsPos(x,y: Byte): Word;\r
+function Color(fgnd,bgnd: Byte): Byte;\r
+procedure CleanScreen(var dest);\r
+procedure initialize;\r
+\r
+type\r
+  tCUSTOM_VIDEO_MODE = 0..52;\r
+\r
+procedure SetCustomVideoMode(vmode: tCUSTOM_VIDEO_MODE);\r
+\r
+type\r
+  tFRAME_SETTING = Record\r
+                     shadow_enabled,\r
+                     wide_range_type,\r
+                     zooming_enabled,\r
+                     update_area: Boolean;\r
+                   end;\r
+const\r
+  fr_setting: tFRAME_SETTING =\r
+    (shadow_enabled:  TRUE;\r
+     wide_range_type: FALSE;\r
+     zooming_enabled: FALSE;\r
+     update_area:     TRUE);\r
+\r
+procedure Frame(var dest; x1,y1,x2,y2,atr1: Byte;\r
+                          title: String; atr2: Byte; border: String);\r
+\r
+const\r
+  solid1 = '        ';\r
+  solid2 = 'ÛßÛÛÛÛÜÛ';\r
+  single = 'ÚÄ¿³³ÀÄÙ';\r
+  double = 'ÉÍ»ººÈͼ';\r
+  dbside = 'ÖÄ·ººÓĽ';\r
+  dbtop  = 'Õ͸³³Ô;';\r
+\r
+var\r
+  MaxLn,MaxCol,\r
+  work_maxln,work_maxcol: Byte;\r
+  area_x1,area_y1,area_x2,area_y2: Byte;\r
+  v_mode: Byte;\r
+  DispPg: Byte;\r
+  v_seg,v_ofs: Longint;\r
+  CheckSnow: Boolean;\r
+\r
+function iEGA:  Boolean;\r
+function iVGA:  Boolean;\r
+function iPS2:  Boolean;\r
+function iMDA:  Boolean;\r
+function iCGA:  Boolean;\r
+function iMCGA: Boolean;\r
+\r
+function  WhereX: Byte;\r
+function  WhereY: Byte;\r
+procedure GotoXY(x,y: Byte);\r
+procedure ResetMode;\r
+\r
+function  GetCursor: Longint;\r
+procedure SetCursor(cursor: Longint);\r
+procedure ThinCursor;\r
+procedure WideCursor;\r
+procedure HideCursor;\r
+function  GetCursorShape: Word;\r
+procedure SetCursorShape(shape: Word);\r
+\r
+type\r
+  tVIDEO_STATE = Record\r
+                   font: Byte;\r
+                   cursor: Longint;\r
+                   MaxLn,MaxCol,v_mode: Byte;\r
+                   v_ofs: Longint;\r
+                   screen: array[0..PRED(8192)] of Byte;\r
+                   data: array[0..PRED(4096)] of Byte;\r
+                 end;\r
+\r
+procedure GetVideoState(var data: tVIDEO_STATE);\r
+procedure SetVideoState(var data: tVIDEO_STATE; restore_screen: Boolean);\r
+procedure GetRGBitem(color: Byte; var red,green,blue: Byte);\r
+procedure SetRGBitem(color: Byte; red,green,blue: Byte);\r
+procedure WaitRetrace;\r
+procedure GetPalette(var pal; first,last: Word);\r
+procedure SetPalette(var pal; first,last: Word);\r
+\r
+type\r
+  tFADE  = (first,fadeOut,fadeIn);\r
+  tDELAY = (fast,delayed);\r
+\r
+type\r
+  tFADE_BUF = Record\r
+                action: tFADE;\r
+                pal0: array[0..255] of Record r,g,b: Byte end;\r
+                pal1: array[0..255] of Record r,g,b: Byte end;\r
+              end;\r
+\r
+const\r
+  fade_speed: Byte = 63;\r
+\r
+procedure VgaFade(var data: tFADE_BUF; fade: tFADE; delay: tDELAY);\r
+procedure RefreshEnable;\r
+procedure RefreshDisable;\r
+procedure Split2Static;\r
+procedure SplitScr(line: Integer);\r
+procedure SetSize(columns,lines: Integer);\r
+procedure SetTextDisp(x,y: Integer);\r
+\r
+implementation\r
+uses DPMI;\r
+\r
+var\r
+  absolute_pos: Word;\r
+\r
+procedure DupChar; assembler;\r
+asm\r
+        pushad                           {  IN/ al     -column        }\r
+        xor     ebx,ebx                  {      ah     -line          }\r
+        xchg    ax,bx                    {      dl     -character     }\r
+        xor     eax,eax                  {      dh     -attribute     }\r
+        xchg    ax,bx                    {      ecx    -count         }\r
+        mov     bl,al                    {      edi    -ptr. to write }\r
+        mov     al,MaxCol\r
+        mul     ah\r
+        add     ax,bx\r
+        mov     bl,MaxCol\r
+        sub     ax,bx\r
+        dec     ax\r
+        shl     ax,1\r
+        jecxz   @@1\r
+        add     edi,eax\r
+        xchg    ax,dx\r
+        rep     stosw\r
+        xchg    ax,dx\r
+@@1:    mov     absolute_pos,ax\r
+        popad\r
+end;\r
+\r
+procedure ShowStr(var dest; x,y: Byte; str: String; attr: Byte); assembler;\r
+asm\r
+        mov     edi,[dest]\r
+        mov     esi,[str]\r
+        mov     al,x\r
+        mov     ah,y\r
+        xor     ecx,ecx\r
+        call    DupChar\r
+        xor     edx,edx\r
+        mov     dx,absolute_pos\r
+        lodsb\r
+        mov     cl,al\r
+        jecxz   @@2\r
+        add     edi,edx\r
+        mov     ah,attr\r
+@@1:    lodsb\r
+        stosw\r
+        loop    @@1\r
+@@2:\r
+end;\r
+\r
+procedure ShowVStr(var dest; x,y: Byte; str: String; attr: Byte); assembler;\r
+asm\r
+        mov     al,MaxCol\r
+        dec     al\r
+        xor     ah,ah\r
+        xor     ebx,ebx\r
+        mov     bl,2\r
+        mul     bl\r
+        mov     bx,ax\r
+        mov     edi,[dest]\r
+        mov     esi,[str]\r
+        mov     al,x\r
+        mov     ah,y\r
+        xor     ecx,ecx\r
+        call    DupChar\r
+        xor     edx,edx\r
+        mov     dx,absolute_pos\r
+        lodsb\r
+        mov     cl,al\r
+        jecxz   @@2\r
+        add     edi,edx\r
+        mov     ah,attr\r
+@@1:    lodsb\r
+        stosw\r
+        add     edi,ebx\r
+        loop    @@1\r
+@@2:\r
+end;\r
+\r
+procedure ShowCStr(var dest; x,y: Byte; str: String; atr1,atr2: Byte); assembler;\r
+asm\r
+        mov     esi,[str]\r
+        mov     edi,[dest]\r
+        lodsb\r
+        xor     ecx,ecx\r
+        mov     cl,al\r
+        jecxz   @@3\r
+        push    ecx\r
+        mov     al,x\r
+        mov     ah,y\r
+        xor     ecx,ecx\r
+        call    DupChar\r
+        xor     edx,edx\r
+        mov     dx,absolute_pos\r
+        pop     ecx\r
+        add     edi,edx\r
+        mov     ah,atr1\r
+        mov     bh,atr2\r
+@@1:    lodsb\r
+        cmp     al,'~'\r
+        jz      @@2\r
+        stosw\r
+        loop    @@1\r
+        jmp     @@3\r
+@@2:    xchg    ah,bh\r
+        loop    @@1\r
+@@3:\r
+end;\r
+\r
+procedure ShowVCStr(var dest; x,y: Byte; str: String; atr1,atr2: Byte); assembler;\r
+asm\r
+        mov     al,MaxCol\r
+        dec     al\r
+        xor     ah,ah\r
+        mov     bl,2\r
+        mul     bl\r
+        mov     bx,ax\r
+        mov     esi,[str]\r
+        mov     edi,[dest]\r
+        lodsb\r
+        xor     ecx,ecx\r
+        mov     cl,al\r
+        jecxz   @@3\r
+        push    ecx\r
+        mov     al,x\r
+        mov     ah,y\r
+        xor     ecx,ecx\r
+        call    DupChar\r
+        xor     edx,edx\r
+        mov     dx,absolute_pos\r
+        pop     ecx\r
+        add     edi,edx\r
+        mov     dx,bx\r
+        mov     ah,atr1\r
+        mov     bh,atr2\r
+@@1:    lodsb\r
+        cmp     al,'~'\r
+        jz      @@2\r
+        stosw\r
+        add     edi,edx\r
+        loop    @@1\r
+        jmp     @@3\r
+@@2:    xchg    ah,bh\r
+        loop    @@1\r
+@@3:\r
+end;\r
+\r
+procedure ShowC3Str(var dest; x,y: Byte; str: String; atr1,atr2,atr3: Byte); assembler;\r
+asm\r
+        mov     esi,[str]\r
+        mov     edi,[dest]\r
+        lodsb\r
+        xor     ecx,ecx\r
+        mov     cl,al\r
+        jecxz   @@3\r
+        push    ecx\r
+        mov     al,x\r
+        mov     ah,y\r
+        xor     ecx,ecx\r
+        call    DupChar\r
+        xor     edx,edx\r
+        mov     dx,absolute_pos\r
+        pop     ecx\r
+        add     edi,edx\r
+        mov     ah,atr1\r
+        mov     bl,atr2\r
+        mov     bh,atr3\r
+@@1:    lodsb\r
+        cmp     al,'~'\r
+        jz      @@2\r
+        cmp     al,'`'\r
+        jz      @@3\r
+        stosw\r
+        loop    @@1\r
+        jmp     @@4\r
+@@2:    xchg    ah,bl\r
+        loop    @@1\r
+        jmp     @@4\r
+@@3:    xchg    ah,bh\r
+        loop    @@1\r
+@@4:\r
+end;\r
+\r
+procedure ShowVC3Str(var dest; x,y: Byte; str: String; atr1,atr2,atr3: Byte); assembler;\r
+asm\r
+        mov     al,MaxCol\r
+        dec     al\r
+        xor     ah,ah\r
+        mov     bl,2\r
+        mul     bl\r
+        mov     bx,ax\r
+        mov     esi,[str]\r
+        mov     edi,[dest]\r
+        lodsb\r
+        xor     ecx,ecx\r
+        mov     cl,al\r
+        jecxz   @@4\r
+        push    ecx\r
+        mov     al,x\r
+        mov     ah,y\r
+        xor     ecx,ecx\r
+        call    DupChar\r
+        xor     edx,edx\r
+        mov     dx,absolute_pos\r
+        pop     ecx\r
+        add     edi,edx\r
+        mov     dx,bx\r
+        mov     ah,atr1\r
+        mov     bl,atr2\r
+        mov     bh,atr3\r
+@@1:    lodsb\r
+        cmp     al,'~'\r
+        jz      @@2\r
+        cmp     al,'`'\r
+        jz      @@3\r
+        stosw\r
+        add     edi,edx\r
+        loop    @@1\r
+        jmp     @@4\r
+@@2:    xchg    ah,bl\r
+        loop    @@1\r
+        jmp     @@4\r
+@@3:    xchg    ah,bh\r
+        loop    @@1\r
+@@4:\r
+end;\r
+\r
+function CStrLen(str: String): Byte; assembler;\r
+asm\r
+        mov     edi,[str]\r
+        xor     ecx,ecx\r
+        mov     cl,[edi]\r
+        inc     edi\r
+        mov     bx,cx\r
+        jecxz   @@2\r
+        mov     al,'~'\r
+@@1:    repne   scasb\r
+        jnz     @@2\r
+        dec     bx\r
+        jmp     @@1\r
+@@2:    mov     ax,bx\r
+end;\r
+\r
+function AbsPos(x,y: Byte): Word; assembler;\r
+asm\r
+        mov     al,x\r
+        mov     ah,y\r
+        xor     ecx,ecx\r
+        call    DupChar\r
+        mov     ax,absolute_pos\r
+end;\r
+\r
+function Color(fgnd,bgnd: Byte): Byte; assembler;\r
+asm\r
+        mov     al,bgnd\r
+        xor     ah,ah\r
+        mov     bh,16\r
+        mul     bh\r
+        add     al,fgnd\r
+end;\r
+\r
+procedure CleanScreen(var dest); assembler;\r
+asm\r
+        mov     edi,[dest]\r
+        mov     al,1\r
+        mov     bh,1\r
+        mov     cl,MaxCol\r
+        xor     ch,ch\r
+@@1:    mov     ah,bh\r
+        mov     dl,' '\r
+        mov     dh,07h\r
+        call    DupChar\r
+        inc     bh\r
+        cmp     bh,MaxLn\r
+        jle     @@1\r
+end;\r
+\r
+procedure Frame(var dest; x1,y1,x2,y2,atr1: Byte;\r
+                          title: String; atr2: Byte; border: String); assembler;\r
+var\r
+  xexp1,xexp2,xexp3,yexp1,yexp2: Byte;\r
+  offs: Longint;\r
+\r
+asm\r
+        cmp     fr_setting.update_area,1\r
+        jnz     @@0\r
+        mov     al,x1\r
+        mov     area_x1,al\r
+        mov     al,y1\r
+        mov     area_y1,al\r
+        mov     al,x2\r
+        mov     area_x2,al\r
+        mov     al,y2\r
+        mov     area_y2,al\r
+@@0:    mov     bl,fr_setting.wide_range_type\r
+        mov     bh,fr_setting.shadow_enabled\r
+        mov     esi,[border]\r
+        mov     edi,[dest]\r
+        mov     offs,edi\r
+        cmp     bl,0\r
+        je      @@1\r
+        mov     xexp1,4\r
+        mov     xexp2,-1\r
+        mov     xexp3,7\r
+        mov     yexp1,1\r
+        mov     yexp2,2\r
+        jmp     @@2\r
+@@1:    mov     xexp1,1\r
+        mov     xexp2,2\r
+        mov     xexp3,1\r
+        mov     yexp1,0\r
+        mov     yexp2,1\r
+        jmp     @@4\r
+@@2:    mov     al,x1\r
+        sub     al,3\r
+        mov     ah,y1\r
+        dec     ah\r
+        mov     dl,' '\r
+        mov     dh,atr1\r
+        xor     ecx,ecx\r
+        mov     cl,x2\r
+        sub     cl,x1\r
+        add     cl,7\r
+        call    DupChar\r
+        mov     ah,y2\r
+        inc     ah\r
+        call    DupChar\r
+        mov     bl,y1\r
+@@3:    mov     al,x1\r
+        sub     al,3\r
+        mov     ah,bl\r
+        mov     dl,' '\r
+        mov     ecx,3\r
+        call    DupChar\r
+        mov     al,x2\r
+        inc     al\r
+        mov     dl,' '\r
+        mov     ecx,3\r
+        call    DupChar\r
+        inc     bl\r
+        cmp     bl,y2\r
+        jng     @@3\r
+@@4:    mov     al,x1\r
+        mov     ah,y1\r
+        mov     dl,[esi+1]\r
+        mov     dh,atr1\r
+        mov     ecx,1\r
+        push    edi\r
+        call    DupChar\r
+        inc     al\r
+        mov     dl,[esi+2]\r
+        mov     dh,atr1\r
+        mov     cl,x2\r
+        sub     cl,x1\r
+        dec     cl\r
+        call    DupChar\r
+        mov     al,x2\r
+        mov     dl,[esi+3]\r
+        mov     dh,atr1\r
+        mov     ecx,1\r
+        call    DupChar\r
+        mov     bl,y1\r
+@@5:    inc     bl\r
+        mov     al,x1\r
+        mov     ah,bl\r
+        mov     dl,[esi+4]\r
+        mov     dh,atr1\r
+        mov     ecx,1\r
+        call    DupChar\r
+        inc     al\r
+        mov     dl,' '\r
+        mov     dh,atr1\r
+        mov     cl,x2\r
+        sub     cl,x1\r
+        dec     cl\r
+        call    DupChar\r
+        mov     al,x2\r
+        mov     dl,[esi+5]\r
+        mov     dh,atr1\r
+        mov     ecx,1\r
+        call    DupChar\r
+        cmp     bl,y2\r
+        jnge    @@5\r
+        mov     al,x1\r
+        mov     ah,y2\r
+        mov     dl,[esi+6]\r
+        mov     dh,atr1\r
+        mov     ecx,1\r
+        call    DupChar\r
+        inc     al\r
+        mov     dl,[esi+7]\r
+        mov     cl,x2\r
+        sub     cl,x1\r
+        dec     cl\r
+        call    DupChar\r
+        mov     al,x2\r
+        mov     dl,[esi+8]\r
+        mov     dh,atr1\r
+        mov     ecx,1\r
+        call    DupChar\r
+        mov     esi,[title]\r
+        mov     cl,[esi]\r
+        jecxz   @@7\r
+        xor     eax,eax\r
+        mov     al,x2\r
+        sub     al,x1\r
+        sub     al,cl\r
+        mov     bl,2\r
+        div     bl\r
+        add     al,x1\r
+        add     al,ah\r
+        mov     ah,y1\r
+        xor     ecx,ecx\r
+        call    DupChar\r
+        push    eax\r
+        xor     eax,eax\r
+        mov     ax,absolute_pos\r
+        mov     edi,offs\r
+        add     edi,eax\r
+        pop     eax\r
+        lodsb\r
+        mov     cl,al\r
+        mov     ah,atr2\r
+@@6:    lodsb\r
+        stosw\r
+        loop    @@6\r
+@@7:    cmp     bh,0\r
+        je      @@11\r
+        mov     bl,y1\r
+        sub     bl,yexp1\r
+@@8:    inc     bl\r
+        mov     al,x2\r
+        add     al,xexp1\r
+        mov     ah,bl\r
+        xor     ecx,ecx\r
+        call    DupChar\r
+        push    eax\r
+        xor     eax,eax\r
+        mov     ax,absolute_pos\r
+        mov     edi,offs\r
+        add     edi,eax\r
+        pop     eax\r
+        inc     edi\r
+        mov     al,07\r
+        stosb\r
+        cmp     MaxLn,80\r
+        jae     @@9\r
+        inc     edi\r
+        stosb\r
+        cmp     MaxCol,132\r
+        jna     @@9\r
+        inc     edi\r
+        stosb\r
+@@9:    cmp     bl,y2\r
+        jng     @@8\r
+        mov     al,x1\r
+        add     al,xexp2\r
+        mov     ah,y2\r
+        add     ah,yexp2\r
+        xor     ecx,ecx\r
+        call    DupChar\r
+        push    eax\r
+        xor     eax,eax\r
+        mov     ax,absolute_pos\r
+        mov     edi,offs\r
+        add     edi,eax\r
+        pop     eax\r
+        inc     edi\r
+        mov     al,07\r
+        mov     cl,x2\r
+        sub     cl,x1\r
+        add     cl,xexp3\r
+        cmp     MaxLn,45\r
+        jb      @@10\r
+        dec     cl\r
+@@10:   stosb\r
+        inc     edi\r
+        loop    @@10\r
+@@11:\r
+end;\r
+\r
+function iEGA: Boolean; assembler;\r
+asm\r
+        mov     ax,01200h\r
+        mov     bx,00010h\r
+        mov     cx,0ffffh\r
+        int     10h\r
+        cmp     cx,0ffffh\r
+        jz      @@1\r
+        mov     al,1\r
+        jmp     @@2\r
+@@1:    xor     al,al\r
+@@2:\r
+end;\r
+\r
+function iVGA: Boolean; assembler;\r
+asm\r
+        mov     ax,1a00h\r
+        int     10h\r
+        cmp     al,1ah\r
+        jnz     @@1\r
+        cmp     bl,7\r
+        jb      @@1\r
+        cmp     bl,0ffh\r
+        jnz     @@2\r
+@@1:    xor     al,al\r
+        jmp     @@3\r
+@@2:    mov     al,1\r
+@@3:\r
+end;\r
+\r
+function iPS2: Boolean; assembler;\r
+asm\r
+        mov     ax,1a00h\r
+        int     10h\r
+        and     al,0ffh\r
+        cmp     al,1ah\r
+        jnz     @@1\r
+        and     bl,0ffh\r
+        cmp     bl,07h\r
+        jb      @@1\r
+        cmp     bl,0ch\r
+        ja      @@1\r
+        cmp     bl,09h\r
+        jz      @@1\r
+        cmp     bl,0ah\r
+        jz      @@1\r
+        mov     al,1\r
+        jmp     @@2\r
+@@1:    xor     al,al\r
+@@2:\r
+end;\r
+\r
+function iMDA: Boolean; assembler;\r
+asm\r
+        cmp     v_mode,07h\r
+        jnz     @@1\r
+        mov     al,1\r
+        jmp     @@2\r
+@@1:    xor     al,al\r
+@@2:\r
+end;\r
+\r
+function iCGA: Boolean; assembler;\r
+asm\r
+        call    iMDA\r
+        cmp     al,0\r
+        jnz     @@1\r
+        call    iEGA\r
+        cmp     al,0\r
+        jnz     @@1\r
+        call    iPS2\r
+        cmp     al,0\r
+        jnz     @@1\r
+        mov     al,1\r
+        jmp     @@2\r
+@@1:    xor     al,al\r
+@@2:\r
+end;\r
+\r
+function iMCGA: Boolean; assembler;\r
+asm\r
+        call    iMDA\r
+        cmp     al,0\r
+        jnz     @@1\r
+        call    iEGA\r
+        cmp     al,0\r
+        jnz     @@1\r
+        call    iPS2\r
+        cmp     al,1\r
+        jnz     @@1\r
+        mov     al,1\r
+        jmp     @@2\r
+@@1:    xor     al,al\r
+@@2:\r
+end;\r
+\r
+function WhereX: Byte; assembler;\r
+asm\r
+        mov     bh,DispPg\r
+        mov     ah,03h\r
+        int     10h\r
+        inc     dl\r
+        mov     al,dl\r
+end;\r
+\r
+function WhereY: Byte; assembler;\r
+asm\r
+        mov     bh,DispPg\r
+        mov     ah,03h\r
+        int     10h\r
+        inc     dh\r
+        mov     al,dh\r
+end;\r
+\r
+procedure GotoXY(x,y: Byte); assembler;\r
+asm\r
+        mov     dh,y\r
+        mov     dl,x\r
+        dec     dh\r
+        dec     dl\r
+        mov     bh,DispPg\r
+        mov     ah,02h\r
+        int     10h\r
+end;\r
+\r
+procedure ResetMode; assembler;\r
+asm\r
+        xor     ah,ah\r
+        mov     al,v_mode\r
+        mov     bh,DispPg\r
+        int     10h\r
+end;\r
+\r
+function GetCursor: Longint; assembler;\r
+asm\r
+        xor     edx,edx\r
+        mov     bh,DispPg\r
+        mov     ah,03h\r
+        int     10h\r
+        shl     edx,16\r
+        xor     eax,eax\r
+        push    edx\r
+        call    GetCursorShape\r
+        pop     edx\r
+        add     edx,eax\r
+        mov     eax,edx\r
+end;\r
+\r
+\r
+procedure SetCursor(cursor: Longint); assembler;\r
+asm\r
+        xor     eax,eax\r
+        mov     ax,word ptr [cursor]\r
+        push    eax\r
+        call    SetCursorShape\r
+        mov     dx,word ptr [cursor+2]\r
+        mov     bh,DispPg\r
+        mov     ah,02h\r
+        int     10h\r
+end;\r
+\r
+procedure ThinCursor; assembler;\r
+asm\r
+        xor     ecx,ecx\r
+        call    iMDA\r
+        cmp     al,1\r
+        jnz     @@1\r
+        mov     cx,0b0ch\r
+        jmp     @@5\r
+@@1:    call    iCGA\r
+        cmp     al,1\r
+        jnz     @@2\r
+        mov     cx,0708h\r
+        jmp     @@5\r
+@@2:    call    iMCGA\r
+        cmp     al,1\r
+        jnz     @@3\r
+        mov     cx,0708h\r
+        jmp     @@5\r
+@@3:    call    iVGA\r
+        cmp     al,1\r
+        jnz     @@4\r
+        mov     cx,0d0eh\r
+        jmp     @@5\r
+@@4:    mov     cx,0b0ch\r
+@@5:    push    ecx\r
+        call    SetCursorShape\r
+end;\r
+\r
+procedure WideCursor; assembler;\r
+asm\r
+        xor     ecx,ecx\r
+        call    iMDA\r
+        cmp     al,1\r
+        jnz     @@1\r
+        mov     cx,010ch\r
+        jmp     @@5\r
+@@1:    call    iCGA\r
+        cmp     al,1\r
+        jnz     @@2\r
+        mov     cx,0107h\r
+        jmp     @@5\r
+@@2:    call    iMCGA\r
+        cmp     al,1\r
+        jnz     @@3\r
+        mov     cx,0107h\r
+        jmp     @@5\r
+@@3:    call    iVGA\r
+        cmp     al,1\r
+        jnz     @@4\r
+        mov     cx,010eh\r
+        jmp     @@5\r
+@@4:    mov     cx,010ch\r
+@@5:    push    ecx\r
+        call    SetCursorShape\r
+end;\r
+\r
+procedure HideCursor; assembler;\r
+asm\r
+        xor     ecx,ecx\r
+        mov     cx,1010h\r
+        push    ecx\r
+        call    SetCursorShape\r
+end;\r
+\r
+function GetCursorShape: Word; assembler;\r
+asm\r
+        mov     dx,03d4h\r
+        mov     al,0ah\r
+        out     dx,al\r
+        inc     dx\r
+        in      al,dx\r
+        and     al,1fh\r
+        mov     ah,al\r
+        dec     dx\r
+        mov     al,0bh\r
+        out     dx,al\r
+        inc     dx\r
+        in      al,dx\r
+        and     al,1fh\r
+end;\r
+\r
+procedure SetCursorShape(shape: Word); assembler;\r
+asm\r
+        mov     dx,03d4h\r
+        mov     al,0ah\r
+        out     dx,al\r
+        inc     dx\r
+        in      al,dx\r
+        mov     ah,BYTE(shape)[1]\r
+        and     al,0e0h\r
+        or      al,ah\r
+        out     dx,al\r
+        dec     dx\r
+        mov     al,0bh\r
+        out     dx,al\r
+        inc     dx\r
+        in      al,dx\r
+        mov     ah,BYTE(shape)[0]\r
+        and     al,0e0h\r
+        or      al,ah\r
+        out     dx,al\r
+end;\r
+\r
+procedure initialize;\r
+begin\r
+  asm\r
+        mov     ah,0fh\r
+        int     10h\r
+        and     al,7fh\r
+        mov     v_mode,al\r
+        mov     DispPg,bh\r
+  end;\r
+\r
+  If (MEM[0:$449] = 7) then\r
+    begin\r
+      v_seg := $0b000;\r
+      MaxLn := 25;\r
+    end\r
+  else begin\r
+         v_seg := $0b800;\r
+         MaxLn := SUCC(MEM[0:$484]);\r
+       end;\r
+\r
+  v_ofs  := MEM[0:$44e];\r
+  MaxCol := MEM[0:$44a];\r
+\r
+  work_MaxLn  := MaxLn;\r
+  work_MaxCol := MaxCol;\r
+\r
+  If iCGA then CheckSnow := TRUE\r
+  else CheckSnow := FALSE;\r
+end;\r
+\r
+var\r
+  dos_seg: Word;\r
+  bios_data_backup: array[0..167] of Byte;\r
+  regs: tRmRegs;\r
+\r
+procedure GetVideoState(var data: tVIDEO_STATE);\r
+begin\r
+  Move(Ptr(v_seg,v_ofs)^,data.screen,SizeOf(data.screen));\r
+  data.cursor := GetCursor;\r
+  data.font := MEMW[0:$0485];\r
+  data.v_mode := v_mode;\r
+  data.MaxLn := MaxLn;\r
+  data.MaxCol := MaxCol;\r
+  data.v_ofs := v_ofs;\r
+  Move(MEM[$40:0],bios_data_backup,168);\r
+  dos_seg := DosMemoryAlloc(SizeOf(tVIDEO_STATE(data).data));\r
+  ClearRmRegs(regs);\r
+  regs.cx := 7;\r
+  regs.es := dos_seg;\r
+  regs.ax := $1c01;\r
+  RealModeInt($10,regs);\r
+  Move(bios_data_backup,MEM[$40:0],168);\r
+  Move(POINTER(DWORD(dos_seg)*16)^,tVIDEO_STATE(data).data,\r
+       SizeOf(tVIDEO_STATE(data).data));\r
+  DosMemoryFree(dos_seg);\r
+end;\r
+\r
+procedure SetVideoState(var data: tVIDEO_STATE; restore_screen: Boolean);\r
+begin\r
+  v_mode := data.v_mode;\r
+  ResetMode;\r
+  Move(MEM[$40:0],bios_data_backup,168);\r
+  dos_seg := DosMemoryAlloc(SizeOf(tVIDEO_STATE(data).data));\r
+  Move(tVIDEO_STATE(data).data,POINTER(DWORD(dos_seg)*16)^,\r
+       SizeOf(tVIDEO_STATE(data).data));\r
+  ClearRmRegs(regs);\r
+  regs.cx := 7;\r
+  regs.es := dos_seg;\r
+  regs.ax := $1c02;\r
+  RealModeInt($10,regs);\r
+  DosMemoryFree(dos_seg);\r
+  Move(bios_data_backup,MEM[$40:0],168);\r
+\r
+  MEM[0:$44e] := data.v_ofs;\r
+  MEM[0:$484] := PRED(data.MaxLn);\r
+  MEM[0:$44a] := data.MaxCol;\r
+\r
+  Case data.font of\r
+     8:  asm mov ax,1112h; xor bl,bl; int 10h end;\r
+    14:  asm mov ax,1111h; xor bl,bl; int 10h end;\r
+    else asm mov ax,1114h; xor bl,bl; int 10h end;\r
+  end;\r
+\r
+  initialize;\r
+  SetCursor(data.cursor);\r
+  If restore_screen then\r
+    Move(data.screen,Ptr(v_seg,v_ofs)^,SizeOf(data.screen));\r
+end;\r
+\r
+procedure GetRGBitem(color: Byte; var red,green,blue: Byte);\r
+begin\r
+  PORT[$3c7] := color;\r
+  red   := PORT[$3c9];\r
+  green := PORT[$3c9];\r
+  blue  := PORT[$3c9];\r
+end;\r
+\r
+procedure SetRGBitem(color: Byte; red,green,blue: Byte);\r
+begin\r
+  PORT[$3c8] := color;\r
+  PORT[$3c9] := red;\r
+  PORT[$3c9] := green;\r
+  PORT[$3c9] := blue;\r
+end;\r
+\r
+procedure WaitRetrace; assembler;\r
+asm\r
+        mov     dx,3dah\r
+@@1:    in      al,dx\r
+        and     al,08h\r
+        jnz     @@1\r
+@@2:    in      al,dx\r
+        and     al,08h\r
+        jz      @@2\r
+end;\r
+\r
+procedure GetPalette(var pal; first,last: Word); assembler;\r
+asm\r
+        xor     eax,eax\r
+        xor     ecx,ecx\r
+        mov     ax,first\r
+        mov     cx,last\r
+        sub     ecx,eax\r
+        inc     ecx\r
+        mov     dx,03c7h\r
+        out     dx,al\r
+        add     dx,2\r
+        mov     edi,[pal]\r
+        add     edi,eax\r
+        add     edi,eax\r
+        add     edi,eax\r
+        mov     eax,ecx\r
+        add     ecx,eax\r
+        add     ecx,eax\r
+        rep     insb\r
+end;\r
+\r
+procedure SetPalette(var pal; first,last: Word); assembler;\r
+asm\r
+        mov     dx,03dah\r
+@@1:    in      al,dx\r
+        test    al,8\r
+        jz      @@1\r
+        xor     eax,eax\r
+        xor     ecx,ecx\r
+        mov     ax,first\r
+        mov     cx,last\r
+        sub     ecx,eax\r
+        inc     ecx\r
+        mov     dx,03c8h\r
+        out     dx,al\r
+        inc     dx\r
+        mov     esi,[pal]\r
+        add     esi,eax\r
+        add     esi,eax\r
+        add     esi,eax\r
+        mov     eax,ecx\r
+        add     ecx,eax\r
+        add     ecx,eax\r
+        rep     outsb\r
+end;\r
+\r
+const\r
+  fade_first: Byte = 0;\r
+  fade_last:  Byte = 255;\r
+\r
+procedure wait_ms; assembler;\r
+asm\r
+@@1:    mov     di,-1*1193*2\r
+        xor     al,al\r
+        out     43h,al\r
+        in      al,40h\r
+        mov     bl,al\r
+        in      al,40h\r
+        mov     bh,al\r
+@@2:    xor     al,al\r
+        out     43h,al\r
+        in      al,40h\r
+        mov     ah,al\r
+        in      al,40h\r
+        xchg    ah,al\r
+        sub     ax,bx\r
+        cmp     ax,di\r
+        jnc     @@2\r
+end;\r
+\r
+procedure VgaFade(var data: tFADE_BUF; fade: tFADE; delay: tDELAY);\r
+\r
+var\r
+  i,j: Byte;\r
+\r
+begin\r
+  If (fade = fadeOut) and (data.action in [first,fadeIn]) then\r
+    begin\r
+      GetPalette(data.pal0,fade_first,fade_last);\r
+      If delay = delayed then\r
+        For i := fade_speed downto 0 do\r
+          begin\r
+            For j := fade_first to fade_last do\r
+              begin\r
+                data.pal1[j].r := data.pal0[j].r * i DIV fade_speed;\r
+                data.pal1[j].g := data.pal0[j].g * i DIV fade_speed;\r
+                data.pal1[j].b := data.pal0[j].b * i DIV fade_speed;\r
+              end;\r
+            SetPalette(data.pal1,fade_first,fade_last);\r
+            wait_ms;\r
+          end\r
+      else\r
+        begin\r
+          FillChar(data.pal1,SizeOf(data.pal1),0);\r
+          SetPalette(data.pal1,fade_first,fade_last);\r
+        end;\r
+      data.action := fadeOut;\r
+    end;\r
+\r
+  If (fade = fadeIn) and (data.action = fadeOut) then\r
+    begin\r
+      If delay = delayed then\r
+        For i := 0 to fade_speed do\r
+          begin\r
+            For j := fade_first to fade_last do\r
+              begin\r
+                data.pal1[j].r := data.pal0[j].r * i DIV fade_speed;\r
+                data.pal1[j].g := data.pal0[j].g * i DIV fade_speed;\r
+                data.pal1[j].b := data.pal0[j].b * i DIV fade_speed;\r
+              end;\r
+            SetPalette(data.pal1,fade_first,fade_last);\r
+            wait_ms;\r
+          end\r
+      else\r
+        SetPalette(data.pal0,fade_first,fade_last);\r
+      data.action := fadeIn;\r
+    end;\r
+end;\r
+\r
+procedure RefreshEnable; assembler;\r
+asm mov ax,1200h; mov bl,36h; int 10h end;\r
+\r
+procedure RefreshDisable; assembler;\r
+asm mov ax,1201h; mov bl,36h; int 10h end;\r
+\r
+procedure Split2Static;\r
+\r
+var\r
+  temp: Byte;\r
+\r
+begin\r
+  temp := PORT[$3da];\r
+  PORT[$3c0] := $10 OR $20;\r
+  PORT[$3c0] := PORT[$3c1] OR $20;\r
+end;\r
+\r
+procedure SplitScr(line: Integer);\r
+\r
+var\r
+  temp: Byte;\r
+\r
+begin\r
+  PORT[$3d4] := $18;\r
+  PORT[$3d5] := LO(line);\r
+  PORT[$3d4] := $07;\r
+  temp := PORT[$3d5];\r
+\r
+  If (line < $100) then temp := temp AND $0ef\r
+  else temp := temp OR $10;\r
+\r
+  PORT[$3d5] := temp;\r
+  PORT[$3d4] := $09;\r
+  temp := PORT[$3d5];\r
+\r
+  If (line < $200) then temp := temp AND $0bf\r
+  else temp := temp OR $40;\r
+\r
+  PORT[$3d5] := temp;\r
+end;\r
+\r
+procedure SetSize(columns,lines: Integer);\r
+begin\r
+  PORT[$3d4] := $13;\r
+  PORT[$3d5] := columns SHR 1;\r
+  MEMW[$0000:$44a] := columns;\r
+  MEMW[$0000:$484] := lines-1;\r
+  MEMW[$0000:$44c] := columns*lines;\r
+end;\r
+\r
+procedure SetTextDisp(x,y: Integer);\r
+\r
+var\r
+  temp: Byte;\r
+\r
+begin\r
+  While (PORT[$3da] AND 1 =  1) do ;\r
+  While (PORT[$3da] AND 1 <> 1) do ;\r
+\r
+  PORT[$3d4] := $0c;\r
+  PORT[$3d5] := HI((y SHR 4)*MaxCol+(x DIV 9));\r
+  PORT[$3d4] := $0d;\r
+  PORT[$3d5] := LO((y SHR 4)*MaxCol+(x DIV 9));\r
+  PORT[$3d4] := $08;\r
+  PORT[$3d5] := (PORT[$3d5] AND $0e0) OR (y AND $0f);\r
+  temp := PORT[$3da];\r
+  PORT[$3c0] := $13 OR $20;\r
+  PORT[$3c0] := (x+9) MOD 9;\r
+end;\r
+\r
+procedure SetCustomVideoMode(vmode: tCUSTOM_VIDEO_MODE);\r
+\r
+const\r
+  vmode_data: array[0..52,0..63] of Byte = (\r
+\r
+{ 1..5   - BIOS variables,\r
+  6..9   - Sequencer,\r
+  10     - Miscellaneous Output,\r
+  11..35 - CRTC,\r
+  36..55 - Attribute,\r
+  56..64 - Graphics   }\r
+\r
+{  0, Text 36x14, 9x14, complete }\r
+(  36,  13,  14,   0, 4,     8,   3,   0,   2,    99,\r
+  40, 35, 36,138, 38,192,183, 31,  0,205, 11, 12,  0,  0,  0,\r
+   0,148,134,135, 18, 31,142,177,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{  1, Text 40x14, 8x14, complete }\r
+(  40,  13,  14,   0, 5,     9,   3,   0,   2,    99,\r
+  45, 39, 40,144, 43,160,183, 31,  0,205, 11, 12,  0,  0,  0,\r
+   0,148,134,135, 20, 31,142,177,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{  2, Text 40x14, 9x14, complete }\r
+(  40,  13,  14,   0, 5,     8,   3,   0,   2,   103,\r
+  45, 39, 40,144, 43,160,183, 31,  0,205, 11, 12,  0,  0,  0,\r
+   0,148,134,135, 20, 31,142,177,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{  3, Text 46x14, 8x14, complete }\r
+(  46,  13,  14,   0, 6,     9,   3,   0,   2,   103,\r
+  52, 45, 46,151, 50,150,183, 31,  0,205, 11, 12,  0,  0,  0,\r
+   0,148,134,135, 23, 31,142,177,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+\r
+{  4, Text 36x15, 9x16, complete }\r
+(  36,  14,  16,  0, 5,     8,   3,   0,   2,   227,\r
+  40, 35, 36,138, 38,192, 11, 62,  0,207, 13, 14,  0,  0,  0,\r
+   0,234,172,223, 18, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{  5, Text 40x15, 8x16, complete }\r
+(  40,  14,  16,   0, 5,     9,   3,   0,   2,   227,\r
+  45, 39, 40,144, 43,160, 11, 62,  0,207, 13, 14,  0,  0,  0,\r
+   0,234,172,223, 20, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{  6, Text 40x15, 9x16, complete }\r
+(  40,  14,  16,   0, 5,     8,   3,   0,   2,   231,\r
+  45, 39, 40,144, 43,160, 11, 62,  0,207, 13, 14,  0,  0,  0,\r
+   0,234,172,223, 20, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{  7, Text 46x15, 8x16, complete }\r
+(  46,  14,  16,   0, 6,     9,   3,   0,   2,   231,\r
+  52, 45, 46,151, 50,150, 11, 62,  0,207, 13, 14,  0,  0,  0,\r
+   0,234,172,223, 23, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+\r
+{  8, Text 36x17, 9x14, complete }\r
+(  36,  16,  14,   0, 5,     8,   3,   0,   2,   227,\r
+  40, 35, 36,138, 38,192,  7, 62,  0,205, 11, 12,  0,  0,  0,\r
+   0,230,168,219, 18, 31,227,  2,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{  9, Text 40x17, 8x14, complete }\r
+(  40,  16,  14,   0, 6,     9,   3,   0,   2,   227,\r
+  45, 39, 40,144, 43,160,  7, 62,  0,205, 11, 12,  0,  0,  0,\r
+   0,230,168,219, 20, 31,227,  2,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 10, Text 40x17, 9x14, complete }\r
+(  40,  16,  14,   0, 6,     8,   3,   0,   2,   231,\r
+  45, 39, 40,144, 43,160,  7, 62,  0,205, 11, 12,  0,  0,  0,\r
+   0,230,168,219, 20, 31,227,  2,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 11, Text 46x17, 9x14, complete }\r
+(  46,  16,  14,   0, 7,     9,   3,   0,   2,   231,\r
+  52, 45, 46,151, 50,150,  7, 62,  0,205, 11, 12,  0,  0,  0,\r
+   0,230,168,219, 23, 31,227,  2,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+\r
+{ 12, Text 36x22, 9x16, complete }\r
+(  36,  21,  16,   0, 7,     8,   3,   0,   2,   163,\r
+  40, 35, 36,138, 38,192,193, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,133,165, 95, 18, 31,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 13, Text 40x22, 8x16, complete }\r
+(  40,  21,  16,   0, 7,     9,   3,   0,   2,   163,\r
+  45, 39, 40,144, 43,160,193, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,133,165, 95, 20, 31,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 14, Text 40x22, 9x16, complete }\r
+(  40,  21,  16,   0, 7,     8,   3,   0,   2,   167,\r
+  45, 39, 40,144, 43,160,193, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,133,165, 95, 20, 31,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 15, Text 46x22, 8x16, complete }\r
+(  46,  21,  16,   0, 8,     9,   3,   0,   2,   167,\r
+  52, 45, 46,151, 50,150,193, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,133,165, 95, 23, 31,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 16, Text 70x22, 9x16, complete }\r
+(  70,  21,  16,   0,13,     0,   3,   0,   2,   163,\r
+  83, 69, 70,150, 75, 21,193, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,133,165, 95, 35, 31,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 17, Text 80x22, 8x16, complete }\r
+(  80,  21,  16,   0,14,     1,   3,   0,   2,   163,\r
+  95, 79, 80,130, 85,129,193, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,133,165, 95, 40, 31,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 18, Text 80x22, 9x16, complete }\r
+(  80,  21,  16,   0,14,     0,   3,   0,   2,   167,\r
+  95, 79, 80,130, 85,129,193, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,133,165, 95, 40, 31,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 19, Text 90x22, 8x16, complete }\r
+(  90,  21,  16,   0,16,     1,   3,   0,   2,   167,\r
+ 107, 89, 90,142, 95,138,193, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,133,165, 95, 45, 31,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+\r
+{ 20, Text 36x25, 9x16, complete }\r
+(  36,  24,  16,   0, 8,     8,   3,   0,   2,    99,\r
+  40, 35, 36,138, 38,192,191, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,156,142,143, 18, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 21, Text 40x25, 8x16, complete }\r
+(  40,  24,  16,   0, 8,     9,   3,   0,   2,    99,\r
+  45, 39, 40,144, 43,160,191, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,156,142,143, 20, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 22, Text 40x25, 9x16, complete }\r
+(  40,  24,  16,   0, 8,     8,   3,   0,   2,   103,\r
+  45, 39, 40,144, 43,160,191, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,156,142,143, 20, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 23, Text 46x25, 8x16, complete }\r
+(  46,  24,  16,   0,10,     9,   3,   0,   2,   103,\r
+  52, 45, 46,151, 50,150,191, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,156,142,143, 23, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 24, Text 70x25, 9x16, complete }\r
+(  70,  24,  16,   0,14,     0,   3,   0,   2,   99,\r
+  83, 69, 70,150, 75, 21,191, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,156,142,143, 35, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 25, Text 80x25, 8x16, complete }\r
+(  80,  24,  16,   0,16,     1,   3,   0,   2,   99,\r
+  95, 79, 80,130, 85,129,191, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,156,142,143, 40, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 26, Text 80x25, 9x16, standard }\r
+(  80,  24,  16,   0,16,     0,   3,   0,   2,   103,\r
+  95, 79, 80,130, 85,129,191, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,156,142,143, 40, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 27, Text 90x25, 8x16, complete }\r
+(  90,  24,  16,  0, 18  ,   1,   3,   0,   2,  103,\r
+ 107, 89, 90,142, 95,138,191, 31,  0, 79, 13, 14,  0,  0,  0,\r
+   0,156,142,143, 45, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+\r
+{ 28, Text 46x29, 8x16, complete }\r
+(  46,  28,  14,   0,11,     9,   3,   0,   2,   103,\r
+  52, 45, 46,151, 50,150,193, 31,  0, 77, 11, 12,  0,  0,  0,\r
+   0,159,145,149, 23, 31,155,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 29, Text 70x29, 9x14, complete }\r
+(  70,  28,  14,  0, 16  ,   0,   3,   0,   2,   99,\r
+  83, 69, 70,150, 75, 21,193, 31,  0, 77, 11, 12,  0,  0,  0,\r
+   0,159,145,149, 35, 31,155,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 30, Text 80x29, 8x14, complete }\r
+(  80,  28,  14,  0, 19  ,   1,   3,   0,   2,   99,\r
+  95, 79, 80,130, 85,129,193, 31,  0, 77, 11, 12,  0,  0,  0,\r
+   0,159,145,149, 40, 31,155,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 31, Text 80x29, 9x14, complete }\r
+(  80,  28,  14,  0, 19  ,   0,   3,   0,   2,  103,\r
+  95, 79, 80,130, 85,129,193, 31,  0, 77, 11, 12,  0,  0,  0,\r
+   0,159,145,149, 40, 31,155,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 32, Text 90x29, 8x14, complete }\r
+(  90,  28,  14,  0, 21  ,   1,   3,   0,   2,  103,\r
+ 107, 89, 90,142, 95,138,193, 31,  0, 77, 11, 12,  0,  0,  0,\r
+   0,159,145,149, 45, 31,155,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+\r
+{ 33, Text 70x30, 9x16, complete }\r
+(  70,  29,  16,  0, 17  ,   0,   3,   0,   2,  227,\r
+  83, 69, 70,150, 75, 21, 11, 62,  0, 79, 13, 14,  0,  0,  0,\r
+   0,234,172,223, 35, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 34, Text 80x30, 8x16, complete }\r
+(  80,  29,  16,  0, 19  ,   1,   3,   0,   2,  227,\r
+  95, 79, 80,130, 85,129, 11, 62,  0, 79, 13, 14,  0,  0,  0,\r
+   0,234,172,223, 40, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 35, Text 80x30, 9x16, complete }\r
+(  80,  29,  16,  0, 19  ,   0,   3,   0,   2,  231,\r
+  95, 79, 80,130, 85,129, 11, 62,  0, 79, 13, 14,  0,  0,  0,\r
+   0,234,172,223, 40, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 36, Text 90x30, 8x16 ,complete }\r
+(  90,  29,  16,  0, 22  ,   1,   3,   0,   2,  231,\r
+ 107, 89, 90,142, 95,138, 11, 62,  0, 79, 13, 14,  0,  0,  0,\r
+   0,234,172,223, 45, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+\r
+{ 37, Text 70x34, 9x14, complete }\r
+(  70,  33,  14,  0, 19  ,   0,   3,   0,   2,  227,\r
+  83, 69, 70,150, 75, 21,  7, 62,  0, 77, 11, 12,  0,  0,  0,\r
+   0,230,168,219, 35, 31,227,  2,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 38, Text 80x34, 8x14, complete }\r
+(  80,  33,  14,  0, 22  ,   1,   3,   0,   2,  227,\r
+  95, 79, 80,130, 85,129,  7, 62,  0, 77, 11, 12,  0,  0,  0,\r
+   0,230,168,219, 40, 31,227,  2,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 39, Text 80x34, 9x14, complete }\r
+(  80,  33,  14,  0, 22  ,   0,   3,   0,   2,  231,\r
+  95, 79, 80,130, 85,129,  7, 62,  0, 77, 11, 12,  0,  0,  0,\r
+   0,230,168,219, 40, 31,227,  2,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 40, Text 90x34, 8x14, complete }\r
+(  90,  33,  14,  0, 24  ,   1,   3,   0,   2,  231,\r
+ 107, 89, 90,142, 95,138,  7, 62,  0, 77, 11, 12,  0,  0,  0,\r
+   0,230,168,219, 45, 31,227,  2,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+\r
+{ 41, Text 70x44, 9x8, complete }\r
+(  70,  43,   8,   0,25,     0,   3,   0,   2,   163,\r
+  83, 69, 70,150, 75, 21,193, 31,  0, 71,  6,  7,  0,  0,  0,\r
+   0,133,135, 95, 35, 15,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 42, Text 80x44, 8x8, complete }\r
+(  80,  43,   8,   0,28,     1,   3,   0,   2,   163,\r
+  95, 79, 80,130, 85,129,193, 31,  0, 71,  6,  7,  0,  0,  0,\r
+   0,133,135, 95, 40, 15,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 43, Text 80x44, 9x8, complete }\r
+(  80,  43,   8,   0,28,     0,   3,   0,   2,   167,\r
+  95, 79, 80,130, 85,129,193, 31,  0, 71,  6,  7,  0,  0,  0,\r
+   0,133,135, 95, 40, 15,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 44, Text 90x44, 8x8, complete }\r
+(  90,  43,   8,   0,31,     1,   3,   0,   2,   167,\r
+ 107, 89, 90,142, 95,138,193, 31,  0, 71,  6,  7,  0,  0,  0,\r
+   0,133,135, 95, 45, 15,101,187,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+\r
+{ 45, Text 70x50, 9x8, complete }\r
+(  70,  49,   8,   0,28,     0,   3,   0,   2,   99,\r
+  83, 69, 70,150, 75, 21,191, 31,  0, 71,  6,  7,  0,  0,  0,\r
+   0,156,142,143, 35, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 46, Text 80x50, 8x8, complete }\r
+(  80,  49,   8,   0,32,     1,   3,   0,   2,   99,\r
+  95, 79, 80,130, 85,129,191, 31,  0, 71,  6,  7,  0,  0,  0,\r
+   0,156,142,143, 40, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 47, Text 80x50, 9x8, standard }\r
+(  80,  49,   8,   0,32,     0,   3,   0,   2,   103,\r
+  95, 79, 80,130, 85,129,191, 31,  0, 71,  6,  7,  0,  0,  0,\r
+   0,156,142,143, 40, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63, 12,  0, 15, 8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 48, Text 90x50, 8x8, complete }\r
+(  90,  49,   8,  0, 36  ,   1,   3,   0,   2,  103,\r
+ 107, 89, 90,142, 95,138,191, 31,  0, 71,  6,  7,  0,  0,  0,\r
+   0,156,142,143, 45, 31,150,185,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+\r
+{ 49, Text 70x60, 9x8, complete }\r
+(  70,  59,   8,  0, 33  ,   0,   3,   0,   2,  227,\r
+  83, 69, 70,150, 75, 21, 11, 62,  0, 71,  6,  7,  0,  0,  0,\r
+   0,234,172,223, 35, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 50, Text 80x60, 8x8, complete }\r
+(  80,  59,   8,  0, 38  ,   1,   3,   0,   2,  227,\r
+  95, 79, 80,130, 85,129, 11, 62,  0, 71,  6,  7,  0,  0,  0,\r
+   0,234,172,223, 40, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 51, Text 80x60, 9x8, complete }\r
+(  80,  59,   8,  0, 38  ,   0,   3,   0,   2,  231,\r
+  95, 79, 80,130, 85,129, 11, 62,  0, 71,  6,  7,  0,  0,  0,\r
+   0,234,172,223, 40, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  8,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255),\r
+\r
+{ 52, Text 90x60, 8x8, complete }\r
+(  90,  59,   8,128, 42  ,   1,   3,   0,   2,  231,\r
+ 107, 89, 90,142, 95,138, 11, 62,  0, 71,  6,  7,  0,  0,  0,\r
+   0,234,172,223, 45, 31,231,  6,163,255,  0,  1,  2,  3,  4,\r
+   5, 20,  7, 56, 57, 58, 59, 60, 61, 62, 63,  8,  0, 15,  0,\r
+    0,   0,   0,   0,   0,  16,  14,   0, 255)\r
+\r
+);\r
+\r
+begin\r
+  asm\r
+        movzx   eax,vmode\r
+        shl     eax,6\r
+        lea     esi,[vmode_data]\r
+        add     esi,eax\r
+        mov     dx,3cch\r
+        in      al,dx\r
+        mov     dl,0d4h\r
+        test    al,1\r
+        jnz     @@1\r
+        mov     dl,0b4h\r
+  @@1:  add     dx,6\r
+        in      al,dx\r
+        xor     al,al\r
+        mov     dx,3c0h\r
+        out     dx,al\r
+        mov     ax,100h\r
+        mov     dx,3c4h\r
+        out     dx,ax\r
+        add     esi,5\r
+        mov     ecx,4\r
+        mov     al,1\r
+        mov     dx,3c4h\r
+  @@2:  mov     ah,[esi]\r
+        inc     esi\r
+        out     dx,ax\r
+        inc     al\r
+        loop    @@2\r
+        mov     al,[esi]\r
+        inc     esi\r
+        mov     dx,3c2h\r
+        out     dx,al\r
+        mov     dx,3c4h\r
+        mov     ax,300h\r
+        out     dx,ax\r
+        mov     dx,3cch\r
+        in      al,dx\r
+        mov     dl,0d4h\r
+        test    al,1\r
+        jnz     @@3\r
+        mov     dl,0b4h\r
+  @@3:  movzx   edi,SEG0040\r
+        shl     edi,4\r
+        add     edi,63h\r
+        shl     edi,4\r
+        mov     [edi],dx\r
+        mov     al,11h\r
+        out     dx,al\r
+        inc     dx\r
+        mov     ah,al\r
+        in      al,dx\r
+        dec     dx\r
+        xchg    al,ah\r
+        and     ah,7fh\r
+        out     dx,ax\r
+        mov     ecx,25\r
+        xor     al,al\r
+  @@4:  mov     ah,[esi]\r
+        inc     esi\r
+        out     dx,ax\r
+        inc     al\r
+        loop    @@4\r
+        add     dx,6\r
+        in      al,dx\r
+        xor     ah,ah\r
+        mov     ecx,20\r
+        mov     dx,3c0h\r
+  @@5:  mov     al,ah\r
+        out     dx,al\r
+        inc     ah\r
+        mov     al,[esi]\r
+        inc     esi\r
+        out     dx,al\r
+        loop    @@5\r
+        xor     al,al\r
+        mov     ecx,9\r
+        mov     dx,3ceh\r
+  @@6:  mov     ah,[esi]\r
+        inc     esi\r
+        out     dx,ax\r
+        inc     al\r
+        loop    @@6\r
+        mov     dx,3c0h\r
+        mov     al,32\r
+        out     dx,al\r
+  end;\r
+\r
+  MEM[SEG0040:$4a] := vmode_data[vmode,0];\r
+  MEM[SEG0040:$84] := vmode_data[vmode,1];\r
+  MEM[SEG0040:$85] := vmode_data[vmode,2];\r
+  MEM[SEG0040:$4c] := vmode_data[vmode,3];\r
+  MEM[SEG0040:$4d] := vmode_data[vmode,4];\r
+  FillChar(MEM[SEG0040:$4e],17,0);\r
+\r
+  MEM[SEG0040:$60] := vmode_data[vmode,20];\r
+  MEM[SEG0040:$61] := vmode_data[vmode,21];\r
+  MEM[SEG0040:$62] := 0;\r
+\r
+  Case vmode_data[vmode,2] of\r
+     8: asm mov ah,11h; mov al,2; xor bx,bx; int 10h end;\r
+    14: asm mov ah,11h; mov al,1; xor bx,bx; int 10h end;\r
+    16: asm mov ah,11h; mov al,4; xor bx,bx; int 10h end;\r
+  end;\r
+\r
+  initialize;\r
+  CleanScreen(Ptr(v_seg,v_ofs)^);\r
+end;\r
+\r
+begin\r
+  initialize;\r
+end.\r