finish expansion memory emulation

Tue, 28 Dec 2010 17:47:01 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Tue, 28 Dec 2010 17:47:01 +0000
changeset 63
f772d3c40531
parent 62
c895256b528d
child 64
5005879cb6fc

finish expansion memory emulation

src/main.c file | annotate | diff | revisions
src/memory.c file | annotate | diff | revisions
     1.1 --- a/src/main.c	Tue Dec 28 17:31:28 2010 +0000
     1.2 +++ b/src/main.c	Tue Dec 28 17:47:01 2010 +0000
     1.3 @@ -165,7 +165,7 @@
     1.4  	// set up system state
     1.5  	// 512K of RAM
     1.6  	int i;
     1.7 -	if ((i = state_init(512*1024, 0)) != STATE_E_OK) {
     1.8 +	if ((i = state_init(512*1024, 512*1024)) != STATE_E_OK) {
     1.9  		fprintf(stderr, "ERROR: Emulator initialisation failed. Error code %d.\n", i);
    1.10  		return i;
    1.11  	}
     2.1 --- a/src/memory.c	Tue Dec 28 17:31:28 2010 +0000
     2.2 +++ b/src/memory.c	Tue Dec 28 17:47:01 2010 +0000
     2.3 @@ -561,11 +561,14 @@
     2.4  	} else if (address <= 0x3fffff) {
     2.5  		// RAM access
     2.6  		uint32_t newAddr = mapAddr(address, false);
     2.7 -		if (newAddr <= 0x1fffff)
     2.8 +		if (newAddr <= 0x1fffff) {
     2.9  			return RD32(state.base_ram, newAddr, state.base_ram_size - 1);
    2.10 -		else
    2.11 -			return 0xFFFFFFFF;
    2.12 -		// TODO: expansion RAM
    2.13 +		} else {
    2.14 +			if (newAddr <= (state.exp_ram_size + 0x200000 - 1))
    2.15 +				return RD32(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1);
    2.16 +			else
    2.17 +				return 0xffffffff;
    2.18 +		}
    2.19  	} else if ((address >= 0x400000) && (address <= 0x7FFFFF)) {
    2.20  		// I/O register space, zone A
    2.21  		switch (address & 0x0F0000) {
    2.22 @@ -607,11 +610,14 @@
    2.23  	} else if (address <= 0x3fffff) {
    2.24  		// RAM access
    2.25  		uint32_t newAddr = mapAddr(address, false);
    2.26 -		if (newAddr <= 0x1fffff)
    2.27 +		if (newAddr <= 0x1fffff) {
    2.28  			return RD16(state.base_ram, newAddr, state.base_ram_size - 1);
    2.29 -		else
    2.30 -			return 0xFFFF;
    2.31 -		// TODO: expansion RAM
    2.32 +		} else {
    2.33 +			if (newAddr <= (state.exp_ram_size + 0x200000 - 1))
    2.34 +				return RD16(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1);
    2.35 +			else
    2.36 +				return 0xffff;
    2.37 +		}
    2.38  	} else if ((address >= 0x400000) && (address <= 0x7FFFFF)) {
    2.39  		// I/O register space, zone A
    2.40  		switch (address & 0x0F0000) {
    2.41 @@ -653,11 +659,14 @@
    2.42  	} else if (address <= 0x3fffff) {
    2.43  		// RAM access
    2.44  		uint32_t newAddr = mapAddr(address, false);
    2.45 -		if (newAddr <= 0x1fffff)
    2.46 +		if (newAddr <= 0x1fffff) {
    2.47  			return RD8(state.base_ram, newAddr, state.base_ram_size - 1);
    2.48 -		else
    2.49 -			return 0xFFFFFFFF;
    2.50 -		// TODO: expansion RAM
    2.51 +		} else {
    2.52 +			if (newAddr <= (state.exp_ram_size + 0x200000 - 1))
    2.53 +				return RD8(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1);
    2.54 +			else
    2.55 +				return 0xff;
    2.56 +		}
    2.57  	} else if ((address >= 0x400000) && (address <= 0x7FFFFF)) {
    2.58  		// I/O register space, zone A
    2.59  		switch (address & 0x0F0000) {
    2.60 @@ -696,9 +705,11 @@
    2.61  	} else if (address <= 0x3FFFFF) {
    2.62  		// RAM access
    2.63  		uint32_t newAddr = mapAddr(address, true);
    2.64 -		if (newAddr <= 0x1fffff)
    2.65 +		if (newAddr <= 0x1fffff) {
    2.66  			WR32(state.base_ram, newAddr, state.base_ram_size - 1, value);
    2.67 -		// TODO: expansion ram
    2.68 +		} else {
    2.69 +//			WR32(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1, value);
    2.70 +		}
    2.71  	} else if ((address >= 0x400000) && (address <= 0x7FFFFF)) {
    2.72  		// I/O register space, zone A
    2.73  		switch (address & 0x0F0000) {
    2.74 @@ -735,9 +746,11 @@
    2.75  	} else if (address <= 0x3FFFFF) {
    2.76  		// RAM access
    2.77  		uint32_t newAddr = mapAddr(address, true);
    2.78 -		if (newAddr <= 0x1fffff)
    2.79 +		if (newAddr <= 0x1fffff) {
    2.80  			WR16(state.base_ram, newAddr, state.base_ram_size - 1, value);
    2.81 -		// TODO: expansion ram
    2.82 +		} else {
    2.83 +//			WR16(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1, value);
    2.84 +		}
    2.85  	} else if ((address >= 0x400000) && (address <= 0x7FFFFF)) {
    2.86  		// I/O register space, zone A
    2.87  		switch (address & 0x0F0000) {
    2.88 @@ -774,9 +787,11 @@
    2.89  	} else if (address <= 0x3FFFFF) {
    2.90  		// RAM access
    2.91  		uint32_t newAddr = mapAddr(address, true);
    2.92 -		if (newAddr <= 0x1fffff)
    2.93 +		if (newAddr <= 0x1fffff) {
    2.94  			WR8(state.base_ram, newAddr, state.base_ram_size - 1, value);
    2.95 -		// TODO: expansion ram
    2.96 +		} else {
    2.97 +//			WR8(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1, value);
    2.98 +		}
    2.99  	} else if ((address >= 0x400000) && (address <= 0x7FFFFF)) {
   2.100  		// I/O register space, zone A
   2.101  		switch (address & 0x0F0000) {