 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Thu Feb 21, 2008 7:18 am Post subject: 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? |
|
| Back to top |
|
 |
cosmito
Joined: 04 Mar 2007 Posts: 314 Location: Portugal
|
Posted: Thu Feb 21, 2008 7:39 am Post subject: |
|
|
| SMS does this. At SMS_Data.c, the buffer g_DataBuffer contains several irx embedded into a char array. |
|
| Back to top |
|
 |
Mega Man
Joined: 18 Jun 2005 Posts: 274
|
Posted: Thu Feb 21, 2008 7:54 am Post subject: |
|
|
You need to use programs like bin2s and bin2c to create files you can link to your program and then load it with:
| Code: |
int rv;
int ret;
ret = SifExecModuleBuffer(startaddress, size, argLen, args, &rv);
if (ret < 0) {
rv = ret;
}
if (rv < 0) {
printf("Failed to load module.");
}
|
|
|
| Back to top |
|
 |
Lukasz

Joined: 19 Jan 2004 Posts: 248 Location: Denmark
|
Posted: Thu Feb 21, 2008 8:39 am Post subject: |
|
|
Check the PS2Link source, it embeds the IRX's into the ELF. _________________ Lukasz.dk |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Thu Feb 21, 2008 12:02 pm Post subject: |
|
|
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? |
|
| Back to top |
|
 |
Mega Man
Joined: 18 Jun 2005 Posts: 274
|
|
| Back to top |
|
 |
cosmito
Joined: 04 Mar 2007 Posts: 314 Location: Portugal
|
Posted: Sun Feb 24, 2008 1:58 am Post subject: |
|
|
| Cool files, Mega Man! |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Sun Feb 24, 2008 9:00 am Post subject: |
|
|
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! |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Sun Feb 24, 2008 11:55 pm Post subject: |
|
|
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 ^^. |
|
| Back to top |
|
 |
deba5er
Joined: 04 Feb 2008 Posts: 173
|
Posted: Mon Feb 25, 2008 1:08 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Mon Feb 25, 2008 1:28 am Post subject: |
|
|
| 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) |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Mon Feb 25, 2008 6:57 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Mega Man
Joined: 18 Jun 2005 Posts: 274
|
Posted: Mon Feb 25, 2008 10:18 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Mon Feb 25, 2008 10:33 am Post subject: |
|
|
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: |
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: |
%_irx.s: %.irx
rm -f $@.tmp
rm -f $@
bin2s $^ $@.tmp $(subst -,_,$(subst /,_,$*))_irx
sed -e "s/\.data/.section .rom/g" <$@.tmp >$@
rm -f $@.tmp
%_elf.s: %.elf
bin2s $^ $@ $(subst -,_,$(subst /,_,$*))_elf
%_rgb.s: %.rgb
rm -f $@.tmp
rm -f $@
bin2s $^ $@.tmp $(subst -,_,$(subst /,_,$*))_rgb
sed -e "s/\.data/.section .rom/g" <$@.tmp >$@
rm -f $@.tmp
%.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? |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Tue Feb 26, 2008 3:45 am Post subject: |
|
|
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... |
|
| Back to top |
|
 |
Mega Man
Joined: 18 Jun 2005 Posts: 274
|
Posted: Tue Feb 26, 2008 7:22 am Post subject: |
|
|
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: |
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. |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Tue Feb 26, 2008 10:32 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Wed Feb 27, 2008 6:46 am Post subject: |
|
|
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... |
|
| Back to top |
|
 |
Mega Man
Joined: 18 Jun 2005 Posts: 274
|
Posted: Thu Feb 28, 2008 7:02 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Thu Feb 28, 2008 10:48 am Post subject: |
|
|
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! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|