Log In  


Cart #s23pages-1 | 2022-03-25 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

TO LOAD THIS PICO-8 CART, in immediate mode, type: load #s23pages

Back in QBasic for DOS there was a resolution you could have that gave you 16-pages to store your 320x200 16-color graphic screens. Zero (0) was the main display and 1-15 were storage locations. It was invoked by typing: screen 7 and you could copy screens using pcopy(a,b)

When I first wrote S1 I made heavy use of these additional 15-pages and stored all kinds of information there, not just graphics but including map data and script data converted to pixels and back to numbers again as actual variable space was small.

While we have no requirement for this today you still might need additional pages to draw and recall information from for your 64x64 pixel carts. So I wrote this cart and set of functions to assist in this.

In it you can record and recall a 64x64 pixeled screen (totaling 2048-bytes each) to any of 23-graphic pages that are stored in memory. It uses no arrays or variable space.

You have 5-functions.

The first initializes the 64x64 resolution mode and forces all drawn elements to maintain within that area, it is called: set64x64() and uses no arguments.

The second clears the 64x64 screen at any time. You cannot use CLS() as if you are using pages -1 to -3, it would clear those as well as this is still part of your 128x128 screen despite only viewing 64x64 pixels. It is called: cls64(c) and uses one optional argument for screen color. But is not required.

The third copies any of the 23 pages either to the main screen or back again. It is called: pcopy(a,b) and uses numbers as pages and memory information as listed thus:

  • -7 = the bottom-right-hand corner of sprites (64x64)
  • -6 = the bottom-left-hand corner of sprites (64x64)
  • -5 = top-right-hand corner of sprites (64x64)
  • -4 = top-left-hand corner of sprites (64x64)
  • -3 = bottom-right-hand corner of screen (not seen with 64x64 resolution)
  • -2 = bottom-left-hand corner of screen (also not seen)
  • -1 = top-right-hand corner of screen (not seen)
  • 0 = Your normal 64x64 display
  • 1 = Memory location 0x8000
  • 2 = Memory location 0x8800
  • 3 = Memory location 0x9000
  • 4 = Memory location 0x9800
  • 5 = Memory location 0xA000
  • 6 = Memory location 0xA800
  • 7 = Memory location 0xB000
  • 8 = Memory location 0xB800
  • 9 = Memory location 0xC000
  • 10 = Memory location 0xC800
  • 11 = Memory location 0xD000
  • 12 = Memory location 0xD800
  • 13 = Memory location 0xE000
  • 14 = Memory location 0xE800
  • 15 = Memory location 0xF000
  • 16 = Memory location 0xF800

So if you used pcopy(16,0) that would copy the screen memory from storage #16 back to the visible screen.

To save the current screen to storage #16 you would reverse the numbers, pcopy(0,16)

The fourth function is just like the 3rd except that it forces debug information to appear. It is called: pcopydebug(a,b) and uses the same arguments as pcopy(a,b)

The fifth function returns you to normal 128x128 pixeled graphic mode. It is called: end64x64() and uses no arguments.

In running this demo cart, all 23-pages are filled with randomly colored circles that do not repeat each other to prove it works correctly.

use the arrow keys to navigate copying that particular page number to the main screen. Obviously nothing APPEARS to change for page # 0 as that is your visual page.

Press 🅾️ to remove the 64x64 resolution and return back to 128x128 resolution in addition to copying the spritesheet straight to the screen to show how screens # -4 to #-7 are stored. You must press CTRL+R from here to rerun the cart.

Press ❎ at any time to turn on and off the debug information.

The debug information is interpreted thus:

  • M[1] = The memory location to copy FROM.
  • M[2] = The memory location to copy TO.
  • X[1] = If this is 1 then it is adding 64-pixels to get the right-most side of the screen or spritesheet.
  • X[2] = the same as X[1] except it will always be zero since we are just viewing the main screen.

If you are running in immediate mode, you can press [ESC] to return back to 128x128 mode and see pages # -1 to -3 appearing on the main screen.

If there is a desire, I could make a 128x128 pixel version of this library.

Further if you have any questions or suggestions, feel free to enter them below. Thanks !

1



[Please log in to post a comment]