⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 console.c

📁 包括文件操作、图形系统、并口串口编程、鼠标编程、小型cad系统、编译器、病毒防火墙、海底大战等多个实例。
💻 C
📖 第 1 页 / 共 2 页
字号:
        mov     al, EOL_CHAR    
        mov     ah, dl          
        cmp     cl, bl          
        jl      ch_out2         
        cmp     cl, bh          
        jg      ch_out2         
        mov     ah, dh          
   }
ch_out2:

   ASSEMBLE {
        stosw                   
        inc     cl              
        cmp     cl, ch          
        je      getout          
   }
block_eol:

   ASSEMBLE {
        mov     al, ' '          spaces */
   }
b1:

   ASSEMBLE {
        mov     ah, dl          
        cmp     cl, bl          
        jl      ch_out3         
        cmp     cl, bh          
        jg      ch_out3         
        mov     ah, dh          
   }
ch_out3:

   ASSEMBLE {
        stosw                   
        inc     cl              
        cmp     cl, ch          
        jl      b1              
   }
getout:

   ASSEMBLE {
        pop     di
        pop     si
        pop     ds
      }


   } else if (block_line == TRUE && file->block_type == STREAM &&
              (rline == file->block_br || rline == file->block_er)) {
      if (rline == file->block_br)
         bc = file->block_bc;
      else {
         bc = file->block_ec + 1;
         ec = normal;
         normal = block;
         block = ec;
      }
      if (bc < bcol)
         bc = 0;
      else if (bc < bcol + max_col)
         bc = bc - bcol;
      else
         bc = max_col + 1;


   ASSEMBLE {
      
        push    ds                      
        push    si                      
        push    di                      


        mov     ax, WORD PTR bc         
        mov     bl, al                  
        mov     ax, WORD PTR len        
        mov     bh, al                  
        mov     ax, WORD PTR normal     
        mov     dl, al                  
        mov     ax, WORD PTR block      
        mov     dh, al                  
        mov     ax, WORD PTR max_col    
        mov     ch, al                  
        xor     cl, cl                  

        mov     di, WORD PTR screen_ptr         
        add     di, WORD PTR off                
        mov     ax, WORD PTR screen_ptr+2       
        mov     es, ax
        mov     si, WORD PTR text       
        mov     ax, WORD PTR text+2     
        mov     ds, ax                  
        cmp     si, 0                   
        jne     nott_null               
        cmp     ax, 0                   
        je      ddspl_eol               
   }
nott_null:

   ASSEMBLE {
        cmp     cl, ch          
        je      ggetout         
        cmp     cl, bh          
        je      ddspl_eol       
   }
ttop:

   ASSEMBLE {
        lodsb                   
        mov     ah, dl          
        cmp     cl, bl          
        jl      str_out1        
        mov     ah, dh          
   }
str_out1:

   ASSEMBLE {
        stosw                   
        inc     cl              
        cmp     cl, ch          
        je      ggetout         
        cmp     cl, bh          
        jl      ttop            
   }
ddspl_eol:

   ASSEMBLE {
        cmp     WORD PTR show_eol, FALSE        
        je      stream_eol      
        mov     al, EOL_CHAR    
        mov     ah, dl          
        cmp     cl, bl          
        jl      str_out2        
        mov     ah, dh          
   }
str_out2:

   ASSEMBLE {
        stosw                   
        inc     cl              
        cmp     cl, ch          
        jge     ggetout         
   }
stream_eol:

   ASSEMBLE {
        mov     al, ' '          spaces */
   }
c1:

   ASSEMBLE {
        mov     ah, dl          
        cmp     cl, bl          
        jl      str_out3        
        mov     ah, dh          
   }
str_out3:

   ASSEMBLE {
        stosw                   
        inc     cl              
        cmp     cl, ch          
        jl      c1              
   }
ggetout:

   ASSEMBLE {
        pop     di
        pop     si
        pop     ds
      }


   } else {
      if (block_line)
         attr = block;
      else
         attr = normal;

      assert( len >= 0 );
      assert( len <= MAX_COLS );

   ASSEMBLE {
  
        mov     dx, ds          
        push    di              
        push    si              


        mov     bx, WORD PTR attr               
        mov     ax, WORD PTR len                
        mov     bh, al                          
        mov     cx, WORD PTR max_col            
        mov     ch, cl                          
        xor     cl, cl                          
        mov     di, WORD PTR screen_ptr         
        add     di, WORD PTR off                
        mov     ax, WORD PTR screen_ptr+2       
        mov     es, ax
        mov     si, WORD PTR text       
        mov     ax, WORD PTR text+2     
        mov     ds, ax                  
        cmp     si, 0                   
        jne     nnot_null               
        cmp     ax, 0                   
        je      normeol                 
   }
nnot_null:

   ASSEMBLE {
        mov     ah, bl                  
        cmp     cl, ch          
        jge     getoutt         
        cmp     cl, bh          
        je      normeol         
   }
topp:

   ASSEMBLE {
        lodsb                   
        stosw                   
        inc     cl              
        cmp     cl, ch          
        jge     getoutt         
        cmp     cl, bh          
        jl      topp            
   }
normeol:

   ASSEMBLE {
        cmp     WORD PTR show_eol, FALSE        
        je      clreol          
        mov     al, EOL_CHAR    
        mov     ah, bl          
        stosw                   
        inc     cl              
        cmp     cl, ch          
        jge     getoutt         
   }
clreol:

   ASSEMBLE {
        mov     ah, bl          
        mov     al, ' '         
        sub     ch, cl          
        mov     cl, ch          
        xor     ch, ch          
        rep     stosw           
   }
getoutt:

   ASSEMBLE {
        pop     si
        pop     di
        mov     ds, dx
      }


   }
}



void c_output( int c, int col, int line, int attr )
{
void far *screen_ptr;
int  off;

   screen_ptr = (void far *)g_display.display_address;
   off = line * 160 + col * 2;

   ASSEMBLE {
        mov     bx, WORD PTR screen_ptr         
        add     bx, WORD PTR off                
        mov     ax, WORD PTR screen_ptr+2       
        mov     es, ax
        mov     cx, WORD PTR attr       
        mov     ah, cl                  
        mov     cx, WORD PTR c          
        mov     al, cl                  
        mov     WORD PTR es:[bx], ax    
   }


}



void s_output( char far *s, int line, int col, int attr )
{
void far *screen_ptr;
int  off;
int  max_col;

   max_col = g_display.ncols;
   screen_ptr = (void far *)g_display.display_address;
   off = line * 160 + col * 2;

   ASSEMBLE {
        push    ds              
        push    di              
        push    si              

        mov     bx, WORD PTR attr               
        mov     cx, WORD PTR col                
        mov     dx, WORD PTR max_col            
        mov     di, WORD PTR screen_ptr         
        add     di, WORD PTR off                
        mov     ax, WORD PTR screen_ptr+2       
        mov     es, ax
        mov     si, WORD PTR s  
        or      si, si          
        je      getout          
        mov     ax, WORD PTR s+2        
        or      ax, ax          
        je      getout          
        mov     ds, ax          
        mov     ah, bl          
   }
top:

   ASSEMBLE {
        cmp     cx, dx          
        jge     getout          
        lodsb                   
        or      al, al          
        je      getout          
        cmp     al, 0x0a        
        je      getout          
        stosw                   
        inc     cx              
        jmp     SHORT top       
   }
getout:

   ASSEMBLE {
        pop     si              
        pop     di              
        pop     ds              
   }

/
}



void eol_clear( int col, int line, int attr )
{
int  max_col;
void far *screen_ptr;
int  off;

   max_col = g_display.ncols;
   screen_ptr = (void far *)g_display.display_address;
   off = line * 160 + col * 2;

   ASSEMBLE {
        push    di                              

        mov     bx, WORD PTR attr               
        mov     dx, WORD PTR col                
        mov     cx, WORD PTR max_col            
        cmp     dx, cx                          
        jge     getout                          
        sub     cx, dx                          
        mov     di, WORD PTR screen_ptr         
        add     di, WORD PTR off                
        mov     ax, WORD PTR screen_ptr+2       
        mov     es, ax
        mov     ah, bl                          
        mov     al, ' '                         
        rep     stosw                           
   }
getout:

   ASSEMBLE {
        pop     di                              
   }


void window_eol_clear( WINDOW *window, int attr )
{
int  max_col;
void far *screen_ptr;
int  off;

   if (!g_status.screen_display)
      return;
   screen_ptr = (void far *)g_display.display_address;
   off = window->cline * 160 + window->start_col * 2;
   max_col = window->end_col + 1 - window->start_col;

   ASSEMBLE {
        push    di                              

        mov     bx, WORD PTR attr               
        mov     cx, WORD PTR max_col            
        mov     di, WORD PTR screen_ptr         
        add     di, WORD PTR off                
        mov     ax, WORD PTR screen_ptr+2       
        mov     es, ax
        mov     ah, bl                          
        mov     al, ' '                         
        rep     stosw                           

        pop     di                              
   }


}



void hlight_line( int x, int y, int lgth, int attr )
{
int  off;
void far *screen_ptr;

   screen_ptr = (void far *)g_display.display_address;
   off = y * 160 + 2 * x + 1;  

   ASSEMBLE {
        push    di              

        mov     cx, lgth        

        mov     di, WORD PTR screen_ptr 
        add     di, off                 
        mov     ax, WORD PTR screen_ptr+2
        mov     es, ax
        mov     ax, attr        
   }
lite_len:

   ASSEMBLE {
        stosb                   
        inc     di              
        loop    lite_len        
        pop     di              
   }
}



void cls( void )
{
int  line;

     line = g_display.nlines + 1;

   ASSEMBLE {
        xor     ch, ch                  
        xor     cl, cl                  
        mov     ax, WORD PTR line       
        mov     dh, al                  
        mov     dl, 79                  
        mov     bh, 7                   
        mov     al, 0                   
        mov     ah, 6                   
        push    bp                      
        int     0x10
        pop     bp
   }
}



void set_cursor_size( int csize )
{
   ASSEMBLE {
        mov     ah, 1                   
        mov     cx, WORD PTR csize      
        push    bp
        int     VIDEO_INT               
        pop     bp
   }
}



void set_overscan_color( int color )
{
   ASSEMBLE {
        mov     ah, 0x0b                
        mov     bl, BYTE PTR color      
        xor     bh, bh
        push    bp
        int     VIDEO_INT               
        pop     bp
   }
}



void save_screen_line( int col, int line, char *screen_buffer )
{
char far *p;

   p = g_display.display_address + line * 160 + col * 2;
   _fmemcpy( screen_buffer, p, 160 );
}



void restore_screen_line( int col, int line, char *screen_buffer )
{
char far *p;

   p = g_display.display_address + line * 160 + col * 2;
   _fmemcpy( p, screen_buffer, 160 );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -