src/mess/drivers/socrates.c
| r5322 | r5323 | |
| 160 | 160 | socrates_set_ram_bank( space->machine ); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | /* NTSC-based Palette stuff */ |
| 164 | // max for I and Q |
| 165 | #define M_I 0.5957 |
| 166 | #define M_Q 0.5226 |
| 167 | /* luma amplitudes, measured on scope */ |
| 168 | #define LUMAMAX 1.420 |
| 169 | #define LUMA_COL_0 0.355, 0.139, 0.205, 0, 0.569, 0.355, 0.419, 0.205, 0.502, 0.288, 0.358, 0.142, 0.720, 0.502, 0.571, 0.358, |
| 170 | #define LUMA_COL_COMMON 0.52, 0.52, 0.52, 0.52, 0.734, 0.734, 0.734, 0.734, 0.667, 0.667, 0.667, 0.667, 0.885, 0.885, 0.885, 0.885, |
| 171 | #define LUMA_COL_2 0.574, 0.6565, 0.625, 0.71, 0.792, 0.87, 0.8425, 0.925, 0.724, 0.8055, 0.7825, 0.865, 0.94275, 1.0225, 0.99555, 1.07525, |
| 172 | #define LUMA_COL_5 0.4585, 0.382, 0.4065, 0.337, 0.6715, 0.5975, 0.6205, 0.5465, 0.6075, 0.531, 0.5555, 0.45, 0.8255, 0.7455, 0.774, 0.6985, |
| 173 | #define LUMA_COL_F 0.690, 0.904, 0.830, 1.053, 0.910, 1.120, 1.053, 1.270, 0.840, 1.053, 0.990, 1.202, 1.053, 1.270, 1.202, 1.420 |
| 174 | /* chroma amplitudes, measured on scope */ |
| 175 | #define CHROMAMAX 0.42075 |
| 176 | #define CHROMA_COL_COMMON 0.148, 0.3125, 0.26475, 0.42075, 0.148, 0.3125, 0.26475, 0.42075, 0.148, 0.3125, 0.26475, 0.42075, 0.148, 0.3125, 0.26475, 0.42075, |
| 177 | #define CHROMA_COL_2 0.125125, 0.27525, 0.230225, 0.384875, 0.125125, 0.27525, 0.230225, 0.384875, 0.125125, 0.27525, 0.230225, 0.384875, 0.125125, 0.27525, 0.230225, 0.384875, |
| 178 | #define CHROMA_COL_5 0.1235, 0.2695, 0.22625, 0.378, 0.1235, 0.2695, 0.22625, 0.378, 0.1235, 0.2695, 0.22625, 0.378, 0.1235, 0.2695, 0.22625, 0.378, |
| 179 | // gamma: this needs to be messed with... may differ on different systems... attach to slider somehow? |
| 180 | #define GAMMA 2.2 |
| 163 | 181 | |
| 182 | static rgb_t socrates_create_color(UINT8 color) |
| 183 | { |
| 184 | rgb_t composedcolor; |
| 185 | double lumatable[256] = { |
| 186 | LUMA_COL_0 |
| 187 | LUMA_COL_COMMON |
| 188 | LUMA_COL_2 |
| 189 | LUMA_COL_COMMON |
| 190 | LUMA_COL_COMMON |
| 191 | LUMA_COL_5 |
| 192 | LUMA_COL_COMMON |
| 193 | LUMA_COL_COMMON |
| 194 | LUMA_COL_COMMON |
| 195 | LUMA_COL_COMMON |
| 196 | LUMA_COL_COMMON |
| 197 | LUMA_COL_COMMON |
| 198 | LUMA_COL_COMMON |
| 199 | LUMA_COL_COMMON |
| 200 | LUMA_COL_COMMON |
| 201 | LUMA_COL_F |
| 202 | }; |
| 203 | double chromaintensity[256] = { |
| 204 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
| 205 | CHROMA_COL_COMMON |
| 206 | CHROMA_COL_2 |
| 207 | CHROMA_COL_COMMON |
| 208 | CHROMA_COL_COMMON |
| 209 | CHROMA_COL_5 |
| 210 | CHROMA_COL_COMMON |
| 211 | CHROMA_COL_COMMON |
| 212 | CHROMA_COL_COMMON |
| 213 | CHROMA_COL_COMMON |
| 214 | CHROMA_COL_COMMON |
| 215 | CHROMA_COL_COMMON |
| 216 | CHROMA_COL_COMMON |
| 217 | CHROMA_COL_COMMON |
| 218 | CHROMA_COL_COMMON |
| 219 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 |
| 220 | }; |
| 221 | /* chroma colors and phases: |
| 222 | 0: black-thru-grey (0 assumed chroma) |
| 223 | 1: purple (90 chroma seems correct) |
| 224 | 2: light blue/green (210 or 240 chroma, 210 seems slightly closer) |
| 225 | 3: bright blue (150 seems correct) |
| 226 | 4: green (270 seems correct) |
| 227 | 5: red (30 seems correct, does have some blue in it) |
| 228 | 6: orange (0 seems correct, does have some red in it) |
| 229 | 7: yellow/gold (330 is closest but conflicts with color C, hence 315 seems close, and must have its own delay line separate from the other phases which use a standard 12 phase scheme) |
| 230 | 8: blue with a hint of green in it (180 seems correct) |
| 231 | 9: blue-green (210 seems correct) |
| 232 | A: forest green (240 seems correct) |
| 233 | B: yellow-green (300 seems correct) |
| 234 | C: yellow-orange (330 is close but this conflicts with color 7, and is not quite the same; color 7 has more green in it than color C) |
| 235 | D: magenta (60 is closest) |
| 236 | E: blue-purple (more blue than color 1, 120 is closest) |
| 237 | F: grey-thru-white (0 assumed chroma) |
| 238 | */ |
| 239 | double phaseangle[16] = { 0, 90, 210, 150, 270, 30, 0, 315, 180, 210, 240, 300, 330, 60, 120, 0 }; // note: these are guessed, not measured yet! |
| 240 | int chromaindex = color&0x0F; |
| 241 | int swappedcolor = ((color&0xf0)>>4)|((color&0x0f)<<4); |
| 242 | double finalY, finalI, finalQ, finalR, finalG, finalB; |
| 243 | finalY = (1/LUMAMAX) * lumatable[swappedcolor]; |
| 244 | finalI = (M_I * (cos((phaseangle[chromaindex]/180)*3.141592653589793)))* ((1/CHROMAMAX)*chromaintensity[swappedcolor]); |
| 245 | finalQ = (M_Q * (sin((phaseangle[chromaindex]/180)*3.141592653589793)))* ((1/CHROMAMAX)*chromaintensity[swappedcolor]); |
| 246 | if (finalY > 1) finalY = 1; // clamp luma |
| 247 | /* calculate the R, G and B values here, neato matrix math */ |
| 248 | finalR = (finalY*1)+(finalI*0.9563)+(finalQ*0.6210); |
| 249 | finalG = (finalY*1)+(finalI*-0.2721)+(finalQ*-0.6474); |
| 250 | finalB = (finalY*1)+(finalI*-1.1070)+(finalQ*1.7046); |
| 251 | /* scale/clamp to 0-255 range */ |
| 252 | if (finalR<0) finalR = 0; |
| 253 | if (finalR>1) finalR = 1; |
| 254 | if (finalG<0) finalG = 0; |
| 255 | if (finalG>1) finalG = 1; |
| 256 | if (finalB<0) finalB = 0; |
| 257 | if (finalB>1) finalB = 1; |
| 258 | // gamma correction: 1.0 to GAMMA: |
| 259 | finalR = pow(finalR, 1/GAMMA)*255; |
| 260 | finalG = pow(finalG, 1/GAMMA)*255; |
| 261 | finalB = pow(finalB, 1/GAMMA)*255; |
| 262 | composedcolor = MAKE_RGB((int)finalR,(int)finalG,(int)finalB); |
| 263 | return composedcolor; |
| 264 | } |
| 265 | |
| 266 | static rgb_t socrates_palette[256] = { |
| 267 | }; |
| 268 | |
| 269 | PALETTE_INIT( socrates ) |
| 270 | { |
| 271 | int i; // iterator |
| 272 | for (i = 0; i < 256; i++) |
| 273 | { |
| 274 | socrates_palette[i] = socrates_create_color(i); |
| 275 | } |
| 276 | palette_set_colors(machine, 0, socrates_palette, ARRAY_LENGTH(socrates_palette)); |
| 277 | } |
| 278 | |
| 164 | 279 | /****************************************************************************** |
| 165 | 280 | Address Maps |
| 166 | 281 | ******************************************************************************/ |
| r5322 | r5323 | |
| 218 | 333 | |
| 219 | 334 | /* video hardware */ |
| 220 | 335 | MDRV_DEFAULT_LAYOUT(layout_socrates) |
| 336 | MDRV_SCREEN_ADD("screen", RASTER) |
| 337 | MDRV_SCREEN_REFRESH_RATE(60) |
| 338 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 339 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 340 | MDRV_SCREEN_SIZE(256, 228) |
| 341 | MDRV_SCREEN_VISIBLE_AREA(0, 255, 0, 227) |
| 342 | MDRV_PALETTE_LENGTH(256) |
| 343 | MDRV_PALETTE_INIT(socrates) |
| 221 | 344 | |
| 222 | 345 | /* sound hardware */ |
| 223 | 346 | //MDRV_SPEAKER_STANDARD_MONO("mono") |