Mercurial > repos > blastem
comparison m68k_core.c @ 988:ce9df7a5fdf2
Fix changes made to get_instruction_start and map_native_address to cope with being able to translate at odd addresses.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 27 Apr 2016 19:10:50 -0700 |
parents | 1f09994e92c5 |
children | d70000fdff0b |
comparison
equal
deleted
inserted
replaced
987:1f09994e92c5 | 988:ce9df7a5fdf2 |
---|---|
584 //TODO: Refactor part of this loop into some kind of get_ram_chunk function | 584 //TODO: Refactor part of this loop into some kind of get_ram_chunk function |
585 for (int i = 0; i < opts->gen.memmap_chunks; i++) { | 585 for (int i = 0; i < opts->gen.memmap_chunks; i++) { |
586 if (address >= opts->gen.memmap[i].start && address < opts->gen.memmap[i].end) { | 586 if (address >= opts->gen.memmap[i].start && address < opts->gen.memmap[i].end) { |
587 //calculate the lowest alias for this address | 587 //calculate the lowest alias for this address |
588 address = opts->gen.memmap[i].start + ((address - opts->gen.memmap[i].start) & opts->gen.memmap[i].mask); | 588 address = opts->gen.memmap[i].start + ((address - opts->gen.memmap[i].start) & opts->gen.memmap[i].mask); |
589 break; | |
589 } | 590 } |
590 } | 591 } |
591 | 592 |
592 uint32_t chunk = address / NATIVE_CHUNK_SIZE; | 593 uint32_t chunk = address / NATIVE_CHUNK_SIZE; |
593 if (!native_code_map[chunk].base) { | 594 if (!native_code_map[chunk].base) { |
600 while (native_code_map[chunk].offsets[offset] == EXTENSION_WORD) { | 601 while (native_code_map[chunk].offsets[offset] == EXTENSION_WORD) { |
601 --address; | 602 --address; |
602 chunk = address / NATIVE_CHUNK_SIZE; | 603 chunk = address / NATIVE_CHUNK_SIZE; |
603 offset = address % NATIVE_CHUNK_SIZE; | 604 offset = address % NATIVE_CHUNK_SIZE; |
604 } | 605 } |
605 return address*2; | 606 return address; |
606 } | 607 } |
607 | 608 |
608 void map_native_address(m68k_context * context, uint32_t address, code_ptr native_addr, uint8_t size, uint8_t native_size) | 609 void map_native_address(m68k_context * context, uint32_t address, code_ptr native_addr, uint8_t size, uint8_t native_size) |
609 { | 610 { |
610 native_map_slot * native_code_map = context->native_code_map; | 611 native_map_slot * native_code_map = context->native_code_map; |
647 native_code_map[chunk].offsets = malloc(sizeof(int32_t) * NATIVE_CHUNK_SIZE); | 648 native_code_map[chunk].offsets = malloc(sizeof(int32_t) * NATIVE_CHUNK_SIZE); |
648 memset(native_code_map[chunk].offsets, 0xFF, sizeof(int32_t) * NATIVE_CHUNK_SIZE); | 649 memset(native_code_map[chunk].offsets, 0xFF, sizeof(int32_t) * NATIVE_CHUNK_SIZE); |
649 } | 650 } |
650 uint32_t offset = address % NATIVE_CHUNK_SIZE; | 651 uint32_t offset = address % NATIVE_CHUNK_SIZE; |
651 native_code_map[chunk].offsets[offset] = native_addr-native_code_map[chunk].base; | 652 native_code_map[chunk].offsets[offset] = native_addr-native_code_map[chunk].base; |
652 for(address++,size-=2; size; address++,size-=2) { | 653 for(address++,size-=1; size; address++,size-=1) { |
653 address &= opts->gen.address_mask >> 1; | 654 address &= opts->gen.address_mask; |
654 chunk = address / NATIVE_CHUNK_SIZE; | 655 chunk = address / NATIVE_CHUNK_SIZE; |
655 offset = address % NATIVE_CHUNK_SIZE; | 656 offset = address % NATIVE_CHUNK_SIZE; |
656 if (!native_code_map[chunk].base) { | 657 if (!native_code_map[chunk].base) { |
657 native_code_map[chunk].base = native_addr; | 658 native_code_map[chunk].base = native_addr; |
658 native_code_map[chunk].offsets = malloc(sizeof(int32_t) * NATIVE_CHUNK_SIZE); | 659 native_code_map[chunk].offsets = malloc(sizeof(int32_t) * NATIVE_CHUNK_SIZE); |