Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/input_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void main() {
LCD_Refresh();

while (running) {
memset(&event, 0, sizeof(event));
Mem_Memset(&event, 0, sizeof(event));
GetInput(&event, 0xFFFFFFFF, 0x10);

switch (event.type) {
Expand Down
2 changes: 1 addition & 1 deletion demos/random_circles/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void main() {

bool running = true;
while (running) {
memset(&event, 0, sizeof(event));
Mem_Memset(&event, 0, sizeof(event));
GetInput(&event, 0xFFFFFFFF, 0x10);

switch (event.type) {
Expand Down
4 changes: 2 additions & 2 deletions demos/tetris/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void main() {
for(int i = 0; i < 4; i++){ //get some keycodes to generate a seed for the random() function
bool r = true;
while(r){
memset(&event, 0, sizeof(event));
Mem_Memset(&event, 0, sizeof(event));
GetInput(&event, 0xFFFFFFFF, 0x10);
if(event.type == EVENT_KEY){
if(event.data.key.direction == KEY_PRESSED){
Expand Down Expand Up @@ -168,7 +168,7 @@ void main() {
print_score(0);

while(running){
memset(&event, 0, sizeof(event));
Mem_Memset(&event, 0, sizeof(event));
GetInput(&event, 0x0, 0x12);

if(event.type == EVENT_KEY){
Expand Down
59 changes: 1 addition & 58 deletions doc/user/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,61 +41,4 @@ A `.hhk` file with the name you specified in the `Makefile` will be generated, w
Open the launcher and select your application to launch it. Have fun!

## Newlib
If you want to use C standard libraries such as math.h, string.h and others when developing for the fx-CP400, you must have a standard library implementation such as Newlib installed. Newlib also includes division and other arithmetic subroutines for our SuperH CPU, so that you do not have to always add them to your project manualy when you need them.

First, you will have to define a few environment variables. The `$PREFIX` variable can be changed to your prefered installation directory but `$TARGET` should be left untouched.

```sh
# Directory to install newlib into
# You most likely already have this defined if you have built a cross platform gcc
# I recommend you to change it to the SDK's directory like this:
export PREFIX="$SDK_DIR/newlib"

# Our target architecture
# Again, you might already have $TARGET defined as "sh4-elf"
# Make sure to change it to "sh-elf"
export TARGET="sh-elf"

# The prefix of our cross compiler's binaries such as gcc, as, ld, etc ...
export TARGET_BINS="sh4-elf"
```

After that, grab the latest stable version of the Newlib source code from [their website](https://sourceware.org/newlib/) and extract it. Then run the following commands.

_Make sure to change `VERSION` to your newlib version._

```sh
mkdir build-newlib
cd build-newlib
../newlib-VERSION/configure --target=$TARGET --prefix=$PREFIX CC_FOR_TARGET=${TARGET_BINS}-gcc AS_FOR_TARGET=${TARGET_BINS}-as LD_FOR_TARGET=${TARGET_BINS}-ld AR_FOR_TARGET=${TARGET_BINS}-ar RANLIB_FOR_TARGET=${TARGET_BINS}-ranlib
make all
make install
```

You will now have Newlib installed on your machine. To use it in your projects, add the following to your Makefile's `CC_FLAGS`, `CXX_FLAGS` and `LD_FLAGS`.
If you have used a different installation directory you need to change them here.

```make
CC_FLAGS:=-I $(SDK_DIR)/newlib/sh-elf/include

CXX_FLAS:=-I $(SDK_DIR)/newlib/sh-elf/include

LD_FLAGS:=-L$(SDK_DIR)/newlib/sh-elf/lib
```

Congratulations! You can now utilize standard C functions in your fx-CP400 project.

If you also want newlib to create the arithmetic subroutines, you will need to modify a few more things in your Makefile.

```make
LD:=sh4-elf-gcc # Change the linker to gcc instead of ld
LD_FLAGS:=-nostartfiles -m4-nofpu -Wno-undef -L$(SDK_DIR)/newlib/sh-elf/lib # Change your LD_FLAGS to this (remove -nostdlib and --no-undefined)

# For the APP_BIN target rule, change the line
$(LD) --oformat=binary -T linker.ld -o $@ $(LD_FLAGS) $(OBJECTS) $(SDK_DIR)/sdk.o

# To
$(LD) -Wl,--oformat=binary -T linker.ld -o $@ $(LD_FLAGS) $(OBJECTS) $(SDK_DIR)/sdk.o
```

Thats it. You can now build your app and enjoy Newlib!
If you want to use C standard libraries such as math.h, string.h and others when developing for the fx-CP400, you must have a standard library implementation such as Newlib installed. Check [this](https://github.com/diddyholz/newlib-cp2) repo out for build instructions.
50 changes: 25 additions & 25 deletions launcher/apps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ class File {

~File() {
if (m_opened) {
close(m_fd);
File_Close(m_fd);
}
}

int open(const char *path, int flags) {
m_fd = ::open(path, flags);
m_fd = ::File_Open(path, flags);
m_opened = true;
return m_fd;
}

int getAddr(int offset, const void **addr) {
return ::getAddr(m_fd, offset, addr);
return ::File_GetAddr(m_fd, offset, addr);
}

private:
Expand All @@ -42,18 +42,18 @@ class Find {

~Find() {
if (m_opened) {
findClose(m_findHandle);
File_FindClose(m_findHandle);
}
}

int findFirst(const wchar_t *path, wchar_t *name, struct findInfo *findInfoBuf) {
int ret = ::findFirst(path, &m_findHandle, name, findInfoBuf);
int findFirst(const wchar_t *path, wchar_t *name, struct File_FindInfo *findInfoBuf) {
int ret = ::File_FindFirst(path, &m_findHandle, name, findInfoBuf);
m_opened = true;
return ret;
}

int findNext(wchar_t *name, struct findInfo *findInfoBuf) {
return ::findNext(m_findHandle, name, findInfoBuf);
int findNext(wchar_t *name, struct File_FindInfo *findInfoBuf) {
return ::File_FindNext(m_findHandle, name, findInfoBuf);
}

private:
Expand Down Expand Up @@ -132,7 +132,7 @@ namespace Apps {

void LoadApp(const char *folder, wchar_t *fileName) {
struct AppInfo app;
memset(&app, 0, sizeof(app));
Mem_Memset(&app, 0, sizeof(app));

// copy the file name (converting to a non-wide string in the
// process)
Expand All @@ -145,12 +145,12 @@ namespace Apps {
}

// build the path
//strcat(app.path, "\\fls0\\");
strcat(app.path, folder);
strcat(app.path, app.fileName);
//String_Strcat(app.path, "\\fls0\\");
String_Strcat(app.path, folder);
String_Strcat(app.path, app.fileName);

File f;
int ret = f.open(app.path, OPEN_READ);
int ret = f.open(app.path, FILE_OPEN_READ);
if (ret < 0) {
return;
}
Expand Down Expand Up @@ -182,14 +182,14 @@ namespace Apps {
sectionHeader->sh_offset
);

if (strcmp(sectionName, ".hollyhock_name") == 0) {
strcat(app.name, sectionData);
} else if (strcmp(sectionName, ".hollyhock_description") == 0) {
strcat(app.description, sectionData);
} else if (strcmp(sectionName, ".hollyhock_author") == 0) {
strcat(app.author, sectionData);
} else if (strcmp(sectionName, ".hollyhock_version") == 0) {
strcat(app.version, sectionData);
if (String_Strcmp(sectionName, ".hollyhock_name") == 0) {
String_Strcat(app.name, sectionData);
} else if (String_Strcmp(sectionName, ".hollyhock_description") == 0) {
String_Strcat(app.description, sectionData);
} else if (String_Strcmp(sectionName, ".hollyhock_author") == 0) {
String_Strcat(app.author, sectionData);
} else if (String_Strcmp(sectionName, ".hollyhock_version") == 0) {
String_Strcat(app.version, sectionData);
}
}

Expand All @@ -203,7 +203,7 @@ namespace Apps {
Find find;

wchar_t fileName[100];
struct findInfo findInfoBuf;
struct File_FindInfo findInfoBuf;

wchar_t findDir[100];
int i=0;
Expand Down Expand Up @@ -231,7 +231,7 @@ namespace Apps {
struct AppInfo *app = &g_apps[i];

File f;
int ret = f.open(app->path, OPEN_READ);
int ret = f.open(app->path, FILE_OPEN_READ);
if (ret < 0) {
return nullptr;
}
Expand Down Expand Up @@ -260,9 +260,9 @@ namespace Apps {
void *dest = reinterpret_cast<void *>(sectionHeader->sh_addr);

if (sectionHeader->sh_type == SHT_PROGBITS) {
memcpy(dest, sectionData, sectionHeader->sh_size);
Mem_Memcpy(dest, sectionData, sectionHeader->sh_size);
} else if (sectionHeader->sh_type == SHT_NOBITS) {
memset(dest, 0, sectionHeader->sh_size);
Mem_Memset(dest, 0, sectionHeader->sh_size);
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions launcher/bins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ class File {

~File() {
if (m_opened) {
close(m_fd);
File_Close(m_fd);
}
}

int open(const char *path, int flags) {
m_fd = ::open(path, flags);
m_fd = ::File_Open(path, flags);
m_opened = true;
return m_fd;
}

int getAddr(int offset, const void **addr) {
return ::getAddr(m_fd, offset, addr);
return ::File_GetAddr(m_fd, offset, addr);
}

int read(void *buf, int count) {
return ::read(m_fd, buf, count);
return ::File_Read(m_fd, buf, count);
}

private:
Expand All @@ -56,18 +56,18 @@ class Find {

~Find() {
if (m_opened) {
findClose(m_findHandle);
File_FindClose(m_findHandle);
}
}

int findFirst(const wchar_t *path, wchar_t *name, struct findInfo *findInfoBuf) {
int ret = ::findFirst(path, &m_findHandle, name, findInfoBuf);
int findFirst(const wchar_t *path, wchar_t *name, struct File_FindInfo *findInfoBuf) {
int ret = ::File_FindFirst(path, &m_findHandle, name, findInfoBuf);
m_opened = true;
return ret;
}

int findNext(wchar_t *name, struct findInfo *findInfoBuf) {
return ::findNext(m_findHandle, name, findInfoBuf);
int findNext(wchar_t *name, struct File_FindInfo *findInfoBuf) {
return ::File_FindNext(m_findHandle, name, findInfoBuf);
}

private:
Expand All @@ -87,7 +87,7 @@ namespace Bins {

void LoadApp(const char *folder, wchar_t *fileName) {
struct AppInfo app;
memset(&app, 0, sizeof(app));
Mem_Memset(&app, 0, sizeof(app));

// copy the file name (converting to a non-wide string in the
// process)
Expand All @@ -101,11 +101,11 @@ namespace Bins {

// build the path
//strcat(app.path, "\\fls0\\");
strcat(app.path, folder);
strcat(app.path, app.fileName);
String_Strcat(app.path, folder);
String_Strcat(app.path, app.fileName);

File f;
int ret = f.open(app.path, OPEN_READ);
int ret = f.open(app.path, FILE_OPEN_READ);
if (ret < 0) {
return;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ namespace Bins {
Find find;

wchar_t fileName[100];
struct findInfo findInfoBuf;
struct File_FindInfo findInfoBuf;

wchar_t findDir[100];
int i=0;
Expand Down Expand Up @@ -168,7 +168,7 @@ namespace Bins {
struct AppInfo *app = &g_apps[i];

File f;
int ret = f.open(app->path, OPEN_READ);
int ret = f.open(app->path, FILE_OPEN_READ);
if (ret < 0) {
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion launcher/execs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace Execs {
if ( *(directoryEntry+16) == 0x47 ) {

struct ExecInfo exec;
memset(&exec, 0, sizeof(exec));
Mem_Memset(&exec, 0, sizeof(exec));

for(int i = 0; i<8 ; i++){
exec.fileName[i]=*(directoryEntry+i);
Expand Down
Loading