Mode 7 library

A library for Mode 7 style graphics.

File:
Mode7.lib
Version:
1.0
Author:
Marcus Johansson

Contents

Details
Constants
Sub routines


Details

You can use the floor, item and flag layers from maps generated with the RC editor with this library. The wall and ceiling data is ignored.


Constants

Array indexing constants.

Name
Description
M7_X
X-coordinate.
M7_Z
Z-coordinate.
M7_ANGLE
Angle.
M7_FLAG
Flag.


Subroutines

Name
Parameters
Brief description
procedure
M7_Init
w, h, zMax#
Init view.
function
M7_GetMapWidth
Get map width.
function
M7_GetMapHeight
Return map height.
procedure
M7_Render
viewx#, viewz#, viewy#, angle#, pitch, fov#
Render view.
procedure
M7_ClearObjects
Remove all objects.
procedure
M7_AddObject
id, img, x#, z#, y#, h#, cel, item_x, item_z
Add object.
procedure
M7_ModifyObject
id, img, x#, z#, y#, h#, cel
Modify an already existing object.
procedure
M7_RemoveObject
id
Remove object.
procedure
M7_RemoveObjectByIndex
index
Remove object by index.
function
M7_HasObject
id
Return true if object exists.
function
M7_LoadMap[][]
filename$
Load map.
procedure
M7_InitMap
w, h
Init map.
procedure
M7_SetFog
r, g, b, zMin#, zMax#
Set fog and clipping
procedure
M7_SetFloor
x, z, img
Set floor image.
procedure
M7_SetFlag
x, z, flag
Set game flag.
procedure
M7_SetItem
x, z, item
Set item.
procedure
M7_RemoveItem
x, z
Remove item.
function
M7_GetFloor
x, z
Get floor index.
function
M7_GetFloorImage
x, z
Return floor image.
function
M7_GetImage
img_index
Get image id.
function
M7_GetFlag
x, z
Get game flag.
function
M7_GetItem
x, z
Get item.
function
M7_GetFlagPos[]
flag
Get map position of game flag.


Subroutine documentation

procedure M7_Init ( w, h, zMax# )

Init view.

Parameter
Mode
Description
w
In
Width.
h
In
Height.
zMax
In
Far clip plane.

[ Back ]


function M7_GetMapWidth ( )

Get map width.

Return value
Map width.

[ Back ]


function M7_GetMapHeight ( )

Return map height.

Return value
Map height.

[ Back ]


procedure M7_Render ( viewx#, viewz#, viewy#, angle#, pitch, fov# )

Render view.

Parameter
Mode
Description
viewx
In
View x-coordinate.
viewz
In
View z-coordinate.
viewy
In
View y-coordinate.
angle
In
View angle.
pitch
In
View pitch.
fov
In
Field of view.

[ Back ]


procedure M7_ClearObjects ( )

Remove all objects.

[ Back ]


procedure M7_AddObject ( id, img, x#, z#, y#, h#, cel, item_x, item_z )

If an object with the specified id already exists, it will be replaced.

Parameter
Mode
Description
id
In
Identifier for object, should be none-zero.
img
In
Image identifier.
x
In
X-coordinate.
z
In
Z-coordinate.
y
In
Y-coordinate.
h
In
Height of object.
cel
In
Image cel to use.
item_x
In
X-coordinate of item (set to -1 if object is not connected to an item).
item_z
In
Z-coordinate of item.

[ Back ]


procedure M7_ModifyObject ( id, img, x#, z#, y#, h#, cel )

Modify an already existing object.

Parameter
Mode
Description
id
In
Object identifier.
x
In
X-coordinate.
z
In
Z-coordinate.
y
In
Y-coordinate.
h
In
Height.
cel
In
Image cel.

[ Back ]


procedure M7_RemoveObject ( id )

Remove object.

Parameter
Mode
Description
id
In
Object identifier.

[ Back ]


procedure M7_RemoveObjectByIndex ( index )

Remove object by index.

Parameter
Mode
Description
index
In
The index.

[ Back ]


function M7_HasObject ( id )

Return true if object exists.

Parameter
Mode
Description
id
In
Object identifier.

Return value

[ Back ]


function M7_LoadMap[][] ( filename$ )

Load map created with RC Editor. If the size of the returned array is zero, the map could not be read. Else the array contains the player's starting position and all loader flags added in the editor. The player's starting position is ([0][M7_X], [0][M7_Z]), and the set starting angle [0][M7_ANGLE]. You can get the positions of the set loader flags using [n][M7_X] and [n][M7_Z] and the flag value with [n][M7_FLAG], where n >= 1.

Parameter
Mode
Description
filename
In
Filename.

Return value
Player's position and loader flags.

[ Back ]


procedure M7_InitMap ( w, h )

If you're not using RC Editor, you can create an empty map with this procedure.

Parameter
Mode
Description
w
In
Width of map.
h
In
Height of map.

[ Back ]


procedure M7_SetFog ( r, g, b, zMin#, zMax# )

Set fog color and start and end distance. 'zMax' also serves as the far clip plane.

Parameter
Mode
Description
r
In
Red color intensity.
g
In
Green color intensity.
b
In
Blue color intensity.
zMin
In
Fog start distance.
zMax
In
Fog start distance and far clip plane.

[ Back ]


procedure M7_SetFloor ( x, z, img )

Set floor image.

Parameter
Mode
Description
x
In
X map-coordinate.
y
In
Y map-coordinate.
img
In
Image identifier.

[ Back ]


procedure M7_SetFlag ( x, z, flag )

Set game flag.

Parameter
Mode
Description
x
In
X map-coordinate.
z
In
Z map-coordinate.
flag
In
Flag value.

[ Back ]


procedure M7_SetItem ( x, z, item )

Set a value in the item layer. Calling this function does not bind a visible object to the item. If you're using RC editor for your maps, you probably needn't care about this function.

Parameter
Mode
Description
x
In
X map-coordinate.
z
In
Z map-coordinate.
item
In
Item value.

[ Back ]


procedure M7_RemoveItem ( x, z )

If the map was created with RC Editor, the visible object that belongs to the item is also removed.

Parameter
Mode
Description
x
In
X map-coordinate.
z
In
Z map-coordinate.

[ Back ]


function M7_GetFloor ( x, z )

Return the index used in RC Editor of the image used for a certain floor tile. This index makes no sense if map was not created with RC Editor.

Parameter
Mode
Description
x
In
X map-coordinate.
z
In
Z map-coordinate.

Return value
Image index.

[ Back ]


function M7_GetFloorImage ( x, z )

Return floor image.

Parameter
Mode
Description
x
In
X map-coordinate.
z
In
Z map-coordinate.

Return value
Image at floor tile.

[ Back ]


function M7_GetImage ( img_index )

This functions returns the id of an image for a certain index. Only makes sense if you're using RC Editor.

Parameter
Mode
Description
Image
In
index.

Return value
Image id.

[ Back ]


function M7_GetFlag ( x, z )

Get game flag set in RC Editor.

Parameter
Mode
Description
x
In
X map-coordinate.
z
In
Z map-coordinate.

Return value
Game flag.

[ Back ]


function M7_GetItem ( x, z )

Get item index set in RC Editor.

Parameter
Mode
Description
x
In
X map-coordinate.
z
In
Z map-coordinate.

Return value

[ Back ]


function M7_GetFlagPos[] ( flag )

This will return the position of the first occurence of a certain game flag in the map. Use [M7_X] and [M7_Z] to extract the coordinates. An empty array is returned if flag was not found anywhere in the map.

Parameter
Mode
Description
Flag
In
value.

Return value
Map position.

[ Back ]


Generated with NLDoc 20140627.