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.

Beginners > different modes

#60408 - ghost Leinad - Thu Nov 10, 2005 1:54 am

Im trying to use a mode change when running my game; the intro is in mode 0 and the game in mode 4, this is because when i learn to do blending, I learned using mode 0...but, when I change the mode a very annoying line cross all over the screen, how can I avoid that when changing modes???


the other question is, can I use blending the same way as in mode 0????
if this is possible...how do i achieve it???

the pic is here:
http://www.angelfire.com/music6/leinad/1.PNG
_________________
All human wisdom is summed up in these two words, - 'Wait and hope"
****************************************
My site www.myth-world.net and www.bmrpg.com :)


Last edited by ghost Leinad on Thu Nov 10, 2005 3:49 am; edited 1 time in total

#60412 - tepples - Thu Nov 10, 2005 2:11 am

Please ask separate questions in separate topics or at least in separate posts. I can split whole posts from a topic into a new topic, but I can't split individual posts.

Why, specifically, do you want to do a mode change halfway down the screen? What will you eventually show on top, and what will you eventually show on bottom?

If you really want to do a mode change halfway down the screen, then you should keep background 2 turned on always and hide it using windows if necessary. This has been tested for modes 0 and 1 (which Mario Kart uses) but not for modes 0 and 4.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#60425 - ghost Leinad - Thu Nov 10, 2005 3:55 am

oh..no you missundertood me :S:S:S

what im trying to do is make a mode change between frames...for instance...frame 4 is in mode 0, and frame 5 is now in mode 4...

why??? because im trying to use blending for my intro, but i don't know how to make bleding in mode 4 :$

after the intro i want to switch modes, cause mi whole game is made (because is one of my first) in mode 4 :D

the line in the pic, is the a line crossing the whole display! is not divided.

so my question is..how do i make a mode change between frames???
and how do i make blending in mode 4...

anyway, i will try to fix the problem by miself
_________________
All human wisdom is summed up in these two words, - 'Wait and hope"
****************************************
My site www.myth-world.net and www.bmrpg.com :)

#60433 - poslundc - Thu Nov 10, 2005 5:45 am

Make sure you change modes during VBlank and you won't get any screen artifacts.

If it takes longer than a single VBlank period for you to load your various assets into VRAM, you'll probably want to engineer a transition phase. Fade your original screen down to black over the course of several frames, make whatever changes you need to in VRAM over however many frames it takes, switch modes, then fade back up over the course of several frames.

In modes 3-5 the canvas is BG2, which can be used with the blend register like in modes 0-2. But since you only get the single layer, you can only blend it with sprites and the backdrop.

Dan.

#60594 - SittingDuck - Sat Nov 12, 2005 10:56 am

That's what I was going to say. Do it in VBlank. If you are already synchronising with VBlank, maybe you're taking too long to do calculations before drawing.

Also, are you using a VBlank interrupt or waiting for it?

#60660 - sgeos - Sun Nov 13, 2005 1:47 pm

Blend to black, change modes. Fade in. Happy.

-Brendan

#61345 - ghost Leinad - Sat Nov 19, 2005 2:13 am

Well, well. I finally managed to get rid of the annoying line. the problem was that I was changing the mode before uploading the video buffer for mode 4. So, my program was showing garbage.

my function is more or less like this

intro()
{
mode0;
uploadbg2;
uploadbg3;
fadeinbackground(); //using blending for bg2 and bg3
fadeoutbackground();//black screen, little wait
uploadbg2 (video buffer);
mode4;
}

My problem now is that when I change modes skips the litle wait and the bg2 is showed suddenly, I don't want this, I want the bg2 on mode 4 to fade in little by little. I guess is because I'm not blending it with the backdrop. So, my question is, how do I make a blend with the backdrop? I was trying but it doesn't seem to work.
_________________
All human wisdom is summed up in these two words, - 'Wait and hope"
****************************************
My site www.myth-world.net and www.bmrpg.com :)

#61375 - Cearn - Sat Nov 19, 2005 1:08 pm

ghost Leinad wrote:
My problem now is that when I change modes skips the litle wait and the bg2 is showed suddenly, I don't want this, I want the bg2 on mode 4 to fade in little by little. I guess is because I'm not blending it with the backdrop. So, my question is, how do I make a blend with the backdrop? I was trying but it doesn't seem to work.

You don't need to blend with the backdrop for a fade to black (or white for that matter), they have their own blend modes.

Code:
#define LAYER_BG2   0x0004
#define BLD_BLACK   0x00C0

REG_BLDCNT= LAYER_BG2 | BLD_BLACK;

// fade out in 0x100/4 frames
for(ii=0; ii<0x100; ii += 4)
{
    vid_vsync();
    REG_COLEY= ii>>4;
}
REG_COLEY=0x10;

// wait a bit
for(ii=0; ii<60; ii++)
    vid_vsync();

// fade in in 0x100/3 frames
for(ii=0x100; ii>=0; ii -= 3)
{
    vid_vsync();
    REG_COLEY= ii>>4;
}
The number for REG_COLEY goes from 0 (no blend) to 0x10 (full blend, in this case to black). Using fixed point math you can easily set how long you want each of the blends to take.