📄 3dtesting.s
字号:
.module _3dtesting.c
.area text(rom, con, rel)
.dbfile F:\CODE\LCD1286418\3dtesting.c
.area lit(rom, con, rel)
_aa::
.word 8
.word -8
.word -8
.word 8
.word 8
.word -8
.word -8
.word 8
.word 8
.word 8
.word 8
.word 8
.word 8
.word 0
.word 4
.word -4
.word -8
.word -8
.word -8
.word -8
.word -8
.word -8
.word -8
.dbsym e aa _aa A[46:23]kI
_bb::
.word 8
.word 8
.word -8
.word -8
.word 8
.word 8
.word -8
.word -8
.word 0
.word -4
.word 4
.word -2
.word 2
.word 8
.word 8
.word 8
.word 4
.word 4
.word 4
.word -4
.word -4
.word -4
.word 0
.dbsym e bb _bb A[46:23]kI
_cc::
.word -8
.word -8
.word -8
.word -8
.word 8
.word 8
.word 8
.word 8
.word 6
.word -6
.word -6
.word 0
.word 0
.word -6
.word 6
.word 6
.word -6
.word 0
.word 6
.word 6
.word 0
.word -6
.word 0
.dbsym e cc _cc A[46:23]kI
_ff::
.word 1
.word 2
.word 3
.word 4
.word 5
.word 6
.word 7
.word 8
.word 1
.word 2
.word 3
.word 4
.word 9
.word 9
.word 12
.word 14
.word 14
.word 17
.word 19
.word 20
.word 21
.word 22
.dbsym e ff _ff A[44:22]kI
_gg::
.word 2
.word 3
.word 4
.word 1
.word 6
.word 7
.word 8
.word 5
.word 5
.word 6
.word 7
.word 8
.word 10
.word 11
.word 13
.word 15
.word 16
.word 19
.word 20
.word 21
.word 18
.word 23
.dbsym e gg _gg A[44:22]kI
.area data(ram, con, rel)
.dbfile F:\CODE\LCD1286418\3dtesting.c
_rotx::
.blkb 4
.area idata
.word 0x0,0x0
.area data(ram, con, rel)
.dbfile F:\CODE\LCD1286418\3dtesting.c
.dbsym e rotx _rotx D
_roty::
.blkb 4
.area idata
.word 0x0,0x0
.area data(ram, con, rel)
.dbfile F:\CODE\LCD1286418\3dtesting.c
.dbsym e roty _roty D
_rotz::
.blkb 4
.area idata
.word 0x0,0x0
.area data(ram, con, rel)
.dbfile F:\CODE\LCD1286418\3dtesting.c
.dbsym e rotz _rotz D
.area text(rom, con, rel)
.dbfile F:\CODE\LCD1286418\3dtesting.c
.dbfunc e cube _cube fV
; loop -> <dead>
; cosaz -> y+142
; sinaz -> y+138
; cosay -> y+134
; sinay -> y+130
; cosax -> y+126
; sinax -> y+122
; zt -> y+118
; yt -> y+114
; xt -> y+110
; newy -> y+64
; newx -> y+18
; y -> y+14
; x -> y+10
; z -> y+6
; vertex -> R22,R23
; i -> y+146
; zpos -> y+166
; ypos -> y+162
; xpos -> y+158
.even
_cube::
xcall push_arg4
xcall push_xgsetF0FC
sbiw R28,63
sbiw R28,63
sbiw R28,22 ; offset = 148
.dbline -1
.dbline 31
; #include <iom128v.h>
; #include "avr.h"
; #include "math.h"
;
; #define OFFSETX 63
; #define OFFSETY 31
; #define OFFSETZ 31
;
; /////////////////////////////////立方体加文字//////////////////////////////////////////////////
; const signed int aa[23]={8,-8,-8,8,8,-8,-8,8,8,8,8,8,8,0,4,-4,-8,-8,-8,-8,-8,-8,-8}; // x data for shape vertex
; const signed int bb[23]={8,8,-8,-8,8,8,-8,-8,0,-4,4,-2,2,8,8,8,4,4,4,-4,-4,-4,0}; // y data for shape vertex
; const signed int cc[23]={-8,-8,-8,-8,8,8,8,8,6,-6,-6,0,0,-6,6,6,-6,0,6,6,0,-6,0}; // z data for shape vertex
;
; const int ff[22]={1,2,3,4,5,6,7,8,1,2,3,4,9,9,12,14,14,17,19,20,21,22}; // start vertex for lines
; const int gg[22]={2,3,4,1,6,7,8,5,5,6,7,8,10,11,13,15,16,19,20,21,18,23}; // end vertex for lines
; //////////////////////////////////////////////////////////////////////////////////////////////
;
; extern unsigned char displaybuffer[8][128];
; int sx,sy,ex,ey; // define global vars for calling graphics subroutines
; float rotx=0.0; // starting amount of x rotation
; float roty=0.0; // starting amount of y rotation
; float rotz=0.0; // starting amount of z rotation
;
; void cube (float xpos,float ypos,float zpos); // define the subroutines this one is the actual cube routine
;
; /***************************************
; * FUNCTION NAME: cube
; * DESCRIPTION: 3d-cube显示
; /***************************************/
; void cube(float xpos,float ypos,float zpos) // routine to draw and calc 3d cube
; {
.dbline 44
; int newx[23]; // translated screen x co-ordinates for vertex
; int newy[23]; // translated screen y co-ordinates for vertex
; int i,loop; // temp variable for loops
; int vertex;
; float xt,yt,zt,x,y,z,sinax,cosax,sinay,cosay,sinaz,cosaz; // lots of work variables
; //float xpos=0.0; // position for object in 3d space, in x
; //float ypos=0.0; // y
; //float zpos=0.0; // and z values
; //float rotx=0.0; // starting amount of x rotation
; //float roty=0.0; // starting amount of y rotation
; //float rotz=0.0; // starting amount of z rotation
;
; xpos=xpos+0.0; // move the object
movw R26,R28
subi R26,98 ; addi 158
sbci R27,255
ld R2,x+
ld R3,x+
ld R4,x+
ld R5,x
ldi R16,<L2
ldi R17,>L2
xcall elpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpadd2
movw R26,R28
subi R26,98 ; addi 158
sbci R27,255
st x+,R16
st x+,R17
st x+,R18
st x,R19
.dbline 45
; ypos=ypos+0.0; // it would wander off screen
movw R26,R28
subi R26,94 ; addi 162
sbci R27,255
ld R2,x+
ld R3,x+
ld R4,x+
ld R5,x
ldi R16,<L2
ldi R17,>L2
xcall elpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpadd2
movw R26,R28
subi R26,94 ; addi 162
sbci R27,255
st x+,R16
st x+,R17
st x+,R18
st x,R19
.dbline 46
; zpos=zpos+0.0; // really quick, so leave it centered
movw R26,R28
subi R26,90 ; addi 166
sbci R27,255
ld R2,x+
ld R3,x+
ld R4,x+
ld R5,x
ldi R16,<L2
ldi R17,>L2
xcall elpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpadd2
movw R30,R28
subi R30,90 ; addi 166
sbci R31,255
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 48
;
; rotx=rotx+0.02; // rotate the cube on X axis
lds R4,_rotx+2
lds R5,_rotx+2+1
lds R2,_rotx
lds R3,_rotx+1
ldi R16,<L3
ldi R17,>L3
xcall elpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpadd2
sts _rotx+1,R17
sts _rotx,R16
sts _rotx+2+1,R19
sts _rotx+2,R18
.dbline 49
; roty=roty+0.03; // and on its y axis
lds R4,_roty+2
lds R5,_roty+2+1
lds R2,_roty
lds R3,_roty+1
ldi R16,<L4
ldi R17,>L4
xcall elpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpadd2
sts _roty+1,R17
sts _roty,R16
sts _roty+2+1,R19
sts _roty+2,R18
.dbline 50
; rotz=rotz+0.01; // dont bother with z or it gets confusing
lds R4,_rotz+2
lds R5,_rotz+2+1
lds R2,_rotz
lds R3,_rotz+1
ldi R16,<L5
ldi R17,>L5
xcall elpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpadd2
sts _rotz+1,R17
sts _rotz,R16
sts _rotz+2+1,R19
sts _rotz+2,R18
.dbline 52
;
; sinax=sin(rotx); // precalculate the sin and cos values
lds R18,_rotx+2
lds R19,_rotx+2+1
lds R16,_rotx
lds R17,_rotx+1
xcall _sinf
movw R30,R28
subi R30,134 ; addi 122
sbci R31,255
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 53
; cosax=cos(rotx); // for the rotation as this saves a
lds R18,_rotx+2
lds R19,_rotx+2+1
lds R16,_rotx
lds R17,_rotx+1
xcall _cosf
movw R30,R28
subi R30,130 ; addi 126
sbci R31,255
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 55
;
; sinay=sin(roty); // little time when running as we
lds R18,_roty+2
lds R19,_roty+2+1
lds R16,_roty
lds R17,_roty+1
xcall _sinf
movw R30,R28
subi R30,126 ; addi 130
sbci R31,255
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 56
; cosay=cos(roty); // call sin and cos less often
lds R18,_roty+2
lds R19,_roty+2+1
lds R16,_roty
lds R17,_roty+1
xcall _cosf
movw R30,R28
subi R30,122 ; addi 134
sbci R31,255
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 58
;
; sinaz=sin(rotz); // they are slow routines
lds R18,_rotz+2
lds R19,_rotz+2+1
lds R16,_rotz
lds R17,_rotz+1
xcall _sinf
movw R30,R28
subi R30,118 ; addi 138
sbci R31,255
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 59
; cosaz=cos(rotz); // and we dont want slow!
lds R18,_rotz+2
lds R19,_rotz+2+1
lds R16,_rotz
lds R17,_rotz+1
xcall _cosf
movw R30,R28
subi R30,114 ; addi 142
sbci R31,255
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 61
;
; for (i=0; i<23; i++) // translate 3d vertex position to 2d screen position
clr R0
clr R1
movw R30,R28
subi R30,110 ; addi 146
sbci R31,255
std z+1,R1
std z+0,R0
L6:
.dbline 62
; {
.dbline 63
; x=aa[i]; // get x for vertex i
ldi R24,<_aa
ldi R25,>_aa
movw R26,R28
subi R26,110 ; addi 146
sbci R27,255
ld R30,x+
ld R31,x
lsl R30
rol R31
add R30,R24
adc R31,R25
elpm R16,Z+
elpm R17,Z
xcall int2fp
std y+10,R16
std y+11,R17
std y+12,R18
std y+13,R19
.dbline 64
; y=bb[i]; // get y for vertex i
ldi R24,<_bb
ldi R25,>_bb
movw R26,R28
subi R26,110 ; addi 146
sbci R27,255
ld R30,x+
ld R31,x
lsl R30
rol R31
add R30,R24
adc R31,R25
elpm R16,Z+
elpm R17,Z
xcall int2fp
std y+14,R16
std y+15,R17
std y+16,R18
std y+17,R19
.dbline 65
; z=cc[i]; // get z for vertex i
ldi R24,<_cc
ldi R25,>_cc
movw R26,R28
subi R26,110 ; addi 146
sbci R27,255
ld R30,x+
ld R31,x
lsl R30
rol R31
add R30,R24
adc R31,R25
elpm R16,Z+
elpm R17,Z
xcall int2fp
std y+6,R16
std y+7,R17
std y+8,R18
std y+9,R19
.dbline 67
;
; yt = y * cosax - z * sinax; // rotate around the x axis
ldd R16,y+14
ldd R17,y+15
ldd R18,y+16
ldd R19,y+17
movw R24,R28
subi R24,130 ; offset = 126
sbci R25,255
st -y,R25
st -y,R24
xcall fpmule1
movw R2,R16
movw R4,R18
ldd R16,y+6
ldd R17,y+7
ldd R18,y+8
ldd R19,y+9
movw R24,R28
subi R24,134 ; offset = 122
sbci R25,255
st -y,R25
st -y,R24
xcall fpmule1x
movw R16,R2
movw R18,R4
xcall fpsub2
movw R26,R28
subi R26,142 ; addi 114
sbci R27,255
st x+,R16
st x+,R17
st x+,R18
st x,R19
.dbline 68
; zt = y * sinax + z * cosax; // using the Y and Z for the rotation
ldd R16,y+14
ldd R17,y+15
ldd R18,y+16
ldd R19,y+17
movw R24,R28
subi R24,134 ; offset = 122
sbci R25,255
st -y,R25
st -y,R24
xcall fpmule1
movw R2,R16
movw R4,R18
ldd R16,y+6
ldd R17,y+7
ldd R18,y+8
ldd R19,y+9
movw R24,R28
subi R24,130 ; offset = 126
sbci R25,255
st -y,R25
st -y,R24
xcall fpmule1x
movw R16,R2
movw R18,R4
xcall fpadd2
movw R26,R28
subi R26,138 ; addi 118
sbci R27,255
st x+,R16
st x+,R17
st x+,R18
st x,R19
.dbline 69
; y = yt;
movw R26,R28
subi R26,142 ; addi 114
sbci R27,255
ld R2,x+
ld R3,x+
ld R4,x+
ld R5,x
std y+14,R2
std y+15,R3
std y+16,R4
std y+17,R5
.dbline 70
; z = zt;
movw R26,R28
subi R26,138 ; addi 118
sbci R27,255
ld R2,x+
ld R3,x+
ld R4,x+
ld R5,x
std y+6,R2
std y+7,R3
std y+8,R4
std y+9,R5
.dbline 72
;
; xt = x * cosay - z * sinay; // rotate around the Y axis
ldd R16,y+10
ldd R17,y+11
ldd R18,y+12
ldd R19,y+13
movw R24,R28
subi R24,122 ; offset = 134
sbci R25,255
st -y,R25
st -y,R24
xcall fpmule1
movw R2,R16
movw R4,R18
ldd R16,y+6
ldd R17,y+7
ldd R18,y+8
ldd R19,y+9
movw R24,R28
subi R24,126 ; offset = 130
sbci R25,255
st -y,R25
st -y,R24
xcall fpmule1x
movw R16,R2
movw R18,R4
xcall fpsub2
movw R26,R28
subi R26,146 ; addi 110
sbci R27,255
st x+,R16
st x+,R17
st x+,R18
st x,R19
.dbline 73
; zt = x * sinay + z * cosay; // using X and Z
ldd R16,y+10
ldd R17,y+11
ldd R18,y+12
ldd R19,y+13
movw R24,R28
subi R24,126 ; offset = 130
sbci R25,255
st -y,R25
st -y,R24
xcall fpmule1
movw R2,R16
movw R4,R18
ldd R16,y+6
ldd R17,y+7
ldd R18,y+8
ldd R19,y+9
movw R24,R28
subi R24,122 ; offset = 134
sbci R25,255
st -y,R25
st -y,R24
xcall fpmule1x
movw R16,R2
movw R18,R4
xcall fpadd2
movw R26,R28
subi R26,138 ; addi 118
sbci R27,255
st x+,R16
st x+,R17
st x+,R18
st x,R19
.dbline 74
; x = xt;
movw R26,R28
subi R26,146 ; addi 110
sbci R27,255
ld R2,x+
ld R3,x+
ld R4,x+
ld R5,x
std y+10,R2
std y+11,R3
std y+12,R4
std y+13,R5
.dbline 75
; z = zt;
movw R26,R28
subi R26,138 ; addi 118
sbci R27,255
ld R2,x+
ld R3,x+
ld R4,x+
ld R5,x
std y+6,R2
std y+7,R3
std y+8,R4
std y+9,R5
.dbline 77
;
; xt = x * cosaz - y * sinaz; // finaly rotate around the Z axis
ldd R16,y+10
ldd R17,y+11
ldd R18,y+12
ldd R19,y+13
movw R24,R28
subi R24,114 ; offset = 142
sbci R25,255
st -y,R25
st -y,R24
xcall fpmule1
movw R2,R16
movw R4,R18
ldd R16,y+14
ldd R17,y+15
ldd R18,y+16
ldd R19,y+17
movw R24,R28
subi R24,118 ; offset = 138
sbci R25,255
st -y,R25
st -y,R24
xcall fpmule1x
movw R16,R2
movw R18,R4
xcall fpsub2
movw R26,R28
subi R26,146 ; addi 110
sbci R27,255
st x+,R16
st x+,R17
st x+,R18
st x,R19
.dbline 78
; yt = x * sinaz + y * cosaz; // using X and Y
ldd R16,y+10
ldd R17,y+11
ldd R18,y+12
ldd R19,y+13
movw R24,R28
subi R24,118 ; offset = 138
sbci R25,255
st -y,R25
st -y,R24
xcall fpmule1
movw R2,R16
movw R4,R18
ldd R16,y+14
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -