Guest User

draw384x224

a guest
Feb 9th, 2021
21
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void drawDoomImage() {
  2. u16 x = 0;
  3. u16 y = 0;
  4. u16 w = 0;
  5. u16 h = 0;
  6. u16 i = 0;
  7. u16 j = 0;
  8. u8 shade = 3;
  9. u8 parallax = 0;
  10. u8 height = 8;
  11. u8 width = 8;
  12. unsigned int pixelData;
  13. u8 byteArr[] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
  14.  
  15. for (i = 0; i < 5376; i+=4) {
  16. for (j = 0; j < 4; j++) {
  17. pixelData = title_screen_384x224Tiles[i+j];
  18. byteArr[0+j*4] = (pixelData >> 24) & 0x000000FF;
  19. byteArr[1+j*4] = (pixelData >> 16) & 0x000000FF;
  20. byteArr[2+j*4] = (pixelData >> 8) & 0x000000FF;
  21. byteArr[3+j*4] = (pixelData >> 0) & 0x000000FF;
  22. }
  23.  
  24. x = (i*2)%384;
  25. y = ((i*2)/384)*8;
  26.  
  27. for (h = 0; h < height; h++) {
  28. for (w = 0; w < width; w++) {
  29. u8 hiBit = (byteArr[h*2 + 1] >> (7-w)) & 1;
  30. u8 loBit = (byteArr[h*2 + 0] >> (7-w)) & 1;
  31. shade = (hiBit << 1) | loBit;
  32. // draws pixel with buffhln (more efficient than buffvln or buffln) with length of 0 (so it's only one dot)
  33. buffhln(x+w, y+h, 0, shade, parallax);
  34. }
  35. }
  36. }
  37. }
RAW Paste Data