#include "rsp.h" #include "rsp_lemm.h" #include "utils.h" #include "dos_lemm.h" #include /* uint16_t... */ #include /* strcpy() */ #include /* printf() */ int main(int argc, char *argv[]) { int i, rv, similar_frames, end; struct rsp_state rsp; char ds_si[10], command[16]; union lemm_data lemm, prevlemm; char draw_hint_str[256][16]; char state_str[16][16]; memset(lemm.raw, 0, sizeof(lemm.raw)); for (i=0;i<256;i++) strcpy(draw_hint_str[i], "hint_unknown"); strcpy(draw_hint_str[hint_nothing], "hint_nothing"); strcpy(draw_hint_str[hint_falling], "hint_falling"); strcpy(draw_hint_str[hint_special1],"hint_special1"); strcpy(draw_hint_str[hint_walking], "hint_walking"); strcpy(draw_hint_str[hint_building],"hint_building"); strcpy(draw_hint_str[hint_mining], "hint_mining"); strcpy(draw_hint_str[hint_bashing], "hint_bashing"); strcpy(state_str[s_splatting],"s_splatting"); strcpy(state_str[s_exploding],"s_exploding"); strcpy(state_str[s_falling],"s_falling"); strcpy(state_str[s_ascending],"s_ascending"); strcpy(state_str[s_digging],"s_digging"); strcpy(state_str[s_climbing],"s_climbing"); strcpy(state_str[s_climb_ending],"s_climb_ending"); strcpy(state_str[s_building],"s_building"); strcpy(state_str[s_blocking],"s_blocking"); strcpy(state_str[s_bashing],"s_bashing"); strcpy(state_str[s_floating],"s_floating"); strcpy(state_str[s_mining],"s_mining"); strcpy(state_str[s_drawning],"s_drawning"); strcpy(state_str[s_ending],"s_ending"); strcpy(state_str[s_b7],"s_b7"); strcpy(state_str[s_exploding2],"s_exploding2"); rv=rsp_lemm_init(&rsp, ds_si); if ( rv != 0 ) { printf("Error rsp_lemm_init() returns %i\n", rv); return 1; } end=0; similar_frames=0; while (!end) { rsp_query(&rsp, "c"); // Continue if ( rsp.replied != 1 ) printf("Bug 03\n"); rsp_recv_full(&rsp); if ( rsp_check_and_clear(&rsp, "S05") != 0 ) printf("Bug 04\n"); snprintf(command, 15, "m%s,0x2d", ds_si); rsp_query(&rsp, command); // Read a lemming record if ( rsp_decode(&rsp) != 2*sizeof(lemm.raw) ) { printf("Bug 07\n"); continue; } memcpy(prevlemm.raw, lemm.raw, sizeof(lemm.raw)); //printf("%s\n", rsp.decoded); rv = hexascii2bin(rsp.decoded, lemm.raw, sizeof(lemm.raw)); if ( rv != sizeof(lemm.raw) ) { printf("Bug 08\n"); continue; } for (i=0; i 0x02) { // Skip detailing all 80 changes... Just beginning and ending continue; } } // If here, an interessting change has been detected if ( similar_frames > 0) { printf("(%i similar frames)\n", similar_frames); } similar_frames=-1; switch(i) { case 0x4: // x_spr_offset i=0x5; // go to the next case (prevents double printing) case 0x5: // x_spr_offset printf("x_spr_offset\t%i -> %i\n",prevlemm.s.x_spr_offset, lemm.s.x_spr_offset); break; case 0x6: // y_spr_offset i=0x7; case 0x7: // y_spr_offset printf("y_spr_offset\t%i -> %i\n",prevlemm.s.y_spr_offset, lemm.s.y_spr_offset); break; case 0x8: // state i=0x9; case 0x9: // state rv=bit_position(lemm.s.state.raw); switch (rv) { case -2: //FIXME : boucle bit par bit car ya parfois de multiple bits... printf("state\t\t%04x -> %04x (multiple)\n",prevlemm.s.state.raw, lemm.s.state.raw); break; case -1: printf("state\t\t%04x -> %04x (walking...)\n",prevlemm.s.state.raw, lemm.s.state.raw); break; default: printf("state\t\t%04x -> %04x (%s)\n",prevlemm.s.state.raw, lemm.s.state.raw, state_str[rv]); break; } break; case 0xc: // spr_data_ptr i=0xd; case 0xd: // spr_data_ptr printf("spr_data_ptr\t%04x -> %04x\n",prevlemm.s.spr_data_ptr, lemm.s.spr_data_ptr); break; case 0xe: // floattime_dble ? printf("floattime_dble\t%02x -> %02x\n",prevlemm.s.floattime_dble, lemm.s.floattime_dble); break; case 0x14: // ptr2 ? i=0x15; case 0x15: // ptr2 ? printf("ptr2\t\t%04x -> %04x\n",prevlemm.s.ptr2, lemm.s.ptr2); break; case 0x20: //expl_countdown printf("expl_countdown\t%02x -> %02x\n",prevlemm.s.expl_countdown, lemm.s.expl_countdown); break; case 0x21: //steps_remain printf("steps_remain\t%02x -> %02x\n",prevlemm.s.steps_remain, lemm.s.steps_remain); break; case 0x23: //falldist printf("falldist\t%02x -> %02x\n",prevlemm.s.falldist, lemm.s.falldist); break; case 0x24: //flags1 if ( prevlemm.s.flags1.bf.cap_climber != lemm.s.flags1.bf.cap_climber ) { printf("cap_climber\t%2i -> %2i\n", prevlemm.s.flags1.bf.cap_climber, lemm.s.flags1.bf.cap_climber); } else if ( prevlemm.s.flags1.bf.walk_pause_for_shruggling != lemm.s.flags1.bf.walk_pause_for_shruggling ) { printf("walk_pause_for_shruggling\t%2i -> %2i\n", prevlemm.s.flags1.bf.walk_pause_for_shruggling, lemm.s.flags1.bf.walk_pause_for_shruggling); } else { printf("flags1.unknown\t%02x -> %02x\n",prevlemm.s.flags1.raw, lemm.s.flags1.raw); } break; case 0x25: //cap_floater printf("cap_floater\t%02x -> %02x\n",prevlemm.s.cap_floater, lemm.s.cap_floater); break; case 0x26: //is_gone printf("is_gone\t%02x -> %02x\n",prevlemm.s.is_gone, lemm.s.is_gone); break; case 0x27: //direction printf("direction\t%i -> %i\n",prevlemm.s.direction, lemm.s.direction); break; case 0x29: //draw_hint ? printf("draw_hint\t\t%02x -> %02x (%s)\n",prevlemm.s.draw_hint, lemm.s.draw_hint, draw_hint_str[lemm.s.draw_hint]); break; default: printf("(0x%02x)\t\t%02x -> %02x\n", i, prevlemm.raw[i], lemm.raw[i]); } } similar_frames++; } rsp_quit(&rsp); return 0; }