Log In  

If you have ever used Tac-08, an early Pico-8 emulator for the RG-350 handheld gaming device, you will be painfully aware that certain commands do not work. These especially, flip() memcpy() reload() and cstore()

While you can still use cartdata() and dset() for permanently saved data, many programmers including myself have difficulty coding with the absence of flip().

Thanks to @luchak's guidance, I can see now how to use yield() in its place. And as near as I can tell, it's perfect and remarkably simple to prepare. Let's take this example program:

function main()
cls()
repeat
  pset(rnd(128),rnd(128),rnd(16))
  _flip()
until forever
end

function _init()
  _flip=yield
  _main=cocreate(main)
end

function _update()
  coresume(_main)
end

Let's go through it.

You have _init() create a new command called _flip which is the same thing as yield You also create the pointer to a looped process, in this case our main program. And NO it doesn't matter if you call '_flip' outside of the main() function, inside a WHILE/END, REPEAT/UNTIL, or FOR/END, however you still must initialize the main program.

The _update() only has one programming line, to resume and loop our main routine. This is needed to get it started. Anytime you _flip() it will exit from wherever it is, come here to do a single screen update, then jump right back exactly where you left it, even if it's a different function or loop entirely.


And there you have it ! To change existing carts, load one up that uses flip() and change it to _flip() making the necessary changes in the code with the addition of _init() and _update() Then it will run correctly in Tac-08.

To do a global replace of flip() to _flip() you can edit it in NOTEPAD and select [E]dit, [R]eplace.

Type flip() in the Find what field and _flip() in the Replace with field. Select Replace [A]ll.

If that's too much work, you can load the cart in Pico-8, then in the editor, press CTRL+F, type in the search term: flip() followed by ENTER and replace all occurances with _flip() Press CTRL+H to find the next match and continue manually making changes until you return back to the top of the code where _flip() already exists.

Here is an example game I wrote some time ago that earlier did not run on the Tac-08 but now does with the new _flip() in place ! And verified. I just checked, this cart I wrote now runs perfectly on the RG-350. It had 6 flip() in it originally. All have been changed now to _flip()

Cart #dowawewete-0 | 2021-12-19 | Code ▽ | Embed ▽ | No License
1

It is indeed a wonderful thing to be able to open existing carts that earlier would not run on Tac-08 and now making use of new _flip() - they can run well and for the very first time ! Making the RG-350 portable gaming console that much more valuable an asset to Pico-8 gamers and programmers worldwide.

HOPE THIS HELPS !

P#103132 2021-12-19 22:58 ( Edited 2021-12-20 00:21)

You can just redefine a 'flip' function! not required to search-replace flip to _flip.

P#103182 2021-12-20 15:31

I tried that first, @merwok. It doesn't work. Yet ... I'm not sure why it doesn't. Try the following code to see that method does not work.

function main()

cls()

repeat
  pset(rnd(128),rnd(128),rnd(16))
  flip()
until forever

end

function _init()
  flip=yield
  _main=cocreate(main)
end

function _update()
  coresume(_main)
end

Neither does this work:

function main()

cls()
repeat
  pset(rnd(128),rnd(128),rnd(16))
  flip()
until forever

end

function _init()
  _main=cocreate(main)
end

function _update()
  coresume(_main)
end

function flip()
  yield()
end

No, in order To fix the code above change all of flip to _flip

Understand also you cannot ever mention flip by itself for instance to redefine it in the code for Tac-08, even if you don't use it, as it is an unknown command and immediately registers as an error.

Now if you can find a way around this, I would definitely like to see that.

P#103191 2021-12-20 17:47 ( Edited 2021-12-20 19:32)

[Please log in to post a comment]