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

📄 newspr2.s

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 S
📖 第 1 页 / 共 2 页
字号:
/* Let's convert this to pure asm... */	// Only used Space Gun and othunder// In fact the drivers use the zoom and zoom2 functions in spr64.c, which// call these functions when no zoom is actually needed !// 8bpp functions#include "asmdefs.inc"CODE_SEG// Macro used to handle 8 pixels in the Draw64x64 function// Thanks to the ';' it is much more readable now !// Notice that emacs takes the ';' as a comment... IT IS NOT a comment !	 #define HANDLE_8_PIXELS( base )						\	movl	base(%esi),%eax	;					\	movl	base+4(%esi),%ebx;					\									\	/* Still 3 instructions for 1 pixel (see 16bpp) */		\	/* Actually that's a little more because of the bswaps... */	\									\	movb	%al,%dl	;						\	movb	(%ecx,%edx,1),%al ;					\	movb	%bl,%dl	;						\	movb	(%ecx,%edx,1),%bl ;					\	movb	%ah,%dl	;						\	movb	(%ecx,%edx,1),%ah ;					\	movb	%bh,%dl	;						\	movb	(%ecx,%edx,1),%bh ;					\									\	bswap	%eax		;					\	bswap	%ebx		;					\									\	movb	%al,%dl	;						\	movb	(%ecx,%edx,1),%al ;					\	movb	%bl,%dl	;						\	movb	(%ecx,%edx,1),%bl ;					\	movb	%ah,%dl	;						\	movb	(%ecx,%edx,1),%ah ;					\	movb	%bh,%dl	;						\	movb	(%ecx,%edx,1),%bh ;					\									\	bswap	%eax		;					\	bswap	%ebx		;					\									\	movl	%eax,base(%edi)	;					\	movl	%ebx,base+4(%edi)	;// Now the FlipY version. The same except edi is accessed the other way// around...	// I am not sure this macro works actually : it writes 4 pixels in a row// without flipping them, but flips groups of 4 pixels. Almost sure it// does not work. Might be a good idea to test this, but it will probably// be easier to do it with the _Rot interface, or only to remove these// functions completely and replace them by 16x16 drawing...#define HANDLE_8_PIXELS_FLIPY( base )					\	movl	base(%esi),%eax	;					\	movl	base+4(%esi),%ebx;					\									\	/* Still 3 instructions for 1 pixel (see 16bpp) */		\	/* Actually that's a little more because of the bswaps... */	\									\	movb	%al,%dl	;						\	movb	(%ecx,%edx,1),%al ;					\	movb	%bl,%dl	;						\	movb	(%ecx,%edx,1),%bl ;					\	movb	%ah,%dl	;						\	movb	(%ecx,%edx,1),%ah ;					\	movb	%bh,%dl	;						\	movb	(%ecx,%edx,1),%bh ;					\									\	bswap	%eax		;					\	bswap	%ebx		;					\									\	movb	%al,%dl	;						\	movb	(%ecx,%edx,1),%al ;					\	movb	%bl,%dl	;						\	movb	(%ecx,%edx,1),%bl ;					\	movb	%ah,%dl	;						\	movb	(%ecx,%edx,1),%ah ;					\	movb	%bh,%dl	;						\	movb	(%ecx,%edx,1),%bh ;					\									\	bswap	%eax		;					\	bswap	%ebx		;					\									\	movl	%eax,60-base(%edi);					\	movl	%ebx,56-base(%edi)	;			//void Draw64x64_Mapped(UINT8 *SPR, int x, int y, UINT8 *cmap)FUNC( Draw64x64_Mapped )	pushl	%ebp	pushl	%edi	pushl	%esi	pushl	%ebx	pushl	%ecx	// A nice mess to convert to 16bpp with all these registers !	// Yes let's remove these and use Draw16x16 instead !!!		movl	24(%esp),%esi			// source	movl	32(%esp),%eax			// y	sall	$2,%eax	movl	0xDEADBEEF(%eax),%ediblin_00:	movl	36(%esp),%ecx			// cmap	addl	28(%esp),%edi			// +x 	xorl	%edx,%edx	movl	$64,%ebp	// Tile Height	jmp	loop0		// Alignement.align	8loop0:	HANDLE_8_PIXELS(0)	HANDLE_8_PIXELS(8)	HANDLE_8_PIXELS(16)	HANDLE_8_PIXELS(24)	HANDLE_8_PIXELS(32)	HANDLE_8_PIXELS(40)	HANDLE_8_PIXELS(48)	HANDLE_8_PIXELS(56)	addl	$64,%esi		/* Next Tile Line */	addl	$0xdeadbeef,%edi	/* Next Screen Line */bitw_00:	decl	%ebp	jne	loop0	popl	%ecx	popl	%ebx	popl	%esi	popl	%edi	popl	%ebp	ret	//void Draw64x64_Mapped_FlipY(UINT8 *SPR, int x, int y, UINT8 *cmap)// Exactly the same function as before. It just uses another macro...	FUNC( Draw64x64_Mapped_FlipY )	pushl	%ebp	pushl	%edi	pushl	%esi	pushl	%ebx	pushl	%ecx	movl	24(%esp),%esi			// source	movl	32(%esp),%eax			// y	sall	$2,%eax	movl	0xDEADBEEF(%eax),%ediblin_01:	movl	36(%esp),%ecx			// cmap	addl	28(%esp),%edi			// +x 	xorl	%edx,%edx	movl	$64,%ebp	// Tile Height	jmp	loop1		// Alignement.align	8loop1:	HANDLE_8_PIXELS_FLIPY(0)	HANDLE_8_PIXELS_FLIPY(8)	HANDLE_8_PIXELS_FLIPY(16)	HANDLE_8_PIXELS_FLIPY(24)	HANDLE_8_PIXELS_FLIPY(32)	HANDLE_8_PIXELS_FLIPY(40)	HANDLE_8_PIXELS_FLIPY(48)	HANDLE_8_PIXELS_FLIPY(56)	addl	$64,%esi		/* Next Tile Line */	addl	$0xdeadbeef,%edi	/* Next Screen Line */bitw_01:	decl	%ebp	jne	loop1	popl	%ecx	popl	%ebx	popl	%esi	popl	%edi	popl	%ebp	ret// void Draw64x64_Mapped_FlipX(UINT8 *SPR, int x, int y, UINT8 *cmap)// This time we use the first macro, but we put the results backwards in the// screen buffer...	FUNC( Draw64x64_Mapped_FlipX )	pushl	%ebp	pushl	%edi	pushl	%esi	pushl	%ebx	pushl	%ecx		movl	24(%esp),%esi			// source	movl	32(%esp),%eax			// y	sall	$2,%eax	movl	0xDEADBEEF(%eax),%edi	// This time we start at the endblin_02:	movl	36(%esp),%ecx			// cmap	addl	28(%esp),%edi			// +x 	xorl	%edx,%edx	movl	$64,%ebp	// Tile Height	jmp	loop2		// Alignement.align	8loop2:	HANDLE_8_PIXELS(0)	HANDLE_8_PIXELS(8)	HANDLE_8_PIXELS(16)	HANDLE_8_PIXELS(24)	HANDLE_8_PIXELS(32)	HANDLE_8_PIXELS(40)	HANDLE_8_PIXELS(48)	HANDLE_8_PIXELS(56)	addl	$64,%esi		/* Next Tile Line */	subl	$0xdeadbeef,%edi	/* prev Screen Line */bitw_02:	decl	%ebp	jne	loop2	popl	%ecx	popl	%ebx	popl	%esi	popl	%edi	popl	%ebp	ret//void Draw64x64_Mapped_FlipXY(UINT8 *SPR, int x, int y, UINT8 *cmap)// Combination of the 2 last functions : backwards, using the 2nd macro !FUNC( Draw64x64_Mapped_FlipXY )	pushl	%ebp	pushl	%edi	pushl	%esi	pushl	%ebx	pushl	%ecx		movl	24(%esp),%esi			// source	movl	32(%esp),%eax			// y	sall	$2,%eax	movl	0xDEADBEEF(%eax),%edi	// This time we start at the endblin_03:	movl	36(%esp),%ecx			// cmap	addl	28(%esp),%edi			// +x 	xorl	%edx,%edx	movl	$64,%ebp	// Tile Height	jmp	loop3		// Alignement.align	8loop3:		HANDLE_8_PIXELS_FLIPY(0)	HANDLE_8_PIXELS_FLIPY(8)	HANDLE_8_PIXELS_FLIPY(16)	HANDLE_8_PIXELS_FLIPY(24)	HANDLE_8_PIXELS_FLIPY(32)	HANDLE_8_PIXELS_FLIPY(40)	HANDLE_8_PIXELS_FLIPY(48)	HANDLE_8_PIXELS_FLIPY(56)	addl	$64,%esi		/* Next Tile Line */	subl	$0xdeadbeef,%edi	/* prev Screen Line */bitw_03:	decl	%ebp	jne	loop3	popl	%ecx	popl	%ebx	popl	%esi	popl	%edi	popl	%ebp	ret/********************************************************************/// Transparency. This requires 2 new macros.// The screen is filled byte per byte now...#define HANDLE_8_PIXELS_TRANSP(base) \	movl	base(%esi),%eax	;		\	movl	base+4(%esi),%ebx ;		\						\	cmpb	%dh,%al		;  /* 0 ? */	\	je	7f		;		\	movb	%al,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,base(%edi)	;		\7:	cmpb	%dh,%bl		;		\	je	7f		;		\	movb	%bl,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,base+4(%edi);		\7:	cmpb	%dh,%ah		;		\	je	7f		;		\	movb	%ah,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,base+1(%edi);		\7:	cmpb	%dh,%bh		;		\	je	7f		;		\	movb	%bh,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,base+5(%edi) ;		\7:						\	shr	$16,%eax	;		\	shr	$16,%ebx	;		\						\	cmpb	%dh,%al		;		\	je	7f		;		\	movb	%al,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,base+2(%edi) ;		\7:	cmpb	%dh,%bl		;		\	je	7f		;		\	movb	%bl,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,base+6(%edi) ;		\7:	cmpb	%dh,%ah		;		\	je	7f		;		\	movb	%ah,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,base+3(%edi) ;		\7:	cmpb	%dh,%bh		;		\	je	7f		;		\	movb	%bh,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,base+7(%edi) ;		\7:// flipy : the same but from 63 to 0#define HANDLE_8_PIXELS_TRANSP_FLIPY(base) \	movl	base(%esi),%eax	;		\	movl	base+4(%esi),%ebx ;		\						\	cmpb	%dh,%al		;  /* 0 ? */	\	je	7f		;		\	movb	%al,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,63-base(%edi)	;		\7:	cmpb	%dh,%bl		;		\	je	7f		;		\	movb	%bl,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,63-4-base(%edi);		\7:	cmpb	%dh,%ah		;		\	je	7f		;		\	movb	%ah,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,63-1-base(%edi);		\7:	cmpb	%dh,%bh		;		\	je	7f		;		\	movb	%bh,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,63-5-base(%edi) ;		\7:						\	shr	$16,%eax	;		\	shr	$16,%ebx	;		\						\	cmpb	%dh,%al		;		\	je	7f		;		\	movb	%al,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,63-2-base(%edi) ;		\7:	cmpb	%dh,%bl		;		\	je	7f		;		\	movb	%bl,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,63-6-base(%edi) ;		\7:	cmpb	%dh,%ah		;		\	je	7f		;		\	movb	%ah,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,63-base-3(%edi) ;		\7:	cmpb	%dh,%bh		;		\	je	7f		;		\	movb	%bh,%dl		;		\	movb	(%ecx,%edx,1),%al ;		\	movb	%al,63-base-7(%edi) ;		\7:		//void Draw64x64_Trans_Mapped(UINT8 *SPR, int x, int y, UINT8 *cmap)FUNC( Draw64x64_Trans_Mapped )	pushl	%ebp	pushl	%edi	pushl	%esi	pushl	%ebx	pushl	%ecx		movl	24(%esp),%esi			// source	movl	32(%esp),%eax			// y	sall	$2,%eax	movl	0xDEADBEEF(%eax),%ediblin_10:	movl	36(%esp),%ecx			// cmap	addl	28(%esp),%edi			// +x 	xorl	%edx,%edx	movl	$64,%ebp	// Tile Height	jmp	loop10		// Alignement.align	8loop10:	HANDLE_8_PIXELS_TRANSP(0)	HANDLE_8_PIXELS_TRANSP(8)	HANDLE_8_PIXELS_TRANSP(16)	HANDLE_8_PIXELS_TRANSP(24)	HANDLE_8_PIXELS_TRANSP(32)	HANDLE_8_PIXELS_TRANSP(40)	HANDLE_8_PIXELS_TRANSP(48)	HANDLE_8_PIXELS_TRANSP(56)	addl	$64,%esi		/* Next Tile Line */	addl	$0xdeadbeef,%edi	/* Next Screen Line */bitw_10:	decl	%ebp	jne	loop10	popl	%ecx	popl	%ebx	popl	%esi	popl	%edi	popl	%ebp	ret//void Draw64x64_Trans_Mapped_FlipY(UINT8 *SPR, int x, int y, UINT8 *cmap)FUNC( Draw64x64_Trans_Mapped_FlipY )	pushl	%ebp	pushl	%edi	pushl	%esi	pushl	%ebx	pushl	%ecx		movl	24(%esp),%esi			// source	movl	32(%esp),%eax			// y	sall	$2,%eax	movl	0xDEADBEEF(%eax),%ediblin_11:	movl	36(%esp),%ecx			// cmap	addl	28(%esp),%edi			// +x 	xorl	%edx,%edx	movl	$64,%ebp	// Tile Height	jmp	loop11		// Alignement.align	8loop11:	HANDLE_8_PIXELS_TRANSP_FLIPY(0)	HANDLE_8_PIXELS_TRANSP_FLIPY(8)	HANDLE_8_PIXELS_TRANSP_FLIPY(16)	HANDLE_8_PIXELS_TRANSP_FLIPY(24)	HANDLE_8_PIXELS_TRANSP_FLIPY(32)	HANDLE_8_PIXELS_TRANSP_FLIPY(40)	HANDLE_8_PIXELS_TRANSP_FLIPY(48)	HANDLE_8_PIXELS_TRANSP_FLIPY(56)	addl	$64,%esi		/* Next Tile Line */	addl	$0xdeadbeef,%edi	/* Next Screen Line */bitw_11:	decl	%ebp	jne	loop11	popl	%ecx	popl	%ebx	popl	%esi	popl	%edi	popl	%ebp	ret	// void Draw64x64_Trans_Mapped_FlipX(UINT8 *SPR, int x, int y, UINT8 *cmap)FUNC( Draw64x64_Trans_Mapped_FlipX )	pushl	%ebp	pushl	%edi	pushl	%esi	pushl	%ebx	pushl	%ecx		movl	24(%esp),%esi			// source	movl	32(%esp),%eax			// y	sall	$2,%eax	movl	0xDEADBEEF(%eax),%edi	// This time we start at the endblin_12:	movl	36(%esp),%ecx			// cmap	addl	28(%esp),%edi			// +x 	xorl	%edx,%edx	movl	$64,%ebp	// Tile Height	jmp	loop12		// Alignement

⌨️ 快捷键说明

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