void search_similar_pattern(int count) { u8 *block = malloc (config.block_size); /* backup basic block */ radare_read(0); memcpy (block, config.block, config.block_size); radare_controlc (); radare_read (1); // read next block while (!config.interrupted && config.seek<config.size) { int diff = memcmpdiff(config.block, block, config.block_size); int equal = config.block_size-diff; // equal sera un numero petit quan diff sigui gran // quan equal sigui gran diff sera petit if (equal >= count) { //count > equal) { //if (count > equal) { cons_printf("0x%08llx %d/%d\n", config.seek, equal, config.block_size); cons_flush(); radare_read(1); } else { config.seek += 1; // skip diff bytes can be faster ?? //config.seek += diff; // skip diff bytes can be faster ?? int ret = radare_read(0); if (ret<config.block_size)break; } } radare_controlc_end (); free (block); }
int main(void) { uint16_t mask; int level = DMA_LEVEL_0; irq_mux_t *vblank_in; irq_mux_t *vblank_out; irq_mux_t *hblank_out; unsigned int joyR = 0, oldjoyR = 0, joyL = 0, oldjoyL = 0, joyA = 0, oldjoyA = 0, joyB = 0, oldjoyB = 0, joyC = 0, oldjoyC = 0; unsigned int joyLeft = 0, oldjoyLeft = 0, joyRight = 0, oldjoyRight = 0, joyStart = 0, oldjoyStart = 0, joyUp = 0, oldjoyUp = 0, joyDown = 0, oldjoyDown = 0; static uint16_t back_screen_color = { COLOR_RGB_DATA | COLOR_RGB555(0, 7, 7) }; vdp2_init(); vdp1_init(); smpc_init(); smpc_peripheral_init(); scu_dma_cpu_init(); cons_init(CONS_DRIVER_VDP2); consbuf = (char *)malloc(1024); mask = IC_MASK_LEVEL_0_DMA_END | IC_MASK_LEVEL_1_DMA_END | IC_MASK_LEVEL_2_DMA_END | IC_MASK_DMA_ILLEGAL; cpu_intc_disable(); vblank_in = vdp2_tvmd_vblank_in_irq_get(); irq_mux_handle_add(vblank_in, vblank_in_handler, NULL); vblank_out = vdp2_tvmd_vblank_out_irq_get(); irq_mux_handle_add(vblank_out, vblank_out_handler, NULL); hblank_out = vdp2_tvmd_hblank_in_irq_get(); irq_mux_handle_add(hblank_out, hblank_out_handler, NULL); scu_ic_mask_chg(IC_MASK_ALL, mask); scu_ic_interrupt_set(IC_INTERRUPT_LEVEL_0_DMA_END, scu_dma_level_0_end); scu_ic_interrupt_set(IC_INTERRUPT_LEVEL_1_DMA_END, scu_dma_level_1_end); scu_ic_interrupt_set(IC_INTERRUPT_LEVEL_2_DMA_END, scu_dma_level_2_end); scu_ic_interrupt_set(IC_INTERRUPT_DMA_ILLEGAL, scu_dma_illegal); scu_ic_mask_chg(IC_MASK_ALL & ~mask, IC_MASK_NONE); cpu_intc_enable(); vdp2_tvmd_display_set(); vdp2_scrn_back_screen_color_set(VRAM_ADDR_4MBIT(3, 0x1FFFE), back_screen_color); while (true) { (void)sprintf( consbuf, "[01;2H**** SCU DMA from H-RAM to VDP1 ****[04;2HRelease Start to run, Z to quit[05;2HTo configure press:[07;2HA/B/C: SCU DMA Level 0/1/2[08;2HL/R: Mode Direct/Indirect[09;2HDown/Up/Left/Right: VBO/VBI/HBL/Bit[11;2HLevel %d State %d Mode %s Trig %d[14;2HLast exec time: %08lu HBL", level, state.st_status, (state.st_level[level].level_mode==DMA_MODE_DIRECT)?"DIR":"IND", state.st_level[level].level_sf, g_dma_counter); cons_buffer(consbuf); vdp2_tvmd_vblank_in_wait(); cons_flush(); vdp2_tvmd_vblank_out_wait(); switch (state.st_status) { case ST_STATUS_WAIT: cons_buffer("[13;2HStatus wait "); break; case ST_STATUS_ILLEGAL: state.st_begin = false; cons_buffer("[13;2HStatus illegal "); break; case ST_STATUS_END: state.st_begin = false; cons_buffer("[13;2HStatus end "); state.st_status = ST_STATUS_WAIT; break; } if (!state.st_begin) { if (g_digital.connected == 1) { joyL = g_digital.pressed.button.l; joyR = g_digital.pressed.button.r; joyStart = g_digital.released.button.start; joyA = g_digital.pressed.button.a; joyB = g_digital.pressed.button.b; joyC = g_digital.pressed.button.c; joyUp = g_digital.pressed.button.up; joyDown = g_digital.pressed.button.down; joyRight = g_digital.pressed.button.right; joyLeft = g_digital.pressed.button.left; if(joyA & !oldjoyA) level = DMA_LEVEL_0; else if (joyB & !oldjoyB) level = DMA_LEVEL_1; else if (joyC & !oldjoyC) level = DMA_LEVEL_2; else if (joyL & !oldjoyL) state.st_level[level].level_mode = DMA_MODE_DIRECT; else if (joyR & !oldjoyR) state.st_level[level].level_mode = DMA_MODE_INDIRECT; else if (joyUp & !oldjoyUp) state.st_level[level].level_sf = DMA_MODE_START_FACTOR_VBLANK_IN; else if (joyDown & !oldjoyDown) state.st_level[level].level_sf = DMA_MODE_START_FACTOR_VBLANK_OUT; else if (joyLeft & !oldjoyLeft) state.st_level[level].level_sf = DMA_MODE_START_FACTOR_HBLANK_IN; else if (joyRight & !oldjoyRight) state.st_level[level].level_sf = DMA_MODE_START_FACTOR_ENABLE; if (joyStart & !oldjoyStart) { cons_buffer("[12;2HStarted "); scu_dma_level(level); } else { cons_buffer("[12;2HNot Started "); } oldjoyR = joyR; oldjoyL = joyL; oldjoyA = joyA; oldjoyB = joyB; oldjoyC = joyC; oldjoyUp = joyUp; oldjoyDown = joyDown; oldjoyLeft = joyLeft; oldjoyRight = joyRight; oldjoyStart = joyStart; } } // exit if(g_digital.pressed.button.z) abort(); } return 0; }