Previous 15994 Revisions Next

r15640 Sunday 22nd July, 2012 at 07:09:53 UTC by Jonathan Gevaryahu
VK100: FINALLY fixed the vector generator. Display looks relatively sane now. Fixed shift and capslock being reversed and added port_toggle to capslock. [Lord Nightmare]
[src/mess/drivers]vk100.c

src/mess/drivers/vk100.c
r15639r15640
9393    X - 0 X X X X (0x30) "
9494
9595*/
96#undef VG_VERBOSE
96// show messages related to writes to the 0x4x VG registers
97#undef VG40_VERBOSE
98// show messages related to writes to the 0x6x VG registers
99#undef VG60_VERBOSE
100// show messages related to LED/beeper writes
97101#undef LED_VERBOSE
102// show messages related to KYBD writes
98103#undef KBD_VERBOSE
104// debug the pattern reg
105#undef PAT_DEBUG
99106
100107#include "emu.h"
101108#include "cpu/i8085/i8085.h"
r15639r15640
129136   UINT8 m_vgERR;
130137   UINT8 m_vgSOPS;
131138   UINT8 m_vgPAT;
132   UINT8 m_vgPAT_Shift; // holds the shifted pattern
139   UINT16 m_vgPAT_Mask; // current mask for PAT but <<1
133140   UINT8 m_vgPMUL; // reload value for pmul_count
134141   UINT8 m_vgPMUL_Count;
135142   UINT8 m_vgDU;
r15639r15640
167174   /* figure out ram address based on tech manual page 5-24:
168175    * real address to 16-bit chunk a13 a12 | a11 a10 a9  a8 | a7  a6  a5  a4 | a3  a2  a1  a0
169176    * X+Y input                    Y8  Y7  | Y6  Y5  Y4  Y3 | Y2  Y1  X9' X8'| X7' X6' X5' X4'
170               X3' and X2' choose a 4-bit block, X1 and X0 choose a bit within that.
177    *          X3' and X2' choose a 4-bit block, X1 and X0 choose a bit within that.
178    * Figure out the ram address in address space "vram" based on this:
179    * vram is 0x8000 long (0x4000 16-bit blocks in sequence)
180    * so:
181    * vram: a14 a13 a12 | a11 a10 a9  a8 | a7  a6  a5  a4 | a3  a2  a1  a0
182    * vg:   Y8  Y7  Y6  | Y5  Y4  Y3  Y2 | Y1  X9' X8' X7'| X6' X5' X4'(x3') x2' x1 x0
183    *     X3' is handled by the nybblenum statement, as is X2'
184    *     X1 and X0 are handled by the pattern rom directly:
185    *     x0 -> a0, x1 -> a1
186    *     this handles bits like:
187    *     x1 x0
188    *      0  0 -> bit 0
189    *      0  1 -> bit 1
190    *      1  0 -> bit 2
191    *      1  1 -> bit 3
192    *
171193    */
172194   vk100_state *state = machine.driver_data<vk100_state>();
173195   while (state->m_GO) // temporary hack to draw the entire vector in one call
174196   {
175      UINT16 XFinal = state->m_trans[(state->m_vgX&0x3FC)>>2]<<2|(state->m_vgX&3); // appears correct
197      // XFinal is (X'&0x3FC)|(X&0x3)
198      UINT16 XFinal = state->m_trans[(state->m_vgX&0x3FC)>>2]<<2|(state->m_vgX&0x3); // appears correct
199      // EA is the effective ram address for a 16-bit block
176200      UINT16 EA = ((state->m_vgY&0x1FE)<<5)|(XFinal>>4); // appears correct
177      //EA indexes a block of 16 bits
201      // block is the 16 bit block directly (note EA has to be <<1 to correctly index a byte)
178202      UINT16 block = state->m_vram[(EA<<1)+1] | (state->m_vram[(EA<<1)]<<8);
179203      // pattern rom addressing is a complex mess. see the pattern rom def later in this file.
180204      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);
205      //printf("EA: %04X, nybblenum: %d X: %04X, X': %04X, Y: %04X\n", EA, nybbleNum, state->m_vgX, XFinal, state->m_vgY);
206      // patmask should be vg_patmask >>1 unless vg_patmask is 0x1 in which case it is 0x80
207      UINT8 PATMask = state->m_vgPAT_Mask >> 1;
208      if (PATMask == 0) PATMask = 0x80;
182209      UINT8 thisNyb = 0;
183210      UINT16 blockRemain = 0;
184211      switch(nybbleNum)
185212      {
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)
213         case 2: // modify the left nybble only (from the first byte)
194214            thisNyb = (block&0x0F00)>>8;
195215            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];
216            thisNyb = state->m_pattern[((state->m_vgPAT&PATMask)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb];
197217            state->m_LASTVRAM = thisNyb;
198218            block = blockRemain | (thisNyb<<8);
199219            break;
200         case 2: // modify the left nybble of the second byte
220         case 1: // modify the right nybble only (from the first byte)
201221            thisNyb = (block&0x00F0)>>4;
202222            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];
223            thisNyb = state->m_pattern[((state->m_vgPAT&PATMask)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb];
204224            state->m_LASTVRAM = thisNyb;
205225            block = blockRemain | (thisNyb<<4);
206226            break;
227         case 0: // modify the left nybble of the second byte
228            thisNyb = (block&0x000F);
229            blockRemain = (block&0xFFF0); // save the rest of the block
230            thisNyb = state->m_pattern[((state->m_vgPAT&PATMask)?0x200:0)|((state->m_vgWOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb];
231            state->m_LASTVRAM = thisNyb;
232            block = blockRemain | thisNyb;
233            break;
207234         default: // should never EVER get here
208            printf("ERROR: attempted to modify the attribute nybble!\n");
235            fatalerror("ERROR: VK100 VG attempted to modify the attribute nybble!\n");
209236            break;
210237      }
211238      // 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);
239      if (state->m_vgWOPS&0x08) block = (block&0x0FFF)|(((UINT16)state->m_vgWOPS&0xF0)<<8);
213240      // finally write the block back to ram
214241      state->m_vram[(EA<<1)+1] = block&0xFF;
215242      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!`
243      state->m_vgX++;// TODO: since the direction rom is missing; the vector generator direction is FIXED rightward!
244      //state->m_vgY++;// hack to mix stuff up a little
217245      //printf("VG state: EA: %d, lastvram: %d, curvram: %d, pmulcount: %d
218      if (((++state->m_vgPMUL_Count)&0xF)==0) {
246      if (((++state->m_vgPMUL_Count)&0xF)==0) { // if pattern multiplier counter overflowed
219247         state->m_vgPMUL_Count = state->m_vgPMUL; // reload counter
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;
222      }
248         state->m_vgPAT_Mask >>= 1;
249         if ((state->m_vgPAT_Mask) == 0x00) state->m_GO = 0; // check if the pattern shifter is empty, if so we're done
250         }
223251   }
224252}
225253
r15639r15640
234262{
235263   m_vgX &= 0xFF << ((1-offset)*8);
236264   m_vgX |= ((UINT16)data) << (offset*8);
237#ifdef VG_VERBOSE
265#ifdef VG40_VERBOSE
238266   logerror("VG: 0x%02X: X Reg loaded with %04X, new X value is %04X\n", 0x40+offset, ((UINT16)data) << (offset*8), m_vgX);
239267#endif
240268}
r15639r15640
244272{
245273   m_vgY &= 0xFF << ((1-offset)*8);
246274   m_vgY |= ((UINT16)data) << (offset*8);
247#ifdef VG_VERBOSE
275#ifdef VG40_VERBOSE
248276   logerror("VG: 0x%02X: Y Reg loaded with %04X, new Y value is %04X\n", 0x42+offset, ((UINT16)data) << (offset*8), m_vgY);
249277#endif
250278}
r15639r15640
253281WRITE8_MEMBER(vk100_state::vgERR)
254282{
255283   m_vgERR = data;
256#ifdef VG_VERBOSE
284#ifdef VG40_VERBOSE
257285   logerror("VG: 0x44: ERR Reg loaded with %02X\n", m_vgERR);
258286#endif
259287}
r15639r15640
267295WRITE8_MEMBER(vk100_state::vgSOPS)
268296{
269297   m_vgSOPS = data;
270//#ifdef VG_VERBOSE
298#ifdef VG40_VERBOSE
271299   logerror("VG: 0x45: SOPS Reg loaded with %02X: Blink: %d, Background GRB: %d%d%d, Serial select: %x, Reverse BG/FG: %d\n", m_vgSOPS, (m_vgSOPS>>7)&1, (m_vgSOPS>>6)&1, (m_vgSOPS>>5)&1, (m_vgSOPS>>4)&1, (m_vgSOPS>>1)&7, m_vgSOPS&1);
272//#endif
300#endif
273301}
274302
275303/* port 0x46: "PAT" load vg Pattern register */
276304WRITE8_MEMBER(vk100_state::vgPAT)
277305{
278306   m_vgPAT = data;
279#ifdef VG_VERBOSE
307#ifdef PAT_DEBUG
308   for (int i = 7; i >= 0; i--)
309   {
310      printf("%s", (data&(1<<i))?"X":".");
311   }
312   printf("\n");
313#endif
314#ifdef VG40_VERBOSE
280315   logerror("VG: 0x46: PAT Reg loaded with %02X\n", m_vgPAT);
281316#endif
282317}
r15639r15640
289324WRITE8_MEMBER(vk100_state::vgPMUL)
290325{
291326   m_vgPMUL = data;
292#ifdef VG_VERBOSE
327#ifdef VG40_VERBOSE
293328   logerror("VG: 0x47: PMUL Reg loaded with %02X\n", m_vgPMUL);
294329#endif
295330}
r15639r15640
298333WRITE8_MEMBER(vk100_state::vgDU)
299334{
300335   m_vgDU = data;
301#ifdef VG_VERBOSE
336#ifdef VG60_VERBOSE
302337   logerror("VG: 0x60: DU Reg loaded with %02X\n", m_vgDU);
303338#endif
304339}
r15639r15640
307342WRITE8_MEMBER(vk100_state::vgDVM)
308343{
309344   m_vgDVM = data;
310#ifdef VG_VERBOSE
345#ifdef VG60_VERBOSE
311346   logerror("VG: 0x61: DVM Reg loaded with %02X\n", m_vgDVM);
312347#endif
313348}
r15639r15640
316351WRITE8_MEMBER(vk100_state::vgDIR)
317352{
318353   m_vgDIR = data;
319#ifdef VG_VERBOSE
354#ifdef VG60_VERBOSE
320355   logerror("VG: 0x62: DIR Reg loaded with %02X\n", m_vgDIR);
321356#endif
322357}
r15639r15640
330365WRITE8_MEMBER(vk100_state::vgWOPS)
331366{
332367   m_vgWOPS = data;
333#ifdef VG_VERBOSE
368#ifdef VG60_VERBOSE
334369   static const char *const functions[] = { "Overlay", "Replace", "Complement", "Erase" };
335370   logerror("VG: 0x64: WOPS Reg loaded with %02X: KGRB %d%d%d%d, AttrChange %d, Function %s, Negate %d\n", data, (m_vgWOPS>>7)&1, (m_vgWOPS>>6)&1, (m_vgWOPS>>5)&1, (m_vgWOPS>>4)&1, (m_vgWOPS>>3)&1, functions[(m_vgWOPS>>1)&3], m_vgWOPS&1);
336371#endif
r15639r15640
339374/* port 0x64: "EX MOV" execute a move (start the state machine) */
340375WRITE8_MEMBER(vk100_state::vgEX_MOV)
341376{
342#ifdef VG_VERBOSE
377#ifdef VG60_VERBOSE
343378   logerror("VG Execute Move 0x64 written: stub!\n");
344379#endif
345380   // TODO: short term: do some calculations here and print the expected starting ram address etc
346381   // TODO: long term: fire a timer and actually move the ram with correct timing
347382   m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count
348   m_vgPAT_Shift = 1; // load vgPAT_Shift
383   m_vgPAT_Mask = 0x100;
349384   m_EX_TYPE = 0;
350385   m_GO = 1;
351386   machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg));
r15639r15640
354389/* port 0x65: "EX DOT" execute a dot (start the state machine) */
355390WRITE8_MEMBER(vk100_state::vgEX_DOT)
356391{
357#ifdef VG_VERBOSE
392#ifdef VG60_VERBOSE
358393   logerror("VG: 0x65: Execute Dot written: stub!\n");
359394#endif
360395   // TODO: short term: do some calculations here and print the expected starting ram address etc
361396   // TODO: long term: fire a timer and actually draw the dot to ram with correct timing
362397   m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count
363   m_vgPAT_Shift = 1; // load vgPAT_Shift
398   m_vgPAT_Mask = 0x100; // load vgPAT_Mask
364399   m_EX_TYPE = 1;
365400   m_GO = 1;
366401   machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg));
r15639r15640
369404/* port 0x66: "EX VEC" execute a pattern (8 fixed direction) vector (start the state machine) */
370405WRITE8_MEMBER(vk100_state::vgEX_VEC)
371406{
372#ifdef VG_VERBOSE
407#ifdef VG60_VERBOSE
373408   logerror("VG: 0x66: Execute Vector written: stub!\n");
374409#endif
375410   // TODO: short term: do some calculations here and print the expected starting ram address etc
376411   // TODO: long term: fire a timer and actually draw the vector to ram with correct timing
377412   m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count
378   m_vgPAT_Shift = 1; // load vgPAT_Shift
413   m_vgPAT_Mask = 0x100; // load vgPAT_Mask
379414   m_EX_TYPE = 2;
380415   m_GO = 1;
381416   machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg));
r15639r15640
384419/* port 0x67: "EX ER" execute an arbitrary bresenham vector (start the state machine) */
385420WRITE8_MEMBER(vk100_state::vgEX_ER)
386421{
387#ifdef VG_VERBOSE
422#ifdef VG60_VERBOSE
388423   logerror("VG: 0x67: Execute Arbitrary 'error' vector written: stub!\n");
389424#endif
390425   // TODO: short term: do some calculations here and print the expected starting ram address etc
391426   // TODO: long term: fire a timer and actually use the state machine to draw the vector to ram with correct timing
392427   m_vgPMUL_Count = m_vgPMUL; // load PMUL_Count
393   m_vgPAT_Shift = 1; // load vgPAT_Shift
428   m_vgPAT_Mask = 0x100; // load vgPAT_Mask
394429   m_EX_TYPE = 3;
395430   m_GO = 1;
396431   machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg));
r15639r15640
406441   output_set_value("hardcopy_led", BIT(data, 2) ? 1 : 0);
407442   output_set_value("l1_led", BIT(data, 1) ? 1 : 0);
408443   output_set_value("l2_led", BIT(data, 0) ? 1 : 0);
444#ifdef LED_VERBOSE
409445   if (BIT(data, 6)) logerror("kb keyclick bit 6 set: not emulated yet (multivibrator)!\n");
446#endif
410447   beep_set_state( m_speaker, BIT(data, 7));
411448#ifdef LED_VERBOSE
412449   logerror("LED state: %02X: %s %s %s %s %s %s\n", data&0xFF, (data&0x20)?"------- LOCAL ":"ON LINE ----- ", (data&0x10)?"--------- ":"NO SCROLL ", (data&0x8)?"----- ":"BASIC ", (data&0x4)?"--------- ":"HARD-COPY ", (data&0x2)?"-- ":"L1 ", (data&0x1)?"-- ":"L2 ");
r15639r15640
529566
530567   PORT_START("CAPSSHIFT") // CAPS LOCK and SHIFT appear as the high 2 bits on all rows
531568      PORT_BIT(0x3f, IP_ACTIVE_HIGH, IPT_UNUSED)
532      PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Caps lock") PORT_CODE(KEYCODE_CAPSLOCK)
533      PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT)
534   PORT_START("COL0")
569      PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT)
570      PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_TOGGLE PORT_NAME("Caps lock") PORT_CODE(KEYCODE_CAPSLOCK)
571      PORT_START("COL0")
535572      PORT_BIT(0x1f, IP_ACTIVE_LOW, IPT_UNUSED)
536573      PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_UNUSED) // row 0 bit 6 is always low, checked by keyboard test
537574      PORT_BIT(0xc0, IP_ACTIVE_HIGH, IPT_UNUSED) // all rows have these bits left low to save a mask op later
r15639r15640
673710   state->m_vgERR = 0;
674711   state->m_vgSOPS = 0;
675712   state->m_vgPAT = 0;
676   state->m_vgPAT_Shift = 0x80;
713   state->m_vgPAT_Mask = 0x80;
677714   state->m_vgPMUL = 0;
678715   state->m_vgPMUL_Count = 0;
679716   state->m_vgDU = 0;
r15639r15640
689726static DRIVER_INIT( vk100 )
690727{
691728   UINT8 *gfx = machine.root_device().memregion("vram")->base();
692   // for debug purposes, set the entire screen to black but with the attributes of all pixels set to white
693   for (int i = 1; i < 0x8000; i+=2)
694      gfx[i] = 0xF;
729   // for debug purposes, set the entire screen to a hash pattern
730   for (int i = 0; i < 0x8000; i+=2)
731   {
732      gfx[i] = 0xFA;
733      gfx[i+1] = 0xAA;
695734      //gfx[i] = (((i&0x1)?0x00:0xFF)^((i&0x100)?0x00:0xff));
735   }
696736}
697737
698738static PALETTE_INIT( vk100 )
r15639r15640
732772
733773static MC6845_UPDATE_ROW( vk100_update_row )
734774{
735   static const UINT32 colorTable[8] = { 0x000000, 0x0000FF, 0xFF0000, 0xFF00FF, 0x00FF00, 0x00FFFF, 0xFFFF00, 0xFFFFFF };
775   static const UINT32 colorTable[16] = {
776   0x000000, 0x0000FF, 0xFF0000, 0xFF00FF, 0x00FF00, 0x00FFFF, 0xFFFF00, 0xFFFFFF,
777   0x000000, 0x0000FF, 0xFF0000, 0xFF00FF, 0x00FF00, 0x00FFFF, 0xFFFF00, 0xFFFFFF };
736778   //printf("y=%d, ma=%04x, ra=%02x, x_count=%02x ", y, ma, ra, x_count);
737779   /* figure out ram address based on tech manual page 5-23:
738780    * real address to 16-bit chunk a13  a12  a11 a10 a9  a8  a7  a6  a5  a4  a3  a2  a1  a0
r15639r15640
741783   vk100_state *state = device->machine().driver_data<vk100_state>();
742784   //UINT8 *gfx = device->machine.root_device().memregion("vram")->base();
743785   UINT16 EA = ((ma&0xfc0)<<2)|((ra&0x3)<<6)|(ma&0x3F);
744   EA <<= 1; // this is needed to address the whole 0000-7fff area since we deal with 16 bit blocks
745   //printf("EA: %04X\n", EA);
746786   // display the 64 different 12-bit-wide chunks
747787   for (int i = 0; i < 64; i++)
748788   {
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;
751      // TODO: blink is NOT HANDLED YET!; is this done by using the cursor output of the CRTC somehow?
752      //UINT8 blink = block&0x8;
753      UINT8 bgColor = (state->m_vgSOPS&0x70)>>4;
789      UINT16 block = state->m_vram[(EA<<1)+(2*i)+1] | (state->m_vram[(EA<<1)+(2*i)]<<8); // store big endian
790      UINT8 fgColor = (block&0xF000)>>12;
791      // TODO: blink is NOT HANDLED YET!
792      UINT8 bgColor = (state->m_vgSOPS&0xF0)>>4;
754793      // display a 12-bit wide chunk
755794      for (int j = 0; j < 12; j++)
756795      {
757         bitmap.pix32(y, (12*i)+j) = ((block&(0x8000>>j))^(state->m_vgSOPS&1))?colorTable[fgColor]:colorTable[bgColor];
796         bitmap.pix32(y, (12*i)+j) = ((block&(0x0001<<j))^(state->m_vgSOPS&1))?colorTable[fgColor]:colorTable[bgColor];
758797      }
759798   }
760799}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team