/**************************************************************************** * GB-fREMe * * 2000/08 modified to cd deconstruct by s burdach * ****************************************************************************/ #include #include #include #include "bkg.h" /* random.. */ fixed seed; unsigned int n,vz; long int zeit; unsigned int zaehler; UBYTE joy; /* character data */ #include "bkg.c" UWORD bkg_palette[] = { bkgCGBPal0c0, bkgCGBPal0c1, bkgCGBPal0c2, bkgCGBPal0c3, bkgCGBPal1c0, bkgCGBPal1c1, bkgCGBPal1c2, bkgCGBPal1c3 }; /* frame */ unsigned char frame1[][20] = { { 0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02,0x02,0x02,0x09,0x09,0x09,0x03 }, { 0x01,0x09,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x09,0x09,0x03 }, { 0x01,0x09,0x09,0x02,0x02,0x02,0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x09,0x03 }, { 0x01,0x09,0x09,0x09,0x02,0x02,0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x03 } }; /* button */ unsigned char btn_attrb0[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; unsigned char btn_attrb1[] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1 }; /* remocon data */ #include "remocon_data_struct.c" /* message */ unsigned char msg_pad[] = { "A: B: U: D: R: L: S:" }; /* work area */ UBYTE ram[4][127]; UBYTE type; UBYTE pattern; UBYTE leader_h; UBYTE leader_l; UBYTE trailer_h; UBYTE trailer_l; UBYTE data_0; UBYTE data_1; UBYTE length; UBYTE *code; /* functoins */ void set_bkg_attribute( UBYTE x, UBYTE y, UBYTE sx, UBYTE sy, unsigned char *p ) { VBK_REG = 1; set_bkg_tiles( x, y, sx, sy, p ); VBK_REG = 0; } void init_character() { set_bkg_data( 0, 128, bkg ); set_bkg_palette( 0, 2, bkg_palette ); SHOW_BKG; DISPLAY_ON; enable_interrupts(); } void sound_effect() { NR50_REG = 0x77; NR51_REG = 0x11; NR52_REG = 0x8F; NR10_REG = 0x15; NR11_REG = 0x80; NR12_REG = 0xF0; NR13_REG = 0x00; NR14_REG = 0x84; } void encode_main( UBYTE m ) { UBYTE i, n, bit, w_code; n = 0; ram[m][n] = leader_h; ram[m+1][n] = leader_l; n++; w_code = *code; bit = 8; for( i=0; i> 1; bit--; if( !(bit) ) { code++; w_code = *code; bit = 8; } n++; } ram[m][n] = trailer_h; ram[m+1][n] = trailer_l; n++; ram[m][n] = 0; ram[m+1][n] = 0; if( !(bit==8) ) code++; } void encode( UBYTE remocon_no, UBYTE button_no ) { UBYTE i, x, y; type = remocon_data[remocon_no].type; pattern = remocon_data[remocon_no].header & 0x03; leader_h = remocon_data[remocon_no].leader_h; leader_l = remocon_data[remocon_no].leader_l; trailer_h = remocon_data[remocon_no].trailer_h; trailer_l = remocon_data[remocon_no].trailer_l; data_0 = remocon_data[remocon_no].data_0; data_1 = remocon_data[remocon_no].data_1; length = remocon_data[remocon_no].length; code = remocon_data[remocon_no].code[button_no]; encode_main(0); if( pattern == 2 ) { ram[2][0] = leader_h; ram[3][0] = leader_l; ram[2][1] = trailer_h; ram[3][1] = trailer_l; ram[2][2] = 0; ram[3][2] = 0; } if( pattern == 3 ) { encode_main(2); } } void play_remocon() { // sound_effect(); play_remcon38( 0 ); while( joypad() && pattern ) { // sound_effect(); switch( pattern ) { case 1: play_remcon38( 0 ); break; case 2: play_remcon38( 1 ); break; case 3: play_remcon38( 1 ); play_remcon38( 0 ); break; } } } void play_remocon2() { UBYTE i; // sound_effect(); play_remcon38( 0 ); for( i=0; i<10; i++ ) { // sound_effect(); switch( pattern ) { case 1: play_remcon38( 0 ); break; case 2: play_remcon38( 1 ); break; case 3: play_remcon38( 1 ); play_remcon38( 0 ); break; } } } void play_macro() { UBYTE i, remocon_no, button_no; set_bkg_attribute( 2, 6*2+4, 14, 1, btn_attrb1 ); for( i=0; i<3; i++ ) { remocon_no = remocon_macro[i][0]; button_no = remocon_macro[i][1]; encode( remocon_no, button_no ); play_remocon2(); } set_bkg_attribute( 2, 6*2+4, 14, 1, btn_attrb0 ); } void main() { UBYTE key, remocon_no, button_no ,pattern; /* random seed */ init_character(); printf("\n \n---CD DECONSTRUCT---\n\n(c) 2001\nSebastian Burdach\n\nBased on IR Routinesby Teamknox\n\n--------------------\n\n press any key "); /* We use the DIV register to get a random initial seed */ waitpad(0xFF); waitpadup(); seed.b.l = DIV_REG; waitpad(0xFF); waitpadup(); seed.b.h = DIV_REG; initrand(seed.w); gotoxy(1,13); printf(" "); /* initialize bank number */ ENABLE_RAM_MBC1; SWITCH_RAM_MBC1( 0 ); remocon_no = 0; vz=5; while( 1 ) { key=joypad(); switch( key ) { case J_A: vz++; case J_B: vz--; } if(vz>100)vz=100; if(vz<1)vz=1; while(n<10){n=rand();} zeit=n; zeit=zeit*vz; gotoxy(9,15); printf(" "); delay(zeit); button_no=0; n=rand(); gotoxy(2,13); printf("TIME FACTOR: "); printf("%u",n); printf(" "); if(n>180){button_no=1;} gotoxy(9,15); if (button_no==0)printf("<<"); if (button_no==1)printf(">>"); while (zaehler<2){ encode( remocon_no, button_no ); play_remocon(); zaehler++; } zaehler=0; } } /* EOF */