modplay.pp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. program modplay;
  2. {$J+}
  3. {$macro on}
  4. {$mode objfpc}
  5. {$goto on}
  6. uses
  7. cmem, ctypes, aesndlib, gcmodplay, gccore;
  8. // include generated header
  9. {$include inc/technique.mod.inc}
  10. {$L build/technique.mod.o}
  11. var
  12. xfb: pcuint32 = nil;
  13. rmode: PGXRModeObj = nil;
  14. mplay: TMODPlay;
  15. begin
  16. // Initialise the video system
  17. VIDEO_Init();
  18. // Initialise the attached controllers
  19. WPAD_Init();
  20. // Initialise the audio subsystem
  21. AESND_Init();
  22. // Obtain the preferred video mode from the system
  23. // This will correspond to the settings in the Wii menu
  24. rmode := VIDEO_GetPreferredMode(nil);
  25. // Allocate memory for the display in the uncached region
  26. xfb := SYS_AllocateFramebuffer(rmode);
  27. // Initialise the console, required for printf
  28. console_init(xfb,20,20,rmode^.fbWidth,rmode^.xfbHeight,rmode^.fbWidth*VI_DISPLAY_PIX_SZ);
  29. // Set up the video registers with the chosen mode
  30. VIDEO_Configure(rmode);
  31. // Tell the video hardware where our display memory is
  32. VIDEO_SetNextFramebuffer(xfb);
  33. // Make the display visible
  34. VIDEO_SetBlack(FALSE);
  35. // Flush the video register changes to the hardware
  36. VIDEO_Flush();
  37. // Wait for Video setup to complete
  38. VIDEO_WaitVSync();
  39. if (rmode^.viTVMode and VI_NON_INTERLACE) <> 0 then VIDEO_WaitVSync();
  40. // The console understands VT terminal escape codes
  41. // This positions the cursor on row 2, column 0
  42. // we can use variables for this with format codes too
  43. // e.g. printf ("\x1b[%d;%dH", row, column );
  44. printf(#$1b'[2;0H');
  45. printf('Hello World!');
  46. MODPlay_Init(@mplay);
  47. MODPlay_SetMOD(@mplay,@technique_mod);
  48. MODPlay_SetVolume(@mplay,63,63);
  49. MODPlay_Start(@mplay);
  50. while true do
  51. begin
  52. // Call WPAD_ScanPads each loop, this reads the latest controller states
  53. WPAD_ScanPads();
  54. // WPAD_ButtonsDown tells us which buttons were pressed in this loop
  55. // this is a "one shot" state which will not fire again until the button has been released
  56. // We return to the launcher application via exit
  57. if ( WPAD_ButtonsDown(0) and WPAD_BUTTON_HOME ) <> 0 then exit;
  58. // Wait for the next frame
  59. VIDEO_WaitVSync();
  60. end;
  61. end.