Log In  

@dw817

Follow
Follow

Just another mad coder.

We're all mad. I'm mad. You're mad, you must be - or you wouldn't have come here.

Calculators have always fascinated me. For that matter numbers. Even before I could bring Dad's calculator to school I was busily working on paper with digits 0-9. Fascinated, just ... fascinated by what they meant, what they implied, and what they COULD mean with new definitions.

When I finally understood computers, I was quite interested. No, that's not the right word. I was OBSESSED. Obsessed to the point of mania would it could mean. What I could do. And what I could do with tools that worked with these numbers. Tools within tools. Numbers within numbers ...

So perhaps this is a work of love, real love, for the majesty and magnificence of numbers.

With that out of the way, let me show you what I have done.

I suppose it's a bit of a calculator, but with a difference. You can have ANY number of digits. And I mean any. Right now I have it scaled for 64-digits. That includes positive and negative.

Most importantly, it does NOT do it a single number at a time as you can tell. No, it truly does add and subtract every digit intelligently. So if you have 16-digits set. Then it will take no more than 5-loops or 80 looped statements to get the right value.

  • [1st loop] retrieve digits
  • [2nd loop] find largest numbers
  • [3rd loop] add digits (if adding)
  • [4th loop] subtract digits (if subtracting)
  • [5th loop] locate beginning of return value
  • [6th loop] send return value to variable

NOT 1-million loops to get a value of 1-million.

So far it's just addition and subtraction, but maybe that's because I don't really know how to write simple code to multiply or divide without a calculator or computer.

Anyways, it does addition and subtraction quite well, and as mentioned, with any number of digits. I'm not kidding about that.

 
mab
by dw817
Cart [#mab-0#] | Code | 2019-10-20 | License: CC4-BY-NC-SA | Embed

Try out the sample program included and you have a few controls available to you.

Press LEFT and RIGHT to increase and decrease randomly by several thousand.
Hold (O) and LEFT and RIGHT to do it 100 times over.

Tap (X) to double your value. This will rapidly increase the amount. Remember, I just have it keyed to work no more than 64-digits at the moment. You can always change that.

Tap UP to take out the last digit in your number. A good way to shrink the value.

Try this for a test.

Hold (O) and RIGHT to get it up to about 50-million.

Now hold (X) for a bit to see it dramatically increase by doubling the total each time. You can check my work with a calculator too if you want.

Seems to work well for positive numbers. Alright, either hold (O) and LEFT or UP to get the value back down. Test it for negative numbers now.

Here's where my hardest coding came in. To bounce back and forth between positive and negative WITHOUT getting the wrong value. Test it though, please. I want this to work right. I think it does. I hope it doesn't get any errors.

I feel a little like Willy Wonka developing a new candy. As he (Gene Wilder) said, "I don't think so. Few more tests."

Anyways, there you have it. A calculator that can count well past trillions. Definitely good for scoreboards or long-playing RPGs with huge experience point values.

Likely you can find other more interesting uses for it.

P#69113 2019-10-20 16:59 ( Edited 2019-10-20 22:24)

 
Cart [#debug-2#] | Code | 2019-10-19 | License: CC4-BY-NC-SA | Embed
1

to load this cart in Pico-8 immediate mode type:

load #debug-2

updated 10-18-19: Now works correctly no matter what the names of your functions are or even if you rename the debug() function itself.

Ah ! I bet you did not know about this ?

There is a command in Pico-8 that lets you see what function you are in as well as the line number ! Works with nested functions too, as deep as you please.

Debugging your code just got a lot easier.

Try out this sample program and feel free to use this function I put together to assist you. Every time you call DEBUG() it will display at the bottom of the screen what function called it and at what line number.

Big thanks to @Felice for introduction to trace() command which is neither listed in the Pico-8 manual nor the advanced manual. Sometimes things are just found like that. :)

HOPE THIS HELPS !

P#69039 2019-10-19 02:07 ( Edited 2019-10-19 04:34)

Sometimes you just can't get what you want by plotting sprites cause they may not be there or you've put a bunch of binary code on top of 'em. Sometimes you just MUST pixel.

Well, that's all good and well, and there's a few ways to go about it.

[1] Record every pixel in the area ahead of time and later plot it all out again.

[2] As above but only plot select pixels. In this case, do not plot black pixels.

[3] Unique method caching pixels. Explained later below.

[4] NEW ! Shoxidizer's Serializer.

[5] NEW ! Using PEEK and POKE.

Try this program I wrote:

 
by dw817
Cart [#iymp-0#] | Code | 2019-10-18 | No License | Embed

Use LEFT and RIGHT arrow keys to change drawing method.
Lots of moving and colorful sprites. It starts out in MODE 0, which is the 1st above.

. . .

In mode zero you can see above it records every pixel in the sprite and then plots back every single pixel without caring what color they are. For moving 100 sprites, this uses up 63% of your CPU.

. . .

Mode 1 is better and more intelligent. It like above records every pixel in the sprite area but when it comes back to plotting, it only plots pixels that are not color zero (black). This gives you a slight speed increase. Uses 52% of your CPU.

. . .

So what's going on with the cache method which is the fastest using only 32% of your CPU ? Let me see if I can explain.

Instead of using an array that is 8x8 in size to house every pixel, it creates a new single dimensional array that has 3-separate elements in it.

The first is the X-position in the pixel, the next is the Y-position, lastly the color.

So how is this different from the two above ?

Instead of going through 64-different pixels to see which is lit and which is not, it records the X/Y coordinates for each pixel plus the color and saves THAT as a single item in the array.

I'll let you think about that for a minute before giving an answer. Scroll down to see how it's done. No, I don't know how to hide text in Lex.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

So is this what you were expecting ? If so, congratulations, you got it right ! :D

Yes, THIS method of not only recording each pixel you want plotted but their exact X+Y coordinates runs quite a bit faster than the standard 8x8 sweeping method.

So there you have it.

HOPE THIS HELPS !

NOW DO YOU know of a faster way to plot individual pixels from a table or sprite sheet ?

P#69015 2019-10-18 18:16 ( Edited 2019-10-19 02:22)

What games have you had your eye on that you the most ?

This is by no means a complete list or in any any particular order, but these are definitely some games I thoroughly enjoy playing and playing again and will play again even after I have won them.


Wandering Magic - by @Overkill
Carmina - by @makz
A Messenger's Tale - by @JustFire45
Dungeo The Lich Queen - by @nephilim
Of Ineffable Nature - by @Jimmu
Jack Of Spades - by @BoneVolt
Dusk Child - by @SophieHoulden
Mai-Chan's Sweet Buns - by @Krystman
Celeste v0.1.2 - by @noel
Upward - by @matthias
Feed The Ducks - by @kittenm4ster
Just One Boss - by @bridgs
Minima 1.1.1 - by @Feneric
Dank Tomb - by @krajzeg
Alone In Pico - by @NuSan
Swordfish - by @chowyunbrent
Santa's Christmas Run - by @Tassilo
Charge! (LD39) 1.0 - by @DragonXVI
Kelin's Delivery - Rain v1.2.1 - by @NeithR
The Legend Of Bobby 0.7 - by @AbsolutRenal
The Green Legion v1.03 - by @guerragames
Buzzkill 1.4 - by @morningtoast
Eigengrau 0.1 - by @LeDjinn
Puzzle Cave I and II - by @hackefuffel
Tower Noire I - by @Cow

That's a page right there. I'll try to add more later.

How about you ? What are some of your Pico-8 game favorites ?

And what is it in them that makes them so enjoyable to play for you ? This information could and likely will help game developers across the globe - especially if they happen to be YOU. :)

P#69001 2019-10-18 03:02 ( Edited 2019-10-20 02:29)

 
by dw817
Cart [#sots-2#] | Code | 2019-10-17 | License: CC4-BY-NC-SA | Embed
1

update: put helpful remarks in ALL of code now.

This is not a very complex cart, or perhaps it is.

The classic SNAKE game has been around for many years and during that time some innovative programmers have figured out unique, interesting, and compact ways of handling it.

It's not simply drawing a line, it creates a trail that disappears behind the player according to how far in the game they are.

There are many approaches to writing this. As for me, I have always opted to ID the entire screen, in this case, all 15x15 tiles and use a number to represent a part of the snake.

The higher the number the longer it will be in play. Albeit a lower number means it will vanish more quickly.

To update this I have a sweep of the entire playing area and if one of the tiles is a number that is greater to or equals one, then it decreases by one. So you need only plot a number behind where the player just was, to create this trail effect.

My question to you is how would =YOU= do it more efficiently ?

This is open to any and all programmers, not just you aces and veterans but those who are either learning to program in Pico-8 or have for a-while.

How would you code your SNAKE in the most efficient manner possible, and please, include the source.

Chances are one of us (likely me) will learn something from it. :)

P#68977 2019-10-17 19:57 ( Edited 2019-10-17 20:20)

stars in the galaxy.
Whoops, sorry, not that. No, something BETTER. Millions and billions of VALUES you can now use in Pico-8.

 
mib
by dw817
Cart [#mib-0#] | Code | 2019-10-17 | License: CC4-BY-NC-SA | Embed
2

load this in Pico-8 immediate mode with:

load #mib-0

I understand there was a library made sometime ago that could increase a value to trillions, but it could not decrease, let alone go beyond 0 to negative numbers.

Well, I sat down and thought about it. Realized that getting past 0 is a tricky thing indeed. Especially going from 0 to a negative number and found at least for me a fairly simple solution to get around it.

So what do you have here ?

Well, in the demo hit LEFT and RIGHT to choose a positive or negative number to add or subtract to your total. And calculate the result every time you hit (O).

A program that lets you count up as high as you like, well past a billion or trillion using a STRING instead of a numeric variable. There is a catch though, and likely this is a limitation on my coding ability. You can only add or subtract up to 16383 at a time.

I'm not sure how to do it otherwise, but one advantage is if both numbers are ranged to 16383 or less, positive or negative, then the calculation is instant.

If not, it goes through my function and adds or subtracts properly and it defaults to 16-digits, or you can choose how many digits you want in your numbers if that's not enough.

Useful if you want to have a score over a long time or experience points for an RPG that surpass the 32767 barrier.

I have no doubt my code could be optimized further. :)

...

Wait. What the heck ?? It doesn't work correctly here but it does in Pico-8 ??
Well that's just EVIL. I had this problem in GFA-Basic years ago. My code would ran fine in the editor, compiled, didn't run properly. Augh ! Solution anyone ? Gotta be a bug @zep needs to squash.

Try for yourself to see it works perfect in the actual Pico-8 system.

P#68949 2019-10-17 02:29 ( Edited 2019-10-17 03:54)

Here is the latest, 10-18-19

 
brw
by dw817
Cart [#brw-3#] | Code | 2019-10-18 | License: CC4-BY-NC-SA | Embed
5

To load this in Pico-8, in the console immediate mode type:

load #brw-3

. . .

 
brw
by dw817
Cart [#brw-2#] | Code | 2019-10-15 | No License | Embed
5

(older version)

Hope you don't mind me starting a new thread. I literally had to rewrite more than half the code here so I think it's deserving of it.

And yes, it now has a proportionally spaced font.

New configuration in code lets you turn on/off shadow (runs a lot faster without).
Configure page and ink color too. And of course this will work with any text file, provided you have enough memory for it. Anything close to 19,000 chars will fit.

You have a few questions ? I have a few questions. :D

Would you like me to post an additional version that uses soft-sprites instead of individual pixel-plotting as it is now ?

The advantage will be the bookreader will run much faster even with shadowing, the disadvantage of course is you can't inject your own sprites over the set during reading.

Also I could make a version that just reads the text file by itself without poking it to sprite territory.

Further I have the font-writer with the sprite table of fonts I doodled. Do you like the proportionally spaced font or would you like to build one of your own for it ? You will need that tool.

Let me know, and thanks everyone who's helped me get as far in Pico-8 as I have today !

P#68907 2019-10-15 21:38 ( Edited 2019-10-18 20:16)

Now that I'm mixing and matching my metaphors in programming, metaphorically speaking of course, I'm running into some curious behavior by Pico-8.

For instance, take this code:

a="1"
b=2
?a+b

Which gives you 3, and that's fine.

But if you do this:

a="1"
b={1}
?b[a]

The result is NIL. Now I already know why it is because it's a string, but wouldn't it be easier for Pico (and possibly other programmers) to remove the number "type" completely and instead treat all variables as strings, only doing calculations when desired, and even then the results while visually appearing numerically are still just in truth a string ?

We already have ".." to show linking two strings together so there would be no difficulty with getting the "+" chosen correctly for calculations in determining whether or not it needs to be added to or appended to.

What problems would typecasting everything as a string cause ?

I can already see one advantage. Since strings can be any size this could also mean Pico-8 could be upgraded by @zep and allow numbers with any number of digits in them, both to the left and right of the decimal place. It would break the -32767.9999 and 32767.9999 barrier.

P#68887 2019-10-15 00:10 ( Edited 2019-10-15 01:09)

I'm still staying pretty busy here working on something else, but thought I would give this a go using the speed of the mapper to swap pages. See what you think:

Cart [#yaaa256-0#] | Code | 2019-10-13 | License: CC4-BY-NC-SA | Embed
1

P#68854 2019-10-13 23:06

Hello !

I am excited to say that apparently it is indeed possible to copy and paste music from Pico-8 to the Lexaloffle BBS and it creates an awesome jukebox interface besides. Here for instance is an example from @zep's own Hello demo.

[sfx]

So how is it done ? Well, it's tricky and I'm surprised anyone managed to figure it out. To the best of my knowledge, @Gruber is one of the first.

https://www.lexaloffle.com/bbs/?tid=35640

So how can you do it ? First bring up Pico-8 that has the music you want to paste Online. Make sure you are in the MUSIC editor, not the SFX. Now click HERE on the zero zero:

Now click this pink arrow HERE until you can no longer see colored dots above the numbers:

In this case, it is track 11.

Now HOLD DOWN THE SHIFT KEY and click the very last number that has colored dots above it. A visual change will appear so it looks like THIS:

NOTICE the 9 and 10 are now GREEN. This means you can actually copy it now. Go press CTRL+C to copy all of this to the clipboard, it will work now.

Then in your message, hit CTRL+V to paste it. Do a preview and there it is, ready to play Online.

[sfx]

And that's it ! I think this will aid musicians out there to share their original music out there when all they want to do is have an Online jukebox for others to enjoy.

HOPE THIS HELPS !

P#68804 2019-10-12 17:43 ( Edited 2019-10-12 18:01)

Since working on compressing text in a simple bookreader:

https://www.lexaloffle.com/bbs/?tid=35608

I got curious and wanted to know if it was possible to recreate simple text that is chosen from random letters via the walking distance between the points when a match is made.

While I don't think this is at all useful for compression, it is interesting perhaps for use in encryption, secret messages, and your classic magic super decoder ring.

Actual code is really small, but it's chock full of helpful remarks.

Here it is:

-- secret decoder with random
-- written by dw817

-- simple wait for (o) key
function key()
  repeat
    flip()
  until btnp(4)
end

-- character set to use
char=" .abcdefghijklmnopqrstuvwxyz"

-- secret text, change to
-- your liking
t="the key is under the tree."

-- store the encrypted lookup
-- table here.
decod={}

cls()

-- force all random numbers to
-- follow this seed.
srand(1)

-- get length of string char.
-- we ask for it twice in the
-- code so this is convenient.
l=#char

-- starting position for lookup
-- table.
p=0

-- go through each character of
-- the secret string.
for i=1,#t do

-- pull out a single character.
  c=sub(t,i,i)

-- reset iterations needed to
-- find a match.
  n=0

  repeat

-- retrieve a random number to
-- use in finding a matching
-- character with our secret
-- string.
    r=flr(rnd()*l)+1

-- count the number of times it
-- takes.
    n+=1

-- keep looping until we get a
-- match.
  until c==sub(char,r,r)

-- match ? output the results.
  print("char="..c.." index="..i.." iterations="..n)

-- simple delay.
  flip()

-- record the time it took in
-- our lookup array.
  decod[p]=n

-- reset time.
  n=0

-- increase index for lookup
-- table.
  p+=1

-- do every single character
-- from secret string.
end

-- wait for (o) key.
key()

cls()
?"ready to decode:"

-- reseed our random number.
-- important !
srand(1)

-- reset position in lookup
-- table.
p=0

repeat

-- loop for length of lookup
-- table in elements.
  for i=1,decod[p] do

-- get a random number the
-- length of the chars used.  
    r=flr(rnd()*l)+1

-- keep looping the same number
-- of times it took to find
-- each character matching
-- initially.
  end

-- print out each newly
-- randomly generated
-- character.
  print(sub(char,r,r),p*4,64)

-- bit of a pause.
  flip()

-- increase position in lookup
-- table.
  p+=1

-- keep looping until we have
-- covered every character.
until p==#t

-- neat, print at bottom.
print("",0,120)

-- loop forever
repeat
  key()
until forever

The output to start with is the character we need to encode, the next is the index, the next is the time it took for RND() to randomly pick the correct matching letter.

After the "ready to decode:" then it just reseeds the same random seed and recreates the event based entirely upon the number of iterations needed to randomly pick the correct letters again.

Really something to see !

And it actually runs faster than this, too. Take out the FLIP() after each PRINT statement and it's off like a shot.

P#68725 2019-10-10 17:30 ( Edited 2019-10-10 18:19)

Man I'm tired. Aren't you tired ? Good day of coding indeed. Even busier day tomorrow - but no time for coding then.

And then this evening I started messing with the RUN command, thinking I could clear all variables but start running code at a different location and got this:

::here::
print"*"
flip()
run(here)

Got it all typed in ? Good cause soon as you run it WHAMMO, not only does it crash it exits the whole blooming PICO-8 system like you pressed ALT-F4 ! Wow.

Any ideas what's going on here ?

P#68669 2019-10-09 04:37 ( Edited 2019-10-09 15:18)

dw817's BOOK READER AND WRITER

 
br
by dw817
Cart [#br-1#] | Code | 2019-10-08 | License: CC4-BY-NC-SA | Embed
4

First off, converting a book to a cart (not just for Pico-8) is not a unique idea.

I originally saw this being used back for Gameboy Color many years ago by Jeff Frohwein. At the time he was using a font very similar to ZEP's at a 3x5 pixel scale, but also included a distorted 3x4 letters for lowercase. Surprisingly it had 32k of storage for the story, so back then it was even more capable of storage than Pico-8 is of today.

There have been countless Bible programs for the pc which claim not only to contain the entire Bible but also have a search routine so you can look for certain passages and entries.

Today I use a bookreader on both my cellphone and portable PSP handheld game unit especially for the works of Arthur C. Clarke.

So ... this idea is not new and has in fact been tackled by many people long before the Pico-8 even existed. I have many interests myself, databases and compression just being a few. I was eventually going to get around to writing a book writer and reader, and here it is.

Having looked at dddaaannn's excellent version of a Pico-8 bookreader found HERE:

https://www.lexaloffle.com/bbs/?tid=2776

I realized I would be wanting to write one that would be simpler and not as complex or require much work for others to make use of my libs. And it may not compress as well, only(62-68%) but it would certainly contain everything in the single code needed so anyone could not only read the story enclosed but additionally add their own on top of it and compile for their own use.

And in less than 260-lines of source-code. That and not require any external batch files, Python files, manual compression, or what have you.

Nope ! It's ready to run right out of the box, batteries included. :)

First off when you run it you get a chance to read a bit of Alice In Wonderland. Use the UP and DOWN arrow keys to navigate by sentences and the LEFT and RIGHT to navigate by pages.

Notice you have a blue and red marker. The blue marker shows where your current bookmark is and the red marker shows where you are reading in the story.

Press (X) to set the bookmark and (O) to jump to it. Bookmarks are recorded so even if you run the program again later, it will remember that same bookmark you gave it.

In the code itself, it's very simple.

Set MODE to 0 (zero) if you just want to clear out the book RAM space so you can examine for yourself it truly is cleared.

Set MODE to 1 (one) and it will take whatever is in string variable STORY and both compress and stuff it all up in memory using up to 12288 bytes maximum for it.

Set MODE to 2 (default) and you can use the book reader included in the same program to examine your book.

Memory contents 0-1 is length of book.
Memory contents 2-3 is the current position of the bookmark.

And both of these elements are handled automatically in the code so you don't need to worry about them.

Also because this cart is self-modifying, once you compress a book of your choosing via the STORY variable, you can save off the .P8 or compile to EXE or whatever and it will automatically contain the story you put in there.

It should also be possible to write the code to handle more than one story here, you know, like Aesop's Fables, so you have a list of stories to choose from. Depending on the interest shown in this, I'll consider it.

P#68648 2019-10-08 17:18 ( Edited 2019-10-09 02:59)

 
dsm
by dw817
Cart [#dsm-0#] | Code | 2019-10-05 | License: CC4-BY-NC-SA | Embed
1

Thought I would put this out.

I've seen quite a few platformers up to now. Only a few of them use dual scrolling maps.

What is that ? Try out the cart to see for yourself.

Very small coding. Uses _INIT() and _DRAW(). Hit arrow keys left and right to scroll.
Also wraps correctly. Method is included in the code.

HOPE THIS HELPS !

P#68535 2019-10-05 18:56 ( Edited 2019-10-05 20:37)

 
mt
by dw817
Cart [#mt-0#] | Code | 2019-10-05 | License: CC4-BY-NC-SA | Embed

Here's something I've been working on for a-while. When I first saw Pico-8 and its limitation of 16-colors, I still knew somehow this could be done. And of course my first experiments always ran out of memory.

Why ? Well I was trying to encode a table of 256x256x256 colors. So I started to scale it down, from 256-animation frames to 16 or less - and it still took 4096-chars for a lookup table. But then it worked !

You have 6 modes to choose from:

-- 0=fade boy to circles
-- 1=fade boy to black
-- 2=fade boy to white
-- 3=fade boy wizard to girl (default)
-- 4=fade from black to girl
-- 5=fade from white to girl

Currently it's #3. If you want to look at the code and change the mode to test type:

load #mt-0

You coding demons out there might be able to get more speed out of this. Right now this is the upper limit of my coding ability.

P#68523 2019-10-05 16:34 ( Edited 2019-10-05 22:19)

Before I set out on a long journey of code, I wanted to know if Pico-8 had the ability to do something like this:

a=sum("(3+4)*2")
print(a)

Where the answer would come back 12. And yes, the statement needs to be in a string and be able to handle one or more parentheses math.

The TRS-80 could do this:

INPUT A$
PRINT A$

And B4GL could as well.

INPUT A$
CODE("PRINT "+A$)
P#68477 2019-10-04 20:45 ( Edited 2019-10-04 21:15)

Was curious to know if this was a problem ?

And possibly for others who need exact math in their calculations.

P#68461 2019-10-04 18:18 ( Edited 2019-10-10 21:17)

This may be old hat to you veterans, but is there an easier way to look for a non-value than this ?

function sum(a,b)
  if a==nil or a=="" or b==nil or b=="" then
    return
  end
((rest of function)
end
P#68453 2019-10-04 16:19 ( Edited 2019-10-04 18:14)

 
cds
by dw817
Cart [#cds-1#] | Code | 2019-10-04 | License: CC4-BY-NC-SA | Embed
1

Hmm ... You press ENTER in the BBS and it pauses, okay, run it local or use the spacebar instead.

Also, use the "=" as the backspace key and the "[" key for letter P.

As you know or should by watching how to write game in Pico-8 or doing so yourself, there is a nifty function called FGET() which will let you retrieve whether or not up to 8-flags are being set for a sprite of your choosing.

You can see pointing right at them HERE.

So how do they work ? Very simply. You click on them, up to 8 and using the command FGET followed by the sprite # you get the value of TRUE or FALSE whether or not that particular flag # (0-7) is set.

Not bad, but it could be better. That's where I come in with my new code. :)

So what does it do ?

Well for one thing is it lets you add a lot more definition and ease of retrieval for your sprites.

For instance, here is the string generated by the builder. You don't need to modify the string manually as I've created a program to edit each individual sprite, but it's still important to see what it looks like:

0[blank[[1[player[[2[floor[[3[wall[w[4[switch[[5[up[w[6[down[[7[treasure[w[8[empty[w[9[note[w[10[frenzy[[11[home[[12[zap[[17[blu[[18[bld[[19[bll[[20[blr[[63[marker[[

The data is separated into 3-parts. The first is the sprite # to contain this special data. The next is the name of the sprite, up to 8-chars you remember. The next is any sprite flags that exist for that sprite, and there can be up to 52 in any order for each sprite. You will see some of them have "W" set meaning Wall. So while you can name the sprites anything you want, you can also individually switch on and off the 52-flags available for them.

So what are the 52-flags ? That would be these:

.!?,;:#$%&-+*/=()<>{}|~^[email protected]

Assume in Pico-8 that these are uppercase. Why no digits ? Because if you call FFGET() with digits it assumes that you are requesting either the text name or status of the flags based on your numeric entry. Let's continue.

Now run the program above and select a sprite with the arrow keys, press ENTER and you can enter an up to 8-character name for it.

Press ENTER again and you can hit any of those characters you see below and that becomes a flag. This would be real nightmare to do with numbers and a modified FGET() though, right ?

Not to worry.

You see, the way I set it, you can retrieve all the following:

PRINT FFGET(number)
ANSWER: text name of that sprite.
PRINT FFGET(name)
ANSWER: number of that sprite on the sheet, zero being the first.
PRINT FFGET(1st character of name)
ANSWER: also the same number

Let's pause for a second. That last one is a little tricky. If you have more than one sprite that you have named with the same beginning character, it will only choose the last one calculated. It's not a reliable method if you have more than 26-sprites and you should choose the full-name or number each time in your code if you have dozens of sprites with definitions. Okay, let's continue. How are the flags handled ? Quite simply.

PRINT FFGET(number),(number)
ANSWER: the condition of whether that sprite #'s flag # is TRUE or FALSE
PRINT FFGET(name),(number)
ANSWER: same as above
PRINT FFGET(number),(single string character of flag)
ANSWER: same as above
PRINT FFGET(name),(string character of flag)
ANSWER: same as above

Let's see this in action with the sprite, WALL.

Quite a bit is happening, first off the total number of sprites (range) is 63 by printing SPR_TOTAL.

Then we are printing SPR_FLAGCHARS which are the 52-choices available to set flags for that individual sprite, ON or OFF, TRUE or FALSE.

Next is SPR_FLAGS which as described above is the string you need to copy to your code to have these flags set for your sprites.

Now we're using FFGET(). The wall is sprite #3. 48 is the letter "W" from the table. And you can see how it's possible to mix and match them quite thoroughly and still get the results you want.

If you only have one argument for FFGET() though, if it's a number it will retrieve the name of the sprite. If it's the name it will reverse and give you the number.

Example, to plot the player:

spr(ffget("player"),x,y)
or
spr(ffget("p"),x,y)
provided you only have one sprite name that begins with "p"

And that's it !

For your use, IMPORT your own sprite table. Run the program. Set your flags. Press "\" to save to clipboard. In a separate PICO-8 task (you should have 2 running). PASTE that string at the top of your _INIT() code. Then copy that one line in the first cart, the one called SPR_INIT(). Call that from your _INIT() code.

And you're done !

This is a considerably more robust flag system than PICO-8 came with. This demo also uses 1% of your onboard memory so it should work fine for you. I hope you use it and if you do, please let me know. Would love to see how you are getting on it.

And yes, those sprites included - I plan to make a game sometime later demonstrating the use of this new sprite library so no borrowing them for your projects just yet. :)

If you have any questions, and you might as this is a pretty busy upgrade going on here, feel free to let me know.

P#68427 2019-10-04 00:21 ( Edited 2019-10-04 03:45)

Alright so you've been using PICO for a-while now and have gotten used to the limitations on the sound. But then occasionally you come across a snazzy cart that has sound you are CERTAIN is just not possible with the limitations of Pico-8, or so you think.

So what gives ?

Well let's see if we can discover what's going on. First off save off the work on your current cart and REBOOT.

Let's start with a clean slate. Press the ESC key and ALT-RIGHT arrow key three times and TAB until you are at the sound editor.

Let's start with something basic. The rain sound. To make this, type out the following. You can create that "C" with letter Z.

Then click on the right-most number of LOOP to 1 so it shows LOOP 00 01 and press SPACEBAR to hear it.

Familiar. But is that as low pitch as the sound can go ? Well, yes and no.

Let's now discover something new. Hit SPACEBAR again to stop playing. Now, do you see that tiny little button just below the 2nd number for LOOP. Well, click on it.

Now this is different ! Your waveforms have been replaced with digits now 0-7 and you can see the button is active as it is GREEN.

Hit = and TAB to go to the next sound. From here, type out:

NOTICE the center number is no longer PINK but GREEN. This is a special case.

Set the loop here to 00 and 01 like the first sound and press SPACEBAR.

Well there's a sound you haven't heard in PICO before. So what's going on here.

When you use GREEN for your note instead of PINK you will be using THAT sound # as the instrument itself. In this case, you can see the zero is green so it means we are using the 1st sound as OUR instrument and are telling it to play it at an even lower pitch.

For low sounds you likely won't get much improvement as the audio is pretty raspy to begin with. But for high-pitch ? Well, let's try an experiment, shall we ?

Hit = and TAB again to go to the 3rd page for sounds. This time we're going to leave the LOOP at 00 and 00, but we ARE going to do something tricky.

Try this. First off hold down the "." key until your SPD is 255. We want it to play a good long time. Now type out the following:

Let's take a look at it letter per number.

It has a C so that's just the note. The next is is pitch, high as it will get. The GREEN number says to use - well - to use THIS sound as its instrument. This oughta be interesting. The next is 7, loud, and the last, the warble effect.

Get ready to hear a sound you've never heard in PICO before ! Press SPACEBAR to hear it.

Hope that didn't scare the cat ! :D

What's going on here ? Well, you're doing a feedback essentially. Like when a microphone gets too close to the speaker. You get this interesting warbling feedback effect. You could also get this trying to tune an AM radio.

So let's recap. The green number then means to use the SOUND # (0-7), sorry there are no more, to use as an instrument. So ... How could we use this to our advantage ? We've still got a bit of space. Let's do something fancy indeed.

If you have trouble typing this in, there's a copy of this cart at the end of the document.

Now on the next page have the following:

Notice that we have speed here set to 255 as well. So what do you think will happen ? Press SPACEBAR to play and find out.

Ah ! So it is indeed possible to play a sound that has tones as a single instrument itself and most importantly CHANGE THE KEY it is playing in.

And of course you can play something really high pitched as the instrument and then use a 2nd sound to play it even higher pitch getting some interesting sound effects not possible before this.

What amazing sounds will you discover ? Feel free to share.

Here is the sound set I put together.

Cart [#jumugujido-0#] | Code | 2019-10-03 | No License | Embed

HOPE THIS HELPS !

P#68406 2019-10-03 17:14 ( Edited 2019-10-03 19:34)

View Older Posts
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-10-21 17:57 | 0.279s | 4194k | Q:224