#14424 - NeoGeo - Tue Jan 06, 2004 12:43 pm
I was tyring to do some sprite rotation the other day when I got a tip that there was possible to use some BIOS functions for this. I think it was called ObjAffineSet of something, can anyone give me a step by step example on how to do this from C.
#14425 - Cearn - Tue Jan 06, 2004 1:17 pm
You can do this by using inline assembly. The CowBite Spec
has a list of available BIOS calls and what the input and
output should be. ObjAffineSet is number 0x0f. The code for
using it is:
Code: |
typedef struct tObjAffineSource
{
s16 wX;
s16 wY;
u16 theta;
} ObjAffineSource;
typedef struct tObjAffineDest
{
s16 pa, pb, pc, pd;
} ObjAffineDest ;
// NOTE!
// ** theta does a CLOCKWISE rotation
// ** wX and wY are reciprocals of the actual scales: wX=1/sX; wY= 1/sY
// | wX*cos(th) -wX*sin(th) |
// P = | |
// | wY*sin(th) wY*cos(th) |
void ObjAffineSet(ObjAffineSource *src, ObjAffineDest *dst, int num, int offset)
{ asm("swi 0x0f0000"); }
|
src and dst are arrays of structures, num is the numbers of elements
in the array (i.e., the numer of calculations) and offset is the
distance (in bytes) between the matrix elements. This is for GCC
in ARM mode. SDT and THUMB is a little different.
Usage example:
Code: |
ObjAffineSource af_src= {0x0100, 0x0080, 0x4000};
ObjAffineDest af_dest;
ObjAffineSet(&af_src, &af_dest, 1, 2);
|
As for why this works, I'll get back to you on that.
#14537 - Miked0801 - Thu Jan 08, 2004 2:51 am
Your devkit should have some built in function calls to do this for you in agb.h. make sure that's included - then check it out for a list of functions.
#15604 - dagamer34 - Mon Jan 26, 2004 3:14 am
I have a problem when running my ROM from my cart. It always hangs when I can swi 0x010000, RegisterRamReset. It works perfectly in VBA but I get a white screen on real hardware.
Don't you just love it when that happens?
Well, please download my ROM and test it on your flash cart and see if the same thing happens. That way I can know if its my ROM or the flash cart that's the problem. By the way, I tested it with a EZF-Advance so maybe someone with a F2A or XG1/XG2 can give it a go.
www.geocities.com/dagamer34/
It's called SWI Test.
Thanks.
EDIT: After using the BIOS when running VBA, I find that it decides to enable the Force Blank flag. Now why would it do something like that? Isn't it supposed to clear parts of RAM?
_________________
Little kids and Playstation 2's don't mix. :(
#15607 - tepples - Mon Jan 26, 2004 4:12 am
dagamer34 wrote: |
it decides to enable the Force Blank flag. Now why would it do something like that? |
umm... isn't it called RegisterRamReset()?
Try clearing the bit that tells it to reset the video registers.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#15640 - dagamer34 - Mon Jan 26, 2004 11:20 pm
Well, after extensive testing using a bios, I have figured out that SWI 01 decides to set the GBA to mode 0 and turn off the screen. All I did was save a temporary copy of REG_DISPCNT before calling it and restoring it afterwards.
I wonder why this was never documented. I guess the unofficial docs really are a work in progress. Someone should add it.
_________________
Little kids and Playstation 2's don't mix. :(
#15646 - torne - Tue Jan 27, 2004 12:30 am
dagamer34 wrote: |
Well, after extensive testing using a bios, I have figured out that SWI 01 decides to set the GBA to mode 0 and turn off the screen. All I did was save a temporary copy of REG_DISPCNT before calling it and restoring it afterwards.
I wonder why this was never documented. I guess the unofficial docs really are a work in progress. Someone should add it. |
If you read GBAtek you will find the following:
Quote: |
SWI 1 - RegisterRamReset
...
The function always switches the screen into forced blank by setting DISPCNT=0080h (regardless of incoming R0, screen becomes white). |
It is documented.
#15652 - dagamer34 - Tue Jan 27, 2004 4:42 am
Sorry, I was looking at the CowBite spec. It needs to be documented there.
_________________
Little kids and Playstation 2's don't mix. :(
#15672 - torne - Tue Jan 27, 2004 6:31 pm
Try referring to gbatek as well or instead, as it tends to be more complete and accurate (though often less helpful).
#15702 - dagamer34 - Wed Jan 28, 2004 3:38 am
It seems GBATek was really written for professional developers instead of hobbyists. And I finally took a look at that site... $5000?
The price really just goes to show how harmful piracy is. However, VBA is still useful, even if it has its *bugs*. Then again, he isn't getting paid for it. He works on it in his "spare" time. Thanks a lot, Forgotten!!
Some tips for the next release.... *laughs*
_________________
Little kids and Playstation 2's don't mix. :(
#15716 - tom - Wed Jan 28, 2004 1:21 pm
dagamer34 wrote: |
It seems GBATek was really written for professional developers instead of hobbyists. And I finally took a look at that site... $5000? |
uh, you're talking about no$gba.
gbatek is the technical documentation for no$gba, which is available for free (the docs, not the emulator...):
http://www.work.de/nocash/gbatek.txt
it's to be preferred over any other halfbaked technical docs on the gba (including the cowbite specs)
#15733 - torne - Wed Jan 28, 2004 6:20 pm
http://www.work.de/nocash/gbatek.htm is the slightly more readable HTML version.
#15749 - dagamer34 - Thu Jan 29, 2004 12:26 am
"for the emulator" is what I meant to add on.
_________________
Little kids and Playstation 2's don't mix. :(
#17725 - batblaster - Sat Mar 13, 2004 11:05 am
VBA is a great Emulator and is free but No$gba is the best emulator available for coders, when long time ago i do somethings for GBC the no$gbc help me a lot. The No$Gba has a lot of futures very very interesting for debugging and coding , very accurate and very very similar to real hardware... Normally i use vba but sometimes i use no$gba (the last public version released, not the best but work)...
The No$gba help coder in a lot of things like a realtime showing of screenposition and realtime showing of obj position, is faster but is very very expensive...
_________________
Batblaster / 7 Raven Studios Co. Ltd
------------------------------------------