Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdbool.h>
- #include <stdint.h>
- #include <dingoo/ucos2.h>
- #include <dingoo/entry.h>
- #include <dingoo/audio.h>
- #include <sml/graphics.h>
- #include <sml/display.h>
- #include <sml/control.h>
- #include <sml/timer.h>
- #include "images.h"
- #include "chord.h"
- gfx_font* gameFont = NULL;
- waveout_args mywaveinfo;
- waveout_inst* woHandle;
- #define max(x, y) (x > y ? x : y)
- #define min(x, y) (x < y ? x : y)
- void logWrite(char* str);
- void screenWrite(char* str);
- display* gameDisplay = NULL;
- void screenWrite(char* str)
- {
- gfx_render_target_clear(gfx_color_rgb(0x00, 0x00, 0x00));
- gfx_font_print_center(200, gameFont, str);
- display_flip(gameDisplay);
- }
- int main(int argc, char** argv) {
- int ref = EXIT_SUCCESS;
- srand(OSTimeGet());
- control_init();
- gameDisplay = display_create(320, 240, 320, DISPLAY_FORMAT_RGBA8888, NULL, NULL);
- if(gameDisplay == NULL) {
- control_term();
- return ref;
- }
- gfx_init(gameDisplay);
- gameFont = gfx_font_load_from_buffer(tgaFont, tgaFontSize, COLOR_MAGENTA);
- screenWrite("INIT");
- control_lock(timer_resolution / 4);
- //mywaveinfo.sample_rate = 22050;
- mywaveinfo.sample_rate = 44100;
- mywaveinfo.format = 16;
- mywaveinfo.channel = 2;
- mywaveinfo.volume = 30;
- screenWrite("Opening waveout");
- woHandle = waveout_open(&mywaveinfo);
- screenWrite("Ready. Press A to play sound.");
- while(1)
- {
- control_poll();
- if (control_check(CONTROL_BUTTON_START).pressed || control_check(CONTROL_BUTTON_SELECT).pressed)
- {
- break;
- }
- if (control_just_pressed(CONTROL_BUTTON_A))
- {
- waveout_write(woHandle, chord, chordSize);
- }
- }
- screenWrite("Exiting...");
- waveout_close(woHandle);
- gfx_font_delete(gameFont);
- gfx_term();
- display_delete(gameDisplay);
- control_term();
- return ref;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement