src/memory.c

changeset 52
a350dfa92895
parent 46
7d14fab5e4aa
child 53
e1693c4b8a0c
     1.1 --- a/src/memory.c	Sun Dec 05 16:18:50 2010 +0000
     1.2 +++ b/src/memory.c	Sun Dec 05 16:20:00 2010 +0000
     1.3 @@ -310,6 +310,9 @@
     1.4  					case 0x000000:		// [ef][08]xxxx ==> WD1010 hard disc controller
     1.5  						break;
     1.6  					case 0x010000:		// [ef][19]xxxx ==> WD2797 floppy disc controller
     1.7 +						data = wd2797_read_reg(&state.fdc_ctx, (address >> 1) & 3);
     1.8 +						printf("WD279X: rd %02X ==> %02X\n", (address >> 1) & 3, data);
     1.9 +						handled = true;
    1.10  						break;
    1.11  					case 0x020000:		// [ef][2a]xxxx ==> Miscellaneous Control Register 2
    1.12  						break;
    1.13 @@ -472,6 +475,9 @@
    1.14  					case 0x000000:		// [ef][08]xxxx ==> WD1010 hard disc controller
    1.15  						break;
    1.16  					case 0x010000:		// [ef][19]xxxx ==> WD2797 floppy disc controller
    1.17 +						data = wd2797_read_reg(&state.fdc_ctx, (address >> 1) & 3);
    1.18 +						printf("WD279X: rd %02X ==> %02X\n", (address >> 1) & 3, data);
    1.19 +						handled = true;
    1.20  						break;
    1.21  					case 0x020000:		// [ef][2a]xxxx ==> Miscellaneous Control Register 2
    1.22  						break;
    1.23 @@ -643,6 +649,9 @@
    1.24  					case 0x000000:		// [ef][08]xxxx ==> WD1010 hard disc controller
    1.25  						break;
    1.26  					case 0x010000:		// [ef][19]xxxx ==> WD2797 floppy disc controller
    1.27 +						data = wd2797_read_reg(&state.fdc_ctx, (address >> 1) & 3);
    1.28 +						printf("WD279X: rd %02X ==> %02X\n", (address >> 1) & 3, data);
    1.29 +						handled = true;
    1.30  						break;
    1.31  					case 0x020000:		// [ef][2a]xxxx ==> Miscellaneous Control Register 2
    1.32  						break;
    1.33 @@ -762,6 +771,8 @@
    1.34  				break;
    1.35  			case 0x0A0000:				// Miscellaneous Control Register
    1.36  				// TODO: handle the ctrl bits properly
    1.37 +				// TODO: &0x8000 --> dismiss 60hz intr
    1.38 +				state.dma_reading = (value & 0x4000);
    1.39  				state.leds = (~value & 0xF00) >> 8;
    1.40  				printf("LEDs: %s %s %s %s\n",
    1.41  						(state.leds & 8) ? "R" : "-",
    1.42 @@ -779,8 +790,22 @@
    1.43  				handled = true;
    1.44  				break;
    1.45  			case 0x0D0000:				// DMA Address Register
    1.46 +				if (address & 0x004000) {
    1.47 +					// A14 high -- set most significant bits
    1.48 +					state.dma_address = (state.dma_address & 0xff) | ((address & 0x3fff) << 7);
    1.49 +				} else {
    1.50 +					// A14 low -- set least significant bits
    1.51 +					state.dma_address = (state.dma_address & 0x3fff00) | (address & 0xff);
    1.52 +				}
    1.53  				break;
    1.54  			case 0x0E0000:				// Disk Control Register
    1.55 +				// B7 = FDD controller reset
    1.56 +				if ((value & 0x80) == 0) wd2797_reset(&state.fdc_ctx);
    1.57 +				// B6 = drive 0 select -- TODO
    1.58 +				// B5 = motor enable -- TODO
    1.59 +				// B4 = HDD controller reset -- TODO
    1.60 +				// B3 = HDD0 select -- TODO
    1.61 +				// B2,1,0 = HDD0 head select
    1.62  				break;
    1.63  			case 0x0F0000:				// Line Printer Data Register
    1.64  				break;
    1.65 @@ -810,6 +835,9 @@
    1.66  					case 0x000000:		// [ef][08]xxxx ==> WD1010 hard disc controller
    1.67  						break;
    1.68  					case 0x010000:		// [ef][19]xxxx ==> WD2797 floppy disc controller
    1.69 +						wd2797_write_reg(&state.fdc_ctx, (address >> 1) & 3, value);
    1.70 +						printf("WD279X: wr %02X ==> %02X\n\t", (address >> 1) & 3, value);
    1.71 +						//handled = true;
    1.72  						break;
    1.73  					case 0x020000:		// [ef][2a]xxxx ==> Miscellaneous Control Register 2
    1.74  						break;
    1.75 @@ -936,6 +964,8 @@
    1.76  				break;
    1.77  			case 0x0A0000:				// Miscellaneous Control Register
    1.78  				// TODO: handle the ctrl bits properly
    1.79 +				// TODO: &0x8000 --> dismiss 60hz intr
    1.80 +				state.dma_reading = (value & 0x4000);
    1.81  				state.leds = (~value & 0xF00) >> 8;
    1.82  				printf("LEDs: %s %s %s %s\n",
    1.83  						(state.leds & 8) ? "R" : "-",
    1.84 @@ -953,8 +983,22 @@
    1.85  				handled = true;
    1.86  				break;
    1.87  			case 0x0D0000:				// DMA Address Register
    1.88 +				if (address & 0x004000) {
    1.89 +					// A14 high -- set most significant bits
    1.90 +					state.dma_address = (state.dma_address & 0xff) | ((address & 0x3fff) << 7);
    1.91 +				} else {
    1.92 +					// A14 low -- set least significant bits
    1.93 +					state.dma_address = (state.dma_address & 0x3fff00) | (address & 0xff);
    1.94 +				}
    1.95  				break;
    1.96  			case 0x0E0000:				// Disk Control Register
    1.97 +				// B7 = FDD controller reset
    1.98 +				if ((value & 0x80) == 0) wd2797_reset(&state.fdc_ctx);
    1.99 +				// B6 = drive 0 select -- TODO
   1.100 +				// B5 = motor enable -- TODO
   1.101 +				// B4 = HDD controller reset -- TODO
   1.102 +				// B3 = HDD0 select -- TODO
   1.103 +				// B2,1,0 = HDD0 head select
   1.104  				break;
   1.105  			case 0x0F0000:				// Line Printer Data Register
   1.106  				break;
   1.107 @@ -983,6 +1027,9 @@
   1.108  					case 0x000000:		// [ef][08]xxxx ==> WD1010 hard disc controller
   1.109  						break;
   1.110  					case 0x010000:		// [ef][19]xxxx ==> WD2797 floppy disc controller
   1.111 +						wd2797_write_reg(&state.fdc_ctx, (address >> 1) & 3, value);
   1.112 +						printf("WD279X: wr %02X ==> %02X\n\t", (address >> 1) & 3, value);
   1.113 +						//handled = true;
   1.114  						break;
   1.115  					case 0x020000:		// [ef][2a]xxxx ==> Miscellaneous Control Register 2
   1.116  						break;
   1.117 @@ -1109,10 +1156,14 @@
   1.118  				break;
   1.119  			case 0x0A0000:				// Miscellaneous Control Register
   1.120  				// TODO: handle the ctrl bits properly
   1.121 -				if ((address & 1) == 0)
   1.122 -					;// CTL bits
   1.123 -				else
   1.124 +				if ((address & 1) == 0) {
   1.125 +					// low byte
   1.126 +				} else {
   1.127 +					// hight byte
   1.128 +					// TODO: &0x8000 --> dismiss 60hz intr
   1.129 +					state.dma_reading = (value & 0x40);
   1.130  					state.leds = (~value & 0xF);
   1.131 +				}
   1.132  				printf("LEDs: %s %s %s %s\n",
   1.133  						(state.leds & 8) ? "R" : "-",
   1.134  						(state.leds & 4) ? "G" : "-",
   1.135 @@ -1129,8 +1180,22 @@
   1.136  				handled = true;
   1.137  				break;
   1.138  			case 0x0D0000:				// DMA Address Register
   1.139 +				if (address & 0x004000) {
   1.140 +					// A14 high -- set most significant bits
   1.141 +					state.dma_address = (state.dma_address & 0xff) | ((address & 0x3fff) << 7);
   1.142 +				} else {
   1.143 +					// A14 low -- set least significant bits
   1.144 +					state.dma_address = (state.dma_address & 0x3fff00) | (address & 0xff);
   1.145 +				}
   1.146  				break;
   1.147  			case 0x0E0000:				// Disk Control Register
   1.148 +				// B7 = FDD controller reset
   1.149 +				if ((value & 0x80) == 0) wd2797_reset(&state.fdc_ctx);
   1.150 +				// B6 = drive 0 select -- TODO
   1.151 +				// B5 = motor enable -- TODO
   1.152 +				// B4 = HDD controller reset -- TODO
   1.153 +				// B3 = HDD0 select -- TODO
   1.154 +				// B2,1,0 = HDD0 head select
   1.155  				break;
   1.156  			case 0x0F0000:				// Line Printer Data Register
   1.157  				break;
   1.158 @@ -1159,6 +1224,9 @@
   1.159  					case 0x000000:		// [ef][08]xxxx ==> WD1010 hard disc controller
   1.160  						break;
   1.161  					case 0x010000:		// [ef][19]xxxx ==> WD2797 floppy disc controller
   1.162 +						wd2797_write_reg(&state.fdc_ctx, (address >> 1) & 3, value);
   1.163 +						printf("WD279X: wr %02X ==> %02X\n\t", (address >> 1) & 3, value);
   1.164 +						//handled = true;
   1.165  						break;
   1.166  					case 0x020000:		// [ef][2a]xxxx ==> Miscellaneous Control Register 2
   1.167  						break;