I spent quite a while working this out on paper first, put it in notepad, and gave it a try.
First a note. If you leave line breaks after something, it will delete two lines down, and copy one. Example:
Code:
jmp main;
alterz:
mov esp,edx;
Turns into, once you load it in,
Code:
jmp main;
jmp main;
mov esp,edx;
, which was quite annoying.
Anyway, here's the code. I just ran through creating the unit circle, and scaled it according to the Z-position, and ran up and down the Z axis. But this code made it really long
, and I know there are probably much easier ways. Heavily commented, so I'm hoping it can help somone out, it pretty much meant that I don't fail at languages, for me =P
Code:
CODE;
// eax is x
// ebx is y
// ecx is the counter
// edx is z
// esi is the increment
// The frequency should be very high!
// edi is the previous z
// ebp is the altered z
// esp is a random temporary thing
// port0 is x
// port1 is y
// port2 is z
// port3 is lifetime
// port4 is display
init:
**mov esi,1; // Set increment to .01 or so
**div esi,100; // May need to change this to make it faster
**mov ecx,0; // Initial counter 0
**fsin eax,ecx; // Set inital x and y
**fcos ebx,ecx;
**mov edx,5; // Initial z = 5, in the middle
**mov edi,4; // Set this lower than z so it will start with increasing
**mov port3,50; // May need alteration, the fade rate
**mov port4,1; // Always display
main:
**cmp edx,5; // To get the number to multiply x and y by
**jg alterz;
**mov ebp,edx; // If it's at 5 or below, just use z
midmain:
**add ecx,esi; // Increment the counter
**fsin eax,ecx; // Get X
**mul eax,ebp; // Multiply by z (or altered z)
**fcos ebx,ecx; // Get Y
**mul ebx,ebp; // Multiply
**mov port0,eax; // Set them all to their respective ports
**mov port1,ebx;
**mov port2,edx;
**cmp ecx,6.283185; // Compare the counter to twice pi (one full revolution)
**jg nextz; // If it's past it, we need to change z
**jmp main; // Otherwise loop again
nextz:
**mov esp,edx; // Store edx here temporarily
**sub esp,edi; // And subtract the previous from the current
**add edx,esp; // So here, we can add this to both edx
**add edi,esp; // and edi to increment or decrement, depending on
**mov ecx,0; // the trend.
**cmp edx,0; // And now see if it's below 0 or above 10, and change the trend if it is
**jl incz;
**cmp edx,10;
**jg decz;
**jmp main;
incz:
**mov edx,1;
**mov edi,0;
**jmp main;
decz:
**mov edx,9;
**mov edi,10;
**jmp main;
alterz:
**mov esp,edx; // Store the Z in an editable variable
**sub esp,5; // Subtract 5
**mov ebp,2; // Put 2 in the temporary Z
**mul ebp,esp; // Multiplies 2 x (Z - 5)
**mov esp,ebp; // Put that in ESP
**mov ebp,5; // Put 5 here
**sub ebp,esp; // And here we have 5 - 2(Z - 5)
**jmp midmain;
I also have one very small and odd problem with this code, and I don't understand it at all.
Sometimes, when it's at a Z value of 1 and 0, or 9 and 10, it will suddenly make a full-width circle, rather than a next-to-0 width circle. Help? Looking at the code, that should simply not happen...
Edit: Added a bit of structure. xD
Edit again: Much simpler, same idea, I enjoy making pretty shapes on the holograph thing. It works much better than with timers, too, because they're all out of synch and bleh. Here we are. Perfect cube, and this one works precisely as planned.
Code:
// Input: Attach a running timer to Port0
// Output: Holograph X - Port 0
//******** Holograph Y - Port 1
//******** Holograph Z - Port 2
CODE;
mov ebx,1;
main:
**mov port0,0; // Alternate between four coordinates
**mov port1,0;
**halt 0;******// Wait for the timer to think
**mov port0,1; // You can use 250,000 clock speed if you want, because of this
**mov port1,0;
**halt 0;
**mov port0,1;
**mov port1,1;
**halt 0;
**mov port0,0;
**mov port1,1;
**halt 0;
**add eax,ebx; // Add the incremental, ebx, to Z
**mov port2,eax; // And output it, of course
**cmp eax,10; // See if it's at 10 or 0, and alter the incremental
**jge blarg; // if it is
**cmp eax,0;
**jle nub;
**jmp main;
blarg:****// I'm tired, give me a break with these labels
**mov ebx,0;
**dec ebx; // Roundabout way to get -1 =P
**jmp main;
nub:
**mov ebx,1;
**jmp main;
Bookmarks