1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781
|
////////////////////////////////////////////////////////////////////////////////////////
//
// Nestopia - NES/Famicom emulator written in C++
//
// Copyright (C) 2003-2008 Martin Freij
//
// This file is part of Nestopia.
//
// Nestopia is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Nestopia is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Nestopia; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////////////////////////////////////
#ifndef NST_API_VIDEO_H
#define NST_API_VIDEO_H
#include "NstApi.hpp"
#ifdef NST_PRAGMA_ONCE
#pragma once
#endif
#if NST_ICC >= 810
#pragma warning( push )
#pragma warning( disable : 304 444 )
#elif NST_MSVC >= 1200
#pragma warning( push )
#pragma warning( disable : 4512 )
#endif
namespace Nes
{
namespace Core
{
namespace Video
{
/**
* Video output context.
*/
class Output
{
struct Locker;
struct Unlocker;
public:
enum
{
WIDTH = 256,
HEIGHT = 240,
NTSC_WIDTH = 602
};
/**
* Pointer to surface memory to be written to. Size must be equal to
* or greater than bitsPerPixel/8 * NES screen width * NES screen height.
*/
void* pixels;
/**
* Distance in bytes for each line in the surface memory.
* Must be equal to or greater than the actual NES screen width.
* Value is allowed to be negative.
*/
long pitch;
Output(void* v=0,long p=0)
: pixels(v), pitch(p) {}
/**
* Surface lock callback prototype.
*
* Called right before the core is about to render to the surface.
*
* @param userData optional user data
* @param output object to this class
* @return true if surface is valid and can be written to
*/
typedef bool (NST_CALLBACK *LockCallback) (void* userData,Output& output);
/**
* Surface unlock callback prototype.
*
* Called when the core has finished rendering to the surface and a previous locked was made.
*
* @param userData optional user data
* @param output object to this class
*/
typedef void (NST_CALLBACK *UnlockCallback) (void* userData,Output& output);
/**
* Surface lock callback manager.
*
* Static object used for adding the user defined callback.
*/
static Locker lockCallback;
/**
* Surface unlock callback manager.
*
* Static object used for adding the user defined callback.
*/
static Unlocker unlockCallback;
};
/**
* Surface lock callback invoker.
*
* Used internally by the core.
*/
struct Output::Locker : UserCallback<Output::LockCallback>
{
bool operator () (Output& output) const
{
return (!function || function( userdata, output )) && output.pixels && output.pitch;
}
};
/**
* Surface unlock callback invoker.
*
* Used internally by the core.
*/
struct Output::Unlocker : UserCallback<Output::UnlockCallback>
{
void operator () (Output& output) const
{
if (function)
function( userdata, output );
}
};
}
}
namespace Api
{
/**
* Video interface.
*/
class Video : public Base
{
public:
/**
* Interface constructor.
*
* @param instance emulator instance
*/
template<typename T>
Video(T& instance)
: Base(instance) {}
/**
* Video output context.
*/
typedef Core::Video::Output Output;
enum
{
MIN_BRIGHTNESS = -100,
DEFAULT_BRIGHTNESS = 0,
MAX_BRIGHTNESS = +100,
MIN_SATURATION = -100,
DEFAULT_SATURATION = 0,
DEFAULT_SATURATION_COMP = 0,
DEFAULT_SATURATION_SVIDEO = 0,
DEFAULT_SATURATION_RGB = 0,
DEFAULT_SATURATION_MONO = -100,
MAX_SATURATION = +100,
MIN_CONTRAST = -100,
DEFAULT_CONTRAST = 0,
MAX_CONTRAST = +100,
MIN_SHARPNESS = -100,
DEFAULT_SHARPNESS_COMP = 0,
DEFAULT_SHARPNESS_SVIDEO = 20,
DEFAULT_SHARPNESS_RGB = 20,
DEFAULT_SHARPNESS_MONO = 0,
MAX_SHARPNESS = +100,
MIN_COLOR_RESOLUTION = -100,
DEFAULT_COLOR_RESOLUTION_COMP = 0,
DEFAULT_COLOR_RESOLUTION_SVIDEO = 20,
DEFAULT_COLOR_RESOLUTION_RGB = 70,
DEFAULT_COLOR_RESOLUTION_MONO = 0,
MAX_COLOR_RESOLUTION = +100,
MIN_COLOR_BLEED = -100,
DEFAULT_COLOR_BLEED_COMP = 0,
DEFAULT_COLOR_BLEED_SVIDEO = 0,
DEFAULT_COLOR_BLEED_RGB = -100,
DEFAULT_COLOR_BLEED_MONO = 0,
MAX_COLOR_BLEED = +100,
MIN_COLOR_ARTIFACTS = -100,
DEFAULT_COLOR_ARTIFACTS_COMP = 0,
DEFAULT_COLOR_ARTIFACTS_SVIDEO = -100,
DEFAULT_COLOR_ARTIFACTS_RGB = -100,
DEFAULT_COLOR_ARTIFACTS_MONO = 5,
MAX_COLOR_ARTIFACTS = +100,
MIN_COLOR_FRINGING = -100,
DEFAULT_COLOR_FRINGING_COMP = 0,
DEFAULT_COLOR_FRINGING_SVIDEO = -100,
DEFAULT_COLOR_FRINGING_RGB = -100,
DEFAULT_COLOR_FRINGING_MONO = 5,
MAX_COLOR_FRINGING = +100,
MIN_HUE = -45,
DEFAULT_HUE = 0,
MAX_HUE = +45
};
/**
* Adds extra scanlines to fix lag
*/
Result EnableOverclocking(bool state) throw();
/**
* Allows the PPU to render more than eight sprites per line.
*
* @param state true to allow it, default is false
* @return result code
*/
Result EnableUnlimSprites(bool state) throw();
/**
* Checks if the PPU sprite software extension is enabled.
*
* @return true if enabled
*/
bool AreUnlimSpritesEnabled() const throw();
/**
* Returns the current brightness.
*
* @return brightness value in the range -100 to 100
*/
int GetBrightness() const throw();
/**
* Returns the current saturation.
*
* @return saturation value in the range -100 to 100
*/
int GetSaturation() const throw();
/**
* Returns the current contrast.
*
* @return contrast value in the range -100 to 100
*/
int GetContrast() const throw();
/**
* Returns the current sharpness for the NTSC filter.
*
* @return sharpness value in the range -100 to 100
*/
int GetSharpness() const throw();
/**
* Returns the current color resolution for the NTSC filter.
*
* @return color resolution value in the range -100 to 100
*/
int GetColorResolution() const throw();
/**
* Returns the current color bleed for the NTSC filter.
*
* @return color bleed value in the range -100 to 100
*/
int GetColorBleed() const throw();
/**
* Returns the current color artifacts for the NTSC filter.
*
* @return color artifacts value in the range -100 to 100
*/
int GetColorArtifacts() const throw();
/**
* Returns the current color fringing for the NTSC filter.
*
* @return color fringing value in the range -100 to 100
*/
int GetColorFringing() const throw();
/**
* Returns the current hue.
*
* @return hue value in the range -45 to 45
*/
int GetHue() const throw();
/**
* Returns whenever the xbr filters blends pixels or not
*/
bool GetBlend() const throw();
/**
* Returns how the xbr filters rounds corners
*/
int GetCornerRounding() const throw();
/**
* Sets the brightness.
*
* @param value brightness in the range -100 to 100, default is 0
* @return result code
*/
Result SetBrightness(int value) throw();
/**
* Sets the saturation.
*
* @param value saturation in the range -100 to 100, default is 0
* @return result code
*/
Result SetSaturation(int value) throw();
/**
* Sets the contrast.
*
* @param value contrast in the range -100 to 100, default is 0
* @return result code
*/
Result SetContrast(int value) throw();
/**
* Sets the sharpness for the NTSC filter.
*
* @param value sharpness in the range -100 to 100, default is 0
* @return result code
*/
Result SetSharpness(int value) throw();
/**
* Sets the color resolution for the NTSC filter.
*
* @param value color resolution in the range -100 to 100, default is 0
* @return result code
*/
Result SetColorResolution(int value) throw();
/**
* Sets the color bleed for the NTSC filter.
*
* @param value color bleed in the range -100 to 100, default is 0
* @return result code
*/
Result SetColorBleed(int value) throw();
/**
* Sets the color artifacts for the NTSC filter.
*
* @param value color artifacts in the range -100 to 100, default is 0
* @return result code
*/
Result SetColorArtifacts(int value) throw();
/**
* Sets the color fringing for the NTSC filter.
*
* @param value fringing in the range -100 to 100, default is 0
* @return result code
*/
Result SetColorFringing(int value) throw();
/**
* Sets the hue.
*
* @param value hue in the range -45 to 45, default is 0
* @return result code
*/
Result SetHue(int value) throw();
/**
* Sets whenever the xbr filters is to blend pixels or not.
*/
Result SetBlend(bool value) throw();
/**
* Sets whenever the xbr filters is to round corners or not.
*/
Result SetCornerRounding(int value) throw();
/**
* Quickfix for blank screen issue.
*/
void ClearFilterUpdateFlag() throw();
/**
* Enables field merging for the NTSC filter.
*
* @param state true to enable
*/
void EnableFieldMerging(bool state) throw();
/**
* Checks if NTSC filter field merging is enabled.
*
* @return true if enabled
*/
bool IsFieldMergingEnabled() const throw();
/**
* Performs a manual blit to the video output object.
*
* The core calls this method internally for each frame.
*
* @param output video output object to blit to
* @return result code
*/
Result Blit(Output& output) throw();
/**
* YUV decoder presets.
*/
enum DecoderPreset
{
/**
* Canonical (default)
*/
DECODER_CANONICAL,
/**
* Consumer
*/
DECODER_CONSUMER,
/**
* Alternative
*/
DECODER_ALTERNATIVE
};
/**
* YUV decoder context.
*/
struct Decoder
{
/**
* Constructor.
*
* @param preset preset, canonical by default
*/
Decoder(DecoderPreset preset=DECODER_CANONICAL) throw();
/**
* Tests for equality.
*
* @param decoder object to compare
* @return true if equal
*/
bool operator == (const Decoder& decoder) const throw();
/**
* Tests for non-equality.
*
* @param decoder object to compare
* @return true if non-equal
*/
bool operator != (const Decoder& decoder) const throw();
enum
{
AXIS_RY,
AXIS_GY,
AXIS_BY,
NUM_AXES
};
struct
{
float gain;
uint angle;
} axes[NUM_AXES];
bool boostYellow;
};
/**
* Sets the YUV decoder.
*
* @param decoder decoder
* @return result code
*/
Result SetDecoder(const Decoder& decoder) throw();
/**
* Returns the current YUV decoder.
*
* @return current decoder
*/
const Decoder& GetDecoder() const throw();
/**
* Palette interface.
*/
class Palette
{
Core::Machine& emulator;
public:
/**
* Interface constructor
*
* @param instance emulator instance
*/
Palette(Core::Machine& instance)
: emulator(instance) {}
enum
{
NUM_ENTRIES = 64,
NUM_ENTRIES_EXT = 512
};
/**
* Custom palette types.
*/
enum CustomType
{
/**
* Standard palette. 64 colors.
*/
STD_PALETTE = NUM_ENTRIES,
/**
* Extended palette. 512 colors with emphasis included in it.
*/
EXT_PALETTE = NUM_ENTRIES_EXT
};
/**
* Palette modes
*/
enum Mode
{
/**
* YUV (default)
*/
MODE_YUV,
/**
* RGB
*/
MODE_RGB,
/**
* Custom
*/
MODE_CUSTOM
};
/**
* RGB colors.
*/
typedef const uchar (*Colors)[3];
/**
* Returns the current palette mode.
*
* @return current mode
*/
Mode GetMode() const throw();
/**
* Returns the default palette mode.
*
* @return default palette mode
*/
Mode GetDefaultMode() const throw();
/**
* Sets the custom palette.
*
* @param colors RGB color data
* @param type custom palette type
*/
Result SetCustom(Colors colors,CustomType type=STD_PALETTE) throw();
/**
* Returns the custom palette.
*
* @param colors RGB colors to be filled
* @param type custom palette type
* @return number of colors written
*/
uint GetCustom(uchar (*colors)[3],CustomType type) const throw();
/**
* Resets the custom palette.
*/
void ResetCustom() throw();
/**
* Returns the custom palette type.
*
* @return custom palette type
*/
CustomType GetCustomType() const throw();
/**
* Return the current palette colors.
*
* @return palette colors
*/
Colors GetColors() const throw();
/**
* Sets the palette mode.
*
* @param mode palette mode
* @return result code
*/
Result SetMode(Mode mode) throw();
};
/**
* Returns the palette interface.
*
* @return palette interface
*/
Palette GetPalette()
{
return emulator;
}
/**
* Render state context.
*/
struct RenderState
{
RenderState() throw();
/**
* Pixel context.
*/
struct Bits
{
/**
* RGB bit mask.
*/
struct Mask
{
ulong r,g,b;
};
/**
* RGB bit mask.
*/
Mask mask;
/**
* Bits per pixel.
*/
uint count;
};
/**
* Pixel context.
*/
Bits bits;
/**
* Screen width.
*/
ushort width;
/**
* Screen height.
*/
ushort height;
/**
* Video Filter.
*/
enum Filter
{
/**
* No filter (default).
*/
FILTER_NONE,
/**
* NTSC filter.
*/
FILTER_NTSC
#ifndef NST_NO_SCALEX
,
/**
* Scale2x filter.
*/
FILTER_SCALE2X,
/**
* Scale3x filter.
*/
FILTER_SCALE3X
#endif
#ifndef NST_NO_HQ2X
,
/**
* Hq2x filter.
*/
FILTER_HQ2X,
/**
* Hq3x filter.
*/
FILTER_HQ3X,
/**
* Hq4x filter.
*/
FILTER_HQ4X
#endif
#ifndef NST_NO_2XSAI
,
/**
* 2xSaI filter.
*/
FILTER_2XSAI
#endif
#ifndef NST_NO_XBR
,
FILTER_2XBR,
FILTER_3XBR,
FILTER_4XBR
#endif
};
/**
* Scale factors.
*/
enum Scale
{
SCALE_NONE = 1
#ifndef NST_NO_SCALEX
,SCALE_SCALE2X = 2
,SCALE_SCALE3X = 3
#endif
#ifndef NST_NO_HQ2X
,SCALE_HQ2X = 2
,SCALE_HQ3X = 3
#endif
#ifndef NST_NO_2XSAI
,SCALE_2XSAI = 2
#endif
};
/**
* Filter.
*/
Filter filter;
};
/**
* Sets the render state.
*
* @param state render state to be set
* @return result code
*/
Result SetRenderState(const RenderState& state) throw();
/**
* Returns the current render state.
*
* @param state object to be filled
* @return result code
*/
Result GetRenderState(RenderState& state) const throw();
};
}
}
#if NST_MSVC >= 1200 || NST_ICC >= 810
#pragma warning( pop )
#endif
#endif
|