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

📄 a_nasm.asm

📁 小型游戏引擎
💻 ASM
📖 第 1 页 / 共 2 页
字号:
; // "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman; // Ken Silverman's official web site: "http://www.advsys.net/ken"; // See the included license file "BUILDLIC.TXT" for license info.; // This file has been modified from Ken Silverman's original release; These two aren't needed AH;.586P;.8087;include mmx.inc       ;Include this if using < WATCOM 11.0 WASM;Warning: IN THIS FILE, ALL SEGMENTS ARE REMOVED.  THIS MEANS THAT DS:[];MUST BE ADDED FOR ALL SELF-MODIFIES FOR MASM TO WORK.;;WASM PROBLEMS:;   1. Requires all scaled registers (*1,*2,*4,*8) to be last thing on line;   2. Using 'DATA' is nice for self-mod. code, but WDIS only works with 'CODE';;MASM PROBLEMS:;   1. Requires DS: to be written out for self-modifying code to work;   2. Doesn't encode short jumps automatically like WASM;   3. Stupidly adds wait prefix to ffree's; ************************; **  Start Data Block  **; ************************SECTION .data    ; Some C compilers insert an underscore ('_') character in front of    ;  identifiers. In such a case, we need to redefine our references to    ;  global indentifiers that exist in the C code.  --ryan.%ifdef C_IDENTIFIERS_UNDERSCORED%define asm1 _asm1%define asm2 _asm2%define asm3 _asm3%define asm4 _asm4%define fpuasm _fpuasm%define reciptable _reciptable%define globalx3 _globalx3%define globaly3 _globaly3%define ylookup _ylookup%define vplce _vplce%define vince _vince%define palookupoffse _palookupoffse%define bufplce _bufplce%define ebpbak _ebpbak%define espbak _espbak%define pow2char _pow2char%define pow2long _pow2long%endifextern asm1extern asm2extern asm3extern asm4extern fpuasmextern reciptableextern globalx3extern globaly3extern ylookupextern vplceextern vinceextern palookupoffseextern bufplceextern ebpbakextern espbakextern pow2charextern pow2long; These are our globally-scoped labels (i.e. functions) AH  global _asm_krecipasm  global _asm_sethlinesizes  global _asm_prosethlinesizes  global _asm_setvlinebpl  global _asm_setpalookupaddress  global _asm_prosetpalookupaddress  global _asm_setuphlineasm4  global _asm_hlineasm4  global _asm_prohlineasm4  global _asm_setupvlineasm  global _asm_prosetupvlineasm  global _asm_setupmvlineasm  global _asm_setuptvlineasm  global _asm_prevlineasm1  global _asm_vlineasm1  global _asm_mvlineasm1  global _asm_fixtransluscence  global _asm_settransnormal  global _asm_settransreverse  global _asm_tvlineasm1  global _asm_vlineasm4  global _asm_provlineasm4  global _asm_mvlineasm4  global _asm_setupspritevline  global _asm_spritevline  global _asm_msetupspritevline  global _asm_mspritevline  global _asm_tsetupspritevline  global _asm_tspritevline  global _asm_msethlineshift  global _asm_mhline  global _asm_mhlineskipmodify  global _asm_tsethlineshift  global _asm_thline  global _asm_thlineskipmodify  global _asm_setuptvlineasm2  global _asm_tvlineasm2  global _asm_setupslopevlin2  global _asm_slopevlin2  global _asm_setupslopevlin  global _asm_slopevlin  global _asm_setuprhlineasm4  global _asm_rhlineasm4  global _asm_setuprmhlineasm4  global _asm_rmhlineasm4  global _asm_setupqrhlineasm4  global _asm_qrhlineasm4  global _asm_setupdrawslab  global _asm_drawslab  global _asm_stretchhline  global _asm_mmxoverlay  global _asm_isvmwarerunning; ************************; **   End Data Block   **; ************************; ************************; **  Start Code Block  **; ************************SEGMENT .text; Ignore all the 'offset's in the code AH%idefine offset; Align entire code block to 16 bit boundariesALIGN 16_asm_isvmwarerunning:	mov eax,564d5868h	mov ecx,0000000ah	mov dx,5658h	in  eax,dx	cmp ebx,564d5868h	jz  vmware_y	xor eax,eax	retvmware_y:        mov eax,1h        ret _asm_sethlinesizes:	mov byte [machxbits1+2], al	mov byte [machxbits2+2], al	mov byte [machxbits3+2], al	neg al	mov byte [hxsiz1+2], al	mov byte [hxsiz2+2], al	mov byte [hxsiz3+2], al	mov byte [hxsiz4+2], al	mov byte [machnegxbits1+2], al	mov byte [hysiz1+3], bl	mov byte [hysiz2+3], bl	mov byte [hysiz3+3], bl	mov byte [hysiz4+3], bl	mov byte [hmach3a+2], bl	mov byte [hmach3b+2], bl	mov byte [hmach3c+2], bl	mov byte [hmach3d+2], bl	mov dword [hoffs1+2], ecx	mov dword [hoffs2+2], ecx	mov dword [hoffs3+2], ecx	mov dword [hoffs4+2], ecx	mov dword [hoffs5+2], ecx	mov dword [hoffs6+2], ecx	mov dword [hoffs7+2], ecx	mov dword [hoffs8+2], ecx	mov edx, -1	mov cl, al	sub cl, bl	shr edx, cl	mov dword [hmach2a+1], edx	mov dword [hmach2b+1], edx	mov dword [hmach2c+1], edx	mov dword [hmach2d+1], edx   retALIGN 16_asm_prosethlinesizes:	mov dword [prohbuf-4], ecx	neg eax	mov ecx, eax	sub eax, ebx	mov byte [prohshru-1], al   ;bl = 32-al-bl	mov eax, -1	shr eax, cl	mov ecx, ebx	shl eax, cl	mov dword [prohand-4], eax  ;((-1>>(-oal))<<obl)	neg ebx	mov byte [prohshrv-1], bl   ;bl = 32-bl	retALIGN 16	_asm_setvlinebpl:	mov dword [fixchain1a+2], eax	mov dword [fixchain1b+2], eax	mov dword [fixchain1m+2], eax	mov dword [fixchain1t+2], eax	mov dword [fixchain1s+2], eax	mov dword [mfixchain1s+2], eax	mov dword [tfixchain1s+2], eax	mov dword [fixchain2a+2], eax	mov dword [profixchain2a+2], eax	mov dword [fixchain2ma+2], eax	mov dword [fixchain2mb+2], eax	mov dword [fixchaint2a+1], eax	mov dword [fixchaint2b+2], eax	mov dword [fixchaint2c+2], eax	mov dword [fixchaint2d+2], eax	mov dword [fixchaint2e+2], eax    retALIGN 16_asm_setpalookupaddress:    mov dword [pal1+2], eax	mov dword [pal2+2], eax	mov dword [pal3+2], eax	mov dword [pal4+2], eax	mov dword [pal5+2], eax	mov dword [pal6+2], eax	mov dword [pal7+2], eax	mov dword [pal8+2], eax	retALIGN 16_asm_prosetpalookupaddress:	mov dword [prohpala-4], eax	retALIGN 16_asm_setuphlineasm4:machxbits3: rol eax, 6                     ;xbits    mov dword [hmach4a+2], eax	mov dword [hmach4b+2], eax	mov bl, al	mov dword [hmach4c+2], eax	mov dword [hmach4d+2], eax	mov dword [hmach1a+2], ebx	mov dword [hmach1b+2], ebx	mov dword [hmach1c+2], ebx	mov dword [hmach1d+2], ebx    ret	;Non-256-stuffed ceiling&floor method with NO SHLD!:	;yinc&0xffffff00   lea eax, [edx+88888800h]           1     1/2	;ybits...xbits     and edx, 88000088h                 1     1/2	;ybits             rol edx, 6                         2     1/2	;xinc<<xbits       add esi, 88888888h                 1     1/2	;xinc>>(32-xbits)  adc al, 88h                        1     1/2	;bufplc            mov cl, byte [edx+88888888h]   1     1/2	;paloffs&255       mov bl, byte [ecx+88888888h]   1     1/2_asm_hlineasm4:	push ebp	lea ebp, [eax+1]	cmp ebp, 8	jle NEAR shorthline	test edi, 1	jnz short skipthe1byte	mov eax, esihxsiz1: shr eax, 26hysiz1: shld eax, edx, 6hoffs1: mov cl, byte [eax+88888888h]pal1: mov bl, byte [ecx+88888888h]	sub esi, [asm1]	sub edx, [asm2]	mov byte [edi], bl	dec edi	dec ebpskipthe1byte:	test edi, 2	jnz short skipthe2byte	mov eax, esihxsiz2: shr eax, 26hysiz2: shld eax, edx, 6hoffs2: mov cl, byte [eax+88888888h]pal2: mov bh, byte [ecx+88888888h]	sub esi, [asm1]	sub edx, [asm2]	mov eax, esihxsiz3: shr eax, 26hysiz3: shld eax, edx, 6hoffs3: mov cl, byte [eax+88888888h]pal3: mov bl, byte [ecx+88888888h]	sub esi, [asm1]	sub edx, [asm2]	mov word [edi-1], bx	sub edi, 2	sub ebp, 2skipthe2byte:	mov eax, esimachxbits1: shl esi, 6                     ;xbitsmachnegxbits1: shr eax, 32-6               ;32-xbits	mov dl, al	inc edi	add ebx, ebx	mov eax, edx	jc beginhline64	mov eax, [asm1]machxbits2: rol eax, 6                     ;xbits	mov dword [hmach4a+2], eax	mov dword [hmach4b+2], eax	mov dword [hmach4c+2], eax	mov dword [hmach4d+2], eax	mov ebx, eax	mov eax, [asm2]	mov al, bl	mov dword [hmach1a+2], eax	mov dword [hmach1b+2], eax	mov dword [hmach1c+2], eax	mov dword [hmach1d+2], eax	mov eax, edx	jmp beginhline64prebeginhline64:	mov dword [edi], ebxbeginhline64:hmach3a: rol eax, 6hmach2a: and eax, 00008888hhmach4a: sub esi, 88888888hhmach1a: sbb edx, 88888888h	sub edi, 4hoffs4: mov cl, byte [eax+88888888h]	mov eax, edx

⌨️ 快捷键说明

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