Skip to content

Commit

Permalink
Additional helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
McCaulay committed Mar 12, 2023
1 parent 4c8e4fa commit b6f487f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions sdk/include/offsets/ps/eboot/1.01.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@

// Function Stub Pointers
#define EBOOT_SCE_KERNEL_USLEEP_STUB_PTR 0x083d1c0
#define EBOOT_SCE_KERNEL_REACHABILITY_STUB_PTR 0x083d038

#define EBOOT_SCE_MSG_DIALOG_GET_RESULT_STUB_PTR 0x0083d440
#define EBOOT_SCE_MSG_DIALOG_UPDATE_STATUS_STUB_PTR 0x0083d470
Expand Down
5 changes: 3 additions & 2 deletions sdk/include/ps2/okage.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#pragma once
#include <types.hpp>

class Okage
{
public:
typedef int fMemoryCardOpen(const char* name, int mode);
typedef void fMemoryCardRead(int fd, char* buffer, int size);
typedef void fMemoryCardWrite(int fd, char* buffer, int size);
typedef void fMemoryCardRead(int fd, uint8_t* buffer, int size);
typedef void fMemoryCardWrite(int fd, uint8_t* buffer, int size);
typedef void fMemoryCardSeek(int fd, int offset, int origin);
typedef void fMemoryCardClose(int fd);
public:
Expand Down
3 changes: 3 additions & 0 deletions sdk/include/ps2/ps2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class PS2
static void* realloc(void* ptr, unsigned int size);
static char* strcpy(char* dest, const char* src);
static char* strcat(char* dest, const char* src);
static bool contains(const char* str, const char* c);
static int indexOf(const char* str, const char* c, int fromOffset = 0);
static int indexOf(const char* str, char c, int fromOffset = 0);
static int lastIndexOf(const char* str, char c);
static const char* basename(const char* path);
static int createAndStartThread(void *(*func)(void*), void* stack, uint32_t stackSize, const char* name);
Expand Down
28 changes: 28 additions & 0 deletions sdk/src/ps2/ps2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,34 @@ char* PS2::strcat(char* dest, const char* src)
return dest;
}

bool PS2::contains(const char* str, const char* c)
{
return PS2::indexOf(str, c) != -1;
}

int PS2::indexOf(const char* str, const char* c, int fromOffset)
{
int len = PS2::strlen(str);
int cLen = PS2::strlen(c);
for (int i = fromOffset; i < len; i++)
{
if (PS2::memcmp((void*)(str + i), (void*)c, cLen) == 0)
return i;
}
return -1;
}

int PS2::indexOf(const char* str, char c, int fromOffset)
{
int len = PS2::strlen(str);
for (int i = fromOffset; i < len; i++)
{
if (str[i] == c)
return i;
}
return -1;
}

int PS2::lastIndexOf(const char* str, char c)
{
int len = PS2::strlen(str);
Expand Down

0 comments on commit b6f487f

Please sign in to comment.