src/memory.c

changeset 121
15ae2788e848
parent 119
101fe02456ce
child 128
3246b74d96bc
child 129
8b24770dea79
     1.1 --- a/src/memory.c	Mon Jan 14 09:50:37 2013 +0000
     1.2 +++ b/src/memory.c	Tue Jan 15 17:02:56 2013 +0000
     1.3 @@ -111,7 +111,6 @@
     1.4  	return MEM_ALLOWED;
     1.5  }/*}}}*/
     1.6  
     1.7 -#undef MAPRAM
     1.8  
     1.9  
    1.10  /********************************************************
    1.11 @@ -1011,7 +1010,72 @@
    1.12  
    1.13  
    1.14  // for the disassembler
    1.15 -uint32_t m68k_read_disassembler_32(uint32_t addr) { return m68k_read_memory_32(addr); }
    1.16 -uint32_t m68k_read_disassembler_16(uint32_t addr) { return m68k_read_memory_16(addr); }
    1.17 -uint32_t m68k_read_disassembler_8 (uint32_t addr) { return m68k_read_memory_8 (addr); }
    1.18 +uint32_t m68k_read_disassembler_32(uint32_t addr)
    1.19 +{
    1.20 +	if (addr < 0x400000) {
    1.21 +		uint16_t page = (addr >> 12) & 0x3FF;
    1.22 +		uint32_t new_page_addr = MAPRAM(page) & 0x3FF;
    1.23 +		uint32_t newAddr = (new_page_addr << 12) + (addr & 0xFFF);
    1.24 +		if (newAddr <= 0x1fffff) {
    1.25 +			if (newAddr >= state.base_ram_size)
    1.26 +				return EMPTY;
    1.27 +			else
    1.28 +				return RD32(state.base_ram, newAddr, state.base_ram_size - 1);
    1.29 +		} else {
    1.30 +			if ((newAddr <= (state.exp_ram_size + 0x200000 - 1)) && (newAddr >= 0x200000))
    1.31 +				return RD32(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1);
    1.32 +			else
    1.33 +				return EMPTY;
    1.34 +		}
    1.35 +	} else {
    1.36 +		printf(">>> WARNING Disassembler RD32 out of range 0x%08X\n", addr);
    1.37 +		return EMPTY;
    1.38 +	}
    1.39 +}
    1.40  
    1.41 +uint32_t m68k_read_disassembler_16(uint32_t addr)
    1.42 +{
    1.43 +	if (addr < 0x400000) {
    1.44 +		uint16_t page = (addr >> 12) & 0x3FF;
    1.45 +		uint32_t new_page_addr = MAPRAM(page) & 0x3FF;
    1.46 +		uint32_t newAddr = (new_page_addr << 12) + (addr & 0xFFF);
    1.47 +		if (newAddr <= 0x1fffff) {
    1.48 +			if (newAddr >= state.base_ram_size)
    1.49 +				return EMPTY & 0xffff;
    1.50 +			else
    1.51 +				return RD16(state.base_ram, newAddr, state.base_ram_size - 1);
    1.52 +		} else {
    1.53 +			if ((newAddr <= (state.exp_ram_size + 0x200000 - 1)) && (newAddr >= 0x200000))
    1.54 +				return RD16(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1);
    1.55 +			else
    1.56 +				return EMPTY & 0xffff;
    1.57 +		}
    1.58 +	} else {
    1.59 +		printf(">>> WARNING Disassembler RD16 out of range 0x%08X\n", addr);
    1.60 +		return EMPTY & 0xffff;
    1.61 +	}
    1.62 +}
    1.63 +
    1.64 +uint32_t m68k_read_disassembler_8 (uint32_t addr)
    1.65 +{
    1.66 +	if (addr < 0x400000) {
    1.67 +		uint16_t page = (addr >> 12) & 0x3FF;
    1.68 +		uint32_t new_page_addr = MAPRAM(page) & 0x3FF;
    1.69 +		uint32_t newAddr = (new_page_addr << 12) + (addr & 0xFFF);
    1.70 +		if (newAddr <= 0x1fffff) {
    1.71 +			if (newAddr >= state.base_ram_size)
    1.72 +				return EMPTY & 0xff;
    1.73 +			else
    1.74 +				return RD8(state.base_ram, newAddr, state.base_ram_size - 1);
    1.75 +		} else {
    1.76 +			if ((newAddr <= (state.exp_ram_size + 0x200000 - 1)) && (newAddr >= 0x200000))
    1.77 +				return RD8(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1);
    1.78 +			else
    1.79 +				return EMPTY & 0xff;
    1.80 +		}
    1.81 +	} else {
    1.82 +		printf(">>> WARNING Disassembler RD8 out of range 0x%08X\n", addr);
    1.83 +		return EMPTY & 0xff;
    1.84 +	}
    1.85 +}
    1.86 +