Scrolling Plane A (Horizontally)

Heya, been awhile since I've posted in here :D.

I've finally got around to getting XGCC setup right and am busy refamiliarizing myself with Genesis programming (XGCC is making it so much more fun).

I'm currently writing a quick tutorial on setting up the XGCC environment (meant for newbies) that walks through the setup, a quick explanation of the entities required to get a program running, and walking through compiling a test demo I'm writing. The test demo is just me kind of getting my feet wet again getting use to how to get things to work.

Everything has been going fine, but I've ran into a bit of trouble getting Plane A to scroll horizontally. I've written a function that worked according to the Sega Documentation, which worked with Plane B fine. Its my understanding that the shift values start at whatever you set your HSCROLL table at in the graphics init. The first word is for shifting plane B, and the second plane a, correct?

When I couldn't get my function to work, I pulled out Kaneda's function from his GENESIS.C util library. Same result, Plane B scrolls like a charm, but no luck on Plane A. The graphics are displaying fine so I'm fairly sure I'm doing that correctly (it all seems a lot more easy now). So anyway, any help would be appreciated in figuring out how to do this. Plane A just has a full background on it. Plane A has some text tiles ("Hello World").

Here's my Graphics INIT:

Code:
  volatile ushort *pw;

  

  pw = (ushort *) GFXCNTL;

  *pw = 0x8016;  /* reg. 0 - Enable HBL */

  *pw = 0x8174;  /* reg. 1 - Enable display, VBL, DMA + VCell size */

  *pw = 0x8230;  /* reg. 2 - Plane A =$30*$400=$C000 */

  *pw = 0x832C;  /* reg. 3 - Window =$2C*$400=$B000 */

  *pw = 0x8407;  /* reg. 4 - Plane B =$7*$2000=$E000 */

  *pw = 0x855E;  /* reg. 5 - sprite table begins at $BC00=$5E*$200 */

  *pw = 0x8600;  /* reg. 6 - not used */

  *pw = 0x8700;  /* reg. 7 - Background Color number*/

  *pw = 0x8800;  /* reg. 8 - not used */

  *pw = 0x8900;  /* reg. 9 - not used */

  *pw = 0x8a01;  /* reg 10 - HInterrupt timing */

  *pw = 0x8b00;  /* reg 11 - $0000abcd a=extr.int b=vscr cd=hscr */

  *pw = 0x8c81;  /* reg 12 - Screen width set to 320 and no shadow/hightlight*/

  *pw = 0x8d2E;  /* reg 13 - HScoll Table = $B800 */

  *pw = 0x8e00;  /* reg 14 - not used */

  *pw = 0x8f02;  /* reg 15 - auto increment data */

  *pw = 0x9011;  /* reg 16 - scrl screen v&h size (64x64) */

  *pw = 0x9100;  /* reg 17 - window hpos */

  *pw = 0x92ff;  /* reg 18 - window vpos */

My Defines for Planes:

Code:
// Field Address Defines

//***************************

#define APLAN 0xC000

#define WPLAN 0xB000

#define BPLAN 0xE000

#define SLIST 0xBC00

#define HSCRL 0xB800

Kaneda's function I'm currently using:

Code:
void scrollh(posA, posB)

int posA;

int posB;

{

  register int *pw;

  register ulong *pl;

  pl = (ulong *) GFXCNTL;

  *pl = GFX_WRITE_ADDR(HSCRL);

  pw = (int *) GFXDATA;

  *pw = posA;

  *pw = posB;

  /* you must scroll fieldA before fieldB....(?) */

  wait_sync(); 

}

And my main code (all using fairly standard functions:)

Code:
  init_gfx();

  // Set Palettes

  set_colors(0,charset_pal);

  set_colors(1,bg_pal);

  // Load Tiles into Memory

  load_tiles(bg,(bg_VSize*bg_HSize),1);

  load_tiles(charset,(charset_VSize*charset_HSize),(bg_VSize*bg_HSize)+1);

  

  // Show Background on Plane B

  show_tiles(1,(28*40),1,40,BPLAN);

  

  // Print Hello World on Plane A

  print((bg_VSize*bg_HSize)+1,"HELLO WORLD!!!",2,2,0,APLAN);

  

  // Wait for VBL

  wait_sync();

  scrollh(30,30);
 
Code:
void scrollh(posA, posB)

int posA;

int posB;

{

  register int *pw;

  register ulong *pl;

  pl = (ulong *) GFXCNTL;

  *pl = GFX_WRITE_ADDR(HSCRL);

  pw = (int *) GFXDATA;

  *pw = posA;

  *pw = posB;

  /* you must scroll fieldA before fieldB....(?) */

  wait_sync();

}

I think you want pw to be an ushort* here, since the scroll table entries are 16 bits each.
 
Originally posted by mic@Sun, 2005-11-20 @ 11:03 PM

I think you want pw to be an ushort* here, since the scroll table entries are 16 bits each.

[post=141909]Quoted post[/post]​


That was it, looking at fonzie's XGCC example, I see thats what he does:

Code:
void scrollh(sa,sb)

short sa,sb;

{

  volatile register ushort *pw;

  uint *pl;

  pl = (uint *) GFXCNTL;

  *pl = GFX_WRITE_ADDR(HSCRL);

  pw = (ushort *) GFXDATA;

    *pw =sa;

    *pw =sb;

}

And I also forgot a different in XGCC from SGCC, as fonzie noted in his example also:

In SGCC:

char:8bits

int:16bits

long:32bits

In GCC(here):

char:8bits

short:16bits

int:32bits

long:34bits

Thanks mic! Congrats on your 4th compiler for both Genesis and Saturn. Keep up the good work buddy!
 
Top