NESe (pronounced "Nessie") is a NES emulator based on the e6502 emulator, also written in C with a focus on speed and portability for use on embedded platforms, especially ARM.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

73 Zeilen
1.3KB

  1. #include <errno.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4. #include <sys/mman.h>
  5. #include "nese.h"
  6. #include "port.h"
  7. #define DEBUG "Port"
  8. #include "log.h"
  9. void* nese_map_file(FILE* file, int size) {
  10. void* addr = mmap(NULL, size, PROT_READ, MAP_SHARED,
  11. fileno(file), 0);
  12. if (MAP_FAILED == addr || NULL == addr) {
  13. fprintf(stderr, "mmap failed: %d\n", (int)errno);
  14. addr = NULL;
  15. }
  16. return addr;
  17. }
  18. int nese_unmap_file(void* addr, int size) {
  19. return munmap(addr, size);
  20. }
  21. int nese_frame_ready() {
  22. /*
  23. static int frame = 0;
  24. static int ignore = 1;
  25. static struct timespec t_last = {0};
  26. struct timespec t_now = {0};
  27. ++frame;
  28. clock_gettime(CLOCK_MONOTONIC, &t_now);
  29. if (t_now.tv_sec > t_last.tv_sec) {
  30. if (!ignore) printf("%d\n", frame);
  31. frame = 0;
  32. ignore = 0;
  33. }
  34. t_last = t_now;
  35. */
  36. // TODO: Render frame
  37. // TODO: Time sync
  38. // TODO: Handle quit signal
  39. // TODO: Perform menu actions
  40. return 0;
  41. }
  42. int nese_update_input(nes_Input* input) {
  43. // TODO: Populate the gamepad states
  44. return 0;
  45. }
  46. static nes sys = {0};
  47. int main(int argc, char* argv[]) {
  48. int status = 0;
  49. if (argc <= 1) {
  50. LOGE("No ROM file provided.");
  51. status = -1;
  52. } else {
  53. status = nese_start(&sys, argv[1]);
  54. }
  55. return status;
  56. }