Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5301 → Rev 5302

/programs/games/heliothryx/game/rsgame.c
238,8 → 238,8
rskos_snd_update_buffer(&snd->hbuf, snd->data, snd->length_samples);
};
 
void soundbuf_play(rs_soundbuf_t *snd) {
rskos_snd_play(&snd->hbuf, 0);
void soundbuf_play(rs_soundbuf_t *snd, int mode) {
rskos_snd_play(&snd->hbuf, mode);
};
 
void soundbuf_stop(rs_soundbuf_t *snd) {
246,8 → 246,12
rskos_snd_stop(&snd->hbuf);
};
 
void soundbuf_loop_check(rs_soundbuf_t *snd) {
rskos_snd_check_loop(&snd->hbuf);
};
 
 
 
unsigned char clamp_byte(int value) {
value = value * (1 - (value >> 31)); // negative to zero
return (value > 255) ? 255 : value;
510,7 → 514,7
 
#ifndef RS_KOS
rs_audio_init(RS_AUDIO_FMT_MONO16, RS_AUDIO_FREQ_16000, 0);
rs_audio_init(RS_AUDIO_FMT_MONO16, RS_AUDIO_FREQ_16000, 2);
#endif
 
soundbuf_init(&game.sound_test1, 2048);
545,7 → 549,7
rs_sgen_func_normalize(0, 1.0);
 
rs_sgen_func_lowpass(2, 0, 0.6, 0.0, 20.0);
rs_sgen_func_normalize(2, 1.0);
rs_sgen_func_normalize(2, 0.7);
 
rs_sgen_wave_out(2);
 
567,7 → 571,7
rs_sgen_func_normalize(0, 1.0);
 
rs_sgen_func_highpass(2, 0, 1.0, 0.3, 20.0);
rs_sgen_func_normalize(2, 1.0);
rs_sgen_func_normalize(2, 0.6);
 
rs_sgen_wave_out(2);
 
576,9 → 580,77
 
rs_sgen_term();
 
 
#define NOTE(i) ( 3 << ( (i)/12) ) / ( 24 - ( (i) % 12) )
int amp = 70;
int t_shift = 0;
int t;
 
soundlen = 128 * 1024;
 
 
soundbuf_init(&game.sound_music, soundlen);
for (t = t_shift; t < soundlen+t_shift; t++) {
game.sound_music.data[t-t_shift] = (0xFF &
(
((t>>11) | (t>>7) | ( t>>5) | (t))
 
)
) * amp;
};
 
soundbuf_update(&game.sound_music);
 
int d[4] = { 5, 6, 1, 2 };
soundbuf_init(&game.sound_music2, soundlen);
for (t = t_shift; t < soundlen+t_shift; t++) {
// y = 1 + (t & 16383);
// x = (t * c[ (t>>13) & 3 ] / 24) & 127;
game.sound_music2.data[t-t_shift] = (0xFF &
(
//( t*5 & t >> 7 ) | ( t*2 & t >> 10 )
// ( ((t*t*t/1000000 + t) % 127) | t>>4 | t>>5 | (t%127) ) + ( (t>>16) | t )
// ((t>>11) | (t>>7) | ( t>>5) | (t))
// //+
// //(( (t*5) >>12) & ( (t*3)>>19))
// (3000 / y) * 35
// + x*y*40000
// + ( ( ((t>>8) & (t>>10)) | (t >> 14) | x) & 63 )
// ( ((6 * t / d[ (t>>13) & 15 ] ) & 127) * 10000 )
//|( ( t>>3 ) )
(t*NOTE( d[ (t>>13) & 3 ] )*10000)
| ((t>>6)*20000)
)
) * amp;
};
soundbuf_update(&game.sound_music2);
soundbuf_play( &game.sound_music, SND_MODE_LOOP );
 
};
 
 
void GameTerm() {
 
 
639,7 → 711,27
case RS_KEY_A:
BIT_SET(game.keyboard_state, RS_ATTACK_KEY_MASK);
game.shoot_keypressed = 1;
// soundbuf_loop_check( &game.sound_music );
break;
// case RS_KEY_SPACE:
// soundbuf_play( &game.sound_music, SND_MODE_LOOP );
// break;
// #ifdef RS_LINUX
//
// case RS_KEY_Z:
// soundbuf_play( &game.sound_music2, 0 );
// break;
//
// #endif
 
};
694,12 → 786,7
break;
case RS_KEY_SPACE:
#ifdef RS_LINUX
soundbuf_play( &game.sound_hit );
#endif
//game_obj_add( game_obj( OBJ_EXPLOSION, 0, 0, 0, game.tx + 80, game.ty - 10, 0, 0.0 ) );
// game_obj_add( game_obj( OBJ_ROCK, 0, 0, 32, game.tx + 80, game.ty - 10, 0, 0.0 ) );
782,10 → 869,10
switch (i) {
case 0:
soundbuf_play(&game.sound_test2);
soundbuf_play(&game.sound_test2, 0);
break;
case 1:
soundbuf_play(&game.sound_test3);
soundbuf_play(&game.sound_test3, 0);
break;
};
/programs/games/heliothryx/game/rsgame.h
95,7 → 95,8
void soundbuf_fill(rs_soundbuf_t *snd, int amp, int freq_div);
void soundbuf_sin(rs_soundbuf_t *snd, float freq);
void soundbuf_sin_fade(rs_soundbuf_t *snd, float freq);
void soundbuf_play(rs_soundbuf_t *snd);
void soundbuf_play(rs_soundbuf_t *snd, int mode);
void soundbuf_loop_check(rs_soundbuf_t *snd);
void soundbuf_stop(rs_soundbuf_t *snd);
 
// Game Objects
194,6 → 195,9
rs_soundbuf_t sound_explosions[SOUND_EXPLOSIONS_COUNT];
rs_soundbuf_t sound_hit;
rs_soundbuf_t sound_music;
rs_soundbuf_t sound_music2;
int status;
int flags;
/programs/games/heliothryx/game/rsgamelogic.c
90,11 → 90,12
game.health--;
game.bg_color = COLOR_DARK_RED;
soundbuf_play( &game.sound_hit );
soundbuf_play( &game.sound_hit, 0 );
 
if (game.health < 1) {
game.status = STATUS_MENU;
soundbuf_play( &game.sound_music, SND_MODE_LOOP );
menu_open( MENU_GAME_OVER );
};
117,7 → 118,7
game.shoot_restore_delay = 0;
game.ammo--;
soundbuf_play(&game.sound_test1);
soundbuf_play(&game.sound_test1, 0);
game_obj_add( game_obj( OBJ_BULLET, 0, 0, 0, game.player_x+5, game.player_y, 0, 0.0) );
// };
275,6 → 276,7
else if (game.stage == 10) {
game.status = STATUS_MENU;
soundbuf_play( &game.sound_music, SND_MODE_LOOP );
menu_open( MENU_LEVEL_PASSED );
level_passed_score_str[1] = '0' + (game.score / 100) % 10;
403,7 → 405,7
for (i = 0; i < game.objs_count; i++) {
if ( IS_BIT_SET( game.objs[i].flags, OBJ_FLAG_DESTROYED ) ) {
soundbuf_play( &game.sound_explosions[ rs_rand() % SOUND_EXPLOSIONS_COUNT ] );
soundbuf_play( &game.sound_explosions[ rs_rand() % SOUND_EXPLOSIONS_COUNT ], 0 );
game_obj_add( game_obj( OBJ_EXPLOSION, 0, 0, EXPLOSION_RADIUS, game.objs[i].x, game.objs[i].y, 0, 0.0 ) );
game_obj_remove(i);
i--;
417,6 → 419,10
 
game_draw();
 
if (game.status == STATUS_MENU) {
soundbuf_loop_check( &game.sound_music );
};
 
}
 
 
/programs/games/heliothryx/game/rsgamemenu.c
162,6 → 162,8
game.bg_color = COLOR_BLACK;
soundbuf_stop( &game.sound_music );
};
 
void menu_action_exit() {
/programs/games/heliothryx/game/rskos.c
132,7 → 132,8
 
void rskos_snd_play(SNDBUF *hbuf, unsigned int mode) {
rs_sound_play(*hbuf);
// rs_sound_play(*hbuf);
rs_sound_play_adv(*hbuf, mode==SND_MODE_LOOP ? 1 : 0, mode==SND_MODE_LOOP ? 0 : -1, 1.0);
};
 
140,7 → 141,11
rs_sound_stop(*hbuf);
};
 
void rskos_snd_check_loop(SNDBUF *phbuf) {
//
};
 
 
#else
 
#include "rs/rsplatform.h"
208,7 → 213,7
 
void rskos_snd_play(SNDBUF *phbuf, unsigned int mode) {
SetBufferPos(*phbuf, 0);
PlayBuffer(*phbuf, 0);
PlayBuffer(*phbuf, 0); // SND_MODE_LOOP
};
 
void rskos_snd_stop(SNDBUF *phbuf) {
215,6 → 220,23
StopBuffer(*phbuf);
};
 
void rskos_snd_check_loop(SNDBUF *phbuf) {
int offset;
int length;
 
GetBufferPos(*phbuf, &offset);
//GetBufferSize(*phbuf, &length);
 
// kol_board_puti(offset);
//kol_board_putc('\n');
if (offset <= 0) {
SetBufferPos(*phbuf, 0); //offset - length/2);
PlayBuffer(*phbuf, 0); // SND_MODE_LOOP
};
};
 
 
 
#endif
/programs/games/heliothryx/game/rskos.h
24,10 → 24,13
#endif
#endif
 
#define SND_MODE_LOOP 1
 
//void rskos_snd_init();
void rskos_snd_create_buffer(SNDBUF *phbuf, signed short *buffer, unsigned int length_samples);
void rskos_snd_update_buffer(SNDBUF *phbuf, signed short *buffer, unsigned int length_samples);
void rskos_snd_play(SNDBUF *phbuf, unsigned int mode);
void rskos_snd_stop(SNDBUF *phbuf);
void rskos_snd_check_loop(SNDBUF *phbuf);
 
#endif