Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - VDP - Scrolling...

Reply to topic
Author Message
ATani
  • Guest
Reply with quote
VDP - Scrolling...
Post Posted: Sat Apr 01, 2000 5:12 am
Charles,
Something that i see that is kinda missing in the VDP docs that you have put together is about the Vertical and Horizontal scrolling... Can you elaborate as to how the VDP handles the scrolling mechanism.

Thanks :)

Atani
 
  • Joined: 28 Sep 1999
  • Posts: 1197
Reply with quote
Post Posted: Sat Apr 01, 2000 8:05 am
Quote
> Charles,
> Something that i see that is kinda missing in the VDP docs that you have put together is about the Vertical and Horizontal scrolling... Can you elaborate as to how the VDP handles the scrolling mechanism.

Ok, lemme dig this up from memory...

The scroll values provide an index within the name table
for the VDP to start fetching name table data.

The lower three bits of each register act as the individual
pixel or line index into a pattern, while the upper five
bits act as the row or column index into the name table.

I can't remember if the horizontal scroll value is inverted
or not. Not terribly hard to verify. :)

Here's some "C" pseudocode to illustrate this:

// reg[] = vdp registers
// scanline = current scanline (0-191)

// Offset into display, in lines
int v_line = (reg[9] + scanline) % 224;

// Offset into pattern, in lines
int v_row = (v_line & 7);

// Offset into name table, in rows
int nt_row = (v_line >> 3) & 0x1F;

// Index into name table row, in columns
int xscroll = (reg[8] >> 3) & 0x1F;

// Point to start of selected row in name table
word *ptr = &vram[name_table_base + (nt_row << 6)];

// Draw 32 columns
for(col = 0; col < 32; col += 1)
{
attribute = ptr[(xscroll + col) & 0x1F];

for(x = 0; x < 8; x += 1)
{
pixel = pattern_cache[attribute & 0x1FF][v_row][x];
/* draw pattern line here */
}
}

Hope that's what you wanted to know. :)



  View user's profile Send private message Visit poster's website
ATani
  • Guest
Reply with quote
Post Posted: Sat Apr 01, 2000 3:38 pm
Quote
> Hope that's what you wanted to know. :)

Actually that is eactly what i wanted to know :) i am working on writting a simple VDP for my SMS section of my emulator and i couldnt get the scrolling to work correctly... this clears up most of it :)
 
Reply to topic



Back to the top of this page

Back to SMS Power!