📄 rotate.asm
字号:
/*****************************************************************
** 函数名:Rotate
** 输 入: float angle,float Ox,float Oy
** angle---要旋转的角度,单位是弧度
** Ox---旋转轴心的横坐标
** Oy---旋转轴心的纵坐标
** 输 出: 无
** 功能描述:将待旋转的点逐点绕[Ox,Oy]旋转angle度
** 全局变量:_g_nNumOfRotatedResult;_g_nNumOfRotatedResult;
** 调用模块:cos(),sin()
** 作 者:
** 日 期:2003.01.29
** 修 改:
** 日 期:2003.04.22
** 版 本:正确,未优化
****************************************************************/
#include "hddamacros.h"
#include <asm_sprt.h>
#include "def21160.h"
.extern _sinf;
.extern _cosf;
.extern _g_nNumOfRotatedResult;
.extern _g_nNumOfToBeRotated;
.extern _g_nRotatedResult;
//void Rotate(float angle,float Ox,float Oy);
.SECTION/PM seg_pmco;
.GLOBAL _Rotate;
_Rotate:
entry;
save_reg;
r5=dm(_g_nNumOfToBeRotated);//if numoftoberotated==0 return
r5=pass r5;
if le jump _Rotate_End;
// f6=cos();angle is in f4;
//如果加上下面两句,则angle的单位变为以角度来表示
// f3=PI_180;
// f4=f3*f4;
f3=f4;//save the angle for sin
f14=f8;//save Ox,Oy because cos() and sin() will use the f8,f12
f15=f12;
r2=i6;
i6=i7;
jump _cosf(db);
dm(i7,m7)=r2;
dm(i7,m7)=pc;
f6=f0;
// f7=sin();
f4=f3;
r2=i6;
i6=i7;
jump _sinf(db);
dm(i7,m7)=r2;
dm(i7,m7)=pc;
f7=f0;
f8=f14;
f12=f15;
r0=_g_nRotatedResult;//get the address of output area
r1=dm(_g_nNumOfRotatedResult);
r3=7;
r2=r1*r3(ssi);
r0=r0+r2;
i4=r0;m4=4;
r2=r5+r1;
dm(_g_nNumOfRotatedResult)=r2;
r14=255;f15=float r14;
lcntr=r5,do _rotateloop until lce;
r0=dm(i4,m6);//r0=x
f0=float r0;
f0=f0-f8,r1=dm(i4,m7);//r1=y,f0=x-Ox
f1=float r1;
f1=f1-f12;//f1=y-Oy
f11=f0*f6;//cos()*(x-Ox)
f13=f1*f7;//sin()*(y-Oy)
f4=f11+f13;//new x=cos()*(x-Ox)+sin()*(y-Oy)+Ox
f4=f4+f8;
f2=f0*f7;//sin()*(x-Ox)
f3=f1*f6;//cos()*(y-Oy)
f5=f3-f2;//new y=cos()*(y-Oy)-sin()*(x-Ox)+Oy
f5=f5+f12;
r0=trunc f4;//new int x
r1=trunc f5;//new int y
f2=float r0;
f3=float r1;
f2=f4-f2;//fraction x
f3=f5-f3;//fraction y
f4=f2*f15;//f4=f2*256.0 right
f5=f3*f15;//f5=f3*256.0 down
f2=f4*f3;//f2=f2*f3*256.0 right down
r4=trunc f4,dm(i4,m6)=r0;
r5=trunc f5,dm(i4,5)=r1;
r2=trunc f2;
r3=r5-r2,dm(i4,m7)=r2;
r4=r4-r2,dm(i4,m7)=r3;
r5=r14-r2,dm(i4,m7)=r4;//r5=256-r2-r3-r4
r5=r5-r3;
r5=r5-r4;
dm(i4,4)=r5;
_rotateloop:
nop;
_Rotate_End:
r1=r5-r5;
dm(_g_nNumOfToBeRotated)=r1;
restore_reg;
exit;
_Rotate.end:
/*half optimized
.SECTION/PM seg_pmco;
.GLOBAL _Rotate;
_Rotate:
entry;
save_reg;
r5=dm(_g_nNumOfToBeRotated);//if numoftoberotated==0 return
r5=pass r5;
if eq jump _Rotate_End;
// f6=cos();angle is in f4;
f3=f4;//save the angle for sin
f14=f8;//save Ox,Oy because cos() and sin() will use the f8,f12
f15=f12;
r2=i6;
i6=i7;
jump _cosf(db);
dm(i7,m7)=r2;
dm(i7,m7)=pc;
f6=f0;
// f7=sin();
f4=f3;
r2=i6;
i6=i7;
jump _sinf(db);
dm(i7,m7)=r2;
dm(i7,m7)=pc;
f7=f0;
f8=f14;
f12=f15;
r0=_g_nRotatedResult;//get the address of output area
r1=dm(_g_nNumOfRotatedResult);
r3=7;
r2=r1*r3(ssi);
r0=r0+r2;
i4=r0;
r2=r5+r1;
dm(_g_nNumOfRotatedResult)=r2;
r1=r5-r5;
dm(_g_nNumOfToBeRotated)=r1;
r14=255;
f15=float r14,r0=dm(i4,m6);//r0=x
f0=float r0;
//loop start
lcntr=r5,do _rotateloop until lce;
f0=f0-f8,r1=dm(i4,m7);//r1=y,f0=x-Ox
f9=float r1;
f11=f0*f6,f1=f9-f12;//f1=y-Oy//cos()*(x-Ox)
f13=f1*f7;//sin()*(y-Oy)
f2=f0*f7,f13=f11+f13;//f2=sin()*(x-Ox)
//f4=new x=cos()*(x-Ox)+sin()*(y-Oy)+Ox
f3=f1*f6,f4=f8+f13;//cos()*(y-Oy)
f5=f3-f2;//new y=cos()*(y-Oy)-sin()*(x-Ox)+Oy
f5=f5+f12;
r0=trunc f4;//new int x
r1=trunc f5;//new int y
f2=float r0,dm(i4,m6)=r0;
f3=float r1,dm(i4,6)=r1;
f2=f4-f2,r0=dm(i4,m7);//fraction x//r0=x
f3=f5-f3;//fraction y
f4=f2*f15;//f4=f2*256.0 right
f5=f3*f15;//f5=f3*256.0 down
f2=f4*f3;//f2=f2*f3*256.0 right down
r4=trunc f4;
r5=trunc f5;
r2=trunc f2;
r3=r5-r2,dm(i4,m7)=r2;
r4=r4-r2,dm(i4,m7)=r3;
r5=r14-r2,dm(i4,m7)=r4;//r5=256-r2-r3-r4
r5=r5-r3;
r5=r5-r4;
_rotateloop:
f0=float r0,dm(i4,5)=r5;
_Rotate_End:
restore_reg;
exit;
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -