Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 14625 - 14654 of 15019   Newest  |  < Newer  |  Older >  |  Oldest
Messages: Show Message Summaries   (Group by Topic) Sort by Date v  
#14654 From: "Thomas" <sorcererxiii@...>
Date: Mon Dec 8, 2003 10:24 pm
Subject: Fixed Point Square Root
SorcererXIII
Offline Offline
Send Email Send Email
 
Can someone give me a good fixed point square root algorithm?  I need
to get the square root of a 22.10 fixed point number.  I am brain
dead when it comes to elementary algebra like this.  Please be kind.

I'd like a general algorithm in C or psuedocode that could be used for
different fraction sizes just be changing a #define value.  I've
searched and found some that worked for specific cases (like on that
was 2.30) but I could figure out how to adapt it for 22.10.

Thanks in advance,
Tom

#14653 From: <dovoto@...>
Date: Mon Dec 1, 2003 6:46 am
Subject: Re: Re: Rotation Backgrounds???
jason_lee_ro...
Offline Offline
Send Email Send Email
 
Hmm..i will look at this...the code is very old..pre gba release I think so
probably not that reliable.
-jason

Jason Rogers
aka Dovoto
www.ThePernProject.com

----- Original Message -----
From: "ismstudios" <lewis@...>
To: <gbadev@yahoogroups.com>
Sent: Sunday, November 30, 2003 6:25 PM
Subject: [gbadev] Re: Rotation Backgrounds???


>
> I tried everything and what worked was the rotation matrix reset values
that you gave
> me. For some reason, it doesn't seem to work with the functions I borrowed
from
> www.thepernproject.com.
>
> Anyway, I set the REG_BG2CNT register to wrap by setting the 13th bit. I
also have the
> background scrolling down so it looks like my sprite is flying over
it--but there is
> annoying strip of 8x8 tiles at the top that do not scroll (when tested on
the
> hardware)... I've also noticed this with dovoto's pacman example but there
is no
> mention of this bug??
>
> Does anyone seem to know anything about this scrolling annoyance?
>
> Thank you.
>
> Lewis
>
>
> --- In gbadev@yahoogroups.com, "Damian Yerrick" <d_yerrick@h...> wrote:
> > --- In gbadev@yahoogroups.com, Lewis Moronta <lewis@g...> wrote:
> > > I'm trying to learn how to use rotation backgrounds--my code only
> > tends to work in modes 0 or 1 with text backgrounds. Can anyone help?
> > I would like to work in mode 2 with backgrounds 2 & 3.
> > >
> > [code snipped]
> >
> > This code doesn't seem to be doing any map data translation.
> >
> > > If i change the background # in the structure to 2 or 3, it won't
> > work.
> >
> > "Won't work" as in a blank screen, or as in a jumbled screen?
> >
> > Things you might want to look for:  1. Tile data in a tiled
> > rotation background must be 256-color.  2. Map data in a tiled
> > rotation background is 8-bit rather than 16-bit and does not allow
> > for vertical or horizontal flipping of tiles.  3. Map data in a
> > tiled rotation background is 8-bit and allows for only 256 tiles
> > in one background, not 1024 as in text backgrounds.  4. Map data
> > in a tiled rotation background is 8-bit; modifying a single tile
> > requires a read-modify-write to a 16-bit pair of map spaces.
> > 5. A program running before yours may have changed a background's
> > rotation matrix.  Here are the defaults that give a 1:1 pixel
> > mapping:
> >
> > pa = 0x100, pb = 0, pc = 0, pd = 0x100, x_origin = 0, y_origin = 0
> >
> > --
> > Damian
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>

#14652 From: "ismstudios" <lewis@...>
Date: Sun Nov 30, 2003 11:25 pm
Subject: Re: Rotation Backgrounds???
ismstudios
Offline Offline
Send Email Send Email
 
I tried everything and what worked was the rotation matrix reset values that you
gave
me. For some reason, it doesn't seem to work with the functions I borrowed from
www.thepernproject.com.

Anyway, I set the REG_BG2CNT register to wrap by setting the 13th bit. I also
have the
background scrolling down so it looks like my sprite is flying over it--but
there is
annoying strip of 8x8 tiles at the top that do not scroll (when tested on the
hardware)... I've also noticed this with dovoto's pacman example but there is no
mention of this bug??

Does anyone seem to know anything about this scrolling annoyance?

Thank you.

Lewis


--- In gbadev@yahoogroups.com, "Damian Yerrick" <d_yerrick@h...> wrote:
> --- In gbadev@yahoogroups.com, Lewis Moronta <lewis@g...> wrote:
> > I'm trying to learn how to use rotation backgrounds--my code only
> tends to work in modes 0 or 1 with text backgrounds. Can anyone help?
> I would like to work in mode 2 with backgrounds 2 & 3.
> >
> [code snipped]
>
> This code doesn't seem to be doing any map data translation.
>
> > If i change the background # in the structure to 2 or 3, it won't
> work.
>
> "Won't work" as in a blank screen, or as in a jumbled screen?
>
> Things you might want to look for:  1. Tile data in a tiled
> rotation background must be 256-color.  2. Map data in a tiled
> rotation background is 8-bit rather than 16-bit and does not allow
> for vertical or horizontal flipping of tiles.  3. Map data in a
> tiled rotation background is 8-bit and allows for only 256 tiles
> in one background, not 1024 as in text backgrounds.  4. Map data
> in a tiled rotation background is 8-bit; modifying a single tile
> requires a read-modify-write to a 16-bit pair of map spaces.
> 5. A program running before yours may have changed a background's
> rotation matrix.  Here are the defaults that give a 1:1 pixel
> mapping:
>
> pa = 0x100, pb = 0, pc = 0, pd = 0x100, x_origin = 0, y_origin = 0
>
> --
> Damian

#14651 From: "Damian Yerrick" <d_yerrick@...>
Date: Sun Nov 30, 2003 6:31 pm
Subject: Re: Rotation Backgrounds???
yerricde
Offline Offline
Send Email Send Email
 
--- In gbadev@yahoogroups.com, Lewis Moronta <lewis@g...> wrote:
> I'm trying to learn how to use rotation backgrounds--my code only
tends to work in modes 0 or 1 with text backgrounds. Can anyone help?
I would like to work in mode 2 with backgrounds 2 & 3.
>
[code snipped]

This code doesn't seem to be doing any map data translation.

> If i change the background # in the structure to 2 or 3, it won't
work.

"Won't work" as in a blank screen, or as in a jumbled screen?

Things you might want to look for:  1. Tile data in a tiled
rotation background must be 256-color.  2. Map data in a tiled
rotation background is 8-bit rather than 16-bit and does not allow
for vertical or horizontal flipping of tiles.  3. Map data in a
tiled rotation background is 8-bit and allows for only 256 tiles
in one background, not 1024 as in text backgrounds.  4. Map data
in a tiled rotation background is 8-bit; modifying a single tile
requires a read-modify-write to a 16-bit pair of map spaces.
5. A program running before yours may have changed a background's
rotation matrix.  Here are the defaults that give a 1:1 pixel
mapping:

pa = 0x100, pb = 0, pc = 0, pd = 0x100, x_origin = 0, y_origin = 0

--
Damian

#14650 From: Lewis Moronta <lewis@...>
Date: Sun Nov 30, 2003 2:11 pm
Subject: Rotation Backgrounds???
ismstudios
Offline Offline
Send Email Send Email
 
Hi,

I'm trying to learn how to use rotation backgrounds--my code only tends to work
in modes 0 or 1 with text backgrounds. Can anyone help? I would like to work in
mode 2 with backgrounds 2 & 3.

Here's the code that I'm trying to modify but it won't work for Rot/Scale
BG's--only for text BG's (as it's currently written).

	 setMode(MODE_1 | OBJ_ENABLE | OBJ_MAP_1D);

	 bground.number = 1;
	 bground.charBaseBlock = 0;
	 bground.screenBaseBlock = 31;
	 bground.colorMode = BG_COLOR_256;
	 bground.size = TEXTBG_SIZE_256x256;
	 bground.mosiac = 0;
	 bground.x_scroll = 0;
	 bground.y_scroll = 0;

	 EnableBackground(&bground);

	 for (index = 0; index < 256; index++)
		 BGPaletteMem[index] = tilesPalette[index];

	 for (index = 0; index < tiles_WIDTH*tiles_HEIGHT/2; index++) // tile width *
height /2
		 bground.tileData[index] = tilesData[index];

	 temp = (u16*)(test);
	 for (index = 0; index < 32*32/2; index++)
		 bground.mapData[index] = test[index];

If i change the background # in the structure to 2 or 3, it won't work. Not even
after updating the video mode or size parameter (which is 0 for a 256x256
Rot/Scale bg)...

Any help is appreciated. Thank you.

-Lewis
www.ismstudios.com

_____________________________________________________________
Get email for your site ---> http://www.everyone.net

#14649 From: "miked0801" <katy.mike@...>
Date: Sat Nov 29, 2003 6:17 pm
Subject: Re: Fixed Point Arithmetic Vector Library
miked0801
Offline Offline
Send Email Send Email
 
Most of the time, I get away with just using the old trick of using
edistance for values - that is largest plus 3/8s of smallest for 2D
vectors and a similiar trick for larger - though the truth is,
getting the square of the value is faster than this.

Divides can be done in roughly 10-100 cycles depending on signifigant
digits.  Jeff Frowhein's page has a sample of that - though for our
3D work, we just use a very large (100K or so) reciprical table in
ROM.

These gave us good results in the 8-bit bitmap mode (can't remember
if that's mode 3 or 4)

Mike

#14648 From: James Daniels <james.daniels@...>
Date: Fri Nov 28, 2003 3:05 pm
Subject: Re: Fixed Point Arithmetic Vector Library
j_r_daniels
Offline Offline
Send Email Send Email
 
Hi Pete,

> This is how I thought
> about doing it originally, but obviously the sqrt() function in
> length,

This is fastest integer sqrt() function I'm aware of:

isqrt:

	 MOV r1,#(3 << 30)
	 MOV r2,#(1 << 30)

	 CMP r0,r2
	 SUBHS r0,r0,r2
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 1)
	 SUBHS r0,r0,r2,ROR #(2 * 1)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 2)
	 SUBHS r0,r0,r2,ROR #(2 * 2)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 3)
	 SUBHS r0,r0,r2,ROR #(2 * 3)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 4)
	 SUBHS r0,r0,r2,ROR #(2 * 4)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 5)
	 SUBHS r0,r0,r2,ROR #(2 * 5)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 6)
	 SUBHS r0,r0,r2,ROR #(2 * 6)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 7)
	 SUBHS r0,r0,r2,ROR #(2 * 7)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 8)
	 SUBHS r0,r0,r2,ROR #(2 * 8)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 9)
	 SUBHS r0,r0,r2,ROR #(2 * 9)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 10)
	 SUBHS r0,r0,r2,ROR #(2 * 10)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 11)
	 SUBHS r0,r0,r2,ROR #(2 * 11)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 12)
	 SUBHS r0,r0,r2,ROR #(2 * 12)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 13)
	 SUBHS r0,r0,r2,ROR #(2 * 13)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 14)
	 SUBHS r0,r0,r2,ROR #(2 * 14)
	 ADC r2,r1,r2,LSL #1

	 CMP r0,r2,ROR #(2 * 15)
	 SUBHS r0,r0,r2,ROR #(2 * 15)
	 ADC r2,r1,r2,LSL #1

	 BIC   r0,r2,#(3 << 30)

	 BX    LR

I think it's ~52 cycles per call.

> and the divide in normalise() would be too costly to be of
> any real use:

You could try using a look up table to store the reciprocal, although
this might not be accurate enough. However, you can probably avoid
normalising vectors in your main loop by precalculating them and then
just rotating them as necessary.
--
Cheers,
James.

James Daniels, Apex Designs
http://www.apex-designs.net

#14647 From: Pete <dooby@...>
Date: Fri Nov 28, 2003 10:48 am
Subject: Re: Fixed Point Arithmetic Vector Library
dooby@...
Send Email Send Email
 
On Fri, 28 Nov 2003, Pete Gunter wrote:

> I'm trying to write two classes Vector3 and Vector2, which store their
> components as 8bit fixed point values, to be used in a 3D library. Now
> I'm trying to write a methods to return the length of the vector, and
> normalise it to a unit vector. This is how I thought about doing it
> originally, but obviously the sqrt() function in length, and the
> divide in normalise() would be too costly to be of any real use:
>
> inline CVector2 &normalise(void)
> {
>  FIXED m = length();
>
>  if (m > 0.0f)
>   m = 1.0f / m;
>  else    //prevent division by zero
>   m = 0.0f;
>
>  m_fV[X] = (m_fV[X] * m) >> 8;
>  m_fV[Y] = (m_fV[Y] * m) >> 8;
>
>  return *this;
> }
>
> inline FIXED length() const
> {
>  return (float) sqrt(m_v[X]*m_v[X] + m_v[Y]*m_v[Y])>>8;
> }
>
> What's the most efficient way to perform these operations?

I've got sqrt functions which execute in 52 cycles worst case, or 70
cycles worst case.

My gba_div routine isn't that fast though, so to get around this in a
Gouraud shader I'm playing with I just kept the vertex normals in an
already normalised form and rotated them along with the vertex
coordinates.

Maybe this approach would work for you too?

Cheers, Pete
--
http://www.bits.bris.ac.uk/dooby/

#14646 From: "Pete Gunter" <reno@...>
Date: Fri Nov 28, 2003 1:50 am
Subject: Fixed Point Arithmetic Vector Library
gunterpete
Offline Offline
Send Email Send Email
 
Hi all,

I'm trying to write two classes Vector3 and Vector2, which store their
components as 8bit fixed point values, to be used in a 3D library. Now I'm
trying to write a methods to return the length of the vector, and normalise it
to a unit vector. This is how I thought about doing it originally, but obviously
the sqrt() function in length, and the divide in normalise() would be too costly
to be of any real use:

inline CVector2 &normalise(void)
{
  FIXED m = length();

  if (m > 0.0f)
   m = 1.0f / m;
  else    //prevent division by zero
   m = 0.0f;

  m_fV[X] = (m_fV[X] * m) >> 8;
  m_fV[Y] = (m_fV[Y] * m) >> 8;

  return *this;
}

inline FIXED length() const
{
  return (float) sqrt(m_v[X]*m_v[X] + m_v[Y]*m_v[Y])>>8;
}

What's the most efficient way to perform these operations?

Kind regards,
-Pete Gunter

#14645 From: David Welch <gba@...>
Date: Wed Nov 26, 2003 8:30 am
Subject: Re: one down one to go
dwelchgba
Offline Offline
Send Email Send Email
 
I finally got around to updating the dhrystone numbers now that gcc will
build with -mthumb -O3.

http://www.dwelch.com/gba/dhry.htm

The gcc 3.4 (snapshot) numbers are pretty damn good.  13 percent faster
than 3.3.2 (With gcse.c patched, see the first bug below)

David




On Sat, 2003-11-08 at 20:50, David Welch wrote:
> Cool, someone fixed the dhrystone bug in gcc...well...actually I have
> not run the compiled code it just doesnt hit an abort() in gcse.c
> anymore.
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10467
>
> So I posted another:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12976
>
> David
>
>
>
>
>
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>

#14644 From: Julian Squires <tek@...>
Date: Mon Nov 24, 2003 1:01 pm
Subject: Re: clock() not working???
erovonket
Offline Offline
Send Email Send Email
 
On Sat, Nov 22, 2003 at 04:46:26AM -0800, Lewis Moronta wrote:
> By the way, the game compiles great--could it be that Visualboy
> doesn't support the clock function? And if it doesn't, what do these
> other professional games use? I'm baffled.

In the console world, one typically uses the vertical blank to sync to a
framerate, rather than any clock functions.  There are a variety of ways
to do this, but for many games it is sufficient to simply have the main
loop driven by the vblank interrupt.

HTH.

--
Julian Squires

#14643 From: Dave Mejia <j_dave_mejia@...>
Date: Sun Nov 23, 2003 5:02 pm
Subject: Re: clock() not working???
j_dave_mejia
Offline Offline
Send Email Send Email
 
My last message contained a faux-pas, so I'm setting
the record straight.


--- Dave Mejia <j_dave_mejia@...> wrote:
> Hi Lewis,
>
> A common method for controlling frame rates on the
> GBA
> is by setting up and using a global time counter
> variable (32 bit unsigned integer).
> ...
> For example you wanted to maintain a 60fps rate:
>
> 1. Copy the global_time to a start_time variable
> 2. Execute the main loop
> 3. Compare the global_time value to start_time + 60
>    continue step 3 until global_time >= start_time +
> 60, then repeat step 1.
>
> ...

In step 3 you should compare the global_time to
start_time + 1 ( 1 / 60th of a second --
approximatley) not 60 ( just about one second ).

Dave

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

#14642 From: "opcodevoid2000" <vbmew@...>
Date: Sun Nov 23, 2003 4:48 pm
Subject: Can I use Game Shark Cable instead of MultiBoot ?
opcodevoid2000
Offline Offline
Send Email Send Email
 
I bought A game Shark for GBC, but it came with a cable that allowed
me to connect it to my computor though a serial/paralle port.

My question is can I use the cable that came with game shark instead
of the cabel that comes with MultiBoot.

I already tried to do it but I'm having problems, I'm wondering
should I give up or keep trying

#14641 From: "Damian Yerrick" <d_yerrick@...>
Date: Sun Nov 23, 2003 1:33 pm
Subject: Re: Transparent color index?
yerricde
Offline Offline
Send Email Send Email
 
--- In gbadev@yahoogroups.com, Lewis Moronta <lewis@g...> wrote:
> I thought I read somewhere that the GPU was supposed to not draw the
color black and cut out sprites that used this color as a backdrop color.

You don't need to crosspost between forum.gbadev.org and the Y! Group.

The NES PPU, the Super NES PPU, the Game Boy PPU, and the GBA PPU
treat pixels of color 0 as transparent, irrespective of whether
the palette says they're black, white, purple, or what have you.

--
Damian

#14640 From: Lewis Moronta <lewis@...>
Date: Sun Nov 23, 2003 8:59 am
Subject: Transparent color index?
ismstudios
Offline Offline
Send Email Send Email
 
I'm working in mode 4 and I finally got two sprites to interact on stage. I have
one problem though--the black bounding boxes that I drew them in shows when the
objects overlap.

I thought I read somewhere that the GPU was supposed to not draw the color black
and cut out sprites that used this color as a backdrop color.

Can anyone help?

#14639 From: Dave Mejia <j_dave_mejia@...>
Date: Sun Nov 23, 2003 12:22 am
Subject: Re: clock() not working???
j_dave_mejia
Offline Offline
Send Email Send Email
 
Hi Lewis,

A common method for controlling frame rates on the GBA
is by setting up and using a global time counter
variable (32 bit unsigned integer). Increment this
variable each time the VCOUNT interrupt is
encountered. This interrupt occurs (approximately) 60
times per second.

For example you wanted to maintain a 60fps rate:

1. Copy the global_time to a start_time variable
2. Execute the main loop
3. Compare the global_time value to start_time + 60
    continue step 3 until global_time >= start_time +
60, then repeat step 1.

You could use timer interrupts but that would not be
the best use of the hardware IMHO.

Hope this helps.
Dave









--- Lewis Moronta <lewis@...> wrote:
> Hello,
>
> I'm currently using gcc as my compiler for GBA dev.
> I'm currently
> trying to write a delay, or sleep function to slow
> down and maintain
> my frames and frame-rate. It doesn't seem to be
> working...
>
> I've tested similar code in a win32 window and it
> works great...
>
> By the way, the game compiles great--could it be
> that Visualboy
> doesn't support the clock function? And if it
> doesn't, what do these
> other professional games use? I'm baffled.
>
> Any comments are appreciated. Thank you. And please
> let
> me know if there are any other ticking functions
> that I can use.
>
> Lewis Moronta
> Interactive Designer
> www.ismstudios.com
> www.m80produxions.com
>
>
_____________________________________________________________
> Get email for your site ---> http://www.everyone.net
>
>

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

#14638 From: Lewis Moronta <lewis@...>
Date: Sat Nov 22, 2003 12:46 pm
Subject: clock() not working???
ismstudios
Offline Offline
Send Email Send Email
 
Hello,

I'm currently using gcc as my compiler for GBA dev. I'm currently
trying to write a delay, or sleep function to slow down and maintain
my frames and frame-rate. It doesn't seem to be working...

I've tested similar code in a win32 window and it works great...

By the way, the game compiles great--could it be that Visualboy
doesn't support the clock function? And if it doesn't, what do these
other professional games use? I'm baffled.

Any comments are appreciated. Thank you. And please let
me know if there are any other ticking functions that I can use.

Lewis Moronta
Interactive Designer
www.ismstudios.com
www.m80produxions.com

_____________________________________________________________
Get email for your site ---> http://www.everyone.net

#14637 From: Lewis Moronta <lewis@...>
Date: Sat Nov 22, 2003 5:55 am
Subject: Publishers and Distributers
ismstudios
Offline Offline
Send Email Send Email
 
Hello,

I'm new in the Gameboy Dev scene and I just wanted to know if you guys
know of any small publishers that tend to pick up indie developers for
royaltee contracts?

I'm look'n and willing to invest my first game just to get some
recognition and some GBA stuff on my resume. Any advice?

-Lewis Moronta
Interactive Designer
www.ismstudios.com
www.m80produxions.com

#14636 From: "Damian Yerrick" <d_yerrick@...>
Date: Wed Nov 19, 2003 2:46 am
Subject: Re: Using Interrupts
yerricde
Offline Offline
Send Email Send Email
 
--- In gbadev@yahoogroups.com, "Pete Gunter" <reno@t...> wrote:
> All the .o files are being created apart from the
> isr.text.iwram.o one. I've tried it with and without the
> .text with the same results. I know I'm probably doing
> something really silly

Summary:  Where did you put the command to compile the ISR?

Your make.bat script looks like this:

8< 8< 8< begin 8< 8< 8<
path=C:\devkitadv\bin

g++  -c -O3 -marm -mthumb-interwork main.c
g++  -c -O3 -marm -mthumb-interwork map.c
g++  -c -O3 -marm -mthumb-interwork dma.c
g++ -marm -mthumb-interwork -o map.elf map.o main.o dma.o

objcopy -O binary map.elf map.gba

pause
8< 8< 8< end 8< 8< 8<

I've noticed that you're compiling the three source code files
in ARM.  Only interrupt handlers and code designed to run from
IWRAM need to be in ARM; the rest will run faster as Thumb.
And when you link, specify -mthumb instead of -marm to bring
in the Thumb compiled version of Newlib, which is faster when
running from 16-bit memory such as ROM or EWRAM.

The funny thing is that nowhere in this make.bat script do I
see a command to compile the ISR.  Consider replacing the g++
lines in the script as follows:

g++  -c -O3 -marm   -mthumb-interwork isr.text.iwram.c
g++  -c -O3 -mthumb -mthumb-interwork main.c
g++  -c -O3 -mthumb -mthumb-interwork map.c
g++  -c -O3 -mthumb -mthumb-interwork dma.c
g++ -mthumb -mthumb-interwork -o map.elf map.o main.o dma.o
isr.text.iwram.o

> I'm using the Devkit advance r4 files to compile. Should I be
> using the r5 ones?

DevKit Advance R5b3's GCC has a much better code optimizer,
and its linker script has much more predictable ways to put
code and data where you want them.  If you're on Windows,
UPGRADE NOW ABSOLUTELY FREE!!!1!1 ;)

--
Damian

#14635 From: "Pete Gunter" <reno@...>
Date: Tue Nov 18, 2003 6:12 pm
Subject: Re: Re: Using Interrupts
gunterpete
Offline Offline
Send Email Send Email
 
All the .o files are being created apart from the isr.text.iwram.o one. I've
tried it with and without the .text with the same results. I know I'm probably
doing something really silly, but my understanding of assembly leaves something
to be desired.

I'm using the Devkit advance r4 files to compile. Should I be using the r5 ones?

I've updated the project file on my site:
http://tbhl.theonering.net/petegunter/downloads/Mode7.zip

Regards,
-Pete Gunter
   ----- Original Message -----
   From: Damian Yerrick
   To: gbadev@yahoogroups.com
   Sent: Tuesday, November 18, 2003 3:58 PM
   Subject: [gbadev] Re: Using Interrupts


   --- In gbadev@yahoogroups.com, "Pete Gunter" <reno@t...> wrote:
   > I couldn't seem to compile the interupt code into IWRAM, when I
   compile the project using the following makefile, I get the following
   errors (isr.text.iwram.o isn't being compiled)

   What is the output of "dir *.o"?

   Is "isr.iwram.o" (without the "text") being compiled?  In Devkit
   Advance R5 beta 3 (yes, it is stable enough for windows users),
   the "text" in the object file's name shouldn't matter.

   --
   Damian



         Yahoo! Groups Sponsor
               ADVERTISEMENT




   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

#14634 From: "Damian Yerrick" <d_yerrick@...>
Date: Tue Nov 18, 2003 3:58 pm
Subject: Re: Using Interrupts
yerricde
Offline Offline
Send Email Send Email
 
--- In gbadev@yahoogroups.com, "Pete Gunter" <reno@t...> wrote:
> I couldn't seem to compile the interupt code into IWRAM, when I
compile the project using the following makefile, I get the following
errors (isr.text.iwram.o isn't being compiled)

What is the output of "dir *.o"?

Is "isr.iwram.o" (without the "text") being compiled?  In Devkit
Advance R5 beta 3 (yes, it is stable enough for windows users),
the "text" in the object file's name shouldn't matter.

--
Damian

#14633 From: "Pete Gunter" <reno@...>
Date: Tue Nov 18, 2003 1:45 pm
Subject: Re: Re: Using Interrupts
gunterpete
Offline Offline
Send Email Send Email
 
Thanks you guys,

I had indeed got the bits wrong for HBlank and VBlank (doh!) and when I compiled
it using Arm instructions it works fine.

I couldn't seem to compile the interupt code into IWRAM, when I compile the
project using the following makefile, I get the following errors
(isr.text.iwram.o isn't being compiled):

CFLAGS = -c -O3
MODEL = -marm -mthumb-interwork
all : Mode7.bin

Mode7.bin : Mode7.elf
  objcopy -O binary Mode7.elf Mode7.bin

Mode7.elf : main.o
  g++ $(MODEL) -o Mode7.elf main.o map.o dma.o isr.text.iwram.o

main.o : main.c
  g++ $(CFLAGS) $(MODEL) main.c

map.o : map.cpp
  g++ $(CFLAGS) $(MODEL) map.c

dma.o : dma.c
  g++ $(CFLAGS) $(MODEL) dma.c

isr.text.iwram.o : isr.text.iwram.c
  g++ $(CFLAGS) $(MODEL) isr.text.iwram.c


--------------------Configuration: Mode7 - Win32 Debug--------------------
Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
  g++ -marm -mthumb-interwork -o Mode7.elf main.o map.o dma.o isr.text.iwram.o
g++: isr.text.iwram.o: No such file or directory
NMAKE : fatal error U1077: 'g++' : return code '0x1'
Stop.
Error executing nmake.

Mode7.bin - 1 error(s), 0 warning(s)

However I won't worry too much about this untill performance becomes an issue.

Thanks again for all your help,
-Pete Gunter
   ----- Original Message -----
   From: Damian Yerrick
   To: gbadev@yahoogroups.com
   Sent: Tuesday, November 18, 2003 3:09 AM
   Subject: [gbadev] Re: Using Interrupts


   Would you give your right ARM for a solution?

   --- In gbadev@yahoogroups.com, "Pete Gunter" <reno@t...> wrote:
   > Thanks so much for your help, I've incorporated the thumb code
   > for the SWI from vboy.emuhq.com and it works nicely. Using
   > it and your new interupt handler I've determined that the
   > interuptHandler() function is never entered, however as far
   > as I can see (and I've been staring blankly at it all
   > evening :P) the interupts are set up correctly.

   Let me see what I can do:

   > /*
   > //*** Lookup tables
   > FIXED SIN[360]; //Lookup tables for SIN and COS
   > FIXED COS[360];
   > FIXED div[160]; //Lookup tables  for divides
   > */

   Some suggestions here:
   1. It's much faster to use 256 degrees than 360 degrees.
   2. It saves memory to maintain a COS table, and then compute
      SIN in terms of COS.
   3. It's best to precompute LUTs in a PC-side program, so that the
      tables go in ROM as opposed to precious RAM and so that init
      goes faster.  Look in TOD's source code for tools/writecos.c
      to see an example of a precompute program.

   > int main(void)
   > {
   >  int x;
   >
   >  //Initialise the map data
   >  init();
   >
   >  //Main loop
   >  while(1)
   >  {
   >   update();
   >  }//end while
   > }

   Is update() getting called continuously?  If your ISR hangs,
   or BIOS hangs while trying to call your ISR, update() will
   stop getting called after a frame or two.

   > void init(void)
   > {
   [...]
   >
   >  /* Enable Interupts */
   >  REG_IME = 0;        //Disable interupts
   >  REG_INTERUPT = (u32)interupt;    //Point the interupt handler
   register to the function
   >  REG_DISPSTAT |= (DST_ENABLE_HBLANK);   //Enable HBLANK in
   REG_DISPSTAT
   >  REG_IE |= INT_HBLANK;      //Enable HBLANK in REG_IE
   >  REG_IME = 1;        //Enable interupts
   [...]
   >}

   Everything looks OK to me.  Is your GBA header file correct?

   I downloaded your project, and it turns out your make script
   may be the culprit:

   > g++  -c -O3 -mthumb -mthumb-interwork main.c

   Yyour ISR MUST be compiled in ARM (not Thumb) instructions.
   Your ISR SHOULD be located in IWRAM.  I'd suggest putting
   the ISR into a separate module, called "isr.iwram.c", and
   compiling it like this:

     g++  -c -O3 -marm   -mthumb-interwork isr.iwram.c

   > By strange cooincidence I was looking at your site as your
   > email arrived. Your sound compressor and TOD are awesome.

   Thanks a lot!

   --
   Damian



         Yahoo! Groups Sponsor
               ADVERTISEMENT




   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

#14632 From: "Damian Yerrick" <d_yerrick@...>
Date: Tue Nov 18, 2003 3:09 am
Subject: Re: Using Interrupts
yerricde
Offline Offline
Send Email Send Email
 
Would you give your right ARM for a solution?

--- In gbadev@yahoogroups.com, "Pete Gunter" <reno@t...> wrote:
> Thanks so much for your help, I've incorporated the thumb code
> for the SWI from vboy.emuhq.com and it works nicely. Using
> it and your new interupt handler I've determined that the
> interuptHandler() function is never entered, however as far
> as I can see (and I've been staring blankly at it all
> evening :P) the interupts are set up correctly.

Let me see what I can do:

> /*
> //*** Lookup tables
> FIXED SIN[360]; //Lookup tables for SIN and COS
> FIXED COS[360];
> FIXED div[160]; //Lookup tables  for divides
> */

Some suggestions here:
1. It's much faster to use 256 degrees than 360 degrees.
2. It saves memory to maintain a COS table, and then compute
    SIN in terms of COS.
3. It's best to precompute LUTs in a PC-side program, so that the
    tables go in ROM as opposed to precious RAM and so that init
    goes faster.  Look in TOD's source code for tools/writecos.c
    to see an example of a precompute program.

> int main(void)
> {
>  int x;
>
>  //Initialise the map data
>  init();
>
>  //Main loop
>  while(1)
>  {
>   update();
>  }//end while
> }

Is update() getting called continuously?  If your ISR hangs,
or BIOS hangs while trying to call your ISR, update() will
stop getting called after a frame or two.

> void init(void)
> {
[...]
>
>  /* Enable Interupts */
>  REG_IME = 0;        //Disable interupts
>  REG_INTERUPT = (u32)interupt;    //Point the interupt handler
register to the function
>  REG_DISPSTAT |= (DST_ENABLE_HBLANK);   //Enable HBLANK in
REG_DISPSTAT
>  REG_IE |= INT_HBLANK;      //Enable HBLANK in REG_IE
>  REG_IME = 1;        //Enable interupts
[...]
>}

Everything looks OK to me.  Is your GBA header file correct?

I downloaded your project, and it turns out your make script
may be the culprit:

> g++  -c -O3 -mthumb -mthumb-interwork main.c

Yyour ISR MUST be compiled in ARM (not Thumb) instructions.
Your ISR SHOULD be located in IWRAM.  I'd suggest putting
the ISR into a separate module, called "isr.iwram.c", and
compiling it like this:

   g++  -c -O3 -marm   -mthumb-interwork isr.iwram.c

> By strange cooincidence I was looking at your site as your
> email arrived. Your sound compressor and TOD are awesome.

Thanks a lot!

--
Damian

#14631 From: "Graham Wall" <graham@...>
Date: Tue Nov 18, 2003 2:59 am
Subject: RE: Re: Using Interrupts
prizeonion
Offline Offline
Send Email Send Email
 
I believe your problem lies in the DST_ENABLE_HBLANK and DST_ENABLE_VBLANK
definitions. I thinks yours are the wrong way around. I've been using:

#define DST_ENABLE_VBLANK 0x0008
#define DST_ENABLE_HBLANK 0x0010

Graham

-----Original Message-----
From: Pete Gunter [mailto:reno@...]
Sent: 18 November 2003 02:27
To: gbadev@yahoogroups.com
Subject: Re: [gbadev] Re: Using Interrupts


Thanks so much for your help, I've incorporated the thumb code for the SWI
from vboy.emuhq.com and it works
nicely. Using it and your new interupt handler I've determined that the
interuptHandler() function is never entered,
however as far as I can see (and I've been staring blankly at it all evening
:P) the interupts are set up correctly.

I've uploaded the complete project to
http://tbhl.theonering.net/petegunter/downloads/Mode7.zip, and the latest
code in the main file is pasted below. If anyone's prepared to have a look
at it for me I'd be very gratefull. My sleep
deprived brain just can't handle any more!

Regards,
-Pete Gunter

By strange cooincidence I was looking at your site as your email arrived.
Your sound compressor and TOD are awesome.



// display.c : sample program to display pcx, and get key input

#include <math.h>

#include "gba.h"
#include "map.h" //Map data


//FUNCTION PROTOTYPES
void init(void);
void update(void);
void interupt(void);
void print(char *s);

//GLOBALS
/*
//*** Lookup tables
FIXED SIN[360]; //Lookup tables for SIN and COS
FIXED COS[360];
FIXED div[160]; //Lookup tables  for divides
*/
int x;

int main(void)
{
int x;

//Initialise the map data
init();

//Main loop
while(1)
{
   update();
}//end while
}

void init(void)
{
//print("Entered Initialisation function\n");

/* Lookup Table Initialisation */
/* int loop;
// sine cos LUT
for(loop = 0; loop < 360; loop++)
{
   SIN[loop] = (FIXED)(sin(RADIAN(loop)) * (float)(1<<16));  //sin and cos
are computed and cast to fixed       //fixed
   COS[loop] = (FIXED)(cos(RADIAN(loop)) * (float)(1<<16));
}

//calculate my divide look up table so I can use the property x/y = x*(1/y)
= x*div[y]
for(loop=0;loop <160;loop++)
{
   //our fixed point divide table is 8.24 (24 bits of fraction)
   div[loop] = (FIXED)( (float)( (1<<16)/loop) );
}

*/

/* Enable Interupts */
REG_IME = 0;        //Disable interupts
REG_INTERUPT = (u32)interupt;    //Point the interupt handler register to
the function
REG_DISPSTAT |= (DST_ENABLE_HBLANK);   //Enable HBLANK in REG_DISPSTAT
REG_IE |= INT_HBLANK;      //Enable HBLANK in REG_IE
REG_IME = 1;        //Enable interupts

/* Screen Initialisation */
int x=0,y=0; //just some looping vars
//this is a temparary pointer that we will point to the last screen memory
block(31)
u16* bg2map =(u16*)ScreenBaseBlock(31);
//bg0map now points to were we are going to put our map data

//now we set up background 0 to be a 256 x 256 256 color background and make
sure it
//it looks in the right place for its map data
REG_BG2CNT = BG_COLOR256 | ROTBG_SIZE_256x256 | (31 << SCREEN_SHIFT) |
WRAPAROUND;

//good old set mode function. here we just set it to mode 0 and enable
background 0
SetMode(MODE_2 | BG2_ENABLE);

/* Map data Initialisation */
//now we use our DMA copy routine to copy in the palette
DMA_Copy(3,(void*)mapMap.pal,(void*)BGPaletteMem,128,DMA_32NOW);

//now we copy in the tile data
DMA_Copy(3,(void*)mapMap.tiledata,(void*)CharBaseBlock(0),mapMap.tileDataSiz
e/4,DMA_32NOW);

//now we copy in the map. this could be done with dma as well but this is a
bit more flexible
for(y = 0; y < 32; y++) //loop through all 32x32 tiles
{
   for(x = 0; x < 16; x++)
   {
    //this is where the data from our map editor is copied to video memory
    //First tile in 16bit address (Hiword)
    bg2map[x + y * 16] =  (u16)((u8)mapMap.layers[0].data[(x*2) + y *
mapMap.layers[0].w]);
    //Next tile in 16bit address (Loword)
    bg2map[x + y * 16] += (u16)((u8)mapMap.layers[0].data[(x*2)+1 + y *
mapMap.layers[0].w]<<8);

   }
}



}

void update(void)
{
while(!(REG_DISPSTAT & DST_VBLANK));//wait for vblank


// REG_BG2X = x<<5;

while((REG_DISPSTAT & DST_VBLANK));//Make sure VBLANK is over so our game
does run faster than 60 frames per second
}

/*void interupt(void)
{
REG_IME = 0; // Disable interrupts

   REG_BG2PA = 300;

if(REG_IF & INT_HBLANK)
{



   REG_IF |= INT_HBLANK;
}

REG_IME = 1;       // Re-Enable interrups
}*/

/* Alternative interupt handler, provided by Damian Yerrick
<d_yerrick@...> */
void interupt(void)
{
//print("Entered interupt function\n");

/* make a local copy of the interrupts that happened */
u16 reg_if = REG_IF;

/* disable interrupts */
REG_IME = 0;

/* handle each interrupt */
if(reg_if & INT_HBLANK)
{
//print("Entered hblank routine\n");

    /* play with the palette to prove that it gets called */
    BGPaletteMem[0] = REG_VCOUNT;
    REG_IF |= INT_HBLANK;
    REG_BG2X = REG_VCOUNT << 8;
}
/* likewise for other interrupts */

/* acknowledge to BIOS, for IntrWait() */
*(volatile unsigned short *)0x03fffff8 |= reg_if;

/* acknowledge to hardware */
REG_IF = reg_if;

/* reenable interrupts */
REG_IME = 1;
}

// Print VBA debug line - From FAQ at http://vboy.emuhq.com
void print(char *s)
{
asm volatile("mov r0, %0;"
   "swi 0xff;"
   : // no ouput
   : "r" (s)
   : "r0");
}

   ----- Original Message -----
   From: Damian Yerrick
   To: gbadev@yahoogroups.com
   Sent: Tuesday, November 18, 2003 1:17 AM
   Subject: [gbadev] Re: Using Interrupts


   --- In gbadev@yahoogroups.com, "Pete Gunter" <reno@t...> wrote:
   > Hi all,
   >
   > Kinda hoping someone might be able to help me with interupts.
   > I'm trying to use the HBlank interrupt, and will eventually
   > attempt to use it for Mode 7 graphics. For now I'm just trying
   > to offset background 2 x value by the value of REG_VCOUNT
   > (Which I think should skew the image). However, when I run
   > the rom, the map is just displayed as normal.

   Remember, you have to enable the interrupt in two places: at the
   source (REG_DISPSTAT) and at the mask (REG_IE).  I notice that you
   are in fact doing this.

   > Also, in VisualBoy Advance I've noticed the option AGBPrint in
   > the Logging tool. Is there a way of printing debug lines ot this?

   In VBA, you can print a NUL-terminated string using a special SWI.
   http://vboy.emuhq.com/faq.shtml#cat12_5
   However, this will crash on real hardware.  In Mappy VM, you can
   print a NUL-terminated string using a sequence that acts like a
   big fat NOP on real hardware but prints on the emulator; VBA
   supports this as well.
   http://www.bottledlight.com/docs/sdk.html

   > For example I'd like to write a print statement in the Hblank
   > interrupt to see if it's even being entered.

   What I like to do when testing code-coverage (i.e. see what parts
   are being entered and what aren't) is play with the palette.

   > void interuptHandler(void)

   Your ISR will fail to do anything when more than one interrupt
   happens at once.  Here's a simpler, more robust boilerplate
   interrupt handler, based on the one I used in Tetanus On Drugs:

   void interuptHandler(void)
   {
   /* make a local copy of the interrupts that happened */
   int reg_if = REG_IF;

   /* disable interrupts */
   REG_IME = 0;

   /* handle each interrupt */
   if(reg_if & INT_HBLANK)
   {
     /* play with the palette to prove that it gets called */
     PALRAM[0] = REG_VCOUNT;
     REG_IF |= INT_HBLANK;
     REG_BG2X = REG_VCOUNT << 8;
   }
   /* likewise for other interrupts */

   /* acknowledge to BIOS, for IntrWait() */
   *(volatile unsigned short *)0x03fffff8 |= reg_if;
   /* acknowledge to hardware */
   REG_IF = reg_if;
   /* reenable interrupts */
   REG_IME = 1;
   }

   --
   Damian



         Yahoo! Groups Sponsor
               ADVERTISEMENT




   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



Yahoo! Groups Sponsor
ADVERTISEMENT




Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

#14630 From: "Pete Gunter" <reno@...>
Date: Tue Nov 18, 2003 2:27 am
Subject: Re: Re: Using Interrupts
gunterpete
Offline Offline
Send Email Send Email
 
Thanks so much for your help, I've incorporated the thumb code for the SWI from
vboy.emuhq.com and it works
nicely. Using it and your new interupt handler I've determined that the
interuptHandler() function is never entered,
however as far as I can see (and I've been staring blankly at it all evening :P)
the interupts are set up correctly.

I've uploaded the complete project to
http://tbhl.theonering.net/petegunter/downloads/Mode7.zip, and the latest
code in the main file is pasted below. If anyone's prepared to have a look at it
for me I'd be very gratefull. My sleep
deprived brain just can't handle any more!

Regards,
-Pete Gunter

By strange cooincidence I was looking at your site as your email arrived. Your
sound compressor and TOD are awesome.



// display.c : sample program to display pcx, and get key input

#include <math.h>

#include "gba.h"
#include "map.h" //Map data


//FUNCTION PROTOTYPES
void init(void);
void update(void);
void interupt(void);
void print(char *s);

//GLOBALS
/*
//*** Lookup tables
FIXED SIN[360]; //Lookup tables for SIN and COS
FIXED COS[360];
FIXED div[160]; //Lookup tables  for divides
*/
int x;

int main(void)
{
  int x;

  //Initialise the map data
  init();

  //Main loop
  while(1)
  {
   update();
  }//end while
}

void init(void)
{
//print("Entered Initialisation function\n");

  /* Lookup Table Initialisation */
/* int loop;
  // sine cos LUT
  for(loop = 0; loop < 360; loop++)
  {
   SIN[loop] = (FIXED)(sin(RADIAN(loop)) * (float)(1<<16));  //sin and cos are
computed and cast to fixed       //fixed
   COS[loop] = (FIXED)(cos(RADIAN(loop)) * (float)(1<<16));
  }

  //calculate my divide look up table so I can use the property x/y = x*(1/y) =
x*div[y]
  for(loop=0;loop <160;loop++)
  {
   //our fixed point divide table is 8.24 (24 bits of fraction)
   div[loop] = (FIXED)( (float)( (1<<16)/loop) );
  }

*/

  /* Enable Interupts */
  REG_IME = 0;        //Disable interupts
  REG_INTERUPT = (u32)interupt;    //Point the interupt handler register to the
function
  REG_DISPSTAT |= (DST_ENABLE_HBLANK);   //Enable HBLANK in REG_DISPSTAT
  REG_IE |= INT_HBLANK;      //Enable HBLANK in REG_IE
  REG_IME = 1;        //Enable interupts

  /* Screen Initialisation */
  int x=0,y=0; //just some looping vars
  //this is a temparary pointer that we will point to the last screen memory
block(31)
  u16* bg2map =(u16*)ScreenBaseBlock(31);
  //bg0map now points to were we are going to put our map data

  //now we set up background 0 to be a 256 x 256 256 color background and make
sure it
  //it looks in the right place for its map data
  REG_BG2CNT = BG_COLOR256 | ROTBG_SIZE_256x256 | (31 << SCREEN_SHIFT) |
WRAPAROUND;

  //good old set mode function. here we just set it to mode 0 and enable
background 0
  SetMode(MODE_2 | BG2_ENABLE);

  /* Map data Initialisation */
  //now we use our DMA copy routine to copy in the palette
  DMA_Copy(3,(void*)mapMap.pal,(void*)BGPaletteMem,128,DMA_32NOW);

  //now we copy in the tile data
 
DMA_Copy(3,(void*)mapMap.tiledata,(void*)CharBaseBlock(0),mapMap.tileDataSize/4,\
DMA_32NOW);

  //now we copy in the map. this could be done with dma as well but this is a bit
more flexible
  for(y = 0; y < 32; y++) //loop through all 32x32 tiles
  {
   for(x = 0; x < 16; x++)
   {
    //this is where the data from our map editor is copied to video memory
    //First tile in 16bit address (Hiword)
    bg2map[x + y * 16] =  (u16)((u8)mapMap.layers[0].data[(x*2) + y *
mapMap.layers[0].w]);
    //Next tile in 16bit address (Loword)
    bg2map[x + y * 16] += (u16)((u8)mapMap.layers[0].data[(x*2)+1 + y *
mapMap.layers[0].w]<<8);

   }
  }



}

void update(void)
{
  while(!(REG_DISPSTAT & DST_VBLANK));//wait for vblank


// REG_BG2X = x<<5;

  while((REG_DISPSTAT & DST_VBLANK));//Make sure VBLANK is over so our game does
run faster than 60 frames per second
}

/*void interupt(void)
{
  REG_IME = 0; // Disable interrupts

   REG_BG2PA = 300;

  if(REG_IF & INT_HBLANK)
  {



   REG_IF |= INT_HBLANK;
  }

  REG_IME = 1;       // Re-Enable interrups
}*/

/* Alternative interupt handler, provided by Damian Yerrick
<d_yerrick@...> */
void interupt(void)
{
//print("Entered interupt function\n");

  /* make a local copy of the interrupts that happened */
  u16 reg_if = REG_IF;

  /* disable interrupts */
  REG_IME = 0;

  /* handle each interrupt */
  if(reg_if & INT_HBLANK)
  {
//print("Entered hblank routine\n");

    /* play with the palette to prove that it gets called */
    BGPaletteMem[0] = REG_VCOUNT;
    REG_IF |= INT_HBLANK;
    REG_BG2X = REG_VCOUNT << 8;
  }
  /* likewise for other interrupts */

  /* acknowledge to BIOS, for IntrWait() */
  *(volatile unsigned short *)0x03fffff8 |= reg_if;

  /* acknowledge to hardware */
  REG_IF = reg_if;

  /* reenable interrupts */
  REG_IME = 1;
}

// Print VBA debug line - From FAQ at http://vboy.emuhq.com
void print(char *s)
{
  asm volatile("mov r0, %0;"
   "swi 0xff;"
   : // no ouput
   : "r" (s)
   : "r0");
}

   ----- Original Message -----
   From: Damian Yerrick
   To: gbadev@yahoogroups.com
   Sent: Tuesday, November 18, 2003 1:17 AM
   Subject: [gbadev] Re: Using Interrupts


   --- In gbadev@yahoogroups.com, "Pete Gunter" <reno@t...> wrote:
   > Hi all,
   >
   > Kinda hoping someone might be able to help me with interupts.
   > I'm trying to use the HBlank interrupt, and will eventually
   > attempt to use it for Mode 7 graphics. For now I'm just trying
   > to offset background 2 x value by the value of REG_VCOUNT
   > (Which I think should skew the image). However, when I run
   > the rom, the map is just displayed as normal.

   Remember, you have to enable the interrupt in two places: at the
   source (REG_DISPSTAT) and at the mask (REG_IE).  I notice that you
   are in fact doing this.

   > Also, in VisualBoy Advance I've noticed the option AGBPrint in
   > the Logging tool. Is there a way of printing debug lines ot this?

   In VBA, you can print a NUL-terminated string using a special SWI.
   http://vboy.emuhq.com/faq.shtml#cat12_5
   However, this will crash on real hardware.  In Mappy VM, you can
   print a NUL-terminated string using a sequence that acts like a
   big fat NOP on real hardware but prints on the emulator; VBA
   supports this as well.
   http://www.bottledlight.com/docs/sdk.html

   > For example I'd like to write a print statement in the Hblank
   > interrupt to see if it's even being entered.

   What I like to do when testing code-coverage (i.e. see what parts
   are being entered and what aren't) is play with the palette.

   > void interuptHandler(void)

   Your ISR will fail to do anything when more than one interrupt
   happens at once.  Here's a simpler, more robust boilerplate
   interrupt handler, based on the one I used in Tetanus On Drugs:

   void interuptHandler(void)
   {
   /* make a local copy of the interrupts that happened */
   int reg_if = REG_IF;

   /* disable interrupts */
   REG_IME = 0;

   /* handle each interrupt */
   if(reg_if & INT_HBLANK)
   {
     /* play with the palette to prove that it gets called */
     PALRAM[0] = REG_VCOUNT;
     REG_IF |= INT_HBLANK;
     REG_BG2X = REG_VCOUNT << 8;
   }
   /* likewise for other interrupts */

   /* acknowledge to BIOS, for IntrWait() */
   *(volatile unsigned short *)0x03fffff8 |= reg_if;
   /* acknowledge to hardware */
   REG_IF = reg_if;
   /* reenable interrupts */
   REG_IME = 1;
   }

   --
   Damian



         Yahoo! Groups Sponsor
               ADVERTISEMENT




   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

#14629 From: "Damian Yerrick" <d_yerrick@...>
Date: Tue Nov 18, 2003 1:17 am
Subject: Re: Using Interrupts
yerricde
Offline Offline
Send Email Send Email
 
--- In gbadev@yahoogroups.com, "Pete Gunter" <reno@t...> wrote:
> Hi all,
>
> Kinda hoping someone might be able to help me with interupts.
> I'm trying to use the HBlank interrupt, and will eventually
> attempt to use it for Mode 7 graphics. For now I'm just trying
> to offset background 2 x value by the value of REG_VCOUNT
> (Which I think should skew the image). However, when I run
> the rom, the map is just displayed as normal.

Remember, you have to enable the interrupt in two places: at the
source (REG_DISPSTAT) and at the mask (REG_IE).  I notice that you
are in fact doing this.

> Also, in VisualBoy Advance I've noticed the option AGBPrint in
> the Logging tool. Is there a way of printing debug lines ot this?

In VBA, you can print a NUL-terminated string using a special SWI.
http://vboy.emuhq.com/faq.shtml#cat12_5
However, this will crash on real hardware.  In Mappy VM, you can
print a NUL-terminated string using a sequence that acts like a
big fat NOP on real hardware but prints on the emulator; VBA
supports this as well.
http://www.bottledlight.com/docs/sdk.html

> For example I'd like to write a print statement in the Hblank
> interrupt to see if it's even being entered.

What I like to do when testing code-coverage (i.e. see what parts
are being entered and what aren't) is play with the palette.

> void interuptHandler(void)

Your ISR will fail to do anything when more than one interrupt
happens at once.  Here's a simpler, more robust boilerplate
interrupt handler, based on the one I used in Tetanus On Drugs:

void interuptHandler(void)
{
  /* make a local copy of the interrupts that happened */
  int reg_if = REG_IF;

  /* disable interrupts */
  REG_IME = 0;

  /* handle each interrupt */
  if(reg_if & INT_HBLANK)
  {
   /* play with the palette to prove that it gets called */
   PALRAM[0] = REG_VCOUNT;
   REG_IF |= INT_HBLANK;
   REG_BG2X = REG_VCOUNT << 8;
  }
  /* likewise for other interrupts */

  /* acknowledge to BIOS, for IntrWait() */
  *(volatile unsigned short *)0x03fffff8 |= reg_if;
  /* acknowledge to hardware */
  REG_IF = reg_if;
  /* reenable interrupts */
  REG_IME = 1;
}

--
Damian

#14628 From: deathping <deathping@...>
Date: Tue Nov 18, 2003 1:24 am
Subject: Re: Using Interrupts
deathpingg
Offline Offline
Send Email Send Email
 
> void interuptHandler(void)
> {
> REG_IME = 0; // Disable interrupts
>
>
> REG_IME = 1;       // Re-Enable interrups
> }

Correct me if I'm wrong, but I don't think its necessary (wise?) to
disable/enable interupts in your handler.

#14627 From: "Pete Gunter" <reno@...>
Date: Mon Nov 17, 2003 9:04 pm
Subject: Using Interrupts
gunterpete
Offline Offline
Send Email Send Email
 
Hi all,

Kinda hoping someone might be able to help me with interupts. I'm trying to use
the HBlank interrupt, and will eventually attempt to use it for Mode 7 graphics.
For now I'm just trying to offset background 2 x value by the value of
REG_VCOUNT (Which I think should skew the image). However, when I run the rom,
the map is just displayed as normal.

Also, in VisualBoy Advance I've noticed the option AGBPrint in the Logging tool.
Is there a way of printing debug lines ot this? For example I'd like to write a
print statement in the Hblank interrupt to see if it's even being entered.

Here's the code I'm using, thanks in advance for any help:

// display.c : sample program to display pcx, and get key input

#include <math.h>

#include "gba.h"
#include "map.h" //Map data


//FUNCTION PROTOTYPES
void init(void);
void update(void);
void interuptHandler(void);

int main(void)
{
  //Initialise the map data
  init();

  //Main loop
  while(1)
  {
   update();

  }//end while
}

void init(void)
{
  int x=0,y=0; //just some looping vars

  /* Screen Initialisation */
  //this is a temparary pointer that we will point to the last screen memory
block(31)
  u16* bg2map =(u16*)ScreenBaseBlock(31);
  //bg0map now points to were we are going to put our map data

  //now we set up background 0 to be a 256 x 256 256 color background and make
sure it
  //it looks in the right place for its map data
  REG_BG2CNT = BG_COLOR256 | ROTBG_SIZE_256x256 | (31 << SCREEN_SHIFT) |
WRAPAROUND;

  //good old set mode function. here we just set it to mode 0 and enable
background 0
  SetMode(MODE_2 | BG2_ENABLE);


  /* Map data Initialisation */
  //now we use our DMA copy routine to copy in the palette
  DMA_Copy(3,(void*)mapMap.pal,(void*)BGPaletteMem,128,DMA_32NOW);

  //now we copy in the tile data
 
DMA_Copy(3,(void*)mapMap.tiledata,(void*)CharBaseBlock(0),mapMap.tileDataSize/4,\
DMA_32NOW);

  //now we copy in the map. this could be done with dma as well but this is a bit
more flexible
  for(y = 0; y < 32; y++) //loop through all 32x32 tiles
  {
   for(x = 0; x < 16; x++)
   {
    //this is where the data from our map editor is copied to video memory
    //First tile in 16bit address (Hiword)
    bg2map[x + y * 16] =  (u16)((u8)mapMap.layers[0].data[(x*2) + y *
mapMap.layers[0].w]);
    //Next tile in 16bit address (Loword)
    bg2map[x + y * 16] += (u16)((u8)mapMap.layers[0].data[(x*2)+1 + y *
mapMap.layers[0].w]<<8);

   }
  }

  /* Enable Interupts */
  REG_IME = 0;        //Disable interupts
  REG_INTERUPT = (u32)interuptHandler;  //Point the interupt handler register to
the function
  REG_DISPSTAT |= 0x18;      //Enable VBLANK and HBLANK in REG_DISPSTAT (3rd and
4th bits)
  REG_IE = INT_VBLANK | INT_HBLANK;   //Enable VBLANK and HBLANK in REG_IE
  REG_IME = 1;        //Enable interupts
}

void update(void)
{
   while(!(REG_DISPSTAT & 1));//wait for vblank



   while((REG_DISPSTAT & 1));//Make sure VBLANK is over so our game does run
faster than 60 frames per second
}

void interuptHandler(void)
{
  REG_IME = 0; // Disable interrupts

  if(REG_IF == INT_VBLANK)
  {
   REG_IF |= INT_VBLANK;
  }

  if(REG_IF == INT_HBLANK)
  {
   REG_IF |= INT_HBLANK;
   REG_BG2X = REG_VCOUNT << 8;
  }

  if(REG_IF == INT_DMA0)
  {
   REG_IF = INT_DMA0;
  }
  if(REG_IF == INT_DMA1)
  {
   REG_IF = INT_DMA1;
  }
  if(REG_IF == INT_DMA2)
  {
   REG_IF = INT_DMA2;
  }
  if(REG_IF == INT_DMA3)
  {
   REG_IF = INT_DMA3;
  }
  if(REG_IF == INT_VCOUNT)
  {
   REG_IF = INT_VCOUNT;
  }
  if(REG_IF == INT_TIMMER0)
  {
   REG_IF = INT_TIMMER0;
  }
  if(REG_IF == INT_TIMMER1)
  {
   REG_IF = INT_TIMMER1;
  }
  if(REG_IF == INT_TIMMER2)
  {
   REG_IF = INT_TIMMER2;
  }
  if(REG_IF == INT_TIMMER3)
  {
   REG_IF = INT_TIMMER3;
  }
  if(REG_IF == INT_KEYBOARD)
  {
   REG_IF = INT_TIMMER3;
  }
  if(REG_IF == INT_CART)
  {
   REG_IF = INT_CART;
  }
  if(REG_IF == INT_COMUNICATION)
  {
   REG_IF = INT_COMUNICATION;
  }

  REG_IME = 1;       // Re-Enable interrups
}

#14626 From: "Damian Yerrick" <d_yerrick@...>
Date: Mon Nov 17, 2003 8:22 pm
Subject: Re: GBA Accessing GBA Cards
yerricde
Offline Offline
Send Email Send Email
 
--- In gbadev@yahoogroups.com, "vogt31337" <vogt31337@g...> wrote:
> Ok, but how fast data is needed? In the Docmument nothing is
> mentioned about this.

Look in the section of GBATEK that covers "wait states."

> I mean the theoratical maximum amount of data transferred
> between GBA and Card.

Assuming 3/1 wait state (as for official Game Paks), you'll
need 16.8 MBytes per second (two bytes every two cycles),
and under 180 ns (three cycles) to decode the first address
and read the first pair of bytes.

> And what will happen if data is slower than GBA requires is?
> Perhaps GBA will hang.

Probably.

> But what if I force the rd-Line low? Will GBA wait for me??

The GBA boots in 4/2 wait state.  If you can seek in 240 ns and
transfer 11 MBytes per second, you can run at 4/2 wait state.

--
Damian

#14625 From: "Damian Yerrick" <d_yerrick@...>
Date: Mon Nov 17, 2003 8:06 pm
Subject: Re: Advice: GBA Startup
yerricde
Offline Offline
Send Email Send Email
 
--- In gbadev@yahoogroups.com, "gbwgp" <GBWGP@a...> wrote:
> is it required that my company be using an official dev kit
> or can we go with GCC?

I've read that Nintendo doesn't care about your source code or
what compiler you use, only that 1. your binary doesn't crash
and doesn't glitch when running on Nintendo flash cards, and
2. your game doesn't have showstopper playability issues.

> Also, is it better to try to get a deal on a finished title
> or on a prototype (keeping in mind this is a startup with no
> previous titles)?

Port your game to PC first, and sell it on PC first.
This may get your foot in the door.

--
Damian

Messages 14625 - 14654 of 15019   Newest  |  < Newer  |  Older >  |  Oldest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help