manager.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Mapper manager - The peTI-NESulator Project
  3. * manager.c
  4. *
  5. * Created by Manoel TRAPIER.
  6. * Copyright (c) 2003-2018 986-Studio. All rights reserved.
  7. *
  8. * $LastChangedDate$
  9. * $Author$
  10. * $HeadURL$
  11. * $Revision$
  12. *
  13. */
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <mappers/manager.h>
  17. #include <os_dependent.h>
  18. MapperIRQ mapper_irqloop;
  19. MapperDump mapper_dump;
  20. MapperWriteHook mapper_hook;
  21. typedef struct Mapper_
  22. {
  23. byte id;
  24. char *name;
  25. MapperInit init;
  26. MapperIRQ irq;
  27. MapperDump dump;
  28. } Mapper;
  29. #include "mappers_list.h"
  30. void mapper_list ()
  31. {
  32. Mapper *ptr = &(Mappers[0]);
  33. console_printf(Console_Default, "Available mapers:\n");
  34. while(ptr->name != NULL)
  35. {
  36. console_printf(Console_Default, "%d - %s\n", ptr->id, ptr->name);
  37. ptr++;
  38. }
  39. }
  40. int mapper_init (NesCart *cart)
  41. {
  42. Mapper *ptr = &(Mappers[0]);
  43. console_printf (Console_Default, "Search for a compatible mapper ID #%d:\n", cart->MapperID);
  44. while (ptr->name != NULL)
  45. {
  46. if (ptr->id == cart->MapperID)
  47. {
  48. console_printf (Console_Default, "Found mapper ID #%d - '%s'\n", ptr->id, ptr->name);
  49. if (ptr->init)
  50. ptr->init (cart);
  51. mapper_irqloop = ptr->irq;
  52. mapper_dump = ptr->dump;
  53. return 0;
  54. }
  55. ptr++;
  56. }
  57. console_printf (Console_Default, "No compatible mapper found!\n");
  58. return -1;
  59. }