mirror of https://github.com/sm64pc/sm64pc.git
Merge remote-tracking branch 'upstream/nightly' into rumble_back
This commit is contained in:
commit
cf122ee6e8
|
@ -245,6 +245,7 @@ static inline u8 *convert_ia8_char(u8 c, u16 *tex, s16 w, s16 h) {
|
||||||
#ifdef EXTERNAL_TEXTURES
|
#ifdef EXTERNAL_TEXTURES
|
||||||
return (u8 *)tex; // the data's just a name
|
return (u8 *)tex; // the data's just a name
|
||||||
#else
|
#else
|
||||||
|
if (!tex) return NULL;
|
||||||
if (!charCache[c].used) {
|
if (!charCache[c].used) {
|
||||||
charCache[c].used = 1;
|
charCache[c].used = 1;
|
||||||
alloc_ia8_text_from_i1(charCache[c].data, tex, w, h);
|
alloc_ia8_text_from_i1(charCache[c].data, tex, w, h);
|
||||||
|
@ -305,6 +306,7 @@ static u8 *convert_ia4_char(u8 c, u8 *tex, s16 w, s16 h) {
|
||||||
#ifdef EXTERNAL_TEXTURES
|
#ifdef EXTERNAL_TEXTURES
|
||||||
return tex; // the data's just a name
|
return tex; // the data's just a name
|
||||||
#else
|
#else
|
||||||
|
if (!tex) return NULL;
|
||||||
if (!charCache[c].used) {
|
if (!charCache[c].used) {
|
||||||
charCache[c].used = 1;
|
charCache[c].used = 1;
|
||||||
alloc_ia4_tex_from_i1(charCache[c].data, tex, w, h);
|
alloc_ia4_tex_from_i1(charCache[c].data, tex, w, h);
|
||||||
|
|
|
@ -231,7 +231,7 @@ void configfile_load(const char *filename) {
|
||||||
// Go through each line in the file
|
// Go through each line in the file
|
||||||
while ((line = read_file_line(file)) != NULL) {
|
while ((line = read_file_line(file)) != NULL) {
|
||||||
char *p = line;
|
char *p = line;
|
||||||
char *tokens[2];
|
char *tokens[1 + MAX_BINDS];
|
||||||
int numTokens;
|
int numTokens;
|
||||||
|
|
||||||
while (isspace(*p))
|
while (isspace(*p))
|
||||||
|
@ -240,7 +240,7 @@ void configfile_load(const char *filename) {
|
||||||
if (!*p || *p == '#') // comment or empty line
|
if (!*p || *p == '#') // comment or empty line
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
numTokens = tokenize_string(p, 2, tokens);
|
numTokens = tokenize_string(p, sizeof(tokens) / sizeof(tokens[0]), tokens);
|
||||||
if (numTokens != 0) {
|
if (numTokens != 0) {
|
||||||
if (numTokens >= 2) {
|
if (numTokens >= 2) {
|
||||||
const struct ConfigOption *option = NULL;
|
const struct ConfigOption *option = NULL;
|
||||||
|
@ -274,7 +274,9 @@ void configfile_load(const char *filename) {
|
||||||
default:
|
default:
|
||||||
assert(0); // bad type
|
assert(0); // bad type
|
||||||
}
|
}
|
||||||
printf("option: '%s', value: '%s'\n", tokens[0], tokens[1]);
|
printf("option: '%s', value:", tokens[0]);
|
||||||
|
for (int i = 1; i < numTokens; ++i) printf(" '%s'", tokens[i]);
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
puts("error: expected value");
|
puts("error: expected value");
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "lib/src/libultra_internal.h"
|
#include "lib/src/libultra_internal.h"
|
||||||
#include "lib/src/osContInternal.h"
|
#include "lib/src/osContInternal.h"
|
||||||
|
|
||||||
|
#include "../configfile.h"
|
||||||
|
|
||||||
#include "controller_recorded_tas.h"
|
#include "controller_recorded_tas.h"
|
||||||
#include "controller_keyboard.h"
|
#include "controller_keyboard.h"
|
||||||
#include "controller_sdl.h"
|
#include "controller_sdl.h"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -573,30 +574,47 @@ static bool preload_texture(const char *path) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void load_texture(const char *name) {
|
||||||
|
static char fpath[SYS_MAX_PATH];
|
||||||
|
int w, h;
|
||||||
|
const char *texname = name;
|
||||||
|
|
||||||
|
if (!texname[0]) {
|
||||||
|
fprintf(stderr, "empty texture name at %p\n", texname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(fpath, sizeof(fpath), "%s/%s.png", sys_data_path(), texname);
|
||||||
|
u8 *data = stbi_load(fpath, &w, &h, NULL, 4);
|
||||||
|
if (!data) {
|
||||||
|
fprintf(stderr, "could not load texture: `%s`\n", fpath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx_rapi->upload_texture(data, w, h);
|
||||||
|
stbi_image_free(data); // don't need this anymore
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EXTERNAL_TEXTURES
|
#endif // EXTERNAL_TEXTURES
|
||||||
|
|
||||||
static void import_texture(int tile) {
|
static void import_texture(int tile) {
|
||||||
uint8_t fmt = rdp.texture_tile.fmt;
|
uint8_t fmt = rdp.texture_tile.fmt;
|
||||||
uint8_t siz = rdp.texture_tile.siz;
|
uint8_t siz = rdp.texture_tile.siz;
|
||||||
|
|
||||||
|
if (!rdp.loaded_texture[tile].addr) {
|
||||||
|
fprintf(stderr, "NULL texture: tile %d, format %d/%d, size %d\n",
|
||||||
|
tile, (int)fmt, (int)siz, (int)rdp.loaded_texture[tile].size_bytes);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (gfx_texture_cache_lookup(tile, &rendering_state.textures[tile], rdp.loaded_texture[tile].addr, fmt, siz)) {
|
if (gfx_texture_cache_lookup(tile, &rendering_state.textures[tile], rdp.loaded_texture[tile].addr, fmt, siz)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EXTERNAL_TEXTURES
|
#ifdef EXTERNAL_TEXTURES
|
||||||
// the "texture data" is actually a C string with the path to our texture in it
|
// the "texture data" is actually a C string with the path to our texture in it
|
||||||
// load it from an external image in our data path
|
// load it from an external image in our data path
|
||||||
static char fpath[SYS_MAX_PATH];
|
load_texture((const char*)rdp.loaded_texture[tile].addr);
|
||||||
int w, h;
|
|
||||||
const char *texname = (const char*)rdp.loaded_texture[tile].addr;
|
|
||||||
snprintf(fpath, sizeof(fpath), "%s/%s.png", sys_data_path(), texname);
|
|
||||||
u8 *data = stbi_load(fpath, &w, &h, NULL, 4);
|
|
||||||
if (!data) {
|
|
||||||
fprintf(stderr, "could not load texture: `%s`\n", fpath);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
gfx_rapi->upload_texture(data, w, h);
|
|
||||||
stbi_image_free(data); // don't need this anymore
|
|
||||||
#else
|
#else
|
||||||
// the texture data is actual texture data
|
// the texture data is actual texture data
|
||||||
int t0 = get_time();
|
int t0 = get_time();
|
||||||
|
|
Loading…
Reference in New Issue