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

📄 newg162.asm

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 ASM
📖 第 1 页 / 共 4 页
字号:
;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 ngwintable,ngwinen,ngcwinptr,ngcpixleft,ngcwinmode
EXTSYM tleftn, ng16bprval, vrama, bg1drwng, ng16bbgval, bg1totng
EXTSYM bgtxadd, taddnfy16x16, taddfy16x16, switch16x16, curmosaicsz, domosaicng16b
EXTSYM vidmemch4,vidmemch2,vidmemch8,mode0add,vcache4b,vcache2b,vcache8b
EXTSYM cachesingle2bng,cachesingle8bng,ngpalcon4b,ngpalcon8b
EXTSYM ngpalcon2b,tleftnb,tltype2b,tltype4b,tltype8b,yposng,flipyposng
EXTSYM ofsmcptr,ofsmtptr,ofsmmptr,ofsmcyps,ofsmady,ofsmadx,FillSubScr,UnusedBitXor
EXTSYM yposngom,flipyposngom,cbgval,ofsmval,ofsmvalh,vram,CPalPtrng,BGMS1,scadtng
EXTSYM CMainWinScr,CSubWinScr,UnusedBit,res640,mosclineval,mostranspval
EXTSYM vcache2bs,vcache4bs,vcache8bs
EXTSYM vidmemch2s,vidmemch4s,vidmemch8s
EXTSYM cpalval,bgtxadd2
EXTSYM SpecialLine

NEWSYM NewG162AsmStart

%include "video/vidmacro.mac"
%include "video/newg162.mac"
%include "video/newgfx16.mac"
%include "video/newg16wn.mac"









;******************************************
; 16bitng caching functions
;******************************************

%macro cacheloopstuff 1
    mov bl,[esi+%1]
    or bl,bl
    jnz %%okay
    mov ax,0FFFFh
    jmp %%transp
%%okay
    or bl,dl
    mov ax,[ebp+ebx*2]
%%transp
    mov [edi+%1*2],ax
    mov [edi+14-%1*2+128],ax
%endmacro

%macro DoCache 2
    push ecx
    push eax
    push esi
    push edi
    mov esi,ecx
    xor ebx,ebx
    shl esi,6
    shl ecx,8
    add esi,[%1]
    add ecx,[%2]
    mov edi,ecx
    mov ecx,8
.loop
    cacheloopstuff 0
    cacheloopstuff 1
    cacheloopstuff 2
    cacheloopstuff 3
    cacheloopstuff 4
    cacheloopstuff 5
    cacheloopstuff 6
    cacheloopstuff 7
    add edi,16
    add esi,8
    dec ecx
    jnz near .loop
    pop edi
    pop esi
    pop eax
    pop ecx
    ret
%endmacro

cache2b16b:
    DoCache vcache2b,vcache2bs
cache4b16b:
    DoCache vcache4b,vcache4bs
cache8b16b:
    DoCache vcache8b,vcache8bs

;******************************************
; 8x8 tiles - tile engine
;******************************************

%macro WinClipMacro 1
    mov byte[tleftn],33
    mov dword[ngcwinptr],ngwintable
    mov dword[ngcwinmode],0
    cmp dword[ngwintable],0
    jne .loop
    add dword[ngcwinptr],4
    mov dword[ngcwinmode],1
.winclipped
    mov ebx,[ngcwinptr]
    mov cx,[vrama+eax]
    cmp dword[ebx],8
    jbe near %1
    sub dword[ebx],8
    add ax,2
    mov ebx,[ng16bbgval]
    add edi,16
    inc dword[bg1totng+ebx*4]
    test eax,03Fh
    jnz .notileadd
    add ax,[bgtxadd]
.notileadd
    dec byte[tleftn]
    jnz .winclipped
    pop ebx
    cmp byte[curmosaicsz],1
    jne near domosaicng16b
    ret
.loop
    mov ebx,[ngcwinptr]
    mov cx,[vrama+eax]
    cmp dword[ebx],8
    jbe near %1
    sub dword[ebx],8
    xor ecx,[ng16bprval]
    test ecx,2000h
    jnz near .finline
%endmacro

%macro determinetransp 1
    mov [mostranspval],dl
    mov [mosclineval],ebx
    add ecx,[CMainWinScr]
    cmp byte[curmosaicsz],1
    jne .mosaic
    test byte[BGMS1+ebx*2],dl
    jz .nosubmain
    test byte[FillSubScr+ebx],1
    jnz near %1
    jmp .main
.nosubmain
    test byte[FillSubScr+ebx],1
    jz .main
    sub ecx,[CMainWinScr]
    add ecx,[CSubWinScr]
    add edi,75036*2
    jmp .main
.mosaic
    test byte[FillSubScr+ebx],1
    jz .main
    sub ecx,[CMainWinScr]
    add ecx,[CSubWinScr]
.main
%endmacro

%macro CheckWindowing 1
    cmp byte[ngwinen],0
    je %%nowindowing
    cmp byte[ecx],0
    jne near %1
%%nowindowing
%endmacro

%macro DetermineWindow 3        ; both,main,sub
    cmp byte[ngwinen],0
    je %%nowindow
    cmp byte[ecx],0
    jz near %3
    sub ecx,[CMainWinScr]
    add ecx,[CSubWinScr]
    cmp byte[ecx],0
    jnz near %1
    jmp %2
%%nowindow
%endmacro

%macro drawtile16b 10
    mov byte[tleftn],33
%%loop
    mov cx,[vrama+eax]
    xor ecx,[ng16bprval]
    test ecx,2000h
    jnz near %%finline
    drawtileng16b %1,%2,%3,%%loop,%%finline,%4,%5,%6,%7,%8,%9,%10
    ret
%endmacro

%macro drawtile16bw 12
    WinClipMacro %%processwinclip2b
    drawtileng16b %1,%2,%3,.loop,.finline,%4,%5,%6,%7,%8,%9,%10
%%processwinclip2b
    mov ebx,[ngcwinptr]
    mov cx,[vrama+eax]
    mov ebx,[ebx]
    xor ecx,[ng16bprval]
    mov [ngcpixleft],ebx
    test ecx,2000h
    jnz near %%finline
    drawtilengwin16b %1,%2,%3,%%loop,%%finline,%4,%5,%6,%7,%8,%11,%12
%%loop
    push eax
    mov ebx,[ngcwinptr]
    mov eax,[ngcpixleft]
    mov [ebx],eax
    pop eax
    cmp dword[ngcwinmode],1
    je near .winclipped
    jmp .loop
%endmacro

%macro drawtile16bw2 14
    mov byte[tleftn],33
    mov dword[ngcwinptr],ngwintable
    mov dword[ngcwinmode],0
    cmp dword[ngwintable],0
    jne near .loop
    add dword[ngcwinptr],4
    mov dword[ngcwinmode],1
.winclipped
    mov ebx,[ngcwinptr]
    mov cx,[vrama+eax]
    cmp dword[ebx],8
    jbe near %%processwinclip2b
    sub dword[ebx],8
    xor ecx,[ng16bprval]
    test ecx,2000h
    jnz near .finlineb
    drawtileng16b %1,%2,%3,.winclipped,.finlineb,%4,%5,%6,%7,%8,%13,%14
.loop
    mov ebx,[ngcwinptr]
    mov cx,[vrama+eax]
    cmp dword[ebx],8
    jbe near %%processwinclip2b
    sub dword[ebx],8
    xor ecx,[ng16bprval]
    test ecx,2000h
    jnz near .finline
    drawtileng16b %1,%2,%3,.loop,.finline,%4,%5,%6,%7,%8,%9,%10
%%processwinclip2b
    mov ebx,[ngcwinptr]
    mov cx,[vrama+eax]
    mov ebx,[ebx]
    xor ecx,[ng16bprval]
    mov [ngcpixleft],ebx
    test ecx,2000h
    jnz near %%finline
    drawtilengwin16b %1,%2,%3,%%loop,%%finline,%4,%5,%6,%7,%8,%11,%12
%%loop
    push eax
    mov ebx,[ngcwinptr]
    mov eax,[ngcpixleft]
    mov [ebx],eax
    pop eax
    cmp dword[ngcwinmode],1
    je near .winclipped
    jmp .loop
%endmacro

NEWSYM drawtileng2b16b
    mov ebp,[cpalval+ebx*4]
    determinetransp drawtileng2b16bt
drawtileng2b16bnt
    CheckWindowing drawtileng2bwin
    drawtile16b tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormal,tilenormalb
drawtileng2bwin:
    drawtile16bw tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormal,tilenormalb,tilenormalw,tilenormalwb
drawtileng2b16bt
    test byte[BGMS1+ebx*2+1],dl
    jnz near drawtileng2b16bms
    test byte[scadtng+ebx],dl
    jz near drawtileng2b16bnt
    CheckWindowing drawtileng2bwint
    drawtile16b tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormalt,tilenormalbt
drawtileng2bwint:
    drawtile16bw tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormalt,tilenormalbt,tilenormalwt,tilenormalwbt
drawtileng2b16bms:
    test byte[scadtng+ebx],dl
    jz near drawtileng2b16bmsnt
    DetermineWindow drawtileng2b16bmstmsw, drawtileng2b16bmstmw, drawtileng2b16bmstsw
    drawtile16b tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormalmst,tilenormalbmst
drawtileng2b16bmstmsw:
    drawtile16bw tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormalmst,tilenormalbmst,tilenormalwmst,tilenormalwbmst
drawtileng2b16bmstmw:
    drawtile16bw2 tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormalmst,tilenormalbmst,tilenormalwsmt,tilenormalwbsmt,tilenormals,tilenormalbs
drawtileng2b16bmstsw:
    drawtile16bw2 tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormalmst,tilenormalbmst,tilenormalwmsbt,tilenormalwbmsbt,tilenormalt,tilenormalbt
drawtileng2b16bmsnt
    DetermineWindow drawtileng2b16bmsntmsw, drawtileng2b16bmsntmw, drawtileng2b16bmsntsw
    drawtile16b tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormalmsnt,tilenormalbmsnt
drawtileng2b16bmsntmsw:
    drawtile16bw tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormalmsnt,tilenormalbmsnt,tilenormalwmsnt,tilenormalwbmsnt
drawtileng2b16bmsntmw:
    drawtile16bw2 tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormalmsnt,tilenormalbmsnt,tilenormalwsmnt,tilenormalwbsmnt,tilenormals,tilenormalbs
drawtileng2b16bmsntsw:
    drawtile16bw2 tltype2b, preparet2batile, cachesingle2bng,ngpalcon2b,test2ba,03h,vidmemch2s,cache2b16b,tilenormalmsnt,tilenormalbmsnt,tilenormalwmsbnt,tilenormalwbmsbnt,tilenormal,tilenormalb

NEWSYM drawtileng4b16b
    mov ebp,[cpalval+ebx*4]
    determinetransp drawtileng4b16bt
drawtileng4b16bnt
    CheckWindowing drawtileng4bwin
    drawtile16b tltype4b, preparet4batile, cachesingle4bng,ngpalcon4b,test4ba,0Fh,vidmemch4s,cache4b16b,tilenormal,tilenormalb
drawtileng4bwin:
    drawtile16bw tltype4b, preparet4batile, cachesingle4bng,ngpalcon4b,test4ba,0Fh,vidmemch4s,cache4b16b,tilenormal,tilenormalb,tilenormalw,tilenormalwb
drawtileng4b16bt
    test byte[BGMS1+ebx*2+1],dl
    jnz near drawtileng4b16bms
    test byte[scadtng+ebx],dl
    jz near drawtileng4b16bnt
    CheckWindowing drawtileng4bwint
    drawtile16b tltype4b, preparet4batile, cachesingle4bng,ngpalcon4b,test4ba,0Fh,vidmemch4s,cache4b16b,tilenormalt,tilenormalbt
drawtileng4bwint:
    drawtile16bw tltype4b, preparet4batile, cachesingle4bng,ngpalcon4b,test4ba,0Fh,vidmemch4s,cache4b16b,tilenormalt,tilenormalbt,tilenormalwt,tilenormalwbt
drawtileng4b16bms:
    test byte[scadtng+ebx],dl
    jz near drawtileng4b16bmsnt
    DetermineWindow drawtileng4b16bmstmsw, drawtileng4b16bmstmw, drawtileng4b16bmstsw
    drawtile16b tltype4b, preparet4batile, cachesingle4bng,ngpalcon4b,test4ba,0Fh,vidmemch4s,cache4b16b,tilenormalmst,tilenormalbmst
drawtileng4b16bmstmsw:
    drawtile16bw tltype4b, preparet4batile, cachesingle4bng,ngpalcon4b,test4ba,0Fh,vidmemch4s,cache4b16b,tilenormalmst,tilenormalbmst,tilenormalwmst,tilenormalwbmst
drawtileng4b16bmstmw:
    drawtile16bw2 tltype4b, preparet4batile, cachesingle4bng,ngpalcon4b,test4ba,0Fh,vidmemch4s,cache4b16b,tilenormalmst,tilenormalbmst,tilenormalwsmt,tilenormalwbsmt,tilenormals,tilenormalbs
drawtileng4b16bmstsw:
    drawtile16bw2 tltype4b, preparet4batile, cachesingle4bng,ngpalcon4b,test4ba,0Fh,vidmemch4s,cache4b16b,tilenormalmst,tilenormalbmst,tilenormalwmsbt,tilenormalwbmsbt,tilenormalt,tilenormalbt
drawtileng4b16bmsnt
    DetermineWindow drawtileng4b16bmsntmsw, drawtileng4b16bmsntmw, drawtileng4b16bmsntsw
    drawtile16b tltype4b, preparet4batile, cachesingle4bng,ngpalcon4b,test4ba,0Fh,vidmemch4s,cache4b16b,tilenormalmsnt,tilenormalbmsnt
drawtileng4b16bmsntmsw:
    drawtile16bw tltype4b, preparet4batile, cachesingle4bng,ngpalcon4b,test4ba,0Fh,vidmemch4s,cache4b16b,tilenormalmsnt,tilenormalbmsnt,tilenormalwmsnt,tilenormalwbmsnt
drawtileng4b16bmsntmw:
    drawtile16bw2 tltype4b, preparet4batile, cachesingle4bng,ngpalcon4b,test4ba,0Fh,vidmemch4s,cache4b16b,tilenormalmsnt,tilenormalbmsnt,tilenormalwsmnt,tilenormalwbsmnt,tilenormals,tilenormalbs
drawtileng4b16bmsntsw:

⌨️ 快捷键说明

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