forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SDL - How to disable SDL_main?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
tobiasbp



Joined: 22 Apr 2006
Posts: 5
Location: Denmark

PostPosted: Mon Apr 24, 2006 7:17 am    Post subject: SDL - How to disable SDL_main? Reply with quote

Hello....

I want to add sound to my C game using SDL. I have installed SDL and SDL_mixer.

As I allready have my program written with the PSPSDK callbacks I dont want SDL to add those to my main().

I dont really understand the documentation (shown at end of post).

It says:
"Of course, you can leave off -lSDLmain, and write the real main()
yourself if you need more control than this."

I have not added -lSDLmain to my libs. So according to the above it should be off right? It's not however.


The documentation then says:
"By default, the PSP "sdl-config --cflags" will define main=SDL_main."

Does that mean I have to change the sdl-config script to disable main=SDL_main?


Here is my Makefile:
TARGET = tileDraw
OBJS = main.o graphics.o framebuffer.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LIBS = -lpspgu -lpng -lz -lm -lSDL_mixer
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Image Example

PSPSDK=$(shell psp-config --pspsdk-path)

PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)

include $(PSPSDK)/lib/build.mak


From the SDL documentation:

SDL_main
--------
When writing an SDL program, the typical use is to write your main
function as "SDL_main", then link -lSDLmain which provides the real
main(). In this implementation, -lSDLmain will:
- Define the required PSP_* macros
- Set up the "home" button callback.
- Initialize the debugging screen
- Call the user-supplied SDL_main
- When it returns, delay 2.5 seconds, then exit to VSH.

Of course, you can leave off -lSDLmain, and write the real main()
yourself if you need more control than this.

By default, the PSP "sdl-config --cflags" will define main=SDL_main.


Building applications
---------------------
Write your source file as you would a normal SDL program. Use the standard
Makefile as supplied with any PSPSDK sample program. Above the final "include"
line, add:

PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)



Thanks
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Mon Apr 24, 2006 7:46 am    Post subject: Re: SDL - How to disable SDL_main? Reply with quote

tobiasbp wrote:
The documentation then says:
"By default, the PSP "sdl-config --cflags" will define main=SDL_main."

Does that mean I have to change the sdl-config script to disable main=SDL_main?

I would recommend that you use "sed" inside the Makefile to remove the parts of sdl-config that you don't want, like this:
Code:

CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags | sed s/-Dmain=SDL_main//)
LIBS += $(shell $(PSPBIN)/sdl-config --libs | sed s/-lSDLmain//)

If you do this, your "main" becomes the actual main function, and libSDLmain.a will not be used.
Back to top
View user's profile Send private message
tobiasbp



Joined: 22 Apr 2006
Posts: 5
Location: Denmark

PostPosted: Mon Apr 24, 2006 11:47 pm    Post subject: Reply with quote

I never did make the disabling of SDL_main work. I commented out the PSP specific setup commands in my C file and things appear to be working.

Thanks for your help.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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