psxsdk

offscr

A sprite painted onto a sphere's texture while it runs: drawing into video memory off the screen.

Controls

The right-hand buttons move the sprite over the texture, the directional buttons and L1 and L2 move the sphere, Select makes either faster, Start pauses and resumes, and Start and Select together quit.

A port of L. Evans's Net Yaroze tutorial on retexturing at run time (Sony, 1997). A sphere, textured from a 16-bit image, sits over a square of floor. Every frame, after drawing the scene, the program points the drawing environment at the part of VRAM outside the two display buffers where the sphere's texture lives, draws a sprite there, and points it back: the sprite is painted onto the texture, and the sphere wears it from the next frame on. Four seconds in, it also copies a block of VRAM over another, the simplest way to change a texture. The sprite is also drawn on screen, in the top left, as it is.

Differences from the original:

  • The data is read off the disc to the addresses the original's batch script sent it to.
  • What the original prints to the serial console, a line every frame and the drawing environment at the start, is left out. What it shows on screen is kept.
  • The second ordering tables, through which the sprite is drawn onto the texture, have the two entries their length of 1 gives them. The original declares them an entry long, so clearing one writes past its end into whatever follows; here that was the view.
  • Code the original never runs is left out: the sprite placement for objects drawn as sprites, of which it has none, and the palette copy it has commented out.

Source on GitHub