📄 procvid.asm
字号:
;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
;
;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;as published by the Free Software Foundation; either
;version 2 of the License, or (at your option) any later
;version.
;
;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 BGMA,DSPMem,INTEnab,V8Mode,antienab,cacheud,cbitmode
EXTSYM ccud,cfield,cgfxmod,cgram,coladdb,coladdg,coladdr,cpalval,curblank
EXTSYM curfps,cvidmode,delay,draw16bnng,extlatch,fnamest,fulladdtab,En2xSaI
EXTSYM gammalevel,hirestiledat,ignor512,latchx,latchy,maxbr,ForceNewGfxOff
EXTSYM newengen,nextframe,objptr,pressed,prevpal,res512switch,res640
EXTSYM resolutn,romispal,sbpmofs,sbselec,scaddtype,scadtng,scanlines
EXTSYM scbcong,selcA000,snesmouse,t1cc,vcache4b,vesa2_bpos,spritetablea
EXTSYM vesa2_clbit,vesa2_gpos,vesa2_rpos,vesa2red10,vesa2selec,vidbuffer
EXTSYM vidbufferm,vram,vsyncon,vbufdptr,KeyStateSelct,forceblnk,soundon
EXTSYM Open_File,Read_File,Close_File,Create_File,Write_File,Get_File_Date
EXTSYM Triplebufen,makepal,changepal,saveselectpal,displayfpspal,superscopepal
EXTSYM DrawScreen
EXTSYM Get_MouseData,Get_MousePositionDisplacement
EXTSYM GUIEnableTransp
EXTSYM GUIFontData
EXTSYM StopSound,StartSound
EXTSYM PrevPicture,File_Seek,File_Seek_End,nggposng
;EXTSYM OSPort
EXTSYM Palette0
EXTSYM GetTimeInSeconds
EXTSYM scaddset,scrnon,spcRam,nmiprevline,bgmode,ofsmcptr
EXTSYM interlval,bg3ptr,bg3scroly,bg3scrolx,C4Ram,SprValAdd,SA1IRQEn,SA1IRQV
EXTSYM winbg1en,winlogica,wincolen,winlogicb,dsp1ptr,dsp1array,bg3objptr
EXTSYM cnetptrhead,cnetptrtail,JoyBOrig,pl2neten,Voice6Ptr,HIRQLoc,SA1DoIRQ
EXTSYM mode7A,mode7B,mode7C,mode7D,mode7set,winbg3en,winl1,winr1,SA1DMAInfo
EXTSYM winl2,winr2,VIRQLoc,SA1Enable,mode7X0,mode7Y0,SA1Temp
EXTSYM SA1IRQTemp,SA1IRQEnable,SA1DMADest,SA1DMAChar,SA1DMASource,SA1DMACount
EXTSYM objptrn,Voice0State,TempValueSnd,nglogicval,bgtilesz,C4values
EXTSYM curexecstate,TempVidInfo,LatestBank,C4ObjSelec
EXTSYM BGMS1,scadsng,winenabm,winenabs,vidbright
EXTSYM genfulladdtab,genfulladdtabng
EXTSYM KeyQuickChat,CNetType,WritetochatBuffer,NetAddChar,TimerEnable,ShowTimer
EXTSYM ClearScreenSkip,debugdisble,cmovietimeint
EXTSYM ChatNick
EXTSYM StringLength
EXTSYM chatstrLt
EXTSYM GUIOn,HalfTrans
EXTSYM ClearScreen
EXTSYM Mode7HiRes,mosenng,mosszng,intrlng,mode7hr ;,VESAAddr
EXTSYM GUICPC, newgfx16b
EXTSYM vesa2_clbitng,vesa2_clbitng2,vesa2_clbitng3
EXTSYM granadd,CSStatus
EXTSYM SpecialLine
EXTSYM vidbufferofsb
;EXTSYM Super2xSaI
EXTSYM HalfTransB,HalfTransC
NEWSYM ProcVidAsmStart
NEWSYM ScreenScale, db 0 ; If horizontal is scaled or not
NEWSYM TempDebugV, dw 0 ; Temporary Debugging variable
%macro MMXStuff 0
%%1
movq mm0,[esi]
movq [es:edi],mm0
movq mm1,[esi+8]
movq [es:edi+8],mm1
add esi,16
add edi,16
dec ecx
jnz %%1
%endmacro
%macro FPUStuff 1
FILD QWORD [ESI+%1*16]
FILD QWORD [ESI+8+%1*16]
FISTP QWORD [ES:EDI+8+%1*16]
FISTP QWORD [ES:EDI+%1*16]
%endmacro
%MACRO CopyFPU 0
%ENDMACRO
%include "video/2xsaimmx.inc"
%include "video/copyvid.inc"
SECTION .text
NEWSYM FPUZero
mov [.Zero],eax
mov [.Zero+4],eax
mov [.Zero2],eax
mov [.Zero2+4],eax
.TopOfLoop
FILD QWORD [.Zero]
FILD QWORD [.Zero2]
FXCH
FISTP QWORD [EDI]
FISTP QWORD [EDI+8]
ADD EDI,16
DEC ECX
JNZ .TopOfLoop
ret
.Zero dd 0,0
.Zero2 dd 0,0
NEWSYM FPUCopy, db 0
;*******************************************************
; ShowVideo Processes & displays video
;*******************************************************
NEWSYM showvideo
push esi
push edi
push edx
push ebx
push ebp
inc byte[ccud]
mov bl,byte[ccud]
cmp byte[cacheud],bl
je .noinc
mov byte[ccud],0
.noinc
call copyvid
mov eax,[KeyStateSelct]
test byte[pressed+eax],1
jz .nosavesel
call saveselect
.nosavesel
xor ecx,ecx
pop ebp
pop ebx
pop edx
pop edi
pop esi
ret
NEWSYM processmouse
push esi
push edi
push edx
push ebx
call Get_MouseData
mov [mousebuttons],bx
cmp byte[snesmouse],3
jne .ss
cmp byte[pressed+13],0
je .noautosw
cmp byte[ssautoswb],1
je .ss
xor byte[ssautosw],20h
mov byte[ssautoswb],1
mov dword[Msgptr],.ssautoen
cmp byte[ssautosw],0
jne .nononauto
mov dword[Msgptr],.ssautodi
.nononauto
mov eax,[MsgCount]
mov [MessageOn],eax
jmp .ss
.noautosw
mov byte[ssautoswb],0
.ss
call Get_MousePositionDisplacement
cmp byte[snesmouse],4
je .le
cmp byte[snesmouse],3
jne .ss2
.le
add word[mousexloc],cx
test word[mousexloc],8000h
jz .nowrapleft
mov word[mousexloc],0
.nowrapleft
cmp word[mousexloc],255
jbe .nowrapright
mov word[mousexloc],255
.nowrapright
mov ax,[mousexloc]
add ax,40
mov [latchx],ax
mov byte[extlatch],40h
.ss2
mov word[mousexpos],0
cmp cx,0
je .noxchange
mov byte[mousexdir],0
cmp cx,0
jge .noneg
mov byte[mousexdir],1
neg cx
.noneg
mov [mousexpos],cx
.noxchange
cmp byte[snesmouse],4
je .le2
cmp byte[snesmouse],3
jne .ss3
.le2
add word[mouseyloc],dx
test word[mouseyloc],8000h
jz .nowrapup
mov word[mouseyloc],0
.nowrapup
cmp word[mouseyloc],223
jbe .nowrapdown
mov word[mouseyloc],223
.nowrapdown
mov ax,[mouseyloc]
mov [latchy],ax
.ss3
mov word[mouseypos],0
cmp dx,0
je .noychange
mov byte[mouseydir],0
cmp dx,0
jge .noneg2
mov byte[mouseydir],1
neg dx
.noneg2
mov [mouseypos],dx
.noychange
xor ecx,ecx
pop ebx
pop edx
pop edi
pop esi
ret
.ssautoen db 'AUTOFIRE ENABLED.',0
.ssautodi db 'AUTOFIRE DISABLED.',0
NEWSYM ssautosw, db 20h
NEWSYM ssautoswb, db 0
NEWSYM mousebuttons, dw 0
NEWSYM mousexpos, dw 0
NEWSYM mousexdir, db 0
NEWSYM mouseypos, dw 0
NEWSYM mouseydir, db 0
NEWSYM mousechan, db 0
NEWSYM mousexloc, dw 128
NEWSYM mouseyloc, dw 112
;*******************************************************
; Output Hex Outputs the hex in al @ esi
;*******************************************************
NEWSYM outputhex
push edi
push esi
push eax
push ebx
push ecx
push esi
mov edi,FontData
xor ebx,ebx
mov bl,al
shr bl,4
shl ebx,3
add edi,ebx
add edi,8
mov cl,8
.loopa
mov ah,[edi]
mov ch,8
.loopb
test ah,80h
jz .nowrite
mov byte[esi],128
mov byte[esi+289],192
.nowrite
shl ah,1
inc esi
dec ch
jnz .loopb
add esi,280
inc edi
dec cl
jnz .loopa
pop esi
add esi,8
mov edi,FontData
xor ebx,ebx
mov bl,al
and bl,0Fh
shl ebx,3
add edi,ebx
add edi,8
mov cl,8
.loopa2
mov ah,[edi]
mov ch,8
.loopb2
test ah,80h
jz .nowrite2
mov byte[esi],128
mov byte[esi+289],192
.nowrite2
shl ah,1
inc esi
dec ch
jnz .loopb2
add esi,280
inc edi
dec cl
jnz .loopa2
pop ecx
pop ebx
pop eax
pop esi
pop edi
ret
OutputText16b:
cmp byte[ForceNonTransp],1
je near OutText16bnt
cmp byte[GUIEnableTransp],0
je near OutText16bnt
; output text in edi to esi
push ebx
push eax
mov cl,9
.loopa
mov ch,9
xor eax,eax
cmp cl,1
je .not1
mov al,[edi]
shl eax,1
.not1
xor ebx,ebx
cmp cl,9
je .loopb
mov bl,[edi-1]
.loopb
test ax,100h
jz .nowrite
push eax
and word[esi],dx
shr word[esi],1
and word[esi+75036*4],dx
shr word[esi+75036*4],1
ror edx,16
add word[esi],dx
add word[esi+75036*4],dx
ror edx,16
pop eax
jmp .nowrite2
.nowrite
test bx,100h
jz .nowrite2
and word[esi],dx
shr word[esi],1
and word[esi+75036*4],dx
shr word[esi+75036*4],1
.nowrite2
shl ax,1
shl bx,1
add esi,2
dec ch
jnz .loopb
add esi,279*2
inc edi
dec cl
jnz .loopa
pop eax
pop ebx
ret
OutText16bnt:
; output text in edi to esi
push ebx
push eax
mov cl,9
.loopa
mov ch,9
xor eax,eax
cmp cl,1
je .not1
mov al,[edi]
shl eax,1
.not1
xor ebx,ebx
cmp cl,9
je .loopb
mov bl,[edi-1]
.loopb
test ax,100h
jz .nowrite
mov word[esi],0FFFFh
mov word[esi+75036*4],0FFFFh
jmp .nowrite2
.nowrite
test bx,100h
jz .nowrite2
and word[esi],dx
and word[esi+75036*4],dx
shr word[esi],1
shr word[esi+75036*4],1
.nowrite2
shl ax,1
shl bx,1
add esi,2
dec ch
jnz .loopb
add esi,279*2
inc edi
dec cl
jnz .loopa
pop eax
pop ebx
ret
NEWSYM outputhex16
push edi
push esi
push eax
push ebx
push ecx
push edx
push esi
mov dx,[vesa2_clbitng]
ror edx,16
mov dx,[vesa2_clbitng]
shr dx,1
ror edx,16
mov edi,FontData
xor ebx,ebx
mov bl,al
shr bl,4
shl ebx,3
add edi,ebx
add edi,8
call OutputText16b
pop esi
add esi,16
mov edi,FontData
xor ebx,ebx
mov bl,al
and bl,0Fh
shl ebx,3
add edi,ebx
add edi,8
call OutputText16b
pop edx
pop ecx
pop ebx
pop eax
pop esi
pop edi
ret
NEWSYM ASCII2Font
db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h
db 00h,00h,00h,00h,00h,00h,00h,00h,00h,30h,00h,00h,00h,00h,00h,00h
db 00h,3Eh,33h,31h,3Fh,37h,2Fh,3Dh,3Ah,3Bh,35h,38h,39h,25h,28h,29h
db 01h,02h,03h,04h,05h,06h,07h,08h,09h,0Ah,2Eh,40h,2Ah,32h,2Bh,36h
db 3Ch,0Bh,0Ch,0Dh,0Eh,0Fh,10h,11h,12h,13h,14h,15h,16h,17h,18h,19h
db 1Ah,1Bh,1Ch,1Dh,1Eh,1Fh,20h,21h,22h,23h,24h,2Ch,34h,2Dh,42h,26h
db 41h,0Bh,0Ch,0Dh,0Eh,0Fh,10h,11h,12h,13h,14h,15h,16h,17h,18h,19h
db 1Ah,1Bh,1Ch,1Dh,1Eh,1Fh,20h,21h,22h,23h,24h,43h,00h,44h,27h,00h
db 0Dh,1Fh,0Fh,0Bh,0Bh,0Bh,0Bh,0Dh,0Fh,0Fh,0Fh,13h,13h,13h,0Bh,0Bh
db 0Fh,0Bh,0Bh,19h,19h,19h,1Fh,1Fh,23h,19h,1Fh,0Dh,10h,23h,1Ah,10h
db 0Bh,13h,19h,1Fh,18h,18h,0Bh,19h,00h,00h,00h,00h,00h,00h,00h,00h
db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h
db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h
db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h
db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h
db 00h,00h,00h,00h,00h,00h,00h,4Dh,4Ch,4Bh,4Ah,45h,46h,47h,48h,49h
NEWSYM FontData
db 0,0,0,0,0,0,0,0
db 01111100b,11000110b,11001110b,11010110b ; 0, 1
db 11100110b,11000110b,01111100b,00000000b
db 00011000b,00111000b,01111000b,00011000b ; 1, 2
db 00011000b,00011000b,01111110b,00000000b
db 01111100b,11000110b,00001100b,00011000b ; 2, 3
db 00110000b,01100110b,11111110b,00000000b
db 01111100b,11000110b,00000110b,00111100b ; 3, 4
db 00000110b,11000110b,01111100b,00000000b
db 00111100b,01101100b,11001100b,11111110b ; 4, 5
db 00001100b,00001100b,00001100b,00000000b
db 11111110b,11000000b,11000000b,11111100b ; 5, 6
db 00000110b,11000110b,01111100b,00000000b
db 00111100b,01100000b,11000000b,11111100b ; 6, 7
db 11000110b,11000110b,01111100b,00000000b
db 11111110b,11000110b,00000110b,00001100b ; 7, 8
db 00011000b,00011000b,00011000b,00000000b
db 01111100b,11000110b,11000110b,01111100b ; 8, 9
db 11000110b,11000110b,01111100b,00000000b
db 01111100b,11000110b,11000110b,01111110b ; 9, A
db 00000110b,11000110b,01111100b,00000000b
db 00111000b,01101100b,11000110b,11111110b ; A, B
db 11000110b,11000110b,11000110b,00000000b
db 11111100b,11000110b,11000110b,11111100b ; B, C
db 11000110b,11000110b,11111100b,00000000b
db 01111100b,11000110b,11000000b,11000000b ; C, D
db 11000000b,11000110b,01111100b,00000000b
db 11111100b,11000110b,11000110b,11000110b ; D, E
db 11000110b,11000110b,11111100b,00000000b
db 11111110b,11000000b,11000000b,11111000b ; E, F
db 11000000b,11000000b,11111110b,00000000b
db 11111110b,11000000b,11000000b,11111000b ; F, 10
db 11000000b,11000000b,11000000b,00000000b
db 01111100b,11000110b,11000000b,11000000b ; G, 11
db 11001110b,11000110b,01111100b,00000000b
db 11000110b,11000110b,11000110b,11111110b ; H, 12
db 11000110b,11000110b,11000110b,00000000b
db 00111100b,00011000b,00011000b,00011000b ; I, 13
db 00011000b,00011000b,00111100b,00000000b
db 00011110b,00001100b,00001100b,00001100b ; J, 14
db 00001100b,11001100b,00111100b,00000000b
db 11001100b,11011000b,11110000b,11100000b ; K, 15
db 11110000b,11011000b,11001100b,00000000b
db 11000000b,11000000b,11000000b,11000000b ; L, 16
db 11000000b,11000000b,11111110b,00000000b
db 11000110b,11101110b,11111110b,11010110b ; M, 17
db 11000110b,11000110b,11000110b,00000000b
db 11000110b,11100110b,11110110b,11011110b ; N, 18
db 11001110b,11000110b,11000110b,00000000b
db 01111100b,11000110b,11000110b,11000110b ; O, 19
db 11000110b,11000110b,01111100b,00000000b
db 11111100b,11000110b,11000110b,11111100b ; P, 1A
db 11000000b,11000000b,11000000b,00000000b
db 01111100b,11000110b,11000110b,11000110b ; Q, 1B
db 11010110b,11001110b,01111110b,00000000b
db 11111100b,11000110b,11000110b,11111100b ; R, 1C
db 11001100b,11000110b,11000110b,00000000b
db 01111100b,11000110b,11000000b,01111100b ; S, 1D
db 00000110b,11000110b,01111100b,00000000b
db 01111110b,00011000b,00011000b,00011000b ; T, 1E
db 00011000b,00011000b,00011000b,00000000b
db 11000110b,11000110b,11000110b,11000110b ; U, 1F
db 11000110b,11000110b,01111100b,00000000b
db 11000110b,11000110b,11000110b,11000110b ; V, 20
db 01101100b,00111000b,00010000b,00000000b
db 11000110b,11000110b,11000110b,11010110b ; W, 21
db 11010110b,11111110b,01101100b,00000000b
db 11000110b,01101100b,00111000b,00010000b ; X, 22
db 00111000b,01101100b,11000110b,00000000b
db 11001100b,11001100b,01111000b,00110000b ; Y, 23
db 00110000b,00110000b,00110000b,00000000b
db 11111100b,10001100b,00011000b,00110000b ; Z, 24
db 01100000b,11000100b,11111100b,00000000b
db 00000000b,00000000b,00000000b,11111110b ; -, 25
db 00000000b,00000000b,00000000b,00000000b
db 00000000b,00000000b,00000000b,00000000b ; _, 26
db 00000000b,00000000b,11111110b,00000000b
db 01110000b,11011100b,00000110b,00000000b ; ~, 27
db 00000000b,00000000b,00000000b,00000000b
db 00000000b,00000000b,00000000b,00000000b ; ., 28
db 00000000b,00110000b,00110000b,00000000b
db 00000010b,00000100b,00001000b,00010000b ; /, 29
db 00100000b,01000000b,10000000b,00000000b
db 00001100b,00011000b,00110000b,01100000b ; <, 2A
db 00110000b,00011000b,00001100b,00000000b
db 01100000b,00110000b,00011000b,00001100b ; >, 2B
db 00011000b,00110000b,01100000b,00000000b
db 00111000b,00100000b,00100000b,00100000b ; [, 2C
db 00100000b,00100000b,00111000b,00000000b
db 00111000b,00001000b,00001000b,00001000b ; ], 2D
db 00001000b,00001000b,00111000b,00000000b
db 00000000b,00011000b,00011000b,00000000b ; :, 2E
db 00011000b,00011000b,00000000b,00000000b
db 00011000b
db 00100100b
db 00011000b
db 00111010b ; &, 2F
db 01000100b
db 01000110b
db 00111010b
db 00000000b
; Arrow, 30
; #, 31 (, 3A {, 43
; =, 32 ), 3B }, 44
; ", 33 @, 3C Up,45
; \, 34 ', 3D Dn,46
; *, 35 !, 3E Lt,47
; ?, 36 $, 3F Rt,48
; %, 37 ;, 40 Bk,49
; +, 38 `, 41 .5,4A
; ,, 39 ^, 42
;*******************************************************
; Output Char Outputs char in al @ esi
;*******************************************************
NEWSYM outputchar
push edi
push esi
push eax
mov edi,FontData
xor ebx,ebx
mov bl,al
shl ebx,3
add edi,ebx
mov cl,8
.loopa
mov ah,[edi]
mov ch,8
.loopb
test ah,80h
jz .nowrite
mov al,[textcolor]
mov byte[esi],al
mov byte[esi+289],192
.nowrite
shl ah,1
inc esi
dec ch
jnz .loopb
add esi,280
inc edi
dec cl
jnz .loopa
pop eax
pop esi
pop edi
ret
NEWSYM outputchar16b
push edi
push esi
push eax
push edx
push ecx
mov dx,[vesa2_clbitng]
ror edx,16
mov dx,[vesa2_clbitng]
shr dx,1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -