// The top-level API for managed applications. // TBD: The API will be extended to handle I/O devices (controllers, expansion ports) #pragma once #if defined(_WINDOWS) && !defined(BREAKS_CORE_STATIC) #define DLL_EXPORT __declspec(dllexport) #else #define DLL_EXPORT #endif extern "C" { /// /// Creates a motherboard instance with all the hardware (APU/PPU/cartridge connector). The cartridge defaults to the Ejected state. /// /// Revision name of the motherboard. If the board is not supported, a `BogusBoard` will be created. /// APU revision /// PPU revision /// The form factor of the cartridge connector. DLL_EXPORT void CreateBoard(char* boardName, char* apu, char* ppu, char* p1); /// /// Destroys the motherboard instance and all the resources it occupies. /// DLL_EXPORT void DestroyBoard(); /// /// Insert the cartridge. Cartridge Factory will try to fit .nes ROM into the form factor of the current motherboard's cartridge connector. In addition, a mapper instance will be created if it is supported. /// /// .nes ROM image. /// Image size (bytes) DLL_EXPORT int InsertCartridge(uint8_t* nesImage, size_t size); /// /// Free the cartridge connector from the ROM/mapper and all resources. /// DLL_EXPORT void EjectCartridge(); /// /// Simulate 1 half cycle of the board. The simulation of the signal edge is not supported, this is overkill. /// DLL_EXPORT void Step(); /// /// Make the board /RES pins = 0 for a few CLK half cycles so that the APU/PPU resets all of its internal circuits. /// DLL_EXPORT void Reset(); /// /// The parent application can check that the board is in the reset process and ignore the audio/video signal for that time. /// /// DLL_EXPORT bool InResetState(); /// /// Get the values of the ACLK cycle counter. /// /// DLL_EXPORT size_t GetACLKCounter(); /// /// Get the value of the 6502 core cycle counter (PHI Counter) /// /// DLL_EXPORT size_t GetPHICounter(); /// /// Get the current resulting AUX value in normalized [0.0; 1.0] format. /// /// DLL_EXPORT void SampleAudioSignal(float* sample); /// /// Load APU/PPU registers dump (APUPlayer/PPUPlayer only) /// /// RegDumpEntry records /// Dump size (bytes) DLL_EXPORT void LoadRegDump(uint8_t* data, size_t data_size); /// /// Get audio signal settings that help with its rendering on the consumer side. /// /// DLL_EXPORT void GetApuSignalFeatures(APUSim::AudioSignalFeatures* features); /// /// Get the "pixel" counter. Keep in mind that pixels refers to an abstract entity representing the visible or invisible part of the video signal. /// /// DLL_EXPORT size_t GetPCLKCounter(); /// /// Get 1 sample of the video signal. /// /// DLL_EXPORT void SampleVideoSignal(PPUSim::VideoOutSignal* sample); /// /// Get the direct value from the PPU H counter. /// /// DLL_EXPORT size_t GetHCounter(); /// /// Get the direct value from the PPU V counter. /// /// DLL_EXPORT size_t GetVCounter(); /// /// Forcibly enable rendering ($2001[3] = $2001[4] always equals 1). /// Used for debugging PPU signals, when the CPU I/F register dump is limited, or when you want to get faster simulation results. /// Keep in mind that with permanently enabled rendering the PPU becomes unstable and this hack should be applied when you know what you're doing. /// /// DLL_EXPORT void RenderAlwaysEnabled(bool enable); /// /// Get video signal settings that help with its rendering on the consumer side. /// /// DLL_EXPORT void GetPpuSignalFeatures(PPUSim::VideoSignalFeatures* features); /// /// Convert the raw color to RGB. Can be used for palette generation or PPU video output in RAW mode. /// The SYNC level (RAW.Sync) check must be done from the outside. /// DLL_EXPORT void ConvertRAWToRGB(uint16_t raw, uint8_t* r, uint8_t* g, uint8_t* b); /// /// Use RAW color output. /// RAW color refers to the Chroma/Luma combination that comes to the video generator and the Emphasis bit combination. /// /// DLL_EXPORT void SetRAWColorMode(bool enable); /// /// Set one of the ways to decay OAM cells. /// DLL_EXPORT void SetOamDecayBehavior(PPUSim::OAMDecayBehavior behavior); /// /// Set the noise for the composite video signal (in volts). /// /// DLL_EXPORT void SetNoiseLevel(float volts); /// /// Return all core debugging information for BreaksDebug. /// /// DLL_EXPORT void GetAllCoreDebugInfo(M6502Core::DebugInfo* info); };