Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FF8] Research for WM + battle texture replacement #564

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@

- Common: Fix startup hang on launch
- Common: Fix jp version crash
- Config: enable worldmap fixes by default
- Graphics: Add Field texture replacement ( https://github.com/julianxhokaxhiu/FFNx/pull/542 https://github.com/julianxhokaxhiu/FFNx/pull/545 )
- Graphics: Add Battle texture replacement ( https://github.com/julianxhokaxhiu/FFNx/pull/564 )
- Graphics: Fix wrong texture replacements in battle
- Graphics: Fix bad texture UVs in worldmap ( https://github.com/julianxhokaxhiu/FFNx/pull/564 )
- Graphics: Disable texture filtering for external textures, as sprites can overlap or look bad in FF8

# 1.15.0

Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ We are always open for contributions via PRs, and in case you want to join the c
#### FF8
- Vibration support
- **Voice acting**
- Maki's patch for worldmap included
- Various graphical patches for worldmap included
- Enable the VRAM debug window while playing in order to see how the engine uploads textures

### As a modder
Expand All @@ -102,10 +102,11 @@ For a more in-depth documentation feel free to visit the [docs/](docs/) folder.

## Screenshots

| Vanilla/Steam |
| :-------------------------------------------------------: |
| ![Final Fantasy VII running on Vulkan](.screens/ff7.png) |
| ![Final Fantasy VIII running on Vulkan](.screens/ff8.png) |
| Vanilla/Steam |
| :--------------------------------------------------------------------------------------------------: |
| ![Final Fantasy VII running on Vulkan](.screens/ff7.png) |
| ![Final Fantasy VIII running on Vulkan](.screens/ff8.png) |
| [![Final Fantasy VIII Worldmap graphical patches](.screens/ff8-worldmap-official-release-vs-ffnx.png)](https://imgsli.com/MTg5NjQ2) |

## Tech Stack

Expand Down
4 changes: 4 additions & 0 deletions misc/FFNx.toml
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ save_path = "save"
#~~~~~~~~~~~~~~~~~~~~~~~~~~~
ff8_worldmap_internal_highres_textures = true

# Attempt to fix texturing holes by restoring full precision from the game data
#~~~~~~~~~~~~~~~~~~~~~~~~~~~
ff8_fix_uv_coords_precision = true

## GAME INSTALLATION OPTIONS

#[APP PATH]
Expand Down
4 changes: 3 additions & 1 deletion src/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ double hdr_max_nits;
long external_audio_number_of_channels;
long external_audio_sample_rate;
bool ff8_worldmap_internal_highres_textures;
bool ff8_fix_uv_coords_precision;
std::string app_path;
std::string data_drive;

Expand Down Expand Up @@ -271,7 +272,8 @@ void read_cfg()
hdr_max_nits = config["hdr_max_nits"].value_or(0);
external_audio_number_of_channels = config["external_audio_number_of_channels"].value_or(2);
external_audio_sample_rate = config["external_audio_sample_rate"].value_or(44100);
ff8_worldmap_internal_highres_textures = config["ff8_worldmap_internal_highres_textures"].value_or(false);
ff8_worldmap_internal_highres_textures = config["ff8_worldmap_internal_highres_textures"].value_or(true);
ff8_fix_uv_coords_precision = config["ff8_fix_uv_coords_precision"].value_or(true);
app_path = config["app_path"].value_or("");
data_drive = config["data_drive"].value_or("");

Expand Down
1 change: 1 addition & 0 deletions src/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ extern double hdr_max_nits;
extern long external_audio_number_of_channels;
extern long external_audio_sample_rate;
extern bool ff8_worldmap_internal_highres_textures;
extern bool ff8_fix_uv_coords_precision;
extern std::string app_path;
extern std::string data_drive;

Expand Down
10 changes: 7 additions & 3 deletions src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include "ff8/vram.h"
#include "ff8/vibration.h"
#include "ff8/engine.h"
#include "ff8/uv_patch.h"

bool proxyWndProc = false;

Expand Down Expand Up @@ -866,6 +867,9 @@ int common_create_window(HINSTANCE hInstance, struct game_obj* game_object)
if (ff8)
{
vram_init();
if (ff8_fix_uv_coords_precision) {
uv_patch_init();
}
vibration_init();
}

Expand Down Expand Up @@ -1764,17 +1768,17 @@ struct texture_set *common_load_texture(struct texture_set *_texture_set, struct
if(tex_format->palettes == 0) tex_format->palettes = VREF(tex_header, palette_entries);

// convert texture data from source format and load it
if(texture_format != 0 && VREF(tex_header, image_data) != 0)
if(texture_format != 0 && VREF(tex_header, image_data) != 0 && (! ff8 || ! texturePacker.drawTexturesBackgroundIsDisabled()))
{
// detect changes in palette data for FF8, we can't trust it to notify us
if(ff8 && VREF(tex_header, palettes) > 0 && VREF(tex_header, version) != FB_TEX_VERSION)
if(ff8 && VREF(tex_header, palettes) > 0 && VREF(tex_header, version) != FB_TEX_VERSION && tex_format->bytesperpixel == 1)
{
if(!VREF(tex_header, old_palette_data))
{
VRASS(tex_header, old_palette_data, (unsigned char*)external_malloc(4 * tex_format->palette_size));
}

if(memcmp(VREF(tex_header, old_palette_data), tex_format->palette_data, 4 * tex_format->palette_size))
if(memcmp(VREF(tex_header, old_palette_data), tex_format->palette_data, 4 * tex_format->palette_size) != 0)
{
for (uint32_t idx = 0; idx < VREF(texture_set, ogl.gl_set->textures); idx++)
newRenderer.deleteTexture(VREF(texture_set, texturehandle[idx]));
Expand Down
27 changes: 24 additions & 3 deletions src/ff8.h
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,14 @@ struct ff8_externals
uint32_t ssigpu_init;
uint32_t *d3dcaps;
uint32_t sub_53BB90;
uint32_t worldmap_fog_filter_polygons_in_block_1;
uint32_t worldmap_polygon_condition_2045C8C;
uint32_t worldmap_has_polygon_condition_2045C90;
uint32_t worldmap_sub_45DF20;
uint32_t sub_45E3A0;
uint32_t worldmap_fog_filter_polygons_in_block_2;
uint32_t sub_461E00;
uint32_t dword_1CA8848;
uint32_t sub_53E2A0;
uint32_t sub_53E6B0;
uint32_t sub_4023D0;
Expand All @@ -1102,7 +1110,7 @@ struct ff8_externals
uint32_t sub_54A0D0;
uint32_t sub_54D7E0;
uint32_t sub_54FDA0;
uint32_t sub_53FAC0;
uint32_t worldmap_with_fog_sub_53FAC0;
uint32_t sub_550070;
int (*sub_541C80)(int);
uint32_t sub_54B460;
Expand All @@ -1120,7 +1128,6 @@ struct ff8_externals
uint32_t stop_music;
uint32_t set_midi_volume;
uint32_t sub_46C050;
uint32_t sub_500900;
uint32_t sub_501B60;
uint32_t pause_music_and_sfx;
uint32_t restart_music_and_sfx;
Expand Down Expand Up @@ -1171,8 +1178,9 @@ struct ff8_externals
uint32_t *ssigpu_callbacks_2;
uint32_t sub_462AD0;
uint32_t sub_462DF0;
uint32_t sub_461220;
uint32_t ssigpu_tx_select_2_sub_465CE0;
int (*sub_464F70)(int, int, int, int, int, int, int, int, int, uint8_t *);
int (*sub_464F70)(struc_50 *, texture_page *, int, int, int, int, int, int, int, uint8_t *);
void(*read_vram_1)(uint8_t *, int, uint8_t *, int, signed int, int, int);
void(*read_vram_2_paletted)(uint8_t *, int, uint8_t *, int, signed int, int, int, uint16_t *);
void(*read_vram_3_paletted)(uint8_t *, uint8_t *, signed int, int, int, uint16_t *);
Expand Down Expand Up @@ -1247,6 +1255,19 @@ struct ff8_externals
ff8_audio_fmt **sfx_audio_fmt;
uint32_t manage_time_engine_sub_569971;
int (*enable_rdtsc_sub_40AA00)(int enable);
uint32_t loc_47D490;
uint32_t sub_500870;
uint32_t sub_500C00;
uint32_t sub_500CC0;
uint32_t sub_506C90;
uint32_t sub_506CF0;
uint32_t sub_5084B0;
uint32_t battle_open_file_wrapper;
uint32_t battle_open_file;
char **battle_filenames;
uint32_t battle_load_textures_sub_500900;
uint32_t loc_5005A0;
uint32_t battle_upload_texture_to_vram;
};

void ff8gl_field_78(struct ff8_polygon_set *polygon_set, struct ff8_game_obj *game_object);
Expand Down
Loading