The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: didar_nice on May 24, 2011, 02:12:32 PM

Title: save entire screen
Post by: didar_nice on May 24, 2011, 02:12:32 PM
hello. i need to write a code that can save entire screen(80*25) to a file(the screen filled by some words by the user like a notepad) . actually i dont know how to put rows and columns to a 80*25 array or should do something else for that buffer variable and then put that variable to DX for save file. can any one help me please?
Title: Re: save entire screen
Post by: dedndave on May 24, 2011, 04:56:32 PM
the screen buffer resides at 0B800h
each character takes 2 bytes - one for the char and one for the attribute byte
the fastest way is to read it directly from the buffer

if you only want the characters, you need 80x25 = 2000 bytes
you may want to add carriage return/line feed pairs to the end of each line
it depends on what you intend to do with the data

if you just want the characters, something like this should work
        .DATA?

ScnBuf  db 2000 dup(?)

        .CODE

        mov     ax,@DATA
        mov     es,ax
        mov     ax,0B800h
        mov     ds,ax
        xor     si,si
        mov     di,offset ScnBuf
        mov     cx,2000

RdLoop: mov     al,[si]
        stosb
        add     si,2
        loop    RdLoop

        push    es
        pop     ds
Title: Re: save entire screen
Post by: FORTRANS on May 24, 2011, 06:19:52 PM
Hi,

   Look for the Snipper utility from PC Magazine.  Using it may
give you some ideas.  Version 2.6 was written by Tom Kihlken
in 1987.  A variation on Dave's code below with chages in
uppercase.

Regards,

Steve


        .DATA?

ScnBuf  db 2000 dup(?)

        .CODE

        PUSH    ES
        mov     ax,@DATA
        mov     es,ax
        mov     ax,0B800h
        mov     ds,ax
        xor     si,si
        mov     di,offset ScnBuf
        mov     cx,2000

RdLoop:
        LODSW
        stosb
        loop    RdLoop

        push    es
        pop     ds
        POP     ES
Title: Re: save entire screen
Post by: didar_nice on May 24, 2011, 11:00:55 PM
ok thanks a lot guys:) i should try those