Previous 199869 Revisions Next

r26506 Wednesday 4th December, 2013 at 18:21:19 UTC by David Haywood
note updates (nw)
[src/mame/drivers]pinkiri8.c

trunk/src/mame/drivers/pinkiri8.c
r26505r26506
11/***************************************************************************
22
3Pinkiri 8 skeleton driver
3Janshi / Pinkiri 8 / Ron Jan
4 - Wing / Eagle Mahjong board using HD647180X0P6 with internal ROM
45
5- current blocker is the video emulation i/o ports, it looks somewhat exotic.
66
7 Todo:
8 - background tilemap is not fully understood, we lack evidence to support
9   it properly, all the games here just do a solid fill of one tile!
10
11 - sprite heights?!
12
713============================================================================
814Janshi
915(c)1992 Eagle
r26505r26506
7985   virtual void video_start();
8086   UINT32 screen_update_pinkiri8(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8187   required_device<cpu_device> m_maincpu;
88
89   void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect);
90   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
8291};
8392
8493
8594
8695/* VDP device to give us our own memory map */
87
8896class janshi_vdp_device : public device_t,
8997                     public device_memory_interface
9098{
r26505r26506
97105   virtual void device_reset();
98106   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
99107   address_space_config        m_space_config;
100
101
102
103108};
104109
105110
r26505r26506
122127
123128const device_type JANSHIVDP = &device_creator<janshi_vdp_device>;
124129
125
126
127130janshi_vdp_device::janshi_vdp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
128131   : device_t(mconfig, JANSHIVDP, "JANSHIVDP", tag, owner, clock, "janshi_vdp", __FILE__),
129132      device_memory_interface(mconfig, *this),
r26505r26506
131134{
132135}
133136
137void janshi_vdp_device::device_config_complete(){}
138void janshi_vdp_device::device_validity_check(validity_checker &valid) const {}
139void janshi_vdp_device::device_start() {}
140void janshi_vdp_device::device_reset() {}
134141
135
136
137
138void janshi_vdp_device::device_config_complete()
139{
140//  int address_bits = 24;
141
142//  m_space_config = address_space_config("janshi_vdp", ENDIANNESS_BIG, 8,  address_bits, 0, *ADDRESS_MAP_NAME(janshi_vdp_map8));
143}
144
145void janshi_vdp_device::device_validity_check(validity_checker &valid) const
146{
147}
148
149void janshi_vdp_device::device_start()
150{
151}
152
153void janshi_vdp_device::device_reset()
154{
155}
156
157142const address_space_config *janshi_vdp_device::memory_space_config(address_spacenum spacenum) const
158143{
159144   return (spacenum == 0) ? &m_space_config : NULL;
160145}
161146
147void pinkiri8_state::video_start() {}
162148
163/* end VDP device to give us our own memory map */
164149
165
166
167
168
169void pinkiri8_state::video_start()
150void pinkiri8_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect)
170151{
171}
172
173/*
174
175ronjan
17600, 7d, 00, 40, 00, 42, 00, 44, 00, 46, 00, 48, 00, 4a, 00, 0c, 00, 4e, 00, 10, 00, 12, 00, 14, 00, 16, 00, 18, 00, 1a, 00, 1c,
17700, 7d, 00, 40, 00, 42, 00, 44, 00, 46, 00, 48, 00, 4a, 00, 4c, 00, 4e, 00, 50, 00, 52, 00, 54, 00, 56, 00, 58, 00, 5a, 00, 5c,
17800, 7d, 00, 40, 00, 42, 00, 44, 00, 46, 00, 48, 00, 4a, 00, 4c, 00, 4e, 00, 50, 00, 52, 00, 54, 00, 56, 00, 58, 00, 5a, 00, 5c,
179
18000, 1e, 00, 20, 00, 22, 00, 24, 00, 26, 00, 68, 00, 6a, 00, 6c, 00, 6e, 00, 70, 00, 72, 00, 74, 00, 76, 00, 38, 00, 3a, 00, c0,
18100, 5e, 00, 60, 00, 62, 00, 64, 00, 66, 00, 68, 00, 6a, 00, 6c, 00, 6e, 00, 70, 00, 72, 00, 74, 00, 76, 00, 78, 00, 7a, 00, c0,
18200, 5e, 00, 60, 00, 62, 00, 64, 00, 66, 00, 68, 00, 6a, 00, 6c, 00, 6e, 00, 70, 00, 72, 00, 74, 00, 76, 00, 78, 00, 7a, 00, c0,
183
184
18500, c2, 00, c4, 00, c6, 00, c8, 00, ca, 00, cc, 00, ce, 00, d0, 00, d2, 00, d4, 00, d6, 00, d8, 00, da, 00, dc, 00, de, 00, e0,
18600, c2, 00, c4, 00, c6, 00, c8, 00, ca, 00, cc, 00, ce, 00, d0, 00, d2, 00, d4, 00, d6, 00, d8, 00, da, 00, dc, 00, de, 00, e0,
18700, c2, 00, c4, 00, c6, 00, c8, 00, ca, 00, cc, 00, ce, 00, d0, 00, d2, 00, d4, 00, d6, 00, d8, 00, da, 00, dc, 00, de, 00, e0,
188
18900, e3, 00, e5, 00, e7, 00, e9, 00, eb, 00, ed, 00, ef, 00, f1, 00, f3, 00, f5, 00, f7, 00, f9, 00, fb, 00, fd, 00, ff, 00, 7e,
19000, e3, 00, e5, 00, e7, 00, e9, 00, eb, 00, ed, 00, ef, 00, f1, 00, f3, 00, f5, 00, f7, 00, f9, 00, fb, 00, fd, 00, ff, 00, 7e,
19100, e3, 00, e5, 00, e7, 00, e9, 00, eb, 00, ed, 00, ef, 00, f1, 00, f3, 00, f5, 00, f7, 00, f9, 00, fb, 00, fd, 00, ff, 00, 7e,
192
19300, 00, 00, 01, 00, 01, 00, 01, 00, 01, 00, 00, 00, 01, 00, 00, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01,
19400, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01,
19500, 00, 00, 01, 00, 01, 00, 01, 00, 01, 00, 00, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01,
196
197
19800, 01, 00, 01, 00, 01, 00, 01, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 01, 00, 01, 00, 00, 00, 00,
19900, 01, 00, 01, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
20000, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 00, 00, 00, 00, 00,
201
202
203
204*/
205
206UINT32 pinkiri8_state::screen_update_pinkiri8(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
207{
208   int col_bank;
209152   gfx_element *gfx = machine().gfx[0];
210153
211   /* update palette */
212   for (int pen = 0; pen < 0x800 ; pen++)
154   /* FIXME: color is a bit of a mystery */
213155   {
214      UINT16 val = (m_janshi_paletteram[pen]) | (m_janshi_paletteram2[pen]<<8);
215      int r = (val & 0x001f) >> 0;
216      int g = (val & 0x03e0) >> 5;
217      int b = (val & 0x7c00) >> 10;
218      palette_set_color_rgb(machine(), pen, pal5bit(r), pal5bit(g), pal5bit(b));
219   }
156      int x, y, col, tile, count, attr;
220157
221   int game_type_hack = 0;
158      count = 0;
222159
223   if (!strcmp(machine().system().name,"janshi")) game_type_hack = 1;
224
225   if ( machine().input().code_pressed_once(KEYCODE_W) )
226   {
227      int i;
228      int count2;
229      printf("-------------------------------\n");
230      count2=0;
231      for (i=0x00;i<0x40;i+=2)
160      for (y = 0; y < 64; y++)
232161      {
233         printf("%02x, ", m_janshi_widthflags[i+1]);
234
235         count2++;
236
237         if (count2==0x10)
162         for (x = 0; x < 32; x++)
238163         {
239            printf("\n");
240            count2 = 0;
241         }
164            tile = m_janshi_back_vram[count + 1] << 8 | m_janshi_back_vram[count + 0];
165            attr = m_janshi_back_vram[count + 2] ^ 0xf0;
166            col = (attr >> 4) | 0x10;
242167
168            drawgfx_transpen(bitmap, cliprect, gfx, tile, col, 0, 0, x * 16, y * 8, 0);
243169
170            count += 4;
171         }
244172      }
245
246
247173   }
174}
248175
176void pinkiri8_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
177{
178   int game_type_hack = 0;
179   int col_bank;
180   gfx_element *gfx = machine().gfx[0];
249181
182   if (!strcmp(machine().system().name,"janshi")) game_type_hack = 1;
250183
251184   //popmessage("%02x",m_janshi_crtc_regs[0x0a]);
252185   col_bank = (m_janshi_crtc_regs[0x0a] & 0x40) >> 6;
253186
254   bitmap.fill(get_black_pen(machine()), cliprect);
255187
256   /* FIXME: color is a bit of a mystery */
257   {
258      int x,y,col,tile,count,attr;
188   int x,y; //,unk2;
189   int col;
259190
260      count = 0;
191   int spr_offs,i;
261192
262      for(y=0;y<64;y++)
263      {
264         for(x=0;x<32;x++)
265         {
266            tile = m_janshi_back_vram[count+1]<<8 | m_janshi_back_vram[count+0];
267            attr = m_janshi_back_vram[count+2] ^ 0xf0;
268            col = (attr >> 4) | 0x10;
193   int width, height;
269194
270            drawgfx_transpen(bitmap,cliprect,gfx,tile,col,0,0,x*16,y*8,0);
271195
272            count+=4;
273         }
274      }
275   }
276196
197   for(i=(0x1000/4)-4;i>=0;i--)
277198   {
278      int x,y; //,unk2;
279      int col;
199   /*  "vram1" (video map 0xfc2000)
280200
281      int spr_offs,i;
201      tttt tttt | 00tt tttt | cccc c000 | xxxx xxxx |
282202
283      int width, height;
203      "vram2" (video map 0xfc3800)
284204
205      yyyy yyyy | ???? ???? |
285206
286207
287      for(i=(0x1000/4)-4;i>=0;i--)
288      {
289      /* vram 1 (video map 0xfc2000)
208      widths come from "widthflags" (0xfc3780)
209      "unk1" (0xfc3700) and "unk2" (0xfc37c0) are a mystery
290210
291        tttt tttt | 00tt tttt | cccc c000 | xxxx xxxx |
211      */
292212
293        vram 2 (video map 0xfc3800)
213      spr_offs = ((m_janshi_vram1[(i*4)+0] & 0xff) | (m_janshi_vram1[(i*4)+1]<<8)) & 0xffff;
214      col = (m_janshi_vram1[(i*4)+2] & 0xf8) >> 3;
215      x =   m_janshi_vram1[(i*4)+3] * 2;
294216
295        yyyy yyyy | ???? ???? |
217//          unk2 = m_janshi_vram2[(i*2)+1];
218      y = (m_janshi_vram2[(i*2)+0]);
296219
297      there is also some data at 13000 - 137ff
298      and a table at 20000..
220      y = 0x100-y;
299221
300        */
222      col|= col_bank<<5;
301223
302         spr_offs = ((m_janshi_vram1[(i*4)+0] & 0xff) | (m_janshi_vram1[(i*4)+1]<<8)) & 0xffff;
303         col = (m_janshi_vram1[(i*4)+2] & 0xf8) >> 3;
304         x =   m_janshi_vram1[(i*4)+3];
224   //  width = 0; height = 0;
305225
306         x &= 0xff;
307         x *= 2;
226      width = 2;
227      height = 2;
308228
309//          unk2 = m_janshi_vram2[(i*2)+1];
310         y = (m_janshi_vram2[(i*2)+0]);
311229
312         y = 0x100-y;
230      // this bit determines the sprite width, one bit is used in each word, each bit is used for a range of sprites
231      int bit = m_janshi_widthflags[(i/0x20)*2 + 1];
313232
314         col|= col_bank<<5;
315
316      //  width = 0; height = 0;
317
233      if (bit)
234      {
235         //col = machine().rand();
318236         width = 2;
237      }
238      else
239      {
240         width = 1;
319241         height = 2;
242      }
320243
321
322         // these bits seem to somehow determine the sprite height / widths for the sprite ram region?
323         int bit = m_janshi_widthflags[(i/0x20)*2 + 1];
324
325         if (bit)
244      // hacks!
245      if (game_type_hack==1) // janshi
246      {
247         if (spr_offs<0x400)
326248         {
327            //col = machine().rand();
328            width = 2;
249            height = 4;
329250         }
251         else if (spr_offs<0x580)
252         {
253         //  height = 2;
254         }
255         else if (spr_offs<0x880)
256         {
257            height = 4;
258         }
259         else if (spr_offs<0x1000)
260         {
261         //  height = 2;
262         }
263         else if (spr_offs<0x1080)
264         {
265         //  height = 2;
266         }
267         else if (spr_offs<0x1700)
268         {
269            height = 4;
270         }
271         else if (spr_offs<0x1730)
272         {
273         //  height = 2;
274         }
275         else if (spr_offs<0x1930)
276         {
277            height = 4;
278         }
279         else if (spr_offs<0x19c0)
280         {
281            height = 1;
282         }
330283         else
331284         {
332            width = 1;
333            height = 2;
285            height = 4;
334286         }
335287
336         // hacks!
337         if (game_type_hack==1) // janshi
338         {
339            if (spr_offs<0x400)
340            {
341               height = 4;
342            }
343            else if (spr_offs<0x580)
344            {
345            //  height = 2;
346            }
347            else if (spr_offs<0x880)
348            {
349               height = 4;
350            }
351            else if (spr_offs<0x1000)
352            {
353            //  height = 2;
354            }
355            else if (spr_offs<0x1080)
356            {
357            //  height = 2;
358            }
359            else if (spr_offs<0x1700)
360            {
361               height = 4;
362            }
363            else if (spr_offs<0x1730)
364            {
365            //  height = 2;
366            }
367            else if (spr_offs<0x1930)
368            {
369               height = 4;
370            }
371            else if (spr_offs<0x19c0)
372            {
373               height = 1;
374            }
375            else
376            {
377               height = 4;
378            }
379288
289      }
380290
381         }
382291
383292
384293
385294
386295
296      if (height==1)
297         y+=16;
387298
388         if (height==1)
389            y+=16;
390299
300      // hmm...
301      if (height==2)
302         y+=16;
391303
392         // hmm...
393         if (height==2)
394            y+=16;
395304
396305
306      {
307         int count = 0;
397308
398         {
399            int count = 0;
400309
401
402            for (int yy=0;yy<height;yy++)
310         for (int yy=0;yy<height;yy++)
311         {
312            for (int xx=0;xx<width;xx++)
403313            {
404               for (int xx=0;xx<width;xx++)
405               {
406                  drawgfx_transpen(bitmap,cliprect,gfx,spr_offs+count,col,0,0,x+xx*16,y+yy*8,0);
407                  count++;
408               }
314               drawgfx_transpen(bitmap,cliprect,gfx,spr_offs+count,col,0,0,(x+xx*16) -7 ,(y+yy*8)-33,0);
315               count++;
409316            }
410317         }
411318      }
412319   }
320}
413321
322UINT32 pinkiri8_state::screen_update_pinkiri8(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
323{
324
325   /* update palette */
326   for (int pen = 0; pen < 0x800 ; pen++)
327   {
328      UINT16 val = (m_janshi_paletteram[pen]) | (m_janshi_paletteram2[pen]<<8);
329      int r = (val & 0x001f) >> 0;
330      int g = (val & 0x03e0) >> 5;
331      int b = (val & 0x7c00) >> 10;
332      palette_set_color_rgb(machine(), pen, pal5bit(r), pal5bit(g), pal5bit(b));
333   }
334
335
336
337#if 0
338   if ( machine().input().code_pressed_once(KEYCODE_W) )
339   {
340      int i;
341      int count2;
342      printf("-------------------------------\n");
343      count2=0;
344      for (i=0x00;i<0x40;i+=2)
345      {
346         printf("%02x, ", m_janshi_widthflags[i+1]);
347
348         count2++;
349
350         if (count2==0x10)
351         {
352            printf("\n");
353            count2 = 0;
354         }
355      }
356   }
357#endif
358
359
360   bitmap.fill(get_black_pen(machine()), cliprect);
361
362   draw_background(bitmap, cliprect);
363
364   draw_sprites(bitmap, cliprect);
365
414366   return 0;
415367}
416368
r26505r26506
11381090   MCFG_SCREEN_REFRESH_RATE(60)
11391091   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
11401092   MCFG_SCREEN_SIZE(64*8, 64*8)
1141   MCFG_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 0*8, 64*8-1)
1093   MCFG_SCREEN_VISIBLE_AREA(0*8, 62*8-1, 0*8, 32*8-1)
11421094   MCFG_SCREEN_UPDATE_DRIVER(pinkiri8_state, screen_update_pinkiri8)
11431095
11441096   MCFG_GFXDECODE(pinkiri8)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team