src/mess/drivers/vboy.c
| r15952 | r15953 | |
| 172 | 172 | |
| 173 | 173 | col = (pal >> (dat*2)) & 3; |
| 174 | 174 | |
| 175 | | if (dat) |
| 175 | if (dat && res_x < 384 && res_y < 224) |
| 176 | 176 | bitmap.pix16((res_y), (res_x)) = state->machine().pens[col]; |
| 177 | 177 | } |
| 178 | 178 | } |
| r15952 | r15953 | |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | static 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, bool right) |
| 232 | { |
| 233 | int x,y; |
| 234 | |
| 235 | for(y=0;y<=h;y++) |
| 236 | { |
| 237 | for(x=0;x<=w;x++) |
| 238 | { |
| 239 | int src_x,src_y; |
| 240 | INT16 y1 = (y+gy); |
| 241 | INT16 x1 = (x+gx); |
| 242 | int pix = 0; |
| 243 | |
| 244 | x1 += right ? -gp : gp; |
| 245 | if (mode==1) |
| 246 | x1 += vboy_paramtab[y*2]; |
| 247 | |
| 248 | src_x = x+mx; |
| 249 | src_y = y+my; |
| 250 | src_x += right ? -mp : mp; |
| 251 | |
| 252 | pix = state->m_bg_map[((src_y) & 0x1ff)*0x200+((src_x) & 0x1ff)]; |
| 253 | |
| 254 | if(pix != -1) |
| 255 | if (y1>=0 && y1<224) |
| 256 | if (x1>=0 && x1<384) |
| 257 | bitmap.pix16(y1, x1) = state->machine().pens[pix & 3]; |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | static void draw_affine_map(vboy_state *state, bitmap_ind16 &bitmap, UINT16 *vboy_paramtab, int gx, int gp, int gy, int h, int w, bool right) |
| 263 | { |
| 264 | int x,y; |
| 265 | |
| 266 | for(y=0;y<=h;y++) |
| 267 | { |
| 268 | float h_skw = vboy_paramtab[y*8+0] / 8.0; |
| 269 | int prlx = vboy_paramtab[y*8+1]; |
| 270 | float v_skw = vboy_paramtab[y*8+2] / 8.0; |
| 271 | float h_scl = vboy_paramtab[y*8+3] / 512.0; |
| 272 | float v_scl = vboy_paramtab[y*8+4] / 512.0; |
| 273 | |
| 274 | for(x=0;x<=w;x++) |
| 275 | { |
| 276 | int src_x,src_y; |
| 277 | INT16 y1 = (y+gy); |
| 278 | INT16 x1 = (x+gx); |
| 279 | int pix = 0; |
| 280 | |
| 281 | x1 += right ? -gp : gp; |
| 282 | x1 += right ? prlx : -prlx; |
| 283 | src_x = (INT32)((h_skw) + (h_scl * x)); |
| 284 | src_y = (INT32)((v_skw) + (v_scl * y)); |
| 285 | |
| 286 | pix = state->m_bg_map[((src_y) & 0x1ff)*0x200+((src_x) & 0x1ff)]; |
| 287 | |
| 288 | if(pix != -1) |
| 289 | if (y1>=0 && y1<224) |
| 290 | if (x1>=0 && x1<384) |
| 291 | bitmap.pix16(y1, x1) = state->machine().pens[pix & 3]; |
| 292 | } |
| 293 | } |
| 294 | } |
| 295 | |
| 231 | 296 | static UINT8 display_world(vboy_state *state, int num, bitmap_ind16 &bitmap, bool right, int &cur_spt) |
| 232 | 297 | { |
| 233 | 298 | num <<= 4; |
| r15952 | r15953 | |
| 245 | 310 | UINT16 param_base = state->m_world[num+9] & 0xfff0; |
| 246 | 311 | // UINT16 overplane = state->m_world[num+10]; |
| 247 | 312 | UINT8 bg_map_num = def & 0x0f; |
| 248 | | INT16 x,y; |
| 249 | 313 | UINT8 mode = (def >> 12) & 3; |
| 250 | 314 | UINT16 *vboy_paramtab; |
| 251 | 315 | int i; |
| r15952 | r15953 | |
| 260 | 324 | if (lon && (!right)) |
| 261 | 325 | { |
| 262 | 326 | fill_bg_map(state, bg_map_num); |
| 263 | | |
| 264 | | // Left screen |
| 265 | | for(y=0;y<=h;y++) |
| 266 | | { |
| 267 | | for(x=0;x<=w;x++) |
| 268 | | { |
| 269 | | INT16 y1 = (y+gy); |
| 270 | | INT16 x1 = (x+gx-gp); |
| 271 | | int pix = 0; |
| 272 | | if (mode==1) |
| 273 | | x1 += vboy_paramtab[y*2]; |
| 274 | | |
| 275 | | pix = state->m_bg_map[((y+my) & 0x1ff)*0x200+((x+mx-mp) & 0x1ff)]; |
| 276 | | |
| 277 | | if(pix != -1) |
| 278 | | if (y1>=0 && y1<224) |
| 279 | | if (x1>=0 && x1<384) |
| 280 | | bitmap.pix16(y1, x1) = state->machine().pens[pix & 3]; |
| 281 | | } |
| 282 | | } |
| 327 | draw_bg_map(state, bitmap, vboy_paramtab, mode, gx, gp, gy, mx, mp, my, h,w, right); |
| 283 | 328 | } |
| 284 | 329 | |
| 285 | 330 | if (ron && (right)) |
| 286 | 331 | { |
| 287 | 332 | fill_bg_map(state, bg_map_num); |
| 288 | | |
| 289 | | // Right screen |
| 290 | | for(y=0;y<=h;y++) |
| 291 | | { |
| 292 | | for(x=0; x<=w; x++) |
| 293 | | { |
| 294 | | INT16 y1 = (y+gy); |
| 295 | | INT16 x1 = (x+gx+gp); |
| 296 | | int pix = 0; |
| 297 | | if (mode==1) |
| 298 | | x1 += vboy_paramtab[y*2+1]; |
| 299 | | |
| 300 | | pix = state->m_bg_map[((y+my) & 0x1ff)*0x200+((x+mx+mp) & 0x1ff)]; |
| 301 | | |
| 302 | | if(pix != -1) |
| 303 | | if (y1>=0 && y1<224) |
| 304 | | if (x1>=0 && x1<384) |
| 305 | | bitmap.pix16(y1, x1) = state->machine().pens[pix & 3]; |
| 306 | | } |
| 307 | | } |
| 333 | draw_bg_map(state, bitmap, vboy_paramtab, mode, gx, gp, gy, mx, mp, my, h,w, right); |
| 308 | 334 | } |
| 309 | 335 | } |
| 310 | | else |
| 311 | | if (mode==2) // Affine Mode |
| 336 | else if (mode==2) // Affine Mode |
| 312 | 337 | { |
| 313 | 338 | if (lon && (!right)) |
| 314 | 339 | { |
| 315 | 340 | fill_bg_map(state, bg_map_num); |
| 316 | | |
| 317 | | // Left screen |
| 318 | | for(y=0;y<=h;y++) |
| 319 | | { |
| 320 | | float h_skw = vboy_paramtab[y*8+0] / 8.0; |
| 321 | | int prlx = vboy_paramtab[y*8+1]; |
| 322 | | float v_skw = vboy_paramtab[y*8+2] / 8.0; |
| 323 | | float h_scl = vboy_paramtab[y*8+3] / 512.0; |
| 324 | | float v_scl = vboy_paramtab[y*8+4] / 512.0; |
| 325 | | |
| 326 | | for(x=0;x<=w;x++) |
| 327 | | { |
| 328 | | int src_x,src_y; |
| 329 | | INT16 y1 = (y+gy); |
| 330 | | INT16 x1 = (x+gx-gp+prlx); |
| 331 | | int pix = 0; |
| 332 | | |
| 333 | | src_x = (INT32)((h_skw) + (h_scl * x)); |
| 334 | | src_y = (INT32)((v_skw) + (v_scl * y)); |
| 335 | | |
| 336 | | pix = state->m_bg_map[((src_y) & 0x1ff)*0x200+((src_x) & 0x1ff)]; |
| 337 | | |
| 338 | | if(pix != -1) |
| 339 | | if (y1>=0 && y1<224) |
| 340 | | if (x1>=0 && x1<384) |
| 341 | | bitmap.pix16(y1, x1) = state->machine().pens[pix & 3]; |
| 342 | | } |
| 343 | | } |
| 341 | draw_affine_map(state, bitmap, vboy_paramtab, gx, gp, gy, h,w, right); |
| 344 | 342 | } |
| 345 | 343 | |
| 346 | 344 | if (ron && (right)) |
| 347 | 345 | { |
| 348 | 346 | fill_bg_map(state, bg_map_num); |
| 349 | | |
| 350 | | // Right screen |
| 351 | | for(y=0;y<=h;y++) |
| 352 | | { |
| 353 | | float h_skw = vboy_paramtab[y*8+0] / 8.0; |
| 354 | | int prlx = vboy_paramtab[y*8+1]; |
| 355 | | float v_skw = vboy_paramtab[y*8+2] / 8.0; |
| 356 | | float h_scl = vboy_paramtab[y*8+3] / 512.0; |
| 357 | | float v_scl = vboy_paramtab[y*8+4] / 512.0; |
| 358 | | |
| 359 | | for(x=0;x<=w;x++) |
| 360 | | { |
| 361 | | int src_x,src_y; |
| 362 | | INT16 y1 = (y+gy); |
| 363 | | INT16 x1 = (x+gx+gp-prlx); |
| 364 | | int pix = 0; |
| 365 | | |
| 366 | | src_x = (INT32)((h_skw) + (h_scl * x)); |
| 367 | | src_y = (INT32)((v_skw) + (v_scl * y)); |
| 368 | | |
| 369 | | pix = state->m_bg_map[((src_y) & 0x1ff)*0x200+((src_x) & 0x1ff)]; |
| 370 | | |
| 371 | | if(pix != -1) |
| 372 | | if (y1>=0 && y1<224) |
| 373 | | if (x1>=0 && x1<384) |
| 374 | | bitmap.pix16(y1, x1) = state->machine().pens[pix & 3]; |
| 375 | | } |
| 376 | | } |
| 347 | draw_affine_map(state, bitmap, vboy_paramtab, gx, gp, gy, h,w, right); |
| 377 | 348 | } |
| 378 | 349 | } |
| 379 | | else |
| 380 | | if (mode==3) // OBJ Mode |
| 350 | else if (mode==3) // OBJ Mode |
| 381 | 351 | { |
| 382 | 352 | int start_offs, end_offs; |
| 383 | 353 | |