gb.rsannotatedgb.rssource67 lines · 2.2 KB · raw
1use gb_config::{GbAspectRatio, GbAudioResampler, GbPalette, GbcColorCorrection};
2use jgenesis_proc_macros::deserialize_default_on_error;
3use serde::{Deserialize, Serialize};
4use std::path::PathBuf;

Default to black and white

7const DEFAULT_GB_CUSTOM_PALETTE: [(u8, u8, u8); 4] =
8    [(0xFF, 0xFF, 0xFF), (0xAA, 0xAA, 0xAA), (0x55, 0x55, 0x55), (0x00, 0x00, 0x00)];

Slightly brighten

11const DEFAULT_GBC_GAMMA: f64 = 2.0;

Significantly darken

14const DEFAULT_GBA_GAMMA: f64 = 3.2;
16#[deserialize_default_on_error]
17#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
18#[serde(default)]
19pub struct GameBoyAppConfig {
20    pub force_dmg_mode: bool,
21    pub force_cgb_mode: bool,
22    pub pretend_to_be_gba: bool,
23    pub dmg_boot_rom: bool,
24    pub cgb_boot_rom: bool,
25    pub dmg_boot_rom_path: Option<PathBuf>,
26    pub cgb_boot_rom_path: Option<PathBuf>,
27    pub aspect_ratio: GbAspectRatio,
28    pub gb_palette: GbPalette,
29    pub gb_custom_palette: [(u8, u8, u8); 4],
30    pub gbc_color_correction: GbcColorCorrection,
31    pub gbc_correction_gamma: f64,
32    pub gba_correction_gamma: f64,
33    pub frame_blending: bool,
34    pub audio_resampler: GbAudioResampler,
35    pub audio_60hz_hack: bool,
36    pub allow_opposing_joypad_directions: bool,
37}
38
39#[must_use]
40pub const fn default_gb_custom_palette() -> [(u8, u8, u8); 4] {
41    // Default to black and white
42    [(0xFF, 0xFF, 0xFF), (0xAA, 0xAA, 0xAA), (0x55, 0x55, 0x55), (0x00, 0x00, 0x00)]
43}
44
45impl Default for GameBoyAppConfig {
46    fn default() -> Self {
47        Self {
48            force_dmg_mode: false,
49            force_cgb_mode: false,
50            pretend_to_be_gba: false,
51            dmg_boot_rom: false,
52            cgb_boot_rom: false,
53            dmg_boot_rom_path: None,
54            cgb_boot_rom_path: None,
55            aspect_ratio: GbAspectRatio::default(),
56            gb_palette: GbPalette::default(),
57            gb_custom_palette: DEFAULT_GB_CUSTOM_PALETTE,
58            gbc_color_correction: GbcColorCorrection::default(),
59            gbc_correction_gamma: DEFAULT_GBC_GAMMA,
60            gba_correction_gamma: DEFAULT_GBA_GAMMA,
61            frame_blending: true,
62            audio_resampler: GbAudioResampler::default(),
63            audio_60hz_hack: false,
64            allow_opposing_joypad_directions: false,
65        }
66    }
67}