易码技术论坛

 找回密码
 加入易码
搜索
查看: 508502|回复: 12

[源码] [求助]circle和ellipse的汇编代码

[复制链接]
发表于 2007-6-25 16:34:43 | 显示全部楼层
这里有我以前发的一些图形相关的汇编代码:
http://emsky.net/bbs/read.php?tid=14591
里面有画圆的代码
发表于 2007-6-25 16:36:17 | 显示全部楼层
;-----------------------------------------------------------------------  
;作圆

CircleA:  .MACRO x,y,r,type
  LDA #x
  STA Graph_x1
  LDA #y
  STA Graph_y1
  LDA #r
  STA GraphType
  int m_CircleA
    .ENDM
   
CircleB:  .MACRO x,y,r,type
  LDA #x
  STA Graph_x1
  LDA #y
  STA Graph_y1
  LDA #r
  STA GraphType
  int m_CircleB
    .ENDM
   
;-----------------------------------------------------------------------
;作椭圆

EllipseA:  .MACRO x,y,a,b,type
  LDA #x
  STA Graph_x1
  LDA #y
  STA Graph_y1
  LDA #a
  STA Graph_a
  LDA #b
  STA Graph_b
  LDA #type
  STA GraphType
  int m_EllipseA
    .ENDM
   
EllipseB:  .MACRO x,y,a,b,type
  LDA x
  STA Graph_x1
  LDA y
  STA Graph_y1
  LDA a
  STA Graph_a
  LDA b
  STA Graph_b
  LDA type
  STA GraphType
  int m_EllipseB
    .ENDM

;-----------------------------------------------------------------------
发表于 2007-6-25 16:36:53 | 显示全部楼层
发出来了.
发表于 2007-6-25 16:38:23 | 显示全部楼层
楼上用的是系统中断,楼主要原生的代码.
发表于 2007-6-25 16:40:12 | 显示全部楼层
记得NC3000上有直接可以用的画圆和椭圆的中断,可以直接调用的.

NC3000.rar

3 KB, 下载次数: 245

发表于 2007-6-25 16:41:02 | 显示全部楼层
哦,那就直接反一下中断好了.
 楼主| 发表于 2007-6-25 16:55:28 | 显示全部楼层
谢谢啦。
 楼主| 发表于 2007-6-25 18:48:54 | 显示全部楼层
Eastsun的代码只有circle函数?
发表于 2007-6-25 22:10:35 | 显示全部楼层
NC3000.h
晕~我原先竟然没想到!做一个这样的文件对写程序很有用~~
哦……又跑题了!
---------------------------
yan还要ellipse的代码!
发表于 2007-6-25 22:57:49 | 显示全部楼层
引用第9楼POTO2007-06-25 22:10发表的“”:
NC3000.h
晕~我原先竟然没想到!做一个这样的文件对写程序很有用~~
哦……又跑题了!
---------------------------
yan还要ellipse的代码!
这样写程序才比较有条理,呵呵.
发表于 2007-6-26 00:11:37 | 显示全部楼层
引用第8楼yan2007-06-25 18:48发表的“”:
Eastsun的代码只有circle函数?
嗯,因为Circle的简单,:-)
当初为了写这些代码还研究了一番基本图形生成算法.
发表于 2007-6-26 00:13:11 | 显示全部楼层
ellipse有普适性
 楼主| 发表于 2007-6-25 16:29:53 | 显示全部楼层 |阅读模式
本人的汇编太差,写不出来。
哪位高手能将以下的代码用汇编写出来,谢谢了。
void cpoint(int xCenter,int yCenter,int x,int y,int type)
{Point(xCenter+x,yCenter+y,type);
Point(xCenter-x,yCenter+y,type);
Point(xCenter+x,yCenter-y,type);
Point(xCenter-x,yCenter-y,type);
Point(xCenter+y,yCenter+x,type);
Point(xCenter-y,yCenter+x,type);
Point(xCenter+y,yCenter-x,type);
Point(xCenter-y,yCenter-x,type);
}
void circle(int xCenter,int yCenter,int radius,int type)
{int x;
int p;
cpoint(xCenter,yCenter,0,radius,type);
x=0;p=1-radius;
while(x++<radius)
  {if(p<0)p=p+(x<<1)+1;
  else
   {radius--;
    p=p+((x-radius)<<1)+1;
   }
  cpoint(xCenter,yCenter,x,radius,type);
  }
}
void epoint(int xCenter,int yCenter,int x,int y,int type)
{Point(xCenter+x,yCenter+y,type);
Point(xCenter-x,yCenter+y,type);
Point(xCenter+x,yCenter-y,type);
Point(xCenter-x,yCenter-y,type);
}
void ellispe(int xCenter,int yCenter,int Rx,int Ry,int type)
{int Rx2,Ry2;
int twoRx2,twoRy2;
long p;
int x,y;
long px,py;
x=0;px=0;
Rx2=Rx*Rx;Ry2=Ry*Ry;
twoRx2=Rx2<<1;twoRy2=Ry2<<1;
y=Ry;py=twoRx2*y;
epoint(xCenter,yCenter,x,y,type);
p=Ry2-Rx2*Ry+((Rx2+2)>>2);
while(px<py)
  {x++;px=px+twoRy2;
  if(p<0)p=p+Ry2+px;
  else
   {y--;
    py=py-twoRx2;
    p=p+Ry2+px-py;
   }
  epoint(xCenter,yCenter,x,y,type);
  }
p=Ry2*x*x+Ry2*x+Rx2*(y-1)*(y-1)-Rx2*Ry2+((Ry2+2)>>2);
while(y-->0)
  {py=py-twoRx2;
  if(p>0)p=p+Rx2-py;
  else{x++;px=px+twoRy2;p=p+Rx2-py+px;}
  epoint(xCenter,yCenter,x,y,type);
  }
}
您需要登录后才可以回帖 登录 | 加入易码

本版积分规则

Archiver|手机版|小黑屋|EMAX Studio

GMT+8, 2024-3-29 21:22 , Processed in 0.016800 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表