Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Denys Sergeyuk
APO SEM
Commits
193cd20a
Commit
193cd20a
authored
Jun 02, 2021
by
Tom Pastuszek
Browse files
mel by byt funkcni fraktal computation... teoreticky
parent
d739c1de
Changes
6
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
193cd20a
ARCH
=
mips-elf
#ARCH=mips-linux-gnu
SOURCES
=
crt0local.S qtmips_binrep.c display.c
SOURCES
=
crt0local.S qtmips_binrep.c display.c
fractal_computation.c
TARGET_EXE
=
qtmips_binrep
CC
=
$(ARCH)
-gcc
...
...
@@ -25,7 +25,7 @@ LDFLAGS += -static
CFLAGS
+=
$(ARCHFLAGS)
CXXFLAGS
+=
$(ARCHFLAGS)
AFLAGS
+=
$(ARCHFLAGS)
LDFLAGS
+=
$(ARCHFLAGS)
LDFLAGS
+=
$(ARCHFLAGS)
OBJECTS
+=
$(
filter
%.o,
$(SOURCES:%.S=%.o)
)
OBJECTS
+=
$(
filter
%.o,
$(SOURCES:%.c=%.o)
)
...
...
@@ -50,7 +50,7 @@ all : default
default
:
$(TARGET_EXE)
$(TARGET_EXE)
:
$(OBJECTS)
$(CC)
$(LDFLAGS)
$^
-o
$@
$(CC)
$(LDFLAGS)
$^
-o
$@
dep
:
depend
...
...
depend
View file @
193cd20a
...
...
@@ -14,7 +14,8 @@ qtmips_binrep.o: qtmips_binrep.c display.h \
/usr/mips-elf/gcc/7.4.0/lib/include/stddef.h \
/usr/mips-elf/include/sys/_types.h \
/usr/mips-elf/include/machine/_types.h /usr/mips-elf/include/sys/lock.h \
/usr/mips-elf/include/sys/cdefs.h /usr/mips-elf/include/_ansi.h
/usr/mips-elf/include/sys/cdefs.h /usr/mips-elf/include/_ansi.h \
fractal_computation.h
display.o: display.c display.h \
/usr/mips-elf/gcc/7.4.0/lib/include/stdint.h \
/usr/mips-elf/include/stdint.h \
...
...
@@ -30,12 +31,22 @@ fractal_computation.o: fractal_computation.c fractal_computation.h \
/usr/mips-elf/include/sys/features.h \
/usr/mips-elf/include/_newlib_version.h \
/usr/mips-elf/include/sys/_intsup.h /usr/mips-elf/include/sys/_stdint.h \
/usr/mips-elf/include/math
.h /usr/mips-elf/include/s
ys/reent
.h \
display.h periphery
.h /usr/mips-elf/include/s
tdio
.h \
/usr/mips-elf/include/_ansi.h /usr/mips-elf/include/newlib.h \
/usr/mips-elf/include/sys/config.h \
/usr/mips-elf/include/machine/ieeefp.h \
/usr/mips-elf/include/machine/ieeefp.h
/usr/mips-elf/include/sys/cdefs.h
\
/usr/mips-elf/gcc/7.4.0/lib/include/stddef.h \
/usr/mips-elf/gcc/7.4.0/lib/include/stdarg.h \
/usr/mips-elf/include/sys/reent.h /usr/mips-elf/include/_ansi.h \
/usr/mips-elf/include/sys/_types.h \
/usr/mips-elf/include/machine/_types.h /usr/mips-elf/include/sys/lock.h \
/usr/mips-elf/include/sys/cdefs.h /usr/mips-elf/include/_ansi.h \
display.h periphery.h
/usr/mips-elf/include/sys/types.h /usr/mips-elf/include/machine/endian.h \
/usr/mips-elf/include/machine/_endian.h \
/usr/mips-elf/include/sys/select.h /usr/mips-elf/include/sys/_sigset.h \
/usr/mips-elf/include/sys/_timeval.h \
/usr/mips-elf/include/sys/timespec.h \
/usr/mips-elf/include/sys/_timespec.h \
/usr/mips-elf/include/sys/_pthreadtypes.h \
/usr/mips-elf/include/sys/sched.h /usr/mips-elf/include/machine/types.h \
/usr/mips-elf/include/sys/stdio.h /usr/mips-elf/include/stdlib.h \
/usr/mips-elf/include/machine/stdlib.h /usr/mips-elf/include/alloca.h
fractal_computation.c
View file @
193cd20a
#include "fractal_computation.h"
#include "math.h"
#include <stdio.h>
#include <stdlib.h>
extern
video_buff_ptr
video_base
;
float
Q_rsqrt
(
float
number
)
// Quake 3 sqrt implementation
{
long
i
;
float
x2
,
y
;
const
float
threehalfs
=
1
.
5
F
;
x2
=
number
*
0
.
5
F
;
y
=
number
;
i
=
*
(
long
*
)
&
y
;
// evil floating point bit level hacking
i
=
0x5f3759df
-
(
i
>>
1
);
// what the fuck?
y
=
*
(
float
*
)
&
i
;
y
=
y
*
(
threehalfs
-
(
x2
*
y
*
y
)
);
// 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return
y
;
}
int
compute
(
double
z_re
,
double
z_im
,
double
c_re
,
double
c_im
,
int
n
)
{
double
old_re
=
z_re
;
double
old_im
=
z_im
;
...
...
@@ -13,7 +35,9 @@ int compute(double z_re, double z_im, double c_re, double c_im, int n) {
//z_i+1 = z_i^2 + c = re_i^2 + 2*re_i*im_i - im_i^2
new_re
=
(
old_re
*
old_re
)
-
(
old_im
*
old_im
)
+
c_re
;
new_im
=
(
2
*
old_re
*
old_im
)
+
c_im
;
double
z
=
sqrt
(
new_re
*
new_re
+
new_im
*
new_im
);
float
sqr
=
(
float
)(
new_re
*
new_re
+
new_im
*
new_im
);
double
z
=
Q_rsqrt
(
sqr
);
if
(
z
>=
2
){
return
i
;
}
...
...
@@ -23,15 +47,34 @@ int compute(double z_re, double z_im, double c_re, double c_im, int n) {
return
n
;
}
uint16_t
conv_color
(
float
t
){
uint16_t
red
;
uint16_t
green
;
uint16_t
blue
;
void
fractal
(
double
X1
,
double
Y1
,
double
X2
,
double
Y2
,
double
C_x
,
double
C_y
,
int
n
){
double
dec_x
;
double
dec_y
;
red
=
9
*
(
1
-
t
)
*
t
*
t
*
t
*
255
;
green
=
15
*
(
1
-
t
)
*
(
1
-
t
)
*
t
*
t
*
255
;
blue
=
8
.
5
*
(
1
-
t
)
*
(
1
-
t
)
*
(
1
-
t
)
*
t
*
255
;
uint16_t
pixel
=
rgb_pack
(
red
,
green
,
blue
);
return
pixel
;
}
dec_x
=
(
X1
-
X2
)
/
LCD_WIDTH
;
dec_y
=
(
Y1
-
Y2
)
/
LCD_HEIGHT
;
void
fractal
(
double
X1
,
double
Y1
,
double
X2
,
double
Y2
,
double
C_x
,
double
C_y
,
int
n
){
double
dec_x
=
(
X1
-
X2
)
/
LCD_WIDTH
;
double
dec_y
=
(
Y1
-
Y2
)
/
LCD_HEIGHT
;
for
(
int
i
=
0
;
i
<=
LCD_HEIGHT
;
i
++
){
for
(
int
j
=
0
;
j
<=
LCD_WIDTH
;
j
++
){
double
re
=
X1
+
j
*
dec_x
;
double
im
=
Y1
+
i
*
dec_y
;
float
t
=
(
compute
(
re
,
im
,
C_x
,
C_y
,
n
))
/
n
;
uint16_t
pixel
=
conv_color
(
t
);
*
video_base
[
i
][
j
]
=
pixel
;
}
}
}
\ No newline at end of file
fractal_computation.h
View file @
193cd20a
#include "stdint.h"
#include "math.h"
#include "display.h"
#include "periphery.h"
float
Q_rsqrt
(
float
number
);
int
compute
(
double
z_re
,
double
z_im
,
double
c_re
,
double
c_im
,
int
n
);
void
fractal
(
double
X1
,
double
Y1
,
double
X2
,
double
Y2
,
double
C_re
,
double
C_im
,
int
n
);
qtmips_binrep
0 → 100755
View file @
193cd20a
File added
qtmips_binrep.c
View file @
193cd20a
...
...
@@ -18,6 +18,7 @@
#include "display.h"
#include "periphery.h"
#include "math.h"
#include "fractal_computation.h"
unsigned
char
*
mem_base
=
(
unsigned
char
*
)
SPILED_REG_BASE
;
video_buff_ptr
video_base
=
(
video_buff_ptr
)
LCD_FB_START
;
...
...
@@ -130,9 +131,12 @@ int main(int argc, char *argv[])
float
X2_value
=
19
.
99
;
float
Y2_value
=
10
.
03
;
draw_filled_rect
(
0
,
0
,
LCD_WIDTH
,
LCD_HEIGHT
,
tmp_color
);
//
draw_filled_rect(0, 0, LCD_WIDTH, LCD_HEIGHT, tmp_color);
//memcpy((void*)LCD_FB_START, &tmp_color, LCD_FB_END-LCD_FB_START);
fractal
(
-
1
.
6
,
-
1
.
1
,
1
.
6
,
1
.
1
,
-
0
.
4
,
0
.
6
,
60
);
draw_menu
();
draw_boxes_and_labels
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment