Difference between revisions of "API"

From WowWiki
Jump to navigation Jump to search
Line 7: Line 7:
 
==WOWCube Paradigms==
 
==WOWCube Paradigms==
  
WOWCUBE executes 8 copies of the byte-code of the script at the same time, providing functions for the interaction of scripts with each other, drawing functions, functions for accessing resources, and other specific functions. Each copy of the script has access to 3 displays. Resource scripts are packed into a package.
+
WOWCube executes 8 copies of the byte-code of the script at the same time, providing functions for the interaction of scripts with each other, drawing functions, functions for accessing resources, and other specific functions. Each copy of the script has access to 3 displays. Resource scripts are packed into a package.
 
 
==Firmware API==
 
( здесь этого не публикуем. Здесь только открытые API)
 
  
 
==Pawn API==
 
==Pawn API==
 
===Graphic functions===
 
===Graphic functions===
  
G2D acceleration is implemented as a separate task which handles all communication with G2D accelerator. It has mailbox for requests and it also provides utility functions to fill up this mail box for other tasks. Communication is done in OpenGL style, any other task can ask to prepare layers blending, add some layers to blend and initiate blending process.]]
+
====Graphics 2D acceleration (G2D)====
Currently result is stored in 3 internal buffers (one for each modules face) and ADD_BITMAP command is modified to access buffers in a primitive way. It is also supposed to render directly into display framebuffer (TBD).
+
WOWCube provides the 2D acceleration interfaces to enhance gaming experience . Basically G2D engine allows to blend up to the 4 image layers at once with a HW acceleration. However there is no limit of layers, they are blended in a cascade. For example, if Pawn script requested 7 layers to be blended then 2 HW blending will occur:
There is a way to wait until rendering is complete for other tasks.
+
[[File:Cascade.png|center|G2D cascading scheme]]
Task is implemented as a NFA
+
Result of the blending can be saved as an internal G2D resource or flushed immediately on the specified display. Internal G2D resources can be used as an usual bitmap primitive ([[API#abi_CMD_BITMAP|abi_CMD_BITMAP]])or reused as an input for the next G2D action.
 +
 
 +
=====abi_CMD_G2D_BEGIN_BITMAP=====
 +
Syntax:
 +
abi_CMD_G2D_BEGIN_BITMAP(const resID, const width, const height, const bool:replace)
 +
Description:
 +
: abi_CMD_G2D_BEGIN_BITMAP and [[API#abi_CMD_G2D_END|abi_CMD_G2D_END]] delimits the group of layers to be blended into internal G2D resource. This API is not intended for frequent usage. It is better suited for complex background generation on game initialization or dynamic resource modification triggered by rare game events.
 +
Arguments:
 +
: ''resID''
 +
:: ID of the resource that will be generated from blending layers presented between abi_CMD_G2D_BEGIN_BITMAP and the subsequent [[API#abi_CMD_G2D_END|abi_CMD_G2D_END]]. G2D engine can keep up to 3 different resources with IDs: 0, 1 and 2.
 +
: ''width''
 +
:: Width of the resulting resource. G2D engine can keep resource of 240px width maximum.
 +
: ''height''
 +
:: Height of the resulting resource. G2D engine can keep resource of 240px height maximum.
 +
: ''replace''
 +
:: If true, then an existing image will be replaced completely, otherwise it will be overwritten by reusing itself as a background layer.
 +
 
 +
=====abi_CMD_G2D_BEGIN_DISPLAY=====
 +
Syntax:
 +
abi_CMD_G2D_BEGIN_DISPLAY(const display, const bool:replace)
 +
Description:
 +
: abi_CMD_G2D_BEGIN_DISPLAY and [[API#abi_CMD_G2D_END|abi_CMD_G2D_END]] delimits the group of layers to be blended directly into display framebuffer. Obviously this API is designed for rendering scene on game tick. This API is not limited by layers count as well as [[API#abi_CMD_G2D_BEGIN_BITMAP|abi_CMD_G2D_BEGIN_BITMAP]]. However it is strictly recommended to blend no more than 4 layers. Otherwise cascade blending will be initiated resulting in some FPS drop.
 +
Arguments:
 +
: ''display''
 +
:: ID of the display which framebuffer will be used for blending. Each module have 3 displays with ID starting from 0.
 +
: ''replace''
 +
:: If true then an existing image will be replaced completely, otherwise it will be overwritten by reusing itself as a background layer.
 +
 
 +
=====abi_CMD_G2D_ADD_SPRITE=====
 +
Syntax:
 +
abi_CMD_G2D_ADD_SPRITE(const resID, const bool:g2d, const x, const y, const alpha, const color, const rotation, const mirror)
 +
Description:
 +
: Specifies game resource which will be used as a layer for blending.
 +
Arguments:
 +
: ''resID''
 +
:: ID of the resource to be uses as a layer.
 +
: ''g2d''
 +
:: Indicates if an internal G2D resource is specified or not.
 +
: ''x'', ''y''
 +
:: Coordinates of the bitmap center to place on the layer.
 +
: ''alpha''
 +
:: Layer transparency in range between 0x00 and 0xFF, where 0x00 is a fully transparent layer.
 +
: ''color''
 +
:: Layer's source key - a color in ARGB8888 format to be avoided.
 +
: ''rotation''
 +
:: Clockwise rotation angle in degrees. It is possible to specify free angle, but only right angles have HW acceleration.
 +
: ''mirror''
 +
:: Mirroring variant. Possible values are self-explained: MIRROR_BLANK, MIRROR_X, MIRROR_Y, MIRROR_XY.
 +
 
 +
=====abi_CMD_G2D_ADD_RECTANGLE=====
 +
Syntax:
 +
abi_CMD_G2D_ADD_RECTANGLE(const x, const y, const width, const height, const color)
 +
Description:
 +
: Specifies rectangle area which will be used as layer of blending. This API is not intended for frequent usage, i.e. particles generation. It is better suited for changing image background or applying color mask.
 +
Arguments:
 +
: ''x'', ''y''
 +
:: Coordinates of top left rectangle corner.
 +
: ''width''
 +
:: Rectangle width.
 +
: ''height''
 +
:: Rectangle height.
 +
: ''color''
 +
:: Rectangle color in ARGB8888 format.
  
[[File:G2D acceleration.png|thumb|right|280px| G2D acceleration paradigm]]
+
=====abi_CMD_G2D_END()=====
 +
Syntax:
 +
abi_CMD_G2D_END()
 +
Description:
 +
: abi_CMD_G2D_END() and [[API#abi_CMD_G2D_BEGIN_BITMAP|abi_CMD_G2D_BEGIN_BITMAP]]/[[API#abi_CMD_G2D_BEGIN_DISPLAY|abi_CMD_G2D_BEGIN_DISPLAY]] delimits the group of layers to be blended. After abi_CMD_G2D_END call final blending will be initiated and results will be stored according to the begin comand.
  
 
====Graphic primitives====
 
====Graphic primitives====

Revision as of 22:05, 2 September 2020

Template:Notice

Introduction

The main functions of the API are listed here, the features of the work of the environment are described

WOWCube Paradigms

WOWCube executes 8 copies of the byte-code of the script at the same time, providing functions for the interaction of scripts with each other, drawing functions, functions for accessing resources, and other specific functions. Each copy of the script has access to 3 displays. Resource scripts are packed into a package.

Pawn API

Graphic functions

Graphics 2D acceleration (G2D)

WOWCube provides the 2D acceleration interfaces to enhance gaming experience . Basically G2D engine allows to blend up to the 4 image layers at once with a HW acceleration. However there is no limit of layers, they are blended in a cascade. For example, if Pawn script requested 7 layers to be blended then 2 HW blending will occur:

G2D cascading scheme

Result of the blending can be saved as an internal G2D resource or flushed immediately on the specified display. Internal G2D resources can be used as an usual bitmap primitive (abi_CMD_BITMAP)or reused as an input for the next G2D action.

abi_CMD_G2D_BEGIN_BITMAP

Syntax:

abi_CMD_G2D_BEGIN_BITMAP(const resID, const width, const height, const bool:replace)

Description:

abi_CMD_G2D_BEGIN_BITMAP and abi_CMD_G2D_END delimits the group of layers to be blended into internal G2D resource. This API is not intended for frequent usage. It is better suited for complex background generation on game initialization or dynamic resource modification triggered by rare game events.

Arguments:

resID
ID of the resource that will be generated from blending layers presented between abi_CMD_G2D_BEGIN_BITMAP and the subsequent abi_CMD_G2D_END. G2D engine can keep up to 3 different resources with IDs: 0, 1 and 2.
width
Width of the resulting resource. G2D engine can keep resource of 240px width maximum.
height
Height of the resulting resource. G2D engine can keep resource of 240px height maximum.
replace
If true, then an existing image will be replaced completely, otherwise it will be overwritten by reusing itself as a background layer.
abi_CMD_G2D_BEGIN_DISPLAY

Syntax:

abi_CMD_G2D_BEGIN_DISPLAY(const display, const bool:replace)

Description:

abi_CMD_G2D_BEGIN_DISPLAY and abi_CMD_G2D_END delimits the group of layers to be blended directly into display framebuffer. Obviously this API is designed for rendering scene on game tick. This API is not limited by layers count as well as abi_CMD_G2D_BEGIN_BITMAP. However it is strictly recommended to blend no more than 4 layers. Otherwise cascade blending will be initiated resulting in some FPS drop.

Arguments:

display
ID of the display which framebuffer will be used for blending. Each module have 3 displays with ID starting from 0.
replace
If true then an existing image will be replaced completely, otherwise it will be overwritten by reusing itself as a background layer.
abi_CMD_G2D_ADD_SPRITE

Syntax:

abi_CMD_G2D_ADD_SPRITE(const resID, const bool:g2d, const x, const y, const alpha, const color, const rotation, const mirror)

Description:

Specifies game resource which will be used as a layer for blending.

Arguments:

resID
ID of the resource to be uses as a layer.
g2d
Indicates if an internal G2D resource is specified or not.
x, y
Coordinates of the bitmap center to place on the layer.
alpha
Layer transparency in range between 0x00 and 0xFF, where 0x00 is a fully transparent layer.
color
Layer's source key - a color in ARGB8888 format to be avoided.
rotation
Clockwise rotation angle in degrees. It is possible to specify free angle, but only right angles have HW acceleration.
mirror
Mirroring variant. Possible values are self-explained: MIRROR_BLANK, MIRROR_X, MIRROR_Y, MIRROR_XY.
abi_CMD_G2D_ADD_RECTANGLE

Syntax:

abi_CMD_G2D_ADD_RECTANGLE(const x, const y, const width, const height, const color)

Description:

Specifies rectangle area which will be used as layer of blending. This API is not intended for frequent usage, i.e. particles generation. It is better suited for changing image background or applying color mask.

Arguments:

x, y
Coordinates of top left rectangle corner.
width
Rectangle width.
height
Rectangle height.
color
Rectangle color in ARGB8888 format.
abi_CMD_G2D_END()

Syntax:

abi_CMD_G2D_END()

Description:

abi_CMD_G2D_END() and abi_CMD_G2D_BEGIN_BITMAP/abi_CMD_G2D_BEGIN_DISPLAY delimits the group of layers to be blended. After abi_CMD_G2D_END call final blending will be initiated and results will be stored according to the begin comand.

Graphic primitives

Font drawing functions

API:

 abi_CMD_TEXT(const text[], const fontResID, const x, const y, const scale, const angle, const r, const g, const b)

Example:

new text[4] = ['A', 'p', 'p', '\0'];
abi_CMD_TEXT(text, RES_ID_FONT, 90, 160, 16, current_angles[face], 255, 0, 0);