Offline

Hello!

I don't know much about coding, especially not C, ASM or anything hardware related.
But I really, really need to finish a project before this week ends.

What I need to do is rewrite a small piece of the source rom for the GBA Slideshow Builder, I need it to change picture every second instead of using the buttons to manually advance the slides.

I've got Devkit Advance running, I can compile some things fine, but not the .bin I need to use for this.
There's a file called makefile.mak that I tried making into a .bat (read a tutorial on compiling for the gba), but that didn't work.

CFLAGS    = -I c:\gba\include -c -g -O2 -mthumb-interwork -Wall -ffreestanding
ASFLAGS    = -mthumb-interwork
LDFLAGS = -L c:\gba\lib -T gbarom2mb

all : ufgbass.bin

ufgbass.bin : ufgbass.elf
    objcopy -v -O binary ufgbass.elf ufgbass.bin

ufgbass.elf : main.o
    ld $(LDFLAGS) -o ufgbass.elf main.o

main.o : main.c
    gcc $(CFLAGS) main.c

I don't know if this is for a different compiler or devkit or something, I have no idea at all.
I just know I need this project to be finished asap and would appreciate help.

And, I need the code to change the slides automatically.
I'm thinking I need to change these lines of code:

 // react to joypad presses
  while(1)
  {
    // copy current index
    imgNew = imgCurrent;
    if (!(PADREG & PAD_RIGHT)) imgNew++;
    if (!(PADREG & PAD_LEFT)) imgNew--;
    // wrap around if neccesary
    if (imgNew < 0) imgNew = imgCount - 1;
    if (imgNew >= imgCount) imgNew = 0;
    // copy image
    if (imgNew != imgCurrent)
    {
      waitVSync();
      copyImage(pScreen, imageinfo.list->start[imgNew]);
      imgCurrent = imgNew;
      // wait keyDelay frames
      for(keyDelayCount = keyDelay; keyDelayCount > 0; keyDelayCount--) 
      {
        // next time use shorter delay
        keyDelay = KEYREPEATDELAY;
        waitVSync();
        // both keys are released ?
        if ((PADREG & PAD_RIGHT) && (PADREG & PAD_LEFT)) 
        {
          // use initial delay 
          keyDelay = KEYWAITDELAY;
          // break from loop
          break;
        }
      }
    }
  }
}

Here is a link to the program:
http://www.gameboy-advance.net/emulated … e_show.htm

Here is the sourcerom:
http://moire.se/sourcerom.zip

It would mean alot to me if I could get some help with this.

Offline
Sweeeeeeden
 // react to joypad presses
  while(1)
  {
    waitVSync();

    countdown++;
    if (countdown>60){
      countdown=0;
      imgNew++;
    }

    // copy current index
    imgNew = imgCurrent;
    if (!(PADREG & PAD_RIGHT)) imgNew++;
    if (!(PADREG & PAD_LEFT)) imgNew--;
    // wrap around if neccesary
    imgNew = (imgNew+imgCount) %imgCount;


    // copy image
    if (imgNew != imgCurrent)
    {
      copyImage(pScreen, imageinfo.list->start[imgNew]);
      imgCurrent = imgNew;
      // wait keyDelay frames
      for(keyDelayCount = keyDelay; keyDelayCount > 0; keyDelayCount--) 
      {
        // next time use shorter delay
        keyDelay = KEYREPEATDELAY;
        waitVSync();
        // both keys are released ?
        if ((PADREG & PAD_RIGHT) && (PADREG & PAD_LEFT)) 
        {
          // use initial delay 
          keyDelay = KEYWAITDELAY;
          // break from loop
          break;
        }
      }
      countdown=0;
    }
  }
}

Something like this-ish maybe a little bit? Note that I've shuffled things around a bit, so copy all of the code as is.

You also need to declare the countdown variable (or technically countup) somewhere near the start of the function. This is where all the other variables are defined.

int countdown;

The time taken waited between each frame image is controlled by "if (countdown>60){". 60 here means 60 frames, which is one second.

Offline

I knew I could count on you. smile

No pun intended.

Thanks!

Offline
Sweeeeeeden

Are you getting any error messages when trying to compile?