Files into elf
Files into elf
Hello.
Any of you know what I have to do to put irxs, fonts , images and etc into an elf file?
Like SMS, uLaunchelf and so on...
I searched on SMS source for a way to do this and didn't find...
Can someone help me?
Any of you know what I have to do to put irxs, fonts , images and etc into an elf file?
Like SMS, uLaunchelf and so on...
I searched on SMS source for a way to do this and didn't find...
Can someone help me?
You need to use programs like bin2s and bin2c to create files you can link to your program and then load it with:
Code: Select all
int rv;
int ret;
ret = SifExecModuleBuffer(startaddress, size, argLen, args, &rv);
if (ret < 0) {
rv = ret;
}
if (rv < 0) {
printf("Failed to load module.");
}
hm, ok, and how about fonts and images?
what file of SMS source contains some images (png, jpg, etc...) or fonts(arial, etc...)?
[edit]
I saw that bmp2c on Dreamtime's Tutorial, but I don't know if this will work with the gsKit.
Any of you know a way to convert kpeg to a code that can be used on the gsKit?
what file of SMS source contains some images (png, jpg, etc...) or fonts(arial, etc...)?
[edit]
I saw that bmp2c on Dreamtime's Tutorial, but I don't know if this will work with the gsKit.
Any of you know a way to convert kpeg to a code that can be used on the gsKit?
Here are examples for extracting image data:
http://mitglied.lycos.de/ps2dev/examples/jpgloader.c
http://mitglied.lycos.de/ps2dev/examples/jpgloader.h
http://mitglied.lycos.de/ps2dev/examples/pngloader.c
http://mitglied.lycos.de/ps2dev/examples/pngloader.h
http://mitglied.lycos.de/ps2dev/examples/bmpreader.c
http://mitglied.lycos.de/ps2dev/examples/bmpreader.h
You need just to provide the rom interface or copy the files from kernelloader. When you copy it you need also to copy some parts of the Makefile.
The function "getTexture" in kernelloader shows how to pass the extracted result to gsKit.
There a more examples in kernelloader:
png2rgb and ppm2rgb
The programs convert the image to raw image format.
http://mitglied.lycos.de/ps2dev/examples/jpgloader.c
http://mitglied.lycos.de/ps2dev/examples/jpgloader.h
http://mitglied.lycos.de/ps2dev/examples/pngloader.c
http://mitglied.lycos.de/ps2dev/examples/pngloader.h
http://mitglied.lycos.de/ps2dev/examples/bmpreader.c
http://mitglied.lycos.de/ps2dev/examples/bmpreader.h
You need just to provide the rom interface or copy the files from kernelloader. When you copy it you need also to copy some parts of the Makefile.
The function "getTexture" in kernelloader shows how to pass the extracted result to gsKit.
There a more examples in kernelloader:
png2rgb and ppm2rgb
The programs convert the image to raw image format.
hey!
I have an idea!
That bmb2c from Tony Savesky gives a .c file that have the width, height, a array that contains the colors, right?
And if I pass the colors to the gsKit using gsKit_prim_point (for original width and height), or gsKit_prim_sprite or even g2_print_quad acording to the cordinates and colors contained on the bmb converted into c?
That colors can be passed to the gsKit with no problem?
Or if anyone have the non-corrupted kernel loader source, it's even better ^^.
I have an idea!
That bmb2c from Tony Savesky gives a .c file that have the width, height, a array that contains the colors, right?
And if I pass the colors to the gsKit using gsKit_prim_point (for original width and height), or gsKit_prim_sprite or even g2_print_quad acording to the cordinates and colors contained on the bmb converted into c?
That colors can be passed to the gsKit with no problem?
Or if anyone have the non-corrupted kernel loader source, it's even better ^^.
I use 7-zip (www.7-zip.org) to open .tgz archives. I just re-downloaded the kernelloader source package and opened it with 7-zip to verify that it is not corrupt.
ok, i downloaded the kernelloader 1.5 correctly, and saw the getTexture funtcion, but where are the "romfilelist.h" and "romdefinitions.h" that are needed?
ps.: this kernelloader is a great code, and very nice.
[edit]
ok, got it...
sorry for asking whihout looking the Makefile.
so these files only includes the irx's to the Makefile, huh?
but romimitialize contains some texture loading...
I only have to copy this part of the makefile and use the convert tools on the source?
I have to copy this part too?
[edit again]
so the functions returns a pointer to the raw image.
but for example getTexture requires a filename, and not a pointer.
there is any example of using an raw image pointer on gsKit?
ps.: this kernelloader is a great code, and very nice.
[edit]
ok, got it...
Code: Select all
romfilelist.h: $(RGB_HEADERS) $(RGB_FILES)
rm -f romfilelist.h
for file in $(ROM_FILES); do \
echo "{ \"$$file\", NULL, 0, 0, 0, 0}," >> romfilelist.h; \
done
romdefinitions.h:
rm -f romdefinitions.h
for file in $(subst -,_,$(subst .,_,$(subst /,_,$(ROM_FILES)))); do \
echo "extern unsigned char $$file[];" >> romdefinitions.h; \
echo "extern int size_$$file;" >> romdefinitions.h; \
done
rominitialize.h: $(RGBFILES)
rm -f rominitialize.h
for file in $(subst -,_,$(subst .,_,$(subst /,_,$(ROM_FILES)))); do \
if [ "$${file: -3:3}" = "rgb" ]; then \
echo "#include \"$${file}\"" | sed -e "s/_rgb\"/\.h\"/g" >> rominitialize.h; \
fi; \
done
for file in $(subst -,_,$(subst .,_,$(subst /,_,$(ROM_FILES)))); do \
echo "rom_files[i].start = $$file;" >> rominitialize.h; \
echo "rom_files[i].size = size_$$file;" >> rominitialize.h; \
if [ "$${file: -3:3}" = "rgb" ]; then \
ufile="`echo $$file | perl -n -e \"s/_rgb\$$//g; print uc($$@);\"`"; \
echo "rom_files[i].width = $${ufile}_WIDTH;" >> rominitialize.h; \
echo "rom_files[i].height = $${ufile}_HEIGHT;" >> rominitialize.h; \
echo "rom_files[i].depth = $${ufile}_DEPTH;" >> rominitialize.h; \
fi; \
echo "i++;" >> rominitialize.h; \
done
so these files only includes the irx's to the Makefile, huh?
but romimitialize contains some texture loading...
I only have to copy this part of the makefile and use the convert tools on the source?
I have to copy this part too?
Code: Select all
%_irx.s: %.irx
rm -f [email protected]
rm -f $@
bin2s $^ [email protected] $(subst -,_,$(subst /,_,$*))_irx
sed -e "s/\.data/.section .rom/g" <[email protected] >$@
rm -f [email protected]
%_elf.s: %.elf
bin2s $^ $@ $(subst -,_,$(subst /,_,$*))_elf
%_rgb.s: %.rgb
rm -f [email protected]
rm -f $@
bin2s $^ [email protected] $(subst -,_,$(subst /,_,$*))_rgb
sed -e "s/\.data/.section .rom/g" <[email protected] >$@
rm -f [email protected]
%.rgb %.h: %.ppm ../ppm2rgb/ppm2rgb
../ppm2rgb/ppm2rgb $*.ppm $*.rgb $*.h $*
%.rgb %.h: %.png ../png2rgb/png2rgb
../png2rgb/png2rgb $*.png $*.rgb $*.h $*
.depend/%.d: %.c
mkdir -p .depend
$(EE_CC) -E -M -MG $(EE_CFLAGS) $(EE_INCS) $< >$@
.depend/%.d: %.cpp
mkdir -p .depend
$(EE_CXX) -E -M -MG $(EE_CXXFLAGS) $(EE_INCS) $< >$@
so the functions returns a pointer to the raw image.
but for example getTexture requires a filename, and not a pointer.
there is any example of using an raw image pointer on gsKit?
hey, sorry for asking whihout seeing the code...
I saw how the png2raw works passing the code to the program.
I typed make on the "loader" dir to see what kind of files would appear, and after some linking messages and all... I got an error talking about a file "/cygdrive/ps2dev/ee... and so on"(it's a .h file). I don't use cygwin, and why I received this mesage? I checked the Makefile.pref and didn't see anything talking about cygdrive...
I saw how the png2raw works passing the code to the program.
I typed make on the "loader" dir to see what kind of files would appear, and after some linking messages and all... I got an error talking about a file "/cygdrive/ps2dev/ee... and so on"(it's a .h file). I don't use cygwin, and why I received this mesage? I checked the Makefile.pref and didn't see anything talking about cygdrive...
I believe one environment variable is set to cygwin. The README describes how to build kernelloader (including ps2sdk and required modules).
You can't just run "make" in loader directory, because there are some files needed.
Here is a simplified version of the Makefile. You need just to copy "rom.c", "rom.h" and "cloud.png" into the directory and generate a "hello.c". The rgb stuff is removed.
If you want to support other file formats, you need to copy the png rules.
You can't just run "make" in loader directory, because there are some files needed.
Here is a simplified version of the Makefile. You need just to copy "rom.c", "rom.h" and "cloud.png" into the directory and generate a "hello.c". The rgb stuff is removed.
Code: Select all
PROGRAM = hello
EE_BIN = $(PROGRAM).elf
EE_OBJS = hello.o rom.o
EE_FLAGS += -Wall -W -Wimplicit-int -Werror-implicit-function-declaration
EE_OBJS += $(addsuffix .o, $(subst .,_,$(ROM_FILES)))
MODULES = ioptrap.irx iomanX.irx ps2dev9.irx ps2ip.irx poweroff.irx
ROM_FILES += \
$(MODULES) \
cloud.png
all: $(EE_BIN)
$(MODULES):
for file in $(MODULES); do cp $(PS2SDK)/iop/irx/$$file .; done
rom.o: rom.c romfilelist.h romdefinitions.h rominitialize.h
clean:
rm -f $(EE_BIN) $(EE_OBJS) $(MODULES)
rm -f romfilelist.h romdefinitions.h rominitialize.h
rm -f $(addsuffix .s,$(subst .,_,$(ROM_FILES)))
rm -f $(addsuffix .o,$(subst .,_,$(ROM_FILES)))
rm -rf .depend
romfilelist.h:
rm -f romfilelist.h
for file in $(ROM_FILES); do \
echo "{ \"$$file\", NULL, 0, 0, 0, 0}," >> romfilelist.h; \
done
romdefinitions.h:
rm -f romdefinitions.h
for file in $(subst -,_,$(subst .,_,$(subst /,_,$(ROM_FILES)))); do \
echo "extern unsigned char $$file[];" >> romdefinitions.h; \
echo "extern int size_$$file;" >> romdefinitions.h; \
done
rominitialize.h:
rm -f rominitialize.h
for file in $(subst -,_,$(subst .,_,$(subst /,_,$(ROM_FILES)))); do \
echo "rom_files[i].start = $$file;" >> rominitialize.h; \
echo "rom_files[i].size = size_$$file;" >> rominitialize.h; \
echo "i++;" >> rominitialize.h; \
done
%_irx.s: %.irx
rm -f $@
bin2s $^ $@ $(subst -,_,$(subst /,_,$*))_irx
%_elf.s: %.elf
rm -f $@
bin2s $^ $@ $(subst -,_,$(subst /,_,$*))_elf
%_png.s: %.png
rm -f $@
bin2s $^ $@ $(subst -,_,$(subst /,_,$*))_png
.depend/%.d: %.c
mkdir -p .depend
$(EE_CC) -E -M -MG $(EE_CFLAGS) $(EE_INCS) $< >$@
.depend/%.d: %.cpp
mkdir -p .depend
$(EE_CXX) -E -M -MG $(EE_CXXFLAGS) $(EE_INCS) $< >$@
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
ifneq ($(MAKECMDGOALS),clean)
-include $(addprefix .depend/,$(subst .o,.d, $(EE_OBJS)))
endif
hey, only a little other thing.
The libpng that the ps2 (not pc) functions need is the same lipng for pc?
Or the svn have any libpng?
And for example:
If I have a Texture like this:
GSTEXTURE *tex = NULL;
I can use this:
uint32 test = NULL;
test = loadPng(file_name, width, height, *depth);
tex->mem = test;
// And all the rest...
To load a texture?
Or I have to use this?
rom_entry_t *test;
test = rom_getFile(file_name);
tex->mem = test.start;
// And all the rest...
The libpng that the ps2 (not pc) functions need is the same lipng for pc?
Or the svn have any libpng?
And for example:
If I have a Texture like this:
GSTEXTURE *tex = NULL;
I can use this:
uint32 test = NULL;
test = loadPng(file_name, width, height, *depth);
tex->mem = test;
// And all the rest...
To load a texture?
Or I have to use this?
rom_entry_t *test;
test = rom_getFile(file_name);
tex->mem = test.start;
// And all the rest...