rate my lame smooth scroller (using MSXgl)

Pagina 1/4
| 2 | 3 | 4

Door xchip

Rookie (26)

afbeelding van xchip

20-03-2022, 15:09

feedback and questions are very welcome.

https://pastebin.com/hiFKPSE7

Todo:
- I probably should double buffer the patterns and name tables to speed up things

Aangemeld of registreer om reacties te plaatsen

Van Grauw

Ascended (10621)

afbeelding van Grauw

20-03-2022, 16:50

Code looks tidy. My question is: where’s the demo video or rom Smile.

Idk if SDCC optimises it (probably does), but a shift operation (offset >> 3, x >> 1, y << 1) is faster than a division or multiplication (offset / 8, x / 2, y * 2).

Since you’re already doing & bitwise operations in the vicinity, using shifts is more logical to me even if the compiler does generate the same code in the end.

Van xchip

Rookie (26)

afbeelding van xchip

20-03-2022, 16:54

Multiplications an divisions by powers of 2 get always optimized by compilers.

Any suggestion on where I can put the rom to share it?

Van ARTRAG

Enlighted (6862)

afbeelding van ARTRAG

20-03-2022, 19:10

This is nice
https://msxpen.com/

Van aoineko

Hero (535)

afbeelding van aoineko

20-03-2022, 20:59

I compiled our MSXgl projet and uploaded a ROM on MSXVillage: https://msxvillage.fr/upload/scroller.rom
Here is a link to test it online: https://webmsx.org/?ROM=https://msxvillage.fr/upload/scrolle...

I haven't looked at your code yet. I'll do some feedback later.

Van aoineko

Hero (535)

afbeelding van aoineko

20-03-2022, 22:07

According to (the excellent) Emulicious profiler, the scroll_level_ab function take 95% of the frame. ^^
The assembly code generated by SDCC for this function is not nice to see.

As you have 256 possible inputs and 8 possible values for the offset, it should be worth the cost to precalculate everything (requires 2 KB which can be stored in ROM).

Van ARTRAG

Enlighted (6862)

afbeelding van ARTRAG

20-03-2022, 22:12

You should consider to store in VRAM the rotated tiles. If you can fit in VRAM the rotated tiles you need for building the level there it will be just a matter of mapping the offsets to tiles.

Van xchip

Rookie (26)

afbeelding van xchip

20-03-2022, 22:14

Thanks Aoineko and thanks again for your great lib!

Scrolling works using the cursors.

Van xchip

Rookie (26)

afbeelding van xchip

21-03-2022, 12:11

Oh nice, I will use that profiler too. I already ported the *scroll* function to heavily unrolled asm, I think it is a 30% faster now.

As for precalculating the tiles, this is just an exercise to see how far I can push things without loss of generality.

I'll send an update later today.

Van xchip

Rookie (26)

afbeelding van xchip

29-03-2022, 01:11

here is the version 2.0

https://pastebin.com/y0xwMRFM

Nothing is precalculated and tiles are scrolled on the fly.

Talking about serious stuff, how does robocop achieve such a wonderful smooth scroll?

Van ARTRAG

Enlighted (6862)

afbeelding van ARTRAG

29-03-2022, 09:54

Robocop is a zx port. I'm not an expert but It was common for those zx games to have background tiles (or better, couples of tiles) stored pre-rotated at different offsets and copied in a 4KB buffer accordingly to the scroll step.
In the same buffer, the animated software sprites were superimposed using AND for masks and OR for the shapes. Also shapes and masks were stored with different offsets, in order to reduce the time spent rotating bytes.
Once the frame was composed, it was transferred to VRAM. This step was additional to the zx code and msx specific, in order to take into account the differences in the video layout of the two machines.

Pagina 1/4
| 2 | 3 | 4