Previous 15994 Revisions Next

r15972 Monday 20th August, 2012 at 00:51:16 UTC by Angelo Salese
Implemented tilemap wrap-around disable
[src/mess/drivers]vboy.c

src/mess/drivers/vboy.c
r15971r15972
113113   vip_regs_t m_vip_regs;
114114   vboy_timer_t m_vboy_timer;
115115   int *m_bg_map;
116   int *m_ovr_map;
116117   UINT16 m_frame_count;
117118   UINT8 m_displayfb;
118119   UINT8 m_display_count;
r15971r15972
135136
136137   // Allocate memory for temporary screens
137138   state->m_bg_map = auto_alloc_array_clear(machine, int, 0x1000*0x1000);
139   state->m_ovr_map = auto_alloc_array_clear(machine, int, 8*8);
138140
139141   state->m_font  = auto_alloc_array(machine, UINT16, 2048 * 8);
140142   state->m_bgmap = auto_alloc_array(machine, UINT16, 0x20000 >> 1);
r15971r15972
144146   state->m_world = state->m_bgmap + (0x1d800 >> 1);
145147}
146148
147static void put_obj(vboy_state *state, bitmap_ind16 &bitmap, int x, int y, UINT16 ch, bool flipx, bool flipy, UINT8 pal)
149static void put_obj(vboy_state *state, bitmap_ind16 &bitmap, int x, int y, UINT16 code, bool flipx, bool flipy, UINT8 pal)
148150{
149   UINT16 data, code = ch;
151   UINT16 data;
150152   UINT8 yi, xi, dat, col;
151153
152154   for (yi = 0; yi < 8; yi++)
r15971r15972
176178   }
177179}
178180
179static void put_char(vboy_state *state, int x, int y, UINT16 ch, bool flipx, bool flipy, UINT8 pal)
181static void put_char(vboy_state *state, int x, int y, UINT16 code, bool flipx, bool flipy, UINT8 pal)
180182{
181   UINT16 data, code = ch;
183   UINT16 data;
182184   UINT8 yi, xi, dat;
183185   int col;
184186
r15971r15972
211213   }
212214}
213215
216static void fill_ovr_char(vboy_state *state, UINT16 code, bool flipx, bool flipy, UINT8 pal)
217{
218   UINT16 data;
219   UINT8 yi, xi, dat;
220   int col;
214221
222   for (yi = 0; yi < 8; yi++)
223   {
224      if (!flipy)
225          data = state->m_font[code * 8 + yi];
226      else
227          data = state->m_font[code * 8 + (7-yi)];
228
229      for (xi = 0; xi < 8; xi++)
230      {
231         if (!flipx)
232            dat = ((data >> (xi << 1)) & 0x03);
233         else
234            dat = ((data >> ((7-xi) << 1)) & 0x03);
235
236         col = (pal >> (dat*2)) & 3;
237
238         if(dat == 0)
239            col = -1;
240
241         state->m_ovr_map[yi*8+xi] = col;
242      }
243   }
244}
245
215246static void fill_bg_map(vboy_state *state, int num, UINT16 scx, UINT16 scy)
216247{
217248   int x, y;
r15971r15972
230261   }
231262}
232263
233static void draw_bg_map(vboy_state *state, bitmap_ind16 &bitmap, UINT16 *vboy_paramtab, int mode, int gx, int gp, int gy, int mx, int mp, int my, int h, int w, UINT16 x_mask, UINT16 y_mask, bool right)
264static void draw_bg_map(vboy_state *state, bitmap_ind16 &bitmap, UINT16 *vboy_paramtab, int mode, int gx, int gp, int gy, int mx, int mp, int my, int h, int w, UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right)
234265{
235266   int x,y;
236267
r15971r15972
245276
246277         x1 += right ? -gp : gp;
247278         if (mode==1)
248            x1 += vboy_paramtab[y*2];
279            x1 += vboy_paramtab[y*2+(right ^ 1)];
249280
250281         src_x = x+mx;
251282         src_y = y+my;
252283         src_x += right ? -mp : mp;
253284
254         pix = state->m_bg_map[(src_y & y_mask)*0x1000+(src_x & x_mask)];
285         if(ovr && (src_x > x_mask || src_y > y_mask || src_x < 0 || src_y < 0))
286            pix = state->m_ovr_map[(src_y & 7)*8+(src_x & 7)];
287         else
288            pix = state->m_bg_map[(src_y & y_mask)*0x1000+(src_x & x_mask)];
255289
256290         if(pix != -1)
257291            if (y1>=0 && y1<224)
r15971r15972
261295   }
262296}
263297
264static void draw_affine_map(vboy_state *state, bitmap_ind16 &bitmap, UINT16 *vboy_paramtab, int gx, int gp, int gy, int h, int w, UINT16 x_mask, UINT16 y_mask, bool right)
298static void draw_affine_map(vboy_state *state, bitmap_ind16 &bitmap, UINT16 *vboy_paramtab, int gx, int gp, int gy, int h, int w, UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right)
265299{
266300   int x,y;
267301
r15971r15972
287321         src_x = (INT32)((h_skw) + (h_scl * x));
288322         src_y = (INT32)((v_skw) + (v_scl * x));
289323
290         pix = state->m_bg_map[(src_y & y_mask)*0x1000+(src_x & x_mask)];
324         if(ovr && (src_y > y_mask || src_x > x_mask || src_x < 0 || src_y < 0))
325            pix = state->m_ovr_map[(src_y & 7)*8+(src_x & 7)];
326         else
327            pix = state->m_bg_map[(src_y & y_mask)*0x1000+(src_x & x_mask)];
291328
292329            if(pix != -1)
293330            if (y1>=0 && y1<224)
r15971r15972
300337/*
301338x--- ---- ---- ---- [0] LON
302339-x-- ---- ---- ----     RON
303--xx ---- ---- ---- BGM type
304---- xx-- ---- ---- SCX
305---- --xx ---- ---- SCY
306---- ---- x--- ---- OVR
307---- ---- -x-- ---- END
340--xx ---- ---- ----     BGM type
341---- xx-- ---- ----     SCX
342---- --xx ---- ----     SCY
343---- ---- x--- ----     OVR
344---- ---- -x-- ----     END
308345---- ---- --00 ----
309---- ---- ---- xxxx BGMAP_BASE
346---- ---- ---- xxxx     BGMAP_BASE
310347*/
311348
312349static UINT8 display_world(vboy_state *state, int num, bitmap_ind16 &bitmap, bool right, int &cur_spt)
r15971r15972
318355   UINT8 mode = (def >> 12) & 3;
319356   UINT16 scx = 64 << ((def >> 10) & 3);
320357   UINT16 scy = 64 << ((def >> 8) & 3);
358   UINT8 ovr = (def >> 7) & 1;
359   UINT8 end = (def >> 6) & 1;
321360   INT16 gx  = state->m_world[num+1];
322361   INT16 gp  = state->m_world[num+2];
323362   INT16 gy  = state->m_world[num+3];
r15971r15972
327366   UINT16 w  = state->m_world[num+7];
328367   UINT16 h  = state->m_world[num+8];
329368   UINT16 param_base = state->m_world[num+9] & 0xfff0;
330//  UINT16 overplane = state->m_world[num+10];
369   UINT16 ovr_char = state->m_world[num+10];
331370   UINT8 bg_map_num = def & 0x0f;
332371   UINT16 *vboy_paramtab;
333372   int i;
334373
335374   vboy_paramtab = state->m_bgmap + param_base;
336375
337   if(def & 0x40) // END flag
376   if(end)
338377      return 1;
339378
340379   if (mode < 2) // Normal / Hbias Mode
r15971r15972
342381      if(mode == 1)
343382         popmessage("mode == 1, check");
344383
384      if(ovr)
385         fill_ovr_char(state, ovr_char & 0x7ff,BIT(ovr_char,13), BIT(ovr_char,12), state->m_vip_regs.GPLT[(ovr_char >> 14) & 3]);
386
345387      if (lon && (!right))
346388      {
347389         fill_bg_map(state, bg_map_num, scx, scy);
348         draw_bg_map(state, bitmap, vboy_paramtab, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, right);
390         draw_bg_map(state, bitmap, vboy_paramtab, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, ovr, right);
349391      }
350392
351393      if (ron && (right))
352394      {
353395         fill_bg_map(state, bg_map_num, scx, scy);
354         draw_bg_map(state, bitmap, vboy_paramtab, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, right);
396         draw_bg_map(state, bitmap, vboy_paramtab, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, ovr, right);
355397      }
356398   }
357399   else if (mode==2) // Affine Mode
358400   {
401      if(ovr)
402         fill_ovr_char(state, ovr_char & 0x7ff,BIT(ovr_char,13), BIT(ovr_char,12), state->m_vip_regs.GPLT[(ovr_char >> 14) & 3]);
403
359404      if (lon && (!right))
360405      {
361406         fill_bg_map(state, bg_map_num, scx, scy);
362         draw_affine_map(state, bitmap, vboy_paramtab, gx, gp, gy, h,w, scx*8-1, scy*8-1, right);
407         draw_affine_map(state, bitmap, vboy_paramtab, gx, gp, gy, h,w, scx*8-1, scy*8-1, ovr, right);
363408      }
364409
365410      if (ron && (right))
366411      {
367412         fill_bg_map(state, bg_map_num, scx, scy);
368         draw_affine_map(state, bitmap, vboy_paramtab, gx, gp, gy, h,w, scx*8-1, scy*8-1, right);
413         draw_affine_map(state, bitmap, vboy_paramtab, gx, gp, gy, h,w, scx*8-1, scy*8-1, ovr, right);
369414      }
370415   }
371416   else if (mode==3) // OBJ Mode

Previous 15994 Revisions Next


© 1998-2018 The MESS Team