Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2018-03-28 18:58:12

jobalisk
Member
From: I don't even know anymore...
Registered: 2017-05-28
Posts: 55
Website

Creating an upwards scrolling background

Hello all...

So I'm having a bit of difficulty at the moment with getting an upwards scrolling background to work in my game at the moment.

I've watched a you tube video about it which dosn't seem to help at all so I'm at a bit of a loss as of what to do next.

Here is my c file for the map:

#define map01Width 20
#define map01Height 30
#define map01Bank 0

unsigned char map01[] =
{
  0x00,0x01,0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x05,
  0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x01,
  0x00,0x05,0x01,0x01,0x01,0x05,0x05,0x04,0x01,0x01,
  0x01,0x03,0x01,0x01,0x01,0x01,0x01,0x05,0x05,0x01,
  0x05,0x01,0x05,0x01,0x03,0x01,0x01,0x02,0x04,0x01,
  0x01,0x01,0x01,0x01,0x02,0x01,0x01,0x01,0x01,0x01,
  0x00,0x01,0x02,0x02,0x03,0x05,0x05,0x01,0x01,0x03,
  0x01,0x01,0x01,0x01,0x01,0x01,0x04,0x01,0x01,0x01,
  0x00,0x02,0x02,0x01,0x01,0x05,0x01,0x01,0x01,0x01,
  0x01,0x01,0x05,0x05,0x01,0x01,0x01,0x01,0x01,0x01,
  0x02,0x02,0x01,0x01,0x01,0x01,0x03,0x01,0x01,0x03,
  0x01,0x01,0x01,0x05,0x05,0x01,0x05,0x01,0x01,0x03,
  0x00,0x02,0x01,0x03,0x01,0x01,0x05,0x01,0x01,0x01,
  0x01,0x01,0x01,0x02,0x05,0x01,0x03,0x04,0x04,0x04,
  0x00,0x01,0x01,0x03,0x01,0x01,0x01,0x03,0x01,0x01,
  0x02,0x01,0x01,0x01,0x01,0x02,0x05,0x01,0x01,0x01,
  0x00,0x04,0x01,0x03,0x01,0x01,0x04,0x01,0x01,0x00,
  0x01,0x01,0x05,0x01,0x03,0x04,0x01,0x03,0x01,0x01,
  0x00,0x04,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x01,
  0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  0x00,0x04,0x01,0x04,0x01,0x03,0x01,0x01,0x01,0x01,
  0x03,0x03,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,
  0x05,0x00,0x01,0x01,0x01,0x03,0x01,0x05,0x01,0x01,
  0x01,0x01,0x01,0x01,0x04,0x05,0x01,0x01,0x01,0x01,
  0x00,0x03,0x03,0x01,0x01,0x03,0x05,0x01,0x01,0x03,
  0x01,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x05,
  0x00,0x01,0x02,0x05,0x05,0x05,0x03,0x03,0x04,0x04,
  0x01,0x01,0x01,0x05,0x05,0x05,0x01,0x01,0x01,0x01,
  0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  0x00,0x01,0x01,0x01,0x02,0x01,0x01,0x01,0x02,0x01,
  0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x05,
  0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x02,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x02,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,
  0x03,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
  0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x03,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,
  0x02,0x01,0x0F,0x07,0x07,0x07,0x07,0x07,0x06,0x06,
  0x06,0x06,0x07,0x07,0x07,0x07,0x07,0x0C,0x01,0x01,
  0x00,0x05,0x0A,0x0E,0x0E,0x0E,0x0E,0x0E,0x04,0x01,
  0x02,0x01,0x0E,0x0E,0x0E,0x0E,0x0E,0x08,0x04,0x04
};

and here is the code where I call it.


    SWITCH_ROM_MBC1(10);
    set_bkg_data(0,26, ground_white); //place down the background
    SWITCH_ROM_MBC1(9);
    set_bkg_tiles(BKYcounter1, BKXcounter1, 20, 30, map01);

currently I can get the background displaying but trying to change its position just causes the sprites to screw up.

Can anyone explain how I should do this properly please?

Offline

 

#2 2018-03-29 00:00:46

gbjosh
Member
From: KY
Registered: 2016-06-15
Posts: 51

Re: Creating an upwards scrolling background

Offline

 

#3 2018-03-29 02:09:50

jobalisk
Member
From: I don't even know anymore...
Registered: 2017-05-28
Posts: 55
Website

Re: Creating an upwards scrolling background

Thanks, I'll give it a shot.

Offline

 

#4 2018-03-29 14:24:52

jobalisk
Member
From: I don't even know anymore...
Registered: 2017-05-28
Posts: 55
Website

Re: Creating an upwards scrolling background

Ok, so that post was no help what so ever. The issue I have at the moment is that I cant scroll down. The background starts at 0,0. if I try to go to 2,0 the background scrolls up, but my map starts at the top and wont start where I want it to at the bottom, (it starts in the blue area, i want it to start at the bottom).

http://i.xomf.com/gyzdd.png

Whenever I try to scroll down, using a negative int the screen just goes to pot:

http://i.xomf.com/gbdbw.png

This leaves me really unsure as to my next step.

Last edited by jobalisk (2018-03-29 14:26:10)

Offline

 

#5 2018-03-29 15:33:24

ISSOtm
Member
From: Somewhere in Echo RAM
Registered: 2017-04-18
Posts: 160
Website

Re: Creating an upwards scrolling background

I have no idea how this is done with GBDK, but if you want to scroll your BG, you need to edit SCY (vertical) and SCX (horizontal). Increasing those causes the BG to scroll left, pixel by pixel. The values are bytes, and the screen wraps around nicely.

<insert rant about how much GBDK is shit>


The French Lord Of Laziness.
Legend of Zelda and Undertale fan, I also tend to break Pokémon R/B/Y a little too much.

Twitter | Me on GCL | Discord : ISSOtm#9015 | Skype : isso.tm (I don't login anymore)

Offline

 

#6 2018-03-29 20:16:43

ssjason123
Member
Registered: 2017-03-21
Posts: 45

Re: Creating an upwards scrolling background

I think you need to post more code. If you are just scrolling the view position it should be done with either move_bkg (absolute position) or scroll_bkg(relative position). If you are trying to load in new tiles at each adjustment that could be causing your corruptions.

The VRAM viewer in BGB is a huge help when trying to figure out what is going on when you scroll the screen position.

Offline

 

#7 2018-03-29 23:25:09

jobalisk
Member
From: I don't even know anymore...
Registered: 2017-05-28
Posts: 55
Website

Re: Creating an upwards scrolling background

Ok, So I had misread gbjosh's article he posted, the move_bkg worked fine, thanks.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson