trunk/src/mess/drivers/vboy.c
| r20332 | r20333 | |
| 184 | 184 | DECLARE_WRITE32_MEMBER(sram_w); |
| 185 | 185 | |
| 186 | 186 | void put_obj(bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y, UINT16 code, bool flipx, bool flipy, UINT8 pal); |
| 187 | | void put_char(int x, int y, UINT16 code, bool flipx, bool flipy, UINT8 pal); |
| 188 | 187 | void fill_ovr_char(UINT16 code, bool flipx, bool flipy, UINT8 pal); |
| 189 | | void fill_bg_map(int num, UINT16 scx, UINT16 scy); |
| 188 | INT8 get_bg_map_pixel(int num, int xpos, int ypos); |
| 190 | 189 | void draw_bg_map(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 param_base, int mode, int gx, int gp, int gy, int mx, int mp, int my,int h, int w, |
| 191 | | UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right); |
| 190 | UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right, int bg_map_num); |
| 192 | 191 | void draw_affine_map(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 param_base, int gx, int gp, int gy, int h, int w, |
| 193 | | UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right); |
| 192 | UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right, int bg_map_num); |
| 194 | 193 | UINT8 display_world(int num, bitmap_ind16 &bitmap, const rectangle &cliprect, bool right, int &cur_spt); |
| 195 | 194 | void m_set_brightness(void); |
| 196 | 195 | virtual void machine_start(); |
| r20332 | r20333 | |
| 259 | 258 | } |
| 260 | 259 | } |
| 261 | 260 | |
| 262 | | void vboy_state::put_char(int x, int y, UINT16 code, bool flipx, bool flipy, UINT8 pal) |
| 263 | | { |
| 264 | | UINT16 data; |
| 265 | | UINT8 yi, xi, dat; |
| 266 | | int col; |
| 267 | 261 | |
| 268 | | for (yi = 0; yi < 8; yi++) |
| 269 | | { |
| 270 | | if (!flipy) |
| 271 | | data = READ_FONT(code * 8 + yi); |
| 272 | | else |
| 273 | | data = READ_FONT(code * 8 + (7-yi)); |
| 274 | 262 | |
| 275 | | for (xi = 0; xi < 8; xi++) |
| 276 | | { |
| 277 | | int res_x,res_y; |
| 278 | | |
| 279 | | if (!flipx) |
| 280 | | dat = ((data >> (xi << 1)) & 0x03); |
| 281 | | else |
| 282 | | dat = ((data >> ((7-xi) << 1)) & 0x03); |
| 283 | | |
| 284 | | res_x = x + xi; |
| 285 | | res_y = y + yi; |
| 286 | | |
| 287 | | col = (pal >> (dat*2)) & 3; |
| 288 | | |
| 289 | | if(dat == 0) |
| 290 | | col = -1; |
| 291 | | |
| 292 | | WRITE_BG_TEMPDRAW_MAP(res_y*0x1000+res_x, col); |
| 293 | | } |
| 294 | | } |
| 295 | | } |
| 296 | | |
| 297 | 263 | void vboy_state::fill_ovr_char(UINT16 code, bool flipx, bool flipy, UINT8 pal) |
| 298 | 264 | { |
| 299 | 265 | UINT16 data; |
| r20332 | r20333 | |
| 324 | 290 | } |
| 325 | 291 | } |
| 326 | 292 | |
| 327 | | void vboy_state::fill_bg_map(int num, UINT16 scx, UINT16 scy) |
| 293 | INT8 vboy_state::get_bg_map_pixel(int num, int xpos, int ypos) |
| 328 | 294 | { |
| 329 | 295 | int x, y; |
| 330 | 296 | UINT8 stepx, stepy; |
| 331 | 297 | |
| 298 | y = ypos >>3; |
| 299 | x = xpos >>3; |
| 300 | |
| 332 | 301 | // Fill background map |
| 333 | | for (y = 0; y < scy; y++) |
| 302 | // for (y = 0; y < scy; y++) |
| 334 | 303 | { |
| 335 | | for (x = 0; x < scx; x++) |
| 304 | // for (x = 0; x < scx; x++) |
| 336 | 305 | { |
| 337 | 306 | stepx = (x & 0x1c0) >> 6; |
| 338 | 307 | stepy = ((y & 0x1c0) >> 6) * (stepx+1); |
| 339 | 308 | UINT16 val = READ_BGMAP((x & 0x3f) + (64 * (y & 0x3f)) + ((num + stepx + stepy) * 0x1000)); |
| 340 | | put_char(x * 8, y * 8, val & 0x7ff, BIT(val,13), BIT(val,12), m_vip_regs.GPLT[(val >> 14) & 3]); |
| 309 | int flipx = BIT(val,13); |
| 310 | int flipy = BIT(val,12); |
| 311 | int pal = m_vip_regs.GPLT[(val >> 14) & 3]; |
| 312 | int code = val & 0x7ff; |
| 313 | |
| 314 | //put_char(x * 8, y * 8, , , , ); |
| 315 | { |
| 316 | UINT16 data; |
| 317 | UINT8 yi, xi, dat; |
| 318 | int col; |
| 319 | |
| 320 | // for (yi = 0; yi < 8; yi++) |
| 321 | yi = ypos & 7; |
| 322 | |
| 323 | { |
| 324 | if (!flipy) |
| 325 | data = READ_FONT(code * 8 + yi); |
| 326 | else |
| 327 | data = READ_FONT(code * 8 + (7-yi)); |
| 328 | |
| 329 | //for (xi = 0; xi < 8; xi++) |
| 330 | xi = xpos & 7; |
| 331 | { |
| 332 | //int res_x,res_y; |
| 333 | |
| 334 | if (!flipx) |
| 335 | dat = ((data >> (xi << 1)) & 0x03); |
| 336 | else |
| 337 | dat = ((data >> ((7-xi) << 1)) & 0x03); |
| 338 | |
| 339 | //res_x = x + xi; |
| 340 | //res_y = y + yi; |
| 341 | |
| 342 | col = (pal >> (dat*2)) & 3; |
| 343 | |
| 344 | if(dat == 0) |
| 345 | col = -1; |
| 346 | |
| 347 | return col; |
| 348 | //WRITE_BG_TEMPDRAW_MAP(res_y*0x1000+res_x, col); |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 341 | 353 | } |
| 342 | 354 | } |
| 343 | 355 | } |
| 344 | 356 | |
| 345 | 357 | void vboy_state::draw_bg_map(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 param_base, int mode, int gx, int gp, int gy, int mx, int mp, int my, int h, int w, |
| 346 | | UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right) |
| 358 | UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right, int bg_map_num) |
| 347 | 359 | { |
| 348 | 360 | int x,y; |
| 349 | 361 | |
| r20332 | r20333 | |
| 371 | 383 | } |
| 372 | 384 | else |
| 373 | 385 | { |
| 374 | | pix = READ_BG_TEMPDRAW_MAP((src_y & y_mask)*0x1000+(src_x & x_mask)); |
| 386 | pix = get_bg_map_pixel(bg_map_num, src_x & x_mask, src_y & y_mask); |
| 375 | 387 | } |
| 376 | 388 | |
| 377 | 389 | if(pix != -1) |
| r20332 | r20333 | |
| 382 | 394 | } |
| 383 | 395 | |
| 384 | 396 | void vboy_state::draw_affine_map(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 param_base, int gx, int gp, int gy, int h, int w, |
| 385 | | UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right) |
| 397 | UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right, int bg_map_num) |
| 386 | 398 | { |
| 387 | 399 | int x,y; |
| 388 | 400 | |
| r20332 | r20333 | |
| 414 | 426 | } |
| 415 | 427 | else |
| 416 | 428 | { |
| 417 | | pix = READ_BG_TEMPDRAW_MAP((src_y & y_mask)*0x1000+(src_x & x_mask)); |
| 429 | pix = get_bg_map_pixel(bg_map_num, src_x & x_mask, src_y & y_mask); |
| 418 | 430 | } |
| 419 | 431 | |
| 420 | 432 | if(pix != -1) |
| r20332 | r20333 | |
| 470 | 482 | |
| 471 | 483 | if (lon && (!right)) |
| 472 | 484 | { |
| 473 | | fill_bg_map(bg_map_num, scx, scy); |
| 474 | | draw_bg_map(bitmap, cliprect, param_base, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, ovr, right); |
| 485 | //fill_bg_map(bg_map_num, scx, scy); |
| 486 | draw_bg_map(bitmap, cliprect, param_base, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, ovr, right, bg_map_num); |
| 475 | 487 | } |
| 476 | 488 | |
| 477 | 489 | if (ron && (right)) |
| 478 | 490 | { |
| 479 | | fill_bg_map(bg_map_num, scx, scy); |
| 480 | | draw_bg_map(bitmap, cliprect, param_base, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, ovr, right); |
| 491 | //fill_bg_map(bg_map_num, scx, scy); |
| 492 | draw_bg_map(bitmap, cliprect, param_base, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, ovr, right, bg_map_num); |
| 481 | 493 | } |
| 482 | 494 | } |
| 483 | 495 | else if (mode==2) // Affine Mode |
| r20332 | r20333 | |
| 487 | 499 | |
| 488 | 500 | if (lon && (!right)) |
| 489 | 501 | { |
| 490 | | fill_bg_map(bg_map_num, scx, scy); |
| 491 | | draw_affine_map(bitmap, cliprect, param_base, gx, gp, gy, h,w, scx*8-1, scy*8-1, ovr, right); |
| 502 | //fill_bg_map(bg_map_num, scx, scy); |
| 503 | draw_affine_map(bitmap, cliprect, param_base, gx, gp, gy, h,w, scx*8-1, scy*8-1, ovr, right, bg_map_num); |
| 492 | 504 | } |
| 493 | 505 | |
| 494 | 506 | if (ron && (right)) |
| 495 | 507 | { |
| 496 | | fill_bg_map(bg_map_num, scx, scy); |
| 497 | | draw_affine_map(bitmap, cliprect, param_base, gx, gp, gy, h,w, scx*8-1, scy*8-1, ovr, right); |
| 508 | //fill_bg_map(bg_map_num, scx, scy); |
| 509 | draw_affine_map(bitmap, cliprect, param_base, gx, gp, gy, h,w, scx*8-1, scy*8-1, ovr, right, bg_map_num); |
| 498 | 510 | } |
| 499 | 511 | } |
| 500 | 512 | else if (mode==3) // OBJ Mode |