Code:
// Compiled/Commented by Hitman271
dentrypoint 0,_EntryHere // Dentrypoint makes the gpu start reading code at _EntryHere
mov #deg2rad,3.141592 // Degrees to radians
div #deg2rad,180
timer #GpuSpawn // Timer sets GpuSpawn to the current curtime of the server, this is done here
//so that I know the exact time this gpu was spawned
dexit
///// FIELD /////
_EntryHere:
dcvxpipe 2 //Co-ords in gpu have to be from 0..1 to be displayed now
dclrscr BackGround_Color //Clear the screen to this color
dsetsize 24 //Set font size to 24
dsetwidth 0.001 //Set line widths to 0.001 i.e. - (dline pos,pos2)
dcolor Test_Color //Set the color for things drawn to this color
jmp Cursors //I skip the code below as it is only for reference
///// FIELD /////
CircleStuff:
mov eax,#deg2rad
mul eax,360 // I want 2*pi
mov #65478,0 //Start of circle
mov #65477,eax //end of circle, at 2*pi
//Any circle drawn now will be from 0-2pi, or 0-360 degrees
//Go learn trig if you haven't by now
//Also, by default the end of circles is already at 2*pi
//Setting the circle end to pi would make a semi-circle
///// FIELD /////
2dRenders:
drectwh MidPos,Dim //Draw a rectangle with top-left point at MidPos and dimensions of Dim( or 0.1, 0.1 )
dcircle MidPos,#TestRadius //Draw a circle with a Center of MidPos and a radius of TestRadius
dline MidPos,TextPos //Draw a line from MidPos to TextPos
dorectwh Point1,Point3 //This draws an outlined rectangle
//This rectangle has nothing inside but is just 4 lines
dvxpoly TestPoly,3 //Draw a polygon
//In the code, TestPoly is a label
//The compiler is pointed to TestPoly and reads 3 points
//These points are plotted and line drawn between them
//Dcolor applies to this aswell
///// FIELD /////
3dRenders:
//Haha, no
///// FIELD /////
Pixelation:
mov #65533,0 //This sets hardware clear to 0
//With no clearing, everything drawn stays on-screen
//So a box drawn will appear to "smudge" if moved every frame
//This is how Pamento was created
dcolor UnitColor //This color is just 1,1,1
dshade 255 //Dshade multiplies the dcolor color (UnitColor) by 255
//So now the color is 255, 255, 255
///// FIELD /////
Cursors:
mov #65503,1 //With this on, whenever you have your cursor on the gpu an arrow will be drawn on the cursor
mov #Cursor.X,#65505 //The X componet of the cursor
mov #Cursor.Y,#65504 //The Y componet of the cursor
vmov TextPos,Cursor //The Text is moved to the cursor so you can move the text around
jmp RealCode //Skip again
///// FIELD /////
Strings:
mov #StringHere,CoderWho //Under TestString, this is defined
mov #FloatHere,#deg2rad //Under TestString, this is defined
mov #IntegerHere,#GpuSpawn //Under TestString, this is defined
dwritefmt TextPos,TestString //TestString is a formatted string, so we tell the compiler this
//Formatted strings have a % parameter in them
//Along with variable directly under them that point to other variables
//Parameters are
// %f - floats
// %s - strings
// %i - integers, or rounded floats
// %t - tab (not in code), should be same as tab key?
///// FIELD /////
Vectors:
vmov RegisterVector,F1 //Setting it equal to
vsub RegisterVector,F2 //Substracts the vectors
vlen eax,RegisterVector //Eax = 2 ^ 0.5 //Gets vector magnitude
vnorm RegisterVector,RegisterVector //First vector is set to the normalized vector of the second
//Here, I just set a vector to its normalized self
vmul RegisterVector,2 //Vector multiplied by scalar
mov #RegisterVector.x,0 //The x's and y's of vectors have certain stack locations and can be treated like this
mov #RegisterVector.y,0
vmov RegisterVector,F2
xchg #RegisterVector.x,#RegisterVector.y //Exchanges the first parameter with the second ( x,y = y,x )
neg #RegisterVector.y //This is now perpendicular to F2, Negates the parameter
///// FIELD /////
RealCode:
timer #Uptime
sub #Uptime,#GpuSpawn //TimeNow - TimeSpawned
mul #Uptime,10 //This is done to get to 1 decimal precision
fint #Uptime
div #Uptime,10
mov #String1,CoderWho
dwritefmt TextPos,TExt
dexit
///// FIELD /////
//GPU: VARIABLES, DATA, AND ALL-AROUND TOM-FOOLERY
///// FIELD /////
color BackGround_Color, 51, 54, 77
color Test_Color, 103, 126, 43
color UnitColor, 1, 1, 1
float deg2rad
float TestRadius, 0.1
float GpuSpawn
vec2f TextPos, 0.05, 0.4
vec2f Dim, 0.1, 0.1
vec2f MidPos, 0.5, 0.5
vec2f Cursor
vec2f F1, 0, 0
vec2f F2, 1, 1
vec2f RegisterVector
string CoderWho, 'Compiled by Hitman271'
string TExt, 'You can move me around!',10,'Look in my code for handbook!'10' Gpu Uptime: %f seconds'10,10'%s'
float Uptime
alloc String1
string TestString, 'String 1: %s '10' Float 1: %f '10' Integer 1: %i'
alloc StringHere
alloc FloatHere
alloc IntegerHere
//The 10 is ascii for "new line", or equivalent to enter key
TestPoly: //sides=3 ,All consecutive points
vec2f Point1, 0.5, 0.1
vec2f Point2, 0.1, 0.9
vec2f Point3, 0.9, 0.9
Bookmarks