Log In  


Cart #remcode_backbuffer-4 | 2021-12-09 | Code ▽ | Embed ▽ | No License

Description

A small and limited exploration of using screen and sprite memory as front and back buffers in a custom written game loop.

Uses pokes to the addresses: 0X5F54 0X5F55

These new pokes make front and back buffers fairly easy.

The code implements two commands. An overridden CLS, and an alternative function (drawsprite rather than SPR) to draw a sprite to the spritesheet. The programming is not intended to be as efficient as it could be, but instead to demonstrate the capability in a way that I hope is understandable for a wide audience - anyone wishing to read through it and use what they glean from it is welcome to.

If the example is unclear, please see: Wikipedia: Backbuffer: Page flipping, or other online resources.

Limitations of the code

The code loops per second is displayed via a normal print command which has not been overridden, so some flicker may occur in the info at the top of the screen. In code intended for a fuller release, the print command and all the other graphics commands (such as sspr, rectfill) would need to be overridden to print to the back buffer.

Controls

The program allows you move a small sprite about the screen using the D-pad. The sprite's speed can be switched between two settings using the o/x buttons (c/x keys).

Blog versus general forum

I've opted to post this as a blog item.

Reasons:

  • I feel it's interesting enough to post, but probably not useful to many.
  • Lack of previous experience with writing page flipping code.

It was written out of curiosity about the switching the memory pokes allowed, just as a start in exploring them; in that respect it's an experimental/learning cart for myself.

On screen info

Displays code loops per second but this is not the frames per second. It is looping through the very simple and short piece of code that fast, but presumably Pico-8 is only displaying when it can. The frames per second are also shown.

Feedback

If anyone with more experience of page flipping spots anything silly I've done (this is the first page flipping routine I've written, as far as I recall) please feel free to point it out politely. (Likewise if I have any errors in my understanding of the concept that come through, please feel free to point them out politely.) Or if there's an easier way to achieve this, feel free to share.

Other feedback is also welcome.

Thanks!

Edits made to cart and post

(Oldest to newest.)

Minor edits made to display code loops per second and achieved frame rate per second.

Some edits to the post made to keep in line with edits to the cart, as mentioned above.

Changed "proof of concept", with which I was never happy to "small and limited exploration" and "code" in various places; other changes in line with this.




[Please log in to post a comment]