Jump to content
IGNORED

sprites won't show up


Serguei2

Recommended Posts

 

#include <coleco.h>

#include <getput1.h>
const byte gtsSPRITES[] = {
0x87, 0x00, 0x01, 0x07, 0x01, 0x85, 0x00, 0x0F, 0x0C, 0x1E, 0x1E, 0x3E, 0x1E, 0x0E, 0x0C,
0x1E, 0xBE, 0xFE, 0x3E, 0x1E, 0x1E, 0x1C, 0x1C, 0x3C, 0x88, 0x00, 0x00, 0x01, 0x87, 0x00, 0x07,
0x10, 0x3C, 0x1C, 0x0C, 0x0C, 0x00, 0x1C, 0xF8, 0x85, 0x00, 0xFF};
void nmi(void) {}
void main(void)
{
screen_mode_2_text();
paper(0xc);
fill_vram0(0x2000,0x1800,0xb0);
duplicate_pattern();
rle2vram (gtsSPRITES,0x3800);
sprites[0].x=50;
sprites[0].y=50;
sprites[0].colour=12;
sprites[0].pattern=8;
sprites[1].x=50;
sprites[1].y=50;
sprites[1].colour=9;
sprites[1].pattern=8;
update_sprites(0,2);
cls();
screen_on();
pause();
}

 

I made a mistake somewhere.

Link to comment
Share on other sites

Like this?

 

 

#include <coleco.h>

#include <getput1.h>
byte gtsSPRITES[] = {
0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,
0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,
0x41, 0x8F, 0x41, 0xFF};
void nmi(void) {}
void main(void)
{
screen_mode_2_text();
paper(0xc);
fill_vram0(0x2000,0x1800,0xb0);
duplicate_pattern();
change_spattern(0,gtsSPRITES,4);
sprites[0].x=204;
sprites[0].y=0;
sprites[0].colour=9;
sprites[0].pattern=15;
sprites[1].x=204;
sprites[1].y=0;
sprites[1].colour=4;
sprites[1].pattern=15;
update_sprites(0,2);
cls();
screen_on();
pause();
}

Still not working.

 

 

If I write change_spattern(gtsSPRITES,0x1800);, I'll get an error.

Link to comment
Share on other sites

change_spattern must be used like that

 

 

const byte Sprite1[] = {
0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,
0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,
0x41, 0x8F, 0x41, 0xFF};

 

 

const byte Sprite2[] = {
0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,
0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,
0x41, 0x8F, 0x41, 0xFF};

.....

 

change_spattern(0,Sprite1,4);

change_spattern(4,Sprite2,4);

 

 

sprites[0].x=204;
sprites[0].y=0;
sprites[0].colour=9;
sprites[0].pattern=0;

sprites[1].x=204;
sprites[1].y=16;
sprites[1].colour=4;
sprites[1].pattern=4;

updatesprites(0,2); //<= don't put the underscore between update and sprites on that command!... use updatesprites NOT update_sprites

Edited by youki
Link to comment
Share on other sites

I use


void main(void){
 screen_mode_2_text();
 paper(0xc);
 fill_vram0(0x2000,0x1800,0xb0);
 duplicate_pattern();
 rle2vram (gtsSPRITES,0x3800);
 sprites[0].x=50;
 sprites[0].y=50;
 sprites[0].colour=12
 sprites[0].pattern=0;
 sprites[1].x=50;
 sprites[1].y=50;
 sprites[1].colour=9;
 sprites[1].pattern=4;
 cls();
 screen_on();
enable_nmi();
loop:
delay(1);
updatesprites(0,64);
goto loop;
}

I added enable_nmi() so the bios function would work properly and put the delay(1);updatesprites(0,64); in a loop. Now the sprites are being updated 60 hz. updatesprites(0,64); ensure that the sprites won't start flashing due to unknown reason.

 

More on disable_nmi(); enable_nmi();

 

Enable_nmi() will allow the controller to function, Colecovision sound engine to the next data, anything that is in the NMI{} will run anytime nmi occur. The downside, there is a chance for video corruption if you did too many things during a frame. Right after delay(1); I would use updatesprites(0,64); first, and if you need to draw the score, time or do small video write during the game loop do that first. Then after that, update game logic which uses the CPU and won't corrupt the VRAM.

 

disable_nmi(); will allow you to do large video write.

example:

disable_nmi();
delay(1);
rle2vram(levelCOLOR,0x2000);
rle2vram(levelPATTERN,0x0000);
duplicate_pattern();
put_vram(0x1800,hud,128);
rle2vram(commonSPRITE,0x3800);
put_vram(0x3A00,Slime,512);
put_vram(0x3F00,itemSPRITE,160);//56

Then use enable_nmi(); if you need the controller, sound and other things to work.

 

And delay(1) in a game loop. This is like WAIT or VSYNC in basic programming if you're running a gameloop. It wait for the vdp status to tell it that it finished drawing the screen.

Link to comment
Share on other sites

change_spattern must be used like that

 

 

const byte Sprite1[] = {

0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,

0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,

0x41, 0x8F, 0x41, 0xFF};

 

 

const byte Sprite2[] = {

0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,

0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,

0x41, 0x8F, 0x41, 0xFF};

.....

 

change_spattern(0,Sprite1,4);

change_spattern(4,Sprite2,4);

 

 

sprites[0].x=204;

sprites[0].y=0;

sprites[0].colour=9;

sprites[0].pattern=0;

 

sprites[1].x=204;

sprites[1].y=16;

sprites[1].colour=4;

sprites[1].pattern=4;

updatesprites(0,2); //<= don't put the underscore between update and sprites on that command!... use updatesprites NOT update_sprites

 

If I need to update sprites, I will use this technique. Thanks for the tip.

 

 

I use


void main(void){
 screen_mode_2_text();
 paper(0xc);
 fill_vram0(0x2000,0x1800,0xb0);
 duplicate_pattern();
 rle2vram (gtsSPRITES,0x3800);
 sprites[0].x=50;
 sprites[0].y=50;
 sprites[0].colour=12
 sprites[0].pattern=0;
 sprites[1].x=50;
 sprites[1].y=50;
 sprites[1].colour=9;
 sprites[1].pattern=4;
 cls();
 screen_on();
enable_nmi();
loop:
delay(1);
updatesprites(0,64);
goto loop;
}

I added enable_nmi() so the bios function would work properly and put the delay(1);updatesprites(0,64); in a loop. Now the sprites are being updated 60 hz. updatesprites(0,64); ensure that the sprites won't start flashing due to unknown reason.

 

More on disable_nmi(); enable_nmi();

 

Enable_nmi() will allow the controller to function, Colecovision sound engine to the next data, anything that is in the NMI{} will run anytime nmi occur. The downside, there is a chance for video corruption if you did too many things during a frame. Right after delay(1); I would use updatesprites(0,64); first, and if you need to draw the score, time or do small video write during the game loop do that first. Then after that, update game logic which uses the CPU and won't corrupt the VRAM.

 

disable_nmi(); will allow you to do large video write.

example:

disable_nmi();
delay(1);
rle2vram(levelCOLOR,0x2000);
rle2vram(levelPATTERN,0x0000);
duplicate_pattern();
put_vram(0x1800,hud,128);
rle2vram(commonSPRITE,0x3800);
put_vram(0x3A00,Slime,512);
put_vram(0x3F00,itemSPRITE,160);//56

Then use enable_nmi(); if you need the controller, sound and other things to work.

 

And delay(1) in a game loop. This is like WAIT or VSYNC in basic programming if you're running a gameloop. It wait for the vdp status to tell it that it finished drawing the screen.

 

It works. Thanks again Kiwi.

 

Other thing. I noted icvgm always writes this:

 

 

byte SPRITESINIT[] = {

204, 0, 0, 15,
204, 0, 4, 15};

 

Is it useful?

Link to comment
Share on other sites

byte SPRITESINIT[] = {

204, 0, 0, 15,
204, 0, 4, 15};
Yours would be
byte SPRITESINIT[] = {
50,50, 0, 12,
50,50, 4, 9};
I think the data format is
y, x, pattern, and color
You can load it to
put_vram(0x1b00,SPRITESINIT, 8); 0x1b00 is where the sprite's attribute goes.
I mostly prefer the array format of sprite mainly to load variables and rearrange the sprites priorities to make sprite flickers when there's more than 4 on a line.
Loading variable.
sprites[0].x=herox;
sprites[0].y=heroy;
sprites[0].colour=heroc1;
sprites[0].pattern=herop1;
sprites[1].x=herox;
sprites[1].y=heroy;
sprites[1].colour=heroc2;
sprites[1].pattern=herop2;
Rolling up loop to save ROM space and rearrange sprite order every frame.

 

here's an example from my game A Sparrow's Goes Flapping

if (flicker==0){
sprites[0].y = birdy;
sprites[0].x = birdx;
sprites[0].colour =9;
sprites[0].pattern =birdpattern;
sprites[1].y = birdy;
sprites[1].x = birdx;
sprites[1].colour =11;
sprites[1].pattern =birdpattern+4;
sprites[10].y=223;//move bird double off screen
sprites[11].y=223;//move bird double off screen
for(ID=0;ID<=5;ID++){
sprites[2+ID].y = objecty[ID];
sprites[2+ID].x = objectx[ID];
sprites[2+ID].colour =objectc[ID];
sprites[2+ID].pattern =objectp[ID];
}
}
if (flicker==1){
sprites[10].y = birdy;
sprites[10].x = birdx;
sprites[10].colour =9;
sprites[10].pattern =birdpattern;
sprites[11].y = birdy;
sprites[11].x = birdx;
sprites[11].colour =11;
sprites[11].pattern =birdpattern+4;
sprites[0].y=223;//move bird double off screen
sprites[1].y=223;//move bird double off screen
for(ID=0;ID<=5;ID++){
sprites[7-ID].y = objecty[ID];
sprites[7-ID].x = objectx[ID];
sprites[7-ID].colour =objectc[ID];
sprites[7-ID].pattern =objectp[ID];
}
}
Edited by Kiwi
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...