Previous 15994 Revisions Next

r15638 Friday 20th July, 2012 at 23:23:56 UTC by Jonathan Gevaryahu
VK100: further improvements to the vector generator, still not completely correct. [Lord Nightmare]
[src/mess/drivers]vk100.c

src/mess/drivers/vk100.c
r15637r15638
77
88        Todo:
99              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
1111              * note that since two proms aren't dumped yet some stuff will have to be HLE'd for now
1212              hook up baud generator to i8251 rx and tx clocks
1313
r15637r15638
165165static TIMER_CALLBACK( execute_vg )
166166{
167167   /* 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'
170170               X3' and X2' choose a 4-bit block, X1 and X0 choose a bit within that.
171171    */
172172   vk100_state *state = machine.driver_data<vk100_state>();
173173   while (state->m_GO) // temporary hack to draw the entire vector in one call
174174   {
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);
179179      // 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;
188210      }
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!`
199217      //printf("VG state: EA: %d, lastvram: %d, curvram: %d, pmulcount: %d
200218      if (((++state->m_vgPMUL_Count)&0xF)==0) {
201219         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;
204222      }
205223   }
206224}
r15637r15638
327345   // TODO: short term: do some calculations here and print the expected starting ram address etc
328346   // TODO: long term: fire a timer and actually move the ram with correct timing
329347   m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count
330   m_vgPAT_Shift = 0x80; // load vgPAT_Shift
348   m_vgPAT_Shift = 1; // load vgPAT_Shift
331349   m_EX_TYPE = 0;
332350   m_GO = 1;
333351   machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg));
r15637r15638
342360   // TODO: short term: do some calculations here and print the expected starting ram address etc
343361   // TODO: long term: fire a timer and actually draw the dot to ram with correct timing
344362   m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count
345   m_vgPAT_Shift = 0x80; // load vgPAT_Shift
363   m_vgPAT_Shift = 1; // load vgPAT_Shift
346364   m_EX_TYPE = 1;
347365   m_GO = 1;
348366   machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg));
r15637r15638
357375   // TODO: short term: do some calculations here and print the expected starting ram address etc
358376   // TODO: long term: fire a timer and actually draw the vector to ram with correct timing
359377   m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count
360   m_vgPAT_Shift = 0x80; // load vgPAT_Shift
378   m_vgPAT_Shift = 1; // load vgPAT_Shift
361379   m_EX_TYPE = 2;
362380   m_GO = 1;
363381   machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg));
r15637r15638
372390   // TODO: short term: do some calculations here and print the expected starting ram address etc
373391   // TODO: long term: fire a timer and actually use the state machine to draw the vector to ram with correct timing
374392   m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count
375   m_vgPAT_Shift = 0x80; // load vgPAT_Shift
393   m_vgPAT_Shift = 1; // load vgPAT_Shift
376394   m_EX_TYPE = 3;
377395   m_GO = 1;
378396   machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg));
r15637r15638
728746   // display the 64 different 12-bit-wide chunks
729747   for (int i = 0; i < 64; i++)
730748   {
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;
733751      // 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;
735753      UINT8 bgColor = (state->m_vgSOPS&0x70)>>4;
736754      // display a 12-bit wide chunk
737755      for (int j = 0; j < 12; j++)
738756      {
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];
740758      }
741759   }
742760}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team