src/mess/drivers/vk100.c
| r15637 | r15638 | |
| 7 | 7 | |
| 8 | 8 | Todo: |
| 9 | 9 | handle blink attribute in the vram display renderer |
| 10 | | emulate vector generator hardware enough to write stuff to vram |
| 10 | fix vector generator hardware enough to write stuff to vram LEGIBLY |
| 11 | 11 | * note that since two proms aren't dumped yet some stuff will have to be HLE'd for now |
| 12 | 12 | hook up baud generator to i8251 rx and tx clocks |
| 13 | 13 | |
| r15637 | r15638 | |
| 165 | 165 | static TIMER_CALLBACK( execute_vg ) |
| 166 | 166 | { |
| 167 | 167 | /* figure out ram address based on tech manual page 5-24: |
| 168 | | * real address to 16-bit chunk a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 |
| 169 | | * X+Y input Y8 Y7 Y6 Y5 Y4 Y3 Y2 Y1 X9' X8' X7' X6' X5' X4' |
| 168 | * real address to 16-bit chunk a13 a12 | a11 a10 a9 a8 | a7 a6 a5 a4 | a3 a2 a1 a0 |
| 169 | * X+Y input Y8 Y7 | Y6 Y5 Y4 Y3 | Y2 Y1 X9' X8'| X7' X6' X5' X4' |
| 170 | 170 | X3' and X2' choose a 4-bit block, X1 and X0 choose a bit within that. |
| 171 | 171 | */ |
| 172 | 172 | vk100_state *state = machine.driver_data<vk100_state>(); |
| 173 | 173 | while (state->m_GO) // temporary hack to draw the entire vector in one call |
| 174 | 174 | { |
| 175 | | UINT16 X_prime = state->m_trans[state->m_vgX>>2]<<2; |
| 176 | | UINT16 EA = (state->m_vgY&0x1FE)<<5|(X_prime>>4); |
| 177 | | EA <<= 1; |
| 178 | | //UINT16 block = state->m_vram[(EA+(2*i))+1] | (state->m_vram[(EA+(2*i))]<<8); |
| 175 | UINT16 XFinal = state->m_trans[(state->m_vgX&0x3FC)>>2]<<2|(state->m_vgX&3); // appears correct |
| 176 | UINT16 EA = ((state->m_vgY&0x1FE)<<5)|(XFinal>>4); // appears correct |
| 177 | //EA indexes a block of 16 bits |
| 178 | UINT16 block = state->m_vram[(EA<<1)+1] | (state->m_vram[(EA<<1)]<<8); |
| 179 | 179 | // pattern rom addressing is a complex mess. see the pattern rom def later in this file. |
| 180 | | if (!(X_prime&0x4)) |
| 181 | | { // modify the left nybble only |
| 182 | | UINT8 tempnyb = (state->m_vram[EA+((X_prime&0x8)>>3)]&0xF0)>>4; |
| 183 | | state->m_LASTVRAM = tempnyb; |
| 184 | | UINT8 othernyb = (state->m_vram[EA+((X_prime&0x8)>>3)]&0x0F); |
| 185 | | tempnyb = state->m_pattern[((state->m_vgPAT&state->m_vgPAT_Shift)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|state->m_LASTVRAM]; |
| 186 | | tempnyb <<= 4; |
| 187 | | state->m_vram[EA+((X_prime&0x8)>>3)] = tempnyb | othernyb; |
| 180 | UINT8 nybbleNum = (XFinal&0xC)>>2; // which of the four nybbles within the block to address. should NEVER be 3! |
| 181 | printf("EA: %04X, nybblenum: %d X: %04X, X': %04X, Y: %04X\n", EA, nybbleNum, state->m_vgX, XFinal, state->m_vgY); |
| 182 | UINT8 thisNyb = 0; |
| 183 | UINT16 blockRemain = 0; |
| 184 | switch(nybbleNum) |
| 185 | { |
| 186 | case 0: // modify the left nybble only (from the first byte) |
| 187 | thisNyb = (block&0xF000)>>12; |
| 188 | blockRemain = (block&0x0FFF); // save the rest of the block |
| 189 | thisNyb = state->m_pattern[((state->m_vgPAT&state->m_vgPAT_Shift)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb]; |
| 190 | state->m_LASTVRAM = thisNyb; |
| 191 | block = blockRemain | (thisNyb<<12); |
| 192 | break; |
| 193 | case 1: // modify the right nybble only (from the first byte) |
| 194 | thisNyb = (block&0x0F00)>>8; |
| 195 | blockRemain = (block&0xF0FF); // save the rest of the block |
| 196 | thisNyb = state->m_pattern[((state->m_vgPAT&state->m_vgPAT_Shift)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb]; |
| 197 | state->m_LASTVRAM = thisNyb; |
| 198 | block = blockRemain | (thisNyb<<8); |
| 199 | break; |
| 200 | case 2: // modify the left nybble of the second byte |
| 201 | thisNyb = (block&0x00F0)>>4; |
| 202 | blockRemain = (block&0xFF0F); // save the rest of the block |
| 203 | thisNyb = state->m_pattern[((state->m_vgPAT&state->m_vgPAT_Shift)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb]; |
| 204 | state->m_LASTVRAM = thisNyb; |
| 205 | block = blockRemain | (thisNyb<<4); |
| 206 | break; |
| 207 | default: // should never EVER get here |
| 208 | printf("ERROR: attempted to modify the attribute nybble!\n"); |
| 209 | break; |
| 188 | 210 | } |
| 189 | | else |
| 190 | | { // modify the right nybble only |
| 191 | | UINT8 tempnyb = (state->m_vram[EA+((X_prime&0x8)>>3)]&0x0F); |
| 192 | | state->m_LASTVRAM = tempnyb; |
| 193 | | UINT8 othernyb = (state->m_vram[EA+((X_prime&0x8)>>3)]&0xF0); |
| 194 | | tempnyb = state->m_pattern[((state->m_vgPAT&state->m_vgPAT_Shift)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|state->m_LASTVRAM]; |
| 195 | | state->m_vram[EA+((X_prime&0x8)>>3)] = tempnyb | othernyb; |
| 196 | | } |
| 197 | | if (state->m_vgWOPS&0x08) state->m_vram[EA+1] = (state->m_vgWOPS&0xF0)>>4; |
| 198 | | state->m_vgX++;// TODO: since the direction rom is missing; the vector generator direction is FIXED rightward! |
| 211 | // check if the attribute nybble is supposed to be modified, and if so do so |
| 212 | if (state->m_vgWOPS&0x08) block = (block&0xFFF0)|((state->m_vgWOPS&0xF0)>>4); |
| 213 | // finally write the block back to ram |
| 214 | state->m_vram[(EA<<1)+1] = block&0xFF; |
| 215 | state->m_vram[(EA<<1)] = (block&0xFF00)>>8; |
| 216 | state->m_vgX++;// TODO: since the direction rom is missing; the vector generator direction is FIXED rightward!` |
| 199 | 217 | //printf("VG state: EA: %d, lastvram: %d, curvram: %d, pmulcount: %d |
| 200 | 218 | if (((++state->m_vgPMUL_Count)&0xF)==0) { |
| 201 | 219 | state->m_vgPMUL_Count = state->m_vgPMUL; // reload counter |
| 202 | | if (state->m_vgPAT_Shift == 0x01) state->m_GO = 0; // check if the pattern shifter is empty, if so we're done |
| 203 | | state->m_vgPAT_Shift >>= 1; |
| 220 | if (state->m_vgPAT_Shift == 0x80) state->m_GO = 0; // check if the pattern shifter is empty, if so we're done |
| 221 | state->m_vgPAT_Shift <<= 1; |
| 204 | 222 | } |
| 205 | 223 | } |
| 206 | 224 | } |
| r15637 | r15638 | |
| 327 | 345 | // TODO: short term: do some calculations here and print the expected starting ram address etc |
| 328 | 346 | // TODO: long term: fire a timer and actually move the ram with correct timing |
| 329 | 347 | m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count |
| 330 | | m_vgPAT_Shift = 0x80; // load vgPAT_Shift |
| 348 | m_vgPAT_Shift = 1; // load vgPAT_Shift |
| 331 | 349 | m_EX_TYPE = 0; |
| 332 | 350 | m_GO = 1; |
| 333 | 351 | machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg)); |
| r15637 | r15638 | |
| 342 | 360 | // TODO: short term: do some calculations here and print the expected starting ram address etc |
| 343 | 361 | // TODO: long term: fire a timer and actually draw the dot to ram with correct timing |
| 344 | 362 | m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count |
| 345 | | m_vgPAT_Shift = 0x80; // load vgPAT_Shift |
| 363 | m_vgPAT_Shift = 1; // load vgPAT_Shift |
| 346 | 364 | m_EX_TYPE = 1; |
| 347 | 365 | m_GO = 1; |
| 348 | 366 | machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg)); |
| r15637 | r15638 | |
| 357 | 375 | // TODO: short term: do some calculations here and print the expected starting ram address etc |
| 358 | 376 | // TODO: long term: fire a timer and actually draw the vector to ram with correct timing |
| 359 | 377 | m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count |
| 360 | | m_vgPAT_Shift = 0x80; // load vgPAT_Shift |
| 378 | m_vgPAT_Shift = 1; // load vgPAT_Shift |
| 361 | 379 | m_EX_TYPE = 2; |
| 362 | 380 | m_GO = 1; |
| 363 | 381 | machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg)); |
| r15637 | r15638 | |
| 372 | 390 | // TODO: short term: do some calculations here and print the expected starting ram address etc |
| 373 | 391 | // TODO: long term: fire a timer and actually use the state machine to draw the vector to ram with correct timing |
| 374 | 392 | m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count |
| 375 | | m_vgPAT_Shift = 0x80; // load vgPAT_Shift |
| 393 | m_vgPAT_Shift = 1; // load vgPAT_Shift |
| 376 | 394 | m_EX_TYPE = 3; |
| 377 | 395 | m_GO = 1; |
| 378 | 396 | machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg)); |
| r15637 | r15638 | |
| 728 | 746 | // display the 64 different 12-bit-wide chunks |
| 729 | 747 | for (int i = 0; i < 64; i++) |
| 730 | 748 | { |
| 731 | | UINT16 block = state->m_vram[(EA+(2*i))+1] | (state->m_vram[(EA+(2*i))]<<8); |
| 732 | | UINT8 fgColor = block&7; |
| 749 | UINT16 block = state->m_vram[(EA+(2*i))+1] | (state->m_vram[(EA+(2*i))]<<8); // store big endian |
| 750 | UINT8 fgColor = block&0x7; |
| 733 | 751 | // TODO: blink is NOT HANDLED YET!; is this done by using the cursor output of the CRTC somehow? |
| 734 | | //UINT8 blink = (block&8)>>3; |
| 752 | //UINT8 blink = block&0x8; |
| 735 | 753 | UINT8 bgColor = (state->m_vgSOPS&0x70)>>4; |
| 736 | 754 | // display a 12-bit wide chunk |
| 737 | 755 | for (int j = 0; j < 12; j++) |
| 738 | 756 | { |
| 739 | | bitmap.pix32(y, (12*i)+j) = ((block&(0x10<<j))^(state->m_vgSOPS&1))?colorTable[fgColor]:colorTable[bgColor]; |
| 757 | bitmap.pix32(y, (12*i)+j) = ((block&(0x8000>>j))^(state->m_vgSOPS&1))?colorTable[fgColor]:colorTable[bgColor]; |
| 740 | 758 | } |
| 741 | 759 | } |
| 742 | 760 | } |