manager.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Mapper manager - The TI-NESulator Project
  3. * manager.c
  4. *
  5. * Created by Manoel TRAPIER.
  6. * Copyright (c) 2003-2008 986Corp. 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 #%X:\n", cart->MapperID);
  44. while (ptr->name != NULL)
  45. {
  46. if (ptr->id == cart->MapperID)
  47. {
  48. console_printf (Console_Default, "Found mapper ID #%X - '%s'\n", ptr->id, ptr->name);
  49. ptr->init (cart);
  50. mapper_irqloop = ptr->irq;
  51. mapper_dump = ptr->dump;
  52. return 0;
  53. }
  54. ptr++;
  55. }
  56. return -1;
  57. }