So, i was trying to make it scroll less then 8 pixels by changing the xscroll to a float, but now i have a new problem. (still doesn't scroll less than 8 pixels, don't know what to do)
The graphics corrupt while i have scrollx going, and the player is passing above or bellow the npc to trigger the zorder change.
I don't think it's because i switch to a float, but that i switch sprite array order while its scrolling. What you think it could be?
Here is the code.
Code that switches zorder.
if (player1.posy > cxypos[1][0])
{
if (triggerIndex == 1)
{
player1.pzorder = 0;
czorder = 1;
SPR_initSprite(&sprites[player1.pzorder], &jason_sprite, player1.posx, player1.posy, TILE_ATTR(PAL1, TRUE, FALSE, FALSE));
SPR_initSprite(&sprites[czorder], &fcitizen_sprite, cxypos[0][0], cxypos[1][0], TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
triggerIndex = 0;
}
}
else
{
if (triggerIndex == 0)
{
player1.pzorder = 1;
czorder = 0;
SPR_initSprite(&sprites[player1.pzorder], &jason_sprite, player1.posx, player1.posy, TILE_ATTR(PAL1, TRUE, FALSE, FALSE));
SPR_initSprite(&sprites[czorder], &fcitizen_sprite, cxypos[0][0], cxypos[1][0], TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
triggerIndex = 1;
}
}
Map scrolling code.
if (tileproperty == TILEPROP_NOTSOLID) { scrollH = 1; } else { scrollH = 0; }
if ((value & BUTTON_RIGHT) && MapXPosInTile < 152 && scrollH == 1 )
{
SYS_disableInts();
MapXPosInTile += 0.1;
pInMAX = (player1.posx/16)+MapXPosInTile;
cxypos[0][0] -= 0.1;
SPR_setPosition(&sprites[czorder], cxypos[0][0], cxypos[1][0]);
indb = TILE_USERINDEX;
VDP_setMapEx(BPLAN, map, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, indb), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
indb += bgb_image.tileset->numTile;
SYS_enableInts();
}
if ((value & BUTTON_LEFT) && MapXPosInTile > 0 && mright != 1 && scrollH == 1 && tileproperty == TILEPROP_NOTSOLID)
{
SYS_disableInts();
MapXPosInTile -= 0.1;
pInMAX = (player1.posx/16)+MapXPosInTile;
cxypos[0][0] += 0.1;
SPR_setPosition(&sprites[czorder], cxypos[0][0], cxypos[1][0]);
indb = TILE_USERINDEX;
VDP_setMapEx(BPLAN, map, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, indb), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
indb += bgb_image.tileset->numTile;
SYS_enableInts();
}
Scroll map region corruption
Moderator: Stef
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Re: Scroll map region corruption
You can try commenting out section by section to narrow down which part is causing the problem.
By corruption, what gets affected? sprites, backgrounds or both? Are the graphics random garbage or just the wrong tiles?
Can you provide a screenshot?
By corruption, what gets affected? sprites, backgrounds or both? Are the graphics random garbage or just the wrong tiles?
Can you provide a screenshot?
Re: Scroll map region corruption
Full screen visual corruption, of random garbage. I'll see if i can record it and upload to youtube. I'm going to do a video log anyways.djcouchycouch wrote:You can try commenting out section by section to narrow down which part is causing the problem.
By corruption, what gets affected? sprites, backgrounds or both? Are the graphics random garbage or just the wrong tiles?
Can you provide a screenshot?
Probably was that float. I switched it back to regular int and it's not doing the problem. But now i am back to square one, and it's still scrolls 8 pixels at a time. Also my animation code seems to cause the screen to flicker twice every so often with the idle animation.
Now it seems i got it to corrupt (well black out) with int as well if i switch zorder quickly. I think i am doing to much, with the scrolling and the zorder code.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Scroll map region corruption
Did you actually tried to use "float" type in your code ? They are not really supported (i don't think SGDK compiler even include the float emulation API) and if they are, they will be damn slow so you really need to avoid any "float" or "double" declarations.
SGDK has sort of fixed point support type to help with mathematical stuff :
https://github.com/Stephane-D/SGDK/wiki/Tuto-Maths
So use fix16 or fix32 instead of float
SGDK has sort of fixed point support type to help with mathematical stuff :
https://github.com/Stephane-D/SGDK/wiki/Tuto-Maths
So use fix16 or fix32 instead of float
Re: Scroll map region corruption
Yep, i used float lol.Stef wrote:Did you actually tried to use "float" type in your code ? They are not really supported (i don't think SGDK compiler even include the float emulation API) and if they are, they will be damn slow so you really need to avoid any "float" or "double" declarations.
SGDK has sort of fixed point support type to help with mathematical stuff :
https://github.com/Stephane-D/SGDK/wiki/Tuto-Maths
So use fix16 or fix32 instead of float
But how do you make it scroll less then 8 pixels? the map does not seem to budge until it gets to int values, 1,2,3,4 etc
Or its how the mapex works?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Scroll map region corruption
You have to use the hardware scrolling capabilities :
I really encourage you to read more about how work the Megadrive video system as that is basic feature of it
Code: Select all
void VDP_setHorizontalScroll(VDPPlan plan, s16 value);