Advertisement
Guest User

Untitled

a guest
Jul 1st, 2011
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.85 KB | None | 0 0
  1.  
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdbool.h>
  6. #include <stdint.h>
  7. #include <dingoo/ucos2.h>
  8. #include <dingoo/entry.h>
  9. #include <dingoo/audio.h>
  10.  
  11. #include <sml/graphics.h>
  12. #include <sml/display.h>
  13. #include <sml/control.h>
  14. #include <sml/timer.h>
  15.  
  16. #include "images.h"
  17. #include "chord.h"
  18.  
  19. gfx_font* gameFont = NULL;
  20.  
  21. waveout_args mywaveinfo;
  22. waveout_inst* woHandle;
  23.  
  24. #define max(x, y) (x > y ? x : y)
  25. #define min(x, y) (x < y ? x : y)
  26.  
  27. void logWrite(char* str);
  28. void screenWrite(char* str);
  29.  
  30. display* gameDisplay  = NULL;
  31.  
  32. void screenWrite(char* str)
  33. {
  34.     gfx_render_target_clear(gfx_color_rgb(0x00, 0x00, 0x00));
  35.     gfx_font_print_center(200, gameFont, str);
  36.     display_flip(gameDisplay);
  37. }
  38.  
  39. int main(int argc, char** argv) {
  40.     int ref = EXIT_SUCCESS;
  41.  
  42.     srand(OSTimeGet());
  43.  
  44.     control_init();
  45.     gameDisplay = display_create(320, 240, 320, DISPLAY_FORMAT_RGBA8888, NULL, NULL);
  46.     if(gameDisplay == NULL) {
  47.         control_term();
  48.         return ref;
  49.     }
  50.     gfx_init(gameDisplay);
  51.     gameFont = gfx_font_load_from_buffer(tgaFont, tgaFontSize, COLOR_MAGENTA);
  52.  
  53.     screenWrite("INIT");
  54.  
  55.     control_lock(timer_resolution / 4);
  56.  
  57.     //mywaveinfo.sample_rate = 22050;
  58.     mywaveinfo.sample_rate = 44100;
  59.     mywaveinfo.format = 16;
  60.     mywaveinfo.channel = 2;
  61.     mywaveinfo.volume = 30;
  62.  
  63.     screenWrite("Opening waveout");
  64.  
  65.     woHandle = waveout_open(&mywaveinfo);
  66.  
  67.     screenWrite("Ready. Press A to play sound.");
  68.  
  69.     while(1)
  70.     {
  71.         control_poll();
  72.         if (control_check(CONTROL_BUTTON_START).pressed || control_check(CONTROL_BUTTON_SELECT).pressed)
  73.         {
  74.             break;
  75.         }
  76.  
  77.         if (control_just_pressed(CONTROL_BUTTON_A))
  78.         {
  79.             waveout_write(woHandle, chord, chordSize);
  80.         }
  81.     }
  82.  
  83.     screenWrite("Exiting...");
  84.  
  85.     waveout_close(woHandle);
  86.  
  87.     gfx_font_delete(gameFont);
  88.     gfx_term();
  89.     display_delete(gameDisplay);
  90.     control_term();
  91.  
  92.     return ref;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement