-
Notifications
You must be signed in to change notification settings - Fork 507
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
Use tex sizes from texture rather than hardcoded values #610
Use tex sizes from texture rather than hardcoded values #610
Conversation
3815604
to
4090512
Compare
libultraship/libultraship/Window.cpp
Outdated
@@ -199,6 +199,21 @@ extern "C" { | |||
return (char*)res->imageData; | |||
} | |||
|
|||
uint16_t ResourceMgr_LoadTexWidthByName(char* texPath) { | |||
const auto res = static_cast<Ship::Texture*>(Ship::GlobalCtx2::GetInstance()->GetResourceManager()->LoadResource(texPath).get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line might be useful as a helper function that gets inlined? it's duplicated in each of these functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is prime macro real estate.
libultraship/libultraship/Window.cpp
Outdated
uint16_t ResourceMgr_LoadTexWidthByName(char* texPath) { | ||
const auto res = LOAD_TEX(texPath); | ||
return res->width; | ||
} | ||
|
||
uint16_t ResourceMgr_LoadTexHeightByName(char* texPath) { | ||
const auto res = LOAD_TEX(texPath); | ||
return res->height; | ||
} | ||
|
||
uint32_t ResourceMgr_LoadTexSizeByName(char* texPath) { | ||
const auto res = LOAD_TEX(texPath); | ||
return res->imageDataSize; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would probably be good to have some kind of check to see if res
is null, incase the provided path points to a non-existent resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We weren't doing that before but happy to add it. What would be an acceptable recovery here though? Should we just log it out and return -1?
// "Item 32-0" | ||
osSyncPrintf("アイテム32-0\n"); | ||
} else { | ||
R_TEXTBOX_ICON_XPOS = R_TEXT_INIT_XPOS - sIconItem24XOffsets[gSaveContext.language]; | ||
R_TEXTBOX_ICON_YPOS = y + 10; | ||
R_TEXTBOX_ICON_SIZE = 24; | ||
memcpy((uintptr_t)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, | ||
ResourceMgr_LoadTexByName(gItemIcons[itemId]), 0x900); | ||
ResourceMgr_LoadTexByName(gItemIcons[itemId]), ResourceMgr_LoadTexSizeByName(gItemIcons[itemId])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid memcpy here (and further down) in the first place. The texture should better be loaded in the gfx plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There’s a separate plan to completely remove LoadTexWithName and friends.. but that is a very big change and also requires dealing with the skyboxes. I was aiming to fix some of the issues the arise from textures sometimes being the wrong size than what’s given while that effort happens.
…rs#610) * Use tex sizes from texture rather than hardcoded values * Dynamic do action tex sizes * Remove unused minimap texture keys * Restore MESSAGE_STATIC_TEX_SIZE * Use dynamic offsets * MACRO it up * Enable SPDLOG in Xcode * Handle non-existent texture
…rs#610) * Use tex sizes from texture rather than hardcoded values * Dynamic do action tex sizes * Remove unused minimap texture keys * Restore MESSAGE_STATIC_TEX_SIZE * Use dynamic offsets * MACRO it up * Enable SPDLOG in Xcode * Handle non-existent texture
Uses actual size from texture rather than harcoded values. This fixes a few bugs where the textures are actually bigger than the size given (especially when using ASAN).