Advertising (This ad goes away for registered users. You can Login or Register)

yMenu for eCFW / VHBL / PSP

VHBL (Vita Half Byte Loader) is an open source tool to load PSP homebrews on the Playstation Vita.
VHBL can be downloaded at http://wololo.net/vhbl
Acid_Snake
Retired Mod
Posts: 3100
Joined: Tue May 01, 2012 11:32 am
Location: Behind you!

Re: yMenu for eCFW / VHBL / PSP

Post by Acid_Snake »

wth wrote:- Secured background loading thread with semaphore for cfws
you don't need a semaphore for that, this code will work just as well (consider the type Image as the object that holds the image, this may differ from libraries):

Code: Select all

void loadNewBackgroundSafely(){
    Image* aux = currentBackground; // backup current background
    currentBackground = loadImage(path); // load the new image
    delete aux; // delete the older one
}
this code will be thread-safe and doesn't need locking/unlocking mutex.
Advertising
wth
HBL Developer
Posts: 834
Joined: Wed Aug 31, 2011 4:44 pm
Contact:

Re: yMenu for eCFW / VHBL / PSP

Post by wth »

.
Advertising
Last edited by wth on Sun Sep 07, 2014 9:51 pm, edited 1 time in total.
Acid_Snake
Retired Mod
Posts: 3100
Joined: Tue May 01, 2012 11:32 am
Location: Behind you!

Re: yMenu for eCFW / VHBL / PSP

Post by Acid_Snake »

Well if you rethink it again you really don't need a state variable, you only need the main thread (or drawing thread, however you did it) accessing the background to draw it and the background thread counting the seconds passed and changing the background itself after a certain ammount of seconds. I don't see a need for more than this.
wth
HBL Developer
Posts: 834
Joined: Wed Aug 31, 2011 4:44 pm
Contact:

Re: yMenu for eCFW / VHBL / PSP

Post by wth »

.
Last edited by wth on Sun Sep 07, 2014 9:50 pm, edited 1 time in total.
Acid_Snake
Retired Mod
Posts: 3100
Joined: Tue May 01, 2012 11:32 am
Location: Behind you!

Re: yMenu for eCFW / VHBL / PSP

Post by Acid_Snake »

wth wrote:No because I need to know when the new one has finished loading so they can be swapped
with the code I posted above you don't need to know when the new one has been loaded, it'll swap it as soon as it finishes loading
wth
HBL Developer
Posts: 834
Joined: Wed Aug 31, 2011 4:44 pm
Contact:

Re: yMenu for eCFW / VHBL / PSP

Post by wth »

.
Last edited by wth on Sun Sep 07, 2014 9:50 pm, edited 1 time in total.
Acid_Snake
Retired Mod
Posts: 3100
Joined: Tue May 01, 2012 11:32 am
Location: Behind you!

Re: yMenu for eCFW / VHBL / PSP

Post by Acid_Snake »

wth wrote:This means the currentBackground variable would be shared between both threads
I don't see why this would be a problem, even if you want to have structured code and want to follow OOP blindly (I hate people that do this, OOP is not a panaceum) then just have both threads be part of the same class or namespace.
wth wrote:so if the main thread accesses it at the same time, it will crash (even if the probability may not be so high)
Which would require to secure the currentBackground variable
I've never seen any problem with this code, if you are too afraid, just have a semaphore shared on the "delete aux" and "currentBackground->draw()" statements.
wth
HBL Developer
Posts: 834
Joined: Wed Aug 31, 2011 4:44 pm
Contact:

Re: yMenu for eCFW / VHBL / PSP

Post by wth »

.
Last edited by wth on Sun Sep 07, 2014 9:50 pm, edited 1 time in total.
Acid_Snake
Retired Mod
Posts: 3100
Joined: Tue May 01, 2012 11:32 am
Location: Behind you!

Re: yMenu for eCFW / VHBL / PSP

Post by Acid_Snake »

wth wrote:
Acid_Snake wrote:I've never seen any problem with this code, if you are too afraid, just have a semaphore shared on the "delete aux" and "currentBackground->draw()" statements.
yeah maybe on psp it doesn't matter no idea depends on the architecture but in theory if one threads reads when the other writes it cannot work. But yeah I know I'm kinda paranoïd about that maybe but I do remember very rare crashes due to that from my tests before, but maybe that's just me
but anyway if I use a semaphore it's just like my code, even though I made a total mess with this code lately anyway
Not to insult or anything but imo the entire project is badly structured and is hard to find specifics parts of the code and is generally hard to read. A big cleanup and restructuring would do wonders to the project.
wth
HBL Developer
Posts: 834
Joined: Wed Aug 31, 2011 4:44 pm
Contact:

Re: yMenu for eCFW / VHBL / PSP

Post by wth »

Haters gonna hate :mrgreen:
Locked

Return to “Vita Half Byte Loader”