src/mess/drivers/vboy.c
| r15971 | r15972 | |
| 113 | 113 | vip_regs_t m_vip_regs; |
| 114 | 114 | vboy_timer_t m_vboy_timer; |
| 115 | 115 | int *m_bg_map; |
| 116 | int *m_ovr_map; |
| 116 | 117 | UINT16 m_frame_count; |
| 117 | 118 | UINT8 m_displayfb; |
| 118 | 119 | UINT8 m_display_count; |
| r15971 | r15972 | |
| 135 | 136 | |
| 136 | 137 | // Allocate memory for temporary screens |
| 137 | 138 | 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); |
| 138 | 140 | |
| 139 | 141 | state->m_font = auto_alloc_array(machine, UINT16, 2048 * 8); |
| 140 | 142 | state->m_bgmap = auto_alloc_array(machine, UINT16, 0x20000 >> 1); |
| r15971 | r15972 | |
| 144 | 146 | state->m_world = state->m_bgmap + (0x1d800 >> 1); |
| 145 | 147 | } |
| 146 | 148 | |
| 147 | | static void put_obj(vboy_state *state, bitmap_ind16 &bitmap, int x, int y, UINT16 ch, bool flipx, bool flipy, UINT8 pal) |
| 149 | static void put_obj(vboy_state *state, bitmap_ind16 &bitmap, int x, int y, UINT16 code, bool flipx, bool flipy, UINT8 pal) |
| 148 | 150 | { |
| 149 | | UINT16 data, code = ch; |
| 151 | UINT16 data; |
| 150 | 152 | UINT8 yi, xi, dat, col; |
| 151 | 153 | |
| 152 | 154 | for (yi = 0; yi < 8; yi++) |
| r15971 | r15972 | |
| 176 | 178 | } |
| 177 | 179 | } |
| 178 | 180 | |
| 179 | | static void put_char(vboy_state *state, int x, int y, UINT16 ch, bool flipx, bool flipy, UINT8 pal) |
| 181 | static void put_char(vboy_state *state, int x, int y, UINT16 code, bool flipx, bool flipy, UINT8 pal) |
| 180 | 182 | { |
| 181 | | UINT16 data, code = ch; |
| 183 | UINT16 data; |
| 182 | 184 | UINT8 yi, xi, dat; |
| 183 | 185 | int col; |
| 184 | 186 | |
| r15971 | r15972 | |
| 211 | 213 | } |
| 212 | 214 | } |
| 213 | 215 | |
| 216 | static 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; |
| 214 | 221 | |
| 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 | |
| 215 | 246 | static void fill_bg_map(vboy_state *state, int num, UINT16 scx, UINT16 scy) |
| 216 | 247 | { |
| 217 | 248 | int x, y; |
| r15971 | r15972 | |
| 230 | 261 | } |
| 231 | 262 | } |
| 232 | 263 | |
| 233 | | 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, UINT16 x_mask, UINT16 y_mask, bool right) |
| 264 | 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, UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right) |
| 234 | 265 | { |
| 235 | 266 | int x,y; |
| 236 | 267 | |
| r15971 | r15972 | |
| 245 | 276 | |
| 246 | 277 | x1 += right ? -gp : gp; |
| 247 | 278 | if (mode==1) |
| 248 | | x1 += vboy_paramtab[y*2]; |
| 279 | x1 += vboy_paramtab[y*2+(right ^ 1)]; |
| 249 | 280 | |
| 250 | 281 | src_x = x+mx; |
| 251 | 282 | src_y = y+my; |
| 252 | 283 | src_x += right ? -mp : mp; |
| 253 | 284 | |
| 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)]; |
| 255 | 289 | |
| 256 | 290 | if(pix != -1) |
| 257 | 291 | if (y1>=0 && y1<224) |
| r15971 | r15972 | |
| 261 | 295 | } |
| 262 | 296 | } |
| 263 | 297 | |
| 264 | | static 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) |
| 298 | static 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) |
| 265 | 299 | { |
| 266 | 300 | int x,y; |
| 267 | 301 | |
| r15971 | r15972 | |
| 287 | 321 | src_x = (INT32)((h_skw) + (h_scl * x)); |
| 288 | 322 | src_y = (INT32)((v_skw) + (v_scl * x)); |
| 289 | 323 | |
| 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)]; |
| 291 | 328 | |
| 292 | 329 | if(pix != -1) |
| 293 | 330 | if (y1>=0 && y1<224) |
| r15971 | r15972 | |
| 300 | 337 | /* |
| 301 | 338 | x--- ---- ---- ---- [0] LON |
| 302 | 339 | -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 |
| 308 | 345 | ---- ---- --00 ---- |
| 309 | | ---- ---- ---- xxxx BGMAP_BASE |
| 346 | ---- ---- ---- xxxx BGMAP_BASE |
| 310 | 347 | */ |
| 311 | 348 | |
| 312 | 349 | static UINT8 display_world(vboy_state *state, int num, bitmap_ind16 &bitmap, bool right, int &cur_spt) |
| r15971 | r15972 | |
| 318 | 355 | UINT8 mode = (def >> 12) & 3; |
| 319 | 356 | UINT16 scx = 64 << ((def >> 10) & 3); |
| 320 | 357 | UINT16 scy = 64 << ((def >> 8) & 3); |
| 358 | UINT8 ovr = (def >> 7) & 1; |
| 359 | UINT8 end = (def >> 6) & 1; |
| 321 | 360 | INT16 gx = state->m_world[num+1]; |
| 322 | 361 | INT16 gp = state->m_world[num+2]; |
| 323 | 362 | INT16 gy = state->m_world[num+3]; |
| r15971 | r15972 | |
| 327 | 366 | UINT16 w = state->m_world[num+7]; |
| 328 | 367 | UINT16 h = state->m_world[num+8]; |
| 329 | 368 | 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]; |
| 331 | 370 | UINT8 bg_map_num = def & 0x0f; |
| 332 | 371 | UINT16 *vboy_paramtab; |
| 333 | 372 | int i; |
| 334 | 373 | |
| 335 | 374 | vboy_paramtab = state->m_bgmap + param_base; |
| 336 | 375 | |
| 337 | | if(def & 0x40) // END flag |
| 376 | if(end) |
| 338 | 377 | return 1; |
| 339 | 378 | |
| 340 | 379 | if (mode < 2) // Normal / Hbias Mode |
| r15971 | r15972 | |
| 342 | 381 | if(mode == 1) |
| 343 | 382 | popmessage("mode == 1, check"); |
| 344 | 383 | |
| 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 | |
| 345 | 387 | if (lon && (!right)) |
| 346 | 388 | { |
| 347 | 389 | 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); |
| 349 | 391 | } |
| 350 | 392 | |
| 351 | 393 | if (ron && (right)) |
| 352 | 394 | { |
| 353 | 395 | 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); |
| 355 | 397 | } |
| 356 | 398 | } |
| 357 | 399 | else if (mode==2) // Affine Mode |
| 358 | 400 | { |
| 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 | |
| 359 | 404 | if (lon && (!right)) |
| 360 | 405 | { |
| 361 | 406 | 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); |
| 363 | 408 | } |
| 364 | 409 | |
| 365 | 410 | if (ron && (right)) |
| 366 | 411 | { |
| 367 | 412 | 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); |
| 369 | 414 | } |
| 370 | 415 | } |
| 371 | 416 | else if (mode==3) // OBJ Mode |