⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 copyvid.inc

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 INC
📖 第 1 页 / 共 5 页
字号:
    dec ecx
    jnz .abh
    add edi,64*2
    mov ecx,128
    sub esi,256
.abh2
    mov al,[esi+1]
    mov bx,[GUICPC+eax*2]
    mov al,[esi]
    shl ebx,16
    mov bx,[GUICPC+eax*2]
    and ebx,[vesa2_clbitng2]
    shr ebx,1
    mov [es:edi],ebx
    add esi,2
    add edi,4
    dec ecx
    jnz .abh2
    add esi,32
    add edi,64*2
    dec dl
    jnz .loopabh
    pop es
    ret

.quarterscanlines
.loopabhq
    mov ecx,256
    xor eax,eax
.abhq
    mov al,[esi]
    mov bx,[GUICPC+eax*2]
    mov [es:edi],bx
    inc esi
    add edi,2
    dec ecx
    jnz .abhq
    add edi,64*2
    mov ecx,128
    sub esi,256
.abh2q
    mov al,[esi+1]
    mov bx,[GUICPC+eax*2]
    mov al,[esi]
    shl ebx,16
    mov bx,[GUICPC+eax*2]
    and ebx,[vesa2_clbitng2]
    shr ebx,1
    mov eax,ebx
    and eax,[vesa2_clbitng2]
    shr eax,1
    add ebx,eax
    mov [es:edi],ebx
    xor eax,eax
    add esi,2
    add edi,4
    dec ecx
    jnz .abh2q
    add esi,32
    add edi,64*2
    dec dl
    jnz .loopabhq
    pop es
    ret
%endif

NEWSYM ConvertToAFormat
    cmp byte[GUIOn],1
    je .nonewgfx
    cmp byte[newengen],0
    je .nonewgfx
    ret
.nonewgfx
    mov eax,[vesa2_clbitng2]
    mov ebx,eax
    and eax,11111111110000001111111111000000b
    and ebx,00000000000111110000000000011111b
    or eax,ebx
    mov [vesavaland],eax
    mov [vesavaland+4],eax
    mov esi,[vidbuffer]
    add esi,16*2+256*2+32*2
    mov dl,[resolutn]
    dec dl
    dec dl
    cmp byte[FPUCopy],2
    je near .mmxconv
.crgbloop
    mov ecx,128
.crgbloop2
    mov eax,[esi]
    mov ebx,eax
    and eax,11111111110000001111111111000000b
    and ebx,00000000000111110000000000011111b
    shr eax,1
    or ebx,eax
    mov [esi],ebx
    add esi,4
    loop .crgbloop2
    add esi,64
    dec dl
    jnz .crgbloop
    jmp .nocopyvesa2r
.mmxconv
.crgbloopm
    mov ecx,64
    movq mm6,[mmxvalanda]
    movq mm7,[mmxvalandb]
.crgbloop2m
    movq mm0,[esi]
    movq mm1,mm0
    pand mm0,mm6
    pand mm1,mm7
    psrlw mm0,1
    por mm0,mm1
    movq [esi],mm0
    add esi,8
    loop .crgbloop2m
    add esi,64
    dec dl
    jnz .crgbloopm
    emms
.nocopyvesa2r
    ret

NEWSYM UnConvertToAFormat
    mov esi,[vidbuffer]
    add esi,16*2+256*2+32*2
    mov dl,[resolutn]
    dec dl
    dec dl
.crgbloop
    mov ecx,128
.crgbloop2
    mov eax,[esi]
    mov ebx,eax
    and eax,01111111111000000111111111100000b
    and ebx,00000000000111110000000000011111b
    shl eax,1
    or ebx,eax
    mov [esi],ebx
    add esi,4
    loop .crgbloop2
    add esi,64
    dec dl
    jnz .crgbloop
    ret

%ifdef __MSDOS__
NEWSYM copyvesa2320x480x16b
    cmp byte[curblank],40h
    jne .startcopy
    ret
.startcopy
    mov eax,[vesa2_clbitng2]
    mov [vesavaland],eax
    mov [vesavaland+4],eax
    cmp byte[vesa2red10],1
    jne .nocopyvesa2r
    call ConvertToAFormat
.nocopyvesa2r
    push es
    mov ax,[vesa2selec]
    mov es,ax
    mov esi,[vidbuffer]
    mov edi,32*2           ; Draw @ Y from 9 to 247
    cmp word[resolutn],224
    jne .res239
    mov edi,8*320*2+32*2
.res239
    add edi,[VidStartDraw]
    add esi,16*2+256*2+32*2
    xor eax,eax
    mov dl,[resolutn]
    dec dl
    dec dl
    cmp byte[scanlines],1
    je near .scanlines
    cmp byte[scanlines],3
    je near .halfscanlines
    cmp byte[scanlines],2
    je near .quartscanlines
.loopa
    mov ecx,128
    cmp byte[FPUCopy],2
    je near .mmx
    rep movsd
    sub esi,256*2
    add edi,64*2
    mov ecx,128
    rep movsd
.return
    add esi,64
    add edi,64*2
    inc ebx
    dec dl
    jnz .loopa
    pop es
    cmp byte[FPUCopy],2
    je .mmx2
    ret
.mmx2
    emms
    ret
.mmx
    mov ecx,32
.mmxr
    movq mm0,[esi]
    movq mm1,[esi+8]
    movq [es:edi],mm0
    movq [es:edi+8],mm1
    add esi,16
    add edi,16
    dec ecx
    jnz .mmxr
    sub esi,16*32
    add edi,64*2
    mov ecx,32
.mmxr2
    movq mm0,[esi]
    movq mm1,[esi+8]
    movq [es:edi],mm0
    movq [es:edi+8],mm1
    add esi,16
    add edi,16
    dec ecx
    jnz .mmxr2
    jmp .return

.scanlines
.loopab
    mov ecx,128
    cmp byte[FPUCopy],2
    je near .mmxsl
.ab
    mov eax,[esi]
    mov [es:edi],eax
    add esi,4
    add edi,4
    dec ecx
    jnz .ab
.returnb
    add esi,64
    add edi,64*2+320*2
    inc ebx
    dec dl
    jnz .loopab
    pop es
    cmp byte[FPUCopy],2
    je near .mmx2
    ret
.mmxsl
    mov ecx,32
.mmxrsl
    movq mm0,[esi]
    movq mm1,[esi+8]
    movq [es:edi],mm0
    movq [es:edi+8],mm1
    add esi,16
    add edi,16
    dec ecx
    jnz .mmxrsl
    jmp .returnb

.halfscanlines
.loopabh
    cmp byte[FPUCopy],2
    je near .mmxslh
    mov ecx,128
.abh
    mov eax,[esi]
    mov [es:edi],eax
    add esi,4
    add edi,4
    dec ecx
    jnz .abh
    mov ecx,128
    sub esi,512
    add edi,64*2
.abhs
    mov eax,[esi]
    and eax,[vesavaland]
    shr eax,1
    mov [es:edi],eax
    add esi,4
    add edi,4
    dec ecx
    jnz .abhs
.returnbh
    add esi,64
    add edi,64*2
    inc ebx
    dec dl
    jnz .loopabh
    pop es
    cmp byte[FPUCopy],2
    je near .mmx2
    ret
.mmxslh
    mov ecx,32
    add eax,512
.mmxrslh
    movq mm0,[esi]
    movq mm1,[esi+8]
    movq [es:edi],mm0
    movq [es:edi+8],mm1
    add esi,16
    add edi,16
    dec ecx
    jnz .mmxrslh
    mov ecx,16
    sub esi,512
    add eax,512
    add edi,64*2
    movq mm4,[vesavaland]
.mmxr2h
    movq mm0,[esi]
    movq mm1,[esi+8]
    movq mm2,[esi+16]
    movq mm3,[esi+24]
    pand mm0,mm4
    pand mm1,mm4
    pand mm2,mm4
    pand mm3,mm4
    psrlw mm0,1
    psrlw mm1,1
    psrlw mm2,1
    psrlw mm3,1
    movq [es:edi],mm0
    movq [es:edi+8],mm1
    movq [es:edi+16],mm2
    movq [es:edi+24],mm3
    add esi,32
    add edi,32
    dec ecx
    jnz .mmxr2h
    jmp .returnbh

.quartscanlines
    mov [lineleft],dl
.loopabh2
    cmp byte[FPUCopy],2
    je near .mmxslh2
    mov ecx,128
.abh2
    mov eax,[esi]
    mov [es:edi],eax
    add esi,4
    add edi,4
    dec ecx
    jnz .abh2
    mov ecx,128
    sub esi,512
    add edi,64*2
.abhs2
    mov eax,[esi]
    and eax,[vesavaland]
    shr eax,1
    mov edx,eax
    and edx,[vesavaland]
    shr edx,1
    add eax,edx
    mov [es:edi],eax
    add esi,4
    add edi,4
    dec ecx
    jnz .abhs2
.returnbh2
    add esi,64
    add edi,64*2
    inc ebx
    dec byte[lineleft]
    jnz near .loopabh2
    pop es
    cmp byte[FPUCopy],2
    je near .mmx2
    ret
.mmxslh2
    mov ecx,32
    add eax,512
.mmxrslh2
    movq mm0,[esi]
    movq mm1,[esi+8]
    movq [es:edi],mm0
    movq [es:edi+8],mm1
    add esi,16
    add edi,16
    dec ecx
    jnz .mmxrslh2
    mov ecx,32
    sub esi,512
    add edi,64*2
    movq mm4,[vesavaland]
.mmxr2h2
    movq mm0,[esi]
    movq mm1,[esi+8]
    pand mm0,mm4
    pand mm1,mm4
    psrlw mm0,1
    psrlw mm1,1
    movq mm2,mm0
    movq mm3,mm1
    pand mm2,mm4
    pand mm3,mm4
    psrlw mm2,1
    psrlw mm3,1
    paddd mm0,mm2
    paddd mm1,mm3
    movq [es:edi],mm0
    movq [es:edi+8],mm1
    add esi,16
    add edi,16
    dec ecx
    jnz .mmxr2h2
    jmp .returnbh2

;*******************************************************
; Copy VESA2 640x480x16b Copies buffer to 640x480x16bVB2
;*******************************************************

%macro copya640x480 0
    mov [es:edi],dx
    mov [es:edi+2],dx
    mov [es:edi+640*2],dx
    mov [es:edi+640*2+2],dx
%endmacro

%macro copyb640x480 0
    mov [es:edi+4],dx
    mov [es:edi+6],dx
    mov [es:edi+640*2+4],dx
    mov [es:edi+640*2+6],dx
%endmacro

%macro copya640x480sl 0
    mov [es:edi],dx
    mov [es:edi+2],dx
%endmacro

%macro copyb640x480sl 0
    mov [es:edi+4],dx
    mov [es:edi+6],dx
%endmacro

%macro precheckvesa12 1
    cmp edx,%1
    ja %%a
    mov ecx,edx
%%a
%endmacro

%macro postcheckvesa12 4
    cmp edx,%3
    ja %%a
    call VESA12Bankswitch
    mov ecx,%3
    sub ecx,edx
    add edx,%4
    or ecx,ecx
    jz %%a
    jmp %1
%%a
    sub edx,%3
    sub edx,%2
    jg %%nobankswitch
    add edx,%4
    call VESA12Bankswitch
%%nobankswitch
%endmacro

NEWSYM copyvesa12640x480x16bgui
    cmp byte[curblank],40h
    jne .startcopy
    ret
.startcopy
    push es
    mov word[bankpos],0
    call VESA12Bankswitch
    mov ax,[selcA000]
    mov es,ax
    mov esi,[vidbuffer]
    mov edi,32*2*2           ; Draw @ Y from 9 to 247
    cmp word[resolutn],224
    jne .res239
    mov edi,8*320*2*2+32*2*2
.res239
    add esi,16+256+32
    xor eax,eax
    mov dl,[resolutn]
    dec dl
    dec dl
    mov [lineleft],dl
    mov edx,65536
    sub edx,edi
    shr edx,2
    cmp byte[smallscreenon],1
    je near .smallscreen
    cmp byte[scanlines],1
    je near .scanlines
.loopa
    mov ecx,256
    xor eax,eax
    precheckvesa12 256
.a
    mov al,[esi]
    mov bx,[GUICPC+eax*2]
    mov [es:edi],bx
    mov [es:edi+2],bx
    inc esi
    add edi,4
    dec ecx
    jnz .a
    postcheckvesa12 .a,64,256,16384
    sub esi,256
    add edi,128*2
    mov ecx,256
    xor eax,eax
    precheckvesa12 256
.a2
    mov al,[esi]
    mov bx,[GUICPC+eax*2]
    mov [es:edi],bx
    mov [es:edi+2],bx
    inc esi
    add edi,4
    dec ecx
    jnz .a2
    postcheckvesa12 .a2,64,256,16384
    add esi,32
    add edi,128*2
    dec byte[lineleft]
    jnz near .loopa
    pop es
    ret

.scanlines
.loopa2
    mov ecx,256
    xor eax,eax
    precheckvesa12 256
.ab
    mov al,[esi]
    mov bx,[GUICPC+eax*2]
    mov [es:edi],bx
    mov [es:edi+2],bx
    inc esi
    add edi,4
    dec ecx
    jnz .ab
    postcheckvesa12 .ab,64+320,256,16384
    add esi,32
    add edi,128*2+640*2
    dec byte[lineleft]
    jnz near .loopa2
    pop es
    ret

.smallscreen
    add edx,edx
.loopa3
    mov ecx,256
    xor eax,eax
    precheckvesa12 256
.ac
    mov al,[esi]
    mov bx,[GUICPC+eax*2]
    mov [es:edi],bx
    inc esi
    add edi,2
    dec ecx
    jnz .ac
    postcheckvesa12 .ac,128+256,256,32768
    add esi,32
    add edi,128*2+256*2
    dec byte[lineleft]
    jnz near .loopa3
    pop es
    ret


VESA12Bankswitch:
    pushad
    mov ax,4F05h
    mov bx,0
    mov dx,[bankpos]
    int 10h
    mov ax,[granadd]
    add word[bankpos],ax
    popad
    sub edi,65536
    ret

NEWSYM copyvesa2640x480x16bgui
    je near smallscreen640x480x16bgui.fullscreen
    cmp byte[curblank],40h
    jne .startcopy
    ret
.startcopy
    push es
    mov ax,[vesa2selec]
    mov es,ax
    mov esi,[vidbuffer]
    mov edi,32*2*2           ; Draw @ Y from 9 to 247
    cmp word[resolutn],224
    jne .res239
    mov edi,8*320*2*2+32*2*2
.res239
    add edi,[VidStartDraw]
    add esi,16+256+32
    xor eax,eax
    mov dl,[resolutn]
    dec dl
    dec dl
    cmp byte[scanlines],3
    je near .halfscanlines
    cmp byte[scanlines],2
    je near .quarterscanlines
    cmp byte[scanlines],1
    je near .scanlines
.loopa
    mov ecx,256
    xor eax,eax
.a
    mov al,[esi]
    mov bx,[GUICPC+eax*2]
    mov [es:edi],bx
    mov [es:edi+2],bx
    inc esi
    add edi,4
    dec ecx
    jnz .a
    sub esi,256
    add edi,128*2
    mov ecx,256
    xor eax,eax
.a2
    mov al,[esi]
    mov bx,[GUICPC+eax*2]
    mov [es:edi],bx
    mov [es:edi+2],bx
    inc esi
    add edi,4
    dec ecx
    jnz .a2
    add esi,32
    add edi,128*2
    dec dl
    jnz .loopa
    pop es
    ret

.scanlines
.loopab
    mov ecx,256
    xor eax,eax
.ab
    mov al,[esi]
    mov bx,[GUICPC+eax*2]
    mov [es:edi],bx
    mov [es:edi+2],bx
    inc esi
    add edi,4
    dec ecx
    jnz .ab
.returnb
    add esi,32
    add edi,128*2+640*2
    dec dl
    jnz .loopab
    pop es
    ret

.halfscanlines
.loopabh
    mov ecx,256
    xor eax,eax
.abh
    mov al,[esi]
    mov bx,[GUICPC+eax*2]
    mov [es:edi],bx
    mov [es:edi+2],bx
    inc esi
    add edi,4
    dec ecx
    jnz .abh
    add edi,128*2
    mov ecx,256
    sub esi,256
.abh2
    mov al,[esi]
    mov bx,[GUICPC+eax*2]
    shl ebx,16
    mov bx,[GUICPC+eax*2]
    and ebx,[vesa2_clbitng2]
    shr ebx,1
    mov [es:edi],ebx
    inc esi
    add edi,4
    dec ecx
    jnz .abh2
    add esi,32
    add edi,128*2
    dec dl

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -