vce.c
1 2 #include "shared.h" 3 4 t_vce vce; 5 6 void vce_w(int address, int data) 7 { 8 int msb = (address & 1); 9 10 switch(address & ~1) 11 { 12 case 0x404: /* Data */ 13 { 14 if(data != vce.data[((vce.addr & 0x1FF) << 1) | (msb)]) 15 { 16 vce.data[((vce.addr & 0x1FF) << 1) | (msb)] = data; 17 18 if((vce.addr & 0x0F) != 0x00) 19 { 20 // uint16 temp = *(uint16 *)&vce.data[(vce.addr << 1)]; // Execute error. 21 uint8 temp1 = vce.data[(vce.addr << 1)]; 22 uint8 temp2 = vce.data[(vce.addr << 1)+1]; 23 uint16 temp; 24 #ifndef LSB_FIRST 25 // temp = (temp >> 8) | (temp << 8); 26 temp = (((uint16)temp1) << 8) + (uint16)temp2; 27 #else 28 temp = (((uint16)temp2) << 8) + (uint16)temp1; 29 #endif 30 pixel[(vce.addr >> 8) & 1][(vce.addr & 0xFF)] = pixel_lut[temp]; 31 temp = (temp >> 1) & 0xFF; 32 } 33 34 /* Update overscan color */ 35 if((vce.addr & 0x0F) == 0x00) 36 { 37 int n; 38 uint16 temp = *(uint16 *)&vce.data[0]; 39 #ifndef LSB_FIRST 40 temp = (temp >> 8) | (temp << 8); 41 #endif 42 for(n = 0; n < 0x10; n += 1) 43 pixel[0][(n << 4)] = pixel_lut[temp]; 44 temp = (temp >> 1) & 0xFF; 45 } 46 } 47 } 48 49 /* Increment VCE address on access to the MSB data port */ 50 if(msb) vce.addr += 1; 51 break; 52 53 case 0x402: /* Address */ 54 if(msb) 55 vce.addr = (vce.addr & 0x00FF) | ((data & 1) << 8); 56 else 57 vce.addr = (vce.addr & 0x0100) | (data); 58 break; 59 60 case 0x0400: /* Control */ 61 if(!msb) vce.ctrl = (data & 1); 62 break; 63 } 64 } 65 66 67 int vce_r(int address) 68 { 69 int msb = (address & 1); 70 71 if((address & ~1) == 0x0404) 72 { 73 uint8 temp = vce.data[((vce.addr & 0x1FF) << 1) | (msb)]; 74 if(msb) vce.addr += 1; 75 return (temp); 76 } 77 78 return (0xFF); 79 }