ENHANCE_LEVEL_TEXTURES and make all DynOS textures overridable in Lua

This commit is contained in:
Agent X 2023-11-11 12:15:32 -05:00
parent 140d50ebb2
commit 802affd839
25 changed files with 372 additions and 35 deletions

View file

@ -36,6 +36,8 @@ TARGET_BITS ?= 0
# Disable texture fixes by default (helps with them purists)
TEXTURE_FIX ?= 0
# Enable level texture enhancements by default (Castle Grounds and Castle Courtyard recolorable texture hills)
ENHANCE_LEVEL_TEXTURES ?= 1
# Enable Discord Game SDK (used for Discord invites)
DISCORD_SDK ?= 1
# Enable CoopNet SDK (used for CoopNet server hosting)
@ -1070,6 +1072,12 @@ ifeq ($(TEXTURE_FIX),1)
CFLAGS += -DTEXTURE_FIX
endif
# Check for enhance level textures option
ifeq ($(ENHANCE_LEVEL_TEXTURES),1)
CC_CHECK_CFLAGS += -DENHANCE_LEVEL_TEXTURES
CFLAGS += -DENHANCE_LEVEL_TEXTURES
endif
# Check for no bzero/bcopy workaround option
ifeq ($(NO_BZERO_BCOPY),1)
CC_CHECK_CFLAGS += -DNO_BZERO_BCOPY

View file

@ -301,6 +301,8 @@ manual_index_documentation = """
- [djui_hud_render_texture_tile](#djui_hud_render_texture_tile)
- [djui_hud_render_texture_interpolated](#djui_hud_render_texture_interpolated)
- [djui_hud_render_texture_tile_interpolated](#djui_hud_render_texture_tile_interpolated)
- [texture_override_set](#texture_override_set)
- [texture_override_reset](#texture_override_reset)
- [smlua_anim_util_register_animation](#smlua_anim_util_register_animation)
- [level_script_parse](#level_script_parse)
- [set_exclamation_box_contents](#set_exclamation_box_contents)
@ -540,6 +542,51 @@ Renders an interpolated tile of a texture to the screen.
<br />
## [texture_override_reset](#texture_override_reset)
Resets an overridden texture.
### Lua Example
`texture_override_reset("outside_09004000")`
### Parameters
| Field | Type |
| ----- | ---- |
| textureName | `string` |
### Returns
- None
### C Prototype
`void dynos_texture_override_reset(const char* textureName);`
[:arrow_up_small:](#)
<br />
## [texture_override_set](#texture_override_set)
Overrides a texture with a custom `TextureInfo`.
### Lua Example
`texture_override_set("outside_09004000", overrideTexInfo)`
### Parameters
| Field | Type |
| ----- | ---- |
| textureName | `string` |
| overrideTexInfo | [TextureInfo](structs.md#TextureInfo) |
### Returns
- None
### C Prototype
`void dynos_texture_override_set(const char* textureName, struct TextureInfo* overrideTexInfo);`
[:arrow_up_small:](#)
<br />
## [smlua_anim_util_register_animation](#smlua_anim_util_register_animation)
Register a new Lua animation.

View file

@ -164,33 +164,35 @@ function network_init_object(object, standardSync, fieldTable)
-- ...
end
--- @param object Object
--- @param reliable boolean
--- @param object Object Object to sync
--- @param reliable boolean Whether or not the game should try to resend the packet in case its lost, good for important packets
--- @return nil
--- Sends a sync packet to sync up the object with everyone else
function network_send_object(object, reliable)
-- ...
end
--- @param reliable boolean
--- @param dataTable table
--- @param reliable boolean Whether or not the game should try to resend the packet in case its lost, good for important packets
--- @param dataTable table Table of values to be included in the packet
--- @return nil
--- Note: `dataTable` can only contain strings, integers, numbers, booleans, and nil
--- `dataTable` can only contain strings, integers, numbers, booleans, and nil
function network_send(reliable, dataTable)
-- ...
end
--- @param toLocalIndex integer
--- @param reliable boolean
--- @param dataTable table
--- @param toLocalIndex integer The local index to send the packet to
--- @param reliable boolean Whether or not the game should try to resend the packet in case its lost, good for important packets
--- @param dataTable table Table of values to be included in the packet
--- @return nil
--- Note: `dataTable` can only contain strings, integers, numbers, booleans, and nil
--- `dataTable` can only contain strings, integers, numbers, booleans, and nil
function network_send_to(toLocalIndex, reliable, dataTable)
-- ...
end
--- @param textureName string
--- @return TextureInfo
--- Gets the `TextureInfo` of a texture by name
--- - Note: This also works with vanilla textures
function get_texture_info(textureName)
-- ...
end
@ -201,6 +203,7 @@ end
--- @param scaleW number
--- @param scaleH number
--- @return nil
--- Renders a texture to the screen
function djui_hud_render_texture(texInfo, x, y, scaleW, scaleH)
-- ...
end
@ -215,6 +218,7 @@ end
--- @param tileW number
--- @param tileH number
--- @return nil
--- Renders a tile of a texture to the screen
function djui_hud_render_texture_tile(texInfo, x, y, scaleW, scaleH, tileX, tileY, tileW, tileH)
-- ...
end
@ -229,6 +233,7 @@ end
--- @param scaleW number
--- @param scaleH number
--- @return nil
--- Renders an interpolated texture to the screen
function djui_hud_render_texture_interpolated(texInfo, prevX, prevY, prevScaleW, prevScaleH, x, y, scaleW, scaleH)
-- ...
end
@ -247,10 +252,26 @@ end
--- @param tileW number
--- @param tileH number
--- @return nil
--- Renders an interpolated tile of a texture to the screen
function djui_hud_render_texture_tile_interpolated(texInfo, prevX, prevY, prevScaleW, prevScaleH, x, y, scaleW, scaleH, tileX, tileY, tileW, tileH)
-- ...
end
--- @param textureName string
--- @param overrideTexInfo TextureInfo
--- @return nil
--- Overrides a texture with a custom `TextureInfo`
function texture_override_set(textureName, overrideTexInfo)
-- ...
end
--- @param textureName string
--- @return nil
--- Resets an overridden texture
function texture_override_reset(textureName)
-- ...
end
--- @param name string
--- @param flags integer
--- @param animYTransDivisor integer
@ -260,6 +281,7 @@ end
--- @param values table
--- @param index table
--- @return nil
--- Registers an animation that can be used in objects if `smlua_anim_util_set_animation` is called
function smlua_anim_util_register_animation(name, flags, animYTransDivisor, startFrame, loopStart, loopEnd, values, index)
-- ...
end

View file

@ -2085,6 +2085,7 @@
--- @class TextureInfo
--- @field public bitSize integer
--- @field public height integer
--- @field public name string
--- @field public texture Pointer_integer
--- @field public width integer

View file

@ -47,6 +47,8 @@ Collision* dynos_collision_get(const char* collisionName);
// -- textures -- //
void dynos_add_texture(const char *filePath, const char* textureName);
bool dynos_texture_get(const char* textureName, struct TextureInfo* outTextureInfo);
void dynos_texture_override_set(const char* textureName, struct TextureInfo* overrideTextureInfo);
void dynos_texture_override_reset(const char* textureName);
// -- movtexqcs -- //
void dynos_movtexqc_register(const char* name, s16 level, s16 area, s16 type);

View file

@ -910,6 +910,8 @@ void DynOS_Tex_Activate(DataNode<TexData>* aNode, bool aCustomTexture);
void DynOS_Tex_Deactivate(DataNode<TexData>* aNode);
void DynOS_Tex_AddCustom(const SysPath &aFilename, const char *aTexName);
bool DynOS_Tex_Get(const char* aTexName, struct TextureInfo* aOutTexInfo);
void DynOS_Tex_Override_Set(const char* textureName, struct TextureInfo* aOverrideTexInfo);
void DynOS_Tex_Override_Reset(const char* textureName);
void DynOS_Tex_ModShutdown();
//

View file

@ -148,6 +148,14 @@ bool dynos_texture_get(const char* textureName, struct TextureInfo* outTextureIn
return DynOS_Tex_Get(textureName, outTextureInfo);
}
void dynos_texture_override_set(const char* textureName, struct TextureInfo* overrideTextureInfo) {
DynOS_Tex_Override_Set(textureName, overrideTextureInfo);
}
void dynos_texture_override_reset(const char* textureName) {
DynOS_Tex_Override_Reset(textureName);
}
// -- movtexqcs -- //
void dynos_movtexqc_register(const char* name, s16 level, s16 area, s16 type) {

View file

@ -1177,12 +1177,14 @@ extern ALIGNED8 const Texture bowser_2_seg7_texture_07000000[];
extern ALIGNED8 const Texture bowser_3_seg7_texture_07000000[];
extern ALIGNED8 const Texture bowser_3_seg7_texture_07000800[];
extern ALIGNED8 const Texture bowser_3_seg7_texture_07001000[];
extern ALIGNED8 const Texture castle_courtyard_seg7_texture_07000000[];
extern ALIGNED8 const Texture castle_grounds_seg7_texture_0700C9E8[];
extern ALIGNED8 const Texture castle_grounds_seg7_texture_0700D9E8[];
extern ALIGNED8 const Texture castle_grounds_seg7_us_texture_0700EAE8[];
extern ALIGNED8 const Texture castle_grounds_seg7_texture_07000000[];
extern ALIGNED8 const Texture castle_grounds_seg7_texture_07001000[];
extern ALIGNED8 const Texture castle_grounds_seg7_texture_07002000[];
extern ALIGNED8 const Texture castle_grounds_seg7_texture_07003000[];
extern ALIGNED8 const Texture texture_castle_light[];
extern ALIGNED8 const Texture inside_castle_seg7_texture_07000800[];
extern ALIGNED8 const Texture inside_castle_seg7_texture_07001000[];

View file

@ -2321,6 +2321,11 @@ static const struct BuiltinTexInfo sDynosBuiltinTexs[] = {
//define_builtin_tex(texture_menu_kurs_upper, "levels/menu/main_menu_seg7_eu.0DDA0.rgba16.png"),
//define_builtin_tex(texture_menu_course_lower, "levels/menu/main_menu_seg7_eu.0EDA0.rgba16.png"),
#ifdef ENHANCE_LEVEL_TEXTURES
define_builtin_tex(castle_courtyard_seg7_texture_07000000, "levels/castle_courtyard/0_custom.rgba16.png", 32, 64, 16),
define_builtin_tex(castle_grounds_seg7_texture_07003000, "levels/castle_grounds/6_custom.rgba16.png", 32, 64, 16),
#endif
#ifdef VERSION_EU
define_builtin_tex(texture_menu_font_char_D, "levels/menu/main_menu_seg7_eu.0AF80.ia8.png", 8, 8, 16),
define_builtin_tex(texture_menu_font_char_comma, "levels/menu/main_menu_seg7_eu.0B640.ia8.png", 8, 8, 16),

View file

@ -15,6 +15,11 @@ static std::map<const Texture*, struct OverrideTexture*>& DynosOverrideTextures(
return sDynosOverrideTextures;
}
static std::map<const Texture*, struct OverrideTexture*>& DynosOverrideLuaTextures() {
static std::map<const Texture*, struct OverrideTexture*> sDynosOverrideLuaTextures;
return sDynosOverrideLuaTextures;
}
// static set
static std::set<DataNode<TexData> *>& DynosValidTextures() {
static std::set<DataNode<TexData> *> sDynosValidTextures;
@ -298,6 +303,11 @@ void DynOS_Tex_Update() {
//
static DataNode<TexData> *DynOS_Tex_RetrieveNode(void *aPtr) {
auto _LuaOverride = DynosOverrideLuaTextures()[(const Texture*)aPtr];
if (_LuaOverride && _LuaOverride->node) {
return _LuaOverride->node;
}
auto _Override = DynosOverrideTextures()[(const Texture*)aPtr];
if (_Override && _Override->node) {
return _Override->node;
@ -343,6 +353,16 @@ static Array<Pair<const char*, DataNode<TexData>*>>& DynosCustomTexs() {
return sDynosCustomTexs;
}
static DataNode<TexData> *DynOS_Lua_Tex_RetrieveNode(const char* aName) {
auto& _DynosCustomTexs = DynosCustomTexs();
for (s32 i = 0; i < _DynosCustomTexs.Count(); ++i) {
if (!strcmp(_DynosCustomTexs[i].first, aName)) {
return _DynosCustomTexs[i].second;
}
}
return NULL;
}
void DynOS_Tex_Activate(DataNode<TexData>* aNode, bool aCustomTexture) {
if (!aNode) { return; }
@ -457,6 +477,7 @@ bool DynOS_Tex_Get(const char* aTexName, struct TextureInfo* aOutTexInfo) {
aOutTexInfo->width = _Data->mRawWidth;
aOutTexInfo->height = _Data->mRawHeight;
aOutTexInfo->texture = _Data->mRawData.begin();
aOutTexInfo->name = aTexName;
return true;
}
}
@ -468,10 +489,39 @@ bool DynOS_Tex_Get(const char* aTexName, struct TextureInfo* aOutTexInfo) {
aOutTexInfo->width = info->width;
aOutTexInfo->height = info->height;
aOutTexInfo->texture = (u8*)info->pointer;
aOutTexInfo->name = aTexName;
return true;
}
void DynOS_Tex_Override_Set(const char* aTexName, struct TextureInfo* aOverrideTexInfo) {
// Override texture
const Texture* _BuiltinTex = DynOS_Builtin_Tex_GetFromName(aTexName);
DataNode<TexData>* _Node = DynOS_Lua_Tex_RetrieveNode(aOverrideTexInfo->name);
if (!_BuiltinTex || !_Node) { return; }
auto& _DynosOverrideLuaTextures = DynosOverrideLuaTextures();
struct OverrideTexture* _Override = new OverrideTexture();
_Override->customTexture = false;
_Override->node = _Node;
_DynosOverrideLuaTextures[_BuiltinTex] = _Override;
}
void DynOS_Tex_Override_Reset(const char* aTexName) {
// Override texture
const Texture* _BuiltinTex = DynOS_Builtin_Tex_GetFromName(aTexName);
if (!_BuiltinTex) { return; }
auto& _DynosOverrideLuaTextures = DynosOverrideLuaTextures();
auto _Override = _DynosOverrideLuaTextures[_BuiltinTex];
if (_Override) {
_DynosOverrideLuaTextures.erase(_BuiltinTex);
}
}
void DynOS_Tex_ModShutdown() {
auto& _DynosOverrideLuaTextures = DynosOverrideLuaTextures();
_DynosOverrideLuaTextures.clear();
auto& _DynosCustomTexs = DynosCustomTexs();
while (_DynosCustomTexs.Count() > 0) {
auto& pair = _DynosCustomTexs[0];

View file

@ -19,6 +19,8 @@
- [djui_hud_render_texture_tile](#djui_hud_render_texture_tile)
- [djui_hud_render_texture_interpolated](#djui_hud_render_texture_interpolated)
- [djui_hud_render_texture_tile_interpolated](#djui_hud_render_texture_tile_interpolated)
- [texture_override_set](#texture_override_set)
- [texture_override_reset](#texture_override_reset)
- [smlua_anim_util_register_animation](#smlua_anim_util_register_animation)
- [level_script_parse](#level_script_parse)
- [set_exclamation_box_contents](#set_exclamation_box_contents)
@ -2019,6 +2021,51 @@ Renders an interpolated tile of a texture to the screen.
<br />
## [texture_override_reset](#texture_override_reset)
Resets an overridden texture.
### Lua Example
`texture_override_reset("outside_09004000")`
### Parameters
| Field | Type |
| ----- | ---- |
| textureName | `string` |
### Returns
- None
### C Prototype
`void dynos_texture_override_reset(const char* textureName);`
[:arrow_up_small:](#)
<br />
## [texture_override_set](#texture_override_set)
Overrides a texture with a custom `TextureInfo`.
### Lua Example
`texture_override_set("outside_09004000", overrideTexInfo)`
### Parameters
| Field | Type |
| ----- | ---- |
| textureName | `string` |
| overrideTexInfo | [TextureInfo](structs.md#TextureInfo) |
### Returns
- None
### C Prototype
`void dynos_texture_override_set(const char* textureName, struct TextureInfo* overrideTexInfo);`
[:arrow_up_small:](#)
<br />
## [smlua_anim_util_register_animation](#smlua_anim_util_register_animation)
Register a new Lua animation.

View file

@ -2652,6 +2652,7 @@
| ----- | ---- | ------ |
| bitSize | `integer` | read-only |
| height | `integer` | read-only |
| name | `string` | read-only |
| texture | `Pointer` <`integer`> | read-only |
| width | `integer` | read-only |

View file

@ -433,6 +433,7 @@ struct TextureInfo
u8 bitSize;
u32 width;
u32 height;
const char* name;
};
#define PLAY_MODE_NORMAL 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

View file

@ -692,6 +692,22 @@ static const Vtx castle_courtyard_seg7_vertex_07002180[] = {
// 0x070021C0 - 0x070022A0
static const Vtx castle_courtyard_seg7_vertex_070021C0[] = {
#ifdef ENHANCE_LEVEL_TEXTURES
{{{ -4095, 728, -3378}, 0, { 192, 2084}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -4486, 1000, -2810}, 0, { 364, 1576}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -3583, 512, -3071}, 0, { 36, 1792}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -3583, 614, -2047}, 0, { 96, 868}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -4914, 898, -2047}, 0, { 482, 1040}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -4709, 1382, -1228}, 0, { 556, 120}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -3583, 614, -1228}, 0, { 130, 160}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -3583, 512, -511}, 0, { 138, -424}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -4699, 1280, -501}, 0, { 564, -480}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -4455, 1638, 434}, 0, { 610, -1464}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -3583, 614, 307}, 0, { 192, -1172}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -4147, 1690, 755}, 0, { 556, -1820}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -3839, 1638, 1075}, 0, { 482, -2144}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -3071, 614, 717}, 0, { 80, -1628}, {0xff, 0xff, 0xff, 0xff}}},
#else
{{{ -4095, 728, -3378}, 0, { 192, 2084}, {0x30, 0xdb, 0x02, 0xff}}},
{{{ -4486, 1000, -2810}, 0, { 364, 1576}, {0x30, 0xdb, 0x02, 0xff}}},
{{{ -3583, 512, -3071}, 0, { 36, 1792}, {0x30, 0xdb, 0x02, 0xff}}},
@ -706,10 +722,27 @@ static const Vtx castle_courtyard_seg7_vertex_070021C0[] = {
{{{ -4147, 1690, 755}, 0, { 556, -1820}, {0x30, 0xdb, 0x02, 0xff}}},
{{{ -3839, 1638, 1075}, 0, { 482, -2144}, {0x30, 0xdb, 0x02, 0xff}}},
{{{ -3071, 614, 717}, 0, { 80, -1628}, {0x30, 0xdb, 0x02, 0xff}}},
#endif
};
// 0x070022A0 - 0x07002380
static const Vtx castle_courtyard_seg7_vertex_070022A0[] = {
#ifdef ENHANCE_LEVEL_TEXTURES
{{{ 4545, 666, -1135}, 0, { 614, 2096}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 3584, 614, -1228}, 0, { 62, 1720}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 3584, 512, -511}, 0, { 124, 1020}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -3839, 1638, 1075}, 0, { 482, -2144}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -3071, 1126, 1434}, 0, { 208, -2428}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -3071, 614, 717}, 0, { 80, -1628}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -2559, 512, 717}, 0, { -64, -1696}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -2559, 1024, 1434}, 0, { 62, -2496}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 3584, 614, 307}, 0, { 284, 240}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 4198, 1126, 307}, 0, { 820, 584}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 3651, 1000, 987}, 0, { 574, -348}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 3072, 614, 717}, 0, { 68, -404}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 4318, 1024, -460}, 0, { 732, 1376}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 3584, 614, -2047}, 0, { -54, 2508}, {0xff, 0xff, 0xff, 0xff}}},
#else
{{{ 4545, 666, -1135}, 0, { 614, 2096}, {0x30, 0xdb, 0x02, 0xff}}},
{{{ 3584, 614, -1228}, 0, { 62, 1720}, {0x30, 0xdb, 0x02, 0xff}}},
{{{ 3584, 512, -511}, 0, { 124, 1020}, {0x30, 0xdb, 0x02, 0xff}}},
@ -724,6 +757,7 @@ static const Vtx castle_courtyard_seg7_vertex_070022A0[] = {
{{{ 3072, 614, 717}, 0, { 68, -404}, {0x30, 0xdb, 0x02, 0xff}}},
{{{ 4318, 1024, -460}, 0, { 732, 1376}, {0x30, 0xdb, 0x02, 0xff}}},
{{{ 3584, 614, -2047}, 0, { -54, 2508}, {0x30, 0xdb, 0x02, 0xff}}},
#endif
};
// 0x07002380 - 0x07002470
@ -1382,7 +1416,11 @@ static const Gfx castle_courtyard_seg7_dl_070041A0[] = {
// 0x070041D8 - 0x07004370
static const Gfx castle_courtyard_seg7_dl_070041D8[] = {
#ifdef ENHANCE_LEVEL_TEXTURES
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, castle_courtyard_seg7_texture_07000000),
#else
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, outside_09004800),
#endif
gsDPLoadSync(),
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)),
gsSPVertex(castle_courtyard_seg7_vertex_070021C0, 14, 0),
@ -1398,6 +1436,11 @@ static const Gfx castle_courtyard_seg7_dl_070041D8[] = {
gsSP2Triangles( 8, 9, 2, 0x0, 8, 10, 9, 0x0),
gsSP2Triangles( 8, 11, 10, 0x0, 9, 12, 2, 0x0),
gsSP2Triangles(12, 0, 2, 0x0, 13, 1, 0, 0x0),
#ifdef ENHANCE_LEVEL_TEXTURES
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, outside_09004800),
gsDPLoadSync(),
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)),
#endif
gsSPVertex(castle_courtyard_seg7_vertex_07002380, 15, 0),
gsSP2Triangles( 0, 1, 2, 0x0, 1, 3, 2, 0x0),
gsSP2Triangles( 4, 5, 6, 0x0, 7, 8, 6, 0x0),

View file

@ -1,2 +1,3 @@
// Blank File
ALIGNED8 const Texture castle_courtyard_seg7_texture_07000000[] = {
#include "levels/castle_courtyard/0_custom.rgba16.inc.c"
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

View file

@ -42,8 +42,13 @@ static const Lights1 castle_grounds_seg7_lights_07006F68 = gdSPDefLights1(
// 0x07006F80 - 0x07006F98
static const Lights1 castle_grounds_seg7_lights_07006F80 = gdSPDefLights1(
#ifdef ENHANCE_LEVEL_TEXTURES
0x55, 0x55, 0x55,
0xff, 0xff, 0x0ff, 0x28, 0x28, 0x28
#else
0x13, 0x57, 0x00,
0x30, 0xdb, 0x02, 0x28, 0x28, 0x28
#endif
);
// 0x07006F98 - 0x07006FD8
@ -854,7 +859,11 @@ static const Gfx castle_grounds_seg7_dl_07009010[] = {
// 0x07009330 - 0x07009568
static const Gfx castle_grounds_seg7_dl_07009330[] = {
#ifdef ENHANCE_LEVEL_TEXTURES
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, castle_grounds_seg7_texture_07003000),
#else
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, outside_09004800),
#endif
gsDPLoadSync(),
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)),
gsSPLight(&castle_grounds_seg7_lights_07006F80.l, 1),

View file

@ -12,3 +12,7 @@ ALIGNED8 const Texture castle_grounds_seg7_texture_07001000[] = {
ALIGNED8 const Texture castle_grounds_seg7_texture_07002000[] = {
#include "levels/castle_grounds/2.rgba16.inc.c"
};
ALIGNED8 const Texture castle_grounds_seg7_texture_07003000[] = {
#include "levels/castle_grounds/6_custom.rgba16.inc.c"
};

View file

@ -34,7 +34,7 @@ struct Character gCharacters[CT_MAX] = {
.type = CT_MARIO,
.name = "Mario",
.hudHead = '(',
.hudHeadTexture = { .texture = (u8*)texture_hud_char_mario_head, .bitSize = 8, .width = 16, .height = 16 },
.hudHeadTexture = { .texture = (u8*)texture_hud_char_mario_head, .bitSize = 8, .width = 16, .height = 16, .name = "texture_hud_char_mario_head" },
.cameraHudHead = GLYPH_CAM_MARIO_HEAD,
.modelId = MODEL_MARIO,
.capModelId = MODEL_MARIOS_CAP,
@ -311,7 +311,7 @@ struct Character gCharacters[CT_MAX] = {
.type = CT_LUIGI,
.name = "Luigi",
.hudHead = ')',
.hudHeadTexture = { .texture = (u8*)texture_hud_char_luigi_head, .bitSize = 8, .width = 16, .height = 16 },
.hudHeadTexture = { .texture = (u8*)texture_hud_char_luigi_head, .bitSize = 8, .width = 16, .height = 16, .name = "texture_hud_char_luigi_head" },
.cameraHudHead = GLYPH_CAM_LUIGI_HEAD,
.modelId = MODEL_LUIGI,
.capModelId = MODEL_LUIGIS_CAP,
@ -588,7 +588,7 @@ struct Character gCharacters[CT_MAX] = {
.type = CT_TOAD,
.name = "Toad",
.hudHead = '|',
.hudHeadTexture = { .texture = (u8*)texture_hud_char_toad_head, .bitSize = 8, .width = 16, .height = 16 },
.hudHeadTexture = { .texture = (u8*)texture_hud_char_toad_head, .bitSize = 8, .width = 16, .height = 16, .name = "texture_hud_char_toad_head" },
.cameraHudHead = GLYPH_CAM_TOAD_HEAD,
.modelId = MODEL_TOAD_PLAYER,
.capModelId = MODEL_TOADS_CAP,
@ -865,7 +865,7 @@ struct Character gCharacters[CT_MAX] = {
.type = CT_WALUIGI,
.name = "Waluigi",
.hudHead = ']',
.hudHeadTexture = { .texture = (u8*)texture_hud_char_waluigi_head, .bitSize = 8, .width = 16, .height = 16 },
.hudHeadTexture = { .texture = (u8*)texture_hud_char_waluigi_head, .bitSize = 8, .width = 16, .height = 16, .name = "texture_hud_char_waluigi_head" },
.cameraHudHead = GLYPH_CAM_WALUIGI_HEAD,
.modelId = MODEL_WALUIGI,
.capModelId = MODEL_WALUIGIS_CAP,
@ -1145,7 +1145,7 @@ struct Character gCharacters[CT_MAX] = {
.type = CT_WARIO,
.name = "Wario",
.hudHead = '[',
.hudHeadTexture = { .texture = (u8*)texture_hud_char_wario_head, .bitSize = 8, .width = 16, .height = 16 },
.hudHeadTexture = { .texture = (u8*)texture_hud_char_wario_head, .bitSize = 8, .width = 16, .height = 16, .name = "texture_hud_char_wario_head" },
.cameraHudHead = GLYPH_CAM_WARIO_HEAD,
.modelId = MODEL_WARIO,
.capModelId = MODEL_WARIOS_CAP,

View file

@ -49,20 +49,20 @@ extern ALIGNED8 const u8 texture_hud_char_apostrophe[];
extern ALIGNED8 const u8 texture_hud_char_double_quote[];
struct GlobalTextures gGlobalTextures = {
.camera = { .texture = (u8*)texture_hud_char_camera, .bitSize = 8, .width = 16, .height = 16 },
.lakitu = { .texture = (u8*)texture_hud_char_lakitu, .bitSize = 8, .width = 16, .height = 16 },
.no_camera = { .texture = (u8*)texture_hud_char_no_camera, .bitSize = 8, .width = 16, .height = 16 },
.arrow_up = { .texture = (u8*)texture_hud_char_arrow_up, .bitSize = 8, .width = 8, .height = 8 },
.arrow_down = { .texture = (u8*)texture_hud_char_arrow_down, .bitSize = 8, .width = 8, .height = 8 },
.coin = { .texture = (u8*)texture_hud_char_coin, .bitSize = 8, .width = 16, .height = 16 },
.star = { .texture = (u8*)texture_hud_char_star, .bitSize = 8, .width = 16, .height = 16 },
.apostrophe = { .texture = (u8*)texture_hud_char_apostrophe, .bitSize = 8, .width = 16, .height = 16 },
.double_quote = { .texture = (u8*)texture_hud_char_double_quote, .bitSize = 8, .width = 16, .height = 16 },
.mario_head = { .texture = (u8*)texture_hud_char_mario_head, .bitSize = 8, .width = 16, .height = 16 },
.luigi_head = { .texture = (u8*)texture_hud_char_luigi_head, .bitSize = 8, .width = 16, .height = 16 },
.toad_head = { .texture = (u8*)texture_hud_char_toad_head, .bitSize = 8, .width = 16, .height = 16 },
.waluigi_head = { .texture = (u8*)texture_hud_char_waluigi_head, .bitSize = 8, .width = 16, .height = 16 },
.wario_head = { .texture = (u8*)texture_hud_char_wario_head, .bitSize = 8, .width = 16, .height = 16 }
.camera = { .texture = (u8*)texture_hud_char_camera, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_camera" },
.lakitu = { .texture = (u8*)texture_hud_char_lakitu, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_lakitu" },
.no_camera = { .texture = (u8*)texture_hud_char_no_camera, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_no_camera" },
.arrow_up = { .texture = (u8*)texture_hud_char_arrow_up, .bitSize = 8, .width = 8, .height = 8, "texture_hud_char_arrow_up" },
.arrow_down = { .texture = (u8*)texture_hud_char_arrow_down, .bitSize = 8, .width = 8, .height = 8, "texture_hud_char_arrow_down" },
.coin = { .texture = (u8*)texture_hud_char_coin, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_coin" },
.star = { .texture = (u8*)texture_hud_char_star, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_star" },
.apostrophe = { .texture = (u8*)texture_hud_char_apostrophe, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_apostrophe" },
.double_quote = { .texture = (u8*)texture_hud_char_double_quote, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_double_quote" },
.mario_head = { .texture = (u8*)texture_hud_char_mario_head, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_mario_head" },
.luigi_head = { .texture = (u8*)texture_hud_char_luigi_head, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_luigi_head" },
.toad_head = { .texture = (u8*)texture_hud_char_toad_head, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_toad_head" },
.waluigi_head = { .texture = (u8*)texture_hud_char_waluigi_head, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_waluigi_head" },
.wario_head = { .texture = (u8*)texture_hud_char_wario_head, .bitSize = 8, .width = 16, .height = 16, "texture_hud_char_wario_head" }
};
static void djui_hud_position_translate(f32* x, f32* y) {

View file

@ -2286,12 +2286,13 @@ static struct LuaObjectField sSurfaceFields[LUA_SURFACE_FIELD_COUNT] = {
{ "vertex3", LVT_COBJECT, offsetof(struct Surface, vertex3), true, LOT_VEC3S },
};
#define LUA_TEXTURE_INFO_FIELD_COUNT 4
#define LUA_TEXTURE_INFO_FIELD_COUNT 5
static struct LuaObjectField sTextureInfoFields[LUA_TEXTURE_INFO_FIELD_COUNT] = {
{ "bitSize", LVT_U8, offsetof(struct TextureInfo, bitSize), true, LOT_NONE },
{ "height", LVT_U32, offsetof(struct TextureInfo, height), true, LOT_NONE },
{ "texture", LVT_U8_P, offsetof(struct TextureInfo, texture), true, LOT_POINTER },
{ "width", LVT_U32, offsetof(struct TextureInfo, width), true, LOT_NONE },
{ "bitSize", LVT_U8, offsetof(struct TextureInfo, bitSize), true, LOT_NONE },
{ "height", LVT_U32, offsetof(struct TextureInfo, height), true, LOT_NONE },
{ "name", LVT_STRING_P, offsetof(struct TextureInfo, name), true, LOT_NONE },
{ "texture", LVT_U8_P, offsetof(struct TextureInfo, texture), true, LOT_POINTER },
{ "width", LVT_U32, offsetof(struct TextureInfo, width), true, LOT_NONE },
};
#define LUA_TRANSITION_INFO_FIELD_COUNT 9

View file

@ -341,6 +341,10 @@ int smlua_func_get_texture_info(lua_State* L) {
lua_pushinteger(L, texInfo.height);
lua_settable(L, -3);
lua_pushstring(L, "name");
lua_pushstring(L, texInfo.name);
lua_settable(L, -3);
return 1;
}
@ -372,6 +376,9 @@ int smlua_func_djui_hud_render_texture(lua_State* L) {
tmpTexInfo.height = smlua_get_integer_field(top+1, "height");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'height' field"); return 0; }
tmpTexInfo.name = smlua_get_string_field(top+1, "name");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'name' field"); return 0; }
lua_settop(L, top);
}
@ -417,6 +424,9 @@ int smlua_func_djui_hud_render_texture_tile(lua_State* L) {
tmpTexInfo.height = smlua_get_integer_field(top+1, "height");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'height' field"); return 0; }
tmpTexInfo.name = smlua_get_string_field(top+1, "name");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'name' field"); return 0; }
lua_settop(L, top);
}
@ -470,6 +480,9 @@ int smlua_func_djui_hud_render_texture_interpolated(lua_State* L) {
tmpTexInfo.height = smlua_get_integer_field(top+1, "height");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'height' field"); return 0; }
tmpTexInfo.name = smlua_get_string_field(top+1, "name");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'name' field"); return 0; }
lua_settop(L, top);
}
@ -523,6 +536,9 @@ int smlua_func_djui_hud_render_texture_tile_interpolated(lua_State* L) {
tmpTexInfo.height = smlua_get_integer_field(top+1, "height");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'height' field"); return 0; }
tmpTexInfo.name = smlua_get_string_field(top+1, "name");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'name' field"); return 0; }
lua_settop(L, top);
}
@ -556,6 +572,58 @@ int smlua_func_djui_hud_render_texture_tile_interpolated(lua_State* L) {
return 1;
}
int smlua_func_texture_override_set(lua_State* L) {
if (!smlua_functions_valid_param_count(L, 2)) { return 0; }
const char* textureName = smlua_to_string(L, 1);
struct TextureInfo tmpOverrideTexInfo = { 0 };
struct TextureInfo* overrideTexInfo = &tmpOverrideTexInfo;
if (smlua_is_cobject(L, 2, LOT_TEXTUREINFO)) {
overrideTexInfo = (struct TextureInfo*)smlua_to_cobject(L, 2, LOT_TEXTUREINFO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
} else {
int top = lua_gettop(L);
lua_pushvalue(L, 2);
lua_pushstring(L, "texture");
lua_gettable(L, top+1);
tmpOverrideTexInfo.texture = smlua_to_cpointer(L, lua_gettop(L), LVT_U8_P);
lua_pop(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2's 'texture' field"); return 0; }
tmpOverrideTexInfo.bitSize = smlua_get_integer_field(top+1, "bitSize");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2's 'bitSize' field"); return 0; }
tmpOverrideTexInfo.width = smlua_get_integer_field(top+1, "width");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2's 'width' field"); return 0; }
tmpOverrideTexInfo.height = smlua_get_integer_field(top+1, "height");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2's 'height' field"); return 0; }
tmpOverrideTexInfo.name = smlua_get_string_field(top+1, "name");
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2's 'name' field"); return 0; }
lua_settop(L, top);
}
dynos_texture_override_set(textureName, overrideTexInfo);
return 1;
}
int smlua_func_texture_override_reset(lua_State* L) {
if (!smlua_functions_valid_param_count(L, 1)) { return 0; }
const char* textureName = smlua_to_string(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
dynos_texture_override_reset(textureName);
return 1;
}
////////////////////////////////
// level script preprocessing //
////////////////////////////////
@ -838,6 +906,8 @@ void smlua_bind_functions(void) {
smlua_bind_function(L, "djui_hud_render_texture_tile", smlua_func_djui_hud_render_texture_tile);
smlua_bind_function(L, "djui_hud_render_texture_interpolated", smlua_func_djui_hud_render_texture_interpolated);
smlua_bind_function(L, "djui_hud_render_texture_tile_interpolated", smlua_func_djui_hud_render_texture_tile_interpolated);
smlua_bind_function(L, "texture_override_set", smlua_func_texture_override_set);
smlua_bind_function(L, "texture_override_reset", smlua_func_texture_override_reset);
smlua_bind_function(L, "level_script_parse", smlua_func_level_script_parse);
smlua_bind_function(L, "smlua_anim_util_register_animation", smlua_func_smlua_anim_util_register_animation);
smlua_bind_function(L, "set_exclamation_box_new_contents", smlua_func_set_exclamation_box_new_contents);

View file

@ -525,6 +525,18 @@ lua_Number smlua_get_number_field(int index, const char* name) {
return val;
}
const char* smlua_get_string_field(int index, const char* name) {
if (lua_type(gLuaState, index) != LUA_TTABLE) {
LOG_LUA_LINE("smlua_get_string_field received improper type '%d'", lua_type(gLuaState, index));
gSmLuaConvertSuccess = false;
return 0;
}
lua_getfield(gLuaState, index, name);
const char* val = smlua_to_string(gLuaState, -1);
lua_pop(gLuaState, 1);
return val;
}
LuaFunction smlua_get_function_field(int index, const char *name) {
if (lua_type(gLuaState, index) != LUA_TTABLE) {
LOG_LUA_LINE("smlua_get_function_field received improper type '%d'", lua_type(gLuaState, index));

View file

@ -40,6 +40,7 @@ void smlua_push_lnt(struct LSTNetworkType* lnt);
lua_Integer smlua_get_integer_field(int index, const char* name);
lua_Number smlua_get_number_field(int index, const char* name);
const char* smlua_get_string_field(int index, const char* name);
LuaFunction smlua_get_function_field(int index, const char *name);
const char* smlua_lnt_to_str(struct LSTNetworkType* lnt);