2024-07-28 02:59:16 -03:00
|
|
|
#ifndef LEVEL_H
|
|
|
|
#define LEVEL_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <psxgpu.h>
|
|
|
|
|
2024-10-02 00:06:15 -03:00
|
|
|
#include "object_state.h"
|
|
|
|
|
2024-08-05 22:25:06 -03:00
|
|
|
#define LEVEL_MAX_X_CHUNKS 255
|
|
|
|
#define LEVEL_MAX_Y_CHUNKS 31
|
2024-09-17 17:49:29 -03:00
|
|
|
#define LEVEL_ARENA_SIZE 131072
|
2024-07-28 02:59:16 -03:00
|
|
|
|
2024-08-01 02:17:07 -03:00
|
|
|
typedef struct {
|
|
|
|
uint8_t floor[8];
|
|
|
|
uint8_t rwall[8];
|
|
|
|
uint8_t ceiling[8];
|
|
|
|
uint8_t lwall[8];
|
2024-08-16 00:07:38 -03:00
|
|
|
|
|
|
|
int32_t floor_angle;
|
|
|
|
int32_t rwall_angle;
|
|
|
|
int32_t ceiling_angle;
|
|
|
|
int32_t lwall_angle;
|
2024-08-01 02:17:07 -03:00
|
|
|
} Collision;
|
|
|
|
|
2024-07-28 02:59:16 -03:00
|
|
|
typedef struct {
|
|
|
|
uint16_t tile_width;
|
|
|
|
uint16_t num_tiles;
|
|
|
|
uint16_t frame_side;
|
|
|
|
uint16_t *frames;
|
2024-08-01 02:17:07 -03:00
|
|
|
Collision **collision;
|
2024-09-17 17:49:29 -03:00
|
|
|
} TileMap16;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint16_t index;
|
|
|
|
uint8_t props;
|
|
|
|
uint8_t _unused;
|
|
|
|
} Frame128;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint16_t tile_width;
|
|
|
|
uint16_t num_tiles;
|
|
|
|
uint16_t frame_side;
|
|
|
|
Frame128 *frames;
|
|
|
|
} TileMap128;
|
2024-07-28 02:59:16 -03:00
|
|
|
|
2024-09-17 17:49:29 -03:00
|
|
|
#define MAP128_PROP_SOLID 0
|
|
|
|
#define MAP128_PROP_ONEWAY 1
|
|
|
|
#define MAP128_PROP_NONE 2
|
2024-07-28 02:59:16 -03:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint8_t width;
|
|
|
|
uint8_t height;
|
|
|
|
uint16_t *tiles;
|
|
|
|
} LevelLayerData;
|
|
|
|
|
2024-10-02 00:06:15 -03:00
|
|
|
#define MAX_OBJECTS_PER_CHUNK 15
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint8_t num_objects;
|
|
|
|
ObjectState objects[MAX_OBJECTS_PER_CHUNK];
|
|
|
|
} ChunkObjectData;
|
|
|
|
|
2024-07-28 02:59:16 -03:00
|
|
|
typedef struct {
|
|
|
|
uint8_t num_layers;
|
|
|
|
uint8_t _unused0;
|
|
|
|
LevelLayerData *layers;
|
2024-10-02 00:06:15 -03:00
|
|
|
ChunkObjectData **objects;
|
2024-07-28 02:59:16 -03:00
|
|
|
|
|
|
|
uint16_t crectx, crecty;
|
|
|
|
uint16_t prectx, precty;
|
|
|
|
uint16_t clutmode, _unused1;
|
|
|
|
} LevelData;
|
|
|
|
|
2024-08-05 22:25:06 -03:00
|
|
|
void level_init();
|
|
|
|
void level_reset();
|
|
|
|
void level_debrief();
|
2024-07-28 02:59:16 -03:00
|
|
|
|
2024-09-17 17:49:29 -03:00
|
|
|
void load_map16(TileMap16 *mapping, const char *filename, const char *collision_filename);
|
|
|
|
void load_map128(TileMap128 *mapping, const char *filename);
|
2024-07-28 02:59:16 -03:00
|
|
|
void load_lvl(LevelData *lvl, const char *filename);
|
|
|
|
|
2024-09-17 20:00:29 -03:00
|
|
|
void prepare_renderer(LevelData *lvl);
|
2024-07-28 02:59:16 -03:00
|
|
|
void render_lvl(
|
|
|
|
LevelData *lvl, TileMap128 *map128, TileMap16 *map16,
|
|
|
|
int32_t cam_x, int32_t cam_y);
|
|
|
|
|
2024-08-02 21:10:58 -03:00
|
|
|
|
2024-10-02 00:06:15 -03:00
|
|
|
// Object-related. These are defined in object_state.c
|
|
|
|
void load_object_placement(const char *filename, LevelData *lvl);
|
|
|
|
|
2024-07-28 02:59:16 -03:00
|
|
|
#endif
|