gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > BoycottAdvance & Vis. Boy Adv.: Different results (+src&

#9619 - Domovoi - Mon Aug 11, 2003 12:32 am

Hi there. I'm testing some interrupt code I've been writing, and I noticed an oddity while doing so. I normally run my compiled code in BoycottAdvance (because it starts faster), but when I want to check tile data and such, I use VisualBoy Advance.

However, when I run the same .bin in both emulators, they don't yield the exact same result. BCA displays things fine, while VBA messes up the background map.

Here's what I'm doing: I wrote an interrupt handler in C, which scrolls background 0 (using he BG0VOFS register) to various positions when reaching certain scanlines. So at line 0 it's scrolled to a certain point, then at line 8 it's scrolled to somewhere else, then on 16, it is scrolled on the position 'it should be'. (in other words, the top two rows of tiles display something, and the rest of the screen is something else).

However, I need to store the position 'it should be' before I start moving the map around at lines 0 and 8, or I won't know where it should go on 16. So what I'm doing is I created a static variable in the interrupt handler, and at line 0, it stores the contents of BG0VOFS in that variable, and then sets BG0VOFS to its desired value. Later it sets BG0VOFS to another value, and when it reaches line 16, I need to put the map back where it was before; the value stored in the static variable.

It works like a charm on BCA. No problem whatsover. But on VBA, for some reason, I have to add 45 to the static variable, or the map won't be at the right position (the top two tiles are.) Of course, when I do that (which isn't a solution of course), it naturally looks messed up in BCA.

Does anyone have an idea what's going on here? I'm baffled by the fact that the two emulators yield different results. Now I can't tell wether my code is correct, because I don't know which emulator is the 'good' one. (I can't test on hardware, by the way.) Besides, if it turned out VBA -does- display it wrong... then that would render VBA useless.

Anyone know what's going on? Does BCA take certain liberties it shouldn't, or does VBA not support things it should? Or is there something else?

Edit: Could be handy to show you exactly what's happening... Here's the interrupt handler:

Code:

void InterruptHandler()
{
   if (REG_IF & INT_VCOUNT)
   {
      static unsigned short pos = 240;

      if (REG_VCOUNT == 0) 
      {
         pos = REG_BG0VOFS;

         REG_BG0VOFS = 248;
         REG_DISPSTAT = 32 | (8 << 8);
      }
      else if (REG_VCOUNT == 8)
      {
         REG_BG0VOFS = 240;
         REG_DISPSTAT = 32 | (16 << 8);
      }
      else if (REG_VCOUNT == 16)
      {
         REG_BG0VOFS = pos;
         REG_DISPSTAT = 32 | (144 << 8);
      }
      else if (REG_VCOUNT == 144)
      {
         REG_BG0VOFS = 104;
         REG_DISPSTAT = 32 | (152 << 8);
      }
      else if (REG_VCOUNT == 152)
      {
         REG_BG0VOFS = 96;
         REG_DISPSTAT = 32;
      }

      REG_IF = INT_VCOUNT;
   }
}


So, on lines 0, 8, 16, 144, and 152, it scrolls the map to a certain position, and sets REG_DISPSTAT to cause an interrupt on the next desired line. On line 0, the vertical offset might've been changed by user input, so it is saved to pos, and on line 16, it is read from pos again to scroll to that point.

Here's the .bin: http://baspaap.hypermart.net/GBAScroll2.bin

Try it out in BoycottAdvane and VisualBoyAdvance. (use left and right to scroll.) On BCA, it runs as I expected, but in VBA, the offset from line 16 to 144 is wrong. Anyone got an idea?

#9633 - jenswa - Mon Aug 11, 2003 7:21 pm

I don't know how it should look.

with ba .28 and it was really screwed up.
and with vboy there are some black lines and
a good picture and a part with tiles.

I don't know what the problem, but it doesn't work
on both emus for me.

If you can compile a multiboot version, i might be able
to test it on hardware and see how it looks
_________________
It seems this wasn't lost after all.

#9636 - abilyk - Mon Aug 11, 2003 8:13 pm

I just tested the .bin on hardware for you. It looks and runs exactly the same as it does with VBA, with the addition of a couple artifacts towards the top and bottom of the screen. I've heard something about VBA being able to use an image of the GBA bios to better emulate the hardware. Perhaps if you did that, VBA would produce those additional artifacts as well so you can better troubleshoot.

#9826 - Daniel Andersen - Tue Aug 19, 2003 7:09 am

Boycott Advance has some problems with the stack while switching from interrupt mode to super-visor (if I remembers right). It doesn't use the user-mode's stack and that messes things quite a lot up!

I realised this while in an interrupt and trying to call an ordinary method. I had to switch to super-visor-mode (to be able to switch back again) but it didn't work.

It works fine on VisualBoy Advance and all I have made works just as on the real thing!