manager.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. MapperIRQ mapper_irqloop;
  18. MapperDump mapper_dump;
  19. MapperWriteHook mapper_hook;
  20. typedef struct Mapper_
  21. {
  22. byte id;
  23. char *name;
  24. MapperInit init;
  25. MapperIRQ irq;
  26. MapperDump dump;
  27. } Mapper;
  28. #include "mappers_list.h"
  29. void mapper_list ()
  30. {
  31. Mapper *ptr = &(Mappers[0]);
  32. printf("Available mapers:\n");
  33. while(ptr->name != NULL)
  34. {
  35. printf("%d - %s\n", ptr->id, ptr->name);
  36. ptr++;
  37. }
  38. }
  39. int mapper_init (NesCart *cart)
  40. {
  41. Mapper *ptr = &(Mappers[0]);
  42. printf ("Search for a compatible mapper ID #%X:\n", cart->MapperID);
  43. while (ptr->name != NULL)
  44. {
  45. if (ptr->id == cart->MapperID)
  46. {
  47. printf ("Found mapper ID #%X - '%s'\n", ptr->id, ptr->name);
  48. ptr->init (cart);
  49. mapper_irqloop = ptr->irq;
  50. mapper_dump = ptr->dump;
  51. return 0;
  52. }
  53. ptr++;
  54. }
  55. return -1;
  56. }