-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
Have getters in GX use const pointers #118
Conversation
You put the const on the wrong side of the pointer. This just marks the variable itself as const, not the memory it points to, which is useless inside the function. |
I would also suggest adding const to the casts as well, e.g.: -void* GX_GetFifoBase(GXFifoObj *fifo)
+void* GX_GetFifoBase(const GXFifoObj *fifo)
{
- return (void*)((struct __gxfifo*)fifo)->buf_start;
+ return (void*)((const struct __gxfifo*)fifo)->buf_start;
} |
@endrift Gah, thank you. It's been a while since I've written C.
@mtheall Okay, I'll do that 👍 |
I think the ones that output void* break const correctness, but still "work" because they're explicitly cast to void* (which you shouldn't actually need to do in C, and would recommend removing those casts in the process to see if it raises warnings). |
Those are fine. |
@endrift Wasn't sure if by "output Removing casts from a function with output parametersChange: void GX_GetFifoPtrs(const GXFifoObj *fifo,void **rd_ptr,void **wt_ptr)
{
const struct __gxfifo *ptr = (const struct __gxfifo*)fifo;
- *rd_ptr = (void*)ptr->rd_ptr;
- *wt_ptr = (void*)ptr->wt_ptr;
+ *rd_ptr = ptr->rd_ptr;
+ *wt_ptr = ptr->wt_ptr;
} Output:
Removing cast from a function returning `void *`Change: void* GX_GetFifoBase(const GXFifoObj *fifo)
{
- return (void*)((const struct __gxfifo*)fifo)->buf_start;
+ return ((const struct __gxfifo*)fifo)->buf_start;
} Output:
|
I had assumed they were void*, not vu32, so my reply was incorrect. @mtheall corrected me. Sorry about the confusion. |
@1011X : Hey, sorry for the late reply. Thanks for the PR! the output of the example should be a white square and a triangle according to the lessons its ported from . i confirmed this with the current libogc main. however, im getting a black screen with this change. it didn't crash, as the home button on my wiimote works. Thanks again! EDIT : WM might think it has to do with lesson 2 having an Init bug, i might need to test the other lessons and check what i can |
little update : lesson 2, 11 & 19 are broken. i do still need somebody to figure out the bug that is now showing up though... |
Hi @DacoTaco ! I tried this branch, and it works fine for me: lessons 2 and 11 are working fine for me, and actually lesson 19 too. I'm testing on the Dolphin emulator. |
Hey, thanks for testing! can you test it on a wii as well? |
Ah, indeed! But it may be that WM is right: I now tried to run the original lessons on a wii (via wiiload on TCP) and I'm getting these results:
All this is with the original libogc (I mean, with the version from the official package repo; I haven't try with the master branch). I'll now try with this branch, but it looks like this test is not really going to prove a lot :-) |
if lesson 11 works for you, i might as well finally merge this fix |
OK, and here are the results with this branch:
Overall, I've the feeling that there's something flacky with the setup of the examples, so I think that this branch is not to blame on the failures. |
huh, lesson 19 locked up for me. there is some setup weirdness in the lesson, so ill blame it on that. |
Co-authored-by: Infra <1011X@users.noreply.github.com>
No description provided.