maug
Quick and dirty C mini-augmentation library.
Loading...
Searching...
No Matches
RetroFlat Viewport API

A flexible API to facilitate tile-based views using hardware acceleration where available. More...

Collaboration diagram for RetroFlat Viewport API:

Data Structures

struct  RETROFLAT_VIEWPORT
 The viewport data struct. More...
 

Macros

#define retroflat_screen_colors()
 
#define retroflat_viewport_world_x()
 Return the current viewport X position in the world in pixels.
 
#define retroflat_viewport_world_y()
 Return the current viewport Y position in the world in pixels.
 
#define retroflat_viewport_world_tile_x()
 
#define retroflat_viewport_world_tile_y()
 
#define retroflat_viewport_world_w()
 Return the current width of the world in pixels.
 
#define retroflat_viewport_world_h()
 Return the current height of the world in pixels.
 
#define retroflat_viewport_screen_tile_w()
 Return the current width of the world in tiles.
 
#define retroflat_viewport_screen_tile_h()
 Return the current height of the world in tiles.
 
#define retroflat_viewport_screen_w()
 Return the width of the viewport in pixels.
 
#define retroflat_viewport_screen_h()
 Return the height of the viewport in pixels.
 
#define retroflat_viewport_screen_w_remainder()
 Return the difference in pixels between the viewport X + width and the screen width.
 
#define retroflat_viewport_screen_h_remainder()
 Return the difference in pixels between the viewport Y + height and the screen height.
 
#define retroflat_viewport_set_world(w, h)
 Set the pixel width and height of the world so the viewport knows how far it may scroll.
 
#define retroflat_viewport_set_world_pos(x, y)
 Set the position of the viewport in the world in pixels.
 
#define retroflat_viewport_set_pos_size(x_px, y_px, w_px, h_px)
 Set the pixel width and height of the viewport, as well as some other dependent values frequently used in screen updates.
 
#define retroflat_viewport_lock_refresh()
 Lock access to RETROFLAT_VIEWPORT::refresh_grid in memory.
 
#define retroflat_viewport_unlock_refresh()
 Unlock access to RETROFLAT_VIEWPORT::refresh_grid in memory.
 
#define retroflat_viewport_set_refresh(x, y, tid)
 Set the tile at the given screen pixel coordinates to the given tile ID.
 
#define retroflat_viewport_focus(x1, y1, range, speed)
 Move the viewport in a direction or combination thereof so that it's focusing the given x1/y1 within the given range.
 
#define retroflat_viewport_screen_x(world_x)
 Return the screenspace X coordinate at which something at the given world coordinate should be drawn.
 
#define retroflat_viewport_screen_y(world_y)
 Return the screenspace Y coordinate at which something at the given world coordinate should be drawn.
 
#define retroflat_viewport_move_x(x)
 
#define retroflat_viewport_move_y(y)
 

Detailed Description

A flexible API to facilitate tile-based views using hardware acceleration where available.

If no hardware acceleration is available on the platform, then the platform API header should define RETROFLAT_SOFT_VIEWPORT to enable the _generic functions and suffixes for this functionality.

Macro Definition Documentation

◆ retroflat_screen_colors

#define retroflat_screen_colors ( )
Value:
(g_retroflat_state->screen_colors)

◆ retroflat_viewport_focus

#define retroflat_viewport_focus ( x1,
y1,
range,
speed )
Value:
retroflat_viewport_focus_generic( x1, y1, range, speed )

Move the viewport in a direction or combination thereof so that it's focusing the given x1/y1 within the given range.

Parameters
x1The X coordinate to focus on.
y1The Y coordinate to focus on.
rangeThe number of pixels from the center of the screen to keep the given X and Y inside.
speedThe increment by which to move the viewport if the given X and Y are not in focus.
Warning
The speed parameter should always divide evenly into the tile size, or problems may occur!

◆ retroflat_viewport_lock_refresh

#define retroflat_viewport_lock_refresh ( )
related
Value:
retroflat_viewport_lock_refresh_generic()

Lock access to RETROFLAT_VIEWPORT::refresh_grid in memory.

This should be called before making references to the refresh grid e.g. with retroflat_viewport_tile_is_stale().

◆ retroflat_viewport_move_x

#define retroflat_viewport_move_x ( x)
Value:
retroflat_viewport_move_x_generic( x )

◆ retroflat_viewport_move_y

#define retroflat_viewport_move_y ( y)
Value:
retroflat_viewport_move_y_generic( y )

◆ retroflat_viewport_screen_h

#define retroflat_viewport_screen_h ( )
related
Value:
retroflat_viewport_screen_h_generic()

Return the height of the viewport in pixels.

◆ retroflat_viewport_screen_h_remainder

#define retroflat_viewport_screen_h_remainder ( )
related
Value:
retroflat_viewport_screen_h_remainder_generic()

Return the difference in pixels between the viewport Y + height and the screen height.

◆ retroflat_viewport_screen_tile_h

#define retroflat_viewport_screen_tile_h ( )
related
Value:
retroflat_viewport_screen_tile_h_generic()

Return the current height of the world in tiles.

◆ retroflat_viewport_screen_tile_w

#define retroflat_viewport_screen_tile_w ( )
related
Value:
retroflat_viewport_screen_tile_w_generic()

Return the current width of the world in tiles.

◆ retroflat_viewport_screen_w

#define retroflat_viewport_screen_w ( )
related
Value:
retroflat_viewport_screen_w_generic()

Return the width of the viewport in pixels.

◆ retroflat_viewport_screen_w_remainder

#define retroflat_viewport_screen_w_remainder ( )
related
Value:
retroflat_viewport_screen_w_remainder_generic()

Return the difference in pixels between the viewport X + width and the screen width.

◆ retroflat_viewport_screen_x

#define retroflat_viewport_screen_x ( world_x)
Value:
retroflat_viewport_screen_x_generic( world_x )

Return the screenspace X coordinate at which something at the given world coordinate should be drawn.

◆ retroflat_viewport_screen_y

#define retroflat_viewport_screen_y ( world_y)
Value:
retroflat_viewport_screen_y_generic( world_y )

Return the screenspace Y coordinate at which something at the given world coordinate should be drawn.

◆ retroflat_viewport_set_pos_size

#define retroflat_viewport_set_pos_size ( x_px,
y_px,
w_px,
h_px )
related
Value:
retroflat_viewport_set_pos_size_generic( x_px, y_px, w_px, h_px )

Set the pixel width and height of the viewport, as well as some other dependent values frequently used in screen updates.

◆ retroflat_viewport_set_refresh

#define retroflat_viewport_set_refresh ( x,
y,
tid )
related
Value:
retroflat_viewport_set_refresh_generic( x, y, tid )

Set the tile at the given screen pixel coordinates to the given tile ID.

If these coordinates are from the world, they should subtract retroflat_viewport_screen_x()/retroflat_viewport_screen_y() first!

When the viewport is redrawn, e.g. with retrotile_topdown_draw(), it will not redraw this tile if the tile ID is still the same.

◆ retroflat_viewport_set_world

#define retroflat_viewport_set_world ( w,
h )
related
Value:
retroflat_viewport_set_world_generic( w, h )

Set the pixel width and height of the world so the viewport knows how far it may scroll.

Parameters
wThe width of the world in pixels (tile_width * map_tile_width).
hThe height of the world in pixels (tile_height * map_tile_height).

◆ retroflat_viewport_set_world_pos

#define retroflat_viewport_set_world_pos ( x,
y )
related
Value:
retroflat_viewport_set_world_pos_generic( x, y )

Set the position of the viewport in the world in pixels.

◆ retroflat_viewport_unlock_refresh

#define retroflat_viewport_unlock_refresh ( )
related
Value:
retroflat_viewport_unlock_refresh_generic()

Unlock access to RETROFLAT_VIEWPORT::refresh_grid in memory.

This should be called when references to the refresh grid are no longer in use and may be invalidated by the system.

◆ retroflat_viewport_world_h

#define retroflat_viewport_world_h ( )
related
Value:
retroflat_viewport_world_h_generic()

Return the current height of the world in pixels.

◆ retroflat_viewport_world_tile_x

#define retroflat_viewport_world_tile_x ( )
Value:
retroflat_viewport_world_tile_x_generic()

◆ retroflat_viewport_world_tile_y

#define retroflat_viewport_world_tile_y ( )
Value:
retroflat_viewport_world_tile_y_generic()

◆ retroflat_viewport_world_w

#define retroflat_viewport_world_w ( )
related
Value:
retroflat_viewport_world_w_generic()

Return the current width of the world in pixels.

◆ retroflat_viewport_world_x

#define retroflat_viewport_world_x ( )
related
Value:
((retroflat_viewport_world_x_generic() \
>> RETROFLAT_TILE_W_BITS) << RETROFLAT_TILE_W_BITS)

Return the current viewport X position in the world in pixels.

◆ retroflat_viewport_world_y

#define retroflat_viewport_world_y ( )
related
Value:
((retroflat_viewport_world_y_generic() \
>> RETROFLAT_TILE_H_BITS) << RETROFLAT_TILE_H_BITS)

Return the current viewport Y position in the world in pixels.