/* myscr2.c
1. Example of window scrolling routines with keyboard IO.
*/
        #include <stdio.h>
        void screen( void );
        void scroll( void );
        void get_char( void );

        char char_in;    /*/ variable defs */
        unsigned char row, col, row_up, row_down, col_up, col_down;
        char MYMSG[]="minha terra tem palmeiras onde canta o sabia$";
        char ** MYPMSG=MYMSG;
        void main()
        {
          row = 0;
          col = 0;
          row_up   = 3;    /*/ define a 10 line by 40 col */
          row_down = 13;   /*/ window for scrolling*/
          col_up   = 20;
          col_down = 60;
          screen();        /*/ erase the screen */
          scroll();        /*/ scroll the screen */
          get_char();      /*/ get char to terminate..*/
        }

        void screen()
        {
             asm  mov cx,50h       /* 80 interations */
        
        disp_loop:
              asm  mov ah,02h     /* cursor position */
              asm  mov bh,00h      /* BIOS call */
              asm mov dh,row
              asm and dh,1Fh     /* limit 32 lines */
              asm mov row,dh     /* restore row value */
              asm mov dl,col
              asm int 10h
              asm inc row        /* incr row,col ptrs */
              asm inc col    
              asm mov ah,09h     /* DOS char output */
              asm mov dx,MYPMSG     /* output the X char */
              asm int 21h
              asm loop disp_loop /* loop until done */
           
        }

        /*/ ............................................  */

        void scroll()
        { 
          asm mov ah,06h       /* BIOS scroll function */
          asm mov al,10h       /* 16 lines */
          asm mov bh,07h
          asm mov ch,row_up    /* set window limits */
          asm mov cl,col_up
          asm mov dh,row_down
          asm mov dl,col_down
          asm int 10h
          
        }

        /* / ............................................*/

        void get_char()
        { 
          asm mov ah,02h    /* cursor pos BIOS call */
          asm mov bh,00h
          asm mov dh,06d
          asm mov dl,25d
          asm int 10h
          asm mov ah,02h    /* DOS char output call */
          asm mov dl,'?'
          asm int 21h
          asm mov ah,01h    /* keyboard in, no echo */
          asm int 21h

        }
