| Previous | 15994 Revisions | Next |
| r14064 Monday 16th January, 2012 at 15:30:02 UTC by Miodrag Milanović |
|---|
| Sync with MAME r15054 (nw) |
| [src/emu] | delegate.h drawgfxm.h info.c machine.c machine.h render.c render.h rendfont.c rendlay.c screen.c screen.h softlist.c tilemap.c tilemap.h ui.c uigfx.c |
| [src/emu/cpu/arm7] | arm7.c arm7ops.c arm7ops.h arm7thmb.c |
| [src/emu/cpu/i386] | i386.c i386priv.h |
| [src/emu/cpu/tms34010] | tms34010.c |
| [src/emu/debugint] | debugint.c |
| [src/emu/drivers] | empty.c testcpu.c |
| [src/emu/imagedev] | cartslot.h |
| [src/emu/machine] | idectrl.c laserdsc.c laserdsc.h ldpr8210.c ldv1000.c ldvp931.c s3c24xx.c |
| [src/emu/sound] | cdp1869.c |
| [src/emu/video] | crt9007.c hd44102.c i8275.c mc6845.c pc_vga.c psx.c s2636.c tms9927.c upd3301.c v9938.c v9938.h vector.c voodoo.c |
| [src/lib/formats] | ap_dsk35.c |
| [src/lib/util] | bitmap.c bitmap.h |
| [src/mame] | mame.lst mame.mak |
| [src/mame/drivers] | alg.c aristmk6.c atarisy4.c bingor.c ccastles.c cloud9.c cps3.c cybertnk.c dlair.c flyball.c gei.c gpworld.c gunpey.c highvdeo.c hng64.c ichiban.c* igs009.c igs011.c itgambl2.c itgambl3.c jackie.c jantotsu.c kingdrby.c limenko.c luckgrln.c magicard.c majorpkr.c marinedt.c mediagx.c midzeus.c mogura.c namcoic.c naomi.c pcxt.c peplus.c pgm.c pgm2.c progolf.c rabbit.c savquest.c sfbonus.c srmp5.c taitowlf.c thayers.c tickee.c tmmjprd.c tonton.c vamphalf.c zn.c |
| [src/mame/includes] | beathead.h stv.h |
| [src/mame/machine] | megadriv.c n64.c pgmprot.c segamsys.c |
| [src/mame/video] | angelkds.c archimds.c atari.c beathead.c blockout.c bosco.c canyon.c cchasm.c cps1.c dc.c deco32.c deco_mlc.c deniam.c exerion.c galaga.c galastrm.c galaxold.c gp9001.c grchamp.c groundfx.c hng64.c itech32.c jack.c jaguar.c konamigx.c lastduel.c lethalj.c lordgun.c m10.c m107.c m58.c magmax.c mermaid.c midzeus.c midzeus2.c model2.c model3.c namconb1.c namcos1.c namcos22.c nmk16.c pgm.c pitnrun.c pk8000.c policetr.c psikyosh.c psychic5.c rallyx.c realbrk.c redclash.c sega16sp.c segaybd.c senjyo.c shangha3.c skyraid.c sprint2.c ssv.c st0016.c starcrus.c starshp1.c stvvdp1.c stvvdp2.c suprloco.c taito_f2.c taitoic.c tank8.c taotaido.c toaplan1.c toaplan2.c triplhnt.c twin16.c twincobr.c vectrex.c videopin.c warpwarp.c wgp.c xmen.c ygv608.c zac2650.c |
| [src/osd/sdl] | sdlmain.c |
| r14063 | r14064 | |
|---|---|---|
| 4813 | 4813 | smarinef // 2000.03 Sega Marine Fishing |
| 4814 | 4814 | wldkicks // 2000.03 World Kicks |
| 4815 | 4815 | pstone2 // 2000.04 Power Stone 2 |
| 4816 | toukon4 | |
| 4816 | toukon4 | |
| 4817 | 4817 | qmegamis // 2000.05 Quiz Ah Megamisama |
| 4818 | 4818 | derbyo2k // 2000.06 Derby Owners Club 2000 Ver.2 (Rev A) |
| 4819 | 4819 | vonot // 2000.06 Virtual-on Oratorio Tangram M.S.B.S. ver.5.66 2000 Edition |
| r14063 | r14064 | |
| 4887 | 4887 | quizqgd // 2002.?? Quiz Keitai Q mode |
| 4888 | 4888 | shootopl // 2002.?? Shootout Pool |
| 4889 | 4889 | shootpl // 2002.?? Shootout Pool / Shootout Pool Prize (Rev A) |
| 4890 | ||
| 4890 | mtkob2 // 2003.02 MushiKing The King Of Beetle | |
| 4891 | 4891 | // 2003.03 Sega Network Taisen Mahjong MJ |
| 4892 | 4892 | ggxxrl // 2003.03 Guilty Gear XX # Reload (Rev A) |
| 4893 | 4893 | shikgam2 // 2003.04 Shikigami No Shiro II / The Castle of Shikigami II |
| r14063 | r14064 | |
| 10660 | 10660 | bingor4 // (c) 2002 Unknown |
| 10661 | 10661 | bingor5 // (c) 2002 Unknown |
| 10662 | 10662 | galgame // (c) 1971 Computer Recreations, Inc |
| 10663 | ichiban // (c) 199? Excel | |
| 10663 | 10664 | |
| 10664 | 10665 | // InterFlip / Recreativos Franco |
| 10665 | 10666 | videopkr // (c) 1984 InterFlip |
| r14063 | r14064 | |
|---|---|---|
| 378 | 378 | |
| 379 | 379 | // RDRAM Interface (RI) |
| 380 | 380 | |
| 381 | #define RDRAM_CONFIG | |
| 381 | #define RDRAM_CONFIG | |
| 382 | 382 | #define RDRAM_DEVICE_ID (1) |
| 383 | 383 | #define RDRAM_DELAY (2) |
| 384 | 384 | #define RDRAM_MODE (3) |
| r14063 | r14064 | |
| 1336 | 1336 | pi_dma_dir = 0; |
| 1337 | 1337 | pi_status |= 1; |
| 1338 | 1338 | |
| 1339 | attotime dma_period = attotime::from_hz(93750000) * (pi_rd_len + 1) * 3; | |
| 1340 | //printf("want read dma in %d\n", (pi_rd_len + 1)); | |
| 1341 | pi_dma_timer->adjust(dma_period); | |
| 1339 | attotime dma_period = attotime::from_hz(93750000) * (pi_rd_len + 1) * 3; | |
| 1340 | //printf("want read dma in %d\n", (pi_rd_len + 1)); | |
| 1341 | pi_dma_timer->adjust(dma_period); | |
| 1342 | 1342 | break; |
| 1343 | 1343 | } |
| 1344 | 1344 | |
| r14063 | r14064 | |
| 1348 | 1348 | pi_dma_dir = 1; |
| 1349 | 1349 | pi_status |= 1; |
| 1350 | 1350 | |
| 1351 | attotime dma_period = attotime::from_hz(93750000) * (pi_wr_len + 1) * 3; | |
| 1352 | //printf("want write dma in %d\n", (pi_wr_len + 1)); | |
| 1353 | pi_dma_timer->adjust(dma_period); | |
| 1351 | attotime dma_period = attotime::from_hz(93750000) * (pi_wr_len + 1) * 3; | |
| 1352 | //printf("want write dma in %d\n", (pi_wr_len + 1)); | |
| 1353 | pi_dma_timer->adjust(dma_period); | |
| 1354 | 1354 | break; |
| 1355 | 1355 | } |
| 1356 | 1356 |
| r14063 | r14064 | |
|---|---|---|
| 9412 | 9412 | megadrive_sprite_collision=0;//? when to reset this .. |
| 9413 | 9413 | megadrive_imode = MEGADRIVE_REG0C_INTERLEAVE; // can't change mid-frame.. |
| 9414 | 9414 | megadrive_imode_odd_frame^=1; |
| 9415 | // | |
| 9415 | // cputag_set_input_line(machine, "genesis_snd_z80", 0, CLEAR_LINE); // if the z80 interrupt hasn't happened by now, clear it.. | |
| 9416 | 9416 | |
| 9417 | 9417 | if (input_port_read_safe(screen.machine(), "RESET", 0x00) & 0x01) |
| 9418 | 9418 | cputag_set_input_line(screen.machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE); |
| r14063 | r14064 | |
| 9481 | 9481 | case 2:scr_width = 320;break;// configure_screen(0, 320-1, megadrive_visible_scanlines-1,(double)megadriv_framerate); break; /* technically invalid, but used in rare cases */ |
| 9482 | 9482 | case 3:scr_width = 320;break;// configure_screen(0, 320-1, megadrive_visible_scanlines-1,(double)megadriv_framerate); break; |
| 9483 | 9483 | } |
| 9484 | // | |
| 9484 | // mame_printf_debug("my mode %02x", megadrive_vdp_register[0x0c]); | |
| 9485 | 9485 | |
| 9486 | visarea.min_x = 0; | |
| 9487 | visarea.max_x = scr_width-1; | |
| 9488 | visarea.min_y = 0; | |
| 9489 | visarea.max_y = megadrive_visible_scanlines-1; | |
| 9486 | visarea.set(0, scr_width-1, 0, megadrive_visible_scanlines-1); | |
| 9490 | 9487 | |
| 9491 | 9488 | screen.machine().primary_screen->configure(scr_width, megadrive_visible_scanlines, visarea, HZ_TO_ATTOSECONDS(megadriv_framerate)); |
| 9492 | 9489 | |
| 9493 | 9490 | if (0) |
| 9494 | 9491 | { |
| 9495 | 9492 | //int xxx; |
| 9496 | // | |
| 9493 | // UINT64 frametime; | |
| 9497 | 9494 | |
| 9498 | 9495 | // /* reference */ |
| 9499 | // | |
| 9496 | // frametime = ATTOSECONDS_PER_SECOND/megadriv_framerate; | |
| 9500 | 9497 | |
| 9501 | 9498 | //time_elapsed_since_crap = frame_timer->time_elapsed(); |
| 9502 | 9499 | //xxx = screen.machine().device<cpudevice>("maincpu")->attotime_to_cycles(time_elapsed_since_crap); |
| r14063 | r14064 | |
|---|---|---|
| 1150 | 1150 | |
| 1151 | 1151 | if (chip->vdp_type!=GG_VDP) /* In GG mode the Game Gear resolution is fixed */ |
| 1152 | 1152 | { |
| 1153 | rectangle visarea; | |
| 1153 | rectangle visarea(0, 256-1, 0, sms_mode_table[chip->screen_mode].sms2_height-1); | |
| 1154 | 1154 | |
| 1155 | visarea.min_x = 0; | |
| 1156 | visarea.max_x = 256-1; | |
| 1157 | visarea.min_y = 0; | |
| 1158 | visarea.max_y = sms_mode_table[chip->screen_mode].sms2_height-1; | |
| 1159 | ||
| 1160 | 1155 | if (chip->chip_id==3) machine.primary_screen->configure(256, 256, visarea, HZ_TO_ATTOSECONDS(chip->sms_framerate)); |
| 1161 | 1156 | |
| 1162 | 1157 | } |
| 1163 | 1158 | else /* 160x144 */ |
| 1164 | 1159 | { |
| 1165 | rectangle visarea; | |
| 1166 | visarea.min_x = (256-160)/2; | |
| 1167 | visarea.max_x = (256-160)/2+160-1; | |
| 1168 | visarea.min_y = (192-144)/2; | |
| 1169 | visarea.max_y = (192-144)/2+144-1; | |
| 1160 | rectangle visarea((256-160)/2, (256-160)/2+160-1, (192-144)/2, (192-144)/2+144-1); | |
| 1170 | 1161 | |
| 1171 | 1162 | machine.primary_screen->configure(256, 256, visarea, HZ_TO_ATTOSECONDS(chip->sms_framerate)); |
| 1172 | 1163 | } |
| r14063 | r14064 | |
|---|---|---|
| 1163 | 1163 | |
| 1164 | 1164 | kov_value ^= kov_key; |
| 1165 | 1165 | |
| 1166 | // | |
| 1166 | // bprintf (PRINT_NORMAL, _T("ASIC27 command: %2.2x data: %4.4x\n"), (data ^ kov_key) & 0xff, kov_value); | |
| 1167 | 1167 | |
| 1168 | 1168 | switch ((data ^ kov_key) & 0xff) |
| 1169 | 1169 | { |
| r14063 | r14064 | |
| 1282 | 1282 | |
| 1283 | 1283 | default: |
| 1284 | 1284 | kov_response = 0x880000; |
| 1285 | // | |
| 1285 | // bprintf (PRINT_NORMAL, _T("Unknown ASIC27 command: %2.2x data: %4.4x\n"), (data ^ kov_key) & 0xff, kov_value); | |
| 1286 | 1286 | break; |
| 1287 | 1287 | } |
| 1288 | 1288 |
| r14063 | r14064 | |
|---|---|---|
| 20 | 20 | virtual void machine_reset(); |
| 21 | 21 | |
| 22 | 22 | virtual void video_start(); |
| 23 | ||
| 23 | ||
| 24 | 24 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 25 | 25 | |
| 26 | 26 | required_device<asap_device> m_maincpu; |
| r14063 | r14064 | |
|---|---|---|
| 118 | 118 | legacy_cpu_device* m_maincpu; |
| 119 | 119 | legacy_cpu_device* m_slave; |
| 120 | 120 | legacy_cpu_device* m_audiocpu; |
| 121 | ||
| 121 | ||
| 122 | 122 | bitmap_rgb32 m_tmpbitmap; |
| 123 | 123 | }; |
| 124 | 124 |
| r14063 | r14064 | |
|---|---|---|
| 1733 | 1733 | $(DRIVERS)/homedata.o $(VIDEO)/homedata.o \ |
| 1734 | 1734 | $(DRIVERS)/hotblock.o \ |
| 1735 | 1735 | $(DRIVERS)/hotstuff.o \ |
| 1736 | $(DRIVERS)/ichiban.o \ | |
| 1736 | 1737 | $(DRIVERS)/imolagp.o \ |
| 1737 | 1738 | $(DRIVERS)/intrscti.o \ |
| 1738 | 1739 | $(DRIVERS)/istellar.o \ |
| r14063 | r14064 | |
|---|---|---|
| 501 | 501 | { |
| 502 | 502 | deco_mlc_state *state = screen.machine().driver_data<deco_mlc_state>(); |
| 503 | 503 | /* Spriteram is definitely double buffered, as the vram lookup tables |
| 504 | are often updated a frame after spriteram is setup to point to a new | |
| 505 | lookup table. Without buffering incorrect one frame glitches are seen | |
| 506 | in several places, especially in Hoops. | |
| 507 | */ | |
| 504 | are often updated a frame after spriteram is setup to point to a new | |
| 505 | lookup table. Without buffering incorrect one frame glitches are seen | |
| 506 | in several places, especially in Hoops. | |
| 507 | */ | |
| 508 | 508 | memcpy(state->m_mlc_buffered_spriteram, state->m_spriteram, 0x3000); |
| 509 | 509 | } |
| 510 | 510 | } |
| r14063 | r14064 | |
|---|---|---|
| 747 | 747 | const rectangle &visarea = screen.visible_area(); |
| 748 | 748 | |
| 749 | 749 | // clip to the current bitmap |
| 750 | finalclip.min_x = finalclip.min_y = 0; | |
| 751 | finalclip.max_x = screen.width() - 1; | |
| 752 | finalclip.max_y = screen.height() - 1; | |
| 750 | finalclip.set(0, screen.width() - 1, 0, screen.height() - 1); | |
| 753 | 751 | finalclip &= cliprect; |
| 754 | 752 | |
| 755 | 753 | // punt if not initialized |
| r14063 | r14064 | |
|---|---|---|
| 2002 | 2002 | |
| 2003 | 2003 | case 0x0008: |
| 2004 | 2004 | if (VDP1_LOG) logerror ("Sprite List Set Command for User Clipping (%d,%d),(%d,%d)\n", stv2_current_sprite.CMDXA, stv2_current_sprite.CMDYA, stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYC); |
| 2005 | state->m_vdp1.user_cliprect.min_x = stv2_current_sprite.CMDXA; | |
| 2006 | state->m_vdp1.user_cliprect.min_y = stv2_current_sprite.CMDYA; | |
| 2007 | state->m_vdp1.user_cliprect.max_x = stv2_current_sprite.CMDXC; | |
| 2008 | state->m_vdp1.user_cliprect.max_y = stv2_current_sprite.CMDYC; | |
| 2005 | state->m_vdp1.user_cliprect.set(stv2_current_sprite.CMDXA, stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYA, stv2_current_sprite.CMDYC); | |
| 2009 | 2006 | break; |
| 2010 | 2007 | |
| 2011 | 2008 | case 0x0009: |
| 2012 | 2009 | if (VDP1_LOG) logerror ("Sprite List Set Command for System Clipping (0,0),(%d,%d)\n", stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYC); |
| 2013 | state->m_vdp1.system_cliprect.min_x = 0; | |
| 2014 | state->m_vdp1.system_cliprect.min_y = 0; | |
| 2015 | state->m_vdp1.system_cliprect.max_x = stv2_current_sprite.CMDXC; | |
| 2016 | state->m_vdp1.system_cliprect.max_y = stv2_current_sprite.CMDYC; | |
| 2010 | state->m_vdp1.system_cliprect.set(0, stv2_current_sprite.CMDXC, 0, stv2_current_sprite.CMDYC); | |
| 2017 | 2011 | break; |
| 2018 | 2012 | |
| 2019 | 2013 | case 0x000a: |
| r14063 | r14064 | |
| 2178 | 2172 | stv_clear_framebuffer(machine, state->m_vdp1.framebuffer_current_draw); |
| 2179 | 2173 | state->m_vdp1.framebuffer_clear_on_next_frame = 0; |
| 2180 | 2174 | |
| 2181 | state->m_vdp1.system_cliprect.min_x = state->m_vdp1.system_cliprect.max_x = 0; | |
| 2182 | state->m_vdp1.system_cliprect.min_y = state->m_vdp1.system_cliprect.max_y = 0; | |
| 2175 | state->m_vdp1.system_cliprect.set(0, 0, 0, 0); | |
| 2183 | 2176 | /* Kidou Senshi Z Gundam - Zenpen Zeta no Kodou loves to use the user cliprect vars in an undefined state ... */ |
| 2184 | state->m_vdp1.user_cliprect.min_x = 0; | |
| 2185 | state->m_vdp1.user_cliprect.min_y = 0; | |
| 2186 | state->m_vdp1.user_cliprect.max_x = 512; | |
| 2187 | state->m_vdp1.user_cliprect.max_y = 256; | |
| 2177 | state->m_vdp1.user_cliprect.set(0, 512, 0, 256); | |
| 2188 | 2178 | |
| 2189 | 2179 | // save state |
| 2190 | 2180 | state_save_register_global_pointer(machine, state->m_vdp1_regs, 0x020/2); |
| r14063 | r14064 | |
|---|---|---|
| 232 | 232 | sy = 255 - sy; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | if (sy >= cliprect.min_y && sy <= cliprect.max_y && | |
| 236 | sx >= cliprect.min_x && sx <= cliprect.max_x) | |
| 235 | if (cliprect.contains(sx, sy)) | |
| 237 | 236 | bitmap.pix16(sy, sx) = offs < 0x200 ? 512 : 513; |
| 238 | 237 | } |
| 239 | 238 | } |
| r14063 | r14064 | |
|---|---|---|
| 524 | 524 | address_space *space = screen.machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 525 | 525 | |
| 526 | 526 | /* Spriteram is always 1 frame ahead, suggesting spriteram buffering. |
| 527 | There are no CPU output registers that control this so we | |
| 528 | assume it happens automatically every frame, at the end of vblank */ | |
| 527 | There are no CPU output registers that control this so we | |
| 528 | assume it happens automatically every frame, at the end of vblank */ | |
| 529 | 529 | buffer_spriteram16_w(space,0,0,0xffff); |
| 530 | 530 | } |
| 531 | 531 | } |
| r14063 | r14064 | |
|---|---|---|
| 156 | 156 | const rectangle &visarea = screen.machine().primary_screen->visible_area(); |
| 157 | 157 | |
| 158 | 158 | /* |
| 159 | * Collisions are detected for both player cars: | |
| 160 | * | |
| 161 | * D7 => state->m_collision w/ white playfield | |
| 162 | * D6 => state->m_collision w/ black playfield or another car | |
| 163 | * | |
| 164 | */ | |
| 159 | * Collisions are detected for both player cars: | |
| 160 | * | |
| 161 | * D7 => state->m_collision w/ white playfield | |
| 162 | * D6 => state->m_collision w/ black playfield or another car | |
| 163 | * | |
| 164 | */ | |
| 165 | 165 | |
| 166 | 166 | for (i = 0; i < 2; i++) |
| 167 | 167 | { |
| r14063 | r14064 | |
| 172 | 172 | rect.max_x = get_sprite_x(video_ram, i) + screen.machine().gfx[1]->width - 1; |
| 173 | 173 | rect.max_y = get_sprite_y(video_ram, i) + screen.machine().gfx[1]->height - 1; |
| 174 | 174 | |
| 175 | if (rect.min_x < visarea.min_x) | |
| 176 | rect.min_x = visarea.min_x; | |
| 177 | if (rect.min_y < visarea.min_y) | |
| 178 | rect.min_y = visarea.min_y; | |
| 179 | if (rect.max_x > visarea.max_x) | |
| 180 | rect.max_x = visarea.max_x; | |
| 181 | if (rect.max_y > visarea.max_y) | |
| 182 | rect.max_y = visarea.max_y; | |
| 175 | rect &= visarea; | |
| 183 | 176 | |
| 184 | 177 | /* check for sprite-tilemap collisions */ |
| 185 | 178 |
| r14063 | r14064 | |
|---|---|---|
| 351 | 351 | SCREEN_UPDATE_IND16( policetr ) |
| 352 | 352 | { |
| 353 | 353 | policetr_state *state = screen.machine().driver_data<policetr_state>(); |
| 354 | int width = cliprect. | |
| 354 | int width = cliprect.w | |
| 355 | 355 | int y; |
| 356 | 356 | |
| 357 | 357 | /* render all the scanlines from the dstbitmap to MAME's bitmap */ |
| r14063 | r14064 | |
|---|---|---|
| 4223 | 4223 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 4224 | 4224 | |
| 4225 | 4225 | // int window_applied = 0; |
| 4226 | rectangle mycliprect; | |
| 4227 | mycliprect.min_x = cliprect.min_x; | |
| 4228 | mycliprect.max_x = cliprect.max_x; | |
| 4229 | mycliprect.min_y = cliprect.min_y; | |
| 4230 | mycliprect.max_y = cliprect.max_y; | |
| 4226 | rectangle mycliprect = cliprect; | |
| 4231 | 4227 | |
| 4232 | 4228 | if ( stv2_current_tilemap.linescroll_enable || |
| 4233 | 4229 | stv2_current_tilemap.vertical_linescroll_enable || |
| r14063 | r14064 | |
| 5295 | 5291 | stv2_current_tilemap.transparency = STV_TRANSPARENCY_ALPHA; |
| 5296 | 5292 | } |
| 5297 | 5293 | |
| 5298 | mycliprect.min_x = cliprect.min_x; | |
| 5299 | mycliprect.max_x = cliprect.max_x; | |
| 5300 | mycliprect.min_y = cliprect.min_y; | |
| 5301 | mycliprect.max_y = cliprect.max_y; | |
| 5294 | mycliprect = cliprect; | |
| 5302 | 5295 | |
| 5303 | 5296 | if ( window_control ) |
| 5304 | 5297 | { |
| r14063 | r14064 | |
| 5962 | 5955 | |
| 5963 | 5956 | { |
| 5964 | 5957 | int vblank_period,hblank_period; |
| 5965 | rectangle visarea = machine.primary_screen->visible_area(); | |
| 5966 | 5958 | attoseconds_t refresh;; |
| 5967 | visarea.min_x = 0; | |
| 5968 | visarea.max_x = horz_res-1; | |
| 5969 | visarea.min_y = 0; | |
| 5970 | visarea.max_y = vert_res-1; | |
| 5959 | rectangle visarea(0, horz_res-1, 0, vert_res-1); | |
| 5971 | 5960 | |
| 5972 | 5961 | vblank_period = get_vblank_duration(machine); |
| 5973 | 5962 | hblank_period = get_hblank_duration(machine); |
| r14063 | r14064 | |
| 6362 | 6351 | (STV_VDP2_SPW0A * 0x10) | |
| 6363 | 6352 | (STV_VDP2_SPW1A * 0x20) | |
| 6364 | 6353 | (STV_VDP2_SPSWA * 0x40); |
| 6365 | mycliprect.min_x = cliprect.min_x; | |
| 6366 | mycliprect.max_x = cliprect.max_x; | |
| 6367 | mycliprect.min_y = cliprect.min_y; | |
| 6368 | mycliprect.max_y = cliprect.max_y; | |
| 6354 | mycliprect = cliprect; | |
| 6369 | 6355 | |
| 6370 | 6356 | stv_vdp2_apply_window_on_layer(machine,mycliprect); |
| 6371 | 6357 |
| r14063 | r14064 | |
|---|---|---|
| 140 | 140 | INLINE void disable_clipping(itech32_state *state) |
| 141 | 141 | { |
| 142 | 142 | state->m_clip_save = state->m_clip_rect; |
| 143 | ||
| 144 | state->m_clip_rect.min_x = state->m_clip_rect.min_y = 0; | |
| 145 | state->m_clip_rect.max_x = state->m_clip_rect.max_y = 0xfff; | |
| 146 | ||
| 147 | state->m_scaled_clip_rect.min_x = state->m_scaled_clip_rect.min_y = 0; | |
| 148 | state->m_scaled_clip_rect.max_x = state->m_scaled_clip_rect.max_y = 0xfff << 8; | |
| 143 | state->m_clip_rect.set(0, 0xfff, 0, 0xfff); | |
| 144 | state->m_scaled_clip_rect.set(0, 0xfff << 8, 0, 0xfff << 8); | |
| 149 | 145 | } |
| 150 | 146 | |
| 151 | 147 | INLINE void enable_clipping(itech32_state *state) |
| r14063 | r14064 | |
| 561 | 557 | /* render all pixels */ |
| 562 | 558 | sx = startx; |
| 563 | 559 | for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep) |
| 564 | if (ty >= state->m_scaled_clip_rect.min_y && ty < state->m_scaled_clip_rect.max_y && | |
| 565 | sx >= state->m_scaled_clip_rect.min_x && sx < state->m_scaled_clip_rect.max_x) | |
| 560 | if (state->m_scaled_clip_rect.contains(sx, ty)) | |
| 566 | 561 | { |
| 567 | 562 | int pixel = rowsrc[x >> 8]; |
| 568 | 563 | if (pixel != transparent_pen) |
| r14063 | r14064 | |
| 747 | 742 | if (state->m_drivedge_zbuf_control[3] & 0x8000) |
| 748 | 743 | { |
| 749 | 744 | for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep) |
| 750 | if (ty >= state->m_scaled_clip_rect.min_y && ty < state->m_scaled_clip_rect.max_y && | |
| 751 | sx >= state->m_scaled_clip_rect.min_x && sx < state->m_scaled_clip_rect.max_x) | |
| 745 | if (state->m_scaled_clip_rect.contains(sx, ty)) | |
| 752 | 746 | { |
| 753 | 747 | int pixel = rowsrc[x >> 8]; |
| 754 | 748 | if (pixel != transparent_pen) |
| r14063 | r14064 | |
| 762 | 756 | else if (state->m_drivedge_zbuf_control[3] & 0x4000) |
| 763 | 757 | { |
| 764 | 758 | for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep) |
| 765 | if (ty >= state->m_scaled_clip_rect.min_y && ty < state->m_scaled_clip_rect.max_y && | |
| 766 | sx >= state->m_scaled_clip_rect.min_x && sx < state->m_scaled_clip_rect.max_x) | |
| 759 | if (state->m_scaled_clip_rect.contains(sx, ty)) | |
| 767 | 760 | { |
| 768 | 761 | int pixel = rowsrc[x >> 8]; |
| 769 | 762 | UINT16 *zbuf = &zbase[compute_safe_address(state, sx >> 8, ty >> 8)]; |
| r14063 | r14064 | |
| 778 | 771 | else |
| 779 | 772 | { |
| 780 | 773 | for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep) |
| 781 | if (ty >= state->m_scaled_clip_rect.min_y && ty < state->m_scaled_clip_rect.max_y && | |
| 782 | sx >= state->m_scaled_clip_rect.min_x && sx < state->m_scaled_clip_rect.max_x) | |
| 774 | if (state->m_scaled_clip_rect.contains(sx, ty)) | |
| 783 | 775 | { |
| 784 | 776 | int pixel = rowsrc[x >> 8]; |
| 785 | 777 | UINT16 *zbuf = &zbase[compute_safe_address(state, sx >> 8, ty >> 8)]; |
| r14063 | r14064 | |
| 1457 | 1449 | } |
| 1458 | 1450 | |
| 1459 | 1451 | /* draw from the buffer */ |
| 1460 | draw_scanline16(bitmap, cliprect.min_x, y, cliprect. | |
| 1452 | draw_scanline16(bitmap, cliprect.min_x, y, cliprect.w | |
| 1461 | 1453 | } |
| 1462 | 1454 | |
| 1463 | 1455 | /* otherwise, draw directly from VRAM */ |
| 1464 | 1456 | else |
| 1465 | draw_scanline16(bitmap, cliprect.min_x, y, cliprect. | |
| 1457 | draw_scanline16(bitmap, cliprect.min_x, y, cliprect.w | |
| 1466 | 1458 | } |
| 1467 | 1459 | return 0; |
| 1468 | 1460 | } |
| r14063 | r14064 | |
|---|---|---|
| 647 | 647 | // for now we only draw these 2 layers on the last update call |
| 648 | 648 | if (cliprect.max_y == 247) |
| 649 | 649 | { |
| 650 | rectangle clip; | |
| 651 | clip.min_x = cliprect.min_x; | |
| 652 | clip.max_x = cliprect.max_x; | |
| 653 | clip.min_y = 8; | |
| 654 | clip.max_y = 247; | |
| 650 | rectangle clip(cliprect.min_x, cliprect.max_x, 8, 247); | |
| 655 | 651 | |
| 656 | 652 | dragngun_draw_sprites(screen.machine(),bitmap,clip,screen.machine().generic.buffered_spriteram.u32); |
| 657 | 653 | deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, clip, 0, 0); |
| r14063 | r14064 | |
|---|---|---|
| 184 | 184 | |
| 185 | 185 | INLINE void waveram_plot(int y, int x, UINT16 color) |
| 186 | 186 | { |
| 187 | if ( | |
| 187 | if ( | |
| 188 | 188 | WAVERAM_WRITEPIX(zeus_renderbase, y, x, color); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | INLINE void waveram_plot_depth(int y, int x, UINT16 color, UINT16 depth) |
| 192 | 192 | { |
| 193 | if ( | |
| 193 | if ( | |
| 194 | 194 | { |
| 195 | 195 | WAVERAM_WRITEPIX(zeus_renderbase, y, x, color); |
| 196 | 196 | WAVERAM_WRITEDEPTH(zeus_renderbase, y, x, depth); |
| r14063 | r14064 | |
| 199 | 199 | |
| 200 | 200 | INLINE void waveram_plot_check_depth(int y, int x, UINT16 color, UINT16 depth) |
| 201 | 201 | { |
| 202 | if ( | |
| 202 | if ( | |
| 203 | 203 | { |
| 204 | 204 | UINT16 *depthptr = WAVERAM_PTRDEPTH(zeus_renderbase, y, x); |
| 205 | 205 | if (depth <= *depthptr) |
| r14063 | r14064 | |
| 213 | 213 | #ifdef UNUSED_FUNCTION |
| 214 | 214 | INLINE void waveram_plot_check_depth_nowrite(int y, int x, UINT16 color, UINT16 depth) |
| 215 | 215 | { |
| 216 | if ( | |
| 216 | if ( | |
| 217 | 217 | { |
| 218 | 218 | UINT16 *depthptr = WAVERAM_PTRDEPTH(zeus_renderbase, y, x); |
| 219 | 219 | if (depth <= *depthptr) |
| r14063 | r14064 | |
| 743 | 743 | { |
| 744 | 744 | int vtotal = zeusbase[0xca] >> 16; |
| 745 | 745 | int htotal = zeusbase[0xc6] >> 16; |
| 746 | rectangle visarea; | |
| 747 | 746 | |
| 748 | visarea.min_x = zeusbase[0xc6] & 0xffff; | |
| 749 | visarea.max_x = htotal - 3; | |
| 750 | visarea.min_y = 0; | |
| 751 | visarea.max_y = zeusbase[0xc8] & 0xffff; | |
| 747 | rectangle visarea(zeusbase[0xc6] & 0xffff, htotal - 3, 0, zeusbase[0xc8] & 0xffff); | |
| 752 | 748 | if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal) |
| 753 | 749 | { |
| 754 | 750 | machine.primary_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 8.0 / (htotal * vtotal))); |
| r14063 | r14064 | |
|---|---|---|
| 148 | 148 | if( pixel != sprite_transp ){ |
| 149 | 149 | sx = x+x0; |
| 150 | 150 | sy = y+y0; |
| 151 | if( (sx >= visarea->min_x) && (sx <= visarea->max_x) && | |
| 152 | (sy >= visarea->min_y) && (sy <= visarea->max_y) ) | |
| 151 | if(visarea->contains(sx, sy)) | |
| 153 | 152 | { |
| 154 | 153 | // Collision check uses only 16 pens! |
| 155 | 154 | pixel = bitmap.pix16(sy, sx) % 16; |
| r14063 | r14064 | |
|---|---|---|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /* draw the yboard sprites */ |
| 55 | yboard_clip.min_x = yboard_clip.min_y = 0; | |
| 56 | yboard_clip.max_x = yboard_clip.max_y = 511; | |
| 55 | yboard_clip.set(0, 511, 0, 511); | |
| 57 | 56 | segaic16_sprites_draw(screen, *state->m_tmp_bitmap, yboard_clip, 1); |
| 58 | 57 | |
| 59 | 58 | /* apply rotation */ |
| r14063 | r14064 | |
|---|---|---|
| 57 | 57 | int color = val / 32; |
| 58 | 58 | int count = val % 32; |
| 59 | 59 | |
| 60 | rectangle r; | |
| 60 | rectangle r(x, x + 31 - count, y, y+ 1); | |
| 61 | 61 | |
| 62 | r.min_y = y; | |
| 63 | r.min_x = x; | |
| 64 | r.max_y = y + 1; | |
| 65 | r.max_x = x + 31 - count; | |
| 66 | ||
| 67 | 62 | bitmap.fill(color, r); |
| 68 | 63 | |
| 69 | 64 | x += 32 - count; |
| r14063 | r14064 | |
|---|---|---|
| 269 | 269 | { |
| 270 | 270 | if (rom[i] & 0x0f) |
| 271 | 271 | { |
| 272 | if (sx + x >= cliprect.min_x && sx + x <= cliprect.max_x && | |
| 273 | y >= cliprect.min_y && y <= cliprect.max_y) | |
| 272 | if (cliprect.contains(sx + x, y)) | |
| 274 | 273 | { |
| 275 | 274 | if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 276 | 275 | bitmap.pix16(y, sx + x) = color * 16 + (rom[i] & 0x0f); |
| r14063 | r14064 | |
| 289 | 288 | { |
| 290 | 289 | if (rom[i] & 0xf0) |
| 291 | 290 | { |
| 292 | if (sx + x >= cliprect.min_x && sx + x <= cliprect.max_x && | |
| 293 | y >= cliprect.min_y && y <= cliprect.max_y) | |
| 291 | if (cliprect.contains(sx + x, y)) | |
| 294 | 292 | { |
| 295 | 293 | if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 296 | 294 | bitmap.pix16(y, sx + x) = color * 16+(rom[i] >> 4); |
| r14063 | r14064 | |
| 313 | 311 | { |
| 314 | 312 | if (rom[i] & 0xf0) |
| 315 | 313 | { |
| 316 | if (sx + x >= cliprect.min_x && sx + x <= cliprect.max_x && | |
| 317 | y >= cliprect.min_y && y <= cliprect.max_y) | |
| 314 | if (cliprect.contains(sx + x, y)) | |
| 318 | 315 | { |
| 319 | 316 | if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 320 | 317 | bitmap.pix16(y, sx + x) = color * 16 + (rom[i] >> 4); |
| r14063 | r14064 | |
| 333 | 330 | { |
| 334 | 331 | if (rom[i] & 0x0f) |
| 335 | 332 | { |
| 336 | if (sx + x >= cliprect.min_x && sx + x <= cliprect.max_x && | |
| 337 | y >= cliprect.min_y && y <= cliprect.max_y) | |
| 333 | if (cliprect.contains(sx + x, y)) | |
| 338 | 334 | { |
| 339 | 335 | if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 340 | 336 | bitmap.pix16(y, sx + x) = color * 16 + (rom[i] & 0x0f); |
| r14063 | r14064 | |
|---|---|---|
| 158 | 158 | |
| 159 | 159 | for (i = 0; i < 8; i++) |
| 160 | 160 | { |
| 161 | rectangle rect; | |
| 162 | ||
| 163 | 161 | int x = get_x_pos(state, 8 + i); |
| 164 | 162 | int y = get_y_pos(state, 8 + i); |
| 165 | 163 | |
| 166 | 164 | x -= 4; /* ? */ |
| 167 | 165 | |
| 168 | rect.min_x = x; | |
| 169 | rect.min_y = y; | |
| 170 | rect.max_x = rect.min_x + 3; | |
| 171 | rect.max_y = rect.min_y + 4; | |
| 166 | rectangle rect(x, x + 3, y, y + 4); | |
| 167 | rect &= cliprect; | |
| 172 | 168 | |
| 173 | if (rect.min_x < cliprect.min_x) | |
| 174 | rect.min_x = cliprect.min_x; | |
| 175 | if (rect.min_y < cliprect.min_y) | |
| 176 | rect.min_y = cliprect.min_y; | |
| 177 | if (rect.max_x > cliprect.max_x) | |
| 178 | rect.max_x = cliprect.max_x; | |
| 179 | if (rect.max_y > cliprect.max_y) | |
| 180 | rect.max_y = cliprect.max_y; | |
| 181 | ||
| 182 | 169 | bitmap.fill((i << 1) | 0x01, rect); |
| 183 | 170 | } |
| 184 | 171 | } |
| r14063 | r14064 | |
|---|---|---|
| 506 | 506 | { |
| 507 | 507 | UINT16 *dsti = &bitmap.pix16(y, x); |
| 508 | 508 | UINT8 *dstp = &priority.pix8(y, x); |
| 509 | int length = cliprect. | |
| 509 | int length = cliprect.w | |
| 510 | 510 | |
| 511 | 511 | src += cliprect.min_x; |
| 512 | 512 | dsti += cliprect.min_x; |
| r14063 | r14064 | |
| 2352 | 2352 | src_x = (256 - 64 - src_x) & width_mask; |
| 2353 | 2353 | |
| 2354 | 2354 | // Col offsets are 'tilemap' space 0-511, and apply to blocks of 8 pixels at once |
| 2355 | for (x = 0; x < | |
| 2355 | for (x = 0; x < | |
| 2356 | 2356 | { |
| 2357 | 2357 | column_offset = tc0100scn->colscroll_ram[(src_x & 0x3ff) / 8]; |
| 2358 | 2358 | p = src_bitmap.pix16((src_y - column_offset) & height_mask, src_x); |
| r14063 | r14064 | |
| 3264 | 3264 | int x_index, x_step; |
| 3265 | 3265 | int machine_flip = 0; /* for ROT 180 ? */ |
| 3266 | 3266 | |
| 3267 | UINT16 screen_width = 512; //cliprect. | |
| 3267 | UINT16 screen_width = 512; //cliprect.w | |
| 3268 | 3268 | UINT16 min_y = cliprect.min_y; |
| 3269 | 3269 | UINT16 max_y = cliprect.max_y; |
| 3270 | 3270 | |
| r14063 | r14064 | |
| 3400 | 3400 | int flipscreen = tc0480scp->pri_reg & 0x40; |
| 3401 | 3401 | int machine_flip = 0; /* for ROT 180 ? */ |
| 3402 | 3402 | |
| 3403 | UINT16 screen_width = 512; //cliprect. | |
| 3403 | UINT16 screen_width = 512; //cliprect.w | |
| 3404 | 3404 | UINT16 min_y = cliprect.min_y; |
| 3405 | 3405 | UINT16 max_y = cliprect.max_y; |
| 3406 | 3406 |
| r14063 | r14064 | |
|---|---|---|
| 2723 | 2723 | |
| 2724 | 2724 | col = ((col & 0xe0) >> 1) + (screen.frame_number() / 16 & 0x0f); |
| 2725 | 2725 | |
| 2726 | if (sx >= cliprect.min_x && sx <= cliprect.max_x && | |
| 2727 | sy >= cliprect.min_y && sy <= cliprect.max_y) | |
| 2726 | if (cliprect.contains(sx, sy)) | |
| 2728 | 2727 | bitmap.pix16(sy, sx) = 0xa00 + col; |
| 2729 | 2728 | } |
| 2730 | 2729 | } |
| r14063 | r14064 | |
| 2749 | 2748 | |
| 2750 | 2749 | col = ((col & 0xe0) >> 1) + (screen.frame_number() / 16 & 0x0f); |
| 2751 | 2750 | |
| 2752 | if (sx >= cliprect.min_x && sx <= cliprect.max_x && | |
| 2753 | sy >= cliprect.min_y && sy <= cliprect.max_y) | |
| 2751 | if (cliprect.contains(sx, sy)) | |
| 2754 | 2752 | bitmap.pix16(sy, sx) = 0x800 + col; |
| 2755 | 2753 | } |
| 2756 | 2754 | } |
| r14063 | r14064 | |
|---|---|---|
| 167 | 167 | starcrus_state *state = machine.driver_data<starcrus_state>(); |
| 168 | 168 | int org_x, org_y; |
| 169 | 169 | int sx, sy; |
| 170 | rectangle clip; | |
| 170 | rectangle clip(0, 15, 0, 15); | |
| 171 | 171 | |
| 172 | clip.min_x=0; | |
| 173 | clip.max_x=15; | |
| 174 | clip.min_y=0; | |
| 175 | clip.max_y=15; | |
| 176 | ||
| 177 | 172 | state->m_ship1_vid->fill(0, clip); |
| 178 | 173 | state->m_ship2_vid->fill(0, clip); |
| 179 | 174 | |
| r14063 | r14064 | |
| 215 | 210 | starcrus_state *state = machine.driver_data<starcrus_state>(); |
| 216 | 211 | int org_x, org_y; |
| 217 | 212 | int sx, sy; |
| 218 | rectangle clip; | |
| 213 | rectangle clip(0, 15, 0, 15); | |
| 219 | 214 | |
| 220 | 215 | /* if both are scores, return */ |
| 221 | 216 | if ( ((state->m_p1_sprite & 0x08) == 0) && |
| r14063 | r14064 | |
| 224 | 219 | return 0; |
| 225 | 220 | } |
| 226 | 221 | |
| 227 | clip.min_x=0; | |
| 228 | clip.max_x=15; | |
| 229 | clip.min_y=0; | |
| 230 | clip.max_y=15; | |
| 231 | ||
| 232 | 222 | state->m_proj1_vid->fill(0, clip); |
| 233 | 223 | state->m_proj2_vid->fill(0, clip); |
| 234 | 224 | |
| r14063 | r14064 | |
| 276 | 266 | starcrus_state *state = machine.driver_data<starcrus_state>(); |
| 277 | 267 | int org_x, org_y; |
| 278 | 268 | int sx, sy; |
| 279 | rectangle clip; | |
| 269 | rectangle clip(0, 15, 0, 15); | |
| 280 | 270 | |
| 281 | 271 | /* if both are scores, return */ |
| 282 | 272 | if ( ((state->m_p1_sprite & 0x08) == 0) && |
| r14063 | r14064 | |
| 285 | 275 | return 0; |
| 286 | 276 | } |
| 287 | 277 | |
| 288 | clip.min_x=0; | |
| 289 | clip.max_x=15; | |
| 290 | clip.min_y=0; | |
| 291 | clip.max_y=15; | |
| 292 | ||
| 293 | 278 | state->m_ship1_vid->fill(0, clip); |
| 294 | 279 | state->m_proj1_vid->fill(0, clip); |
| 295 | 280 | state->m_proj2_vid->fill(0, clip); |
| r14063 | r14064 | |
| 353 | 338 | starcrus_state *state = machine.driver_data<starcrus_state>(); |
| 354 | 339 | int org_x, org_y; |
| 355 | 340 | int sx, sy; |
| 356 | rectangle clip; | |
| 341 | rectangle clip(0, 15, 0, 15); | |
| 357 | 342 | |
| 358 | 343 | /* if both are scores, return */ |
| 359 | 344 | if ( ((state->m_p1_sprite & 0x08) == 0) && |
| r14063 | r14064 | |
| 362 | 347 | return 0; |
| 363 | 348 | } |
| 364 | 349 | |
| 365 | clip.min_x=0; | |
| 366 | clip.max_x=15; | |
| 367 | clip.min_y=0; | |
| 368 | clip.max_y=15; | |
| 369 | ||
| 370 | 350 | state->m_ship2_vid->fill(0, clip); |
| 371 | 351 | state->m_proj1_vid->fill(0, clip); |
| 372 | 352 | state->m_proj2_vid->fill(0, clip); |
| r14063 | r14064 | |
|---|---|---|
| 316 | 316 | rect.max_x = sx + screen.machine().gfx[1]->width - 1; |
| 317 | 317 | rect.max_y = sy + screen.machine().gfx[1]->height - 1; |
| 318 | 318 | |
| 319 | if (rect.min_x < visarea.min_x) | |
| 320 | rect.min_x = visarea.min_x; | |
| 321 | if (rect.min_y < visarea.min_y) | |
| 322 | rect.min_y = visarea.min_y; | |
| 323 | if (rect.max_x > visarea.max_x) | |
| 324 | rect.max_x = visarea.max_x; | |
| 325 | if (rect.max_y > visarea.max_y) | |
| 326 | rect.max_y = visarea.max_y; | |
| 319 | rect &= visarea; | |
| 327 | 320 | |
| 328 | 321 | // check collision sprite - background |
| 329 | 322 | |
| r14063 | r14064 | |
| 426 | 419 | rect.max_x = sx + screen.machine().gfx[1]->width - 1; |
| 427 | 420 | rect.max_y = sy + screen.machine().gfx[1]->height - 1; |
| 428 | 421 | |
| 429 | if (rect.min_x < visarea.min_x) | |
| 430 | rect.min_x = visarea.min_x; | |
| 431 | if (rect.min_y < visarea.min_y) | |
| 432 | rect.min_y = visarea.min_y; | |
| 433 | if (rect.max_x > visarea.max_x) | |
| 434 | rect.max_x = visarea.max_x; | |
| 435 | if (rect.max_y > visarea.max_y) | |
| 436 | rect.max_y = visarea.max_y; | |
| 422 | rect &= visarea; | |
| 437 | 423 | |
| 438 | 424 | // check collision sprite - sprite |
| 439 | 425 | |
| r14063 | r14064 | |
| 514 | 500 | rect.max_x = sx + screen.machine().gfx[1]->width - 1; |
| 515 | 501 | rect.max_y = sy + screen.machine().gfx[1]->height - 1; |
| 516 | 502 | |
| 517 | if (rect.min_x < visarea.min_x) | |
| 518 | rect.min_x = visarea.min_x; | |
| 519 | if (rect.min_y < visarea.min_y) | |
| 520 | rect.min_y = visarea.min_y; | |
| 521 | if (rect.max_x > visarea.max_x) | |
| 522 | rect.max_x = visarea.max_x; | |
| 523 | if (rect.max_y > visarea.max_y) | |
| 524 | rect.max_y = visarea.max_y; | |
| 525 | ||
| 503 | rect &= visarea; | |
| 504 | ||
| 526 | 505 | // check collision sprite - sprite |
| 527 | 506 | |
| 528 | 507 | state->m_helper.fill(0, rect); |
| r14063 | r14064 | |
|---|---|---|
| 24 | 24 | { |
| 25 | 25 | static const char *const gunnames[] = { "LIGHT0_X", "LIGHT0_Y", "LIGHT1_X", "LIGHT1_Y" }; |
| 26 | 26 | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 27 | int width = visarea.max_x + 1 - visarea.min_x; | |
| 28 | int height = visarea.max_y + 1 - visarea.min_y; | |
| 27 | int width = visarea.width(); | |
| 28 | int height = visarea.height(); | |
| 29 | 29 | |
| 30 | 30 | *x = ((input_port_read_safe(machine, gunnames[player * 2], 0x00) & 0xff) * width) / 255; |
| 31 | 31 | *y = ((input_port_read_safe(machine, gunnames[1 + player * 2], 0x00) & 0xff) * height) / 255; |
| r14063 | r14064 | |
|---|---|---|
| 143 | 143 | clip.min_y = (yclip>>16) - 0x21; |
| 144 | 144 | clip.max_y = (yclip&0xffff) - 0x21 - 1; |
| 145 | 145 | /* intersect with master clip rectangle */ |
| 146 | if( clip.min_x < cliprect.min_x ){ clip.min_x = cliprect.min_x; } | |
| 147 | if( clip.min_y < cliprect.min_y ){ clip.min_y = cliprect.min_y; } | |
| 148 | if( clip.max_x > cliprect.max_x ){ clip.max_x = cliprect.max_x; } | |
| 149 | if( clip.max_y > cliprect.max_y ){ clip.max_y = cliprect.max_y; } | |
| 146 | clip &= cliprect; | |
| 150 | 147 | |
| 151 | 148 | bitmap.fill(get_black_pen(screen.machine()), cliprect ); |
| 152 | 149 | |
| r14063 | r14064 | |
| 184 | 181 | clip.min_y = (yclip>>16) - 0x21; |
| 185 | 182 | clip.max_y = (yclip&0xffff) - 0x21 - 1; |
| 186 | 183 | /* intersect with master clip rectangle */ |
| 187 | if( clip.min_x < cliprect.min_x ){ clip.min_x = cliprect.min_x; } | |
| 188 | if( clip.min_y < cliprect.min_y ){ clip.min_y = cliprect.min_y; } | |
| 189 | if( clip.max_x > cliprect.max_x ){ clip.max_x = cliprect.max_x; } | |
| 190 | if( clip.max_y > cliprect.max_y ){ clip.max_y = cliprect.max_y; } | |
| 184 | clip &= cliprect; | |
| 191 | 185 | |
| 192 | 186 | bitmap.fill(get_black_pen(screen.machine()), cliprect ); |
| 193 | 187 |
| r14063 | r14064 | |
|---|---|---|
| 928 | 928 | poly_manager *poly = state->m_poly; |
| 929 | 929 | poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(poly); |
| 930 | 930 | UINT8 renderer; |
| 931 | rectangle vp; | |
| 932 | 931 | |
| 933 | 932 | /* select renderer based on attributes (bit15 = checker, bit14 = textured, bit13 = transparent */ |
| 934 | 933 | renderer = (tri->texheader[0] >> 13) & 7; |
| 935 | 934 | |
| 936 | 935 | /* calculate and clip to viewport */ |
| 937 | vp.min_x = tri->viewport[0] - 8; | |
| 938 | vp.max_x = tri->viewport[2] - 8; | |
| 939 | vp.min_y = (384-tri->viewport[3])+90; | |
| 940 | vp.max_y = (384-tri->viewport[1])+90; | |
| 936 | rectangle vp(tri->viewport[0] - 8, tri->viewport[2] - 8, (384-tri->viewport[3])+90, (384-tri->viewport[1])+90); | |
| 937 | vp &= cliprect; | |
| 941 | 938 | |
| 942 | if ( vp.min_x < cliprect.min_x ) vp.min_x = cliprect.min_x; | |
| 943 | if ( vp.max_x > cliprect.max_x ) vp.max_x = cliprect.max_x; | |
| 944 | if ( vp.min_y < cliprect.min_y ) vp.min_y = cliprect.min_y; | |
| 945 | if ( vp.max_y > cliprect.max_y ) vp.max_y = cliprect.max_y; | |
| 946 | ||
| 947 | 939 | extra->state = state; |
| 948 | 940 | extra->lumabase = ((tri->texheader[1] & 0xFF) << 7) + ((tri->luma >> 5) ^ 0x7); |
| 949 | 941 | extra->colorbase = (tri->texheader[3] >> 6) & 0x3FF; |
| r14063 | r14064 | |
| 2712 | 2704 | { |
| 2713 | 2705 | model2_state *state = machine.driver_data<model2_state>(); |
| 2714 | 2706 | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 2715 | int width = visarea.max_x - visarea.min_x; | |
| 2716 | int height = visarea.max_y - visarea.min_y; | |
| 2707 | int width = visarea.width(); | |
| 2708 | int height = visarea.height(); | |
| 2717 | 2709 | |
| 2718 | 2710 | state->m_sys24_bitmap.allocate(width, height+4); |
| 2719 | 2711 |
| r14063 | r14064 | |
|---|---|---|
| 211 | 211 | |
| 212 | 212 | lorddgun_calc_gun_scr(machine, i); |
| 213 | 213 | |
| 214 | if ( (state->m_gun[i].scr_x < visarea.min_x) || | |
| 215 | (state->m_gun[i].scr_x > visarea.max_x) || | |
| 216 | (state->m_gun[i].scr_y < visarea.min_y) || | |
| 217 | (state->m_gun[i].scr_y > visarea.max_y) ) | |
| 214 | if (!visarea.contains(state->m_gun[i].scr_x, state->m_gun[i].scr_y)) | |
| 218 | 215 | state->m_gun[i].hw_x = state->m_gun[i].hw_y = 0; |
| 219 | 216 | } |
| 220 | 217 |
| r14063 | r14064 | |
|---|---|---|
| 1094 | 1094 | { |
| 1095 | 1095 | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 1096 | 1096 | |
| 1097 | sx_base = ((visarea.max_x + 1) - visarea.min_x) - (sx_base + 8); /* visarea.x = 320 */ | |
| 1098 | sy_base = ((visarea.max_y + 1) - visarea.min_y) - (sy_base + 8); /* visarea.y = 240 */ | |
| 1099 | sy_base += ((visarea.max_y + 1) - ((visarea.max_y + 1) - visarea.min_y)) * 2; /* Horizontal games are offset so adjust by +0x20 */ | |
| 1097 | sx_base = visarea.width() - (sx_base + 8); /* visarea.x = 320 */ | |
| 1098 | sy_base = visarea.height() - (sy_base + 8); /* visarea.y = 240 */ | |
| 1099 | sy_base += ((visarea.max_y + 1) - visarea.height()) * 2; /* Horizontal games are offset so adjust by +0x20 */ | |
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | 1102 | for (dim_y = 0; dim_y < sprite_sizey; dim_y += 8) |
| r14063 | r14064 | |
|---|---|---|
| 1085 | 1085 | { |
| 1086 | 1086 | if ((state_ta.grab[a].ispbase == state->pvrta_regs[PARAM_BASE]) && (state_ta.grab[a].valid == 1) && (state_ta.grab[a].busy == 0)) |
| 1087 | 1087 | { |
| 1088 | rectangle clip; | |
| 1089 | ||
| 1090 | 1088 | state_ta.grab[a].busy = 1; |
| 1091 | 1089 | state_ta.renderselect = a; |
| 1092 | 1090 | state_ta.start_render_received=1; |
| r14063 | r14064 | |
| 1095 | 1093 | state_ta.grab[a].fbwsof1=state->pvrta_regs[FB_W_SOF1]; |
| 1096 | 1094 | state_ta.grab[a].fbwsof2=state->pvrta_regs[FB_W_SOF2]; |
| 1097 | 1095 | |
| 1098 | clip.min_x = 0; | |
| 1099 | clip.max_x = 1023; | |
| 1100 | clip.min_y = 0; | |
| 1101 | clip.max_y = 1023; | |
| 1096 | rectangle clip(0, 1023, 0, 1023); | |
| 1102 | 1097 | |
| 1103 | 1098 | // we've got a request to draw, so, draw to the accumulation buffer! |
| 1104 | 1099 | // this should really be done for each tile! |
| r14063 | r14064 | |
|---|---|---|
| 259 | 259 | if (flip_screen_y_get(screen.machine())) |
| 260 | 260 | dy=128-dy; |
| 261 | 261 | |
| 262 | myclip.min_x=dx; | |
| 263 | myclip.min_y=dy; | |
| 264 | myclip.max_x=dx+127; | |
| 265 | myclip.max_y=dy+127; | |
| 262 | myclip.set(dx, dx+127, dy, dy+127); | |
| 263 | myclip &= cliprect; | |
| 266 | 264 | |
| 267 | ||
| 268 | if(myclip.min_y<cliprect.min_y)myclip.min_y=cliprect.min_y; | |
| 269 | if(myclip.min_x<cliprect.min_x)myclip.min_x=cliprect.min_x; | |
| 270 | ||
| 271 | if(myclip.max_y>cliprect.max_y)myclip.max_y=cliprect.max_y; | |
| 272 | if(myclip.max_x>cliprect.max_x)myclip.max_x=cliprect.max_x; | |
| 273 | ||
| 274 | 265 | tilemap_draw(bitmap,myclip,state->m_bg, 0,0); |
| 275 | 266 | } |
| 276 | 267 |
| r14063 | r14064 | |
|---|---|---|
| 187 | 187 | #ifdef UNUSED_FUNCTION |
| 188 | 188 | INLINE void waveram_plot(int y, int x, UINT32 color) |
| 189 | 189 | { |
| 190 | if ( | |
| 190 | if ( | |
| 191 | 191 | WAVERAM_WRITEPIX(zeus_renderbase, y, x, color); |
| 192 | 192 | } |
| 193 | 193 | #endif |
| 194 | 194 | |
| 195 | 195 | INLINE void waveram_plot_depth(int y, int x, UINT32 color, UINT16 depth) |
| 196 | 196 | { |
| 197 | if ( | |
| 197 | if ( | |
| 198 | 198 | { |
| 199 | 199 | WAVERAM_WRITEPIX(zeus_renderbase, y, x, color); |
| 200 | 200 | WAVERAM_WRITEDEPTH(zeus_renderbase, y, x, depth); |
| r14063 | r14064 | |
| 204 | 204 | #ifdef UNUSED_FUNCTION |
| 205 | 205 | INLINE void waveram_plot_check_depth(int y, int x, UINT32 color, UINT16 depth) |
| 206 | 206 | { |
| 207 | if ( | |
| 207 | if ( | |
| 208 | 208 | { |
| 209 | 209 | UINT16 *depthptr = WAVERAM_PTRDEPTH(zeus_renderbase, y, x); |
| 210 | 210 | if (depth <= *depthptr) |
| r14063 | r14064 | |
| 219 | 219 | #ifdef UNUSED_FUNCTION |
| 220 | 220 | INLINE void waveram_plot_check_depth_nowrite(int y, int x, UINT32 color, UINT16 depth) |
| 221 | 221 | { |
| 222 | if ( | |
| 222 | if ( | |
| 223 | 223 | { |
| 224 | 224 | UINT16 *depthptr = WAVERAM_PTRDEPTH(zeus_renderbase, y, x); |
| 225 | 225 | if (depth <= *depthptr) |
| r14063 | r14064 | |
| 564 | 564 | { |
| 565 | 565 | int vtotal = zeusbase[0x37] & 0xffff; |
| 566 | 566 | int htotal = zeusbase[0x34] >> 16; |
| 567 | rectangle visarea; | |
| 568 | 567 | |
| 569 | visarea.min_x = zeusbase[0x33] >> 16; | |
| 570 | visarea.max_x = (zeusbase[0x34] & 0xffff) - 1; | |
| 571 | visarea.min_y = 0; | |
| 572 | visarea.max_y = zeusbase[0x35] & 0xffff; | |
| 568 | rectangle visarea(zeusbase[0x33] >> 16, (zeusbase[0x34] & 0xffff) - 1, 0, zeusbase[0x35] & 0xffff); | |
| 573 | 569 | if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal) |
| 574 | 570 | { |
| 575 | 571 | machine.primary_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 4.0 / (htotal * vtotal))); |
| r14063 | r14064 | |
|---|---|---|
| 357 | 357 | #endif |
| 358 | 358 | state->m_screen_clip = (rectangle*)&cliprect; |
| 359 | 359 | |
| 360 | state->m_clip3d.min_x = cliprect.min_x; | |
| 361 | state->m_clip3d.max_x = cliprect.max_x; | |
| 362 | state->m_clip3d.min_y = cliprect.min_y; | |
| 363 | state->m_clip3d.max_y = cliprect.max_y; | |
| 360 | state->m_clip3d = cliprect; | |
| 364 | 361 | |
| 365 | 362 | /* layer disable debug keys */ |
| 366 | 363 | state->m_tick++; |
| r14063 | r14064 | |
|---|---|---|
| 31 | 31 | { |
| 32 | 32 | if (!(destpri[xdrawpos]&2)) |
| 33 | 33 | { |
| 34 | dest[xdrawpos] = srcdat; | |
| 35 | } | |
| 34 | dest[xdrawpos] = srcdat; | |
| 35 | } | |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| r14063 | r14064 | |
| 60 | 60 | { |
| 61 | 61 | if (!(destpri[xdrawpos]&2)) |
| 62 | 62 | { |
| 63 | dest[xdrawpos] = srcdat; | |
| 64 | } | |
| 63 | dest[xdrawpos] = srcdat; | |
| 64 | } | |
| 65 | 65 | } |
| 66 | 66 | destpri[xdrawpos]|=1; |
| 67 | 67 | } |
| r14063 | r14064 | |
| 114 | 114 | xdrawpos = xpos + xcntdraw; |
| 115 | 115 | else |
| 116 | 116 | xdrawpos = xpos + realxsize - xcntdraw; |
| 117 | ||
| 117 | ||
| 118 | 118 | pgm_draw_pix(xdrawpos, pri, dest, destpri, srcdat); |
| 119 | 119 | |
| 120 | 120 | xcntdraw++; |
| r14063 | r14064 | |
| 125 | 125 | xdrawpos = xpos + realxsize - xcntdraw; |
| 126 | 126 | |
| 127 | 127 | pgm_draw_pix(xdrawpos, pri, dest, destpri, srcdat); |
| 128 | ||
| 128 | ||
| 129 | 129 | xcntdraw++; |
| 130 | 130 | } |
| 131 | 131 | else if (xzoombit == 1 && xgrow == 0) |
| r14063 | r14064 | |
| 140 | 140 | xdrawpos = xpos + realxsize - xcntdraw; |
| 141 | 141 | |
| 142 | 142 | pgm_draw_pix(xdrawpos, pri, dest, destpri, srcdat); |
| 143 | ||
| 143 | ||
| 144 | 144 | xcntdraw++; |
| 145 | 145 | } |
| 146 | 146 | } |
| r14063 | r14064 | |
| 184 | 184 | |
| 185 | 185 | /* precalculate where drawing will end, for flipped zoomed cases. */ |
| 186 | 186 | /* if we're to avoid pre-decoding the data for each sprite each time we draw then we have to draw the sprite data |
| 187 | in the order it is in ROM due to the nature of the compresson scheme. This means drawing upwards from the end point | |
| 188 | in the case of flipped sprites */ | |
| 187 | in the order it is in ROM due to the nature of the compresson scheme. This means drawing upwards from the end point | |
| 188 | in the case of flipped sprites */ | |
| 189 | 189 | ycnt = 0; |
| 190 | 190 | ycntdraw = 0; |
| 191 | 191 | int realysize = 0; |
| r14063 | r14064 | |
| 227 | 227 | { |
| 228 | 228 | int temp_aoffset = state->m_aoffset; |
| 229 | 229 | int temp_boffset = state->m_boffset; |
| 230 | ||
| 230 | ||
| 231 | 231 | if (!(flip & 0x02)) |
| 232 | 232 | ydrawpos = ypos + ycntdraw; |
| 233 | 233 | else |
| r14063 | r14064 | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | ycntdraw++; |
| 248 | ||
| 248 | ||
| 249 | 249 | // we need to draw this line again, so restore our pointers to previous values |
| 250 | 250 | state->m_aoffset = temp_aoffset; |
| 251 | 251 | state->m_boffset = temp_boffset; |
| r14063 | r14064 | |
| 301 | 301 | else |
| 302 | 302 | { |
| 303 | 303 | draw_sprite_line(machine, wide, NULL, NULL, xzoom, xgrow, flip, xpos, pri, realxsize, palt, 0); |
| 304 | ||
| 304 | ||
| 305 | 305 | if (!(flip & 0x02)) |
| 306 | 306 | { |
| 307 | 307 | if (ydrawpos>224) |
| r14063 | r14064 | |
| 312 | 312 | if (ydrawpos<0) |
| 313 | 313 | return; |
| 314 | 314 | } |
| 315 | ||
| 315 | ||
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | ycntdraw++; |
| r14063 | r14064 | |
| 363 | 363 | xdrawpos = xpos + realxsize - xcntdraw; |
| 364 | 364 | |
| 365 | 365 | pgm_draw_pix_nopri(xdrawpos, dest, destpri, srcdat); |
| 366 | ||
| 366 | ||
| 367 | 367 | xcntdraw++; |
| 368 | 368 | } |
| 369 | 369 | |
| r14063 | r14064 | |
| 405 | 405 | xdrawpos = xpos + realxsize - xcntdraw; |
| 406 | 406 | |
| 407 | 407 | pgm_draw_pix_pri(xdrawpos, dest, destpri, srcdat); |
| 408 | ||
| 408 | ||
| 409 | 409 | xcntdraw++; |
| 410 | 410 | } |
| 411 | 411 | |
| r14063 | r14064 | |
| 452 | 452 | |
| 453 | 453 | while (ycnt < high) |
| 454 | 454 | { |
| 455 | ||
| 455 | ||
| 456 | 456 | if (!(flip & 0x02)) |
| 457 | 457 | ydrawpos = ypos + ycntdraw; |
| 458 | 458 | else |
| r14063 | r14064 | |
| 467 | 467 | else |
| 468 | 468 | { |
| 469 | 469 | draw_sprite_line_basic(machine, wide, NULL, NULL, flip, xpos, pri, realxsize, palt, 0); |
| 470 | ||
| 470 | ||
| 471 | 471 | if (!(flip & 0x02)) |
| 472 | 472 | { |
| 473 | 473 | if (ydrawpos>224) |
| r14063 | r14064 | |
| 626 | 626 | state->m_bdatasize = machine.region("sprmask")->bytes() - 1; |
| 627 | 627 | state->m_aoffset = 0; |
| 628 | 628 | state->m_boffset = 0; |
| 629 | ||
| 629 | ||
| 630 | 630 | state->m_tx_tilemap = tilemap_create(machine, get_pgm_tx_tilemap_tile_info, tilemap_scan_rows, 8, 8, 64, 32); |
| 631 | 631 | tilemap_set_transparent_pen(state->m_tx_tilemap, 15); |
| 632 | 632 |
| r14063 | r14064 | |
|---|---|---|
| 380 | 380 | if (drawxpos > cliprect.max_x) |
| 381 | 381 | drawxpos -= 512; // wrap around |
| 382 | 382 | |
| 383 | if ( | |
| 383 | if ( | |
| 384 | 384 | { |
| 385 | 385 | if(st0016_spriteram[offset+5]&0x40) |
| 386 | 386 | { |
| r14063 | r14064 | |
| 546 | 546 | if (drawxpos > cliprect.max_x) |
| 547 | 547 | drawxpos -= 512; // wrap around |
| 548 | 548 | |
| 549 | if ( | |
| 549 | if ( | |
| 550 | 550 | { |
| 551 | 551 | |
| 552 | 552 | if(st0016_vregs[j+7]==0x12) |
| r14063 | r14064 | |
|---|---|---|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /* then draw it */ |
| 185 | draw_scanline16(bitmap, cliprect.min_x, y, cliprect. | |
| 185 | draw_scanline16(bitmap, cliprect.min_x, y, cliprect.w | |
| 186 | 186 | } |
| 187 | 187 | return 0; |
| 188 | 188 | } |
| r14063 | r14064 | |
|---|---|---|
| 124 | 124 | cchasm_state *state = machine.driver_data<cchasm_state>(); |
| 125 | 125 | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 126 | 126 | |
| 127 | state->m_xcenter=((visarea.max_x + visarea.min_x)/2) << 16; | |
| 128 | state->m_ycenter=((visarea.max_y + visarea.min_y)/2) << 16; | |
| 127 | state->m_xcenter=visarea.xcenter() << 16; | |
| 128 | state->m_ycenter=visarea.ycenter() << 16; | |
| 129 | 129 | |
| 130 | 130 | VIDEO_START_CALL(vector); |
| 131 | 131 | } |
| r14063 | r14064 | |
|---|---|---|
| 446 | 446 | rectangle clip; |
| 447 | 447 | const rectangle &visarea = screen.visible_area(); |
| 448 | 448 | |
| 449 | clip.min_x = visarea.min_x; | |
| 450 | clip.max_x = visarea.max_x; | |
| 451 | clip.min_y = visarea.min_y; | |
| 452 | clip.max_y = visarea.max_y; | |
| 449 | clip = visarea; | |
| 453 | 450 | |
| 454 | 451 | /* used for 'for use in' and '8ing' screen on bbakraid, raizing on batrider */ |
| 455 | 452 | for (line = 0; line < 256;line++) |
| r14063 | r14064 | |
|---|---|---|
| 271 | 271 | { |
| 272 | 272 | if (flip) x += 20*8; |
| 273 | 273 | |
| 274 | if ( | |
| 274 | if ( | |
| 275 | 275 | bitmap.pix16(y, x) = STARS_COLOR_BASE + star_seed_tab[star_cntr].col; |
| 276 | 276 | } |
| 277 | 277 | } |
| r14063 | r14064 | |
|---|---|---|
| 444 | 444 | UINT8 pivlayer[3]; |
| 445 | 445 | UINT16 priority; |
| 446 | 446 | static const int primasks[4] = {0xfffc, 0xfff0, 0xff00, 0x0}; |
| 447 | rectangle clip; | |
| 448 | 447 | bitmap_ind8 &priority_bitmap = screen.machine().priority_bitmap; |
| 449 | 448 | |
| 450 | clip.min_x = 0; | |
| 451 | clip.min_y = 0; | |
| 452 | clip.max_x = screen.width() -1; | |
| 453 | clip.max_y = screen.height() -1; | |
| 449 | rectangle clip(0, screen.width() -1, 0, screen.height() -1); | |
| 454 | 450 | |
| 455 | 451 | tc0100scn_tilemap_update(tc0100scn); |
| 456 | 452 | tc0480scp_tilemap_update(tc0480scp); |
| r14063 | r14064 | |
|---|---|---|
| 314 | 314 | address_space *space = screen.machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 315 | 315 | |
| 316 | 316 | /* Spriteram is always 1 frame ahead, suggesting buffering. I can't find |
| 317 | a register to control this so I assume it happens automatically | |
| 318 | every frame at the end of vblank */ | |
| 317 | a register to control this so I assume it happens automatically | |
| 318 | every frame at the end of vblank */ | |
| 319 | 319 | buffer_spriteram16_w(space, 0, 0, 0xffff); |
| 320 | 320 | } |
| 321 | 321 | } |
| r14063 | r14064 | |
|---|---|---|
| 293 | 293 | int cy = 240+vy; |
| 294 | 294 | mClip.cx = cx; |
| 295 | 295 | mClip.cy = cy; |
| 296 | mClip.scissor.min_x = cx + vw; | |
| 297 | mClip.scissor.max_x = cx - vw; | |
| 298 | mClip.scissor.min_y = cy + vh; | |
| 299 | mClip.scissor.max_y = cy - vh; | |
| 296 | mClip.scissor.set(cx + vw, cx - vw, cy + vh, cy - vh); | |
| 300 | 297 | if( mClip.scissor.min_x<0 ) mClip.scissor.min_x = 0; |
| 301 | 298 | if( mClip.scissor.max_x>639 ) mClip.scissor.max_x = 639; |
| 302 | 299 | if( mClip.scissor.min_y<0 ) mClip.scissor.min_y = 0; |
| r14063 | r14064 | |
| 307 | 304 | sprite_Clip( int min_x, int max_x, int min_y, int max_y ) |
| 308 | 305 | { |
| 309 | 306 | // cx/cy not used |
| 310 | mClip.scissor.min_x = min_x; | |
| 311 | mClip.scissor.max_x = max_x; | |
| 312 | mClip.scissor.min_y = min_y; | |
| 313 | mClip.scissor.max_y = max_y; | |
| 307 | mClip.scissor.set(min_x, max_x, min_y, max_y); | |
| 314 | 308 | if( mClip.scissor.min_x<0 ) mClip.scissor.min_x = 0; |
| 315 | 309 | if( mClip.scissor.max_x>639 ) mClip.scissor.max_x = 639; |
| 316 | 310 | if( mClip.scissor.min_y<0 ) mClip.scissor.min_y = 0; |
| r14063 | r14064 | |
| 322 | 316 | { |
| 323 | 317 | mClip.cx = 320; |
| 324 | 318 | mClip.cy = 240; |
| 325 | mClip.scissor.min_x = 0; | |
| 326 | mClip.scissor.max_x = 639; | |
| 327 | mClip.scissor.min_y = 0; | |
| 328 | mClip.scissor.max_y = 479; | |
| 319 | mClip.scissor.set(0, 639, 0, 479); | |
| 329 | 320 | } |
| 330 | 321 | |
| 331 | 322 | typedef struct |
| r14063 | r14064 | |
|---|---|---|
| 283 | 283 | sx = 240 - sx; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | if (sx >= cliprect.min_x && sx <= cliprect.max_x && | |
| 287 | sy >= cliprect.min_y && sy <= cliprect.max_y) | |
| 286 | if (cliprect.contains(sx, sy)) | |
| 288 | 287 | bitmap.pix16(sy, sx) = 0x19; |
| 289 | 288 | } |
| 290 | 289 | } |
| r14063 | r14064 | |
| 396 | 395 | else |
| 397 | 396 | vcond = yloc & 0x01; |
| 398 | 397 | |
| 399 | if ( | |
| 398 | if ( | |
| 400 | 399 | { |
| 401 | 400 | if ((hcond ^ vcond) == 0) |
| 402 | 401 | { |
| r14063 | r14064 | |
|---|---|---|
| 623 | 623 | { |
| 624 | 624 | x--; |
| 625 | 625 | |
| 626 | if ( | |
| 626 | if ( | |
| 627 | 627 | bitmap.pix16(y, x) = BULLETS_COLOR_BASE; |
| 628 | 628 | } |
| 629 | 629 | } |
| r14063 | r14064 | |
| 1143 | 1143 | { |
| 1144 | 1144 | x--; |
| 1145 | 1145 | |
| 1146 | if ( | |
| 1146 | if ( | |
| 1147 | 1147 | { |
| 1148 | 1148 | int color; |
| 1149 | 1149 | |
| r14063 | r14064 | |
| 1163 | 1163 | |
| 1164 | 1164 | x = x - 6; |
| 1165 | 1165 | |
| 1166 | if ( | |
| 1166 | if ( | |
| 1167 | 1167 | /* yellow bullets */ |
| 1168 | 1168 | bitmap.pix16(y, x) = BULLETS_COLOR_BASE; |
| 1169 | 1169 | } |
| r14063 | r14064 | |
| 1175 | 1175 | |
| 1176 | 1176 | x = x - 6; |
| 1177 | 1177 | |
| 1178 | if ( | |
| 1178 | if ( | |
| 1179 | 1179 | bitmap.pix16(y, x) = 32 + state->m_darkplnt_bullet_color; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| r14063 | r14064 | |
| 1200 | 1200 | x--; |
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | if ( | |
| 1203 | if ( | |
| 1204 | 1204 | bitmap.pix16(y, x) = color; |
| 1205 | 1205 | } |
| 1206 | 1206 | } |
| r14063 | r14064 | |
| 1377 | 1377 | static void dambustr_draw_upper_background(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 1378 | 1378 | { |
| 1379 | 1379 | galaxold_state *state = machine.driver_data<galaxold_state>(); |
| 1380 | rectangle clip; | |
| 1381 | 1380 | |
| 1382 | 1381 | if (flip_screen_x_get(machine)) |
| 1383 | 1382 | { |
| 1384 | clip.min_x = 254 - state->m_dambustr_bg_split_line; | |
| 1385 | clip.max_x = state->m_dambustr_bg_split_line; | |
| 1386 | clip.min_y = 0; | |
| 1387 | clip.max_y = 255; | |
| 1383 | rectangle clip(254 - state->m_dambustr_bg_split_line, state->m_dambustr_bg_split_line, 0, 255); | |
| 1388 | 1384 | copybitmap(bitmap, *state->m_dambustr_tmpbitmap, 0, 0, 0, 0, clip); |
| 1389 | 1385 | } |
| 1390 | 1386 | else |
| 1391 | 1387 | { |
| 1392 | clip.min_x = 0; | |
| 1393 | clip.max_x = 254 - state->m_dambustr_bg_split_line; | |
| 1394 | clip.min_y = 0; | |
| 1395 | clip.max_y = 255; | |
| 1388 | rectangle clip(0, 254 - state->m_dambustr_bg_split_line, 0, 255); | |
| 1396 | 1389 | copybitmap(bitmap, *state->m_dambustr_tmpbitmap, 0, 0, 0, 0, clip); |
| 1397 | 1390 | } |
| 1398 | 1391 | } |
| r14063 | r14064 | |
| 1482 | 1475 | if (state->m_flipscreen_y) |
| 1483 | 1476 | y = 255 - y; |
| 1484 | 1477 | |
| 1485 | if ( | |
| 1478 | if ( | |
| 1486 | 1479 | bitmap.pix16(y, x) = state->m_stars_colors_start + color; |
| 1487 | 1480 | } |
| 1488 | 1481 |
| r14063 | r14064 | |
|---|---|---|
| 538 | 538 | int flipscreen = 0; /* n/a */ |
| 539 | 539 | int machine_flip = 0; /* for ROT 180 ? */ |
| 540 | 540 | |
| 541 | UINT16 screen_width = cliprect. | |
| 541 | UINT16 screen_width = cliprect.w | |
| 542 | 542 | UINT16 min_y = cliprect.min_y; |
| 543 | 543 | UINT16 max_y = cliprect.max_y; |
| 544 | 544 |
| r14063 | r14064 | |
|---|---|---|
| 628 | 628 | |
| 629 | 629 | /* Set up a clipping region for the tilemap slice .. */ |
| 630 | 630 | |
| 631 | clip.min_x = sx; | |
| 632 | clip.max_x = sx + xnum * 0x10 - 1; | |
| 633 | clip.min_y = sy; | |
| 634 | clip.max_y = sy + ynum * 0x8 - 1; | |
| 631 | clip.set(sx, sx + xnum * 0x10 - 1, sy, sy + ynum * 0x8 - 1); | |
| 635 | 632 | |
| 636 | 633 | /* .. and clip it against the visible screen */ |
| 637 | 634 |
| r14063 | r14064 | |
|---|---|---|
| 281 | 281 | bitmap.fill(0x3f, cliprect); /* is there a register controling the colour?, we currently use the last colour of the tx palette */ |
| 282 | 282 | |
| 283 | 283 | /* draw top of screen */ |
| 284 | clip.min_x = 8*0; | |
| 285 | clip.max_x = 8*16-1; | |
| 286 | clip.min_y = visarea.min_y; | |
| 287 | clip.max_y = visarea.max_y; | |
| 284 | clip.set(8*0, 8*16-1, visarea.min_y, visarea.max_y); | |
| 288 | 285 | |
| 289 | 286 | if ((state->m_layer_ctrl & 0x80) == 0x00) |
| 290 | 287 | tilemap_draw(bitmap, clip, state->m_bgtop_tilemap, 0, 0); |
| r14063 | r14064 | |
| 295 | 292 | tilemap_draw(bitmap, clip, state->m_tx_tilemap, 0, 0); |
| 296 | 293 | |
| 297 | 294 | /* draw bottom of screen */ |
| 298 | clip.min_x = 8*16; | |
| 299 | clip.max_x = 8*32-1; | |
| 300 | clip.min_y = visarea.min_y; | |
| 301 | clip.max_y = visarea.max_y; | |
| 295 | clip.set(8*16, 8*32-1, visarea.min_y, visarea.max_y); | |
| 302 | 296 | |
| 303 | 297 | if ((state->m_layer_ctrl & 0x40) == 0x00) |
| 304 | 298 | tilemap_draw(bitmap, clip, state->m_bgbot_tilemap, 0, 0); |
| r14063 | r14064 | |
|---|---|---|
| 217 | 217 | |
| 218 | 218 | INLINE void geebee_plot(bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y, pen_t pen) |
| 219 | 219 | { |
| 220 | if ( | |
| 220 | if ( | |
| 221 | 221 | bitmap.pix16(y, x) = pen; |
| 222 | 222 | } |
| 223 | 223 |
| r14063 | r14064 | |
|---|---|---|
| 237 | 237 | { |
| 238 | 238 | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 239 | 239 | |
| 240 | int width = visarea.max_x + 1 - visarea.min_x; | |
| 241 | int height = visarea.max_y + 1 - visarea.min_y; | |
| 240 | int width = visarea.width(); | |
| 241 | int height = visarea.height(); | |
| 242 | 242 | /* only 2 lightguns are connected */ |
| 243 | 243 | *x = visarea.min_x + (((input_port_read(machine, player ? "FAKE2_X" : "FAKE1_X") & 0xff) * width) >> 8); |
| 244 | 244 | *y = visarea.min_y + (((input_port_read(machine, player ? "FAKE2_Y" : "FAKE1_Y") & 0xff) * height) >> 8); |
| r14063 | r14064 | |
| 751 | 751 | /* adjust for the half-lines */ |
| 752 | 752 | if (hperiod != 0 && vperiod != 0 && hbend < hbstart && vbend < vbstart && hbstart < hperiod) |
| 753 | 753 | { |
| 754 | rectangle visarea; | |
| 755 | visarea.min_x = hbend / 2; | |
| 756 | visarea.max_x = hbstart / 2 - 1; | |
| 757 | visarea.min_y = vbend / 2; | |
| 758 | visarea.max_y = vbstart / 2 - 1; | |
| 754 | rectangle visarea(hbend / 2, hbstart / 2 - 1, vbend / 2, vbstart / 2 - 1); | |
| 759 | 755 | space->machine().primary_screen->configure(hperiod / 2, vperiod / 2, visarea, HZ_TO_ATTOSECONDS((double)pixel_clock * 2 / hperiod / vperiod)); |
| 760 | 756 | } |
| 761 | 757 | } |
| r14063 | r14064 | |
|---|---|---|
| 71 | 71 | state_save_register_global(machine, state->m_flipscreen); |
| 72 | 72 | |
| 73 | 73 | state->m_prom_tab = auto_alloc_array(machine, UINT32, 256); |
| 74 | ||
| 74 | ||
| 75 | 75 | machine.primary_screen->register_screen_bitmap(state->m_bitmap); |
| 76 | 76 | |
| 77 | 77 | /* Allocate temporary bitmap */ |
| r14063 | r14064 | |
|---|---|---|
| 448 | 448 | |
| 449 | 449 | static void plot_star( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y, int color ) |
| 450 | 450 | { |
| 451 | if (y < cliprect.min_y || y > cliprect.max_y || | |
| 452 | x < cliprect.min_x || x > cliprect.max_x) | |
| 451 | if (!cliprect.contains(x, y)) | |
| 453 | 452 | return; |
| 454 | 453 | |
| 455 | 454 | if (flip_screen_x_get(machine)) |
| r14063 | r14064 | |
|---|---|---|
| 222 | 222 | int max_x = machine.primary_screen->width(); |
| 223 | 223 | int max_y = machine.primary_screen->height(); |
| 224 | 224 | |
| 225 | rectangle spritetile_clip; | |
| 226 | spritetile_clip.min_x = 0; | |
| 227 | spritetile_clip.min_y = 0; | |
| 228 | spritetile_clip.max_x = 31; | |
| 229 | spritetile_clip.max_y = 31; | |
| 225 | rectangle spritetile_clip(0, 31, 0, 31); | |
| 230 | 226 | |
| 231 | 227 | for ( offs = 0x3000/2; offs < 0x3600/2; offs += 2/2 ) |
| 232 | 228 | { |
| r14063 | r14064 | |
|---|---|---|
| 395 | 395 | i = ((state->m_cus116[6] << 8) | state->m_cus116[7]) - 0x11 - 1; // max y |
| 396 | 396 | if (new_clip.max_y > i) new_clip.max_y = i; |
| 397 | 397 | |
| 398 | if (new_clip. | |
| 398 | if (new_clip. | |
| 399 | 399 | return 0; |
| 400 | 400 | |
| 401 | 401 |
| r14063 | r14064 | |
|---|---|---|
| 557 | 557 | x = (star_seed_tab[star_cntr].x + state->m_stars_scrollx) % 256 + x_align; |
| 558 | 558 | y = (y_align + star_seed_tab[star_cntr].y + state->m_stars_scrolly) % 256; |
| 559 | 559 | |
| 560 | if ( | |
| 560 | if ( | |
| 561 | 561 | bitmap.pix16(y, x) = STARS_COLOR_BASE + star_seed_tab[ star_cntr ].col; |
| 562 | 562 | } |
| 563 | 563 |
| r14063 | r14064 | |
|---|---|---|
| 405 | 405 | switch (state->m_bg_clip_mode) |
| 406 | 406 | { |
| 407 | 407 | case 0: case 4: case 8: case 12: case 16: |
| 408 | clip. | |
| 408 | clip.set(0, 0, 0, | |
| 409 | 409 | break; |
| 410 | 410 | case 1: clip.min_y = state->m_sy1; break; |
| 411 | 411 | case 3: clip.max_y = state->m_sy2; break; |
| r14063 | r14064 | |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | if (flip_screen_get(machine)) |
| 419 | { | |
| 420 | int min_x,max_x,min_y,max_y; | |
| 421 | min_x = 255 - clip.max_x; | |
| 422 | max_x = 255 - clip.min_x; | |
| 423 | min_y = 255 - clip.max_y; | |
| 424 | max_y = 255 - clip.min_y; | |
| 425 | clip.min_x = min_x; | |
| 426 | clip.max_x = max_x; | |
| 427 | clip.min_y = min_y; | |
| 428 | clip.max_y = max_y; | |
| 429 | } | |
| 419 | clip.set(255 - clip.max_x, 255 - clip.min_x, 255 - clip.max_y, 255 - clip.min_y); | |
| 430 | 420 | } |
| 431 | 421 | |
| 432 | 422 | tilemap_draw(bitmap, clip, state->m_bg_tilemap, 0, 0); |
| r14063 | r14064 | |
|---|---|---|
| 52 | 52 | SET_TILE_INFO(0, code, color, 0); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | static | |
| 55 | static | |
| 56 | 56 | { |
| 57 | 57 | /* logical (col,row) -> memory offset */ |
| 58 | 58 | return (col * num_rows) + (num_rows - 1 - row); |
| r14063 | r14064 | |
|---|---|---|
| 77 | 77 | int color; |
| 78 | 78 | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 79 | 79 | |
| 80 | if ( | |
| 80 | if (! | |
| 81 | 81 | return; |
| 82 | 82 | |
| 83 | 83 | front = state->m_videoram[y * 256 + x / 2]; |
| r14063 | r14064 | |
|---|---|---|
| 65 | 65 | int sx = 254 - state->m_videoram[0x3d0 + 2 * i + 0x5]; |
| 66 | 66 | int sy = 246 - state->m_videoram[0x3d0 + 2 * i + 0xc]; |
| 67 | 67 | |
| 68 | rectangle rect; | |
| 68 | rectangle rect(sx, sx + 1, sy, sy + 1); | |
| 69 | rect &= cliprect; | |
| 69 | 70 | |
| 70 | rect.min_x = sx; | |
| 71 | rect.min_y = sy; | |
| 72 | rect.max_x = sx + 1; | |
| 73 | rect.max_y = sy + 1; | |
| 74 | ||
| 75 | if (rect.min_x < cliprect.min_x) rect.min_x = cliprect.min_x; | |
| 76 | if (rect.min_y < cliprect.min_y) rect.min_y = cliprect.min_y; | |
| 77 | if (rect.max_x > cliprect.max_x) rect.max_x = cliprect.max_x; | |
| 78 | if (rect.max_y > cliprect.max_y) rect.max_y = cliprect.max_y; | |
| 79 | ||
| 80 | 71 | bitmap.fill(1 + 2 * i, rect); |
| 81 | 72 | } |
| 82 | 73 | } |
| r14063 | r14064 | |
|---|---|---|
| 154 | 154 | int offset; |
| 155 | 155 | |
| 156 | 156 | // const rectangle *visarea = screen.machine().primary_screen->visible_area(); |
| 157 | // cliprect.min_x = visarea->min_x; | |
| 158 | // cliprect.max_x = visarea->max_x; | |
| 159 | // cliprect.min_y = visarea->min_y; | |
| 160 | // cliprect.max_y = visarea->max_y; | |
| 157 | // cliprect = *visarea; | |
| 161 | 158 | |
| 162 | cliprect.min_x = 0; | |
| 163 | cliprect.max_x = 64 * 8 - 1; | |
| 164 | cliprect.min_y = 2 * 8; | |
| 165 | cliprect.max_y = 30 * 8 - 1; | |
| 159 | cliprect.set(0, 64 * 8 - 1, 2 * 8, 30 * 8 - 1); | |
| 166 | 160 | |
| 167 | 161 | |
| 168 | 162 | if (screen.machine().primary_screen->frame_number() & 0x01) |
| r14063 | r14064 | |
| 172 | 166 | memcpy(state->m_k053247_ram, state->m_xmen6p_spriteramright, 0x1000); |
| 173 | 167 | |
| 174 | 168 | /* we write the entire content of the tileram to the chip to ensure |
| 175 | everything gets marked as dirty and the desired tilemap is rendered | |
| 176 | this is not very efficient! | |
| 177 | */ | |
| 169 | everything gets marked as dirty and the desired tilemap is rendered | |
| 170 | this is not very efficient! | |
| 171 | */ | |
| 178 | 172 | for (offset = 0; offset < (0xc000 / 2); offset++) |
| 179 | 173 | { |
| 180 | 174 | // K052109_lsb_w |
| r14063 | r14064 | |
| 190 | 184 | memcpy(state->m_k053247_ram, state->m_xmen6p_spriteramleft, 0x1000); |
| 191 | 185 | |
| 192 | 186 | /* we write the entire content of the tileram to the chip to ensure |
| 193 | ||
| 187 | everything gets marked as dirty and the desired tilemap is rendered | |
| 194 | 188 | |
| 195 | this is not very efficient! | |
| 196 | */ | |
| 189 | this is not very efficient! | |
| 190 | */ | |
| 197 | 191 | for (offset = 0; offset < (0xc000 / 2); offset++) |
| 198 | 192 | { |
| 199 | 193 | // K052109_lsb_w |
| r14063 | r14064 | |
| 230 | 224 | k052109_tilemap_draw(state->m_k052109, *renderbitmap, cliprect, layer[2], 0, 4); |
| 231 | 225 | |
| 232 | 226 | /* this isn't supported anymore and it is unsure if still needed; keeping here for reference |
| 233 | ||
| 227 | pdrawgfx_shadow_lowpri = 1; fix shadows of boulders in front of feet */ | |
| 234 | 228 | k053247_sprites_draw(state->m_k053246, *renderbitmap, cliprect); |
| 235 | 229 | } |
| 236 | 230 | } |
| r14063 | r14064 | |
|---|---|---|
| 47 | 47 | { |
| 48 | 48 | for (col = 0; col < 48; col++) |
| 49 | 49 | { |
| 50 | UINT32 offset = | |
| 50 | UINT32 offset = s | |
| 51 | 51 | |
| 52 | 52 | if (state->m_video_ram[offset] & 0x80) /* ball bit found */ |
| 53 | 53 | { |
| 54 | rectangle rect; | |
| 55 | ||
| 56 | 54 | int x = 8 * col; |
| 57 | 55 | int y = 8 * row; |
| 58 | 56 | |
| r14063 | r14064 | |
| 61 | 59 | |
| 62 | 60 | x += 4; /* account for delayed loading of flip-flop C4 */ |
| 63 | 61 | |
| 64 | rect.min_x = x; | |
| 65 | rect.min_y = y; | |
| 66 | rect.max_x = x + 15; | |
| 67 | rect.max_y = y + 15; | |
| 62 | rectangle rect(x, x + 15, y, y + 15); | |
| 63 | rect &= cliprect; | |
| 68 | 64 | |
| 69 | if (rect.min_x < cliprect.min_x) | |
| 70 | rect.min_x = cliprect.min_x; | |
| 71 | if (rect.min_y < cliprect.min_y) | |
| 72 | rect.min_y = cliprect.min_y; | |
| 73 | if (rect.max_x > cliprect.max_x) | |
| 74 | rect.max_x = cliprect.max_x; | |
| 75 | if (rect.max_y > cliprect.max_y) | |
| 76 | rect.max_y = cliprect.max_y; | |
| 77 | ||
| 78 | 65 | x -= state->m_ball_x; |
| 79 | 66 | y -= state->m_ball_y; |
| 80 | 67 |
| r14063 | r14064 | |
|---|---|---|
| 712 | 712 | |
| 713 | 713 | LOG(("atari antic_vh_start\n")); |
| 714 | 714 | memset(&antic, 0, sizeof(antic)); |
| 715 | ||
| 715 | ||
| 716 | 716 | antic.bitmap = auto_bitmap_ind16_alloc(machine, machine.primary_screen->width(), machine.primary_screen->height()); |
| 717 | 717 | |
| 718 | 718 | antic.renderer = antic_mode_0_xx; |
| r14063 | r14064 | |
|---|---|---|
| 342 | 342 | { |
| 343 | 343 | rectangle cliprect; |
| 344 | 344 | |
| 345 | cliprect.min_x = 0; | |
| 346 | cliprect.max_x = state->m_bg_bitmap.width() - 1; | |
| 347 | cliprect.min_y = sy * 16; | |
| 348 | cliprect.max_y = cliprect.min_y + 16 - 1; | |
| 345 | cliprect.set(0, state->m_bg_bitmap.width() - 1, sy * 16, cliprect.min_y + 16 - 1); | |
| 349 | 346 | |
| 350 | 347 | state->m_bg_bitmap.fill(BG_TRANSPEN, cliprect); |
| 351 | 348 | int width = size * 16; |
| r14063 | r14064 | |
| 391 | 388 | int last_bank[32]; // corresponds to bank of bitmap in state->m_bg_bitmap. bg_bitmap is split into 16/32-rows of one-tile high each |
| 392 | 389 | for(int ii = 0; ii < 32; ii++) last_bank[ii] = -1; |
| 393 | 390 | |
| 394 | int scr_width = (cliprect.max_x-cliprect.min_x + 1); | |
| 395 | int scr_height = (cliprect.max_y-cliprect.min_y + 1); | |
| 391 | int scr_width = cliprect.width(); | |
| 392 | int scr_height = cliprect.height(); | |
| 396 | 393 | UINT32 *scroll_reg = &state->m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4]; |
| 397 | 394 | UINT32 *pzab_reg = &state->m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4 + 0x400 / 4]; // pri, zoom, alpha, bank |
| 398 | 395 |
| r14063 | r14064 | |
|---|---|---|
| 100 | 100 | int x,y,j,b; |
| 101 | 101 | UINT16 offset = (pk8000_video_mode & 0xc0) << 8; |
| 102 | 102 | rectangle my_rect; |
| 103 | my_rect.min_x = 0; | |
| 104 | my_rect.max_x = 256+32-1; | |
| 105 | my_rect.min_y = 0; | |
| 106 | my_rect.max_y = 192+32-1; | |
| 103 | my_rect.set(0, 256+32-1, 0, 192+32-1); | |
| 107 | 104 | |
| 108 | 105 | if (pk8000_video_enable) { |
| 109 | 106 | bitmap.fill((pk8000_video_color >> 4) & 0x0f, my_rect); |
| r14063 | r14064 | |
|---|---|---|
| 1105 | 1105 | /* clear out any scanlines we might be using */ |
| 1106 | 1106 | for (y = cliprect.min_y; y <= cliprect.max_y; y++) |
| 1107 | 1107 | if (!(rotatebase[y & ~1] & 0xc000)) |
| 1108 | memset(&bitmap.pix16(y, cliprect.min_x), 0xff, | |
| 1108 | memset(&bitmap.pix16(y, cliprect.min_x), 0xff, | |
| 1109 | 1109 | |
| 1110 | 1110 | /* now scan backwards and render the sprites in order */ |
| 1111 | 1111 | for (data = sega16sp->spriteram; !(data[0] & 0x8000) && !visited[next]; data = sega16sp->spriteram + next * 8) |
| r14063 | r14064 | |
|---|---|---|
| 90 | 90 | void K053936GP_set_cliprect(int chip, int minx, int maxx, int miny, int maxy) |
| 91 | 91 | { |
| 92 | 92 | rectangle &cliprect = K053936_cliprect[chip]; |
| 93 | cliprect.min_x = minx; | |
| 94 | cliprect.max_x = maxx; | |
| 95 | cliprect.min_y = miny; | |
| 96 | cliprect.max_y = maxy; | |
| 93 | cliprect.set(minx, maxx, miny, maxy); | |
| 97 | 94 | } |
| 98 | 95 | |
| 99 | 96 | INLINE void K053936GP_copyroz32clip( running_machine &machine, |
| r14063 | r14064 | |
| 1056 | 1053 | { |
| 1057 | 1054 | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 1058 | 1055 | |
| 1059 | int w = visarea.max_x - visarea.min_x + 1; | |
| 1060 | int h = visarea.max_y - visarea.min_y + 1; | |
| 1056 | int w = visarea.width(); | |
| 1057 | int h = visarea.height(); | |
| 1061 | 1058 | |
| 1062 | 1059 | UINT8 *zptr = gx_objzbuf; |
| 1063 | 1060 | int ecx = h; |
| r14063 | r14064 | |
| 1575 | 1572 | { |
| 1576 | 1573 | int pixeldouble_output = 0; |
| 1577 | 1574 | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 1578 | int width = visarea. | |
| 1575 | int width = visarea.w | |
| 1579 | 1576 | |
| 1580 | 1577 | if (width>512) // vsnetscr case |
| 1581 | 1578 | pixeldouble_output = 1; |
| r14063 | r14064 | |
| 2319 | 2316 | gxtype1_roz_dstbitmap2 = auto_bitmap_ind16_alloc(machine,512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing |
| 2320 | 2317 | |
| 2321 | 2318 | |
| 2322 | gxtype1_roz_dstbitmapclip.min_x = 0; | |
| 2323 | gxtype1_roz_dstbitmapclip.max_x = 512-1; | |
| 2324 | gxtype1_roz_dstbitmapclip.min_y = 0; | |
| 2325 | gxtype1_roz_dstbitmapclip.max_y = 512-1; | |
| 2319 | gxtype1_roz_dstbitmapclip.set(0, 512-1, 0, 512-1); | |
| 2326 | 2320 | |
| 2327 | 2321 | |
| 2328 | 2322 | K053936_wraparound_enable(0, 1); |
| r14063 | r14064 | |
| 2360 | 2354 | gxtype1_roz_dstbitmap2 = auto_bitmap_ind16_alloc(machine,512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing |
| 2361 | 2355 | |
| 2362 | 2356 | |
| 2363 | gxtype1_roz_dstbitmapclip.min_x = 0; | |
| 2364 | gxtype1_roz_dstbitmapclip.max_x = 512-1; | |
| 2365 | gxtype1_roz_dstbitmapclip.min_y = 0; | |
| 2366 | gxtype1_roz_dstbitmapclip.max_y = 512-1; | |
| 2357 | gxtype1_roz_dstbitmapclip.set(0, 512-1, 0, 512-1); | |
| 2367 | 2358 | |
| 2368 | 2359 | |
| 2369 | 2360 | K053936_wraparound_enable(0, 1); |
| r14063 | r14064 | |
| 2447 | 2438 | { |
| 2448 | 2439 | // we're going to throw half of this away anyway in post-process, so only render what's needed |
| 2449 | 2440 | rectangle temprect; |
| 2450 | temprect | |
| 2441 | temprect | |
| 2451 | 2442 | temprect.max_x = cliprect.min_x+320; |
| 2452 | temprect.min_y = cliprect.min_y; | |
| 2453 | temprect.max_y = cliprect.max_y; | |
| 2454 | 2443 | |
| 2455 | 2444 | if (konamigx_type3_psac2_actual_bank == 1) K053936_0_zoom_draw(*type3_roz_temp_bitmap, temprect,gx_psac_tilemap_alt, 0,0,0); // soccerss playfield |
| 2456 | 2445 | else K053936_0_zoom_draw(*type3_roz_temp_bitmap, temprect,gx_psac_tilemap, 0,0,0); // soccerss playfield |
| r14063 | r14064 | |
|---|---|---|
| 284 | 284 | screen_device *screen = machine.first_screen(); |
| 285 | 285 | const rectangle &visarea = screen->visible_area(); |
| 286 | 286 | |
| 287 | state->m_x_center=((visarea.max_x - visarea.min_x) / 2) << 16; | |
| 288 | state->m_y_center=((visarea.max_y - visarea.min_y) / 2) << 16; | |
| 287 | state->m_x_center=(visarea.width() / 2) << 16; | |
| 288 | state->m_y_center=(visarea.height() / 2) << 16; | |
| 289 | 289 | state->m_x_max = visarea.max_x << 16; |
| 290 | 290 | state->m_y_max = visarea.max_y << 16; |
| 291 | 291 | |
| r14063 | r14064 | |
| 484 | 484 | screen_device *screen = machine.first_screen(); |
| 485 | 485 | const rectangle &visarea = screen->visible_area(); |
| 486 | 486 | |
| 487 | state->m_x_center=((visarea.max_x - visarea.min_x) / 2) << 16; | |
| 488 | state->m_y_center=((visarea.max_y - visarea.min_y) / 2) << 16; | |
| 487 | state->m_x_center=(visarea.width() / 2) << 16; | |
| 488 | state->m_y_center=(visarea.height() / 2) << 16; | |
| 489 | 489 | state->m_x_max = visarea.max_x << 16; |
| 490 | 490 | state->m_y_max = visarea.max_y << 16; |
| 491 | 491 |
| r14063 | r14064 | |
|---|---|---|
| 399 | 399 | rect.min_y = get_sprite_vpos(state, 13); |
| 400 | 400 | rect.max_x = rect.min_x + screen.machine().gfx[1]->width - 1; |
| 401 | 401 | rect.max_y = rect.min_y + screen.machine().gfx[1]->height - 1; |
| 402 | ||
| 402 | ||
| 403 | 403 | rect &= state->m_helper.cliprect(); |
| 404 | 404 | |
| 405 | 405 | state->m_helper.fill(0, visarea); |
| r14063 | r14064 | |
|---|---|---|
| 971 | 971 | if (vblank_on) |
| 972 | 972 | { |
| 973 | 973 | /* spriteram[2] and [3] are 1 frame behind... |
| 974 | ||
| 974 | probably thundfox_eof_callback would work fine */ | |
| 975 | 975 | |
| 976 | 976 | taitof2_state *state = screen.machine().driver_data<taitof2_state>(); |
| 977 | 977 | UINT16 *spriteram = state->m_spriteram; |
| r14063 | r14064 | |
|---|---|---|
| 1110 | 1110 | int xinc,yinc; |
| 1111 | 1111 | |
| 1112 | 1112 | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 1113 | clip.min_x = visarea.min_x; | |
| 1114 | clip.max_x = visarea.max_x; | |
| 1115 | clip.min_y = visarea.min_y; | |
| 1116 | clip.max_y = visarea.max_y; | |
| 1113 | clip = visarea; | |
| 1117 | 1114 | |
| 1118 | 1115 | if (global_tileregs&0x04000000) // globally selects alt scroll register layout??? |
| 1119 | 1116 | { |
| r14063 | r14064 | |
| 1541 | 1538 | // Blit the color buffer into the primary bitmap |
| 1542 | 1539 | for (y = cliprect.min_y; y <= cliprect.max_y; y++) |
| 1543 | 1540 | { |
| 1544 | UINT32 *src = &state->m_colorBuffer3d[y * | |
| 1541 | UINT32 *src = &state->m_colorBuffer3d[y * | |
| 1545 | 1542 | UINT32 *dst = &bitmap.pix32(y, cliprect.min_x); |
| 1546 | 1543 | |
| 1547 | 1544 | for (x = cliprect.min_x; x <= cliprect.max_x; x++) |
| r14063 | r14064 | |
| 1698 | 1695 | state->m_additive_tilemap_debug = 0; |
| 1699 | 1696 | |
| 1700 | 1697 | // 3d Buffer Allocation |
| 1701 | state->m_depthBuffer3d = auto_alloc_array(machine, float, (visarea.max_x)*(visarea.max_y)); | |
| 1702 | state->m_colorBuffer3d = auto_alloc_array(machine, UINT32, (visarea.max_x)*(visarea.max_y)); | |
| 1698 | state->m_depthBuffer3d = auto_alloc_array(machine, float, (visarea.max_x + 1)*(visarea.max_y + 1)); | |
| 1699 | state->m_colorBuffer3d = auto_alloc_array(machine, UINT32, (visarea.max_x + 1)*(visarea.max_y + 1)); | |
| 1703 | 1700 | } |
| 1704 | 1701 | |
| 1705 | 1702 |
| r14063 | r14064 | |
|---|---|---|
| 10 | 10 | state->m_spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000); |
| 11 | 11 | |
| 12 | 12 | /* Hack */ |
| 13 | state->m_hack_cliprect.min_x = 69; | |
| 14 | state->m_hack_cliprect.max_x = 250; | |
| 15 | state->m_hack_cliprect.min_y = 24 + 5; | |
| 16 | state->m_hack_cliprect.max_y = 24 + 44; | |
| 13 | state->m_hack_cliprect.set(69, 250, 24 + 5, 24 + 44); | |
| 17 | 14 | } |
| 18 | 15 | |
| 19 | 16 | /*************************************************************** |
| r14063 | r14064 | |
|---|---|---|
| 169 | 169 | y = bitmap.height() - y - 1; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | if (x < cliprect.min_x || | |
| 173 | x > cliprect.max_x || | |
| 174 | y < cliprect.min_y || | |
| 175 | y > cliprect.max_y) | |
| 176 | return; | |
| 177 | ||
| 178 | bitmap.pix16(y, x) = color; | |
| 172 | if (cliprect.contains(x, y)) | |
| 173 | bitmap.pix16(y, x) = color; | |
| 179 | 174 | } |
| 180 | 175 | |
| 181 | 176 |
| r14063 | r14064 | |
|---|---|---|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
| 162 | static | |
| 162 | static | |
| 163 | 163 | { |
| 164 | 164 | /* logical (col,row) -> memory offset */ |
| 165 | 165 | if (col >= 32) |
| r14063 | r14064 | |
|---|---|---|
| 79 | 79 | { |
| 80 | 80 | for (y = fy; y < fy + machine.gfx[expand]->height; y++) |
| 81 | 81 | { |
| 82 | if ((x < visarea.min_x) || | |
| 83 | (x > visarea.max_x) || | |
| 84 | (y < visarea.min_y) || | |
| 85 | (y > visarea.max_y)) | |
| 86 | { | |
| 87 | continue; | |
| 88 | } | |
| 89 | ||
| 90 | Checksum += state->m_spritebitmap.pix16(y, x); | |
| 82 | if (visarea.contains(x, y)) | |
| 83 | Checksum += state->m_spritebitmap.pix16(y, x); | |
| 91 | 84 | } |
| 92 | 85 | } |
| 93 | 86 | |
| r14063 | r14064 | |
| 105 | 98 | { |
| 106 | 99 | for (y = fy; y < fy + machine.gfx[expand]->height; y++) |
| 107 | 100 | { |
| 108 | if ((x < visarea.min_x) || | |
| 109 | (x > visarea.max_x) || | |
| 110 | (y < visarea.min_y) || | |
| 111 | (y > visarea.max_y)) | |
| 112 | { | |
| 113 | continue; | |
| 114 | } | |
| 115 | ||
| 116 | Checksum -= state->m_spritebitmap.pix16(y, x); | |
| 101 | if (visarea.contains(x, y)) | |
| 102 | Checksum -= state->m_spritebitmap.pix16(y, x); | |
| 117 | 103 | } |
| 118 | 104 | } |
| 119 | 105 | |
| r14063 | r14064 | |
| 194 | 180 | { |
| 195 | 181 | for (y = by; y < by + machine.gfx[expand]->height; y++) |
| 196 | 182 | { |
| 197 | if ((x < visarea.min_x) || | |
| 198 | (x > visarea.max_x) || | |
| 199 | (y < visarea.min_y) || | |
| 200 | (y > visarea.max_y)) | |
| 201 | { | |
| 202 | continue; | |
| 203 | } | |
| 204 | ||
| 205 | if (bitmap.pix16(y, x) != state->m_bitmap.pix16(y, x)) | |
| 206 | { | |
| 207 | state->m_CollisionBackground = 0x80; | |
| 208 | break; | |
| 209 | } | |
| 183 | if (visarea.contains(x, y)) | |
| 184 | if (bitmap.pix16(y, x) != state->m_bitmap.pix16(y, x)) | |
| 185 | { | |
| 186 | state->m_CollisionBackground = 0x80; | |
| 187 | break; | |
| 188 | } | |
| 210 | 189 | } |
| 211 | 190 | } |
| 212 | 191 |
| r14063 | r14064 | |
|---|---|---|
| 151 | 151 | //if (shangha3_ram[offs+11] || shangha3_ram[offs+12]) |
| 152 | 152 | //logerror("offs %04x: sx %04x sy %04x zoom %04x %04x %04x %04x fx %d fy %d\n",offs,sx,sy,zoomx,shangha3_ram[offs+11]),shangha3_ram[offs+12],zoomy,flipx,flipy); |
| 153 | 153 | |
| 154 | myclip.min_x = sx; | |
| 155 | myclip.max_x = sx + sizex; | |
| 156 | myclip.min_y = sy; | |
| 157 | myclip.max_y = sy + sizey; | |
| 154 | myclip.set(sx, sx + sizex, sy, sy + sizey); | |
| 158 | 155 | myclip &= rawbitmap.cliprect(); |
| 159 | 156 | |
| 160 | 157 | if (shangha3_ram[offs+4] & 0x08) /* tilemap */ |
| r14063 | r14064 | |
|---|---|---|
| 208 | 208 | rectangle clip; |
| 209 | 209 | |
| 210 | 210 | const rectangle &visarea = screen.visible_area(); |
| 211 | clip.min_x = visarea.min_x; | |
| 212 | clip.max_x = visarea.max_x; | |
| 213 | clip.min_y = visarea.min_y; | |
| 214 | clip.max_y = visarea.max_y; | |
| 211 | clip = visarea; | |
| 215 | 212 | |
| 216 | 213 | for (line = 0; line < 224;line++) |
| 217 | 214 | { |
| r14063 | r14064 | |
|---|---|---|
| 319 | 319 | int line; |
| 320 | 320 | rectangle clip; |
| 321 | 321 | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 322 | clip.min_x = visarea.min_x; | |
| 323 | clip.max_x = visarea.max_x; | |
| 324 | clip.min_y = visarea.min_y; | |
| 325 | clip.max_y = visarea.max_y; | |
| 322 | clip = visarea; | |
| 326 | 323 | |
| 327 | 324 | if (state->m_control[0x08 + laynum] & 0x02) |
| 328 | 325 | { |
| r14063 | r14064 | |
|---|---|---|
| 550 | 550 | state->m_need_process_spriteram = 1; |
| 551 | 551 | |
| 552 | 552 | /* if the sprite preprocessor is used, sprite ram is copied to an external buffer first, |
| 553 | as evidenced by 1-frame sprite lag in gradius2 and devilw otherwise, though there's probably | |
| 554 | more to it than that */ | |
| 553 | as evidenced by 1-frame sprite lag in gradius2 and devilw otherwise, though there's probably | |
| 554 | more to it than that */ | |
| 555 | 555 | memcpy(&screen.machine().generic.buffered_spriteram.u16[0x1800],state->m_sprite_buffer,0x800*sizeof(UINT16)); |
| 556 | 556 | memcpy(state->m_sprite_buffer,&screen.machine().generic.spriteram.u16[0x1800],0x800*sizeof(UINT16)); |
| 557 | 557 | } |
| r14063 | r14064 | |
|---|---|---|
| 64 | 64 | |
| 65 | 65 | if(vidc_interlace) |
| 66 | 66 | { |
| 67 | if ((res_x) >= 0 && | |
| 68 | (res_y) >= 0 && | |
| 69 | (res_x) <= screen.visible_area().max_x && (res_y) <= screen.visible_area().max_y && (res_x) <= xend && (res_y) <= yend) | |
| 67 | if (cliprect.contains(res_x, res_y) && (res_x) <= xend && (res_y) <= yend) | |
| 70 | 68 | bitmap.pix32(res_y, res_x) = screen.machine().pens[(pen>>(xi))&0x1]; |
| 71 | if ((res_x) >= 0 && | |
| 72 | (res_y) >= 0 && | |
| 73 | (res_x) <= screen.visible_area().max_x && (res_y+1) <= screen.visible_area().max_y && (res_x) <= xend && (res_y+1) <= yend) | |
| 69 | if (cliprect.contains(res_x, res_y+1) && (res_x) <= xend && (res_y+1) <= yend) | |
| 74 | 70 | bitmap.pix32(res_y+1, res_x) = screen.machine().pens[(pen>>(xi))&0x1]; |
| 75 | 71 | } |
| 76 | 72 | else |
| 77 | 73 | { |
| 78 | if ((res_x) >= 0 && | |
| 79 | (res_y) >= 0 && | |
| 80 | (res_x) <= screen.visible_area().max_x && (res_y) <= screen.visible_area().max_y && (res_x) <= xend && (res_y) <= yend) | |
| 74 | if (cliprect.contains(res_x, res_y) && (res_x) <= xend && (res_y) <= yend) | |
| 81 | 75 | bitmap.pix32(res_y, res_x) = screen.machine().pens[(pen>>(xi))&0x1]; |
| 82 | 76 | } |
| 83 | 77 | } |
| r14063 | r14064 | |
| 100 | 94 | |
| 101 | 95 | if(vidc_interlace) |
| 102 | 96 | { |
| 103 | if ((res_x) >= 0 && | |
| 104 | (res_y) >= 0 && | |
| 105 | (res_x) <= screen.visible_area().max_x && (res_y) <= screen.visible_area().max_y && (res_x) <= xend && (res_y) <= yend) | |
| 97 | if (cliprect.contains(res_x, res_y) && (res_x) <= xend && (res_y) <= yend) | |
| 106 | 98 | bitmap.pix32(res_y, res_x) = screen.machine().pens[(pen&0xff)+0x100]; |
| 107 | if ((res_x) >= 0 && | |
| 108 | (res_y) >= 0 && | |
| 109 | (res_x) <= screen.visible_area().max_x && (res_y+1) <= screen.visible_area().max_y && (res_x) <= xend && (res_y+1) <= yend) | |
| 99 | if (cliprect.contains(res_x, res_y) && (res_x) <= xend && (res_y+1) <= yend) | |
| 110 | 100 | bitmap.pix32(res_y+1, res_x) = screen.machine().pens[(pen&0xff)+0x100]; |
| 111 | 101 | } |
| 112 | 102 | else |
| 113 | 103 | { |
| 114 | if ((res_x) >= 0 && | |
| 115 | (res_y) >= 0 && | |
| 116 | (res_x) <= screen.visible_area().max_x && (res_y) <= screen.visible_area().max_y && (res_x) <= xend && (res_y) <= yend) | |
| 104 | if (cliprect.contains(res_x, res_y) && (res_x) <= xend && (res_y) <= yend) | |
| 117 | 105 | bitmap.pix32(res_y, res_x) = screen.machine().pens[(pen&0xff)+0x100]; |
| 118 | 106 | } |
| 119 | 107 |
| r14063 | r14064 | |
|---|---|---|
| 59 | 59 | |
| 60 | 60 | if (state->m_sprite_zoom) |
| 61 | 61 | { |
| 62 | rect.min_x = hpos - 16; | |
| 63 | rect.min_y = 196 - vpos; | |
| 64 | rect.max_x = rect.min_x + 63; | |
| 65 | rect.max_y = rect.min_y + 63; | |
| 62 | rect.set(hpos - 16, hpos - 16 + 63, 196 - vpos, 196 - vpos + 63); | |
| 66 | 63 | } |
| 67 | 64 | else |
| 68 | 65 | { |
| 69 | rect.min_x = hpos - 16; | |
| 70 | rect.min_y = 224 - vpos; | |
| 71 | rect.max_x = rect.min_x + 31; | |
| 72 | rect.max_y = rect.min_y + 31; | |
| 66 | rect.set(hpos - 16, hpos - 16 + 31, 224 - vpos, 224 - vpos + 31); | |
| 73 | 67 | } |
| 74 | 68 | |
| 75 | 69 | /* render sprite to auxiliary bitmap */ |
| r14063 | r14064 | |
| 78 | 72 | 2 * code + state->m_sprite_bank, 0, code & 8, 0, |
| 79 | 73 | rect.min_x, rect.min_y); |
| 80 | 74 | |
| 81 | if (rect.min_x < cliprect.min_x) | |
| 82 | rect.min_x = cliprect.min_x; | |
| 83 | if (rect.min_y < cliprect.min_y) | |
| 84 | rect.min_y = cliprect.min_y; | |
| 85 | if (rect.max_x > cliprect.max_x) | |
| 86 | rect.max_x = cliprect.max_x; | |
| 87 | if (rect.max_y > cliprect.max_y) | |
| 88 | rect.max_y = cliprect.max_y; | |
| 75 | rect &= cliprect; | |
| 89 | 76 | |
| 90 | 77 | /* check for collisions and copy sprite */ |
| 91 | 78 |
| r14063 | r14064 | |
|---|---|---|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /* draw the scanline */ |
| 342 | draw_scanline16(bitmap, cliprect.min_x, y, cliprect. | |
| 342 | draw_scanline16(bitmap, cliprect.min_x, y, cliprect.w | |
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 |
| r14063 | r14064 | |
|---|---|---|
| 914 | 914 | { |
| 915 | 915 | int drawxx = xx+sx; |
| 916 | 916 | |
| 917 | if ( | |
| 917 | if ( | |
| 918 | 918 | { |
| 919 | 919 | UINT8 pix = srcdata[count]; |
| 920 | 920 | UINT16* dstptr = &bitmap.pix16(drawyy, drawxx); |
| r14063 | r14064 | |
|---|---|---|
| 798 | 798 | { |
| 799 | 799 | nmk16_state *state = screen.machine().driver_data<nmk16_state>(); |
| 800 | 800 | /* sprites are DMA'd from Main RAM to a private buffer automatically |
| 801 | ||
| 801 | (or at least this is how I interpret the datasheet) */ | |
| 802 | 802 | |
| 803 | 803 | /* -- I actually see little evidence to support this, sprite lag |
| 804 | ||
| 804 | in some games should be checked on real boards */ | |
| 805 | 805 | |
| 806 | 806 | // memcpy(state->m_spriteram_old2,state->m_spriteram_old,0x1000); |
| 807 | 807 | memcpy(state->m_spriteram_old2,state->m_mainram+0x8000/2,0x1000); |
| r14063 | r14064 | |
| 815 | 815 | { |
| 816 | 816 | nmk16_state *state = screen.machine().driver_data<nmk16_state>(); |
| 817 | 817 | /* sprites are DMA'd from Main RAM to a private buffer automatically |
| 818 | ||
| 818 | (or at least this is how I interpret the datasheet) */ | |
| 819 | 819 | |
| 820 | 820 | /* -- I actually see little evidence to support this, sprite lag |
| 821 | ||
| 821 | in some games should be checked on real boards */ | |
| 822 | 822 | |
| 823 | 823 | /* strahl sprites are allocated in memory range FF000-FFFFF */ |
| 824 | 824 |
| r14063 | r14064 | |
|---|---|---|
| 42 | 42 | 8*8 /* every char takes 8 consecutive bytes */ |
| 43 | 43 | }; |
| 44 | 44 | |
| 45 | static | |
| 45 | static | |
| 46 | 46 | { |
| 47 | 47 | return (31 - col) * 32 + row; |
| 48 | 48 | } |
| r14063 | r14064 | |
|---|---|---|
| 402 | 402 | |
| 403 | 403 | color = ((state->m_magicram[count]) & 0x000f)>>0; |
| 404 | 404 | |
| 405 | if( | |
| 405 | if( | |
| 406 | 406 | bitmap.pix32(y, (x*4)+3) = screen.machine().pens[color]; |
| 407 | 407 | |
| 408 | 408 | color = ((state->m_magicram[count]) & 0x00f0)>>4; |
| 409 | 409 | |
| 410 | if( | |
| 410 | if( | |
| 411 | 411 | bitmap.pix32(y, (x*4)+2) = screen.machine().pens[color]; |
| 412 | 412 | |
| 413 | 413 | color = ((state->m_magicram[count]) & 0x0f00)>>8; |
| 414 | 414 | |
| 415 | if( | |
| 415 | if( | |
| 416 | 416 | bitmap.pix32(y, (x*4)+1) = screen.machine().pens[color]; |
| 417 | 417 | |
| 418 | 418 | color = ((state->m_magicram[count]) & 0xf000)>>12; |
| 419 | 419 | |
| 420 | if( | |
| 420 | if( | |
| 421 | 421 | bitmap.pix32(y, (x*4)+0) = screen.machine().pens[color]; |
| 422 | 422 | |
| 423 | 423 | count++; |
| r14063 | r14064 | |
| 434 | 434 | |
| 435 | 435 | color = ((state->m_magicram[count]) & 0x00ff)>>0; |
| 436 | 436 | |
| 437 | if( | |
| 437 | if( | |
| 438 | 438 | bitmap.pix32(y, (x*2)+1) = screen.machine().pens[color]; |
| 439 | 439 | |
| 440 | 440 | color = ((state->m_magicram[count]) & 0xff00)>>8; |
| 441 | 441 | |
| 442 | if( | |
| 442 | if( | |
| 443 | 443 | bitmap.pix32(y, (x*2)+0) = screen.machine().pens[color]; |
| 444 | 444 | |
| 445 | 445 | count++; |
| r14063 | r14064 | |
|---|---|---|
| 210 | 210 | assert(state->m_vblank_end < state->m_vblank_start); |
| 211 | 211 | |
| 212 | 212 | /* reconfigure the visible area to match */ |
| 213 | visarea.min_x = 0; | |
| 214 | visarea.max_x = 255; | |
| 215 | visarea.min_y = state->m_vblank_end; | |
| 216 | visarea.max_y = state->m_vblank_start - 1; | |
| 213 | visarea.set(0, 255, state->m_vblank_end, state->m_vblank_start - 1); | |
| 217 | 214 | machine.primary_screen->configure(320, 256, visarea, HZ_TO_ATTOSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL); |
| 218 | 215 | |
| 219 | 216 | /* configure the ROM banking */ |
| r14063 | r14064 | |
|---|---|---|
| 251 | 251 | state->m_frame_width = width; |
| 252 | 252 | state->m_frame_height = height; |
| 253 | 253 | |
| 254 | visarea.min_x = visarea.min_y = 0; | |
| 255 | visarea.max_x = width - 1; | |
| 256 | visarea.max_y = height - 1; | |
| 254 | visarea.set(0, width - 1, 0, height - 1); | |
| 257 | 255 | machine.primary_screen->configure(width, height * 262 / 240, visarea, machine.primary_screen->frame_period().attoseconds); |
| 258 | 256 | } |
| 259 | 257 |
| r14063 | r14064 | |
|---|---|---|
| 2808 | 2808 | ROM_LOAD( "ts2u_04.2h", 0x0000000, 0x080000, CRC(ddb52e7c) SHA1(e77891abae7681d911ef6eba2e0920d81433ebe6) ) |
| 2809 | 2809 | |
| 2810 | 2810 | ROM_REGION32_LE( 0x2400000, "user2", 0 ) |
| 2811 | ROM_LOAD( "ts2-05", 0x0000000, 0x400000, CRC(7f4228e2) SHA1(3690a76d19d97e55bc7b05a8456328697cfd7a77) ) | |
| 2812 | ROM_LOAD( "ts2-06m", 0x0400000, 0x400000, CRC(cd7e0a27) SHA1(325b5f2e653cdea07cddc9d20d12b5ab50dca949) ) | |
| 2813 | ROM_LOAD( "ts2-08m", 0x0800000, 0x400000, CRC(b1f7f115) SHA1(3f416d2aac07aa73a99593b5a21b047da60cea6a) ) | |
| 2814 | ROM_LOAD( "ts2-10", 0x0c00000, 0x200000, CRC(ad90679a) SHA1(19dd30764f892ee7f89c78ccbccdaf4d6b0e6e09) ) | |
| 2811 | ROM_LOAD( "ts2-05m.3h", 0x0000000, 0x400000, CRC(7f4228e2) SHA1(3690a76d19d97e55bc7b05a8456328697cfd7a77) ) | |
| 2812 | ROM_LOAD( "ts2-06m.4h", 0x0400000, 0x200000, CRC(67be6797) SHA1(521f69439ba7666f54d1008a291f3391f3a16499) ) | |
| 2813 | ROM_LOAD( "ts2-07m.5h", 0x0600000, 0x200000, CRC(db73e2b8) SHA1(239243f44c41df765789c14cc4036bb02e2ab373) ) | |
| 2814 | ROM_LOAD( "ts2-08m.2k", 0x0800000, 0x200000, CRC(01a48431) SHA1(6e395af726da91909e07dac25bb9b70b3ccebd4e) ) | |
| 2815 | ROM_LOAD( "ts2-09m.3k", 0x0a00000, 0x200000, CRC(83f408de) SHA1(415787c4dca604dd5611e16936a0ffa981dedf78) ) | |
| 2816 | ROM_LOAD( "ts2-10m.4k", 0x0c00000, 0x200000, CRC(ad90679a) SHA1(19dd30764f892ee7f89c78ccbccdaf4d6b0e6e09) ) | |
| 2815 | 2817 | |
| 2816 | 2818 | ROM_REGION( 0x50000, "audiocpu", 0 ) /* 64k for the audio CPU (+banks) */ |
| 2817 | 2819 | ROM_LOAD( "ts2_02.2e", 0x00000, 0x08000, CRC(2f45c461) SHA1(513b6b9b5a2f7c567c30c958e0e13834cd9bd266) ) |
| 2818 | 2820 | ROM_CONTINUE( 0x10000, 0x18000 ) |
| 2819 | 2821 | |
| 2820 | 2822 | ROM_REGION( 0x400000, "qsound", 0 ) /* Q Sound Samples */ |
| 2821 | ROM_LOAD16_WORD_SWAP( "ts2-01", 0x0000000, 0x400000, CRC(d7a505e0) SHA1(f1b0cdea712101f695bd326eccd753eb79a07490) ) | |
| 2823 | ROM_LOAD16_WORD_SWAP( "ts2-01m.3b", 0x0000000, 0x400000, CRC(d7a505e0) SHA1(f1b0cdea712101f695bd326eccd753eb79a07490) ) | |
| 2822 | 2824 | ROM_END |
| 2823 | 2825 | |
| 2824 | 2826 | /* 95681-2 */ |
| r14063 | r14064 | |
| 2829 | 2831 | ROM_LOAD( "ts2j_04.2h", 0x0000000, 0x080000, CRC(4aba8c5e) SHA1(a56001bf50bfc1b03036e88ae1febd1aac8c63c0) ) |
| 2830 | 2832 | |
| 2831 | 2833 | ROM_REGION32_LE( 0x2400000, "user2", 0 ) |
| 2832 | ROM_LOAD( "ts2-05", 0x0000000, 0x400000, CRC(7f4228e2) SHA1(3690a76d19d97e55bc7b05a8456328697cfd7a77) ) | |
| 2833 | ROM_LOAD( "ts2-06m", 0x0400000, 0x400000, CRC(cd7e0a27) SHA1(325b5f2e653cdea07cddc9d20d12b5ab50dca949) ) | |
| 2834 | ROM_LOAD( "ts2-08m", 0x0800000, 0x400000, CRC(b1f7f115) SHA1(3f416d2aac07aa73a99593b5a21b047da60cea6a) ) | |
| 2835 | ROM_LOAD( "ts2-10", 0x0c00000, 0x200000, CRC(ad90679a) SHA1(19dd30764f892ee7f89c78ccbccdaf4d6b0e6e09) ) | |
| 2834 | ROM_LOAD( "ts2-05m.3h", 0x0000000, 0x400000, CRC(7f4228e2) SHA1(3690a76d19d97e55bc7b05a8456328697cfd7a77) ) | |
| 2835 | ROM_LOAD( "ts2-06m.4h", 0x0400000, 0x200000, CRC(67be6797) SHA1(521f69439ba7666f54d1008a291f3391f3a16499) ) | |
| 2836 | ROM_LOAD( "ts2-07m.5h", 0x0600000, 0x200000, CRC(db73e2b8) SHA1(239243f44c41df765789c14cc4036bb02e2ab373) ) | |
| 2837 | ROM_LOAD( "ts2-08m.2k", 0x0800000, 0x200000, CRC(01a48431) SHA1(6e395af726da91909e07dac25bb9b70b3ccebd4e) ) | |
| 2838 | ROM_LOAD( "ts2-09m.3k", 0x0a00000, 0x200000, CRC(83f408de) SHA1(415787c4dca604dd5611e16936a0ffa981dedf78) ) | |
| 2839 | ROM_LOAD( "ts2-10m.4k", 0x0c00000, 0x200000, CRC(ad90679a) SHA1(19dd30764f892ee7f89c78ccbccdaf4d6b0e6e09) ) | |
| 2836 | 2840 | |
| 2837 | 2841 | ROM_REGION( 0x50000, "audiocpu", 0 ) /* 64k for the audio CPU (+banks) */ |
| 2838 | 2842 | ROM_LOAD( "ts2_02.2e", 0x00000, 0x08000, CRC(2f45c461) SHA1(513b6b9b5a2f7c567c30c958e0e13834cd9bd266) ) |
| 2839 | 2843 | ROM_CONTINUE( 0x10000, 0x18000 ) |
| 2840 | 2844 | |
| 2841 | 2845 | ROM_REGION( 0x400000, "qsound", 0 ) /* Q Sound Samples */ |
| 2842 | ROM_LOAD16_WORD_SWAP( "ts2-01", 0x0000000, 0x400000, CRC(d7a505e0) SHA1(f1b0cdea712101f695bd326eccd753eb79a07490) ) | |
| 2846 | ROM_LOAD16_WORD_SWAP( "ts2-01m.3b", 0x0000000, 0x400000, CRC(d7a505e0) SHA1(f1b0cdea712101f695bd326eccd753eb79a07490) ) | |
| 2843 | 2847 | ROM_END |
| 2844 | 2848 | |
| 2845 | 2849 | /* 95681-2 */ |
| r14063 | r14064 | |
| 2858 | 2862 | ROM_LOAD( "ps1-10m.4k", 0x1400000, 0x400000, CRC(ff80c18a) SHA1(8d01717eed6ec1f508fe7c445da941fb84ef7d22) ) |
| 2859 | 2863 | |
| 2860 | 2864 | ROM_REGION( 0x50000, "audiocpu", 0 ) /* 64k for the audio CPU (+banks) */ |
| 2861 | ROM_LOAD( "ps1_02a.2e", 0x000000, 0x008000, CRC(b854df92) SHA1(ea71a613b5b19ec7e9c6e342e7743d320582a6bb) ) | |
| 2862 | ROM_CONTINUE( 0x010000, 0x018000 ) | |
| 2863 | ROM_LOAD( "ps1_03a.3e", 0x028000, 0x020000, CRC(a2562fbb) SHA1(3de02a4aa7ea620961ca2a5c331f38134033db79) ) | |
| 2865 | ROM_LOAD( "ps1_02a.2e", 0x00000, 0x08000, CRC(b854df92) SHA1(ea71a613b5b19ec7e9c6e342e7743d320582a6bb) ) | |
| 2866 | ROM_CONTINUE( 0x10000, 0x18000 ) | |
| 2867 | ROM_LOAD( "ps1_03a.3e", 0x28000, 0x20000, CRC(a2562fbb) SHA1(3de02a4aa7ea620961ca2a5c331f38134033db79) ) | |
| 2864 | 2868 | |
| 2865 | 2869 | ROM_REGION( 0x400000, "qsound", 0 ) /* Q Sound Samples */ |
| 2866 | ROM_LOAD16_WORD_SWAP( "ps1-01m.3b", 0x000000, 0x400000, CRC(0bfb17aa) SHA1(cf4482785a2a33ad814c8b1461c5bc8e8e027895) ) | |
| 2870 | ROM_LOAD16_WORD_SWAP( "ps1-01m.3b", 0x0000000, 0x400000, CRC(0bfb17aa) SHA1(cf4482785a2a33ad814c8b1461c5bc8e8e027895) ) | |
| 2867 | 2871 | ROM_END |
| 2868 | 2872 | |
| 2869 | 2873 | /* 95681-2 */ |
| r14063 | r14064 | |
| 2882 | 2886 | ROM_LOAD( "ps1-10m.4k", 0x1400000, 0x400000, CRC(ff80c18a) SHA1(8d01717eed6ec1f508fe7c445da941fb84ef7d22) ) |
| 2883 | 2887 | |
| 2884 | 2888 | ROM_REGION( 0x50000, "audiocpu", 0 ) /* 64k for the audio CPU (+banks) */ |
| 2885 | ROM_LOAD( "ps1_02a.2e", 0x000000, 0x008000, CRC(b854df92) SHA1(ea71a613b5b19ec7e9c6e342e7743d320582a6bb) ) | |
| 2886 | ROM_CONTINUE( 0x010000, 0x018000 ) | |
| 2887 | ROM_LOAD( "ps1_03a.3e", 0x028000, 0x020000, CRC(a2562fbb) SHA1(3de02a4aa7ea620961ca2a5c331f38134033db79) ) | |
| 2889 | ROM_LOAD( "ps1_02a.2e", 0x00000, 0x08000, CRC(b854df92) SHA1(ea71a613b5b19ec7e9c6e342e7743d320582a6bb) ) | |
| 2890 | ROM_CONTINUE( 0x10000, 0x18000 ) | |
| 2891 | ROM_LOAD( "ps1_03a.3e", 0x28000, 0x20000, CRC(a2562fbb) SHA1(3de02a4aa7ea620961ca2a5c331f38134033db79) ) | |
| 2888 | 2892 | |
| 2889 | 2893 | ROM_REGION( 0x400000, "qsound", 0 ) /* Q Sound Samples */ |
| 2890 | ROM_LOAD16_WORD_SWAP( "ps1-01m.3b", 0x000000, 0x400000, CRC(0bfb17aa) SHA1(cf4482785a2a33ad814c8b1461c5bc8e8e027895) ) | |
| 2894 | ROM_LOAD16_WORD_SWAP( "ps1-01m.3b", 0x0000000, 0x400000, CRC(0bfb17aa) SHA1(cf4482785a2a33ad814c8b1461c5bc8e8e027895) ) | |
| 2891 | 2895 | ROM_END |
| 2892 | 2896 | |
| 2893 | 2897 | /* 95681-2 */ |
| r14063 | r14064 | |
|---|---|---|
| 126 | 126 | |
| 127 | 127 | color = (blit_ram[count] & 0xff)>>0; |
| 128 | 128 | |
| 129 | if( | |
| 129 | if( | |
| 130 | 130 | bitmap.pix32(y, x) = screen.machine().pens[color]; |
| 131 | 131 | |
| 132 | 132 | count++; |
| r14063 | r14064 | |
|---|---|---|
| 531 | 531 | { "GUNX1", "GUNY1" }, |
| 532 | 532 | { "GUNX2", "GUNY2" } |
| 533 | 533 | }; |
| 534 | gun_x[player] = input_port_read(space->machine(), names[player][0]) * (visarea.max_x + 1 - visarea.min_x) / 255 + visarea.min_x + BEAM_XOFFS; | |
| 535 | gun_y[player] = input_port_read(space->machine(), names[player][1]) * (visarea.max_y + 1 - visarea.min_y) / 255 + visarea.min_y; | |
| 534 | gun_x[player] = input_port_read(space->machine(), names[player][0]) * visarea.width() / 255 + visarea.min_x + BEAM_XOFFS; | |
| 535 | gun_y[player] = input_port_read(space->machine(), names[player][1]) * visarea.height() / 255 + visarea.min_y; | |
| 536 | 536 | gun_timer[player]->adjust(space->machine().primary_screen->time_until_pos(MAX(0, gun_y[player] - BEAM_DY), MAX(0, gun_x[player] - BEAM_DX)), player); |
| 537 | 537 | } |
| 538 | 538 | } |
| r14063 | r14064 | |
|---|---|---|
| 208 | 208 | |
| 209 | 209 | static void draw_pixel( bitmap_ind16 &bitmap, const rectangle &cliprect, int y, int x, int pen) |
| 210 | 210 | { |
| 211 | if (x>cliprect.max_x) return; | |
| 212 | if (x<cliprect.min_x) return; | |
| 213 | if (y>cliprect.max_y) return; | |
| 214 | if (y<cliprect.min_y) return; | |
| 215 | ||
| 216 | bitmap.pix16(y, x) = pen; | |
| 211 | if (cliprect.contains(x, y)) | |
| 212 | bitmap.pix16(y, x) = pen; | |
| 217 | 213 | } |
| 218 | 214 | |
| 219 | 215 | static UINT32 update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int screen_shift) |
| r14063 | r14064 | |
|---|---|---|
| 158 | 158 | for(pen_i = 0;pen_i<4;pen_i++) |
| 159 | 159 | color |= (((state->m_bitmap[count + pen_i*0x2000]) >> (7 - i)) & 1) << pen_i; |
| 160 | 160 | |
| 161 | if ( | |
| 161 | if ( | |
| 162 | 162 | bitmap.pix32(y, x + i) = screen.machine().pens[color]; |
| 163 | 163 | } |
| 164 | 164 |
| r14063 | r14064 | |
|---|---|---|
| 125 | 125 | |
| 126 | 126 | color = ((state->m_blit_ram[count]) & 0x00ff)>>0; |
| 127 | 127 | |
| 128 | if( | |
| 128 | if( | |
| 129 | 129 | bitmap.pix32(y, (x*2)+0) = screen.machine().pens[color]; |
| 130 | 130 | |
| 131 | 131 | color = ((state->m_blit_ram[count]) & 0xff00)>>8; |
| 132 | 132 | |
| 133 | if( | |
| 133 | if( | |
| 134 | 134 | bitmap.pix32(y, (x*2)+1) = screen.machine().pens[color]; |
| 135 | 135 | |
| 136 | 136 | count++; |
| r14063 | r14064 | |
| 162 | 162 | b = (color & 0x001f) << 3; |
| 163 | 163 | g = (color & 0x07e0) >> 3; |
| 164 | 164 | r = (color & 0xf800) >> 8; |
| 165 | if( | |
| 165 | if( | |
| 166 | 166 | bitmap.pix32(y, x) = b | (g<<8) | (r<<16); |
| 167 | 167 | |
| 168 | 168 | count++; |
| r14063 | r14064 | |
|---|---|---|
| 532 | 532 | /* The following custom_clip is to exclude the last char column (unused) |
| 533 | 533 | form the render. We need more proof about how the video is working. |
| 534 | 534 | */ |
| 535 | custom_clip.min_x=cliprect.min_x; | |
| 536 | custom_clip.max_x=cliprect.max_x-16; | |
| 537 | custom_clip.min_y=cliprect.min_y; | |
| 538 | custom_clip.max_y=cliprect.max_y; | |
| 535 | custom_clip = cliprect; | |
| 536 | custom_clip.max_x -= 16; | |
| 539 | 537 | |
| 540 | 538 | tilemap_draw(bitmap, custom_clip, state->m_bg_tilemap, 0, 0); |
| 541 | 539 | tilemap_draw(bitmap, custom_clip, state->m_fg_tilemap, 0, 0); |
| r0 | r14064 | |
|---|---|---|
| 1 | /*************************************************************************** | |
| 2 | ||
| 3 | Ichi Ban Jyan | |
| 4 | Excel, 199? | |
| 5 | ||
| 6 | TODO: code is encrypted (data, not opcodes) | |
| 7 | ||
| 8 | PCB Layout | |
| 9 | ---------- | |
| 10 | ||
| 11 | MJ911 | |
| 12 | |----------------------------------| | |
| 13 | |MB3712 DSW-D DSW-C DSW-B DSW-A SW| | |
| 14 | | M6378 BATT | | |
| 15 | |VOL 6264 3 | | |
| 16 | | YM2413 MJB | | |
| 17 | |M 1 2 | | |
| 18 | |A YM2149 MJG |-------| | | |
| 19 | |H |ALTERA | Z80 | | |
| 20 | |J MJR |EP1810 | | | |
| 21 | |O | | ALTERA | | |
| 22 | |N |-------| EP910 | | |
| 23 | |G | | |
| 24 | | | | |
| 25 | | 41464 41464 | | |
| 26 | | 41464 41464 18.432MHz| | |
| 27 | |----------------------------------| | |
| 28 | Notes: | |
| 29 | Z80 clock - 6.144MHz [18.432/3] | |
| 30 | YM2149 clock - 1.536MHz [18.432/12] | |
| 31 | YM2413 clock - 3.072MHz [18.432/6] | |
| 32 | VSync - 60.5686Hz | |
| 33 | HSync - 15.510kHz | |
| 34 | ||
| 35 | ***************************************************************************/ | |
| 36 | ||
| 37 | #define ADDRESS_MAP_MODERN | |
| 38 | ||
| 39 | #include "emu.h" | |
| 40 | #include "cpu/z80/z80.h" | |
| 41 | #include "sound/ay8910.h" | |
| 42 | #include "sound/2413intf.h" | |
| 43 | ||
| 44 | #define MAIN_CLOCK XTAL_18_432MHz | |
| 45 | ||
| 46 | class ichibanjyan_state : public driver_device | |
| 47 | { | |
| 48 | public: | |
| 49 | ichibanjyan_state(const machine_config &mconfig, device_type type, const char *tag) | |
| 50 | : driver_device(mconfig, type, tag), | |
| 51 | m_maincpu(*this, "maincpu") | |
| 52 | { } | |
| 53 | ||
| 54 | // devices | |
| 55 | required_device<cpu_device> m_maincpu; | |
| 56 | ||
| 57 | // driver_device overrides | |
| 58 | virtual void machine_start(); | |
| 59 | virtual void machine_reset(); | |
| 60 | ||
| 61 | virtual void video_start(); | |
| 62 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); | |
| 63 | ||
| 64 | DECLARE_WRITE8_MEMBER( bank_w ); | |
| 65 | }; | |
| 66 | ||
| 67 | void ichibanjyan_state::video_start() | |
| 68 | { | |
| 69 | ||
| 70 | } | |
| 71 | ||
| 72 | UINT32 ichibanjyan_state::screen_update( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) | |
| 73 | { | |
| 74 | return 0; | |
| 75 | } | |
| 76 | ||
| 77 | ||
| 78 | static ADDRESS_MAP_START( ichibanjyan_map, AS_PROGRAM, 8, ichibanjyan_state ) | |
| 79 | AM_RANGE(0x0000, 0x7fff) AM_ROMBANK("bank1") | |
| 80 | ADDRESS_MAP_END | |
| 81 | ||
| 82 | static ADDRESS_MAP_START( ichibanjyan_io, AS_IO, 8, ichibanjyan_state ) | |
| 83 | ADDRESS_MAP_GLOBAL_MASK(0xff) | |
| 84 | ADDRESS_MAP_END | |
| 85 | ||
| 86 | static INPUT_PORTS_START( ichibanjyan ) | |
| 87 | INPUT_PORTS_END | |
| 88 | ||
| 89 | static const gfx_layout charlayout = | |
| 90 | { | |
| 91 | 8,8, | |
| 92 | RGN_FRAC(1,1), | |
| 93 | 8, | |
| 94 | { 0, 1, 2, 3, 4, 5, 6, 7 }, | |
| 95 | { STEP8( 0*512, 8 ) }, | |
| 96 | { STEP8( 0*512, 8*8 ) }, | |
| 97 | 8*8*8 | |
| 98 | }; | |
| 99 | ||
| 100 | static GFXDECODE_START( ichibanjyan ) | |
| 101 | GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 1 ) | |
| 102 | GFXDECODE_ENTRY( "gfx2", 0, charlayout, 0, 1 ) | |
| 103 | GFXDECODE_END | |
| 104 | ||
| 105 | ||
| 106 | void ichibanjyan_state::machine_start() | |
| 107 | { | |
| 108 | UINT8 *ROM = machine().region("code")->base(); | |
| 109 | ||
| 110 | memory_configure_bank(machine(), "bank1", 0, 4, ROM, 0x8000); | |
| 111 | } | |
| 112 | ||
| 113 | void ichibanjyan_state::machine_reset() | |
| 114 | { | |
| 115 | } | |
| 116 | ||
| 117 | ||
| 118 | static MACHINE_CONFIG_START( ichibanjyan, ichibanjyan_state ) | |
| 119 | ||
| 120 | /* basic machine hardware */ | |
| 121 | MCFG_CPU_ADD("maincpu",Z80,MAIN_CLOCK/3) | |
| 122 | MCFG_CPU_PROGRAM_MAP(ichibanjyan_map) | |
| 123 | MCFG_CPU_IO_MAP(ichibanjyan_io) | |
| 124 | ||
| 125 | /* video hardware */ | |
| 126 | MCFG_SCREEN_ADD("screen", RASTER) | |
| 127 | MCFG_SCREEN_REFRESH_RATE(60) | |
| 128 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) | |
| 129 | MCFG_SCREEN_UPDATE_DRIVER(ichibanjyan_state, screen_update) | |
| 130 | MCFG_SCREEN_SIZE(32*8, 32*8) | |
| 131 | MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) | |
| 132 | ||
| 133 | MCFG_GFXDECODE(ichibanjyan) | |
| 134 | ||
| 135 | MCFG_PALETTE_INIT(RRRR_GGGG_BBBB) | |
| 136 | MCFG_PALETTE_LENGTH(512) | |
| 137 | ||
| 138 | /* sound hardware */ | |
| 139 | MCFG_SPEAKER_STANDARD_MONO("mono") | |
| 140 | MCFG_SOUND_ADD("aysnd", YM2149, MAIN_CLOCK/12) | |
| 141 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) | |
| 142 | ||
| 143 | MCFG_SOUND_ADD("ymsnd", YM2413, MAIN_CLOCK/6) | |
| 144 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) | |
| 145 | MACHINE_CONFIG_END | |
| 146 | ||
| 147 | ||
| 148 | /*************************************************************************** | |
| 149 | ||
| 150 | Game driver(s) | |
| 151 | ||
| 152 | ***************************************************************************/ | |
| 153 | ||
| 154 | ROM_START( ichiban ) | |
| 155 | ROM_REGION( 0x20000, "code", 0 ) | |
| 156 | ROM_LOAD( "3.u15", 0, 0x20000, CRC(76240568) SHA1(cf055d1eaae25661a49ec4722a2c7caca862e66a) ) | |
| 157 | ||
| 158 | ROM_REGION( 0x20000, "gfx1", 0 ) | |
| 159 | ROM_LOAD( "1.u28", 0, 0x20000, CRC(2caa4d3f) SHA1(5e5af164880140b764c097a65388c22ba5ea572b) ) | |
| 160 | ||
| 161 | ROM_REGION( 0x20000, "gfx2", 0 ) | |
| 162 | ROM_LOAD( "2.u14", 0, 0x20000, CRC(b4834d8e) SHA1(836ddf7586dc5440faf88f5ec50a32265e9a0ec8) ) | |
| 163 | ||
| 164 | ROM_REGION( 0x600, "proms", 0 ) | |
| 165 | ROM_LOAD( "mjr.u36", 0x000, 0x200, CRC(31cd7a90) SHA1(1525ad19d748561a52626e4ab13df67d9bedf3b8) ) | |
| 166 | ROM_LOAD( "mjg.u37", 0x200, 0x200, CRC(5b3562aa) SHA1(ada60d2a5a5a657d7b209d18a23b685305d9ff7b) ) | |
| 167 | ROM_LOAD( "mjb.u38", 0x400, 0x200, CRC(0ef881cb) SHA1(44b61a443d683f5cb2d1b1a4f74d8a8f41021de5) ) | |
| 168 | ROM_END | |
| 169 | ||
| 170 | GAME( 199?, ichiban, 0, ichibanjyan, ichibanjyan, 0, ROT0, "Excel", "Ichi Ban Jyan", GAME_NOT_WORKING | GAME_NO_SOUND ) |
| r14063 | r14064 | |
|---|---|---|
| 4432 | 4432 | static DRIVER_INIT( kovboot ) |
| 4433 | 4433 | { |
| 4434 | 4434 | pgm_basic_init(machine); |
| 4435 | // | |
| 4435 | // pgm_kov_decrypt(machine); | |
| 4436 | 4436 | kovsh_latch_init(machine); |
| 4437 | 4437 | install_protection_asic_sim_kov(machine); |
| 4438 | 4438 | } |
| r14063 | r14064 | |
|---|---|---|
| 120 | 120 | for(pen_i = 0;pen_i<4;pen_i++) |
| 121 | 121 | color |= ((bg_rom[y*320/8+x+(pen_i*0x20000)+yi*0x400+state->m_bg_bank*0x2000+1] >> (7-xi)) & 1) << pen_i; |
| 122 | 122 | |
| 123 | if( | |
| 123 | if( | |
| 124 | 124 | bitmap.pix32(y*8+yi, x*8+xi) = screen.machine().pens[color]; |
| 125 | 125 | } |
| 126 | 126 | } |
| r14063 | r14064 | |
|---|---|---|
| 3937 | 3937 | NAOMI_DEFAULT_EEPROM |
| 3938 | 3938 | |
| 3939 | 3939 | ROM_REGION( 0x4000000, "rom_board", ROMREGION_ERASEFF) |
| 3940 | ROM_LOAD( "epr-23071.ic11", 0x0000000, 0x0200000, CRC(1b58f24a) SHA1(90f91af31beff9399c8d72ae0087bf4d3122cac2) ) | |
| 3941 | ROM_LOAD32_WORD( "mpr-23063.ic17s", 0x1000000, 0x0800000, CRC(9678a759) SHA1(6f2602c6eef8db0d4a145d832aec3ea0e0491c0c) ) | |
| 3942 | ROM_LOAD32_WORD( "mpr-23064.ic18", 0x1000002, 0x0800000, CRC(e159c44d) SHA1(fd0dcd74f7e214c7c9214bb04167f7c3acea30cf) ) | |
| 3943 | ROM_LOAD32_WORD( "mpr-23065.ic19s", 0x2000000, 0x0800000, CRC(10eff527) SHA1(c208529b0825ba45dc474c6aaa4b4c5557335c10) ) | |
| 3944 | ROM_LOAD32_WORD( "mpr-23066.ic20", 0x2000002, 0x0800000, CRC(4f9c1710) SHA1(7834bab5933a156656756f837c217e7820f2ae63) ) | |
| 3945 | ROM_LOAD32_WORD( "mpr-23067.ic21s", 0x3000000, 0x0800000, CRC(32724cd9) SHA1(7bfdd58dd5e69529125a720f51c53ebe526ef2e9) ) | |
| 3946 | ROM_LOAD32_WORD( "mpr-23068.ic22", 0x3000002, 0x0800000, CRC(2ce3e0ea) SHA1(805ec80273856ec6e5ee04fdca5fd1407c404f8e) ) | |
| 3940 | ROM_LOAD( "epr-23071.ic11", 0x0000000, 0x0200000, CRC(1b58f24a) SHA1(90f91af31beff9399c8d72ae0087bf4d3122cac2) ) | |
| 3941 | ROM_LOAD32_WORD( "mpr-23063.ic17s", 0x1000000, 0x0800000, CRC(9678a759) SHA1(6f2602c6eef8db0d4a145d832aec3ea0e0491c0c) ) | |
| 3942 | ROM_LOAD32_WORD( "mpr-23064.ic18", 0x1000002, 0x0800000, CRC(e159c44d) SHA1(fd0dcd74f7e214c7c9214bb04167f7c3acea30cf) ) | |
| 3943 | ROM_LOAD32_WORD( "mpr-23065.ic19s", 0x2000000, 0x0800000, CRC(10eff527) SHA1(c208529b0825ba45dc474c6aaa4b4c5557335c10) ) | |
| 3944 | ROM_LOAD32_WORD( "mpr-23066.ic20", 0x2000002, 0x0800000, CRC(4f9c1710) SHA1(7834bab5933a156656756f837c217e7820f2ae63) ) | |
| 3945 | ROM_LOAD32_WORD( "mpr-23067.ic21s", 0x3000000, 0x0800000, CRC(32724cd9) SHA1(7bfdd58dd5e69529125a720f51c53ebe526ef2e9) ) | |
| 3946 | ROM_LOAD32_WORD( "mpr-23068.ic22", 0x3000002, 0x0800000, CRC(2ce3e0ea) SHA1(805ec80273856ec6e5ee04fdca5fd1407c404f8e) ) | |
| 3947 | 3947 | |
| 3948 | 3948 | ROM_REGION( 4, "rom_key", 0 ) |
| 3949 | ROM_LOAD( "tduno2.key", 0x000000, 0x000004, CRC(8e0f0f3b) SHA1(914d3db8746c806d559539cc0851169161d32c04) ) | |
| 3949 | ROM_LOAD( "tduno2.key", 0x000000, 0x000004, CRC(8e0f0f3b) SHA1(914d3db8746c806d559539cc0851169161d32c04) ) | |
| 3950 | 3950 | ROM_END |
| 3951 | 3951 | |
| 3952 | ROM_START( mtkob2 ) | |
| 3953 | NAOMI_BIOS | |
| 3954 | NAOMI_DEFAULT_EEPROM | |
| 3955 | ||
| 3956 | ROM_REGION( 0x4000000, "rom_board", ROMREGION_ERASEFF) | |
| 3957 | ROM_LOAD( "epr-24217.ic11", 0x0000000, 0x0400000, CRC(5ecf807b) SHA1(f91d03a68a44d02970e360789b746bec9289275f) ) | |
| 3958 | ROM_LOAD32_WORD( "mpr-24218.ic17s", 0x1000000, 0x0800000, CRC(e8c51e1d) SHA1(e81f0580e144aa7a7e8c9399ffa09227b6e93675) ) | |
| 3959 | ROM_LOAD32_WORD( "mpr-24219.ic18", 0x1000002, 0x0800000, CRC(b0a5709f) SHA1(993f7a99d59a924641c37a549208723342007e5a) ) | |
| 3960 | ROM_LOAD32_WORD( "mpr-24220.ic19s", 0x2000000, 0x0800000, CRC(9f6cefe2) SHA1(499e17d2c284b340db6b124b63a23c7fa5045d0f) ) | |
| 3961 | ROM_LOAD32_WORD( "mpr-24221.ic20", 0x2000002, 0x0800000, CRC(73bf9cc6) SHA1(ab187cc0babd1435f5e8636331818d81de23636f) ) | |
| 3962 | ROM_LOAD32_WORD( "mpr-24222.ic21s", 0x3000000, 0x0800000, CRC(7098e728) SHA1(82f4f57efcee3063467c24758cefd406dccb1ea4) ) | |
| 3963 | ROM_LOAD32_WORD( "mpr-24223.ic22", 0x3000002, 0x0800000, CRC(eca13c90) SHA1(26a66906bf4ebda8697140d89eb5e493e941e8b2) ) | |
| 3964 | ||
| 3965 | ROM_REGION( 4, "rom_key", 0 ) | |
| 3966 | ROM_LOAD( "mtkob2-key.bin", 0x000000, 0x000004, CRC(db088208) SHA1(14d65ad2555183a445abcd93907c85df4032b41d) ) | |
| 3967 | ROM_END | |
| 3968 | ||
| 3952 | 3969 | ROM_START( crackndj ) |
| 3953 | 3970 | NAOMI_BIOS |
| 3954 | 3971 | NAOMI_DEFAULT_EEPROM |
| r14063 | r14064 | |
| 5450 | 5467 | NAOMI_DEFAULT_EEPROM |
| 5451 | 5468 | |
| 5452 | 5469 | ROM_REGION( 0x10000000, "rom_board", ROMREGION_ERASEFF) |
| 5453 | ROM_LOAD( "trf1_fl0.2f", 0x0000000, 0x0800000, CRC(862e673d) SHA1(f2c90932ba4abe31d02e86f80ef3e2689342c384) ) | |
| 5454 | ROM_LOAD( "trf1_fl1.2d", 0x0800000, 0x0800000, CRC(59a935c9) SHA1(7298d83a27eac74bad18d716a791ab2016fe028f) ) | |
| 5455 | ROM_LOAD( "trf1_ma1.4n", 0x1000000, 0x1000000, CRC(b1b3ab96) SHA1(3dc4bcf796583a0fb51359a86a46d7883df54fad) ) | |
| 5456 | ROM_LOAD( "trf1_ma2.4m", 0x2000000, 0x1000000, CRC(a27d3dda) SHA1(b9ec4be5845cbe91fd7bc537669e96716513a5f0) ) | |
| 5457 | ROM_LOAD( "trf1_ma3.4l", 0x3000000, 0x1000000, CRC(345ec434) SHA1(986d9930e7de46b88936c898ba8b05d950262a1f) ) | |
| 5458 | ROM_LOAD( "trf1_ma4.4k", 0x4000000, 0x1000000, CRC(fc47a104) SHA1(07ced58c1b17719ac36db1589771e67ce16d912e) ) | |
| 5459 | ROM_LOAD( "trf1_ma5.4j", 0x5000000, 0x1000000, CRC(e1bb077d) SHA1(6b70d8103bf067319e9022742fc1dd843d7e5076) ) | |
| 5460 | ROM_LOAD( "trf1_ma6.4h", 0x6000000, 0x1000000, CRC(abae4d06) SHA1(56da2ca3551287942afabf37e7fd1b884bd3cac8) ) | |
| 5461 | ROM_LOAD( "trf1_ma7.4f", 0x7000000, 0x1000000, CRC(19d0092a) SHA1(2ae2dbf2f3958da9f69b3a8636c6837e4243bb67) ) | |
| 5462 | ROM_LOAD( "trf1_ma8.4e", 0x8000000, 0x1000000, CRC(6fbf34ab) SHA1(f4747d1a1c02e22502e68d72a4f0c152fa69d778) ) | |
| 5463 | ROM_LOAD( "trf1_ma9.4d", 0x9000000, 0x1000000, CRC(2fa36c5d) SHA1(6478687c91484141521ae79a997cecbcfbb7beae) ) | |
| 5464 | ROM_LOAD( "trf1_ma10.4c", 0xa000000, 0x1000000, CRC(bc866a37) SHA1(d4d12f285a3bc9136cf3fc2a59dba5ad557cc7d7) ) | |
| 5465 | ROM_LOAD( "trf1_ma11.4b", 0xb000000, 0x1000000, CRC(68d11482) SHA1(fe991ba5664d6ccf0aac5167f05c5a780f851ae9) ) | |
| 5466 | ROM_LOAD( "trf1_ma12.6p", 0xc000000, 0x1000000, CRC(a7c3bd3c) SHA1(ed5a24e4c47f686120577dae4550fb9378209cf8) ) | |
| 5467 | ROM_LOAD( "trf1_ma13.6n", 0xd000000, 0x1000000, CRC(e52d41fe) SHA1(e1769d42d6048f9621ca289af3ddeca7c14cee00) ) | |
| 5468 | ROM_LOAD( "trf1_ma14.6m", 0xe000000, 0x1000000, CRC(87cb31a0) SHA1(27aef9ac571a0b5e3a76e4ee22f5bc5d0ae962f2) ) | |
| 5469 | ROM_LOAD( "trf1_ma15.6l", 0xf000000, 0x1000000, CRC(42d318c5) SHA1(f9fe82ffbfc51fcb52333f94c55a7092e7124fb4) ) | |
| 5470 | ROM_LOAD( "trf1_fl0.2f", 0x0000000, 0x0800000, CRC(862e673d) SHA1(f2c90932ba4abe31d02e86f80ef3e2689342c384) ) | |
| 5471 | ROM_LOAD( "trf1_fl1.2d", 0x0800000, 0x0800000, CRC(59a935c9) SHA1(7298d83a27eac74bad18d716a791ab2016fe028f) ) | |
| 5472 | ROM_LOAD( "trf1_ma1.4n", 0x1000000, 0x1000000, CRC(b1b3ab96) SHA1(3dc4bcf796583a0fb51359a86a46d7883df54fad) ) | |
| 5473 | ROM_LOAD( "trf1_ma2.4m", 0x2000000, 0x1000000, CRC(a27d3dda) SHA1(b9ec4be5845cbe91fd7bc537669e96716513a5f0) ) | |
| 5474 | ROM_LOAD( "trf1_ma3.4l", 0x3000000, 0x1000000, CRC(345ec434) SHA1(986d9930e7de46b88936c898ba8b05d950262a1f) ) | |
| 5475 | ROM_LOAD( "trf1_ma4.4k", 0x4000000, 0x1000000, CRC(fc47a104) SHA1(07ced58c1b17719ac36db1589771e67ce16d912e) ) | |
| 5476 | ROM_LOAD( "trf1_ma5.4j", 0x5000000, 0x1000000, CRC(e1bb077d) SHA1(6b70d8103bf067319e9022742fc1dd843d7e5076) ) | |
| 5477 | ROM_LOAD( "trf1_ma6.4h", 0x6000000, 0x1000000, CRC(abae4d06) SHA1(56da2ca3551287942afabf37e7fd1b884bd3cac8) ) | |
| 5478 | ROM_LOAD( "trf1_ma7.4f", 0x7000000, 0x1000000, CRC(19d0092a) SHA1(2ae2dbf2f3958da9f69b3a8636c6837e4243bb67) ) | |
| 5479 | ROM_LOAD( "trf1_ma8.4e", 0x8000000, 0x1000000, CRC(6fbf34ab) SHA1(f4747d1a1c02e22502e68d72a4f0c152fa69d778) ) | |
| 5480 | ROM_LOAD( "trf1_ma9.4d", 0x9000000, 0x1000000, CRC(2fa36c5d) SHA1(6478687c91484141521ae79a997cecbcfbb7beae) ) | |
| 5481 | ROM_LOAD( "trf1_ma10.4c", 0xa000000, 0x1000000, CRC(bc866a37) SHA1(d4d12f285a3bc9136cf3fc2a59dba5ad557cc7d7) ) | |
| 5482 | ROM_LOAD( "trf1_ma11.4b", 0xb000000, 0x1000000, CRC(68d11482) SHA1(fe991ba5664d6ccf0aac5167f05c5a780f851ae9) ) | |
| 5483 | ROM_LOAD( "trf1_ma12.6p", 0xc000000, 0x1000000, CRC(a7c3bd3c) SHA1(ed5a24e4c47f686120577dae4550fb9378209cf8) ) | |
| 5484 | ROM_LOAD( "trf1_ma13.6n", 0xd000000, 0x1000000, CRC(e52d41fe) SHA1(e1769d42d6048f9621ca289af3ddeca7c14cee00) ) | |
| 5485 | ROM_LOAD( "trf1_ma14.6m", 0xe000000, 0x1000000, CRC(87cb31a0) SHA1(27aef9ac571a0b5e3a76e4ee22f5bc5d0ae962f2) ) | |
| 5486 | ROM_LOAD( "trf1_ma15.6l", 0xf000000, 0x1000000, CRC(42d318c5) SHA1(f9fe82ffbfc51fcb52333f94c55a7092e7124fb4) ) | |
| 5470 | 5487 | |
| 5471 | 5488 | ROM_REGION( 4, "rom_key", 0 ) |
| 5472 | ROM_LOAD( "tr4ae-key.bin", 0x000000, 0x000004, CRC(986a7cee) SHA1(70c3ff80f86de6a0655251658c66a156fb644995) ) | |
| 5489 | ROM_LOAD( "tr4ae-key.bin", 0x000000, 0x000004, CRC(986a7cee) SHA1(70c3ff80f86de6a0655251658c66a156fb644995) ) | |
| 5473 | 5490 | ROM_END |
| 5474 | 5491 | |
| 5475 | 5492 | ROM_START( vtenis2c ) |
| r14063 | r14064 | |
| 7716 | 7733 | /* 0020 */ GAME( 1999, samba, naomi, naomim2, naomi, naomi, ROT0, "Sega", "Samba De Amigo (JPN) (Rev B)", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) |
| 7717 | 7734 | /* 0021 */ GAME( 2000, virnbao, virnba, naomim2, naomi, naomi, ROT0, "Sega", "Virtua NBA (JPN, USA, EXP, KOR, AUS) (original)", GAME_FLAGS ) |
| 7718 | 7735 | /* 0021-01 */ GAME( 2000,virnba, naomi, naomi, naomi, naomi, ROT0, "Sega", "Virtua NBA (JPN, USA, EXP, KOR, AUS)", GAME_FLAGS ) |
| 7719 | /* 0022 */ GAME( 2000, tduno2, naomi, naomim2, naomi, naomi, ROT0, "Sega", "Touch de Uno! 2", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) | |
| 7736 | /* 0022 */ GAME( 2000, tduno2, naomi, naomim2, naomi, naomi, ROT0, "Sega", "Touch de Uno! 2", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) | |
| 7720 | 7737 | /* 0023 */ GAME( 2000, 18wheelr, naomi, naomim2, 18wheelr, naomi, ROT0, "Sega", "18 Wheeler Deluxe (Rev A) (JPN)", GAME_FLAGS ) |
| 7721 | 7738 | /* 0023 */ GAME( 2000, 18wheels, 18wheelr, naomim2, 18wheelr, naomi, ROT0, "Sega", "18 Wheeler (Rev A) (JPN)", GAME_FLAGS ) |
| 7722 | 7739 | // 0025 Mars TV |
| r14063 | r14064 | |
| 7746 | 7763 | /* 0126 */ GAME( 2003, oinori, naomi, naomi, naomi, naomi, ROT0, "Sega", "Oinori-daimyoujin Matsuri", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) |
| 7747 | 7764 | /* 0128 */ GAME( 2002, shootpl, naomi, naomim1, naomi, naomi, ROT0, "Sega", "Shootout Pool (JPN, USA, KOR, AUS) / Shootout Pool Prize (EXP)", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) |
| 7748 | 7765 | /* 0140 */ GAME( 2004, kick4csh, naomi, naomim1, naomi, kick4csh, ROT0, "Sega", "Kick '4' Cash", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) |
| 7749 | / | |
| 7766 | /* 0150 */ GAME( 2003, mtkob2, naomi, naomim1, naomi, naomi, ROT0, "Sega", "Mushiking The King Of Beetle 2K3 2nd", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) | |
| 7750 | 7767 | // 0164 MushiKing The King Of Beetle II ENG |
| 7751 | 7768 | // 0166 Touch De Zunou (Japan) |
| 7752 | 7769 | // 0166 Touch De Zunou (Japan) (Rev A) |
| r14063 | r14064 | |
| 7798 | 7815 | |
| 7799 | 7816 | /* Cart games on Namco custom ROM board */ |
| 7800 | 7817 | /* 25209801 */ GAME( 2000, wldkicks, naomi, naomim2, naomi, naomi, ROT0, "Capcom / Namco", "World Kicks", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) |
| 7801 | /* 25349801 */ GAME( 2000, toukon4, naomi, naomim2, naomi, naomi, ROT0, "Capcom / Namco", "Shin Nihon Pro Wrestling Toukon Retsuden 4 Arcade Edition", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) | |
| 7818 | /* 25349801 */ GAME( 2000, toukon4, naomi, naomim2, naomi, naomi, ROT0, "Capcom / Namco", "Shin Nihon Pro Wrestling Toukon Retsuden 4 Arcade Edition", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) | |
| 7802 | 7819 | // 25469801 Ninja Assault |
| 7803 | 7820 | /* 25709801 */ GAME( 2001, gunsur2, naomi, naomi, naomi, naomi, ROT0, "Capcom / Namco", "Gun Survivor 2 Biohazard Code: Veronica", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) |
| 7804 | 7821 | // 25869812 Mazan : Flash of the Blade |
| r14063 | r14064 | |
|---|---|---|
| 21 | 21 | Final Godori (c) 2001 SemiCom (version 2.20.5915) |
| 22 | 22 | Wyvern Wings (c) 2001 SemiCom |
| 23 | 23 | Mr. Kicker (c) 2001 SemiCom [1] |
| 24 | Toy Land Adventure (c) 2001 SemiCom | |
| 24 | Toy Land Adventure (c) 2001 SemiCom | |
| 25 | 25 | Age Of Heroes - Silkroad 2 (c) 2001 Unico (v0.63 - 2001/02/07) |
| 26 | 26 | |
| 27 | 27 | Real games bugs: |
| 28 | 28 | - dquizgo2: bugged video test |
| 29 | 29 | |
| 30 | 30 | Notes: |
| 31 | [1] Mr. Kicker game code crashes if the eeprom values are empty, because it replaces the SP register with a bogus value at PC = $18D0 before crashing. | |
| 32 | It could be an original game bug or a hyperstone core bug | |
| 33 | [2] Toy Land Adventure is currently missing graphics roms which makes it non-working. | |
| 31 | [1] Mr. Kicker game code crashes if the eeprom values are empty, because it replaces | |
| 32 | the SP register with a bogus value at PC = $18D0 before crashing. It could be an | |
| 33 | original game bug or a hyperstone core bug. Also happens with High Score update. | |
| 34 | 34 | |
| 35 | 35 | Mr Kicker is also known to exist (not dumped) on the F-E1-16-010 PCB that |
| 36 | 36 | Semicom also used for Toy Land Adventure & SemiComDate Quiz Go Go Episode 2 game. |
| r14063 | r14064 | |
| 1328 | 1328 | ROM_START( toyland ) |
| 1329 | 1329 | ROM_REGION16_BE( 0x100000, "user1", ROMREGION_ERASE00 ) /* Hyperstone CPU Code */ |
| 1330 | 1330 | /* ROM1 empty */ |
| 1331 | ROM_LOAD( "rom2", 0x80000, 0x080000, CRC(e3455002) SHA1(5ad7884f82fb125d70829accec02f238e7d9593c) ) | |
| 1331 | ROM_LOAD( "rom2.bin", 0x80000, 0x080000, CRC(e3455002) SHA1(5ad7884f82fb125d70829accec02f238e7d9593c) ) | |
| 1332 | 1332 | |
| 1333 | 1333 | ROM_REGION( 0xc00000, "gfx1", 0 ) /* 16x16x8 Sprites */ |
| 1334 | ROM_LOAD32_WORD( "roml00", 0x000000, 0x200000, NO_DUMP ) | |
| 1335 | ROM_LOAD32_WORD( "romu00", 0x000002, 0x200000, NO_DUMP ) | |
| 1336 | ROM_LOAD32_WORD( "roml01", 0x400000, 0x200000, NO_DUMP ) | |
| 1337 | ROM_LOAD32_WORD( "romu01", 0x400002, 0x200000, NO_DUMP ) | |
| 1334 | ROM_LOAD32_WORD( "roml00.bin", 0x000000, 0x200000, CRC(06f5673d) SHA1(23769015fc9a37d36b0fe4924964650aeca77573) ) | |
| 1335 | ROM_LOAD32_WORD( "romu00.bin", 0x000002, 0x200000, CRC(8c3db0e4) SHA1(6101ec550ae165338333fb04e0762edee65ca253) ) | |
| 1336 | ROM_LOAD32_WORD( "roml01.bin", 0x400000, 0x200000, CRC(076a84e1) SHA1(f58cb4cd874e1f3f266a5ccbf8ffb5e0111034d3) ) | |
| 1337 | ROM_LOAD32_WORD( "romu01.bin", 0x400002, 0x200000, CRC(1bc33d01) SHA1(a2a3e6b473cefe463dbd60bda98cb5a4df2bc81b) ) | |
| 1338 | 1338 | /* roml02 empty */ |
| 1339 | 1339 | /* romu02 empty */ |
| 1340 | 1340 | /* roml03 empty */ |
| 1341 | 1341 | /* romu03 empty */ |
| 1342 | 1342 | |
| 1343 | 1343 | ROM_REGION( 0x40000, "oki", 0 ) /* Oki Samples */ |
| 1344 | ROM_LOAD( "vrom1", 0x00000, 0x40000, CRC(d7e6fc5d) SHA1(ab5bca4035299214d98b222320276fbcaedb0898) ) | |
| 1344 | ROM_LOAD( "vrom1.bin", 0x00000, 0x40000, CRC(d7e6fc5d) SHA1(ab5bca4035299214d98b222320276fbcaedb0898) ) | |
| 1345 | ||
| 1346 | ROM_REGION16_BE( 0x80, "eeprom", 0 ) /* Default EEPROM */ | |
| 1347 | ROM_LOAD( "epr1.ic3", 0x0000, 0x0080, CRC(812f3d87) SHA1(744919ff4b44eaa3c4dcc75a1cc2f231ccbb4a3e) ) | |
| 1348 | ||
| 1345 | 1349 | ROM_END |
| 1346 | 1350 | |
| 1347 | 1351 | /* |
| r14063 | r14064 | |
| 1954 | 1958 | static READ16_HANDLER( toyland_speedup_r ) |
| 1955 | 1959 | { |
| 1956 | 1960 | vamphalf_state *state = space->machine().driver_data<vamphalf_state>(); |
| 1957 | ||
| 1961 | ||
| 1958 | 1962 | if (cpu_get_pc(&space->device()) == 0x130c2) |
| 1959 | 1963 | device_spin_until_interrupt(&space->device()); |
| 1960 | 1964 | |
| r14063 | r14064 | |
| 2138 | 2142 | GAME( 2000, mrdig, 0, mrdig, common, mrdig, ROT0, "Sun", "Mr. Dig", 0 ) |
| 2139 | 2143 | GAME( 2001, finalgdr, 0, finalgdr, finalgdr, finalgdr, ROT0, "SemiCom", "Final Godori (Korea, version 2.20.5915)", 0 ) |
| 2140 | 2144 | GAME( 2001, mrkicker, 0, mrkicker, finalgdr, mrkicker, ROT0, "SemiCom", "Mr. Kicker", GAME_NOT_WORKING ) // game stops booting / working properly after you get a high score, or if you don't have a default eeprom with 'valid data. It's never worked properly, CPU core issue? |
| 2141 | GAME( 2001, toyland, 0, coolmini, common, toyland, ROT0, "SemiCom", "Toy Land Adventure", | |
| 2145 | GAME( 2001, toyland, 0, coolmini, common, toyland, ROT0, "SemiCom", "Toy Land Adventure", 0 | |
| 2142 | 2146 | GAME( 2001, wyvernwg, 0, wyvernwg, common, wyvernwg, ROT270, "SemiCom (Game Vision license)", "Wyvern Wings", GAME_NO_SOUND ) |
| 2143 | 2147 | GAME( 2001, aoh, 0, aoh, aoh, aoh, ROT0, "Unico", "Age Of Heroes - Silkroad 2 (v0.63 - 2001/02/07)", 0 ) |
| r14063 | r14064 | |
|---|---|---|
| 251 | 251 | poly_vertex v1, v2, v3; |
| 252 | 252 | poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(state->m_poly); |
| 253 | 253 | |
| 254 | clip.min_x = 0; | |
| 255 | clip.min_y = 0; | |
| 256 | clip.max_x = 511; | |
| 257 | clip.max_y = 511; | |
| 254 | clip.set(0, 511, 0, 511); | |
| 258 | 255 | |
| 259 | 256 | extra->color = color; |
| 260 | 257 | extra->screen_ram = state->m_screen_ram; |
| r14063 | r14064 | |
|---|---|---|
| 116 | 116 | /* basic machine hardware */ |
| 117 | 117 | MCFG_CPU_ADD("maincpu", ARM7, 20000000) // ?? unknown CPU, has internal ROM. |
| 118 | 118 | MCFG_CPU_PROGRAM_MAP(pgm2_map) |
| 119 | // | |
| 119 | // MCFG_DEVICE_DISABLE() | |
| 120 | 120 | |
| 121 | 121 | MCFG_MACHINE_START( pgm2 ) |
| 122 | 122 | MCFG_MACHINE_RESET( pgm2 ) |
| r14063 | r14064 | |
| 152 | 152 | ROM_REGION( 0x1000000, "bgtile", 0 ) |
| 153 | 153 | ROM_LOAD16_BYTE( "ig-a.u35", 0x000000, 0x0800000, CRC(083a8315) SHA1(0dba25e132fbb12faa59ced648c27b881dc73478) ) |
| 154 | 154 | ROM_LOAD16_BYTE( "ig-a.u36", 0x000001, 0x0800000, CRC(e197221d) SHA1(5574b1e3da4b202db725be906dd868edc2fd4634) ) |
| 155 | ||
| 155 | ||
| 156 | 156 | ROM_REGION( 0x2000000, "spritesa", 0 ) // 1bpp sprite mask data |
| 157 | 157 | ROM_LOAD32_WORD( "ig-a.u12", 0x000000, 0x1000000, CRC(113a331c) SHA1(ee6b31bb2b052cc8799573de0d2f0a83f0ab4f6a) ) |
| 158 | 158 | ROM_LOAD32_WORD( "ig-a.u16", 0x000002, 0x1000000, CRC(fbf411c8) SHA1(5089b5cc9bbf6496ef1367c6255e63e9ab895117) ) |
| r14063 | r14064 | |
| 175 | 175 | ROM_REGION( 0x1000000, "bgtile", 0 ) |
| 176 | 176 | ROM_LOAD16_BYTE( "ig-a.u35", 0x000000, 0x0800000, CRC(083a8315) SHA1(0dba25e132fbb12faa59ced648c27b881dc73478) ) |
| 177 | 177 | ROM_LOAD16_BYTE( "ig-a.u36", 0x000001, 0x0800000, CRC(e197221d) SHA1(5574b1e3da4b202db725be906dd868edc2fd4634) ) |
| 178 | ||
| 178 | ||
| 179 | 179 | ROM_REGION( 0x2000000, "spritesa", 0 ) // 1bpp sprite mask data |
| 180 | 180 | ROM_LOAD32_WORD( "ig-a.u12", 0x000000, 0x1000000, CRC(113a331c) SHA1(ee6b31bb2b052cc8799573de0d2f0a83f0ab4f6a) ) |
| 181 | 181 | ROM_LOAD32_WORD( "ig-a.u16", 0x000002, 0x1000000, CRC(fbf411c8) SHA1(5089b5cc9bbf6496ef1367c6255e63e9ab895117) ) |
| r14063 | r14064 | |
| 198 | 198 | ROM_REGION( 0x1000000, "bgtile", 0 ) |
| 199 | 199 | ROM_LOAD16_BYTE( "ig-a3.u35", 0x000000, 0x0800000, CRC(2d46b1f6) SHA1(ea8c805eda6292e86a642e9633d8fee7054d10b1) ) |
| 200 | 200 | ROM_LOAD16_BYTE( "ig-a3.u36", 0x000001, 0x0800000, CRC(df710c36) SHA1(f826c3f496c4f17b46d18af1d8e02cac7b7027ac) ) |
| 201 | ||
| 201 | ||
| 202 | 202 | ROM_REGION( 0x2000000, "spritesa", 0 ) // 1bpp sprite mask data |
| 203 | 203 | ROM_LOAD32_WORD( "ig-a3.u12", 0x000000, 0x1000000, CRC(0bf63836) SHA1(b8e4f1951f8074b475b795bd7840c5a375b6f5ef) ) |
| 204 | 204 | ROM_LOAD32_WORD( "ig-a3.u16", 0x000002, 0x1000000, CRC(4a378542) SHA1(5d06a8a8796285a786ebb690c34610f923ef5570) ) |
| r14063 | r14064 | |
| 221 | 221 | ROM_REGION( 0x1000000, "bgtile", 0 ) |
| 222 | 222 | ROM_LOAD16_BYTE( "ig-a3.u35", 0x000000, 0x0800000, CRC(2d46b1f6) SHA1(ea8c805eda6292e86a642e9633d8fee7054d10b1) ) |
| 223 | 223 | ROM_LOAD16_BYTE( "ig-a3.u36", 0x000001, 0x0800000, CRC(df710c36) SHA1(f826c3f496c4f17b46d18af1d8e02cac7b7027ac) ) |
| 224 | ||
| 224 | ||
| 225 | 225 | ROM_REGION( 0x2000000, "spritesa", 0 ) // 1bpp sprite mask data |
| 226 | 226 | ROM_LOAD32_WORD( "ig-a3.u12", 0x000000, 0x1000000, CRC(0bf63836) SHA1(b8e4f1951f8074b475b795bd7840c5a375b6f5ef) ) |
| 227 | 227 | ROM_LOAD32_WORD( "ig-a3.u16", 0x000002, 0x1000000, CRC(4a378542) SHA1(5d06a8a8796285a786ebb690c34610f923ef5570) ) |
| r14063 | r14064 | |
| 240 | 240 | |
| 241 | 241 | for (i = 1; i < len / 2; i+=2) |
| 242 | 242 | { |
| 243 | UINT16 x = ixor; | |
| 243 | UINT16 x = ixor; | |
| 244 | 244 | |
| 245 | 245 | if ( (i>>1) & 0x000001) x ^= 0x0010; |
| 246 | 246 | if ( (i>>1) & 0x000002) x ^= 0x2004; |
| r14063 | r14064 | |
| 265 | 265 | |
| 266 | 266 | for (i = 0; i < len / 2; i+=2) |
| 267 | 267 | { |
| 268 | UINT16 x = ixor; | |
| 268 | UINT16 x = ixor; | |
| 269 | 269 | |
| 270 | 270 | if ( (i>>1) & 0x000001) x ^= 0x9004; |
| 271 | 271 | if ( (i>>1) & 0x000002) x ^= 0x0028; |
| r14063 | r14064 | |
|---|---|---|
| 222 | 222 | tilemap_set_scrolly( state->m_sc0w_tilemap,0, 32); |
| 223 | 223 | |
| 224 | 224 | /* maybe it needs two window tilemaps? (one at the top, the other at the bottom)*/ |
| 225 | clip.min_x = visarea.min_x; | |
| 226 | clip.max_x = 256; | |
| 227 | clip.min_y = 192; | |
| 228 | clip.max_y = visarea.max_y; | |
| 225 | clip.set(visarea.min_x, 256, 192, visarea.max_y); | |
| 229 | 226 | |
| 230 | 227 | /*TILEMAP_DRAW_CATEGORY + TILEMAP_DRAW_OPAQUE doesn't suit well?*/ |
| 231 | 228 | tilemap_draw(bitmap,cliprect,state->m_sc0_tilemap,0,0); |
| r14063 | r14064 | |
|---|---|---|
| 80 | 80 | : driver_device(mconfig, type, tag) { } |
| 81 | 81 | |
| 82 | 82 | virtual void video_start(); |
| 83 | ||
| 83 | ||
| 84 | 84 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 85 | ||
| 85 | ||
| 86 | 86 | bitmap_ind16 m_bitmap; |
| 87 | 87 | |
| 88 | 88 | UINT8 m_drawctrl[3]; |
| r14063 | r14064 | |
|---|---|---|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | /* Set the clipping rect to mask off the other portion of the sprite */ |
| 587 | rect.min_x=sx; | |
| 588 | rect.max_x=sx+(sizex-1); | |
| 589 | rect.min_y=sy; | |
| 590 | rect.max_y=sy+(sizey-1); | |
| 587 | rect.set(sx, sx+(sizex-1), sy, sy+(sizey-1)); | |
| 588 | rect &= cliprect; | |
| 591 | 589 | |
| 592 | if (cliprect.min_x > rect.min_x) rect.min_x = cliprect.min_x; | |
| 593 | if (cliprect.max_x < rect.max_x) rect.max_x = cliprect.max_x; | |
| 594 | if (cliprect.min_y > rect.min_y) rect.min_y = cliprect.min_y; | |
| 595 | if (cliprect.max_y < rect.max_y) rect.max_y = cliprect.max_y; | |
| 596 | ||
| 597 | 590 | if( !bBigSprite ) |
| 598 | 591 | { |
| 599 | 592 | sizex = 16; |
| r14063 | r14064 | |
| 604 | 597 | sx -= (tile&1)?16:0; |
| 605 | 598 | sy -= (tile&2)?16:0; |
| 606 | 599 | |
| 607 | rect.min_x=sx; | |
| 608 | rect.max_x=sx+(sizex-1); | |
| 609 | rect.min_y=sy; | |
| 610 | rect.max_y=sy+(sizey-1); | |
| 600 | rect.set(sx, sx+(sizex-1), sy, sy+(sizey-1)); | |
| 611 | 601 | rect.min_x += (tile&1)?16:0; |
| 612 | 602 | rect.max_x += (tile&1)?16:0; |
| 613 | 603 | rect.min_y += (tile&2)?16:0; |
| r14063 | r14064 | |
| 804 | 794 | hpos -= xscroll; |
| 805 | 795 | vpos -= yscroll; |
| 806 | 796 | pWinAttr = &spriteram16[0x2400/2+((palette>>8)&0xf)*4]; |
| 807 | clip.min_x = pWinAttr[0] - xscroll; | |
| 808 | clip.max_x = pWinAttr[1] - xscroll; | |
| 809 | clip.min_y = pWinAttr[2] - yscroll; | |
| 810 | clip.max_y = pWinAttr[3] - yscroll; | |
| 811 | if( clip.min_x < cliprect.min_x ){ clip.min_x = cliprect.min_x; } | |
| 812 | if( clip.min_y < cliprect.min_y ){ clip.min_y = cliprect.min_y; } | |
| 813 | if( clip.max_x > cliprect.max_x ){ clip.max_x = cliprect.max_x; } | |
| 814 | if( clip.max_y > cliprect.max_y ){ clip.max_y = cliprect.max_y; } | |
| 797 | clip.set(pWinAttr[0] - xscroll, pWinAttr[1] - xscroll, pWinAttr[2] - yscroll, pWinAttr[3] - yscroll); | |
| 798 | clip &= cliprect; | |
| 815 | 799 | hpos&=0x7ff; if( hpos&0x400 ) hpos |= ~0x7ff; /* sign extend */ |
| 816 | 800 | vpos&=0x7ff; if( vpos&0x400 ) vpos |= ~0x7ff; /* sign extend */ |
| 817 | 801 | |
| r14063 | r14064 | |
| 1310 | 1294 | UnpackRozParam( pSource, &rozInfo ); |
| 1311 | 1295 | if( pri == rozInfo.priority ) |
| 1312 | 1296 | { |
| 1313 | clip.min_x = 0; | |
| 1314 | clip.max_x = bitmap.width()-1; | |
| 1315 | clip.min_y = clip.max_y = line; | |
| 1297 | clip.set(0, bitmap.width()-1, line, line); | |
| 1298 | clip &= cliprect; | |
| 1316 | 1299 | |
| 1317 | if( clip.min_x < cliprect.min_x ){ clip.min_x = cliprect.min_x; } | |
| 1318 | if( clip.min_y < cliprect.min_y ){ clip.min_y = cliprect.min_y; } | |
| 1319 | if( clip.max_x > cliprect.max_x ){ clip.max_x = cliprect.max_x; } | |
| 1320 | if( clip.max_y > cliprect.max_y ){ clip.max_y = cliprect.max_y; } | |
| 1321 | ||
| 1322 | 1300 | DrawRozHelper( bitmap, mRozTilemap[which], clip, &rozInfo ); |
| 1323 | 1301 | } /* priority */ |
| 1324 | 1302 | } /* enabled */ |
| r14063 | r14064 | |
|---|---|---|
| 86 | 86 | g = (g << 2) | (g & 3); |
| 87 | 87 | b = (b << 3) | (b & 0x7); |
| 88 | 88 | |
| 89 | if( | |
| 89 | if( | |
| 90 | 90 | bitmap.pix32(y, x) = r | g<<8 | b<<16; |
| 91 | 91 | |
| 92 | 92 | count+=2; |
| r14063 | r14064 | |
| 97 | 97 | |
| 98 | 98 | color = blit_ram[count]; |
| 99 | 99 | |
| 100 | if( | |
| 100 | if( | |
| 101 | 101 | bitmap.pix32(y, x) = screen.machine().pens[color]; |
| 102 | 102 | |
| 103 | 103 | count++; |
| r14063 | r14064 | |
|---|---|---|
| 60 | 60 | { |
| 61 | 61 | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 62 | 62 | |
| 63 | *x = (((input_port_read(machine, player ? "GUNX2" : "GUNX1") & 0xff) * (visarea.max_x - visarea.min_x)) >> 8) + visarea.min_x; | |
| 64 | *y = (((input_port_read(machine, player ? "GUNY2" : "GUNY1") & 0xff) * (visarea.max_y - visarea.min_y)) >> 8) + visarea.min_y; | |
| 63 | *x = (((input_port_read(machine, player ? "GUNX2" : "GUNX1") & 0xff) * visarea.width()) >> 8) + visarea.min_x; | |
| 64 | *y = (((input_port_read(machine, player ? "GUNY2" : "GUNY1") & 0xff) * visarea.height()) >> 8) + visarea.min_y; | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 |
| r14063 | r14064 | |
|---|---|---|
| 92 | 92 | UINT16 *sprite_list=state->m_sprram; |
| 93 | 93 | UINT16 *sprite_list_end=&state->m_sprram[0x4000]; //guess |
| 94 | 94 | UINT8 *pixels=(UINT8 *)state->m_tileram; |
| 95 | const rectangle &visarea = screen.visible_area(); | |
| 96 | 95 | |
| 97 | 96 | //Table surface seems to be tiles, but display corrupts when switching the scene if always ON. |
| 98 | 97 | //Currently the tiles are OFF. |
| r14063 | r14064 | |
| 168 | 167 | xs2 = (sprite_sublist[SPRITE_PALETTE] & 0x8000) ? (sizex - xs) : xs; |
| 169 | 168 | if(pen) |
| 170 | 169 | { |
| 171 | if( | |
| 170 | if(cl | |
| 172 | 171 | { |
| 173 | 172 | UINT16 pixdata=state->m_palram[pen+((sprite_sublist[SPRITE_PALETTE]&0xff)<<8)]; |
| 174 | 173 | bitmap.pix32(yb+ys2, xb+xs2) = ((pixdata&0x7c00)>>7) | ((pixdata&0x3e0)<<6) | ((pixdata&0x1f)<<19); |
| r14063 | r14064 | |
|---|---|---|
| 89 | 89 | g = (color & 0x03e0) >> 2; |
| 90 | 90 | r = (color & 0x7c00) >> 7; |
| 91 | 91 | |
| 92 | if( | |
| 92 | if( | |
| 93 | 93 | bitmap.pix32(y, x) = b | (g<<8) | (r<<16); |
| 94 | 94 | |
| 95 | 95 |
| r14063 | r14064 | |
|---|---|---|
| 474 | 474 | |
| 475 | 475 | color = (state->m_blit_ram[count] & 0xf000)>>12; |
| 476 | 476 | |
| 477 | if( | |
| 477 | if( | |
| 478 | 478 | bitmap.pix32(y, x+3) = screen.machine().pens[color]; |
| 479 | 479 | |
| 480 | 480 | color = (state->m_blit_ram[count] & 0x0f00)>>8; |
| 481 | 481 | |
| 482 | if( | |
| 482 | if( | |
| 483 | 483 | bitmap.pix32(y, x+2) = screen.machine().pens[color]; |
| 484 | 484 | |
| 485 | 485 | color = (state->m_blit_ram[count] & 0x00f0)>>4; |
| 486 | 486 | |
| 487 | if( | |
| 487 | if( | |
| 488 | 488 | bitmap.pix32(y, x+1) = screen.machine().pens[color]; |
| 489 | 489 | |
| 490 | 490 | color = (state->m_blit_ram[count] & 0x000f)>>0; |
| 491 | 491 | |
| 492 | if( | |
| 492 | if( | |
| 493 | 493 | bitmap.pix32(y, x+0) = screen.machine().pens[color]; |
| 494 | 494 | |
| 495 | 495 | count++; |
| r14063 | r14064 | |
|---|---|---|
| 179 | 179 | assert(state->m_vblank_end < state->m_vblank_start); |
| 180 | 180 | |
| 181 | 181 | /* reconfigure the visible area to match */ |
| 182 | visarea.min_x = 0; | |
| 183 | visarea.max_x = 255; | |
| 184 | visarea.min_y = state->m_vblank_end + 1; | |
| 185 | visarea.max_y = state->m_vblank_start; | |
| 182 | visarea.set(0, 255, state->m_vblank_end + 1, state->m_vblank_start); | |
| 186 | 183 | machine.primary_screen->configure(320, 256, visarea, HZ_TO_ATTOSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL); |
| 187 | 184 | |
| 188 | 185 | /* create a timer for IRQs and set up the first callback */ |
| r14063 | r14064 | |
|---|---|---|
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | // driver_device overrides |
| 80 | // | |
| 80 | // virtual void video_start(); | |
| 81 | 81 | }; |
| 82 | 82 | |
| 83 | 83 | // Intel 82439TX System Controller (MXTC) |
| r14063 | r14064 | |
|---|---|---|
| 830 | 830 | //printf("%04x %04x %d\n",zz, xxxscroll, line/8); |
| 831 | 831 | |
| 832 | 832 | /* draw top of screen */ |
| 833 | clip.min_x = visarea.min_x; | |
| 834 | clip.max_x = 511; | |
| 835 | clip.min_y = startclipmin; | |
| 836 | clip.max_y = startclipmin; | |
| 833 | clip.set(visarea.min_x, 511, startclipmin, startclipmin); | |
| 837 | 834 | |
| 838 | 835 | |
| 839 | 836 |
| r14063 | r14064 | |
|---|---|---|
| 192 | 192 | |
| 193 | 193 | if (!depth) |
| 194 | 194 | { |
| 195 | if ( | |
| 195 | if ( | |
| 196 | 196 | { |
| 197 | 197 | dat = (rom[(tileaddr*32)+count] & 0xf0)>>4; |
| 198 | 198 | if (dat!=15) |
| r14063 | r14064 | |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | drawx++; |
| 206 | if ( | |
| 206 | if ( | |
| 207 | 207 | { |
| 208 | 208 | dat = (rom[(tileaddr*32)+count] & 0x0f); |
| 209 | 209 | if (dat!=15) |
| r14063 | r14064 | |
| 218 | 218 | } |
| 219 | 219 | else |
| 220 | 220 | { |
| 221 | if ( | |
| 221 | if ( | |
| 222 | 222 | { |
| 223 | 223 | dat = (rom[(tileaddr*32)+count] & 0xff); |
| 224 | 224 | if (dat!=255) |
| r14063 | r14064 | |
|---|---|---|
| 269 | 269 | const rectangle &visarea = screen.visible_area(); |
| 270 | 270 | int i; |
| 271 | 271 | |
| 272 | rectangle clip; | |
| 272 | rectangle clip = visarea; | |
| 273 | 273 | |
| 274 | clip.min_x = visarea.min_x; | |
| 275 | clip.max_x = visarea.max_x; | |
| 276 | clip.min_y = visarea.min_y; | |
| 277 | clip.max_y = visarea.max_y; | |
| 278 | ||
| 279 | 274 | bitmap.fill(0, cliprect); |
| 280 | 275 | |
| 281 | 276 | for (i= 0;i < 64;i++) |
| r14063 | r14064 | |
|---|---|---|
| 114 | 114 | |
| 115 | 115 | color = (blit_ram[count] & 0xff)>>0; |
| 116 | 116 | |
| 117 | if( | |
| 117 | if( | |
| 118 | 118 | bitmap.pix32(y, x) = screen.machine().pens[color]; |
| 119 | 119 | |
| 120 | 120 | count++; |
| r14063 | r14064 | |
|---|---|---|
| 119 | 119 | static WRITE32_HANDLER( spriteram_buffer_w ) |
| 120 | 120 | { |
| 121 | 121 | limenko_state *state = space->machine().driver_data<limenko_state>(); |
| 122 | rectangle clip; | |
| 123 | clip.min_x = 0; | |
| 124 | clip.max_x = 383; | |
| 125 | clip.min_y = 0; | |
| 126 | clip.max_y = 239; | |
| 122 | rectangle clip(0, 383, 0, 239); | |
| 127 | 123 | |
| 128 | 124 | state->m_sprites_bitmap_pri.fill(0, clip); |
| 129 | 125 | state->m_sprites_bitmap.fill(0, clip); |
| r14063 | r14064 | |
|---|---|---|
| 84 | 84 | const rectangle &visarea = screen.visible_area(); |
| 85 | 85 | |
| 86 | 86 | /* tilemap layout is a bit strange ... */ |
| 87 | rectangle clip; | |
| 88 | clip.min_x = visarea.min_x; | |
| 87 | rectangle clip = visarea; | |
| 89 | 88 | clip.max_x = 256 - 1; |
| 90 | clip.min_y = visarea.min_y; | |
| 91 | clip.max_y = visarea.max_y; | |
| 92 | 89 | tilemap_set_scrollx(state->m_tilemap, 0, 256); |
| 93 | 90 | tilemap_draw(bitmap, clip, state->m_tilemap, 0, 0); |
| 94 | 91 | |
| 95 | 92 | clip.min_x = 256; |
| 96 | 93 | clip.max_x = 512 - 1; |
| 97 | clip.min_y = visarea.min_y; | |
| 98 | clip.max_y = visarea.max_y; | |
| 99 | 94 | tilemap_set_scrollx(state->m_tilemap, 0, -128); |
| 100 | 95 | tilemap_draw(bitmap, clip, state->m_tilemap, 0, 0); |
| 101 | 96 |
| r14063 | r14064 | |
|---|---|---|
| 298 | 298 | int rowenable = state->m_bg_scroll2[zz]; |
| 299 | 299 | |
| 300 | 300 | /* draw top of screen */ |
| 301 | clip.min_x = visarea.min_x; | |
| 302 | clip.max_x = visarea.max_x; | |
| 303 | clip.min_y = startclipmin; | |
| 304 | clip.max_y = startclipmin+2; | |
| 301 | clip.set(visarea.min_x, visarea.max_x, startclipmin, startclipmin+2); | |
| 305 | 302 | |
| 306 | 303 | bitmap.fill(screen.machine().pens[rowenable], clip); |
| 307 | 304 |
| r14063 | r14064 | |
|---|---|---|
| 547 | 547 | int x = OBJ_X(state->m_obj1_x) + sx; |
| 548 | 548 | int y = OBJ_Y(state->m_obj1_y) + sy; |
| 549 | 549 | |
| 550 | if ( | |
| 550 | if (! | |
| 551 | 551 | continue; |
| 552 | 552 | |
| 553 | 553 | if (state->m_obj1->pix16(sy, sx) == 0) |
| r14063 | r14064 | |
|---|---|---|
| 847 | 847 | // between 0x00 and 0x80 (0x40 is normal, 0x80 would be 'view twice as much', 0x20 is 'view half as much') |
| 848 | 848 | state->m_renderbuffer_bitmap.allocate(512*2,224*2); |
| 849 | 849 | |
| 850 | state->m_renderbuffer_clip.min_x = 0; | |
| 851 | state->m_renderbuffer_clip.max_x = state->m_screenwidth-1; | |
| 852 | state->m_renderbuffer_clip.min_y = 0; | |
| 853 | state->m_renderbuffer_clip.max_y = 224-1; | |
| 850 | state->m_renderbuffer_clip.set(0, state->m_screenwidth-1, 0, 224-1); | |
| 854 | 851 | |
| 855 | 852 | state->m_renderbuffer_bitmap.fill(0x3f, state->m_renderbuffer_clip); |
| 856 | 853 | |
| r14063 | r14064 | |
| 912 | 909 | |
| 913 | 910 | if (drawline>cliprect.max_y+4) return; |
| 914 | 911 | |
| 915 | clip.min_x = cliprect.min_x; | |
| 916 | clip.max_x = cliprect.max_x; | |
| 917 | clip.min_y = drawline; | |
| 918 | clip.max_y = drawline; | |
| 912 | clip.set(cliprect.min_x, cliprect.max_x, drawline, drawline); | |
| 919 | 913 | |
| 920 | 914 | for (x=0;x<(cliprect.max_x/16)+2;x++) |
| 921 | 915 | { |
| r14063 | r14064 | |
| 964 | 958 | if (state->m_screenwidth!=496) |
| 965 | 959 | { |
| 966 | 960 | state->m_screenwidth = 496; |
| 967 | visarea.min_x = 0; visarea.max_x = 496-1; | |
| 968 | visarea.min_y = 0; visarea.max_y = 224-1; | |
| 961 | visarea.set(0, 496-1, 0, 224-1); | |
| 969 | 962 | screen.configure(496, 224, visarea, period); |
| 970 | 963 | } |
| 971 | 964 | } |
| r14063 | r14064 | |
| 974 | 967 | if (state->m_screenwidth!=384) |
| 975 | 968 | { |
| 976 | 969 | state->m_screenwidth = 384; |
| 977 | visarea.min_x = 0; visarea.max_x = 384-1; | |
| 978 | visarea.min_y = 0; visarea.max_y = 224-1; | |
| 970 | visarea.set(0, 384-1, 0, 224-1); | |
| 979 | 971 | screen.configure(384, 224, visarea, period); |
| 980 | 972 | } |
| 981 | 973 | } |
| r14063 | r14064 | |
|---|---|---|
| 36 | 36 | tonton_state(const machine_config &mconfig, device_type type, const char *tag) |
| 37 | 37 | : driver_device(mconfig, type, tag), |
| 38 | 38 | m_v9938(*this, "v9938") { } |
| 39 | ||
| 39 | ||
| 40 | 40 | required_device<v9938_device> m_v9938; |
| 41 | 41 | }; |
| 42 | 42 |
| r14063 | r14064 | |
|---|---|---|
| 107 | 107 | |
| 108 | 108 | for (y = bally; y < bally + 2; y++) |
| 109 | 109 | for (x = ballx; x < ballx + 2; x++) |
| 110 | if (x >= cliprect.min_x && | |
| 111 | x <= cliprect.max_x && | |
| 112 | y >= cliprect.min_y && | |
| 113 | y <= cliprect.max_y) | |
| 110 | if (cliprect.contains(x, y)) | |
| 114 | 111 | bitmap.pix16(y, x) = 1; |
| 115 | 112 | return 0; |
| 116 | 113 | } |
| r14063 | r14064 | |
|---|---|---|
| 127 | 127 | { |
| 128 | 128 | color = state->m_fg_fb[(xi+yi*8)+count*0x40]; |
| 129 | 129 | |
| 130 | if( | |
| 130 | if( | |
| 131 | 131 | bitmap.pix16(x+yi, 256-y+xi) = screen.machine().pens[(color & 0x7)]; |
| 132 | 132 | } |
| 133 | 133 | } |
| r14063 | r14064 | |
|---|---|---|
| 196 | 196 | int rowenable = state->m_bg_scroll2[j]; |
| 197 | 197 | |
| 198 | 198 | /* draw top of screen */ |
| 199 | clip.min_x = visarea.min_x; | |
| 200 | clip.max_x = visarea.max_x; | |
| 201 | clip.min_y = startclipmin; | |
| 202 | clip.max_y = startclipmin+1; | |
| 199 | clip.set(visarea.min_x, visarea.max_x, startclipmin, startclipmin+1); | |
| 203 | 200 | |
| 204 | 201 | if (rowenable==0) |
| 205 | 202 | { |
| r14063 | r14064 | |
|---|---|---|
| 64 | 64 | if (xpos == -1 || ypos == -1) |
| 65 | 65 | return FALSE; |
| 66 | 66 | |
| 67 | *x = visarea.min_x + xpos * (visarea.max_x - visarea.min_x + 1) / 255; | |
| 68 | *y = visarea.min_y + ypos * (visarea.max_y - visarea.min_y + 1) / 255; | |
| 67 | *x = visarea.min_x + xpos * visarea.width() / 255; | |
| 68 | *y = visarea.min_y + ypos * visarea.height() / 255; | |
| 69 | 69 | return TRUE; |
| 70 | 70 | } |
| 71 | 71 |
| r14063 | r14064 | |
|---|---|---|
| 387 | 387 | |
| 388 | 388 | if (BIT(data, 5)) |
| 389 | 389 | { |
| 390 | if (state->m_ldv1000 != NULL) | |
| 390 | if (state->m_ldv1000 != NULL) | |
| 391 | 391 | { |
| 392 | 392 | state->m_ldv1000->data_w(state->m_laserdisc_data); |
| 393 | 393 | state->m_ldv1000->enter_w(BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE); |
| r14063 | r14064 | |
| 760 | 760 | state->m_cart_present = 0; |
| 761 | 761 | state->m_pr7820_enter = 0; |
| 762 | 762 | |
| 763 | // newtype = (input_port_read(machine, "DSWB") & 0x18) ? LASERDISC_TYPE_PIONEER_LDV1000 : LASERDISC_TYPE_PIONEER_PR7820; | |
| 764 | // laserdisc_set_type(state->m_laserdisc, newtype); | |
| 763 | // newtype = (input_port_read(machine, "DSWB") & 0x18) ? LASERDISC_TYPE_PIONEER_LDV1000 : LASERDISC_TYPE_PIONEER_PR7820; | |
| 764 | // laserdisc_set_type(state->m_laserdisc, newtype); | |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /* COP400 Interface */ |
| r14063 | r14064 | |
|---|---|---|
| 80 | 80 | |
| 81 | 81 | color = (blit_ram[count] & 0xff); |
| 82 | 82 | |
| 83 | if( | |
| 83 | if( | |
| 84 | 84 | bitmap.pix32(y, x+0) = screen.machine().pens[color]; |
| 85 | 85 | |
| 86 | 86 | count++; |
| r14063 | r14064 | |
|---|---|---|
| 85 | 85 | if (m_ldv1000 != NULL) return m_ldv1000->status_strobe_r(); |
| 86 | 86 | return CLEAR_LINE; |
| 87 | 87 | } |
| 88 | ||
| 88 | ||
| 89 | 89 | UINT8 laserdisc_ready_r() |
| 90 | 90 | { |
| 91 | 91 | if (m_ldv1000 != NULL) return m_ldv1000->command_strobe_r(); |
| r14063 | r14064 | |
| 968 | 968 | |
| 969 | 969 | static DRIVER_INIT( fixed ) |
| 970 | 970 | { |
| 971 | // dlair_state *state = machine.driver_data<dlair_state>(); | |
| 972 | // state->m_laserdisc_type = LASERDISC_TYPE_FIXED; | |
| 971 | // dlair_state *state = machine.driver_data<dlair_state>(); | |
| 972 | // state->m_laserdisc_type = LASERDISC_TYPE_FIXED; | |
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | |
| 976 | 976 | static DRIVER_INIT( variable ) |
| 977 | 977 | { |
| 978 | // dlair_state *state = machine.driver_data<dlair_state>(); | |
| 979 | // state->m_laserdisc_type = LASERDISC_TYPE_VARIABLE; | |
| 978 | // dlair_state *state = machine.driver_data<dlair_state>(); | |
| 979 | // state->m_laserdisc_type = LASERDISC_TYPE_VARIABLE; | |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 |
| r14063 | r14064 | |
|---|---|---|
| 321 | 321 | const rectangle &vis_area = device->machine().primary_screen->visible_area(); |
| 322 | 322 | int xt, yt; |
| 323 | 323 | |
| 324 | xt = x_val * (vis_area.max_x - vis_area.min_x) / 1024 + vis_area.min_x; | |
| 325 | yt = y_val * (vis_area.max_y - vis_area.min_y) / 1024 + vis_area.min_y; | |
| 324 | xt = x_val * vis_area.width() / 1024 + vis_area.min_x; | |
| 325 | yt = y_val * vis_area.height() / 1024 + vis_area.min_y; | |
| 326 | 326 | |
| 327 | 327 | device->machine().scheduler().timer_set(device->machine().primary_screen->time_until_pos(yt, xt), FUNC(assert_lp_cb), 0, device); |
| 328 | 328 | } |
| r14063 | r14064 | |
|---|---|---|
| 97 | 97 | y = bitmap.height() - y - 1; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | if (x < cliprect.min_x || | |
| 101 | x > cliprect.max_x || | |
| 102 | y < cliprect.min_y || | |
| 103 | y > cliprect.max_y) | |
| 104 | return; | |
| 105 | ||
| 106 | bitmap.pix16(y, x) = color; | |
| 100 | if (cliprect.contains(x, y)) | |
| 101 | bitmap.pix16(y, x) = color; | |
| 107 | 102 | } |
| 108 | 103 | |
| 109 | 104 | static void gpworld_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| r14063 | r14064 | |
|---|---|---|
| 935 | 935 | |
| 936 | 936 | state->m_screen_dis = 0; |
| 937 | 937 | |
| 938 | visarea.min_x = min_x; | |
| 939 | visarea.max_x = min_x + max_x - 1; | |
| 940 | visarea.min_y = min_y; | |
| 941 | visarea.max_y = min_y + max_y - 1; | |
| 938 | visarea.set(min_x, min_x + max_x - 1, min_y, min_y + max_y - 1); | |
| 942 | 939 | space->machine().primary_screen->configure(HTOTAL, VTOTAL, visarea, space->machine().primary_screen->frame_period().attoseconds ); |
| 943 | 940 | } |
| 944 | 941 | } |
| r14063 | r14064 | |
|---|---|---|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | // plot it |
| 439 | if ( | |
| 439 | if ( | |
| 440 | 440 | { |
| 441 | 441 | if (clear) dest[x + y * 512] = clear_pen; |
| 442 | 442 | else if (pen != trans_pen) dest[x + y * 512] = pen | pen_hi; |
| r14063 | r14064 | |
|---|---|---|
| 377 | 377 | tilemap_map_pen_to_layer(state->m_tilemap[3], 1, 255, TILEMAP_PIXEL_TRANSPARENT); |
| 378 | 378 | |
| 379 | 379 | state->m_sprite_bitmap = auto_bitmap_ind16_alloc(machine,0x1000,0x1000); |
| 380 | state->m_sprite_clip.min_x = 0; | |
| 381 | state->m_sprite_clip.max_x = 0x1000-1; | |
| 382 | state->m_sprite_clip.min_y = 0; | |
| 383 | state->m_sprite_clip.max_y = 0x1000-1; | |
| 380 | state->m_sprite_clip.set(0, 0x1000-1, 0, 0x1000-1); | |
| 384 | 381 | } |
| 385 | 382 | |
| 386 | 383 | /* |
| r14063 | r14064 | |
|---|---|---|
| 777 | 777 | const CFIndex count = 1; |
| 778 | 778 | CGRect bounding_rect, success_rect; |
| 779 | 779 | CGContextRef context_ref; |
| 780 | ||
| 780 | ||
| 781 | 781 | if( chnum == ' ' ) |
| 782 | 782 | { |
| 783 | 783 | uni_char = 'n'; |
| r14063 | r14064 | |
| 1062 | 1062 | SDL_Surface *drawsurf; |
| 1063 | 1063 | SDL_Color fcol = { 0xff, 0xff, 0xff }; |
| 1064 | 1064 | UINT16 ustr[16]; |
| 1065 | ||
| 1065 | ||
| 1066 | 1066 | ttffont = (TTF_Font *)font; |
| 1067 | 1067 | |
| 1068 | 1068 | memset(ustr,0,sizeof(ustr)); |
| r14063 | r14064 | |
|---|---|---|
| 1120 | 1120 | UINT16 *dest = &bitmap.pix16(cliprect.min_y); |
| 1121 | 1121 | for (x = cliprect.min_x; x < params.heblnk; x++) |
| 1122 | 1122 | dest[x] = blackpen; |
| 1123 | for (x = params.hsblnk; x <= cliprect.max_ | |
| 1123 | for (x = params.hsblnk; x <= cliprect.max_x; x++) | |
| 1124 | 1124 | dest[x] = blackpen; |
| 1125 | 1125 | return 0; |
| 1126 | 1126 | |
| r14063 | r14064 | |
| 1168 | 1168 | UINT32 *dest = &bitmap.pix32(cliprect.min_y); |
| 1169 | 1169 | for (x = cliprect.min_x; x < params.heblnk; x++) |
| 1170 | 1170 | dest[x] = blackpen; |
| 1171 | for (x = params.hsblnk; x <= cliprect.max_ | |
| 1171 | for (x = params.hsblnk; x <= cliprect.max_x; x++) | |
| 1172 | 1172 | dest[x] = blackpen; |
| 1173 | 1173 | return 0; |
| 1174 | 1174 | } |
| r14063 | r14064 | |
|---|---|---|
| 419 | 419 | *address = (page_entry & 0xfffff000) | offset; |
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | if(!ret) | |
| 422 | if(!ret) | |
| 423 | 423 | { |
| 424 | 424 | *error = ((rw && 1)<<1) | ((cpustate->CPL==3)?1<<2:0); |
| 425 | 425 | return 0; |
| r14063 | r14064 | |
|---|---|---|
| 2260 | 2260 | { |
| 2261 | 2261 | if(newflags & 0x00020000) // if returning to virtual 8086 mode |
| 2262 | 2262 | { |
| 2263 | // | |
| 2263 | // UINT8 SSRPL,SSDPL; | |
| 2264 | 2264 | memset(&desc, 0, sizeof(desc)); |
| 2265 | 2265 | desc.selector = newCS; |
| 2266 | 2266 | i386_load_protected_mode_segment(cpustate,&desc); |
| r14063 | r14064 | |
| 2275 | 2275 | /* Return to v86 mode */ |
| 2276 | 2276 | logerror("IRET (%08x): Returning to Virtual 8086 mode.\n",cpustate->pc); |
| 2277 | 2277 | // Should these be done at this point? The 386 programmers' reference is a bit confusing about this |
| 2278 | /* if(RPL != 3) | |
| 2279 | { | |
| 2280 | logerror("IRET to V86 (%08x): Return CS RPL is not 3\n",cpustate->pc); | |
| 2281 | FAULT(FAULT_GP,newCS); | |
| 2282 | } | |
| 2283 | if(operand32 == 0) | |
| 2284 | { | |
| 2285 | if(REG16(SP)+36 > cpustate->sreg[SS].limit) | |
| 2286 | { | |
| 2287 | logerror("IRET to V86 (%08x): Stack does not have enough room left\n",cpustate->pc); | |
| 2288 | FAULT(FAULT_SS,0); | |
| 2289 | } | |
| 2290 | } | |
| 2291 | else | |
| 2292 | { | |
| 2293 | if(REG32(ESP)+36 > cpustate->sreg[SS].limit) | |
| 2294 | { | |
| 2295 | logerror("IRET to V86 (%08x): Stack does not have enough space left\n",cpustate->pc); | |
| 2296 | FAULT(FAULT_SS,0); | |
| 2297 | } | |
| 2298 | } | |
| 2299 | // code segment checks | |
| 2300 | if((newCS & ~0x07) == 0) | |
| 2301 | { | |
| 2302 | logerror("IRET to V86 (%08x): Return CS selector is null\n",cpustate->pc); | |
| 2303 | FAULT(FAULT_GP,newCS); | |
| 2304 | } | |
| 2305 | if(desc.flags & 0x04) | |
| 2306 | { // LDT | |
| 2307 | if(newCS > cpustate->ldtr.limit) | |
| 2308 | { | |
| 2309 | logerror("IRET to V86 (%08x): Return CS selector is past LDT limit\n",cpustate->pc); | |
| 2310 | FAULT(FAULT_GP,newCS); | |
| 2311 | } | |
| 2312 | } | |
| 2313 | else | |
| 2314 | { // GDT | |
| 2315 | if(newCS > cpustate->gdtr.limit) | |
| 2316 | { | |
| 2317 | logerror("IRET to V86 (%08x): Return CS selector is past GDT limit\n",cpustate->pc); | |
| 2318 | FAULT(FAULT_GP,newCS); | |
| 2319 | } | |
| 2320 | } | |
| 2321 | if((desc.flags & 0x18) != 0x18) | |
| 2322 | { | |
| 2323 | logerror("IRET to V86 (%08x): Return CS segment is not a code segment\n",cpustate->pc); | |
| 2324 | FAULT(FAULT_GP,newCS); | |
| 2325 | } | |
| 2326 | if(DPL != 3) | |
| 2327 | { | |
| 2328 | logerror("IRET to V86 (%08x): Return CS segment does not have a DPL of 3\n",cpustate->pc); | |
| 2329 | FAULT(FAULT_GP,newCS); | |
| 2330 | } | |
| 2331 | if(!(desc.flags & 0x0080)) | |
| 2332 | { | |
| 2333 | logerror("IRET to V86 (%08x): Return CS segment is not present\n",cpustate->pc); | |
| 2334 | FAULT(FAULT_NP,newCS); | |
| 2335 | } | |
| 2336 | // Stack segment checks | |
| 2337 | if((newSS & ~0x07) == 0) | |
| 2338 | { | |
| 2339 | logerror("IRET to V86 (%08x): Return SS segment is null\n",cpustate->pc); | |
| 2340 | FAULT(FAULT_GP,newSS); | |
| 2341 | } | |
| 2342 | if(desc.flags & 0x04) | |
| 2343 | { // LDT | |
| 2344 | if(newSS > cpustate->ldtr.limit) | |
| 2345 | { | |
| 2346 | logerror("IRET to V86 (%08x): Return SS selector is past LDT limit\n",cpustate->pc); | |
| 2347 | FAULT(FAULT_GP,newSS); | |
| 2348 | } | |
| 2349 | } | |
| 2350 | else | |
| 2351 | { // GDT | |
| 2352 | if(newSS > cpustate->gdtr.limit) | |
| 2353 | { | |
| 2354 | logerror("IRET to V86 (%08x): Return SS selector is past GDT limit\n",cpustate->pc); | |
| 2355 | FAULT(FAULT_GP,newSS); | |
| 2356 | } | |
| 2357 | } | |
| 2358 | if(SSRPL != RPL) | |
| 2359 | { | |
| 2360 | logerror("IRET to V86 (%08x): Return SS selector RPL is not equal to CS selector RPL\n",cpustate->pc); | |
| 2361 | FAULT(FAULT_GP,newSS); | |
| 2362 | } | |
| 2363 | if(((stack.flags & 0x0018) != 0x10) && (!(stack.flags & 0x02))) | |
| 2364 | { | |
| 2365 | logerror("IRET to V86 (%08x): Return SS segment is not a writable data segment\n",cpustate->pc); | |
| 2366 | FAULT(FAULT_GP,newSS); | |
| 2367 | } | |
| 2368 | if(SSDPL != RPL) | |
| 2369 | { | |
| 2370 | logerror("IRET to V86 (%08x): Return SS segment DPL is not equal to CS selector RPL\n",cpustate->pc); | |
| 2371 | FAULT(FAULT_GP,newSS); | |
| 2372 | } | |
| 2373 | if(!(stack.flags & 0x0080)) | |
| 2374 | { | |
| 2375 | logerror("IRET to V86 (%08x): Return SS segment is not present\n",cpustate->pc); | |
| 2376 | FAULT(FAULT_NP,newSS); | |
| 2377 | } | |
| 2278 | /* if(RPL != 3) | |
| 2279 | { | |
| 2280 | logerror("IRET to V86 (%08x): Return CS RPL is not 3\n",cpustate->pc); | |
| 2281 | FAULT(FAULT_GP,newCS); | |
| 2282 | } | |
| 2283 | if(operand32 == 0) | |
| 2284 | { | |
| 2285 | if(REG16(SP)+36 > cpustate->sreg[SS].limit) | |
| 2286 | { | |
| 2287 | logerror("IRET to V86 (%08x): Stack does not have enough room left\n",cpustate->pc); | |
| 2288 | FAULT(FAULT_SS,0); | |
| 2289 | } | |
| 2290 | } | |
| 2291 | else | |
| 2292 | { | |
| 2293 | if(REG32(ESP)+36 > cpustate->sreg[SS].limit) | |
| 2294 | { | |
| 2295 | logerror("IRET to V86 (%08x): Stack does not have enough space left\n",cpustate->pc); | |
| 2296 | FAULT(FAULT_SS,0); | |
| 2297 | } | |
| 2298 | } | |
| 2299 | // code segment checks | |
| 2300 | if((newCS & ~0x07) == 0) | |
| 2301 | { | |
| 2302 | logerror("IRET to V86 (%08x): Return CS selector is null\n",cpustate->pc); | |
| 2303 | FAULT(FAULT_GP,newCS); | |
| 2304 | } | |
| 2305 | if(desc.flags & 0x04) | |
| 2306 | { // LDT | |
| 2307 | if(newCS > cpustate->ldtr.limit) | |
| 2308 | { | |
| 2309 | logerror("IRET to V86 (%08x): Return CS selector is past LDT limit\n",cpustate->pc); | |
| 2310 | FAULT(FAULT_GP,newCS); | |
| 2311 | } | |
| 2312 | } | |
| 2313 | else | |
| 2314 | { // GDT | |
| 2315 | if(newCS > cpustate->gdtr.limit) | |
| 2316 | { | |
| 2317 | logerror("IRET to V86 (%08x): Return CS selector is past GDT limit\n",cpustate->pc); | |
| 2318 | FAULT(FAULT_GP,newCS); | |
| 2319 | } | |
| 2320 | } | |
| 2321 | if((desc.flags & 0x18) != 0x18) | |
| 2322 | { | |
| 2323 | logerror("IRET to V86 (%08x): Return CS segment is not a code segment\n",cpustate->pc); | |
| 2324 | FAULT(FAULT_GP,newCS); | |
| 2325 | } | |
| 2326 | if(DPL != 3) | |
| 2327 | { | |
| 2328 | logerror("IRET to V86 (%08x): Return CS segment does not have a DPL of 3\n",cpustate->pc); | |
| 2329 | FAULT(FAULT_GP,newCS); | |
| 2330 | } | |
| 2331 | if(!(desc.flags & 0x0080)) | |
| 2332 | { | |
| 2333 | logerror("IRET to V86 (%08x): Return CS segment is not present\n",cpustate->pc); | |
| 2334 | FAULT(FAULT_NP,newCS); | |
| 2335 | } | |
| 2336 | // Stack segment checks | |
| 2337 | if((newSS & ~0x07) == 0) | |
| 2338 | { | |
| 2339 | logerror("IRET to V86 (%08x): Return SS segment is null\n",cpustate->pc); | |
| 2340 | FAULT(FAULT_GP,newSS); | |
| 2341 | } | |
| 2342 | if(desc.flags & 0x04) | |
| 2343 | { // LDT | |
| 2344 | if(newSS > cpustate->ldtr.limit) | |
| 2345 | { | |
| 2346 | logerror("IRET to V86 (%08x): Return SS selector is past LDT limit\n",cpustate->pc); | |
| 2347 | FAULT(FAULT_GP,newSS); | |
| 2348 | } | |
| 2349 | } | |
| 2350 | else | |
| 2351 | { // GDT | |
| 2352 | if(newSS > cpustate->gdtr.limit) | |
| 2353 | { | |
| 2354 | logerror("IRET to V86 (%08x): Return SS selector is past GDT limit\n",cpustate->pc); | |
| 2355 | FAULT(FAULT_GP,newSS); | |
| 2356 | } | |
| 2357 | } | |
| 2358 | if(SSRPL != RPL) | |
| 2359 | { | |
| 2360 | logerror("IRET to V86 (%08x): Return SS selector RPL is not equal to CS selector RPL\n",cpustate->pc); | |
| 2361 | FAULT(FAULT_GP,newSS); | |
| 2362 | } | |
| 2363 | if(((stack.flags & 0x0018) != 0x10) && (!(stack.flags & 0x02))) | |
| 2364 | { | |
| 2365 | logerror("IRET to V86 (%08x): Return SS segment is not a writable data segment\n",cpustate->pc); | |
| 2366 | FAULT(FAULT_GP,newSS); | |
| 2367 | } | |
| 2368 | if(SSDPL != RPL) | |
| 2369 | { | |
| 2370 | logerror("IRET to V86 (%08x): Return SS segment DPL is not equal to CS selector RPL\n",cpustate->pc); | |
| 2371 | FAULT(FAULT_GP,newSS); | |
| 2372 | } | |
| 2373 | if(!(stack.flags & 0x0080)) | |
| 2374 | { | |
| 2375 | logerror("IRET to V86 (%08x): Return SS segment is not present\n",cpustate->pc); | |
| 2376 | FAULT(FAULT_NP,newSS); | |
| 2377 | } | |
| 2378 | 2378 | |
| 2379 | if(newEIP > desc.limit) | |
| 2380 | { | |
| 2381 | logerror("IRET to V86 (%08x): New EIP is past CS segment limit\n",cpustate->pc); | |
| 2382 | FAULT(FAULT_GP,0); | |
| 2383 | } | |
| 2384 | */ | |
| 2379 | if(newEIP > desc.limit) | |
| 2380 | { | |
| 2381 | logerror("IRET to V86 (%08x): New EIP is past CS segment limit\n",cpustate->pc); | |
| 2382 | FAULT(FAULT_GP,0); | |
| 2383 | } | |
| 2384 | */ | |
| 2385 | 2385 | set_flags(cpustate,newflags); |
| 2386 | 2386 | cpustate->eip = POP32(cpustate) & 0xffff; // high 16 bits are ignored |
| 2387 | 2387 | cpustate->sreg[CS].selector = POP32(cpustate) & 0xffff; |
| 2388 | 2388 | POP32(cpustate); // already set flags |
| 2389 | // | |
| 2389 | // if(RPL > CPL) | |
| 2390 | 2390 | { |
| 2391 | 2391 | newESP = POP32(cpustate); |
| 2392 | 2392 | newSS = POP32(cpustate) & 0xffff; |
| r14063 | r14064 | |
| 2649 | 2649 | FAULT(FAULT_GP,0) |
| 2650 | 2650 | } |
| 2651 | 2651 | |
| 2652 | // if(operand32 == 0) | |
| 2653 | // REG16(SP) += 10; | |
| 2654 | // else | |
| 2655 | // REG32(ESP) += 20; | |
| 2652 | // if(operand32 == 0) | |
| 2653 | // REG16(SP) += 10; | |
| 2654 | // else | |
| 2655 | // REG32(ESP) += 20; | |
| 2656 | 2656 | |
| 2657 | 2657 | if(operand32 == 0) |
| 2658 | 2658 | { |
| r14063 | r14064 | |
|---|---|---|
| 29 | 29 | // #define THUMB_RELADDR_SP ((UINT16)0x0800) |
| 30 | 30 | tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_0, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, tg0a_1, |
| 31 | 31 | // #define THUMB_STACKOP_TYPE ((UINT16)0x0f00) |
| 32 | tg0b_0, tg0b_0, tg0b_0, tg0b_0, tg0b_1, tg0b_1, tg0b_1, tg0b_1, tg0b_2, tg0b_2, tg0b_2, tg0b_2, tg0b_3, tg0b_3, tg0b_3, tg0b_3, tg0b_4, tg0b_4, tg0b_4, tg0b_4, tg0b_5, tg0b_5, tg0b_5, tg0b_5, tg0b_6, tg0b_6, tg0b_6, tg0b_6, tg0b_7, tg0b_7, tg0b_7, tg0b_7, tg0b_8, tg0b_8, tg0b_8, tg0b_8, tg0b_9, tg0b_9, tg0b_9, tg0b_9, tg0b_a, tg0b_a, tg0b_a, tg0b_a, tg0b_b, tg0b_b, tg0b_b, tg0b_b, tg0b_c, tg0b_c, tg0b_c, tg0b_c, tg0b_d, tg0b_d, tg0b_d, tg0b_d, tg0b_e, tg0b_e, tg0b_e, tg0b_e, tg0b_f, tg0b_f, tg0b_f, tg0b_f, | |
| 32 | tg0b_0, tg0b_0, tg0b_0, tg0b_0, tg0b_1, tg0b_1, tg0b_1, tg0b_1, tg0b_2, tg0b_2, tg0b_2, tg0b_2, tg0b_3, tg0b_3, tg0b_3, tg0b_3, tg0b_4, tg0b_4, tg0b_4, tg0b_4, tg0b_5, tg0b_5, tg0b_5, tg0b_5, tg0b_6, tg0b_6, tg0b_6, tg0b_6, tg0b_7, tg0b_7, tg0b_7, tg0b_7, tg0b_8, tg0b_8, tg0b_8, tg0b_8, tg0b_9, tg0b_9, tg0b_9, tg0b_9, tg0b_a, tg0b_a, tg0b_a, tg0b_a, tg0b_b, tg0b_b, tg0b_b, tg0b_b, tg0b_c, tg0b_c, tg0b_c, tg0b_c, tg0b_d, tg0b_d, tg0b_d, tg0b_d, tg0b_e, tg0b_e, tg0b_e, tg0b_e, tg0b_f, tg0b_f, tg0b_f, tg0b_f, | |
| 33 | 33 | // #define THUMB_MULTLS ((UINT16)0x0800) |
| 34 | 34 | tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_0, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, tg0c_1, |
| 35 | 35 | // #define THUMB_COND_TYPE ((UINT16)0x0f00) |
| 36 | tg0d_0, tg0d_0, tg0d_0, tg0d_0, tg0d_1, tg0d_1, tg0d_1, tg0d_1, tg0d_2, tg0d_2, tg0d_2, tg0d_2, tg0d_3, tg0d_3, tg0d_3, tg0d_3, tg0d_4, tg0d_4, tg0d_4, tg0d_4, tg0d_5, tg0d_5, tg0d_5, tg0d_5, tg0d_6, tg0d_6, tg0d_6, tg0d_6, tg0d_7, tg0d_7, tg0d_7, tg0d_7, tg0d_8, tg0d_8, tg0d_8, tg0d_8, tg0d_9, tg0d_9, tg0d_9, tg0d_9, tg0d_a, tg0d_a, tg0d_a, tg0d_a, tg0d_b, tg0d_b, tg0d_b, tg0d_b, tg0d_c, tg0d_c, tg0d_c, tg0d_c, tg0d_d, tg0d_d, tg0d_d, tg0d_d, tg0d_e, tg0d_e, tg0d_e, tg0d_e, tg0d_f, tg0d_f, tg0d_f, tg0d_f, | |
| 36 | tg0d_0, tg0d_0, tg0d_0, tg0d_0, tg0d_1, tg0d_1, tg0d_1, tg0d_1, tg0d_2, tg0d_2, tg0d_2, tg0d_2, tg0d_3, tg0d_3, tg0d_3, tg0d_3, tg0d_4, tg0d_4, tg0d_4, tg0d_4, tg0d_5, tg0d_5, tg0d_5, tg0d_5, tg0d_6, tg0d_6, tg0d_6, tg0d_6, tg0d_7, tg0d_7, tg0d_7, tg0d_7, tg0d_8, tg0d_8, tg0d_8, tg0d_8, tg0d_9, tg0d_9, tg0d_9, tg0d_9, tg0d_a, tg0d_a, tg0d_a, tg0d_a, tg0d_b, tg0d_b, tg0d_b, tg0d_b, tg0d_c, tg0d_c, tg0d_c, tg0d_c, tg0d_d, tg0d_d, tg0d_d, tg0d_d, tg0d_e, tg0d_e, tg0d_e, tg0d_e, tg0d_f, tg0d_f, tg0d_f, tg0d_f, | |
| 37 | 37 | // #define THUMB_BLOP_LO ((UINT16)0x0800) |
| 38 | 38 | tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_0, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, tg0e_1, |
| 39 | 39 | // #define THUMB_BLOP_LO ((UINT16)0x0800) |
| r14063 | r14064 | |
| 116 | 116 | |
| 117 | 117 | /* Arithmetic */ |
| 118 | 118 | |
| 119 | const void tg01_0(arm_state *cpustate, UINT32 pc, UINT32 insn) | |
| 119 | const void tg01_0(arm_state *cpustate, UINT32 pc, UINT32 insn) | |
| 120 | 120 | { |
| 121 | 121 | UINT32 rs, rd, rrs; |
| 122 | 122 | INT32 offs; |
| r14063 | r14064 | |
| 168 | 168 | { |
| 169 | 169 | UINT32 rn, rs, rd; |
| 170 | 170 | |
| 171 | ||
| 171 | ||
| 172 | 172 | rn = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RNIMM) >> THUMB_ADDSUB_RNIMM_SHIFT); |
| 173 | 173 | rs = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT); |
| 174 | 174 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| r14063 | r14064 | |
| 180 | 180 | const void tg01_11(arm_state *cpustate, UINT32 pc, UINT32 insn) /* SUB Rd, Rs, Rn */ |
| 181 | 181 | { |
| 182 | 182 | UINT32 rn, rs, rd; |
| 183 | ||
| 183 | ||
| 184 | 184 | rn = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RNIMM) >> THUMB_ADDSUB_RNIMM_SHIFT); |
| 185 | 185 | rs = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT); |
| 186 | 186 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| r14063 | r14064 | |
| 192 | 192 | const void tg01_12(arm_state *cpustate, UINT32 pc, UINT32 insn) /* ADD Rd, Rs, #imm */ |
| 193 | 193 | { |
| 194 | 194 | UINT32 rs, rd, imm; |
| 195 | ||
| 195 | ||
| 196 | 196 | imm = (insn & THUMB_ADDSUB_RNIMM) >> THUMB_ADDSUB_RNIMM_SHIFT; |
| 197 | 197 | rs = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT); |
| 198 | 198 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| r14063 | r14064 | |
| 204 | 204 | const void tg01_13(arm_state *cpustate, UINT32 pc, UINT32 insn) /* SUB Rd, Rs, #imm */ |
| 205 | 205 | { |
| 206 | 206 | UINT32 rs, rd, imm; |
| 207 | ||
| 207 | ||
| 208 | 208 | imm = (insn & THUMB_ADDSUB_RNIMM) >> THUMB_ADDSUB_RNIMM_SHIFT; |
| 209 | 209 | rs = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT); |
| 210 | 210 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| r14063 | r14064 | |
| 215 | 215 | |
| 216 | 216 | /* CMP / MOV */ |
| 217 | 217 | |
| 218 | const void tg02_0(arm_state *cpustate, UINT32 pc, UINT32 insn) | |
| 218 | const void tg02_0(arm_state *cpustate, UINT32 pc, UINT32 insn) | |
| 219 | 219 | { |
| 220 | 220 | UINT32 rd, op2; |
| 221 | 221 | |
| r14063 | r14064 | |
| 227 | 227 | R15 += 2; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | const void tg02_1(arm_state *cpustate, UINT32 pc, UINT32 insn) | |
| 230 | const void tg02_1(arm_state *cpustate, UINT32 pc, UINT32 insn) | |
| 231 | 231 | { |
| 232 | 232 | UINT32 rn, rd, op2; |
| 233 | 233 | |
| r14063 | r14064 | |
| 273 | 273 | const void tg04_00_00(arm_state *cpustate, UINT32 pc, UINT32 insn) /* AND Rd, Rs */ |
| 274 | 274 | { |
| 275 | 275 | UINT32 rs, rd; |
| 276 | ||
| 276 | ||
| 277 | 277 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 278 | 278 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 279 | 279 | SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rd) & GET_REGISTER(cpustate, rs)); |
| r14063 | r14064 | |
| 286 | 286 | const void tg04_00_01(arm_state *cpustate, UINT32 pc, UINT32 insn) /* EOR Rd, Rs */ |
| 287 | 287 | { |
| 288 | 288 | UINT32 rs, rd; |
| 289 | ||
| 289 | ||
| 290 | 290 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 291 | 291 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 292 | 292 | SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rd) ^ GET_REGISTER(cpustate, rs)); |
| r14063 | r14064 | |
| 300 | 300 | { |
| 301 | 301 | UINT32 rs, rd, rrd; |
| 302 | 302 | INT32 offs; |
| 303 | ||
| 303 | ||
| 304 | 304 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 305 | 305 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 306 | 306 | rrd = GET_REGISTER(cpustate, rd); |
| r14063 | r14064 | |
| 347 | 347 | { |
| 348 | 348 | UINT32 rs, rd, rrd; |
| 349 | 349 | INT32 offs; |
| 350 | ||
| 350 | ||
| 351 | 351 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 352 | 352 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 353 | 353 | rrd = GET_REGISTER(cpustate, rd); |
| r14063 | r14064 | |
| 393 | 393 | const void tg04_00_04(arm_state *cpustate, UINT32 pc, UINT32 insn) /* ASR Rd, Rs */ |
| 394 | 394 | { |
| 395 | 395 | UINT32 rs, rd, rrs, rrd; |
| 396 | ||
| 396 | ||
| 397 | 397 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 398 | 398 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 399 | 399 | rrs = GET_REGISTER(cpustate, rs)&0xff; |
| r14063 | r14064 | |
| 436 | 436 | const void tg04_00_05(arm_state *cpustate, UINT32 pc, UINT32 insn) /* ADC Rd, Rs */ |
| 437 | 437 | { |
| 438 | 438 | UINT32 rn, rs, rd, op2; |
| 439 | ||
| 439 | ||
| 440 | 440 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 441 | 441 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 442 | 442 | op2=(GET_CPSR & C_MASK) ? 1 : 0; |
| r14063 | r14064 | |
| 462 | 462 | const void tg04_00_07(arm_state *cpustate, UINT32 pc, UINT32 insn) /* ROR Rd, Rs */ |
| 463 | 463 | { |
| 464 | 464 | UINT32 rs, rd, imm, rrd; |
| 465 | ||
| 465 | ||
| 466 | 466 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 467 | 467 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 468 | 468 | rrd = GET_REGISTER(cpustate, rd); |
| r14063 | r14064 | |
| 485 | 485 | const void tg04_00_08(arm_state *cpustate, UINT32 pc, UINT32 insn) /* TST Rd, Rs */ |
| 486 | 486 | { |
| 487 | 487 | UINT32 rs, rd; |
| 488 | ||
| 488 | ||
| 489 | 489 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 490 | 490 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 491 | 491 | SET_CPSR(GET_CPSR & ~(Z_MASK | N_MASK)); |
| r14063 | r14064 | |
| 497 | 497 | const void tg04_00_09(arm_state *cpustate, UINT32 pc, UINT32 insn) /* NEG Rd, Rs */ |
| 498 | 498 | { |
| 499 | 499 | UINT32 rn, rs, rd, rrs; |
| 500 | ||
| 500 | ||
| 501 | 501 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 502 | 502 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 503 | 503 | rrs = GET_REGISTER(cpustate, rs); |
| r14063 | r14064 | |
| 510 | 510 | const void tg04_00_0a(arm_state *cpustate, UINT32 pc, UINT32 insn) /* CMP Rd, Rs */ |
| 511 | 511 | { |
| 512 | 512 | UINT32 rn, rs, rd; |
| 513 | ||
| 513 | ||
| 514 | 514 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 515 | 515 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 516 | 516 | rn = GET_REGISTER(cpustate, rd) - GET_REGISTER(cpustate, rs); |
| r14063 | r14064 | |
| 522 | 522 | const void tg04_00_0b(arm_state *cpustate, UINT32 pc, UINT32 insn) /* CMN Rd, Rs - check flags, add dasm */ |
| 523 | 523 | { |
| 524 | 524 | UINT32 rn, rs, rd; |
| 525 | ||
| 525 | ||
| 526 | 526 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 527 | 527 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 528 | 528 | rn = GET_REGISTER(cpustate, rd) + GET_REGISTER(cpustate, rs); |
| r14063 | r14064 | |
| 533 | 533 | const void tg04_00_0c(arm_state *cpustate, UINT32 pc, UINT32 insn) /* ORR Rd, Rs */ |
| 534 | 534 | { |
| 535 | 535 | UINT32 rs, rd; |
| 536 | ||
| 536 | ||
| 537 | 537 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 538 | 538 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 539 | 539 | SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rd) | GET_REGISTER(cpustate, rs)); |
| r14063 | r14064 | |
| 546 | 546 | const void tg04_00_0d(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MUL Rd, Rs */ |
| 547 | 547 | { |
| 548 | 548 | UINT32 rn, rs, rd; |
| 549 | ||
| 549 | ||
| 550 | 550 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 551 | 551 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 552 | 552 | rn = GET_REGISTER(cpustate, rd) * GET_REGISTER(cpustate, rs); |
| r14063 | r14064 | |
| 560 | 560 | const void tg04_00_0e(arm_state *cpustate, UINT32 pc, UINT32 insn) /* BIC Rd, Rs */ |
| 561 | 561 | { |
| 562 | 562 | UINT32 rs, rd; |
| 563 | ||
| 563 | ||
| 564 | 564 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 565 | 565 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 566 | 566 | SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rd) & (~GET_REGISTER(cpustate, rs))); |
| r14063 | r14064 | |
| 572 | 572 | const void tg04_00_0f(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MVN Rd, Rs */ |
| 573 | 573 | { |
| 574 | 574 | UINT32 rs, rd, op2; |
| 575 | ||
| 575 | ||
| 576 | 576 | rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT; |
| 577 | 577 | rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT; |
| 578 | 578 | op2 = GET_REGISTER(cpustate, rs); |
| r14063 | r14064 | |
| 587 | 587 | |
| 588 | 588 | const void tg04_01_00(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 589 | 589 | { |
| 590 | // UINT32 rs, rd; | |
| 591 | // rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT; | |
| 592 | // rd = insn & THUMB_HIREG_RD; | |
| 590 | // UINT32 rs, rd; | |
| 591 | // rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT; | |
| 592 | // rd = insn & THUMB_HIREG_RD; | |
| 593 | 593 | |
| 594 | 594 | |
| 595 | 595 | fatalerror("%08x: G4-1-0 Undefined Thumb instruction: %04x %x\n", pc, insn, (insn & THUMB_HIREG_H) >> THUMB_HIREG_H_SHIFT); |
| r14063 | r14064 | |
| 604 | 604 | rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT; |
| 605 | 605 | rd = insn & THUMB_HIREG_RD; |
| 606 | 606 | |
| 607 | ||
| 607 | ||
| 608 | 608 | SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rd) + GET_REGISTER(cpustate, rs+8)); |
| 609 | 609 | // emulate the effects of pre-fetch |
| 610 | 610 | if (rs == 7) |
| r14063 | r14064 | |
| 621 | 621 | rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT; |
| 622 | 622 | rd = insn & THUMB_HIREG_RD; |
| 623 | 623 | |
| 624 | ||
| 624 | ||
| 625 | 625 | SET_REGISTER(cpustate, rd+8, GET_REGISTER(cpustate, rd+8) + GET_REGISTER(cpustate, rs)); |
| 626 | 626 | if (rd == 7) |
| 627 | 627 | { |
| r14063 | r14064 | |
| 637 | 637 | rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT; |
| 638 | 638 | rd = insn & THUMB_HIREG_RD; |
| 639 | 639 | |
| 640 | ||
| 640 | ||
| 641 | 641 | SET_REGISTER(cpustate, rd+8, GET_REGISTER(cpustate, rd+8) + GET_REGISTER(cpustate, rs+8)); |
| 642 | 642 | // emulate the effects of pre-fetch |
| 643 | 643 | if (rs == 7) |
| r14063 | r14064 | |
| 667 | 667 | const void tg04_01_11(arm_state *cpustate, UINT32 pc, UINT32 insn) /* CMP Rd, Hs */ |
| 668 | 668 | { |
| 669 | 669 | UINT32 rn, rs, rd; |
| 670 | ||
| 670 | ||
| 671 | 671 | rs = GET_REGISTER(cpustate, ((insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT) + 8); |
| 672 | 672 | rd = GET_REGISTER(cpustate, insn & THUMB_HIREG_RD); |
| 673 | 673 | rn = rd - rs; |
| r14063 | r14064 | |
| 678 | 678 | const void tg04_01_12(arm_state *cpustate, UINT32 pc, UINT32 insn) /* CMP Hd, Rs */ |
| 679 | 679 | { |
| 680 | 680 | UINT32 rn, rs, rd; |
| 681 | ||
| 681 | ||
| 682 | 682 | rs = GET_REGISTER(cpustate, ((insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT)); |
| 683 | 683 | rd = GET_REGISTER(cpustate, (insn & THUMB_HIREG_RD) + 8); |
| 684 | 684 | rn = rd - rs; |
| r14063 | r14064 | |
| 689 | 689 | const void tg04_01_13(arm_state *cpustate, UINT32 pc, UINT32 insn) /* CMP Hd, Hs */ |
| 690 | 690 | { |
| 691 | 691 | UINT32 rn, rs, rd; |
| 692 | ||
| 692 | ||
| 693 | 693 | rs = GET_REGISTER(cpustate, ((insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT) + 8); |
| 694 | 694 | rd = GET_REGISTER(cpustate, (insn & THUMB_HIREG_RD) + 8); |
| 695 | 695 | rn = rd - rs; |
| r14063 | r14064 | |
| 703 | 703 | const void tg04_01_20(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MOV Rd, Rs (undefined) */ |
| 704 | 704 | { |
| 705 | 705 | UINT32 rs, rd; |
| 706 | ||
| 707 | ||
| 706 | ||
| 707 | ||
| 708 | 708 | rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT; |
| 709 | 709 | rd = insn & THUMB_HIREG_RD; |
| 710 | 710 | SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rs)); |
| r14063 | r14064 | |
| 715 | 715 | const void tg04_01_21(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MOV Rd, Hs */ |
| 716 | 716 | { |
| 717 | 717 | UINT32 rs, rd; |
| 718 | ||
| 718 | ||
| 719 | 719 | rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT; |
| 720 | 720 | rd = insn & THUMB_HIREG_RD; |
| 721 | 721 | if (rs == 7) |
| r14063 | r14064 | |
| 733 | 733 | const void tg04_01_22(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MOV Hd, Rs */ |
| 734 | 734 | { |
| 735 | 735 | UINT32 rs, rd; |
| 736 | ||
| 736 | ||
| 737 | 737 | rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT; |
| 738 | 738 | rd = insn & THUMB_HIREG_RD; |
| 739 | 739 | SET_REGISTER(cpustate, rd + 8, GET_REGISTER(cpustate, rs)); |
| r14063 | r14064 | |
| 751 | 751 | const void tg04_01_23(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MOV Hd, Hs */ |
| 752 | 752 | { |
| 753 | 753 | UINT32 rs, rd; |
| 754 | ||
| 754 | ||
| 755 | 755 | rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT; |
| 756 | 756 | rd = insn & THUMB_HIREG_RD; |
| 757 | 757 | if (rs == 7) |
| r14063 | r14064 | |
| 826 | 826 | |
| 827 | 827 | const void tg04_01_32(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 828 | 828 | { |
| 829 | // UINT32 addr; | |
| 830 | // UINT32 rd; | |
| 829 | // UINT32 addr; | |
| 830 | // UINT32 rd; | |
| 831 | 831 | |
| 832 | 832 | |
| 833 | 833 | fatalerror("%08x: G4-3 Undefined Thumb instruction: %04x\n", pc, insn); |
| r14063 | r14064 | |
| 837 | 837 | |
| 838 | 838 | const void tg04_01_33(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 839 | 839 | { |
| 840 | // UINT32 addr; | |
| 841 | // UINT32 rd; | |
| 840 | // UINT32 addr; | |
| 841 | // UINT32 rd; | |
| 842 | 842 | |
| 843 | 843 | |
| 844 | 844 | fatalerror("%08x: G4-3 Undefined Thumb instruction: %04x\n", pc, insn); |
| r14063 | r14064 | |
| 851 | 851 | |
| 852 | 852 | |
| 853 | 853 | |
| 854 | const void tg04_0203(arm_state *cpustate, UINT32 pc, UINT32 insn) | |
| 854 | const void tg04_0203(arm_state *cpustate, UINT32 pc, UINT32 insn) | |
| 855 | 855 | { |
| 856 | 856 | UINT32 readword; |
| 857 | 857 | |
| r14063 | r14064 | |
| 866 | 866 | { |
| 867 | 867 | UINT32 addr; |
| 868 | 868 | UINT32 rm, rn, rd; |
| 869 | ||
| 869 | ||
| 870 | 870 | rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT; |
| 871 | 871 | rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT; |
| 872 | 872 | rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT; |
| 873 | 873 | addr = GET_REGISTER(cpustate, rn) + GET_REGISTER(cpustate, rm); |
| 874 | 874 | WRITE32(addr, GET_REGISTER(cpustate, rd)); |
| 875 | 875 | R15 += 2; |
| 876 | ||
| 876 | ||
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | const void tg05_1(arm_state *cpustate, UINT32 pc, UINT32 insn) /* STRH Rd, [Rn, Rm] */ |
| 880 | 880 | { |
| 881 | 881 | UINT32 addr; |
| 882 | 882 | UINT32 rm, rn, rd; |
| 883 | ||
| 883 | ||
| 884 | 884 | rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT; |
| 885 | 885 | rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT; |
| 886 | 886 | rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT; |
| r14063 | r14064 | |
| 894 | 894 | { |
| 895 | 895 | UINT32 addr; |
| 896 | 896 | UINT32 rm, rn, rd; |
| 897 | ||
| 897 | ||
| 898 | 898 | rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT; |
| 899 | 899 | rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT; |
| 900 | 900 | rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT; |
| r14063 | r14064 | |
| 908 | 908 | { |
| 909 | 909 | UINT32 addr; |
| 910 | 910 | UINT32 rm, rn, rd, op2; |
| 911 | ||
| 911 | ||
| 912 | 912 | rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT; |
| 913 | 913 | rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT; |
| 914 | 914 | rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT; |
| r14063 | r14064 | |
| 927 | 927 | { |
| 928 | 928 | UINT32 addr; |
| 929 | 929 | UINT32 rm, rn, rd, op2; |
| 930 | ||
| 930 | ||
| 931 | 931 | rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT; |
| 932 | 932 | rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT; |
| 933 | 933 | rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT; |
| r14063 | r14064 | |
| 942 | 942 | { |
| 943 | 943 | UINT32 addr; |
| 944 | 944 | UINT32 rm, rn, rd, op2; |
| 945 | ||
| 945 | ||
| 946 | 946 | rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT; |
| 947 | 947 | rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT; |
| 948 | 948 | rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT; |
| r14063 | r14064 | |
| 957 | 957 | { |
| 958 | 958 | UINT32 addr; |
| 959 | 959 | UINT32 rm, rn, rd, op2; |
| 960 | ||
| 960 | ||
| 961 | 961 | rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT; |
| 962 | 962 | rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT; |
| 963 | 963 | rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT; |
| r14063 | r14064 | |
| 972 | 972 | { |
| 973 | 973 | UINT32 addr; |
| 974 | 974 | UINT32 rm, rn, rd, op2; |
| 975 | ||
| 975 | ||
| 976 | 976 | rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT; |
| 977 | 977 | rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT; |
| 978 | 978 | rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT; |
| r14063 | r14064 | |
| 1119 | 1119 | { |
| 1120 | 1120 | UINT32 addr; |
| 1121 | 1121 | |
| 1122 | ||
| 1122 | ||
| 1123 | 1123 | addr = (insn & THUMB_INSN_IMM); |
| 1124 | 1124 | addr &= ~THUMB_INSN_IMM_S; |
| 1125 | 1125 | SET_REGISTER(cpustate, 13, GET_REGISTER(cpustate, 13) + ((insn & THUMB_INSN_IMM_S) ? -(addr << 2) : (addr << 2))); |
| r14063 | r14064 | |
| 1129 | 1129 | |
| 1130 | 1130 | const void tg0b_1(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1131 | 1131 | { |
| 1132 | // UINT32 addr; | |
| 1133 | // INT32 offs; | |
| 1132 | // UINT32 addr; | |
| 1133 | // INT32 offs; | |
| 1134 | 1134 | |
| 1135 | 1135 | fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn); |
| 1136 | 1136 | R15 += 2; |
| r14063 | r14064 | |
| 1139 | 1139 | |
| 1140 | 1140 | const void tg0b_2(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1141 | 1141 | { |
| 1142 | // UINT32 addr; | |
| 1143 | // INT32 offs; | |
| 1142 | // UINT32 addr; | |
| 1143 | // INT32 offs; | |
| 1144 | 1144 | |
| 1145 | 1145 | fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn); |
| 1146 | 1146 | R15 += 2; |
| r14063 | r14064 | |
| 1149 | 1149 | |
| 1150 | 1150 | const void tg0b_3(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1151 | 1151 | { |
| 1152 | // UINT32 addr; | |
| 1153 | // INT32 offs; | |
| 1152 | // UINT32 addr; | |
| 1153 | // INT32 offs; | |
| 1154 | 1154 | |
| 1155 | 1155 | fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn); |
| 1156 | 1156 | R15 += 2; |
| r14063 | r14064 | |
| 1160 | 1160 | const void tg0b_4(arm_state *cpustate, UINT32 pc, UINT32 insn) /* PUSH {Rlist} */ |
| 1161 | 1161 | { |
| 1162 | 1162 | INT32 offs; |
| 1163 | ||
| 1163 | ||
| 1164 | 1164 | for (offs = 7; offs >= 0; offs--) |
| 1165 | 1165 | { |
| 1166 | 1166 | if (insn & (1 << offs)) |
| r14063 | r14064 | |
| 1176 | 1176 | const void tg0b_5(arm_state *cpustate, UINT32 pc, UINT32 insn) /* PUSH {Rlist}{LR} */ |
| 1177 | 1177 | { |
| 1178 | 1178 | INT32 offs; |
| 1179 | ||
| 1179 | ||
| 1180 | 1180 | SET_REGISTER(cpustate, 13, GET_REGISTER(cpustate, 13) - 4); |
| 1181 | 1181 | WRITE32(GET_REGISTER(cpustate, 13), GET_REGISTER(cpustate, 14)); |
| 1182 | 1182 | for (offs = 7; offs >= 0; offs--) |
| r14063 | r14064 | |
| 1193 | 1193 | |
| 1194 | 1194 | const void tg0b_6(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1195 | 1195 | { |
| 1196 | // UINT32 addr; | |
| 1197 | // INT32 offs; | |
| 1196 | // UINT32 addr; | |
| 1197 | // INT32 offs; | |
| 1198 | 1198 | |
| 1199 | 1199 | fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn); |
| 1200 | 1200 | R15 += 2; |
| r14063 | r14064 | |
| 1203 | 1203 | |
| 1204 | 1204 | const void tg0b_7(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1205 | 1205 | { |
| 1206 | // UINT32 addr; | |
| 1207 | // INT32 offs; | |
| 1206 | // UINT32 addr; | |
| 1207 | // INT32 offs; | |
| 1208 | 1208 | |
| 1209 | 1209 | fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn); |
| 1210 | 1210 | R15 += 2; |
| r14063 | r14064 | |
| 1213 | 1213 | |
| 1214 | 1214 | const void tg0b_8(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1215 | 1215 | { |
| 1216 | // UINT32 addr; | |
| 1217 | // INT32 offs; | |
| 1216 | // UINT32 addr; | |
| 1217 | // INT32 offs; | |
| 1218 | 1218 | |
| 1219 | 1219 | fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn); |
| 1220 | 1220 | R15 += 2; |
| r14063 | r14064 | |
| 1223 | 1223 | |
| 1224 | 1224 | const void tg0b_9(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1225 | 1225 | { |
| 1226 | // UINT32 addr; | |
| 1227 | // INT32 offs; | |
| 1226 | // UINT32 addr; | |
| 1227 | // INT32 offs; | |
| 1228 | 1228 | |
| 1229 | 1229 | fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn); |
| 1230 | 1230 | R15 += 2; |
| r14063 | r14064 | |
| 1233 | 1233 | |
| 1234 | 1234 | const void tg0b_a(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1235 | 1235 | { |
| 1236 | // UINT32 addr; | |
| 1237 | // INT32 offs; | |
| 1236 | // UINT32 addr; | |
| 1237 | // INT32 offs; | |
| 1238 | 1238 | |
| 1239 | 1239 | fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn); |
| 1240 | 1240 | R15 += 2; |
| r14063 | r14064 | |
| 1243 | 1243 | |
| 1244 | 1244 | const void tg0b_b(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1245 | 1245 | { |
| 1246 | // UINT32 addr; | |
| 1247 | // INT32 offs; | |
| 1246 | // UINT32 addr; | |
| 1247 | // INT32 offs; | |
| 1248 | 1248 | |
| 1249 | 1249 | fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn); |
| 1250 | 1250 | R15 += 2; |
| r14063 | r14064 | |
| 1254 | 1254 | const void tg0b_c(arm_state *cpustate, UINT32 pc, UINT32 insn) /* POP {Rlist} */ |
| 1255 | 1255 | { |
| 1256 | 1256 | INT32 offs; |
| 1257 | ||
| 1257 | ||
| 1258 | 1258 | for (offs = 0; offs < 8; offs++) |
| 1259 | 1259 | { |
| 1260 | 1260 | if (insn & (1 << offs)) |
| r14063 | r14064 | |
| 1270 | 1270 | const void tg0b_d(arm_state *cpustate, UINT32 pc, UINT32 insn) /* POP {Rlist}{PC} */ |
| 1271 | 1271 | { |
| 1272 | 1272 | INT32 offs; |
| 1273 | ||
| 1273 | ||
| 1274 | 1274 | for (offs = 0; offs < 8; offs++) |
| 1275 | 1275 | { |
| 1276 | 1276 | if (insn & (1 << offs)) |
| r14063 | r14064 | |
| 1286 | 1286 | |
| 1287 | 1287 | const void tg0b_e(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1288 | 1288 | { |
| 1289 | // UINT32 addr; | |
| 1290 | // INT32 offs; | |
| 1289 | // UINT32 addr; | |
| 1290 | // INT32 offs; | |
| 1291 | 1291 | |
| 1292 | 1292 | fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn); |
| 1293 | 1293 | R15 += 2; |
| r14063 | r14064 | |
| 1296 | 1296 | |
| 1297 | 1297 | const void tg0b_f(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1298 | 1298 | { |
| 1299 | // UINT32 addr; | |
| 1300 | // INT32 offs; | |
| 1299 | // UINT32 addr; | |
| 1300 | // INT32 offs; | |
| 1301 | 1301 | |
| 1302 | 1302 | fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn); |
| 1303 | 1303 | R15 += 2; |
| r14063 | r14064 | |
| 1361 | 1361 | ld_st_address += 4; |
| 1362 | 1362 | } |
| 1363 | 1363 | } |
| 1364 | ||
| 1364 | ||
| 1365 | 1365 | if (!rd_in_list) |
| 1366 | 1366 | SET_REGISTER(cpustate, rd, ld_st_address); |
| 1367 | ||
| 1367 | ||
| 1368 | 1368 | R15 += 2; |
| 1369 | 1369 | } |
| 1370 | 1370 | |
| r14063 | r14064 | |
| 1375 | 1375 | INT32 offs; |
| 1376 | 1376 | |
| 1377 | 1377 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1378 | //case | |
| 1378 | //case | |
| 1379 | 1379 | if (Z_IS_SET(GET_CPSR)) |
| 1380 | 1380 | { |
| 1381 | 1381 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1392 | 1392 | INT32 offs; |
| 1393 | 1393 | |
| 1394 | 1394 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1395 | //case | |
| 1395 | //case | |
| 1396 | 1396 | if (Z_IS_CLEAR(GET_CPSR)) |
| 1397 | 1397 | { |
| 1398 | 1398 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1409 | 1409 | INT32 offs; |
| 1410 | 1410 | |
| 1411 | 1411 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1412 | //case | |
| 1412 | //case | |
| 1413 | 1413 | if (C_IS_SET(GET_CPSR)) |
| 1414 | 1414 | { |
| 1415 | 1415 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1426 | 1426 | INT32 offs; |
| 1427 | 1427 | |
| 1428 | 1428 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1429 | //case | |
| 1429 | //case | |
| 1430 | 1430 | if (C_IS_CLEAR(GET_CPSR)) |
| 1431 | 1431 | { |
| 1432 | 1432 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1443 | 1443 | INT32 offs; |
| 1444 | 1444 | |
| 1445 | 1445 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1446 | //case | |
| 1446 | //case | |
| 1447 | 1447 | if (N_IS_SET(GET_CPSR)) |
| 1448 | 1448 | { |
| 1449 | 1449 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1460 | 1460 | INT32 offs; |
| 1461 | 1461 | |
| 1462 | 1462 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1463 | //case | |
| 1463 | //case | |
| 1464 | 1464 | if (N_IS_CLEAR(GET_CPSR)) |
| 1465 | 1465 | { |
| 1466 | 1466 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1477 | 1477 | INT32 offs; |
| 1478 | 1478 | |
| 1479 | 1479 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1480 | //case | |
| 1480 | //case | |
| 1481 | 1481 | if (V_IS_SET(GET_CPSR)) |
| 1482 | 1482 | { |
| 1483 | 1483 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1494 | 1494 | INT32 offs; |
| 1495 | 1495 | |
| 1496 | 1496 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1497 | //case | |
| 1497 | //case | |
| 1498 | 1498 | if (V_IS_CLEAR(GET_CPSR)) |
| 1499 | 1499 | { |
| 1500 | 1500 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1511 | 1511 | INT32 offs; |
| 1512 | 1512 | |
| 1513 | 1513 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1514 | //case | |
| 1514 | //case | |
| 1515 | 1515 | if (C_IS_SET(GET_CPSR) && Z_IS_CLEAR(GET_CPSR)) |
| 1516 | 1516 | { |
| 1517 | 1517 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1528 | 1528 | INT32 offs; |
| 1529 | 1529 | |
| 1530 | 1530 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1531 | //case | |
| 1531 | //case | |
| 1532 | 1532 | if (C_IS_CLEAR(GET_CPSR) || Z_IS_SET(GET_CPSR)) |
| 1533 | 1533 | { |
| 1534 | 1534 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1545 | 1545 | INT32 offs; |
| 1546 | 1546 | |
| 1547 | 1547 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1548 | //case | |
| 1548 | //case | |
| 1549 | 1549 | if (!(GET_CPSR & N_MASK) == !(GET_CPSR & V_MASK)) |
| 1550 | 1550 | { |
| 1551 | 1551 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1562 | 1562 | INT32 offs; |
| 1563 | 1563 | |
| 1564 | 1564 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1565 | //case | |
| 1565 | //case | |
| 1566 | 1566 | if (!(GET_CPSR & N_MASK) != !(GET_CPSR & V_MASK)) |
| 1567 | 1567 | { |
| 1568 | 1568 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1579 | 1579 | INT32 offs; |
| 1580 | 1580 | |
| 1581 | 1581 | offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1582 | //case | |
| 1582 | //case | |
| 1583 | 1583 | if (Z_IS_CLEAR(GET_CPSR) && !(GET_CPSR & N_MASK) == !(GET_CPSR & V_MASK)) |
| 1584 | 1584 | { |
| 1585 | 1585 | R15 += 4 + (offs << 1); |
| r14063 | r14064 | |
| 1610 | 1610 | |
| 1611 | 1611 | const void tg0d_e(arm_state *cpustate, UINT32 pc, UINT32 insn) // COND_AL: |
| 1612 | 1612 | { |
| 1613 | // | |
| 1613 | // INT32 offs; | |
| 1614 | 1614 | |
| 1615 | 1615 | // offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1616 | //case | |
| 1616 | //case | |
| 1617 | 1617 | fatalerror("%08x: Undefined Thumb instruction: %04x (ARM9 reserved)\n", pc, insn); |
| 1618 | 1618 | R15 += 2; |
| 1619 | 1619 | |
| r14063 | r14064 | |
| 1621 | 1621 | |
| 1622 | 1622 | const void tg0d_f(arm_state *cpustate, UINT32 pc, UINT32 insn) // COND_NV: // SWI (this is sort of a "hole" in the opcode encoding) |
| 1623 | 1623 | { |
| 1624 | // | |
| 1624 | // INT32 offs; | |
| 1625 | 1625 | |
| 1626 | 1626 | // offs = (INT8)(insn & THUMB_INSN_IMM); |
| 1627 | 1627 | |
| 1628 | //case | |
| 1628 | //case | |
| 1629 | 1629 | cpustate->pendingSwi = 1; |
| 1630 | 1630 | ARM7_CHECKIRQ; |
| 1631 | 1631 | |
| r14063 | r14064 | |
| 1633 | 1633 | |
| 1634 | 1634 | /* B #offs */ |
| 1635 | 1635 | |
| 1636 | const void tg0e_0(arm_state *cpustate, UINT32 pc, UINT32 insn) | |
| 1636 | const void tg0e_0(arm_state *cpustate, UINT32 pc, UINT32 insn) | |
| 1637 | 1637 | { |
| 1638 | 1638 | INT32 offs; |
| 1639 | 1639 | |
| r14063 | r14064 | |
| 1649 | 1649 | const void tg0e_1(arm_state *cpustate, UINT32 pc, UINT32 insn) |
| 1650 | 1650 | { |
| 1651 | 1651 | UINT32 addr; |
| 1652 | ||
| 1652 | ||
| 1653 | 1653 | addr = GET_REGISTER(cpustate, 14); |
| 1654 | 1654 | addr += (insn & THUMB_BLOP_OFFS) << 1; |
| 1655 | 1655 | addr &= 0xfffffffc; |
| r14063 | r14064 | |
|---|---|---|
| 551 | 551 | |
| 552 | 552 | insn = cpustate->direct->read_decrypted_word(raddr); |
| 553 | 553 | thumb_handler[(insn & 0xffc0) >> 6](cpustate, pc, insn); |
| 554 | ||
| 554 | ||
| 555 | 555 | } |
| 556 | 556 | else |
| 557 | 557 | { |
| r14063 | r14064 | |
|---|---|---|
| 1840 | 1840 | HandleALU(cpustate, insn); |
| 1841 | 1841 | } |
| 1842 | 1842 | } |
| 1843 | // | |
| 1843 | // break; | |
| 1844 | 1844 | } |
| 1845 | 1845 | |
| 1846 | 1846 | const void arm7ops_4567(arm_state *cpustate, UINT32 insn) /* Data Transfer - Single Data Access */ |
| r14063 | r14064 | |
| 1851 | 1851 | //case 7: |
| 1852 | 1852 | HandleMemSingle(cpustate, insn); |
| 1853 | 1853 | R15 += 4; |
| 1854 | // | |
| 1854 | // break; | |
| 1855 | 1855 | } |
| 1856 | ||
| 1856 | ||
| 1857 | 1857 | const void arm7ops_89(arm_state *cpustate, UINT32 insn) /* Block Data Transfer/Access */ |
| 1858 | 1858 | { |
| 1859 | 1859 | //case 8: |
| 1860 | 1860 | //case 9: |
| 1861 | 1861 | HandleMemBlock(cpustate, insn); |
| 1862 | 1862 | R15 += 4; |
| 1863 | // | |
| 1863 | // break; | |
| 1864 | 1864 | } |
| 1865 | 1865 | |
| 1866 | 1866 | const void arm7ops_ab(arm_state *cpustate, UINT32 insn) /* Branch or Branch & Link */ |
| r14063 | r14064 | |
| 1868 | 1868 | //case 0xa: |
| 1869 | 1869 | //case 0xb: |
| 1870 | 1870 | HandleBranch(cpustate, insn); |
| 1871 | // | |
| 1871 | // break; | |
| 1872 | 1872 | } |
| 1873 | 1873 | |
| 1874 | 1874 | const void arm7ops_cd(arm_state *cpustate, UINT32 insn) /* Co-Processor Data Transfer */ |
| r14063 | r14064 | |
| 1877 | 1877 | //case 0xd: |
| 1878 | 1878 | HandleCoProcDT(cpustate, insn); |
| 1879 | 1879 | R15 += 4; |
| 1880 | // | |
| 1880 | // break; | |
| 1881 | 1881 | } |
| 1882 | 1882 | |
| 1883 | 1883 | const void arm7ops_e(arm_state *cpustate, UINT32 insn) /* Co-Processor Data Operation or Register Transfer */ |
| r14063 | r14064 | |
| 1888 | 1888 | else |
| 1889 | 1889 | HandleCoProcDO(cpustate, insn); |
| 1890 | 1890 | R15 += 4; |
| 1891 | // | |
| 1891 | // break; | |
| 1892 | 1892 | } |
| 1893 | 1893 | |
| 1894 | 1894 | const void arm7ops_f(arm_state *cpustate, UINT32 insn) /* Software Interrupt */ |
| r14063 | r14064 | |
| 1896 | 1896 | cpustate->pendingSwi = 1; |
| 1897 | 1897 | ARM7_CHECKIRQ; |
| 1898 | 1898 | //couldn't find any cycle counts for SWI |
| 1899 | // | |
| 1899 | // break; | |
| 1900 | 1900 | } |
| r14063 | r14064 | |
|---|---|---|
| 5 | 5 | const void arm7ops_ab(arm_state *cpustate, UINT32 insn); |
| 6 | 6 | const void arm7ops_cd(arm_state *cpustate, UINT32 insn); |
| 7 | 7 | const void arm7ops_e(arm_state *cpustate, UINT32 insn); |
| 8 | const void arm7ops_f(arm_state *cpustate, UINT32 insn); | |
| No newline at end of file | ||
| 8 | const void arm7ops_f(arm_state *cpustate, UINT32 insn); |
| r14063 | r14064 | |
|---|---|---|
| 169 | 169 | |
| 170 | 170 | rectangle visarea; |
| 171 | 171 | |
| 172 | visarea.min_x = 0; | |
| 173 | visarea.min_y = 0; | |
| 174 | visarea.max_x = (m_h * m_width) - 1; | |
| 175 | visarea.max_y = (m_l * m_r) - 1; | |
| 172 | visarea.set(0, (m_h * m_width) - 1, 0, (m_l * m_r) - 1); | |
| 176 | 173 | |
| 177 | 174 | if (LOG) |
| 178 | 175 | { |
| r14063 | r14064 | |
|---|---|---|
| 420 | 420 | // visible area |
| 421 | 421 | rectangle visarea; |
| 422 | 422 | |
| 423 | visarea.min_x = m_hsync_end; | |
| 424 | visarea.max_x = horiz_pix_total - 1; | |
| 423 | visarea.set(m_hsync_end, horiz_pix_total - 1, m_vsync_end, vert_pix_total - 1); | |
| 425 | 424 | |
| 426 | visarea.min_y = m_vsync_end; | |
| 427 | visarea.max_y = vert_pix_total - 1; | |
| 428 | ||
| 429 | 425 | if (LOG) |
| 430 | 426 | { |
| 431 | 427 | logerror("CRT9007 '%s' Screen: %u x %u @ %f Hz\n", tag(), horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh)); |
| r14063 | r14064 | |
|---|---|---|
| 324 | 324 | |
| 325 | 325 | attoseconds_t refresh = HZ_TO_ATTOSECONDS(m_clock) * (m_horiz_char_total + 1) * vert_pix_total; |
| 326 | 326 | |
| 327 | visarea.min_x = 0; | |
| 328 | visarea.min_y = 0; | |
| 329 | visarea.max_x = max_visible_x; | |
| 330 | visarea.max_y = max_visible_y; | |
| 327 | visarea.set(0, max_visible_x, 0, max_visible_y); | |
| 331 | 328 | |
| 332 | 329 | if (LOG) logerror("M6845 config screen: HTOTAL: 0x%x VTOTAL: 0x%x MAX_X: 0x%x MAX_Y: 0x%x HSYNC: 0x%x-0x%x VSYNC: 0x%x-0x%x Freq: %ffps\n", |
| 333 | 330 | horiz_pix_total, vert_pix_total, max_visible_x, max_visible_y, hsync_on_pos, hsync_off_pos - 1, vsync_on_pos, vsync_off_pos - 1, 1 / ATTOSECONDS_TO_DOUBLE(refresh)); |
| r14063 | r14064 | |
|---|---|---|
| 284 | 284 | int sy = m_sy + z; |
| 285 | 285 | int sx = m_sx + y; |
| 286 | 286 | |
| 287 | if ( | |
| 287 | if ( | |
| 288 | 288 | { |
| 289 | 289 | int color = (m_status & STATUS_DISPLAY_OFF) ? 0 : BIT(data, z % 8); |
| 290 | 290 |
| r14063 | r14064 | |
|---|---|---|
| 930 | 930 | if (v->stats.display) |
| 931 | 931 | { |
| 932 | 932 | const rectangle &visible_area = v->screen->visible_area(); |
| 933 | int screen_area = | |
| 933 | int screen_area = | |
| 934 | 934 | char *statsptr = v->stats.buffer; |
| 935 | 935 | int pixelcount; |
| 936 | 936 | int i; |
| r14063 | r14064 | |
| 2573 | 2573 | rectangle visarea; |
| 2574 | 2574 | |
| 2575 | 2575 | /* create a new visarea */ |
| 2576 | visarea.min_x = hbp; | |
| 2577 | visarea.max_x = hbp + hvis - 1; | |
| 2578 | visarea.min_y = vbp; | |
| 2579 | visarea.max_y = vbp + vvis - 1; | |
| 2576 | visarea.set(hbp, hbp + hvis - 1, vbp, vbp + vvis - 1); | |
| 2580 | 2577 | |
| 2581 | 2578 | /* keep within bounds */ |
| 2582 | 2579 | visarea.max_x = MIN(visarea.max_x, htotal - 1); |
| r14063 | r14064 | |
|---|---|---|
| 201 | 201 | vert_pix_total *= 2; // Use of spaced rows |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | visarea.min_x = 0; | |
| 205 | visarea.min_y = 0; | |
| 206 | visarea.max_x = horiz_pix_total - 1; | |
| 207 | visarea.max_y = vert_pix_total - 1; | |
| 204 | visarea.set(0, horiz_pix_total - 1, 0, vert_pix_total - 1); | |
| 208 | 205 | |
| 209 | 206 | i8275->screen->configure(horiz_pix_total, vert_pix_total, visarea, |
| 210 | 207 | i8275->screen->frame_period().attoseconds); |
| r14063 | r14064 | |
|---|---|---|
| 162 | 162 | int tx = x + sx * (expand + 1) + ex; |
| 163 | 163 | |
| 164 | 164 | /* get out if outside the drawing region */ |
| 165 | if ((tx < cliprect.min_x) || | |
| 166 | (tx > cliprect.max_x) || | |
| 167 | (ty < cliprect.min_y) || | |
| 168 | (ty > cliprect.max_y)) | |
| 165 | if (!cliprect.contains(tx, ty)) | |
| 169 | 166 | continue; |
| 170 | 167 | |
| 171 | 168 | /* get out if current image bit is transparent */ |
| r14063 | r14064 | |
| 221 | 218 | for (x = x1; x < x1 + SPRITE_WIDTH; x++) |
| 222 | 219 | for (y = y1; y < y1 + SPRITE_HEIGHT; y++) |
| 223 | 220 | { |
| 224 | if ((x < cliprect.min_x) || (x > cliprect.max_x) || | |
| 225 | (y < cliprect.min_y) || (y > cliprect.max_y)) | |
| 221 | if (!cliprect.contains(x, y)) | |
| 226 | 222 | continue; |
| 227 | 223 | |
| 228 | 224 | checksum = checksum + s2636->collision_bitmap->pix16(y, x); |
| r14063 | r14064 | |
| 235 | 231 | for (x = x1; x < x1 + SPRITE_WIDTH; x++) |
| 236 | 232 | for (y = y1; y < y1 + SPRITE_HEIGHT; y++) |
| 237 | 233 | { |
| 238 | if ((x < cliprect.min_x) || (x > cliprect.max_x) || | |
| 239 | (y < cliprect.min_y) || (y > cliprect.max_y)) | |
| 234 | if (!cliprect.contains(x, y)) | |
| 240 | 235 | continue; |
| 241 | 236 | |
| 242 | 237 | checksum = checksum - s2636->collision_bitmap->pix16(y, x); |
| r14063 | r14064 | |
|---|---|---|
| 240 | 240 | |
| 241 | 241 | /* create a visible area */ |
| 242 | 242 | /* fix me: how do the offsets fit in here? */ |
| 243 | visarea.min_x = 0; | |
| 244 | visarea.max_x = tms->visible_hpix - 1; | |
| 245 | visarea.min_y = 0; | |
| 246 | visarea.max_y = tms->visible_vpix - 1; | |
| 243 | visarea.set(0, tms->visible_hpix - 1, 0, tms->visible_vpix - 1); | |
| 247 | 244 | |
| 248 | 245 | refresh = HZ_TO_ATTOSECONDS(tms->clock) * tms->total_hpix * tms->total_vpix; |
| 249 | 246 |
| r14063 | r14064 | |
|---|---|---|
| 181 | 181 | |
| 182 | 182 | void pc_video_start(running_machine &machine) |
| 183 | 183 | { |
| 184 | // | |
| 184 | // pc_choosevideomode = choosevideomode; | |
| 185 | 185 | pc_current_height = -1; |
| 186 | 186 | pc_current_width = -1; |
| 187 | 187 | } |
| r14063 | r14064 | |
|---|---|---|
| 435 | 435 | n_screenwidth = 640; |
| 436 | 436 | break; |
| 437 | 437 | } |
| 438 | visarea.min_x = visarea.min_y = 0; | |
| 439 | visarea.max_x = n_screenwidth - 1; | |
| 440 | visarea.max_y = n_screenheight - 1; | |
| 438 | visarea.set(0, n_screenwidth - 1, 0, n_screenheight - 1); | |
| 441 | 439 | machine().primary_screen->configure(n_screenwidth, n_screenheight, visarea, HZ_TO_ATTOSECONDS(refresh)); |
| 442 | 440 | } |
| 443 | 441 |
| r14063 | r14064 | |
|---|---|---|
| 258 | 258 | { |
| 259 | 259 | UINT32 flags = PRIMFLAG_ANTIALIAS(screen.machine().options().antialias() ? 1 : 0) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD); |
| 260 | 260 | const rectangle &visarea = screen.visible_area(); |
| 261 | float xscale = 1.0f / (65536 * (visarea.max_x - visarea.min_x)); | |
| 262 | float yscale = 1.0f / (65536 * (visarea.max_y - visarea.min_y)); | |
| 261 | float xscale = 1.0f / (65536 * visarea.width()); | |
| 262 | float yscale = 1.0f / (65536 * visarea.height()); | |
| 263 | 263 | float xoffs = (float)visarea.min_x; |
| 264 | 264 | float yoffs = (float)visarea.min_y; |
| 265 | 265 | point *curpoint; |
| r14063 | r14064 | |
|---|---|---|
| 257 | 257 | |
| 258 | 258 | // init v9938 512-color palette |
| 259 | 259 | PALETTE_INIT_CALL(v9938); |
| 260 | ||
| 260 | ||
| 261 | 261 | if (v99x8_device::s_pal_indYJK == NULL) |
| 262 | 262 | v99x8_device::s_pal_indYJK = global_alloc_array(UINT16, 0x20000); |
| 263 | 263 | |
| r14063 | r14064 | |
| 585 | 585 | assert(m_screen != NULL); |
| 586 | 586 | if (!m_screen->started()) |
| 587 | 587 | throw device_missing_dependencies(); |
| 588 | ||
| 588 | ||
| 589 | 589 | if (!m_int_callback.isnull()) |
| 590 | 590 | { |
| 591 | 591 | device_t *device = (m_int_callback_device_name != NULL) ? machine().device(m_int_callback_device_name) : NULL; |
| r14063 | r14064 | |
| 1867 | 1867 | |
| 1868 | 1868 | #define SHORT_WIDTH (256 + 16) |
| 1869 | 1869 | #define LONG_WIDTH (512 + 32) |
| 1870 | ||
| 1870 | ||
| 1871 | 1871 | const v99x8_device::v99x8_mode v99x8_device::s_modes[] = { |
| 1872 | 1872 | { 0x02, |
| 1873 | 1873 | &v99x8_device::mode_text1<UINT16, LONG_WIDTH>, |
| r14063 | r14064 | |
| 2274 | 2274 | #define CM_HMMC 0xF |
| 2275 | 2275 | |
| 2276 | 2276 | /*************************************************************/ |
| 2277 | // Many VDP commands are executed in some kind of loop but | |
| 2278 | // essentially, there are only a few basic loop structures | |
| 2279 | // that are re-used. We define the loop structures that are | |
| 2280 | // re-used here so that they have to be entered only once | |
| 2277 | // Many VDP commands are executed in some kind of loop but | |
| 2278 | // essentially, there are only a few basic loop structures | |
| 2279 | // that are re-used. We define the loop structures that are | |
| 2280 | // re-used here so that they have to be entered only once | |
| 2281 | 2281 | /*************************************************************/ |
| 2282 | 2282 | #define pre_loop \ |
| 2283 | 2283 | while ((cnt-=delta) > 0) { |
| r14063 | r14064 | |
| 2331 | 2331 | // ScrOf ScrOn ScrOf ScrOn |
| 2332 | 2332 | static const int srch_timing[8]={ |
| 2333 | 2333 | 818, 1025, 818, 830, // ntsc |
| 2334 | 696, 854, 696, 684 // pal | |
| 2334 | 696, 854, 696, 684 // pal | |
| 2335 | 2335 | }; |
| 2336 | 2336 | static const int line_timing[8]={ |
| 2337 | 2337 | 1063, 1259, 1063, 1161, |
| r14063 | r14064 | |
| 3106 | 3106 | if (ScrMode<5) |
| 3107 | 3107 | return(0); |
| 3108 | 3108 | |
| 3109 | SM = ScrMode-5; // Screen mode index 0..3 | |
| 3109 | SM = ScrMode-5; // Screen mode index 0..3 | |
| 3110 | 3110 | |
| 3111 | 3111 | m_mmc.CM = Op>>4; |
| 3112 | 3112 | if ((m_mmc.CM & 0x0C) != 0x0C && m_mmc.CM != 0) |
| r14063 | r14064 | |
|---|---|---|
| 79 | 79 | int get_transpen(); |
| 80 | 80 | bitmap_ind16 &get_bitmap() { return m_bitmap; } |
| 81 | 81 | void update_mouse_state(int mx_delta, int my_delta, int button_state); |
| 82 | ||
| 82 | ||
| 83 | 83 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 84 | 84 | |
| 85 | 85 | DECLARE_READ8_MEMBER( read ); |
| r14063 | r14064 | |
| 98 | 98 | |
| 99 | 99 | protected: |
| 100 | 100 | int m_model; |
| 101 | ||
| 101 | ||
| 102 | 102 | // device overrides |
| 103 | 103 | virtual void device_start(); |
| 104 | 104 | virtual void device_reset(); |
| r14063 | r14064 | |
| 110 | 110 | int vram_read (int offset); |
| 111 | 111 | void check_int (); |
| 112 | 112 | void register_write (int reg, int data); |
| 113 | ||
| 113 | ||
| 114 | 114 | template<typename _PixelType, int _Width> void default_border(const pen_t *pens, _PixelType *ln); |
| 115 | 115 | template<typename _PixelType, int _Width> void graphic7_border(const pen_t *pens, _PixelType *ln); |
| 116 | 116 | template<typename _PixelType, int _Width> void graphic5_border(const pen_t *pens, _PixelType *ln); |
| r14063 | r14064 | |
| 135 | 135 | void refresh_line (int line); |
| 136 | 136 | |
| 137 | 137 | void interrupt_start_vblank (); |
| 138 | ||
| 138 | ||
| 139 | 139 | UINT8 *VDPVRMP(UINT8 M, int MX, int X, int Y); |
| 140 | 140 | |
| 141 | 141 | UINT8 VDPpoint5(int MXS, int SX, int SY); |
| r14063 | r14064 | |
|---|---|---|
| 4 | 4 | |
| 5 | 5 | Generic tilemap management system. |
| 6 | 6 | |
| 7 | Copyright Nicola Salmoria and the MAME Team. | |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. | |
| 7 | **************************************************************************** | |
| 9 | 8 | |
| 10 | ***************************************************************************/ | |
| 9 | Copyright Aaron Giles | |
| 10 | All rights reserved. | |
| 11 | 11 | |
| 12 | #include "emu.h" | |
| 13 | #include "profiler.h" | |
| 12 | Redistribution and use in source and binary forms, with or without | |
| 13 | modification, are permitted provided that the following conditions are | |
| 14 | met: | |
| 14 | 15 | |
| 16 | * Redistributions of source code must retain the above copyright | |
| 17 | notice, this list of conditions and the following disclaimer. | |
| 18 | * Redistributions in binary form must reproduce the above copyright | |
| 19 | notice, this list of conditions and the following disclaimer in | |
| 20 | the documentation and/or other materials provided with the | |
| 21 | distribution. | |
| 22 | * Neither the name 'MAME' nor the names of its contributors may be | |
| 23 | used to endorse or promote products derived from this software | |
| 24 | without specific prior written permission. | |
| 15 | 25 | |
| 16 | /*************************************************************************** | |
| 17 | CONSTANTS | |
| 18 | ***************************************************************************/ | |
| 26 | THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR | |
| 27 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 28 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 29 | DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, | |
| 30 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 31 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 32 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 34 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
| 35 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 36 | POSSIBILITY OF SUCH DAMAGE. | |
| 19 | 37 | |
| 20 | /* internal usage to mark tiles dirty */ | |
| 21 | #define TILE_FLAG_DIRTY 0xff | |
| 22 | ||
| 23 | /* invalid logical index */ | |
| 24 | #define INVALID_LOGICAL_INDEX ((tilemap_logical_index)~0) | |
| 25 | ||
| 26 | /* maximum index in each array */ | |
| 27 | #define MAX_PEN_TO_FLAGS 256 | |
| 28 | ||
| 29 | ||
| 30 | /*************************************************************************** | |
| 31 | TYPE DEFINITIONS | |
| 32 | 38 | ***************************************************************************/ |
| 33 | 39 | |
| 34 | /* logical index */ | |
| 35 | typedef UINT32 tilemap_logical_index; | |
| 40 | #include "emu.h" | |
| 41 | #include "profiler.h" | |
| 36 | 42 | |
| 37 | 43 | |
| 38 | /* internal set of transparency states for rendering */ | |
| 39 | typedef enum | |
| 40 | { | |
| 41 | WHOLLY_TRANSPARENT, | |
| 42 | WHOLLY_OPAQUE, | |
| 43 | MASKED | |
| 44 | } trans_t; | |
| 44 | //************************************************************************** | |
| 45 | // INLINE FUNCTIONS | |
| 46 | //************************************************************************** | |
| 45 | 47 | |
| 48 | //------------------------------------------------- | |
| 49 | // effective_rowscroll - return the effective | |
| 50 | // rowscroll value for a given index, taking into | |
| 51 | // account tilemap flip states | |
| 52 | //------------------------------------------------- | |
| 46 | 53 | |
| 47 | /* internal blitting callbacks */ | |
| 48 | typedef void (*blitmask_func)(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha); | |
| 49 | typedef void (*blitopaque_func)(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha); | |
| 50 | ||
| 51 | ||
| 52 | /* blitting parameters for rendering */ | |
| 53 | typedef struct _blit_parameters blit_parameters; | |
| 54 | struct _blit_parameters | |
| 54 | inline INT32 tilemap_t::effective_rowscroll(int index, UINT32 screen_width) | |
| 55 | 55 | { |
| 56 | rectangle cliprect; | |
| 57 | blitmask_func draw_masked; | |
| 58 | blitopaque_func draw_opaque; | |
| 59 | UINT32 tilemap_priority_code; | |
| 60 | UINT8 mask; | |
| 61 | UINT8 value; | |
| 62 | UINT8 alpha; | |
| 63 | }; | |
| 56 | // if we're flipping vertically, adjust the row number | |
| 57 | if (m_attributes & TILEMAP_FLIPY) | |
| 58 | index = m_scrollrows - 1 - index; | |
| 64 | 59 | |
| 65 | ||
| 66 | /* core tilemap structure */ | |
| 67 | class tilemap_t | |
| 68 | { | |
| 69 | public: | |
| 70 | tilemap_t(running_machine &machine) | |
| 71 | : m_machine(machine) { } | |
| 72 | ||
| 73 | running_machine &machine() const { return m_machine; } | |
| 74 | ||
| 75 | tilemap_t * next; /* pointer to next tilemap */ | |
| 76 | ||
| 77 | /* basic tilemap metrics */ | |
| 78 | UINT32 rows; /* number of tile rows */ | |
| 79 | UINT32 cols; /* number of tile columns */ | |
| 80 | UINT32 tilewidth; /* width of a single tile in pixels */ | |
| 81 | UINT32 tileheight; /* height of a single tile in pixels */ | |
| 82 | UINT32 width; /* width of the full tilemap in pixels */ | |
| 83 | UINT32 height; /* height of the full tilemap in pixels */ | |
| 84 | ||
| 85 | /* logical <-> memory mappings */ | |
| 86 | tilemap_mapper_func mapper; /* callback to map a row/column to a memory index */ | |
| 87 | tilemap_logical_index * memory_to_logical; /* map from memory index to logical index */ | |
| 88 | tilemap_logical_index max_logical_index; /* maximum valid logical index */ | |
| 89 | tilemap_memory_index * logical_to_memory; /* map from logical index to memory index */ | |
| 90 | tilemap_memory_index max_memory_index; /* maximum valid memory index */ | |
| 91 | ||
| 92 | /* callback to interpret video RAM for the tilemap */ | |
| 93 | tile_get_info_func tile_get_info; /* callback to get information about a tile */ | |
| 94 | void * tile_get_info_object;/* object passed as the first parameter to the get_info functon */ | |
| 95 | tile_data tileinfo; /* structure to hold the data for a tile */ | |
| 96 | void * user_data; /* user data value passed to the callback */ | |
| 97 | ||
| 98 | /* global tilemap states */ | |
| 99 | UINT8 enable; /* true if we are enabled */ | |
| 100 | UINT8 attributes; /* global attributes (flipx/y) */ | |
| 101 | UINT8 all_tiles_dirty; /* true if all tiles are dirty */ | |
| 102 | UINT8 all_tiles_clean; /* true if all tiles are clean */ | |
| 103 | UINT32 palette_offset; /* palette offset */ | |
| 104 | UINT32 pen_data_offset; /* pen data offset */ | |
| 105 | UINT32 gfx_used; /* bitmask of gfx items used */ | |
| 106 | UINT32 gfx_dirtyseq[MAX_GFX_ELEMENTS]; /* dirtyseq values from last check */ | |
| 107 | ||
| 108 | /* scroll information */ | |
| 109 | UINT32 scrollrows; /* number of independently scrolled rows */ | |
| 110 | UINT32 scrollcols; /* number of independently scrolled colums */ | |
| 111 | INT32 * rowscroll; /* array of rowscroll values */ | |
| 112 | INT32 * colscroll; /* array of colscroll values */ | |
| 113 | INT32 dx; /* global horizontal scroll offset */ | |
| 114 | INT32 dx_flipped; /* global horizontal scroll offset when flipped */ | |
| 115 | INT32 dy; /* global vertical scroll offset */ | |
| 116 | INT32 dy_flipped; /* global vertical scroll offset when flipped */ | |
| 117 | ||
| 118 | /* pixel data */ | |
| 119 | bitmap_ind16 pixmap; /* cached pixel data */ | |
| 120 | ||
| 121 | /* transparency mapping */ | |
| 122 | bitmap_ind8 flagsmap; /* per-pixel flags */ | |
| 123 | UINT8 * tileflags; /* per-tile flags */ | |
| 124 | UINT8 * pen_to_flags; /* mapping of pens to flags */ | |
| 125 | ||
| 126 | private: | |
| 127 | running_machine & m_machine; /* pointer back to the owning machine */ | |
| 128 | }; | |
| 129 | ||
| 130 | ||
| 131 | struct _tilemap_private | |
| 132 | { | |
| 133 | tilemap_t * list; | |
| 134 | tilemap_t ** tailptr; | |
| 135 | int instance; | |
| 136 | }; | |
| 137 | ||
| 138 | ||
| 139 | ||
| 140 | /*************************************************************************** | |
| 141 | FUNCTION PROTOTYPES | |
| 142 | ***************************************************************************/ | |
| 143 | ||
| 144 | /* system management helpers */ | |
| 145 | static tilemap_t *tilemap_create_common(running_machine &machine, void *get_info_object, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows); | |
| 146 | static void tilemap_exit(running_machine &machine); | |
| 147 | static void tilemap_postload(tilemap_t *tmap); | |
| 148 | static void tilemap_dispose(tilemap_t *tmap); | |
| 149 | ||
| 150 | /* logical <-> memory index mapping */ | |
| 151 | static void mappings_create(tilemap_t *tmap); | |
| 152 | static void mappings_update(tilemap_t *tmap); | |
| 153 | ||
| 154 | /* tile rendering */ | |
| 155 | static void pixmap_update(tilemap_t *tmap); | |
| 156 | static void tile_update(tilemap_t *tmap, tilemap_logical_index logindex, UINT32 cached_col, UINT32 cached_row); | |
| 157 | static UINT8 tile_draw(tilemap_t *tmap, const UINT8 *pendata, UINT32 x0, UINT32 y0, UINT32 palette_base, UINT8 category, UINT8 group, UINT8 flags, UINT8 pen_mask); | |
| 158 | static UINT8 tile_apply_bitmask(tilemap_t *tmap, const UINT8 *maskdata, UINT32 x0, UINT32 y0, UINT8 category, UINT8 flags); | |
| 159 | ||
| 160 | /* drawing helpers */ | |
| 161 | static void configure_blit_parameters(blit_parameters *blit, tilemap_t *tmap, bitmap_format dest_format, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask); | |
| 162 | template<class _BitmapClass> | |
| 163 | static void tilemap_draw_instance(_BitmapClass &dest, tilemap_t *tmap, const blit_parameters *blit, int xpos, int ypos); | |
| 164 | template<class _BitmapClass> | |
| 165 | static void tilemap_draw_roz_core(_BitmapClass &dest, tilemap_t *tmap, const blit_parameters *blit, | |
| 166 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound); | |
| 167 | ||
| 168 | /* scanline rasterizers for drawing to the pixmap */ | |
| 169 | inline void scanline_draw_opaque_null(int count, UINT8 *pri, UINT32 pcode); | |
| 170 | inline void scanline_draw_masked_null(const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode); | |
| 171 | inline void scanline_draw_opaque_ind16(UINT16 *dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode); | |
| 172 | inline void scanline_draw_masked_ind16(UINT16 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode); | |
| 173 | inline void scanline_draw_opaque_rgb32(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode); | |
| 174 | inline void scanline_draw_masked_rgb32(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode); | |
| 175 | inline void scanline_draw_opaque_rgb32_alpha(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha); | |
| 176 | inline void scanline_draw_masked_rgb32_alpha(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha); | |
| 177 | ||
| 178 | ||
| 179 | ||
| 180 | /*************************************************************************** | |
| 181 | INLINE FUNCTIONS | |
| 182 | ***************************************************************************/ | |
| 183 | ||
| 184 | /*------------------------------------------------- | |
| 185 | effective_rowscroll - return the effective | |
| 186 | rowscroll value for a given index, taking into | |
| 187 | account tilemap flip states | |
| 188 | -------------------------------------------------*/ | |
| 189 | ||
| 190 | INLINE INT32 effective_rowscroll(tilemap_t *tmap, int index, UINT32 screen_width) | |
| 191 | { | |
| 60 | // adjust final result based on the horizontal flip and dx values | |
| 192 | 61 | INT32 value; |
| 193 | ||
| 194 | /* if we're flipping vertically, adjust the row number */ | |
| 195 | if (tmap->attributes & TILEMAP_FLIPY) | |
| 196 | index = tmap->scrollrows - 1 - index; | |
| 197 | ||
| 198 | /* adjust final result based on the horizontal flip and dx values */ | |
| 199 | if (!(tmap->attributes & TILEMAP_FLIPX)) | |
| 200 | value = tmap->dx - tmap->rowscroll[index]; | |
| 62 | if (!(m_attributes & TILEMAP_FLIPX)) | |
| 63 | value = m_dx - m_rowscroll[index]; | |
| 201 | 64 | else |
| 202 | value = screen_width - | |
| 65 | value = screen_width - | |
| 203 | 66 | |
| 204 | / | |
| 67 | // clamp to 0..width | |
| 205 | 68 | if (value < 0) |
| 206 | value = | |
| 69 | value = | |
| 207 | 70 | else |
| 208 | value %= | |
| 71 | value %= | |
| 209 | 72 | return value; |
| 210 | 73 | } |
| 211 | 74 | |
| 212 | 75 | |
| 213 | /*------------------------------------------------- | |
| 214 | effective_colscroll - return the effective | |
| 215 | colscroll value for a given index, taking into | |
| 216 | account tilemap flip states | |
| 217 | -------------------------------------------------*/ | |
| 76 | //------------------------------------------------- | |
| 77 | // effective_colscroll - return the effective | |
| 78 | // colscroll value for a given index, taking into | |
| 79 | // account tilemap flip states | |
| 80 | //------------------------------------------------- | |
| 218 | 81 | |
| 219 | ||
| 82 | inline INT32 tilemap_t::effective_colscroll( | |
| 220 | 83 | { |
| 221 | INT32 value; | |
| 84 | // if we're flipping horizontally, adjust the column number | |
| 85 | if (m_attributes & TILEMAP_FLIPX) | |
| 86 | index = m_scrollcols - 1 - index; | |
| 222 | 87 | |
| 223 | /* if we're flipping horizontally, adjust the column number */ | |
| 224 | if (tmap->attributes & TILEMAP_FLIPX) | |
| 225 | index = tmap->scrollcols - 1 - index; | |
| 226 | ||
| 227 | /* adjust final result based on the vertical flip and dx values */ | |
| 228 | if (!(tmap->attributes & TILEMAP_FLIPY)) | |
| 229 | value = tmap->dy - tmap->colscroll[index]; | |
| 88 | // adjust final result based on the vertical flip and dx values | |
| 89 | INT32 value; | |
| 90 | if (!(m_attributes & TILEMAP_FLIPY)) | |
| 91 | value = m_dy - m_colscroll[index]; | |
| 230 | 92 | else |
| 231 | value = screen_height - | |
| 93 | value = screen_height - | |
| 232 | 94 | |
| 233 | / | |
| 95 | // clamp to 0..height | |
| 234 | 96 | if (value < 0) |
| 235 | value = | |
| 97 | value = | |
| 236 | 98 | else |
| 237 | value %= | |
| 99 | value %= | |
| 238 | 100 | return value; |
| 239 | 101 | } |
| 240 | 102 | |
| 241 | 103 | |
| 242 | /*------------------------------------------------- | |
| 243 | indexed_tilemap - return a tilemap by index | |
| 244 | -------------------------------------------------*/ | |
| 104 | //------------------------------------------------- | |
| 105 | // gfx_tiles_changed - return TRUE if any | |
| 106 | // gfx_elements used by this tilemap have | |
| 107 | // changed | |
| 108 | //------------------------------------------------- | |
| 245 | 109 | |
| 246 | ||
| 110 | inline bool tilemap_t::gf | |
| 247 | 111 | { |
| 248 | tilemap_t *tmap; | |
| 112 | UINT32 usedmask = m_gfx_used; | |
| 113 | bool isdirty = false; | |
| 249 | 114 | |
| 250 | /* find by the tilemap index */ | |
| 251 | for (tmap = machine.tilemap_data->list; tmap != NULL; tmap = tmap->next) | |
| 252 | if (index-- == 0) | |
| 253 | return tmap; | |
| 254 | ||
| 255 | return NULL; | |
| 256 | } | |
| 257 | ||
| 258 | ||
| 259 | /*------------------------------------------------- | |
| 260 | gfx_tiles_changed - return TRUE if any | |
| 261 | gfx_elements used by this tilemap have | |
| 262 | changed | |
| 263 | -------------------------------------------------*/ | |
| 264 | ||
| 265 | INLINE int gfx_elements_changed(tilemap_t *tmap) | |
| 266 | { | |
| 267 | UINT32 usedmask = tmap->gfx_used; | |
| 268 | int isdirty = FALSE; | |
| 269 | int gfxnum; | |
| 270 | ||
| 271 | /* iterate over all used gfx types and set the dirty flag if any of them have changed */ | |
| 272 | for (gfxnum = 0; usedmask != 0; usedmask >>= 1, gfxnum++) | |
| 115 | // iterate over all used gfx types and set the dirty flag if any of them have changed | |
| 116 | for (int gfxnum = 0; usedmask != 0; usedmask >>= 1, gfxnum++) | |
| 273 | 117 | if ((usedmask & 1) != 0) |
| 274 | if ( | |
| 118 | if ( | |
| 275 | 119 | { |
| 276 | tmap->gfx_dirtyseq[gfxnum] = tmap->machine().gfx[gfxnum]->dirtyseq; | |
| 277 | isdirty = TRUE; | |
| 120 | m_gfx_dirtyseq[gfxnum] = machine().gfx[gfxnum]->dirtyseq; | |
| 121 | isdirty = true; | |
| 278 | 122 | } |
| 279 | 123 | |
| 280 | 124 | return isdirty; |
| 281 | 125 | } |
| 282 | 126 | |
| 283 | 127 | |
| 284 | /*************************************************************************** | |
| 285 | SYSTEM-WIDE MANAGEMENT | |
| 286 | ***************************************************************************/ | |
| 128 | //************************************************************************** | |
| 129 | // SCANLINE RASTERIZERS | |
| 130 | //************************************************************************** | |
| 287 | 131 | |
| 288 | /*------------------------------------------------- | |
| 289 | tilemap_init - initialize the tilemap system | |
| 290 | -------------------------------------------------*/ | |
| 132 | //------------------------------------------------- | |
| 133 | // scanline_draw_opaque_null - draw to a NULL | |
| 134 | // bitmap, setting priority only | |
| 135 | //------------------------------------------------- | |
| 291 | 136 | |
| 292 | void tilemap_ | |
| 137 | inline void tilemap_ | |
| 293 | 138 | { |
| 294 | if (machine.primary_screen == NULL || machine.primary_screen->width() == 0) | |
| 139 | // skip entirely if not changing priority | |
| 140 | if (pcode == 0xff00) | |
| 295 | 141 | return; |
| 296 | 142 | |
| 297 | machine.primary_screen->register_screen_bitmap(machine.priority_bitmap); | |
| 298 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(tilemap_exit), &machine)); | |
| 143 | // update priority across the scanline | |
| 144 | for (int i = 0; i < count; i++) | |
| 145 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 299 | 146 | } |
| 300 | 147 | |
| 301 | 148 | |
| 149 | //------------------------------------------------- | |
| 150 | // scanline_draw_masked_null - draw to a NULL | |
| 151 | // bitmap using a mask, setting priority only | |
| 152 | //------------------------------------------------- | |
| 302 | 153 | |
| 303 | /*************************************************************************** | |
| 304 | TILEMAP CREATION AND CONFIGURATION | |
| 305 | ***************************************************************************/ | |
| 306 | ||
| 307 | /*------------------------------------------------- | |
| 308 | tilemap_create - create a new tilemap | |
| 309 | -------------------------------------------------*/ | |
| 310 | ||
| 311 | tilemap_t *tilemap_create(running_machine &machine, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows) | |
| 154 | inline void tilemap_t::scanline_draw_masked_null(const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode) | |
| 312 | 155 | { |
| 313 | return tilemap_create_common(machine, (void *)&machine, tile_get_info, mapper, tilewidth, tileheight, cols, rows); | |
| 156 | // skip entirely if not changing priority | |
| 157 | if (pcode == 0xff00) | |
| 158 | return; | |
| 159 | ||
| 160 | // update priority across the scanline, checking the mask | |
| 161 | for (int i = 0; i < count; i++) | |
| 162 | if ((maskptr[i] & mask) == value) | |
| 163 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 314 | 164 | } |
| 315 | 165 | |
| 316 | 166 | |
| 317 | /*------------------------------------------------- | |
| 318 | tilemap_create - create a new tilemap that | |
| 319 | is owned by a device | |
| 320 | -------------------------------------------------*/ | |
| 321 | 167 | |
| 322 | tilemap_t *tilemap_create_device(device_t *device, tile_get_info_device_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows) | |
| 168 | //------------------------------------------------- | |
| 169 | // scanline_draw_opaque_ind16 - draw to a 16bpp | |
| 170 | // indexed bitmap | |
| 171 | //------------------------------------------------- | |
| 172 | ||
| 173 | inline void tilemap_t::scanline_draw_opaque_ind16(UINT16 *dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode) | |
| 323 | 174 | { |
| 324 | return tilemap_create_common(device->machine(), (void *)device, (tile_get_info_func)tile_get_info, mapper, tilewidth, tileheight, cols, rows); | |
| 325 | } | |
| 175 | // special case for no palette offset | |
| 176 | int pal = pcode >> 16; | |
| 177 | if (pal == 0) | |
| 178 | { | |
| 179 | // use memcpy which should be well-optimized for the platform | |
| 180 | memcpy(dest, source, count * 2); | |
| 326 | 181 | |
| 182 | // skip the rest if not changing priority | |
| 183 | if (pcode == 0xff00) | |
| 184 | return; | |
| 327 | 185 | |
| 328 | /*------------------------------------------------- | |
| 329 | tilemap_create_common - shared creation | |
| 330 | function | |
| 331 | -------------------------------------------------*/ | |
| 186 | // update priority across the scanline | |
| 187 | for (int i = 0; i < count; i++) | |
| 188 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 189 | } | |
| 332 | 190 | |
| 333 | static tilemap_t *tilemap_create_common(running_machine &machine, void *get_info_object, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows) | |
| 334 | { | |
| 335 | tilemap_t *tmap; | |
| 336 | int tilemap_instance; | |
| 337 | int group; | |
| 338 | ||
| 339 | /* if no tilemap private data yet, allocate it */ | |
| 340 | if (machine.tilemap_data == NULL) | |
| 191 | // priority case | |
| 192 | else if ((pcode & 0xffff) != 0xff00) | |
| 341 | 193 | { |
| 342 | machine.tilemap_data = auto_alloc_clear(machine, tilemap_private); | |
| 343 | machine.tilemap_data->tailptr = &machine.tilemap_data->list; | |
| 194 | for (int i = 0; i < count; i++) | |
| 195 | { | |
| 196 | dest[i] = source[i] + pal; | |
| 197 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 198 | } | |
| 344 | 199 | } |
| 345 | tilemap_instance = machine.tilemap_data->instance; | |
| 346 | 200 | |
| 347 | /* allocate the tilemap itself */ | |
| 348 | tmap = auto_alloc_clear(machine, tilemap_t(machine)); | |
| 349 | ||
| 350 | /* fill in the basic metrics */ | |
| 351 | tmap->rows = rows; | |
| 352 | tmap->cols = cols; | |
| 353 | tmap->tilewidth = tilewidth; | |
| 354 | tmap->tileheight = tileheight; | |
| 355 | tmap->width = cols * tilewidth; | |
| 356 | tmap->height = rows * tileheight; | |
| 357 | ||
| 358 | /* set up the logical <-> memory mappings */ | |
| 359 | tmap->mapper = mapper; | |
| 360 | mappings_create(tmap); | |
| 361 | ||
| 362 | /* set up the tile map callbacks */ | |
| 363 | tmap->tile_get_info = tile_get_info; | |
| 364 | tmap->tile_get_info_object = get_info_object; | |
| 365 | ||
| 366 | /* set up the default pen mask */ | |
| 367 | tmap->tileinfo.pen_mask = 0xff; | |
| 368 | tmap->tileinfo.gfxnum = 0xff; | |
| 369 | ||
| 370 | /* initialize global states */ | |
| 371 | tmap->enable = TRUE; | |
| 372 | tmap->all_tiles_dirty = TRUE; | |
| 373 | ||
| 374 | /* initialize scroll information */ | |
| 375 | tmap->scrollrows = 1; | |
| 376 | tmap->scrollcols = 1; | |
| 377 | tmap->rowscroll = auto_alloc_array_clear(machine, INT32, tmap->height); | |
| 378 | tmap->colscroll = auto_alloc_array_clear(machine, INT32, tmap->width); | |
| 379 | ||
| 380 | /* allocate the pixel data cache */ | |
| 381 | tmap->pixmap.allocate(tmap->width, tmap->height); | |
| 382 | ||
| 383 | /* allocate transparency mapping data */ | |
| 384 | tmap->tileflags = auto_alloc_array(machine, UINT8, tmap->max_logical_index); | |
| 385 | tmap->flagsmap.allocate(tmap->width, tmap->height); | |
| 386 | tmap->pen_to_flags = auto_alloc_array_clear(machine, UINT8, MAX_PEN_TO_FLAGS * TILEMAP_NUM_GROUPS); | |
| 387 | for (group = 0; group < TILEMAP_NUM_GROUPS; group++) | |
| 388 | tilemap_map_pens_to_layer(tmap, group, 0, 0, TILEMAP_PIXEL_LAYER0); | |
| 389 | ||
| 390 | /* add us to the end of the list of tilemaps */ | |
| 391 | *machine.tilemap_data->tailptr = tmap; | |
| 392 | machine.tilemap_data->tailptr = &tmap->next; | |
| 393 | ||
| 394 | /* save relevant state */ | |
| 395 | machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->enable)); | |
| 396 | machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->attributes)); | |
| 397 | machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->palette_offset)); | |
| 398 | machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->pen_data_offset)); | |
| 399 | machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->scrollrows)); | |
| 400 | machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->scrollcols)); | |
| 401 | machine.save().save_pointer("tilemap", NULL, tilemap_instance, NAME(tmap->rowscroll), rows * tileheight); | |
| 402 | machine.save().save_pointer("tilemap", NULL, tilemap_instance, NAME(tmap->colscroll), cols * tilewidth); | |
| 403 | machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->dx)); | |
| 404 | machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->dx_flipped)); | |
| 405 | machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->dy)); | |
| 406 | machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->dy_flipped)); | |
| 407 | machine.tilemap_data->instance++; | |
| 408 | ||
| 409 | /* reset everything after a load */ | |
| 410 | machine.save().register_postload(save_prepost_delegate(FUNC(tilemap_postload), tmap)); | |
| 411 | return tmap; | |
| 201 | // no priority case | |
| 202 | else | |
| 203 | { | |
| 204 | for (int i = 0; i < count; i++) | |
| 205 | dest[i] = source[i] + pal; | |
| 206 | } | |
| 412 | 207 | } |
| 413 | 208 | |
| 414 | 209 | |
| 415 | /*------------------------------------------------- | |
| 416 | tilemap_set_user_data - specify a parameter | |
| 417 | to be passed into the tile_get_info callback | |
| 418 | -------------------------------------------------*/ | |
| 210 | //------------------------------------------------- | |
| 211 | // scanline_draw_masked_ind16 - draw to a 16bpp | |
| 212 | // indexed bitmap using a mask | |
| 213 | //------------------------------------------------- | |
| 419 | 214 | |
| 420 | void tilemap_ | |
| 215 | inline void tilemap_ | |
| 421 | 216 | { |
| 422 | tmap->user_data = user_data; | |
| 423 | } | |
| 217 | int pal = pcode >> 16; | |
| 424 | 218 | |
| 219 | // priority case | |
| 220 | if ((pcode & 0xffff) != 0xff00) | |
| 221 | { | |
| 222 | for (int i = 0; i < count; i++) | |
| 223 | if ((maskptr[i] & mask) == value) | |
| 224 | { | |
| 225 | dest[i] = source[i] + pal; | |
| 226 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 227 | } | |
| 228 | } | |
| 425 | 229 | |
| 426 | /*------------------------------------------------- | |
| 427 | tilemap_set_palette_offset - specify an offset | |
| 428 | to be added to each pixel before looking up | |
| 429 | the palette | |
| 430 | -------------------------------------------------*/ | |
| 431 | ||
| 432 | void tilemap_set_palette_offset(tilemap_t *tmap, UINT32 offset) | |
| 433 | { | |
| 434 | tmap->palette_offset = offset; | |
| 230 | // no priority case | |
| 231 | else | |
| 232 | { | |
| 233 | for (int i = 0; i < count; i++) | |
| 234 | if ((maskptr[i] & mask) == value) | |
| 235 | dest[i] = source[i] + pal; | |
| 236 | } | |
| 435 | 237 | } |
| 436 | 238 | |
| 437 | 239 | |
| 438 | /*------------------------------------------------- | |
| 439 | tilemap_set_enable - set an enable flag for | |
| 440 | the tilemap; if 0, requests to draw the | |
| 441 | tilemap are ignored | |
| 442 | -------------------------------------------------*/ | |
| 443 | 240 | |
| 444 | void tilemap_set_enable(tilemap_t *tmap, int enable) | |
| 445 | { | |
| 446 | tmap->enable = (enable != 0); | |
| 447 | } | |
| 241 | //------------------------------------------------- | |
| 242 | // scanline_draw_opaque_rgb32 - draw to a 32bpp | |
| 243 | // RGB bitmap | |
| 244 | //------------------------------------------------- | |
| 448 | 245 | |
| 449 | /*------------------------------------------------- | |
| 450 | tilemap_get_scrolldx - return the enable flag | |
| 451 | for the tilemap | |
| 452 | -------------------------------------------------*/ | |
| 453 | ||
| 454 | int tilemap_get_enable(tilemap_t *tmap) | |
| 246 | inline void tilemap_t::scanline_draw_opaque_rgb32(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode) | |
| 455 | 247 | { |
| 456 | return tmap->enable; | |
| 457 | } | |
| 248 | const pen_t *clut = &pens[pcode >> 16]; | |
| 458 | 249 | |
| 250 | // priority case | |
| 251 | if ((pcode & 0xffff) != 0xff00) | |
| 252 | { | |
| 253 | for (int i = 0; i < count; i++) | |
| 254 | { | |
| 255 | dest[i] = clut[source[i]]; | |
| 256 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 257 | } | |
| 258 | } | |
| 459 | 259 | |
| 460 | /*------------------------------------------------- | |
| 461 | tilemap_set_flip - set a global flip for the | |
| 462 | tilemap | |
| 463 | -------------------------------------------------*/ | |
| 464 | ||
| 465 | void tilemap_set_flip(tilemap_t *tmap, UINT32 attributes) | |
| 466 | { | |
| 467 | /* if we're changing things, force a refresh of the mappings and mark it all dirty */ | |
| 468 | if (tmap->attributes != attributes) | |
| 260 | // no priority case | |
| 261 | else | |
| 469 | 262 | { |
| 470 | tmap->attributes = attributes; | |
| 471 | mappings_update(tmap); | |
| 263 | for (int i = 0; i < count; i++) | |
| 264 | dest[i] = clut[source[i]]; | |
| 472 | 265 | } |
| 473 | 266 | } |
| 474 | 267 | |
| 475 | 268 | |
| 476 | /*------------------------------------------------- | |
| 477 | tilemap_set_flip_all - set a global flip for all | |
| 478 | the tilemaps | |
| 479 | -------------------------------------------------*/ | |
| 269 | //------------------------------------------------- | |
| 270 | // scanline_draw_masked_rgb32 - draw to a 32bpp | |
| 271 | // RGB bitmap using a mask | |
| 272 | //------------------------------------------------- | |
| 480 | 273 | |
| 481 | void tilemap_ | |
| 274 | inline void tilemap_ | |
| 482 | 275 | { |
| 483 | t | |
| 276 | const | |
| 484 | 277 | |
| 485 | if (machine.tilemap_data == NULL) | |
| 486 | return; | |
| 487 | ||
| 488 | for (tmap = machine.tilemap_data->list; tmap != NULL; tmap = tmap->next) | |
| 489 | tilemap_set_flip(tmap, attributes); | |
| 490 | } | |
| 491 | ||
| 492 | ||
| 493 | ||
| 494 | /*************************************************************************** | |
| 495 | DIRTY TILE MARKING | |
| 496 | ***************************************************************************/ | |
| 497 | ||
| 498 | /*------------------------------------------------- | |
| 499 | tilemap_mark_tile_dirty - mark a single tile | |
| 500 | dirty based on its memory index | |
| 501 | -------------------------------------------------*/ | |
| 502 | ||
| 503 | void tilemap_mark_tile_dirty(tilemap_t *tmap, tilemap_memory_index memindex) | |
| 504 | { | |
| 505 | /* only mark if within range */ | |
| 506 | if (memindex < tmap->max_memory_index) | |
| 278 | // priority case | |
| 279 | if ((pcode & 0xffff) != 0xff00) | |
| 507 | 280 | { |
| 508 | tilemap_logical_index logindex = tmap->memory_to_logical[memindex]; | |
| 281 | for (int i = 0; i < count; i++) | |
| 282 | if ((maskptr[i] & mask) == value) | |
| 283 | { | |
| 284 | dest[i] = clut[source[i]]; | |
| 285 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 286 | } | |
| 287 | } | |
| 509 | 288 | |
| 510 | /* there may be no logical index for a given memory index */ | |
| 511 | if (logindex != INVALID_LOGICAL_INDEX) | |
| 512 | { | |
| 513 | tmap->tileflags[logindex] = TILE_FLAG_DIRTY; | |
| 514 | tmap->all_tiles_clean = FALSE; | |
| 515 | } | |
| 289 | // no priority case | |
| 290 | else | |
| 291 | { | |
| 292 | for (int i = 0; i < count; i++) | |
| 293 | if ((maskptr[i] & mask) == value) | |
| 294 | dest[i] = clut[source[i]]; | |
| 516 | 295 | } |
| 517 | 296 | } |
| 518 | 297 | |
| 519 | 298 | |
| 520 | /*------------------------------------------------- | |
| 521 | tilemap_mark_all_tiles_dirty - mark all the | |
| 522 | tiles in a tilemap dirty | |
| 523 | -------------------------------------------------*/ | |
| 299 | //------------------------------------------------- | |
| 300 | // scanline_draw_opaque_rgb32_alpha - draw to a | |
| 301 | // 32bpp RGB bitmap with alpha blending | |
| 302 | //------------------------------------------------- | |
| 524 | 303 | |
| 525 | void tilemap_ | |
| 304 | inline void tilemap_t::scanline_draw_opaque_rgb32_alpha(UINT32 *des | |
| 526 | 305 | { |
| 527 | /* mark all tiles dirty and clear the clean flag */ | |
| 528 | tmap->all_tiles_dirty = TRUE; | |
| 529 | tmap->all_tiles_clean = FALSE; | |
| 530 | } | |
| 306 | const pen_t *clut = &pens[pcode >> 16]; | |
| 531 | 307 | |
| 532 | ||
| 533 | /*------------------------------------------------- | |
| 534 | tilemap_mark_all_tiles_dirty_all - mark all the | |
| 535 | tiles in all the tilemaps dirty | |
| 536 | -------------------------------------------------*/ | |
| 537 | ||
| 538 | void tilemap_mark_all_tiles_dirty_all(running_machine &machine) | |
| 539 | { | |
| 540 | tilemap_t *tmap; | |
| 541 | for (tmap = machine.tilemap_data->list; tmap != NULL; tmap = tmap->next) | |
| 542 | tilemap_mark_all_tiles_dirty(tmap); | |
| 543 | } | |
| 544 | ||
| 545 | ||
| 546 | /*************************************************************************** | |
| 547 | PEN-TO-LAYER MAPPING | |
| 548 | ***************************************************************************/ | |
| 549 | ||
| 550 | /*------------------------------------------------- | |
| 551 | tilemap_map_pens_to_layer - specify the | |
| 552 | mapping of one or more pens (where | |
| 553 | (<pen> & mask) == pen) to a layer | |
| 554 | -------------------------------------------------*/ | |
| 555 | ||
| 556 | void tilemap_map_pens_to_layer(tilemap_t *tmap, int group, pen_t pen, pen_t mask, UINT8 layermask) | |
| 557 | { | |
| 558 | UINT8 *array = tmap->pen_to_flags + group * MAX_PEN_TO_FLAGS; | |
| 559 | pen_t start, stop, cur; | |
| 560 | UINT8 changed = FALSE; | |
| 561 | ||
| 562 | assert(group < TILEMAP_NUM_GROUPS); | |
| 563 | assert((layermask & TILEMAP_PIXEL_CATEGORY_MASK) == 0); | |
| 564 | ||
| 565 | /* we start at the index where (pen & mask) == pen, and all other bits are 0 */ | |
| 566 | start = pen & mask; | |
| 567 | ||
| 568 | /* we stop at the index where (pen & mask) == pen, and all other bits are 1 */ | |
| 569 | stop = start | ~mask; | |
| 570 | ||
| 571 | /* clamp to the number of entries actually there */ | |
| 572 | stop = MIN(stop, MAX_PEN_TO_FLAGS - 1); | |
| 573 | ||
| 574 | /* iterate and set */ | |
| 575 | for (cur = start; cur <= stop; cur++) | |
| 576 | if ((cur & mask) == pen && array[cur] != layermask) | |
| 308 | // priority case | |
| 309 | if ((pcode & 0xffff) != 0xff00) | |
| 310 | { | |
| 311 | for (int i = 0; i < count; i++) | |
| 577 | 312 | { |
| 578 | changed = TRUE; | |
| 579 | array[cur] = layermask; | |
| 313 | dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha); | |
| 314 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 580 | 315 | } |
| 316 | } | |
| 581 | 317 | |
| 582 | /* everything gets dirty if anything changed */ | |
| 583 | if (changed) | |
| 584 | tilemap_mark_all_tiles_dirty(tmap); | |
| 318 | // no priority case | |
| 319 | else | |
| 320 | { | |
| 321 | for (int i = 0; i < count; i++) | |
| 322 | dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha); | |
| 323 | } | |
| 585 | 324 | } |
| 586 | 325 | |
| 587 | 326 | |
| 588 | /*------------------------------------------------- | |
| 589 | tilemap_set_transparent_pen - set a single | |
| 590 | transparent pen into the tilemap, mapping | |
| 591 | all other pens to layer 0 | |
| 592 | -------------------------------------------------*/ | |
| 327 | //------------------------------------------------- | |
| 328 | // scanline_draw_masked_rgb32_alpha - draw to a | |
| 329 | // 32bpp RGB bitmap using a mask and alpha | |
| 330 | // blending | |
| 331 | //------------------------------------------------- | |
| 593 | 332 | |
| 594 | void tilemap_se | |
| 333 | inline void tilemap_t::scanline | |
| 595 | 334 | { |
| 596 | /* reset the whole pen map to opaque */ | |
| 597 | tilemap_map_pens_to_layer(tmap, 0, 0, 0, TILEMAP_PIXEL_LAYER0); | |
| 335 | const pen_t *clut = &pens[pcode >> 16]; | |
| 598 | 336 | |
| 599 | /* set the single pen to transparent */ | |
| 600 | tilemap_map_pen_to_layer(tmap, 0, pen, TILEMAP_PIXEL_TRANSPARENT); | |
| 601 | } | |
| 337 | // priority case | |
| 338 | if ((pcode & 0xffff) != 0xff00) | |
| 339 | { | |
| 340 | for (int i = 0; i < count; i++) | |
| 341 | if ((maskptr[i] & mask) == value) | |
| 342 | { | |
| 343 | dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha); | |
| 344 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 345 | } | |
| 346 | } | |
| 602 | 347 | |
| 603 | ||
| 604 | /*------------------------------------------------- | |
| 605 | tilemap_set_transmask - set up the first 32 | |
| 606 | pens using a foreground mask (mapping to | |
| 607 | layer 0) and a background mask (mapping to | |
| 608 | layer 1) | |
| 609 | -------------------------------------------------*/ | |
| 610 | ||
| 611 | void tilemap_set_transmask(tilemap_t *tmap, int group, UINT32 fgmask, UINT32 bgmask) | |
| 612 | { | |
| 613 | pen_t pen; | |
| 614 | ||
| 615 | /* iterate over all 32 pens specified */ | |
| 616 | for (pen = 0; pen < 32; pen++) | |
| 348 | // no priority case | |
| 349 | else | |
| 617 | 350 | { |
| 618 | UINT8 fgbits = ((fgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER0; | |
| 619 | UINT8 bgbits = ((bgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER1; | |
| 620 | tilemap_map_pen_to_layer(tmap, group, pen, fgbits | bgbits); | |
| 351 | for (int i = 0; i < count; i++) | |
| 352 | if ((maskptr[i] & mask) == value) | |
| 353 | dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha); | |
| 621 | 354 | } |
| 622 | 355 | } |
| 623 | 356 | |
| 624 | 357 | |
| 358 | //************************************************************************** | |
| 359 | // TILEMAP CREATION AND CONFIGURATION | |
| 360 | //************************************************************************** | |
| 625 | 361 | |
| 626 | /*************************************************************************** | |
| 627 | TILEMAP SCROLLING | |
| 628 | ***************************************************************************/ | |
| 362 | //------------------------------------------------- | |
| 363 | // tilemap_create_common - shared creation | |
| 364 | // function | |
| 365 | //------------------------------------------------- | |
| 629 | 366 | |
| 630 | /*------------------------------------------------- | |
| 631 | tilemap_set_scroll_rows - specify the number of | |
| 632 | independently scrollable row units; each unit | |
| 633 | covers height/scroll_rows pixels | |
| 634 | -------------------------------------------------*/ | |
| 635 | ||
| 636 | void tilemap_set_scroll_rows(tilemap_t *tmap, UINT32 scroll_rows) | |
| 367 | tilemap_t::tilemap_t(tilemap_manager &manager, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows) | |
| 368 | : m_next(NULL), | |
| 369 | m_rows(rows), | |
| 370 | m_cols(cols), | |
| 371 | m_tilewidth(tilewidth), | |
| 372 | m_tileheight(tileheight), | |
| 373 | m_width(cols * tilewidth), | |
| 374 | m_height(rows * tileheight), | |
| 375 | m_mapper(mapper), | |
| 376 | m_memory_to_logical(NULL), | |
| 377 | m_max_logical_index(0), | |
| 378 | m_logical_to_memory(NULL), | |
| 379 | m_max_memory_index(0), | |
| 380 | m_tile_get_info(tile_get_info), | |
| 381 | m_user_data(NULL), | |
| 382 | m_enable(true), | |
| 383 | m_attributes(0), | |
| 384 | m_all_tiles_dirty(true), | |
| 385 | m_all_tiles_clean(false), | |
| 386 | m_palette_offset(0), | |
| 387 | m_pen_data_offset(0), | |
| 388 | m_gfx_used(0), | |
| 389 | m_scrollrows(1), | |
| 390 | m_scrollcols(1), | |
| 391 | m_rowscroll(auto_alloc_array_clear(manager.machine(), INT32, m_height)), | |
| 392 | m_colscroll(auto_alloc_array_clear(manager.machine(), INT32, m_width)), | |
| 393 | m_dx(0), | |
| 394 | m_dx_flipped(0), | |
| 395 | m_dy(0), | |
| 396 | m_dy_flipped(0), | |
| 397 | m_pixmap(m_width, m_height), | |
| 398 | m_flagsmap(m_width, m_height), | |
| 399 | m_tileflags(NULL), | |
| 400 | m_manager(manager) | |
| 637 | 401 | { |
| 638 | assert(scroll_rows <= tmap->height); | |
| 639 | tmap->scrollrows = scroll_rows; | |
| 640 | } | |
| 402 | // reset internal arrays | |
| 403 | memset(m_gfx_dirtyseq, 0, sizeof(m_gfx_dirtyseq)); | |
| 404 | memset(m_pen_to_flags, 0, sizeof(m_pen_to_flags)); | |
| 641 | 405 | |
| 406 | // create the initial mappings | |
| 407 | mappings_create(); | |
| 642 | 408 | |
| 643 | /*------------------------------------------------- | |
| 644 | tilemap_set_scroll_cols - specify the number of | |
| 645 | independently scrollable column units; each | |
| 646 | unit covers width/scroll_cols pixels | |
| 647 | -------------------------------------------------*/ | |
| 409 | // set up the default pen mask | |
| 410 | memset(&m_tileinfo, 0, sizeof(m_tileinfo)); | |
| 411 | m_tileinfo.pen_mask = 0xff; | |
| 412 | m_tileinfo.gfxnum = 0xff; | |
| 648 | 413 | |
| 649 | void tilemap_set_scroll_cols(tilemap_t *tmap, UINT32 scroll_cols) | |
| 650 | { | |
| 651 | assert(scroll_cols <= tmap->width); | |
| 652 | tmap->scrollcols = scroll_cols; | |
| 653 | } | |
| 414 | // allocate transparency mapping data | |
| 415 | m_tileflags = auto_alloc_array(machine(), UINT8, m_max_logical_index); | |
| 416 | for (int group = 0; group < TILEMAP_NUM_GROUPS; group++) | |
| 417 | map_pens_to_layer(group, 0, 0, TILEMAP_PIXEL_LAYER0); | |
| 654 | 418 | |
| 419 | // save relevant state | |
| 420 | int instance = manager.alloc_instance(); | |
| 421 | machine().save().save_item("tilemap", NULL, instance, NAME(m_enable)); | |
| 422 | machine().save().save_item("tilemap", NULL, instance, NAME(m_attributes)); | |
| 423 | machine().save().save_item("tilemap", NULL, instance, NAME(m_palette_offset)); | |
| 424 | machine().save().save_item("tilemap", NULL, instance, NAME(m_pen_data_offset)); | |
| 425 | machine().save().save_item("tilemap", NULL, instance, NAME(m_scrollrows)); | |
| 426 | machine().save().save_item("tilemap", NULL, instance, NAME(m_scrollcols)); | |
| 427 | machine().save().save_pointer("tilemap", NULL, instance, NAME(m_rowscroll), rows * tileheight); | |
| 428 | machine().save().save_pointer("tilemap", NULL, instance, NAME(m_colscroll), cols * tilewidth); | |
| 429 | machine().save().save_item("tilemap", NULL, instance, NAME(m_dx)); | |
| 430 | machine().save().save_item("tilemap", NULL, instance, NAME(m_dx_flipped)); | |
| 431 | machine().save().save_item("tilemap", NULL, instance, NAME(m_dy)); | |
| 432 | machine().save().save_item("tilemap", NULL, instance, NAME(m_dy_flipped)); | |
| 655 | 433 | |
| 656 | /*------------------------------------------------- | |
| 657 | tilemap_set_scrolldx - specify global | |
| 658 | horizontal scroll offset, for non-flipped and | |
| 659 | flipped cases | |
| 660 | -------------------------------------------------*/ | |
| 661 | ||
| 662 | void tilemap_set_scrolldx(tilemap_t *tmap, int dx, int dx_flipped) | |
| 663 | { | |
| 664 | tmap->dx = dx; | |
| 665 | tmap->dx_flipped = dx_flipped; | |
| 434 | // reset everything after a load | |
| 435 | machine().save().register_postload(save_prepost_delegate(FUNC(tilemap_t::postload), this)); | |
| 666 | 436 | } |
| 667 | 437 | |
| 668 | 438 | |
| 669 | /*------------------------------------------------- | |
| 670 | tilemap_set_scrolldy - specify global | |
| 671 | vertical scroll offset, for non-flipped and | |
| 672 | flipped cases | |
| 673 | -------------------------------------------------*/ | |
| 439 | //------------------------------------------------- | |
| 440 | // ~tilemap_t - destructor | |
| 441 | //------------------------------------------------- | |
| 674 | 442 | |
| 675 | ||
| 443 | ||
| 676 | 444 | { |
| 677 | tmap->dy = dy; | |
| 678 | tmap->dy_flipped = dy_flipped; | |
| 679 | 445 | } |
| 680 | 446 | |
| 681 | 447 | |
| 682 | /*------------------------------------------------- | |
| 683 | tilemap_get_scrolldx - return the global | |
| 684 | horizontal scroll offset, based on current | |
| 685 | flip state | |
| 686 | -------------------------------------------------*/ | |
| 448 | //------------------------------------------------- | |
| 449 | // mark_tile_dirty - mark a single tile dirty | |
| 450 | // based on its memory index | |
| 451 | //------------------------------------------------- | |
| 687 | 452 | |
| 688 | i | |
| 453 | void | |
| 689 | 454 | { |
| 690 | return (tmap->attributes & TILEMAP_FLIPX) ? tmap->dx_flipped : tmap->dx; | |
| 691 | } | |
| 692 | ||
| 693 | ||
| 694 | /*------------------------------------------------- | |
| 695 | tilemap_get_scrolldy - return the global | |
| 696 | vertical scroll offset, based on current | |
| 697 | flip state | |
| 698 | -------------------------------------------------*/ | |
| 699 | ||
| 700 | int tilemap_get_scrolldy(tilemap_t *tmap) | |
| 701 | { | |
| 702 | return (tmap->attributes & TILEMAP_FLIPY) ? tmap->dy_flipped : tmap->dy; | |
| 703 | } | |
| 704 | ||
| 705 | ||
| 706 | /*------------------------------------------------- | |
| 707 | tilemap_set_scrollx - specify the scroll value | |
| 708 | for a row unit | |
| 709 | -------------------------------------------------*/ | |
| 710 | ||
| 711 | void tilemap_set_scrollx(tilemap_t *tmap, int which, int value) | |
| 712 | { | |
| 713 | if (which < tmap->scrollrows) | |
| 714 | tmap->rowscroll[which] = value; | |
| 715 | } | |
| 716 | ||
| 717 | ||
| 718 | /*------------------------------------------------- | |
| 719 | tilemap_set_scrolly - specify the scroll value | |
| 720 | for a column unit | |
| 721 | -------------------------------------------------*/ | |
| 722 | ||
| 723 | void tilemap_set_scrolly(tilemap_t *tmap, int which, int value) | |
| 724 | { | |
| 725 | if (which < tmap->scrollcols) | |
| 726 | tmap->colscroll[which] = value; | |
| 727 | } | |
| 728 | ||
| 729 | ||
| 730 | /*------------------------------------------------- | |
| 731 | tilemap_get_scrollx - return the scroll value | |
| 732 | for a row unit | |
| 733 | -------------------------------------------------*/ | |
| 734 | ||
| 735 | int tilemap_get_scrollx(tilemap_t *tmap, int which) | |
| 736 | { | |
| 737 | if (which < tmap->scrollrows) | |
| 738 | return tmap->rowscroll[which]; | |
| 739 | else | |
| 740 | return 0; | |
| 741 | } | |
| 742 | ||
| 743 | ||
| 744 | /*------------------------------------------------- | |
| 745 | tilemap_get_scrolly - return the scroll value | |
| 746 | for a column unit | |
| 747 | -------------------------------------------------*/ | |
| 748 | ||
| 749 | int tilemap_get_scrolly(tilemap_t *tmap, int which) | |
| 750 | { | |
| 751 | if (which < tmap->scrollcols) | |
| 752 | return tmap->colscroll[which]; | |
| 753 | else | |
| 754 | return 0; | |
| 755 | } | |
| 756 | ||
| 757 | ||
| 758 | ||
| 759 | /*************************************************************************** | |
| 760 | INTERNAL MAP ACCESS | |
| 761 | ***************************************************************************/ | |
| 762 | ||
| 763 | /*------------------------------------------------- | |
| 764 | tilemap_get_pixmap - return a pointer to the | |
| 765 | (updated) internal pixmap for a tilemap | |
| 766 | -------------------------------------------------*/ | |
| 767 | ||
| 768 | bitmap_ind16 &tilemap_get_pixmap(tilemap_t *tmap) | |
| 769 | { | |
| 770 | /* ensure all the tiles are up-to-date and then return the pixmap */ | |
| 771 | pixmap_update(tmap); | |
| 772 | return tmap->pixmap; | |
| 773 | } | |
| 774 | ||
| 775 | ||
| 776 | /*------------------------------------------------- | |
| 777 | tilemap_get_flagsmap - return a pointer to the | |
| 778 | (updated) internal flagsmap for a tilemap | |
| 779 | -------------------------------------------------*/ | |
| 780 | ||
| 781 | bitmap_ind8 &tilemap_get_flagsmap(tilemap_t *tmap) | |
| 782 | { | |
| 783 | /* ensure all the tiles are up-to-date and then return the flagsmap */ | |
| 784 | pixmap_update(tmap); | |
| 785 | return tmap->flagsmap; | |
| 786 | } | |
| 787 | ||
| 788 | ||
| 789 | /*------------------------------------------------- | |
| 790 | tilemap_get_pixmap - return a pointer to the | |
| 791 | (updated) internal per-tile flags for a tilemap | |
| 792 | -------------------------------------------------*/ | |
| 793 | ||
| 794 | UINT8 *tilemap_get_tile_flags(tilemap_t *tmap) | |
| 795 | { | |
| 796 | /* ensure all the tiles are up-to-date and then return the per-tile flags */ | |
| 797 | pixmap_update(tmap); | |
| 798 | return tmap->tileflags; | |
| 799 | } | |
| 800 | ||
| 801 | ||
| 802 | ||
| 803 | /*************************************************************************** | |
| 804 | TILEMAP RENDERING | |
| 805 | ***************************************************************************/ | |
| 806 | ||
| 807 | /*------------------------------------------------- | |
| 808 | tilemap_draw_primask - draw a tilemap to the | |
| 809 | destination with clipping; pixels apply | |
| 810 | priority/priority_mask to the priority bitmap | |
| 811 | -------------------------------------------------*/ | |
| 812 | ||
| 813 | template<class _BitmapClass> | |
| 814 | void tilemap_draw_primask_common(_BitmapClass &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 815 | { | |
| 816 | UINT32 width, height; | |
| 817 | blit_parameters blit; | |
| 818 | int xpos, ypos; | |
| 819 | ||
| 820 | /* skip if disabled */ | |
| 821 | if (!tmap->enable) | |
| 822 | return; | |
| 823 | ||
| 824 | g_profiler.start(PROFILER_TILEMAP_DRAW); | |
| 825 | /* configure the blit parameters based on the input parameters */ | |
| 826 | configure_blit_parameters(&blit, tmap, dest.format(), cliprect, flags, priority, priority_mask); | |
| 827 | ||
| 828 | /* if the whole map is dirty, mark it as such */ | |
| 829 | if (tmap->all_tiles_dirty || gfx_elements_changed(tmap)) | |
| 455 | // only mark if within range | |
| 456 | if (memindex < m_max_memory_index) | |
| 830 | 457 | { |
| 831 | memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index); | |
| 832 | tmap->all_tiles_dirty = FALSE; | |
| 833 | tmap->gfx_used = 0; | |
| 834 | } | |
| 835 | ||
| 836 | width = tmap->machine().primary_screen->width(); | |
| 837 | height = tmap->machine().primary_screen->height(); | |
| 838 | ||
| 839 | /* XY scrolling playfield */ | |
| 840 | if (tmap->scrollrows == 1 && tmap->scrollcols == 1) | |
| 841 | { | |
| 842 | int scrollx = effective_rowscroll(tmap, 0, width); | |
| 843 | int scrolly = effective_colscroll(tmap, 0, height); | |
| 844 | ||
| 845 | /* iterate to handle wraparound */ | |
| 846 | for (ypos = scrolly - tmap->height; ypos <= blit.cliprect.max_y; ypos += tmap->height) | |
| 847 | for (xpos = scrollx - tmap->width; xpos <= blit.cliprect.max_x; xpos += tmap->width) | |
| 848 | tilemap_draw_instance(dest, tmap, &blit, xpos, ypos); | |
| 849 | } | |
| 850 | ||
| 851 | /* scrolling rows + vertical scroll */ | |
| 852 | else if (tmap->scrollcols == 1) | |
| 853 | { | |
| 854 | const rectangle original_cliprect = blit.cliprect; | |
| 855 | int rowheight = tmap->height / tmap->scrollrows; | |
| 856 | int scrolly = effective_colscroll(tmap, 0, height); | |
| 857 | int currow, nextrow; | |
| 858 | ||
| 859 | /* iterate over Y to handle wraparound */ | |
| 860 | for (ypos = scrolly - tmap->height; ypos <= original_cliprect.max_y; ypos += tmap->height) | |
| 458 | // there may be no logical index for a given memory index | |
| 459 | logical_index logindex = m_memory_to_logical[memindex]; | |
| 460 | if (logindex != INVALID_LOGICAL_INDEX) | |
| 861 | 461 | { |
| 862 | int const firstrow = MAX((original_cliprect.min_y - ypos) / rowheight, 0); | |
| 863 | int const lastrow = MIN((original_cliprect.max_y - ypos) / rowheight, tmap->scrollrows - 1); | |
| 864 | ||
| 865 | /* iterate over rows in the tilemap */ | |
| 866 | for (currow = firstrow; currow <= lastrow; currow = nextrow) | |
| 867 | { | |
| 868 | int scrollx = effective_rowscroll(tmap, currow, width); | |
| 869 | ||
| 870 | /* scan forward until we find a non-matching row */ | |
| 871 | for (nextrow = currow + 1; nextrow <= lastrow; nextrow++) | |
| 872 | if (effective_rowscroll(tmap, nextrow, width) != scrollx) | |
| 873 | break; | |
| 874 | ||
| 875 | /* skip if disabled */ | |
| 876 | if (scrollx == TILE_LINE_DISABLED) | |
| 877 | continue; | |
| 878 | ||
| 879 | /* update the cliprect just for this set of rows */ | |
| 880 | blit.cliprect.min_y = currow * rowheight + ypos; | |
| 881 | blit.cliprect.max_y = nextrow * rowheight - 1 + ypos; | |
| 882 | blit.cliprect &= original_cliprect; | |
| 883 | ||
| 884 | /* iterate over X to handle wraparound */ | |
| 885 | for (xpos = scrollx - tmap->width; xpos <= original_cliprect.max_x; xpos += tmap->width) | |
| 886 | tilemap_draw_instance(dest, tmap, &blit, xpos, ypos); | |
| 887 | } | |
| 462 | m_tileflags[logindex] = TILE_FLAG_DIRTY; | |
| 463 | m_all_tiles_clean = false; | |
| 888 | 464 | } |
| 889 | 465 | } |
| 890 | ||
| 891 | /* scrolling columns + horizontal scroll */ | |
| 892 | else if (tmap->scrollrows == 1) | |
| 893 | { | |
| 894 | const rectangle original_cliprect = blit.cliprect; | |
| 895 | int colwidth = tmap->width / tmap->scrollcols; | |
| 896 | int scrollx = effective_rowscroll(tmap, 0, width); | |
| 897 | int curcol, nextcol; | |
| 898 | ||
| 899 | /* iterate over columns in the tilemap */ | |
| 900 | for (curcol = 0; curcol < tmap->scrollcols; curcol = nextcol) | |
| 901 | { | |
| 902 | int scrolly = effective_colscroll(tmap, curcol, height); | |
| 903 | ||
| 904 | /* scan forward until we find a non-matching column */ | |
| 905 | for (nextcol = curcol + 1; nextcol < tmap->scrollcols; nextcol++) | |
| 906 | if (effective_colscroll(tmap, nextcol, height) != scrolly) | |
| 907 | break; | |
| 908 | ||
| 909 | /* skip if disabled */ | |
| 910 | if (scrolly == TILE_LINE_DISABLED) | |
| 911 | continue; | |
| 912 | ||
| 913 | /* iterate over X to handle wraparound */ | |
| 914 | for (xpos = scrollx - tmap->width; xpos <= original_cliprect.max_x; xpos += tmap->width) | |
| 915 | { | |
| 916 | /* update the cliprect just for this set of columns */ | |
| 917 | blit.cliprect.min_x = curcol * colwidth + xpos; | |
| 918 | blit.cliprect.max_x = nextcol * colwidth - 1 + xpos; | |
| 919 | blit.cliprect &= original_cliprect; | |
| 920 | ||
| 921 | /* iterate over Y to handle wraparound */ | |
| 922 | for (ypos = scrolly - tmap->height; ypos <= original_cliprect.max_y; ypos += tmap->height) | |
| 923 | tilemap_draw_instance(dest, tmap, &blit, xpos, ypos); | |
| 924 | } | |
| 925 | } | |
| 926 | } | |
| 927 | g_profiler.stop(); | |
| 928 | 466 | } |
| 929 | 467 | |
| 930 | void tilemap_draw_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 931 | { tilemap_draw_primask_common(dest, cliprect, tmap, flags, priority, priority_mask); } | |
| 932 | 468 | |
| 933 | void tilemap_draw_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 934 | { tilemap_draw_primask_common(dest, cliprect, tmap, flags, priority, priority_mask); } | |
| 469 | //------------------------------------------------- | |
| 470 | // map_pens_to_layer - specify the mapping of one | |
| 471 | // or more pens (where (<pen> & mask) == pen) to | |
| 472 | // a layer | |
| 473 | //------------------------------------------------- | |
| 935 | 474 | |
| 936 | /*------------------------------------------------- | |
| 937 | tilemap_draw_primask - draw a tilemap to the | |
| 938 | destination with clipping and arbitrary | |
| 939 | rotate/zoom; pixels apply priority/ | |
| 940 | priority_mask to the priority bitmap | |
| 941 | -------------------------------------------------*/ | |
| 942 | ||
| 943 | template<class _BitmapClass> | |
| 944 | void tilemap_draw_roz_common(_BitmapClass &dest, const rectangle &cliprect, tilemap_t *tmap, | |
| 945 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, | |
| 946 | int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 475 | void tilemap_t::map_pens_to_layer(int group, pen_t pen, pen_t mask, UINT8 layermask) | |
| 947 | 476 | { |
| 948 | blit_parameters blit; | |
| 477 | assert(group < TILEMAP_NUM_GROUPS); | |
| 478 | assert((layermask & TILEMAP_PIXEL_CATEGORY_MASK) == 0); | |
| 949 | 479 | |
| 950 | /* notes: | |
| 951 | - startx and starty MUST be UINT32 for calculations to work correctly | |
| 952 | - srcbitmap->width and height are assumed to be a power of 2 to speed up wraparound | |
| 953 | */ | |
| 480 | // we start at the index where (pen & mask) == pen, and all other bits are 0 | |
| 481 | pen_t start = pen & mask; | |
| 954 | 482 | |
| 955 | /* skip if disabled */ | |
| 956 | if (!tmap->enable) | |
| 957 | return; | |
| 483 | // we stop at the index where (pen & mask) == pen, and all other bits are 1 | |
| 484 | pen_t stop = start | ~mask; | |
| 958 | 485 | |
| 959 | /* see if this is just a regular render and if so, do a regular render */ | |
| 960 | if (incxx == (1 << 16) && incxy == 0 && incyx == 0 && incyy == (1 << 16) && wraparound) | |
| 961 | { | |
| 962 | tilemap_set_scrollx(tmap, 0, startx >> 16); | |
| 963 | tilemap_set_scrolly(tmap, 0, starty >> 16); | |
| 964 | tilemap_draw(dest, cliprect, tmap, flags, priority); | |
| 965 | return; | |
| 966 | } | |
| 486 | // clamp to the number of entries actually there | |
| 487 | stop = MIN(stop, MAX_PEN_TO_FLAGS - 1); | |
| 967 | 488 | |
| 968 | g_profiler.start(PROFILER_TILEMAP_DRAW_ROZ); | |
| 969 | /* configure the blit parameters */ | |
| 970 | configure_blit_parameters(&blit, tmap, dest.format(), cliprect, flags, priority, priority_mask); | |
| 489 | // iterate and set | |
| 490 | UINT8 *array = m_pen_to_flags + group * MAX_PEN_TO_FLAGS; | |
| 491 | bool changed = false; | |
| 492 | for (pen_t cur = start; cur <= stop; cur++) | |
| 493 | if ((cur & mask) == pen && array[cur] != layermask) | |
| 494 | { | |
| 495 | changed = true; | |
| 496 | array[cur] = layermask; | |
| 497 | } | |
| 971 | 498 | |
| 972 | /* get the full pixmap for the tilemap */ | |
| 973 | tilemap_get_pixmap(tmap); | |
| 974 | ||
| 975 | /* then do the roz copy */ | |
| 976 | tilemap_draw_roz_core(dest, tmap, &blit, startx, starty, incxx, incxy, incyx, incyy, wraparound); | |
| 977 | g_profiler.stop(); | |
| 499 | // everything gets dirty if anything changed | |
| 500 | if (changed) | |
| 501 | mark_all_dirty(); | |
| 978 | 502 | } |
| 979 | 503 | |
| 980 | void tilemap_draw_roz_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap, | |
| 981 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, | |
| 982 | int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 983 | { tilemap_draw_roz_common(dest, cliprect, tmap, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); } | |
| 984 | 504 | |
| 985 | void tilemap_draw_roz_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, | |
| 986 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, | |
| 987 | int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 988 | { tilemap_draw_roz_common(dest, cliprect, tmap, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); } | |
| 505 | //------------------------------------------------- | |
| 506 | // set_transparent_pen - set a single transparent | |
| 507 | // pen into the tilemap, mapping all other pens | |
| 508 | // to layer 0 | |
| 509 | //------------------------------------------------- | |
| 989 | 510 | |
| 990 | ||
| 991 | /*************************************************************************** | |
| 992 | INDEXED TILEMAP HANDLING | |
| 993 | ***************************************************************************/ | |
| 994 | ||
| 995 | /*------------------------------------------------- | |
| 996 | tilemap_count - return the number of tilemaps | |
| 997 | -------------------------------------------------*/ | |
| 998 | ||
| 999 | int tilemap_count(running_machine &machine) | |
| 511 | void tilemap_t::set_transparent_pen(pen_t pen) | |
| 1000 | 512 | { |
| 1001 | tilemap_t *tmap; | |
| 1002 | int count = 0; | |
| 513 | // reset the whole pen map to opaque | |
| 514 | map_pens_to_layer(0, 0, 0, TILEMAP_PIXEL_LAYER0); | |
| 1003 | 515 | |
| 1004 | if (machine.tilemap_data == NULL) | |
| 1005 | return 0; | |
| 1006 | ||
| 1007 | /* find by the tilemap index */ | |
| 1008 | for (tmap = machine.tilemap_data->list; tmap != NULL; tmap = tmap->next) | |
| 1009 | count++; | |
| 1010 | return count; | |
| 516 | // set the single pen to transparent | |
| 517 | map_pen_to_layer(0, pen, TILEMAP_PIXEL_TRANSPARENT); | |
| 1011 | 518 | } |
| 1012 | 519 | |
| 1013 | 520 | |
| 1014 | /*------------------------------------------------- | |
| 1015 | tilemap_size_by_index - return the size of an | |
| 1016 | indexed tilemap | |
| 1017 | -------------------------------------------------*/ | |
| 521 | //------------------------------------------------- | |
| 522 | // set_transmask - set up the first 32 pens using | |
| 523 | // a foreground mask (mapping to layer 0) and a | |
| 524 | // background mask (mapping to layer 1) | |
| 525 | //------------------------------------------------- | |
| 1018 | 526 | |
| 1019 | void tilemap_s | |
| 527 | void tilemap_t::s | |
| 1020 | 528 | { |
| 1021 | tilemap_t *tmap = indexed_tilemap(machine, number); | |
| 1022 | *width = tmap->width; | |
| 1023 | *height = tmap->height; | |
| 1024 | } | |
| 1025 | ||
| 1026 | ||
| 1027 | /*------------------------------------------------- | |
| 1028 | tilemap_draw_by_index - render an indexed | |
| 1029 | tilemap with fixed characteristics (no | |
| 1030 | priority) | |
| 1031 | -------------------------------------------------*/ | |
| 1032 | ||
| 1033 | void tilemap_draw_by_index(running_machine &machine, bitmap_rgb32 &dest, int number, UINT32 scrollx, UINT32 scrolly) | |
| 1034 | { | |
| 1035 | tilemap_t *tmap = indexed_tilemap(machine, number); | |
| 1036 | blit_parameters blit; | |
| 1037 | int xpos,ypos; | |
| 1038 | ||
| 1039 | /* set up for the blit, using hard-coded parameters (no priority, etc) */ | |
| 1040 | configure_blit_parameters(&blit, tmap, dest.format(), dest.cliprect(), TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES, 0, 0xff); | |
| 1041 | ||
| 1042 | /* compute the effective scroll positions */ | |
| 1043 | scrollx = tmap->width - scrollx % tmap->width; | |
| 1044 | scrolly = tmap->height - scrolly % tmap->height; | |
| 1045 | ||
| 1046 | /* if the whole map is dirty, mark it as such */ | |
| 1047 | if (tmap->all_tiles_dirty || gfx_elements_changed(tmap)) | |
| 529 | // iterate over all 32 pens specified | |
| 530 | for (pen_t pen = 0; pen < 32; pen++) | |
| 1048 | 531 | { |
| 1049 | memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index); | |
| 1050 | tmap->all_tiles_dirty = FALSE; | |
| 1051 | tmap->gfx_used = 0; | |
| 532 | UINT8 fgbits = ((fgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER0; | |
| 533 | UINT8 bgbits = ((bgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER1; | |
| 534 | map_pen_to_layer(group, pen, fgbits | bgbits); | |
| 1052 | 535 | } |
| 1053 | ||
| 1054 | /* iterate to handle wraparound */ | |
| 1055 | for (ypos = scrolly - tmap->height; ypos <= blit.cliprect.max_y; ypos += tmap->height) | |
| 1056 | for (xpos = scrollx - tmap->width; xpos <= blit.cliprect.max_x; xpos += tmap->width) | |
| 1057 | tilemap_draw_instance(dest, tmap, &blit, xpos, ypos); | |
| 1058 | 536 | } |
| 1059 | 537 | |
| 1060 | 538 | |
| 1061 | 539 | |
| 1062 | /*************************************************************************** | |
| 1063 | COMMON LOGICAL-TO-MEMORY MAPPERS | |
| 1064 | ***************************************************************************/ | |
| 540 | //************************************************************************** | |
| 541 | // COMMON LOGICAL-TO-MEMORY MAPPERS | |
| 542 | //************************************************************************** | |
| 1065 | 543 | |
| 1066 | /*------------------------------------------------- | |
| 1067 | tilemap_scan_rows | |
| 1068 | tilemap_scan_rows_flip_x | |
| 1069 | tilemap_scan_rows_flip_y | |
| 1070 | tilemap_scan_rows_flip_xy - scan in row-major | |
| 1071 | order with optional flipping | |
| 1072 | -------------------------------------------------*/ | |
| 544 | //------------------------------------------------- | |
| 545 | // tilemap_scan_rows | |
| 546 | // tilemap_scan_rows_flip_x | |
| 547 | // tilemap_scan_rows_flip_y | |
| 548 | // tilemap_scan_rows_flip_xy - scan in row-major | |
| 549 | // order with optional flipping | |
| 550 | //------------------------------------------------- | |
| 1073 | 551 | |
| 1074 | 552 | TILEMAP_MAPPER( tilemap_scan_rows ) |
| 1075 | 553 | { |
| r14063 | r14064 | |
| 1092 | 570 | } |
| 1093 | 571 | |
| 1094 | 572 | |
| 1095 | /*------------------------------------------------- | |
| 1096 | tilemap_scan_cols | |
| 1097 | tilemap_scan_cols_flip_x | |
| 1098 | tilemap_scan_cols_flip_y | |
| 1099 | tilemap_scan_cols_flip_xy - scan in column- | |
| 1100 | major order with optional flipping | |
| 1101 | -------------------------------------------------*/ | |
| 573 | //------------------------------------------------- | |
| 574 | // tilemap_scan_cols | |
| 575 | // tilemap_scan_cols_flip_x | |
| 576 | // tilemap_scan_cols_flip_y | |
| 577 | // tilemap_scan_cols_flip_xy - scan in column- | |
| 578 | // major order with optional flipping | |
| 579 | //------------------------------------------------- | |
| 1102 | 580 | |
| 1103 | 581 | TILEMAP_MAPPER( tilemap_scan_cols ) |
| 1104 | 582 | { |
| r14063 | r14064 | |
| 1122 | 600 | |
| 1123 | 601 | |
| 1124 | 602 | |
| 1125 | /*************************************************************************** | |
| 1126 | SYSTEM MANAGEMENT HELPERS | |
| 1127 | ***************************************************************************/ | |
| 603 | //------------------------------------------------- | |
| 604 | // postload - after loading a save state | |
| 605 | // invalidate everything | |
| 606 | //------------------------------------------------- | |
| 1128 | 607 | |
| 1129 | /*------------------------------------------------- | |
| 1130 | tilemap_exit - free memory allocated by the | |
| 1131 | tilemap system | |
| 1132 | -------------------------------------------------*/ | |
| 1133 | ||
| 1134 | static void tilemap_exit(running_machine &machine) | |
| 608 | void tilemap_t::postload() | |
| 1135 | 609 | { |
| 1136 | tilemap_private *tilemap_data = machine.tilemap_data; | |
| 1137 | ||
| 1138 | /* free all the tilemaps in the list */ | |
| 1139 | if (tilemap_data != NULL) | |
| 1140 | while (tilemap_data->list != NULL) | |
| 1141 | { | |
| 1142 | tilemap_t *next = tilemap_data->list->next; | |
| 1143 | tilemap_dispose(tilemap_data->list); | |
| 1144 | tilemap_data->list = next; | |
| 1145 | } | |
| 610 | mappings_update(); | |
| 1146 | 611 | } |
| 1147 | 612 | |
| 1148 | 613 | |
| 1149 | /*------------------------------------------------- | |
| 1150 | tilemap_postload - after loading a save state | |
| 1151 | invalidate everything | |
| 1152 | -------------------------------------------------*/ | |
| 1153 | 614 | |
| 1154 | static void tilemap_postload(tilemap_t *tmap) | |
| 1155 | { | |
| 1156 | mappings_update(tmap); | |
| 1157 | } | |
| 615 | //************************************************************************** | |
| 616 | // LOGICAL <-> MEMORY INDEX MAPPING | |
| 617 | //************************************************************************** | |
| 1158 | 618 | |
| 619 | //------------------------------------------------- | |
| 620 | // mappings_create - allocate memory for the | |
| 621 | // mapping tables and compute their extents | |
| 622 | //------------------------------------------------- | |
| 1159 | 623 | |
| 1160 | /*------------------------------------------------- | |
| 1161 | tilemap_dispose - dispose of a tilemap | |
| 1162 | -------------------------------------------------*/ | |
| 1163 | ||
| 1164 | static void tilemap_dispose(tilemap_t *tmap) | |
| 624 | void tilemap_t::mappings_create() | |
| 1165 | 625 | { |
| 1166 | tilemap_t **tmapptr; | |
| 626 | // compute the maximum logical index | |
| 627 | m_max_logical_index = m_rows * m_cols; | |
| 1167 | 628 | |
| 1168 | /* walk the list of tilemaps; when we find ourself, remove it */ | |
| 1169 | for (tmapptr = &tmap->machine().tilemap_data->list; *tmapptr != NULL; tmapptr = &(*tmapptr)->next) | |
| 1170 | if (*tmapptr == tmap) | |
| 629 | // compute the maximum memory index | |
| 630 | m_max_memory_index = 0; | |
| 631 | for (UINT32 row = 0; row < m_rows; row++) | |
| 632 | for (UINT32 col = 0; col < m_cols; col++) | |
| 1171 | 633 | { |
| 1172 | *tmapptr = tmap->next; | |
| 1173 | break; | |
| 634 | tilemap_memory_index memindex = memory_index(col, row); | |
| 635 | m_max_memory_index = MAX(m_max_memory_index, memindex); | |
| 1174 | 636 | } |
| 637 | m_max_memory_index++; | |
| 1175 | 638 | |
| 1176 | /* free allocated memory */ | |
| 1177 | auto_free(tmap->machine(), tmap->pen_to_flags); | |
| 1178 | auto_free(tmap->machine(), tmap->tileflags); | |
| 1179 | auto_free(tmap->machine(), tmap->colscroll); | |
| 1180 | auto_free(tmap->machine(), tmap->rowscroll); | |
| 1181 | auto_free(tmap->machine(), tmap->logical_to_memory); | |
| 1182 | auto_free(tmap->machine(), tmap->memory_to_logical); | |
| 1183 | auto_free(tmap->machine(), tmap); | |
| 639 | // allocate the necessary mappings | |
| 640 | m_memory_to_logical = auto_alloc_array(machine(), logical_index, m_max_memory_index); | |
| 641 | m_logical_to_memory = auto_alloc_array(machine(), tilemap_memory_index, m_max_logical_index); | |
| 642 | ||
| 643 | // update the mappings | |
| 644 | mappings_update(); | |
| 1184 | 645 | } |
| 1185 | 646 | |
| 1186 | 647 | |
| 648 | //------------------------------------------------- | |
| 649 | // mappings_update - update the mappings after | |
| 650 | // a major change (flip x/y changes) | |
| 651 | //------------------------------------------------- | |
| 1187 | 652 | |
| 1188 | /*************************************************************************** | |
| 1189 | LOGICAL <-> MEMORY INDEX MAPPING | |
| 1190 | ***************************************************************************/ | |
| 1191 | ||
| 1192 | /*------------------------------------------------- | |
| 1193 | mappings_create - allocate memory for the | |
| 1194 | mapping tables and compute their extents | |
| 1195 | -------------------------------------------------*/ | |
| 1196 | ||
| 1197 | static void mappings_create(tilemap_t *tmap) | |
| 653 | void tilemap_t::mappings_update() | |
| 1198 | 654 | { |
| 1199 | UINT32 col, row; | |
| 655 | // initialize all the mappings to invalid values | |
| 656 | memset(m_memory_to_logical, 0xff, m_max_memory_index * sizeof(m_memory_to_logical[0])); | |
| 1200 | 657 | |
| 1201 | /* compute the maximum logical index */ | |
| 1202 | tmap->max_logical_index = tmap->rows * tmap->cols; | |
| 658 | // now iterate over all logical indexes and populate the memory index | |
| 659 | for (logical_index logindex = 0; logindex < m_max_logical_index; logindex++) | |
| 660 | { | |
| 661 | UINT32 logical_col = logindex % m_cols; | |
| 662 | UINT32 logical_row = logindex / m_cols; | |
| 663 | tilemap_memory_index memindex = memory_index(logical_col, logical_row); | |
| 1203 | 664 | |
| 1204 | /* compute the maximum memory index */ | |
| 1205 | tmap->max_memory_index = 0; | |
| 1206 | for (row = 0; row < tmap->rows; row++) | |
| 1207 | for (col = 0; col < tmap->cols; col++) | |
| 1208 | { | |
| 1209 | tilemap_memory_index memindex = (*tmap->mapper)(col, row, tmap->cols, tmap->rows); | |
| 1210 | tmap->max_memory_index = MAX(tmap->max_memory_index, memindex); | |
| 1211 | } | |
| 1212 | tmap->max_memory_index++; | |
| 665 | // apply tilemap flip to get the final location to store | |
| 666 | if (m_attributes & TILEMAP_FLIPX) | |
| 667 | logical_col = (m_cols - 1) - logical_col; | |
| 668 | if (m_attributes & TILEMAP_FLIPY) | |
| 669 | logical_row = (m_rows - 1) - logical_row; | |
| 670 | UINT32 flipped_logindex = logical_row * m_cols + logical_col; | |
| 1213 | 671 | |
| 1214 | /* allocate the necessary mappings */ | |
| 1215 | tmap->memory_to_logical = auto_alloc_array(tmap->machine(), tilemap_logical_index, tmap->max_memory_index); | |
| 1216 | tmap->logical_to_memory = auto_alloc_array(tmap->machine(), tilemap_memory_index, tmap->max_logical_index); | |
| 672 | // fill in entries in both arrays | |
| 673 | m_memory_to_logical[memindex] = flipped_logindex; | |
| 674 | m_logical_to_memory[flipped_logindex] = memindex; | |
| 675 | } | |
| 1217 | 676 | |
| 1218 | /* update the mappings */ | |
| 1219 | mappings_update(tmap); | |
| 677 | // mark the whole tilemap dirty | |
| 678 | mark_all_dirty(); | |
| 1220 | 679 | } |
| 1221 | 680 | |
| 1222 | 681 | |
| 1223 | /*------------------------------------------------- | |
| 1224 | mappings_update - update the mappings after | |
| 1225 | a major change (flip x/y changes) | |
| 1226 | -------------------------------------------------*/ | |
| 1227 | 682 | |
| 1228 | static void mappings_update(tilemap_t *tmap) | |
| 1229 | { | |
| 1230 | tilemap_logical_index logindex; | |
| 1231 | tilemap_memory_index memindex; | |
| 683 | //************************************************************************** | |
| 684 | // TILE RENDERING | |
| 685 | //************************************************************************** | |
| 1232 | 686 | |
| 1233 | /* initialize all the mappings to invalid values */ | |
| 1234 | for (memindex = 0; memindex < tmap->max_memory_index; memindex++) | |
| 1235 | tmap->memory_to_logical[memindex] = -1; | |
| 1236 | ||
| 1237 | /* now iterate over all logical indexes and populate the memory index */ | |
| 1238 | for (logindex = 0; logindex < tmap->max_logical_index; logindex++) | |
| 687 | inline void tilemap_t::realize_all_dirty_tiles() | |
| 688 | { | |
| 689 | // if all the tiles are marked dirty, or something in the gfx has changed, | |
| 690 | // flush the dirty status to all tiles | |
| 691 | if (m_all_tiles_dirty || gfx_elements_changed()) | |
| 1239 | 692 | { |
| 1240 | UINT32 logical_col = logindex % tmap->cols; | |
| 1241 | UINT32 logical_row = logindex / tmap->cols; | |
| 1242 | memindex = (*tmap->mapper)(logical_col, logical_row, tmap->cols, tmap->rows); | |
| 1243 | UINT32 flipped_logindex; | |
| 1244 | ||
| 1245 | /* apply tilemap flip to get the final location to store */ | |
| 1246 | if (tmap->attributes & TILEMAP_FLIPX) | |
| 1247 | logical_col = (tmap->cols - 1) - logical_col; | |
| 1248 | if (tmap->attributes & TILEMAP_FLIPY) | |
| 1249 | logical_row = (tmap->rows - 1) - logical_row; | |
| 1250 | flipped_logindex = logical_row * tmap->cols + logical_col; | |
| 1251 | ||
| 1252 | /* fill in entries in both arrays */ | |
| 1253 | tmap->memory_to_logical[memindex] = flipped_logindex; | |
| 1254 | tmap->logical_to_memory[flipped_logindex] = memindex; | |
| 693 | memset(m_tileflags, TILE_FLAG_DIRTY, m_max_logical_index); | |
| 694 | m_all_tiles_dirty = false; | |
| 695 | m_gfx_used = 0; | |
| 1255 | 696 | } |
| 1256 | ||
| 1257 | /* mark the whole tilemap dirty */ | |
| 1258 | tilemap_mark_all_tiles_dirty(tmap); | |
| 1259 | 697 | } |
| 1260 | 698 | |
| 699 | //------------------------------------------------- | |
| 700 | // pixmap_update - update the entire pixmap | |
| 701 | //------------------------------------------------- | |
| 1261 | 702 | |
| 1262 | ||
| 1263 | /*************************************************************************** | |
| 1264 | TILE RENDERING | |
| 1265 | ***************************************************************************/ | |
| 1266 | ||
| 1267 | /*------------------------------------------------- | |
| 1268 | pixmap_update - update the entire pixmap | |
| 1269 | -------------------------------------------------*/ | |
| 1270 | ||
| 1271 | static void pixmap_update(tilemap_t *tmap) | |
| 703 | void tilemap_t::pixmap_update() | |
| 1272 | 704 | { |
| 1273 | int mincol, maxcol, minrow, maxrow; | |
| 1274 | int row, col; | |
| 705 | // if the graphics changed, we need to mark everything dirty | |
| 706 | if (gfx_elements_changed()) | |
| 707 | mark_all_dirty(); | |
| 1275 | 708 | |
| 1276 | /* if the graphics changed, we need to mark everything dirty */ | |
| 1277 | if (gfx_elements_changed(tmap)) | |
| 1278 | tilemap_mark_all_tiles_dirty(tmap); | |
| 1279 | ||
| 1280 | /* if everything is clean, do nothing */ | |
| 1281 | if (tmap->all_tiles_clean) | |
| 709 | // if everything is clean, do nothing | |
| 710 | if (m_all_tiles_clean) | |
| 1282 | 711 | return; |
| 1283 | 712 | |
| 1284 | 713 | g_profiler.start(PROFILER_TILEMAP_DRAW); |
| 1285 | 714 | |
| 1286 | /* compute which columns and rows to update */ | |
| 1287 | mincol = minrow = 0; | |
| 1288 | maxcol = tmap->cols - 1; | |
| 1289 | maxrow = tmap->rows - 1; | |
| 715 | // flush the dirty state to all tiles as appropriate | |
| 716 | realize_all_dirty_tiles(); | |
| 1290 | 717 | |
| 1291 | /* if the whole map is dirty, mark it as such */ | |
| 1292 | if (tmap->all_tiles_dirty) | |
| 1293 | { | |
| 1294 | memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index); | |
| 1295 | tmap->all_tiles_dirty = FALSE; | |
| 1296 | tmap->gfx_used = 0; | |
| 1297 | } | |
| 718 | // iterate over rows and columns | |
| 719 | logical_index logindex = 0; | |
| 720 | for (int row = 0; row < m_rows; row++) | |
| 721 | for (int col = 0; col < m_cols; col++, logindex++) | |
| 722 | if (m_tileflags[logindex] == TILE_FLAG_DIRTY) | |
| 723 | tile_update(logindex, col, row); | |
| 1298 | 724 | |
| 1299 | /* iterate over rows */ | |
| 1300 | for (row = minrow; row <= maxrow; row++) | |
| 1301 | { | |
| 1302 | tilemap_logical_index logindex = row * tmap->cols; | |
| 725 | // mark it all clean | |
| 726 | m_all_tiles_clean = true; | |
| 1303 | 727 | |
| 1304 | /* iterate over colums */ | |
| 1305 | for (col = mincol; col <= maxcol; col++) | |
| 1306 | if (tmap->tileflags[logindex + col] == TILE_FLAG_DIRTY) | |
| 1307 | tile_update(tmap, logindex + col, col, row); | |
| 1308 | } | |
| 1309 | ||
| 1310 | /* mark it all clean */ | |
| 1311 | if (mincol == 0 && minrow == 0 && maxcol == tmap->cols - 1 && maxcol == tmap->rows - 1) | |
| 1312 | tmap->all_tiles_clean = TRUE; | |
| 1313 | ||
| 1314 | 728 | g_profiler.stop(); |
| 1315 | 729 | } |
| 1316 | 730 | |
| 1317 | 731 | |
| 1318 | /*------------------------------------------------- | |
| 1319 | tile_update - update a single dirty tile | |
| 1320 | -------------------------------------------------*/ | |
| 732 | //------------------------------------------------- | |
| 733 | // tile_update - update a single dirty tile | |
| 734 | //------------------------------------------------- | |
| 1321 | 735 | |
| 1322 | ||
| 736 | ||
| 1323 | 737 | { |
| 1324 | UINT32 x0 = tmap->tilewidth * col; | |
| 1325 | UINT32 y0 = tmap->tileheight * row; | |
| 1326 | tilemap_memory_index memindex; | |
| 1327 | UINT32 flags; | |
| 1328 | ||
| 1329 | 738 | g_profiler.start(PROFILER_TILEMAP_UPDATE); |
| 1330 | 739 | |
| 1331 | /* call the get info callback for the associated memory index */ | |
| 1332 | memindex = tmap->logical_to_memory[logindex]; | |
| 1333 | (*tmap->tile_get_info)(*(running_machine *)tmap->tile_get_info_object, &tmap->tileinfo, memindex, tmap->user_data); | |
| 740 | // call the get info callback for the associated memory index | |
| 741 | tilemap_memory_index memindex = m_logical_to_memory[logindex]; | |
| 742 | m_tile_get_info(&m_tileinfo, memindex, m_user_data); | |
| 1334 | 743 | |
| 1335 | /* apply the global tilemap flip to the returned flip flags */ | |
| 1336 | flags = tmap->tileinfo.flags ^ (tmap->attributes & 0x03); | |
| 744 | // apply the global tilemap flip to the returned flip flags | |
| 745 | UINT32 flags = m_tileinfo.flags ^ (m_attributes & 0x03); | |
| 1337 | 746 | |
| 1338 | /* draw the tile, using either direct or transparent */ | |
| 1339 | tmap->tileflags[logindex] = tile_draw(tmap, tmap->tileinfo.pen_data + tmap->pen_data_offset, x0, y0, | |
| 1340 | tmap->tileinfo.palette_base, tmap->tileinfo.category, tmap->tileinfo.group, flags, tmap->tileinfo.pen_mask); | |
| 747 | // draw the tile, using either direct or transparent | |
| 748 | UINT32 x0 = m_tilewidth * col; | |
| 749 | UINT32 y0 = m_tileheight * row; | |
| 750 | m_tileflags[logindex] = tile_draw(m_tileinfo.pen_data + m_pen_data_offset, x0, y0, | |
| 751 | m_tileinfo.palette_base, m_tileinfo.category, m_tileinfo.group, flags, m_tileinfo.pen_mask); | |
| 1341 | 752 | |
| 1342 | /* if mask data is specified, apply it */ | |
| 1343 | if ((flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2)) == 0 && tmap->tileinfo.mask_data != NULL) | |
| 1344 | tmap->tileflags[logindex] = tile_apply_bitmask(tmap, tmap->tileinfo.mask_data, x0, y0, tmap->tileinfo.category, flags); | |
| 753 | // if mask data is specified, apply it | |
| 754 | if ((flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2)) == 0 && m_tileinfo.mask_data != NULL) | |
| 755 | m_tileflags[logindex] = tile_apply_bitmask(m_tileinfo.mask_data, x0, y0, m_tileinfo.category, flags); | |
| 1345 | 756 | |
| 1346 | /* track which gfx have been used for this tilemap */ | |
| 1347 | if (tmap->tileinfo.gfxnum != 0xff && (tmap->gfx_used & (1 << tmap->tileinfo.gfxnum)) == 0) | |
| 757 | // track which gfx have been used for this tilemap | |
| 758 | if (m_tileinfo.gfxnum != 0xff && (m_gfx_used & (1 << m_tileinfo.gfxnum)) == 0) | |
| 1348 | 759 | { |
| 1349 | tmap->gfx_used |= 1 << tmap->tileinfo.gfxnum; | |
| 1350 | tmap->gfx_dirtyseq[tmap->tileinfo.gfxnum] = tmap->machine().gfx[tmap->tileinfo.gfxnum]->dirtyseq; | |
| 760 | m_gfx_used |= 1 << m_tileinfo.gfxnum; | |
| 761 | m_gfx_dirtyseq[m_tileinfo.gfxnum] = machine().gfx[m_tileinfo.gfxnum]->dirtyseq; | |
| 1351 | 762 | } |
| 1352 | 763 | |
| 1353 | 764 | g_profiler.stop(); |
| 1354 | 765 | } |
| 1355 | 766 | |
| 1356 | 767 | |
| 1357 | /*------------------------------------------------- | |
| 1358 | tile_draw - draw a single tile to the | |
| 1359 | tilemap's internal pixmap, using the pen as | |
| 1360 | the pen_to_flags lookup value, and adding | |
| 1361 | the palette_base | |
| 1362 | -------------------------------------------------*/ | |
| 768 | //------------------------------------------------- | |
| 769 | // tile_draw - draw a single tile to the | |
| 770 | // tilemap's internal pixmap, using the pen as | |
| 771 | // the pen_to_flags lookup value, and adding | |
| 772 | // the palette_base | |
| 773 | //------------------------------------------------- | |
| 1363 | 774 | |
| 1364 | ||
| 775 | ||
| 1365 | 776 | { |
| 1366 | const UINT8 *penmap = tmap->pen_to_flags + group * MAX_PEN_TO_FLAGS; | |
| 1367 | bitmap_ind8 &flagsmap = tmap->flagsmap; | |
| 1368 | bitmap_ind16 &pixmap = tmap->pixmap; | |
| 1369 | int height = tmap->tileheight; | |
| 1370 | int width = tmap->tilewidth; | |
| 1371 | UINT8 andmask = ~0, ormask = 0; | |
| 1372 | int dx0 = 1, dy0 = 1; | |
| 1373 | int tx, ty; | |
| 1374 | ||
| 1375 | /* OR in the force layer flags */ | |
| 777 | // OR in the force layer flags | |
| 1376 | 778 | category |= flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2); |
| 1377 | 779 | |
| 1378 | /* if we're vertically flipped, point to the bottom row and work backwards */ | |
| 780 | // if we're vertically flipped, point to the bottom row and work backwards | |
| 781 | int dy0 = 1; | |
| 1379 | 782 | if (flags & TILE_FLIPY) |
| 1380 | 783 | { |
| 1381 | y0 += height - 1; | |
| 784 | y0 += m_tileheight - 1; | |
| 1382 | 785 | dy0 = -1; |
| 1383 | 786 | } |
| 1384 | 787 | |
| 1385 | /* if we're horizontally flipped, point to the rightmost column and work backwards */ | |
| 788 | // if we're horizontally flipped, point to the rightmost column and work backwards | |
| 789 | int dx0 = 1; | |
| 1386 | 790 | if (flags & TILE_FLIPX) |
| 1387 | 791 | { |
| 1388 | x0 += width - 1; | |
| 792 | x0 += m_tilewidth - 1; | |
| 1389 | 793 | dx0 = -1; |
| 1390 | 794 | } |
| 1391 | 795 | |
| 1392 | /* in 4bpp mode, we draw in groups of 2 pixels, so halve the width now */ | |
| 796 | // in 4bpp mode, we draw in groups of 2 pixels, so halve the width now | |
| 797 | int width = m_tilewidth; | |
| 1393 | 798 | if (flags & TILE_4BPP) |
| 1394 | 799 | { |
| 1395 | 800 | assert(width % 2 == 0); |
| 1396 | 801 | width /= 2; |
| 1397 | 802 | } |
| 1398 | 803 | |
| 1399 | /* iterate over rows */ | |
| 1400 | for (ty = 0; ty < height; ty++) | |
| 804 | // iterate over rows | |
| 805 | const UINT8 *penmap = m_pen_to_flags + group * MAX_PEN_TO_FLAGS; | |
| 806 | UINT8 andmask = ~0, ormask = 0; | |
| 807 | for (int ty = 0; ty < m_tileheight; ty++) | |
| 1401 | 808 | { |
| 1402 | UINT16 *pixptr = &pixmap.pix16(y0, x0); | |
| 1403 | UINT8 *flagsptr = &flagsmap.pix8(y0, x0); | |
| 1404 | int xoffs = 0; | |
| 809 | UINT16 *pixptr = &m_pixmap.pix16(y0, x0); | |
| 810 | UINT8 *flagsptr = &m_flagsmap.pix8(y0, x0); | |
| 1405 | 811 | |
| 1406 | / | |
| 812 | // pre-advance to the next row | |
| 1407 | 813 | y0 += dy0; |
| 1408 | 814 | |
| 1409 | / | |
| 815 | // 8bpp data | |
| 1410 | 816 | if (!(flags & TILE_4BPP)) |
| 1411 | 817 | { |
| 1412 | for (tx = 0; tx < width; tx++) | |
| 818 | for (int tx = 0, xoffs = 0; tx < width; tx++, xoffs += dx0) | |
| 1413 | 819 | { |
| 1414 | 820 | UINT8 pen = (*pendata++) & pen_mask; |
| 1415 | 821 | UINT8 map = penmap[pen]; |
| r14063 | r14064 | |
| 1417 | 823 | flagsptr[xoffs] = map | category; |
| 1418 | 824 | andmask &= map; |
| 1419 | 825 | ormask |= map; |
| 1420 | xoffs += dx0; | |
| 1421 | 826 | } |
| 1422 | 827 | } |
| 1423 | 828 | |
| 1424 | / | |
| 829 | // 4bpp data | |
| 1425 | 830 | else |
| 1426 | 831 | { |
| 1427 | for (tx = 0; tx < width; tx++) | |
| 832 | for (int tx = 0, xoffs = 0; tx < width; tx++) | |
| 1428 | 833 | { |
| 1429 | 834 | UINT8 data = *pendata++; |
| 1430 | 835 | UINT8 pen, map; |
| r14063 | r14064 | |
| 1451 | 856 | } |
| 1452 | 857 | |
| 1453 | 858 | |
| 1454 | /*------------------------------------------------- | |
| 1455 | tile_apply_bitmask - apply a bitmask to an | |
| 1456 | already-rendered tile by modifying the | |
| 1457 | flagsmap appropriately | |
| 1458 | -------------------------------------------------*/ | |
| 859 | //------------------------------------------------- | |
| 860 | // tile_apply_bitmask - apply a bitmask to an | |
| 861 | // already-rendered tile by modifying the | |
| 862 | // flagsmap appropriately | |
| 863 | //------------------------------------------------- | |
| 1459 | 864 | |
| 1460 | ||
| 865 | ||
| 1461 | 866 | { |
| 1462 | bitmap_ind8 &flagsmap = tmap->flagsmap; | |
| 1463 | int height = tmap->tileheight; | |
| 1464 | int width = tmap->tilewidth; | |
| 1465 | UINT8 andmask = ~0, ormask = 0; | |
| 1466 | int dx0 = 1, dy0 = 1; | |
| 1467 | int bitoffs = 0; | |
| 1468 | int tx, ty; | |
| 1469 | ||
| 1470 | /* if we're vertically flipped, point to the bottom row and work backwards */ | |
| 867 | // if we're vertically flipped, point to the bottom row and work backwards | |
| 868 | int dy0 = 1; | |
| 1471 | 869 | if (flags & TILE_FLIPY) |
| 1472 | 870 | { |
| 1473 | y0 += height - 1; | |
| 871 | y0 += m_tileheight - 1; | |
| 1474 | 872 | dy0 = -1; |
| 1475 | 873 | } |
| 1476 | 874 | |
| 1477 | /* if we're horizontally flipped, point to the rightmost column and work backwards */ | |
| 875 | // if we're horizontally flipped, point to the rightmost column and work backwards | |
| 876 | int dx0 = 1; | |
| 1478 | 877 | if (flags & TILE_FLIPX) |
| 1479 | 878 | { |
| 1480 | x0 += width - 1; | |
| 879 | x0 += m_tilewidth - 1; | |
| 1481 | 880 | dx0 = -1; |
| 1482 | 881 | } |
| 1483 | 882 | |
| 1484 | /* iterate over rows */ | |
| 1485 | for (ty = 0; ty < height; ty++) | |
| 883 | // iterate over rows | |
| 884 | UINT8 andmask = ~0, ormask = 0; | |
| 885 | int bitoffs = 0; | |
| 886 | for (int ty = 0; ty < m_tileheight; ty++) | |
| 1486 | 887 | { |
| 1487 | UINT8 *flagsptr = &flagsmap.pix8(y0, x0); | |
| 1488 | int xoffs = 0; | |
| 1489 | ||
| 1490 | /* pre-advance to the next row */ | |
| 888 | // pre-advance to the next row | |
| 889 | UINT8 *flagsptr = &m_flagsmap.pix8(y0, x0); | |
| 1491 | 890 | y0 += dy0; |
| 1492 | 891 | |
| 1493 | /* anywhere the bitmask is 0 should be transparent */ | |
| 1494 | for (tx = 0; tx < width; tx++) | |
| 892 | // anywhere the bitmask is 0 should be transparent | |
| 893 | for (int tx = 0, xoffs = 0; tx < m_tilewidth; tx++, xoffs += dx0) | |
| 1495 | 894 | { |
| 1496 | 895 | UINT8 map = flagsptr[xoffs]; |
| 1497 | 896 | |
| r14063 | r14064 | |
| 1499 | 898 | map = flagsptr[xoffs] = TILEMAP_PIXEL_TRANSPARENT | category; |
| 1500 | 899 | andmask &= map; |
| 1501 | 900 | ormask |= map; |
| 1502 | xoffs += dx0; | |
| 1503 | 901 | bitoffs++; |
| 1504 | 902 | } |
| 1505 | 903 | } |
| r14063 | r14064 | |
| 1508 | 906 | |
| 1509 | 907 | |
| 1510 | 908 | |
| 1511 | /*************************************************************************** | |
| 1512 | DRAWING HELPERS | |
| 1513 | ***************************************************************************/ | |
| 909 | //************************************************************************** | |
| 910 | // DRAWING HELPERS | |
| 911 | //************************************************************************** | |
| 1514 | 912 | |
| 1515 | /*------------------------------------------------- | |
| 1516 | configure_blit_parameters - fill in the | |
| 1517 | standard blit parameters based on the input | |
| 1518 | data; this code is shared by normal, roz, | |
| 1519 | and indexed drawing code | |
| 1520 | -------------------------------------------------*/ | |
| 913 | //------------------------------------------------- | |
| 914 | // configure_blit_parameters - fill in the | |
| 915 | // standard blit parameters based on the input | |
| 916 | // data; this code is shared by normal, roz, | |
| 917 | // and indexed drawing code | |
| 918 | //------------------------------------------------- | |
| 1521 | 919 | |
| 1522 | ||
| 920 | ||
| 1523 | 921 | { |
| 1524 | /* start with nothing */ | |
| 1525 | memset(blit, 0, sizeof(*blit)); | |
| 922 | // set the target bitmap | |
| 923 | blit.cliprect = cliprect; | |
| 1526 | 924 | |
| 1527 | /* set the target bitmap */ | |
| 1528 | blit->cliprect = cliprect; | |
| 925 | // set the priority code and alpha | |
| 926 | blit.tilemap_priority_code = priority | (priority_mask << 8) | (m_palette_offset << 16); | |
| 927 | blit.alpha = (flags & TILEMAP_DRAW_ALPHA_FLAG) ? (flags >> 24) : 0xff; | |
| 1529 | 928 | |
| 1530 | /* set the priority code and alpha */ | |
| 1531 | blit->tilemap_priority_code = priority | (priority_mask << 8) | (tmap->palette_offset << 16); | |
| 1532 | blit->alpha = (flags & TILEMAP_DRAW_ALPHA_FLAG) ? (flags >> 24) : 0xff; | |
| 929 | // tile priority; unless otherwise specified, draw anything in layer 0 | |
| 930 | blit.mask = TILEMAP_PIXEL_CATEGORY_MASK; | |
| 931 | blit.value = flags & TILEMAP_PIXEL_CATEGORY_MASK; | |
| 1533 | 932 | |
| 1534 | /* tile priority; unless otherwise specified, draw anything in layer 0 */ | |
| 1535 | blit->mask = TILEMAP_PIXEL_CATEGORY_MASK; | |
| 1536 | blit->value = flags & TILEMAP_PIXEL_CATEGORY_MASK; | |
| 1537 | ||
| 1538 | /* if no layers specified, draw layer 0 */ | |
| 933 | // if no layers specified, draw layer 0 | |
| 1539 | 934 | if ((flags & (TILEMAP_DRAW_LAYER0 | TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_LAYER2)) == 0) |
| 1540 | 935 | flags |= TILEMAP_DRAW_LAYER0; |
| 1541 | 936 | |
| 1542 | /* OR in the bits from the draw masks */ | |
| 1543 | blit->mask |= flags & (TILEMAP_DRAW_LAYER0 | TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_LAYER2); | |
| 1544 | blit->value |= flags & (TILEMAP_DRAW_LAYER0 | TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_LAYER2); | |
| 937 | // OR in the bits from the draw masks | |
| 938 | blit.mask |= flags & (TILEMAP_DRAW_LAYER0 | TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_LAYER2); | |
| 939 | blit.value |= flags & (TILEMAP_DRAW_LAYER0 | TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_LAYER2); | |
| 1545 | 940 | |
| 1546 | / | |
| 941 | // for all-opaque rendering, don't check any of the layer bits | |
| 1547 | 942 | if (flags & TILEMAP_DRAW_OPAQUE) |
| 1548 | 943 | { |
| 1549 | blit->mask &= ~(TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1 | TILEMAP_PIXEL_LAYER2); | |
| 1550 | blit->value &= ~(TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1 | TILEMAP_PIXEL_LAYER2); | |
| 944 | blit.mask &= ~(TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1 | TILEMAP_PIXEL_LAYER2); | |
| 945 | blit.value &= ~(TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1 | TILEMAP_PIXEL_LAYER2); | |
| 1551 | 946 | } |
| 1552 | 947 | |
| 1553 | / | |
| 948 | // don't check category if requested | |
| 1554 | 949 | if (flags & TILEMAP_DRAW_ALL_CATEGORIES) |
| 1555 | 950 | { |
| 1556 | blit->mask &= ~TILEMAP_PIXEL_CATEGORY_MASK; | |
| 1557 | blit->value &= ~TILEMAP_PIXEL_CATEGORY_MASK; | |
| 951 | blit.mask &= ~TILEMAP_PIXEL_CATEGORY_MASK; | |
| 952 | blit.value &= ~TILEMAP_PIXEL_CATEGORY_MASK; | |
| 1558 | 953 | } |
| 1559 | 954 | } |
| 1560 | 955 | |
| 1561 | 956 | |
| 1562 | /*------------------------------------------------- | |
| 1563 | tilemap_draw_instance - draw a single | |
| 1564 | instance of the tilemap to the internal | |
| 1565 | pixmap at the given xpos,ypos | |
| 1566 | -------------------------------------------------*/ | |
| 957 | //------------------------------------------------- | |
| 958 | // draw_common - draw a tilemap to the | |
| 959 | // destination with clipping; pixels apply | |
| 960 | // priority/priority_mask to the priority bitmap | |
| 961 | //------------------------------------------------- | |
| 1567 | 962 | |
| 1568 | 963 | template<class _BitmapClass> |
| 1569 | ||
| 964 | ||
| 1570 | 965 | { |
| 1571 | bitmap_ind8 &priority_bitmap = tmap->machine().priority_bitmap; | |
| 1572 | const UINT16 *source_baseaddr; | |
| 1573 | const UINT8 *mask_baseaddr; | |
| 1574 | typename _BitmapClass::pixel_t *dest_baseaddr = NULL; | |
| 1575 | UINT8 *priority_baseaddr; | |
| 1576 | int dest_rowpixels = 0; | |
| 1577 | int mincol, maxcol; | |
| 1578 | int x1, y1, x2, y2; | |
| 1579 | int y, nexty; | |
| 966 | // skip if disabled | |
| 967 | if (!m_enable) | |
| 968 | return; | |
| 1580 | 969 | |
| 1581 | /* clip destination coordinates to the tilemap */ | |
| 1582 | /* note that x2/y2 are exclusive, not inclusive */ | |
| 1583 | x1 = MAX(xpos, blit->cliprect.min_x); | |
| 1584 | x2 = MIN(xpos + (int)tmap->width, blit->cliprect.max_x + 1); | |
| 1585 | y1 = MAX(ypos, blit->cliprect.min_y); | |
| 1586 | y2 = MIN(ypos + (int)tmap->height, blit->cliprect.max_y + 1); | |
| 970 | g_profiler.start(PROFILER_TILEMAP_DRAW); | |
| 971 | // configure the blit parameters based on the input parameters | |
| 972 | blit_parameters blit; | |
| 973 | configure_blit_parameters(blit, cliprect, flags, priority, priority_mask); | |
| 1587 | 974 | |
| 1588 | /* if totally clipped, stop here */ | |
| 975 | // flush the dirty state to all tiles as appropriate | |
| 976 | realize_all_dirty_tiles(); | |
| 977 | ||
| 978 | UINT32 width = machine().primary_screen->width(); | |
| 979 | UINT32 height = machine().primary_screen->height(); | |
| 980 | ||
| 981 | // XY scrolling playfield | |
| 982 | if (m_scrollrows == 1 && m_scrollcols == 1) | |
| 983 | { | |
| 984 | // iterate to handle wraparound | |
| 985 | int scrollx = effective_rowscroll(0, width); | |
| 986 | int scrolly = effective_colscroll(0, height); | |
| 987 | for (int ypos = scrolly - m_height; ypos <= blit.cliprect.max_y; ypos += m_height) | |
| 988 | for (int xpos = scrollx - m_width; xpos <= blit.cliprect.max_x; xpos += m_width) | |
| 989 | draw_instance(dest, blit, xpos, ypos); | |
| 990 | } | |
| 991 | ||
| 992 | // scrolling rows + vertical scroll | |
| 993 | else if (m_scrollcols == 1) | |
| 994 | { | |
| 995 | const rectangle original_cliprect = blit.cliprect; | |
| 996 | ||
| 997 | // iterate over Y to handle wraparound | |
| 998 | int rowheight = m_height / m_scrollrows; | |
| 999 | int scrolly = effective_colscroll(0, height); | |
| 1000 | for (int ypos = scrolly - m_height; ypos <= original_cliprect.max_y; ypos += m_height) | |
| 1001 | { | |
| 1002 | int const firstrow = MAX((original_cliprect.min_y - ypos) / rowheight, 0); | |
| 1003 | int const lastrow = MIN((original_cliprect.max_y - ypos) / rowheight, m_scrollrows - 1); | |
| 1004 | ||
| 1005 | // iterate over rows in the tilemap | |
| 1006 | int nextrow; | |
| 1007 | for (int currow = firstrow; currow <= lastrow; currow = nextrow) | |
| 1008 | { | |
| 1009 | // scan forward until we find a non-matching row | |
| 1010 | int scrollx = effective_rowscroll(currow, width); | |
| 1011 | for (nextrow = currow + 1; nextrow <= lastrow; nextrow++) | |
| 1012 | if (effective_rowscroll(nextrow, width) != scrollx) | |
| 1013 | break; | |
| 1014 | ||
| 1015 | // skip if disabled | |
| 1016 | if (scrollx == TILE_LINE_DISABLED) | |
| 1017 | continue; | |
| 1018 | ||
| 1019 | // update the cliprect just for this set of rows | |
| 1020 | blit.cliprect.min_y = currow * rowheight + ypos; | |
| 1021 | blit.cliprect.max_y = nextrow * rowheight - 1 + ypos; | |
| 1022 | blit.cliprect &= original_cliprect; | |
| 1023 | ||
| 1024 | // iterate over X to handle wraparound | |
| 1025 | for (int xpos = scrollx - m_width; xpos <= original_cliprect.max_x; xpos += m_width) | |
| 1026 | draw_instance(dest, blit, xpos, ypos); | |
| 1027 | } | |
| 1028 | } | |
| 1029 | } | |
| 1030 | ||
| 1031 | // scrolling columns + horizontal scroll | |
| 1032 | else if (m_scrollrows == 1) | |
| 1033 | { | |
| 1034 | const rectangle original_cliprect = blit.cliprect; | |
| 1035 | ||
| 1036 | // iterate over columns in the tilemap | |
| 1037 | int scrollx = effective_rowscroll(0, width); | |
| 1038 | int colwidth = m_width / m_scrollcols; | |
| 1039 | int nextcol; | |
| 1040 | for (int curcol = 0; curcol < m_scrollcols; curcol = nextcol) | |
| 1041 | { | |
| 1042 | // scan forward until we find a non-matching column | |
| 1043 | int scrolly = effective_colscroll(curcol, height); | |
| 1044 | for (nextcol = curcol + 1; nextcol < m_scrollcols; nextcol++) | |
| 1045 | if (effective_colscroll(nextcol, height) != scrolly) | |
| 1046 | break; | |
| 1047 | ||
| 1048 | // skip if disabled | |
| 1049 | if (scrolly == TILE_LINE_DISABLED) | |
| 1050 | continue; | |
| 1051 | ||
| 1052 | // iterate over X to handle wraparound | |
| 1053 | for (int xpos = scrollx - m_width; xpos <= original_cliprect.max_x; xpos += m_width) | |
| 1054 | { | |
| 1055 | // update the cliprect just for this set of columns | |
| 1056 | blit.cliprect.min_x = curcol * colwidth + xpos; | |
| 1057 | blit.cliprect.max_x = nextcol * colwidth - 1 + xpos; | |
| 1058 | blit.cliprect &= original_cliprect; | |
| 1059 | ||
| 1060 | // iterate over Y to handle wraparound | |
| 1061 | for (int ypos = scrolly - m_height; ypos <= original_cliprect.max_y; ypos += m_height) | |
| 1062 | draw_instance(dest, blit, xpos, ypos); | |
| 1063 | } | |
| 1064 | } | |
| 1065 | } | |
| 1066 | g_profiler.stop(); | |
| 1067 | } | |
| 1068 | ||
| 1069 | void tilemap_t::draw(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 1070 | { draw_common(dest, cliprect, flags, priority, priority_mask); } | |
| 1071 | ||
| 1072 | void tilemap_t::draw(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 1073 | { draw_common(dest, cliprect, flags, priority, priority_mask); } | |
| 1074 | ||
| 1075 | ||
| 1076 | //------------------------------------------------- | |
| 1077 | // draw_roz - draw a tilemap to the destination | |
| 1078 | // with clipping and arbitrary rotate/zoom; pixels | |
| 1079 | // apply priority/priority_mask to the priority | |
| 1080 | // bitmap | |
| 1081 | //------------------------------------------------- | |
| 1082 | ||
| 1083 | template<class _BitmapClass> | |
| 1084 | void tilemap_t::draw_roz_common(_BitmapClass &dest, const rectangle &cliprect, | |
| 1085 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, | |
| 1086 | bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 1087 | { | |
| 1088 | // notes: | |
| 1089 | // - startx and starty MUST be UINT32 for calculations to work correctly | |
| 1090 | // - srcbim_width and height are assumed to be a power of 2 to speed up wraparound | |
| 1091 | ||
| 1092 | // skip if disabled | |
| 1093 | if (!m_enable) | |
| 1094 | return; | |
| 1095 | ||
| 1096 | // see if this is just a regular render and if so, do a regular render | |
| 1097 | if (incxx == (1 << 16) && incxy == 0 && incyx == 0 && incyy == (1 << 16) && wraparound) | |
| 1098 | { | |
| 1099 | set_scrollx(0, startx >> 16); | |
| 1100 | set_scrolly(0, starty >> 16); | |
| 1101 | draw(dest, cliprect, flags, priority, priority_mask); | |
| 1102 | return; | |
| 1103 | } | |
| 1104 | ||
| 1105 | g_profiler.start(PROFILER_TILEMAP_DRAW_ROZ); | |
| 1106 | // configure the blit parameters | |
| 1107 | blit_parameters blit; | |
| 1108 | configure_blit_parameters(blit, cliprect, flags, priority, priority_mask); | |
| 1109 | ||
| 1110 | // get the full pixmap for the tilemap | |
| 1111 | pixmap(); | |
| 1112 | ||
| 1113 | // then do the roz copy | |
| 1114 | draw_roz_core(dest, blit, startx, starty, incxx, incxy, incyx, incyy, wraparound); | |
| 1115 | g_profiler.stop(); | |
| 1116 | } | |
| 1117 | ||
| 1118 | void tilemap_t::draw_roz(bitmap_ind16 &dest, const rectangle &cliprect, | |
| 1119 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, | |
| 1120 | bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 1121 | { draw_roz_common(dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); } | |
| 1122 | ||
| 1123 | void tilemap_t::draw_roz(bitmap_rgb32 &dest, const rectangle &cliprect, | |
| 1124 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, | |
| 1125 | bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 1126 | { draw_roz_common(dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); } | |
| 1127 | ||
| 1128 | ||
| 1129 | //------------------------------------------------- | |
| 1130 | // draw_instance - draw a single instance of the | |
| 1131 | // tilemap to the internal pixmap at the given | |
| 1132 | // xpos,ypos | |
| 1133 | //------------------------------------------------- | |
| 1134 | ||
| 1135 | template<class _BitmapClass> | |
| 1136 | void tilemap_t::draw_instance(_BitmapClass &dest, const blit_parameters &blit, int xpos, int ypos) | |
| 1137 | { | |
| 1138 | // clip destination coordinates to the tilemap | |
| 1139 | // note that x2/y2 are exclusive, not inclusive | |
| 1140 | int x1 = MAX(xpos, blit.cliprect.min_x); | |
| 1141 | int x2 = MIN(xpos + (int)m_width, blit.cliprect.max_x + 1); | |
| 1142 | int y1 = MAX(ypos, blit.cliprect.min_y); | |
| 1143 | int y2 = MIN(ypos + (int)m_height, blit.cliprect.max_y + 1); | |
| 1144 | ||
| 1145 | // if totally clipped, stop here | |
| 1589 | 1146 | if (x1 >= x2 || y1 >= y2) |
| 1590 | 1147 | return; |
| 1591 | 1148 | |
| 1592 | /* look up priority and destination base addresses for y1 */ | |
| 1593 | priority_baseaddr = &priority_bitmap.pix8(y1, xpos); | |
| 1149 | // look up priority and destination base addresses for y1 | |
| 1150 | bitmap_ind8 &priority_bitmap = machine().priority_bitmap; | |
| 1151 | UINT8 *priority_baseaddr = &priority_bitmap.pix8(y1, xpos); | |
| 1152 | typename _BitmapClass::pixel_t *dest_baseaddr = NULL; | |
| 1153 | int dest_rowpixels = 0; | |
| 1594 | 1154 | if (dest.valid()) |
| 1595 | 1155 | { |
| 1596 | 1156 | dest_rowpixels = dest.rowpixels(); |
| 1597 | 1157 | dest_baseaddr = &dest.pix(y1, xpos); |
| 1598 | 1158 | } |
| 1599 | 1159 | |
| 1600 | / | |
| 1160 | // convert screen coordinates to source tilemap coordinates | |
| 1601 | 1161 | x1 -= xpos; |
| 1602 | 1162 | y1 -= ypos; |
| 1603 | 1163 | x2 -= xpos; |
| 1604 | 1164 | y2 -= ypos; |
| 1605 | 1165 | |
| 1606 | /* get tilemap pixels */ | |
| 1607 | source_baseaddr = &tmap->pixmap.pix16(y1); | |
| 1608 | mask_baseaddr = &tmap->flagsmap.pix8(y1); | |
| 1166 | // get tilemap pixels | |
| 1167 | const UINT16 *source_baseaddr = &m_pixmap.pix16(y1); | |
| 1168 | const UINT8 *mask_baseaddr = &m_flagsmap.pix8(y1); | |
| 1609 | 1169 | |
| 1610 | /* get start/stop columns, rounding outward */ | |
| 1611 | mincol = x1 / tmap->tilewidth; | |
| 1612 | maxcol = (x2 + tmap->tilewidth - 1) / tmap->tilewidth; | |
| 1170 | // get start/stop columns, rounding outward | |
| 1171 | int mincol = x1 / m_tilewidth; | |
| 1172 | int maxcol = (x2 + m_tilewidth - 1) / m_tilewidth; | |
| 1613 | 1173 | |
| 1614 | /* set up row counter */ | |
| 1615 | y = y1; | |
| 1616 | nexty = tmap->tileheight * (y1 / tmap->tileheight) + tmap->tileheight; | |
| 1174 | // set up row counter | |
| 1175 | int y = y1; | |
| 1176 | int nexty = m_tileheight * (y1 / m_tileheight) + m_tileheight; | |
| 1617 | 1177 | nexty = MIN(nexty, y2); |
| 1618 | 1178 | |
| 1619 | / | |
| 1179 | // loop over tilemap rows | |
| 1620 | 1180 | for (;;) |
| 1621 | 1181 | { |
| 1622 | int row = y / tmap->tileheight; | |
| 1623 | trans_t prev_trans = WHOLLY_TRANSPARENT; | |
| 1624 | trans_t cur_trans; | |
| 1182 | int row = y / m_tileheight; | |
| 1625 | 1183 | int x_start = x1; |
| 1626 | int column; | |
| 1627 | 1184 | |
| 1628 | /* iterate across the applicable tilemap columns */ | |
| 1629 | for (column = mincol; column <= maxcol; column++) | |
| 1185 | // iterate across the applicable tilemap columns | |
| 1186 | trans_t prev_trans = WHOLLY_TRANSPARENT; | |
| 1187 | trans_t cur_trans; | |
| 1188 | for (int column = mincol; column <= maxcol; column++) | |
| 1630 | 1189 | { |
| 1631 | 1190 | int x_end; |
| 1632 | 1191 | |
| 1633 | / | |
| 1192 | // we don't actually render the last column; it is always just used for flushing | |
| 1634 | 1193 | if (column == maxcol) |
| 1635 | 1194 | cur_trans = WHOLLY_TRANSPARENT; |
| 1636 | 1195 | |
| 1637 | / | |
| 1196 | // for other columns we look up the transparency information | |
| 1638 | 1197 | else |
| 1639 | 1198 | { |
| 1640 | | |
| 1199 | | |
| 1641 | 1200 | |
| 1642 | /* if the current tile is dirty, fix it */ | |
| 1643 | if (tmap->tileflags[logindex] == TILE_FLAG_DIRTY) | |
| 1644 | tile_update(tmap, logindex, column, row); | |
| 1201 | // if the current tile is dirty, fix it | |
| 1202 | if (m_tileflags[logindex] == TILE_FLAG_DIRTY) | |
| 1203 | tile_update(logindex, column, row); | |
| 1645 | 1204 | |
| 1646 | /* if the current summary data is non-zero, we must draw masked */ | |
| 1647 | if ((tmap->tileflags[logindex] & blit->mask) != 0) | |
| 1205 | // if the current summary data is non-zero, we must draw masked | |
| 1206 | if ((m_tileflags[logindex] & blit.mask) != 0) | |
| 1648 | 1207 | cur_trans = MASKED; |
| 1649 | 1208 | |
| 1650 | / | |
| 1209 | // otherwise, our transparency state is constant across the tile; fetch it | |
| 1651 | 1210 | else |
| 1652 | cur_trans = ((mask_baseaddr[column * | |
| 1211 | cur_trans = ((mask_baseaddr[column * | |
| 1653 | 1212 | } |
| 1654 | 1213 | |
| 1655 | / | |
| 1214 | // if the transparency state is the same as last time, don't render yet | |
| 1656 | 1215 | if (cur_trans == prev_trans) |
| 1657 | 1216 | continue; |
| 1658 | 1217 | |
| 1659 | /* compute the end of this run, in pixels */ | |
| 1660 | x_end = column * tmap->tilewidth; | |
| 1218 | // compute the end of this run, in pixels | |
| 1219 | x_end = column * m_tilewidth; | |
| 1661 | 1220 | x_end = MAX(x_end, x1); |
| 1662 | 1221 | x_end = MIN(x_end, x2); |
| 1663 | 1222 | |
| 1664 | / | |
| 1223 | // if we're rendering something, compute the pointers | |
| 1665 | 1224 | if (prev_trans != WHOLLY_TRANSPARENT) |
| 1666 | 1225 | { |
| 1667 | 1226 | const UINT16 *source0 = source_baseaddr + x_start; |
| 1668 | 1227 | typename _BitmapClass::pixel_t *dest0 = dest_baseaddr + x_start; |
| 1669 | 1228 | UINT8 *pmap0 = priority_baseaddr + x_start; |
| 1670 | int cury; | |
| 1671 | 1229 | |
| 1672 | / | |
| 1230 | // if we were opaque, use the opaque renderer | |
| 1673 | 1231 | if (prev_trans == WHOLLY_OPAQUE) |
| 1674 | 1232 | { |
| 1675 | for (cury = y; cury < nexty; cury++) | |
| 1233 | for (int cury = y; cury < nexty; cury++) | |
| 1676 | 1234 | { |
| 1677 | 1235 | if (dest_baseaddr == NULL) |
| 1678 | scanline_draw_opaque_null(x_end - x_start, pmap0, blit | |
| 1236 | scanline_draw_opaque_null(x_end - x_start, pmap0, blit. | |
| 1679 | 1237 | else if (sizeof(*dest0) == 2) |
| 1680 | scanline_draw_opaque_ind16(reinterpret_cast<UINT16 *>(dest0), source0, x_end - x_start, pmap0, blit->tilemap_priority_code); | |
| 1681 | else if (sizeof(*dest0) == 4 && blit->alpha >= 0xff) | |
| 1682 | scanline_draw_opaque_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, tmap->machine().pens, pmap0, blit->tilemap_priority_code); | |
| 1238 | scanline_draw_opaque_ind16(reinterpret_cast<UINT16 *>(dest0), source0, x_end - x_start, pmap0, blit.tilemap_priority_code); | |
| 1239 | else if (sizeof(*dest0) == 4 && blit.alpha >= 0xff) | |
| 1240 | scanline_draw_opaque_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, machine().pens, pmap0, blit.tilemap_priority_code); | |
| 1683 | 1241 | else if (sizeof(*dest0) == 4) |
| 1684 | scanline_draw_opaque_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, | |
| 1242 | scanline_draw_opaque_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, | |
| 1685 | 1243 | |
| 1686 | 1244 | dest0 += dest_rowpixels; |
| 1687 | source0 += | |
| 1245 | source0 += | |
| 1688 | 1246 | pmap0 += priority_bitmap.rowpixels(); |
| 1689 | 1247 | } |
| 1690 | 1248 | } |
| 1691 | 1249 | |
| 1692 | / | |
| 1250 | // otherwise use the masked renderer | |
| 1693 | 1251 | else |
| 1694 | 1252 | { |
| 1695 | 1253 | const UINT8 *mask0 = mask_baseaddr + x_start; |
| 1696 | for (cury = y; cury < nexty; cury++) | |
| 1254 | for (int cury = y; cury < nexty; cury++) | |
| 1697 | 1255 | { |
| 1698 | 1256 | if (dest_baseaddr == NULL) |
| 1699 | scanline_draw_masked_null(mask0, blit | |
| 1257 | scanline_draw_masked_null(mask0, blit. | |
| 1700 | 1258 | else if (sizeof(*dest0) == 2) |
| 1701 | scanline_draw_masked_ind16(reinterpret_cast<UINT16 *>(dest0), source0, mask0, blit->mask, blit->value, x_end - x_start, pmap0, blit->tilemap_priority_code); | |
| 1702 | else if (sizeof(*dest0) == 4 && blit->alpha >= 0xff) | |
| 1703 | scanline_draw_masked_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit->mask, blit->value, x_end - x_start, tmap->machine().pens, pmap0, blit->tilemap_priority_code); | |
| 1259 | scanline_draw_masked_ind16(reinterpret_cast<UINT16 *>(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, pmap0, blit.tilemap_priority_code); | |
| 1260 | else if (sizeof(*dest0) == 4 && blit.alpha >= 0xff) | |
| 1261 | scanline_draw_masked_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, machine().pens, pmap0, blit.tilemap_priority_code); | |
| 1704 | 1262 | else if (sizeof(*dest0) == 4) |
| 1705 | scanline_draw_masked_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit | |
| 1263 | scanline_draw_masked_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit. | |
| 1706 | 1264 | |
| 1707 | 1265 | dest0 += dest_rowpixels; |
| 1708 | source0 += tmap->pixmap.rowpixels(); | |
| 1709 | mask0 += tmap->flagsmap.rowpixels(); | |
| 1266 | source0 += m_pixmap.rowpixels(); | |
| 1267 | mask0 += m_flagsmap.rowpixels(); | |
| 1710 | 1268 | pmap0 += priority_bitmap.rowpixels(); |
| 1711 | 1269 | } |
| 1712 | 1270 | } |
| 1713 | 1271 | } |
| 1714 | 1272 | |
| 1715 | / | |
| 1273 | // the new start is the end | |
| 1716 | 1274 | x_start = x_end; |
| 1717 | 1275 | prev_trans = cur_trans; |
| 1718 | 1276 | } |
| 1719 | 1277 | |
| 1720 | / | |
| 1278 | // if this was the last row, stop | |
| 1721 | 1279 | if (nexty == y2) |
| 1722 | 1280 | break; |
| 1723 | 1281 | |
| 1724 | / | |
| 1282 | // advance to the next row on all our bitmaps | |
| 1725 | 1283 | priority_baseaddr += priority_bitmap.rowpixels() * (nexty - y); |
| 1726 | source_baseaddr += tmap->pixmap.rowpixels() * (nexty - y); | |
| 1727 | mask_baseaddr += tmap->flagsmap.rowpixels() * (nexty - y); | |
| 1284 | source_baseaddr += m_pixmap.rowpixels() * (nexty - y); | |
| 1285 | mask_baseaddr += m_flagsmap.rowpixels() * (nexty - y); | |
| 1728 | 1286 | dest_baseaddr += dest_rowpixels * (nexty - y); |
| 1729 | 1287 | |
| 1730 | / | |
| 1288 | // increment the Y counter | |
| 1731 | 1289 | y = nexty; |
| 1732 | nexty += | |
| 1290 | nexty += | |
| 1733 | 1291 | nexty = MIN(nexty, y2); |
| 1734 | 1292 | } |
| 1735 | 1293 | } |
| 1736 | 1294 | |
| 1737 | 1295 | |
| 1738 | /*------------------------------------------------- | |
| 1739 | tilemap_draw_roz_core - render the tilemap's | |
| 1740 | pixmap to the destination with rotation | |
| 1741 | and zoom | |
| 1742 | -------------------------------------------------*/ | |
| 1296 | //------------------------------------------------- | |
| 1297 | // tilemap_draw_roz_core - render the tilemap's | |
| 1298 | // pixmap to the destination with rotation | |
| 1299 | // and zoom | |
| 1300 | //------------------------------------------------- | |
| 1743 | 1301 | |
| 1744 | 1302 | #define ROZ_PLOT_PIXEL(INPUT_VAL) \ |
| 1745 | 1303 | do { \ |
| r14063 | r14064 | |
| 1752 | 1310 | } while (0) |
| 1753 | 1311 | |
| 1754 | 1312 | template<class _BitmapClass> |
| 1755 | static void tilemap_draw_roz_core(_BitmapClass &destbitmap, tilemap_t *tmap, const blit_parameters *blit, | |
| 1756 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound) | |
| 1313 | void tilemap_t::draw_roz_core(_BitmapClass &destbitmap, const blit_parameters &blit, | |
| 1314 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound) | |
| 1757 | 1315 | { |
| 1758 | const pen_t *clut = &tmap->machine().pens[blit->tilemap_priority_code >> 16]; | |
| 1759 | bitmap_ind8 &priority_bitmap = tmap->machine().priority_bitmap; | |
| 1760 | bitmap_ind16 &srcbitmap = tmap->pixmap; | |
| 1761 | bitmap_ind8 &flagsmap = tmap->flagsmap; | |
| 1762 | const int xmask = srcbitmap.width()-1; | |
| 1763 | const int ymask = srcbitmap.height()-1; | |
| 1764 | const int widthshifted = srcbitmap.width() << 16; | |
| 1765 | const int heightshifted = srcbitmap.height() << 16; | |
| 1766 | UINT32 priority = blit->tilemap_priority_code; | |
| 1767 | UINT8 mask = blit->mask; | |
| 1768 | UINT8 value = blit->value; | |
| 1769 | UINT8 alpha = blit->alpha; | |
| 1770 | UINT32 cx; | |
| 1771 | UINT32 cy; | |
| 1772 | int x; | |
| 1773 | int sx; | |
| 1774 | int sy; | |
| 1775 | int ex; | |
| 1776 | int ey; | |
| 1777 | typename _BitmapClass::pixel_t *dest; | |
| 1778 | UINT8 *pri; | |
| 1779 | const UINT16 *src; | |
| 1780 | const UINT8 *maskptr; | |
| 1316 | // pre-cache all the inner loop values | |
| 1317 | const pen_t *clut = &machine().pens[blit.tilemap_priority_code >> 16]; | |
| 1318 | bitmap_ind8 &priority_bitmap = machine().priority_bitmap; | |
| 1319 | const int xmask = m_pixmap.width() - 1; | |
| 1320 | const int ymask = m_pixmap.height() - 1; | |
| 1321 | const int widthshifted = m_pixmap.width() << 16; | |
| 1322 | const int heightshifted = m_pixmap.height() << 16; | |
| 1323 | UINT32 priority = blit.tilemap_priority_code; | |
| 1324 | UINT8 mask = blit.mask; | |
| 1325 | UINT8 value = blit.value; | |
| 1326 | UINT8 alpha = blit.alpha; | |
| 1781 | 1327 | |
| 1782 | /* pre-advance based on the cliprect */ | |
| 1783 | startx += blit->cliprect.min_x * incxx + blit->cliprect.min_y * incyx; | |
| 1784 | starty += blit->cliprect.min_x * incxy + blit->cliprect.min_y * incyy; | |
| 1328 | // pre-advance based on the cliprect | |
| 1329 | startx += blit.cliprect.min_x * incxx + blit.cliprect.min_y * incyx; | |
| 1330 | starty += blit.cliprect.min_x * incxy + blit.cliprect.min_y * incyy; | |
| 1785 | 1331 | |
| 1786 | /* extract start/end points */ | |
| 1787 | sx = blit->cliprect.min_x; | |
| 1788 | sy = blit->cliprect.min_y; | |
| 1789 | ex = blit->cliprect.max_x; | |
| 1790 | ey = blit->cliprect.max_y; | |
| 1332 | // extract start/end points | |
| 1333 | int sx = blit.cliprect.min_x; | |
| 1334 | int sy = blit.cliprect.min_y; | |
| 1335 | int ex = blit.cliprect.max_x; | |
| 1336 | int ey = blit.cliprect.max_y; | |
| 1791 | 1337 | |
| 1792 | / | |
| 1338 | // optimized loop for the not rotated case | |
| 1793 | 1339 | if (incxy == 0 && incyx == 0 && !wraparound) |
| 1794 | 1340 | { |
| 1795 | / | |
| 1341 | // skip without drawing until we are within the bitmap | |
| 1796 | 1342 | while (startx >= widthshifted && sx <= ex) |
| 1797 | 1343 | { |
| 1798 | 1344 | startx += incxx; |
| 1799 | 1345 | sx++; |
| 1800 | 1346 | } |
| 1801 | 1347 | |
| 1802 | / | |
| 1348 | // early exit if we're done already | |
| 1803 | 1349 | if (sx > ex) |
| 1804 | 1350 | return; |
| 1805 | 1351 | |
| 1806 | / | |
| 1352 | // loop over rows | |
| 1807 | 1353 | while (sy <= ey) |
| 1808 | 1354 | { |
| 1809 | / | |
| 1355 | // only draw if Y is within range | |
| 1810 | 1356 | if (starty < heightshifted) |
| 1811 | 1357 | { |
| 1812 | /* initialize X counters */ | |
| 1813 | x = sx; | |
| 1814 | cx = startx; | |
| 1815 | cy = starty >> 16; | |
| 1358 | // initialize X counters | |
| 1359 | int x = sx; | |
| 1360 | UINT32 cx = startx; | |
| 1361 | UINT32 cy = starty >> 16; | |
| 1816 | 1362 | |
| 1817 | /* get source and priority pointers */ | |
| 1818 | pri = &priority_bitmap.pix8(sy, sx); | |
| 1819 | src = &srcbitmap.pix16(cy); | |
| 1820 | maskptr = &flagsmap.pix8(cy); | |
| 1821 | dest = &destbitmap.pix(sy, sx); | |
| 1363 | // get source and priority pointers | |
| 1364 | UINT8 *pri = &priority_bitmap.pix8(sy, sx); | |
| 1365 | const UINT16 *src = &m_pixmap.pix16(cy); | |
| 1366 | const UINT8 *maskptr = &m_flagsmap.pix8(cy); | |
| 1367 | typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx); | |
| 1822 | 1368 | |
| 1823 | / | |
| 1369 | // loop over columns | |
| 1824 | 1370 | while (x <= ex && cx < widthshifted) |
| 1825 | 1371 | { |
| 1826 | / | |
| 1372 | // plot if we match the mask | |
| 1827 | 1373 | if ((maskptr[cx >> 16] & mask) == value) |
| 1828 | 1374 | { |
| 1829 | 1375 | ROZ_PLOT_PIXEL(src[cx >> 16]); |
| 1830 | 1376 | *pri = (*pri & (priority >> 8)) | priority; |
| 1831 | 1377 | } |
| 1832 | 1378 | |
| 1833 | / | |
| 1379 | // advance in X | |
| 1834 | 1380 | cx += incxx; |
| 1835 | 1381 | x++; |
| 1836 | 1382 | dest++; |
| r14063 | r14064 | |
| 1838 | 1384 | } |
| 1839 | 1385 | } |
| 1840 | 1386 | |
| 1841 | / | |
| 1387 | // advance in Y | |
| 1842 | 1388 | starty += incyy; |
| 1843 | 1389 | sy++; |
| 1844 | 1390 | } |
| 1845 | 1391 | } |
| 1846 | 1392 | |
| 1847 | / | |
| 1393 | // wraparound case | |
| 1848 | 1394 | else if (wraparound) |
| 1849 | 1395 | { |
| 1850 | / | |
| 1396 | // loop over rows | |
| 1851 | 1397 | while (sy <= ey) |
| 1852 | 1398 | { |
| 1853 | /* initialize X counters */ | |
| 1854 | x = sx; | |
| 1855 | cx = startx; | |
| 1856 | cy = starty; | |
| 1399 | // initialize X counters | |
| 1400 | int x = sx; | |
| 1401 | UINT32 cx = startx; | |
| 1402 | UINT32 cy = starty; | |
| 1857 | 1403 | |
| 1858 | /* get dest and priority pointers */ | |
| 1859 | dest = &destbitmap.pix(sy, sx); | |
| 1860 | pri = &priority_bitmap.pix8(sy, sx); | |
| 1404 | // get dest and priority pointers | |
| 1405 | typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx); | |
| 1406 | UINT8 *pri = &priority_bitmap.pix8(sy, sx); | |
| 1861 | 1407 | |
| 1862 | / | |
| 1408 | // loop over columns | |
| 1863 | 1409 | while (x <= ex) |
| 1864 | 1410 | { |
| 1865 | /* plot if we match the mask */ | |
| 1866 | if ((flagsmap.pix8((cy >> 16) & ymask, (cx >> 16) & xmask) & mask) == value) | |
| 1411 | // plot if we match the mask | |
| 1412 | if ((m_flagsmap.pix8((cy >> 16) & ymask, (cx >> 16) & xmask) & mask) == value) | |
| 1867 | 1413 | { |
| 1868 | ROZ_PLOT_PIXEL( | |
| 1414 | ROZ_PLOT_PIXEL(m_p | |
| 1869 | 1415 | *pri = (*pri & (priority >> 8)) | priority; |
| 1870 | 1416 | } |
| 1871 | 1417 | |
| 1872 | / | |
| 1418 | // advance in X | |
| 1873 | 1419 | cx += incxx; |
| 1874 | 1420 | cy += incxy; |
| 1875 | 1421 | x++; |
| r14063 | r14064 | |
| 1877 | 1423 | pri++; |
| 1878 | 1424 | } |
| 1879 | 1425 | |
| 1880 | / | |
| 1426 | // advance in Y | |
| 1881 | 1427 | startx += incyx; |
| 1882 | 1428 | starty += incyy; |
| 1883 | 1429 | sy++; |
| 1884 | 1430 | } |
| 1885 | 1431 | } |
| 1886 | 1432 | |
| 1887 | / | |
| 1433 | // non-wraparound case | |
| 1888 | 1434 | else |
| 1889 | 1435 | { |
| 1890 | / | |
| 1436 | // loop over rows | |
| 1891 | 1437 | while (sy <= ey) |
| 1892 | 1438 | { |
| 1893 | /* initialize X counters */ | |
| 1894 | x = sx; | |
| 1895 | cx = startx; | |
| 1896 | cy = starty; | |
| 1439 | // initialize X counters | |
| 1440 | int x = sx; | |
| 1441 | UINT32 cx = startx; | |
| 1442 | UINT32 cy = starty; | |
| 1897 | 1443 | |
| 1898 | /* get dest and priority pointers */ | |
| 1899 | dest = &destbitmap.pix(sy, sx); | |
| 1900 | pri = &priority_bitmap.pix8(sy, sx); | |
| 1444 | // get dest and priority pointers | |
| 1445 | typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx); | |
| 1446 | UINT8 *pri = &priority_bitmap.pix8(sy, sx); | |
| 1901 | 1447 | |
| 1902 | / | |
| 1448 | // loop over columns | |
| 1903 | 1449 | while (x <= ex) |
| 1904 | 1450 | { |
| 1905 | / | |
| 1451 | // plot if we're within the bitmap and we match the mask | |
| 1906 | 1452 | if (cx < widthshifted && cy < heightshifted) |
| 1907 | if ((flagsmap.pix8(cy >> 16, cx >> 16) & mask) == value) | |
| 1453 | if ((m_flagsmap.pix8(cy >> 16, cx >> 16) & mask) == value) | |
| 1908 | 1454 | { |
| 1909 | ROZ_PLOT_PIXEL( | |
| 1455 | ROZ_PLOT_PIXEL(m_p | |
| 1910 | 1456 | *pri = (*pri & (priority >> 8)) | priority; |
| 1911 | 1457 | } |
| 1912 | 1458 | |
| 1913 | / | |
| 1459 | // advance in X | |
| 1914 | 1460 | cx += incxx; |
| 1915 | 1461 | cy += incxy; |
| 1916 | 1462 | x++; |
| r14063 | r14064 | |
| 1918 | 1464 | pri++; |
| 1919 | 1465 | } |
| 1920 | 1466 | |
| 1921 | / | |
| 1467 | // advance in Y | |
| 1922 | 1468 | startx += incyx; |
| 1923 | 1469 | starty += incyy; |
| 1924 | 1470 | sy++; |
| r14063 | r14064 | |
| 1927 | 1473 | } |
| 1928 | 1474 | |
| 1929 | 1475 | |
| 1930 | /*************************************************************************** | |
| 1931 | SCANLINE RASTERIZERS | |
| 1932 | ***************************************************************************/ | |
| 1476 | //------------------------------------------------- | |
| 1477 | // draw_debug - draw a debug version without any | |
| 1478 | // rowscroll and with fixed parameters | |
| 1479 | //------------------------------------------------- | |
| 1933 | 1480 | |
| 1934 | /*------------------------------------------------- | |
| 1935 | scanline_draw_opaque_null - draw to a NULL | |
| 1936 | bitmap, setting priority only | |
| 1937 | -------------------------------------------------*/ | |
| 1938 | ||
| 1939 | inline void scanline_draw_opaque_null(int count, UINT8 *pri, UINT32 pcode) | |
| 1481 | void tilemap_t::draw_debug(bitmap_rgb32 &dest, UINT32 scrollx, UINT32 scrolly) | |
| 1940 | 1482 | { |
| 1941 | int i; | |
| 1483 | // set up for the blit, using hard-coded parameters (no priority, etc) | |
| 1484 | blit_parameters blit; | |
| 1485 | configure_blit_parameters(blit, dest.cliprect(), TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES, 0, 0xff); | |
| 1942 | 1486 | |
| 1943 | /* skip entirely if not changing priority */ | |
| 1944 | if (pcode != 0xff00) | |
| 1945 | { | |
| 1946 | for (i = 0; i < count; i++) | |
| 1947 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 1948 | } | |
| 1949 | } | |
| 1487 | // compute the effective scroll positions | |
| 1488 | scrollx = m_width - scrollx % m_width; | |
| 1489 | scrolly = m_height - scrolly % m_height; | |
| 1950 | 1490 | |
| 1491 | // flush the dirty state to all tiles as appropriate | |
| 1492 | realize_all_dirty_tiles(); | |
| 1951 | 1493 | |
| 1952 | /*------------------------------------------------- | |
| 1953 | scanline_draw_masked_null - draw to a NULL | |
| 1954 | bitmap using a mask, setting priority only | |
| 1955 | -------------------------------------------------*/ | |
| 1956 | ||
| 1957 | inline void scanline_draw_masked_null(const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode) | |
| 1958 | { | |
| 1959 | int i; | |
| 1960 | ||
| 1961 | /* skip entirely if not changing priority */ | |
| 1962 | if (pcode != 0xff00) | |
| 1963 | { | |
| 1964 | for (i = 0; i < count; i++) | |
| 1965 | if ((maskptr[i] & mask) == value) | |
| 1966 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 1967 | } | |
| 1494 | // iterate to handle wraparound | |
| 1495 | for (int ypos = scrolly - m_height; ypos <= blit.cliprect.max_y; ypos += m_height) | |
| 1496 | for (int xpos = scrollx - m_width; xpos <= blit.cliprect.max_x; xpos += m_width) | |
| 1497 | draw_instance(dest, blit, xpos, ypos); | |
| 1968 | 1498 | } |
| 1969 | 1499 | |
| 1970 | 1500 | |
| 1971 | 1501 | |
| 1972 | /*------------------------------------------------- | |
| 1973 | scanline_draw_opaque_ind16 - draw to a 16bpp | |
| 1974 | indexed bitmap | |
| 1975 | -------------------------------------------------*/ | |
| 1502 | //************************************************************************** | |
| 1503 | // TILEMAP MANAGER | |
| 1504 | //************************************************************************** | |
| 1976 | 1505 | |
| 1977 | inline void scanline_draw_opaque_ind16(UINT16 *dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode) | |
| 1978 | { | |
| 1979 | int pal = pcode >> 16; | |
| 1980 | int i; | |
| 1506 | //------------------------------------------------- | |
| 1507 | // tilemap_manager - constructor | |
| 1508 | //------------------------------------------------- | |
| 1981 | 1509 | |
| 1982 | /* special case for no palette offset */ | |
| 1983 | if (pal == 0) | |
| 1984 | { | |
| 1985 | memcpy(dest, source, count * 2); | |
| 1986 | ||
| 1987 | /* priority if necessary */ | |
| 1988 | if (pcode != 0xff00) | |
| 1989 | { | |
| 1990 | for (i = 0; i < count; i++) | |
| 1991 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 1992 | } | |
| 1993 | } | |
| 1994 | ||
| 1995 | /* priority case */ | |
| 1996 | else if ((pcode & 0xffff) != 0xff00) | |
| 1997 | { | |
| 1998 | for (i = 0; i < count; i++) | |
| 1999 | { | |
| 2000 | dest[i] = source[i] + pal; | |
| 2001 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 2002 | } | |
| 2003 | } | |
| 2004 | ||
| 2005 | /* no priority case */ | |
| 2006 | else | |
| 2007 | { | |
| 2008 | for (i = 0; i < count; i++) | |
| 2009 | dest[i] = source[i] + pal; | |
| 2010 | } | |
| 2011 | } | |
| 2012 | ||
| 2013 | ||
| 2014 | /*------------------------------------------------- | |
| 2015 | scanline_draw_masked_ind16 - draw to a 16bpp | |
| 2016 | indexed bitmap using a mask | |
| 2017 | -------------------------------------------------*/ | |
| 2018 | ||
| 2019 | inline void scanline_draw_masked_ind16(UINT16 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode) | |
| 1510 | tilemap_manager::tilemap_manager(running_machine &machine) | |
| 1511 | : m_machine(machine), | |
| 1512 | m_instance(0) | |
| 2020 | 1513 | { |
| 2021 | int pal = pcode >> 16; | |
| 2022 | int i; | |
| 2023 | ||
| 2024 | /* priority case */ | |
| 2025 | if ((pcode & 0xffff) != 0xff00) | |
| 2026 | { | |
| 2027 | for (i = 0; i < count; i++) | |
| 2028 | if ((maskptr[i] & mask) == value) | |
| 2029 | { | |
| 2030 | dest[i] = source[i] + pal; | |
| 2031 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 2032 | } | |
| 2033 | } | |
| 2034 | ||
| 2035 | /* no priority case */ | |
| 2036 | else | |
| 2037 | { | |
| 2038 | for (i = 0; i < count; i++) | |
| 2039 | if ((maskptr[i] & mask) == value) | |
| 2040 | dest[i] = source[i] + pal; | |
| 2041 | } | |
| 1514 | if (machine.primary_screen == NULL || machine.primary_screen->width() == 0) | |
| 1515 | return; | |
| 1516 | machine.primary_screen->register_screen_bitmap(machine.priority_bitmap); | |
| 2042 | 1517 | } |
| 2043 | 1518 | |
| 2044 | 1519 | |
| 1520 | //------------------------------------------------- | |
| 1521 | // set_flip_all - set a global flip for all the | |
| 1522 | // tilemaps | |
| 1523 | //------------------------------------------------- | |
| 2045 | 1524 | |
| 2046 | /*------------------------------------------------- | |
| 2047 | scanline_draw_opaque_rgb32 - draw to a 32bpp | |
| 2048 | RGB bitmap | |
| 2049 | -------------------------------------------------*/ | |
| 2050 | ||
| 2051 | inline void scanline_draw_opaque_rgb32(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode) | |
| 1525 | tilemap_t &tilemap_manager::create(tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows) | |
| 2052 | 1526 | { |
| 2053 | const pen_t *clut = &pens[pcode >> 16]; | |
| 2054 | int i; | |
| 2055 | ||
| 2056 | /* priority case */ | |
| 2057 | if ((pcode & 0xffff) != 0xff00) | |
| 2058 | { | |
| 2059 | for (i = 0; i < count; i++) | |
| 2060 | { | |
| 2061 | dest[i] = clut[source[i]]; | |
| 2062 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 2063 | } | |
| 2064 | } | |
| 2065 | ||
| 2066 | /* no priority case */ | |
| 2067 | else | |
| 2068 | { | |
| 2069 | for (i = 0; i < count; i++) | |
| 2070 | dest[i] = clut[source[i]]; | |
| 2071 | } | |
| 1527 | return m_tilemap_list.append(*auto_alloc(machine(), tilemap_t(*this, tile_get_info, mapper, tilewidth, tileheight, cols, rows))); | |
| 2072 | 1528 | } |
| 2073 | 1529 | |
| 2074 | ||
| 2075 | /*------------------------------------------------- | |
| 2076 | scanline_draw_masked_rgb32 - draw to a 32bpp | |
| 2077 | RGB bitmap using a mask | |
| 2078 | -------------------------------------------------*/ | |
| 2079 | ||
| 2080 | inline void scanline_draw_masked_rgb32(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode) | |
| 1530 | tilemap_t &tilemap_manager::create(tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows) | |
| 2081 | 1531 | { |
| 2082 | const pen_t *clut = &pens[pcode >> 16]; | |
| 2083 | int i; | |
| 2084 | ||
| 2085 | /* priority case */ | |
| 2086 | if ((pcode & 0xffff) != 0xff00) | |
| 2087 | { | |
| 2088 | for (i = 0; i < count; i++) | |
| 2089 | if ((maskptr[i] & mask) == value) | |
| 2090 | { | |
| 2091 | dest[i] = clut[source[i]]; | |
| 2092 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 2093 | } | |
| 2094 | } | |
| 2095 | ||
| 2096 | /* no priority case */ | |
| 2097 | else | |
| 2098 | { | |
| 2099 | for (i = 0; i < count; i++) | |
| 2100 | if ((maskptr[i] & mask) == value) | |
| 2101 | dest[i] = clut[source[i]]; | |
| 2102 | } | |
| 1532 | return m_tilemap_list.append(*auto_alloc(machine(), tilemap_t(*this, tilemap_get_info_delegate(tile_get_info, "", &machine()), tilemap_mapper_delegate(mapper, "", &machine()), tilewidth, tileheight, cols, rows))); | |
| 2103 | 1533 | } |
| 2104 | 1534 | |
| 2105 | 1535 | |
| 2106 | /*------------------------------------------------- | |
| 2107 | scanline_draw_opaque_rgb32_alpha - draw to a | |
| 2108 | 32bpp RGB bitmap with alpha blending | |
| 2109 | -------------------------------------------------*/ | |
| 1536 | //------------------------------------------------- | |
| 1537 | // set_flip_all - set a global flip for all the | |
| 1538 | // tilemaps | |
| 1539 | //------------------------------------------------- | |
| 2110 | 1540 | |
| 2111 | ||
| 1541 | ||
| 2112 | 1542 | { |
| 2113 | const pen_t *clut = &pens[pcode >> 16]; | |
| 2114 | int i; | |
| 2115 | ||
| 2116 | /* priority case */ | |
| 2117 | if ((pcode & 0xffff) != 0xff00) | |
| 2118 | { | |
| 2119 | for (i = 0; i < count; i++) | |
| 2120 | { | |
| 2121 | dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha); | |
| 2122 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 2123 | } | |
| 2124 | } | |
| 2125 | ||
| 2126 | /* no priority case */ | |
| 2127 | else | |
| 2128 | { | |
| 2129 | for (i = 0; i < count; i++) | |
| 2130 | dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha); | |
| 2131 | } | |
| 1543 | for (tilemap_t *tmap = m_tilemap_list.first(); tmap != NULL; tmap = tmap->next()) | |
| 1544 | tmap->set_flip(attributes); | |
| 2132 | 1545 | } |
| 2133 | 1546 | |
| 2134 | 1547 | |
| 2135 | /*------------------------------------------------- | |
| 2136 | scanline_draw_masked_rgb32_alpha - draw to a | |
| 2137 | 32bpp RGB bitmap using a mask and alpha | |
| 2138 | blending | |
| 2139 | -------------------------------------------------*/ | |
| 1548 | //------------------------------------------------- | |
| 1549 | // mark_all_dirty - mark all the tiles in all the | |
| 1550 | // tilemaps dirty | |
| 1551 | //------------------------------------------------- | |
| 2140 | 1552 | |
| 2141 | ||
| 1553 | ||
| 2142 | 1554 | { |
| 2143 | const pen_t *clut = &pens[pcode >> 16]; | |
| 2144 | int i; | |
| 2145 | ||
| 2146 | /* priority case */ | |
| 2147 | if ((pcode & 0xffff) != 0xff00) | |
| 2148 | { | |
| 2149 | for (i = 0; i < count; i++) | |
| 2150 | if ((maskptr[i] & mask) == value) | |
| 2151 | { | |
| 2152 | dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha); | |
| 2153 | pri[i] = (pri[i] & (pcode >> 8)) | pcode; | |
| 2154 | } | |
| 2155 | } | |
| 2156 | ||
| 2157 | /* no priority case */ | |
| 2158 | else | |
| 2159 | { | |
| 2160 | for (i = 0; i < count; i++) | |
| 2161 | if ((maskptr[i] & mask) == value) | |
| 2162 | dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha); | |
| 2163 | } | |
| 1555 | for (tilemap_t *tmap = m_tilemap_list.first(); tmap != NULL; tmap = tmap->next()) | |
| 1556 | tmap->mark_all_dirty(); | |
| 2164 | 1557 | } |
| r14063 | r14064 | |
|---|---|---|
| 4 | 4 | |
| 5 | 5 | Generic tilemap management system. |
| 6 | 6 | |
| 7 | Copyright Nicola Salmoria and the MAME Team. | |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. | |
| 7 | **************************************************************************** | |
| 9 | 8 | |
| 9 | Copyright Aaron Giles | |
| 10 | All rights reserved. | |
| 11 | ||
| 12 | Redistribution and use in source and binary forms, with or without | |
| 13 | modification, are permitted provided that the following conditions are | |
| 14 | met: | |
| 15 | ||
| 16 | * Redistributions of source code must retain the above copyright | |
| 17 | notice, this list of conditions and the following disclaimer. | |
| 18 | * Redistributions in binary form must reproduce the above copyright | |
| 19 | notice, this list of conditions and the following disclaimer in | |
| 20 | the documentation and/or other materials provided with the | |
| 21 | distribution. | |
| 22 | * Neither the name 'MAME' nor the names of its contributors may be | |
| 23 | used to endorse or promote products derived from this software | |
| 24 | without specific prior written permission. | |
| 25 | ||
| 26 | THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR | |
| 27 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 28 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 29 | DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, | |
| 30 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 31 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 32 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 34 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
| 35 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 36 | POSSIBILITY OF SUCH DAMAGE. | |
| 37 | ||
| 10 | 38 | **************************************************************************** |
| 11 | 39 | |
| 12 | 40 | Core concepts: |
| r14063 | r14064 | |
| 302 | 330 | #define __TILEMAP_H__ |
| 303 | 331 | |
| 304 | 332 | |
| 305 | /*************************************************************************** | |
| 306 | CONSTANTS | |
| 307 | ***************************************************************************/ | |
| 333 | //************************************************************************** | |
| 334 | // CONSTANTS | |
| 335 | //************************************************************************** | |
| 308 | 336 | |
| 309 | / | |
| 337 | // maximum number of groups | |
| 310 | 338 | #define TILEMAP_NUM_GROUPS 256 |
| 311 | 339 | |
| 312 | 340 | |
| 313 | /* these flags control tilemap_draw() behavior */ | |
| 314 | #define TILEMAP_DRAW_CATEGORY_MASK 0x0f /* specify the category to draw */ | |
| 315 | #define TILEMAP_DRAW_CATEGORY(x) (x) /* specify category to draw */ | |
| 316 | #define TILEMAP_DRAW_LAYER0 0x10 /* draw layer 0 */ | |
| 317 | #define TILEMAP_DRAW_LAYER1 0x20 /* draw layer 1 */ | |
| 318 | #define TILEMAP_DRAW_LAYER2 0x40 /* draw layer 2 */ | |
| 319 | #define TILEMAP_DRAW_OPAQUE 0x80 /* draw everything, even transparent stuff */ | |
| 320 | #define TILEMAP_DRAW_ALPHA_FLAG 0x100 /* draw with alpha blending (in the upper 8 bits) */ | |
| 321 | #define TILEMAP_DRAW_ALPHA(x) (TILEMAP_DRAW_ALPHA_FLAG | (rgb_clamp(x) << 24)) | |
| 322 | #define TILEMAP_DRAW_ALL_CATEGORIES 0x200 /* draw all categories */ | |
| 341 | // these flags control tilemap_draw() behavior | |
| 342 | const UINT32 TILEMAP_DRAW_CATEGORY_MASK = 0x0f; // specify the category to draw | |
| 343 | const UINT32 TILEMAP_DRAW_LAYER0 = 0x10; // draw layer 0 | |
| 344 | const UINT32 TILEMAP_DRAW_LAYER1 = 0x20; // draw layer 1 | |
| 345 | const UINT32 TILEMAP_DRAW_LAYER2 = 0x40; // draw layer 2 | |
| 346 | const UINT32 TILEMAP_DRAW_OPAQUE = 0x80; // draw everything, even transparent stuff | |
| 347 | const UINT32 TILEMAP_DRAW_ALPHA_FLAG = 0x100; // draw with alpha blending (in the upper 8 bits) | |
| 348 | const UINT32 TILEMAP_DRAW_ALL_CATEGORIES = 0x200; // draw all categories | |
| 323 | 349 | |
| 350 | // per-pixel flags in the transparency_bitmap | |
| 351 | const UINT8 TILEMAP_PIXEL_CATEGORY_MASK = 0x0f; // category is stored in the low 4 bits | |
| 352 | const UINT8 TILEMAP_PIXEL_TRANSPARENT = 0x00; // transparent if in none of the layers below | |
| 353 | const UINT8 TILEMAP_PIXEL_LAYER0 = 0x10; // pixel is opaque in layer 0 | |
| 354 | const UINT8 TILEMAP_PIXEL_LAYER1 = 0x20; // pixel is opaque in layer 1 | |
| 355 | const UINT8 TILEMAP_PIXEL_LAYER2 = 0x40; // pixel is opaque in layer 2 | |
| 324 | 356 | |
| 325 | /* per-pixel flags in the transparency_bitmap */ | |
| 326 | #define TILEMAP_PIXEL_CATEGORY_MASK 0x0f /* category is stored in the low 4 bits */ | |
| 327 | #define TILEMAP_PIXEL_TRANSPARENT 0x00 /* transparent if in none of the layers below */ | |
| 328 | #define TILEMAP_PIXEL_LAYER0 0x10 /* pixel is opaque in layer 0 */ | |
| 329 | #define TILEMAP_PIXEL_LAYER1 0x20 /* pixel is opaque in layer 1 */ | |
| 330 | #define TILEMAP_PIXEL_LAYER2 0x40 /* pixel is opaque in layer 2 */ | |
| 357 | // per-tile flags, set by get_tile_info callback | |
| 358 | const UINT8 TILE_FLIPX = 0x01; // draw this tile horizontally flipped | |
| 359 | const UINT8 TILE_FLIPY = 0x02; // draw this tile vertically flipped | |
| 360 | const UINT8 TILE_4BPP = 0x04; // tile data is packed 4bpp | |
| 361 | const UINT8 TILE_FORCE_LAYER0 = TILEMAP_PIXEL_LAYER0; // force all pixels to be layer 0 (no transparency) | |
| 362 | const UINT8 TILE_FORCE_LAYER1 = TILEMAP_PIXEL_LAYER1; // force all pixels to be layer 1 (no transparency) | |
| 363 | const UINT8 TILE_FORCE_LAYER2 = TILEMAP_PIXEL_LAYER2; // force all pixels to be layer 2 (no transparency) | |
| 331 | 364 | |
| 365 | // tilemap global flags, used by tilemap_set_flip() | |
| 366 | const UINT32 TILEMAP_FLIPX = TILE_FLIPX; // draw the tilemap horizontally flipped | |
| 367 | const UINT32 TILEMAP_FLIPY = TILE_FLIPY; // draw the tilemap vertically flipped | |
| 332 | 368 | |
| 333 | /* per-tile flags, set by get_tile_info callback */ | |
| 334 | #define TILE_FLIPX 0x01 /* draw this tile horizontally flipped */ | |
| 335 | #define TILE_FLIPY 0x02 /* draw this tile vertically flipped */ | |
| 336 | #define TILE_4BPP 0x04 /* tile data is packed 4bpp */ | |
| 337 | #define TILE_FORCE_LAYER0 TILEMAP_PIXEL_LAYER0 /* force all pixels to be layer 0 (no transparency) */ | |
| 338 | #define TILE_FORCE_LAYER1 TILEMAP_PIXEL_LAYER1 /* force all pixels to be layer 1 (no transparency) */ | |
| 339 | #define TILE_FORCE_LAYER2 TILEMAP_PIXEL_LAYER2 /* force all pixels to be layer 2 (no transparency) */ | |
| 369 | // set this value for a scroll row/column to fully disable it | |
| 370 | const UINT32 TILE_LINE_DISABLED = 0x80000000; | |
| 340 | 371 | |
| 341 | 372 | |
| 342 | /* tilemap global flags, used by tilemap_set_flip() */ | |
| 343 | #define TILEMAP_FLIPX TILE_FLIPX /* draw the tilemap horizontally flipped */ | |
| 344 | #define TILEMAP_FLIPY TILE_FLIPY /* draw the tilemap vertically flipped */ | |
| 345 | 373 | |
| 374 | //************************************************************************** | |
| 375 | // TYPE DEFINITIONS | |
| 376 | //************************************************************************** | |
| 346 | 377 | |
| 347 | /* set this value for a scroll row/column to fully disable it */ | |
| 348 | #define TILE_LINE_DISABLED 0x80000000 | |
| 378 | // forward declarations | |
| 379 | class tilemap_t; | |
| 380 | class tilemap_manager; | |
| 349 | 381 | |
| 350 | 382 | |
| 383 | // global types | |
| 384 | typedef UINT32 tilemap_memory_index; | |
| 351 | 385 | |
| 352 | /*************************************************************************** | |
| 353 | MACROS | |
| 354 | ***************************************************************************/ | |
| 355 | 386 | |
| 356 | /* function definition for a get info callback */ | |
| 357 | #define TILE_GET_INFO(_name) void _name(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param) | |
| 358 | #define TILE_GET_INFO_DEVICE(_name) void _name(device_t *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param) | |
| 387 | // tile_data is filled in by the get_tile_info callback | |
| 388 | struct tile_data | |
| 389 | { | |
| 390 | const UINT8 * pen_data; // required | |
| 391 | const UINT8 * mask_data; // required | |
| 392 | pen_t palette_base; // defaults to 0 | |
| 393 | UINT8 category; // defaults to 0; range from 0..15 | |
| 394 | UINT8 group; // defaults to 0; range from 0..TILEMAP_NUM_GROUPS | |
| 395 | UINT8 flags; // defaults to 0; one or more of TILE_* flags above | |
| 396 | UINT8 pen_mask; // defaults to 0xff; mask to apply to pen_data while rendering the tile | |
| 397 | UINT8 gfxnum; // defaults to 0xff; specify index of machine.gfx for auto-invalidation on dirty | |
| 359 | 398 | |
| 360 | /* function definition for a logical-to-memory mapper */ | |
| 361 | #define TILEMAP_MAPPER(_name) tilemap_memory_index _name(UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows) | |
| 399 | void set(running_machine &machine, int _gfxnum, int rawcode, int rawcolor, int _flags) | |
| 400 | { | |
| 401 | const gfx_element *gfx = machine.gfx[_gfxnum]; | |
| 402 | int code = rawcode % gfx->total_elements; | |
| 403 | pen_data = gfx_element_get_data(gfx, code); | |
| 404 | palette_base = gfx->color_base + gfx->color_granularity * rawcolor; | |
| 405 | flags = _flags; | |
| 406 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 407 | flags |= TILE_4BPP; | |
| 408 | gfxnum = _gfxnum; | |
| 409 | } | |
| 410 | }; | |
| 362 | 411 | |
| 363 | /* useful macro inside of a TILE_GET_INFO callback to set tile information */ | |
| 364 | #define SET_TILE_INFO(GFX,CODE,COLOR,FLAGS) tileinfo_set(machine, tileinfo, GFX, CODE, COLOR, FLAGS) | |
| 365 | #define SET_TILE_INFO_DEVICE(GFX,CODE,COLOR,FLAGS) tileinfo_set(device->machine(), tileinfo, GFX, CODE, COLOR, FLAGS) | |
| 366 | 412 | |
| 367 | /* Macros for setting tile attributes in the TILE_GET_INFO callback: */ | |
| 368 | /* TILE_FLIP_YX assumes that flipy is in bit 1 and flipx is in bit 0 */ | |
| 369 | /* TILE_FLIP_XY assumes that flipy is in bit 0 and flipx is in bit 1 */ | |
| 370 | #define TILE_FLIPYX(YX) ((YX) & 3) | |
| 371 | #define TILE_FLIPXY(XY) ((((XY) & 2) >> 1) | (((XY) & 1) << 1)) | |
| 413 | // modern delegates | |
| 414 | typedef delegate<void (tile_data *, tilemap_memory_index, void *)> tilemap_get_info_delegate; | |
| 415 | typedef delegate<tilemap_memory_index (UINT32, UINT32, UINT32, UINT32)> tilemap_mapper_delegate; | |
| 372 | 416 | |
| 373 | 417 | |
| 418 | // legacy callbacks | |
| 419 | typedef void (*tile_get_info_func)(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param); | |
| 420 | typedef void (*tile_get_info_device_func)(device_t *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param); | |
| 421 | typedef tilemap_memory_index (*tilemap_mapper_func)(running_machine &machine, UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows); | |
| 374 | 422 | |
| 375 | /*************************************************************************** | |
| 376 | TYPE DEFINITIONS | |
| 377 | ***************************************************************************/ | |
| 378 | 423 | |
| 379 | /* memory indexes are unsigned integers */ | |
| 380 | typedef UINT32 tilemap_memory_index; | |
| 424 | // core tilemap structure | |
| 425 | class tilemap_t | |
| 426 | { | |
| 427 | DISABLE_COPYING(tilemap_t); | |
| 428 | ||
| 429 | friend class tilemap_manager; | |
| 430 | friend class simple_list<tilemap_t>; | |
| 431 | friend resource_pool_object<tilemap_t>::~resource_pool_object(); | |
| 381 | 432 | |
| 382 | /* opaque tilemap definition */ | |
| 383 | class tilemap_t; | |
| 433 | // logical index | |
| 434 | typedef UINT32 logical_index; | |
| 384 | 435 | |
| 436 | // internal usage to mark tiles dirty | |
| 437 | static const UINT8 TILE_FLAG_DIRTY = 0xff; | |
| 385 | 438 | |
| 386 | /* tile_data is filled in by the get_tile_info callback */ | |
| 387 | typedef struct _tile_data tile_data; | |
| 388 | struct _tile_data | |
| 389 | { | |
| 390 | const UINT8 * pen_data; /* required */ | |
| 391 | const UINT8 * mask_data; /* required */ | |
| 392 | pen_t palette_base; /* defaults to 0 */ | |
| 393 | UINT8 category; /* defaults to 0; range from 0..15 */ | |
| 394 | UINT8 group; /* defaults to 0; range from 0..TILEMAP_NUM_GROUPS */ | |
| 395 | UINT8 flags; /* defaults to 0; one or more of TILE_* flags above */ | |
| 396 | UINT8 pen_mask; /* defaults to 0xff; mask to apply to pen_data while rendering the tile */ | |
| 397 | UINT8 gfxnum; /* defaults to 0xff; specify index of machine.gfx for auto-invalidation on dirty */ | |
| 439 | // invalid logical index | |
| 440 | static const logical_index INVALID_LOGICAL_INDEX = (logical_index)~0; | |
| 441 | ||
| 442 | // maximum index in each array | |
| 443 | static const int MAX_PEN_TO_FLAGS = 256; | |
| 444 | ||
| 445 | // tilemap_manager controlls our allocations | |
| 446 | tilemap_t(tilemap_manager &manager, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows); | |
| 447 | ~tilemap_t(); | |
| 448 | ||
| 449 | public: | |
| 450 | // getters | |
| 451 | running_machine &machine() const; | |
| 452 | tilemap_t *next() const { return m_next; } | |
| 453 | UINT32 width() const { return m_width; } | |
| 454 | UINT32 height() const { return m_height; } | |
| 455 | bool enabled() const { return m_enable; } | |
| 456 | int scrolldx() const { return (m_attributes & TILEMAP_FLIPX) ? m_dx_flipped : m_dx; } | |
| 457 | int scrolldy() const { return (m_attributes & TILEMAP_FLIPY) ? m_dy_flipped : m_dy; } | |
| 458 | int scrollx(int which = 0) const { return (which < m_scrollrows) ? m_rowscroll[which] : 0; } | |
| 459 | int scrolly(int which = 0) const { return (which < m_scrollcols) ? m_colscroll[which] : 0; } | |
| 460 | bitmap_ind16 &pixmap() { pixmap_update(); return m_pixmap; } | |
| 461 | bitmap_ind8 &flagsmap() { pixmap_update(); return m_flagsmap; } | |
| 462 | UINT8 *tile_flags() { pixmap_update(); return m_tileflags; } | |
| 463 | tilemap_memory_index memory_index(UINT32 col, UINT32 row) { return m_mapper(col, row, m_cols, m_rows); } | |
| 464 | ||
| 465 | // setters | |
| 466 | void set_user_data(void *user_data) { m_user_data = user_data; } | |
| 467 | void set_palette_offset(UINT32 offset) { m_palette_offset = offset; } | |
| 468 | void set_enable(bool enable) { m_enable = enable; } | |
| 469 | void set_scrolldx(int dx, int dx_flipped) { m_dx = dx; m_dx_flipped = dx_flipped; } | |
| 470 | void set_scrolldy(int dy, int dy_flipped) { m_dy = dy; m_dy_flipped = dy_flipped; } | |
| 471 | void set_scrollx(int which, int value) { if (which < m_scrollrows) m_rowscroll[which] = value; } | |
| 472 | void set_scrolly(int which, int value) { if (which < m_scrollcols) m_colscroll[which] = value; } | |
| 473 | void set_scrollx(int value) { set_scrollx(0, value); } | |
| 474 | void set_scrolly(int value) { set_scrolly(0, value); } | |
| 475 | void set_scroll_rows(UINT32 scroll_rows) { assert(scroll_rows <= m_height); m_scrollrows = scroll_rows; } | |
| 476 | void set_scroll_cols(UINT32 scroll_cols) { assert(scroll_cols <= m_width); m_scrollcols = scroll_cols; } | |
| 477 | void set_flip(UINT32 attributes) { if (m_attributes != attributes) { m_attributes = attributes; mappings_update(); } } | |
| 478 | ||
| 479 | // dirtying | |
| 480 | void mark_tile_dirty(tilemap_memory_index memindex); | |
| 481 | void mark_all_dirty() { m_all_tiles_dirty = true; m_all_tiles_clean = false; } | |
| 482 | ||
| 483 | // pen mapping | |
| 484 | void map_pens_to_layer(int group, pen_t pen, pen_t mask, UINT8 layermask); | |
| 485 | void map_pen_to_layer(int group, pen_t pen, UINT8 layermask) { map_pens_to_layer(group, pen, ~0, layermask); } | |
| 486 | void set_transparent_pen(pen_t pen); | |
| 487 | void set_transmask(int group, UINT32 fgmask, UINT32 bgmask); | |
| 488 | ||
| 489 | // drawing | |
| 490 | void draw(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask = 0xff); | |
| 491 | void draw(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask = 0xff); | |
| 492 | void draw_roz(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask = 0xff); | |
| 493 | void draw_roz(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask = 0xff); | |
| 494 | void draw_debug(bitmap_rgb32 &dest, UINT32 scrollx, UINT32 scrolly); | |
| 495 | ||
| 496 | private: | |
| 497 | // internal set of transparency states for rendering | |
| 498 | enum trans_t | |
| 499 | { | |
| 500 | WHOLLY_TRANSPARENT, | |
| 501 | WHOLLY_OPAQUE, | |
| 502 | MASKED | |
| 503 | }; | |
| 504 | ||
| 505 | // blitting parameters for rendering | |
| 506 | struct blit_parameters | |
| 507 | { | |
| 508 | rectangle cliprect; | |
| 509 | UINT32 tilemap_priority_code; | |
| 510 | UINT8 mask; | |
| 511 | UINT8 value; | |
| 512 | UINT8 alpha; | |
| 513 | }; | |
| 514 | ||
| 515 | // inline helpers | |
| 516 | INT32 effective_rowscroll(int index, UINT32 screen_width); | |
| 517 | INT32 effective_colscroll(int index, UINT32 screen_height); | |
| 518 | bool gfx_elements_changed(); | |
| 519 | ||
| 520 | // inline scanline rasterizers | |
| 521 | void scanline_draw_opaque_null(int count, UINT8 *pri, UINT32 pcode); | |
| 522 | void scanline_draw_masked_null(const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode); | |
| 523 | void scanline_draw_opaque_ind16(UINT16 *dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode); | |
| 524 | void scanline_draw_masked_ind16(UINT16 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode); | |
| 525 | void scanline_draw_opaque_rgb32(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode); | |
| 526 | void scanline_draw_masked_rgb32(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode); | |
| 527 | void scanline_draw_opaque_rgb32_alpha(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha); | |
| 528 | void scanline_draw_masked_rgb32_alpha(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha); | |
| 529 | ||
| 530 | // internal helpers | |
| 531 | void postload(); | |
| 532 | void mappings_create(); | |
| 533 | void mappings_update(); | |
| 534 | void realize_all_dirty_tiles(); | |
| 535 | ||
| 536 | // internal drawing | |
| 537 | void pixmap_update(); | |
| 538 | void tile_update(logical_index logindex, UINT32 col, UINT32 row); | |
| 539 | UINT8 tile_draw(const UINT8 *pendata, UINT32 x0, UINT32 y0, UINT32 palette_base, UINT8 category, UINT8 group, UINT8 flags, UINT8 pen_mask); | |
| 540 | UINT8 tile_apply_bitmask(const UINT8 *maskdata, UINT32 x0, UINT32 y0, UINT8 category, UINT8 flags); | |
| 541 | void configure_blit_parameters(blit_parameters &blit, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask); | |
| 542 | template<class _BitmapClass> void draw_common(_BitmapClass &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask); | |
| 543 | template<class _BitmapClass> void draw_roz_common(_BitmapClass &dest, const rectangle &cliprect, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask); | |
| 544 | template<class _BitmapClass> void draw_instance(_BitmapClass &dest, const blit_parameters &blit, int xpos, int ypos); | |
| 545 | template<class _BitmapClass> void draw_roz_core(_BitmapClass &destbitmap, const blit_parameters &blit, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound); | |
| 546 | ||
| 547 | // basic tilemap metrics | |
| 548 | tilemap_t * m_next; // pointer to next tilemap | |
| 549 | UINT32 m_rows; // number of tile rows | |
| 550 | UINT32 m_cols; // number of tile columns | |
| 551 | UINT32 m_tilewidth; // width of a single tile in pixels | |
| 552 | UINT32 m_tileheight; // height of a single tile in pixels | |
| 553 | UINT32 m_width; // width of the full tilemap in pixels | |
| 554 | UINT32 m_height; // height of the full tilemap in pixels | |
| 555 | ||
| 556 | // logical <-> memory mappings | |
| 557 | tilemap_mapper_delegate m_mapper; // callback to map a row/column to a memory index | |
| 558 | logical_index * m_memory_to_logical; // map from memory index to logical index | |
| 559 | logical_index m_max_logical_index; // maximum valid logical index | |
| 560 | tilemap_memory_index * m_logical_to_memory; // map from logical index to memory index | |
| 561 | tilemap_memory_index m_max_memory_index; // maximum valid memory index | |
| 562 | ||
| 563 | // callback to interpret video RAM for the tilemap | |
| 564 | tilemap_get_info_delegate m_tile_get_info; // callback to get information about a tile | |
| 565 | tile_data m_tileinfo; // structure to hold the data for a tile | |
| 566 | void * m_user_data; // user data value passed to the callback | |
| 567 | ||
| 568 | // global tilemap states | |
| 569 | bool m_enable; // true if we are enabled | |
| 570 | UINT8 m_attributes; // global attributes (flipx/y) | |
| 571 | bool m_all_tiles_dirty; // true if all tiles are dirty | |
| 572 | bool m_all_tiles_clean; // true if all tiles are clean | |
| 573 | UINT32 m_palette_offset; // palette offset | |
| 574 | UINT32 m_pen_data_offset; // pen data offset | |
| 575 | UINT32 m_gfx_used; // bitmask of gfx items used | |
| 576 | UINT32 m_gfx_dirtyseq[MAX_GFX_ELEMENTS]; // dirtyseq values from last check | |
| 577 | ||
| 578 | // scroll information | |
| 579 | UINT32 m_scrollrows; // number of independently scrolled rows | |
| 580 | UINT32 m_scrollcols; // number of independently scrolled colums | |
| 581 | INT32 * m_rowscroll; // array of rowscroll values | |
| 582 | INT32 * m_colscroll; // array of colscroll values | |
| 583 | INT32 m_dx; // global horizontal scroll offset | |
| 584 | INT32 m_dx_flipped; // global horizontal scroll offset when flipped | |
| 585 | INT32 m_dy; // global vertical scroll offset | |
| 586 | INT32 m_dy_flipped; // global vertical scroll offset when flipped | |
| 587 | ||
| 588 | // pixel data | |
| 589 | bitmap_ind16 m_pixmap; // cached pixel data | |
| 590 | ||
| 591 | // transparency mapping | |
| 592 | bitmap_ind8 m_flagsmap; // per-pixel flags | |
| 593 | UINT8 * m_tileflags; // per-tile flags | |
| 594 | UINT8 m_pen_to_flags[MAX_PEN_TO_FLAGS * TILEMAP_NUM_GROUPS]; // mapping of pens to flags | |
| 595 | ||
| 596 | private: | |
| 597 | tilemap_manager & m_manager; // reference to the owning manager | |
| 398 | 598 | }; |
| 399 | 599 | |
| 400 | 600 | |
| 401 | /* callback function to get info about a tile */ | |
| 402 | typedef void (*tile_get_info_func)(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param); | |
| 403 | typedef void (*tile_get_info_device_func)(device_t *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param); | |
| 601 | // tilemap manager | |
| 602 | class tilemap_manager | |
| 603 | { | |
| 604 | friend class tilemap_t; | |
| 404 | 605 | |
| 405 | /* callback function to map a column,row pair to a memory index */ | |
| 406 | typedef tilemap_memory_index (*tilemap_mapper_func)(UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows); | |
| 606 | public: | |
| 607 | // construction/destuction | |
| 608 | tilemap_manager(running_machine &machine); | |
| 609 | ||
| 610 | // getters | |
| 611 | running_machine &machine() const { return m_machine; } | |
| 612 | ||
| 613 | // tilemap creation | |
| 614 | tilemap_t &create(tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows); | |
| 615 | tilemap_t &create(tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows); | |
| 407 | 616 | |
| 617 | // tilemap list information | |
| 618 | tilemap_t *find(int index) { return m_tilemap_list.find(index); } | |
| 619 | int count() const { return m_tilemap_list.count(); } | |
| 408 | 620 | |
| 621 | // global operations on all tilemaps | |
| 622 | void mark_all_dirty(); | |
| 623 | void set_flip_all(UINT32 attributes); | |
| 409 | 624 | |
| 410 | /*************************************************************************** | |
| 411 | FUNCTION PROTOTYPES | |
| 412 | ***************************************************************************/ | |
| 625 | private: | |
| 626 | // allocate an instance index | |
| 627 | int alloc_instance() { return ++m_instance; } | |
| 413 | 628 | |
| 629 | // internal state | |
| 630 | running_machine & m_machine; | |
| 631 | simple_list<tilemap_t> m_tilemap_list; | |
| 632 | int m_instance; | |
| 633 | }; | |
| 414 | 634 | |
| 415 | /* ----- system-wide management ----- */ | |
| 416 | 635 | |
| 417 | /* initialize the tilemap system -- not for use by drivers */ | |
| 418 | void tilemap_init(running_machine &machine); | |
| 419 | 636 | |
| 637 | //************************************************************************** | |
| 638 | // MACROS | |
| 639 | //************************************************************************** | |
| 420 | 640 | |
| 641 | // macros to help form flags for tilemap_draw | |
| 642 | #define TILEMAP_DRAW_CATEGORY(x) (x) // specify category to draw | |
| 643 | #define TILEMAP_DRAW_ALPHA(x) (TILEMAP_DRAW_ALPHA_FLAG | (rgb_clamp(x) << 24)) | |
| 421 | 644 | |
| 422 | /* ----- tilemap creation and configuration ----- */ | |
| 645 | // function definition for a get info callback | |
| 646 | #define TILE_GET_INFO(_name) void _name(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param) | |
| 647 | #define TILE_GET_INFO_DEVICE(_name) void _name(device_t *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param) | |
| 423 | 648 | |
| 424 | /* create a new tilemap; note that tilemaps are tracked by the core so there is no dispose */ | |
| 425 | tilemap_t *tilemap_create(running_machine &machine, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows); | |
| 649 | // function definition for a logical-to-memory mapper | |
| 650 | #define TILEMAP_MAPPER(_name) tilemap_memory_index _name(running_machine &machine, UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows) | |
| 426 | 651 | |
| 427 | /* create a new tilemap that is owned by a device */ | |
| 428 | tilemap_t *tilemap_create_device(device_t *device, tile_get_info_device_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows); | |
| 652 | // useful macro inside of a TILE_GET_INFO callback to set tile information | |
| 653 | #define SET_TILE_INFO(GFX,CODE,COLOR,FLAGS) tileinfo_set(machine, tileinfo, GFX, CODE, COLOR, FLAGS) | |
| 654 | #define SET_TILE_INFO_DEVICE(GFX,CODE,COLOR,FLAGS) tileinfo_set(device->machine(), tileinfo, GFX, CODE, COLOR, FLAGS) | |
| 429 | 655 | |
| 430 | /* specify a parameter to be passed into the tile_get_info callback */ | |
| 431 | void tilemap_set_user_data(tilemap_t *tmap, void *user_data); | |
| 656 | // Macros for setting tile attributes in the TILE_GET_INFO callback: | |
| 657 | // TILE_FLIP_YX assumes that flipy is in bit 1 and flipx is in bit 0 | |
| 658 | // TILE_FLIP_XY assumes that flipy is in bit 0 and flipx is in bit 1 | |
| 659 | #define TILE_FLIPYX(YX) ((YX) & 3) | |
| 660 | #define TILE_FLIPXY(XY) ((((XY) & 2) >> 1) | (((XY) & 1) << 1)) | |
| 432 | 661 | |
| 433 | /* specify an offset to be added to each pixel before looking up the palette. | |
| 434 | * The offset only applies at final rendering time (e.g., tilemap_draw()) | |
| 435 | * It does not apply to the cached pixmap, which is provided by tilemap_get_pixmap(). | |
| 436 | */ | |
| 437 | void tilemap_set_palette_offset(tilemap_t *tmap, UINT32 offset); | |
| 438 | 662 | |
| 439 | /* set an enable flag for the tilemap; if 0, requests to draw the tilemap are ignored */ | |
| 440 | void tilemap_set_enable(tilemap_t *tmap, int enable); | |
| 441 | 663 | |
| 442 | /* return enable flag for the tilemap */ | |
| 443 | int tilemap_get_enable(tilemap_t *tmap); | |
| 664 | //************************************************************************** | |
| 665 | // FUNCTION PROTOTYPES | |
| 666 | //************************************************************************** | |
| 444 | 667 | |
| 445 | /* set a global flip for the tilemap */ | |
| 446 | void tilemap_set_flip(tilemap_t *tmap, UINT32 attributes); | |
| 447 | 668 | |
| 448 | /* set a global flip for all tilemaps */ | |
| 449 | void tilemap_set_flip_all(running_machine &machine, UINT32 attributes); | |
| 669 | // ----- tilemap creation and configuration ----- | |
| 450 | 670 | |
| 671 | // create a new tilemap; note that tilemaps are tracked by the core so there is no dispose | |
| 672 | inline tilemap_t *tilemap_create(running_machine &machine, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows) | |
| 673 | { return &machine.tilemap().create(tilemap_get_info_delegate(tile_get_info, "", &machine), tilemap_mapper_delegate(mapper, "", &machine), tilewidth, tileheight, cols, rows); } | |
| 451 | 674 | |
| 675 | // create a new tilemap that is owned by a device | |
| 676 | inline tilemap_t *tilemap_create_device(device_t *device, tile_get_info_device_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows) | |
| 677 | { return &device->machine().tilemap().create(tilemap_get_info_delegate(tile_get_info, "", device), tilemap_mapper_delegate(mapper, "", &device->machine()), tilewidth, tileheight, cols, rows); } | |
| 452 | 678 | |
| 453 | /* ----- dirty tile marking ----- */ | |
| 679 | // specify a parameter to be passed into the tile_get_info callback | |
| 680 | inline void tilemap_set_user_data(tilemap_t *tmap, void *user_data) | |
| 681 | { tmap->set_user_data(user_data); } | |
| 454 | 682 | |
| 455 | /* mark a single tile dirty based on its memory index */ | |
| 456 | void tilemap_mark_tile_dirty(tilemap_t *tmap, tilemap_memory_index memory_index); | |
| 683 | // specify an offset to be added to each pixel before looking up the palette. | |
| 684 | inline void tilemap_set_palette_offset(tilemap_t *tmap, UINT32 offset) | |
| 685 | { tmap->set_palette_offset(offset); } | |
| 457 | 686 | |
| 458 | /* mark all the tiles dirty in a tilemap */ | |
| 459 | void tilemap_mark_all_tiles_dirty(tilemap_t *tmap); | |
| 687 | // set an enable flag for the tilemap; if 0, requests to draw the tilemap are ignored | |
| 688 | inline void tilemap_set_enable(tilemap_t *tmap, int enable) | |
| 689 | { tmap->set_enable(enable); } | |
| 460 | 690 | |
| 461 | /* mark all the tiles dirty in all tilemaps */ | |
| 462 | void tilemap_mark_all_tiles_dirty_all(running_machine &machine); | |
| 691 | // return enable flag for the tilemap | |
| 692 | inline int tilemap_get_enable(tilemap_t *tmap) | |
| 693 | { return tmap->enabled(); } | |
| 463 | 694 | |
| 695 | // set a global flip for the tilemap | |
| 696 | inline void tilemap_set_flip(tilemap_t *tmap, UINT32 attributes) | |
| 697 | { tmap->set_flip(attributes); } | |
| 464 | 698 | |
| 699 | // set a global flip for all tilemaps | |
| 700 | inline void tilemap_set_flip_all(running_machine &machine, UINT32 attributes) | |
| 701 | { machine.tilemap().set_flip_all(attributes); } | |
| 465 | 702 | |
| 466 | /* ----- pen-to-layer mapping ----- */ | |
| 467 | 703 | |
| 468 | /* specify the mapping of one or more pens (where (<pen> & mask == pen) to a layer */ | |
| 469 | void tilemap_map_pens_to_layer(tilemap_t *tmap, int group, pen_t pen, pen_t mask, UINT8 layermask); | |
| 470 | 704 | |
| 471 | /* set a single transparent pen into the tilemap, mapping all other pens to layer 0 */ | |
| 472 | void tilemap_set_transparent_pen(tilemap_t *tmap, pen_t pen); | |
| 705 | // ----- dirty tile marking ----- | |
| 473 | 706 | |
| 474 | /* set up the first 32 pens using a foreground (layer 0) mask and a background (layer 1) mask */ | |
| 475 | void tilemap_set_transmask(tilemap_t *tmap, int group, UINT32 fgmask, UINT32 bgmask); | |
| 707 | // mark a single tile dirty based on its memory index | |
| 708 | inline void tilemap_mark_tile_dirty(tilemap_t *tmap, tilemap_memory_index memory_index) | |
| 709 | { tmap->mark_tile_dirty(memory_index); } | |
| 476 | 710 | |
| 711 | // mark all the tiles dirty in a tilemap | |
| 712 | inline void tilemap_mark_all_tiles_dirty(tilemap_t *tmap) | |
| 713 | { tmap->mark_all_dirty(); } | |
| 477 | 714 | |
| 715 | // mark all the tiles dirty in all tilemaps | |
| 716 | inline void tilemap_mark_all_tiles_dirty_all(running_machine &machine) | |
| 717 | { machine.tilemap().mark_all_dirty(); } | |
| 478 | 718 | |
| 479 | /* ----- tilemap scrolling ----- */ | |
| 480 | 719 | |
| 481 | /* specify the number of independently scrollable row units; each unit covers height/scroll_rows pixels */ | |
| 482 | void tilemap_set_scroll_rows(tilemap_t *tmap, UINT32 scroll_rows); | |
| 483 | 720 | |
| 484 | /* specify the number of independently scrollable column units; each unit covers width/scroll_cols pixels */ | |
| 485 | void tilemap_set_scroll_cols(tilemap_t *tmap, UINT32 scroll_cols); | |
| 721 | // ----- pen-to-layer mapping ----- | |
| 486 | 722 | |
| 487 | /* specify global horizontal and vertical scroll offsets, for non-flipped and flipped cases */ | |
| 488 | void tilemap_set_scrolldx(tilemap_t *tmap, int dx, int dx_if_flipped); | |
| 489 | void tilemap_set_scrolldy(tilemap_t *tmap, int dy, int dy_if_flipped); | |
| 723 | // specify the mapping of one or more pens (where (<pen> & mask == pen) to a layer | |
| 724 | inline void tilemap_map_pens_to_layer(tilemap_t *tmap, int group, pen_t pen, pen_t mask, UINT8 layermask) | |
| 725 | { tmap->map_pens_to_layer(group, pen, mask, layermask); } | |
| 490 | 726 | |
| 491 | /* return the global horizontal or vertical scroll offset, based on current flip state */ | |
| 492 | int tilemap_get_scrolldx(tilemap_t *tmap); | |
| 493 | int tilemap_get_scrolldy(tilemap_t *tmap); | |
| 727 | // set a single transparent pen into the tilemap, mapping all other pens to layer 0 | |
| 728 | inline void tilemap_set_transparent_pen(tilemap_t *tmap, pen_t pen) | |
| 729 | { tmap->set_transparent_pen(pen); } | |
| 494 | 730 | |
| 495 | /* specify the scroll value for a row/column unit */ | |
| 496 | void tilemap_set_scrollx(tilemap_t *tmap, int row, int value); | |
| 497 | void tilemap_set_scrolly(tilemap_t *tmap, int col, int value); | |
| 731 | // set up the first 32 pens using a foreground (layer 0) mask and a background (layer 1) mask | |
| 732 | inline void tilemap_set_transmask(tilemap_t *tmap, int group, UINT32 fgmask, UINT32 bgmask) | |
| 733 | { tmap->set_transmask(group, fgmask, bgmask); } | |
| 498 | 734 | |
| 499 | /* return the scroll value for a row/column unit */ | |
| 500 | int tilemap_get_scrollx(tilemap_t *tmap, int row); | |
| 501 | int tilemap_get_scrolly(tilemap_t *tmap, int col); | |
| 502 | 735 | |
| 503 | 736 | |
| 737 | // ----- tilemap scrolling ----- | |
| 504 | 738 | |
| 505 | /* ----- internal map access ----- */ | |
| 739 | // specify the number of independently scrollable row units; each unit covers height/scroll_rows pixels | |
| 740 | inline void tilemap_set_scroll_rows(tilemap_t *tmap, UINT32 scroll_rows) | |
| 741 | { tmap->set_scroll_rows(scroll_rows); } | |
| 506 | 742 | |
| 507 | /* return a pointer to the (updated) internal pixmap for a tilemap */ | |
| 508 | bitmap_ind16 &tilemap_get_pixmap(tilemap_t *tmap); | |
| 743 | // specify the number of independently scrollable column units; each unit covers width/scroll_cols pixels | |
| 744 | inline void tilemap_set_scroll_cols(tilemap_t *tmap, UINT32 scroll_cols) | |
| 745 | { tmap->set_scroll_cols(scroll_cols); } | |
| 509 | 746 | |
| 510 | /* return a pointer to the (updated) internal flagsmap for a tilemap */ | |
| 511 | bitmap_ind8 &tilemap_get_flagsmap(tilemap_t *tmap); | |
| 747 | // specify global horizontal and vertical scroll offsets, for non-flipped and flipped cases | |
| 748 | inline void tilemap_set_scrolldx(tilemap_t *tmap, int dx, int dx_if_flipped) | |
| 749 | { tmap->set_scrolldx(dx, dx_if_flipped); } | |
| 750 | inline void tilemap_set_scrolldy(tilemap_t *tmap, int dy, int dy_if_flipped) | |
| 751 | { tmap->set_scrolldy(dy, dy_if_flipped); } | |
| 512 | 752 | |
| 513 | /* return a pointer to the (updated) internal per-tile flags for a tilemap */ | |
| 514 | UINT8 *tilemap_get_tile_flags(tilemap_t *tmap); | |
| 753 | // return the global horizontal or vertical scroll offset, based on current flip state | |
| 754 | inline int tilemap_get_scrolldx(tilemap_t *tmap) | |
| 755 | { return tmap->scrolldx(); } | |
| 756 | inline int tilemap_get_scrolldy(tilemap_t *tmap) | |
| 757 | { return tmap->scrolldy(); } | |
| 515 | 758 | |
| 759 | // specify the scroll value for a row/column unit | |
| 760 | inline void tilemap_set_scrollx(tilemap_t *tmap, int row, int value) | |
| 761 | { tmap->set_scrollx(row, value); } | |
| 762 | inline void tilemap_set_scrolly(tilemap_t *tmap, int col, int value) | |
| 763 | { tmap->set_scrolly(col, value); } | |
| 516 | 764 | |
| 765 | // return the scroll value for a row/column unit | |
| 766 | inline int tilemap_get_scrollx(tilemap_t *tmap, int row) | |
| 767 | { return tmap->scrollx(row); } | |
| 768 | inline int tilemap_get_scrolly(tilemap_t *tmap, int col) | |
| 769 | { return tmap->scrolly(col); } | |
| 517 | 770 | |
| 518 | /* ----- tilemap rendering ----- */ | |
| 519 | 771 | |
| 520 | /* draw a tilemap to the destination with clipping; pixels apply priority/priority_mask to the priority bitmap */ | |
| 521 | void tilemap_draw_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask); | |
| 522 | void tilemap_draw_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask); | |
| 523 | 772 | |
| 524 | /* draw a tilemap to the destination with clipping and arbitrary rotate/zoom; */ | |
| 525 | /* pixels apply priority/priority_mask to the priority bitmap */ | |
| 526 | void tilemap_draw_roz_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap, | |
| 527 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, | |
| 528 | int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask); | |
| 529 | void tilemap_draw_roz_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, | |
| 530 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, | |
| 531 | int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask); | |
| 773 | // ----- internal map access ----- | |
| 532 | 774 | |
| 775 | // return a pointer to the (updated) internal pixmap for a tilemap | |
| 776 | inline bitmap_ind16 &tilemap_get_pixmap(tilemap_t *tmap) | |
| 777 | { return tmap->pixmap(); } | |
| 533 | 778 | |
| 779 | // return a pointer to the (updated) internal flagsmap for a tilemap | |
| 780 | inline bitmap_ind8 &tilemap_get_flagsmap(tilemap_t *tmap) | |
| 781 | { return tmap->flagsmap(); } | |
| 534 | 782 | |
| 535 | /* ----- indexed tilemap handling ----- */ | |
| 783 | // return a pointer to the (updated) internal per-tile flags for a tilemap | |
| 784 | inline UINT8 *tilemap_get_tile_flags(tilemap_t *tmap) | |
| 785 | { return tmap->tile_flags(); } | |
| 536 | 786 | |
| 537 | /* return the number of tilemaps */ | |
| 538 | int tilemap_count(running_machine &machine); | |
| 539 | 787 | |
| 540 | /* return the size of an indexed tilemap */ | |
| 541 | void tilemap_size_by_index(running_machine &machine, int number, UINT32 *width, UINT32 *height); | |
| 542 | 788 | |
| 543 | /* render an indexed tilemap with fixed characteristics (no priority) */ | |
| 544 | void tilemap_draw_by_index(running_machine &machine, bitmap_rgb32 &dest, int number, UINT32 scrollx, UINT32 scrolly); | |
| 789 | // ----- tilemap rendering ----- | |
| 545 | 790 | |
| 791 | // draw a tilemap to the destination with clipping; pixels apply priority/priority_mask to the priority bitmap | |
| 792 | inline void tilemap_draw_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 793 | { tmap->draw(dest, cliprect, flags, priority, priority_mask); } | |
| 794 | inline void tilemap_draw_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 795 | { tmap->draw(dest, cliprect, flags, priority, priority_mask); } | |
| 546 | 796 | |
| 797 | // draw a tilemap to the destination with clipping and arbitrary rotate/zoom; | |
| 798 | // pixels apply priority/priority_mask to the priority bitmap | |
| 799 | inline void tilemap_draw_roz_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap, | |
| 800 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, | |
| 801 | int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 802 | { tmap->draw_roz(dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); } | |
| 803 | inline void tilemap_draw_roz_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, | |
| 804 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, | |
| 805 | int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask) | |
| 806 | { tmap->draw_roz(dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); } | |
| 547 | 807 | |
| 548 | /* ----- common logical-to-memory mappers ----- */ | |
| 549 | 808 | |
| 550 | /* scan in row-major order with optional flipping */ | |
| 809 | ||
| 810 | // ----- common logical-to-memory mappers ----- | |
| 811 | ||
| 812 | // scan in row-major order with optional flipping | |
| 551 | 813 | TILEMAP_MAPPER( tilemap_scan_rows ); |
| 552 | 814 | TILEMAP_MAPPER( tilemap_scan_rows_flip_x ); |
| 553 | 815 | TILEMAP_MAPPER( tilemap_scan_rows_flip_y ); |
| 554 | 816 | TILEMAP_MAPPER( tilemap_scan_rows_flip_xy ); |
| 555 | 817 | |
| 556 | / | |
| 818 | // scan in column-major order with optional flipping | |
| 557 | 819 | TILEMAP_MAPPER( tilemap_scan_cols ); |
| 558 | 820 | TILEMAP_MAPPER( tilemap_scan_cols_flip_x ); |
| 559 | 821 | TILEMAP_MAPPER( tilemap_scan_cols_flip_y ); |
| r14063 | r14064 | |
| 561 | 823 | |
| 562 | 824 | |
| 563 | 825 | |
| 564 | /*************************************************************************** | |
| 565 | INLINE FUNCTIONS | |
| 566 | ***************************************************************************/ | |
| 826 | //************************************************************************** | |
| 827 | // INLINE FUNCTIONS | |
| 828 | //************************************************************************** | |
| 567 | 829 | |
| 568 | 830 | /*------------------------------------------------- |
| 569 | 831 | tileinfo_set - set the values of a tileinfo |
| r14063 | r14064 | |
| 571 | 833 | -------------------------------------------------*/ |
| 572 | 834 | |
| 573 | 835 | inline void tileinfo_set(running_machine &machine, tile_data *tileinfo, int gfxnum, int rawcode, int rawcolor, int flags) |
| 574 | { | |
| 575 | const gfx_element *gfx = machine.gfx[gfxnum]; | |
| 576 | int code = rawcode % gfx->total_elements; | |
| 577 | tileinfo->pen_data = gfx_element_get_data(gfx, code); | |
| 578 | tileinfo->palette_base = gfx->color_base + gfx->color_granularity * rawcolor; | |
| 579 | tileinfo->flags = flags; | |
| 580 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 581 | tileinfo->flags |= TILE_4BPP; | |
| 582 | tileinfo->gfxnum = gfxnum; | |
| 583 | } | |
| 836 | { tileinfo->set(machine, gfxnum, rawcode, rawcolor, flags); } | |
| 584 | 837 | |
| 585 | 838 | |
| 586 | 839 | /*------------------------------------------------- |
| r14063 | r14064 | |
| 589 | 842 | -------------------------------------------------*/ |
| 590 | 843 | |
| 591 | 844 | inline void tilemap_map_pen_to_layer(tilemap_t *tmap, int group, pen_t pen, UINT8 layermask) |
| 592 | { | |
| 593 | tilemap_map_pens_to_layer(tmap, group, pen, ~0, layermask); | |
| 594 | } | |
| 845 | { tmap->map_pen_to_layer(group, pen, layermask); } | |
| 595 | 846 | |
| 596 | 847 | |
| 597 | 848 | /*------------------------------------------------- |
| r14063 | r14064 | |
| 601 | 852 | |
| 602 | 853 | template<class _BitmapClass> |
| 603 | 854 | inline void tilemap_draw(_BitmapClass &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority) |
| 604 | { | |
| 605 | tilemap_draw_primask(dest, cliprect, tmap, flags, priority, 0xff); | |
| 606 | } | |
| 855 | { tmap->draw(dest, cliprect, flags, priority); } | |
| 607 | 856 | |
| 608 | 857 | |
| 609 | 858 | /*------------------------------------------------- |
| r14063 | r14064 | |
| 615 | 864 | inline void tilemap_draw_roz(_BitmapClass &dest, const rectangle &cliprect, tilemap_t *tmap, |
| 616 | 865 | UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, |
| 617 | 866 | int wraparound, UINT32 flags, UINT8 priority) |
| 867 | { tmap->draw_roz(dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority); } | |
| 868 | ||
| 869 | ||
| 870 | inline running_machine &tilemap_t::machine() const | |
| 618 | 871 | { |
| 619 | | |
| 872 | | |
| 620 | 873 | } |
| 621 | 874 | |
| 622 | 875 | |
| 623 | ||
| 624 | #endif /* __TILEMAP_H__ */ | |
| 876 | #endif // __TILEMAP_H__ |
| r14063 | r14064 | |
|---|---|---|
| 211 | 211 | sprintf(temp, "~scr%dnativexaspect~", scrnum); |
| 212 | 212 | if (!strncmp(string, temp, strlen(temp))) |
| 213 | 213 | { |
| 214 | int num = device->visible_area().max_x + 1 - device->visible_area().min_x; | |
| 215 | int den = device->visible_area().max_y + 1 - device->visible_area().min_y; | |
| 214 | int num = device->visible_area().width(); | |
| 215 | int den = device->visible_area().height(); | |
| 216 | 216 | reduce_fraction(num, den); |
| 217 | 217 | *outputptr += sprintf(*outputptr, "%d", num); |
| 218 | 218 | return strlen(temp); |
| r14063 | r14064 | |
| 222 | 222 | sprintf(temp, "~scr%dnativeyaspect~", scrnum); |
| 223 | 223 | if (!strncmp(string, temp, strlen(temp))) |
| 224 | 224 | { |
| 225 | int num = device->visible_area().max_x + 1 - device->visible_area().min_x; | |
| 226 | int den = device->visible_area().max_y + 1 - device->visible_area().min_y; | |
| 225 | int num = device->visible_area().width(); | |
| 226 | int den = device->visible_area().height(); | |
| 227 | 227 | reduce_fraction(num, den); |
| 228 | 228 | *outputptr += sprintf(*outputptr, "%d", den); |
| 229 | 229 | return strlen(temp); |
| r14063 | r14064 | |
| 233 | 233 | sprintf(temp, "~scr%dwidth~", scrnum); |
| 234 | 234 | if (!strncmp(string, temp, strlen(temp))) |
| 235 | 235 | { |
| 236 | *outputptr += sprintf(*outputptr, "%d", device->visible_area(). | |
| 236 | *outputptr += sprintf(*outputptr, "%d", device->visible_area().w | |
| 237 | 237 | return strlen(temp); |
| 238 | 238 | } |
| 239 | 239 | |
| r14063 | r14064 | |
| 241 | 241 | sprintf(temp, "~scr%dheight~", scrnum); |
| 242 | 242 | if (!strncmp(string, temp, strlen(temp))) |
| 243 | 243 | { |
| 244 | *outputptr += sprintf(*outputptr, "%d", device->visible_area(). | |
| 244 | *outputptr += sprintf(*outputptr, "%d", device->visible_area().h | |
| 245 | 245 | return strlen(temp); |
| 246 | 246 | } |
| 247 | 247 | } |
| r14063 | r14064 | |
| 749 | 749 | UINT32 inva = (1.0f - m_color.a) * 255.0; |
| 750 | 750 | |
| 751 | 751 | // iterate over X and Y |
| 752 | for (UINT32 y = bounds.min_y; y < bounds.max_y; y++) | |
| 753 | for (UINT32 x = bounds.min_x; x < bounds.max_x; x++) | |
| 752 | for (UINT32 y = bounds.min_y; y <= bounds.max_y; y++) | |
| 753 | for (UINT32 x = bounds.min_x; x <= bounds.max_x; x++) | |
| 754 | 754 | { |
| 755 | 755 | UINT32 finalr = r; |
| 756 | 756 | UINT32 finalg = g; |
| r14063 | r14064 | |
| 785 | 785 | UINT32 inva = (1.0f - m_color.a) * 255.0; |
| 786 | 786 | |
| 787 | 787 | // find the center |
| 788 | float xcenter = (float)(bounds.min_x + bounds.max_x) * 0.5f; | |
| 789 | float ycenter = (float)(bounds.min_y + bounds.max_y) * 0.5f; | |
| 790 | float xradius = (float)(bounds.max_x - bounds.min_x) * 0.5f; | |
| 791 | float yradius = (float)(bounds.max_y - bounds.min_y) * 0.5f; | |
| 788 | float xcenter = float(bounds.xcenter()) * 0.5f; | |
| 789 | float ycenter = float(bounds.ycenter()) * 0.5f; | |
| 790 | float xradius = float(bounds.width()) * 0.5f; | |
| 791 | float yradius = float(bounds.height()) * 0.5f; | |
| 792 | 792 | float ooyradius2 = 1.0f / (yradius * yradius); |
| 793 | 793 | |
| 794 | 794 | // iterate over y |
| 795 | for (UINT32 y = bounds.min_y; y < bounds.max_y; y++) | |
| 795 | for (UINT32 y = bounds.min_y; y <= bounds.max_y; y++) | |
| 796 | 796 | { |
| 797 | 797 | float ycoord = ycenter - ((float)y + 0.5f); |
| 798 | 798 | float xval = xradius * sqrt(1.0f - (ycoord * ycoord) * ooyradius2); |
| r14063 | r14064 | |
| 842 | 842 | INT32 width; |
| 843 | 843 | while (1) |
| 844 | 844 | { |
| 845 | width = font->string_width(bounds.max_y - bounds.min_y, aspect, m_string); | |
| 846 | if (width < bounds.max_x - bounds.min_x) | |
| 845 | width = font->string_width(bounds.height(), aspect, m_string); | |
| 846 | if (width < bounds.width()) | |
| 847 | 847 | break; |
| 848 | 848 | aspect *= 0.9f; |
| 849 | 849 | } |
| 850 | INT32 curx = bounds.min_x + (bounds. | |
| 850 | INT32 curx = bounds.min_x + (bounds.w | |
| 851 | 851 | |
| 852 | 852 | // allocate a temporary bitmap |
| 853 | 853 | bitmap_argb32 tempbitmap(dest.width(), dest.height()); |
| r14063 | r14064 | |
| 857 | 857 | { |
| 858 | 858 | // get the font bitmap |
| 859 | 859 | rectangle chbounds; |
| 860 | font->get_scaled_bitmap_and_bounds(tempbitmap, bounds. | |
| 860 | font->get_scaled_bitmap_and_bounds(tempbitmap, bounds.he | |
| 861 | 861 | |
| 862 | 862 | // copy the data into the target |
| 863 | for (int y = 0; y < chbounds. | |
| 863 | for (int y = 0; y < chbounds. | |
| 864 | 864 | { |
| 865 | 865 | int effy = bounds.min_y + y; |
| 866 | 866 | if (effy >= bounds.min_y && effy <= bounds.max_y) |
| 867 | 867 | { |
| 868 | 868 | UINT32 *src = &tempbitmap.pix32(y); |
| 869 | 869 | UINT32 *d = &dest.pix32(effy); |
| 870 | for (int x = 0; x < chbounds. | |
| 870 | for (int x = 0; x < chbounds.w | |
| 871 | 871 | { |
| 872 | 872 | int effx = curx + x + chbounds.min_x; |
| 873 | 873 | if (effx >= bounds.min_x && effx <= bounds.max_x) |
| r14063 | r14064 | |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | // advance in the X direction |
| 891 | curx += font->char_width(bounds. | |
| 891 | curx += font->char_width(bounds.he | |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | // free the temporary bitmap and font |
| r14063 | r14064 | |
|---|---|---|
| 149 | 149 | debug_flags(0), |
| 150 | 150 | memory_data(NULL), |
| 151 | 151 | palette_data(NULL), |
| 152 | tilemap_data(NULL), | |
| 153 | 152 | romload_data(NULL), |
| 154 | 153 | input_data(NULL), |
| 155 | 154 | input_port_data(NULL), |
| r14063 | r14064 | |
| 170 | 169 | m_input(NULL), |
| 171 | 170 | m_sound(NULL), |
| 172 | 171 | m_video(NULL), |
| 172 | m_tilemap(NULL), | |
| 173 | 173 | m_debug_view(NULL), |
| 174 | 174 | m_driver_device(NULL), |
| 175 | 175 | m_current_phase(MACHINE_PHASE_PREINIT), |
| r14063 | r14064 | |
| 305 | 305 | |
| 306 | 306 | // initialize image devices |
| 307 | 307 | image_init(*this); |
| 308 | tilemap_i | |
| 308 | m_tilemap = auto_alloc(*this, tilemap_manager(*this)); | |
| 309 | 309 | crosshair_init(*this); |
| 310 | 310 | network_init(*this); |
| 311 | 311 |
| r14063 | r14064 | |
|---|---|---|
| 953 | 953 | } |
| 954 | 954 | |
| 955 | 955 | int cols = m_freshorz ? CDP1869_COLUMNS_FULL : CDP1869_COLUMNS_HALF; |
| 956 | int rows = | |
| 956 | int rows = | |
| 957 | 957 | |
| 958 | 958 | UINT16 pmemsize = get_pmemsize(cols, rows); |
| 959 | 959 | UINT16 addr = m_hma; |
| r14063 | r14064 | |
|---|---|---|
| 179 | 179 | class render_manager; |
| 180 | 180 | class sound_manager; |
| 181 | 181 | class video_manager; |
| 182 | class tilemap_manager; | |
| 182 | 183 | class debug_view_manager; |
| 183 | 184 | class osd_interface; |
| 184 | 185 | |
| 185 | 186 | typedef struct _memory_private memory_private; |
| 186 | 187 | typedef struct _palette_private palette_private; |
| 187 | typedef struct _tilemap_private tilemap_private; | |
| 188 | 188 | typedef struct _romload_private romload_private; |
| 189 | 189 | typedef struct _input_private input_private; |
| 190 | 190 | typedef struct _input_port_private input_port_private; |
| r14063 | r14064 | |
| 342 | 342 | input_manager &input() const { assert(m_input != NULL); return *m_input; } |
| 343 | 343 | sound_manager &sound() const { assert(m_sound != NULL); return *m_sound; } |
| 344 | 344 | video_manager &video() const { assert(m_video != NULL); return *m_video; } |
| 345 | tilemap_manager &tilemap() const { assert(m_tilemap != NULL); return *m_tilemap; } | |
| 345 | 346 | debug_view_manager &debug_view() const { assert(m_debug_view != NULL); return *m_debug_view; } |
| 346 | 347 | driver_device *driver_data() const { return m_driver_device; } |
| 347 | 348 | template<class _DriverClass> _DriverClass *driver_data() const { return downcast<_DriverClass *>(m_driver_device); } |
| r14063 | r14064 | |
| 429 | 430 | // internal core information |
| 430 | 431 | memory_private * memory_data; // internal data from memory.c |
| 431 | 432 | palette_private * palette_data; // internal data from palette.c |
| 432 | tilemap_private * tilemap_data; // internal data from tilemap.c | |
| 433 | 433 | romload_private * romload_data; // internal data from romload.c |
| 434 | 434 | input_private * input_data; // internal data from input.c |
| 435 | 435 | input_port_private * input_port_data; // internal data from inptport.c |
| r14063 | r14064 | |
| 466 | 466 | input_manager * m_input; // internal data from input.c |
| 467 | 467 | sound_manager * m_sound; // internal data from sound.c |
| 468 | 468 | video_manager * m_video; // internal data from video.c |
| 469 | tilemap_manager * m_tilemap; // internal data from tilemap.c | |
| 469 | 470 | debug_view_manager * m_debug_view; // internal data from debugvw.c |
| 470 | 471 | |
| 471 | 472 | // driver state |
| r14063 | r14064 | |
|---|---|---|
| 1110 | 1110 | const rectangle &visarea = screen->visible_area(); |
| 1111 | 1111 | |
| 1112 | 1112 | string.catprintf("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n", |
| 1113 | visarea.max_x - visarea.min_x + 1, | |
| 1114 | visarea.max_y - visarea.min_y + 1, | |
| 1113 | visarea.width(), visarea.height(), | |
| 1115 | 1114 | (machine.system().flags & ORIENTATION_SWAP_XY) ? "V" : "H", |
| 1116 | 1115 | ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds)); |
| 1117 | 1116 | } |
| r14063 | r14064 | |
|---|---|---|
| 366 | 366 | m_param(NULL), |
| 367 | 367 | m_curseq(0) |
| 368 | 368 | { |
| 369 | m_sbounds. | |
| 369 | m_sbounds. | |
| 370 | 370 | memset(m_scaled, 0, sizeof(m_scaled)); |
| 371 | 371 | } |
| 372 | 372 | |
| r14063 | r14064 | |
| 416 | 416 | // invalidate references to the original bitmap as well |
| 417 | 417 | m_manager->invalidate_all(m_bitmap); |
| 418 | 418 | m_bitmap = NULL; |
| 419 | m_sbounds. | |
| 419 | m_sbounds. | |
| 420 | 420 | m_format = TEXFORMAT_ARGB32; |
| 421 | 421 | m_curseq = 0; |
| 422 | 422 | |
| r14063 | r14064 | |
| 503 | 503 | texinfo.seqid = ++m_curseq; |
| 504 | 504 | return true; |
| 505 | 505 | } |
| 506 | ||
| 506 | ||
| 507 | 507 | // make sure we can recover the original argb32 bitmap |
| 508 | bitmap_argb32 &srcbitmap = downcast<bitmap_argb32 &>(*m_bitmap); | |
| 508 | bitmap_argb32 dummy; | |
| 509 | bitmap_argb32 &srcbitmap = (m_bitmap != NULL) ? downcast<bitmap_argb32 &>(*m_bitmap) : dummy; | |
| 509 | 510 | |
| 510 | 511 | // is it a size we already have? |
| 511 | 512 | scaled_texture *scaled = NULL; |
| r14063 | r14064 | |
| 1285 | 1286 | float xscale, yscale; |
| 1286 | 1287 | if (!(orientation_add(m_orientation, screen->container().orientation()) & ORIENTATION_SWAP_XY)) |
| 1287 | 1288 | { |
| 1288 | xscale = (float)(visarea.max_x + 1 - visarea.min_x) / (bounds.x1 - bounds.x0); | |
| 1289 | yscale = (float)(visarea.max_y + 1 - visarea.min_y) / (bounds.y1 - bounds.y0); | |
| 1289 | xscale = float(visarea.width()) / bounds.width(); | |
| 1290 | yscale = float(visarea.height()) / bounds.height(); | |
| 1290 | 1291 | } |
| 1291 | 1292 | else |
| 1292 | 1293 | { |
| 1293 | xscale = (float)(visarea.max_y + 1 - visarea.min_y) / (bounds.x1 - bounds.x0); | |
| 1294 | yscale = (float)(visarea.max_x + 1 - visarea.min_x) / (bounds.y1 - bounds.y0); | |
| 1294 | xscale = float(visarea.height()) / bounds.width(); | |
| 1295 | yscale = float(visarea.width()) / bounds.height(); | |
| 1295 | 1296 | } |
| 1296 | 1297 | |
| 1297 | 1298 | // pick the greater |
| r14063 | r14064 | |
|---|---|---|
| 190 | 190 | float y0; // topmost Y coordinate |
| 191 | 191 | float x1; // rightmost X coordinate |
| 192 | 192 | float y1; // bottommost Y coordinate |
| 193 | ||
| 194 | float width() const { return x1 - x0; } | |
| 195 | float height() const { return y1 - y0; } | |
| 193 | 196 | }; |
| 194 | 197 | |
| 195 | 198 |
| r14063 | r14064 | |
|---|---|---|
| 61 | 61 | // force the UI to show the game select screen |
| 62 | 62 | ui_menu_force_game_select(machine(), &machine().render().ui_container()); |
| 63 | 63 | } |
| 64 | ||
| 64 | ||
| 65 | 65 | UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 66 | 66 | { |
| 67 | 67 | bitmap.fill(RGB_BLACK); |
| r14063 | r14064 | |
|---|---|---|
| 80 | 80 | 0x986a0070 // stb r3,0x0070(r10) |
| 81 | 81 | }; |
| 82 | 82 | |
| 83 | // iterate over instructions | |
| 83 | // iterate over instructions | |
| 84 | 84 | for (int instnum = 0; instnum < ARRAY_LENGTH(sample_instructions); instnum++) |
| 85 | 85 | { |
| 86 | 86 | // write the instruction to execute, followed by a BLR which will terminate the |
| 87 | 87 | // basic block in the DRC |
| 88 | 88 | m_space->write_dword(RAM_BASE, sample_instructions[instnum]); |
| 89 | 89 | m_space->write_dword(RAM_BASE + 4, 0x4e800020); |
| 90 | ||
| 90 | ||
| 91 | 91 | // initialize the register state |
| 92 | 92 | m_cpu->set_state(PPC_PC, RAM_BASE); |
| 93 | 93 | for (int regnum = 0; regnum < 32; regnum++) |
| r14063 | r14064 | |
| 110 | 110 | // execute one instruction |
| 111 | 111 | *m_cpu->m_icountptr = 0; |
| 112 | 112 | m_cpu->run(); |
| 113 | ||
| 113 | ||
| 114 | 114 | // dump the final register state |
| 115 | 115 | printf("Final state:\n"); |
| 116 | 116 | dump_state(false); |
| 117 | 117 | } |
| 118 | ||
| 118 | ||
| 119 | 119 | // all done; just bail |
| 120 | 120 | throw emu_fatalerror(0, "All done"); |
| 121 | 121 | } |
| 122 | ||
| 122 | ||
| 123 | 123 | // startup code; do basic configuration and set a timer to go off immediately |
| 124 | 124 | virtual void machine_start() |
| 125 | 125 | { |
| 126 | 126 | // find the CPU's address space |
| 127 | 127 | m_space = m_cpu->space(AS_PROGRAM); |
| 128 | ||
| 128 | ||
| 129 | 129 | // configure DRC in the most compatible mode |
| 130 | 130 | ppcdrc_set_options(m_cpu, PPCDRC_COMPATIBLE_OPTIONS); |
| 131 | 131 | |
| 132 | 132 | // set a timer to go off right away |
| 133 | 133 | timer_set(attotime::zero); |
| 134 | 134 | } |
| 135 | ||
| 135 | ||
| 136 | 136 | // dump the current CPU state |
| 137 | 137 | void dump_state(bool disassemble) |
| 138 | 138 | { |
| r14063 | r14064 | |
| 147 | 147 | for (int bytenum = 0; bytenum < maxbytes; bytenum++) |
| 148 | 148 | instruction[bytenum] = m_space->read_byte(RAM_BASE + bytenum); |
| 149 | 149 | |
| 150 | // disassemble the current instruction | |
| 150 | // disassemble the current instruction | |
| 151 | 151 | bytes = m_cpu->disassemble(buffer, RAM_BASE, instruction, instruction) & DASMFLAG_LENGTHMASK; |
| 152 | 152 | } |
| 153 | ||
| 153 | ||
| 154 | 154 | // output the registers |
| 155 | 155 | printf("PC : %08X", UINT32(m_cpu->state(PPC_PC))); |
| 156 | 156 | if (disassemble && bytes > 0) |
| r14063 | r14064 | |
| 167 | 167 | if (regnum % 4 == 3) printf("\n"); |
| 168 | 168 | } |
| 169 | 169 | printf("CR : %08X LR : %08X CTR: %08X XER: %08X\n", |
| 170 | UINT32(m_cpu->state(PPC_CR)), UINT32(m_cpu->state(PPC_LR)), | |
| 170 | UINT32(m_cpu->state(PPC_CR)), UINT32(m_cpu->state(PPC_LR)), | |
| 171 | 171 | UINT32(m_cpu->state(PPC_CTR)), UINT32(m_cpu->state(PPC_XER))); |
| 172 | 172 | for (int regnum = 0; regnum < 32; regnum++) |
| 173 | 173 | { |
| r14063 | r14064 | |
| 175 | 175 | if (regnum % 4 == 3) printf("\n"); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | ||
| 178 | ||
| 179 | 179 | // report reads from anywhere |
| 180 | 180 | READ64_MEMBER( general_r ) |
| 181 | 181 | { |
| r14063 | r14064 | |
|---|---|---|
| 40 | 40 | virtual bool call_load(); |
| 41 | 41 | virtual void call_unload(); |
| 42 | 42 | virtual void call_display_info() { if (m_device_displayinfo) m_device_displayinfo(*this); } |
| 43 | virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) { | |
| 43 | virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) { | |
| 44 | 44 | virtual device_image_partialhash_func get_partial_hash() const { return m_device_partialhash; } |
| 45 | ||
| 45 | ||
| 46 | 46 | virtual iodevice_t image_type() const { return IO_CARTSLOT; } |
| 47 | 47 | |
| 48 | 48 | virtual bool is_readable() const { return 1; } |
| r14063 | r14064 | |
| 53 | 53 | virtual const char *image_interface() const { return m_interface; } |
| 54 | 54 | virtual const char *file_extensions() const { return m_extensions; } |
| 55 | 55 | virtual const option_guide *create_option_guide() const { return NULL; } |
| 56 | ||
| 56 | ||
| 57 | 57 | void set_extensions(const char *_extensions) { m_extensions = _extensions; } |
| 58 | 58 | void set_interface(const char *_interface) { m_interface = _interface; } |
| 59 | 59 | void set_must_be_loaded(bool _must_be_loaded) { m_must_be_loaded = _must_be_loaded; } |
| r14063 | r14064 | |
| 67 | 67 | // device-level overrides |
| 68 | 68 | virtual void device_config_complete(); |
| 69 | 69 | virtual void device_start(); |
| 70 | ||
| 70 | ||
| 71 | 71 | int load_cartridge(const rom_entry *romrgn, const rom_entry *roment, bool load); |
| 72 | 72 | int process_cartridge(bool load); |
| 73 | ||
| 74 | 73 | |
| 74 | ||
| 75 | 75 | const char * m_extensions; |
| 76 | 76 | const char * m_interface; |
| 77 | 77 | bool m_must_be_loaded; |
| r14063 | r14064 | |
|---|---|---|
| 2015 | 2015 | mame_printf_error("%s: %s has a part (%s) with no data\n", list->file->filename(), swinfo->shortname, swpart->name); |
| 2016 | 2016 | error = TRUE; |
| 2017 | 2017 | } |
| 2018 | ||
| 2018 | ||
| 2019 | 2019 | if (part_names.add(swpart->name, swinfo, FALSE) == TMERR_DUPLICATE) |
| 2020 | 2020 | { |
| 2021 | 2021 | mame_printf_error("%s: %s has a part (%s) whose name is duplicate\n", list->file->filename(), swinfo->shortname, swpart->name); |
| 2022 | error = TRUE; | |
| 2022 | error = TRUE; | |
| 2023 | 2023 | } |
| 2024 | 2024 | |
| 2025 | 2025 | for (struct rom_entry *swdata = software_find_romdata(swpart, NULL); swdata != NULL; swdata = software_romdata_next(swdata)) |
| r14063 | r14064 | |
|---|---|---|
| 154 | 154 | ui_gfx_state *state = &ui_gfx; |
| 155 | 155 | |
| 156 | 156 | /* if we have nothing, implicitly cancel */ |
| 157 | if (machine.total_colors() == 0 && machine.colortable == NULL && machine.gfx[0] == NULL && tilemap | |
| 157 | if (machine.total_colors() == 0 && machine.colortable == NULL && machine.gfx[0] == NULL && machine.tilemap().count( | |
| 158 | 158 | goto cancel; |
| 159 | 159 | |
| 160 | 160 | /* if we're not paused, mark the bitmap dirty */ |
| r14063 | r14064 | |
| 189 | 189 | |
| 190 | 190 | case 2: |
| 191 | 191 | /* if we have tilemaps, display them */ |
| 192 | if (tilemap | |
| 192 | if (machine.tilemap().count( | |
| 193 | 193 | { |
| 194 | 194 | tilemap_handler(machine, container, state); |
| 195 | 195 | break; |
| r14063 | r14064 | |
| 717 | 717 | rectangle cellbounds; |
| 718 | 718 | |
| 719 | 719 | /* make a rect that covers this row */ |
| 720 | cellbounds.min_x = 0; | |
| 721 | cellbounds.max_x = state->bitmap->width() - 1; | |
| 722 | cellbounds.min_y = y * cellypix; | |
| 723 | cellbounds.max_y = (y + 1) * cellypix - 1; | |
| 720 | cellbounds.set(0, state->bitmap->width() - 1, y * cellypix, (y + 1) * cellypix - 1); | |
| 724 | 721 | |
| 725 | 722 | /* only display if there is data to show */ |
| 726 | 723 | if (state->gfxset.offset[set] + y * xcells < gfx->total_elements) |
| r14063 | r14064 | |
| 854 | 851 | char title[100]; |
| 855 | 852 | |
| 856 | 853 | /* get the size of the tilemap itself */ |
| 857 | tilemap_size_by_index(machine, state->tilemap.which, &mapwidth, &mapheight); | |
| 854 | tilemap_t *tilemap = machine.tilemap().find(state->tilemap.which); | |
| 855 | mapwidth = tilemap->width(); | |
| 856 | mapheight = tilemap->height(); | |
| 858 | 857 | if (state->tilemap.rotate & ORIENTATION_SWAP_XY) |
| 859 | 858 | { UINT32 temp = mapwidth; mapwidth = mapheight; mapheight = temp; } |
| 860 | 859 | |
| r14063 | r14064 | |
| 906 | 905 | boxbounds.y1 = mapboxbounds.y1 + 0.5f * chheight; |
| 907 | 906 | |
| 908 | 907 | /* figure out the title and expand the outer box to fit */ |
| 909 | sprintf(title, "TMAP %d/%d %dx%d OFFS %d,%d", state->tilemap.which, tilemap | |
| 908 | sprintf(title, "TMAP %d/%d %dx%d OFFS %d,%d", state->tilemap.which, machine.tilemap().count( | |
| 910 | 909 | titlewidth = ui_font->string_width(chheight, machine.render().ui_aspect(), title); |
| 911 | 910 | if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth) |
| 912 | 911 | { |
| r14063 | r14064 | |
| 960 | 959 | /* clamp within range */ |
| 961 | 960 | if (state->tilemap.which < 0) |
| 962 | 961 | state->tilemap.which = 0; |
| 963 | if (state->tilemap.which >= tilemap_count(machine)) | |
| 964 | state->tilemap.which = tilemap_count(machine) - 1; | |
| 962 | if (state->tilemap.which >= machine.tilemap().count()) | |
| 963 | state->tilemap.which = machine.tilemap().count() - 1; | |
| 965 | 964 | |
| 966 | 965 | /* cache some info in locals */ |
| 967 | tilemap_size_by_index(machine, state->tilemap.which, &mapwidth, &mapheight); | |
| 966 | tilemap_t *tilemap = machine.tilemap().find(state->tilemap.which); | |
| 967 | mapwidth = tilemap->width(); | |
| 968 | mapheight = tilemap->height(); | |
| 968 | 969 | |
| 969 | 970 | /* handle zoom (minus,plus) */ |
| 970 | 971 | if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT)) |
| r14063 | r14064 | |
| 1053 | 1054 | /* handle the redraw */ |
| 1054 | 1055 | if (state->bitmap_dirty) |
| 1055 | 1056 | { |
| 1056 | tilemap_draw_by_index(machine, *state->bitmap, state->tilemap.which, state->tilemap.xoffs, state->tilemap.yoffs); | |
| 1057 | tilemap_t *tilemap = machine.tilemap().find(state->tilemap.which); | |
| 1058 | tilemap->draw_debug(*state->bitmap, state->tilemap.xoffs, state->tilemap.yoffs); | |
| 1057 | 1059 | |
| 1058 | 1060 | /* reset the texture to force an update */ |
| 1059 | 1061 | state->texture->set_bitmap(*state->bitmap, state->bitmap->cliprect(), TEXFORMAT_RGB32); |
| r14063 | r14064 | |
|---|---|---|
| 681 | 681 | if (device->screen_type() != SCREEN_TYPE_VECTOR) |
| 682 | 682 | { |
| 683 | 683 | const rectangle &visarea = device->visible_area(); |
| 684 | fprintf(m_output, " width=\"%d\"", visarea.max_x - visarea.min_x + 1); | |
| 685 | fprintf(m_output, " height=\"%d\"", visarea.max_y - visarea.min_y + 1); | |
| 684 | fprintf(m_output, " width=\"%d\"", visarea.width()); | |
| 685 | fprintf(m_output, " height=\"%d\"", visarea.height()); | |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | // output refresh rate |
| r14063 | r14064 | |
|---|---|---|
| 290 | 290 | // on entry, assume x0,y0 are the top,left coordinate of the cell and add |
| 291 | 291 | // the character bounding box to that position |
| 292 | 292 | float scale = m_scale * height; |
| 293 | bounds.x0 += | |
| 293 | bounds.x0 += | |
| 294 | 294 | |
| 295 | 295 | // compute x1,y1 from there based on the bitmap size |
| 296 | bounds.x1 = bounds.x0 + (float)gl.bmwidth * scale * aspect; | |
| 297 | bounds.y1 = bounds.y0 + (float)m_height * scale; | |
| 296 | bounds.x1 = bounds.x0 + float(gl.bmwidth) * scale * aspect; | |
| 297 | bounds.y1 = bounds.y0 + float(m_height) * scale; | |
| 298 | 298 | |
| 299 | 299 | // return the texture |
| 300 | 300 | return gl.texture; |
| r14063 | r14064 | |
| 313 | 313 | // on entry, assume x0,y0 are the top,left coordinate of the cell and add |
| 314 | 314 | // the character bounding box to that position |
| 315 | 315 | float scale = m_scale * height; |
| 316 | bounds.min_x = | |
| 316 | bounds.min_x = | |
| 317 | 317 | bounds.min_y = 0; |
| 318 | 318 | |
| 319 | 319 | // compute x1,y1 from there based on the bitmap size |
| 320 | bounds.max_x = bounds.min_x + (float)gl.bmwidth * scale * aspect; | |
| 321 | bounds.max_y = bounds.min_y + (float)m_height * scale; | |
| 320 | bounds.set_width(float(gl.bmwidth) * scale * aspect); | |
| 321 | bounds.set_height(float(m_height) * scale); | |
| 322 | 322 | |
| 323 | 323 | // if the bitmap isn't big enough, bail |
| 324 | if (dest.width() < bounds. | |
| 324 | if (dest.width() < bounds.w | |
| 325 | 325 | return; |
| 326 | 326 | |
| 327 | 327 | // if no texture, fill the target |
| r14063 | r14064 | |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // scale the font |
| 335 | bitmap_argb32 tempbitmap(dest, bounds); | |
| 335 | bitmap_argb32 tempbitmap(&dest.pix(0), bounds.width(), bounds.height(), dest.rowpixels()); | |
| 336 | 336 | render_texture::hq_scale(tempbitmap, gl.bitmap, gl.bitmap.cliprect(), NULL); |
| 337 | 337 | } |
| 338 | 338 | |
| r14063 | r14064 | |
| 344 | 344 | |
| 345 | 345 | float render_font::char_width(float height, float aspect, unicode_char ch) |
| 346 | 346 | { |
| 347 | return | |
| 347 | return | |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | |
| r14063 | r14064 | |
| 361 | 361 | totwidth += get_char(*ptr).width; |
| 362 | 362 | |
| 363 | 363 | // scale the final result based on height |
| 364 | return | |
| 364 | return | |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | |
| r14063 | r14064 | |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | // scale the final result based on height |
| 391 | return | |
| 391 | return | |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 |
| r14063 | r14064 | |
|---|---|---|
| 120 | 120 | UINT16 num_cylinders; |
| 121 | 121 | UINT8 num_sectors; |
| 122 | 122 | UINT8 num_heads; |
| 123 | ||
| 123 | ||
| 124 | 124 | chd_file *handle; |
| 125 | 125 | hard_disk_file *disk; |
| 126 | bool is_image_device; | |
| 127 | }; | |
| 126 | bool is_image_device; | |
| 127 | }; | |
| 128 | 128 | |
| 129 | 129 | |
| 130 | 130 | typedef struct _ide_state ide_state; |
| r14063 | r14064 | |
| 173 | 173 | |
| 174 | 174 | UINT8 gnetreadlock; |
| 175 | 175 | ide_hardware * hardware; |
| 176 | ||
| 176 | ||
| 177 | 177 | UINT8 cur_drive; |
| 178 | 178 | ide_device drive[2]; |
| 179 | 179 | }; |
| r14063 | r14064 | |
| 1872 | 1872 | |
| 1873 | 1873 | /* set MAME harddisk handle */ |
| 1874 | 1874 | config = (const ide_config *)downcast<const legacy_device_base *>(device)->inline_config(); |
| 1875 | ||
| 1875 | ||
| 1876 | 1876 | ide->drive[0].handle = get_disk_handle(device->machine(), (config->master != NULL) ? config->master : device->tag()); |
| 1877 | 1877 | ide->drive[0].disk = hard_disk_open(ide->drive[0].handle); |
| 1878 | 1878 | ide->drive[0].is_image_device = false; |
| r14063 | r14064 | |
| 1914 | 1914 | |
| 1915 | 1915 | /* build the features page */ |
| 1916 | 1916 | ide_build_features(ide,0); |
| 1917 | } | |
| 1917 | } | |
| 1918 | 1918 | if (ide->drive[1].disk != NULL) |
| 1919 | 1919 | { |
| 1920 | 1920 | hdinfo = hard_disk_get_info(ide->drive[1].disk); |
| r14063 | r14064 | |
| 1928 | 1928 | |
| 1929 | 1929 | /* build the features page */ |
| 1930 | 1930 | ide_build_features(ide,1); |
| 1931 | } | |
| 1931 | } | |
| 1932 | 1932 | if (config->hardware != NULL) { |
| 1933 | 1933 | ide->hardware = (ide_hardware *)config->hardware; |
| 1934 | 1934 | ide->hardware->get_info(ide->device, ide->drive[0].features, ide->drive[0].num_cylinders, ide->drive[0].num_sectors, ide->drive[0].num_heads); |
| r14063 | r14064 | |
| 2055 | 2055 | } |
| 2056 | 2056 | } |
| 2057 | 2057 | } |
| 2058 | } | |
| 2058 | } | |
| 2059 | 2059 | if (device->machine().device( hardtag_slave.cstr() )) { |
| 2060 | 2060 | if (!ide->drive[1].disk) |
| 2061 | 2061 | { |
| r14063 | r14064 | |
| 2084 | 2084 | } |
| 2085 | 2085 | } |
| 2086 | 2086 | } |
| 2087 | } | |
| 2087 | } | |
| 2088 | 2088 | if (ide->hardware != NULL) { |
| 2089 | 2089 | ide->hardware->get_info(ide->device, ide->drive[0].features, ide->drive[0].num_cylinders, ide->drive[0].num_sectors, ide->drive[0].num_heads); |
| 2090 | 2090 | ide_generate_features (ide,0); |
| r14063 | r14064 | |
|---|---|---|
| 240 | 240 | m_i8049_port2(0) |
| 241 | 241 | { |
| 242 | 242 | } |
| 243 | ||
| 244 | 243 | |
| 244 | ||
| 245 | 245 | //------------------------------------------------- |
| 246 | // control_w - write callback when the CONTROL | |
| 246 | // control_w - write callback when the CONTROL | |
| 247 | 247 | // line is toggled |
| 248 | 248 | //------------------------------------------------- |
| 249 | 249 | |
| r14063 | r14064 | |
| 252 | 252 | // set the new value and remember the last |
| 253 | 253 | UINT8 prev = m_control; |
| 254 | 254 | m_control = data; |
| 255 | ||
| 255 | ||
| 256 | 256 | // handle rising edge |
| 257 | 257 | if (prev != ASSERT_LINE && data == ASSERT_LINE) |
| 258 | 258 | { |
| r14063 | r14064 | |
| 351 | 351 | switch (id) |
| 352 | 352 | { |
| 353 | 353 | // update the VBI data in the PIA as soon as it is ready; |
| 354 | // this must happen early in the frame because the player | |
| 354 | // this must happen early in the frame because the player | |
| 355 | 355 | // logic relies on fetching it here |
| 356 | 356 | case TID_VBI_DATA_FETCH: |
| 357 | 357 | |
| r14063 | r14064 | |
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | break; |
| 399 | ||
| 399 | ||
| 400 | 400 | // clear the VSYNC flag |
| 401 | 401 | case TID_VSYNC_OFF: |
| 402 | 402 | m_vsync = false; |
| 403 | 403 | break; |
| 404 | ||
| 404 | ||
| 405 | 405 | // pass everything else onto the parent |
| 406 | 406 | default: |
| 407 | 407 | laserdisc_device::device_timer(timer, id, param, ptr); |
| r14063 | r14064 | |
| 458 | 458 | |
| 459 | 459 | |
| 460 | 460 | //------------------------------------------------- |
| 461 | // player_update - update callback, called on the | |
| 461 | // player_update - update callback, called on the | |
| 462 | 462 | // first visible line of the frame |
| 463 | 463 | //------------------------------------------------- |
| 464 | 464 | |
| r14063 | r14064 | |
| 639 | 639 | $04 = (in) SIZE 8/12 |
| 640 | 640 | $02 = (in) FG via op-amp (spindle motor stop detector) |
| 641 | 641 | $01 = (in) SLOW TIMER OUT |
| 642 | ||
| 642 | */ | |
| 643 | 643 | |
| 644 | 644 | UINT8 result = 0x00; |
| 645 | 645 | |
| r14063 | r14064 | |
| 684 | 684 | $02 = (out) SCAN A (/SCAN) |
| 685 | 685 | $01 = (out) JUMP TRG (jump back trigger, clock on high->low) |
| 686 | 686 | */ |
| 687 | ||
| 687 | ||
| 688 | 688 | // set the new value |
| 689 | 689 | UINT8 prev = m_i8049_port1; |
| 690 | 690 | m_i8049_port1 = data; |
| r14063 | r14064 | |
| 933 | 933 | |
| 934 | 934 | |
| 935 | 935 | //------------------------------------------------- |
| 936 | // data_w - write callback when the parallel data | |
| 936 | // data_w - write callback when the parallel data | |
| 937 | 937 | // port is written to |
| 938 | 938 | //------------------------------------------------- |
| 939 | 939 | |
| r14063 | r14064 | |
| 1028 | 1028 | case TID_IRQ_OFF: |
| 1029 | 1029 | m_i8748_cpu->set_input_line(MCS48_INPUT_IRQ, CLEAR_LINE); |
| 1030 | 1030 | break; |
| 1031 | ||
| 1031 | ||
| 1032 | 1032 | // latch data |
| 1033 | 1033 | case TID_LATCH_DATA: |
| 1034 | 1034 | m_data = param; |
| r14063 | r14064 | |
|---|---|---|
| 146 | 146 | { |
| 147 | 147 | // control the CPU state |
| 148 | 148 | m_i8049_cpu->set_input_line(INPUT_LINE_RESET, data); |
| 149 | ||
| 149 | ||
| 150 | 150 | // on an assert, reset the device state as well |
| 151 | 151 | if (data == ASSERT_LINE) |
| 152 | 152 | reset(); |
| r14063 | r14064 | |
| 154 | 154 | |
| 155 | 155 | |
| 156 | 156 | //------------------------------------------------- |
| 157 | // data_r - handle a parallel data read from the | |
| 157 | // data_r - handle a parallel data read from the | |
| 158 | 158 | // 22VP931 |
| 159 | 159 | //------------------------------------------------- |
| 160 | 160 | |
| r14063 | r14064 | |
| 182 | 182 | { |
| 183 | 183 | // pass through to the parent |
| 184 | 184 | laserdisc_device::device_start(); |
| 185 | ||
| 185 | ||
| 186 | 186 | // allocate a timer |
| 187 | 187 | m_tracktimer = timer_alloc(TID_HALF_TRACK); |
| 188 | 188 | } |
| r14063 | r14064 | |
| 201 | 201 | m_i8049_out0 = 0; |
| 202 | 202 | m_i8049_out1 = 0; |
| 203 | 203 | m_i8049_port1 = 0; |
| 204 | ||
| 204 | ||
| 205 | 205 | m_daticval = 0; |
| 206 | 206 | m_daticerp = 0; |
| 207 | 207 | m_datastrobe = 0; |
| 208 | ||
| 208 | ||
| 209 | 209 | m_fromcontroller = 0; |
| 210 | 210 | m_fromcontroller_pending = false; |
| 211 | 211 | m_tocontroller = 0; |
| 212 | 212 | m_tocontroller_pending = false; |
| 213 | ||
| 213 | ||
| 214 | 214 | m_trackdir = 0; |
| 215 | 215 | m_trackstate = 0; |
| 216 | ||
| 216 | ||
| 217 | 217 | m_cmdcount = 0; |
| 218 | 218 | m_advanced = 0; |
| 219 | 219 | } |
| r14063 | r14064 | |
| 263 | 263 | timer_set(screen().time_until_pos(line*2, which * 2 * screen().width() / 4), TID_VBI_DATA_FETCH, (line << 2) + which); |
| 264 | 264 | break; |
| 265 | 265 | } |
| 266 | ||
| 266 | ||
| 267 | 267 | case TID_DEFERRED_DATA: |
| 268 | 268 | // set the value and mark it pending |
| 269 | 269 | if (LOG_COMMANDS && m_fromcontroller_pending) |
| r14063 | r14064 | |
| 279 | 279 | printf("Cmd: %02X %02X %02X\n", m_cmdbuf[0], m_cmdbuf[1], m_cmdbuf[2]); |
| 280 | 280 | } |
| 281 | 281 | break; |
| 282 | ||
| 282 | ||
| 283 | 283 | case TID_IRQ_OFF: |
| 284 | 284 | m_i8049_cpu->set_input_line(MCS48_INPUT_IRQ, CLEAR_LINE); |
| 285 | 285 | break; |
| 286 | ||
| 286 | ||
| 287 | 287 | case TID_DATA_STROBE_OFF: |
| 288 | 288 | m_datastrobe = 0; |
| 289 | 289 | break; |
| 290 | ||
| 290 | ||
| 291 | 291 | case TID_ERP_OFF: |
| 292 | 292 | m_daticerp = 0; |
| 293 | 293 | break; |
| 294 | ||
| 294 | ||
| 295 | 295 | case TID_HALF_TRACK: |
| 296 | 296 | // advance by the count and toggle the state |
| 297 | 297 | m_trackstate ^= 1; |
| r14063 | r14064 | |
| 301 | 301 | m_advanced += m_trackdir; |
| 302 | 302 | } |
| 303 | 303 | break; |
| 304 | ||
| 304 | ||
| 305 | 305 | // pass everything else onto the parent |
| 306 | 306 | default: |
| 307 | 307 | laserdisc_device::device_timer(timer, id, param, ptr); |
| r14063 | r14064 | |
| 471 | 471 | |
| 472 | 472 | |
| 473 | 473 | //------------------------------------------------- |
| 474 | // i8049_keypad_r - vestigial keypad/button | |
| 474 | // i8049_keypad_r - vestigial keypad/button | |
| 475 | 475 | // controls |
| 476 | 476 | //------------------------------------------------- |
| 477 | 477 | |
| r14063 | r14064 | |
| 517 | 517 | |
| 518 | 518 | |
| 519 | 519 | //------------------------------------------------- |
| 520 | // i8049_to_controller_w - write a value back to | |
| 520 | // i8049_to_controller_w - write a value back to | |
| 521 | 521 | // the external controller |
| 522 | 522 | //------------------------------------------------- |
| 523 | 523 | |
| r14063 | r14064 | |
| 672 | 672 | |
| 673 | 673 | |
| 674 | 674 | //------------------------------------------------- |
| 675 | // i8049_t1_r - return the T1 line status, which | |
| 675 | // i8049_t1_r - return the T1 line status, which | |
| 676 | 676 | // is connected to the tracking state and is used |
| 677 | 677 | // to count the number of tracks advanced |
| 678 | 678 | //------------------------------------------------- |
| r14063 | r14064 | |
|---|---|---|
| 143 | 143 | //************************************************************************** |
| 144 | 144 | |
| 145 | 145 | //------------------------------------------------- |
| 146 | // get_field_code - return raw field information | |
| 146 | // get_field_code - return raw field information | |
| 147 | 147 | // read from the disc |
| 148 | 148 | //------------------------------------------------- |
| 149 | 149 | |
| r14063 | r14064 | |
| 244 | 244 | |
| 245 | 245 | |
| 246 | 246 | //------------------------------------------------- |
| 247 | // static_set_get_disc - set the get disc | |
| 247 | // static_set_get_disc - set the get disc | |
| 248 | 248 | // delegate |
| 249 | 249 | //------------------------------------------------- |
| 250 | 250 | |
| r14063 | r14064 | |
| 255 | 255 | |
| 256 | 256 | |
| 257 | 257 | //------------------------------------------------- |
| 258 | // static_set_get_disc - set the audio interceptor | |
| 258 | // static_set_get_disc - set the audio interceptor | |
| 259 | 259 | // delegate |
| 260 | 260 | //------------------------------------------------- |
| 261 | 261 | |
| r14063 | r14064 | |
| 292 | 292 | |
| 293 | 293 | //------------------------------------------------- |
| 294 | 294 | // static_set_overlay - set the overlay visible |
| 295 | // | |
| 295 | // subregion | |
| 296 | 296 | //------------------------------------------------- |
| 297 | 297 | |
| 298 | 298 | void laserdisc_device::static_set_overlay_clip(device_t &device, INT32 minx, INT32 maxx, INT32 miny, INT32 maxy) |
| r14063 | r14064 | |
| 302 | 302 | |
| 303 | 303 | |
| 304 | 304 | //------------------------------------------------- |
| 305 | // static_set_overlay_position - set the overlay | |
| 305 | // static_set_overlay_position - set the overlay | |
| 306 | 306 | // position parameters |
| 307 | 307 | //------------------------------------------------- |
| 308 | 308 | |
| r14063 | r14064 | |
| 316 | 316 | |
| 317 | 317 | //------------------------------------------------- |
| 318 | 318 | // static_set_overlay_scale - set the overlay |
| 319 | // | |
| 319 | // scale parameters | |
| 320 | 320 | //------------------------------------------------- |
| 321 | 321 | |
| 322 | 322 | void laserdisc_device::static_set_overlay_scale(device_t &device, float scalex, float scaley) |
| r14063 | r14064 | |
| 528 | 528 | { |
| 529 | 529 | // first update to the current time |
| 530 | 530 | update_slider_pos(); |
| 531 | ||
| 531 | ||
| 532 | 532 | // then update the track position |
| 533 | 533 | add_and_clamp_track(numtracks); |
| 534 | 534 | if (LOG_SLIDER) |
| r14063 | r14064 | |
| 729 | 729 | advanceby = 1; |
| 730 | 730 | } |
| 731 | 731 | break; |
| 732 | ||
| 732 | ||
| 733 | 733 | default: |
| 734 | 734 | // do nothing |
| 735 | 735 | break; |
| r14063 | r14064 | |
| 855 | 855 | // bind our handlers |
| 856 | 856 | m_overupdate_ind16.bind_relative_to(*owner()); |
| 857 | 857 | m_overupdate_rgb32.bind_relative_to(*owner()); |
| 858 | ||
| 858 | ||
| 859 | 859 | // configure bitmap formats |
| 860 | 860 | bitmap_format format = !m_overupdate_ind16.isnull() ? BITMAP_FORMAT_IND16 : BITMAP_FORMAT_RGB32; |
| 861 | 861 | texture_format texformat = !m_overupdate_ind16.isnull() ? TEXFORMAT_PALETTEA16 : TEXFORMAT_ARGB32; |
| r14063 | r14064 | |
| 867 | 867 | m_overbitmap[index].set_palette(machine().palette); |
| 868 | 868 | m_overbitmap[index].resize(m_overwidth, m_overheight); |
| 869 | 869 | } |
| 870 | ||
| 870 | ||
| 871 | 871 | // allocate overlay texture |
| 872 | 872 | m_overtex = machine().render().texture_alloc(); |
| 873 | 873 | if (m_overtex == NULL) |
| r14063 | r14064 | |
| 930 | 930 | void laserdisc_device::update_slider_pos() |
| 931 | 931 | { |
| 932 | 932 | attotime curtime = machine().time(); |
| 933 | ||
| 933 | ||
| 934 | 934 | // if not moving, update to now |
| 935 | 935 | if (m_attospertrack == 0) |
| 936 | 936 | m_sliderupdate = curtime; |
| r14063 | r14064 | |
|---|---|---|
| 165 | 165 | // ======================> laserdisc_device |
| 166 | 166 | |
| 167 | 167 | // base laserdisc class |
| 168 | class laserdisc_device : | |
| 168 | class laserdisc_device : | |
| 169 | 169 | public device_sound_interface, |
| 170 | 170 | public laserdisc_overlay_config |
| 171 | 171 | { |
| r14063 | r14064 | |
| 372 | 372 | bool m_videoenable; // is video enabled? |
| 373 | 373 | render_texture * m_videotex; // texture for the video |
| 374 | 374 | palette_t * m_videopalette; // palette for the video |
| 375 | ||
| 375 | ||
| 376 | 376 | // overlays |
| 377 | 377 | bool m_overenable; // is the overlay enabled? |
| 378 | 378 | screen_bitmap m_overbitmap[2]; // overlay bitmaps |
| r14063 | r14064 | |
|---|---|---|
| 937 | 937 | } |
| 938 | 938 | height = lineval + 1; |
| 939 | 939 | s3c24xx->lcd.framerate = framerate; |
| 940 | visarea.min_x = 0; | |
| 941 | visarea.min_y = 0; | |
| 942 | visarea.max_x = width - 1; | |
| 943 | visarea.max_y = height - 1; | |
| 940 | visarea.set(0, width - 1, 0, height - 1); | |
| 944 | 941 | verboselog( device->machine(), 3, "LCD - visarea min_x %d min_y %d max_x %d max_y %d\n", visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y); |
| 945 | 942 | verboselog( device->machine(), 3, "video_screen_configure %d %d %f\n", width, height, s3c24xx->lcd.framerate); |
| 946 | 943 | s3c24xx->lcd.hpos_min = 0; |
| r14063 | r14064 | |
|---|---|---|
| 107 | 107 | |
| 108 | 108 | static const ppi8255_interface ppi0intf = |
| 109 | 109 | { |
| 110 | DEVCB_NULL, | |
| 111 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_portb_r), | |
| 110 | DEVCB_NULL, | |
| 111 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_portb_r), | |
| 112 | 112 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_portc_r), |
| 113 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_porta_w), | |
| 114 | DEVCB_NULL, | |
| 113 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_porta_w), | |
| 114 | DEVCB_NULL, | |
| 115 | 115 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_portc_w) |
| 116 | 116 | }; |
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | static const ppi8255_interface ppi1intf = |
| 120 | 120 | { |
| 121 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi1_porta_r), | |
| 122 | DEVCB_NULL, | |
| 121 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi1_porta_r), | |
| 123 | 122 | DEVCB_NULL, |
| 124 | DEVCB_NULL, | |
| 125 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi1_portb_w), | |
| 123 | DEVCB_NULL, | |
| 124 | DEVCB_NULL, | |
| 125 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi1_portb_w), | |
| 126 | 126 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi1_portc_w) |
| 127 | 127 | }; |
| 128 | 128 | |
| r14063 | r14064 | |
| 193 | 193 | |
| 194 | 194 | |
| 195 | 195 | //------------------------------------------------- |
| 196 | // data_w - handle a parallel data write to the | |
| 196 | // data_w - handle a parallel data write to the | |
| 197 | 197 | // LD-V1000 |
| 198 | 198 | //------------------------------------------------- |
| 199 | 199 | |
| r14063 | r14064 | |
| 222 | 222 | { |
| 223 | 223 | // pass through to the parent |
| 224 | 224 | laserdisc_device::device_start(); |
| 225 | ||
| 225 | ||
| 226 | 226 | // allocate timers |
| 227 | 227 | m_multitimer = timer_alloc(TID_MULTIJUMP); |
| 228 | 228 | } |
| r14063 | r14064 | |
| 273 | 273 | timer.adjust(MULTIJUMP_TRACK_TIME); |
| 274 | 274 | break; |
| 275 | 275 | } |
| 276 | ||
| 276 | ||
| 277 | 277 | case TID_VSYNC_OFF: |
| 278 | 278 | m_vsync = false; |
| 279 | 279 | break; |
| 280 | ||
| 280 | ||
| 281 | 281 | case TID_VBI_DATA_FETCH: |
| 282 | 282 | { |
| 283 | 283 | // appears to return data in reverse order |
| r14063 | r14064 | |
| 315 | 315 | m_vbiindex = 0; |
| 316 | 316 | break; |
| 317 | 317 | } |
| 318 | ||
| 318 | ||
| 319 | 319 | // pass everything else onto the parent |
| 320 | 320 | default: |
| 321 | 321 | laserdisc_device::device_timer(timer, id, param, ptr); |
| r14063 | r14064 | |
| 398 | 398 | |
| 399 | 399 | |
| 400 | 400 | //------------------------------------------------- |
| 401 | // z80_decoder_display_port_w - handle writes to | |
| 401 | // z80_decoder_display_port_w - handle writes to | |
| 402 | 402 | // the decoder/display chips |
| 403 | 403 | //------------------------------------------------- |
| 404 | 404 |
| r14063 | r14064 | |
|---|---|---|
| 139 | 139 | screen.m_vblank = screen.m_refresh / vtotal * (vtotal - (vbstart - vbend)); |
| 140 | 140 | screen.m_width = htotal; |
| 141 | 141 | screen.m_height = vtotal; |
| 142 | screen.m_visarea.min_x = hbend; | |
| 143 | screen.m_visarea.max_x = hbstart - 1; | |
| 144 | screen.m_visarea.min_y = vbend; | |
| 145 | screen.m_visarea.max_y = vbstart - 1; | |
| 142 | screen.m_visarea.set(hbend, hbstart - 1, vbend, vbstart - 1); | |
| 146 | 143 | } |
| 147 | 144 | |
| 148 | 145 | |
| r14063 | r14064 | |
| 232 | 229 | |
| 233 | 230 | |
| 234 | 231 | //------------------------------------------------- |
| 235 | // static_set_screen_vblank - set the screen | |
| 232 | // static_set_screen_vblank - set the screen | |
| 236 | 233 | // VBLANK callback in the device configuration |
| 237 | 234 | //------------------------------------------------- |
| 238 | 235 | |
| r14063 | r14064 | |
| 261 | 258 | // sanity check display area |
| 262 | 259 | if (m_type != SCREEN_TYPE_VECTOR) |
| 263 | 260 | { |
| 264 | if ((m_visarea.max_x < m_visarea.min_x) || | |
| 265 | (m_visarea.max_y < m_visarea.min_y) || | |
| 266 | (m_visarea.max_x >= m_width) || | |
| 267 | (m_visarea.max_y >= m_height)) | |
| 261 | if (m_visarea.empty() || m_visarea.max_x >= m_width || m_visarea.max_y >= m_height) | |
| 268 | 262 | { |
| 269 | 263 | mame_printf_error("%s: %s screen '%s' has an invalid display area\n", driver.source_file, driver.name, tag()); |
| 270 | 264 | error = true; |
| r14063 | r14064 | |
| 284 | 278 | mame_printf_error("%s: %s screen '%s' has a zero refresh rate\n", driver.source_file, driver.name, tag()); |
| 285 | 279 | error = true; |
| 286 | 280 | } |
| 287 | ||
| 281 | ||
| 288 | 282 | return error; |
| 289 | 283 | } |
| 290 | 284 | |
| r14063 | r14064 | |
| 299 | 293 | m_screen_update_ind16.bind_relative_to(*owner()); |
| 300 | 294 | m_screen_update_rgb32.bind_relative_to(*owner()); |
| 301 | 295 | m_screen_vblank.bind_relative_to(*owner()); |
| 302 | ||
| 296 | ||
| 303 | 297 | // configure bitmap formats and allocate screen bitmaps |
| 304 | 298 | texture_format texformat = !m_screen_update_ind16.isnull() ? TEXFORMAT_PALETTE16 : TEXFORMAT_RGB32; |
| 305 | 299 | for (int index = 0; index < ARRAY_LENGTH(m_bitmap); index++) |
| r14063 | r14064 | |
| 414 | 408 | case TID_VBLANK_START: |
| 415 | 409 | vblank_begin(); |
| 416 | 410 | break; |
| 417 | ||
| 411 | ||
| 418 | 412 | // signal VBLANK end |
| 419 | 413 | case TID_VBLANK_END: |
| 420 | 414 | vblank_end(); |
| 421 | 415 | break; |
| 422 | ||
| 416 | ||
| 423 | 417 | // first visible scanline |
| 424 | 418 | case TID_SCANLINE0: |
| 425 | 419 | reset_partial_updates(); |
| 426 | 420 | break; |
| 427 | ||
| 421 | ||
| 428 | 422 | // subsequent scanlines when scanline updates are enabled |
| 429 | 423 | case TID_SCANLINE: |
| 430 | 424 | |
| r14063 | r14064 | |
| 472 | 466 | // if there has been no VBLANK time specified in the MACHINE_DRIVER, compute it now |
| 473 | 467 | // from the visible area, otherwise just used the supplied value |
| 474 | 468 | if (m_vblank == 0 && !m_oldstyle_vblank_supplied) |
| 475 | m_vblank_period = m_scantime * (height - | |
| 469 | m_vblank_period = m_scantime * (height - | |
| 476 | 470 | else |
| 477 | 471 | m_vblank_period = m_vblank; |
| 478 | 472 | |
| r14063 | r14064 | |
| 797 | 791 | |
| 798 | 792 | |
| 799 | 793 | //------------------------------------------------- |
| 800 | // vblank_begin - call any external callbacks to | |
| 794 | // vblank_begin - call any external callbacks to | |
| 801 | 795 | // signal the VBLANK period has begun |
| 802 | 796 | //------------------------------------------------- |
| 803 | 797 | |
| r14063 | r14064 | |
| 829 | 823 | |
| 830 | 824 | |
| 831 | 825 | //------------------------------------------------- |
| 832 | // vblank_end - call any external callbacks to | |
| 826 | // vblank_end - call any external callbacks to | |
| 833 | 827 | // signal the VBLANK period has ended |
| 834 | 828 | //------------------------------------------------- |
| 835 | 829 | |
| r14063 | r14064 | |
| 908 | 902 | int ystart = ((UINT32)rand() % 32767) * ystep / 32767; |
| 909 | 903 | int srcx, srcy; |
| 910 | 904 | int x, y; |
| 911 | ||
| 905 | ||
| 912 | 906 | switch (curbitmap.format()) |
| 913 | 907 | { |
| 914 | 908 | default: |
| r14063 | r14064 | |
| 929 | 923 | } |
| 930 | 924 | break; |
| 931 | 925 | } |
| 932 | ||
| 926 | ||
| 933 | 927 | case BITMAP_FORMAT_RGB32: |
| 934 | 928 | { |
| 935 | 929 | // iterate over rows in the destination |
| r14063 | r14064 | |
| 967 | 961 | scaledvis.max_y = m_visarea.max_y * m_burnin.height() / m_height; |
| 968 | 962 | |
| 969 | 963 | // wrap a bitmap around the subregion we care about |
| 970 | bitmap_argb32 finalmap(scaledvis. | |
| 964 | bitmap_argb32 finalmap(scaledvis.w | |
| 971 | 965 | int srcwidth = m_burnin.width(); |
| 972 | 966 | int srcheight = m_burnin.height(); |
| 973 | 967 | int dstwidth = finalmap.width(); |
| r14063 | r14064 | |
|---|---|---|
| 88 | 88 | m_live(&m_rgb32) { } |
| 89 | 89 | screen_bitmap(bitmap_ind16 &orig) |
| 90 | 90 | : m_format(BITMAP_FORMAT_IND16), |
| 91 | m_texformat(TEXFORMAT_PALETTE16), | |
| 91 | m_texformat(TEXFORMAT_PALETTE16), | |
| 92 | 92 | m_live(&m_ind16), |
| 93 | 93 | m_ind16(orig, orig.cliprect()) { } |
| 94 | 94 | screen_bitmap(bitmap_rgb32 &orig) |
| 95 | 95 | : m_format(BITMAP_FORMAT_RGB32), |
| 96 | m_texformat(TEXFORMAT_RGB32), | |
| 96 | m_texformat(TEXFORMAT_RGB32), | |
| 97 | 97 | m_live(&m_rgb32), |
| 98 | 98 | m_rgb32(orig, orig.cliprect()) { } |
| 99 | ||
| 99 | ||
| 100 | 100 | // resizing |
| 101 | 101 | void resize(int width, int height) { live().resize(width, height); } |
| 102 | 102 | |
| r14063 | r14064 | |
| 104 | 104 | operator bitmap_t &() { return live(); } |
| 105 | 105 | bitmap_ind16 &as_ind16() { assert(m_format == BITMAP_FORMAT_IND16); return m_ind16; } |
| 106 | 106 | bitmap_rgb32 &as_rgb32() { assert(m_format == BITMAP_FORMAT_RGB32); return m_rgb32; } |
| 107 | ||
| 107 | ||
| 108 | 108 | // getters |
| 109 | 109 | INT32 width() const { return live().width(); } |
| 110 | 110 | INT32 height() const { return live().height(); } |
| r14063 | r14064 | |
| 132 | 132 | m_ind16.reset(); |
| 133 | 133 | m_rgb32.reset(); |
| 134 | 134 | } |
| 135 | ||
| 135 | ||
| 136 | 136 | private: |
| 137 | 137 | // internal state |
| 138 | 138 | bitmap_format m_format; |
| r14063 | r14064 | |
| 168 | 168 | int width() const { return m_width; } |
| 169 | 169 | int height() const { return m_height; } |
| 170 | 170 | const rectangle &visible_area() const { return m_visarea; } |
| 171 | const rectangle &cliprect() const { return m_bitmap[0].cliprect(); } | |
| 171 | 172 | bool oldstyle_vblank_supplied() const { return m_oldstyle_vblank_supplied; } |
| 172 | 173 | attoseconds_t refresh_attoseconds() const { return m_refresh; } |
| 173 | 174 | attoseconds_t vblank_attoseconds() const { return m_vblank; } |
| r14063 | r14064 | |
| 219 | 220 | bool update_partial(int scanline); |
| 220 | 221 | void update_now(); |
| 221 | 222 | void reset_partial_updates(); |
| 222 | ||
| 223 | ||
| 223 | 224 | // additional helpers |
| 224 | 225 | void register_vblank_callback(vblank_state_delegate vblank_callback); |
| 225 | 226 | void register_screen_bitmap(bitmap_t &bitmap); |
| r14063 | r14064 | |
| 323 | 324 | : m_next(NULL), |
| 324 | 325 | m_bitmap(bitmap) { } |
| 325 | 326 | auto_bitmap_item *next() const { return m_next; } |
| 326 | ||
| 327 | ||
| 327 | 328 | auto_bitmap_item * m_next; |
| 328 | 329 | bitmap_t & m_bitmap; |
| 329 | 330 | }; |
| r14063 | r14064 | |
| 406 | 407 | |
| 407 | 408 | //------------------------------------------------- |
| 408 | 409 | // screen_update_delegate_smart - collection of |
| 409 | // inline helpers which create the appropriate | |
| 410 | // screen_update_delegate based on the input | |
| 411 | // function type | |
| 410 | // inline helpers which create the appropriate | |
| 411 | // screen_update_delegate based on the input | |
| 412 | // function type | |
| 412 | 413 | //------------------------------------------------- |
| 413 | 414 | |
| 414 | 415 | inline screen_update_ind16_delegate screen_update_delegate_smart(UINT32 (*callback)(device_t *, screen_device &, bitmap_ind16 &, const rectangle &), const char *name) |
| r14063 | r14064 | |
|---|---|---|
| 278 | 278 | |
| 279 | 279 | public: |
| 280 | 280 | // define our traits |
| 281 | template<class _FunctionClass> | |
| 281 | template<class _FunctionClass> | |
| 282 | 282 | struct traits |
| 283 | 283 | { |
| 284 | 284 | typedef typename delegate_traits<_FunctionClass, _ReturnType, _P1Type, _P2Type, _P3Type, _P4Type, _P5Type>::member_func_type member_func_type; |
| r14063 | r14064 | |
| 530 | 530 | |
| 531 | 531 | public: |
| 532 | 532 | // define our traits |
| 533 | template<class _FunctionClass> | |
| 533 | template<class _FunctionClass> | |
| 534 | 534 | struct traits |
| 535 | 535 | { |
| 536 | 536 | typedef typename delegate_traits<_FunctionClass, _ReturnType, _P1Type, _P2Type, _P3Type, _P4Type, _P5Type>::member_func_type member_func_type; |
| r14063 | r14064 | |
|---|---|---|
| 166 | 166 | this->state = flags | VIEW_STATE_NEEDS_UPDATE; |
| 167 | 167 | |
| 168 | 168 | // initial size |
| 169 | this->bounds.min_x = 0; | |
| 170 | this->bounds.min_y = 0; | |
| 171 | this->bounds.max_x = 300; | |
| 172 | this->bounds.max_y = 300; | |
| 169 | this->bounds.set(0, 300, 0, 300); | |
| 173 | 170 | |
| 174 | 171 | /* specials */ |
| 175 | 172 | switch (type) |
| r14063 | r14064 | |
| 377 | 374 | rectangle r; |
| 378 | 375 | |
| 379 | 376 | dview_get_rect(dv, type, r); |
| 380 | if ( | |
| 377 | if ( | |
| 381 | 378 | return TRUE; |
| 382 | 379 | return FALSE; |
| 383 | 380 | } |
| r14063 | r14064 | |
| 396 | 393 | dview_draw_outlined_box(dv, RECT_DVIEW_HSB, 0, 0, VSB_WIDTH,HSB_HEIGHT, MAKE_ARGB(0xff, 0xff, 0x00, 0x00)); |
| 397 | 394 | dview_draw_outlined_box(dv, RECT_DVIEW_HSB, r.width() - VSB_WIDTH, 0, VSB_WIDTH, HSB_HEIGHT, MAKE_ARGB(0xff, 0xff, 0x00, 0x00)); |
| 398 | 395 | |
| 399 | ts = (r. | |
| 396 | ts = (r.w | |
| 400 | 397 | |
| 401 | 398 | sz = (ts * (sb->page_size)) / (sb->upper - sb->lower); |
| 402 | 399 | ts = ts - sz; |
| r14063 | r14064 | |
| 420 | 417 | dview_draw_outlined_box(dv, RECT_DVIEW_VSB, 0, r.height() - HSB_HEIGHT, VSB_WIDTH, HSB_HEIGHT, MAKE_ARGB(0xff, 0xff, 0x00, 0x00)); |
| 421 | 418 | dview_draw_outlined_box(dv, RECT_DVIEW_VSB, 0, 0, VSB_WIDTH, HSB_HEIGHT, MAKE_ARGB(0xff, 0xff, 0x00, 0x00)); |
| 422 | 419 | |
| 423 | ts = | |
| 420 | ts = | |
| 424 | 421 | |
| 425 | 422 | sz = (ts * (sb->page_size)) / (sb->upper - sb->lower); |
| 426 | 423 | ts = ts - sz; |
| r14063 | r14064 | |
|---|---|---|
| 362 | 362 | assert(dest.valid()); \ |
| 363 | 363 | assert(gfx != NULL); \ |
| 364 | 364 | assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid()); \ |
| 365 | assert(cliprect.min_x >= 0); \ | |
| 366 | assert(cliprect.max_x < dest.width()); \ | |
| 367 | assert(cliprect.min_y >= 0); \ | |
| 368 | assert(cliprect.max_y < dest.height()); \ | |
| 365 | assert(dest.cliprect().contains(cliprect)); \ | |
| 369 | 366 | assert(code < gfx->total_elements); \ |
| 370 | 367 | \ |
| 371 | 368 | /* ignore empty/invalid cliprects */ \ |
| r14063 | r14064 | |
| 632 | 629 | assert(dest.valid()); \ |
| 633 | 630 | assert(gfx != NULL); \ |
| 634 | 631 | assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid()); \ |
| 635 | assert(cliprect.min_x >= 0); \ | |
| 636 | assert(cliprect.max_x < dest.width()); \ | |
| 637 | assert(cliprect.min_y >= 0); \ | |
| 638 | assert(cliprect.max_y < dest.height()); \ | |
| 632 | assert(dest.cliprect().contains(cliprect)); \ | |
| 639 | 633 | \ |
| 640 | 634 | /* ignore empty/invalid cliprects */ \ |
| 641 | 635 | if (cliprect.empty()) \ |
| r14063 | r14064 | |
| 807 | 801 | assert(dest.valid()); \ |
| 808 | 802 | assert(src.valid()); \ |
| 809 | 803 | assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid()); \ |
| 810 | assert(cliprect.min_x >= 0); \ | |
| 811 | assert(cliprect.max_x < dest.width()); \ | |
| 812 | assert(cliprect.min_y >= 0); \ | |
| 813 | assert(cliprect.max_y < dest.height()); \ | |
| 804 | assert(dest.cliprect().contains(cliprect)); \ | |
| 814 | 805 | \ |
| 815 | 806 | /* ignore empty/invalid cliprects */ \ |
| 816 | 807 | if (cliprect.empty()) \ |
| r14063 | r14064 | |
| 981 | 972 | assert(dest.valid()); \ |
| 982 | 973 | assert(dest.valid()); \ |
| 983 | 974 | assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid()); \ |
| 984 | assert(cliprect.min_x >= 0); \ | |
| 985 | assert(cliprect.max_x < dest.width()); \ | |
| 986 | assert(cliprect.min_y >= 0); \ | |
| 987 | assert(cliprect.max_y < dest.height()); \ | |
| 988 | assert(!wraparound || (src.width() & (src.width() - 1)) == 0); \ | |
| 975 | assert(dest.cliprect().contains(cliprect)); \ | |
| 976 | assert(!wraparound || (src.width() & (src.width() - 1)) == 0); \ | |
| 989 | 977 | assert(!wraparound || (src.height() & (src.height() - 1)) == 0); \ |
| 990 | 978 | \ |
| 991 | 979 | /* ignore empty/invalid cliprects */ \ |
| r14063 | r14064 | |
| 997 | 985 | srcfixheight = src.height() << 16; \ |
| 998 | 986 | \ |
| 999 | 987 | /* advance the starting coordinates to the top-left of the cliprect */ \ |
| 1000 | startx += cliprect.min_x * incxx + cliprect.min_y * incyx; \ | |
| 1001 | starty += cliprect.min_x * incxy + cliprect.min_y * incyy; \ | |
| 988 | startx += cliprect.min_x * incxx + cliprect.min_y * incyx; \ | |
| 989 | starty += cliprect.min_x * incxy + cliprect.min_y * incyy; \ | |
| 1002 | 990 | \ |
| 1003 | 991 | /* compute how many blocks of 4 pixels we have */ \ |
| 1004 | numblocks = (cliprect.max_x + 1 - cliprect.min_x) / 4; \ | |
| 1005 | leftovers = (cliprect.max_x + 1 - cliprect.min_x) - 4 * numblocks; \ | |
| 992 | numblocks = cliprect.width() / 4; \ | |
| 993 | leftovers = cliprect.width() - 4 * numblocks; \ | |
| 1006 | 994 | \ |
| 1007 | 995 | /* if incxy and incyx are 0, then we aren't rotating, just zooming */ \ |
| 1008 | 996 | if (incxy == 0 && incyx == 0) \ |
| r14063 | r14064 | |
|---|---|---|
| 1254 | 1254 | { SECTOR_LOOP_END }, |
| 1255 | 1255 | { END }, |
| 1256 | 1256 | }; |
| 1257 | ||
| 1258 | 1257 | |
| 1258 | ||
| 1259 | 1259 | bool dc42_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) |
| 1260 | 1260 | { |
| 1261 | 1261 | UINT8 h[0x54]; |
| r14063 | r14064 | |
| 1317 | 1317 | if(pos == ts) { |
| 1318 | 1318 | pos = 0; |
| 1319 | 1319 | wrap++; |
| 1320 | } | |
| 1320 | } | |
| 1321 | 1321 | } |
| 1322 | 1322 | return v; |
| 1323 | 1323 | } |
| r14063 | r14064 | |
| 1397 | 1397 | UINT8 tr = gcr6bw_tb[h[0]] | (v2 & 1 ? 0x40 : 0x00); |
| 1398 | 1398 | UINT8 se = gcr6bw_tb[h[1]]; |
| 1399 | 1399 | UINT8 si = v2 & 0x20 ? 1 : 0; |
| 1400 | // UINT8 ds = v3 & 0x20 ? 1 : 0; | |
| 1401 | // UINT8 fmt = v3 & 0x1f; | |
| 1400 | // UINT8 ds = v3 & 0x20 ? 1 : 0; | |
| 1401 | // UINT8 fmt = v3 & 0x1f; | |
| 1402 | 1402 | UINT8 c1 = (tr^se^v2^v3) & 0x3f; |
| 1403 | 1403 | UINT8 chk = gcr6bw_tb[h[4]]; |
| 1404 | 1404 | if(chk == c1 && tr == track && si == head && se < nsect) { |
| r14063 | r14064 | |
|---|---|---|
| 59 | 59 | //************************************************************************** |
| 60 | 60 | |
| 61 | 61 | //------------------------------------------------- |
| 62 | // compute_rowpixels - compute an aligned | |
| 62 | // compute_rowpixels - compute an aligned | |
| 63 | 63 | // rowpixels value |
| 64 | 64 | //------------------------------------------------- |
| 65 | 65 | |
| r14063 | r14064 | |
| 161 | 161 | |
| 162 | 162 | // delete any existing stuff |
| 163 | 163 | reset(); |
| 164 | ||
| 164 | ||
| 165 | 165 | // handle empty requests cleanly |
| 166 | 166 | if (width <= 0 || height <= 0) |
| 167 | 167 | return; |
| r14063 | r14064 | |
| 204 | 204 | int new_rowpixels = compute_rowpixels(width, xslop); |
| 205 | 205 | UINT32 new_allocbytes = new_rowpixels * (height + 2 * yslop) * m_bpp / 8; |
| 206 | 206 | new_allocbytes += BITMAP_OVERALL_ALIGN - 1; |
| 207 | ||
| 207 | ||
| 208 | 208 | // if we need more memory, just realloc |
| 209 | 209 | if (new_allocbytes > m_allocbytes) |
| 210 | 210 | { |
| r14063 | r14064 | |
| 213 | 213 | set_palette(palette); |
| 214 | 214 | return; |
| 215 | 215 | } |
| 216 | ||
| 216 | ||
| 217 | 217 | // otherwise, reconfigure |
| 218 | 218 | m_rowpixels = new_rowpixels; |
| 219 | 219 | m_width = width; |
| r14063 | r14064 | |
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | //------------------------------------------------- |
| 250 | // wrap -- wrap an array of memory; the target | |
| 250 | // wrap -- wrap an array of memory; the target | |
| 251 | 251 | // bitmap does not own the memory |
| 252 | 252 | //------------------------------------------------- |
| 253 | 253 | |
| r14063 | r14064 | |
| 255 | 255 | { |
| 256 | 256 | // delete any existing stuff |
| 257 | 257 | reset(); |
| 258 | ||
| 258 | ||
| 259 | 259 | // initialize relevant fields |
| 260 | 260 | m_base = base; |
| 261 | 261 | m_rowpixels = rowpixels; |
| r14063 | r14064 | |
| 266 | 266 | |
| 267 | 267 | |
| 268 | 268 | //------------------------------------------------- |
| 269 | // wrap -- wrap a subrectangle of an existing | |
| 270 | // bitmap by copying its fields; the target | |
| 269 | // wrap -- wrap a subrectangle of an existing | |
| 270 | // bitmap by copying its fields; the target | |
| 271 | 271 | // bitmap does not own the memory |
| 272 | 272 | //------------------------------------------------- |
| 273 | 273 | |
| r14063 | r14064 | |
| 279 | 279 | |
| 280 | 280 | // delete any existing stuff |
| 281 | 281 | reset(); |
| 282 | ||
| 282 | ||
| 283 | 283 | // copy relevant fields |
| 284 | 284 | m_base = source.raw_pixptr(subrect.min_y, subrect.min_x); |
| 285 | 285 | m_rowpixels = source.m_rowpixels; |
| r14063 | r14064 | |
| 331 | 331 | case 8: |
| 332 | 332 | // 8bpp always uses memset |
| 333 | 333 | for (INT32 y = fill.min_y; y <= fill.max_y; y++) |
| 334 | memset(raw_pixptr(y, fill.min_x), (UINT8)color, fill. | |
| 334 | memset(raw_pixptr(y, fill.min_x), (UINT8)color, fill.w | |
| 335 | 335 | break; |
| 336 | 336 | |
| 337 | 337 | case 16: |
| r14063 | r14064 | |
| 339 | 339 | if ((UINT8)(color >> 8) == (UINT8)color) |
| 340 | 340 | { |
| 341 | 341 | for (INT32 y = fill.min_y; y <= fill.max_y; y++) |
| 342 | memset(raw_pixptr(y, fill.min_x), (UINT8)color, | |
| 342 | memset(raw_pixptr(y, fill.min_x), (UINT8)color, | |
| 343 | 343 | } |
| 344 | 344 | else |
| 345 | 345 | { |
| r14063 | r14064 | |
| 353 | 353 | for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++) |
| 354 | 354 | { |
| 355 | 355 | destrow = &pixt<UINT16>(y, fill.min_x); |
| 356 | memcpy(destrow, destrow0, | |
| 356 | memcpy(destrow, destrow0, | |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | break; |
| r14063 | r14064 | |
| 363 | 363 | if ((UINT8)(color >> 8) == (UINT8)color && (UINT16)(color >> 16) == (UINT16)color) |
| 364 | 364 | { |
| 365 | 365 | for (INT32 y = fill.min_y; y <= fill.max_y; y++) |
| 366 | memset(&pixt<UINT32>(y, fill.min_x), (UINT8)color, | |
| 366 | memset(&pixt<UINT32>(y, fill.min_x), (UINT8)color, | |
| 367 | 367 | } |
| 368 | 368 | else |
| 369 | 369 | { |
| r14063 | r14064 | |
| 377 | 377 | for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++) |
| 378 | 378 | { |
| 379 | 379 | destrow = &pixt<UINT32>(y, fill.min_x); |
| 380 | memcpy(destrow, destrow0, | |
| 380 | memcpy(destrow, destrow0, | |
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | break; |
| r14063 | r14064 | |
| 387 | 387 | if ((UINT8)(color >> 8) == (UINT8)color && (UINT16)(color >> 16) == (UINT16)color) |
| 388 | 388 | { |
| 389 | 389 | for (INT32 y = fill.min_y; y <= fill.max_y; y++) |
| 390 | memset(&pixt<UINT64>(y, fill.min_x), (UINT8)color, | |
| 390 | memset(&pixt<UINT64>(y, fill.min_x), (UINT8)color, | |
| 391 | 391 | } |
| 392 | 392 | else |
| 393 | 393 | { |
| r14063 | r14064 | |
| 401 | 401 | for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++) |
| 402 | 402 | { |
| 403 | 403 | destrow = &pixt<UINT64>(y, fill.min_x); |
| 404 | memcpy(destrow, destrow0, | |
| 404 | memcpy(destrow, destrow0, | |
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | break; |
| r14063 | r14064 | |
|---|---|---|
| 103 | 103 | bool contains(const rectangle &rect) const { return (min_x <= rect.min_x && max_x >= rect.max_x && min_y <= rect.min_y && max_y >= rect.max_y); } |
| 104 | 104 | INT32 width() const { return max_x + 1 - min_x; } |
| 105 | 105 | INT32 height() const { return max_y + 1 - min_y; } |
| 106 | INT32 xcenter() const { return (min_x + max_x + 1) / 2; } | |
| 107 | INT32 ycenter() const { return (min_y + max_y + 1) / 2; } | |
| 106 | 108 | |
| 107 | 109 | // setters |
| 108 | 110 | void set(INT32 minx, INT32 maxx, INT32 miny, INT32 maxy) { min_x = minx; max_x = maxx; min_y = miny; max_y = maxy; } |
| 111 | void setx(INT32 minx, INT32 maxx) { min_x = minx; max_x = maxx; } | |
| 112 | void sety(INT32 miny, INT32 maxy) { min_y = miny; max_y = maxy; } | |
| 109 | 113 | void set_width(INT32 width) { max_x = min_x + width - 1; } |
| 110 | 114 | void set_height(INT32 height) { max_y = min_y + height - 1; } |
| 111 | 115 | void set_origin(INT32 x, INT32 y) { max_x += x - min_x; max_y += y - min_y; min_x = x; min_y = y; } |
| 116 | void set_size(INT32 width, INT32 height) { set_width(width); set_height(height); } | |
| 112 | 117 | |
| 113 | 118 | // internal state |
| 114 | 119 | INT32 min_x; // minimum X, or left coordinate |
| r14063 | r14064 | |
| 205 | 210 | protected: |
| 206 | 211 | // construction/destruction -- subclasses only |
| 207 | 212 | bitmap8_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 8, width, height, xslop, yslop) { } |
| 208 | bitmap8_t(bitmap_format format, | |
| 213 | bitmap8_t(bitmap_format format, UINT8 *base, int width, int height, int rowpixels) : bitmap_t(format, 8, base, width, height, rowpixels) { assert(valid_format(format)); } | |
| 209 | 214 | bitmap8_t(bitmap_format format, bitmap8_t &source, const rectangle &subrect) : bitmap_t(format, 8, source, subrect) { } |
| 210 | 215 | |
| 211 | 216 | public: |
| 212 | 217 | // getters |
| 213 | 218 | UINT8 bpp() const { return 8; } |
| 214 | ||
| 219 | ||
| 215 | 220 | // pixel accessors |
| 216 | 221 | typedef UINT8 pixel_t; |
| 217 | 222 | pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } |
| r14063 | r14064 | |
| 228 | 233 | protected: |
| 229 | 234 | // construction/destruction -- subclasses only |
| 230 | 235 | bitmap16_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 16, width, height, xslop, yslop) { assert(valid_format(format)); } |
| 231 | bitmap16_t(bitmap_format format, | |
| 236 | bitmap16_t(bitmap_format format, UINT16 *base, int width, int height, int rowpixels) : bitmap_t(format, 16, base, width, height, rowpixels) { assert(valid_format(format)); } | |
| 232 | 237 | bitmap16_t(bitmap_format format, bitmap16_t &source, const rectangle &subrect) : bitmap_t(format, 16, source, subrect) { } |
| 233 | 238 | |
| 234 | 239 | public: |
| 235 | 240 | // getters |
| 236 | 241 | UINT8 bpp() const { return 16; } |
| 237 | ||
| 242 | ||
| 238 | 243 | // pixel accessors |
| 239 | 244 | typedef UINT16 pixel_t; |
| 240 | 245 | pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } |
| r14063 | r14064 | |
| 251 | 256 | protected: |
| 252 | 257 | // construction/destruction -- subclasses only |
| 253 | 258 | bitmap32_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 32, width, height, xslop, yslop) { assert(valid_format(format)); } |
| 254 | bitmap32_t(bitmap_format format, | |
| 259 | bitmap32_t(bitmap_format format, UINT32 *base, int width, int height, int rowpixels) : bitmap_t(format, 32, base, width, height, rowpixels) { assert(valid_format(format)); } | |
| 255 | 260 | bitmap32_t(bitmap_format format, bitmap32_t &source, const rectangle &subrect) : bitmap_t(format, 32, source, subrect) { } |
| 256 | 261 | |
| 257 | 262 | public: |
| 258 | 263 | // getters |
| 259 | 264 | UINT8 bpp() const { return 32; } |
| 260 | ||
| 265 | ||
| 261 | 266 | // pixel accessors |
| 262 | 267 | typedef UINT32 pixel_t; |
| 263 | 268 | pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } |
| r14063 | r14064 | |
| 274 | 279 | protected: |
| 275 | 280 | // construction/destruction -- subclasses only |
| 276 | 281 | bitmap64_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 64, width, height, xslop, yslop) { assert(valid_format(format)); } |
| 277 | bitmap64_t(bitmap_format format, | |
| 282 | bitmap64_t(bitmap_format format, UINT64 *base, int width, int height, int rowpixels) : bitmap_t(format, 64, base, width, height, rowpixels) { assert(valid_format(format)); } | |
| 278 | 283 | bitmap64_t(bitmap_format format, bitmap64_t &source, const rectangle &subrect) : bitmap_t(format, 64, source, subrect) { } |
| 279 | 284 | |
| 280 | 285 | public: |
| 281 | 286 | // getters |
| 282 | 287 | UINT8 bpp() const { return 64; } |
| 283 | ||
| 288 | ||
| 284 | 289 | // pixel accessors |
| 285 | 290 | typedef UINT64 pixel_t; |
| 286 | 291 | pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } |
| r14063 | r14064 | |
| 294 | 299 | class bitmap_ind8 : public bitmap8_t |
| 295 | 300 | { |
| 296 | 301 | static const bitmap_format k_bitmap_format = BITMAP_FORMAT_IND8; |
| 297 | ||
| 302 | ||
| 298 | 303 | public: |
| 299 | 304 | // construction/destruction |
| 300 | 305 | bitmap_ind8(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap8_t(k_bitmap_format, width, height, xslop, yslop) { } |
| 301 | bitmap_ind8( | |
| 306 | bitmap_ind8(UINT8 *base, int width, int height, int rowpixels) : bitmap8_t(k_bitmap_format, base, width, height, rowpixels) { } | |
| 302 | 307 | bitmap_ind8(bitmap_ind8 &source, const rectangle &subrect) : bitmap8_t(k_bitmap_format, source, subrect) { } |
| 303 | 308 | void wrap(UINT8 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } |
| 304 | 309 | void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); } |
| r14063 | r14064 | |
| 315 | 320 | public: |
| 316 | 321 | // construction/destruction |
| 317 | 322 | bitmap_ind16(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap16_t(k_bitmap_format, width, height, xslop, yslop) { } |
| 318 | bitmap_ind16( | |
| 323 | bitmap_ind16(UINT16 *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { } | |
| 319 | 324 | bitmap_ind16(bitmap_ind16 &source, const rectangle &subrect) : bitmap16_t(k_bitmap_format, source, subrect) { } |
| 320 | 325 | void wrap(UINT16 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } |
| 321 | 326 | void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); } |
| r14063 | r14064 | |
| 332 | 337 | public: |
| 333 | 338 | // construction/destruction |
| 334 | 339 | bitmap_ind32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { } |
| 335 | bitmap_ind32( | |
| 340 | bitmap_ind32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { } | |
| 336 | 341 | bitmap_ind32(bitmap_ind32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { } |
| 337 | 342 | void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } |
| 338 | 343 | void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); } |
| r14063 | r14064 | |
| 349 | 354 | public: |
| 350 | 355 | // construction/destruction |
| 351 | 356 | bitmap_ind64(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap64_t(k_bitmap_format, width, height, xslop, yslop) { } |
| 352 | bitmap_ind64( | |
| 357 | bitmap_ind64(UINT64 *base, int width, int height, int rowpixels) : bitmap64_t(k_bitmap_format, base, width, height, rowpixels) { } | |
| 353 | 358 | bitmap_ind64(bitmap_ind64 &source, const rectangle &subrect) : bitmap64_t(k_bitmap_format, source, subrect) { } |
| 354 | 359 | void wrap(UINT64 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } |
| 355 | 360 | void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); } |
| r14063 | r14064 | |
| 369 | 374 | public: |
| 370 | 375 | // construction/destruction |
| 371 | 376 | bitmap_yuy16(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap16_t(k_bitmap_format, width, height, xslop, yslop) { } |
| 372 | bitmap_yuy16( | |
| 377 | bitmap_yuy16(UINT16 *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { } | |
| 373 | 378 | bitmap_yuy16(bitmap_yuy16 &source, const rectangle &subrect) : bitmap16_t(k_bitmap_format, source, subrect) { } |
| 374 | 379 | void wrap(UINT16 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } |
| 375 | 380 | void wrap(bitmap_yuy16 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); } |
| r14063 | r14064 | |
| 386 | 391 | public: |
| 387 | 392 | // construction/destruction |
| 388 | 393 | bitmap_rgb32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { } |
| 389 | bitmap_rgb32( | |
| 394 | bitmap_rgb32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { } | |
| 390 | 395 | bitmap_rgb32(bitmap_rgb32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { } |
| 391 | 396 | void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } |
| 392 | 397 | void wrap(bitmap_rgb32 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); } |
| r14063 | r14064 | |
| 403 | 408 | public: |
| 404 | 409 | // construction/destruction |
| 405 | 410 | bitmap_argb32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { } |
| 406 | bitmap_argb32( | |
| 411 | bitmap_argb32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { } | |
| 407 | 412 | bitmap_argb32(bitmap_argb32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { } |
| 408 | 413 | void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } |
| 409 | 414 | void wrap(bitmap_argb32 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); } |
| Previous | 15994 Revisions | Next |