SNES Mode 7 Support. More...
#include <snes/types.h>Go to the source code of this file.
Macros | |
| #define | MODE7_FLIP_H 0x01 |
| Flip Mode 7 plane horizontally. | |
| #define | MODE7_FLIP_V 0x02 |
| Flip Mode 7 plane vertically. | |
| #define | MODE7_TILE0 0xC0 |
| Show tile 0 when out of bounds. | |
| #define | MODE7_TRANSPARENT 0x80 |
| Show transparent when out of bounds. | |
| #define | MODE7_WRAP 0x00 |
| Wrap around when out of bounds (default) | |
Functions | |
| void | mode7Init (void) |
| Initialize Mode 7. | |
| void | mode7Rotate (u16 degrees) |
| Set rotation in degrees (0-359) | |
| void | mode7SetAngle (u8 angle) |
| Set Mode 7 rotation angle. | |
| void | mode7SetCenter (s16 x, s16 y) |
| Set Mode 7 center point. | |
| void | mode7SetMatrix (s16 a, s16 b, s16 c, s16 d) |
| Set Mode 7 matrix directly. | |
| void | mode7SetPivot (u8 x, u8 y) |
| Set pivot point (screen coordinates) | |
| void | mode7SetScale (u16 scale_x, u16 scale_y) |
| Set Mode 7 scale factors. | |
| void | mode7SetScroll (s16 x, s16 y) |
| Set Mode 7 scroll position. | |
| void | mode7SetSettings (u8 settings) |
| Set Mode 7 settings register. | |
| void | mode7Transform (u16 degrees, u16 scalePercent) |
| Set rotation and scale together. | |
SNES Mode 7 Support.
Functions for Mode 7 rotation and scaling effects. Mode 7 is the SNES's hardware rotation/scaling mode, famously used in F-Zero, Super Mario Kart, and Pilotwings.
Mode 7 uses a special interleaved VRAM format:
Use mode7LoadGraphics() or set up DMA manually with interleaved data.
| #define MODE7_FLIP_H 0x01 |
Flip Mode 7 plane horizontally.
| #define MODE7_FLIP_V 0x02 |
Flip Mode 7 plane vertically.
| #define MODE7_TILE0 0xC0 |
Show tile 0 when out of bounds.
| #define MODE7_TRANSPARENT 0x80 |
Show transparent when out of bounds.
| #define MODE7_WRAP 0x00 |
Wrap around when out of bounds (default)
| void mode7Init | ( | void | ) |
Initialize Mode 7.
Sets up default scale (1.0), identity matrix, center point (128,128), and scroll position. Call this before using other Mode 7 functions.
| void mode7Rotate | ( | u16 | degrees | ) |
Set rotation in degrees (0-359)
Convenience function that converts degrees to the internal 0-255 format.
| degrees | Rotation angle in degrees (0-359) |
| void mode7SetAngle | ( | u8 | angle | ) |
Set Mode 7 rotation angle.
Sets the rotation angle and recalculates the transformation matrix. The angle is 0-255 where 256 would equal 360 degrees (wraps at 256).
| angle | Rotation angle (0-255) |
This function:
Set Mode 7 center point.
Sets the center of rotation/scaling. Default is (128, 128).
| x | Center X coordinate (13-bit signed, -4096 to 4095) |
| y | Center Y coordinate (13-bit signed, -4096 to 4095) |
Set Mode 7 matrix directly.
For advanced users who need direct control over the transformation matrix. Bypasses the angle/scale system.
The matrix maps screen (x,y) to Mode 7 plane (X,Y): X = A*(x-cx) + B*(y-cy) + sx + cx Y = C*(x-cx) + D*(y-cy) + sy + cy
| a | Matrix A (1.7.8 fixed point) |
| b | Matrix B (1.7.8 fixed point) |
| c | Matrix C (1.7.8 fixed point) |
| d | Matrix D (1.7.8 fixed point) |
Set pivot point (screen coordinates)
Sets the rotation center using screen coordinates (0-255). The pivot point is where the Mode 7 plane appears to rotate around.
| x | Screen X coordinate (0-255) |
| y | Screen Y coordinate (0-223) |
Set Mode 7 scale factors.
Sets the X and Y scale for Mode 7 transformation. Scale is in 8.8 fixed point format:
| scale_x | Horizontal scale (8.8 fixed point) |
| scale_y | Vertical scale (8.8 fixed point) |
Set Mode 7 scroll position.
Sets the scroll offset for the Mode 7 plane.
| x | Horizontal scroll (13-bit signed) |
| y | Vertical scroll (13-bit signed) |
| void mode7SetSettings | ( | u8 | settings | ) |
Set Mode 7 settings register.
Controls flipping and out-of-bounds behavior.
| settings | M7SEL value: Bit 1: Flip vertically Bit 0: Flip horizontally Bits 7-6: Out of bounds behavior (0=wrap, 0x80=transparent, 0xC0=tile 0) |
Set rotation and scale together.
Combined transformation with rotation in degrees and percentage-based scaling.
| degrees | Rotation angle in degrees (0-359) |
| scalePercent | Scale as percentage (100 = normal, 50 = half, 200 = double) |