config.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. class Configuration : public configuration {
  2. public:
  3. struct System {
  4. string video, audio, input;
  5. bool crashedOnLastRun;
  6. unsigned speed;
  7. } system;
  8. struct Video {
  9. bool isFullscreen;
  10. bool synchronize;
  11. signed contrastAdjust, brightnessAdjust, gammaAdjust;
  12. bool enableGammaRamp;
  13. bool enableNtscMergeFields;
  14. double ntscAspectRatio, palAspectRatio;
  15. struct Context {
  16. bool correctAspectRatio;
  17. unsigned multiplier, region;
  18. unsigned hwFilter, swFilter;
  19. } *context, windowed, fullscreen;
  20. } video;
  21. struct Audio {
  22. bool synchronize;
  23. bool mute;
  24. unsigned volume, latency, outputFrequency, inputFrequency;
  25. } audio;
  26. struct Input {
  27. enum policy_t { FocusPolicyPauseEmulation, FocusPolicyIgnoreInput, FocusPolicyAllowInput };
  28. unsigned focusPolicy;
  29. bool allowInvalidInput;
  30. struct Joypad {
  31. string up, down, left, right, a, b, x, y, l, r, select, start;
  32. } joypad1, joypad2,
  33. multitap1a, multitap1b, multitap1c, multitap1d,
  34. multitap2a, multitap2b, multitap2c, multitap2d;
  35. struct Mouse {
  36. string x, y, left, right;
  37. } mouse1, mouse2;
  38. struct SuperScope {
  39. string x, y, trigger, turbo, cursor, pause;
  40. } superscope;
  41. struct Justifier {
  42. string x, y, trigger, start;
  43. } justifier1, justifier2;
  44. struct UiGeneral {
  45. string loadCartridge;
  46. string pauseEmulation;
  47. string resetSystem;
  48. string triggerIrq;
  49. string powerCycleSystem;
  50. string lowerSpeed;
  51. string raiseSpeed;
  52. string toggleCheatSystem;
  53. string toggleFullscreen;
  54. string toggleMenu;
  55. string toggleStatus;
  56. string exitEmulator;
  57. } uiGeneral;
  58. } input;
  59. Configuration() {
  60. //========
  61. //external
  62. //========
  63. attach(snes.config.controller_port1 = SNES::Input::DeviceJoypad, "snes.controllerPort1");
  64. attach(snes.config.controller_port2 = SNES::Input::DeviceJoypad, "snes.controllerPort2");
  65. attach(snes.config.expansion_port = SNES::ExpansionBSX, "snes.expansionPort");
  66. attach(snes.config.region = SNES::Autodetect, "snes.region");
  67. attach(snes.config.file.autodetect_type = false, "file.autodetectType");
  68. attach(snes.config.file.bypass_patch_crc32 = false, "file.bypassPatchCrc32");
  69. attach(snes.config.path.rom = "", "path.rom");
  70. attach(snes.config.path.save = "", "path.save");
  71. attach(snes.config.path.patch = "", "path.patch");
  72. attach(snes.config.path.cheat = "", "path.cheat");
  73. attach(snes.config.path.data = "", "path.data");
  74. attach(snes.config.path.bsx = "", "path.bsx");
  75. attach(snes.config.path.st = "", "path.st");
  76. attach(snes.config.cpu.version = 2, "cpu.version", "Valid version(s) are: 1, 2");
  77. attach(snes.config.cpu.ntsc_clock_rate = 21477272, "cpu.ntscClockRate");
  78. attach(snes.config.cpu.pal_clock_rate = 21281370, "cpu.palClockRate");
  79. attach(snes.config.cpu.alu_mul_delay = 2, "cpu.aluMulDelay");
  80. attach(snes.config.cpu.alu_div_delay = 2, "cpu.aluDivDelay");
  81. attach(snes.config.cpu.wram_init_value = 0x55, "cpu.wramInitValue");
  82. attach(snes.config.smp.ntsc_clock_rate = 32041 * 768, "smp.ntscClockRate");
  83. attach(snes.config.smp.pal_clock_rate = 32041 * 768, "smp.palClockRate");
  84. attach(snes.config.ppu1.version = 1, "ppu1.version", "Valid version(s) are: 1");
  85. attach(snes.config.ppu2.version = 3, "ppu2.version", "Valid version(s) are: 1, 2, 3");
  86. //========
  87. //internal
  88. //========
  89. attach(system.video = "", "system.video");
  90. attach(system.audio = "", "system.audio");
  91. attach(system.input = "", "system.input");
  92. attach(system.crashedOnLastRun = false, "system.crashedOnLastRun");
  93. attach(system.speed = 2, "system.speed");
  94. video.context = &video.windowed;
  95. attach(video.isFullscreen = false, "video.isFullscreen");
  96. attach(video.synchronize = false, "video.synchronize");
  97. attach(video.contrastAdjust = 0, "video.contrastAdjust");
  98. attach(video.brightnessAdjust = 0, "video.brightnessAdjust");
  99. attach(video.gammaAdjust = 0, "video.gammaAdjust");
  100. attach(video.enableGammaRamp = true, "video.enableGammaRamp");
  101. attach(video.enableNtscMergeFields = false, "video.enableNtscMergeFields");
  102. attach(video.ntscAspectRatio = 54.0 / 47.0, "video.ntscAspectRatio", "NTSC aspect ratio (x / y)");
  103. attach(video.palAspectRatio = 32.0 / 23.0, "video.palAspectRatio", "PAL aspect ratio (x / y)");
  104. attach(video.windowed.correctAspectRatio = true, "video.windowed.correctAspectRatio");
  105. attach(video.windowed.multiplier = 2, "video.windowed.multiplier");
  106. attach(video.windowed.region = 0, "video.windowed.region");
  107. attach(video.windowed.hwFilter = 1, "video.windowed.hwFilter");
  108. attach(video.windowed.swFilter = 0, "video.windowed.swFilter");
  109. attach(video.fullscreen.correctAspectRatio = true, "video.fullscreen.correctAspectRatio");
  110. attach(video.fullscreen.multiplier = 9, "video.fullscreen.multiplier");
  111. attach(video.fullscreen.region = 0, "video.fullscreen.region");
  112. attach(video.fullscreen.hwFilter = 1, "video.fullscreen.hwFilter");
  113. attach(video.fullscreen.swFilter = 0, "video.fullscreen.swFilter");
  114. attach(audio.synchronize = true, "audio.synchronize");
  115. attach(audio.mute = false, "audio.mute");
  116. attach(audio.volume = 100, "audio.volume");
  117. attach(audio.latency = 80, "audio.latency");
  118. attach(audio.outputFrequency = 48000, "audio.outputFrequency");
  119. attach(audio.inputFrequency = 32000, "audio.inputFrequency");
  120. attach(input.focusPolicy = Input::FocusPolicyPauseEmulation, "input.focusPolicy");
  121. attach(input.allowInvalidInput = false, "input.allowInvalidInput", "Allow up+down / left+right combinations; may trigger bugs in some games");
  122. attach(input.joypad1.up = "keyboard00.up", "input.joypad1.up");
  123. attach(input.joypad1.down = "keyboard00.down", "input.joypad1.down");
  124. attach(input.joypad1.left = "keyboard00.left", "input.joypad1.left");
  125. attach(input.joypad1.right = "keyboard00.right", "input.joypad1.right");
  126. attach(input.joypad1.a = "keyboard00.x", "input.joypad1.a");
  127. attach(input.joypad1.b = "keyboard00.z", "input.joypad1.b");
  128. attach(input.joypad1.x = "keyboard00.s", "input.joypad1.x");
  129. attach(input.joypad1.y = "keyboard00.a", "input.joypad1.y");
  130. attach(input.joypad1.l = "keyboard00.d", "input.joypad1.l");
  131. attach(input.joypad1.r = "keyboard00.c", "input.joypad1.r");
  132. attach(input.joypad1.select = "keyboard00.rshift", "input.joypad1.select");
  133. attach(input.joypad1.start = "keyboard00.return", "input.joypad1.start");
  134. //these are all mapped to "none" by default
  135. attachJoypad(input.joypad2, "input.joypad2");
  136. attachJoypad(input.multitap1a, "input.multitap1a");
  137. attachJoypad(input.multitap1b, "input.multitap1b");
  138. attachJoypad(input.multitap1c, "input.multitap1c");
  139. attachJoypad(input.multitap1d, "input.multitap1d");
  140. attachJoypad(input.multitap2a, "input.multitap2a");
  141. attachJoypad(input.multitap2b, "input.multitap2b");
  142. attachJoypad(input.multitap2c, "input.multitap2c");
  143. attachJoypad(input.multitap2d, "input.multitap2d");
  144. attach(input.mouse1.x = "mouse00.x", "input.mouse1.x");
  145. attach(input.mouse1.y = "mouse00.y", "input.mouse1.y");
  146. attach(input.mouse1.left = "mouse00.button00", "input.mouse1.left");
  147. attach(input.mouse1.right = "mouse00.button02", "input.mouse1.right");
  148. //more likely a user will only use one mouse at a time, than for a system to have two mice
  149. attach(input.mouse2.x = "mouse00.x", "input.mouse2.x");
  150. attach(input.mouse2.y = "mouse00.y", "input.mouse2.y");
  151. attach(input.mouse2.left = "mouse00.button00", "input.mouse2.left");
  152. attach(input.mouse2.right = "mouse00.button02", "input.mouse2.right");
  153. //unlikely a user will have a five-button mouse for turbo / pause mapping
  154. attach(input.superscope.x = "mouse00.x", "input.superscope.x");
  155. attach(input.superscope.y = "mouse00.y", "input.superscope.y");
  156. attach(input.superscope.trigger = "mouse00.button00", "input.superscope.trigger");
  157. attach(input.superscope.cursor = "mouse00.button02", "input.superscope.cursor");
  158. attach(input.superscope.turbo = "keyboard00.t", "input.superscope.turbo");
  159. attach(input.superscope.pause = "keyboard00.p", "input.superscope.pause");
  160. attach(input.justifier1.x = "mouse00.x", "input.justifier1.x");
  161. attach(input.justifier1.y = "mouse00.y", "input.justifier1.y");
  162. attach(input.justifier1.trigger = "mouse00.button00", "input.justifier1.trigger");
  163. attach(input.justifier1.start = "mouse00.button02", "input.jusitifer1.start");
  164. attach(input.justifier2.x = "mouse01.x", "input.justifier2.x");
  165. attach(input.justifier2.y = "mouse01.y", "input.justifier2.y");
  166. attach(input.justifier2.trigger = "mouse01.button00", "input.justifier2.trigger");
  167. attach(input.justifier2.start = "mouse01.button02", "input.justifier2.start");
  168. attach(input.uiGeneral.loadCartridge = "none", "input.uiGeneral.loadCartridge");
  169. attach(input.uiGeneral.pauseEmulation = "keyboard00.pause", "input.uiGeneral.pauseEmulation");
  170. attach(input.uiGeneral.resetSystem = "none", "input.uiGeneral.resetSystem");
  171. attach(input.uiGeneral.triggerIrq = "none", "input.uiGeneral.triggerIrq");
  172. attach(input.uiGeneral.powerCycleSystem = "none", "input.uiGeneral.powerCycleSystem");
  173. attach(input.uiGeneral.lowerSpeed = "keyboard00.divide", "input.uiGeneral.lowerSpeed");
  174. attach(input.uiGeneral.raiseSpeed = "keyboard00.multiply", "input.uiGeneral.raiseSpeed");
  175. attach(input.uiGeneral.toggleCheatSystem = "none", "input.uiGeneral.toggleCheatSystem");
  176. attach(input.uiGeneral.toggleFullscreen = "keyboard00.f11", "input.uiGeneral.toggleFullscreen");
  177. attach(input.uiGeneral.toggleMenu = "keyboard00.escape", "input.uiGeneral.toggleMenu");
  178. attach(input.uiGeneral.toggleStatus = "keyboard00.escape", "input.uiGeneral.toggleStatus");
  179. attach(input.uiGeneral.exitEmulator = "none", "input.uiGeneral.exitEmulator");
  180. }
  181. void attachJoypad(Input::Joypad &joypad, const char *name) {
  182. attach(joypad.up = "none", string() << name << ".up");
  183. attach(joypad.down = "none", string() << name << ".down");
  184. attach(joypad.left = "none", string() << name << ".left");
  185. attach(joypad.right = "none", string() << name << ".right");
  186. attach(joypad.a = "none", string() << name << ".a");
  187. attach(joypad.b = "none", string() << name << ".b");
  188. attach(joypad.x = "none", string() << name << ".x");
  189. attach(joypad.y = "none", string() << name << ".y");
  190. attach(joypad.l = "none", string() << name << ".l");
  191. attach(joypad.r = "none", string() << name << ".r");
  192. attach(joypad.select = "none", string() << name << ".select");
  193. attach(joypad.start = "none", string() << name << ".start");
  194. }
  195. bool load(const char *filename) {
  196. if(configuration::load(filename) == false) return false;
  197. video.context = (video.isFullscreen == false) ? &video.windowed : &video.fullscreen;
  198. return true;
  199. }
  200. } config;