src/mess/video/fm7.c
| r5137 | r5138 | |
| 120 | 120 | fm7_video.vram_access = 0; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | static void fm7_alu_function_pset(UINT32 offset) |
| 124 | { |
| 125 | // PSET - simply sets the pixels to the selected logical colour |
| 126 | int x; |
| 127 | UINT8 dat; |
| 128 | int page = 0; |
| 129 | UINT8 mask; |
| 130 | |
| 131 | if(offset > 0xc000) |
| 132 | page = 1; |
| 133 | |
| 134 | for(x=0;x<3;x++) // cycle through banks |
| 135 | { |
| 136 | if(fm7_alu.lcolour & (1 << x)) |
| 137 | dat = 0xff; |
| 138 | else |
| 139 | dat = 0; |
| 140 | |
| 141 | mask = (fm7_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]) & fm7_alu.mask; |
| 142 | dat &= ~fm7_alu.mask; |
| 143 | dat |= mask; |
| 144 | |
| 145 | fm7_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)] = dat; |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | static void fm7_alu_function(UINT32 offset) |
| 150 | { |
| 151 | switch(fm7_alu.command & 0x07) |
| 152 | { |
| 153 | case 0x00: // PSET |
| 154 | fm7_alu_function_pset(offset); |
| 155 | break; |
| 156 | case 0x02: // OR |
| 157 | case 0x03: // AND |
| 158 | case 0x04: // XOR |
| 159 | case 0x05: // NOT |
| 160 | case 0x06: // TILEPAINT |
| 161 | case 0x07: // COMPARE |
| 162 | logerror("ALU: Unimplemented draw mode %i used\n",fm7_alu.command & 0x07); |
| 163 | break; |
| 164 | case 0x01: |
| 165 | default: |
| 166 | logerror("ALU: Invalid draw mode %i used\n",fm7_alu.command & 0x07); |
| 167 | } |
| 168 | } |
| 169 | |
| 123 | 170 | READ8_HANDLER( fm7_vram_r ) |
| 124 | 171 | { |
| 125 | 172 | int offs; |
| 126 | 173 | UINT16 page = 0x0000; |
| 174 | |
| 175 | if(fm7_video.active_video_page != 0) |
| 176 | page = 0xc000; |
| 177 | |
| 178 | if(fm7_alu.command & 0x80) // ALU active, writes to VRAM even when reading it (go figure) |
| 179 | { |
| 180 | fm7_alu_function(offset+page); |
| 181 | } |
| 127 | 182 | |
| 128 | 183 | if(offset < 0x4000 && (fm7_video.multi_page & 0x01)) |
| 129 | 184 | return 0xff; |
| r5137 | r5138 | |
| 132 | 187 | if((offset < 0xc000 && offset >=0x8000) && (fm7_video.multi_page & 0x04)) |
| 133 | 188 | return 0xff; |
| 134 | 189 | |
| 135 | | if(fm7_video.active_video_page != 0) |
| 136 | | page = 0xc000; |
| 137 | | |
| 138 | 190 | offs = (offset & 0xc000) | ((offset + fm7_video.vram_offset) & 0x3fff); |
| 139 | 191 | return fm7_video_ram[offs + page]; |
| 140 | 192 | } |
| r5137 | r5138 | |
| 144 | 196 | int offs; |
| 145 | 197 | UINT16 page = 0x0000; |
| 146 | 198 | |
| 199 | if(fm7_video.active_video_page != 0) |
| 200 | page = 0xc000; |
| 201 | |
| 202 | if(fm7_alu.command & 0x80) // ALU active |
| 203 | { |
| 204 | fm7_alu_function(offset+page); |
| 205 | return; |
| 206 | } |
| 207 | |
| 147 | 208 | if(offset < 0x4000 && (fm7_video.multi_page & 0x01)) |
| 148 | 209 | return; |
| 149 | 210 | if((offset < 0x8000 && offset >=0x4000) && (fm7_video.multi_page & 0x02)) |
| r5137 | r5138 | |
| 151 | 212 | if((offset < 0xc000 && offset >=0x8000) && (fm7_video.multi_page & 0x04)) |
| 152 | 213 | return; |
| 153 | 214 | |
| 154 | | if(fm7_video.active_video_page != 0) |
| 155 | | page = 0xc000; |
| 156 | | |
| 157 | 215 | offs = (offset & 0xc000) | ((offset + fm7_video.vram_offset) & 0x3fff); |
| 158 | 216 | if(fm7_video.vram_access != 0) |
| 159 | 217 | fm7_video_ram[offs+page] = data; |
| r5137 | r5138 | |
| 167 | 225 | |
| 168 | 226 | if(!fm7_video.sub_halt) // no access if sub CPU is not halted. |
| 169 | 227 | return; |
| 228 | |
| 229 | if(fm7_video.active_video_page != 0) |
| 230 | page = 0xc000; |
| 231 | |
| 232 | if(fm7_alu.command & 0x80) // ALU active |
| 233 | { |
| 234 | fm7_alu_function(offset+page); |
| 235 | return; |
| 236 | } |
| 170 | 237 | |
| 171 | 238 | if(offset < 0x4000 && (fm7_video.multi_page & 0x01)) |
| 172 | 239 | return; |
| r5137 | r5138 | |
| 175 | 242 | if((offset < 0xc000 && offset >=0x8000) && (fm7_video.multi_page & 0x04)) |
| 176 | 243 | return; |
| 177 | 244 | |
| 178 | | if(fm7_video.active_video_page != 0) |
| 179 | | page = 0xc000; |
| 180 | | |
| 181 | 245 | offs = (offset & 0xc000) | ((offset + fm7_video.vram_offset) & 0x3fff); |
| 182 | 246 | fm7_video_ram[offs+page] = data; |
| 183 | 247 | } |