Crash-tan
And that's 1.39.0... in the same week!
Crash BASIC 1.39.0 Release Notes
written by Crash-tan
THE "PICK ANY COLOR YOU WANT" UPDATE
For your whole life with me, color has meant a number 0 to 255 — an
index into a 256-slot palette. Want a specific shade? Better hope it's in
the palette, or go redefine a slot first. It's the honest old-school way,
and it's staying exactly as it is by default. But sometimes you just want
to say "draw this in #FF8800 orange" and be done.
As of 1.39.0, you can:
SET PALETTE OFF ' enter direct-color mode
COLOR &HFFFF8800 ' opaque orange — A=FF, R=FF, G=88, B=00
PSET (10, 10), &H8000FF00 ' 50%-transparent green, no palette needed
SET PALETTE ON ' back to palette indices (the default)In direct-color mode a color value is the color — a literal0xAARRGGBB (alpha, red, green, blue). Transparency comes from the alpha
byte (&H00...... = fully transparent). No palette slot, no setup, every
color in the 32-bit space available immediately. Flip back to SET PALETTE ON and you're indexed again. Mix and match per-section however
you like.
Hexadecimal & octal numbers: &H and &O
To make that orange bearable to type, whole numbers can now be written in
hex and octal, the classic BASIC way:
x = &HFF ' hex 255 (also &hff — case doesn't matter)
y = &O17 ' octal 15
c = &HFFFF8800 ' that orange again&H for hexadecimal, &O for octal. They're plain integers — use them
anywhere a number goes, not just colors. (Heads up: &H.../&O... now
take precedence over the & name-dereference operator. &HFF is always
hex 255; to dereference a variable, its name needs a non-hex character —&Handler is still a deref, since "andler" isn't all hex digits.)
The palette grew up (no more 256-color ceiling)
The palette is no longer capped at 256 entries. PALETTE accepts any
index you give it and the palette grows to fit — index 300, 5000,
whatever you need:
PALETTE 1000, &HFF112233 ' totally fine now
PSET (50, 50), 1000The old "color index out of range (0–255)" error is gone — it was a
pointless restriction. Indices were always stored as integers; now they
actually behave like it. -1 still means transparent when you're
drawing, same as ever.
Polish that ships with all this
- Clean edges on see-through shapes. A filled box (
LINE … BF) or a
solid circle/polygon drawn in a semi-transparent color now has a
uniform edge — no more darker, double-blended border where the
outline used to get painted twice over the fill. (You'd never have
noticed with opaque palette colors; with alpha it was obvious.) - A friendlier
CIRCLEtypo. Fat-finger a color value into the
radius slot —CIRCLE (60,60), &HBBFFFFFF— and instead of the
renderer falling over, you get a clear "radius out of range" message
pointing you at the argument order. Much nicer than a hang.
Compatibility notes
- Nothing breaks. Palette mode is still the default. Every existing
program behaves identically —SET PALETTEis opt-in, color indices
still work, and the default VGA palette is unchanged. &H/&Oare new syntax, not changes to anything that existed —
except the one&-precedence note above (a deref of a hex-looking name
like&HFFnow reads as hex; vanishingly rare in practice).- Direct vs. palette is a per-section choice. Toggle
SET PALETTE OFF/ONas often as you like; it only affects how color values are
interpreted from that point on.
256 colors walked so 16 million could run.
— Crash-tan