main.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <time.h>
  4. #include "data.h";
  5. #include "pad.h";
  6. #include "event.h";
  7. #include "myEvents.h";
  8. #include "ressource.h";
  9. #include "PPU.h"
  10. #include "debug.h"
  11. #include "integer.h"
  12. typedef void (*FUNC) (void);
  13. padStatus pad1;
  14. void initInternalRegisters(void)
  15. {
  16. characterLocation[0] = 0x0000;
  17. characterLocation[1] = 0x0000;
  18. characterLocation[2] = 0x0000;
  19. characterLocation[3] = 0x0000;
  20. debug_init();
  21. }
  22. void preInit(void)
  23. {
  24. // For testing purpose ...
  25. // Insert code here to be executed before register init
  26. }
  27. void halt(void)
  28. {
  29. while (1);
  30. }
  31. void wait(void)
  32. {
  33. printfc("SNES::wait: press A to continue\n");
  34. enablePad();
  35. pad1 = readPad((byte) 0);
  36. while (!pad1.A) {
  37. waitForVBlank();
  38. pad1 = readPad((byte) 0);
  39. }
  40. printfc("SNES::wait: done\n");
  41. }
  42. void boot(DWORD addr)
  43. {
  44. FUNC fn;
  45. //printfc("SNES::boot addr=%lx\n", addr);
  46. fn = (FUNC) addr;
  47. fn();
  48. }
  49. unsigned char i;
  50. unsigned char j;
  51. void main(void)
  52. {
  53. initInternalRegisters();
  54. *(byte *) 0x2105 = 0x01; // MODE 1 value
  55. *(byte *) 0x212c = 0x01; // Plane 0 (bit one) enable register
  56. *(byte *) 0x212d = 0x00; // All subPlane disable
  57. *(byte *) 0x2100 = 0x0f; // enable background
  58. debug_enable();
  59. i=0;
  60. j=0;
  61. while (1) {
  62. printfs(0,"IRQ COUNT %i", i);
  63. printfs(1,"NMI COUNT %i", j++);
  64. waitForVBlank();
  65. }
  66. }
  67. void IRQHandler(void)
  68. {
  69. i = i + 1;
  70. }
  71. void NMIHandler(void)
  72. {
  73. // processEvents();
  74. }