Scroll & Sprites

Page 2/3
1 | | 3

By thegeps

Master (166)

thegeps's picture

12-02-2019, 01:55

I couldn't wait. So I tried this after told you I would do it tomorrow...
and I did it! Scrolling in main loop and sprite management in ISR.
Here's the video:

https://youtu.be/MlM9WTute0s

How I did it? I set a flag in a memory location: both the routine check this flag (I called it vdpbusy) bwefore change addres and write vram. and when finished writing set the flag with values needed by other routine.
In the main routine (scrolling) I poll the flag before start until is value is 0 then update the nametable and at the end of outi loops I set the flag to 1. Then poll again before write tiles attributes and then set it to 1. In the end poll it for 0 before write address for tiles colors and then set it to 1:So the ISR poll the vdpbusy until its value is 1 (and is 1 after nametable write, after tiles attributes write and after tiles color write). And all works fine!
I'm pretty happy! :RNFF:

By santiontanon

Paladin (752)

santiontanon's picture

12-02-2019, 05:47

nice!!! looking very smooth!! Big smile

By thegeps

Master (166)

thegeps's picture

12-02-2019, 07:21

This evening, after work, I'll implement your fifth sprite solution for clear scoreboard Smile

By TomH

Champion (322)

TomH's picture

12-02-2019, 18:25

The work being done is so great that I'm scraping around for something useful to contribute. That being the threshold:

santiontanon wrote:

Also, a quick trick: you can prevent the ships from being drawn OVER the scoreboard at the top, by just placing 4 sprites exactly over the scoreboard (they can just be black sprites that would be invisible),

Rather than worrying about their colour, or creating empty graphic entries, could they not just be any old sprites you have to hand, assigned the transparent colour?

By turbor

Champion (415)

turbor's picture

12-02-2019, 20:50

TomH wrote:

Rather than worrying about their colour, or creating empty graphic entries, could they not just be any old sprites you have to hand, assigned the transparent colour?

Yes, they can be empty or color 0, but you just have to make sure that they are in the high priority planes Smile

By thegeps

Master (166)

thegeps's picture

12-02-2019, 22:09

Mmm I think they must be 16 pixel full (in eight) to avoid any spriteline to be displayed... I'll probably define a 16x16 sprite empty ezcept the most right vertical line and put 4 of these sprites at y=0, x=255. All trasparent, of course

By thegeps

Master (166)

thegeps's picture

12-02-2019, 22:12

Maybe 4 different "vertical line sprites", to avoid collisiom too...

By TomH

Champion (322)

TomH's picture

12-02-2019, 23:07

I'm pretty sure they can be entirely without pixels, but you're right that the collision flag would be set should the patterns overlap, regardless of whether you've set them to transparent.

As ever, I defer to the big chart of things the VDP fetches during a scan line. Head to TMS9918 character, one row from the bottom. Starting from the access window that beings on cycle 37, you'll see that from there a single byte is fetched for all sprites, ending at cycle 305. That's the VDP grabbing the current y coordinate for each sprite. That's the complete set of information it uses to decide which are visible.

It then grabs full sprite details — x positions, y again*, pattern and colour — for the four it has selected for display starting from 313 and into the next line, finishing on 29. So it doesn't even know what the patterns or colours are until after it's picked the four that are visible.

* I've yet to learn what happens if the sprite has changed y during the interim, other than that I would dare imagine you can't trick the GPU into an out-of-bounds access since it's not going to be full 16-bit arithmetic. I'm curious, but I guess it's off-topic here.

By thegeps

Master (166)

thegeps's picture

13-02-2019, 00:16

I think they must have pixels. if you have 4 sprites on the same line, the fifth sprites starts to disappear when entering the same line (for example going down) of the drawed sprites. If you look at the video I posted in slow motion (but you can discern it too watching at normal speed) when there's 5 sprites on the same line (each enemy ship is 2 sprites made so when there's 2 enemies in a row and a bullet) you'll see the color inside one enemy disappear from down to up, not all internal color in one time...

By TomH

Champion (322)

TomH's picture

13-02-2019, 03:56

I'm certain that they don't need pixels. The VDP does this loop:

  1. fetch y positions of all 32 sprites. Pick the first up to four of those that are in the proper y range.
  2. for the selected four, fetch x, y, name and colour, then two bytes of pattern.

The selection of up to four is a function of y positions only. Whether they have any pixels and are not the transparent colour isn't known until later.

Page 2/3
1 | | 3
My MSX profile