Idiot question (sorry!)

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
Ketsuban
Interested
Posts: 25
Joined: Wed Jan 17, 2007 11:37 am
Location: United Kingdom of Great Boredom

Idiot question (sorry!)

Post by Ketsuban » Fri Jan 26, 2007 1:28 am

I'm struggling to understand exactly how the scrollplanes work on the Megadrive. Here's how I understand it, and hopefully I don't confuse you too much.

The screen is (for the purposes of this question) 40x28 cells in size, and this size is set by certain VDP registers. The scrollplanes are both 64x32 cells, and this size is set by a different set of VDP registers. The pattern tables for the scrollplanes are located in VRAM, at a location defined by yet more VDP registers.

My question is, if I draw a particular pattern to the scrollplane and then scroll it, what is it that actually moves? Is it the scrollplane or the tiles? If it's the scrollplane I'd expect behaviour to be undefined when the screen displays outside the scrollplane; if it's the tiles I'd expect scrolling too far to result in the data that the scrollplane contains being lost.

Furthermore, if it's the tiles that move then how do I set where the screen is on the scrollplane? I'd ideally like the 40x28 screen to be centred on the 64x32 scrollplane, so that there's a two-cell gap between the top and bottom of the scrollplane and the top and bottom of the screen respectively, and similarly a twelve-cell gap between the respective sides.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri Jan 26, 2007 6:33 am

I might be incorrect:
* VDP reads data from the scrolldata
* then reads graphics according to data from scrolldata
* and then adds displacement (amount of scroll) to the graphics
* and displays the stuff that fits the screen

And the last result is: scrolldata remains unchanged

I hope it is not too confusing
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

LocalH
Very interested
Posts: 152
Joined: Tue Dec 19, 2006 5:04 pm

Re: Idiot question (sorry!)

Post by LocalH » Fri Jan 26, 2007 7:12 am

Quickman wrote:My question is, if I draw a particular pattern to the scrollplane and then scroll it, what is it that actually moves? Is it the scrollplane or the tiles? If it's the scrollplane I'd expect behaviour to be undefined when the screen displays outside the scrollplane; if it's the tiles I'd expect scrolling too far to result in the data that the scrollplane contains being lost.
As far as I know, the scrollplane moves, and it wraps around. I encountered this in the early making of my First Time Out demo, as I'd used a larger LOCAL H logo, and it wrapped around while scrolling. I can't speak for the VDP's internal operation, but that's the external result.
Quickman wrote:Furthermore, if it's the tiles that move then how do I set where the screen is on the scrollplane? I'd ideally like the 40x28 screen to be centred on the 64x32 scrollplane, so that there's a two-cell gap between the top and bottom of the scrollplane and the top and bottom of the screen respectively, and similarly a twelve-cell gap between the respective sides.
Just set your base scroll values appropriately, and you can do this. Increasing scroll values move the planes right and up, whereas decreasing values move the planes left and down.

ob1
Very interested
Posts: 463
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Fri Jan 26, 2007 8:23 am

Planes are made of pointers to tiles, and they all reside in VRAM (the HScroll also, by the way).

The scroll datas are offset. On each line, the VDP reads the planes data, and fetches the needed tiles. Then, just before sending the line to the TV screen, line is shifted regarding the offset (HScroll data).
Nothing moves in VRAM.

The 40cell mode is the display screen. It can be 32 or 40 cell wide. The PAL/NTSC defines the display screen height : 28/30.
Besides this, the plane size can be 32x32, 32x64, 32x128, 64x32, 64x64 or 128x32. This size affect both A-plane and B-plane.

If you have a 64x32 plane, and a 40 display screen, only 40 cell-rows out of 64 are visible ; the 40 first left ones by default. If you set the H scroll to, let's say 112 (14 cell), you will see the rows from cell 50 to cell 64, then it wraps and you have cell 0 to cell 26. If you set the H scroll to 240 (30 cell), you will see from cell 0 to cell 6, then wraps from cell 0 to cell 6.

Here's a pic. Hope it helps :

Code: Select all

+----------------------------------------+
| Display Screen                         |
|                                        |
|+----------------------------------------------------------------+
|| A-Plane 64x32                         |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
||                                       |                        |
+|---------------------------------------+                        |
 |                                                                |
 |                                                                |
 |                                                                |
 |                                                                |
 |                                                                |
 |                                                                |
 +----------------------------------------------------------------+

H scroll 64 (8 cell)
+----------------------------------------+
| Display Screen                         |
|                                        |
|--------++--------------------------------------------------------+
|        || A-Plane 64x32                |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
|        ||                              |                         |
+--------||------------------------------+                         |
         ||                                                        |
         ||                                                        |
         ||                                                        |
         ||                                                        |
 --------++--------------------------------------------------------+

Ketsuban
Interested
Posts: 25
Joined: Wed Jan 17, 2007 11:37 am
Location: United Kingdom of Great Boredom

Post by Ketsuban » Fri Jan 26, 2007 2:20 pm

I think I understand now.

Post Reply