+Stephen Posted May 20, 2022 Share Posted May 20, 2022 Following up on my previous question about text mode. I have created a custom palette and noticed when using Altirra 4.10 test 11 to debug, that certain values do not get saved properly. I see in the documentation, that only bits 7-1 are used, hence the 21-bit palette specification. To me, this would mean that only even numbers are allowed. But it's not working this way. 55 becomes 54, AA becomes AB, but FF does save as FF. This makes no sense - 54 is even, but AB and FF are odd, therefore have bit 0 set. I cannot confirm this on real hardware, because the palette registers are unfortunately read-only. This is not causing a problem, I am just curious as to why this is happening. Here's a little snippet of TBXL code that demonstrates this. It assumes VBXE is at $D600. 10 CSEL=$D644:PSEL=$D645 20 CR=$D646:CG=$D647:CB=$D648 30 POKE CSEL,0:POKE PSEL,1 100 FOR A=0 TO 255 110 POKE CR,A:POKE CG,A:POKE CB,A 120 NEXT A .vbxe_pal 100 L100 $100: 000000 000000 020202 020202 040404 040404 060606 060606 080808 080808 0A0A0A 0A0A0A 0C0C0C 0C0C0C 0E0E0E 0E0E0E $110: 101010 101010 121212 121212 141414 141414 161616 161616 181818 181818 1A1A1A 1A1A1A 1C1C1C 1C1C1C 1E1E1E 1E1E1E $120: 202020 202020 222222 222222 242424 242424 262626 262626 282828 282828 2A2A2A 2A2A2A 2C2C2C 2C2C2C 2E2E2E 2E2E2E $130: 303030 303030 323232 323232 343434 343434 363636 363636 383838 383838 3A3A3A 3A3A3A 3C3C3C 3C3C3C 3E3E3E 3E3E3E $140: 404040 404040 424242 424242 444444 444444 464646 464646 484848 484848 4A4A4A 4A4A4A 4C4C4C 4C4C4C 4E4E4E 4E4E4E $150: 505050 505050 525252 525252 545454 545454 565656 565656 585858 585858 5A5A5A 5A5A5A 5C5C5C 5C5C5C 5E5E5E 5E5E5E $160: 606060 606060 626262 626262 646464 646464 666666 666666 686868 686868 6A6A6A 6A6A6A 6C6C6C 6C6C6C 6E6E6E 6E6E6E $170: 707070 707070 727272 727272 747474 747474 767676 767676 787878 787878 7A7A7A 7A7A7A 7C7C7C 7C7C7C 7E7E7E 7E7E7E $180: 818181 818181 838383 838383 858585 858585 878787 878787 898989 898989 8B8B8B 8B8B8B 8D8D8D 8D8D8D 8F8F8F 8F8F8F $190: 919191 919191 939393 939393 959595 959595 979797 979797 999999 999999 9B9B9B 9B9B9B 9D9D9D 9D9D9D 9F9F9F 9F9F9F $1A0: A1A1A1 A1A1A1 A3A3A3 A3A3A3 A5A5A5 A5A5A5 A7A7A7 A7A7A7 A9A9A9 A9A9A9 ABABAB ABABAB ADADAD ADADAD AFAFAF AFAFAF $1B0: B1B1B1 B1B1B1 B3B3B3 B3B3B3 B5B5B5 B5B5B5 B7B7B7 B7B7B7 B9B9B9 B9B9B9 BBBBBB BBBBBB BDBDBD BDBDBD BFBFBF BFBFBF $1C0: C1C1C1 C1C1C1 C3C3C3 C3C3C3 C5C5C5 C5C5C5 C7C7C7 C7C7C7 C9C9C9 C9C9C9 CBCBCB CBCBCB CDCDCD CDCDCD CFCFCF CFCFCF $1D0: D1D1D1 D1D1D1 D3D3D3 D3D3D3 D5D5D5 D5D5D5 D7D7D7 D7D7D7 D9D9D9 D9D9D9 DBDBDB DBDBDB DDDDDD DDDDDD DFDFDF DFDFDF $1E0: E1E1E1 E1E1E1 E3E3E3 E3E3E3 E5E5E5 E5E5E5 E7E7E7 E7E7E7 E9E9E9 E9E9E9 EBEBEB EBEBEB EDEDED EDEDED EFEFEF EFEFEF $1F0: F1F1F1 F1F1F1 F3F3F3 F3F3F3 F5F5F5 F5F5F5 F7F7F7 F7F7F7 F9F9F9 F9F9F9 FBFBFB FBFBFB FDFDFD FDFDFD FFFFFF FFFFFF 54 01010100 Even AB 10101011 Odd FF 11111111 Odd Quote Link to comment Share on other sites More sharing options...
shanti77 Posted May 20, 2022 Share Posted May 20, 2022 I don't know exactly what you mean. The palette in VBXE is 21 bits long, which means that in the color component (RGB) the youngest bit is ignored. So the color ($c8,$c8,$c8) is identical to the color ($c9,$c9,$c9), we have the same in Atari when we do not use GTIA modes, the color $0a is the same as $0b. 1 Quote Link to comment Share on other sites More sharing options...
phaeron Posted May 20, 2022 Share Posted May 20, 2022 This is an artifact of Altirra's internal implementation and the .vbxe_pal command. When writes to the VBXE palette occur, the RGB values are expanded from 7 bits to 8 bits by replicating the MSB into the LSB so that VBXE 21-bit white maps to 24-bit RGB white. The top 7 bits should match what was written through the VBXE control registers. On the actual hardware, this would instead be implicit in the digital to analog conversion since there is no intermediate second digital pixel format. Note that the values written to the palette and reported by this command are the architectural color values. The actual color values used for rendering are subject to the color correction mode in color settings, in particular converting from NTSC color space to sRGB. The post-conversion colors are what you will see if you sample colors from the final rendered image. 1 1 Quote Link to comment Share on other sites More sharing options...
+Stephen Posted May 20, 2022 Author Share Posted May 20, 2022 1 hour ago, shanti77 said: I don't know exactly what you mean. The palette in VBXE is 21 bits long, which means that in the color component (RGB) the youngest bit is ignored. So the color ($c8,$c8,$c8) is identical to the color ($c9,$c9,$c9), we have the same in Atari when we do not use GTIA modes, the color $0a is the same as $0b. Right - I expected then, that only "even" numbers would be used. My confusion stemmed from the fact that writing 55 resulted in 54 being stored (even), writing 7A resulted in 7A being stored (even), but writing AA resulted in AB being stored (an odd value) as well as the fact that FF was being stored (an odd value). Quote Link to comment Share on other sites More sharing options...
shanti77 Posted May 22, 2022 Share Posted May 22, 2022 @phaeron So now I also have a question. I set the colors like this: set_colors0 ldy #$45 mva #1 (fx_ptr),y ; PSEL ,nr palety ldx #0 mva #1 pom0 @ lda pom0 ldy #$44 sta (fx_ptr),y ; CSEL ,nr koloru clc adc #16 sta pom0 ldy #$46 ; CR lda #171 sta (fx_ptr),y ;RED iny sta (fx_ptr),y ;GREEN iny sta (fx_ptr),y ;BLUE, nr_koloru++ ldy #$46 ; CR lda tab_color0,x sta (fx_ptr),y ;RED iny inx lda tab_color0,x sta (fx_ptr),y ;GREEN iny inx lda tab_color0,x sta (fx_ptr),y ;BLUE, nr_koloru++ inx ldy #$46 ; CR lda #0 sta (fx_ptr),y ;RED iny sta (fx_ptr),y ;GREEN iny sta (fx_ptr),y ;BLUE, nr_koloru++ cpx #16*3 bcc @- rts tab_color0 dta 0,0,0 ;black dta 255,255,255 ;1=white dta 137,64,54 ;2=red dta 122,191,199 ;3=cyan dta 138,70,174 ;4=purple dta 104,169,65 ;5=green dta 62,49,162 ;6=blue dta 208,220,113 ;7=yellow dta 144,95,37 ;8=orange dta 92,71,0 ;9=brown dta 187,119,109 ;10=pink dta 85,85,85 ;11=dark gray dta 128,128,128 ;12=medium gray dta 172,234,136 ;13=lite green dta 124,112,218 ;14=lite blue dta 171,171,171 ;15=lite gray As a result, he gets such a palette: $100: 000000 ABABAB 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $110: 000000 ABABAB FFFFFF 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $120: 000000 ABABAB 894036 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $130: 000000 ABABAB 7ABFC7 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $140: 000000 ABABAB 8B46AF 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $150: 000000 ABABAB 68A940 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $160: 000000 ABABAB 3E30A3 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $170: 000000 ABABAB D1DD70 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $180: 000000 B7B7B7 4A38AD 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $190: 000000 ABABAB 5C4600 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $1A0: 000000 ABABAB BB766C 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $1B0: 000000 ABABAB 545454 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $1C0: 000000 ABABAB 818181 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $1D0: 000000 ABABAB ADEB89 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $1E0: 000000 ABABAB 7C70DB 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $1F0: 000000 ABABAB ABABAB 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 Why are the $181 and $182 (orange) colors wrong? Quote Link to comment Share on other sites More sharing options...
shanti77 Posted May 22, 2022 Share Posted May 22, 2022 However, the bug was in my code, as I wrote this I didn't know that Altirra has extra commands for VBXE. Now I found the error easily. There was no question 1 Quote Link to comment Share on other sites More sharing options...
+Stephen Posted May 22, 2022 Author Share Posted May 22, 2022 Just wanted to say thanks again for everyone for responding. Here's my palette (via https://en.wikipedia.org/wiki/ANSI_escape_code - VGA): $100: 000000 AB0000 00AB00 AB5400 0000AB AB00AB 00ABAB ABABAB 545454 FF5454 54FF54 FFFF54 5454FF FF54FF 54FFFF FFFFFF $110: 000000 AB0000 00AB00 AB5400 0000AB AB00AB 00ABAB ABABAB 545454 FF5454 54FF54 FFFF54 5454FF FF54FF 54FFFF FFFFFF $120: 000000 AB0000 00AB00 AB5400 0000AB AB00AB 00ABAB ABABAB 545454 FF5454 54FF54 FFFF54 5454FF FF54FF 54FFFF FFFFFF $130: 000000 AB0000 00AB00 AB5400 0000AB AB00AB 00ABAB ABABAB 545454 FF5454 54FF54 FFFF54 5454FF FF54FF 54FFFF FFFFFF $140: 000000 AB0000 00AB00 AB5400 0000AB AB00AB 00ABAB ABABAB 545454 FF5454 54FF54 FFFF54 5454FF FF54FF 54FFFF FFFFFF $150: 000000 AB0000 00AB00 AB5400 0000AB AB00AB 00ABAB ABABAB 545454 FF5454 54FF54 FFFF54 5454FF FF54FF 54FFFF FFFFFF $160: 000000 AB0000 00AB00 AB5400 0000AB AB00AB 00ABAB ABABAB 545454 FF5454 54FF54 FFFF54 5454FF FF54FF 54FFFF FFFFFF $170: 000000 AB0000 00AB00 AB5400 0000AB AB00AB 00ABAB ABABAB 545454 FF5454 54FF54 FFFF54 5454FF FF54FF 54FFFF FFFFFF $180: 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 $190: AB0000 AB0000 AB0000 AB0000 AB0000 AB0000 AB0000 AB0000 AB0000 AB0000 AB0000 AB0000 AB0000 AB0000 AB0000 AB0000 $1A0: 00AB00 00AB00 00AB00 00AB00 00AB00 00AB00 00AB00 00AB00 00AB00 00AB00 00AB00 00AB00 00AB00 00AB00 00AB00 00AB00 $1B0: AB5400 AB5400 AB5400 AB5400 AB5400 AB5400 AB5400 AB5400 AB5400 AB5400 AB5400 AB5400 AB5400 AB5400 AB5400 AB5400 $1C0: 0000AB 0000AB 0000AB 0000AB 0000AB 0000AB 0000AB 0000AB 0000AB 0000AB 0000AB 0000AB 0000AB 0000AB 0000AB 0000AB $1D0: AB00AB AB00AB AB00AB AB00AB AB00AB AB00AB AB00AB AB00AB AB00AB AB00AB AB00AB AB00AB AB00AB AB00AB AB00AB AB00AB $1E0: 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB 00ABAB $1F0: ABABAB ABABAB ABABAB ABABAB ABABAB ABABAB ABABAB ABABAB ABABAB ABABAB ABABAB ABABAB ABABAB ABABAB ABABAB ABABAB Using an original IBM CGA font, this is what it will do: Please don't tell me yellow is orange - even my colour-blind ass can see it. I followed the above linked article for the original VGA look. If I were to include one or two other palettes from that article, which do you feel would be best? Quote Link to comment Share on other sites More sharing options...
Rybags Posted May 23, 2022 Share Posted May 23, 2022 Such a palette is probably based on 2 bits/channel RGB - yellow just being the mix of green/red so you can't go too wrong. Quote Link to comment Share on other sites More sharing options...
+Stephen Posted May 23, 2022 Author Share Posted May 23, 2022 33 minutes ago, Rybags said: Such a palette is probably based on 2 bits/channel RGB - yellow just being the mix of green/red so you can't go too wrong. The standard yellow is orange - I don't like it, but I based it 100% on the original VGA paletts as referenced https://en.wikipedia.org/wiki/ANSI_escape_code The footnote explains it: "On terminals based on CGA compatible hardware, such as ANSI.SYS running on DOS, this normal intensity foreground color is rendered as Orange. CGA RGBI monitors contained hardware to modify the dark yellow color to an orange/brown color by reducing the green component." Since I have 2 free palettes, I am considering at least one with a proper yellow. Quote Link to comment Share on other sites More sharing options...
Rybags Posted May 23, 2022 Share Posted May 23, 2022 Yellow is supposedly a tricky colour to do well. There was an LCD TV being sold not long ago that had yellow subpixels as well as the normal RGB. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.