Previous 199869 Revisions Next

r18101 Sunday 23rd September, 2012 at 21:22:50 UTC by Couriersud
Fix for MT5018. [Couriersud]
Also improves blue background levels and gradient for Radar Scope.
[src/mame/drivers]dkong.c
[src/mame/includes]dkong.h
[src/mame/video]dkong.c

trunk/src/mame/includes/dkong.h
r18100r18101
5757
5858enum
5959{
60   DKONG_RADARSCP_CONVERSION = 0,
61   DKONG_BOARD = 1
62};
63
64enum
65{
6066   DK2650_HERBIEDK = 0,
6167   DK2650_HUNCHBKD,
6268   DK2650_EIGHTACT,
r18100r18101
7581   dkong_state(const machine_config &mconfig, device_type type, const char *tag)
7682      : driver_device(mconfig, type, tag),
7783      m_video_ram(*this,"video_ram"),
78      m_sprite_ram(*this,"sprite_ram") { }
84      m_sprite_ram(*this,"sprite_ram"),
85      m_vidhw(DKONG_BOARD) { }
7986
8087   /* memory pointers */
8188   required_shared_ptr<UINT8> m_video_ram;
r18100r18101
8794   device_t *m_dev_vp2;      /* virtual port 2 */
8895   device_t *m_dev_6h;
8996
90#if 0
9197   /* machine states */
92   UINT8   m_hardware_type;
93
94   /* sound state */
95   const UINT8 *         m_snd_rom;
96
97   /* video state */
98   tilemap_t *m_bg_tilemap;
99
100   bitmap_ind16 m_bg_bits;
101   const UINT8 *   m_color_codes;
102   emu_timer *      m_scanline_timer;
103   INT8         m_vidhw;         /* Selected video hardware RS Conversion / TKG04 */
104
105   /* radar scope */
106
107   UINT8 *         m_gfx4;
108   UINT8 *         m_gfx3;
109   int            m_gfx3_len;
110
111   UINT8   m_sig30Hz;
112   UINT8   m_grid_sig;
113   UINT8   m_rflip_sig;
114   UINT8   m_star_ff;
115   UINT8   m_blue_level;
116   double   m_cd4049_a;
117   double   m_cd4049_b;
118
119   /* Specific states */
120   INT8 m_decrypt_counter;
121
122   /* 2650 protection */
123   UINT8 m_protect_type;
124   UINT8 m_hunchloopback;
125   UINT8 m_prot_cnt;
126   UINT8 m_main_fo;
127
128   /* Save state relevant */
129   UINT8   m_gfx_bank;
130   UINT8   m_palette_bank;
131   UINT8   m_grid_on;
132   UINT16   m_grid_col;
133   UINT8   m_sprite_bank;
134   UINT8   m_dma_latch;
135   UINT8   m_flip;
136
137   /* reverse address lookup map - hunchbkd */
138   INT16 m_rev_map[0x200];
139#endif
140   /* machine states */
14198   UINT8               m_hardware_type;
14299   UINT8            m_nmi_mask;
143100
r18100r18101
159116   int               m_gfx3_len;
160117
161118   UINT8             m_sig30Hz;
119   UINT8           m_lfsr_5I;
162120   UINT8             m_grid_sig;
163121   UINT8             m_rflip_sig;
164122   UINT8             m_star_ff;
r18100r18101
192150   double m_vg3;
193151   double m_cv3;
194152   double m_cv4;
153   double m_vc17;
195154   int m_pixelcnt;
196155
197156   /* radarscp_scanline */
trunk/src/mame/video/dkong.c
r18100r18101
119119    darlington. The blue channel has a pulldown resistor (R8, 0M15) as well.
120120*/
121121
122
123#define TRS_J1   (1)         // (1) = Closed (0) = Open
124
125
122126static const res_net_info radarscp_net_info =
123127{
124128   RES_NET_VCC_5V | RES_NET_VBIAS_TTL | RES_NET_VIN_MB7052 |  RES_NET_MONITOR_SANYO_EZV20,
125129   {
126      { RES_NET_AMP_DARLINGTON, 470,      0, 3, { 1000, 470, 220 } },
127      { RES_NET_AMP_DARLINGTON, 470,      0, 3, { 1000, 470, 220 } },
128      { RES_NET_AMP_DARLINGTON, 680, 150000, 2, {  470, 220,   0 } }    /*  radarscp */
130      { RES_NET_AMP_DARLINGTON, 470 * TRS_J1, 470*(1-TRS_J1), 3, { 1000, 470, 220 } },
131      { RES_NET_AMP_DARLINGTON, 470 * TRS_J1, 470*(1-TRS_J1), 3, { 1000, 470, 220 } },
132      { RES_NET_AMP_EMITTER,      680 * TRS_J1, 680*(1-TRS_J1), 2, {  470, 220,   0 } }    /*  radarscp */
129133   }
130134};
131135
r18100r18101
133137{
134138   RES_NET_VCC_5V | RES_NET_VBIAS_TTL | RES_NET_VIN_MB7052 |  RES_NET_MONITOR_SANYO_EZV20,
135139   {
136      { RES_NET_AMP_DARLINGTON, 470,      0, 0, { 0 } },
137      { RES_NET_AMP_DARLINGTON, 470,      0, 0, { 0 } },
138      { RES_NET_AMP_DARLINGTON, 680, 150000, 0, { 0 } }    /*  radarscp */
140      { RES_NET_AMP_DARLINGTON, 470, 4700, 0, { 0 } },
141      { RES_NET_AMP_DARLINGTON, 470, 4700, 0, { 0 } },
142      { RES_NET_AMP_EMITTER,      470, 4700, 0, { 0 } }    /*  radarscp */
139143   }
140144};
141145
r18100r18101
153157   {
154158      { RES_NET_AMP_DARLINGTON, 0,      0, 4, { 39000, 20000, 10000, 4990 } },
155159      { RES_NET_AMP_DARLINGTON, 0,      0, 4, { 39000, 20000, 10000, 4990 } },
156      { RES_NET_AMP_DARLINGTON, 0,      0, 4, { 39000, 20000, 10000, 4990 } }
160      { RES_NET_AMP_EMITTER,    0,      0, 4, { 39000, 20000, 10000, 4990 } }
157161   }
158162};
159163
r18100r18101
165169   {
166170      { RES_NET_AMP_DARLINGTON, 4700, 470, 0, { 0 } },
167171      { RES_NET_AMP_DARLINGTON,    1,   0, 0, { 0 } },   /*  dummy */
168      { RES_NET_AMP_DARLINGTON,    1,   0, 0, { 0 } },   /*  dummy */
172      { RES_NET_AMP_EMITTER,       1,   0, 0, { 0 } },   /*  dummy */
169173   }
170174};
171175
r18100r18101
177181   {
178182      { RES_NET_AMP_DARLINGTON,  470, 4700, 0, { 0 } },   /*  bias/gnd exist in schematics, readable in TKG3 schematics */
179183      { RES_NET_AMP_DARLINGTON,  470, 4700, 0, { 0 } },   /*  bias/gnd exist in schematics, readable in TKG3 schematics */
180      { RES_NET_AMP_DARLINGTON,    0,    0, 8, { 128,64,32,16,8,4,2,1 } },   /*  dummy */
184      { RES_NET_AMP_EMITTER,       0,    0, 8, { 128,64,32,16,8,4,2,1 } },   /*  dummy */
181185   }
182186};
183187
r18100r18101
189193   {
190194      { RES_NET_AMP_DARLINGTON,    0,   0, 1, { 1 } },   /*  dummy */
191195      { RES_NET_AMP_DARLINGTON,    0,   0, 1, { 1 } },   /*  dummy */
192      { RES_NET_AMP_DARLINGTON,    0,   0, 1, { 1 } },   /*  dummy */
196      { RES_NET_AMP_EMITTER,       0,   0, 1, { 1 } },   /*  dummy */
193197   }
194198};
195199
r18100r18101
291295   /* Now treat tri-state black background generation */
292296
293297   for (i=0;i<256;i++)
294      if ( (i & 0x03) == 0x00 )  /*  NOR => CS=1 => Tristate => real black */
298      if ( (m_vidhw != DKONG_RADARSCP_CONVERSION) && ( (i & 0x03) == 0x00 ))  /*  NOR => CS=1 => Tristate => real black */
295299      {
296300         r = compute_res_net( 1, 0, &radarscp_net_bck_info );
297301         g = compute_res_net( 1, 1, &radarscp_net_bck_info );
r18100r18101
708712   double diff;
709713   int sig;
710714
711   line_cnt += 256;
712   if (line_cnt>511)
713      line_cnt -= VTOTAL;
715   /* vsync is divided by 2 by a LS161
716    * The resulting 30 Hz signal clocks a LFSR (LS164) operating as a
717    * random number generator.
718    */
714719
720   if ( line_cnt == 0)
721   {
722      state->m_sig30Hz = (1-state->m_sig30Hz);
723      if (state->m_sig30Hz)
724         state->m_lfsr_5I = (machine.rand() > RAND_MAX/2);
725   }
726
715727   /* sound2 mixes in a 30Hz noise signal.
716728     * With the current model this has no real effect
717729     * Included for completeness
718730     */
719731
720   line_cnt++;
721   if (line_cnt>=512)
722      line_cnt=512-VTOTAL;
723
724   if ( ( !(line_cnt & 0x40) && ((line_cnt+1) & 0x40) ) && (machine.rand() > RAND_MAX/2))
725      state->m_sig30Hz = (1-state->m_sig30Hz);
726
727732   /* Now mix with SND02 (sound 2) line - on 74ls259, bit2 */
728733   address_space &space = machine.driver_data()->generic_space();
729   state->m_rflip_sig = latch8_bit2_r(state->m_dev_6h, space, 0) & state->m_sig30Hz;
734   state->m_rflip_sig = latch8_bit2_r(state->m_dev_6h, space, 0) & state->m_lfsr_5I;
730735
736   /* blue background generation */
737
738   line_cnt += (256 - 8) + 1; // offset 8 needed to match monitor pictures
739   if (line_cnt>511)
740      line_cnt -= VTOTAL;
741
731742   sig = state->m_rflip_sig ^ ((line_cnt & 0x80)>>7);
732743
733744   if (state->m_hardware_type == HARDWARE_TRS01)
r18100r18101
736747   if  (sig) /*  128VF */
737748      diff = (0.0 - state->m_cv1);
738749   else
739      diff = (3.4 - state->m_cv1);
750      diff = (4.8 - state->m_cv1);
740751   diff = diff - diff*exp(0.0 - (1.0/RC1 * dt) );
741752   state->m_cv1 += diff;
742753
r18100r18101
744755   diff = diff - diff*exp(0.0 - (1.0/RC2 * dt) );
745756   state->m_cv2 += diff;
746757
747   state->m_vg1 = (state->m_cv1 - state->m_cv2)*0.9 + 0.1 * state->m_vg2;
748   state->m_vg2 = 5*CD4049(machine, state->m_vg1/5);
758   // FIXME: use the inverse function
759   // Solve the amplifier by iteration
760   for (int j=1; j<=11; j++)// 11% = 1/75 / (1/75+1/10)
761   {
762      double f = (double) j / 100.0f;
763      state->m_vg1 = (state->m_cv1 - state->m_cv2)*(1-f) + f * state->m_vg2;
764      state->m_vg2 = 5*CD4049(machine, state->m_vg1/5);
765   }
766   // FIXME: use the inverse function
767   // Solve the amplifier by iteration 50% = both resistors equal
768   for (int j=10; j<=20; j++)
769   {
770      double f = (double) j / 40.0f;
771      vg3i = (1.0f-f) * state->m_vg2 + f * state->m_vg3;
772      state->m_vg3 = 5*CD4049(machine, vg3i/5);
773   }
749774
750   /* on the real hardware, the gain would be 1.
751     * This will not work here.
752     */
753   vg3i = 0.9*state->m_vg2 + 0.1 * state->m_vg3;
754   state->m_vg3 = 5*CD4049(machine, vg3i/5);
775#define RC17 (33e-6 * 1e3 * (0*4.7+1.0/(1.0/10.0+1.0/20.0+0.0/0.3)))
776   diff = (state->m_vg3 - state->m_vc17);
777   diff = diff - diff*exp(0.0 - (1.0/RC17 * dt) );
778   state->m_vc17 += diff;
755779
756   state->m_blue_level = (int)(state->m_vg3/5.0*255);
780   double vo = (state->m_vg3 - state->m_vc17);
781   vo = vo + 20.0 / (20.0+10.0) * 5;
757782
783   // Transistor is marked as OMIT in TRS-02 schems.
784   //vo = vo - 0.7;
785
786
787   //double vo = (vg3o - vg3)/4.7 + 5.0/16.0;
788   //vo = vo / (1.0 / 4.7 + 1.0 / 16.0 + 1.0 / 30.0 );
789   //printf("%f %f\n", vg3, vc17);
790
791   state->m_blue_level = (int)(vo/5.0*255);
792   //printf("%d\n", state->m_blue_level);
793
758794   /*
759795     * Grid signal
760796     *
r18100r18101
776812   diff = diff - diff*exp(0.0 - (1.0/RC4 * dt) );
777813   state->m_cv4 += diff;
778814
779   if (CD4049(machine, CD4049(machine, state->m_vg2 - state->m_cv4))>2.4/5.0) /* TTL - Level */
815   if (CD4049(machine, CD4049(machine, (state->m_vg2 - state->m_cv4)/5.0))>2.4/5.0) /* TTL - Level */
780816      state->m_grid_sig = 0;
781817   else
782818      state->m_grid_sig = 1;
r18100r18101
886922         state->m_vidhw = newset;
887923         switch (newset)
888924         {
889            case 0x00:
925            case DKONG_RADARSCP_CONVERSION:
890926               state->PALETTE_INIT_CALL_MEMBER(radarscp);
891927               break;
892            case 0x01:
928            case DKONG_BOARD:
893929               state->PALETTE_INIT_CALL_MEMBER(dkong2b);
894930               break;
895931         }
trunk/src/mame/drivers/dkong.c
r18100r18101
458458
459459    MACHINE_START_CALL_MEMBER(dkong2b);
460460    m_hardware_type = HARDWARE_TRS02;
461    m_vidhw = DKONG_BOARD;
461462}
462463
463464MACHINE_START_MEMBER(dkong_state,radarscp1)
r18100r18101
465466
466467    MACHINE_START_CALL_MEMBER(dkong2b);
467468    m_hardware_type = HARDWARE_TRS01;
469    m_vidhw = DKONG_BOARD;
468470}
469471
470472MACHINE_START_MEMBER(dkong_state,dkong3)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team