Initial commit
This commit is contained in:
commit
b119290d1e
17
readme.txt
Normal file
17
readme.txt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
If you want to dev on PS2, you should install this: https://github.com/ps2dev/ps2dev
|
||||||
|
|
||||||
|
Note that a lot of things changed inside ps2dev around 2019, making a lot of documentation on the internet obsolete. Don't do what we did and try to use SDL1, it's broken now. Use SDL2.
|
||||||
|
|
||||||
|
To make this project, cd into a directory and use "make". You can use ps2-packer to make the resulting elf smaller.
|
||||||
|
|
||||||
|
How to debug .ELFs on the PS2 over LAN:
|
||||||
|
- Put ps2link on memory card (configs did not load from USB), configure appropriately (IP, netmask, gateway): https://www.psx-place.com/resources/ps2link.949/
|
||||||
|
- Start ps2link on PS2
|
||||||
|
- Use ps2client (part of ps2dev) on PC to manage PS2
|
||||||
|
- Start elf: ps2client -h 192.168.0.x execee host:sdl2.elf
|
||||||
|
- Reset: ps2client -h 192.168.0.x reset
|
||||||
|
|
||||||
|
Special thanks to:
|
||||||
|
- haloopdy for mental support
|
||||||
|
- All the people at https://github.com/ps2dev for making this possible
|
||||||
|
- https://github.com/fjtrujy/helloWorldPS2 for opening our world
|
40
sdl2/Makefile
Executable file
40
sdl2/Makefile
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
# _____ ___ ____ ___ ____
|
||||||
|
# ____| | ____| | | |____|
|
||||||
|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2001-2022, ps2dev - http://www.ps2dev.org
|
||||||
|
# Licenced under Academic Free License version 2.0
|
||||||
|
# Review ps2sdk README & LICENSE files for further details.
|
||||||
|
|
||||||
|
EE_BIN = sdl2.elf
|
||||||
|
EE_OBJS = main.o
|
||||||
|
EE_CFLAGS += -fdata-sections -ffunction-sections -I$(PS2SDK)/ports/include
|
||||||
|
EE_LDFLAGS += -L$(PS2SDK)/ports/lib -L$(GSKIT)/lib -lSDL2 -lgskit -ldmakit -lps2_drivers -Wl,--gc-sections
|
||||||
|
|
||||||
|
ifeq ($(DUMMY_TIMEZONE), 1)
|
||||||
|
EE_CFLAGS += -DDUMMY_TIMEZONE
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(DUMMY_LIBC_INIT), 1)
|
||||||
|
EE_CFLAGS += -DDUMMY_LIBC_INIT
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(KERNEL_NOPATCH), 1)
|
||||||
|
EE_CFLAGS += -DKERNEL_NOPATCH
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(DEBUG), 1)
|
||||||
|
EE_CFLAGS += -DDEBUG -O0 -g
|
||||||
|
else
|
||||||
|
EE_CFLAGS += -Os
|
||||||
|
EE_LDFLAGS += -s
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: $(EE_BIN)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(EE_OBJS) $(EE_BIN)
|
||||||
|
|
||||||
|
# Include makefiles
|
||||||
|
include $(PS2SDK)/samples/Makefile.pref
|
||||||
|
include $(PS2SDK)/samples/Makefile.eeglobal
|
62
sdl2/main.c
Executable file
62
sdl2/main.c
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
#include <kernel.h>
|
||||||
|
#include "SDL2/SDL.h"
|
||||||
|
int printf(const char *format, ...);
|
||||||
|
|
||||||
|
char * ps2elf_storage;
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
// Just some debugging
|
||||||
|
printf("Arguments:\n");
|
||||||
|
for (int i=0; i < argc; i++) {
|
||||||
|
printf("* %d: %s\n",i,argv[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
// Getting the device from elf path
|
||||||
|
char * sep = strchr(argv[0], ':');
|
||||||
|
if (sep == NULL) {
|
||||||
|
printf("ERROR: Could not find storage device of elf!\n");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
size_t size = sep - argv[0];
|
||||||
|
ps2elf_storage = malloc(size + 1);
|
||||||
|
memcpy(ps2elf_storage,argv[0],size);
|
||||||
|
ps2elf_storage[size] = 0;
|
||||||
|
printf("* Detected storage device: '%s'\n",ps2elf_storage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initializing SDL2
|
||||||
|
printf("[SDL2] Initializing ...\n");
|
||||||
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
|
printf("[SDL2] Creating window ...\n");
|
||||||
|
int width = 640;
|
||||||
|
int height = 480;
|
||||||
|
SDL_Window * window = SDL_CreateWindow("game",
|
||||||
|
0,0,
|
||||||
|
width,height,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
printf("[SDL2] Grabbing surface ...\n");
|
||||||
|
SDL_Surface * surface = SDL_GetWindowSurface(window);
|
||||||
|
Uint16 * pixels = surface->pixels;
|
||||||
|
Uint32 tracker = 0;
|
||||||
|
|
||||||
|
// Draw-loop
|
||||||
|
printf("[SDL2] Entering draw-loop ...\n");
|
||||||
|
int x; int y;
|
||||||
|
while (1) {
|
||||||
|
// Just doing some fun animated pattern
|
||||||
|
for (y = 0; y < height; y++) {
|
||||||
|
for (x = 0; x < width; x++) {
|
||||||
|
pixels[(((y * width) + x) + tracker) % (width * height)] = (tracker + (x ^ y)) + y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tracker = tracker + 3;
|
||||||
|
SDL_UpdateWindowSurface(window);
|
||||||
|
printf("\r"); fflush(stdout); // printf seems to fire an interrupt, which allows ps2link to reset the console, so we keep sending an "empty" debug message.
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
sdl2/main.o
Normal file
BIN
sdl2/main.o
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user