LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Is it possible to check color code of chars on the text screen?

Root / Programming Questions / [.]

MZ952Created:
Basically the title. If I
COLOR 15,0?"ABC"
Is there any way, however extraordinary, to infer the color codes of those chars, or is it lost unless otherwise stored?

No, unfortunately you'll have to store the color code.

Shoot

What are you trying to make?

If you don't mind using the Graphics layer instead of a Text layer, you could use GPUTCHR to write text and GPGET in conjunction with a 2D loop to tell what color it is

What are you trying to make?
Probably nothing important
If you don't mind using the Graphics layer instead of a Text layer, you could use GPUTCHR to write text and GPGET in conjunction with a 2D loop to tell what color it is
Yeah I know. I was looking for text-screen-specific.

You CAN in SB4, but for some reason it's more complicated than it needs to be. They expanded CHKCHR to also return display attributes, but not color, so you have to refer to TSAVE or TARRAY to do that.
'option 1
DEF CHRCOL(S%, X%, Y%)
 RETURN TARRAY(S%)[Y%,X%*2+1]
END

'option 2
DEF CHRCOL(S%, X%, Y%)
 DIM T%[2]
 TSAVE S%, X%, Y%, 1, 1, T%
 RETURN T%[1]
END

This might be a bit over the top for a text editor... But you could use a screen full of 8x8 sprites instead of the text layer. Where each sprite can be any character or blank space. Probably too ridiculous, but it would mean that you could animate each letter individually, as well as get and set their color on the fly.

This might be a bit over the top for a text editor... But you could use a screen full of 8x8 sprites instead of the text layer. Where each sprite can be any character or blank space. Probably too ridiculous, but it would mean that you could animate each letter individually, as well as get and set their color on the fly.
I... was just thinking about this. It might be worth exploring. I would need to create a mock text screen using either:
  • Individual 8x8 sprites or;
  • A 400x240 sprite displaying part of the sprite page
  • Of the 512 available sprites, dynamically allocate sprite management numbers to represent certain common chars visible on screen
If you've got a screen full of random chars, that last one is likely to fail. To do the second, I'd need to like GPUTCHR on the sprite page, which, at that point, I might as well not even use sprites but instead regular graphics (which I don't). To do the first option, I'd need probably a combination of option 1 and two. I wouldn't be able to fill a screen full of random char values either way, though.

Other than that, you could build a 2D array in which the RGB values are arranged in a grid. And every time you update the text screen you update the array with the color values. I know that doesn't satisfy the "without storing it" requirement but it might give you the most functionality for the least amount of work

That's what I started doing. I created a pseudo COLOR function that updated values in an array, based on previous LOCATE params from CSRX, CSRY. But... What I was trying to do was sort of silly in the first place. (I'm not even going to mention it.) So I don't have much use for it anymore.
Spoilerokay, fine, I was going to use it to take text "screenshots" that my program (text editor) could use to make a cool uh window changing animation.

Polish is important, never doubt that. Sometimes a good transition can even help maintain a user's train of thought. If remembering the colors doesn't work out, you could still have a transition but perhaps immediately on activation it goes grayscale, or bright yellow, or cyan - depending on existing color scheme