diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-01-04 12:24:34 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-01-04 12:24:34 -0800 |
commit | 5517b4f5712f49a04ab2f43365991b14e286065a (patch) | |
tree | f3ae60d276590cc43b104412859306303858b54e /vdp.c | |
parent | bb5e4d5126fb6c6b64ef84615ec9e5e15848575d (diff) |
Adjusted h40_hsync_cycles so that lines actually take 3420 mclks. Fixed vdp_cycles_next_line to take h40_sync_cycles into account
Diffstat (limited to 'vdp.c')
-rw-r--r-- | vdp.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1420,7 +1420,7 @@ void check_render_bg(vdp_context * context, int32_t line, uint32_t slot) } } -uint32_t h40_hsync_cycles[] = {19, 20, 20, 20, 18, 20, 20, 20, 18, 20, 20, 20, 18, 20, 20, 20, 19}; +uint32_t const h40_hsync_cycles[] = {19, 20, 20, 20, 19, 20, 20, 20, 19, 20, 20, 20, 19, 20, 20, 20, 19}; void vdp_run_context(vdp_context * context, uint32_t target_cycles) { @@ -1827,6 +1827,15 @@ uint32_t vdp_cycles_next_line(vdp_context * context) return (HBLANK_START_H40 - context->hslot) * MCLKS_SLOT_H40; } else if (context->hslot < 183) { return MCLKS_LINE - (context->hslot - LINE_CHANGE_H40) * MCLKS_SLOT_H40; + } else if (context->hslot < HSYNC_END_H40){ + uint32_t before_hsync = context->hslot < HSYNC_SLOT_H40 ? (HSYNC_SLOT_H40 - context->hslot) * MCLKS_SLOT_H40 : 0; + uint32_t hsync = 0; + for (int i = context->hslot <= HSYNC_SLOT_H40 ? 0 : context->hslot - HSYNC_SLOT_H40; i < sizeof(h40_hsync_cycles)/sizeof(uint32_t); i++) + { + hsync += h40_hsync_cycles[i]; + } + uint32_t after_hsync = (256- HSYNC_END_H40 + LINE_CHANGE_H40) * MCLKS_SLOT_H40; + return before_hsync + hsync + after_hsync; } else { return (256-context->hslot + LINE_CHANGE_H40) * MCLKS_SLOT_H40; } |