;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
; screen capture code
;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
 


do_screenshot   proc near

        push    ax
        push    bx
        push    cx
        push    dx
        push    ds


        ; open target file

        lea     dx, my_file
        mov     al, 1
        mov     cx, ARCHIVE
        mov     ah, 3ch
        int     21h
        ;jc     open error

        mov     bx, ax
        ; point ds:dx to data

        mov     dx, 0b800h
        mov     ds, dx
        xor     dx, dx
        mov     cx, 16*1024             ; write 16k of data

        mov     ah, 40h
        int     21h

        mov     ah, 3eh
        int     21h
        pop     ds

        call    updatefilename

        pop     dx
        pop     cx
        pop     bx
        pop     ax

        ; clear out screenshot flag
        and     byte ptr cs:[flags],NOT SCREENSHOT
        ret
my_file db      "image00.cga",0

do_screenshot   endp

updatefilename proc near

        ; create new filename
        lea     bx, my_file
        add     bx, 6
        cmp     byte ptr ds:[bx],"9"
        jz      add10
        inc     byte ptr ds:[bx]
        jmp     filenamedone

add10:
        dec     bx
        cmp     byte ptr ds:[bx],"9"           ; are we at 99? (jesus christ!)
        jz      filenamedone                   ; bail, overwrite at 99

        mov     byte ptr ds:[bx+1], "0"         ; reset one's back to 0
        inc     byte ptr ds:[bx]                ; inc 10's

filenamedone:
        ret
updatefilename endp


savescreen      proc near


        push    ax
        push    bx
        push    cx
        push    dx

        push    si
        push    di
        push    es
        push    ds


        push    cs
        pop     es
        lea     di, endflag                     ; tuck data at end of flopper

        push    0B800h
        pop     ds

        xor     si,si

        mov     cx, 16*1024
        cli
        rep     movsb
        sti


        pop     ds
        pop     es
        pop     di
        pop     si

        pop     dx
        pop     cx
        pop     bx
        pop     ax
        ret
savescreen      endp

restorescreen      proc near


        push    ax
        push    bx
        push    cx
        push    dx

        push    si
        push    di
        push    es
        push    ds


        push    cs
        pop     ds
        lea     si, endflag                     ; grab data from end of flopper

        push    0B800h
        pop     es

        xor     di,di

        mov     cx, 16*1024
        cli
        rep     movsb
        sti


        pop     ds
        pop     es
        pop     di
        pop     si

        pop     dx
        pop     cx
        pop     bx
        pop     ax

        ret
restorescreen      endp

