/* NANOVOICE - spectral sound synthesis on the Game Boy - written by (c) Oliver Wittchow and Julian Rohrhuber this program was written for an old version of GBDK, to make it work with a recent version, replace direct register commands like _reg_0x19 = 128 ; by something like *(unsigned char *)0x19 = 128; */ #include #define J_ADOWN 0x18U /* extended joypad access */ #define J_AUP 0x14U #define J_ALEFT 0x12U #define J_ARIGHT 0x11U #define J_BDOWN 0x28U #define J_BUP 0x24U #define J_BLEFT 0x22U #define J_BRIGHT 0x21U #define J_SEDOWN 0x48U #define J_SEUP 0x44U #define J_SELEFT 0x42U #define J_SERIGHT 0x41U #define MASTER 0 #define SLAVE 1 unsigned char icons[] = { 60,60,66,66,129,129,129,129,129,129,129,129,66,66,60,60, /* sprite data */ 128,128,160,160,168,168,170,170,170,170,168,168,160,160,128,128, 192,192,240,176,252,140,255,131,255,131,252,140,240,176,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 1,1,5,5,21,21,85,85,85,85,21,21,5,5,1,1 }; unsigned char ikone[1]; unsigned char planar[16][16]; char delta_planar[16][16]; unsigned char i, samp_freq, sum, count, time, harmonic, tempo, clock, watch,paddel, pad, joy, index, fade, render, old, demo, stereo, slow, bob, todd, pop, modus; unsigned char changed[16]; long makro_wave[16][64]; unsigned char wave_product[17][64]; unsigned char pre_wave_product[17][32]; static char wave [16][32] = /* sine wave forms of 16 harmonics */ { {1,3,4,5,6,7,7,7,7,7,6,5,4,3,1,0,-2,-4,-5,-6,-7,-8,-8,-8,-8,-8,-7,-6,-5,-4,-2,-1}, {3,5,7,7,7,5,3,0,-4,-6,-8,-8,-8,-6,-4,-1,3,5,7,7,7,5,3,0,-4,-6,-8,-8,-8,-6,-4,-1}, {4,7,7,5,1,-4,-7,-8,-7,-4,1,5,7,7,4,0,-5,-8,-8,-6,-2,3,6,7,6,3,-2,-6,-8,-8,-5,-1}, {5,8,5,0,-6,-8,-6,-1,5,7,5,0,-6,-8,-6,-1,5,7,5,0,-6,-8,-6,-1,5,7,5,0,-6,-8,-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,0,0,0,0,0,0, 255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0, 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, 0,255,255,0,0,255,255,0,0,255,255,0,0,255,255,0, 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, 255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255 }; unsigned char auto_planar[112][16]= /* demo patterns */ { {5,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}, /* 1 */ {0,5,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}, {0,0,5,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}, {0,0,0,4, 0,0,0,0, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 4,0,0,0, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 0,4,0,0, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 0,0,3,0, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 0,0,0,3, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 0,0,0,0, 3,0,0,0, 0,0,0,0}, {0,0,0,0, 0,0,0,0, 0,2,0,0, 0,0,0,0}, {0,0,0,0, 0,0,0,0, 0,0,2,0, 0,0,0,0}, {0,0,0,0, 0,0,0,0, 0,0,0,2, 0,0,0,0}, {0,0,0,0, 0,0,0,0, 0,0,0,0, 1,0,0,0}, {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,1,0,0}, {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,1,0}, {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1}, {6,0,3,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}, /* 2 */ {0,0,0,0, 3,0,6,0, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 0,0,2,0, 0,4,0,0, 0,0,0,0}, {0,4,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 0,0,0,0, 0,0,0,5, 0,0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,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}, {0,1,2,1, 0,0,0,0, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}, {3,2,1,0, 0,0,0,0, 0,0,0,0, 0,0,1,2}, {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}, {3,2,1,0, 0,0,0,0, 0,0,0,0, 0,0,1,2}, {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}, {0,1,2,1, 0,0,0,0, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}, }; unsigned char demo_samp_freq[7]= {250, 250, 250, 250, 246, 250,245}; unsigned char demo_tempo[7]= {16,11,11,11,1 ,20,18}; // sync options void slave() { bob = pop; (*(UBYTE *)0xFF02) = 128; todd = (*(UBYTE *)0xFF01); if (todd == 0 ) pop = 0; else pop = 1; if ( bob != pop) { if( clock != 15) clock++; else clock = 0; } } void master() { watch++; if(watch > tempo) { watch = 0; if( clock != 15) clock++; else clock = 0; } } /* " index" repeatedly counts through the wave form for a duration given by "tempo" and counted by "watch", */ /* then the player jumps to the wave form of the next time slot, indexed by "clock", which is equivalent to "time" */ void player() { index++; if ( index == 32 ) { if ( modus == MASTER ) master(); else slave(); index = 0; } _reg_0x12 = wave_product[16 - clock][index]; /* set volume register of sound 1, play it backwards (16-clock) */ _reg_0x14 = 128 ; /* restart sound chip 1 */ _reg_0x17 = wave_product[clock][index]; /* set volume register of sound 2 */ _reg_0x19 = 128 ; /* restart sound chip 2 */ } void tim() { player(); /* load playback function into timer interrupt function */ } void demo_calculate(unsigned char time) { unsigned char i; sum = 0; for(i = 0; i != 16; i++) sum = sum+planar[time][i]; sum = sum /7 +7; for(i = 0; i != 16; i++) { if ( delta_planar[time][i] != 0) { for ( count = 0; count != 32; count ++) { makro_wave[time][count] = makro_wave[time][count] + wave[i][count] * delta_planar[time][i]; pre_wave_product[time][count] = makro_wave[time][count] / sum +8; if ( pre_wave_product[time][count] >15 ) pre_wave_product[time][count] = 15 ; if ( pre_wave_product[time][count] < 1 ) pre_wave_product[time][count] = 1 ; pre_wave_product[time][count] =pre_wave_product[time][count]*16 ; } delta_planar[time][i] = 0; } } for ( count = 0; count != 32; count ++) { pre_wave_product[16][count] = pre_wave_product[0][count] ; } } void calculate(unsigned char time) { unsigned char i; sum = 0; for(i = 0; i != 16; i++) sum = sum+planar[time][i]; sum = sum /7 +7; for(i = 0; i != 16; i++) { if ( delta_planar[time][i] != 0) { for ( count = 0; count != 32; count ++) { makro_wave[time][count] = makro_wave[time][count] + wave[i][count] * delta_planar[time][i]; wave_product[time][count] = makro_wave[time][count] / sum +8; if ( wave_product[time][count] >15 ) wave_product[time][count] = 15 ; if ( wave_product[time][count] < 1 ) wave_product[time][count] = 1 ; wave_product[time][count] =wave_product[time][count]*16 ; } delta_planar[time][i] = 0; } } for ( count = 0; count != 32; count ++) { wave_product[16][count] = wave_product[0][count] ; } } void delete() { old = planar[time][harmonic]; planar[time][harmonic] = 0; delta_planar[time][harmonic]= ( planar[time][harmonic] - old) + delta_planar[time][harmonic]; changed[time] = 1; ikone[0]= 0; set_bkg_tiles(time,16-harmonic,1,1,ikone); SHOW_BKG; } void main() { printf("\n\n\n\n\n NANOVOICE\n\n\n\n 16 - channel\n spectral\n sound synthesis\n in stereo \n\n\n\n\n\n\n\n"); delay(2000); cls(); printf("\n written by\n\n Oliver \n Wittchow\n\n and\n \n Julian \n Rohrhuber\n\n\n\n\n\n\n\n"); delay(2000); cls(); printf("\n press SELECT\n\n to edit\n your own \n sound\n\n\n\n\n\n\n "); delay(2000); cls(); set_bkg_data(0,8,backgr); /* some initializations */ ikone[0] = 0; for ( i = 0; i != 16; i++) { for ( count = 0; count != 32; count++) { wave_product[i][count] = 1; if(count < 16) set_bkg_tiles(i,count,1,1,ikone); } } _reg_0x25 = 255; /* sound on */ _reg_0x26 = 255; _reg_0x24 = 255 - 136; _reg_0x25 =33; delay(2000); _reg_0x10 = 24 ; _reg_0x11 = 2 * 64; _reg_0x12 = 2 * 16 ; _reg_0x13 = 44 ; _reg_0x14 = 2 + 128 ; _reg_0x16 = 2 * 64; _reg_0x17 =2 * 16 ; _reg_0x18 =44 ; _reg_0x19 = 2 + 128; set_sprite_data(0,5,icons); set_sprite_tile(0,0); set_sprite_tile(1,1); set_sprite_tile(2,2); set_sprite_tile(3,3); move_sprite(1, 255 - 140, 32); samp_freq = 160; tempo = 10; move_sprite(2,100 - tempo,16); disable_interrupts(); add_TIM(tim); enable_interrupts(); TMA_REG =samp_freq; TAC_REG = 0x07U; set_interrupts(VBL_IFLAG | TIM_IFLAG); scroll_bkg(-16,-4); for ( time = 0; time != 16; time++) { for ( harmonic = 0; harmonic !=16; harmonic++) { ikone[0]=planar[time][harmonic]=delta_planar[time][harmonic] = auto_planar[time][harmonic]; set_bkg_tiles(time,16 - harmonic,1,1,ikone); } calculate(time); SHOW_BKG; } time=0; harmonic=0; demo=0; delay(500); samp_freq = 240; TMA_REG =samp_freq; delay(500); samp_freq = 250; TMA_REG =samp_freq; while(!0) /* infinite loop for demo*/ { if (joypad() == J_SELECT ) break; slow++; if ( slow ==2) { slow = 0; demo++; } if(demo==7) demo=1; for ( time = 0; time != 16; time++) { for ( harmonic = 0; harmonic !=16; harmonic++) { planar[time][harmonic]=delta_planar[time][harmonic]=0; } for ( count = 0; count !=32;count ++) { makro_wave[time][count] = 0; } for ( harmonic = 0; harmonic !=16; harmonic++) { planar[time][harmonic]=delta_planar[time][harmonic] = auto_planar[harmonic+16 * demo][time]; } demo_calculate(time); if (joypad() == J_SELECT && demo !=0 ) break; } for ( time = 0; time != 17; time++) { for ( count = 0; count !=32;count ++) { wave_product[time][count] = pre_wave_product[time][count]; if ( count < 15) { ikone[0]=planar[time][count]; set_bkg_tiles(time,16 -count,1,1,ikone); } } } SHOW_BKG; samp_freq = demo_samp_freq[demo]; TMA_REG =samp_freq; tempo =demo_tempo[demo]; time=0; harmonic=0; } for ( time = 0; time != 16; time++) { for ( harmonic = 0; harmonic !=16; harmonic++) { delete(); } calculate(time); } time=harmonic=0; while(!0) /* infinite loop for editor */ { /* stops the joypad signal for a while after returning one signal, e.g. when you press "UP"and keep it pressed, */ /* the cursor moves up one step, then waits for a short period before going up fast */ if ( joypad() != 0 ) pad++; else pad = 0; if ( joypad() != joy || pad > 10 ) paddel = joypad(); else paddel = 0; if ( joypad() != joy) pad = 0; joy = joypad(); /* move the cursor around ( time = x-coordinate, harmonic = y-coordinate ) */ if(paddel==J_RIGHT) { if ( time == 15) time = 0; else time++; move_sprite(0,24 + time * 8, 148 - harmonic * 8); } if(paddel==J_LEFT ) { if ( time ==0) time = 15; else time--; move_sprite(0,24 + time * 8, 148 - harmonic * 8); } if(paddel==J_UP &&harmonic != 15) { harmonic++; move_sprite(0,24 + time * 8, 148 - harmonic * 8); } if(paddel==J_DOWN && harmonic != 0) { harmonic--; move_sprite(0,24 + time * 8, 148 - harmonic * 8); } if ( paddel == J_AUP && planar[time][harmonic] !=6) { render = 1; planar[time][harmonic]++; changed[time]= 1; delta_planar[time][harmonic]++; ikone[0]= planar[time][harmonic]; set_bkg_tiles(time,16-harmonic,1,1,ikone); SHOW_BKG; } if ( paddel == J_ADOWN && planar[time][harmonic] !=0) { render = 1; planar[time][harmonic]--; changed[time] = 1; delta_planar[time][harmonic]--; ikone[0]= planar[time][harmonic]; set_bkg_tiles(time,16-harmonic,1,1,ikone); SHOW_BKG; } if ( paddel == J_ARIGHT && planar[time][harmonic] > 1 ) { render = 1; for ( i =1; i != planar[time][harmonic]; i++) { if ( time + i < 16) fade = time + i; else fade = (time + i) - 16 ; old = planar[fade][harmonic]; planar[fade][harmonic] = planar[time][harmonic] - i; changed[fade] = 1; delta_planar[fade][harmonic] = ( planar[fade][harmonic] - old ) + delta_planar[fade][harmonic] ; ikone[0] = planar[fade][harmonic]; set_bkg_tiles(fade,16-harmonic,1,1,ikone); } } if ( paddel == J_ALEFT && planar[time][harmonic] > 1 ) { render = 1; for ( i =1; i != planar[time][harmonic]; i++) { if ( time - i >= 0) fade = time - i; else fade = 16 + (time - i); old = planar[fade][harmonic]; planar[fade][harmonic] = planar[time][harmonic] - i; changed[fade] = 1; delta_planar[fade][harmonic] = ( planar[fade][harmonic] - old ) + delta_planar[fade][harmonic] ; ikone[0]=planar[fade][harmonic]; set_bkg_tiles(fade,16-harmonic,1,1,ikone); } } if (paddel == J_B ) { render = 1; delete(); } if (paddel == J_BUP && harmonic != 15) { render = 1; harmonic++; move_sprite(0,24 + time * 8, 148 - harmonic * 8); delete(); } if (paddel == J_BDOWN && harmonic != 0) { render = 1; harmonic--; move_sprite(0,24 + time * 8, 148 - harmonic * 8); delete(); } if (paddel == J_BRIGHT ) { render = 1; if( time != 15) time++; else time = 0; delete(); move_sprite(0,24 + time * 8, 148 - harmonic * 8); } if (paddel == J_BLEFT ) { render = 1; if( time != 0) time--; else time =15; delete(); move_sprite(0,24 + time * 8, 148 - harmonic * 8); } if( paddel ==0 && render==1 ) { render=0; for ( i = 0; i != 16; i++) { if ( changed[i] ==1) { calculate(i); changed[i] =0; } } } if ( paddel == J_SEDOWN && samp_freq != 240 ) { samp_freq--; move_sprite(1, samp_freq -140, 32); TMA_REG =samp_freq; } if ( paddel == J_SEUP && samp_freq != 251 ) { samp_freq++; move_sprite(1, samp_freq -140, 32); TMA_REG =samp_freq; } if ( paddel == J_SERIGHT && tempo != 1 ) { tempo--; move_sprite(2,100 - tempo,16); } if ( paddel == J_SELEFT && tempo != 40) { tempo++; move_sprite(2,100 - tempo, 16); } if ( paddel == J_START) { if (modus == 0) { modus = 1; set_sprite_tile( 2, 4); } else { modus = 0; set_sprite_tile( 2, 2); } } SHOW_SPRITES; delay (10); } /* end while */ } /* end main */