Proofreading

Lior Halphon 2024-12-01 01:09:32 +02:00
parent dc31336674
commit 8fdca7f388
79 changed files with 177 additions and 182 deletions

@ -11,11 +11,11 @@ In `display.h`
## Description ## Description
Four built-in presets palettes to be used with [[GB_set_palette|GB_set_palette and GB_get_palette]]: Four built-in preset palettes to be used with [[GB_set_palette|GB_set_palette and GB_get_palette]]:
* `GB_PALETTE_GREY`: A palette with four evenly-spaced shades of grey. * `GB_PALETTE_GREY`: A palette with four evenly-spaced shades of grey.
* `GB_PALETTE_DMG`: A green palette mimicking the look of the original Game Boy (DMG) * `GB_PALETTE_DMG`: A green palette mimicking the look of the original Game Boy (DMG)
* `GB_PALETTE_MGB`: An olive palette mimicking the look of the Game Boy Pocket (MGB) * `GB_PALETTE_MGB`: An olive palette mimicking the look of the Game Boy Pocket (MGB)
* `GB_PALETTE_GBL`: A teal palette mimicking the look of the Game Boy Light (GBL/MGL) * `GB_PALETTE_GBL`: A teal palette mimicking the look of the Game Boy Light (GBL/MGL)
## See Also ## See Also

@ -10,4 +10,4 @@ In `gb.h`
## Description ## Description
When this macro is defined, SameBoy is built with thread-safety assertions. It is implicitly defined in release builds where `NDEBUG` is not defined. When this macro is defined, SameBoy is built with thread-safety assertions. It is implicitly defined in release builds where `NDEBUG` is not defined.

@ -10,7 +10,7 @@ In `apu.h`
## Description ## Description
This function sets a callback that's whenever the emulator instance has a rendered sample ready. The rate in which the callback is called is controlled by the [[sample rate|GB_set_sample_rate]]. This function sets a callback that triggers whenever the emulator instance has a rendered sample ready. The rate at which the callback is called is controlled by the [[sample rate|GB_set_sample_rate]].
## Thread Safety ## Thread Safety
@ -23,4 +23,4 @@ The callback isn't called when the sample rate is set to 0.
## See Also ## See Also
* [[GB_sample_t]] * [[GB_sample_t]]
* [[GB_set_sample_rate]] * [[GB_set_sample_rate]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
A convenient function used to log formatted string (following `printf` semantics), along with [[attributes|GB_log_attributes_t]] through an emulator instance's [[log callback|GB_set_log_callback]]. A convenient function used to log a formatted string (following `printf` semantics), along with [[attributes|GB_log_attributes_t]] through an emulator instance's [[log callback|GB_set_log_callback]].
## Thread Safety ## Thread Safety
@ -16,4 +16,4 @@ A convenient function used to log formatted string (following `printf` semantics
* [[GB_log]] * [[GB_log]]
* [[GB_log_attributes_t]] * [[GB_log_attributes_t]]
* [[GB_set_log_callback]] * [[GB_set_log_callback]]

@ -14,4 +14,4 @@ Resets the value returned by [[GB_get_joyp_accessed]] back to `false`. See [[GB_
## See Also ## See Also
* [[GB_get_joyp_accessed]] * [[GB_get_joyp_accessed]]

@ -14,4 +14,4 @@ Breaks the debugger. This will cause the emulator instance to [[wait for the use
## See Also ## See Also
* [[GB_debugger_is_stopped]] * [[GB_debugger_is_stopped]]

@ -6,7 +6,7 @@ In `debugger.h`
## Description ## Description
Evaluates the expression `string` in the context of an emulator instance. Return `true` if the expression was evaluated successfully. Evaluates the expression `string` in the context of an emulator instance. Returns `true` if the expression was evaluated successfully.
If `result` is not `NULL`, it will be populated with the 16-bit result of the evaluated expression upon success. If `result` is not `NULL`, it will be populated with the 16-bit result of the evaluated expression upon success.
@ -18,4 +18,4 @@ If `result_bank` is not `NULL`, it will be populated with the bank of the evalua
## See Also ## See Also
* [[GB_debugger_execute_command]] * [[GB_debugger_execute_command]]

@ -6,7 +6,7 @@ In `debugger.h`
## Description ## Description
Executes a debugger command `input` in an emulator instance, and returns its (potentially formatted) output via the [[logging interface|GB_set_log_callback]]. Executes a debugger command `input` in an emulator instance and returns its (potentially formatted) output via the [[logging interface|GB_set_log_callback]].
The contents of `input` are destroyed upon returning from this function. The contents of `input` are destroyed upon returning from this function.
@ -16,8 +16,8 @@ The contents of `input` are destroyed upon returning from this function.
## Notes ## Notes
Some flow-control commands, such as `continue` and `step`, are not supported by this function and may not behave as expected. Some flow control commands, such as `continue` and `step`, are not supported by this function and may not behave as expected.
## See Also ## See Also
* [[GB_debugger_evaluate]] * [[GB_debugger_evaluate]]

@ -6,7 +6,7 @@ In `debugger.h`
## Description ## Description
Returns `true` if the debugger has stopped (due to a [[break|GB_debugger_break]] or a stop condition), and hasn't been resumed by a command yet. Returns `true` if the debugger has stopped (due to a [[break|GB_debugger_break]] or a stop condition) and has not been resumed by a command yet.
## Thread Safety ## Thread Safety
@ -14,4 +14,4 @@ Returns `true` if the debugger has stopped (due to a [[break|GB_debugger_break]]
## See Also ## See Also
* [[GB_debugger_break]] * [[GB_debugger_break]]

@ -12,7 +12,7 @@ An object representing an emulated Game Boy instance, normally passed as a refer
## Notes ## Notes
The size of this struct changes between versions of SameBoy. If the version of SameBoy you're linking against is not known in compile-time, you must not allocate instance statically. See [[Instance Allocation]]. The size of this struct changes between versions of SameBoy. If the version of SameBoy you're linking against is not known at compile time, you must not allocate the instance statically. See [[Instance Allocation]].
## See Also ## See Also
* [[Instance Allocation]] * [[Instance Allocation]]

@ -16,7 +16,7 @@ Resets the emulator instance and sets it to play the specified `track` number in
This function replaces [[GB_reset]] and [[GB_quick_reset]] on emulator instances that successfully loaded a GBS file. Do not call this function on emulator instances that have a different type of file loaded, and vice versa. This function replaces [[GB_reset]] and [[GB_quick_reset]] on emulator instances that successfully loaded a GBS file. Do not call this function on emulator instances that have a different type of file loaded, and vice versa.
You must call this function some time after [[GB_load_gbs]] or [[GB_load_gbs_from_buffer]] and before the first call to [[GB_run]] or [[GB_run_frame]]. You must call this function sometime after [[GB_load_gbs]] or [[GB_load_gbs_from_buffer]] and before the first call to [[GB_run]] or [[GB_run_frame]].
If you call [[GB_switch_model_and_reset]] on an emulator instance that has a GBS file loaded, you must call this function before the first call to [[GB_run]] or [[GB_run_frame]]. If you call [[GB_switch_model_and_reset]] on an emulator instance that has a GBS file loaded, you must call this function before the first call to [[GB_run]] or [[GB_run_frame]].
@ -24,4 +24,4 @@ If you call [[GB_switch_model_and_reset]] on an emulator instance that has a GBS
* [[GB_load_gbs]] * [[GB_load_gbs]]
* [[GB_load_gbs_from_buffer]] * [[GB_load_gbs_from_buffer]]
* [[GB_gbs_info_t]] * [[GB_gbs_info_t]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
Returns the current clock rate of the emulator instance, in Hertz. The value returned by this function is affected by the [[clock multiplier|GB_set_clock_multiplier]]. Returns the current clock rate of the emulator instance in Hertz. The value returned by this function is affected by the [[clock multiplier|GB_set_clock_multiplier]].
## Thread Safety ## Thread Safety
@ -15,4 +15,4 @@ Returns the current clock rate of the emulator instance, in Hertz. The value ret
## See Also ## See Also
* [[GB_set_clock_multiplier]] * [[GB_set_clock_multiplier]]
* [[GB_get_unmultiplied_clock_rate]] * [[GB_get_unmultiplied_clock_rate]]

@ -46,11 +46,11 @@ The regions supported by this function are:
## Notes ## Notes
The pointers returned by this function may become invalid upon calling a function that loads a different ROM (e.g. [[GB_load_rom]]) or by [[switching the emulated model|GB_switch_model_and_reset]]. Make sure to not retain pointers to these buffers after they stop being valid. The pointers returned by this function may become invalid upon calling a function that loads a different ROM (e.g. [[GB_load_rom]]) or by [[switching the emulated model|GB_switch_model_and_reset]]. Make sure not to retain pointers to these buffers after they stop being valid.
Some MMIO registers will not appear in the `GB_DIRECT_ACCESS_IO` region in the same way they actually appear in the emulator instance's memory, and writes to this region might not always have the desired effect. It is recommended to use [[GB_read_memory]] and [[GB_write_memory]] to access this region, when possible. Some MMIO registers will not appear in the `GB_DIRECT_ACCESS_IO` region in the same way they actually appear in the emulator instance's memory, and writes to this region might not always have the desired effect. It is recommended to use [[GB_read_memory]] and [[GB_write_memory]] to access this region when possible.
Writes to `GB_DIRECT_ACCESS_IE` can have unexpected results and needs to be avoided. Writes to `GB_DIRECT_ACCESS_IE` can have unexpected results and need to be avoided.
Writes to the `GB_DIRECT_ACCESS_BGP` and `GB_DIRECT_ACCESS_OBP` regions might not have an immediate visual effect. Writes to the `GB_DIRECT_ACCESS_BGP` and `GB_DIRECT_ACCESS_OBP` regions might not have an immediate visual effect.
@ -58,4 +58,4 @@ Writes to the `GB_DIRECT_ACCESS_BGP` and `GB_DIRECT_ACCESS_OBP` regions might no
* [[GB_read_memory]] * [[GB_read_memory]]
* [[GB_safe_read_memory]] * [[GB_safe_read_memory]]
* [[GB_write_memory]] * [[GB_write_memory]]

@ -14,4 +14,4 @@ Return `true` if the JOYP/P1 register was read, directly (via a memory read) or
## See Also ## See Also
* [[GB_clear_joyp_accessed]] * [[GB_clear_joyp_accessed]]

@ -20,4 +20,4 @@ Returns the currently emulated [[model|GB_model_t]] of an emulator instance.
* [[GB_get_state_model]] * [[GB_get_state_model]]
* [[GB_is_cgb]] * [[GB_is_cgb]]
* [[GB_is_hle_sgb]] * [[GB_is_hle_sgb]]
* [[GB_is_sgb]] * [[GB_is_sgb]]

@ -6,7 +6,7 @@ In `sgb.h`
## Description ## Description
Returns the current number of players in an emulated instance. When emulating a Super Game Boy, the emulated ROM can dynamically change the number of players to 1, 2 or 4. Returns the current number of players in an emulated instance. When emulating a Super Game Boy, the emulated ROM can dynamically change the number of players to 1, 2, or 4.
## Thread Safety ## Thread Safety
@ -15,4 +15,4 @@ Returns the current number of players in an emulated instance. When emulating a
## See Also ## See Also
* [[GB_set_key_state_for_player]] * [[GB_set_key_state_for_player]]
* [[GB_set_key_mask_for_player]] * [[GB_set_key_mask_for_player]]

@ -14,4 +14,4 @@ Returns a pointer to the [[register set|GB_registers_t]] of the emulator instanc
## See Also ## See Also
* [[GB_registers_t]] * [[GB_registers_t]]

@ -8,7 +8,7 @@ In `display.h`
## Description ## Description
These function return the dimensions of the video output of an emulator instance. The dimensions are affected by the [[emulated model|GB_model_t]] and the current [[border mode|GB_set_border_mode]] of the emulator instance, and can be either 160×144 or 256×224. These functions return the dimensions of the video output of an emulator instance. The dimensions are affected by the [[emulated model|GB_model_t]] and the current [[border mode|GB_set_border_mode]] of the emulator instance and can be either 160×144 or 256×224.
## Thread Safety ## Thread Safety
@ -17,4 +17,4 @@ These function return the dimensions of the video output of an emulator instance
## See Also ## See Also
* [[GB_set_pixels_output]] * [[GB_set_pixels_output]]
* [[GB_set_border_mode]] * [[GB_set_border_mode]]

@ -6,7 +6,7 @@ In `save_state.h`
## Description ## Description
Retrieves the [[model|GB_model_t]] used by a a save state file stored under `path`. Populates `model` and returns 0 on success. Returns a positive `errno` value on a POSIX failure, and -1 on other failures. Retrieves the [[model|GB_model_t]] used by a save state file stored under `path`. Populates `model` and returns 0 on success. Returns a positive `errno` value on a POSIX failure and -1 on other failures.
## Thread Safety ## Thread Safety

@ -18,4 +18,4 @@ This function also works on save states created by other emulators if they follo
## See Also ## See Also
* [[GB_get_state_model]] * [[GB_get_state_model]]

@ -15,4 +15,4 @@ Returns the current clock rate of the emulator instance, in Hertz. The value ret
## See Also ## See Also
* [[GB_get_clock_rate]] * [[GB_get_clock_rate]]
* [[GB_set_clock_multiplier]] * [[GB_set_clock_multiplier]]

@ -17,4 +17,4 @@ Returns `true` if the emulator instance currently emulates a Game Boy Color or a
* [[GB_model_t]] * [[GB_model_t]]
* [[GB_get_model]] * [[GB_get_model]]
* [[GB_is_hle_sgb]] * [[GB_is_hle_sgb]]
* [[GB_is_sgb]] * [[GB_is_sgb]]

@ -12,6 +12,6 @@ Returns `true` if the emulator instance currently emulates a Game Boy Color or a
`GB_is_cgb_in_cgb_mode` is thread-safe and can be called from any thread and context. `GB_is_cgb_in_cgb_mode` is thread-safe and can be called from any thread and context.
## See Also ## See Also
* [[GB_is_cgb]] * [[GB_is_cgb]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
Returns `true` if the emulator instance emulates a variant of the Super Game Boy, and also emulates the SFC or SNES side via high-level-emulation. Returns `true` if the emulator instance emulates a variant of the Super Game Boy and also emulates the SFC or SNES side via high-level emulation.
## Thread Safety ## Thread Safety
@ -17,4 +17,4 @@ Returns `true` if the emulator instance emulates a variant of the Super Game Boy
* [[GB_model_t]] * [[GB_model_t]]
* [[GB_get_model]] * [[GB_get_model]]
* [[GB_is_sgb]] * [[GB_is_sgb]]
* [[GB_is_cgb]] * [[GB_is_cgb]]

@ -6,7 +6,7 @@ In `save_state.h`
## Description ## Description
Returns `true` if the file at `path` contains a SameBoy or [BESS](https://github.com/LIJI32/SameBoy/blob/master/BESS.md) save state. Returns `true` if the file at `path` contains a SameBoy or [BESS](https://github.com/LIJI32/SameBoy/blob/master/BESS.md) save state.
## Thread Safety ## Thread Safety
@ -19,4 +19,4 @@ This function merely checks for header and footer magic values, it does not guar
## See Also ## See Also
* [[GB_get_state_model]] * [[GB_get_state_model]]
* [[GB_get_state_model_from_buffer]] * [[GB_get_state_model_from_buffer]]

@ -17,4 +17,4 @@ Returns `true` if the emulator instance emulates any variant of the Super Game B
* [[GB_model_t]] * [[GB_model_t]]
* [[GB_get_model]] * [[GB_get_model]]
* [[GB_is_hle_sgb]] * [[GB_is_hle_sgb]]
* [[GB_is_cgb]] * [[GB_is_cgb]]

@ -11,17 +11,15 @@ typedef enum {
GB_KEY_SELECT_MASK = 1 << <a href="GB_key_t.md">GB_KEY_SELECT</a>, GB_KEY_SELECT_MASK = 1 << <a href="GB_key_t.md">GB_KEY_SELECT</a>,
GB_KEY_START_MASK = 1 << <a href="GB_key_t.md">GB_KEY_START</a>, GB_KEY_START_MASK = 1 << <a href="GB_key_t.md">GB_KEY_START</a>,
} GB_key_mask_t; } GB_key_mask_t;
#define GB_MASK_FOR_PLAYER(mask, player) ((x) << (player * 8))
</pre> </pre>
In `joypad.h` In `joypad.h`
## Description ## Description
An enum representing each of the 8 buttons of a Game Boy as a mask value. Multiple values can be combine with `|` and used with functions such as [[GB_set_key_mask]]. An enum representing each of the 8 buttons of a Game Boy as a mask value. Multiple values can be combined with `|` and used with functions such as [[GB_set_key_mask]].
## See Also ## See Also
* [[GB_set_key_mask]] * [[GB_set_key_mask]]
* [[GB_set_key_mask_for_player]] * [[GB_set_key_mask_for_player]]

@ -23,4 +23,4 @@ An enum representing each of the 8 buttons of a Game Boy, for use with functions
## See Also ## See Also
* [[GB_set_key_state]] * [[GB_set_key_state]]
* [[GB_set_key_state_for_player]] * [[GB_set_key_state_for_player]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
Loads battery-backed information (e.g. battery-powered cartridge RAM or Real Time Clock information) from the file at `path` into the emulator instance. Return `0` on success and a positive value for `POSIX` failures`. Loads battery-backed information (e.g. battery-powered cartridge RAM or Real-Time Clock information) from the file at `path` into the emulator instance. Returns `0` on success and a positive value for POSIX failures.
## Thread Safety ## Thread Safety
@ -14,9 +14,9 @@ Loads battery-backed information (e.g. battery-powered cartridge RAM or Real Tim
## Notes ## Notes
This function does not considered truncated files as failures. SameBoy battery saves are compatible with most other emulators and vice versa. This function does not consider truncated files as failures. SameBoy battery saves are compatible with most other emulators and vice versa.
## See Also ## See Also
* [[GB_load_battery_from_buffer]] * [[GB_load_battery_from_buffer]]
* [[GB_save_battery]] * [[GB_save_battery]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
Loads battery-backed information (e.g. battery-powered cartridge RAM or Real Time Clock information) from `buffer` with length `size` into the emulator instance. This function never fails, and will load partial information if the buffer isn't large enough. Loads battery-backed information (e.g., battery-powered cartridge RAM or Real-Time Clock information) from `buffer` with a length of `size` into the emulator instance. This function never fails and will load partial information if the buffer is not large enough.
## Thread Safety ## Thread Safety
@ -14,9 +14,9 @@ Loads battery-backed information (e.g. battery-powered cartridge RAM or Real Tim
## Notes ## Notes
SameBoy battery saves are compatible with most other emulators and vice versa. SameBoy battery saves are compatible with most other emulators, and vice versa.
## See Also ## See Also
* [[GB_load_battery]] * [[GB_load_battery]]
* [[GB_save_battery_to_buffer]] * [[GB_save_battery_to_buffer]]

@ -15,4 +15,4 @@ Loads a boot ROM from a file into an emulator instance. If you're not using [[GB
## See Also ## See Also
* [[GB_set_boot_rom_load_callback]] * [[GB_set_boot_rom_load_callback]]
* [[GB_load_boot_rom]] * [[GB_load_boot_rom]]

@ -24,4 +24,4 @@ After loading a GBS file, you must call [[GB_gbs_switch_track]] to specify the t
* [[GB_gbs_info_t]] * [[GB_gbs_info_t]]
* [[GB_gbs_switch_track]] * [[GB_gbs_switch_track]]
* [[GB_load_rom]] * [[GB_load_rom]]
* [[GB_load_isx]] * [[GB_load_isx]]

@ -15,4 +15,4 @@ Loads ROM data into an emulator instance. Warning messages may be output to the
## See Also ## See Also
* [[GB_load_rom]] * [[GB_load_rom]]
* [[GB_load_gbs_from_buffer]] * [[GB_load_gbs_from_buffer]]

@ -14,11 +14,11 @@ Loads a snapshot of an emulation state of the emulator instance from `path`. Ret
## Notes ## Notes
SameBoy follows the [BESS](https://github.com/LIJI32/SameBoy/blob/master/BESS.md) specification, and will load save states from other BESS-compliant emulators. SameBoy follows the [BESS](https://github.com/LIJI32/SameBoy/blob/master/BESS.md) specification and will load save states from other BESS-compliant emulators.
Loading a save state will fail if [[the save state's model|GB_get_state_model]] is from a different [[model family|GB_model_t]]. Loading a save state from a different model in the same model family will not change the current model in the emulator instance. If this behavior is not desired, call [[GB_switch_model_and_reset]] with [[the correct model|GB_get_state_model]] before loading the save state. Loading a save state will fail if [[the save state's model|GB_get_state_model]] is from a different [[model family|GB_model_t]]. Loading a save state from a different model in the same model family will not change the current model in the emulator instance. If this behavior is not desired, call [[GB_switch_model_and_reset]] with [[the correct model|GB_get_state_model]] before loading the save state.
## See Also ## See Also
* [[GB_load_state_from_buffer]] * [[GB_load_state_from_buffer]]
* [[GB_save_state]] * [[GB_save_state]]

@ -6,7 +6,7 @@ In `save_state.h`
## Description ## Description
Loads a snapshot of an emulation state of the emulator instance from `buffer` with size `length`. Returns `0` on success, `EIO if the buffer is too short, and `-1` on other failures. Detailed error messages will be written to the [[log|GB_set_log_callback]] on failure. Loads a snapshot of an emulation state of the emulator instance from `buffer` with size `length`. Returns `0` on success, `EIO` if the buffer is too short, and `-1` on other failures. Detailed error messages will be written to the [[log|GB_set_log_callback]] on failure.
## Thread Safety ## Thread Safety
@ -14,11 +14,11 @@ Loads a snapshot of an emulation state of the emulator instance from `buffer` wi
## Notes ## Notes
SameBoy follows the [BESS](https://github.com/LIJI32/SameBoy/blob/master/BESS.md) specification, and will load save states from other BESS-compliant emulators. SameBoy follows the [BESS](https://github.com/LIJI32/SameBoy/blob/master/BESS.md) specification and will load save states from other BESS-compliant emulators.
Loading a save state will fail if [[the save state's model|GB_get_state_model_from_buffer]] is from a different [[model family|GB_model_t]]. Loading a save state from a different model in the same model family will not change the current model in the emulator instance. If this behavior is not desired, call [[GB_switch_model_and_reset]] with [[the correct model|GB_get_state_model_from_buffer]] before loading the save state. Loading a save state will fail if [[the save state's model|GB_get_state_model_from_buffer]] is from a different [[model family|GB_model_t]]. Loading a save state from a different model in the same model family will not change the current model in the emulator instance. If this behavior is not desired, call [[GB_switch_model_and_reset]] with [[the correct model|GB_get_state_model_from_buffer]] before loading the save state.
## See Also ## See Also
* [[GB_load_state]] * [[GB_load_state]]
* [[GB_save_state_to_buffer]] * [[GB_save_state_to_buffer]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
A convenient function used to log formatted string (following `printf` semantics) through an emulator instance's [[log callback|GB_set_log_callback]]. Calling this function is equivalent to calling [[GB_attributed_log]] with the `attributes` argument passed as `0`. A convenient function used to log a formatted string (following `printf` semantics) through an emulator instance's [[log callback|GB_set_log_callback]]. Calling this function is equivalent to calling [[GB_attributed_log]] with the `attributes` argument passed as `0`.
## Thread Safety ## Thread Safety
@ -15,4 +15,4 @@ A convenient function used to log formatted string (following `printf` semantics
## See Also ## See Also
* [[GB_attributed_log]] * [[GB_attributed_log]]
* [[GB_set_log_callback]] * [[GB_set_log_callback]]

@ -5,7 +5,7 @@ typedef enum {
GB_LOG_BOLD = 1, GB_LOG_BOLD = 1,
GB_LOG_DASHED_UNDERLINE = 2, GB_LOG_DASHED_UNDERLINE = 2,
GB_LOG_UNDERLINE = 4, GB_LOG_UNDERLINE = 4,
GB_LOG_UNDERLINE_MASK = GB_LOG_DASHED_UNDERLINE | GB_LOG_UNDERLINE GB_LOG_UNDERLINE_MASK = GB_LOG_DASHED_UNDERLINE | GB_LOG_UNDERLINE
} GB_log_attributes_t; } GB_log_attributes_t;
``` ```
@ -18,4 +18,4 @@ A bitfield of string attributes denoting the style of a string delivered to the
## See Also ## See Also
* [[GB_set_log_callback]] * [[GB_set_log_callback]]
* [[GB_attributed_log]] * [[GB_attributed_log]]

@ -44,30 +44,28 @@ In `model.h`
## Description ## Description
Each value in this enum represents a Game Boy model and SOC revision that can be passed to [[GB_init]] or [[GB_switch_model_and_reset]]. Commented out values are currently not supported, and have their values reserved for future use. Each value in this enum represents a Game Boy model and SOC revision that can be passed to [[GB_init]] or [[GB_switch_model_and_reset]]. Commented-out values are currently not supported and have their values reserved for future use.
The values in this enum are: The values in this enum are:
* `GB_MODEL_DMG_*`: A SOC revision of an original Game Boy * `GB_MODEL_DMG_*`: A SOC revision of an original Game Boy.
* `GB_MODEL_SGB` and `GB_MODEL_SGB_NTSC`: A Super Game Boy SOC inside a high-level-emulated SFC or NTSC SNES * `GB_MODEL_SGB` and `GB_MODEL_SGB_NTSC`: A Super Game Boy SOC inside a high-level-emulated SFC or NTSC SNES.
* `GB_MODEL_SGB_PAL`: A Super Game Boy SOC inside a high-level-emulated PAL SNES * `GB_MODEL_SGB_PAL`: A Super Game Boy SOC inside a high-level-emulated PAL SNES.
* `GB_MODEL_SGB_NO_SFC` and `GB_MODEL_SGB_NTSC_NO_SFC`: A Super Game Boy SOC, for used with integration with SFC or NTSC SNES emulators * `GB_MODEL_SGB_NO_SFC` and `GB_MODEL_SGB_NTSC_NO_SFC`: A Super Game Boy SOC, for use with integration with SFC or NTSC SNES emulators.
* `GB_MODEL_SGB_PAL_NO_SFC`: A Super Game Boy SOC, for used with integration with PAL SNES emulators * `GB_MODEL_SGB_PAL_NO_SFC`: A Super Game Boy SOC, for use with integration with PAL SNES emulators.
* `GB_MODEL_SGB2`: A Super Game Boy 2 SOC inside a high-level-emulated SFC or SNES * `GB_MODEL_SGB2`: A Super Game Boy 2 SOC inside a high-level-emulated SFC or SNES.
* `GB_MODEL_SGB2_NO_SFC`: A Super Game Boy 2 SOC, for used with integration with SFC or SNES emulators * `GB_MODEL_SGB2_NO_SFC`: A Super Game Boy 2 SOC, for use with integration with SFC or SNES emulators.
* `GB_MODEL_MGB`: A Game Boy Pocket SOC, also found in a Game Boy Light * `GB_MODEL_MGB`: A Game Boy Pocket SOC, also found in a Game Boy Light.
* `GB_MODEL_CGB_*`: A SOC revision of a Game Boy Color. The recommended revision is `GB_MODEL_CGB_E`. * `GB_MODEL_CGB_*`: A SOC revision of a Game Boy Color. The recommended revision is `GB_MODEL_CGB_E`.
* `GB_MODEL_AGB_*`: A SOC revision of a Game Boy Advance. * `GB_MODEL_AGB_*`: A SOC revision of a Game Boy Advance.
* `GB_MODEL_GBP_*`: A SOC revision of a Game Boy Advance inside a Game Boy Player * `GB_MODEL_GBP_*`: A SOC revision of a Game Boy Advance inside a Game Boy Player.
Additionally, the following macros can extract properties from a `GB_model_t` value:
* `GB_MODEL_FAMILY_MASK`: Use this mask to extract the model family of a `GB_model_t` value: * `GB_MODEL_FAMILY_MASK`: Use this mask to extract the model family of a `GB_model_t` value:
* `GB_MODEL_DMG_FAMILY`: This model belongs to the original Game Boy and Super Game Boy line of SOCs * `GB_MODEL_DMG_FAMILY`: This model belongs to the original Game Boy and Super Game Boy line of SOCs.
* `GB_MODEL_MGB_FAMILY`: This model belongs to the Game Boy Pocket and Super Game Boy 2 line of SOCs * `GB_MODEL_MGB_FAMILY`: This model belongs to the Game Boy Pocket and Super Game Boy 2 line of SOCs.
* `GB_MODEL_CGB_FAMILY`: This model belongs to the Game Boy Color or Game Boy Advance lines of SOCs * `GB_MODEL_CGB_FAMILY`: This model belongs to the Game Boy Color or Game Boy Advance lines of SOCs.
* `GB_MODEL_GBP_BIT`: This bit will be set if this model is a Game Boy Advance SOC in a Game Boy Player * `GB_MODEL_GBP_BIT`: This bit will be set if this model is a Game Boy Advance SOC in a Game Boy Player.
* `GB_MODEL_PAL_BIT`: This bit will be set if this model is a Super Game Boy inside a PAL console * `GB_MODEL_PAL_BIT`: This bit will be set if this model is a Super Game Boy inside a PAL console.
* `GB_MODEL_NO_SFC_BIT`: This bit will be set if this model is a Super Game Boy that delegates emulation of the SFC or SNES side to outside of the core. * `GB_MODEL_NO_SFC_BIT`: This bit will be set if this model is a Super Game Boy that delegates emulation of the SFC or SNES side to outside of the core.
## See Also ## See Also
@ -77,4 +75,4 @@ Additionally, the following macros can extract properties from a `GB_model_t` va
* [[GB_get_state_model]] * [[GB_get_state_model]]
* [[GB_is_cgb]] * [[GB_is_cgb]]
* [[GB_is_hle_sgb]] * [[GB_is_hle_sgb]]
* [[GB_is_sgb]] * [[GB_is_sgb]]

@ -12,9 +12,9 @@ In `display.h`
## Description ## Description
A structure describing a color palette, used for rendering the screen of a monochrome [[model|GB_model_t]]. The first 4 colors represent the 4 different shades of grey (or green) rendered by a Game Boy LCD, with the first color being the darkest and the last color being the lightest. The 5th color is used when rendering a turned off LCD. A structure describing a color palette, used for rendering the screen of a monochrome [[model|GB_model_t]]. The first 4 colors represent the 4 different shades of grey (or green) rendered by a Game Boy LCD, with the first color being the darkest and the last color being the lightest. The 5th color is used when rendering a turned-off LCD.
## See Also ## See Also
* [[GB_set_palette and GB_get_palette]] * [[GB_set_palette and GB_get_palette]]
* [[BuiltIn DMG Palettes]] * [[BuiltIn DMG Palettes]]

@ -6,7 +6,7 @@ In `random.h`
## Description ## Description
Sets the current random seed to a specific 64-bit value, which will be used when an emulator instance is [[initialized|Instance Allocation]] or [[reset|GB_reset]]. This function can be used to force a newly reset or initialized emulator instance to a specific state. Sets the current random seed to a specific 64-bit value, which will be used when an emulator instance is [[initialized|Instance Allocation]] or [[reset|GB_reset]]. This function can be used to force a newly reset or initialized emulator instance to a specific state.
## Thread Safety ## Thread Safety
@ -19,4 +19,4 @@ The seed is automatically initialized on process launch to a value based on the
## See Also ## See Also
* [[GB_random_set_enabled]] * [[GB_random_set_enabled]]

@ -14,8 +14,8 @@ When an emulator instance is [[initialized|Instance Allocation]] or [[reset|GB_r
## Notes ## Notes
This setting is global, and will affect all emulator instances in the process. This setting is global and will affect all emulator instances in the process.
## See Also ## See Also
* [[GB_random_seed]] * [[GB_random_seed]]

@ -6,7 +6,7 @@ In `memory.h`
## Description ## Description
Performs a memory read on a 16-bit address on the emulator instance, as if it was performed by the SM83 CPU, and returns the 8-bit read value. Performs a memory read on a 16-bit address on the emulator instance, as if it were performed by the SM83 CPU, and returns the 8-bit read value.
## Thread Safety ## Thread Safety
@ -14,12 +14,12 @@ Performs a memory read on a 16-bit address on the emulator instance, as if it wa
## Notes ## Notes
To read data outside of a currently mapped bank, or to read from a memory region that might not be currently readable (e.g. VRAM during mode 3), you can use [[GB_get_direct_access]]. To read data outside of a currently mapped bank, or to read from a memory region that might not be currently readable (e.g., VRAM during mode 3), you can use [[GB_get_direct_access]].
Because this functions goes through the same routines used by a CPU memory read, it will trigger any side effect caused by a memory read, including, for example, OAM corruption. If you wish you avoid this behavior, you can use either [[GB_safe_read_memory]] or [[GB_get_direct_access]]. Because this function goes through the same routines used by a CPU memory read, it will trigger any side effect caused by a memory read, including, for example, OAM corruption. If you wish to avoid this behavior, you can use either [[GB_safe_read_memory]] or [[GB_get_direct_access]].
## See Also ## See Also
* [[GB_safe_read_memory]] * [[GB_safe_read_memory]]
* [[GB_write_memory]] * [[GB_write_memory]]
* [[GB_get_direct_access]] * [[GB_get_direct_access]]

@ -69,4 +69,4 @@ A structure that represents the internal state of the SM83 CPU in an emulator co
## See Also ## See Also
* [[GB_get_registers]] * [[GB_get_registers]]

@ -16,4 +16,4 @@ This function emulates a power cycle in an emulator instance. All internal RAM t
* [[GB_quick_reset]] * [[GB_quick_reset]]
* [[GB_switch_model_and_reset]] * [[GB_switch_model_and_reset]]
* [[GB_random_set_enabled]] * [[GB_random_set_enabled]]

@ -20,4 +20,3 @@ Rewinding a frame will not re-render the popped frame or call the [[vblank callb
* [[GB_set_rewind_length]] * [[GB_set_rewind_length]]
* [[GB_rewind_reset]] * [[GB_rewind_reset]]

@ -14,9 +14,9 @@ Clears the current contents of the emulator instance's rewind buffer.
## Note ## Note
You should call this function after performing changes that invalidate the internal save states in the rewind buffer, such as hot-swapping into an incompatible ROM. This function can be implicitly called by other APIs if such change is detected. You should call this function after performing changes that invalidate the internal save states in the rewind buffer, such as hot-swapping into an incompatible ROM. This function can be implicitly called by other APIs if such changes are detected.
## See Also ## See Also
* [[GB_set_rewind_length]] * [[GB_set_rewind_length]]
* [[GB_rewind_pop]] * [[GB_rewind_pop]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
Runs an emulator instance for an atomic amount of time (usually a single instruction). Returns the number of time passed, in units of 8MHz (8,388,608Hz) ticks. If SameBoy was not compiled with time keeping disabled, and [[turbo mode|GB_set_turbo_mode]] was not enabled, this function can potentially sleep before returning to keep a correct frame rate. Runs an emulator instance for an atomic amount of time (usually a single instruction). Returns the number of time passed, in units of 8MHz (8,388,608Hz) ticks. If SameBoy was not compiled with timekeeping disabled, and [[turbo mode|GB_set_turbo_mode]] was not enabled, this function can potentially sleep before returning to maintain a correct frame rate.
## Thread Safety ## Thread Safety
@ -14,4 +14,4 @@ Runs an emulator instance for an atomic amount of time (usually a single instruc
## See Also ## See Also
* [[GB_run_frame]] * [[GB_run_frame]]
* [[GB_set_turbo_mode]] * [[GB_set_turbo_mode]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
Runs an emulator instance until a [[vblank callback|GB_set_vblank_callback]] is called. Returns the number of time passed, in units of 8MHz (8,388,608Hz) ticks. Unlike [[GB_run]], this function does not handle time keeping, and will not sleep. Runs an emulator instance until a [[vblank callback|GB_set_vblank_callback]] is called. Returns the number of time passed, in units of 8MHz (8,388,608Hz) ticks. Unlike [[GB_run]], this function does not handle timekeeping and will not sleep.
## Thread Safety ## Thread Safety
@ -15,4 +15,4 @@ Runs an emulator instance until a [[vblank callback|GB_set_vblank_callback]] is
## See Also ## See Also
* [[GB_run]] * [[GB_run]]
* [[GB_set_vblank_callback]] * [[GB_set_vblank_callback]]

@ -6,7 +6,7 @@ In `memory.h`
## Description ## Description
Performs a memory read on a 16-bit address on the emulator instance and returns the 8-bit read value, while avoiding side-effects that would occur of the CPU was to perform the same read. Performs a memory read on a 16-bit address in the emulator instance and returns the 8-bit read value, while avoiding side effects that would occur if the CPU were to perform the same read.
## Thread Safety ## Thread Safety
@ -14,10 +14,10 @@ Performs a memory read on a 16-bit address on the emulator instance and returns
## Notes ## Notes
To read data outside of a currently mapped bank, or to read from a memory region that might not be currently readable (e.g. VRAM during mode 3), you can use [[GB_get_direct_access]]. To read data outside of a currently mapped bank, or to read from a memory region that might not be currently readable (e.g., VRAM during mode 3), you can use [[GB_get_direct_access]].
## See Also ## See Also
* [[GB_read_memory]] * [[GB_read_memory]]
* [[GB_write_memory]] * [[GB_write_memory]]
* [[GB_get_direct_access]] * [[GB_get_direct_access]]

@ -12,9 +12,9 @@ In `apu.h`
## Description ## Description
A struct representing a single stereo sample, in signed 16-bit format. A struct representing a single stereo sample in signed 16-bit format.
## See Also ## See Also
* [[GB_apu_set_sample_callback]] * [[GB_apu_set_sample_callback]]
* [[GB_set_sample_rate]] * [[GB_set_sample_rate]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
Saves battery-backed information (e.g. battery-powered cartridge RAM or Real Time Clock information) from the emulator instance into the file at `path`. Returns `0` on success and a positive `errno` value on POSIX failures. Will do nothing and return `0` if the currently loaded ROM has no battery-backed information. Saves battery-backed information (e.g., battery-powered cartridge RAM or Real-Time Clock information) from the emulator instance into the file at `path`. Returns `0` on success and a positive `errno` value on POSIX failures. It will do nothing and return `0` if the currently loaded ROM has no battery-backed information.
## Thread Safety ## Thread Safety
@ -15,4 +15,4 @@ Saves battery-backed information (e.g. battery-powered cartridge RAM or Real Tim
## See Also ## See Also
* [[GB_load_battery]] * [[GB_load_battery]]
* [[GB_save_battery_to_buffer]] * [[GB_save_battery_to_buffer]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
Returns the battery-backed save size required by the emulator instance's currently loaded ROM, which may be 0. For use with [[GB_save_battery_to_buffer]]. Returns the battery-backed save size required by the emulator instance's currently loaded ROM, which may be 0. This function is used with [[GB_save_battery_to_buffer]].
## Thread Safety ## Thread Safety
@ -15,4 +15,4 @@ Returns the battery-backed save size required by the emulator instance's current
## See Also ## See Also
* [[GB_save_battery_to_buffer]] * [[GB_save_battery_to_buffer]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
Saves battery-backed information (e.g. battery-powered cartridge RAM or Real Time Clock information) from the emulator instance into `buffer`. Returns `0` on success and `EIO` if `size` is less than the value returned by [[GB_save_battery_size]]. Saves battery-backed information (e.g. battery-powered cartridge RAM or Real-Time Clock information) from the emulator instance into `buffer`. Returns `0` on success and `EIO` if `size` is less than the value returned by [[GB_save_battery_size]].
## Thread Safety ## Thread Safety
@ -16,4 +16,4 @@ Saves battery-backed information (e.g. battery-powered cartridge RAM or Real Tim
* [[GB_save_battery_size]] * [[GB_save_battery_size]]
* [[GB_load_battery_from_buffer]] * [[GB_load_battery_from_buffer]]
* [[GB_save_battery]] * [[GB_save_battery]]

@ -14,9 +14,9 @@ Saves a snapshot of the current emulation state of the emulator instance into `p
## Notes ## Notes
SameBoy follows the [BESS](https://github.com/LIJI32/SameBoy/blob/master/BESS.md) specification, and generates save states compatible with other BESS-compliant emulators. SameBoy follows the [BESS](https://github.com/LIJI32/SameBoy/blob/master/BESS.md) specification and generates save states compatible with other BESS-compliant emulators.
## See Also ## See Also
* [[GB_save_state_to_buffer]] * [[GB_save_state_to_buffer]]
* [[GB_load_state]] * [[GB_load_state]]

@ -14,9 +14,9 @@ Saves a snapshot of the current emulation state of the emulator instance into `b
## Notes ## Notes
SameBoy follows the [BESS](https://github.com/LIJI32/SameBoy/blob/master/BESS.md) specification, and generates save states compatible with other BESS-compliant emulators. SameBoy follows the [BESS](https://github.com/LIJI32/SameBoy/blob/master/BESS.md) specification and generates save states compatible with other BESS-compliant emulators.
## See Also ## See Also
* [[GB_save_state]] * [[GB_save_state]]
* [[GB_load_state_from_buffer]] * [[GB_load_state_from_buffer]]

@ -6,7 +6,7 @@ In `joypad.h`
## Description ## Description
A Super Game Boy and Game Boy Player forbid pressing opposing directional buttons (Up + Down or Left + Right) together via software, while other models have their shells physically built to make such button combinations impossible. By default, trying to input these illegal combinations will cause the emulator instance to drop one of the inputs. Use this function to disable this behavior. Super Game Boy and Game Boy Player forbid pressing opposing directional buttons (Up + Down or Left + Right) together via software, while other models have their shells physically built to make such button combinations impossible. By default, trying to input these illegal combinations will cause the emulator instance to drop one of the inputs. Use this function to disable this behavior.
## Thread Safety ## Thread Safety
@ -14,4 +14,4 @@ A Super Game Boy and Game Boy Player forbid pressing opposing directional button
## Notes ## Notes
Some commercial games are known to crash when illegal inputs are made. Some commercial games are known to crash when illegal inputs are made.

@ -23,7 +23,7 @@ In `gb.h`
## Description ## Description
Sets an optional, but recommended callback that lets the emulator instance request a specific boot ROM. This callback is required to allow the `GB_BORDER_ALWAYS` [[border mode|GB_set_border_mode]] to use Super Game Boy borders while emulating a non-Super Game Boy model. When the callback is called, the callee must call either [[GB_load_boot_rom]] or [[GB_load_boot_rom_from_buffer]] to load a suitable boot ROM before returning. Sets an optional but recommended callback that lets the emulator instance request a specific boot ROM. This callback is required to allow the `GB_BORDER_ALWAYS` [[border mode|GB_set_border_mode]] to use Super Game Boy borders while emulating a non-Super Game Boy model. When the callback is called, the callee must call either [[GB_load_boot_rom]] or [[GB_load_boot_rom_from_buffer]] to load a suitable boot ROM before returning.
The possible values for `GB_boot_rom_t` are: The possible values for `GB_boot_rom_t` are:
* `GB_BOOT_ROM_DMG_0`: A boot ROM for the original DMG revision, usually saved as `dmg0_boot.bin` * `GB_BOOT_ROM_DMG_0`: A boot ROM for the original DMG revision, usually saved as `dmg0_boot.bin`
@ -34,9 +34,9 @@ The possible values for `GB_boot_rom_t` are:
* `GB_BOOT_ROM_CGB_0`: A boot ROM for the original CGB revision, usually saved as `cgb0_boot.bin` * `GB_BOOT_ROM_CGB_0`: A boot ROM for the original CGB revision, usually saved as `cgb0_boot.bin`
* `GB_BOOT_ROM_CGB`: A boot ROM for the CGB revisions A to D, usually saved as `cgb_boot.bin` * `GB_BOOT_ROM_CGB`: A boot ROM for the CGB revisions A to D, usually saved as `cgb_boot.bin`
* `GB_BOOT_ROM_CGB_E`: A boot ROM for CGB revision E, usually saved as `cgbE_boot.bin` * `GB_BOOT_ROM_CGB_E`: A boot ROM for CGB revision E, usually saved as `cgbE_boot.bin`
* If this boot ROM revision is not available, the callback can safely fall-back to treating this value as `GB_BOOT_ROM_CGB`. * If this boot ROM revision is not available, the callback can safely fall back to treating this value as `GB_BOOT_ROM_CGB`.
* `GB_BOOT_ROM_AGB_0`: A boot ROM for the original AGB revision, usually saved as `agb0_boot.bin` * `GB_BOOT_ROM_AGB_0`: A boot ROM for the original AGB revision, usually saved as `agb0_boot.bin`
* If this boot ROM revision is not available, the callback can safely fall-back to treating this value as `GB_BOOT_ROM_AGB`. * If this boot ROM revision is not available, the callback can safely fall back to treating this value as `GB_BOOT_ROM_AGB`.
* `GB_BOOT_ROM_AGB`: A boot ROM for all other AGB revisions, usually saved as `agb_boot.bin` * `GB_BOOT_ROM_AGB`: A boot ROM for all other AGB revisions, usually saved as `agb_boot.bin`
## Thread Safety ## Thread Safety
@ -45,4 +45,4 @@ The possible values for `GB_boot_rom_t` are:
## See Also ## See Also
* [[GB_load_boot_rom]] * [[GB_load_boot_rom]]
* [[GB_load_boot_rom_from_buffer]] * [[GB_load_boot_rom_from_buffer]]

@ -15,4 +15,4 @@ Controls overclocking and underclocking of the emulator instance by multiplying
## See Also ## See Also
* [[GB_get_clock_rate]] * [[GB_get_clock_rate]]
* [[GB_get_unmultiplied_clock_rate]] * [[GB_get_unmultiplied_clock_rate]]

@ -18,15 +18,15 @@ In `display.h`
## Description ## Description
The original hardware does not use the sRGB colorspace. This function selects which color correction algorithm is used by the emulator instance to convert RGB values from the model's color space to sRGB. The values supported are: The original hardware does not use the sRGB color space. This function selects which color correction algorithm is used by the emulator instance to convert RGB values from the model's color space to sRGB. The values supported are:
* `GB_COLOR_CORRECTION_DISABLED`: Colors are directly interpreted as sRGB, resulting in unbalanced colors and inaccurate hues * `GB_COLOR_CORRECTION_DISABLED`: Colors are directly interpreted as sRGB, resulting in unbalanced colors and inaccurate hues.
* `GB_COLOR_CORRECTION_CORRECT_CURVES`: Colors have their brightness corrected, but hues remain unbalanced * `GB_COLOR_CORRECTION_CORRECT_CURVES`: Colors have their brightness corrected, but hues remain unbalanced.
* `GB_COLOR_CORRECTION_MODERN_ACCURATE`: Emulates a modern display. Colors have their hues and brightness corrected * `GB_COLOR_CORRECTION_MODERN_ACCURATE`: Emulates a modern display. Colors have their hues and brightness corrected.
* `GB_COLOR_CORRECTION_MODERN_BALANCED`: Emulates a modern display. Blue contrast is moderately enhanced at the cost of slight hue inaccuracy * `GB_COLOR_CORRECTION_MODERN_BALANCED`: Emulates a modern display. Blue contrast is moderately enhanced at the cost of slight hue inaccuracy.
* `GB_COLOR_CORRECTION_MODERN_BOOST_CONTRAST`: Like Modern Balanced, but further boosts the contrast of greens and magentas that is lacking on the original hardware * `GB_COLOR_CORRECTION_MODERN_BOOST_CONTRAST`: Like Modern Balanced, but further boosts the contrast of greens and magentas that is lacking on the original hardware.
* `GB_COLOR_CORRECTION_REDUCE_CONTRAST`: Slightly reduce the contrast to better represent the tint and contrast of the original display * `GB_COLOR_CORRECTION_REDUCE_CONTRAST`: Slightly reduce the contrast to better represent the tint and contrast of the original display.
* `GB_COLOR_CORRECTION_LOW_CONTRAST`: Harshly reduce the contrast to accurately represent the tint and low constrast of the original display * `GB_COLOR_CORRECTION_LOW_CONTRAST`: Harshly reduce the contrast to accurately represent the tint and low contrast of the original display.
The following values are also available as deprecated aliases: The following values are also available as deprecated aliases:
@ -39,14 +39,14 @@ The following values are also available as deprecated aliases:
## Notes ## Notes
The currently emulated [[model|GB_model_t]] affects how color correction behaves. Super Game Boy, Game Boy Color, and Game Boy Advanced can all render the same RGB values as different colors. The currently emulated [[model|GB_model_t]] affects how color correction behaves. Super Game Boy, Game Boy Color, and Game Boy Advance can all render the same RGB values as different colors.
This value is not used when emulating monochrome models because they do not use RGB values. To control the appearance of these models, use [[GB_set_palette|GB_set_palette and GB_get_palette]]. This value is not used when emulating monochrome models because they do not use RGB values. To control the appearance of these models, use [[GB_set_palette|GB_set_palette and GB_get_palette]].
The Super Game Boy colorspace is very similar to sRGB and only requires a correction of the brightness curve. When emulating a Super Game Boy, any color correction mode other than `GB_COLOR_CORRECTION_DISABLED` will be treated like `GB_COLOR_CORRECTION_CORRECT_CURVES`. The Super Game Boy color space is very similar to sRGB and only requires a correction of the brightness curve. When emulating a Super Game Boy, any color correction mode other than `GB_COLOR_CORRECTION_DISABLED` will be treated like `GB_COLOR_CORRECTION_CORRECT_CURVES`.
## See Also ## See Also
* [[GB_set_light_temperature]] * [[GB_set_light_temperature]]
* [[GB_set_palette and GB_get_palette]] * [[GB_set_palette and GB_get_palette]]
* [[GB_set_rgb_encode_callback]] * [[GB_set_rgb_encode_callback]]

@ -6,7 +6,7 @@ In `joypad.h`
## Description ## Description
The physical buttons of various Game Boy models suffer from button bouncing, and do not instantly transition from a released state to a pressed one, and vice versa. This functions controls whether or not this physical behavior should be emulated by software. The physical buttons of various Game Boy models suffer from button bouncing, and do not instantly transition from a released state to a pressed one, and vice versa. This function controls whether or not this physical behavior should be emulated by software.
By default, button bouncing is emulated. By default, button bouncing is emulated.
@ -18,4 +18,4 @@ By default, button bouncing is emulated.
The time it takes for a bouncing button to stabilize depends on the currently emulated [[model|GB_model_t]]. Super Game Boy and Game Boy Player models never emulate joypad bouncing. The time it takes for a bouncing button to stabilize depends on the currently emulated [[model|GB_model_t]]. Super Game Boy and Game Boy Player models never emulate joypad bouncing.
Despite the bouncing pattern being pseudo random, it's completely deterministic and reproducable. Despite the bouncing pattern being pseudo-random, it's completely deterministic and reproducible.

@ -15,11 +15,11 @@ In `apu.h`
## Description ## Description
A real Game Boy has its audio output going through a high-pass filter before reaching the built-in speaker or headphones, which removes the variable DC-offset the digital output generates. This function controls the high-pass filter the emulator instance uses: A real Game Boy has its audio output going through a high-pass filter before reaching the built-in speaker or headphones, which removes the variable DC offset the digital output generates. This function controls the high-pass filter the emulator instance uses:
* `GB_HIGHPASS_OFF`: No high-pass filter is used, the DC offset remains * `GB_HIGHPASS_OFF`: No high-pass filter is used, and the DC offset remains.
* `GB_HIGHPASS_ACCURATE`: A simple high-pass filter is applied; this setting best represents the hardware behavior * `GB_HIGHPASS_ACCURATE`: A simple high-pass filter is applied; this setting best represents the hardware behavior.
* `GB_HIGHPASS_REMOVE_DC_OFFSET`: The DC offset is separated from the actual wave form, and a simple high-pass filter is only applied to the DC offset part * `GB_HIGHPASS_REMOVE_DC_OFFSET`: The DC offset is separated from the actual waveform, and a simple high-pass filter is only applied to the DC offset part.
## Thread Safety ## Thread Safety
@ -27,4 +27,4 @@ A real Game Boy has its audio output going through a high-pass filter before rea
## Notes ## Notes
Keep in mind that the DC offset is not constant prior to applying the high-pass filter. Keep in mind that the DC offset is not constant before applying the high-pass filter.

@ -24,4 +24,4 @@ If `callback` is not NULL, `GB_set_input_callback` and `GB_set_async_input_callb
## Notes ## Notes
The default asynchronous input callback is not supported on Windows; provide a custom callback if you wish to support asynchronous debugger commands on Windows. The default asynchronous input callback is not supported on Windows; provide a custom callback if you wish to support asynchronous debugger commands on Windows.

@ -17,4 +17,4 @@ Sets the state for all of player 1's buttons using a [[mask|GB_key_mask_t]].
* [[GB_key_mask_t]] * [[GB_key_mask_t]]
* [[GB_set_key_state]] * [[GB_set_key_state]]
* [[GB_set_key_mask_for_player]] * [[GB_set_key_mask_for_player]]
* [[GB_get_player_count]] * [[GB_get_player_count]]

@ -17,4 +17,4 @@ For use with Super Game Boy games that support multiplayer. Sets the state for `
* [[GB_key_t]] * [[GB_key_t]]
* [[GB_set_key_state]] * [[GB_set_key_state]]
* [[GB_set_key_mask_for_player]] * [[GB_set_key_mask_for_player]]
* [[GB_get_player_count]] * [[GB_get_player_count]]

@ -6,7 +6,7 @@ In `display.h`
## Description ## Description
Game Boy Color and Game Boy Advance (excluding the SP models) did not have any form of backlight or frontlight, and their display was affected by the ambient light. This function sets the simulated light temperature used when rendering the screen of the emulator instance. The minimum value of `temperature` is `-1.0` which corresponds to a light temperature of 1000K (warm red light), and the maximum value is `1.0` which corresponds to a light temperature of 12000K (cool blue light). The default value is `0.0` which corresponds to 6500K (neutral white), and effectively disables simulation of ambient light temperature. Game Boy Color and Game Boy Advance (excluding the SP models) did not have any form of backlight or frontlight, and their display was affected by the ambient light. This function sets the simulated light temperature used when rendering the screen of the emulator instance. The minimum value of `temperature` is `-1.0`, which corresponds to a light temperature of 1000K (warm red light), and the maximum value is `1.0`, which corresponds to a light temperature of 12000K (cool blue light). The default value is `0.0`, which corresponds to 6500K (neutral white) and effectively disables simulation of ambient light temperature.
## Thread Safety ## Thread Safety
@ -20,4 +20,4 @@ This value is not used when emulating monochrome models because they do not use
* [[GB_set_color_correction_mode]] * [[GB_set_color_correction_mode]]
* [[GB_set_palette and GB_get_palette]] * [[GB_set_palette and GB_get_palette]]
* [[GB_set_rgb_encode_callback]] * [[GB_set_rgb_encode_callback]]

@ -18,4 +18,4 @@ If `callback` is not NULL, `GB_set_log_callback` is thread-safe and can be calle
* [[GB_log_attributes_t]] * [[GB_log_attributes_t]]
* [[GB_log]] * [[GB_log]]
* [[GB_attributed_log]] * [[GB_attributed_log]]

@ -8,7 +8,7 @@ In `display.h`
## Description ## Description
A monochrome [[model|GB_model_t]] renders a screen with 4 colors (usually shades of grey), and potentially a different 5th color used when the LCD display is turned off. These 5 colors are stored in a [[palette struct|GB_palette_t]]. The palette can be changed and read back using these two functions. The default palette is [[GB_PALETTE_GREY|BuiltIn DMG Palettes]]. A monochrome [[model|GB_model_t]] renders a screen with 4 colors (usually shades of grey) and potentially a different 5th color used when the LCD display is turned off. These 5 colors are stored in a [[palette struct|GB_palette_t]]. The palette can be changed and read back using these two functions. The default palette is [[GB_PALETTE_GREY|BuiltIn DMG Palettes]].
## Thread Safety ## Thread Safety
@ -23,4 +23,4 @@ This value is only used when emulating monochrome models.
* [[GB_palette_t]] * [[GB_palette_t]]
* [[BuiltIn DMG Palettes]] * [[BuiltIn DMG Palettes]]
* [[GB_set_rgb_encode_callback]] * [[GB_set_rgb_encode_callback]]
* [[GB_set_color_correction_mode]] * [[GB_set_color_correction_mode]]

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
Call this function with `true` to disable video output in an emulator instance. This will make the [[run loop|GB_run]] of the emulator instance consume less CPU usage, and it's useful in scenarios where you don't need video output (e.g. sound-only applications or automations). Call this function with `true` to disable video output in an emulator instance. This action will cause the [[run loop|GB_run]] of the emulator instance to consume less CPU usage. This is useful in scenarios where video output is unnecessary (e.g., sound-only applications or automations).
## Thread Safety ## Thread Safety

@ -17,4 +17,4 @@ In order for the debugger to support the `backstep` command, a non-zero rewind l
## See Also ## See Also
* [[GB_rewind_pop]] * [[GB_rewind_pop]]
* [[GB_rewind_reset]] * [[GB_rewind_reset]]

@ -39,4 +39,4 @@ If `callback` is not NULL, `GB_set_rgb_encode_callback` is thread-safe and can b
* [[GB_set_palette and GB_get_palette]] * [[GB_set_palette and GB_get_palette]]
* [[GB_set_pixels_output]] * [[GB_set_pixels_output]]
* [[GB_set_rgb_encode_callback]] * [[GB_set_rgb_encode_callback]]
* [[GB_get_screen_width and GB_get_screen_height]] * [[GB_get_screen_width and GB_get_screen_height]]

@ -13,9 +13,9 @@ In `timing.h`
## Description ## Description
Specifies how the emulator instances emulates a Real Time Clock inside an emulated cartridge: Specifies how the emulator instance emulates a Real-Time Clock inside an emulated cartridge:
* `GB_RTC_MODE_SYNC_TO_HOST`: The RTC follows the time in the host's clock. Even when the emulator instance is [[overclocked, underclocked|GB_set_clock_multiplier]], set to [[turbo mode|GB_set_turbo_mode]], or paused, the in-game RTC will always advanced in one real-world-second intervals. * `GB_RTC_MODE_SYNC_TO_HOST`: The RTC follows the time on the host's clock. Even when the emulator instance is [[overclocked, underclocked|GB_set_clock_multiplier]], set to [[turbo mode|GB_set_turbo_mode]], or paused, the in-game RTC will always advance in one real-world-second intervals.
* `GB_RTC_MODE_ACCURATE`: The RTC timings are accurately emulated. Pausing or changing the speed of the instance will also pause or change the speed of the RTC. * `GB_RTC_MODE_ACCURATE`: The RTC timings are accurately emulated. Pausing or changing the speed of the instance will also pause or change the speed of the RTC.
## Thread Safety ## Thread Safety
@ -24,4 +24,4 @@ Specifies how the emulator instances emulates a Real Time Clock inside an emulat
## See Also ## See Also
* [[GB_set_rtc_multiplier]] * [[GB_set_rtc_multiplier]]

@ -25,4 +25,4 @@ The default sample rate is `0`, which disables audio rendering.
## See Also ## See Also
* [[GB_apu_set_sample_callback]] * [[GB_apu_set_sample_callback]]
* [[GB_sample_t]] * [[GB_sample_t]]

@ -10,7 +10,7 @@ In `joypad.h`
## Description ## Description
Set the input hint callback of an emulator instance. This optional callback is called when its "ideal" for a frontend to call [[GB_set_key_state]], etc. Frontends that use polling for user inputs can poll in this callback to minimize input lag. Set the input hint callback of an emulator instance. This optional callback is called when it's "ideal" for a frontend to call [[GB_set_key_state]], etc. Frontends that use polling for user inputs can poll in this callback to minimize input lag.
## Thread Safety ## Thread Safety
@ -21,4 +21,4 @@ If `callback` is not NULL, `GB_set_update_input_hint_callback` is thread-safe an
* [[GB_set_key_state]] * [[GB_set_key_state]]
* [[GB_set_key_mask]] * [[GB_set_key_mask]]
* [[GB_set_key_state_for_player]] * [[GB_set_key_state_for_player]]
* [[GB_set_key_mask_for_player]] * [[GB_set_key_mask_for_player]]

@ -12,4 +12,4 @@ In `gb.h`
## Thread Safety ## Thread Safety
`GB_set_user_data` and `GB_get_user_data` thread-safe and can be called from any thread and context. `GB_set_user_data` and `GB_get_user_data` are thread-safe and can be called from any thread and context.

@ -21,10 +21,10 @@ In `display.h`
Sets a callback that will be called when the emulator instance finishes rendering a frame into the set [[pixel buffer|GB_set_pixels_output]], usually when the LCD controller enters the VBlank stage. The callback will be called even if [[rendering is disabled|GB_set_rendering_disabled]]. The `type` argument for the callback specifies the kind of VBlank event being reported: Sets a callback that will be called when the emulator instance finishes rendering a frame into the set [[pixel buffer|GB_set_pixels_output]], usually when the LCD controller enters the VBlank stage. The callback will be called even if [[rendering is disabled|GB_set_rendering_disabled]]. The `type` argument for the callback specifies the kind of VBlank event being reported:
* `GB_VBLANK_TYPE_NORMAL_FRAME`: A normal frame has finished rendering, the pixel buffer will contain the new frame's data. * `GB_VBLANK_TYPE_NORMAL_FRAME`: A normal frame has finished rendering, and the pixel buffer will contain the new frame's data.
* `GB_VBLANK_TYPE_LCD_OFF`: The LCD has been off for a period of time long enough that requires presenting it to the user, the pixel buffer will contain a solid color. * `GB_VBLANK_TYPE_LCD_OFF`: The LCD has been off for a period of time long enough that requires presenting it to the user, and the pixel buffer will contain a solid color.
* `GB_VBLANK_TYPE_ARTIFICIAL`: The LCD is turned on, but the ROM is preventing the PPU (Pixel Processing Unit) from rendering a complete frame. The pixel buffer will contain a partially rendered frame that may be presented to the user. * `GB_VBLANK_TYPE_ARTIFICIAL`: The LCD is turned on, but the ROM is preventing the PPU (Pixel Processing Unit) from rendering a complete frame. The pixel buffer will contain a partially rendered frame that may be presented to the user.
* `GB_VBLANK_TYPE_REPEAT`: The PPU has finished rendering a frame, but the LCD on a real Game Boy hardware would not display it. The pixels buffer will contain the new frame's data, but an accurate frontend should repeat the previous frame instead of displaying it. * `GB_VBLANK_TYPE_REPEAT`: The PPU has finished rendering a frame, but the LCD on a real Game Boy hardware would not display it. The pixel buffer will contain the new frame's data, but an accurate frontend should repeat the previous frame instead of displaying it.
## Thread Safety ## Thread Safety

@ -6,7 +6,7 @@ In `gb.h`
## Description ## Description
This function will replace the emulator instance's [[model|GB_model_t]], then perform a [[reset|GB_reset]]. This function will replace the emulator instance's [[model|GB_model_t]] and then perform a [[reset|GB_reset]].
## Thread Safety ## Thread Safety
@ -17,4 +17,4 @@ This function will replace the emulator instance's [[model|GB_model_t]], then pe
* [[GB_model_t]] * [[GB_model_t]]
* [[Instance Allocation (GB_init)|Instance Allocation]] * [[Instance Allocation (GB_init)|Instance Allocation]]
* [[GB_reset]] * [[GB_reset]]
* [[GB_quick_reset]] * [[GB_quick_reset]]

@ -6,7 +6,7 @@ In `memory.h`
## Description ## Description
Performs an 8-bit memory write on a 16-bit address on the emulator instance, as if it was performed by the SM83 CPU Performs an 8-bit memory write on a 16-bit address on the emulator instance, as if it were performed by the SM83 CPU.
## Thread Safety ## Thread Safety
@ -14,12 +14,12 @@ Performs an 8-bit memory write on a 16-bit address on the emulator instance, as
## Notes ## Notes
The ROM is not writable, as the CPU is unable to perform a ROM write. Attempting to write to the ROM will perform an MBC register write, just like as if the write was performed by the CPU. To dynamically modify the ROM, use [[GB_get_direct_access]]. The ROM is not writable, as the CPU is unable to perform a ROM write. Attempting to write to the ROM will perform an MBC register write, just as if the write was performed by the CPU. To dynamically modify the ROM, use [[GB_get_direct_access]].
To write data outside of a currently mapped bank, or to write to a memory region that might not be currently writeable (e.g. VRAM during mode 3), you can use [[GB_get_direct_access]]. To write data outside of a currently mapped bank, or to write to a memory region that might not be currently writable (e.g., VRAM during mode 3), you can use [[GB_get_direct_access]].
## See Also ## See Also
* [[GB_read_memory]] * [[GB_read_memory]]
* [[GB_safe_read_memory]] * [[GB_safe_read_memory]]
* [[GB_get_direct_access]] * [[GB_get_direct_access]]

@ -39,7 +39,7 @@ enum {
GB_IO_NR41 = 0x20, // Channel 4 Sound Length (R/W) GB_IO_NR41 = 0x20, // Channel 4 Sound Length (R/W)
GB_IO_NR42 = 0x21, // Channel 4 Volume Envelope (R/W) GB_IO_NR42 = 0x21, // Channel 4 Volume Envelope (R/W)
GB_IO_NR43 = 0x22, // Channel 4 Polynomial Counter (R/W) GB_IO_NR43 = 0x22, // Channel 4 Polynomial Counter (R/W)
GB_IO_NR44 = 0x23, // Channel 4 Counter/consecutive, Inital (R/W) GB_IO_NR44 = 0x23, // Channel 4 Counter/consecutive, Initial (R/W)
GB_IO_NR50 = 0x24, // Channel control / ON-OFF / Volume (R/W) GB_IO_NR50 = 0x24, // Channel control / ON-OFF / Volume (R/W)
GB_IO_NR51 = 0x25, // Selection of Sound output terminal (R/W) GB_IO_NR51 = 0x25, // Selection of Sound output terminal (R/W)
GB_IO_NR52 = 0x26, // Sound on/off GB_IO_NR52 = 0x26, // Sound on/off
@ -124,6 +124,6 @@ In `gb.h`
Constants for accessing memory-mapped IO registers. `GB_IO_*` constants are offsets from the MMIO base (`0xFF00`). `GB_LCDC_*` constants are bit masks for the LCDC register. Constants for accessing memory-mapped IO registers. `GB_IO_*` constants are offsets from the MMIO base (`0xFF00`). `GB_LCDC_*` constants are bit masks for the LCDC register.
## See Also ## See Also
* [[GB_read_memory]] * [[GB_read_memory]]
* [[GB_write_memory]] * [[GB_write_memory]]
* [[GB_get_direct_access]] * [[GB_get_direct_access]]

@ -31,7 +31,7 @@ GB_gameboy_t *gb = GB_init(GB_alloc(), model);
/* GB_free(gb); */ // optional /* GB_free(gb); */ // optional
GB_dealloc(gb); GB_dealloc(gb);
``` ```
`GB_alloc` will allocate a buffer with the right size for your instance, which can then be initialized with `GB_init`. `GB_delloc` will call `GB_free` if it wasn't already called, and free the allocated buffer. For convenience, `GB_init` always returns the first argument back. `GB_alloc` will allocate a buffer with the right size for your instance, which can then be initialized with `GB_init`. `GB_dealloc` will call `GB_free` if it wasn't already called and free the allocated buffer. For convenience, `GB_init` always returns the first argument back.
3. Manually allocated: 3. Manually allocated:
```c ```c
@ -40,9 +40,9 @@ GB_gameboy_t *gb = GB_init(my_custom_malloc(GB_allocation_size()), model);
GB_free(gb); GB_free(gb);
my_custom_free(gb); my_custom_free(gb);
``` ```
Using `GB_allocation_size` you can obtain the required buffer size for an instance, which can then be used to allocate a buffer for it using any arbitrary allocation method. Using `GB_allocation_size`, you can obtain the required buffer size for an instance, which can then be used to allocate a buffer for it using any arbitrary allocation method.
Additionally, `GB_is_inited` will return `true` if a [[GB_gameboy_t]] instance is initialized in a given buffer. If an instance is allocated in such before, it must be first freed with `GB_free` or `GB_dealloc` before being deallocated. Additionally, `GB_is_inited` will return `true` if a [[GB_gameboy_t]] instance is initialized in a given buffer. If an instance is allocated in such a way before, it must be first freed with `GB_free` or `GB_dealloc` before being deallocated.
## Thread Safety ## Thread Safety
`GB_free` and `GB_dealloc` must not be called if the instance is being run in any thread, including the current one (via a callback). `GB_free` and `GB_dealloc` must not be called if the instance is being run in any thread, including the current one (via a callback).
@ -54,4 +54,4 @@ Additionally, `GB_is_inited` will return `true` if a [[GB_gameboy_t]] instance i
* [[GB_gameboy_t]] * [[GB_gameboy_t]]
* [[GB_model_t]] * [[GB_model_t]]
* [[GB_reset]] * [[GB_reset]]
* [[GB_switch_model_and_reset]] * [[GB_switch_model_and_reset]]