Skip to content

Commit

Permalink
Fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dogo committed Sep 9, 2024
1 parent 1dc17a2 commit cdbe2fe
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 88 deletions.
18 changes: 10 additions & 8 deletions src/adhoc/pspadhoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,17 @@ void _matchingCB(int unk1, int event, unsigned char *macSource, int size, void *
////////////////////////////////////////////////////////////////////////////////////////////////////////
int oslAdhocInit(char *productID)
{
if( state != ADHOC_UNINIT) return 0;
if (state != ADHOC_UNINIT) return 0;

memset(myMacAddress, 0, 8 * sizeof(u8));

// Ensure null termination after copying
strncpy(product.product, productID, 8); // Copy up to 8 characters
product.product[8] = '\0'; // Null-terminate explicitly

memset(myMacAddress, 0, 8*sizeof(u8) );
strncpy(product.product, productID, 9);
product.unknown = 0;
matchingHD=-1;
pdpHD=-1;
matchingHD = -1;
pdpHD = -1;
port = 0x309;
allRemotePSPCount = 0;

Expand All @@ -245,9 +249,7 @@ int oslAdhocInit(char *productID)
if (_getMacAddress() < 0)
return ADHOC_ERROR_MAC;

_loadModules();
/*if (_loadModules())
return ADHOC_ERROR_MODULES;*/
_loadModules();

if (_libNetInit() < 0)
return ADHOC_ERROR_NET_INIT;
Expand Down
90 changes: 45 additions & 45 deletions src/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,54 +18,54 @@ static SceUID vpl;
static pspUtilityHtmlViewerParam params;
static int browserIsActive = 0;

int oslBrowserInit(char *url, char *downloadDir, int browserMemory, unsigned int displaymode, unsigned int options, unsigned int interfacemode, unsigned int connectmode){
int res;
if (browserMemory <= 0)
browserMemory = BROWSER_MEMORY;
int oslBrowserInit(char *url, char *downloadDir, int browserMemory, unsigned int displaymode, unsigned int options, unsigned int interfacemode, unsigned int connectmode) {
int res;

vpl = sceKernelCreateVpl("BrowserVpl", PSP_MEMORY_PARTITION_USER, 0, browserMemory + 256, NULL);
if (vpl < 0)
return OSL_BROWSER_ERROR_MEMORY;

memset(&params, 0, sizeof(pspUtilityHtmlViewerParam));

params.base.size = sizeof(pspUtilityHtmlViewerParam);

sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &params.base.language);
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN, &params.base.buttonSwap);

params.base.graphicsThread = 17;
params.base.accessThread = 19;
params.base.fontThread = 18;
params.base.soundThread = 16;
params.memsize = browserMemory;
params.initialurl = url;
params.numtabs = 1;
params.cookiemode = PSP_UTILITY_HTMLVIEWER_COOKIEMODE_DEFAULT;
params.homeurl = url;
params.textsize = PSP_UTILITY_HTMLVIEWER_TEXTSIZE_NORMAL;
params.displaymode = displaymode;
params.options = options;
params.interfacemode = interfacemode;
params.connectmode = connectmode;

// WITHOUT 'ms0:' on the paths
params.dldirname = downloadDir;

res = sceKernelAllocateVpl(vpl, params.memsize, &params.memaddr, NULL);
if (res < 0)
return OSL_BROWSER_ERROR_MEMORY;

res = sceUtilityHtmlViewerInitStart(&params);
if (res < 0)
return res; //<-- STAS: Such a return value is more informative...
// return OSL_BROWSER_ERROR_INIT;

browserIsActive = 1;
return 0;
if (browserMemory <= 0) {
browserMemory = BROWSER_MEMORY;
}

vpl = sceKernelCreateVpl("BrowserVpl", PSP_MEMORY_PARTITION_USER, 0, browserMemory + 256, NULL);
if (vpl < 0)
return OSL_BROWSER_ERROR_MEMORY;

memset(&params, 0, sizeof(pspUtilityHtmlViewerParam));

params.base.size = sizeof(pspUtilityHtmlViewerParam);

sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &params.base.language);
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN, &params.base.buttonSwap);

params.base.graphicsThread = 17;
params.base.accessThread = 19;
params.base.fontThread = 18;
params.base.soundThread = 16;
params.memsize = browserMemory;
params.initialurl = url;
params.numtabs = 1;
params.cookiemode = PSP_UTILITY_HTMLVIEWER_COOKIEMODE_DEFAULT;
params.homeurl = url;
params.textsize = PSP_UTILITY_HTMLVIEWER_TEXTSIZE_NORMAL;
params.displaymode = displaymode;
params.options = options;
params.interfacemode = interfacemode;
params.connectmode = connectmode;

// WITHOUT 'ms0:' on the paths
params.dldirname = downloadDir;

res = sceKernelAllocateVpl(vpl, params.memsize, &params.memaddr, NULL);
if (res < 0)
return OSL_BROWSER_ERROR_MEMORY;

res = sceUtilityHtmlViewerInitStart(&params);
if (res < 0)
return res; // This return value is more informative

browserIsActive = 1;
return 0;
}


void oslDrawBrowser()
{
switch (sceUtilityHtmlViewerGetStatus()){
Expand Down
2 changes: 1 addition & 1 deletion src/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ int oslDialogGetResult() {
}

void oslDrawDialog() {
int status;
int status = PSP_UTILITY_DIALOG_NONE;

if (dialogType == OSL_DIALOG_MESSAGE || dialogType == OSL_DIALOG_ERROR) {
status = sceUtilityMsgDialogGetStatus();
Expand Down
54 changes: 31 additions & 23 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,32 +193,36 @@ int oslNetTerm()
}

int oslGetIPaddress(char *IPaddress){
union SceNetApctlInfo apctlInfo;
union SceNetApctlInfo apctlInfo;
strcpy(IPaddress, "");
if (sceNetApctlGetInfo(PSP_NET_APCTL_INFO_IP, &apctlInfo))

if (sceNetApctlGetInfo(PSP_NET_APCTL_INFO_IP, &apctlInfo)) {
return OSL_ERR_APCTL_GETINFO;
strcpy(IPaddress, apctlInfo.ip);
}

strcpy(IPaddress, apctlInfo.ip);
return 0;
}


int oslConnectToAP(int config, int timeout,
int (*apctlCallback)(int state)){
int err = 0;
int stateLast = -1;
int err = 0;
int stateLast = -1;

if (!oslIsWlanPowerOn())
if (!oslIsWlanPowerOn()) {
return OSL_ERR_WLAN_OFF;
}

err = sceNetApctlConnect(config);
if (err)
return OSL_ERR_APCTL_CONNECT;
err = sceNetApctlConnect(config);
if (err)
return OSL_ERR_APCTL_CONNECT;

time_t startTime;
time_t currTime;
time(&startTime);
while (!osl_quit){
//Check timeout:

while (!osl_quit){
// Check timeout
time(&currTime);
if (currTime - startTime >= timeout){
if (apctlCallback != NULL)
Expand All @@ -227,30 +231,34 @@ int oslConnectToAP(int config, int timeout,
err = OSL_ERR_APCTL_TIMEOUT;
break;
}
int state;
err = sceNetApctlGetState(&state);
if (err){

int state;
err = sceNetApctlGetState(&state);
if (err){
if (apctlCallback != NULL)
(*apctlCallback)(OSL_ERR_APCTL_GETSTATE);
oslDisconnectFromAP();
err = OSL_ERR_APCTL_GETSTATE;
break;
}
if (state > stateLast){
stateLast = state;

if (state > stateLast){
stateLast = state;
if (apctlCallback != NULL){
if ((*apctlCallback)(state)){
err = OSL_USER_ABORTED;
break;
}
}
}
if (state == PSP_NET_APCTL_STATE_GOT_IP)
break; // connected with static IP
sceKernelDelayThread(50*1000);
}

return err;
if (state == PSP_NET_APCTL_STATE_GOT_IP)
break; // connected with static IP

sceKernelDelayThread(50*1000);
}

return err;
}

int oslDisconnectFromAP(){
Expand Down Expand Up @@ -325,7 +333,7 @@ int oslNetGetFile(const char *url, const char *filepath)

if(status != 200)
return 0;

/* Strangelove fix
ret = sceHttpGetContentLength(request, &contentsize);
if(ret < 0)
Expand Down
23 changes: 12 additions & 11 deletions src/shape.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ void toggleTexturing(int enable) {
}

OSL_COLOR oslBlendColors(OSL_COLOR color1, OSL_COLOR color2) {
if (color2 == 0xffffffff) // No blending needed
if (color2 == 0xffffffff) { // No blending needed
return color1;
}

if ((color2 & 0x00ffffff) == 0x00ffffff) {
// No tinting, simple alpha blending
return (color1 & 0xffffff) | (((color1 >> 24) * (color2 >> 24) >> 8) << 24);
} else {
return
((((u64)(color1 & 0xff000000) * (color2 & 0xff000000)) >> 32) & 0xff000000) |
((((u64)(color1 & 0xff0000) * (color2 & 0xff0000)) >> 24) & 0xff0000) |
((((color1 & 0xff00) * (color2 & 0xff00)) >> 16) & 0xff00) |
(((color1 & 0xff) * (color2 & 0xff)) >> 8);
}
if ((color2 & 0x00ffffff) == 0x00ffffff) {
// No tinting, simple alpha blending
return (color1 & 0xffffff) | (((color1 >> 24) * (color2 >> 24) >> 8) << 24);
} else {
return
((((u64)(color1 & 0xff000000) * (color2 & 0xff000000)) >> 32) & 0xff000000) |
((((u64)(color1 & 0xff0000) * (color2 & 0xff0000)) >> 24) & 0xff0000) |
((((color1 & 0xff00) * (color2 & 0xff00)) >> 16) & 0xff00) |
(((color1 & 0xff) * (color2 & 0xff)) >> 8);
}
}

void oslDrawLine(int x0, int y0, int x1, int y1, OSL_COLOR color) {
Expand Down

0 comments on commit cdbe2fe

Please sign in to comment.