Compare commits
15 commits
Author | SHA1 | Date | |
---|---|---|---|
19d0f373a8 | |||
997d5021ed | |||
86ba27d73d | |||
f28130787c | |||
ffb24fc06f | |||
5ec96d087a | |||
35e58e9e13 | |||
e6556e93fe | |||
0791ba1054 | |||
2593d28231 | |||
72826769be | |||
128fed3ffd | |||
8a486ddfea | |||
601bc9c90c | |||
c31dd35535 |
24 changed files with 393 additions and 71 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
untracked/
|
||||||
|
cmake-build*/
|
59
CMakeLists.txt
Normal file
59
CMakeLists.txt
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
cmake_minimum_required(VERSION 3.28)
|
||||||
|
project(yeti3dpro LANGUAGES C)
|
||||||
|
|
||||||
|
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3-shared)
|
||||||
|
|
||||||
|
# base engine library
|
||||||
|
|
||||||
|
add_library(y3d STATIC)
|
||||||
|
target_sources(y3d PRIVATE
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_animation.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_ansic.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_cell.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_draw.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_engine.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_entity.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_file.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_fixed.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_fruity.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_image.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_keyboard.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_map.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_matrix.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_pixel.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_record.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_sound.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_spanner.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_surface.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_vertex.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/y3d/y3d_yeti.c
|
||||||
|
)
|
||||||
|
target_include_directories(y3d PUBLIC ${PROJECT_SOURCE_DIR}/src/y3d/)
|
||||||
|
target_compile_definitions(y3d PUBLIC __SDL__)
|
||||||
|
|
||||||
|
# demo game library
|
||||||
|
|
||||||
|
add_library(game STATIC)
|
||||||
|
target_sources(game PRIVATE
|
||||||
|
${PROJECT_SOURCE_DIR}/src/game/data.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/game/entities.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/game/game.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/game/maps.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/game/models.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/game/screens.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/game/sprites.c
|
||||||
|
)
|
||||||
|
target_include_directories(game PUBLIC ${PROJECT_SOURCE_DIR}/src/game/)
|
||||||
|
target_link_libraries(game PRIVATE y3d)
|
||||||
|
|
||||||
|
# sdl3 platform
|
||||||
|
|
||||||
|
add_executable(game-sdl3)
|
||||||
|
target_sources(game-sdl3 PRIVATE
|
||||||
|
${PROJECT_SOURCE_DIR}/platform/sdl3/main.c
|
||||||
|
)
|
||||||
|
target_link_libraries(game-sdl3 PRIVATE SDL3::SDL3 game y3d)
|
||||||
|
find_library(MATH m)
|
||||||
|
if(MATH)
|
||||||
|
target_link_libraries(game-sdl3 PUBLIC ${MATH})
|
||||||
|
endif()
|
18
COPYING
Normal file
18
COPYING
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
YETI3D PRO Source Code
|
||||||
|
Dated: 17/8/2004
|
||||||
|
|
||||||
|
Here is a copy of Yeti3D PRO taken from a backup CD dated 17/8/2004.
|
||||||
|
|
||||||
|
Only the core source code is provided. None of the original sprites or MD2
|
||||||
|
models are provided, except the ANSI C data files.
|
||||||
|
|
||||||
|
I have included the World Editor and MD2 Model Converter tools which require
|
||||||
|
Borland C++Builder 6+ to compile. You should be able to get them running
|
||||||
|
on older versions with some hacking.
|
||||||
|
|
||||||
|
I have included the Win32 platform code which will show you how to get a
|
||||||
|
basic Yeti3D PRO system running.
|
||||||
|
|
||||||
|
This project is as old as the hills and I doubt this was the last version.
|
||||||
|
|
||||||
|
Use this code as you will.
|
23
README.md
23
README.md
|
@ -1,22 +1,5 @@
|
||||||
YETI3D PRO Source Code
|
# Yeti3D PRO SDL3 Port
|
||||||
Dated: 17/8/2004
|
|
||||||
|
|
||||||
Here is a copy of Yeti3D PRO taken from a backup CD dated 17/8/2004.
|
|
||||||
|
|
||||||
Only the core source code is provided. None of the original sprites or MD2
|
|
||||||
models are provided, except the ANSI C data files.
|
|
||||||
|
|
||||||
I have included the World Editor and MD2 Model Converter tools which require
|
|
||||||
Borland C++Builder 6+ to compile. You should be able to get them running
|
|
||||||
on older versions with some hacking.
|
|
||||||
|
|
||||||
I have included the Win32 platform code which will show you how to get a
|
|
||||||
basic Yeti3D PRO system running.
|
|
||||||
|
|
||||||
This project is as old as the hills and I doubt this was the last version.
|
|
||||||
|
|
||||||
Use this code as you will.
|
|
||||||
|
|
||||||
| | | |
|
| | | |
|
||||||
|----------------------------------|-------------------------------|--------------------------------|
|
|--------------------------------|--------------------------------|--------------------------------|
|
||||||
| ![](./screenshots/thetemple.jpg) | ![](./screenshots/yeti3d.png) | ![](./screenshots/pacyeti.jpg) |
|
| ![](./screenshots/yeti006.png) | ![](./screenshots/yeti007.png) | ![](./screenshots/yeti008.png) |
|
||||||
|
|
242
platform/sdl3/main.c
Normal file
242
platform/sdl3/main.c
Normal file
|
@ -0,0 +1,242 @@
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
|
#define SDL_MAIN_USE_CALLBACKS
|
||||||
|
#include <SDL3/SDL_main.h>
|
||||||
|
|
||||||
|
#include "game.h"
|
||||||
|
#include "maps.h"
|
||||||
|
|
||||||
|
#define MAXFPS (60)
|
||||||
|
|
||||||
|
static yeti_t yeti;
|
||||||
|
static u16 backbuffer[YETI_FRAMEBUFFER_WIDTH * YETI_FRAMEBUFFER_HEIGHT];
|
||||||
|
|
||||||
|
static SDL_Window *window = NULL;
|
||||||
|
static SDL_Renderer *renderer = NULL;
|
||||||
|
static SDL_Texture *texture = NULL;
|
||||||
|
|
||||||
|
static bool focused = true;
|
||||||
|
|
||||||
|
static Sint64 now = 0, then = 0;
|
||||||
|
|
||||||
|
static int requested_map = -1;
|
||||||
|
|
||||||
|
static int screenshot_idx = 0;
|
||||||
|
|
||||||
|
static void die(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
static char error[1024];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
SDL_vsnprintf(error, sizeof(error), fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, error);
|
||||||
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", error, NULL);
|
||||||
|
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dump_textures(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
SDL_Palette *pal;
|
||||||
|
|
||||||
|
pal = SDL_CreatePalette(256);
|
||||||
|
|
||||||
|
for (i = 0; i < pal->ncolors; i++)
|
||||||
|
{
|
||||||
|
pal->colors[i].r = palette[i][0];
|
||||||
|
pal->colors[i].g = palette[i][1];
|
||||||
|
pal->colors[i].b = palette[i][2];
|
||||||
|
pal->colors[i].a = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < TEXTURE_MAX; i++)
|
||||||
|
{
|
||||||
|
char filename[256];
|
||||||
|
SDL_Surface *surf;
|
||||||
|
|
||||||
|
surf = SDL_CreateSurfaceFrom(TEXTURE_WIDTH, TEXTURE_HEIGHT, SDL_PIXELFORMAT_INDEX8, textures[i], TEXTURE_WIDTH * sizeof(u8));
|
||||||
|
SDL_SetSurfacePalette(surf, pal);
|
||||||
|
SDL_FlipSurface(surf, SDL_FLIP_VERTICAL);
|
||||||
|
|
||||||
|
SDL_snprintf(filename, sizeof(filename), "texture%03d.bmp", i);
|
||||||
|
SDL_SaveBMP(surf, filename);
|
||||||
|
SDL_DestroySurface(surf);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_DestroyPalette(pal);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
|
||||||
|
{
|
||||||
|
Uint32 format;
|
||||||
|
|
||||||
|
if (!SDL_Init(SDL_INIT_VIDEO))
|
||||||
|
die(SDL_GetError());
|
||||||
|
|
||||||
|
window = SDL_CreateWindow(YETI_STR_CAPTION, YETI_FRAMEBUFFER_WIDTH, YETI_FRAMEBUFFER_HEIGHT, SDL_WINDOW_RESIZABLE | SDL_WINDOW_MAXIMIZED);
|
||||||
|
if (!window)
|
||||||
|
die(SDL_GetError());
|
||||||
|
|
||||||
|
SDL_SetWindowRelativeMouseMode(window, focused);
|
||||||
|
|
||||||
|
SDL_SetWindowMinimumSize(window, YETI_FRAMEBUFFER_WIDTH, YETI_FRAMEBUFFER_HEIGHT);
|
||||||
|
|
||||||
|
renderer = SDL_CreateRenderer(window, NULL);
|
||||||
|
if (!renderer)
|
||||||
|
die(SDL_GetError());
|
||||||
|
|
||||||
|
SDL_SetRenderVSync(renderer, 1);
|
||||||
|
SDL_SetRenderLogicalPresentation(renderer, YETI_FRAMEBUFFER_WIDTH, YETI_FRAMEBUFFER_HEIGHT, SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
|
||||||
|
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_XBGR1555, SDL_TEXTUREACCESS_STREAMING, YETI_FRAMEBUFFER_WIDTH, YETI_FRAMEBUFFER_HEIGHT);
|
||||||
|
if (!texture)
|
||||||
|
die(SDL_GetError());
|
||||||
|
|
||||||
|
SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST);
|
||||||
|
|
||||||
|
yeti_init(&yeti, backbuffer, backbuffer, textures, palette);
|
||||||
|
yeti_init_lua(&yeti, YETI_GAMMA);
|
||||||
|
game_init(&yeti);
|
||||||
|
|
||||||
|
/* get requested map */
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
requested_map = SDL_atoi(argv[1]);
|
||||||
|
SDL_Log("Loading map %d", requested_map);
|
||||||
|
game_load_map(&yeti, maps[requested_map]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
game_load_map(&yeti, &map_e1m1);
|
||||||
|
}
|
||||||
|
|
||||||
|
game_goto(&yeti.game, GAME_MODE_PLAY);
|
||||||
|
|
||||||
|
/* start counting time */
|
||||||
|
then = SDL_GetTicks();
|
||||||
|
|
||||||
|
return SDL_APP_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_frame(Sint64 dt)
|
||||||
|
{
|
||||||
|
static Sint64 frame_delta = 1000;
|
||||||
|
const bool *keys = SDL_GetKeyboardState(NULL);
|
||||||
|
|
||||||
|
yeti.keyboard.state.up = keys[SDL_SCANCODE_UP] || keys[SDL_SCANCODE_W];
|
||||||
|
yeti.keyboard.state.down = keys[SDL_SCANCODE_DOWN] || keys[SDL_SCANCODE_S];
|
||||||
|
yeti.keyboard.state.left = keys[SDL_SCANCODE_LEFT];
|
||||||
|
yeti.keyboard.state.right = keys[SDL_SCANCODE_RIGHT];
|
||||||
|
yeti.keyboard.state.a = keys[SDL_SCANCODE_RCTRL];
|
||||||
|
yeti.keyboard.state.b = keys[SDL_SCANCODE_SPACE];
|
||||||
|
yeti.keyboard.state.l = keys[SDL_SCANCODE_A];
|
||||||
|
yeti.keyboard.state.r = keys[SDL_SCANCODE_Z];
|
||||||
|
yeti.keyboard.state.select = keys[SDL_SCANCODE_ESCAPE];
|
||||||
|
|
||||||
|
frame_delta += dt;
|
||||||
|
|
||||||
|
if (frame_delta > (1000 / MAXFPS))
|
||||||
|
{
|
||||||
|
game_loop(&yeti);
|
||||||
|
frame_delta = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_AppResult SDL_AppIterate(void *appstate)
|
||||||
|
{
|
||||||
|
void *pixels;
|
||||||
|
int pitch;
|
||||||
|
|
||||||
|
/* speed limiter */
|
||||||
|
now = SDL_GetTicks();
|
||||||
|
do_frame(now - then);
|
||||||
|
then = now;
|
||||||
|
|
||||||
|
if (SDL_LockTexture(texture, NULL, &pixels, &pitch))
|
||||||
|
{
|
||||||
|
SDL_memcpy(pixels, backbuffer, sizeof(backbuffer));
|
||||||
|
SDL_UnlockTexture(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
SDL_RenderTexture(renderer, texture, NULL, NULL);
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
|
||||||
|
return SDL_APP_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool file_exists(const char *filename)
|
||||||
|
{
|
||||||
|
SDL_IOStream *io = SDL_IOFromFile(filename, "rb");
|
||||||
|
|
||||||
|
if (io)
|
||||||
|
{
|
||||||
|
SDL_CloseIO(io);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
|
||||||
|
{
|
||||||
|
switch (event->type)
|
||||||
|
{
|
||||||
|
case SDL_EVENT_QUIT:
|
||||||
|
return SDL_APP_SUCCESS;
|
||||||
|
|
||||||
|
case SDL_EVENT_KEY_DOWN:
|
||||||
|
if (event->key.scancode == SDL_SCANCODE_ESCAPE)
|
||||||
|
{
|
||||||
|
focused = !focused;
|
||||||
|
SDL_SetWindowRelativeMouseMode(window, focused);
|
||||||
|
}
|
||||||
|
else if (event->key.scancode == SDL_SCANCODE_F12)
|
||||||
|
{
|
||||||
|
SDL_Surface *screen;
|
||||||
|
char filename[256];
|
||||||
|
|
||||||
|
screen = SDL_CreateSurfaceFrom(YETI_FRAMEBUFFER_WIDTH, YETI_FRAMEBUFFER_HEIGHT, SDL_PIXELFORMAT_XBGR1555, backbuffer, YETI_FRAMEBUFFER_WIDTH * sizeof(u16));
|
||||||
|
if (!screen)
|
||||||
|
die("%s", SDL_GetError());
|
||||||
|
|
||||||
|
SDL_snprintf(filename, sizeof(filename), "yeti%03d.bmp", screenshot_idx++);
|
||||||
|
while (file_exists(filename))
|
||||||
|
SDL_snprintf(filename, sizeof(filename), "yeti%03d.bmp", screenshot_idx++);
|
||||||
|
|
||||||
|
SDL_SaveBMP(screen, filename);
|
||||||
|
SDL_Log("Saved screenshot %s", filename);
|
||||||
|
|
||||||
|
SDL_DestroySurface(screen);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_EVENT_MOUSE_MOTION:
|
||||||
|
if (focused)
|
||||||
|
{
|
||||||
|
yeti.camera->p += fl2f(event->motion.yrel);
|
||||||
|
yeti.camera->t += fl2f(event->motion.xrel);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SDL_APP_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDL_AppQuit(void *appstate, SDL_AppResult result)
|
||||||
|
{
|
||||||
|
if (window) SDL_DestroyWindow(window);
|
||||||
|
if (renderer) SDL_DestroyRenderer(renderer);
|
||||||
|
if (texture) SDL_DestroyTexture(texture);
|
||||||
|
|
||||||
|
SDL_Quit();
|
||||||
|
}
|
BIN
screenshots/yeti006.png
Normal file
BIN
screenshots/yeti006.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 225 KiB |
BIN
screenshots/yeti007.png
Normal file
BIN
screenshots/yeti007.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 238 KiB |
BIN
screenshots/yeti008.png
Normal file
BIN
screenshots/yeti008.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 196 KiB |
|
@ -1,3 +0,0 @@
|
||||||
del *.obj
|
|
||||||
del *.~*
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
del *.obj
|
|
||||||
del *.~*
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ void player_tick(yeti_t* yeti, entity_t* e)
|
||||||
|
|
||||||
void player_init(entity_t* e)
|
void player_init(entity_t* e)
|
||||||
{
|
{
|
||||||
e->radius = 0;
|
e->radius = 64;
|
||||||
e->ontick = player_tick;
|
e->ontick = player_tick;
|
||||||
animation_init(&e->animation, 0, 0, 8, 192, LOOP_FOREVER);
|
animation_init(&e->animation, 0, 0, 8, 192, LOOP_FOREVER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
#include "y3d/y3d_yeti.h"
|
#include "y3d_yeti.h"
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef __MAPS_H__
|
#ifndef __MAPS_H__
|
||||||
#define __MAPS_H__
|
#define __MAPS_H__
|
||||||
|
|
||||||
#include "y3d/y3d_yeti.h"
|
#include "y3d_yeti.h"
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
del *.obj
|
|
||||||
del *.~*
|
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -47,15 +49,15 @@ typedef unsigned __int64 u64;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
typedef signed char s8;
|
typedef int8_t s8;
|
||||||
typedef signed short s16;
|
typedef int16_t s16;
|
||||||
typedef signed long s32;
|
typedef int32_t s32;
|
||||||
typedef signed __int64 s64;
|
typedef int64_t s64;
|
||||||
|
|
||||||
typedef unsigned char u8;
|
typedef uint8_t u8;
|
||||||
typedef unsigned short u16;
|
typedef uint16_t u16;
|
||||||
typedef unsigned long u32;
|
typedef uint32_t u32;
|
||||||
typedef unsigned __int64 u64;
|
typedef uint64_t u64;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -69,7 +71,7 @@ typedef volatile s64 vs64;
|
||||||
typedef volatile u8 vu8;
|
typedef volatile u8 vu8;
|
||||||
typedef volatile u16 vu16;
|
typedef volatile u16 vu16;
|
||||||
typedef volatile u32 vu32;
|
typedef volatile u32 vu32;
|
||||||
//typedef volatile u64 vu64;
|
typedef volatile u64 vu64;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ extern "C"{
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
typedef struct rom_cell_t
|
typedef struct rom_cell
|
||||||
{
|
{
|
||||||
u8 swi; // Cell switchs (flags).
|
u8 swi; // Cell switchs (flags).
|
||||||
u8 ent; // Entity Id. Used for setting start locations for entities.
|
u8 ent; // Entity Id. Used for setting start locations for entities.
|
||||||
|
@ -93,7 +93,7 @@ typedef struct rom_cell_t
|
||||||
s8 bos; // Bottom offset.
|
s8 bos; // Bottom offset.
|
||||||
} rom_cell_t;
|
} rom_cell_t;
|
||||||
|
|
||||||
typedef struct cell_t
|
typedef struct cell
|
||||||
{
|
{
|
||||||
u8 swi; // Cell flags.
|
u8 swi; // Cell flags.
|
||||||
u8 ent; // Entity Id. Used for setting start locations for entities.
|
u8 ent; // Entity Id. Used for setting start locations for entities.
|
||||||
|
|
|
@ -182,7 +182,7 @@ void tmap_16_cs(polygon_t p, int n, u16* dst, u16* src, int mode)
|
||||||
{
|
{
|
||||||
do {i = lt_i--; if (lt_i < 0) lt_i = n - 1;} while ((lt_length = d[lt_i] - d[i]) <= 0);
|
do {i = lt_i--; if (lt_i < 0) lt_i = n - 1;} while ((lt_length = d[lt_i] - d[i]) <= 0);
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#if defined(__WIN32__) || defined(__SDL__)
|
||||||
lt_xx = (p[lt_i].x - (lt_x = p[i].x)) / lt_length;
|
lt_xx = (p[lt_i].x - (lt_x = p[i].x)) / lt_length;
|
||||||
lt_uu = (p[lt_i].u - (lt_u = p[i].u)) / lt_length;
|
lt_uu = (p[lt_i].u - (lt_u = p[i].u)) / lt_length;
|
||||||
lt_vv = (p[lt_i].v - (lt_v = p[i].v)) / lt_length;
|
lt_vv = (p[lt_i].v - (lt_v = p[i].v)) / lt_length;
|
||||||
|
@ -196,7 +196,7 @@ void tmap_16_cs(polygon_t p, int n, u16* dst, u16* src, int mode)
|
||||||
{
|
{
|
||||||
do {i = rt_i++; if (rt_i >= n) rt_i = 0;} while ((rt_length = d[rt_i] - d[i]) <= 0);
|
do {i = rt_i++; if (rt_i >= n) rt_i = 0;} while ((rt_length = d[rt_i] - d[i]) <= 0);
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#if defined(__WIN32__) || defined(__SDL__)
|
||||||
rt_xx = (p[rt_i].x - (rt_x = p[i].x)) / rt_length;
|
rt_xx = (p[rt_i].x - (rt_x = p[i].x)) / rt_length;
|
||||||
#else
|
#else
|
||||||
rt_xx = r2i((p[rt_i].x - (rt_x = p[i].x)) * reciprocal[rt_length]);
|
rt_xx = r2i((p[rt_i].x - (rt_x = p[i].x)) * reciprocal[rt_length]);
|
||||||
|
|
|
@ -37,7 +37,7 @@ extern "C"{
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
#define XDITHER(I) ((((int)&fb[I])>>1)&1)
|
#define XDITHER(I) ((((intptr_t)&fb[I])>>1)&1)
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ void yeti_model_draw(yeti_t* yeti, entity_t* entity)
|
||||||
** merged into one. Since the variable usage of each was similar, I
|
** merged into one. Since the variable usage of each was similar, I
|
||||||
** achieved an overall speed boost.
|
** achieved an overall speed boost.
|
||||||
*/
|
*/
|
||||||
void yeti_quad_draw(yeti_t* yeti, cell_t* basecell, int tid, quad_t quad, int texgen)
|
void yeti_quad_draw(yeti_t* yeti, cell_t* basecell, int tid, quadrangle_t quad, int texgen)
|
||||||
{
|
{
|
||||||
int i, n, v[3];
|
int i, n, v[3];
|
||||||
polyclip_t p, a;
|
polyclip_t p, a;
|
||||||
|
@ -440,7 +440,7 @@ skip_transformation:
|
||||||
** to allow pre-quad effects like liquid and multi-texturing. Slower
|
** to allow pre-quad effects like liquid and multi-texturing. Slower
|
||||||
** processors can bypass the high-end features.
|
** processors can bypass the high-end features.
|
||||||
*/
|
*/
|
||||||
void yeti_quad(yeti_t* yeti, cell_t* basecell, int tid, quad_t quad, int texgen)
|
void yeti_quad(yeti_t* yeti, cell_t* basecell, int tid, quadrangle_t quad, int texgen)
|
||||||
{
|
{
|
||||||
int i, mode;
|
int i, mode;
|
||||||
|
|
||||||
|
@ -591,7 +591,7 @@ void yeti_draw(yeti_t* yeti)
|
||||||
cell_vis_t vis;
|
cell_vis_t vis;
|
||||||
entity_t* e1;
|
entity_t* e1;
|
||||||
entity_t* e2;
|
entity_t* e2;
|
||||||
quad_t q;
|
quadrangle_t q;
|
||||||
cell_t* camcell;
|
cell_t* camcell;
|
||||||
cell_t* c;
|
cell_t* c;
|
||||||
cell_t* d;
|
cell_t* d;
|
||||||
|
|
|
@ -25,7 +25,7 @@ extern "C"{
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
typedef vec3_t quad_t[4];
|
typedef vec3_t quadrangle_t[4];
|
||||||
|
|
||||||
typedef struct bucket_node_t
|
typedef struct bucket_node_t
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,7 +37,12 @@ extern "C"{
|
||||||
#define ENTITY_LIGHT 5
|
#define ENTITY_LIGHT 5
|
||||||
#define ENTITY_BLOCKER 255
|
#define ENTITY_BLOCKER 255
|
||||||
|
|
||||||
typedef struct entity_visual_t
|
/* HACK */
|
||||||
|
typedef struct yeti yeti_t;
|
||||||
|
typedef struct entity entity_t;
|
||||||
|
typedef struct cell cell_t;
|
||||||
|
|
||||||
|
typedef struct entity_visual
|
||||||
{
|
{
|
||||||
u8 altpitch:1; // Use alternate pitch rotation.
|
u8 altpitch:1; // Use alternate pitch rotation.
|
||||||
u8 altroll:1; // Use alternate roll rotation.
|
u8 altroll:1; // Use alternate roll rotation.
|
||||||
|
@ -46,7 +51,7 @@ typedef struct entity_visual_t
|
||||||
s16 width; // 8:8 width.
|
s16 width; // 8:8 width.
|
||||||
s16 height; // 8:8 height.
|
s16 height; // 8:8 height.
|
||||||
void* data; // Rendering data. ie: Sprite or model.
|
void* data; // Rendering data. ie: Sprite or model.
|
||||||
void (*ondraw)(struct yeti_t* yeti, struct entity_t* e);
|
void (*ondraw)(yeti_t* yeti, struct entity* e);
|
||||||
} entity_visual_t;
|
} entity_visual_t;
|
||||||
|
|
||||||
typedef struct entity_state_t
|
typedef struct entity_state_t
|
||||||
|
@ -54,9 +59,9 @@ typedef struct entity_state_t
|
||||||
u16 pain;
|
u16 pain;
|
||||||
} entity_state_t;
|
} entity_state_t;
|
||||||
|
|
||||||
typedef struct entity_t
|
typedef struct entity
|
||||||
{
|
{
|
||||||
struct entity_t* next;
|
struct entity* next;
|
||||||
void* tag;
|
void* tag;
|
||||||
|
|
||||||
entity_visual_t visual;
|
entity_visual_t visual;
|
||||||
|
@ -81,12 +86,12 @@ typedef struct entity_t
|
||||||
s16 ry; // View space Y position
|
s16 ry; // View space Y position
|
||||||
s16 rz; // View space Z position
|
s16 rz; // View space Z position
|
||||||
|
|
||||||
void (*ontick)(struct yeti_t* yeti, struct entity_t* e);
|
void (*ontick)(yeti_t* yeti, entity_t* e);
|
||||||
void (*onhit)(struct yeti_t* yeti, struct entity_t* e1, struct entity_t* e2);
|
void (*onhit)(yeti_t* yeti, entity_t* e1, entity_t* e2);
|
||||||
void (*onwall)(struct yeti_t* yeti, struct entity_t* e, struct cell_t* c);
|
void (*onwall)(yeti_t* yeti, entity_t* e, cell_t* c);
|
||||||
} entity_t;
|
} entity_t;
|
||||||
|
|
||||||
typedef void (*entity_behaviour_t)(struct yeti_t* yeti, entity_t* e);
|
typedef void (*entity_behaviour_t)(yeti_t* yeti, entity_t* e);
|
||||||
|
|
||||||
// The maxium number of entities allocated. Instead of increasing this, try
|
// The maxium number of entities allocated. Instead of increasing this, try
|
||||||
// to reuse entities via entity pools.
|
// to reuse entities via entity pools.
|
||||||
|
|
|
@ -153,7 +153,7 @@ void pixel_buffer_draw(
|
||||||
#define AFFINE(I) fb[I] = pixel_converter->item[*tb++];
|
#define AFFINE(I) fb[I] = pixel_converter->item[*tb++];
|
||||||
AFFINE_LOOP()
|
AFFINE_LOOP()
|
||||||
#undef AFFINE
|
#undef AFFINE
|
||||||
video = (u16*)((int)video + pitch);
|
video = (u16*)((intptr_t)video + pitch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,6 +271,26 @@ extern int YetiFrameBufferHeight;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __SDL__
|
||||||
|
|
||||||
|
#define YETI_RGB555
|
||||||
|
|
||||||
|
#define YETI_VIEWPORT_INTERVAL 35
|
||||||
|
|
||||||
|
#define YETI_FRAMEBUFFER_WIDTH 640
|
||||||
|
#define YETI_FRAMEBUFFER_HEIGHT 480
|
||||||
|
#define YETI_VIEWPORT_X1 0
|
||||||
|
#define YETI_VIEWPORT_Y1 0
|
||||||
|
#define YETI_VIEWPORT_X2 YETI_FRAMEBUFFER_WIDTH
|
||||||
|
#define YETI_VIEWPORT_Y2 YETI_FRAMEBUFFER_HEIGHT
|
||||||
|
#define TEXT_SCALE 1
|
||||||
|
|
||||||
|
#define YETI_GAMMA (2.1)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
#ifdef YETI_RGB555
|
#ifdef YETI_RGB555
|
||||||
#define RGB_BLEND_MASK 0x7BDE
|
#define RGB_BLEND_MASK 0x7BDE
|
||||||
#define RGB_SET(R,G,B) (((B)<<10)|((G)<<5)|(R))
|
#define RGB_SET(R,G,B) (((B)<<10)|((G)<<5)|(R))
|
||||||
|
|
|
@ -52,7 +52,7 @@ extern "C"{
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#if defined(__WIN32__) || defined(__SDL__)
|
||||||
#define YETI_RAY_WIDTH 100
|
#define YETI_RAY_WIDTH 100
|
||||||
#define YETI_RAY_MAX 256
|
#define YETI_RAY_MAX 256
|
||||||
#ifdef __YETI_EDITOR__
|
#ifdef __YETI_EDITOR__
|
||||||
|
@ -150,7 +150,7 @@ typedef struct visual_t
|
||||||
typedef STATICARRAY(point8_t, YETI_CELL_MAX) cell_vis_t;
|
typedef STATICARRAY(point8_t, YETI_CELL_MAX) cell_vis_t;
|
||||||
typedef STATICARRAY(entity_t* , YETI_BULLET_MAX) bullet_array_t;
|
typedef STATICARRAY(entity_t* , YETI_BULLET_MAX) bullet_array_t;
|
||||||
|
|
||||||
typedef struct yeti_t
|
typedef struct yeti
|
||||||
{
|
{
|
||||||
game_t game;
|
game_t game;
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ typedef struct yeti_t
|
||||||
|
|
||||||
vertex_t verts[YETI_MODEL_VERTEX_MAX];
|
vertex_t verts[YETI_MODEL_VERTEX_MAX];
|
||||||
|
|
||||||
void (*onhit)(struct yeti_t* yeti, struct entity_t* e1, struct entity_t* e2);
|
void (*onhit)(struct yeti* yeti, struct entity* e1, struct entity* e2);
|
||||||
} yeti_t;
|
} yeti_t;
|
||||||
|
|
||||||
#define YETI_BULLET(YETI) ((YETI)->bullets.item[(YETI)->bullets.length++ & YETI_BULLET_MASK])
|
#define YETI_BULLET(YETI) ((YETI)->bullets.item[(YETI)->bullets.length++ & YETI_BULLET_MASK])
|
||||||
|
|
Loading…
Reference in a new issue