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

📄 vesa2.asm

📁 linux下的任天堂模拟器代码。供大家参考。
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;Copyright (C) 1997-2007 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach );;http://www.zsnes.com;http://sourceforge.net/projects/zsnes;https://zsnes.bountysource.com;;This program is free software; you can redistribute it and/or;modify it under the terms of the GNU General Public License;version 2 as published by the Free Software Foundation.;;This program is distributed in the hope that it will be useful,;but WITHOUT ANY WARRANTY; without even the implied warranty of;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the;GNU General Public License for more details.;;You should have received a copy of the GNU General Public License;along with this program; if not, write to the Free Software;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.%include "macros.mac"EXTSYM DosExit,PrintStr,HalfTransB,HalfTransC,Init_2xSaIMMX,ZSNESBaseEXTSYM UnusedBit,HalfTrans,UnusedBitXor,ngrposng,nggposng,ngbposngEXTSYM videotroub,ExitFromGUI,ErrorPointer,vesa2_x,vesa2_y,vesa2_bits,TripBufAvail,vesa2red10EXTSYM vesa2_rposng,vesa2_gposng,vesa2_bposng,vesa2_clbitng,vesa2_clbitng2,vesa2_clbitng3EXTSYM vesa2_clbit,vesa2_usbit,vesa2_rpos,vesa2_rfull,vesa2_rtrcl,vesa2_rtrcla,genfulladdtabEXTSYM vesa2_gpos,vesa2_gfull,vesa2_gtrcl,vesa2_gtrcla,vesa2_bpos,vesa2_bfull,vesa2_btrcl,vesa2_btrclaSECTION .data; add 0214h video modeanticrash times 10 db 0ALIGN32NEWSYM vesa2selec,      dd 0            ; VESA2 Selector LocationNEWSYM vesa3en,         dd 0NEWSYM VESAAddr,        dd 0SECTION .bssSECTION .textNEWSYM VESA2EXITTODOS    mov byte[videotroub],1    cmp byte[ExitFromGUI],0    je .nogui    mov [ErrorPointer],edx    ret.nogui    mov ax,0003h    int 10h    push edx    mov edx,.exitfromvesa2    call PrintStr    pop edx    call PrintStr    mov edx,.return    call PrintStr    jmp DosExitSECTION .data.exitfromvesa2 db 'Unable to Initialize VESA2 : ',0.return db 10,13,0SECTION .text;*******************************************************;   Set up Vesa 2;*******************************************************NEWSYM InitVesa2    ;-------------------------------------------------;     ; First - allocate some bytes in DOS memory for ;     ; communication with VBE                        ;    ;-------------------------------------------------;    mov eax,0100h    mov ebx,512/16  ; 512 bytes    int 31h         ; Function 31h,100h - Allocate                    ; DOS memory (512 bytes)    jnc .gotmem    mov edx,.nomemmessage    jmp VESA2EXITTODOS.gotmem    mov fs,dx   ; FS now points to the DOS buffer    ;--------------------------------------------------;     ; Now, get information about the video card into ;     ; a data structure                               ;    ;--------------------------------------------------;    mov edi,RMREGS    mov dword[fs:0],'VBE2'   ; Request VBE 2.0 info    mov dword[RMREGS.eax],4f00h    mov [RMREGS.es],ax       ; Real mode segment of DOS buffer    mov dword[RMREGS.edi],0    push es    push ds    pop es    mov eax,300h    mov ebx,10h    xor ecx,ecx    int 31h                  ; Simulate real mode interrupt    pop es    jnc .int1ok    mov edx,.noint1message    jmp VESA2EXITTODOS.int1ok              ; Real mode int successful!!!    mov eax,[RMREGS.eax]    cmp al,4fh       ; Check vbe interrupt went OK    jz .vbedetected    mov edx,.novbemessage    jmp VESA2EXITTODOS.vbedetected    cmp dword[fs:0000],'VESA'    jz .vesadetected  ; Check for presence of vesa    mov edx,.novesamessage    jmp VESA2EXITTODOS.vesadetected    cmp word[fs:0004],200h    jae .vesa2detected ; Check we've got VESA 2.0 or greater    mov edx,.novesa2message    jmp VESA2EXITTODOS    ;-----------------------------------------------------;     ; OK - vesa 2.0 or greater has been detected. Copy  ;     ; mode information into VESAmodelist                ;    ;-----------------------------------------------------;.vesa2detected    mov dword[vesa3en],0    cmp word[fs:004],300h    jb .notvbe3    mov dword[vesa3en],1.notvbe3    mov ax,[fs:12h]             ; Get no. of 64k blocks    mov [noblocks],ax    mov ax, 2    mov bx,[fs:10h]    int 31h    jnc .wegottheselector    mov edx, .oopsnoselector    jmp VESA2EXITTODOS.wegottheselector    mov gs,ax    xor eax,eax    mov ebp,VESAmodelist    mov ecx,512    mov ax,[fs:0eh].loopcopymodes    mov bx,[gs:eax]    mov [ebp],bx    cmp bx,0ffffh    jz .copiedmodes    add ebp,2    add eax,2    dec ecx    jz .outofmodelistspace    jmp .loopcopymodes.outofmodelistspace    mov edx,.outofmodelistspacemessage    jmp VESA2EXITTODOS    ;----------------------------------------------;     ; OK - Scan the mode list to find a matching ;     ; mode for vesa2_x, vesa2_y and vesa2_depth  ;    ;----------------------------------------------;.copiedmodes    mov ebp,VESAmodelist    xor ecx,ecx.loopcheckmodes    mov cx, [ebp]    cmp cx, 0ffffh    jnz .notendoflist    mov edx,.endoflist    jmp VESA2EXITTODOS.notendoflist    mov edi, RMREGS    mov dword[RMREGS.eax],4f01h    mov dword[RMREGS.ebx],0    mov [RMREGS.ecx],ecx    mov dword[RMREGS.edi],0    push es    push ds    pop es    mov eax,300h    mov ebx,10h    xor ecx,ecx    int 31h                 ; Simulate real mode interrupt    pop es    jnc .modecheckok    mov edx,.modecheckfail    jmp VESA2EXITTODOS.modecheckok    add ebp,2    test word[fs:0000h],1b    jz near .loopcheckmodes     ; If mode is not available    mov eax,[vesa2_x]    cmp [fs:12h],ax             ; Check that the height matches    jnz near .loopcheckmodes    mov eax,[vesa2_y]    cmp [fs:14h],ax             ; Check that the width matches    jnz near .loopcheckmodes    mov al,[vesa2_bits]    cmp [fs:19h],al             ; Check bits/pixel for match    jnz near .loopcheckmodes    mov byte[TripBufAvail],1    test word[fs:0000h],400h    jz .notbuf    mov byte[TripBufAvail],1.notbuf.notvesa3;        D0 = Window supported;                0 = Window is not supported;                1 = Window is supported;        D1 = Window readable;                0 = Window is not readable;                1 = Window is readable;        D2 = Window writeable;                0 = Window is not writeable;                1 = Window is writeable;        D3-D7 = Reserved    mov byte[.whichwin],0    mov al,[fs:2]      ; Get window A attributes    and al,0100b    cmp al,0100b    je .foundwin       ; Mode supported    mov al,[fs:3]      ; Get window B attributes    and al,0100b    cmp al,0100b    jne .foundwin      ; Mode not supported    mov byte[.whichwin],1.foundwin    ; Success - a match has been found!!    sub ebp,2    mov ax,[ebp]    mov [vesamode],ax  ; Store vesa 2 mode number    mov ax,[fs:10h]    mov byte[vesa2red10],0    mov byte[vesa2_rposng],11    mov byte[vesa2_gposng],6    mov byte[vesa2_bposng],0    mov dword[vesa2_clbitng],1111011111011110b    mov dword[vesa2_clbitng2],11110111110111101111011111011110b    mov dword[vesa2_clbitng2+4],11110111110111101111011111011110b    mov dword[vesa2_clbitng3],0111101111101111b    mov [bytesperscanline],ax   ; Store bytes per scan line    cmp byte[fs:20h],10    jne near .nored10    mov byte[fs:20h],11    mov byte[vesa2red10],1    mov byte[vesa2_rposng],10    mov byte[vesa2_gposng],5    mov dword[vesa2_clbitng],0111101111011110b    mov dword[vesa2_clbitng2],01111011110111100111101111011110b    mov dword[vesa2_clbitng2+4],01111011110111100111101111011110b    mov dword[vesa2_clbitng3],0011110111101111b    mov dword[UnusedBit],     10000000000000001000000000000000b    mov dword[HalfTrans],     01111011110111100111101111011110b    mov dword[UnusedBitXor],  01111111111111110111111111111111b    mov dword[UnusedBit+4],   10000000000000001000000000000000b    mov dword[HalfTrans+4],   01111011110111100111101111011110b    mov dword[UnusedBitXor+4],01111111111111110111111111111111b    mov dword[HalfTransB],    00000100001000010000010000100001b    mov dword[HalfTransB+4],  00000100001000010000010000100001b    mov dword[HalfTransC],    01111011110111100111101111011110b    mov dword[HalfTransC+4],  01111011110111100111101111011110b    mov dword[ngrposng],10    mov dword[nggposng],5    mov dword[ngbposng],0.nored10    ; fix up bit lengths    mov al,16    sub al,[fs:20h]    mov ah,[fs:22h]    sub ah,[fs:20h]    mov bl,[fs:24h]    sub bl,[fs:20h]    mov bh,al    cmp bh,ah    jb .scheck1    mov bh,ah.scheck1    cmp bh,bl    jb .scheck2    mov bh,bl.scheck2    mov byte[fs:19h],5    mov al,16    sub al,[fs:22h]    mov ah,[fs:20h]    sub ah,[fs:22h]    mov bl,[fs:24h]    sub bl,[fs:22h]    mov bh,al

⌨️ 快捷键说明

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