src/mess/drivers/vk100.c
| r15645 | r15646 | |
| 204 | 204 | * |
| 205 | 205 | */ |
| 206 | 206 | vk100_state *state = machine.driver_data<vk100_state>(); |
| 207 | | while (state->m_GO) // temporary hack to draw the entire vector in one call |
| 207 | // XFinal is (X'&0x3FC)|(X&0x3) |
| 208 | UINT16 XFinal = state->m_trans[(state->m_vgX&0x3FC)>>2]<<2|(state->m_vgX&0x3); // appears correct |
| 209 | // EA is the effective ram address for a 16-bit block |
| 210 | UINT16 EA = ((state->m_vgY&0x1FE)<<5)|(XFinal>>4); // appears correct |
| 211 | // block is the 16 bit block directly (note EA has to be <<1 to correctly index a byte) |
| 212 | UINT16 block = state->m_vram[(EA<<1)+1] | (state->m_vram[(EA<<1)]<<8); |
| 213 | // pattern rom addressing is a complex mess. see the pattern rom def later in this file. |
| 214 | UINT8 nybbleNum = (XFinal&0xC)>>2; // which of the four nybbles within the block to address. should NEVER be 3! |
| 215 | //printf("EA: %04X, nybblenum: %d X: %04X, X': %04X, Y: %04X\n", EA, nybbleNum, state->m_vgX, XFinal, state->m_vgY); |
| 216 | // patmask should be vg_patmask >>1 unless vg_patmask is 0x1 in which case it is 0x80 |
| 217 | UINT8 PATMask = state->m_vgPAT_Mask >> 1; |
| 218 | if (PATMask == 0) PATMask = 0x80; |
| 219 | UINT8 thisNyb = 0; |
| 220 | UINT16 blockRemain = 0; |
| 221 | switch(nybbleNum) |
| 208 | 222 | { |
| 209 | | // XFinal is (X'&0x3FC)|(X&0x3) |
| 210 | | UINT16 XFinal = state->m_trans[(state->m_vgX&0x3FC)>>2]<<2|(state->m_vgX&0x3); // appears correct |
| 211 | | // EA is the effective ram address for a 16-bit block |
| 212 | | UINT16 EA = ((state->m_vgY&0x1FE)<<5)|(XFinal>>4); // appears correct |
| 213 | | // block is the 16 bit block directly (note EA has to be <<1 to correctly index a byte) |
| 214 | | UINT16 block = state->m_vram[(EA<<1)+1] | (state->m_vram[(EA<<1)]<<8); |
| 215 | | // pattern rom addressing is a complex mess. see the pattern rom def later in this file. |
| 216 | | UINT8 nybbleNum = (XFinal&0xC)>>2; // which of the four nybbles within the block to address. should NEVER be 3! |
| 217 | | //printf("EA: %04X, nybblenum: %d X: %04X, X': %04X, Y: %04X\n", EA, nybbleNum, state->m_vgX, XFinal, state->m_vgY); |
| 218 | | // patmask should be vg_patmask >>1 unless vg_patmask is 0x1 in which case it is 0x80 |
| 219 | | UINT8 PATMask = state->m_vgPAT_Mask >> 1; |
| 220 | | if (PATMask == 0) PATMask = 0x80; |
| 221 | | UINT8 thisNyb = 0; |
| 222 | | UINT16 blockRemain = 0; |
| 223 | | switch(nybbleNum) |
| 224 | | { |
| 225 | | case 2: // modify the right nybble only (from the first byte) |
| 226 | | thisNyb = (block&0x0F00)>>8; |
| 227 | | blockRemain = (block&0xF0FF); // save the rest of the block |
| 228 | | thisNyb = state->m_pattern[((state->m_vgPAT&PATMask)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb]; |
| 229 | | state->m_LASTVRAM = thisNyb; |
| 230 | | block = blockRemain | (thisNyb<<8); |
| 231 | | break; |
| 232 | | case 1: // modify the left nybble only (from the second byte) |
| 233 | | thisNyb = (block&0x00F0)>>4; |
| 234 | | blockRemain = (block&0xFF0F); // save the rest of the block |
| 235 | | thisNyb = state->m_pattern[((state->m_vgPAT&PATMask)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb]; |
| 236 | | state->m_LASTVRAM = thisNyb; |
| 237 | | block = blockRemain | (thisNyb<<4); |
| 238 | | break; |
| 239 | | case 0: // modify the right nybble only (from the second byte) |
| 240 | | thisNyb = (block&0x000F); |
| 241 | | blockRemain = (block&0xFFF0); // save the rest of the block |
| 242 | | thisNyb = state->m_pattern[((state->m_vgPAT&PATMask)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb]; |
| 243 | | state->m_LASTVRAM = thisNyb; |
| 244 | | block = blockRemain | thisNyb; |
| 245 | | break; |
| 246 | | default: // should never EVER get here |
| 247 | | fatalerror("ERROR: VK100 VG attempted to modify the attribute nybble!\n"); |
| 248 | | break; |
| 249 | | } |
| 250 | | // check if the attribute nybble is supposed to be modified, and if so do so |
| 251 | | if (state->m_vgWOPS&0x08) block = (block&0x0FFF)|(((UINT16)state->m_vgWOPS&0xF0)<<8); |
| 252 | | // finally write the block back to ram |
| 253 | | state->m_vram[(EA<<1)+1] = block&0xFF; |
| 254 | | state->m_vram[(EA<<1)] = (block&0xFF00)>>8; |
| 255 | | // HACK: we need the proper direction rom dump for this! |
| 256 | | switch(state->m_vgDIR&0x7) |
| 257 | | { |
| 258 | | case 0: |
| 259 | | state->m_vgX++; |
| 260 | | break; |
| 261 | | case 7: |
| 262 | | state->m_vgX++; |
| 263 | | state->m_vgY++; |
| 264 | | break; |
| 265 | | case 6: |
| 266 | | state->m_vgY++; |
| 267 | | break; |
| 268 | | case 5: |
| 269 | | state->m_vgX--; |
| 270 | | state->m_vgY++; |
| 271 | | break; |
| 272 | | case 4: |
| 273 | | state->m_vgX--; |
| 274 | | break; |
| 275 | | case 3: |
| 276 | | state->m_vgX--; |
| 277 | | state->m_vgY--; |
| 278 | | break; |
| 279 | | case 2: |
| 280 | | state->m_vgY--; |
| 281 | | break; |
| 282 | | case 1: |
| 283 | | state->m_vgX++; |
| 284 | | state->m_vgY--; |
| 285 | | break; |
| 286 | | } |
| 287 | | //printf("VG state: EA: %d, lastvram: %d, curvram: %d, pmulcount: %d |
| 288 | | if (((++state->m_vgPMUL_Count)&0xF)==0) { // if pattern multiplier counter overflowed |
| 289 | | state->m_vgPMUL_Count = state->m_vgPMUL; // reload counter |
| 290 | | state->m_vgPAT_Mask >>= 1; |
| 291 | | if ((state->m_vgPAT_Mask) == 0x00) state->m_GO = 0; // check if the pattern shifter is empty, if so we're done |
| 292 | | } |
| 223 | case 2: // modify the right nybble only (from the first byte) |
| 224 | thisNyb = (block&0x0F00)>>8; |
| 225 | blockRemain = (block&0xF0FF); // save the rest of the block |
| 226 | thisNyb = state->m_pattern[((state->m_vgPAT&PATMask)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb]; |
| 227 | state->m_LASTVRAM = thisNyb; |
| 228 | block = blockRemain | (thisNyb<<8); |
| 229 | break; |
| 230 | case 1: // modify the left nybble only (from the second byte) |
| 231 | thisNyb = (block&0x00F0)>>4; |
| 232 | blockRemain = (block&0xFF0F); // save the rest of the block |
| 233 | thisNyb = state->m_pattern[((state->m_vgPAT&PATMask)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb]; |
| 234 | state->m_LASTVRAM = thisNyb; |
| 235 | block = blockRemain | (thisNyb<<4); |
| 236 | break; |
| 237 | case 0: // modify the right nybble only (from the second byte) |
| 238 | thisNyb = (block&0x000F); |
| 239 | blockRemain = (block&0xFFF0); // save the rest of the block |
| 240 | thisNyb = state->m_pattern[((state->m_vgPAT&PATMask)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb]; |
| 241 | state->m_LASTVRAM = thisNyb; |
| 242 | block = blockRemain | thisNyb; |
| 243 | break; |
| 244 | default: // should never EVER get here |
| 245 | fatalerror("ERROR: VK100 VG attempted to modify the attribute nybble!\n"); |
| 246 | break; |
| 293 | 247 | } |
| 248 | // check if the attribute nybble is supposed to be modified, and if so do so |
| 249 | if (state->m_vgWOPS&0x08) block = (block&0x0FFF)|(((UINT16)state->m_vgWOPS&0xF0)<<8); |
| 250 | // finally write the block back to ram |
| 251 | state->m_vram[(EA<<1)+1] = block&0xFF; |
| 252 | state->m_vram[(EA<<1)] = (block&0xFF00)>>8; |
| 253 | // HACK: we need the proper direction rom dump for this! |
| 254 | switch(state->m_vgDIR&0x7) |
| 255 | { |
| 256 | case 0: |
| 257 | state->m_vgX++; |
| 258 | break; |
| 259 | case 7: |
| 260 | state->m_vgX++; |
| 261 | state->m_vgY++; |
| 262 | break; |
| 263 | case 6: |
| 264 | state->m_vgY++; |
| 265 | break; |
| 266 | case 5: |
| 267 | state->m_vgX--; |
| 268 | state->m_vgY++; |
| 269 | break; |
| 270 | case 4: |
| 271 | state->m_vgX--; |
| 272 | break; |
| 273 | case 3: |
| 274 | state->m_vgX--; |
| 275 | state->m_vgY--; |
| 276 | break; |
| 277 | case 2: |
| 278 | state->m_vgY--; |
| 279 | break; |
| 280 | case 1: |
| 281 | state->m_vgX++; |
| 282 | state->m_vgY--; |
| 283 | break; |
| 284 | } |
| 285 | //printf("VG state: EA: %d, lastvram: %d, curvram: %d, pmulcount: %d |
| 286 | if (((++state->m_vgPMUL_Count)&0xF)==0) { // if pattern multiplier counter overflowed |
| 287 | state->m_vgPMUL_Count = state->m_vgPMUL; // reload counter |
| 288 | state->m_vgPAT_Mask >>= 1; |
| 289 | if ((state->m_vgPAT_Mask) == 0x00) state->m_GO = 0; // check if the pattern shifter is empty, if so we're done |
| 290 | } |
| 291 | if (state->m_GO) machine.scheduler().timer_set(attotime::from_hz(XTAL_45_6192Mhz/3/12/6), FUNC(execute_vg)); // note the 6 is wrong, need to find exact val for this; also varies somewhat by vector type. |
| 294 | 292 | } |
| 295 | 293 | |
| 296 | 294 | /* |