2024-07-10 22:17:04 -03:00
|
|
|
#ifndef RENDER_H
|
|
|
|
#define RENDER_H
|
|
|
|
|
|
|
|
#include <psxgpu.h>
|
|
|
|
|
|
|
|
#define SCREEN_XRES 320
|
|
|
|
#define SCREEN_YRES 240
|
|
|
|
#define SCREEN_Z 320
|
|
|
|
#define CENTERX (SCREEN_XRES >> 1)
|
|
|
|
#define CENTERY (SCREEN_YRES >> 1)
|
|
|
|
|
|
|
|
// Length of the ordering table, i.e. the range Z coordinates can have, 0-15 in
|
|
|
|
// this case. Larger values will allow for more granularity with depth (useful
|
|
|
|
// when drawing a complex 3D scene) at the expense of RAM usage and performance.
|
|
|
|
#define OT_LENGTH 2048
|
|
|
|
|
|
|
|
// Size of the buffer GPU commands and primitives are written to. If the program
|
|
|
|
// crashes due to too many primitives being drawn, increase this value.
|
2024-07-28 02:59:16 -03:00
|
|
|
//#define BUFFER_LENGTH 8192
|
2024-09-17 20:00:29 -03:00
|
|
|
#define BUFFER_LENGTH 24576
|
2024-08-05 22:25:06 -03:00
|
|
|
//#define BUFFER_LENGTH 40960
|
2024-09-17 20:00:29 -03:00
|
|
|
//#define BUFFER_LENGTH 65532
|
2024-07-10 22:17:04 -03:00
|
|
|
|
2024-10-13 11:06:19 -03:00
|
|
|
// Lerp color with respect to background color (0-128) and target color
|
|
|
|
// (useful for fade in and fade out)
|
|
|
|
#define LERPC(bg, c) ((c * bg) / 128)
|
|
|
|
|
2024-07-10 22:17:04 -03:00
|
|
|
/* Framebuffer/display list class */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DISPENV disp_env;
|
|
|
|
DRAWENV draw_env;
|
|
|
|
uint32_t ot[OT_LENGTH];
|
|
|
|
uint8_t buffer[BUFFER_LENGTH];
|
|
|
|
} RenderBuffer;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
RenderBuffer buffers[2];
|
|
|
|
uint8_t *next_packet;
|
|
|
|
int active_buffer;
|
|
|
|
} RenderContext;
|
|
|
|
|
|
|
|
void setup_context();
|
|
|
|
void set_clear_color(uint8_t r, uint8_t g, uint8_t b);
|
2024-10-01 01:35:45 -03:00
|
|
|
void force_clear();
|
2024-07-10 22:17:04 -03:00
|
|
|
void swap_buffers();
|
|
|
|
void *get_next_prim();
|
|
|
|
uint32_t *get_ot_at(uint32_t otz);
|
2024-07-28 02:59:16 -03:00
|
|
|
void increment_prim(uint32_t size);
|
2024-07-10 22:17:04 -03:00
|
|
|
void sort_prim(void *prim, uint32_t otz);
|
2024-11-02 15:19:11 -03:00
|
|
|
void draw_quad(int16_t vx, int16_t vy,
|
|
|
|
int16_t w, int16_t h,
|
|
|
|
uint8_t r, uint8_t g, uint8_t b,
|
|
|
|
uint8_t semitrans,
|
|
|
|
uint16_t otz);
|
2024-07-10 22:17:04 -03:00
|
|
|
|
|
|
|
void draw_text(int x, int y, int z, const char *text);
|
|
|
|
|
2024-08-06 21:45:11 -03:00
|
|
|
void render_loading_text();
|
|
|
|
|
2024-08-28 18:46:03 -03:00
|
|
|
RECT *render_get_buffer_clip(void);
|
|
|
|
|
2024-07-10 22:17:04 -03:00
|
|
|
#endif
|