| maug
    Quick and dirty C mini-augmentation library. | 
The viewport data struct. More...
#include <retroflt.h>
| Data Fields | |
| int16_t | screen_x | 
| X position of the viewport in real screen memory in pixels. Should only be retrieved through retroflat_viewport_screen_x() and set through retroflat_viewport_set_pos_size(). | |
| int16_t | screen_y | 
| Y position of the viewport in real screen memory in pixels. Should only be retrieved through retroflat_viewport_screen_y() and set through retroflat_viewport_set_pos_size() | |
| int16_t | world_x | 
| The X offset, in pixels, of the viewport on the world tilemap. Should only be retrieved through retroflat_viewport_world_x() and set through retroflat_viewport_set_world_pos(). | |
| int16_t | world_y | 
| The Y offset, in pixels, of the viewport on the world tilemap. Should only be retrieved through retroflat_viewport_world_y() and set through retroflat_viewport_set_world_pos(). | |
| int16_t | world_w | 
| The width of the entire world tilemap in pixels. Should only be retrieved through retroflat_viewport_world_w() and set through retroflat_viewport_set_world(). | |
| int16_t | world_h | 
| The height of the entire world tilemap in pixels. Should only be retrieved through retroflat_viewport_world_h() and set through retroflat_viewport_set_world(). | |
| uint16_t | screen_w | 
| Viewport width in pixels. Should only be retrieved through retroflat_viewport_screen_w() and set through retroflat_viewport_set_pos_size(). | |
| uint16_t | screen_h | 
| Viewport height in pixels. Should only be retrieved through retroflat_viewport_screen_w() and set through retroflat_viewport_set_pos_size(). | |
| uint16_t | screen_w_remainder | 
| Difference between viewport width and screen width in pixels. Should only be retrieved through retroflat_viewport_screen_w_remainder() and calculated through retroflat_viewport_set_pos_size(). | |
| uint16_t | screen_h_remainder | 
| Difference between viewport height and screen height in pixels. Should only be retrieved through retroflat_viewport_screen_h_remainder() and calculated through retroflat_viewport_set_pos_size(). | |
| int16_t | screen_tile_w | 
| The number of tiles across that fit in the viewport. Should only be retrieved through retroflat_viewport_screen_tile_w() and calculated through retroflat_viewport_set_pos_size(). | |
| int16_t | screen_tile_h | 
| The number of tiles high that fit in the viewport. Should only be retrieved through retroflat_viewport_screen_tile_h() and calculated through retroflat_viewport_set_pos_size(). | |
| int16_t | world_tile_x | 
| int16_t | world_tile_y | 
| MAUG_MHANDLE | refresh_grid_h | 
| retroflat_tile_t * | refresh_grid | 
| A grid of tile values representing the last-drawn values on-screen.  More... | |
| Related Functions | |
| (Note that these are not member functions.) | |
| #define | retroflat_viewport_world_x() | 
| Return the current viewport X position in the world in pixels.  More... | |
| #define | retroflat_viewport_world_y() | 
| Return the current viewport Y position in the world in pixels.  More... | |
| #define | retroflat_viewport_world_w() retroflat_viewport_world_w_generic() | 
| Return the current width of the world in pixels. | |
| #define | retroflat_viewport_world_h() retroflat_viewport_world_h_generic() | 
| Return the current height of the world in pixels. | |
| #define | retroflat_viewport_screen_tile_w() retroflat_viewport_screen_tile_w_generic() | 
| Return the current width of the world in tiles. | |
| #define | retroflat_viewport_screen_tile_h() retroflat_viewport_screen_tile_h_generic() | 
| Return the current height of the world in tiles. | |
| #define | retroflat_viewport_screen_w() retroflat_viewport_screen_w_generic() | 
| Return the width of the viewport in pixels. | |
| #define | retroflat_viewport_screen_h() retroflat_viewport_screen_h_generic() | 
| Return the height of the viewport in pixels. | |
| #define | retroflat_viewport_screen_w_remainder() retroflat_viewport_screen_w_remainder_generic() | 
| Return the difference in pixels between the viewport X + width and the screen width. | |
| #define | retroflat_viewport_screen_h_remainder() retroflat_viewport_screen_h_remainder_generic() | 
| Return the difference in pixels between the viewport Y + height and the screen height. | |
| #define | retroflat_viewport_set_world(w, h) 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.  More... | |
| #define | retroflat_viewport_set_world_pos(x, y) retroflat_viewport_set_world_pos_generic( 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) 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. | |
| #define | retroflat_viewport_lock_refresh() retroflat_viewport_lock_refresh_generic() | 
| Lock access to RETROFLAT_VIEWPORT::refresh_grid in memory.  More... | |
| #define | retroflat_viewport_unlock_refresh() retroflat_viewport_unlock_refresh_generic() | 
| Unlock access to RETROFLAT_VIEWPORT::refresh_grid in memory.  More... | |
| #define | retroflat_viewport_set_refresh(x, y, tid) retroflat_viewport_set_refresh_generic( x, y, tid ) | 
| Set the tile at the given screen pixel coordinates to the given tile ID.  More... | |
The viewport data struct.
| 
 | related | 
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().
| 
 | related | 
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.
| 
 | related | 
Set the pixel width and height of the world so the viewport knows how far it may scroll.
| w | The width of the world in pixels (tile_width * map_tile_width). | 
| h | The height of the world in pixels (tile_height * map_tile_height). | 
| 
 | related | 
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.
| 
 | related | 
Return the current viewport X position in the world in pixels.
| 
 | related | 
Return the current viewport Y position in the world in pixels.
| retroflat_tile_t* RETROFLAT_VIEWPORT::refresh_grid | 
A grid of tile values representing the last-drawn values on-screen.
If the value for a tile in this grid matches the value about to be drawn, the draw will be skipped. This increases performance a LOT on systems with slow video memory access.
This functionality may be disabled by defining the macro RETROFLAT_NO_VIEWPORT_REFRESH on build.