Cita
Indiket ha escrito:
SDl is not as bad as it seems! Works fairly nice, and you only have to know some basic things to get it working :)
Start looking at some source codes of SDL games, from this websiter or another. You will see how to init SDL, which lib does it use (I think latest KOS has SDL 1.2.15 already in kos-ports), etc etc.
Code:
all: rm-elf main.elf
include $(KOS_BASE)/Makefile.rules
OBJS = main.o
clean:
-rm -f main.elf $(OBJS)
clean-all:
-rm -f main.elf $(OBJS) main.iso output.bin Program.cdi 1st_read.bin
dist:
-rm -f $(OBJS)
$(KOS_STRIP) main.elf
rm-elf:
-rm -f main.elf
main.elf: $(OBJS)
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $@ $(KOS_START) $^ -lm $(KOS_LIBS)
#include <kos.h>
#include <SDL/SDL.h>
int main(void)
{
return 0;
}
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $@ $(KOS_START) $^ -lSDL -lm $(KOS_LIBS)
Cita
Indiket ha escrito:
You will need to add SDL library into the linking process (cause when you start to use SDL functions, you will get undefined errors at linking stage).
Just add "-lSDL" into the compile line, like this:
Código. Descargar código fuente.$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $@ $(KOS_START) $^ -lSDL -lm $(KOS_LIBS)
Cita
Indiket ha escrito:
Nope, just add the C++ library to link!!: -lstdc++
Cita
Indiket ha escrito:
SDL_DC_Mapkey is only available in Chui's SDL version, so you won't find it in the KOS one. -lSDL_129 is from the Chui's version, right.
You can try to read using joystick buttons instead of PC keyboard keys, so you won't need this function.
////Starting the Joystick
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
SDL_JoystickEventState(SDL_ENABLE);
joystick = SDL_JoystickOpen(0);
buttonCount = SDL_JoystickNumButtons(joystick);
switch(event.type)
{
case SDL_JOYBUTTONDOWN:
switch(event.jbutton.button)
{
case 0:
////// A Button Dreamcast Joystick
break;
case 1:
////// B Button Dreamcast Joystick
break;
case 2:
////// X Button Dreamcast Joystick
break;
case 3:
////// Y Button Dreamcast Joystick
break;
}
break;
case SDL_JOYHATMOTION:
switch(event.jhat.value)
{
case 2: //right
break;
case 8: //left
break;
case 0: //neutral
break;
}
break;
}