Page 1 of 1
Files into elf
Posted: Thu Feb 21, 2008 7:18 am
by methos3
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?
Posted: Thu Feb 21, 2008 7:39 am
by cosmito
SMS does this. At SMS_Data.c, the buffer g_DataBuffer contains several irx embedded into a char array.
Posted: Thu Feb 21, 2008 7:54 am
by Mega Man
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.");
}
Posted: Thu Feb 21, 2008 8:39 am
by Lukasz
Check the PS2Link source, it embeds the IRX's into the ELF.
Posted: Thu Feb 21, 2008 12:02 pm
by methos3
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?
Posted: Sat Feb 23, 2008 10:33 pm
by Mega Man
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.
Posted: Sun Feb 24, 2008 1:58 am
by cosmito
Cool files, Mega Man!
Posted: Sun Feb 24, 2008 9:00 am
by methos3
yeah, the jpgloader and etc are great and better than Dreamtime's ones, but I tryed to open the kernelloader and got an error on both winzip and winrar.
Do you have a non-corrupted copy of the kernelloader?
thanks!
Posted: Sun Feb 24, 2008 11:55 pm
by methos3
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 ^^.
Posted: Mon Feb 25, 2008 1:08 am
by deba5er
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.
Posted: Mon Feb 25, 2008 1:28 am
by methos3
it's exactly 7-zip that I use and i'm still getting an error message talking about corrupted file, and when I search for any file with the "getTexture" function, no one of the files have this function (and no functions referrencing to gsKit)
Posted: Mon Feb 25, 2008 6:57 am
by J.F.
The tgz's test fine for me. I guess you are having trouble downloading the file correctly. Try using wget from the commandline to download the file.
Posted: Mon Feb 25, 2008 10:18 am
by Mega Man
The functions in the files return a pointer to a raw image format. The function getTexture() is located in kernelloader and it loads a raw image into VRAM. When the newest tgz is not working, you can also try older onces.
Posted: Mon Feb 25, 2008 10:33 am
by methos3
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...
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
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?
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) $< >$@
[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?
Posted: Tue Feb 26, 2008 3:45 am
by methos3
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...
Posted: Tue Feb 26, 2008 7:22 am
by Mega Man
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.
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
If you want to support other file formats, you need to copy the png rules.
Posted: Tue Feb 26, 2008 10:32 am
by methos3
Thanks!
I didn't run Make to see everything being compiled allright, , only to see if it would get in the part that does the conversion from png into rgb.
Later I will test this Makefile to compile a hello.
Posted: Wed Feb 27, 2008 6:46 am
by methos3
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...
Posted: Thu Feb 28, 2008 7:02 am
by Mega Man
The libpng is in the SVN at ps2sdk-ports/libpng.
The first code is for loading PNGs directly.
The second code is for loading raw image files created by png2rgb.
Posted: Thu Feb 28, 2008 10:48 am
by methos3
So I only will need a uint32 to do all the job.
Today some hours ago I googled for the libpng for ps2dev and got the ps2sdk-ports/libpng directory. I didn't download yet, but later I will do this.
Thanks, friend!