Shop OBEX P1 Docs P2 Docs Learn Events
static vs. "normal" global variable - Page 2 — Parallax Forums

static vs. "normal" global variable

2»

Comments

  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-12 14:55
    Just tried your graphics demo and it looks nice! Is this designed for a particular board that has a connector for the NES controller? How do I connect one myself? Are any parts required other than the controller itself?
  • maccamacca Posts: 826
    edited 2013-04-13 00:02
    Found the problem!

    Nothing to do with static declarations or aligments, just a stupid mistake on my side. The initialize_background function was overflowing the tile_map arrays by more than 200 bytes. The effect was visible with static declarations because the memory is organized differently in that case (I see the tile_map arrays are located in the .bss segment, while without static they are located in the .common segment) and the overflow was overwriting other data. The aligments, according to the output of nm, are as expected in both cases.

    Thank you all for your help, and sorry for the time you loose on this.
    David Betz wrote: »
    Just tried your graphics demo and it looks nice! Is this designed for a particular board that has a connector for the NES controller? How do I connect one myself? Are any parts required other than the controller itself?

    It is not designed for a particular board. The NES controller expects P2=clock, P3=latch and P4=data (also P5=data for second controller but is not used), the pins are defined in nes_gamepad_ctrl.h and can be changed to match the hardware. I don't think other parts are necessary except the controller and related connector (I think Parallax has a NES connector breakout board).

    I have a site for this project at http://dev.maccasoft.com/propge/ if you want to take a look.

    Related discussions are here http://forums.parallax.com/showthread.php/146667 and on the Propellerpowered site here http://propellerpowered.com/forum/index.php?topic=415.0
  • kuronekokuroneko Posts: 3,623
    edited 2013-04-13 00:56
    macca wrote: »
    Nothing to do with static declarations or aligments, ...
    You'd still have to make sure that the array is long aligned (gcc only guarantees word alignment for the type you used). This is assuming that propeller-elf-gcc acts the same as gcc in that respect.
  • maccamacca Posts: 826
    edited 2013-04-13 08:56
    Actually not, the array is readed with rdword so word alignment is fine (this thing has confused me a lot).
Sign In or Register to comment.