nxtBasic : Draw cube in the background and then bring it to screen128.

All aspects of programming on the Commander X16.
Post Reply
funkheld
Posts: 322
Joined: Mon Feb 26, 2024 11:11 am

nxtBasic : Draw cube in the background and then bring it to screen128.

Post by funkheld »

hello, good day.

draw cube in the background and then bring it to screen128.
can you do that in nxtbasic?

thanks.
greetings
unartic
Posts: 145
Joined: Sat Oct 28, 2023 3:26 pm

Re: nxtBasic : Draw cube in the background and then bring it to screen128.

Post by unartic »

Well, you mean double buffering in this instance. x16 does not support that in a good way. There is not enough vera memory to store two 256 colored bitmaps in vram, so 320x240, 256colors can not be double buffered. You could go to 16 color bitmap, then you can do double buffering, but support for 16 color bitmap is not as good as 256 color bitmap.

So If you want a cube to appear on the screen there are several ways with its advantages and disadvantages:
- Just draw to the bitmap layer: with animation this often results in flickering. (allthough the fastes)
- Draw somewhere within vram or highram yourself by setting bytes, which correspond to pixels and when needed copy a chunck of memory to vram. (see cube.bas in the examples which uses this approach, though the 'buffer' is drawn to the visible screen area)
- Mask of a piece of the bitmap layer by placing a sprite over it (for example if you have some kind of HUD on the screen). You can then draw 'under' it, and copy a rectangle to the coordinates you want your graphic to appear.

Maybe others can come up with even better solutions, as this is a x16-thing, not a nxtBasic thing.
funkheld
Posts: 322
Joined: Mon Feb 26, 2024 11:11 am

Re: nxtBasic : Draw cube in the background and then bring it to screen128.

Post by funkheld »

thanks, the idea with the HUD is good.

greeting
Post Reply