hello

there is a C++ game called dunelegacy which work on other GCC architecture ok
On G++ 68k it compile ok, but produce wrong code, because there seem something 
diffrent in
va_list. The value of
SDL_RWops is transfer wrong.

I do not understand what backend problem is possible to cause this. Please 
help.va_list use the
builtin GCC functions

this happen on all 68k compilers i test. (3.x and some 4.x)

See also the source attached of this class

the program flow of the critical part begin here. 

Wsafile::Wsafile(SDL_RWops* RWop)
{
    readdata(1,RWop);
}

......


now there are 2 Methods named readdata, and gcc call the 2. one. This work 
wrong. Only when called
the first is ok.

.....

void Wsafile::readdata(int NumFiles, ...) {
    va_list args;
    va_start(args,NumFiles);
    readdata(NumFiles,args);
    va_end(args);
}

/// Helper method for reading and concatinating various WSA-Files.
/**
    This methods reads from the RWops all data and concatinates all the frames 
to one animation. The
SDL_RWops
    can be readonly but must support seeking.
    \param  NumFiles    Number of SDL_RWops
    \param  args        SDL_RWops for each wsa-File should be in this va_list. 
(can be readonly)
*/
void Wsafile::readdata(int NumFiles, va_list args) {
    unsigned char** Filedata;
    Uint32** Index;
    Uint16* NumberOfFrames;
    bool* extended;

    if((Filedata = (unsigned char**) malloc(sizeof(unsigned char*) * NumFiles)) 
== NULL) {
        fprintf(stderr, "Wsafile::readdata(): Unable to allocate memory!\n");
        exit(EXIT_FAILURE);
    }


.....................


when i change code to this and rename the first readdata method to 
readdata_first then it work

Wsafile::Wsafile(SDL_RWops* RWop)
{
    readdata_first(1,RWop);   <---- I change that line
}

now there is called this method before and all work ok


void Wsafile::readdata_frist(int NumFiles, ...) {   <---- I rename readdata to 
readdata_first.
    va_list args;
    va_start(args,NumFiles);
    readdata(NumFiles,args);
    va_end(args);
}

/// Helper method for reading and concatinating various WSA-Files.
/**
    This methods reads from the RWops all data and concatinates all the frames 
to one animation. The
SDL_RWops
    can be readonly but must support seeking.
    \param  NumFiles    Number of SDL_RWops
    \param  args        SDL_RWops for each wsa-File should be in this va_list. 
(can be readonly)
*/
void Wsafile::readdata(int NumFiles, va_list args) {
    unsigned char** Filedata;
    Uint32** Index;
    Uint16* NumberOfFrames;
    bool* extended;

    if((Filedata = (unsigned char**) malloc(sizeof(unsigned char*) * NumFiles)) 
== NULL) {
        fprintf(stderr, "Wsafile::readdata(): Unable to allocate memory!\n");
        exit(EXIT_FAILURE);
    }

    ..........

       int WsaFilesize;
        RWop = va_arg(args,SDL_RWops*);   
        Filedata[i] = readfile(RWop,&WsaFilesize); <--- here crash, when not 
the 1. method is called
before

Bye

Reply via email to