DC and SDL

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
reaper2k2
DC Developer
DC Developer
Posts: 2648
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

SDL mixer works fine will the wav part ive ported my first emu and the sound now works

i used the mixer you last put out ! wav files play nicely so no worrys blue crab

i ported a space invaders arcaded emu 8080 simulator

ill releasr the source with it when i can get the screen res better its game boy size and flickers like a bad speccys game

so some good new if you copy the coding style of this emu's sound sytem we can use it in our sdl games its very well commented!

YAH!
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

Ok, you've confused me, did you get sound in SDL to work, or are you using KOS sound still?
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

I think that means that the SDL sound output drivers work, and that the WAV playing part of SDL Mixer works too.
Bombshell
DC Developer
DC Developer
Posts: 179
Joined: Wed Nov 20, 2002 8:29 pm
Has thanked: 0
Been thanked: 0

Post by Bombshell »

Coolness,

Sound is good, What about streaming mp3? or is it only wav now? Just finished up all my revisions to the SDL code reaper check you e-mail there is an explanation of what ive changed in the source file.

TGIF forget that it was Friday today, hooray! if you have time to test it today tell me everything that isnt working so i can fix when i get back from school. Also gonna implement functions for both controller support and implent a menu
couroumba
DCEmu Newbie
DCEmu Newbie
Posts: 1
Joined: Mon Dec 30, 2002 3:24 am
Location: France
Has thanked: 0
Been thanked: 0

Post by couroumba »

I don't understand... :o
The SDL_Mixer for DC at http://sourceforge.net/projects/sdl-dc/ don't yet work ?! :?:

I began to develop a karaoke player ... so I'd wanted to use it to develop the midi part with it.

Anybody knows if midi file works fine ?
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

WE dont use that code couroumba we have been busy little things lol

when i release the source to the port of the space invaders emu

i want people to try compile it to see if "there SDL_mixer is working" as i may have fixed it in the code i forget what ive done most days and the mixer i used was bluecrabs first one and the paths in the mak files were changed to include the includes

its in this thread if you look one of the best SDL threads on the net


ok bombshell i just have to make the grafix because there all bmps that i have right now
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

Can you tell me what you changed please? I am porting over my game from KOS's libparallax to SDL so I can test it on my PC. I'd like to be able to use the sound on the dreamcast version without having to have dreamcast only code. Anyway, back to what I was doing.
Bombshell
DC Developer
DC Developer
Posts: 179
Joined: Wed Nov 20, 2002 8:29 pm
Has thanked: 0
Been thanked: 0

Post by Bombshell »

Cool 20 more minutes till school is done and i can go home to work on the menu and the controller functions to program. Can you also provide me to a link to your RAD Quake source so that i can have a go at getting the mapple wood controller working on it theat sounds like a good challenge and by the sound of it that is the only missing feature in it. Anywas Later
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

THE source has not been uploaded yet to any server for r.a.d quake

heres the full video controler driver !

the source will not compile at the moment in the midle of adding features

so its of no use should be fixed as soon as i can remember what i did to it

ill upload it the way it is soon its pretty hefty so i need to give it to my site updater goldbergwwe

Code: Select all

// vid_sdl.h -- sdl video driver 
#include <dc/maple.h>
#include <dc/maple/keyboard.h>
#include <dc/maple/controller.h>
#include <dc/maple/mouse.h>



#include "quakedef.h"
#include "d_local.h"
#include "alloca.h"
#include <stdio.h> 
#include <stdlib.h> 
#include <SDL.h> 
#include <SDL_timer.h> 
#include "SDL.h" 
#include "SDL_timer.h" 
viddef_t    vid;                // global video state
unsigned short  d_8to16table[256];

//reaper2k2
#define    BASEWIDTH    320
#define    BASEHEIGHT   240


int    VGA_width, VGA_height, VGA_rowbytes, VGA_bufferrowbytes = 0;
byte    *VGA_pagebase;

static SDL_Surface *screen = NULL;

static qboolean mouse_avail;
static float   mouse_x, mouse_y;
static int mouse_oldbuttonstate = 0;

// No support for option menus
void (*vid_menudrawfn)(void) = NULL;
void (*vid_menukeyfn)(int key) = NULL;

void    VID_SetPalette (unsigned char *palette)
{
    int i;
    SDL_Color colors[256];

    for ( i=0; i<256; ++i )
    {
        colors[i].r = *palette++;
        colors[i].g = *palette++;
        colors[i].b = *palette++;
    }
    SDL_SetColors(screen, colors, 0, 256);
}

void    VID_ShiftPalette (unsigned char *palette)
{
    VID_SetPalette(palette);
}

void    VID_Init (unsigned char *palette)
{
    int pnum, chunk;
    byte *cache;
    int cachesize;
   Uint8 video_bpp;
  // Uint16 video_bpp;
   Uint32 flags;

    // Load the SDL library
    if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_CDROM) < 0)
        Sys_Error("VID: Couldn't load SDL: %s", SDL_GetError());
      
       
       
    // Set up display mode (width and height)
    vid.width = BASEWIDTH;
    vid.height = BASEHEIGHT;
    vid.maxwarpwidth = WARP_WIDTH;
    vid.maxwarpheight = WARP_HEIGHT;
    if ((pnum=COM_CheckParm("-winsize")))
    {
        if (pnum >= com_argc-2)
            Sys_Error("VID: -winsize <width> <height>\n");
        vid.width = Q_atoi(com_argv[pnum+1]);
        vid.height = Q_atoi(com_argv[pnum+2]);
        if (!vid.width || !vid.height)
            Sys_Error("VID: Bad window width/height\n");
    }

    // Set video width, height and flags
    flags = (SDL_HWSURFACE |SDL_HWPALETTE | SDL_HWACCEL | SDL_SRCALPHA ); 
    if ( COM_CheckParm ("-fullscreen") )
        flags |= SDL_FULLSCREEN;

    // Initialize display 
    if (!(screen = SDL_SetVideoMode(vid.width, vid.height, 8, flags)))
        Sys_Error("VID: Couldn't set video mode: %s\n", SDL_GetError());
    VID_SetPalette(palette);
    SDL_WM_SetCaption("sdlquake","sdlquake");
    // now know everything we need to know about the buffer
    VGA_width = vid.conwidth = vid.width;
    VGA_height = vid.conheight = vid.height;
    vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0);
    vid.numpages = 1;
    vid.colormap = host_colormap;
    vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
    VGA_pagebase = vid.buffer = screen->pixels;
    VGA_rowbytes = vid.rowbytes = screen->pitch;
    vid.conbuffer = vid.buffer;
    vid.conrowbytes = vid.rowbytes;
    vid.direct = 0;
    
    // allocate z buffer and surface cache
    chunk = vid.width * vid.height * sizeof (*d_pzbuffer);
    cachesize = D_SurfaceCacheForRes (vid.width, vid.height);
    chunk += cachesize;
    d_pzbuffer = Hunk_HighAllocName(chunk, "video");
    if (d_pzbuffer == NULL)
        Sys_Error ("Not enough memory for video mode\n");

    // initialize the cache memory 
        cache = (byte *) d_pzbuffer
                + vid.width * vid.height * sizeof (*d_pzbuffer);
    D_InitCaches (cache, cachesize);

    // initialize the mouse
    SDL_ShowCursor(0);
}



void
VID_Shutdown (void)
{
	SDL_Quit ();
}

void
VID_Update (vrect_t *rects)
{
	SDL_Rect   *sdlrects;
	int         n, i;
	vrect_t    *rect;

	// Two-pass system, since Quake doesn't do it the SDL way...

	// First, count the number of rectangles
	n = 0;
	for (rect = rects; rect; rect = rect->pnext)
		++n;

	// Second, copy them to SDL rectangles and update
	if (!(sdlrects = (SDL_Rect *) alloca ( n * sizeof (SDL_Rect))))
		Sys_Error ("Out of memory!");
	i = 0;
	for (rect = rects; rect; rect = rect->pnext) {
		sdlrects[i].x = rect->x;
		sdlrects[i].y = rect->y;
		sdlrects[i].w = rect->width;
		sdlrects[i].h = rect->height;
		++i;
	}
	SDL_UpdateRects (screen, n, sdlrects);
}

/*
	D_BeginDirectRect
*/
void
D_BeginDirectRect (int x, int y, byte * pbitmap, int width, int height)
{
	Uint8     *offset;


	if (!screen)
		return;
	if (x < 0)
		x = screen->w + x - 1;
	offset = (Uint8 *) screen->pixels + y * screen->pitch + x;
	while (height--) {
		memcpy (offset, pbitmap, width);
		offset += screen->pitch;
		pbitmap += width;
	}
}

/*
	D_EndDirectRect
*/
void
D_EndDirectRect (int x, int y, int width, int height)
{
	if (!screen)
		return;
	if (x < 0)
		x = screen->w + x - 1;
	SDL_UpdateRect (screen, x, y, width, height);
}





/*
================
Sys_SendKeyEvents
================
*/

void Sys_SendKeyEvents(void)
{
    SDL_Event event;
    int sym, state;
     int modstate;

    while (SDL_PollEvent(&event))
    {
        switch (event.type) {

            case SDL_KEYDOWN:
            case SDL_KEYUP:
                sym = event.key.keysym.sym;
                state = event.key.state;
                modstate = SDL_GetModState();
                switch(sym)
                {
                   case SDLK_DELETE: sym = K_DEL; break;
                  // case SDLK_BACKSPACE: sym = K_BACKSPACE; break;
                   case SDLK_F1: sym = K_F1; break;
                   case SDLK_F2: sym = K_F2; break;
                   case SDLK_F3: sym = K_F3; break;
                   case SDLK_F4: sym = K_F4; break;
                   case SDLK_F5: sym = K_F5; break;
                   case SDLK_F6: sym = K_F6; break;
                   case SDLK_F7: sym = K_F7; break;
                   case SDLK_F8: sym = K_F8; break;
                   case SDLK_F9: sym = K_F9; break;
                   case SDLK_F10: sym = K_F10; break;
                   case SDLK_F11: sym = K_F11; break;
                   case SDLK_F12: sym = K_F12; break;
                   case SDLK_BREAK:
                   case SDLK_PAUSE: sym = K_PAUSE; break;
                   case SDLK_UP: sym = K_UPARROW; break;
                   case SDLK_DOWN: sym = K_DOWNARROW; break;
                   case SDLK_RIGHT: sym = K_RIGHTARROW; break;
                   case SDL_HAT_LEFT: sym = K_LEFTARROW; break;
                   case SDLK_INSERT: sym = K_INS; break;
                   case SDLK_HOME: sym = K_HOME; break;
                   case SDLK_END: sym = K_END; break;
                   case SDLK_PAGEUP: sym = K_PGUP; break;
                   case SDLK_PAGEDOWN: sym = K_PGDN; break;
                   case SDLK_RSHIFT:
                   case SDLK_LSHIFT: sym = K_SHIFT; break;
                   case SDLK_RCTRL:
                   case SDLK_LCTRL: sym = K_CTRL; break;
                   case SDLK_RALT:
                   case SDLK_LALT: sym = K_ALT; break;
                   case SDLK_KP0: 
                       if(modstate & KMOD_NUM) sym = K_INS; 
                       else sym = SDLK_0;
                       break;
                   case SDLK_KP1:
                       if(modstate & KMOD_NUM) sym = K_END;
                       else sym = SDLK_1;
                       break;
                   case SDLK_KP2:
                       if(modstate & KMOD_NUM) sym = K_DOWNARROW;
                       else sym = SDLK_2;
                       break;
                   case SDLK_KP3:
                       if(modstate & KMOD_NUM) sym = K_PGDN;
                       else sym = SDLK_3;
                       break;
                   case SDLK_KP4:
                       if(modstate & KMOD_NUM) sym = K_LEFTARROW;
                       else sym = SDLK_4;
                       break;
                   case SDLK_KP5: sym = SDLK_5; break;
                   case SDLK_KP6:
                       if(modstate & KMOD_NUM) sym = K_RIGHTARROW;
                       else sym = SDLK_6;
                       break;
                   case SDLK_KP7:
                       if(modstate & KMOD_NUM) sym = K_HOME;
                       else sym = SDLK_7;
                       break;
                   case SDLK_KP8:
                       if(modstate & KMOD_NUM) sym = K_UPARROW;
                       else sym = SDLK_8;
                       break;
                   case SDLK_KP9:
                       if(modstate & KMOD_NUM) sym = K_PGUP;
                       else sym = SDLK_9;
                       break;
                   case SDLK_KP_PERIOD:
                       if(modstate & KMOD_NUM) sym = K_DEL;
                       else sym = SDLK_PERIOD;
                       break;
                   case SDLK_KP_DIVIDE: sym = SDLK_SLASH; break;
                   case SDLK_KP_MULTIPLY: sym = SDLK_ASTERISK; break;
                   case SDLK_KP_MINUS: sym = SDLK_MINUS; break;
                   case SDLK_KP_PLUS: sym = SDLK_PLUS; break;
                   case SDLK_KP_ENTER: sym = SDLK_RETURN; break;
                   case SDLK_KP_EQUALS: sym = SDLK_EQUALS; break;
                }
                
	
                
                
                
                // If we're not directly handled and still above 255
                // just force it to 0
                if(sym > 255) sym = 0;
                Key_Event(sym, state);
                break;
            case SDL_MOUSEMOTION:
                if ( (event.motion.x != (vid.width/2)) ||
                     (event.motion.y != (vid.height/2)) ) {
                    mouse_x = event.motion.xrel*10;
                    mouse_y = event.motion.yrel*10;
                    if ( (event.motion.x < ((vid.width/2)-(vid.width/4))) ||
                         (event.motion.x > ((vid.width/2)+(vid.width/4))) ||
                         (event.motion.y < ((vid.height/2)-(vid.height/4))) ||
                         (event.motion.y > ((vid.height/2)+(vid.height/4))) ) {
                        SDL_WarpMouse(vid.width/2, vid.height/2);
                    }
                }
                break;

            case SDL_QUIT:
                CL_Disconnect ();
                Host_ShutdownServer(false);        
                Sys_Quit ();
                break;
            default:
                break;
        }
    }
}

void IN_Init (void)
{
    if ( COM_CheckParm ("-nomouse") )
        return;
    mouse_x = mouse_y = 0.0;
    mouse_avail = 1;
}

void IN_Shutdown (void)
{
    mouse_avail = 0;
}

void IN_Commands (void)
{
    int i;
    int mouse_buttonstate;
   
    if (!mouse_avail) return;
   
    i = SDL_GetMouseState(NULL, NULL);
    /* Quake swaps the second and third buttons */
    mouse_buttonstate = (i & ~0x06) | ((i & 0x02)<<1) | ((i & 0x04)>>1);
    for (i=0 ; i<3 ; i++) {
        if ( (mouse_buttonstate & (1<<i)) && !(mouse_oldbuttonstate & (1<<i)) )
            Key_Event (K_MOUSE1 + i, true);

        if ( !(mouse_buttonstate & (1<<i)) && (mouse_oldbuttonstate & (1<<i)) )
            Key_Event (K_MOUSE1 + i, false);
    }
    mouse_oldbuttonstate = mouse_buttonstate;
}

void IN_Move (usercmd_t *cmd)
{
    if (!mouse_avail)
        return;
   
    mouse_x *= sensitivity.value;
    mouse_y *= sensitivity.value;
   
    if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
        cmd->sidemove += m_side.value * mouse_x;
    else
        cl.viewangles[YAW] -= m_yaw.value * mouse_x;
    if (in_mlook.state & 1)
        V_StopPitchDrift ();
   
    if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) {
        cl.viewangles[PITCH] += m_pitch.value * mouse_y;
        if (cl.viewangles[PITCH] > 80)
            cl.viewangles[PITCH] = 80;
        if (cl.viewangles[PITCH] < -70)
            cl.viewangles[PITCH] = -70;
    } else {
        if ((in_strafe.state & 1) && noclip_anglehack)
            cmd->upmove -= m_forward.value * mouse_y;
        else
            cmd->forwardmove -= m_forward.value * mouse_y;
    }
    mouse_x = mouse_y = 0.0;
}


	

	
		
	


/*
================
Sys_ConsoleInput
================
*/
char *Sys_ConsoleInput (void)
{
    return 0;
}
thats the full controler code and video if you want to take a look fast grab the q1.zip of id software its 3.6 meg then the SDLquake source its a bit smaller all you need is some voided functions and you can get your own port working pretty fast i dont have a fast connection 56k the whole source is about 8 meg for me at the moment so please forgive me for not uploading it just yet nothing is commented in it ether I know bad habbit lol

the source to the Siemu will be out soon to ive been busy working on IT

new version will be out that is shocklying pro looking ABOUT TIME lol

off to sleep

blue crab i dont think i changed any think i think all the examples we had were crap as i used the first mixer you gave me and it worked!
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

Ok, I'll just try a few other things and see what I come up with....
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

THERES still lots of problems with the mixer seems to be not using the right paths to me still

if you want to take a look now head off the th authors site of the pc version the sound system in that emu siemu i did not need to change it to get it to work only include headers it was a shock to hear sound
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

i get these errors a lot when trying to port any think that uses the SDL_MIXER i just make null .c file and get it to compile but this must be the problem with it

Code: Select all

/usr/local/dc/kos/lib/libSDL_mixer.a(mixer.o): In function `mix_channels':
/usr/local/dc/kos/addons/SDL_mixer/mixer.c:184: undefined reference to `SDL_MixAudio'
/usr/local/dc/kos/lib/libSDL_mixer.a(mixer.o): In function `Mix_LoadWAV_RW':
/usr/local/dc/kos/addons/SDL_mixer/mixer.c:384: undefined reference to `SDL_ReadLE32'
/usr/local/dc/kos/addons/SDL_mixer/mixer.c:384: undefined reference to `SDL_FreeWAV'
/usr/local/dc/kos/addons/SDL_mixer/mixer.c:384: undefined reference to `SDL_LoadWAV_RW
'
/usr/local/dc/kos/lib/libSDL_mixer.a(music_ogg.o): In function `OGG_new':
/usr/local/dc/kos/addons/SDL_mixer/music_ogg.c:82: undefined reference to `ov_open'
/usr/local/dc/kos/lib/libSDL_mixer.a(music_ogg.o): In function `OGG_getsome':
/usr/local/dc/kos/addons/SDL_mixer/music_ogg.c:112: undefined reference to `ov_read'
/usr/local/dc/kos/addons/SDL_mixer/music_ogg.c:112: undefined reference to `ov_info'
/usr/local/dc/kos/lib/libSDL_mixer.a(music_ogg.o): In function `OGG_playAudio':
/usr/local/dc/kos/addons/SDL_mixer/music_ogg.c:150: undefined reference to `SDL_MixAud
io'
/usr/local/dc/kos/lib/libSDL_mixer.a(music_ogg.o): In function `OGG_delete':
/usr/local/dc/kos/addons/SDL_mixer/music_ogg.c:185: undefined reference to `ov_clear'
/usr/local/dc/kos/lib/libSDL_mixer.a(music_ogg.o): In function `OGG_jump_to_time':
/usr/local/dc/kos/addons/SDL_mixer/music_ogg.c:191: undefined reference to `ov_time_se
ek'
/usr/local/dc/kos/lib/libSDL_mixer.a(wavestream.o): In function `ReadChunk':
/usr/local/dc/kos/addons/SDL_mixer/wavestream.c:254: undefined reference to `SDL_ReadL
E32'
/usr/local/dc/kos/lib/libSDL_mixer.a(wavestream.o): In function `LoadWAVStream':
/usr/local/dc/kos/addons/SDL_mixer/wavestream.c:285: undefined reference to `SDL_ReadL
E32'
/usr/local/dc/kos/lib/libSDL_mixer.a(wavestream.o): In function `LoadAIFFStream':
/usr/local/dc/kos/addons/SDL_mixer/wavestream.c:436: undefined reference to `SDL_ReadL
E32'
/usr/local/dc/kos/addons/SDL_mixer/wavestream.c:436: undefined reference to `SDL_ReadB
E32'
/usr/local/dc/kos/addons/SDL_mixer/wavestream.c:436: undefined reference to `SDL_ReadB
E16'
/usr/local/dc/kos/lib/libSDL_mixer.a(load_aiff.o): In function `Mix_LoadAIFF_RW':
/usr/local/dc/kos/addons/SDL_mixer/load_aiff.c:92: undefined reference to `SDL_ReadLE3
2'
/usr/local/dc/kos/addons/SDL_mixer/load_aiff.c:92: undefined reference to `SDL_ReadBE3
2'
/usr/local/dc/kos/addons/SDL_mixer/load_aiff.c:92: undefined reference to `SDL_ReadBE1
6'
some path is not set is what im thinking some were ive looked for a few hours manged to get SDL_TFF not to cause any errors but i dont know if it works ether i think bluecrab had it working for his system

/usr/local/dc/kos/lib/libSDL_image.a(IMG_bmp.o): In function `IMG_LoadBMP_RW':
/usr/local/dc/kos/addons/SDL_image/IMG_bmp.c:53: undefined reference to `SDL_LoadBMP_R
W'

i get this from this lib ive include the I paths in the make files as well

still gives this error SDL_IMAGE has not worked for me yet all i still get is a blank screen so i cant test the unpdated source to the game yet bombshell the new site is looking pretty good for R.A.D software
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

IVE ported quiet a few sdl games all just get to a black screen all use SDL_image


ITS still giving a black screen it does not work even using this code

Code: Select all

#include "SDL.h" 
#include "SDL_image.h" 
int main(int argc, char *argv[])   { 
   uint32 flags = (SDL_HWSURFACE|SDL_FULLSCREEN); //i changed this 
   SDL_Surface * screen, * image; 

   if(SDL_Init(SDL_INIT_VIDEO) < 0)   { 
      return -1; 
   } 

   /* Set our video mode to 640x480 16bpp */ 
   screen = SDL_SetVideoMode(640, 480, 16, flags); 

/* This stuff, right now, is only applicable to the DC version. */ 
#ifdef _arch_dreamcast 

   /* Load up disclaimer */ 
   image = IMG_Load("/cd/rad.jpg"); /* This is the only difference between using SDL_image, and SDL's builtin BMP function, all other stuff works just the same */ 

   /* Put up the Disclaimer */ 
   SDL_BlitSurface(image, NULL, screen, NULL); 
   SDL_Flip(screen); 

   SDL_Delay(200000);  

   /* Get rid of the image */ 
   SDL_FreeSurface(image); 

#endif 

/* put the rest of your game here, of course, in different functions */ 
   return 0; 
}
i can see the mouse pointer but black screen as allways

I USED the NEW version off bluecrabs site still did not work i used the right thing in the link line to and had the paths right

just does not work ive tested it with JPG and PNG nothing just a black screen so if any one did it get it working tell me i do need this lib now
Last edited by reaper2k2 on Sat Jan 11, 2003 8:59 am, edited 1 time in total.
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

Ok, did you modify the paths to the images in the stuff that uses SDL_image, and did you place the images on your CD where the IMG_Load call says they'll be.

Also, the new version of SDL_image that was on my site has a slightly different path to go with how SDL is arranged on KOS now. It is actually in addons/sdl/SDL_image and its include is in the same directory as the normal SDL ones, so you can get rid of the -I$(KOS_BASE)/includes/SDL_image in your makefile. I think your problem may be that you are compiling the old version (which didn't work).

As for your SDL_mixer problems, thats due to the fact that you need to link with the following to use SDL_mixer "-lSDL_mixer -lSDL" (of course in addition to what you already have, and if you want OGG vorbis support, don't forget to put "-ltremor" in there too.
Bombshell
DC Developer
DC Developer
Posts: 179
Joined: Wed Nov 20, 2002 8:29 pm
Has thanked: 0
Been thanked: 0

Post by Bombshell »

reaper2k2 wrote:

Code: Select all

   image = IMG_Load("/cd/rad.jpg");
   
   /* Put up the Disclaimer */ 
   SDL_BlitSurface(image, NULL, screen, NULL); 
   SDL_Flip(screen); 

   SDL_Delay(200000);  

   /* Get rid of the image */ 
   SDL_FreeSurface(image); 
Reaper can you see any it in any other games using the straight SDL_image function? or is it just in this instance. Here is what i am using in DC Slots try replacing it with your IMG_Load Function and see if anything better comes out of it,

Code: Select all

SDL_Surface *loadImg(char *loadPrefix, int num, char *loadExt) {
    SDL_Surface *image;

    // Declare our strings that will be used for our file name
    char fileName[35];
    //Check to make sure there is not an overflow
    if(strlen(loadPrefix) + strlen(loadExt) > 34) {
        printf("Boo-urns buffer overflow,\n file names and paths must be less then 35 characters\n");
        return 0;
    }
    sprintf(fileName, "%s%d.%s", loadPrefix, num, loadExt);
    image = SDL_image(fileName);
    if(image == NULL) {
        getError();
    }
    return image;
}
Also kind of harsh is it not to make them wait for 200 seconds :wink:
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

YES i did mod the paths im still using kos1.18 ive even stoped using the cd and got SDL using the romdisk system in kos


SO jpegs worked for you im reading this site right now

http://jcatki.no-ip.org/SDL_image/

I cant find all the ones you had uploaded before blue crab the mixer have you changed it any as i think straight wav files sound in SDL is what is working not the mixer

if i use just SDL i can display bmp files fine

bombshell

straight SDL_image function is working well no problems with that just any thing that uses SDL IMAGE give nothing but a black screen it does not reboot and the program is still running
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

I've only tested using PNG files, not JPEGs, that was put in there just for anyone to test. I can't run tests of my own right now because I'm compiler-less. Anyway, maybe later tonight I'll get my compiler working again.
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

HEREs some more

Post by reaper2k2 »

I put this together to test if its the SDL_IMAGE LIB

IT compiles and works on dev c++ and it does work on the dreamcast if you use the SDL built in bmp functions

Code: Select all

#include "SDL.h"
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h> 
#include <SDL/SDL_image.h> 
//reaper angel  splash screen example windows/dreamcast 2003

void ComplainAndExit(void) 
{ 
        fprintf(stderr, "Problem: %s\n", SDL_GetError()); 
        exit(1); 
} 

int main(int argc, char *argv[]) 
{ 
        SDL_PixelFormat fmt; 
        SDL_Surface *screen, *locked; 
        SDL_Surface *imagebmp, *image; 
        SDL_Rect dstrect; 
        int i; 
        Uint8 *buffer; 

        /* Initialize SDL */ 
        if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { 
                ComplainAndExit(); 
        } 
        atexit(SDL_Quit); 

        /* Load a BMP image into a surface */ 
        imagebmp = IMG_Load("/cd/RAD.jpg");   //only change needed ETC
        if ( imagebmp == NULL ) { 
                ComplainAndExit(); 
        } 

        /* Set the video mode (640x480 at native depth) */ 
        screen = SDL_SetVideoMode(640, 480, 0, SDL_HWSURFACE|SDL_FULLSCREEN); 
        if ( screen == NULL ) { 
                ComplainAndExit(); 
        } 

        /* Set the video colormap */ 
        if ( imagebmp->format->palette != NULL ) { 
                SDL_SetColors(screen, 
                                imagebmp->format->palette->colors, 0, 
                                imagebmp->format->palette->ncolors); 
        } 

        /* Convert the image to the video format (maps colors) */ 
        image = SDL_DisplayFormat(imagebmp); 
        SDL_FreeSurface(imagebmp); 
        if ( image == NULL ) { 
                ComplainAndExit(); 
        } 

        /* Draw bands of color on the raw surface */ 
        if ( SDL_MUSTLOCK(screen) ) { 
                if ( SDL_LockSurface(screen) < 0 ) 
                        ComplainAndExit(); 
        } 
        buffer=(Uint8 *)screen->pixels; 
        for ( i=0; i<screen->h; ++i ) { 
                memset(buffer,(i*255)/screen->h, 
                        screen->w*screen->format->BytesPerPixel); 
                buffer += screen->pitch; 
        } 
        if ( SDL_MUSTLOCK(screen) ) { 
                SDL_UnlockSurface(screen); 
        } 

        /* Blit the image to the center of the screen */ 
        dstrect.x = (screen->w-image->w)/2; 
        dstrect.y = (screen->h-image->h)/2; 
        dstrect.w = image->w; 
        dstrect.h = image->h; 
        if ( SDL_BlitSurface(image, NULL, screen, &dstrect) < 0 ) { 
                SDL_FreeSurface(image); 
                ComplainAndExit(); 
        } 
        SDL_FreeSurface(image); 

        /* Update the screen */ 
        SDL_UpdateRects(screen, 1, &dstrect); 

        SDL_Delay(50000);        /* Wait 5 seconds */    // change this to display longer 
   return 0; 
}
IT's acting like the make file has not got it defined ON the dreamcast yet it is..... still have nothing working with SDL_IMAGE i dont think im causing it ...

i cant go on till i get this working
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

I'll try to get my compiler up tonight and see if I have any problems with it....
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

heres a little program to test if you SDL image is working or check what formats are working its for windows etc but maybe we can mod a version of it

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
#include <libiberty.h>
#include "SDL.h"
#include "SDL_image.h"


char *files[]={
	"lena.bmp", "BMP",
	"lena.gif", "GIF",
	"lena.jpg", "JPG",
	"lena.lbm", "LBM",
	"lena.pcx", "PCX",
	"lena.png", "PNG",
	"lena.pnm", "PNM",
	"lena.tga", "TGA",
	"lena.tif", "TIF",
	"lena.xcf", "XCF",
	"lena.xpm", "XPM",
	NULL,
	"lena.xbm", "XBM",
	NULL
};

int main(int argc, char **argv)
{
	SDL_Surface *image;
	int i;
	
	/* check arguments */
	if(argc!=1)
	{
		printf("%s (no arguments)\n",*argv);
		return 1;
	}

	/* startup SDL */
	if(SDL_Init(SDL_INIT_VIDEO)==-1)
	{
		printf("SDL_Init: %s\n", SDL_GetError());
		return 1;
	}

	for(i=0; files[i]; i+=2)
	{
		/* load the image */
		image=IMG_Load(files[i]);
		if(!image)
		{
			/* image failed to load */
			printf("IMG_Load: %s\n", IMG_GetError());
			printf("%s is not supported, or the image data is corrupted\n", files[i+1]);
			files[i+1]=NULL;
			continue;
		}
		/* report success */
		printf("%s is supported\n", files[i+1]);
		/* free the loaded image */
		SDL_FreeSurface(image);
	}

	/* shutdown SDL */
	SDL_Quit();

	return 0;
}
this prints a report to a txt file if you can make it print the report to the screen and hold it draw frame till press start some think like that maybe it will provide some debug info i dont really know if it will just a thought

could be total waste of time works for windows thou
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
Post Reply