ZyeliosGPU documentation
This is not done yet, but due to requests some part of information is available
GPU is still in beta version, and many of things are not done/pending changes, so if something is not in these docs, most likely it's not yet implemented.
ZyeliosGPU is based on ZyeliosCPU.
That means you should perfectly know everything in ZyeliosCPU documentation before reading this one: http://www.wiremod.com/forum/cpu-tut...mentation.html
Differencies from ZyeliosCPU
These registers are missing in ZGPU: Page, IDTR, NIDT, EF, PF, IF, LADD, BusLock, Idle, CPAGE. ESP is now 32767.
There is no protected or extended mode, but there is basic error/interrupt handling. These are the error codes in GPU:
GPU has 65536 bytes of ram, but stack starts from 32767, and last memory addresses 63488..65535 are reserved for hardware registers.Code:ERROR | Meaning ------|---------------------------------------------------- 2 | End of program 3 | Division by zero 4 | Unknown opcode 5 | Internal processor error 6 | Stack error (overflow/underflow) 7 | Memory read/write fault 13 | General processor fault 15 | Address space violation 16 | Pants integrity violation 23 | String read error (string over 1024 characters) ------|----------------------------------------------------
These opcodes are not available in ZGPU (all other ZCPU opcodes work): RD, WD, SPG, CPG, HALT, IRET, STI, CLI, STP, CLP, STEF, CLEF, NMIINT, ERPG, WRPG, RDPG, LIDTR, STATESTORE, STATERESTORE, NMIRET, IDLE, RLADD, SPP, CPP, SRL, GRL
GPU ports reside in address range 63488..64511. Negative addresses are not available.
GPU resets all registers each frame. Each frame begins drawing from start of the program, and ends with DEXIT opcode. Please dont use infinite looping in GPU - there is no need for that.
GPU opcodes table
Parameters can be:
INT - Integer value (1 fbyte)
F - Floating point value (1 fbyte)
2F - 2D Vector. Use vector2f or uv macros
3F - 3D Vector. Use vector3f macro
MODEF - Depends on current vector mode, either 2F or 3F
MATRIX - Use matrix macro. Array of 16 floats.
COLOR - Use vector4f or color macros (refer to ZASM documentation)
STIRNG - Pointer to a null-terminated string. Can be max 1024 characters long.
STRING+PARAMS - Pointer to a null-terminated string followed by parameters. Special format elements are:
- %i - Integer (floored too)
- %f - Float
- %s - String (parameter is pointer to string)
- %t - Tab (6 characters padding)
FONTID - Font ID. Available fonts:
- 0 - Lucida Console
- 1 - Courier New
- 2 - Trebuchet
- 3 - Arial
- 4 - Times New Roman
ARRAY[X] - Array of elements with type X
BORDER_STRUCT - Following format:
Code:border_struct: vector2f position, <posx>, <posy> vector2f size, <sizex>, <sizey> vector4f data, <highlight_color>, <shadow_color>, <face_color>, <border_size>Internal pipelineCode:# | Opcode name | Description | Parameters (type) ----|-------------------|-------------------------------------------------------|-------------------------------------- 200 | DRECT_TEST | Perform GPU graphics test | | 201 | DEXIT | End current frame execution | | 202 | DCLR | Clear screen color to black | | 203 | DCLRTEX | Clear background with texture | | 204 | DVXFLUSH | Flush current vertex buffer to screen | | 205 | DVXCLEAR | Clear vertex buffer | | 206 | DERROREXIT | Exit error handler | | ----|-------------------|-------------------------------------------------------|-------------------------------------- 210 | DVXPIPE X | Vertex pipe = X | INT | 211 | DCVXPIPE X | Coordinate vertex pipe = X | INT | 212 | DENABLE X | Enable parameter X | INT | 213 | DDISABLE X | Disable parameter X | INT | 214 | DCLRSCR X | Clear screen with color X | COLOR | 215 | DCOLOR X | Set current color to X | COLOR | 216 | DBINDTEXTURE X | Bind texture | STRING | 217 | DSETFONT X | Set current font to X | FONTID | 218 | DSETSIZE X | Set font size to X | INT | 219 | DMOVE X | Set offset position to X | 2F | ----|-------------------|-------------------------------------------------------|-------------------------------------- 220 | DVXDATA_2F X,Y | Draw solid 2d polygon | ARRAY[2F] | INT 220 | DVXPOLY | | | 221 | DVXDATA_2F_TEX X,Y| Draw textured 2d polygon | ARRAY[2F+UV] | INT 221 | DVXTEXPOLY | | | 222 | DVXDATA_3F X,Y | Draw solid 3d polygon | 3F | INT 223 | DVXDATA_3F_TEX X,Y| Draw textured 3d polygon | ARRAY[3F+UV] | INT 225 | DRECT X,Y | Draw rectangle (XY1,XY2) | 2F | 2F 226 | DCIRCLE X,Y | Draw circle (XY,R) | 2F | F 227 | DLINE X,Y | Draw line (XY1,XY2) | 2F | 2F 228 | DRECTWH X,Y | Draw rectangle (XY,WH) | 2F | 2F 229 | DTRECTWH X,Y | Draw textured rectangle (XY1,XY2) | 2F | 2F ----|-------------------|-------------------------------------------------------|-------------------------------------- 230 | DTRANSFORM2F X,Y | Transform Y, save to X | 2F | 2F 231 | DTRANSFORM3F X,Y | Transform Y, save to X | 3F | 3F 232 | DSCRSIZE X,Y | Set screen size | F | F 233 | DROTATESCALE X,Y | Rotate and scale | F | F 234 | DORECTWH X,Y | Draw outlined rectangle (XY1,XY2) | 2F | 2F ----|-------------------|-------------------------------------------------------|-------------------------------------- 240 | DWRITE X,Y | Write Y to coordinates X | 2F | STRING 241 | DWRITEI X,Y | Write INT Y to coordinates X | 2F | I 242 | DWRITEF X,Y | Write 1F Y to coordinates X | 2F | F 243 | DENTRYPOINT X,Y | Set entry point X to address Y | INT | INT 244 | DSETLIGHT X,Y | Set light X to Y (Y points to [pos,color]) | INT | 3F+COLOR 245 | DGETLIGHT X,Y | Get light Y to X (X points to [pos,color]) | INT | 3F+COLOR 246 | DWRITEFMT X,Y | Write formatted string Y to coordinates X | 2F | STRING+PARAMS 247 | DWRITEFIX X,Y | Write fixed value Y to coordinates X | 2F | F ----|-------------------|-------------------------------------------------------|-------------------------------------- 250 | VADD X,Y | X = X + Y | MODEF | MODEF 251 | VSUB X,Y | X = X - Y | MODEF | MODEF 252 | VMUL X,Y | X = X * SCALAR Y | MODEF | MODEF 253 | VDOT X,Y | X = X . Y | MODEF | MODEF 254 | VCROSS X,Y | X = X x Y | MODEF | MODEF 255 | VMOV X,Y | X = Y | MODEF | MODEF 256 | VNORM X,Y | X = NORMALIZE(Y) | MODEF | MODEF 257 | VCOLORNORM X,Y | X = COLOR_NORMALIZE(Y) | MODEF | MODEF 259 | DLOOPXY X,Y | IF DX>0 {IP=X;IF CX>0{CX--}ELSE{DX--;CX=Y}} | INT | INT ----|-------------------|-------------------------------------------------------|-------------------------------------- 260 | MADD X,Y | X = X + Y | MATRIX | MATRIX 261 | MSUB X,Y | X = X - Y | MATRIX | MATRIX 262 | MMUL X,Y | X = X * Y | MATRIX | MATRIX 263 | MROTATE X,Y | X = ROT(Y) | MATRIX | 4F 264 | MSCALE X,Y | X = SCALE(Y) | MATRIX | 4F 265 | MPERSPECTIVE X,Y | X = PERSPECTIVE(Y) | MATRIX | 4F 266 | MTRANSLATE | X = TRANSLATE(Y) | MATRIX | 4F 267 | MLOOKAT | X = LOOKAT(Y) | MATRIX | 4F 268 | MMOV | X = Y | MATRIX | MATRIX ----|-------------------|-------------------------------------------------------|-------------------------------------- 270 | MIDENT X | Load identity matrix into X | MATRIX 271 | MLOAD X | Load matrix X into view matrix | MATRIX 272 | MREAD X | Write view matrix into matrix X | MATRIX 273 | VMODE X | Vector mode = Y | INT 274 | DT X | X -> Frame DeltaTime | F 275 | DSTRPRECACHE X | Precache string | STRING 276 | DSHADE X | COLOR = COLOR * X | F 277 | DSETWIDTH X | LINEWIDTH = X | F ----|-------------------|-------------------------------------------------------|-------------------------------------- 280 | DDFRAME X | Draw bordered frame | BORDER_STRUCT ----|-------------------|-------------------------------------------------------|-------------------------------------- 294 | DMULDT X,Y | X = Y * dT | F | F
Entry points are points where program should start when handling certain events. There are following entrypoints:
Entrypoints should be set using DENTRYPOINT opcode. Entrypoint should be a label.Code:0 DRAW This entrypoint is called when screen is redrawn 2 USE This entrypoint is called when screen is used by someone 3 ERROR This is called instead of DRAW if rendering error occurred
Draw sequence is following:
- Render opcode generates vertex data (triangles)
- Vertex data is added to vertex buffer (internal storage for graphics data)
- Vertex data is flushed (manually, or automatically)
- Vertex pipe performs transform
- Coordinate vertex pipe performs transform
- Data is rendered on screen
Vertex data can be flushed automatically after each rendering opcode, or manually using DVXFLUSH opcode. This is controlled by control flags.
Control flags are enabled/disabled using DENABLE or DDISABLE
These control flags exist:
Vertex pipe is selected using DVXPIPE opcode. Vertex pipe exist for transforming all rendered coordinates in a certain way.Code:0 VERTEX_ZSORT Enable or disable ZSorting in vertex buffer (sorted on flush) 1 VERTEX_LIGHTING Enable or disable vertex lighting 2 VERTEX_BUFFER Enable or disable vertex buffer 3 VERTEX_CULLING Enable or disable culling on faces
These vertex pipes exist:
Coordinate pipe is selected using DCVXPIPE opcode. Coordinate pipes are used to map any coordinate system you pick to native GPU 512x512 resolution.Code:0 XY mapping Xscreen = X Yscreen = Y 1 YZ mapping Xscreen = Y Yscreen = Z 2 XZ mapping Xscreen = X Yscreen = Z 3 XYZ projective mapping Xscreen = (X + Z) / Z Yscreen = (Y + Z) / Z 4 XY mapping + matrix Xscreen = (XY * TransformMatrix).X Yscreen = (XY * TransformMatrix).Y 5 XYZ projective mapping + matrix Xscreen = (XYZ * TransformMatrix).X Yscreen = (XYZ * TransformMatrix).Y
Also coordinate pipe performs 2D rotation and scale (set by DROTATESCALE opcode). It eats kittens.
These coordinate pipes exist:
This is really incomplete! It doesn't cover full potential of what you can do with GPU!Code:0 Direct mapping X = X Y = Y 1 Screen resolution mapping X = 512 * (X / RSCREEN_WIDTH) Y = 512 * (Y / RSCREEN_HEIGHT) 2 Coordinates in 0..1 range X = 512 * X Y = 512 * Y 3 Coordinates in -1..1 range X = 256 + X * 256 Y = 256 + Y * 256 4 Coordinates in -256..256 range X = X + 256 Y = Y + 256


LinkBack URL
About LinkBacks









Reply With Quote





Bookmarks