main.pp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. program main;
  2. {$L blaster.raw.o}
  3. {$L saberoff.raw.o}
  4. {$L ion.raw.o}
  5. {$apptype arm9}
  6. {$define ARM9}
  7. {$mode objfpc}
  8. uses
  9. ctypes, nds9;
  10. var
  11. blaster_raw_end: array [0..0] of u8; cvar; external;
  12. blaster_raw: array [0..0] of u8; cvar; external;
  13. blaster_raw_size: u32; cvar; external;
  14. ion_raw_end: array [0..0] of u8; cvar; external;
  15. ion_raw: array [0..0] of u8; cvar; external;
  16. ion_raw_size: u32; cvar; external;
  17. saberoff_raw_end: array [0..0] of u8; cvar; external;
  18. saberoff_raw: array [0..0] of u8; cvar; external;
  19. saberoff_raw_size: u32; cvar; external;
  20. blaster: TransferSoundData;
  21. keys: u16;
  22. begin
  23. powerON( POWER_LCD or POWER_2D_B );
  24. // initialise the irq dispatcher
  25. irqInit();
  26. // a vblank interrupt is needed to use swiWaitForVBlank()
  27. // since the dispatcher handles the flags no handler is required
  28. irqSet(IRQ_VBLANK, nil);
  29. irqEnable(IRQ_VBLANK);
  30. videoSetMode(0); //not using the main screen
  31. videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text
  32. vramSetBankC(VRAM_C_SUB_BG);
  33. SUB_BG0_CR^ := BG_MAP_BASE(31);
  34. BG_PALETTE_SUB[255] := (RGB15(31,31,31)); //by default font will be rendered with color 255
  35. //consoleInit() is a lot more flexible but this gets you up and running quick
  36. consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)), pu16(CHAR_BASE_BLOCK_SUB(0)), 16);
  37. printf(#10#10 + 'Simple Sound Demo' + #10 +
  38. 'Press A for SaberOff' + #10 +
  39. ' L for ion' + #10 +
  40. ' R for blaster' + #10);
  41. // set the generic sound parameters
  42. setGenericSound( 11025, (* sample rate *)
  43. 127, (* volume *)
  44. 64, (* panning *)
  45. 1 ); (* sound format*)
  46. with blaster do
  47. begin
  48. data := @blaster_raw;
  49. len := blaster_raw_size;
  50. rate := 11025;
  51. vol := 127;
  52. pan := 64;
  53. format := 1;
  54. PADDING := 0;
  55. end;
  56. while true do
  57. begin
  58. swiWaitForVBlank();
  59. scanKeys();
  60. keys := keysDown();
  61. if ( keys and KEY_L) <> 0 then playGenericSound(@ion_raw, ion_raw_size);
  62. if ( keys and KEY_A) <> 0 then playGenericSound(@saberoff_raw, saberoff_raw_size);
  63. if ( keys and KEY_R) <> 0 then playSound(@blaster);
  64. end;
  65. end.