debug.c 1001 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "data.h"
  2. #include "pad.h"
  3. #include "PPU.h"
  4. #include "ressource.h"
  5. #include "crc.h"
  6. word debugMap[0x400];
  7. void initDebugMap(void) {
  8. word i;
  9. for(i=0; i<0x400; i++) {
  10. debugMap[i] = 0x00;
  11. }
  12. }
  13. void int2hex(word i, char *buf)
  14. {
  15. word a;
  16. for (a = 0; a < 4; ++a) {
  17. buf[a] = (i >> (4 * (2 * 2 - 1 - a))) & 0xf;
  18. if (buf[a] < 10)
  19. buf[a] += '0';
  20. else
  21. buf[a] += 'A' - 10;
  22. }
  23. buf[a] = 0;
  24. }
  25. void writeln(char *buffer,word y){
  26. char i;
  27. waitForVBlank();
  28. for(i=0; i<32; i++) {
  29. waitForVBlank();
  30. VRAMByteWrite((byte) (buffer[i]-32), (word) (0x4000+i+(y*0x20)));
  31. }
  32. }
  33. void enableDebugScreen(void){
  34. VRAMLoad((word) debugFont_pic, 0x5000, 2048);
  35. CGRAMLoad((word) debugFont_pal, (byte) 0x00, (word) 16);
  36. VRAMLoad((word) debugMap, 0x4000, 0x0800);
  37. setTileMapLocation(0x4000, (byte) 0x00, (byte) 0);
  38. setCharacterLocation(0x5000, (byte) 0);
  39. *(byte*) 0x2100 = 0x0f; // enable background
  40. }