VTSTech
Developer
This took me way too long to figure out.
We can't actually see the first 80 or so lines of text output to the screen. So I had to pad things a bit before I could see anything. (not really)
Turns out the real culprit was a need to sleep(1) after init_scr. if a program does nothing else but scr_printf after init_scr, 8 lines can execute before it is complete. (also not really)
Turns out the real, real culprit was emulation accuracy on PCSX2 itself. The code always worked on a real PS2...
Source+Compiled binaries attatched. Compiled with "Prebuilt MinGW Playstation 2 Toolchain - 2018/10/19" https://github.com/ps2dev/ps2toolchain/releases/download/2018-10-19/ps2toolchain-20181019.7z
hello.c
Makefile
We can't actually see the first 80 or so lines of text output to the screen. So I had to pad things a bit before I could see anything. (not really)
Turns out the real culprit was a need to sleep(1) after init_scr. if a program does nothing else but scr_printf after init_scr, 8 lines can execute before it is complete. (also not really)
Turns out the real, real culprit was emulation accuracy on PCSX2 itself. The code always worked on a real PS2...

Source+Compiled binaries attatched. Compiled with "Prebuilt MinGW Playstation 2 Toolchain - 2018/10/19" https://github.com/ps2dev/ps2toolchain/releases/download/2018-10-19/ps2toolchain-20181019.7z
hello.c
Code:
// An actual 'Hello World' using the main game display of a PS2
// No longer infinite loop. Now fully commented
// Written by VTSTech ([email protected])
// v0.4 11/29/2019 8:42:50 AM
// Now not using any loops at all.
// sleep() for 1 second allows for inital lines to display
// just scr_printf() right off the bat, first 8 lines can execute before init_scr complete
// v0.3 11/27/2019 5:47:29 AM
// Using unistd.h and sleep() instead of kernel.h and SleepThread()
// Now sleeps for only 30s and quits instead of sleeping forever
// Now using for loop instead of infinite loop
// aligned comment fields, commented all lines
// v0.2 11/25/2019 9:04:00 AM
// Now breaking infinite loop and sleeping forever
// Added newline buffer to cause text to display
// Added comments
// v0.1 05/06/2019 7:20:00 AM
// Text displays on game screen
// An infinite loop simply saying "It Works!"
#include <debug.h> //needed for init_scr();
#include <unistd.h> //needed for sleep();
int main() //int main() is automatically called/started with all programs
{
init_scr(); //Initialize Screen
sleep(1); //PS2 is old. Give it a second...
scr_printf("Hello World!\n"); //print our string
sleep(30); //Wait here for 30 seconds instead of exiting (ret 0) with sleep();
return 0; //This exits and returns to system menu
}
Makefile
Code:
EE_BIN = hello.elf
EE_OBJS = hello.o
EE_LIBS = -ldebug -lc
all: $(EE_BIN)
clean:
rm -f $(EE_BIN) $(EE_OBJS)
run: $(EE_BIN)
ps2client execee host:$(EE_BIN)
reset:
ps2client reset
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
Attachments
Last edited: