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

Using the graphics pages to store data

Root / Programming Questions / [.]

MZ952Created:
OPTION STRICT
OPTION DEFINT

DEF WR _N,X,Y
 DIM A,R,G,B,N=ABS(_N)
 A=(SGN(_N)==-1)
 R=N DIV 31 DIV 31*8
 G=N DIV 31 MOD 31*8
 B=N MOD 31*8
 GPSET X,Y,RGB(A,R,G,B)
END

DEF RD(X,Y)
 DIM A,R,G,B,N
 RGBREAD GSPOIT(X,Y) OUT A,R,G,B
 N=R/8*31*31+G/8*31+B/8
 IF A THEN N=N*-1 ENDIF
 RETURN N
END
I never really bothered screwing around with color codes and color conversion before. This method covers the integers from -30751 to 30751. Is there a better way?

Just use GSAVE/GLOAD with the color conversion flag turned off, to read/write raw 16 bit data.

Lol nice. SB should have a function to toggle color conversion with graphic functions. The graphics screen can't store 32 bit values, can it? So, what is color conversion really for?

It's so you can use normal 32 bit color codes for everything.