Sprites are not loaded in new version SGDK

SGDK only sub forum

Moderator: Stef

Post Reply
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Sprites are not loaded in new version SGDK

Post by alko » Sat Dec 04, 2021 1:38 pm

Compile with old version

Image

and at new version

Image

code:

Code: Select all

#include <genesis.h>
#include "maths.h"
//#include "vdp_pal.h"

#include "Alice.h"
#include "globalvar.h"
#include "gfx.h"
#include "music.h"
#include "sprite.h"
#include "Alice.h"
#include "dma.h"

void init_level1();
u16 state=0;
u16 timer;
u16 floorpos=0;


void update_flame()
{
for (u16 i=0;i<8;i++)
    {
flame[i].x-=flame[i].speed;
flame[i].lifetime++;
if(flame[i].lifetime==6) SPR_setFrame(sprites[1+i],2);
if(flame[i].lifetime==8) SPR_setFrame(sprites[1+i],1);

if(flame[i].lifetime>10)
    {

        flame[i].lifetime=random()%10+5;
  flame[i].speed=random()%4+1;
        flame[i].x=Alice.x-8;
        flame[i].y=Alice.y+40+random()%4;
        SPR_setFrame(sprites[1+i],0);
    }
       SPR_setPosition(sprites[1+i], flame[i].x,flame[i].y );
    }
}



void update_game()
{
meter_count++;

if(meter_count==320)
    {

 VDP_drawImageEx(BG_B, &back2, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind),1, 6, FALSE, TRUE);

VDP_drawImageEx(BG_B, &back2, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind),13, 12, FALSE, TRUE);
    }

    update_flame();
floorpos+=2;
update_Alice();

      //   VDP_setHorizontalScroll(PLAN_B,-floorpos);
       VDP_setScrollingMode(HSCROLL_TILE,VSCROLL_PLANE);
    u16 hscroll[24]= {0};
    u16 i;
    for(i = 0; i < 19; i+=1)
    {
        hscroll[i] =-floorpos;
    }
        for(i = 19; i < 23; i+=1)
    {
        hscroll[i] =-floorpos*2;
    }
           for(i = 23; i < 28; i+=1)
    {
        hscroll[i] =-floorpos*3;
    }


VDP_setHorizontalScrollTile	(BG_B, 1, hscroll,28,1);



}


int main()
{

    //SYS_disableInts();

    VDP_setScreenWidth320();
   // VDP_setScreenHeight240();

VDP_setPlanSize(64,32);
    SPR_init();
      VDP_setPaletteColors(0, (u16*) palette_black, 64);


    init_level1();

    SYS_enableInts();
    while(TRUE)
    {
        handleInput();


            update_game();


        SPR_update();

        VDP_waitVSync();
    }

    return 0;
}



void init_level1()
{

    ind = TILE_USERINDEX;
    VDP_setVerticalScroll(BG_A,0);
    VDP_setVerticalScroll(BG_B,0);

    VDP_clearPlane	(BG_A,1);
    VDP_clearPlane	(BG_B,1);




    VDP_setPalette(PAL0, floor1.palette->data);
   VDP_setPalette(PAL1, skate1.palette->data);
 VDP_setPalette(PAL2, back1.palette->data);
 VDP_setPalette(PAL3, smoke.palette->data);


   // VDP_waitVSync();


 VDP_drawImageEx(BG_B, &UI, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, ind),0, 0, FALSE, TRUE);
 ind += UI.tileset->numTile;

 for (u16 i=0;i<8;i++){
    VDP_drawImageEx(BG_B, &floor1, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind),i*8, 20, FALSE, TRUE);
}
    ind += floor1.tileset->numTile;


for (u16 j=0;j<5;j++){
for (u16 i=0;i<8;i++){
 VDP_drawImageEx(BG_B, &back1, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind),i*8, j*4, FALSE, TRUE);
}
}

ind += back1.tileset->numTile;



Alice.x=50;
Alice.y=50;
Alice.dx=0;
Alice.dy=0;

    sprites[0] = SPR_addSprite( &skate1 ,Alice.x, Alice.y, TILE_ATTR(PAL1, FALSE, FALSE, FALSE));

for (u16 i=0;i<8;i++)
    {
        flame[i].speed=random()%4;
        flame[i].x=Alice.x-8;
        flame[i].y=Alice.y+40;
 sprites[i+1] = SPR_addSprite( &spr_flame ,flame[i].x,flame[i].y , TILE_ATTR(PAL1, FALSE, FALSE, FALSE));
    }


for(u16 i=0;i<20;i++ ){
 sprites[9+i] = SPR_addSprite(&stolb,100,i*8, TILE_ATTR(PAL1, FALSE, FALSE, FALSE));
}

}

int k;
void waveFX()
{
  k+=8;

    s16 hscroll2[225] = {0}; //scroll values
for(int i = 5; i < 224; i++)
 hscroll2[i] = (sinFix16(i*150+k)>>3)-8;

     VDP_setHorizontalScrollLine(BG_A, 1, hscroll2, 224, TRUE);
}
Image

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Sprites are not loaded in new version SGDK

Post by Stef » Sat Dec 04, 2021 10:18 pm

The Changelog give some tips about required changes when updating to a new SGDK version.
Version 1.6 required a major update in the code:
Change all VDP_waitVSync() references by VDP_doVBlankProcess().
You may have others issues but i think this one is the most important one :)

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Sprites are not loaded in new version SGDK

Post by alko » Sun Dec 05, 2021 12:49 pm

Stef wrote:
Sat Dec 04, 2021 10:18 pm

VDP_doVBlankProcess().
But I can't find this function
Image
Image

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Sprites are not loaded in new version SGDK

Post by Stef » Sun Dec 05, 2021 2:27 pm

Oh sorry the method is called SYS_doVBlankProcess() !

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Sprites are not loaded in new version SGDK

Post by alko » Sun Dec 05, 2021 5:47 pm

Thanks. Now it works correctly.
Image

Post Reply