main.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. void main(void)
  50. {
  51. unsigned char i,j;
  52. unsigned long addr;
  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. #if 0
  60. addr = 0x008000;
  61. for (i=0;i<28;i++){
  62. printfs(i,"ROW %02i %02X %08li %06lX",i,i,addr,addr);
  63. printfc("ROW %02i %02X %08li %06lX\n",i,i,addr,addr);
  64. addr += 0x10000;
  65. }
  66. #endif
  67. #define START_ADDR 0x020000
  68. #define END_ADDR 0x7f2000
  69. addr = 0x000000;
  70. i=0;
  71. j=0;
  72. for (addr=START_ADDR; addr < END_ADDR; addr+=0x1000){
  73. if (addr > START_ADDR && addr%0x2000==0){
  74. //printfc("hit %06lx\n",addr);
  75. addr += 0x10000 - 0x2000;
  76. j++;
  77. if (j>26)
  78. j=0;
  79. }
  80. i++;
  81. printfc("fill mem=%06lx tag=%02x tag=%i \n", addr, i, i);
  82. *(byte *) (addr) = i;
  83. }
  84. i=0;
  85. j=0;
  86. for (addr=START_ADDR; addr < END_ADDR; addr+=0x1000){
  87. if (addr > START_ADDR && addr%0x2000==0){
  88. addr += 0x10000 - 0x2000;
  89. i++;
  90. j++;
  91. if (j>26)
  92. j=0;
  93. }
  94. printfs(j,"DUMP %06lX ",addr);
  95. printc_packet(addr,16,(byte *) (addr));
  96. }
  97. while (1) {
  98. wait();
  99. }
  100. }
  101. void IRQHandler(void)
  102. {
  103. }
  104. void NMIHandler(void)
  105. {
  106. // processEvents();
  107. }