1 #ifndef _interface__c_interface__h__included__
2 #define _interface__c_interface__h__included__
6 Copyright (c) 2013 Ilari Liusvaara
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 * Some general information about the interface:
30 * - The parameter type for LSNES_CORE_FOO is struct lsnes_core_foo*
31 * - There are also some other enumerations/structures.
32 * - The only exposed entry point (lsnes_core_entrypoint) has fp type of lsnes_core_func_t.
33 * - By nature, this interface does not reference any symbols (exception is lsnes_register_builtin_core).
34 * - Some fields may be conditional on API version.
35 * - The following functions are required:
36 * * LSNES_CORE_ENUMERATE_CORES
37 * * LSNES_CORE_GET_CORE_INFO
38 * * LSNES_CORE_GET_TYPE_INFO
39 * * LSNES_CORE_GET_REGION_INFO
40 * * LSNES_CORE_GET_SYSREGION_INFO
41 * * LSNES_CORE_GET_AV_STATE
42 * * LSNES_CORE_EMULATE
43 * * LSNES_CORE_SAVESTATE
44 * * LSNES_CORE_LOADSTATE
45 * * LSNES_CORE_GET_CONTROLLERCONFIG
46 * * LSNES_CORE_LOAD_ROM
47 * - Scratch buffers from emulator side last for duration of the call.
48 * - Scratch buffers form core side last until next call.
49 * - Never free buffer from emulator in core or vice versa.
50 * - The spaces for Core, Type, Region and Sysregion IDs are distinct.
51 * - If you only have one region, use ID of 0 for that and GET_REGION/SET_REGION are not needed.
62 #define LSNES_CORE_API 0
66 #define LSNES_CORE_VMA_READONLY 1
67 //VMA has special semantics (no read/write consistency).
68 #define LSNES_CORE_VMA_SPECIAL 2
69 //VMA is volatile (and uninitialized on poweron).
70 #define LSNES_CORE_VMA_VOLATILE 4
73 //Core supports multiple regions (By supporting LSNES_CORE_GET_REGION/LSNES_CORE_SET_REGION).
74 #define LSNES_CORE_CAP1_MULTIREGION 0x00000001U
75 //Core supports poll flags (By supporting LSNES_CORE_GET_PFLAG/LSNES_CORE_SET_PFLAG).
76 #define LSNES_CORE_CAP1_PFLAG 0x00000002U
77 //Core supports actions (By supporting LSNES_CORE_GET_ACTION_FLAGS/LSNES_CORE_EXECUTE_ACTION).
78 #define LSNES_CORE_CAP1_ACTION 0x00000004U
79 //Core supports bus map (By supporting LSNES_CORE_GET_BUS_MAPPING).
80 #define LSNES_CORE_CAP1_BUSMAP 0x00000008U
81 //Core supports SRAM (By supporting LSNES_CORE_ENUMERATE_SRAM/LSNES_CORE_LOAD_SRAM/LSNES_CORE_SAVE_SRAM).
82 #define LSNES_CORE_CAP1_SRAM 0x00000010U
83 //Core supports resets (By supporting LSNES_CORE_GET_RESET_ACTION). LSNES_CORE_CAP1_ACTION is required.
84 #define LSNES_CORE_CAP1_RESET 0x00000020U
85 //Core supports custom scale computation (By supporting LSNES_CORE_COMPUTE_SCALE).
86 #define LSNES_CORE_CAP1_SCALE 0x00000040U
87 //Core supports explicit save points (By supporting LSNES_CORE_RUNTOSAVE).
88 #define LSNES_CORE_CAP1_RUNTOSAVE 0x00000080U
89 //Core supports powerons (By supporting LSNES_CORE_POWERON).
90 #define LSNES_CORE_CAP1_POWERON 0x00000100U
91 //Core supports cartridge unload (By supporting LSNES_CORE_UNLOAD_CARTRIDGE).
92 #define LSNES_CORE_CAP1_UNLOAD 0x00000200U
93 //Core supports debugging (By supporting LSNES_CORE_DEBUG_RESET and LSNES_CORE_SET_DEBUG_FLAGS[breakpoints]).
94 //LSNES_CORE_CAP1_MEMWATCH is required.
95 #define LSNES_CORE_CAP1_DEBUG 0x00000400U
96 //Core supports tracing (By supporting LSNES_CORE_DEBUG_RESET and LSNES_CORE_SET_DEBUG_FLAGS[tracing]).
97 //LSNES_CORE_CAP1_MEMWATCH is required.
98 #define LSNES_CORE_CAP1_TRACE 0x00000800U
99 //Core supports cheating (By supporting LSNES_CORE_DEBUG_RESET and LSNES_CORE_SET_CHEAT).
100 //LSNES_CORE_CAP1_MEMWATCH is required.
101 #define LSNES_CORE_CAP1_CHEAT 0x00001000U
102 //Core supports cover pages (By supporting LSNES_CORE_DRAW_COVER).
103 #define LSNES_CORE_CAP1_COVER 0x00002000U
104 //Core supports pre-emulate (By supporting LSNES_CORE_PRE_EMULATE).
105 #define LSNES_CORE_CAP1_PREEMULATE 0x00004000U
106 //Core supports registers (By supporting LSNES_CORE_GET_DEVICE_REGS).
107 #define LSNES_CORE_CAP1_REGISTERS 0x00008000U
108 //Core supports memory watch (By supporting LSNES_CORE_GET_VMA_LIST).
109 #define LSNES_CORE_CAP1_MEMWATCH 0x00010000U
110 //Core supports lightguns (By setting lightgun_height/lightgun_width in LSNES_CORE_GET_AV_STATE).
111 #define LSNES_CORE_CAP1_LIGHTGUN 0x00020000U
112 //Core supports fast reinit (By supporting LSNES_CORE_REINIT).
113 #define LSNES_CORE_CAP1_REINIT 0x00040000U
114 //Reserved capabilities.
115 #define LSNES_CORE_CAP1_RESERVED19 0x00080000U
116 #define LSNES_CORE_CAP1_RESERVED20 0x00100000U
117 #define LSNES_CORE_CAP1_RESERVED21 0x00200000U
118 #define LSNES_CORE_CAP1_RESERVED22 0x00400000U
119 #define LSNES_CORE_CAP1_RESERVED23 0x00800000U
120 #define LSNES_CORE_CAP1_RESERVED24 0x01000000U
121 #define LSNES_CORE_CAP1_RESERVED25 0x02000000U
122 #define LSNES_CORE_CAP1_RESERVED26 0x04000000U
123 #define LSNES_CORE_CAP1_RESERVED27 0x08000000U
124 #define LSNES_CORE_CAP1_RESERVED28 0x10000000U
125 #define LSNES_CORE_CAP1_RESERVED29 0x20000000U
126 #define LSNES_CORE_CAP1_RESERVED30 0x40000000U
127 #define LSNES_CORE_CAP1_CAPS2 0x80000000U
129 #define LSNES_END_OF_LIST 0xFFFFFFFFU
131 //Do action <action> on item <item> with parameters <params>.
132 //If successful, return 0.
133 //If supported but unsuccessful, return -1 and fill <error> (will not be released, only needs to be stable to next
135 //In dynamic libs, this is looked up as lsnes_core_fn.
136 typedef int(*lsnes_core_func_t
)(unsigned action
, unsigned item
, void* params
, const char** error
);
139 enum lsnes_core_pixel_format
141 LSNES_CORE_PIXFMT_RGB15
,
142 LSNES_CORE_PIXFMT_BGR15
,
143 LSNES_CORE_PIXFMT_RGB16
,
144 LSNES_CORE_PIXFMT_BGR16
,
145 LSNES_CORE_PIXFMT_RGB24
,
146 LSNES_CORE_PIXFMT_BGR24
,
147 LSNES_CORE_PIXFMT_RGB32
,
148 LSNES_CORE_PIXFMT_LRGB
152 struct lsnes_core_framebuffer_info
154 //Pixel format of framebuffer.
155 enum lsnes_core_pixel_format type
;
156 //The physical memory backing the framebuffer.
158 //Physical width of framebuffer.
160 //Physical height of framebuffer.
162 //Physical stride of framebuffer (in bytes).
164 //Visible width of framebuffer.
166 //Visible height of framebuffer.
168 //Visible stride of framebuffer (in bytes).
170 //Visible X offset of framebuffer.
172 //Visible Y offset of framebuffer.
176 struct lsnes_core_sram
186 struct lsnes_core_system_setting
194 struct lsnes_core_disassembler
199 const char* (*fn
)(uint64_t base
, unsigned char(*fetch
)(void* ctx
), void* ctx
);
202 //Font rendering request.
203 struct lsnes_core_fontrender_req
205 //Input: Context to pass to callbacks.
207 //Input: Allocate bitmap memory.
208 //cb_ctx => cb_ctx from above.
209 //mem_size => Number of bytes needed to allocate.
210 //return buffer at least mem_size bytes. Or return NULL on error.
211 void* (*alloc
)(void* cb_ctx
, size_t mem_size
);
212 //Input: Text to render (UTF-8).
214 //Input: Length of text in bytes. If negative, text is null-terminated.
216 //Input: Bytes per pixel to request. Can be 1, 2, 3 or 4.
218 //Input: Foreground color (native endian).
220 //Input: Background color (native endian).
222 //Output: The allocated bitmap (this comes from ->alloc). Not released on failure.
224 //Output: Width of the bitmap.
226 //Output: Height of the bitmap.
230 //Request 0: Initialize and enumerate cores.
232 //Default action: (required)
233 //Called as the first call. Do the needed initialization and return list of core IDs.
234 #define LSNES_CORE_ENUMERATE_CORES 0
235 struct lsnes_core_enumerate_cores
237 //Output: List of sysregion ids. Terminated by 0xFFFFFFFF.
238 unsigned* sysregions
;
239 //Input: Emulator capability flags 1.
241 //Input: Function to print message line.
242 void (*message
)(const char* msg
, size_t length
);
244 short (*get_input
)(unsigned port
, unsigned index
, unsigned control
);
245 //Input: Notify that state of action has updated.
246 void (*notify_action_update
)();
247 //Input: Notify that time has ticked.
248 void (*timer_tick
)(uint32_t increment
, uint32_t per_second
);
249 //Input: Get firmware path. The return value is temporary.
250 const char* (*get_firmware_path
)();
251 //Input: Get cartridge base path. The return value is temporary.
252 const char* (*get_base_path
)();
253 //Input: Get current time.
254 time_t (*get_time
)();
255 //Input: Get random seed.
256 time_t (*get_randomseed
)();
257 //Input: Notify that memory has been read.
258 void (*memory_read
)(uint64_t addr
, uint64_t value
);
259 //Input: Notify that memory is about to be written.
260 void (*memory_write
)(uint64_t addr
, uint64_t value
);
261 //Input: Notify that memory is about to be executed.
262 void (*memory_execute
)(uint64_t addr
, uint64_t cpunum
);
263 //Input: Notify memory trace event. Str needs to be valid during call.
264 void (*memory_trace
)(uint64_t proc
, const char* str
, int insn
);
265 //Input: Submit sound.
266 void (*submit_sound
)(const int16_t* samples
, size_t count
, int stereo
, double rate
);
267 //Input: Notify latch event. Parameters are NULL-terminated and need to be remain during call.
268 void (*notify_latch
)(const char** params
);
269 //Input: Output a frame.
270 void (*submit_frame
)(struct lsnes_core_framebuffer_info
* fb
, uint32_t fps_n
, uint32_t fps_d
);
271 //Input: Add disassembler. Only available if emu_flags1>=1.
272 void* (*add_disasm
)(struct lsnes_core_disassembler
* disasm
);
273 //Input: Remove disassembler. Only available if emu_flags1>=1.
274 void (*remove_disasm
)(void* handle
);
275 //Input: Render text into bitmap. Returns 0 on success, -1 on failure. Only available if emu_flags>=2.
276 int (*render_text
)(struct lsnes_core_fontrender_req
* req
);
279 //Request 1: Request information about core.
281 //Default action: (required)
282 //Obtain information about core.
283 #define LSNES_CORE_GET_CORE_INFO 1
284 struct lsnes_core_get_core_info_aparam
286 //Name of the parameter.
290 //int:<val>,<val>: Integer in specified range.
291 //string[:<regex>]: String with regex.
292 //enum:<json-array-of-strings>: Enumeration.
293 //toggle: Not a real parameter, boolean toggle, must be the first.
296 struct lsnes_core_get_core_info_action
298 //Internal id of the action.
300 //Internal name of the action.
302 //Human-readable Name of the action
304 //Array of parameters. Terminated by parameter with NULL name.
305 struct lsnes_core_get_core_info_aparam
* parameters
;
307 struct lsnes_core_get_core_info
309 //Output: The JSON text.
311 //Output: JSON pointer to root of the port array.
312 const char* root_ptr
;
313 //Output: Short core name.
314 const char* shortname
;
315 //Output: Full core name.
316 const char* fullname
;
317 //Output: Capability flags #1 (LSNES_CORE_CAP1_*).
319 //Output: Array of actions. Terminated by action with NUL iname. Only if LSNES_CORE_CAP1_ACTION is set.
320 struct lsnes_core_get_core_info_action
* actions
;
321 //Output: List of trace CPUs. Terminated by NULL. Only if LSNES_CORE_CAP1_TRACE is set.
322 const char** trace_cpu_list
;
325 //Request 2: Request information about system type.
327 //Default action: (required)
328 //Obtain information about system type.
329 #define LSNES_CORE_GET_TYPE_INFO 2
330 struct lsnes_core_get_type_info_paramval
336 struct lsnes_core_get_type_info_param
340 //Human-readable name.
344 //Enumeration of values (if enumerated, ended by value with NULL iname).
345 //If values are false and true, this is boolean.
346 struct lsnes_core_get_type_info_paramval
* values
;
347 //Validation regex (only for non-enumerated).
350 struct lsnes_core_get_type_info_romimage
354 //Human-readable name.
356 //Mandatory mask (OR of all preset ones must equal OR of all).
358 //Pass mode: 0 => Content. 1 => Filename, 2 => Directory.
360 //Optional header size.
362 //Standard extensions (split by ;).
363 const char* extensions
;
365 struct lsnes_core_get_type_info
367 //Output: ID of core emulating this.
369 //Output: internal name.
371 //Output: human-readable name.
373 //Output: Short System name (e.g. SNES).
377 //Output: List of regions. Terminated by 0xFFFFFFFF.
379 //Output: List of images. Terminated by image with NULL iname.
380 struct lsnes_core_get_type_info_romimage
* images
;
381 //Output: List of settings. Terminated by setting with NULL iname.
382 struct lsnes_core_get_type_info_param
* settings
;
385 //Request 3: Request information about region.
386 //Item id: Region ID.
387 //Default action: (required)
388 //Obtain information about region.
389 #define LSNES_CORE_GET_REGION_INFO 3
390 struct lsnes_core_get_region_info
392 //Output: Internal name.
394 //Output: Human-readable name.
398 //Output: Multi-region flag.
400 //Output: Fps numerator.
402 //Output: Fps denomerator.
404 //Output: Compatible run regions, ended with 0xFFFFFFFF.
405 unsigned* compatible_runs
;
408 //Request 4: Get sysregion info.
409 //Item id: Sysregion ID.
410 //Default action: (required)
411 //Get information about specific sysregion.
412 #define LSNES_CORE_GET_SYSREGION_INFO 4
413 struct lsnes_core_get_sysregion_info
415 //Output: The name of sysregion.
417 //Output: The type ID.
419 //Output: The region ID.
421 //Output: The system name this is for.
422 const char* for_system
;
426 //Request 5: Get current A/V state.
428 //Default action: (required)
429 //Fill the structure with current A/V state.
430 #define LSNES_CORE_GET_AV_STATE 5
431 struct lsnes_core_get_av_state
438 unsigned lightgun_width
;
439 unsigned lightgun_height
;
443 //Request 6: Emulate a frame
445 //Default action: (required).
446 //Emulate a frame and output the video and audio data resulting.
447 #define LSNES_CORE_EMULATE 6
448 struct lsnes_core_emulate
452 //Request 7: Save state.
454 //Default action: (required).
456 #define LSNES_CORE_SAVESTATE 7
457 struct lsnes_core_savestate
459 //Output: Size of the savestate.
461 //Output: Savestate data. Only needs to be stable to next call.
465 //Request 8: Load state.
467 //Default action: (required).
469 #define LSNES_CORE_LOADSTATE 8
470 struct lsnes_core_loadstate
472 //Input: Size of the savestate.
474 //Input: Savestate data. Only stable during call.
478 //Request 9: Get controller set.
480 //Default action: (required).
481 //Get the controller set.
482 #define LSNES_CORE_GET_CONTROLLERCONFIG 9
483 struct lsnes_core_get_controllerconfig_logical_entry
490 struct lsnes_core_get_controllerconfig
492 //Input: System settings. Ended by entry with NULL name.
493 struct lsnes_core_system_setting
* settings
;
494 //Output: Port types, indexed by 0-based ID to port type root JSON array. Ended by 0xFFFFFFFF.
495 unsigned* controller_types
;
496 //Output: Logical map (ended by 0,0).
497 struct lsnes_core_get_controllerconfig_logical_entry
* logical_map
;
500 //Request 10: Load ROM.
502 //Default action: (required).
504 #define LSNES_CORE_LOAD_ROM 10
505 struct lsnes_core_load_rom_image
507 //ROM image (or filename thereof)
514 struct lsnes_core_load_rom
516 //Input: The image set.
517 struct lsnes_core_load_rom_image
* images
;
518 //Input: System settings. Ended by entry with NULL name.
519 struct lsnes_core_system_setting
* settings
;
522 //Input: RTC subsecond.
526 //Request 11: Get region.
528 //Default action: Fill region 0.
529 //Return the current region.
530 #define LSNES_CORE_GET_REGION 11
531 struct lsnes_core_get_region
533 //Output: The region.
537 //Request 12: Set region.
539 //Default action: If region is 0, succeed, otherwise fail.
540 //Set current region.
541 #define LSNES_CORE_SET_REGION 12
542 struct lsnes_core_set_region
544 //Input: The region ID.
548 //Request 13: Deinitialize
550 //Default action: No-op
551 //Deinitialize the state.
552 #define LSNES_CORE_DEINITIALIZE 13
553 struct lsnes_core_deinitialize
557 //Request 14: Get poll flag state.
559 //Default action: Return flag inferred from polls.
560 //Return the poll flag state.
561 //The poll flag gets automatically set to 1 if core reads controllers.
562 #define LSNES_CORE_GET_PFLAG 14
563 struct lsnes_core_get_pflag
565 //Output: The poll flag state.
569 //Request 15: Set poll flag state.
571 //Default action: Set flag inferred from polls.
572 //Sets the poll flag state.
573 #define LSNES_CORE_SET_PFLAG 15
574 struct lsnes_core_set_pflag
576 //Input: The poll flag state.
580 //Request 16: Get action flags.
582 //Default action: Act as if flags was 1.
583 //Get flags for given action.
584 #define LSNES_CORE_GET_ACTION_FLAGS 16
585 struct lsnes_core_get_action_flags
587 //Input: The ID of action.
595 //Request 17: Execute action.
597 //Default action: Do nothing.
598 //Execute given action.
599 #define LSNES_CORE_EXECUTE_ACTION 17
600 struct lsnes_core_execute_action_param
611 struct lsnes_core_execute_action
613 //Input: The ID of action.
615 //Parameters block (length is set by action info).
616 struct lsnes_core_execute_action_param
* params
;
619 //Request 18: Get bus mapping.
621 //Default action: base=0, size=0 (no mapping).
622 //Get the base and size of bus mapping.
623 #define LSNES_CORE_GET_BUS_MAPPING 18
624 struct lsnes_core_get_bus_mapping
626 //Output: The base address of the mapping.
628 //Output: The size of the mapping.
632 //Request 19: Enumerate SRAMs.
634 //Default action: Return empty set.
635 //Get the set of SRAMs available.
636 #define LSNES_CORE_ENUMERATE_SRAM 19
637 struct lsnes_core_enumerate_sram
639 //Output: List of SRAMs, NULL terminated (valid until next call).
643 //Request 20: Save SRAMs.
645 //Default action: Return empty set.
646 //Save the contents of SRAMs.
647 #define LSNES_CORE_SAVE_SRAM 20
648 struct lsnes_core_save_sram
650 //Output: The SRAMs, terminated by entry with NULL name. Valid until next call.
651 struct lsnes_core_sram
* srams
;
654 //Request 21: Load SRAMs.
656 //Default action: Warn about any SRAMs present.
657 //Load the contents of SRAMs.
658 #define LSNES_CORE_LOAD_SRAM 21
659 struct lsnes_core_load_sram
661 //Intput: The SRAMs, terminated by entry with NULL name. Valid during call.
662 struct lsnes_core_sram
* srams
;
665 //Request 22: Get reset action number.
667 //Default action: Return -1 for both (not supported).
668 //Return the IDs for reset actions.
669 #define LSNES_CORE_GET_RESET_ACTION 22
670 struct lsnes_core_get_reset_action
672 //Output: Soft reset action (-1 if not supported).
674 //Output: Hard reset action (-1 if not supported).
678 //Request 23: Get scale factors.
680 //Default action: Scale to at least 360 width, 320 height.
681 //Compute scale factors for given resolution.
682 #define LSNES_CORE_COMPUTE_SCALE 23
683 struct lsnes_core_compute_scale
689 //Output: Horizontal scale factor.
691 //Output: Vertical scale factor.
695 //Request 24: Run to save.
697 //Default action: Do nothing.
698 //Run to next save point (can be at most frame).
699 #define LSNES_CORE_RUNTOSAVE 24
700 struct lsnes_core_runtosave
704 //Request 25: Poweron the system
706 //Default action: Do nothing.
707 //Powers on the emulate system.
708 #define LSNES_CORE_POWERON 25
709 struct lsnes_core_poweron
713 //Request 26: Unload the ROM.
715 //Default action: Do nothing.
716 //Signals that the ROM is no longer needed and can be unloaded.
717 #define LSNES_CORE_UNLOAD_CARTRIDGE 26
718 struct lsnes_core_unload_cartridge
722 //Request 27: Reset debugging.
724 //Default action: Do nothing.
725 //Signals that debugging system should discard all breakpoints, cheats and tracks.
726 #define LSNES_CORE_DEBUG_RESET 27
727 struct lsnes_core_debug_reset
731 //Request 28: Set debug flags.
733 //Default action: Do nothing.
734 //Set debugging flags.
735 #define LSNES_CORE_SET_DEBUG_FLAGS 28
736 struct lsnes_core_set_debug_flags
738 //Input: Address or CPU id.
740 //Input: Flags to set.
741 //1 => Break on read.
742 //2 => Break on write.
743 //4 => Break on execute.
746 //Input: Flags to clear.
750 //Request 29: Set cheat.
752 //Default action: Do nothing.
753 //Set or clear cheat.
754 #define LSNES_CORE_SET_CHEAT 29
755 struct lsnes_core_set_cheat
757 //Input: Address to set on.
759 //Input: Value to set.
761 //Input: If nonzero, set cheat, else clear it.
765 //Request 30: Draw cover page.
767 //Default action: Draw black screen.
768 //Draw the cover page.
769 #define LSNES_CORE_DRAW_COVER 30
770 struct lsnes_core_draw_cover
772 //Output: The cover page. Needs to stay valid to next call.
773 struct lsnes_core_framebuffer_info
* coverpage
;
776 //Request 31: Set system controls before emulating frame.
778 //Default action: Do nothing.
779 //Set the system controls before frame is emulated.
780 #define LSNES_CORE_PRE_EMULATE 31
781 struct lsnes_core_pre_emulate
783 //Input: Context to pass to the function.
785 //Input: Set input function.
786 void (*set_input
)(void* context
, unsigned port
, unsigned controller
, unsigned index
, short value
);
789 //Request 32: Get list of device registers.
791 //Default action: Return no registers.
792 //Return list of device registers.
793 #define LSNES_CORE_GET_DEVICE_REGS 32
794 struct lsnes_core_get_device_regs_reg
796 //Name of the register.
801 void (*write
)(uint64_t v
);
805 struct lsnes_core_get_device_regs
807 //Output: List of registers. Terminated with register with NULL name.
808 struct lsnes_core_get_device_regs_reg
* regs
;
811 //Request 33: Get VMA list.
813 //Default action: Return no VMAs.
814 //Get the list of VMAs.
815 #define LSNES_CORE_GET_VMA_LIST 33
816 struct lsnes_core_get_vma_list_vma
824 //Endianess of region (-1 => little, 0 => host, 1 => big).
826 //flags (LSNES_CORE_VMA_*).
828 //Direct mapping for the region. If not NULL, read/write will not be used, instead all operations directly
829 //manipulate this buffer (faster). Must be NULL for special regions.
830 unsigned char* direct_map
;
831 //Function to read region (if direct_map is NULL).
832 uint8_t (*read
)(uint64_t offset
);
833 //Function to write region (if direct_map is NULL and readonly is 0).
834 void (*write
)(uint64_t offset
, uint8_t value
);
836 struct lsnes_core_get_vma_list
838 //Output: List of VMAs. NULL-terminated.
839 struct lsnes_core_get_vma_list_vma
** vmas
;
842 //Request 34: Reinit core to last loaded state.
844 //Default action: Emulate using loadstate.
845 //Signals that the core state should be reset to state just after last load (load savestate at moment of initial
847 #define LSNES_CORE_REINIT 27
848 struct lsnes_core_reinit
853 #ifdef LSNES_BUILD_AS_BUILTIN_CORE
854 void lsnes_register_builtin_core(lsnes_core_func_t fn
);
856 int lsnes_core_entrypoint(unsigned action
, unsigned item
, void* params
, const char** error
);