Wrapping my head around the palette

Discuss game and other programming topics not specifically covered in another forum

Moderator: Programming Moderators

User avatar
sol_hsa
Posts: 273
Joined: Fri Jun 02, 2017 10:10 am
Location: Finland
Contact:

Wrapping my head around the palette

Postby sol_hsa » Sun May 10, 2020 8:17 pm

As I understand it, layer2 uses 8 bit pixels that are indexes to the palette, which is 256 colors out of 8x8x8=512.

These colors, when set survive until the next cold boot.

Assuming one is making a .nex app which takes over the machine and will need a reboot to exit, is there a part of the palette that should be left alone in order not to mess up warm reboots? Or does the system set the necessary palette entries needed for std graphics to work?

I do a understand I'd get answers to these by simply trying them out, but I don't have my home grown .nex framework up yet..

Ped7g
Posts: 256
Joined: Mon Jul 16, 2018 7:11 pm

Re: Wrapping my head around the palette

Postby Ped7g » Sun May 10, 2020 8:49 pm

generally you don't care about what happens after soft/hard reset (except the features where soft reset is part of the setup step, like enabling particular expansion bus config and hw config to run something particular after soft reset).

NextZXOS should be robust enough to recover, if not, report it and discuss. (L2 palette is all yours for sure)

User avatar
SevenFFF
Posts: 565
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: Wrapping my head around the palette

Postby SevenFFF » Sun May 10, 2020 10:02 pm

NextZXOS sets the necessary palette entries needed for std graphics to work, which you trigger during soft reset.it also turns layer 2, sprites, tilemap etc off. Soft reset should usually give you a clean set of defaults for everything that NextZXOS uses.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins

User avatar
varmfskii
Posts: 287
Joined: Fri Jun 23, 2017 1:13 pm
Location: Stone Mountain, GA USA

Re: Wrapping my head around the palette

Postby varmfskii » Mon May 11, 2020 4:00 pm

There are several (8 iirc) 256 colour palettes in the ZX Next. Layer2 has two just for its own use. Layer 2 uses 8-bit pixels in 256x192 an 320x256 mode, but it used 4-bit pixels in 640x256 mode.
Backer #2741 - TS2068, Byte, ZX Evolution

User avatar
sol_hsa
Posts: 273
Joined: Fri Jun 02, 2017 10:10 am
Location: Finland
Contact:

Re: Wrapping my head around the palette

Postby sol_hsa » Mon May 11, 2020 5:35 pm

varmfskii wrote:
Mon May 11, 2020 4:00 pm
There are several (8 iirc) 256 colour palettes in the ZX Next. Layer2 has two just for its own use. Layer 2 uses 8-bit pixels in 256x192 an 320x256 mode, but it used 4-bit pixels in 640x256 mode.
Okay, you totally lost me. I think I've browsed through all the register specs etc but I haven't seen any mention of 320x256 or 640x256 modes. Except if those are the timex ones. Also, two palettes for the layer2? I haven't seen anything that refers to that, or how to set this alternative palette or what it's used for.

If you're talking about some implementation detail re: priority pixels, that would make sense.

User avatar
varmfskii
Posts: 287
Joined: Fri Jun 23, 2017 1:13 pm
Location: Stone Mountain, GA USA

Re: Wrapping my head around the palette

Postby varmfskii » Mon May 11, 2020 6:12 pm

Register (R/W) $70 (112) ⇒ Layer 2 Control
• bits 7-6 = Reserved, must be 0
• bits 5-4 = Resolution (00 on soft reset)
– 00 = 256 × 192 × 256
– 01 = 320 × 256 × 256
– 10 = 640 × 256 × 16
– 11 = Do not use
• bits 3-0 = Palette offset ($0 on soft reset)
Backer #2741 - TS2068, Byte, ZX Evolution

User avatar
varmfskii
Posts: 287
Joined: Fri Jun 23, 2017 1:13 pm
Location: Stone Mountain, GA USA

Re: Wrapping my head around the palette

Postby varmfskii » Mon May 11, 2020 6:17 pm

Register (R/W) $43 (67) ⇒ Palette Control
• bit 7 = Disable palette write auto-increment.
• bits 6-4 = Select palette for reading or writing:
– 000 = ULA first palette
– 100 = ULA second palette
– 001 = Layer 2 first palette
– 101 = Layer 2 second palette
– 010 = Sprite first palette
– 110 = Sprite second palette
– 011 = Layer 3 first palette
– 111 = Layer 3 second palette
• bit 3 = Select Sprite palette (0 = first palette, 1 = second palette)
• bit 2 = Select Layer 2 palette (0 = first palette, 1 = second palette)
• bit 1 = Select ULA palette (0 = first palette, 1 = second palette)
• bit 0 = Enable EnhancedULA mode if 1. (0 after a reset)
Backer #2741 - TS2068, Byte, ZX Evolution

User avatar
varmfskii
Posts: 287
Joined: Fri Jun 23, 2017 1:13 pm
Location: Stone Mountain, GA USA

Re: Wrapping my head around the palette

Postby varmfskii » Mon May 11, 2020 6:18 pm

Which register specs have you been looking through? Register 112 ($70) is not in the printed docs that came with the machines.
Backer #2741 - TS2068, Byte, ZX Evolution

User avatar
sol_hsa
Posts: 273
Joined: Fri Jun 02, 2017 10:10 am
Location: Finland
Contact:

Re: Wrapping my head around the palette

Postby sol_hsa » Mon May 11, 2020 6:58 pm

Well, I'll be damned. I've been hopping from https://wiki.specnext.dev/Layer_2 to relevant register pages, none of which were the ones you quoted. That's probably why.

User avatar
SevenFFF
Posts: 565
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: Wrapping my head around the palette

Postby SevenFFF » Mon May 11, 2020 7:22 pm

Not sure how the wiki got wrong, but it's sometimes not been easy keeping it accurate and up to date.

If you're after the absolute source of truth, these two documents describe the hardware one nextreg and port at a time. Allen maintains these and keeps them in sync as he makes changes to the core, so you can rely on them:

https://gitlab.com/SpectrumNext/ZX_Spec ... extreg.txt

https://gitlab.com/SpectrumNext/ZX_Spec ... /ports.txt
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins


Who is online

Users browsing this forum: No registered users and 3 guests