Mercurial > repos > blastem
view x86_backend.c @ 380:1c8d74f2ab0b
Make the PSG and YM2612 use the master clock internal with an increment based on clock divider so that they stay perflectly in sync. Run both the PSG and YM2612 whenver one of them needs to be run.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 03 Jun 2013 21:43:38 -0700 |
parents | 7b8a49220e3b |
children | 140af5509ce7 |
line wrap: on
line source
#include "x86_backend.h" #include <stdlib.h> deferred_addr * defer_address(deferred_addr * old_head, uint32_t address, uint8_t *dest) { deferred_addr * new_head = malloc(sizeof(deferred_addr)); new_head->next = old_head; new_head->address = address & 0xFFFFFF; new_head->dest = dest; return new_head; } void remove_deferred_until(deferred_addr **head_ptr, deferred_addr * remove_to) { for(deferred_addr *cur = *head_ptr; cur && cur != remove_to; cur = *head_ptr) { *head_ptr = cur->next; free(cur); } } void process_deferred(deferred_addr ** head_ptr, void * context, native_addr_func get_native) { deferred_addr * cur = *head_ptr; deferred_addr **last_next = head_ptr; while(cur) { uint8_t * native = get_native(context, cur->address);//get_native_address(opts->native_code_map, cur->address); if (native) { int32_t disp = native - (cur->dest + 4); uint8_t * out = cur->dest; *(out++) = disp; disp >>= 8; *(out++) = disp; disp >>= 8; *(out++) = disp; disp >>= 8; *out = disp; *last_next = cur->next; free(cur); cur = *last_next; } else { last_next = &(cur->next); cur = cur->next; } } }