Skip to content

Commit d247ca9

Browse files
committed
first commit of this Motif widget GUI branch
0 parents  commit d247ca9

19 files changed

+4491
-0
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.{c,asm}]
2+
indent_style = tab
3+
indent_size = 4

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
CC = gcc
2+
LD = gcc
3+
AS = nasm
4+
5+
CFLAGS = -c -m32
6+
#CFLAGS = -c -m32 -DNO_XPM
7+
#CFLAGS = -c -m32 -DHAVE_SDL2
8+
LFLAGS = -m32 -lX11 -lXpm -lXm -lXt
9+
#LFLAGS = -m32 -lX11 -lXm -lXt
10+
#LFLAGS = -m32 -lX11 -lXpm -lSDL2 -lXm -lXt
11+
AFLAGS = -f elf
12+
13+
all: fractald fractalf
14+
15+
fractald: fractald.o routinesd.o
16+
$(LD) fractald.o routinesd.o -o fractald $(LFLAGS)
17+
18+
fractalf: fractalf.o routinesf.o
19+
$(LD) fractalf.o routinesf.o -o fractalf $(LFLAGS)
20+
21+
routinesd.o: routinesd.asm
22+
$(AS) $(AFLAGS) routinesd.asm
23+
24+
routinesf.o: routinesf.asm
25+
$(AS) $(AFLAGS) routinesf.asm
26+
27+
fractald.o: fractald.c
28+
$(CC) $(CFLAGS) fractald.c
29+
30+
fractalf.o: fractalf.c
31+
$(CC) $(CFLAGS) fractalf.c
32+
33+
clean:
34+
rm -f *.o fractald fractalf

Makefile.64

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
CC = gcc
2+
LD = gcc
3+
AS = nasm
4+
5+
CFLAGS = -c
6+
#CFLAGS = -c -DNO_XPM
7+
#CFLAGS = -c -DHAVE_SDL2
8+
LFLAGS = -lX11 -lXpm -lXm -lXt
9+
#LFLAGS = -lX11 -lXm -lXt
10+
#LFLAGS = -lX11 -lXpm -lSDL2 -lXm -lXt
11+
AFLAGS = -f elf64
12+
13+
all: fractald fractalf
14+
15+
fractald: fractald.o routinesd.o
16+
$(LD) fractald.o routinesd.o -o fractald $(LFLAGS)
17+
18+
fractalf: fractalf.o routinesf.o
19+
$(LD) fractalf.o routinesf.o -o fractalf $(LFLAGS)
20+
21+
routinesd.o: routinesd.asm
22+
$(AS) $(AFLAGS) routinesd.asm
23+
24+
routinesf.o: routinesf.asm
25+
$(AS) $(AFLAGS) routinesf.asm
26+
27+
fractald.o: fractald.c
28+
$(CC) $(CFLAGS) fractald.c
29+
30+
fractalf.o: fractalf.c
31+
$(CC) $(CFLAGS) fractalf.c
32+
33+
clean:
34+
rm -f *.o fractald fractalf

README.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
x86 Assembly Mandelbrot and Julia Fractal Program (Linux/Motif GUI)
2+
==================================================================
3+
4+
<table>
5+
<tr><td><img src="fractal1.png" width=396></td><td><img src="fractal2.png" width=396></td></tr>
6+
<tr><td><img src="fractal3.png" width=396></td><td><img src="fractal4.png" width=396></td></tr>
7+
</table>
8+
9+
## Introduction
10+
11+
This is a Mandelbrot and Julia Set fractal program written in x86 assembly
12+
language and C. I chose this mix because I didn't want to code the Linux
13+
GUI stuff in assembly. This program is based on the fractal program I wrote
14+
for a CPU / computer design I created. I have included that original program
15+
in case you want to see how this project has evolved. I created the x86 version
16+
in order to learn x86 assembly language and in order to create a tutorial video
17+
on x86 assembly language. Because of this, I purposely only used basic x86
18+
assembly. That means no SSE, SSE2, AVX-512, etc. Using newer x86 instructions
19+
(vector, etc.) would make it faster, but would make it a bit harder to
20+
understand and would deviate quite a bit from my original program (for my CPU
21+
design). For example, fmul versus VPCLMULQDQ to multiply. Besides, GPU would
22+
be faster anyway, in which case you wouldn't even use assembly.
23+
24+
This is not meant to be the best, most versatile, fractal program. It was
25+
meant to show assembly language programming. BTW, this is why it's 512x512
26+
resolution (with a 256x256 mode) - the original program was 256x256 due to the
27+
resolution of Logisim's video screen component. (Logisim is the simulation
28+
program I used to simulate my CPU design - refer to my various videos to see
29+
what I mean).
30+
31+
## Running
32+
33+
Start from either command line or icon.
34+
Once started, press 'h' to see the various keyboard controls. Or press
35+
'0' through '9', '-', or 'a' to go to preset areas of the fractals. To zoom,
36+
press either 'z' for zoom by opposing corners or 'x' for zoom by center to
37+
corner. Then click (and hold) left mouse button to select first point and
38+
drag to second point (and release). Press 'u' to undo the zoom. Zoom by
39+
default preserves the square aspect ratio. If that is not desired, press 'k'
40+
to toggle that feature off/on. Press 'p' to set or view the fractal
41+
parameters. BTW, to get images like the ones in my videos, lower the
42+
(iteration) limit to 255. Also, press 's' to save the current image to a
43+
PPM file.
44+
45+
Most of the keyboard controls can be put on the command-line as if you pressed
46+
them while the program is running. For example:
47+
48+
fractald 3-cd...
49+
50+
would choose Mandelbrot location #3 (3) to be displayed, then Mandelbrot
51+
location #4 (-), then color cycling enabled (c), then cycling direction
52+
changed (d), then cycling delta increased three times (.)
53+
54+
## Building
55+
56+
Linux executables are provided, so there shouldn't be a need to build, but if
57+
you need to...
58+
59+
nasm is required to assemble the assembly code. You can get it
60+
[here](https://github.com/netwide-assembler/nasm). It's official website is
61+
[here](https://www.nasm.us). You'll also need the X11 development files
62+
installed (including libxpm-dev package if you want the program to have an
63+
icon). If you don't have the required packages, you can run this (you may
64+
remove from this command any packages you already have installed or don't
65+
want):
66+
67+
sudo apt-get install libx11-dev libmotif-dev libxpm-dev nasm libsdl2-dev
68+
69+
Once you have the required tools, just:
70+
71+
make
72+
73+
for the 32-bit version, or:
74+
75+
make -f Makefile.64
76+
77+
for the 64-bit version.
78+
79+
These will make both the double and float versions of the fractal program.
80+
81+
## Special Linux Version Notes
82+
83+
I had wanted to make this program as simple as possible, so at first, I didn't
84+
use various toolkits such as GTK, Qt, Xt, Xaw, Motif, OLIT, XView, GLUT,
85+
wxWidgets, SDL, Tk, etc. But, I decided to make a Motif GUI version. Motif
86+
isn't the best, but I chose it because it had everything I needed and I could
87+
also force it to work with my existing code rather than take over my existing
88+
code. I used Motif in probably an unorthodox way, but it works. However,
89+
there still is the ability to use SDL2 for the help message box, if that's
90+
desired. Use -DHAVE_SDL2 in CFLAGS and -lSDL2 in LFLAGS in makefiles
91+
to compile in this feature.
92+
93+
Refer to the master branch for the non-Motif version.
94+
95+
Also, I chose not to use inline assembly, because in my opinion gcc's inline
96+
assembly style is horrendous (despite what others say). I kinda understand
97+
why it has to be horrendous, but I don't like it.
98+
99+
## Link to Windows Version
100+
101+
[https://github.com/mrmcsoftware/FractalAsm](https://github.com/mrmcsoftware/FractalAsm)
102+
103+
## Manifest
104+
105+
<table>
106+
<tr><td>fractald.c</td><td>"double" version of x86 fractal program - higher precision, but most likely slower</td></tr>
107+
<tr><td>fractalf.c</td><td>"float" version of x86 fractal program</td></tr>
108+
<tr><td>routinesd.asm</td><td>"double" assembly language routines</td></tr>
109+
<tr><td>routinesf.asm</td><td>"float" assembly language routines</td></tr>
110+
<tr><td>myicon.xpm</td><td>XPM image file representing the icon</td></tr>
111+
<tr><td>Makefile</td><td>Makefile for 32-bit version</td></tr>
112+
<tr><td>Makefile.64</td><td>Makefile for 64-bit version</td></tr>
113+
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
114+
<tr><td>fractalb.asm</td><td>My original fractal program for my CPU design</td></tr>
115+
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
116+
<tr><td>fractald</td><td>ELF 32-bit Linux executable (double version)</td></tr>
117+
<tr><td>fractalf</td><td>ELF 32-bit Linux executable (float version)</td></tr>
118+
<tr><td>fractald64</td><td>ELF 64-bit Linux executable (double version)</td></tr>
119+
<tr><td>fractalf64</td><td>ELF 64-bit Linux executable (float version)</td></tr>
120+
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
121+
<tr><td>fractal*.png</td><td>Screenshots</td></tr>
122+
<tr><td>README.md</td><td>This file</td></tr>
123+
</table>
124+
125+
## Demonstration Videos
126+
127+
[My x86 assembly language tutorial video containing an earlier version of this fractal program for Windows (starting at 3:42)](https://www.youtube.com/watch?v=KgPVx_kfBik)
128+
129+
[Part 1 of that x86 assembly language tutorial](https://www.youtube.com/watch?v=2i935mP6hUM)
130+
131+
[My CPU / computer design running my original fractal program written for that design](https://www.youtube.com/watch?v=ygf0aa1r3NY)
132+
133+
## Author
134+
135+
Mark Craig
136+
[https://www.youtube.com/MrMcSoftware](https://www.youtube.com/MrMcSoftware)

bin/fractald

47.8 KB
Binary file not shown.

bin/fractald64

60.6 KB
Binary file not shown.

bin/fractalf

47.6 KB
Binary file not shown.

bin/fractalf64

60.4 KB
Binary file not shown.

fractal1.png

56.5 KB
Loading

fractal2.png

124 KB
Loading

0 commit comments

Comments
 (0)