2
0

windows.pp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. program windows;
  2. {$L build/drunkenlogo.o}
  3. {$mode objfpc}
  4. uses
  5. ctypes, nds9;
  6. const
  7. drunkenlogoPalLen = 512;
  8. drunkenlogoBitmapLen = 65536;
  9. var
  10. drunkenlogoPal: array [0..255] of cushort; cvar; external;
  11. drunkenlogoBitmap: array [0..16383] of cuint; cvar; external;
  12. bg3: integer;
  13. x, y, size: integer;
  14. begin
  15. videoSetMode(MODE_5_2D);
  16. vramSetBankA(VRAM_A_MAIN_BG);
  17. //enable a background
  18. bg3 := bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0, 0);
  19. //use the standard drunken logo
  20. dmaCopy(@drunkenlogoBitmap, bgGetGfxPtr(bg3), drunkenlogoBitmapLen);
  21. dmaCopy(@drunkenlogoPal, BG_PALETTE, drunkenlogoPalLen);
  22. //enable window 0
  23. windowEnable(WINDOW_0);
  24. //enable window 0 on our new background
  25. bgWindowEnable(bg3, WINDOW_0);
  26. x := 60;
  27. y := 60;
  28. size := 100;
  29. while true do
  30. begin
  31. scanKeys();
  32. //the code below just moves the window around
  33. if (keysHeld() and KEY_UP) <> 0 then dec(y);
  34. if (keysHeld() and KEY_DOWN) <> 0 then inc(y);
  35. if (keysHeld() and KEY_LEFT) <> 0 then dec(x);
  36. if (keysHeld() and KEY_RIGHT) <> 0 then inc(x);
  37. if (keysHeld() and KEY_A) <> 0 then dec(size);
  38. if (keysHeld() and KEY_B) <> 0 then inc(size);
  39. if (keysHeld() and KEY_X) <> 0 then
  40. begin
  41. bgWindowDisable(bg3, WINDOW_OUT);
  42. bgWindowEnable(bg3, WINDOW_0);
  43. end;
  44. if (keysHeld() and KEY_Y) <> 0 then
  45. begin
  46. bgWindowDisable(bg3, WINDOW_0);
  47. bgWindowEnable(bg3, WINDOW_OUT);
  48. end;
  49. if (x < 0) then x := 0;
  50. if (x > SCREEN_WIDTH - 1) then x := SCREEN_WIDTH - 1;
  51. if (y < 0) then y := 0;
  52. if (y > SCREEN_HEIGHT - 1) then y := SCREEN_HEIGHT - 1;
  53. swiWaitForVBlank();
  54. //set up the boundaries on our window
  55. windowSetBounds(WINDOW_0, x, y, x + size, y + size);
  56. end;
  57. end.