;old flopper crap that I probably will not use anytime soon.



if F12 eq 1

;new INT 15 fn 4F code

        
new_i15_vector:           ;this will sit at 9f30:0  
        jmp overi15data   ; this is 3 bytes long


        i15off     dw 1122h       ;address of "real" int 15
        i15seg     dw 3344h
        screenshot db 2           ;number of screenshots so far


write_screenshot proc
;input: ES:BX=pointer to screen data
;       

        pusha


        mov ax,0                ; reset drive
        mov dx,0
        pushf
        call dword ptr cs:[NI13OFF+3]   ; call re-vectored INT 13


write_loop:

        mov ax,0308h            ; write 8 sectors
        mov cl,1                ; starting sector #
        mov dh,0                ; head 0
        mov dl,0                ; drive A:
        mov ch, cs:[NI15OFF+7]

        pushf
        call dword ptr cs:[NI13OFF+3]   ; call re-vectored INT 13


        ; do next 4k to side 1 same track

        mov ax,0308h
        add bx,8*512
        mov dh,1

        pushf
        call dword ptr cs:[NI13OFF+3]   ; call re-vectored INT 13

        inc byte ptr cs:[NI15OFF+7]     ; next track

        cmp bp,1
        jz finished_screenshot

        add bx,8*512
        mov bp,1                        ; set flag

        jmp write_loop

finished_screenshot:

        popa
        ret

write_screenshot endp














overi15data:

        pushf                         ;ok, do INT15 functions
        call dword ptr cs:ni15off+3   ;

        pushf
        cmp     al,SCAN_CODE
        jnz skipi15
        popf

       ; signal end of interrupt
       sti
       push ax
       mov al,20h
       out 20h,al
       jmp $+2
       jmp $+2
       out 0a0h,al
       jmp $+2
       jmp $+2
       pop ax
              

        ; screenshot time!


        ; check to see if we have done the maximum screenshots/session
        cmp byte ptr cs:[Ni15OFF+7],79
        ja skipi15

        ; grab mode/pallette byte from 40:65 and copy to b800:3fff

        push es
        push ds
        push si
        push di

        mov si,40h
        mov ds,si
        mov si,65h

        mov di,0b800h
        mov es,di
        mov di,3fffh

        movsb

        pop di
        pop si
        pop ds
        pop es




        ; copy screen data to temporary memory spot
        ; for some reason I can't write data directly from video memory.
        ; Need to re-test/verify this.



        push dx
        push ds
        push si
        push bx
        push di
        push es


        mov dx,0b800h
        mov ds,dx

        xor si,si 

         ;copy 16k of data to temporary storage at 8000:0
         ; id rather not have to do this.


                mov di,8000h       ; 
                mov cx,16*1024
                push cs
                pop es
                rep movsb

        mov bx,8000h          ;  lea bx,endflag


        call write_screenshot

        pop es
        pop di
        pop bx
        pop si
        pop ds
        pop dx
        
        iret

skipi15:
        popf                          ;restore flags
        iret
endi15vectordata:

endif


%

comment %

        ;copy our int 13h code just below 640k.


        push es
        push ds

        push cs
        pop ds

        lea di,endI13vectordata
        lea si,new_i13_vector
        sub di,si
        mov cx,di
        mov ax,ni13seg
        mov es,ax
        mov di,ni13off
        rep movsb



if F12 eq 1

                ;copy int 15 code into 1k area



        lea di,endi15vectordata
        lea si,new_i15_vector
        sub di,si
        mov cx,di
        mov ax,ni15seg
        mov es,ax
        mov di,ni15off
        rep movsb
        
endif


        pop ds
        pop es


                ;revector int 13h
                ;can't use int 21 anymore!!!



        mov bx,0
        mov es,bx
        mov bx,13h*4
        mov dx,word ptr es:[bx]
        mov cx,word ptr es:[bx+2]



        push ds
        push ni13seg


        pop ds
        
        push bp
        mov bp,ni13off
        mov ds:[bp+5],cx
        mov ds:[bp+3],dx
        pop bp

        pop ds



        ;set up new vector

        mov dx,ni13seg                ;load dx with the new routine
        mov cx,ni13off
        mov bx,13h*4
        mov word ptr es:[bx],cx
        mov word ptr es:[bx+2],dx



if F12 eq 1
                ;revector int 15h
                ;can't use int 21 anymore!!!



        mov bx,0
        mov es,bx
        mov bx,15h*4
        mov dx,word ptr es:[bx]
        mov cx,word ptr es:[bx+2]



        push ds
        push ni15seg


        pop ds
        
        push bp
        mov bp,ni15off
        mov ds:[bp+5],cx
        mov ds:[bp+3],dx
        pop bp

        pop ds



        ;set up new vector

        mov dx,ni15seg                ;load dx with the new routine
        mov cx,ni15off
        mov bx,15h*4
        mov word ptr es:[bx],cx
        mov word ptr es:[bx+2],dx

endif

%
