-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsparrowPrimitivesAsm.c
168 lines (166 loc) · 4.05 KB
/
sparrowPrimitivesAsm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* This file is part of sparrow3d.
* Sparrow3d is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Sparrow3d is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>
*
* For feedback and questions about my Files and Projects please mail me,
* Alexander Matthes (Ziz) , zizsdl_at_googlemail.com */
#include "sparrowPrimitivesAsm.h"
#include <stdlib.h>
#ifdef __arm__
PREFIX void spHorizentalLine( Uint16* pixel, Sint32 x, Sint32 y, Sint32 l_, Uint32 color_, Uint32 check, Sint32 engineWindowX, Sint32 engineWindowY )
{
//l_++;
if ( check )
{
if ( y < 0 )
return;
if ( y >= engineWindowY ) //Their is a FUCKING Bug if I write in the last line on the gp2x. Dont know why...
return;
if ( x < 0 )
{
l_ = x + l_;
x = 0;
}
if ( x + l_ >= engineWindowX )
l_ = engineWindowX - x;
if ( l_ <= 0 )
return;
}
register Uint32 pos asm( "r0" );
pos = ( ( x + y * engineWindowX ) << 1 ) + ( Uint32 )pixel;
register Uint32 l asm( "r1" );
l = l_;
register Uint32 color asm( "r2" );
color = color_;
asm volatile( // saving r3-r12 to the stack
"stmfd sp!,{r3-r12} \n\t"
//catching "awkward" laying Halfword at the beginning
"mov r3,%0,lsr #2 \n\t"
"subs r4,%0,r3,asl #2 \n\t"
"beq .all_ok \n\t"
"strh %2,[%0],#2 \n\t"
"subs %1,%1,#1 \n\t"
".all_ok: \n\t"
//if l>=22 then
// jmp twentytwo;
"cmp %1,#22\n\t"
"bge .twentytwo\n\t"
//if l>=12 then
// jmp twelve;
"cmp %1,#12\n\t"
"bge .twelve \n\t"
//if l>=6 then
// jmp six;
"cmp %1,#6\n\t"
"bge .six \n\t"
//else
// jmp thelast;
"bne .thelast\n\t"
//twentytwo:
".twentytwo: \n\t"
// assining r2 on itself, but shifted
"orr %2,%2,%2,lsl #16 \n\t"
// setting r3-r12 to r2
"mov r3,%2 \n\t"
"mov r4,%2 \n\t"
"mov r5,%2 \n\t"
"mov r6,%2 \n\t"
"mov r7,%2 \n\t"
"mov r8,%2 \n\t"
"mov r9,%2 \n\t"
"mov r10,%2 \n\t"
"mov r11,%2 \n\t"
"mov r12,%2 \n\t"
// again22:
".again22: \n\t"
// setting pos til pos+43 to r2-r12
"stmia %0!,{%2,r3-r12} \n\t"
// l-=22;
"subs %1,%1,#22 \n\t"
// if l>=22 then
// jmp again22;
"cmp %1,#22 \n\t"
"bge .again22\n\t"
// if l>=12 then
// jmp again12;
"cmp %1,#12 \n\t"
"bge .again12\n\t"
// if l>=6 then
// jmp again6;
"cmp %1,#6 \n\t"
"bge .again6\n\t"
// else
// jmp thelast;
"bne .thelast\n\t"
" \n\t"
//twelve:
".twelve: \n\t"
// mirroring r2 auf sich selbst spiegeln
"orr %2,%2,%2,lsl #16 \n\t"
// setting r3-r7 to r2
"mov r3,%2 \n\t"
"mov r4,%2 \n\t"
"mov r5,%2 \n\t"
"mov r6,%2 \n\t"
"mov r7,%2 \n\t"
// again12:
".again12: \n\t"
// setting pos..pos+23 to r2-r7
"stmia %0!,{%2,r3-r7} \n\t"
// l-=12;
"subs %1,%1,#12 \n\t"
// if l>=6 then
// jmp again6;
"cmp %1,#6 \n\t"
"bge .again6\n\t"
// else
// jmp thelast;
"bne .thelast\n\t"
" \n\t"
//six:
".six: \n\t"
// mirroring r2 to itself
"orr %2,%2,%2,lsl #16 \n\t"
// setting r3 and r4 to r2
"mov r3,%2 \n\t"
"mov r4,%2 \n\t"
// again6:
".again6: \n\t"
// pos+12 auf r2-r4 setzen
"stmia %0!,{%2,r3-r4} \n\t"
// l-=6;
"subs %1,%1,#6 \n\t"
//thelast:
".thelast: \n\t"
// if l=0 then
// jmp end;
"cmp %1,#0 \n\t"
"beq .end \n\t"
// again:
".again: \n\t"
// Setting color at pos directly and increment
"strh %2,[%0],#2 \n\t"
// l--;
"subs %1,%1,#1 \n\t"
// if l!=0:
// jmp again;
"bne .again \n\t"
//end:
".end: \n\t"
//Poping the registers
"ldmfd sp!,{r3-r12} \n\t"
:
: "r" ( pos ), "r"( l ), "r"( color )
: /*"r3","r4", "r5", "r6", "r7","r8", "r9", "r10", "r11","r12", */"cc" );
}
#endif