# HG changeset patch # User Mike Pavone # Date 1367558807 25200 # Node ID 9b04b57434b59fb3a650f2d014befcc3e7ba72af # Parent 969ee17471c5aa62730de34193c39b5b037c1970 Implement LDI diff -r 969ee17471c5 -r 9b04b57434b5 render_sdl.c --- a/render_sdl.c Thu May 02 22:21:41 2013 -0700 +++ b/render_sdl.c Thu May 02 22:26:47 2013 -0700 @@ -366,7 +366,7 @@ } } //TODO: Adjust frame delay so we actually get 60 FPS rather than 62.5 FPS - uint32_t current = SDL_GetTicks(); + /*uint32_t current = SDL_GetTicks(); uint32_t desired = last_frame + FRAME_DELAY; if (current < desired) { uint32_t delay = last_frame + FRAME_DELAY - current; @@ -376,14 +376,14 @@ } while ((desired) >= SDL_GetTicks()) { } - } + }*/ render_context(context); - /* + //TODO: Figure out why this causes segfaults - frame_counter++; + /*frame_counter++; if ((last_frame - start) > 1000) { - if (start) { + if (start && (last_frame-start)) { printf("\r%f fps", ((float)frame_counter) / (((float)(last_frame-start)) / 1000.0)); fflush(stdout); } diff -r 969ee17471c5 -r 9b04b57434b5 z80_to_x86.c --- a/z80_to_x86.c Thu May 02 22:21:41 2013 -0700 +++ b/z80_to_x86.c Thu May 02 22:26:47 2013 -0700 @@ -507,7 +507,21 @@ dst = mov_rdisp8r(dst, CONTEXT, zar_off(Z80_E), opts->regs[Z80_DE], SZ_W); dst = mov_rrdisp8(dst, SCRATCH1, CONTEXT, zar_off(Z80_E), SZ_W); break; - //case Z80_LDI: + case Z80_LDI: { + dst = zcycles(dst, 8); + dst = mov_rr(dst, opts->regs[Z80_HL], SCRATCH1, SZ_W); + dst = call(dst, (uint8_t *)z80_read_byte); + dst = mov_rr(dst, opts->regs[Z80_DE], SCRATCH2, SZ_W); + dst = call(dst, (uint8_t *)z80_read_byte); + dst = zcycles(dst, 2); + dst = add_ir(dst, 1, opts->regs[Z80_DE], SZ_W); + dst = add_ir(dst, 1, opts->regs[Z80_HL], SZ_W); + dst = sub_ir(dst, 1, opts->regs[Z80_BC], SZ_W); + //TODO: Implement half-carry + dst = mov_irdisp8(dst, 0, CONTEXT, zf_off(ZF_N), SZ_B); + dst = setcc_rdisp8(dst, CC_NZ, CONTEXT, zf_off(ZF_PV)); + break; + } case Z80_LDIR: { dst = zcycles(dst, 8); dst = mov_rr(dst, opts->regs[Z80_HL], SCRATCH1, SZ_W);