; FLIP.COM  by K. S. Hunziker
; See PC Mag V4 No.4 p256
; Switches between page 0 and page 1 of the color/graphics display
; in text mode.  Note that some "end run" programs always write to
; page 0 rather than the active page.
code_seg    segment
            assume cs:code_seg
            org 100h
begin:      mov ah,15      ; read video state (call to BIOS)
            int 10h
            and bh,1       ; make sure we deal only with 0 or 1
            xor bh,1       ; switch to other page
            mov bl,bh      ; save new page number
            mov al,bh      ; set new active page (call to BIOS)
            mov ah,5
            int 10h
            mov dh,22      ; set cursor to row 22
            mov dl,0       ;   and column 0
            mov ah,2       ; set cursor position (call to BIOS)
            int 10h
            mov ch,6       ; assume page 0, begin cursor at 6
            mov cl,7       ; end cursor at line 7
            or  bh,bh      ; check new page number
            jz  is_zero    ; if new page is 0, we guessed right
            mov ch,0       ; cursor begins at line 0
is_zero:    mov ah,1       ; set cursor type (call to BIOS)
            int 10h
            mov ch,23      ; set upper left of window to row 23
            mov cl,0       ;   and column 0
            mov dh,24      ; set lower right of window to row 24
            mov dl,79      ;   and column 79
            mov al,0       ; blank the window
            mov bh,7       ; use white on black
            mov ah,6       ; perform window scroll (call to BIOS)
            int 10h
            mov al,bl      ; supply new page number as return code
            mov ah,4ch     ; exit to DOS
            int 21h
code_seg    ends
            end  begin
