deltabeard / Peanut-GB

A Game Boy (DMG) emulator single header library written in C99. Performance is prioritised over accuracy.
https://projects.deltabeard.com/peanutgb/
283 stars 40 forks source link

input: use various methods of updating button presses #13

Closed deltabeard closed 5 years ago

deltabeard commented 5 years ago

Create a gb_init_input() function that allows the front-end to configure how to update the button presses.

  1. (Default) Calling a function already defined in the library at any time (eg. for an interrupt) to update the joypad registers.
  2. Calling a given front-end function whenever the game reads the joypad input registers.
deltabeard commented 5 years ago
  1. Calling a function already defined in the library before gb_run_frame(). This is what is currently done, and I don't think the other two options posses any significant advantage over this. However, the front-end should not have to modify values within the emulator context (gb_t). This should be changed.
deltabeard commented 5 years ago

In the end, I went with:

  1. Don't change it if it ain't broken.

Instead, I cleaned up the implementation a bit by removing unnecessary operations and a function in 4aff06be48c9b5c43cb252fa8237a93b11b166a1.