| Previous | 15994 Revisions | Next |
| r937 Saturday 8th September, 2007 at 00:57:50 UTC by Nathan Woods |
|---|
| Updated to 0.118u5 core - some changes in palette and CHD handling are error prone, so watch out |
| [docs] | messnew.txt |
| [src/emu] | audit.c clifront.c cpuintrf.c cpuintrf.h drawgfx.c drawgfx.h driver.c driver.h emu.mak emuopts.c emuopts.h emupal.c* emupal.h* fileio.c info.c mame.h mamecore.h memconv.h render.c render.h rendlay.c romload.c romload.h sound.c tilemap.h ui.c uigfx.c validity.c video.c |
| [src/emu/cpu] | cpu.mak x86emit.h |
| [src/emu/cpu/arm7] | arm7dasm.c |
| [src/emu/cpu/h83002] | h83002.c h8disasm.c |
| [src/emu/cpu/nec] | necdasm.c |
| [src/emu/cpu/powerpc] | ppc.c ppc.h ppc_ops.c ppcdrc.c |
| [src/emu/debug] | express.c |
| [src/emu/drivers] | empty.c |
| [src/lib] | lib.mak |
| [src/lib/expat] | xmlparse.c |
| [src/lib/util] | bitmap.c bitmap.h chd.c chd.h palette.c* palette.h* png.c |
| [src/mame] | mame.mak mamedriv.c |
| [src/mame/audio] | gottlieb.c |
| [src/mame/drivers] | bankp.c baraduke.c bfm_sc2.c bishjan.c* coolpool.c cps2.c cps3.c cubocd32.c darius.c ddrible.c dec8.c deniam.c docastle.c dynax.c equites.c galaga.c gaplus.c hornet.c ironhors.c istellar.c jrpacman.c ksys573.c lastfght.c legionna.c limenko.c mediagx.c mpu4.c namcoic.c namcona1.c nemesis.c nwk-tr.c pacland.c paradise.c polepos.c rockola.c royalmah.c seibuspi.c speglsht.c* srmp2.c st0016.c taitowlf.c thayers.c thepit.c vamphalf.c vulgus.c wilytowr.c |
| [src/mame/includes] | amiga.h cubocd32.h* docastle.h m107.h m72.h m92.h taitoipt.h |
| [src/mame/machine] | amiga.c bublbobl.c cps2crpt.c cubocd32.c* konamigx.c playch10.c snes.c vsnes.c wd33c93.c wd33c93.h |
| [src/mame/video] | 20pacgal.c arabian.c atarigt.c atarimo.c atarisy1.c balsente.c bankp.c bbusters.c bosco.c bwing.c circus.c deco16ic.c deco32.c deco_mlc.c digdug.c djmain.c dkong.c docastle.c equites.c exerion.c gaiden.c galaga.c gaplus.c genesis.c gridlee.c hyprduel.c jalblend.c kaneko16.c konamiic.c m62.c magmax.c mappy.c metro.c mpatrol.c n64.c namcona1.c namcos22.c namcos86.c nbmj8891.c pacland.c pacman.c plygonet.c polepos.c psikyosh.c qix.c rockola.c rungun.c segaic24.c seibuspi.c seta.c snes.c spbactn.c sprint4.c st0016.c stvvdp2.c suprloco.c system1.c system16.c taito_f2.c taito_f3.c taitoic.c taitojc.c tatsumi.c tceptor.c tecmo16.c thepit.c toaplan1.c toypop.c tubep.c twin16.c ultratnk.c vulgus.c wecleman.c xevious.c |
| [src/mess] | image.c image.h mess.h mess.mak |
| [src/mess/devices] | chd_cd.c harddriv.c |
| [src/mess/machine] | gb.c |
| [src/mess/tools/imgtool] | imghd.c stream.c stream.h |
| [src/mess/video] | arcadia.c avigo.c gb.c odyssey2.c pc_t1t.c ted7360.c vc4000.c vic6560.c x68k.c |
| [src/osd/windows] | drawd3d.c drawdd.c windows.mak |
| [src/tools] | chdman.c |
| r936 | r937 | |
|---|---|---|
| 14 | 14 | |
| 15 | 15 | if ((data&0x0f) != 0xf) /* interrupt trigered by four low bits (not all 1's) */ |
| 16 | 16 | { |
| 17 | if (sndti_t | |
| 17 | if (sndti_exist | |
| 18 | 18 | { |
| 19 | 19 | if (!strcmp(Machine->gamedrv->name,"reactor")) /* reactor */ |
| 20 | 20 | { |
| r936 | r937 | |
| 91 | 91 | if (!strcmp(Machine->gamedrv->name,"reactor")) /* reactor */ |
| 92 | 92 | { |
| 93 | 93 | } |
| 94 | else if (sndti_t | |
| 94 | else if (sndti_exist | |
| 95 | 95 | sample_start(0,44,0); |
| 96 | 96 | } |
| 97 | 97 |
| r0 | r937 | |
|---|---|---|
| 1 | #include "driver.h" | |
| 2 | #include "includes/amiga.h" | |
| 3 | #include "cdrom.h" | |
| 4 | #include "coreutil.h" | |
| 5 | #include "sound/cdda.h" | |
| 6 | ||
| 7 | ||
| 8 | /********************************************************************************* | |
| 9 | ||
| 10 | Akiko custom chip emulation | |
| 11 | ||
| 12 | The Akiko chip has: | |
| 13 | - built in 1KB NVRAM | |
| 14 | - chunky to planar converter | |
| 15 | - custom CDROM controller | |
| 16 | ||
| 17 | TODO: Add CDDA support | |
| 18 | ||
| 19 | *********************************************************************************/ | |
| 20 | ||
| 21 | #define LOG_AKIKO 0 | |
| 22 | #define LOG_AKIKO_I2C 0 | |
| 23 | #define LOG_AKIKO_CD 0 | |
| 24 | ||
| 25 | #define CD_SECTOR_TIME (1000/((150*1024)/2048)) /* 1X CDROM sector time in msec (300KBps) */ | |
| 26 | ||
| 27 | ||
| 28 | /************************************* | |
| 29 | * | |
| 30 | * Akiko I2C NVRAM implementation | |
| 31 | * | |
| 32 | ************************************/ | |
| 33 | ||
| 34 | enum { | |
| 35 | I2C_WAIT = 0, | |
| 36 | I2C_DEVICEADDR, | |
| 37 | I2C_WORDADDR, | |
| 38 | I2C_DATA | |
| 39 | }; | |
| 40 | ||
| 41 | #define NVRAM_SIZE 1024 | |
| 42 | #define NVRAM_PAGE_SIZE 16 /* max size of one write request */ | |
| 43 | ||
| 44 | struct akiko_def | |
| 45 | { | |
| 46 | /* chunky to planar converter */ | |
| 47 | UINT32 c2p_input_buffer[8]; | |
| 48 | UINT32 c2p_output_buffer[8]; | |
| 49 | UINT32 c2p_input_index; | |
| 50 | UINT32 c2p_output_index; | |
| 51 | ||
| 52 | /* i2c bus */ | |
| 53 | int i2c_state; | |
| 54 | int i2c_bitcounter; | |
| 55 | int i2c_direction; | |
| 56 | int i2c_sda_dir_nvram; | |
| 57 | int i2c_scl_out; | |
| 58 | int i2c_scl_in; | |
| 59 | int i2c_scl_dir; | |
| 60 | int i2c_oscl; | |
| 61 | int i2c_sda_out; | |
| 62 | int i2c_sda_in; | |
| 63 | int i2c_sda_dir; | |
| 64 | int i2c_osda; | |
| 65 | ||
| 66 | /* nvram */ | |
| 67 | UINT8 nvram[NVRAM_SIZE]; | |
| 68 | UINT8 nvram_writetmp[NVRAM_PAGE_SIZE]; | |
| 69 | int nvram_address; | |
| 70 | int nvram_writeaddr; | |
| 71 | int nvram_rw; | |
| 72 | UINT8 nvram_byte; | |
| 73 | ||
| 74 | /* cdrom */ | |
| 75 | UINT32 cdrom_status[2]; | |
| 76 | UINT32 cdrom_address[2]; | |
| 77 | UINT32 cdrom_track_index; | |
| 78 | UINT32 cdrom_lba_start; | |
| 79 | UINT32 cdrom_lba_end; | |
| 80 | UINT32 cdrom_lba_cur; | |
| 81 | UINT16 cdrom_readmask; | |
| 82 | UINT16 cdrom_readreqmask; | |
| 83 | UINT32 cdrom_dmacontrol; | |
| 84 | UINT32 cdrom_numtracks; | |
| 85 | UINT8 cdrom_speed; | |
| 86 | UINT8 cdrom_cmd_start; | |
| 87 | UINT8 cdrom_cmd_end; | |
| 88 | UINT8 cdrom_cmd_resp; | |
| 89 | cdrom_file *cdrom; | |
| 90 | UINT8 * cdrom_toc; | |
| 91 | mame_timer *dma_timer; | |
| 92 | mame_timer *frame_timer; | |
| 93 | } akiko; | |
| 94 | ||
| 95 | static TIMER_CALLBACK(akiko_dma_proc); | |
| 96 | static TIMER_CALLBACK(akiko_frame_proc); | |
| 97 | ||
| 98 | void amiga_akiko_init(void) | |
| 99 | { | |
| 100 | akiko.c2p_input_index = 0; | |
| 101 | akiko.c2p_output_index = 0; | |
| 102 | ||
| 103 | akiko.i2c_state = I2C_WAIT; | |
| 104 | akiko.i2c_bitcounter = -1; | |
| 105 | akiko.i2c_direction = -1; | |
| 106 | akiko.i2c_sda_dir_nvram = 0; | |
| 107 | akiko.i2c_scl_out = 0; | |
| 108 | akiko.i2c_scl_in = 0; | |
| 109 | akiko.i2c_scl_dir = 0; | |
| 110 | akiko.i2c_oscl = 0; | |
| 111 | akiko.i2c_sda_out = 0; | |
| 112 | akiko.i2c_sda_in = 0; | |
| 113 | akiko.i2c_sda_dir = 0; | |
| 114 | akiko.i2c_osda = 0; | |
| 115 | ||
| 116 | akiko.nvram_address = 0; | |
| 117 | akiko.nvram_writeaddr = 0; | |
| 118 | akiko.nvram_rw = 0; | |
| 119 | akiko.nvram_byte = 0; | |
| 120 | memset( akiko.nvram, 0, NVRAM_SIZE ); | |
| 121 | ||
| 122 | akiko.cdrom_status[0] = akiko.cdrom_status[1] = 0; | |
| 123 | akiko.cdrom_address[0] = akiko.cdrom_address[1] = 0; | |
| 124 | akiko.cdrom_track_index = 0; | |
| 125 | akiko.cdrom_lba_start = 0; | |
| 126 | akiko.cdrom_lba_end = 0; | |
| 127 | akiko.cdrom_lba_cur = 0; | |
| 128 | akiko.cdrom_readmask = 0; | |
| 129 | akiko.cdrom_readreqmask = 0; | |
| 130 | akiko.cdrom_dmacontrol = 0; | |
| 131 | akiko.cdrom_numtracks = 0; | |
| 132 | akiko.cdrom_speed = 0; | |
| 133 | akiko.cdrom_cmd_start = 0; | |
| 134 | akiko.cdrom_cmd_end = 0; | |
| 135 | akiko.cdrom_cmd_resp = 0; | |
| 136 | akiko.cdrom = cdrom_open(get_disk_handle(0)); | |
| 137 | akiko.cdrom_toc = NULL; | |
| 138 | akiko.dma_timer = mame_timer_alloc(akiko_dma_proc); | |
| 139 | akiko.frame_timer = mame_timer_alloc(akiko_frame_proc); | |
| 140 | ||
| 141 | /* create the TOC table */ | |
| 142 | if ( akiko.cdrom != NULL && cdrom_get_last_track(akiko.cdrom) ) | |
| 143 | { | |
| 144 | UINT8 *p; | |
| 145 | int i, addrctrl = cdrom_get_adr_control( akiko.cdrom, 0 ); | |
| 146 | UINT32 discend; | |
| 147 | ||
| 148 | discend = cdrom_get_track_start(akiko.cdrom,cdrom_get_last_track(akiko.cdrom)-1); | |
| 149 | discend += cdrom_get_toc(akiko.cdrom)->tracks[cdrom_get_last_track(akiko.cdrom)-1].frames; | |
| 150 | discend = lba_to_msf(discend); | |
| 151 | ||
| 152 | akiko.cdrom_numtracks = cdrom_get_last_track(akiko.cdrom)+3; | |
| 153 | ||
| 154 | akiko.cdrom_toc = (UINT8*)auto_malloc(13*akiko.cdrom_numtracks); | |
| 155 | memset( akiko.cdrom_toc, 0, 13*akiko.cdrom_numtracks); | |
| 156 | ||
| 157 | p = akiko.cdrom_toc; | |
| 158 | p[1] = ((addrctrl & 0x0f) << 4) | ((addrctrl & 0xf0) >> 4); | |
| 159 | p[3] = 0xa0; /* first track */ | |
| 160 | p[8] = 1; | |
| 161 | p += 13; | |
| 162 | p[1] = 0x01; | |
| 163 | p[3] = 0xa1; /* last track */ | |
| 164 | p[8] = cdrom_get_last_track(akiko.cdrom); | |
| 165 | p += 13; | |
| 166 | p[1] = 0x01; | |
| 167 | p[3] = 0xa2; /* disc end */ | |
| 168 | p[8] = (discend >> 16 ) & 0xff; | |
| 169 | p[9] = (discend >> 8 ) & 0xff; | |
| 170 | p[10] = discend & 0xff; | |
| 171 | p += 13; | |
| 172 | ||
| 173 | for( i = 0; i < cdrom_get_last_track(akiko.cdrom); i++ ) | |
| 174 | { | |
| 175 | UINT32 trackpos = cdrom_get_track_start(akiko.cdrom,i); | |
| 176 | ||
| 177 | trackpos = lba_to_msf(trackpos); | |
| 178 | addrctrl = cdrom_get_adr_control( akiko.cdrom, i ); | |
| 179 | ||
| 180 | p[1] = ((addrctrl & 0x0f) << 4) | ((addrctrl & 0xf0) >> 4); | |
| 181 | p[3] = dec_2_bcd( i+1 ); | |
| 182 | p[8] = (trackpos >> 16 ) & 0xff; | |
| 183 | p[9] = (trackpos >> 8 ) & 0xff; | |
| 184 | p[10] = trackpos & 0xff; | |
| 185 | ||
| 186 | p += 13; | |
| 187 | } | |
| 188 | } | |
| 189 | } | |
| 190 | ||
| 191 | static void akiko_i2c( void ) | |
| 192 | { | |
| 193 | akiko.i2c_sda_in = 1; | |
| 194 | ||
| 195 | if ( !akiko.i2c_sda_dir_nvram && akiko.i2c_scl_out && akiko.i2c_oscl ) | |
| 196 | { | |
| 197 | if ( !akiko.i2c_sda_out && akiko.i2c_osda ) /* START-condition? */ | |
| 198 | { | |
| 199 | akiko.i2c_state = I2C_DEVICEADDR; | |
| 200 | akiko.i2c_bitcounter = 0; | |
| 201 | akiko.i2c_direction = -1; | |
| 202 | #if LOG_AKIKO_I2C | |
| 203 | logerror("START\n"); | |
| 204 | #endif | |
| 205 | return; | |
| 206 | } | |
| 207 | else if ( akiko.i2c_sda_out && !akiko.i2c_osda ) /* STOP-condition? */ | |
| 208 | { | |
| 209 | akiko.i2c_state = I2C_WAIT; | |
| 210 | akiko.i2c_bitcounter = -1; | |
| 211 | #if LOG_AKIKO_I2C | |
| 212 | logerror("STOP\n"); | |
| 213 | #endif | |
| 214 | if ( akiko.i2c_direction > 0 ) | |
| 215 | { | |
| 216 | memcpy( akiko.nvram + ( akiko.nvram_address & ~(NVRAM_PAGE_SIZE - 1) ), akiko.nvram_writetmp, NVRAM_PAGE_SIZE ); | |
| 217 | akiko.i2c_direction = -1; | |
| 218 | #if LOG_AKIKO_I2C | |
| 219 | { | |
| 220 | int i; | |
| 221 | ||
| 222 | logerror("NVRAM write address %04X:", akiko.nvram_address & ~(NVRAM_PAGE_SIZE - 1)); | |
| 223 | for (i = 0; i < NVRAM_PAGE_SIZE; i++) | |
| 224 | logerror("%02X", akiko.nvram_writetmp[i]); | |
| 225 | logerror("\n"); | |
| 226 | } | |
| 227 | #endif | |
| 228 | } | |
| 229 | return; | |
| 230 | } | |
| 231 | } | |
| 232 | ||
| 233 | if ( akiko.i2c_bitcounter >= 0 ) | |
| 234 | { | |
| 235 | if ( akiko.i2c_direction ) | |
| 236 | { | |
| 237 | /* Amiga -> NVRAM */ | |
| 238 | if ( akiko.i2c_scl_out && !akiko.i2c_oscl ) | |
| 239 | { | |
| 240 | if ( akiko.i2c_bitcounter == 8 ) | |
| 241 | { | |
| 242 | akiko.i2c_sda_in = 0; /* ACK */ | |
| 243 | ||
| 244 | if ( akiko.i2c_direction > 0 ) | |
| 245 | { | |
| 246 | akiko.nvram_writetmp[akiko.nvram_writeaddr++] = akiko.nvram_byte; | |
| 247 | akiko.nvram_writeaddr &= (NVRAM_PAGE_SIZE - 1); | |
| 248 | akiko.i2c_bitcounter = 0; | |
| 249 | } | |
| 250 | else | |
| 251 | { | |
| 252 | akiko.i2c_bitcounter = -1; | |
| 253 | } | |
| 254 | } | |
| 255 | else | |
| 256 | { | |
| 257 | akiko.nvram_byte <<= 1; | |
| 258 | akiko.nvram_byte |= akiko.i2c_sda_out; | |
| 259 | akiko.i2c_bitcounter++; | |
| 260 | } | |
| 261 | } | |
| 262 | } | |
| 263 | else | |
| 264 | { | |
| 265 | /* NVRAM -> Amiga */ | |
| 266 | if ( akiko.i2c_scl_out && !akiko.i2c_oscl && akiko.i2c_bitcounter < 8 ) | |
| 267 | { | |
| 268 | if ( akiko.i2c_bitcounter == 0 ) | |
| 269 | akiko.nvram_byte = akiko.nvram[akiko.nvram_address]; | |
| 270 | ||
| 271 | akiko.i2c_sda_dir_nvram = 1; | |
| 272 | akiko.i2c_sda_in = (akiko.nvram_byte & 0x80) ? 1 : 0; | |
| 273 | akiko.nvram_byte <<= 1; | |
| 274 | akiko.i2c_bitcounter++; | |
| 275 | ||
| 276 | if ( akiko.i2c_bitcounter == 8 ) | |
| 277 | { | |
| 278 | #if LOG_AKIKO_I2C | |
| 279 | logerror("NVRAM sent byte %02X address %04X\n", akiko.nvram[akiko.nvram_address], akiko.nvram_address); | |
| 280 | #endif | |
| 281 | akiko.nvram_address++; | |
| 282 | akiko.nvram_address &= NVRAM_SIZE - 1; | |
| 283 | akiko.i2c_sda_dir_nvram = 0; | |
| 284 | } | |
| 285 | } | |
| 286 | ||
| 287 | if ( !akiko.i2c_sda_out && akiko.i2c_sda_dir && !akiko.i2c_scl_out ) /* ACK from Amiga */ | |
| 288 | akiko.i2c_bitcounter = 0; | |
| 289 | } | |
| 290 | ||
| 291 | if ( akiko.i2c_bitcounter >= 0 ) | |
| 292 | return; | |
| 293 | } | |
| 294 | ||
| 295 | switch( akiko.i2c_state ) | |
| 296 | { | |
| 297 | case I2C_DEVICEADDR: | |
| 298 | if ( ( akiko.nvram_byte & 0xf0 ) != 0xa0 ) | |
| 299 | { | |
| 300 | #if LOG_AKIKO_I2C | |
| 301 | logerror("WARNING: I2C_DEVICEADDR: device address != 0xA0\n"); | |
| 302 | #endif | |
| 303 | akiko.i2c_state = I2C_WAIT; | |
| 304 | return; | |
| 305 | } | |
| 306 | ||
| 307 | akiko.nvram_rw = (akiko.nvram_byte & 1) ? 0 : 1; | |
| 308 | ||
| 309 | if ( akiko.nvram_rw ) | |
| 310 | { | |
| 311 | /* 2 high address bits, only fetched if WRITE = 1 */ | |
| 312 | akiko.nvram_address &= 0xff; | |
| 313 | akiko.nvram_address |= ((akiko.nvram_byte >> 1) & 3) << 8; | |
| 314 | akiko.i2c_state = I2C_WORDADDR; | |
| 315 | akiko.i2c_direction = -1; | |
| 316 | } | |
| 317 | else | |
| 318 | { | |
| 319 | akiko.i2c_state = I2C_DATA; | |
| 320 | akiko.i2c_direction = 0; | |
| 321 | akiko.i2c_sda_dir_nvram = 1; | |
| 322 | } | |
| 323 | ||
| 324 | akiko.i2c_bitcounter = 0; | |
| 325 | #if LOG_AKIKO_I2C | |
| 326 | logerror("I2C_DEVICEADDR: rw %d, address %02Xxx\n", akiko.nvram_rw, akiko.nvram_address >> 8); | |
| 327 | #endif | |
| 328 | break; | |
| 329 | ||
| 330 | case I2C_WORDADDR: | |
| 331 | akiko.nvram_address &= 0x300; | |
| 332 | akiko.nvram_address |= akiko.nvram_byte; | |
| 333 | ||
| 334 | #if LOG_AKIKO_I2C | |
| 335 | logerror("I2C_WORDADDR: address %04X\n", akiko.nvram_address); | |
| 336 | #endif | |
| 337 | if ( akiko.i2c_direction < 0 ) | |
| 338 | { | |
| 339 | memcpy( akiko.nvram_writetmp, akiko.nvram + (akiko.nvram_address & ~(NVRAM_PAGE_SIZE - 1)), NVRAM_PAGE_SIZE); | |
| 340 | akiko.nvram_writeaddr = akiko.nvram_address & (NVRAM_PAGE_SIZE - 1); | |
| 341 | } | |
| 342 | ||
| 343 | akiko.i2c_state = I2C_DATA; | |
| 344 | akiko.i2c_bitcounter = 0; | |
| 345 | akiko.i2c_direction = 1; | |
| 346 | break; | |
| 347 | } | |
| 348 | } | |
| 349 | ||
| 350 | static void akiko_nvram_write(UINT32 data) | |
| 351 | { | |
| 352 | int sda; | |
| 353 | ||
| 354 | akiko.i2c_oscl = akiko.i2c_scl_out; | |
| 355 | akiko.i2c_scl_out = BIT(data,31); | |
| 356 | akiko.i2c_osda = akiko.i2c_sda_out; | |
| 357 | akiko.i2c_sda_out = BIT(data,30); | |
| 358 | akiko.i2c_scl_dir = BIT(data,15); | |
| 359 | akiko.i2c_sda_dir = BIT(data,14); | |
| 360 | ||
| 361 | sda = akiko.i2c_sda_out; | |
| 362 | if ( akiko.i2c_oscl != akiko.i2c_scl_out || akiko.i2c_osda != sda ) | |
| 363 | { | |
| 364 | akiko_i2c(); | |
| 365 | akiko.i2c_oscl = akiko.i2c_scl_out; | |
| 366 | akiko.i2c_osda = sda; | |
| 367 | } | |
| 368 | } | |
| 369 | ||
| 370 | static UINT32 akiko_nvram_read(void) | |
| 371 | { | |
| 372 | UINT32 v = 0; | |
| 373 | ||
| 374 | if ( !akiko.i2c_scl_dir ) | |
| 375 | v |= akiko.i2c_scl_in ? (1<<31) : 0x00; | |
| 376 | else | |
| 377 | v |= akiko.i2c_scl_out ? (1<<31) : 0x00; | |
| 378 | ||
| 379 | if ( !akiko.i2c_sda_dir ) | |
| 380 | v |= akiko.i2c_sda_in ? (1<<30) : 0x00; | |
| 381 | else | |
| 382 | v |= akiko.i2c_sda_out ? (1<<30) : 0x00; | |
| 383 | ||
| 384 | v |= akiko.i2c_scl_dir ? (1<<15) : 0x00; | |
| 385 | v |= akiko.i2c_sda_dir ? (1<<14) : 0x00; | |
| 386 | ||
| 387 | return v; | |
| 388 | } | |
| 389 | ||
| 390 | NVRAM_HANDLER( cd32 ) | |
| 391 | { | |
| 392 | if (read_or_write) | |
| 393 | /* save the SRAM settings */ | |
| 394 | mame_fwrite(file, akiko.nvram, NVRAM_SIZE); | |
| 395 | else | |
| 396 | { | |
| 397 | /* load the SRAM settings */ | |
| 398 | if (file) | |
| 399 | mame_fread(file, akiko.nvram, NVRAM_SIZE); | |
| 400 | else | |
| 401 | memset(akiko.nvram, 0, NVRAM_SIZE); | |
| 402 | } | |
| 403 | } | |
| 404 | ||
| 405 | /************************************* | |
| 406 | * | |
| 407 | * Akiko Chunky to Planar converter | |
| 408 | * | |
| 409 | ************************************/ | |
| 410 | ||
| 411 | static void akiko_c2p_write(UINT32 data) | |
| 412 | { | |
| 413 | akiko.c2p_input_buffer[akiko.c2p_input_index] = data; | |
| 414 | akiko.c2p_input_index++; | |
| 415 | akiko.c2p_input_index &= 7; | |
| 416 | akiko.c2p_output_index = 0; | |
| 417 | } | |
| 418 | ||
| 419 | static UINT32 akiko_c2p_read(void) | |
| 420 | { | |
| 421 | UINT32 val; | |
| 422 | ||
| 423 | if ( akiko.c2p_output_index == 0 ) | |
| 424 | { | |
| 425 | int i; | |
| 426 | ||
| 427 | for ( i = 0; i < 8; i++ ) | |
| 428 | akiko.c2p_output_buffer[i] = 0; | |
| 429 | ||
| 430 | for (i = 0; i < 8 * 32; i++) { | |
| 431 | if (akiko.c2p_input_buffer[7 - (i >> 5)] & (1 << (i & 31))) | |
| 432 | akiko.c2p_output_buffer[i & 7] |= 1 << (i >> 3); | |
| 433 | } | |
| 434 | } | |
| 435 | akiko.c2p_input_index = 0; | |
| 436 | val = akiko.c2p_output_buffer[akiko.c2p_output_index]; | |
| 437 | akiko.c2p_output_index++; | |
| 438 | akiko.c2p_output_index &= 7; | |
| 439 | return val; | |
| 440 | } | |
| 441 | ||
| 442 | #if LOG_AKIKO | |
| 443 | static const char* akiko_reg_names[] = | |
| 444 | { | |
| 445 | /*0*/ "ID", | |
| 446 | /*1*/ "CDROM STATUS 1", | |
| 447 | /*2*/ "CDROM_STATUS 2", | |
| 448 | /*3*/ "???", | |
| 449 | /*4*/ "CDROM ADDRESS 1", | |
| 450 | /*5*/ "CDROM ADDRESS 2", | |
| 451 | /*6*/ "CDROM COMMAND 1", | |
| 452 | /*7*/ "CDROM COMMAND 2", | |
| 453 | /*8*/ "CDROM READMASK", | |
| 454 | /*9*/ "CDROM DMACONTROL", | |
| 455 | /*A*/ "???", | |
| 456 | /*B*/ "???", | |
| 457 | /*C*/ "NVRAM", | |
| 458 | /*D*/ "???", | |
| 459 | /*E*/ "C2P" | |
| 460 | }; | |
| 461 | ||
| 462 | const char* get_akiko_reg_name(int reg) | |
| 463 | { | |
| 464 | if (reg < 0xf ) | |
| 465 | { | |
| 466 | return akiko_reg_names[reg]; | |
| 467 | } | |
| 468 | else | |
| 469 | { | |
| 470 | return "???"; | |
| 471 | } | |
| 472 | } | |
| 473 | #endif | |
| 474 | ||
| 475 | /************************************* | |
| 476 | * | |
| 477 | * Akiko CDROM Controller | |
| 478 | * | |
| 479 | ************************************/ | |
| 480 | ||
| 481 | static void akiko_cdda_stop( void ) | |
| 482 | { | |
| 483 | int cddanum = cdda_num_from_cdrom(akiko.cdrom); | |
| 484 | ||
| 485 | if (cddanum != -1) | |
| 486 | { | |
| 487 | cdda_stop_audio(cddanum); | |
| 488 | mame_timer_reset( akiko.frame_timer, time_never ); | |
| 489 | } | |
| 490 | } | |
| 491 | ||
| 492 | static void akiko_cdda_play( UINT32 lba, UINT32 num_blocks ) | |
| 493 | { | |
| 494 | int cddanum = cdda_num_from_cdrom(akiko.cdrom); | |
| 495 | if (cddanum != -1) | |
| 496 | { | |
| 497 | cdda_start_audio(cddanum, lba, num_blocks); | |
| 498 | mame_timer_adjust( akiko.frame_timer, MAME_TIME_IN_HZ( 75 ), 0, time_zero ); | |
| 499 | } | |
| 500 | } | |
| 501 | ||
| 502 | static void akiko_cdda_pause( int pause ) | |
| 503 | { | |
| 504 | int cddanum = cdda_num_from_cdrom(akiko.cdrom); | |
| 505 | if (cddanum != -1) | |
| 506 | { | |
| 507 | if (cdda_audio_active(cddanum) && cdda_audio_paused(cddanum) != pause ) | |
| 508 | { | |
| 509 | cdda_pause_audio(cddanum, pause); | |
| 510 | ||
| 511 | if ( pause ) | |
| 512 | { | |
| 513 | mame_timer_reset( akiko.frame_timer, time_never ); | |
| 514 | } | |
| 515 | else | |
| 516 | { | |
| 517 | mame_timer_adjust( akiko.frame_timer, MAME_TIME_IN_HZ( 75 ), 0, time_zero ); | |
| 518 | } | |
| 519 | } | |
| 520 | } | |
| 521 | } | |
| 522 | ||
| 523 | static UINT8 akiko_cdda_getstatus( UINT32 *lba ) | |
| 524 | { | |
| 525 | int cddanum = cdda_num_from_cdrom(akiko.cdrom); | |
| 526 | ||
| 527 | if ( lba ) *lba = 0; | |
| 528 | ||
| 529 | if (cddanum != -1) | |
| 530 | { | |
| 531 | if (cdda_audio_active(cddanum)) | |
| 532 | { | |
| 533 | if ( lba ) *lba = cdda_get_audio_lba(cddanum); | |
| 534 | ||
| 535 | if (cdda_audio_paused(cddanum)) | |
| 536 | { | |
| 537 | return 0x12; /* audio paused */ | |
| 538 | } | |
| 539 | else | |
| 540 | { | |
| 541 | return 0x11; /* audio in progress */ | |
| 542 | } | |
| 543 | } | |
| 544 | else if (cdda_audio_ended(cddanum)) | |
| 545 | { | |
| 546 | return 0x13; /* audio ended */ | |
| 547 | } | |
| 548 | } | |
| 549 | ||
| 550 | return 0x15; /* no audio status */ | |
| 551 | } | |
| 552 | ||
| 553 | static void akiko_set_cd_status( UINT32 status ) | |
| 554 | { | |
| 555 | akiko.cdrom_status[0] |= status; | |
| 556 | ||
| 557 | if ( akiko.cdrom_status[0] & akiko.cdrom_status[1] ) | |
| 558 | { | |
| 559 | #if LOG_AKIKO_CD | |
| 560 | logerror( "Akiko CD IRQ\n" ); | |
| 561 | #endif | |
| 562 | amiga_custom_w(REG_INTREQ, 0x8000 | INTENA_PORTS, 0); | |
| 563 | } | |
| 564 | } | |
| 565 | ||
| 566 | static TIMER_CALLBACK(akiko_frame_proc) | |
| 567 | { | |
| 568 | int cddanum = cdda_num_from_cdrom(akiko.cdrom); | |
| 569 | ||
| 570 | (void)param; | |
| 571 | ||
| 572 | if (cddanum != -1) | |
| 573 | { | |
| 574 | UINT8 s = akiko_cdda_getstatus(NULL); | |
| 575 | ||
| 576 | if ( s == 0x11 ) | |
| 577 | { | |
| 578 | akiko_set_cd_status( 0x80000000 ); /* subcode ready */ | |
| 579 | } | |
| 580 | ||
| 581 | mame_timer_adjust( akiko.frame_timer, MAME_TIME_IN_HZ( 75 ), 0, time_zero ); | |
| 582 | } | |
| 583 | } | |
| 584 | ||
| 585 | static UINT32 lba_from_triplet( UINT8 *triplet ) | |
| 586 | { | |
| 587 | UINT32 r; | |
| 588 | ||
| 589 | r = bcd_2_dec(triplet[0]) * (60*75); | |
| 590 | r += bcd_2_dec(triplet[1]) * 75; | |
| 591 | r += bcd_2_dec(triplet[2]); | |
| 592 | ||
| 593 | return r; | |
| 594 | } | |
| 595 | ||
| 596 | static TIMER_CALLBACK(akiko_dma_proc) | |
| 597 | { | |
| 598 | UINT8 buf[2352]; | |
| 599 | int index; | |
| 600 | ||
| 601 | if ( (akiko.cdrom_dmacontrol & 0x04000000) == 0 ) | |
| 602 | return; | |
| 603 | ||
| 604 | if ( akiko.cdrom_readreqmask == 0 ) | |
| 605 | return; | |
| 606 | ||
| 607 | index = (akiko.cdrom_lba_cur - akiko.cdrom_lba_start) & 0x0f; | |
| 608 | ||
| 609 | if ( akiko.cdrom_readreqmask & ( 1 << index ) ) | |
| 610 | { | |
| 611 | UINT32 track = cdrom_get_track( akiko.cdrom, akiko.cdrom_lba_cur ); | |
| 612 | UINT32 datasize = cdrom_get_toc( akiko.cdrom )->tracks[track].datasize; | |
| 613 | UINT32 subsize = cdrom_get_toc( akiko.cdrom )->tracks[track].subsize; | |
| 614 | UINT32 secsize = datasize + subsize; | |
| 615 | int i; | |
| 616 | ||
| 617 | if ( secsize <= (2352-16) ) | |
| 618 | { | |
| 619 | UINT32 curmsf = lba_to_msf( akiko.cdrom_lba_cur ); | |
| 620 | memset( buf, 0, 16 ); | |
| 621 | ||
| 622 | buf[3] = akiko.cdrom_lba_cur - akiko.cdrom_lba_start; | |
| 623 | memset( &buf[4], 0xff, 8 ); | |
| 624 | ||
| 625 | buf[12] = (curmsf >> 16) & 0xff; | |
| 626 | buf[13] = (curmsf >> 8) & 0xff; | |
| 627 | buf[14] = curmsf & 0xff; | |
| 628 | buf[15] = 0x01; /* mode1 */ | |
| 629 | ||
| 630 | if ( !cdrom_read_data( akiko.cdrom, akiko.cdrom_lba_cur, &buf[16], CD_TRACK_RAW_DONTCARE ) ) | |
| 631 | { | |
| 632 | logerror( "AKIKO: Read error trying to read sector %08x!\n", akiko.cdrom_lba_cur ); | |
| 633 | return; | |
| 634 | } | |
| 635 | ||
| 636 | if ( subsize ) | |
| 637 | { | |
| 638 | if ( !cdrom_read_subcode( akiko.cdrom, akiko.cdrom_lba_cur, &buf[16+datasize] ) ) | |
| 639 | { | |
| 640 | logerror( "AKIKO: Read error trying to read subcode for sector %08x!\n", akiko.cdrom_lba_cur ); | |
| 641 | return; | |
| 642 | } | |
| 643 | } | |
| 644 | } | |
| 645 | else | |
| 646 | { | |
| 647 | if ( !cdrom_read_data( akiko.cdrom, akiko.cdrom_lba_cur, buf, CD_TRACK_RAW_DONTCARE) ) | |
| 648 | { | |
| 649 | logerror( "AKIKO: Read error trying to read sector %08x!\n", akiko.cdrom_lba_cur ); | |
| 650 | return; | |
| 651 | } | |
| 652 | ||
| 653 | if ( subsize ) | |
| 654 | { | |
| 655 | if ( !cdrom_read_subcode( akiko.cdrom, akiko.cdrom_lba_cur, &buf[datasize] ) ) | |
| 656 | { | |
| 657 | logerror( "AKIKO: Read error trying to read subcode for sector %08x!\n", akiko.cdrom_lba_cur ); | |
| 658 | return; | |
| 659 | } | |
| 660 | } | |
| 661 | } | |
| 662 | ||
| 663 | #if LOG_AKIKO_CD | |
| 664 | logerror( "DMA: sector %d - address %08x\n", akiko.cdrom_lba_cur, akiko.cdrom_address[0] + (index*4096) ); | |
| 665 | #endif | |
| 666 | ||
| 667 | for( i = 0; i < 2352; i += 2 ) | |
| 668 | { | |
| 669 | UINT16 data; | |
| 670 | ||
| 671 | data = buf[i]; | |
| 672 | data <<= 8; | |
| 673 | data |= buf[i+1]; | |
| 674 | ||
| 675 | amiga_chip_ram_w( akiko.cdrom_address[0] + (index*4096) + i, data ); | |
| 676 | } | |
| 677 | ||
| 678 | akiko.cdrom_readmask |= ( 1 << index ); | |
| 679 | akiko.cdrom_readreqmask &= ~( 1 << index ); | |
| 680 | akiko.cdrom_lba_cur++; | |
| 681 | } | |
| 682 | ||
| 683 | if ( akiko.cdrom_readreqmask == 0 ) | |
| 684 | akiko_set_cd_status(0x04000000); | |
| 685 | else | |
| 686 | mame_timer_adjust( akiko.dma_timer, MAME_TIME_IN_USEC( CD_SECTOR_TIME / akiko.cdrom_speed ), 0, time_zero ); | |
| 687 | } | |
| 688 | ||
| 689 | static void akiko_start_dma( void ) | |
| 690 | { | |
| 691 | if ( akiko.cdrom_readreqmask == 0 ) | |
| 692 | return; | |
| 693 | ||
| 694 | if ( akiko.cdrom_lba_start > akiko.cdrom_lba_end ) | |
| 695 | return; | |
| 696 | ||
| 697 | if ( akiko.cdrom_speed == 0 ) | |
| 698 | return; | |
| 699 | ||
| 700 | akiko.cdrom_lba_cur = akiko.cdrom_lba_start; | |
| 701 | ||
| 702 | mame_timer_adjust( akiko.dma_timer, MAME_TIME_IN_USEC( CD_SECTOR_TIME / akiko.cdrom_speed ), 0, time_zero ); | |
| 703 | } | |
| 704 | ||
| 705 | static void akiko_setup_response( int len, UINT8 *r1 ) | |
| 706 | { | |
| 707 | int resp_addr = akiko.cdrom_address[1]; | |
| 708 | UINT8 resp_csum = 0xff; | |
| 709 | UINT8 resp_buffer[32]; | |
| 710 | int i; | |
| 711 | ||
| 712 | memset( resp_buffer, 0, sizeof( resp_buffer ) ); | |
| 713 | ||
| 714 | for( i = 0; i < len; i++ ) | |
| 715 | { | |
| 716 | resp_buffer[i] = r1[i]; | |
| 717 | resp_csum -= resp_buffer[i]; | |
| 718 | } | |
| 719 | ||
| 720 | resp_buffer[len++] = resp_csum; | |
| 721 | ||
| 722 | for( i = 0; i < len; i++ ) | |
| 723 | { | |
| 724 | program_write_byte( resp_addr + ((akiko.cdrom_cmd_resp + i) & 0xff), resp_buffer[i] ); | |
| 725 | } | |
| 726 | ||
| 727 | akiko.cdrom_cmd_resp = (akiko.cdrom_cmd_resp+len) & 0xff; | |
| 728 | ||
| 729 | akiko_set_cd_status( 0x10000000 ); /* new data available */ | |
| 730 | } | |
| 731 | ||
| 732 | static TIMER_CALLBACK( akiko_cd_delayed_cmd ) | |
| 733 | { | |
| 734 | UINT8 resp[32]; | |
| 735 | UINT8 cddastatus; | |
| 736 | ||
| 737 | if ( akiko.cdrom_status[0] & 0x10000000 ) | |
| 738 | return; | |
| 739 | ||
| 740 | cddastatus = akiko_cdda_getstatus(NULL); | |
| 741 | ||
| 742 | if ( cddastatus == 0x11 || cddastatus == 0x12 ) | |
| 743 | return; | |
| 744 | ||
| 745 | memset( resp, 0, sizeof( resp ) ); | |
| 746 | resp[0] = param; | |
| 747 | ||
| 748 | param &= 0x0f; | |
| 749 | ||
| 750 | if ( param == 0x05 ) | |
| 751 | { | |
| 752 | #if LOG_AKIKO_CD | |
| 753 | logerror( "AKIKO: Completing Command %d\n", param ); | |
| 754 | #endif | |
| 755 | ||
| 756 | resp[0] = 0x06; | |
| 757 | ||
| 758 | if ( akiko.cdrom == NULL || akiko.cdrom_numtracks == 0 ) | |
| 759 | { | |
| 760 | resp[1] = 0x80; | |
| 761 | akiko_setup_response( 15, resp ); | |
| 762 | } | |
| 763 | else | |
| 764 | { | |
| 765 | resp[1] = 0x00; | |
| 766 | memcpy( &resp[2], &akiko.cdrom_toc[13*akiko.cdrom_track_index], 13 ); | |
| 767 | ||
| 768 | akiko.cdrom_track_index = ( akiko.cdrom_track_index + 1 ) % akiko.cdrom_numtracks; | |
| 769 | ||
| 770 | akiko_setup_response( 15, resp ); | |
| 771 | } | |
| 772 | } | |
| 773 | } | |
| 774 | ||
| 775 | static void akiko_update_cdrom( void ) | |
| 776 | { | |
| 777 | UINT8 resp[32], cmdbuf[32]; | |
| 778 | ||
| 779 | if ( akiko.cdrom_status[0] & 0x10000000 ) | |
| 780 | return; | |
| 781 | ||
| 782 | while ( akiko.cdrom_cmd_start != akiko.cdrom_cmd_end ) | |
| 783 | { | |
| 784 | UINT32 cmd_addr = akiko.cdrom_address[1] + 0x200 + akiko.cdrom_cmd_start; | |
| 785 | int cmd = program_read_byte( cmd_addr ); | |
| 786 | ||
| 787 | memset( resp, 0, sizeof( resp ) ); | |
| 788 | resp[0] = cmd; | |
| 789 | ||
| 790 | cmd &= 0x0f; | |
| 791 | ||
| 792 | #if LOG_AKIKO_CD | |
| 793 | logerror( "CDROM command: %02X\n", cmd ); | |
| 794 | #endif | |
| 795 | ||
| 796 | if ( cmd == 0x02 ) /* pause audio */ | |
| 797 | { | |
| 798 | resp[1] = 0x00; | |
| 799 | ||
| 800 | if ( akiko_cdda_getstatus(NULL) == 0x11 ) | |
| 801 | resp[1] = 0x08; | |
| 802 | ||
| 803 | akiko_cdda_pause( 1 ); | |
| 804 | ||
| 805 | akiko.cdrom_cmd_start = (akiko.cdrom_cmd_start+2) & 0xff; | |
| 806 | ||
| 807 | akiko_setup_response( 2, resp ); | |
| 808 | } | |
| 809 | else if ( cmd == 0x03 ) /* unpause audio (and check audiocd playing status) */ | |
| 810 | { | |
| 811 | resp[1] = 0x00; | |
| 812 | ||
| 813 | if ( akiko_cdda_getstatus(NULL) == 0x11 ) | |
| 814 | resp[1] = 0x08; | |
| 815 | ||
| 816 | akiko_cdda_pause( 0 ); | |
| 817 | ||
| 818 | akiko.cdrom_cmd_start = (akiko.cdrom_cmd_start+2) & 0xff; | |
| 819 | ||
| 820 | akiko_setup_response( 2, resp ); | |
| 821 | } | |
| 822 | else if ( cmd == 0x04 ) /* seek/read/play cd multi command */ | |
| 823 | { | |
| 824 | int i; | |
| 825 | UINT32 startpos, endpos; | |
| 826 | ||
| 827 | for( i = 0; i < 13; i++ ) | |
| 828 | { | |
| 829 | cmdbuf[i] = program_read_byte( cmd_addr ); | |
| 830 | cmd_addr &= 0xffffff00; | |
| 831 | cmd_addr += ( akiko.cdrom_cmd_start + i + 1 ) & 0xff; | |
| 832 | } | |
| 833 | ||
| 834 | akiko.cdrom_cmd_start = (akiko.cdrom_cmd_start+13) & 0xff; | |
| 835 | ||
| 836 | if ( akiko.cdrom == NULL || akiko.cdrom_numtracks == 0 ) | |
| 837 | { | |
| 838 | resp[1] = 0x80; | |
| 839 | akiko_setup_response( 2, resp ); | |
| 840 | } | |
| 841 | else | |
| 842 | { | |
| 843 | startpos = lba_from_triplet( &cmdbuf[1] ); | |
| 844 | endpos = lba_from_triplet( &cmdbuf[4] ); | |
| 845 | ||
| 846 | akiko_cdda_stop(); | |
| 847 | ||
| 848 | resp[1] = 0x00; | |
| 849 | ||
| 850 | if ( cmdbuf[7] == 0x80 ) | |
| 851 | { | |
| 852 | #if LOG_AKIKO_CD | |
| 853 | logerror( "AKIKO CD: PC:%06x Data read - start lba: %08x - end lba: %08x\n", safe_activecpu_get_pc(), startpos, endpos ); | |
| 854 | #endif | |
| 855 | akiko.cdrom_speed = (cmdbuf[8] & 0x40) ? 2 : 1; | |
| 856 | akiko.cdrom_lba_start = startpos; | |
| 857 | akiko.cdrom_lba_end = endpos; | |
| 858 | ||
| 859 | resp[1] = 0x02; | |
| 860 | } | |
| 861 | else if ( cmdbuf[10] & 0x04 ) | |
| 862 | { | |
| 863 | logerror( "AKIKO CD: Audio Play - start lba: %08x - end lba: %08x\n", startpos, endpos ); | |
| 864 | akiko_cdda_play( startpos, endpos - startpos ); | |
| 865 | resp[1] = 0x08; | |
| 866 | } | |
| 867 | else | |
| 868 | { | |
| 869 | #if LOG_AKIKO_CD | |
| 870 | logerror( "AKIKO CD: Seek - start lba: %08x - end lba: %08x\n", startpos, endpos ); | |
| 871 | #endif | |
| 872 | akiko.cdrom_track_index = 0; | |
| 873 | ||
| 874 | for( i = 0; i < cdrom_get_last_track(akiko.cdrom); i++ ) | |
| 875 | { | |
| 876 | if ( startpos <= cdrom_get_track_start( akiko.cdrom, i ) ) | |
| 877 | { | |
| 878 | /* reset to 0 */ | |
| 879 | akiko.cdrom_track_index = i + 2; | |
| 880 | akiko.cdrom_track_index %= akiko.cdrom_numtracks; | |
| 881 | break; | |
| 882 | } | |
| 883 | } | |
| 884 | } | |
| 885 | ||
| 886 | akiko_setup_response( 2, resp ); | |
| 887 | } | |
| 888 | } | |
| 889 | else if ( cmd == 0x05 ) /* read toc */ | |
| 890 | { | |
| 891 | akiko.cdrom_cmd_start = (akiko.cdrom_cmd_start+3) & 0xff; | |
| 892 | ||
| 893 | mame_timer_set( MAME_TIME_IN_MSEC(1), resp[0], akiko_cd_delayed_cmd ); | |
| 894 | ||
| 895 | break; | |
| 896 | } | |
| 897 | else if ( cmd == 0x06 ) /* read subq */ | |
| 898 | { | |
| 899 | UINT32 lba; | |
| 900 | ||
| 901 | resp[1] = 0x00; | |
| 902 | ||
| 903 | (void)akiko_cdda_getstatus( &lba ); | |
| 904 | ||
| 905 | if ( lba > 0 ) | |
| 906 | { | |
| 907 | UINT32 disk_pos; | |
| 908 | UINT32 track_pos; | |
| 909 | UINT32 track; | |
| 910 | int addrctrl; | |
| 911 | ||
| 912 | track = cdrom_get_track(akiko.cdrom, lba); | |
| 913 | addrctrl = cdrom_get_adr_control(akiko.cdrom, track); | |
| 914 | ||
| 915 | resp[2] = 0x00; | |
| 916 | resp[3] = ((addrctrl & 0x0f) << 4) | ((addrctrl & 0xf0) >> 4); | |
| 917 | resp[4] = dec_2_bcd(track+1); | |
| 918 | resp[5] = 0; /* index */ | |
| 919 | ||
| 920 | disk_pos = lba_to_msf(lba); | |
| 921 | track_pos = lba_to_msf(lba - cdrom_get_track_start(akiko.cdrom, track)); | |
| 922 | ||
| 923 | /* track position */ | |
| 924 | resp[6] = (track_pos >> 16) & 0xff; | |
| 925 | resp[7] = (track_pos >> 8) & 0xff; | |
| 926 | resp[8] = track_pos & 0xff; | |
| 927 | ||
| 928 | /* disk position */ | |
| 929 | resp[9] = (disk_pos >> 24) & 0xff; | |
| 930 | resp[10] = (disk_pos >> 16) & 0xff; | |
| 931 | resp[11] = (disk_pos >> 8) & 0xff; | |
| 932 | resp[12] = disk_pos & 0xff; | |
| 933 | } | |
| 934 | else | |
| 935 | { | |
| 936 | resp[1] = 0x80; | |
| 937 | } | |
| 938 | ||
| 939 | akiko_setup_response( 15, resp ); | |
| 940 | } | |
| 941 | else if ( cmd == 0x07 ) /* check door status */ | |
| 942 | { | |
| 943 | resp[1] = 0x01; | |
| 944 | ||
| 945 | akiko.cdrom_cmd_start = (akiko.cdrom_cmd_start+2) & 0xff; | |
| 946 | ||
| 947 | if ( akiko.cdrom == NULL || akiko.cdrom_numtracks == 0 ) | |
| 948 | resp[1] = 0x80; | |
| 949 | ||
| 950 | akiko_setup_response( 20, resp ); | |
| 951 | break; | |
| 952 | } | |
| 953 | else | |
| 954 | { | |
| 955 | break; | |
| 956 | } | |
| 957 | } | |
| 958 | } | |
| 959 | ||
| 960 | READ32_HANDLER(amiga_akiko32_r) | |
| 961 | { | |
| 962 | UINT32 retval; | |
| 963 | ||
| 964 | #if LOG_AKIKO | |
| 965 | if ( offset < (0x30/4) ) | |
| 966 | { | |
| 967 | logerror( "Reading AKIKO reg %0x [%s] at PC=%06x\n", offset, get_akiko_reg_name(offset), activecpu_get_pc() ); | |
| 968 | } | |
| 969 | #endif | |
| 970 | ||
| 971 | switch( offset ) | |
| 972 | { | |
| 973 | case 0x00/4: /* ID */ | |
| 974 | if ( akiko.cdrom != NULL ) cdda_set_cdrom(0, akiko.cdrom); | |
| 975 | return 0x0000cafe; | |
| 976 | ||
| 977 | case 0x04/4: /* CDROM STATUS 1 */ | |
| 978 | return akiko.cdrom_status[0]; | |
| 979 | ||
| 980 | case 0x08/4: /* CDROM STATUS 2 */ | |
| 981 | return akiko.cdrom_status[1]; | |
| 982 | ||
| 983 | case 0x10/4: /* CDROM ADDRESS 1 */ | |
| 984 | return akiko.cdrom_address[0]; | |
| 985 | ||
| 986 | case 0x14/4: /* CDROM ADDRESS 2 */ | |
| 987 | return akiko.cdrom_address[1]; | |
| 988 | ||
| 989 | case 0x18/4: /* CDROM COMMAND 1 */ | |
| 990 | akiko_update_cdrom(); | |
| 991 | retval = akiko.cdrom_cmd_start; | |
| 992 | retval <<= 8; | |
| 993 | retval |= akiko.cdrom_cmd_resp; | |
| 994 | retval <<= 8; | |
| 995 | return retval; | |
| 996 | ||
| 997 | case 0x1C/4: /* CDROM COMMAND 2 */ | |
| 998 | akiko_update_cdrom(); | |
| 999 | retval = akiko.cdrom_cmd_end; | |
| 1000 | retval <<= 16; | |
| 1001 | return retval; | |
| 1002 | ||
| 1003 | case 0x20/4: /* CDROM DMA SECTOR READ MASK */ | |
| 1004 | retval = akiko.cdrom_readmask << 16; | |
| 1005 | return retval; | |
| 1006 | ||
| 1007 | case 0x24/4: /* CDROM DMA ENABLE? */ | |
| 1008 | retval = akiko.cdrom_dmacontrol; | |
| 1009 | return retval; | |
| 1010 | ||
| 1011 | case 0x30/4: /* NVRAM */ | |
| 1012 | return akiko_nvram_read(); | |
| 1013 | ||
| 1014 | case 0x38/4: /* C2P */ | |
| 1015 | return akiko_c2p_read(); | |
| 1016 | ||
| 1017 | default: | |
| 1018 | break; | |
| 1019 | } | |
| 1020 | ||
| 1021 | return 0; | |
| 1022 | } | |
| 1023 | ||
| 1024 | WRITE32_HANDLER(amiga_akiko32_w) | |
| 1025 | { | |
| 1026 | #if LOG_AKIKO | |
| 1027 | if ( offset < (0x30/4) ) | |
| 1028 | { | |
| 1029 | logerror( "Writing AKIKO reg %0x [%s] with %08x at PC=%06x\n", offset, get_akiko_reg_name(offset), data, activecpu_get_pc() ); | |
| 1030 | } | |
| 1031 | #endif | |
| 1032 | ||
| 1033 | switch( offset ) | |
| 1034 | { | |
| 1035 | case 0x04/4: /* CDROM STATUS 1 */ | |
| 1036 | akiko.cdrom_status[0] = data; | |
| 1037 | break; | |
| 1038 | ||
| 1039 | case 0x08/4: /* CDROM STATUS 2 */ | |
| 1040 | akiko.cdrom_status[1] = data; | |
| 1041 | akiko.cdrom_status[0] &= data; | |
| 1042 | break; | |
| 1043 | ||
| 1044 | case 0x10/4: /* CDROM ADDRESS 1 */ | |
| 1045 | akiko.cdrom_address[0] = data; | |
| 1046 | break; | |
| 1047 | ||
| 1048 | case 0x14/4: /* CDROM ADDRESS 2 */ | |
| 1049 | akiko.cdrom_address[1] = data; | |
| 1050 | break; | |
| 1051 | ||
| 1052 | case 0x18/4: /* CDROM COMMAND 1 */ | |
| 1053 | if ( ( mem_mask & 0x00ff0000 ) == 0 ) | |
| 1054 | akiko.cdrom_cmd_start = ( data >> 16 ) & 0xff; | |
| 1055 | ||
| 1056 | if ( ( mem_mask & 0x0000ff00 ) == 0 ) | |
| 1057 | akiko.cdrom_cmd_resp = ( data >> 8 ) & 0xff; | |
| 1058 | ||
| 1059 | akiko_update_cdrom(); | |
| 1060 | break; | |
| 1061 | ||
| 1062 | case 0x1C/4: /* CDROM COMMAND 2 */ | |
| 1063 | if ( ( mem_mask & 0x00ff0000 ) == 0 ) | |
| 1064 | akiko.cdrom_cmd_end = ( data >> 16 ) & 0xff; | |
| 1065 | ||
| 1066 | akiko_update_cdrom(); | |
| 1067 | break; | |
| 1068 | ||
| 1069 | case 0x20/4: /* CDROM DMA SECTOR READ REQUEST WRITE */ | |
| 1070 | #if LOG_AKIKO_CD | |
| 1071 | logerror( "Read Req mask W: data %08x - mem mask %08x\n", data, mem_mask ); | |
| 1072 | #endif | |
| 1073 | if ( ( mem_mask & 0xffff0000 ) == 0 ) | |
| 1074 | { | |
| 1075 | akiko.cdrom_readreqmask = (data >> 16); | |
| 1076 | akiko.cdrom_readmask = 0; | |
| 1077 | } | |
| 1078 | break; | |
| 1079 | ||
| 1080 | case 0x24/4: /* CDROM DMA ENABLE? */ | |
| 1081 | #if LOG_AKIKO_CD | |
| 1082 | logerror( "DMA enable W: data %08x - mem mask %08x\n", data, mem_mask ); | |
| 1083 | #endif | |
| 1084 | if ( ( akiko.cdrom_dmacontrol ^ data ) & 0x04000000 ) | |
| 1085 | { | |
| 1086 | if ( data & 0x04000000 ) | |
| 1087 | akiko_start_dma(); | |
| 1088 | } | |
| 1089 | akiko.cdrom_dmacontrol = data; | |
| 1090 | break; | |
| 1091 | ||
| 1092 | case 0x30/4: | |
| 1093 | akiko_nvram_write(data); | |
| 1094 | break; | |
| 1095 | ||
| 1096 | case 0x38/4: | |
| 1097 | akiko_c2p_write(data); | |
| 1098 | break; | |
| 1099 | ||
| 1100 | default: | |
| 1101 | break; | |
| 1102 | } | |
| 1103 | } |
| r936 | r937 | |
|---|---|---|
| 29 | 29 | cpunum_set_input_line(1, INPUT_LINE_RESET, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE); |
| 30 | 30 | |
| 31 | 31 | /* bit 5 resets mcu */ |
| 32 | if (Machine->drv->cpu[3].cpu_type) // only if we have a MCU | |
| 32 | if (Machine->drv->cpu[3].cpu_type != CPU_DUMMY) // only if we have a MCU | |
| 33 | 33 | cpunum_set_input_line(3, INPUT_LINE_RESET, (data & 0x20) ? CLEAR_LINE : ASSERT_LINE); |
| 34 | 34 | |
| 35 | 35 | /* bit 6 enables display */ |
| r936 | r937 | |
|---|---|---|
| 353 | 353 | int x = readinputport( 4 ); |
| 354 | 354 | int y = readinputport( 5 ); |
| 355 | 355 | UINT32 pix, color_base; |
| 356 | pen_t *pens = Machine->pens; | |
| 356 | const pen_t *pens = Machine->pens; | |
| 357 | 357 | |
| 358 | 358 | /* get the pixel at the gun position */ |
| 359 | 359 | pix = ppu2c0x_get_pixel( 0, x, y ); |
| r936 | r937 | |
|---|---|---|
| 178 | 178 | static TIMER_CALLBACK( amiga_irq_proc ); |
| 179 | 179 | static TIMER_CALLBACK( amiga_blitter_proc ); |
| 180 | 180 | |
| 181 | ||
| 182 | ||
| 183 | 181 | /************************************* |
| 184 | 182 | * |
| 185 | 183 | * Chipmem 16/32 bit access |
| r936 | r937 | |
| 310 | 308 | autoconfig_reset(); |
| 311 | 309 | |
| 312 | 310 | /* set the overlay bit */ |
| 313 | amiga_cia_w(0x1001/2, 1, 0); | |
| 311 | if ( IS_AGA(amiga_intf) ) | |
| 312 | { | |
| 313 | program_write_byte( 0xbfa001, 1 ); | |
| 314 | } | |
| 315 | else | |
| 316 | { | |
| 317 | amiga_cia_w(0x1001/2, 1, 0); | |
| 318 | } | |
| 314 | 319 | |
| 315 | 320 | if (activecpu_get_pc() < 0x80000) |
| 316 | 321 | memory_set_opbase(0); |
| r936 | r937 | |
| 328 | 333 | autoconfig_reset(); |
| 329 | 334 | |
| 330 | 335 | /* set the overlay bit */ |
| 331 | amiga_cia_w(0x1001/2, 1, 0); | |
| 336 | if ( IS_AGA(amiga_intf) ) | |
| 337 | { | |
| 338 | program_write_byte( 0xbfa001, 1 ); | |
| 339 | } | |
| 340 | else | |
| 341 | { | |
| 342 | amiga_cia_w(0x1001/2, 1, 0); | |
| 343 | } | |
| 332 | 344 | |
| 333 | 345 | /* call the system-specific callback */ |
| 334 | 346 | if (amiga_intf->reset_callback) |
| r936 | r937 | |
| 974 | 986 | /* is there another blitting in progress? */ |
| 975 | 987 | if (CUSTOM_REG(REG_DMACON) & 0x4000) |
| 976 | 988 | { |
| 977 | logerror("This program is playing tricks with the blitter\n" ); | |
| 989 | logerror("PC: %08x - This program is playing tricks with the blitter\n", safe_activecpu_get_pc() ); | |
| 978 | 990 | return; |
| 979 | 991 | } |
| 980 | 992 | |
| r936 | r937 | |
| 1012 | 1024 | blittime = BLITTER_NASTY_DELAY; |
| 1013 | 1025 | } |
| 1014 | 1026 | |
| 1027 | /* AGA has twice the bus bandwidth, so blits take half the time */ | |
| 1028 | if ( IS_AGA(amiga_intf) ) | |
| 1029 | blittime /= 2; | |
| 1030 | ||
| 1015 | 1031 | /* signal blitter busy */ |
| 1016 | 1032 | CUSTOM_REG(REG_DMACON) |= 0x4000; |
| 1017 | 1033 | |
| r936 | r937 | |
| 1130 | 1146 | CUSTOM_REG(REG_DDFSTOP) = 0xd8; |
| 1131 | 1147 | CUSTOM_REG(REG_INTENA) = 0x0000; |
| 1132 | 1148 | CUSTOM_REG(REG_VPOSR) = vidmode; |
| 1149 | CUSTOM_REG(REG_SERDATR) = 0x3000; | |
| 1133 | 1150 | |
| 1134 | 1151 | switch (amiga_intf->chip_ram_mask) |
| 1135 | 1152 | { |
| 1136 | 1153 | case ANGUS_CHIP_RAM_MASK: |
| 1137 | 1154 | case FAT_ANGUS_CHIP_RAM_MASK: |
| 1138 | CUSTOM_REG(REG_DENISEID) = 0x | |
| 1155 | CUSTOM_REG(REG_DENISEID) = 0x00FF; | |
| 1139 | 1156 | break; |
| 1140 | 1157 | |
| 1141 | 1158 | case ECS_CHIP_RAM_MASK: |
| 1142 | 1159 | CUSTOM_REG(REG_VPOSR) |= 0x2000; |
| 1143 | CUSTOM_REG(REG_DENISEID) = 0x | |
| 1160 | CUSTOM_REG(REG_DENISEID) = 0x00FC; | |
| 1144 | 1161 | if (IS_AGA(amiga_intf)) |
| 1145 | 1162 | { |
| 1146 | 1163 | CUSTOM_REG(REG_VPOSR) |= 0x0300; |
| 1147 | CUSTOM_REG(REG_DENISEID) = 0x | |
| 1164 | CUSTOM_REG(REG_DENISEID) = 0x00F8; | |
| 1148 | 1165 | } |
| 1149 | 1166 | break; |
| 1150 | 1167 | } |
| r936 | r937 | |
| 1164 | 1181 | |
| 1165 | 1182 | switch (offset & 0xff) |
| 1166 | 1183 | { |
| 1184 | case REG_BLTDDAT: | |
| 1185 | return CUSTOM_REG(REG_BLTDDAT); | |
| 1186 | ||
| 1167 | 1187 | case REG_DMACONR: |
| 1168 | 1188 | return CUSTOM_REG(REG_DMACON); |
| 1169 | 1189 |
| r936 | r937 | |
|---|---|---|
| 870 | 870 | { |
| 871 | 871 | return wd33c93_get_xfer_count(); |
| 872 | 872 | } |
| 873 | /* | |
| 874 | * wd33c93.c | |
| 875 | * | |
| 876 | * WD/AMD 33c93 SCSI controller, as seen in | |
| 877 | * early PCs, some MSX add-ons, NEC PC-88, and SGI | |
| 878 | * Indigo, Indigo2, and Indy systems. | |
| 879 | * | |
| 880 | * References: | |
| 881 | * WD 33c93 manual | |
| 882 | * NetBSD 33c93 driver | |
| 883 | * | |
| 884 | */ | |
| 885 | ||
| 886 | #include "driver.h" | |
| 887 | #include "state.h" | |
| 888 | #include "wd33c93.h" | |
| 889 | ||
| 890 | #define VERBOSE 0 | |
| 891 | ||
| 892 | typedef struct | |
| 893 | { | |
| 894 | void *data; // device's "this" pointer | |
| 895 | pSCSIDispatch handler; // device's handler routine | |
| 896 | } SCSIDev; | |
| 897 | ||
| 898 | static SCSIDev devices[8]; // SCSI IDs 0-7 | |
| 899 | static struct WD33C93interface *intf; | |
| 900 | ||
| 901 | /* wd register names */ | |
| 902 | #define WD_OWN_ID 0x00 | |
| 903 | #define WD_CONTROL 0x01 | |
| 904 | #define WD_TIMEOUT_PERIOD 0x02 | |
| 905 | #define WD_CDB_1 0x03 | |
| 906 | #define WD_CDB_2 0x04 | |
| 907 | #define WD_CDB_3 0x05 | |
| 908 | #define WD_CDB_4 0x06 | |
| 909 | #define WD_CDB_5 0x07 | |
| 910 | #define WD_CDB_6 0x08 | |
| 911 | #define WD_CDB_7 0x09 | |
| 912 | #define WD_CDB_8 0x0a | |
| 913 | #define WD_CDB_9 0x0b | |
| 914 | #define WD_CDB_10 0x0c | |
| 915 | #define WD_CDB_11 0x0d | |
| 916 | #define WD_CDB_12 0x0e | |
| 917 | #define WD_TARGET_LUN 0x0f | |
| 918 | #define WD_COMMAND_PHASE 0x10 | |
| 919 | #define WD_SYNCHRONOUS_TRANSFER 0x11 | |
| 920 | #define WD_TRANSFER_COUNT_MSB 0x12 | |
| 921 | #define WD_TRANSFER_COUNT 0x13 | |
| 922 | #define WD_TRANSFER_COUNT_LSB 0x14 | |
| 923 | #define WD_DESTINATION_ID 0x15 | |
| 924 | #define WD_SOURCE_ID 0x16 | |
| 925 | #define WD_SCSI_STATUS 0x17 | |
| 926 | #define WD_COMMAND 0x18 | |
| 927 | #define WD_DATA 0x19 | |
| 928 | #define WD_QUEUE_TAG 0x1a | |
| 929 | #define WD_AUXILIARY_STATUS 0x1f | |
| 930 | ||
| 931 | /* WD commands */ | |
| 932 | #define WD_CMD_RESET 0x00 | |
| 933 | #define WD_CMD_ABORT 0x01 | |
| 934 | #define WD_CMD_ASSERT_ATN 0x02 | |
| 935 | #define WD_CMD_NEGATE_ACK 0x03 | |
| 936 | #define WD_CMD_DISCONNECT 0x04 | |
| 937 | #define WD_CMD_RESELECT 0x05 | |
| 938 | #define WD_CMD_SEL_ATN 0x06 | |
| 939 | #define WD_CMD_SEL 0x07 | |
| 940 | #define WD_CMD_SEL_ATN_XFER 0x08 | |
| 941 | #define WD_CMD_SEL_XFER 0x09 | |
| 942 | #define WD_CMD_RESEL_RECEIVE 0x0a | |
| 943 | #define WD_CMD_RESEL_SEND 0x0b | |
| 944 | #define WD_CMD_WAIT_SEL_RECEIVE 0x0c | |
| 945 | #define WD_CMD_SSCC 0x0d | |
| 946 | #define WD_CMD_SND_DISC 0x0e | |
| 947 | #define WD_CMD_SET_IDI 0x0f | |
| 948 | #define WD_CMD_RCV_CMD 0x10 | |
| 949 | #define WD_CMD_RCV_DATA 0x11 | |
| 950 | #define WD_CMD_RCV_MSG_OUT 0x12 | |
| 951 | #define WD_CMD_RCV 0x13 | |
| 952 | #define WD_CMD_SND_STATUS 0x14 | |
| 953 | #define WD_CMD_SND_DATA 0x15 | |
| 954 | #define WD_CMD_SND_MSG_IN 0x16 | |
| 955 | #define WD_CMD_SND 0x17 | |
| 956 | #define WD_CMD_TRANS_ADDR 0x18 | |
| 957 | #define WD_CMD_XFER_PAD 0x19 | |
| 958 | #define WD_CMD_TRANS_INFO 0x20 | |
| 959 | #define WD_CMD_TRANSFER_PAD 0x21 | |
| 960 | #define WD_CMD_SBT_MODE 0x80 | |
| 961 | ||
| 962 | /* ASR register */ | |
| 963 | #define ASR_INT 0x80 | |
| 964 | #define ASR_LCI 0x40 | |
| 965 | #define ASR_BSY 0x20 | |
| 966 | #define ASR_CIP 0x10 | |
| 967 | #define ASR_PE 0x02 | |
| 968 | #define ASR_DBR 0x01 | |
| 969 | ||
| 970 | /* SCSI Bus Phases */ | |
| 971 | #define PHS_DATA_OUT 0x00 | |
| 972 | #define PHS_DATA_IN 0x01 | |
| 973 | #define PHS_COMMAND 0x02 | |
| 974 | #define PHS_STATUS 0x03 | |
| 975 | #define PHS_MESS_OUT 0x06 | |
| 976 | #define PHS_MESS_IN 0x07 | |
| 977 | ||
| 978 | /* Command Status Register definitions */ | |
| 979 | ||
| 980 | /* reset state interrupts */ | |
| 981 | #define CSR_RESET 0x00 | |
| 982 | #define CSR_RESET_AF 0x01 | |
| 983 | ||
| 984 | /* successful completion interrupts */ | |
| 985 | #define CSR_RESELECT 0x10 | |
| 986 | #define CSR_SELECT 0x11 | |
| 987 | #define CSR_SEL_XFER_DONE 0x16 | |
| 988 | #define CSR_XFER_DONE 0x18 | |
| 989 | ||
| 990 | /* paused or aborted interrupts */ | |
| 991 | #define CSR_MSGIN 0x20 | |
| 992 | #define CSR_SDP 0x21 | |
| 993 | #define CSR_SEL_ABORT 0x22 | |
| 994 | #define CSR_RESEL_ABORT 0x25 | |
| 995 | #define CSR_RESEL_ABORT_AM 0x27 | |
| 996 | #define CSR_ABORT 0x28 | |
| 997 | ||
| 998 | /* terminated interrupts */ | |
| 999 | #define CSR_INVALID 0x40 | |
| 1000 | #define CSR_UNEXP_DISC 0x41 | |
| 1001 | #define CSR_TIMEOUT 0x42 | |
| 1002 | #define CSR_PARITY 0x43 | |
| 1003 | #define CSR_PARITY_ATN 0x44 | |
| 1004 | #define CSR_BAD_STATUS 0x45 | |
| 1005 | #define CSR_UNEXP 0x48 | |
| 1006 | ||
| 1007 | /* service required interrupts */ | |
| 1008 | #define CSR_RESEL 0x80 | |
| 1009 | #define CSR_RESEL_AM 0x81 | |
| 1010 | #define CSR_DISC 0x85 | |
| 1011 | #define CSR_SRV_REQ 0x88 | |
| 1012 | ||
| 1013 | /* Own ID/CDB Size register */ | |
| 1014 | #define OWNID_EAF 0x08 | |
| 1015 | #define OWNID_EHP 0x10 | |
| 1016 | #define OWNID_RAF 0x20 | |
| 1017 | #define OWNID_FS_8 0x00 | |
| 1018 | #define OWNID_FS_12 0x40 | |
| 1019 | #define OWNID_FS_16 0x80 | |
| 1020 | ||
| 1021 | /* Control register */ | |
| 1022 | #define CTRL_HSP 0x01 | |
| 1023 | #define CTRL_HA 0x02 | |
| 1024 | #define CTRL_IDI 0x04 | |
| 1025 | #define CTRL_EDI 0x08 | |
| 1026 | #define CTRL_HHP 0x10 | |
| 1027 | #define CTRL_POLLED 0x00 | |
| 1028 | #define CTRL_BURST 0x20 | |
| 1029 | #define CTRL_BUS 0x40 | |
| 1030 | #define CTRL_DMA 0x80 | |
| 1031 | ||
| 1032 | /* Synchronous Transfer Register */ | |
| 1033 | #define STR_FSS 0x80 | |
| 1034 | ||
| 1035 | /* Destination ID register */ | |
| 1036 | #define DSTID_DPD 0x40 | |
| 1037 | #define DATA_OUT_DIR 0 | |
| 1038 | #define DATA_IN_DIR 1 | |
| 1039 | #define DSTID_SCC 0x80 | |
| 1040 | ||
| 1041 | /* Source ID register */ | |
| 1042 | #define SRCID_MASK 0x07 | |
| 1043 | #define SRCID_SIV 0x08 | |
| 1044 | #define SRCID_DSP 0x20 | |
| 1045 | #define SRCID_ES 0x40 | |
| 1046 | #define SRCID_ER 0x80 | |
| 1047 | ||
| 1048 | /* command handler definition */ | |
| 1049 | typedef void (*cmd_handler)(void); | |
| 1050 | ||
| 1051 | #define TEMP_INPUT_LEN 65536 | |
| 1052 | #define FIFO_SIZE 12 | |
| 1053 | ||
| 1054 | /* internal controller data definition */ | |
| 1055 | typedef struct | |
| 1056 | { | |
| 1057 | UINT8 sasr; | |
| 1058 | UINT8 regs[WD_AUXILIARY_STATUS+1]; | |
| 1059 | UINT8 fifo[FIFO_SIZE]; | |
| 1060 | int fifo_pos; | |
| 1061 | UINT8 *temp_input; | |
| 1062 | int temp_input_pos; | |
| 1063 | UINT8 busphase; | |
| 1064 | UINT8 identify; | |
| 1065 | int read_pending; | |
| 1066 | mame_timer *cmd_timer; | |
| 1067 | } _wd33c93_data; | |
| 1068 | ||
| 1069 | /* local instance of controller data */ | |
| 1070 | static _wd33c93_data scsi_data; | |
| 1071 | ||
| 1072 | ||
| 1073 | /* convernience functions */ | |
| 1074 | static UINT8 wd33c93_getunit( void ) | |
| 1075 | { | |
| 1076 | /* return the destination unit id */ | |
| 1077 | return scsi_data.regs[WD_DESTINATION_ID] & SRCID_MASK; | |
| 1078 | } | |
| 1079 | ||
| 1080 | static void wd33c93_set_xfer_count( int count ) | |
| 1081 | { | |
| 1082 | /* set the count */ | |
| 1083 | scsi_data.regs[ WD_TRANSFER_COUNT_LSB ] = count & 0xff; | |
| 1084 | scsi_data.regs[ WD_TRANSFER_COUNT ] = ( count >> 8 ) & 0xff; | |
| 1085 | scsi_data.regs[ WD_TRANSFER_COUNT_MSB ] = ( count >> 16 ) & 0xff; | |
| 1086 | } | |
| 1087 | ||
| 1088 | static int wd33c93_get_xfer_count( void ) | |
| 1089 | { | |
| 1090 | /* get the count */ | |
| 1091 | int count = scsi_data.regs[ WD_TRANSFER_COUNT_MSB ]; | |
| 1092 | ||
| 1093 | count <<= 8; | |
| 1094 | count |= scsi_data.regs[ WD_TRANSFER_COUNT ]; | |
| 1095 | count <<= 8; | |
| 1096 | count |= scsi_data.regs[ WD_TRANSFER_COUNT_LSB ]; | |
| 1097 | ||
| 1098 | return count; | |
| 1099 | } | |
| 1100 | ||
| 1101 | static void wd33c93_read_data(int bytes, UINT8 *pData) | |
| 1102 | { | |
| 1103 | UINT8 unit = wd33c93_getunit(); | |
| 1104 | ||
| 1105 | if ( devices[unit].handler ) | |
| 1106 | { | |
| 1107 | devices[unit].handler(SCSIOP_READ_DATA, devices[unit].data, bytes, pData); | |
| 1108 | } | |
| 1109 | else | |
| 1110 | { | |
| 1111 | logerror("wd33c93: request for unknown device SCSI ID %d\n", unit); | |
| 1112 | } | |
| 1113 | } | |
| 1114 | ||
| 1115 | static void wd33c93_complete_immediate( int status ) | |
| 1116 | { | |
| 1117 | /* reset our timer */ | |
| 1118 | mame_timer_reset( scsi_data.cmd_timer, time_never ); | |
| 1119 | ||
| 1120 | /* set the new status */ | |
| 1121 | scsi_data.regs[WD_SCSI_STATUS] = status & 0xff; | |
| 1122 | ||
| 1123 | /* set interrupt pending */ | |
| 1124 | scsi_data.regs[WD_AUXILIARY_STATUS] |= ASR_INT; | |
| 1125 | ||
| 1126 | /* check for error conditions */ | |
| 1127 | if ( wd33c93_get_xfer_count() > 0 ) | |
| 1128 | { | |
| 1129 | /* set data buffer ready */ | |
| 1130 | scsi_data.regs[WD_AUXILIARY_STATUS] |= ASR_DBR; | |
| 1131 | } | |
| 1132 | else | |
| 1133 | { | |
| 1134 | /* clear data buffer ready */ | |
| 1135 | scsi_data.regs[WD_AUXILIARY_STATUS] &= ~ASR_DBR; | |
| 1136 | } | |
| 1137 | ||
| 1138 | /* clear command in progress and bus busy */ | |
| 1139 | scsi_data.regs[WD_AUXILIARY_STATUS] &= ~(ASR_CIP | ASR_BSY); | |
| 1140 | ||
| 1141 | /* if we have a callback, call it */ | |
| 1142 | if (intf && intf->irq_callback) | |
| 1143 | { | |
| 1144 | intf->irq_callback(1); | |
| 1145 | } | |
| 1146 | } | |
| 1147 | ||
| 1148 | static TIMER_CALLBACK(wd33c93_complete_cb) | |
| 1149 | { | |
| 1150 | wd33c93_complete_immediate( param ); | |
| 1151 | } | |
| 1152 | ||
| 1153 | static TIMER_CALLBACK(wd33c93_service_request) | |
| 1154 | { | |
| 1155 | /* issue a message out request */ | |
| 1156 | wd33c93_complete_immediate(CSR_SRV_REQ | scsi_data.busphase); | |
| 1157 | } | |
| 1158 | ||
| 1159 | static TIMER_CALLBACK(wd33c93_deassert_cip) | |
| 1160 | { | |
| 1161 | scsi_data.regs[WD_AUXILIARY_STATUS] &= ~ASR_CIP; | |
| 1162 | } | |
| 1163 | ||
| 1164 | static void wd33c93_complete_cmd( UINT8 status ) | |
| 1165 | { | |
| 1166 | /* fire off a timer to complete the command */ | |
| 1167 | mame_timer_adjust( scsi_data.cmd_timer, MAME_TIME_IN_USEC(1), status, time_zero ); | |
| 1168 | } | |
| 1169 | ||
| 1170 | /* command handlers */ | |
| 1171 | static void wd33c93_invalid_cmd( void ) | |
| 1172 | { | |
| 1173 | logerror( "Unknown/Unimplemented SCSI controller command: %02x (PC=%x)\n", scsi_data.regs[WD_COMMAND], activecpu_get_pc() ); | |
| 1174 | ||
| 1175 | /* complete the command */ | |
| 1176 | wd33c93_complete_cmd( CSR_INVALID ); | |
| 1177 | } | |
| 1178 | ||
| 1179 | static void wd33c93_reset_cmd( void ) | |
| 1180 | { | |
| 1181 | int advanced = 0; | |
| 1182 | ||
| 1183 | /* see if it wants us to reset with advanced features */ | |
| 1184 | if ( scsi_data.regs[WD_OWN_ID] & OWNID_EAF ) | |
| 1185 | { | |
| 1186 | advanced = 1; | |
| 1187 | } | |
| 1188 | ||
| 1189 | /* clear out all registers */ | |
| 1190 | memset( scsi_data.regs, 0, sizeof( scsi_data.regs ) ); | |
| 1191 | ||
| 1192 | /* complete the command */ | |
| 1193 | wd33c93_complete_cmd(advanced ? CSR_RESET_AF : CSR_RESET); | |
| 1194 | } | |
| 1195 | ||
| 1196 | static void wd33c93_abort_cmd( void ) | |
| 1197 | { | |
| 1198 | /* complete the command */ | |
| 1199 | wd33c93_complete_cmd(CSR_ABORT); | |
| 1200 | } | |
| 1201 | ||
| 1202 | static void wd33c93_disconnect_cmd( void ) | |
| 1203 | { | |
| 1204 | /* complete the command */ | |
| 1205 | scsi_data.regs[WD_AUXILIARY_STATUS] &= ~(ASR_CIP | ASR_BSY); | |
| 1206 | } | |
| 1207 | ||
| 1208 | static void wd33c93_select_cmd( void ) | |
| 1209 | { | |
| 1210 | UINT8 unit = wd33c93_getunit(); | |
| 1211 | UINT8 newstatus; | |
| 1212 | ||
| 1213 | /* see if we can select that device */ | |
| 1214 | if ( devices[unit].handler ) | |
| 1215 | { | |
| 1216 | /* device is available - signal selection done */ | |
| 1217 | newstatus = CSR_SELECT; | |
| 1218 | ||
| 1219 | /* determine the next bus phase depending on the command */ | |
| 1220 | if ( (scsi_data.regs[WD_COMMAND] & 0x7f) == WD_CMD_SEL_ATN ) | |
| 1221 | { | |
| 1222 | /* /ATN asserted during select: Move to Message Out Phase to read identify */ | |
| 1223 | scsi_data.busphase = PHS_MESS_OUT; | |
| 1224 | } | |
| 1225 | else | |
| 1226 | { | |
| 1227 | /* No /ATN asserted: Move to Command Phase */ | |
| 1228 | scsi_data.busphase = PHS_COMMAND; | |
| 1229 | } | |
| 1230 | ||
| 1231 | /* queue up a service request out in the future */ | |
| 1232 | mame_timer_set( MAME_TIME_IN_USEC(50), 0, wd33c93_service_request ); | |
| 1233 | } | |
| 1234 | else | |
| 1235 | { | |
| 1236 | /* device is not available */ | |
| 1237 | newstatus = CSR_TIMEOUT; | |
| 1238 | } | |
| 1239 | ||
| 1240 | /* complete the command */ | |
| 1241 | wd33c93_complete_cmd(newstatus); | |
| 1242 | } | |
| 1243 | ||
| 1244 | static void wd33c93_selectxfer_cmd( void ) | |
| 1245 | { | |
| 1246 | UINT8 unit = wd33c93_getunit(); | |
| 1247 | UINT8 newstatus; | |
| 1248 | ||
| 1249 | /* see if we can select that device */ | |
| 1250 | if ( devices[unit].handler ) | |
| 1251 | { | |
| 1252 | if ( scsi_data.regs[WD_COMMAND_PHASE] < 0x45 ) | |
| 1253 | { | |
| 1254 | /* device is available */ | |
| 1255 | int xfercount; | |
| 1256 | ||
| 1257 | /* do the request */ | |
| 1258 | xfercount = devices[unit].handler(SCSIOP_EXEC_COMMAND, devices[unit].data, 0, &scsi_data.regs[WD_CDB_1]); | |
| 1259 | ||
| 1260 | /* set transfer count */ | |
| 1261 | if ( wd33c93_get_xfer_count() > TEMP_INPUT_LEN ) | |
| 1262 | { | |
| 1263 | logerror( "WD33C93: Transfer count too big. Please increase TEMP_INPUT_LEN (size=%d)\n", wd33c93_get_xfer_count() ); | |
| 1264 | wd33c93_set_xfer_count( TEMP_INPUT_LEN ); | |
| 1265 | } | |
| 1266 | ||
| 1267 | scsi_data.read_pending = 1; | |
| 1268 | } | |
| 1269 | ||
| 1270 | if ( scsi_data.read_pending ) | |
| 1271 | { | |
| 1272 | int len = TEMP_INPUT_LEN; | |
| 1273 | ||
| 1274 | if ( wd33c93_get_xfer_count() < len ) len = wd33c93_get_xfer_count(); | |
| 1275 | ||
| 1276 | memset( &scsi_data.temp_input[0], 0, TEMP_INPUT_LEN ); | |
| 1277 | wd33c93_read_data( len, &scsi_data.temp_input[0] ); | |
| 1278 | scsi_data.temp_input_pos = 0; | |
| 1279 | scsi_data.read_pending = 0; | |
| 1280 | } | |
| 1281 | ||
| 1282 | scsi_data.regs[WD_TARGET_LUN] = 0; | |
| 1283 | scsi_data.regs[WD_CONTROL] |= CTRL_EDI; | |
| 1284 | scsi_data.regs[WD_COMMAND_PHASE] = 0x60; | |
| 1285 | ||
| 1286 | /* signal transfer ready */ | |
| 1287 | newstatus = CSR_SEL_XFER_DONE; | |
| 1288 | ||
| 1289 | /* if allowed disconnect, queue a service request */ | |
| 1290 | if ( scsi_data.identify & 0x40 ) | |
| 1291 | { | |
| 1292 | /* queue disconnect message in */ | |
| 1293 | scsi_data.busphase = PHS_MESS_IN; | |
| 1294 | ||
| 1295 | /* queue up a service request out in the future */ | |
| 1296 | mame_timer_set( MAME_TIME_IN_MSEC(50), 0, wd33c93_service_request ); | |
| 1297 | } | |
| 1298 | } | |
| 1299 | else | |
| 1300 | { | |
| 1301 | /* device is not available */ | |
| 1302 | newstatus = CSR_TIMEOUT; | |
| 1303 | ||
| 1304 | wd33c93_set_xfer_count( 0 ); | |
| 1305 | } | |
| 1306 | ||
| 1307 | /* complete the command */ | |
| 1308 | wd33c93_complete_cmd(newstatus); | |
| 1309 | } | |
| 1310 | ||
| 1311 | static void wd33c93_negate_ack( void ) | |
| 1312 | { | |
| 1313 | logerror( "WD33C93: ACK Negated\n" ); | |
| 1314 | ||
| 1315 | /* complete the command */ | |
| 1316 | scsi_data.regs[WD_AUXILIARY_STATUS] &= ~(ASR_CIP | ASR_BSY); | |
| 1317 | } | |
| 1318 | ||
| 1319 | static void wd33c93_xferinfo_cmd( void ) | |
| 1320 | { | |
| 1321 | /* make the buffer available right away */ | |
| 1322 | scsi_data.regs[WD_AUXILIARY_STATUS] |= ASR_DBR; | |
| 1323 | scsi_data.regs[WD_AUXILIARY_STATUS] |= ASR_CIP; | |
| 1324 | ||
| 1325 | /* the command will be completed once the data is transferred */ | |
| 1326 | mame_timer_set( MAME_TIME_IN_MSEC(1), 0, wd33c93_deassert_cip ); | |
| 1327 | } | |
| 1328 | ||
| 1329 | /* Command handlers */ | |
| 1330 | static cmd_handler wd33c93_cmds[0x22] = | |
| 1331 | { | |
| 1332 | &wd33c93_reset_cmd, /* 0x00 - WD_CMD_RESET */ | |
| 1333 | &wd33c93_abort_cmd, /* 0x01 - WD_CMD_ABORT */ | |
| 1334 | &wd33c93_invalid_cmd, /* 0x02 - WD_CMD_ASSERT_ATN (uninmplemented) */ | |
| 1335 | &wd33c93_negate_ack, /* 0x03 - WD_CMD_NEGATE_ACK */ | |
| 1336 | &wd33c93_disconnect_cmd,/* 0x04 - WD_CMD_DISCONNECT */ | |
| 1337 | &wd33c93_invalid_cmd, /* 0x05 - WD_CMD_RESELECT (uninmplemented) */ | |
| 1338 | &wd33c93_select_cmd, /* 0x06 - WD_CMD_SEL_ATN */ | |
| 1339 | &wd33c93_select_cmd, /* 0x07 - WD_CMD_SEL */ | |
| 1340 | &wd33c93_selectxfer_cmd,/* 0x08 - WD_CMD_SEL_ATN_XFER */ | |
| 1341 | &wd33c93_selectxfer_cmd,/* 0x09 - WD_CMD_SEL_XFER */ | |
| 1342 | &wd33c93_invalid_cmd, /* 0x0a - WD_CMD_RESEL_RECEIVE (uninmplemented) */ | |
| 1343 | &wd33c93_invalid_cmd, /* 0x0b - WD_CMD_RESEL_SEND (uninmplemented) */ | |
| 1344 | &wd33c93_invalid_cmd, /* 0x0c - WD_CMD_WAIT_SEL_RECEIVE (uninmplemented) */ | |
| 1345 | &wd33c93_invalid_cmd, /* 0x0d - WD_CMD_SSCC (uninmplemented) */ | |
| 1346 | &wd33c93_invalid_cmd, /* 0x0e - WD_CMD_SND_DISC (uninmplemented) */ | |
| 1347 | &wd33c93_invalid_cmd, /* 0x0f - WD_CMD_SET_IDI (uninmplemented) */ | |
| 1348 | &wd33c93_invalid_cmd, /* 0x10 - WD_CMD_RCV_CMD (uninmplemented) */ | |
| 1349 | &wd33c93_invalid_cmd, /* 0x11 - WD_CMD_RCV_DATA (uninmplemented) */ | |
| 1350 | &wd33c93_invalid_cmd, /* 0x12 - WD_CMD_RCV_MSG_OUT (uninmplemented) */ | |
| 1351 | &wd33c93_invalid_cmd, /* 0x13 - WD_CMD_RCV (uninmplemented) */ | |
| 1352 | &wd33c93_invalid_cmd, /* 0x14 - WD_CMD_SND_STATUS (uninmplemented) */ | |
| 1353 | &wd33c93_invalid_cmd, /* 0x15 - WD_CMD_SND_DATA (uninmplemented) */ | |
| 1354 | &wd33c93_invalid_cmd, /* 0x16 - WD_CMD_SND_MSG_IN (uninmplemented) */ | |
| 1355 | &wd33c93_invalid_cmd, /* 0x17 - WD_CMD_SND (uninmplemented) */ | |
| 1356 | &wd33c93_invalid_cmd, /* 0x18 - WD_CMD_TRANS_ADDR (uninmplemented) */ | |
| 1357 | &wd33c93_invalid_cmd, /* 0x19 - WD_CMD_XFER_PAD (uninmplemented) */ | |
| 1358 | &wd33c93_invalid_cmd, /* 0x1a - invalid */ | |
| 1359 | &wd33c93_invalid_cmd, /* 0x1b - invalid */ | |
| 1360 | &wd33c93_invalid_cmd, /* 0x1c - invalid */ | |
| 1361 | &wd33c93_invalid_cmd, /* 0x1d - invalid */ | |
| 1362 | &wd33c93_invalid_cmd, /* 0x1e - invalid */ | |
| 1363 | &wd33c93_invalid_cmd, /* 0x1f - invalid */ | |
| 1364 | &wd33c93_xferinfo_cmd, /* 0x20 - WD_CMD_TRANS_INFO) */ | |
| 1365 | &wd33c93_invalid_cmd /* 0x21 - WD_CMD_TRANSFER_PAD (uninmplemented) */ | |
| 1366 | }; | |
| 1367 | ||
| 1368 | /* Handle pending commands */ | |
| 1369 | static void wd33c93_command( void ) | |
| 1370 | { | |
| 1371 | /* get the command */ | |
| 1372 | UINT8 cmd = scsi_data.regs[WD_COMMAND]; | |
| 1373 | ||
| 1374 | /* check if its within valid bounds */ | |
| 1375 | if ( (cmd & 0x7F) > WD_CMD_TRANSFER_PAD ) | |
| 1376 | { | |
| 1377 | wd33c93_invalid_cmd(); | |
| 1378 | return; | |
| 1379 | } | |
| 1380 | ||
| 1381 | /* call the command handler */ | |
| 1382 | (*wd33c93_cmds[cmd & 0x7F])(); | |
| 1383 | } | |
| 1384 | ||
| 1385 | WRITE8_HANDLER(wd33c93_w) | |
| 1386 | { | |
| 1387 | switch( offset ) | |
| 1388 | { | |
| 1389 | case 0: | |
| 1390 | { | |
| 1391 | /* update register select */ | |
| 1392 | scsi_data.sasr = data & 0x1f; | |
| 1393 | } | |
| 1394 | break; | |
| 1395 | ||
| 1396 | case 1: | |
| 1397 | { | |
| 1398 | #if VERBOSE | |
| 1399 | logerror( "WD33C93: PC=%08x - Write REG=%02x, data = %02x\n", safe_activecpu_get_pc(), scsi_data.sasr, data ); | |
| 1400 | #endif | |
| 1401 | ||
| 1402 | /* update the register */ | |
| 1403 | scsi_data.regs[scsi_data.sasr] = data; | |
| 1404 | ||
| 1405 | /* if we receive a command, schedule to process it */ | |
| 1406 | if ( scsi_data.sasr == WD_COMMAND ) | |
| 1407 | { | |
| 1408 | #if VERBOSE | |
| 1409 | logerror( "WDC33C93: PC=%08x - Executing command %08x - unit %d\n", safe_activecpu_get_pc(), data, wd33c93_getunit() ); | |
| 1410 | #endif | |
| 1411 | ||
| 1412 | /* signal we're processing it */ | |
| 1413 | scsi_data.regs[WD_AUXILIARY_STATUS] |= ASR_CIP; | |
| 1414 | ||
| 1415 | /* process the command */ | |
| 1416 | wd33c93_command(); | |
| 1417 | } | |
| 1418 | else if ( scsi_data.sasr == WD_CDB_1 ) | |
| 1419 | { | |
| 1420 | scsi_data.regs[WD_COMMAND_PHASE] = 0; | |
| 1421 | } | |
| 1422 | else if ( scsi_data.sasr == WD_DATA ) | |
| 1423 | { | |
| 1424 | /* if data was written, and we have a count, send to device */ | |
| 1425 | int count = wd33c93_get_xfer_count(); | |
| 1426 | ||
| 1427 | if ( scsi_data.regs[WD_COMMAND] & 0x80 ) | |
| 1428 | count = 1; | |
| 1429 | ||
| 1430 | if ( count-- > 0 ) | |
| 1431 | { | |
| 1432 | /* write to FIFO */ | |
| 1433 | if ( scsi_data.fifo_pos < FIFO_SIZE ) | |
| 1434 | { | |
| 1435 | scsi_data.fifo[scsi_data.fifo_pos++] = data; | |
| 1436 | } | |
| 1437 | ||
| 1438 | /* update count */ | |
| 1439 | wd33c93_set_xfer_count( count ); | |
| 1440 | ||
| 1441 | /* if we're done with the write, see where we're at */ | |
| 1442 | if ( count == 0 ) | |
| 1443 | { | |
| 1444 | scsi_data.regs[WD_AUXILIARY_STATUS] |= ASR_INT; | |
| 1445 | scsi_data.regs[WD_AUXILIARY_STATUS] &= ~ASR_DBR; | |
| 1446 | ||
| 1447 | switch( scsi_data.busphase ) | |
| 1448 | { | |
| 1449 | case PHS_MESS_OUT: | |
| 1450 | { | |
| 1451 | /* reset fifo */ | |
| 1452 | scsi_data.fifo_pos = 0; | |
| 1453 | ||
| 1454 | /* Message out phase. Data is probably SCSI Identify. Move to command phase. */ | |
| 1455 | scsi_data.busphase = PHS_COMMAND; | |
| 1456 | ||
| 1457 | scsi_data.identify = scsi_data.fifo[0]; | |
| 1458 | } | |
| 1459 | break; | |
| 1460 | ||
| 1461 | case PHS_COMMAND: | |
| 1462 | { | |
| 1463 | UINT8 unit = wd33c93_getunit(); | |
| 1464 | int xfercount; | |
| 1465 | ||
| 1466 | /* Execute the command. Depending on the command, we'll move to data in or out */ | |
| 1467 | xfercount = devices[unit].handler(SCSIOP_EXEC_COMMAND, devices[unit].data, 0, &scsi_data.fifo[0]); | |
| 1468 | ||
| 1469 | /* reset fifo */ | |
| 1470 | scsi_data.fifo_pos = 0; | |
| 1471 | ||
| 1472 | /* set the new count */ | |
| 1473 | wd33c93_set_xfer_count( xfercount ); | |
| 1474 | ||
| 1475 | if ( xfercount == 0 ) | |
| 1476 | { | |
| 1477 | /* move to status phase */ | |
| 1478 | scsi_data.busphase = PHS_STATUS; | |
| 1479 | } | |
| 1480 | else | |
| 1481 | { | |
| 1482 | /* update bus phase */ | |
| 1483 | if ( scsi_data.fifo[0] == 0x15 || scsi_data.fifo[0] == 0x55 ) /* MODE SELECT */ | |
| 1484 | { | |
| 1485 | scsi_data.busphase = PHS_DATA_OUT; | |
| 1486 | } | |
| 1487 | else | |
| 1488 | { | |
| 1489 | scsi_data.busphase = PHS_DATA_IN; | |
| 1490 | scsi_data.read_pending = 1; | |
| 1491 | } | |
| 1492 | } | |
| 1493 | } | |
| 1494 | break; | |
| 1495 | ||
| 1496 | case PHS_DATA_OUT: | |
| 1497 | { | |
| 1498 | /* write data out to device */ | |
| 1499 | wd33c93_write_data( scsi_data.fifo_pos, scsi_data.fifo ); | |
| 1500 | ||
| 1501 | /* reset fifo */ | |
| 1502 | scsi_data.fifo_pos = 0; | |
| 1503 | ||
| 1504 | /* move to status phase */ | |
| 1505 | scsi_data.busphase = PHS_STATUS; | |
| 1506 | } | |
| 1507 | break; | |
| 1508 | } | |
| 1509 | ||
| 1510 | /* complete the command */ | |
| 1511 | wd33c93_complete_immediate(CSR_XFER_DONE | scsi_data.busphase); | |
| 1512 | } | |
| 1513 | } | |
| 1514 | else | |
| 1515 | { | |
| 1516 | logerror( "WD33C93: Sending data to device with transfer count = 0!. Ignoring...\n" ); | |
| 1517 | } | |
| 1518 | } | |
| 1519 | ||
| 1520 | /* auto-increment register select if not on special registers */ | |
| 1521 | if ( scsi_data.sasr != WD_COMMAND && scsi_data.sasr != WD_DATA && scsi_data.sasr != WD_AUXILIARY_STATUS ) | |
| 1522 | { | |
| 1523 | scsi_data.sasr = ( scsi_data.sasr + 1 ) & 0x1f; | |
| 1524 | } | |
| 1525 | } | |
| 1526 | break; | |
| 1527 | ||
| 1528 | default: | |
| 1529 | { | |
| 1530 | logerror( "WD33C93: Write to invalid offset %d (data=%02x)\n", offset, data ); | |
| 1531 | } | |
| 1532 | break; | |
| 1533 | } | |
| 1534 | } | |
| 1535 | ||
| 1536 | READ8_HANDLER(wd33c93_r) | |
| 1537 | { | |
| 1538 | switch( offset ) | |
| 1539 | { | |
| 1540 | case 0: | |
| 1541 | { | |
| 1542 | /* read aux status */ | |
| 1543 | return scsi_data.regs[WD_AUXILIARY_STATUS]; | |
| 1544 | } | |
| 1545 | break; | |
| 1546 | ||
| 1547 | case 1: | |
| 1548 | { | |
| 1549 | UINT8 ret; | |
| 1550 | ||
| 1551 | /* if reading status, clear irq flag */ | |
| 1552 | if ( scsi_data.sasr == WD_SCSI_STATUS ) | |
| 1553 | { | |
| 1554 | scsi_data.regs[WD_AUXILIARY_STATUS] &= ~ASR_INT; | |
| 1555 | ||
| 1556 | if (intf && intf->irq_callback) | |
| 1557 | { | |
| 1558 | intf->irq_callback(0); | |
| 1559 | } | |
| 1560 | ||
| 1561 | #if VERBOSE | |
| 1562 | logerror( "WD33C93: PC=%08x - Status read (%02x)\n", safe_activecpu_get_pc(), scsi_data.regs[WD_SCSI_STATUS] ); | |
| 1563 | #endif | |
| 1564 | } | |
| 1565 | else if ( scsi_data.sasr == WD_DATA ) | |
| 1566 | { | |
| 1567 | /* we're going to be doing synchronous reads */ | |
| 1568 | ||
| 1569 | /* get the transfer count */ | |
| 1570 | int count = wd33c93_get_xfer_count(); | |
| 1571 | ||
| 1572 | /* initialize the return value */ | |
| 1573 | scsi_data.regs[WD_DATA] = 0; | |
| 1574 | ||
| 1575 | if ( count <= 0 && scsi_data.busphase == PHS_MESS_IN ) | |
| 1576 | { | |
| 1577 | /* move to disconnect */ | |
| 1578 | wd33c93_complete_cmd(CSR_DISC); | |
| 1579 | } | |
| 1580 | else if ( count == 1 && scsi_data.busphase == PHS_STATUS ) | |
| 1581 | { | |
| 1582 | /* update the count */ | |
| 1583 | wd33c93_set_xfer_count( 0 ); | |
| 1584 | ||
| 1585 | /* move to message in phase */ | |
| 1586 | scsi_data.busphase = PHS_MESS_IN; | |
| 1587 | ||
| 1588 | /* complete the command */ | |
| 1589 | wd33c93_complete_cmd(CSR_XFER_DONE | scsi_data.busphase); | |
| 1590 | } | |
| 1591 | else if ( count-- > 0 ) /* make sure we still have data to send */ | |
| 1592 | { | |
| 1593 | if ( scsi_data.read_pending ) | |
| 1594 | { | |
| 1595 | int len = TEMP_INPUT_LEN; | |
| 1596 | ||
| 1597 | if ( (count+1) < len ) len = count+1; | |
| 1598 | wd33c93_read_data( len, &scsi_data.temp_input[0] ); | |
| 1599 | scsi_data.temp_input_pos = 0; | |
| 1600 | scsi_data.read_pending = 0; | |
| 1601 | } | |
| 1602 | ||
| 1603 | scsi_data.regs[WD_AUXILIARY_STATUS] &= ~ASR_INT; | |
| 1604 | ||
| 1605 | /* read in one byte */ | |
| 1606 | if ( scsi_data.temp_input_pos < TEMP_INPUT_LEN ) | |
| 1607 | scsi_data.regs[WD_DATA] = scsi_data.temp_input[scsi_data.temp_input_pos++]; | |
| 1608 | ||
| 1609 | /* update the count */ | |
| 1610 | wd33c93_set_xfer_count( count ); | |
| 1611 | ||
| 1612 | /* transfer finished, see where we're at */ | |
| 1613 | if ( count == 0 ) | |
| 1614 | { | |
| 1615 | if ( scsi_data.regs[WD_COMMAND_PHASE] != 0x60 ) | |
| 1616 | { | |
| 1617 | /* move to status phase */ | |
| 1618 | scsi_data.busphase = PHS_STATUS; | |
| 1619 | ||
| 1620 | /* complete the command */ | |
| 1621 | wd33c93_complete_cmd(CSR_XFER_DONE | scsi_data.busphase); | |
| 1622 | } | |
| 1623 | else | |
| 1624 | { | |
| 1625 | scsi_data.regs[WD_AUXILIARY_STATUS] |= ASR_INT; | |
| 1626 | scsi_data.regs[WD_AUXILIARY_STATUS] &= ~ASR_DBR; | |
| 1627 | } | |
| 1628 | } | |
| 1629 | } | |
| 1630 | } | |
| 1631 | ||
| 1632 | #if VERBOSE | |
| 1633 | logerror( "WD33C93: PC=%08x - Data read (%02x)\n", safe_activecpu_get_pc(), scsi_data.regs[WD_DATA] ); | |
| 1634 | #endif | |
| 1635 | ||
| 1636 | /* get the register value */ | |
| 1637 | ret = scsi_data.regs[scsi_data.sasr]; | |
| 1638 | ||
| 1639 | /* auto-increment register select if not on special registers */ | |
| 1640 | if ( scsi_data.sasr != WD_COMMAND && scsi_data.sasr != WD_DATA && scsi_data.sasr != WD_AUXILIARY_STATUS ) | |
| 1641 | { | |
| 1642 | scsi_data.sasr = ( scsi_data.sasr + 1 ) & 0x1f; | |
| 1643 | } | |
| 1644 | ||
| 1645 | return ret; | |
| 1646 | } | |
| 1647 | ||
| 1648 | default: | |
| 1649 | { | |
| 1650 | logerror( "WD33C93: Read from invalid offset %d\n", offset ); | |
| 1651 | } | |
| 1652 | break; | |
| 1653 | } | |
| 1654 | ||
| 1655 | return 0; | |
| 1656 | } | |
| 1657 | ||
| 1658 | extern void wd33c93_init( struct WD33C93interface *interface ) | |
| 1659 | { | |
| 1660 | int i; | |
| 1661 | ||
| 1662 | // save interface pointer for later | |
| 1663 | intf = interface; | |
| 1664 | ||
| 1665 | memset(&scsi_data, 0, sizeof(scsi_data)); | |
| 1666 | memset(devices, 0, sizeof(devices)); | |
| 1667 | ||
| 1668 | // try to open the devices | |
| 1669 | for (i = 0; i < interface->scsidevs->devs_present; i++) | |
| 1670 | { | |
| 1671 | devices[interface->scsidevs->devices[i].scsiID].handler = interface->scsidevs->devices[i].handler; | |
| 1672 | interface->scsidevs->devices[i].handler(SCSIOP_ALLOC_INSTANCE, &devices[interface->scsidevs->devices[i].scsiID].data, interface->scsidevs->devices[i].diskID, (UINT8 *)NULL); | |
| 1673 | } | |
| 1674 | ||
| 1675 | /* allocate a timer for commands */ | |
| 1676 | scsi_data.cmd_timer = mame_timer_alloc(wd33c93_complete_cb); | |
| 1677 | ||
| 1678 | scsi_data.temp_input = auto_malloc( TEMP_INPUT_LEN ); | |
| 1679 | ||
| 1680 | // state_save_register_item_array("wd33c93", 0, scsi_data); | |
| 1681 | } | |
| 1682 | ||
| 1683 | void wd33c93_get_dma_data( int bytes, UINT8 *pData ) | |
| 1684 | { | |
| 1685 | int len = bytes; | |
| 1686 | ||
| 1687 | if ( len >= wd33c93_get_xfer_count() ) | |
| 1688 | len = wd33c93_get_xfer_count(); | |
| 1689 | ||
| 1690 | if ( len == 0 ) | |
| 1691 | return; | |
| 1692 | ||
| 1693 | if ( (scsi_data.temp_input_pos+len) >= TEMP_INPUT_LEN ) | |
| 1694 | { | |
| 1695 | logerror( "Reading past end of buffer, increase TEMP_INPUT_LEN size\n" ); | |
| 1696 | len = TEMP_INPUT_LEN - len; | |
| 1697 | } | |
| 1698 | ||
| 1699 | memcpy( pData, &scsi_data.temp_input[scsi_data.temp_input_pos], len ); | |
| 1700 | ||
| 1701 | scsi_data.temp_input_pos += len; | |
| 1702 | len = wd33c93_get_xfer_count() - len; | |
| 1703 | wd33c93_set_xfer_count(len); | |
| 1704 | } | |
| 1705 | ||
| 1706 | void wd33c93_write_data(int bytes, UINT8 *pData) | |
| 1707 | { | |
| 1708 | UINT8 unit = wd33c93_getunit(); | |
| 1709 | ||
| 1710 | if (devices[unit].handler) | |
| 1711 | { | |
| 1712 | devices[unit].handler(SCSIOP_WRITE_DATA, devices[unit].data, bytes, pData); | |
| 1713 | } | |
| 1714 | else | |
| 1715 | { | |
| 1716 | logerror("wd33c93: request for unknown device SCSI ID %d\n", unit); | |
| 1717 | } | |
| 1718 | } | |
| 1719 | ||
| 1720 | void *wd33c93_get_device(int id) | |
| 1721 | { | |
| 1722 | void *ret; | |
| 1723 | ||
| 1724 | if (devices[id].handler) | |
| 1725 | { | |
| 1726 | devices[id].handler(SCSIOP_GET_DEVICE, devices[id].data, 0, (UINT8 *)&ret); | |
| 1727 | ||
| 1728 | return ret; | |
| 1729 | } | |
| 1730 | ||
| 1731 | return NULL; | |
| 1732 | } | |
| 1733 | ||
| 1734 | void wd33c93_clear_dma(void) | |
| 1735 | { | |
| 1736 | /* indicate DMA completed by clearing the transfer count */ | |
| 1737 | wd33c93_set_xfer_count(0); | |
| 1738 | scsi_data.regs[WD_AUXILIARY_STATUS] &= ~ASR_DBR; | |
| 1739 | } | |
| 1740 | ||
| 1741 | int wd33c93_get_dma_count(void) | |
| 1742 | { | |
| 1743 | return wd33c93_get_xfer_count(); | |
| 1744 | } |
| r936 | r937 | |
|---|---|---|
| 25 | 25 | extern WRITE8_HANDLER(wd33c93_w); |
| 26 | 26 | |
| 27 | 27 | #endif |
| 28 | /* | |
| 29 | * wd33c93.h | |
| 30 | * | |
| 31 | */ | |
| 32 | ||
| 33 | #ifndef _WD33C93_H_ | |
| 34 | #define _WD33C93_H_ | |
| 35 | ||
| 36 | #include "machine/scsidev.h" | |
| 37 | ||
| 38 | struct WD33C93interface | |
| 39 | { | |
| 40 | SCSIConfigTable *scsidevs; /* SCSI devices */ | |
| 41 | void (*irq_callback)(int state); /* irq callback */ | |
| 42 | }; | |
| 43 | ||
| 44 | extern void wd33c93_init( struct WD33C93interface *interface ); | |
| 45 | extern void wd33c93_get_dma_data(int bytes, UINT8 *pData); | |
| 46 | extern void wd33c93_write_data(int bytes, UINT8 *pData); | |
| 47 | extern void *wd33c93_get_device(int id); | |
| 48 | extern void wd33c93_set_device(int id, void *); | |
| 49 | extern void wd33c93_clear_dma(void); | |
| 50 | extern int wd33c93_get_dma_count(void); | |
| 51 | extern READ8_HANDLER(wd33c93_r); | |
| 52 | extern WRITE8_HANDLER(wd33c93_w); | |
| 53 | ||
| 54 | #endif |
| r936 | r937 | |
|---|---|---|
| 532 | 532 | // for the 2nd FN (2x32 bits) |
| 533 | 533 | static void expand_subkey(UINT32* subkey, UINT16 seed) |
| 534 | 534 | { |
| 535 | // Note that e | |
| 535 | // Note that each row | |
| 536 | 536 | static const int bits[64] = |
| 537 | 537 | { |
| 538 | 5, 10, 14, 9, 4, 0, 15, 6, | |
| 539 | 1, 8, 3, 2, 12, 7, 13, 11, | |
| 540 | 5, 12, 7, 2, 13, 11, 9, 14, | |
| 541 | 4, 1, 6, 10, 8, 0, 15, 3, | |
| 542 | 4, 10, 2, 0, 6, 9, 12, 1, | |
| 543 | 11, 7, 15, 8, 13, 5, 14, 3, | |
| 544 | 14, 11, 12, 7, 4, 5, 2, 10, | |
| 545 | 1, 15, 0, 9, 8, 6, 13, 3, | |
| 538 | 5, 10, 14, 9, 4, 0, 15, 6, 1, 8, 3, 2, 12, 7, 13, 11, | |
| 539 | 5, 12, 7, 2, 13, 11, 9, 14, 4, 1, 6, 10, 8, 0, 15, 3, | |
| 540 | 4, 10, 2, 0, 6, 9, 12, 1, 11, 7, 15, 8, 13, 5, 14, 3, | |
| 541 | 14, 11, 12, 7, 4, 5, 2, 10, 1, 15, 0, 9, 8, 6, 13, 3, | |
| 546 | 542 | }; |
| 547 | 543 | int i; |
| 548 | 544 | |
| r936 | r937 | |
| 559 | 555 | const struct optimised_sbox* boxes1, const struct optimised_sbox* boxes2, const struct optimised_sbox* boxes3, const struct optimised_sbox* boxes4, |
| 560 | 556 | UINT32 key1, UINT32 key2, UINT32 key3, UINT32 key4) |
| 561 | 557 | { |
| 562 | const UINT8 l0 = BITSWAP8(val, bitsB[7],bitsB[6],bitsB[5],bitsB[4],bitsB[3],bitsB[2],bitsB[1],bitsB[0]); | |
| 563 | const UINT8 r0 = BITSWAP8(val, bitsA[7],bitsA[6],bitsA[5],bitsA[4],bitsA[3],bitsA[2],bitsA[1],bitsA[0]); | |
| 558 | UINT8 l = BITSWAP8(val, bitsB[7],bitsB[6],bitsB[5],bitsB[4],bitsB[3],bitsB[2],bitsB[1],bitsB[0]); | |
| 559 | UINT8 r = BITSWAP8(val, bitsA[7],bitsA[6],bitsA[5],bitsA[4],bitsA[3],bitsA[2],bitsA[1],bitsA[0]); | |
| 564 | 560 | |
| 565 | const UINT8 l1 = r0; | |
| 566 | const UINT8 r1 = l0 ^ fn(r0, boxes1, key1); | |
| 561 | l ^= fn(r, boxes1, key1); | |
| 562 | r ^= fn(l, boxes2, key2); | |
| 563 | l ^= fn(r, boxes3, key3); | |
| 564 | r ^= fn(l, boxes4, key4); | |
| 567 | 565 | |
| 568 | const UINT8 l2 = r1; | |
| 569 | const UINT8 r2 = l1 ^ fn(r1, boxes2, key2); | |
| 570 | ||
| 571 | const UINT8 l3 = r2; | |
| 572 | const UINT8 r3 = l2 ^ fn(r2, boxes3, key3); | |
| 573 | ||
| 574 | const UINT8 l4 = r3; | |
| 575 | const UINT8 r4 = l3 ^ fn(r3, boxes4, key4); | |
| 576 | ||
| 577 | 566 | return |
| 578 | (BIT(l4, 0) << bitsA[0]) | | |
| 579 | (BIT(l4, 1) << bitsA[1]) | | |
| 580 | (BIT(l4, 2) << bitsA[2]) | | |
| 581 | (BIT(l4, 3) << bitsA[3]) | | |
| 582 | (BIT(l4, 4) << bitsA[4]) | | |
| 583 | (BIT(l4, 5) << bitsA[5]) | | |
| 584 | (BIT(l4, 6) << bitsA[6]) | | |
| 585 | (BIT(l4, 7) << bitsA[7]) | | |
| 586 | (BIT(r4, 0) << bitsB[0]) | | |
| 587 | (BIT(r4, 1) << bitsB[1]) | | |
| 588 | (BIT(r4, 2) << bitsB[2]) | | |
| 589 | (BIT(r4, 3) << bitsB[3]) | | |
| 590 | (BIT(r4, 4) << bitsB[4]) | | |
| 591 | (BIT(r4, 5) << bitsB[5]) | | |
| 592 | (BIT(r4, 6) << bitsB[6]) | | |
| 593 | (BIT(r4, 7) << bitsB[7]); | |
| 567 | (BIT(l, 0) << bitsA[0]) | | |
| 568 | (BIT(l, 1) << bitsA[1]) | | |
| 569 | (BIT(l, 2) << bitsA[2]) | | |
| 570 | (BIT(l, 3) << bitsA[3]) | | |
| 571 | (BIT(l, 4) << bitsA[4]) | | |
| 572 | (BIT(l, 5) << bitsA[5]) | | |
| 573 | (BIT(l, 6) << bitsA[6]) | | |
| 574 | (BIT(l, 7) << bitsA[7]) | | |
| 575 | (BIT(r, 0) << bitsB[0]) | | |
| 576 | (BIT(r, 1) << bitsB[1]) | | |
| 577 | (BIT(r, 2) << bitsB[2]) | | |
| 578 | (BIT(r, 3) << bitsB[3]) | | |
| 579 | (BIT(r, 4) << bitsB[4]) | | |
| 580 | (BIT(r, 5) << bitsB[5]) | | |
| 581 | (BIT(r, 6) << bitsB[6]) | | |
| 582 | (BIT(r, 7) << bitsB[7]); | |
| 594 | 583 | } |
| 595 | 584 | |
| 596 | 585 | |
| r936 | r937 | |
| 792 | 781 | { "xmcotah", { 0xf5e8dc34,0xa096b217 }, 0x100000 }, // 0C80 1972 0301 cmpi.l #$19720301,D0 |
| 793 | 782 | { "xmcotaj", { 0x46027315,0xaf8bcd9e }, 0x100000 }, // 0C80 1972 0301 cmpi.l #$19720301,D0 |
| 794 | 783 | { "xmcotaj1", { 0x46027315,0xaf8bcd9e }, 0x100000 }, // 0C80 1972 0301 cmpi.l #$19720301,D0 |
| 784 | { "xmcotaj2", { 0x46027315,0xaf8bcd9e }, 0x100000 }, // 0C80 1972 0301 cmpi.l #$19720301,D0 | |
| 795 | 785 | { "xmcotajr", { 0x46027315,0xaf8bcd9e }, 0x100000 }, // 0C80 1972 0301 cmpi.l #$19720301,D0 |
| 796 | 786 | { "xmcotaa", { 0x0795a4e2,0xdb3f861c }, 0x100000 }, // 0C80 1972 0301 cmpi.l #$19720301,D0 |
| 797 | 787 | { "armwar", { 0x9e9d4c0b,0x8a39081f }, 0x100000 }, // 3039 0080 4020 move.w $00804020,D0 |
| r936 | r937 | |
|---|---|---|
| 221 | 221 | int x = readinputport( 5 ); |
| 222 | 222 | int y = readinputport( 6 ); |
| 223 | 223 | UINT32 pix, color_base; |
| 224 | pen_t *pens = Machine->pens; | |
| 224 | const pen_t *pens = Machine->pens; | |
| 225 | 225 | |
| 226 | 226 | /* no sprite hit (yet) */ |
| 227 | 227 | ret |= 0x08; |
| r936 | r937 | |
|---|---|---|
| 221 | 221 | int src_pitch, incxy, incxx; |
| 222 | 222 | int src_minx, src_maxx, src_miny, src_maxy, cmask; |
| 223 | 223 | UINT16 *src_base; |
| 224 | | |
| 224 | const pen_t *pal_base; | |
| 225 | 225 | UINT32 *dst_ptr; |
| 226 | 226 | |
| 227 | 227 | int tx, dst_pitch; |
| r936 | r937 | |
| 476 | 476 | UINT8 z8, db0, p8, db1; |
| 477 | 477 | UINT8 *ozbuf_ptr; |
| 478 | 478 | UINT8 *szbuf_ptr; |
| 479 | UINT32 *pal_base; | |
| 480 | UINT32 *shd_base; | |
| 479 | const pen_t *pal_base; | |
| 480 | const pen_t *shd_base; | |
| 481 | 481 | UINT32 *dst_ptr; |
| 482 | 482 | |
| 483 | 483 | // outter loop |
| r936 | r937 | |
| 523 | 523 | src_fh = 16; |
| 524 | 524 | src_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| 525 | 525 | |
| 526 | pal_base = | |
| 526 | pal_base = Machine->remapped_colortable + gfx->color_base + (color % gfx->total_colors) * granularity; | |
| 527 | 527 | shd_base = Machine->shadow_table; |
| 528 | 528 | |
| 529 | 529 | dst_ptr = bitmap->base; |
| r936 | r937 | |
|---|---|---|
| 1337 | 1337 | r = (r * fade) >> 4; |
| 1338 | 1338 | g = (g * fade) >> 4; |
| 1339 | 1339 | b = (b * fade) >> 4; |
| 1340 | Machine->remapped_colortable[FIXED_COLOUR] = ((r & 0x1f) | ((g & 0x1f) << 5) | ((b & 0x1f) << 10)); | |
| 1340 | /* palette hacks! */ | |
| 1341 | ((pen_t *)Machine->remapped_colortable)[FIXED_COLOUR] = ((r & 0x1f) | ((g & 0x1f) << 5) | ((b & 0x1f) << 10)); | |
| 1341 | 1342 | } break; |
| 1342 | 1343 | case SETINI: /* Screen mode/video select */ |
| 1343 | 1344 | /* FIXME: We only support line count here */ |
| r936 | r937 | |
|---|---|---|
| 651 | 651 | DRIVER( skykid ) /* (c) 1985 */ |
| 652 | 652 | DRIVER( skykido ) /* (c) 1985 */ |
| 653 | 653 | DRIVER( skykidd ) /* (c) 1985 */ |
| 654 | DRIVER( aliensec ) /* (c) 1985 */ | |
| 654 | 655 | DRIVER( baraduke ) /* (c) 1985 */ |
| 655 | DRIVER( baraduka ) /* (c) 1985 */ | |
| 656 | 656 | DRIVER( metrocrs ) /* (c) 1985 */ |
| 657 | 657 | DRIVER( metrocra ) /* (c) 1985 */ |
| 658 | 658 | |
| r936 | r937 | |
| 2487 | 2487 | DRIVER( xmcota ) /* 05/01/1995 (c) 1994 (Euro) */ |
| 2488 | 2488 | DRIVER( xmcotau ) /* 05/01/1995 (c) 1994 (US) */ |
| 2489 | 2489 | DRIVER( xmcotah ) /* 31/03/1995 (c) 1994 (Hispanic) */ |
| 2490 | DRIVER( xmcotaj ) /* 19/12/1994 (c) 1994 (Japan) */ | |
| 2491 | DRIVER( xmcotaj1 ) /* 17/12/1994 (c) 1994 (Japan) */ | |
| 2490 | DRIVER( xmcotaj ) /* 22/12/1994 (c) 1994 (Japan) */ | |
| 2491 | DRIVER( xmcotaj1 ) /* 19/12/1994 (c) 1994 (Japan) */ | |
| 2492 | DRIVER( xmcotaj2 ) /* 17/12/1994 (c) 1994 (Japan) */ | |
| 2492 | 2493 | DRIVER( xmcotaa ) /* 17/12/1994 (c) 1994 (Asia) */ |
| 2493 | 2494 | DRIVER( xmcotajr ) /* 08/12/1994 (c) 1994 (Japan Rent) */ |
| 2494 | 2495 | DRIVER( nwarr ) /* 16/03/1995 (c) 1995 (Euro) */ |
| r936 | r937 | |
| 2846 | 2847 | DRIVER( dstage ) /* 1999 - Dancing Stage (GN845 VER. EAA) */ |
| 2847 | 2848 | DRIVER( ddru ) /* 1999 - Dance Dance Revolution (GN845 VER. UAA) */ |
| 2848 | 2849 | DRIVER( ddrj ) /* 1998 - Dance Dance Revolution - Internet Ranking Ver (GC845 VER. JBA) */ |
| 2849 | DRIVER( ddrja ) /* 1998 - Dance Dance Revolution (GC845 VER. JAB) */ | |
| 2850 | DRIVER( ddrja ) /* 1998 - Dance Dance Revolution (GC845 VER. JAA) */ | |
| 2851 | DRIVER( ddrjb ) /* 1998 - Dance Dance Revolution (GC845 VER. JAB) */ | |
| 2850 | 2852 | DRIVER( ddra ) /* 1999 - Dance Dance Revolution (GN845 VER. AAA) */ |
| 2851 | 2853 | DRIVER( fbait2bc ) /* 1998 - Fisherman's Bait 2 - A Bass Challenge (GE865 VER. UAB) */ |
| 2852 | 2854 | DRIVER( drmn ) /* 1999 - DrumMania (GQ881 VER. JAD) */ |
| r936 | r937 | |
| 2865 | 2867 | DRIVER( ddr2mc2 ) /* 1999 - Dance Dance Revolution 2nd Mix with beatmaniaIIDX substream CLUB VERSiON 2 (GE984 VER. JAA) */ |
| 2866 | 2868 | DRIVER( gtrfrk2m ) /* 1999 - Guitar Freaks 2nd Mix Ver 1.01 (GQ883 VER. JAD) */ |
| 2867 | 2869 | DRIVER( dsftkd ) /* 1999 - Dancing Stage featuring TRUE KiSS DESTiNATiON (G*884 VER. JAA) */ |
| 2868 | DRIVER( ddrsbm ) /* 1999 - Dance Dance Revolution Solo Bass Mix (GQ894 VER. JAA) */ | |
| 2869 | DRIVER( ddrs2k ) /* 1999 - Dance Dance Revolution Solo 2000 (GC905 VER. AAA) */ | |
| 2870 | DRIVER( ddrs2kj ) /* 1999 - Dance Dance Revolution Solo 2000 (GC905 VER. JAA) */ | |
| 2871 | 2870 | DRIVER( ddr3mk ) /* 2000 - Dance Dance Revolution 3rd Mix - Ver.Korea2 (GN887 VER. KBA) */ |
| 2872 | 2871 | DRIVER( ddr3mka ) /* 2000 - Dance Dance Revolution 3rd Mix - Ver.Korea (GN887 VER. KAA) */ |
| 2873 | 2872 | DRIVER( ddr3ma ) /* 1999 - Dance Dance Revolution 3rd Mix (GN887 VER. AAA) */ |
| 2874 | 2873 | DRIVER( ddr3mj ) /* 1999 - Dance Dance Revolution 3rd Mix (GN887 VER. JAA) */ |
| 2874 | DRIVER( ddrsbm ) /* 1999 - Dance Dance Revolution Solo Bass Mix (GQ894 VER. JAA) */ | |
| 2875 | DRIVER( ddrs2k ) /* 1999 - Dance Dance Revolution Solo 2000 (GC905 VER. AAA) */ | |
| 2876 | DRIVER( ddrs2kj ) /* 1999 - Dance Dance Revolution Solo 2000 (GC905 VER. JAA) */ | |
| 2877 | DRIVER( dsfdct ) /* 1999 - Dancing Stage featuring Dreams Come True (GC910 VER. JCA) */ | |
| 2878 | DRIVER( dsfdcta ) /* 1999 - Dancing Stage featuring Dreams Come True (GC910 VER. JAA) */ | |
| 2875 | 2879 | DRIVER( drmn2m ) /* 1999 - DrumMania 2nd Mix (GE912 VER. JAA) */ |
| 2876 | 2880 | DRIVER( dncfrks ) /* 2000 - Dance Freaks (G*874 VER. KAA) */ |
| 2877 | 2881 | DRIVER( dmx ) /* 2000 - Dance Maniax (G*874 VER. JAA) */ |
| r936 | r937 | |
| 2896 | 2900 | DRIVER( ddrmax ) /* 2001 - DDR Max - Dance Dance Revolution 6th Mix (G*B19 VER. JAA) */ |
| 2897 | 2901 | DRIVER( ddrmax2 ) /* 2002 - DDR Max 2 - Dance Dance Revolution 7th Mix (G*B20 VER. JAA) */ |
| 2898 | 2902 | DRIVER( dsem2 ) /* 2002 - Dancing Stage Euro Mix 2 (G*C23 VER. EAA) */ |
| 2903 | DRIVER( ddrextrm ) /* 2002 - Dance Dance Revolution Extreme (G*C36 VER. JAA) */ | |
| 2899 | 2904 | DRIVER( gtfrk11m ) /* 2004 - Guitar Freaks 11th Mix (G*D39 VER. JAA) */ |
| 2900 | 2905 | |
| 2901 | 2906 | /* Konami Viper games */ |
| r936 | r937 | |
| 6492 | 6497 | /* Seta games */ |
| 6493 | 6498 | DRIVER( hanaawas ) /* (c) SetaKikaku */ |
| 6494 | 6499 | DRIVER( speedatk ) /* CB-0 (c) SetaKikaku */ |
| 6500 | DRIVER( srmp1 ) /* UB or UC?? (c) 1987 */ | |
| 6495 | 6501 | DRIVER( srmp2 ) /* UB or UC?? (c) 1987 */ |
| 6496 | 6502 | DRIVER( srmp3 ) /* ZA-0? (c) 1988 */ |
| 6497 | 6503 | DRIVER( mjyuugi ) /* (c) 1990 Visco */ |
| r936 | r937 | |
| 6903 | 6909 | DRIVER( mjfriday ) /* "26" (c) [1989] Dynax */ |
| 6904 | 6910 | DRIVER( jantouki ) /* "27" Jantouki 1989 Dynax */ |
| 6905 | 6911 | DRIVER( mjifb ) /* "29" 1990 Dynax */ |
| 6912 | DRIVER( cafetime ) /* 1992 Dynax */ | |
| 6906 | 6913 | DRIVER( janptr96 ) /* 1996 Dynax */ |
| 6907 | 6914 | DRIVER( sprtmtch ) /* "31" (c) 1989 Dynax + Fabtek license */ |
| 6908 | 6915 | DRIVER( maya ) /* (c) 1994 Promat */ |
| r936 | r937 | |
| 6910 | 6917 | DRIVER( mcnpshnt ) /* "33" Mahjong Campus Hunting 1990 Dynax */ |
| 6911 | 6918 | DRIVER( 7jigen ) /* "37" 7jigen no Youseitachi 1990 Dynax */ |
| 6912 | 6919 | DRIVER( neruton ) /* "45" Neruton Haikujiradan 1990 Dynax */ |
| 6920 | DRIVER( mjcomv1 ) /* 1991 Dynax */ | |
| 6913 | 6921 | DRIVER( shpeng ) /* (c) 1995 WSAC Systems */ |
| 6914 | 6922 | DRIVER( tenkai ) /* 1991 Dynax */ |
| 6915 | 6923 | DRIVER( tenkai2b ) /* 1991 Dynax */ |
| r936 | r937 | |
| 7240 | 7248 | /* Scorpion 2+Video Board Games */ |
| 7241 | 7249 | DRIVER( qntoondo ) /* 1993 */ |
| 7242 | 7250 | DRIVER( quintoon ) /* 1993 */ |
| 7251 | DRIVER( quintono ) /* 1993 */ | |
| 7243 | 7252 | DRIVER( qntoond ) /* 1993 */ |
| 7244 | 7253 | DRIVER( pokio ) /* 1994 */ |
| 7245 | 7254 | DRIVER( slotsnl ) /* 1995 */ |
| r936 | r937 | |
| 7473 | 7482 | DRIVER( puzlbang ) /* (c) 1999 Omega System */ |
| 7474 | 7483 | DRIVER( suplup ) /* (c) 1999 Omega System */ |
| 7475 | 7484 | DRIVER( vamphalf ) /* (c) 1999 DanBi & F2 System */ |
| 7485 | DRIVER( dquizgo2 ) /* (c) 2000 Semicom */ | |
| 7476 | 7486 | DRIVER( misncrft ) /* (c) 2000 Sun */ |
| 7477 | 7487 | DRIVER( hidnctch ) /* (c) 1998 Eolith */ |
| 7478 | 7488 | DRIVER( puzzlekg ) /* (c) 1998 Eolith */ |
| r936 | r937 | |
| 7642 | 7652 | DRIVER( go2000 ) /* (c) 2000 SA */ |
| 7643 | 7653 | DRIVER( mirax ) /* (c) 1985 Current Technologies */ |
| 7644 | 7654 | DRIVER( lastfght ) /* (c) 2000 Subsino */ |
| 7655 | DRIVER( bishjan ) /* (c) 1999 Subsino */ | |
| 7645 | 7656 | DRIVER( sliver ) /* (c) 1996 Hollow Corp */ |
| 7646 | 7657 | DRIVER( intrscti ) /* ???? */ |
| 7647 | 7658 | DRIVER( pasha2 ) /* (c) 1998 Dong Sung */ |
| r936 | r937 | |
|---|---|---|
| 377 | 377 | #define TAITO_JOY_DUAL_UDRL(PL_L, PL_H) \ |
| 378 | 378 | TAITO_GENERIC_JOY_DUAL_UDRL(PL_L, PL_H) |
| 379 | 379 | |
| 380 | /******************************************************************************* | |
| 381 | ||
| 382 | Input port macros used by many games in mutiple Taito drivers | |
| 383 | ||
| 384 | *******************************************************************************/ | |
| 385 | ||
| 386 | ||
| 387 | /**************************** Machine Dip Swicthes ****************************/ | |
| 388 | ||
| 389 | /* with location */ | |
| 390 | #define TAITO_DSWA_BITS_2_TO_3_LOC(DIPBANK) \ | |
| 391 | PORT_SERVICE_DIPLOC( 0x04, IP_ACTIVE_LOW, #DIPBANK":3" ) \ | |
| 392 | PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION(#DIPBANK":4") \ | |
| 393 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) \ | |
| 394 | PORT_DIPSETTING( 0x08, DEF_STR( On ) ) | |
| 395 | ||
| 396 | #define TAITO_DSWA_BITS_1_TO_3_LOC(DIPBANK) \ | |
| 397 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION(#DIPBANK":2") \ | |
| 398 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) \ | |
| 399 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) \ | |
| 400 | TAITO_DSWA_BITS_2_TO_3_LOC(DIPBANK) | |
| 401 | ||
| 402 | #define TAITO_MACHINE_COCKTAIL_LOC(DIPBANK) \ | |
| 403 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION(#DIPBANK":1") \ | |
| 404 | PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) \ | |
| 405 | PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) ) \ | |
| 406 | TAITO_DSWA_BITS_1_TO_3_LOC(DIPBANK) | |
| 407 | ||
| 408 | #define TAITO_MACHINE_NO_COCKTAIL_LOC(DIPBANK) \ | |
| 409 | PORT_DIPUNUSED_DIPLOC( 0x01, IP_ACTIVE_LOW, #DIPBANK":1" ) \ | |
| 410 | TAITO_DSWA_BITS_1_TO_3_LOC(DIPBANK) | |
| 411 | ||
| 412 | ||
| 413 | /* without location */ | |
| 414 | #define TAITO_DSWA_BITS_2_TO_3 \ | |
| 415 | PORT_SERVICE( 0x04, IP_ACTIVE_LOW ) \ | |
| 416 | PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) ) \ | |
| 417 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) \ | |
| 418 | PORT_DIPSETTING( 0x08, DEF_STR( On ) ) | |
| 419 | ||
| 420 | #define TAITO_DSWA_BITS_1_TO_3 \ | |
| 421 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) \ | |
| 422 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) \ | |
| 423 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) \ | |
| 424 | TAITO_DSWA_BITS_2_TO_3 | |
| 425 | ||
| 426 | #define TAITO_MACHINE_COCKTAIL \ | |
| 427 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) \ | |
| 428 | PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) \ | |
| 429 | PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) ) \ | |
| 430 | TAITO_DSWA_BITS_1_TO_3 | |
| 431 | ||
| 432 | #define TAITO_MACHINE_NO_COCKTAIL \ | |
| 433 | PORT_DIPUNUSED( 0x01, IP_ACTIVE_LOW ) \ | |
| 434 | TAITO_DSWA_BITS_1_TO_3 | |
| 435 | ||
| 436 | ||
| 437 | /**************************** Coinage Dip Swicthes ****************************/ | |
| 438 | ||
| 439 | /* with location */ | |
| 440 | #define TAITO_COINAGE_JAPAN_OLD_COIN_A_LOC(DIPBANK) \ | |
| 441 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) ) PORT_DIPLOCATION(#DIPBANK":5,6") \ | |
| 442 | PORT_DIPSETTING( 0x10, DEF_STR( 2C_1C ) ) \ | |
| 443 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) ) \ | |
| 444 | PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) ) \ | |
| 445 | PORT_DIPSETTING( 0x20, DEF_STR( 1C_2C ) ) | |
| 446 | ||
| 447 | #define TAITO_COINAGE_JAPAN_OLD_COIN_B_LOC(DIPBANK) \ | |
| 448 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) ) PORT_DIPLOCATION(#DIPBANK":7,8") \ | |
| 449 | PORT_DIPSETTING( 0x40, DEF_STR( 2C_1C ) ) \ | |
| 450 | PORT_DIPSETTING( 0xc0, DEF_STR( 1C_1C ) ) \ | |
| 451 | PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) ) \ | |
| 452 | PORT_DIPSETTING( 0x80, DEF_STR( 1C_2C ) ) | |
| 453 | ||
| 454 | #define TAITO_COINAGE_JAPAN_NEW_COIN_A_LOC(DIPBANK) \ | |
| 455 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) ) PORT_DIPLOCATION(#DIPBANK":5,6") \ | |
| 456 | PORT_DIPSETTING( 0x00, DEF_STR( 3C_1C ) ) \ | |
| 457 | PORT_DIPSETTING( 0x10, DEF_STR( 2C_1C ) ) \ | |
| 458 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) ) \ | |
| 459 | PORT_DIPSETTING( 0x20, DEF_STR( 1C_2C ) ) | |
| 460 | ||
| 461 | #define TAITO_COINAGE_JAPAN_NEW_COIN_B_LOC(DIPBANK) \ | |
| 462 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) ) PORT_DIPLOCATION(#DIPBANK":7,8") \ | |
| 463 | PORT_DIPSETTING( 0x00, DEF_STR( 3C_1C ) ) \ | |
| 464 | PORT_DIPSETTING( 0x40, DEF_STR( 2C_1C ) ) \ | |
| 465 | PORT_DIPSETTING( 0xc0, DEF_STR( 1C_1C ) ) \ | |
| 466 | PORT_DIPSETTING( 0x80, DEF_STR( 1C_2C ) ) | |
| 467 | ||
| 468 | #define TAITO_COINAGE_WORLD_COIN_A_LOC(DIPBANK) \ | |
| 469 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) ) PORT_DIPLOCATION(#DIPBANK":5,6") \ | |
| 470 | PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) \ | |
| 471 | PORT_DIPSETTING( 0x10, DEF_STR( 3C_1C ) ) \ | |
| 472 | PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) ) \ | |
| 473 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) ) | |
| 474 | ||
| 475 | #define TAITO_COINAGE_WORLD_COIN_B_LOC(DIPBANK) \ | |
| 476 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) ) PORT_DIPLOCATION(#DIPBANK":7,8") \ | |
| 477 | PORT_DIPSETTING( 0xc0, DEF_STR( 1C_2C ) ) \ | |
| 478 | PORT_DIPSETTING( 0x80, DEF_STR( 1C_3C ) ) \ | |
| 479 | PORT_DIPSETTING( 0x40, DEF_STR( 1C_4C ) ) \ | |
| 480 | PORT_DIPSETTING( 0x00, DEF_STR( 1C_6C ) ) | |
| 481 | ||
| 482 | #define TAITO_COINAGE_US_COIN_START_LOC(DIPBANK) \ | |
| 483 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coinage ) ) PORT_DIPLOCATION(#DIPBANK":5,6") \ | |
| 484 | PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) \ | |
| 485 | PORT_DIPSETTING( 0x10, DEF_STR( 3C_1C ) ) \ | |
| 486 | PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) ) \ | |
| 487 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) ) | |
| 488 | ||
| 489 | #define TAITO_COINAGE_US_COIN_CONT_LOC(DIPBANK) \ | |
| 490 | PORT_DIPNAME( 0xc0, 0xc0, "Price to Continue" ) PORT_DIPLOCATION(#DIPBANK":7,8") \ | |
| 491 | PORT_DIPSETTING( 0x00, DEF_STR( 3C_1C ) ) \ | |
| 492 | PORT_DIPSETTING( 0x40, DEF_STR( 2C_1C ) ) \ | |
| 493 | PORT_DIPSETTING( 0x80, DEF_STR( 1C_1C ) ) \ | |
| 494 | PORT_DIPSETTING( 0xc0, "Same as Start" ) | |
| 495 | ||
| 496 | #define TAITO_COINAGE_JAPAN_OLD_LOC(DIPBANK) \ | |
| 497 | TAITO_COINAGE_JAPAN_OLD_COIN_A_LOC(DIPBANK) \ | |
| 498 | TAITO_COINAGE_JAPAN_OLD_COIN_B_LOC(DIPBANK) | |
| 499 | ||
| 500 | #define TAITO_COINAGE_JAPAN_NEW_LOC(DIPBANK) \ | |
| 501 | TAITO_COINAGE_JAPAN_NEW_COIN_A_LOC(DIPBANK) \ | |
| 502 | TAITO_COINAGE_JAPAN_NEW_COIN_B_LOC(DIPBANK) | |
| 503 | ||
| 504 | #define TAITO_COINAGE_WORLD_LOC(DIPBANK) \ | |
| 505 | TAITO_COINAGE_WORLD_COIN_A_LOC(DIPBANK) \ | |
| 506 | TAITO_COINAGE_WORLD_COIN_B_LOC(DIPBANK) | |
| 507 | ||
| 508 | #define TAITO_COINAGE_US_LOC(DIPBANK) \ | |
| 509 | TAITO_COINAGE_US_COIN_START_LOC(DIPBANK) \ | |
| 510 | TAITO_COINAGE_US_COIN_CONT_LOC(DIPBANK) | |
| 511 | ||
| 512 | ||
| 513 | /* without location */ | |
| 514 | #define TAITO_COINAGE_JAPAN_OLD_COIN_A \ | |
| 515 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) ) \ | |
| 516 | PORT_DIPSETTING( 0x10, DEF_STR( 2C_1C ) ) \ | |
| 517 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) ) \ | |
| 518 | PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) ) \ | |
| 519 | PORT_DIPSETTING( 0x20, DEF_STR( 1C_2C ) ) | |
| 520 | ||
| 521 | #define TAITO_COINAGE_JAPAN_OLD_COIN_B \ | |
| 522 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) ) \ | |
| 523 | PORT_DIPSETTING( 0x40, DEF_STR( 2C_1C ) ) \ | |
| 524 | PORT_DIPSETTING( 0xc0, DEF_STR( 1C_1C ) ) \ | |
| 525 | PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) ) \ | |
| 526 | PORT_DIPSETTING( 0x80, DEF_STR( 1C_2C ) ) | |
| 527 | ||
| 528 | #define TAITO_COINAGE_JAPAN_NEW_COIN_A \ | |
| 529 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) ) \ | |
| 530 | PORT_DIPSETTING( 0x00, DEF_STR( 3C_1C ) ) \ | |
| 531 | PORT_DIPSETTING( 0x10, DEF_STR( 2C_1C ) ) \ | |
| 532 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) ) \ | |
| 533 | PORT_DIPSETTING( 0x20, DEF_STR( 1C_2C ) ) | |
| 534 | ||
| 535 | #define TAITO_COINAGE_JAPAN_NEW_COIN_B \ | |
| 536 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) ) \ | |
| 537 | PORT_DIPSETTING( 0x00, DEF_STR( 3C_1C ) ) \ | |
| 538 | PORT_DIPSETTING( 0x40, DEF_STR( 2C_1C ) ) \ | |
| 539 | PORT_DIPSETTING( 0xc0, DEF_STR( 1C_1C ) ) \ | |
| 540 | PORT_DIPSETTING( 0x80, DEF_STR( 1C_2C ) ) | |
| 541 | ||
| 542 | #define TAITO_COINAGE_WORLD_COIN_A \ | |
| 543 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) ) \ | |
| 544 | PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) \ | |
| 545 | PORT_DIPSETTING( 0x10, DEF_STR( 3C_1C ) ) \ | |
| 546 | PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) ) \ | |
| 547 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) ) | |
| 548 | ||
| 549 | #define TAITO_COINAGE_WORLD_COIN_B \ | |
| 550 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) ) \ | |
| 551 | PORT_DIPSETTING( 0xc0, DEF_STR( 1C_2C ) ) \ | |
| 552 | PORT_DIPSETTING( 0x80, DEF_STR( 1C_3C ) ) \ | |
| 553 | PORT_DIPSETTING( 0x40, DEF_STR( 1C_4C ) ) \ | |
| 554 | PORT_DIPSETTING( 0x00, DEF_STR( 1C_6C ) ) | |
| 555 | ||
| 556 | #define TAITO_COINAGE_US_COIN_START \ | |
| 557 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coinage ) ) \ | |
| 558 | PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) \ | |
| 559 | PORT_DIPSETTING( 0x10, DEF_STR( 3C_1C ) ) \ | |
| 560 | PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) ) \ | |
| 561 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) ) | |
| 562 | ||
| 563 | #define TAITO_COINAGE_US_COIN_CONT \ | |
| 564 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Continue_Price ) ) \ | |
| 565 | PORT_DIPSETTING( 0x00, DEF_STR( 3C_1C ) ) \ | |
| 566 | PORT_DIPSETTING( 0x40, DEF_STR( 2C_1C ) ) \ | |
| 567 | PORT_DIPSETTING( 0x80, DEF_STR( 1C_1C ) ) \ | |
| 568 | PORT_DIPSETTING( 0xc0, "Same as Start" ) | |
| 569 | ||
| 570 | #define TAITO_COINAGE_JAPAN_OLD \ | |
| 571 | TAITO_COINAGE_JAPAN_OLD_COIN_A \ | |
| 572 | TAITO_COINAGE_JAPAN_OLD_COIN_B | |
| 573 | ||
| 574 | #define TAITO_COINAGE_JAPAN_NEW \ | |
| 575 | TAITO_COINAGE_JAPAN_NEW_COIN_A \ | |
| 576 | TAITO_COINAGE_JAPAN_NEW_COIN_B | |
| 577 | ||
| 578 | #define TAITO_COINAGE_WORLD \ | |
| 579 | TAITO_COINAGE_WORLD_COIN_A \ | |
| 580 | TAITO_COINAGE_WORLD_COIN_B | |
| 581 | ||
| 582 | #define TAITO_COINAGE_US \ | |
| 583 | TAITO_COINAGE_US_COIN_START \ | |
| 584 | TAITO_COINAGE_US_COIN_CONT | |
| 585 | ||
| 586 | ||
| 587 | /************************** Difficulty Dip Swicthes ***************************/ | |
| 588 | ||
| 589 | /* with location */ | |
| 590 | #define TAITO_DIFFICULTY_LOC(DIPBANK) \ | |
| 591 | PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPLOCATION(#DIPBANK":1,2") \ | |
| 592 | PORT_DIPSETTING( 0x02, DEF_STR( Easy ) ) \ | |
| 593 | PORT_DIPSETTING( 0x03, DEF_STR( Medium ) ) \ | |
| 594 | PORT_DIPSETTING( 0x01, DEF_STR( Hard ) ) \ | |
| 595 | PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) ) | |
| 596 | ||
| 597 | /* without location */ | |
| 598 | #define TAITO_DIFFICULTY \ | |
| 599 | PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) \ | |
| 600 | PORT_DIPSETTING( 0x02, DEF_STR( Easy ) ) \ | |
| 601 | PORT_DIPSETTING( 0x03, DEF_STR( Medium ) ) \ | |
| 602 | PORT_DIPSETTING( 0x01, DEF_STR( Hard ) ) \ | |
| 603 | PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) ) | |
| 604 | ||
| 605 | ||
| 606 | /************************** Joysticks and buttons *****************************/ | |
| 607 | ||
| 608 | /* generic (might be moved elsewhere) */ | |
| 609 | #define INPUT_GENERIC_JOY_LOW_NIBBLE(PL, STATE, WAY, B01, B02, B04, B08) \ | |
| 610 | PORT_BIT( 0x01, STATE, IPT_JOYSTICK_##B01 ) WAY PORT_PLAYER(PL) \ | |
| 611 | PORT_BIT( 0x02, STATE, IPT_JOYSTICK_##B02 ) WAY PORT_PLAYER(PL) \ | |
| 612 | PORT_BIT( 0x04, STATE, IPT_JOYSTICK_##B04 ) WAY PORT_PLAYER(PL) \ | |
| 613 | PORT_BIT( 0x08, STATE, IPT_JOYSTICK_##B08 ) WAY PORT_PLAYER(PL) | |
| 614 | ||
| 615 | #define INPUT_GENERIC_JOY_HIGH_NIBBLE(PL, STATE, WAY, B10, B20, B40, B80) \ | |
| 616 | PORT_BIT( 0x10, STATE, IPT_JOYSTICK_##B10 ) WAY PORT_PLAYER(PL) \ | |
| 617 | PORT_BIT( 0x20, STATE, IPT_JOYSTICK_##B20 ) WAY PORT_PLAYER(PL) \ | |
| 618 | PORT_BIT( 0x40, STATE, IPT_JOYSTICK_##B40 ) WAY PORT_PLAYER(PL) \ | |
| 619 | PORT_BIT( 0x80, STATE, IPT_JOYSTICK_##B80 ) WAY PORT_PLAYER(PL) | |
| 620 | ||
| 621 | ||
| 622 | /* Taito generic (more might be needed) */ | |
| 623 | #define TAITO_GENERIC_JOY_MONO_UDLR(PL) \ | |
| 624 | INPUT_GENERIC_JOY_LOW_NIBBLE(PL, IP_ACTIVE_LOW, PORT_8WAY, UP, DOWN, LEFT, RIGHT) | |
| 625 | ||
| 626 | #define TAITO_GENERIC_JOY_MONO_UDRL(PL) \ | |
| 627 | INPUT_GENERIC_JOY_LOW_NIBBLE(PL, IP_ACTIVE_LOW, PORT_8WAY, UP, DOWN, RIGHT, LEFT) | |
| 628 | ||
| 629 | #define TAITO_GENERIC_JOY_MONO_LRUD(PL) \ | |
| 630 | INPUT_GENERIC_JOY_LOW_NIBBLE(PL, IP_ACTIVE_LOW, PORT_8WAY, LEFT, RIGHT, UP, DOWN) | |
| 631 | ||
| 632 | #define TAITO_GENERIC_JOY_DUAL_UDLR(PL_L, PL_H) \ | |
| 633 | INPUT_GENERIC_JOY_LOW_NIBBLE(PL_L, IP_ACTIVE_LOW, PORT_8WAY, UP, DOWN, LEFT, RIGHT) \ | |
| 634 | INPUT_GENERIC_JOY_HIGH_NIBBLE(PL_H, IP_ACTIVE_LOW, PORT_8WAY, UP, DOWN, LEFT, RIGHT) | |
| 635 | ||
| 636 | #define TAITO_GENERIC_JOY_DUAL_UDRL(PL_L, PL_H) \ | |
| 637 | INPUT_GENERIC_JOY_LOW_NIBBLE(PL_L, IP_ACTIVE_LOW, PORT_8WAY, UP, DOWN, RIGHT, LEFT) \ | |
| 638 | INPUT_GENERIC_JOY_HIGH_NIBBLE(PL_H, IP_ACTIVE_LOW, PORT_8WAY, UP, DOWN, RIGHT, LEFT) | |
| 639 | ||
| 640 | ||
| 641 | #define TAITO_GENERIC_BUTTONS_LOW_NIBBLE(PL, STATE, BUTTON_A, BUTTON_B, BUTTON_C) \ | |
| 642 | PORT_BIT( 0x01, STATE, IPT_##BUTTON_A ) PORT_PLAYER(PL) \ | |
| 643 | PORT_BIT( 0x02, STATE, IPT_##BUTTON_B ) PORT_PLAYER(PL) \ | |
| 644 | PORT_BIT( 0x04, STATE, IPT_##BUTTON_C ) PORT_PLAYER(PL) | |
| 645 | /* DO NOT fill bit 3 as it may be defined as START button ! */ | |
| 646 | ||
| 647 | #define TAITO_GENERIC_BUTTONS_HIGH_NIBBLE(PL, STATE, BUTTON_A, BUTTON_B, BUTTON_C) \ | |
| 648 | PORT_BIT( 0x10, STATE, IPT_##BUTTON_A ) PORT_PLAYER(PL) \ | |
| 649 | PORT_BIT( 0x20, STATE, IPT_##BUTTON_B ) PORT_PLAYER(PL) \ | |
| 650 | PORT_BIT( 0x40, STATE, IPT_##BUTTON_C ) PORT_PLAYER(PL) | |
| 651 | /* DO NOT fill bit 7 as it may be defined as START button ! */ | |
| 652 | ||
| 653 | #define TAITO_GENERIC_1_BUTTON(PL) \ | |
| 654 | TAITO_GENERIC_BUTTONS_HIGH_NIBBLE(PL, IP_ACTIVE_LOW, BUTTON1, UNKNOWN, UNKNOWN) \ | |
| 655 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 656 | ||
| 657 | #define TAITO_GENERIC_2_BUTTONS(PL) \ | |
| 658 | TAITO_GENERIC_BUTTONS_HIGH_NIBBLE(PL, IP_ACTIVE_LOW, BUTTON1, BUTTON2, UNKNOWN) \ | |
| 659 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 660 | ||
| 661 | #define TAITO_GENERIC_3_BUTTONS(PL) \ | |
| 662 | TAITO_GENERIC_BUTTONS_HIGH_NIBBLE(PL, IP_ACTIVE_LOW, BUTTON1, BUTTON2, BUTTON3) \ | |
| 663 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 664 | ||
| 665 | #define TAITO_GENERIC_1_BUTTON_START(PL) \ | |
| 666 | TAITO_GENERIC_BUTTONS_HIGH_NIBBLE(PL, IP_ACTIVE_LOW, BUTTON1, UNKNOWN, UNKNOWN) \ | |
| 667 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START##PL ) | |
| 668 | ||
| 669 | #define TAITO_GENERIC_2_BUTTONS_START(PL) \ | |
| 670 | TAITO_GENERIC_BUTTONS_HIGH_NIBBLE(PL, IP_ACTIVE_LOW, BUTTON1, BUTTON2, UNKNOWN) \ | |
| 671 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START##PL ) | |
| 672 | ||
| 673 | #define TAITO_GENERIC_3_BUTTONS_START(PL) \ | |
| 674 | TAITO_GENERIC_BUTTONS_HIGH_NIBBLE(PL, IP_ACTIVE_LOW, BUTTON1, BUTTON2, BUTTON3) \ | |
| 675 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START##PL ) | |
| 676 | ||
| 677 | ||
| 678 | /* Taito games (more might be needed) */ | |
| 679 | #define TAITO_JOY_UDLR_1_BUTTON(PL) \ | |
| 680 | TAITO_GENERIC_JOY_MONO_UDLR(PL) \ | |
| 681 | TAITO_GENERIC_1_BUTTON(PL) | |
| 682 | ||
| 683 | #define TAITO_JOY_UDLR_2_BUTTONS(PL) \ | |
| 684 | TAITO_GENERIC_JOY_MONO_UDLR(PL) \ | |
| 685 | TAITO_GENERIC_2_BUTTONS(PL) | |
| 686 | ||
| 687 | #define TAITO_JOY_UDLR_3_BUTTONS(PL) \ | |
| 688 | TAITO_GENERIC_JOY_MONO_UDLR(PL) \ | |
| 689 | TAITO_GENERIC_3_BUTTONS(PL) | |
| 690 | ||
| 691 | #define TAITO_JOY_UDRL_1_BUTTON(PL) \ | |
| 692 | TAITO_GENERIC_JOY_MONO_UDRL(PL) \ | |
| 693 | TAITO_GENERIC_1_BUTTON(PL) | |
| 694 | ||
| 695 | #define TAITO_JOY_UDRL_2_BUTTONS(PL) \ | |
| 696 | TAITO_GENERIC_JOY_MONO_UDRL(PL) \ | |
| 697 | TAITO_GENERIC_2_BUTTONS(PL) | |
| 698 | ||
| 699 | #define TAITO_JOY_UDRL_3_BUTTONS(PL) \ | |
| 700 | TAITO_GENERIC_JOY_MONO_UDRL(PL) \ | |
| 701 | TAITO_GENERIC_3_BUTTONS(PL) | |
| 702 | ||
| 703 | #define TAITO_JOY_LRUD_1_BUTTON(PL) \ | |
| 704 | TAITO_GENERIC_JOY_MONO_LRUD(PL) \ | |
| 705 | TAITO_GENERIC_1_BUTTON(PL) | |
| 706 | ||
| 707 | #define TAITO_JOY_LRUD_2_BUTTONS(PL) \ | |
| 708 | TAITO_GENERIC_JOY_MONO_LRUD(PL) \ | |
| 709 | TAITO_GENERIC_2_BUTTONS(PL) | |
| 710 | ||
| 711 | #define TAITO_JOY_LRUD_3_BUTTONS(PL) \ | |
| 712 | TAITO_GENERIC_JOY_MONO_LRUD(PL) \ | |
| 713 | TAITO_GENERIC_3_BUTTONS(PL) | |
| 714 | ||
| 715 | ||
| 716 | #define TAITO_JOY_UDLR_1_BUTTON_START(PL) \ | |
| 717 | TAITO_GENERIC_JOY_MONO_UDLR(PL) \ | |
| 718 | TAITO_GENERIC_1_BUTTON_START(PL) | |
| 719 | ||
| 720 | #define TAITO_JOY_UDLR_2_BUTTONS_START(PL) \ | |
| 721 | TAITO_GENERIC_JOY_MONO_UDLR(PL) \ | |
| 722 | TAITO_GENERIC_2_BUTTONS_START(PL) | |
| 723 | ||
| 724 | #define TAITO_JOY_UDLR_3_BUTTONS_START(PL) \ | |
| 725 | TAITO_GENERIC_JOY_MONO_UDLR(PL) \ | |
| 726 | TAITO_GENERIC_3_BUTTONS_START(PL) | |
| 727 | ||
| 728 | #define TAITO_JOY_UDRL_1_BUTTON_START(PL) \ | |
| 729 | TAITO_GENERIC_JOY_MONO_UDRL(PL) \ | |
| 730 | TAITO_GENERIC_1_BUTTONS_START(PL) | |
| 731 | ||
| 732 | #define TAITO_JOY_UDRL_2_BUTTONS_START(PL) \ | |
| 733 | TAITO_GENERIC_JOY_MONO_UDRL(PL) \ | |
| 734 | TAITO_GENERIC_2_BUTTONS_START(PL) | |
| 735 | ||
| 736 | #define TAITO_JOY_UDRL_3_BUTTONS_START(PL) \ | |
| 737 | TAITO_GENERIC_JOY_MONO_UDRL(PL) \ | |
| 738 | TAITO_GENERIC_3_BUTTONS_START(PL) | |
| 739 | ||
| 740 | #define TAITO_JOY_LRUD_1_BUTTON_START(PL) \ | |
| 741 | TAITO_GENERIC_JOY_MONO_LRUD(PL) \ | |
| 742 | TAITO_GENERIC_1_BUTTON_START(PL) | |
| 743 | ||
| 744 | #define TAITO_JOY_LRUD_2_BUTTONS_START(PL) \ | |
| 745 | TAITO_GENERIC_JOY_MONO_LRUD(PL) \ | |
| 746 | TAITO_GENERIC_2_BUTTONS_START(PL) | |
| 747 | ||
| 748 | #define TAITO_JOY_LRUD_3_BUTTONS_START(PL) \ | |
| 749 | TAITO_GENERIC_JOY_MONO_LRUD(PL) \ | |
| 750 | TAITO_GENERIC_3_BUTTONS_START(PL) | |
| 751 | ||
| 752 | ||
| 753 | #define TAITO_JOY_DUAL_UDLR(PL_L, PL_H) \ | |
| 754 | TAITO_GENERIC_JOY_DUAL_UDLR(PL_L, PL_H) | |
| 755 | ||
| 756 | #define TAITO_JOY_DUAL_UDRL(PL_L, PL_H) \ | |
| 757 | TAITO_GENERIC_JOY_DUAL_UDRL(PL_L, PL_H) | |
| 758 |
| r0 | r937 | |
|---|---|---|
| 1 | /*************************************************************************** | |
| 2 | ||
| 3 | CuboCD32 definitions | |
| 4 | ||
| 5 | ***************************************************************************/ | |
| 6 | ||
| 7 | #ifndef __CUBOCD32_H__ | |
| 8 | #define __CUBOCD32_H__ | |
| 9 | ||
| 10 | extern void amiga_akiko_init(void); | |
| 11 | extern NVRAM_HANDLER( cd32 ); | |
| 12 | extern READ32_HANDLER(amiga_akiko32_r); | |
| 13 | extern WRITE32_HANDLER(amiga_akiko32_w); | |
| 14 | ||
| 15 | #endif /* __CUBOCD32_H__ */ |
| r936 | r937 | |
|---|---|---|
| 17 | 17 | WRITE8_HANDLER( docastle_flipscreen_on_w ); |
| 18 | 18 | |
| 19 | 19 | PALETTE_INIT( docastle ); |
| 20 | PALETTE_INIT( dorunrun ); | |
| 21 | 20 | VIDEO_START( docastle ); |
| 21 | VIDEO_START( dorunrun ); | |
| 22 | 22 | VIDEO_UPDATE( docastle ); |
| 23 | 23 |
| r936 | r937 | |
|---|---|---|
| 23 | 23 | |
| 24 | 24 | VIDEO_START( m92 ); |
| 25 | 25 | VIDEO_UPDATE( m92 ); |
| 26 | /************************************************************************* | |
| 27 | ||
| 28 | Irem M92 hardware | |
| 29 | ||
| 30 | *************************************************************************/ | |
| 31 | ||
| 32 | /*----------- defined in video/m92.c -----------*/ | |
| 33 | ||
| 34 | extern int m92_raster_irq_position, m92_raster_enable; | |
| 35 | extern UINT16 *m92_vram_data, *m92_spritecontrol; | |
| 36 | ||
| 37 | extern UINT8 m92_sprite_buffer_busy, m92_game_kludge; | |
| 38 | ||
| 39 | WRITE16_HANDLER( m92_spritecontrol_w ); | |
| 40 | WRITE16_HANDLER( m92_videocontrol_w ); | |
| 41 | READ16_HANDLER( m92_paletteram_r ); | |
| 42 | WRITE16_HANDLER( m92_paletteram_w ); | |
| 43 | WRITE16_HANDLER( m92_vram_w ); | |
| 44 | WRITE16_HANDLER( m92_pf1_control_w ); | |
| 45 | WRITE16_HANDLER( m92_pf2_control_w ); | |
| 46 | WRITE16_HANDLER( m92_pf3_control_w ); | |
| 47 | WRITE16_HANDLER( m92_master_control_w ); | |
| 48 | ||
| 49 | VIDEO_START( m92 ); | |
| 50 | VIDEO_UPDATE( m92 ); |
| r936 | r937 | |
|---|---|---|
| 292 | 292 | #define AMIGA_68000_NTSC_CLOCK 7159090 /* Hz */ |
| 293 | 293 | #define AMIGA_68000_PAL_CLOCK 7093790 /* Hz */ |
| 294 | 294 | #define AMIGA_68EC020_NTSC_CLOCK 14318180 /* Hz */ |
| 295 | #define CDTV_CLOCK_X1 28636363 | |
| 296 | #define CDTV_CLOCK_X5 28375160 | |
| 295 | #define AMIGA_68EC020_PAL_CLOCK 14187580 /* Hz */ | |
| 296 | #define CDTV_CLOCK_X1 28636363 /* Hz */ | |
| 297 | #define CDTV_CLOCK_X5 28375160 /* Hz */ | |
| 297 | 298 | |
| 298 | 299 | |
| 299 | 300 | #define ANGUS_CHIP_RAM_MASK 0x07fffe |
| r936 | r937 | |
|---|---|---|
| 17 | 17 | VIDEO_START( m107 ); |
| 18 | 18 | WRITE16_HANDLER( m107_control_w ); |
| 19 | 19 | WRITE16_HANDLER( m107_vram_w ); |
| 20 | /************************************************************************* | |
| 21 | ||
| 22 | Irem M107 hardware | |
| 23 | ||
| 24 | *************************************************************************/ | |
| 25 | ||
| 26 | ||
| 27 | /*----------- defined in video/m107.c -----------*/ | |
| 28 | ||
| 29 | extern UINT16 *m107_vram_data; | |
| 30 | extern UINT8 m107_spritesystem; | |
| 31 | extern UINT16 m107_raster_irq_position; | |
| 32 | ||
| 33 | WRITE16_HANDLER( m107_spritebuffer_w ); | |
| 34 | VIDEO_UPDATE( m107 ); | |
| 35 | VIDEO_UPDATE( dsoccr ); | |
| 36 | VIDEO_START( m107 ); | |
| 37 | WRITE16_HANDLER( m107_control_w ); | |
| 38 | WRITE16_HANDLER( m107_vram_w ); |
| r936 | r937 | |
|---|---|---|
| 38 | 38 | |
| 39 | 39 | VIDEO_UPDATE( m72 ); |
| 40 | 40 | VIDEO_UPDATE( majtitle ); |
| 41 | /************************************************************************* | |
| 42 | ||
| 43 | Irem M72 hardware | |
| 44 | ||
| 45 | *************************************************************************/ | |
| 46 | ||
| 47 | /*----------- defined in video/m72.c -----------*/ | |
| 48 | ||
| 49 | extern UINT16 *m72_videoram1,*m72_videoram2,*majtitle_rowscrollram; | |
| 50 | ||
| 51 | MACHINE_RESET( m72 ); | |
| 52 | MACHINE_RESET( xmultipl ); | |
| 53 | MACHINE_RESET( kengo ); | |
| 54 | ||
| 55 | INTERRUPT_GEN( m72_interrupt ); | |
| 56 | ||
| 57 | VIDEO_START( m72 ); | |
| 58 | VIDEO_START( rtype2 ); | |
| 59 | VIDEO_START( majtitle ); | |
| 60 | VIDEO_START( hharry ); | |
| 61 | VIDEO_START( poundfor ); | |
| 62 | ||
| 63 | READ16_HANDLER( m72_palette1_r ); | |
| 64 | READ16_HANDLER( m72_palette2_r ); | |
| 65 | WRITE16_HANDLER( m72_palette1_w ); | |
| 66 | WRITE16_HANDLER( m72_palette2_w ); | |
| 67 | WRITE16_HANDLER( m72_videoram1_w ); | |
| 68 | WRITE16_HANDLER( m72_videoram2_w ); | |
| 69 | WRITE16_HANDLER( m72_irq_line_w ); | |
| 70 | WRITE16_HANDLER( m72_scrollx1_w ); | |
| 71 | WRITE16_HANDLER( m72_scrollx2_w ); | |
| 72 | WRITE16_HANDLER( m72_scrolly1_w ); | |
| 73 | WRITE16_HANDLER( m72_scrolly2_w ); | |
| 74 | WRITE16_HANDLER( m72_dmaon_w ); | |
| 75 | WRITE16_HANDLER( m72_port02_w ); | |
| 76 | WRITE16_HANDLER( rtype2_port02_w ); | |
| 77 | WRITE16_HANDLER( majtitle_gfx_ctrl_w ); | |
| 78 | ||
| 79 | VIDEO_UPDATE( m72 ); | |
| 80 | VIDEO_UPDATE( majtitle ); |
| r936 | r937 | |
|---|---|---|
| 163 | 163 | CPUS += M37702 |
| 164 | 164 | CPUS += M37710 |
| 165 | 165 | CPUS += PPC403 |
| 166 | CPUS += PPC601 | |
| 166 | 167 | CPUS += PPC602 |
| 167 | 168 | CPUS += PPC603 |
| 168 | 169 | CPUS += MPC8240 |
| r936 | r937 | |
| 364 | 365 | $(MAMEOBJ)/sigma.a \ |
| 365 | 366 | $(MAMEOBJ)/snk.a \ |
| 366 | 367 | $(MAMEOBJ)/stern.a \ |
| 368 | $(MAMEOBJ)/subsino.a \ | |
| 367 | 369 | $(MAMEOBJ)/sun.a \ |
| 368 | 370 | $(MAMEOBJ)/suna.a \ |
| 369 | 371 | $(MAMEOBJ)/tad.a \ |
| r936 | r937 | |
| 476 | 478 | $(DRIVERS)/alg.o \ |
| 477 | 479 | $(MACHINE)/amiga.o $(AUDIO)/amiga.o $(VIDEO)/amiga.o \ |
| 478 | 480 | $(DRIVERS)/arcadia.o \ |
| 479 | $(DRIVERS)/cubocd32.o \ | |
| 481 | $(DRIVERS)/cubocd32.o $(MACHINE)/cubocd32.o \ | |
| 480 | 482 | $(DRIVERS)/mquake.o \ |
| 481 | 483 | $(DRIVERS)/upscope.o \ |
| 482 | 484 | |
| r936 | r937 | |
| 1244 | 1246 | $(DRIVERS)/macs.o \ |
| 1245 | 1247 | $(DRIVERS)/seta.o $(VIDEO)/seta.o \ |
| 1246 | 1248 | $(DRIVERS)/seta2.o $(VIDEO)/seta2.o \ |
| 1249 | $(DRIVERS)/speglsht.o \ | |
| 1247 | 1250 | $(DRIVERS)/speedatk.o $(VIDEO)/speedatk.o \ |
| 1248 | 1251 | $(DRIVERS)/srmp2.o $(VIDEO)/srmp2.o \ |
| 1249 | 1252 | $(DRIVERS)/srmp6.o \ |
| r936 | r937 | |
| 1278 | 1281 | $(DRIVERS)/mazerbla.o \ |
| 1279 | 1282 | $(DRIVERS)/supdrapo.o \ |
| 1280 | 1283 | |
| 1284 | $(MAMEOBJ)/subsino.a: \ | |
| 1285 | $(DRIVERS)/bishjan.o \ | |
| 1286 | $(DRIVERS)/lastfght.o \ | |
| 1287 | ||
| 1281 | 1288 | $(MAMEOBJ)/sun.a: \ |
| 1282 | 1289 | $(DRIVERS)/arabian.o $(VIDEO)/arabian.o \ |
| 1283 | 1290 | $(DRIVERS)/ikki.o $(VIDEO)/ikki.o \ |
| r936 | r937 | |
| 1576 | 1583 | $(DRIVERS)/kyugo.o $(VIDEO)/kyugo.o \ |
| 1577 | 1584 | $(DRIVERS)/ladyfrog.o $(VIDEO)/ladyfrog.o \ |
| 1578 | 1585 | $(DRIVERS)/laserbas.o \ |
| 1579 | $(DRIVERS)/lastfght.o \ | |
| 1580 | 1586 | $(DRIVERS)/lethalj.o $(VIDEO)/lethalj.o \ |
| 1581 | 1587 | $(DRIVERS)/limenko.o \ |
| 1582 | 1588 | $(DRIVERS)/ltcasino.o \ |
| r936 | r937 | |
|---|---|---|
| 17 | 17 | static tilemap *fg_tilemap,*bg_tilemap; |
| 18 | 18 | static INT32 xevious_bs[2]; |
| 19 | 19 | |
| 20 | static colortable *xevious_colortable; | |
| 21 | ||
| 20 | 22 | /*************************************************************************** |
| 21 | 23 | |
| 22 | 24 | Convert the color PROMs into a more useable format. |
| r936 | r937 | |
| 36 | 38 | { |
| 37 | 39 | int i; |
| 38 | 40 | #define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity) |
| 39 | #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs]) | |
| 40 | 41 | |
| 42 | xevious_colortable = colortable_alloc(machine, 128+1); | |
| 41 | 43 | |
| 42 | 44 | for (i = 0;i < 128;i++) |
| 43 | 45 | { |
| 44 | 46 | int bit0,bit1,bit2,bit3,r,g,b; |
| 45 | 47 | |
| 46 | ||
| 47 | 48 | /* red component */ |
| 48 | 49 | bit0 = (color_prom[0] >> 0) & 0x01; |
| 49 | 50 | bit1 = (color_prom[0] >> 1) & 0x01; |
| r936 | r937 | |
| 63 | 64 | bit3 = (color_prom[2*256] >> 3) & 0x01; |
| 64 | 65 | b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; |
| 65 | 66 | |
| 66 | palette_set_color( | |
| 67 | colortable_palette_set_color(xev | |
| 67 | 68 | color_prom++; |
| 68 | 69 | } |
| 69 | 70 | |
| 70 | 71 | /* color 0x80 is used by sprites to mark transparency */ |
| 71 | palette_set_color( | |
| 72 | colortable_palette_set_color(xev | |
| 72 | 73 | |
| 73 | 74 | color_prom += 128; /* the bottom part of the PROM is unused */ |
| 74 | 75 | color_prom += 2*256; |
| r936 | r937 | |
| 77 | 78 | /* background tiles */ |
| 78 | 79 | for (i = 0;i < TOTAL_COLORS(1);i++) |
| 79 | 80 | { |
| 80 | COLOR(1,i) = (color_prom[0] & 0x0f) | ((color_prom[TOTAL_COLORS(1)] & 0x0f) << 4); | |
| 81 | colortable_entry_set_value(xevious_colortable, machine->gfx[1]->color_base + i, | |
| 82 | (color_prom[0] & 0x0f) | ((color_prom[TOTAL_COLORS(1)] & 0x0f) << 4)); | |
| 81 | 83 | |
| 82 | 84 | color_prom++; |
| 83 | 85 | } |
| r936 | r937 | |
| 88 | 90 | { |
| 89 | 91 | int c = (color_prom[0] & 0x0f) | ((color_prom[TOTAL_COLORS(2)] & 0x0f) << 4); |
| 90 | 92 | |
| 91 | if (c & 0x80) COLOR(2,i) = c & 0x7f; | |
| 92 | else COLOR(2,i) = 0x80; /* transparent */ | |
| 93 | colortable_entry_set_value(xevious_colortable, machine->gfx[2]->color_base + i, | |
| 94 | (c & 0x80) ? (c & 0x7f) : 0x80); | |
| 93 | 95 | |
| 94 | 96 | color_prom++; |
| 95 | 97 | } |
| r936 | r937 | |
| 98 | 100 | /* foreground characters */ |
| 99 | 101 | for (i = 0;i < TOTAL_COLORS(0);i++) |
| 100 | 102 | { |
| 101 | if (i % 2 == 0) COLOR(0,i) = 0x80; /* transparent */ | |
| 102 | else COLOR(0,i) = i / 2; | |
| 103 | colortable_entry_set_value(xevious_colortable, machine->gfx[0]->color_base + i, | |
| 104 | (i % 2 != 0) ? (i / 2) : 0x80); | |
| 103 | 105 | } |
| 104 | 106 | } |
| 105 | 107 | |
| r936 | r937 | |
| 108 | 110 | PALETTE_INIT( battles ) |
| 109 | 111 | { |
| 110 | 112 | int i; |
| 111 | #define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity) | |
| 112 | #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs]) | |
| 113 | 113 | |
| 114 | xevious_colortable = colortable_alloc(machine, 128+1); | |
| 114 | 115 | |
| 115 | 116 | for (i = 0;i < 128;i++) |
| 116 | 117 | { |
| 117 | 118 | int bit0,bit1,bit2,bit3,r,g,b; |
| 118 | 119 | |
| 119 | ||
| 120 | 120 | /* red component */ |
| 121 | 121 | bit0 = (color_prom[0] >> 0) & 0x01; |
| 122 | 122 | bit1 = (color_prom[0] >> 1) & 0x01; |
| r936 | r937 | |
| 136 | 136 | bit3 = (color_prom[2*256] >> 3) & 0x01; |
| 137 | 137 | b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; |
| 138 | 138 | |
| 139 | palette_set_color( | |
| 139 | colortable_palette_set_color(xev | |
| 140 | 140 | color_prom++; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /* color 0x80 is used by sprites to mark transparency */ |
| 144 | palette_set_color( | |
| 144 | colortable_palette_set_color(xev | |
| 145 | 145 | |
| 146 | 146 | color_prom += 128; /* the bottom part of the PROM is unused */ |
| 147 | 147 | color_prom += 2*256; |
| r936 | r937 | |
| 150 | 150 | /* background tiles */ |
| 151 | 151 | for (i = 0;i < TOTAL_COLORS(1);i++) |
| 152 | 152 | { |
| 153 | COLOR(1,i) = (color_prom[0] & 0x0f) | ((color_prom[0x400] & 0x0f) << 4); | |
| 153 | colortable_entry_set_value(xevious_colortable, machine->gfx[1]->color_base + i, | |
| 154 | (color_prom[0] & 0x0f) | ((color_prom[0x400] & 0x0f) << 4)); | |
| 154 | 155 | |
| 155 | 156 | color_prom++; |
| 156 | 157 | } |
| r936 | r937 | |
| 161 | 162 | { |
| 162 | 163 | int c = (color_prom[0] & 0x0f) | ((color_prom[0x400] & 0x0f) << 4); |
| 163 | 164 | |
| 164 | if (c & 0x80) COLOR(2,i) = c & 0x7f; | |
| 165 | else COLOR(2,i) = 0x80; /* transparent */ | |
| 165 | colortable_entry_set_value(xevious_colortable, machine->gfx[2]->color_base + i, | |
| 166 | (c & 0x80) ? (c & 0x7f) : 0x80); | |
| 166 | 167 | |
| 167 | 168 | color_prom++; |
| 168 | 169 | } |
| r936 | r937 | |
| 170 | 171 | /* foreground characters */ |
| 171 | 172 | for (i = 0;i < TOTAL_COLORS(0);i++) |
| 172 | 173 | { |
| 173 | if (i % 2 == 0) COLOR(0,i) = 0x80; /* transparent */ | |
| 174 | else COLOR(0,i) = i / 2; | |
| 174 | colortable_entry_set_value(xevious_colortable, machine->gfx[0]->color_base + i, | |
| 175 | (i % 2 != 0) ? (i / 2) : 0x80); | |
| 175 | 176 | } |
| 176 | 177 | } |
| 177 | 178 | |
| r936 | r937 | |
| 192 | 193 | timing signals, while x flip is done by selecting the 2nd character set. |
| 193 | 194 | We reproduce this here, but since the tilemap system automatically flips |
| 194 | 195 | characters when screen is flipped, we have to flip them back. */ |
| 196 | UINT8 color = ((attr & 0x03) << 4) | ((attr & 0x3c) >> 2); | |
| 195 | 197 | SET_TILE_INFO( |
| 196 | 198 | 0, |
| 197 | 199 | xevious_fg_videoram[tile_index] | (flip_screen ? 0x100 : 0), |
| 198 | | |
| 200 | | |
| 199 | 201 | TILE_FLIPYX((attr & 0xc0) >> 6) ^ (flip_screen ? TILE_FLIPX : 0)); |
| 200 | 202 | } |
| 201 | 203 | |
| r936 | r937 | |
| 203 | 205 | { |
| 204 | 206 | UINT8 code = xevious_bg_videoram[tile_index]; |
| 205 | 207 | UINT8 attr = xevious_bg_colorram[tile_index]; |
| 208 | UINT8 color = ((attr & 0x3c) >> 2) | ((code & 0x80) >> 3) | ((attr & 0x03) << 5); | |
| 206 | 209 | SET_TILE_INFO( |
| 207 | 210 | 1, |
| 208 | 211 | code + ((attr & 0x01) << 8), |
| 209 | | |
| 212 | | |
| 210 | 213 | TILE_FLIPYX((attr & 0xc0) >> 6)); |
| 211 | 214 | } |
| 212 | 215 | |
| r936 | r937 | |
| 433 | 436 | if ((spriteram[offs + 1] & 0x40) == 0) /* I'm not sure about this one */ |
| 434 | 437 | { |
| 435 | 438 | int bank,code,color,flipx,flipy; |
| 439 | UINT32 transmask; | |
| 436 | 440 | |
| 437 | ||
| 438 | 441 | if (spriteram_3[offs] & 0x80) |
| 439 | 442 | { |
| 440 | 443 | bank = 2; |
| r936 | r937 | |
| 456 | 459 | } |
| 457 | 460 | sx = spriteram_2[offs + 1] - 40 + 0x100*(spriteram_3[offs + 1] & 1); |
| 458 | 461 | sy = 28*8-spriteram_2[offs]-1; |
| 462 | ||
| 463 | transmask = colortable_get_transpen_mask(xevious_colortable, machine->gfx[bank], color, 0x80); | |
| 464 | ||
| 459 | 465 | if (spriteram_3[offs] & 2) /* double height (?) */ |
| 460 | 466 | { |
| 461 | 467 | if (spriteram_3[offs] & 1) /* double width, double height */ |
| r936 | r937 | |
| 464 | 470 | drawgfx(bitmap,machine->gfx[bank], |
| 465 | 471 | code+3,color,flipx,flipy, |
| 466 | 472 | flipx ? sx : sx+16,flipy ? sy-16 : sy, |
| 467 | cliprect,TRANSPARENCY_ | |
| 473 | cliprect,TRANSPARENCY_PENS | |
| 468 | 474 | drawgfx(bitmap,machine->gfx[bank], |
| 469 | 475 | code+1,color,flipx,flipy, |
| 470 | 476 | flipx ? sx : sx+16,flipy ? sy : sy-16, |
| 471 | cliprect,TRANSPARENCY_ | |
| 477 | cliprect,TRANSPARENCY_PENS | |
| 472 | 478 | } |
| 473 | 479 | code &= ~2; |
| 474 | 480 | drawgfx(bitmap,machine->gfx[bank], |
| 475 | 481 | code+2,color,flipx,flipy, |
| 476 | 482 | flipx ? sx+16 : sx,flipy ? sy-16 : sy, |
| 477 | cliprect,TRANSPARENCY_ | |
| 483 | cliprect,TRANSPARENCY_PENS | |
| 478 | 484 | drawgfx(bitmap,machine->gfx[bank], |
| 479 | 485 | code,color,flipx,flipy, |
| 480 | 486 | flipx ? sx+16 : sx,flipy ? sy : sy-16, |
| 481 | cliprect,TRANSPARENCY_ | |
| 487 | cliprect,TRANSPARENCY_PENS | |
| 482 | 488 | } |
| 483 | 489 | else if (spriteram_3[offs] & 1) /* double width */ |
| 484 | 490 | { |
| r936 | r937 | |
| 486 | 492 | drawgfx(bitmap,machine->gfx[bank], |
| 487 | 493 | code,color,flipx,flipy, |
| 488 | 494 | flipx ? sx+16 : sx,flipy ? sy-16 : sy, |
| 489 | cliprect,TRANSPARENCY_ | |
| 495 | cliprect,TRANSPARENCY_PENS | |
| 490 | 496 | drawgfx(bitmap,machine->gfx[bank], |
| 491 | 497 | code+1,color,flipx,flipy, |
| 492 | 498 | flipx ? sx : sx+16,flipy ? sy-16 : sy, |
| 493 | cliprect,TRANSPARENCY_ | |
| 499 | cliprect,TRANSPARENCY_PENS | |
| 494 | 500 | } |
| 495 | 501 | else /* normal */ |
| 496 | 502 | { |
| 497 | 503 | drawgfx(bitmap,machine->gfx[bank], |
| 498 | 504 | code,color,flipx,flipy,sx,sy, |
| 499 | cliprect,TRANSPARENCY_ | |
| 505 | cliprect,TRANSPARENCY_PENS | |
| 500 | 506 | } |
| 501 | 507 | } |
| 502 | 508 | } |
| r936 | r937 | |
|---|---|---|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | { |
| 98 | if( gfx | |
| 98 | if( gfx | |
| 99 | 99 | { |
| 100 | const pen_t *pal = & | |
| 100 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 101 | 101 | int source_base1 = (code1 % gfx->total_elements) * gfx->height; |
| 102 | 102 | int source_base2 = (code2 % gfx->total_elements) * gfx->height; |
| 103 | 103 |
| r936 | r937 | |
|---|---|---|
| 101 | 101 | decodegfx(machine->gfx[ttl_gfx_index], memory_region(REGION_GFX3), 0, machine->gfx[ttl_gfx_index]->total_elements); |
| 102 | 102 | |
| 103 | 103 | if (machine->drv->color_table_len) |
| 104 | { | |
| 105 | machine->gfx[ttl_gfx_index]->colortable = machine->remapped_colortable; | |
| 106 | 104 | machine->gfx[ttl_gfx_index]->total_colors = machine->drv->color_table_len / 16; |
| 107 | } | |
| 108 | 105 | else |
| 109 | { | |
| 110 | machine->gfx[ttl_gfx_index]->colortable = machine->pens; | |
| 111 | 106 | machine->gfx[ttl_gfx_index]->total_colors = machine->drv->total_colors / 16; |
| 112 | } | |
| 113 | 107 | |
| 114 | 108 | // create the tilemap |
| 115 | 109 | ttl_tilemap = tilemap_create(ttl_get_tile_info, tilemap_scan_rows, TILEMAP_TYPE_PEN, 8, 8, 64, 32); |
| r936 | r937 | |
|---|---|---|
| 11 | 11 | #include "driver.h" |
| 12 | 12 | #include "includes/docastle.h" |
| 13 | 13 | |
| 14 | static tilemap * | |
| 14 | static tilemap *docast | |
| 15 | 15 | |
| 16 | 16 | /*************************************************************************** |
| 17 | 17 | |
| r936 | r937 | |
| 30 | 30 | bit 0 -- 390 ohm resistor -- BLUE |
| 31 | 31 | |
| 32 | 32 | ***************************************************************************/ |
| 33 | static void convert_color_prom(running_machine *machine,UINT16 *colortable,const UINT8 *color_prom, | |
| 34 | int priority) | |
| 33 | PALETTE_INIT( docastle ) | |
| 35 | 34 | { |
| 36 | int i | |
| 35 | int i | |
| 37 | 36 | |
| 38 | ||
| 39 | 37 | for (i = 0;i < 256;i++) |
| 40 | 38 | { |
| 41 | 39 | int bit0,bit1,bit2,r,g,b; |
| 42 | 40 | |
| 43 | ||
| 44 | 41 | /* red component */ |
| 45 | 42 | bit0 = (*color_prom >> 5) & 0x01; |
| 46 | 43 | bit1 = (*color_prom >> 6) & 0x01; |
| r936 | r937 | |
| 57 | 54 | bit2 = (*color_prom >> 1) & 0x01; |
| 58 | 55 | b = 0x23 * bit0 + 0x4b * bit1 + 0x91 * bit2; |
| 59 | 56 | |
| 60 | palette_set_color(machine,i,MAKE_RGB(r,g,b)); | |
| 57 | /* because the graphics are decoded as 4bpp with the top bit used for transparency | |
| 58 | or priority, we create matching 3bpp sets of palette entries, which effectively | |
| 59 | ignores the value of the top bit */ | |
| 60 | palette_set_color(machine, ((i & 0xf8) << 1) | 0x00 | (i & 0x07), MAKE_RGB(r,g,b)); | |
| 61 | palette_set_color(machine, ((i & 0xf8) << 1) | 0x08 | (i & 0x07), MAKE_RGB(r,g,b)); | |
| 61 | 62 | color_prom++; |
| 62 | 63 | } |
| 63 | ||
| 64 | /* reserve one color for the transparent pen (none of the game colors can have */ | |
| 65 | /* these RGB components) */ | |
| 66 | palette_set_color(machine,256,MAKE_RGB(1,1,1)); | |
| 67 | /* and the last color for the sprite covering pen */ | |
| 68 | palette_set_color(machine,257,MAKE_RGB(2,2,2)); | |
| 69 | ||
| 70 | ||
| 71 | /* characters */ | |
| 72 | /* characters have 4 bitplanes, but they actually have only 8 colors. The fourth */ | |
| 73 | /* plane is used to select priority over sprites. The meaning of the high bit is */ | |
| 74 | /* reversed in Do's Castle wrt the other games. */ | |
| 75 | ||
| 76 | /* first create a table with all colors, used to draw the background */ | |
| 77 | for (i = 0;i < 32;i++) | |
| 78 | { | |
| 79 | for (j = 0;j < 8;j++) | |
| 80 | { | |
| 81 | colortable[16*i+j] = 8*i+j; | |
| 82 | colortable[16*i+j+8] = 8*i+j; | |
| 83 | } | |
| 84 | } | |
| 85 | /* now create a table with only the colors which have priority over sprites, used */ | |
| 86 | /* to draw the foreground. */ | |
| 87 | for (i = 0;i < 32;i++) | |
| 88 | { | |
| 89 | for (j = 0;j < 8;j++) | |
| 90 | { | |
| 91 | if (priority == 0) /* Do's Castle */ | |
| 92 | { | |
| 93 | colortable[32*16+16*i+j] = 256; /* high bit clear means less priority than sprites */ | |
| 94 | colortable[32*16+16*i+j+8] = 8*i+j; | |
| 95 | } | |
| 96 | else /* Do Wild Ride, Do Run Run, Kick Rider */ | |
| 97 | { | |
| 98 | colortable[32*16+16*i+j] = 8*i+j; | |
| 99 | colortable[32*16+16*i+j+8] = 256; /* high bit set means less priority than sprites */ | |
| 100 | } | |
| 101 | } | |
| 102 | } | |
| 103 | ||
| 104 | /* sprites */ | |
| 105 | /* sprites have 4 bitplanes, but they actually have only 8 colors. The fourth */ | |
| 106 | /* plane is used for transparency. */ | |
| 107 | for (i = 0;i < 32;i++) | |
| 108 | { | |
| 109 | /* build two versions of the colortable, one with the covering color | |
| 110 | mapped to transparent, and one with all colors but the covering one | |
| 111 | mapped to transparent. */ | |
| 112 | for (j = 0;j < 16;j++) | |
| 113 | { | |
| 114 | if (j < 8) | |
| 115 | colortable[64*16+16*i+j] = 256; /* high bit clear means transparent */ | |
| 116 | else if (j == 15) | |
| 117 | colortable[64*16+16*i+j] = 256; /* sprite covering color */ | |
| 118 | else | |
| 119 | colortable[64*16+16*i+j] = 8*i+(j&7); | |
| 120 | } | |
| 121 | for (j = 0;j < 16;j++) | |
| 122 | { | |
| 123 | if (j == 15) | |
| 124 | colortable[64*16+32*16+16*i+j] = 257; /* sprite covering color */ | |
| 125 | else | |
| 126 | colortable[64*16+32*16+16*i+j] = 256; | |
| 127 | } | |
| 128 | } | |
| 129 | 64 | } |
| 130 | 65 | |
| 131 | PALETTE_INIT( docastle ) | |
| 132 | { | |
| 133 | convert_color_prom(machine,colortable,color_prom,0); | |
| 134 | } | |
| 135 | ||
| 136 | PALETTE_INIT( dorunrun ) | |
| 137 | { | |
| 138 | convert_color_prom(machine,colortable,color_prom,1); | |
| 139 | } | |
| 140 | ||
| 141 | 66 | WRITE8_HANDLER( docastle_videoram_w ) |
| 142 | 67 | { |
| 143 | 68 | videoram[offset] = data; |
| 144 | tilemap_mark_tile_dirty(bg_tilemap, offset); | |
| 145 | tilemap_mark_tile_dirty(fg_tilemap, offset); | |
| 69 | tilemap_mark_tile_dirty(docastle_tilemap, offset); | |
| 146 | 70 | } |
| 147 | 71 | |
| 148 | 72 | WRITE8_HANDLER( docastle_colorram_w ) |
| 149 | 73 | { |
| 150 | 74 | colorram[offset] = data; |
| 151 | tilemap_mark_tile_dirty(bg_tilemap, offset); | |
| 152 | tilemap_mark_tile_dirty(fg_tilemap, offset); | |
| 75 | tilemap_mark_tile_dirty(docastle_tilemap, offset); | |
| 153 | 76 | } |
| 154 | 77 | |
| 155 | 78 | READ8_HANDLER( docastle_flipscreen_off_r ) |
| 156 | 79 | { |
| 157 | 80 | flip_screen_set(0); |
| 158 | tilemap_mark_all_tiles_dirty( | |
| 81 | tilemap_mark_all_tiles_dirty(docastle_tilemap | |
| 159 | 82 | return 0; |
| 160 | 83 | } |
| 161 | 84 | |
| 162 | 85 | READ8_HANDLER( docastle_flipscreen_on_r ) |
| 163 | 86 | { |
| 164 | 87 | flip_screen_set(1); |
| 165 | tilemap_mark_all_tiles_dirty( | |
| 88 | tilemap_mark_all_tiles_dirty(docastle_tilemap | |
| 166 | 89 | return 1; |
| 167 | 90 | } |
| 168 | 91 | |
| 169 | 92 | WRITE8_HANDLER( docastle_flipscreen_off_w ) |
| 170 | 93 | { |
| 171 | 94 | flip_screen_set(0); |
| 172 | tilemap_mark_all_tiles_dirty( | |
| 95 | tilemap_mark_all_tiles_dirty(docastle_tilemap | |
| 173 | 96 | } |
| 174 | 97 | |
| 175 | 98 | WRITE8_HANDLER( docastle_flipscreen_on_w ) |
| 176 | 99 | { |
| 177 | 100 | flip_screen_set(1); |
| 178 | tilemap_mark_all_tiles_dirty( | |
| 101 | tilemap_mark_all_tiles_dirty(docastle_tilemap | |
| 179 | 102 | } |
| 180 | 103 | |
| 181 | static TILE_GET_INFO( get_ | |
| 104 | static TILE_GET_INFO( get_ | |
| 182 | 105 | { |
| 183 | 106 | int code = videoram[tile_index] + 8 * (colorram[tile_index] & 0x20); |
| 184 | 107 | int color = colorram[tile_index] & 0x1f; |
| r936 | r937 | |
| 186 | 109 | SET_TILE_INFO(0, code, color, 0); |
| 187 | 110 | } |
| 188 | 111 | |
| 189 | static | |
| 112 | static void | |
| 190 | 113 | { |
| 191 | int code = videoram[tile_index] + 8 * (colorram[tile_index] & 0x20); | |
| 192 | int color = (colorram[tile_index] & 0x1f) + 32; | |
| 193 | ||
| 194 | SET_TILE_INFO(0, code, color, 0); | |
| 114 | docastle_tilemap = tilemap_create(get_tile_info, tilemap_scan_rows, TILEMAP_TYPE_PEN, 8, 8, 32, 32); | |
| 115 | tilemap_set_transmask(docastle_tilemap, 0, tile_transmask, 0x0000); | |
| 195 | 116 | } |
| 196 | 117 | |
| 197 | 118 | VIDEO_START( docastle ) |
| 198 | 119 | { |
| 199 | bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, | |
| 200 | TILEMAP_TYPE_PEN, 8, 8, 32, 32); | |
| 120 | video_start_common(machine, 0x00ff); | |
| 121 | } | |
| 201 | 122 | |
| 202 | fg_tilemap = tilemap_create(get_fg_tile_info, tilemap_scan_rows, | |
| 203 | TILEMAP_TYPE_COLORTABLE, 8, 8, 32, 32); | |
| 204 | ||
| 205 | tilemap_set_transparent_pen(fg_tilemap, 256); | |
| 123 | VIDEO_START( dorunrun ) | |
| 124 | { | |
| 125 | video_start_common(machine, 0xff00); | |
| 206 | 126 | } |
| 207 | 127 | |
| 208 | 128 | static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect) |
| r936 | r937 | |
| 282 | 202 | color, |
| 283 | 203 | flipx,flipy, |
| 284 | 204 | sx,sy, |
| 285 | cliprect,TRANSPARENCY_ | |
| 205 | cliprect,TRANSPARENCY_PENS | |
| 286 | 206 | 0x00); |
| 287 | 207 | |
| 288 | 208 | /* then draw the mask, behind the background but obscuring following sprites */ |
| 289 | 209 | pdrawgfx(bitmap,machine->gfx[1], |
| 290 | 210 | code, |
| 291 | color | |
| 211 | color | |
| 292 | 212 | flipx,flipy, |
| 293 | 213 | sx,sy, |
| 294 | cliprect,TRANSPARENCY_ | |
| 214 | cliprect,TRANSPARENCY_PENS | |
| 295 | 215 | 0x02); |
| 296 | 216 | } |
| 297 | 217 | } |
| 298 | 218 | |
| 299 | 219 | VIDEO_UPDATE( docastle ) |
| 300 | 220 | { |
| 301 | tilemap_draw(bitmap, cliprect, | |
| 221 | tilemap_draw(bitmap, cliprect, docastle_tilemap, TILEMAP_DRAW_OPAQUE, 0); | |
| 302 | 222 | draw_sprites(machine, bitmap, cliprect); |
| 303 | tilemap_draw(bitmap, cliprect, | |
| 223 | tilemap_draw(bitmap, cliprect, docastle_tilemap, TILEMAP_DRAW_LAYER0, 0); | |
| 304 | 224 | return 0; |
| 305 | 225 | } |
| r936 | r937 | |
|---|---|---|
| 370 | 370 | |
| 371 | 371 | VIDEO_UPDATE( arabian ) |
| 372 | 372 | { |
| 373 | pen_t *colortable = &machine->remapped_colortable[(arabian_video_control >> 3) << 8]; | |
| 373 | const pen_t *colortable = &machine->remapped_colortable[(arabian_video_control >> 3) << 8]; | |
| 374 | 374 | int y; |
| 375 | 375 | |
| 376 | 376 | /* render the screen from the bitmap */ |
| r936 | r937 | |
|---|---|---|
| 329 | 329 | UINT8 alpha = alpha_table[global_pen]; |
| 330 | 330 | if (alpha) |
| 331 | 331 | { |
| 332 | p[i] = alpha_blend16(p[i], | |
| 332 | p[i] = alpha_blend16(p[i], Machine->remapped_colortable[gfx->color_base + global_pen]); | |
| 333 | 333 | } |
| 334 | 334 | else |
| 335 | 335 | { |
| 336 | p[i] = | |
| 336 | p[i] = Machine->remapped_colortable[gfx->color_base + global_pen]; | |
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | dp_i += xd; |
| r936 | r937 | |
|---|---|---|
| 13 | 13 | UINT8 *gaplus_spriteram; |
| 14 | 14 | |
| 15 | 15 | static tilemap *bg_tilemap; |
| 16 | static colortable *gaplus_colortable; | |
| 16 | 17 | |
| 17 | 18 | |
| 18 | 19 | /*************************************************************************** |
| r936 | r937 | |
| 31 | 32 | PALETTE_INIT( gaplus ) |
| 32 | 33 | { |
| 33 | 34 | int i; |
| 34 | #define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity) | |
| 35 | #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs]) | |
| 36 | 35 | |
| 36 | /* allocate the colortable */ | |
| 37 | gaplus_colortable = colortable_alloc(machine, 256); | |
| 37 | 38 | |
| 38 | for (i = 0;i < | |
| 39 | for (i = 0;i < 256 | |
| 39 | 40 | { |
| 40 | 41 | int bit0,bit1,bit2,bit3,r,g,b; |
| 41 | 42 | |
| 42 | ||
| 43 | 43 | /* red component */ |
| 44 | 44 | bit0 = (color_prom[i] >> 0) & 0x01; |
| 45 | 45 | bit1 = (color_prom[i] >> 1) & 0x01; |
| r936 | r937 | |
| 59 | 59 | bit3 = (color_prom[i + 0x200] >> 3) & 0x01; |
| 60 | 60 | b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; |
| 61 | 61 | |
| 62 | palette_set_color( | |
| 62 | colortable_palette_set_color(gaplus_colortable,i,MAKE_RGB(r,g,b)); | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | color_prom += 0x300; |
| 66 | 66 | /* color_prom now points to the beginning of the lookup table */ |
| 67 | 67 | |
| 68 | ||
| 69 | 68 | /* characters use colors 0xf0-0xff */ |
| 70 | for (i = 0;i < TOTAL_COLORS(0);i++) | |
| 71 | COLOR(0,i) = 0xf0 + (*(color_prom++) & 0x0f); | |
| 69 | for (i = 0;i < machine->gfx[0]->total_colors * machine->gfx[0]->color_granularity;i++) | |
| 70 | colortable_entry_set_value(gaplus_colortable, machine->gfx[0]->color_base + i, 0xf0 + (*color_prom++ & 0x0f)); | |
| 72 | 71 | |
| 73 | 72 | /* sprites */ |
| 74 | for (i = 0;i < | |
| 73 | for (i = 0;i < machine->gfx[1]->total_colors * machine->gfx[1]->color_granularity;i++) | |
| 75 | 74 | { |
| 76 | | |
| 75 | colortable_entry_set_value(gaplus_colortable, machine->gfx[1]->color_base + i, (color_prom[0] & 0x0f) + ((color_prom[0x200] & 0x0f) << 4)); | |
| 77 | 76 | color_prom++; |
| 78 | 77 | } |
| 79 | 78 | } |
| r936 | r937 | |
| 105 | 104 | { |
| 106 | 105 | UINT8 attr = gaplus_videoram[tile_index + 0x400]; |
| 107 | 106 | tileinfo->category = (attr & 0x40) >> 6; |
| 107 | tileinfo->group = attr & 0x3f; | |
| 108 | 108 | SET_TILE_INFO( |
| 109 | 109 | 0, |
| 110 | 110 | gaplus_videoram[tile_index] + ((attr & 0x80) << 1), |
| r936 | r937 | |
| 196 | 196 | |
| 197 | 197 | VIDEO_START( gaplus ) |
| 198 | 198 | { |
| 199 | bg_tilemap = tilemap_create(get_tile_info,tilemap_scan,TILEMAP_TYPE_ | |
| 199 | bg_tilemap = tilemap_create(get_tile_info,tilemap_scan,TILEMAP_TYPE_P | |
| 200 | 200 | |
| 201 | tilemap_ | |
| 201 | colortable_configure_tilemap_g | |
| 202 | 202 | |
| 203 | 203 | spriteram = gaplus_spriteram + 0x780; |
| 204 | 204 | spriteram_2 = spriteram + 0x800; |
| r936 | r937 | |
| 310 | 310 | color, |
| 311 | 311 | flipx,flipy, |
| 312 | 312 | sx + 16*x,sy + 16*y, |
| 313 | cliprect,TRANSPARENCY_COLOR,0xff); | |
| 313 | cliprect,TRANSPARENCY_PENS, | |
| 314 | colortable_get_transpen_mask(gaplus_colortable, machine->gfx[1], color, 0xff)); | |
| 314 | 315 | } |
| 315 | 316 | } |
| 316 | 317 | } |
| r936 | r937 | |
|---|---|---|
| 254 | 254 | { |
| 255 | 255 | int sy,row,height,src,bank; |
| 256 | 256 | UINT8 *sprite_base; |
| 257 | pen_t *sprite_palette; | |
| 257 | const pen_t *sprite_palette; | |
| 258 | 258 | INT16 skip; /* bytes to skip before drawing each row (can be negative) */ |
| 259 | 259 | UINT8 *gfx; |
| 260 | 260 |
| r936 | r937 | |
|---|---|---|
| 2409 | 2409 | clip=&myclip; |
| 2410 | 2410 | } |
| 2411 | 2411 | |
| 2412 | if( gfx | |
| 2412 | if( gfx | |
| 2413 | 2413 | { |
| 2414 | const pen_t *pal = & | |
| 2414 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 2415 | 2415 | UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| 2416 | 2416 | |
| 2417 | 2417 | //int sprite_screen_height = (scaley*gfx->height+0x8000)>>16; |
| r936 | r937 | |
| 2485 | 2485 | /* case 0: TRANSPARENCY_NONE */ |
| 2486 | 2486 | if (transparency == TRANSPARENCY_NONE) |
| 2487 | 2487 | { |
| 2488 | if (gfx->flags & GFX_PACKED) | |
| 2488 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 2489 | 2489 | { |
| 2490 | 2490 | for( y=sy; y<ey; y++ ) |
| 2491 | 2491 | { |
| r936 | r937 | |
| 2524 | 2524 | /* case 1: TRANSPARENCY_PEN */ |
| 2525 | 2525 | if (transparency == TRANSPARENCY_PEN) |
| 2526 | 2526 | { |
| 2527 | if (gfx->flags & GFX_PACKED) | |
| 2527 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 2528 | 2528 | { |
| 2529 | 2529 | for( y=sy; y<ey; y++ ) |
| 2530 | 2530 | { |
| r936 | r937 | |
| 2585 | 2585 | /* case : STV_TRANSPARENCY_ADD_BLEND */ |
| 2586 | 2586 | if (transparency == STV_TRANSPARENCY_ADD_BLEND ) |
| 2587 | 2587 | { |
| 2588 | if (gfx->flags & GFX_PACKED) | |
| 2588 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 2589 | 2589 | { |
| 2590 | 2590 | for( y=sy; y<ey; y++ ) |
| 2591 | 2591 | { |
| r936 | r937 | |
|---|---|---|
| 155 | 155 | { |
| 156 | 156 | if (ypos >= (16 + BALSENTE_VBEND) && ypos >= cliprect->min_y && ypos <= cliprect->max_y) |
| 157 | 157 | { |
| 158 | | |
| 158 | const pen_t *pens = &machine->pens[palettebank_vis * 256]; | |
| 159 | 159 | UINT8 *old = &local_videoram[(ypos - BALSENTE_VBEND) * 256 + xpos]; |
| 160 | 160 | int currx = xpos; |
| 161 | 161 | |
| r936 | r937 | |
| 222 | 222 | |
| 223 | 223 | VIDEO_UPDATE( balsente ) |
| 224 | 224 | { |
| 225 | pen_t *pens = &machine->pens[palettebank_vis * 256]; | |
| 225 | const pen_t *pens = &machine->pens[palettebank_vis * 256]; | |
| 226 | 226 | int y, i; |
| 227 | 227 | |
| 228 | 228 | /* draw scanlines from the VRAM directly */ |
| r936 | r937 | |
|---|---|---|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | { |
| 490 | if( gfx | |
| 490 | if( gfx | |
| 491 | 491 | { |
| 492 | const pen_t *pal = & | |
| 492 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 493 | 493 | int source_base = (code % gfx->total_elements) * gfx->height; |
| 494 | 494 | |
| 495 | 495 | if (sprite_screen_width && sprite_screen_height) |
| r936 | r937 | |
| 1413 | 1413 | */ |
| 1414 | 1414 | static void mixDualAlphaSprites(running_machine* machine, mame_bitmap *bitmap, const rectangle *cliprect, const gfx_element *gfx0, const gfx_element *gfx1, int mixAlphaTilemap) |
| 1415 | 1415 | { |
| 1416 | const pen_t *pal0 = gfx0->colortable; | |
| 1417 | const pen_t *pal1 = gfx1->colortable; | |
| 1418 | const pen_t *pal2 = (deco32_pri&1) ? machine->gfx[1]->colortable : machine->gfx[2]->colortable; | |
| 1416 | const pen_t *pal0 = &machine->remapped_colortable[gfx0->color_base]; | |
| 1417 | const pen_t *pal1 = &machine->remapped_colortable[gfx1->color_base]; | |
| 1418 | const pen_t *pal2 = &machine->remapped_colortable[(deco32_pri&1) ? machine->gfx[1]->color_base : machine->gfx[2]->color_base]; | |
| 1419 | 1419 | int x,y; |
| 1420 | 1420 | |
| 1421 | 1421 | /* Mix sprites into main bitmap, based on priority & alpha */ |
| r936 | r937 | |
|---|---|---|
| 240 | 240 | if (sy > ey) return; |
| 241 | 241 | |
| 242 | 242 | { |
| 243 | pen_t *paldata = machine->pens; | |
| 243 | const pen_t *paldata = machine->pens; | |
| 244 | 244 | UINT32 *end; |
| 245 | 245 | |
| 246 | 246 | UINT16 *sd1 = src1->base; /* source data */ |
| r936 | r937 | |
|---|---|---|
| 238 | 238 | |
| 239 | 239 | gfx0 = allocgfx( &cg_layout ); |
| 240 | 240 | gfx1 = allocgfx( &shape_layout ); |
| 241 | gfx0->colortable = machine->remapped_colortable; | |
| 242 | 241 | gfx0->total_colors = machine->drv->total_colors/256; |
| 243 | 242 | machine->gfx[0] = gfx0; |
| 244 | 243 | |
| 245 | gfx1->colortable = machine->remapped_colortable; | |
| 246 | 244 | gfx1->total_colors = machine->drv->total_colors/2; |
| 247 | 245 | machine->gfx[1] = gfx1; |
| 248 | 246 | } /* namcona1_vh_start */ |
| r936 | r937 | |
| 279 | 277 | mask = machine->gfx[1]; |
| 280 | 278 | code %= gfx->total_elements; |
| 281 | 279 | color %= gfx->total_colors; |
| 282 | paldata = & | |
| 280 | paldata = &machine->remapped_colortable[gfx->color_base + gfx->color_granularity * color]; | |
| 283 | 281 | gfx_addr = gfx->gfxdata + code * gfx->char_modulo; |
| 284 | 282 | gfx_pitch = gfx->line_modulo; |
| 285 | 283 | mask_addr = mask->gfxdata + code * mask->char_modulo; |
| r936 | r937 | |
| 403 | 401 | gfx = machine->gfx[0]; |
| 404 | 402 | code %= gfx->total_elements; |
| 405 | 403 | color %= gfx->total_colors; |
| 406 | paldata = & | |
| 404 | paldata = &machine->remapped_colortable[gfx->color_base + gfx->color_granularity * color]; | |
| 407 | 405 | gfx_addr = gfx->gfxdata + code * gfx->char_modulo; |
| 408 | 406 | gfx_pitch = gfx->line_modulo; |
| 409 | 407 | |
| r936 | r937 | |
| 558 | 556 | gfx_element *pGfx; |
| 559 | 557 | |
| 560 | 558 | pGfx = machine->gfx[0]; |
| 561 | paldata = & | |
| 559 | paldata = &machine->remapped_colortable[pGfx->color_base + pGfx->color_granularity * tilemap_palette_bank[which]]; | |
| 562 | 560 | |
| 563 | 561 | /* draw one scanline at a time */ |
| 564 | 562 | clip.min_x = cliprect->min_x; |
| r936 | r937 | |
|---|---|---|
| 236 | 236 | palette_set_color_rgb(machine,i,r,g,b); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | palette_normalize_range(machine, 0, 255, 0, 255); | |
| 239 | palette_normalize_range(machine->palette, 0, 255, 0, 255); | |
| 240 | 240 | |
| 241 | 241 | color_prom += 512; |
| 242 | 242 | /* color_prom now points to the beginning of the character color codes */ |
| r936 | r937 | |
| 299 | 299 | |
| 300 | 300 | palette_set_color_rgb(machine,RADARSCP_GRID_COL_OFFSET + i,r,g,b); |
| 301 | 301 | } |
| 302 | palette_normalize_range(machine, 0, RADARSCP_GRID_COL_OFFSET+7, 0, 255); | |
| 302 | palette_normalize_range(machine->palette, 0, RADARSCP_GRID_COL_OFFSET+7, 0, 255); | |
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | |
| r936 | r937 | |
| 364 | 364 | |
| 365 | 365 | palette_set_color_rgb(machine,RADARSCP_GRID_COL_OFFSET + i,r,g,b); |
| 366 | 366 | } |
| 367 | palette_normalize_range(machine, 0, RADARSCP_GRID_COL_OFFSET+7, 0, 255); | |
| 367 | palette_normalize_range(machine->palette, 0, RADARSCP_GRID_COL_OFFSET+7, 0, 255); | |
| 368 | 368 | |
| 369 | 369 | color_prom += 512; |
| 370 | 370 | /* color_prom now points to the beginning of the character color codes */ |
| r936 | r937 | |
| 414 | 414 | |
| 415 | 415 | rgb = compute_res_net_all(color_prom, &dkong3_decode_info, &dkong3_net_info); |
| 416 | 416 | palette_set_colors(machine, 0, rgb, 256); |
| 417 | palette_normalize_range(machine, 0, 255, 0, 255); | |
| 417 | palette_normalize_range(machine->palette, 0, 255, 0, 255); | |
| 418 | 418 | free(rgb); |
| 419 | 419 | |
| 420 | 420 | color_prom += 1024; |
| r936 | r937 | |
|---|---|---|
| 94 | 94 | |
| 95 | 95 | VIDEO_EOF( sprint4 ) |
| 96 | 96 | { |
| 97 | UINT16 BG = machine->gfx[0]->color | |
| 97 | UINT16 BG = machine->remapped_colortable[machine->gfx[0]->color_ | |
| 98 | 98 | |
| 99 | 99 | int i; |
| 100 | 100 |
| r936 | r937 | |
|---|---|---|
| 395 | 395 | UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, |
| 396 | 396 | const rectangle *clip,int priority) |
| 397 | 397 | { |
| 398 | const pen_t *pal = & | |
| 398 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 399 | 399 | UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| 400 | 400 | |
| 401 | 401 | int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16; |
| r936 | r937 | |
|---|---|---|
| 59 | 59 | |
| 60 | 60 | WRITE8_HANDLER( pacgal_lookup_w ) |
| 61 | 61 | { |
| 62 | Machine->game_colortable[offset] = data & 0x0f; | |
| 63 | Machine->remapped_colortable[offset] = Machine->pens[data & 0x0f]; | |
| 62 | /* palette hacks! */ | |
| 63 | ((UINT16 *)Machine->game_colortable)[offset] = data & 0x0f; | |
| 64 | ((pen_t *)Machine->remapped_colortable)[offset] = Machine->pens[data & 0x0f]; | |
| 64 | 65 | } |
| 65 | 66 | |
| 66 | 67 | WRITE8_HANDLER( pacgal_active_game_w ) |
| r936 | r937 | |
|---|---|---|
| 35 | 35 | if (sy > ey) return; |
| 36 | 36 | |
| 37 | 37 | { |
| 38 | pen_t *paldata = machine->pens; | |
| 38 | const pen_t *paldata = machine->pens; | |
| 39 | 39 | UINT32 *end; |
| 40 | 40 | |
| 41 | 41 | UINT16 *sd1 = src1->base; /* source data */ |
| r936 | r937 | |
|---|---|---|
| 208 | 208 | int shadow, |
| 209 | 209 | int shadow_pen, int eos ) |
| 210 | 210 | { |
| 211 | const pen_t *shadow_base = machine->gfx[0]->color | |
| 211 | const pen_t *shadow_base = machine->remapped_colortable + machine->gfx[0]->color_ | |
| 212 | 212 | const UINT8 *source; |
| 213 | 213 | int full_shadow=shadow&SYS16_SPR_SHADOW; |
| 214 | 214 | int partial_shadow=shadow&SYS16_SPR_PARTIAL_SHADOW; |
| r936 | r937 | |
| 339 | 339 | |
| 340 | 340 | static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int b3d ) //* |
| 341 | 341 | { |
| 342 | const pen_t *base_pal = machine->gfx[0]->color | |
| 342 | const pen_t *base_pal = machine->remapped_colortable + machine->gfx[0]->color_ | |
| 343 | 343 | const UINT8 *base_gfx = memory_region(REGION_GFX2); |
| 344 | 344 | const int gfx_rom_size = memory_region_length(REGION_GFX2); |
| 345 | 345 | const UINT16 *source = sys16_spriteram; |
| r936 | r937 | |
|---|---|---|
| 239 | 239 | mo->gfxelement[idx] = *machine->gfx[idx]; |
| 240 | 240 | mo->gfxgranularity[idx] = mo->gfxelement[idx].color_granularity; |
| 241 | 241 | mo->gfxelement[idx].color_granularity = 1; |
| 242 | mo->gfxelement[idx].color | |
| 242 | mo->gfxelement[idx].color_ | |
| 243 | 243 | mo->gfxelement[idx].total_colors = 65536; |
| 244 | 244 | } |
| 245 | 245 |
| r936 | r937 | |
|---|---|---|
| 15 | 15 | |
| 16 | 16 | static UINT16 road16_vscroll; |
| 17 | 17 | |
| 18 | static colortable *polepos_colortable; | |
| 18 | 19 | static tilemap *bg_tilemap,*tx_tilemap; |
| 19 | 20 | static int polepos_chacl; |
| 20 | 21 | |
| r936 | r937 | |
| 39 | 40 | { |
| 40 | 41 | int i, j; |
| 41 | 42 | |
| 43 | /* allocate the colortable */ | |
| 44 | polepos_colortable = colortable_alloc(machine, 128); | |
| 45 | ||
| 42 | 46 | /******************************************************* |
| 43 | 47 | * Color PROMs |
| 44 | 48 | * Sheet 15B: middle, 136014-137,138,139 |
| r936 | r937 | |
| 83 | 87 | bit3 = (color_prom[0x200 + i] >> 3) & 1; |
| 84 | 88 | b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; |
| 85 | 89 | |
| 86 | palette_set_color( | |
| 90 | colortable_palette_set_color(polepos_colortable,i,MAKE_RGB(r,g,b)); | |
| 87 | 91 | } |
| 88 | 92 | |
| 89 | 93 | /******************************************************* |
| r936 | r937 | |
| 94 | 98 | for (i = 0; i < 64*4; i++) |
| 95 | 99 | { |
| 96 | 100 | int color = color_prom[0x300 + i]; |
| 97 | colortable[0x0000 + i] = (color != 15) ? (0x020 + color) : 0x2f; | |
| 98 | colortable[0x0100 + i] = (color != 15) ? (0x060 + color) : 0x2f; | |
| 101 | colortable_entry_set_value(polepos_colortable, 0x0000 + i, (color != 15) ? (0x020 + color) : 0x2f); | |
| 102 | colortable_entry_set_value(polepos_colortable, 0x0100 + i, (color != 15) ? (0x060 + color) : 0x2f); | |
| 99 | 103 | } |
| 100 | 104 | |
| 101 | 105 | /******************************************************* |
| r936 | r937 | |
| 107 | 111 | for (i = 0; i < 64*4; i++) |
| 108 | 112 | { |
| 109 | 113 | int color = color_prom[0x400 + i]; |
| 110 | colortable | |
| 114 | colortable_entry_set_value(polepos_colortable, 0x0200 + i, | |
| 111 | 115 | } |
| 112 | 116 | |
| 113 | 117 | /******************************************************* |
| r936 | r937 | |
| 118 | 122 | for (i = 0; i < 64*16; i++) |
| 119 | 123 | { |
| 120 | 124 | int color = color_prom[0xc00 + i]; |
| 121 | colortable[0x0300 + i] = (color != 15) ? (0x010 + color) : 0x1f; | |
| 122 | colortable[0x0700 + i] = (color != 15) ? (0x050 + color) : 0x1f; | |
| 125 | colortable_entry_set_value(polepos_colortable, 0x0300 + i, (color != 15) ? (0x010 + color) : 0x1f); | |
| 126 | colortable_entry_set_value(polepos_colortable, 0x0700 + i, (color != 15) ? (0x050 + color) : 0x1f); | |
| 123 | 127 | } |
| 124 | 128 | |
| 125 | 129 | /******************************************************* |
| r936 | r937 | |
| 131 | 135 | for (i = 0; i < 64*16; i++) |
| 132 | 136 | { |
| 133 | 137 | int color = color_prom[0x800 + i]; |
| 134 | colortable | |
| 138 | colortable_entry_set_value(polepos_colortable, 0x0b00 + i, | |
| 135 | 139 | } |
| 136 | 140 | |
| 137 | 141 | /* 136014-142, 136014-143, 136014-144 Vertical position modifiers */ |
| r936 | r937 | |
| 185 | 189 | code, |
| 186 | 190 | color, |
| 187 | 191 | 0); |
| 192 | tileinfo->group = color; | |
| 188 | 193 | } |
| 189 | 194 | |
| 190 | 195 | |
| r936 | r937 | |
| 198 | 203 | VIDEO_START( polepos ) |
| 199 | 204 | { |
| 200 | 205 | bg_tilemap = tilemap_create(bg_get_tile_info,tilemap_scan_cols,TILEMAP_TYPE_PEN,8,8,64,16); |
| 201 | tx_tilemap = tilemap_create(tx_get_tile_info,tilemap_scan_rows,TILEMAP_TYPE_ | |
| 206 | tx_tilemap = tilemap_create(tx_get_tile_info,tilemap_scan_rows,TILEMAP_TYPE_P | |
| 202 | 207 | |
| 203 | tilemap_se | |
| 208 | colortable_configure_tilemap_groups(polepos_colortabl | |
| 204 | 209 | } |
| 205 | 210 | |
| 206 | 211 | |
| r936 | r937 | |
| 354 | 359 | const UINT8 *road_bits2 = memory_region(REGION_GFX5) + 0x4000; |
| 355 | 360 | int x, y, i; |
| 356 | 361 | |
| 357 | ||
| 358 | 362 | /* loop over the lower half of the screen */ |
| 359 | 363 | for (y = 128; y < 256; y++) |
| 360 | 364 | { |
| 361 | 365 | int xoffs, yoffs, xscroll, roadpal; |
| 362 | 366 | UINT8 scanline[256 + 8]; |
| 363 | 367 | UINT8 *dest = scanline; |
| 364 | pen_t *colortable; | |
| 368 | const pen_t *colortable; | |
| 365 | 369 | |
| 366 | 370 | /* first add the vertical position modifier and the vertical scroll */ |
| 367 | 371 | yoffs = ((polepos_vertical_position_modifier[y] + road16_vscroll) >> 3) & 0x1ff; |
| r936 | r937 | |
| 370 | 374 | roadpal = polepos_road16_memory[yoffs] & 15; |
| 371 | 375 | |
| 372 | 376 | /* this becomes the palette base for the scanline */ |
| 373 | colortable = &machine-> | |
| 377 | colortable = &machine-> | |
| 374 | 378 | |
| 375 | 379 | /* now fetch the horizontal scroll offset for this scanline */ |
| 376 | 380 | xoffs = polepos_road16_memory[0x380 + (y & 0x7f)] & 0x3ff; |
| r936 | r937 | |
| 430 | 434 | const gfx_element *gfx = machine->gfx[big ? 3 : 2]; |
| 431 | 435 | UINT8 *gfxdata = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| 432 | 436 | UINT8 *scaling_rom = memory_region(REGION_GFX6); |
| 433 | pen_t *colortable = gfx->colortable + color * gfx->color_granularity; | |
| 437 | UINT32 transmask = colortable_get_transpen_mask(polepos_colortable, gfx, color, 0x1f); | |
| 438 | int coloroffs = gfx->color_base + color * gfx->color_granularity; | |
| 434 | 439 | int x,y; |
| 435 | 440 | |
| 436 | 441 | if (flipx) flipx = big ? 0x1f : 0x0f; |
| r936 | r937 | |
| 455 | 460 | { |
| 456 | 461 | if (xx < 0x100) |
| 457 | 462 | { |
| 458 | int pen = | |
| 463 | int pen = | |
| 459 | 464 | |
| 460 | if (pen != 0x1f) | |
| 461 | *BITMAP_ADDR16(bitmap, yy, xx) = pen; | |
| 465 | if (!((transmask >> pen) & 1)) | |
| 466 | *BITMAP_ADDR16(bitmap, yy, xx) = pen + coloroffs; | |
| 462 | 467 | } |
| 463 | 468 | offs++; |
| 464 | 469 |
| r936 | r937 | |
|---|---|---|
| 1572 | 1572 | machine->gfx[gfx_index] = allocgfx(&TC0080VCO_charlayout); |
| 1573 | 1573 | |
| 1574 | 1574 | /* set the color information */ |
| 1575 | machine->gfx[gfx_index]->colortable = machine->remapped_colortable; | |
| 1576 | 1575 | machine->gfx[gfx_index]->total_colors = 64; // is this correct ? |
| 1577 | 1576 | TC0080VCO_tx_gfx = gfx_index; |
| 1578 | 1577 | |
| r936 | r937 | |
| 2337 | 2336 | machine->gfx[gfx_index] = allocgfx(&TC0100SCN_charlayout); |
| 2338 | 2337 | |
| 2339 | 2338 | /* set the color information */ |
| 2340 | machine->gfx[gfx_index]->colortable = machine->remapped_colortable; | |
| 2341 | 2339 | machine->gfx[gfx_index]->total_colors = 64; |
| 2342 | 2340 | |
| 2343 | 2341 | TC0100SCN_tx_gfx[i] = gfx_index; |
| r936 | r937 | |
| 3204 | 3202 | machine->gfx[gfx_index] = allocgfx(&TC0480SCP_charlayout); |
| 3205 | 3203 | |
| 3206 | 3204 | /* set the color information */ |
| 3207 | machine->gfx[gfx_index]->colortable = machine->remapped_colortable; | |
| 3208 | 3205 | machine->gfx[gfx_index]->total_colors = 64; |
| 3209 | 3206 | |
| 3210 | 3207 | TC0480SCP_tx_gfx = gfx_index; |
| r936 | r937 | |
|---|---|---|
| 365 | 365 | |
| 366 | 366 | fillbitmap(priority_bitmap, 0, cliprect); |
| 367 | 367 | |
| 368 | fillbitmap(bitmap,machine->gfx[0]->color | |
| 368 | fillbitmap(bitmap,machine->remapped_colortable[machine->gfx[0]->color_ | |
| 369 | 369 | |
| 370 | 370 | for (layer = 0;layer < 8;layer++) |
| 371 | 371 | { |
| r936 | r937 | |
|---|---|---|
| 148 | 148 | |
| 149 | 149 | static void bbusters_draw_block(running_machine *machine, mame_bitmap *dest,int x,int y,int size,int flipx,int flipy,UINT32 sprite,int color,int bank,int block) |
| 150 | 150 | { |
| 151 | const pen_t *pal = &machine->gfx[bank]->color | |
| 151 | const pen_t *pal = &machine->remapped_colortable[machine->gfx[bank]->color_ | |
| 152 | 152 | UINT32 xinc=(scale_line_count * 0x10000 ) / size; |
| 153 | 153 | UINT8 pixel; |
| 154 | 154 | int x_index; |
| r936 | r937 | |
|---|---|---|
| 471 | 471 | gfx.width = width; |
| 472 | 472 | gfx.height = height; |
| 473 | 473 | gfx.total_elements = 1; |
| 474 | gfx.color_depth = 256; | |
| 474 | 475 | gfx.color_granularity = 256; |
| 475 | gfx.color | |
| 476 | gfx.color_ | |
| 476 | 477 | gfx.total_colors = 0x20; |
| 477 | 478 | gfx.pen_usage = NULL; |
| 478 | 479 | gfx.gfxdata = gfxdata; |
| r936 | r937 | |
| 500 | 501 | gfx.width = width; |
| 501 | 502 | gfx.height = height; |
| 502 | 503 | gfx.total_elements = 1; |
| 504 | gfx.color_depth = 16; | |
| 503 | 505 | gfx.color_granularity = 16; |
| 504 | gfx.color | |
| 506 | gfx.color_ | |
| 505 | 507 | gfx.total_colors = 0x200; |
| 506 | 508 | gfx.pen_usage = NULL; |
| 507 | 509 | gfx.gfxdata = gfxdata; |
| 508 | 510 | gfx.line_modulo = width/2; |
| 509 | 511 | gfx.char_modulo = 0; /* doesn't matter */ |
| 510 | gfx.flags = GFX_PACKED; | |
| 512 | gfx.flags = GFX_ELEMENT_PACKED; | |
| 511 | 513 | |
| 512 | 514 | /* Bounds checking */ |
| 513 | 515 | if ( (gfxdata + width/2 * height - 1) >= gfx_max ) |
| r936 | r937 | |
|---|---|---|
| 166 | 166 | machine->gfx[sys24_char_gfx_index] = allocgfx(&sys24_char_layout); |
| 167 | 167 | |
| 168 | 168 | if (machine->drv->color_table_len) |
| 169 | { | |
| 170 | machine->gfx[sys24_char_gfx_index]->colortable = machine->remapped_colortable; | |
| 171 | 169 | machine->gfx[sys24_char_gfx_index]->total_colors = machine->drv->color_table_len / 16; |
| 172 | } | |
| 173 | 170 | else |
| 174 | { | |
| 175 | machine->gfx[sys24_char_gfx_index]->colortable = machine->pens; | |
| 176 | 171 | machine->gfx[sys24_char_gfx_index]->total_colors = machine->drv->total_colors / 16; |
| 177 | } | |
| 178 | 172 | |
| 179 | 173 | state_save_register_global_pointer(sys24_tile_ram, 0x10000/2); |
| 180 | 174 | state_save_register_global_pointer(sys24_char_ram, 0x80000/2); |
| r936 | r937 | |
| 340 | 334 | const UINT16 *source = ((UINT16 *)bm->base) + sx + sy*bm->rowpixels; |
| 341 | 335 | const UINT8 *trans = ((UINT8 *) tm->base) + sx + sy*tm->rowpixels; |
| 342 | 336 | UINT16 *dest = dm->base; |
| 343 | pen_t | |
| 337 | const pen_t | |
| 344 | 338 | |
| 345 | 339 | tpri |= TILEMAP_PIXEL_LAYER0; |
| 346 | 340 |
| r936 | r937 | |
|---|---|---|
| 945 | 945 | UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, |
| 946 | 946 | const rectangle *clip,int priority) |
| 947 | 947 | { |
| 948 | const pen_t *pal = & | |
| 948 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 949 | 949 | UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| 950 | 950 | |
| 951 | 951 | int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16; |
| r936 | r937 | |
|---|---|---|
| 205 | 205 | |
| 206 | 206 | /* set the color information */ |
| 207 | 207 | if (machine->drv->color_table_len) |
| 208 | { | |
| 209 | machine->gfx[taitojc_gfx_index]->colortable = machine->remapped_colortable; | |
| 210 | 208 | machine->gfx[taitojc_gfx_index]->total_colors = machine->drv->color_table_len / 16; |
| 211 | } | |
| 212 | 209 | else |
| 213 | { | |
| 214 | machine->gfx[taitojc_gfx_index]->colortable = machine->pens; | |
| 215 | 210 | machine->gfx[taitojc_gfx_index]->total_colors = machine->drv->total_colors / 16; |
| 216 | } | |
| 217 | 211 | |
| 218 | 212 | taitojc_texture = auto_malloc(0x400000); |
| 219 | 213 |
| r936 | r937 | |
|---|---|---|
| 12 | 12 | |
| 13 | 13 | UINT32 st0016_game; |
| 14 | 14 | |
| 15 | ||
| 16 | 15 | static INT32 st0016_spr_bank,st0016_spr2_bank,st0016_pal_bank,st0016_char_bank; |
| 17 | 16 | static int spr_dx,spr_dy; |
| 18 | 17 | |
| 19 | ||
| 20 | 18 | static UINT8 st0016_vregs[0xc0]; |
| 21 | 19 | static int st0016_ramgfx; |
| 22 | 20 | |
| 21 | //super eagle shot | |
| 22 | static mame_bitmap *speglsht_bitmap; | |
| 23 | extern UINT32 *speglsht_framebuffer; | |
| 24 | extern UINT32 speglsht_videoreg; | |
| 23 | 25 | |
| 24 | ||
| 25 | ||
| 26 | 26 | static const gfx_layout charlayout = |
| 27 | 27 | { |
| 28 | 28 | 8,8, |
| r936 | r937 | |
| 203 | 203 | else |
| 204 | 204 | { |
| 205 | 205 | /* samples ? sound dma ? */ |
| 206 | // speaglsht: unknown DMA copy : src - 2B6740, dst - 4400, len - 1E400 | |
| 206 | 207 | logerror("unknown DMA copy : src - %X, dst - %X, len - %X, PC - %X\n",srcadr,dstadr,length,activecpu_get_previouspc()); |
| 207 | 208 | break; |
| 208 | 209 | } |
| r936 | r937 | |
| 443 | 444 | VIDEO_START( st0016 ) |
| 444 | 445 | { |
| 445 | 446 | int gfx_index=0; |
| 446 | ||
| 447 | 447 | st0016_charram=auto_malloc(ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE); |
| 448 | 448 | st0016_spriteram=auto_malloc(ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE); |
| 449 | 449 | st0016_paletteram=auto_malloc(ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE); |
| r936 | r937 | |
| 459 | 459 | machine->gfx[gfx_index] = allocgfx(&charlayout); |
| 460 | 460 | |
| 461 | 461 | /* set the color information */ |
| 462 | machine->gfx[gfx_index]->color | |
| 462 | machine->gfx[gfx_index]->color_ | |
| 463 | 463 | machine->gfx[gfx_index]->total_colors = 0x40; |
| 464 | 464 | st0016_ramgfx = gfx_index; |
| 465 | 465 | |
| 466 | spr_dx=0; | |
| 467 | spr_dy=0; | |
| 468 | ||
| 466 | 469 | switch(st0016_game&0x3f) |
| 467 | 470 | { |
| 468 | 471 | case 0: //renju kizoku |
| r936 | r937 | |
| 477 | 480 | spr_dy=8; |
| 478 | 481 | break; |
| 479 | 482 | |
| 483 | case 3: //super eagle shot | |
| 484 | speglsht_bitmap = auto_bitmap_alloc( 512, 5122, BITMAP_FORMAT_INDEXED16 ); | |
| 485 | break; | |
| 486 | ||
| 480 | 487 | case 4: //mayjinsen 1&2 |
| 481 | 488 | video_screen_set_visarea(0, 0,32*8-1,0,28*8-1); |
| 482 | 489 | break; |
| r936 | r937 | |
| 489 | 496 | video_screen_set_visarea(0, 0,383,0,383); |
| 490 | 497 | break; |
| 491 | 498 | |
| 492 | ||
| 493 | default: | |
| 494 | spr_dx=0; | |
| 495 | spr_dy=0; | |
| 496 | 499 | } |
| 497 | 500 | |
| 498 | 501 | st0016_save_init(); |
| r936 | r937 | |
| 596 | 599 | } |
| 597 | 600 | |
| 598 | 601 | |
| 602 | #define PLOT_PIXEL_RGB(x,y,r,g,b) if(y>=0 && x>=0 && x<512 && y<512) \ | |
| 603 | { \ | |
| 604 | *BITMAP_ADDR32(bitmap, y, x) = (b) | ((g)<<8) | ((r)<<16); \ | |
| 605 | } | |
| 606 | ||
| 599 | 607 | VIDEO_UPDATE( st0016 ) |
| 600 | 608 | { |
| 609 | ||
| 601 | 610 | #ifdef MAME_DEBUG |
| 602 | 611 | if(input_code_pressed_once(KEYCODE_Z)) |
| 603 | 612 | { |
| r936 | r937 | |
| 620 | 629 | } |
| 621 | 630 | #endif |
| 622 | 631 | |
| 623 | if( | |
| 632 | if((st00 | |
| 624 | 633 | { |
| 625 | if(!(readinputportbytag("SYS1")&1)) //fake coins - MACS2 system | |
| 634 | //super eagle shot | |
| 635 | int x,y,dy; | |
| 636 | ||
| 637 | fillbitmap(speglsht_bitmap,machine->pens[0],&machine->screen[0].visarea); | |
| 638 | dy=(speglsht_videoreg&0x20)?(256*512):0; //visible frame | |
| 639 | ||
| 640 | for(y=0;y<256;y++) | |
| 626 | 641 | { |
| 627 | macs_ram2[0]++; | |
| 642 | for(x=0;x<512;x++) | |
| 643 | { | |
| 644 | int tmp=dy+y*512+x; | |
| 645 | PLOT_PIXEL_RGB(x-67,y-5,(speglsht_framebuffer[tmp]>>0)&0xff,(speglsht_framebuffer[tmp]>>8)&0xff,(speglsht_framebuffer[tmp]>>16)&0xff); | |
| 646 | } | |
| 628 | 647 | } |
| 648 | ||
| 649 | //draw st0016 gfx to temporary bitmap (indexed 16) | |
| 650 | draw_bgmap(machine, speglsht_bitmap,cliprect,0); | |
| 651 | draw_sprites(machine, speglsht_bitmap,cliprect); | |
| 652 | draw_bgmap(machine, speglsht_bitmap,cliprect,1); | |
| 653 | ||
| 654 | //copy temporary bitmap to rgb 32 bit bitmap | |
| 655 | for(y=cliprect->min_y; y<cliprect->max_y;y++) | |
| 656 | { | |
| 657 | UINT16 *srcline = BITMAP_ADDR16(speglsht_bitmap, y, 0); | |
| 658 | for(x=cliprect->min_x; x<cliprect->max_x;x++) | |
| 659 | { | |
| 660 | if(srcline[x]) | |
| 661 | { | |
| 662 | rgb_t color=palette_get_color(Machine, srcline[x]); | |
| 663 | PLOT_PIXEL_RGB(x,y,RGB_RED(color),RGB_GREEN(color),RGB_BLUE(color)); | |
| 664 | } | |
| 665 | } | |
| 666 | } | |
| 629 | 667 | } |
| 668 | else | |
| 669 | { | |
| 670 | if(ISMACS1) | |
| 671 | { | |
| 672 | if(!(readinputportbytag("SYS1")&1)) //fake coins - MACS2 system | |
| 673 | { | |
| 674 | macs_ram2[0]++; | |
| 675 | } | |
| 676 | } | |
| 630 | 677 | |
| 631 | fillbitmap(bitmap,machine->pens[UNUSED_PEN],&machine->screen[0].visarea); | |
| 632 | draw_bgmap(machine, bitmap,cliprect,0); | |
| 633 | draw_sprites(machine, bitmap,cliprect); | |
| 634 | draw_bgmap(machine, bitmap,cliprect,1); | |
| 678 | fillbitmap(bitmap,machine->pens[UNUSED_PEN],&machine->screen[0].visarea); | |
| 679 | draw_bgmap(machine, bitmap,cliprect,0); | |
| 680 | draw_sprites(machine, bitmap,cliprect); | |
| 681 | draw_bgmap(machine, bitmap,cliprect,1); | |
| 682 | } | |
| 635 | 683 | return 0; |
| 636 | 684 | } |
| 637 | 685 |
| r936 | r937 | |
|---|---|---|
| 311 | 311 | #endif |
| 312 | 312 | |
| 313 | 313 | /* return the pens we are going to use to update the display */ |
| 314 | return &machine->pens[qix_palettebank * 256]; | |
| 314 | return (void *)&machine->pens[qix_palettebank * 256]; | |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 |
| r936 | r937 | |
|---|---|---|
| 1782 | 1782 | r = ((col & 0x1f) * fade) >> 4; |
| 1783 | 1783 | g = (((col & 0x3e0) >> 5) * fade) >> 4; |
| 1784 | 1784 | b = (((col & 0x7c00) >> 10) * fade) >> 4; |
| 1785 | machine->remapped_colortable[ii] = ((r & 0x1f) | ((g & 0x1f) << 5) | ((b & 0x1f) << 10)); | |
| 1785 | /* palette hacks! */ | |
| 1786 | ((pen_t *)machine->remapped_colortable)[ii] = ((r & 0x1f) | ((g & 0x1f) << 5) | ((b & 0x1f) << 10)); | |
| 1786 | 1787 | } |
| 1787 | 1788 | } |
| 1788 | 1789 |
| r936 | r937 | |
|---|---|---|
| 15 | 15 | static int priority; |
| 16 | 16 | |
| 17 | 17 | static tilemap *bg_tilemap, *fg_tilemap; |
| 18 | static colortable *bankp_colortable; | |
| 18 | 19 | |
| 20 | ||
| 19 | 21 | /*************************************************************************** |
| 20 | 22 | |
| 21 | 23 | Convert the color PROMs into a more useable format. |
| r936 | r937 | |
| 44 | 46 | #define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity) |
| 45 | 47 | #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs]) |
| 46 | 48 | |
| 49 | /* allocate the colortable */ | |
| 50 | bankp_colortable = colortable_alloc(machine, 32); | |
| 47 | 51 | |
| 48 | for (i = 0;i < | |
| 52 | for (i = 0;i < 32 | |
| 49 | 53 | { |
| 50 | 54 | int bit0,bit1,bit2,r,g,b; |
| 51 | 55 | |
| 52 | ||
| 53 | 56 | /* red component */ |
| 54 | 57 | bit0 = (*color_prom >> 0) & 0x01; |
| 55 | 58 | bit1 = (*color_prom >> 1) & 0x01; |
| r936 | r937 | |
| 66 | 69 | bit2 = (*color_prom >> 7) & 0x01; |
| 67 | 70 | b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 68 | 71 | |
| 69 | palette_set_color( | |
| 72 | colortable_palette_set_color(ba | |
| 70 | 73 | |
| 71 | 74 | color_prom++; |
| 72 | 75 | } |
| r936 | r937 | |
| 74 | 77 | /* color_prom now points to the beginning of the lookup table */ |
| 75 | 78 | |
| 76 | 79 | /* charset #1 lookup table */ |
| 77 | for (i = 0;i < TOTAL_COLORS(0);i++) | |
| 78 | COLOR(0,i) = *(color_prom++) & 0x0f; | |
| 80 | for (i = 0;i < machine->gfx[0]->total_colors * machine->gfx[0]->color_granularity;i++) | |
| 81 | colortable_entry_set_value(bankp_colortable, machine->gfx[0]->color_base + i, *color_prom++ & 0x0f); | |
| 79 | 82 | |
| 80 | 83 | color_prom += 128; /* skip the bottom half of the PROM - seems to be not used */ |
| 81 | 84 | |
| 82 | 85 | /* charset #2 lookup table */ |
| 83 | for (i = 0;i < TOTAL_COLORS(1);i++) | |
| 84 | COLOR(1,i) = *(color_prom++) & 0x0f; | |
| 86 | for (i = 0;i < machine->gfx[1]->total_colors * machine->gfx[1]->color_granularity;i++) | |
| 87 | colortable_entry_set_value(bankp_colortable, machine->gfx[1]->color_base + i, *color_prom++ & 0x0f); | |
| 85 | 88 | |
| 86 | 89 | /* the bottom half of the PROM seems to be not used */ |
| 87 | 90 | } |
| r936 | r937 | |
| 139 | 142 | int flags = (bankp_colorram2[tile_index] & 0x08) ? TILE_FLIPX : 0; |
| 140 | 143 | |
| 141 | 144 | SET_TILE_INFO(1, code, color, flags); |
| 145 | tileinfo->group = color; | |
| 142 | 146 | } |
| 143 | 147 | |
| 144 | 148 | static TILE_GET_INFO( get_fg_tile_info ) |
| r936 | r937 | |
| 148 | 152 | int flags = (colorram[tile_index] & 0x04) ? TILE_FLIPX : 0; |
| 149 | 153 | |
| 150 | 154 | SET_TILE_INFO(0, code, color, flags); |
| 155 | tileinfo->group = color; | |
| 151 | 156 | } |
| 152 | 157 | |
| 153 | 158 | VIDEO_START( bankp ) |
| 154 | 159 | { |
| 155 | 160 | bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, |
| 156 | TILEMAP_TYPE_ | |
| 161 | TILEMAP_TYPE_P | |
| 157 | 162 | |
| 158 | 163 | fg_tilemap = tilemap_create(get_fg_tile_info, tilemap_scan_rows, |
| 159 | TILEMAP_TYPE_ | |
| 164 | TILEMAP_TYPE_P | |
| 160 | 165 | |
| 161 | tilemap_set_transparent_pen(bg_tilemap, 0); | |
| 162 | tilemap_set_transparent_pen(fg_tilemap, 0); | |
| 166 | colortable_configure_tilemap_groups(bankp_colortable, bg_tilemap, machine->gfx[1], 0); | |
| 167 | colortable_configure_tilemap_groups(bankp_colortable, fg_tilemap, machine->gfx[0], 0); | |
| 163 | 168 | } |
| 164 | 169 | |
| 165 | 170 | VIDEO_UPDATE( bankp ) |
| r936 | r937 | |
|---|---|---|
| 26 | 26 | UINT8 *pen_data; /* points to top left corner of tile data */ |
| 27 | 27 | int line_offset; |
| 28 | 28 | |
| 29 | pen_t *pal_data; | |
| 29 | const pen_t *pal_data; | |
| 30 | 30 | |
| 31 | 31 | int x_offset, y_offset; |
| 32 | 32 | int tile_width, tile_height; |
| r936 | r937 | |
| 104 | 104 | |
| 105 | 105 | static void get_sprite_info(running_machine *machine) |
| 106 | 106 | { |
| 107 | pen_t *base_pal = machine->remapped_colortable; | |
| 107 | const pen_t *base_pal = machine->remapped_colortable; | |
| 108 | 108 | UINT8 *base_gfx = memory_region(REGION_GFX1); |
| 109 | 109 | int gfx_max = memory_region_length(REGION_GFX1); |
| 110 | 110 | |
| r936 | r937 | |
| 202 | 202 | #define PRECISION_Y 20 |
| 203 | 203 | #define FPY_HALF (1<<(PRECISION_Y-1)) |
| 204 | 204 | |
| 205 | pen_t *pal_base; | |
| 205 | const pen_t *pal_base; | |
| 206 | 206 | int src_f0y, src_fdy, src_f0x, src_fdx, src_fpx; |
| 207 | 207 | int x1, x2, y1, y2, dx, dy, sx, sy; |
| 208 | 208 | int xcount0=0, ycount0=0; |
| r936 | r937 | |
| 559 | 559 | |
| 560 | 560 | |
| 561 | 561 | UINT8 *src_ptr; |
| 562 | pen_t *pal_ptr, *rgb_ptr; | |
| 562 | const pen_t *pal_ptr, *rgb_ptr; | |
| 563 | 563 | |
| 564 | 564 | int scrollx, sy, sx; |
| 565 | 565 | int mdy, tdy, i; |
| r936 | r937 | |
| 653 | 653 | { |
| 654 | 654 | UINT8 *src_base, *src_ptr; |
| 655 | 655 | UINT16 *tmap_ptr, *dst_base, *dst_ptr; |
| 656 | pen_t *pal_base, *pal_ptr; | |
| 656 | const pen_t *pal_base, *pal_ptr; | |
| 657 | 657 | |
| 658 | 658 | int tilew, tileh; |
| 659 | 659 | int tmskipx, tmskipy, tmscanx, tmmaskx, tmmasky; |
| r936 | r937 | |
| 1014 | 1014 | |
| 1015 | 1015 | VIDEO_UPDATE ( wecleman ) |
| 1016 | 1016 | { |
| 1017 | pen_t *mrct; | |
| 1017 | const pen_t *mrct; | |
| 1018 | 1018 | int video_on; |
| 1019 | 1019 | int fg_x, bg_x, fg_y, bg_y; |
| 1020 | 1020 | int cloud_sx, cloud_sy; |
| r936 | r937 | |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | // temporary fix for ranking screen tile masking |
| 1052 | mrct[0x27] = mrct[0x24]; | |
| 1052 | /* palette hacks! */ | |
| 1053 | ((pen_t *)mrct)[0x27] = mrct[0x24]; | |
| 1053 | 1054 | |
| 1054 | 1055 | get_sprite_info(machine); |
| 1055 | 1056 | |
| r936 | r937 | |
| 1064 | 1065 | // draws the cloud layer; needs work |
| 1065 | 1066 | if (cloud_visible) |
| 1066 | 1067 | { |
| 1067 | mrct[0] = mrct[0x40] = mrct[0x200] = mrct[0x205]; | |
| 1068 | /* palette hacks! */ | |
| 1069 | ((pen_t *)mrct)[0] = ((pen_t *)mrct)[0x40] = ((pen_t *)mrct)[0x200] = ((pen_t *)mrct)[0x205]; | |
| 1068 | 1070 | |
| 1069 | 1071 | if (video_on) |
| 1070 | 1072 | draw_cloud(machine, |
| r936 | r937 | |
|---|---|---|
| 11 | 11 | |
| 12 | 12 | |
| 13 | 13 | #define MAX_STARS 252 |
| 14 | #define STARS_COLOR_BASE | |
| 14 | #define STARS_COLOR_BASE (64*4+64*4+4) | |
| 15 | 15 | |
| 16 | 16 | static UINT32 stars_scrollx; |
| 17 | 17 | static UINT32 stars_scrolly; |
| r936 | r937 | |
| 26 | 26 | UINT8 *bosco_radarattr; |
| 27 | 27 | static UINT8 *bosco_radarx,*bosco_radary; |
| 28 | 28 | |
| 29 | static colortable *bosco_colortable; | |
| 29 | 30 | |
| 31 | ||
| 30 | 32 | PALETTE_INIT( bosco ) |
| 31 | 33 | { |
| 32 | 34 | int i; |
| 33 | #define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity) | |
| 34 | #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs]) | |
| 35 | 35 | |
| 36 | bosco_colortable = colortable_alloc(machine, 32+64); | |
| 36 | 37 | |
| 38 | /* core palette */ | |
| 37 | 39 | for (i = 0;i < 32;i++) |
| 38 | 40 | { |
| 39 | 41 | int bit0,bit1,bit2,r,g,b; |
| r936 | r937 | |
| 52 | 54 | bit2 = ((*color_prom) >> 7) & 0x01; |
| 53 | 55 | b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 54 | 56 | |
| 55 | palette_set_color( | |
| 57 | colortable_palette_set_color(bosco_colortable,i,MAKE_RGB(r,g,b)); | |
| 56 | 58 | color_prom++; |
| 57 | 59 | } |
| 58 | 60 | |
| 59 | /* characters / sprites */ | |
| 60 | for (i = 0;i < 64*4;i++) | |
| 61 | { | |
| 62 | colortable[i] = (color_prom[i] & 0x0f) + 0x10; /* chars */ | |
| 63 | colortable[i+64*4] = (color_prom[i] & 0x0f); /* sprites */ | |
| 64 | } | |
| 65 | ||
| 66 | /* bullets lookup table */ | |
| 67 | /* they use colors 28-31, I think - PAL 5A controls it */ | |
| 68 | for (i = 0;i < 4;i++) | |
| 69 | { | |
| 70 | COLOR(2,i) = 31-i; | |
| 71 | COLOR(2,i+4) = 0; // transparent | |
| 72 | } | |
| 73 | ||
| 74 | /* now the stars */ | |
| 61 | /* palette for the stars */ | |
| 75 | 62 | for (i = 0;i < 64;i++) |
| 76 | 63 | { |
| 77 | 64 | int bits,r,g,b; |
| 78 | static const int map[4] = { 0x00, 0x47, 0x97 | |
| 65 | static const int map[4] = { 0x00, 0x47, 0x97 | |
| 79 | 66 | |
| 80 | 67 | bits = (i >> 0) & 0x03; |
| 81 | 68 | r = map[bits]; |
| r936 | r937 | |
| 84 | 71 | bits = (i >> 4) & 0x03; |
| 85 | 72 | b = map[bits]; |
| 86 | 73 | |
| 87 | palette_set_color( | |
| 74 | colortable_palette_set_color(bosco_colortable,32 + i | |
| 88 | 75 | } |
| 76 | ||
| 77 | /* characters / sprites */ | |
| 78 | for (i = 0;i < 64*4;i++) | |
| 79 | { | |
| 80 | colortable_entry_set_value(bosco_colortable, i, (color_prom[i] & 0x0f) + 0x10); /* chars */ | |
| 81 | colortable_entry_set_value(bosco_colortable, i+64*4, color_prom[i] & 0x0f); /* sprites */ | |
| 82 | } | |
| 83 | ||
| 84 | /* bullets lookup table */ | |
| 85 | /* they use colors 28-31, I think - PAL 5A controls it */ | |
| 86 | for (i = 0;i < 4;i++) | |
| 87 | colortable_entry_set_value(bosco_colortable, 64*4+64*4+i, 31-i); | |
| 88 | ||
| 89 | /* now the stars */ | |
| 90 | for (i = 0;i < 64;i++) | |
| 91 | colortable_entry_set_value(bosco_colortable, 64*4+64*4+4+i, 32 + i); | |
| 89 | 92 | } |
| 90 | 93 | |
| 91 | 94 | |
| r936 | r937 | |
| 107 | 110 | { |
| 108 | 111 | UINT8 attr = bosco_videoram[ram_offs + tile_index + 0x800]; |
| 109 | 112 | tileinfo->category = (attr & 0x20) >> 5; |
| 113 | tileinfo->group = attr & 0x3f; | |
| 110 | 114 | SET_TILE_INFO( |
| 111 | 115 | 0, |
| 112 | 116 | bosco_videoram[ram_offs + tile_index], |
| r936 | r937 | |
| 134 | 138 | |
| 135 | 139 | VIDEO_START( bosco ) |
| 136 | 140 | { |
| 137 | ||
| 138 | 141 | bg_tilemap = tilemap_create(bg_get_tile_info,tilemap_scan_rows,TILEMAP_TYPE_PEN,8,8,32,32); |
| 139 | 142 | fg_tilemap = tilemap_create(fg_get_tile_info,fg_tilemap_scan, TILEMAP_TYPE_PEN,8,8, 8,32); |
| 140 | 143 | |
| 144 | colortable_configure_tilemap_groups(bosco_colortable, bg_tilemap, machine->gfx[0], 0x1f); | |
| 145 | colortable_configure_tilemap_groups(bosco_colortable, fg_tilemap, machine->gfx[0], 0x1f); | |
| 146 | ||
| 141 | 147 | tilemap_set_scrolldx(bg_tilemap,3,3); |
| 142 | 148 | |
| 143 | 149 | spriteram_size = 0x0c; |
| r936 | r937 | |
| 217 | 223 | int sy = 240 - spriteram_2[offs]; |
| 218 | 224 | int flipx = spriteram[offs] & 1; |
| 219 | 225 | int flipy = spriteram[offs] & 2; |
| 226 | int color = spriteram_2[offs + 1] & 0x3f; | |
| 220 | 227 | if (flip_screen) sx += 32-2; |
| 221 | 228 | |
| 222 | 229 | drawgfx(bitmap,machine->gfx[1], |
| 223 | 230 | (spriteram[offs] & 0xfc) >> 2, |
| 224 | | |
| 231 | c | |
| 225 | 232 | flipx,flipy, |
| 226 | 233 | sx,sy, |
| 227 | cliprect,TRANSPARENCY_COLOR,0x0f); | |
| 234 | cliprect,TRANSPARENCY_PENS, | |
| 235 | colortable_get_transpen_mask(bosco_colortable, machine->gfx[1], color, 0x0f)); | |
| 228 | 236 | } |
| 229 | 237 | } |
| 230 | 238 | |
| r936 | r937 | |
| 246 | 254 | 0, |
| 247 | 255 | 0,0, |
| 248 | 256 | x,y, |
| 249 | cliprect,TRANSPARENCY_ | |
| 257 | cliprect,TRANSPARENCY_PENS | |
| 250 | 258 | } |
| 251 | 259 | } |
| 252 | 260 | |
| 253 | 261 | |
| 254 | 262 | static void draw_stars(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect ) |
| 255 | 263 | { |
| 256 | ||
| 257 | 264 | if (1) |
| 258 | ||
| 259 | 265 | { |
| 260 | int | |
| 266 | int | |
| 261 | 267 | int set_a, set_b; |
| 262 | 268 | |
| 263 | 269 | /* two sets of stars controlled by these bits */ |
| 264 | ||
| 265 | 270 | set_a = bosco_starblink[0]; |
| 266 | 271 | set_b = bosco_starblink[1] |0x2; |
| 267 | 272 | |
| 268 | bpen = machine->pens[0x1f]; | |
| 269 | 273 | for (star_cntr = 0;star_cntr < MAX_STARS;star_cntr++) |
| 270 | 274 | { |
| 271 | 275 | int x,y; |
| 272 | 276 | |
| 273 | 277 | if ( (set_a == star_seed_tab[star_cntr].set) || ( set_b == star_seed_tab[star_cntr].set) ) |
| 274 | 278 | { |
| 279 | x = ( star_seed_tab[star_cntr].x + stars_scrollx) % 256; | |
| 280 | y = ( star_seed_tab[star_cntr].y + stars_scrolly) % 256; | |
| 275 | 281 | |
| 276 | ||
| 277 | x = ( star_seed_tab[star_cntr].x + stars_scrollx) % 256; | |
| 278 | y = ( star_seed_tab[star_cntr].y + stars_scrolly) % 256; | |
| 279 | ||
| 280 | 282 | /* dont draw the stars that are off the screen */ |
| 281 | 283 | if ( x < 224 && y < 224 ) |
| 282 | { | |
| 283 | ||
| 284 | { | |
| 284 | 285 | if (flip_screen) x += 64; |
| 285 | 286 | |
| 286 | 287 | if (y >= machine->screen[0].visarea.min_y && y <= machine->screen[0].visarea.max_y) |
| 287 | { | |
| 288 | if (*BITMAP_ADDR16(bitmap, y, x) == bpen) | |
| 289 | *BITMAP_ADDR16(bitmap, y, x) = STARS_COLOR_BASE + star_seed_tab[star_cntr].col; | |
| 290 | } | |
| 288 | *BITMAP_ADDR16(bitmap, y, x) = STARS_COLOR_BASE + star_seed_tab[star_cntr].col; | |
| 291 | 289 | } |
| 292 | 290 | } |
| 293 | ||
| 294 | 291 | } |
| 295 | 292 | } |
| 296 | ||
| 297 | ||
| 298 | 293 | } |
| 299 | 294 | |
| 300 | 295 | |
| r936 | r937 | |
| 315 | 310 | fg_clip.min_x = 28*8; |
| 316 | 311 | } |
| 317 | 312 | |
| 313 | fillbitmap(bitmap,get_black_pen(machine),cliprect); | |
| 314 | draw_stars(machine, bitmap,cliprect); | |
| 315 | ||
| 318 | 316 | tilemap_draw(bitmap,&bg_clip,bg_tilemap,0,0); |
| 319 | 317 | tilemap_draw(bitmap,&fg_clip,fg_tilemap,0,0); |
| 320 | 318 | |
| r936 | r937 | |
| 326 | 324 | |
| 327 | 325 | draw_bullets(machine, bitmap,cliprect); |
| 328 | 326 | |
| 329 | draw_stars(machine, bitmap,cliprect); | |
| 330 | 327 | return 0; |
| 331 | 328 | } |
| 332 | 329 |
| r936 | r937 | |
|---|---|---|
| 778 | 778 | |
| 779 | 779 | clip=&myclip; |
| 780 | 780 | } |
| 781 | if( gfx | |
| 781 | if( gfx | |
| 782 | 782 | { |
| 783 | const pen_t *pal = & | |
| 783 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 784 | 784 | UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| 785 | 785 | int sprite_screen_height = (scaley*gfx->height+0x8000)>>16; |
| 786 | 786 | int sprite_screen_width = (scalex*gfx->width+0x8000)>>16; |
| r936 | r937 | |
|---|---|---|
| 16 | 16 | |
| 17 | 17 | static tilemap *bg_tilemap, *fg_tilemap; |
| 18 | 18 | |
| 19 | static rgb_t palette[64]; | |
| 20 | ||
| 21 | #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity) | |
| 22 | #define COLOR(gfxn,offs) (Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs) | |
| 23 | ||
| 24 | ||
| 25 | ||
| 19 | 26 | /*************************************************************************** |
| 20 | 27 | |
| 21 | 28 | Convert the color PROMs into a more useable format. |
| r936 | r937 | |
| 27 | 34 | { |
| 28 | 35 | int i; |
| 29 | 36 | |
| 30 | #define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity) | |
| 31 | #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs]) | |
| 32 | ||
| 33 | 37 | for (i = 0; i < machine->drv->total_colors; i++) |
| 34 | 38 | { |
| 35 | 39 | int bit0, bit1, bit2, r, g, b; |
| r936 | r937 | |
| 58 | 62 | |
| 59 | 63 | b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 60 | 64 | |
| 61 | palette | |
| 65 | palette[ | |
| 62 | 66 | |
| 63 | 67 | color_prom++; |
| 64 | 68 | } |
| r936 | r937 | |
| 66 | 70 | backcolor = 0; /* background color can be changed by the game */ |
| 67 | 71 | |
| 68 | 72 | for (i = 0; i < TOTAL_COLORS(0); i++) |
| 69 | COLOR(0, i) | |
| 73 | palette_set_color(machine, COLOR(0, i), palette[i]); | |
| 70 | 74 | |
| 71 | 75 | for (i = 0; i < TOTAL_COLORS(1); i++) |
| 72 | 76 | { |
| 73 | 77 | if (i % 4 == 0) |
| 74 | COLOR(1, i) | |
| 78 | palette_set_color(machine, COLOR(1, i), palette[4 * backcolor + 0x20]); | |
| 75 | 79 | else |
| 76 | COLOR(1, i) | |
| 80 | palette_set_color(machine, COLOR(1, i), palette[i + 0x20]); | |
| 77 | 81 | } |
| 78 | 82 | } |
| 79 | 83 | |
| r936 | r937 | |
| 118 | 122 | backcolor = data & 7; |
| 119 | 123 | |
| 120 | 124 | for (i = 0;i < 32;i += 4) |
| 121 | Machine->gfx[1]->colortable[i] = Machine->pens[4 * backcolor + 0x20]; | |
| 122 | ||
| 123 | tilemap_mark_all_tiles_dirty(ALL_TILEMAPS); | |
| 125 | palette_set_color(Machine, COLOR(1, i), palette[4 * backcolor + 0x20]); | |
| 124 | 126 | } |
| 125 | 127 | |
| 126 | 128 | /* bit 3 selects char bank */ |
| r936 | r937 | |
| 196 | 198 | { |
| 197 | 199 | int i; |
| 198 | 200 | |
| 199 | #define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity) | |
| 200 | #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs]) | |
| 201 | ||
| 202 | 201 | for (i = 0; i < machine->drv->total_colors; i++) |
| 203 | 202 | { |
| 204 | 203 | int bit0, bit1, bit2, r, g, b; |
| r936 | r937 | |
| 227 | 226 | |
| 228 | 227 | b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 229 | 228 | |
| 230 | palette | |
| 229 | palette[ | |
| 231 | 230 | |
| 232 | 231 | color_prom++; |
| 233 | 232 | } |
| r936 | r937 | |
| 235 | 234 | backcolor = 0; /* background color can be changed by the game */ |
| 236 | 235 | |
| 237 | 236 | for (i = 0; i < TOTAL_COLORS(0); i++) |
| 238 | COLOR(0, i) | |
| 237 | palette_set_color(machine, COLOR(0, i), palette[4 * (i % 4) + (i / 4)]); | |
| 239 | 238 | |
| 240 | 239 | for (i = 0; i < TOTAL_COLORS(1); i++) |
| 241 | 240 | { |
| 242 | 241 | if (i % 4 == 0) |
| 243 | COLOR(1, i) | |
| 242 | palette_set_color(machine, COLOR(1, i), palette[backcolor + 0x10]); | |
| 244 | 243 | else |
| 245 | COLOR(1, i) | |
| 244 | palette_set_color(machine, COLOR(1, i), palette[4 * (i % 4) + (i / 4) + 0x10]); | |
| 246 | 245 | } |
| 247 | 246 | } |
| 248 | 247 | |
| r936 | r937 | |
| 276 | 275 | backcolor = data & 0x03; |
| 277 | 276 | |
| 278 | 277 | for (i = 0; i < 16; i += 4) |
| 279 | Machine->gfx[1]->colortable[i] = Machine->pens[backcolor + 0x10]; | |
| 280 | ||
| 281 | tilemap_mark_all_tiles_dirty(ALL_TILEMAPS); | |
| 278 | palette_set_color(Machine, COLOR(1, i), palette[backcolor + 0x10]); | |
| 282 | 279 | } |
| 283 | 280 | } |
| 284 | 281 |
| r936 | r937 | |
|---|---|---|
| 654 | 654 | decodegfx(machine->gfx[gfx_index], &memory_region(REGION_GFX2)[0x80000 * (bank_index - 1)], 0, machine->gfx[gfx_index]->total_elements); |
| 655 | 655 | |
| 656 | 656 | /* set the color information */ |
| 657 | machine->gfx[gfx_index]->color | |
| 657 | machine->gfx[gfx_index]->color_ | |
| 658 | 658 | machine->gfx[gfx_index]->color_granularity = 8; |
| 659 | 659 | machine->gfx[gfx_index]->total_colors = 0x40; |
| 660 | 660 | bank_color_shift[gfx_index] = bpp - 3; |
| r936 | r937 | |
|---|---|---|
| 295 | 295 | decodegfx(machine->gfx[gfx_index], memory_region(region), 0, machine->gfx[gfx_index]->total_elements); |
| 296 | 296 | |
| 297 | 297 | /* set the color information */ |
| 298 | machine->gfx[gfx_index]->color | |
| 298 | machine->gfx[gfx_index]->color_ | |
| 299 | 299 | machine->gfx[gfx_index]->total_colors = 64; |
| 300 | 300 | } |
| 301 | 301 | |
| r936 | r937 | |
| 306 | 306 | decodegfx(machine->gfx[gfx_index], data, 0, machine->gfx[gfx_index]->total_elements); |
| 307 | 307 | |
| 308 | 308 | /* set the color information */ |
| 309 | machine->gfx[gfx_index]->color | |
| 309 | machine->gfx[gfx_index]->color_ | |
| 310 | 310 | machine->gfx[gfx_index]->total_colors = 64; |
| 311 | 311 | } |
| 312 | 312 |
| r936 | r937 | |
|---|---|---|
| 652 | 652 | gfx.width = width; |
| 653 | 653 | gfx.height = height; |
| 654 | 654 | gfx.total_elements = 1; |
| 655 | gfx.color_depth = 256; | |
| 655 | 656 | gfx.color_granularity = 256; |
| 656 | gfx.color | |
| 657 | gfx.color_ | |
| 657 | 658 | gfx.total_colors = 0x20; |
| 658 | 659 | gfx.pen_usage = NULL; |
| 659 | 660 | gfx.gfxdata = gfxdata; |
| r936 | r937 | |
| 681 | 682 | gfx.width = width; |
| 682 | 683 | gfx.height = height; |
| 683 | 684 | gfx.total_elements = 1; |
| 685 | gfx.color_depth = 16; | |
| 684 | 686 | gfx.color_granularity = 16; |
| 685 | gfx.color | |
| 687 | gfx.color_ | |
| 686 | 688 | gfx.total_colors = 0x200; |
| 687 | 689 | gfx.pen_usage = NULL; |
| 688 | 690 | gfx.gfxdata = gfxdata; |
| 689 | 691 | gfx.line_modulo = width/2; |
| 690 | 692 | gfx.char_modulo = 0; /* doesn't matter */ |
| 691 | gfx.flags = GFX_PACKED; | |
| 693 | gfx.flags = GFX_ELEMENT_PACKED; | |
| 692 | 694 | |
| 693 | 695 | /* Bounds checking */ |
| 694 | 696 | if ( (gfxdata + width/2 * height - 1) >= gfx_max ) |
| r936 | r937 | |
|---|---|---|
| 85 | 85 | else { ystart = 0; yend = high; yinc = +1; } |
| 86 | 86 | |
| 87 | 87 | /* Start drawing */ |
| 88 | if( gfx | |
| 88 | if( gfx | |
| 89 | 89 | { |
| 90 | 90 | for (ytile = ystart; ytile != yend; ytile += yinc ) |
| 91 | 91 | { |
| 92 | 92 | for (xtile = xstart; xtile != xend; xtile += xinc ) |
| 93 | 93 | { |
| 94 | const pen_t *pal = &gfx->colortable[gfx->color_granularity * (color % gfx->total_colors)]; /* ASG 980209 */ | |
| 95 | const UINT8 *alpha = &jal_blend_table[gfx->color_granularity * (color % gfx->total_colors)]; /* ASG 980209 */ | |
| 94 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 95 | const UINT8 *alpha = &jal_blend_table[gfx->color_granularity * (color % gfx->total_colors)]; | |
| 96 | 96 | int source_base = ((code + code_offset++) % gfx->total_elements) * gfx->height; |
| 97 | 97 | |
| 98 | 98 | int x_index_base, y_index, sx, sy, ex, ey; |
| r936 | r937 | |
|---|---|---|
| 323 | 323 | static void update_pixel1(int x, int y) |
| 324 | 324 | { |
| 325 | 325 | UINT8 color = nbmj8891_videoram1[(y * Machine->screen[0].width) + x]; |
| 326 | *BITMAP_ADDR16(nbmj8891_tmpbitmap1, y, x) = Machine->pens[color]; | |
| 326 | *BITMAP_ADDR16(nbmj8891_tmpbitmap1, y, x) = Machine->pens[(color == 0x7f) ? 0xff : color]; | |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | static TIMER_CALLBACK( blitter_timer_callback ) |
| r936 | r937 | |
| 512 | 512 | nbmj8891_clut = auto_malloc(0x800 * sizeof(UINT8)); |
| 513 | 513 | memset(nbmj8891_videoram0, 0xff, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT8))); |
| 514 | 514 | memset(nbmj8891_videoram1, 0xff, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT8))); |
| 515 | machine->pens[0x07f] = 0xff; /* palette_transparent_pen */ | |
| 516 | 515 | gfxdraw_mode = 1; |
| 517 | 516 | } |
| 518 | 517 |
| r936 | r937 | |
|---|---|---|
| 278 | 278 | if (ACCESSING_LSB) |
| 279 | 279 | { |
| 280 | 280 | seta_coin_lockout_w (data & 0x0f); |
| 281 | if (sndti_t | |
| 281 | if (sndti_exist | |
| 282 | 282 | seta_sound_enable_w (data & 0x20); |
| 283 | 283 | coin_counter_w(0,data & 0x01); |
| 284 | 284 | coin_counter_w(1,data & 0x02); |
| r936 | r937 | |
|---|---|---|
| 70 | 70 | decodegfx(machine->gfx[ttl_gfx_index], memory_region(REGION_GFX1), 0, machine->gfx[ttl_gfx_index]->total_elements); |
| 71 | 71 | |
| 72 | 72 | if (machine->drv->color_table_len) |
| 73 | { | |
| 74 | machine->gfx[ttl_gfx_index]->colortable = machine->remapped_colortable; | |
| 75 | 73 | machine->gfx[ttl_gfx_index]->total_colors = machine->drv->color_table_len / 16; |
| 76 | } | |
| 77 | 74 | else |
| 78 | { | |
| 79 | machine->gfx[ttl_gfx_index]->colortable = machine->pens; | |
| 80 | 75 | machine->gfx[ttl_gfx_index]->total_colors = machine->drv->total_colors / 16; |
| 81 | } | |
| 82 | 76 | |
| 83 | 77 | // create the tilemap |
| 84 | 78 | ttl_tilemap = tilemap_create(ttl_get_tile_info, tilemap_scan_rows, TILEMAP_TYPE_PEN, 8, 8, 64, 32); |
| r936 | r937 | |
|---|---|---|
| 141 | 141 | UINT32 rom15F_addr = (((scroll_v + v) & 0x07)<<2) + (map_v_scr_100<<5); |
| 142 | 142 | UINT32 map_v_scr_1fe_6 =((scroll_v + v) & 0x1fe)<<6; |
| 143 | 143 | |
| 144 | pen_t *pens = &machine->pens[2*16 + (map_v_scr_100>>1)]; | |
| 144 | const pen_t *pens = &machine->pens[2*16 + (map_v_scr_100>>1)]; | |
| 145 | 145 | |
| 146 | 146 | if (!map_v_scr_100) |
| 147 | 147 | { |
| r936 | r937 | |
|---|---|---|
| 837 | 837 | int ox,oy,cx,cy; |
| 838 | 838 | int x_index,y_index,x,y; |
| 839 | 839 | |
| 840 | const pen_t *pal = & | |
| 840 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 841 | 841 | int source_base = (code % gfx->total_elements) * gfx->height; |
| 842 | 842 | |
| 843 | 843 | /* check bounds */ |
| r936 | r937 | |
|---|---|---|
| 131 | 131 | |
| 132 | 132 | VIDEO_UPDATE( gridlee ) |
| 133 | 133 | { |
| 134 | pen_t *pens = &machine->pens[palettebank_vis * 32]; | |
| 134 | const pen_t *pens = &machine->pens[palettebank_vis * 32]; | |
| 135 | 135 | int x, y, i; |
| 136 | 136 | |
| 137 | 137 | /* draw scanlines from the VRAM directly */ |
| r936 | r937 | |
|---|---|---|
| 178 | 178 | palette_set_colors(machine, 0x100, rgb, 0x100); |
| 179 | 179 | free(rgb); |
| 180 | 180 | |
| 181 | palette_normalize_range(machine, 0x000, 0x1ff, 0x00, 0xff); | |
| 181 | palette_normalize_range(machine->palette, 0x000, 0x1ff, 0x00, 0xff); | |
| 182 | 182 | |
| 183 | 183 | /* we'll need this at run time */ |
| 184 | 184 | sprite_height_prom = color_prom + 0x600; |
| r936 | r937 | |
| 197 | 197 | palette_set_colors(machine, 0x180, rgb, 0x180); |
| 198 | 198 | free(rgb); |
| 199 | 199 | |
| 200 | palette_normalize_range(machine, 0x000, 0x2ff, 0x00, 0xff); | |
| 200 | palette_normalize_range(machine->palette, 0x000, 0x2ff, 0x00, 0xff); | |
| 201 | 201 | |
| 202 | 202 | /* we'll need this at run time */ |
| 203 | 203 | sprite_height_prom = color_prom + 0x900; |
| r936 | r937 | |
| 220 | 220 | palette_set_colors(machine, 0x200, rgb, 0x020); |
| 221 | 221 | free(rgb); |
| 222 | 222 | |
| 223 | palette_normalize_range(machine, 0x000, 0x21f, 0x00, 0xff); | |
| 223 | palette_normalize_range(machine->palette, 0x000, 0x21f, 0x00, 0xff); | |
| 224 | 224 | |
| 225 | 225 | sprite_height_prom = color_prom + 0x620; /* we'll need this at run time */ |
| 226 | 226 | } |
| r936 | r937 | |
| 238 | 238 | palette_set_colors(machine, 0x200, rgb, 0x100); |
| 239 | 239 | free(rgb); |
| 240 | 240 | |
| 241 | palette_normalize_range(machine, 0x000, 0x2ff, 0x00, 0xff); | |
| 241 | palette_normalize_range(machine->palette, 0x000, 0x2ff, 0x00, 0xff); | |
| 242 | 242 | |
| 243 | 243 | /* we'll need this at run time */ |
| 244 | 244 | sprite_height_prom = color_prom + 0x700; |
| r936 | r937 | |
|---|---|---|
| 11 | 11 | |
| 12 | 12 | |
| 13 | 13 | #define MAX_STARS 252 |
| 14 | #define STARS_COLOR_BASE | |
| 14 | #define STARS_COLOR_BASE (64*4+64*4) | |
| 15 | 15 | |
| 16 | 16 | UINT8 *galaga_videoram; |
| 17 | 17 | UINT8 *galaga_ram1,*galaga_ram2,*galaga_ram3; |
| 18 | 18 | UINT8 galaga_starcontrol[6]; |
| 19 | 19 | static UINT32 stars_scrollx,stars_scrolly; |
| 20 | static colortable *galaga_colortable; | |
| 20 | 21 | |
| 21 | 22 | static INT32 galaga_gfxbank; // used by catsbee |
| 22 | 23 | |
| r936 | r937 | |
| 337 | 338 | { |
| 338 | 339 | int i; |
| 339 | 340 | |
| 341 | galaga_colortable = colortable_alloc(machine, 32+64); | |
| 340 | 342 | |
| 343 | /* core palette */ | |
| 341 | 344 | for (i = 0;i < 32;i++) |
| 342 | 345 | { |
| 343 | 346 | int bit0,bit1,bit2,r,g,b; |
| 344 | 347 | |
| 345 | ||
| 346 | 348 | bit0 = ((*color_prom) >> 0) & 0x01; |
| 347 | 349 | bit1 = ((*color_prom) >> 1) & 0x01; |
| 348 | 350 | bit2 = ((*color_prom) >> 2) & 0x01; |
| r936 | r937 | |
| 356 | 358 | bit2 = ((*color_prom) >> 7) & 0x01; |
| 357 | 359 | b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 358 | 360 | |
| 359 | palette_set_color( | |
| 361 | colortable_palette_set_color(galaga_colortable,i,MAKE_RGB(r,g,b)); | |
| 360 | 362 | color_prom++; |
| 361 | 363 | } |
| 362 | 364 | |
| 363 | /* characters */ | |
| 364 | for (i = 0;i < 64*4;i++) | |
| 365 | *(colortable++) = (*(color_prom++) & 0x0f) + 0x10; /* chars */ | |
| 366 | ||
| 367 | /* sprites */ | |
| 368 | for (i = 0;i < 64*4;i++) | |
| 369 | *(colortable++) = (*(color_prom++) & 0x0f); /* sprites */ | |
| 370 | ||
| 371 | ||
| 372 | /* now the stars */ | |
| 365 | /* palette for the stars */ | |
| 373 | 366 | for (i = 0;i < 64;i++) |
| 374 | 367 | { |
| 375 | 368 | int bits,r,g,b; |
| r936 | r937 | |
| 382 | 375 | bits = (i >> 4) & 0x03; |
| 383 | 376 | b = map[bits]; |
| 384 | 377 | |
| 385 | palette_set_color( | |
| 378 | colortable_palette_set_color(galaga_colortable,32 + i | |
| 386 | 379 | } |
| 380 | ||
| 381 | /* characters */ | |
| 382 | for (i = 0;i < 64*4;i++) | |
| 383 | colortable_entry_set_value(galaga_colortable, i, (*(color_prom++) & 0x0f) + 0x10); /* chars */ | |
| 384 | ||
| 385 | /* sprites */ | |
| 386 | for (i = 0;i < 64*4;i++) | |
| 387 | colortable_entry_set_value(galaga_colortable, 64*4+i, (*(color_prom++) & 0x0f)); | |
| 388 | ||
| 389 | /* now the stars */ | |
| 390 | for (i = 0;i < 64;i++) | |
| 391 | colortable_entry_set_value(galaga_colortable, 64*4+64*4+i, 32 + i); | |
| 387 | 392 | } |
| 388 | 393 | |
| 389 | 394 | |
| r936 | r937 | |
| 417 | 422 | timing signals, while x flip is done by selecting the 2nd character set. |
| 418 | 423 | We reproduce this here, but since the tilemap system automatically flips |
| 419 | 424 | characters when screen is flipped, we have to flip them back. */ |
| 425 | int color = galaga_videoram[tile_index + 0x400] & 0x3f; | |
| 420 | 426 | SET_TILE_INFO( |
| 421 | 427 | 0, |
| 422 | 428 | (galaga_videoram[tile_index] & 0x7f) | (flip_screen ? 0x80 : 0) | (galaga_gfxbank << 8), |
| 423 | | |
| 429 | col | |
| 424 | 430 | flip_screen ? TILE_FLIPX : 0); |
| 431 | tileinfo->group = color; | |
| 425 | 432 | } |
| 426 | 433 | |
| 427 | 434 | |
| r936 | r937 | |
| 434 | 441 | |
| 435 | 442 | VIDEO_START( galaga ) |
| 436 | 443 | { |
| 437 | tx_tilemap = tilemap_create(get_tile_info,tilemap_scan,TILEMAP_TYPE_COLORTABLE,8,8,36,28); | |
| 444 | tx_tilemap = tilemap_create(get_tile_info,tilemap_scan,TILEMAP_TYPE_PEN,8,8,36,28); | |
| 445 | colortable_configure_tilemap_groups(galaga_colortable, tx_tilemap, machine->gfx[0], 0x1f); | |
| 438 | 446 | |
| 439 | tilemap_set_transparent_pen(tx_tilemap, 0x1f); | |
| 440 | ||
| 441 | 447 | galaga_gfxbank = 0; |
| 442 | 448 | |
| 443 | 449 | spriteram = galaga_ram1 + 0x380; |
| r936 | r937 | |
| 529 | 535 | color, |
| 530 | 536 | flipx,flipy, |
| 531 | 537 | sx + 16*x, sy + 16*y, |
| 532 | cliprect,TRANSPARENCY_COLOR,0x0f); | |
| 538 | cliprect,TRANSPARENCY_PENS, | |
| 539 | colortable_get_transpen_mask(galaga_colortable, machine->gfx[1], color, 0x0f)); | |
| 533 | 540 | } |
| 534 | 541 | } |
| 535 | 542 | } |
| r936 | r937 | |
| 545 | 552 | |
| 546 | 553 | if ( galaga_starcontrol[5] == 1 ) |
| 547 | 554 | { |
| 548 | int | |
| 555 | int | |
| 549 | 556 | int set_a, set_b; |
| 550 | bpen = machine->pens[0x1f]; | |
| 551 | 557 | |
| 552 | 558 | /* two sets of stars controlled by these bits */ |
| 553 | 559 | |
| r936 | r937 | |
| 569 | 575 | |
| 570 | 576 | |
| 571 | 577 | if (y >= machine->screen[0].visarea.min_y && y <= machine->screen[0].visarea.max_y) |
| 572 | { | |
| 573 | if (*BITMAP_ADDR16(bitmap, y, x) == bpen) | |
| 574 | *BITMAP_ADDR16(bitmap, y, x) = STARS_COLOR_BASE + star_seed_tab[ star_cntr ].col; | |
| 575 | } | |
| 578 | *BITMAP_ADDR16(bitmap, y, x) = STARS_COLOR_BASE + star_seed_tab[ star_cntr ].col; | |
| 576 | 579 | } |
| 577 | 580 | |
| 578 | 581 | } |
| r936 | r937 | |
| 581 | 584 | |
| 582 | 585 | VIDEO_UPDATE( galaga ) |
| 583 | 586 | { |
| 584 | fillbitmap(bitmap,machine->pens[0x1f],cliprect); | |
| 587 | fillbitmap(bitmap,get_black_pen(machine),cliprect); | |
| 588 | draw_stars(machine,bitmap,cliprect); | |
| 585 | 589 | draw_sprites(machine,bitmap,cliprect); |
| 586 | 590 | tilemap_draw(bitmap,cliprect,tx_tilemap,0,0); |
| 587 | ||
| 588 | draw_stars(machine,bitmap,cliprect); | |
| 589 | 591 | return 0; |
| 590 | 592 | } |
| 591 | 593 |
| r936 | r937 | |
|---|---|---|
| 32 | 32 | static int palette_bank; |
| 33 | 33 | static const UINT8 *pacland_color_prom; |
| 34 | 34 | |
| 35 | static colortable *pacland_colortable; | |
| 35 | 36 | static tilemap *bg_tilemap, *fg_tilemap; |
| 36 | 37 | static mame_bitmap *sprite_bitmap,*fg_bitmap; |
| 37 | 38 | |
| r936 | r937 | |
| 92 | 93 | |
| 93 | 94 | color_prom++; |
| 94 | 95 | |
| 95 | palette_set_color( | |
| 96 | colortable_palette_set_color(pacland_colortable,i,MAKE_RGB(r,g,b)); | |
| 96 | 97 | } |
| 97 | 98 | } |
| 98 | 99 | |
| 99 | 100 | PALETTE_INIT( pacland ) |
| 100 | 101 | { |
| 101 | 102 | int i; |
| 102 | #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs]) | |
| 103 | 103 | |
| 104 | /* allocate the colortable */ | |
| 105 | pacland_colortable = colortable_alloc(machine, 256); | |
| 104 | 106 | |
| 105 | 107 | pacland_color_prom = color_prom; /* we'll need this later */ |
| 106 | 108 | /* skip the palette data, it will be initialized later */ |
| r936 | r937 | |
| 109 | 111 | |
| 110 | 112 | /* Foreground */ |
| 111 | 113 | for (i = 0;i < 0x400;i++) |
| 112 | | |
| 114 | colortable_entry_set_value(pacland_colortable, machine->gfx[0]->color_base + i, * | |
| 113 | 115 | |
| 114 | 116 | /* Background */ |
| 115 | 117 | for (i = 0;i < 0x400;i++) |
| 116 | | |
| 118 | colortable_entry_set_value(pacland_colortable, machine->gfx[1]->color_base + i, * | |
| 117 | 119 | |
| 118 | 120 | /* Sprites */ |
| 119 | 121 | for (i = 0;i < 0x400;i++) |
| 120 | 122 | { |
| 121 | COLOR(2,i) = *(color_prom++); | |
| 122 | COLOR(2,i + 0x400) = (COLOR(2,i) < 0x80) ? 0x7f : 0xff; // for high priority mask (round 19) | |
| 123 | colortable_entry_set_value(pacland_colortable, machine->gfx[2]->color_base + i, *color_prom); | |
| 124 | colortable_entry_set_value(pacland_colortable, machine->gfx[2]->color_base + i + 0x400, (*color_prom++ < 0x80) ? 0x7f : 0xff); // for high priority mask (round 19) | |
| 123 | 125 | } |
| 124 | 126 | |
| 125 | 127 | palette_bank = 0; |
| r936 | r937 | |
| 154 | 156 | int flags = TILE_FLIPYX(attr >> 6); |
| 155 | 157 | |
| 156 | 158 | tileinfo->category = (attr & 0x20) ? 1 : 0; |
| 159 | tileinfo->group = color; | |
| 157 | 160 | |
| 158 | 161 | SET_TILE_INFO(0, code, color, flags); |
| 159 | 162 | } |
| r936 | r937 | |
| 171 | 174 | fg_bitmap = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format); |
| 172 | 175 | sprite_bitmap = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format); |
| 173 | 176 | |
| 174 | bg_tilemap = tilemap_create(get_bg_tile_info,tilemap_scan_rows,TILEMAP_TYPE_PEN, 8,8,64,32); | |
| 175 | fg_tilemap = tilemap_create(get_fg_tile_info,tilemap_scan_rows,TILEMAP_TYPE_COLORTABLE,8,8,64,32); | |
| 177 | bg_tilemap = tilemap_create(get_bg_tile_info,tilemap_scan_rows,TILEMAP_TYPE_PEN,8,8,64,32); | |
| 178 | fg_tilemap = tilemap_create(get_fg_tile_info,tilemap_scan_rows,TILEMAP_TYPE_PEN,8,8,64,32); | |
| 176 | 179 | |
| 177 | 180 | tilemap_set_scroll_rows(fg_tilemap, 32); |
| 178 | tilemap_ | |
| 181 | colortable_configure_tilemap_g | |
| 179 | 182 | |
| 180 | 183 | spriteram = pacland_spriteram + 0x780; |
| 181 | 184 | spriteram_2 = spriteram + 0x800; |
| r936 | r937 | |
| 280 | 283 | color, |
| 281 | 284 | flipx,flipy, |
| 282 | 285 | sx + 16*x,sy + 16*y, |
| 283 | cliprect,TRANSPARENCY_COLOR,0xff); | |
| 286 | cliprect,TRANSPARENCY_PENS, | |
| 287 | colortable_get_transpen_mask(pacland_colortable, machine->gfx[2], color, 0xff)); | |
| 284 | 288 | } |
| 285 | 289 | } |
| 286 | 290 | } |
| r936 | r937 | |
|---|---|---|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | { |
| 268 | if( gfx | |
| 268 | if( gfx | |
| 269 | 269 | { |
| 270 | const pen_t *pal = & | |
| 270 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 271 | 271 | const UINT8 *shadow_pens = shadow_pen_array + (gfx->color_granularity * (color % gfx->total_colors)); |
| 272 | 272 | int source_base = (code % gfx->total_elements) * gfx->height; |
| 273 | 273 |
| r936 | r937 | |
|---|---|---|
| 1981 | 1981 | |
| 1982 | 1982 | /* set the color information */ |
| 1983 | 1983 | if (machine->drv->color_table_len) |
| 1984 | { | |
| 1985 | machine->gfx[gfx_index]->colortable = machine->remapped_colortable; | |
| 1986 | 1984 | machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; |
| 1987 | } | |
| 1988 | 1985 | else |
| 1989 | { | |
| 1990 | machine->gfx[gfx_index]->colortable = machine->pens; | |
| 1991 | 1986 | machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; |
| 1992 | } | |
| 1993 | 1987 | |
| 1994 | 1988 | K052109_memory_region = gfx_memory_region; |
| 1995 | 1989 | K052109_gfxnum = gfx_index; |
| r936 | r937 | |
| 2452 | 2446 | |
| 2453 | 2447 | /* set the color information */ |
| 2454 | 2448 | if (machine->drv->color_table_len) |
| 2455 | { | |
| 2456 | machine->gfx[gfx_index]->colortable = machine->remapped_colortable; | |
| 2457 | 2449 | machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; |
| 2458 | } | |
| 2459 | 2450 | else |
| 2460 | { | |
| 2461 | machine->gfx[gfx_index]->colortable = machine->pens; | |
| 2462 | 2451 | machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; |
| 2463 | } | |
| 2464 | 2452 | |
| 2465 | 2453 | #if VERBOSE |
| 2466 | 2454 | if (!(machine->drv->video_attributes & VIDEO_HAS_SHADOWS)) |
| r936 | r937 | |
| 2949 | 2937 | |
| 2950 | 2938 | /* set the color information */ |
| 2951 | 2939 | if (machine->drv->color_table_len) |
| 2952 | { | |
| 2953 | machine->gfx[gfx_index]->colortable = machine->remapped_colortable; | |
| 2954 | 2940 | machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; |
| 2955 | } | |
| 2956 | 2941 | else |
| 2957 | { | |
| 2958 | machine->gfx[gfx_index]->colortable = machine->pens; | |
| 2959 | 2942 | machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; |
| 2960 | } | |
| 2961 | 2943 | |
| 2962 | 2944 | #if VERBOSE |
| 2963 | 2945 | if (!(machine->drv->video_attributes & VIDEO_HAS_SHADOWS)) |
| r936 | r937 | |
| 3695 | 3677 | |
| 3696 | 3678 | /* set the color information */ |
| 3697 | 3679 | if (machine->drv->color_table_len) |
| 3698 | { | |
| 3699 | machine->gfx[gfx_index]->colortable = machine->remapped_colortable; | |
| 3700 | 3680 | machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; |
| 3701 | } | |
| 3702 | 3681 | else |
| 3703 | { | |
| 3704 | machine->gfx[gfx_index]->colortable = machine->pens; | |
| 3705 | 3682 | machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; |
| 3706 | } | |
| 3707 | 3683 | |
| 3708 | 3684 | #if VERBOSE |
| 3709 | 3685 | if (machine->screen[0].format == BITMAP_FORMAT_RGB32) |
| r936 | r937 | |
| 3857 | 3833 | |
| 3858 | 3834 | /* set the color information */ |
| 3859 | 3835 | if (machine->drv->color_table_len) |
| 3860 | { | |
| 3861 | machine->gfx[gfx_index]->colortable = machine->remapped_colortable; | |
| 3862 | 3836 | machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; |
| 3863 | } | |
| 3864 | 3837 | else |
| 3865 | { | |
| 3866 | machine->gfx[gfx_index]->colortable = machine->pens; | |
| 3867 | 3838 | machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; |
| 3868 | } | |
| 3869 | 3839 | |
| 3870 | 3840 | #if VERBOSE |
| 3871 | 3841 | if (!(machine->drv->video_attributes & VIDEO_HAS_SHADOWS)) |
| r936 | r937 | |
| 4620 | 4590 | |
| 4621 | 4591 | /* set the color information */ |
| 4622 | 4592 | if (machine->drv->color_table_len) |
| 4623 | { | |
| 4624 | machine->gfx[gfx_index]->colortable = machine->remapped_colortable; | |
| 4625 | 4593 | machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / (1 << bpp); |
| 4626 | } | |
| 4627 | 4594 | else |
| 4628 | { | |
| 4629 | machine->gfx[gfx_index]->colortable = machine->pens; | |
| 4630 | 4595 | machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / (1 << bpp); |
| 4631 | } | |
| 4632 | 4596 | |
| 4633 | 4597 | K051316_memory_region[chip] = gfx_memory_region; |
| 4634 | 4598 | K051316_gfxnum[chip] = gfx_index; |
| r936 | r937 | |
| 5686 | 5650 | |
| 5687 | 5651 | /* set the color information */ |
| 5688 | 5652 | if (machine->drv->color_table_len) |
| 5689 | { | |
| 5690 | machine->gfx[gfx_index]->colortable = machine->remapped_colortable; | |
| 5691 | 5653 | machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; |
| 5692 | } | |
| 5693 | 5654 | else |
| 5694 | { | |
| 5695 | machine->gfx[gfx_index]->colortable = machine->pens; | |
| 5696 | 5655 | machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; |
| 5697 | } | |
| 5698 | 5656 | machine->gfx[gfx_index]->color_granularity = 16; /* override */ |
| 5699 | 5657 | |
| 5700 | 5658 | K056832_memory_region = gfx_memory_region; |
| r936 | r937 | |
| 6415 | 6373 | int all_dirty, line; |
| 6416 | 6374 | int offs, mask; |
| 6417 | 6375 | |
| 6418 | pen_t *pal_ptr; | |
| 6376 | const pen_t *pal_ptr; | |
| 6419 | 6377 | const UINT8 *src_base, *src_ptr; |
| 6420 | 6378 | UINT8 *xpr_ptr; |
| 6421 | 6379 | UINT16 *dst_ptr; |
| r936 | r937 | |
| 7936 | 7894 | #else |
| 7937 | 7895 | |
| 7938 | 7896 | // utility function to render a clipped scanline vertically or horizontally |
| 7939 | INLINE void K053250_pdraw_scanline32(mame_bitmap *bitmap, pen_t *palette, UINT8 *source, | |
| 7897 | INLINE void K053250_pdraw_scanline32(mame_bitmap *bitmap, const pen_t *palette, UINT8 *source, | |
| 7940 | 7898 | const rectangle *cliprect, int linepos, int scroll, int zoom, |
| 7941 | 7899 | UINT32 clipmask, UINT32 wrapmask, UINT32 orientation, int priority) |
| 7942 | 7900 | { |
| r936 | r937 | |
| 7951 | 7909 | int src_x; |
| 7952 | 7910 | int src_fx, src_fdx; |
| 7953 | 7911 | int pix_data, dst_offset; |
| 7954 | pen_t *pal_base; | |
| 7912 | const pen_t *pal_base; | |
| 7955 | 7913 | UINT8 *pri_base; |
| 7956 | 7914 | UINT32 *dst_base; |
| 7957 | 7915 | int dst_adv; |
| r936 | r937 | |
| 8108 | 8066 | struct K053250_CHIPTAG *chip_ptr; |
| 8109 | 8067 | UINT16 *line_ram; |
| 8110 | 8068 | UINT8 *pix_base, *pix_ptr, *regs; |
| 8111 | pen_t *pal_base, *pal_ptr; | |
| 8069 | const pen_t *pal_base, *pal_ptr; | |
| 8112 | 8070 | UINT32 rommask, src_clipmask, src_wrapmask, dst_wrapmask; |
| 8113 | 8071 | int map_scrollx, map_scrolly, ctrl, orientation; |
| 8114 | 8072 | int dst_minx, dst_maxx, dst_miny, dst_maxy; |
| r936 | r937 | |
|---|---|---|
| 239 | 239 | if (sy > ey) return; |
| 240 | 240 | |
| 241 | 241 | { |
| 242 | pen_t *paldata = machine->pens; | |
| 242 | const pen_t *paldata = machine->pens; | |
| 243 | 243 | UINT32 *end; |
| 244 | 244 | |
| 245 | 245 | UINT16 *sd1 = src1->base; /* source data */ |
| r936 | r937 | |
|---|---|---|
| 16 | 16 | UINT16 *toypop_bg_image; |
| 17 | 17 | static int bitmapflip,palettebank; |
| 18 | 18 | |
| 19 | static | |
| 19 | static colortable *toypop_colortable | |
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | /*************************************************************************** |
| r936 | r937 | |
| 30 | 30 | |
| 31 | 31 | PALETTE_INIT( toypop ) |
| 32 | 32 | { |
| 33 | rgb_t palette[256]; | |
| 34 | 33 | int i; |
| 35 | 34 | |
| 35 | /* allocate the colortable */ | |
| 36 | toypop_colortable = colortable_alloc(machine, 256); | |
| 37 | ||
| 36 | 38 | for (i = 0;i < 256;i++) |
| 37 | 39 | { |
| 38 | 40 | int bit0,bit1,bit2,bit3,r,g,b; |
| r936 | r937 | |
| 56 | 58 | bit3 = (color_prom[i+0x200] >> 3) & 0x01; |
| 57 | 59 | b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; |
| 58 | 60 | |
| 59 | palette | |
| 61 | colortable_palette_set_color(toypop_colortable, i, | |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | /* allocate memory for mask of pens that are transparent in sprites */ | |
| 63 | transmask = auto_malloc(64 * sizeof(transmask[0])); | |
| 64 | memset(transmask, 0, 64 * sizeof(transmask[0])); | |
| 65 | ||
| 66 | 64 | for (i = 0;i < 256;i++) |
| 67 | 65 | { |
| 68 | 66 | UINT8 entry; |
| 67 | ||
| 69 | 68 | // characters |
| 70 | palette_set_color(machine, i + 0*256, palette[(color_prom[i + 0x300] & 0x0f) | 0x70]); | |
| 71 | palette_set_color(machine, i + 1*256, palette[(color_prom[i + 0x300] & 0x0f) | 0xf0]); | |
| 69 | colortable_entry_set_value(toypop_colortable, i + 0*256, (color_prom[i + 0x300] & 0x0f) | 0x70); | |
| 70 | colortable_entry_set_value(toypop_colortable, i + 1*256, (color_prom[i + 0x300] & 0x0f) | 0xf0); | |
| 72 | 71 | // sprites |
| 73 | 72 | entry = color_prom[i + 0x500]; |
| 74 | palette_set_color(machine, i + 2*256, palette[entry]); | |
| 75 | if (entry == 0xff) | |
| 76 | transmask[i/4] |= 1 << (i % 4); | |
| 73 | colortable_entry_set_value(toypop_colortable, i + 2*256, entry); | |
| 77 | 74 | } |
| 78 | 75 | for (i = 0;i < 16;i++) |
| 79 | 76 | { |
| 80 | 77 | // background |
| 81 | palette_set_color(machine, i + 3*256 + 0*16, palette[0x60 + i]); | |
| 82 | palette_set_color(machine, i + 3*256 + 1*16, palette[0xe0 + i]); | |
| 78 | colortable_entry_set_value(toypop_colortable, i + 3*256 + 0*16, 0x60 + i); | |
| 79 | colortable_entry_set_value(toypop_colortable, i + 3*256 + 1*16, 0xe0 + i); | |
| 83 | 80 | } |
| 84 | 81 | } |
| 85 | 82 | |
| r936 | r937 | |
| 226 | 223 | ***************************************************************************/ |
| 227 | 224 | |
| 228 | 225 | /* from mappy.c */ |
| 229 | void mappy_draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int xoffs, int yoffs, co | |
| 226 | void mappy_draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int xoffs, int yoffs, colortable | |
| 230 | 227 | |
| 231 | 228 | |
| 232 | 229 | VIDEO_UPDATE( toypop ) |
| r936 | r937 | |
| 234 | 231 | draw_background(bitmap); |
| 235 | 232 | tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); |
| 236 | 233 | |
| 237 | mappy_draw_sprites(machine, bitmap, cliprect, -31, -8, tra | |
| 234 | mappy_draw_sprites(machine, bitmap, cliprect, -31, -8, toypop_colortable, | |
| 238 | 235 | return 0; |
| 239 | 236 | } |
| r936 | r937 | |
|---|---|---|
| 9 | 9 | |
| 10 | 10 | static INT32 bg_select, tx_color_mode, bg_disable, bg_color_bank; |
| 11 | 11 | |
| 12 | static colortable *digdug_colortable; | |
| 12 | 13 | |
| 13 | 14 | |
| 14 | 15 | /*************************************************************************** |
| r936 | r937 | |
| 34 | 35 | { |
| 35 | 36 | int i; |
| 36 | 37 | |
| 38 | digdug_colortable = colortable_alloc(machine, 32); | |
| 39 | ||
| 37 | 40 | for (i = 0;i < 32;i++) |
| 38 | 41 | { |
| 39 | 42 | int bit0,bit1,bit2,r,g,b; |
| r936 | r937 | |
| 50 | 53 | bit1 = (*color_prom >> 6) & 0x01; |
| 51 | 54 | bit2 = (*color_prom >> 7) & 0x01; |
| 52 | 55 | b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 53 | palette_set_color( | |
| 56 | colortable_palette_set_color(d | |
| 54 | 57 | color_prom++; |
| 55 | 58 | } |
| 56 | 59 | |
| 57 | 60 | /* characters - direct mapping */ |
| 58 | 61 | for (i = 0; i < 16; i++) |
| 59 | 62 | { |
| 60 | colortable[0] = 0; | |
| 61 | colortable[1] = i; | |
| 62 | colortable += 2; | |
| 63 | colortable_entry_set_value(digdug_colortable, i*2+0, 0); | |
| 64 | colortable_entry_set_value(digdug_colortable, i*2+1, i); | |
| 63 | 65 | } |
| 66 | ||
| 64 | 67 | /* sprites */ |
| 65 | 68 | for (i = 0;i < 0x100;i++) |
| 66 | *(colortable++) = (*(color_prom++) & 0x0f) + 0x10; | |
| 69 | colortable_entry_set_value(digdug_colortable, 16*2+i, (*color_prom++ & 0x0f) + 0x10); | |
| 70 | ||
| 67 | 71 | /* bg_select */ |
| 68 | 72 | for (i = 0;i < 0x100;i++) |
| 69 | | |
| 73 | colortable_entry_set_value(digdug_colortable, 16*2+256+i, | |
| 70 | 74 | } |
| 71 | 75 | |
| 72 | 76 | |
| r936 | r937 | |
| 288 | 292 | { |
| 289 | 293 | for (x = 0;x <= size;x++) |
| 290 | 294 | { |
| 295 | UINT32 transmask = colortable_get_transpen_mask(digdug_colortable, machine->gfx[1], color, 0x1f); | |
| 291 | 296 | drawgfx(bitmap,machine->gfx[1], |
| 292 | 297 | sprite + gfx_offs[y ^ (size * flipy)][x ^ (size * flipx)], |
| 293 | 298 | color, |
| 294 | 299 | flipx,flipy, |
| 295 | 300 | ((sx + 16*x) & 0xff), sy + 16*y, |
| 296 | &spritevisiblearea,TRANSPARENCY_ | |
| 301 | &spritevisiblearea,TRANSPARENCY_PENS | |
| 297 | 302 | /* wraparound */ |
| 298 | 303 | drawgfx(bitmap,machine->gfx[1], |
| 299 | 304 | sprite + gfx_offs[y ^ (size * flipy)][x ^ (size * flipx)], |
| 300 | 305 | color, |
| 301 | 306 | flipx,flipy, |
| 302 | 307 | ((sx + 16*x) & 0xff) + 0x100, sy + 16*y, |
| 303 | &spritevisiblearea,TRANSPARENCY_ | |
| 308 | &spritevisiblearea,TRANSPARENCY_PENS | |
| 304 | 309 | } |
| 305 | 310 | } |
| 306 | 311 | } |
| r936 | r937 | |
|---|---|---|
| 97 | 97 | |
| 98 | 98 | VIDEO_EOF( ultratnk ) |
| 99 | 99 | { |
| 100 | UINT16 BG = machine->gfx[0]->color | |
| 100 | UINT16 BG = machine->remapped_colortable[machine->gfx[0]->color_ | |
| 101 | 101 | |
| 102 | 102 | int i; |
| 103 | 103 |
| r936 | r937 | |
|---|---|---|
| 10 | 10 | |
| 11 | 11 | static mame_bitmap *sprite_bitmap; |
| 12 | 12 | |
| 13 | static | |
| 13 | static colo | |
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | /*************************************************************************** |
| r936 | r937 | |
| 44 | 44 | { |
| 45 | 45 | static const int resistances[3] = { 1000, 470, 220 }; |
| 46 | 46 | double rweights[3], gweights[3], bweights[2]; |
| 47 | rgb_t palette[32]; | |
| 48 | 47 | int i; |
| 49 | 48 | |
| 50 | 49 | /* compute the color output resistor weights */ |
| r936 | r937 | |
| 53 | 52 | 3, &resistances[0], gweights, 0, 0, |
| 54 | 53 | 2, &resistances[1], bweights, 0, 0); |
| 55 | 54 | |
| 55 | /* allocate the colortable */ | |
| 56 | mappy_colortable = colortable_alloc(machine, 32); | |
| 57 | ||
| 56 | 58 | /* create a lookup table for the palette */ |
| 57 | 59 | for (i = 0; i < 32; i++) |
| 58 | 60 | { |
| r936 | r937 | |
| 76 | 78 | bit1 = (color_prom[i] >> 7) & 0x01; |
| 77 | 79 | b = combine_2_weights(bweights, bit0, bit1); |
| 78 | 80 | |
| 79 | palette | |
| 81 | colortable_palette_set_color(mappy_colortable, i, | |
| 80 | 82 | } |
| 81 | 83 | |
| 82 | 84 | /* color_prom now points to the beginning of the lookup table */ |
| 83 | 85 | color_prom += 32; |
| 84 | 86 | |
| 85 | /* allocate memory for mask of pens that are transparent in sprites */ | |
| 86 | transmask = auto_malloc(64 * sizeof(transmask[0])); | |
| 87 | memset(transmask, 0, 64 * sizeof(transmask[0])); | |
| 88 | ||
| 89 | 87 | /* characters map to the upper 16 palette entries */ |
| 90 | 88 | for (i = 0; i < 64*4; i++) |
| 91 | 89 | { |
| 92 | 90 | UINT8 ctabentry = color_prom[i] & 0x0f; |
| 93 | | |
| 91 | colortable_ | |
| 94 | 92 | } |
| 95 | 93 | |
| 96 | 94 | /* sprites map to the lower 16 palette entries */ |
| 97 | 95 | for (i = 64*4; i < 128*4; i++) |
| 98 | 96 | { |
| 99 | 97 | UINT8 ctabentry = color_prom[i] & 0x0f; |
| 100 | palette_set_color(machine, i, palette[ctabentry]); | |
| 101 | ||
| 102 | /* if the color table maps to palette entry 15, it is transparent */ | |
| 103 | if (ctabentry == 15) | |
| 104 | transmask[(i - 64*4)/4] |= 1 << (i % 4); | |
| 98 | colortable_entry_set_value(mappy_colortable, i, ctabentry); | |
| 105 | 99 | } |
| 106 | 100 | } |
| 107 | 101 | |
| r936 | r937 | |
| 109 | 103 | { |
| 110 | 104 | static const int resistances[3] = { 1000, 470, 220 }; |
| 111 | 105 | double rweights[3], gweights[3], bweights[2]; |
| 112 | rgb_t palette[32]; | |
| 113 | 106 | int i; |
| 114 | 107 | |
| 115 | 108 | /* compute the color output resistor weights */ |
| r936 | r937 | |
| 118 | 111 | 3, &resistances[0], gweights, 0, 0, |
| 119 | 112 | 2, &resistances[1], bweights, 0, 0); |
| 120 | 113 | |
| 114 | /* allocate the colortable */ | |
| 115 | mappy_colortable = colortable_alloc(machine, 32); | |
| 116 | ||
| 121 | 117 | /* create a lookup table for the palette */ |
| 122 | 118 | for (i = 0; i < 32; i++) |
| 123 | 119 | { |
| r936 | r937 | |
| 141 | 137 | bit1 = (color_prom[i] >> 7) & 0x01; |
| 142 | 138 | b = combine_2_weights(bweights, bit0, bit1); |
| 143 | 139 | |
| 144 | palette | |
| 140 | colortable_palette_set_color(mappy_colortable, i, | |
| 145 | 141 | } |
| 146 | 142 | |
| 147 | 143 | /* color_prom now points to the beginning of the lookup table */ |
| 148 | 144 | color_prom += 32; |
| 149 | 145 | |
| 150 | /* allocate memory for mask of pens that are transparent in sprites */ | |
| 151 | transmask = auto_malloc(64 * sizeof(transmask[0])); | |
| 152 | memset(transmask, 0, 64 * sizeof(transmask[0])); | |
| 153 | ||
| 154 | 146 | /* characters map to the upper 16 palette entries */ |
| 155 | 147 | for (i = 0*4; i < 64*4; i++) |
| 156 | 148 | { |
| 157 | 149 | UINT8 ctabentry = color_prom[i] & 0x0f; |
| 158 | | |
| 150 | colortable_ | |
| 159 | 151 | } |
| 160 | 152 | |
| 161 | 153 | /* sprites map to the lower 16 palette entries */ |
| 162 | 154 | for (i = 64*4; i < machine->drv->total_colors; i++) |
| 163 | 155 | { |
| 164 | 156 | UINT8 ctabentry = color_prom[i] & 0x0f; |
| 165 | palette_set_color(machine, i, palette[ctabentry]); | |
| 166 | ||
| 167 | /* if the color table maps to palette entry 15, it is transparent */ | |
| 168 | if (ctabentry == 15) | |
| 169 | transmask[(i - 64*4)/16] |= 1 << (i % 16); | |
| 157 | colortable_entry_set_value(mappy_colortable, i, ctabentry); | |
| 170 | 158 | } |
| 171 | 159 | } |
| 172 | 160 | |
| r936 | r937 | |
| 186 | 174 | { |
| 187 | 175 | static const int resistances[4] = { 2200, 1000, 470, 220 }; |
| 188 | 176 | double rweights[4], gweights[4], bweights[4]; |
| 189 | rgb_t palette[32]; | |
| 190 | 177 | int i; |
| 191 | 178 | |
| 192 | 179 | /* compute the color output resistor weights */ |
| r936 | r937 | |
| 195 | 182 | 4, &resistances[0], gweights, 0, 0, |
| 196 | 183 | 4, &resistances[0], bweights, 0, 0); |
| 197 | 184 | |
| 185 | /* allocate the colortable */ | |
| 186 | mappy_colortable = colortable_alloc(machine, 32); | |
| 187 | ||
| 198 | 188 | /* create a lookup table for the palette */ |
| 199 | 189 | for (i = 0; i < 32; i++) |
| 200 | 190 | { |
| r936 | r937 | |
| 222 | 212 | bit3 = (color_prom[i + 0x200] >> 3) & 0x01; |
| 223 | 213 | b = combine_4_weights(bweights, bit0, bit1, bit2, bit3); |
| 224 | 214 | |
| 225 | palette | |
| 215 | colortable_palette_set_color(mappy_colortable, i, | |
| 226 | 216 | } |
| 227 | 217 | |
| 228 | 218 | /* color_prom now points to the beginning of the lookup table */ |
| 229 | 219 | color_prom += 0x300; |
| 230 | 220 | |
| 231 | /* allocate memory for mask of pens that are transparent in sprites */ | |
| 232 | transmask = auto_malloc(64 * sizeof(transmask[0])); | |
| 233 | memset(transmask, 0, 64 * sizeof(transmask[0])); | |
| 234 | ||
| 235 | 221 | /* characters map to the lower 16 palette entries */ |
| 236 | 222 | for (i = 0; i < 64*4; i++) |
| 237 | 223 | { |
| 238 | 224 | UINT8 ctabentry = color_prom[i] & 0x0f; |
| 239 | | |
| 225 | colortable_ | |
| 240 | 226 | } |
| 241 | 227 | |
| 242 | 228 | /* sprites map to the upper 16 palette entries */ |
| 243 | 229 | for (i = 64*4; i < 128*4; i++) |
| 244 | 230 | { |
| 245 | 231 | UINT8 ctabentry = color_prom[i] & 0x0f; |
| 246 | palette_set_color(machine, i, palette[ctabentry + 0x10]); | |
| 247 | ||
| 248 | /* if the color table maps to palette entry 15, it is transparent */ | |
| 249 | if (ctabentry == 15) | |
| 250 | transmask[(i - 64*4)/4] |= 1 << (i % 4); | |
| 232 | colortable_entry_set_value(mappy_colortable, i, ctabentry + 0x10); | |
| 251 | 233 | } |
| 252 | 234 | } |
| 253 | 235 | |
| r936 | r937 | |
| 300 | 282 | { |
| 301 | 283 | UINT8 attr = mappy_videoram[tile_index + 0x400]; |
| 302 | 284 | tileinfo->category = (attr & 0x40) >> 6; |
| 285 | tileinfo->group = attr & 0x3f; | |
| 303 | 286 | SET_TILE_INFO( |
| 304 | 287 | 0, |
| 305 | 288 | mappy_videoram[tile_index], |
| r936 | r937 | |
| 311 | 294 | { |
| 312 | 295 | UINT8 attr = mappy_videoram[tile_index + 0x400]; |
| 313 | 296 | tileinfo->category = (attr & 0x40) >> 6; |
| 297 | tileinfo->group = attr & 0x3f; | |
| 314 | 298 | SET_TILE_INFO( |
| 315 | 299 | 0, |
| 316 | 300 | mappy_videoram[tile_index] + ((attr & 0x80) << 1), |
| r936 | r937 | |
| 322 | 306 | { |
| 323 | 307 | UINT8 attr = mappy_videoram[tile_index + 0x800]; |
| 324 | 308 | tileinfo->category = (attr & 0x40) >> 6; |
| 309 | tileinfo->group = attr & 0x3f; | |
| 325 | 310 | SET_TILE_INFO( |
| 326 | 311 | 0, |
| 327 | 312 | mappy_videoram[tile_index], |
| r936 | r937 | |
| 339 | 324 | |
| 340 | 325 | VIDEO_START( superpac ) |
| 341 | 326 | { |
| 342 | bg_tilemap = tilemap_create(superpac_get_tile_info,superpac_tilemap_scan,TILEMAP_TYPE_ | |
| 327 | bg_tilemap = tilemap_create(superpac_get_tile_info,superpac_tilemap_scan,TILEMAP_TYPE_P | |
| 343 | 328 | sprite_bitmap = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format); |
| 344 | 329 | |
| 345 | tilemap_ | |
| 330 | colortable_configure_tilemap_g | |
| 346 | 331 | |
| 347 | 332 | spriteram = mappy_spriteram + 0x780; |
| 348 | 333 | spriteram_2 = spriteram + 0x800; |
| r936 | r937 | |
| 351 | 336 | |
| 352 | 337 | VIDEO_START( phozon ) |
| 353 | 338 | { |
| 354 | bg_tilemap = tilemap_create(phozon_get_tile_info,superpac_tilemap_scan,TILEMAP_TYPE_ | |
| 339 | bg_tilemap = tilemap_create(phozon_get_tile_info,superpac_tilemap_scan,TILEMAP_TYPE_P | |
| 355 | 340 | |
| 356 | tilemap_ | |
| 341 | colortable_configure_tilemap_g | |
| 357 | 342 | |
| 358 | 343 | spriteram = mappy_spriteram + 0x780; |
| 359 | 344 | spriteram_2 = spriteram + 0x800; |
| r936 | r937 | |
| 362 | 347 | |
| 363 | 348 | VIDEO_START( mappy ) |
| 364 | 349 | { |
| 365 | bg_tilemap = tilemap_create(mappy_get_tile_info,mappy_tilemap_scan,TILEMAP_TYPE_ | |
| 350 | bg_tilemap = tilemap_create(mappy_get_tile_info,mappy_tilemap_scan,TILEMAP_TYPE_P | |
| 366 | 351 | |
| 367 | tilemap_ | |
| 352 | colortable_configure_tilemap_g | |
| 368 | 353 | tilemap_set_scroll_cols(bg_tilemap, 36); |
| 369 | 354 | |
| 370 | 355 | spriteram = mappy_spriteram + 0x780; |
| r936 | r937 | |
| 417 | 402 | ***************************************************************************/ |
| 418 | 403 | |
| 419 | 404 | /* also used by toypop.c */ |
| 420 | void mappy_draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int xoffs, int yoffs, co | |
| 405 | void mappy_draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int xoffs, int yoffs, colortable | |
| 421 | 406 | { |
| 422 | 407 | int offs; |
| 423 | 408 | |
| r936 | r937 | |
| 462 | 447 | color, |
| 463 | 448 | flipx,flipy, |
| 464 | 449 | sx + 16*x,sy + 16*y, |
| 465 | cliprect,TRANSPARENCY_PENS,transmask_table[color & 0x3f]); | |
| 450 | cliprect,TRANSPARENCY_PENS, | |
| 451 | colortable_get_transpen_mask(ctable, machine->gfx[1], color, transcolor)); | |
| 466 | 452 | } |
| 467 | 453 | } |
| 468 | 454 | } |
| r936 | r937 | |
| 536 | 522 | color, |
| 537 | 523 | flipx,flipy, |
| 538 | 524 | sx + 8*x,sy + 8*y, |
| 539 | cliprect,TRANSPARENCY_PENS,transmask[color & 0x3f]); | |
| 525 | cliprect,TRANSPARENCY_PENS, | |
| 526 | colortable_get_transpen_mask(mappy_colortable, machine->gfx[1], color, 31)); | |
| 540 | 527 | } |
| 541 | 528 | } |
| 542 | 529 | } |
| r936 | r937 | |
| 552 | 539 | tilemap_draw(bitmap,cliprect,bg_tilemap,1|TILEMAP_DRAW_OPAQUE,0); |
| 553 | 540 | |
| 554 | 541 | fillbitmap(sprite_bitmap,15,cliprect); |
| 555 | mappy_draw_sprites(machine,sprite_bitmap,cliprect,0,0, | |
| 542 | mappy_draw_sprites(machine,sprite_bitmap,cliprect,0,0, | |
| 556 | 543 | copybitmap(bitmap,sprite_bitmap,0,0,0,0,cliprect,TRANSPARENCY_PEN,15); |
| 557 | 544 | |
| 558 | 545 | /* Redraw the high priority characters */ |
| r936 | r937 | |
| 595 | 582 | tilemap_draw(bitmap,cliprect,bg_tilemap,0|TILEMAP_DRAW_OPAQUE,0); |
| 596 | 583 | tilemap_draw(bitmap,cliprect,bg_tilemap,1|TILEMAP_DRAW_OPAQUE,0); |
| 597 | 584 | |
| 598 | mappy_draw_sprites(machine,bitmap,cliprect,0,0, | |
| 585 | mappy_draw_sprites(machine,bitmap,cliprect,0,0, | |
| 599 | 586 | |
| 600 | 587 | /* Redraw the high priority characters */ |
| 601 | 588 | tilemap_draw(bitmap,cliprect,bg_tilemap,1,0); |
| r936 | r937 | |
|---|---|---|
| 436 | 436 | else { ystart = 0; yend = high; yinc = +1; } |
| 437 | 437 | |
| 438 | 438 | /* Start drawing */ |
| 439 | if( gfx | |
| 439 | if( gfx | |
| 440 | 440 | { |
| 441 | 441 | for (ytile = ystart; ytile != yend; ytile += yinc ) |
| 442 | 442 | { |
| 443 | 443 | for (xtile = xstart; xtile != xend; xtile += xinc ) |
| 444 | 444 | { |
| 445 | const pen_t *pal = & | |
| 445 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 446 | 446 | int source_base = ((code + code_offset++) % gfx->total_elements) * gfx->height; |
| 447 | 447 | |
| 448 | 448 | int x_index_base, y_index, sx, sy, ex, ey; |
| r936 | r937 | |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | /* Start drawing */ |
| 707 | if( gfx | |
| 707 | if( gfx | |
| 708 | 708 | { |
| 709 | const pen_t *pal = & | |
| 709 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 710 | 710 | |
| 711 | 711 | int sprite_screen_height = ((high*gfx->height*(0x400*0x400))/zoomy + 0x200)>>10; /* Round up to nearest pixel */ |
| 712 | 712 | int sprite_screen_width = ((wide*gfx->width*(0x400*0x400))/zoomx + 0x200)>>10; |
| r936 | r937 | |
|---|---|---|
| 323 | 323 | rect.max_y = ypos + 2 * BGHEIGHT - 1; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | fillbitmap(bitmap, machine->gfx[image]->color | |
| 326 | fillbitmap(bitmap, machine->remapped_colortable[machine->gfx[image]->color_ | |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 |
| r936 | r937 | |
|---|---|---|
| 34 | 34 | static int bgcolor[4]; |
| 35 | 35 | static rectangle halfclip; |
| 36 | 36 | static struct PRESTEP_TYPE { unsigned sy, fdx; } *prestep; |
| 37 | static colortable *equites_colortable; | |
| 37 | 38 | |
| 38 | 39 | /******************************************************************************/ |
| 39 | 40 | // Exports |
| r936 | r937 | |
| 45 | 46 | |
| 46 | 47 | static void video_init_common(running_machine *machine) |
| 47 | 48 | { |
| 48 | pen_t *colortable; | |
| 49 | 49 | int i; |
| 50 | 50 | |
| 51 | colortable = machine->remapped_colortable; | |
| 52 | ||
| 53 | 51 | // set defaults |
| 54 | 52 | maskwidth = 8; |
| 55 | 53 | maskheight = machine->screen[0].visarea.max_y - machine->screen[0].visarea.min_y + 1; |
| r936 | r937 | |
| 80 | 78 | UINT8 *clut_ptr; |
| 81 | 79 | int i; |
| 82 | 80 | |
| 81 | equites_colortable = colortable_alloc(machine, 256); | |
| 82 | ||
| 83 | 83 | for (i=0; i<256; i++) |
| 84 | { | |
| 85 | palette_set_color_rgb(machine, i, pal4bit(color_prom[i]), pal4bit(color_prom[i+0x100]), pal4bit(color_prom[i+0x200])); | |
| 86 | colortable[i] = i; | |
| 87 | } | |
| 84 | colortable_palette_set_color(equites_colortable, i, MAKE_RGB(pal4bit(color_prom[i]), pal4bit(color_prom[i+0x100]), pal4bit(color_prom[i+0x200]))); | |
| 88 | 85 | |
| 86 | for (i=0; i<256; i++) | |
| 87 | colortable_entry_set_value(equites_colortable, i, i); | |
| 88 | ||
| 89 | 89 | clut_ptr = memory_region(REGION_USER1) + 0x80; |
| 90 | 90 | for (i=0; i<128; i++) |
| 91 | colortable | |
| 91 | colortable_entry_set_value(equites_colortable, i+0x100, | |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | static TILE_GET_INFO( equites_charinfo ) |
| r936 | r937 | |
| 120 | 120 | UINT8 *prom_ptr; |
| 121 | 121 | int i; |
| 122 | 122 | |
| 123 | equites_colortable = colortable_alloc(machine, 256); | |
| 124 | ||
| 123 | 125 | for (i=0; i<0x100; i++) |
| 124 | { | |
| 125 | palette_set_color_rgb(machine, i, pal4bit(color_prom[i]), pal4bit(color_prom[i+0x100]), pal4bit(color_prom[i+0x200])); | |
| 126 | colortable[i] = (i & 3 || (i > 0x3f && i < 0x80) || i > 0xbf) ? i : 0; | |
| 126 | colortable_palette_set_color(equites_colortable, i, MAKE_RGB(pal4bit(color_prom[i]), pal4bit(color_prom[i+0x100]), pal4bit(color_prom[i+0x200]))); | |
| 127 | 127 | |
| 128 | } | |
| 128 | for (i = 0; i < 0x100; i++) | |
| 129 | colortable_entry_set_value(equites_colortable, i, i); | |
| 130 | ||
| 129 | 131 | prom_ptr = memory_region(REGION_USER1); |
| 130 | colortable += 0x100; | |
| 131 | for (i=0; i<0x80; i++) { colortable[i] = prom_ptr[i]+0x10; colortable[i+0x80] = prom_ptr[i]; } | |
| 132 | for (i=0; i<0x80; i++) | |
| 133 | { | |
| 134 | colortable_entry_set_value(equites_colortable, i + 0x100, prom_ptr[i] + 0x10); | |
| 135 | colortable_entry_set_value(equites_colortable, i + 0x180, prom_ptr[i]); | |
| 136 | } | |
| 132 | 137 | |
| 133 | 138 | prom_ptr += 0x100; |
| 134 | colortable += 0x100; | |
| 135 | for (i=0; i<0x400; i++) colortable[i] = prom_ptr[i]; | |
| 139 | for (i=0; i<0x400; i++) | |
| 140 | colortable_entry_set_value(equites_colortable, i + 0x200, prom_ptr[i]); | |
| 136 | 141 | } |
| 137 | 142 | |
| 138 | 143 | static TILE_GET_INFO( splndrbt_char0info ) |
| r936 | r937 | |
| 146 | 151 | color &= 0x3f; |
| 147 | 152 | |
| 148 | 153 | SET_TILE_INFO(0, tile, color, 0); |
| 154 | if (color & 0x10) | |
| 155 | tileinfo->flags |= TILE_FORCE_LAYER0; | |
| 149 | 156 | } |
| 150 | 157 | |
| 151 | 158 | static TILE_GET_INFO( splndrbt_char1info ) |
| r936 | r937 | |
| 160 | 167 | tile += 0x100; |
| 161 | 168 | |
| 162 | 169 | SET_TILE_INFO(0, tile, color, 0); |
| 170 | if (color & 0x10) | |
| 171 | tileinfo->flags |= TILE_FORCE_LAYER0; | |
| 163 | 172 | } |
| 164 | 173 | |
| 165 | 174 | static void splndrbt_video_reset(void) |
| r936 | r937 | |
| 224 | 233 | |
| 225 | 234 | tmpbitmap = auto_bitmap_alloc(BMW, BMW, machine->screen[0].format); |
| 226 | 235 | |
| 227 | charmap0 = tilemap_create(splndrbt_char0info, tilemap_scan_cols, TILEMAP_TYPE_ | |
| 236 | charmap0 = tilemap_create(splndrbt_char0info, tilemap_scan_cols, TILEMAP_TYPE_P | |
| 228 | 237 | tilemap_set_transparent_pen(charmap0, 0); |
| 229 | 238 | tilemap_set_scrolldx(charmap0, 8, 8); |
| 230 | 239 | tilemap_set_scrolldy(charmap0, 32, 32); |
| 231 | 240 | |
| 232 | charmap1 = tilemap_create(splndrbt_char1info, tilemap_scan_cols, TILEMAP_TYPE_ | |
| 241 | charmap1 = tilemap_create(splndrbt_char1info, tilemap_scan_cols, TILEMAP_TYPE_P | |
| 233 | 242 | tilemap_set_transparent_pen(charmap1, 0); |
| 234 | 243 | tilemap_set_scrolldx(charmap1, 8, 8); |
| 235 | 244 | tilemap_set_scrolldy(charmap1, 32, 32); |
| r936 | r937 | |
| 261 | 270 | // Equites Hardware |
| 262 | 271 | static void equites_update_clut(running_machine *machine) |
| 263 | 272 | { |
| 264 | pen_t *colortable; | |
| 265 | 273 | int i, c; |
| 266 | 274 | |
| 267 | | |
| 275 | /* p | |
| 268 | 276 | c = *bgcolor; |
| 269 | 277 | |
| 270 | for (i=0x80; i<0x100; i+=0x08) colortable[i] = c; | |
| 278 | for (i=0x80; i<0x100; i+=0x08) | |
| 279 | colortable_entry_set_value(equites_colortable, i, c); | |
| 271 | 280 | } |
| 272 | 281 | |
| 273 | 282 | static void equites_draw_scroll(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect) |
| r936 | r937 | |
| 381 | 390 | // Splendor Blast Hardware |
| 382 | 391 | static void splndrbt_update_clut(running_machine *machine) |
| 383 | 392 | { |
| 384 | pen_t *colortable; | |
| 385 | 393 | int c; |
| 386 | 394 | |
| 387 | | |
| 395 | /* p | |
| 388 | 396 | c = *bgcolor; |
| 389 | 397 | |
| 390 | 398 | switch(equites_id) |
| 391 | 399 | { |
| 392 | 400 | case 0x8511: |
| 393 | colortable | |
| 401 | colortable_entry_set_value(equites_colortable, 0x114, | |
| 394 | 402 | break; |
| 395 | 403 | } |
| 396 | 404 | } |
| r936 | r937 | |
| 437 | 445 | unsigned dst_startw, unsigned dst_endw, |
| 438 | 446 | struct PRESTEP_TYPE *ps) |
| 439 | 447 | { |
| 440 | #define W | |
| 448 | #define W | |
| 441 | 449 | |
| 442 | UINT16 *src_base, *src_ptr, *dst_ptr; | |
| 443 | int src_pitch, dst_pitch, dst_wdiff, dst_visw, dst_vish; | |
| 444 | int dst_curline, dst_xend, src_fsx, src_fdx, eax, ebx, ecx, edx; | |
| 450 | int src_center_x = ((src_x + (src_w>>1)) & WRAP) << FP_PRECISION; | |
| 451 | int dst_pitch, dst_wdiff, dst_visw, dst_vish; | |
| 452 | int dst_curline; | |
| 445 | 453 | |
| 446 | src_base = (UINT16*)src_bitmap->base; | |
| 447 | src_pitch = src_bitmap->rowpixels; | |
| 448 | ebx = ((src_x + (src_w>>1)) & WARP) << FP_PRECISION; | |
| 449 | ||
| 450 | eax = dst_clip->min_x; | |
| 451 | edx = dst_clip->min_y; | |
| 452 | dst_visw = dst_clip->max_x - eax + 1; | |
| 453 | dst_vish = dst_clip->max_y - edx; | |
| 454 | dst_visw = dst_clip->max_x - dst_clip->min_x + 1; | |
| 455 | dst_vish = dst_clip->max_y - dst_clip->min_y; | |
| 454 | 456 | dst_pitch = dst_bitmap->rowpixels; |
| 455 | dst_ptr = (UINT16*)dst_bitmap->base + edx * dst_pitch + eax + (dst_visw >> 1); | |
| 456 | 457 | |
| 457 | 458 | dst_wdiff = dst_endw - dst_startw; |
| 458 | dst_curline = 0; | |
| 459 | 459 | |
| 460 | | |
| 460 | for (dst_curline = dst_clip->min_y; dst_curline <= dst_clip->max_y; dst_curline++) | |
| 461 | 461 | { |
| 462 | dst_xend = dst_startw + (dst_wdiff * dst_curline) / dst_vish; | |
| 463 | eax = (src_y + ps[dst_curline].sy) & WARP; | |
| 464 | src_fdx = ps[dst_curline].fdx; | |
| 465 | src_ptr = src_base + src_pitch * eax; | |
| 462 | const UINT16 *src_ptr = BITMAP_ADDR16(src_bitmap, (src_y + ps[dst_curline - dst_clip->min_y].sy) & WRAP, 0); | |
| 463 | UINT16 *dst_ptr = BITMAP_ADDR16(dst_bitmap, dst_curline, dst_clip->min_x + dst_visw / 2); | |
| 464 | int dst_xend = dst_startw + (dst_wdiff * (dst_curline - dst_clip->min_y)) / dst_vish; | |
| 465 | int src_fsx = FP_HALF; | |
| 466 | int src_fdx = ps[dst_curline - dst_clip->min_y].fdx; | |
| 467 | int dst_x; | |
| 468 | ||
| 466 | 469 | if (dst_xend > dst_visw) dst_xend = dst_visw; |
| 467 | src_fsx = FP_HALF; | |
| 468 | dst_xend >>= 1; | |
| 469 | ecx = 0; | |
| 470 | dst_xend /= 2; | |
| 470 | 471 | |
| 471 | | |
| 472 | for (dst_x = 0; dst_x < dst_xend; dst_x++) | |
| 472 | 473 | { |
| 473 | eax = ebx - src_fsx; | |
| 474 | edx = ebx + src_fsx; | |
| 474 | dst_ptr[-dst_x - 1] = src_ptr[((src_center_x - src_fsx) >> FP_PRECISION) & WRAP]; | |
| 475 | dst_ptr[dst_x] = src_ptr[((src_center_x + src_fsx) >> FP_PRECISION) & WRAP]; | |
| 475 | 476 | src_fsx += src_fdx; |
| 476 | eax >>= FP_PRECISION; | |
| 477 | edx >>= FP_PRECISION; | |
| 478 | eax &= WARP; | |
| 479 | edx &= WARP; | |
| 480 | eax = *(src_ptr + eax); | |
| 481 | edx = *(src_ptr + edx); | |
| 482 | *(dst_ptr - ecx - 1) = eax; | |
| 483 | *(dst_ptr + ecx) = edx; | |
| 484 | 477 | } |
| 485 | while(++ecx < dst_xend); | |
| 486 | ||
| 487 | dst_ptr += dst_pitch; | |
| 488 | 478 | } |
| 489 | while(++dst_curline <= dst_vish); | |
| 490 | 479 | |
| 491 | #undef W | |
| 480 | #undef W | |
| 492 | 481 | } |
| 493 | 482 | |
| 494 | 483 | static void splndrbt_draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *clip) |
| r936 | r937 | |
|---|---|---|
| 17 | 17 | int offs, pri_code; |
| 18 | 18 | int sortedlist[NUM_SPRITES]; |
| 19 | 19 | |
| 20 | machine->gfx[0]->color | |
| 20 | machine->gfx[0]->color_ | |
| 21 | 21 | |
| 22 | 22 | for (offs = 0; offs < NUM_SPRITES; offs++) |
| 23 | 23 | sortedlist[offs] = -1; |
| r936 | r937 | |
|---|---|---|
| 47 | 47 | |
| 48 | 48 | /*****************************************************************************/ |
| 49 | 49 | |
| 50 | #ifdef LSB_FIRST | |
| 51 | #define BYTE_ADDR_XOR 3 | |
| 52 | #define WORD_ADDR_XOR 1 | |
| 53 | #else | |
| 54 | #define BYTE_ADDR_XOR 0 | |
| 55 | #define WORD_ADDR_XOR 0 | |
| 56 | #endif | |
| 50 | #define BYTE_ADDR_XOR BYTE4_XOR_BE(0) | |
| 51 | #define WORD_ADDR_XOR (WORD_XOR_BE(0) >> 1) | |
| 57 | 52 | |
| 58 | 53 | typedef struct |
| 59 | 54 | { |
| r936 | r937 | |
| 815 | 810 | { |
| 816 | 811 | switch (tsize) |
| 817 | 812 | { |
| 818 | case 0: break; | |
| 819 | case 1: break; // FIXME?: Extreme-G 2 does this | |
| 813 | case 0: | |
| 814 | color->r = color->g = color->b = color->a = 0xff; | |
| 815 | break; | |
| 816 | case 1: | |
| 817 | // FIXME?: Extreme-G 2 does this | |
| 818 | color->r = color->g = color->b = color->a = 0xff; | |
| 819 | break; | |
| 820 | 820 | case PIXEL_SIZE_16BIT: |
| 821 | 821 | { |
| 822 | 822 | UINT16 *tc = (UINT16*)texture_cache; |
| r936 | r937 | |
| 841 | 841 | color->a = ((c >> 0) & 0xff); |
| 842 | 842 | break; |
| 843 | 843 | } |
| 844 | default: fatalerror("FETCH_TEXEL: unknown RGBA texture size %d\n", tsize); break; | |
| 844 | default: | |
| 845 | color->r = color->g = color->b = color->a = 0xff; | |
| 846 | fatalerror("FETCH_TEXEL: unknown RGBA texture size %d\n", tsize); | |
| 847 | break; | |
| 845 | 848 | } |
| 846 | 849 | break; |
| 847 | 850 | } |
| r936 | r937 | |
| 891 | 894 | } |
| 892 | 895 | break; |
| 893 | 896 | } |
| 894 | case 2: break; // FIXME?: Clay Fighter Sculptor's Cut does this.. | |
| 895 | default: fatalerror("FETCH_TEXEL: unknown CI texture size %d\n", tsize); break; | |
| 897 | case 2: | |
| 898 | // FIXME?: Clay Fighter Sculptor's Cut does this.. | |
| 899 | color->r = color->g = color->b = color->a = 0xff; | |
| 900 | break; | |
| 901 | default: | |
| 902 | color->r = color->g = color->b = color->a = 0xff; | |
| 903 | fatalerror("FETCH_TEXEL: unknown CI texture size %d\n", tsize); | |
| 904 | break; | |
| 896 | 905 | } |
| 897 | 906 | break; |
| 898 | 907 | } |
| r936 | r937 | |
| 939 | 948 | color->a = c & 0xff; |
| 940 | 949 | break; |
| 941 | 950 | } |
| 942 | default: fatalerror("FETCH_TEXEL: unknown IA texture size %d\n", tsize); break; | |
| 951 | default: | |
| 952 | color->r = color->g = color->b = color->a = 0xff; | |
| 953 | fatalerror("FETCH_TEXEL: unknown IA texture size %d\n", tsize); | |
| 954 | break; | |
| 943 | 955 | } |
| 944 | 956 | break; |
| 945 | 957 | } |
| r936 | r937 | |
| 972 | 984 | color->a = c; |
| 973 | 985 | break; |
| 974 | 986 | } |
| 975 | default: fatalerror("FETCH_TEXEL: unknown I texture size %d\n", tsize); break; | |
| 987 | default: | |
| 988 | color->r = color->g = color->b = color->a = 0xff; | |
| 989 | fatalerror("FETCH_TEXEL: unknown I texture size %d\n", tsize); | |
| 990 | break; | |
| 976 | 991 | } |
| 977 | 992 | break; |
| 978 | 993 | } |
| 979 | 994 | default: |
| 980 | 995 | { |
| 996 | color->r = color->g = color->b = color->a = 0xff; | |
| 981 | 997 | fatalerror("FETCH_TEXEL: unknown texture format %d\n", tformat); |
| 982 | 998 | break; |
| 983 | 999 | } |
| r936 | r937 | |
|---|---|---|
| 368 | 368 | UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, |
| 369 | 369 | const rectangle *clip,int scalex, int scaley) |
| 370 | 370 | { |
| 371 | const pen_t *pal = & | |
| 371 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 372 | 372 | UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| 373 | 373 | |
| 374 | 374 | int sprite_screen_height = (scaley*gfx->height+0x8000)>>16; |
| r936 | r937 | |
|---|---|---|
| 664 | 664 | |
| 665 | 665 | /* draw background ram */ |
| 666 | 666 | { |
| 667 | pen_t *pens = &machine->pens[ 32 ]; //change it later | |
| 667 | const pen_t *pens = &machine->pens[ 32 ]; //change it later | |
| 668 | 668 | |
| 669 | 669 | UINT32 h,v; |
| 670 | 670 | UINT8 * romBxx = memory_region(REGION_USER1) + 0x2000*background_romsel; |
| r936 | r937 | |
| 778 | 778 | |
| 779 | 779 | /* draw background ram */ |
| 780 | 780 | { |
| 781 | pen_t *pens = &machine->pens[ 0x00 ]; | |
| 781 | const pen_t *pens = &machine->pens[ 0x00 ]; | |
| 782 | 782 | |
| 783 | 783 | UINT32 h,v; |
| 784 | 784 | UINT8 * rom13D = memory_region(REGION_USER1); |
| r936 | r937 | |
|---|---|---|
| 187 | 187 | { |
| 188 | 188 | int sx,sy,col,row,height,src,adjy,dy; |
| 189 | 189 | UINT8 *spr_reg; |
| 190 | pen_t *spr_palette; | |
| 190 | const pen_t *spr_palette; | |
| 191 | 191 | short skip; /* bytes to skip before drawing each row (can be negative) */ |
| 192 | 192 | |
| 193 | 193 |
| r936 | r937 | |
|---|---|---|
| 13 | 13 | |
| 14 | 14 | static int vulgus_palette_bank; |
| 15 | 15 | static tilemap *fg_tilemap, *bg_tilemap; |
| 16 | static colortable *vulgus_colortable; | |
| 16 | 17 | |
| 17 | 18 | |
| 18 | 19 | /*************************************************************************** |
| r936 | r937 | |
| 24 | 25 | PALETTE_INIT( vulgus ) |
| 25 | 26 | { |
| 26 | 27 | int i; |
| 27 | #define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity) | |
| 28 | #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs]) | |
| 29 | 28 | |
| 29 | vulgus_colortable = colortable_alloc(machine, 256); | |
| 30 | 30 | |
| 31 | for (i = 0;i < | |
| 31 | for (i = 0;i < 256 | |
| 32 | 32 | { |
| 33 | 33 | int bit0,bit1,bit2,bit3,r,g,b; |
| 34 | 34 | |
| 35 | ||
| 36 | 35 | bit0 = (color_prom[0] >> 0) & 0x01; |
| 37 | 36 | bit1 = (color_prom[0] >> 1) & 0x01; |
| 38 | 37 | bit2 = (color_prom[0] >> 2) & 0x01; |
| 39 | 38 | bit3 = (color_prom[0] >> 3) & 0x01; |
| 40 | 39 | r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; |
| 41 | bit0 = (color_prom[machine->drv->total_colors] >> 0) & 0x01; | |
| 42 | bit1 = (color_prom[machine->drv->total_colors] >> 1) & 0x01; | |
| 43 | bit2 = (color_prom[machine->drv->total_colors] >> 2) & 0x01; | |
| 44 | bit3 = (color_prom[machine->drv->total_colors] >> 3) & 0x01; | |
| 40 | bit0 = (color_prom[256] >> 0) & 0x01; | |
| 41 | bit1 = (color_prom[256] >> 1) & 0x01; | |
| 42 | bit2 = (color_prom[256] >> 2) & 0x01; | |
| 43 | bit3 = (color_prom[256] >> 3) & 0x01; | |
| 45 | 44 | g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; |
| 46 | bit0 = (color_prom[2*machine->drv->total_colors] >> 0) & 0x01; | |
| 47 | bit1 = (color_prom[2*machine->drv->total_colors] >> 1) & 0x01; | |
| 48 | bit2 = (color_prom[2*machine->drv->total_colors] >> 2) & 0x01; | |
| 49 | bit3 = (color_prom[2*machine->drv->total_colors] >> 3) & 0x01; | |
| 45 | bit0 = (color_prom[2*256] >> 0) & 0x01; | |
| 46 | bit1 = (color_prom[2*256] >> 1) & 0x01; | |
| 47 | bit2 = (color_prom[2*256] >> 2) & 0x01; | |
| 48 | bit3 = (color_prom[2*256] >> 3) & 0x01; | |
| 50 | 49 | b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; |
| 51 | 50 | |
| 52 | palette_set_color( | |
| 51 | colortable_palette_set_color(vulgus_colortable,i,MAKE_RGB(r,g,b)); | |
| 53 | 52 | color_prom++; |
| 54 | 53 | } |
| 55 | 54 | |
| 56 | color_prom += 2* | |
| 55 | color_prom += 2*256 | |
| 57 | 56 | /* color_prom now points to the beginning of the lookup table */ |
| 58 | 57 | |
| 59 | 58 | |
| 60 | 59 | /* characters use colors 32-47 (?) */ |
| 61 | for (i = 0;i < TOTAL_COLORS(0);i++) | |
| 62 | COLOR(0,i) = *(color_prom++) + 32; | |
| 60 | for (i = 0;i < machine->gfx[0]->total_colors * machine->gfx[0]->color_granularity;i++) | |
| 61 | colortable_entry_set_value(vulgus_colortable, machine->gfx[0]->color_base + i, 32 + *color_prom++); | |
| 63 | 62 | |
| 64 | 63 | /* sprites use colors 16-31 */ |
| 65 | for (i = 0;i < TOTAL_COLORS(2);i++) | |
| 66 | { | |
| 67 | COLOR(2,i) = *(color_prom++) + 16; | |
| 68 | } | |
| 64 | for (i = 0;i < machine->gfx[2]->total_colors * machine->gfx[2]->color_granularity;i++) | |
| 65 | colortable_entry_set_value(vulgus_colortable, machine->gfx[2]->color_base + i, 16 + *color_prom++); | |
| 69 | 66 | |
| 70 | 67 | /* background tiles use colors 0-15, 64-79, 128-143, 192-207 in four banks */ |
| 71 | for (i = 0;i < | |
| 68 | for (i = 0;i < machine->gfx[1]->total_colors * machine->gfx[1]->color_granularity / 4;i++) | |
| 72 | 69 | { |
| 73 | COLOR(1,i) = *color_prom; | |
| 74 | COLOR(1,i+32*8) = *color_prom + 64; | |
| 75 | COLOR(1,i+2*32*8) = *color_prom + 128; | |
| 76 | COLOR(1,i+3*32*8) = *color_prom + 192; | |
| 70 | colortable_entry_set_value(vulgus_colortable, machine->gfx[1]->color_base + 0*32*8 + i, *color_prom); | |
| 71 | colortable_entry_set_value(vulgus_colortable, machine->gfx[1]->color_base + 1*32*8 + i, *color_prom + 64); | |
| 72 | colortable_entry_set_value(vulgus_colortable, machine->gfx[1]->color_base + 2*32*8 + i, *color_prom + 128); | |
| 73 | colortable_entry_set_value(vulgus_colortable, machine->gfx[1]->color_base + 3*32*8 + i, *color_prom + 192); | |
| 77 | 74 | color_prom++; |
| 78 | 75 | } |
| 79 | 76 | } |
| r936 | r937 | |
| 96 | 93 | code + ((color & 0x80) << 1), |
| 97 | 94 | color & 0x3f, |
| 98 | 95 | 0); |
| 96 | tileinfo->group = color & 0x3f; | |
| 99 | 97 | } |
| 100 | 98 | |
| 101 | 99 | static TILE_GET_INFO( get_bg_tile_info ) |
| r936 | r937 | |
| 120 | 118 | |
| 121 | 119 | VIDEO_START( vulgus ) |
| 122 | 120 | { |
| 123 | fg_tilemap = tilemap_create(get_fg_tile_info,tilemap_scan_rows,TILEMAP_TYPE_COLORTABLE, 8, 8,32,32); | |
| 124 | bg_tilemap = tilemap_create(get_bg_tile_info,tilemap_scan_cols,TILEMAP_TYPE_PEN ,16,16,32,32); | |
| 121 | fg_tilemap = tilemap_create(get_fg_tile_info,tilemap_scan_rows,TILEMAP_TYPE_PEN, 8, 8,32,32); | |
| 122 | bg_tilemap = tilemap_create(get_bg_tile_info,tilemap_scan_cols,TILEMAP_TYPE_PEN,16,16,32,32); | |
| 125 | 123 | |
| 126 | tilemap_s | |
| 124 | colortable_configure_tilemap_groups(vulgus_colortabl | |
| 127 | 125 | } |
| 128 | 126 | |
| 129 | 127 |
| r936 | r937 | |
|---|---|---|
| 202 | 202 | static void ripcord_draw_skydiver(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect) |
| 203 | 203 | { |
| 204 | 204 | const gfx_element *gfx; |
| 205 | pen_t *pal_ptr; | |
| 205 | const pen_t *pal_ptr; | |
| 206 | 206 | UINT8 *src_lineptr, *src_pixptr; |
| 207 | 207 | UINT16 *dst_lineptr, *dst_lineend; |
| 208 | 208 | UINT32 code, color; |
| r936 | r937 | |
| 222 | 222 | edx = 1; |
| 223 | 223 | |
| 224 | 224 | gfx = machine->gfx[1]; |
| 225 | pal_ptr = | |
| 225 | pal_ptr = &machine->remapped_colortable[gfx->color_base + color * gfx->color_granularity]; | |
| 226 | 226 | src_lineptr = gfx->gfxdata + code * gfx->char_modulo; |
| 227 | 227 | src_pitch = gfx->line_modulo; |
| 228 | 228 | dst_pitch = bitmap->rowpixels; |
| r936 | r937 | |
|---|---|---|
| 1362 | 1362 | UINT32 orient, |
| 1363 | 1363 | int skip_layer_num) |
| 1364 | 1364 | { |
| 1365 | pen_t *clut = &machine->remapped_colortable[0]; | |
| 1365 | const pen_t *clut = &machine->remapped_colortable[0]; | |
| 1366 | 1366 | UINT32 bgcolor=clut[0]; |
| 1367 | 1367 | int length; |
| 1368 | 1368 | |
| r936 | r937 | |
| 2664 | 2664 | } |
| 2665 | 2665 | |
| 2666 | 2666 | |
| 2667 | if( gfx | |
| 2667 | if( gfx | |
| 2668 | 2668 | { |
| 2669 | const pen_t *pal = & | |
| 2669 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 2670 | 2670 | int source_base = (code % gfx->total_elements) * 16; |
| 2671 | 2671 | |
| 2672 | 2672 | { |
| r936 | r937 | |
| 2828 | 2828 | } |
| 2829 | 2829 | |
| 2830 | 2830 | |
| 2831 | if( gfx | |
| 2831 | if( gfx | |
| 2832 | 2832 | { |
| 2833 | const pen_t *pal = & | |
| 2833 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 2834 | 2834 | int source_base = (code % gfx->total_elements) * 16; |
| 2835 | 2835 | |
| 2836 | 2836 | { |
| r936 | r937 | |
|---|---|---|
| 357 | 357 | */ |
| 358 | 358 | const UINT16 *gfx_data = gfx_base + (code&0x7ff)*16 + bank_table[(code>>11)&0x3]*0x8000; |
| 359 | 359 | int color = (code>>13); |
| 360 | pen_t *pal_data = Machine->pens + 16*(0x20+color+8*palette); | |
| 360 | const pen_t *pal_data = Machine->pens + 16*(0x20+color+8*palette); | |
| 361 | 361 | |
| 362 | 362 | { |
| 363 | 363 | int y; |
| r936 | r937 | |
|---|---|---|
| 20 | 20 | #include "includes/pacman.h" |
| 21 | 21 | #include "video/resnet.h" |
| 22 | 22 | |
| 23 | static colortable *pacman_colortable; | |
| 23 | 24 | static tilemap *bg_tilemap; |
| 24 | static UINT8 *transmask; | |
| 25 | 25 | static UINT8 charbank; |
| 26 | 26 | static UINT8 spritebank; |
| 27 | 27 | static UINT8 palettebank; |
| r936 | r937 | |
| 84 | 84 | { |
| 85 | 85 | static const int resistances[3] = { 1000, 470, 220 }; |
| 86 | 86 | double rweights[3], gweights[3], bweights[2]; |
| 87 | rgb_t palette[32]; | |
| 88 | 87 | int i; |
| 89 | 88 | |
| 90 | 89 | /* compute the color output resistor weights */ |
| r936 | r937 | |
| 93 | 92 | 3, &resistances[0], gweights, 0, 0, |
| 94 | 93 | 2, &resistances[1], bweights, 0, 0); |
| 95 | 94 | |
| 95 | /* allocate the colortable */ | |
| 96 | pacman_colortable = colortable_alloc(machine, 32); | |
| 97 | ||
| 96 | 98 | /* create a lookup table for the palette */ |
| 97 | 99 | for (i = 0; i < 32; i++) |
| 98 | 100 | { |
| r936 | r937 | |
| 116 | 118 | bit1 = (color_prom[i] >> 7) & 0x01; |
| 117 | 119 | b = combine_2_weights(bweights, bit0, bit1); |
| 118 | 120 | |
| 119 | palette | |
| 121 | colortable_palette_set_color(pacman_colortable, i, | |
| 120 | 122 | } |
| 121 | 123 | |
| 122 | 124 | /* color_prom now points to the beginning of the lookup table */ |
| 123 | 125 | color_prom += 32; |
| 124 | 126 | |
| 125 | /* allocate memory for mask of pens that are transparent in sprites */ | |
| 126 | transmask = auto_malloc(64); | |
| 127 | memset(transmask, 0, 64); | |
| 128 | ||
| 129 | /* color table; 64 entries total of 4 colors each */ | |
| 127 | /* allocate the colortable */ | |
| 130 | 128 | for (i = 0; i < 64*4; i++) |
| 131 | 129 | { |
| 132 | 130 | UINT8 ctabentry = color_prom[i] & 0x0f; |
| 133 | 131 | |
| 134 | /* if this color table entry maps to pen 0, mark the appropriate pens in the transmask */ | |
| 135 | if (ctabentry == 0) | |
| 136 | transmask[i/4] |= 1 << (i % 4); | |
| 137 | ||
| 138 | 132 | /* first palette bank */ |
| 139 | | |
| 133 | colortable_ | |
| 140 | 134 | |
| 141 | 135 | /* second palette bank */ |
| 142 | | |
| 136 | colortable_ | |
| 143 | 137 | } |
| 144 | 138 | } |
| 145 | 139 | |
| r936 | r937 | |
| 252 | 246 | color, |
| 253 | 247 | spriteram[offs] & 1,spriteram[offs] & 2, |
| 254 | 248 | sx,sy, |
| 255 | &spriteclip,TRANSPARENCY_PENS,transmask[color & 0x3f]); | |
| 249 | &spriteclip,TRANSPARENCY_PENS, | |
| 250 | colortable_get_transpen_mask(pacman_colortable, machine->gfx[1], color, 0)); | |
| 256 | 251 | |
| 257 | 252 | /* also plot the sprite with wraparound (tunnel in Crush Roller) */ |
| 258 | 253 | drawgfx(bitmap,machine->gfx[1], |
| r936 | r937 | |
| 260 | 255 | color, |
| 261 | 256 | spriteram[offs] & 1,spriteram[offs] & 2, |
| 262 | 257 | sx - 256,sy, |
| 263 | &spriteclip,TRANSPARENCY_PENS,transmask[color & 0x3f]); | |
| 258 | &spriteclip,TRANSPARENCY_PENS, | |
| 259 | colortable_get_transpen_mask(pacman_colortable, machine->gfx[1], color, 0)); | |
| 264 | 260 | } |
| 265 | 261 | /* In the Pac Man based games (NOT Pengo) the first two sprites must be offset */ |
| 266 | 262 | /* one pixel to the left to get a more correct placement */ |
| r936 | r937 | |
| 278 | 274 | color, |
| 279 | 275 | spriteram[offs] & 1,spriteram[offs] & 2, |
| 280 | 276 | sx,sy + xoffsethack, |
| 281 | &spriteclip,TRANSPARENCY_PENS,transmask[color & 0x3f]); | |
| 277 | &spriteclip,TRANSPARENCY_PENS, | |
| 278 | colortable_get_transpen_mask(pacman_colortable, machine->gfx[1], color, 0)); | |
| 282 | 279 | |
| 283 | 280 | /* also plot the sprite with wraparound (tunnel in Crush Roller) */ |
| 284 | 281 | drawgfx(bitmap,machine->gfx[1], |
| r936 | r937 | |
| 286 | 283 | color, |
| 287 | 284 | spriteram[offs] & 2,spriteram[offs] & 1, |
| 288 | 285 | sx - 256,sy + xoffsethack, |
| 289 | &spriteclip,TRANSPARENCY_PENS,transmask[color & 0x3f]); | |
| 286 | &spriteclip,TRANSPARENCY_PENS, | |
| 287 | colortable_get_transpen_mask(pacman_colortable, machine->gfx[1], color, 0)); | |
| 290 | 288 | } |
| 291 | 289 | } |
| 292 | 290 | |
| r936 | r937 | |
| 418 | 416 | color, |
| 419 | 417 | spriteram[offs] & 1,spriteram[offs] & 2, |
| 420 | 418 | sx,sy, |
| 421 | cliprect,TRANSPARENCY_PENS,transmask[color & 0x3f]); | |
| 419 | cliprect,TRANSPARENCY_PENS, | |
| 420 | colortable_get_transpen_mask(pacman_colortable, machine->gfx[1], color & 0x3f, 0)); | |
| 422 | 421 | } |
| 423 | 422 | /* In the Pac Man based games (NOT Pengo) the first two sprites must be offset */ |
| 424 | 423 | /* one pixel to the left to get a more correct placement */ |
| r936 | r937 | |
| 438 | 437 | color, |
| 439 | 438 | spriteram[offs] & 1,spriteram[offs] & 2, |
| 440 | 439 | sx,sy + xoffsethack, |
| 441 | cliprect,TRANSPARENCY_PENS,transmask[color & 0x3f]); | |
| 440 | cliprect,TRANSPARENCY_PENS, | |
| 441 | colortable_get_transpen_mask(pacman_colortable, machine->gfx[1], color & 0x3f, 0)); | |
| 442 | 442 | } |
| 443 | 443 | return 0; |
| 444 | 444 | } |
| r936 | r937 | |
|---|---|---|
| 165 | 165 | |
| 166 | 166 | #define BW_SET_TILE_INFO(GFX, CODE, COLOR) { \ |
| 167 | 167 | tileinfo->pen_data = GFX->gfxdata + (CODE) * GFX->char_modulo; \ |
| 168 | tileinfo->palette_base = | |
| 168 | tileinfo->palette_base = | |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | static TILE_GET_INFO( get_fgtileinfo ) |
| r936 | r937 | |
|---|---|---|
| 65 | 65 | static UINT16 *cram, *tram; |
| 66 | 66 | static UINT32 *mram; |
| 67 | 67 | |
| 68 | static pen_t *substitute_pens; | |
| 69 | ||
| 68 | 70 | static UINT32 *expanded_mram; |
| 69 | 71 | |
| 70 | 72 | static UINT8 rshift, gshift, bshift; |
| r936 | r937 | |
| 154 | 156 | expanded_mram = auto_malloc(sizeof(*expanded_mram) * MRAM_ENTRIES * 3); |
| 155 | 157 | |
| 156 | 158 | /* map pens 1:1 */ |
| 159 | substitute_pens = auto_malloc(65536 * sizeof(*substitute_pens)); | |
| 157 | 160 | for (i = 0; i < machine->drv->total_colors; i++) |
| 158 | machine->pens[i] = i; | |
| 161 | substitute_pens[i] = i; | |
| 162 | machine->pens = substitute_pens; | |
| 159 | 163 | |
| 160 | 164 | /* compute shift values */ |
| 161 | 165 | rshift = 16; |
| r936 | r937 | |
|---|---|---|
| 426 | 426 | case 0x09: |
| 427 | 427 | case 0x0a: |
| 428 | 428 | case 0x0b: |
| 429 | if (ACCESSING_LSB && sndti_t | |
| 429 | if (ACCESSING_LSB && sndti_exist | |
| 430 | 430 | SN76496_0_w(0, data & 0xff); |
| 431 | 431 | break; |
| 432 | 432 | } |
| r936 | r937 | |
|---|---|---|
| 16 | 16 | size_t thepit_spriteram_size; |
| 17 | 17 | |
| 18 | 18 | static UINT8 graphics_bank; |
| 19 | static UINT8 color_count; | |
| 20 | static int color_granularity; | |
| 21 | 19 | static UINT8 thepit_flip_screen_x; |
| 22 | 20 | static UINT8 thepit_flip_screen_y; |
| 21 | static tilemap *thepit_solid_tilemap; | |
| 23 | 22 | static tilemap *thepit_tilemap; |
| 23 | static UINT8 *dummy_tile; | |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | static rectangle spritevisiblearea = |
| r936 | r937 | |
| 57 | 57 | { |
| 58 | 58 | int i; |
| 59 | 59 | |
| 60 | /* allocate primary colors for the background and foreground | |
| 61 | this is wrong, but I don't know where to pick the colors from */ | |
| 62 | for (i = 0; i < 8; i++) | |
| 60 | for (i = 0; i < 32; i++) | |
| 63 | 61 | { |
| 64 | palette_set_color_rgb(machine, i, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); | |
| 65 | } | |
| 66 | ||
| 67 | for (i = 0; i < machine->drv->total_colors - 8; i++) | |
| 68 | { | |
| 69 | 62 | int bit0, bit1, bit2, r, g, b; |
| 70 | 63 | |
| 71 | 64 | bit0 = (color_prom[i] >> 0) & 0x01; |
| r936 | r937 | |
| 83 | 76 | bit2 = (color_prom[i] >> 7) & 0x01; |
| 84 | 77 | b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 85 | 78 | |
| 86 | palette_set_color(machine, i | |
| 79 | palette_set_color(machine, i | |
| 87 | 80 | } |
| 88 | 81 | |
| 89 | /* background priority colors */ | |
| 90 | for (i = 0; i < machine->drv->color_table_len - 32; i++) | |
| 91 | { | |
| 92 | colortable[i] = i + 8; | |
| 93 | } | |
| 94 | ||
| 95 | /* foreground priority colors - creates solid square */ | |
| 96 | for (i = 0; i < 32; i++) | |
| 97 | { | |
| 98 | colortable[machine->drv->color_table_len - 32 + i] = i >> 2; | |
| 99 | } | |
| 82 | /* allocate primary colors for the background and foreground | |
| 83 | this is wrong, but I don't know where to pick the colors from */ | |
| 84 | for (i = 0; i < 8; i++) | |
| 85 | palette_set_color_rgb(machine, i + 32, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); | |
| 100 | 86 | } |
| 101 | 87 | |
| 102 | 88 | |
| r936 | r937 | |
| 111 | 97 | { |
| 112 | 98 | int i; |
| 113 | 99 | |
| 114 | /* allocate primary colors for the background and foreground | |
| 115 | this is wrong, but I don't know where to pick the colors from */ | |
| 116 | for (i = 0; i < 8; i++) | |
| 100 | for (i = 0; i < 32; i++) | |
| 117 | 101 | { |
| 118 | palette_set_color_rgb(machine, i, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); | |
| 119 | } | |
| 120 | ||
| 121 | for (i = 0; i < machine->drv->total_colors - 8; i++) | |
| 122 | { | |
| 123 | 102 | UINT8 r = ((color_prom[i + 0x20] >> 6) | (color_prom[i + 0x00] << 2)) & 0x1f; |
| 124 | ||
| 125 | 103 | UINT8 g = BITSWAP8(color_prom[i + 0x20], 7, 6, 0, 1, 2, 3, 4, 5) & 0x1f; |
| 126 | ||
| 127 | 104 | UINT8 b = BITSWAP8(color_prom[i + 0x00], 0, 1, 2, 3, 4, 5, 6, 7) & 0x1f; |
| 128 | 105 | |
| 129 | 106 | palette_set_color_rgb(machine, i + 8, pal5bit(r), pal5bit(g), pal5bit(b)); |
| 130 | 107 | } |
| 131 | 108 | |
| 132 | for (i = 0;i < machine->drv->color_table_len;i++) | |
| 133 | { | |
| 134 | colortable[i] = i + 8; | |
| 135 | } | |
| 136 | ||
| 137 | /* background priority colors */ | |
| 138 | for (i = 0; i < machine->drv->color_table_len - 64; i++) | |
| 139 | { | |
| 140 | colortable[i] = i + 8; | |
| 141 | } | |
| 142 | ||
| 143 | /* foreground priority colors - creates solid square */ | |
| 144 | for (i = 0; i < 64; i++) | |
| 145 | { | |
| 146 | colortable[machine->drv->color_table_len - 64 + i] = i >> 3; | |
| 147 | } | |
| 109 | /* allocate primary colors for the background and foreground | |
| 110 | this is wrong, but I don't know where to pick the colors from */ | |
| 111 | for (i = 0; i < 8; i++) | |
| 112 | palette_set_color_rgb(machine, i + 32, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); | |
| 148 | 113 | } |
| 149 | 114 | |
| 150 | 115 | |
| r936 | r937 | |
| 155 | 120 | |
| 156 | 121 | ***************************************************************************/ |
| 157 | 122 | |
| 158 | static TILE_GET_INFO( get_tile_info ) | |
| 123 | static TILE_GET_INFO( solid_get_tile_info ) | |
| 159 | 124 | { |
| 160 | UINT8 fore_color; | |
| 161 | ||
| 162 | UINT8 code = thepit_videoram[tile_index]; | |
| 163 | 125 | UINT8 back_color = (thepit_colorram[tile_index] & 0x70) >> 4; |
| 164 | 126 | int priority = (back_color != 0) && ((thepit_colorram[tile_index] & 0x80) == 0); |
| 127 | tileinfo->pen_data = dummy_tile; | |
| 128 | tileinfo->palette_base = back_color + 32; | |
| 129 | tileinfo->category = priority; | |
| 130 | } | |
| 165 | 131 | |
| 166 | if (priority) | |
| 167 | { | |
| 168 | /* foreground - solid square */ | |
| 169 | fore_color = color_count + back_color; | |
| 170 | } | |
| 171 | else | |
| 172 | { | |
| 173 | /* background */ | |
| 174 | fore_color = thepit_colorram[tile_index] & (color_count - 1); | |
| 175 | 132 | |
| 176 | /* set up pen #0 color */ | |
| 177 | machine->gfx[graphics_bank]->colortable[fore_color * color_granularity] = machine->pens[back_color]; | |
| 178 | } | |
| 179 | ||
| 133 | static TILE_GET_INFO( get_tile_info ) | |
| 134 | { | |
| 135 | UINT8 fore_color = thepit_colorram[tile_index] % machine->gfx[0]->total_colors; | |
| 136 | UINT8 code = thepit_videoram[tile_index]; | |
| 180 | 137 | SET_TILE_INFO(2 * graphics_bank, code, fore_color, 0); |
| 181 | tileinfo->category = priority; | |
| 182 | 138 | } |
| 183 | 139 | |
| 184 | 140 | |
| r936 | r937 | |
| 189 | 145 | * |
| 190 | 146 | *************************************/ |
| 191 | 147 | |
| 192 | ||
| 148 | V | |
| 193 | 149 | { |
| 150 | thepit_solid_tilemap = tilemap_create(solid_get_tile_info,tilemap_scan_rows,TILEMAP_TYPE_PEN,8,8,32,32); | |
| 151 | ||
| 194 | 152 | thepit_tilemap = tilemap_create(get_tile_info,tilemap_scan_rows,TILEMAP_TYPE_PEN,8,8,32,32); |
| 153 | tilemap_set_transparent_pen(thepit_tilemap, 0); | |
| 195 | 154 | |
| 155 | tilemap_set_scroll_cols(thepit_solid_tilemap, 32); | |
| 196 | 156 | tilemap_set_scroll_cols(thepit_tilemap, 32); |
| 197 | 157 | |
| 198 | color_count = _color_count; | |
| 199 | color_granularity = _color_granularity; | |
| 200 | } | |
| 158 | dummy_tile = auto_malloc(8*8); | |
| 159 | memset(dummy_tile, 0, 8*8); | |
| 201 | 160 | |
| 202 | ||
| 203 | VIDEO_START( thepit ) | |
| 204 | { | |
| 205 | video_start_common(8, 4); | |
| 206 | ||
| 207 | graphics_bank = 0; /* not used in this game */ | |
| 161 | graphics_bank = 0; /* only used in intrepid */ | |
| 208 | 162 | } |
| 209 | 163 | |
| 210 | 164 | |
| 211 | VIDEO_START( intrepid ) | |
| 212 | { | |
| 213 | video_start_common(8, 4); | |
| 214 | } | |
| 215 | 165 | |
| 216 | ||
| 217 | VIDEO_START( suprmous ) | |
| 218 | { | |
| 219 | video_start_common(4, 8); | |
| 220 | ||
| 221 | graphics_bank = 0; /* not used in this game */ | |
| 222 | } | |
| 223 | ||
| 224 | ||
| 225 | ||
| 226 | 166 | /************************************* |
| 227 | 167 | * |
| 228 | 168 | * Memory handlers |
| r936 | r937 | |
| 240 | 180 | { |
| 241 | 181 | thepit_colorram[offset] = data; |
| 242 | 182 | tilemap_mark_tile_dirty(thepit_tilemap, offset); |
| 183 | tilemap_mark_tile_dirty(thepit_solid_tilemap, offset); | |
| 243 | 184 | } |
| 244 | 185 | |
| 245 | 186 | |
| r936 | r937 | |
| 248 | 189 | thepit_flip_screen_x = data & 0x01; |
| 249 | 190 | |
| 250 | 191 | tilemap_set_flip(thepit_tilemap, thepit_flip_screen_x ? TILEMAP_FLIPX : 0); |
| 192 | tilemap_set_flip(thepit_solid_tilemap, thepit_flip_screen_x ? TILEMAP_FLIPX : 0); | |
| 251 | 193 | } |
| 252 | 194 | |
| 253 | 195 | |
| r936 | r937 | |
| 256 | 198 | thepit_flip_screen_y = data & 0x01; |
| 257 | 199 | |
| 258 | 200 | tilemap_set_flip(thepit_tilemap, thepit_flip_screen_y ? TILEMAP_FLIPY : 0); |
| 201 | tilemap_set_flip(thepit_solid_tilemap, thepit_flip_screen_y ? TILEMAP_FLIPY : 0); | |
| 259 | 202 | } |
| 260 | 203 | |
| 261 | 204 | |
| r936 | r937 | |
| 333 | 276 | |
| 334 | 277 | drawgfx(bitmap, machine->gfx[2 * graphics_bank + 1], |
| 335 | 278 | thepit_spriteram[offs + 1] & 0x3f, |
| 336 | thepit_spriteram[offs + 2] | |
| 279 | thepit_spriteram[offs + 2] | |
| 337 | 280 | flipx, flipy, x, y, |
| 338 | 281 | thepit_flip_screen_x ? &spritevisibleareaflipx : &spritevisiblearea, |
| 339 | 282 | TRANSPARENCY_PEN, 0); |
| r936 | r937 | |
| 349 | 292 | for (offs = 0; offs < 32; offs++) |
| 350 | 293 | { |
| 351 | 294 | tilemap_set_scrolly(thepit_tilemap, offs, thepit_attributesram[offs << 1]); |
| 295 | tilemap_set_scrolly(thepit_solid_tilemap, offs, thepit_attributesram[offs << 1]); | |
| 352 | 296 | } |
| 353 | 297 | |
| 354 | 298 | /* low priority tiles */ |
| 299 | tilemap_draw(bitmap, cliprect, thepit_solid_tilemap, 0, 0); | |
| 355 | 300 | tilemap_draw(bitmap, cliprect, thepit_tilemap, 0, 0); |
| 356 | 301 | |
| 357 | 302 | /* low priority sprites */ |
| 358 | 303 | draw_sprites(machine, bitmap, cliprect, 0); |
| 359 | 304 | |
| 360 | 305 | /* high priority tiles */ |
| 361 | tilemap_draw(bitmap, cliprect, thepit_tilemap, 1, 1); | |
| 306 | tilemap_draw(bitmap, cliprect, thepit_solid_tilemap, 1, 1); | |
| 362 | 307 | |
| 363 | 308 | /* high priority sprites */ |
| 364 | 309 | draw_sprites(machine, bitmap, cliprect, 1); |
| r936 | r937 | |
|---|---|---|
| 248 | 248 | int stop3 = background_latches[11] >> 4; |
| 249 | 249 | UINT8 *mixer = &background_mixer[(background_latches[12] << 4) & 0xf0]; |
| 250 | 250 | UINT8 scanline[VISIBLE_X_MAX]; |
| 251 | pen_t *pens; | |
| 251 | const pen_t *pens; | |
| 252 | 252 | |
| 253 | 253 | /* the cocktail flip flag controls whether we count up or down in X */ |
| 254 | 254 | if (!exerion_cocktail_flip) |
| r936 | r937 | |
|---|---|---|
| 591 | 591 | RGN_FRAC(1,1), |
| 592 | 592 | 4, |
| 593 | 593 | { 0, 1, 2, 3 }, |
| 594 | { 0, 4, 8, 12, 16, 20, 24, 28 }, | |
| 595 | { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, | |
| 594 | { STEP8(0,4) }, | |
| 595 | { STEP8(0,32) }, | |
| 596 | 596 | 32*8 |
| 597 | 597 | }; |
| 598 | 598 | |
| r936 | r937 | |
| 602 | 602 | RGN_FRAC(1,1), |
| 603 | 603 | 4, |
| 604 | 604 | { 0, 1, 2, 3 }, |
| 605 | { 0, 4, 8, 12, 16, 20, 24, 28, | |
| 606 | 32, 36, 40, 44, 48, 52, 56, 60 }, | |
| 607 | { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, | |
| 608 | 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 }, | |
| 605 | { STEP16(0,4) }, | |
| 606 | { STEP16(0,64) }, | |
| 609 | 607 | 128*8 |
| 610 | 608 | }; |
| 611 | 609 | |
| r936 | r937 | |
| 614 | 612 | static const gfx_decode gfxdecodeinfo[] = |
| 615 | 613 | { |
| 616 | 614 | { REGION_GFX1, 0, &charlayout, 0, 64 }, |
| 617 | { REGION_GFX2, 0, &spritelayout, | |
| 615 | { REGION_GFX2, 0, &spritelayout, 0, 32*2 }, | |
| 618 | 616 | { -1 } |
| 619 | 617 | }; |
| 620 | 618 | |
| r936 | r937 | |
| 653 | 651 | MDRV_SCREEN_SIZE(32*8, 32*8) |
| 654 | 652 | MDRV_SCREEN_VISIBLE_AREA(1*8, 31*8-1, 4*8, 28*8-1) |
| 655 | 653 | MDRV_GFXDECODE(gfxdecodeinfo) |
| 656 | MDRV_PALETTE_LENGTH(258) | |
| 657 | MDRV_COLORTABLE_LENGTH(64*16+2*32*16) | |
| 654 | MDRV_PALETTE_LENGTH(512) | |
| 658 | 655 | |
| 659 | 656 | MDRV_PALETTE_INIT(docastle) |
| 660 | 657 | MDRV_VIDEO_START(docastle) |
| r936 | r937 | |
| 687 | 684 | MDRV_CPU_PROGRAM_MAP(dorunrun_map2, 0) |
| 688 | 685 | |
| 689 | 686 | // video hardware |
| 690 | MDRV_ | |
| 687 | MDRV_VIDEO | |
| 691 | 688 | MACHINE_DRIVER_END |
| 692 | 689 | |
| 693 | 690 | static MACHINE_DRIVER_START( idsoccer ) |
| r936 | r937 | |
| 701 | 698 | MDRV_CPU_PROGRAM_MAP(idsoccer_map2, 0) |
| 702 | 699 | |
| 703 | 700 | // video hardware |
| 704 | MDRV_ | |
| 701 | MDRV_VIDEO | |
| 705 | 702 | |
| 706 | 703 | // sound hardware |
| 707 | 704 | MDRV_SOUND_ADD(MSM5205, 384000) |
| r936 | r937 | |
|---|---|---|
| 343 | 343 | decodegfx(machine->gfx[K037122_gfx_index[chip]], (UINT8*)K037122_char_ram[chip], 0, machine->gfx[K037122_gfx_index[chip]]->total_elements); |
| 344 | 344 | |
| 345 | 345 | if (machine->drv->color_table_len) |
| 346 | { | |
| 347 | machine->gfx[K037122_gfx_index[chip]]->colortable = machine->remapped_colortable; | |
| 348 | 346 | machine->gfx[K037122_gfx_index[chip]]->total_colors = machine->drv->color_table_len / 16; |
| 349 | } | |
| 350 | 347 | else |
| 351 | { | |
| 352 | machine->gfx[K037122_gfx_index[chip]]->colortable = machine->pens; | |
| 353 | 348 | machine->gfx[K037122_gfx_index[chip]]->total_colors = machine->drv->total_colors / 16; |
| 354 | } | |
| 355 | 349 | |
| 356 | 350 | return 0; |
| 357 | 351 | } |
| r936 | r937 | |
|---|---|---|
| 183 | 183 | UINT8 pen = dp[index++]; |
| 184 | 184 | if (pen) |
| 185 | 185 | { |
| 186 | p[i] = | |
| 186 | p[i] = Machine->remapped_colortable[gfx->color_base + (att & 0xf)]; | |
| 187 | 187 | } |
| 188 | 188 | else |
| 189 | 189 | { |
| 190 | 190 | if (((att >> 4) & 7) > 0) |
| 191 | 191 | { |
| 192 | p[i] = | |
| 192 | p[i] = Machine->remapped_colortable[gfx->color_base + ((att >> 4) & 0x7)]; | |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | } |
| r936 | r937 | |
|---|---|---|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | // oki banking |
| 867 | if (sndti_t | |
| 867 | if (sndti_exist | |
| 868 | 868 | OKIM6295_set_bank_base(1, (data & 0x4000000) ? 0x40000 : 0); |
| 869 | 869 | } |
| 870 | 870 |
| r936 | r937 | |
|---|---|---|
| 175 | 175 | { |
| 176 | 176 | /* keep track of the last few writes */ |
| 177 | 177 | memmove(&nvram_write_seq[0], &nvram_write_seq[1], (NVRAM_UNLOCK_SEQ_LEN - 1) * sizeof(nvram_write_seq[0])); |
| 178 | nvram_write_seq[NVRAM_UNLOCK_SEQ_LEN - 1] = offset; | |
| 178 | nvram_write_seq[NVRAM_UNLOCK_SEQ_LEN - 1] = offset & 0x3ff; | |
| 179 | 179 | |
| 180 | 180 | /* if they match the unlock sequence, enable writes and set a timeout */ |
| 181 | 181 | if (!memcmp(nvram_unlock_seq, nvram_write_seq, sizeof(nvram_unlock_seq))) |
| r936 | r937 | |
|---|---|---|
| 780 | 780 | MDRV_SCREEN_SIZE(36*8, 28*8) |
| 781 | 781 | MDRV_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 0*8, 28*8-1) |
| 782 | 782 | MDRV_GFXDECODE(gfxdecodeinfo) |
| 783 | MDRV_PALETTE_LENGTH(256) | |
| 784 | MDRV_COLORTABLE_LENGTH(64*4+64*8) | |
| 783 | MDRV_PALETTE_LENGTH(64*4+64*8) | |
| 785 | 784 | |
| 786 | 785 | MDRV_PALETTE_INIT(gaplus) |
| 787 | 786 | MDRV_VIDEO_START(gaplus) |
| r936 | r937 | |
|---|---|---|
| 1 | /*************************************************************************** | |
| 1 | /**************************************************************************************** | |
| 2 | 2 | |
| 3 | | |
| 3 | | |
| 4 | 4 | |
| 5 | Bellfruit scorpion2/3 driver, (under heavy construction !!!) | |
| 6 | ||
| 7 | ***************************************************************************************** | |
| 8 | ||
| 5 | 9 | 30-12-2006: J Wallace: Fixed init routines. |
| 6 | 10 | 07-03-2006: El Condor: Recoded to more accurately represent the hardware setup. |
| 7 | 11 | 18-01-2006: Cleaned up for MAME inclusion |
| r936 | r937 | |
| 73 | 77 | -----------+---+-----------------+----------------------------------------- |
| 74 | 78 | 2336 |?/W| D D D D D D D D | dimcnt ? |
| 75 | 79 | -----------+---+-----------------+----------------------------------------- |
| 76 | 2337 | W | D D D D D D D D | volume overide | |
| 80 | 2337 | W | D D D D D D D D | volume override | |
| 77 | 81 | -----------+---+-----------------+----------------------------------------- |
| 78 | 82 | 2338 | W | D D D D D D D D | payout chip select |
| 79 | 83 | -----------+---+-----------------+----------------------------------------- |
| 80 | 84 | 2339 | W | D D D D D D D D | clkden ? |
| 81 | 85 | -----------+---+-----------------+----------------------------------------- |
| 82 | 2400 |R/W| D D D D D D D D | uart1 (MC6850 compatible) control/status | |
| 86 | 2400 |R/W| D D D D D D D D | uart1 (MC6850 compatible) control/status | |
| 83 | 87 | -----------+---+-----------------+----------------------------------------- |
| 84 | 2500 |R/W| D D D D D D D D | uart1 (MC6850 compatible) data | |
| 88 | 2500 |R/W| D D D D D D D D | uart1 (MC6850 compatible) data | |
| 85 | 89 | -----------+---+-----------------+----------------------------------------- |
| 86 | 2600 |R/W| D D D D D D D D | uart2 (MC6850 compatible) control/status | |
| 90 | 2600 |R/W| D D D D D D D D | uart2 (MC6850 compatible) control/status | |
| 87 | 91 | -----------+---+-----------------+----------------------------------------- |
| 88 | 2700 |R/W| D D D D D D D D | uart2 (MC6850 compatible) data | |
| 92 | 2700 |R/W| D D D D D D D D | uart2 (MC6850 compatible) data | |
| 89 | 93 | -----------+---+-----------------+----------------------------------------- |
| 90 | 94 | 2800 |R/W| D D D D D D D D | vfd1 |
| 91 | 95 | -----------+---+-----------------+----------------------------------------- |
| r936 | r937 | |
| 120 | 124 | |
| 121 | 125 | Adder hardware: |
| 122 | 126 | Games supported: |
| 123 | * Quintoon (2 sets Dutch, 1 set UK) | |
| 124 | * Quintoon (UK) (1 set) | |
| 127 | * Quintoon (2 sets Dutch, 2 sets UK) | |
| 125 | 128 | * Pokio (1 set) |
| 126 | 129 | * Paradice (1 set) |
| 127 | 130 | * Pyramid (1 set) |
| r936 | r937 | |
| 130 | 133 | |
| 131 | 134 | Known issues: |
| 132 | 135 | * Need to find the 'missing' game numbers |
| 133 | ||
| 136 | * Fix RS232 protocol | |
| 134 | 137 | ***************************************************************************/ |
| 135 | 138 | |
| 136 | 139 | #include "driver.h" |
| r936 | r937 | |
| 162 | 165 | #ifdef MAME_DEBUG |
| 163 | 166 | #define LOG_SERIAL(x) logerror x // log serial communication between mainboard (scorpion2) and videoboard (adder2) |
| 164 | 167 | #define UART_LOG(x) logerror x //enable UART data logging |
| 168 | #define LOG(x) logerror x | |
| 165 | 169 | #else |
| 166 | 170 | #define LOG_SERIAL(x) |
| 167 | 171 | #define UART_LOG(x) |
| 172 | #define LOG(x) | |
| 168 | 173 | #endif |
| 169 | 174 | |
| 170 | 175 | // local prototypes /////////////////////////////////////////////////////// |
| r936 | r937 | |
| 180 | 185 | |
| 181 | 186 | // local vars ///////////////////////////////////////////////////////////// |
| 182 | 187 | |
| 183 | static UINT8 *nvram; // pointer to NV ram | |
| 184 | static size_t nvram_size; // size of NV ram | |
| 185 | static UINT8 key[16]; // security device on gamecard (video games only) | |
| 188 | static UINT8 *nvram; // pointer to NVRAM | |
| 189 | static size_t nvram_size; // size of NVRAM | |
| 190 | static UINT8 key[16]; // security device on gamecard (video games only) | |
| 186 | 191 | |
| 187 | static UINT8 e2ram[1024]; | |
| 192 | static UINT8 e2ram[1024]; // x24C08 e2ram | |
| 188 | 193 | |
| 189 | static int mmtr_latch; // mechanical meter latch | |
| 190 | static int triac_latch; // payslide triac latch | |
| 191 | static int vfd1_latch; // vfd1 latch | |
| 192 | static int vfd2_latch; // vfd2 latch | |
| 193 | static int irq_status; // custom chip IRQ status | |
| 194 | static int optic_pattern; // reel optics | |
| 195 | static int uart1_status; // MC6850 status | |
| 196 | static int uart2_status; // MC6850 status | |
| 197 | static int locked; // hardware lock/unlock status (0=unlocked) | |
| 194 | static int mmtr_latch; // mechanical meter latch | |
| 195 | static int triac_latch; // payslide triac latch | |
| 196 | static int vfd1_latch; // vfd1 latch | |
| 197 | static int vfd2_latch; // vfd2 latch | |
| 198 | static int irq_status; // custom chip IRQ status | |
| 199 | static int optic_pattern; // reel optics | |
| 200 | static int uart1_data; | |
| 201 | static int uart2_data; | |
| 202 | static int data_to_uart1; | |
| 203 | static int data_to_uart2; | |
| 204 | static int locked; // hardware lock/unlock status (0=unlocked) | |
| 198 | 205 | static int timer_enabled; |
| 199 | 206 | static int reel_changed; |
| 200 | 207 | static int coin_inhibits; |
| 201 | 208 | static int irq_timer_stat; |
| 202 | 209 | static int expansion_latch; |
| 203 | static int global_volume; // 0-31 | |
| 204 | static int volume_override; // 0 / 1 | |
| 210 | static int global_volume; // 0-31 | |
| 211 | static int volume_override; // 0 / 1 | |
| 205 | 212 | |
| 206 | static int sc2_show_door; // flag <>0, show door state | |
| 207 | static int sc2_door_state; // door switch strobe/data | |
| 213 | static int sc2_show_door; // flag <>0, show door state | |
| 214 | static int sc2_door_state; // door switch strobe/data | |
| 208 | 215 | |
| 209 | 216 | static int reel12_latch; |
| 210 | 217 | static int reel34_latch; |
| r936 | r937 | |
| 214 | 221 | static int slide_states[6]; |
| 215 | 222 | static int slide_pay_sensor[6]; |
| 216 | 223 | |
| 217 | static int has_hopper; | |
| 224 | static int has_hopper; | |
| 218 | 225 | |
| 219 | 226 | static int triac_select; |
| 220 | 227 | |
| 221 | static int hopper_running; // flag <>0, hopper is running used in some scorpion2 videogames | |
| 222 | static int hopper_coin_sense; // hopper coin sense state | |
| 223 | static int timercnt; // timer counts up every IRQ (=1000 times a second) | |
| 228 | static int hopper_running; // flag <>0, hopper is running used in some scorpion2 videogames | |
| 229 | static int hopper_coin_sense; | |
| 230 | static int timercnt; // timer counts up every IRQ (=1000 times a second) | |
| 224 | 231 | |
| 225 | 232 | static int watchdog_cnt; |
| 226 | 233 | static int watchdog_kicked; |
| 227 | 234 | |
| 228 | 235 | // user interface stuff /////////////////////////////////////////////////// |
| 229 | 236 | |
| 230 | static UINT8 Lamps[256]; // 256 multiplexed lamps | |
| 231 | static UINT8 sc2_Inputs[64]; // ?? multiplexed inputs, | |
| 232 | // need to be hooked to buttons | |
| 237 | static UINT8 Lamps[256]; | |
| 238 | static UINT8 sc2_Inputs[64]; | |
| 233 | 239 | |
| 234 | 240 | static UINT8 input_override[64];// bit pattern, bit set means this input is overriden and cannot be changed with switches |
| 235 | 241 | |
| r936 | r937 | |
| 254 | 260 | |
| 255 | 261 | static void send_to_adder(int data) |
| 256 | 262 | { |
| 257 | adder2_data_from_sc2 = 1; // set flag, data from scorpion2 board available | |
| 258 | adder2_sc2data = data; // store data | |
| 263 | adder2_data_from_sc2 = 1; | |
| 264 | adder2_sc2data = data; | |
| 259 | 265 | |
| 260 | adder2_acia_triggered = 1; // set flag, acia IRQ triggered | |
| 261 | cpunum_set_input_line(1, M6809_IRQ_LINE, HOLD_LINE ); // trigger IRQ | |
| 266 | adder2_acia_triggered = 1; | |
| 267 | cpunum_set_input_line(1, M6809_IRQ_LINE, HOLD_LINE ); | |
| 262 | 268 | |
| 263 | 269 | LOG_SERIAL(("sadder %02X (%c)\n",data, data )); |
| 264 | 270 | } |
| r936 | r937 | |
| 268 | 274 | static int receive_from_adder(void) |
| 269 | 275 | { |
| 270 | 276 | int data = adder2_data; |
| 271 | adder2_data_to_sc2 = 0; | |
| 277 | adder2_data_to_sc2 = 0; | |
| 272 | 278 | |
| 273 | 279 | LOG_SERIAL(("radder: %02X(%c)\n",data, data )); |
| 274 | 280 | |
| r936 | r937 | |
| 281 | 287 | { |
| 282 | 288 | int status = 0; |
| 283 | 289 | |
| 284 | if ( adder2_data_to_sc2 ) status |= 0x01; | |
| 290 | if ( adder2_data_to_sc2 ) status |= 0x01; // receive buffer full | |
| 285 | 291 | if ( !adder2_data_from_sc2) status |= 0x02; // transmit buffer empty |
| 286 | 292 | |
| 287 | 293 | return status; |
| r936 | r937 | |
| 351 | 357 | |
| 352 | 358 | } |
| 353 | 359 | |
| 354 | uart1_status = 0x02; // MC6850 transmit buffer empty !!! | |
| 355 | uart2_status = 0x02; // MC6850 transmit buffer empty !!! | |
| 356 | locked = 0; // hardware is NOT locked | |
| 360 | locked = 0; | |
| 357 | 361 | |
| 358 | 362 | // make sure no inputs are overidden //////////////////////////////////// |
| 359 | 363 | memset(input_override, 0, sizeof(input_override)); |
| r936 | r937 | |
| 374 | 378 | |
| 375 | 379 | static void Scorpion2_SetSwitchState(int strobe, int data, int state) |
| 376 | 380 | { |
| 377 | //logerror("setstate(%0x:%0x, %d) ", strobe, data, state); | |
| 378 | 381 | if ( strobe < 11 && data < 8 ) |
| 379 | 382 | { |
| 380 | 383 | if ( strobe < 8 ) |
| r936 | r937 | |
| 382 | 385 | input_override[strobe] |= (1<<data); |
| 383 | 386 | |
| 384 | 387 | if ( state ) sc2_Inputs[strobe] |= (1<<data); |
| 385 | else sc2_Inputs[strobe] &= ~(1<<data); | |
| 386 | ||
| 387 | //logerror("override[%02x] = %02x %02x\n", strobe, input_override[strobe], sc2_Inputs[strobe]); | |
| 388 | else sc2_Inputs[strobe] &= ~(1<<data); | |
| 388 | 389 | } |
| 389 | 390 | else |
| 390 | 391 | { |
| r936 | r937 | |
| 394 | 395 | |
| 395 | 396 | if ( state ) sc2_Inputs[strobe-8+4] |= (1<<(data+2)); |
| 396 | 397 | else sc2_Inputs[strobe-8+4] &= ~(1<<(data+2)); |
| 397 | ||
| 398 | //logerror("override[%02x] = %02x %02x\n", strobe-8+4, input_override[strobe-8+4], sc2_Inputs[strobe-8+4]); | |
| 399 | 398 | } |
| 400 | 399 | else |
| 401 | 400 | { |
| r936 | r937 | |
| 403 | 402 | |
| 404 | 403 | if ( state ) sc2_Inputs[strobe-8] |= (1 << (data+5)); |
| 405 | 404 | else sc2_Inputs[strobe-8] &= ~(1 << (data+5)); |
| 406 | ||
| 407 | //logerror("override[%02x] = %02x %02x\n", strobe-8, input_override[strobe-8], sc2_Inputs[strobe-8]); | |
| 408 | 405 | } |
| 409 | 406 | } |
| 410 | 407 | } |
| r936 | r937 | |
| 441 | 438 | |
| 442 | 439 | static NVRAM_HANDLER( bfm_sc2 ) |
| 443 | 440 | { |
| 441 | static const UINT8 init_e2ram[10] = { 1, 4, 10, 20, 0, 1, 1, 4, 10, 20 }; | |
| 444 | 442 | if ( read_or_write ) |
| 445 | 443 | { // writing |
| 446 | 444 | mame_fwrite(file,nvram,nvram_size); |
| r936 | r937 | |
| 457 | 455 | { |
| 458 | 456 | memset(nvram,0x00,nvram_size); |
| 459 | 457 | memset(e2ram,0x00,sizeof(e2ram)); |
| 460 | e2ram[ 0] = 1; | |
| 461 | e2ram[ 1] = 4; | |
| 462 | e2ram[ 2] = 10; | |
| 463 | e2ram[ 3] = 20; | |
| 464 | e2ram[ 4] = 0; | |
| 465 | e2ram[ 5] = 1; | |
| 466 | e2ram[ 6] = 1; | |
| 467 | e2ram[ 7] = 4; | |
| 468 | e2ram[ 8] = 10; | |
| 469 | e2ram[ 9] = 20; | |
| 470 | e2ram[10] = 0; | |
| 458 | memcpy(e2ram,init_e2ram,sizeof(init_e2ram)); | |
| 471 | 459 | } |
| 472 | 460 | } |
| 473 | 461 | } |
| r936 | r937 | |
| 483 | 471 | |
| 484 | 472 | static WRITE8_HANDLER( ram_w ) |
| 485 | 473 | { |
| 486 | nvram[offset] = data; | |
| 474 | nvram[offset] = data; | |
| 487 | 475 | } |
| 488 | 476 | |
| 489 | 477 | /////////////////////////////////////////////////////////////////////////// |
| r936 | r937 | |
| 504 | 492 | |
| 505 | 493 | static INTERRUPT_GEN( timer_irq ) |
| 506 | 494 | { |
| 495 | timercnt++; | |
| 496 | ||
| 507 | 497 | if ( watchdog_kicked ) |
| 508 | 498 | { |
| 509 | 499 | watchdog_cnt = 0; |
| r936 | r937 | |
| 625 | 615 | if ( Mechmtr_update(0, cycles, data & 0x01 ) ) |
| 626 | 616 | { |
| 627 | 617 | sc2gui_update_mmtr |= 0x01; |
| 628 | logerror("meter %d = %ld\n", 1, MechMtr_Getcount(0) ); | |
| 629 | 618 | } |
| 630 | 619 | } |
| 631 | 620 | |
| r936 | r937 | |
| 634 | 623 | if ( Mechmtr_update(1, cycles, data & 0x02 ) ) |
| 635 | 624 | { |
| 636 | 625 | sc2gui_update_mmtr |= 0x02; |
| 637 | logerror("meter %d = %ld\n", 2, MechMtr_Getcount(1) ); | |
| 638 | 626 | } |
| 639 | 627 | } |
| 640 | 628 | |
| r936 | r937 | |
| 643 | 631 | if ( Mechmtr_update(2, cycles, data & 0x04 ) ) |
| 644 | 632 | { |
| 645 | 633 | sc2gui_update_mmtr |= 0x04; |
| 646 | logerror("meter %d = %ld\n", 3, MechMtr_Getcount(2) ); | |
| 647 | 634 | } |
| 648 | 635 | } |
| 649 | 636 | |
| r936 | r937 | |
| 652 | 639 | if ( Mechmtr_update(3, cycles, data & 0x08 ) ) |
| 653 | 640 | { |
| 654 | 641 | sc2gui_update_mmtr |= 0x08; |
| 655 | logerror("meter %d = %ld\n", 4, MechMtr_Getcount(3) ); | |
| 656 | 642 | } |
| 657 | 643 | } |
| 658 | 644 | |
| r936 | r937 | |
| 662 | 648 | if ( Mechmtr_update(4, cycles, data & 0x10 ) ) |
| 663 | 649 | { |
| 664 | 650 | sc2gui_update_mmtr |= 0x10; |
| 665 | logerror("meter %d = %ld\n", 5, MechMtr_Getcount(4) ); | |
| 666 | 651 | } |
| 667 | 652 | } |
| 668 | 653 | |
| r936 | r937 | |
| 671 | 656 | if ( Mechmtr_update(5, cycles, data & 0x20 ) ) |
| 672 | 657 | { |
| 673 | 658 | sc2gui_update_mmtr |= 0x20; |
| 674 | logerror("meter %d = %ld\n", 6, MechMtr_Getcount(5) ); | |
| 675 | 659 | } |
| 676 | 660 | } |
| 677 | 661 | |
| r936 | r937 | |
| 680 | 664 | if ( Mechmtr_update(6, cycles, data & 0x40 ) ) |
| 681 | 665 | { |
| 682 | 666 | sc2gui_update_mmtr |= 0x40; |
| 683 | logerror("meter %d = %ld\n", 7, MechMtr_Getcount(6) ); | |
| 684 | 667 | } |
| 685 | 668 | } |
| 686 | 669 | |
| r936 | r937 | |
| 689 | 672 | if ( Mechmtr_update(7, cycles, data & 0x80 ) ) |
| 690 | 673 | { |
| 691 | 674 | sc2gui_update_mmtr |= 0x80; |
| 692 | logerror("meter %d = %ld\n", 8, MechMtr_Getcount(7) ); | |
| 693 | 675 | } |
| 694 | 676 | } |
| 695 | 677 | |
| r936 | r937 | |
| 703 | 685 | int i; |
| 704 | 686 | int off = offset<<3; |
| 705 | 687 | |
| 706 | Lamps[ off ] = (data & 0x01) != 0; | |
| 707 | Lamps[ off+1 ] = (data & 0x02) != 0; | |
| 708 | Lamps[ off+2 ] = (data & 0x04) != 0; | |
| 709 | Lamps[ off+3 ] = (data & 0x08) != 0; | |
| 710 | Lamps[ off+4 ] = (data & 0x10) != 0; | |
| 711 | Lamps[ off+5 ] = (data & 0x20) != 0; | |
| 712 | Lamps[ off+6 ] = (data & 0x40) != 0; | |
| 713 | Lamps[ off+7 ] = (data & 0x80) != 0; | |
| 714 | ||
| 688 | for (i=0; i<8; i++) | |
| 689 | { | |
| 690 | Lamps[ off+i ] = (data & (1 << i)) != 0; | |
| 691 | } | |
| 715 | 692 | if (offset == 0) // update all lamps after strobe 0 has been updated (HACK) |
| 716 | 693 | { |
| 717 | 694 | for ( i = 0; i < 256; i++ ) |
| r936 | r937 | |
| 727 | 704 | { |
| 728 | 705 | int result = 0xFF,t1,t2; |
| 729 | 706 | |
| 730 | | |
| 707 | | |
| 731 | 708 | { |
| 732 | case 0: | |
| 733 | case 1: | |
| 734 | case 2: | |
| 735 | case 3: | |
| 736 | t1 = input_override[offset]; // strobe 0-3 data 0-4 | |
| 737 | t2 = input_override[offset+8]; // strobe 8-B data 0-2 | |
| 709 | int idx = (offset & 4) ? 4 : 8; | |
| 710 | t1 = input_override[offset]; // strobe 0-7 data 0-4 | |
| 711 | t2 = input_override[offset+idx]; // strobe 8-B data 0-4 | |
| 738 | 712 | |
| 739 | t1 = (sc2_Inputs[offset] & t1) | ( ( readinputport(offset+1) & ~t1) & 0x1F); | |
| 713 | t1 = (sc2_Inputs[offset] & t1) | ( ( readinputport(offset+1) & ~t1) & 0x1F); | |
| 714 | if (idx == 8) | |
| 740 | 715 | t2 = (sc2_Inputs[offset+8] & t2) | ( ( readinputport(offset+1+8) & ~t2) << 5); |
| 741 | ||
| 742 | sc2_Inputs[offset] = (sc2_Inputs[offset] & ~0x1F) | t1; | |
| 743 | sc2_Inputs[offset+8] = (sc2_Inputs[offset+8] & ~0x60) | t2; | |
| 744 | result = t1 | t2; | |
| 745 | break; | |
| 746 | ||
| 747 | case 4: | |
| 748 | case 5: | |
| 749 | case 6: | |
| 750 | case 7: | |
| 751 | t1 = input_override[offset]; // strobe 4-7 data 0-4 | |
| 752 | t2 = input_override[offset+4]; // strobe 8-B data 3-4 | |
| 753 | ||
| 754 | t1 = (sc2_Inputs[offset] & t1) | ( ( readinputport(offset+1) & ~t1) & 0x1F); | |
| 716 | else | |
| 755 | 717 | t2 = (sc2_Inputs[offset+4] & t2) | ( ( ( readinputport(offset+1+4) & ~t2) << 2) & 0x60); |
| 756 | 718 | |
| 757 | sc2_Inputs[offset] = (sc2_Inputs[offset] & ~0x1F) | t1; | |
| 758 | sc2_Inputs[offset+4] = (sc2_Inputs[offset+4] & ~0x60) | t2; | |
| 759 | result = t1 | t2; | |
| 760 | break; | |
| 761 | ||
| 762 | default: | |
| 763 | logerror("read strobe %d\n", offset); | |
| 719 | sc2_Inputs[offset] = (sc2_Inputs[offset] & ~0x1F) | t1; | |
| 720 | sc2_Inputs[offset+idx] = (sc2_Inputs[offset+idx] & ~0x60) | t2; | |
| 721 | result = t1 | t2; | |
| 764 | 722 | } |
| 765 | 723 | |
| 766 | 724 | return result; |
| r936 | r937 | |
| 825 | 783 | if ( data & 0x80 ) bank |= 0x01; |
| 826 | 784 | if ( expansion_latch & 2 ) bank |= 0x02; |
| 827 | 785 | |
| 828 | //logerror("start sound %d bank %d\n", data, bank); | |
| 829 | 786 | upd7759_set_bank_base(0, bank*0x20000); |
| 830 | 787 | |
| 831 | 788 | upd7759_port_w(0, data&0x3F); // setup sample |
| r936 | r937 | |
| 978 | 935 | if ( changed & p ) |
| 979 | 936 | { // this inhibit line has changed |
| 980 | 937 | coin_lockout_w(i, (~data & p) ); // update lockouts |
| 981 | ||
| 982 | //logerror("lockout %d, %s\n", i, data&p?"OFF":"ON"); | |
| 983 | ||
| 984 | 938 | changed &= ~p; |
| 985 | 939 | } |
| 986 | 940 | |
| r936 | r937 | |
| 996 | 950 | return 0; |
| 997 | 951 | } |
| 998 | 952 | |
| 999 | ||
| 1000 | 953 | /////////////////////////////////////////////////////////////////////////// |
| 1001 | 954 | |
| 1002 | 955 | static READ8_HANDLER( coin_input_r ) |
| r936 | r937 | |
| 1113 | 1066 | |
| 1114 | 1067 | static READ8_HANDLER( uart1stat_r ) |
| 1115 | 1068 | { |
| 1116 | return uart1_status; | |
| 1117 | } | |
| 1069 | int status = 0x06; | |
| 1118 | 1070 | |
| 1071 | if ( data_to_uart1 ) status |= 0x01; | |
| 1072 | if ( !data_to_uart2 ) status |= 0x02; | |
| 1073 | ||
| 1074 | return status; | |
| 1075 | } | |
| 1119 | 1076 | /////////////////////////////////////////////////////////////////////////// |
| 1120 | 1077 | |
| 1121 | 1078 | static READ8_HANDLER( uart1data_r ) |
| 1122 | 1079 | { |
| 1123 | return | |
| 1080 | return ua | |
| 1124 | 1081 | } |
| 1125 | 1082 | |
| 1126 | ////////////////////////////////////////////////////////////////////////// | |
| 1083 | ////////////////////////////////////////////////////////////////////////// | |
| 1127 | 1084 | |
| 1128 | 1085 | static WRITE8_HANDLER( uart1ctrl_w ) |
| 1129 | 1086 | { |
| 1087 | UART_LOG(("uart1ctrl:%x\n", data)); | |
| 1130 | 1088 | } |
| 1131 | ||
| 1132 | 1089 | /////////////////////////////////////////////////////////////////////////// |
| 1133 | 1090 | |
| 1134 | 1091 | static WRITE8_HANDLER( uart1data_w ) |
| 1135 | 1092 | { |
| 1136 | UART_LOG(("uart1:%c\n", data)); | |
| 1093 | data_to_uart2 = 1; | |
| 1094 | uart1_data = data; | |
| 1095 | UART_LOG(("uart1:%x\n", data)); | |
| 1137 | 1096 | } |
| 1138 | ||
| 1139 | 1097 | /////////////////////////////////////////////////////////////////////////// |
| 1140 | 1098 | |
| 1141 | 1099 | static READ8_HANDLER( uart2stat_r ) |
| 1142 | 1100 | { |
| 1143 | return uart2_status; | |
| 1144 | } | |
| 1101 | int status = 0x06; | |
| 1145 | 1102 | |
| 1103 | if ( data_to_uart2 ) status |= 0x01; | |
| 1104 | if ( !data_to_uart1 ) status |= 0x02; | |
| 1105 | ||
| 1106 | return status; | |
| 1107 | } | |
| 1146 | 1108 | /////////////////////////////////////////////////////////////////////////// |
| 1147 | 1109 | |
| 1148 | 1110 | static READ8_HANDLER( uart2data_r ) |
| 1149 | 1111 | { |
| 1150 | return | |
| 1112 | return uart2_data; | |
| 1151 | 1113 | } |
| 1152 | 1114 | |
| 1153 | 1115 | /////////////////////////////////////////////////////////////////////////// |
| 1154 | 1116 | |
| 1155 | 1117 | static WRITE8_HANDLER( uart2ctrl_w ) |
| 1156 | 1118 | { |
| 1119 | UART_LOG(("uart2ctrl:%x\n", data)); | |
| 1157 | 1120 | } |
| 1158 | 1121 | |
| 1159 | 1122 | /////////////////////////////////////////////////////////////////////////// |
| 1160 | 1123 | |
| 1161 | 1124 | static WRITE8_HANDLER( uart2data_w ) |
| 1162 | 1125 | { |
| 1163 | UART_LOG(("uart2:%c\n", data)); | |
| 1126 | data_to_uart1 = 1; | |
| 1127 | uart2_data = data; | |
| 1128 | UART_LOG(("uart2:%x\n", data)); | |
| 1164 | 1129 | } |
| 1165 | 1130 | |
| 1166 | 1131 | /////////////////////////////////////////////////////////////////////////// |
| r936 | r937 | |
| 1261 | 1226 | |
| 1262 | 1227 | e2data_to_read <<= 1; |
| 1263 | 1228 | |
| 1264 | | |
| 1229 | LOG | |
| 1265 | 1230 | |
| 1266 | 1231 | e2cnt++; |
| 1267 | 1232 | if ( e2cnt >= 8 ) |
| r936 | r937 | |
| 1304 | 1269 | |
| 1305 | 1270 | e2reg = data; |
| 1306 | 1271 | |
| 1307 | // logerror("e2: D:%d C:%d [%d]:%d\n", data&SDA?1:0, data&SCL?1:0, e2state, e2cnt ); | |
| 1308 | ||
| 1309 | 1272 | if ( changed ) |
| 1310 | 1273 | { |
| 1311 | 1274 | while ( 1 ) |
| r936 | r937 | |
| 1316 | 1279 | { // X24C08 Start condition (1->0 on SDA while SCL=1) |
| 1317 | 1280 | e2dummywrite = ( e2state == 5 ); |
| 1318 | 1281 | |
| 1319 | | |
| 1282 | LOG | |
| 1320 | 1283 | |
| 1321 | 1284 | e2state = 1; // ready for commands |
| 1322 | 1285 | e2cnt = 0; |
| r936 | r937 | |
| 1328 | 1291 | ( !(changed & SCL) && (data & SCL) ) // SCL=1 and not changed |
| 1329 | 1292 | ) |
| 1330 | 1293 | { // X24C08 Stop condition (0->1 on SDA while SCL=1) |
| 1331 | | |
| 1294 | LOG | |
| 1332 | 1295 | e2state = 0; |
| 1333 | 1296 | e2data = 0; |
| 1334 | 1297 | break; |
| r936 | r937 | |
| 1344 | 1307 | e2cnt = 0; |
| 1345 | 1308 | e2rw = e2data & 1; |
| 1346 | 1309 | |
| 1347 | logerror("e2ram: Slave address received !! device id=%01X device adr=%01d high order adr %0X RW=%d) %02X\n", | |
| 1348 | e2data>>4, (e2data & 0x08)?1:0, (e2data>>1) & 0x03, e2rw , e2data ); | |
| 1310 | LOG(("e2ram: Slave address received !! device id=%01X device adr=%01d high order adr %0X RW=%d) %02X\n", | |
| 1311 | e2data>>4, (e2data & 0x08)?1:0, (e2data>>1) & 0x03, e2rw , e2data )); | |
| 1349 | 1312 | |
| 1350 | 1313 | e2state = 2; |
| 1351 | 1314 | } |
| r936 | r937 | |
| 1360 | 1323 | |
| 1361 | 1324 | if ( ack < 0 ) |
| 1362 | 1325 | { |
| 1363 | | |
| 1326 | LOG | |
| 1364 | 1327 | e2state = 0; |
| 1365 | 1328 | } |
| 1366 | 1329 | else |
| 1367 | 1330 | { |
| 1368 | | |
| 1331 | LOG | |
| 1369 | 1332 | if ( e2dummywrite ) |
| 1370 | 1333 | { |
| 1371 | 1334 | e2dummywrite = 0; |
| r936 | r937 | |
| 1383 | 1346 | switch ( e2state ) |
| 1384 | 1347 | { |
| 1385 | 1348 | case 7: |
| 1386 | | |
| 1349 | LOG | |
| 1387 | 1350 | e2data_to_read = e2ram[e2address]; |
| 1388 | 1351 | break; |
| 1389 | 1352 | case 3: |
| 1390 | | |
| 1353 | LOG | |
| 1391 | 1354 | break; |
| 1392 | 1355 | default: |
| 1393 | | |
| 1356 | LOG | |
| 1394 | 1357 | break; |
| 1395 | 1358 | } |
| 1396 | 1359 | } |
| r936 | r937 | |
| 1405 | 1368 | e2data_pin = 0; |
| 1406 | 1369 | e2address = (e2address & 0xFF00) | e2data; |
| 1407 | 1370 | |
| 1408 | | |
| 1371 | LOG | |
| 1409 | 1372 | e2state = 4; |
| 1410 | 1373 | e2cnt = 0; |
| 1411 | 1374 | e2data = 0; |
| r936 | r937 | |
| 1422 | 1385 | if ( ack < 0 ) |
| 1423 | 1386 | { |
| 1424 | 1387 | e2state = 0; |
| 1425 | | |
| 1388 | LOG | |
| 1426 | 1389 | } |
| 1427 | 1390 | else |
| 1428 | 1391 | { |
| 1429 | 1392 | e2state = 5; |
| 1430 | | |
| 1393 | LOG | |
| 1431 | 1394 | } |
| 1432 | 1395 | } |
| 1433 | 1396 | break; |
| r936 | r937 | |
| 1435 | 1398 | case 5: // receive data to write |
| 1436 | 1399 | if ( recdata(changed, data) ) |
| 1437 | 1400 | { |
| 1438 | | |
| 1401 | LOG | |
| 1439 | 1402 | e2cnt = 0; |
| 1440 | 1403 | e2state = 6; // wait ack |
| 1441 | 1404 | } |
| r936 | r937 | |
| 1449 | 1412 | if ( ack < 0 ) |
| 1450 | 1413 | { |
| 1451 | 1414 | e2state = 0; |
| 1452 | | |
| 1415 | LOG | |
| 1453 | 1416 | } |
| 1454 | 1417 | else |
| 1455 | 1418 | { |
| 1456 | | |
| 1419 | LOG | |
| 1457 | 1420 | |
| 1458 | 1421 | e2ram[e2address] = e2data; |
| 1459 | 1422 | |
| r936 | r937 | |
| 1470 | 1433 | { |
| 1471 | 1434 | //e2data_pin = 0; |
| 1472 | 1435 | |
| 1473 | | |
| 1436 | LOG | |
| 1474 | 1437 | |
| 1475 | 1438 | e2state = 8; |
| 1476 | 1439 | } |
| r936 | r937 | |
| 1486 | 1449 | |
| 1487 | 1450 | e2data_to_read = e2ram[e2address]; |
| 1488 | 1451 | |
| 1489 | | |
| 1452 | LOG | |
| 1490 | 1453 | |
| 1491 | 1454 | e2cnt = 0; |
| 1492 | 1455 | e2data = 0; |
| r936 | r937 | |
| 1495 | 1458 | |
| 1496 | 1459 | case 0: |
| 1497 | 1460 | |
| 1498 | | |
| 1461 | LOG | |
| 1499 | 1462 | break; |
| 1500 | 1463 | } |
| 1501 | 1464 | break; |
| r936 | r937 | |
| 1505 | 1468 | |
| 1506 | 1469 | static int read_e2ram(void) |
| 1507 | 1470 | { |
| 1508 | | |
| 1471 | LOG | |
| 1509 | 1472 | |
| 1510 | 1473 | return e2data_pin; |
| 1511 | 1474 | } |
| r936 | r937 | |
| 1593 | 1556 | //BFM_dm01_reset(); No known video based game has a Matrix board |
| 1594 | 1557 | } |
| 1595 | 1558 | |
| 1559 | static VIDEO_UPDATE( addersc2 ) | |
| 1560 | { | |
| 1561 | if ( sc2_show_door ) | |
| 1562 | { | |
| 1563 | output_set_value("door",( Scorpion2_GetSwitchState(sc2_door_state>>4, sc2_door_state & 0x0F) ) ); | |
| 1564 | } | |
| 1565 | ||
| 1566 | return video_update_adder2(machine,screen,bitmap,cliprect); | |
| 1567 | } | |
| 1568 | ||
| 1596 | 1569 | // memory map for scorpion2 board video addon ///////////////////////////// |
| 1597 | 1570 | |
| 1598 | 1571 | static ADDRESS_MAP_START( memmap_vid, ADDRESS_SPACE_PROGRAM, 8 ) |
| r936 | r937 | |
| 2275 | 2248 | |
| 2276 | 2249 | INPUT_PORTS_END |
| 2277 | 2250 | |
| 2251 | // input ports for UK quintoon (older)///////////////////////////////////// | |
| 2252 | ||
| 2253 | static INPUT_PORTS_START( quintono ) | |
| 2254 | PORT_INCLUDE(quintoon) | |
| 2255 | PORT_MODIFY("STROBE10") | |
| 2256 | PORT_DIPNAME( 0x10, 0x00, "Stake per Game / Jackpot" )PORT_DIPLOCATION("DIL:11") | |
| 2257 | PORT_DIPSETTING( 0x00, "20p / 6 Pounds" ) | |
| 2258 | PORT_DIPSETTING( 0x10, "50p / 20 Pounds" ) | |
| 2259 | INPUT_PORTS_END | |
| 2260 | ||
| 2278 | 2261 | // input ports for slotsnl /////////////////////////////////////////////// |
| 2279 | 2262 | |
| 2280 | 2263 | static INPUT_PORTS_START( slotsnl ) |
| r936 | r937 | |
| 3053 | 3036 | /////////////////////////////////////////////////////////////////////////// |
| 3054 | 3037 | |
| 3055 | 3038 | static MACHINE_DRIVER_START( scorpion2_vid ) |
| 3056 | MDRV_MACHINE_RESET( init ) // main scorpion2 board initialisation | |
| 3039 | MDRV_MACHINE_RESET( init ) // main scorpion2 board initialisation | |
| 3057 | 3040 | MDRV_INTERLEAVE(16) // needed for serial communication !! |
| 3058 | ||
| 3059 | MDRV_CPU_ADD_TAG("main", M6809, 2000000 ) // 6809 CPU at 2 Mhz | |
| 3041 | MDRV_CPU_ADD_TAG("main", M6809, 2000000 ) // 6809 CPU at 2 Mhz | |
| 3060 | 3042 | MDRV_CPU_PROGRAM_MAP(memmap_vid,0) // setup scorpion2 board memorymap |
| 3061 | 3043 | MDRV_CPU_PERIODIC_INT(timer_irq, 1000) // generate 1000 IRQ's per second |
| 3044 | ||
| 3062 | 3045 | MDRV_NVRAM_HANDLER(bfm_sc2) |
| 3063 | 3046 | MDRV_DEFAULT_LAYOUT(layout_bfm_sc2) |
| 3064 | 3047 | |
| r936 | r937 | |
| 3068 | 3051 | MDRV_SCREEN_SIZE( 400, 280) |
| 3069 | 3052 | MDRV_SCREEN_VISIBLE_AREA( 0, 400-1, 0, 280-1) |
| 3070 | 3053 | MDRV_SCREEN_REFRESH_RATE(50) |
| 3054 | ||
| 3071 | 3055 | MDRV_VIDEO_START( adder2) |
| 3072 | 3056 | MDRV_VIDEO_RESET( adder2) |
| 3073 | MDRV_VIDEO_UPDATE(adder2) | |
| 3057 | MDRV_VIDEO_UPDATE(addersc2) | |
| 3074 | 3058 | |
| 3075 | 3059 | MDRV_PALETTE_LENGTH(16) |
| 3076 | 3060 | MDRV_COLORTABLE_LENGTH(16) |
| r936 | r937 | |
| 3118 | 3102 | |
| 3119 | 3103 | // UK quintoon initialisation //////////////////////////////////////////////// |
| 3120 | 3104 | |
| 3121 | static DRIVER_INIT | |
| 3105 | static DRIVER_INIT | |
| 3122 | 3106 | { |
| 3123 | 3107 | sc2_common_init(); |
| 3124 | 3108 | adder2_decode_char_roms(); |
| 3125 | Mechmtr_init(8); // setup mech meters | |
| 3109 | Mechmtr_init(8); // setup mech meters | |
| 3126 | 3110 | |
| 3127 | 3111 | has_hopper = 0; |
| 3128 | 3112 | |
| 3129 | Scorpion2_SetSwitchState(3,0,1); // tube1 level switch | |
| 3130 | Scorpion2_SetSwitchState(3,1,1); // tube2 level switch | |
| 3131 | Scorpion2_SetSwitchState(3,2,1); // tube3 level switch | |
| 3113 | Scorpion2_SetSwitchState(3,0,1); // tube1 level switch | |
| 3114 | Scorpion2_SetSwitchState(3,1,1); // tube2 level switch | |
| 3115 | Scorpion2_SetSwitchState(3,2,1); // tube3 level switch | |
| 3132 | 3116 | |
| 3133 | 3117 | Scorpion2_SetSwitchState(5,2,1); |
| 3134 | 3118 | Scorpion2_SetSwitchState(6,4,1); |
| r936 | r937 | |
| 3142 | 3126 | static DRIVER_INIT( pyramid ) |
| 3143 | 3127 | { |
| 3144 | 3128 | sc2_common_init(); |
| 3145 | adder2_decode_char_roms(); | |
| 3129 | adder2_decode_char_roms(); | |
| 3146 | 3130 | adder2_common_init(); |
| 3147 | 3131 | |
| 3148 | 3132 | has_hopper = 1; |
| 3149 | 3133 | |
| 3150 | Scorpion2_SetSwitchState(3,0,1); // tube1 level switch | |
| 3151 | Scorpion2_SetSwitchState(3,1,1); // tube2 level switch | |
| 3152 | Scorpion2_SetSwitchState(3,2,1); // tube3 level switch | |
| 3134 | Scorpion2_SetSwitchState(3,0,1); // tube1 level switch | |
| 3135 | Scorpion2_SetSwitchState(3,1,1); // tube2 level switch | |
| 3136 | Scorpion2_SetSwitchState(3,2,1); // tube3 level switch | |
| 3153 | 3137 | |
| 3154 | 3138 | sc2_show_door = 1; |
| 3155 | 3139 | sc2_door_state = 0x41; |
| r936 | r937 | |
| 3159 | 3143 | static DRIVER_INIT( sltsbelg ) |
| 3160 | 3144 | { |
| 3161 | 3145 | sc2_common_init(); |
| 3162 | adder2_decode_char_roms(); | |
| 3146 | adder2_decode_char_roms(); | |
| 3163 | 3147 | adder2_common_init(); |
| 3164 | 3148 | |
| 3165 | 3149 | has_hopper = 1; |
| r936 | r937 | |
| 3173 | 3157 | static DRIVER_INIT( adder_dutch ) |
| 3174 | 3158 | { |
| 3175 | 3159 | sc2_common_init(); |
| 3176 | adder2_decode_char_roms(); | |
| 3160 | adder2_decode_char_roms(); | |
| 3177 | 3161 | adder2_common_init(); |
| 3178 | 3162 | |
| 3179 | 3163 | has_hopper = 0; |
| 3180 | 3164 | |
| 3181 | Scorpion2_SetSwitchState(3,0,1); // tube1 level switch | |
| 3182 | Scorpion2_SetSwitchState(3,1,1); // tube2 level switch | |
| 3183 | Scorpion2_SetSwitchState(3,2,1); // tube3 level switch | |
| 3165 | Scorpion2_SetSwitchState(3,0,1); // tube1 level switch | |
| 3166 | Scorpion2_SetSwitchState(3,1,1); // tube2 level switch | |
| 3167 | Scorpion2_SetSwitchState(3,2,1); // tube3 level switch | |
| 3184 | 3168 | |
| 3185 | 3169 | sc2_show_door = 1; |
| 3186 | 3170 | sc2_door_state = 0x41; |
| r936 | r937 | |
| 3191 | 3175 | static DRIVER_INIT( gldncrwn ) |
| 3192 | 3176 | { |
| 3193 | 3177 | sc2_common_init(); |
| 3194 | adder2_decode_char_roms(); | |
| 3178 | adder2_decode_char_roms(); | |
| 3195 | 3179 | adder2_common_init(); |
| 3196 | 3180 | |
| 3197 | 3181 | has_hopper = 0; |
| 3198 | 3182 | |
| 3199 | Scorpion2_SetSwitchState(3,0,1); // tube1 level switch | |
| 3200 | Scorpion2_SetSwitchState(3,1,1); // tube2 level switch | |
| 3201 | Scorpion2_SetSwitchState(3,2,1); // tube3 level switch | |
| 3183 | Scorpion2_SetSwitchState(3,0,1); // tube1 level switch | |
| 3184 | Scorpion2_SetSwitchState(3,1,1); // tube2 level switch | |
| 3185 | Scorpion2_SetSwitchState(3,2,1); // tube3 level switch | |
| 3202 | 3186 | |
| 3203 | 3187 | sc2_show_door = 0; |
| 3204 | 3188 | sc2_door_state = 0x41; |
| 3205 | 3189 | } |
| 3206 | 3190 | |
| 3207 | // ROM definition UK Quintoon //////////////////////////////////////////// | |
| 3191 | // ROM definition UK Quintoon //////////////////////////////////////////// | |
| 3208 | 3192 | |
| 3209 | 3193 | ROM_START( quintoon ) |
| 3210 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) /* 64 + 8k for code */ | |
| 3211 | ROM_LOAD( "95750203.bin", 0x0000, 0x10000, CRC(037ef2d0) SHA1(6958624e29629a7639a80e8929b833a8b0201833)) | |
| 3194 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3195 | ROM_LOAD("95750206.p1", 0x00000, 0x10000, CRC(05f4bfad) SHA1(22751573f3a51a9fd2d2a75a7d1b20d78112e0bb)) | |
| 3212 | 3196 | |
| 3213 | 3197 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) |
| 3214 | ROM_LOAD( | |
| 3198 | ROM_LOAD( | |
| 3215 | 3199 | |
| 3216 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // samples - using Dutch version, need to check a UK Quintoon PCB | |
| 3217 | ROM_LOAD( "95001016.snd", 0x00000, 0x20000, BAD_DUMP CRC(cf097d41) SHA1(6712f93896483360256d8baffc05977c8e532ef1)) | |
| 3200 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // using Dutch samples, need to check a UK Quintoon PCB | |
| 3201 | ROM_LOAD("95001016.snd", 0x00000, 0x20000, BAD_DUMP CRC(cf097d41) SHA1(6712f93896483360256d8baffc05977c8e532ef1)) | |
| 3218 | 3202 | |
| 3219 | 3203 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 3220 | ROM_LOAD( "quinp233",0x00000, 0x20000, CRC(3d4ebecf) SHA1(b339cf16797ccf7a1ec20fcebf52b6edad9a1047)) | |
| 3204 | ROM_LOAD("quinp233", 0x00000, 0x20000, CRC(3d4ebecf) SHA1(b339cf16797ccf7a1ec20fcebf52b6edad9a1047)) | |
| 3205 | ROM_END | |
| 3221 | 3206 | |
| 3207 | // ROM definition UK Quintoon (older) //////////////////////////////////// | |
| 3208 | ||
| 3209 | ROM_START( quintono ) | |
| 3210 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3211 | ROM_LOAD("95750203.bin", 0x00000, 0x10000, CRC(037ef2d0) SHA1(6958624e29629a7639a80e8929b833a8b0201833)) | |
| 3212 | ||
| 3213 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) | |
| 3214 | ROM_LOAD("quinp132", 0x00000, 0x20000, CRC(63896a7f) SHA1(81aa56874a15faa3aabdfc0fc524b2e25b751f22)) | |
| 3215 | ||
| 3216 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // using Dutch samples, need to check a UK Quintoon PCB | |
| 3217 | ROM_LOAD("95001016.snd", 0x00000, 0x20000, BAD_DUMP CRC(cf097d41) SHA1(6712f93896483360256d8baffc05977c8e532ef1)) | |
| 3218 | ||
| 3219 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) | |
| 3220 | ROM_LOAD("quinp233", 0x00000, 0x20000, CRC(3d4ebecf) SHA1(b339cf16797ccf7a1ec20fcebf52b6edad9a1047)) | |
| 3222 | 3221 | ROM_END |
| 3223 | 3222 | |
| 3224 | 3223 | // ROM definition Dutch Quintoon /////////////////////////////////////////// |
| 3225 | 3224 | |
| 3226 | 3225 | ROM_START( qntoond ) |
| 3227 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) /* 64 + 8k for code */ | |
| 3228 | ROM_LOAD( "95750243.bin", 0x0000, 0x10000, CRC(36a8dcd1) SHA1(ab21301312fbb6609f850e1cf6bcda5a2b7f66f5)) | |
| 3226 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3227 | ROM_LOAD("95750243.bin", 0x00000, 0x10000, CRC(36a8dcd1) SHA1(ab21301312fbb6609f850e1cf6bcda5a2b7f66f5)) | |
| 3229 | 3228 | |
| 3230 | 3229 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) |
| 3231 | ROM_LOAD( | |
| 3230 | ROM_LOAD( | |
| 3232 | 3231 | |
| 3233 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // samples | |
| 3234 | ROM_LOAD( "95001016.snd", 0x00000, 0x20000, CRC(cf097d41) SHA1(6712f93896483360256d8baffc05977c8e532ef1)) | |
| 3232 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) | |
| 3233 | ROM_LOAD("95001016.snd", 0x00000, 0x20000, CRC(cf097d41) SHA1(6712f93896483360256d8baffc05977c8e532ef1)) | |
| 3235 | 3234 | |
| 3236 | 3235 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 3237 | ROM_LOAD( "95770025.chr", 0x00000, 0x20000, CRC(f59748ea) SHA1(f0f7f914fdf72db8eb60717b95e7d027c0081339)) | |
| 3238 | ||
| 3236 | ROM_LOAD("95770025.chr", 0x00000, 0x20000, CRC(f59748ea) SHA1(f0f7f914fdf72db8eb60717b95e7d027c0081339)) | |
| 3239 | 3237 | ROM_END |
| 3240 | 3238 | |
| 3241 | 3239 | // ROM definition Dutch Quintoon alternate set ///////////////////////////// |
| 3242 | 3240 | |
| 3243 | 3241 | ROM_START( qntoondo ) |
| 3244 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) /* 64 + 8k for code */ | |
| 3245 | ROM_LOAD( "95750136.bin", 0x0000, 0x10000, CRC(839ea01d) SHA1(d7f77dbaea4e87c3d782408eb50d10f44b6df5e2)) | |
| 3242 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3243 | ROM_LOAD("95750136.bin", 0x00000, 0x10000, CRC(839ea01d) SHA1(d7f77dbaea4e87c3d782408eb50d10f44b6df5e2)) | |
| 3246 | 3244 | |
| 3247 | 3245 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) |
| 3248 | ROM_LOAD( | |
| 3246 | ROM_LOAD( | |
| 3249 | 3247 | |
| 3250 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // samples | |
| 3251 | ROM_LOAD( "95001016.snd", 0x00000, 0x20000, CRC(cf097d41) SHA1(6712f93896483360256d8baffc05977c8e532ef1)) | |
| 3248 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) | |
| 3249 | ROM_LOAD("95001016.snd", 0x00000, 0x20000, CRC(cf097d41) SHA1(6712f93896483360256d8baffc05977c8e532ef1)) | |
| 3252 | 3250 | |
| 3253 | 3251 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 3254 | ROM_LOAD( "95770025.chr", 0x00000, 0x20000, CRC(f59748ea) SHA1(f0f7f914fdf72db8eb60717b95e7d027c0081339)) | |
| 3255 | ||
| 3252 | ROM_LOAD("95770025.chr", 0x00000, 0x20000, CRC(f59748ea) SHA1(f0f7f914fdf72db8eb60717b95e7d027c0081339)) | |
| 3256 | 3253 | ROM_END |
| 3257 | 3254 | |
| 3258 | 3255 | // ROM definition dutch golden crown ////////////////////////////////////// |
| 3259 | 3256 | |
| 3260 | 3257 | ROM_START( gldncrwn ) |
| 3261 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) /* 64 + 8k for code */ | |
| 3262 | ROM_LOAD( "95752011.bin", 0x0000, 0x10000, CRC(54f7cca0) SHA1(835727d88113700a38060f880b4dfba2ded41487)) | |
| 3258 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3259 | ROM_LOAD("95752011.bin", 0x00000, 0x10000, CRC(54f7cca0) SHA1(835727d88113700a38060f880b4dfba2ded41487)) | |
| 3263 | 3260 | |
| 3264 | 3261 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) |
| 3265 | ROM_LOAD( | |
| 3262 | ROM_LOAD( | |
| 3266 | 3263 | |
| 3267 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // samples | |
| 3268 | ROM_LOAD( "95001039.snd", 0x00000, 0x20000, CRC(6af26157) SHA1(9b3a85f5dd760c4430e38e2844928b74aadc7e75)) | |
| 3264 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) | |
| 3265 | ROM_LOAD("95001039.snd", 0x00000, 0x20000, CRC(6af26157) SHA1(9b3a85f5dd760c4430e38e2844928b74aadc7e75)) | |
| 3269 | 3266 | |
| 3270 | 3267 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 3271 | ROM_LOAD( "95770118.ch1", 0x00000, 0x20000, CRC(9c9ac946) SHA1(9a571e7d00f6654242aface032c2fb186ef44aba)) | |
| 3272 | ROM_LOAD( "95770119.ch2", 0x20000, 0x20000, CRC(9e0fdb2e) SHA1(05e8257285b0009df4fcc73e93490876358a8be8)) | |
| 3268 | ROM_LOAD("95770118.ch1", 0x00000, 0x20000, CRC(9c9ac946) SHA1(9a571e7d00f6654242aface032c2fb186ef44aba)) | |
| 3269 | ROM_LOAD("95770119.ch2", 0x20000, 0x20000, CRC(9e0fdb2e) SHA1(05e8257285b0009df4fcc73e93490876358a8be8)) | |
| 3273 | 3270 | |
| 3274 | 3271 | ROM_REGION( 0x10, REGION_PROMS, ROMREGION_DISPOSE ) |
| 3275 | ROM_LOAD( | |
| 3272 | ROM_LOAD( | |
| 3276 | 3273 | ROM_END |
| 3277 | 3274 | |
| 3278 | 3275 | // ROM definition Dutch Paradice ////////////////////////////////////////// |
| 3279 | 3276 | |
| 3280 | 3277 | ROM_START( paradice ) |
| 3281 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) /* 64 + 8k for code */ | |
| 3282 | ROM_LOAD( "95750615.bin", 0x0000, 0x10000, CRC(f51192e5) SHA1(a1290e32bba698006e83fd8d6075202586232929)) | |
| 3278 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3279 | ROM_LOAD("95750615.bin", 0x00000, 0x10000, CRC(f51192e5) SHA1(a1290e32bba698006e83fd8d6075202586232929)) | |
| 3283 | 3280 | |
| 3284 | 3281 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) |
| 3285 | ROM_LOAD( | |
| 3282 | ROM_LOAD( | |
| 3286 | 3283 | |
| 3287 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // samples | |
| 3288 | ROM_LOAD( "95001037.snd", 0x00000, 0x20000, CRC(82f74276) SHA1(c51c3caeb7bf514ec7a1b452c8effc4c79186062)) | |
| 3284 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) | |
| 3285 | ROM_LOAD("95001037.snd", 0x00000, 0x20000, CRC(82f74276) SHA1(c51c3caeb7bf514ec7a1b452c8effc4c79186062)) | |
| 3289 | 3286 | |
| 3290 | 3287 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 3291 | ROM_LOAD( "95770085.ch1", 0x00000, 0x20000, CRC(4d1fb82f) SHA1(054f683d1d7c884911bd2d0f85aab4c59ddf9930)) | |
| 3292 | ROM_LOAD( "95770086.ch2", 0x20000, 0x20000, CRC(7b566e11) SHA1(f34c82ad75a0f88204ac4ae83a00801215c46ca9)) | |
| 3288 | ROM_LOAD("95770085.ch1", 0x00000, 0x20000, CRC(4d1fb82f) SHA1(054f683d1d7c884911bd2d0f85aab4c59ddf9930)) | |
| 3289 | ROM_LOAD("95770086.ch2", 0x20000, 0x20000, CRC(7b566e11) SHA1(f34c82ad75a0f88204ac4ae83a00801215c46ca9)) | |
| 3293 | 3290 | |
| 3294 | 3291 | ROM_REGION( 0x10, REGION_PROMS, ROMREGION_DISPOSE ) |
| 3295 | 3292 | ROM_LOAD( "pdcepal.bin", 0, 8 , CRC(64020c97) SHA1(9371841e2df950c1f2e5b5a4b52621beb6f60945)) |
| r936 | r937 | |
| 3298 | 3295 | // ROM definition Dutch Pokio ///////////////////////////////////////////// |
| 3299 | 3296 | |
| 3300 | 3297 | ROM_START( pokio ) |
| 3301 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) /* 64 + 8k for code */ | |
| 3302 | ROM_LOAD( "95750278.bin", 0x0000, 0x10000, CRC(5124b24d) SHA1(9bc63891a8e9283c2baa64c264a5d6d1625d44b2)) | |
| 3298 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3299 | ROM_LOAD("95750278.bin", 0x00000, 0x10000, CRC(5124b24d) SHA1(9bc63891a8e9283c2baa64c264a5d6d1625d44b2)) | |
| 3303 | 3300 | |
| 3304 | 3301 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) |
| 3305 | ROM_LOAD( | |
| 3302 | ROM_LOAD( | |
| 3306 | 3303 | |
| 3307 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // samples | |
| 3308 | ROM_LOAD( "95001016.snd", 0x00000, 0x20000, CRC(98aaff76) SHA1(4a59cf83daf018d93f1ff7805e06309d2f3d7252)) | |
| 3304 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) | |
| 3305 | ROM_LOAD("95001016.snd", 0x00000, 0x20000, CRC(98aaff76) SHA1(4a59cf83daf018d93f1ff7805e06309d2f3d7252)) | |
| 3309 | 3306 | |
| 3310 | 3307 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 3311 | ROM_LOAD( | |
| 3308 | ROM_LOAD( | |
| 3312 | 3309 | |
| 3313 | 3310 | ROM_REGION( 0x10, REGION_PROMS, ROMREGION_DISPOSE ) |
| 3314 | ROM_LOAD( | |
| 3311 | ROM_LOAD( | |
| 3315 | 3312 | ROM_END |
| 3316 | 3313 | |
| 3317 | 3314 | // ROM definition pyramid prototype ////////////////////////////////////// |
| 3318 | 3315 | |
| 3319 | 3316 | ROM_START( pyramid ) |
| 3320 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) /* 64 + 8k for code */ | |
| 3321 | ROM_LOAD( "95750898.bin", 0x0000, 0x10000, CRC(3b0df16c) SHA1(9af599fe604f86c72986aa1610d74837852e023f)) | |
| 3317 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3318 | ROM_LOAD("95750898.bin", 0x00000, 0x10000, CRC(3b0df16c) SHA1(9af599fe604f86c72986aa1610d74837852e023f)) | |
| 3322 | 3319 | |
| 3323 | 3320 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) |
| 3324 | ROM_LOAD( | |
| 3321 | ROM_LOAD( | |
| 3325 | 3322 | |
| 3326 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // samples | |
| 3327 | ROM_LOAD( "95001038.snd", 0x00000, 0x20000, CRC(f885c42e) SHA1(4d79fc5ae4c58247740d78d81302bfbb43331c43)) | |
| 3323 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) | |
| 3324 | ROM_LOAD("95001038.snd", 0x00000, 0x20000, CRC(f885c42e) SHA1(4d79fc5ae4c58247740d78d81302bfbb43331c43)) | |
| 3328 | 3325 | |
| 3329 | 3326 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 3330 | ROM_LOAD( "95770106.ch1", 0x00000, 0x20000, CRC(a83c27ae) SHA1(f61ca3cdf19a933bae18c1b32a5fb0a2204dde78)) | |
| 3331 | ROM_LOAD( "95770107.ch2", 0x20000, 0x20000, CRC(52e59f64) SHA1(ea4828c2cfb72cd77c92c60560b4d5ee424f7dca)) | |
| 3327 | ROM_LOAD("95770106.ch1", 0x00000, 0x20000, CRC(a83c27ae) SHA1(f61ca3cdf19a933bae18c1b32a5fb0a2204dde78)) | |
| 3328 | ROM_LOAD("95770107.ch2", 0x20000, 0x20000, CRC(52e59f64) SHA1(ea4828c2cfb72cd77c92c60560b4d5ee424f7dca)) | |
| 3332 | 3329 | |
| 3333 | 3330 | ROM_REGION( 0x10, REGION_PROMS, ROMREGION_DISPOSE ) |
| 3334 | ROM_LOAD( | |
| 3331 | ROM_LOAD( | |
| 3335 | 3332 | ROM_END |
| 3336 | 3333 | |
| 3337 | 3334 | // ROM definition Dutch slots ///////////////////////////////////////////// |
| 3338 | 3335 | |
| 3339 | 3336 | ROM_START( slotsnl ) |
| 3340 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) /* 64 + 8k for code */ | |
| 3341 | ROM_LOAD( "95750368.bin", 0x0000, 0x10000, CRC(3a43048c) SHA1(13728e05b334cba90ea9cc51ea00c4384baa8614)) | |
| 3337 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3338 | ROM_LOAD("95750368.bin", 0x00000, 0x10000, CRC(3a43048c) SHA1(13728e05b334cba90ea9cc51ea00c4384baa8614)) | |
| 3342 | 3339 | |
| 3343 | 3340 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) |
| 3344 | ROM_LOAD( | |
| 3341 | ROM_LOAD( | |
| 3345 | 3342 | |
| 3346 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // samples | |
| 3347 | ROM_LOAD( "95001029.snd", 0x00000, 0x20000, CRC(7749c724) SHA1(a87cce0c99e392f501bba44b3936a7059d682c9c)) | |
| 3343 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) | |
| 3344 | ROM_LOAD("95001029.snd", 0x00000, 0x20000, CRC(7749c724) SHA1(a87cce0c99e392f501bba44b3936a7059d682c9c)) | |
| 3348 | 3345 | |
| 3349 | 3346 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 3350 | ROM_LOAD( | |
| 3347 | ROM_LOAD( | |
| 3351 | 3348 | |
| 3352 | 3349 | ROM_REGION( 0x10, REGION_PROMS, ROMREGION_DISPOSE ) |
| 3353 | 3350 | ROM_LOAD( "slotspal.bin", 0, 8 , CRC(ee5421f0) SHA1(21bdcbf11dda8b1a93c49ae1c706954bba53c917)) |
| r936 | r937 | |
| 3356 | 3353 | // ROM definition Belgian Slots (Token pay per round) Payslide //////////// |
| 3357 | 3354 | |
| 3358 | 3355 | ROM_START( sltblgtk ) |
| 3359 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) /* 64 + 8k for code */ | |
| 3360 | ROM_LOAD( "95750943.bin", 0x0000, 0x10000, CRC(c9fb8153) SHA1(7c1d0660c15f05b1e0784d8322c62981fe8dc4c9)) | |
| 3356 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3357 | ROM_LOAD("95750943.bin", 0x00000, 0x10000, CRC(c9fb8153) SHA1(7c1d0660c15f05b1e0784d8322c62981fe8dc4c9)) | |
| 3361 | 3358 | |
| 3362 | 3359 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) |
| 3363 | ROM_LOAD( | |
| 3360 | ROM_LOAD( | |
| 3364 | 3361 | |
| 3365 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // samples | |
| 3366 | ROM_LOAD( "sound029.bin", 0x00000, 0x20000, CRC(7749c724) SHA1(a87cce0c99e392f501bba44b3936a7059d682c9c)) | |
| 3362 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) | |
| 3363 | ROM_LOAD("sound029.bin", 0x00000, 0x20000, CRC(7749c724) SHA1(a87cce0c99e392f501bba44b3936a7059d682c9c)) | |
| 3367 | 3364 | |
| 3368 | 3365 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 3369 | ROM_LOAD( | |
| 3366 | ROM_LOAD( | |
| 3370 | 3367 | |
| 3371 | 3368 | ROM_REGION( 0x10, REGION_PROMS, ROMREGION_DISPOSE ) |
| 3372 | ROM_LOAD( | |
| 3369 | ROM_LOAD( | |
| 3373 | 3370 | ROM_END |
| 3374 | 3371 | |
| 3375 | 3372 | // ROM definition Belgian Slots (Cash Payout) ///////////////////////////// |
| 3376 | 3373 | |
| 3377 | 3374 | ROM_START( sltblgp1 ) |
| 3378 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) /* 64 + 8k for code */ | |
| 3379 | ROM_LOAD( "95752008.bin", 0x0000, 0x10000, CRC(3167d3b9) SHA1(a28563f65d55c4d47f3e7fdb41e050d8a733b9bd)) | |
| 3375 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3376 | ROM_LOAD("95752008.bin", 0x00000, 0x10000, CRC(3167d3b9) SHA1(a28563f65d55c4d47f3e7fdb41e050d8a733b9bd)) | |
| 3380 | 3377 | |
| 3381 | 3378 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) |
| 3382 | ROM_LOAD( | |
| 3379 | ROM_LOAD( | |
| 3383 | 3380 | |
| 3384 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // samples | |
| 3385 | ROM_LOAD( "sound033.bin", 0x00000, 0x20000, CRC(bb1dfa55) SHA1(442454fccfe03e6f4c3353551cb7459e184a099d)) | |
| 3381 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) | |
| 3382 | ROM_LOAD("sound033.bin", 0x00000, 0x20000, CRC(bb1dfa55) SHA1(442454fccfe03e6f4c3353551cb7459e184a099d)) | |
| 3386 | 3383 | |
| 3387 | 3384 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 3388 | ROM_LOAD( | |
| 3385 | ROM_LOAD( | |
| 3389 | 3386 | |
| 3390 | 3387 | ROM_REGION( 0x10, REGION_PROMS, ROMREGION_DISPOSE ) |
| 3391 | ROM_LOAD( | |
| 3388 | ROM_LOAD( | |
| 3392 | 3389 | ROM_END |
| 3393 | 3390 | |
| 3394 | 3391 | // ROM definition Belgian Slots (Cash Payout) ///////////////////////////// |
| 3395 | 3392 | |
| 3396 | 3393 | ROM_START( sltblgpo ) |
| 3397 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) /* 64 + 8k for code */ | |
| 3398 | ROM_LOAD( "95770938.bin", 0x0000, 0x10000, CRC(7e802634) SHA1(fecf86e632546649d5e647c42a248b39fc2cf982)) | |
| 3394 | ROM_REGION( 0x12000, REGION_CPU1, 0 ) | |
| 3395 | ROM_LOAD("95770938.bin", 0x00000, 0x10000, CRC(7e802634) SHA1(fecf86e632546649d5e647c42a248b39fc2cf982)) | |
| 3399 | 3396 | |
| 3400 | 3397 | ROM_REGION( 0x20000, REGION_CPU2, 0 ) |
| 3401 | ROM_LOAD( | |
| 3398 | ROM_LOAD( | |
| 3402 | 3399 | |
| 3403 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) // samples | |
| 3404 | ROM_LOAD( "sound033.bin", 0x00000, 0x20000, CRC(bb1dfa55) SHA1(442454fccfe03e6f4c3353551cb7459e184a099d)) | |
| 3400 | ROM_REGION( 0x20000, REGION_SOUND1, 0 ) | |
| 3401 | ROM_LOAD("sound033.bin", 0x00000, 0x20000, CRC(bb1dfa55) SHA1(442454fccfe03e6f4c3353551cb7459e184a099d)) | |
| 3405 | 3402 | |
| 3406 | 3403 | ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 3407 | ROM_LOAD( | |
| 3404 | ROM_LOAD( | |
| 3408 | 3405 | |
| 3409 | 3406 | ROM_REGION( 0x10, REGION_PROMS, ROMREGION_DISPOSE ) |
| 3410 | ROM_LOAD( | |
| 3407 | ROM_LOAD( | |
| 3411 | 3408 | ROM_END |
| 3412 | 3409 | |
| 3413 | 3410 | // year, name, parent, machine, input, init, monitor, company, fullname |
| 3414 | 3411 | GAMEL( 1993, qntoondo, qntoond, scorpion2_vid, qntoond, adder_dutch,0, "BFM/ELAM", "Quintoon (Dutch, Game Card 95-750-136)", GAME_SUPPORTS_SAVE,layout_quintoon ) |
| 3415 | GAMEL( 1993, quintoon, 0, scorpion2_vid, quintoon, quintoon, 0, "BFM", "Quintoon (UK, Game Card 95-750-203)", GAME_SUPPORTS_SAVE|GAME_IMPERFECT_SOUND,layout_quintoon ) //Current samples need verification | |
| 3412 | GAMEL( 1993, quintoon, 0, scorpion2_vid, quintoon, quintoon, 0, "BFM", "Quintoon (UK, Game Card 95-750-206)", GAME_SUPPORTS_SAVE|GAME_IMPERFECT_SOUND,layout_quintoon ) //Current samples need verification | |
| 3413 | GAMEL( 1993, quintono, quintoon, scorpion2_vid, quintono, quintoon, 0, "BFM", "Quintoon (UK, Game Card 95-750-203)", GAME_SUPPORTS_SAVE|GAME_IMPERFECT_SOUND,layout_quintoon ) //Current samples need verification | |
| 3416 | 3414 | GAMEL( 1993, qntoond, 0, scorpion2_vid, qntoond, adder_dutch,0, "BFM/ELAM", "Quintoon (Dutch, Game Card 95-750-243)", GAME_SUPPORTS_SAVE,layout_quintoon ) |
| 3417 | 3415 | GAMEL( 1994, pokio, 0, scorpion2_vid, pokio, adder_dutch,0, "BFM/ELAM", "Pokio (Dutch, Game Card 95-750-278)", GAME_SUPPORTS_SAVE,layout_pokio ) |
| 3418 | 3416 | GAMEL( 1995, slotsnl, 0, scorpion2_vid, slotsnl, adder_dutch,0, "BFM/ELAM", "Slots (Dutch, Game Card 95-750-368)", GAME_SUPPORTS_SAVE,layout_slots ) |
| r936 | r937 | |
|---|---|---|
| 10 | 10 | Custom: TC17G032AP-0246 (blitter) |
| 11 | 11 | |
| 12 | 12 | --------------------------------------------------------------------------------------------------------------------- |
| 13 | Year + Game Board(s) Sound Palette Notes | |
| 13 | Year + Game Board(s) Sound Clock Palette Notes | |
| 14 | 14 | --------------------------------------------------------------------------------------------------------------------- |
| 15 | 88 Hana no Mai D1610088L1 AY8912 YM2203 M5205 PROM | |
| 16 | 88 Hana Kochou D201901L2 + D201901L1-0 AY8912 YM2203 M5205 PROM | |
| 17 | 89 Hana Oriduru D2304268L AY8912 YM2413 M5205 RAM | |
| 18 | 89 Dragon Punch D24? YM2203 PROM | |
| 19 | 89 Mahjong Friday D2607198L1 YM2413 PROM | |
| 20 | 89 Sports Match D31? YM2203 PROM | |
| 21 | 90 Jong Tou Ki (1) D1505178-A + D2711078L-B AY8912 YM2203 M5205 PROM | |
| 22 | 90 Mahjong Campus Hunting D3312108L1-1 + D23SUB1 AY8912 YM2413 M5205 RAM | |
| 23 | 90 7jigen no Youseitachi D3707198L1 + D23SUB1 AY8912 YM2413 M5205 RAM | |
| 24 | 90 Mahjong Electron Base AY8912 YM2413 RAM | |
| 25 | 90 Mahjong X-Tal/Diamond 7 D4005208L1-1 + D23SUB AY8912 YM2413 M5205 RAM | |
| 26 | 90 Neruton Haikujiradan D4005208L1-1 + D4508308L-2 AY8912 YM2413 M5205 RAM | |
| 27 | 91 Mahjong Yarunara D5512068L1-1 + D4508308L-2 AY8912 YM2413 M5205 RAM | |
| 28 | 91 Mahjong Angels D5512068L1-1 + D6107068L-1 AY8912 YM2413 M5205 RAM | |
| 29 | 91 Mahjong Dial Q2 D5212298L-1 YM2413 PROM | |
| 30 | 91 Mahjong Tenkaigen AY8910 YM2413 M6242 RAM TMP91P640, protecttion | |
| 31 | 92 Quiz TV Gassyuukoku Q&Q D5512068L1-2 + D6410288L-1 AY8912 YM2413 M5205 RAM | |
| 32 | 94 Mahjong Reach (bootleg) bootleg AY8910 YM2413 M6242 PROM TMP91P640 | |
| 33 | 94 Maya YM2203 PROM | |
| 34 | 96 Mahjong Raijinhai DX D10010318L1 + D10502168 AY8910 M6242 PROM undumped TMP91P640 code | |
| 35 | 9? Inca YM2203 PROM | |
| 15 | 88 Hana no Mai D1610088L1 AY8912 YM2203 M5205 PROM | |
| 16 | 88 Hana Kochou D201901L2 + D201901L1-0 AY8912 YM2203 M5205 PROM | |
| 17 | 89 Hana Oriduru D2304268L AY8912 YM2413 M5205 RAM | |
| 18 | 89 Dragon Punch D24? YM2203 PROM | |
| 19 | 89 Mahjong Friday D2607198L1 YM2413 PROM | |
| 20 | 89 Sports Match D31? YM2203 PROM | |
| 21 | 90 Jong Tou Ki D1505178-A + D2711078L-B AY8912 YM2203 M5205 PROM 2 x Z80, 2 x blitter | |
| 22 | 90 Mahjong Campus Hunting D3312108L1-1 + D23SUB1 AY8912 YM2413 M5205 RAM | |
| 23 | 90 7jigen no Youseitachi D3707198L1 + D23SUB1 AY8912 YM2413 M5205 RAM | |
| 24 | 90 Mahjong Electron Base AY8912 YM2413 RAM | |
| 25 | 90 Mahjong X-Tal/Diamond 7 D4005208L1-1 + D23SUB AY8912 YM2413 M5205 RAM | |
| 26 | 90 Neruton Haikujiradan D4005208L1-1 + D4508308L-2 AY8912 YM2413 M5205 RAM | |
| 27 | 91 Mahjong Yarunara D5512068L1-1 + D4508308L-2 AY8912 YM2413 M5205 M6242 RAM NL-001 | |
| 28 | 91 Mahjong Angels D5512068L1-1 + D6107068L-1 AY8912 YM2413 M5205 RAM | |
| 29 | 91 Mahjong Comic Gekijou Vol.1 D5512068L1-1 + D6107068L-1 AY8912 YM2413 M5205 M6242 RAM NL-001, Battery | |
| 30 | 91 Mahjong Dial Q2 D5212298L-1 YM2413 PROM | |
| 31 | 91 Mahjong Tenkaigen AY8910 YM2413 M6242 RAM TMP91P640, protecttion, Battery | |
| 32 | 92 Quiz TV Gassyuukoku Q&Q D5512068L1-2 + D6410288L-1 AY8912 YM2413 M5205 RAM | |
| 33 | 94 Mahjong Reach (bootleg) bootleg AY8910 YM2413 M6242 PROM TMP91P640, Battery | |
| 34 | 94 Maya YM2203 PROM | |
| 35 | 96 Mahjong Raijinhai DX D10010318L1 + D10502168 AY8910 M6242 PROM undumped TMP91P640 code, Battery | |
| 36 | 9? Inca YM2203 PROM | |
| 36 | 37 | --------------------------------------------------------------------------------------------------------------------- |
| 37 | (1) quite different from the others: it has a slave Z80 and *two* blitters | |
| 38 | 38 | |
| 39 | 39 | Notes: |
| 40 | 40 | |
| r936 | r937 | |
| 666 | 666 | case 0x01: dynax_blit_romregion_w(0,1); return; |
| 667 | 667 | case 0x80: dynax_blit_romregion_w(0,2); return; |
| 668 | 668 | case 0x81: dynax_blit_romregion_w(0,3); return; |
| 669 | case 0x82: dynax_blit_romregion_w(0,4); return; // mjcomv1 | |
| 669 | 670 | } |
| 670 | 671 | logerror("%04x: unmapped romregion=%02X\n",activecpu_get_pc(),data); |
| 671 | 672 | } |
| r936 | r937 | |
| 1014 | 1015 | static int rombank; |
| 1015 | 1016 | static UINT8 *romptr; |
| 1016 | 1017 | int tenkai_dswsel, tenkai_ipsel, tenkai_ip; |
| 1018 | static UINT8 tenkai_p5_val; | |
| 1017 | 1019 | |
| 1018 | 1020 | static WRITE8_HANDLER( tenkai_ipsel_w ) |
| 1019 | 1021 | { |
| r936 | r937 | |
| 1148 | 1150 | rombank = (rombank & 0x08) | ((data & 0x0e) >> 1); |
| 1149 | 1151 | tenkai_update_rombank(); |
| 1150 | 1152 | } |
| 1153 | // Added by Whistler - START | |
| 1154 | static READ8_HANDLER( tenkai_p5_r ) | |
| 1155 | { | |
| 1156 | return tenkai_p5_val; | |
| 1157 | } | |
| 1158 | static WRITE8_HANDLER( tenkai_p6_w ) | |
| 1159 | { | |
| 1160 | tenkai_p5_val &= 0x0f; | |
| 1161 | if (data & 0x0f) | |
| 1162 | { | |
| 1163 | tenkai_p5_val |= (1 << 4); | |
| 1164 | } | |
| 1165 | } | |
| 1166 | static WRITE8_HANDLER( tenkai_p7_w ) | |
| 1167 | { | |
| 1168 | tenkai_p5_val &= 0xf0; | |
| 1169 | if (data & 0x03) | |
| 1170 | { | |
| 1171 | tenkai_p5_val |= (1 << 3); | |
| 1172 | } | |
| 1173 | } | |
| 1174 | // Added by Whistler - END | |
| 1151 | 1175 | static WRITE8_HANDLER( tenkai_p8_w ) |
| 1152 | 1176 | { |
| 1153 | rombank = ((data & 0x08) << 1) | (rombank & 0x0f); | |
| 1177 | rombank = ((data & 0x08) << 1) | (rombank & 0x0f); | |
| 1154 | 1178 | tenkai_update_rombank(); |
| 1155 | 1179 | } |
| 1156 | 1180 | static READ8_HANDLER( tenkai_p8_r ) |
| r936 | r937 | |
| 1262 | 1286 | static ADDRESS_MAP_START( tenkai_io_map, ADDRESS_SPACE_IO, 8 ) |
| 1263 | 1287 | AM_RANGE( T90_P3, T90_P3 ) AM_READWRITE( tenkai_p3_r , tenkai_p3_w ) |
| 1264 | 1288 | AM_RANGE( T90_P4, T90_P4 ) AM_WRITE( tenkai_p4_w ) |
| 1289 | AM_RANGE( T90_P5, T90_P5 ) AM_READ( tenkai_p5_r ) | |
| 1290 | AM_RANGE( T90_P6, T90_P6 ) AM_WRITE( tenkai_p6_w ) | |
| 1291 | AM_RANGE( T90_P7, T90_P7 ) AM_WRITE( tenkai_p7_w ) | |
| 1265 | 1292 | AM_RANGE( T90_P8, T90_P8 ) AM_READWRITE( tenkai_p8_r, tenkai_p8_w ) |
| 1266 | 1293 | ADDRESS_MAP_END |
| 1267 | 1294 | |
| r936 | r937 | |
| 4918 | 4945 | ROM_RELOAD( 0x10000, 0x40000 ) |
| 4919 | 4946 | ROM_LOAD( "tmp91p640n-10.5b", 0x00000, 0x04000, CRC(509f1c97) SHA1(08557bea2e924053fd5bc9de5e306f3ecf8e98e6) ) |
| 4920 | 4947 | |
| 4948 | // Note by Whistler: | |
| 4949 | // It appears that the first half of lzc-01.u6 in tenkaibb (as well as the same data in other bootleg versions) | |
| 4950 | // does not exist _anywhere_ in this rom dump, and in this way some girls won't show correctly (such as the 3rd one) | |
| 4921 | 4951 | ROM_REGION( 0x80000, REGION_GFX1, 0 ) // blitter data |
| 4922 | 4952 | ROM_LOAD( "taicom01.15b", 0x000000, 0x80000, CRC(39e4e6f3) SHA1(5b543a5933446091d7cfd519d5a6f23047d8a9f2) ) |
| 4923 | 4953 | |
| 4924 | ROM_REGION( 0x | |
| 4954 | ROM_REGION( 0x100000, REGION_GFX2, 0 ) // blitter data | |
| 4925 | 4955 | ROM_LOAD( "taicom02.11b", 0x000000, 0x80000, CRC(aae8cfb7) SHA1(736c6148aa6e7b22ca19615a27e9a10d41778aa7) ) |
| 4926 | ||
| 4927 | ROM_REGION( 0x80000, REGION_GFX3, 0 ) // blitter data | |
| 4928 | ROM_LOAD( "taicom03.13b", 0x000000, 0x80000, CRC(68cb730a) SHA1(7ce90e34fa51d50a7668ac1c5ccbc18bebe8ad84) ) | |
| 4956 | ROM_LOAD( "taicom03.13b", 0x080000, 0x80000, CRC(68cb730a) SHA1(7ce90e34fa51d50a7668ac1c5ccbc18bebe8ad84) ) | |
| 4929 | 4957 | ROM_END |
| 4930 | 4958 | |
| 4931 | 4959 | /*************************************************************************** |
| r936 | r937 | |
| 5226 | 5254 | |
| 5227 | 5255 | /*************************************************************************** |
| 5228 | 5256 | |
| 5257 | Mahjong Comic Gekijou Vol.1 | |
| 5258 | (c)1991 Dynax / Tenho Iwatani | |
| 5259 | D5512068L1-1 (main PCB) | |
| 5260 | D6107068L-1 (sub PCB) | |
| 5229 | 5261 | |
| 5262 | CPU: Z80B | |
| 5263 | Sound: AY-3-8912, YM2413, M5205 | |
| 5264 | OSC: 20.0000MHz (near Z80B) | |
| 5265 | 14.31818MHz (near sound section) | |
| 5266 | ?MHz (near RTC) | |
| 5267 | Custom: DYNAX NL-001 | |
| 5268 | DYNAX TC17G032AP-0246 | |
| 5269 | Others: 3.6V Ni-Cd Battery, M6242B RTC | |
| 5270 | ||
| 5271 | ROMs: | |
| 5272 | 6101.2D [60552776] \ | |
| 5273 | 6102.4D [4b4f3966] -- Programs? | |
| 5274 | ||
| 5275 | 6103.5D [6d56e5c1] -- Samples? | |
| 5276 | ||
| 5277 | 6104.1A [04eb1ce0] \ | |
| 5278 | 6105.2A [54115f33] | | |
| 5279 | 6106.3A [093faddb] | | |
| 5280 | 6107.4A [0b0997f5] | | |
| 5281 | 6108.5A [bd31ae6f] | | |
| 5282 | 6109.1B [cf718f69] |- Graphics | |
| 5283 | 6110.2B [2865eae4] | | |
| 5284 | 6111.3B [581edcc0] | | |
| 5285 | 6112.4B [3083c0cf] | | |
| 5286 | 6113.5B [e34e9541] | | |
| 5287 | 6114.1C [1aa9a1d7] / | |
| 5288 | ||
| 5289 | d61a.4e \ | |
| 5290 | d61b.7b -- PAL16CEV8 (not dumped) | |
| 5291 | ||
| 5292 | 6104-6114 and D61B is on sub PCB, others are on main PCB | |
| 5293 | ||
| 5294 | ***************************************************************************/ | |
| 5295 | ||
| 5296 | ROM_START( mjcomv1 ) | |
| 5297 | ROM_REGION( 0x10000 + 0x28*0x8000, REGION_CPU1, 0 ) // Z80 Code | |
| 5298 | ROM_LOAD( "6101.2d", 0x000000, 0x20000, CRC(60552776) SHA1(9876f1aece8f25b7e495c6fac24ebb5028916f73) ) | |
| 5299 | // 00-03 | |
| 5300 | ROM_RELOAD( 0x010000, 0x20000 ) | |
| 5301 | // 0c-0f | |
| 5302 | ROM_RELOAD( 0x070000, 0x20000 ) | |
| 5303 | // 24-27 | |
| 5304 | ROM_RELOAD( 0x130000, 0x20000 ) | |
| 5305 | // 04-07 | |
| 5306 | ROM_LOAD( "6102.4d", 0x030000, 0x20000, CRC(4b4f3966) SHA1(150cf8fe6342ea9a956073b3ebba6553c13e9cf8) ) | |
| 5307 | // 08-0b | |
| 5308 | ROM_LOAD( "6103.5d", 0x050000, 0x20000, CRC(6d56e5c1) SHA1(2c02a400d21e442cdd68bf6210b397b770cde3b5) ) // 1ST AND 2ND HALF IDENTICAL | |
| 5309 | ||
| 5310 | // ROM_REGION( 0x00000, REGION_GFX1, 0 ) // blitter data | |
| 5311 | // unused | |
| 5312 | ||
| 5313 | // ROM_REGION( 0x00000, REGION_GFX2, 0 ) // blitter data | |
| 5314 | // unused | |
| 5315 | ||
| 5316 | ROM_REGION( 0x100000, REGION_GFX3, 0 ) // blitter data | |
| 5317 | // 0x00000, 0x20000 | |
| 5318 | ROM_LOAD( "6105.2a", 0x20000, 0x20000, CRC(54115f33) SHA1(ed7d00c9b5c8aad066cf92c627b36c3a5e982d9f) ) | |
| 5319 | ROM_LOAD( "6106.3a", 0x40000, 0x20000, CRC(093faddb) SHA1(ac8ee5abcd8a7b28f28407f5488c21a4bbff305a) ) | |
| 5320 | ROM_LOAD( "6107.4a", 0x60000, 0x20000, CRC(0b0997f5) SHA1(ef31ca2818b8aef7fac01293e34fd7b37c8326f4) ) | |
| 5321 | ROM_LOAD( "6108.5a", 0x80000, 0x20000, CRC(bd31ae6f) SHA1(cc322dd07acab85874e5f033c65d2c99838d7474) ) | |
| 5322 | ROM_LOAD( "6109.1b", 0xa0000, 0x20000, CRC(cf718f69) SHA1(0e8f9e6c9ef35f71a4b7fcaf62e4c22b486dcb9d) ) | |
| 5323 | ROM_LOAD( "6110.2b", 0xc0000, 0x20000, CRC(2865eae4) SHA1(dd945a2a531a08e654f13c135bb9cb799589d513) ) | |
| 5324 | ROM_LOAD( "6111.3b", 0xe0000, 0x20000, CRC(581edcc0) SHA1(d52de6ca199f03e0d88c8e4275fe2b37b3ef6016) ) | |
| 5325 | ||
| 5326 | ROM_REGION( 0x60000, REGION_GFX4, 0 ) // blitter data | |
| 5327 | ROM_LOAD( "6112.4b", 0x00000, 0x20000, CRC(3083c0cf) SHA1(24465e2d01cb0f0646644a3a5d57d9c0f456cf96) ) | |
| 5328 | ROM_LOAD( "6113.5b", 0x20000, 0x20000, CRC(e34e9541) SHA1(fbe457b4107730f3d633536e82b9271dcbc71559) ) | |
| 5329 | ROM_LOAD( "6114.1c", 0x40000, 0x20000, CRC(1aa9a1d7) SHA1(67991ff4968443e596fd2fadb097e32d2e6802c3) ) | |
| 5330 | ||
| 5331 | ROM_REGION( 0x80000, REGION_GFX5, 0 ) // blitter data | |
| 5332 | ROM_LOAD( "6104.1a", 0x00000, 0x80000, CRC(04eb1ce0) SHA1(670b213db190bb845c0a99e0a8b166ebff8a7ea1) ) | |
| 5333 | ROM_END | |
| 5334 | ||
| 5335 | /*************************************************************************** | |
| 5336 | ||
| 5337 | ||
| 5230 | 5338 | Game Drivers |
| 5231 | 5339 | |
| 5232 | 5340 | |
| r936 | r937 | |
| 5252 | 5360 | GAME( 1990, mjelct3a, mjelctrn, mjelctrn, mjelct3, mjelct3a, ROT180, "Dynax", "Mahjong Electron Base (parts 2 & 3, alt., Japan)", 0 ) |
| 5253 | 5361 | GAME( 1990, majxtal7, 0, majxtal7, majxtal7, mjelct3, ROT180, "Dynax", "Mahjong X-Tal 7 - Crystal Mahjong / Mahjong Diamond 7 (Japan)",GAME_IMPERFECT_GRAPHICS ) |
| 5254 | 5362 | GAME( 1990, neruton, 0, neruton, neruton, mjelct3, ROT180, "Dynax / Yukiyoshi Tokoro", "Mahjong Neruton Haikujirada (Japan)", GAME_IMPERFECT_GRAPHICS ) |
| 5363 | GAME( 1991, mjcomv1, 0, yarunara, yarunara, 0, ROT180, "Dynax", "Mahjong Comic Gekijou Vol.1 (Japan)", 0 ) | |
| 5255 | 5364 | GAME( 1991, tenkai, 0, tenkai, tenkai, 0, ROT0, "Dynax", "Mahjong Tenkaigen", GAME_NOT_WORKING ) |
| 5256 | 5365 | GAME( 1991, tenkai2b, tenkai, tenkai, tenkai, 0, ROT0, "Dynax", "Mahjong Tenkaigen Part 2 (bootleg)", GAME_NOT_WORKING ) |
| 5257 | 5366 | GAME( 1991, tenkaibb, tenkai, tenkai, tenkai, 0, ROT0, "Dynax", "Mahjong Tenkaigen (bootleg b)", 0 ) |
| r936 | r937 | |
|---|---|---|
| 57 | 57 | { |
| 58 | 58 | if (data & ~0x02) logerror("CPU #0 - PC %04X: unknown oki bank bits %02X\n",activecpu_get_pc(),data); |
| 59 | 59 | |
| 60 | if (sndti_t | |
| 60 | if (sndti_exist | |
| 61 | 61 | OKIM6295_set_bank_base(1, (data & 0x02) ? 0x40000 : 0); |
| 62 | 62 | } |
| 63 | 63 |
| r936 | r937 | |
|---|---|---|
| 196 | 196 | */ |
| 197 | 197 | 0x30,0x32,0x4f,0x63,0x74,0x39,0x32,0x52,0x45,0x56,0x49,0x53,0x49,0x4f,0x4e,0x35, |
| 198 | 198 | 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x01, |
| 199 | 0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00, | |
| 200 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
| 201 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
| 202 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
| 203 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
| 204 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
| 205 | 0x51,0x01,0x38,0x38,0xa7,0xbf,0xf1,0x04,0x0d,0x15,0x9b,0x80,0x1f,0x83,0xd5,0xa4, | |
| 206 | 0x69,0x88,0x7c,0x9f,0xb6,0x01,0xda,0x93,0x17,0x45,0x8b,0x12,0xb2,0x02,0x33,0x5c, | |
| 207 | 0x50,0xd6,0xe1,0x56,0xa4,0xad,0x42,0x4a,0x5c,0xdd,0x86,0x61,0xe9,0x03,0x12,0xe1, | |
| 208 | 0x0f,0x9b,0xea,0x26,0x2c,0x61,0xdc,0x62,0x48,0x6b,0x6d,0x14,0xe0,0x03,0x85,0x4a, | |
| 209 | 0x72,0x46,0xda,0x96,0xc8,0x7d,0x1c,0xd1,0x05,0x3e,0xe5,0x92,0x70,0x43,0x5f,0x6c, | |
| 210 | 0x03,0x05,0xb3,0xeb,0xb3,0x20,0x35,0x4d,0x7e,0x66,0x50,0x01,0x36,0xc0,0x33,0xe1, | |
| 211 | 0x0f,0xc9,0x38,0x2e,0xe9,0x29,0x19,0x4f,0x5e,0xb1,0xd1,0x49,0x8b,0x3b,0x53,0xfd, | |
| 212 | 0x9f,0x3f,0xee,0x25,0x25,0x35,0x7b,0x0d,0x11,0xaf,0x4c,0x11,0x8c,0x32,0xd4,0xda, | |
| 213 | 0x7f,0xd8,0x16,0x57,0xe1,0xa6,0xce,0x7d,0xc1,0xae,0x62,0xbf,0x13,0xe4,0x87,0x4c, | |
| 214 | 0x3a,0xc1,0xb3,0x0c,0x59,0x99,0x47,0x58,0x5a,0xbd,0x78,0x7c,0xba,0x50,0x01,0xed, | |
| 215 | 0x1b,0xea,0x8a,0x49,0x88,0xee,0xd6,0x14,0x85,0xab,0xb0,0x2c,0xde,0x35,0x93,0x11, | |
| 216 | 0x2d,0x01,0x1c,0xd7,0x28,0x43,0x30,0xe7,0xb0,0x08,0xed,0x79 | |
| 199 | 0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02 | |
| 217 | 200 | }; /* ExvaniaDefaultNvMem */ |
| 218 | 201 | |
| 219 | 202 | static const UINT8 QuiztouDefaultNvMem[] = |
| r936 | r937 | |
| 224 | 207 | */ |
| 225 | 208 | 0x30,0x32,0x4F,0x63,0x74,0x39,0x32,0x52,0x45,0x56,0x49,0x53,0x49,0x4F,0x4E,0x35, |
| 226 | 209 | 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x01, |
| 227 | 0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00, | |
| 228 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
| 229 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
| 230 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
| 231 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
| 232 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
| 233 | 0xC1,0x9B,0xE1,0xC0,0x7E,0xE9,0xA8,0x9A,0xA7,0x86,0xC2,0xB5,0x54,0xBF,0x9A,0xE7, | |
| 234 | 0xD9,0x23,0xD1,0x55,0x90,0x38,0x28,0xD1,0xD9,0x6C,0xA1,0x66,0x5E,0x4E,0xE1,0x30, | |
| 235 | 0x9C,0xFE,0xD9,0x71,0x9F,0xE2,0xA5,0xE2,0x0C,0x9B,0xB4,0x47,0x65,0x38,0x2A,0x46, | |
| 236 | 0x89,0xA9,0x82,0x79,0x7A,0x76,0x78,0xC2,0x63,0xB1,0x26,0xDF,0xDA,0x29,0x6D,0x3E, | |
| 237 | 0x62,0xE0,0x96,0x12,0x34,0xBF,0x39,0xA6,0x3F,0x89,0x5E,0xF1,0x6D,0x0E,0xE3,0x6C, | |
| 238 | 0x28,0xA1,0x1E,0x20,0x1D,0xCB,0xC2,0x03,0x3F,0x41,0x07,0x84,0x0F,0x14,0x05,0x65, | |
| 239 | 0x1B,0x28,0x61,0xC9,0xC5,0xE7,0x2C,0x8E,0x46,0x36,0x08,0xDC,0xF3,0xA8,0x8D,0xFE, | |
| 240 | 0xBE,0xF2,0xEB,0x71,0xFF,0xA0,0xD0,0x3B,0x75,0x06,0x8C,0x7E,0x87,0x78,0x73,0x4D, | |
| 241 | 0xD0,0xBE,0x82,0xBE,0xDB,0xC2,0x46,0x41,0x2B,0x8C,0xFA,0x30,0x7F,0x70,0xF0,0xA7, | |
| 242 | 0x54,0x86,0x32,0x95,0xAA,0x5B,0x68,0x13,0x0B,0xE6,0xFC,0xF5,0xCA,0xBE,0x7D,0x9F, | |
| 243 | 0x89,0x8A,0x41,0x1B,0xFD,0xB8,0x4F,0x68,0xF6,0x72,0x7B,0x14,0x99,0xCD,0xD3,0x0D, | |
| 244 | 0xF0,0x44,0x3A,0xB4,0xA6,0x66,0x53,0x33,0x0B,0xCB,0xA1,0x10,0x5E,0x4C,0xEC,0x03, | |
| 245 | 0x4C,0x73,0xE6,0x05,0xB4,0x31,0x0E,0xAA,0xAD,0xCF,0xD5,0xB0,0xCA,0x27,0xFF,0xD8, | |
| 246 | 0x9D,0x14,0x4D,0xF4,0x79,0x27,0x59,0x42,0x7C,0x9C,0xC1,0xF8,0xCD,0x8C,0x87,0x20, | |
| 247 | 0x23,0x64,0xB8,0xA6 | |
| 210 | 0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02 | |
| 248 | 211 | }; /* QuiztouDefaultNvMem */ |
| 249 | 212 | |
| 213 | static const UINT8 CgangpzlDefaultNvMem[] = | |
| 214 | { | |
| 215 | /* This data oughtn't be necessary; when Cgangpzl's EPROM area is uninitialized, | |
| 216 | * the game software automatically writes these values there, but then hangs. | |
| 217 | */ | |
| 218 | 0x30,0x32,0x4F,0x63,0x74,0x39,0x32,0x52,0x45,0x56,0x49,0x53,0x49,0x4F,0x4E,0x35, | |
| 219 | 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x01, | |
| 220 | 0x00,0x02,0x00,0x00,0x00,0x01 | |
| 221 | }; /* CgangpzlDefaultNvMem */ | |
| 222 | ||
| 250 | 223 | static UINT8 namcona1_nvmem[NA1_NVRAM_SIZE]; |
| 251 | 224 | |
| 252 | 225 | static NVRAM_HANDLER( namcosna1 ) |
| r936 | r937 | |
| 274 | 247 | case NAMCO_QUIZTOU: |
| 275 | 248 | memcpy( namcona1_nvmem, QuiztouDefaultNvMem, sizeof(QuiztouDefaultNvMem) ); |
| 276 | 249 | break; |
| 250 | ||
| 251 | case NAMCO_CGANGPZL: | |
| 252 | memcpy( namcona1_nvmem, CgangpzlDefaultNvMem, sizeof(CgangpzlDefaultNvMem) ); | |
| 253 | break; | |
| 277 | 254 | } |
| 278 | 255 | } |
| 279 | 256 | } |
| r936 | r937 | |
|---|---|---|
| 1754 | 1754 | machine->gfx[mpu4_gfx_index+3] = allocgfx(&mpu4_vid_char_16x16_layout); |
| 1755 | 1755 | |
| 1756 | 1756 | /* set the color information */ |
| 1757 | machine->gfx[mpu4_gfx_index+0]->colortable = machine->pens; | |
| 1758 | 1757 | machine->gfx[mpu4_gfx_index+0]->total_colors = machine->drv->total_colors / 16; |
| 1759 | machine->gfx[mpu4_gfx_index+1]->colortable = machine->pens; | |
| 1760 | 1758 | machine->gfx[mpu4_gfx_index+1]->total_colors = machine->drv->total_colors / 16; |
| 1761 | machine->gfx[mpu4_gfx_index+2]->colortable = machine->pens; | |
| 1762 | 1759 | machine->gfx[mpu4_gfx_index+2]->total_colors = machine->drv->total_colors / 16; |
| 1763 | machine->gfx[mpu4_gfx_index+3]->colortable = machine->pens; | |
| 1764 | 1760 | machine->gfx[mpu4_gfx_index+3]->total_colors = machine->drv->total_colors / 16; |
| 1765 | 1761 | |
| 1766 | 1762 | scn2675_IR_pointer = 0; |
| r936 | r937 | |
|---|---|---|
| 309 | 309 | static void irqhandler(int linestate) |
| 310 | 310 | { |
| 311 | 311 | /* system 16c doesn't have the sound CPU */ |
| 312 | if (Machine->drv->cpu[1].cpu_type) | |
| 312 | if (Machine->drv->cpu[1].cpu_type != CPU_DUMMY) | |
| 313 | 313 | cpunum_set_input_line(1,0,linestate); |
| 314 | 314 | } |
| 315 | 315 |
| r936 | r937 | |
|---|---|---|
| 225 | 225 | gfx.width = width; |
| 226 | 226 | gfx.height = height; |
| 227 | 227 | gfx.total_elements = 1; |
| 228 | gfx.color_depth = 256; | |
| 228 | 229 | gfx.color_granularity = 256; |
| 229 | gfx.color | |
| 230 | gfx.color_ | |
| 230 | 231 | gfx.total_colors = 0x10; |
| 231 | 232 | gfx.pen_usage = NULL; |
| 232 | 233 | gfx.gfxdata = gfxdata; |
| r936 | r937 | |
|---|---|---|
| 912 | 912 | MDRV_SCREEN_SIZE(32*8, 32*8) |
| 913 | 913 | MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) |
| 914 | 914 | MDRV_GFXDECODE(gfxdecodeinfo) |
| 915 | MDRV_PALETTE_LENGTH(128) | |
| 916 | MDRV_COLORTABLE_LENGTH(0x0f00) | |
| 915 | MDRV_PALETTE_LENGTH(0x0f00) | |
| 917 | 916 | |
| 918 | 917 | MDRV_PALETTE_INIT(polepos) |
| 919 | 918 | MDRV_VIDEO_START(polepos) |
| r936 | r937 | |
|---|---|---|
| 6638 | 6638 | |
| 6639 | 6639 | ROM_START( xmcotaj ) |
| 6640 | 6640 | ROM_REGION( CODE_SIZE, REGION_CPU1, 0 ) /* 68000 code */ |
| 6641 | ROM_LOAD16_WORD_SWAP( "xmnj.03d", 0x000000, 0x80000, CRC(79086d62) SHA1(d99a48bd40593aa9c1ff1fcbfc40cfe3bc882fc5) ) | |
| 6642 | ROM_LOAD16_WORD_SWAP( "xmnj.04d", 0x080000, 0x80000, CRC(38eed613) SHA1(86ecb58bf03adda705a39a9779862fe2c85cadad) ) | |
| 6643 | ROM_LOAD16_WORD_SWAP( "xmn.05", 0x100000, 0x80000, CRC(c3ed62a2) SHA1(4e3317d7ca981e33318822103a16e59f4ce20deb) ) | |
| 6644 | ROM_LOAD16_WORD_SWAP( "xmn.06", 0x180000, 0x80000, CRC(f03c52e1) SHA1(904b2312ee594f5ece0484cad0eed25cc758185e) ) | |
| 6645 | ROM_LOAD16_WORD_SWAP( "xmn.07", 0x200000, 0x80000, CRC(325626b1) SHA1(3f3a0aabbe5ffad8136ac91e0de785103b16059b) ) | |
| 6646 | ROM_LOAD16_WORD_SWAP( "xmn.08", 0x280000, 0x80000, CRC(7194ea10) SHA1(40a5892d816f24cbfd4c310792eeabf689c6fa7e) ) | |
| 6647 | ROM_LOAD16_WORD_SWAP( "xmn.09", 0x300000, 0x80000, CRC(ae946df3) SHA1(733671f76d766bda7110df9d338791cc5202b050) ) | |
| 6648 | ROM_LOAD16_WORD_SWAP( "xmn.10", 0x380000, 0x80000, CRC(32a6be1d) SHA1(8f5fcb33b528abed670b4fc3fa62431a6e033c56) ) | |
| 6649 | ||
| 6650 | ROM_REGION( 0x2000000, REGION_GFX1, 0 ) | |
| 6651 | ROMX_LOAD( "xmn.13m", 0x0000000, 0x400000, CRC(bf4df073) SHA1(4d2740c3a827f0ec2cf75ad99c65e393c6a11c23) , ROM_GROUPWORD | ROM_SKIP(6) ) | |
| 6652 | ROMX_LOAD( "xmn.15m", 0x0000002, 0x400000, CRC(4d7e4cef) SHA1(50b8797b8099a8d76ad063ba1201a13dbb88ae3a) , ROM_GROUPWORD | ROM_SKIP(6) ) | |
| 6653 | ROMX_LOAD( "xmn.17m", 0x0000004, 0x400000, CRC(513eea17) SHA1(a497477ad9ac13180911d8745ef6ee1955c0b877) , ROM_GROUPWORD | ROM_SKIP(6) ) | |
| 6654 | ROMX_LOAD( "xmn.19m", 0x0000006, 0x400000, CRC(d23897fc) SHA1(1e31627999736652252164d32662779a1ac6ca29) , ROM_GROUPWORD | ROM_SKIP(6) ) | |
| 6655 | ROMX_LOAD( "xmn.14m", 0x1000000, 0x400000, CRC(778237b7) SHA1(89a759ec383518ec52f5059d10ec342f2247aa20) , ROM_GROUPWORD | ROM_SKIP(6) ) | |
| 6656 | ROMX_LOAD( "xmn.16m", 0x1000002, 0x400000, CRC(67b36948) SHA1(692fb6e4096b880aa22996d554b160f664bbd907) , ROM_GROUPWORD | ROM_SKIP(6) ) | |
| 6657 | ROMX_LOAD( "xmn.18m", 0x1000004, 0x400000, CRC(015a7c4c) SHA1(cccc95dafd076a1a9fa004710006149c42d058ba) , ROM_GROUPWORD | ROM_SKIP(6) ) | |
| 6658 | ROMX_LOAD( "xmn.20m", 0x1000006, 0x400000, CRC(9dde2758) SHA1(17ba259cad03c7b5d56c0a5eda9ab53521665729) , ROM_GROUPWORD | ROM_SKIP(6) ) | |
| 6659 | ||
| 6660 | ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */ | |
| 6661 | ROM_LOAD( "xmn.01a", 0x00000, 0x08000, CRC(40f479ea) SHA1(f29e15f537675305264ae2138a0a537fb9e2008b) ) | |
| 6662 | ROM_CONTINUE( 0x10000, 0x18000 ) | |
| 6663 | ROM_LOAD( "xmn.02a", 0x28000, 0x20000, CRC(39d9b5ad) SHA1(af502debfd36100d4fc971ed25fdf9d7121d6f18) ) | |
| 6664 | ||
| 6665 | ROM_REGION( 0x400000, REGION_SOUND1, 0 ) /* QSound samples */ | |
| 6666 | ROM_LOAD16_WORD_SWAP( "xmn.11m", 0x000000, 0x200000, CRC(c848a6bc) SHA1(ac8ac564d3c43225822f8bc330eba9f35b24b0a4) ) | |
| 6667 | ROM_LOAD16_WORD_SWAP( "xmn.12m", 0x200000, 0x200000, CRC(729c188f) SHA1(3279774ad8aebbcf0fc779cdfcbe21044dd192ad) ) | |
| 6668 | ROM_END | |
| 6669 | ||
| 6670 | ROM_START( xmcotaj1 ) | |
| 6671 | ROM_REGION( CODE_SIZE, REGION_CPU1, 0 ) /* 68000 code */ | |
| 6641 | 6672 | ROM_LOAD16_WORD_SWAP( "xmnj.03b", 0x000000, 0x80000, CRC(c8175fb3) SHA1(ea25bd165f8794324a1e07719312798cf9742924) ) |
| 6642 | 6673 | ROM_LOAD16_WORD_SWAP( "xmnj.04b", 0x080000, 0x80000, CRC(54b3fba3) SHA1(47eaff5d36a45e4196f87ed3d02e54d5407e7962) ) |
| 6643 | 6674 | ROM_LOAD16_WORD_SWAP( "xmn.05", 0x100000, 0x80000, CRC(c3ed62a2) SHA1(4e3317d7ca981e33318822103a16e59f4ce20deb) ) |
| r936 | r937 | |
| 6667 | 6698 | ROM_LOAD16_WORD_SWAP( "xmn.12m", 0x200000, 0x200000, CRC(729c188f) SHA1(3279774ad8aebbcf0fc779cdfcbe21044dd192ad) ) |
| 6668 | 6699 | ROM_END |
| 6669 | 6700 | |
| 6670 | ROM_START( xmcotaj | |
| 6701 | ROM_START( xmcotaj2 ) | |
| 6671 | 6702 | ROM_REGION( CODE_SIZE, REGION_CPU1, 0 ) /* 68000 code */ |
| 6672 | 6703 | ROM_LOAD16_WORD_SWAP( "xmnj.03a", 0x000000, 0x80000, CRC(00761611) SHA1(e780dbe1d21a0d5b6981f0395942c9fa59688113) ) |
| 6673 | 6704 | ROM_LOAD16_WORD_SWAP( "xmnj.04a", 0x080000, 0x80000, CRC(614d3f60) SHA1(2272ae243557562a0bc85d2cd2b37dd876f6902c) ) |
| r936 | r937 | |
| 7148 | 7179 | GAME( 1994, xmcota, 0, cps2, ssf2, cps2, ROT0, "Capcom", "X-Men: Children of the Atom (Euro 950105)", 0 ) |
| 7149 | 7180 | GAME( 1994, xmcotau, xmcota, cps2, ssf2, cps2, ROT0, "Capcom", "X-Men: Children of the Atom (USA 950105)", 0 ) |
| 7150 | 7181 | GAME( 1994, xmcotah, xmcota, cps2, ssf2, cps2, ROT0, "Capcom", "X-Men: Children of the Atom (Hispanic 950331)", 0 ) |
| 7151 | GAME( 1994, xmcotaj, xmcota, cps2, ssf2, cps2, ROT0, "Capcom", "X-Men: Children of the Atom (Japan 941219)", 0 ) | |
| 7152 | GAME( 1994, xmcotaj1, xmcota, cps2, ssf2, cps2, ROT0, "Capcom", "X-Men: Children of the Atom (Japan 941217)", 0 ) | |
| 7182 | GAME( 1994, xmcotaj, xmcota, cps2, ssf2, cps2, ROT0, "Capcom", "X-Men: Children of the Atom (Japan 941222)", 0 ) | |
| 7183 | GAME( 1994, xmcotaj1, xmcota, cps2, ssf2, cps2, ROT0, "Capcom", "X-Men: Children of the Atom (Japan 941219)", 0 ) | |
| 7184 | GAME( 1994, xmcotaj2, xmcota, cps2, ssf2, cps2, ROT0, "Capcom", "X-Men: Children of the Atom (Japan 941217)", 0 ) | |
| 7153 | 7185 | GAME( 1994, xmcotajr, xmcota, cps2, ssf2, cps2, ROT0, "Capcom", "X-Men: Children of the Atom (Japan 941208 rent version)", 0 ) |
| 7154 | 7186 | GAME( 1994, xmcotaa, xmcota, cps2, ssf2, cps2, ROT0, "Capcom", "X-Men: Children of the Atom (Asia 941217)", 0 ) |
| 7155 | 7187 | GAME( 1994, armwar, 0, cps2, avsp, cps2, ROT0, "Capcom", "Armored Warriors (Euro 941024)", 0 ) |
| r936 | r937 | |
|---|---|---|
| 366 | 366 | int left, right; |
| 367 | 367 | left = ( darius_pan[0] * darius_vol[6])>>8; |
| 368 | 368 | right = ((0xff - darius_pan[0]) * darius_vol[6])>>8; |
| 369 | if (sndti_t | |
| 369 | if (sndti_exist | |
| 370 | 370 | flt_volume_set_volume(6, left / 100.0); |
| 371 | if (sndti_t | |
| 371 | if (sndti_exist | |
| 372 | 372 | flt_volume_set_volume(7, right / 100.0); /* FM #0 */ |
| 373 | 373 | } |
| 374 | 374 | |
| r936 | r937 | |
| 377 | 377 | int left, right; |
| 378 | 378 | left = ( darius_pan[1] * darius_vol[7])>>8; |
| 379 | 379 | right = ((0xff - darius_pan[1]) * darius_vol[7])>>8; |
| 380 | if (sndti_t | |
| 380 | if (sndti_exist | |
| 381 | 381 | flt_volume_set_volume(14, left / 100.0); |
| 382 | if (sndti_t | |
| 382 | if (sndti_exist | |
| 383 | 383 | flt_volume_set_volume(15, right / 100.0); /* FM #1 */ |
| 384 | 384 | } |
| 385 | 385 | |
| r936 | r937 | |
| 388 | 388 | int left, right; |
| 389 | 389 | left = ( darius_pan[2] * darius_vol[port])>>8; |
| 390 | 390 | right = ((0xff - darius_pan[2]) * darius_vol[port])>>8; |
| 391 | if (sndti_t | |
| 391 | if (sndti_exist | |
| 392 | 392 | flt_volume_set_volume(port*2+0, left / 100.0); |
| 393 | if (sndti_t | |
| 393 | if (sndti_exist | |
| 394 | 394 | flt_volume_set_volume(port*2+1, right / 100.0); |
| 395 | 395 | } |
| 396 | 396 | |
| r936 | r937 | |
| 399 | 399 | int left, right; |
| 400 | 400 | left = ( darius_pan[3] * darius_vol[port + 3])>>8; |
| 401 | 401 | right = ((0xff - darius_pan[3]) * darius_vol[port + 3])>>8; |
| 402 | if (sndti_t | |
| 402 | if (sndti_exist | |
| 403 | 403 | flt_volume_set_volume(port*2+0+8, left / 100.0); |
| 404 | if (sndti_t | |
| 404 | if (sndti_exist | |
| 405 | 405 | flt_volume_set_volume(port*2+1+8, right / 100.0); |
| 406 | 406 | } |
| 407 | 407 | |
| r936 | r937 | |
| 410 | 410 | int left, right; |
| 411 | 411 | left = darius_def_vol[(darius_pan[4]>>4)&0x0f]; |
| 412 | 412 | right = darius_def_vol[(darius_pan[4]>>0)&0x0f]; |
| 413 | if (sndti_t | |
| 413 | if (sndti_exist | |
| 414 | 414 | flt_volume_set_volume(16, left / 100.0); |
| 415 | if (sndti_t | |
| 415 | if (sndti_exist | |
| 416 | 416 | flt_volume_set_volume(17, right / 100.0); /* FM #1 */ |
| 417 | 417 | } |
| 418 | 418 |
| r936 | r937 | |
|---|---|---|
| 3 | 3 | driver by Tomasz Slanina |
| 4 | 4 | ******************************************** |
| 5 | 5 | |
| 6 | ||
| 7 | 6 | Todo: |
| 8 | 7 | - find NMI source, and NMI enable/disable (timer ? video hw ?) |
| 9 | 8 | |
| 10 | 9 | Not working games : |
| 11 | 10 | - Super Real Mahjong P5 |
| 12 | - Super Eagle Shot | |
| 13 | RAM 0x0a000000 - 0x0a003fff (8bit) is shared with ST-0016 ($f000-$ffff) | |
| 14 | after boot, r3000 writes there "KCUFUOY" , and ST-0016 "YOU!" ;) | |
| 15 | 11 | */ |
| 16 | 12 | |
| 17 | 13 | #include "driver.h" |
| r936 | r937 | |
| 130 | 126 | AM_RANGE(0x1fc00000, 0x1fdfffff) AM_READ(MRA32_ROM) AM_WRITE(MWA32_ROM) AM_REGION(REGION_USER1, 0) |
| 131 | 127 | ADDRESS_MAP_END |
| 132 | 128 | |
| 133 | static ADDRESS_MAP_START( speglsht_mem, ADDRESS_SPACE_PROGRAM, 32 ) | |
| 134 | AM_RANGE(0x00000000, 0x000fffff) AM_RAM | |
| 135 | AM_RANGE(0x01800200, 0x01800203) AM_WRITE(MWA32_RAM) | |
| 136 | AM_RANGE(0x01a00000, 0x01afffff) AM_RAM | |
| 137 | AM_RANGE(0x01c00000, 0x01c00003) AM_READ(MRA32_RAM) | |
| 138 | AM_RANGE(0x01ca5000, 0x01ca6fff) AM_RAM /* i/o ?? */ | |
| 139 | AM_RANGE(0x0a000000, 0x0a003fff) AM_RAM /* shared with st-0016 ! */ | |
| 140 | AM_RANGE(0x1eff0000, 0x1eff001f) AM_WRITE(MWA32_RAM) | |
| 141 | AM_RANGE(0x1fc00000, 0x1fdfffff) AM_READ(MRA32_ROM) AM_WRITE(MWA32_ROM) AM_REGION(REGION_USER1, 0) | |
| 142 | ADDRESS_MAP_END | |
| 143 | ||
| 144 | 129 | /************************************* |
| 145 | 130 | * |
| 146 | 131 | * Machine's structure ST0016 + V810 |
| r936 | r937 | |
| 162 | 147 | latches[2]|=1; |
| 163 | 148 | COMBINE_DATA(&latches[offset]); |
| 164 | 149 | timer_call_after_resynch(0, NULL); |
| 165 | ||
| 166 | 150 | } |
| 167 | 151 | |
| 168 | 152 | static READ8_HANDLER(latch8_r) |
| r936 | r937 | |
| 445 | 429 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 446 | 430 | INPUT_PORTS_END |
| 447 | 431 | |
| 448 | INPUT_PORTS_START( speglsht ) | |
| 449 | PORT_INCLUDE( st0016 ) | |
| 450 | ||
| 451 | PORT_MODIFY("DSW1") /* Dip switch A */ | |
| 452 | PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) ) | |
| 453 | PORT_DIPSETTING( 0x03, DEF_STR( 3C_1C ) ) | |
| 454 | PORT_DIPSETTING( 0x04, DEF_STR( 2C_1C ) ) | |
| 455 | PORT_DIPSETTING( 0x07, DEF_STR( 1C_1C ) ) | |
| 456 | PORT_DIPSETTING( 0x01, "1C/1C or 2C/3C" ) /* 1 coin/1 credit or 2 coins/3 credits */ | |
| 457 | PORT_DIPSETTING( 0x02, DEF_STR( 2C_3C ) ) | |
| 458 | PORT_DIPSETTING( 0x06, DEF_STR( 1C_2C ) ) | |
| 459 | PORT_DIPSETTING( 0x05, DEF_STR( 1C_3C ) ) | |
| 460 | PORT_DIPSETTING( 0x00, "2C Start/1C Continue" ) | |
| 461 | PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) ) | |
| 462 | PORT_DIPSETTING( 0x18, DEF_STR( 3C_1C ) ) | |
| 463 | PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) ) | |
| 464 | PORT_DIPSETTING( 0x38, DEF_STR( 1C_1C ) ) | |
| 465 | PORT_DIPSETTING( 0x08, "1C/1C or 2C/3C" ) /* 1 coin/1 credit or 2 coins/3 credits */ | |
| 466 | PORT_DIPSETTING( 0x10, DEF_STR( 2C_3C ) ) | |
| 467 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_2C ) ) | |
| 468 | PORT_DIPSETTING( 0x28, DEF_STR( 1C_3C ) ) | |
| 469 | PORT_DIPSETTING( 0x00, "2C Start/1C Continue" ) | |
| 470 | PORT_DIPNAME( 0x40, 0x40, "Unkown / Unused" ) | |
| 471 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) | |
| 472 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 473 | PORT_DIPNAME( 0x80, 0x80, "Bonus for PAR Play" ) | |
| 474 | PORT_DIPSETTING( 0x80, DEF_STR( None ) ) | |
| 475 | PORT_DIPSETTING( 0x00, "Extra Hole" ) | |
| 476 | ||
| 477 | PORT_MODIFY("DSW2") /* Dip switch B */ | |
| 478 | PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) | |
| 479 | PORT_DIPSETTING( 0x03, DEF_STR( Normal ) ) | |
| 480 | PORT_DIPSETTING( 0x02, DEF_STR( Easy ) ) | |
| 481 | PORT_DIPSETTING( 0x01, DEF_STR( Hard ) ) | |
| 482 | PORT_DIPSETTING( 0x00, DEF_STR( Very_Hard ) ) | |
| 483 | PORT_DIPNAME( 0x0c, 0x0c, "Number of Players" ) | |
| 484 | PORT_DIPSETTING( 0x0c, "3" ) | |
| 485 | PORT_DIPSETTING( 0x08, "4" ) | |
| 486 | PORT_DIPSETTING( 0x04, "2" ) | |
| 487 | PORT_DIPSETTING( 0x00, "1" ) | |
| 488 | PORT_DIPNAME( 0x10, 0x00, DEF_STR( Demo_Sounds ) ) | |
| 489 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) | |
| 490 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 491 | PORT_DIPNAME( 0x20, 0x20, "Control Panel" ) | |
| 492 | PORT_DIPSETTING( 0x00, "2P Pair" ) | |
| 493 | PORT_DIPSETTING( 0x40, DEF_STR( Single ) ) | |
| 494 | PORT_DIPNAME( 0x40, 0x40, "Country" ) | |
| 495 | PORT_DIPSETTING( 0x40, DEF_STR( Japan ) ) | |
| 496 | PORT_DIPSETTING( 0x00, "North America" ) | |
| 497 | PORT_DIPNAME( 0x80, 0x80, "Test Mode" ) | |
| 498 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) | |
| 499 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 500 | INPUT_PORTS_END | |
| 501 | ||
| 502 | 432 | INPUT_PORTS_START( srmp5 ) |
| 503 | 433 | PORT_START_TAG("IN0") |
| 504 | 434 | PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| r936 | r937 | |
| 590 | 520 | |
| 591 | 521 | static MACHINE_DRIVER_START( srmp5 ) |
| 592 | 522 | MDRV_IMPORT_FROM(st0016) |
| 593 | MDRV_CPU_ADD(R3000 | |
| 523 | MDRV_CPU_ADD(R3000LE, 16000000) | |
| 594 | 524 | MDRV_CPU_CONFIG(config) |
| 595 | 525 | MDRV_CPU_PROGRAM_MAP(srmp5_mem,0) |
| 596 | 526 | MACHINE_DRIVER_END |
| 597 | 527 | |
| 598 | static MACHINE_DRIVER_START( speglsht ) | |
| 599 | MDRV_IMPORT_FROM(st0016) | |
| 600 | MDRV_CPU_ADD(R3000BE, 16000000) | |
| 601 | MDRV_CPU_CONFIG(config) | |
| 602 | MDRV_CPU_PROGRAM_MAP(speglsht_mem,0) | |
| 603 | MACHINE_DRIVER_END | |
| 604 | ||
| 605 | 528 | /************************************* |
| 606 | 529 | * |
| 607 | 530 | * ROM definition(s) |
| r936 | r937 | |
| 736 | 659 | ROM_END |
| 737 | 660 | |
| 738 | 661 | /* |
| 739 | Super Eagle Shot | |
| 740 | (c)1993 Seta (distributed by Visco) | |
| 741 | E30-001A | |
| 742 | ||
| 743 | CPU : Integrated Device IDT79R3051-25J 9407C (R3000A) | |
| 744 | Sound: ST-0016 | |
| 745 | OSC : 50.0000MHz (X1) 42.9545MHz (X3) | |
| 746 | ||
| 747 | ROMs: | |
| 748 | SX004-01.PR0 - Main programs (MX27C4000) | |
| 749 | SX004-02.PR1 | | |
| 750 | SX004-03.PR2 | | |
| 751 | SX004-04.PR3 / | |
| 752 | ||
| 753 | SX004-05.RD0 - Graphics? (D23C8000SCZ) | |
| 754 | SX004-06.RD1 / | |
| 755 | ||
| 756 | SX004-07.ZPR - Program? (16M mask, read as 27c160) | |
| 757 | ||
| 758 | GALs (not dumped): | |
| 759 | SX004-08.27 (16V8B) | |
| 760 | SX004-09.46 (16V8B) | |
| 761 | SX004-10.59 (16V8B) | |
| 762 | SX004-11.61 (22V10B) | |
| 763 | SX004-12.62 (22V10B) | |
| 764 | SX004-13.63 (22V10B) | |
| 765 | ||
| 766 | Custom chips: | |
| 767 | SETA ST-0015 60EN502F12 JAPAN 9415YAI (U18, 208pin PQFP, system controller) | |
| 768 | SETA ST-0016 TC6187AF JAPAN 9348YAA (U68, 208pin PQFP, sound & object) | |
| 769 | ||
| 770 | ? ST-0015 SX004-01 49.9545MHz ST-0016 5588-25 | |
| 771 | SX004-02 52B256-70 514256 514256 | |
| 772 | 50MHz SX004-03 52B256-70 SX004-07 | |
| 773 | 528257-70 514256-70 514256-70 SX004-04 | |
| 774 | 528257-70 514256-70 514256-70 SX004-05 | |
| 775 | 528257-70 514256-70 514256-70 SX004-06 | |
| 776 | 514256-70 514256-70 | |
| 777 | NEC D6376 | |
| 778 | ||
| 779 | */ | |
| 780 | ||
| 781 | ROM_START( speglsht ) | |
| 782 | ROM_REGION( 0x210000, REGION_CPU1, 0 ) | |
| 783 | ROM_LOAD( "sx004-07", 0x10000, 0x200000, CRC(2d759cc4) SHA1(9fedd829190b2aab850b2f1088caaec91e8715dd) ) | |
| 784 | ROM_COPY( REGION_CPU1, 0x10000, 0x00000, 0x08000 ) | |
| 785 | ||
| 786 | ROM_REGION32_BE( 0x200000, REGION_USER1, 0 ) | |
| 787 | ROM_LOAD32_BYTE( "sx004-04.u33", 0x00000, 0x80000, CRC(e46d2e57) SHA1(b1fb836ab2ce547dc2e8d1046d7ef835b87bb04e) ) | |
| 788 | ROM_LOAD32_BYTE( "sx004-03.u32", 0x00001, 0x80000, CRC(c6ffb00e) SHA1(f57ef45bb5c690c3e63101a36835d2687abfcdbd) ) | |
| 789 | ROM_LOAD32_BYTE( "sx004-02.u31", 0x00002, 0x80000, CRC(21eb46e4) SHA1(0ab21ed012c9a76e01c83b60c6f4670836dfa718) ) | |
| 790 | ROM_LOAD32_BYTE( "sx004-01.u30", 0x00003, 0x80000, CRC(65646949) SHA1(74931c230f4e4b1008fbc5fba169292e216aa23b) ) | |
| 791 | ||
| 792 | ROM_REGION( 0x200000, REGION_USER2,0) | |
| 793 | ROM_LOAD( "sx004-05", 0x000000, 0x100000, CRC(4b8ae72b) SHA1(261495edf41d7797d2ea8d442ac6a8362bafadf2) ) | |
| 794 | ROM_LOAD( "sx004-06", 0x100000, 0x100000, CRC(5af78e44) SHA1(0131d50348fef80c2b100d74b7c967c6a710d548) ) | |
| 795 | ROM_END | |
| 796 | ||
| 797 | ROM_START( speglsha ) | |
| 798 | ROM_REGION( 0x210000, REGION_CPU1, 0 ) | |
| 799 | ROM_LOAD( "sx004-07", 0x10000, 0x200000, CRC(2d759cc4) SHA1(9fedd829190b2aab850b2f1088caaec91e8715dd) ) | |
| 800 | ROM_COPY( REGION_CPU1, 0x10000, 0x00000, 0x08000 ) | |
| 801 | ||
| 802 | ROM_REGION32_BE( 0x200000, REGION_USER1, 0 ) | |
| 803 | ROM_LOAD32_BYTE( "sx004-04.u33", 0x00000, 0x80000, CRC(e46d2e57) SHA1(b1fb836ab2ce547dc2e8d1046d7ef835b87bb04e) ) | |
| 804 | ROM_LOAD32_BYTE( "sx004-03.u32", 0x00001, 0x80000, CRC(c6ffb00e) SHA1(f57ef45bb5c690c3e63101a36835d2687abfcdbd) ) | |
| 805 | ROM_LOAD32_BYTE( "sx004-02.u31", 0x00002, 0x80000, CRC(21eb46e4) SHA1(0ab21ed012c9a76e01c83b60c6f4670836dfa718) ) | |
| 806 | ROM_LOAD32_BYTE( "sx004-01.u30", 0x00003, 0x80000, CRC(65646949) SHA1(74931c230f4e4b1008fbc5fba169292e216aa23b) ) | |
| 807 | ||
| 808 | ROM_REGION( 0x200000, REGION_USER2,0) | |
| 809 | ROM_LOAD( "sx004-05.rd0", 0x000000, 0x100000, CRC(f3c69468) SHA1(81daef6d0596cb67bb6f87b39874aae1b1ffe6a6) ) | |
| 810 | ROM_LOAD( "sx004-06", 0x100000, 0x100000, CRC(5af78e44) SHA1(0131d50348fef80c2b100d74b7c967c6a710d548) ) | |
| 811 | ROM_END | |
| 812 | ||
| 813 | /* | |
| 814 | 662 | Mayjinsen (JPN Ver.) |
| 815 | 663 | (c)1994 Seta |
| 816 | 664 | |
| r936 | r937 | |
| 910 | 758 | st0016_game=2; |
| 911 | 759 | } |
| 912 | 760 | |
| 913 | static DRIVER_INIT(speglsht) | |
| 914 | { | |
| 915 | st0016_game=3; | |
| 916 | } | |
| 917 | ||
| 918 | 761 | static DRIVER_INIT(mayjinsn) |
| 919 | 762 | { |
| 920 | 763 | st0016_game=4|0x80; |
| r936 | r937 | |
| 939 | 782 | GAME( 1995, koikois, 0, st0016, koikois, renju, ROT0, "Visco", "Koi Koi Shimasho", GAME_IMPERFECT_GRAPHICS) |
| 940 | 783 | /* Not working */ |
| 941 | 784 | GAME( 199?, srmp5, 0, srmp5, srmp5, srmp5, ROT0, "Seta", "Super Real Mahjong P5",GAME_NOT_WORKING) |
| 942 | GAME( 1994, speglsht, 0, speglsht, speglsht, speglsht, ROT0, "Seta", "Super Eagle Shot (set 1)",GAME_NOT_WORKING) | |
| 943 | GAME( 1994, speglsha, speglsht, speglsht, speglsht, speglsht, ROT0, "Seta", "Super Eagle Shot (set 2)",GAME_NOT_WORKING) | |
| 944 | 785 | GAME( 1994, mayjinsn, 0, mayjinsn, st0016, mayjinsn, ROT0, "Seta", "Mayjinsen",GAME_IMPERFECT_GRAPHICS|GAME_NOT_WORKING) |
| r936 | r937 | |
|---|---|---|
| 47 | 47 | |
| 48 | 48 | static WRITE8_HANDLER( ironhors_filter_w ) |
| 49 | 49 | { |
| 50 | if (sndti_t | |
| 50 | if (sndti_exist | |
| 51 | 51 | { |
| 52 | 52 | filter_rc_set_RC(0,FLT_RC_LOWPASS, 1000,2200,1000,data & 0x04 ? CAP_N(220) : 0); /* YM2203-SSG-A */ |
| 53 | 53 | filter_rc_set_RC(1,FLT_RC_LOWPASS, 1000,2200,1000,data & 0x02 ? CAP_N(220) : 0); /* YM2203-SSG-B */ |
| r936 | r937 | |
|---|---|---|
| 432 | 432 | |
| 433 | 433 | /* 32-bit ONLY */ |
| 434 | 434 | { |
| 435 | if( gfx | |
| 435 | if( gfx | |
| 436 | 436 | { |
| 437 | // const pen_t *pal = &gfx->colortable[gfx->color_granularity * (color % gfx->total_colors)]; | |
| 437 | // const pen_t *pal = &gfx->colortable[gfx->color_granularity * (color % gfx->total_colors)]; | |
| 438 | 438 | UINT32 palbase = (gfx->color_granularity * color) & 0x1ffff; |
| 439 | 439 | const pen_t *pal = &cps3_mame_colours[palbase]; |
| 440 | 440 | UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| r936 | r937 | |
| 907 | 907 | |
| 908 | 908 | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| 909 | 909 | machine->gfx[0] = allocgfx(&cps3_tiles8x8_layout); |
| 910 | machine->gfx[0]->colortable = machine->pens; | |
| 911 | 910 | machine->gfx[0]->total_colors = machine->drv->total_colors / 16; |
| 912 | 911 | |
| 913 | 912 | //decode_ssram(); |
| 914 | 913 | |
| 915 | 914 | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| 916 | 915 | machine->gfx[1] = allocgfx(&cps3_tiles16x16_layout); |
| 917 | machine->gfx[1]->colortable = machine->pens; | |
| 918 | 916 | machine->gfx[1]->total_colors = machine->drv->total_colors / 64; |
| 919 | 917 | machine->gfx[1]->color_granularity=64; |
| 920 | 918 |
| r936 | r937 | |
|---|---|---|
| 246 | 246 | 1024, /* 1024 characters */ |
| 247 | 247 | 2, /* 2 bits per pixel */ |
| 248 | 248 | { 0, 4 }, /* the bitplanes are packed in one byte */ |
| 249 | { 8*8+3, 8*8+2, 8*8+1, 8*8+0, 3, 2, 1, 0 }, | |
| 250 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 249 | { STEP4(8*8+3,-1), STEP4(0*8+3,-1) }, | |
| 250 | { STEP8(0*8,8) }, | |
| 251 | 251 | 16*8 /* every char takes 8 consecutive bytes */ |
| 252 | 252 | }; |
| 253 | 253 | static const gfx_layout charlayout2 = |
| r936 | r937 | |
| 256 | 256 | 2048, /* 2048 characters */ |
| 257 | 257 | 3, /* 3 bits per pixel */ |
| 258 | 258 | { 0, 2048*8*8, 2*2048*8*8 }, /* the bitplanes are separated */ |
| 259 | { 7, 6, 5, 4, 3, 2, 1, 0 }, | |
| 260 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 259 | { STEP8(7,-1) }, | |
| 260 | { STEP8(0*8,8) }, | |
| 261 | 261 | 8*8 /* every char takes 8 consecutive bytes */ |
| 262 | 262 | }; |
| 263 | 263 | |
| r936 | r937 | |
| 288 | 288 | MDRV_SCREEN_SIZE(32*8, 32*8) |
| 289 | 289 | MDRV_SCREEN_VISIBLE_AREA(3*8, 31*8-1, 2*8, 30*8-1) |
| 290 | 290 | MDRV_GFXDECODE(gfxdecodeinfo) |
| 291 | MDRV_PALETTE_LENGTH(32) | |
| 292 | MDRV_COLORTABLE_LENGTH(32*4+16*8) | |
| 291 | MDRV_PALETTE_LENGTH(32*4+16*8) | |
| 293 | 292 | |
| 294 | 293 | MDRV_PALETTE_INIT(bankp) |
| 295 | 294 | MDRV_VIDEO_START(bankp) |
| r0 | r937 | |
|---|---|---|
| 1 | /* | |
| 2 | Super Eagle Shot | |
| 3 | (c)1993 Seta (distributed by Visco) | |
| 4 | ----------------------------------- | |
| 5 | driver by Tomasz Slanina | |
| 6 | ||
| 7 | ||
| 8 | GOLF | |
| 9 | E30-001A | |
| 10 | ||
| 11 | CPU : Integrated Device IDT79R3051-25J 9407C (R3000A) | |
| 12 | Sound+Objects : ST-0016 | |
| 13 | OSC : 50.0000MHz (X1) 42.9545MHz (X3) | |
| 14 | ||
| 15 | ROMs: | |
| 16 | SX004-01.PR0 - R3051 Main programs (MX27C4000) | |
| 17 | SX004-02.PR1 | | |
| 18 | SX004-03.PR2 | | |
| 19 | SX004-04.PR3 / | |
| 20 | ||
| 21 | SX004-05.RD0 - Data and Graphics (D23C8000SCZ) | |
| 22 | SX004-06.RD1 / | |
| 23 | ||
| 24 | SX004-07.ZPR - ST-0016 Program and Data (16M mask, read as 27c160) | |
| 25 | ||
| 26 | GALs (not dumped): | |
| 27 | SX004-08.27 (16V8B) | |
| 28 | SX004-09.46 (16V8B) | |
| 29 | SX004-10.59 (16V8B) | |
| 30 | SX004-11.61 (22V10B) | |
| 31 | SX004-12.62 (22V10B) | |
| 32 | SX004-13.63 (22V10B) | |
| 33 | ||
| 34 | Custom chips: | |
| 35 | SETA ST-0015 60EN502F12 JAPAN 9415YAI (U18, 208pin PQFP, system controller) | |
| 36 | SETA ST-0016 TC6187AF JAPAN 9348YAA (U68, 208pin PQFP, sound & object) | |
| 37 | ||
| 38 | R3051 ST-0015 SX004-01 49.9545MHz ST-0016 5588-25 | |
| 39 | SX004-02 52B256-70 514256 514256 | |
| 40 | 50MHz SX004-03 52B256-70 SX004-07 | |
| 41 | 528257-70 514256-70 514256-70 SX004-04 | |
| 42 | 528257-70 514256-70 514256-70 SX004-05 | |
| 43 | 528257-70 514256-70 514256-70 SX004-06 | |
| 44 | 514256-70 514256-70 | |
| 45 | NEC D6376 | |
| 46 | ||
| 47 | ||
| 48 | */ | |
| 49 | ||
| 50 | #include "driver.h" | |
| 51 | #include "cpu/z80/z80.h" | |
| 52 | #include "cpu/mips/r3000.h" | |
| 53 | #include "sound/st0016.h" | |
| 54 | #include "st0016.h" | |
| 55 | ||
| 56 | READ8_HANDLER(st0016_dma_r); | |
| 57 | static UINT8 *shared; | |
| 58 | ||
| 59 | UINT32 *speglsht_framebuffer; | |
| 60 | UINT32 speglsht_videoreg; | |
| 61 | ||
| 62 | extern UINT8 *st0016_charram; | |
| 63 | ||
| 64 | static ADDRESS_MAP_START( st0016_mem, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 65 | AM_RANGE(0x0000, 0x7fff) AM_ROM | |
| 66 | AM_RANGE(0x8000, 0xbfff) AM_ROMBANK(1) | |
| 67 | AM_RANGE(0xc000, 0xcfff) AM_READ(st0016_sprite_ram_r) AM_WRITE(st0016_sprite_ram_w) | |
| 68 | AM_RANGE(0xd000, 0xdfff) AM_READ(st0016_sprite2_ram_r) AM_WRITE(st0016_sprite2_ram_w) | |
| 69 | AM_RANGE(0xe000, 0xe7ff) AM_RAM | |
| 70 | AM_RANGE(0xe800, 0xe87f) AM_RAM | |
| 71 | AM_RANGE(0xe900, 0xe9ff) AM_RAM AM_WRITE(st0016_snd_w) AM_BASE(&st0016_sound_regs) | |
| 72 | AM_RANGE(0xea00, 0xebff) AM_READ(st0016_palette_ram_r) AM_WRITE(st0016_palette_ram_w) | |
| 73 | AM_RANGE(0xec00, 0xec1f) AM_READ(st0016_character_ram_r) AM_WRITE(st0016_character_ram_w) | |
| 74 | AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE(&shared) | |
| 75 | ADDRESS_MAP_END | |
| 76 | ||
| 77 | static ADDRESS_MAP_START( st0016_io, ADDRESS_SPACE_IO, 8 ) | |
| 78 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 79 | AM_RANGE(0x00, 0xbf) AM_READ(st0016_vregs_r) AM_WRITE(st0016_vregs_w) | |
| 80 | AM_RANGE(0xe1, 0xe1) AM_WRITE(st0016_rom_bank_w) | |
| 81 | AM_RANGE(0xe2, 0xe2) AM_WRITE(st0016_sprite_bank_w) | |
| 82 | AM_RANGE(0xe3, 0xe4) AM_WRITE(st0016_character_bank_w) | |
| 83 | AM_RANGE(0xe5, 0xe5) AM_WRITE(st0016_palette_bank_w) | |
| 84 | AM_RANGE(0xe6, 0xe6) AM_WRITENOP | |
| 85 | AM_RANGE(0xe7, 0xe7) AM_WRITENOP | |
| 86 | AM_RANGE(0xf0, 0xf0) AM_READ(st0016_dma_r) | |
| 87 | ADDRESS_MAP_END | |
| 88 | ||
| 89 | static READ32_HANDLER(shared_r) | |
| 90 | { | |
| 91 | return shared[offset]; | |
| 92 | } | |
| 93 | ||
| 94 | static WRITE32_HANDLER(shared_w) | |
| 95 | { | |
| 96 | shared[offset]=data&0xff; | |
| 97 | } | |
| 98 | ||
| 99 | static WRITE32_HANDLER(videoreg_w) | |
| 100 | { | |
| 101 | COMBINE_DATA(&speglsht_videoreg); | |
| 102 | } | |
| 103 | ||
| 104 | static UINT32 *cop_ram; | |
| 105 | ||
| 106 | static WRITE32_HANDLER(cop_w) | |
| 107 | { | |
| 108 | COMBINE_DATA(&cop_ram[offset]); | |
| 109 | ||
| 110 | if(cop_ram[offset]&0x8000) //fix (sign) | |
| 111 | { | |
| 112 | cop_ram[offset]|=0xffff0000; | |
| 113 | } | |
| 114 | } | |
| 115 | ||
| 116 | //matrix * vector | |
| 117 | static READ32_HANDLER(cop_r) | |
| 118 | { | |
| 119 | INT32 *cop=(INT32*)&cop_ram[0]; | |
| 120 | ||
| 121 | union | |
| 122 | { | |
| 123 | INT32 a; | |
| 124 | UINT32 b; | |
| 125 | }temp; | |
| 126 | ||
| 127 | switch (offset) | |
| 128 | { | |
| 129 | case 0x40/4: | |
| 130 | { | |
| 131 | temp.a=((cop[0x3]*cop[0x0]+cop[0x4]*cop[0x1]+cop[0x5]*cop[0x2])>>14)+cop[0xc]; | |
| 132 | return temp.b; | |
| 133 | } | |
| 134 | ||
| 135 | case 0x44/4: | |
| 136 | { | |
| 137 | temp.a=((cop[0x6]*cop[0x0]+cop[0x7]*cop[0x1]+cop[0x8]*cop[0x2])>>14)+cop[0xd]; | |
| 138 | return temp.b; | |
| 139 | } | |
| 140 | ||
| 141 | case 0x48/4: | |
| 142 | { | |
| 143 | temp.a=((cop[0x9]*cop[0x0]+cop[0xa]*cop[0x1]+cop[0xb]*cop[0x2])>>14)+cop[0xe]; | |
| 144 | return temp.b; | |
| 145 | } | |
| 146 | } | |
| 147 | ||
| 148 | return 0; | |
| 149 | } | |
| 150 | ||
| 151 | static ADDRESS_MAP_START( speglsht_mem, ADDRESS_SPACE_PROGRAM, 32 ) | |
| 152 | AM_RANGE(0x00000000, 0x000fffff) AM_RAM | |
| 153 | AM_RANGE(0x01000000, 0x01007fff) AM_RAM //tested - STATIC RAM | |
| 154 | AM_RANGE(0x01600000, 0x0160004f) AM_READWRITE(cop_r, cop_w) AM_BASE(&cop_ram) | |
| 155 | AM_RANGE(0x01800200, 0x01800203) AM_WRITE(videoreg_w) | |
| 156 | AM_RANGE(0x01800300, 0x01800303) AM_READ(input_port_0_dword_r) | |
| 157 | AM_RANGE(0x01800400, 0x01800403) AM_READ(input_port_1_dword_r) | |
| 158 | AM_RANGE(0x01a00000, 0x01afffff) AM_RAM AM_BASE(&speglsht_framebuffer) | |
| 159 | AM_RANGE(0x01b00000, 0x01b07fff) AM_RAM //cleared ... video related ? | |
| 160 | AM_RANGE(0x01c00000, 0x01dfffff) AM_READ(MRA32_ROM) AM_WRITE(MWA32_ROM) AM_REGION(REGION_USER2, 0) | |
| 161 | AM_RANGE(0x0a000000, 0x0a003fff) AM_READWRITE(shared_r, shared_w) | |
| 162 | AM_RANGE(0x1eff0000, 0x1eff001f) AM_RAM | |
| 163 | AM_RANGE(0x1eff003c, 0x1eff003f) AM_READNOP //interrupt related | |
| 164 | AM_RANGE(0x1fc00000, 0x1fdfffff) AM_ROM AM_REGION(REGION_USER1, 0) | |
| 165 | AM_RANGE(0x2fc00000, 0x2fdfffff) AM_ROM AM_REGION(REGION_USER1, 0) // mirror for interrupts | |
| 166 | ADDRESS_MAP_END | |
| 167 | ||
| 168 | static INPUT_PORTS_START( speglsht ) | |
| 169 | ||
| 170 | PORT_START | |
| 171 | PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 172 | PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2) | |
| 173 | PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) | |
| 174 | PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) | |
| 175 | PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) | |
| 176 | PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) | |
| 177 | PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) | |
| 178 | PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) | |
| 179 | PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 ) | |
| 180 | PORT_BIT( 0xffff0000, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 181 | ||
| 182 | PORT_START | |
| 183 | PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) ) | |
| 184 | PORT_DIPSETTING( 0x0003, DEF_STR( 3C_1C ) ) | |
| 185 | PORT_DIPSETTING( 0x0004, DEF_STR( 2C_1C ) ) | |
| 186 | PORT_DIPSETTING( 0x0007, DEF_STR( 1C_1C ) ) | |
| 187 | PORT_DIPSETTING( 0x0001, "1C/1C or 2C/3C" ) /* 1 coin/1 credit or 2 coins/3 credits */ | |
| 188 | PORT_DIPSETTING( 0x0002, DEF_STR( 2C_3C ) ) | |
| 189 | PORT_DIPSETTING( 0x0006, DEF_STR( 1C_2C ) ) | |
| 190 | PORT_DIPSETTING( 0x0005, DEF_STR( 1C_3C ) ) | |
| 191 | PORT_DIPSETTING( 0x0000, "2C Start/1C Continue" ) | |
| 192 | PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) ) | |
| 193 | PORT_DIPSETTING( 0x0018, DEF_STR( 3C_1C ) ) | |
| 194 | PORT_DIPSETTING( 0x0020, DEF_STR( 2C_1C ) ) | |
| 195 | PORT_DIPSETTING( 0x0038, DEF_STR( 1C_1C ) ) | |
| 196 | PORT_DIPSETTING( 0x0008, "1C/1C or 2C/3C" ) /* 1 coin/1 credit or 2 coins/3 credits */ | |
| 197 | PORT_DIPSETTING( 0x0010, DEF_STR( 2C_3C ) ) | |
| 198 | PORT_DIPSETTING( 0x0030, DEF_STR( 1C_2C ) ) | |
| 199 | PORT_DIPSETTING( 0x0028, DEF_STR( 1C_3C ) ) | |
| 200 | PORT_DIPSETTING( 0x0000, "2C Start/1C Continue" ) | |
| 201 | PORT_DIPNAME( 0x0040, 0x0040, "Unkown / Unused" ) | |
| 202 | PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) | |
| 203 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) | |
| 204 | PORT_DIPNAME( 0x0080, 0x0080, "Bonus for PAR Play" ) | |
| 205 | PORT_DIPSETTING( 0x0080, DEF_STR( None ) ) | |
| 206 | PORT_DIPSETTING( 0x0000, "Extra Hole" ) | |
| 207 | PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Difficulty ) ) | |
| 208 | PORT_DIPSETTING( 0x0300, DEF_STR( Normal ) ) | |
| 209 | PORT_DIPSETTING( 0x0200, DEF_STR( Easy ) ) | |
| 210 | PORT_DIPSETTING( 0x0100, DEF_STR( Hard ) ) | |
| 211 | PORT_DIPSETTING( 0x0000, DEF_STR( Very_Hard ) ) | |
| 212 | PORT_DIPNAME( 0x0c00, 0x0c00, "Number of Players" ) | |
| 213 | PORT_DIPSETTING( 0x0c00, "3" ) | |
| 214 | PORT_DIPSETTING( 0x0800, "4" ) | |
| 215 | PORT_DIPSETTING( 0x0400, "2" ) | |
| 216 | PORT_DIPSETTING( 0x0000, "1" ) | |
| 217 | PORT_DIPNAME( 0x1000, 0x0000, DEF_STR( Demo_Sounds ) ) | |
| 218 | PORT_DIPSETTING( 0x1000, DEF_STR( Off ) ) | |
| 219 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) | |
| 220 | PORT_DIPNAME( 0x2000, 0x0000, "Control Panel" ) | |
| 221 | PORT_DIPSETTING( 0x2000, "Double" ) | |
| 222 | PORT_DIPSETTING( 0x0000, DEF_STR( Single ) ) | |
| 223 | PORT_DIPNAME( 0x4000, 0x4000, "Country" ) | |
| 224 | PORT_DIPSETTING( 0x4000, DEF_STR( Japan ) ) | |
| 225 | PORT_DIPSETTING( 0x0000, DEF_STR( USA ) ) | |
| 226 | PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 227 | PORT_BIT( 0x00010000, IP_ACTIVE_HIGH, IPT_SERVICE ) PORT_NAME("Test Mode") PORT_CODE(KEYCODE_F2) | |
| 228 | PORT_BIT( 0x00020000, IP_ACTIVE_LOW, IPT_TILT ) | |
| 229 | PORT_BIT( 0x00040000, IP_ACTIVE_LOW, IPT_COIN1 ) | |
| 230 | PORT_BIT( 0x00080000, IP_ACTIVE_LOW, IPT_COIN2 ) | |
| 231 | PORT_BIT( 0x00100000, IP_ACTIVE_LOW, IPT_SERVICE1 ) | |
| 232 | PORT_BIT( 0x80A00000, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 233 | PORT_BIT( 0x00400000, IP_ACTIVE_LOW, IPT_START1 ) | |
| 234 | PORT_BIT( 0x01000000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1) | |
| 235 | PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) | |
| 236 | PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) | |
| 237 | PORT_BIT( 0x08000000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) | |
| 238 | PORT_BIT( 0x10000000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) | |
| 239 | PORT_BIT( 0x20000000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) | |
| 240 | PORT_BIT( 0x40000000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) | |
| 241 | INPUT_PORTS_END | |
| 242 | ||
| 243 | static const gfx_decode gfxdecodeinfo[] = | |
| 244 | { | |
| 245 | { -1 } /* end of array */ | |
| 246 | }; | |
| 247 | ||
| 248 | static struct ST0016interface st0016_interface = | |
| 249 | { | |
| 250 | &st0016_charram | |
| 251 | }; | |
| 252 | ||
| 253 | static INTERRUPT_GEN( irq4_gen ) | |
| 254 | { | |
| 255 | cpunum_set_input_line(1, R3000_IRQ4, ASSERT_LINE); | |
| 256 | } | |
| 257 | ||
| 258 | static struct r3000_config config = | |
| 259 | { | |
| 260 | 0, | |
| 261 | 4096, /* code cache size */ | |
| 262 | 2048 /* data cache size */ | |
| 263 | }; | |
| 264 | ||
| 265 | static MACHINE_RESET(speglsht) | |
| 266 | { | |
| 267 | memset(shared,0,0x1000); | |
| 268 | } | |
| 269 | ||
| 270 | static MACHINE_DRIVER_START( speglsht ) | |
| 271 | /* basic machine hardware */ | |
| 272 | MDRV_CPU_ADD_TAG("main",Z80, 8000000) /* 8 MHz ? */ | |
| 273 | MDRV_CPU_PROGRAM_MAP(st0016_mem,0) | |
| 274 | MDRV_CPU_IO_MAP(st0016_io,0) | |
| 275 | ||
| 276 | MDRV_CPU_VBLANK_INT(irq0_line_hold,1) | |
| 277 | ||
| 278 | MDRV_CPU_ADD(R3000LE, 25000000) | |
| 279 | MDRV_CPU_CONFIG(config) | |
| 280 | MDRV_CPU_PROGRAM_MAP(speglsht_mem,0) | |
| 281 | MDRV_CPU_VBLANK_INT(irq4_gen,1) | |
| 282 | ||
| 283 | MDRV_SCREEN_REFRESH_RATE(60) | |
| 284 | MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION) | |
| 285 | MDRV_INTERLEAVE(100) | |
| 286 | MDRV_MACHINE_RESET(speglsht) | |
| 287 | ||
| 288 | /* video hardware */ | |
| 289 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) | |
| 290 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) | |
| 291 | MDRV_SCREEN_SIZE(512, 512) | |
| 292 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 8, 239-8) | |
| 293 | MDRV_GFXDECODE(gfxdecodeinfo) | |
| 294 | MDRV_PALETTE_LENGTH(16*16*4+1) | |
| 295 | ||
| 296 | MDRV_VIDEO_START(st0016) | |
| 297 | MDRV_VIDEO_UPDATE(st0016) | |
| 298 | ||
| 299 | MDRV_SPEAKER_STANDARD_STEREO("left", "right") | |
| 300 | ||
| 301 | MDRV_SOUND_ADD(ST0016, 0) | |
| 302 | MDRV_SOUND_CONFIG(st0016_interface) | |
| 303 | MDRV_SOUND_ROUTE(0, "left", 1.0) | |
| 304 | MDRV_SOUND_ROUTE(1, "right", 1.0) | |
| 305 | MACHINE_DRIVER_END | |
| 306 | ||
| 307 | ROM_START( speglsht ) | |
| 308 | ROM_REGION( 0x210000, REGION_CPU1, 0 ) | |
| 309 | ROM_LOAD( "sx004-07", 0x010000, 0x200000, CRC(2d759cc4) SHA1(9fedd829190b2aab850b2f1088caaec91e8715dd) ) | |
| 310 | ||
| 311 | ROM_COPY( REGION_CPU1, 0x10000, 0x00000, 0x08000 ) | |
| 312 | ||
| 313 | ROM_REGION32_BE( 0x200000, REGION_USER1, 0 ) | |
| 314 | ROM_LOAD32_BYTE( "sx004-04.u33", 0x00000, 0x80000, CRC(e46d2e57) SHA1(b1fb836ab2ce547dc2e8d1046d7ef835b87bb04e) ) | |
| 315 | ROM_LOAD32_BYTE( "sx004-03.u32", 0x00001, 0x80000, CRC(c6ffb00e) SHA1(f57ef45bb5c690c3e63101a36835d2687abfcdbd) ) | |
| 316 | ROM_LOAD32_BYTE( "sx004-02.u31", 0x00002, 0x80000, CRC(21eb46e4) SHA1(0ab21ed012c9a76e01c83b60c6f4670836dfa718) ) | |
| 317 | ROM_LOAD32_BYTE( "sx004-01.u30", 0x00003, 0x80000, CRC(65646949) SHA1(74931c230f4e4b1008fbc5fba169292e216aa23b) ) | |
| 318 | ||
| 319 | ROM_REGION( 0x200000, REGION_USER2,0) | |
| 320 | ROM_LOAD32_WORD( "sx004-05.rd0", 0x000000, 0x100000, CRC(f3c69468) SHA1(81daef6d0596cb67bb6f87b39874aae1b1ffe6a6) ) | |
| 321 | ROM_LOAD32_WORD( "sx004-06", 0x000002, 0x100000, CRC(5af78e44) SHA1(0131d50348fef80c2b100d74b7c967c6a710d548) ) | |
| 322 | ||
| 323 | ROM_END | |
| 324 | ||
| 325 | ||
| 326 | ROM_START( speglsha ) | |
| 327 | ROM_REGION( 0x210000, REGION_CPU1, 0 ) | |
| 328 | ROM_LOAD( "sx004-07", 0x10000, 0x200000, CRC(2d759cc4) SHA1(9fedd829190b2aab850b2f1088caaec91e8715dd) ) | |
| 329 | ROM_COPY( REGION_CPU1, 0x10000, 0x00000, 0x08000 ) | |
| 330 | ||
| 331 | ROM_REGION32_BE( 0x200000, REGION_USER1, 0 ) | |
| 332 | ROM_LOAD32_BYTE( "sx004-04.u33", 0x00000, 0x80000, CRC(e46d2e57) SHA1(b1fb836ab2ce547dc2e8d1046d7ef835b87bb04e) ) | |
| 333 | ROM_LOAD32_BYTE( "sx004-03.u32", 0x00001, 0x80000, CRC(c6ffb00e) SHA1(f57ef45bb5c690c3e63101a36835d2687abfcdbd) ) | |
| 334 | ROM_LOAD32_BYTE( "sx004-02.u31", 0x00002, 0x80000, CRC(21eb46e4) SHA1(0ab21ed012c9a76e01c83b60c6f4670836dfa718) ) | |
| 335 | ROM_LOAD32_BYTE( "sx004-01.u30", 0x00003, 0x80000, CRC(65646949) SHA1(74931c230f4e4b1008fbc5fba169292e216aa23b) ) | |
| 336 | ||
| 337 | ROM_REGION( 0x200000, REGION_USER2,0) | |
| 338 | ROM_LOAD( "sx004-05.rd0", 0x000000, 0x100000, CRC(f3c69468) SHA1(81daef6d0596cb67bb6f87b39874aae1b1ffe6a6) ) | |
| 339 | ROM_LOAD( "sx004-06", 0x100000, 0x100000, CRC(5af78e44) SHA1(0131d50348fef80c2b100d74b7c967c6a710d548) ) | |
| 340 | ROM_END | |
| 341 | ||
| 342 | ||
| 343 | ||
| 344 | static DRIVER_INIT(speglsht) | |
| 345 | { | |
| 346 | st0016_game=3; | |
| 347 | } | |
| 348 | ||
| 349 | ||
| 350 | GAME( 1994, speglsht, 0, speglsht, speglsht, speglsht, ROT0, "Seta", "Super Eagle Shot", GAME_IMPERFECT_GRAPHICS) | |
| 351 | GAME( 1994, speglsha, speglsht, speglsht, speglsht, speglsht, ROT0, "Seta", "Super Eagle Shot (set 2)",GAME_NOT_WORKING) |
| r936 | r937 | |
|---|---|---|
| 1030 | 1030 | MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 28*8-1) |
| 1031 | 1031 | MDRV_GFXDECODE(sasuke_gfxdecodeinfo) |
| 1032 | 1032 | MDRV_PALETTE_LENGTH(32) |
| 1033 | MDRV_COLORTABLE_LENGTH(4*4 + 4*4) | |
| 1034 | 1033 | |
| 1035 | 1034 | MDRV_PALETTE_INIT(satansat) |
| 1036 | 1035 | MDRV_VIDEO_START(satansat) |
| r936 | r937 | |
| 1103 | 1102 | MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 28*8-1) |
| 1104 | 1103 | MDRV_GFXDECODE(vanguard_gfxdecodeinfo) |
| 1105 | 1104 | MDRV_PALETTE_LENGTH(64) |
| 1106 | MDRV_COLORTABLE_LENGTH(16*4) | |
| 1107 | 1105 | |
| 1108 | 1106 | MDRV_PALETTE_INIT(rockola) |
| 1109 | 1107 | MDRV_VIDEO_START(rockola) |
| r936 | r937 | |
|---|---|---|
| 213 | 213 | |
| 214 | 214 | static const gfx_layout tilelayout = |
| 215 | 215 | { |
| 216 | 8,8, /* 8*8 characters */ | |
| 217 | RGN_FRAC(1,2), /* 256 characters */ | |
| 218 | 2, /* 2 bits per pixel */ | |
| 219 | { 0, 4 }, /* the two bitplanes for 4 pixels are packed into one byte */ | |
| 220 | { 8*8+0, 8*8+1, 8*8+2, 8*8+3, 0, 1, 2, 3 }, /* bits are packed in groups of four */ | |
| 221 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 222 | 16*8 /* every char takes 16 bytes */ | |
| 216 | 8,8, | |
| 217 | RGN_FRAC(1,2), | |
| 218 | 2, | |
| 219 | { 0, 4 }, | |
| 220 | { STEP4(8*8,1), STEP4(0*8,1) }, | |
| 221 | { STEP8(0*8,8) }, | |
| 222 | 16*8 | |
| 223 | 223 | }; |
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | static const gfx_layout spritelayout = |
| 227 | 227 | { |
| 228 | 16,16, /* 16*16 sprites */ | |
| 229 | RGN_FRAC(1,2), /* 64 sprites */ | |
| 230 | 2, /* 2 bits per pixel */ | |
| 231 | { 0, 4 }, /* the two bitplanes for 4 pixels are packed into one byte */ | |
| 232 | { 8*8, 8*8+1, 8*8+2, 8*8+3, 16*8+0, 16*8+1, 16*8+2, 16*8+3, | |
| 233 | 24*8+0, 24*8+1, 24*8+2, 24*8+3, 0, 1, 2, 3 }, | |
| 234 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, | |
| 235 | 32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 }, | |
| 236 | 64*8 /* every sprite takes 64 bytes */ | |
| 228 | 16,16, | |
| 229 | RGN_FRAC(1,2), | |
| 230 | 2, | |
| 231 | { 0, 4 }, | |
| 232 | { STEP4(8*8,1), STEP4(16*8,1), STEP4(24*8,1), STEP4(0*8,1) }, | |
| 233 | { STEP8(0*8,8), STEP8(32*8,8) }, | |
| 234 | 64*8 | |
| 237 | 235 | }; |
| 238 | 236 | |
| 239 | 237 |
| r936 | r937 | |
|---|---|---|
| 47 | 47 | #include "driver.h" |
| 48 | 48 | #include "sound/custom.h" |
| 49 | 49 | #include "includes/amiga.h" |
| 50 | #include "cdrom.h" | |
| 51 | #include "sound/cdda.h" | |
| 50 | #include "includes/cubocd32.h" | |
| 51 | //#include "memconv.h" | |
| 52 | 52 | |
| 53 | /* | |
| 53 | //READWRITE16BETO32BE(amiga_cia32,amiga_cia_r,amiga_cia_w) | |
| 54 | //READWRITE16BETO32BE(amiga_custom32,amiga_custom_r,amiga_custom_w) | |
| 54 | 55 | |
| 55 | Akiko custom chip emulation | |
| 56 | ||
| 57 | The Akiko chip has: | |
| 58 | - built in 1KB NVRAM | |
| 59 | - chunky to planar converter | |
| 60 | - custom CDROM controller | |
| 61 | ||
| 62 | CDROM Commands: | |
| 63 | len does not include checksum byte, | |
| 64 | resp len does include checksum byte | |
| 65 | ||
| 66 | x0: len = 0x01, resp len = 0x01 | |
| 67 | x1: len = 0x02, resp len = 0x03 | |
| 68 | x2: len = 0x01, resp len = 0x03 - Pause CD Audio | |
| 69 | x3: len = 0x01, resp len = 0x03 - Unpause CD Audio | |
| 70 | x4: len = 0x0C, resp len = 0x03 - CD Audio Play/Read CD Data/Seek | |
| 71 | x5: len = 0x02, resp len = 0x10 - Read TOC | |
| 72 | x6: len = 0x01, resp len = 0x10 - Get Next TOC entry | |
| 73 | x7: len = 0x01, resp len = 0x15 - Door Status | |
| 74 | x8: len = 0x04, resp len = 0x03 | |
| 75 | x9: len = 0x01, resp len = 0x01 | |
| 76 | xA: len = 0x00, resp len = 0x03 - Media Status: Response = 0A NN CK where NN = 0: no disk and NN = 1: disk inserted | |
| 77 | xB: len = 0x00, resp len = 0x01 | |
| 78 | xC: len = 0x00, resp len = 0x01 | |
| 79 | xD: len = 0x00, resp len = 0x01 | |
| 80 | xE: len = 0x00, resp len = 0x01 | |
| 81 | xF: len = 0x00, resp len = 0x01 | |
| 82 | */ | |
| 83 | ||
| 84 | #define LOG_AKIKO 0 | |
| 85 | #define LOG_AKIKO_I2C 0 | |
| 86 | ||
| 87 | enum { | |
| 88 | I2C_WAIT = 0, | |
| 89 | I2C_DEVICEADDR, | |
| 90 | I2C_WORDADDR, | |
| 91 | I2C_DATA | |
| 92 | }; | |
| 93 | ||
| 94 | #define NVRAM_SIZE 1024 | |
| 95 | /* max size of one write request */ | |
| 96 | #define NVRAM_PAGE_SIZE 16 | |
| 97 | ||
| 98 | struct akiko_def | |
| 56 | static READ32_HANDLER( amiga_cia32_r ) | |
| 99 | 57 | { |
| 100 | /* chunky to planar converter */ | |
| 101 | UINT32 c2p_input_buffer[8]; | |
| 102 | UINT32 c2p_output_buffer[8]; | |
| 103 | UINT32 c2p_input_index; | |
| 104 | UINT32 c2p_output_index; | |
| 105 | ||
| 106 | /* i2c bus */ | |
| 107 | int i2c_state; | |
| 108 | int i2c_bitcounter; | |
| 109 | int i2c_direction; | |
| 110 | int i2c_sda_dir_nvram; | |
| 111 | int i2c_scl_out; | |
| 112 | int i2c_scl_in; | |
| 113 | int i2c_scl_dir; | |
| 114 | int i2c_oscl; | |
| 115 | int i2c_sda_out; | |
| 116 | int i2c_sda_in; | |
| 117 | int i2c_sda_dir; | |
| 118 | int i2c_osda; | |
| 119 | ||
| 120 | /* nvram */ | |
| 121 | UINT8 nvram[NVRAM_SIZE]; | |
| 122 | UINT8 nvram_writetmp[NVRAM_PAGE_SIZE]; | |
| 123 | int nvram_address; | |
| 124 | int nvram_writeaddr; | |
| 125 | int nvram_rw; | |
| 126 | UINT8 nvram_byte; | |
| 127 | ||
| 128 | /* cdrom */ | |
| 129 | UINT32 cdrom_status[2]; | |
| 130 | UINT32 cdrom_address[2]; | |
| 131 | UINT8 cdrom_cmd_start; | |
| 132 | UINT8 cdrom_cmd_end; | |
| 133 | UINT8 cdrom_cmd_resp; | |
| 134 | cdrom_file *cdrom; | |
| 135 | } akiko; | |
| 136 | ||
| 137 | void init_akiko(void) | |
| 138 | { | |
| 139 | akiko.c2p_input_index = 0; | |
| 140 | akiko.c2p_output_index = 0; | |
| 141 | ||
| 142 | akiko.i2c_state = I2C_WAIT; | |
| 143 | akiko.i2c_bitcounter = -1; | |
| 144 | akiko.i2c_direction = -1; | |
| 145 | akiko.i2c_sda_dir_nvram = 0; | |
| 146 | akiko.i2c_scl_out = 0; | |
| 147 | akiko.i2c_scl_in = 0; | |
| 148 | akiko.i2c_scl_dir = 0; | |
| 149 | akiko.i2c_oscl = 0; | |
| 150 | akiko.i2c_sda_out = 0; | |
| 151 | akiko.i2c_sda_in = 0; | |
| 152 | akiko.i2c_sda_dir = 0; | |
| 153 | akiko.i2c_osda = 0; | |
| 154 | ||
| 155 | akiko.nvram_address = 0; | |
| 156 | akiko.nvram_writeaddr = 0; | |
| 157 | akiko.nvram_rw = 0; | |
| 158 | akiko.nvram_byte = 0; | |
| 159 | memset( akiko.nvram, 0, NVRAM_SIZE ); | |
| 160 | ||
| 161 | akiko.cdrom_status[0] = akiko.cdrom_status[1] = 0; | |
| 162 | akiko.cdrom_address[0] = akiko.cdrom_address[1] = 0; | |
| 163 | akiko.cdrom_cmd_start = akiko.cdrom_cmd_end = akiko.cdrom_cmd_resp = 0; | |
| 164 | akiko.cdrom = cdrom_open(get_disk_handle(0)); | |
| 58 | UINT32 result = 0; | |
| 59 | if ((mem_mask & 0xffff0000) != 0xffff0000) | |
| 60 | result |= amiga_cia_r(offset * 2 + 0, mem_mask >> 16) << 16; | |
| 61 | if ((mem_mask & 0x0000ffff) != 0x0000ffff) | |
| 62 | result |= amiga_cia_r(offset * 2 + 1, mem_mask) << 0; | |
| 63 | return result; | |
| 165 | 64 | } |
| 166 | 65 | |
| 167 | ||
| 66 | st | |
| 168 | 67 | { |
| 169 | akiko.c2p_input_buffer[akiko.c2p_input_index] = data; | |
| 170 | akiko.c2p_input_index++; | |
| 171 | akiko.c2p_input_index &= 7; | |
| 172 | akiko.c2p_output_index = 0; | |
| 68 | if ((mem_mask & 0xffff0000) != 0xffff0000) | |
| 69 | amiga_cia_w( offset * 2 + 0, data >> 16, mem_mask >> 16); | |
| 70 | if ((mem_mask & 0x0000ffff) != 0x0000ffff) | |
| 71 | amiga_cia_w( offset * 2 + 1, data, mem_mask); | |
| 173 | 72 | } |
| 174 | 73 | |
| 175 | ||
| 74 | static READ32_HANDLER( amiga_custom32 | |
| 176 | 75 | { |
| 177 | UINT32 val; | |
| 178 | ||
| 179 | if ( akiko.c2p_output_index == 0 ) | |
| 180 | { | |
| 181 | int i; | |
| 182 | ||
| 183 | for ( i = 0; i < 8; i++ ) | |
| 184 | akiko.c2p_output_buffer[i] = 0; | |
| 185 | ||
| 186 | for (i = 0; i < 8 * 32; i++) { | |
| 187 | if (akiko.c2p_input_buffer[7 - (i >> 5)] & (1 << (i & 31))) | |
| 188 | akiko.c2p_output_buffer[i & 7] |= 1 << (i >> 3); | |
| 189 | } | |
| 190 | } | |
| 191 | akiko.c2p_input_index = 0; | |
| 192 | val = akiko.c2p_output_buffer[akiko.c2p_output_index]; | |
| 193 | akiko.c2p_output_index++; | |
| 194 | akiko.c2p_output_index &= 7; | |
| 195 | return val; | |
| 76 | UINT32 result = 0; | |
| 77 | if ((mem_mask & 0xffff0000) != 0xffff0000) | |
| 78 | result |= amiga_custom_r(offset * 2 + 0, mem_mask >> 16) << 16; | |
| 79 | if ((mem_mask & 0x0000ffff) != 0x0000ffff) | |
| 80 | result |= amiga_custom_r(offset * 2 + 1, mem_mask) << 0; | |
| 81 | return result; | |
| 196 | 82 | } |
| 197 | 83 | |
| 198 | static | |
| 84 | static WRITE32_HANDLER( amiga_ | |
| 199 | 85 | { |
| 200 | akiko.i2c_sda_in = 1; | |
| 201 | ||
| 202 | if ( !akiko.i2c_sda_dir_nvram && akiko.i2c_scl_out && akiko.i2c_oscl ) | |
| 203 | { | |
| 204 | if ( !akiko.i2c_sda_out && akiko.i2c_osda ) /* START-condition? */ | |
| 205 | { | |
| 206 | akiko.i2c_state = I2C_DEVICEADDR; | |
| 207 | akiko.i2c_bitcounter = 0; | |
| 208 | akiko.i2c_direction = -1; | |
| 209 | #if LOG_AKIKO_I2C | |
| 210 | logerror("START\n"); | |
| 211 | #endif | |
| 212 | return; | |
| 213 | } | |
| 214 | else if ( akiko.i2c_sda_out && !akiko.i2c_osda ) /* STOP-condition? */ | |
| 215 | { | |
| 216 | akiko.i2c_state = I2C_WAIT; | |
| 217 | akiko.i2c_bitcounter = -1; | |
| 218 | #if LOG_AKIKO_I2C | |
| 219 | logerror("STOP\n"); | |
| 220 | #endif | |
| 221 | if ( akiko.i2c_direction > 0 ) | |
| 222 | { | |
| 223 | memcpy( akiko.nvram + ( akiko.nvram_address & ~(NVRAM_PAGE_SIZE - 1) ), akiko.nvram_writetmp, NVRAM_PAGE_SIZE ); | |
| 224 | akiko.i2c_direction = -1; | |
| 225 | #if LOG_AKIKO_I2C | |
| 226 | { | |
| 227 | int i; | |
| 228 | ||
| 229 | logerror("NVRAM write address %04X:", akiko.nvram_address & ~(NVRAM_PAGE_SIZE - 1)); | |
| 230 | for (i = 0; i < NVRAM_PAGE_SIZE; i++) | |
| 231 | logerror("%02X", akiko.nvram_writetmp[i]); | |
| 232 | logerror("\n"); | |
| 233 | } | |
| 234 | #endif | |
| 235 | } | |
| 236 | return; | |
| 237 | } | |
| 238 | } | |
| 239 | ||
| 240 | if ( akiko.i2c_bitcounter >= 0 ) | |
| 241 | { | |
| 242 | if ( akiko.i2c_direction ) | |
| 243 | { | |
| 244 | /* Amiga -> NVRAM */ | |
| 245 | if ( akiko.i2c_scl_out && !akiko.i2c_oscl ) | |
| 246 | { | |
| 247 | if ( akiko.i2c_bitcounter == 8 ) | |
| 248 | { | |
| 249 | akiko.i2c_sda_in = 0; /* ACK */ | |
| 250 | ||
| 251 | if ( akiko.i2c_direction > 0 ) | |
| 252 | { | |
| 253 | akiko.nvram_writetmp[akiko.nvram_writeaddr++] = akiko.nvram_byte; | |
| 254 | akiko.nvram_writeaddr &= (NVRAM_PAGE_SIZE - 1); | |
| 255 | akiko.i2c_bitcounter = 0; | |
| 256 | } | |
| 257 | else | |
| 258 | { | |
| 259 | akiko.i2c_bitcounter = -1; | |
| 260 | } | |
| 261 | } | |
| 262 | else | |
| 263 | { | |
| 264 | akiko.nvram_byte <<= 1; | |
| 265 | akiko.nvram_byte |= akiko.i2c_sda_out; | |
| 266 | akiko.i2c_bitcounter++; | |
| 267 | } | |
| 268 | } | |
| 269 | } | |
| 270 | else | |
| 271 | { | |
| 272 | /* NVRAM -> Amiga */ | |
| 273 | if ( akiko.i2c_scl_out && !akiko.i2c_oscl && akiko.i2c_bitcounter < 8 ) | |
| 274 | { | |
| 275 | if ( akiko.i2c_bitcounter == 0 ) | |
| 276 | akiko.nvram_byte = akiko.nvram[akiko.nvram_address]; | |
| 277 | ||
| 278 | akiko.i2c_sda_dir_nvram = 1; | |
| 279 | akiko.i2c_sda_in = (akiko.nvram_byte & 0x80) ? 1 : 0; | |
| 280 | akiko.nvram_byte <<= 1; | |
| 281 | akiko.i2c_bitcounter++; | |
| 282 | ||
| 283 | if ( akiko.i2c_bitcounter == 8 ) | |
| 284 | { | |
| 285 | #if LOG_AKIKO_I2C | |
| 286 | logerror("NVRAM sent byte %02X address %04X\n", akiko.nvram[akiko.nvram_address], akiko.nvram_address); | |
| 287 | #endif | |
| 288 | akiko.nvram_address++; | |
| 289 | akiko.nvram_address &= NVRAM_SIZE - 1; | |
| 290 | akiko.i2c_sda_dir_nvram = 0; | |
| 291 | } | |
| 292 | } | |
| 293 | ||
| 294 | if ( !akiko.i2c_sda_out && akiko.i2c_sda_dir && !akiko.i2c_scl_out ) /* ACK from Amiga */ | |
| 295 | akiko.i2c_bitcounter = 0; | |
| 296 | } | |
| 297 | ||
| 298 | if ( akiko.i2c_bitcounter >= 0 ) | |
| 299 | return; | |
| 300 | } | |
| 301 | ||
| 302 | switch( akiko.i2c_state ) | |
| 303 | { | |
| 304 | case I2C_DEVICEADDR: | |
| 305 | if ( ( akiko.nvram_byte & 0xf0 ) != 0xa0 ) | |
| 306 | { | |
| 307 | #if LOG_AKIKO_I2C | |
| 308 | logerror("WARNING: I2C_DEVICEADDR: device address != 0xA0\n"); | |
| 309 | #endif | |
| 310 | akiko.i2c_state = I2C_WAIT; | |
| 311 | return; | |
| 312 | } | |
| 313 | ||
| 314 | akiko.nvram_rw = (akiko.nvram_byte & 1) ? 0 : 1; | |
| 315 | ||
| 316 | if ( akiko.nvram_rw ) | |
| 317 | { | |
| 318 | /* 2 high address bits, only fetched if WRITE = 1 */ | |
| 319 | akiko.nvram_address &= 0xff; | |
| 320 | akiko.nvram_address |= ((akiko.nvram_byte >> 1) & 3) << 8; | |
| 321 | akiko.i2c_state = I2C_WORDADDR; | |
| 322 | akiko.i2c_direction = -1; | |
| 323 | } | |
| 324 | else | |
| 325 | { | |
| 326 | akiko.i2c_state = I2C_DATA; | |
| 327 | akiko.i2c_direction = 0; | |
| 328 | akiko.i2c_sda_dir_nvram = 1; | |
| 329 | } | |
| 330 | ||
| 331 | akiko.i2c_bitcounter = 0; | |
| 332 | #if LOG_AKIKO_I2C | |
| 333 | logerror("I2C_DEVICEADDR: rw %d, address %02Xxx\n", akiko.nvram_rw, akiko.nvram_address >> 8); | |
| 334 | #endif | |
| 335 | break; | |
| 336 | ||
| 337 | case I2C_WORDADDR: | |
| 338 | akiko.nvram_address &= 0x300; | |
| 339 | akiko.nvram_address |= akiko.nvram_byte; | |
| 340 | ||
| 341 | #if LOG_AKIKO_I2C | |
| 342 | logerror("I2C_WORDADDR: address %04X\n", akiko.nvram_address); | |
| 343 | #endif | |
| 344 | if ( akiko.i2c_direction < 0 ) | |
| 345 | { | |
| 346 | memcpy( akiko.nvram_writetmp, akiko.nvram + (akiko.nvram_address & ~(NVRAM_PAGE_SIZE - 1)), NVRAM_PAGE_SIZE); | |
| 347 | akiko.nvram_writeaddr = akiko.nvram_address & (NVRAM_PAGE_SIZE - 1); | |
| 348 | } | |
| 349 | ||
| 350 | akiko.i2c_state = I2C_DATA; | |
| 351 | akiko.i2c_bitcounter = 0; | |
| 352 | akiko.i2c_direction = 1; | |
| 353 | break; | |
| 354 | } | |
| 86 | if ((mem_mask & 0xffff0000) != 0xffff0000) | |
| 87 | amiga_custom_w( offset * 2 + 0, data >> 16, mem_mask >> 16); | |
| 88 | if ((mem_mask & 0x0000ffff) != 0x0000ffff) | |
| 89 | amiga_custom_w( offset * 2 + 1, data, mem_mask); | |
| 355 | 90 | } |
| 356 | 91 | |
| 357 | ||
| 92 | static WRITE32_HANDLER( aga | |
| 358 | 93 | { |
| 359 | int sda; | |
| 360 | ||
| 361 | akiko.i2c_oscl = akiko.i2c_scl_out; | |
| 362 | akiko.i2c_scl_out = BIT(data,31); | |
| 363 | akiko.i2c_osda = akiko.i2c_sda_out; | |
| 364 | akiko.i2c_sda_out = BIT(data,30); | |
| 365 | akiko.i2c_scl_dir = BIT(data,15); | |
| 366 | akiko.i2c_sda_dir = BIT(data,14); | |
| 367 | ||
| 368 | sda = akiko.i2c_sda_out; | |
| 369 | if ( akiko.i2c_oscl != akiko.i2c_scl_out || akiko.i2c_osda != sda ) | |
| 370 | { | |
| 371 | akiko_i2c(); | |
| 372 | akiko.i2c_oscl = akiko.i2c_scl_out; | |
| 373 | akiko.i2c_osda = sda; | |
| 374 | } | |
| 375 | } | |
| 376 | ||
| 377 | UINT32 akiko_nvram_read(void) | |
| 378 | { | |
| 379 | UINT32 v = 0; | |
| 380 | ||
| 381 | if ( !akiko.i2c_scl_dir ) | |
| 382 | v |= akiko.i2c_scl_in ? (1<<31) : 0x00; | |
| 383 | else | |
| 384 | v |= akiko.i2c_scl_out ? (1<<31) : 0x00; | |
| 385 | ||
| 386 | if ( !akiko.i2c_sda_dir ) | |
| 387 | v |= akiko.i2c_sda_in ? (1<<30) : 0x00; | |
| 388 | else | |
| 389 | v |= akiko.i2c_sda_out ? (1<<30) : 0x00; | |
| 390 | ||
| 391 | v |= akiko.i2c_scl_dir ? (1<<15) : 0x00; | |
| 392 | v |= akiko.i2c_sda_dir ? (1<<14) : 0x00; | |
| 393 | ||
| 394 | return v; | |
| 395 | } | |
| 396 | ||
| 397 | static const char* akiko_reg_names[] = | |
| 398 | { | |
| 399 | /*0*/ "ID", | |
| 400 | /*1*/ "CDROM STATUS 1", | |
| 401 | /*2*/ "CDROM_STATUS 2", | |
| 402 | /*3*/ "???", | |
| 403 | /*4*/ "CDROM ADDRESS 1", | |
| 404 | /*5*/ "CDROM ADDRESS 2", | |
| 405 | /*6*/ "CDROM COMMAND 1", | |
| 406 | /*7*/ "CDROM COMMAND 2", | |
| 407 | /*8*/ "CDROM READMASK", | |
| 408 | /*9*/ "CDROM LONGMASK", | |
| 409 | /*A*/ "???", | |
| 410 | /*B*/ "???", | |
| 411 | /*C*/ "NVRAM", | |
| 412 | /*D*/ "???", | |
| 413 | /*E*/ "C2P" | |
| 414 | }; | |
| 415 | ||
| 416 | const char* get_akiko_reg_name(int reg) | |
| 417 | { | |
| 418 | if (reg < 0xf ) | |
| 94 | if ((mem_mask & 0x00ff0000) != 0x00ff0000) | |
| 419 | 95 | { |
| 420 | return akiko_reg_names[reg]; | |
| 421 | } | |
| 422 | else | |
| 423 | { | |
| 424 | return "???"; | |
| 425 | } | |
| 426 | } | |
| 96 | data = (data >> 16) & 1; | |
| 427 | 97 | |
| 428 | static void akiko_setup_response( int len, int r0, UINT8 *r1 ) | |
| 429 | { | |
| 430 | int resp_addr = akiko.cdrom_address[1]; | |
| 431 | UINT8 resp_csum = 0xff; | |
| 432 | UINT8 resp_buffer[32]; | |
| 433 | int i; | |
| 98 | /* switch banks as appropriate */ | |
| 99 | memory_set_bank(1, data & 1); | |
| 434 | 100 | |
| 435 | memset( resp_buffer, 0, sizeof( resp_buffer ) ); | |
| 436 | ||
| 437 | resp_buffer[0] = r0; | |
| 438 | ||
| 439 | for( i = 0; i < len; i++ ) | |
| 440 | { | |
| 441 | resp_buffer[i+1] = r1[i]; | |
| 442 | resp_csum -= resp_buffer[i]; | |
| 443 | } | |
| 444 | ||
| 445 | resp_buffer[len] = resp_csum; | |
| 446 | len++; | |
| 447 | ||
| 448 | for( i = 0; i < len; i++ ) | |
| 449 | { | |
| 450 | program_write_byte( resp_addr + ((akiko.cdrom_cmd_resp + i) & 0xff), resp_buffer[i] ); | |
| 451 | } | |
| 452 | ||
| 453 | akiko.cdrom_cmd_resp = (akiko.cdrom_cmd_resp+len) & 0xff; | |
| 454 | ||
| 455 | akiko.cdrom_status[0] |= 0x10000000; /* new data available */ | |
| 456 | } | |
| 457 | ||
| 458 | static TIMER_CALLBACK( akiko_cd_delayed_cmd ) | |
| 459 | { | |
| 460 | UINT8 resp[32]; | |
| 461 | ||
| 462 | memset( resp, 0, sizeof( resp ) ); | |
| 463 | ||
| 464 | if ( param == 0x05 ) | |
| 465 | { | |
| 466 | logerror( "AKIKO: Completing Command %d\n", param ); | |
| 467 | ||
| 468 | if ( akiko.cdrom == NULL || cdrom_get_last_track(akiko.cdrom) == 0 ) | |
| 469 | { | |
| 470 | resp[0] = 0x80; | |
| 471 | akiko_setup_response( 2, param, resp ); | |
| 472 | } | |
| 101 | /* swap the write handlers between ROM and bank 1 based on the bit */ | |
| 102 | if ((data & 1) == 0) | |
| 103 | /* overlay disabled, map RAM on 0x000000 */ | |
| 104 | memory_install_write32_handler(0, ADDRESS_SPACE_PROGRAM, 0x000000, 0x1fffff, 0, 0, MWA32_BANK1); | |
| 473 | 105 | else |
| 474 | { | |
| 475 | int addrctrl = cdrom_get_adr_control( akiko.cdrom, 0 ); | |
| 476 | UINT32 trackstart = lba_to_msf(cdrom_get_track_start( akiko.cdrom, 0 )); | |
| 477 | ||
| 478 | resp[0] = 0x00; | |
| 479 | resp[1] = ((addrctrl & 0x0f) << 4) | ((addrctrl & 0xf0) >> 4); | |
| 480 | /* 2-3: track number in BCD format */ | |
| 481 | /* 4-7: ??? */ | |
| 482 | resp[8] = (trackstart >> 16) & 0xff; | |
| 483 | resp[9] = (trackstart >> 8) & 0xff; | |
| 484 | resp[10] = trackstart & 0xff; | |
| 485 | ||
| 486 | akiko_setup_response( 15, param, resp ); | |
| 487 | } | |
| 106 | /* overlay enabled, map Amiga system ROM on 0x000000 */ | |
| 107 | memory_install_write32_handler(0, ADDRESS_SPACE_PROGRAM, 0x000000, 0x1fffff, 0, 0, MWA32_ROM); | |
| 488 | 108 | } |
| 489 | 109 | } |
| 490 | 110 | |
| 491 | static void akiko_update_cdrom( void ) | |
| 492 | { | |
| 493 | UINT8 resp[32]; | |
| 494 | ||
| 495 | if ( akiko.cdrom_status[0] & 0x10000000 ) | |
| 496 | return; | |
| 497 | ||
| 498 | while ( akiko.cdrom_cmd_start < akiko.cdrom_cmd_end ) | |
| 499 | { | |
| 500 | int cmd_addr = akiko.cdrom_address[1] + 0x200 + akiko.cdrom_cmd_start; | |
| 501 | int cmd = program_read_byte( cmd_addr ); | |
| 502 | ||
| 503 | cmd &= 0x0f; | |
| 504 | ||
| 505 | logerror( "CDROM command: %02X\n", cmd ); | |
| 506 | ||
| 507 | memset( resp, 0, sizeof( resp ) ); | |
| 508 | ||
| 509 | if ( cmd == 0x05 ) /* read toc */ | |
| 510 | { | |
| 511 | akiko.cdrom_cmd_start = (akiko.cdrom_cmd_start+3) & 0xff; | |
| 512 | ||
| 513 | mame_timer_set( MAME_TIME_IN_MSEC(500), cmd, akiko_cd_delayed_cmd ); | |
| 514 | ||
| 515 | break; | |
| 516 | } | |
| 517 | else if ( cmd == 0x07 ) /* check door status */ | |
| 518 | { | |
| 519 | resp[0] = 0x01; | |
| 520 | ||
| 521 | akiko.cdrom_cmd_start = (akiko.cdrom_cmd_start+2) & 0xff; | |
| 522 | ||
| 523 | if ( akiko.cdrom == NULL || cdrom_get_last_track(akiko.cdrom) == 0 ) | |
| 524 | resp[0] = 0x80; | |
| 525 | ||
| 526 | akiko_setup_response( 20, cmd, resp ); | |
| 527 | break; | |
| 528 | } | |
| 529 | else | |
| 530 | { | |
| 531 | break; | |
| 532 | } | |
| 533 | } | |
| 534 | } | |
| 535 | ||
| 536 | READ32_HANDLER(amiga_akiko32_r) | |
| 537 | { | |
| 538 | UINT32 retval; | |
| 539 | if ( offset < (0x30/4) ) | |
| 540 | { | |
| 541 | if ( LOG_AKIKO ) logerror( "Reading AKIKO reg %0x [%s] at PC=%06x\n", offset, get_akiko_reg_name(offset), activecpu_get_pc() ); | |
| 542 | } | |
| 543 | ||
| 544 | switch( offset ) | |
| 545 | { | |
| 546 | case 0x00/4: /* ID */ | |
| 547 | init_akiko(); | |
| 548 | return 0x0000cafe; | |
| 549 | ||
| 550 | case 0x04/4: /* CDROM STATUS 1 */ | |
| 551 | return akiko.cdrom_status[0]; | |
| 552 | ||
| 553 | case 0x08/4: /* CDROM STATUS 2 */ | |
| 554 | return akiko.cdrom_status[1]; | |
| 555 | ||
| 556 | case 0x10/4: /* CDROM ADDRESS 1 */ | |
| 557 | return akiko.cdrom_address[0]; | |
| 558 | ||
| 559 | case 0x14/4: /* CDROM ADDRESS 2 */ | |
| 560 | return akiko.cdrom_address[1]; | |
| 561 | ||
| 562 | case 0x18/4: /* CDROM COMMAND 1 */ | |
| 563 | akiko_update_cdrom(); | |
| 564 | retval = akiko.cdrom_cmd_start; | |
| 565 | retval <<= 8; | |
| 566 | retval |= akiko.cdrom_cmd_resp; | |
| 567 | retval <<= 8; | |
| 568 | return retval; | |
| 569 | ||
| 570 | case 0x1C/4: /* CDROM COMMAND 2 */ | |
| 571 | akiko_update_cdrom(); | |
| 572 | retval = akiko.cdrom_cmd_end; | |
| 573 | retval <<= 16; | |
| 574 | return retval; | |
| 575 | ||
| 576 | case 0x30/4: /* NVRAM */ | |
| 577 | return akiko_nvram_read(); | |
| 578 | ||
| 579 | case 0x38/4: /* C2P */ | |
| 580 | return akiko_c2p_read(); | |
| 581 | ||
| 582 | default: | |
| 583 | break; | |
| 584 | } | |
| 585 | ||
| 586 | return 0; | |
| 587 | } | |
| 588 | ||
| 589 | WRITE32_HANDLER(amiga_akiko32_w) | |
| 590 | { | |
| 591 | if ( offset < (0x30/4) ) | |
| 592 | { | |
| 593 | if ( LOG_AKIKO ) logerror( "Writing AKIKO reg %0x [%s] with %08x at PC=%06x\n", offset, get_akiko_reg_name(offset), data, activecpu_get_pc() ); | |
| 594 | } | |
| 595 | ||
| 596 | switch( offset ) | |
| 597 | { | |
| 598 | case 0x04/4: /* CDROM STATUS 1 */ | |
| 599 | akiko.cdrom_status[0] = data; | |
| 600 | break; | |
| 601 | ||
| 602 | case 0x08/4: /* CDROM STATUS 2 */ | |
| 603 | akiko.cdrom_status[1] = data; | |
| 604 | akiko.cdrom_status[0] &= data; | |
| 605 | break; | |
| 606 | ||
| 607 | case 0x10/4: /* CDROM ADDRESS 1 */ | |
| 608 | akiko.cdrom_address[0] = data; | |
| 609 | break; | |
| 610 | ||
| 611 | case 0x14/4: /* CDROM ADDRESS 2 */ | |
| 612 | akiko.cdrom_address[1] = data; | |
| 613 | break; | |
| 614 | ||
| 615 | case 0x18/4: /* CDROM COMMAND 1 */ | |
| 616 | if ( ( mem_mask & 0x00ff0000 ) == 0 ) | |
| 617 | akiko.cdrom_cmd_start = ( data >> 16 ) & 0xff; | |
| 618 | ||
| 619 | if ( ( mem_mask & 0x0000ff00 ) == 0 ) | |
| 620 | akiko.cdrom_cmd_resp = ( data >> 8 ) & 0xff; | |
| 621 | ||
| 622 | akiko_update_cdrom(); | |
| 623 | break; | |
| 624 | ||
| 625 | case 0x1C/4: /* CDROM COMMAND 2 */ | |
| 626 | if ( ( mem_mask & 0x00ff0000 ) == 0 ) | |
| 627 | akiko.cdrom_cmd_end = ( data >> 16 ) & 0xff; | |
| 628 | ||
| 629 | akiko_update_cdrom(); | |
| 630 | break; | |
| 631 | ||
| 632 | case 0x30/4: | |
| 633 | akiko_nvram_write(data); | |
| 634 | break; | |
| 635 | ||
| 636 | case 0x38/4: | |
| 637 | akiko_c2p_write(data); | |
| 638 | break; | |
| 639 | ||
| 640 | default: | |
| 641 | break; | |
| 642 | } | |
| 643 | } | |
| 644 | ||
| 645 | static READ32_HANDLER(amiga_cia32_r) | |
| 646 | { | |
| 647 | UINT32 retval = 0; | |
| 648 | ||
| 649 | #if 0 | |
| 650 | if ( (mem_mask & 0xffff) != 0xffff) | |
| 651 | retval |= (amiga_cia_r(offset*2, mem_mask & 0xffff) ); | |
| 652 | ||
| 653 | if ( ((mem_mask >> 16) & 0xffff) != 0xffff) | |
| 654 | retval |= (amiga_cia_r(offset*2 + 1, mem_mask >> 16) << 16); | |
| 655 | #else | |
| 656 | if ( ((mem_mask >> 16) & 0xffff) != 0xffff) | |
| 657 | { | |
| 658 | retval |= amiga_cia_r(offset*2, (mem_mask >> 16) & 0xffff); | |
| 659 | retval <<= 16; | |
| 660 | } | |
| 661 | ||
| 662 | if ( (mem_mask & 0xffff) != 0xffff ) | |
| 663 | retval |= amiga_cia_r(offset*2 + 1, mem_mask & 0xffff); | |
| 664 | ||
| 665 | return retval; | |
| 666 | #endif | |
| 667 | ||
| 668 | return retval; | |
| 669 | } | |
| 670 | ||
| 671 | static WRITE32_HANDLER(amiga_cia32_w) | |
| 672 | { | |
| 673 | // amiga_cia_w(offset*2, data >> 16, mem_mask >> 16 ); | |
| 674 | if ( ((mem_mask >> 16) & 0xffff) != 0xffff) | |
| 675 | amiga_cia_w(offset*2, data >> 16, mem_mask >> 16 ); | |
| 676 | ||
| 677 | if ( (mem_mask & 0xffff) != 0xffff ) | |
| 678 | amiga_cia_w(offset*2 + 1, data & 0xffff, mem_mask & 0xffff ); | |
| 679 | } | |
| 680 | ||
| 681 | static READ32_HANDLER(amiga_custom32_r) | |
| 682 | { | |
| 683 | UINT32 retval = 0; | |
| 684 | ||
| 685 | if ( ((mem_mask >> 16) & 0xffff) != 0xffff) | |
| 686 | { | |
| 687 | retval |= amiga_custom_r(offset*2, (mem_mask >> 16) & 0xffff); | |
| 688 | retval <<= 16; | |
| 689 | } | |
| 690 | ||
| 691 | if ( (mem_mask & 0xffff) != 0xffff ) | |
| 692 | retval |= amiga_custom_r(offset*2 + 1, mem_mask & 0xffff); | |
| 693 | ||
| 694 | return retval; | |
| 695 | } | |
| 696 | ||
| 697 | static WRITE32_HANDLER(amiga_custom32_w) | |
| 698 | { | |
| 699 | if ( ((mem_mask >> 16) & 0xffff) != 0xffff) | |
| 700 | amiga_custom_w(offset*2, data >> 16, mem_mask >> 16 ); | |
| 701 | ||
| 702 | if ( (mem_mask & 0xffff) != 0xffff ) | |
| 703 | amiga_custom_w(offset*2 + 1, data & 0xffff, mem_mask & 0xffff ); | |
| 704 | } | |
| 705 | ||
| 706 | 111 | /************************************* |
| 707 | 112 | * |
| 708 | 113 | * CIA-A port A access: |
| r936 | r937 | |
| 714 | 119 | * PA3 = /WPRO (disk write protect) |
| 715 | 120 | * PA2 = /CHNG (disk change) |
| 716 | 121 | * PA1 = /LED (LED, 0=bright / audio filter control) |
| 717 | * PA0 = | |
| 122 | * PA0 = | |
| 718 | 123 | * |
| 719 | 124 | *************************************/ |
| 720 | 125 | |
| r936 | r937 | |
| 725 | 130 | |
| 726 | 131 | static void cd32_cia_0_porta_w(UINT8 data) |
| 727 | 132 | { |
| 728 | /* switch banks as appropriate */ | |
| 729 | memory_set_bank(1, data & 1); | |
| 133 | /* bit 1 = cd audio mute */ | |
| 134 | sndti_set_output_gain(SOUND_CDDA, 0, 0, ( data & 1 ) ? 0.0 : 1.0 ); | |
| 730 | 135 | |
| 731 | /* swap the write handlers between ROM and bank 1 based on the bit */ | |
| 732 | if ((data & 1) == 0) | |
| 733 | /* overlay disabled, map RAM on 0x000000 */ | |
| 734 | memory_install_write32_handler(0, ADDRESS_SPACE_PROGRAM, 0x000000, 0x1fffff, 0, 0, MWA32_BANK1); | |
| 735 | ||
| 736 | else | |
| 737 | /* overlay enabled, map Amiga system ROM on 0x000000 */ | |
| 738 | memory_install_write32_handler(0, ADDRESS_SPACE_PROGRAM, 0x000000, 0x1fffff, 0, 0, MWA32_ROM); | |
| 739 | ||
| 740 | 136 | /* bit 2 = Power Led on Amiga */ |
| 741 | 137 | set_led_status(0, (data & 2) ? 0 : 1); |
| 742 | 138 | } |
| r936 | r937 | |
| 769 | 165 | logerror("%06x:CIA0_portb_w(%02x)\n", activecpu_get_pc(), data); |
| 770 | 166 | } |
| 771 | 167 | |
| 772 | static | |
| 168 | static | |
| 773 | 169 | { |
| 774 | if (read_or_write) | |
| 775 | /* save the SRAM settings */ | |
| 776 | mame_fwrite(file, akiko.nvram, NVRAM_SIZE); | |
| 777 | else | |
| 778 | { | |
| 779 | /* load the SRAM settings */ | |
| 780 | if (file) | |
| 781 | mame_fread(file, akiko.nvram, NVRAM_SIZE); | |
| 782 | else | |
| 783 | memset(akiko.nvram, 0, NVRAM_SIZE); | |
| 784 | } | |
| 170 | return readinputportbytag("DIPSW1"); | |
| 785 | 171 | } |
| 786 | 172 | |
| 787 | 173 | static ADDRESS_MAP_START( cd32_map, ADDRESS_SPACE_PROGRAM, 32 ) |
| 788 | 174 | ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) ) |
| 789 | 175 | AM_RANGE(0x000000, 0x1fffff) AM_RAMBANK(1) AM_BASE(&amiga_chip_ram32) AM_SIZE(&amiga_chip_ram_size) |
| 176 | AM_RANGE(0x800000, 0x800003) AM_READ( dipswitch_r ); | |
| 790 | 177 | AM_RANGE(0xb80000, 0xb8003f) AM_READWRITE(amiga_akiko32_r, amiga_akiko32_w) |
| 178 | AM_RANGE(0xbfa000, 0xbfa003) AM_WRITE(aga_overlay_w); | |
| 791 | 179 | AM_RANGE(0xbfd000, 0xbfefff) AM_READWRITE(amiga_cia32_r, amiga_cia32_w) |
| 792 | 180 | AM_RANGE(0xc00000, 0xdfffff) AM_READWRITE(amiga_custom32_r, amiga_custom32_w) AM_BASE((UINT32**)&amiga_custom_regs) |
| 793 | 181 | AM_RANGE(0xe00000, 0xe7ffff) AM_ROM AM_REGION(REGION_USER1, 0x80000) /* CD32 Extended ROM */ |
| r936 | r937 | |
| 804 | 192 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL |
| 805 | 193 | |
| 806 | 194 | PORT_START_TAG("CIA0PORTB") |
| 807 | PORT_DIPNAME( 0x01, 0x01, "DSW1 1" ) | |
| 808 | PORT_DIPSETTING( 0x01, "Reset" ) | |
| 809 | PORT_DIPSETTING( 0x00, "Set" ) | |
| 810 | PORT_SERVICE_NO_TOGGLE( 0x02, IP_ACTIVE_LOW ) | |
| 811 | 195 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 ) |
| 812 | 196 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 ) |
| 813 | 197 | |
| r936 | r937 | |
| 841 | 225 | PORT_START_TAG("COINS") |
| 842 | 226 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) |
| 843 | 227 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) |
| 228 | ||
| 229 | PORT_START_TAG("DIPSW1") | |
| 230 | PORT_DIPNAME( 0x01, 0x01, "DSW1 1" ) | |
| 231 | PORT_DIPSETTING( 0x01, "Reset" ) | |
| 232 | PORT_DIPSETTING( 0x00, "Set" ) | |
| 233 | PORT_DIPNAME( 0x02, 0x02, "DSW1 2" ) | |
| 234 | PORT_DIPSETTING( 0x02, "Reset" ) | |
| 235 | PORT_DIPSETTING( 0x00, "Set" ) | |
| 236 | PORT_DIPNAME( 0x04, 0x04, "DSW1 3" ) | |
| 237 | PORT_DIPSETTING( 0x04, "Reset" ) | |
| 238 | PORT_DIPSETTING( 0x00, "Set" ) | |
| 239 | PORT_DIPNAME( 0x08, 0x08, "DSW1 4" ) | |
| 240 | PORT_DIPSETTING( 0x08, "Reset" ) | |
| 241 | PORT_DIPSETTING( 0x00, "Set" ) | |
| 242 | PORT_DIPNAME( 0x10, 0x10, "DSW1 5" ) | |
| 243 | PORT_DIPSETTING( 0x10, "Reset" ) | |
| 244 | PORT_DIPSETTING( 0x00, "Set" ) | |
| 245 | PORT_DIPNAME( 0x20, 0x20, "DSW1 6" ) | |
| 246 | PORT_DIPSETTING( 0x20, "Reset" ) | |
| 247 | PORT_DIPSETTING( 0x00, "Set" ) | |
| 248 | PORT_SERVICE( 0x40, IP_ACTIVE_HIGH ) | |
| 249 | PORT_DIPNAME( 0x80, 0x80, "DSW1 8" ) | |
| 250 | PORT_DIPSETTING( 0x80, "Reset" ) | |
| 251 | PORT_DIPSETTING( 0x00, "Set" ) | |
| 844 | 252 | INPUT_PORTS_END |
| 845 | 253 | |
| 846 | 254 | /************************************* |
| r936 | r937 | |
| 858 | 266 | static MACHINE_DRIVER_START( cd32 ) |
| 859 | 267 | |
| 860 | 268 | /* basic machine hardware */ |
| 861 | MDRV_CPU_ADD(M68EC020, AMIGA_68EC020_ | |
| 269 | MDRV_CPU_ADD(M68EC020, AMIGA_68EC020_PAL | |
| 862 | 270 | MDRV_CPU_PROGRAM_MAP(cd32_map,0) |
| 863 | MDRV_CPU_VBLANK_INT(amiga_scanline_callback, | |
| 271 | MDRV_CPU_VBLANK_INT(amiga_scanline_callback, 312) | |
| 864 | 272 | |
| 865 | 273 | MDRV_SCREEN_REFRESH_RATE(59.997) |
| 866 | 274 | MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0)) |
| r936 | r937 | |
| 871 | 279 | /* video hardware */ |
| 872 | 280 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_BEFORE_VBLANK) |
| 873 | 281 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 874 | MDRV_SCREEN_SIZE(512*2, 262) | |
| 875 | MDRV_SCREEN_VISIBLE_AREA((129-8)*2, (449+8-1)*2, 44-8, 244+8-1) | |
| 282 | MDRV_SCREEN_SIZE(512*2, 312) | |
| 283 | MDRV_SCREEN_VISIBLE_AREA((129-8)*2, (449+8-1)*2, 44-8, 300+8-1) | |
| 876 | 284 | MDRV_PALETTE_LENGTH(4096) |
| 877 | 285 | MDRV_PALETTE_INIT(amiga) |
| 878 | 286 | |
| r936 | r937 | |
| 884 | 292 | |
| 885 | 293 | MDRV_SOUND_ADD(CUSTOM, 3579545) |
| 886 | 294 | MDRV_SOUND_CONFIG(amiga_custom_interface) |
| 887 | MDRV_SOUND_ROUTE(0, "left", 0.50) | |
| 888 | MDRV_SOUND_ROUTE(1, "right", 0.50) | |
| 889 | MDRV_SOUND_ROUTE(2, "right", 0.50) | |
| 890 | MDRV_SOUND_ROUTE(3, "left", 0.50) | |
| 295 | MDRV_SOUND_ROUTE(0, "left", 0.25) | |
| 296 | MDRV_SOUND_ROUTE(1, "right", 0.25) | |
| 297 | MDRV_SOUND_ROUTE(2, "right", 0.25) | |
| 298 | MDRV_SOUND_ROUTE(3, "left", 0.25) | |
| 299 | ||
| 300 | MDRV_SOUND_ADD( CDDA, 0 ) | |
| 301 | MDRV_SOUND_ROUTE( 0, "left", 0.50 ) | |
| 302 | MDRV_SOUND_ROUTE( 1, "right", 0.50 ) | |
| 891 | 303 | MACHINE_DRIVER_END |
| 892 | 304 | |
| 893 | 305 | |
| r936 | r937 | |
| 970 | 382 | /* set up memory */ |
| 971 | 383 | memory_configure_bank(1, 0, 1, amiga_chip_ram32, 0); |
| 972 | 384 | memory_configure_bank(1, 1, 1, memory_region(REGION_USER1), 0); |
| 385 | ||
| 386 | /* intialize akiko */ | |
| 387 | amiga_akiko_init(); | |
| 973 | 388 | } |
| 974 | 389 | |
| 975 | 390 | /***************************************************************************************************/ |
| r936 | r937 | |
|---|---|---|
| 341 | 341 | |
| 342 | 342 | res |= 0xd0; |
| 343 | 343 | |
| 344 | if (sndti_t | |
| 344 | if (sndti_exist | |
| 345 | 345 | res |= 0x20; |
| 346 | 346 | |
| 347 | 347 | return res; |
| r936 | r937 | |
|---|---|---|
| 7 | 7 | |
| 8 | 8 | Games Supported: |
| 9 | 9 | |
| 10 | Vamp 1/2 (c) 1999 Danbi & F2 System (Korea version) | |
| 11 | Mission Craft (c) 2000 Sun (version 2.4) | |
| 12 | Minigame Cool Collection (c) 1999 SemiCom | |
| 13 | Super Lup Lup Puzzle (c) 1999 Omega System (version 4.0) | |
| 14 | Lup Lup Puzzle (c) 1999 Omega System (version 3.0 and 2.9) | |
| 15 | Puzzle Bang Bang (c) 1999 Omega System (version 2.8) | |
| 16 | Wyvern Wings (c) 2001 SemiCom | |
| 17 | Final Godori (c) 2001 SemiCom (version 2.20.5915) | |
| 18 | 10 | |
| 11 | Minigame Cool Collection (c) 1999 SemiCom | |
| 12 | Lup Lup Puzzle (c) 1999 Omega System (version 3.0 and 2.9) | |
| 13 | Puzzle Bang Bang (c) 1999 Omega System (version 2.8) | |
| 14 | Super Lup Lup Puzzle (c) 1999 Omega System (version 4.0) | |
| 15 | Vamp 1/2 (c) 1999 Danbi & F2 System (Korea version) | |
| 16 | Date Quiz Go Go Episode 2 (c) 2000 SemiCom | |
| 17 | Mission Craft (c) 2000 Sun (version 2.4) | |
| 18 | Final Godori (c) 2001 SemiCom (version 2.20.5915) | |
| 19 | Wyvern Wings (c) 2001 SemiCom | |
| 20 | ||
| 19 | 21 | Games Needed: |
| 20 | 22 | |
| 21 | 23 | Vamp 1/2 (World version) |
| 22 | 24 | |
| 25 | Actual games bugs: | |
| 26 | - dquizgo2: bugged video test | |
| 27 | ||
| 23 | 28 | *********************************************************************/ |
| 24 | 29 | |
| 25 | 30 | #include "driver.h" |
| r936 | r937 | |
| 202 | 207 | return readinputport(1) << 16; |
| 203 | 208 | } |
| 204 | 209 | |
| 210 | static WRITE32_HANDLER( finalgdr_oki_bank_w ) | |
| 211 | { | |
| 212 | // is this right ? | |
| 213 | if(data) | |
| 214 | OKIM6295_set_bank_base(0, 0x40000 * (((data & 0x300) >> 8) - 1)); | |
| 215 | } | |
| 216 | ||
| 205 | 217 | static ADDRESS_MAP_START( common_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| 206 | 218 | AM_RANGE(0x00000000, 0x001fffff) AM_RAM AM_BASE(&wram) |
| 207 | 219 | AM_RANGE(0x40000000, 0x4003ffff) AM_RAM AM_BASE(&tiles) |
| r936 | r937 | |
| 269 | 281 | static ADDRESS_MAP_START( finalgdr_io, ADDRESS_SPACE_IO, 32 ) |
| 270 | 282 | AM_RANGE(0x2400, 0x2403) AM_READ(finalgdr_prot_r) |
| 271 | 283 | //AM_RANGE(0x2800, 0x2803) AM_WRITE() //? |
| 272 | AM_RANGE(0x2c00, 0x2dff) AM_RAM // | |
| 284 | AM_RANGE(0x2c00, 0x2dff) AM_RAM //AM_BASE(&generic_ | |
| 273 | 285 | AM_RANGE(0x3000, 0x3003) AM_WRITE(ym2151_register32_w) |
| 274 | 286 | AM_RANGE(0x3004, 0x3007) AM_READWRITE(ym2151_status32_r, ym2151_data32_w) |
| 275 | 287 | AM_RANGE(0x3800, 0x3803) AM_READ(finalgdr_input0_r) |
| 276 | 288 | AM_RANGE(0x3400, 0x3403) AM_READWRITE(oki32_r, oki32_w) |
| 277 | 289 | AM_RANGE(0x3c00, 0x3c03) AM_READ(finalgdr_input1_r) |
| 278 | 290 | AM_RANGE(0x4400, 0x4403) AM_READ(eeprom32_r) |
| 279 | //AM_RANGE(0x6000, 0x6003) AM_READ() //? | |
| 291 | //AM_RANGE(0x6000, 0x6003) AM_READ(eeprom32_r) //? | |
| 280 | 292 | AM_RANGE(0x6000, 0x6003) AM_WRITE(finalgdr_eeprom_w) |
| 281 | 293 | AM_RANGE(0x6040, 0x6043) AM_WRITE(finalgdr_prot_w) |
| 282 | 294 | //AM_RANGE(0x6080, 0x6083) AM_WRITE(flipscreen32_w) //? |
| 283 | 295 | //AM_RANGE(0x6060, 0x6063) AM_WRITE() //? |
| 284 | | |
| 296 | | |
| 285 | 297 | ADDRESS_MAP_END |
| 286 | 298 | |
| 287 | 299 | /* |
| r936 | r937 | |
| 1009 | 1021 | /* roml01 empty */ |
| 1010 | 1022 | /* romh01 empty */ |
| 1011 | 1023 | |
| 1012 | ROM_REGION( 0x080000, REGION_ | |
| 1024 | ROM_REGION( 0x080000, REGION_ | |
| 1013 | 1025 | ROM_LOAD( "u7", 0x000000, 0x080000, CRC(080f61f8) SHA1(df3764b1b07f9fc38685e3706b0f834f62088727) ) |
| 1026 | ||
| 1027 | /* $00000-$20000 stays the same in all sound banks, */ | |
| 1028 | /* the second half of the bank is what gets switched */ | |
| 1029 | ROM_REGION( 0xc0000, REGION_SOUND1, 0 ) /* Samples */ | |
| 1030 | ROM_COPY( REGION_USER2, 0x000000, 0x000000, 0x020000) | |
| 1031 | ROM_COPY( REGION_USER2, 0x020000, 0x020000, 0x020000) | |
| 1032 | ROM_COPY( REGION_USER2, 0x000000, 0x040000, 0x020000) | |
| 1033 | ROM_COPY( REGION_USER2, 0x040000, 0x060000, 0x020000) | |
| 1034 | ROM_COPY( REGION_USER2, 0x000000, 0x080000, 0x020000) | |
| 1035 | ROM_COPY( REGION_USER2, 0x060000, 0x0a0000, 0x020000) | |
| 1014 | 1036 | ROM_END |
| 1015 | 1037 | |
| 1038 | /* | |
| 1039 | ||
| 1040 | Date Quiz Go Go Episode 2 | |
| 1041 | SemiCom, 2000 | |
| 1042 | ||
| 1043 | F-E1-16-010 | |
| 1044 | ||
| 1045 | */ | |
| 1046 | ||
| 1047 | ROM_START( dquizgo2 ) | |
| 1048 | ROM_REGION16_BE( 0x100000, REGION_USER1, ROMREGION_ERASE00 ) /* Hyperstone CPU Code */ | |
| 1049 | ROM_LOAD( "rom1", 0x00000, 0x080000, CRC(81eef038) SHA1(9c925d1ef261ea85069925ccd1a5aeb939f55d5a) ) | |
| 1050 | ROM_LOAD( "rom2", 0x80000, 0x080000, CRC(e8789d8a) SHA1(1ee26c26cc7024c5df9d0da630b326021ece9f41) ) | |
| 1051 | ||
| 1052 | ROM_REGION( 0xc00000, REGION_GFX1, ROMREGION_DISPOSE ) /* 16x16x8 Sprites */ | |
| 1053 | ROM_LOAD32_WORD( "roml00", 0x000000, 0x200000, CRC(de811dd7) SHA1(bf31e165440ed2e3cdddd2174521b15afd8b2e69) ) | |
| 1054 | ROM_LOAD32_WORD( "romu00", 0x000002, 0x200000, CRC(2bdbfc6b) SHA1(8e755574e3c9692bd8f82c7351fe3623a31ec136) ) | |
| 1055 | ROM_LOAD32_WORD( "roml01", 0x400000, 0x200000, CRC(f574a2a3) SHA1(c6a8aca75bd3a4e4109db5095f3a3edb9b1e6657) ) | |
| 1056 | ROM_LOAD32_WORD( "romu01", 0x400002, 0x200000, CRC(d05cf02f) SHA1(624316d4ee42c6257bc64747e4260a0d3950f9cd) ) | |
| 1057 | ROM_LOAD32_WORD( "roml02", 0x800000, 0x200000, CRC(43ca2cff) SHA1(02ad7cce42d917dbefdba2e4e8886fc883b1dc60) ) | |
| 1058 | ROM_LOAD32_WORD( "romu02", 0x800002, 0x200000, CRC(b8218222) SHA1(1e1aa60e0de9c02b841896512a1163dda280c845) ) | |
| 1059 | /* roml03 empty */ | |
| 1060 | /* romu03 empty */ | |
| 1061 | ||
| 1062 | ROM_REGION( 0x40000, REGION_SOUND1, 0 ) /* Oki Samples */ | |
| 1063 | ROM_LOAD( "vrom1", 0x00000, 0x40000, CRC(24d5b55f) SHA1(cb4d3a22440831e37df0a7fe5433bea708d60f31) ) | |
| 1064 | ROM_END | |
| 1065 | ||
| 1016 | 1066 | static int irq_active(void) |
| 1017 | 1067 | { |
| 1018 | 1068 | UINT32 FCR = activecpu_get_reg(27); |
| r936 | r937 | |
| 1139 | 1189 | return wram32[0x005e874/4]; |
| 1140 | 1190 | } |
| 1141 | 1191 | |
| 1192 | static READ16_HANDLER( dquizgo2_speedup_r ) | |
| 1193 | { | |
| 1194 | if(activecpu_get_pc() == 0xaa622) | |
| 1195 | { | |
| 1196 | if(irq_active()) | |
| 1197 | cpu_spinuntil_int(); | |
| 1198 | else | |
| 1199 | activecpu_eat_cycles(50); | |
| 1200 | } | |
| 1142 | 1201 | |
| 1202 | return wram[(0xcde70/2)+offset]; | |
| 1203 | } | |
| 1204 | ||
| 1205 | ||
| 1143 | 1206 | DRIVER_INIT( vamphalf ) |
| 1144 | 1207 | { |
| 1145 | 1208 | memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x0004a6d0, 0x0004a6d3, 0, 0, vamphalf_speedup_r ); |
| r936 | r937 | |
| 1218 | 1281 | semicom_prot_data[1] = 3; |
| 1219 | 1282 | } |
| 1220 | 1283 | |
| 1284 | DRIVER_INIT( dquizgo2 ) | |
| 1285 | { | |
| 1286 | memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x00cde70, 0x00cde73, 0, 0, dquizgo2_speedup_r ); | |
| 1287 | ||
| 1288 | palshift = 0; | |
| 1289 | flip_bit = 1; | |
| 1290 | } | |
| 1291 | ||
| 1221 | 1292 | GAME( 1999, coolmini, 0, coolmini, common, coolmini, ROT0, "SemiCom", "Cool Minigame Collection", 0 ) |
| 1222 | 1293 | GAME( 1999, suplup, 0, suplup, common, suplup, ROT0, "Omega System", "Super Lup Lup Puzzle / Zhuan Zhuan Puzzle (version 4.0 / 990518)" , 0) |
| 1223 | 1294 | GAME( 1999, luplup, suplup, suplup, common, luplup, ROT0, "Omega System", "Lup Lup Puzzle / Zhuan Zhuan Puzzle (version 3.0 / 990128)", 0 ) |
| 1224 | 1295 | GAME( 1999, luplup29, suplup, suplup, common, luplup29, ROT0, "Omega System", "Lup Lup Puzzle / Zhuan Zhuan Puzzle (version 2.9 / 990108)", 0 ) |
| 1225 | 1296 | GAME( 1999, puzlbang, suplup, suplup, common, puzlbang, ROT0, "Omega System", "Puzzle Bang Bang (version 2.8 / 990106)", 0 ) |
| 1226 | 1297 | GAME( 1999, vamphalf, 0, vamphalf, common, vamphalf, ROT0, "Danbi & F2 System", "Vamp 1/2 (Korea version)", 0 ) |
| 1298 | GAME( 2000, dquizgo2, 0, coolmini, common, dquizgo2, ROT0, "SemiCom", "Date Quiz Go Go Episode 2" , 0) | |
| 1227 | 1299 | GAME( 2000, misncrft, 0, misncrft, common, misncrft, ROT90, "Sun", "Mission Craft (version 2.4)", GAME_NO_SOUND ) |
| 1228 | 1300 | GAME( 2001, finalgdr, 0, finalgdr, common, finalgdr, ROT0, "SemiCom", "Final Godori (Korea)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) |
| 1229 | 1301 | GAME( 2001, wyvernwg, 0, wyvernwg, common, wyvernwg, ROT270, "SemiCom (Game Vision License)", "Wyvern Wings", GAME_NO_SOUND ) |
| r936 | r937 | |
|---|---|---|
| 1469 | 1469 | RGN_FRAC(1,1), |
| 1470 | 1470 | 2, |
| 1471 | 1471 | { 0, 4 }, |
| 1472 | { 8*8+0, 8*8+1, 8*8+2, 8*8+3, 0, 1, 2, 3 }, | |
| 1473 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 1472 | { STEP4(8*8,1), STEP4(0*8,1) }, | |
| 1473 | { STEP8(0*8,8) }, | |
| 1474 | 1474 | 16*8 |
| 1475 | 1475 | }; |
| 1476 | 1476 | |
| r936 | r937 | |
| 1480 | 1480 | RGN_FRAC(1,1), |
| 1481 | 1481 | 1, |
| 1482 | 1482 | { 0 }, |
| 1483 | { 0, 1, 2, 3, 4, 5, 6, 7 }, | |
| 1484 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 1483 | { STEP8(0,1) }, | |
| 1484 | { STEP8(0,8) }, | |
| 1485 | 1485 | 8*8 |
| 1486 | 1486 | }; |
| 1487 | 1487 | |
| r936 | r937 | |
| 1491 | 1491 | RGN_FRAC(1,1), |
| 1492 | 1492 | 1, |
| 1493 | 1493 | { 0 }, |
| 1494 | { 7, 6, 5, 4, 3, 2, 1, 0 }, | |
| 1495 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 1494 | { STEP8(7,-1) }, | |
| 1495 | { STEP8(0,8) }, | |
| 1496 | 1496 | 8*8 |
| 1497 | 1497 | }; |
| 1498 | 1498 | |
| r936 | r937 | |
| 1502 | 1502 | RGN_FRAC(1,2), |
| 1503 | 1503 | 2, |
| 1504 | 1504 | { 0, RGN_FRAC(1,2) }, |
| 1505 | { 0, 1, 2, 3, 4, 5, 6, 7 }, | |
| 1506 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 1505 | { STEP8(0,1) }, | |
| 1506 | { STEP8(0,8) }, | |
| 1507 | 1507 | 8*8 |
| 1508 | 1508 | }; |
| 1509 | 1509 | |
| r936 | r937 | |
| 1513 | 1513 | RGN_FRAC(1,1), |
| 1514 | 1514 | 2, |
| 1515 | 1515 | { 0, 4 }, |
| 1516 | { 8*8, 8*8+1, 8*8+2, 8*8+3, 16*8+0, 16*8+1, 16*8+2, 16*8+3, | |
| 1517 | 24*8+0, 24*8+1, 24*8+2, 24*8+3, 0, 1, 2, 3 }, | |
| 1518 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, | |
| 1519 | 32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 }, | |
| 1516 | { STEP4(8*8,1), STEP4(16*8,1), STEP4(24*8,1), STEP4(0*8,1) }, | |
| 1517 | { STEP8(0*8,8), STEP8(32*8,8) }, | |
| 1520 | 1518 | 64*8 |
| 1521 | 1519 | }; |
| 1522 | 1520 | |
| r936 | r937 | |
| 1526 | 1524 | RGN_FRAC(1,1), |
| 1527 | 1525 | 2, |
| 1528 | 1526 | { 0, 4 }, |
| 1529 | { 0, 1, 2, 3, 8*8, 8*8+1, 8*8+2, 8*8+3, 16*8+0, 16*8+1, 16*8+2, 16*8+3, | |
| 1530 | 24*8+0, 24*8+1, 24*8+2, 24*8+3 }, | |
| 1531 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, | |
| 1532 | 32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 }, | |
| 1527 | { STEP4(0*8,1), STEP4(8*8,1), STEP4(16*8,1), STEP4(24*8,1) }, | |
| 1528 | { STEP8(0*8,8), STEP8(32*8,8) }, | |
| 1533 | 1529 | 64*8 |
| 1534 | 1530 | }; |
| 1535 | 1531 | |
| r936 | r937 | |
| 1539 | 1535 | RGN_FRAC(1,2), |
| 1540 | 1536 | 3, |
| 1541 | 1537 | { RGN_FRAC(1,2)+4, 0, 4 }, |
| 1542 | { 0, 1, 2, 3, 8*8+0, 8*8+1, 8*8+2, 8*8+3, | |
| 1543 | 16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3 }, | |
| 1544 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, | |
| 1545 | 32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 }, | |
| 1538 | { STEP4(0*8,1), STEP4(8*8,1), STEP4(16*8,1), STEP4(24*8,1) }, | |
| 1539 | { STEP8(0*8,8), STEP8(32*8,8) }, | |
| 1546 | 1540 | 64*8 |
| 1547 | 1541 | }; |
| 1548 | 1542 | |
| r936 | r937 | |
| 1552 | 1546 | 8, |
| 1553 | 1547 | 3, /* 2 bits color + 1 bit transparency */ |
| 1554 | 1548 | { 5, 6, 7 }, |
| 1555 | { 0*8, 1*8, 2*8, 3*8 }, | |
| 1556 | { 0*32, 1*32, 2*32, 3*32 }, | |
| 1549 | { STEP4(0,8) }, | |
| 1550 | { STEP4(0,32) }, | |
| 1557 | 1551 | 16*8 |
| 1558 | 1552 | }; |
| 1559 | 1553 | |
| r936 | r937 | |
| 1672 | 1666 | MDRV_SCREEN_SIZE(36*8, 32*8) |
| 1673 | 1667 | MDRV_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 2*8, 30*8-1) |
| 1674 | 1668 | MDRV_GFXDECODE(gfxdecodeinfo_bosco) |
| 1675 | MDRV_PALETTE_LENGTH(32+64) | |
| 1676 | MDRV_COLORTABLE_LENGTH(64*4+64*4+8) | |
| 1669 | MDRV_PALETTE_LENGTH(64*4+64*4+4+64) | |
| 1677 | 1670 | |
| 1678 | 1671 | MDRV_PALETTE_INIT(bosco) |
| 1679 | 1672 | MDRV_VIDEO_START(bosco) |
| r936 | r937 | |
| 1731 | 1724 | MDRV_SCREEN_SIZE(36*8, 28*8) |
| 1732 | 1725 | MDRV_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 0*8, 28*8-1) |
| 1733 | 1726 | MDRV_GFXDECODE(gfxdecodeinfo_galaga) |
| 1734 | MDRV_PALETTE_LENGTH(32+64) | |
| 1735 | MDRV_COLORTABLE_LENGTH(64*4+64*4) | |
| 1727 | MDRV_PALETTE_LENGTH(64*4+64*4+64) | |
| 1736 | 1728 | |
| 1737 | 1729 | MDRV_PALETTE_INIT(galaga) |
| 1738 | 1730 | MDRV_VIDEO_START(galaga) |
| r936 | r937 | |
| 1805 | 1797 | MDRV_SCREEN_SIZE(36*8, 28*8) |
| 1806 | 1798 | MDRV_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 0*8, 28*8-1) |
| 1807 | 1799 | MDRV_GFXDECODE(gfxdecodeinfo_xevious) |
| 1808 | MDRV_PALETTE_LENGTH(128+1) | |
| 1809 | MDRV_COLORTABLE_LENGTH(128*4+64*8+64*2) | |
| 1800 | MDRV_PALETTE_LENGTH(128*4+64*8+64*2) | |
| 1810 | 1801 | |
| 1811 | 1802 | MDRV_PALETTE_INIT(xevious) |
| 1812 | 1803 | MDRV_VIDEO_START(xevious) |
| r936 | r937 | |
| 1879 | 1870 | MDRV_SCREEN_SIZE(36*8, 28*8) |
| 1880 | 1871 | MDRV_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 0*8, 28*8-1) |
| 1881 | 1872 | MDRV_GFXDECODE(gfxdecodeinfo_digdug) |
| 1882 | MDRV_PALETTE_LENGTH(32) | |
| 1883 | MDRV_COLORTABLE_LENGTH(16*2+64*4+64*4) | |
| 1873 | MDRV_PALETTE_LENGTH(16*2+64*4+64*4) | |
| 1884 | 1874 | |
| 1885 | 1875 | MDRV_PALETTE_INIT(digdug) |
| 1886 | 1876 | MDRV_VIDEO_START(digdug) |
| r936 | r937 | |
|---|---|---|
| 406 | 406 | |
| 407 | 407 | /* YEAR NAME PARENT MACHINE INPUT INIT MONITOR COMPANY FULLNAME FLAGS) */ |
| 408 | 408 | GAME( 1983, istellar, 0, istellar, istellar, istellar, ROT0, "Funai/Gakken", "Interstellar Laser Fantasy", GAME_NOT_WORKING|GAME_NO_SOUND) |
| 409 | /* | |
| 410 | Funai / Gakken Interstellar Laser Fantasy laserdisc hardware | |
| 411 | Driver by Andrew Gardner with help from Daphne Source | |
| 412 | ||
| 413 | Notes: | |
| 414 | Holding down the TEST switch (T) while hitting reset will bring up the Self Test. | |
| 415 | Hit T twice more for color and monitor calibration. | |
| 416 | This is somewhat strange hardware : More z80's than necessary | |
| 417 | 3 bpp sprites | |
| 418 | 6-pin dip switches with odd handling | |
| 419 | inverted DIP logic? | |
| 420 | CPU2 maps RAM over where its ROM lives | |
| 421 | The DIP switch settings seem to be inverted (or the test mode shows 1 for open and 0 for closed). This is fine, but | |
| 422 | the DIPLOC stuff displays the switches off when they should be on and vice-versa. Maybe a fix the DIPlOCc code is needed? | |
| 423 | ||
| 424 | Todo: | |
| 425 | How does one best make one DIP switch bit from address 0x02 tie to two bits from address 0x03? | |
| 426 | Get real ROM labels! The current labels are unfortunately a bit odd. | |
| 427 | Add sprite drawing. | |
| 428 | Convert to tilemaps. | |
| 429 | Make it work - this one should be close right now :/. | |
| 430 | */ | |
| 431 | ||
| 432 | #include "driver.h" | |
| 433 | #include "render.h" | |
| 434 | #include "machine/laserdsc.h" | |
| 435 | ||
| 436 | /* There is only 1 crystal on the stack of 3 boards - speed is unknown, the following is Daphne's guess */ | |
| 437 | #define GUESSED_CLOCK (3072000) | |
| 438 | ||
| 439 | ||
| 440 | /* Misc variables */ | |
| 441 | static laserdisc_info *discinfo; | |
| 442 | ||
| 443 | static UINT8 *tile_ram; | |
| 444 | static UINT8 *tile_control_ram; | |
| 445 | static UINT8 *sprite_ram; | |
| 446 | ||
| 447 | static UINT8 ldp_latch1; | |
| 448 | static UINT8 ldp_latch2; | |
| 449 | ||
| 450 | static UINT8 z80_2_nmi_enable; | |
| 451 | ||
| 452 | /* VIDEO GOODS */ | |
| 453 | VIDEO_UPDATE( istellar ) | |
| 454 | { | |
| 455 | int charx, chary; | |
| 456 | ||
| 457 | /* clear */ | |
| 458 | fillbitmap(bitmap, 0, cliprect); | |
| 459 | ||
| 460 | /* display disc information */ | |
| 461 | if (discinfo != NULL) | |
| 462 | popmessage("%s", laserdisc_describe_state(discinfo)); | |
| 463 | ||
| 464 | /* DEBUG */ | |
| 465 | /* | |
| 466 | for (charx = 0; charx < 0x400; charx ++) | |
| 467 | { | |
| 468 | printf ("%x ", sprite_ram[charx]) ; | |
| 469 | } | |
| 470 | printf("\n\n\n"); | |
| 471 | */ | |
| 472 | ||
| 473 | /* Draw tiles */ | |
| 474 | for (charx = 0; charx < 32; charx++) | |
| 475 | { | |
| 476 | for (chary = 0; chary < 32; chary++) | |
| 477 | { | |
| 478 | int current_screen_character = (chary*32) + charx; | |
| 479 | ||
| 480 | drawgfx(bitmap, machine->gfx[0], | |
| 481 | tile_ram[current_screen_character], | |
| 482 | (tile_control_ram[current_screen_character] & 0x0f), | |
| 483 | 0, 0, charx*8, chary*8, cliprect, TRANSPARENCY_PEN, 0); | |
| 484 | } | |
| 485 | } | |
| 486 | ||
| 487 | ||
| 488 | /* Draw sprites */ | |
| 489 | ||
| 490 | return 0; | |
| 491 | } | |
| 492 | ||
| 493 | ||
| 494 | ||
| 495 | /* MEMORY HANDLERS */ | |
| 496 | /* Z80 0 R/W */ | |
| 497 | READ8_HANDLER(z80_0_latch1_read) | |
| 498 | { | |
| 499 | /*logerror("CPU0 : reading LDP status latch (%x)\n", ldp_latch1);*/ | |
| 500 | return ldp_latch1; | |
| 501 | } | |
| 502 | ||
| 503 | WRITE8_HANDLER(z80_0_latch2_write) | |
| 504 | { | |
| 505 | /*logerror("CPU0 : writing cpu_latch2 (%x). Potentially followed by an IRQ.\n", data);*/ | |
| 506 | ldp_latch2 = data; | |
| 507 | ||
| 508 | /* A CPU2 NMI */ | |
| 509 | if (z80_2_nmi_enable) | |
| 510 | { | |
| 511 | logerror("Executing an NMI on CPU2\n"); | |
| 512 | cpunum_set_input_line(2, INPUT_LINE_NMI, PULSE_LINE); /* Maybe this is a ASSERT_LINE, CLEAR_LINE combo? */ | |
| 513 | z80_2_nmi_enable = 0; | |
| 514 | } | |
| 515 | } | |
| 516 | ||
| 517 | ||
| 518 | /* Z80 1 R/W */ | |
| 519 | ||
| 520 | ||
| 521 | /* Z80 2 R/W */ | |
| 522 | READ8_HANDLER(z80_2_ldp_read) | |
| 523 | { | |
| 524 | UINT8 readResult = laserdisc_data_r(discinfo); | |
| 525 | logerror("CPU2 : reading LDP : %x\n", readResult); | |
| 526 | return readResult; | |
| 527 | } | |
| 528 | ||
| 529 | READ8_HANDLER(z80_2_latch2_read) | |
| 530 | { | |
| 531 | logerror("CPU2 : reading latch2 (%x)\n", ldp_latch2); | |
| 532 | return ldp_latch2; | |
| 533 | } | |
| 534 | ||
| 535 | READ8_HANDLER(z80_2_nmienable) | |
| 536 | { | |
| 537 | logerror("CPU2 : ENABLING NMI\n"); | |
| 538 | z80_2_nmi_enable = 1; | |
| 539 | return 0x00; | |
| 540 | } | |
| 541 | ||
| 542 | READ8_HANDLER(z80_2_unknown_read) | |
| 543 | { | |
| 544 | logerror("CPU2 : c000!\n"); | |
| 545 | return 0x00; | |
| 546 | } | |
| 547 | ||
| 548 | WRITE8_HANDLER(z80_2_latch1_write) | |
| 549 | { | |
| 550 | logerror("CPU2 : writing latch1 (%x)\n", data); | |
| 551 | ldp_latch1 = data; | |
| 552 | } | |
| 553 | ||
| 554 | WRITE8_HANDLER(z80_2_ldp_write) | |
| 555 | { | |
| 556 | logerror("CPU2 : writing LDP : 0x%x\n", data); | |
| 557 | laserdisc_data_w(discinfo,data); | |
| 558 | } | |
| 559 | ||
| 560 | ||
| 561 | ||
| 562 | /* PROGRAM MAPS */ | |
| 563 | static ADDRESS_MAP_START( z80_0_mem, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 564 | AM_RANGE(0x0000,0x9fff) AM_ROM | |
| 565 | AM_RANGE(0xa000,0xa7ff) AM_RAM | |
| 566 | AM_RANGE(0xa800,0xabff) AM_RAM AM_BASE(&tile_ram) | |
| 567 | AM_RANGE(0xac00,0xafff) AM_RAM AM_BASE(&tile_control_ram) | |
| 568 | AM_RANGE(0xb000,0xb3ff) AM_RAM AM_BASE(&sprite_ram) | |
| 569 | ADDRESS_MAP_END | |
| 570 | ||
| 571 | static ADDRESS_MAP_START( z80_1_mem, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 572 | AM_RANGE(0x0000,0x1fff) AM_ROM | |
| 573 | AM_RANGE(0x4000,0x47ff) AM_RAM | |
| 574 | ADDRESS_MAP_END | |
| 575 | ||
| 576 | static ADDRESS_MAP_START( z80_2_mem, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 577 | AM_RANGE(0x0000,0x17ff) AM_ROM | |
| 578 | AM_RANGE(0x1800,0x1fff) AM_RAM | |
| 579 | AM_RANGE(0xc000,0xc000) AM_READ(z80_2_unknown_read) /* Seems to be thrown away every time it's read - maybe interrupt related? */ | |
| 580 | ADDRESS_MAP_END | |
| 581 | ||
| 582 | ||
| 583 | /* IO MAPS */ | |
| 584 | static ADDRESS_MAP_START( z80_0_io, ADDRESS_SPACE_IO, 8 ) | |
| 585 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 586 | AM_RANGE(0x00,0x00) AM_READ_PORT("IN0") | |
| 587 | AM_RANGE(0x02,0x02) AM_READ_PORT("DSW1") | |
| 588 | AM_RANGE(0x03,0x03) AM_READ_PORT("DSW2") | |
| 589 | /*AM_RANGE(0x04,0x04) AM_WRITE(volatile_palette_write)*/ | |
| 590 | AM_RANGE(0x05,0x05) AM_READWRITE(z80_0_latch1_read,z80_0_latch2_write) | |
| 591 | ADDRESS_MAP_END | |
| 592 | ||
| 593 | static ADDRESS_MAP_START( z80_1_io, ADDRESS_SPACE_IO, 8 ) | |
| 594 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 595 | AM_RANGE(0x00,0x00) AM_NOP /*AM_READWRITE(z80_1_slatch_read,z80_1_slatch_write)*/ | |
| 596 | AM_RANGE(0x01,0x01) AM_NOP /*AM_READWRITE(z80_1_nmienable,z80_1_soundwrite_front)*/ | |
| 597 | AM_RANGE(0x02,0x02) AM_NOP /*AM_WRITE(z80_1_soundwrite_rear)*/ | |
| 598 | ADDRESS_MAP_END | |
| 599 | ||
| 600 | static ADDRESS_MAP_START( z80_2_io, ADDRESS_SPACE_IO, 8 ) | |
| 601 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 602 | AM_RANGE(0x00,0x00) AM_READWRITE(z80_2_ldp_read,z80_2_ldp_write) | |
| 603 | AM_RANGE(0x01,0x01) AM_READWRITE(z80_2_latch2_read,z80_2_latch1_write) | |
| 604 | AM_RANGE(0x02,0x02) AM_READ(z80_2_nmienable) | |
| 605 | /* AM_RANGE(0x03,0x03) AM_WRITE(z80_2_ldtrans_write)*/ | |
| 606 | ADDRESS_MAP_END | |
| 607 | ||
| 608 | ||
| 609 | /* PORTS */ | |
| 610 | INPUT_PORTS_START( istellar ) | |
| 611 | /* TEST MODE might display a 0 for a short and a 1 for an open circuit? If so, everything below is inverted. */ | |
| 612 | PORT_START_TAG("DSW1") | |
| 613 | PORT_DIPNAME( 0x01, 0x01, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW1:1") | |
| 614 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) | |
| 615 | PORT_DIPSETTING( 0x01, DEF_STR( On ) ) | |
| 616 | PORT_DIPNAME( 0x0e, 0x00, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:2,3,4") | |
| 617 | PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) ) | |
| 618 | PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) | |
| 619 | PORT_DIPSETTING( 0x06, DEF_STR( 2C_3C ) ) | |
| 620 | PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) ) | |
| 621 | PORT_DIPSETTING( 0x04, DEF_STR( 1C_3C ) ) | |
| 622 | PORT_DIPSETTING( 0x0c, DEF_STR( 1C_6C ) ) | |
| 623 | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW1:5,6") | |
| 624 | PORT_DIPSETTING( 0x00, "3" ) | |
| 625 | PORT_DIPSETTING( 0x10, "4" ) | |
| 626 | PORT_DIPSETTING( 0x20, "5" ) | |
| 627 | PORT_DIPSETTING( 0x30, "10" ) | |
| 628 | PORT_DIPNAME( 0x40, 0x00, "Barrier UFO" ) PORT_DIPLOCATION("SW2:1") | |
| 629 | PORT_DIPSETTING( 0x40, DEF_STR( No ) ) | |
| 630 | PORT_DIPSETTING( 0x00, DEF_STR( Yes ) ) | |
| 631 | PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW2:2") | |
| 632 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) | |
| 633 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 634 | ||
| 635 | /* NOTE - bit 0x80 in the above read is combined with bits 0x03 in the below read to form the Coin_B | |
| 636 | settings. I'm unaware of what mechanism MAME will use to make this work right? */ | |
| 637 | ||
| 638 | /* "In case of inter-stellar upright type the coin switch 2 is not used." Quoth the manual. */ | |
| 639 | PORT_START_TAG("DSW2") | |
| 640 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW2:3") | |
| 641 | PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) | |
| 642 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 643 | PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW2:4") | |
| 644 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) | |
| 645 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 646 | PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW2:5") /* Maybe SERVICE? */ | |
| 647 | PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) | |
| 648 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 649 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "TEST" ) PORT_CODE( KEYCODE_T ) | |
| 650 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN2 ) | |
| 651 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) | |
| 652 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 ) | |
| 653 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START1 ) | |
| 654 | ||
| 655 | PORT_START_TAG("IN0") | |
| 656 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_4WAY | |
| 657 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_4WAY | |
| 658 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY | |
| 659 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY | |
| 660 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) | |
| 661 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) | |
| 662 | /* SERVICE might be hanging out back here */ | |
| 663 | INPUT_PORTS_END | |
| 664 | ||
| 665 | PALETTE_INIT( istellar ) | |
| 666 | { | |
| 667 | int i; | |
| 668 | ||
| 669 | /* Oddly enough, the top 4 bits of each byte is 0 */ | |
| 670 | for (i = 0; i < machine->drv->total_colors; i++) | |
| 671 | { | |
| 672 | int r,g,b; | |
| 673 | int bit0,bit1,bit2,bit3; | |
| 674 | ||
| 675 | /* Daphne says "TODO: get the real interstellar resistor values" */ | |
| 676 | ||
| 677 | /* red component */ | |
| 678 | bit0 = (color_prom[i+0x000] >> 0) & 0x01; | |
| 679 | bit1 = (color_prom[i+0x000] >> 1) & 0x01; | |
| 680 | bit2 = (color_prom[i+0x000] >> 2) & 0x01; | |
| 681 | bit3 = (color_prom[i+0x000] >> 3) & 0x01; | |
| 682 | r = (0x8f * bit3) + (0x43 * bit2) + (0x1f * bit1) + (0x0e * bit0); | |
| 683 | ||
| 684 | /* green component */ | |
| 685 | bit0 = (color_prom[i+0x100] >> 0) & 0x01; | |
| 686 | bit1 = (color_prom[i+0x100] >> 1) & 0x01; | |
| 687 | bit2 = (color_prom[i+0x100] >> 2) & 0x01; | |
| 688 | bit3 = (color_prom[i+0x100] >> 3) & 0x01; | |
| 689 | g = (0x8f * bit3) + (0x43 * bit2) + (0x1f * bit1) + (0x0e * bit0); | |
| 690 | ||
| 691 | /* blue component */ | |
| 692 | bit0 = (color_prom[i+0x200] >> 0) & 0x01; | |
| 693 | bit1 = (color_prom[i+0x200] >> 1) & 0x01; | |
| 694 | bit2 = (color_prom[i+0x200] >> 2) & 0x01; | |
| 695 | bit3 = (color_prom[i+0x200] >> 3) & 0x01; | |
| 696 | b = (0x8f * bit3) + (0x43 * bit2) + (0x1f * bit1) + (0x0e * bit0); | |
| 697 | ||
| 698 | palette_set_color(machine,i,MAKE_RGB(r,g,b)); | |
| 699 | } | |
| 700 | } | |
| 701 | ||
| 702 | static const gfx_layout istellar_gfx_layout = | |
| 703 | { | |
| 704 | 8,8, | |
| 705 | 0x2000/8, | |
| 706 | 3, | |
| 707 | { 0, 0x2000*8, 0x4000*8 }, | |
| 708 | { 0,1,2,3,4,5,6,7 }, | |
| 709 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 710 | 8*8 | |
| 711 | }; | |
| 712 | ||
| 713 | static const gfx_decode gfxdecodeinfo[] = | |
| 714 | { | |
| 715 | { REGION_GFX1, 0, &istellar_gfx_layout, 0x0, 0x100 }, | |
| 716 | { -1 } | |
| 717 | }; | |
| 718 | ||
| 719 | static MACHINE_START( istellar ) | |
| 720 | { | |
| 721 | discinfo = laserdisc_init(LASERDISC_TYPE_LDV1000, get_disk_handle(0), 0); | |
| 722 | return; | |
| 723 | } | |
| 724 | ||
| 725 | static INTERRUPT_GEN( vblank_callback_istellar ) | |
| 726 | { | |
| 727 | /* Interrupt presumably comes from VBlank */ | |
| 728 | cpunum_set_input_line(0, 0, ASSERT_LINE); | |
| 729 | ||
| 730 | /* Interrupt presumably comes from the LDP's status strobe */ | |
| 731 | cpunum_set_input_line(2, 0, ASSERT_LINE); | |
| 732 | ||
| 733 | /* Only do the LDP's sync once */ | |
| 734 | if (cpu_getactivecpu() == 0) | |
| 735 | laserdisc_vsync(discinfo); | |
| 736 | } | |
| 737 | ||
| 738 | ||
| 739 | /* DRIVER */ | |
| 740 | static MACHINE_DRIVER_START( istellar ) | |
| 741 | /* main cpu */ | |
| 742 | MDRV_CPU_ADD(Z80, GUESSED_CLOCK) | |
| 743 | MDRV_CPU_PROGRAM_MAP(z80_0_mem,0) | |
| 744 | MDRV_CPU_IO_MAP(z80_0_io,0) | |
| 745 | MDRV_CPU_VBLANK_INT(vblank_callback_istellar, 1) | |
| 746 | ||
| 747 | /* sound cpu */ | |
| 748 | MDRV_CPU_ADD(Z80, GUESSED_CLOCK) | |
| 749 | MDRV_CPU_PROGRAM_MAP(z80_1_mem,0) | |
| 750 | MDRV_CPU_IO_MAP(z80_1_io,0) | |
| 751 | ||
| 752 | /* ldp comm cpu */ | |
| 753 | MDRV_CPU_ADD(Z80, GUESSED_CLOCK) | |
| 754 | MDRV_CPU_PROGRAM_MAP(z80_2_mem,0) | |
| 755 | MDRV_CPU_IO_MAP(z80_2_io,0) | |
| 756 | ||
| 757 | MDRV_MACHINE_START(istellar) | |
| 758 | ||
| 759 | /* video */ | |
| 760 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) | |
| 761 | ||
| 762 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) | |
| 763 | MDRV_SCREEN_REFRESH_RATE(60) | |
| 764 | MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION) | |
| 765 | MDRV_SCREEN_SIZE(32*8, 32*8) | |
| 766 | MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1) | |
| 767 | ||
| 768 | MDRV_PALETTE_LENGTH(256) | |
| 769 | MDRV_PALETTE_INIT(istellar) | |
| 770 | ||
| 771 | MDRV_GFXDECODE(gfxdecodeinfo) | |
| 772 | MDRV_VIDEO_UPDATE(istellar) | |
| 773 | ||
| 774 | /* sound */ | |
| 775 | MACHINE_DRIVER_END | |
| 776 | ||
| 777 | ||
| 778 | /* There is a photo of the PCB with blurry IC locations and labels. Comments reflect what I can (barely) see. */ | |
| 779 | ROM_START( istellar ) | |
| 780 | /* Main program CPU */ | |
| 781 | ROM_REGION( 0xa000, REGION_CPU1, 0 ) | |
| 782 | ROM_LOAD( "rom2.top", 0x0000, 0x2000, CRC(5d643381) SHA1(75ca52c28a52f534eda00c18b0db97e9923ff670) ) /* At IC location C63 (top board) - label ? */ | |
| 783 | ROM_LOAD( "rom3.top", 0x2000, 0x2000, CRC(ce5a2b09) SHA1(2de6a6e993c3411577ac0c834db8aaf16fb007ed) ) /* At IC location C64 (top board) - label ? */ | |
| 784 | ROM_LOAD( "rom4.top", 0x4000, 0x2000, CRC(7c2cb1f1) SHA1(ffd92510c03c2d35a59d233883c2b9f57394a51c) ) /* At IC location C65 (top board) - label ? */ | |
| 785 | ROM_LOAD( "rom5.top", 0x6000, 0x2000, CRC(354377f6) SHA1(bcf95b7ee1b47854e10baf24b0d8af3d56738b99) ) /* At IC location C66 (top board) - label ? */ | |
| 786 | ROM_LOAD( "rom6.top", 0x8000, 0x2000, CRC(0319bf40) SHA1(f324626e457c3eb7d6b74bc6afbfcc3aab2b3c72) ) /* At IC location C67 (top board) - label ? */ | |
| 787 | ||
| 788 | /* Sound CPU */ | |
| 789 | ROM_REGION( 0x2000, REGION_CPU2, 0 ) | |
| 790 | ROM_LOAD( "rom1.top", 0x0000, 0x2000, CRC(4f34fb1d) SHA1(56ca19344c84c5989d0be797e2759f84760310be) ) /* At IC location C62 (top board) - label ? */ | |
| 791 | ||
| 792 | /* LDP Communications CPU */ | |
| 793 | ROM_REGION( 0x2000, REGION_CPU3, 0 ) | |
| 794 | ROM_LOAD( "rom11.bot", 0x0000, 0x2000, CRC(165cbc57) SHA1(39463888f22ec3125f0686066d923a9aae79a8f7) ) /* At IC location C12 (bottom board) - label IS11 */ | |
| 795 | ||
| 796 | /* Tiles */ | |
| 797 | ROM_REGION( 0x6000, REGION_GFX1, ROMREGION_DISPOSE ) | |
| 798 | ROM_LOAD( "rom9.bot", 0x0000, 0x2000, CRC(9d79acb6) SHA1(72af972695face0016afce8a26c629d963e86d48) ) /* At IC location C47? (bottom board) - label ? */ | |
| 799 | ROM_LOAD( "rom8.bot", 0x2000, 0x2000, CRC(e9c9e490) SHA1(79aa35552b984018bc723adece5c40a0833a313c) ) /* At IC location C48? (bottom board) - label ? */ | |
| 800 | ROM_LOAD( "rom7.bot", 0x4000, 0x2000, CRC(1447ce3a) SHA1(8545cec108df6adab303802b1407c89b2dceba21) ) /* At IC location C49? (bottom board) - label ? */ | |
| 801 | ||
| 802 | /* Color PROMs */ | |
| 803 | ROM_REGION( 0x300, REGION_PROMS, 0 ) | |
| 804 | ROM_LOAD( "red6b.bot", 0x000, 0x100, CRC(5c52f844) SHA1(a8a3d91f3247ad13c805d8d8288b07f3cdaf1189) ) /* At IC location C63? (bottom board) - label ? */ | |
| 805 | ROM_LOAD( "green6c.bot", 0x100, 0x100, CRC(7d8c845c) SHA1(04ae2ca0cc6679e21346ce34e9e01aa5bf4e2067) ) /* At IC location C62? (bottom board) - label ? */ | |
| 806 | ROM_LOAD( "blue6d.bot", 0x200, 0x100, CRC(5ebb81f9) SHA1(285d60f2894c524ca80fc68ad7c2dfd9093a67ea) ) /* At IC location C61? (bottom board) - label ? */ | |
| 807 | ROM_END | |
| 808 | ||
| 809 | ||
| 810 | static DRIVER_INIT( istellar ) | |
| 811 | { | |
| 812 | z80_2_nmi_enable = 0; | |
| 813 | } | |
| 814 | ||
| 815 | /* YEAR NAME PARENT MACHINE INPUT INIT MONITOR COMPANY FULLNAME FLAGS) */ | |
| 816 | GAME( 1983, istellar, 0, istellar, istellar, istellar, ROT0, "Funai/Gakken", "Interstellar Laser Fantasy", GAME_NOT_WORKING|GAME_NO_SOUND) |
| r936 | r937 | |
|---|---|---|
| 376 | 376 | RGN_FRAC(1,2), |
| 377 | 377 | 4, |
| 378 | 378 | { 0, 4, RGN_FRAC(1,2)+0, RGN_FRAC(1,2)+4 }, |
| 379 | { 0, 1, 2, 3, 8*8, 8*8+1, 8*8+2, 8*8+3, | |
| 380 | 16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3 }, | |
| 381 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, | |
| 382 | 32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 }, | |
| 379 | { STEP4(0*8,1), STEP4(8*8,1), STEP4(16*8,1), STEP4(24*8,1) }, | |
| 380 | { STEP8(0*8,8), STEP8(32*8,8) }, | |
| 383 | 381 | 64*8 |
| 384 | 382 | }; |
| 385 | 383 | |
| r936 | r937 | |
| 389 | 387 | RGN_FRAC(1,1), |
| 390 | 388 | 2, |
| 391 | 389 | { 0, 4 }, |
| 392 | { 8*8, 8*8+1, 8*8+2, 8*8+3, 0, 1, 2, 3 }, | |
| 393 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 390 | { STEP4(8*8,1), STEP4(0*8,1) }, | |
| 391 | { STEP8(0*8,8) }, | |
| 394 | 392 | 16*8 |
| 395 | 393 | }; |
| 396 | 394 | |
| r936 | r937 | |
| 435 | 433 | MDRV_SCREEN_SIZE(64*8, 32*8) |
| 436 | 434 | MDRV_SCREEN_VISIBLE_AREA(3*8, 39*8-1, 2*8, 30*8-1) |
| 437 | 435 | MDRV_GFXDECODE(gfxdecodeinfo) |
| 438 | MDRV_PALETTE_LENGTH(256) | |
| 439 | MDRV_COLORTABLE_LENGTH(256*4+256*4+2*64*16) | |
| 436 | MDRV_PALETTE_LENGTH(256*4+256*4+2*64*16) | |
| 440 | 437 | |
| 441 | 438 | MDRV_PALETTE_INIT(pacland) |
| 442 | 439 | MDRV_VIDEO_START(pacland) |
| r936 | r937 | |
|---|---|---|
| 103 | 103 | /* b5 : VLM5030-ST */ |
| 104 | 104 | /* b4 : VLM5300-VCU */ |
| 105 | 105 | /* b3 : ROM bank select */ |
| 106 | if (sndti_t | |
| 106 | if (sndti_exist | |
| 107 | 107 | { |
| 108 | 108 | VLM5030_RST( data & 0x40 ? 1 : 0 ); |
| 109 | 109 | VLM5030_ST( data & 0x20 ? 1 : 0 ); |
| r936 | r937 | |
| 113 | 113 | /* b2 : SSG-C rc filter enable */ |
| 114 | 114 | /* b1 : SSG-B rc filter enable */ |
| 115 | 115 | /* b0 : SSG-A rc filter enable */ |
| 116 | if (sndti_t | |
| 116 | if (sndti_exist | |
| 117 | 117 | { |
| 118 | 118 | filter_rc_set_RC(2,FLT_RC_LOWPASS, 1000,2200,1000,data & 0x04 ? CAP_N(150) : 0); /* YM2203-SSG-C */ |
| 119 | 119 | filter_rc_set_RC(1,FLT_RC_LOWPASS, 1000,2200,1000,data & 0x02 ? CAP_N(150) : 0); /* YM2203-SSG-B */ |
| r936 | r937 | |
|---|---|---|
| 507 | 507 | cop_g_latch = 0xff; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | /* YEAR NAME PARENT MACHINE INPUT INIT MONITOR COMPANY FULLNAME FLAGS) */ | |
| 511 | GAME( 1983, thayers, 0, thayers, thayers, thayers, ROT0, "RDI Video Systems", "Thayer's Quest", GAME_NOT_WORKING|GAME_NO_SOUND) | |
| 512 | /* | |
| 513 | RDI Video Systems Thayer's Quest laserdisc hardware | |
| 514 | Driver by Andrew Gardner from schematics with help from Daphne Source | |
| 515 | ||
| 516 | Notes: | |
| 517 | How odd. The schematics say there's a COP421L hooked up, but they also make mention of | |
| 518 | a COP404L - A ROMless COP420 with 1k of RAM. I wonder which one is correct? | |
| 519 | ||
| 520 | Todo: | |
| 521 | Add SIO to the cop420 core. | |
| 522 | Fix up my poor interpretation of the hard-to-read schematics. | |
| 523 | Write a real SC-01 (SSI-263) emulator for MAME. | |
| 524 | Convert to tilemaps. | |
| 525 | */ | |
| 526 | ||
| 527 | #include "driver.h" | |
| 528 | #include "render.h" | |
| 529 | #include "machine/laserdsc.h" | |
| 530 | #include "cpu/cop400/cop400.h" | |
| 531 | ||
| 532 | #define SCHEMATIC_CLOCK (4000000) | |
| 533 | ||
| 534 | /* | |
| 535 | * Z80 IRQ Status bit | |
| 536 | * ------------------ | |
| 537 | * | |
| 538 | * Bit | Use | |
| 539 | * 76543210-+---------------- | |
| 540 | * -------x | Unused | |
| 541 | * ------x- | Unused | |
| 542 | * -----x-- | SSI-263 Request Data. | |
| 543 | * ----x--- | always high. (? but it's checked at 0x1bb ?) | |
| 544 | * ---x---- | /TIMER INT. | |
| 545 | * --x----- | /DATA RDY INT. | |
| 546 | * -x------ | /CART PRES. | |
| 547 | * x------- | Unused | |
| 548 | */ | |
| 549 | static UINT8 z80_irq_status; | |
| 550 | ||
| 551 | #define Z80_IRQ_STATUS_SET() (z80_irq_status = 0x00) | |
| 552 | #define Z80_IRQ_STATUS_CLEAR() (z80_irq_status = 0xff) | |
| 553 | ||
| 554 | #define Z80_SSI_REQUEST() ((z80_irq_status & 0x04) >> 2) | |
| 555 | #define Z80_TIMER_INT() ((z80_irq_status & 0x10) >> 4) | |
| 556 | #define Z80_DATA_RDY_INT() ((z80_irq_status & 0x20) >> 5) | |
| 557 | #define Z80_CART_PRES() ((z80_irq_status & 0x40) >> 6) | |
| 558 | ||
| 559 | #define SET_Z80_SSI_REQUEST() (z80_irq_status &= ~0x04) | |
| 560 | #define SET_Z80_TIMER_INT() (z80_irq_status &= ~0x10) | |
| 561 | #define SET_Z80_DATA_RDY_INT() (z80_irq_status &= ~0x20) | |
| 562 | #define SET_Z80_CART_PRES() (z80_irq_status &= ~0x40) | |
| 563 | ||
| 564 | #define CLEAR_Z80_SSI_REQUEST() (z80_irq_status |= 0x04) | |
| 565 | #define CLEAR_Z80_TIMER_INT() (z80_irq_status |= 0x10) | |
| 566 | #define CLEAR_Z80_DATA_RDY_INT() (z80_irq_status |= 0x20) | |
| 567 | #define CLEAR_Z80_CART_PRES() (z80_irq_status |= 0x40) | |
| 568 | ||
| 569 | ||
| 570 | /* Misc variables */ | |
| 571 | static UINT8* ram_ic; | |
| 572 | static laserdisc_info *discinfo; | |
| 573 | ||
| 574 | static UINT8 m_ssi_control; | |
| 575 | static UINT8 cop_g_latch; | |
| 576 | static UINT8 cop_l_latch; | |
| 577 | ||
| 578 | ||
| 579 | ||
| 580 | /* VIDEO GOODS */ | |
| 581 | VIDEO_UPDATE( thayers ) | |
| 582 | { | |
| 583 | /* display disc information */ | |
| 584 | if (discinfo != NULL) | |
| 585 | popmessage("%s", laserdisc_describe_state(discinfo)); | |
| 586 | ||
| 587 | return 0; | |
| 588 | } | |
| 589 | ||
| 590 | ||
| 591 | ||
| 592 | /* MEMORY HANDLERS */ | |
| 593 | /* Z80 R/W */ | |
| 594 | READ8_HANDLER(z80_irq_status_r) | |
| 595 | { | |
| 596 | return z80_irq_status; | |
| 597 | } | |
| 598 | ||
| 599 | READ8_HANDLER(ram_ic_read) | |
| 600 | { | |
| 601 | /* Daphne patches. | |
| 602 | if (offset == 0xbe07-0x8000) | |
| 603 | return 0x02; | |
| 604 | ||
| 605 | if (offset == 0xbe17-0x8000) | |
| 606 | return 0x01; | |
| 607 | */ | |
| 608 | ||
| 609 | return ram_ic[offset]; | |
| 610 | } | |
| 611 | ||
| 612 | static UINT32 laserdisc_status_r(void *param) | |
| 613 | { | |
| 614 | if (discinfo == NULL) | |
| 615 | return 0; | |
| 616 | ||
| 617 | /* Someday handle multiple LD players */ | |
| 618 | return (laserdisc_line_r(discinfo, LASERDISC_LINE_STATUS) == ASSERT_LINE) ? 0 : 1; | |
| 619 | } | |
| 620 | ||
| 621 | static UINT32 laserdisc_command_r(void *param) | |
| 622 | { | |
| 623 | if (discinfo == NULL) | |
| 624 | return 0; | |
| 625 | ||
| 626 | /* Someday handle multiple LD players */ | |
| 627 | return (laserdisc_line_r(discinfo, LASERDISC_LINE_COMMAND) == ASSERT_LINE) ? 0 : 1; | |
| 628 | } | |
| 629 | ||
| 630 | WRITE8_HANDLER(ram_ic_write) | |
| 631 | { | |
| 632 | ram_ic[offset] = data; | |
| 633 | } | |
| 634 | ||
| 635 | WRITE8_HANDLER(data_ready_int_w) | |
| 636 | { | |
| 637 | CLEAR_Z80_DATA_RDY_INT(); | |
| 638 | /* Hackaroo? */ | |
| 639 | /* cop_l_latch = 0x00; */ | |
| 640 | } | |
| 641 | ||
| 642 | WRITE8_HANDLER(timer_int_w) | |
| 643 | { | |
| 644 | CLEAR_Z80_TIMER_INT(); | |
| 645 | } | |
| 646 | ||
| 647 | WRITE8_HANDLER(write_cop) | |
| 648 | { | |
| 649 | logerror("Writing 0x%x to COP port G\n", data); | |
| 650 | ||
| 651 | /* Bits 5-7 write to COP421 ports G0-G2 */ | |
| 652 | cop_g_latch = (data >> 5) & 0x07; | |
| 653 | ||
| 654 | /* Bit 2 goes to BANKSELT */ | |
| 655 | /* bankselect = (data & 0x04) >> 2; */ | |
| 656 | ||
| 657 | /* Bit 1 goes to CS128x? (illegible schems) */ | |
| 658 | } | |
| 659 | ||
| 660 | WRITE8_HANDLER(data_write_cop) | |
| 661 | { | |
| 662 | cop_l_latch = data; | |
| 663 | } | |
| 664 | ||
| 665 | WRITE8_HANDLER(intrq_w) | |
| 666 | { | |
| 667 | cpunum_set_input_line(0, 0, ASSERT_LINE); | |
| 668 | } | |
| 669 | ||
| 670 | WRITE8_HANDLER(sc01_register_w) | |
| 671 | { | |
| 672 | /* (Thank you Daphne) */ | |
| 673 | switch (offset) | |
| 674 | { | |
| 675 | case 0x00: | |
| 676 | if (m_ssi_control) | |
| 677 | { | |
| 678 | logerror("SC-01 control mode : 0x%x\n", data); | |
| 679 | ||
| 680 | switch(data) | |
| 681 | { | |
| 682 | /* Stop requesting phonemes */ | |
| 683 | case 0x00: | |
| 684 | CLEAR_Z80_SSI_REQUEST(); | |
| 685 | break; | |
| 686 | ||
| 687 | /* Start adding phonemes */ | |
| 688 | case 0xc0: | |
| 689 | SET_Z80_SSI_REQUEST(); | |
| 690 | if (!(Z80_SSI_REQUEST())) | |
| 691 | logerror("SETTING IRQ LINE sc01\n"); | |
| 692 | cpunum_set_input_line(0, 0, ASSERT_LINE); | |
| 693 | break; | |
| 694 | ||
| 695 | default: | |
| 696 | logerror("SC-01 control mode invalid code 0x%x\n", data); | |
| 697 | break; | |
| 698 | } | |
| 699 | } | |
| 700 | else | |
| 701 | { | |
| 702 | logerror("SC-01 receiving phonemes 0x%x\n", data & 0x3f); | |
| 703 | } | |
| 704 | break; | |
| 705 | ||
| 706 | case 0x01: | |
| 707 | logerror("SC-01 inflection changed to 0x%x\n", data); | |
| 708 | break; | |
| 709 | ||
| 710 | case 0x02: | |
| 711 | logerror("SC-01 speech rate changed to 0x%x\n", data); | |
| 712 | break; | |
| 713 | ||
| 714 | case 0x03: | |
| 715 | if (data & 0x80) | |
| 716 | { | |
| 717 | m_ssi_control = 1; | |
| 718 | logerror("SC-01 now in control mode.\n"); | |
| 719 | } | |
| 720 | else if (data & 0x70) | |
| 721 | { | |
| 722 | m_ssi_control = 0; | |
| 723 | logerror("SC-01 control mode cleared.\n"); | |
| 724 | } | |
| 725 | else | |
| 726 | { | |
| 727 | logerror("SC-01 amplitude manipulated 0x%x.\n", data); | |
| 728 | } | |
| 729 | break; | |
| 730 | ||
| 731 | case 0x04: | |
| 732 | logerror("SC-01 filter frequency changed to 0x%x.\n", data); | |
| 733 | break; | |
| 734 | } | |
| 735 | } | |
| 736 | ||
| 737 | ||
| 738 | /* COP R/W */ | |
| 739 | /* All 8 l pins are hooked up here */ | |
| 740 | READ8_HANDLER(cop_l_read) | |
| 741 | { | |
| 742 | logerror("COP - Reading from L @ (0x%x)\n", activecpu_get_pc()); | |
| 743 | return cop_l_latch; | |
| 744 | } | |
| 745 | ||
| 746 | /* Pins g0, g1, g2, and g3 are all hooked up */ | |
| 747 | READ8_HANDLER(cop_g_read) | |
| 748 | { | |
| 749 | logerror("COP - Reading from G @ (0x%x)\n", activecpu_get_pc()); | |
| 750 | return cop_g_latch; | |
| 751 | } | |
| 752 | ||
| 753 | WRITE8_HANDLER(cop_l_write) | |
| 754 | { | |
| 755 | logerror("COP - WRITING TO L 0x%x @ (0x%x)\n", data, activecpu_get_pc()); | |
| 756 | cop_l_latch = data; | |
| 757 | } | |
| 758 | ||
| 759 | WRITE8_HANDLER(cop_g_write) | |
| 760 | { | |
| 761 | logerror("COP - WRITING TO G 0x%x @ (0x%x)\n", data, activecpu_get_pc()); | |
| 762 | ||
| 763 | /* Bit 3 goes to an enable pin on the data latch? */ | |
| 764 | /* Bits 0-2 seem to go into the wrong side of a logic IC? */ | |
| 765 | } | |
| 766 | ||
| 767 | /* Schematics say pins d0 and d1 are the only two that are hooked up */ | |
| 768 | WRITE8_HANDLER(cop_d_write) | |
| 769 | { | |
| 770 | int irq_flag = 0; | |
| 771 | ||
| 772 | logerror("COP - WRITING TO D 0x%x @ (0x%x)\n", data, activecpu_get_pc()); | |
| 773 | ||
| 774 | /* Pin d0 - TIMER INT */ | |
| 775 | if (!(data & 0x01)) | |
| 776 | { | |
| 777 | SET_Z80_TIMER_INT(); | |
| 778 | irq_flag = 1; | |
| 779 | logerror("THE COP IS TRIPPING THE TIMER INTERRUPT\n"); | |
| 780 | } | |
| 781 | else | |
| 782 | { | |
| 783 | CLEAR_Z80_TIMER_INT(); | |
| 784 | } | |
| 785 | ||
| 786 | /* Pin d1 - DATA READY INT */ | |
| 787 | if (!(data & 0x02)) | |
| 788 | { | |
| 789 | SET_Z80_DATA_RDY_INT(); | |
| 790 | irq_flag = 1; | |
| 791 | logerror("THE COP IS TRIPPING THE DATA READY INTERRUPT\n"); | |
| 792 | } | |
| 793 | else | |
| 794 | { | |
| 795 | CLEAR_Z80_DATA_RDY_INT(); | |
| 796 | } | |
| 797 | ||
| 798 | /* Assert the Z80's interrupt line if necessary */ | |
| 799 | if (irq_flag) | |
| 800 | { | |
| 801 | cpunum_set_input_line(0, 0, ASSERT_LINE); | |
| 802 | } | |
| 803 | } | |
| 804 | ||
| 805 | WRITE8_HANDLER(cop_sk_write) | |
| 806 | { | |
| 807 | /* I think this data falls off into a black hole - the pins aren't hooked up. | |
| 808 | The COP400 XAS instruction writes to both SK and SIO, that's why the CPU writes data here at all. */ | |
| 809 | } | |
| 810 | ||
| 811 | WRITE8_HANDLER(cop_sio_write) | |
| 812 | { | |
| 813 | /* This data is sent to the CLK pin of the keyboard handling logic. We don't need to emulate it here. */ | |
| 814 | } | |
| 815 | ||
| 816 | ||
| 817 | ||
| 818 | /* PROGRAM MAPS */ | |
| 819 | static ADDRESS_MAP_START( mainmem, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 820 | AM_RANGE(0x0000, 0x7fff) AM_ROM | |
| 821 | AM_RANGE(0x8000, 0xbfff) AM_READWRITE(ram_ic_read,ram_ic_write) AM_BASE(&ram_ic) /* Not quite sure how big the RAM IC is. */ | |
| 822 | AM_RANGE(0xc000, 0xdfff) AM_ROM /* This is what Daphne says - we'll soon see. */ | |
| 823 | ADDRESS_MAP_END | |
| 824 | ||
| 825 | static ADDRESS_MAP_START( copmem, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 826 | AM_RANGE(0x000, 0x3ff) AM_ROM /* The schematics seem to claim this is a 2716 (0x800 bytes) - is the dump too small? */ | |
| 827 | ADDRESS_MAP_END | |
| 828 | ||
| 829 | ||
| 830 | /* IO MAPS */ | |
| 831 | static ADDRESS_MAP_START( mainio, ADDRESS_SPACE_IO, 8 ) | |
| 832 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 833 | AM_RANGE(0x00,0x04) AM_WRITE(sc01_register_w) | |
| 834 | AM_RANGE(0x20,0x20) AM_WRITE(write_cop) | |
| 835 | AM_RANGE(0x40,0x40) AM_READ(z80_irq_status_r) | |
| 836 | /* AM_RANGE(0x80,0x80) AM_WRITE(data_write_cop) */ | |
| 837 | AM_RANGE(0xa0,0xa0) AM_WRITE(timer_int_w) | |
| 838 | AM_RANGE(0xc0,0xc0) AM_WRITE(data_ready_int_w) | |
| 839 | ||
| 840 | /* AM_RANGE(0xf0,0xf0) */ /* Laserdisc data read */ | |
| 841 | AM_RANGE(0xf1,0xf1) AM_READ_PORT("DSWB") /* 4 dips, 2 coins, Laserdisc 'ready' and 'enter' pins */ | |
| 842 | AM_RANGE(0xf2,0xf2) AM_READ_PORT("DSWA") /* 8 dips */ | |
| 843 | AM_RANGE(0xf3,0xf3) AM_WRITE(intrq_w) /* goes to /INTRQ */ | |
| 844 | /* AM_RANGE(0xf4,0xf4) */ /* Laserdisc data write */ | |
| 845 | /* AM_RANGE(0xf5,0xf5) */ /* Coin counter, 0xf4 write enable, DIP-controlled (SWB-6) LDV1000 'enter' line, and LDV1000 INT/!EXT line */ | |
| 846 | /* AM_RANGE(0xf6,0xf6) */ /* Scoreboard DEN1 */ | |
| 847 | /* AM_RANGE(0xf7,0xf7) */ /* Scoreboard DEN2 */ | |
| 848 | ADDRESS_MAP_END | |
| 849 | ||
| 850 | static ADDRESS_MAP_START( copio, ADDRESS_SPACE_IO, 8 ) | |
| 851 | AM_RANGE(COP400_PORT_L, COP400_PORT_L) AM_READWRITE(cop_l_read,cop_l_write) | |
| 852 | AM_RANGE(COP400_PORT_G, COP400_PORT_G) AM_READWRITE(cop_g_read,cop_g_write) | |
| 853 | AM_RANGE(COP400_PORT_D, COP400_PORT_D) AM_WRITE(cop_d_write) | |
| 854 | AM_RANGE(COP400_PORT_SK, COP400_PORT_SK) AM_WRITE(cop_sk_write) | |
| 855 | AM_RANGE(COP400_PORT_SIO,COP400_PORT_SIO) AM_READWRITE(port_tag_to_handler8("THAYERS_LETTERS"),cop_sio_write) /* Unemulated in COP40x core, so nothing happens ATM */ | |
| 856 | ADDRESS_MAP_END /* This is also very wrong. The keyboard interface needs to | |
| 857 | be understood much better than what I have here */ | |
| 858 | ||
| 859 | /* PORTS */ | |
| 860 | INPUT_PORTS_START( thayers ) | |
| 861 | PORT_START_TAG("DSWA") | |
| 862 | PORT_DIPNAME( 0x07, 0x07, "Time Per Coin" ) PORT_DIPLOCATION( "A:3,2,1" ) | |
| 863 | PORT_DIPSETTING( 0x07, "110 Seconds" ) | |
| 864 | PORT_DIPSETTING( 0x06, "95 Seconds" ) | |
| 865 | PORT_DIPSETTING( 0x05, "80 Seconds" ) | |
| 866 | PORT_DIPSETTING( 0x04, "70 Seconds" ) | |
| 867 | PORT_DIPSETTING( 0x03, "60 Seconds" ) | |
| 868 | PORT_DIPSETTING( 0x02, "45 Seconds" ) | |
| 869 | PORT_DIPSETTING( 0x01, "30 Seconds" ) | |
| 870 | PORT_DIPSETTING( 0x00, DEF_STR ( Free_Play ) ) | |
| 871 | PORT_DIPNAME( 0x08, 0x08, DEF_STR( Coinage ) ) PORT_DIPLOCATION( "A:4" ) | |
| 872 | PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) ) | |
| 873 | PORT_DIPSETTING( 0x08, DEF_STR( 1C_1C ) ) | |
| 874 | PORT_DIPNAME( 0x10, 0x10, DEF_STR( Lives ) ) PORT_DIPLOCATION( "A:5" ) | |
| 875 | PORT_DIPSETTING( 0x10, "3" ) | |
| 876 | PORT_DIPSETTING( 0x00, "5" ) | |
| 877 | PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION( "A:6" ) | |
| 878 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) | |
| 879 | PORT_DIPSETTING( 0x20, DEF_STR( On ) ) | |
| 880 | PORT_DIPNAME( 0x40, 0x40, "Attract Mode Audio" ) PORT_DIPLOCATION( "A:7" ) | |
| 881 | PORT_DIPSETTING( 0x40, "Always Playing" ) | |
| 882 | PORT_DIPSETTING( 0x00, "One Out of 8 Times" ) | |
| 883 | PORT_DIPUNUSED_DIPLOC( 0x80, IP_ACTIVE_LOW, "A:8" ) | |
| 884 | ||
| 885 | PORT_START_TAG("DSWB") | |
| 886 | PORT_DIPNAME( 0x01, 0x01, "Gameplay Mode" ) PORT_DIPLOCATION( "B:1" ) | |
| 887 | PORT_DIPSETTING( 0x01, "Normal Play" ) | |
| 888 | PORT_DIPSETTING( 0x00, "Self-Diagnostics Mode" ) | |
| 889 | PORT_DIPUNUSED_DIPLOC( 0x02, IP_ACTIVE_LOW, "B:2" ) | |
| 890 | PORT_DIPUNUSED_DIPLOC( 0x04, IP_ACTIVE_LOW, "B:3" ) | |
| 891 | PORT_DIPNAME( 0x08, 0x08, "LD Player" ) PORT_DIPLOCATION( "B:4" ) | |
| 892 | PORT_DIPSETTING( 0x08, "LDV-1000" ) | |
| 893 | PORT_DIPSETTING( 0x00, "PR-7820" ) | |
| 894 | /* DIP SWITCH 5 isn't read here, but it also controls LD player selection - I wonder how to add it properly? */ | |
| 895 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 ) | |
| 896 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) | |
| 897 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(laserdisc_command_r, 0 ) /* Enter pin on LD player */ | |
| 898 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(laserdisc_status_r, 0 ) /* Ready pin on LD player */ | |
| 899 | ||
| 900 | /* The following 3 port definitions can be combined into one (thus making this scheme work) if the port bit limit is raised from 32 to 64 */ | |
| 901 | /* But maybe there's a better way to do it than what I have here? */ | |
| 902 | /* Or maybe this doesn't even work at all :) */ | |
| 903 | /* "Scan codes" heisted from Daphne - need to be tested! */ | |
| 904 | PORT_START_TAG("THAYERS_ACTIONS") | |
| 905 | PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( DEF_STR( No ) ) PORT_CODE( KEYCODE_DEL_PAD ) | |
| 906 | PORT_BIT( 0x31, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( DEF_STR( Yes ) ) PORT_CODE( KEYCODE_0_PAD ) | |
| 907 | PORT_BIT( 0x32, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "Items" ) PORT_CODE( KEYCODE_1_PAD ) | |
| 908 | PORT_BIT( 0x33, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "Drop Item" ) PORT_CODE( KEYCODE_2_PAD ) | |
| 909 | PORT_BIT( 0x34, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "Give Score" ) PORT_CODE( KEYCODE_3_PAD ) | |
| 910 | PORT_BIT( 0x35, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "Replay" ) PORT_CODE( KEYCODE_4_PAD ) | |
| 911 | PORT_BIT( 0x36, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "Combine Action" ) PORT_CODE( KEYCODE_6_PAD ) | |
| 912 | PORT_BIT( 0x37, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "Save Game" ) PORT_CODE( KEYCODE_7_PAD ) | |
| 913 | PORT_BIT( 0x38, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "Update" ) PORT_CODE( KEYCODE_8_PAD ) | |
| 914 | PORT_BIT( 0x39, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "Hint" ) PORT_CODE( KEYCODE_9_PAD ) | |
| 915 | ||
| 916 | PORT_START_TAG("THAYERS_LETTERS") | |
| 917 | PORT_BIT( 0x41, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "A" ) PORT_CODE( KEYCODE_A ) | |
| 918 | PORT_BIT( 0x42, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "B - Silver Wheat" ) PORT_CODE( KEYCODE_B ) | |
| 919 | PORT_BIT( 0x43, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "C - Spell of Seeing" ) PORT_CODE( KEYCODE_C ) | |
| 920 | PORT_BIT( 0x44, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "D - Great Circlet" ) PORT_CODE( KEYCODE_D ) | |
| 921 | PORT_BIT( 0x45, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "E - Black Mace" ) PORT_CODE( KEYCODE_E ) | |
| 922 | PORT_BIT( 0x46, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "F - Hunting Horn" ) PORT_CODE( KEYCODE_F ) | |
| 923 | PORT_BIT( 0x47, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "G - Long Bow" ) PORT_CODE( KEYCODE_G ) | |
| 924 | PORT_BIT( 0x48, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "H - Medallion" ) PORT_CODE( KEYCODE_H ) | |
| 925 | PORT_BIT( 0x49, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "I - Crown" ) PORT_CODE( KEYCODE_I ) | |
| 926 | PORT_BIT( 0x4a, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "J - Onyx Seal" ) PORT_CODE( KEYCODE_J ) | |
| 927 | PORT_BIT( 0x4b, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "K - Orb of Quoid" ) PORT_CODE( KEYCODE_K ) | |
| 928 | PORT_BIT( 0x4c, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "L" ) PORT_CODE( KEYCODE_L ) | |
| 929 | PORT_BIT( 0x4d, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "M - Spell of Understanding" ) PORT_CODE( KEYCODE_M ) | |
| 930 | PORT_BIT( 0x4e, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "N - Staff" ) PORT_CODE( KEYCODE_N ) | |
| 931 | PORT_BIT( 0x4f, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "O - Crystal" ) PORT_CODE( KEYCODE_O ) | |
| 932 | PORT_BIT( 0x50, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "P" ) PORT_CODE( KEYCODE_P ) | |
| 933 | PORT_BIT( 0x51, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "Q" ) PORT_CODE( KEYCODE_Q ) | |
| 934 | PORT_BIT( 0x52, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "R - Blood Sword" ) PORT_CODE( KEYCODE_R ) | |
| 935 | PORT_BIT( 0x53, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "S - Dagger" ) PORT_CODE( KEYCODE_S ) | |
| 936 | PORT_BIT( 0x54, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "T - Chalice" ) PORT_CODE( KEYCODE_T ) | |
| 937 | PORT_BIT( 0x55, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "U - Cold Fire" ) PORT_CODE( KEYCODE_U ) | |
| 938 | PORT_BIT( 0x56, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "V - Shield" ) PORT_CODE( KEYCODE_V ) | |
| 939 | PORT_BIT( 0x57, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "W - Amulet" ) PORT_CODE( KEYCODE_W ) | |
| 940 | PORT_BIT( 0x58, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "X - Scepter" ) PORT_CODE( KEYCODE_X ) | |
| 941 | PORT_BIT( 0x59, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "Y - Coins" ) PORT_CODE( KEYCODE_Y ) | |
| 942 | PORT_BIT( 0x5a, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "Z - Spell of Release" ) PORT_CODE( KEYCODE_Z ) | |
| 943 | ||
| 944 | PORT_START_TAG("THAYERS_NUMBERS") | |
| 945 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "1 - Clear" ) PORT_CODE( KEYCODE_LCONTROL ) | |
| 946 | PORT_BIT( 0x81, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "2" ) PORT_CODE( KEYCODE_RCONTROL ) | |
| 947 | PORT_BIT( 0x82, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "3 - Enter" ) PORT_CODE( KEYCODE_ENTER ) | |
| 948 | PORT_BIT( 0x83, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "4 - Space" ) PORT_CODE( KEYCODE_SPACE ) | |
| 949 | INPUT_PORTS_END | |
| 950 | ||
| 951 | ||
| 952 | static MACHINE_START( thayers ) | |
| 953 | { | |
| 954 | discinfo = laserdisc_init(LASERDISC_TYPE_LDV1000, get_disk_handle(0), 0); | |
| 955 | return; | |
| 956 | } | |
| 957 | ||
| 958 | static INTERRUPT_GEN( vblank_callback_thayers ) | |
| 959 | { | |
| 960 | laserdisc_vsync(discinfo); | |
| 961 | } | |
| 962 | ||
| 963 | ||
| 964 | /* DRIVER */ | |
| 965 | static MACHINE_DRIVER_START( thayers ) | |
| 966 | /* main cpu */ | |
| 967 | MDRV_CPU_ADD(Z80, SCHEMATIC_CLOCK) | |
| 968 | MDRV_CPU_PROGRAM_MAP(mainmem,0) | |
| 969 | MDRV_CPU_IO_MAP(mainio,0) | |
| 970 | MDRV_CPU_VBLANK_INT(vblank_callback_thayers, 1) | |
| 971 | ||
| 972 | MDRV_MACHINE_START(thayers) | |
| 973 | ||
| 974 | /* io device cpu */ | |
| 975 | MDRV_CPU_ADD(COP420, SCHEMATIC_CLOCK/2/8); /* Can't read the schematics, but this is what daphne says */ | |
| 976 | MDRV_CPU_PROGRAM_MAP(copmem,0) | |
| 977 | MDRV_CPU_IO_MAP(copio,0) | |
| 978 | ||
| 979 | /* video */ | |
| 980 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) | |
| 981 | ||
| 982 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) | |
| 983 | MDRV_SCREEN_REFRESH_RATE(60) | |
| 984 | MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION) | |
| 985 | MDRV_SCREEN_SIZE(32*10, 32*8) | |
| 986 | MDRV_SCREEN_VISIBLE_AREA(0*10, 32*10-1, 0*8, 32*8-1) | |
| 987 | ||
| 988 | MDRV_PALETTE_LENGTH(256) | |
| 989 | MDRV_VIDEO_UPDATE(thayers) | |
| 990 | ||
| 991 | /* sound */ | |
| 992 | MACHINE_DRIVER_END | |
| 993 | ||
| 994 | ||
| 995 | ROM_START( thayers ) | |
| 996 | ROM_REGION( 0xe000, REGION_CPU1, 0 ) | |
| 997 | ROM_LOAD( "tq_u33.bin", 0x0000, 0x8000, CRC(82df5d89) SHA1(58dfd62bf8c5a55d1eba397d2c284e99a4685a3f) ) | |
| 998 | ROM_LOAD( "tq_u1.bin", 0xc000, 0x2000, CRC(e8e7f566) SHA1(df7b83ef465c65446c8418bc6007447693b75021) ) | |
| 999 | ||
| 1000 | ROM_REGION( 0x400, REGION_CPU2, 0 ) | |
| 1001 | ROM_LOAD( "tq_cop.bin", 0x000, 0x400, CRC(6748e6b3) SHA1(5d7d1ecb57c1501ef6a2d9691eecc9970586606b) ) | |
| 1002 | ROM_END | |
| 1003 | ||
| 1004 | ROM_START( thayersa ) | |
| 1005 | ROM_REGION( 0xe000, REGION_CPU1, 0 ) | |
| 1006 | ROM_LOAD( "tq_u33.bin", 0x0000, 0x8000, CRC(82df5d89) SHA1(58dfd62bf8c5a55d1eba397d2c284e99a4685a3f) ) | |
| 1007 | ROM_LOAD( "tq_u1.bin", 0xc000, 0x2000, CRC(33817e25) SHA1(f9750da863dd57fe2f5b6e8fce9c6695dc5c9adc) ) | |
| 1008 | ||
| 1009 | ROM_REGION( 0x400, REGION_CPU2, 0 ) | |
| 1010 | ROM_LOAD( "tq_cop.bin", 0x000, 0x400, CRC(6748e6b3) SHA1(5d7d1ecb57c1501ef6a2d9691eecc9970586606b) ) | |
| 1011 | ROM_END | |
| 1012 | ||
| 1013 | static DRIVER_INIT( thayers ) | |
| 1014 | { | |
| 1015 | Z80_IRQ_STATUS_CLEAR(); | |
| 1016 | m_ssi_control = 0; | |
| 1017 | ||
| 1018 | cop_g_latch = 0xff; | |
| 1019 | } | |
| 1020 | ||
| 510 | 1021 | /* YEAR NAME PARENT MACHINE INPUT INIT MONITOR COMPANY FULLNAME FLAGS) */ |
| 511 | 1022 | GAME( 1983, thayers, 0, thayers, thayers, thayers, ROT0, "RDI Video Systems", "Thayer's Quest", GAME_NOT_WORKING|GAME_NO_SOUND) |
| 512 | 1023 | GAME( 1983, thayersa, thayers, thayers, thayers, thayers, ROT0, "RDI Video Systems", "Thayer's Quest (Alternate Set)", GAME_NOT_WORKING|GAME_NO_SOUND) |
| r936 | r937 | |
|---|---|---|
| 1195 | 1195 | |
| 1196 | 1196 | ***************************************************************************/ |
| 1197 | 1197 | |
| 1198 | /*************************************************************************** | |
| 1199 | ||
| 1200 | Super Real Mahjong PI | |
| 1201 | (c)1987 Seta | |
| 1202 | PO-023 | |
| 1203 | M6100242A | |
| 1204 | 860161517 | |
| 1205 | ||
| 1206 | CPU: 68000 | |
| 1207 | Sound: AY-3-8910, M5205 | |
| 1208 | OSC: 8.000MHz(X1) 20.000MHz(X2) | |
| 1209 | Custom chips: X1-003, X2-003(x3), X1-004(x2), X0-005 | |
| 1210 | plus 2 chips covered with heatsink | |
| 1211 | Others: Battery, D8243HC | |
| 1212 | ||
| 1213 | UB0-1.19 [a5960661] 831000 | |
| 1214 | UB0-2.17 [b88dbeba] | | |
| 1215 | UB0-3.18 [6302cfa8] / | |
| 1216 | ||
| 1217 | UB0-4.60 [cb6f7cce] | |
| 1218 | UB0-5.61 [7b48c540] | |
| 1219 | UB0-6.62 [6c891ac5] | |
| 1220 | UB0-7.63 [60a45755] | |
| 1221 | ||
| 1222 | UB0-8.64 [b58024b9] MB83256 | |
| 1223 | UB0-9.65 [e28c2566] | | |
| 1224 | UB0-10.66 [d20a935c] | | |
| 1225 | UB0-11.67 [30957ca8] / | |
| 1226 | ||
| 1227 | UB1.12 [d2ed93c8] MB7124E | |
| 1228 | UB2.13 [7e7d25f7] / | |
| 1229 | ||
| 1230 | UB-3 (PAL16L8A - not dumped) | |
| 1231 | ||
| 1232 | ***************************************************************************/ | |
| 1233 | ||
| 1234 | ROM_START( srmp1 ) | |
| 1235 | ROM_REGION( 0x40000, REGION_CPU1, 0 ) /* 68000 Code */ | |
| 1236 | ROM_LOAD16_BYTE( "ub0-2.17", 0x000000, 0x20000, BAD_DUMP CRC(b88dbeba) SHA1(b4120c09aba6b6696148480f55aeee2f4a82b504) ) // 1ST AND 2ND HALF IDENTICAL | |
| 1237 | ROM_LOAD16_BYTE( "ub0-3.18", 0x000001, 0x20000, BAD_DUMP CRC(6302cfa8) SHA1(214834437c996816e8f63e98f990dc8bce49643a) ) // 1ST AND 2ND HALF IDENTICAL | |
| 1238 | ||
| 1239 | ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_DISPOSE ) /* Sprites */ | |
| 1240 | ROM_LOAD ( "ubo-4.60", 0x000000, 0x040000, CRC(cb6f7cce) SHA1(27d7c2f4f998023081fac1bbacfd4b0b56edaee2) ) | |
| 1241 | ROM_LOAD ( "ubo-5.61", 0x040000, 0x040000, CRC(7b48c540) SHA1(06229caec6846581f95409204ea22f0f76684b08) ) | |
| 1242 | ROM_LOAD16_BYTE( "ub0-8.64", 0x080000, 0x008000, CRC(b58024b9) SHA1(d38750fa90c1b14288884a3c2713b90f0b941bfb) ) | |
| 1243 | ROM_LOAD16_BYTE( "ub0-9.65", 0x080001, 0x008000, CRC(e28c2566) SHA1(91ce9d7138e05f9bcd31dfeaaa558d4431ae9515) ) | |
| 1244 | ROM_LOAD ( "ubo-6.62", 0x100000, 0x040000, CRC(6c891ac5) SHA1(eab595bce16e4cdc465a5e2e029c3949a0f28629) ) | |
| 1245 | ROM_LOAD ( "ubo-7.63", 0x140000, 0x040000, CRC(60a45755) SHA1(22bbf024bbe2186b621389a23697e55d512b501a) ) | |
| 1246 | ROM_LOAD16_BYTE( "ub0-10.66", 0x180000, 0x008000, CRC(d20a935c) SHA1(1d01b0ccfb6c2ea226e16e555796acd10b10e835) ) | |
| 1247 | ROM_LOAD16_BYTE( "ub0-11.67", 0x180001, 0x008000, CRC(30957ca8) SHA1(02aaa3f2f266e8f4db2d35c177546365d7836004) ) | |
| 1248 | ||
| 1249 | ROM_REGION( 0x020000, REGION_SOUND1, 0 ) /* Samples */ | |
| 1250 | ROM_LOAD( "ub0-1.19", 0x000000, 0x20000, CRC(a5960661) SHA1(76e7a58276a7ae245bbe266b50cefa7d03043f77) ) // 1ST AND 2ND HALF IDENTICAL | |
| 1251 | ||
| 1252 | ROM_REGION( 0x800, REGION_PROMS, 0 ) /* Color PROMs */ | |
| 1253 | ROM_LOAD( "ub1.12", 0x000, 0x200, CRC(d2ed93c8) SHA1(334d4fe6fa477758b336b138ffc306e2d6334371) ) | |
| 1254 | ROM_LOAD( "ub2.13", 0x400, 0x200, CRC(7e7d25f7) SHA1(e5bf5071567f95c3bb70347f0b86a9703f9f2e6c) ) | |
| 1255 | ROM_END | |
| 1256 | ||
| 1198 | 1257 | ROM_START( srmp2 ) |
| 1199 | 1258 | ROM_REGION( 0x040000, REGION_CPU1, 0 ) /* 68000 Code */ |
| 1200 | 1259 | ROM_LOAD16_BYTE( "uco-2.17", 0x000000, 0x020000, CRC(0d6c131f) SHA1(be85f2578b0ae2a072565605b7dbeb970e5e3851) ) |
| r936 | r937 | |
| 1322 | 1381 | ROM_END |
| 1323 | 1382 | |
| 1324 | 1383 | |
| 1325 | GAME( 1987, srmp2, 0, srmp2, srmp2, srmp2, ROT0, "Seta", "Super Real Mahjong Part 2 (Japan)", 0 ) | |
| 1326 | GAME( 1988, srmp3, 0, srmp3, srmp3, srmp3, ROT0, "Seta", "Super Real Mahjong Part 3 (Japan)", 0 ) | |
| 1327 | GAME( 1990, mjyuugi, 0, mjyuugi, mjyuugi, 0, ROT0, "Visco", "Mahjong Yuugi (Japan set 1)", 0 ) | |
| 1328 | GAME( 1990, mjyuugia, mjyuugi, mjyuugi, mjyuugi, 0, ROT0, "Visco", "Mahjong Yuugi (Japan set 2)", 0 ) | |
| 1384 | GAME( 1987, srmp1, 0, srmp2, srmp2, 0, ROT0, "Seta", "Super Real Mahjong Part 1 (Japan)", GAME_NOT_WORKING ) | |
| 1385 | GAME( 1987, srmp2, 0, srmp2, srmp2, srmp2, ROT0, "Seta", "Super Real Mahjong Part 2 (Japan)", 0 ) | |
| 1386 | GAME( 1988, srmp3, 0, srmp3, srmp3, srmp3, ROT0, "Seta", "Super Real Mahjong Part 3 (Japan)", 0 ) | |
| 1387 | GAME( 1990, mjyuugi, 0, mjyuugi, mjyuugi, 0, ROT0, "Visco", "Mahjong Yuugi (Japan set 1)", 0 ) | |
| 1388 | GAME( 1990, mjyuugia, mjyuugi, mjyuugi, mjyuugi, 0, ROT0, "Visco", "Mahjong Yuugi (Japan set 2)", 0 ) | |
| 1329 | 1389 | GAME( 1991, ponchin, 0, mjyuugi, ponchin, 0, ROT0, "Visco", "Mahjong Pon Chin Kan (Japan set 1)", 0 ) |
| 1330 | 1390 | GAME( 1991, ponchina, ponchin, mjyuugi, ponchin, 0, ROT0, "Visco", "Mahjong Pon Chin Kan (Japan set 2)", 0 ) |
| r936 | r937 | |
|---|---|---|
| 3036 | 3036 | DISK_IMAGE_READONLY( "706jaa02", 0, MD5(4f096051df039b0d104d4c0fff5dadb8) SHA1(4c8d976096c2da6d01804a44957daf9b50103c90) ) |
| 3037 | 3037 | ROM_END |
| 3038 | 3038 | |
| 3039 | ROM_START( ddrextrm ) | |
| 3040 | ROM_REGION32_LE( 0x080000, REGION_USER1, 0 ) | |
| 3041 | SYS573_BIOS_A | |
| 3042 | ||
| 3043 | ROM_REGION( 0x0001014, REGION_USER2, 0 ) /* security cart eeprom */ | |
| 3044 | ROM_LOAD( "gcc36ja.u1", 0x000000, 0x001014, BAD_DUMP CRC(c1601287) SHA1(929691a78f7bb6dd830f832f301116df0da1619b) ) | |
| 3045 | ||
| 3046 | ROM_REGION( 0x1000000, REGION_USER3, 0 ) /* onboard flash */ | |
| 3047 | ROM_FILL( 0x0000000, 0x1000000, 0xff ) | |
| 3048 | ||
| 3049 | ROM_REGION( 0x2000000, REGION_USER5, 0 ) /* PCCARD2 */ | |
| 3050 | ROM_FILL( 0x0000000, 0x2000000, 0xff ) | |
| 3051 | ||
| 3052 | ROM_REGION( 0x000008, REGION_USER9, 0 ) /* security cart id */ | |
| 3053 | ROM_LOAD( "gcc36ja.u6", 0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) ) | |
| 3054 | ||
| 3055 | DISK_REGION( REGION_DISKS ) | |
| 3056 | DISK_IMAGE_READONLY( "c36jaa02", 0, MD5(83fa51031d826d603c0371b18180aeda) SHA1(a1591cb4f1da7e460de57afb17a85592719243e0) ) | |
| 3057 | ROM_END | |
| 3058 | ||
| 3039 | 3059 | ROM_START( ddru ) |
| 3040 | 3060 | ROM_REGION32_LE( 0x080000, REGION_USER1, 0 ) |
| 3041 | 3061 | SYS573_BIOS_A |
| r936 | r937 | |
| 3072 | 3092 | ROM_LOAD( "gc845ja.u1", 0x000000, 0x000224, NO_DUMP ) |
| 3073 | 3093 | |
| 3074 | 3094 | ROM_REGION( 0x1000000, REGION_USER3, 0 ) /* onboard flash */ |
| 3075 | ROM_LOAD( "gc845ja.31m", 0x000000, 0x200000, NO_DUMP ) | |
| 3076 | ROM_LOAD( "gc845ja.27m", 0x200000, 0x200000, NO_DUMP ) | |
| 3077 | ROM_LOAD( "gc845ja.31l", 0x400000, 0x200000, NO_DUMP ) | |
| 3078 | ROM_LOAD( "gc845ja.27l", 0x600000, 0x200000, NO_DUMP ) | |
| 3079 | ROM_LOAD( "gc845ja.31j", 0x800000, 0x200000, NO_DUMP ) | |
| 3080 | ROM_LOAD( "gc845ja.27j", 0xa00000, 0x200000, NO_DUMP ) | |
| 3081 | ROM_LOAD( "gc845ja.31h", 0xc00000, 0x200000, NO_DUMP ) | |
| 3082 | ROM_LOAD( "gc845ja.27h", 0xe00000, 0x200000, NO_DUMP ) | |
| 3095 | ROM_LOAD( "gc845jaa.31m", 0x000000, 0x200000, NO_DUMP ) | |
| 3096 | ROM_LOAD( "gc845jaa.27m", 0x200000, 0x200000, NO_DUMP ) | |
| 3097 | ROM_LOAD( "gc845jaa.31l", 0x400000, 0x200000, NO_DUMP ) | |
| 3098 | ROM_LOAD( "gc845jaa.27l", 0x600000, 0x200000, NO_DUMP ) | |
| 3099 | ROM_LOAD( "gc845jaa.31j", 0x800000, 0x200000, NO_DUMP ) | |
| 3100 | ROM_LOAD( "gc845jaa.27j", 0xa00000, 0x200000, NO_DUMP ) | |
| 3101 | ROM_LOAD( "gc845jaa.31h", 0xc00000, 0x200000, NO_DUMP ) | |
| 3102 | ROM_LOAD( "gc845jaa.27h", 0xe00000, 0x200000, NO_DUMP ) | |
| 3083 | 3103 | |
| 3084 | 3104 | DISK_REGION( REGION_DISKS ) |
| 3085 | DISK_IMAGE_READONLY( "845ja | |
| 3105 | DISK_IMAGE_READONLY( "845jaa02", 0, MD5(045237 | |
| 3086 | 3106 | DISK_IMAGE_READONLY( "845jaa01", 1, NO_DUMP ) // if this even exists |
| 3087 | 3107 | ROM_END |
| 3088 | 3108 | |
| 3109 | ROM_START( ddrjb ) | |
| 3110 | ROM_REGION32_LE( 0x080000, REGION_USER1, 0 ) | |
| 3111 | SYS573_BIOS_A | |
| 3112 | ||
| 3113 | ROM_REGION( 0x0000224, REGION_USER2, 0 ) /* security cart eeprom */ | |
| 3114 | ROM_LOAD( "gc845ja.u1", 0x000000, 0x000224, NO_DUMP ) | |
| 3115 | ||
| 3116 | ROM_REGION( 0x1000000, REGION_USER3, 0 ) /* onboard flash */ | |
| 3117 | ROM_LOAD( "gc845jab.31m", 0x000000, 0x200000, NO_DUMP ) | |
| 3118 | ROM_LOAD( "gc845jab.27m", 0x200000, 0x200000, NO_DUMP ) | |
| 3119 | ROM_LOAD( "gc845jab.31l", 0x400000, 0x200000, NO_DUMP ) | |
| 3120 | ROM_LOAD( "gc845jab.27l", 0x600000, 0x200000, NO_DUMP ) | |
| 3121 | ROM_LOAD( "gc845jab.31j", 0x800000, 0x200000, NO_DUMP ) | |
| 3122 | ROM_LOAD( "gc845jab.27j", 0xa00000, 0x200000, NO_DUMP ) | |
| 3123 | ROM_LOAD( "gc845jab.31h", 0xc00000, 0x200000, NO_DUMP ) | |
| 3124 | ROM_LOAD( "gc845jab.27h", 0xe00000, 0x200000, NO_DUMP ) | |
| 3125 | ||
| 3126 | DISK_REGION( REGION_DISKS ) | |
| 3127 | DISK_IMAGE_READONLY( "845jab02", 0, MD5(ebaaf265a1a7efae93cd745a67ea2cb2) SHA1(10ee3081065ebf5a814abbd30c8dee91b384a849) ) | |
| 3128 | DISK_IMAGE_READONLY( "845jab01", 1, NO_DUMP ) // if this even exists | |
| 3129 | ROM_END | |
| 3130 | ||
| 3089 | 3131 | ROM_START( ddra ) |
| 3090 | 3132 | ROM_REGION32_LE( 0x080000, REGION_USER1, 0 ) |
| 3091 | 3133 | SYS573_BIOS_A |
| r936 | r937 | |
| 3111 | 3153 | ROM_FILL( 0x0000000, 0x1000000, 0xff ) |
| 3112 | 3154 | |
| 3113 | 3155 | DISK_REGION( REGION_DISKS ) |
| 3114 | DISK_IMAGE_READONLY( "895ja", 0, | |
| 3156 | DISK_IMAGE_READONLY( "895jaa02", 0, | |
| 3115 | 3157 | ROM_END |
| 3116 | 3158 | |
| 3117 | 3159 | ROM_START( ddr2mc ) |
| r936 | r937 | |
| 3126 | 3168 | |
| 3127 | 3169 | DISK_REGION( REGION_DISKS ) |
| 3128 | 3170 | DISK_IMAGE_READONLY( "896jaa01", 0, MD5(3cab3bc6d9459360da8f6784dd861067) SHA1(cb99e52eac5223509e914648d9b5dec59ed242f8) ) |
| 3129 | DISK_IMAGE_READONLY( "895ja", | |
| 3171 | DISK_IMAGE_READONLY( "895jaa02", | |
| 3130 | 3172 | ROM_END |
| 3131 | 3173 | |
| 3132 | 3174 | ROM_START( ddr2mc2 ) |
| r936 | r937 | |
| 3141 | 3183 | |
| 3142 | 3184 | DISK_REGION( REGION_DISKS ) |
| 3143 | 3185 | DISK_IMAGE_READONLY( "984jaa01", 0, MD5(945de47f526007f7c607c398b9b6275a) SHA1(da257e5a553a75439970393bdafc581f6971f946) ) |
| 3144 | DISK_IMAGE_READONLY( "895ja", | |
| 3186 | DISK_IMAGE_READONLY( "895jaa02", | |
| 3145 | 3187 | ROM_END |
| 3146 | 3188 | |
| 3147 | 3189 | ROM_START( ddr2ml ) |
| r936 | r937 | |
| 3488 | 3530 | |
| 3489 | 3531 | DISK_REGION( REGION_DISKS ) |
| 3490 | 3532 | DISK_IMAGE_READONLY( "892jaa01", 0, MD5(b29b63bafdd35f38662ff8daf5fc59f7) SHA1(c929c488d206e055e756ca506c3b1ff430a46aaa) ) |
| 3491 | DISK_IMAGE_READONLY( "895ja", | |
| 3533 | DISK_IMAGE_READONLY( "895jaa02", | |
| 3492 | 3534 | ROM_END |
| 3493 | 3535 | |
| 3494 | 3536 | ROM_START( ddrs2k ) |
| r936 | r937 | |
| 3767 | 3809 | DISK_IMAGE_READONLY( "c23eaa02", 0, MD5(e7275ba9f53334ac528afaa278df7153) SHA1(661f0b53ab64fc746b8e3b7ff3dd32d2bed852ac) ) |
| 3768 | 3810 | ROM_END |
| 3769 | 3811 | |
| 3770 | ROM_START( dst | |
| 3812 | ROM_START( dsfdct | |
| 3771 | 3813 | ROM_REGION32_LE( 0x080000, REGION_USER1, 0 ) |
| 3772 | 3814 | SYS573_BIOS_A |
| 3773 | 3815 | |
| 3774 | ROM_REGION( 0x0000224, REGION_USER2, 0 ) /* security cart eeprom */ | |
| 3775 | ROM_LOAD( "gn845ea.u1", 0x000000, 0x000224, BAD_DUMP CRC(db643af7) SHA1(881221da640b883302e657b906ea0a4e74555679) ) | |
| 3816 | ROM_REGION( 0x0000084, REGION_USER2, 0 ) /* install security cart eeprom */ | |
| 3817 | ROM_LOAD( "ge887ja_gn887ja.u1", 0x000000, 0x000084, BAD_DUMP CRC(08a60147) SHA1(0d39dca5e9e17fff0e64f296c8416e4ca23fdc1b) ) | |
| 3776 | 3818 | |
| 3819 | ROM_REGION( 0x0000084, REGION_USER8, 0 ) /* game security cart eeprom */ | |
| 3820 | ROM_LOAD( "gc910jc.u1", 0x000000, 0x000084, BAD_DUMP CRC(3c1ca973) SHA1(32211a72e3ac88b2723f82dac0b26f93031b3a9c) ) | |
| 3821 | ||
| 3777 | 3822 | ROM_REGION( 0x1000000, REGION_USER3, 0 ) /* onboard flash */ |
| 3778 | 3823 | ROM_FILL( 0x0000000, 0x1000000, 0xff ) |
| 3779 | 3824 | |
| 3825 | ROM_REGION( 0x2000000, REGION_USER5, 0 ) /* PCCARD2 */ | |
| 3826 | ROM_FILL( 0x0000000, 0x2000000, 0xff ) | |
| 3827 | ||
| 3828 | ROM_REGION( 0x000008, REGION_USER9, 0 ) /* install security cart id */ | |
| 3829 | ROM_LOAD( "ge887ja_gn887ja.u6", 0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) ) | |
| 3830 | ||
| 3831 | ROM_REGION( 0x000008, REGION_USER10, 0 ) /* game security cart id */ | |
| 3832 | ROM_LOAD( "gc910jc.u6", 0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) ) | |
| 3833 | ||
| 3780 | 3834 | DISK_REGION( REGION_DISKS ) |
| 3781 | DISK_IMAGE_READONLY( " | |
| 3835 | DISK_IMAGE_READONLY( "910jca02", 0, | |
| 3782 | 3836 | ROM_END |
| 3783 | 3837 | |
| 3838 | ROM_START( dsfdcta ) | |
| 3839 | ROM_REGION32_LE( 0x080000, REGION_USER1, 0 ) | |
| 3840 | SYS573_BIOS_A | |
| 3841 | ||
| 3842 | ROM_REGION( 0x0000084, REGION_USER2, 0 ) /* install security cart eeprom */ | |
| 3843 | ROM_LOAD( "gn884ja.u1", 0x000000, 0x000084, BAD_DUMP CRC(ce6b98ce) SHA1(75549d9470345ce06d2706d373b19416d97e5b9a) ) | |
| 3844 | ||
| 3845 | ROM_REGION( 0x0000084, REGION_USER8, 0 ) /* game security cart eeprom */ | |
| 3846 | ROM_LOAD( "gc910ja.u1", 0x000000, 0x000084, BAD_DUMP CRC(59a23808) SHA1(fcff1c68ff6cfbd391ac997a40fb5253fc62de82) ) | |
| 3847 | ||
| 3848 | ROM_REGION( 0x1000000, REGION_USER3, 0 ) /* onboard flash */ | |
| 3849 | ROM_FILL( 0x0000000, 0x1000000, 0xff ) | |
| 3850 | ||
| 3851 | ROM_REGION( 0x2000000, REGION_USER5, 0 ) /* PCCARD2 */ | |
| 3852 | ROM_FILL( 0x0000000, 0x2000000, 0xff ) | |
| 3853 | ||
| 3854 | ROM_REGION( 0x000008, REGION_USER9, 0 ) /* install security cart id */ | |
| 3855 | ROM_LOAD( "gn884ja.u6", 0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) ) | |
| 3856 | ||
| 3857 | ROM_REGION( 0x000008, REGION_USER10, 0 ) /* game security cart id */ | |
| 3858 | ROM_LOAD( "gc910ja.u6", 0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) ) | |
| 3859 | ||
| 3860 | DISK_REGION( REGION_DISKS ) | |
| 3861 | DISK_IMAGE_READONLY( "910jaa02", 0, MD5(e5380280b5cbb10822391f74866f8bee) SHA1(3d17320f56be7edb1be6b1bd53269d452f71123d) ) | |
| 3862 | ROM_END | |
| 3863 | ||
| 3784 | 3864 | ROM_START( dsftkd ) |
| 3785 | 3865 | ROM_REGION32_LE( 0x080000, REGION_USER1, 0 ) |
| 3786 | 3866 | SYS573_BIOS_A |
| r936 | r937 | |
| 3798 | 3878 | DISK_IMAGE_READONLY( "884jaa02", 0, MD5(d73444ab74efb8587c2bf455e3ec0d13) SHA1(92522380b92333b10d401fda4f81592073f3e601) ) |
| 3799 | 3879 | ROM_END |
| 3800 | 3880 | |
| 3881 | ROM_START( dstage ) | |
| 3882 | ROM_REGION32_LE( 0x080000, REGION_USER1, 0 ) | |
| 3883 | SYS573_BIOS_A | |
| 3884 | ||
| 3885 | ROM_REGION( 0x0000224, REGION_USER2, 0 ) /* security cart eeprom */ | |
| 3886 | ROM_LOAD( "gn845ea.u1", 0x000000, 0x000224, BAD_DUMP CRC(db643af7) SHA1(881221da640b883302e657b906ea0a4e74555679) ) | |
| 3887 | ||
| 3888 | ROM_REGION( 0x1000000, REGION_USER3, 0 ) /* onboard flash */ | |
| 3889 | ROM_FILL( 0x0000000, 0x1000000, 0xff ) | |
| 3890 | ||
| 3891 | DISK_REGION( REGION_DISKS ) | |
| 3892 | DISK_IMAGE_READONLY( "845ea", 0, BAD_DUMP MD5(32d52ee2b37559d7413788c87085f37c) SHA1(e82610e1a34fba144499f9ee892ac882d1e96853) ) | |
| 3893 | ROM_END | |
| 3894 | ||
| 3801 | 3895 | ROM_START( fbait2bc ) |
| 3802 | 3896 | ROM_REGION32_LE( 0x080000, REGION_USER1, 0 ) |
| 3803 | 3897 | SYS573_BIOS_A |
| r936 | r937 | |
| 4211 | 4305 | GAME( 1999, dstage, sys573, konami573, ddr, ddr, ROT0, "Konami", "Dancing Stage (GN845 VER. EAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 4212 | 4306 | GAME( 1999, ddru, dstage, konami573, ddr, ddr, ROT0, "Konami", "Dance Dance Revolution (GN845 VER. UAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 4213 | 4307 | GAME( 1998, ddrj, dstage, konami573, ddr, ddr, ROT0, "Konami", "Dance Dance Revolution - Internet Ranking Ver (GC845 VER. JBA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 4214 | GAME( 1998, ddrja, dstage, konami573, ddr, ddr, ROT0, "Konami", "Dance Dance Revolution (GC845 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) | |
| 4308 | GAME( 1998, ddrja, dstage, konami573, ddr, ddr, ROT0, "Konami", "Dance Dance Revolution (GC845 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) | |
| 4309 | GAME( 1998, ddrjb, dstage, konami573, ddr, ddr, ROT0, "Konami", "Dance Dance Revolution (GC845 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) | |
| 4215 | 4310 | GAME( 1999, ddra, dstage, konami573, ddr, ddr, ROT0, "Konami", "Dance Dance Revolution (GN845 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 4216 | 4311 | GAME( 1998, fbait2bc, sys573, konami573, fbaitbc, ge765pwbba, ROT0, "Konami", "Fisherman's Bait 2 - A Bass Challenge (GE865 VER. UAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 4217 | 4312 | GAME( 1999, drmn, sys573, konami573, drmn, drmn, ROT0, "Konami", "DrumMania (GQ881 VER. JAD)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) |
| r936 | r937 | |
| 4230 | 4325 | GAME( 1999, ddr2mc2, ddr2m, konami573, ddr, ddr, ROT0, "Konami", "Dance Dance Revolution 2nd Mix with beatmaniaIIDX substream CLUB VERSiON 2 (GE984 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 4231 | 4326 | GAME( 1999, gtrfrk2m, sys573, konami573, gtrfrks, gtrfrks, ROT0, "Konami", "Guitar Freaks 2nd Mix Ver 1.01 (GQ883 VER. JAD)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 4232 | 4327 | GAME( 1999, dsftkd, sys573, konami573, ddr, ddr, ROT0, "Konami", "Dancing Stage featuring TRUE KiSS DESTiNATiON (G*884 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 4328 | GAME( 2000, ddr3mk, sys573, konami573, ddr, ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix - Ver.Korea2 (GN887 VER. KBA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.3 */ | |
| 4329 | GAME( 2000, ddr3mka, ddr3mk, konami573, ddr, ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix - Ver.Korea (GN887 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.3 */ | |
| 4330 | GAME( 1999, ddr3ma, ddr3mk, konami573, ddr, ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix (GN887 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.1 */ | |
| 4331 | GAME( 1999, ddr3mj, ddr3mk, konami573, ddr, ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix (GN887 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.0 */ | |
| 4233 | 4332 | GAME( 1999, ddrsbm, sys573, konami573, ddrsolo, ddrsolo, ROT0, "Konami", "Dance Dance Revolution Solo Bass Mix (GQ894 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) |
| 4234 | 4333 | GAME( 1999, ddrs2k, sys573, konami573, ddrsolo, ddrsolo, ROT0, "Konami", "Dance Dance Revolution Solo 2000 (GC905 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.3 */ |
| 4235 | 4334 | GAME( 1999, ddrs2kj, ddrs2k, konami573, ddrsolo, ddrsolo, ROT0, "Konami", "Dance Dance Revolution Solo 2000 (GC905 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.2 */ |
| 4335 | GAME( 1999, dsfdct, sys573, konami573, ddr, ddrdigital, ROT0, "Konami", "Dancing Stage featuring Dreams Come True (GC910 VER. JCA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) | |
| 4336 | GAME( 1999, dsfdcta, dsfdct, konami573, ddr, ddr, ROT0, "Konami", "Dancing Stage featuring Dreams Come True (GC910 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) | |
| 4236 | 4337 | GAME( 1999, drmn2m, sys573, konami573, drmn, drmndigital,ROT0, "Konami", "DrumMania 2nd Mix (GE912 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.5 */ |
| 4237 | GAME( 2000, ddr3mk, sys573, konami573, ddr, ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix - Ver.Korea2 (GN887 VER. KBA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.3 */ | |
| 4238 | GAME( 2000, ddr3mka, ddr3mk, konami573, ddr, ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix - Ver.Korea (GN887 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.3 */ | |
| 4239 | GAME( 1999, ddr3ma, ddr3mk, konami573, ddr, ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix (GN887 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.1 */ | |
| 4240 | GAME( 1999, ddr3mj, ddr3mk, konami573, ddr, ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix (GN887 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.0 */ | |
| 4241 | 4338 | GAME( 2000, dncfrks, sys573, konami573, dmx, dmx, ROT0, "Konami", "Dance Freaks (G*874 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.6 */ |
| 4242 | 4339 | GAME( 2000, dmx, dncfrks, konami573, dmx, dmx, ROT0, "Konami", "Dance Maniax (G*874 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.6 */ |
| 4243 | 4340 | GAME( 2000, gtrfrk3m, sys573, konami573, gtrfrks, gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 3rd Mix (GE949 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.4 */ |
| r936 | r937 | |
| 4261 | 4358 | GAME( 2001, ddrmax, sys573, konami573, ddr, ddrdigital, ROT0, "Konami", "DDR Max - Dance Dance Revolution 6th Mix (G*B19 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */ |
| 4262 | 4359 | GAME( 2002, ddrmax2, sys573, konami573, ddr, ddrdigital, ROT0, "Konami", "DDR Max 2 - Dance Dance Revolution 7th Mix (G*B20 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */ |
| 4263 | 4360 | GAME( 2002, dsem2, sys573, konami573, ddr, ddrdigital, ROT0, "Konami", "Dancing Stage Euro Mix 2 (G*C23 VER. EAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */ |
| 4361 | GAME( 2002, ddrextrm, sys573, konami573, ddr, ddrdigital, ROT0, "Konami", "Dance Dance Revolution Extreme (G*C36 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */ | |
| 4264 | 4362 | GAME( 2004, gtfrk11m, sys573, konami573, gtrfrks, gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 11th Mix (G*D39 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */ |
| r936 | r937 | |
|---|---|---|
| 370 | 370 | |
| 371 | 371 | static void protection_hit_jsr(UINT32 work_ram1,UINT32 work_ram2) |
| 372 | 372 | { |
| 373 | | |
| 373 | | |
| 374 | 374 | x1 = (program_read_word(work_ram1+0x8)); |
| 375 | 375 | y1 = (program_read_word(work_ram1+0x4)); |
| 376 | 376 | //hit1 = (program_read_word(work_ram1-));//this sprite is attacking |
| r936 | r937 | |
| 382 | 382 | |
| 383 | 383 | if((x1 >= (x2-0x80)) && |
| 384 | 384 | (x1 <= (x2+0x80)) && |
| 385 | (y1 >= (y | |
| 385 | (y1 >= (y2-3)) && | |
| 386 | 386 | (y1 <= (y2+3))) |
| 387 | 387 | hit_check = 0; |
| 388 | 388 | else |
| r936 | r937 | |
|---|---|---|
| 51 | 51 | UINT8 pen = dp[index++]; |
| 52 | 52 | if (pen) |
| 53 | 53 | { |
| 54 | p[i] = | |
| 54 | p[i] = Machine->remapped_colortable[gfx->color_base + (att & 0xf)]; | |
| 55 | 55 | } |
| 56 | 56 | else |
| 57 | 57 | { |
| 58 | p[i] = | |
| 58 | p[i] = Machine->remapped_colortable[gfx->color_base + ((att >> 4) & 0x7)]; | |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | } |
| r936 | r937 | |
|---|---|---|
| 1 | /* | |
| 1 | /********************************************************************************************************************* | |
| 2 | 2 | |
| 3 | Last Fighting | |
| 4 | (c) 2000 Subsino | |
| 3 | Last Fighting (C)2000 Subsino | |
| 5 | 4 | |
| 6 | | |
| 5 | driver by Luca | |
| 7 | 6 | |
| 8 | ||
| 9 | 7 | PCB Layout |
| 10 | 8 | ---------- |
| 11 | 9 | |
| r936 | r937 | |
| 34 | 32 | | | |-------| | |7032 | | |
| 35 | 33 | | | CN2 | |-----| 3V_BATT| |
| 36 | 34 | |-----|-------------------|----------------------------| |
| 35 | ||
| 37 | 36 | Notes: |
| 38 | 37 | H8/3044 - Subsino re-badged Hitachi H8/3044 HD6433044A22F Microcontroller (QFP100) |
| 39 | 38 | The H8/3044 is a H8/3002 with 24bit address bus and has 32k MASKROM and 2k RAM, clock input is 16.000MHz [32/2] |
| r936 | r937 | |
| 61 | 60 | V106.U16 - MX27C4000 4MBit DIP32 EPROM; Main Program |
| 62 | 61 | V100.U7 - ST M27C801 8MBit DIP32 EPROM; Audio Samples? |
| 63 | 62 | |
| 64 | */ | |
| 63 | *********************************************************************************************************************/ | |
| 65 | 64 | |
| 66 | 65 | #include "driver.h" |
| 67 | 66 | #include "cpu/h83002/h83002.h" |
| 68 | 67 | |
| 69 | static int clr_offset=0; | |
| 68 | /*************************************************************************** | |
| 69 | Video Hardware | |
| 70 | ***************************************************************************/ | |
| 70 | 71 | |
| 71 | INPUT_PORTS_START( lastfght ) | |
| 72 | INPUT_PORTS_END | |
| 72 | static mame_bitmap *lastfght_bitmap[2]; | |
| 73 | static int clr_offset; | |
| 74 | static int lastfght_dest; | |
| 73 | 75 | |
| 74 | 76 | static VIDEO_START( lastfght ) |
| 75 | 77 | { |
| 78 | int i; | |
| 79 | for (i = 0; i < 2; i++) | |
| 80 | lastfght_bitmap[i] = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format); | |
| 81 | ||
| 82 | colorram = auto_malloc(256*3); | |
| 76 | 83 | } |
| 77 | 84 | |
| 85 | ||
| 78 | 86 | static VIDEO_UPDATE( lastfght ) |
| 79 | 87 | { |
| 80 | int x,y; | |
| 81 | int count; | |
| 82 | static int base = 0; | |
| 88 | #ifdef MAME_DEBUG | |
| 89 | #if 1 | |
| 90 | // gfx roms viewer (toggle with enter, use pgup/down to browse) | |
| 91 | int x, y, count = 0; | |
| 92 | static unsigned base = 0; | |
| 93 | static int view_roms = 0; | |
| 94 | UINT8 *gfxdata = memory_region( REGION_GFX1 ); | |
| 95 | UINT8 data; | |
| 83 | 96 | |
| 84 | fillbitmap( bitmap, get_black_pen(machine), cliprect ); | |
| 85 | fillbitmap( priority_bitmap, 0, cliprect ); | |
| 97 | if ( input_code_pressed_once(KEYCODE_ENTER) ) view_roms ^= 1; | |
| 98 | if ( view_roms ) | |
| 99 | { | |
| 100 | if ( input_code_pressed_once(KEYCODE_PGDN) ) base += 512 * 256; | |
| 101 | if ( input_code_pressed_once(KEYCODE_PGUP) ) base -= 512 * 256; | |
| 102 | base %= memory_region_length( REGION_GFX1 ); | |
| 86 | 103 | |
| 87 | if ( input_code_pressed_once(KEYCODE_Z) ) | |
| 88 | base += 512*512; | |
| 104 | count = base; | |
| 89 | 105 | |
| 90 | if ( input_code_pressed_once(KEYCODE_X) ) | |
| 91 | base -= 512*512; | |
| 92 | ||
| 93 | count = base; | |
| 94 | ||
| 95 | for (y=0;y<512;y++) | |
| 96 | { | |
| 97 | for (x=0;x<512;x++) | |
| 106 | fillbitmap( bitmap, get_black_pen(machine), cliprect ); | |
| 107 | for ( y = 0 ; y < 256; y++ ) | |
| 98 | 108 | { |
| 99 | UINT8 *gfxdata = memory_region( REGION_GFX1 ); | |
| 100 | *BITMAP_ADDR16(bitmap, y, x) = gfxdata[count]; | |
| 101 | count++; | |
| 109 | for ( x = 0; x < 512; x++ ) | |
| 110 | { | |
| 111 | data = ( ((count&0xf)==0)&&((count&0x1e00)==0) )? get_white_pen(Machine) : gfxdata[count]; // white grid or data | |
| 112 | *BITMAP_ADDR16(bitmap, y, x) = data; | |
| 113 | count++; | |
| 114 | } | |
| 102 | 115 | } |
| 116 | popmessage("%x",base); | |
| 117 | return 0; | |
| 103 | 118 | } |
| 119 | #endif | |
| 120 | #endif | |
| 104 | 121 | |
| 105 | if(input_code_pressed(KEYCODE_Q)) | |
| 122 | copybitmap(bitmap,lastfght_bitmap[lastfght_dest^1],0,0,0,0,&machine->screen[0].visarea,TRANSPARENCY_NONE,0); | |
| 123 | ||
| 124 | return 0; | |
| 125 | } | |
| 126 | ||
| 127 | // Palette: HMC HM86171 VGA 256 colour RAMDAC | |
| 128 | ||
| 129 | static WRITE16_HANDLER(colordac_w) | |
| 130 | { | |
| 131 | if (ACCESSING_LSB) | |
| 106 | 132 | { |
| 107 | cpunum_set_input_line(0, 0, PULSE_LINE); | |
| 133 | colorram[clr_offset] = data; | |
| 134 | palette_set_color_rgb(Machine, clr_offset/3, | |
| 135 | pal6bit(colorram[(clr_offset/3)*3+0]), | |
| 136 | pal6bit(colorram[(clr_offset/3)*3+1]), | |
| 137 | pal6bit(colorram[(clr_offset/3)*3+2]) | |
| 138 | ); | |
| 139 | clr_offset = (clr_offset+1) % (256*3); | |
| 108 | 140 | } |
| 109 | 141 | |
| 110 | if( | |
| 142 | if (A | |
| 111 | 143 | { |
| 112 | c | |
| 144 | clr | |
| 113 | 145 | } |
| 146 | } | |
| 114 | 147 | |
| 115 | if(input_code_pressed(KEYCODE_E)) | |
| 148 | // Blitter (supports zooming) | |
| 149 | ||
| 150 | static int lastfght_hi, lastfght_sx, lastfght_sx1, lastfght_dsx, lastfght_sy, lastfght_sy1, lastfght_dsy, lastfght_sp, lastfght_sr; | |
| 151 | static int lastfght_x, lastfght_y, lastfght_w, lastfght_h; | |
| 152 | ||
| 153 | // high byte of a 16 bit register | |
| 154 | static WRITE16_HANDLER( lastfght_hi_w ) | |
| 155 | { | |
| 156 | if (ACCESSING_MSB) logerror("%06x: 600000.b = %02x\n", activecpu_get_pc(),data>>8); | |
| 157 | if (ACCESSING_LSB) | |
| 116 | 158 | { |
| 117 | cpunum_set_input_line(0, 2, PULSE_LINE); | |
| 159 | lastfght_hi = data << 8; | |
| 160 | //logerror("%06x: lastfght_hi = %02x\n", activecpu_get_pc(),data); | |
| 118 | 161 | } |
| 119 | ||
| 120 | if(input_code_pressed(KEYCODE_R)) | |
| 162 | } | |
| 163 | // screen x | |
| 164 | static WRITE16_HANDLER( lastfght_x_w ) | |
| 165 | { | |
| 166 | if (ACCESSING_MSB) logerror("%06x: 800008.b = %02x\n", activecpu_get_pc(),data>>8); | |
| 167 | if (ACCESSING_LSB) | |
| 121 | 168 | { |
| 122 | cpunum_set_input_line(0, 3, PULSE_LINE); | |
| 169 | lastfght_x = lastfght_hi | data; | |
| 170 | //logerror("%06x: lastfght_x = %02x\n", activecpu_get_pc(),data); | |
| 123 | 171 | } |
| 124 | ||
| 125 | if(input_code_pressed(KEYCODE_T)) | |
| 172 | } | |
| 173 | // screen y, screen width - 1 | |
| 174 | static WRITE16_HANDLER( lastfght_yw_w ) | |
| 175 | { | |
| 176 | if (ACCESSING_MSB) | |
| 126 | 177 | { |
| 127 | cpunum_set_input_line(0, 4, PULSE_LINE); | |
| 178 | lastfght_y = lastfght_hi | (data >> 8); | |
| 179 | //logerror("%06x: lastfght_y = %02x\n", activecpu_get_pc(),data>>8); | |
| 128 | 180 | } |
| 129 | ||
| 130 | if(input_code_pressed(KEYCODE_Y)) | |
| 181 | if (ACCESSING_LSB) | |
| 131 | 182 | { |
| 132 | cpunum_set_input_line(0, 5, PULSE_LINE); | |
| 183 | lastfght_w = lastfght_hi | data; | |
| 184 | //logerror("%06x: lastfght_w = %02x\n", activecpu_get_pc(),data); | |
| 133 | 185 | } |
| 134 | ||
| 135 | if(input_code_pressed(KEYCODE_U)) | |
| 186 | } | |
| 187 | // screen height - 1 | |
| 188 | static WRITE16_HANDLER( lastfght_h_w ) | |
| 189 | { | |
| 190 | if (ACCESSING_MSB) | |
| 136 | 191 | { |
| 137 | cpunum_set_input_line(0, 6, PULSE_LINE); | |
| 192 | lastfght_h = lastfght_hi | (data >> 8); | |
| 193 | //logerror("%06x: lastfght_h = %02x\n", activecpu_get_pc(),data>>8); | |
| 138 | 194 | } |
| 139 | ||
| 140 | if(input_code_pressed(KEYCODE_I)) | |
| 195 | if (ACCESSING_LSB) logerror("%06x: 80000d.b = %02x\n", activecpu_get_pc(),data); | |
| 196 | } | |
| 197 | // source delta x << 6, source x << 6 | |
| 198 | static WRITE16_HANDLER( lastfght_sx_w ) | |
| 199 | { | |
| 200 | if (ACCESSING_MSB) | |
| 141 | 201 | { |
| 142 | cpunum_set_input_line(0, 7, PULSE_LINE); | |
| 202 | lastfght_dsx = lastfght_hi | (data >> 8); | |
| 203 | //logerror("%06x: lastfght_dsx = %02x\n", activecpu_get_pc(),data>>8); | |
| 143 | 204 | } |
| 144 | return 0; | |
| 205 | if (ACCESSING_LSB) | |
| 206 | { | |
| 207 | lastfght_sx = lastfght_hi | data; | |
| 208 | //logerror("%06x: lastfght_sx = %02x\n", activecpu_get_pc(),data); | |
| 209 | } | |
| 145 | 210 | } |
| 146 | ||
| 147 | static WRITE16_HANDLER(colordac_w) | |
| 211 | // source y << 6, source y1 << 6 | |
| 212 | static WRITE16_HANDLER( lastfght_sy_w ) | |
| 148 | 213 | { |
| 149 | if(ACCESSING_ | |
| 214 | if (ACCESSING_MSB) | |
| 150 | 215 | { |
| 151 | colorram[clr_offset]=data; | |
| 152 | palette_set_color_rgb(Machine,clr_offset/3,pal6bit(colorram[(clr_offset/3)*3]),pal6bit(colorram[(clr_offset/3)*3+1]),pal6bit(colorram[(clr_offset/3)*3+2])); | |
| 153 | clr_offset=(clr_offset+1)%768; | |
| 216 | lastfght_sy = lastfght_hi | (data >> 8); | |
| 217 | //logerror("%06x: lastfght_sy = %02x\n", activecpu_get_pc(),data>>8); | |
| 154 | 218 | } |
| 155 | ||
| 156 | if(ACCESSING_MSB) | |
| 219 | if (ACCESSING_LSB) | |
| 157 | 220 | { |
| 158 | clr_offset=(data>>8)*3; | |
| 221 | lastfght_sy1 = lastfght_hi | data; | |
| 222 | //logerror("%06x: lastfght_sy1 = %02x\n", activecpu_get_pc(),data); | |
| 159 | 223 | } |
| 160 | 224 | } |
| 225 | // source rom (0x200000 bytes), source page (512x256 bytes) | |
| 226 | static WRITE16_HANDLER( lastfght_sr_w ) | |
| 227 | { | |
| 228 | if (ACCESSING_MSB) | |
| 229 | { | |
| 230 | lastfght_sp = (lastfght_hi>>8) >> 4; | |
| 231 | //logerror("%06x: lastfght_sp = %02x\n", activecpu_get_pc(),data>>8); | |
| 232 | } | |
| 233 | if (ACCESSING_LSB) | |
| 234 | { | |
| 235 | lastfght_sr = data; | |
| 236 | //logerror("%06x: lastfght_sr = %02x\n", activecpu_get_pc(),data); | |
| 237 | } | |
| 238 | } | |
| 239 | // source x1 << 6, source delta y << 6 | |
| 240 | static WRITE16_HANDLER( lastfght_sd_w ) | |
| 241 | { | |
| 242 | if (ACCESSING_MSB) | |
| 243 | { | |
| 244 | lastfght_sx1 = lastfght_hi | (data >> 8); | |
| 245 | //logerror("%06x: lastfght_sx1 = %02x\n", activecpu_get_pc(),data>>8); | |
| 246 | } | |
| 247 | if (ACCESSING_LSB) | |
| 248 | { | |
| 249 | lastfght_dsy = lastfght_hi | data; | |
| 250 | //logerror("%06x: lastfght_dsy = %02x\n", activecpu_get_pc(),data); | |
| 251 | } | |
| 252 | } | |
| 253 | // start blit | |
| 254 | static WRITE16_HANDLER( lastfght_blit_w ) | |
| 255 | { | |
| 256 | if (ACCESSING_MSB) | |
| 257 | { | |
| 258 | int x,y, addr; | |
| 259 | UINT8 *gfxdata = memory_region( REGION_GFX1 ); | |
| 260 | mame_bitmap *dest = lastfght_bitmap[lastfght_dest]; | |
| 161 | 261 | |
| 262 | #if 0 | |
| 263 | logerror("%06x: blit x %03x, y %03x, w %03x, h %03x, sx %03x.%02x, sx1 %03x.%02x, dsx %03x.%02x, sy %03x.%02x, sy1 %03x.%02x, dsy %03x.%02x, sp %02x, sr %02x, data %02x\n", activecpu_get_pc(), | |
| 264 | lastfght_x,lastfght_y,lastfght_w+1,lastfght_h+1, | |
| 265 | lastfght_sx>>6,lastfght_sx&0x3f, lastfght_sx1>>6,lastfght_dsx&0x3f, lastfght_sx1>>6,lastfght_sx1&0x3f, | |
| 266 | lastfght_sy>>6,lastfght_sy&0x3f, lastfght_sy1>>6,lastfght_dsy&0x3f, lastfght_sy1>>6,lastfght_sy1&0x3f, | |
| 267 | lastfght_sp,lastfght_sr, | |
| 268 | data>>8 ); | |
| 269 | #endif | |
| 270 | ||
| 271 | for (y = 0; y <= lastfght_h; y++) | |
| 272 | { | |
| 273 | for (x = 0; x <= lastfght_w; x++) | |
| 274 | { | |
| 275 | addr = (( (lastfght_sx + lastfght_sx1 + lastfght_dsx * x) >> 6 ) & 0x1ff) + | |
| 276 | (( (lastfght_sy + lastfght_sy1 + lastfght_dsy * y) >> 6 ) & 0xff ) * 0x200 + | |
| 277 | lastfght_sp * 0x200 * 0x100 + | |
| 278 | lastfght_sr * 0x200000; | |
| 279 | ||
| 280 | data = gfxdata[addr]; | |
| 281 | ||
| 282 | if (data && (lastfght_x + x >= 0) && (lastfght_x + x < 512) && (lastfght_y + y >= 0) && (lastfght_y + y < 256)) | |
| 283 | *BITMAP_ADDR16(dest, lastfght_y + y, lastfght_x + x) = data; | |
| 284 | } | |
| 285 | } | |
| 286 | } | |
| 287 | if (ACCESSING_LSB) logerror("%06x: 600007.b = %02x\n", activecpu_get_pc(),data); | |
| 288 | } | |
| 289 | // toggle framebuffer | |
| 290 | static WRITE16_HANDLER( lastfght_dest_w ) | |
| 291 | { | |
| 292 | if (ACCESSING_LSB) lastfght_dest ^= 1; | |
| 293 | } | |
| 294 | ||
| 295 | static READ16_HANDLER( lastfght_c00000_r ) | |
| 296 | { | |
| 297 | // high byte: | |
| 298 | // bit 7 = blitter busy | |
| 299 | // bit 6 = blitter? | |
| 300 | return 0x4000; | |
| 301 | ||
| 302 | } | |
| 303 | ||
| 304 | static READ16_HANDLER( lastfght_c00002_r ) | |
| 305 | { | |
| 306 | // high byte: | |
| 307 | // mask 0x1c: from sound? | |
| 308 | return (mame_rand(Machine) & 0x1c00) | readinputport(0); | |
| 309 | } | |
| 310 | ||
| 311 | static READ16_HANDLER( lastfght_c00004_r ) | |
| 312 | { | |
| 313 | return readinputport(1); | |
| 314 | } | |
| 315 | ||
| 316 | static READ16_HANDLER( lastfght_c00006_r ) | |
| 317 | { | |
| 318 | // low byte: | |
| 319 | // bit 7 = protection? | |
| 320 | // bit 5 = blitter? | |
| 321 | return readinputport(2); | |
| 322 | } | |
| 323 | ||
| 324 | static WRITE16_HANDLER( lastfght_c00006_w ) | |
| 325 | { | |
| 326 | static UINT16 val = 0; | |
| 327 | COMBINE_DATA(&val); | |
| 328 | // popmessage("%04x",val); | |
| 329 | } | |
| 330 | ||
| 331 | static READ16_HANDLER( lastfght_sound_r ) | |
| 332 | { | |
| 333 | // low byte: | |
| 334 | // bit 3 | |
| 335 | return 8; | |
| 336 | } | |
| 337 | ||
| 338 | static WRITE16_HANDLER( lastfght_sound_w ) | |
| 339 | { | |
| 340 | if (ACCESSING_MSB) logerror("%06x: sound_w msb = %02x\n", activecpu_get_pc(),data>>8); | |
| 341 | if (ACCESSING_LSB) logerror("%06x: sound_w lsb = %02x\n", activecpu_get_pc(),data); | |
| 342 | } | |
| 343 | ||
| 344 | /*************************************************************************** | |
| 345 | Memory Maps | |
| 346 | ***************************************************************************/ | |
| 347 | ||
| 162 | 348 | static ADDRESS_MAP_START( lastfght_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| 163 | 349 | ADDRESS_MAP_FLAGS( AMEF_ABITS(24) ) |
| 164 | AM_RANGE(0x000000, 0x07ffff) AM_ROM AM_REGION(REGION_CPU1, 0) | |
| 165 | AM_RANGE(0x080000, 0x0fffff) AM_ROM AM_REGION(REGION_CPU1, 0) | |
| 166 | AM_RANGE(0x200000, 0x20ffff) AM_RAM | |
| 167 | AM_RANGE(0x600008, 0x600009) AM_WRITE(colordac_w) | |
| 168 | AM_RANGE(0x800000, 0x80001f) AM_RAM // blitter regs ? | |
| 169 | AM_RANGE(0xc00000, 0xc0001f) AM_RAM // protection ? | |
| 170 | AM_RANGE(0xff0000, 0xffffff) AM_RAM | |
| 350 | ||
| 351 | AM_RANGE( 0x000000, 0x07ffff ) AM_ROM AM_REGION(REGION_CPU1, 0) | |
| 352 | AM_RANGE( 0x080000, 0x0fffff ) AM_ROM AM_REGION(REGION_CPU1, 0) | |
| 353 | ||
| 354 | AM_RANGE( 0x200000, 0x20ffff ) AM_RAM AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size) // battery | |
| 355 | ||
| 356 | AM_RANGE( 0x600000, 0x600001 ) AM_WRITE( lastfght_hi_w ) | |
| 357 | AM_RANGE( 0x600002, 0x600003 ) AM_READWRITE( lastfght_sound_r, lastfght_sound_w ) | |
| 358 | AM_RANGE( 0x600006, 0x600007 ) AM_WRITE( lastfght_blit_w ) | |
| 359 | AM_RANGE( 0x600008, 0x600009 ) AM_WRITE( colordac_w ) | |
| 360 | AM_RANGE( 0x60000a, 0x60000b ) AM_WRITE( MWA16_NOP ) // colordac? | |
| 361 | ||
| 362 | AM_RANGE( 0x800000, 0x800001 ) AM_WRITE( lastfght_sx_w ) | |
| 363 | AM_RANGE( 0x800002, 0x800003 ) AM_WRITE( lastfght_sd_w ) | |
| 364 | AM_RANGE( 0x800004, 0x800005 ) AM_WRITE( lastfght_sy_w ) | |
| 365 | AM_RANGE( 0x800006, 0x800007 ) AM_WRITE( lastfght_sr_w ) | |
| 366 | AM_RANGE( 0x800008, 0x800009 ) AM_WRITE( lastfght_x_w ) | |
| 367 | AM_RANGE( 0x80000a, 0x80000b ) AM_WRITE( lastfght_yw_w ) | |
| 368 | AM_RANGE( 0x80000c, 0x80000d ) AM_WRITE( lastfght_h_w ) | |
| 369 | ||
| 370 | AM_RANGE( 0x800014, 0x800015 ) AM_WRITE( lastfght_dest_w ) | |
| 371 | ||
| 372 | AM_RANGE( 0xc00000, 0xc00001 ) AM_READ( lastfght_c00000_r ) | |
| 373 | AM_RANGE( 0xc00002, 0xc00003 ) AM_READ( lastfght_c00002_r ) | |
| 374 | AM_RANGE( 0xc00004, 0xc00005 ) AM_READ( lastfght_c00004_r ) | |
| 375 | AM_RANGE( 0xc00006, 0xc00007 ) AM_READWRITE( lastfght_c00006_r, lastfght_c00006_w ) | |
| 376 | ||
| 377 | AM_RANGE( 0xff0000, 0xffffff ) AM_RAM | |
| 171 | 378 | ADDRESS_MAP_END |
| 172 | 379 | |
| 380 | ||
| 381 | /*************************************************************************** | |
| 382 | Input Ports | |
| 383 | ***************************************************************************/ | |
| 384 | ||
| 385 | INPUT_PORTS_START( lastfght ) | |
| 386 | PORT_START // IN0 - c00002&3 | |
| 387 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SERVICE1 ) | |
| 388 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 389 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Reset") PORT_CODE(KEYCODE_F1) | |
| 390 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 391 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 392 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 393 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE ) | |
| 394 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 395 | ||
| 396 | PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 397 | PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 398 | PORT_BIT( 0x0400, IP_ACTIVE_HIGH,IPT_SPECIAL ) | |
| 399 | PORT_BIT( 0x0800, IP_ACTIVE_HIGH,IPT_SPECIAL ) | |
| 400 | PORT_BIT( 0x1000, IP_ACTIVE_HIGH,IPT_SPECIAL ) | |
| 401 | PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 402 | PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 403 | PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 404 | ||
| 405 | PORT_START // IN1 - c00004&5 | |
| 406 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) | |
| 407 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) | |
| 408 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 409 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) | |
| 410 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 411 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_START1 ) | |
| 412 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 413 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) | |
| 414 | ||
| 415 | PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) | |
| 416 | PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) | |
| 417 | PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) | |
| 418 | PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) | |
| 419 | PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 420 | PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 421 | PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_COIN1 ) | |
| 422 | PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN2 ) | |
| 423 | ||
| 424 | PORT_START // IN2 - c00006&7 | |
| 425 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 426 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 427 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 428 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 429 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 430 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 431 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 432 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 433 | ||
| 434 | PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) | |
| 435 | PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) | |
| 436 | PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 437 | PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2) | |
| 438 | PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 439 | PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_START2 ) | |
| 440 | PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 441 | PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) | |
| 442 | INPUT_PORTS_END | |
| 443 | ||
| 444 | ||
| 445 | /*************************************************************************** | |
| 446 | Machine Drivers | |
| 447 | ***************************************************************************/ | |
| 448 | ||
| 173 | 449 | static INTERRUPT_GEN( unknown_interrupt ) |
| 174 | 450 | { |
| 175 | cpunum_set_input_line(0, cpu_getiloops(), PULSE_LINE); | |
| 451 | switch (cpu_getiloops()) | |
| 452 | { | |
| 453 | case 0: | |
| 454 | cpunum_set_input_line(0, 0, PULSE_LINE); | |
| 455 | break; | |
| 456 | default: | |
| 457 | h8_3002_InterruptRequest(24); | |
| 458 | break; | |
| 459 | } | |
| 176 | 460 | } |
| 177 | 461 | |
| 178 | ||
| 179 | 462 | static MACHINE_DRIVER_START( lastfght ) |
| 180 | MDRV_CPU_ADD(H83002, | |
| 463 | MDRV_CPU_ADD(H83002, 32000000/2) | |
| 181 | 464 | MDRV_CPU_PROGRAM_MAP( lastfght_map, 0 ) |
| 182 | ||
| 465 | | |
| 183 | 466 | |
| 184 | MDRV_SCREEN_REFRESH_RATE( 60 ) | |
| 185 | MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS( 0 )) | |
| 467 | MDRV_NVRAM_HANDLER(generic_0fill) | |
| 186 | 468 | |
| 469 | /* video hardware */ | |
| 187 | 470 | MDRV_VIDEO_ATTRIBUTES( VIDEO_TYPE_RASTER ) |
| 188 | 471 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 189 | MDRV_SCREEN_SIZE( 512, 512 ) | |
| 190 | MDRV_SCREEN_VISIBLE_AREA( 0, 512-1, 0, 512-1 ) | |
| 472 | MDRV_SCREEN_SIZE( 512, 256 ) | |
| 473 | MDRV_SCREEN_VISIBLE_AREA( 0, 512-1, 0, 256-16-1 ) | |
| 191 | 474 | MDRV_PALETTE_LENGTH( 256 ) |
| 475 | MDRV_SCREEN_REFRESH_RATE( 60 ) | |
| 192 | 476 | |
| 193 | 477 | MDRV_VIDEO_START( lastfght ) |
| 194 | 478 | MDRV_VIDEO_UPDATE( lastfght ) |
| 195 | ||
| 196 | MDRV_SPEAKER_STANDARD_STEREO("left", "right") | |
| 197 | 479 | MACHINE_DRIVER_END |
| 198 | 480 | |
| 481 | ||
| 482 | /*************************************************************************** | |
| 483 | ROMs Loading | |
| 484 | ***************************************************************************/ | |
| 485 | ||
| 199 | 486 | ROM_START( lastfght ) |
| 200 | // H8/3044 program | |
| 201 | ROM_REGION( 0x100000, REGION_CPU1, 0 ) | |
| 202 | ROM_LOAD( "v106.u16", 0x000000, 0x080000, CRC(7aec89f4) SHA1(7cff00844ad82a0f8d19b1bd07ba3a2bced69d66) ) | |
| 487 | ROM_REGION( 0x100000, REGION_CPU1, 0 ) // H8/3044 program | |
| 488 | ROM_LOAD( "v106.u16", 0x000000, 0x080000, CRC(7aec89f4) SHA1(7cff00844ad82a0f8d19b1bd07ba3a2bced69d66) ) | |
| 203 | 489 | |
| 204 | // graphics (512x256? pages) | |
| 205 | ROM_REGION( 0x800000, REGION_GFX1, 0 ) | |
| 206 | ROM_LOAD( "1.b1", 0x000000, 0x200000, CRC(6c438136) SHA1(138934e948bbd6bd80f354f037badedef6cd8cb1) ) | |
| 207 | ROM_LOAD( "2.b2", 0x200000, 0x200000, CRC(9710bcff) SHA1(0291385489a065ed895c99ae7197fdeac0a0e2a0) ) | |
| 208 | ROM_LOAD( "3.b3", 0x400000, 0x200000, CRC(4236c79a) SHA1(94f093d12c096d38d1e7278796f6d58e4ba14e2e) ) | |
| 209 | ROM_LOAD( "4.b4", 0x600000, 0x200000, CRC(68153b0f) SHA1(46ddf37d5885f411e0e6de9c7e8969ba3a00f17f) ) | |
| 490 | ROM_REGION( 0x800000, REGION_GFX1, 0 ) // Blitter data | |
| 491 | ROM_LOAD( "1.b1", 0x000000, 0x200000, CRC(6c438136) SHA1(138934e948bbd6bd80f354f037badedef6cd8cb1) ) | |
| 492 | ROM_LOAD( "2.b2", 0x200000, 0x200000, CRC(9710bcff) SHA1(0291385489a065ed895c99ae7197fdeac0a0e2a0) ) | |
| 493 | ROM_LOAD( "3.b3", 0x400000, 0x200000, CRC(4236c79a) SHA1(94f093d12c096d38d1e7278796f6d58e4ba14e2e) ) | |
| 494 | ROM_LOAD( "4.b4", 0x600000, 0x200000, CRC(68153b0f) SHA1(46ddf37d5885f411e0e6de9c7e8969ba3a00f17f) ) | |
| 210 | 495 | |
| 211 | // samples? | |
| 212 | ROM_REGION( 0x100000, REGION_SOUND1, 0 ) | |
| 213 | ROM_LOAD( "v100.u7", 0x000000, 0x100000, CRC(c134378c) SHA1(999c75f3a7890421cfd904a926ca377ee43a6825) ) | |
| 496 | ROM_REGION( 0x100000, REGION_SOUND1, 0 ) // Samples | |
| 497 | ROM_LOAD( "v100.u7", 0x000000, 0x100000, CRC(c134378c) SHA1(999c75f3a7890421cfd904a926ca377ee43a6825) ) | |
| 214 | 498 | ROM_END |
| 215 | 499 | |
| 216 | 500 | static DRIVER_INIT(lastfght) |
| 217 | 501 | { |
| 218 | | |
| 502 | UINT16 *ro | |
| 219 | 503 | |
| 220 | // remove comment to pass initial check (protection ? hw?) | |
| 221 | // memory_region(REGION_CPU1)[0x00355]=0x40; | |
| 504 | // pass initial check (protection ? hw?) | |
| 505 | rom[0x00354/2] = 0x403e; | |
| 506 | ||
| 507 | // rts -> rte | |
| 508 | rom[0x01b86/2] = 0x5670; | |
| 222 | 509 | } |
| 223 | 510 | |
| 224 | GAME(2000, lastfght, 0, lastfght, lastfght, lastfght, ROT0, "Subsino", "Last Fighting", GAME_NO | |
| 511 | GAME(2000, lastfght, 0, lastfght, lastfght, lastfght, ROT0, "Subsino", "Last Fighting", GAME_NO |
| r936 | r937 | |
|---|---|---|
| 226 | 226 | |
| 227 | 227 | static WRITE8_HANDLER( snddata_w ) |
| 228 | 228 | { |
| 229 | int num_ays = (sndti_t | |
| 229 | int num_ays = (sndti_exist | |
| 230 | 230 | if ((p2 & 0xf0) == 0xe0) |
| 231 | 231 | AY8910_control_port_0_w(0,offset); |
| 232 | 232 | else if ((p2 & 0xf0) == 0xa0) |
| r0 | r937 | |
|---|---|---|
| 1 | /********************************************************************************************************************* | |
| 2 | ||
| 3 | Bishou Jan (Laugh World) (C)1999 Subsino | |
| 4 | ||
| 5 | driver by Luca Elia | |
| 6 | ||
| 7 | PCB Layout | |
| 8 | ---------- | |
| 9 | ||
| 10 | |------------------------------------------------------| | |
| 11 | |TDA1519A 28-WAY | | |
| 12 | | VOL | | |
| 13 | | HM86171 ULN2003 | | |
| 14 | | LM324 | | |
| 15 | | S-1 ULN2003 | | |
| 16 | | | | |
| 17 | | |-------| DSW1(8) | | |
| 18 | | |-------| |SUBSINO| | | |
| 19 | | 2-V201.U9 |SUBSINO| |SS9802 | | | |
| 20 | | |SS9904 | | | | | |
| 21 | | | | |-------| | | |
| 22 | | |-------| | | |
| 23 | | | | |
| 24 | | 44.1MHz CXK58257 | | |
| 25 | | 3-V201.U25 | | |
| 26 | | 1-V203.U21 | | |
| 27 | | 4-V201.U26 SW1| | |
| 28 | | |-------| |-------| |-----| | | |
| 29 | | 5-V201.U27 |SUBSINO| |SUBSINO| |H8 | | | |
| 30 | | |SS9601 | |SS9803 | |3044 | | | |
| 31 | | 6-V201.U28 | | | | |-----| | | |
| 32 | | |-------| |-------| | | |
| 33 | | 62256 62256 BATTERY | | |
| 34 | |------------------------------------------------------| | |
| 35 | Notes: | |
| 36 | H8/3044 - Subsino re-badged Hitachi H8/3044 HD6433044A22F Microcontroller (QFP100) | |
| 37 | The H8/3044 is a H8/3002 with 24bit address bus and has 32k MASKROM and 2k RAM, clock input is 14.7MHz [44.1/3] | |
| 38 | MD0,MD1 & MD2 are configured to MODE 6 16MByte Expanded Mode with the on-chip 32k MASKROM enabled. | |
| 39 | CXK58257 - Sony CXK58257 32k x8 SRAM (SOP28) | |
| 40 | HM86171 - Hualon Microelectronics HMC HM86171 VGA 256 colour RAMDAC (DIP28) | |
| 41 | S-1 - ?? Probably some kind of audio OP AMP or DAC? (DIP8) | |
| 42 | SW1 - Push Button Test Switch | |
| 43 | HSync - 15.75kHz | |
| 44 | VSync - 60Hz | |
| 45 | ||
| 46 | *********************************************************************************************************************/ | |
| 47 | ||
| 48 | #include "driver.h" | |
| 49 | #include "cpu/h83002/h83002.h" | |
| 50 | ||
| 51 | /*************************************************************************** | |
| 52 | Video Hardware | |
| 53 | ***************************************************************************/ | |
| 54 | ||
| 55 | static int clr_offset; | |
| 56 | ||
| 57 | static UINT16 *bishjan_scroll, *bishjan_layers; | |
| 58 | ||
| 59 | static UINT16 *bishjan_videoram1, *bishjan_videoram2; | |
| 60 | static tilemap *tmap1, *tmap2; | |
| 61 | ||
| 62 | static TILE_GET_INFO( get_tile_info1 ) { SET_TILE_INFO(0, bishjan_videoram1[ tile_index ], 0, 0); } | |
| 63 | static TILE_GET_INFO( get_tile_info2 ) { SET_TILE_INFO(0, bishjan_videoram2[ tile_index ], 0, 0); } | |
| 64 | ||
| 65 | VIDEO_START(bishjan) | |
| 66 | { | |
| 67 | tmap1 = tilemap_create( get_tile_info1, tilemap_scan_rows, | |
| 68 | TILEMAP_TYPE_PEN, 8,8, 0x80,0x40 ); | |
| 69 | ||
| 70 | tmap2 = tilemap_create( get_tile_info2, tilemap_scan_rows, | |
| 71 | TILEMAP_TYPE_PEN, 8,8, 0x80,0x40 ); | |
| 72 | ||
| 73 | tilemap_set_transparent_pen(tmap1, 0); | |
| 74 | tilemap_set_transparent_pen(tmap2, 0); | |
| 75 | ||
| 76 | bishjan_videoram1 = (UINT16*)auto_malloc(sizeof(UINT16) * 0x80 * 0x40); | |
| 77 | bishjan_videoram2 = (UINT16*)auto_malloc(sizeof(UINT16) * 0x80 * 0x40); | |
| 78 | ||
| 79 | colorram = auto_malloc(256*3); | |
| 80 | } | |
| 81 | ||
| 82 | VIDEO_UPDATE( bishjan ) | |
| 83 | { | |
| 84 | int layers_ctrl = ~bishjan_layers[0]; | |
| 85 | ||
| 86 | int scroll1_x = ((bishjan_scroll[1] & 0x0f00)>>0) | (bishjan_scroll[0] >> 8); | |
| 87 | int scroll1_y = ((bishjan_scroll[1] & 0xf000)>>4) | (bishjan_scroll[0] & 0xff); | |
| 88 | ||
| 89 | int scroll2_x = ((bishjan_scroll[2] & 0x0f)<<8) | (bishjan_scroll[1] & 0xff); | |
| 90 | int scroll2_y = ((bishjan_scroll[2] & 0xf0)<<4) | (bishjan_scroll[2] >> 8); | |
| 91 | ||
| 92 | #ifdef MAME_DEBUG | |
| 93 | if (input_code_pressed(KEYCODE_Z)) | |
| 94 | { | |
| 95 | int msk = 0; | |
| 96 | if (input_code_pressed(KEYCODE_Q)) msk |= 1; | |
| 97 | if (input_code_pressed(KEYCODE_W)) msk |= 2; | |
| 98 | if (msk != 0) layers_ctrl &= msk; | |
| 99 | } | |
| 100 | #endif | |
| 101 | ||
| 102 | scroll1_y += 1; | |
| 103 | scroll2_y += 1; | |
| 104 | ||
| 105 | tilemap_set_scrollx( tmap1, 0, scroll1_x); tilemap_set_scrolly( tmap1, 0, scroll1_y ); | |
| 106 | tilemap_set_scrollx( tmap2, 0, scroll2_x); tilemap_set_scrolly( tmap2, 0, scroll2_y ); | |
| 107 | ||
| 108 | fillbitmap(bitmap,get_black_pen(machine),cliprect); | |
| 109 | ||
| 110 | if (layers_ctrl & 1) tilemap_draw(bitmap,cliprect, tmap1, 0, 0); | |
| 111 | if (layers_ctrl & 2) tilemap_draw(bitmap,cliprect, tmap2, 0, 0); | |
| 112 | ||
| 113 | // popmessage("23: %03x,%03x - %03x,%03x LY: %02x", scroll1_x,scroll1_y, scroll2_x,scroll2_y, (int)*bishjan_layers); | |
| 114 | ||
| 115 | return 0; | |
| 116 | } | |
| 117 | ||
| 118 | // Palette: HMC HM86171 VGA 256 colour RAMDAC | |
| 119 | ||
| 120 | static WRITE16_HANDLER(colordac_w) | |
| 121 | { | |
| 122 | if (ACCESSING_LSB) | |
| 123 | { | |
| 124 | colorram[clr_offset] = data; | |
| 125 | palette_set_color_rgb(Machine, clr_offset/3, | |
| 126 | pal6bit(colorram[(clr_offset/3)*3+0]), | |
| 127 | pal6bit(colorram[(clr_offset/3)*3+1]), | |
| 128 | pal6bit(colorram[(clr_offset/3)*3+2]) | |
| 129 | ); | |
| 130 | clr_offset = (clr_offset+1) % (256*3); | |
| 131 | } | |
| 132 | ||
| 133 | if (ACCESSING_MSB) | |
| 134 | { | |
| 135 | clr_offset = (data>>8) * 3; | |
| 136 | } | |
| 137 | } | |
| 138 | ||
| 139 | // Tilemaps | |
| 140 | ||
| 141 | static UINT16 bishjan_low; | |
| 142 | ||
| 143 | static WRITE16_HANDLER( bishjan_low_w ) | |
| 144 | { | |
| 145 | if (ACCESSING_MSB) bishjan_low = data >> 8; | |
| 146 | } | |
| 147 | ||
| 148 | static WRITE16_HANDLER( bishjan_tmap1_w ) | |
| 149 | { | |
| 150 | if (ACCESSING_MSB) | |
| 151 | { | |
| 152 | bishjan_videoram1[offset*2] = data | bishjan_low; | |
| 153 | tilemap_mark_tile_dirty(tmap1, offset*2); | |
| 154 | } | |
| 155 | if (ACCESSING_LSB) | |
| 156 | { | |
| 157 | bishjan_videoram1[offset*2+1] = (data << 8) | bishjan_low; | |
| 158 | tilemap_mark_tile_dirty(tmap1, offset*2+1); | |
| 159 | } | |
| 160 | } | |
| 161 | static WRITE16_HANDLER( bishjan_tmap2_w ) | |
| 162 | { | |
| 163 | if (ACCESSING_MSB) | |
| 164 | { | |
| 165 | bishjan_videoram2[offset*2] = data | bishjan_low; | |
| 166 | tilemap_mark_tile_dirty(tmap2, offset*2); | |
| 167 | } | |
| 168 | if (ACCESSING_LSB) | |
| 169 | { | |
| 170 | bishjan_videoram2[offset*2+1] = (data << 8) | bishjan_low; | |
| 171 | tilemap_mark_tile_dirty(tmap2, offset*2+1); | |
| 172 | } | |
| 173 | } | |
| 174 | ||
| 175 | static READ16_HANDLER( bishjan_tmap1_lo_r ) | |
| 176 | { | |
| 177 | return (bishjan_videoram1[offset*2+0] << 8) | (bishjan_videoram1[offset*2+1] & 0x00ff); | |
| 178 | } | |
| 179 | static READ16_HANDLER( bishjan_tmap1_hi_r ) | |
| 180 | { | |
| 181 | return (bishjan_videoram1[offset*2+0] & 0xff00) | (bishjan_videoram1[offset*2+1] >> 8); | |
| 182 | } | |
| 183 | ||
| 184 | static READ16_HANDLER( bishjan_tmap2_lo_r ) | |
| 185 | { | |
| 186 | return (bishjan_videoram2[offset*2+0] << 8) | (bishjan_videoram2[offset*2+1] & 0x00ff); | |
| 187 | } | |
| 188 | static READ16_HANDLER( bishjan_tmap2_hi_r ) | |
| 189 | { | |
| 190 | return (bishjan_videoram2[offset*2+0] & 0xff00) | (bishjan_videoram2[offset*2+1] >> 8); | |
| 191 | } | |
| 192 | ||
| 193 | // Inputs | |
| 194 | ||
| 195 | static UINT16 bishjan_sel, bishjan_input, bishjan_hopper; | |
| 196 | ||
| 197 | static WRITE16_HANDLER( bishjan_sel_w ) | |
| 198 | { | |
| 199 | if (ACCESSING_MSB) bishjan_sel = data >> 8; | |
| 200 | } | |
| 201 | ||
| 202 | static READ16_HANDLER( bishjan_unk_r ) | |
| 203 | { | |
| 204 | return | |
| 205 | (mame_rand(Machine) & 0x9800) | // bit 7 eeprom? | |
| 206 | (((bishjan_sel==0x12) ? 0x40:0x00) << 8) | | |
| 207 | // (mame_rand() & 0xff); | |
| 208 | // (((cpu_getcurrentframe()%60)==0)?0x18:0x00); | |
| 209 | 0x18; | |
| 210 | } | |
| 211 | ||
| 212 | static WRITE16_HANDLER( bishjan_input_w ) | |
| 213 | { | |
| 214 | if (ACCESSING_MSB) bishjan_input = data >> 8; | |
| 215 | } | |
| 216 | ||
| 217 | static READ16_HANDLER( bishjan_input_r ) | |
| 218 | { | |
| 219 | int i; | |
| 220 | UINT16 res = 0xff; | |
| 221 | ||
| 222 | for (i = 0; i < 5; i++) | |
| 223 | if (bishjan_input & (1 << i)) | |
| 224 | res = readinputport(4+i); | |
| 225 | ||
| 226 | return (res << 8) | | |
| 227 | readinputport(3) | | |
| 228 | ((bishjan_hopper && !(cpu_getcurrentframe()%10)) ? 0x00 : 0x04) // bit 2: hopper sensor | |
| 229 | ; | |
| 230 | } | |
| 231 | ||
| 232 | static WRITE16_HANDLER( bishjan_coin_w ) | |
| 233 | { | |
| 234 | if (ACCESSING_LSB) | |
| 235 | { | |
| 236 | // coin out data & 0x01; | |
| 237 | bishjan_hopper = data & 0x02; // hopper | |
| 238 | coin_counter_w( 1, data & 0x10 ); | |
| 239 | } | |
| 240 | } | |
| 241 | ||
| 242 | /*************************************************************************** | |
| 243 | Memory Maps | |
| 244 | ***************************************************************************/ | |
| 245 | ||
| 246 | /* | |
| 247 | 432000 & 436000 W + lo (80*20=1000) | |
| 248 | 412000 & 422000 R (lo & hi) | |
| 249 | 416000 & 426000 R (lo & hi) | |
| 250 | ||
| 251 | 433000 & 437000 W | |
| 252 | 413000 & 423000 R | |
| 253 | 417000 & 427000 R | |
| 254 | */ | |
| 255 | ||
| 256 | static ADDRESS_MAP_START( bishjan_map, ADDRESS_SPACE_PROGRAM, 16 ) | |
| 257 | ADDRESS_MAP_FLAGS( AMEF_ABITS(24) ) | |
| 258 | ||
| 259 | AM_RANGE( 0x000000, 0x07ffff ) AM_ROM AM_REGION(REGION_CPU1, 0) | |
| 260 | AM_RANGE( 0x080000, 0x0fffff ) AM_ROM AM_REGION(REGION_CPU1, 0) | |
| 261 | ||
| 262 | AM_RANGE( 0x200000, 0x207fff ) AM_RAM AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size) // battery | |
| 263 | ||
| 264 | AM_RANGE( 0x412000, 0x412fff ) AM_READ( bishjan_tmap2_lo_r ) //? | |
| 265 | AM_RANGE( 0x413000, 0x413fff ) AM_READ( MRA16_RAM ) AM_SHARE(1) | |
| 266 | AM_RANGE( 0x416000, 0x416fff ) AM_READ( bishjan_tmap1_lo_r ) //? | |
| 267 | AM_RANGE( 0x417000, 0x417fff ) AM_READ( MRA16_RAM ) AM_SHARE(1) | |
| 268 | AM_RANGE( 0x422000, 0x422fff ) AM_READ( bishjan_tmap2_hi_r ) //? | |
| 269 | AM_RANGE( 0x423000, 0x423fff ) AM_READ( MRA16_RAM ) AM_SHARE(2) | |
| 270 | AM_RANGE( 0x426000, 0x426fff ) AM_READ( bishjan_tmap1_hi_r ) | |
| 271 | AM_RANGE( 0x427000, 0x427fff ) AM_READ( MRA16_RAM ) AM_SHARE(2) | |
| 272 | AM_RANGE( 0x430000, 0x431fff ) AM_WRITE( bishjan_tmap2_w ) | |
| 273 | AM_RANGE( 0x432000, 0x432fff ) AM_WRITE( bishjan_tmap2_w ) //? | |
| 274 | AM_RANGE( 0x433000, 0x433fff ) AM_WRITE( MWA16_RAM ) AM_SHARE(1) | |
| 275 | AM_RANGE( 0x434000, 0x435fff ) AM_WRITE( bishjan_tmap1_w ) | |
| 276 | AM_RANGE( 0x436000, 0x436fff ) AM_WRITE( bishjan_tmap1_w ) //? | |
| 277 | AM_RANGE( 0x437000, 0x437fff ) AM_WRITE( MWA16_RAM ) AM_SHARE(2) | |
| 278 | ||
| 279 | AM_RANGE( 0x600000, 0x600001 ) AM_READWRITE( MRA16_NOP, bishjan_sel_w ) | |
| 280 | AM_RANGE( 0x600060, 0x600061 ) AM_WRITE( colordac_w ) | |
| 281 | AM_RANGE( 0x600062, 0x600063 ) AM_WRITE( MWA16_NOP ) // ff to 600062 | |
| 282 | AM_RANGE( 0x6000a0, 0x6000a1 ) AM_WRITE( bishjan_low_w ) | |
| 283 | ||
| 284 | AM_RANGE( 0xa0001e, 0xa0001f ) AM_WRITE( MWA16_RAM ) AM_BASE( &bishjan_layers ) | |
| 285 | ||
| 286 | AM_RANGE( 0xa00020, 0xa00025 ) AM_WRITE( MWA16_RAM ) AM_BASE( &bishjan_scroll ) | |
| 287 | ||
| 288 | AM_RANGE( 0xc00000, 0xc00001 ) AM_READ( input_port_1_word_r ) // c00001 sw1 | |
| 289 | AM_RANGE( 0xc00002, 0xc00003 ) AM_READWRITE( input_port_2_word_r, bishjan_input_w ) // in c | |
| 290 | AM_RANGE( 0xc00004, 0xc00005 ) AM_READ( bishjan_input_r ) // in a & b | |
| 291 | AM_RANGE( 0xc00006, 0xc00007 ) AM_READ( bishjan_unk_r ) // c00006 in d ($18) | |
| 292 | AM_RANGE( 0xc00008, 0xc00009 ) AM_READWRITE( input_port_0_word_r, bishjan_coin_w ) // c00009 reset | |
| 293 | ADDRESS_MAP_END | |
| 294 | ||
| 295 | ||
| 296 | /*************************************************************************** | |
| 297 | Graphics Layout | |
| 298 | ***************************************************************************/ | |
| 299 | ||
| 300 | static const gfx_layout bishjan_8x8_layout = | |
| 301 | { | |
| 302 | 8,8, | |
| 303 | RGN_FRAC(1,1), | |
| 304 | 8, | |
| 305 | { STEP8(0,1) }, | |
| 306 | { STEP8(0,8) }, | |
| 307 | { STEP8(0,8*8) }, | |
| 308 | 8*8*8 | |
| 309 | }; | |
| 310 | ||
| 311 | static const gfx_decode bishjan_gfxdecodeinfo[] = | |
| 312 | { | |
| 313 | { REGION_GFX1, 0, &bishjan_8x8_layout, 0, 1 }, | |
| 314 | { -1 } | |
| 315 | }; | |
| 316 | ||
| 317 | ||
| 318 | /*************************************************************************** | |
| 319 | Input Ports | |
| 320 | ***************************************************************************/ | |
| 321 | ||
| 322 | INPUT_PORTS_START( bishjan ) | |
| 323 | PORT_START // IN0 - Reset | |
| 324 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Reset") PORT_CODE(KEYCODE_F1) | |
| 325 | ||
| 326 | PORT_START // IN1 - DSW(SW1) | |
| 327 | PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Controls ) ) | |
| 328 | PORT_DIPSETTING( 0x0001, "Keyboard" ) | |
| 329 | PORT_DIPSETTING( 0x0000, DEF_STR( Joystick ) ) | |
| 330 | PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) | |
| 331 | PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) | |
| 332 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) | |
| 333 | PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) ) | |
| 334 | PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) | |
| 335 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) | |
| 336 | PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) ) | |
| 337 | PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) | |
| 338 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) | |
| 339 | PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) ) | |
| 340 | PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) | |
| 341 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) | |
| 342 | PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) ) | |
| 343 | PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) | |
| 344 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) | |
| 345 | PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) ) | |
| 346 | PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) | |
| 347 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) | |
| 348 | PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) ) | |
| 349 | PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) | |
| 350 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) | |
| 351 | ||
| 352 | PORT_START // IN2 - C | |
| 353 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 ) // start (joy) | |
| 354 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) // down (joy) | |
| 355 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 356 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) // left (joy) | |
| 357 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) // right (joy) | |
| 358 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 ) // n (joy) | |
| 359 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_MAHJONG_BET ) // bet (joy) | |
| 360 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON2 ) // select (joy) | |
| 361 | ||
| 362 | PORT_START // IN3 - A | |
| 363 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 364 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_SERVICE ) // test | |
| 365 | PORT_BIT( 0x0004, IP_ACTIVE_HIGH,IPT_SPECIAL ) // hopper sensor | |
| 366 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_SERVICE1 ) // stats | |
| 367 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_SERVICE2 ) // pay out? "hopper empty" | |
| 368 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2) // coin | |
| 369 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE3 ) // pay out? "hopper empty" | |
| 370 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2) // coin | |
| 371 | ||
| 372 | PORT_START // IN4 - B(1) | |
| 373 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_A ) // a | |
| 374 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_E ) // e | |
| 375 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_I ) // i | |
| 376 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_M ) // m | |
| 377 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN ) // i2 | |
| 378 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_START1 ) // b2 (start) | |
| 379 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 380 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 381 | ||
| 382 | PORT_START // IN5 - B(2) | |
| 383 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_B ) // b | |
| 384 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_F ) // f | |
| 385 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_J ) // j | |
| 386 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_N ) // n | |
| 387 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN ) // l2 | |
| 388 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_MAHJONG_BET ) // c2 (bet) | |
| 389 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 390 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 391 | ||
| 392 | PORT_START // IN6 - B(3) | |
| 393 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_C ) // c | |
| 394 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_G ) // g | |
| 395 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_K ) // k | |
| 396 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN ) // k2 | |
| 397 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN ) // m2 | |
| 398 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 399 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 400 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 401 | ||
| 402 | PORT_START // IN7 - B(4) | |
| 403 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_D ) // d | |
| 404 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_H ) // h | |
| 405 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_L ) // l | |
| 406 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN ) // j2 | |
| 407 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 408 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 409 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 410 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 411 | ||
| 412 | PORT_START // IN8 - B(5) | |
| 413 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 414 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN ) // g2 | |
| 415 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN ) // e2 | |
| 416 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 417 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN ) // d2 | |
| 418 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN ) // f2 | |
| 419 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 420 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 421 | INPUT_PORTS_END | |
| 422 | ||
| 423 | ||
| 424 | /*************************************************************************** | |
| 425 | Machine Drivers | |
| 426 | ***************************************************************************/ | |
| 427 | ||
| 428 | static INTERRUPT_GEN( bishjan_interrupt ) | |
| 429 | { | |
| 430 | switch (cpu_getiloops()) | |
| 431 | { | |
| 432 | case 0: | |
| 433 | cpunum_set_input_line(0, 0, PULSE_LINE); | |
| 434 | break; | |
| 435 | default: | |
| 436 | h8_3002_InterruptRequest(24); | |
| 437 | break; | |
| 438 | } | |
| 439 | } | |
| 440 | ||
| 441 | static MACHINE_DRIVER_START( bishjan ) | |
| 442 | MDRV_CPU_ADD(H83002, 44100000/3) | |
| 443 | MDRV_CPU_PROGRAM_MAP( bishjan_map, 0 ) | |
| 444 | MDRV_CPU_VBLANK_INT(bishjan_interrupt,2) | |
| 445 | ||
| 446 | MDRV_NVRAM_HANDLER(generic_0fill) | |
| 447 | ||
| 448 | /* video hardware */ | |
| 449 | MDRV_VIDEO_ATTRIBUTES( VIDEO_TYPE_RASTER ) | |
| 450 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) | |
| 451 | MDRV_SCREEN_SIZE( 512, 256 ) | |
| 452 | MDRV_SCREEN_VISIBLE_AREA( 0, 512-1, 0, 256-16-1 ) | |
| 453 | MDRV_GFXDECODE(bishjan_gfxdecodeinfo) | |
| 454 | MDRV_PALETTE_LENGTH( 256 ) | |
| 455 | MDRV_SCREEN_REFRESH_RATE( 60 ) | |
| 456 | ||
| 457 | MDRV_VIDEO_START( bishjan ) | |
| 458 | MDRV_VIDEO_UPDATE( bishjan ) | |
| 459 | MACHINE_DRIVER_END | |
| 460 | ||
| 461 | /*************************************************************************** | |
| 462 | ROMs Loading | |
| 463 | ***************************************************************************/ | |
| 464 | ||
| 465 | ROM_START( bishjan ) | |
| 466 | ROM_REGION( 0x100000, REGION_CPU1, 0 ) // H8/3044 program | |
| 467 | ROM_LOAD( "1-v203.u21", 0x000000, 0x080000, CRC(1f891d48) SHA1(0b6a5aa8b781ba8fc133289790419aa8ea21c400) ) | |
| 468 | ||
| 469 | ROM_REGION( 0x400000, REGION_GFX1, 0 ) // Tiles | |
| 470 | ROM_LOAD32_BYTE( "3-v201.u25", 0x000000, 0x100000, CRC(e013e647) SHA1(a5b0f82f3454393c1ea5e635b0d37735a25e2ea5) ) | |
| 471 | ROM_LOAD32_BYTE( "4-v201.u26", 0x000001, 0x100000, CRC(e0d40ef1) SHA1(95f80889103a7b93080b46387274cb1ffe0c8768) ) | |
| 472 | ROM_LOAD32_BYTE( "5-v201.u27", 0x000002, 0x100000, CRC(85067d40) SHA1(3ecf7851311a77a0dfca90775fcbf6faabe9c2ab) ) | |
| 473 | ROM_LOAD32_BYTE( "6-v201.u28", 0x000003, 0x100000, CRC(430bd9d7) SHA1(dadf5a7eb90cf2dc20f97dbf20a4b6c8e7734fb1) ) | |
| 474 | ||
| 475 | ROM_REGION( 0x100000, REGION_SOUND1, 0 ) // Samples | |
| 476 | ROM_LOAD( "2-v201.u9", 0x000000, 0x100000, CRC(ea42764d) SHA1(13fe1cd30e474f4b092949c440068e9ddca79976) ) | |
| 477 | ROM_END | |
| 478 | ||
| 479 | static DRIVER_INIT(bishjan) | |
| 480 | { | |
| 481 | UINT16 *rom = (UINT16*)memory_region(REGION_CPU1); | |
| 482 | ||
| 483 | // check | |
| 484 | rom[0x042EA/2] = 0x4008; | |
| 485 | ||
| 486 | // rts -> rte | |
| 487 | rom[0x33386/2] = 0x5670; | |
| 488 | rom[0x0CC5C/2] = 0x5670; | |
| 489 | } | |
| 490 | ||
| 491 | GAME(1999, bishjan, 0, bishjan, bishjan, bishjan, ROT0, "Subsino", "Bishou Jan", GAME_NO_SOUND) |
| r936 | r937 | |
|---|---|---|
| 604 | 604 | 256, |
| 605 | 605 | 2, |
| 606 | 606 | { 0, 4 }, |
| 607 | { 8*8+3, 8*8+2, 8*8+1, 8*8, 3, 2, 1, 0 }, | |
| 608 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 607 | { STEP4(8*8+3,-1), STEP4(0*8+3,-1) }, | |
| 608 | { STEP8(0*8,8) }, | |
| 609 | 609 | 16*8 |
| 610 | 610 | }; |
| 611 | 611 | |
| r936 | r937 | |
| 615 | 615 | 256, |
| 616 | 616 | 3, |
| 617 | 617 | { 0, 0x4000*8, 0x4000*8+4 }, |
| 618 | { | |
| 619 | 128*1+3, 128*1+2, 128*1+1, 128*1+0, | |
| 620 | 128*2+3, 128*2+2, 128*2+1, 128*2+0, | |
| 621 | 128*3+3, 128*3+2, 128*3+1, 128*3+0, | |
| 622 | 3, 2, 1, 0 | |
| 623 | }, | |
| 624 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, | |
| 618 | { STEP4(128*1+3,-1), STEP4(128*2+3,-1), STEP4(128*3+3,-1), STEP4(128*0+3,-1) }, | |
| 619 | { STEP16(0,8) }, | |
| 625 | 620 | 64*8 |
| 626 | 621 | }; |
| 627 | 622 | |
| r936 | r937 | |
| 631 | 626 | 256, |
| 632 | 627 | 3, |
| 633 | 628 | { 0, 0x4000*8, 0x4000*8+4 }, |
| 634 | { | |
| 635 | 3, 2, 1, 0, | |
| 636 | 128*1+3, 128*1+2, 128*1+1, 128*1+0, | |
| 637 | 128*2+3, 128*2+2, 128*2+1, 128*2+0, | |
| 638 | 128*3+3, 128*3+2, 128*3+1, 128*3+0 | |
| 639 | }, | |
| 640 | { 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8 }, | |
| 629 | { STEP4(128*0+3,-1), STEP4(128*1+3,-1), STEP4(128*2+3,-1), STEP4(128*3+3,-1) }, | |
| 630 | { STEP16(1*8,8) }, | |
| 641 | 631 | 64*8 |
| 642 | 632 | }; |
| 643 | 633 | |
| r936 | r937 | |
| 658 | 648 | 512, |
| 659 | 649 | 2, |
| 660 | 650 | { 0, 4 }, |
| 661 | { 8*8+3, 8*8+2, 8*8+1, 8*8, 3, 2, 1, 0 }, | |
| 662 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 651 | { STEP4(8*8+3,-1), STEP4(0*8+3,-1) }, | |
| 652 | { STEP8(0*8,8) }, | |
| 663 | 653 | 16*8 |
| 664 | 654 | }; |
| 665 | 655 | |
| r936 | r937 | |
| 669 | 659 | 256, |
| 670 | 660 | 2, |
| 671 | 661 | { 0, 4 }, |
| 672 | { | |
| 673 | 16*8+3, 16*8+2, 16*8+1, 16*8+0, | |
| 674 | 32*8+3, 32*8+2, 32*8+1, 32*8+0, | |
| 675 | 48*8+3, 48*8+2, 48*8+1, 48*8+0, | |
| 676 | 3, 2, 1, 0 | |
| 677 | }, | |
| 678 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, | |
| 662 | { STEP4(16*8+3,-1), STEP4(32*8+3,-1), STEP4(48*8+3,-1), STEP4(0*8+3,-1) }, | |
| 663 | { STEP16(0*8,8) }, | |
| 679 | 664 | 64*8 |
| 680 | 665 | }; |
| 681 | 666 | |
| r936 | r937 | |
| 685 | 670 | 128, |
| 686 | 671 | 3, |
| 687 | 672 | { 0, 0x8000*8, 0x8000*8+4 }, |
| 688 | { | |
| 689 | 0*8+3, 0*8+2, 0*8+1, 0*8+0, 1*8+3, 1*8+2, 1*8+1, 1*8+0, | |
| 690 | 2*8+3, 2*8+2, 2*8+1, 2*8+0, 3*8+3, 3*8+2, 3*8+1, 3*8+0, | |
| 691 | 4*8+3, 4*8+2, 4*8+1, 4*8+0, 5*8+3, 5*8+2, 5*8+1, 5*8+0, | |
| 692 | 6*8+3, 6*8+2, 6*8+1, 6*8+0, 7*8+3, 7*8+2, 7*8+1, 7*8+0 | |
| 693 | }, | |
| 694 | { | |
| 695 | 0*8*8, 1*8*8, 2*8*8, 3*8*8, 4*8*8, 5*8*8, 6*8*8, 7*8*8, | |
| 696 | 8*8*8, 9*8*8,10*8*8,11*8*8,12*8*8,13*8*8,14*8*8,15*8*8, | |
| 697 | 31*8*8,30*8*8,29*8*8,28*8*8,27*8*8,26*8*8,25*8*8,24*8*8, | |
| 698 | 23*8*8,22*8*8,21*8*8,20*8*8,19*8*8,18*8*8,17*8*8,16*8*8 | |
| 699 | }, | |
| 673 | { STEP4(0*8+3,-1), STEP4(1*8+3,-1), STEP4(2*8+3,-1), STEP4(3*8+3,-1), STEP4(4*8+3,-1), STEP4(5*8+3,-1), STEP4(6*8+3,-1), STEP4(7*8+3,-1) }, | |
| 674 | { STEP16(0*8*8,8*8), STEP16(31*8*8,-8*8) }, | |
| 700 | 675 | 8*32*8 |
| 701 | 676 | }; |
| 702 | 677 | |
| r936 | r937 | |
| 727 | 702 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 728 | 703 | MDRV_SCREEN_SIZE(256 +BMPAD*2, 256 +BMPAD*2) |
| 729 | 704 | MDRV_SCREEN_VISIBLE_AREA(0 +BMPAD, 256-1 +BMPAD, 24 +BMPAD, 232-1 +BMPAD) |
| 730 | MDRV_PALETTE_LENGTH(256) | |
| 731 | MDRV_COLORTABLE_LENGTH(384) | |
| 705 | MDRV_PALETTE_LENGTH(384) | |
| 732 | 706 | MDRV_GFXDECODE(equites_gfxdecodeinfo) |
| 733 | 707 | |
| 734 | 708 | MDRV_PALETTE_INIT(equites) |
| r936 | r937 | |
| 756 | 730 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 757 | 731 | MDRV_SCREEN_SIZE(256, 256) |
| 758 | 732 | MDRV_SCREEN_VISIBLE_AREA(0, 256-1, 64, 256-1) |
| 759 | MDRV_PALETTE_LENGTH(256) | |
| 760 | MDRV_COLORTABLE_LENGTH(1536) | |
| 733 | MDRV_PALETTE_LENGTH(1536) | |
| 761 | 734 | MDRV_GFXDECODE(splndrbt_gfxdecodeinfo) |
| 762 | 735 | |
| 763 | 736 | MDRV_PALETTE_INIT(splndrbt) |
| r936 | r937 | |
|---|---|---|
| 273 | 273 | if (!scalex || !scaley) return; |
| 274 | 274 | if (dest_bmp->bpp == 16) |
| 275 | 275 | { |
| 276 | if( gfx | |
| 276 | if( gfx | |
| 277 | 277 | { |
| 278 | 278 | int shadow_offset = (machine->drv->video_attributes&VIDEO_HAS_SHADOWS)?machine->drv->total_colors:0; |
| 279 | const pen_t *pal = & | |
| 279 | const pen_t *pal = &machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 280 | 280 | UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| 281 | 281 | int sprite_screen_height = (scaley*gfx->height+0x8000)>>16; |
| 282 | 282 | int sprite_screen_width = (scalex*gfx->width+0x8000)>>16; |
| r936 | r937 | |
| 1577 | 1577 | { |
| 1578 | 1578 | gfx_element *pGfx = allocgfx( &RoadTileLayout ); |
| 1579 | 1579 | decodegfx(pGfx, 0x10000+(UINT8 *)mpRoadRAM, 0, pGfx->total_elements); |
| 1580 | pGfx->color | |
| 1580 | pGfx->color_ | |
| 1581 | 1581 | pGfx->total_colors = 0x3f; |
| 1582 | 1582 | |
| 1583 | 1583 | machine->gfx[gfxbank] = pGfx; |
| r936 | r937 | |
|---|---|---|
| 279 | 279 | |
| 280 | 280 | if (machine->drv->color_table_len) |
| 281 | 281 | { |
| 282 | machine->gfx[K001604_gfx_index[chip][0]]->colortable = machine->remapped_colortable; | |
| 283 | 282 | machine->gfx[K001604_gfx_index[chip][0]]->total_colors = machine->drv->color_table_len / 16; |
| 284 | machine->gfx[K001604_gfx_index[chip][1]]->colortable = machine->remapped_colortable; | |
| 285 | 283 | machine->gfx[K001604_gfx_index[chip][1]]->total_colors = machine->drv->color_table_len / 16; |
| 286 | 284 | } |
| 287 | 285 | else |
| 288 | 286 | { |
| 289 | machine->gfx[K001604_gfx_index[chip][0]]->colortable = machine->pens; | |
| 290 | 287 | machine->gfx[K001604_gfx_index[chip][0]]->total_colors = machine->drv->total_colors / 16; |
| 291 | machine->gfx[K001604_gfx_index[chip][1]]->colortable = machine->pens; | |
| 292 | 288 | machine->gfx[K001604_gfx_index[chip][1]]->total_colors = machine->drv->total_colors / 16; |
| 293 | 289 | } |
| 294 | 290 |
| r936 | r937 | |
|---|---|---|
| 263 | 263 | MDRV_SCREEN_SIZE(32*8, 32*8) |
| 264 | 264 | MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) |
| 265 | 265 | MDRV_GFXDECODE(gfxdecodeinfo) |
| 266 | MDRV_PALETTE_LENGTH(256) | |
| 267 | MDRV_COLORTABLE_LENGTH(64*4+16*16+4*32*8) | |
| 266 | MDRV_PALETTE_LENGTH(64*4+16*16+4*32*8) | |
| 268 | 267 | |
| 269 | 268 | MDRV_PALETTE_INIT(vulgus) |
| 270 | 269 | MDRV_VIDEO_START(vulgus) |
| r936 | r937 | |
|---|---|---|
| 473 | 473 | |
| 474 | 474 | |
| 475 | 475 | |
| 476 | ROM_START( | |
| 476 | ROM_START( | |
| 477 | 477 | ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* 6809 code */ |
| 478 | ROM_LOAD( "prg1.9c", 0x6000, 0x02000, CRC(ea2ea790) SHA1(ab6f523803b2b0ea04b78f2f252de6c2d344a26c) ) | |
| 479 | ROM_LOAD( "prg2.9a", 0x8000, 0x04000, CRC(9a0a9a87) SHA1(6d88fb5b443c822ede4884d4452e333834b16aca) ) | |
| 480 | ROM_LOAD( "prg3.9b", 0xc000, 0x04000, CRC(383e5458) SHA1(091f25e287f0a81649c9a4fa196ebe4112a82295) ) | |
| 478 | ROM_LOAD( "bd1_3.9c", 0x6000, 0x02000, CRC(ea2ea790) SHA1(ab6f523803b2b0ea04b78f2f252de6c2d344a26c) ) | |
| 479 | ROM_LOAD( "bd2_1.9a", 0x8000, 0x04000, CRC(9a0a9a87) SHA1(6d88fb5b443c822ede4884d4452e333834b16aca) ) | |
| 480 | ROM_LOAD( "bd2_2.9b", 0xc000, 0x04000, CRC(383e5458) SHA1(091f25e287f0a81649c9a4fa196ebe4112a82295) ) | |
| 481 | 481 | |
| 482 | 482 | ROM_REGION( 0x10000 , REGION_CPU2, 0 ) /* MCU code */ |
| 483 | ROM_LOAD( " | |
| 483 | ROM_LOAD( "bd1_4.3b", 0x8000, 0x4000, CRC(abda0fe7) SHA1(f7edcb5f9fa47bb38a8207af5678cf4ccc243547) ) /* subprogram for the MCU */ | |
| 484 | 484 | ROM_LOAD( "cus60-60a1.mcu", 0xf000, 0x1000, CRC(076ea82a) SHA1(22b5e62e26390d7d5cacc0503c7aa5ed524204df) ) /* MCU internal code */ |
| 485 | 485 | |
| 486 | 486 | ROM_REGION( 0x02000, REGION_GFX1, ROMREGION_DISPOSE ) |
| 487 | ROM_LOAD( " | |
| 487 | ROM_LOAD( "bd1_5.3j", | |
| 488 | 488 | |
| 489 | 489 | ROM_REGION( 0x10000, REGION_GFX2, ROMREGION_DISPOSE ) |
| 490 | ROM_LOAD( "ch2.4p", 0x00000, 0x4000, CRC(b0bb0710) SHA1(797832aea59bf80342fd2a3505645f2766bde65b) ) /* tiles */ | |
| 491 | ROM_LOAD( "ch3.4n", 0x04000, 0x4000, CRC(0d7ebec9) SHA1(6b86b476db61f5760bc8610b51adc1115cfdad96) ) | |
| 492 | ROM_LOAD( "ch4.4m", 0x08000, 0x4000, CRC(e5da0896) SHA1(abb8bf7e9dc1c60bc0a20a691109fb145bb1d8e0) ) | |
| 490 | ROM_LOAD( "bd2_8.4p", 0x00000, 0x4000, CRC(432bd7d9) SHA1(876e071b514864d434ab49002c5432f9c88665c1) ) /* tiles */ | |
| 491 | ROM_LOAD( "bd1_7.4n", 0x04000, 0x4000, CRC(0d7ebec9) SHA1(6b86b476db61f5760bc8610b51adc1115cfdad96) ) | |
| 492 | ROM_LOAD( "bd2_6.4m", 0x08000, 0x4000, CRC(f4c1df60) SHA1(8a3a6682884b227fe4293adb09624a4389ee660d) ) | |
| 493 | 493 | /* 0xc000-0xffff will be unpacked from 0x8000-0xbfff */ |
| 494 | 494 | |
| 495 | 495 | ROM_REGION( 0x10000, REGION_GFX3, ROMREGION_DISPOSE ) |
| 496 | ROM_LOAD( "obj1.8k", 0x00000, 0x4000, CRC(87a29acc) SHA1(3aa00efc95d1da50f6e4637d101640328287dea1) ) /* sprites */ | |
| 497 | ROM_LOAD( "obj2.8l", 0x04000, 0x4000, CRC(72b6d20c) SHA1(e40b48dacefce4fd62ab28d3e6ff3932d4ff005b) ) | |
| 498 | ROM_LOAD( "obj3.8m", 0x08000, 0x4000, CRC(3076af9c) SHA1(57ce09b298fd0bae94e4d8c817a34ce812c3ddfc) ) | |
| 499 | ROM_LOAD( "obj4.8n", 0x0c000, 0x4000, CRC(8b4c09a3) SHA1(46e0ef39cb313c6780f6137769153dc4a054c77f) ) | |
| 496 | ROM_LOAD( "bd1_9.8k", 0x00000, 0x4000, CRC(87a29acc) SHA1(3aa00efc95d1da50f6e4637d101640328287dea1) ) /* sprites */ | |
| 497 | ROM_LOAD( "bd1_10.8l", 0x04000, 0x4000, CRC(72b6d20c) SHA1(e40b48dacefce4fd62ab28d3e6ff3932d4ff005b) ) | |
| 498 | ROM_LOAD( "bd1_11.8m", 0x08000, 0x4000, CRC(3076af9c) SHA1(57ce09b298fd0bae94e4d8c817a34ce812c3ddfc) ) | |
| 499 | ROM_LOAD( "bd1_12.8n", 0x0c000, 0x4000, CRC(8b4c09a3) SHA1(46e0ef39cb313c6780f6137769153dc4a054c77f) ) | |
| 500 | 500 | |
| 501 | 501 | ROM_REGION( 0x1000, REGION_PROMS, 0 ) |
| 502 | ROM_LOAD( "prmcolbg.1n",0x0000, 0x0800, CRC(0d78ebc6) SHA1(0a0c1e23eb4d1748c4e6c448284d785286c77911) ) /* Blue + Green palette */ | |
| 503 | ROM_LOAD( "prmcolr.2m", 0x0800, 0x0800, CRC(03f7241f) SHA1(16ae059f084ba0ac4ddaa95dbeed113295f106ea) ) /* Red palette */ | |
| 502 | ROM_LOAD( "bd1-1.1n", 0x0000, 0x0800, CRC(0d78ebc6) SHA1(0a0c1e23eb4d1748c4e6c448284d785286c77911) ) /* Blue + Green palette (prom type mb7138e) */ | |
| 503 | ROM_LOAD( "bd1-2.2m", 0x0800, 0x0800, CRC(03f7241f) SHA1(16ae059f084ba0ac4ddaa95dbeed113295f106ea) ) /* Red palette (prom type mb7128e) */ | |
| 504 | 504 | ROM_END |
| 505 | 505 | |
| 506 | ROM_START( baraduk | |
| 506 | ROM_START( baraduke ) | |
| 507 | 507 | ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* 6809 code */ |
| 508 | ROM_LOAD( "prg1.9c", 0x6000, 0x02000, CRC(ea2ea790) SHA1(ab6f523803b2b0ea04b78f2f252de6c2d344a26c) ) | |
| 509 | ROM_LOAD( "bd1_1.9a", 0x8000, 0x04000, CRC(4e9f2bdc) SHA1(bc6e71d4d3b2064e662a105c1a77d2731070d58e) ) | |
| 510 | ROM_LOAD( "bd1_2.9b", 0xc000, 0x04000, CRC(40617fcd) SHA1(51d17f3a2fc96e13c8ef5952efece526e0fb33f4) ) | |
| 508 | ROM_LOAD( "bd1_3.9c", 0x6000, 0x02000, CRC(ea2ea790) SHA1(ab6f523803b2b0ea04b78f2f252de6c2d344a26c) ) | |
| 509 | ROM_LOAD( "bd1_1.9a", 0x8000, 0x04000, CRC(4e9f2bdc) SHA1(bc6e71d4d3b2064e662a105c1a77d2731070d58e) ) | |
| 510 | ROM_LOAD( "bd1_2.9b", 0xc000, 0x04000, CRC(40617fcd) SHA1(51d17f3a2fc96e13c8ef5952efece526e0fb33f4) ) | |
| 511 | 511 | |
| 512 | 512 | ROM_REGION( 0x10000 , REGION_CPU2, 0 ) /* MCU code */ |
| 513 | 513 | ROM_LOAD( "bd1_4b.3b", 0x8000, 0x4000, CRC(a47ecd32) SHA1(a2a75e65deb28224a5729ed134ee4d5ea8c50706) ) /* subprogram for the MCU */ |
| 514 | 514 | ROM_LOAD( "cus60-60a1.mcu", 0xf000, 0x1000, CRC(076ea82a) SHA1(22b5e62e26390d7d5cacc0503c7aa5ed524204df) ) /* MCU internal code */ |
| 515 | 515 | |
| 516 | 516 | ROM_REGION( 0x02000, REGION_GFX1, ROMREGION_DISPOSE ) |
| 517 | ROM_LOAD( " | |
| 517 | ROM_LOAD( "bd1_5.3j", | |
| 518 | 518 | |
| 519 | 519 | ROM_REGION( 0x10000, REGION_GFX2, ROMREGION_DISPOSE ) |
| 520 | ROM_LOAD( "ch2.4p", 0x00000, 0x4000, CRC(b0bb0710) SHA1(797832aea59bf80342fd2a3505645f2766bde65b) ) /* tiles */ | |
| 521 | ROM_LOAD( "ch3.4n", 0x04000, 0x4000, CRC(0d7ebec9) SHA1(6b86b476db61f5760bc8610b51adc1115cfdad96) ) | |
| 522 | ROM_LOAD( "ch4.4m", 0x08000, 0x4000, CRC(e5da0896) SHA1(abb8bf7e9dc1c60bc0a20a691109fb145bb1d8e0) ) | |
| 520 | ROM_LOAD( "bd1_8.4p", 0x00000, 0x4000, CRC(b0bb0710) SHA1(797832aea59bf80342fd2a3505645f2766bde65b) ) /* tiles */ | |
| 521 | ROM_LOAD( "bd1_7.4n", 0x04000, 0x4000, CRC(0d7ebec9) SHA1(6b86b476db61f5760bc8610b51adc1115cfdad96) ) | |
| 522 | ROM_LOAD( "bd1_6.4m", 0x08000, 0x4000, CRC(e5da0896) SHA1(abb8bf7e9dc1c60bc0a20a691109fb145bb1d8e0) ) | |
| 523 | 523 | /* 0xc000-0xffff will be unpacked from 0x8000-0xbfff */ |
| 524 | 524 | |
| 525 | 525 | ROM_REGION( 0x10000, REGION_GFX3, ROMREGION_DISPOSE ) |
| 526 | ROM_LOAD( "obj1.8k", 0x00000, 0x4000, CRC(87a29acc) SHA1(3aa00efc95d1da50f6e4637d101640328287dea1) ) /* sprites */ | |
| 527 | ROM_LOAD( "obj2.8l", 0x04000, 0x4000, CRC(72b6d20c) SHA1(e40b48dacefce4fd62ab28d3e6ff3932d4ff005b) ) | |
| 528 | ROM_LOAD( "obj3.8m", 0x08000, 0x4000, CRC(3076af9c) SHA1(57ce09b298fd0bae94e4d8c817a34ce812c3ddfc) ) | |
| 529 | ROM_LOAD( "obj4.8n", 0x0c000, 0x4000, CRC(8b4c09a3) SHA1(46e0ef39cb313c6780f6137769153dc4a054c77f) ) | |
| 526 | ROM_LOAD( "bd1_9.8k", 0x00000, 0x4000, CRC(87a29acc) SHA1(3aa00efc95d1da50f6e4637d101640328287dea1) ) /* sprites */ | |
| 527 | ROM_LOAD( "bd1_10.8l", 0x04000, 0x4000, CRC(72b6d20c) SHA1(e40b48dacefce4fd62ab28d3e6ff3932d4ff005b) ) | |
| 528 | ROM_LOAD( "bd1_11.8m", 0x08000, 0x4000, CRC(3076af9c) SHA1(57ce09b298fd0bae94e4d8c817a34ce812c3ddfc) ) | |
| 529 | ROM_LOAD( "bd1_12.8n", 0x0c000, 0x4000, CRC(8b4c09a3) SHA1(46e0ef39cb313c6780f6137769153dc4a054c77f) ) | |
| 530 | 530 | |
| 531 | 531 | ROM_REGION( 0x1000, REGION_PROMS, 0 ) |
| 532 | ROM_LOAD( "prmcolbg.1n",0x0000, 0x0800, CRC(0d78ebc6) SHA1(0a0c1e23eb4d1748c4e6c448284d785286c77911) ) /* Blue + Green palette */ | |
| 533 | ROM_LOAD( "prmcolr.2m", 0x0800, 0x0800, CRC(03f7241f) SHA1(16ae059f084ba0ac4ddaa95dbeed113295f106ea) ) /* Red palette */ | |
| 532 | ROM_LOAD( "bd1-1.1n", 0x0000, 0x0800, CRC(0d78ebc6) SHA1(0a0c1e23eb4d1748c4e6c448284d785286c77911) ) /* Blue + Green palette (prom type mb7138e) */ | |
| 533 | ROM_LOAD( "bd1-2.2m", 0x0800, 0x0800, CRC(03f7241f) SHA1(16ae059f084ba0ac4ddaa95dbeed113295f106ea) ) /* Red palette (prom type mb7128e) */ | |
| 534 | 534 | ROM_END |
| 535 | 535 | |
| 536 | 536 | ROM_START( metrocrs ) |
| r936 | r937 | |
| 612 | 612 | |
| 613 | 613 | GAME( 1985, metrocrs, 0, baraduke, metrocrs, baraduke, ROT0, "Namco", "Metro-Cross (set 1)", 0 ) |
| 614 | 614 | GAME( 1985, metrocra, metrocrs, baraduke, metrocrs, baraduke, ROT0, "Namco", "Metro-Cross (set 2)", 0 ) |
| 615 | GAME( 1985, baraduke, 0, baraduke, baraduke, baraduke, ROT0, "Namco", "Baraduke (set 1)", 0 ) | |
| 616 | GAME( 1985, baraduka, baraduke, baraduke, baraduke, baraduke, ROT0, "Namco", "Baraduke (set 2)", 0 ) | |
| 615 | GAME( 1985, aliensec, 0, baraduke, baraduke, baraduke, ROT0, "Namco", "Alien Sector", 0 ) | |
| 616 | GAME( 1985, baraduke, aliensec, baraduke, baraduke, baraduke, ROT0, "Namco", "Baraduke", 0 ) |
| r936 | r937 | |
|---|---|---|
| 3454 | 3454 | |
| 3455 | 3455 | sound_cpu = 1; |
| 3456 | 3456 | /* Oscar has three CPUs */ |
| 3457 | if (machine->drv->cpu[2].cpu_type != | |
| 3457 | if (machine->drv->cpu[2].cpu_type != CPU_DUMMY) sound_cpu = 2; | |
| 3458 | 3458 | |
| 3459 | 3459 | /* bits 5 and 6 of the opcodes are swapped */ |
| 3460 | 3460 | rom = memory_region(REGION_CPU1+sound_cpu); |
| r936 | r937 | |
|---|---|---|
| 118 | 118 | #include "sound/ay8910.h" |
| 119 | 119 | |
| 120 | 120 | |
| 121 | #define MASTER_CLOCK (18432000) | |
| 122 | #define SOUND_CLOCK (10000000) | |
| 123 | ||
| 124 | #define PIXEL_CLOCK (MASTER_CLOCK/3) | |
| 125 | ||
| 126 | /* H counts from 128->511, HBLANK starts at 128 and ends at 256 */ | |
| 127 | #define HTOTAL (384) | |
| 128 | #define HBEND (0) /*(256)*/ | |
| 129 | #define HBSTART (256) /*(128)*/ | |
| 130 | ||
| 131 | #define VTOTAL (264) | |
| 132 | #define VBEND (16) | |
| 133 | #define VBSTART (224+16) | |
| 134 | ||
| 135 | ||
| 136 | ||
| 137 | ||
| 121 | 138 | extern UINT8 *thepit_videoram; |
| 122 | 139 | extern UINT8 *thepit_colorram; |
| 123 | 140 | extern UINT8 *thepit_attributesram; |
| r936 | r937 | |
| 127 | 144 | PALETTE_INIT( thepit ); |
| 128 | 145 | PALETTE_INIT( suprmous ); |
| 129 | 146 | VIDEO_START( thepit ); |
| 130 | VIDEO_START( intrepid ); | |
| 131 | VIDEO_START( suprmous ); | |
| 132 | 147 | VIDEO_UPDATE( thepit ); |
| 133 | 148 | WRITE8_HANDLER( thepit_videoram_w ); |
| 134 | 149 | WRITE8_HANDLER( thepit_colorram_w ); |
| r936 | r937 | |
| 554 | 569 | |
| 555 | 570 | static const gfx_layout thepit_charlayout = |
| 556 | 571 | { |
| 557 | 8,8, /* 8*8 characters */ | |
| 558 | 256, /* 256 characters */ | |
| 559 | 2, /* 2 bits per pixel */ | |
| 560 | { 0x1000*8, 0 }, /* the two bitplanes are separated */ | |
| 561 | { 0, 1, 2, 3, 4, 5, 6, 7 }, | |
| 562 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 563 | 8*8 /* every char takes 8 consecutive bytes */ | |
| 572 | 8,8, | |
| 573 | 256, | |
| 574 | 2, | |
| 575 | { 0x1000*8, 0 }, | |
| 576 | { STEP8(0,1) }, | |
| 577 | { STEP8(0,8) }, | |
| 578 | 8*8 | |
| 564 | 579 | }; |
| 565 | 580 | |
| 566 | 581 | |
| 567 | 582 | static const gfx_layout thepit_spritelayout = |
| 568 | 583 | { |
| 569 | 16,16, /* 16*16 sprites */ | |
| 570 | 64, /* 64 sprites */ | |
| 571 | 2, /* 2 bits per pixel */ | |
| 572 | { 0x1000*8, 0 }, /* the two bitplanes are separated */ | |
| 573 | { 0, 1, 2, 3, 4, 5, 6, 7, | |
| 574 | 8*8+0, 8*8+1, 8*8+2, 8*8+3, 8*8+4, 8*8+5, 8*8+6, 8*8+7 }, | |
| 575 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, | |
| 576 | 16*8, 17*8, 18*8, 19*8, 20*8, 21*8, 22*8, 23*8 }, | |
| 577 | 32*8 /* every sprite takes 32 consecutive bytes */ | |
| 584 | 16,16, | |
| 585 | 64, | |
| 586 | 2, | |
| 587 | { 0x1000*8, 0 }, | |
| 588 | { STEP8(0,1), STEP8(8*8,1) }, | |
| 589 | { STEP8(0,8), STEP8(16*8,8) }, | |
| 590 | 32*8 | |
| 578 | 591 | }; |
| 579 | 592 | |
| 580 | 593 | |
| 581 | 594 | static const gfx_layout suprmous_charlayout = |
| 582 | 595 | { |
| 583 | 8,8, /* 8*8 characters */ | |
| 584 | 256, /* 256 characters */ | |
| 585 | 3, /* 3 bits per pixel */ | |
| 586 | { 0x2000*8, 0x1000*8, 0 }, /* the three bitplanes for 4 pixels are separated */ | |
| 587 | { 0, 1, 2, 3, 4, 5, 6, 7 }, | |
| 588 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, | |
| 589 | 8*8 /* every char takes 8 consecutive bytes */ | |
| 596 | 8,8, | |
| 597 | 256, | |
| 598 | 3, | |
| 599 | { 0x2000*8, 0x1000*8, 0 }, | |
| 600 | { STEP8(0,1) }, | |
| 601 | { STEP8(0,8) }, | |
| 602 | 8*8 | |
| 590 | 603 | }; |
| 591 | 604 | |
| 592 | 605 | |
| 593 | 606 | static const gfx_layout suprmous_spritelayout = |
| 594 | 607 | { |
| 595 | 16,16, /* 16*16 sprites */ | |
| 596 | 64, /* 64 sprites */ | |
| 597 | 3, /* 3 bits per pixel */ | |
| 598 | { 0x2000*8, 0x1000*8, 0 }, /* the bitplanes are separated */ | |
| 599 | { 0, 1, 2, 3, 4, 5, 6, 7, | |
| 600 | 8*8+0, 8*8+1, 8*8+2, 8*8+3, 8*8+4, 8*8+5, 8*8+6, 8*8+7 }, | |
| 601 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, | |
| 602 | 16*8, 17*8, 18*8, 19*8, 20*8, 21*8, 22*8, 23*8 }, | |
| 603 | 32*8 /* every sprite takes 32 consecutive bytes */ | |
| 608 | 16,16, | |
| 609 | 64, | |
| 610 | 3, | |
| 611 | { 0x2000*8, 0x1000*8, 0 }, | |
| 612 | { STEP8(0,1), STEP8(8*8,1) }, | |
| 613 | { STEP8(0,8), STEP8(16*8,8) }, | |
| 614 | 32*8 | |
| 604 | 615 | }; |
| 605 | 616 | |
| 606 | 617 | |
| 607 | 618 | static const gfx_decode thepit_gfxdecodeinfo[] = |
| 608 | 619 | { |
| 609 | { REGION_GFX1, 0, &thepit_charlayout, 0, 8 + 8 }, | |
| 610 | { REGION_GFX1, 0, &thepit_spritelayout, 0, 8 + 8 }, | |
| 620 | { REGION_GFX1, 0, &thepit_charlayout, 0, 8 }, | |
| 621 | { REGION_GFX1, 0, &thepit_spritelayout, 0, 8 }, | |
| 611 | 622 | { -1 } |
| 612 | 623 | }; |
| 613 | 624 | |
| 614 | 625 | static const gfx_decode intrepid_gfxdecodeinfo[] = |
| 615 | 626 | { |
| 616 | { REGION_GFX1, 0x0000, &thepit_charlayout, 0, 8 + 8 }, | |
| 617 | { REGION_GFX1, 0x0000, &thepit_spritelayout, 0, 8 + 8 }, | |
| 618 | { REGION_GFX1, 0x0800, &thepit_charlayout, 0, 8 + 8 }, | |
| 619 | { REGION_GFX1, 0x0800, &thepit_spritelayout, 0, 8 + 8 }, | |
| 627 | { REGION_GFX1, 0x0000, &thepit_charlayout, 0, 8 }, | |
| 628 | { REGION_GFX1, 0x0000, &thepit_spritelayout, 0, 8 }, | |
| 629 | { REGION_GFX1, 0x0800, &thepit_charlayout, 0, 8 }, | |
| 630 | { REGION_GFX1, 0x0800, &thepit_spritelayout, 0, 8 }, | |
| 620 | 631 | { -1 } |
| 621 | 632 | }; |
| 622 | 633 | |
| 623 | 634 | static const gfx_decode suprmous_gfxdecodeinfo[] = |
| 624 | 635 | { |
| 625 | { REGION_GFX1, 0x0000, &suprmous_charlayout, 0, 4 + 8 }, | |
| 626 | { REGION_GFX1, 0x0800, &suprmous_spritelayout, 0, 4 + 8 }, | |
| 636 | { REGION_GFX1, 0x0000, &suprmous_charlayout, 0, 4 }, | |
| 637 | { REGION_GFX1, 0x0800, &suprmous_spritelayout, 0, 4 }, | |
| 627 | 638 | { -1 } |
| 628 | 639 | }; |
| 629 | 640 | |
| r936 | r937 | |
| 637 | 648 | static MACHINE_DRIVER_START( thepit ) |
| 638 | 649 | |
| 639 | 650 | /* basic machine hardware */ |
| 640 | MDRV_CPU_ADD_TAG("main", Z80, | |
| 651 | MDRV_CPU_ADD_TAG("main", Z80, PIXEL_CLOCK/2) /* 3.072 MHz */ | |
| 641 | 652 | MDRV_CPU_PROGRAM_MAP(thepit_main_map,0) |
| 642 | 653 | MDRV_CPU_VBLANK_INT(nmi_line_pulse,1) |
| 643 | 654 | |
| 644 | MDRV_CPU_ADD(Z80, 10000000/4) /* 2.5 MHz */ | |
| 645 | /* audio CPU */ | |
| 655 | MDRV_CPU_ADD(Z80, SOUND_CLOCK/4) /* 2.5 MHz */ | |
| 646 | 656 | MDRV_CPU_PROGRAM_MAP(audio_map,0) |
| 647 | 657 | MDRV_CPU_IO_MAP(audio_io_map,0) |
| 648 | 658 | MDRV_CPU_VBLANK_INT(irq0_line_hold,1) |
| 649 | 659 | |
| 650 | 660 | /* video hardware */ |
| 651 | 661 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) |
| 652 | MDRV_VIDEO_START(thepit) | |
| 653 | MDRV_VIDEO_UPDATE(thepit) | |
| 662 | MDRV_GFXDECODE(thepit_gfxdecodeinfo) | |
| 654 | 663 | MDRV_PALETTE_LENGTH(32+8) |
| 655 | MDRV_PALETTE_INIT(thepit) | |
| 656 | MDRV_GFXDECODE(thepit_gfxdecodeinfo) | |
| 657 | MDRV_COLORTABLE_LENGTH(32+32) | |
| 658 | 664 | |
| 659 | 665 | MDRV_SCREEN_ADD("main", 0) |
| 660 | 666 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 661 | MDRV_SCREEN_SIZE(32*8, 32*8) | |
| 662 | MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) | |
| 663 | MDRV_SCREEN_REFRESH_RATE(60) | |
| 664 | MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION /* frames per second, vblank duration */) | |
| 667 | MDRV_SCREEN_RAW_PARAMS(PIXEL_CLOCK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART) | |
| 665 | 668 | |
| 669 | MDRV_PALETTE_INIT(thepit) | |
| 670 | MDRV_VIDEO_START(thepit) | |
| 671 | MDRV_VIDEO_UPDATE(thepit) | |
| 672 | ||
| 666 | 673 | /* sound hardware */ |
| 667 | 674 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 668 | 675 | |
| 669 | MDRV_SOUND_ADD(AY8910, | |
| 676 | MDRV_SOUND_ADD(AY8910, PIXEL_CLOCK/4 | |
| 670 | 677 | MDRV_SOUND_CONFIG(ay8910_interface) |
| 671 | 678 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 672 | 679 | |
| 673 | MDRV_SOUND_ADD(AY8910, | |
| 680 | MDRV_SOUND_ADD(AY8910, PIXEL_CLOCK/4 | |
| 674 | 681 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 675 | 682 | MACHINE_DRIVER_END |
| 676 | 683 | |
| r936 | r937 | |
| 683 | 690 | MDRV_CPU_PROGRAM_MAP(intrepid_main_map,0) |
| 684 | 691 | |
| 685 | 692 | /* video hardware */ |
| 686 | MDRV_VIDEO_START(intrepid) | |
| 687 | 693 | MDRV_GFXDECODE(intrepid_gfxdecodeinfo) |
| 688 | 694 | MACHINE_DRIVER_END |
| 689 | 695 | |
| r936 | r937 | |
| 694 | 700 | MDRV_IMPORT_FROM(intrepid) |
| 695 | 701 | |
| 696 | 702 | /* video hardware */ |
| 697 | MDRV_VIDEO_START(suprmous) | |
| 698 | 703 | MDRV_PALETTE_INIT(suprmous) |
| 699 | 704 | MDRV_GFXDECODE(suprmous_gfxdecodeinfo) |
| 700 | MDRV_COLORTABLE_LENGTH(32+64) | |
| 701 | 705 | MACHINE_DRIVER_END |
| 702 | 706 | |
| 703 | 707 | |
| r936 | r937 | |
| 968 | 972 | ROM_LOAD( "mm7.3d", 0x2000, 0x1000, CRC(a6f60ed2) SHA1(7ce12a10546144ce529d41159b593f1bac9b900b) ) |
| 969 | 973 | |
| 970 | 974 | ROM_REGION( 0x0040, REGION_PROMS, 0 ) |
| 971 | ROM_LOAD( "mmouse2.clr", 0x0000, 0x0020, NO_DUMP ) | |
| 972 | ROM_LOAD( "mmouse1.clr", 0x0020, 0x0020, NO_DUMP ) | |
| 975 | ROM_LOAD( "mm-pr1.1", 0x0000, 0x0020, CRC(e4babc1f) SHA1(a41991baafbb3696ea2724a58c31929882341109) ) | |
| 976 | ROM_LOAD( "mm-pr2.2", 0x0020, 0x0020, CRC(9a4919ed) SHA1(09d59b3943a52868fceef9571ca48b7b2e3b24a4) ) | |
| 973 | 977 | ROM_END |
| 974 | 978 | |
| 975 | 979 | ROM_START( rtriv ) |
| r936 | r937 | |
| 1053 | 1057 | GAME( 1982, portman, dockman, intrepid, dockman, 0, ROT90, "Nova Games Ltd.", "Port Man", 0 ) |
| 1054 | 1058 | GAME( 1982, funnymou, 0, suprmous, suprmous, 0, ROT90, "Chuo Co. Ltd", "Funny Mouse", 0 ) |
| 1055 | 1059 | GAME( 1982, suprmous, funnymou, suprmous, suprmous, 0, ROT90, "Taito Corporation", "Super Mouse", 0 ) |
| 1056 | GAME( 1982, machomou, 0, suprmous, suprmous, 0, ROT90, "Techstar", "Macho Mouse", | |
| 1060 | GAME( 1982, machomou, 0, suprmous, suprmous, 0, ROT90, "Techstar", "Macho Mouse", 0 | |
| 1057 | 1061 | GAME( 1983, intrepid, 0, intrepid, intrepid, 0, ROT90, "Nova Games Ltd.", "Intrepid (set 1)", 0 ) |
| 1058 | 1062 | GAME( 1983, intrepi2, intrepid, intrepid, intrepid, 0, ROT90, "Nova Games Ltd.", "Intrepid (set 2)", 0 ) |
| 1059 | 1063 | GAME( 1984, zaryavos, 0, intrepid, intrepid, 0, ROT90, "Nova Games of Canada", "Zarya Vostoka", GAME_NOT_WORKING ) |
| r936 | r937 | |
|---|---|---|
| 12 | 12 | Sound: AY-3-8910 |
| 13 | 13 | OSC: 18.432MHz and 8MHz |
| 14 | 14 | |
| 15 | ------------------------------------------------------------------------------------------- | |
| 16 | Year + Game Board Company Notes | |
| 17 | ------------------------------------------------------------------------------------------- | |
| 18 | 82 Royal Mahjong FRM-03 Falcon | |
| 19 | 86 Don Den Mahjong D039198L-0 Dyna Electronics | |
| 20 | 86 Watashiha Suzumechan Dyna Electronics | |
| 21 | 87 Mahjong Diplomat D0706088L1-0 Dynax | |
| 22 | 87 Mahjong Studio 101 D1708228L1 Dynax | |
| 23 | 87 Tonton D0908288L1-0 Dynax | |
| 24 | 88 Mahjong Almond Pinky D1401128L-0 Dynax | |
| 25 | 89 Mahjong Derringer D2203018L Dynax Larger palette | |
| 26 | 90 Mahjong If..? D29? Dynax Larger palette, TLCS-90 CPU | |
| 27 | 95 Mahjong Tensinhai D10010318L1 Dynax Real Time Clock, TLCS-90 CPU | |
| 28 | 96 Janputer '96 Dynax Real Time Clock | |
| 29 | ------------------------------------------------------------------------------------------- | |
| 15 | ---------------------------------------------------------------------------------------------------------- | |
| 16 | Year + Game Board CPU Company Notes | |
| 17 | ---------------------------------------------------------------------------------------------------------- | |
| 18 | 82 Royal Mahjong FRM-03 Z80 Falcon | |
| 19 | 86 Don Den Mahjong D039198L-0 Z80 Dyna Electronics | |
| 20 | 86 Watashiha Suzumechan Z80 Dyna Electronics | |
| 21 | 87 Mahjong Diplomat D0706088L1-0 Z80 Dynax | |
| 22 | 87 Mahjong Studio 101 D1708228L1 Z80 Dynax | |
| 23 | 87 Tonton D0908288L1-0 Z80 Dynax | |
| 24 | 88 Mahjong Almond Pinky D1401128L-0 Z80 Dynax | |
| 25 | 89 Mahjong Derringer D2203018L Z80 Dynax Larger palette | |
| 26 | 90 Mahjong If..? D29? TLCS-90 Dynax Larger palette | |
| 27 | 92 Mahjong Cafe Time D6310128L1-1 TLCS-90 Dynax Larger palette, Real Time Clock | |
| 28 | 95 Mahjong Tensinhai D10010318L1 TLCS-90 Dynax Larger palette, Real Time Clock | |
| 29 | 96 Janputer '96 Z80 Dynax Larger palette, Real Time Clock | |
| 30 | ---------------------------------------------------------------------------------------------------------- | |
| 30 | 31 | |
| 31 | 32 | TODO: |
| 32 | 33 | |
| 33 | - dip switches and inputs in dondenmj, suzume, mj | |
| 34 | - dip switches and inputs in dondenmj, suzume, mj | |
| 34 | 35 | |
| 35 | 36 | - there's something fishy with the bank switching in tontonb/mjdiplob |
| 36 | 37 | |
| r936 | r937 | |
| 75 | 76 | - janptr96: in service mode press in sequence N,Ron,Ron,N to access some |
| 76 | 77 | hidden options. (thanks bnathan) |
| 77 | 78 | |
| 78 | ||
| 79 | *** Notes by Roberto Fresca *** | |
| 80 | ||
| 81 | - Added Mahjong Almond Pinky (Dynax, 1988). | |
| 82 | Sub board: D1401128L-0 | |
| 83 | ||
| 84 | - Mapped all read/writes, but some ones need to be figured out.. | |
| 85 | - Updated technical notes. | |
| 86 | ||
| 87 | ||
| 88 | 79 | ****************************************************************************/ |
| 89 | 80 | |
| 90 | 81 | #include "driver.h" |
| r936 | r937 | |
| 93 | 84 | #include "sound/ay8910.h" |
| 94 | 85 | |
| 95 | 86 | |
| 87 | static UINT8 input_port_select, dsw_select, rombank; | |
| 96 | 88 | static int palette_base; |
| 97 | 89 | |
| 98 | 90 | |
| 99 | static | |
| 91 | static PALETTE_INIT( royalmah | |
| 100 | 92 | { |
| 101 | 93 | offs_t i; |
| 102 | 94 | |
| r936 | r937 | |
| 124 | 116 | bit2 = (data >> 7) & 0x01; |
| 125 | 117 | b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 126 | 118 | |
| 127 | pe | |
| 119 | palette_set | |
| 128 | 120 | } |
| 129 | 121 | } |
| 130 | 122 | |
| 131 | 123 | |
| 132 | static | |
| 124 | static PALETTE_INIT( mjderngr | |
| 133 | 125 | { |
| 134 | 126 | offs_t i; |
| 135 | 127 | |
| r936 | r937 | |
| 142 | 134 | UINT8 g = BITSWAP8((data >> 5) & 0x1f,7,6,5,0,1,2,3,4 ); |
| 143 | 135 | UINT8 b = BITSWAP8((data >> 10) & 0x1f,7,6,5,0,1,2,3,4 ); |
| 144 | 136 | |
| 145 | pe | |
| 137 | palette_set | |
| 146 | 138 | } |
| 147 | 139 | } |
| 148 | 140 | |
| r936 | r937 | |
| 174 | 166 | } |
| 175 | 167 | |
| 176 | 168 | |
| 177 | static | |
| 169 | static VIDEO | |
| 178 | 170 | { |
| 171 | ||
| 179 | 172 | offs_t offs; |
| 180 | 173 | |
| 181 | 174 | for (offs = 0; offs < 0x4000; offs++) |
| r936 | r937 | |
| 190 | 183 | |
| 191 | 184 | for (i = 0; i < 4; i++) |
| 192 | 185 | { |
| 193 | UINT8 | |
| 186 | UINT8 pen | |
| 194 | 187 | |
| 195 | *BITMAP_ADDR | |
| 188 | *BITMAP_ADDR16(bitmap, y, x) = | |
| 196 | 189 | |
| 197 | 190 | x = x - 1; |
| 198 | 191 | data1 = data1 >> 1; |
| r936 | r937 | |
| 204 | 197 | } |
| 205 | 198 | |
| 206 | 199 | |
| 207 | static VIDEO_UPDATE( royalmah ) | |
| 208 | { | |
| 209 | pen_t pens[0x400]; | |
| 210 | royalmah_get_pens(pens); | |
| 211 | 200 | |
| 212 | return video_update_common(bitmap, cliprect, pens); | |
| 213 | } | |
| 214 | 201 | |
| 215 | 202 | |
| 216 | static VIDEO_UPDATE( mjderngr ) | |
| 217 | { | |
| 218 | pen_t pens[0x400]; | |
| 219 | mjderngr_get_pens(pens); | |
| 220 | ||
| 221 | return video_update_common(bitmap, cliprect, pens); | |
| 222 | } | |
| 223 | ||
| 224 | ||
| 225 | ||
| 226 | 203 | static WRITE8_HANDLER( royalmah_rom_w ) |
| 227 | 204 | { |
| 228 | 205 | /* using this handler will avoid all the entries in the error log that are the result of |
| r936 | r937 | |
| 230 | 207 | } |
| 231 | 208 | |
| 232 | 209 | |
| 233 | static int royalmah_input_port_select; | |
| 234 | static int majs101b_dsw_select; | |
| 235 | ||
| 236 | static WRITE8_HANDLER( royalmah_input_port_select_w ) | |
| 210 | static WRITE8_HANDLER( input_port_select_w ) | |
| 237 | 211 | { |
| 238 | | |
| 212 | | |
| 239 | 213 | } |
| 240 | 214 | |
| 241 | 215 | static READ8_HANDLER( royalmah_player_1_port_r ) |
| 242 | 216 | { |
| 243 | 217 | int ret = (input_port_0_r(offset) & 0xc0) | 0x3f; |
| 244 | 218 | |
| 245 | if ((royalmah_input_port_select & 0x01) == 0) ret &= input_port_0_r(offset); | |
| 246 | if ((royalmah_input_port_select & 0x02) == 0) ret &= input_port_1_r(offset); | |
| 247 | if ((royalmah_input_port_select & 0x04) == 0) ret &= input_port_2_r(offset); | |
| 248 | if ((royalmah_input_port_select & 0x08) == 0) ret &= input_port_3_r(offset); | |
| 249 | if ((royalmah_input_port_select & 0x10) == 0) ret &= input_port_4_r(offset); | |
| 219 | if ((input_port_select & 0x01) == 0) ret &= input_port_0_r(offset); | |
| 220 | if ((input_port_select & 0x02) == 0) ret &= input_port_1_r(offset); | |
| 221 | if ((input_port_select & 0x04) == 0) ret &= input_port_2_r(offset); | |
| 222 | if ((input_port_select & 0x08) == 0) ret &= input_port_3_r(offset); | |
| 223 | if ((input_port_select & 0x10) == 0) ret &= input_port_4_r(offset); | |
| 250 | 224 | |
| 251 | 225 | return ret; |
| 252 | 226 | } |
| r936 | r937 | |
| 255 | 229 | { |
| 256 | 230 | int ret = (input_port_5_r(offset) & 0xc0) | 0x3f; |
| 257 | 231 | |
| 258 | if ((royalmah_input_port_select & 0x01) == 0) ret &= input_port_5_r(offset); | |
| 259 | if ((royalmah_input_port_select & 0x02) == 0) ret &= input_port_6_r(offset); | |
| 260 | if ((royalmah_input_port_select & 0x04) == 0) ret &= input_port_7_r(offset); | |
| 261 | if ((royalmah_input_port_select & 0x08) == 0) ret &= input_port_8_r(offset); | |
| 262 | if ((royalmah_input_port_select & 0x10) == 0) ret &= input_port_9_r(offset); | |
| 232 | if ((input_port_select & 0x01) == 0) ret &= input_port_5_r(offset); | |
| 233 | if ((input_port_select & 0x02) == 0) ret &= input_port_6_r(offset); | |
| 234 | if ((input_port_select & 0x04) == 0) ret &= input_port_7_r(offset); | |
| 235 | if ((input_port_select & 0x08) == 0) ret &= input_port_8_r(offset); | |
| 236 | if ((input_port_select & 0x10) == 0) ret &= input_port_9_r(offset); | |
| 263 | 237 | |
| 264 | 238 | return ret; |
| 265 | 239 | } |
| r936 | r937 | |
| 268 | 242 | |
| 269 | 243 | static READ8_HANDLER ( majs101b_dsw_r ) |
| 270 | 244 | { |
| 271 | switch ( | |
| 245 | switch ( | |
| 272 | 246 | { |
| 273 | 247 | case 0x00: return readinputport(13); /* DSW3 */ |
| 274 | 248 | case 0x20: return readinputport(14); /* DSW4 */ |
| r936 | r937 | |
| 314 | 288 | } |
| 315 | 289 | |
| 316 | 290 | |
| 291 | static WRITE8_HANDLER ( mjapinky_bank_w ) | |
| 292 | { | |
| 293 | UINT8 *ROM = memory_region(REGION_CPU1); | |
| 294 | rombank = data; | |
| 295 | memory_set_bankptr(1,ROM + 0x10000 + 0x8000 * data); | |
| 296 | } | |
| 297 | ||
| 298 | static WRITE8_HANDLER( mjapinky_palbank_w ) | |
| 299 | { | |
| 300 | flip_screen_set(~data & 4); | |
| 301 | palette_base = (data >> 3) & 0x01; | |
| 302 | coin_counter_w(0,data & 2); // in | |
| 303 | coin_counter_w(1,data & 1); // out | |
| 304 | } | |
| 305 | ||
| 306 | static READ8_HANDLER( mjapinky_dsw_r ) | |
| 307 | { | |
| 308 | if (rombank == 0x0e) return readinputport(13); | |
| 309 | else return *(memory_region(REGION_CPU1) + 0x10000 + 0x8000 * rombank); | |
| 310 | } | |
| 311 | ||
| 317 | 312 | static WRITE8_HANDLER ( tontonb_bank_w ) |
| 318 | 313 | { |
| 319 | 314 | UINT8 *rom = memory_region(REGION_CPU1); |
| r936 | r937 | |
| 339 | 334 | |
| 340 | 335 | //logerror("%04x: bank %02x\n",activecpu_get_pc(),data); |
| 341 | 336 | |
| 342 | | |
| 337 | | |
| 343 | 338 | |
| 344 | 339 | data &= 0x1f; |
| 345 | 340 | |
| r936 | r937 | |
| 352 | 347 | |
| 353 | 348 | |
| 354 | 349 | |
| 355 | static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 356 | AM_RANGE(0x0000, 0x6fff) AM_READ(MRA8_ROM) | |
| 357 | AM_RANGE(0x7000, 0x7fff) AM_READ(MRA8_RAM) | |
| 358 | AM_RANGE(0x8000, 0xffff) AM_READ(MRA8_BANK1) // banked ROMs not present in royalmah | |
| 350 | static ADDRESS_MAP_START( royalmah_map, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 351 | AM_RANGE( 0x0000, 0x6fff ) AM_READWRITE( MRA8_ROM, royalmah_rom_w ) | |
| 352 | AM_RANGE( 0x7000, 0x7fff ) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size) | |
| 353 | AM_RANGE( 0x8000, 0xffff ) AM_READ( MRA8_BANK1 ) // banked ROMs not present in royalmah | |
| 354 | AM_RANGE( 0x8000, 0xffff ) AM_WRITE( MWA8_RAM ) AM_BASE(&videoram) | |
| 359 | 355 | ADDRESS_MAP_END |
| 360 | static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 361 | AM_RANGE(0x0000, 0x6fff) AM_WRITE(royalmah_rom_w) | |
| 362 | AM_RANGE(0x7000, 0x7fff) AM_WRITE(MWA8_RAM) AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size) | |
| 363 | AM_RANGE(0x8000, 0xffff) AM_WRITE(MWA8_RAM) AM_BASE(&videoram) | |
| 364 | ADDRESS_MAP_END | |
| 365 | 356 | |
| 366 | 357 | |
| 367 | ||
| 368 | static ADDRESS_MAP_START( royalmah_readport, ADDRESS_SPACE_IO, 8 ) | |
| 369 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 370 | AM_RANGE(0x01, 0x01) AM_READ(AY8910_read_port_0_r) | |
| 371 | AM_RANGE(0x10, 0x10) AM_READ(input_port_11_r) | |
| 372 | AM_RANGE(0x11, 0x11) AM_READ(input_port_10_r) | |
| 358 | static ADDRESS_MAP_START( mjapinky_map, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 359 | AM_RANGE( 0x0000, 0x6fff ) AM_READWRITE( MRA8_ROM, royalmah_rom_w ) | |
| 360 | AM_RANGE( 0x7000, 0x77ff ) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size) | |
| 361 | AM_RANGE( 0x7800, 0x7fff ) AM_RAM | |
| 362 | AM_RANGE( 0x8000, 0x8000 ) AM_READ( mjapinky_dsw_r ) | |
| 363 | AM_RANGE( 0x8000, 0xffff ) AM_READ( MRA8_BANK1 ) | |
| 364 | AM_RANGE( 0x8000, 0xffff ) AM_WRITE( MWA8_RAM ) AM_BASE(&videoram) | |
| 373 | 365 | ADDRESS_MAP_END |
| 374 | 366 | |
| 375 | static ADDRESS_MAP_START( royalmah_writeport, ADDRESS_SPACE_IO, 8 ) | |
| 376 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 377 | AM_RANGE(0x02, 0x02) AM_WRITE(AY8910_write_port_0_w) | |
| 378 | AM_RANGE(0x03, 0x03) AM_WRITE(AY8910_control_port_0_w) | |
| 379 | AM_RANGE(0x10, 0x10) AM_WRITE(royalmah_palbank_w) | |
| 380 | AM_RANGE(0x11, 0x11) AM_WRITE(royalmah_input_port_select_w) | |
| 381 | ADDRESS_MAP_END | |
| 382 | 367 | |
| 383 | static ADDRESS_MAP_START( suzume_readport, ADDRESS_SPACE_IO, 8 ) | |
| 384 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 385 | AM_RANGE(0x01, 0x01) AM_READ(AY8910_read_port_0_r) | |
| 386 | AM_RANGE(0x10, 0x10) AM_READ(input_port_11_r) | |
| 387 | AM_RANGE(0x11, 0x11) AM_READ(input_port_10_r) | |
| 388 | AM_RANGE(0x80, 0x80) AM_READ(suzume_dsw_r) | |
| 389 | ADDRESS_MAP_END | |
| 390 | 368 | |
| 391 | static ADDRESS_MAP_START( suzume_writeport, ADDRESS_SPACE_IO, 8 ) | |
| 392 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 393 | AM_RANGE(0x02, 0x02) AM_WRITE(AY8910_write_port_0_w) | |
| 394 | AM_RANGE(0x03, 0x03) AM_WRITE(AY8910_control_port_0_w) | |
| 395 | AM_RANGE(0x10, 0x10) AM_WRITE(royalmah_palbank_w) | |
| 396 | AM_RANGE(0x11, 0x11) AM_WRITE(royalmah_input_port_select_w) | |
| 397 | AM_RANGE(0x81, 0x81) AM_WRITE(suzume_bank_w) | |
| 398 | ADDRESS_MAP_END | |
| 399 | 369 | |
| 400 | static ADDRESS_MAP_START( | |
| 370 | static ADDRESS_MAP_START( royal | |
| 401 | 371 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 402 | AM_RANGE(0x01, 0x01) AM_READ(AY8910_read_port_0_r) | |
| 403 | AM_RANGE(0x10, 0x10) AM_READ(input_port_11_r) | |
| 404 | AM_RANGE(0x11, 0x11) AM_READ(input_port_10_r) | |
| 405 | AM_RANGE(0x85, 0x85) AM_READ(input_port_12_r) // DSW2 | |
| 406 | AM_RANGE(0x86, 0x86) AM_READ(input_port_13_r) // DSW3 | |
| 372 | AM_RANGE( 0x01, 0x01 ) AM_READ( AY8910_read_port_0_r ) | |
| 373 | AM_RANGE( 0x02, 0x02 ) AM_WRITE( AY8910_write_port_0_w ) | |
| 374 | AM_RANGE( 0x03, 0x03 ) AM_WRITE( AY8910_control_port_0_w ) | |
| 375 | AM_RANGE( 0x10, 0x10 ) AM_READWRITE( input_port_11_r, royalmah_palbank_w ) | |
| 376 | AM_RANGE( 0x11, 0x11 ) AM_READWRITE( input_port_10_r, input_port_select_w ) | |
| 407 | 377 | ADDRESS_MAP_END |
| 408 | 378 | |
| 409 | static ADDRESS_MAP_START( | |
| 379 | static ADDRESS_MAP_START( suzu | |
| 410 | 380 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 411 | AM_RANGE(0x02, 0x02) AM_WRITE(AY8910_write_port_0_w) | |
| 412 | AM_RANGE(0x03, 0x03) AM_WRITE(AY8910_control_port_0_w) | |
| 413 | AM_RANGE(0x10, 0x10) AM_WRITE(royalmah_palbank_w) | |
| 414 | AM_RANGE(0x11, 0x11) AM_WRITE(royalmah_input_port_select_w) | |
| 415 | AM_RANGE(0x87, 0x87) AM_WRITE(dynax_bank_w) | |
| 381 | AM_RANGE( 0x01, 0x01 ) AM_READ( AY8910_read_port_0_r ) | |
| 382 | AM_RANGE( 0x02, 0x02 ) AM_WRITE( AY8910_write_port_0_w ) | |
| 383 | AM_RANGE( 0x03, 0x03 ) AM_WRITE( AY8910_control_port_0_w ) | |
| 384 | AM_RANGE( 0x10, 0x10 ) AM_READWRITE( input_port_11_r, royalmah_palbank_w ) | |
| 385 | AM_RANGE( 0x11, 0x11 ) AM_READWRITE( input_port_10_r, input_port_select_w ) | |
| 386 | AM_RANGE( 0x80, 0x80 ) AM_READ( suzume_dsw_r ) | |
| 387 | AM_RANGE( 0x81, 0x81 ) AM_WRITE( suzume_bank_w ) | |
| 416 | 388 | ADDRESS_MAP_END |
| 417 | 389 | |
| 418 | static ADDRESS_MAP_START( mj | |
| 390 | static ADDRESS_MAP_START( dondenmj_i | |
| 419 | 391 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 420 | AM_RANGE(0x01, 0x01) AM_READ(AY8910_read_port_0_r) | |
| 421 | AM_RANGE(0x10, 0x10) AM_READ(input_port_11_r) | |
| 422 | AM_RANGE(0x11, 0x11) AM_READ(input_port_10_r) | |
| 423 | AM_RANGE(0x62, 0x62) AM_READ(input_port_12_r) // DSW2 | |
| 424 | AM_RANGE(0x63, 0x63) AM_READ(input_port_13_r) // DSW3 | |
| 392 | AM_RANGE( 0x01, 0x01 ) AM_READ( AY8910_read_port_0_r ) | |
| 393 | AM_RANGE( 0x02, 0x02 ) AM_WRITE( AY8910_write_port_0_w ) | |
| 394 | AM_RANGE( 0x03, 0x03 ) AM_WRITE(AY8910_control_port_0_w) | |
| 395 | AM_RANGE( 0x10, 0x10 ) AM_READWRITE( input_port_11_r, royalmah_palbank_w ) | |
| 396 | AM_RANGE( 0x11, 0x11 ) AM_READWRITE( input_port_10_r, input_port_select_w ) | |
| 397 | AM_RANGE( 0x85, 0x85 ) AM_READ( input_port_12_r ) // DSW2 | |
| 398 | AM_RANGE( 0x86, 0x86 ) AM_READ( input_port_13_r ) // DSW3 | |
| 399 | AM_RANGE( 0x87, 0x87 ) AM_WRITE( dynax_bank_w ) | |
| 425 | 400 | ADDRESS_MAP_END |
| 426 | 401 | |
| 427 | static ADDRESS_MAP_START( mjdiplob_ | |
| 402 | static ADDRESS_MAP_START( mjdiplob_ | |
| 428 | 403 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 429 | AM_RANGE(0x02, 0x02) AM_WRITE(AY8910_write_port_0_w) | |
| 430 | AM_RANGE(0x03, 0x03) AM_WRITE(AY8910_control_port_0_w) | |
| 431 | AM_RANGE(0x10, 0x10) AM_WRITE(royalmah_palbank_w) | |
| 432 | AM_RANGE(0x11, 0x11) AM_WRITE(royalmah_input_port_select_w) | |
| 433 | AM_RANGE(0x61, 0x61) AM_WRITE(tontonb_bank_w) | |
| 404 | AM_RANGE( 0x01, 0x01 ) AM_READ( AY8910_read_port_0_r ) | |
| 405 | AM_RANGE( 0x02, 0x02 ) AM_WRITE( AY8910_write_port_0_w ) | |
| 406 | AM_RANGE( 0x03, 0x03 ) AM_WRITE( AY8910_control_port_0_w ) | |
| 407 | AM_RANGE( 0x10, 0x10 ) AM_READWRITE( input_port_11_r, royalmah_palbank_w ) | |
| 408 | AM_RANGE( 0x11, 0x11 ) AM_READWRITE( input_port_10_r, input_port_select_w ) | |
| 409 | AM_RANGE( 0x61, 0x61 ) AM_WRITE(tontonb_bank_w) | |
| 410 | AM_RANGE( 0x62, 0x62 ) AM_READ( input_port_12_r ) // DSW2 | |
| 411 | AM_RANGE( 0x63, 0x63 ) AM_READ( input_port_13_r ) // DSW3 | |
| 434 | 412 | ADDRESS_MAP_END |
| 435 | 413 | |
| 436 | static ADDRESS_MAP_START( tontonb_ | |
| 414 | static ADDRESS_MAP_START( tontonb_ioma | |
| 437 | 415 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 438 | AM_RANGE(0x01, 0x01) AM_READ(AY8910_read_port_0_r) | |
| 439 | AM_RANGE(0x10, 0x10) AM_READ(input_port_11_r) | |
| 440 | AM_RANGE(0x11, 0x11) AM_READ(input_port_10_r) | |
| 441 | AM_RANGE(0x46, 0x46) AM_READ(input_port_13_r) // DSW2 | |
| 442 | AM_RANGE(0x47, 0x47) AM_READ(input_port_12_r) // DSW3 | |
| 416 | AM_RANGE( 0x01, 0x01 ) AM_READ( AY8910_read_port_0_r ) | |
| 417 | AM_RANGE( 0x02, 0x02 ) AM_WRITE( AY8910_write_port_0_w ) | |
| 418 | AM_RANGE( 0x03, 0x03 ) AM_WRITE( AY8910_control_port_0_w ) | |
| 419 | AM_RANGE( 0x10, 0x10 ) AM_READWRITE( input_port_11_r, royalmah_palbank_w ) | |
| 420 | AM_RANGE( 0x11, 0x11 ) AM_READWRITE( input_port_10_r, input_port_select_w ) | |
| 421 | AM_RANGE( 0x44, 0x44 ) AM_WRITE( tontonb_bank_w ) | |
| 422 | AM_RANGE( 0x46, 0x46 ) AM_READ( input_port_13_r ) // DSW2 | |
| 423 | AM_RANGE( 0x47, 0x47 ) AM_READ( input_port_12_r ) // DSW3 | |
| 443 | 424 | ADDRESS_MAP_END |
| 444 | 425 | |
| 445 | static ADDRESS_MAP_START( | |
| 426 | static ADDRESS_MAP_START( majs101b_ | |
| 446 | 427 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 447 | AM_RANGE(0x02, 0x02) AM_WRITE(AY8910_write_port_0_w) | |
| 448 | AM_RANGE(0x03, 0x03) AM_WRITE(AY8910_control_port_0_w) | |
| 449 | AM_RANGE(0x10, 0x10) AM_WRITE(royalmah_palbank_w) | |
| 450 | AM_RANGE(0x11, 0x11) AM_WRITE(royalmah_input_port_select_w) | |
| 451 | AM_RANGE(0x44, 0x44) AM_WRITE(tontonb_bank_w) | |
| 428 | AM_RANGE( 0x01, 0x01 ) AM_READ( AY8910_read_port_0_r ) | |
| 429 | AM_RANGE( 0x02, 0x02 ) AM_WRITE( AY8910_write_port_0_w ) | |
| 430 | AM_RANGE( 0x03, 0x03 ) AM_WRITE( AY8910_control_port_0_w ) | |
| 431 | AM_RANGE( 0x10, 0x10 ) AM_READWRITE( input_port_11_r, royalmah_palbank_w ) | |
| 432 | AM_RANGE( 0x11, 0x11 ) AM_READWRITE( input_port_10_r, input_port_select_w ) | |
| 433 | AM_RANGE( 0x00, 0x00 ) AM_READWRITE( majs101b_dsw_r, dynax_bank_w ) | |
| 452 | 434 | ADDRESS_MAP_END |
| 453 | 435 | |
| 454 | static ADDRESS_MAP_START( m | |
| 436 | static ADDRESS_MAP_START( m | |
| 455 | 437 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 456 | AM_RANGE(0x01, 0x01) AM_READ(AY8910_read_port_0_r) | |
| 457 | AM_RANGE(0x10, 0x10) AM_READ(input_port_11_r) | |
| 458 | AM_RANGE(0x11, 0x11) AM_READ(input_port_10_r) | |
| 459 | AM_RANGE(0x00, 0x00) AM_READ(majs101b_dsw_r) | |
| 438 | AM_RANGE( 0x01, 0x01 ) AM_READ( AY8910_read_port_0_r ) | |
| 439 | AM_RANGE( 0x02, 0x02 ) AM_WRITE( AY8910_write_port_0_w ) | |
| 440 | AM_RANGE( 0x03, 0x03 ) AM_WRITE( AY8910_control_port_0_w ) | |
| 441 | // AM_RANGE( 0x10, 0x10 ) AM_READ( input_port_11_r ) | |
| 442 | AM_RANGE( 0x10, 0x10 ) AM_WRITE( mjderngr_coin_w ) // palette bank is set separately | |
| 443 | AM_RANGE( 0x11, 0x11 ) AM_READWRITE( input_port_10_r, input_port_select_w ) | |
| 444 | AM_RANGE( 0x20, 0x20 ) AM_WRITE( dynax_bank_w ) | |
| 445 | AM_RANGE( 0x40, 0x40 ) AM_READ( input_port_13_r ) // DSW2 | |
| 446 | AM_RANGE( 0x4c, 0x4c ) AM_READ( input_port_12_r ) // DSW3 | |
| 447 | AM_RANGE( 0x60, 0x60 ) AM_WRITE( mjderngr_palbank_w ) | |
| 460 | 448 | ADDRESS_MAP_END |
| 461 | 449 | |
| 462 | static ADDRESS_MAP_START( m | |
| 450 | static ADDRESS_MAP_START( m | |
| 463 | 451 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 464 | AM_RANGE(0x02, 0x02) AM_WRITE(AY8910_write_port_0_w) | |
| 465 | AM_RANGE(0x03, 0x03) AM_WRITE(AY8910_control_port_0_w) | |
| 466 | AM_RANGE(0x10, 0x10) AM_WRITE(royalmah_palbank_w) | |
| 467 | AM_RANGE(0x11, 0x11) AM_WRITE(royalmah_input_port_select_w) | |
| 468 | AM_RANGE(0x00, 0x00) AM_WRITE(dynax_bank_w) | |
| 452 | AM_RANGE( 0x00, 0x00 ) AM_WRITE( mjapinky_bank_w ) | |
| 453 | AM_RANGE( 0x01, 0x01 ) AM_READ( AY8910_read_port_0_r ) | |
| 454 | AM_RANGE( 0x02, 0x02 ) AM_WRITE( AY8910_write_port_0_w ) | |
| 455 | AM_RANGE( 0x03, 0x03 ) AM_WRITE( AY8910_control_port_0_w ) | |
| 456 | AM_RANGE( 0x04, 0x04 ) AM_READ( input_port_12_r ) | |
| 457 | AM_RANGE( 0x10, 0x10 ) AM_READWRITE( input_port_11_r, mjapinky_palbank_w ) | |
| 458 | AM_RANGE( 0x11, 0x11 ) AM_READWRITE( input_port_10_r, input_port_select_w ) | |
| 469 | 459 | ADDRESS_MAP_END |
| 470 | 460 | |
| 471 | static ADDRESS_MAP_START( mjapinky_readport, ADDRESS_SPACE_IO, 8 ) | |
| 472 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 473 | AM_RANGE(0x01, 0x01) AM_READ(AY8910_read_port_0_r) | |
| 474 | AM_RANGE(0x04, 0x04) AM_READNOP // input port? | |
| 475 | AM_RANGE(0x10, 0x10) AM_READNOP // input port | |
| 476 | AM_RANGE(0x11, 0x11) AM_READNOP // input port | |
| 477 | AM_RANGE(0x00, 0x00) AM_READNOP // dsw? | |
| 478 | ADDRESS_MAP_END | |
| 479 | ||
| 480 | static ADDRESS_MAP_START( mjapinky_writeport, ADDRESS_SPACE_IO, 8 ) | |
| 481 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 482 | AM_RANGE(0x02, 0x02) AM_WRITE(AY8910_write_port_0_w) | |
| 483 | AM_RANGE(0x03, 0x03) AM_WRITE(AY8910_control_port_0_w) | |
| 484 | AM_RANGE(0x10, 0x10) AM_WRITE(royalmah_palbank_w) | |
| 485 | AM_RANGE(0x11, 0x11) AM_WRITE(royalmah_input_port_select_w) | |
| 486 | AM_RANGE(0x00, 0x00) AM_WRITE(dynax_bank_w) | |
| 487 | ADDRESS_MAP_END | |
| 488 | ||
| 489 | static ADDRESS_MAP_START( mjderngr_readport, ADDRESS_SPACE_IO, 8 ) | |
| 490 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 491 | AM_RANGE(0x01, 0x01) AM_READ(AY8910_read_port_0_r) | |
| 492 | // AM_RANGE(0x10, 0x10) AM_READ(input_port_11_r) | |
| 493 | AM_RANGE(0x11, 0x11) AM_READ(input_port_10_r) | |
| 494 | AM_RANGE(0x40, 0x40) AM_READ(input_port_13_r) // DSW2 | |
| 495 | AM_RANGE(0x4c, 0x4c) AM_READ(input_port_12_r) // DSW3 | |
| 496 | ADDRESS_MAP_END | |
| 497 | ||
| 498 | static ADDRESS_MAP_START( mjderngr_writeport, ADDRESS_SPACE_IO, 8 ) | |
| 499 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 500 | AM_RANGE(0x02, 0x02) AM_WRITE(AY8910_write_port_0_w) | |
| 501 | AM_RANGE(0x03, 0x03) AM_WRITE(AY8910_control_port_0_w) | |
| 502 | AM_RANGE(0x10, 0x10) AM_WRITE(mjderngr_coin_w) // palette bank is set separately | |
| 503 | AM_RANGE(0x11, 0x11) AM_WRITE(royalmah_input_port_select_w) | |
| 504 | AM_RANGE(0x20, 0x20) AM_WRITE(dynax_bank_w) | |
| 505 | AM_RANGE(0x60, 0x60) AM_WRITE(mjderngr_palbank_w) | |
| 506 | ADDRESS_MAP_END | |
| 507 | ||
| 508 | ||
| 509 | 461 | /**************************************************************************** |
| 510 | 462 | Janputer '96 |
| 511 | 463 | ****************************************************************************/ |
| 512 | 464 | |
| 513 | static ADDRESS_MAP_START( janptr96_readmem, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 514 | AM_RANGE(0x0000, 0x5fff) AM_READ(MRA8_ROM) | |
| 515 | AM_RANGE(0x6000, 0x6fff) AM_READ(MRA8_BANK3) | |
| 516 | AM_RANGE(0x7000, 0x7fff) AM_READ(MRA8_BANK2) | |
| 517 | AM_RANGE(0x8000, 0xffff) AM_READ(MRA8_BANK1) | |
| 465 | static ADDRESS_MAP_START( janptr96_map, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 466 | AM_RANGE( 0x0000, 0x5fff) AM_ROM | |
| 467 | AM_RANGE( 0x6000, 0x6fff ) AM_RAMBANK(3) // nvram | |
| 468 | AM_RANGE( 0x7000, 0x7fff ) AM_RAMBANK(2) // banked nvram | |
| 469 | AM_RANGE( 0x8000, 0xffff ) AM_READ(MRA8_BANK1) | |
| 470 | AM_RANGE( 0x8000, 0xffff ) AM_WRITE(MWA8_RAM) AM_BASE(&videoram) | |
| 518 | 471 | ADDRESS_MAP_END |
| 519 | static ADDRESS_MAP_START( janptr96_writemem, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 520 | AM_RANGE(0x0000, 0x5fff) AM_WRITE(MWA8_ROM) | |
| 521 | AM_RANGE(0x6000, 0x6fff) AM_WRITE(MWA8_BANK3) // nvram | |
| 522 | AM_RANGE(0x7000, 0x7fff) AM_WRITE(MWA8_BANK2) // banked nvram | |
| 523 | AM_RANGE(0x8000, 0xffff) AM_WRITE(MWA8_RAM) AM_BASE(&videoram) | |
| 524 | ADDRESS_MAP_END | |
| 525 | 472 | |
| 526 | 473 | static WRITE8_HANDLER( janptr96_dswsel_w ) |
| 527 | 474 | { |
| 528 | 475 | // 0x20 = 0 -> hopper on |
| 529 | 476 | // 0x40 ? |
| 530 | | |
| 477 | | |
| 531 | 478 | } |
| 532 | 479 | |
| 533 | 480 | static READ8_HANDLER( janptr96_dswsel_r ) |
| 534 | 481 | { |
| 535 | return | |
| 482 | return | |
| 536 | 483 | } |
| 537 | 484 | |
| 538 | 485 | static READ8_HANDLER( janptr96_dsw_r ) |
| 539 | 486 | { |
| 540 | if (~majs101b_dsw_select & 0x01) return readinputportbytag("DSW4"); | |
| 541 | if (~majs101b_dsw_select & 0x02) return readinputportbytag("DSW3"); | |
| 542 | if (~majs101b_dsw_select & 0x04) return readinputportbytag("DSW2"); | |
| 543 | if (~majs101b_dsw_select & 0x08) return readinputportbytag("DSW1"); | |
| 544 | if (~majs101b_dsw_select & 0x10) return readinputportbytag("DSWTOP"); | |
| 487 | if (~dsw_select & 0x01) return readinputportbytag("DSW4"); | |
| 488 | if (~dsw_select & 0x02) return readinputportbytag("DSW3"); | |
| 489 | if (~dsw_select & 0x04) return readinputportbytag("DSW2"); | |
| 490 | if (~dsw_select & 0x08) return readinputportbytag("DSW1"); | |
| 491 | if (~dsw_select & 0x10) return readinputportbytag("DSWTOP"); | |
| 545 | 492 | return 0xff; |
| 546 | 493 | } |
| 547 | 494 | |
| r936 | r937 | |
| 569 | 516 | coin_counter_w(1,data & 1); // out |
| 570 | 517 | } |
| 571 | 518 | |
| 572 | static ADDRESS_MAP_START( janptr96_ | |
| 519 | static ADDRESS_MAP_START( janptr96_ioma | |
| 573 | 520 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 574 | AM_RANGE(0x1e, 0x1e) AM_READ(janptr96_dswsel_r ) | |
| 575 | AM_RANGE(0x1c, 0x1c) AM_READ(janptr96_dsw_r ) | |
| 576 | AM_RANGE(0x20, 0x20) AM_READ(janptr96_unknown_r ) // ? | |
| 577 | AM_RANGE(0x60, 0x6f) AM_READ(msm6242_r ) // 6242RTC | |
| 578 | AM_RANGE(0x81, 0x81) AM_READ(AY8910_read_port_0_r ) | |
| 579 | AM_RANGE(0xd9, 0xd9) AM_READ(input_port_10_r) | |
| 521 | AM_RANGE( 0x00, 0x00 ) AM_WRITE( janptr96_rombank_w ) // BANK ROM Select | |
| 522 | AM_RANGE( 0x1e, 0x1e ) AM_READWRITE( janptr96_dswsel_r, janptr96_dswsel_w ) | |
| 523 | AM_RANGE( 0x1c, 0x1c ) AM_READ( janptr96_dsw_r ) | |
| 524 | AM_RANGE( 0x20, 0x20 ) AM_READWRITE( janptr96_unknown_r, janptr96_rambank_w ) | |
| 525 | AM_RANGE( 0x50, 0x50 ) AM_WRITE( mjderngr_palbank_w ) | |
| 526 | AM_RANGE( 0x60, 0x6f ) AM_READWRITE( msm6242_r, msm6242_w ) | |
| 527 | AM_RANGE( 0x81, 0x81 ) AM_READ( AY8910_read_port_0_r ) | |
| 528 | AM_RANGE( 0x82, 0x82 ) AM_WRITE( AY8910_write_port_0_w ) | |
| 529 | AM_RANGE( 0x83, 0x83 ) AM_WRITE( AY8910_control_port_0_w ) | |
| 530 | AM_RANGE( 0x93, 0x93 ) AM_WRITE( input_port_select_w ) | |
| 531 | AM_RANGE( 0xd8, 0xd8 ) AM_WRITE( janptr96_coin_counter_w ) | |
| 532 | AM_RANGE( 0xd9, 0xd9 ) AM_READ( input_port_10_r ) | |
| 580 | 533 | ADDRESS_MAP_END |
| 581 | 534 | |
| 582 | static ADDRESS_MAP_START( janptr96_writeport, ADDRESS_SPACE_IO, 8 ) | |
| 583 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) | |
| 584 | AM_RANGE(0x00, 0x00) AM_WRITE(janptr96_rombank_w ) // BANK ROM Select | |
| 585 | AM_RANGE(0x1e, 0x1e) AM_WRITE(janptr96_dswsel_w ) | |
| 586 | AM_RANGE(0x20, 0x20) AM_WRITE(janptr96_rambank_w ) // BANK RAM Select | |
| 587 | AM_RANGE(0x50, 0x50) AM_WRITE(mjderngr_palbank_w ) | |
| 588 | AM_RANGE(0x60, 0x6f) AM_WRITE(msm6242_w ) // 6242RTC | |
| 589 | AM_RANGE(0x82, 0x82) AM_WRITE(AY8910_write_port_0_w ) // AY8910 | |
| 590 | AM_RANGE(0x83, 0x83) AM_WRITE(AY8910_control_port_0_w ) // | |
| 591 | AM_RANGE(0x93, 0x93) AM_WRITE(royalmah_input_port_select_w) | |
| 592 | AM_RANGE(0xd8, 0xd8) AM_WRITE(janptr96_coin_counter_w) | |
| 593 | ADDRESS_MAP_END | |
| 594 | ||
| 595 | 535 | /**************************************************************************** |
| 596 | 536 | Mahjong If |
| 597 | 537 | ****************************************************************************/ |
| 598 | 538 | |
| 599 | static UINT8 rombank; | |
| 600 | 539 | static UINT8 mjifb_rom_enable; |
| 601 | 540 | |
| 602 | 541 | static WRITE8_HANDLER( mjifb_coin_counter_w ) |
| r936 | r937 | |
| 643 | 582 | case 0x9010: |
| 644 | 583 | mjifb_coin_counter_w(0,data); |
| 645 | 584 | return; |
| 646 | case 0x9011: | |
| 585 | case 0x9011: | |
| 647 | 586 | case 0x9013: |
| 648 | 587 | // if (data) popmessage("%02x",data); |
| 649 | 588 | return; |
| r936 | r937 | |
| 740 | 679 | AM_RANGE( 0x6fc2, 0x6fc2 ) AM_WRITE( AY8910_write_port_0_w ) |
| 741 | 680 | AM_RANGE( 0x6fc3, 0x6fc3 ) AM_WRITE( AY8910_control_port_0_w ) |
| 742 | 681 | AM_RANGE( 0x6fd0, 0x6fd0 ) AM_WRITE( janptr96_coin_counter_w ) |
| 743 | AM_RANGE( 0x6fd1, 0x6fd1 ) AM_READWRITE( input_port_10_r, | |
| 682 | AM_RANGE( 0x6fd1, 0x6fd1 ) AM_READWRITE( input_port_10_r, | |
| 744 | 683 | AM_RANGE( 0x6fe0, 0x6fef ) AM_READWRITE( msm6242_r, msm6242_w ) |
| 745 | 684 | AM_RANGE( 0x6ff0, 0x6ff0 ) AM_READWRITE( janptr96_dsw_r, janptr96_dswsel_w ) |
| 746 | 685 | AM_RANGE( 0x6ff1, 0x6ff1 ) AM_WRITE( mjderngr_palbank_w ) |
| r936 | r937 | |
| 756 | 695 | ADDRESS_MAP_END |
| 757 | 696 | |
| 758 | 697 | |
| 698 | /**************************************************************************** | |
| 699 | Mahjong Cafe Time | |
| 700 | ****************************************************************************/ | |
| 759 | 701 | |
| 702 | static void cafetime_update_rombank(void) | |
| 703 | { | |
| 704 | memory_set_bankptr( 1, memory_region(REGION_CPU1) + 0x10000 + rombank * 0x8000 ); | |
| 705 | } | |
| 706 | static WRITE8_HANDLER( cafetime_p4_w ) | |
| 707 | { | |
| 708 | rombank = (rombank & 0xf0) | (data & 0x0f); | |
| 709 | cafetime_update_rombank(); | |
| 710 | } | |
| 711 | static WRITE8_HANDLER( cafetime_p3_w ) | |
| 712 | { | |
| 713 | rombank = (rombank & 0x0f) | ((data & 0x0c) << 2); | |
| 714 | cafetime_update_rombank(); | |
| 715 | } | |
| 760 | 716 | |
| 717 | static WRITE8_HANDLER( cafetime_dsw_w ) | |
| 718 | { | |
| 719 | dsw_select = data; | |
| 720 | } | |
| 721 | static READ8_HANDLER( cafetime_dsw_r ) | |
| 722 | { | |
| 723 | switch( dsw_select ) | |
| 724 | { | |
| 725 | case 0x00: return readinputportbytag("DSW1"); | |
| 726 | case 0x01: return readinputportbytag("DSW2"); | |
| 727 | case 0x02: return readinputportbytag("DSW3"); | |
| 728 | case 0x03: return readinputportbytag("DSW4"); | |
| 729 | case 0x04: return readinputportbytag("DSWTOP"); | |
| 730 | } | |
| 731 | logerror("%04X: unmapped dsw read %02X\n", activecpu_get_pc(), dsw_select); | |
| 732 | return 0xff; | |
| 733 | } | |
| 734 | ||
| 735 | static READ8_HANDLER( cafetime_7fe4_r ) | |
| 736 | { | |
| 737 | return 0xff; | |
| 738 | } | |
| 739 | static WRITE8_HANDLER( cafetime_7fe3_w ) | |
| 740 | { | |
| 741 | // popmessage("%02x",data); | |
| 742 | } | |
| 743 | ||
| 744 | static ADDRESS_MAP_START( cafetime_map, ADDRESS_SPACE_PROGRAM, 8 ) | |
| 745 | AM_RANGE( 0x0000, 0x5fff ) AM_ROM | |
| 746 | AM_RANGE( 0x6000, 0x7eff ) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size) | |
| 747 | AM_RANGE( 0x7fc1, 0x7fc1 ) AM_READ( AY8910_read_port_0_r ) | |
| 748 | AM_RANGE( 0x7fc2, 0x7fc2 ) AM_WRITE( AY8910_write_port_0_w ) | |
| 749 | AM_RANGE( 0x7fc3, 0x7fc3 ) AM_WRITE( AY8910_control_port_0_w ) | |
| 750 | AM_RANGE( 0x7fd0, 0x7fd0 ) AM_WRITE( janptr96_coin_counter_w ) | |
| 751 | AM_RANGE( 0x7fd1, 0x7fd1 ) AM_READWRITE( input_port_10_r, MWA8_NOP ) | |
| 752 | AM_RANGE( 0x7fd3, 0x7fd3 ) AM_WRITE( input_port_select_w ) | |
| 753 | AM_RANGE( 0x7fe0, 0x7fe0 ) AM_READ( cafetime_dsw_r ) | |
| 754 | AM_RANGE( 0x7fe1, 0x7fe1 ) AM_WRITE( cafetime_dsw_w ) | |
| 755 | AM_RANGE( 0x7fe2, 0x7fe2 ) AM_WRITE( mjderngr_palbank_w ) | |
| 756 | AM_RANGE( 0x7fe3, 0x7fe3 ) AM_WRITE( cafetime_7fe3_w ) | |
| 757 | AM_RANGE( 0x7fe4, 0x7fe4 ) AM_READ( cafetime_7fe4_r ) | |
| 758 | AM_RANGE( 0x7ff0, 0x7fff ) AM_READWRITE( msm6242_r, msm6242_w ) | |
| 759 | AM_RANGE( 0x8000, 0xffff ) AM_READ( MRA8_BANK1 ) | |
| 760 | AM_RANGE( 0x8000, 0xffff ) AM_WRITE( MWA8_RAM ) AM_BASE(&videoram) | |
| 761 | ADDRESS_MAP_END | |
| 762 | ||
| 763 | ||
| 764 | static ADDRESS_MAP_START( cafetime_iomap, ADDRESS_SPACE_IO, 8 ) | |
| 765 | AM_RANGE( T90_P3, T90_P3 ) AM_WRITE( cafetime_p3_w ) | |
| 766 | AM_RANGE( T90_P4, T90_P4 ) AM_WRITE( cafetime_p4_w ) | |
| 767 | ADDRESS_MAP_END | |
| 768 | ||
| 769 | ||
| 761 | 770 | static INPUT_PORTS_START( royalmah ) |
| 762 | 771 | PORT_START /* P1 IN0 */ |
| 763 | 772 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A ) |
| r936 | r937 | |
| 1631 | 1640 | INPUT_PORTS_END |
| 1632 | 1641 | |
| 1633 | 1642 | static INPUT_PORTS_START( mjapinky ) |
| 1643 | PORT_START /* P1 IN0 */ | |
| 1644 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A ) | |
| 1645 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E ) | |
| 1646 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_I ) | |
| 1647 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M ) | |
| 1648 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_KAN ) | |
| 1649 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) | |
| 1650 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Payout") PORT_CODE(KEYCODE_7) | |
| 1651 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 1652 | ||
| 1653 | PORT_START /* P1 IN1 */ | |
| 1654 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B ) | |
| 1655 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F ) | |
| 1656 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_J ) | |
| 1657 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N ) | |
| 1658 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_REACH ) | |
| 1659 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET ) | |
| 1660 | PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 1661 | ||
| 1662 | PORT_START /* P1 IN2 */ | |
| 1663 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C ) | |
| 1664 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G ) | |
| 1665 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K ) | |
| 1666 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_CHI ) | |
| 1667 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_RON ) | |
| 1668 | PORT_BIT( 0xe0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 1669 | ||
| 1670 | PORT_START /* P1 IN3 */ | |
| 1671 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D ) | |
| 1672 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H ) | |
| 1673 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L ) | |
| 1674 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON ) | |
| 1675 | PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 1676 | ||
| 1677 | PORT_START /* P1 IN4 */ | |
| 1678 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_LAST_CHANCE ) | |
| 1679 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE ) | |
| 1680 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_DOUBLE_UP ) | |
| 1681 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_FLIP_FLOP ) | |
| 1682 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_BIG ) | |
| 1683 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL ) | |
| 1684 | PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 1685 | ||
| 1686 | PORT_START /* P2 IN0 */ | |
| 1687 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A )PORT_PLAYER(2) | |
| 1688 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E )PORT_PLAYER(2) | |
| 1689 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_I )PORT_PLAYER(2) | |
| 1690 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M )PORT_PLAYER(2) | |
| 1691 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_KAN )PORT_PLAYER(2) | |
| 1692 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 ) | |
| 1693 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) | |
| 1694 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 1695 | ||
| 1696 | PORT_START /* P2 IN1 */ | |
| 1697 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B )PORT_PLAYER(2) | |
| 1698 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F )PORT_PLAYER(2) | |
| 1699 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_J )PORT_PLAYER(2) | |
| 1700 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N )PORT_PLAYER(2) | |
| 1701 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )PORT_PLAYER(2) | |
| 1702 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET )PORT_PLAYER(2) PORT_CODE(KEYCODE_4) | |
| 1703 | PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 1704 | ||
| 1705 | PORT_START /* P2 IN2 */ | |
| 1706 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C )PORT_PLAYER(2) | |
| 1707 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G )PORT_PLAYER(2) | |
| 1708 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K )PORT_PLAYER(2) | |
| 1709 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )PORT_PLAYER(2) | |
| 1710 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_RON )PORT_PLAYER(2) | |
| 1711 | PORT_BIT( 0xe0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 1712 | ||
| 1713 | PORT_START /* P2 IN3 */ | |
| 1714 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D )PORT_PLAYER(2) | |
| 1715 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H )PORT_PLAYER(2) | |
| 1716 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L )PORT_PLAYER(2) | |
| 1717 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON )PORT_PLAYER(2) | |
| 1718 | PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 1719 | ||
| 1720 | PORT_START /* P2 IN4 */ | |
| 1721 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_LAST_CHANCE )PORT_PLAYER(2) | |
| 1722 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE )PORT_PLAYER(2) | |
| 1723 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_DOUBLE_UP )PORT_PLAYER(2) | |
| 1724 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_FLIP_FLOP )PORT_PLAYER(2) | |
| 1725 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_BIG )PORT_PLAYER(2) | |
| 1726 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL )PORT_PLAYER(2) | |
| 1727 | PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 1728 | ||
| 1729 | PORT_START /* IN10 */ | |
| 1730 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 ) /* "Note" ("Paper Money") = 10 Credits */ | |
| 1731 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SERVICE3 ) /* Memory Reset */ | |
| 1732 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SERVICE2 ) /* Analizer (Statistics) */ | |
| 1733 | PORT_SERVICE( 0x08, IP_ACTIVE_HIGH ) | |
| 1734 | PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) | |
| 1735 | ||
| 1736 | PORT_START_TAG("DSW1") /* IN11 */ | |
| 1737 | PORT_DIPNAME( 0x01, 0x01, "Unknown 1-0" ) | |
| 1738 | PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) | |
| 1739 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1740 | PORT_DIPNAME( 0x02, 0x02, "Unknown 1-1" ) | |
| 1741 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) | |
| 1742 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1743 | PORT_DIPNAME( 0x04, 0x04, "Unknown 1-2" ) | |
| 1744 | PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) | |
| 1745 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1746 | PORT_DIPNAME( 0x08, 0x08, "Unknown 1-3" ) | |
| 1747 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) | |
| 1748 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1749 | PORT_DIPNAME( 0x30, 0x30, "Maximum Bet" ) | |
| 1750 | PORT_DIPSETTING( 0x30, "1" ) | |
| 1751 | PORT_DIPSETTING( 0x20, "5" ) | |
| 1752 | PORT_DIPSETTING( 0x10, "10" ) | |
| 1753 | PORT_DIPSETTING( 0x00, "20" ) | |
| 1754 | PORT_DIPNAME( 0x40, 0x00, "Background" ) | |
| 1755 | PORT_DIPSETTING( 0x40, "Black" ) | |
| 1756 | PORT_DIPSETTING( 0x00, "Green" ) | |
| 1757 | PORT_DIPNAME( 0x80, 0x80, "Unknown 1-7" ) | |
| 1758 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) | |
| 1759 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1760 | ||
| 1761 | PORT_START_TAG("DSW2") /* IN12 */ | |
| 1762 | PORT_DIPNAME( 0x03, 0x03, "Unknown 2-0&1" ) | |
| 1763 | PORT_DIPSETTING( 0x03, "0" ) | |
| 1764 | PORT_DIPSETTING( 0x02, "1" ) | |
| 1765 | PORT_DIPSETTING( 0x01, "2" ) | |
| 1766 | PORT_DIPSETTING( 0x00, "3" ) | |
| 1767 | PORT_DIPNAME( 0x04, 0x04, "Unknown 2-2" ) | |
| 1768 | PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) | |
| 1769 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1770 | PORT_DIPNAME( 0x08, 0x08, "Unknown 2-3" ) | |
| 1771 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) | |
| 1772 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1773 | PORT_DIPNAME( 0x30, 0x30, "Unknown 2-4&5" ) | |
| 1774 | PORT_DIPSETTING( 0x30, "0" ) | |
| 1775 | PORT_DIPSETTING( 0x20, "1" ) | |
| 1776 | PORT_DIPSETTING( 0x10, "2" ) | |
| 1777 | PORT_DIPSETTING( 0x00, "3" ) | |
| 1778 | PORT_DIPNAME( 0xc0, 0xc0, "Unknown 2-6&7" ) | |
| 1779 | PORT_DIPSETTING( 0xc0, "0" ) | |
| 1780 | PORT_DIPSETTING( 0x80, "1" ) | |
| 1781 | PORT_DIPSETTING( 0x40, "2" ) | |
| 1782 | PORT_DIPSETTING( 0x00, "3" ) | |
| 1783 | ||
| 1784 | PORT_START_TAG("DSW3") /* IN13 */ | |
| 1785 | PORT_DIPNAME( 0x01, 0x01, "Unknown 3-0" ) | |
| 1786 | PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) | |
| 1787 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1788 | PORT_DIPNAME( 0x02, 0x02, "Unknown 3-1" ) | |
| 1789 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) | |
| 1790 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1791 | PORT_DIPNAME( 0x04, 0x04, "Unknown 3-2" ) | |
| 1792 | PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) | |
| 1793 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1794 | PORT_DIPNAME( 0x08, 0x08, "Unknown 3-3" ) | |
| 1795 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) | |
| 1796 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1797 | PORT_DIPNAME( 0x10, 0x10, "Unknown 3-4" ) | |
| 1798 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) | |
| 1799 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1800 | PORT_DIPNAME( 0x20, 0x20, "Unknown 3-5" ) | |
| 1801 | PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) | |
| 1802 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1803 | PORT_DIPNAME( 0x40, 0x40, "Unknown 3-6" ) | |
| 1804 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) | |
| 1805 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1806 | PORT_DIPNAME( 0x80, 0x80, "Full Test" ) | |
| 1807 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) | |
| 1808 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 1634 | 1809 | INPUT_PORTS_END |
| 1635 | 1810 | |
| 1636 | 1811 | static INPUT_PORTS_START( janptr96 ) |
| r936 | r937 | |
| 2280 | 2455 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 2281 | 2456 | INPUT_PORTS_END |
| 2282 | 2457 | |
| 2458 | static INPUT_PORTS_START( cafetime ) | |
| 2459 | PORT_START /* P1 IN0 */ | |
| 2460 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A ) | |
| 2461 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E ) | |
| 2462 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_I ) | |
| 2463 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M ) | |
| 2464 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_KAN ) | |
| 2465 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) | |
| 2466 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Payout") PORT_CODE(KEYCODE_7) | |
| 2467 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 2468 | ||
| 2469 | PORT_START /* P1 IN1 */ | |
| 2470 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B ) | |
| 2471 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F ) | |
| 2472 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_J ) | |
| 2473 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N ) | |
| 2474 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_REACH ) | |
| 2475 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET ) | |
| 2476 | PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 2477 | ||
| 2478 | PORT_START /* P1 IN2 */ | |
| 2479 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C ) | |
| 2480 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G ) | |
| 2481 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K ) | |
| 2482 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_CHI ) | |
| 2483 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_RON ) | |
| 2484 | PORT_BIT( 0xe0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 2485 | ||
| 2486 | PORT_START /* P1 IN3 */ | |
| 2487 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D ) | |
| 2488 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H ) | |
| 2489 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L ) | |
| 2490 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON ) | |
| 2491 | PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 2492 | ||
| 2493 | PORT_START /* P1 IN4 */ | |
| 2494 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_LAST_CHANCE ) | |
| 2495 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE ) | |
| 2496 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_DOUBLE_UP ) | |
| 2497 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_FLIP_FLOP ) | |
| 2498 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_BIG ) | |
| 2499 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL ) | |
| 2500 | PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 2501 | ||
| 2502 | PORT_START /* P2 IN0 */ | |
| 2503 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A )PORT_PLAYER(2) | |
| 2504 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E )PORT_PLAYER(2) | |
| 2505 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_I )PORT_PLAYER(2) | |
| 2506 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M )PORT_PLAYER(2) | |
| 2507 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_KAN )PORT_PLAYER(2) | |
| 2508 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 ) | |
| 2509 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) | |
| 2510 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 2511 | ||
| 2512 | PORT_START /* P2 IN1 */ | |
| 2513 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B )PORT_PLAYER(2) | |
| 2514 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F )PORT_PLAYER(2) | |
| 2515 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_J )PORT_PLAYER(2) | |
| 2516 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N )PORT_PLAYER(2) | |
| 2517 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )PORT_PLAYER(2) | |
| 2518 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET )PORT_PLAYER(2) PORT_CODE(KEYCODE_4) | |
| 2519 | PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 2520 | ||
| 2521 | PORT_START /* P2 IN2 */ | |
| 2522 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C )PORT_PLAYER(2) | |
| 2523 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G )PORT_PLAYER(2) | |
| 2524 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K )PORT_PLAYER(2) | |
| 2525 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )PORT_PLAYER(2) | |
| 2526 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_RON )PORT_PLAYER(2) | |
| 2527 | PORT_BIT( 0xe0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 2528 | ||
| 2529 | PORT_START /* P2 IN3 */ | |
| 2530 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D )PORT_PLAYER(2) | |
| 2531 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H )PORT_PLAYER(2) | |
| 2532 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L )PORT_PLAYER(2) | |
| 2533 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON )PORT_PLAYER(2) | |
| 2534 | PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 2535 | ||
| 2536 | PORT_START /* P2 IN4 */ | |
| 2537 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_MAHJONG_LAST_CHANCE )PORT_PLAYER(2) | |
| 2538 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE )PORT_PLAYER(2) | |
| 2539 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_MAHJONG_DOUBLE_UP )PORT_PLAYER(2) | |
| 2540 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_MAHJONG_FLIP_FLOP )PORT_PLAYER(2) | |
| 2541 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_MAHJONG_BIG )PORT_PLAYER(2) | |
| 2542 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL )PORT_PLAYER(2) | |
| 2543 | PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) | |
| 2544 | ||
| 2545 | PORT_START /* IN10 */ | |
| 2546 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 ) /* "Note" ("Paper Money") = 10 Credits */ | |
| 2547 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SERVICE3 ) /* Memory Reset */ | |
| 2548 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SERVICE2 ) /* Analizer (Statistics) */ | |
| 2549 | PORT_SERVICE( 0x08, IP_ACTIVE_HIGH ) | |
| 2550 | PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) | |
| 2551 | ||
| 2552 | PORT_START_TAG("DSW1") /* IN11 */ | |
| 2553 | PORT_DIPNAME( 0x0f, 0x07, "Pay Out Rate" ) | |
| 2554 | PORT_DIPSETTING( 0x0f, "96%" ) | |
| 2555 | PORT_DIPSETTING( 0x0e, "93%" ) | |
| 2556 | PORT_DIPSETTING( 0x0d, "90%" ) | |
| 2557 | PORT_DIPSETTING( 0x0c, "87%" ) | |
| 2558 | PORT_DIPSETTING( 0x0b, "84%" ) | |
| 2559 | PORT_DIPSETTING( 0x0a, "81%" ) | |
| 2560 | PORT_DIPSETTING( 0x09, "78%" ) | |
| 2561 | PORT_DIPSETTING( 0x08, "75%" ) | |
| 2562 | PORT_DIPSETTING( 0x07, "71%" ) | |
| 2563 | PORT_DIPSETTING( 0x06, "68%" ) | |
| 2564 | PORT_DIPSETTING( 0x05, "65%" ) | |
| 2565 | PORT_DIPSETTING( 0x04, "62%" ) | |
| 2566 | PORT_DIPSETTING( 0x03, "59%" ) | |
| 2567 | PORT_DIPSETTING( 0x02, "56%" ) | |
| 2568 | PORT_DIPSETTING( 0x01, "53%" ) | |
| 2569 | PORT_DIPSETTING( 0x00, "50%" ) | |
| 2570 | PORT_DIPNAME( 0x30, 0x00, "Maximum Bet" ) | |
| 2571 | PORT_DIPSETTING( 0x30, "1" ) | |
| 2572 | PORT_DIPSETTING( 0x20, "5" ) | |
| 2573 | PORT_DIPSETTING( 0x10, "10" ) | |
| 2574 | PORT_DIPSETTING( 0x00, "20" ) | |
| 2575 | PORT_DIPNAME( 0xc0, 0xc0, "Unknown 1-6&7" ) | |
| 2576 | PORT_DIPSETTING( 0xc0, "1" ) | |
| 2577 | PORT_DIPSETTING( 0x80, "2" ) | |
| 2578 | PORT_DIPSETTING( 0x40, "3" ) | |
| 2579 | PORT_DIPSETTING( 0x00, "4" ) | |
| 2580 | ||
| 2581 | PORT_START_TAG("DSW2") /* IN12 */ | |
| 2582 | PORT_DIPNAME( 0x03, 0x03, "Winnings" ) | |
| 2583 | PORT_DIPSETTING( 0x03, "32 24 16 12 8 4 2 1" ) | |
| 2584 | PORT_DIPSETTING( 0x00, "50 30 15 8 5 3 2 1" ) | |
| 2585 | PORT_DIPSETTING( 0x01, "100 50 25 10 5 3 2 1" ) | |
| 2586 | PORT_DIPSETTING( 0x02, "200 100 50 10 5 3 2 1" ) | |
| 2587 | PORT_DIPNAME( 0x0c, 0x0c, "Unknown 2-2&3" ) | |
| 2588 | PORT_DIPSETTING( 0x0c, "1" ) | |
| 2589 | PORT_DIPSETTING( 0x08, "2" ) | |
| 2590 | PORT_DIPSETTING( 0x04, "3" ) | |
| 2591 | PORT_DIPSETTING( 0x00, "5" ) | |
| 2592 | PORT_DIPNAME( 0x70, 0x70, "Unknown 2-4&5&6" ) | |
| 2593 | PORT_DIPSETTING( 0x70, "0" ) | |
| 2594 | PORT_DIPSETTING( 0x60, "1" ) | |
| 2595 | PORT_DIPSETTING( 0x50, "2" ) | |
| 2596 | PORT_DIPSETTING( 0x40, "3" ) | |
| 2597 | PORT_DIPSETTING( 0x30, "4" ) | |
| 2598 | PORT_DIPSETTING( 0x20, "5" ) | |
| 2599 | PORT_DIPSETTING( 0x10, "6" ) | |
| 2600 | PORT_DIPSETTING( 0x00, "7" ) | |
| 2601 | PORT_DIPNAME( 0x80, 0x80, "Unknown 2-7" ) | |
| 2602 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) | |
| 2603 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2604 | ||
| 2605 | PORT_START_TAG("DSW3") /* IN13 */ | |
| 2606 | PORT_DIPNAME( 0x01, 0x01, "Unknown 3-0" ) | |
| 2607 | PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) | |
| 2608 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2609 | PORT_DIPNAME( 0x02, 0x02, "Unknown 3-1" ) | |
| 2610 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) | |
| 2611 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2612 | PORT_DIPNAME( 0x04, 0x04, "Unknown 3-2" ) | |
| 2613 | PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) | |
| 2614 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2615 | PORT_DIPNAME( 0x08, 0x08, "Unknown 3-3" ) | |
| 2616 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) | |
| 2617 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2618 | PORT_DIPNAME( 0x10, 0x10, "Unknown 3-4" ) | |
| 2619 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) | |
| 2620 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2621 | PORT_DIPNAME( 0x20, 0x20, "Unknown 3-5" ) | |
| 2622 | PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) | |
| 2623 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2624 | PORT_DIPNAME( 0x40, 0x40, "Unknown 3-6" ) | |
| 2625 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) | |
| 2626 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2627 | PORT_DIPNAME( 0x80, 0x80, "Unknown 3-7" ) | |
| 2628 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) | |
| 2629 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2630 | ||
| 2631 | PORT_START_TAG("DSW4") /* IN14 */ | |
| 2632 | PORT_DIPNAME( 0x01, 0x01, "Unknown 4-0" ) | |
| 2633 | PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) | |
| 2634 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2635 | PORT_DIPNAME( 0x02, 0x02, "Unknown 4-1" ) | |
| 2636 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) | |
| 2637 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2638 | PORT_DIPNAME( 0x04, 0x04, "Unknown 4-2" ) | |
| 2639 | PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) | |
| 2640 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2641 | PORT_DIPNAME( 0x08, 0x08, "Unknown 4-3" ) | |
| 2642 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) | |
| 2643 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2644 | PORT_DIPNAME( 0x10, 0x00, "Full Test" ) | |
| 2645 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) | |
| 2646 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2647 | PORT_DIPNAME( 0x20, 0x00, "Background" ) | |
| 2648 | PORT_DIPSETTING( 0x20, "Black" ) | |
| 2649 | PORT_DIPSETTING( 0x00, "Green" ) | |
| 2650 | PORT_DIPNAME( 0x40, 0x40, "Unknown 4-6" ) | |
| 2651 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) | |
| 2652 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2653 | PORT_DIPNAME( 0x80, 0x80, "Unknown 4-7" ) | |
| 2654 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) | |
| 2655 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2656 | ||
| 2657 | PORT_START_TAG("DSWTOP") /* IN15 */ | |
| 2658 | PORT_DIPNAME( 0x01, 0x01, "Credits Per Note" ) | |
| 2659 | PORT_DIPSETTING( 0x01, "5" ) | |
| 2660 | PORT_DIPSETTING( 0x00, "10" ) | |
| 2661 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) | |
| 2662 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) | |
| 2663 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2664 | PORT_DIPNAME( 0x04, 0x04, "Unknown 2-8" ) | |
| 2665 | PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) | |
| 2666 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2667 | PORT_DIPNAME( 0x08, 0x08, "Unknown 2-9" ) | |
| 2668 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) | |
| 2669 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2670 | PORT_DIPNAME( 0x30, 0x30, "Unknown 3-8&9" ) | |
| 2671 | PORT_DIPSETTING( 0x30, "0" ) | |
| 2672 | PORT_DIPSETTING( 0x20, "1" ) | |
| 2673 | PORT_DIPSETTING( 0x10, "2" ) | |
| 2674 | PORT_DIPSETTING( 0x00, "3" ) | |
| 2675 | PORT_DIPNAME( 0x40, 0x40, "Unknown 4-8" ) | |
| 2676 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) | |
| 2677 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2678 | PORT_DIPNAME( 0x80, 0x80, "Unknown 4-9" ) | |
| 2679 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) | |
| 2680 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2681 | INPUT_PORTS_END | |
| 2682 | ||
| 2683 | ||
| 2283 | 2684 | static struct AY8910interface ay8910_interface = |
| 2284 | 2685 | { |
| 2285 | 2686 | royalmah_player_1_port_r, |
| 2286 | 2687 | royalmah_player_2_port_r |
| 2287 | 2688 | }; |
| 2288 | 2689 | |
| 2289 | ||
| 2290 | ||
| 2291 | 2690 | static MACHINE_DRIVER_START( royalmah ) |
| 2292 | 2691 | |
| 2293 | 2692 | /* basic machine hardware */ |
| 2294 | MDRV_CPU_ADD(Z80, 3000000) /* 3.00 MHz ? */ | |
| 2295 | MDRV_CPU_PROGRAM_MAP(readmem,writemem) | |
| 2296 | MDRV_CPU_IO_MAP(royalmah_readport,royalmah_writeport) | |
| 2693 | MDRV_CPU_ADD_TAG("main", Z80, 3000000) /* 3.00 MHz ? */ | |
| 2694 | MDRV_CPU_PROGRAM_MAP(royalmah_map,0) | |
| 2695 | MDRV_CPU_IO_MAP(royalmah_iomap,0) | |
| 2297 | 2696 | MDRV_CPU_VBLANK_INT(irq0_line_hold,1) |
| 2298 | 2697 | |
| 2299 | 2698 | MDRV_NVRAM_HANDLER(generic_0fill) |
| r936 | r937 | |
| 2301 | 2700 | /* video hardware */ |
| 2302 | 2701 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) |
| 2303 | 2702 | MDRV_VIDEO_UPDATE(royalmah) |
| 2703 | MDRV_PALETTE_LENGTH(16*2) | |
| 2704 | MDRV_PALETTE_INIT(royalmah) | |
| 2304 | 2705 | |
| 2305 | 2706 | MDRV_SCREEN_ADD("main", 0) |
| 2306 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_ | |
| 2707 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) | |
| 2307 | 2708 | MDRV_SCREEN_SIZE(256, 256) |
| 2308 | 2709 | MDRV_SCREEN_VISIBLE_AREA(0, 255, 0, 255) |
| 2309 | 2710 | MDRV_SCREEN_REFRESH_RATE(60) |
| r936 | r937 | |
| 2319 | 2720 | |
| 2320 | 2721 | |
| 2321 | 2722 | static MACHINE_DRIVER_START( dondenmj ) |
| 2322 | ||
| 2323 | /* basic machine hardware */ | |
| 2324 | MDRV_CPU_ADD_TAG("main", Z80, 8000000/2) /* 4 MHz ? */ | |
| 2325 | MDRV_CPU_PROGRAM_MAP(readmem,writemem) | |
| 2326 | MDRV_CPU_IO_MAP(dondenmj_readport,dondenmj_writeport) | |
| 2327 | MDRV_CPU_VBLANK_INT(irq0_line_hold,1) | |
| 2328 | ||
| 2329 | MDRV_NVRAM_HANDLER(generic_0fill) | |
| 2330 | ||
| 2331 | /* video hardware */ | |
| 2332 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) | |
| 2333 | MDRV_VIDEO_UPDATE(royalmah) | |
| 2334 | ||
| 2335 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) | |
| 2336 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) | |
| 2337 | MDRV_SCREEN_SIZE(256, 256) | |
| 2338 | MDRV_SCREEN_VISIBLE_AREA(0, 255, 0, 255) | |
| 2339 | MDRV_SCREEN_REFRESH_RATE(60) | |
| 2340 | MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION) | |
| 2341 | ||
| 2342 | /* sound hardware */ | |
| 2343 | MDRV_SPEAKER_STANDARD_MONO("mono") | |
| 2344 | ||
| 2345 | MDRV_SOUND_ADD(AY8910, 18432000/12) | |
| 2346 | MDRV_SOUND_CONFIG(ay8910_interface) | |
| 2347 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.33) | |
| 2723 | MDRV_IMPORT_FROM(royalmah) | |
| 2724 | MDRV_CPU_REPLACE("main", Z80, 8000000/2) /* 4 MHz ? */ | |
| 2725 | MDRV_CPU_IO_MAP(dondenmj_iomap,0) | |
| 2348 | 2726 | MACHINE_DRIVER_END |
| 2349 | 2727 | |
| 2350 | 2728 | static void suzume_irq(void) |
| 2351 | 2729 | { |
| 2352 | cpunum_set_input_line_and_vector(0, 0, HOLD_LINE, 0xcd1216); | |
| 2730 | if ( suzume_bank & 0x40 ) | |
| 2731 | cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE); | |
| 2353 | 2732 | } |
| 2354 | 2733 | |
| 2355 | 2734 | static MACHINE_DRIVER_START( suzume ) |
| 2356 | /* basic machine hardware */ | |
| 2357 | 2735 | MDRV_IMPORT_FROM(dondenmj) |
| 2358 | 2736 | MDRV_CPU_MODIFY("main") |
| 2359 | MDRV_CPU_IO_MAP(suzume_ | |
| 2737 | MDRV_CPU_IO_MAP(suzume_i | |
| 2360 | 2738 | MDRV_CPU_VBLANK_INT(suzume_irq,1) |
| 2361 | 2739 | MACHINE_DRIVER_END |
| 2362 | 2740 | |
| 2363 | 2741 | static MACHINE_DRIVER_START( tontonb ) |
| 2364 | /* basic machine hardware */ | |
| 2365 | 2742 | MDRV_IMPORT_FROM(dondenmj) |
| 2366 | 2743 | MDRV_CPU_MODIFY("main") |
| 2367 | MDRV_CPU_IO_MAP(tontonb_ | |
| 2744 | MDRV_CPU_IO_MAP(tontonb_ioma | |
| 2368 | 2745 | MACHINE_DRIVER_END |
| 2369 | 2746 | |
| 2370 | 2747 | static MACHINE_DRIVER_START( mjdiplob ) |
| 2371 | /* basic machine hardware */ | |
| 2372 | 2748 | MDRV_IMPORT_FROM(dondenmj) |
| 2373 | 2749 | MDRV_CPU_MODIFY("main") |
| 2374 | MDRV_CPU_IO_MAP(mjdiplob_ | |
| 2750 | MDRV_CPU_IO_MAP(mjdiplob_i | |
| 2375 | 2751 | MACHINE_DRIVER_END |
| 2376 | 2752 | |
| 2377 | 2753 | static MACHINE_DRIVER_START( majs101b ) |
| 2378 | /* basic machine hardware */ | |
| 2379 | 2754 | MDRV_IMPORT_FROM(dondenmj) |
| 2380 | 2755 | MDRV_CPU_MODIFY("main") |
| 2381 | MDRV_CPU_IO_MAP(majs101b_ | |
| 2756 | MDRV_CPU_IO_MAP(majs101b_i | |
| 2382 | 2757 | MACHINE_DRIVER_END |
| 2383 | 2758 | |
| 2759 | static MACHINE_DRIVER_START( mjapinky ) | |
| 2760 | MDRV_IMPORT_FROM(dondenmj) | |
| 2761 | MDRV_CPU_MODIFY("main") | |
| 2762 | MDRV_CPU_PROGRAM_MAP(mjapinky_map,0) | |
| 2763 | MDRV_CPU_IO_MAP(mjapinky_iomap,0) | |
| 2764 | MACHINE_DRIVER_END | |
| 2765 | ||
| 2384 | 2766 | static MACHINE_DRIVER_START( mjderngr ) |
| 2385 | /* basic machine hardware */ | |
| 2386 | 2767 | MDRV_IMPORT_FROM(dondenmj) |
| 2387 | 2768 | MDRV_CPU_MODIFY("main") |
| 2388 | MDRV_CPU_IO_MAP(mjderngr_ | |
| 2769 | MDRV_CPU_IO_MAP(mjderngr_i | |
| 2389 | 2770 | |
| 2390 | 2771 | /* video hardware */ |
| 2391 | MDRV_VIDEO_UPDATE(mjderngr) | |
| 2772 | MDRV_PALETTE_LENGTH(16*32) | |
| 2773 | MDRV_PALETTE_INIT(mjderngr) | |
| 2392 | 2774 | MACHINE_DRIVER_END |
| 2393 | 2775 | |
| 2394 | ||
| 2395 | 2776 | /* It runs in IM 2, thus needs a vector on the data bus */ |
| 2396 | static INTERRUPT_GEN( janptr96_ | |
| 2777 | static INTERRUPT_GEN( janptr96_ | |
| 2397 | 2778 | { |
| 2398 | 2779 | switch(cpu_getiloops()) |
| 2399 | 2780 | { |
| r936 | r937 | |
| 2404 | 2785 | } |
| 2405 | 2786 | |
| 2406 | 2787 | static MACHINE_DRIVER_START( janptr96 ) |
| 2407 | ||
| 2408 | /* basic machine hardware */ | |
| 2409 | 2788 | MDRV_IMPORT_FROM(mjderngr) |
| 2410 | ||
| 2411 | 2789 | MDRV_CPU_REPLACE("main",Z80,24000000/4) /* 6 MHz? */ |
| 2412 | MDRV_CPU_PROGRAM_MAP(janptr96_readmem,janptr96_writemem) | |
| 2413 | MDRV_CPU_IO_MAP(janptr96_readport,janptr96_writeport) | |
| 2414 | MDRV_CPU_VBLANK_INT(janptr96_vblank_interrupt,3) /* IM 2 needs a vector on the data bus */ | |
| 2790 | MDRV_CPU_PROGRAM_MAP(janptr96_map,0) | |
| 2791 | MDRV_CPU_IO_MAP(janptr96_iomap,0) | |
| 2792 | MDRV_CPU_VBLANK_INT(janptr96_interrupt,3) /* IM 2 needs a vector on the data bus */ | |
| 2415 | 2793 | |
| 2416 | 2794 | MDRV_SCREEN_VISIBLE_AREA(0, 255, 9, 255-8) |
| 2417 | 2795 | MACHINE_DRIVER_END |
| 2418 | 2796 | |
| 2419 | 2797 | |
| 2420 | 2798 | static MACHINE_DRIVER_START( mjifb ) |
| 2421 | ||
| 2422 | /* basic machine hardware */ | |
| 2423 | 2799 | MDRV_IMPORT_FROM(mjderngr) |
| 2424 | 2800 | MDRV_CPU_REPLACE("main",TMP90841, 8000000) /* ? */ |
| 2425 | 2801 | MDRV_CPU_PROGRAM_MAP(mjifb_map,0) |
| r936 | r937 | |
| 2429 | 2805 | MDRV_SCREEN_VISIBLE_AREA(0, 255, 8, 255-8) |
| 2430 | 2806 | MACHINE_DRIVER_END |
| 2431 | 2807 | |
| 2432 | static INTERRUPT_GEN( mjtensin_ | |
| 2808 | static INTERRUPT_GEN( mjtensin_ | |
| 2433 | 2809 | { |
| 2434 | 2810 | switch(cpu_getiloops()) |
| 2435 | 2811 | { |
| r936 | r937 | |
| 2439 | 2815 | } |
| 2440 | 2816 | |
| 2441 | 2817 | static MACHINE_DRIVER_START( mjtensin ) |
| 2442 | ||
| 2443 | /* basic machine hardware */ | |
| 2444 | 2818 | MDRV_IMPORT_FROM(mjderngr) |
| 2445 | 2819 | MDRV_CPU_REPLACE("main",TMP90841, 12000000) /* ? */ |
| 2446 | 2820 | MDRV_CPU_PROGRAM_MAP(mjtensin_map,0) |
| 2447 | 2821 | MDRV_CPU_IO_MAP(mjtensin_iomap,0) |
| 2448 | MDRV_CPU_VBLANK_INT( mjtensin_ | |
| 2822 | MDRV_CPU_VBLANK_INT( mjtensin_ | |
| 2449 | 2823 | |
| 2450 | 2824 | MDRV_SCREEN_VISIBLE_AREA(0, 255, 8, 255-8) |
| 2451 | 2825 | MACHINE_DRIVER_END |
| 2452 | 2826 | |
| 2453 | static MACHINE_DRIVER_START( mjapinky ) | |
| 2454 | /* basic machine hardware */ | |
| 2455 | MDRV_IMPORT_FROM(dondenmj) | |
| 2456 | MDRV_CPU_MODIFY("main") | |
| 2457 | MDRV_CPU_IO_MAP(mjapinky_readport,mjapinky_writeport) | |
| 2827 | static MACHINE_DRIVER_START( cafetime ) | |
| 2828 | MDRV_IMPORT_FROM(mjderngr) | |
| 2829 | MDRV_CPU_REPLACE("main",TMP90841, 12000000) /* ? */ | |
| 2830 | MDRV_CPU_PROGRAM_MAP(cafetime_map,0) | |
| 2831 | MDRV_CPU_IO_MAP(cafetime_iomap,0) | |
| 2832 | MDRV_CPU_VBLANK_INT(mjtensin_interrupt,2) | |
| 2833 | ||
| 2834 | MDRV_SCREEN_VISIBLE_AREA(0, 255, 8, 255-8) | |
| 2458 | 2835 | MACHINE_DRIVER_END |
| 2459 | 2836 | |
| 2460 | ||
| 2461 | 2837 | /*************************************************************************** |
| 2462 | 2838 | |
| 2463 | 2839 | Game driver(s) |
| r936 | r937 | |
| 2760 | 3136 | ROM_LOAD( "18s030n.clr", 0x0000, 0x0020, CRC(5736d0aa) SHA1(298b51340d2697347842cfaa5921f31c7b7f9748) ) |
| 2761 | 3137 | ROM_END |
| 2762 | 3138 | |
| 3139 | ||
| 3140 | /*************************************************************************** | |
| 3141 | ||
| 3142 | Mahjong Cafe Time | |
| 3143 | (c)1992 Dynax | |
| 3144 | Modified Royal Mahjong PCB | |
| 3145 | D6310128L1-1 (Sub PCB) | |
| 3146 | ||
| 3147 | CPU: Z80 | |
| 3148 | Sound: AY-3-8910 | |
| 3149 | ||
| 3150 | ROMs: | |
| 3151 | 6301.2E [1fc10e7c] | |
| 3152 | 6302.3E [02bbdf78] | |
| 3153 | 6303.5E [0e71eea8] | |
| 3154 | 6304.6E [53c581d6] | |
| 3155 | ||
| 3156 | D63-1.7F [e7410136] MB7124H | |
| 3157 | D63-2.8F [af735b42] / | |
| 3158 | ||
| 3159 | ***************************************************************************/ | |
| 3160 | ||
| 3161 | ROM_START( cafetime ) | |
| 3162 | ROM_REGION( 0x210000, REGION_CPU1, 0 ) | |
| 3163 | ROM_LOAD( "6301.2e", 0x000000, 0x40000, CRC(1fc10e7c) SHA1(0ed6bfd4cc6fc64bbf55bd3c6bde2d8ba9da2afb) ) | |
| 3164 | /* bank switched ROMs follow */ | |
| 3165 | ROM_RELOAD( 0x010000, 0x40000 ) | |
| 3166 | ROM_RELOAD( 0x050000, 0x40000 ) | |
| 3167 | ROM_LOAD( "6302.3e", 0x090000, 0x80000, CRC(02bbdf78) SHA1(e1e107541236ed92854fac4e12c9b300dbac9822) ) | |
| 3168 | ROM_LOAD( "6303.5e", 0x110000, 0x80000, CRC(0e71eea8) SHA1(f95c3b7acee6deabff4aca83b490e255648e2f19) ) | |
| 3169 | ROM_LOAD( "6304.6e", 0x190000, 0x80000, CRC(53c581d6) SHA1(d9cfda63a8f2e92873f69c673d3efe5c22cfa0de) ) | |
| 3170 | ||
| 3171 | ROM_REGION( 0x400, REGION_PROMS, 0 ) | |
| 3172 | ROM_LOAD( "d63-2.8f", 0x000, 0x200, CRC(af735b42) SHA1(deddde3e276d5b9de72e267f65399d80783c6244) ) | |
| 3173 | ROM_LOAD( "d63-1.7f", 0x200, 0x200, CRC(e7410136) SHA1(54d3aec0d11485d4f419e76f9c4071ab9b817937) ) | |
| 3174 | ROM_END | |
| 3175 | ||
| 3176 | ||
| 2763 | 3177 | static DRIVER_INIT( janptr96 ) |
| 2764 | 3178 | { |
| 2765 | 3179 | generic_nvram_size = 0x1000 * 9; |
| r936 | r937 | |
| 2769 | 3183 | } |
| 2770 | 3184 | |
| 2771 | 3185 | |
| 2772 | ||
| 2773 | 3186 | GAME( 1982, royalmah, 0, royalmah, royalmah, 0, ROT0, "Falcon", "Royal Mahjong (Japan)", 0 ) |
| 2774 | 3187 | GAME( 1986, dondenmj, 0, dondenmj, majs101b, 0, ROT0, "Dyna Electronics", "Don Den Mahjong [BET] (Japan)", 0 ) |
| 2775 | 3188 | GAME( 1986, suzume, 0, suzume, suzume, 0, ROT0, "Dyna Electronics", "Watashiha Suzumechan (Japan)", 0 ) |
| 2776 | 3189 | GAME( 1987, mjdiplob, 0, mjdiplob, mjdiplob, 0, ROT0, "Dynax", "Mahjong Diplomat [BET] (Japan)", 0 ) |
| 2777 | 3190 | GAME( 1987, tontonb, 0, tontonb, tontonb, 0, ROT0, "Dynax", "Tonton [BET] (Japan)", 0 ) |
| 2778 | 3191 | GAME( 1988, majs101b, 0, majs101b, majs101b, 0, ROT0, "Dynax", "Mahjong Studio 101 [BET] (Japan)", 0 ) |
| 2779 | GAME( 1988, mjapinky, 0, mjapinky, mjapinky, 0, ROT0, "Dynax", " | |
| 3192 | GAME( 1988, mjapinky, 0, mjapinky, mjapinky, 0, ROT0, "Dynax", " | |
| 2780 | 3193 | GAME( 1989, mjderngr, 0, mjderngr, majs101b, 0, ROT0, "Dynax", "Mahjong Derringer (Japan)", 0 ) |
| 2781 | 3194 | GAME( 1990, mjifb, 0, mjifb, mjifb, 0, ROT0, "Dynax", "Mahjong If...? [BET]", 0 ) |
| 3195 | GAME( 1992, cafetime, 0, cafetime, cafetime, 0, ROT0, "Dynax", "Mahjong Cafe Time", 0 ) | |
| 2782 | 3196 | GAME( 1995, mjtensin, 0, mjtensin, mjtensin, 0, ROT0, "Dynax", "Mahjong Tensinhai (Japan)", GAME_NOT_WORKING ) |
| 2783 | 3197 | GAME( 1996, janptr96, 0, janptr96, janptr96, janptr96, ROT0, "Dynax", "Janputer '96 (Japan)", 0 ) |
| r936 | r937 | |
|---|---|---|
| 8 | 8 | ***************************************************************************/ |
| 9 | 9 | |
| 10 | 10 | #include "osdcore.h" |
| 11 | #include "corefile.h" | |
| 11 | 12 | #include "chdcd.h" |
| 12 | 13 | #include "aviio.h" |
| 13 | 14 | #include "bitmap.h" |
| r936 | r937 | |
| 52 | 53 | static chd_error chdman_compress_file(chd_file *chd, const char *rawfile, UINT32 offset); |
| 53 | 54 | static chd_error chdman_compress_chd(chd_file *chd, chd_file *source, UINT32 totalhunks); |
| 54 | 55 | |
| 55 | static chd_interface_file *chdman_open(const char *filename, const char *mode); | |
| 56 | static void chdman_close(chd_interface_file *file); | |
| 57 | static UINT32 chdman_read(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer); | |
| 58 | static UINT32 chdman_write(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer); | |
| 59 | static UINT64 chdman_length(chd_interface_file *file); | |
| 60 | 56 | |
| 61 | 57 | |
| 62 | ||
| 63 | 58 | /*************************************************************************** |
| 64 | 59 | GLOBAL VARIABLES |
| 65 | 60 | ***************************************************************************/ |
| 66 | 61 | |
| 67 | static chd_interface chdman_interface = | |
| 68 | { | |
| 69 | chdman_open, | |
| 70 | chdman_close, | |
| 71 | chdman_read, | |
| 72 | chdman_write, | |
| 73 | chdman_length | |
| 74 | }; | |
| 75 | ||
| 76 | 62 | static const char *error_strings[] = |
| 77 | 63 | { |
| 78 | 64 | "no error", |
| r936 | r937 | |
| 216 | 202 | printf(" or: chdman -merge parent.chd diff.chd output.chd\n"); |
| 217 | 203 | printf(" or: chdman -diff parent.chd compare.chd diff.chd\n"); |
| 218 | 204 | printf(" or: chdman -setchs inout.chd cylinders heads sectors\n"); |
| 219 | printf(" or: chdman -split input.chd output.chd length\n"); | |
| 220 | 205 | return 1; |
| 221 | 206 | } |
| 222 | 207 | |
| r936 | r937 | |
| 456 | 441 | UINT32 hunksize = CD_FRAME_SIZE * CD_FRAMES_PER_HUNK; |
| 457 | 442 | UINT32 sectorsize = CD_FRAME_SIZE; |
| 458 | 443 | const char *inputfile, *outputfile; |
| 459 | c | |
| 444 | co | |
| 460 | 445 | UINT32 origtotalsectors; |
| 461 | 446 | chd_file *chd = NULL; |
| 462 | 447 | UINT8 *cache = NULL; |
| 463 | 448 | UINT32 totalsectors; |
| 464 | 449 | double ratio = 1.0; |
| 465 | 450 | UINT32 totalhunks; |
| 451 | file_error filerr; | |
| 466 | 452 | chd_error err; |
| 467 | 453 | int i; |
| 468 | 454 | |
| r936 | r937 | |
| 557 | 543 | int curhunk; |
| 558 | 544 | |
| 559 | 545 | /* open the input file for this track */ |
| 560 | srcfile = chdman_open(track_info.fname[i], "rb"); | |
| 561 | if (srcfile == NULL) | |
| 546 | filerr = core_fopen(track_info.fname[i], OPEN_FLAG_READ, &srcfile); | |
| 547 | if (filerr != FILERR_NONE) | |
| 562 | 548 | { |
| 563 | 549 | fprintf(stderr, "Unable to open file: %s\n", track_info.fname[i]); |
| 564 | 550 | err = CHDERR_FILE_NOT_FOUND; |
| r936 | r937 | |
| 582 | 568 | { |
| 583 | 569 | if (frames < toc.tracks[i].frames) |
| 584 | 570 | { |
| 585 | chdman_read(srcfile, sourcefileoffset, bytespersector, &cache[secnum * CD_FRAME_SIZE]); | |
| 571 | core_fseek(srcfile, sourcefileoffset, SEEK_SET); | |
| 572 | core_fread(srcfile, &cache[secnum * CD_FRAME_SIZE], bytespersector); | |
| 586 | 573 | |
| 587 | 574 | if (track_info.swap[i]) |
| 588 | 575 | { |
| r936 | r937 | |
| 613 | 600 | } |
| 614 | 601 | |
| 615 | 602 | /* close the file */ |
| 616 | c | |
| 603 | core | |
| 617 | 604 | srcfile = NULL; |
| 618 | 605 | } |
| 619 | 606 | |
| r936 | r937 | |
| 628 | 615 | if (cache != NULL) |
| 629 | 616 | free(cache); |
| 630 | 617 | if (srcfile != NULL) |
| 631 | c | |
| 618 | core | |
| 632 | 619 | if (chd != NULL) |
| 633 | 620 | chd_close(chd); |
| 634 | 621 | if (err != CHDERR_NONE) |
| r936 | r937 | |
| 1130 | 1117 | static int do_extract(int argc, char *argv[], int param) |
| 1131 | 1118 | { |
| 1132 | 1119 | const char *inputfile, *outputfile; |
| 1133 | c | |
| 1120 | co | |
| 1134 | 1121 | chd_file *infile = NULL; |
| 1135 | 1122 | const chd_header *header; |
| 1136 | 1123 | UINT64 bytesremaining; |
| 1137 | 1124 | void *hunk = NULL; |
| 1125 | file_error filerr; | |
| 1138 | 1126 | chd_error err; |
| 1139 | 1127 | int hunknum; |
| 1140 | 1128 | |
| r936 | r937 | |
| 1169 | 1157 | } |
| 1170 | 1158 | |
| 1171 | 1159 | /* create the output file */ |
| 1172 | outfile = chdman_open(outputfile, "wb"); | |
| 1173 | if (outfile == NULL) | |
| 1160 | filerr = core_fopen(outputfile, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &outfile); | |
| 1161 | if (filerr != FILERR_NONE) | |
| 1174 | 1162 | { |
| 1175 | 1163 | fprintf(stderr, "Error opening output file '%s'\n", outputfile); |
| 1176 | 1164 | err = CHDERR_CANT_CREATE_FILE; |
| r936 | r937 | |
| 1196 | 1184 | |
| 1197 | 1185 | /* write the hunk to the file */ |
| 1198 | 1186 | bytes_to_write = MIN(bytesremaining, header->hunkbytes); |
| 1199 | byteswritten = chdman_write(outfile, (UINT64)hunknum * (UINT64)header->hunkbytes, bytes_to_write, hunk); | |
| 1187 | core_fseek(outfile, (UINT64)hunknum * (UINT64)header->hunkbytes, SEEK_SET); | |
| 1188 | byteswritten = core_fwrite(outfile, hunk, bytes_to_write); | |
| 1200 | 1189 | if (byteswritten != bytes_to_write) |
| 1201 | 1190 | { |
| 1202 | 1191 | fprintf(stderr, "Error writing hunk %d to output file: %s\n", hunknum, error_string(CHDERR_WRITE_ERROR)); |
| r936 | r937 | |
| 1209 | 1198 | cleanup: |
| 1210 | 1199 | /* clean up our mess */ |
| 1211 | 1200 | if (outfile != NULL) |
| 1212 | | |
| 1201 | | |
| 1213 | 1202 | if (hunk != NULL) |
| 1214 | 1203 | free(hunk); |
| 1215 | 1204 | if (infile != NULL) |
| r936 | r937 | |
| 1228 | 1217 | static int do_extractcd(int argc, char *argv[], int param) |
| 1229 | 1218 | { |
| 1230 | 1219 | const char *inputfile, *outputfile, *outputfile2; |
| 1231 | c | |
| 1220 | co | |
| 1232 | 1221 | chd_file *inputchd = NULL; |
| 1233 | 1222 | cdrom_file *cdrom = NULL; |
| 1234 | 1223 | FILE *outfile = NULL; |
| 1235 | 1224 | const cdrom_toc *toc; |
| 1236 | 1225 | UINT64 out2offs; |
| 1226 | file_error filerr; | |
| 1237 | 1227 | chd_error err; |
| 1238 | 1228 | int track; |
| 1239 | 1229 | |
| r936 | r937 | |
| 1280 | 1270 | } |
| 1281 | 1271 | fprintf(outfile, "CD_ROM\n\n\n"); |
| 1282 | 1272 | |
| 1283 | outfile2 = chdman_open(outputfile2, "wb"); | |
| 1284 | if (outfile2 == NULL) | |
| 1273 | filerr = core_fopen(outputfile2, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &outfile2); | |
| 1274 | if (filerr != FILERR_NONE) | |
| 1285 | 1275 | { |
| 1286 | 1276 | fprintf(stderr, "Error opening output file '%s'\n", outputfile2); |
| 1287 | 1277 | err = CHDERR_CANT_CREATE_FILE; |
| r936 | r937 | |
| 1352 | 1342 | cdrom_read_data(cdrom, cdrom_get_track_start(cdrom, track) + frame, sector, toc->tracks[track].trktype); |
| 1353 | 1343 | |
| 1354 | 1344 | /* write it out */ |
| 1355 | byteswritten = chdman_write(outfile2, out2offs, toc->tracks[track].datasize, sector); | |
| 1345 | core_fseek(outfile2, out2offs, SEEK_SET); | |
| 1346 | byteswritten = core_fwrite(outfile2, sector, toc->tracks[track].datasize); | |
| 1356 | 1347 | if (byteswritten != toc->tracks[track].datasize) |
| 1357 | 1348 | { |
| 1358 | 1349 | fprintf(stderr, "Error writing frame %d to output file: %s\n", frame, error_string(CHDERR_WRITE_ERROR)); |
| r936 | r937 | |
| 1365 | 1356 | cdrom_read_subcode(cdrom, cdrom_get_track_start(cdrom, track) + frame, sector); |
| 1366 | 1357 | |
| 1367 | 1358 | /* write it out */ |
| 1368 | byteswritten = chdman_write(outfile2, out2offs, toc->tracks[track].subsize, sector); | |
| 1359 | core_fseek(outfile2, out2offs, SEEK_SET); | |
| 1360 | byteswritten = core_fwrite(outfile2, sector, toc->tracks[track].subsize); | |
| 1369 | 1361 | if (byteswritten != toc->tracks[track].subsize) |
| 1370 | 1362 | { |
| 1371 | 1363 | fprintf(stderr, "Error writing frame %d to output file: %s\n", frame, error_string(CHDERR_WRITE_ERROR)); |
| r936 | r937 | |
| 1383 | 1375 | if (outfile != NULL) |
| 1384 | 1376 | fclose(outfile); |
| 1385 | 1377 | if (outfile2 != NULL) |
| 1386 | c | |
| 1378 | core | |
| 1387 | 1379 | if (cdrom != NULL) |
| 1388 | 1380 | cdrom_close(cdrom); |
| 1389 | 1381 | if (inputchd != NULL) |
| r936 | r937 | |
| 2352 | 2344 | |
| 2353 | 2345 | |
| 2354 | 2346 | /*------------------------------------------------- |
| 2355 | do_split - split a CHD file into multiple | |
| 2356 | parts | |
| 2357 | -------------------------------------------------*/ | |
| 2358 | ||
| 2359 | static int do_split(int argc, char *argv[], int param) | |
| 2360 | { | |
| 2361 | const char *infilename, *outfilename; | |
| 2362 | UINT64 size, srcsize, curoffs = 0; | |
| 2363 | chd_interface_file *outfile = NULL; | |
| 2364 | chd_interface_file *infile = NULL; | |
| 2365 | chd_error err = CHDERR_NONE; | |
| 2366 | char *curfilename = NULL; | |
| 2367 | UINT32 numfiles = 0; | |
| 2368 | UINT32 index; | |
| 2369 | ||
| 2370 | /* require 5 args total */ | |
| 2371 | if (argc != 5) | |
| 2372 | return usage(); | |
| 2373 | ||
| 2374 | /* extract the data */ | |
| 2375 | infilename = argv[2]; | |
| 2376 | outfilename = argv[3]; | |
| 2377 | size = (UINT64)atoi(argv[4]) * 1024 * 1024; | |
| 2378 | ||
| 2379 | /* print some info */ | |
| 2380 | printf("Input file: %s\n", infilename); | |
| 2381 | printf("Output file: %s\n", outfilename); | |
| 2382 | printf("Split size: %d MB\n", (UINT32)(size / (1024 * 1024))); | |
| 2383 | ||
| 2384 | /* open the input file read-only */ | |
| 2385 | infile = chdman_open(infilename, "rb"); | |
| 2386 | if (infile == NULL) | |
| 2387 | { | |
| 2388 | fprintf(stderr, "Error opening input file '%s' read-only\n", infilename); | |
| 2389 | err = CHDERR_FILE_NOT_FOUND; | |
| 2390 | goto cleanup; | |
| 2391 | } | |
| 2392 | srcsize = chdman_length(infile); | |
| 2393 | numfiles = (srcsize + size - 1) / size; | |
| 2394 | if (numfiles <= 1) | |
| 2395 | { | |
| 2396 | printf("No need to split this file; it is smaller than the split size\n"); | |
| 2397 | return 0; | |
| 2398 | } | |
| 2399 | ||
| 2400 | /* allocate a buffer to hold our names */ | |
| 2401 | curfilename = malloc(strlen(outfilename) + 1 + 4); | |
| 2402 | if (curfilename == NULL) | |
| 2403 | { | |
| 2404 | fprintf(stderr, "Unable to allocate temporary filename\n"); | |
| 2405 | err = CHDERR_OUT_OF_MEMORY; | |
| 2406 | goto cleanup; | |
| 2407 | } | |
| 2408 | ||
| 2409 | /* loop until we copy all of the source */ | |
| 2410 | for (index = 0; index < numfiles; index++) | |
| 2411 | { | |
| 2412 | UINT64 targetsize = MIN(size, srcsize - curoffs); | |
| 2413 | UINT64 remaining = targetsize; | |
| 2414 | UINT64 outoffs = 0; | |
| 2415 | ||
| 2416 | /* open the appropriate output file */ | |
| 2417 | if (index == 0) | |
| 2418 | outfile = chdman_open(outfilename, "wb"); | |
| 2419 | else | |
| 2420 | { | |
| 2421 | chd_multi_filename(outfilename, curfilename, index - 1); | |
| 2422 | outfile = chdman_open(curfilename, "wb"); | |
| 2423 | } | |
| 2424 | ||
| 2425 | /* if we fail, bail */ | |
| 2426 | if (outfile == NULL) | |
| 2427 | { | |
| 2428 | fprintf(stderr, "Error opening output file '%s'\n", (index == 0) ? outfilename : curfilename); | |
| 2429 | err = CHDERR_CANT_CREATE_FILE; | |
| 2430 | goto cleanup; | |
| 2431 | } | |
| 2432 | ||
| 2433 | /* loop until we've copied everything */ | |
| 2434 | while (remaining > 0) | |
| 2435 | { | |
| 2436 | UINT8 buffer[16384]; | |
| 2437 | UINT32 bytes_to_copy = MIN(sizeof(buffer), remaining); | |
| 2438 | UINT32 bytes_read, bytes_written; | |
| 2439 | ||
| 2440 | /* progress */ | |
| 2441 | progress(FALSE, "Writing file %d/%d ... %d%% \r", | |
| 2442 | (UINT32)index + 1, (UINT32)((srcsize + size - 1) / size), | |
| 2443 | 100 - (UINT32)(remaining * 100 / targetsize)); | |
| 2444 | ||
| 2445 | /* read a chunk */ | |
| 2446 | bytes_read = chdman_read(infile, curoffs, bytes_to_copy, buffer); | |
| 2447 | if (bytes_read != bytes_to_copy) | |
| 2448 | { | |
| 2449 | fprintf(stderr, "Error reading %d bytes from offset %08X%08X\n", bytes_to_copy, (UINT32)(curoffs >> 32), (UINT32)curoffs); | |
| 2450 | err = CHDERR_READ_ERROR; | |
| 2451 | goto cleanup; | |
| 2452 | } | |
| 2453 | ||
| 2454 | /* write a chunk */ | |
| 2455 | bytes_written = chdman_write(outfile, outoffs, bytes_to_copy, buffer); | |
| 2456 | if (bytes_written != bytes_to_copy) | |
| 2457 | { | |
| 2458 | fprintf(stderr, "Error writing %d bytes to offset %08X%08X\n", bytes_to_copy, (UINT32)(outoffs >> 32), (UINT32)outoffs); | |
| 2459 | err = CHDERR_WRITE_ERROR; | |
| 2460 | goto cleanup; | |
| 2461 | } | |
| 2462 | ||
| 2463 | /* advance our counters */ | |
| 2464 | curoffs += bytes_read; | |
| 2465 | outoffs += bytes_written; | |
| 2466 | remaining -= bytes_read; | |
| 2467 | } | |
| 2468 | ||
| 2469 | /* all done; close the file */ | |
| 2470 | chdman_close(outfile); | |
| 2471 | outfile = NULL; | |
| 2472 | } | |
| 2473 | progress(TRUE, "File successfully split \n"); | |
| 2474 | ||
| 2475 | cleanup: | |
| 2476 | if (infile != NULL) | |
| 2477 | chdman_close(infile); | |
| 2478 | if (outfile != NULL) | |
| 2479 | chdman_close(outfile); | |
| 2480 | if (curfilename != NULL) | |
| 2481 | free(curfilename); | |
| 2482 | if (err != CHDERR_NONE) | |
| 2483 | for (index = 0; index < numfiles; index++) | |
| 2484 | { | |
| 2485 | if (index == 0) | |
| 2486 | osd_rmfile(outfilename); | |
| 2487 | else | |
| 2488 | { | |
| 2489 | chd_multi_filename(outfilename, curfilename, index - 1); | |
| 2490 | osd_rmfile(curfilename); | |
| 2491 | } | |
| 2492 | } | |
| 2493 | return (err != CHDERR_NONE); | |
| 2494 | } | |
| 2495 | ||
| 2496 | ||
| 2497 | /*------------------------------------------------- | |
| 2498 | 2347 | chdman_compress_file - compress a regular |
| 2499 | 2348 | file via the compression interfaces |
| 2500 | 2349 | -------------------------------------------------*/ |
| 2501 | 2350 | |
| 2502 | 2351 | static chd_error chdman_compress_file(chd_file *chd, const char *rawfile, UINT32 offset) |
| 2503 | 2352 | { |
| 2504 | c | |
| 2353 | co | |
| 2505 | 2354 | const chd_header *header; |
| 2506 | 2355 | UINT64 sourceoffset = 0; |
| 2507 | 2356 | UINT8 *cache = NULL; |
| 2508 | 2357 | double ratio = 1.0; |
| 2358 | file_error filerr; | |
| 2509 | 2359 | chd_error err; |
| 2510 | 2360 | int hunknum; |
| 2511 | 2361 | |
| 2512 | 2362 | /* open the raw file */ |
| 2513 | sourcefile = chdman_open(rawfile, "rb"); | |
| 2514 | if (sourcefile == NULL) | |
| 2363 | filerr = core_fopen(rawfile, OPEN_FLAG_READ, &sourcefile); | |
| 2364 | if (filerr != FILERR_NONE) | |
| 2515 | 2365 | { |
| 2516 | 2366 | err = CHDERR_FILE_NOT_FOUND; |
| 2517 | 2367 | goto cleanup; |
| r936 | r937 | |
| 2540 | 2390 | progress(hunknum == 0, "Compressing hunk %d/%d... (ratio=%d%%) \r", hunknum, header->totalhunks, (int)(100.0 * ratio)); |
| 2541 | 2391 | |
| 2542 | 2392 | /* read the data */ |
| 2543 | bytesread = chdman_read(sourcefile, sourceoffset + offset, header->hunkbytes, cache); | |
| 2393 | core_fseek(sourcefile, sourceoffset + offset, SEEK_SET); | |
| 2394 | bytesread = core_fread(sourcefile, cache, header->hunkbytes); | |
| 2544 | 2395 | if (bytesread < header->hunkbytes) |
| 2545 | 2396 | memset(&cache[bytesread], 0, header->hunkbytes - bytesread); |
| 2546 | 2397 | |
| r936 | r937 | |
| 2563 | 2414 | |
| 2564 | 2415 | cleanup: |
| 2565 | 2416 | if (sourcefile != NULL) |
| 2566 | c | |
| 2417 | core | |
| 2567 | 2418 | if (cache != NULL) |
| 2568 | 2419 | free(cache); |
| 2569 | 2420 | return err; |
| r936 | r937 | |
| 2729 | 2580 | |
| 2730 | 2581 | |
| 2731 | 2582 | /*------------------------------------------------- |
| 2732 | chdman_open - open file | |
| 2733 | -------------------------------------------------*/ | |
| 2734 | ||
| 2735 | static chd_interface_file *chdman_open(const char *filename, const char *mode) | |
| 2736 | { | |
| 2737 | file_error filerr; | |
| 2738 | chd_interface_file *file; | |
| 2739 | UINT32 openflags = 0; | |
| 2740 | int open_or_create = 0; | |
| 2741 | ||
| 2742 | switch(*mode++) | |
| 2743 | { | |
| 2744 | case 'r': | |
| 2745 | openflags |= OPEN_FLAG_READ; | |
| 2746 | if (*mode == 'b') | |
| 2747 | mode++; | |
| 2748 | if (*mode == '+') | |
| 2749 | { | |
| 2750 | openflags |= OPEN_FLAG_WRITE; | |
| 2751 | open_or_create = 1; | |
| 2752 | } | |
| 2753 | break; | |
| 2754 | ||
| 2755 | case 'w': | |
| 2756 | openflags |= OPEN_FLAG_WRITE | OPEN_FLAG_CREATE; | |
| 2757 | if (*mode == 'b') | |
| 2758 | mode++; | |
| 2759 | if (*mode == '+') | |
| 2760 | openflags |= OPEN_FLAG_READ; | |
| 2761 | break; | |
| 2762 | ||
| 2763 | default: | |
| 2764 | return NULL; | |
| 2765 | } | |
| 2766 | ||
| 2767 | file = malloc(sizeof(*file)); | |
| 2768 | if (!file) | |
| 2769 | goto error; | |
| 2770 | ||
| 2771 | /* first try to open without creating */ | |
| 2772 | filerr = osd_open(filename, openflags, &file->file, &file->length); | |
| 2773 | if (filerr != FILERR_NONE) | |
| 2774 | { | |
| 2775 | if (open_or_create) | |
| 2776 | filerr = osd_open(filename, openflags | OPEN_FLAG_CREATE, &file->file, &file->length); | |
| 2777 | if (filerr != FILERR_NONE) | |
| 2778 | goto error; | |
| 2779 | } | |
| 2780 | ||
| 2781 | return file; | |
| 2782 | error: | |
| 2783 | if (file) | |
| 2784 | free(file); | |
| 2785 | return NULL; | |
| 2786 | } | |
| 2787 | ||
| 2788 | ||
| 2789 | /*------------------------------------------------- | |
| 2790 | chdman_close - close file | |
| 2791 | -------------------------------------------------*/ | |
| 2792 | ||
| 2793 | static void chdman_close(chd_interface_file *file) | |
| 2794 | { | |
| 2795 | osd_close(file->file); | |
| 2796 | free(file); | |
| 2797 | } | |
| 2798 | ||
| 2799 | ||
| 2800 | /*------------------------------------------------- | |
| 2801 | chdman_read - read from an offset | |
| 2802 | -------------------------------------------------*/ | |
| 2803 | ||
| 2804 | static UINT32 chdman_read(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer) | |
| 2805 | { | |
| 2806 | UINT32 actual; | |
| 2807 | osd_read(file->file, buffer, offset, count, &actual); | |
| 2808 | return actual; | |
| 2809 | } | |
| 2810 | ||
| 2811 | ||
| 2812 | /*------------------------------------------------- | |
| 2813 | chdman_write - write to an offset | |
| 2814 | -------------------------------------------------*/ | |
| 2815 | ||
| 2816 | static UINT32 chdman_write(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer) | |
| 2817 | { | |
| 2818 | UINT32 actual; | |
| 2819 | osd_write(file->file, buffer, offset, count, &actual); | |
| 2820 | return actual; | |
| 2821 | } | |
| 2822 | ||
| 2823 | ||
| 2824 | /*------------------------------------------------- | |
| 2825 | chdman_length - return the current EOF | |
| 2826 | -------------------------------------------------*/ | |
| 2827 | ||
| 2828 | static UINT64 chdman_length(chd_interface_file *file) | |
| 2829 | { | |
| 2830 | return file->length; | |
| 2831 | } | |
| 2832 | ||
| 2833 | ||
| 2834 | /*------------------------------------------------- | |
| 2835 | 2583 | main - entry point |
| 2836 | 2584 | -------------------------------------------------*/ |
| 2837 | 2585 | |
| r936 | r937 | |
| 2860 | 2608 | { "-info", do_info, 0 }, |
| 2861 | 2609 | { "-merge", do_merge_update_chomp, OPERATION_MERGE }, |
| 2862 | 2610 | { "-diff", do_diff, 0 }, |
| 2863 | { "-setchs", do_setchs, 0 }, | |
| 2864 | { "-split", do_split, 0 }, | |
| 2611 | { "-setchs", do_setchs, 0 } | |
| 2865 | 2612 | }; |
| 2866 | 2613 | extern char build_version[]; |
| 2867 | 2614 | int i; |
| r936 | r937 | |
| 2873 | 2620 | if (argc < 2) |
| 2874 | 2621 | return usage(); |
| 2875 | 2622 | |
| 2876 | /* set the interface for everyone */ | |
| 2877 | chd_set_interface(&chdman_interface); | |
| 2878 | ||
| 2879 | 2623 | /* handle the appropriate command */ |
| 2880 | 2624 | for (i = 0; i < ARRAY_LENGTH(option_list); i++) |
| 2881 | 2625 | if (strcmp(argv[1], option_list[i].option) == 0) |
| r936 | r937 | |
|---|---|---|
| 140 | 140 | # Windows-specific debug objects and flags |
| 141 | 141 | #------------------------------------------------- |
| 142 | 142 | |
| 143 | # define the x64 ABI to be Windows | |
| 144 | DEFS += -DX64_WINDOWS_ABI | |
| 145 | ||
| 143 | 146 | # map all instances of "main" to "utf8_main" |
| 144 | 147 | DEFS += -Dmain=utf8_main |
| 145 | 148 | |
| r936 | r937 | |
| 265 | 268 | |
| 266 | 269 | ledutil$(EXE): $(WINOBJ)/ledutil.o $(LIBOCORE) |
| 267 | 270 | @echo Linking $@... |
| 268 | $(LD) $(LDFLAGS) $ | |
| 271 | $(LD) $(LDFLAGS) $ | |
| 269 | 272 | |
| 270 | 273 | TOOLS += ledutil$(EXE) |
| 271 | 274 | |
| r936 | r937 | |
| 277 | 280 | |
| 278 | 281 | VERINFO = $(WINOBJ)/verinfo$(EXE) |
| 279 | 282 | |
| 280 | $(VERINFO): $(WINOBJ)/verinfo.o $( | |
| 283 | $(VERINFO): $(WINOBJ)/verinfo.o $( | |
| 281 | 284 | @echo Linking $@... |
| 282 | $(LD) $(LDFLAGS) $ | |
| 285 | $(LD) $(LDFLAGS) $ | |
| 283 | 286 | |
| 284 | 287 | BUILD += $(VERINFO) |
| 285 | 288 | |
| r936 | r937 | |
| 299 | 302 | # rules for resource file |
| 300 | 303 | #------------------------------------------------- |
| 301 | 304 | |
| 302 | $( | |
| 305 | $(RESFILE | |
| 303 | 306 | |
| 304 | $(WINOBJ)/mamevers.rc: $(VERINFO) | |
| 307 | $(WINOBJ)/mamevers.rc: $(VERINFO) $(SRC)/version.c | |
| 305 | 308 | @echo Emitting $@... |
| 306 | @$(VERINFO) > $@ | |
| 309 | @$(VERINFO) $(SRC)/version.c > $@ |
| r936 | r937 | |
|---|---|---|
| 303 | 303 | static const render_primitive_list *drawdd_window_get_primitives(win_window_info *window) |
| 304 | 304 | { |
| 305 | 305 | dd_info *dd = window->drawdata; |
| 306 | ||
| 306 | 307 | compute_blit_surface_size(window); |
| 307 | 308 | render_target_set_bounds(window->target, dd->blitwidth, dd->blitheight, 0); |
| 309 | render_target_set_max_update_rate(window->target, (dd->refresh == 0) ? dd->origmode.dwRefreshRate : dd->refresh); | |
| 310 | ||
| 308 | 311 | return render_target_get_primitives(window->target); |
| 309 | 312 | } |
| 310 | 313 |
| r936 | r937 | |
|---|---|---|
| 532 | 532 | |
| 533 | 533 | static const render_primitive_list *drawd3d_window_get_primitives(win_window_info *window) |
| 534 | 534 | { |
| 535 | d3d_info *d3d = window->drawdata; | |
| 535 | 536 | RECT client; |
| 537 | ||
| 536 | 538 | GetClientRect(window->hwnd, &client); |
| 537 | 539 | if (rect_width(&client) > 0 && rect_height(&client) > 0) |
| 540 | { | |
| 538 | 541 | render_target_set_bounds(window->target, rect_width(&client), rect_height(&client), winvideo_monitor_get_aspect(window->monitor)); |
| 542 | render_target_set_max_update_rate(window->target, (d3d->refresh == 0) ? d3d->origmode.RefreshRate : d3d->refresh); | |
| 543 | } | |
| 539 | 544 | return render_target_get_primitives(window->target); |
| 540 | 545 | } |
| 541 | 546 |
| r936 | r937 | |
|---|---|---|
| 282 | 282 | ***************************************************************************/ |
| 283 | 283 | |
| 284 | 284 | /* disk handling */ |
| 285 | chd_error open_disk_image(const game_driver *gamedrv, const rom_entry *romp, chd_file **image); | |
| 285 | chd_error open_disk_image(const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd); | |
| 286 | 286 | chd_file *get_disk_handle(int diskindex); |
| 287 | 287 | |
| 288 | 288 | /* ROM processing */ |
| r936 | r937 | |
|---|---|---|
| 1161 | 1161 | /* create a temporary token for holding intermediate number and memory values */ |
| 1162 | 1162 | tempnum.type = TOK_NUMBER; |
| 1163 | 1163 | tempnum.offset = 0; |
| 1164 | tempnum.info = 0; | |
| 1164 | 1165 | tempmem.type = TOK_MEMORY; |
| 1165 | 1166 | tempmem.offset = 0; |
| 1167 | tempmem.info = 0; | |
| 1166 | 1168 | |
| 1167 | 1169 | /* loop over the entire sequence */ |
| 1168 | 1170 | for (tokindex = 0; expr->token[tokindex].type != TOK_END; tokindex++) |
| r936 | r937 | |
|---|---|---|
| 124 | 124 | UINT16 data16; |
| 125 | 125 | INT16 sdata16; |
| 126 | 126 | INT32 sdata32; |
| 127 | UINT16 ext16; | |
| 127 | 128 | |
| 128 | 129 | switch((opcode>>8)&0xf) |
| 129 | 130 | { |
| r936 | r937 | |
| 208 | 209 | size = 6; |
| 209 | 210 | break; |
| 210 | 211 | case 0x78: |
| 211 | // prefix for | |
| 212 | // mov.l (@aa:x, rx), Rx | |
| 213 | data16 = h8_mem_read16(4); | |
| 214 | // 24 bit abs ? | |
| 215 | if((data16 & 0x20 )==0x20) | |
| 212 | // mov.l @(displ24 + Rs), rd | |
| 213 | size = 10; | |
| 214 | ext16 = h8_mem_read16(4); | |
| 215 | sdata32 = h8_mem_read32(6) & 0xffffff; | |
| 216 | if ( (data16 & 0x80) && ((ext16 & ~7) == 0x6ba0) ) | |
| 216 | 217 | { |
| 217 | sdata32 = h8_mem_read32(6); | |
| 218 | sdata32 &= 0xffffff; | |
| 219 | size = 10; | |
| 218 | sprintf(output, "%4.4x mov.l %s,@(%x, %s)", opcode, reg_names32[ext16&7], sdata32, reg_names32[(data16>>4)&7]); | |
| 220 | 219 | } |
| 221 | else | |
| 220 | else if ( (!(data16 & 0x80)) && ((ext16 & ~7) == 0x6b20) ) | |
| 222 | 221 | { |
| 223 | sdata16 = h8_mem_read16(6); | |
| 224 | sdata32 = sdata16; | |
| 225 | size = 8; | |
| 222 | sprintf(output, "%4.4x mov.l @(%x, %s), %s", opcode, sdata32, reg_names32[(data16>>4)&7], reg_names32[ext16&7]); | |
| 226 | 223 | } |
| 227 | if((data16 & 0x80)== 0x80) | |
| 228 | { | |
| 229 | sprintf(output, "%4.4x %x mov.l %s, @%x", opcode, data16, reg_names32[data16&7], sdata32); | |
| 230 | } | |
| 231 | 224 | else |
| 232 | 225 | { |
| 233 | sprintf(output, "%4.4x | |
| 226 | sprintf(output, "%4.4x ? | |
| 234 | 227 | } |
| 235 | 228 | break; |
| 229 | ||
| 236 | 230 | default: |
| 237 | 231 | sprintf(output, "%4.4x ? %x", opcode, data16); |
| 238 | 232 | break; |
| r936 | r937 | |
| 1145 | 1139 | { |
| 1146 | 1140 | if(((data16>>4) & 0xf) == 0xa) |
| 1147 | 1141 | { |
| 1148 | sprintf(output, "%4.4x mov.w %s, @(%x, %s)", opcode, reg_names16[(data16 & 0xf)], data32, reg_names32[opcode&7]); | |
| 1142 | sprintf(output, "%4.4x mov.w %s, @(%x, %s)", opcode, reg_names16[(data16 & 0xf)], data32, reg_names32[(opcode>>4)&7]); | |
| 1149 | 1143 | } |
| 1150 | 1144 | else |
| 1151 | 1145 | { |
| r936 | r937 | |
|---|---|---|
| 121 | 121 | static INT8 h8_neg8(INT8 src); |
| 122 | 122 | static INT16 h8_neg16(INT16 src); |
| 123 | 123 | |
| 124 | static UINT16 h8_divxu8 (UINT16 dst, UINT8 src); | |
| 124 | 125 | static UINT32 h8_divxu16(UINT32 dst, UINT16 src); |
| 125 | 126 | |
| 126 | 127 | static UINT8 h8_not8(UINT8 src); |
| r936 | r937 | |
| 138 | 139 | |
| 139 | 140 | static UINT8 h8_shll8(UINT8 src); |
| 140 | 141 | static UINT16 h8_shll16(UINT16 src); |
| 142 | static UINT32 h8_shll32(UINT32 src); | |
| 143 | ||
| 141 | 144 | static UINT8 h8_shlr8(UINT8 src); |
| 142 | 145 | static UINT16 h8_shlr16(UINT16 src); |
| 143 | 146 | static UINT32 h8_shlr32(UINT32 src); |
| r936 | r937 | |
| 462 | 465 | { |
| 463 | 466 | h8.ppc = h8.pc; |
| 464 | 467 | |
| 468 | #ifdef MAME_DEBUG | |
| 465 | 469 | CALL_MAME_DEBUG; |
| 466 | ||
| 470 | #endif | |
| 467 | 471 | opcode = cpu_readop16(h8.pc); |
| 468 | 472 | // mame_printf_debug("[%06x]: %04x => %x\n", h8.pc, opcode, (opcode>>12)&0xf); |
| 469 | 473 | h8.pc += 2; |
| r936 | r937 | |
| 711 | 715 | address24 += sdata16; |
| 712 | 716 | H8_IFETCH_TIMING(3); |
| 713 | 717 | H8_WORD_TIMING(2, address24); |
| 714 | if( | |
| 718 | if( | |
| 715 | 719 | { |
| 716 | 720 | udata32 = h8_getreg32(ext16 & 0x7); |
| 717 | 721 | h8_mem_write32(address24, udata32); |
| r936 | r937 | |
| 726 | 730 | case 0x78: |
| 727 | 731 | // prefix for |
| 728 | 732 | // mov.l (@aa:x, rx), Rx |
| 733 | //00000A10 010078606B2600201AC2 MOV.L @($00201AC2,ER6),ER6 | |
| 734 | // mov.l @(displ24 + Rs), rd | |
| 735 | srcreg = (ext16 >> 4) & 7; | |
| 729 | 736 | |
| 730 | //00000A10 010078606B2600201AC2 MOV.L @($00201AC2,ER6),ER6 | |
| 731 | if((ext16&0xf)==0) | |
| 737 | // 6b20 | |
| 738 | udata16 = h8_mem_read16(h8.pc); | |
| 739 | h8.pc += 2; | |
| 740 | dstreg = udata16 & 7; | |
| 741 | ||
| 742 | address24 = h8_mem_read32(h8.pc); | |
| 743 | h8.pc += 4; | |
| 744 | address24 += h8_getreg32(srcreg); | |
| 745 | address24 &= 0xffffff; | |
| 746 | ||
| 747 | if ( (ext16 & 0x80) && ((udata16 & ~7) == 0x6ba0) ) | |
| 732 | 748 | { |
| 733 | address24 = h8_getreg32((ext16>>4) & 0x7); | |
| 734 | ext16=h8_mem_read16(h8.pc); | |
| 735 | h8.pc += 2; | |
| 736 | if((ext16&0xfff0) == 0x6b20) | |
| 737 | { | |
| 738 | udata32=h8_mem_read32(h8.pc); | |
| 739 | h8.pc += 4; | |
| 740 | udata32+=address24; | |
| 741 | udata32=h8_mem_read32(udata32); | |
| 742 | ||
| 743 | h8.h8zflag = (udata32==0)?1:0; | |
| 744 | h8.h8nflag = (udata32&0x80000000)?1:0; | |
| 745 | h8.h8vflag = 0; | |
| 746 | h8_setreg32(ext16 & 0x7, udata32); | |
| 747 | H8_IOP_TIMING(14); | |
| 748 | break; | |
| 749 | } | |
| 749 | udata32 = h8_getreg32(dstreg); | |
| 750 | h8_mem_write32(address24, udata32); | |
| 750 | 751 | } |
| 752 | else if ( (!(ext16 & 0x80)) && ((udata16 & ~7) == 0x6b20) ) | |
| 753 | { | |
| 754 | udata32 = h8_mem_read32(address24); | |
| 755 | h8_setreg32(dstreg, udata32); | |
| 756 | } | |
| 757 | else | |
| 758 | { | |
| 759 | h8.h8err = 1; | |
| 760 | } | |
| 751 | 761 | |
| 752 | h8 | |
| 762 | h8_mov32(udata32); | |
| 753 | 763 | |
| 764 | H8_IFETCH_TIMING(5); | |
| 765 | H8_WORD_TIMING(2, address24); | |
| 766 | ||
| 754 | 767 | break; |
| 755 | 768 | default: |
| 756 | 769 | h8.h8err = 1; |
| r936 | r937 | |
| 1056 | 1069 | h8_setreg16(opcode & 0xf, udata16); |
| 1057 | 1070 | H8_IFETCH_TIMING(1); |
| 1058 | 1071 | break; |
| 1072 | case 0x3: | |
| 1073 | // shal.l Rx | |
| 1074 | udata32 = h8_getreg32(opcode & 0x7); | |
| 1075 | udata32 = h8_shll32(udata32); | |
| 1076 | h8_setreg32(opcode & 0x7, udata32); | |
| 1077 | H8_IFETCH_TIMING(1); | |
| 1078 | break; | |
| 1079 | ||
| 1059 | 1080 | case 0x8: |
| 1060 | 1081 | // shal.b Rx |
| 1061 | 1082 | udata8 = h8_getreg8(opcode & 0xf); |
| r936 | r937 | |
| 1070 | 1091 | h8_setreg16(opcode & 0xf, udata16); |
| 1071 | 1092 | H8_IFETCH_TIMING(1); |
| 1072 | 1093 | break; |
| 1073 | ||
| 1094 | ||
| 1074 | 1095 | default: |
| 1075 | 1096 | logerror("H8/3002: Unk. group 1 0 %x\n", opcode); |
| 1076 | 1097 | h8.h8err = 1; |
| r936 | r937 | |
| 1237 | 1258 | h8_setreg16(dstreg, udata16); |
| 1238 | 1259 | H8_IFETCH_TIMING(1); |
| 1239 | 1260 | break; |
| 1261 | ||
| 1262 | case 0x5: | |
| 1263 | // extu.w Rx | |
| 1264 | dstreg = opcode & 0xf; | |
| 1265 | udata16 = h8_getreg16(dstreg) & 0x00ff; | |
| 1266 | h8_setreg16(dstreg, udata16); | |
| 1267 | h8.h8nflag = 0; | |
| 1268 | h8.h8vflag = 0; | |
| 1269 | h8.h8zflag = ((udata16 == 0) ? 1 : 0); | |
| 1270 | H8_IFETCH_TIMING(1); | |
| 1271 | break; | |
| 1240 | 1272 | case 0x7: |
| 1241 | 1273 | // extu.l Rx |
| 1242 | dstreg = opcode & 0xf; | |
| 1243 | h8_setreg32(dstreg, h8_getreg32(dstreg) & 0xffff); | |
| 1274 | dstreg = opcode & 0x7; | |
| 1275 | udata32 = h8_getreg32(dstreg) & 0x0000ffff; | |
| 1276 | h8_setreg32(dstreg, udata32); | |
| 1277 | h8.h8nflag = 0; | |
| 1278 | h8.h8vflag = 0; | |
| 1279 | h8.h8zflag = ((udata32 == 0) ? 1 : 0); | |
| 1244 | 1280 | H8_IFETCH_TIMING(1); |
| 1245 | 1281 | break; |
| 1246 | 1282 | case 0x8: |
| r936 | r937 | |
| 1376 | 1412 | h8_setreg16(dstreg, udata16); |
| 1377 | 1413 | H8_IFETCH_TIMING(1); |
| 1378 | 1414 | break; |
| 1415 | case 0xf: // dec.l #2, rN | |
| 1416 | dstreg = opcode & 0x7; | |
| 1417 | udata32 = h8_dec32(h8_getreg32(dstreg)); | |
| 1418 | if (h8.h8vflag) | |
| 1419 | { | |
| 1420 | udata32 = h8_dec32(udata32); | |
| 1421 | h8.h8vflag = 1; | |
| 1422 | } | |
| 1423 | else | |
| 1424 | udata32 = h8_dec32(udata32); | |
| 1425 | h8_setreg32(dstreg, udata32); | |
| 1426 | H8_IFETCH_TIMING(1); | |
| 1427 | break; | |
| 1428 | ||
| 1379 | 1429 | default: |
| 1380 | 1430 | logerror("H8/3002: Unk. group 1 B %x\n", opcode); |
| 1381 | 1431 | h8.h8err = 1; |
| r936 | r937 | |
| 1392 | 1442 | h8_cmp16(h8_getreg16((opcode>>4) &0xf), h8_getreg16(opcode & 0xf)); |
| 1393 | 1443 | H8_IFETCH_TIMING(1); |
| 1394 | 1444 | break; |
| 1445 | case 0xe: | |
| 1446 | // subx.b rx, ry | |
| 1447 | dstreg = opcode & 0xf; | |
| 1448 | udata8 = h8_subx8(h8_getreg8((opcode>>4) &0xf), h8_getreg8(dstreg)); | |
| 1449 | h8_setreg8(dstreg, udata8); | |
| 1450 | H8_IFETCH_TIMING(1); | |
| 1451 | break; | |
| 1395 | 1452 | case 0xf: |
| 1396 | 1453 | if(opcode & 0x80) |
| 1397 | 1454 | { |
| r936 | r937 | |
| 1435 | 1492 | H8_IFETCH_TIMING(1); |
| 1436 | 1493 | H8_IOP_TIMING(12); |
| 1437 | 1494 | break; |
| 1495 | case 0x1: | |
| 1438 | 1496 | // divxu.b |
| 1497 | udata8 = h8_getreg8((opcode>>4)&0xf); | |
| 1498 | udata16 = h8_getreg16(opcode & 0x0f); | |
| 1499 | udata16 = h8_divxu8(udata16,udata8); | |
| 1500 | h8_setreg16(opcode & 0xf, udata16); | |
| 1501 | H8_IFETCH_TIMING(1); | |
| 1502 | H8_IOP_TIMING(12); | |
| 1503 | break; | |
| 1439 | 1504 | case 0x2: |
| 1440 | 1505 | // mulxu.w |
| 1441 | 1506 | udata16 = h8_getreg16((opcode>>4)&0xf); |
| r936 | r937 | |
| 1572 | 1637 | address24 &= 0xffffff; |
| 1573 | 1638 | // extended mode stack push! |
| 1574 | 1639 | h8_setreg32(H8_SP, h8_getreg32(H8_SP)-4); |
| 1575 | h8_mem_write32(h8_getreg32(H8_SP), h8.pc | |
| 1640 | h8_mem_write32(h8_getreg32(H8_SP), h8.pc | |
| 1576 | 1641 | h8.pc = address24; |
| 1577 | 1642 | change_pc(h8.pc); |
| 1578 | 1643 | H8_STACK_TIMING(2); |
| r936 | r937 | |
| 1946 | 2011 | } |
| 1947 | 2012 | break; |
| 1948 | 2013 | case 0x8: |
| 1949 | | |
| 2014 | ex | |
| 1950 | 2015 | h8.pc += 2; |
| 1951 | 2016 | udata32 = h8_mem_read32(h8.pc); |
| 1952 | 2017 | h8.pc += 4; |
| 1953 | 2018 | |
| 1954 | if((( | |
| 2019 | if(((ex | |
| 1955 | 2020 | { |
| 1956 | if((( | |
| 2021 | if(((ex | |
| 1957 | 2022 | { |
| 1958 | udata8 = h8_getreg8( | |
| 2023 | udata8 = h8_getreg8(ex | |
| 1959 | 2024 | h8_mov8(udata8); // update flags ! |
| 1960 | 2025 | udata32 += h8_getreg32((opcode >> 4) & 7); |
| 1961 | 2026 | h8_mem_write8(udata32, udata8); |
| r936 | r937 | |
| 1965 | 2030 | udata32 += h8_getreg32((opcode >> 4) & 7); |
| 1966 | 2031 | udata8 = h8_mem_read8(udata32); |
| 1967 | 2032 | h8_mov8(udata8); // update flags ! |
| 1968 | h8_setreg8( | |
| 2033 | h8_setreg8(ex | |
| 1969 | 2034 | } |
| 1970 | 2035 | H8_BYTE_TIMING(1, udata32); |
| 1971 | 2036 | H8_IFETCH_TIMING(4); |
| 1972 | 2037 | } |
| 1973 | else if (( | |
| 2038 | else if ((ex | |
| 1974 | 2039 | { |
| 1975 | 2040 | udata32 += h8_getreg32((opcode >> 4) & 7); |
| 1976 | 2041 | udata16 = h8_mem_read16(udata32); |
| 2042 | h8_setreg16(ext16 & 0xf, udata16); | |
| 1977 | 2043 | h8_mov16(udata16); // update flags ! |
| 1978 | h8_setreg16(udata16 & 0xf, udata16); | |
| 1979 | ||
| 1980 | H8_BYTE_TIMING(1, udata32); | |
| 2044 | H8_WORD_TIMING(1, udata32); | |
| 1981 | 2045 | H8_IFETCH_TIMING(4); |
| 1982 | 2046 | } |
| 2047 | else if ((ext16 & 0xfff0) == 0x6ba0) // mov.w rM, @(24-bit direct, rN) | |
| 2048 | { | |
| 2049 | udata32 += h8_getreg32((opcode >> 4) & 7); | |
| 2050 | udata16 = h8_getreg16(ext16 & 0xf); | |
| 2051 | h8_mem_write16(udata32, udata16); | |
| 2052 | h8_mov16(udata16); // update flags ! | |
| 2053 | H8_WORD_TIMING(1, udata32); | |
| 2054 | H8_IFETCH_TIMING(4); | |
| 2055 | } | |
| 1983 | 2056 | else |
| 1984 | 2057 | { |
| 1985 | 2058 | logerror("H8/3002: Unk. group 7 8 %x\n", opcode); |
| 1986 | 2059 | h8.h8err = 1; |
| 1987 | 2060 | } |
| 1988 | 2061 | break; |
| 2062 | ||
| 2063 | ||
| 1989 | 2064 | // xxx.w #aa:16, rd |
| 1990 | 2065 | case 0x9: |
| 1991 | 2066 | if( ((opcode>>4) & 0xf) > 0x6) |
| r936 | r937 | |
| 2073 | 2148 | break; |
| 2074 | 2149 | // bxx.b #xx:3, @rd |
| 2075 | 2150 | case 0xc: |
| 2151 | { | |
| 2152 | UINT8 bitnr; | |
| 2153 | ||
| 2154 | address24 = h8_getreg32((opcode>>4) & 0x7); | |
| 2155 | udata8 = h8_mem_read8(address24); | |
| 2156 | H8_BYTE_TIMING(1, address24); | |
| 2157 | ||
| 2158 | ext16 = h8_mem_read16(h8.pc); | |
| 2159 | h8.pc += 2; | |
| 2160 | H8_IFETCH_TIMING(2); | |
| 2161 | ||
| 2162 | switch(ext16>>8) | |
| 2163 | { | |
| 2164 | // BTST Rn,@ERd | |
| 2165 | case 0x63: | |
| 2166 | srcreg = (ext16>>4)&0xf; | |
| 2167 | bitnr = h8_getreg8(srcreg)&7; | |
| 2168 | h8_btst8(bitnr, udata8); | |
| 2169 | break; | |
| 2170 | // btst.b #imm, @Rn | |
| 2171 | case 0x73: | |
| 2172 | bitnr = (ext16>>4)&7; | |
| 2173 | h8_btst8(bitnr, udata8); | |
| 2174 | break; | |
| 2175 | default: | |
| 2176 | h8.h8err=1; | |
| 2177 | } | |
| 2178 | } | |
| 2179 | break; | |
| 2076 | 2180 | case 0xd: |
| 2077 | 2181 | { |
| 2078 | 2182 | UINT8 bitnr; |
| r936 | r937 | |
| 2088 | 2192 | { |
| 2089 | 2193 | // bset.b #imm, @Rn |
| 2090 | 2194 | case 0x70: udata8 = h8_bset8(bitnr, udata8); h8_mem_write8(address24, udata8); H8_IFETCH_TIMING(2); H8_BYTE_TIMING(2, address24); break; |
| 2091 | // bnot.b #imm, @Rn | |
| 2092 | case 0x71: udata8 = h8_bnot8(bitnr, udata8); h8_mem_write8(address24, udata8); H8_IFETCH_TIMING(2); H8_BYTE_TIMING(2, address24); break; | |
| 2093 | 2195 | // bclr.b #imm, @Rn |
| 2094 | 2196 | case 0x72: udata8 = h8_bclr8(bitnr, udata8); h8_mem_write8(address24, udata8); H8_IFETCH_TIMING(2); H8_BYTE_TIMING(2, address24); break; |
| 2095 | // btst.b #imm, @Rn | |
| 2096 | case 0x73: h8_btst8(bitnr, udata8); H8_IFETCH_TIMING(2); H8_BYTE_TIMING(1, address24); break; | |
| 2097 | // bxor.b #imm, @Rn | |
| 2098 | case 0x75: h8_bxor8(bitnr, udata8); H8_IFETCH_TIMING(2); H8_BYTE_TIMING(1, address24); break; | |
| 2099 | // bld.b #imm, @Rn | |
| 2100 | case 0x77: h8_bld8(bitnr, udata8); H8_IFETCH_TIMING(2); H8_BYTE_TIMING(1, address24); break; | |
| 2101 | 2197 | default: |
| 2102 | 2198 | h8.h8err=1; |
| 2103 | 2199 | logerror("H8/3002: Unk. group 7 cd-1 %x (%x)\n", opcode, (sdata16>>4)&7); |
| r936 | r937 | |
| 3071 | 3167 | return res; |
| 3072 | 3168 | } |
| 3073 | 3169 | |
| 3170 | static UINT32 h8_shll32(UINT32 src) | |
| 3171 | { | |
| 3172 | UINT32 res; | |
| 3173 | h8.h8cflag = (src>>31) & 1; | |
| 3174 | res = src<<1; | |
| 3175 | // N and Z modified | |
| 3176 | h8.h8nflag = (res>>31) & 1; | |
| 3177 | h8.h8vflag = 0; | |
| 3178 | ||
| 3179 | // zflag | |
| 3180 | if(res==0) | |
| 3181 | { | |
| 3182 | h8.h8zflag = 1; | |
| 3183 | } | |
| 3184 | else | |
| 3185 | { | |
| 3186 | h8.h8zflag = 0; | |
| 3187 | } | |
| 3188 | ||
| 3189 | return res; | |
| 3190 | } | |
| 3191 | ||
| 3074 | 3192 | static UINT8 h8_shlr8(UINT8 src) |
| 3075 | 3193 | { |
| 3076 | 3194 | UINT8 res; |
| r936 | r937 | |
| 3473 | 3591 | |
| 3474 | 3592 | } |
| 3475 | 3593 | |
| 3594 | static UINT16 h8_divxu8(UINT16 dst, UINT8 src) | |
| 3595 | { | |
| 3596 | UINT8 remainder, quotient; | |
| 3597 | UINT16 res = 0; | |
| 3598 | // N and Z modified | |
| 3599 | h8.h8nflag = (src>>7)&1; | |
| 3600 | // zflag | |
| 3601 | if(src==0) | |
| 3602 | { | |
| 3603 | h8.h8zflag = 1; | |
| 3604 | // dont do anything on division by zero ! | |
| 3605 | } | |
| 3606 | else | |
| 3607 | { | |
| 3608 | h8.h8zflag = 0; | |
| 3609 | quotient = dst / src; | |
| 3610 | remainder = dst % src; | |
| 3611 | res = (remainder << 8) | quotient; | |
| 3612 | } | |
| 3613 | return res; | |
| 3614 | } | |
| 3615 | ||
| 3476 | 3616 | static UINT32 h8_divxu16(UINT32 dst, UINT16 src) |
| 3477 | 3617 | { |
| 3478 | 3618 | UINT16 remainder, quotient; |
| r936 | r937 | |
| 3649 | 3789 | // Interface functions and variables |
| 3650 | 3790 | case CPUINFO_PTR_SET_INFO: info->setinfo = h8_set_info; break; |
| 3651 | 3791 | case CPUINFO_PTR_GET_CONTEXT: info->getcontext = h8_get_context; break; |
| 3652 | case CPUINFO_PTR_SET_CONTEXT: info->setcontext | |
| 3792 | case CPUINFO_PTR_SET_CONTEXT: info->setcontext | |
| 3653 | 3793 | case CPUINFO_PTR_INIT: info->init = h8_init; break; |
| 3654 | 3794 | case CPUINFO_PTR_RESET: info->reset = h8_reset; break; |
| 3655 | 3795 | case CPUINFO_PTR_EXIT: info->exit = 0; break; |
| r936 | r937 | |
| 3707 | 3847 | case CPUINFO_STR_REGISTER + H8_PC: sprintf(info->s, "PC :%08x", h8.pc); break; |
| 3708 | 3848 | case CPUINFO_STR_REGISTER + H8_CCR: sprintf(info->s, "CCR :%08x", h8_get_ccr()); break; |
| 3709 | 3849 | |
| 3710 | case CPUINFO_STR_REGISTER + H8_E0: sprintf(info->s, "E0 :%08x", h8.regs[0]); break; | |
| 3711 | case CPUINFO_STR_REGISTER + H8_E1: sprintf(info->s, "E1 :%08x", h8.regs[1]); break; | |
| 3712 | case CPUINFO_STR_REGISTER + H8_E2: sprintf(info->s, "E2 :%08x", h8.regs[2]); break; | |
| 3713 | case CPUINFO_STR_REGISTER + H8_E3: sprintf(info->s, "E3 :%08x", h8.regs[3]); break; | |
| 3714 | case CPUINFO_STR_REGISTER + H8_E4: sprintf(info->s, "E4 :%08x", h8.regs[4]); break; | |
| 3715 | case CPUINFO_STR_REGISTER + H8_E5: sprintf(info->s, "E5 :%08x", h8.regs[5]); break; | |
| 3716 | case CPUINFO_STR_REGISTER + H8_E6: sprintf(info->s, "E6 :%08x", h8.regs[6]); break; | |
| 3717 | case CPUINFO_STR_REGISTER + H8_E7: sprintf(info->s, "SP :%08x", h8.regs[7]); break; | |
| 3850 | case CPUINFO_STR_REGISTER + H8_E0: sprintf(info->s, "ER0 :%08x", h8.regs[0]); break; | |
| 3851 | case CPUINFO_STR_REGISTER + H8_E1: sprintf(info->s, "ER1 :%08x", h8.regs[1]); break; | |
| 3852 | case CPUINFO_STR_REGISTER + H8_E2: sprintf(info->s, "ER2 :%08x", h8.regs[2]); break; | |
| 3853 | case CPUINFO_STR_REGISTER + H8_E3: sprintf(info->s, "ER3 :%08x", h8.regs[3]); break; | |
| 3854 | case CPUINFO_STR_REGISTER + H8_E4: sprintf(info->s, "ER4 :%08x", h8.regs[4]); break; | |
| 3855 | case CPUINFO_STR_REGISTER + H8_E5: sprintf(info->s, "ER5 :%08x", h8.regs[5]); break; | |
| 3856 | case CPUINFO_STR_REGISTER + H8_E6: sprintf(info->s, "ER6 :%08x", h8.regs[6]); break; | |
| 3857 | case CPUINFO_STR_REGISTER + H8_E7: sprintf(info->s, " SP :%08x", h8.regs[7]); break; | |
| 3718 | 3858 | } |
| 3719 | 3859 | } |
| r936 | r937 | |
|---|---|---|
| 18 | 18 | # Dynamic recompiler objects |
| 19 | 19 | #------------------------------------------------- |
| 20 | 20 | |
| 21 | ifdef PTR64 | |
| 22 | ||
| 23 | DRCOBJ = $(CPUOBJ)/x64drc.o | |
| 24 | ||
| 25 | DRCDEPS = $(CPUSRC)/x86emit.h \ | |
| 26 | $(CPUSRC)/x64drc.c \ | |
| 27 | $(CPUSRC)/x64drc.h \ | |
| 28 | ||
| 29 | $(DRCOBJ): $(DRCDEPS) | |
| 30 | ||
| 31 | else | |
| 32 | ||
| 21 | 33 | DRCOBJ = $(CPUOBJ)/x86drc.o |
| 22 | 34 | |
| 23 | 35 | DRCDEPS = $(CPUSRC)/x86drc.c \ |
| r936 | r937 | |
| 25 | 37 | |
| 26 | 38 | $(DRCOBJ): $(DRCDEPS) |
| 27 | 39 | |
| 40 | endif | |
| 28 | 41 | |
| 29 | 42 | |
| 30 | 43 | #------------------------------------------------- |
| r936 | r937 | |
| 1064 | 1077 | #------------------------------------------------- |
| 1065 | 1078 | |
| 1066 | 1079 | CPUDEFS += -DHAS_PPC403=$(if $(filter PPC403,$(CPUS)),1,0) |
| 1080 | CPUDEFS += -DHAS_PPC601=$(if $(filter PPC601,$(CPUS)),1,0) | |
| 1067 | 1081 | CPUDEFS += -DHAS_PPC602=$(if $(filter PPC602,$(CPUS)),1,0) |
| 1068 | 1082 | CPUDEFS += -DHAS_PPC603=$(if $(filter PPC603,$(CPUS)),1,0) |
| 1069 | 1083 | CPUDEFS += -DHAS_MPC8240=$(if $(filter MPC8240,$(CPUS)),1,0) |
| 1070 | 1084 | |
| 1071 | ifneq ($(filter PPC403 PPC602 PPC603 MPC8240,$(CPUS)),) | |
| 1085 | ifneq ($(filter PPC403 PPC601 PPC602 PPC603 MPC8240,$(CPUS)),) | |
| 1072 | 1086 | OBJDIRS += $(CPUOBJ)/powerpc |
| 1073 | 1087 | DBGOBJS += $(CPUOBJ)/powerpc/ppc_dasm.o |
| 1074 | 1088 |
| r936 | r937 | |
|---|---|---|
| 4 | 4 | #include "ppc.h" |
| 5 | 5 | #include "debugger.h" |
| 6 | 6 | |
| 7 | #if (HAS_PPC603) | |
| 7 | #if (HAS_PPC603 || HAS_PPC601) | |
| 8 | 8 | void ppc603_exception(int exception); |
| 9 | 9 | #endif |
| 10 | 10 | #if (HAS_PPC602) |
| r936 | r937 | |
| 247 | 247 | FPR fpr[32]; |
| 248 | 248 | UINT32 sr[16]; |
| 249 | 249 | |
| 250 | #if HAS_PPC603 | |
| 250 | #if HAS_PPC603 || HAS_PPC601 | |
| 251 | 251 | int is603; |
| 252 | 252 | #endif |
| 253 | 253 | #if HAS_PPC602 |
| r936 | r937 | |
| 315 | 315 | |
| 316 | 316 | INLINE int IS_PPC603(void) |
| 317 | 317 | { |
| 318 | #if HAS_PPC603 | |
| 318 | #if HAS_PPC603 || HAS_PPC601 | |
| 319 | 319 | return ppc.is603; |
| 320 | 320 | #else |
| 321 | 321 | return 0; |
| r936 | r937 | |
| 478 | 478 | case SPR_PVR: return; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | #if (HAS_PPC603 || HAS_PPC602) | |
| 481 | #if (HAS_PPC603 || HAS_PPC602 || HAS_PPC601) | |
| 482 | 482 | if(IS_PPC602() || IS_PPC603()) { |
| 483 | 483 | switch(spr) |
| 484 | 484 | { |
| r936 | r937 | |
| 490 | 490 | if (IS_PPC602()) |
| 491 | 491 | ppc602_exception(EXCEPTION_DECREMENTER); |
| 492 | 492 | #endif |
| 493 | #if HAS_PPC603 | |
| 493 | #if HAS_PPC603 || HAS_PPC601 | |
| 494 | 494 | if (IS_PPC603()) |
| 495 | 495 | ppc603_exception(EXCEPTION_DECREMENTER); |
| 496 | 496 | #endif |
| r936 | r937 | |
| 689 | 689 | } |
| 690 | 690 | #endif |
| 691 | 691 | |
| 692 | #if (HAS_PPC603 || HAS_PPC602) | |
| 692 | #if (HAS_PPC603 || HAS_PPC602 || HAS_PPC601) | |
| 693 | 693 | if (IS_PPC603() || IS_PPC602()) |
| 694 | 694 | { |
| 695 | 695 | switch (spr) |
| r936 | r937 | |
| 831 | 831 | #include "ppc602.c" |
| 832 | 832 | #endif |
| 833 | 833 | |
| 834 | #if (HAS_PPC603) | |
| 834 | #if (HAS_PPC603 || HAS_PPC601) | |
| 835 | 835 | #include "ppc603.c" |
| 836 | 836 | #endif |
| 837 | 837 | |
| r936 | r937 | |
| 1362 | 1362 | } |
| 1363 | 1363 | #endif |
| 1364 | 1364 | |
| 1365 | ||
| 1366 | #if (HAS_PPC601) | |
| 1367 | static void ppc601_init(int index, int clock, const void *_config, int (*irqcallback)(int)) | |
| 1368 | { | |
| 1369 | const ppc_config *config = _config; | |
| 1370 | int pll_config = 0; | |
| 1371 | float multiplier; | |
| 1372 | int i ; | |
| 1373 | ||
| 1374 | ppc_init() ; | |
| 1375 | ||
| 1376 | optable[48] = ppc_lfs; | |
| 1377 | optable[49] = ppc_lfsu; | |
| 1378 | optable[50] = ppc_lfd; | |
| 1379 | optable[51] = ppc_lfdu; | |
| 1380 | optable[52] = ppc_stfs; | |
| 1381 | optable[53] = ppc_stfsu; | |
| 1382 | optable[54] = ppc_stfd; | |
| 1383 | optable[55] = ppc_stfdu; | |
| 1384 | optable31[631] = ppc_lfdux; | |
| 1385 | optable31[599] = ppc_lfdx; | |
| 1386 | optable31[567] = ppc_lfsux; | |
| 1387 | optable31[535] = ppc_lfsx; | |
| 1388 | optable31[595] = ppc_mfsr; | |
| 1389 | optable31[659] = ppc_mfsrin; | |
| 1390 | optable31[371] = ppc_mftb; | |
| 1391 | optable31[210] = ppc_mtsr; | |
| 1392 | optable31[242] = ppc_mtsrin; | |
| 1393 | optable31[758] = ppc_dcba; | |
| 1394 | optable31[759] = ppc_stfdux; | |
| 1395 | optable31[727] = ppc_stfdx; | |
| 1396 | optable31[983] = ppc_stfiwx; | |
| 1397 | optable31[695] = ppc_stfsux; | |
| 1398 | optable31[663] = ppc_stfsx; | |
| 1399 | optable31[370] = ppc_tlbia; | |
| 1400 | optable31[306] = ppc_tlbie; | |
| 1401 | optable31[566] = ppc_tlbsync; | |
| 1402 | optable31[310] = ppc_eciwx; | |
| 1403 | optable31[438] = ppc_ecowx; | |
| 1404 | ||
| 1405 | optable63[264] = ppc_fabsx; | |
| 1406 | optable63[21] = ppc_faddx; | |
| 1407 | optable63[32] = ppc_fcmpo; | |
| 1408 | optable63[0] = ppc_fcmpu; | |
| 1409 | optable63[14] = ppc_fctiwx; | |
| 1410 | optable63[15] = ppc_fctiwzx; | |
| 1411 | optable63[18] = ppc_fdivx; | |
| 1412 | optable63[72] = ppc_fmrx; | |
| 1413 | optable63[136] = ppc_fnabsx; | |
| 1414 | optable63[40] = ppc_fnegx; | |
| 1415 | optable63[12] = ppc_frspx; | |
| 1416 | optable63[26] = ppc_frsqrtex; | |
| 1417 | optable63[22] = ppc_fsqrtx; | |
| 1418 | optable63[20] = ppc_fsubx; | |
| 1419 | optable63[583] = ppc_mffsx; | |
| 1420 | optable63[70] = ppc_mtfsb0x; | |
| 1421 | optable63[38] = ppc_mtfsb1x; | |
| 1422 | optable63[711] = ppc_mtfsfx; | |
| 1423 | optable63[134] = ppc_mtfsfix; | |
| 1424 | optable63[64] = ppc_mcrfs; | |
| 1425 | ||
| 1426 | optable59[21] = ppc_faddsx; | |
| 1427 | optable59[18] = ppc_fdivsx; | |
| 1428 | optable59[24] = ppc_fresx; | |
| 1429 | optable59[22] = ppc_fsqrtsx; | |
| 1430 | optable59[20] = ppc_fsubsx; | |
| 1431 | ||
| 1432 | for(i = 0; i < 32; i++) | |
| 1433 | { | |
| 1434 | optable63[i * 32 | 29] = ppc_fmaddx; | |
| 1435 | optable63[i * 32 | 28] = ppc_fmsubx; | |
| 1436 | optable63[i * 32 | 25] = ppc_fmulx; | |
| 1437 | optable63[i * 32 | 31] = ppc_fnmaddx; | |
| 1438 | optable63[i * 32 | 30] = ppc_fnmsubx; | |
| 1439 | optable63[i * 32 | 23] = ppc_fselx; | |
| 1440 | ||
| 1441 | optable59[i * 32 | 29] = ppc_fmaddsx; | |
| 1442 | optable59[i * 32 | 28] = ppc_fmsubsx; | |
| 1443 | optable59[i * 32 | 25] = ppc_fmulsx; | |
| 1444 | optable59[i * 32 | 31] = ppc_fnmaddsx; | |
| 1445 | optable59[i * 32 | 30] = ppc_fnmsubsx; | |
| 1446 | } | |
| 1447 | ||
| 1448 | for(i = 0; i < 256; i++) | |
| 1449 | { | |
| 1450 | ppc_field_xlat[i] = | |
| 1451 | ((i & 0x80) ? 0xF0000000 : 0) | | |
| 1452 | ((i & 0x40) ? 0x0F000000 : 0) | | |
| 1453 | ((i & 0x20) ? 0x00F00000 : 0) | | |
| 1454 | ((i & 0x10) ? 0x000F0000 : 0) | | |
| 1455 | ((i & 0x08) ? 0x0000F000 : 0) | | |
| 1456 | ((i & 0x04) ? 0x00000F00 : 0) | | |
| 1457 | ((i & 0x02) ? 0x000000F0 : 0) | | |
| 1458 | ((i & 0x01) ? 0x0000000F : 0); | |
| 1459 | } | |
| 1460 | ||
| 1461 | ppc.is603 = 1; | |
| 1462 | ||
| 1463 | ppc.read8 = program_read_byte_64be; | |
| 1464 | ppc.read16 = program_read_word_64be; | |
| 1465 | ppc.read32 = program_read_dword_64be; | |
| 1466 | ppc.read64 = program_read_qword_64be; | |
| 1467 | ppc.write8 = program_write_byte_64be; | |
| 1468 | ppc.write16 = program_write_word_64be; | |
| 1469 | ppc.write32 = program_write_dword_64be; | |
| 1470 | ppc.write64 = program_write_qword_64be; | |
| 1471 | ppc.read16_unaligned = ppc_read16_unaligned; | |
| 1472 | ppc.read32_unaligned = ppc_read32_unaligned; | |
| 1473 | ppc.read64_unaligned = ppc_read64_unaligned; | |
| 1474 | ppc.write16_unaligned = ppc_write16_unaligned; | |
| 1475 | ppc.write32_unaligned = ppc_write32_unaligned; | |
| 1476 | ppc.write64_unaligned = ppc_write64_unaligned; | |
| 1477 | ||
| 1478 | ppc.irq_callback = irqcallback; | |
| 1479 | ||
| 1480 | ppc.pvr = config->pvr; | |
| 1481 | ||
| 1482 | multiplier = (float)((config->bus_frequency_multiplier >> 4) & 0xf) + | |
| 1483 | (float)(config->bus_frequency_multiplier & 0xf) / 10.0f; | |
| 1484 | bus_freq_multiplier = (int)(multiplier * 2); | |
| 1485 | ||
| 1486 | ppc.hid1 = 0; | |
| 1487 | } | |
| 1488 | ||
| 1489 | static void ppc601_exit(void) | |
| 1490 | { | |
| 1491 | ||
| 1492 | } | |
| 1493 | #endif | |
| 1494 | ||
| 1495 | ||
| 1496 | ||
| 1365 | 1497 | static void ppc_get_context(void *dst) |
| 1366 | 1498 | { |
| 1367 | 1499 | /* copy the context */ |
| r936 | r937 | |
| 1757 | 1889 | } |
| 1758 | 1890 | } |
| 1759 | 1891 | #endif |
| 1892 | ||
| 1893 | /* PPC601 */ | |
| 1894 | ||
| 1895 | #if (HAS_PPC601) | |
| 1896 | static void ppc601_set_info(UINT32 state, cpuinfo *info) | |
| 1897 | { | |
| 1898 | if (state >= CPUINFO_INT_INPUT_STATE && state <= CPUINFO_INT_INPUT_STATE + 5) | |
| 1899 | { | |
| 1900 | ppc603_set_irq_line(state-CPUINFO_INT_INPUT_STATE, info->i); | |
| 1901 | return; | |
| 1902 | } | |
| 1903 | switch(state) | |
| 1904 | { | |
| 1905 | default: ppc_set_info(state, info); break; | |
| 1906 | } | |
| 1907 | } | |
| 1908 | ||
| 1909 | void ppc601_get_info(UINT32 state, cpuinfo *info) | |
| 1910 | { | |
| 1911 | switch(state) | |
| 1912 | { | |
| 1913 | /* --- the following bits of info are returned as 64-bit signed integers --- */ | |
| 1914 | case CPUINFO_INT_INPUT_LINES: info->i = 5; break; | |
| 1915 | case CPUINFO_INT_ENDIANNESS: info->i = CPU_IS_BE; break; | |
| 1916 | ||
| 1917 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 64; break; | |
| 1918 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32; break; | |
| 1919 | ||
| 1920 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 1921 | case CPUINFO_PTR_SET_INFO: info->setinfo = ppc601_set_info; break; | |
| 1922 | case CPUINFO_PTR_INIT: info->init = ppc601_init; break; | |
| 1923 | case CPUINFO_PTR_RESET: info->reset = ppc603_reset; break; | |
| 1924 | case CPUINFO_PTR_EXIT: info->exit = ppc601_exit; break; | |
| 1925 | case CPUINFO_PTR_EXECUTE: info->execute = ppc603_execute; break; | |
| 1926 | case CPUINFO_PTR_READ: info->read = ppc_read; break; | |
| 1927 | case CPUINFO_PTR_WRITE: info->write = ppc_write; break; | |
| 1928 | case CPUINFO_PTR_READOP: info->readop = ppc_readop; break; | |
| 1929 | ||
| 1930 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 1931 | case CPUINFO_STR_NAME: strcpy(info->s, "PPC601"); break; | |
| 1932 | ||
| 1933 | default: ppc_get_info(state, info); break; | |
| 1934 | } | |
| 1935 | } | |
| 1936 | #endif |
| r936 | r937 | |
|---|---|---|
| 1055 | 1055 | #ifndef PPC_DRC |
| 1056 | 1056 | static void ppc_sc(UINT32 op) |
| 1057 | 1057 | { |
| 1058 | #if (HAS_PPC603) | |
| 1058 | #if (HAS_PPC603 || HAS_PPC601) | |
| 1059 | 1059 | if (ppc.is603) { |
| 1060 | 1060 | ppc603_exception(EXCEPTION_SYSTEM_CALL); |
| 1061 | 1061 | } |
| r936 | r937 | |
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | if (exception) { |
| 1528 | #if (HAS_PPC603) | |
| 1528 | #if (HAS_PPC603 || HAS_PPC601) | |
| 1529 | 1529 | if (ppc.is603) { |
| 1530 | 1530 | ppc603_exception(EXCEPTION_TRAP); |
| 1531 | 1531 | } |
| r936 | r937 | |
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | 1571 | if (exception) { |
| 1572 | #if (HAS_PPC603) | |
| 1572 | #if (HAS_PPC603 || HAS_PPC601) | |
| 1573 | 1573 | if (ppc.is603) { |
| 1574 | 1574 | ppc603_exception(EXCEPTION_TRAP); |
| 1575 | 1575 | } |
| r936 | r937 | |
|---|---|---|
| 357 | 357 | void mpc8240_get_info(UINT32 state, cpuinfo *info); |
| 358 | 358 | #endif |
| 359 | 359 | |
| 360 | #if (HAS_PPC601) | |
| 361 | void ppc601_get_info(UINT32 state, cpuinfo *info); | |
| 362 | #endif | |
| 363 | ||
| 360 | 364 | #ifdef MAME_DEBUG |
| 361 | 365 | extern offs_t ppc_dasm_one(char *buffer, offs_t pc, UINT32 op); |
| 362 | 366 | #endif |
| r936 | r937 | |
|---|---|---|
| 16 | 16 | #define MAX_INSTRUCTIONS 512 |
| 17 | 17 | |
| 18 | 18 | |
| 19 | #if (HAS_PPC603) | |
| 19 | #if (HAS_PPC603 || HAS_PPC601) | |
| 20 | 20 | static void ppcdrc603_init(int index, int clock, const void *_config, int (*irqcallback)(int)); |
| 21 | 21 | static void ppcdrc603_exit(void); |
| 22 | 22 | #endif |
| r936 | r937 | |
| 510 | 510 | case SPR_PVR: return; |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | #if (HAS_PPC603 || HAS_PPC602) | |
| 513 | #if (HAS_PPC603 || HAS_PPC602 || HAS_PPC601) | |
| 514 | 514 | if(ppc.is603 || ppc.is602) { |
| 515 | 515 | switch(spr) |
| 516 | 516 | { |
| r936 | r937 | |
| 723 | 723 | } |
| 724 | 724 | #endif |
| 725 | 725 | |
| 726 | #if (HAS_PPC603 || HAS_PPC602) | |
| 726 | #if (HAS_PPC603 || HAS_PPC602 || HAS_PPC601) | |
| 727 | 727 | if (ppc.is603 || ppc.is602) |
| 728 | 728 | { |
| 729 | 729 | switch (spr) |
| r936 | r937 | |
| 1586 | 1586 | } |
| 1587 | 1587 | #endif |
| 1588 | 1588 | |
| 1589 | ||
| 1590 | #if (HAS_PPC601) | |
| 1591 | static void ppc601drc_init(int index, int clock, const void *_config, int (*irqcallback)(int)) | |
| 1592 | { | |
| 1593 | int pll_config = 0; | |
| 1594 | float multiplier; | |
| 1595 | const ppc_config *config = _config; | |
| 1596 | int i; | |
| 1597 | ||
| 1598 | ppc_init(); | |
| 1599 | ppcdrc_init(); | |
| 1600 | ||
| 1601 | optable[48] = recompile_lfs; | |
| 1602 | optable[49] = recompile_lfsu; | |
| 1603 | optable[50] = recompile_lfd; | |
| 1604 | optable[51] = recompile_lfdu; | |
| 1605 | optable[52] = recompile_stfs; | |
| 1606 | optable[53] = recompile_stfsu; | |
| 1607 | optable[54] = recompile_stfd; | |
| 1608 | optable[55] = recompile_stfdu; | |
| 1609 | optable31[631] = recompile_lfdux; | |
| 1610 | optable31[599] = recompile_lfdx; | |
| 1611 | optable31[567] = recompile_lfsux; | |
| 1612 | optable31[535] = recompile_lfsx; | |
| 1613 | optable31[595] = recompile_mfsr; | |
| 1614 | optable31[659] = recompile_mfsrin; | |
| 1615 | optable31[371] = recompile_mftb; | |
| 1616 | optable31[210] = recompile_mtsr; | |
| 1617 | optable31[242] = recompile_mtsrin; | |
| 1618 | optable31[758] = recompile_dcba; | |
| 1619 | optable31[759] = recompile_stfdux; | |
| 1620 | optable31[727] = recompile_stfdx; | |
| 1621 | optable31[983] = recompile_stfiwx; | |
| 1622 | optable31[695] = recompile_stfsux; | |
| 1623 | optable31[663] = recompile_stfsx; | |
| 1624 | optable31[370] = recompile_tlbia; | |
| 1625 | optable31[306] = recompile_tlbie; | |
| 1626 | optable31[566] = recompile_tlbsync; | |
| 1627 | optable31[310] = recompile_eciwx; | |
| 1628 | optable31[438] = recompile_ecowx; | |
| 1629 | ||
| 1630 | optable63[264] = recompile_fabsx; | |
| 1631 | optable63[21] = recompile_faddx; | |
| 1632 | optable63[32] = recompile_fcmpo; | |
| 1633 | optable63[0] = recompile_fcmpu; | |
| 1634 | optable63[14] = recompile_fctiwx; | |
| 1635 | optable63[15] = recompile_fctiwzx; | |
| 1636 | optable63[18] = recompile_fdivx; | |
| 1637 | optable63[72] = recompile_fmrx; | |
| 1638 | optable63[136] = recompile_fnabsx; | |
| 1639 | optable63[40] = recompile_fnegx; | |
| 1640 | optable63[12] = recompile_frspx; | |
| 1641 | optable63[26] = recompile_frsqrtex; | |
| 1642 | optable63[22] = recompile_fsqrtx; | |
| 1643 | optable63[20] = recompile_fsubx; | |
| 1644 | optable63[583] = recompile_mffsx; | |
| 1645 | optable63[70] = recompile_mtfsb0x; | |
| 1646 | optable63[38] = recompile_mtfsb1x; | |
| 1647 | optable63[711] = recompile_mtfsfx; | |
| 1648 | optable63[134] = recompile_mtfsfix; | |
| 1649 | optable63[64] = recompile_mcrfs; | |
| 1650 | ||
| 1651 | optable59[21] = recompile_faddsx; | |
| 1652 | optable59[18] = recompile_fdivsx; | |
| 1653 | optable59[24] = recompile_fresx; | |
| 1654 | optable59[22] = recompile_fsqrtsx; | |
| 1655 | optable59[20] = recompile_fsubsx; | |
| 1656 | ||
| 1657 | for(i = 0; i < 32; i++) | |
| 1658 | { | |
| 1659 | optable63[i * 32 | 29] = recompile_fmaddx; | |
| 1660 | optable63[i * 32 | 28] = recompile_fmsubx; | |
| 1661 | optable63[i * 32 | 25] = recompile_fmulx; | |
| 1662 | optable63[i * 32 | 31] = recompile_fnmaddx; | |
| 1663 | optable63[i * 32 | 30] = recompile_fnmsubx; | |
| 1664 | optable63[i * 32 | 23] = recompile_fselx; | |
| 1665 | ||
| 1666 | optable59[i * 32 | 29] = recompile_fmaddsx; | |
| 1667 | optable59[i * 32 | 28] = recompile_fmsubsx; | |
| 1668 | optable59[i * 32 | 25] = recompile_fmulsx; | |
| 1669 | optable59[i * 32 | 31] = recompile_fnmaddsx; | |
| 1670 | optable59[i * 32 | 30] = recompile_fnmsubsx; | |
| 1671 | } | |
| 1672 | ||
| 1673 | for(i = 0; i < 256; i++) | |
| 1674 | { | |
| 1675 | ppc_field_xlat[i] = | |
| 1676 | ((i & 0x80) ? 0xF0000000 : 0) | | |
| 1677 | ((i & 0x40) ? 0x0F000000 : 0) | | |
| 1678 | ((i & 0x20) ? 0x00F00000 : 0) | | |
| 1679 | ((i & 0x10) ? 0x000F0000 : 0) | | |
| 1680 | ((i & 0x08) ? 0x0000F000 : 0) | | |
| 1681 | ((i & 0x04) ? 0x00000F00 : 0) | | |
| 1682 | ((i & 0x02) ? 0x000000F0 : 0) | | |
| 1683 | ((i & 0x01) ? 0x0000000F : 0); | |
| 1684 | } | |
| 1685 | ||
| 1686 | ppc.is603 = 1; | |
| 1687 | ||
| 1688 | ppc.read8 = program_read_byte_64be; | |
| 1689 | ppc.read16 = program_read_word_64be; | |
| 1690 | ppc.read32 = program_read_dword_64be; | |
| 1691 | ppc.read64 = program_read_qword_64be; | |
| 1692 | ppc.write8 = program_write_byte_64be; | |
| 1693 | ppc.write16 = program_write_word_64be; | |
| 1694 | ppc.write32 = program_write_dword_64be; | |
| 1695 | ppc.write64 = program_write_qword_64be; | |
| 1696 | ppc.read16_unaligned = ppc_read16_unaligned; | |
| 1697 | ppc.read32_unaligned = ppc_read32_unaligned; | |
| 1698 | ppc.read64_unaligned = ppc_read64_unaligned; | |
| 1699 | ppc.write16_unaligned = ppc_write16_unaligned; | |
| 1700 | ppc.write32_unaligned = ppc_write32_unaligned; | |
| 1701 | ppc.write64_unaligned = ppc_write64_unaligned; | |
| 1702 | ||
| 1703 | ppc.irq_callback = irqcallback; | |
| 1704 | ||
| 1705 | ppc.pvr = config->pvr; | |
| 1706 | ||
| 1707 | multiplier = (float)((config->bus_frequency_multiplier >> 4) & 0xf) + | |
| 1708 | (float)(config->bus_frequency_multiplier & 0xf) / 10.0f; | |
| 1709 | bus_freq_multiplier = (int)(multiplier * 2); | |
| 1710 | ||
| 1711 | switch(config->pvr) | |
| 1712 | { | |
| 1713 | case PPC_MODEL_603E: pll_config = mpc603e_pll_config[bus_freq_multiplier-1][config->bus_frequency]; break; | |
| 1714 | case PPC_MODEL_603EV: pll_config = mpc603ev_pll_config[bus_freq_multiplier-1][config->bus_frequency]; break; | |
| 1715 | case PPC_MODEL_603R: pll_config = mpc603r_pll_config[bus_freq_multiplier-1][config->bus_frequency]; break; | |
| 1716 | default: break; | |
| 1717 | } | |
| 1718 | ||
| 1719 | if (pll_config == -1) | |
| 1720 | { | |
| 1721 | fatalerror("PPC: Invalid bus/multiplier combination (bus frequency = %d, multiplier = %1.1f)", config->bus_frequency, multiplier); | |
| 1722 | } | |
| 1723 | ||
| 1724 | ppc.hid1 = pll_config << 28; | |
| 1725 | } | |
| 1726 | ||
| 1727 | static void ppc601drc_exit(void) | |
| 1728 | { | |
| 1729 | #if LOG_CODE | |
| 1730 | //if (symfile) fclose(symfile); | |
| 1731 | #endif | |
| 1732 | drc_exit(ppc.drc); | |
| 1733 | } | |
| 1734 | #endif | |
| 1735 | ||
| 1736 | ||
| 1589 | 1737 | static void ppc_get_context(void *dst) |
| 1590 | 1738 | { |
| 1591 | 1739 | /* copy the context */ |
| r936 | r937 | |
| 1974 | 2122 | } |
| 1975 | 2123 | } |
| 1976 | 2124 | #endif |
| 2125 | ||
| 2126 | ||
| 2127 | /* PPC601 */ | |
| 2128 | ||
| 2129 | #if (HAS_PPC601) | |
| 2130 | static void ppc601_set_info(UINT32 state, cpuinfo *info) | |
| 2131 | { | |
| 2132 | if (state >= CPUINFO_INT_INPUT_STATE && state <= CPUINFO_INT_INPUT_STATE + 5) | |
| 2133 | { | |
| 2134 | ppcdrc603_set_irq_line(state-CPUINFO_INT_INPUT_STATE, info->i); | |
| 2135 | return; | |
| 2136 | } | |
| 2137 | switch(state) | |
| 2138 | { | |
| 2139 | default: ppc_set_info(state, info); break; | |
| 2140 | } | |
| 2141 | } | |
| 2142 | ||
| 2143 | void ppc601_get_info(UINT32 state, cpuinfo *info) | |
| 2144 | { | |
| 2145 | switch(state) | |
| 2146 | { | |
| 2147 | /* --- the following bits of info are returned as 64-bit signed integers --- */ | |
| 2148 | case CPUINFO_INT_INPUT_LINES: info->i = 5; break; | |
| 2149 | case CPUINFO_INT_ENDIANNESS: info->i = CPU_IS_BE; break; | |
| 2150 | ||
| 2151 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 64; break; | |
| 2152 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32; break; | |
| 2153 | ||
| 2154 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2155 | case CPUINFO_PTR_SET_INFO: info->setinfo = ppc601_set_info; break; | |
| 2156 | case CPUINFO_PTR_INIT: info->init = ppc601drc_init; break; | |
| 2157 | case CPUINFO_PTR_RESET: info->reset = ppcdrc603_reset; break; | |
| 2158 | case CPUINFO_PTR_EXIT: info->exit = ppc601drc_exit; break; | |
| 2159 | case CPUINFO_PTR_EXECUTE: info->execute = ppcdrc603_execute; break; | |
| 2160 | case CPUINFO_PTR_READ: info->read = ppc_read; break; | |
| 2161 | case CPUINFO_PTR_WRITE: info->write = ppc_write; break; | |
| 2162 | case CPUINFO_PTR_READOP: info->readop = ppc_readop; break; | |
| 2163 | ||
| 2164 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2165 | case CPUINFO_STR_NAME: strcpy(info->s, "PPC601"); break; | |
| 2166 | ||
| 2167 | default: ppc_get_info(state, info); break; | |
| 2168 | } | |
| 2169 | } | |
| 2170 | #endif |
| r936 | r937 | |
|---|---|---|
| 1520 | 1520 | decode_opcode( buffer, &necv_opcode_table1[op], op ); |
| 1521 | 1521 | return (pc-eip) | dasm_flags | DASMFLAG_SUPPORTED; |
| 1522 | 1522 | } |
| 1523 | /* | |
| 1524 | NEC V-series Disassembler | |
| 1525 | ||
| 1526 | Originally Written for i386 by Ville Linde | |
| 1527 | Converted to NEC-V by Aaron Giles | |
| 1528 | */ | |
| 1529 | ||
| 1530 | #include "cpuintrf.h" | |
| 1531 | ||
| 1532 | enum { | |
| 1533 | PARAM_REG8 = 1, /* 8-bit register */ | |
| 1534 | PARAM_REG16, /* 16-bit register */ | |
| 1535 | PARAM_REG2_8, /* 8-bit register */ | |
| 1536 | PARAM_REG2_16, /* 16-bit register */ | |
| 1537 | PARAM_RM8, /* 8-bit memory or register */ | |
| 1538 | PARAM_RM16, /* 16-bit memory or register */ | |
| 1539 | PARAM_I4, /* 4-bit signed immediate */ | |
| 1540 | PARAM_I8, /* 8-bit signed immediate */ | |
| 1541 | PARAM_I16, /* 16-bit signed immediate */ | |
| 1542 | PARAM_UI8, /* 8-bit unsigned immediate */ | |
| 1543 | PARAM_UI16, /* 16-bit unsigned immediate */ | |
| 1544 | PARAM_IMM, /* 16-bit immediate */ | |
| 1545 | PARAM_ADDR, /* 16:16 address */ | |
| 1546 | PARAM_REL8, /* 8-bit PC-relative displacement */ | |
| 1547 | PARAM_REL16, /* 16-bit PC-relative displacement */ | |
| 1548 | PARAM_MEM_OFFS_B, /* 8-bit mem offset */ | |
| 1549 | PARAM_MEM_OFFS_W, /* 16-bit mem offset */ | |
| 1550 | PARAM_SREG, /* segment register */ | |
| 1551 | PARAM_RBANK, /* register bank (V25) */ | |
| 1552 | PARAM_1, /* used by shift/rotate instructions */ | |
| 1553 | PARAM_AL, | |
| 1554 | PARAM_CL, | |
| 1555 | PARAM_DL, | |
| 1556 | PARAM_BL, | |
| 1557 | PARAM_AH, | |
| 1558 | PARAM_CH, | |
| 1559 | PARAM_DH, | |
| 1560 | PARAM_BH, | |
| 1561 | PARAM_AW, | |
| 1562 | PARAM_CW, | |
| 1563 | PARAM_DW, | |
| 1564 | PARAM_BW, | |
| 1565 | PARAM_SP, | |
| 1566 | PARAM_BP, | |
| 1567 | PARAM_IX, | |
| 1568 | PARAM_IY | |
| 1569 | }; | |
| 1570 | ||
| 1571 | enum { | |
| 1572 | MODRM = 1, | |
| 1573 | GROUP, | |
| 1574 | FPU, | |
| 1575 | TWO_BYTE, | |
| 1576 | PREFIX, | |
| 1577 | SEG_PS, | |
| 1578 | SEG_DS0, | |
| 1579 | SEG_DS1, | |
| 1580 | SEG_SS | |
| 1581 | }; | |
| 1582 | ||
| 1583 | typedef struct { | |
| 1584 | char mnemonic[32]; | |
| 1585 | UINT32 flags; | |
| 1586 | UINT32 param1; | |
| 1587 | UINT32 param2; | |
| 1588 | UINT32 param3; | |
| 1589 | offs_t dasm_flags; | |
| 1590 | } I386_OPCODE; | |
| 1591 | ||
| 1592 | typedef struct { | |
| 1593 | char mnemonic[32]; | |
| 1594 | const I386_OPCODE *opcode; | |
| 1595 | } GROUP_OP; | |
| 1596 | ||
| 1597 | static const UINT8 *opcode_ptr; | |
| 1598 | static const UINT8 *opcode_ptr_base; | |
| 1599 | ||
| 1600 | static const I386_OPCODE necv_opcode_table1[256] = | |
| 1601 | { | |
| 1602 | // 0x00 | |
| 1603 | {"add", MODRM, PARAM_RM8, PARAM_REG8, 0 }, | |
| 1604 | {"add", MODRM, PARAM_RM16, PARAM_REG16, 0 }, | |
| 1605 | {"add", MODRM, PARAM_REG8, PARAM_RM8, 0 }, | |
| 1606 | {"add", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1607 | {"add", 0, PARAM_AL, PARAM_UI8, 0 }, | |
| 1608 | {"add", 0, PARAM_AW, PARAM_IMM, 0 }, | |
| 1609 | {"push ds1", 0, 0, 0, 0 }, | |
| 1610 | {"pop ds1", 0, 0, 0, 0 }, | |
| 1611 | {"or", MODRM, PARAM_RM8, PARAM_REG8, 0 }, | |
| 1612 | {"or", MODRM, PARAM_RM16, PARAM_REG16, 0 }, | |
| 1613 | {"or", MODRM, PARAM_REG8, PARAM_RM8, 0 }, | |
| 1614 | {"or", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1615 | {"or", 0, PARAM_AL, PARAM_UI8, 0 }, | |
| 1616 | {"or", 0, PARAM_AW, PARAM_IMM, 0 }, | |
| 1617 | {"push ps", 0, 0, 0, 0 }, | |
| 1618 | {"two_byte", TWO_BYTE, 0, 0, 0 }, | |
| 1619 | // 0x10 | |
| 1620 | {"addc", MODRM, PARAM_RM8, PARAM_REG8, 0 }, | |
| 1621 | {"addc", MODRM, PARAM_RM16, PARAM_REG16, 0 }, | |
| 1622 | {"addc", MODRM, PARAM_REG8, PARAM_RM8, 0 }, | |
| 1623 | {"addc", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1624 | {"addc", 0, PARAM_AL, PARAM_UI8, 0 }, | |
| 1625 | {"addc", 0, PARAM_AW, PARAM_IMM, 0 }, | |
| 1626 | {"push ss", 0, 0, 0, 0 }, | |
| 1627 | {"pop ss", 0, 0, 0, 0 }, | |
| 1628 | {"subc", MODRM, PARAM_RM8, PARAM_REG8, 0 }, | |
| 1629 | {"subc", MODRM, PARAM_RM16, PARAM_REG16, 0 }, | |
| 1630 | {"subc", MODRM, PARAM_REG8, PARAM_RM8, 0 }, | |
| 1631 | {"subc", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1632 | {"subc", 0, PARAM_AL, PARAM_UI8, 0 }, | |
| 1633 | {"subc", 0, PARAM_AW, PARAM_IMM, 0 }, | |
| 1634 | {"push ds0", 0, 0, 0, 0 }, | |
| 1635 | {"pop ds0", 0, 0, 0, 0 }, | |
| 1636 | // 0x20 | |
| 1637 | {"and", MODRM, PARAM_RM8, PARAM_REG8, 0 }, | |
| 1638 | {"and", MODRM, PARAM_RM16, PARAM_REG16, 0 }, | |
| 1639 | {"and", MODRM, PARAM_REG8, PARAM_RM8, 0 }, | |
| 1640 | {"and", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1641 | {"and", 0, PARAM_AL, PARAM_UI8, 0 }, | |
| 1642 | {"and", 0, PARAM_AW, PARAM_IMM, 0 }, | |
| 1643 | {"ds1:", SEG_DS1, 0, 0, 0 }, | |
| 1644 | {"adj4a", 0, 0, 0, 0 }, | |
| 1645 | {"sub", MODRM, PARAM_RM8, PARAM_REG8, 0 }, | |
| 1646 | {"sub", MODRM, PARAM_RM16, PARAM_REG16, 0 }, | |
| 1647 | {"sub", MODRM, PARAM_REG8, PARAM_RM8, 0 }, | |
| 1648 | {"sub", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1649 | {"sub", 0, PARAM_AL, PARAM_I8, 0 }, | |
| 1650 | {"sub", 0, PARAM_AW, PARAM_IMM, 0 }, | |
| 1651 | {"ps:", SEG_PS, 0, 0, 0 }, | |
| 1652 | {"adj4s", 0, 0, 0, 0 }, | |
| 1653 | // 0x30 | |
| 1654 | {"xor", MODRM, PARAM_RM8, PARAM_REG8, 0 }, | |
| 1655 | {"xor", MODRM, PARAM_RM16, PARAM_REG16, 0 }, | |
| 1656 | {"xor", MODRM, PARAM_REG8, PARAM_RM8, 0 }, | |
| 1657 | {"xor", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1658 | {"xor", 0, PARAM_AL, PARAM_UI8, 0 }, | |
| 1659 | {"xor", 0, PARAM_AW, PARAM_IMM, 0 }, | |
| 1660 | {"ss:", SEG_SS, 0, 0, 0 }, | |
| 1661 | {"adjba", 0, 0, 0, 0 }, | |
| 1662 | {"cmp", MODRM, PARAM_RM8, PARAM_REG8, 0 }, | |
| 1663 | {"cmp", MODRM, PARAM_RM16, PARAM_REG16, 0 }, | |
| 1664 | {"cmp", MODRM, PARAM_REG8, PARAM_RM8, 0 }, | |
| 1665 | {"cmp", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1666 | {"cmp", 0, PARAM_AL, PARAM_UI8, 0 }, | |
| 1667 | {"cmp", 0, PARAM_AW, PARAM_IMM, 0 }, | |
| 1668 | {"ds0:", SEG_DS0, 0, 0, 0 }, | |
| 1669 | {"adjbs", 0, 0, 0, 0 }, | |
| 1670 | // 0x40 | |
| 1671 | {"inc", 0, PARAM_AW, 0, 0 }, | |
| 1672 | {"inc", 0, PARAM_CW, 0, 0 }, | |
| 1673 | {"inc", 0, PARAM_DW, 0, 0 }, | |
| 1674 | {"inc", 0, PARAM_BW, 0, 0 }, | |
| 1675 | {"inc", 0, PARAM_SP, 0, 0 }, | |
| 1676 | {"inc", 0, PARAM_BP, 0, 0 }, | |
| 1677 | {"inc", 0, PARAM_IX, 0, 0 }, | |
| 1678 | {"inc", 0, PARAM_IY, 0, 0 }, | |
| 1679 | {"dec", 0, PARAM_AW, 0, 0 }, | |
| 1680 | {"dec", 0, PARAM_CW, 0, 0 }, | |
| 1681 | {"dec", 0, PARAM_DW, 0, 0 }, | |
| 1682 | {"dec", 0, PARAM_BW, 0, 0 }, | |
| 1683 | {"dec", 0, PARAM_SP, 0, 0 }, | |
| 1684 | {"dec", 0, PARAM_BP, 0, 0 }, | |
| 1685 | {"dec", 0, PARAM_IX, 0, 0 }, | |
| 1686 | {"dec", 0, PARAM_IY, 0, 0 }, | |
| 1687 | // 0x50 | |
| 1688 | {"push", 0, PARAM_AW, 0, 0 }, | |
| 1689 | {"push", 0, PARAM_CW, 0, 0 }, | |
| 1690 | {"push", 0, PARAM_DW, 0, 0 }, | |
| 1691 | {"push", 0, PARAM_BW, 0, 0 }, | |
| 1692 | {"push", 0, PARAM_SP, 0, 0 }, | |
| 1693 | {"push", 0, PARAM_BP, 0, 0 }, | |
| 1694 | {"push", 0, PARAM_IX, 0, 0 }, | |
| 1695 | {"push", 0, PARAM_IY, 0, 0 }, | |
| 1696 | {"pop", 0, PARAM_AW, 0, 0 }, | |
| 1697 | {"pop", 0, PARAM_CW, 0, 0 }, | |
| 1698 | {"pop", 0, PARAM_DW, 0, 0 }, | |
| 1699 | {"pop", 0, PARAM_BW, 0, 0 }, | |
| 1700 | {"pop", 0, PARAM_SP, 0, 0 }, | |
| 1701 | {"pop", 0, PARAM_BP, 0, 0 }, | |
| 1702 | {"pop", 0, PARAM_IX, 0, 0 }, | |
| 1703 | {"pop", 0, PARAM_IY, 0, 0 }, | |
| 1704 | // 0x60 | |
| 1705 | {"push r", 0, 0, 0, 0 }, | |
| 1706 | {"pop r", 0, 0, 0, 0 }, | |
| 1707 | {"chkind", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1708 | {"brkn", MODRM, PARAM_RM16, PARAM_REG16, 0 }, /* break into native */ | |
| 1709 | {"repnc", PREFIX, 0, 0, 0 }, | |
| 1710 | {"repc", PREFIX, 0, 0, 0 }, | |
| 1711 | {"fpo2 0", 0,/*OP_SIZE*/ 0, 0, 0 }, | |
| 1712 | {"fpo2 1", 0,/*ADDR_SIZE*/ 0, 0, 0 }, | |
| 1713 | {"push", 0, PARAM_IMM, 0, 0 }, | |
| 1714 | {"mul", MODRM, PARAM_REG16, PARAM_RM16, PARAM_IMM }, | |
| 1715 | {"push", 0, PARAM_I8, 0, 0 }, | |
| 1716 | {"mul", MODRM, PARAM_REG16, PARAM_RM16, PARAM_I8 }, | |
| 1717 | {"inmb", 0, 0, 0, 0 }, | |
| 1718 | {"inmw", 0, 0, 0, 0 }, | |
| 1719 | {"outmb", 0, 0, 0, 0 }, | |
| 1720 | {"outmw", 0, 0, 0, 0 }, | |
| 1721 | // 0x70 | |
| 1722 | {"bv", 0, PARAM_REL8, 0, 0 }, | |
| 1723 | {"bnv", 0, PARAM_REL8, 0, 0 }, | |
| 1724 | {"bc", 0, PARAM_REL8, 0, 0 }, | |
| 1725 | {"bnc", 0, PARAM_REL8, 0, 0 }, | |
| 1726 | {"be", 0, PARAM_REL8, 0, 0 }, | |
| 1727 | {"bne", 0, PARAM_REL8, 0, 0 }, | |
| 1728 | {"bnh", 0, PARAM_REL8, 0, 0 }, | |
| 1729 | {"bh", 0, PARAM_REL8, 0, 0 }, | |
| 1730 | {"bn", 0, PARAM_REL8, 0, 0 }, | |
| 1731 | {"bp", 0, PARAM_REL8, 0, 0 }, | |
| 1732 | {"bpe", 0, PARAM_REL8, 0, 0 }, | |
| 1733 | {"bpo", 0, PARAM_REL8, 0, 0 }, | |
| 1734 | {"blt", 0, PARAM_REL8, 0, 0 }, | |
| 1735 | {"bge", 0, PARAM_REL8, 0, 0 }, | |
| 1736 | {"ble", 0, PARAM_REL8, 0, 0 }, | |
| 1737 | {"bgt", 0, PARAM_REL8, 0, 0 }, | |
| 1738 | // 0x80 | |
| 1739 | {"immb", GROUP, 0, 0, 0 }, | |
| 1740 | {"immw", GROUP, 0, 0, 0 }, | |
| 1741 | {"immb", GROUP, 0, 0, 0 }, | |
| 1742 | {"immws", GROUP, 0, 0, 0 }, | |
| 1743 | {"test", MODRM, PARAM_RM8, PARAM_REG8, 0 }, | |
| 1744 | {"test", MODRM, PARAM_RM16, PARAM_REG16, 0 }, | |
| 1745 | {"xch", MODRM, PARAM_REG8, PARAM_RM8, 0 }, | |
| 1746 | {"xch", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1747 | {"mov", MODRM, PARAM_RM8, PARAM_REG8, 0 }, | |
| 1748 | {"mov", MODRM, PARAM_RM16, PARAM_REG16, 0 }, | |
| 1749 | {"mov", MODRM, PARAM_REG8, PARAM_RM8, 0 }, | |
| 1750 | {"mov", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1751 | {"mov", MODRM, PARAM_RM16, PARAM_SREG, 0 }, | |
| 1752 | {"ldea", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1753 | {"mov", MODRM, PARAM_SREG, PARAM_RM16, 0 }, | |
| 1754 | {"pop", MODRM, PARAM_RM16, 0, 0 }, | |
| 1755 | // 0x90 | |
| 1756 | {"nop", 0, 0, 0, 0 }, | |
| 1757 | {"xch", 0, PARAM_AW, PARAM_CW, 0 }, | |
| 1758 | {"xch", 0, PARAM_AW, PARAM_DW, 0 }, | |
| 1759 | {"xch", 0, PARAM_AW, PARAM_BW, 0 }, | |
| 1760 | {"xch", 0, PARAM_AW, PARAM_SP, 0 }, | |
| 1761 | {"xch", 0, PARAM_AW, PARAM_BP, 0 }, | |
| 1762 | {"xch", 0, PARAM_AW, PARAM_IX, 0 }, | |
| 1763 | {"xch", 0, PARAM_AW, PARAM_IY, 0 }, | |
| 1764 | {"cvtbw", 0, 0, 0, 0 }, | |
| 1765 | {"cvtwl", 0, 0, 0, 0 }, | |
| 1766 | {"call", 0, PARAM_ADDR, 0, 0, DASMFLAG_STEP_OVER}, | |
| 1767 | {"poll", 0, 0, 0, 0 }, | |
| 1768 | {"push psw", 0, 0, 0, 0 }, | |
| 1769 | {"pop psw", 0, 0, 0, 0 }, | |
| 1770 | {"mov psw,ah", 0, 0, 0, 0 }, | |
| 1771 | {"mov ah,psw", 0, 0, 0, 0 }, | |
| 1772 | // 0xa0 | |
| 1773 | {"mov", 0, PARAM_AL, PARAM_MEM_OFFS_W, 0 }, | |
| 1774 | {"mov", 0, PARAM_AW, PARAM_MEM_OFFS_W, 0 }, | |
| 1775 | {"mov", 0, PARAM_MEM_OFFS_W, PARAM_AL, 0 }, | |
| 1776 | {"mov", 0, PARAM_MEM_OFFS_W, PARAM_AW, 0 }, | |
| 1777 | {"movbkb", 0, 0, 0, 0 }, | |
| 1778 | {"movbkw", 0, 0, 0, 0 }, | |
| 1779 | {"cmpbkb", 0, 0, 0, 0 }, | |
| 1780 | {"cmpbkw", 0, 0, 0, 0 }, | |
| 1781 | {"test", 0, PARAM_AL, PARAM_UI8, 0 }, | |
| 1782 | {"test", 0, PARAM_AW, PARAM_IMM, 0 }, | |
| 1783 | {"stmb", 0, 0, 0, 0 }, | |
| 1784 | {"stmw", 0, 0, 0, 0 }, | |
| 1785 | {"ldmb", 0, 0, 0, 0 }, | |
| 1786 | {"ldmw", 0, 0, 0, 0 }, | |
| 1787 | {"cmpmb", 0, 0, 0, 0 }, | |
| 1788 | {"cmpmw", 0, 0, 0, 0 }, | |
| 1789 | // 0xb0 | |
| 1790 | {"mov", 0, PARAM_AL, PARAM_UI8, 0 }, | |
| 1791 | {"mov", 0, PARAM_CL, PARAM_UI8, 0 }, | |
| 1792 | {"mov", 0, PARAM_DL, PARAM_UI8, 0 }, | |
| 1793 | {"mov", 0, PARAM_BL, PARAM_UI8, 0 }, | |
| 1794 | {"mov", 0, PARAM_AH, PARAM_UI8, 0 }, | |
| 1795 | {"mov", 0, PARAM_CH, PARAM_UI8, 0 }, | |
| 1796 | {"mov", 0, PARAM_DH, PARAM_UI8, 0 }, | |
| 1797 | {"mov", 0, PARAM_BH, PARAM_UI8, 0 }, | |
| 1798 | {"mov", 0, PARAM_AW, PARAM_IMM, 0 }, | |
| 1799 | {"mov", 0, PARAM_CW, PARAM_IMM, 0 }, | |
| 1800 | {"mov", 0, PARAM_DW, PARAM_IMM, 0 }, | |
| 1801 | {"mov", 0, PARAM_BW, PARAM_IMM, 0 }, | |
| 1802 | {"mov", 0, PARAM_SP, PARAM_IMM, 0 }, | |
| 1803 | {"mov", 0, PARAM_BP, PARAM_IMM, 0 }, | |
| 1804 | {"mov", 0, PARAM_IX, PARAM_IMM, 0 }, | |
| 1805 | {"mov", 0, PARAM_IY, PARAM_IMM, 0 }, | |
| 1806 | // 0xc0 | |
| 1807 | {"shiftbi", GROUP, 0, 0, 0 }, | |
| 1808 | {"shiftwi", GROUP, 0, 0, 0 }, | |
| 1809 | {"ret", 0, PARAM_I16, 0, 0, DASMFLAG_STEP_OUT}, | |
| 1810 | {"ret", 0, 0, 0, 0, DASMFLAG_STEP_OUT}, | |
| 1811 | {"mov ds1,", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1812 | {"mov ds0,", MODRM, PARAM_REG16, PARAM_RM16, 0 }, | |
| 1813 | {"mov", MODRM, PARAM_RM8, PARAM_UI8, 0 }, | |
| 1814 | {"mov", MODRM, PARAM_RM16, PARAM_IMM, 0 }, | |
| 1815 | {"prepare", 0, PARAM_I16, PARAM_UI8, 0 }, | |
| 1816 | {"dispose", 0, 0, 0, 0 }, | |
| 1817 | {"retf", 0, PARAM_I16, 0, 0, DASMFLAG_STEP_OUT}, | |
| 1818 | {"retf", 0, 0, 0, 0, DASMFLAG_STEP_OUT}, | |
| 1819 | {"brk 3", 0, 0, 0, 0, DASMFLAG_STEP_OVER}, | |
| 1820 | {"brk", 0, PARAM_UI8, 0, 0, DASMFLAG_STEP_OVER}, | |
| 1821 | {"brkv", 0, 0, 0, 0 }, | |
| 1822 | {"reti", 0, 0, 0, 0, DASMFLAG_STEP_OUT}, | |
| 1823 | // 0xd0 | |
| 1824 | {"shiftb", GROUP, 0, 0, 0 }, | |
| 1825 | {"shiftw", GROUP, 0, 0, 0 }, | |
| 1826 | {"shiftbv", GROUP, 0, 0, 0 }, | |
| 1827 | {"shiftwv", GROUP, 0, 0, 0 }, | |
| 1828 | {"cvtbd", 0, PARAM_I8, 0, 0 }, | |
| 1829 | {"cvtdb", 0, PARAM_I8, 0, 0 }, | |
| 1830 | {"???", 0, 0, 0, 0 }, | |
| 1831 | {"trans", 0, 0, 0, 0 }, | |
| 1832 | {"escape", FPU, 0, 0, 0 }, | |
| 1833 | {"escape", FPU, 0, 0, 0 }, | |
| 1834 | {"escape", FPU, 0, 0, 0 }, | |
| 1835 | {"escape", FPU, 0, 0, 0 }, | |
| 1836 | {"escape", FPU, 0, 0, 0 }, | |
| 1837 | {"escape", FPU, 0, 0, 0 }, | |
| 1838 | {"escape", FPU, 0, 0, 0 }, | |
| 1839 | {"escape", FPU, 0, 0, 0 }, | |
| 1840 | // 0xe0 | |
| 1841 | {"dbnzne", 0, PARAM_REL8, 0, 0, DASMFLAG_STEP_OVER}, | |
| 1842 | {"dbnze", 0, PARAM_REL8, 0, 0, DASMFLAG_STEP_OVER}, | |
| 1843 | {"dbnz", 0, PARAM_REL8, 0, 0, DASMFLAG_STEP_OVER}, | |
| 1844 | {"bcwz", 0, PARAM_REL8, 0, 0 }, | |
| 1845 | {"in", 0, PARAM_AL, PARAM_UI8, 0 }, | |
| 1846 | {"in", 0, PARAM_AW, PARAM_UI8, 0 }, | |
| 1847 | {"out", 0, PARAM_UI8, PARAM_AL, 0 }, | |
| 1848 | {"out", 0, PARAM_UI8, PARAM_AW, 0 }, | |
| 1849 | {"call", 0, PARAM_REL16, 0, 0, DASMFLAG_STEP_OVER}, | |
| 1850 | {"br", 0, PARAM_REL16, 0, 0 }, | |
| 1851 | {"br", 0, PARAM_ADDR, 0, 0 }, | |
| 1852 | {"br", 0, PARAM_REL8, 0, 0 }, | |
| 1853 | {"in", 0, PARAM_AL, PARAM_DW, 0 }, | |
| 1854 | {"in", 0, PARAM_AW, PARAM_DW, 0 }, | |
| 1855 | {"out", 0, PARAM_DW, PARAM_AL, 0 }, | |
| 1856 | {"out", 0, PARAM_DW, PARAM_AW, 0 }, | |
| 1857 | // 0xf0 | |
| 1858 | {"buslock", PREFIX, 0, 0, 0 }, | |
| 1859 | {"brks", 0, 0, 0, 0 }, /* break into secure mode */ | |
| 1860 | {"repne", PREFIX, 0, 0, 0 }, | |
| 1861 | {"rep", PREFIX, 0, 0, 0 }, | |
| 1862 | {"halt", 0, 0, 0, 0 }, | |
| 1863 | {"not1 cy", 0, 0, 0, 0 }, | |
| 1864 | {"group1b", GROUP, 0, 0, 0 }, | |
| 1865 | {"group1w", GROUP, 0, 0, 0 }, | |
| 1866 | {"clr1 cy", 0, 0, 0, 0 }, | |
| 1867 | {"set1 cy", 0, 0, 0, 0 }, | |
| 1868 | {"di", 0, 0, 0, 0 }, | |
| 1869 | {"ei", 0, 0, 0, 0 }, | |
| 1870 | {"clr1 dir", 0, 0, 0, 0 }, | |
| 1871 | {"set1 dir", 0, 0, 0, 0 }, | |
| 1872 | {"group2b", GROUP, 0, 0, 0 }, | |
| 1873 | {"group2w", GROUP, 0, 0, 0 } | |
| 1874 | }; | |
| 1875 | ||
| 1876 | static const I386_OPCODE necv_opcode_table2[256] = | |
| 1877 | { | |
| 1878 | // 0x00 | |
| 1879 | {"???", 0, 0, 0, 0 }, | |
| 1880 | {"???", 0, 0, 0, 0 }, | |
| 1881 | {"???", 0, 0, 0, 0 }, | |
| 1882 | {"???", 0, 0, 0, 0 }, | |
| 1883 | {"???", 0, 0, 0, 0 }, | |
| 1884 | {"???", 0, 0, 0, 0 }, | |
| 1885 | {"???", 0, 0, 0, 0 }, | |
| 1886 | {"???", 0, 0, 0, 0 }, | |
| 1887 | {"???", 0, 0, 0, 0 }, | |
| 1888 | {"???", 0, 0, 0, 0 }, | |
| 1889 | {"???", 0, 0, 0, 0 }, | |
| 1890 | {"???", 0, 0, 0, 0 }, | |
| 1891 | {"???", 0, 0, 0, 0 }, | |
| 1892 | {"???", 0, 0, 0, 0 }, | |
| 1893 | {"???", 0, 0, 0, 0 }, | |
| 1894 | {"???", 0, 0, 0, 0 }, | |
| 1895 | // 0x10 - NEC V series only | |
| 1896 | {"test1", MODRM, PARAM_RM8, PARAM_1, 0 }, | |
| 1897 | {"test1", MODRM, PARAM_RM16, PARAM_1, 0 }, | |
| 1898 | {"clr1", MODRM, PARAM_RM8, PARAM_1, 0 }, | |
| 1899 | {"clr1", MODRM, PARAM_RM16, PARAM_1, 0 }, | |
| 1900 | {"set1", MODRM, PARAM_RM8, PARAM_1, 0 }, | |
| 1901 | {"set1", MODRM, PARAM_RM16, PARAM_1, 0 }, | |
| 1902 | {"not1", MODRM, PARAM_RM8, PARAM_1, 0 }, | |
| 1903 | {"not1", MODRM, PARAM_RM16, PARAM_1, 0 }, | |
| 1904 | {"test1", MODRM, PARAM_RM8, PARAM_I8, 0 }, | |
| 1905 | {"test1", MODRM, PARAM_RM16, PARAM_I8, 0 }, | |
| 1906 | {"clr1", MODRM, PARAM_RM8, PARAM_I8, 0 }, | |
| 1907 | {"clr1", MODRM, PARAM_RM16, PARAM_I8, 0 }, | |
| 1908 | {"set1", MODRM, PARAM_RM8, PARAM_I8, 0 }, | |
| 1909 | {"set1", MODRM, PARAM_RM16, PARAM_I8, 0 }, | |
| 1910 | {"not1", MODRM, PARAM_RM8, PARAM_I8, 0 }, | |
| 1911 | {"not1", MODRM, PARAM_RM16, PARAM_I8, 0 }, | |
| 1912 | // 0x20 | |
| 1913 | {"add4s", 0, 0, 0, 0 }, | |
| 1914 | {"???", 0, 0, 0, 0 }, | |
| 1915 | {"sub4s", 0, 0, 0, 0 }, | |
| 1916 | {"???", 0, 0, 0, 0 }, | |
| 1917 | {"???", 0, 0, 0, 0 }, | |
| 1918 | {"movspa", 0, 0, 0, 0 }, /* V25/35 only */ | |
| 1919 | {"cmp4s", 0, 0, 0, 0 }, | |
| 1920 | {"???", 0, 0, 0, 0 }, | |
| 1921 | {"rol4", MODRM, PARAM_RM8, 0, 0 }, | |
| 1922 | {"???", 0, 0, 0, 0 }, | |
| 1923 | {"ror4", MODRM, PARAM_RM8, 0, 0 }, | |
| 1924 | {"???", 0, 0, 0, 0 }, | |
| 1925 | {"???", 0, 0, 0, 0 }, | |
| 1926 | {"brkcs", MODRM, PARAM_REG2_8, 0, 0 }, /* V25/35 only */ | |
| 1927 | {"???", 0, 0, 0, 0 }, | |
| 1928 | {"???", 0, 0, 0, 0 }, | |
| 1929 | // 0x30 | |
| 1930 | {"???", 0, 0, 0, 0 }, | |
| 1931 | {"ins", MODRM, PARAM_REG2_8, PARAM_REG8, 0 }, | |
| 1932 | {"???", 0, 0, 0, 0 }, | |
| 1933 | {"ext", MODRM, PARAM_REG2_8, PARAM_REG8, 0 }, | |
| 1934 | {"???", 0, 0, 0, 0 }, | |
| 1935 | {"???", 0, 0, 0, 0 }, | |
| 1936 | {"???", 0, 0, 0, 0 }, | |
| 1937 | {"???", 0, 0, 0, 0 }, | |
| 1938 | {"???", 0, 0, 0, 0 }, | |
| 1939 | {"ins", MODRM, PARAM_REG2_8, PARAM_I4, 0 }, | |
| 1940 | {"???", 0, 0, 0, 0 }, | |
| 1941 | {"ext", MODRM, PARAM_REG2_8, PARAM_I4, 0 }, | |
| 1942 | {"???", 0, 0, 0, 0 }, | |
| 1943 | {"???", 0, 0, 0, 0 }, | |
| 1944 | {"???", 0, 0, 0, 0 }, | |
| 1945 | {"???", 0, 0, 0, 0 }, | |
| 1946 | // 0x40 | |
| 1947 | {"???", 0, 0, 0, 0 }, | |
| 1948 | {"???", 0, 0, 0, 0 }, | |
| 1949 | {"???", 0, 0, 0, 0 }, | |
| 1950 | {"???", 0, 0, 0, 0 }, | |
| 1951 | {"???", 0, 0, 0, 0 }, | |
| 1952 | {"???", 0, 0, 0, 0 }, | |
| 1953 | {"???", 0, 0, 0, 0 }, | |
| 1954 | {"???", 0, 0, 0, 0 }, | |
| 1955 | {"???", 0, 0, 0, 0 }, | |
| 1956 | {"???", 0, 0, 0, 0 }, | |
| 1957 | {"???", 0, 0, 0, 0 }, | |
| 1958 | {"???", 0, 0, 0, 0 }, | |
| 1959 | {"???", 0, 0, 0, 0 }, | |
| 1960 | {"???", 0, 0, 0, 0 }, | |
| 1961 | {"???", 0, 0, 0, 0 }, | |
| 1962 | {"???", 0, 0, 0, 0 }, | |
| 1963 | // 0x50 | |
| 1964 | {"???", 0, 0, 0, 0 }, | |
| 1965 | {"???", 0, 0, 0, 0 }, | |
| 1966 | {"???", 0, 0, 0, 0 }, | |
| 1967 | {"???", 0, 0, 0, 0 }, | |
| 1968 | {"???", 0, 0, 0, 0 }, | |
| 1969 | {"???", 0, 0, 0, 0 }, | |
| 1970 | {"???", 0, 0, 0, 0 }, | |
| 1971 | {"???", 0, 0, 0, 0 }, | |
| 1972 | {"???", 0, 0, 0, 0 }, | |
| 1973 | {"???", 0, 0, 0, 0 }, | |
| 1974 | {"???", 0, 0, 0, 0 }, | |
| 1975 | {"???", 0, 0, 0, 0 }, | |
| 1976 | {"???", 0, 0, 0, 0 }, | |
| 1977 | {"???", 0, 0, 0, 0 }, | |
| 1978 | {"???", 0, 0, 0, 0 }, | |
| 1979 | {"???", 0, 0, 0, 0 }, | |
| 1980 | // 0x60 | |
| 1981 | {"???", 0, 0, 0, 0 }, | |
| 1982 | {"???", 0, 0, 0, 0 }, | |
| 1983 | {"???", 0, 0, 0, 0 }, | |
| 1984 | {"???", 0, 0, 0, 0 }, | |
| 1985 | {"???", 0, 0, 0, 0 }, | |
| 1986 | {"???", 0, 0, 0, 0 }, | |
| 1987 | {"???", 0, 0, 0, 0 }, | |
| 1988 | {"???", 0, 0, 0, 0 }, | |
| 1989 | {"???", 0, 0, 0, 0 }, | |
| 1990 | {"???", 0, 0, 0, 0 }, | |
| 1991 | {"???", 0, 0, 0, 0 }, | |
| 1992 | {"???", 0, 0, 0, 0 }, | |
| 1993 | {"???", 0, 0, 0, 0 }, | |
| 1994 | {"???", 0, 0, 0, 0 }, | |
| 1995 | {"???", 0, 0, 0, 0 }, | |
| 1996 | {"???", 0, 0, 0, 0 }, | |
| 1997 | // 0x70 | |
| 1998 | {"???", 0, 0, 0, 0 }, | |
| 1999 | {"???", 0, 0, 0, 0 }, | |
| 2000 | {"???", 0, 0, 0, 0 }, | |
| 2001 | {"???", 0, 0, 0, 0 }, | |
| 2002 | {"???", 0, 0, 0, 0 }, | |
| 2003 | {"???", 0, 0, 0, 0 }, | |
| 2004 | {"???", 0, 0, 0, 0 }, | |
| 2005 | {"???", 0, 0, 0, 0 }, | |
| 2006 | {"???", 0, 0, 0, 0 }, | |
| 2007 | {"???", 0, 0, 0, 0 }, | |
| 2008 | {"???", 0, 0, 0, 0 }, | |
| 2009 | {"???", 0, 0, 0, 0 }, | |
| 2010 | {"???", 0, 0, 0, 0 }, | |
| 2011 | {"???", 0, 0, 0, 0 }, | |
| 2012 | {"???", 0, 0, 0, 0 }, | |
| 2013 | {"???", 0, 0, 0, 0 }, | |
| 2014 | // 0x80 | |
| 2015 | {"???", 0, 0, 0, 0 }, | |
| 2016 | {"???", 0, 0, 0, 0 }, | |
| 2017 | {"???", 0, 0, 0, 0 }, | |
| 2018 | {"???", 0, 0, 0, 0 }, | |
| 2019 | {"???", 0, 0, 0, 0 }, | |
| 2020 | {"???", 0, 0, 0, 0 }, | |
| 2021 | {"???", 0, 0, 0, 0 }, | |
| 2022 | {"???", 0, 0, 0, 0 }, | |
| 2023 | {"???", 0, 0, 0, 0 }, | |
| 2024 | {"???", 0, 0, 0, 0 }, | |
| 2025 | {"???", 0, 0, 0, 0 }, | |
| 2026 | {"???", 0, 0, 0, 0 }, | |
| 2027 | {"???", 0, 0, 0, 0 }, | |
| 2028 | {"???", 0, 0, 0, 0 }, | |
| 2029 | {"???", 0, 0, 0, 0 }, | |
| 2030 | {"???", 0, 0, 0, 0 }, | |
| 2031 | // 0x90 | |
| 2032 | {"???", 0, 0, 0, 0 }, | |
| 2033 | {"retrbi", 0, 0, 0, 0 }, /* V25/35 only */ | |
| 2034 | {"fint", 0, 0, 0, 0 }, /* V25/35 only */ | |
| 2035 | {"???", 0, 0, 0, 0 }, | |
| 2036 | {"tsksw", MODRM, PARAM_REG2_8, 0, 0 }, /* V25/35 only */ | |
| 2037 | {"movspb", 0, PARAM_RBANK, 0, 0 }, /* V25/35 only */ | |
| 2038 | {"???", 0, 0, 0, 0 }, | |
| 2039 | {"???", 0, 0, 0, 0 }, | |
| 2040 | {"???", 0, 0, 0, 0 }, | |
| 2041 | {"???", 0, 0, 0, 0 }, | |
| 2042 | {"???", 0, 0, 0, 0 }, | |
| 2043 | {"???", 0, 0, 0, 0 }, | |
| 2044 | {"btclr", MODRM, PARAM_REG2_8, PARAM_I8, PARAM_REL8 }, /* V25/35 only */ | |
| 2045 | {"???", 0, 0, 0, 0 }, | |
| 2046 | {"stop", 0, 0, 0, 0 }, /* V25/35 only */ | |
| 2047 | {"???", 0, 0, 0, 0 }, | |
| 2048 | // 0xa0 | |
| 2049 | {"???", 0, 0, 0, 0 }, | |
| 2050 | {"???", 0, 0, 0, 0 }, | |
| 2051 | {"???", 0, 0, 0, 0 }, | |
| 2052 | {"???", 0, 0, 0, 0 }, | |
| 2053 | {"???", 0, 0, 0, 0 }, | |
| 2054 | {"???", 0, 0, 0, 0 }, | |
| 2055 | {"???", 0, 0, 0, 0 }, | |
| 2056 | {"???", 0, 0, 0, 0 }, | |
| 2057 | {"???", 0, 0, 0, 0 }, | |
| 2058 | {"???", 0, 0, 0, 0 }, | |
| 2059 | {"???", 0, 0, 0, 0 }, | |
| 2060 | {"???", 0, 0, 0, 0 }, | |
| 2061 | {"???", 0, 0, 0, 0 }, | |
| 2062 | {"???", 0, 0, 0, 0 }, | |
| 2063 | {"???", 0, 0, 0, 0 }, | |
| 2064 | {"???", 0, 0, 0, 0 }, | |
| 2065 | // 0xb0 | |
| 2066 | {"???", 0, 0, 0, 0 }, | |
| 2067 | {"???", 0, 0, 0, 0 }, | |
| 2068 | {"???", 0, 0, 0, 0 }, | |
| 2069 | {"???", 0, 0, 0, 0 }, | |
| 2070 | {"???", 0, 0, 0, 0 }, | |
| 2071 | {"???", 0, 0, 0, 0 }, | |
| 2072 | {"???", 0, 0, 0, 0 }, | |
| 2073 | {"???", 0, 0, 0, 0 }, | |
| 2074 | {"???", 0, 0, 0, 0 }, | |
| 2075 | {"???", 0, 0, 0, 0 }, | |
| 2076 | {"???", 0, 0, 0, 0 }, | |
| 2077 | {"???", 0, 0, 0, 0 }, | |
| 2078 | {"???", 0, 0, 0, 0 }, | |
| 2079 | {"???", 0, 0, 0, 0 }, | |
| 2080 | {"???", 0, 0, 0, 0 }, | |
| 2081 | {"???", 0, 0, 0, 0 }, | |
| 2082 | // 0xc0 | |
| 2083 | {"???", 0, 0, 0, 0 }, | |
| 2084 | {"???", 0, 0, 0, 0 }, | |
| 2085 | {"???", 0, 0, 0, 0 }, | |
| 2086 | {"???", 0, 0, 0, 0 }, | |
| 2087 | {"???", 0, 0, 0, 0 }, | |
| 2088 | {"???", 0, 0, 0, 0 }, | |
| 2089 | {"???", 0, 0, 0, 0 }, | |
| 2090 | {"???", 0, 0, 0, 0 }, | |
| 2091 | {"???", 0, 0, 0, 0 }, | |
| 2092 | {"???", 0, 0, 0, 0 }, | |
| 2093 | {"???", 0, 0, 0, 0 }, | |
| 2094 | {"???", 0, 0, 0, 0 }, | |
| 2095 | {"???", 0, 0, 0, 0 }, | |
| 2096 | {"???", 0, 0, 0, 0 }, | |
| 2097 | {"???", 0, 0, 0, 0 }, | |
| 2098 | {"???", 0, 0, 0, 0 }, | |
| 2099 | // 0xd0 | |
| 2100 | {"???", 0, 0, 0, 0 }, | |
| 2101 | {"???", 0, 0, 0, 0 }, | |
| 2102 | {"???", 0, 0, 0, 0 }, | |
| 2103 | {"???", 0, 0, 0, 0 }, | |
| 2104 | {"???", 0, 0, 0, 0 }, | |
| 2105 | {"???", 0, 0, 0, 0 }, | |
| 2106 | {"???", 0, 0, 0, 0 }, | |
| 2107 | {"???", 0, 0, 0, 0 }, | |
| 2108 | {"???", 0, 0, 0, 0 }, | |
| 2109 | {"???", 0, 0, 0, 0 }, | |
| 2110 | {"???", 0, 0, 0, 0 }, | |
| 2111 | {"???", 0, 0, 0, 0 }, | |
| 2112 | {"???", 0, 0, 0, 0 }, | |
| 2113 | {"???", 0, 0, 0, 0 }, | |
| 2114 | {"???", 0, 0, 0, 0 }, | |
| 2115 | {"???", 0, 0, 0, 0 }, | |
| 2116 | // 0xe0 | |
| 2117 | {"brkxa", 0, PARAM_UI8, 0, 0 }, /* V33,53 only */ | |
| 2118 | {"???", 0, 0, 0, 0 }, | |
| 2119 | {"???", 0, 0, 0, 0 }, | |
| 2120 | {"???", 0, 0, 0, 0 }, | |
| 2121 | {"???", 0, 0, 0, 0 }, | |
| 2122 | {"???", 0, 0, 0, 0 }, | |
| 2123 | {"???", 0, 0, 0, 0 }, | |
| 2124 | {"???", 0, 0, 0, 0 }, | |
| 2125 | {"???", 0, 0, 0, 0 }, | |
| 2126 | {"???", 0, 0, 0, 0 }, | |
| 2127 | {"???", 0, 0, 0, 0 }, | |
| 2128 | {"???", 0, 0, 0, 0 }, | |
| 2129 | {"???", 0, 0, 0, 0 }, | |
| 2130 | {"???", 0, 0, 0, 0 }, | |
| 2131 | {"???", 0, 0, 0, 0 }, | |
| 2132 | {"???", 0, 0, 0, 0 }, | |
| 2133 | // 0xf0 | |
| 2134 | {"retxa", 0, PARAM_UI8, 0, 0 }, /* V33,53 only */ | |
| 2135 | {"???", 0, 0, 0, 0 }, | |
| 2136 | {"???", 0, 0, 0, 0 }, | |
| 2137 | {"???", 0, 0, 0, 0 }, | |
| 2138 | {"???", 0, 0, 0, 0 }, | |
| 2139 | {"???", 0, 0, 0, 0 }, | |
| 2140 | {"???", 0, 0, 0, 0 }, | |
| 2141 | {"???", 0, 0, 0, 0 }, | |
| 2142 | {"???", 0, 0, 0, 0 }, | |
| 2143 | {"???", 0, 0, 0, 0 }, | |
| 2144 | {"???", 0, 0, 0, 0 }, | |
| 2145 | {"???", 0, 0, 0, 0 }, | |
| 2146 | {"???", 0, 0, 0, 0 }, | |
| 2147 | {"???", 0, 0, 0, 0 }, | |
| 2148 | {"???", 0, 0, 0, 0 }, | |
| 2149 | {"brkem", 0, PARAM_UI8, 0, 0 } /* V20,30,40,50 only */ | |
| 2150 | }; | |
| 2151 | ||
| 2152 | static const I386_OPCODE immb_table[8] = | |
| 2153 | { | |
| 2154 | {"add", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2155 | {"or", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2156 | {"addc", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2157 | {"subc", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2158 | {"and", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2159 | {"sub", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2160 | {"xor", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2161 | {"cmp", 0, PARAM_RM8, PARAM_I8, 0 } | |
| 2162 | }; | |
| 2163 | ||
| 2164 | static const I386_OPCODE immw_table[8] = | |
| 2165 | { | |
| 2166 | {"add", 0, PARAM_RM16, PARAM_IMM, 0 }, | |
| 2167 | {"or", 0, PARAM_RM16, PARAM_IMM, 0 }, | |
| 2168 | {"addc", 0, PARAM_RM16, PARAM_IMM, 0 }, | |
| 2169 | {"subc", 0, PARAM_RM16, PARAM_IMM, 0 }, | |
| 2170 | {"and", 0, PARAM_RM16, PARAM_IMM, 0 }, | |
| 2171 | {"sub", 0, PARAM_RM16, PARAM_IMM, 0 }, | |
| 2172 | {"xor", 0, PARAM_RM16, PARAM_IMM, 0 }, | |
| 2173 | {"cmp", 0, PARAM_RM16, PARAM_IMM, 0 } | |
| 2174 | }; | |
| 2175 | ||
| 2176 | static const I386_OPCODE immws_table[8] = | |
| 2177 | { | |
| 2178 | {"add", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2179 | {"or", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2180 | {"addc", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2181 | {"subc", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2182 | {"and", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2183 | {"sub", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2184 | {"xor", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2185 | {"cmp", 0, PARAM_RM16, PARAM_I8, 0 } | |
| 2186 | }; | |
| 2187 | ||
| 2188 | static const I386_OPCODE shiftbi_table[8] = | |
| 2189 | { | |
| 2190 | {"rol", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2191 | {"ror", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2192 | {"rolc", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2193 | {"rorc", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2194 | {"shl", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2195 | {"shr", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2196 | {"???", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2197 | {"shra", 0, PARAM_RM8, PARAM_I8, 0 } | |
| 2198 | }; | |
| 2199 | ||
| 2200 | static const I386_OPCODE shiftwi_table[8] = | |
| 2201 | { | |
| 2202 | {"rol", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2203 | {"ror", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2204 | {"rolc", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2205 | {"rorc", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2206 | {"shl", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2207 | {"shr", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2208 | {"???", 0, PARAM_RM16, PARAM_I8, 0 }, | |
| 2209 | {"shra", 0, PARAM_RM16, PARAM_I8, 0 } | |
| 2210 | }; | |
| 2211 | ||
| 2212 | static const I386_OPCODE shiftb_table[8] = | |
| 2213 | { | |
| 2214 | {"rol", 0, PARAM_RM8, PARAM_1, 0 }, | |
| 2215 | {"ror", 0, PARAM_RM8, PARAM_1, 0 }, | |
| 2216 | {"rolc", 0, PARAM_RM8, PARAM_1, 0 }, | |
| 2217 | {"rorc", 0, PARAM_RM8, PARAM_1, 0 }, | |
| 2218 | {"shl", 0, PARAM_RM8, PARAM_1, 0 }, | |
| 2219 | {"shr", 0, PARAM_RM8, PARAM_1, 0 }, | |
| 2220 | {"???", 0, PARAM_RM8, PARAM_1, 0 }, | |
| 2221 | {"shra", 0, PARAM_RM8, PARAM_1, 0 } | |
| 2222 | }; | |
| 2223 | ||
| 2224 | static const I386_OPCODE shiftw_table[8] = | |
| 2225 | { | |
| 2226 | {"rol", 0, PARAM_RM16, PARAM_1, 0 }, | |
| 2227 | {"ror", 0, PARAM_RM16, PARAM_1, 0 }, | |
| 2228 | {"rolc", 0, PARAM_RM16, PARAM_1, 0 }, | |
| 2229 | {"rorc", 0, PARAM_RM16, PARAM_1, 0 }, | |
| 2230 | {"shl", 0, PARAM_RM16, PARAM_1, 0 }, | |
| 2231 | {"shr", 0, PARAM_RM16, PARAM_1, 0 }, | |
| 2232 | {"???", 0, PARAM_RM16, PARAM_1, 0 }, | |
| 2233 | {"shra", 0, PARAM_RM16, PARAM_1, 0 } | |
| 2234 | }; | |
| 2235 | ||
| 2236 | static const I386_OPCODE shiftbv_table[8] = | |
| 2237 | { | |
| 2238 | {"rol", 0, PARAM_RM8, PARAM_CL, 0 }, | |
| 2239 | {"ror", 0, PARAM_RM8, PARAM_CL, 0 }, | |
| 2240 | {"rolc", 0, PARAM_RM8, PARAM_CL, 0 }, | |
| 2241 | {"rorc", 0, PARAM_RM8, PARAM_CL, 0 }, | |
| 2242 | {"shl", 0, PARAM_RM8, PARAM_CL, 0 }, | |
| 2243 | {"shr", 0, PARAM_RM8, PARAM_CL, 0 }, | |
| 2244 | {"???", 0, PARAM_RM8, PARAM_CL, 0 }, | |
| 2245 | {"shra", 0, PARAM_RM8, PARAM_CL, 0 } | |
| 2246 | }; | |
| 2247 | ||
| 2248 | static const I386_OPCODE shiftwv_table[8] = | |
| 2249 | { | |
| 2250 | {"rol", 0, PARAM_RM16, PARAM_CL, 0 }, | |
| 2251 | {"ror", 0, PARAM_RM16, PARAM_CL, 0 }, | |
| 2252 | {"rolc", 0, PARAM_RM16, PARAM_CL, 0 }, | |
| 2253 | {"rorc", 0, PARAM_RM16, PARAM_CL, 0 }, | |
| 2254 | {"shl", 0, PARAM_RM16, PARAM_CL, 0 }, | |
| 2255 | {"shr", 0, PARAM_RM16, PARAM_CL, 0 }, | |
| 2256 | {"???", 0, PARAM_RM16, PARAM_CL, 0 }, | |
| 2257 | {"shra", 0, PARAM_RM16, PARAM_CL, 0 } | |
| 2258 | }; | |
| 2259 | ||
| 2260 | static const I386_OPCODE group1b_table[8] = | |
| 2261 | { | |
| 2262 | {"test", 0, PARAM_RM8, PARAM_I8, 0 }, | |
| 2263 | {"???", 0, 0, 0, 0 }, | |
| 2264 | {"not", 0, PARAM_RM8, 0, 0 }, | |
| 2265 | {"neg", 0, PARAM_RM8, 0, 0 }, | |
| 2266 | {"mulu", 0, PARAM_RM8, 0, 0 }, | |
| 2267 | {"mul", 0, PARAM_RM8, 0, 0 }, | |
| 2268 | {"divu", 0, PARAM_RM8, 0, 0 }, | |
| 2269 | {"div", 0, PARAM_RM8, 0, 0 } | |
| 2270 | }; | |
| 2271 | ||
| 2272 | static const I386_OPCODE group1w_table[8] = | |
| 2273 | { | |
| 2274 | {"test", 0, PARAM_RM16, PARAM_IMM, 0 }, | |
| 2275 | {"???", 0, 0, 0, 0 }, | |
| 2276 | {"not", 0, PARAM_RM16, 0, 0 }, | |
| 2277 | {"neg", 0, PARAM_RM16, 0, 0 }, | |
| 2278 | {"mulu", 0, PARAM_RM16, 0, 0 }, | |
| 2279 | {"mul", 0, PARAM_RM16, 0, 0 }, | |
| 2280 | {"divu", 0, PARAM_RM16, 0, 0 }, | |
| 2281 | {"div", 0, PARAM_RM16, 0, 0 } | |
| 2282 | }; | |
| 2283 | ||
| 2284 | static const I386_OPCODE group2b_table[8] = | |
| 2285 | { | |
| 2286 | {"inc", 0, PARAM_RM8, 0, 0 }, | |
| 2287 | {"dec", 0, PARAM_RM8, 0, 0 }, | |
| 2288 | {"???", 0, 0, 0, 0 }, | |
| 2289 | {"???", 0, 0, 0, 0 }, | |
| 2290 | {"???", 0, 0, 0, 0 }, | |
| 2291 | {"???", 0, 0, 0, 0 }, | |
| 2292 | {"???", 0, 0, 0, 0 }, | |
| 2293 | {"???", 0, 0, 0, 0 } | |
| 2294 | }; | |
| 2295 | ||
| 2296 | static const I386_OPCODE group2w_table[8] = | |
| 2297 | { | |
| 2298 | {"inc", 0, PARAM_RM16, 0, 0 }, | |
| 2299 | {"dec", 0, PARAM_RM16, 0, 0 }, | |
| 2300 | {"call", 0, PARAM_RM16, 0, 0, DASMFLAG_STEP_OVER}, | |
| 2301 | {"call far ptr ",0, PARAM_RM16, 0, 0, DASMFLAG_STEP_OVER}, | |
| 2302 | {"br", 0, PARAM_RM16, 0, 0 }, | |
| 2303 | {"br far ptr ",0, PARAM_RM16, 0, 0 }, | |
| 2304 | {"push", 0, PARAM_RM16, 0, 0 }, | |
| 2305 | {"???", 0, 0, 0, 0 } | |
| 2306 | }; | |
| 2307 | ||
| 2308 | static const GROUP_OP group_op_table[] = | |
| 2309 | { | |
| 2310 | { "immb", immb_table }, | |
| 2311 | { "immw", immw_table }, | |
| 2312 | { "immws", immws_table }, | |
| 2313 | { "shiftbi", shiftbi_table }, | |
| 2314 | { "shiftwi", shiftwi_table }, | |
| 2315 | { "shiftb", shiftb_table }, | |
| 2316 | { "shiftw", shiftw_table }, | |
| 2317 | { "shiftbv", shiftbv_table }, | |
| 2318 | { "shiftwv", shiftwv_table }, | |
| 2319 | { "group1b", group1b_table }, | |
| 2320 | { "group1w", group1w_table }, | |
| 2321 | { "group2b", group2b_table }, | |
| 2322 | { "group2w", group2w_table } | |
| 2323 | }; | |
| 2324 | ||
| 2325 | ||
| 2326 | ||
| 2327 | static const char *nec_reg[8] = { "aw", "cw", "dw", "bw", "sp", "bp", "ix", "iy" }; | |
| 2328 | static const char *neg_reg8[8] = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" }; | |
| 2329 | static const char *nec_sreg[8] = { "ds1", "ps", "ss", "ds0", "???", "???", "???", "???" }; | |
| 2330 | ||
| 2331 | static UINT32 pc; | |
| 2332 | static UINT8 modrm; | |
| 2333 | static UINT32 segment; | |
| 2334 | static offs_t dasm_flags; | |
| 2335 | static char modrm_string[256]; | |
| 2336 | ||
| 2337 | #define MODRM_REG1 ((modrm >> 3) & 0x7) | |
| 2338 | #define MODRM_REG2 (modrm & 0x7) | |
| 2339 | ||
| 2340 | INLINE UINT8 FETCH(void) | |
| 2341 | { | |
| 2342 | if ((opcode_ptr - opcode_ptr_base) + 1 > 15) | |
| 2343 | return 0xff; | |
| 2344 | pc++; | |
| 2345 | return *opcode_ptr++; | |
| 2346 | } | |
| 2347 | ||
| 2348 | INLINE UINT16 FETCH16(void) | |
| 2349 | { | |
| 2350 | UINT16 d; | |
| 2351 | if ((opcode_ptr - opcode_ptr_base) + 2 > 15) | |
| 2352 | return 0xffff; | |
| 2353 | d = opcode_ptr[0] | (opcode_ptr[1] << 8); | |
| 2354 | opcode_ptr += 2; | |
| 2355 | pc += 2; | |
| 2356 | return d; | |
| 2357 | } | |
| 2358 | ||
| 2359 | INLINE UINT8 FETCHD(void) | |
| 2360 | { | |
| 2361 | if ((opcode_ptr - opcode_ptr_base) + 1 > 15) | |
| 2362 | return 0xff; | |
| 2363 | pc++; | |
| 2364 | return *opcode_ptr++; | |
| 2365 | } | |
| 2366 | ||
| 2367 | INLINE UINT16 FETCHD16(void) | |
| 2368 | { | |
| 2369 | UINT16 d; | |
| 2370 | if ((opcode_ptr - opcode_ptr_base) + 2 > 15) | |
| 2371 | return 0xffff; | |
| 2372 | d = opcode_ptr[0] | (opcode_ptr[1] << 8); | |
| 2373 | opcode_ptr += 2; | |
| 2374 | pc += 2; | |
| 2375 | return d; | |
| 2376 | } | |
| 2377 | ||
| 2378 | static char *hexstring(UINT32 value, int digits) | |
| 2379 | { | |
| 2380 | static char buffer[20]; | |
| 2381 | buffer[0] = '0'; | |
| 2382 | if (digits) | |
| 2383 | sprintf(&buffer[1], "%0*Xh", digits, value); | |
| 2384 | else | |
| 2385 | sprintf(&buffer[1], "%Xh", value); | |
| 2386 | return (buffer[1] >= '0' && buffer[1] <= '9') ? &buffer[1] : &buffer[0]; | |
| 2387 | } | |
| 2388 | ||
| 2389 | static char *shexstring(UINT32 value, int digits, int always) | |
| 2390 | { | |
| 2391 | static char buffer[20]; | |
| 2392 | if (value >= 0x80000000) | |
| 2393 | sprintf(buffer, "-%s", hexstring(-value, digits)); | |
| 2394 | else if (always) | |
| 2395 | sprintf(buffer, "+%s", hexstring(value, digits)); | |
| 2396 | else | |
| 2397 | return hexstring(value, digits); | |
| 2398 | return buffer; | |
| 2399 | } | |
| 2400 | ||
| 2401 | static void handle_modrm(char* s) | |
| 2402 | { | |
| 2403 | INT8 disp8; | |
| 2404 | INT16 disp16; | |
| 2405 | UINT8 mod, rm; | |
| 2406 | ||
| 2407 | modrm = FETCHD(); | |
| 2408 | mod = (modrm >> 6) & 0x3; | |
| 2409 | rm = (modrm & 0x7); | |
| 2410 | ||
| 2411 | if( modrm >= 0xc0 ) | |
| 2412 | return; | |
| 2413 | ||
| 2414 | switch(segment) | |
| 2415 | { | |
| 2416 | case SEG_PS: s += sprintf( s, "ps:" ); break; | |
| 2417 | case SEG_DS0: s += sprintf( s, "ds0:" ); break; | |
| 2418 | case SEG_DS1: s += sprintf( s, "ds1:" ); break; | |
| 2419 | case SEG_SS: s += sprintf( s, "ss:" ); break; | |
| 2420 | } | |
| 2421 | ||
| 2422 | s += sprintf( s, "[" ); | |
| 2423 | switch( rm ) | |
| 2424 | { | |
| 2425 | case 0: s += sprintf( s, "bw+ix" ); break; | |
| 2426 | case 1: s += sprintf( s, "bw+iy" ); break; | |
| 2427 | case 2: s += sprintf( s, "bw+ix" ); break; | |
| 2428 | case 3: s += sprintf( s, "bw+iy" ); break; | |
| 2429 | case 4: s += sprintf( s, "ix" ); break; | |
| 2430 | case 5: s += sprintf( s, "iy" ); break; | |
| 2431 | case 6: | |
| 2432 | if( mod == 0 ) { | |
| 2433 | disp16 = FETCHD16(); | |
| 2434 | s += sprintf( s, "%s", hexstring((unsigned) (UINT16) disp16, 0) ); | |
| 2435 | } else { | |
| 2436 | s += sprintf( s, "bp" ); | |
| 2437 | } | |
| 2438 | break; | |
| 2439 | case 7: s += sprintf( s, "bw" ); break; | |
| 2440 | } | |
| 2441 | if( mod == 1 ) { | |
| 2442 | disp8 = FETCHD(); | |
| 2443 | s += sprintf( s, "%s", shexstring((INT32)disp8, 0, TRUE) ); | |
| 2444 | } else if( mod == 2 ) { | |
| 2445 | disp16 = FETCHD16(); | |
| 2446 | s += sprintf( s, "%s", shexstring((INT32)disp16, 0, TRUE) ); | |
| 2447 | } | |
| 2448 | s += sprintf( s, "]" ); | |
| 2449 | } | |
| 2450 | ||
| 2451 | static char* handle_param(char* s, UINT32 param) | |
| 2452 | { | |
| 2453 | UINT8 i8; | |
| 2454 | UINT16 i16; | |
| 2455 | UINT16 ptr; | |
| 2456 | UINT32 addr; | |
| 2457 | INT8 d8; | |
| 2458 | INT16 d16; | |
| 2459 | ||
| 2460 | switch(param) | |
| 2461 | { | |
| 2462 | case PARAM_REG8: | |
| 2463 | s += sprintf( s, "%s", neg_reg8[MODRM_REG1] ); | |
| 2464 | break; | |
| 2465 | ||
| 2466 | case PARAM_REG16: | |
| 2467 | s += sprintf( s, "%s", nec_reg[MODRM_REG1] ); | |
| 2468 | break; | |
| 2469 | ||
| 2470 | case PARAM_REG2_8: | |
| 2471 | s += sprintf( s, "%s", neg_reg8[MODRM_REG2] ); | |
| 2472 | break; | |
| 2473 | ||
| 2474 | case PARAM_REG2_16: | |
| 2475 | s += sprintf( s, "%s", nec_reg[MODRM_REG2] ); | |
| 2476 | break; | |
| 2477 | ||
| 2478 | case PARAM_RM8: | |
| 2479 | if( modrm >= 0xc0 ) { | |
| 2480 | s += sprintf( s, "%s", neg_reg8[MODRM_REG2] ); | |
| 2481 | } else { | |
| 2482 | s += sprintf( s, "byte ptr " ); | |
| 2483 | s += sprintf( s, "%s", modrm_string ); | |
| 2484 | } | |
| 2485 | break; | |
| 2486 | ||
| 2487 | case PARAM_RM16: | |
| 2488 | if( modrm >= 0xc0 ) { | |
| 2489 | s += sprintf( s, "%s", nec_reg[MODRM_REG2] ); | |
| 2490 | } else { | |
| 2491 | s += sprintf( s, "word ptr " ); | |
| 2492 | s += sprintf( s, "%s", modrm_string ); | |
| 2493 | } | |
| 2494 | break; | |
| 2495 | ||
| 2496 | case PARAM_I4: | |
| 2497 | i8 = FETCHD(); | |
| 2498 | s += sprintf( s, "%d", i8 & 0x0f ); | |
| 2499 | break; | |
| 2500 | ||
| 2501 | case PARAM_I8: | |
| 2502 | i8 = FETCHD(); | |
| 2503 | s += sprintf( s, "%s", shexstring((INT8)i8, 0, FALSE) ); | |
| 2504 | break; | |
| 2505 | ||
| 2506 | case PARAM_I16: | |
| 2507 | i16 = FETCHD16(); | |
| 2508 | s += sprintf( s, "%s", shexstring((INT16)i16, 0, FALSE) ); | |
| 2509 | break; | |
| 2510 | ||
| 2511 | case PARAM_UI8: | |
| 2512 | i8 = FETCHD(); | |
| 2513 | s += sprintf( s, "%s", shexstring((UINT8)i8, 0, FALSE) ); | |
| 2514 | break; | |
| 2515 | ||
| 2516 | case PARAM_UI16: | |
| 2517 | i16 = FETCHD16(); | |
| 2518 | s += sprintf( s, "%s", shexstring((UINT16)i16, 0, FALSE) ); | |
| 2519 | break; | |
| 2520 | ||
| 2521 | case PARAM_IMM: | |
| 2522 | i16 = FETCHD16(); | |
| 2523 | s += sprintf( s, "%s", hexstring(i16, 0) ); | |
| 2524 | break; | |
| 2525 | ||
| 2526 | case PARAM_ADDR: | |
| 2527 | addr = FETCHD16(); | |
| 2528 | ptr = FETCHD16(); | |
| 2529 | s += sprintf( s, "%s:", hexstring(ptr, 4) ); | |
| 2530 | s += sprintf( s, "%s", hexstring(addr, 0) ); | |
| 2531 | break; | |
| 2532 | ||
| 2533 | case PARAM_REL16: | |
| 2534 | /* make sure to keep the relative offset within the segment */ | |
| 2535 | d16 = FETCHD16(); | |
| 2536 | s += sprintf( s, "%s", hexstring((pc & 0xFFFF0000) | ((pc + d16) & 0x0000FFFF), 0) ); | |
| 2537 | break; | |
| 2538 | ||
| 2539 | case PARAM_REL8: | |
| 2540 | d8 = FETCHD(); | |
| 2541 | s += sprintf( s, "%s", hexstring(pc + d8, 0) ); | |
| 2542 | break; | |
| 2543 | ||
| 2544 | case PARAM_MEM_OFFS_B: | |
| 2545 | d8 = FETCHD(); | |
| 2546 | s += sprintf( s, "[%s]", hexstring(d8, 0) ); | |
| 2547 | break; | |
| 2548 | ||
| 2549 | case PARAM_MEM_OFFS_W: | |
| 2550 | d16 = FETCHD16(); | |
| 2551 | s += sprintf( s, "[%s]", hexstring(d16, 0) ); | |
| 2552 | break; | |
| 2553 | ||
| 2554 | case PARAM_SREG: | |
| 2555 | s += sprintf( s, "%s", nec_sreg[MODRM_REG1] ); | |
| 2556 | break; | |
| 2557 | ||
| 2558 | case PARAM_1: | |
| 2559 | s += sprintf( s, "1" ); | |
| 2560 | break; | |
| 2561 | ||
| 2562 | case PARAM_RBANK: | |
| 2563 | s += sprintf( s, "%d", FETCHD() & 7 ); | |
| 2564 | break; | |
| 2565 | ||
| 2566 | case PARAM_AL: s += sprintf( s, "al" ); break; | |
| 2567 | case PARAM_CL: s += sprintf( s, "cl" ); break; | |
| 2568 | case PARAM_DL: s += sprintf( s, "dl" ); break; | |
| 2569 | case PARAM_BL: s += sprintf( s, "bl" ); break; | |
| 2570 | case PARAM_AH: s += sprintf( s, "ah" ); break; | |
| 2571 | case PARAM_CH: s += sprintf( s, "ch" ); break; | |
| 2572 | case PARAM_DH: s += sprintf( s, "dh" ); break; | |
| 2573 | case PARAM_BH: s += sprintf( s, "bh" ); break; | |
| 2574 | ||
| 2575 | case PARAM_AW: s += sprintf( s, "aw" ); break; | |
| 2576 | case PARAM_CW: s += sprintf( s, "cw" ); break; | |
| 2577 | case PARAM_DW: s += sprintf( s, "dw" ); break; | |
| 2578 | case PARAM_BW: s += sprintf( s, "bw" ); break; | |
| 2579 | case PARAM_SP: s += sprintf( s, "sp" ); break; | |
| 2580 | case PARAM_BP: s += sprintf( s, "bp" ); break; | |
| 2581 | case PARAM_IX: s += sprintf( s, "ix" ); break; | |
| 2582 | case PARAM_IY: s += sprintf( s, "iy" ); break; | |
| 2583 | } | |
| 2584 | return s; | |
| 2585 | } | |
| 2586 | ||
| 2587 | static void handle_fpu(char *s, UINT8 op1, UINT8 op2) | |
| 2588 | { | |
| 2589 | switch (op1 & 0x7) | |
| 2590 | { | |
| 2591 | case 0: // Group D8 | |
| 2592 | { | |
| 2593 | if (op2 < 0xc0) | |
| 2594 | { | |
| 2595 | pc--; // adjust fetch pointer, so modrm byte read again | |
| 2596 | opcode_ptr--; | |
| 2597 | handle_modrm( modrm_string ); | |
| 2598 | switch ((op2 >> 3) & 0x7) | |
| 2599 | { | |
| 2600 | case 0: sprintf(s, "fadd dword ptr %s", modrm_string); break; | |
| 2601 | case 1: sprintf(s, "fmul dword ptr %s", modrm_string); break; | |
| 2602 | case 2: sprintf(s, "fcom dword ptr %s", modrm_string); break; | |
| 2603 | case 3: sprintf(s, "fcomp dword ptr %s", modrm_string); break; | |
| 2604 | case 4: sprintf(s, "fsub dword ptr %s", modrm_string); break; | |
| 2605 | case 5: sprintf(s, "fsubr dword ptr %s", modrm_string); break; | |
| 2606 | case 6: sprintf(s, "fdiv dword ptr %s", modrm_string); break; | |
| 2607 | case 7: sprintf(s, "fdivr dword ptr %s", modrm_string); break; | |
| 2608 | } | |
| 2609 | } | |
| 2610 | else | |
| 2611 | { | |
| 2612 | switch ((op2 >> 3) & 0x7) | |
| 2613 | { | |
| 2614 | case 0: sprintf(s, "fadd st(0),st(%d)", op2 & 0x7); break; | |
| 2615 | case 1: sprintf(s, "fcom st(0),st(%d)", op2 & 0x7); break; | |
| 2616 | case 2: sprintf(s, "fsub st(0),st(%d)", op2 & 0x7); break; | |
| 2617 | case 3: sprintf(s, "fdiv st(0),st(%d)", op2 & 0x7); break; | |
| 2618 | case 4: sprintf(s, "fmul st(0),st(%d)", op2 & 0x7); break; | |
| 2619 | case 5: sprintf(s, "fcomp st(0),st(%d)", op2 & 0x7); break; | |
| 2620 | case 6: sprintf(s, "fsubr st(0),st(%d)", op2 & 0x7); break; | |
| 2621 | case 7: sprintf(s, "fdivr st(0),st(%d)", op2 & 0x7); break; | |
| 2622 | } | |
| 2623 | } | |
| 2624 | break; | |
| 2625 | } | |
| 2626 | ||
| 2627 | case 1: // Group D9 | |
| 2628 | { | |
| 2629 | if (op2 < 0xc0) | |
| 2630 | { | |
| 2631 | pc--; // adjust fetch pointer, so modrm byte read again | |
| 2632 | opcode_ptr--; | |
| 2633 | handle_modrm( modrm_string ); | |
| 2634 | switch ((op2 >> 3) & 0x7) | |
| 2635 | { | |
| 2636 | case 0: sprintf(s, "fld dword ptr %s", modrm_string); break; | |
| 2637 | case 1: sprintf(s, "??? (FPU)"); break; | |
| 2638 | case 2: sprintf(s, "fst dword ptr %s", modrm_string); break; | |
| 2639 | case 3: sprintf(s, "fstp dword ptr %s", modrm_string); break; | |
| 2640 | case 4: sprintf(s, "fldenv word ptr %s", modrm_string); break; | |
| 2641 | case 5: sprintf(s, "fldcw word ptr %s", modrm_string); break; | |
| 2642 | case 6: sprintf(s, "fstenv word ptr %s", modrm_string); break; | |
| 2643 | case 7: sprintf(s, "fstcw word ptr %s", modrm_string); break; | |
| 2644 | } | |
| 2645 | } | |
| 2646 | else | |
| 2647 | { | |
| 2648 | switch (op2 & 0x3f) | |
| 2649 | { | |
| 2650 | case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: | |
| 2651 | sprintf(s, "fld st(0),st(%d)", op2 & 0x7); break; | |
| 2652 | ||
| 2653 | case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: | |
| 2654 | sprintf(s, "fxch st(0),st(%d)", op2 & 0x7); break; | |
| 2655 | ||
| 2656 | case 0x10: sprintf(s, "fnop"); break; | |
| 2657 | case 0x20: sprintf(s, "fchs"); break; | |
| 2658 | case 0x21: sprintf(s, "fabs"); break; | |
| 2659 | case 0x24: sprintf(s, "ftst"); break; | |
| 2660 | case 0x25: sprintf(s, "fxam"); break; | |
| 2661 | case 0x28: sprintf(s, "fld1"); break; | |
| 2662 | case 0x29: sprintf(s, "fldl2t"); break; | |
| 2663 | case 0x2a: sprintf(s, "fldl2e"); break; | |
| 2664 | case 0x2b: sprintf(s, "fldpi"); break; | |
| 2665 | case 0x2c: sprintf(s, "fldlg2"); break; | |
| 2666 | case 0x2d: sprintf(s, "fldln2"); break; | |
| 2667 | case 0x2e: sprintf(s, "fldz"); break; | |
| 2668 | case 0x30: sprintf(s, "f2xm1"); break; | |
| 2669 | case 0x31: sprintf(s, "fyl2x"); break; | |
| 2670 | case 0x32: sprintf(s, "fptan"); break; | |
| 2671 | case 0x33: sprintf(s, "fpatan"); break; | |
| 2672 | case 0x34: sprintf(s, "fxtract"); break; | |
| 2673 | case 0x35: sprintf(s, "fprem1"); break; | |
| 2674 | case 0x36: sprintf(s, "fdecstp"); break; | |
| 2675 | case 0x37: sprintf(s, "fincstp"); break; | |
| 2676 | case 0x38: sprintf(s, "fprem"); break; | |
| 2677 | case 0x39: sprintf(s, "fyl2xp1"); break; | |
| 2678 | case 0x3a: sprintf(s, "fsqrt"); break; | |
| 2679 | case 0x3b: sprintf(s, "fsincos"); break; | |
| 2680 | case 0x3c: sprintf(s, "frndint"); break; | |
| 2681 | case 0x3d: sprintf(s, "fscale"); break; | |
| 2682 | case 0x3e: sprintf(s, "fsin"); break; | |
| 2683 | case 0x3f: sprintf(s, "fcos"); break; | |
| 2684 | ||
| 2685 | default: sprintf(s, "??? (FPU)"); break; | |
| 2686 | } | |
| 2687 | } | |
| 2688 | break; | |
| 2689 | } | |
| 2690 | ||
| 2691 | case 2: // Group DA | |
| 2692 | { | |
| 2693 | if (op2 < 0xc0) | |
| 2694 | { | |
| 2695 | pc--; // adjust fetch pointer, so modrm byte read again | |
| 2696 | opcode_ptr--; | |
| 2697 | handle_modrm( modrm_string ); | |
| 2698 | switch ((op2 >> 3) & 0x7) | |
| 2699 | { | |
| 2700 | case 0: sprintf(s, "fiadd dword ptr %s", modrm_string); break; | |
| 2701 | case 1: sprintf(s, "fimul dword ptr %s", modrm_string); break; | |
| 2702 | case 2: sprintf(s, "ficom dword ptr %s", modrm_string); break; | |
| 2703 | case 3: sprintf(s, "ficomp dword ptr %s", modrm_string); break; | |
| 2704 | case 4: sprintf(s, "fisub dword ptr %s", modrm_string); break; | |
| 2705 | case 5: sprintf(s, "fisubr dword ptr %s", modrm_string); break; | |
| 2706 | case 6: sprintf(s, "fidiv dword ptr %s", modrm_string); break; | |
| 2707 | case 7: sprintf(s, "fidivr dword ptr %s", modrm_string); break; | |
| 2708 | } | |
| 2709 | } | |
| 2710 | else | |
| 2711 | { | |
| 2712 | switch (op2 & 0x3f) | |
| 2713 | { | |
| 2714 | case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: | |
| 2715 | sprintf(s, "fcmovb st(0),st(%d)", op2 & 0x7); break; | |
| 2716 | ||
| 2717 | case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: | |
| 2718 | sprintf(s, "fcmove st(0),st(%d)", op2 & 0x7); break; | |
| 2719 | ||
| 2720 | case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: | |
| 2721 | sprintf(s, "fcmovbe st(0),st(%d)", op2 & 0x7); break; | |
| 2722 | ||
| 2723 | case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: | |
| 2724 | sprintf(s, "fcmovu st(0),st(%d)", op2 & 0x7); break; | |
| 2725 | ||
| 2726 | default: sprintf(s, "??? (FPU)"); break; | |
| 2727 | ||
| 2728 | } | |
| 2729 | } | |
| 2730 | break; | |
| 2731 | } | |
| 2732 | ||
| 2733 | case 3: // Group DB | |
| 2734 | { | |
| 2735 | if (op2 < 0xc0) | |
| 2736 | { | |
| 2737 | pc--; // adjust fetch pointer, so modrm byte read again | |
| 2738 | opcode_ptr--; | |
| 2739 | handle_modrm( modrm_string ); | |
| 2740 | switch ((op2 >> 3) & 0x7) | |
| 2741 | { | |
| 2742 | case 0: sprintf(s, "fild dword ptr %s", modrm_string); break; | |
| 2743 | case 1: sprintf(s, "??? (FPU)"); break; | |
| 2744 | case 2: sprintf(s, "fist dword ptr %s", modrm_string); break; | |
| 2745 | case 3: sprintf(s, "fistp dword ptr %s", modrm_string); break; | |
| 2746 | case 4: sprintf(s, "??? (FPU)"); break; | |
| 2747 | case 5: sprintf(s, "fld tword ptr %s", modrm_string); break; | |
| 2748 | case 6: sprintf(s, "??? (FPU)"); break; | |
| 2749 | case 7: sprintf(s, "fstp tword ptr %s", modrm_string); break; | |
| 2750 | } | |
| 2751 | } | |
| 2752 | else | |
| 2753 | { | |
| 2754 | switch (op2 & 0x3f) | |
| 2755 | { | |
| 2756 | case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: | |
| 2757 | sprintf(s, "fcmovnb st(0),st(%d)", op2 & 0x7); break; | |
| 2758 | ||
| 2759 | case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: | |
| 2760 | sprintf(s, "fcmovne st(0),st(%d)", op2 & 0x7); break; | |
| 2761 | ||
| 2762 | case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: | |
| 2763 | sprintf(s, "fcmovnbe st(0),st(%d)", op2 & 0x7); break; | |
| 2764 | ||
| 2765 | case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: | |
| 2766 | sprintf(s, "fcmovnu st(0),st(%d)", op2 & 0x7); break; | |
| 2767 | ||
| 2768 | case 0x22: sprintf(s, "fclex"); break; | |
| 2769 | case 0x23: sprintf(s, "finit"); break; | |
| 2770 | ||
| 2771 | case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: | |
| 2772 | sprintf(s, "fucomi st(0),st(%d)", op2 & 0x7); break; | |
| 2773 | ||
| 2774 | case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: | |
| 2775 | sprintf(s, "fcomi st(0),st(%d)", op2 & 0x7); break; | |
| 2776 | ||
| 2777 | default: sprintf(s, "??? (FPU)"); break; | |
| 2778 | } | |
| 2779 | } | |
| 2780 | break; | |
| 2781 | } | |
| 2782 | ||
| 2783 | case 4: // Group DC | |
| 2784 | { | |
| 2785 | if (op2 < 0xc0) | |
| 2786 | { | |
| 2787 | pc--; // adjust fetch pointer, so modrm byte read again | |
| 2788 | opcode_ptr--; | |
| 2789 | handle_modrm( modrm_string ); | |
| 2790 | switch ((op2 >> 3) & 0x7) | |
| 2791 | { | |
| 2792 | case 0: sprintf(s, "fadd qword ptr %s", modrm_string); break; | |
| 2793 | case 1: sprintf(s, "fmul qword ptr %s", modrm_string); break; | |
| 2794 | case 2: sprintf(s, "fcom qword ptr %s", modrm_string); break; | |
| 2795 | case 3: sprintf(s, "fcomp qword ptr %s", modrm_string); break; | |
| 2796 | case 4: sprintf(s, "fsub qword ptr %s", modrm_string); break; | |
| 2797 | case 5: sprintf(s, "fsubr qword ptr %s", modrm_string); break; | |
| 2798 | case 6: sprintf(s, "fdiv qword ptr %s", modrm_string); break; | |
| 2799 | case 7: sprintf(s, "fdivr qword ptr %s", modrm_string); break; | |
| 2800 | } | |
| 2801 | } | |
| 2802 | else | |
| 2803 | { | |
| 2804 | switch (op2 & 0x3f) | |
| 2805 | { | |
| 2806 | case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: | |
| 2807 | sprintf(s, "fadd st(%d),st(0)", op2 & 0x7); break; | |
| 2808 | ||
| 2809 | case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: | |
| 2810 | sprintf(s, "fmul st(%d),st(0)", op2 & 0x7); break; | |
| 2811 | ||
| 2812 | case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: | |
| 2813 | sprintf(s, "fsubr st(%d),st(0)", op2 & 0x7); break; | |
| 2814 | ||
| 2815 | case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: | |
| 2816 | sprintf(s, "fsub st(%d),st(0)", op2 & 0x7); break; | |
| 2817 | ||
| 2818 | case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: | |
| 2819 | sprintf(s, "fdivr st(%d),st(0)", op2 & 0x7); break; | |
| 2820 | ||
| 2821 | case 0x38: case 0x39: case 0x3a: case 0x3b: case 0x3c: case 0x3d: case 0x3e: case 0x3f: | |
| 2822 | sprintf(s, "fdiv st(%d),st(0)", op2 & 0x7); break; | |
| 2823 | ||
| 2824 | default: sprintf(s, "??? (FPU)"); break; | |
| 2825 | } | |
| 2826 | } | |
| 2827 | break; | |
| 2828 | } | |
| 2829 | ||
| 2830 | case 5: // Group DD | |
| 2831 | { | |
| 2832 | if (op2 < 0xc0) | |
| 2833 | { | |
| 2834 | pc--; // adjust fetch pointer, so modrm byte read again | |
| 2835 | opcode_ptr--; | |
| 2836 | handle_modrm( modrm_string ); | |
| 2837 | switch ((op2 >> 3) & 0x7) | |
| 2838 | { | |
| 2839 | case 0: sprintf(s, "fld qword ptr %s", modrm_string); break; | |
| 2840 | case 1: sprintf(s, "??? (FPU)"); break; | |
| 2841 | case 2: sprintf(s, "fst qword ptr %s", modrm_string); break; | |
| 2842 | case 3: sprintf(s, "fstp qword ptr %s", modrm_string); break; | |
| 2843 | case 4: sprintf(s, "frstor %s", modrm_string); break; | |
| 2844 | case 5: sprintf(s, "??? (FPU)"); break; | |
| 2845 | case 6: sprintf(s, "fsave %s", modrm_string); break; | |
| 2846 | case 7: sprintf(s, "fstsw word ptr %s", modrm_string); break; | |
| 2847 | } | |
| 2848 | } | |
| 2849 | else | |
| 2850 | { | |
| 2851 | switch (op2 & 0x3f) | |
| 2852 | { | |
| 2853 | case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: | |
| 2854 | sprintf(s, "ffree st(%d)", op2 & 0x7); break; | |
| 2855 | ||
| 2856 | case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: | |
| 2857 | sprintf(s, "fst st(%d)", op2 & 0x7); break; | |
| 2858 | ||
| 2859 | case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: | |
| 2860 | sprintf(s, "fstp st(%d)", op2 & 0x7); break; | |
| 2861 | ||
| 2862 | case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: | |
| 2863 | sprintf(s, "fucom st(%d), st(0)", op2 & 0x7); break; | |
| 2864 | ||
| 2865 | case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: | |
| 2866 | sprintf(s, "fucomp st(%d)", op2 & 0x7); break; | |
| 2867 | ||
| 2868 | default: sprintf(s, "??? (FPU)"); break; | |
| 2869 | } | |
| 2870 | } | |
| 2871 | break; | |
| 2872 | } | |
| 2873 | ||
| 2874 | case 6: // Group DE | |
| 2875 | { | |
| 2876 | if (op2 < 0xc0) | |
| 2877 | { | |
| 2878 | pc--; // adjust fetch pointer, so modrm byte read again | |
| 2879 | opcode_ptr--; | |
| 2880 | handle_modrm( modrm_string ); | |
| 2881 | switch ((op2 >> 3) & 0x7) | |
| 2882 | { | |
| 2883 | case 0: sprintf(s, "fiadd word ptr %s", modrm_string); break; | |
| 2884 | case 1: sprintf(s, "fimul word ptr %s", modrm_string); break; | |
| 2885 | case 2: sprintf(s, "ficom word ptr %s", modrm_string); break; | |
| 2886 | case 3: sprintf(s, "ficomp word ptr %s", modrm_string); break; | |
| 2887 | case 4: sprintf(s, "fisub word ptr %s", modrm_string); break; | |
| 2888 | case 5: sprintf(s, "fisubr word ptr %s", modrm_string); break; | |
| 2889 | case 6: sprintf(s, "fidiv word ptr %s", modrm_string); break; | |
| 2890 | case 7: sprintf(s, "fidivr word ptr %s", modrm_string); break; | |
| 2891 | } | |
| 2892 | } | |
| 2893 | else | |
| 2894 | { | |
| 2895 | switch (op2 & 0x3f) | |
| 2896 | { | |
| 2897 | case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: | |
| 2898 | sprintf(s, "faddp st(%d)", op2 & 0x7); break; | |
| 2899 | ||
| 2900 | case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: | |
| 2901 | sprintf(s, "fmulp st(%d)", op2 & 0x7); break; | |
| 2902 | ||
| 2903 | case 0x19: sprintf(s, "fcompp"); break; | |
| 2904 | ||
| 2905 | case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: | |
| 2906 | sprintf(s, "fsubrp st(%d)", op2 & 0x7); break; | |
| 2907 | ||
| 2908 | case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: | |
| 2909 | sprintf(s, "fsubp st(%d)", op2 & 0x7); break; | |
| 2910 | ||
| 2911 | case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: | |
| 2912 | sprintf(s, "fdivrp st(%d), st(0)", op2 & 0x7); break; | |
| 2913 | ||
| 2914 | case 0x38: case 0x39: case 0x3a: case 0x3b: case 0x3c: case 0x3d: case 0x3e: case 0x3f: | |
| 2915 | sprintf(s, "fdivp st(%d)", op2 & 0x7); break; | |
| 2916 | ||
| 2917 | default: sprintf(s, "??? (FPU)"); break; | |
| 2918 | } | |
| 2919 | } | |
| 2920 | break; | |
| 2921 | } | |
| 2922 | ||
| 2923 | case 7: // Group DF | |
| 2924 | { | |
| 2925 | if (op2 < 0xc0) | |
| 2926 | { | |
| 2927 | pc--; // adjust fetch pointer, so modrm byte read again | |
| 2928 | opcode_ptr--; | |
| 2929 | handle_modrm( modrm_string ); | |
| 2930 | switch ((op2 >> 3) & 0x7) | |
| 2931 | { | |
| 2932 | case 0: sprintf(s, "fild word ptr %s", modrm_string); break; | |
| 2933 | case 1: sprintf(s, "??? (FPU)"); break; | |
| 2934 | case 2: sprintf(s, "fist word ptr %s", modrm_string); break; | |
| 2935 | case 3: sprintf(s, "fistp word ptr %s", modrm_string); break; | |
| 2936 | case 4: sprintf(s, "fbld %s", modrm_string); break; | |
| 2937 | case 5: sprintf(s, "fild qword ptr %s", modrm_string); break; | |
| 2938 | case 6: sprintf(s, "fbstp %s", modrm_string); break; | |
| 2939 | case 7: sprintf(s, "fistp qword ptr %s", modrm_string); break; | |
| 2940 | } | |
| 2941 | } | |
| 2942 | else | |
| 2943 | { | |
| 2944 | switch (op2 & 0x3f) | |
| 2945 | { | |
| 2946 | case 0x20: sprintf(s, "fstsw aw"); break; | |
| 2947 | ||
| 2948 | case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: | |
| 2949 | sprintf(s, "fucomip st(%d)", op2 & 0x7); break; | |
| 2950 | ||
| 2951 | case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: | |
| 2952 | sprintf(s, "fcomip st(%d),st(0)", op2 & 0x7); break; | |
| 2953 | ||
| 2954 | default: sprintf(s, "??? (FPU)"); break; | |
| 2955 | } | |
| 2956 | } | |
| 2957 | break; | |
| 2958 | } | |
| 2959 | } | |
| 2960 | } | |
| 2961 | ||
| 2962 | static void decode_opcode(char *s, const I386_OPCODE *op, UINT8 op1) | |
| 2963 | { | |
| 2964 | int i; | |
| 2965 | UINT8 op2; | |
| 2966 | ||
| 2967 | switch( op->flags ) | |
| 2968 | { | |
| 2969 | case TWO_BYTE: | |
| 2970 | op2 = FETCHD(); | |
| 2971 | decode_opcode( s, &necv_opcode_table2[op2], op1 ); | |
| 2972 | return; | |
| 2973 | ||
| 2974 | case SEG_PS: | |
| 2975 | case SEG_DS0: | |
| 2976 | case SEG_DS1: | |
| 2977 | case SEG_SS: | |
| 2978 | segment = op->flags; | |
| 2979 | op2 = FETCH(); | |
| 2980 | decode_opcode( s, &necv_opcode_table1[op2], op1 ); | |
| 2981 | return; | |
| 2982 | ||
| 2983 | case PREFIX: | |
| 2984 | s += sprintf( s, "%-8s", op->mnemonic ); | |
| 2985 | op2 = FETCH(); | |
| 2986 | decode_opcode( s, &necv_opcode_table1[op2], op1 ); | |
| 2987 | return; | |
| 2988 | ||
| 2989 | case GROUP: | |
| 2990 | handle_modrm( modrm_string ); | |
| 2991 | for( i=0; i < ARRAY_LENGTH(group_op_table); i++ ) { | |
| 2992 | if( mame_stricmp(op->mnemonic, group_op_table[i].mnemonic) == 0 ) { | |
| 2993 | decode_opcode( s, &group_op_table[i].opcode[MODRM_REG1], op1 ); | |
| 2994 | return; | |
| 2995 | } | |
| 2996 | } | |
| 2997 | goto handle_unknown; | |
| 2998 | ||
| 2999 | case FPU: | |
| 3000 | op2 = FETCHD(); | |
| 3001 | handle_fpu( s, op1, op2); | |
| 3002 | return; | |
| 3003 | ||
| 3004 | case MODRM: | |
| 3005 | handle_modrm( modrm_string ); | |
| 3006 | break; | |
| 3007 | } | |
| 3008 | ||
| 3009 | s += sprintf( s, "%-8s", op->mnemonic ); | |
| 3010 | dasm_flags = op->dasm_flags; | |
| 3011 | ||
| 3012 | if( op->param1 != 0 ) { | |
| 3013 | s = handle_param( s, op->param1 ); | |
| 3014 | } | |
| 3015 | ||
| 3016 | if( op->param2 != 0 ) { | |
| 3017 | s += sprintf( s, "," ); | |
| 3018 | s = handle_param( s, op->param2 ); | |
| 3019 | } | |
| 3020 | ||
| 3021 | if( op->param3 != 0 ) { | |
| 3022 | s += sprintf( s, "," ); | |
| 3023 | s = handle_param( s, op->param3 ); | |
| 3024 | } | |
| 3025 | return; | |
| 3026 | ||
| 3027 | handle_unknown: | |
| 3028 | sprintf(s, "???"); | |
| 3029 | } | |
| 3030 | ||
| 3031 | int necv_dasm_one(char *buffer, UINT32 eip, const UINT8 *oprom) | |
| 3032 | { | |
| 3033 | UINT8 op; | |
| 3034 | ||
| 3035 | opcode_ptr = opcode_ptr_base = oprom; | |
| 3036 | pc = eip; | |
| 3037 | dasm_flags = 0; | |
| 3038 | segment = 0; | |
| 3039 | ||
| 3040 | op = FETCH(); | |
| 3041 | ||
| 3042 | decode_opcode( buffer, &necv_opcode_table1[op], op ); | |
| 3043 | return (pc-eip) | dasm_flags | DASMFLAG_SUPPORTED; | |
| 3044 | } |
| r936 | r937 | |
|---|---|---|
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | /* floating point rounding modes */ |
| 203 | #define FPRND_NEAR 0 | |
| 204 | #define FPRND_DOWN 1 | |
| 205 | #define FPRND_UP 2 | |
| 206 | #define FPRND_CHOP 3 | |
| 207 | ||
| 208 | ||
| 209 | /* opcode flags (in upper 8 bits of opcode) */ | |
| 210 | #define OPFLAG_8BITREG (1 << 24) | |
| 211 | #define OPFLAG_8BITRM (1 << 25) | |
| 212 | ||
| 213 | ||
| 214 | /* single byte opcodes */ | |
| 215 | #define OP_ADD_Eb_Gb 0x00 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 216 | #define OP_ADD_Ev_Gv 0x01 | |
| 217 | #define OP_ADD_Gb_Eb 0x02 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 218 | #define OP_ADD_Gv_Ev 0x03 | |
| 219 | #define OP_ADD_AL_Ib 0x04 | |
| 220 | #define OP_ADD_rAX_Iz 0x05 | |
| 221 | #define OP_PUSH_ES 0x06 | |
| 222 | #define OP_POP_ES 0x07 | |
| 223 | #define OP_OR_Eb_Gb 0x08 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 224 | #define OP_OR_Ev_Gv 0x09 | |
| 225 | #define OP_OR_Gb_Eb 0x0a | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 226 | #define OP_OR_Gv_Ev 0x0b | |
| 227 | #define OP_OR_AL_Ib 0x0c | |
| 228 | #define OP_OR_eAX_Iv 0x0d | |
| 229 | #define OP_PUSH_CS 0x0e | |
| 230 | #define OP_EXTENDED 0x0f | |
| 231 | ||
| 232 | #define OP_ADC_Eb_Gb 0x10 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 233 | #define OP_ADC_Ev_Gv 0x11 | |
| 234 | #define OP_ADC_Gb_Eb 0x12 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 235 | #define OP_ADC_Gv_Ev 0x13 | |
| 236 | #define OP_ADC_AL_Ib 0x14 | |
| 237 | #define OP_ADC_rAX_Iz 0x15 | |
| 238 | #define OP_PUSH_SS 0x16 | |
| 239 | #define OP_POP_SS 0x17 | |
| 240 | #define OP_SBB_Eb_Gb 0x18 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 241 | #define OP_SBB_Ev_Gv 0x19 | |
| 242 | #define OP_SBB_Gb_Eb 0x1a | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 243 | #define OP_SBB_Gv_Ev 0x1b | |
| 244 | #define OP_SBB_AL_Ib 0x1c | |
| 245 | #define OP_SBB_eAX_Iv 0x1d | |
| 246 | #define OP_PUSH_DS 0x1e | |
| 247 | #define OP_POP_DS 0x1f | |
| 248 | ||
| 249 | #define OP_AND_Eb_Gb 0x20 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 250 | #define OP_AND_Ev_Gv 0x21 | |
| 251 | #define OP_AND_Gb_Eb 0x22 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 252 | #define OP_AND_Gv_Ev 0x23 | |
| 253 | #define OP_AND_AL_Ib 0x24 | |
| 254 | #define OP_AND_rAX_Iz 0x25 | |
| 255 | #define PREFIX_ES 0x26 | |
| 256 | #define OP_DAA 0x27 | |
| 257 | #define OP_SUB_Eb_Gb 0x28 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 258 | #define OP_SUB_Ev_Gv 0x29 | |
| 259 | #define OP_SUB_Gb_Eb 0x2a | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 260 | #define OP_SUB_Gv_Ev 0x2b | |
| 261 | #define OP_SUB_AL_Ib 0x2c | |
| 262 | #define OP_SUB_eAX_Iv 0x2d | |
| 263 | #define PREFIX_CS 0x2e | |
| 264 | #define OP_DAS 0x2f | |
| 265 | ||
| 266 | #define OP_XOR_Eb_Gb 0x30 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 267 | #define OP_XOR_Ev_Gv 0x31 | |
| 268 | #define OP_XOR_Gb_Eb 0x32 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 269 | #define OP_XOR_Gv_Ev 0x33 | |
| 270 | #define OP_XOR_AL_Ib 0x34 | |
| 271 | #define OP_XOR_rAX_Iz 0x35 | |
| 272 | #define PREFIX_SS 0x36 | |
| 273 | #define OP_AAA 0x37 | |
| 274 | #define OP_CMP_Eb_Gb 0x38 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 275 | #define OP_CMP_Ev_Gv 0x39 | |
| 276 | #define OP_CMP_Gb_Eb 0x3a | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 277 | #define OP_CMP_Gv_Ev 0x3b | |
| 278 | #define OP_CMP_AL_Ib 0x3c | |
| 279 | #define OP_CMP_eAX_Iv 0x3d | |
| 280 | #define PREFIX_DS 0x3e | |
| 281 | #define OP_AAS 0x3f | |
| 282 | ||
| 283 | #define OP_REX 0x40 | |
| 284 | #define OP_REX_B 0x41 | |
| 285 | #define OP_REX_X 0x42 | |
| 286 | #define OP_REX_XB 0x43 | |
| 287 | #define OP_REX_R 0x44 | |
| 288 | #define OP_REX_RB 0x45 | |
| 289 | #define OP_REX_RX 0x46 | |
| 290 | #define OP_REX_RXB 0x47 | |
| 291 | #define OP_REX_W 0x48 | |
| 292 | #define OP_REX_WB 0x49 | |
| 293 | #define OP_REX_WX 0x4a | |
| 294 | #define OP_REX_WXB 0x4b | |
| 295 | #define OP_REX_WR 0x4c | |
| 296 | #define OP_REX_WRB 0x4d | |
| 297 | #define OP_REX_WRX 0x4e | |
| 298 | #define OP_REX_WRXB 0x4f | |
| 299 | ||
| 300 | #define OP_PUSH_rAX 0x50 | |
| 301 | #define OP_PUSH_rCX 0x51 | |
| 302 | #define OP_PUSH_rDX 0x52 | |
| 303 | #define OP_PUSH_rBX 0x53 | |
| 304 | #define OP_PUSH_rSP 0x54 | |
| 305 | #define OP_PUSH_rBP 0x55 | |
| 306 | #define OP_PUSH_rSI 0x56 | |
| 307 | #define OP_PUSH_rDI 0x57 | |
| 308 | #define OP_POP_rAX 0x58 | |
| 309 | #define OP_POP_rCX 0x59 | |
| 310 | #define OP_POP_rDX 0x5a | |
| 311 | #define OP_POP_rBX 0x5b | |
| 312 | #define OP_POP_rSP 0x5c | |
| 313 | #define OP_POP_rBP 0x5d | |
| 314 | #define OP_POP_rSI 0x5e | |
| 315 | #define OP_POP_rDI 0x5f | |
| 316 | ||
| 317 | #define OP_PUSHA 0x60 | |
| 318 | #define OP_POPA 0x61 | |
| 319 | #define OP_BOUND_Gv_Ma 0x62 | |
| 320 | #define OP_ARPL_Ew_Gw 0x63 | |
| 321 | #define OP_MOVSXD_Gv_Ev 0x63 | |
| 322 | #define PREFIX_FS 0x64 | |
| 323 | #define PREFIX_GS 0x65 | |
| 324 | #define PREFIX_OPSIZE 0x66 | |
| 325 | #define PREFIX_ADSIZE 0x67 | |
| 326 | #define OP_PUSH_Iz 0x68 | |
| 327 | #define OP_IMUL_Gv_Ev_Iz 0x69 | |
| 328 | #define OP_PUSH_Ib 0x6a | |
| 329 | #define OP_IMUL_Gv_Ev_Ib 0x6b | |
| 330 | #define OP_INS_Yb_DX 0x6c | |
| 331 | #define OP_INS_Yz_DX 0x6d | |
| 332 | #define OP_OUTS_DX_Xb 0x6e | |
| 333 | #define OP_OUTS_DX_Xz 0x6f | |
| 334 | ||
| 335 | #define OP_JCC_O_Jb 0x70 | |
| 336 | #define OP_JCC_NO_Jb 0x71 | |
| 337 | #define OP_JCC_B_Jb 0x72 | |
| 338 | #define OP_JCC_C_Jb 0x72 | |
| 339 | #define OP_JCC_NAE_Jb 0x72 | |
| 340 | #define OP_JCC_AE_Jb 0x73 | |
| 341 | #define OP_JCC_NB_Jb 0x73 | |
| 342 | #define OP_JCC_NC_Jb 0x73 | |
| 343 | #define OP_JCC_E_Jb 0x74 | |
| 344 | #define OP_JCC_Z_Jb 0x74 | |
| 345 | #define OP_JCC_NE_Jb 0x75 | |
| 346 | #define OP_JCC_NZ_Jb 0x75 | |
| 347 | #define OP_JCC_BE_Jb 0x76 | |
| 348 | #define OP_JCC_NA_Jb 0x76 | |
| 349 | #define OP_JCC_A_Jb 0x77 | |
| 350 | #define OP_JCC_NBE_Jb 0x77 | |
| 351 | #define OP_JCC_S_Jb 0x78 | |
| 352 | #define OP_JCC_NS_Jb 0x79 | |
| 353 | #define OP_JCC_P_Jb 0x7a | |
| 354 | #define OP_JCC_PE_Jb 0x7a | |
| 355 | #define OP_JCC_NP_Jb 0x7b | |
| 356 | #define OP_JCC_PO_Jb 0x7b | |
| 357 | #define OP_JCC_L_Jb 0x7c | |
| 358 | #define OP_JCC_NGE_Jb 0x7c | |
| 359 | #define OP_JCC_NL_Jb 0x7d | |
| 360 | #define OP_JCC_GE_Jb 0x7d | |
| 361 | #define OP_JCC_LE_Jb 0x7e | |
| 362 | #define OP_JCC_NG_Jb 0x7e | |
| 363 | #define OP_JCC_NLE_Jb 0x7f | |
| 364 | #define OP_JCC_G_Jb 0x7f | |
| 365 | ||
| 366 | #define OP_G1_Eb_Ib 0x80 | OPFLAG_8BITRM | |
| 367 | #define OP_G1_Ev_Iz 0x81 | |
| 368 | #define OP_G1_Eb_Ibx 0x82 | OPFLAG_8BITRM | |
| 369 | #define OP_G1_Ev_Ib 0x83 | |
| 370 | #define OP_TEST_Eb_Gb 0x84 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 371 | #define OP_TEST_Ev_Gv 0x85 | |
| 372 | #define OP_XCHG_Eb_Gb 0x86 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 373 | #define OP_XCHG_Ev_Gv 0x87 | |
| 374 | #define OP_MOV_Eb_Gb 0x88 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 375 | #define OP_MOV_Ev_Gv 0x89 | |
| 376 | #define OP_MOV_Gb_Eb 0x8a | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 377 | #define OP_MOV_Gv_Ev 0x8b | |
| 378 | #define OP_MOV_Ev_Sw 0x8c | |
| 379 | #define OP_LEA_Gv_M 0x8d | |
| 380 | #define OP_MOV_Sw_Ew 0x8e | |
| 381 | #define OP_G1A_Ev 0x8f | |
| 382 | ||
| 383 | #define OP_NOP 0x90 | |
| 384 | #define OP_PAUSE 0x90 | |
| 385 | #define OP_XCHG_rCX 0x91 | |
| 386 | #define OP_XCHG_rDX 0x92 | |
| 387 | #define OP_XCHG_rBX 0x93 | |
| 388 | #define OP_XCHG_rSP 0x94 | |
| 389 | #define OP_XCHG_rBP 0x95 | |
| 390 | #define OP_XCHG_rSI 0x96 | |
| 391 | #define OP_XCHG_rDI 0x97 | |
| 392 | #define OP_CBW 0x98 | |
| 393 | #define OP_CWDE 0x98 | |
| 394 | #define OP_CDQE 0x98 | |
| 395 | #define OP_CWD 0x99 | |
| 396 | #define OP_CDQ 0x99 | |
| 397 | #define OP_CQO 0x99 | |
| 398 | #define OP_CALLF_Ap 0x9a | |
| 399 | #define OP_FWAIT 0x9b | |
| 400 | #define OP_PUSHF_Fv 0x9c | |
| 401 | #define OP_POPF_Fv 0x9d | |
| 402 | #define OP_SAHF 0x9e | |
| 403 | #define OP_LAHF 0x9f | |
| 404 | ||
| 405 | #define OP_MOV_AL_Ob 0xa0 | |
| 406 | #define OP_MOV_rAX_Ov 0xa1 | |
| 407 | #define OP_MOV_Ob_AL 0xa2 | |
| 408 | #define OP_MOV_Ov_rAX 0xa3 | |
| 409 | #define OP_MOVS_Xb_Yb 0xa4 | |
| 410 | #define OP_MOVS_Xv_Yv 0xa5 | |
| 411 | #define OP_CMPS_Xb_Yb 0xa6 | |
| 412 | #define OP_CMPS_Xv_Yv 0xa7 | |
| 413 | #define OP_TEST_AL_Ib 0xa8 | |
| 414 | #define OP_TEST_rAX_Iz 0xa9 | |
| 415 | #define OP_STOS_Yb_AL 0xaa | |
| 416 | #define OP_STOS_Yv_rAX 0xab | |
| 417 | #define OP_LODS_AL_Xb 0xac | |
| 418 | #define OP_LODS_rAX_Xv 0xad | |
| 419 | #define OP_SCAS_AL_Yb 0xae | |
| 420 | #define OP_SCAC_rAX_Yv 0xaf | |
| 421 | ||
| 422 | #define OP_MOV_AL_Ib 0xb0 | |
| 423 | #define OP_MOV_CL_Ib 0xb1 | |
| 424 | #define OP_MOV_DL_Ib 0xb2 | |
| 425 | #define OP_MOV_BL_Ib 0xb3 | |
| 426 | #define OP_MOV_AH_Ib 0xb4 | |
| 427 | #define OP_MOV_CH_Ib 0xb5 | |
| 428 | #define OP_MOV_DH_Ib 0xb6 | |
| 429 | #define OP_MOV_BH_Ib 0xb7 | |
| 430 | #define OP_MOV_rAX_Iv 0xb8 | |
| 431 | #define OP_MOV_rCX_Iv 0xb9 | |
| 432 | #define OP_MOV_rDX_Iv 0xba | |
| 433 | #define OP_MOV_rBX_Iv 0xbb | |
| 434 | #define OP_MOV_rSP_Iv 0xbc | |
| 435 | #define OP_MOV_rBP_Iv 0xbd | |
| 436 | #define OP_MOV_rSI_Iv 0xbe | |
| 437 | #define OP_MOV_rDI_Iv 0xbf | |
| 438 | ||
| 439 | #define OP_G2_Eb_Ib 0xc0 | OPFLAG_8BITRM | |
| 440 | #define OP_G2_Ev_Ib 0xc1 | |
| 441 | #define OP_RETN_Iw 0xc2 | |
| 442 | #define OP_RETN 0xc3 | |
| 443 | #define OP_LES_Gz_Mp 0xc4 | |
| 444 | #define OP_LDS_Gz_Mp 0xc5 | |
| 445 | #define OP_G11_Eb_Ib 0xc6 | OPFLAG_8BITRM | |
| 446 | #define OP_G11_Ev_Iz 0xc7 | |
| 447 | #define OP_ENTER_Iw_Ib 0xc8 | |
| 448 | #define OP_LEAVE 0xc9 | |
| 449 | #define OP_RETF_Iw 0xca | |
| 450 | #define OP_RETF 0xcb | |
| 451 | #define OP_INT_3 0xcc | |
| 452 | #define OP_INT_Ib 0xcd | |
| 453 | #define OP_INTO 0xce | |
| 454 | #define OP_IRET 0xcf | |
| 455 | ||
| 456 | #define OP_G2_Eb_1 0xd0 | OPFLAG_8BITRM | |
| 457 | #define OP_G2_Ev_1 0xd1 | |
| 458 | #define OP_G2_Eb_CL 0xd2 | OPFLAG_8BITRM | |
| 459 | #define OP_G2_Ev_CL 0xd3 | |
| 460 | #define OP_AAM 0xd4 | |
| 461 | #define OP_AAD 0xd5 | |
| 462 | #define OP_XLAT 0xd7 | |
| 463 | #define OP_ESC_D8 0xd8 | |
| 464 | #define OP_ESC_D9 0xd9 | |
| 465 | #define OP_ESC_DA 0xda | |
| 466 | #define OP_ESC_DB 0xdb | |
| 467 | #define OP_ESC_DC 0xdc | |
| 468 | #define OP_ESC_DD 0xdd | |
| 469 | #define OP_ESC_DE 0xde | |
| 470 | #define OP_ESC_DF 0xdf | |
| 471 | ||
| 472 | #define OP_LOOPNE_Jb 0xe0 | |
| 473 | #define OP_LOOPE_Jb 0xe1 | |
| 474 | #define OP_LOOP_Jb 0xe2 | |
| 475 | #define OP_JrCXZ_Jb 0xe3 | |
| 476 | #define OP_IN_AL_Ib 0xe4 | |
| 477 | #define OP_IN_eAX_Ib 0xe5 | |
| 478 | #define OP_OUT_Ib_AL 0xe6 | |
| 479 | #define OP_OUT_Ib_eAX 0xe7 | |
| 480 | #define OP_CALL_Jz 0xe8 | |
| 481 | #define OP_JMP_Jz 0xe9 | |
| 482 | #define OP_JMPF_AP 0xea | |
| 483 | #define OP_JMP_Jb 0xeb | |
| 484 | #define OP_IN_AL_DX 0xec | |
| 485 | #define OP_IN_eAX_D 0xed | |
| 486 | #define OP_OUT_DX_AL 0xee | |
| 487 | #define OP_OUT_DX_eAX 0xef | |
| 488 | ||
| 489 | #define PREFIX_LOCK 0xf0 | |
| 490 | #define PREFIX_REPNE 0xf2 | |
| 491 | #define PREFIX_REPE 0xf3 | |
| 492 | #define OP_HLT 0xf4 | |
| 493 | #define OP_CMC 0xf5 | |
| 494 | #define OP_G3_Eb 0xf6 | OPFLAG_8BITRM | |
| 495 | #define OP_G3_Ev 0xf7 | |
| 496 | #define OP_CLC 0xf8 | |
| 497 | #define OP_STC 0xf9 | |
| 498 | #define OP_CLI 0xfa | |
| 499 | #define OP_STI 0xfb | |
| 500 | #define OP_CLD 0xfc | |
| 501 | #define OP_STD 0xfd | |
| 502 | #define OP_G4 0xfe | |
| 503 | #define OP_G5 0xff | |
| 504 | ||
| 505 | ||
| 506 | /* double byte opcodes */ | |
| 507 | #define OP_G6 0x0f00 | |
| 508 | #define OP_G7 0x0f01 | |
| 509 | #define OP_LAR_Gv_Ew 0x0f02 | |
| 510 | #define OP_LSL_Gv_Ew 0x0f03 | |
| 511 | #define OP_SYSCALL 0x0f05 | |
| 512 | #define OP_CLTS 0x0f06 | |
| 513 | #define OP_SYSRET 0x0f07 | |
| 514 | #define OP_INVD 0x0f08 | |
| 515 | #define OP_WBINVD 0x0f09 | |
| 516 | #define OP_UD2 0x0f0b | |
| 517 | ||
| 518 | #define OP_MOVUPS_Vps_Wps 0x0f10 | |
| 519 | #define OP_MOVSS_Vss_Wss 0xf30f10 | |
| 520 | #define OP_MOVUPD_Vpd_Wpd 0x660f10 | |
| 521 | #define OP_MOVSD_Vsd_Wsd 0xf20f10 | |
| 522 | #define OP_MOVUPS_Wps_Vps 0x0f11 | |
| 523 | #define OP_MOVSS_Wss_Vss 0xf30f11 | |
| 524 | #define OP_MOVUPD_Wpd_Vpd 0x660f11 | |
| 525 | #define OP_MOVSD_Wsd_Vsd 0xf20f11 | |
| 526 | #define OP_MOVLPS_Vq_Mq 0x0f12 | |
| 527 | #define OP_MOVLPD_Vq_Mq 0x660f12 | |
| 528 | #define OP_MOVHLPS_Vq_Uq 0x0f12 | |
| 529 | #define OP_MOVDDUP_Vq_Wq 0xf20f12 | |
| 530 | #define OP_MOVSLDUP_Vq_Wq 0xf30f12 | |
| 531 | #define OP_MOVLPS_Mq_Vq 0x0f13 | |
| 532 | #define OP_MOVLPD_Mq_Vq 0x660f13 | |
| 533 | #define OP_UNPCKLPS_Vps_Wq 0x0f14 | |
| 534 | #define OP_UNPCKLPD_Vpd_Wq 0x660f14 | |
| 535 | #define OP_UNPCKHPS_Vps_Wq 0x0f15 | |
| 536 | #define OP_UNPCKHPD_Vpd_Wq 0x660f15 | |
| 537 | #define OP_MOVHPS_Vq_Mq 0x0f16 | |
| 538 | #define OP_MOVHPD_Vq_Mq 0x660f16 | |
| 539 | #define OP_MOVLHPS_Vq_Uq 0x0f16 | |
| 540 | #define OP_MOVSHDUP_Vq_Wq 0xf30f16 | |
| 541 | #define OP_MOVHPS_Mq_Vq 0x0f17 | |
| 542 | #define OP_MOVHPD_Mq_Vq 0x660f17 | |
| 543 | #define OP_PREFETCH_G16 0x0f18 | |
| 544 | ||
| 545 | #define OP_MOV_Rd_Cd 0x0f20 | |
| 546 | #define OP_MOV_Rd_Dd 0x0f21 | |
| 547 | #define OP_MOV_Cd_Rd 0x0f22 | |
| 548 | #define OP_MOV_Dd_Rd 0x0f23 | |
| 549 | #define OP_MOVAPS_Vps_Wps 0x0f28 | |
| 550 | #define OP_MOVAPD_Vpd_Wpd 0x660f28 | |
| 551 | #define OP_MOVAPS_Wps_Vps 0x0f29 | |
| 552 | #define OP_MOVAPD_Wpd_Vpd 0x660f29 | |
| 553 | #define OP_CVTPI2PS_Vps_Qq 0x0f2a | |
| 554 | #define OP_CVTSI2SS_Vss_Ed 0xf30f2a | |
| 555 | #define OP_CVTPI2PD_Vpd_Qq 0x660f2a | |
| 556 | #define OP_CVTSI2SD_Vsd_Ed 0xf20f2a | |
| 557 | #define OP_MOVNTPS_Mps_Vps 0x0f2b | |
| 558 | #define OP_MOVNTPD_Mpd_Vpd 0x660f2b | |
| 559 | #define OP_CVTTPS2PI_Pq_Wq 0x0f2c | |
| 560 | #define OP_CVTTSS2SI_Gd_Wss 0xf30f2c | |
| 561 | #define OP_CVTTPD2PI_Pq_Wpd 0x660f2c | |
| 562 | #define OP_CVTTSD2SI_Gd_Wsd 0xf20f2c | |
| 563 | #define OP_CVTPS2PI_Pq_Wq 0x0f2d | |
| 564 | #define OP_CVTSS2SI_Gd_Wss 0xf30f2d | |
| 565 | #define OP_CVTPD2PI_Pq_Wpd 0x660f2d | |
| 566 | #define OP_CVTSD2SI_Gd_Wsd 0xf20f2d | |
| 567 | #define OP_UCOMISS_Vss_Wss 0x0f2e | |
| 568 | #define OP_UCOMISD_Vsd_Wsd 0x660f2e | |
| 569 | #define OP_COMISS_Vss_Wss 0x0f2f | |
| 570 | #define OP_COMISD_Vsd_Wsd 0x660f2f | |
| 571 | ||
| 572 | #define OP_WRMSR 0x0f30 | |
| 573 | #define OP_RDTSC 0x0f31 | |
| 574 | #define OP_RDMSR 0x0f32 | |
| 575 | #define OP_RDPMC 0x0f33 | |
| 576 | #define OP_SYSENTER 0x0f34 | |
| 577 | #define OP_SYSEXIT 0x0f35 | |
| 578 | ||
| 579 | #define OP_CMOV_O_Gv_Ev 0x0f40 | |
| 580 | #define OP_CMOV_NO_Gv_Ev 0x0f41 | |
| 581 | #define OP_CMOV_B_Gv_Ev 0x0f42 | |
| 582 | #define OP_CMOV_C_Gv_Ev 0x0f42 | |
| 583 | #define OP_CMOV_AE_Gv_Ev 0x0f43 | |
| 584 | #define OP_CMOV_NC_Gv_Ev 0x0f43 | |
| 585 | #define OP_CMOV_E_Gv_Ev 0x0f44 | |
| 586 | #define OP_CMOV_Z_Gv_Ev 0x0f44 | |
| 587 | #define OP_CMOV_NE_Gv_Ev 0x0f45 | |
| 588 | #define OP_CMOV_NZ_Gv_Ev 0x0f45 | |
| 589 | #define OP_CMOV_BE_Gv_Ev 0x0f46 | |
| 590 | #define OP_CMOV_A_Gv_Ev 0x0f47 | |
| 591 | #define OP_CMOV_S_Gv_Ev 0x0f48 | |
| 592 | #define OP_CMOV_NS_Gv_Ev 0x0f49 | |
| 593 | #define OP_CMOV_P_Gv_Ev 0x0f4a | |
| 594 | #define OP_CMOV_PE_Gv_Ev 0x0f4a | |
| 595 | #define OP_CMOV_NP_Gv_Ev 0x0f4b | |
| 596 | #define OP_CMOV_PO_Gv_Ev 0x0f4b | |
| 597 | #define OP_CMOV_L_Gv_Ev 0x0f4c | |
| 598 | #define OP_CMOV_NGE_Gv_Ev 0x0f4c | |
| 599 | #define OP_CMOV_NL_Gv_Ev 0x0f4d | |
| 600 | #define OP_CMOV_GE_Gv_Ev 0x0f4d | |
| 601 | #define OP_CMOV_LE_Gv_Ev 0x0f4e | |
| 602 | #define OP_CMOV_NG_Gv_Ev 0x0f4e | |
| 603 | #define OP_CMOV_NLE_Gv_Ev 0x0f4f | |
| 604 | #define OP_CMOV_G_Gv_Ev 0x0f4f | |
| 605 | ||
| 606 | #define OP_MOVMSKPS_Gd_Ups 0x0f50 | |
| 607 | #define OP_MOVMSKPD_Gd_Upd 0x660f50 | |
| 608 | #define OP_SQRTPS_Vps_Wps 0x0f51 | |
| 609 | #define OP_SQRTSS_Vss_Wss 0xf30f51 | |
| 610 | #define OP_SQRTPD_Vpd_Wpd 0x660f51 | |
| 611 | #define OP_SQRTSD_Vsd_Wsd 0xf20f51 | |
| 612 | #define OP_RSQRTPS_Vps_Wps 0x0f52 | |
| 613 | #define OP_RSQRTSS_Vss_Wss 0xf30f52 | |
| 614 | #define OP_RCPPS_Vps_Wps 0x0f53 | |
| 615 | #define OP_RCPSS_Vss_Wss 0xf30f53 | |
| 616 | #define OP_ANDPS_Vps_Wps 0x0f54 | |
| 617 | #define OP_ANDPD_Vpd_Wpd 0x660f54 | |
| 618 | #define OP_ANDNPS_Vps_Wps 0x0f55 | |
| 619 | #define OP_ANDNPD_Vpd_Wpd 0x660f55 | |
| 620 | #define OP_ORPS_Vps_Wps 0x0f56 | |
| 621 | #define OP_ORPD_Vpd_Wpd 0x660f56 | |
| 622 | #define OP_XORPS_Vps_Wps 0x0f57 | |
| 623 | #define OP_XORPD_Vpd_Wpd 0x660f57 | |
| 624 | #define OP_ADDPS_Vps_Wps 0x0f58 | |
| 625 | #define OP_ADDSS_Vss_Wss 0xf30f58 | |
| 626 | #define OP_ADDPD_Vpd_Wpd 0x660f58 | |
| 627 | #define OP_ADDSD_Vsd_Wsd 0xf20f58 | |
| 628 | #define OP_MULPS_Vps_Wps 0x0f59 | |
| 629 | #define OP_MULSS_Vss_Wss 0xf30f59 | |
| 630 | #define OP_MULPD_Vpd_Wpd 0x660f59 | |
| 631 | #define OP_MULSD_Vsd_Wsd 0xf20f59 | |
| 632 | #define OP_CVTPS2PD_Vpd_Wq 0x0f5a | |
| 633 | #define OP_CVTSS2SD_Vsd_Wss 0xf30f5a | |
| 634 | #define OP_CVTPD2PS_Vps_Wpd 0x660f5a | |
| 635 | #define OP_CVTSD2SS_Vss_Wsd 0xf20f5a | |
| 636 | #define OP_CVTDQ2PS_Vps_Wdq 0x0f5b | |
| 637 | #define OP_CVTPS2DQ_Vdq_Wps 0x660f5b | |
| 638 | #define OP_CVTTPS2DQ_Vdq_Wps 0xf30f5b | |
| 639 | #define OP_SUBPS_Vps_Wps 0x0f5c | |
| 640 | #define OP_SUBSS_Vss_Wss 0xf30f5c | |
| 641 | #define OP_SUBPD_Vpd_Wpd 0x660f5c | |
| 642 | #define OP_SUBSD_Vsd_Wsd 0xf20f5c | |
| 643 | #define OP_MINPS_Vps_Wps 0x0f5d | |
| 644 | #define OP_MINSS_Vss_Wss 0xf30f5d | |
| 645 | #define OP_MINPD_Vpd_Wpd 0x660f5d | |
| 646 | #define OP_MINSD_Vsd_Wsd 0xf20f5d | |
| 647 | #define OP_DIVPS_Vps_Wps 0x0f5e | |
| 648 | #define OP_DIVSS_Vss_Wss 0xf30f5e | |
| 649 | #define OP_DIVPD_Vpd_Wpd 0x660f5e | |
| 650 | #define OP_DIVSD_Vsd_Wsd 0xf20f5e | |
| 651 | #define OP_MAXPS_Vps_Wps 0x0f5f | |
| 652 | #define OP_MAXSS_Vss_Wss 0xf30f5f | |
| 653 | #define OP_MAXPD_Vpd_Wpd 0x660f5f | |
| 654 | #define OP_MAXSD_Vsd_Wsd 0xf20f5f | |
| 655 | ||
| 656 | #define OP_PUNPCKLBW_Pq_Qd 0x0f60 | |
| 657 | #define OP_PUNPCKLBW_Vdq_Wdq 0x660f60 | |
| 658 | #define OP_PUNPCKLWD_Pq_Qd 0x0f61 | |
| 659 | #define OP_PUNPCKLWD_Vdq_Wdq 0x660f61 | |
| 660 | #define OP_PUNPCKLDQ_Pq_Qd 0x0f62 | |
| 661 | #define OP_PUNPCKLDQ_Vdq_Wdq 0x660f62 | |
| 662 | #define OP_PACKSSWB_Pq_Qq 0x0f63 | |
| 663 | #define OP_PACKSSWB_Vdq_Wdq 0x660f63 | |
| 664 | #define OP_PCMPGTB_Pq_Qq 0x0f64 | |
| 665 | #define OP_PCMPGTB_Vdq_Wdq 0x660f64 | |
| 666 | #define OP_PCMPGTW_Pq_Qq 0x0f65 | |
| 667 | #define OP_PCMPGTW_Vdq_Wdq 0x660f65 | |
| 668 | #define OP_PCMPGTD_Pq_Qq 0x0f66 | |
| 669 | #define OP_PCMPGTD_Vdq_Wdq 0x660f66 | |
| 670 | #define OP_PACKUSWB_Pq_Qq 0x0f67 | |
| 671 | #define OP_PACKUSWB_Vdq_Wdq 0x660f67 | |
| 672 | #define OP_PUNPCKHBW_Pq_Qq 0x0f68 | |
| 673 | #define OP_PUNPCKHBW_Vdq_Qdq 0x660f68 | |
| 674 | #define OP_PUNPCKHWD_Pq_Qq 0x0f69 | |
| 675 | #define OP_PUNPCKHWD_Vdq_Qdq 0x660f69 | |
| 676 | #define OP_PUNPCKHDQ_Pq_Qq 0x0f6a | |
| 677 | #define OP_PUNPCKHDQ_Vdq_Qdq 0x660f6a | |
| 678 | #define OP_PACKSSDW_Pq_Qq 0x0f6b | |
| 679 | #define OP_PACKSSDW_Vdq_Qdq 0x660f6b | |
| 680 | #define OP_PUNPCKLQDQ_Vdq_Wdq 0x660f6c | |
| 681 | #define OP_PUNPCKHQDQ_Vdq_Wdq 0x660f6d | |
| 682 | #define OP_MOVD_Pd_Ed 0x0f6e | |
| 683 | #define OP_MOVD_Vd_Ed 0x660f6e | |
| 684 | #define OP_MOVQ_Pq_Qq 0x0f6f | |
| 685 | #define OP_MOVDQA_Vdq_Wdq 0x660f6f | |
| 686 | #define OP_MOVDQU_Vdq_Wdq 0xf30f6f | |
| 687 | ||
| 688 | #define OP_PSHUFW_Pq_Qq_Ib 0x0f70 | |
| 689 | #define OP_PSHUFD_Vdq_Wdq_Ib 0x660f70 | |
| 690 | #define OP_PSHUFHW_Vdq_Wdq_Ib 0xf30f70 | |
| 691 | #define OP_PSHUFLW_Vdq_Wdq_Ib 0xf20f70 | |
| 692 | #define OP_G12 0x0f71 | |
| 693 | #define OP_G13 0x0f72 | |
| 694 | #define OP_G14 0x0f73 | |
| 695 | #define OP_PCMPEQB_Pq_Qq 0x0f74 | |
| 696 | #define OP_PCMPEQB_Vdq_Wdq 0x660f74 | |
| 697 | #define OP_PCMPEQW_Pq_Qq 0x0f75 | |
| 698 | #define OP_PCMPEQW_Vdq_Wdq 0x660f75 | |
| 699 | #define OP_PCMPEQD_Pq_Qq 0x0f76 | |
| 700 | #define OP_PCMPEQD_Vdq_Wdq 0x660f76 | |
| 701 | #define OP_EMMS 0x0f77 | |
| 702 | #define OP_HADDPD_Vpd_Wpd 0x660f7c | |
| 703 | #define OP_HADDPS_Vps_Wps 0xf20f7c | |
| 704 | #define OP_HSUBPD_Vpd_Wpd 0x660f7d | |
| 705 | #define OP_HSUBPS_Vps_Wps 0xf20f7d | |
| 706 | #define OP_MOVD_Ed_Pd 0x0f7e | |
| 707 | #define OP_MOVD_Ed_Vd 0x660f7e | |
| 708 | #define OP_MOVQ_Vq_Wq 0xf30f7e | |
| 709 | #define OP_MOVQ_Qq_Pq 0x0f7f | |
| 710 | #define OP_MOVDQA_Wdq_Vdq 0x660f7f | |
| 711 | #define OP_MOVDQU_Wdq_Vdq 0xf30f7f | |
| 712 | ||
| 713 | #define OP_JCC_O_Jv 0x0f80 | |
| 714 | #define OP_JCC_NO_Jv 0x0f81 | |
| 715 | #define OP_JCC_B_Jv 0x0f82 | |
| 716 | #define OP_JCC_C_Jv 0x0f82 | |
| 717 | #define OP_JCC_NAE_Jv 0x0f82 | |
| 718 | #define OP_JCC_AE_Jv 0x0f83 | |
| 719 | #define OP_JCC_NB_Jv 0x0f83 | |
| 720 | #define OP_JCC_NC_Jv 0x0f83 | |
| 721 | #define OP_JCC_E_Jv 0x0f84 | |
| 722 | #define OP_JCC_Z_Jv 0x0f84 | |
| 723 | #define OP_JCC_NE_Jv 0x0f85 | |
| 724 | #define OP_JCC_NZ_Jv 0x0f85 | |
| 725 | #define OP_JCC_BE_Jv 0x0f86 | |
| 726 | #define OP_JCC_NA_Jv 0x0f86 | |
| 727 | #define OP_JCC_A_Jv 0x0f87 | |
| 728 | #define OP_JCC_NBE_Jv 0x0f87 | |
| 729 | #define OP_JCC_S_Jv 0x0f88 | |
| 730 | #define OP_JCC_NS_Jv 0x0f89 | |
| 731 | #define OP_JCC_P_Jv 0x0f8a | |
| 732 | #define OP_JCC_PE_Jv 0x0f8a | |
| 733 | #define OP_JCC_NP_Jv 0x0f8b | |
| 734 | #define OP_JCC_PO_Jv 0x0f8b | |
| 735 | #define OP_JCC_L_Jv 0x0f8c | |
| 736 | #define OP_JCC_NGE_Jv 0x0f8c | |
| 737 | #define OP_JCC_NL_Jv 0x0f8d | |
| 738 | #define OP_JCC_GE_Jv 0x0f8d | |
| 739 | #define OP_JCC_LE_Jv 0x0f8e | |
| 740 | #define OP_JCC_NG_Jv 0x0f8e | |
| 741 | #define OP_JCC_NLE_Jv 0x0f8f | |
| 742 | #define OP_JCC_G_Jv 0x0f8f | |
| 743 | ||
| 744 | #define OP_SETCC_O_Eb 0x0f90 | OPFLAG_8BITRM | |
| 745 | #define OP_SETCC_NO_Eb 0x0f91 | OPFLAG_8BITRM | |
| 746 | #define OP_SETCC_B_Eb 0x0f92 | OPFLAG_8BITRM | |
| 747 | #define OP_SETCC_C_Eb 0x0f92 | OPFLAG_8BITRM | |
| 748 | #define OP_SETCC_NAE_Eb 0x0f92 | OPFLAG_8BITRM | |
| 749 | #define OP_SETCC_AE_Eb 0x0f93 | OPFLAG_8BITRM | |
| 750 | #define OP_SETCC_NB_Eb 0x0f93 | OPFLAG_8BITRM | |
| 751 | #define OP_SETCC_NC_Eb 0x0f93 | OPFLAG_8BITRM | |
| 752 | #define OP_SETCC_E_Eb 0x0f94 | OPFLAG_8BITRM | |
| 753 | #define OP_SETCC_Z_Eb 0x0f94 | OPFLAG_8BITRM | |
| 754 | #define OP_SETCC_NE_Eb 0x0f95 | OPFLAG_8BITRM | |
| 755 | #define OP_SETCC_NZ_Eb 0x0f95 | OPFLAG_8BITRM | |
| 756 | #define OP_SETCC_BE_Eb 0x0f96 | OPFLAG_8BITRM | |
| 757 | #define OP_SETCC_NA_Eb 0x0f96 | OPFLAG_8BITRM | |
| 758 | #define OP_SETCC_A_Eb 0x0f97 | OPFLAG_8BITRM | |
| 759 | #define OP_SETCC_NBE_Eb 0x0f97 | OPFLAG_8BITRM | |
| 760 | #define OP_SETCC_S_Eb 0x0f98 | OPFLAG_8BITRM | |
| 761 | #define OP_SETCC_NS_Eb 0x0f99 | OPFLAG_8BITRM | |
| 762 | #define OP_SETCC_P_Eb 0x0f9a | OPFLAG_8BITRM | |
| 763 | #define OP_SETCC_PE_Eb 0x0f9a | OPFLAG_8BITRM | |
| 764 | #define OP_SETCC_NP_Eb 0x0f9b | OPFLAG_8BITRM | |
| 765 | #define OP_SETCC_PO_Eb 0x0f9b | OPFLAG_8BITRM | |
| 766 | #define OP_SETCC_L_Eb 0x0f9c | OPFLAG_8BITRM | |
| 767 | #define OP_SETCC_NGE_Eb 0x0f9c | OPFLAG_8BITRM | |
| 768 | #define OP_SETCC_NL_Eb 0x0f9d | OPFLAG_8BITRM | |
| 769 | #define OP_SETCC_GE_Eb 0x0f9d | OPFLAG_8BITRM | |
| 770 | #define OP_SETCC_LE_Eb 0x0f9e | OPFLAG_8BITRM | |
| 771 | #define OP_SETCC_NG_Eb 0x0f9e | OPFLAG_8BITRM | |
| 772 | #define OP_SETCC_NLE_Eb 0x0f9f | OPFLAG_8BITRM | |
| 773 | #define OP_SETCC_G_Eb 0x0f9f | OPFLAG_8BITRM | |
| 774 | ||
| 775 | #define OP_PUSH_FS 0x0fa0 | |
| 776 | #define OP_POP_FS 0x0fa1 | |
| 777 | #define OP_CPUID 0x0fa2 | |
| 778 | #define OP_BT_Ev_Gv 0x0fa3 | |
| 779 | #define OP_SHLD_Ev_Gv_Ib 0x0fa4 | |
| 780 | #define OP_SHLD_Ev_Gv_CL 0x0fa5 | |
| 781 | #define OP_PUSH_GS 0x0fa8 | |
| 782 | #define OP_POP_GS 0x0fa9 | |
| 783 | #define OP_RSM 0x0faa | |
| 784 | #define OP_BTS_Ev_Gv 0x0fab | |
| 785 | #define OP_SHRD_Ev_Gv_Ib 0x0fac | |
| 786 | #define OP_SHRD_Ev_Gv_CL 0x0fad | |
| 787 | #define OP_G16 0x0fae | |
| 788 | #define OP_IMUL_Gv_Ev 0x0faf | |
| 789 | ||
| 790 | #define OP_CMPXCHG_Eb_Gb 0x0fb0 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 791 | #define OP_CMPXCHG_Ev_Gv 0x0fb1 | |
| 792 | #define OP_LSS_Mp 0x0fb2 | |
| 793 | #define OP_BTR_Ev_Gv 0x0fb3 | |
| 794 | #define OP_LFS_Mp 0x0fb4 | |
| 795 | #define OP_LGS_Mp 0x0fb5 | |
| 796 | #define OP_MOVZX_Gv_Eb 0x0fb6 | OPFLAG_8BITRM | |
| 797 | #define OP_MOVZX_Gv_Ew 0x0fb7 | |
| 798 | #define OP_G10_INVALID 0x0fb9 | |
| 799 | #define OP_G8_Ev_Ib 0x0fba | |
| 800 | #define OP_BTC_Ev_Gv 0x0fbb | |
| 801 | #define OP_BSF_Gv_Ev 0x0fbc | |
| 802 | #define OP_BSR_Gv_Ev 0x0fbd | |
| 803 | #define OP_MOVSX_Gv_Eb 0x0fbe | OPFLAG_8BITRM | |
| 804 | #define OP_MOVSX_Gv_Ew 0x0fbf | |
| 805 | ||
| 806 | #define OP_XADD_Eb_Gb 0x0fc0 | OPFLAG_8BITRM | OPFLAG_8BITREG | |
| 807 | #define OP_XADD_Ev_Gv 0x0fc1 | |
| 808 | #define OP_CMPPS_Vps_Wps_Ib 0x0fc2 | |
| 809 | #define OP_CMPSS_Vss_Wss_Ib 0xf30fc2 | |
| 810 | #define OP_CMPPD_Vpd_Wpd_Ib 0x660fc2 | |
| 811 | #define OP_CMPSD_Vsd_Wsd_Ib 0xf20fc2 | |
| 812 | #define OP_MOVNTI_Md_Gd 0x0fc3 | |
| 813 | #define OP_PINSRW_Pw_Ew_Ib 0x0fc4 | |
| 814 | #define OP_PINSRW_Vw_Ew_Ib 0x660fc4 | |
| 815 | #define OP_PEXTRW_Gw_Pw_Ib 0x0fc5 | |
| 816 | #define OP_PEXTRW_Gw_Vw_Ib 0x660fc5 | |
| 817 | #define OP_SHUFPS_Vps_Wps_Ib 0x0fc6 | |
| 818 | #define OP_SHUFPD_Vpd_Wpd_Ib 0x660fc6 | |
| 819 | #define OP_G9 0x0fc7 | |
| 820 | #define OP_BSWAP_EAX 0x0fc8 | |
| 821 | #define OP_BSWAP_ECX 0x0fc9 | |
| 822 | #define OP_BSWAP_EDX 0x0fca | |
| 823 | #define OP_BSWAP_EBX 0x0fcb | |
| 824 | #define OP_BSWAP_ESP 0x0fcc | |
| 825 | #define OP_BSWAP_EBP 0x0fcd | |
| 826 | #define OP_BSWAP_ESI 0x0fce | |
| 827 | #define OP_BSWAP_EDI 0x0fcf | |
| 828 | ||
| 829 | #define OP_ADDSUBPD_Vpd_Wpd 0x0fd0 | |
| 830 | #define OP_ADDSUBPS_Vps_Wps 0xf20fd0 | |
| 831 | #define OP_PSRLW_Pq_Qq 0x0fd1 | |
| 832 | #define OP_PSRLW_Vdq_Wdq 0x660fd1 | |
| 833 | #define OP_PSRLD_Pq_Qq 0x0fd2 | |
| 834 | #define OP_PSRLD_Vdq_Wdq 0x660fd2 | |
| 835 | #define OP_PSRLQ_Pq_Qq 0x0fd3 | |
| 836 | #define OP_PSRLQ_Vdq_Wdq 0x660fd3 | |
| 837 | #define OP_PADDQ_Pq_Qq 0x0fd4 | |
| 838 | #define OP_PADDQ_Vdq_Wdq 0x660fd4 | |
| 839 | #define OP_PMULLW_Pq_Qq 0x0fd5 | |
| 840 | #define OP_PMULLW_Vdq_Wdq 0x660fd5 | |
| 841 | #define OP_MOVQ_Wq_Vq 0x0fd6 | |
| 842 | #define OP_MOVQ2DQ_Vdq_Qq 0xf30fd6 | |
| 843 | #define OP_MOVDQ2Q_Pq_Vq 0xf20fd6 | |
| 844 | #define OP_PMOVMSKB_Gd_Pq 0x0fd7 | |
| 845 | #define OP_PMOVMSKB_Gd_Vdq 0x660fd7 | |
| 846 | #define OP_PSUBUSB_Pq_Qq 0x0fd8 | |
| 847 | #define OP_PSUBUSB_Vdq_Wdq 0x660fd8 | |
| 848 | #define OP_PSUBUSW_Pq_Qq 0x0fd9 | |
| 849 | #define OP_PSUBUSW_Vdq_Wdq 0x660fd9 | |
| 850 | #define OP_PMINUB_Pq_Qq 0x0fda | |
| 851 | #define OP_PMINUB_Vdq_Wdq 0x660fda | |
| 852 | #define OP_PAND_Pq_Qq 0x0fdb | |
| 853 | #define OP_PAND_Vdq_Wdq 0x660fdb | |
| 854 | #define OP_PADDUSB_Pq_Qq 0x0fdc | |
| 855 | #define OP_PADDUSB_Vdq_Wdq 0x660fdc | |
| 856 | #define OP_PADDUSW_Pq_Qq 0x0fdd | |
| 857 | #define OP_PADDUSW_Vdq_Wdq 0x660fdd | |
| 858 | #define OP_PMAXUB_Pq_Qq 0x0fde | |
| 859 | #define OP_PMAXUB_Vdq_Wdq 0x660fde | |
| 860 | #define OP_PANDN_Pq_Qq 0x0fdf | |
| 861 | #define OP_PANDN_Vdq_Wdq 0x660fdf | |
| 862 | ||
| 863 | #define OP_PAVGB_Pq_Qq 0x0fe0 | |
| 864 | #define OP_PAVGB_Vdq_Wdq 0x660fe0 | |
| 865 | #define OP_PSRAW_Pq_Qq 0x0fe1 | |
| 866 | #define OP_PSRAW_Vdq_Wdq 0x660fe1 | |
| 867 | #define OP_PSRAD_Pq_Qq 0x0fe2 | |
| 868 | #define OP_PSRAD_Vdq_Wdq 0x660fe2 | |
| 869 | #define OP_PAVGW_Pq_Qq 0x0fe3 | |
| 870 | #define OP_PAVGW_Vdq_Wdq 0x660fe3 | |
| 871 | #define OP_PMULHUW_Pq_Qq 0x0fe4 | |
| 872 | #define OP_PMULHUW_Vdq_Wdq 0x660fe4 | |
| 873 | #define OP_PMULHW_Pq_Qq 0x0fe5 | |
| 874 | #define OP_PMULHW_Vdq_Wdq 0x660fe5 | |
| 875 | #define OP_CVTPD2DQ_Vdq_Wpd 0xf20fe6 | |
| 876 | #define OP_CVTTPD2DQ_Vdq_Wpd 0x660fe6 | |
| 877 | #define OP_CVTDQ2PD_Vpd_Wq 0xf30fe6 | |
| 878 | #define OP_MOVNTQ_Mq_Vq 0x0fe7 | |
| 879 | #define OP_MOVNTDQ_Mdq_Vdq 0x660fe7 | |
| 880 | #define OP_PSUBSB_Pq_Qq 0x0fe8 | |
| 881 | #define OP_PSUBSB_Vdq_Wdq 0x660fe8 | |
| 882 | #define OP_PSUBSW_Pq_Qq 0x0fe9 | |
| 883 | #define OP_PSUBSW_Vdq_Wdq 0x660fe9 | |
| 884 | #define OP_PMINSW_Pq_Qq 0x0fea | |
| 885 | #define OP_PMINSW_Vdq_Wdq 0x660fea | |
| 886 | #define OP_POR_Pq_Qq 0x0feb | |
| 887 | #define OP_POR_Vdq_Wdq 0x660feb | |
| 888 | #define OP_PADDSB_Pq_Qq 0x0fec | |
| 889 | #define OP_PADDSB_Vdq_Wdq 0x660fec | |
| 890 | #define OP_PADDSW_Pq_Qq 0x0fed | |
| 891 | #define OP_PADDSW_Vdq_Wdq 0x660fed | |
| 892 | #define OP_PMAXSW_Pq_Qq 0x0fee | |
| 893 | #define OP_PMAXSW_Vdq_Wdq 0x660fee | |
| 894 | #define OP_PXOR_Pq_Qq 0x0fef | |
| 895 | #define OP_PXOR_Vdq_Wdq 0x660fef | |
| 896 | ||
| 897 | #define OP_LDDQU_Vdq_Mdq 0xf20ff0 | |
| 898 | #define OP_PSLLW_Pq_Qq 0x0ff1 | |
| 899 | #define OP_PSLLW_Vdq_Wdq 0x660ff1 | |
| 900 | #define OP_PSLLD_Pq_Qq 0x0ff2 | |
| 901 | #define OP_PSLLD_Vdq_Wdq 0x660ff2 | |
| 902 | #define OP_PSLLQ_Pq_Qq 0x0ff3 | |
| 903 | #define OP_PSLLQ_Vdq_Wdq 0x660ff3 | |
| 904 | #define OP_PMULUDQ_Pq_Qq 0x0ff4 | |
| 905 | #define OP_PMULUDQ_Vdq_Wdq 0x660ff4 | |
| 906 | #define OP_PMADDWD_Pq_Qq 0x0ff5 | |
| 907 | #define OP_PMADDWD_Vdq_Wdq 0x660ff5 | |
| 908 | #define OP_PSADBW_Pq_Qq 0x0ff6 | |
| 909 | #define OP_PSADBW_Vdq_Wdq 0x660ff6 | |
| 910 | #define OP_MASKMOVQ_Pq_Qq 0x0ff7 | |
| 911 | #define OP_MASKMOVDQU_Vdq_Wdq 0x660ff7 | |
| 912 | #define OP_PSUBB_Pq_Qq 0x0ff8 | |
| 913 | #define OP_PSUBB_Vdq_Wdq 0x660ff8 | |
| 914 | #define OP_PSUBW_Pq_Qq 0x0ff9 | |
| 915 | #define OP_PSUBW_Vdq_Wdq 0x660ff9 | |
| 916 | #define OP_PSUBD_Pq_Qq 0x0ffa | |
| 917 | #define OP_PSUBD_Vdq_Wdq 0x660ffa | |
| 918 | #define OP_PSUBQ_Pq_Qq 0x0ffb | |
| 919 | #define OP_PSUBQ_Vdq_Wdq 0x660ffb | |
| 920 | #define OP_PADDB_Pq_Qq 0x0ffc | |
| 921 | #define OP_PADDB_Vdq_Wdq 0x660ffc | |
| 922 | #define OP_PADDW_Pq_Qq 0x0ffd | |
| 923 | #define OP_PADDW_Vdq_Wdq 0x660ffd | |
| 924 | #define OP_PADDD_Pq_Qq 0x0ffe | |
| 925 | #define OP_PADDD_Vdq_Wdq 0x660ffe | |
| 926 | ||
| 927 | ||
| 928 | /* floating point opcodes */ | |
| 929 | #define OP_FADD_ST0_STn 0xd8c0 | |
| 930 | #define OP_FMUL_ST0_STn 0xd8c8 | |
| 931 | #define OP_FCOM_ST0_STn 0xd8d0 | |
| 932 | #define OP_FCOMP_ST0_STn 0xd8d8 | |
| 933 | #define OP_FSUB_ST0_STn 0xd8e0 | |
| 934 | #define OP_FSUBR_ST0_STn 0xd8e8 | |
| 935 | #define OP_FDIV_ST0_STn 0xd8f0 | |
| 936 | #define OP_FDIVR_ST0_STn 0xd8f8 | |
| 937 | #define OP_FLD_ST0_STn 0xd9c0 | |
| 938 | #define OP_FXCH_ST0_STn 0xd9c8 | |
| 939 | #define OP_FNOP 0xd9d0 | |
| 940 | #define OP_FCHS 0xd9e0 | |
| 941 | #define OP_FABS 0xd9e1 | |
| 942 | #define OP_FTST 0xd9e4 | |
| 943 | #define OP_FXAM 0xd9e5 | |
| 944 | #define OP_FLD1 0xd9e8 | |
| 945 | #define OP_FLDL2T 0xd9e9 | |
| 946 | #define OP_FLDL2E 0xd9ea | |
| 947 | #define OP_FLDPI 0xd9eb | |
| 948 | #define OP_FLDLG2 0xd9ec | |
| 949 | #define OP_FLDLN2 0xd9ed | |
| 950 | #define OP_FLDZ 0xd9ee | |
| 951 | #define OP_F2XM1 0xd9f0 | |
| 952 | #define OP_FYL2X 0xd9f1 | |
| 953 | #define OP_FPTAN 0xd9f2 | |
| 954 | #define OP_FPATAN 0xd9f3 | |
| 955 | #define OP_FXTRACT 0xd9f4 | |
| 956 | #define OP_FPREM1 0xd9f5 | |
| 957 | #define OP_FDECSTP 0xd9f6 | |
| 958 | #define OP_FINCSTP 0xd9f7 | |
| 959 | #define OP_FPREM 0xd9f8 | |
| 960 | #define OP_FYL2XP1 0xd9f9 | |
| 961 | #define OP_FSQRT 0xd9fa | |
| 962 | #define OP_FSINCOS 0xd9fb | |
| 963 | #define OP_FRNDINT 0xd9fc | |
| 964 | #define OP_FSCALE 0xd9fd | |
| 965 | #define OP_FSIN 0xd9fe | |
| 966 | #define OP_FCOS 0xd9ff | |
| 967 | #define OP_FCMOVB_ST0_STn 0xdac0 | |
| 968 | #define OP_FCMOVE_ST0_STn 0xdac8 | |
| 969 | #define OP_FCMOVBE_ST0_STn 0xdad0 | |
| 970 | #define OP_FCMOVU_ST0_STn 0xdad8 | |
| 971 | #define OP_FUCOMPP 0xdae9 | |
| 972 | #define OP_FCMOVNB_ST0_STn 0xdbc0 | |
| 973 | #define OP_FCMOVNE_ST0_STn 0xdbc8 | |
| 974 | #define OP_FCMOVNBE_ST0_STn 0xdbd0 | |
| 975 | #define OP_FCMOVNU_ST0_STn 0xdbd8 | |
| 976 | #define OP_FCLEX 0xdbe2 | |
| 977 | #define OP_FINIT 0xdbe3 | |
| 978 | #define OP_FUCOMI_ST0_STn 0xdbe8 | |
| 979 | #define OP_FCOMI_ST0_STn 0xdbf0 | |
| 980 | #define OP_FADD_STn_ST0 0xdcc0 | |
| 981 | #define OP_FMUL_STn_ST0 0xdcc8 | |
| 982 | #define OP_FSUBR_STn_ST0 0xdce0 | |
| 983 | #define OP_FSUB_STn_ST0 0xdce8 | |
| 984 | #define OP_FDIVR_STn_ST0 0xdcf0 | |
| 985 | #define OP_FDIV_STn_ST0 0xdcf8 | |
| 986 | #define OP_FFREE_STn 0xddc0 | |
| 987 | #define OP_FST_STn 0xddd0 | |
| 988 | #define OP_FSTP_STn 0xddd8 | |
| 989 | #define OP_FUCOM_STn_ST0 0xdde0 | |
| 990 | #define OP_FUCOMP_STn 0xdde8 | |
| 991 | #define OP_FADDP_STn_ST0 0xdec0 | |
| 992 | #define OP_FMULP_STn_ST0 0xdec8 | |
| 993 | #define OP_FCOMPP 0xded9 | |
| 994 | #define OP_FSUBRP_STn_ST0 0xdee0 | |
| 995 | #define OP_FSUBP_STn_ST0 0xdee8 | |
| 996 | #define OP_FDIVRP_STn_ST0 0xdef0 | |
| 997 | #define OP_FDIVP_STn_ST0 0xdef8 | |
| 998 | #define OP_FSTSW_AX 0xdfe0 | |
| 999 | #define OP_FCOMIP_ST0_STn 0xdff0 | |
| 1000 | ||
| 1001 | ||
| 1002 | ||
| 1003 | /*************************************************************************** | |
| 1004 | TYPE DEFINITIONS | |
| 1005 | ***************************************************************************/ | |
| 1006 | ||
| 1007 | typedef UINT8 x86code; | |
| 1008 | ||
| 1009 | ||
| 1010 | typedef struct _emit_link emit_link; | |
| 1011 | struct _emit_link | |
| 1012 | { | |
| 1013 | x86code * target; | |
| 1014 | UINT8 size; | |
| 1015 | }; | |
| 1016 | ||
| 1017 | ||
| 1018 | ||
| 1019 | /*************************************************************************** | |
| 1020 | CORE FUNCTIONS | |
| 1021 | ***************************************************************************/ | |
| 1022 | ||
| 1023 | /*------------------------------------------------- | |
| 1024 | make_modrm - assemble a modrm byte from the | |
| 1025 | three components | |
| 1026 | -------------------------------------------------*/ | |
| 1027 | ||
| 1028 | INLINE UINT8 make_modrm(UINT8 mode, UINT8 reg, UINT8 rm) | |
| 1029 | { | |
| 1030 | assert(mode < 4); | |
| 1031 | assert(reg < REG_MAX); | |
| 1032 | assert(rm < REG_MAX); | |
| 1033 | return (mode << 6) | ((reg & 7) << 3) | (rm & 7); | |
| 1034 | } | |
| 1035 | ||
| 1036 | ||
| 1037 | /*------------------------------------------------- | |
| 1038 | make_sib - assemble an sib byte from the | |
| 1039 | three components | |
| 1040 | -------------------------------------------------*/ | |
| 1041 | ||
| 1042 | INLINE UINT8 make_sib(UINT8 scale, UINT8 index, UINT8 base) | |
| 1043 | { | |
| 1044 | static const UINT8 scale_lookup[9] = { 0<<6, 0<<6, 1<<6, 0<<6, 2<<6, 0<<6, 0<<6, 0<<6, 3<<6 }; | |
| 1045 | assert(scale == 1 || scale == 2 || scale == 4 || scale == 8); | |
| 1046 | assert(index < REG_MAX); | |
| 1047 | assert(base < REG_MAX); | |
| 1048 | return scale_lookup[scale] | ((index & 7) << 3) | (base & 7); | |
| 1049 | } | |
| 1050 | ||
| 1051 | ||
| 1052 | /*------------------------------------------------- | |
| 1053 | emit_byte - emit a byte | |
| 1054 | -------------------------------------------------*/ | |
| 1055 | ||
| 1056 | INLINE void emit_byte(x86code **emitptr, UINT8 byte) | |
| 1057 | { | |
| 1058 | *((UINT8 *)*emitptr) = byte; | |
| 1059 | *emitptr += 1; | |
| 1060 | } | |
| 1061 | ||
| 1062 | ||
| 1063 | /*------------------------------------------------- | |
| 1064 | emit_word - emit a word | |
| 1065 | -------------------------------------------------*/ | |
| 1066 | ||
| 1067 | INLINE void emit_word(x86code **emitptr, UINT16 word) | |
| 1068 | { | |
| 1069 | *((UINT16 *)*emitptr) = word; | |
| 1070 | *emitptr += 2; | |
| 1071 | } | |
| 1072 | ||
| 1073 | ||
| 1074 | /*------------------------------------------------- | |
| 1075 | emit_dword - emit a dword | |
| 1076 | -------------------------------------------------*/ | |
| 1077 | ||
| 1078 | INLINE void emit_dword(x86code **emitptr, UINT32 dword) | |
| 1079 | { | |
| 1080 | *((UINT32 *)*emitptr) = dword; | |
| 1081 | *emitptr += 4; | |
| 1082 | } | |
| 1083 | ||
| 1084 | ||
| 1085 | /*------------------------------------------------- | |
| 1086 | emit_qword - emit a dword | |
| 1087 | -------------------------------------------------*/ | |
| 1088 | ||
| 1089 | INLINE void emit_qword(x86code **emitptr, UINT64 qword) | |
| 1090 | { | |
| 1091 | *((UINT64 *)*emitptr) = qword; | |
| 1092 | *emitptr += 8; | |
| 1093 | } | |
| 1094 | ||
| 1095 | ||
| 1096 | ||
| 1097 | /*************************************************************************** | |
| 1098 | GENERIC OPCODE EMITTERS | |
| 1099 | ***************************************************************************/ | |
| 1100 | ||
| 1101 | /*------------------------------------------------- | |
| 1102 | emit_op - emit a 1, 2, or 3-byte opcode, | |
| 1103 | along with any necessary REX prefixes for x64 | |
| 1104 | -------------------------------------------------*/ | |
| 1105 | ||
| 1106 | INLINE void emit_op(x86code **emitptr, UINT32 op, UINT8 op64, UINT8 reg, UINT8 sib, UINT8 rm) | |
| 1107 | { | |
| 1108 | #ifdef PTR64 | |
| 1109 | UINT8 rex; | |
| 1110 | ||
| 1111 | assert(op64 == OP_32BIT || op64 == OP_64BIT); | |
| 1112 | ||
| 1113 | rex = op64 | ((reg & 8) >> 1) | ((sib & 8) >> 2) | ((rm & 8) >> 3); | |
| 1114 | if (rex != 0 || ((op & OPFLAG_8BITREG) && reg >= 4) || ((op & OPFLAG_8BITRM) && rm >= 4)) | |
| 1115 | emit_byte(emitptr, rex | 0x40); | |
| 1116 | #else | |
| 1117 | assert(op64 == OP_32BIT); | |
| 1118 | #endif | |
| 1119 | ||
| 1120 | if ((op & 0xff0000) != 0) | |
| 1121 | emit_byte(emitptr, op >> 16); | |
| 1122 | if ((op & 0xff00) != 0) | |
| 1123 | emit_byte(emitptr, op >> 8); | |
| 1124 | emit_byte(emitptr, op); | |
| 1125 | } | |
| 1126 | ||
| 1127 | ||
| 1128 | /*------------------------------------------------- | |
| 1129 | emit_op_simple - emit a simple opcode | |
| 1130 | -------------------------------------------------*/ | |
| 1131 | ||
| 1132 | INLINE void emit_op_simple(x86code **emitptr, UINT32 op, UINT8 op64) | |
| 1133 | { | |
| 1134 | emit_op(emitptr, op, op64, 0, 0, 0); | |
| 1135 | } | |
| 1136 | ||
| 1137 | ||
| 1138 | /*------------------------------------------------- | |
| 1139 | emit_op_modrm_reg - emit an opcode with a | |
| 1140 | register modrm byte | |
| 1141 | -------------------------------------------------*/ | |
| 1142 | ||
| 1143 | INLINE void emit_op_modrm_reg(x86code **emitptr, UINT32 op, UINT8 op64, UINT8 reg, UINT8 rm) | |
| 1144 | { | |
| 1145 | assert(reg < REG_MAX); | |
| 1146 | assert(rm < REG_MAX); | |
| 1147 | ||
| 1148 | emit_op(emitptr, op, op64, reg, 0, rm); | |
| 1149 | emit_byte(emitptr, make_modrm(3, reg, rm)); | |
| 1150 | } | |
| 1151 | ||
| 1152 | ||
| 1153 | /*------------------------------------------------- | |
| 1154 | emit_op_modrm_mem - emit an opcode with a | |
| 1155 | memory modrm byte | |
| 1156 | -------------------------------------------------*/ | |
| 1157 | ||
| 1158 | INLINE void emit_op_modrm_mem(x86code **emitptr, UINT32 op, UINT8 op64, UINT8 reg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1159 | { | |
| 1160 | assert(reg < REG_MAX); | |
| 1161 | assert(base < REG_MAX || base == REG_NONE); | |
| 1162 | assert(index < REG_MAX || index == REG_NONE); | |
| 1163 | ||
| 1164 | /* turn off the OPFLAG_8BITRM flag since it only applies to register operands */ | |
| 1165 | op &= ~OPFLAG_8BITRM; | |
| 1166 | ||
| 1167 | /* displacement only case */ | |
| 1168 | if (base == REG_NONE && index == REG_NONE) | |
| 1169 | { | |
| 1170 | #ifndef PTR64 | |
| 1171 | emit_op(emitptr, op, op64, reg, 0, 5); | |
| 1172 | emit_byte(emitptr, make_modrm(0, reg, 5)); | |
| 1173 | emit_dword(emitptr, disp); | |
| 1174 | #else | |
| 1175 | fatalerror("Invalid absolute mode in 64-bits!\n"); | |
| 1176 | #endif | |
| 1177 | } | |
| 1178 | ||
| 1179 | /* base only case */ | |
| 1180 | else if (index == REG_NONE && base != REG_ESP) | |
| 1181 | { | |
| 1182 | emit_op(emitptr, op, op64, reg, 0, base); | |
| 1183 | ||
| 1184 | /* mode 0 for no offset */ | |
| 1185 | if (disp == 0 && base != REG_EBP) | |
| 1186 | emit_byte(emitptr, make_modrm(0, reg, base)); | |
| 1187 | ||
| 1188 | /* mode 1 for 1-byte offset */ | |
| 1189 | else if ((INT8)disp == disp) | |
| 1190 | { | |
| 1191 | emit_byte(emitptr, make_modrm(1, reg, base)); | |
| 1192 | emit_byte(emitptr, (INT8)disp); | |
| 1193 | } | |
| 1194 | ||
| 1195 | /* mode 2 for 4-byte offset */ | |
| 1196 | else | |
| 1197 | { | |
| 1198 | emit_byte(emitptr, make_modrm(2, reg, base)); | |
| 1199 | emit_dword(emitptr, disp); | |
| 1200 | } | |
| 1201 | } | |
| 1202 | ||
| 1203 | /* full BISD case */ | |
| 1204 | else | |
| 1205 | { | |
| 1206 | assert(index != REG_ESP); | |
| 1207 | emit_op(emitptr, op, op64, reg, index, base); | |
| 1208 | ||
| 1209 | /* a "none" index == REG_ESP */ | |
| 1210 | if (index == REG_NONE) | |
| 1211 | index = REG_ESP; | |
| 1212 | ||
| 1213 | /* mode 0 for no offset */ | |
| 1214 | if (disp == 0 && base != REG_EBP) | |
| 1215 | { | |
| 1216 | emit_byte(emitptr, make_modrm(0, reg, 4)); | |
| 1217 | emit_byte(emitptr, make_sib(scale, index, (base == REG_NONE) ? REG_EBP : base)); | |
| 1218 | if (base == REG_NONE) | |
| 1219 | emit_dword(emitptr, disp); | |
| 1220 | } | |
| 1221 | ||
| 1222 | /* mode 1 for 1-byte offset */ | |
| 1223 | else if ((INT8)disp == disp) | |
| 1224 | { | |
| 1225 | emit_byte(emitptr, make_modrm(1, reg, 4)); | |
| 1226 | emit_byte(emitptr, make_sib(scale, index, base)); | |
| 1227 | emit_byte(emitptr, (INT8)disp); | |
| 1228 | } | |
| 1229 | ||
| 1230 | /* mode 2 for 4-byte offset */ | |
| 1231 | else | |
| 1232 | { | |
| 1233 | emit_byte(emitptr, make_modrm(2, reg, 4)); | |
| 1234 | emit_byte(emitptr, make_sib(scale, index, base)); | |
| 1235 | emit_dword(emitptr, disp); | |
| 1236 | } | |
| 1237 | } | |
| 1238 | } | |
| 1239 | ||
| 1240 | ||
| 1241 | ||
| 1242 | /*************************************************************************** | |
| 1243 | SIMPLE OPCODE EMITTERS | |
| 1244 | ***************************************************************************/ | |
| 1245 | ||
| 1246 | INLINE void emit_nop(x86code **emitptr) | |
| 1247 | { | |
| 1248 | emit_byte(emitptr, OP_NOP); | |
| 1249 | } | |
| 1250 | ||
| 1251 | INLINE void emit_int_3(x86code **emitptr) | |
| 1252 | { | |
| 1253 | emit_byte(emitptr, OP_INT_3); | |
| 1254 | } | |
| 1255 | ||
| 1256 | INLINE void emit_ret(x86code **emitptr) | |
| 1257 | { | |
| 1258 | emit_byte(emitptr, OP_RETN); | |
| 1259 | } | |
| 1260 | ||
| 1261 | INLINE void emit_cdq(x86code **emitptr) | |
| 1262 | { | |
| 1263 | emit_byte(emitptr, OP_CDQ); | |
| 1264 | } | |
| 1265 | ||
| 1266 | #ifdef PTR64 | |
| 1267 | INLINE void emit_cqo(x86code **emitptr) | |
| 1268 | { | |
| 1269 | emit_byte(emitptr, OP_REX_W); | |
| 1270 | emit_byte(emitptr, OP_CQO); | |
| 1271 | } | |
| 1272 | #endif | |
| 1273 | ||
| 1274 | ||
| 1275 | ||
| 1276 | /*************************************************************************** | |
| 1277 | CALL/JUMP EMITTERS | |
| 1278 | ***************************************************************************/ | |
| 1279 | ||
| 1280 | /*------------------------------------------------- | |
| 1281 | resolve_link - resolve a link in a jump | |
| 1282 | instruction | |
| 1283 | -------------------------------------------------*/ | |
| 1284 | ||
| 1285 | INLINE void resolve_link(x86code **destptr, const emit_link *linkinfo) | |
| 1286 | { | |
| 1287 | INT64 delta = *destptr - linkinfo->target; | |
| 1288 | if (linkinfo->size == 1) | |
| 1289 | { | |
| 1290 | assert((INT8)delta == delta); | |
| 1291 | ((INT8 *)linkinfo->target)[-1] = (INT8)delta; | |
| 1292 | } | |
| 1293 | else if (linkinfo->size == 2) | |
| 1294 | { | |
| 1295 | assert((INT16)delta == delta); | |
| 1296 | ((INT16 *)linkinfo->target)[-1] = (INT16)delta; | |
| 1297 | } | |
| 1298 | else | |
| 1299 | { | |
| 1300 | assert((INT32)delta == delta); | |
| 1301 | ((INT32 *)linkinfo->target)[-1] = (INT32)delta; | |
| 1302 | } | |
| 1303 | } | |
| 1304 | ||
| 1305 | ||
| 1306 | /*------------------------------------------------------------------ | |
| 1307 | emit_call_* | |
| 1308 | ------------------------------------------------------------------*/ | |
| 1309 | ||
| 1310 | INLINE void emit_call_link(x86code **emitptr, emit_link *linkinfo) | |
| 1311 | { | |
| 1312 | emit_op_simple(emitptr, OP_CALL_Jz, OP_32BIT); | |
| 1313 | emit_dword(emitptr, 0); | |
| 1314 | linkinfo->target = *emitptr; | |
| 1315 | linkinfo->size = 4; | |
| 1316 | } | |
| 1317 | ||
| 1318 | INLINE void emit_call(x86code **emitptr, x86code *target) | |
| 1319 | { | |
| 1320 | emit_link link; | |
| 1321 | ||
| 1322 | emit_call_link(emitptr, &link); | |
| 1323 | resolve_link(&target, &link); | |
| 1324 | } | |
| 1325 | ||
| 1326 | ||
| 1327 | /*------------------------------------------------------------------ | |
| 1328 | emit_call_r32_* | |
| 1329 | ------------------------------------------------------------------*/ | |
| 1330 | ||
| 1331 | #ifndef PTR64 | |
| 1332 | ||
| 1333 | INLINE void emit_call_r32(x86code **emitptr, UINT8 dreg) | |
| 1334 | { | |
| 1335 | emit_op_modrm_reg(emitptr, OP_G5, OP_32BIT, 2, dreg); | |
| 1336 | } | |
| 1337 | ||
| 1338 | INLINE void emit_call_m32bisd(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1339 | { | |
| 1340 | emit_op_modrm_mem(emitptr, OP_G5, OP_32BIT, 2, base, index, scale, disp); | |
| 1341 | } | |
| 1342 | ||
| 1343 | #define emit_call_m32abs(e, addr) emit_call_m32bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1344 | #define emit_call_m32bd(e, base, disp) emit_call_m32bisd(e, (base), REG_NONE, 1, (disp)) | |
| 1345 | #define emit_call_m32isd(e, index, scale, disp) emit_call_m32bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 1346 | ||
| 1347 | #endif | |
| 1348 | ||
| 1349 | ||
| 1350 | /*------------------------------------------------------------------ | |
| 1351 | emit_call_r64_* | |
| 1352 | ------------------------------------------------------------------*/ | |
| 1353 | ||
| 1354 | #ifdef PTR64 | |
| 1355 | ||
| 1356 | INLINE void emit_call_r64(x86code **emitptr, UINT8 dreg) | |
| 1357 | { | |
| 1358 | emit_op_modrm_reg(emitptr, OP_G5, OP_32BIT, 2, dreg); | |
| 1359 | } | |
| 1360 | ||
| 1361 | INLINE void emit_call_m64bisd(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1362 | { | |
| 1363 | emit_op_modrm_mem(emitptr, OP_G5, OP_32BIT, 2, base, index, scale, disp); | |
| 1364 | } | |
| 1365 | ||
| 1366 | #define emit_call_m64abs(e, addr) emit_call_m64bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1367 | #define emit_call_m64bd(e, base, disp) emit_call_m64bisd(e, (base), REG_NONE, 1, (disp)) | |
| 1368 | #define emit_call_m64isd(e, index, scale, disp) emit_call_m64bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 1369 | ||
| 1370 | #endif | |
| 1371 | ||
| 1372 | ||
| 1373 | /*------------------------------------------------------------------ | |
| 1374 | emit_jmp_* | |
| 1375 | ------------------------------------------------------------------*/ | |
| 1376 | ||
| 1377 | INLINE void emit_jmp_short_link(x86code **emitptr, emit_link *linkinfo) | |
| 1378 | { | |
| 1379 | emit_op_simple(emitptr, OP_JMP_Jb, OP_32BIT); | |
| 1380 | emit_byte(emitptr, 0); | |
| 1381 | linkinfo->target = *emitptr; | |
| 1382 | linkinfo->size = 1; | |
| 1383 | } | |
| 1384 | ||
| 1385 | INLINE void emit_jmp_near_link(x86code **emitptr, emit_link *linkinfo) | |
| 1386 | { | |
| 1387 | emit_op_simple(emitptr, OP_JMP_Jz, OP_32BIT); | |
| 1388 | emit_dword(emitptr, 0); | |
| 1389 | linkinfo->target = *emitptr; | |
| 1390 | linkinfo->size = 4; | |
| 1391 | } | |
| 1392 | ||
| 1393 | INLINE void emit_jmp(x86code **emitptr, x86code *target) | |
| 1394 | { | |
| 1395 | INT32 delta = target - (*emitptr + 2); | |
| 1396 | emit_link link; | |
| 1397 | ||
| 1398 | if ((INT8)delta == delta) | |
| 1399 | emit_jmp_short_link(emitptr, &link); | |
| 1400 | else | |
| 1401 | emit_jmp_near_link(emitptr, &link); | |
| 1402 | resolve_link(&target, &link); | |
| 1403 | } | |
| 1404 | ||
| 1405 | ||
| 1406 | /*------------------------------------------------------------------ | |
| 1407 | emit_jcc_* | |
| 1408 | ------------------------------------------------------------------*/ | |
| 1409 | ||
| 1410 | INLINE void emit_jcc_short_link(x86code **emitptr, UINT8 condition, emit_link *linkinfo) | |
| 1411 | { | |
| 1412 | emit_op_simple(emitptr, OP_JCC_O_Jb + condition, OP_32BIT); | |
| 1413 | emit_byte(emitptr, 0); | |
| 1414 | linkinfo->target = *emitptr; | |
| 1415 | linkinfo->size = 1; | |
| 1416 | } | |
| 1417 | ||
| 1418 | INLINE void emit_jcc_near_link(x86code **emitptr, UINT8 condition, emit_link *linkinfo) | |
| 1419 | { | |
| 1420 | emit_op_simple(emitptr, OP_JCC_O_Jv + condition, OP_32BIT); | |
| 1421 | emit_dword(emitptr, 0); | |
| 1422 | linkinfo->target = *emitptr; | |
| 1423 | linkinfo->size = 4; | |
| 1424 | } | |
| 1425 | ||
| 1426 | INLINE void emit_jcc(x86code **emitptr, UINT8 condition, x86code *target) | |
| 1427 | { | |
| 1428 | INT32 delta = *emitptr + 2 - target; | |
| 1429 | emit_link link; | |
| 1430 | ||
| 1431 | if ((INT8)delta == delta) | |
| 1432 | emit_jcc_short_link(emitptr, condition, &link); | |
| 1433 | else | |
| 1434 | emit_jcc_near_link(emitptr, condition, &link); | |
| 1435 | resolve_link(&target, &link); | |
| 1436 | } | |
| 1437 | ||
| 1438 | ||
| 1439 | /*------------------------------------------------------------------ | |
| 1440 | emit_jmp_r32_* | |
| 1441 | ------------------------------------------------------------------*/ | |
| 1442 | ||
| 1443 | #ifndef PTR64 | |
| 1444 | ||
| 1445 | INLINE void emit_jmp_r32(x86code **emitptr, UINT8 dreg) | |
| 1446 | { | |
| 1447 | emit_op_modrm_reg(emitptr, OP_G5, OP_32BIT, 4, dreg); | |
| 1448 | } | |
| 1449 | ||
| 1450 | INLINE void emit_jmp_m32bisd(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1451 | { | |
| 1452 | emit_op_modrm_mem(emitptr, OP_G5, OP_32BIT, 4, base, index, scale, disp); | |
| 1453 | } | |
| 1454 | ||
| 1455 | #define emit_jmp_m32abs(e, addr) emit_jmp_m32bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1456 | #define emit_jmp_m32bd(e, base, disp) emit_jmp_m32bisd(e, (base), REG_NONE, 1, (disp)) | |
| 1457 | #define emit_jmp_m32isd(e, index, scale, disp) emit_jmp_m32bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 1458 | ||
| 1459 | #endif | |
| 1460 | ||
| 1461 | ||
| 1462 | /*------------------------------------------------------------------ | |
| 1463 | emit_jmp_r64_* | |
| 1464 | ------------------------------------------------------------------*/ | |
| 1465 | ||
| 1466 | #ifdef PTR64 | |
| 1467 | ||
| 1468 | INLINE void emit_jmp_r64(x86code **emitptr, UINT8 dreg) | |
| 1469 | { | |
| 1470 | emit_op_modrm_reg(emitptr, OP_G5, OP_32BIT, 4, dreg); | |
| 1471 | } | |
| 1472 | ||
| 1473 | INLINE void emit_jmp_m64bisd(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1474 | { | |
| 1475 | emit_op_modrm_mem(emitptr, OP_G5, OP_32BIT, 4, base, index, scale, disp); | |
| 1476 | } | |
| 1477 | ||
| 1478 | #define emit_jmp_m64abs(e, addr) emit_jmp_m64bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1479 | #define emit_jmp_m64bd(e, base, disp) emit_jmp_m64bisd(e, (base), REG_NONE, 1, (disp)) | |
| 1480 | #define emit_jmp_m64isd(e, index, scale, disp) emit_jmp_m64bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 1481 | ||
| 1482 | #endif | |
| 1483 | ||
| 1484 | ||
| 1485 | ||
| 1486 | /*************************************************************************** | |
| 1487 | MOVE EMITTERS | |
| 1488 | ***************************************************************************/ | |
| 1489 | ||
| 1490 | /*------------------------------------------------------------------ | |
| 1491 | emit_mov_r8_* | |
| 1492 | ------------------------------------------------------------------*/ | |
| 1493 | ||
| 1494 | INLINE void emit_mov_r8_imm(x86code **emitptr, UINT8 dreg, UINT8 imm) | |
| 1495 | { | |
| 1496 | emit_op(emitptr, OP_MOV_AL_Ib | (dreg & 7), OP_32BIT, 0, 0, dreg); | |
| 1497 | emit_byte(emitptr, imm); | |
| 1498 | } | |
| 1499 | ||
| 1500 | INLINE void emit_mov_r8_r8(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1501 | { | |
| 1502 | emit_op_modrm_reg(emitptr, OP_MOV_Gb_Eb, OP_32BIT, dreg, sreg); | |
| 1503 | } | |
| 1504 | ||
| 1505 | INLINE void emit_mov_r8_m8bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1506 | { | |
| 1507 | emit_op_modrm_mem(emitptr, OP_MOV_Gb_Eb, OP_32BIT, dreg, base, index, scale, disp); | |
| 1508 | } | |
| 1509 | ||
| 1510 | INLINE void emit_mov_m8bisd_imm(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 imm) | |
| 1511 | { | |
| 1512 | emit_op_modrm_mem(emitptr, OP_G11_Eb_Ib, OP_32BIT, 0, base, index, scale, disp); | |
| 1513 | emit_byte(emitptr, imm); | |
| 1514 | } | |
| 1515 | ||
| 1516 | INLINE void emit_mov_m8bisd_r8(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 1517 | { | |
| 1518 | emit_op_modrm_mem(emitptr, OP_MOV_Eb_Gb, OP_32BIT, sreg, base, index, scale, disp); | |
| 1519 | } | |
| 1520 | ||
| 1521 | #define emit_mov_r8_m8abs(e, dreg, addr) emit_mov_r8_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1522 | #define emit_mov_r8_m8bd(e, dreg, base, disp) emit_mov_r8_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1523 | #define emit_mov_r8_m8isd(e, dreg, index, scale, disp) emit_mov_r8_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1524 | ||
| 1525 | #define emit_mov_m8abs_r8(e, addr, sreg) emit_mov_m8bisd_r8(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 1526 | #define emit_mov_m8bd_r8(e, base, disp, sreg) emit_mov_m8bisd_r8(e, (base), REG_NONE, 1, (disp), sreg) | |
| 1527 | #define emit_mov_m8isd_r8(e, index, scale, disp, sreg) emit_mov_m8bisd_r8(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 1528 | ||
| 1529 | #define emit_mov_m8abs_imm(e, addr, imm) emit_mov_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 1530 | #define emit_mov_m8bd_imm(e, base, disp, imm) emit_mov_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 1531 | #define emit_mov_m8isd_imm(e, index, scale, disp, imm) emit_mov_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 1532 | ||
| 1533 | ||
| 1534 | /*------------------------------------------------------------------ | |
| 1535 | emit_mov_r16_* | |
| 1536 | ------------------------------------------------------------------*/ | |
| 1537 | ||
| 1538 | INLINE void emit_mov_r16_imm(x86code **emitptr, UINT8 dreg, UINT16 imm) | |
| 1539 | { | |
| 1540 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1541 | emit_op(emitptr, OP_MOV_rAX_Iv | (dreg & 7), OP_32BIT, 0, 0, dreg); | |
| 1542 | emit_word(emitptr, imm); | |
| 1543 | } | |
| 1544 | ||
| 1545 | INLINE void emit_mov_r16_r16(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1546 | { | |
| 1547 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1548 | emit_op_modrm_reg(emitptr, OP_MOV_Gv_Ev, OP_32BIT, dreg, sreg); | |
| 1549 | } | |
| 1550 | ||
| 1551 | INLINE void emit_mov_r16_m16bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1552 | { | |
| 1553 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1554 | emit_op_modrm_mem(emitptr, OP_MOV_Gv_Ev, OP_32BIT, dreg, base, index, scale, disp); | |
| 1555 | } | |
| 1556 | ||
| 1557 | INLINE void emit_mov_m16bisd_imm(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT16 imm) | |
| 1558 | { | |
| 1559 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1560 | emit_op_modrm_mem(emitptr, OP_G11_Ev_Iz, OP_32BIT, 0, base, index, scale, disp); | |
| 1561 | emit_word(emitptr, imm); | |
| 1562 | } | |
| 1563 | ||
| 1564 | INLINE void emit_mov_m16bisd_r16(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 1565 | { | |
| 1566 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1567 | emit_op_modrm_mem(emitptr, OP_MOV_Ev_Gv, OP_32BIT, sreg, base, index, scale, disp); | |
| 1568 | } | |
| 1569 | ||
| 1570 | INLINE void emit_cmovcc_r16_r16(x86code **emitptr, UINT8 condition, UINT8 dreg, UINT8 sreg) | |
| 1571 | { | |
| 1572 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1573 | emit_op_modrm_reg(emitptr, OP_CMOV_O_Gv_Ev + condition, OP_32BIT, dreg, sreg); | |
| 1574 | } | |
| 1575 | ||
| 1576 | INLINE void emit_cmovcc_r16_m16bisd(x86code **emitptr, UINT8 condition, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1577 | { | |
| 1578 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1579 | emit_op_modrm_mem(emitptr, OP_CMOV_O_Gv_Ev + condition, OP_32BIT, dreg, base, index, scale, disp); | |
| 1580 | } | |
| 1581 | ||
| 1582 | #define emit_mov_r16_m16abs(e, dreg, addr) emit_mov_r16_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1583 | #define emit_mov_r16_m16bd(e, dreg, base, disp) emit_mov_r16_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1584 | #define emit_mov_r16_m16isd(e, dreg, index, scale, disp) emit_mov_r16_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1585 | ||
| 1586 | #define emit_mov_m16abs_r16(e, addr, sreg) emit_mov_m16bisd_r16(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 1587 | #define emit_mov_m16bd_r16(e, base, disp, sreg) emit_mov_m16bisd_r16(e, (base), REG_NONE, 1, (disp), sreg) | |
| 1588 | #define emit_mov_m16isd_r16(e, index, scale, disp, sreg) emit_mov_m16bisd_r16(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 1589 | ||
| 1590 | #define emit_mov_m16abs_imm(e, addr, imm) emit_mov_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 1591 | #define emit_mov_m16bd_imm(e, base, disp, imm) emit_mov_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 1592 | #define emit_mov_m16isd_imm(e, index, scale, disp, imm) emit_mov_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 1593 | ||
| 1594 | #define emit_cmovcc_r16_m16abs(e, cond, dreg, addr) emit_cmovcc_r16_m16bisd(e, cond, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1595 | #define emit_cmovcc_r16_m16bd(e, cond, dreg, base, disp) emit_cmovcc_r16_m16bisd(e, cond, dreg, (base), REG_NONE, 1, (disp)) | |
| 1596 | #define emit_cmovcc_r16_m16isd(e, cond, dreg, index, scale, disp) emit_cmovcc_r16_m16bisd(e, cond, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1597 | ||
| 1598 | ||
| 1599 | /*------------------------------------------------------------------ | |
| 1600 | emit_mov_r32_* | |
| 1601 | ------------------------------------------------------------------*/ | |
| 1602 | ||
| 1603 | INLINE void emit_mov_r32_imm(x86code **emitptr, UINT8 dreg, UINT32 imm) | |
| 1604 | { | |
| 1605 | emit_op(emitptr, OP_MOV_rAX_Iv | (dreg & 7), OP_32BIT, 0, 0, dreg); | |
| 1606 | emit_dword(emitptr, imm); | |
| 1607 | } | |
| 1608 | ||
| 1609 | INLINE void emit_mov_r32_r32(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1610 | { | |
| 1611 | emit_op_modrm_reg(emitptr, OP_MOV_Gv_Ev, OP_32BIT, dreg, sreg); | |
| 1612 | } | |
| 1613 | ||
| 1614 | INLINE void emit_mov_r32_m32bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1615 | { | |
| 1616 | emit_op_modrm_mem(emitptr, OP_MOV_Gv_Ev, OP_32BIT, dreg, base, index, scale, disp); | |
| 1617 | } | |
| 1618 | ||
| 1619 | INLINE void emit_mov_m32bisd_imm(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT32 imm) | |
| 1620 | { | |
| 1621 | emit_op_modrm_mem(emitptr, OP_G11_Ev_Iz, OP_32BIT, 0, base, index, scale, disp); | |
| 1622 | emit_dword(emitptr, imm); | |
| 1623 | } | |
| 1624 | ||
| 1625 | INLINE void emit_mov_m32bisd_r32(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 1626 | { | |
| 1627 | emit_op_modrm_mem(emitptr, OP_MOV_Ev_Gv, OP_32BIT, sreg, base, index, scale, disp); | |
| 1628 | } | |
| 1629 | ||
| 1630 | INLINE void emit_cmovcc_r32_r32(x86code **emitptr, UINT8 condition, UINT8 dreg, UINT8 sreg) | |
| 1631 | { | |
| 1632 | emit_op_modrm_reg(emitptr, OP_CMOV_O_Gv_Ev + condition, OP_32BIT, dreg, sreg); | |
| 1633 | } | |
| 1634 | ||
| 1635 | INLINE void emit_cmovcc_r32_m32bisd(x86code **emitptr, UINT8 condition, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1636 | { | |
| 1637 | emit_op_modrm_mem(emitptr, OP_CMOV_O_Gv_Ev + condition, OP_32BIT, dreg, base, index, scale, disp); | |
| 1638 | } | |
| 1639 | ||
| 1640 | #define emit_mov_r32_m32abs(e, dreg, addr) emit_mov_r32_m32bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1641 | #define emit_mov_r32_m32bd(e, dreg, base, disp) emit_mov_r32_m32bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1642 | #define emit_mov_r32_m32isd(e, dreg, index, scale, disp) emit_mov_r32_m32bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1643 | ||
| 1644 | #define emit_mov_m32abs_r32(e, addr, sreg) emit_mov_m32bisd_r32(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 1645 | #define emit_mov_m32bd_r32(e, base, disp, sreg) emit_mov_m32bisd_r32(e, (base), REG_NONE, 1, (disp), sreg) | |
| 1646 | #define emit_mov_m32isd_r32(e, index, scale, disp, sreg) emit_mov_m32bisd_r32(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 1647 | ||
| 1648 | #define emit_mov_m32abs_imm(e, addr, imm) emit_mov_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 1649 | #define emit_mov_m32bd_imm(e, base, disp, imm) emit_mov_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 1650 | #define emit_mov_m32isd_imm(e, index, scale, disp, imm) emit_mov_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 1651 | ||
| 1652 | #define emit_cmovcc_r32_m32abs(e, cond, dreg, addr) emit_cmovcc_r32_m32bisd(e, cond, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1653 | #define emit_cmovcc_r32_m32bd(e, cond, dreg, base, disp) emit_cmovcc_r32_m32bisd(e, cond, dreg, (base), REG_NONE, 1, (disp)) | |
| 1654 | #define emit_cmovcc_r32_m32isd(e, cond, dreg, index, scale, disp) emit_cmovcc_r32_m32bisd(e, cond, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1655 | ||
| 1656 | ||
| 1657 | /*------------------------------------------------------------------ | |
| 1658 | emit_mov_r64_* | |
| 1659 | ------------------------------------------------------------------*/ | |
| 1660 | ||
| 1661 | #ifdef PTR64 | |
| 1662 | ||
| 1663 | INLINE void emit_mov_r64_imm(x86code **emitptr, UINT8 dreg, UINT64 imm) | |
| 1664 | { | |
| 1665 | emit_op(emitptr, OP_MOV_rAX_Iv | (dreg & 7), OP_64BIT, 0, 0, dreg); | |
| 1666 | emit_qword(emitptr, imm); | |
| 1667 | } | |
| 1668 | ||
| 1669 | INLINE void emit_mov_r64_r64(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1670 | { | |
| 1671 | emit_op_modrm_reg(emitptr, OP_MOV_Gv_Ev, OP_64BIT, dreg, sreg); | |
| 1672 | } | |
| 1673 | ||
| 1674 | INLINE void emit_mov_r64_m64bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1675 | { | |
| 1676 | emit_op_modrm_mem(emitptr, OP_MOV_Gv_Ev, OP_64BIT, dreg, base, index, scale, disp); | |
| 1677 | } | |
| 1678 | ||
| 1679 | INLINE void emit_mov_m64bisd_imm(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT64 imm) | |
| 1680 | { | |
| 1681 | assert((INT32)imm == (INT64)imm); | |
| 1682 | emit_op_modrm_mem(emitptr, OP_G11_Ev_Iz, OP_64BIT, 0, base, index, scale, disp); | |
| 1683 | emit_dword(emitptr, (INT32)imm); | |
| 1684 | } | |
| 1685 | ||
| 1686 | INLINE void emit_mov_m64bisd_r64(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 1687 | { | |
| 1688 | emit_op_modrm_mem(emitptr, OP_MOV_Ev_Gv, OP_64BIT, sreg, base, index, scale, disp); | |
| 1689 | } | |
| 1690 | ||
| 1691 | INLINE void emit_cmovcc_r64_r64(x86code **emitptr, UINT8 condition, UINT8 dreg, UINT8 sreg) | |
| 1692 | { | |
| 1693 | emit_op_modrm_reg(emitptr, OP_CMOV_O_Gv_Ev + condition, OP_64BIT, dreg, sreg); | |
| 1694 | } | |
| 1695 | ||
| 1696 | INLINE void emit_cmovcc_r64_m64bisd(x86code **emitptr, UINT8 condition, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1697 | { | |
| 1698 | emit_op_modrm_mem(emitptr, OP_CMOV_O_Gv_Ev + condition, OP_64BIT, dreg, base, index, scale, disp); | |
| 1699 | } | |
| 1700 | ||
| 1701 | #define emit_mov_r64_m64abs(e, dreg, addr) emit_mov_r64_m64bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1702 | #define emit_mov_r64_m64bd(e, dreg, base, disp) emit_mov_r64_m64bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1703 | #define emit_mov_r64_m64isd(e, dreg, index, scale, disp) emit_mov_r64_m64bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1704 | ||
| 1705 | #define emit_mov_m64abs_r64(e, addr, sreg) emit_mov_m64bisd_r64(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 1706 | #define emit_mov_m64bd_r64(e, base, disp, sreg) emit_mov_m64bisd_r64(e, (base), REG_NONE, 1, (disp), sreg) | |
| 1707 | #define emit_mov_m64isd_r64(e, index, scale, disp, sreg) emit_mov_m64bisd_r64(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 1708 | ||
| 1709 | #define emit_mov_m64abs_imm(e, addr, imm) emit_mov_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 1710 | #define emit_mov_m64bd_imm(e, base, disp, imm) emit_mov_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 1711 | #define emit_mov_m64isd_imm(e, index, scale, disp, imm) emit_mov_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 1712 | ||
| 1713 | #define emit_cmovcc_r64_m64abs(e, cond, dreg, addr) emit_cmovcc_r64_m64bisd(e, cond, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1714 | #define emit_cmovcc_r64_m64bd(e, cond, dreg, base, disp) emit_cmovcc_r64_m64bisd(e, cond, dreg, (base), REG_NONE, 1, (disp)) | |
| 1715 | #define emit_cmovcc_r64_m64isd(e, cond, dreg, index, scale, disp) emit_cmovcc_r64_m64bisd(e, cond, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1716 | ||
| 1717 | #endif | |
| 1718 | ||
| 1719 | ||
| 1720 | ||
| 1721 | /*************************************************************************** | |
| 1722 | MOVE EXTENDED EMITTERS | |
| 1723 | ***************************************************************************/ | |
| 1724 | ||
| 1725 | /*------------------------------------------------------------------ | |
| 1726 | emit_movsx_r16_* | |
| 1727 | ------------------------------------------------------------------*/ | |
| 1728 | ||
| 1729 | INLINE void emit_movsx_r16_r8(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1730 | { | |
| 1731 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1732 | emit_op_modrm_reg(emitptr, OP_MOVSX_Gv_Eb, OP_32BIT, dreg, sreg); | |
| 1733 | } | |
| 1734 | ||
| 1735 | INLINE void emit_movsx_r16_m8bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1736 | { | |
| 1737 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1738 | emit_op_modrm_mem(emitptr, OP_MOVSX_Gv_Eb, OP_32BIT, dreg, base, index, scale, disp); | |
| 1739 | } | |
| 1740 | ||
| 1741 | #define emit_movsx_r16_m8abs(e, dreg, addr) emit_movsx_r16_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1742 | #define emit_movsx_r16_m8bd(e, dreg, base, disp) emit_movsx_r16_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1743 | #define emit_movsx_r16_m8isd(e, dreg, index, scale, disp) emit_movsx_r16_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1744 | ||
| 1745 | ||
| 1746 | /*------------------------------------------------------------------ | |
| 1747 | emit_movzx_r16_* | |
| 1748 | ------------------------------------------------------------------*/ | |
| 1749 | ||
| 1750 | INLINE void emit_movzx_r16_r8(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1751 | { | |
| 1752 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1753 | emit_op_modrm_reg(emitptr, OP_MOVZX_Gv_Eb, OP_32BIT, dreg, sreg); | |
| 1754 | } | |
| 1755 | ||
| 1756 | INLINE void emit_movzx_r16_m8bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1757 | { | |
| 1758 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1759 | emit_op_modrm_mem(emitptr, OP_MOVZX_Gv_Eb, OP_32BIT, dreg, base, index, scale, disp); | |
| 1760 | } | |
| 1761 | ||
| 1762 | #define emit_movzx_r16_m8abs(e, dreg, addr) emit_movzx_r16_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1763 | #define emit_movzx_r16_m8bd(e, dreg, base, disp) emit_movzx_r16_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1764 | #define emit_movzx_r16_m8isd(e, dreg, index, scale, disp) emit_movzx_r16_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1765 | ||
| 1766 | ||
| 1767 | /*------------------------------------------------------------------ | |
| 1768 | emit_movsx_r32_* | |
| 1769 | ------------------------------------------------------------------*/ | |
| 1770 | ||
| 1771 | INLINE void emit_movsx_r32_r8(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1772 | { | |
| 1773 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1774 | emit_op_modrm_reg(emitptr, OP_MOVSX_Gv_Eb, OP_32BIT, dreg, sreg); | |
| 1775 | } | |
| 1776 | ||
| 1777 | INLINE void emit_movsx_r32_m8bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1778 | { | |
| 1779 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1780 | emit_op_modrm_mem(emitptr, OP_MOVSX_Gv_Eb, OP_32BIT, dreg, base, index, scale, disp); | |
| 1781 | } | |
| 1782 | ||
| 1783 | INLINE void emit_movsx_r32_r16(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1784 | { | |
| 1785 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1786 | emit_op_modrm_reg(emitptr, OP_MOVSX_Gv_Ew, OP_32BIT, dreg, sreg); | |
| 1787 | } | |
| 1788 | ||
| 1789 | INLINE void emit_movsx_r32_m16bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1790 | { | |
| 1791 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1792 | emit_op_modrm_mem(emitptr, OP_MOVSX_Gv_Ew, OP_32BIT, dreg, base, index, scale, disp); | |
| 1793 | } | |
| 1794 | ||
| 1795 | #define emit_movsx_r32_m8abs(e, dreg, addr) emit_movsx_r32_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1796 | #define emit_movsx_r32_m8bd(e, dreg, base, disp) emit_movsx_r32_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1797 | #define emit_movsx_r32_m8isd(e, dreg, index, scale, disp) emit_movsx_r32_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1798 | ||
| 1799 | #define emit_movsx_r32_m16abs(e, dreg, addr) emit_movsx_r32_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1800 | #define emit_movsx_r32_m16bd(e, dreg, base, disp) emit_movsx_r32_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1801 | #define emit_movsx_r32_m16isd(e, dreg, index, scale, disp) emit_movsx_r32_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1802 | ||
| 1803 | ||
| 1804 | /*------------------------------------------------------------------ | |
| 1805 | emit_movzx_r32_* | |
| 1806 | ------------------------------------------------------------------*/ | |
| 1807 | ||
| 1808 | INLINE void emit_movzx_r32_r8(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1809 | { | |
| 1810 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1811 | emit_op_modrm_reg(emitptr, OP_MOVZX_Gv_Eb, OP_32BIT, dreg, sreg); | |
| 1812 | } | |
| 1813 | ||
| 1814 | INLINE void emit_movzx_r32_m8bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1815 | { | |
| 1816 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1817 | emit_op_modrm_mem(emitptr, OP_MOVZX_Gv_Eb, OP_32BIT, dreg, base, index, scale, disp); | |
| 1818 | } | |
| 1819 | ||
| 1820 | INLINE void emit_movzx_r32_r16(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1821 | { | |
| 1822 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1823 | emit_op_modrm_reg(emitptr, OP_MOVZX_Gv_Ew, OP_32BIT, dreg, sreg); | |
| 1824 | } | |
| 1825 | ||
| 1826 | INLINE void emit_movzx_r32_m16bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1827 | { | |
| 1828 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1829 | emit_op_modrm_mem(emitptr, OP_MOVZX_Gv_Ew, OP_32BIT, dreg, base, index, scale, disp); | |
| 1830 | } | |
| 1831 | ||
| 1832 | #define emit_movzx_r32_m8abs(e, dreg, addr) emit_movzx_r32_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1833 | #define emit_movzx_r32_m8bd(e, dreg, base, disp) emit_movzx_r32_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1834 | #define emit_movzx_r32_m8isd(e, dreg, index, scale, disp) emit_movzx_r32_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1835 | ||
| 1836 | #define emit_movzx_r32_m16abs(e, dreg, addr) emit_movzx_r32_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1837 | #define emit_movzx_r32_m16bd(e, dreg, base, disp) emit_movzx_r32_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1838 | #define emit_movzx_r32_m16isd(e, dreg, index, scale, disp) emit_movzx_r32_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1839 | ||
| 1840 | ||
| 1841 | /*------------------------------------------------------------------ | |
| 1842 | emit_movsx_r64_* | |
| 1843 | ------------------------------------------------------------------*/ | |
| 1844 | ||
| 1845 | #ifdef PTR64 | |
| 1846 | ||
| 1847 | INLINE void emit_movsx_r64_r8(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1848 | { | |
| 1849 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1850 | emit_op_modrm_reg(emitptr, OP_MOVSX_Gv_Eb, OP_64BIT, dreg, sreg); | |
| 1851 | } | |
| 1852 | ||
| 1853 | INLINE void emit_movsx_r64_m8bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1854 | { | |
| 1855 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1856 | emit_op_modrm_mem(emitptr, OP_MOVSX_Gv_Eb, OP_64BIT, dreg, base, index, scale, disp); | |
| 1857 | } | |
| 1858 | ||
| 1859 | INLINE void emit_movsx_r64_r16(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1860 | { | |
| 1861 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1862 | emit_op_modrm_reg(emitptr, OP_MOVSX_Gv_Ew, OP_64BIT, dreg, sreg); | |
| 1863 | } | |
| 1864 | ||
| 1865 | INLINE void emit_movsx_r64_m16bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1866 | { | |
| 1867 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1868 | emit_op_modrm_mem(emitptr, OP_MOVSX_Gv_Ew, OP_64BIT, dreg, base, index, scale, disp); | |
| 1869 | } | |
| 1870 | ||
| 1871 | INLINE void emit_movsxd_r64_r32(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1872 | { | |
| 1873 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1874 | emit_op_modrm_reg(emitptr, OP_MOVSXD_Gv_Ev, OP_64BIT, dreg, sreg); | |
| 1875 | } | |
| 1876 | ||
| 1877 | INLINE void emit_movsxd_r64_m32bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1878 | { | |
| 1879 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1880 | emit_op_modrm_mem(emitptr, OP_MOVSXD_Gv_Ev, OP_64BIT, dreg, base, index, scale, disp); | |
| 1881 | } | |
| 1882 | ||
| 1883 | #define emit_movsx_r64_m8abs(e, dreg, addr) emit_movsx_r64_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1884 | #define emit_movsx_r64_m8bd(e, dreg, base, disp) emit_movsx_r64_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1885 | #define emit_movsx_r64_m8isd(e, dreg, index, scale, disp) emit_movsx_r64_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1886 | ||
| 1887 | #define emit_movsx_r64_m16abs(e, dreg, addr) emit_movsx_r64_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1888 | #define emit_movsx_r64_m16bd(e, dreg, base, disp) emit_movsx_r64_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1889 | #define emit_movsx_r64_m16isd(e, dreg, index, scale, disp) emit_movsx_r64_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1890 | ||
| 1891 | #define emit_movsxd_r64_m32abs(e, dreg, addr) emit_movsxd_r64_m32bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1892 | #define emit_movsxd_r64_m32bd(e, dreg, base, disp) emit_movsxd_r64_m32bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1893 | #define emit_movsxd_r64_m32isd(e, dreg, index, scale, disp) emit_movsxd_r64_m32bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1894 | ||
| 1895 | #endif | |
| 1896 | ||
| 1897 | ||
| 1898 | /*------------------------------------------------------------------ | |
| 1899 | emit_movzx_r64_* | |
| 1900 | ------------------------------------------------------------------*/ | |
| 1901 | ||
| 1902 | #ifdef PTR64 | |
| 1903 | ||
| 1904 | INLINE void emit_movzx_r64_r8(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1905 | { | |
| 1906 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1907 | emit_op_modrm_reg(emitptr, OP_MOVZX_Gv_Eb, OP_64BIT, dreg, sreg); | |
| 1908 | } | |
| 1909 | ||
| 1910 | INLINE void emit_movzx_r64_m8bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1911 | { | |
| 1912 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1913 | emit_op_modrm_mem(emitptr, OP_MOVZX_Gv_Eb, OP_64BIT, dreg, base, index, scale, disp); | |
| 1914 | } | |
| 1915 | ||
| 1916 | INLINE void emit_movzx_r64_r16(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1917 | { | |
| 1918 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1919 | emit_op_modrm_reg(emitptr, OP_MOVZX_Gv_Ew, OP_64BIT, dreg, sreg); | |
| 1920 | } | |
| 1921 | ||
| 1922 | INLINE void emit_movzx_r64_m16bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 1923 | { | |
| 1924 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1925 | emit_op_modrm_mem(emitptr, OP_MOVZX_Gv_Ew, OP_64BIT, dreg, base, index, scale, disp); | |
| 1926 | } | |
| 1927 | ||
| 1928 | #define emit_movzx_r64_m8abs(e, dreg, addr) emit_movzx_r64_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1929 | #define emit_movzx_r64_m8bd(e, dreg, base, disp) emit_movzx_r64_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1930 | #define emit_movzx_r64_m8isd(e, dreg, index, scale, disp) emit_movzx_r64_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1931 | ||
| 1932 | #define emit_movzx_r64_m16abs(e, dreg, addr) emit_movzx_r64_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 1933 | #define emit_movzx_r64_m16bd(e, dreg, base, disp) emit_movzx_r64_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 1934 | #define emit_movzx_r64_m16isd(e, dreg, index, scale, disp) emit_movzx_r64_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 1935 | ||
| 1936 | #endif | |
| 1937 | ||
| 1938 | ||
| 1939 | ||
| 1940 | /*************************************************************************** | |
| 1941 | TEST EMITTERS | |
| 1942 | ***************************************************************************/ | |
| 1943 | ||
| 1944 | /*------------------------------------------------------------------ | |
| 1945 | emit_test_r8_* | |
| 1946 | ------------------------------------------------------------------*/ | |
| 1947 | ||
| 1948 | INLINE void emit_test_r8_imm(x86code **emitptr, UINT8 dreg, UINT8 imm) | |
| 1949 | { | |
| 1950 | emit_op_modrm_reg(emitptr, OP_G3_Eb, OP_32BIT, 0, dreg); | |
| 1951 | emit_byte(emitptr, imm); | |
| 1952 | } | |
| 1953 | ||
| 1954 | INLINE void emit_test_r8_r8(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1955 | { | |
| 1956 | emit_op_modrm_reg(emitptr, OP_TEST_Eb_Gb, OP_32BIT, sreg, dreg); | |
| 1957 | } | |
| 1958 | ||
| 1959 | INLINE void emit_test_m8bisd_imm(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 imm) | |
| 1960 | { | |
| 1961 | emit_op_modrm_mem(emitptr, OP_G3_Eb, OP_32BIT, 0, base, index, scale, disp); | |
| 1962 | emit_byte(emitptr, imm); | |
| 1963 | } | |
| 1964 | ||
| 1965 | INLINE void emit_test_m8bisd_r8(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 1966 | { | |
| 1967 | emit_op_modrm_mem(emitptr, OP_TEST_Eb_Gb, OP_32BIT, sreg, base, index, scale, disp); | |
| 1968 | } | |
| 1969 | ||
| 1970 | #define emit_test_m8abs_imm(e, addr, imm) emit_test_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 1971 | #define emit_test_m8bd_imm(e, base, disp, imm) emit_test_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 1972 | #define emit_test_m8isd_imm(e, index, scale, disp, imm) emit_test_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 1973 | ||
| 1974 | #define emit_test_m8abs_r8(e, addr, sreg) emit_test_m8bisd_r8(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 1975 | #define emit_test_m8bd_r8(e, base, disp, sreg) emit_test_m8bisd_r8(e, (base), REG_NONE, 1, (disp), sreg) | |
| 1976 | #define emit_test_m8isd_r8(e, index, scale, disp, sreg) emit_test_m8bisd_r8(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 1977 | ||
| 1978 | ||
| 1979 | /*------------------------------------------------------------------ | |
| 1980 | emit_test_r16_* | |
| 1981 | ------------------------------------------------------------------*/ | |
| 1982 | ||
| 1983 | INLINE void emit_test_r16_imm(x86code **emitptr, UINT8 dreg, UINT16 imm) | |
| 1984 | { | |
| 1985 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1986 | emit_op_modrm_reg(emitptr, OP_G3_Ev, OP_32BIT, 0, dreg); | |
| 1987 | emit_word(emitptr, imm); | |
| 1988 | } | |
| 1989 | ||
| 1990 | INLINE void emit_test_r16_r16(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 1991 | { | |
| 1992 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1993 | emit_op_modrm_reg(emitptr, OP_TEST_Ev_Gv, OP_32BIT, sreg, dreg); | |
| 1994 | } | |
| 1995 | ||
| 1996 | INLINE void emit_test_m16bisd_imm(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT16 imm) | |
| 1997 | { | |
| 1998 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 1999 | emit_op_modrm_mem(emitptr, OP_G3_Ev, OP_32BIT, 0, base, index, scale, disp); | |
| 2000 | emit_word(emitptr, imm); | |
| 2001 | } | |
| 2002 | ||
| 2003 | INLINE void emit_test_m16bisd_r16(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 2004 | { | |
| 2005 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 2006 | emit_op_modrm_mem(emitptr, OP_TEST_Ev_Gv, OP_32BIT, sreg, base, index, scale, disp); | |
| 2007 | } | |
| 2008 | ||
| 2009 | #define emit_test_m16abs_imm(e, addr, imm) emit_test_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2010 | #define emit_test_m16bd_imm(e, base, disp, imm) emit_test_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2011 | #define emit_test_m16isd_imm(e, index, scale, disp, imm) emit_test_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2012 | ||
| 2013 | #define emit_test_m16abs_r16(e, addr, sreg) emit_test_m16bisd_r16(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2014 | #define emit_test_m16bd_r16(e, base, disp, sreg) emit_test_m16bisd_r16(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2015 | #define emit_test_m16isd_r16(e, index, scale, disp, sreg) emit_test_m16bisd_r16(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2016 | ||
| 2017 | ||
| 2018 | /*------------------------------------------------------------------ | |
| 2019 | emit_test_r32_* | |
| 2020 | ------------------------------------------------------------------*/ | |
| 2021 | ||
| 2022 | INLINE void emit_test_r32_imm(x86code **emitptr, UINT8 dreg, UINT32 imm) | |
| 2023 | { | |
| 2024 | emit_op_modrm_reg(emitptr, OP_G3_Ev, OP_32BIT, 0, dreg); | |
| 2025 | emit_dword(emitptr, imm); | |
| 2026 | } | |
| 2027 | ||
| 2028 | INLINE void emit_test_r32_r32(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 2029 | { | |
| 2030 | emit_op_modrm_reg(emitptr, OP_TEST_Ev_Gv, OP_32BIT, sreg, dreg); | |
| 2031 | } | |
| 2032 | ||
| 2033 | INLINE void emit_test_m32bisd_imm(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT32 imm) | |
| 2034 | { | |
| 2035 | emit_op_modrm_mem(emitptr, OP_G3_Ev, OP_32BIT, 0, base, index, scale, disp); | |
| 2036 | emit_dword(emitptr, imm); | |
| 2037 | } | |
| 2038 | ||
| 2039 | INLINE void emit_test_m32bisd_r32(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 2040 | { | |
| 2041 | emit_op_modrm_mem(emitptr, OP_TEST_Ev_Gv, OP_32BIT, sreg, base, index, scale, disp); | |
| 2042 | } | |
| 2043 | ||
| 2044 | #define emit_test_m32abs_imm(e, addr, imm) emit_test_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2045 | #define emit_test_m32bd_imm(e, base, disp, imm) emit_test_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2046 | #define emit_test_m32isd_imm(e, index, scale, disp, imm) emit_test_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2047 | ||
| 2048 | #define emit_test_m32abs_r32(e, addr, sreg) emit_test_m32bisd_r32(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2049 | #define emit_test_m32bd_r32(e, base, disp, sreg) emit_test_m32bisd_r32(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2050 | #define emit_test_m32isd_r32(e, index, scale, disp, sreg) emit_test_m32bisd_r32(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2051 | ||
| 2052 | ||
| 2053 | /*------------------------------------------------------------------ | |
| 2054 | emit_test_r64_* | |
| 2055 | ------------------------------------------------------------------*/ | |
| 2056 | ||
| 2057 | #ifdef PTR64 | |
| 2058 | ||
| 2059 | INLINE void emit_test_r64_imm(x86code **emitptr, UINT8 dreg, UINT64 imm) | |
| 2060 | { | |
| 2061 | assert((INT32)imm == (INT64)imm); | |
| 2062 | emit_op_modrm_reg(emitptr, OP_G3_Ev, OP_64BIT, 0, dreg); | |
| 2063 | emit_dword(emitptr, imm); | |
| 2064 | } | |
| 2065 | ||
| 2066 | INLINE void emit_test_r64_r64(x86code **emitptr, UINT8 dreg, UINT8 sreg) | |
| 2067 | { | |
| 2068 | emit_op_modrm_reg(emitptr, OP_TEST_Ev_Gv, OP_64BIT, sreg, dreg); | |
| 2069 | } | |
| 2070 | ||
| 2071 | INLINE void emit_test_m64bisd_imm(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT64 imm) | |
| 2072 | { | |
| 2073 | assert((INT32)imm == (INT64)imm); | |
| 2074 | emit_op_modrm_mem(emitptr, OP_G3_Ev, OP_64BIT, 0, base, index, scale, disp); | |
| 2075 | emit_dword(emitptr, (INT32)imm); | |
| 2076 | } | |
| 2077 | ||
| 2078 | INLINE void emit_test_m64bisd_r64(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 2079 | { | |
| 2080 | emit_op_modrm_mem(emitptr, OP_TEST_Ev_Gv, OP_64BIT, sreg, base, index, scale, disp); | |
| 2081 | } | |
| 2082 | ||
| 2083 | #define emit_test_m64abs_imm(e, addr, imm) emit_test_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2084 | #define emit_test_m64bd_imm(e, base, disp, imm) emit_test_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2085 | #define emit_test_m64isd_imm(e, index, scale, disp, imm) emit_test_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2086 | ||
| 2087 | #define emit_test_m64abs_r64(e, addr, sreg) emit_test_m64bisd_r64(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2088 | #define emit_test_m64bd_r64(e, base, disp, sreg) emit_test_m64bisd_r64(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2089 | #define emit_test_m64isd_r64(e, index, scale, disp, sreg) emit_test_m64bisd_r64(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2090 | ||
| 2091 | #endif | |
| 2092 | ||
| 2093 | ||
| 2094 | ||
| 2095 | /*************************************************************************** | |
| 2096 | 8-BIT ARITHMETIC EMITTERS | |
| 2097 | ***************************************************************************/ | |
| 2098 | ||
| 2099 | /* | |
| 2100 | Note that the following code relies on this: | |
| 2101 | ||
| 2102 | 00-05 or /0 = ADD | |
| 2103 | 08-0d or /1 = OR | |
| 2104 | 10-15 or /2 = ADC | |
| 2105 | 18-1d or /3 = SBB | |
| 2106 | 20-25 or /4 = AND | |
| 2107 | 28-2d or /5 = SUB | |
| 2108 | 30-35 or /6 = XOR | |
| 2109 | 38-3d or /7 = CMP | |
| 2110 | */ | |
| 2111 | ||
| 2112 | /*------------------------------------------------------------------ | |
| 2113 | emit_arith_r8_* | |
| 2114 | ------------------------------------------------------------------*/ | |
| 2115 | ||
| 2116 | INLINE void emit_arith_r8_imm(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 imm) | |
| 2117 | { | |
| 2118 | emit_op_modrm_reg(emitptr, OP_G1_Eb_Ib, OP_32BIT, opindex, dreg); | |
| 2119 | emit_byte(emitptr, imm); | |
| 2120 | } | |
| 2121 | ||
| 2122 | INLINE void emit_arith_m8bisd_imm(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 imm) | |
| 2123 | { | |
| 2124 | emit_op_modrm_mem(emitptr, OP_G1_Eb_Ib, OP_32BIT, opindex, base, index, scale, disp); | |
| 2125 | emit_byte(emitptr, imm); | |
| 2126 | } | |
| 2127 | ||
| 2128 | INLINE void emit_arith_r8_r8(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 sreg) | |
| 2129 | { | |
| 2130 | emit_op_modrm_reg(emitptr, OP_ADD_Eb_Gb + 8 * opindex, OP_32BIT, dreg, sreg); | |
| 2131 | } | |
| 2132 | ||
| 2133 | INLINE void emit_arith_r8_m8bisd(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 2134 | { | |
| 2135 | emit_op_modrm_mem(emitptr, OP_ADD_Eb_Gb + 8 * opindex, OP_32BIT, dreg, base, index, scale, disp); | |
| 2136 | } | |
| 2137 | ||
| 2138 | INLINE void emit_arith_m8bisd_r8(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 2139 | { | |
| 2140 | emit_op_modrm_mem(emitptr, OP_ADD_Gb_Eb + 8 * opindex, OP_32BIT, sreg, base, index, scale, disp); | |
| 2141 | } | |
| 2142 | ||
| 2143 | ||
| 2144 | /*------------------------------------------------------------------ | |
| 2145 | emit_add_r8_* | |
| 2146 | ------------------------------------------------------------------*/ | |
| 2147 | ||
| 2148 | #define emit_add_r8_imm(e, dreg, imm) emit_arith_r8_imm(e, 0, dreg, imm) | |
| 2149 | #define emit_add_m8bisd_imm(e, base, index, scale, disp, imm) emit_arith_m8bisd_imm(e, 0, base, index, scale, disp, imm) | |
| 2150 | #define emit_add_r8_r8(e, dreg, sreg) emit_arith_r8_r8(e, 0, dreg, sreg) | |
| 2151 | #define emit_add_r8_m8bisd(e, dreg, base, index, scale, disp) emit_arith_r8_m8bisd(e, 0, dreg, base, index, scale, disp) | |
| 2152 | #define emit_add_m8bisd_r8(e, base, index, scale, disp, sreg) emit_arith_m8bisd_r8(e, 0, base, index, scale, disp, sreg) | |
| 2153 | ||
| 2154 | #define emit_add_m8abs_imm(e, addr, imm) emit_add_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2155 | #define emit_add_m8bd_imm(e, base, disp, imm) emit_add_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2156 | #define emit_add_m8isd_imm(e, index, scale, disp, imm) emit_add_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2157 | ||
| 2158 | #define emit_add_r8_m8abs(e, dreg, addr) emit_add_r8_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2159 | #define emit_add_r8_m8bd(e, dreg, base, disp) emit_add_r8_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2160 | #define emit_add_r8_m8isd(e, dreg, index, scale, disp) emit_add_r8_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2161 | ||
| 2162 | #define emit_add_m8abs_r8(e, addr, sreg) emit_add_m8bisd_r8(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2163 | #define emit_add_m8bd_r8(e, base, disp, sreg) emit_add_m8bisd_r8(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2164 | #define emit_add_m8isd_r8(e, index, scale, disp, sreg) emit_add_m8bisd_r8(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2165 | ||
| 2166 | ||
| 2167 | /*------------------------------------------------------------------ | |
| 2168 | emit_or_r8_* | |
| 2169 | ------------------------------------------------------------------*/ | |
| 2170 | ||
| 2171 | #define emit_or_r8_imm(e, dreg, imm) emit_arith_r8_imm(e, 1, dreg, imm) | |
| 2172 | #define emit_or_m8bisd_imm(e, base, index, scale, disp, imm) emit_arith_m8bisd_imm(e, 1, base, index, scale, disp, imm) | |
| 2173 | #define emit_or_r8_r8(e, dreg, sreg) emit_arith_r8_r8(e, 1, dreg, sreg) | |
| 2174 | #define emit_or_r8_m8bisd(e, dreg, base, index, scale, disp) emit_arith_r8_m8bisd(e, 1, dreg, base, index, scale, disp) | |
| 2175 | #define emit_or_m8bisd_r8(e, base, index, scale, disp, sreg) emit_arith_m8bisd_r8(e, 1, base, index, scale, disp, sreg) | |
| 2176 | ||
| 2177 | #define emit_or_m8abs_imm(e, addr, imm) emit_or_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2178 | #define emit_or_m8bd_imm(e, base, disp, imm) emit_or_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2179 | #define emit_or_m8isd_imm(e, index, scale, disp, imm) emit_or_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2180 | ||
| 2181 | #define emit_or_r8_m8abs(e, dreg, addr) emit_or_r8_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2182 | #define emit_or_r8_m8bd(e, dreg, base, disp) emit_or_r8_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2183 | #define emit_or_r8_m8isd(e, dreg, index, scale, disp) emit_or_r8_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2184 | ||
| 2185 | #define emit_or_m8abs_r8(e, addr, sreg) emit_or_m8bisd_r8(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2186 | #define emit_or_m8bd_r8(e, base, disp, sreg) emit_or_m8bisd_r8(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2187 | #define emit_or_m8isd_r8(e, index, scale, disp, sreg) emit_or_m8bisd_r8(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2188 | ||
| 2189 | ||
| 2190 | /*------------------------------------------------------------------ | |
| 2191 | emit_adc_r8_* | |
| 2192 | ------------------------------------------------------------------*/ | |
| 2193 | ||
| 2194 | #define emit_adc_r8_imm(e, dreg, imm) emit_arith_r8_imm(e, 2, dreg, imm) | |
| 2195 | #define emit_adc_m8bisd_imm(e, base, index, scale, disp, imm) emit_arith_m8bisd_imm(e, 2, base, index, scale, disp, imm) | |
| 2196 | #define emit_adc_r8_r8(e, dreg, sreg) emit_arith_r8_r8(e, 2, dreg, sreg) | |
| 2197 | #define emit_adc_r8_m8bisd(e, dreg, base, index, scale, disp) emit_arith_r8_m8bisd(e, 2, dreg, base, index, scale, disp) | |
| 2198 | #define emit_adc_m8bisd_r8(e, base, index, scale, disp, sreg) emit_arith_m8bisd_r8(e, 2, base, index, scale, disp, sreg) | |
| 2199 | ||
| 2200 | #define emit_adc_m8abs_imm(e, addr, imm) emit_adc_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2201 | #define emit_adc_m8bd_imm(e, base, disp, imm) emit_adc_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2202 | #define emit_adc_m8isd_imm(e, index, scale, disp, imm) emit_adc_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2203 | ||
| 2204 | #define emit_adc_r8_m8abs(e, dreg, addr) emit_adc_r8_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2205 | #define emit_adc_r8_m8bd(e, dreg, base, disp) emit_adc_r8_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2206 | #define emit_adc_r8_m8isd(e, dreg, index, scale, disp) emit_adc_r8_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2207 | ||
| 2208 | #define emit_adc_m8abs_r8(e, addr, sreg) emit_adc_m8bisd_r8(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2209 | #define emit_adc_m8bd_r8(e, base, disp, sreg) emit_adc_m8bisd_r8(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2210 | #define emit_adc_m8isd_r8(e, index, scale, disp, sreg) emit_adc_m8bisd_r8(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2211 | ||
| 2212 | ||
| 2213 | /*------------------------------------------------------------------ | |
| 2214 | emit_sbb_r8_* | |
| 2215 | ------------------------------------------------------------------*/ | |
| 2216 | ||
| 2217 | #define emit_sbb_r8_imm(e, dreg, imm) emit_arith_r8_imm(e, 3, dreg, imm) | |
| 2218 | #define emit_sbb_m8bisd_imm(e, base, index, scale, disp, imm) emit_arith_m8bisd_imm(e, 3, base, index, scale, disp, imm) | |
| 2219 | #define emit_sbb_r8_r8(e, dreg, sreg) emit_arith_r8_r8(e, 3, dreg, sreg) | |
| 2220 | #define emit_sbb_r8_m8bisd(e, dreg, base, index, scale, disp) emit_arith_r8_m8bisd(e, 3, dreg, base, index, scale, disp) | |
| 2221 | #define emit_sbb_m8bisd_r8(e, base, index, scale, disp, sreg) emit_arith_m8bisd_r8(e, 3, base, index, scale, disp, sreg) | |
| 2222 | ||
| 2223 | #define emit_sbb_m8abs_imm(e, addr, imm) emit_sbb_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2224 | #define emit_sbb_m8bd_imm(e, base, disp, imm) emit_sbb_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2225 | #define emit_sbb_m8isd_imm(e, index, scale, disp, imm) emit_sbb_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2226 | ||
| 2227 | #define emit_sbb_r8_m8abs(e, dreg, addr) emit_sbb_r8_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2228 | #define emit_sbb_r8_m8bd(e, dreg, base, disp) emit_sbb_r8_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2229 | #define emit_sbb_r8_m8isd(e, dreg, index, scale, disp) emit_sbb_r8_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2230 | ||
| 2231 | #define emit_sbb_m8abs_r8(e, addr, sreg) emit_sbb_m8bisd_r8(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2232 | #define emit_sbb_m8bd_r8(e, base, disp, sreg) emit_sbb_m8bisd_r8(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2233 | #define emit_sbb_m8isd_r8(e, index, scale, disp, sreg) emit_sbb_m8bisd_r8(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2234 | ||
| 2235 | ||
| 2236 | /*------------------------------------------------------------------ | |
| 2237 | emit_and_r8_* | |
| 2238 | ------------------------------------------------------------------*/ | |
| 2239 | ||
| 2240 | #define emit_and_r8_imm(e, dreg, imm) emit_arith_r8_imm(e, 4, dreg, imm) | |
| 2241 | #define emit_and_m8bisd_imm(e, base, index, scale, disp, imm) emit_arith_m8bisd_imm(e, 4, base, index, scale, disp, imm) | |
| 2242 | #define emit_and_r8_r8(e, dreg, sreg) emit_arith_r8_r8(e, 4, dreg, sreg) | |
| 2243 | #define emit_and_r8_m8bisd(e, dreg, base, index, scale, disp) emit_arith_r8_m8bisd(e, 4, dreg, base, index, scale, disp) | |
| 2244 | #define emit_and_m8bisd_r8(e, base, index, scale, disp, sreg) emit_arith_m8bisd_r8(e, 4, base, index, scale, disp, sreg) | |
| 2245 | ||
| 2246 | #define emit_and_m8abs_imm(e, addr, imm) emit_and_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2247 | #define emit_and_m8bd_imm(e, base, disp, imm) emit_and_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2248 | #define emit_and_m8isd_imm(e, index, scale, disp, imm) emit_and_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2249 | ||
| 2250 | #define emit_and_r8_m8abs(e, dreg, addr) emit_and_r8_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2251 | #define emit_and_r8_m8bd(e, dreg, base, disp) emit_and_r8_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2252 | #define emit_and_r8_m8isd(e, dreg, index, scale, disp) emit_and_r8_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2253 | ||
| 2254 | #define emit_and_m8abs_r8(e, addr, sreg) emit_and_m8bisd_r8(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2255 | #define emit_and_m8bd_r8(e, base, disp, sreg) emit_and_m8bisd_r8(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2256 | #define emit_and_m8isd_r8(e, index, scale, disp, sreg) emit_and_m8bisd_r8(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2257 | ||
| 2258 | ||
| 2259 | /*------------------------------------------------------------------ | |
| 2260 | emit_sub_r8_* | |
| 2261 | ------------------------------------------------------------------*/ | |
| 2262 | ||
| 2263 | #define emit_sub_r8_imm(e, dreg, imm) emit_arith_r8_imm(e, 5, dreg, imm) | |
| 2264 | #define emit_sub_m8bisd_imm(e, base, index, scale, disp, imm) emit_arith_m8bisd_imm(e, 5, base, index, scale, disp, imm) | |
| 2265 | #define emit_sub_r8_r8(e, dreg, sreg) emit_arith_r8_r8(e, 5, dreg, sreg) | |
| 2266 | #define emit_sub_r8_m8bisd(e, dreg, base, index, scale, disp) emit_arith_r8_m8bisd(e, 5, dreg, base, index, scale, disp) | |
| 2267 | #define emit_sub_m8bisd_r8(e, base, index, scale, disp, sreg) emit_arith_m8bisd_r8(e, 5, base, index, scale, disp, sreg) | |
| 2268 | ||
| 2269 | #define emit_sub_m8abs_imm(e, addr, imm) emit_sub_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2270 | #define emit_sub_m8bd_imm(e, base, disp, imm) emit_sub_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2271 | #define emit_sub_m8isd_imm(e, index, scale, disp, imm) emit_sub_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2272 | ||
| 2273 | #define emit_sub_r8_m8abs(e, dreg, addr) emit_sub_r8_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2274 | #define emit_sub_r8_m8bd(e, dreg, base, disp) emit_sub_r8_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2275 | #define emit_sub_r8_m8isd(e, dreg, index, scale, disp) emit_sub_r8_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2276 | ||
| 2277 | #define emit_sub_m8abs_r8(e, addr, sreg) emit_sub_m8bisd_r8(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2278 | #define emit_sub_m8bd_r8(e, base, disp, sreg) emit_sub_m8bisd_r8(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2279 | #define emit_sub_m8isd_r8(e, index, scale, disp, sreg) emit_sub_m8bisd_r8(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2280 | ||
| 2281 | ||
| 2282 | /*------------------------------------------------------------------ | |
| 2283 | emit_xor_r8_* | |
| 2284 | ------------------------------------------------------------------*/ | |
| 2285 | ||
| 2286 | #define emit_xor_r8_imm(e, dreg, imm) emit_arith_r8_imm(e, 6, dreg, imm) | |
| 2287 | #define emit_xor_m8bisd_imm(e, base, index, scale, disp, imm) emit_arith_m8bisd_imm(e, 6, base, index, scale, disp, imm) | |
| 2288 | #define emit_xor_r8_r8(e, dreg, sreg) emit_arith_r8_r8(e, 6, dreg, sreg) | |
| 2289 | #define emit_xor_r8_m8bisd(e, dreg, base, index, scale, disp) emit_arith_r8_m8bisd(e, 6, dreg, base, index, scale, disp) | |
| 2290 | #define emit_xor_m8bisd_r8(e, base, index, scale, disp, sreg) emit_arith_m8bisd_r8(e, 6, base, index, scale, disp, sreg) | |
| 2291 | ||
| 2292 | #define emit_xor_m8abs_imm(e, addr, imm) emit_xor_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2293 | #define emit_xor_m8bd_imm(e, base, disp, imm) emit_xor_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2294 | #define emit_xor_m8isd_imm(e, index, scale, disp, imm) emit_xor_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2295 | ||
| 2296 | #define emit_xor_r8_m8abs(e, dreg, addr) emit_xor_r8_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2297 | #define emit_xor_r8_m8bd(e, dreg, base, disp) emit_xor_r8_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2298 | #define emit_xor_r8_m8isd(e, dreg, index, scale, disp) emit_xor_r8_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2299 | ||
| 2300 | #define emit_xor_m8abs_r8(e, addr, sreg) emit_xor_m8bisd_r8(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2301 | #define emit_xor_m8bd_r8(e, base, disp, sreg) emit_xor_m8bisd_r8(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2302 | #define emit_xor_m8isd_r8(e, index, scale, disp, sreg) emit_xor_m8bisd_r8(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2303 | ||
| 2304 | ||
| 2305 | /*------------------------------------------------------------------ | |
| 2306 | emit_cmp_r8_* | |
| 2307 | ------------------------------------------------------------------*/ | |
| 2308 | ||
| 2309 | #define emit_cmp_r8_imm(e, dreg, imm) emit_arith_r8_imm(e, 7, dreg, imm) | |
| 2310 | #define emit_cmp_m8bisd_imm(e, base, index, scale, disp, imm) emit_arith_m8bisd_imm(e, 7, base, index, scale, disp, imm) | |
| 2311 | #define emit_cmp_r8_r8(e, dreg, sreg) emit_arith_r8_r8(e, 7, dreg, sreg) | |
| 2312 | #define emit_cmp_r8_m8bisd(e, dreg, base, index, scale, disp) emit_arith_r8_m8bisd(e, 7, dreg, base, index, scale, disp) | |
| 2313 | #define emit_cmp_m8bisd_r8(e, base, index, scale, disp, sreg) emit_arith_m8bisd_r8(e, 7, base, index, scale, disp, sreg) | |
| 2314 | ||
| 2315 | #define emit_cmp_m8abs_imm(e, addr, imm) emit_cmp_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2316 | #define emit_cmp_m8bd_imm(e, base, disp, imm) emit_cmp_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2317 | #define emit_cmp_m8isd_imm(e, index, scale, disp, imm) emit_cmp_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2318 | ||
| 2319 | #define emit_cmp_r8_m8abs(e, dreg, addr) emit_cmp_r8_m8bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2320 | #define emit_cmp_r8_m8bd(e, dreg, base, disp) emit_cmp_r8_m8bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2321 | #define emit_cmp_r8_m8isd(e, dreg, index, scale, disp) emit_cmp_r8_m8bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2322 | ||
| 2323 | #define emit_cmp_m8abs_r8(e, addr, sreg) emit_cmp_m8bisd_r8(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2324 | #define emit_cmp_m8bd_r8(e, base, disp, sreg) emit_cmp_m8bisd_r8(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2325 | #define emit_cmp_m8isd_r8(e, index, scale, disp, sreg) emit_cmp_m8bisd_r8(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2326 | ||
| 2327 | ||
| 2328 | ||
| 2329 | /*************************************************************************** | |
| 2330 | 16-BIT ARITHMETIC EMITTERS | |
| 2331 | ***************************************************************************/ | |
| 2332 | ||
| 2333 | /* | |
| 2334 | Note that the following code relies on this: | |
| 2335 | ||
| 2336 | 00-05 or /0 = ADD | |
| 2337 | 08-0d or /1 = OR | |
| 2338 | 10-15 or /2 = ADC | |
| 2339 | 18-1d or /3 = SBB | |
| 2340 | 20-25 or /4 = AND | |
| 2341 | 28-2d or /5 = SUB | |
| 2342 | 30-35 or /6 = XOR | |
| 2343 | 38-3d or /7 = CMP | |
| 2344 | */ | |
| 2345 | ||
| 2346 | INLINE void emit_arith_r16_imm(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT16 imm) | |
| 2347 | { | |
| 2348 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 2349 | if ((INT8)imm == (INT16)imm) | |
| 2350 | { | |
| 2351 | emit_op_modrm_reg(emitptr, OP_G1_Ev_Ib, OP_32BIT, opindex, dreg); | |
| 2352 | emit_byte(emitptr, (INT8)imm); | |
| 2353 | } | |
| 2354 | else | |
| 2355 | { | |
| 2356 | emit_op_modrm_reg(emitptr, OP_G1_Ev_Iz, OP_32BIT, opindex, dreg); | |
| 2357 | emit_word(emitptr, imm); | |
| 2358 | } | |
| 2359 | } | |
| 2360 | ||
| 2361 | INLINE void emit_arith_m16bisd_imm(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT16 imm) | |
| 2362 | { | |
| 2363 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 2364 | if ((INT8)imm == (INT16)imm) | |
| 2365 | { | |
| 2366 | emit_op_modrm_mem(emitptr, OP_G1_Ev_Ib, OP_32BIT, opindex, base, index, scale, disp); | |
| 2367 | emit_byte(emitptr, (INT8)imm); | |
| 2368 | } | |
| 2369 | else | |
| 2370 | { | |
| 2371 | emit_op_modrm_mem(emitptr, OP_G1_Ev_Iz, OP_32BIT, opindex, base, index, scale, disp); | |
| 2372 | emit_word(emitptr, imm); | |
| 2373 | } | |
| 2374 | } | |
| 2375 | ||
| 2376 | INLINE void emit_arith_r16_r16(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 sreg) | |
| 2377 | { | |
| 2378 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 2379 | emit_op_modrm_reg(emitptr, OP_ADD_Ev_Gv + 8 * opindex, OP_32BIT, dreg, sreg); | |
| 2380 | } | |
| 2381 | ||
| 2382 | INLINE void emit_arith_r16_m16bisd(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 2383 | { | |
| 2384 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 2385 | emit_op_modrm_mem(emitptr, OP_ADD_Ev_Gv + 8 * opindex, OP_32BIT, dreg, base, index, scale, disp); | |
| 2386 | } | |
| 2387 | ||
| 2388 | INLINE void emit_arith_m16bisd_r16(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 2389 | { | |
| 2390 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 2391 | emit_op_modrm_mem(emitptr, OP_ADD_Gv_Ev + 8 * opindex, OP_32BIT, sreg, base, index, scale, disp); | |
| 2392 | } | |
| 2393 | ||
| 2394 | ||
| 2395 | /*------------------------------------------------------------------ | |
| 2396 | emit_add_r16_* | |
| 2397 | ------------------------------------------------------------------*/ | |
| 2398 | ||
| 2399 | #define emit_add_r16_imm(e, dreg, imm) emit_arith_r16_imm(e, 0, dreg, imm) | |
| 2400 | #define emit_add_m16bisd_imm(e, base, index, scale, disp, imm) emit_arith_m16bisd_imm(e, 0, base, index, scale, disp, imm) | |
| 2401 | #define emit_add_r16_r16(e, dreg, sreg) emit_arith_r16_r16(e, 0, dreg, sreg) | |
| 2402 | #define emit_add_r16_m16bisd(e, dreg, base, index, scale, disp) emit_arith_r16_m16bisd(e, 0, dreg, base, index, scale, disp) | |
| 2403 | #define emit_add_m16bisd_r16(e, base, index, scale, disp, sreg) emit_arith_m16bisd_r16(e, 0, base, index, scale, disp, sreg) | |
| 2404 | ||
| 2405 | #define emit_add_m16abs_imm(e, addr, imm) emit_add_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2406 | #define emit_add_m16bd_imm(e, base, disp, imm) emit_add_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2407 | #define emit_add_m16isd_imm(e, index, scale, disp, imm) emit_add_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2408 | ||
| 2409 | #define emit_add_r16_m16abs(e, dreg, addr) emit_add_r16_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2410 | #define emit_add_r16_m16bd(e, dreg, base, disp) emit_add_r16_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2411 | #define emit_add_r16_m16isd(e, dreg, index, scale, disp) emit_add_r16_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2412 | ||
| 2413 | #define emit_add_m16abs_r16(e, addr, sreg) emit_add_m16bisd_r16(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2414 | #define emit_add_m16bd_r16(e, base, disp, sreg) emit_add_m16bisd_r16(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2415 | #define emit_add_m16isd_r16(e, index, scale, disp, sreg) emit_add_m16bisd_r16(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2416 | ||
| 2417 | ||
| 2418 | /*------------------------------------------------------------------ | |
| 2419 | emit_or_r16_* | |
| 2420 | ------------------------------------------------------------------*/ | |
| 2421 | ||
| 2422 | #define emit_or_r16_imm(e, dreg, imm) emit_arith_r16_imm(e, 1, dreg, imm) | |
| 2423 | #define emit_or_m16bisd_imm(e, base, index, scale, disp, imm) emit_arith_m16bisd_imm(e, 1, base, index, scale, disp, imm) | |
| 2424 | #define emit_or_r16_r16(e, dreg, sreg) emit_arith_r16_r16(e, 1, dreg, sreg) | |
| 2425 | #define emit_or_r16_m16bisd(e, dreg, base, index, scale, disp) emit_arith_r16_m16bisd(e, 1, dreg, base, index, scale, disp) | |
| 2426 | #define emit_or_m16bisd_r16(e, base, index, scale, disp, sreg) emit_arith_m16bisd_r16(e, 1, base, index, scale, disp, sreg) | |
| 2427 | ||
| 2428 | #define emit_or_m16abs_imm(e, addr, imm) emit_or_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2429 | #define emit_or_m16bd_imm(e, base, disp, imm) emit_or_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2430 | #define emit_or_m16isd_imm(e, index, scale, disp, imm) emit_or_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2431 | ||
| 2432 | #define emit_or_r16_m16abs(e, dreg, addr) emit_or_r16_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2433 | #define emit_or_r16_m16bd(e, dreg, base, disp) emit_or_r16_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2434 | #define emit_or_r16_m16isd(e, dreg, index, scale, disp) emit_or_r16_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2435 | ||
| 2436 | #define emit_or_m16abs_r16(e, addr, sreg) emit_or_m16bisd_r16(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2437 | #define emit_or_m16bd_r16(e, base, disp, sreg) emit_or_m16bisd_r16(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2438 | #define emit_or_m16isd_r16(e, index, scale, disp, sreg) emit_or_m16bisd_r16(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2439 | ||
| 2440 | ||
| 2441 | /*------------------------------------------------------------------ | |
| 2442 | emit_adc_r16_* | |
| 2443 | ------------------------------------------------------------------*/ | |
| 2444 | ||
| 2445 | #define emit_adc_r16_imm(e, dreg, imm) emit_arith_r16_imm(e, 2, dreg, imm) | |
| 2446 | #define emit_adc_m16bisd_imm(e, base, index, scale, disp, imm) emit_arith_m16bisd_imm(e, 2, base, index, scale, disp, imm) | |
| 2447 | #define emit_adc_r16_r16(e, dreg, sreg) emit_arith_r16_r16(e, 2, dreg, sreg) | |
| 2448 | #define emit_adc_r16_m16bisd(e, dreg, base, index, scale, disp) emit_arith_r16_m16bisd(e, 2, dreg, base, index, scale, disp) | |
| 2449 | #define emit_adc_m16bisd_r16(e, base, index, scale, disp, sreg) emit_arith_m16bisd_r16(e, 2, base, index, scale, disp, sreg) | |
| 2450 | ||
| 2451 | #define emit_adc_m16abs_imm(e, addr, imm) emit_adc_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2452 | #define emit_adc_m16bd_imm(e, base, disp, imm) emit_adc_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2453 | #define emit_adc_m16isd_imm(e, index, scale, disp, imm) emit_adc_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2454 | ||
| 2455 | #define emit_adc_r16_m16abs(e, dreg, addr) emit_adc_r16_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2456 | #define emit_adc_r16_m16bd(e, dreg, base, disp) emit_adc_r16_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2457 | #define emit_adc_r16_m16isd(e, dreg, index, scale, disp) emit_adc_r16_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2458 | ||
| 2459 | #define emit_adc_m16abs_r16(e, addr, sreg) emit_adc_m16bisd_r16(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2460 | #define emit_adc_m16bd_r16(e, base, disp, sreg) emit_adc_m16bisd_r16(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2461 | #define emit_adc_m16isd_r16(e, index, scale, disp, sreg) emit_adc_m16bisd_r16(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2462 | ||
| 2463 | ||
| 2464 | /*------------------------------------------------------------------ | |
| 2465 | emit_sbb_r16_* | |
| 2466 | ------------------------------------------------------------------*/ | |
| 2467 | ||
| 2468 | #define emit_sbb_r16_imm(e, dreg, imm) emit_arith_r16_imm(e, 3, dreg, imm) | |
| 2469 | #define emit_sbb_m16bisd_imm(e, base, index, scale, disp, imm) emit_arith_m16bisd_imm(e, 3, base, index, scale, disp, imm) | |
| 2470 | #define emit_sbb_r16_r16(e, dreg, sreg) emit_arith_r16_r16(e, 3, dreg, sreg) | |
| 2471 | #define emit_sbb_r16_m16bisd(e, dreg, base, index, scale, disp) emit_arith_r16_m16bisd(e, 3, dreg, base, index, scale, disp) | |
| 2472 | #define emit_sbb_m16bisd_r16(e, base, index, scale, disp, sreg) emit_arith_m16bisd_r16(e, 3, base, index, scale, disp, sreg) | |
| 2473 | ||
| 2474 | #define emit_sbb_m16abs_imm(e, addr, imm) emit_sbb_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2475 | #define emit_sbb_m16bd_imm(e, base, disp, imm) emit_sbb_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2476 | #define emit_sbb_m16isd_imm(e, index, scale, disp, imm) emit_sbb_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2477 | ||
| 2478 | #define emit_sbb_r16_m16abs(e, dreg, addr) emit_sbb_r16_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2479 | #define emit_sbb_r16_m16bd(e, dreg, base, disp) emit_sbb_r16_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2480 | #define emit_sbb_r16_m16isd(e, dreg, index, scale, disp) emit_sbb_r16_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2481 | ||
| 2482 | #define emit_sbb_m16abs_r16(e, addr, sreg) emit_sbb_m16bisd_r16(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2483 | #define emit_sbb_m16bd_r16(e, base, disp, sreg) emit_sbb_m16bisd_r16(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2484 | #define emit_sbb_m16isd_r16(e, index, scale, disp, sreg) emit_sbb_m16bisd_r16(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2485 | ||
| 2486 | ||
| 2487 | /*------------------------------------------------------------------ | |
| 2488 | emit_and_r16_* | |
| 2489 | ------------------------------------------------------------------*/ | |
| 2490 | ||
| 2491 | #define emit_and_r16_imm(e, dreg, imm) emit_arith_r16_imm(e, 4, dreg, imm) | |
| 2492 | #define emit_and_m16bisd_imm(e, base, index, scale, disp, imm) emit_arith_m16bisd_imm(e, 4, base, index, scale, disp, imm) | |
| 2493 | #define emit_and_r16_r16(e, dreg, sreg) emit_arith_r16_r16(e, 4, dreg, sreg) | |
| 2494 | #define emit_and_r16_m16bisd(e, dreg, base, index, scale, disp) emit_arith_r16_m16bisd(e, 4, dreg, base, index, scale, disp) | |
| 2495 | #define emit_and_m16bisd_r16(e, base, index, scale, disp, sreg) emit_arith_m16bisd_r16(e, 4, base, index, scale, disp, sreg) | |
| 2496 | ||
| 2497 | #define emit_and_m16abs_imm(e, addr, imm) emit_and_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2498 | #define emit_and_m16bd_imm(e, base, disp, imm) emit_and_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2499 | #define emit_and_m16isd_imm(e, index, scale, disp, imm) emit_and_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2500 | ||
| 2501 | #define emit_and_r16_m16abs(e, dreg, addr) emit_and_r16_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2502 | #define emit_and_r16_m16bd(e, dreg, base, disp) emit_and_r16_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2503 | #define emit_and_r16_m16isd(e, dreg, index, scale, disp) emit_and_r16_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2504 | ||
| 2505 | #define emit_and_m16abs_r16(e, addr, sreg) emit_and_m16bisd_r16(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2506 | #define emit_and_m16bd_r16(e, base, disp, sreg) emit_and_m16bisd_r16(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2507 | #define emit_and_m16isd_r16(e, index, scale, disp, sreg) emit_and_m16bisd_r16(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2508 | ||
| 2509 | ||
| 2510 | /*------------------------------------------------------------------ | |
| 2511 | emit_sub_r16_* | |
| 2512 | ------------------------------------------------------------------*/ | |
| 2513 | ||
| 2514 | #define emit_sub_r16_imm(e, dreg, imm) emit_arith_r16_imm(e, 5, dreg, imm) | |
| 2515 | #define emit_sub_m16bisd_imm(e, base, index, scale, disp, imm) emit_arith_m16bisd_imm(e, 5, base, index, scale, disp, imm) | |
| 2516 | #define emit_sub_r16_r16(e, dreg, sreg) emit_arith_r16_r16(e, 5, dreg, sreg) | |
| 2517 | #define emit_sub_r16_m16bisd(e, dreg, base, index, scale, disp) emit_arith_r16_m16bisd(e, 5, dreg, base, index, scale, disp) | |
| 2518 | #define emit_sub_m16bisd_r16(e, base, index, scale, disp, sreg) emit_arith_m16bisd_r16(e, 5, base, index, scale, disp, sreg) | |
| 2519 | ||
| 2520 | #define emit_sub_m16abs_imm(e, addr, imm) emit_sub_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2521 | #define emit_sub_m16bd_imm(e, base, disp, imm) emit_sub_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2522 | #define emit_sub_m16isd_imm(e, index, scale, disp, imm) emit_sub_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2523 | ||
| 2524 | #define emit_sub_r16_m16abs(e, dreg, addr) emit_sub_r16_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2525 | #define emit_sub_r16_m16bd(e, dreg, base, disp) emit_sub_r16_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2526 | #define emit_sub_r16_m16isd(e, dreg, index, scale, disp) emit_sub_r16_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2527 | ||
| 2528 | #define emit_sub_m16abs_r16(e, addr, sreg) emit_sub_m16bisd_r16(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2529 | #define emit_sub_m16bd_r16(e, base, disp, sreg) emit_sub_m16bisd_r16(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2530 | #define emit_sub_m16isd_r16(e, index, scale, disp, sreg) emit_sub_m16bisd_r16(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2531 | ||
| 2532 | ||
| 2533 | /*------------------------------------------------------------------ | |
| 2534 | emit_xor_r16_* | |
| 2535 | ------------------------------------------------------------------*/ | |
| 2536 | ||
| 2537 | #define emit_xor_r16_imm(e, dreg, imm) emit_arith_r16_imm(e, 6, dreg, imm) | |
| 2538 | #define emit_xor_m16bisd_imm(e, base, index, scale, disp, imm) emit_arith_m16bisd_imm(e, 6, base, index, scale, disp, imm) | |
| 2539 | #define emit_xor_r16_r16(e, dreg, sreg) emit_arith_r16_r16(e, 6, dreg, sreg) | |
| 2540 | #define emit_xor_r16_m16bisd(e, dreg, base, index, scale, disp) emit_arith_r16_m16bisd(e, 6, dreg, base, index, scale, disp) | |
| 2541 | #define emit_xor_m16bisd_r16(e, base, index, scale, disp, sreg) emit_arith_m16bisd_r16(e, 6, base, index, scale, disp, sreg) | |
| 2542 | ||
| 2543 | #define emit_xor_m16abs_imm(e, addr, imm) emit_xor_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2544 | #define emit_xor_m16bd_imm(e, base, disp, imm) emit_xor_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2545 | #define emit_xor_m16isd_imm(e, index, scale, disp, imm) emit_xor_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2546 | ||
| 2547 | #define emit_xor_r16_m16abs(e, dreg, addr) emit_xor_r16_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2548 | #define emit_xor_r16_m16bd(e, dreg, base, disp) emit_xor_r16_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2549 | #define emit_xor_r16_m16isd(e, dreg, index, scale, disp) emit_xor_r16_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2550 | ||
| 2551 | #define emit_xor_m16abs_r16(e, addr, sreg) emit_xor_m16bisd_r16(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2552 | #define emit_xor_m16bd_r16(e, base, disp, sreg) emit_xor_m16bisd_r16(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2553 | #define emit_xor_m16isd_r16(e, index, scale, disp, sreg) emit_xor_m16bisd_r16(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2554 | ||
| 2555 | ||
| 2556 | /*------------------------------------------------------------------ | |
| 2557 | emit_cmp_r16_* | |
| 2558 | ------------------------------------------------------------------*/ | |
| 2559 | ||
| 2560 | #define emit_cmp_r16_imm(e, dreg, imm) emit_arith_r16_imm(e, 7, dreg, imm) | |
| 2561 | #define emit_cmp_m16bisd_imm(e, base, index, scale, disp, imm) emit_arith_m16bisd_imm(e, 7, base, index, scale, disp, imm) | |
| 2562 | #define emit_cmp_r16_r16(e, dreg, sreg) emit_arith_r16_r16(e, 7, dreg, sreg) | |
| 2563 | #define emit_cmp_r16_m16bisd(e, dreg, base, index, scale, disp) emit_arith_r16_m16bisd(e, 7, dreg, base, index, scale, disp) | |
| 2564 | #define emit_cmp_m16bisd_r16(e, base, index, scale, disp, sreg) emit_arith_m16bisd_r16(e, 7, base, index, scale, disp, sreg) | |
| 2565 | ||
| 2566 | #define emit_cmp_m16abs_imm(e, addr, imm) emit_cmp_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2567 | #define emit_cmp_m16bd_imm(e, base, disp, imm) emit_cmp_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2568 | #define emit_cmp_m16isd_imm(e, index, scale, disp, imm) emit_cmp_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2569 | ||
| 2570 | #define emit_cmp_r16_m16abs(e, dreg, addr) emit_cmp_r16_m16bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2571 | #define emit_cmp_r16_m16bd(e, dreg, base, disp) emit_cmp_r16_m16bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2572 | #define emit_cmp_r16_m16isd(e, dreg, index, scale, disp) emit_cmp_r16_m16bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2573 | ||
| 2574 | #define emit_cmp_m16abs_r16(e, addr, sreg) emit_cmp_m16bisd_r16(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2575 | #define emit_cmp_m16bd_r16(e, base, disp, sreg) emit_cmp_m16bisd_r16(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2576 | #define emit_cmp_m16isd_r16(e, index, scale, disp, sreg) emit_cmp_m16bisd_r16(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2577 | ||
| 2578 | ||
| 2579 | ||
| 2580 | /*************************************************************************** | |
| 2581 | 32-BIT ARITHMETIC EMITTERS | |
| 2582 | ***************************************************************************/ | |
| 2583 | ||
| 2584 | /* | |
| 2585 | Note that the following code relies on this: | |
| 2586 | ||
| 2587 | 00-05 or /0 = ADD | |
| 2588 | 08-0d or /1 = OR | |
| 2589 | 10-15 or /2 = ADC | |
| 2590 | 18-1d or /3 = SBB | |
| 2591 | 20-25 or /4 = AND | |
| 2592 | 28-2d or /5 = SUB | |
| 2593 | 30-35 or /6 = XOR | |
| 2594 | 38-3d or /7 = CMP | |
| 2595 | */ | |
| 2596 | ||
| 2597 | INLINE void emit_arith_r32_imm(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT32 imm) | |
| 2598 | { | |
| 2599 | if ((INT8)imm == (INT32)imm) | |
| 2600 | { | |
| 2601 | emit_op_modrm_reg(emitptr, OP_G1_Ev_Ib, OP_32BIT, opindex, dreg); | |
| 2602 | emit_byte(emitptr, (INT8)imm); | |
| 2603 | } | |
| 2604 | else | |
| 2605 | { | |
| 2606 | emit_op_modrm_reg(emitptr, OP_G1_Ev_Iz, OP_32BIT, opindex, dreg); | |
| 2607 | emit_dword(emitptr, imm); | |
| 2608 | } | |
| 2609 | } | |
| 2610 | ||
| 2611 | INLINE void emit_arith_m32bisd_imm(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT32 imm) | |
| 2612 | { | |
| 2613 | if ((INT8)imm == (INT32)imm) | |
| 2614 | { | |
| 2615 | emit_op_modrm_mem(emitptr, OP_G1_Ev_Ib, OP_32BIT, opindex, base, index, scale, disp); | |
| 2616 | emit_byte(emitptr, (INT8)imm); | |
| 2617 | } | |
| 2618 | else | |
| 2619 | { | |
| 2620 | emit_op_modrm_mem(emitptr, OP_G1_Ev_Iz, OP_32BIT, opindex, base, index, scale, disp); | |
| 2621 | emit_dword(emitptr, imm); | |
| 2622 | } | |
| 2623 | } | |
| 2624 | ||
| 2625 | INLINE void emit_arith_r32_r32(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 sreg) | |
| 2626 | { | |
| 2627 | emit_op_modrm_reg(emitptr, OP_ADD_Gv_Ev + 8 * opindex, OP_32BIT, dreg, sreg); | |
| 2628 | } | |
| 2629 | ||
| 2630 | INLINE void emit_arith_r32_m32bisd(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 2631 | { | |
| 2632 | emit_op_modrm_mem(emitptr, OP_ADD_Gv_Ev + 8 * opindex, OP_32BIT, dreg, base, index, scale, disp); | |
| 2633 | } | |
| 2634 | ||
| 2635 | INLINE void emit_arith_m32bisd_r32(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 2636 | { | |
| 2637 | emit_op_modrm_mem(emitptr, OP_ADD_Ev_Gv + 8 * opindex, OP_32BIT, sreg, base, index, scale, disp); | |
| 2638 | } | |
| 2639 | ||
| 2640 | ||
| 2641 | /*------------------------------------------------------------------ | |
| 2642 | emit_add_r32_* | |
| 2643 | ------------------------------------------------------------------*/ | |
| 2644 | ||
| 2645 | #define emit_add_r32_imm(e, dreg, imm) emit_arith_r32_imm(e, 0, dreg, imm) | |
| 2646 | #define emit_add_m32bisd_imm(e, base, index, scale, disp, imm) emit_arith_m32bisd_imm(e, 0, base, index, scale, disp, imm) | |
| 2647 | #define emit_add_r32_r32(e, dreg, sreg) emit_arith_r32_r32(e, 0, dreg, sreg) | |
| 2648 | #define emit_add_r32_m32bisd(e, dreg, base, index, scale, disp) emit_arith_r32_m32bisd(e, 0, dreg, base, index, scale, disp) | |
| 2649 | #define emit_add_m32bisd_r32(e, base, index, scale, disp, sreg) emit_arith_m32bisd_r32(e, 0, base, index, scale, disp, sreg) | |
| 2650 | ||
| 2651 | #define emit_add_m32abs_imm(e, addr, imm) emit_add_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2652 | #define emit_add_m32bd_imm(e, base, disp, imm) emit_add_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2653 | #define emit_add_m32isd_imm(e, index, scale, disp, imm) emit_add_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2654 | ||
| 2655 | #define emit_add_r32_m32abs(e, dreg, addr) emit_add_r32_m32bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2656 | #define emit_add_r32_m32bd(e, dreg, base, disp) emit_add_r32_m32bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2657 | #define emit_add_r32_m32isd(e, dreg, index, scale, disp) emit_add_r32_m32bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2658 | ||
| 2659 | #define emit_add_m32abs_r32(e, addr, sreg) emit_add_m32bisd_r32(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2660 | #define emit_add_m32bd_r32(e, base, disp, sreg) emit_add_m32bisd_r32(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2661 | #define emit_add_m32isd_r32(e, index, scale, disp, sreg) emit_add_m32bisd_r32(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2662 | ||
| 2663 | ||
| 2664 | /*------------------------------------------------------------------ | |
| 2665 | emit_or_r32_* | |
| 2666 | ------------------------------------------------------------------*/ | |
| 2667 | ||
| 2668 | #define emit_or_r32_imm(e, dreg, imm) emit_arith_r32_imm(e, 1, dreg, imm) | |
| 2669 | #define emit_or_m32bisd_imm(e, base, index, scale, disp, imm) emit_arith_m32bisd_imm(e, 1, base, index, scale, disp, imm) | |
| 2670 | #define emit_or_r32_r32(e, dreg, sreg) emit_arith_r32_r32(e, 1, dreg, sreg) | |
| 2671 | #define emit_or_r32_m32bisd(e, dreg, base, index, scale, disp) emit_arith_r32_m32bisd(e, 1, dreg, base, index, scale, disp) | |
| 2672 | #define emit_or_m32bisd_r32(e, base, index, scale, disp, sreg) emit_arith_m32bisd_r32(e, 1, base, index, scale, disp, sreg) | |
| 2673 | ||
| 2674 | #define emit_or_m32abs_imm(e, addr, imm) emit_or_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2675 | #define emit_or_m32bd_imm(e, base, disp, imm) emit_or_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2676 | #define emit_or_m32isd_imm(e, index, scale, disp, imm) emit_or_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2677 | ||
| 2678 | #define emit_or_r32_m32abs(e, dreg, addr) emit_or_r32_m32bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2679 | #define emit_or_r32_m32bd(e, dreg, base, disp) emit_or_r32_m32bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2680 | #define emit_or_r32_m32isd(e, dreg, index, scale, disp) emit_or_r32_m32bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2681 | ||
| 2682 | #define emit_or_m32abs_r32(e, addr, sreg) emit_or_m32bisd_r32(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2683 | #define emit_or_m32bd_r32(e, base, disp, sreg) emit_or_m32bisd_r32(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2684 | #define emit_or_m32isd_r32(e, index, scale, disp, sreg) emit_or_m32bisd_r32(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2685 | ||
| 2686 | ||
| 2687 | /*------------------------------------------------------------------ | |
| 2688 | emit_adc_r32_* | |
| 2689 | ------------------------------------------------------------------*/ | |
| 2690 | ||
| 2691 | #define emit_adc_r32_imm(e, dreg, imm) emit_arith_r32_imm(e, 2, dreg, imm) | |
| 2692 | #define emit_adc_m32bisd_imm(e, base, index, scale, disp, imm) emit_arith_m32bisd_imm(e, 2, base, index, scale, disp, imm) | |
| 2693 | #define emit_adc_r32_r32(e, dreg, sreg) emit_arith_r32_r32(e, 2, dreg, sreg) | |
| 2694 | #define emit_adc_r32_m32bisd(e, dreg, base, index, scale, disp) emit_arith_r32_m32bisd(e, 2, dreg, base, index, scale, disp) | |
| 2695 | #define emit_adc_m32bisd_r32(e, base, index, scale, disp, sreg) emit_arith_m32bisd_r32(e, 2, base, index, scale, disp, sreg) | |
| 2696 | ||
| 2697 | #define emit_adc_m32abs_imm(e, addr, imm) emit_adc_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2698 | #define emit_adc_m32bd_imm(e, base, disp, imm) emit_adc_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2699 | #define emit_adc_m32isd_imm(e, index, scale, disp, imm) emit_adc_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2700 | ||
| 2701 | #define emit_adc_r32_m32abs(e, dreg, addr) emit_adc_r32_m32bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2702 | #define emit_adc_r32_m32bd(e, dreg, base, disp) emit_adc_r32_m32bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2703 | #define emit_adc_r32_m32isd(e, dreg, index, scale, disp) emit_adc_r32_m32bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2704 | ||
| 2705 | #define emit_adc_m32abs_r32(e, addr, sreg) emit_adc_m32bisd_r32(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2706 | #define emit_adc_m32bd_r32(e, base, disp, sreg) emit_adc_m32bisd_r32(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2707 | #define emit_adc_m32isd_r32(e, index, scale, disp, sreg) emit_adc_m32bisd_r32(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2708 | ||
| 2709 | ||
| 2710 | /*------------------------------------------------------------------ | |
| 2711 | emit_sbb_r32_* | |
| 2712 | ------------------------------------------------------------------*/ | |
| 2713 | ||
| 2714 | #define emit_sbb_r32_imm(e, dreg, imm) emit_arith_r32_imm(e, 3, dreg, imm) | |
| 2715 | #define emit_sbb_m32bisd_imm(e, base, index, scale, disp, imm) emit_arith_m32bisd_imm(e, 3, base, index, scale, disp, imm) | |
| 2716 | #define emit_sbb_r32_r32(e, dreg, sreg) emit_arith_r32_r32(e, 3, dreg, sreg) | |
| 2717 | #define emit_sbb_r32_m32bisd(e, dreg, base, index, scale, disp) emit_arith_r32_m32bisd(e, 3, dreg, base, index, scale, disp) | |
| 2718 | #define emit_sbb_m32bisd_r32(e, base, index, scale, disp, sreg) emit_arith_m32bisd_r32(e, 3, base, index, scale, disp, sreg) | |
| 2719 | ||
| 2720 | #define emit_sbb_m32abs_imm(e, addr, imm) emit_sbb_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2721 | #define emit_sbb_m32bd_imm(e, base, disp, imm) emit_sbb_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2722 | #define emit_sbb_m32isd_imm(e, index, scale, disp, imm) emit_sbb_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2723 | ||
| 2724 | #define emit_sbb_r32_m32abs(e, dreg, addr) emit_sbb_r32_m32bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2725 | #define emit_sbb_r32_m32bd(e, dreg, base, disp) emit_sbb_r32_m32bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2726 | #define emit_sbb_r32_m32isd(e, dreg, index, scale, disp) emit_sbb_r32_m32bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2727 | ||
| 2728 | #define emit_sbb_m32abs_r32(e, addr, sreg) emit_sbb_m32bisd_r32(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2729 | #define emit_sbb_m32bd_r32(e, base, disp, sreg) emit_sbb_m32bisd_r32(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2730 | #define emit_sbb_m32isd_r32(e, index, scale, disp, sreg) emit_sbb_m32bisd_r32(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2731 | ||
| 2732 | ||
| 2733 | /*------------------------------------------------------------------ | |
| 2734 | emit_and_r32_* | |
| 2735 | ------------------------------------------------------------------*/ | |
| 2736 | ||
| 2737 | #define emit_and_r32_imm(e, dreg, imm) emit_arith_r32_imm(e, 4, dreg, imm) | |
| 2738 | #define emit_and_m32bisd_imm(e, base, index, scale, disp, imm) emit_arith_m32bisd_imm(e, 4, base, index, scale, disp, imm) | |
| 2739 | #define emit_and_r32_r32(e, dreg, sreg) emit_arith_r32_r32(e, 4, dreg, sreg) | |
| 2740 | #define emit_and_r32_m32bisd(e, dreg, base, index, scale, disp) emit_arith_r32_m32bisd(e, 4, dreg, base, index, scale, disp) | |
| 2741 | #define emit_and_m32bisd_r32(e, base, index, scale, disp, sreg) emit_arith_m32bisd_r32(e, 4, base, index, scale, disp, sreg) | |
| 2742 | ||
| 2743 | #define emit_and_m32abs_imm(e, addr, imm) emit_and_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2744 | #define emit_and_m32bd_imm(e, base, disp, imm) emit_and_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2745 | #define emit_and_m32isd_imm(e, index, scale, disp, imm) emit_and_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2746 | ||
| 2747 | #define emit_and_r32_m32abs(e, dreg, addr) emit_and_r32_m32bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2748 | #define emit_and_r32_m32bd(e, dreg, base, disp) emit_and_r32_m32bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2749 | #define emit_and_r32_m32isd(e, dreg, index, scale, disp) emit_and_r32_m32bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2750 | ||
| 2751 | #define emit_and_m32abs_r32(e, addr, sreg) emit_and_m32bisd_r32(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2752 | #define emit_and_m32bd_r32(e, base, disp, sreg) emit_and_m32bisd_r32(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2753 | #define emit_and_m32isd_r32(e, index, scale, disp, sreg) emit_and_m32bisd_r32(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2754 | ||
| 2755 | ||
| 2756 | /*------------------------------------------------------------------ | |
| 2757 | emit_sub_r32_* | |
| 2758 | ------------------------------------------------------------------*/ | |
| 2759 | ||
| 2760 | #define emit_sub_r32_imm(e, dreg, imm) emit_arith_r32_imm(e, 5, dreg, imm) | |
| 2761 | #define emit_sub_m32bisd_imm(e, base, index, scale, disp, imm) emit_arith_m32bisd_imm(e, 5, base, index, scale, disp, imm) | |
| 2762 | #define emit_sub_r32_r32(e, dreg, sreg) emit_arith_r32_r32(e, 5, dreg, sreg) | |
| 2763 | #define emit_sub_r32_m32bisd(e, dreg, base, index, scale, disp) emit_arith_r32_m32bisd(e, 5, dreg, base, index, scale, disp) | |
| 2764 | #define emit_sub_m32bisd_r32(e, base, index, scale, disp, sreg) emit_arith_m32bisd_r32(e, 5, base, index, scale, disp, sreg) | |
| 2765 | ||
| 2766 | #define emit_sub_m32abs_imm(e, addr, imm) emit_sub_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2767 | #define emit_sub_m32bd_imm(e, base, disp, imm) emit_sub_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2768 | #define emit_sub_m32isd_imm(e, index, scale, disp, imm) emit_sub_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2769 | ||
| 2770 | #define emit_sub_r32_m32abs(e, dreg, addr) emit_sub_r32_m32bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2771 | #define emit_sub_r32_m32bd(e, dreg, base, disp) emit_sub_r32_m32bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2772 | #define emit_sub_r32_m32isd(e, dreg, index, scale, disp) emit_sub_r32_m32bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2773 | ||
| 2774 | #define emit_sub_m32abs_r32(e, addr, sreg) emit_sub_m32bisd_r32(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2775 | #define emit_sub_m32bd_r32(e, base, disp, sreg) emit_sub_m32bisd_r32(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2776 | #define emit_sub_m32isd_r32(e, index, scale, disp, sreg) emit_sub_m32bisd_r32(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2777 | ||
| 2778 | ||
| 2779 | /*------------------------------------------------------------------ | |
| 2780 | emit_xor_r32_* | |
| 2781 | ------------------------------------------------------------------*/ | |
| 2782 | ||
| 2783 | #define emit_xor_r32_imm(e, dreg, imm) emit_arith_r32_imm(e, 6, dreg, imm) | |
| 2784 | #define emit_xor_m32bisd_imm(e, base, index, scale, disp, imm) emit_arith_m32bisd_imm(e, 6, base, index, scale, disp, imm) | |
| 2785 | #define emit_xor_r32_r32(e, dreg, sreg) emit_arith_r32_r32(e, 6, dreg, sreg) | |
| 2786 | #define emit_xor_r32_m32bisd(e, dreg, base, index, scale, disp) emit_arith_r32_m32bisd(e, 6, dreg, base, index, scale, disp) | |
| 2787 | #define emit_xor_m32bisd_r32(e, base, index, scale, disp, sreg) emit_arith_m32bisd_r32(e, 6, base, index, scale, disp, sreg) | |
| 2788 | ||
| 2789 | #define emit_xor_m32abs_imm(e, addr, imm) emit_xor_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2790 | #define emit_xor_m32bd_imm(e, base, disp, imm) emit_xor_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2791 | #define emit_xor_m32isd_imm(e, index, scale, disp, imm) emit_xor_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2792 | ||
| 2793 | #define emit_xor_r32_m32abs(e, dreg, addr) emit_xor_r32_m32bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2794 | #define emit_xor_r32_m32bd(e, dreg, base, disp) emit_xor_r32_m32bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2795 | #define emit_xor_r32_m32isd(e, dreg, index, scale, disp) emit_xor_r32_m32bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2796 | ||
| 2797 | #define emit_xor_m32abs_r32(e, addr, sreg) emit_xor_m32bisd_r32(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2798 | #define emit_xor_m32bd_r32(e, base, disp, sreg) emit_xor_m32bisd_r32(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2799 | #define emit_xor_m32isd_r32(e, index, scale, disp, sreg) emit_xor_m32bisd_r32(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2800 | ||
| 2801 | ||
| 2802 | /*------------------------------------------------------------------ | |
| 2803 | emit_cmp_r32_* | |
| 2804 | ------------------------------------------------------------------*/ | |
| 2805 | ||
| 2806 | #define emit_cmp_r32_imm(e, dreg, imm) emit_arith_r32_imm(e, 7, dreg, imm) | |
| 2807 | #define emit_cmp_m32bisd_imm(e, base, index, scale, disp, imm) emit_arith_m32bisd_imm(e, 7, base, index, scale, disp, imm) | |
| 2808 | #define emit_cmp_r32_r32(e, dreg, sreg) emit_arith_r32_r32(e, 7, dreg, sreg) | |
| 2809 | #define emit_cmp_r32_m32bisd(e, dreg, base, index, scale, disp) emit_arith_r32_m32bisd(e, 7, dreg, base, index, scale, disp) | |
| 2810 | #define emit_cmp_m32bisd_r32(e, base, index, scale, disp, sreg) emit_arith_m32bisd_r32(e, 7, base, index, scale, disp, sreg) | |
| 2811 | ||
| 2812 | #define emit_cmp_m32abs_imm(e, addr, imm) emit_cmp_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2813 | #define emit_cmp_m32bd_imm(e, base, disp, imm) emit_cmp_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2814 | #define emit_cmp_m32isd_imm(e, index, scale, disp, imm) emit_cmp_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2815 | ||
| 2816 | #define emit_cmp_r32_m32abs(e, dreg, addr) emit_cmp_r32_m32bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2817 | #define emit_cmp_r32_m32bd(e, dreg, base, disp) emit_cmp_r32_m32bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2818 | #define emit_cmp_r32_m32isd(e, dreg, index, scale, disp) emit_cmp_r32_m32bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2819 | ||
| 2820 | #define emit_cmp_m32abs_r32(e, addr, sreg) emit_cmp_m32bisd_r32(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2821 | #define emit_cmp_m32bd_r32(e, base, disp, sreg) emit_cmp_m32bisd_r32(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2822 | #define emit_cmp_m32isd_r32(e, index, scale, disp, sreg) emit_cmp_m32bisd_r32(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2823 | ||
| 2824 | ||
| 2825 | ||
| 2826 | /*************************************************************************** | |
| 2827 | 64-BIT ARITHMETIC EMITTERS | |
| 2828 | ***************************************************************************/ | |
| 2829 | ||
| 2830 | #ifdef PTR64 | |
| 2831 | /* | |
| 2832 | Note that the following code relies on this: | |
| 2833 | ||
| 2834 | 00-05 or /0 = ADD | |
| 2835 | 08-0d or /1 = OR | |
| 2836 | 10-15 or /2 = ADC | |
| 2837 | 18-1d or /3 = SBB | |
| 2838 | 20-25 or /4 = AND | |
| 2839 | 28-2d or /5 = SUB | |
| 2840 | 30-35 or /6 = XOR | |
| 2841 | 38-3d or /7 = CMP | |
| 2842 | */ | |
| 2843 | ||
| 2844 | INLINE void emit_arith_r64_imm(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT32 imm) | |
| 2845 | { | |
| 2846 | if ((INT8)imm == (INT32)imm) | |
| 2847 | { | |
| 2848 | emit_op_modrm_reg(emitptr, OP_G1_Ev_Ib, OP_64BIT, opindex, dreg); | |
| 2849 | emit_byte(emitptr, (INT8)imm); | |
| 2850 | } | |
| 2851 | else | |
| 2852 | { | |
| 2853 | emit_op_modrm_reg(emitptr, OP_G1_Ev_Iz, OP_64BIT, opindex, dreg); | |
| 2854 | emit_dword(emitptr, imm); | |
| 2855 | } | |
| 2856 | } | |
| 2857 | ||
| 2858 | INLINE void emit_arith_m64bisd_imm(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT32 imm) | |
| 2859 | { | |
| 2860 | if ((INT8)imm == (INT32)imm) | |
| 2861 | { | |
| 2862 | emit_op_modrm_mem(emitptr, OP_G1_Ev_Ib, OP_64BIT, opindex, base, index, scale, disp); | |
| 2863 | emit_byte(emitptr, (INT8)imm); | |
| 2864 | } | |
| 2865 | else | |
| 2866 | { | |
| 2867 | emit_op_modrm_mem(emitptr, OP_G1_Ev_Iz, OP_64BIT, opindex, base, index, scale, disp); | |
| 2868 | emit_dword(emitptr, imm); | |
| 2869 | } | |
| 2870 | } | |
| 2871 | ||
| 2872 | INLINE void emit_arith_r64_r64(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 sreg) | |
| 2873 | { | |
| 2874 | emit_op_modrm_reg(emitptr, OP_ADD_Gv_Ev + 8 * opindex, OP_64BIT, dreg, sreg); | |
| 2875 | } | |
| 2876 | ||
| 2877 | INLINE void emit_arith_r64_m64bisd(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 2878 | { | |
| 2879 | emit_op_modrm_mem(emitptr, OP_ADD_Gv_Ev + 8 * opindex, OP_64BIT, dreg, base, index, scale, disp); | |
| 2880 | } | |
| 2881 | ||
| 2882 | INLINE void emit_arith_m64bisd_r64(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 sreg) | |
| 2883 | { | |
| 2884 | emit_op_modrm_mem(emitptr, OP_ADD_Ev_Gv + 8 * opindex, OP_64BIT, sreg, base, index, scale, disp); | |
| 2885 | } | |
| 2886 | ||
| 2887 | ||
| 2888 | /*------------------------------------------------------------------ | |
| 2889 | emit_add_r64_* | |
| 2890 | ------------------------------------------------------------------*/ | |
| 2891 | ||
| 2892 | #define emit_add_r64_imm(e, dreg, imm) emit_arith_r64_imm(e, 0, dreg, imm) | |
| 2893 | #define emit_add_m64bisd_imm(e, base, index, scale, disp, imm) emit_arith_m64bisd_imm(e, 0, base, index, scale, disp, imm) | |
| 2894 | #define emit_add_r64_r64(e, dreg, sreg) emit_arith_r64_r64(e, 0, dreg, sreg) | |
| 2895 | #define emit_add_r64_m64bisd(e, dreg, base, index, scale, disp) emit_arith_r64_m64bisd(e, 0, dreg, base, index, scale, disp) | |
| 2896 | #define emit_add_m64bisd_r64(e, base, index, scale, disp, sreg) emit_arith_m64bisd_r64(e, 0, base, index, scale, disp, sreg) | |
| 2897 | ||
| 2898 | #define emit_add_m64abs_imm(e, addr, imm) emit_add_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2899 | #define emit_add_m64bd_imm(e, base, disp, imm) emit_add_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2900 | #define emit_add_m64isd_imm(e, index, scale, disp, imm) emit_add_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2901 | ||
| 2902 | #define emit_add_r64_m64abs(e, dreg, addr) emit_add_r64_m64bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2903 | #define emit_add_r64_m64bd(e, dreg, base, disp) emit_add_r64_m64bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2904 | #define emit_add_r64_m64isd(e, dreg, index, scale, disp) emit_add_r64_m64bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2905 | ||
| 2906 | #define emit_add_m64abs_r64(e, addr, sreg) emit_add_m64bisd_r64(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2907 | #define emit_add_m64bd_r64(e, base, disp, sreg) emit_add_m64bisd_r64(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2908 | #define emit_add_m64isd_r64(e, index, scale, disp, sreg) emit_add_m64bisd_r64(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2909 | ||
| 2910 | ||
| 2911 | /*------------------------------------------------------------------ | |
| 2912 | emit_or_r64_* | |
| 2913 | ------------------------------------------------------------------*/ | |
| 2914 | ||
| 2915 | #define emit_or_r64_imm(e, dreg, imm) emit_arith_r64_imm(e, 1, dreg, imm) | |
| 2916 | #define emit_or_m64bisd_imm(e, base, index, scale, disp, imm) emit_arith_m64bisd_imm(e, 1, base, index, scale, disp, imm) | |
| 2917 | #define emit_or_r64_r64(e, dreg, sreg) emit_arith_r64_r64(e, 1, dreg, sreg) | |
| 2918 | #define emit_or_r64_m64bisd(e, dreg, base, index, scale, disp) emit_arith_r64_m64bisd(e, 1, dreg, base, index, scale, disp) | |
| 2919 | #define emit_or_m64bisd_r64(e, base, index, scale, disp, sreg) emit_arith_m64bisd_r64(e, 1, base, index, scale, disp, sreg) | |
| 2920 | ||
| 2921 | #define emit_or_m64abs_imm(e, addr, imm) emit_or_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2922 | #define emit_or_m64bd_imm(e, base, disp, imm) emit_or_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2923 | #define emit_or_m64isd_imm(e, index, scale, disp, imm) emit_or_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2924 | ||
| 2925 | #define emit_or_r64_m64abs(e, dreg, addr) emit_or_r64_m64bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2926 | #define emit_or_r64_m64bd(e, dreg, base, disp) emit_or_r64_m64bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2927 | #define emit_or_r64_m64isd(e, dreg, index, scale, disp) emit_or_r64_m64bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2928 | ||
| 2929 | #define emit_or_m64abs_r64(e, addr, sreg) emit_or_m64bisd_r64(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2930 | #define emit_or_m64bd_r64(e, base, disp, sreg) emit_or_m64bisd_r64(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2931 | #define emit_or_m64isd_r64(e, index, scale, disp, sreg) emit_or_m64bisd_r64(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2932 | ||
| 2933 | ||
| 2934 | /*------------------------------------------------------------------ | |
| 2935 | emit_adc_r64_* | |
| 2936 | ------------------------------------------------------------------*/ | |
| 2937 | ||
| 2938 | #define emit_adc_r64_imm(e, dreg, imm) emit_arith_r64_imm(e, 2, dreg, imm) | |
| 2939 | #define emit_adc_m64bisd_imm(e, base, index, scale, disp, imm) emit_arith_m64bisd_imm(e, 2, base, index, scale, disp, imm) | |
| 2940 | #define emit_adc_r64_r64(e, dreg, sreg) emit_arith_r64_r64(e, 2, dreg, sreg) | |
| 2941 | #define emit_adc_r64_m64bisd(e, dreg, base, index, scale, disp) emit_arith_r64_m64bisd(e, 2, dreg, base, index, scale, disp) | |
| 2942 | #define emit_adc_m64bisd_r64(e, base, index, scale, disp, sreg) emit_arith_m64bisd_r64(e, 2, base, index, scale, disp, sreg) | |
| 2943 | ||
| 2944 | #define emit_adc_m64abs_imm(e, addr, imm) emit_adc_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2945 | #define emit_adc_m64bd_imm(e, base, disp, imm) emit_adc_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2946 | #define emit_adc_m64isd_imm(e, index, scale, disp, imm) emit_adc_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2947 | ||
| 2948 | #define emit_adc_r64_m64abs(e, dreg, addr) emit_adc_r64_m64bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2949 | #define emit_adc_r64_m64bd(e, dreg, base, disp) emit_adc_r64_m64bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2950 | #define emit_adc_r64_m64isd(e, dreg, index, scale, disp) emit_adc_r64_m64bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2951 | ||
| 2952 | #define emit_adc_m64abs_r64(e, addr, sreg) emit_adc_m64bisd_r64(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2953 | #define emit_adc_m64bd_r64(e, base, disp, sreg) emit_adc_m64bisd_r64(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2954 | #define emit_adc_m64isd_r64(e, index, scale, disp, sreg) emit_adc_m64bisd_r64(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2955 | ||
| 2956 | ||
| 2957 | /*------------------------------------------------------------------ | |
| 2958 | emit_sbb_r64_* | |
| 2959 | ------------------------------------------------------------------*/ | |
| 2960 | ||
| 2961 | #define emit_sbb_r64_imm(e, dreg, imm) emit_arith_r64_imm(e, 3, dreg, imm) | |
| 2962 | #define emit_sbb_m64bisd_imm(e, base, index, scale, disp, imm) emit_arith_m64bisd_imm(e, 3, base, index, scale, disp, imm) | |
| 2963 | #define emit_sbb_r64_r64(e, dreg, sreg) emit_arith_r64_r64(e, 3, dreg, sreg) | |
| 2964 | #define emit_sbb_r64_m64bisd(e, dreg, base, index, scale, disp) emit_arith_r64_m64bisd(e, 3, dreg, base, index, scale, disp) | |
| 2965 | #define emit_sbb_m64bisd_r64(e, base, index, scale, disp, sreg) emit_arith_m64bisd_r64(e, 3, base, index, scale, disp, sreg) | |
| 2966 | ||
| 2967 | #define emit_sbb_m64abs_imm(e, addr, imm) emit_sbb_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2968 | #define emit_sbb_m64bd_imm(e, base, disp, imm) emit_sbb_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2969 | #define emit_sbb_m64isd_imm(e, index, scale, disp, imm) emit_sbb_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2970 | ||
| 2971 | #define emit_sbb_r64_m64abs(e, dreg, addr) emit_sbb_r64_m64bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2972 | #define emit_sbb_r64_m64bd(e, dreg, base, disp) emit_sbb_r64_m64bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2973 | #define emit_sbb_r64_m64isd(e, dreg, index, scale, disp) emit_sbb_r64_m64bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2974 | ||
| 2975 | #define emit_sbb_m64abs_r64(e, addr, sreg) emit_sbb_m64bisd_r64(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2976 | #define emit_sbb_m64bd_r64(e, base, disp, sreg) emit_sbb_m64bisd_r64(e, (base), REG_NONE, 1, (disp), sreg) | |
| 2977 | #define emit_sbb_m64isd_r64(e, index, scale, disp, sreg) emit_sbb_m64bisd_r64(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 2978 | ||
| 2979 | ||
| 2980 | /*------------------------------------------------------------------ | |
| 2981 | emit_and_r64_* | |
| 2982 | ------------------------------------------------------------------*/ | |
| 2983 | ||
| 2984 | #define emit_and_r64_imm(e, dreg, imm) emit_arith_r64_imm(e, 4, dreg, imm) | |
| 2985 | #define emit_and_m64bisd_imm(e, base, index, scale, disp, imm) emit_arith_m64bisd_imm(e, 4, base, index, scale, disp, imm) | |
| 2986 | #define emit_and_r64_r64(e, dreg, sreg) emit_arith_r64_r64(e, 4, dreg, sreg) | |
| 2987 | #define emit_and_r64_m64bisd(e, dreg, base, index, scale, disp) emit_arith_r64_m64bisd(e, 4, dreg, base, index, scale, disp) | |
| 2988 | #define emit_and_m64bisd_r64(e, base, index, scale, disp, sreg) emit_arith_m64bisd_r64(e, 4, base, index, scale, disp, sreg) | |
| 2989 | ||
| 2990 | #define emit_and_m64abs_imm(e, addr, imm) emit_and_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 2991 | #define emit_and_m64bd_imm(e, base, disp, imm) emit_and_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 2992 | #define emit_and_m64isd_imm(e, index, scale, disp, imm) emit_and_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 2993 | ||
| 2994 | #define emit_and_r64_m64abs(e, dreg, addr) emit_and_r64_m64bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 2995 | #define emit_and_r64_m64bd(e, dreg, base, disp) emit_and_r64_m64bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 2996 | #define emit_and_r64_m64isd(e, dreg, index, scale, disp) emit_and_r64_m64bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 2997 | ||
| 2998 | #define emit_and_m64abs_r64(e, addr, sreg) emit_and_m64bisd_r64(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 2999 | #define emit_and_m64bd_r64(e, base, disp, sreg) emit_and_m64bisd_r64(e, (base), REG_NONE, 1, (disp), sreg) | |
| 3000 | #define emit_and_m64isd_r64(e, index, scale, disp, sreg) emit_and_m64bisd_r64(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 3001 | ||
| 3002 | ||
| 3003 | /*------------------------------------------------------------------ | |
| 3004 | emit_sub_r64_* | |
| 3005 | ------------------------------------------------------------------*/ | |
| 3006 | ||
| 3007 | #define emit_sub_r64_imm(e, dreg, imm) emit_arith_r64_imm(e, 5, dreg, imm) | |
| 3008 | #define emit_sub_m64bisd_imm(e, base, index, scale, disp, imm) emit_arith_m64bisd_imm(e, 5, base, index, scale, disp, imm) | |
| 3009 | #define emit_sub_r64_r64(e, dreg, sreg) emit_arith_r64_r64(e, 5, dreg, sreg) | |
| 3010 | #define emit_sub_r64_m64bisd(e, dreg, base, index, scale, disp) emit_arith_r64_m64bisd(e, 5, dreg, base, index, scale, disp) | |
| 3011 | #define emit_sub_m64bisd_r64(e, base, index, scale, disp, sreg) emit_arith_m64bisd_r64(e, 5, base, index, scale, disp, sreg) | |
| 3012 | ||
| 3013 | #define emit_sub_m64abs_imm(e, addr, imm) emit_sub_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3014 | #define emit_sub_m64bd_imm(e, base, disp, imm) emit_sub_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3015 | #define emit_sub_m64isd_imm(e, index, scale, disp, imm) emit_sub_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3016 | ||
| 3017 | #define emit_sub_r64_m64abs(e, dreg, addr) emit_sub_r64_m64bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3018 | #define emit_sub_r64_m64bd(e, dreg, base, disp) emit_sub_r64_m64bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 3019 | #define emit_sub_r64_m64isd(e, dreg, index, scale, disp) emit_sub_r64_m64bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 3020 | ||
| 3021 | #define emit_sub_m64abs_r64(e, addr, sreg) emit_sub_m64bisd_r64(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 3022 | #define emit_sub_m64bd_r64(e, base, disp, sreg) emit_sub_m64bisd_r64(e, (base), REG_NONE, 1, (disp), sreg) | |
| 3023 | #define emit_sub_m64isd_r64(e, index, scale, disp, sreg) emit_sub_m64bisd_r64(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 3024 | ||
| 3025 | ||
| 3026 | /*------------------------------------------------------------------ | |
| 3027 | emit_xor_r64_* | |
| 3028 | ------------------------------------------------------------------*/ | |
| 3029 | ||
| 3030 | #define emit_xor_r64_imm(e, dreg, imm) emit_arith_r64_imm(e, 6, dreg, imm) | |
| 3031 | #define emit_xor_m64bisd_imm(e, base, index, scale, disp, imm) emit_arith_m64bisd_imm(e, 6, base, index, scale, disp, imm) | |
| 3032 | #define emit_xor_r64_r64(e, dreg, sreg) emit_arith_r64_r64(e, 6, dreg, sreg) | |
| 3033 | #define emit_xor_r64_m64bisd(e, dreg, base, index, scale, disp) emit_arith_r64_m64bisd(e, 6, dreg, base, index, scale, disp) | |
| 3034 | #define emit_xor_m64bisd_r64(e, base, index, scale, disp, sreg) emit_arith_m64bisd_r64(e, 6, base, index, scale, disp, sreg) | |
| 3035 | ||
| 3036 | #define emit_xor_m64abs_imm(e, addr, imm) emit_xor_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3037 | #define emit_xor_m64bd_imm(e, base, disp, imm) emit_xor_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3038 | #define emit_xor_m64isd_imm(e, index, scale, disp, imm) emit_xor_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3039 | ||
| 3040 | #define emit_xor_r64_m64abs(e, dreg, addr) emit_xor_r64_m64bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3041 | #define emit_xor_r64_m64bd(e, dreg, base, disp) emit_xor_r64_m64bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 3042 | #define emit_xor_r64_m64isd(e, dreg, index, scale, disp) emit_xor_r64_m64bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 3043 | ||
| 3044 | #define emit_xor_m64abs_r64(e, addr, sreg) emit_xor_m64bisd_r64(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 3045 | #define emit_xor_m64bd_r64(e, base, disp, sreg) emit_xor_m64bisd_r64(e, (base), REG_NONE, 1, (disp), sreg) | |
| 3046 | #define emit_xor_m64isd_r64(e, index, scale, disp, sreg) emit_xor_m64bisd_r64(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 3047 | ||
| 3048 | ||
| 3049 | /*------------------------------------------------------------------ | |
| 3050 | emit_cmp_r64_* | |
| 3051 | ------------------------------------------------------------------*/ | |
| 3052 | ||
| 3053 | #define emit_cmp_r64_imm(e, dreg, imm) emit_arith_r64_imm(e, 7, dreg, imm) | |
| 3054 | #define emit_cmp_m64bisd_imm(e, base, index, scale, disp, imm) emit_arith_m64bisd_imm(e, 7, base, index, scale, disp, imm) | |
| 3055 | #define emit_cmp_r64_r64(e, dreg, sreg) emit_arith_r64_r64(e, 7, dreg, sreg) | |
| 3056 | #define emit_cmp_r64_m64bisd(e, dreg, base, index, scale, disp) emit_arith_r64_m64bisd(e, 7, dreg, base, index, scale, disp) | |
| 3057 | #define emit_cmp_m64bisd_r64(e, base, index, scale, disp, sreg) emit_arith_m64bisd_r64(e, 7, base, index, scale, disp, sreg) | |
| 3058 | ||
| 3059 | #define emit_cmp_m64abs_imm(e, addr, imm) emit_cmp_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3060 | #define emit_cmp_m64bd_imm(e, base, disp, imm) emit_cmp_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3061 | #define emit_cmp_m64isd_imm(e, index, scale, disp, imm) emit_cmp_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3062 | ||
| 3063 | #define emit_cmp_r64_m64abs(e, dreg, addr) emit_cmp_r64_m64bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3064 | #define emit_cmp_r64_m64bd(e, dreg, base, disp) emit_cmp_r64_m64bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 3065 | #define emit_cmp_r64_m64isd(e, dreg, index, scale, disp) emit_cmp_r64_m64bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 3066 | ||
| 3067 | #define emit_cmp_m64abs_r64(e, addr, sreg) emit_cmp_m64bisd_r64(e, REG_NONE, REG_NONE, 1, (INT32)(addr), sreg) | |
| 3068 | #define emit_cmp_m64bd_r64(e, base, disp, sreg) emit_cmp_m64bisd_r64(e, (base), REG_NONE, 1, (disp), sreg) | |
| 3069 | #define emit_cmp_m64isd_r64(e, index, scale, disp, sreg) emit_cmp_m64bisd_r64(e, REG_NONE, (index), (scale), (disp), sreg) | |
| 3070 | ||
| 3071 | #endif | |
| 3072 | ||
| 3073 | ||
| 3074 | ||
| 3075 | /*************************************************************************** | |
| 3076 | 8-BIT SHIFT EMITTERS | |
| 3077 | ***************************************************************************/ | |
| 3078 | ||
| 3079 | /* | |
| 3080 | Note that the following code relies on this: | |
| 3081 | ||
| 3082 | /0 = ROL | |
| 3083 | /1 = ROR | |
| 3084 | /2 = RCL | |
| 3085 | /3 = RCR | |
| 3086 | /4 = SHL | |
| 3087 | /5 = SHR | |
| 3088 | /7 = SAR | |
| 3089 | */ | |
| 3090 | ||
| 3091 | /*------------------------------------------------------------------ | |
| 3092 | emit_shift_r8_* | |
| 3093 | ------------------------------------------------------------------*/ | |
| 3094 | ||
| 3095 | INLINE void emit_shift_r8_imm(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 imm) | |
| 3096 | { | |
| 3097 | if (imm == 1) | |
| 3098 | emit_op_modrm_reg(emitptr, OP_G2_Eb_1, OP_32BIT, opindex, dreg); | |
| 3099 | else | |
| 3100 | { | |
| 3101 | emit_op_modrm_reg(emitptr, OP_G2_Eb_Ib, OP_32BIT, opindex, dreg); | |
| 3102 | emit_byte(emitptr, imm); | |
| 3103 | } | |
| 3104 | } | |
| 3105 | ||
| 3106 | INLINE void emit_shift_m8bisd_imm(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 imm) | |
| 3107 | { | |
| 3108 | if (imm == 1) | |
| 3109 | emit_op_modrm_mem(emitptr, OP_G2_Eb_1, OP_32BIT, opindex, base, index, scale, disp); | |
| 3110 | else | |
| 3111 | { | |
| 3112 | emit_op_modrm_mem(emitptr, OP_G2_Eb_Ib, OP_32BIT, opindex, base, index, scale, disp); | |
| 3113 | emit_byte(emitptr, imm); | |
| 3114 | } | |
| 3115 | } | |
| 3116 | ||
| 3117 | INLINE void emit_shift_r8_cl(x86code **emitptr, UINT8 opindex, UINT8 dreg) | |
| 3118 | { | |
| 3119 | emit_op_modrm_reg(emitptr, OP_G2_Eb_CL, OP_32BIT, opindex, dreg); | |
| 3120 | } | |
| 3121 | ||
| 3122 | INLINE void emit_shift_m8bisd_cl(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 3123 | { | |
| 3124 | emit_op_modrm_mem(emitptr, OP_G2_Eb_CL, OP_32BIT, opindex, base, index, scale, disp); | |
| 3125 | } | |
| 3126 | ||
| 3127 | ||
| 3128 | /*------------------------------------------------------------------ | |
| 3129 | emit_rol_r8_* | |
| 3130 | ------------------------------------------------------------------*/ | |
| 3131 | ||
| 3132 | #define emit_rol_r8_imm(e, dreg, imm) emit_shift_r8_imm(e, 0, dreg, imm) | |
| 3133 | #define emit_rol_m8bisd_imm(e, base, index, scale, disp, imm) emit_shift_m8bisd_imm(e, 0, base, index, scale, disp, imm) | |
| 3134 | #define emit_rol_r8_cl(e, dreg) emit_shift_r8_cl(e, 0, dreg) | |
| 3135 | #define emit_rol_m8bisd_cl(e, base, index, scale, disp) emit_shift_m8bisd_cl(e, 0, base, index, scale, disp) | |
| 3136 | ||
| 3137 | #define emit_rol_m8abs_imm(e, addr, imm) emit_rol_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3138 | #define emit_rol_m8bd_imm(e, base, disp, imm) emit_rol_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3139 | #define emit_rol_m8isd_imm(e, index, scale, disp, imm) emit_rol_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3140 | ||
| 3141 | #define emit_rol_m8abs_cl(e, addr) emit_rol_m8bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3142 | #define emit_rol_m8bd_cl(e, base, disp) emit_rol_m8bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3143 | #define emit_rol_m8isd_cl(e, index, scale, disp) emit_rol_m8bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3144 | ||
| 3145 | ||
| 3146 | /*------------------------------------------------------------------ | |
| 3147 | emit_ror_r8_* | |
| 3148 | ------------------------------------------------------------------*/ | |
| 3149 | ||
| 3150 | #define emit_ror_r8_imm(e, dreg, imm) emit_shift_r8_imm(e, 1, dreg, imm) | |
| 3151 | #define emit_ror_m8bisd_imm(e, base, index, scale, disp, imm) emit_shift_m8bisd_imm(e, 1, base, index, scale, disp, imm) | |
| 3152 | #define emit_ror_r8_cl(e, dreg) emit_shift_r8_cl(e, 1, dreg) | |
| 3153 | #define emit_ror_m8bisd_cl(e, base, index, scale, disp) emit_shift_m8bisd_cl(e, 1, base, index, scale, disp) | |
| 3154 | ||
| 3155 | #define emit_ror_m8abs_imm(e, addr, imm) emit_ror_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3156 | #define emit_ror_m8bd_imm(e, base, disp, imm) emit_ror_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3157 | #define emit_ror_m8isd_imm(e, index, scale, disp, imm) emit_ror_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3158 | ||
| 3159 | #define emit_ror_m8abs_cl(e, addr) emit_ror_m8bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3160 | #define emit_ror_m8bd_cl(e, base, disp) emit_ror_m8bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3161 | #define emit_ror_m8isd_cl(e, index, scale, disp) emit_ror_m8bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3162 | ||
| 3163 | ||
| 3164 | /*------------------------------------------------------------------ | |
| 3165 | emit_rcl_r8_* | |
| 3166 | ------------------------------------------------------------------*/ | |
| 3167 | ||
| 3168 | #define emit_rcl_r8_imm(e, dreg, imm) emit_shift_r8_imm(e, 2, dreg, imm) | |
| 3169 | #define emit_rcl_m8bisd_imm(e, base, index, scale, disp, imm) emit_shift_m8bisd_imm(e, 2, base, index, scale, disp, imm) | |
| 3170 | #define emit_rcl_r8_cl(e, dreg) emit_shift_r8_cl(e, 2, dreg) | |
| 3171 | #define emit_rcl_m8bisd_cl(e, base, index, scale, disp) emit_shift_m8bisd_cl(e, 2, base, index, scale, disp) | |
| 3172 | ||
| 3173 | #define emit_rcl_m8abs_imm(e, addr, imm) emit_rcl_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3174 | #define emit_rcl_m8bd_imm(e, base, disp, imm) emit_rcl_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3175 | #define emit_rcl_m8isd_imm(e, index, scale, disp, imm) emit_rcl_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3176 | ||
| 3177 | #define emit_rcl_m8abs_cl(e, addr) emit_rcl_m8bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3178 | #define emit_rcl_m8bd_cl(e, base, disp) emit_rcl_m8bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3179 | #define emit_rcl_m8isd_cl(e, index, scale, disp) emit_rcl_m8bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3180 | ||
| 3181 | ||
| 3182 | /*------------------------------------------------------------------ | |
| 3183 | emit_rcr_r8_* | |
| 3184 | ------------------------------------------------------------------*/ | |
| 3185 | ||
| 3186 | #define emit_rcr_r8_imm(e, dreg, imm) emit_shift_r8_imm(e, 3, dreg, imm) | |
| 3187 | #define emit_rcr_m8bisd_imm(e, base, index, scale, disp, imm) emit_shift_m8bisd_imm(e, 3, base, index, scale, disp, imm) | |
| 3188 | #define emit_rcr_r8_cl(e, dreg) emit_shift_r8_cl(e, 3, dreg) | |
| 3189 | #define emit_rcr_m8bisd_cl(e, base, index, scale, disp) emit_shift_m8bisd_cl(e, 3, base, index, scale, disp) | |
| 3190 | ||
| 3191 | #define emit_rcr_m8abs_imm(e, addr, imm) emit_rcr_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3192 | #define emit_rcr_m8bd_imm(e, base, disp, imm) emit_rcr_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3193 | #define emit_rcr_m8isd_imm(e, index, scale, disp, imm) emit_rcr_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3194 | ||
| 3195 | #define emit_rcr_m8abs_cl(e, addr) emit_rcr_m8bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3196 | #define emit_rcr_m8bd_cl(e, base, disp) emit_rcr_m8bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3197 | #define emit_rcr_m8isd_cl(e, index, scale, disp) emit_rcr_m8bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3198 | ||
| 3199 | ||
| 3200 | /*------------------------------------------------------------------ | |
| 3201 | emit_shl_r8_* | |
| 3202 | ------------------------------------------------------------------*/ | |
| 3203 | ||
| 3204 | #define emit_shl_r8_imm(e, dreg, imm) emit_shift_r8_imm(e, 4, dreg, imm) | |
| 3205 | #define emit_shl_m8bisd_imm(e, base, index, scale, disp, imm) emit_shift_m8bisd_imm(e, 4, base, index, scale, disp, imm) | |
| 3206 | #define emit_shl_r8_cl(e, dreg) emit_shift_r8_cl(e, 4, dreg) | |
| 3207 | #define emit_shl_m8bisd_cl(e, base, index, scale, disp) emit_shift_m8bisd_cl(e, 4, base, index, scale, disp) | |
| 3208 | ||
| 3209 | #define emit_shl_m8abs_imm(e, addr, imm) emit_shl_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3210 | #define emit_shl_m8bd_imm(e, base, disp, imm) emit_shl_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3211 | #define emit_shl_m8isd_imm(e, index, scale, disp, imm) emit_shl_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3212 | ||
| 3213 | #define emit_shl_m8abs_cl(e, addr) emit_shl_m8bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3214 | #define emit_shl_m8bd_cl(e, base, disp) emit_shl_m8bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3215 | #define emit_shl_m8isd_cl(e, index, scale, disp) emit_shl_m8bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3216 | ||
| 3217 | ||
| 3218 | /*------------------------------------------------------------------ | |
| 3219 | emit_shr_r8_* | |
| 3220 | ------------------------------------------------------------------*/ | |
| 3221 | ||
| 3222 | #define emit_shr_r8_imm(e, dreg, imm) emit_shift_r8_imm(e, 5, dreg, imm) | |
| 3223 | #define emit_shr_m8bisd_imm(e, base, index, scale, disp, imm) emit_shift_m8bisd_imm(e, 5, base, index, scale, disp, imm) | |
| 3224 | #define emit_shr_r8_cl(e, dreg) emit_shift_r8_cl(e, 5, dreg) | |
| 3225 | #define emit_shr_m8bisd_cl(e, base, index, scale, disp) emit_shift_m8bisd_cl(e, 5, base, index, scale, disp) | |
| 3226 | ||
| 3227 | #define emit_shr_m8abs_imm(e, addr, imm) emit_shr_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3228 | #define emit_shr_m8bd_imm(e, base, disp, imm) emit_shr_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3229 | #define emit_shr_m8isd_imm(e, index, scale, disp, imm) emit_shr_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3230 | ||
| 3231 | #define emit_shr_m8abs_cl(e, addr) emit_shr_m8bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3232 | #define emit_shr_m8bd_cl(e, base, disp) emit_shr_m8bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3233 | #define emit_shr_m8isd_cl(e, index, scale, disp) emit_shr_m8bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3234 | ||
| 3235 | ||
| 3236 | /*------------------------------------------------------------------ | |
| 3237 | emit_sar_r8_* | |
| 3238 | ------------------------------------------------------------------*/ | |
| 3239 | ||
| 3240 | #define emit_sar_r8_imm(e, dreg, imm) emit_shift_r8_imm(e, 7, dreg, imm) | |
| 3241 | #define emit_sar_m8bisd_imm(e, base, index, scale, disp, imm) emit_shift_m8bisd_imm(e, 7, base, index, scale, disp, imm) | |
| 3242 | #define emit_sar_r8_cl(e, dreg) emit_shift_r8_cl(e, 7, dreg) | |
| 3243 | #define emit_sar_m8bisd_cl(e, base, index, scale, disp) emit_shift_m8bisd_cl(e, 7, base, index, scale, disp) | |
| 3244 | ||
| 3245 | #define emit_sar_m8abs_imm(e, addr, imm) emit_sar_m8bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3246 | #define emit_sar_m8bd_imm(e, base, disp, imm) emit_sar_m8bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3247 | #define emit_sar_m8isd_imm(e, index, scale, disp, imm) emit_sar_m8bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3248 | ||
| 3249 | #define emit_sar_m8abs_cl(e, addr) emit_sar_m8bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3250 | #define emit_sar_m8bd_cl(e, base, disp) emit_sar_m8bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3251 | #define emit_sar_m8isd_cl(e, index, scale, disp) emit_sar_m8bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3252 | ||
| 3253 | ||
| 3254 | ||
| 3255 | /*************************************************************************** | |
| 3256 | 16-BIT SHIFT EMITTERS | |
| 3257 | ***************************************************************************/ | |
| 3258 | ||
| 3259 | /* | |
| 3260 | Note that the following code relies on this: | |
| 3261 | ||
| 3262 | /0 = ROL | |
| 3263 | /1 = ROR | |
| 3264 | /2 = RCL | |
| 3265 | /3 = RCR | |
| 3266 | /4 = SHL | |
| 3267 | /5 = SHR | |
| 3268 | /7 = SAR | |
| 3269 | */ | |
| 3270 | ||
| 3271 | /*------------------------------------------------------------------ | |
| 3272 | emit_shift_r16_* | |
| 3273 | ------------------------------------------------------------------*/ | |
| 3274 | ||
| 3275 | INLINE void emit_shift_r16_imm(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 imm) | |
| 3276 | { | |
| 3277 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 3278 | if (imm == 1) | |
| 3279 | emit_op_modrm_reg(emitptr, OP_G2_Ev_1, OP_32BIT, opindex, dreg); | |
| 3280 | else | |
| 3281 | { | |
| 3282 | emit_op_modrm_reg(emitptr, OP_G2_Ev_Ib, OP_32BIT, opindex, dreg); | |
| 3283 | emit_byte(emitptr, imm); | |
| 3284 | } | |
| 3285 | } | |
| 3286 | ||
| 3287 | INLINE void emit_shift_m16bisd_imm(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 imm) | |
| 3288 | { | |
| 3289 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 3290 | if (imm == 1) | |
| 3291 | emit_op_modrm_mem(emitptr, OP_G2_Ev_1, OP_32BIT, opindex, base, index, scale, disp); | |
| 3292 | else | |
| 3293 | { | |
| 3294 | emit_op_modrm_mem(emitptr, OP_G2_Ev_Ib, OP_32BIT, opindex, base, index, scale, disp); | |
| 3295 | emit_byte(emitptr, imm); | |
| 3296 | } | |
| 3297 | } | |
| 3298 | ||
| 3299 | INLINE void emit_shift_r16_cl(x86code **emitptr, UINT8 opindex, UINT8 dreg) | |
| 3300 | { | |
| 3301 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 3302 | emit_op_modrm_reg(emitptr, OP_G2_Ev_CL, OP_32BIT, opindex, dreg); | |
| 3303 | } | |
| 3304 | ||
| 3305 | INLINE void emit_shift_m16bisd_cl(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 3306 | { | |
| 3307 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 3308 | emit_op_modrm_mem(emitptr, OP_G2_Ev_CL, OP_32BIT, opindex, base, index, scale, disp); | |
| 3309 | } | |
| 3310 | ||
| 3311 | ||
| 3312 | /*------------------------------------------------------------------ | |
| 3313 | emit_rol_r16_* | |
| 3314 | ------------------------------------------------------------------*/ | |
| 3315 | ||
| 3316 | #define emit_rol_r16_imm(e, dreg, imm) emit_shift_r16_imm(e, 0, dreg, imm) | |
| 3317 | #define emit_rol_m16bisd_imm(e, base, index, scale, disp, imm) emit_shift_m16bisd_imm(e, 0, base, index, scale, disp, imm) | |
| 3318 | #define emit_rol_r16_cl(e, dreg) emit_shift_r16_cl(e, 0, dreg) | |
| 3319 | #define emit_rol_m16bisd_cl(e, base, index, scale, disp) emit_shift_m16bisd_cl(e, 0, base, index, scale, disp) | |
| 3320 | ||
| 3321 | #define emit_rol_m16abs_imm(e, addr, imm) emit_rol_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3322 | #define emit_rol_m16bd_imm(e, base, disp, imm) emit_rol_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3323 | #define emit_rol_m16isd_imm(e, index, scale, disp, imm) emit_rol_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3324 | ||
| 3325 | #define emit_rol_m16abs_cl(e, addr) emit_rol_m16bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3326 | #define emit_rol_m16bd_cl(e, base, disp) emit_rol_m16bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3327 | #define emit_rol_m16isd_cl(e, index, scale, disp) emit_rol_m16bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3328 | ||
| 3329 | ||
| 3330 | /*------------------------------------------------------------------ | |
| 3331 | emit_ror_r16_* | |
| 3332 | ------------------------------------------------------------------*/ | |
| 3333 | ||
| 3334 | #define emit_ror_r16_imm(e, dreg, imm) emit_shift_r16_imm(e, 1, dreg, imm) | |
| 3335 | #define emit_ror_m16bisd_imm(e, base, index, scale, disp, imm) emit_shift_m16bisd_imm(e, 1, base, index, scale, disp, imm) | |
| 3336 | #define emit_ror_r16_cl(e, dreg) emit_shift_r16_cl(e, 1, dreg) | |
| 3337 | #define emit_ror_m16bisd_cl(e, base, index, scale, disp) emit_shift_m16bisd_cl(e, 1, base, index, scale, disp) | |
| 3338 | ||
| 3339 | #define emit_ror_m16abs_imm(e, addr, imm) emit_ror_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3340 | #define emit_ror_m16bd_imm(e, base, disp, imm) emit_ror_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3341 | #define emit_ror_m16isd_imm(e, index, scale, disp, imm) emit_ror_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3342 | ||
| 3343 | #define emit_ror_m16abs_cl(e, addr) emit_ror_m16bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3344 | #define emit_ror_m16bd_cl(e, base, disp) emit_ror_m16bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3345 | #define emit_ror_m16isd_cl(e, index, scale, disp) emit_ror_m16bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3346 | ||
| 3347 | ||
| 3348 | /*------------------------------------------------------------------ | |
| 3349 | emit_rcl_r16_* | |
| 3350 | ------------------------------------------------------------------*/ | |
| 3351 | ||
| 3352 | #define emit_rcl_r16_imm(e, dreg, imm) emit_shift_r16_imm(e, 2, dreg, imm) | |
| 3353 | #define emit_rcl_m16bisd_imm(e, base, index, scale, disp, imm) emit_shift_m16bisd_imm(e, 2, base, index, scale, disp, imm) | |
| 3354 | #define emit_rcl_r16_cl(e, dreg) emit_shift_r16_cl(e, 2, dreg) | |
| 3355 | #define emit_rcl_m16bisd_cl(e, base, index, scale, disp) emit_shift_m16bisd_cl(e, 2, base, index, scale, disp) | |
| 3356 | ||
| 3357 | #define emit_rcl_m16abs_imm(e, addr, imm) emit_rcl_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3358 | #define emit_rcl_m16bd_imm(e, base, disp, imm) emit_rcl_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3359 | #define emit_rcl_m16isd_imm(e, index, scale, disp, imm) emit_rcl_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3360 | ||
| 3361 | #define emit_rcl_m16abs_cl(e, addr) emit_rcl_m16bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3362 | #define emit_rcl_m16bd_cl(e, base, disp) emit_rcl_m16bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3363 | #define emit_rcl_m16isd_cl(e, index, scale, disp) emit_rcl_m16bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3364 | ||
| 3365 | ||
| 3366 | /*------------------------------------------------------------------ | |
| 3367 | emit_rcr_r16_* | |
| 3368 | ------------------------------------------------------------------*/ | |
| 3369 | ||
| 3370 | #define emit_rcr_r16_imm(e, dreg, imm) emit_shift_r16_imm(e, 3, dreg, imm) | |
| 3371 | #define emit_rcr_m16bisd_imm(e, base, index, scale, disp, imm) emit_shift_m16bisd_imm(e, 31, base, index, scale, disp, imm) | |
| 3372 | #define emit_rcr_r16_cl(e, dreg) emit_shift_r16_cl(e, 3, dreg) | |
| 3373 | #define emit_rcr_m16bisd_cl(e, base, index, scale, disp) emit_shift_m16bisd_cl(e, 3, base, index, scale, disp) | |
| 3374 | ||
| 3375 | #define emit_rcr_m16abs_imm(e, addr, imm) emit_rcr_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3376 | #define emit_rcr_m16bd_imm(e, base, disp, imm) emit_rcr_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3377 | #define emit_rcr_m16isd_imm(e, index, scale, disp, imm) emit_rcr_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3378 | ||
| 3379 | #define emit_rcr_m16abs_cl(e, addr) emit_rcr_m16bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3380 | #define emit_rcr_m16bd_cl(e, base, disp) emit_rcr_m16bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3381 | #define emit_rcr_m16isd_cl(e, index, scale, disp) emit_rcr_m16bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3382 | ||
| 3383 | ||
| 3384 | /*------------------------------------------------------------------ | |
| 3385 | emit_shl_r16_* | |
| 3386 | ------------------------------------------------------------------*/ | |
| 3387 | ||
| 3388 | #define emit_shl_r16_imm(e, dreg, imm) emit_shift_r16_imm(e, 4, dreg, imm) | |
| 3389 | #define emit_shl_m16bisd_imm(e, base, index, scale, disp, imm) emit_shift_m16bisd_imm(e, 4, base, index, scale, disp, imm) | |
| 3390 | #define emit_shl_r16_cl(e, dreg) emit_shift_r16_cl(e, 4, dreg) | |
| 3391 | #define emit_shl_m16bisd_cl(e, base, index, scale, disp) emit_shift_m16bisd_cl(e, 4, base, index, scale, disp) | |
| 3392 | ||
| 3393 | #define emit_shl_m16abs_imm(e, addr, imm) emit_shl_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3394 | #define emit_shl_m16bd_imm(e, base, disp, imm) emit_shl_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3395 | #define emit_shl_m16isd_imm(e, index, scale, disp, imm) emit_shl_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3396 | ||
| 3397 | #define emit_shl_m16abs_cl(e, addr) emit_shl_m16bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3398 | #define emit_shl_m16bd_cl(e, base, disp) emit_shl_m16bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3399 | #define emit_shl_m16isd_cl(e, index, scale, disp) emit_shl_m16bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3400 | ||
| 3401 | ||
| 3402 | /*------------------------------------------------------------------ | |
| 3403 | emit_shr_r16_* | |
| 3404 | ------------------------------------------------------------------*/ | |
| 3405 | ||
| 3406 | #define emit_shr_r16_imm(e, dreg, imm) emit_shift_r16_imm(e, 5, dreg, imm) | |
| 3407 | #define emit_shr_m16bisd_imm(e, base, index, scale, disp, imm) emit_shift_m16bisd_imm(e, 5, base, index, scale, disp, imm) | |
| 3408 | #define emit_shr_r16_cl(e, dreg) emit_shift_r16_cl(e, 5, dreg) | |
| 3409 | #define emit_shr_m16bisd_cl(e, base, index, scale, disp) emit_shift_m16bisd_cl(e, 5, base, index, scale, disp) | |
| 3410 | ||
| 3411 | #define emit_shr_m16abs_imm(e, addr, imm) emit_shr_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3412 | #define emit_shr_m16bd_imm(e, base, disp, imm) emit_shr_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3413 | #define emit_shr_m16isd_imm(e, index, scale, disp, imm) emit_shr_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3414 | ||
| 3415 | #define emit_shr_m16abs_cl(e, addr) emit_shr_m16bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3416 | #define emit_shr_m16bd_cl(e, base, disp) emit_shr_m16bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3417 | #define emit_shr_m16isd_cl(e, index, scale, disp) emit_shr_m16bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3418 | ||
| 3419 | ||
| 3420 | /*------------------------------------------------------------------ | |
| 3421 | emit_sar_r16_* | |
| 3422 | ------------------------------------------------------------------*/ | |
| 3423 | ||
| 3424 | #define emit_sar_r16_imm(e, dreg, imm) emit_shift_r16_imm(e, 7, dreg, imm) | |
| 3425 | #define emit_sar_m16bisd_imm(e, base, index, scale, disp, imm) emit_shift_m16bisd_imm(e, 7, base, index, scale, disp, imm) | |
| 3426 | #define emit_sar_r16_cl(e, dreg) emit_shift_r16_cl(e, 7, dreg) | |
| 3427 | #define emit_sar_m16bisd_cl(e, base, index, scale, disp) emit_shift_m16bisd_cl(e, 7, base, index, scale, disp) | |
| 3428 | ||
| 3429 | #define emit_sar_m16abs_imm(e, addr, imm) emit_sar_m16bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3430 | #define emit_sar_m16bd_imm(e, base, disp, imm) emit_sar_m16bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3431 | #define emit_sar_m16isd_imm(e, index, scale, disp, imm) emit_sar_m16bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3432 | ||
| 3433 | #define emit_sar_m16abs_cl(e, addr) emit_sar_m16bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3434 | #define emit_sar_m16bd_cl(e, base, disp) emit_sar_m16bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3435 | #define emit_sar_m16isd_cl(e, index, scale, disp) emit_sar_m16bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3436 | ||
| 3437 | ||
| 3438 | ||
| 3439 | /*************************************************************************** | |
| 3440 | 32-BIT SHIFT EMITTERS | |
| 3441 | ***************************************************************************/ | |
| 3442 | ||
| 3443 | /* | |
| 3444 | Note that the following code relies on this: | |
| 3445 | ||
| 3446 | /0 = ROL | |
| 3447 | /1 = ROR | |
| 3448 | /2 = RCL | |
| 3449 | /3 = RCR | |
| 3450 | /4 = SHL | |
| 3451 | /5 = SHR | |
| 3452 | /7 = SAR | |
| 3453 | */ | |
| 3454 | ||
| 3455 | /*------------------------------------------------------------------ | |
| 3456 | emit_shift_r32_* | |
| 3457 | ------------------------------------------------------------------*/ | |
| 3458 | ||
| 3459 | INLINE void emit_shift_r32_imm(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 imm) | |
| 3460 | { | |
| 3461 | if (imm == 1) | |
| 3462 | emit_op_modrm_reg(emitptr, OP_G2_Ev_1, OP_32BIT, opindex, dreg); | |
| 3463 | else | |
| 3464 | { | |
| 3465 | emit_op_modrm_reg(emitptr, OP_G2_Ev_Ib, OP_32BIT, opindex, dreg); | |
| 3466 | emit_byte(emitptr, imm); | |
| 3467 | } | |
| 3468 | } | |
| 3469 | ||
| 3470 | INLINE void emit_shift_m32bisd_imm(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 imm) | |
| 3471 | { | |
| 3472 | if (imm == 1) | |
| 3473 | emit_op_modrm_mem(emitptr, OP_G2_Ev_1, OP_32BIT, opindex, base, index, scale, disp); | |
| 3474 | else | |
| 3475 | { | |
| 3476 | emit_op_modrm_mem(emitptr, OP_G2_Ev_Ib, OP_32BIT, opindex, base, index, scale, disp); | |
| 3477 | emit_byte(emitptr, imm); | |
| 3478 | } | |
| 3479 | } | |
| 3480 | ||
| 3481 | INLINE void emit_shift_r32_cl(x86code **emitptr, UINT8 opindex, UINT8 dreg) | |
| 3482 | { | |
| 3483 | emit_op_modrm_reg(emitptr, OP_G2_Ev_CL, OP_32BIT, opindex, dreg); | |
| 3484 | } | |
| 3485 | ||
| 3486 | INLINE void emit_shift_m32bisd_cl(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 3487 | { | |
| 3488 | emit_op_modrm_mem(emitptr, OP_G2_Ev_CL, OP_32BIT, opindex, base, index, scale, disp); | |
| 3489 | } | |
| 3490 | ||
| 3491 | ||
| 3492 | /*------------------------------------------------------------------ | |
| 3493 | emit_rol_r32_* | |
| 3494 | ------------------------------------------------------------------*/ | |
| 3495 | ||
| 3496 | #define emit_rol_r32_imm(e, dreg, imm) emit_shift_r32_imm(e, 0, dreg, imm) | |
| 3497 | #define emit_rol_m32bisd_imm(e, base, index, scale, disp, imm) emit_shift_m32bisd_imm(e, 0, base, index, scale, disp, imm) | |
| 3498 | #define emit_rol_r32_cl(e, dreg) emit_shift_r32_cl(e, 0, dreg) | |
| 3499 | #define emit_rol_m32bisd_cl(e, base, index, scale, disp) emit_shift_m32bisd_cl(e, 0, base, index, scale, disp) | |
| 3500 | ||
| 3501 | #define emit_rol_m32abs_imm(e, addr, imm) emit_rol_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3502 | #define emit_rol_m32bd_imm(e, base, disp, imm) emit_rol_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3503 | #define emit_rol_m32isd_imm(e, index, scale, disp, imm) emit_rol_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3504 | ||
| 3505 | #define emit_rol_m32abs_cl(e, addr) emit_rol_m32bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3506 | #define emit_rol_m32bd_cl(e, base, disp) emit_rol_m32bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3507 | #define emit_rol_m32isd_cl(e, index, scale, disp) emit_rol_m32bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3508 | ||
| 3509 | ||
| 3510 | /*------------------------------------------------------------------ | |
| 3511 | emit_ror_r32_* | |
| 3512 | ------------------------------------------------------------------*/ | |
| 3513 | ||
| 3514 | #define emit_ror_r32_imm(e, dreg, imm) emit_shift_r32_imm(e, 1, dreg, imm) | |
| 3515 | #define emit_ror_m32bisd_imm(e, base, index, scale, disp, imm) emit_shift_m32bisd_imm(e, 1, base, index, scale, disp, imm) | |
| 3516 | #define emit_ror_r32_cl(e, dreg) emit_shift_r32_cl(e, 1, dreg) | |
| 3517 | #define emit_ror_m32bisd_cl(e, base, index, scale, disp) emit_shift_m32bisd_cl(e, 1, base, index, scale, disp) | |
| 3518 | ||
| 3519 | #define emit_ror_m32abs_imm(e, addr, imm) emit_ror_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3520 | #define emit_ror_m32bd_imm(e, base, disp, imm) emit_ror_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3521 | #define emit_ror_m32isd_imm(e, index, scale, disp, imm) emit_ror_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3522 | ||
| 3523 | #define emit_ror_m32abs_cl(e, addr) emit_ror_m32bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3524 | #define emit_ror_m32bd_cl(e, base, disp) emit_ror_m32bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3525 | #define emit_ror_m32isd_cl(e, index, scale, disp) emit_ror_m32bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3526 | ||
| 3527 | ||
| 3528 | /*------------------------------------------------------------------ | |
| 3529 | emit_rcl_r32_* | |
| 3530 | ------------------------------------------------------------------*/ | |
| 3531 | ||
| 3532 | #define emit_rcl_r32_imm(e, dreg, imm) emit_shift_r32_imm(e, 2, dreg, imm) | |
| 3533 | #define emit_rcl_m32bisd_imm(e, base, index, scale, disp, imm) emit_shift_m32bisd_imm(e, 2, base, index, scale, disp, imm) | |
| 3534 | #define emit_rcl_r32_cl(e, dreg) emit_shift_r32_cl(e, 2, dreg) | |
| 3535 | #define emit_rcl_m32bisd_cl(e, base, index, scale, disp) emit_shift_m32bisd_cl(e, 2, base, index, scale, disp) | |
| 3536 | ||
| 3537 | #define emit_rcl_m32abs_imm(e, addr, imm) emit_rcl_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3538 | #define emit_rcl_m32bd_imm(e, base, disp, imm) emit_rcl_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3539 | #define emit_rcl_m32isd_imm(e, index, scale, disp, imm) emit_rcl_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3540 | ||
| 3541 | #define emit_rcl_m32abs_cl(e, addr) emit_rcl_m32bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3542 | #define emit_rcl_m32bd_cl(e, base, disp) emit_rcl_m32bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3543 | #define emit_rcl_m32isd_cl(e, index, scale, disp) emit_rcl_m32bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3544 | ||
| 3545 | ||
| 3546 | /*------------------------------------------------------------------ | |
| 3547 | emit_rcr_r32_* | |
| 3548 | ------------------------------------------------------------------*/ | |
| 3549 | ||
| 3550 | #define emit_rcr_r32_imm(e, dreg, imm) emit_shift_r32_imm(e, 3, dreg, imm) | |
| 3551 | #define emit_rcr_m32bisd_imm(e, base, index, scale, disp, imm) emit_shift_m32bisd_imm(e, 3, base, index, scale, disp, imm) | |
| 3552 | #define emit_rcr_r32_cl(e, dreg) emit_shift_r32_cl(e, 3, dreg) | |
| 3553 | #define emit_rcr_m32bisd_cl(e, base, index, scale, disp) emit_shift_m32bisd_cl(e, 3, base, index, scale, disp) | |
| 3554 | ||
| 3555 | #define emit_rcr_m32abs_imm(e, addr, imm) emit_rcr_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3556 | #define emit_rcr_m32bd_imm(e, base, disp, imm) emit_rcr_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3557 | #define emit_rcr_m32isd_imm(e, index, scale, disp, imm) emit_rcr_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3558 | ||
| 3559 | #define emit_rcr_m32abs_cl(e, addr) emit_rcr_m32bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3560 | #define emit_rcr_m32bd_cl(e, base, disp) emit_rcr_m32bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3561 | #define emit_rcr_m32isd_cl(e, index, scale, disp) emit_rcr_m32bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3562 | ||
| 3563 | ||
| 3564 | /*------------------------------------------------------------------ | |
| 3565 | emit_shl_r32_* | |
| 3566 | ------------------------------------------------------------------*/ | |
| 3567 | ||
| 3568 | #define emit_shl_r32_imm(e, dreg, imm) emit_shift_r32_imm(e, 4, dreg, imm) | |
| 3569 | #define emit_shl_m32bisd_imm(e, base, index, scale, disp, imm) emit_shift_m32bisd_imm(e, 4, base, index, scale, disp, imm) | |
| 3570 | #define emit_shl_r32_cl(e, dreg) emit_shift_r32_cl(e, 4, dreg) | |
| 3571 | #define emit_shl_m32bisd_cl(e, base, index, scale, disp) emit_shift_m32bisd_cl(e, 4, base, index, scale, disp) | |
| 3572 | ||
| 3573 | #define emit_shl_m32abs_imm(e, addr, imm) emit_shl_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3574 | #define emit_shl_m32bd_imm(e, base, disp, imm) emit_shl_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3575 | #define emit_shl_m32isd_imm(e, index, scale, disp, imm) emit_shl_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3576 | ||
| 3577 | #define emit_shl_m32abs_cl(e, addr) emit_shl_m32bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3578 | #define emit_shl_m32bd_cl(e, base, disp) emit_shl_m32bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3579 | #define emit_shl_m32isd_cl(e, index, scale, disp) emit_shl_m32bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3580 | ||
| 3581 | ||
| 3582 | /*------------------------------------------------------------------ | |
| 3583 | emit_shr_r32_* | |
| 3584 | ------------------------------------------------------------------*/ | |
| 3585 | ||
| 3586 | #define emit_shr_r32_imm(e, dreg, imm) emit_shift_r32_imm(e, 5, dreg, imm) | |
| 3587 | #define emit_shr_m32bisd_imm(e, base, index, scale, disp, imm) emit_shift_m32bisd_imm(e, 5, base, index, scale, disp, imm) | |
| 3588 | #define emit_shr_r32_cl(e, dreg) emit_shift_r32_cl(e, 5, dreg) | |
| 3589 | #define emit_shr_m32bisd_cl(e, base, index, scale, disp) emit_shift_m32bisd_cl(e, 5, base, index, scale, disp) | |
| 3590 | ||
| 3591 | #define emit_shr_m32abs_imm(e, addr, imm) emit_shr_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3592 | #define emit_shr_m32bd_imm(e, base, disp, imm) emit_shr_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3593 | #define emit_shr_m32isd_imm(e, index, scale, disp, imm) emit_shr_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3594 | ||
| 3595 | #define emit_shr_m32abs_cl(e, addr) emit_shr_m32bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3596 | #define emit_shr_m32bd_cl(e, base, disp) emit_shr_m32bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3597 | #define emit_shr_m32isd_cl(e, index, scale, disp) emit_shr_m32bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3598 | ||
| 3599 | ||
| 3600 | /*------------------------------------------------------------------ | |
| 3601 | emit_sar_r32_* | |
| 3602 | ------------------------------------------------------------------*/ | |
| 3603 | ||
| 3604 | #define emit_sar_r32_imm(e, dreg, imm) emit_shift_r32_imm(e, 7, dreg, imm) | |
| 3605 | #define emit_sar_m32bisd_imm(e, base, index, scale, disp, imm) emit_shift_m32bisd_imm(e, 7, base, index, scale, disp, imm) | |
| 3606 | #define emit_sar_r32_cl(e, dreg) emit_shift_r32_cl(e, 7, dreg) | |
| 3607 | #define emit_sar_m32bisd_cl(e, base, index, scale, disp) emit_shift_m32bisd_cl(e, 7, base, index, scale, disp) | |
| 3608 | ||
| 3609 | #define emit_sar_m32abs_imm(e, addr, imm) emit_sar_m32bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3610 | #define emit_sar_m32bd_imm(e, base, disp, imm) emit_sar_m32bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3611 | #define emit_sar_m32isd_imm(e, index, scale, disp, imm) emit_sar_m32bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3612 | ||
| 3613 | #define emit_sar_m32abs_cl(e, addr) emit_sar_m32bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3614 | #define emit_sar_m32bd_cl(e, base, disp) emit_sar_m32bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3615 | #define emit_sar_m32isd_cl(e, index, scale, disp) emit_sar_m32bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3616 | ||
| 3617 | ||
| 3618 | ||
| 3619 | /*************************************************************************** | |
| 3620 | 64-BIT SHIFT EMITTERS | |
| 3621 | ***************************************************************************/ | |
| 3622 | ||
| 3623 | #ifdef PTR64 | |
| 3624 | /* | |
| 3625 | Note that the following code relies on this: | |
| 3626 | ||
| 3627 | /0 = ROL | |
| 3628 | /1 = ROR | |
| 3629 | /2 = RCL | |
| 3630 | /3 = RCR | |
| 3631 | /4 = SHL | |
| 3632 | /5 = SHR | |
| 3633 | /7 = SAR | |
| 3634 | */ | |
| 3635 | ||
| 3636 | /*------------------------------------------------------------------ | |
| 3637 | emit_shift_r64_* | |
| 3638 | ------------------------------------------------------------------*/ | |
| 3639 | ||
| 3640 | INLINE void emit_shift_r64_imm(x86code **emitptr, UINT8 opindex, UINT8 dreg, UINT8 imm) | |
| 3641 | { | |
| 3642 | if (imm == 1) | |
| 3643 | emit_op_modrm_reg(emitptr, OP_G2_Ev_1, OP_64BIT, opindex, dreg); | |
| 3644 | else | |
| 3645 | { | |
| 3646 | emit_op_modrm_reg(emitptr, OP_G2_Ev_Ib, OP_64BIT, opindex, dreg); | |
| 3647 | emit_byte(emitptr, imm); | |
| 3648 | } | |
| 3649 | } | |
| 3650 | ||
| 3651 | INLINE void emit_shift_m64bisd_imm(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp, UINT8 imm) | |
| 3652 | { | |
| 3653 | if (imm == 1) | |
| 3654 | emit_op_modrm_mem(emitptr, OP_G2_Ev_1, OP_64BIT, opindex, base, index, scale, disp); | |
| 3655 | else | |
| 3656 | { | |
| 3657 | emit_op_modrm_mem(emitptr, OP_G2_Ev_Ib, OP_64BIT, opindex, base, index, scale, disp); | |
| 3658 | emit_byte(emitptr, imm); | |
| 3659 | } | |
| 3660 | } | |
| 3661 | ||
| 3662 | INLINE void emit_shift_r64_cl(x86code **emitptr, UINT8 opindex, UINT8 dreg) | |
| 3663 | { | |
| 3664 | emit_op_modrm_reg(emitptr, OP_G2_Ev_CL, OP_64BIT, opindex, dreg); | |
| 3665 | } | |
| 3666 | ||
| 3667 | INLINE void emit_shift_m64bisd_cl(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 3668 | { | |
| 3669 | emit_op_modrm_mem(emitptr, OP_G2_Ev_CL, OP_64BIT, opindex, base, index, scale, disp); | |
| 3670 | } | |
| 3671 | ||
| 3672 | ||
| 3673 | /*------------------------------------------------------------------ | |
| 3674 | emit_rol_r64_* | |
| 3675 | ------------------------------------------------------------------*/ | |
| 3676 | ||
| 3677 | #define emit_rol_r64_imm(e, dreg, imm) emit_shift_r64_imm(e, 0, dreg, imm) | |
| 3678 | #define emit_rol_m64bisd_imm(e, base, index, scale, disp, imm) emit_shift_m64bisd_imm(e, 0, base, index, scale, disp, imm) | |
| 3679 | #define emit_rol_r64_cl(e, dreg) emit_shift_r64_cl(e, 0, dreg) | |
| 3680 | #define emit_rol_m64bisd_cl(e, base, index, scale, disp) emit_shift_m64bisd_cl(e, 0, base, index, scale, disp) | |
| 3681 | ||
| 3682 | #define emit_rol_m64abs_imm(e, addr, imm) emit_rol_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3683 | #define emit_rol_m64bd_imm(e, base, disp, imm) emit_rol_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3684 | #define emit_rol_m64isd_imm(e, index, scale, disp, imm) emit_rol_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3685 | ||
| 3686 | #define emit_rol_m64abs_cl(e, addr) emit_rol_m64bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3687 | #define emit_rol_m64bd_cl(e, base, disp) emit_rol_m64bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3688 | #define emit_rol_m64isd_cl(e, index, scale, disp) emit_rol_m64bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3689 | ||
| 3690 | ||
| 3691 | /*------------------------------------------------------------------ | |
| 3692 | emit_ror_r64_* | |
| 3693 | ------------------------------------------------------------------*/ | |
| 3694 | ||
| 3695 | #define emit_ror_r64_imm(e, dreg, imm) emit_shift_r64_imm(e, 1, dreg, imm) | |
| 3696 | #define emit_ror_m64bisd_imm(e, base, index, scale, disp, imm) emit_shift_m64bisd_imm(e, 1, base, index, scale, disp, imm) | |
| 3697 | #define emit_ror_r64_cl(e, dreg) emit_shift_r64_cl(e, 1, dreg) | |
| 3698 | #define emit_ror_m64bisd_cl(e, base, index, scale, disp) emit_shift_m64bisd_cl(e, 1, base, index, scale, disp) | |
| 3699 | ||
| 3700 | #define emit_ror_m64abs_imm(e, addr, imm) emit_ror_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3701 | #define emit_ror_m64bd_imm(e, base, disp, imm) emit_ror_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3702 | #define emit_ror_m64isd_imm(e, index, scale, disp, imm) emit_ror_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3703 | ||
| 3704 | #define emit_ror_m64abs_cl(e, addr) emit_ror_m64bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3705 | #define emit_ror_m64bd_cl(e, base, disp) emit_ror_m64bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3706 | #define emit_ror_m64isd_cl(e, index, scale, disp) emit_ror_m64bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3707 | ||
| 3708 | ||
| 3709 | /*------------------------------------------------------------------ | |
| 3710 | emit_rcl_r64_* | |
| 3711 | ------------------------------------------------------------------*/ | |
| 3712 | ||
| 3713 | #define emit_rcl_r64_imm(e, dreg, imm) emit_shift_r64_imm(e, 2, dreg, imm) | |
| 3714 | #define emit_rcl_m64bisd_imm(e, base, index, scale, disp, imm) emit_shift_m64bisd_imm(e, 2, base, index, scale, disp, imm) | |
| 3715 | #define emit_rcl_r64_cl(e, dreg) emit_shift_r64_cl(e, 2, dreg) | |
| 3716 | #define emit_rcl_m64bisd_cl(e, base, index, scale, disp) emit_shift_m64bisd_cl(e, 2, base, index, scale, disp) | |
| 3717 | ||
| 3718 | #define emit_rcl_m64abs_imm(e, addr, imm) emit_rcl_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3719 | #define emit_rcl_m64bd_imm(e, base, disp, imm) emit_rcl_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3720 | #define emit_rcl_m64isd_imm(e, index, scale, disp, imm) emit_rcl_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3721 | ||
| 3722 | #define emit_rcl_m64abs_cl(e, addr) emit_rcl_m64bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3723 | #define emit_rcl_m64bd_cl(e, base, disp) emit_rcl_m64bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3724 | #define emit_rcl_m64isd_cl(e, index, scale, disp) emit_rcl_m64bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3725 | ||
| 3726 | ||
| 3727 | /*------------------------------------------------------------------ | |
| 3728 | emit_rcr_r64_* | |
| 3729 | ------------------------------------------------------------------*/ | |
| 3730 | ||
| 3731 | #define emit_rcr_r64_imm(e, dreg, imm) emit_shift_r64_imm(e, 3, dreg, imm) | |
| 3732 | #define emit_rcr_m64bisd_imm(e, base, index, scale, disp, imm) emit_shift_m64bisd_imm(e, 3, base, index, scale, disp, imm) | |
| 3733 | #define emit_rcr_r64_cl(e, dreg) emit_shift_r64_cl(e, 3, dreg) | |
| 3734 | #define emit_rcr_m64bisd_cl(e, base, index, scale, disp) emit_shift_m64bisd_cl(e, 3, base, index, scale, disp) | |
| 3735 | ||
| 3736 | #define emit_rcr_m64abs_imm(e, addr, imm) emit_rcr_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3737 | #define emit_rcr_m64bd_imm(e, base, disp, imm) emit_rcr_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3738 | #define emit_rcr_m64isd_imm(e, index, scale, disp, imm) emit_rcr_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3739 | ||
| 3740 | #define emit_rcr_m64abs_cl(e, addr) emit_rcr_m64bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3741 | #define emit_rcr_m64bd_cl(e, base, disp) emit_rcr_m64bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3742 | #define emit_rcr_m64isd_cl(e, index, scale, disp) emit_rcr_m64bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3743 | ||
| 3744 | ||
| 3745 | /*------------------------------------------------------------------ | |
| 3746 | emit_shl_r64_* | |
| 3747 | ------------------------------------------------------------------*/ | |
| 3748 | ||
| 3749 | #define emit_shl_r64_imm(e, dreg, imm) emit_shift_r64_imm(e, 4, dreg, imm) | |
| 3750 | #define emit_shl_m64bisd_imm(e, base, index, scale, disp, imm) emit_shift_m64bisd_imm(e, 4, base, index, scale, disp, imm) | |
| 3751 | #define emit_shl_r64_cl(e, dreg) emit_shift_r64_cl(e, 4, dreg) | |
| 3752 | #define emit_shl_m64bisd_cl(e, base, index, scale, disp) emit_shift_m64bisd_cl(e, 4, base, index, scale, disp) | |
| 3753 | ||
| 3754 | #define emit_shl_m64abs_imm(e, addr, imm) emit_shl_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3755 | #define emit_shl_m64bd_imm(e, base, disp, imm) emit_shl_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3756 | #define emit_shl_m64isd_imm(e, index, scale, disp, imm) emit_shl_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3757 | ||
| 3758 | #define emit_shl_m64abs_cl(e, addr) emit_shl_m64bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3759 | #define emit_shl_m64bd_cl(e, base, disp) emit_shl_m64bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3760 | #define emit_shl_m64isd_cl(e, index, scale, disp) emit_shl_m64bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3761 | ||
| 3762 | ||
| 3763 | /*------------------------------------------------------------------ | |
| 3764 | emit_shr_r64_* | |
| 3765 | ------------------------------------------------------------------*/ | |
| 3766 | ||
| 3767 | #define emit_shr_r64_imm(e, dreg, imm) emit_shift_r64_imm(e, 5, dreg, imm) | |
| 3768 | #define emit_shr_m64bisd_imm(e, base, index, scale, disp, imm) emit_shift_m64bisd_imm(e, 5, base, index, scale, disp, imm) | |
| 3769 | #define emit_shr_r64_cl(e, dreg) emit_shift_r64_cl(e, 5, dreg) | |
| 3770 | #define emit_shr_m64bisd_cl(e, base, index, scale, disp) emit_shift_m64bisd_cl(e, 5, base, index, scale, disp) | |
| 3771 | ||
| 3772 | #define emit_shr_m64abs_imm(e, addr, imm) emit_shr_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3773 | #define emit_shr_m64bd_imm(e, base, disp, imm) emit_shr_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3774 | #define emit_shr_m64isd_imm(e, index, scale, disp, imm) emit_shr_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3775 | ||
| 3776 | #define emit_shr_m64abs_cl(e, addr) emit_shr_m64bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3777 | #define emit_shr_m64bd_cl(e, base, disp) emit_shr_m64bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3778 | #define emit_shr_m64isd_cl(e, index, scale, disp) emit_shr_m64bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3779 | ||
| 3780 | ||
| 3781 | /*------------------------------------------------------------------ | |
| 3782 | emit_sar_r64_* | |
| 3783 | ------------------------------------------------------------------*/ | |
| 3784 | ||
| 3785 | #define emit_sar_r64_imm(e, dreg, imm) emit_shift_r64_imm(e, 7, dreg, imm) | |
| 3786 | #define emit_sar_m64bisd_imm(e, base, index, scale, disp, imm) emit_shift_m64bisd_imm(e, 7, base, index, scale, disp, imm) | |
| 3787 | #define emit_sar_r64_cl(e, dreg) emit_shift_r64_cl(e, 7, dreg) | |
| 3788 | #define emit_sar_m64bisd_cl(e, base, index, scale, disp) emit_shift_m64bisd_cl(e, 7, base, index, scale, disp) | |
| 3789 | ||
| 3790 | #define emit_sar_m64abs_imm(e, addr, imm) emit_sar_m64bisd_imm(e, REG_NONE, REG_NONE, 1, (INT32)(addr), imm) | |
| 3791 | #define emit_sar_m64bd_imm(e, base, disp, imm) emit_sar_m64bisd_imm(e, (base), REG_NONE, 1, (disp), imm) | |
| 3792 | #define emit_sar_m64isd_imm(e, index, scale, disp, imm) emit_sar_m64bisd_imm(e, REG_NONE, (index), (scale), (disp), imm) | |
| 3793 | ||
| 3794 | #define emit_sar_m64abs_cl(e, addr) emit_sar_m64bisd_cl(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3795 | #define emit_sar_m64bd_cl(e, base, disp) emit_sar_m64bisd_cl(e, (base), REG_NONE, 1, (disp)) | |
| 3796 | #define emit_sar_m64isd_cl(e, index, scale, disp) emit_sar_m64bisd_cl(e, REG_NONE, (index), (scale), (disp)) | |
| 3797 | ||
| 3798 | #endif | |
| 3799 | ||
| 3800 | ||
| 3801 | ||
| 3802 | /*************************************************************************** | |
| 3803 | 8-BIT GROUP3 EMITTERS | |
| 3804 | ***************************************************************************/ | |
| 3805 | ||
| 3806 | /* | |
| 3807 | Note that the following code relies on this: | |
| 3808 | ||
| 3809 | /2 = NOT | |
| 3810 | /3 = NEG | |
| 3811 | /4 = MUL | |
| 3812 | /5 = IMUL | |
| 3813 | /6 = DIV | |
| 3814 | /7 = IDIV | |
| 3815 | */ | |
| 3816 | ||
| 3817 | /*------------------------------------------------------------------ | |
| 3818 | emit_group3_r8_* | |
| 3819 | ------------------------------------------------------------------*/ | |
| 3820 | ||
| 3821 | INLINE void emit_group3_r8(x86code **emitptr, UINT8 opindex, UINT8 dreg) | |
| 3822 | { | |
| 3823 | emit_op_modrm_reg(emitptr, OP_G3_Eb, OP_32BIT, opindex, dreg); | |
| 3824 | } | |
| 3825 | ||
| 3826 | INLINE void emit_group3_m8bisd(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 3827 | { | |
| 3828 | emit_op_modrm_mem(emitptr, OP_G3_Eb, OP_32BIT, opindex, base, index, scale, disp); | |
| 3829 | } | |
| 3830 | ||
| 3831 | ||
| 3832 | /*------------------------------------------------------------------ | |
| 3833 | emit_not_r8_* | |
| 3834 | ------------------------------------------------------------------*/ | |
| 3835 | ||
| 3836 | #define emit_not_r8(e, dreg) emit_group3_r8(e, 2, dreg) | |
| 3837 | #define emit_not_m8bisd(e, base, index, scale, disp) emit_group3_m8bisd(e, 2, base, index, scale, disp) | |
| 3838 | ||
| 3839 | #define emit_not_m8abs(e, addr) emit_not_m8bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3840 | #define emit_not_m8bd(e, base, disp) emit_not_m8bisd(e, (base), REG_NONE, 1, (disp)) | |
| 3841 | #define emit_not_m8isd(e, index, scale, disp) emit_not_m8bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 3842 | ||
| 3843 | ||
| 3844 | /*------------------------------------------------------------------ | |
| 3845 | emit_neg_r8_* | |
| 3846 | ------------------------------------------------------------------*/ | |
| 3847 | ||
| 3848 | #define emit_neg_r8(e, dreg) emit_group3_r8(e, 3, dreg) | |
| 3849 | #define emit_neg_m8bisd(e, base, index, scale, disp) emit_group3_m8bisd(e, 3, base, index, scale, disp) | |
| 3850 | ||
| 3851 | #define emit_neg_m8abs(e, addr) emit_neg_m8bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3852 | #define emit_neg_m8bd(e, base, disp) emit_neg_m8bisd(e, (base), REG_NONE, 1, (disp)) | |
| 3853 | #define emit_neg_m8isd(e, index, scale, disp) emit_neg_m8bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 3854 | ||
| 3855 | ||
| 3856 | /*------------------------------------------------------------------ | |
| 3857 | emit_mul_r8_* | |
| 3858 | ------------------------------------------------------------------*/ | |
| 3859 | ||
| 3860 | #define emit_mul_r8(e, dreg) emit_group3_r8(e, 4, dreg) | |
| 3861 | #define emit_mul_m8bisd(e, base, index, scale, disp) emit_group3_m8bisd(e, 4, base, index, scale, disp) | |
| 3862 | ||
| 3863 | #define emit_mul_m8abs(e, addr) emit_mul_m8bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3864 | #define emit_mul_m8bd(e, base, disp) emit_mul_m8bisd(e, (base), REG_NONE, 1, (disp)) | |
| 3865 | #define emit_mul_m8isd(e, index, scale, disp) emit_mul_m8bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 3866 | ||
| 3867 | ||
| 3868 | /*------------------------------------------------------------------ | |
| 3869 | emit_imul_r8_* | |
| 3870 | ------------------------------------------------------------------*/ | |
| 3871 | ||
| 3872 | #define emit_imul_r8(e, dreg) emit_group3_r8(e, 5, dreg) | |
| 3873 | #define emit_imul_m8bisd(e, base, index, scale, disp) emit_group3_m8bisd(e, 5, base, index, scale, disp) | |
| 3874 | ||
| 3875 | #define emit_imul_m8abs(e, addr) emit_imul_m8bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3876 | #define emit_imul_m8bd(e, base, disp) emit_imul_m8bisd(e, (base), REG_NONE, 1, (disp)) | |
| 3877 | #define emit_imul_m8isd(e, index, scale, disp) emit_imul_m8bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 3878 | ||
| 3879 | ||
| 3880 | /*------------------------------------------------------------------ | |
| 3881 | emit_div_r8_* | |
| 3882 | ------------------------------------------------------------------*/ | |
| 3883 | ||
| 3884 | #define emit_div_r8(e, dreg) emit_group3_r8(e, 6, dreg) | |
| 3885 | #define emit_div_m8bisd(e, base, index, scale, disp) emit_group3_m8bisd(e, 6, base, index, scale, disp) | |
| 3886 | ||
| 3887 | #define emit_div_m8abs(e, addr) emit_div_m8bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3888 | #define emit_div_m8bd(e, base, disp) emit_div_m8bisd(e, (base), REG_NONE, 1, (disp)) | |
| 3889 | #define emit_div_m8isd(e, index, scale, disp) emit_div_m8bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 3890 | ||
| 3891 | ||
| 3892 | /*------------------------------------------------------------------ | |
| 3893 | emit_idiv_r8_* | |
| 3894 | ------------------------------------------------------------------*/ | |
| 3895 | ||
| 3896 | #define emit_idiv_r8(e, dreg) emit_group3_r8(e, 7, dreg) | |
| 3897 | #define emit_idiv_m8bisd(e, base, index, scale, disp) emit_group3_m8bisd(e, 7, base, index, scale, disp) | |
| 3898 | ||
| 3899 | #define emit_idiv_m8abs(e, addr) emit_idiv_m8bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3900 | #define emit_idiv_m8bd(e, base, disp) emit_idiv_m8bisd(e, (base), REG_NONE, 1, (disp)) | |
| 3901 | #define emit_idiv_m8isd(e, index, scale, disp) emit_idiv_m8bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 3902 | ||
| 3903 | ||
| 3904 | ||
| 3905 | /*************************************************************************** | |
| 3906 | 16-BIT GROUP3 EMITTERS | |
| 3907 | ***************************************************************************/ | |
| 3908 | ||
| 3909 | /* | |
| 3910 | Note that the following code relies on this: | |
| 3911 | ||
| 3912 | /0 = ROL | |
| 3913 | /1 = ROR | |
| 3914 | /2 = RCL | |
| 3915 | /3 = RCR | |
| 3916 | /4 = SHL | |
| 3917 | /5 = SHR | |
| 3918 | /7 = SAR | |
| 3919 | */ | |
| 3920 | ||
| 3921 | /*------------------------------------------------------------------ | |
| 3922 | emit_group3_r16_* | |
| 3923 | ------------------------------------------------------------------*/ | |
| 3924 | ||
| 3925 | INLINE void emit_group3_r16(x86code **emitptr, UINT8 opindex, UINT8 dreg) | |
| 3926 | { | |
| 3927 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 3928 | emit_op_modrm_reg(emitptr, OP_G3_Ev, OP_32BIT, opindex, dreg); | |
| 3929 | } | |
| 3930 | ||
| 3931 | INLINE void emit_group3_m16bisd(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 3932 | { | |
| 3933 | emit_byte(emitptr, PREFIX_OPSIZE); | |
| 3934 | emit_op_modrm_mem(emitptr, OP_G3_Ev, OP_32BIT, opindex, base, index, scale, disp); | |
| 3935 | } | |
| 3936 | ||
| 3937 | ||
| 3938 | /*------------------------------------------------------------------ | |
| 3939 | emit_not_r16_* | |
| 3940 | ------------------------------------------------------------------*/ | |
| 3941 | ||
| 3942 | #define emit_not_r16(e, dreg) emit_group3_r16(e, 2, dreg) | |
| 3943 | #define emit_not_m16bisd(e, base, index, scale, disp) emit_group3_m16bisd(e, 2, base, index, scale, disp) | |
| 3944 | ||
| 3945 | #define emit_not_m16abs(e, addr) emit_not_m16bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3946 | #define emit_not_m16bd(e, base, disp) emit_not_m16bisd(e, (base), REG_NONE, 1, (disp)) | |
| 3947 | #define emit_not_m16isd(e, index, scale, disp) emit_not_m16bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 3948 | ||
| 3949 | ||
| 3950 | /*------------------------------------------------------------------ | |
| 3951 | emit_neg_r16_* | |
| 3952 | ------------------------------------------------------------------*/ | |
| 3953 | ||
| 3954 | #define emit_neg_r16(e, dreg) emit_group3_r16(e, 3, dreg) | |
| 3955 | #define emit_neg_m16bisd(e, base, index, scale, disp) emit_group3_m16bisd(e, 3, base, index, scale, disp) | |
| 3956 | ||
| 3957 | #define emit_neg_m16abs(e, addr) emit_neg_m16bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3958 | #define emit_neg_m16bd(e, base, disp) emit_neg_m16bisd(e, (base), REG_NONE, 1, (disp)) | |
| 3959 | #define emit_neg_m16isd(e, index, scale, disp) emit_neg_m16bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 3960 | ||
| 3961 | ||
| 3962 | /*------------------------------------------------------------------ | |
| 3963 | emit_mul_r16_* | |
| 3964 | ------------------------------------------------------------------*/ | |
| 3965 | ||
| 3966 | #define emit_mul_r16(e, dreg) emit_group3_r16(e, 4, dreg) | |
| 3967 | #define emit_mul_m16bisd(e, base, index, scale, disp) emit_group3_m16bisd(e, 4, base, index, scale, disp) | |
| 3968 | ||
| 3969 | #define emit_mul_m16abs(e, addr) emit_mul_m16bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3970 | #define emit_mul_m16bd(e, base, disp) emit_mul_m16bisd(e, (base), REG_NONE, 1, (disp)) | |
| 3971 | #define emit_mul_m16isd(e, index, scale, disp) emit_mul_m16bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 3972 | ||
| 3973 | ||
| 3974 | /*------------------------------------------------------------------ | |
| 3975 | emit_imul_r16_* | |
| 3976 | ------------------------------------------------------------------*/ | |
| 3977 | ||
| 3978 | #define emit_imul_r16(e, dreg) emit_group3_r16(e, 5, dreg) | |
| 3979 | #define emit_imul_m16bisd(e, base, index, scale, disp) emit_group3_m16bisd(e, 5, base, index, scale, disp) | |
| 3980 | ||
| 3981 | #define emit_imul_m16abs(e, addr) emit_imul_m16bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3982 | #define emit_imul_m16bd(e, base, disp) emit_imul_m16bisd(e, (base), REG_NONE, 1, (disp)) | |
| 3983 | #define emit_imul_m16isd(e, index, scale, disp) emit_imul_m16bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 3984 | ||
| 3985 | ||
| 3986 | /*------------------------------------------------------------------ | |
| 3987 | emit_div_r16_* | |
| 3988 | ------------------------------------------------------------------*/ | |
| 3989 | ||
| 3990 | #define emit_div_r16(e, dreg) emit_group3_r16(e, 6, dreg) | |
| 3991 | #define emit_div_m16bisd(e, base, index, scale, disp) emit_group3_m16bisd(e, 6, base, index, scale, disp) | |
| 3992 | ||
| 3993 | #define emit_div_m16abs(e, addr) emit_div_m16bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 3994 | #define emit_div_m16bd(e, base, disp) emit_div_m16bisd(e, (base), REG_NONE, 1, (disp)) | |
| 3995 | #define emit_div_m16isd(e, index, scale, disp) emit_div_m16bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 3996 | ||
| 3997 | ||
| 3998 | /*------------------------------------------------------------------ | |
| 3999 | emit_idiv_r16_* | |
| 4000 | ------------------------------------------------------------------*/ | |
| 4001 | ||
| 4002 | #define emit_idiv_r16(e, dreg) emit_group3_r16(e, 7, dreg) | |
| 4003 | #define emit_idiv_m16bisd(e, base, index, scale, disp) emit_group3_m16bisd(e, 7, base, index, scale, disp) | |
| 4004 | ||
| 4005 | #define emit_idiv_m16abs(e, addr) emit_idiv_m16bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4006 | #define emit_idiv_m16bd(e, base, disp) emit_idiv_m16bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4007 | #define emit_idiv_m16isd(e, index, scale, disp) emit_idiv_m16bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4008 | ||
| 4009 | ||
| 4010 | ||
| 4011 | /*************************************************************************** | |
| 4012 | 32-BIT GROUP3 EMITTERS | |
| 4013 | ***************************************************************************/ | |
| 4014 | ||
| 4015 | /* | |
| 4016 | Note that the following code relies on this: | |
| 4017 | ||
| 4018 | /0 = ROL | |
| 4019 | /1 = ROR | |
| 4020 | /2 = RCL | |
| 4021 | /3 = RCR | |
| 4022 | /4 = SHL | |
| 4023 | /5 = SHR | |
| 4024 | /7 = SAR | |
| 4025 | */ | |
| 4026 | ||
| 4027 | /*------------------------------------------------------------------ | |
| 4028 | emit_group3_r32_* | |
| 4029 | ------------------------------------------------------------------*/ | |
| 4030 | ||
| 4031 | INLINE void emit_group3_r32(x86code **emitptr, UINT8 opindex, UINT8 dreg) | |
| 4032 | { | |
| 4033 | emit_op_modrm_reg(emitptr, OP_G3_Ev, OP_32BIT, opindex, dreg); | |
| 4034 | } | |
| 4035 | ||
| 4036 | INLINE void emit_group3_m32bisd(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 4037 | { | |
| 4038 | emit_op_modrm_mem(emitptr, OP_G3_Ev, OP_32BIT, opindex, base, index, scale, disp); | |
| 4039 | } | |
| 4040 | ||
| 4041 | ||
| 4042 | /*------------------------------------------------------------------ | |
| 4043 | emit_not_r32_* | |
| 4044 | ------------------------------------------------------------------*/ | |
| 4045 | ||
| 4046 | #define emit_not_r32(e, dreg) emit_group3_r32(e, 2, dreg) | |
| 4047 | #define emit_not_m32bisd(e, base, index, scale, disp) emit_group3_m32bisd(e, 2, base, index, scale, disp) | |
| 4048 | ||
| 4049 | #define emit_not_m32abs(e, addr) emit_not_m32bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4050 | #define emit_not_m32bd(e, base, disp) emit_not_m32bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4051 | #define emit_not_m32isd(e, index, scale, disp) emit_not_m32bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4052 | ||
| 4053 | ||
| 4054 | /*------------------------------------------------------------------ | |
| 4055 | emit_neg_r32_* | |
| 4056 | ------------------------------------------------------------------*/ | |
| 4057 | ||
| 4058 | #define emit_neg_r32(e, dreg) emit_group3_r32(e, 3, dreg) | |
| 4059 | #define emit_neg_m32bisd(e, base, index, scale, disp) emit_group3_m32bisd(e, 3, base, index, scale, disp) | |
| 4060 | ||
| 4061 | #define emit_neg_m32abs(e, addr) emit_neg_m32bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4062 | #define emit_neg_m32bd(e, base, disp) emit_neg_m32bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4063 | #define emit_neg_m32isd(e, index, scale, disp) emit_neg_m32bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4064 | ||
| 4065 | ||
| 4066 | /*------------------------------------------------------------------ | |
| 4067 | emit_mul_r32_* | |
| 4068 | ------------------------------------------------------------------*/ | |
| 4069 | ||
| 4070 | #define emit_mul_r32(e, dreg) emit_group3_r32(e, 4, dreg) | |
| 4071 | #define emit_mul_m32bisd(e, base, index, scale, disp) emit_group3_m32bisd(e, 4, base, index, scale, disp) | |
| 4072 | ||
| 4073 | #define emit_mul_m32abs(e, addr) emit_mul_m32bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4074 | #define emit_mul_m32bd(e, base, disp) emit_mul_m32bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4075 | #define emit_mul_m32isd(e, index, scale, disp) emit_mul_m32bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4076 | ||
| 4077 | ||
| 4078 | /*------------------------------------------------------------------ | |
| 4079 | emit_imul_r32_* | |
| 4080 | ------------------------------------------------------------------*/ | |
| 4081 | ||
| 4082 | #define emit_imul_r32(e, dreg) emit_group3_r32(e, 5, dreg) | |
| 4083 | #define emit_imul_m32bisd(e, base, index, scale, disp) emit_group3_m32bisd(e, 5, base, index, scale, disp) | |
| 4084 | ||
| 4085 | #define emit_imul_m32abs(e, addr) emit_imul_m32bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4086 | #define emit_imul_m32bd(e, base, disp) emit_imul_m32bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4087 | #define emit_imul_m32isd(e, index, scale, disp) emit_imul_m32bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4088 | ||
| 4089 | ||
| 4090 | /*------------------------------------------------------------------ | |
| 4091 | emit_div_r32_* | |
| 4092 | ------------------------------------------------------------------*/ | |
| 4093 | ||
| 4094 | #define emit_div_r32(e, dreg) emit_group3_r32(e, 6, dreg) | |
| 4095 | #define emit_div_m32bisd(e, base, index, scale, disp) emit_group3_m32bisd(e, 6, base, index, scale, disp) | |
| 4096 | ||
| 4097 | #define emit_div_m32abs(e, addr) emit_div_m32bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4098 | #define emit_div_m32bd(e, base, disp) emit_div_m32bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4099 | #define emit_div_m32isd(e, index, scale, disp) emit_div_m32bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4100 | ||
| 4101 | ||
| 4102 | /*------------------------------------------------------------------ | |
| 4103 | emit_idiv_r32_* | |
| 4104 | ------------------------------------------------------------------*/ | |
| 4105 | ||
| 4106 | #define emit_idiv_r32(e, dreg) emit_group3_r32(e, 7, dreg) | |
| 4107 | #define emit_idiv_m32bisd(e, base, index, scale, disp) emit_group3_m32bisd(e, 7, base, index, scale, disp) | |
| 4108 | ||
| 4109 | #define emit_idiv_m32abs(e, addr) emit_idiv_m32bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4110 | #define emit_idiv_m32bd(e, base, disp) emit_idiv_m32bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4111 | #define emit_idiv_m32isd(e, index, scale, disp) emit_idiv_m32bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4112 | ||
| 4113 | ||
| 4114 | ||
| 4115 | /*************************************************************************** | |
| 4116 | 64-BIT GROUP3 EMITTERS | |
| 4117 | ***************************************************************************/ | |
| 4118 | ||
| 4119 | #ifdef PTR64 | |
| 4120 | /* | |
| 4121 | Note that the following code relies on this: | |
| 4122 | ||
| 4123 | /0 = ROL | |
| 4124 | /1 = ROR | |
| 4125 | /2 = RCL | |
| 4126 | /3 = RCR | |
| 4127 | /4 = SHL | |
| 4128 | /5 = SHR | |
| 4129 | /7 = SAR | |
| 4130 | */ | |
| 4131 | ||
| 4132 | /*------------------------------------------------------------------ | |
| 4133 | emit_group3_r64_* | |
| 4134 | ------------------------------------------------------------------*/ | |
| 4135 | ||
| 4136 | INLINE void emit_group3_r64(x86code **emitptr, UINT8 opindex, UINT8 dreg) | |
| 4137 | { | |
| 4138 | emit_op_modrm_reg(emitptr, OP_G3_Ev, OP_64BIT, opindex, dreg); | |
| 4139 | } | |
| 4140 | ||
| 4141 | INLINE void emit_group3_m64bisd(x86code **emitptr, UINT8 opindex, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 4142 | { | |
| 4143 | emit_op_modrm_mem(emitptr, OP_G3_Ev, OP_64BIT, opindex, base, index, scale, disp); | |
| 4144 | } | |
| 4145 | ||
| 4146 | ||
| 4147 | /*------------------------------------------------------------------ | |
| 4148 | emit_not_r64_* | |
| 4149 | ------------------------------------------------------------------*/ | |
| 4150 | ||
| 4151 | #define emit_not_r64(e, dreg) emit_group3_r64(e, 2, dreg) | |
| 4152 | #define emit_not_m64bisd(e, base, index, scale, disp) emit_group3_m64bisd(e, 2, base, index, scale, disp) | |
| 4153 | ||
| 4154 | #define emit_not_m64abs(e, addr) emit_not_m64bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4155 | #define emit_not_m64bd(e, base, disp) emit_not_m64bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4156 | #define emit_not_m64isd(e, index, scale, disp) emit_not_m64bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4157 | ||
| 4158 | ||
| 4159 | /*------------------------------------------------------------------ | |
| 4160 | emit_neg_r64_* | |
| 4161 | ------------------------------------------------------------------*/ | |
| 4162 | ||
| 4163 | #define emit_neg_r64(e, dreg) emit_group3_r64(e, 3, dreg) | |
| 4164 | #define emit_neg_m64bisd(e, base, index, scale, disp) emit_group3_m64bisd(e, 3, base, index, scale, disp) | |
| 4165 | ||
| 4166 | #define emit_neg_m64abs(e, addr) emit_neg_m64bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4167 | #define emit_neg_m64bd(e, base, disp) emit_neg_m64bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4168 | #define emit_neg_m64isd(e, index, scale, disp) emit_neg_m64bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4169 | ||
| 4170 | ||
| 4171 | /*------------------------------------------------------------------ | |
| 4172 | emit_mul_r64_* | |
| 4173 | ------------------------------------------------------------------*/ | |
| 4174 | ||
| 4175 | #define emit_mul_r64(e, dreg) emit_group3_r64(e, 4, dreg) | |
| 4176 | #define emit_mul_m64bisd(e, base, index, scale, disp) emit_group3_m64bisd(e, 4, base, index, scale, disp) | |
| 4177 | ||
| 4178 | #define emit_mul_m64abs(e, addr) emit_mul_m64bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4179 | #define emit_mul_m64bd(e, base, disp) emit_mul_m64bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4180 | #define emit_mul_m64isd(e, index, scale, disp) emit_mul_m64bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4181 | ||
| 4182 | ||
| 4183 | /*------------------------------------------------------------------ | |
| 4184 | emit_imul_r64_* | |
| 4185 | ------------------------------------------------------------------*/ | |
| 4186 | ||
| 4187 | #define emit_imul_r64(e, dreg) emit_group3_r64(e, 5, dreg) | |
| 4188 | #define emit_imul_m64bisd(e, base, index, scale, disp) emit_group3_m64bisd(e, 5, base, index, scale, disp) | |
| 4189 | ||
| 4190 | #define emit_imul_m64abs(e, addr) emit_imul_m64bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4191 | #define emit_imul_m64bd(e, base, disp) emit_imul_m64bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4192 | #define emit_imul_m64isd(e, index, scale, disp) emit_imul_m64bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4193 | ||
| 4194 | ||
| 4195 | /*------------------------------------------------------------------ | |
| 4196 | emit_div_r64_* | |
| 4197 | ------------------------------------------------------------------*/ | |
| 4198 | ||
| 4199 | #define emit_div_r64(e, dreg) emit_group3_r64(e, 6, dreg) | |
| 4200 | #define emit_div_m64bisd(e, base, index, scale, disp) emit_group3_m64bisd(e, 6, base, index, scale, disp) | |
| 4201 | ||
| 4202 | #define emit_div_m64abs(e, addr) emit_div_m64bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4203 | #define emit_div_m64bd(e, base, disp) emit_div_m64bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4204 | #define emit_div_m64isd(e, index, scale, disp) emit_div_m64bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4205 | ||
| 4206 | ||
| 4207 | /*------------------------------------------------------------------ | |
| 4208 | emit_idiv_r64_* | |
| 4209 | ------------------------------------------------------------------*/ | |
| 4210 | ||
| 4211 | #define emit_idiv_r64(e, dreg) emit_group3_r64(e, 7, dreg) | |
| 4212 | #define emit_idiv_m64bisd(e, base, index, scale, disp) emit_group3_m64bisd(e, 7, base, index, scale, disp) | |
| 4213 | ||
| 4214 | #define emit_idiv_m64abs(e, addr) emit_idiv_m64bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4215 | #define emit_idiv_m64bd(e, base, disp) emit_idiv_m64bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4216 | #define emit_idiv_m64isd(e, index, scale, disp) emit_idiv_m64bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4217 | ||
| 4218 | #endif | |
| 4219 | ||
| 4220 | ||
| 4221 | ||
| 4222 | /*************************************************************************** | |
| 4223 | LEA EMITTERS | |
| 4224 | ***************************************************************************/ | |
| 4225 | ||
| 4226 | /*------------------------------------------------------------------ | |
| 4227 | emit_lea_r32_* | |
| 4228 | ------------------------------------------------------------------*/ | |
| 4229 | ||
| 4230 | INLINE void emit_lea_r32_m32bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 4231 | { | |
| 4232 | emit_op_modrm_mem(emitptr, OP_LEA_Gv_M, OP_32BIT, dreg, base, index, scale, disp); | |
| 4233 | } | |
| 4234 | ||
| 4235 | #define emit_lea_r32_m32abs(e, dreg, addr) emit_lea_r32_m32bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4236 | #define emit_lea_r32_m32bd(e, dreg, base, disp) emit_lea_r32_m32bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 4237 | #define emit_lea_r32_m32isd(e, dreg, index, scale, disp) emit_lea_r32_m32bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4238 | ||
| 4239 | ||
| 4240 | /*------------------------------------------------------------------ | |
| 4241 | emit_lea_r64_* | |
| 4242 | ------------------------------------------------------------------*/ | |
| 4243 | ||
| 4244 | #ifdef PTR64 | |
| 4245 | INLINE void emit_lea_r64_m64bisd(x86code **emitptr, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 4246 | { | |
| 4247 | emit_op_modrm_mem(emitptr, OP_LEA_Gv_M, OP_64BIT, dreg, base, index, scale, disp); | |
| 4248 | } | |
| 4249 | ||
| 4250 | #define emit_lea_r64_m64abs(e, dreg, addr) emit_lea_r64_m64bisd(e, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4251 | #define emit_lea_r64_m64bd(e, dreg, base, disp) emit_lea_r64_m64bisd(e, dreg, (base), REG_NONE, 1, (disp)) | |
| 4252 | #define emit_lea_r64_m64isd(e, dreg, index, scale, disp) emit_lea_r64_m64bisd(e, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4253 | #endif | |
| 4254 | ||
| 4255 | ||
| 4256 | ||
| 4257 | /*************************************************************************** | |
| 4258 | PUSH/POP EMITTERS | |
| 4259 | ***************************************************************************/ | |
| 4260 | ||
| 4261 | /*------------------------------------------------------------------ | |
| 4262 | emit_push_* | |
| 4263 | ------------------------------------------------------------------*/ | |
| 4264 | ||
| 4265 | #ifndef PTR64 | |
| 4266 | INLINE void emit_push_r32(x86code **emitptr, UINT8 reg) | |
| 4267 | { | |
| 4268 | emit_op(emitptr, OP_PUSH_rAX + (reg & 7), OP_32BIT, 0, 0, reg); | |
| 4269 | } | |
| 4270 | #endif | |
| 4271 | ||
| 4272 | #ifdef PTR64 | |
| 4273 | INLINE void emit_push_r64(x86code **emitptr, UINT8 reg) | |
| 4274 | { | |
| 4275 | emit_op(emitptr, OP_PUSH_rAX + (reg & 7), OP_32BIT, 0, 0, reg); | |
| 4276 | } | |
| 4277 | #endif | |
| 4278 | ||
| 4279 | ||
| 4280 | /*------------------------------------------------------------------ | |
| 4281 | emit_pop_* | |
| 4282 | ------------------------------------------------------------------*/ | |
| 4283 | ||
| 4284 | #ifndef PTR64 | |
| 4285 | INLINE void emit_pop_r32(x86code **emitptr, UINT8 reg) | |
| 4286 | { | |
| 4287 | emit_op(emitptr, OP_POP_rAX + (reg & 7), OP_32BIT, 0, 0, reg); | |
| 4288 | } | |
| 4289 | #endif | |
| 4290 | ||
| 4291 | #ifdef PTR64 | |
| 4292 | INLINE void emit_pop_r64(x86code **emitptr, UINT8 reg) | |
| 4293 | { | |
| 4294 | emit_op(emitptr, OP_POP_rAX + (reg & 7), OP_32BIT, 0, 0, reg); | |
| 4295 | } | |
| 4296 | #endif | |
| 4297 | ||
| 4298 | ||
| 4299 | ||
| 4300 | /*************************************************************************** | |
| 4301 | SET EMITTERS | |
| 4302 | ***************************************************************************/ | |
| 4303 | ||
| 4304 | /*------------------------------------------------------------------ | |
| 4305 | emit_setcc_* | |
| 4306 | ------------------------------------------------------------------*/ | |
| 4307 | ||
| 4308 | INLINE void emit_setcc_r8(x86code **emitptr, UINT8 condition, UINT8 dreg) | |
| 4309 | { | |
| 4310 | emit_op_modrm_reg(emitptr, OP_SETCC_O_Eb + condition, OP_32BIT, 0, dreg); | |
| 4311 | } | |
| 4312 | ||
| 4313 | INLINE void emit_setcc_m8bisd(x86code **emitptr, UINT8 condition, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 4314 | { | |
| 4315 | emit_op_modrm_mem(emitptr, OP_SETCC_O_Eb + condition, OP_32BIT, 0, base, index, scale, disp); | |
| 4316 | } | |
| 4317 | ||
| 4318 | #define emit_setcc_m8abs(e, cond, addr) emit_setcc_m8bisd(e, cond, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4319 | #define emit_setcc_m8bd(e, cond, base, disp) emit_setcc_m8bisd(e, cond, (base), REG_NONE, 1, (disp)) | |
| 4320 | #define emit_setcc_m8isd(e, cond, index, scale, disp) emit_setcc_m8bisd(e, cond, REG_NONE, (index), (scale), (disp)) | |
| 4321 | ||
| 4322 | ||
| 4323 | ||
| 4324 | /*************************************************************************** | |
| 4325 | FPU EMITTERS | |
| 4326 | ***************************************************************************/ | |
| 4327 | ||
| 4328 | #ifndef PTR64 | |
| 4329 | INLINE void emit_fp_simple(x86code **emitptr, UINT8 op) | |
| 4330 | { | |
| 4331 | emit_op_simple(emitptr, op, OP_32BIT); | |
| 4332 | } | |
| 4333 | ||
| 4334 | INLINE void emit_fp_reg(x86code **emitptr, UINT8 op, UINT8 reg) | |
| 4335 | { | |
| 4336 | emit_op_simple(emitptr, op + reg, OP_32BIT); | |
| 4337 | } | |
| 4338 | ||
| 4339 | INLINE void emit_fp_modrm(x86code **emitptr, UINT32 op, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 4340 | { | |
| 4341 | emit_op_modrm_mem(emitptr, op, OP_32BIT, dreg, base, index, scale, disp); | |
| 4342 | } | |
| 4343 | ||
| 4344 | ||
| 4345 | ||
| 4346 | /*************************************************************************** | |
| 4347 | SIMPLE FPU EMITTERS | |
| 4348 | ***************************************************************************/ | |
| 4349 | ||
| 4350 | #define emit_fnop(e) emit_fp_simple(e, OP_FNOP) | |
| 4351 | #define emit_fchs(e) emit_fp_simple(e, OP_FCHS) | |
| 4352 | #define emit_fabs(e) emit_fp_simple(e, OP_FABS) | |
| 4353 | #define emit_ftst(e) emit_fp_simple(e, OP_FTST) | |
| 4354 | #define emit_fxam(e) emit_fp_simple(e, OP_FXAM) | |
| 4355 | #define emit_fld1(e) emit_fp_simple(e, OP_FLD1) | |
| 4356 | #define emit_fldl2t(e) emit_fp_simple(e, OP_FLDL2T) | |
| 4357 | #define emit_fldl2e(e) emit_fp_simple(e, OP_FLDL2E) | |
| 4358 | #define emit_fldpi(e) emit_fp_simple(e, OP_FLDPI) | |
| 4359 | #define emit_fldlg2(e) emit_fp_simple(e, OP_FLDLG2) | |
| 4360 | #define emit_fldln2(e) emit_fp_simple(e, OP_FLDLN2) | |
| 4361 | #define emit_fldz(e) emit_fp_simple(e, OP_FLDZ) | |
| 4362 | #define emit_f2xm1(e) emit_fp_simple(e, OP_F2XM1) | |
| 4363 | #define emit_fyl2x(e) emit_fp_simple(e, OP_FYL2X) | |
| 4364 | #define emit_fptan(e) emit_fp_simple(e, OP_FPTAN) | |
| 4365 | #define emit_fpatan(e) emit_fp_simple(e, OP_FPATAN) | |
| 4366 | #define emit_fxtract(e) emit_fp_simple(e, OP_FXTRACT) | |
| 4367 | #define emit_fprem1(e) emit_fp_simple(e, OP_FPREM1) | |
| 4368 | #define emit_fdecstp(e) emit_fp_simple(e, OP_FDECSTP) | |
| 4369 | #define emit_fincstp(e) emit_fp_simple(e, OP_FINCSTP) | |
| 4370 | #define emit_fprem(e) emit_fp_simple(e, OP_FPREM) | |
| 4371 | #define emit_fyl2xp1(e) emit_fp_simple(e, OP_FYl2XP1) | |
| 4372 | #define emit_fsqrt(e) emit_fp_simple(e, OP_FSQRT) | |
| 4373 | #define emit_fsincos(e) emit_fp_simple(e, OP_FSINCOS) | |
| 4374 | #define emit_frndint(e) emit_fp_simple(e, OP_FRNDINT) | |
| 4375 | #define emit_fscale(e) emit_fp_simple(e, OP_FSCALE) | |
| 4376 | #define emit_fsin(e) emit_fp_simple(e, OP_FSIN) | |
| 4377 | #define emit_fcos(e) emit_fp_simple(e, OP_FCOS) | |
| 4378 | #define emit_fucompp(e) emit_fp_simple(e, OP_FUCOMPP) | |
| 4379 | #define emit_fclex(e) emit_fp_simple(e, OP_FCLEX) | |
| 4380 | #define emit_finit(e) emit_fp_simple(e, OP_FINIT) | |
| 4381 | #define emit_fcompp(e) emit_fp_simple(e, OP_FCOMPP) | |
| 4382 | #define emit_fstsw_ax(e) emit_fp_simple(e, OP_FSTSW_AX) | |
| 4383 | ||
| 4384 | ||
| 4385 | ||
| 4386 | /*************************************************************************** | |
| 4387 | REGISTER-BASED FPU EMITTERS | |
| 4388 | ***************************************************************************/ | |
| 4389 | ||
| 4390 | #define emit_ffree_stn(e, reg) emit_fp_reg(e, OP_FFREE_STn, reg) | |
| 4391 | #define emit_fst_stn(e, reg) emit_fp_reg(e, OP_FST_STn, reg) | |
| 4392 | #define emit_fstp_stn(e, reg) emit_fp_reg(e, OP_FSTP_STn, reg) | |
| 4393 | #define emit_fucomp_stn(e, reg) emit_fp_reg(e, OP_FUCOMP_STn, reg) | |
| 4394 | ||
| 4395 | #define emit_fadd_st0_stn(e, reg) emit_fp_reg(e, OP_FADD_ST0_STn, reg) | |
| 4396 | #define emit_fmul_st0_stn(e, reg) emit_fp_reg(e, OP_FMUL_ST0_STn, reg) | |
| 4397 | #define emit_fcom_st0_stn(e, reg) emit_fp_reg(e, OP_FCOM_ST0_STn, reg) | |
| 4398 | #define emit_fcomp_st0_stn(e, reg) emit_fp_reg(e, OP_FCOMP_ST0_STn, reg) | |
| 4399 | #define emit_fsub_st0_stn(e, reg) emit_fp_reg(e, OP_FSUB_ST0_STn, reg) | |
| 4400 | #define emit_fsubr_st0_stn(e, reg) emit_fp_reg(e, OP_FSUBR_ST0_STn, reg) | |
| 4401 | #define emit_fdiv_st0_stn(e, reg) emit_fp_reg(e, OP_FDIV_ST0_STn, reg) | |
| 4402 | #define emit_fdivr_st0_stn(e, reg) emit_fp_reg(e, OP_FDIVR_ST0_STn, reg) | |
| 4403 | #define emit_fld_st0_stn(e, reg) emit_fp_reg(e, OP_FLD_ST0_STn, reg) | |
| 4404 | #define emit_fxch_st0_stn(e, reg) emit_fp_reg(e, OP_FXCH_ST0_STn, reg) | |
| 4405 | #define emit_fcmovb_st0_stn(e, reg) emit_fp_reg(e, OP_FCMOVB_ST0_STn, reg) | |
| 4406 | #define emit_fcmove_st0_stn(e, reg) emit_fp_reg(e, OP_FCMOVE_ST0_STn, reg) | |
| 4407 | #define emit_fcmovbe_st0_stn(e, reg) emit_fp_reg(e, OP_FCMOVBE_ST0_STn, reg) | |
| 4408 | #define emit_fcmovu_st0_stn(e, reg) emit_fp_reg(e, OP_FCMOVU_ST0_STn, reg) | |
| 4409 | #define emit_fcmovnb_st0_stn(e, reg) emit_fp_reg(e, OP_FCMOVNB_ST0_STn, reg) | |
| 4410 | #define emit_fcmovne_st0_stn(e, reg) emit_fp_reg(e, OP_FCMOVNE_ST0_STn, reg) | |
| 4411 | #define emit_fcmovnbe_st0_stn(e, reg) emit_fp_reg(e, OP_FCMOVNBE_ST0_STn, reg) | |
| 4412 | #define emit_fcmovnu_st0_stn(e, reg) emit_fp_reg(e, OP_FCMOVNU_ST0_STn, reg) | |
| 4413 | #define emit_fucomi_st0_stn(e, reg) emit_fp_reg(e, OP_FUCOMI_ST0_STn, reg) | |
| 4414 | #define emit_fcomi_st0_stn(e, reg) emit_fp_reg(e, OP_FCOMI_ST0_STn, reg) | |
| 4415 | #define emit_fcomip_st0_stn(e, reg) emit_fp_reg(e, OP_FCOMIP_ST0_STn, reg) | |
| 4416 | ||
| 4417 | #define emit_fadd_stn_st0(e, reg) emit_fp_reg(e, OP_FADD_STn_ST0, reg) | |
| 4418 | #define emit_fmul_stn_st0(e, reg) emit_fp_reg(e, OP_FMUL_STn_ST0, reg) | |
| 4419 | #define emit_fsubr_stn_st0(e, reg) emit_fp_reg(e, OP_FSUBR_STn_ST0, reg) | |
| 4420 | #define emit_fsub_stn_st0(e, reg) emit_fp_reg(e, OP_FSUB_STn_ST0, reg) | |
| 4421 | #define emit_fdivr_stn_st0(e, reg) emit_fp_reg(e, OP_FDIVR_STn_ST0, reg) | |
| 4422 | #define emit_fdiv_stn_st0(e, reg) emit_fp_reg(e, OP_FDIV_STn_ST0, reg) | |
| 4423 | #define emit_fucom_stn_st0(e, reg) emit_fp_reg(e, OP_FUCOM_STn_ST0, reg) | |
| 4424 | #define emit_faddp_stn_st0(e, reg) emit_fp_reg(e, OP_FADDP_STn_ST0, reg) | |
| 4425 | #define emit_fmulp_stn_st0(e, reg) emit_fp_reg(e, OP_FMULP_STn_ST0, reg) | |
| 4426 | #define emit_fsubrp_stn_st0(e, reg) emit_fp_reg(e, OP_FSUBRP_STn_ST0, reg) | |
| 4427 | #define emit_fsubp_stn_st0(e, reg) emit_fp_reg(e, OP_FSUBP_STn_ST0, reg) | |
| 4428 | #define emit_fdivrp_stn_st0(e, reg) emit_fp_reg(e, OP_FDIVRP_STn_ST0, reg) | |
| 4429 | #define emit_fdivp_stn_st0(e, reg) emit_fp_reg(e, OP_FDIVP_STn_ST0, reg) | |
| 4430 | ||
| 4431 | ||
| 4432 | ||
| 4433 | /*************************************************************************** | |
| 4434 | MEMORY FPU EMITTERS | |
| 4435 | ***************************************************************************/ | |
| 4436 | ||
| 4437 | #define emit_fadd_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_D8, 0, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4438 | #define emit_fadd_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D8, 0, (base), REG_NONE, 1, (disp)) | |
| 4439 | #define emit_fadd_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 0, REG_NONE, (index), (scale), (disp)) | |
| 4440 | #define emit_fadd_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 0, (base), (index), (scale), (disp)) | |
| 4441 | ||
| 4442 | #define emit_fmul_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_D8, 1, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4443 | #define emit_fmul_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D8, 1, (base), REG_NONE, 1, (disp)) | |
| 4444 | #define emit_fmul_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 1, REG_NONE, (index), (scale), (disp)) | |
| 4445 | #define emit_fmul_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 1, (base), (index), (scale), (disp)) | |
| 4446 | ||
| 4447 | #define emit_fcom_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_D8, 2, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4448 | #define emit_fcom_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D8, 2, (base), REG_NONE, 1, (disp)) | |
| 4449 | #define emit_fcom_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 2, REG_NONE, (index), (scale), (disp)) | |
| 4450 | #define emit_fcom_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 2, (base), (index), (scale), (disp)) | |
| 4451 | ||
| 4452 | #define emit_fcomp_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_D8, 3, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4453 | #define emit_fcomp_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D8, 3, (base), REG_NONE, 1, (disp)) | |
| 4454 | #define emit_fcomp_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 3, REG_NONE, (index), (scale), (disp)) | |
| 4455 | #define emit_fcomp_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 3, (base), (index), (scale), (disp)) | |
| 4456 | ||
| 4457 | #define emit_fsub_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_D8, 4, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4458 | #define emit_fsub_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D8, 4, (base), REG_NONE, 1, (disp)) | |
| 4459 | #define emit_fsub_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 4, REG_NONE, (index), (scale), (disp)) | |
| 4460 | #define emit_fsub_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 4, (base), (index), (scale), (disp)) | |
| 4461 | ||
| 4462 | #define emit_fsubr_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_D8, 5, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4463 | #define emit_fsubr_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D8, 5, (base), REG_NONE, 1, (disp)) | |
| 4464 | #define emit_fsubr_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 5, REG_NONE, (index), (scale), (disp)) | |
| 4465 | #define emit_fsubr_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 5, (base), (index), (scale), (disp)) | |
| 4466 | ||
| 4467 | #define emit_fdiv_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_D8, 6, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4468 | #define emit_fdiv_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D8, 6, (base), REG_NONE, 1, (disp)) | |
| 4469 | #define emit_fdiv_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 6, REG_NONE, (index), (scale), (disp)) | |
| 4470 | #define emit_fdiv_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 6, (base), (index), (scale), (disp)) | |
| 4471 | ||
| 4472 | #define emit_fdivr_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_D8, 7, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4473 | #define emit_fdivr_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D8, 7, (base), REG_NONE, 1, (disp)) | |
| 4474 | #define emit_fdivr_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 7, REG_NONE, (index), (scale), (disp)) | |
| 4475 | #define emit_fdivr_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D8, 7, (base), (index), (scale), (disp)) | |
| 4476 | ||
| 4477 | ||
| 4478 | #define emit_fld_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_D9, 0, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4479 | #define emit_fld_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D9, 0, (base), REG_NONE, 1, (disp)) | |
| 4480 | #define emit_fld_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 0, REG_NONE, (index), (scale), (disp)) | |
| 4481 | #define emit_fld_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 0, (base), (index), (scale), (disp)) | |
| 4482 | ||
| 4483 | #define emit_fst_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_D9, 2, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4484 | #define emit_fst_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D9, 2, (base), REG_NONE, 1, (disp)) | |
| 4485 | #define emit_fst_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 2, REG_NONE, (index), (scale), (disp)) | |
| 4486 | #define emit_fst_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 2, (base), (index), (scale), (disp)) | |
| 4487 | ||
| 4488 | #define emit_fstp_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_D9, 3, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4489 | #define emit_fstp_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D9, 3, (base), REG_NONE, 1, (disp)) | |
| 4490 | #define emit_fstp_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 3, REG_NONE, (index), (scale), (disp)) | |
| 4491 | #define emit_fstp_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 3, (base), (index), (scale), (disp)) | |
| 4492 | ||
| 4493 | #define emit_fldenv_mabs(e, addr) emit_fp_modrm(e, OP_ESC_D9, 4, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4494 | #define emit_fldenv_mbd(e, base, disp) emit_fp_modrm(e, OP_ESC_D9, 4, (base), REG_NONE, 1, (disp)) | |
| 4495 | #define emit_fldenv_misd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 4, REG_NONE, (index), (scale), (disp)) | |
| 4496 | #define emit_fldenv_mbisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 4, (base), (index), (scale), (disp)) | |
| 4497 | ||
| 4498 | #define emit_fldcw_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_D9, 5, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4499 | #define emit_fldcw_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D9, 5, (base), REG_NONE, 1, (disp)) | |
| 4500 | #define emit_fldcw_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 5, REG_NONE, (index), (scale), (disp)) | |
| 4501 | #define emit_fldcw_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 5, (base), (index), (scale), (disp)) | |
| 4502 | ||
| 4503 | #define emit_fstenv_mabs(e, addr) emit_fp_modrm(e, OP_ESC_D9, 6, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4504 | #define emit_fstenv_mbd(e, base, disp) emit_fp_modrm(e, OP_ESC_D9, 6, (base), REG_NONE, 1, (disp)) | |
| 4505 | #define emit_fstenv_misd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 6, REG_NONE, (index), (scale), (disp)) | |
| 4506 | #define emit_fstenv_mbisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 6, (base), (index), (scale), (disp)) | |
| 4507 | ||
| 4508 | #define emit_fstcw_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_D9, 7, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4509 | #define emit_fstcw_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_D9, 7, (base), REG_NONE, 1, (disp)) | |
| 4510 | #define emit_fstcw_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 7, REG_NONE, (index), (scale), (disp)) | |
| 4511 | #define emit_fstcw_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_D9, 7, (base), (index), (scale), (disp)) | |
| 4512 | ||
| 4513 | ||
| 4514 | #define emit_fiadd_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DA, 0, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4515 | #define emit_fiadd_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DA, 0, (base), REG_NONE, 1, (disp)) | |
| 4516 | #define emit_fiadd_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 0, REG_NONE, (index), (scale), (disp)) | |
| 4517 | #define emit_fiadd_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 0, (base), (index), (scale), (disp)) | |
| 4518 | ||
| 4519 | #define emit_fimul_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DA, 1, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4520 | #define emit_fimul_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DA, 1, (base), REG_NONE, 1, (disp)) | |
| 4521 | #define emit_fimul_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 1, REG_NONE, (index), (scale), (disp)) | |
| 4522 | #define emit_fimul_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 1, (base), (index), (scale), (disp)) | |
| 4523 | ||
| 4524 | #define emit_ficom_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DA, 2, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4525 | #define emit_ficom_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DA, 2, (base), REG_NONE, 1, (disp)) | |
| 4526 | #define emit_ficom_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 2, REG_NONE, (index), (scale), (disp)) | |
| 4527 | #define emit_ficom_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 2, (base), (index), (scale), (disp)) | |
| 4528 | ||
| 4529 | #define emit_ficomp_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DA, 3, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4530 | #define emit_ficomp_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DA, 3, (base), REG_NONE, 1, (disp)) | |
| 4531 | #define emit_ficomp_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 3, REG_NONE, (index), (scale), (disp)) | |
| 4532 | #define emit_ficomp_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 3, (base), (index), (scale), (disp)) | |
| 4533 | ||
| 4534 | #define emit_fisub_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DA, 4, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4535 | #define emit_fisub_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DA, 4, (base), REG_NONE, 1, (disp)) | |
| 4536 | #define emit_fisub_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 4, REG_NONE, (index), (scale), (disp)) | |
| 4537 | #define emit_fisub_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 4, (base), (index), (scale), (disp)) | |
| 4538 | ||
| 4539 | #define emit_fisubr_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DA, 5, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4540 | #define emit_fisubr_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DA, 5, (base), REG_NONE, 1, (disp)) | |
| 4541 | #define emit_fisubr_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 5, REG_NONE, (index), (scale), (disp)) | |
| 4542 | #define emit_fisubr_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 5, (base), (index), (scale), (disp)) | |
| 4543 | ||
| 4544 | #define emit_fidiv_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DA, 6, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4545 | #define emit_fidiv_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DA, 6, (base), REG_NONE, 1, (disp)) | |
| 4546 | #define emit_fidiv_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 6, REG_NONE, (index), (scale), (disp)) | |
| 4547 | #define emit_fidiv_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 6, (base), (index), (scale), (disp)) | |
| 4548 | ||
| 4549 | #define emit_fidivr_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DA, 7, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4550 | #define emit_fidivr_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DA, 7, (base), REG_NONE, 1, (disp)) | |
| 4551 | #define emit_fidivr_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 7, REG_NONE, (index), (scale), (disp)) | |
| 4552 | #define emit_fidivr_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DA, 7, (base), (index), (scale), (disp)) | |
| 4553 | ||
| 4554 | ||
| 4555 | #define emit_fild_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DB, 0, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4556 | #define emit_fild_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DB, 0, (base), REG_NONE, 1, (disp)) | |
| 4557 | #define emit_fild_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 0, REG_NONE, (index), (scale), (disp)) | |
| 4558 | #define emit_fild_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 0, (base), (index), (scale), (disp)) | |
| 4559 | ||
| 4560 | #define emit_fisttp_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DB, 1, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4561 | #define emit_fisttp_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DB, 1, (base), REG_NONE, 1, (disp)) | |
| 4562 | #define emit_fisttp_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 1, REG_NONE, (index), (scale), (disp)) | |
| 4563 | #define emit_fisttp_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 1, (base), (index), (scale), (disp)) | |
| 4564 | ||
| 4565 | #define emit_fist_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DB, 2, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4566 | #define emit_fist_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DB, 2, (base), REG_NONE, 1, (disp)) | |
| 4567 | #define emit_fist_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 2, REG_NONE, (index), (scale), (disp)) | |
| 4568 | #define emit_fist_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 2, (base), (index), (scale), (disp)) | |
| 4569 | ||
| 4570 | #define emit_fistp_m32abs(e, addr) emit_fp_modrm(e, OP_ESC_DB, 3, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4571 | #define emit_fistp_m32bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DB, 3, (base), REG_NONE, 1, (disp)) | |
| 4572 | #define emit_fistp_m32isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 3, REG_NONE, (index), (scale), (disp)) | |
| 4573 | #define emit_fistp_m32bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 3, (base), (index), (scale), (disp)) | |
| 4574 | ||
| 4575 | #define emit_fld_m80abs(e, addr) emit_fp_modrm(e, OP_ESC_DB, 5, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4576 | #define emit_fld_m80bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DB, 5, (base), REG_NONE, 1, (disp)) | |
| 4577 | #define emit_fld_m80isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 5, REG_NONE, (index), (scale), (disp)) | |
| 4578 | #define emit_fld_m80bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 5, (base), (index), (scale), (disp)) | |
| 4579 | ||
| 4580 | #define emit_fstp_m80abs(e, addr) emit_fp_modrm(e, OP_ESC_DB, 7, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4581 | #define emit_fstp_m80bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DB, 7, (base), REG_NONE, 1, (disp)) | |
| 4582 | #define emit_fstp_m80isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 7, REG_NONE, (index), (scale), (disp)) | |
| 4583 | #define emit_fstp_m80bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DB, 7, (base), (index), (scale), (disp)) | |
| 4584 | ||
| 4585 | ||
| 4586 | #define emit_fadd_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DC, 0, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4587 | #define emit_fadd_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DC, 0, (base), REG_NONE, 1, (disp)) | |
| 4588 | #define emit_fadd_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 0, REG_NONE, (index), (scale), (disp)) | |
| 4589 | #define emit_fadd_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 0, (base), (index), (scale), (disp)) | |
| 4590 | ||
| 4591 | #define emit_fmul_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DC, 1, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4592 | #define emit_fmul_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DC, 1, (base), REG_NONE, 1, (disp)) | |
| 4593 | #define emit_fmul_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 1, REG_NONE, (index), (scale), (disp)) | |
| 4594 | #define emit_fmul_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 1, (base), (index), (scale), (disp)) | |
| 4595 | ||
| 4596 | #define emit_fcom_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DC, 2, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4597 | #define emit_fcom_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DC, 2, (base), REG_NONE, 1, (disp)) | |
| 4598 | #define emit_fcom_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 2, REG_NONE, (index), (scale), (disp)) | |
| 4599 | #define emit_fcom_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 2, (base), (index), (scale), (disp)) | |
| 4600 | ||
| 4601 | #define emit_fcomp_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DC, 3, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4602 | #define emit_fcomp_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DC, 3, (base), REG_NONE, 1, (disp)) | |
| 4603 | #define emit_fcomp_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 3, REG_NONE, (index), (scale), (disp)) | |
| 4604 | #define emit_fcomp_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 3, (base), (index), (scale), (disp)) | |
| 4605 | ||
| 4606 | #define emit_fsub_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DC, 4, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4607 | #define emit_fsub_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DC, 4, (base), REG_NONE, 1, (disp)) | |
| 4608 | #define emit_fsub_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 4, REG_NONE, (index), (scale), (disp)) | |
| 4609 | #define emit_fsub_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 4, (base), (index), (scale), (disp)) | |
| 4610 | ||
| 4611 | #define emit_fsubr_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DC, 5, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4612 | #define emit_fsubr_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DC, 5, (base), REG_NONE, 1, (disp)) | |
| 4613 | #define emit_fsubr_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 5, REG_NONE, (index), (scale), (disp)) | |
| 4614 | #define emit_fsubr_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 5, (base), (index), (scale), (disp)) | |
| 4615 | ||
| 4616 | #define emit_fdiv_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DC, 6, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4617 | #define emit_fdiv_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DC, 6, (base), REG_NONE, 1, (disp)) | |
| 4618 | #define emit_fdiv_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 6, REG_NONE, (index), (scale), (disp)) | |
| 4619 | #define emit_fdiv_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 6, (base), (index), (scale), (disp)) | |
| 4620 | ||
| 4621 | #define emit_fdivr_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DC, 7, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4622 | #define emit_fdivr_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DC, 7, (base), REG_NONE, 1, (disp)) | |
| 4623 | #define emit_fdivr_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 7, REG_NONE, (index), (scale), (disp)) | |
| 4624 | #define emit_fdivr_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DC, 7, (base), (index), (scale), (disp)) | |
| 4625 | ||
| 4626 | ||
| 4627 | #define emit_fld_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DD, 0, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4628 | #define emit_fld_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DD, 0, (base), REG_NONE, 1, (disp)) | |
| 4629 | #define emit_fld_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 0, REG_NONE, (index), (scale), (disp)) | |
| 4630 | #define emit_fld_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 0, (base), (index), (scale), (disp)) | |
| 4631 | ||
| 4632 | #define emit_fisttp_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DD, 1, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4633 | #define emit_fisttp_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DD, 1, (base), REG_NONE, 1, (disp)) | |
| 4634 | #define emit_fisttp_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 1, REG_NONE, (index), (scale), (disp)) | |
| 4635 | #define emit_fisttp_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 1, (base), (index), (scale), (disp)) | |
| 4636 | ||
| 4637 | #define emit_fst_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DD, 2, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4638 | #define emit_fst_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DD, 2, (base), REG_NONE, 1, (disp)) | |
| 4639 | #define emit_fst_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 2, REG_NONE, (index), (scale), (disp)) | |
| 4640 | #define emit_fst_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 2, (base), (index), (scale), (disp)) | |
| 4641 | ||
| 4642 | #define emit_fstp_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DD, 3, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4643 | #define emit_fstp_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DD, 3, (base), REG_NONE, 1, (disp)) | |
| 4644 | #define emit_fstp_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 3, REG_NONE, (index), (scale), (disp)) | |
| 4645 | #define emit_fstp_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 3, (base), (index), (scale), (disp)) | |
| 4646 | ||
| 4647 | #define emit_frstor_mabs(e, addr) emit_fp_modrm(e, OP_ESC_DD, 4, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4648 | #define emit_frstor_mbd(e, base, disp) emit_fp_modrm(e, OP_ESC_DD, 4, (base), REG_NONE, 1, (disp)) | |
| 4649 | #define emit_frstor_misd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 4, REG_NONE, (index), (scale), (disp)) | |
| 4650 | #define emit_frstor_mbisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 4, (base), (index), (scale), (disp)) | |
| 4651 | ||
| 4652 | #define emit_fsave_mabs(e, addr) emit_fp_modrm(e, OP_ESC_DD, 6, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4653 | #define emit_fsave_mbd(e, base, disp) emit_fp_modrm(e, OP_ESC_DD, 6, (base), REG_NONE, 1, (disp)) | |
| 4654 | #define emit_fsave_misd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 6, REG_NONE, (index), (scale), (disp)) | |
| 4655 | #define emit_fsave_mbisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 6, (base), (index), (scale), (disp)) | |
| 4656 | ||
| 4657 | #define emit_fstsw_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DD, 7, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4658 | #define emit_fstsw_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DD, 7, (base), REG_NONE, 1, (disp)) | |
| 4659 | #define emit_fstsw_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 7, REG_NONE, (index), (scale), (disp)) | |
| 4660 | #define emit_fstsw_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DD, 7, (base), (index), (scale), (disp)) | |
| 4661 | ||
| 4662 | ||
| 4663 | #define emit_fiadd_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DE, 0, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4664 | #define emit_fiadd_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DE, 0, (base), REG_NONE, 1, (disp)) | |
| 4665 | #define emit_fiadd_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 0, REG_NONE, (index), (scale), (disp)) | |
| 4666 | #define emit_fiadd_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 0, (base), (index), (scale), (disp)) | |
| 4667 | ||
| 4668 | #define emit_fimul_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DE, 1, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4669 | #define emit_fimul_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DE, 1, (base), REG_NONE, 1, (disp)) | |
| 4670 | #define emit_fimul_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 1, REG_NONE, (index), (scale), (disp)) | |
| 4671 | #define emit_fimul_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 1, (base), (index), (scale), (disp)) | |
| 4672 | ||
| 4673 | #define emit_ficom_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DE, 2, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4674 | #define emit_ficom_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DE, 2, (base), REG_NONE, 1, (disp)) | |
| 4675 | #define emit_ficom_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 2, REG_NONE, (index), (scale), (disp)) | |
| 4676 | #define emit_ficom_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 2, (base), (index), (scale), (disp)) | |
| 4677 | ||
| 4678 | #define emit_ficomp_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DE, 3, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4679 | #define emit_ficomp_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DE, 3, (base), REG_NONE, 1, (disp)) | |
| 4680 | #define emit_ficomp_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 3, REG_NONE, (index), (scale), (disp)) | |
| 4681 | #define emit_ficomp_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 3, (base), (index), (scale), (disp)) | |
| 4682 | ||
| 4683 | #define emit_fisub_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DE, 4, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4684 | #define emit_fisub_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DE, 4, (base), REG_NONE, 1, (disp)) | |
| 4685 | #define emit_fisub_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 4, REG_NONE, (index), (scale), (disp)) | |
| 4686 | #define emit_fisub_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 4, (base), (index), (scale), (disp)) | |
| 4687 | ||
| 4688 | #define emit_fisubr_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DE, 5, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4689 | #define emit_fisubr_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DE, 5, (base), REG_NONE, 1, (disp)) | |
| 4690 | #define emit_fisubr_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 5, REG_NONE, (index), (scale), (disp)) | |
| 4691 | #define emit_fisubr_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 5, (base), (index), (scale), (disp)) | |
| 4692 | ||
| 4693 | #define emit_fidiv_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DE, 6, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4694 | #define emit_fidiv_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DE, 6, (base), REG_NONE, 1, (disp)) | |
| 4695 | #define emit_fidiv_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 6, REG_NONE, (index), (scale), (disp)) | |
| 4696 | #define emit_fidiv_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 6, (base), (index), (scale), (disp)) | |
| 4697 | ||
| 4698 | #define emit_fidivr_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DE, 7, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4699 | #define emit_fidivr_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DE, 7, (base), REG_NONE, 1, (disp)) | |
| 4700 | #define emit_fidivr_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 7, REG_NONE, (index), (scale), (disp)) | |
| 4701 | #define emit_fidivr_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DE, 7, (base), (index), (scale), (disp)) | |
| 4702 | ||
| 4703 | ||
| 4704 | #define emit_fild_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DF, 0, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4705 | #define emit_fild_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DF, 0, (base), REG_NONE, 1, (disp)) | |
| 4706 | #define emit_fild_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 0, REG_NONE, (index), (scale), (disp)) | |
| 4707 | #define emit_fild_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 0, (base), (index), (scale), (disp)) | |
| 4708 | ||
| 4709 | #define emit_fisttp_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DF, 1, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4710 | #define emit_fisttp_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DF, 1, (base), REG_NONE, 1, (disp)) | |
| 4711 | #define emit_fisttp_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 1, REG_NONE, (index), (scale), (disp)) | |
| 4712 | #define emit_fisttp_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 1, (base), (index), (scale), (disp)) | |
| 4713 | ||
| 4714 | #define emit_fist_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DF, 2, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4715 | #define emit_fist_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DF, 2, (base), REG_NONE, 1, (disp)) | |
| 4716 | #define emit_fist_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 2, REG_NONE, (index), (scale), (disp)) | |
| 4717 | #define emit_fist_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 2, (base), (index), (scale), (disp)) | |
| 4718 | ||
| 4719 | #define emit_fistp_m16abs(e, addr) emit_fp_modrm(e, OP_ESC_DF, 3, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4720 | #define emit_fistp_m16bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DF, 3, (base), REG_NONE, 1, (disp)) | |
| 4721 | #define emit_fistp_m16isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 3, REG_NONE, (index), (scale), (disp)) | |
| 4722 | #define emit_fistp_m16bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 3, (base), (index), (scale), (disp)) | |
| 4723 | ||
| 4724 | #define emit_fbld_m80abs(e, addr) emit_fp_modrm(e, OP_ESC_DF, 4, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4725 | #define emit_fbld_m80bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DF, 4, (base), REG_NONE, 1, (disp)) | |
| 4726 | #define emit_fbld_m80isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 4, REG_NONE, (index), (scale), (disp)) | |
| 4727 | #define emit_fbld_m80bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 4, (base), (index), (scale), (disp)) | |
| 4728 | ||
| 4729 | #define emit_fild_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DF, 5, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4730 | #define emit_fild_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DF, 5, (base), REG_NONE, 1, (disp)) | |
| 4731 | #define emit_fild_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 5, REG_NONE, (index), (scale), (disp)) | |
| 4732 | #define emit_fild_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 5, (base), (index), (scale), (disp)) | |
| 4733 | ||
| 4734 | #define emit_fbstp_m80abs(e, addr) emit_fp_modrm(e, OP_ESC_DF, 6, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4735 | #define emit_fbstp_m80bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DF, 6, (base), REG_NONE, 1, (disp)) | |
| 4736 | #define emit_fbstp_m80isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 6, REG_NONE, (index), (scale), (disp)) | |
| 4737 | #define emit_fbstp_m80bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 6, (base), (index), (scale), (disp)) | |
| 4738 | ||
| 4739 | #define emit_fistp_m64abs(e, addr) emit_fp_modrm(e, OP_ESC_DF, 7, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4740 | #define emit_fistp_m64bd(e, base, disp) emit_fp_modrm(e, OP_ESC_DF, 7, (base), REG_NONE, 1, (disp)) | |
| 4741 | #define emit_fistp_m64isd(e, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 7, REG_NONE, (index), (scale), (disp)) | |
| 4742 | #define emit_fistp_m64bisd(e, base, index, scale, disp) emit_fp_modrm(e, OP_ESC_DF, 7, (base), (index), (scale), (disp)) | |
| 4743 | ||
| 4744 | #endif | |
| 4745 | ||
| 4746 | ||
| 4747 | ||
| 4748 | /*************************************************************************** | |
| 4749 | GROUP16 EMITTERS | |
| 4750 | ***************************************************************************/ | |
| 4751 | ||
| 4752 | /*------------------------------------------------------------------ | |
| 4753 | emit_ldmxcsr_* | |
| 4754 | ------------------------------------------------------------------*/ | |
| 4755 | ||
| 4756 | INLINE void emit_ldmxcsr_m32bisd(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 4757 | { | |
| 4758 | emit_op_modrm_mem(emitptr, OP_G16, OP_32BIT, 2, base, index, scale, disp); | |
| 4759 | } | |
| 4760 | ||
| 4761 | #define emit_ldmxcsr_m32abs(e, addr) emit_ldmxcsr_m32bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4762 | #define emit_ldmxcsr_m32bd(e, base, disp) emit_ldmxcsr_m32bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4763 | #define emit_ldmxcsr_m32isd(e, index, scale, disp) emit_ldmxcsr_m32bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4764 | ||
| 4765 | ||
| 4766 | /*------------------------------------------------------------------ | |
| 4767 | emit_stmxcsr_* | |
| 4768 | ------------------------------------------------------------------*/ | |
| 4769 | ||
| 4770 | INLINE void emit_stmxcsr_m32bisd(x86code **emitptr, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 4771 | { | |
| 4772 | emit_op_modrm_mem(emitptr, OP_G16, OP_32BIT, 3, base, index, scale, disp); | |
| 4773 | } | |
| 4774 | ||
| 4775 | #define emit_stmxcsr_m32abs(e, addr) emit_stmxcsr_m32bisd(e, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4776 | #define emit_stmxcsr_m32bd(e, base, disp) emit_stmxcsr_m32bisd(e, (base), REG_NONE, 1, (disp)) | |
| 4777 | #define emit_stmxcsr_m32isd(e, index, scale, disp) emit_stmxcsr_m32bisd(e, REG_NONE, (index), (scale), (disp)) | |
| 4778 | ||
| 4779 | ||
| 4780 | ||
| 4781 | /*************************************************************************** | |
| 4782 | SSE EMITTERS | |
| 4783 | ***************************************************************************/ | |
| 4784 | ||
| 4785 | INLINE void emit_sse_r128_r128(x86code **emitptr, UINT32 op, UINT8 dreg, UINT8 sreg) | |
| 4786 | { | |
| 4787 | emit_op_modrm_reg(emitptr, op, OP_32BIT, dreg, sreg); | |
| 4788 | } | |
| 4789 | ||
| 4790 | INLINE void emit_sse_r128_mbisd(x86code **emitptr, UINT32 op, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 4791 | { | |
| 4792 | emit_op_modrm_mem(emitptr, op, OP_32BIT, dreg, base, index, scale, disp); | |
| 4793 | } | |
| 4794 | ||
| 4795 | INLINE void emit_sse_r128_r128_rex(x86code **emitptr, UINT32 op, UINT8 dreg, UINT8 sreg) | |
| 4796 | { | |
| 4797 | emit_op_modrm_reg(emitptr, op, OP_64BIT, dreg, sreg); | |
| 4798 | } | |
| 4799 | ||
| 4800 | INLINE void emit_sse_r128_mbisd_rex(x86code **emitptr, UINT32 op, UINT8 dreg, UINT8 base, UINT8 index, UINT8 scale, INT32 disp) | |
| 4801 | { | |
| 4802 | emit_op_modrm_mem(emitptr, op, OP_64BIT, dreg, base, index, scale, disp); | |
| 4803 | } | |
| 4804 | ||
| 4805 | ||
| 4806 | ||
| 4807 | /*************************************************************************** | |
| 4808 | SSE SCALAR SINGLE EMITTERS | |
| 4809 | ***************************************************************************/ | |
| 4810 | ||
| 4811 | #define emit_movss_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MOVSS_Vss_Wss, dreg, sreg) | |
| 4812 | #define emit_movss_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MOVSS_Vss_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4813 | #define emit_movss_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MOVSS_Vss_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4814 | #define emit_movss_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MOVSS_Vss_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4815 | #define emit_movss_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_MOVSS_Vss_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4816 | ||
| 4817 | #define emit_movss_m32abs_r128(e, addr, sreg) emit_sse_r128_mbisd(e, OP_MOVSS_Wss_Vss, sreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4818 | #define emit_movss_m32bd_r128(e, base, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVSS_Wss_Vss, sreg, (base), REG_NONE, 1, (disp)) | |
| 4819 | #define emit_movss_m32isd_r128(e, index, scale, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVSS_Wss_Vss, sreg, REG_NONE, (index), (scale), (disp)) | |
| 4820 | #define emit_movss_m32bisd_r128(e, base, index, scale, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVSS_Wss_Vss, sreg, (base), (index), (scale), (disp)) | |
| 4821 | ||
| 4822 | #define emit_addss_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ADDSS_Vss_Wss, dreg, sreg) | |
| 4823 | #define emit_addss_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ADDSS_Vss_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4824 | #define emit_addss_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ADDSS_Vss_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4825 | #define emit_addss_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ADDSS_Vss_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4826 | #define emit_addss_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_ADDSS_Vss_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4827 | ||
| 4828 | #define emit_subss_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SUBSS_Vss_Wss, dreg, sreg) | |
| 4829 | #define emit_subss_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SUBSS_Vss_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4830 | #define emit_subss_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SUBSS_Vss_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4831 | #define emit_subss_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SUBSS_Vss_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4832 | #define emit_subss_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_SUBSS_Vss_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4833 | ||
| 4834 | #define emit_mulss_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MULSS_Vss_Wss, dreg, sreg) | |
| 4835 | #define emit_mulss_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MULSS_Vss_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4836 | #define emit_mulss_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MULSS_Vss_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4837 | #define emit_mulss_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MULSS_Vss_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4838 | #define emit_mulss_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_MULSS_Vss_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4839 | ||
| 4840 | #define emit_divss_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_DIVSS_Vss_Wss, dreg, sreg) | |
| 4841 | #define emit_divss_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_DIVSS_Vss_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4842 | #define emit_divss_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_DIVSS_Vss_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4843 | #define emit_divss_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_DIVSS_Vss_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4844 | #define emit_divss_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_DIVSS_Vss_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4845 | ||
| 4846 | #define emit_rcpss_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_RCPSS_Vss_Wss, dreg, sreg) | |
| 4847 | #define emit_rcpss_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_RCPSS_Vss_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4848 | #define emit_rcpss_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_RCPSS_Vss_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4849 | #define emit_rcpss_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_RCPSS_Vss_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4850 | #define emit_rcpss_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_RCPSS_Vss_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4851 | ||
| 4852 | #define emit_sqrtss_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SQRTSS_Vss_Wss, dreg, sreg) | |
| 4853 | #define emit_sqrtss_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SQRTSS_Vss_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4854 | #define emit_sqrtss_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SQRTSS_Vss_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4855 | #define emit_sqrtss_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SQRTSS_Vss_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4856 | #define emit_sqrtss_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_SQRTSS_Vss_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4857 | ||
| 4858 | #define emit_rsqrtss_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_RSQRTSS_Vss_Wss, dreg, sreg) | |
| 4859 | #define emit_rsqrtss_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_RSQRTSS_Vss_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4860 | #define emit_rsqrtss_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_RSQRTSS_Vss_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4861 | #define emit_rsqrtss_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_RSQRTSS_Vss_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4862 | #define emit_rsqrtss_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_RSQRTSS_Vss_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4863 | ||
| 4864 | #define emit_comiss_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_COMISS_Vss_Wss, dreg, sreg) | |
| 4865 | #define emit_comiss_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_COMISS_Vss_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4866 | #define emit_comiss_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_COMISS_Vss_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4867 | #define emit_comiss_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_COMISS_Vss_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4868 | #define emit_comiss_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_COMISS_Vss_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4869 | ||
| 4870 | #define emit_ucomiss_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_UCOMISS_Vss_Wss, dreg, sreg) | |
| 4871 | #define emit_ucomiss_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_UCOMISS_Vss_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4872 | #define emit_ucomiss_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_UCOMISS_Vss_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4873 | #define emit_ucomiss_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_UCOMISS_Vss_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4874 | #define emit_ucomiss_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_UCOMISS_Vss_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4875 | ||
| 4876 | #define emit_cvtsi2ss_r128_r32(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTSI2SS_Vss_Ed, dreg, sreg) | |
| 4877 | #define emit_cvtsi2ss_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTSI2SS_Vss_Ed, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4878 | #define emit_cvtsi2ss_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTSI2SS_Vss_Ed, dreg, (base), REG_NONE, 1, (disp)) | |
| 4879 | #define emit_cvtsi2ss_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSI2SS_Vss_Ed, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4880 | #define emit_cvtsi2ss_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSI2SS_Vss_Ed, dreg, (base), (index), (scale), (disp)) | |
| 4881 | ||
| 4882 | #ifdef PTR64 | |
| 4883 | #define emit_cvtsi2ss_r128_r64(e, dreg, sreg) emit_sse_r128_r128_rex(e, OP_CVTSI2SS_Vss_Ed, dreg, sreg) | |
| 4884 | #define emit_cvtsi2ss_r128_m64abs(e, dreg, addr) emit_sse_r128_mbisd_rex(e, OP_CVTSI2SS_Vss_Ed, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4885 | #define emit_cvtsi2ss_r128_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSI2SS_Vss_Ed, dreg, (base), REG_NONE, 1, (disp)) | |
| 4886 | #define emit_cvtsi2ss_r128_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSI2SS_Vss_Ed, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4887 | #define emit_cvtsi2ss_r128_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSI2SS_Vss_Ed, dreg, (base), (index), (scale), (disp)) | |
| 4888 | #endif | |
| 4889 | ||
| 4890 | #define emit_cvtsd2ss_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTSD2SS_Vss_Wsd, dreg, sreg) | |
| 4891 | #define emit_cvtsd2ss_r128_m64abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTSD2SS_Vss_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4892 | #define emit_cvtsd2ss_r128_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTSD2SS_Vss_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4893 | #define emit_cvtsd2ss_r128_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSD2SS_Vss_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4894 | #define emit_cvtsd2ss_r128_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSD2SS_Vss_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 4895 | ||
| 4896 | #define emit_cvtss2si_r32_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTSS2SI_Gd_Wss, dreg, sreg) | |
| 4897 | #define emit_cvtss2si_r32_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTSS2SI_Gd_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4898 | #define emit_cvtss2si_r32_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTSS2SI_Gd_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4899 | #define emit_cvtss2si_r32_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSS2SI_Gd_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4900 | #define emit_cvtss2si_r32_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSS2SI_Gd_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4901 | ||
| 4902 | #ifdef PTR64 | |
| 4903 | #define emit_cvtss2si_r64_r128(e, dreg, sreg) emit_sse_r128_r128_rex(e, OP_CVTSS2SI_Gd_Wss, dreg, sreg) | |
| 4904 | #define emit_cvtss2si_r64_m32abs(e, dreg, addr) emit_sse_r128_mbisd_rex(e, OP_CVTSS2SI_Gd_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4905 | #define emit_cvtss2si_r64_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSS2SI_Gd_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4906 | #define emit_cvtss2si_r64_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSS2SI_Gd_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4907 | #define emit_cvtss2si_r64_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSS2SI_Gd_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4908 | #endif | |
| 4909 | ||
| 4910 | #define emit_cvttss2si_r32_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTTSS2SI_Gd_Wss, dreg, sreg) | |
| 4911 | #define emit_cvttss2si_r32_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTTSS2SI_Gd_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4912 | #define emit_cvttss2si_r32_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTTSS2SI_Gd_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4913 | #define emit_cvttss2si_r32_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTTSS2SI_Gd_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4914 | #define emit_cvttss2si_r32_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTTSS2SI_Gd_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4915 | ||
| 4916 | #ifdef PTR64 | |
| 4917 | #define emit_cvttss2si_r64_r128(e, dreg, sreg) emit_sse_r128_r128_rex(e, OP_CVTTSS2SI_Gd_Wss, dreg, sreg) | |
| 4918 | #define emit_cvttss2si_r64_m32abs(e, dreg, addr) emit_sse_r128_mbisd_rex(e, OP_CVTTSS2SI_Gd_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4919 | #define emit_cvttss2si_r64_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd_rex(e, OP_CVTTSS2SI_Gd_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 4920 | #define emit_cvttss2si_r64_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTTSS2SI_Gd_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4921 | #define emit_cvttss2si_r64_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTTSS2SI_Gd_Wss, dreg, (base), (index), (scale), (disp)) | |
| 4922 | #endif | |
| 4923 | ||
| 4924 | ||
| 4925 | ||
| 4926 | /*************************************************************************** | |
| 4927 | SSE PACKED SINGLE EMITTERS | |
| 4928 | ***************************************************************************/ | |
| 4929 | ||
| 4930 | #define emit_movps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MOVPS_Vps_Wps, dreg, sreg) | |
| 4931 | #define emit_movps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MOVPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4932 | #define emit_movps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MOVPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 4933 | #define emit_movps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MOVPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4934 | #define emit_movps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_MOVPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 4935 | ||
| 4936 | #define emit_movps_m128abs_r128(e, addr, sreg) emit_sse_r128_mbisd(e, OP_MOVPS_Wps_Vps, sreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4937 | #define emit_movps_m128bd_r128(e, base, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVPS_Wps_Vps, sreg, (base), REG_NONE, 1, (disp)) | |
| 4938 | #define emit_movps_m128isd_r128(e, index, scale, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVPS_Wps_Vps, sreg, REG_NONE, (index), (scale), (disp)) | |
| 4939 | #define emit_movps_m128bisd_r128(e, base, index, scale, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVPS_Wps_Vps, sreg, (base), (index), (scale), (disp)) | |
| 4940 | ||
| 4941 | #define emit_addps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ADDPS_Vps_Wps, dreg, sreg) | |
| 4942 | #define emit_addps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ADDPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4943 | #define emit_addps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ADDPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 4944 | #define emit_addps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ADDPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4945 | #define emit_addps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_ADDPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 4946 | ||
| 4947 | #define emit_subps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SUBPS_Vps_Wps, dreg, sreg) | |
| 4948 | #define emit_subps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SUBPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4949 | #define emit_subps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SUBPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 4950 | #define emit_subps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SUBPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4951 | #define emit_subps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_SUBPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 4952 | ||
| 4953 | #define emit_mulps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MULPS_Vps_Wps, dreg, sreg) | |
| 4954 | #define emit_mulps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MULPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4955 | #define emit_mulps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MULPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 4956 | #define emit_mulps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MULPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4957 | #define emit_mulps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_MULPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 4958 | ||
| 4959 | #define emit_divps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_DIVPS_Vps_Wps, dreg, sreg) | |
| 4960 | #define emit_divps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_DIVPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4961 | #define emit_divps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_DIVPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 4962 | #define emit_divps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_DIVPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4963 | #define emit_divps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_DIVPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 4964 | ||
| 4965 | #define emit_rcpps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_RCPPS_Vps_Wps, dreg, sreg) | |
| 4966 | #define emit_rcpps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_RCPPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4967 | #define emit_rcpps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_RCPPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 4968 | #define emit_rcpps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_RCPPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4969 | #define emit_rcpps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_RCPPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 4970 | ||
| 4971 | #define emit_sqrtps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SQRTPS_Vps_Wps, dreg, sreg) | |
| 4972 | #define emit_sqrtps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SQRTPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4973 | #define emit_sqrtps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SQRTPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 4974 | #define emit_sqrtps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SQRTPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4975 | #define emit_sqrtps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_SQRTPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 4976 | ||
| 4977 | #define emit_rsqrtps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_RSQRTPS_Vps_Wps, dreg, sreg) | |
| 4978 | #define emit_rsqrtps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_RSQRTPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4979 | #define emit_rsqrtps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_RSQRTPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 4980 | #define emit_rsqrtps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_RSQRTPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4981 | #define emit_rsqrtps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_RSQRTPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 4982 | ||
| 4983 | #define emit_andps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ANDPS_Vps_Wps, dreg, sreg) | |
| 4984 | #define emit_andps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ANDPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4985 | #define emit_andps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ANDPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 4986 | #define emit_andps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4987 | #define emit_andps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 4988 | ||
| 4989 | #define emit_andnps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ANDNPS_Vps_Wps, dreg, sreg) | |
| 4990 | #define emit_andnps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ANDNPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4991 | #define emit_andnps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ANDNPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 4992 | #define emit_andnps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDNPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4993 | #define emit_andnps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDNPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 4994 | ||
| 4995 | #define emit_orps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ORPS_Vps_Wps, dreg, sreg) | |
| 4996 | #define emit_orps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ORPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4997 | #define emit_orps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ORPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 4998 | #define emit_orps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ORPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 4999 | #define emit_orps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_ORPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 5000 | ||
| 5001 | #define emit_xorps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_XORPS_Vps_Wps, dreg, sreg) | |
| 5002 | #define emit_xorps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_XORPS_Vps_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5003 | #define emit_xorps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_XORPS_Vps_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 5004 | #define emit_xorps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_XORPS_Vps_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5005 | #define emit_xorps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_XORPS_Vps_Wps, dreg, (base), (index), (scale), (disp)) | |
| 5006 | ||
| 5007 | #define emit_cvtdq2ps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTDQ2PS_Vps_Wdq, dreg, sreg) | |
| 5008 | #define emit_cvtdq2ps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTDQ2PS_Vps_Wdq, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5009 | #define emit_cvtdq2ps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTDQ2PS_Vps_Wdq, dreg, (base), REG_NONE, 1, (disp)) | |
| 5010 | #define emit_cvtdq2ps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTDQ2PS_Vps_Wdq, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5011 | #define emit_cvtdq2ps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTDQ2PS_Vps_Wdq, dreg, (base), (index), (scale), (disp)) | |
| 5012 | ||
| 5013 | #define emit_cvtpd2ps_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTPD2PS_Vps_Wpd, dreg, sreg) | |
| 5014 | #define emit_cvtpd2ps_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTPD2PS_Vps_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5015 | #define emit_cvtpd2ps_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTPD2PS_Vps_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5016 | #define emit_cvtpd2ps_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPD2PS_Vps_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5017 | #define emit_cvtpd2ps_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPD2PS_Vps_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 5018 | ||
| 5019 | #define emit_cvtps2dq_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTPS2DQ_Vdq_Wps, dreg, sreg) | |
| 5020 | #define emit_cvtps2dq_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTPS2DQ_Vdq_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5021 | #define emit_cvtps2dq_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTPS2DQ_Vdq_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 5022 | #define emit_cvtps2dq_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPS2DQ_Vdq_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5023 | #define emit_cvtps2dq_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPS2DQ_Vdq_Wps, dreg, (base), (index), (scale), (disp)) | |
| 5024 | ||
| 5025 | #define emit_cvttps2dq_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTTPS2DQ_Vdq_Wps, dreg, sreg) | |
| 5026 | #define emit_cvttps2dq_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTTPS2DQ_Vdq_Wps, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5027 | #define emit_cvttps2dq_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTTPS2DQ_Vdq_Wps, dreg, (base), REG_NONE, 1, (disp)) | |
| 5028 | #define emit_cvttps2dq_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTTPS2DQ_Vdq_Wps, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5029 | #define emit_cvttps2dq_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTTPS2DQ_Vdq_Wps, dreg, (base), (index), (scale), (disp)) | |
| 5030 | ||
| 5031 | ||
| 5032 | ||
| 5033 | /*************************************************************************** | |
| 5034 | SSE SCALAR DOUBLE EMITTERS | |
| 5035 | ***************************************************************************/ | |
| 5036 | ||
| 5037 | #define emit_movsd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MOVSD_Vsd_Wsd, dreg, sreg) | |
| 5038 | #define emit_movsd_r128_m64abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MOVSD_Vsd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5039 | #define emit_movsd_r128_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MOVSD_Vsd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5040 | #define emit_movsd_r128_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MOVSD_Vsd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5041 | #define emit_movsd_r128_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_MOVSD_Vsd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5042 | ||
| 5043 | #define emit_movsd_m64abs_r128(e, addr, sreg) emit_sse_r128_mbisd(e, OP_MOVSD_Wsd_Vsd, sreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5044 | #define emit_movsd_m64bd_r128(e, base, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVSD_Wsd_Vsd, sreg, (base), REG_NONE, 1, (disp)) | |
| 5045 | #define emit_movsd_m64isd_r128(e, index, scale, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVSD_Wsd_Vsd, sreg, REG_NONE, (index), (scale), (disp)) | |
| 5046 | #define emit_movsd_m64bisd_r128(e, base, index, scale, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVSD_Wsd_Vsd, sreg, (base), (index), (scale), (disp)) | |
| 5047 | ||
| 5048 | #define emit_addsd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ADDSD_Vsd_Wsd, dreg, sreg) | |
| 5049 | #define emit_addsd_r128_m64abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ADDSD_Vsd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5050 | #define emit_addsd_r128_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ADDSD_Vsd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5051 | #define emit_addsd_r128_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ADDSD_Vsd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5052 | #define emit_addsd_r128_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_ADDSD_Vsd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5053 | ||
| 5054 | #define emit_subsd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SUBSD_Vsd_Wsd, dreg, sreg) | |
| 5055 | #define emit_subsd_r128_m64abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SUBSD_Vsd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5056 | #define emit_subsd_r128_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SUBSD_Vsd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5057 | #define emit_subsd_r128_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SUBSD_Vsd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5058 | #define emit_subsd_r128_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_SUBSD_Vsd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5059 | ||
| 5060 | #define emit_mulsd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MULSD_Vsd_Wsd, dreg, sreg) | |
| 5061 | #define emit_mulsd_r128_m64abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MULSD_Vsd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5062 | #define emit_mulsd_r128_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MULSD_Vsd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5063 | #define emit_mulsd_r128_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MULSD_Vsd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5064 | #define emit_mulsd_r128_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_MULSD_Vsd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5065 | ||
| 5066 | #define emit_divsd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_DIVSD_Vsd_Wsd, dreg, sreg) | |
| 5067 | #define emit_divsd_r128_m64abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_DIVSD_Vsd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5068 | #define emit_divsd_r128_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_DIVSD_Vsd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5069 | #define emit_divsd_r128_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_DIVSD_Vsd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5070 | #define emit_divsd_r128_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_DIVSD_Vsd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5071 | ||
| 5072 | #define emit_sqrtsd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SQRTSD_Vsd_Wsd, dreg, sreg) | |
| 5073 | #define emit_sqrtsd_r128_m64abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SQRTSD_Vsd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5074 | #define emit_sqrtsd_r128_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SQRTSD_Vsd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5075 | #define emit_sqrtsd_r128_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SQRTSD_Vsd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5076 | #define emit_sqrtsd_r128_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_SQRTSD_Vsd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5077 | ||
| 5078 | #define emit_comisd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_COMISD_Vsd_Wsd, dreg, sreg) | |
| 5079 | #define emit_comisd_r128_m64abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_COMISD_Vsd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5080 | #define emit_comisd_r128_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_COMISD_Vsd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5081 | #define emit_comisd_r128_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_COMISD_Vsd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5082 | #define emit_comisd_r128_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_COMISD_Vsd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5083 | ||
| 5084 | #define emit_ucomisd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_UCOMISD_Vsd_Wsd, dreg, sreg) | |
| 5085 | #define emit_ucomisd_r128_m64abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_UCOMISD_Vsd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5086 | #define emit_ucomisd_r128_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_UCOMISD_Vsd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5087 | #define emit_ucomisd_r128_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_UCOMISD_Vsd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5088 | #define emit_ucomisd_r128_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_UCOMISD_Vsd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5089 | ||
| 5090 | #define emit_cvtsi2sd_r128_r32(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTSI2SD_Vsd_Ed, dreg, sreg) | |
| 5091 | #define emit_cvtsi2sd_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTSI2SD_Vsd_Ed, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5092 | #define emit_cvtsi2sd_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTSI2SD_Vsd_Ed, dreg, (base), REG_NONE, 1, (disp)) | |
| 5093 | #define emit_cvtsi2sd_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSI2SD_Vsd_Ed, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5094 | #define emit_cvtsi2sd_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSI2SD_Vsd_Ed, dreg, (base), (index), (scale), (disp)) | |
| 5095 | ||
| 5096 | #ifdef PTR64 | |
| 5097 | #define emit_cvtsi2sd_r128_r64(e, dreg, sreg) emit_sse_r128_r128_rex(e, OP_CVTSI2SD_Vsd_Ed, dreg, sreg) | |
| 5098 | #define emit_cvtsi2sd_r128_m64abs(e, dreg, addr) emit_sse_r128_mbisd_rex(e, OP_CVTSI2SD_Vsd_Ed, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5099 | #define emit_cvtsi2sd_r128_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSI2SD_Vsd_Ed, dreg, (base), REG_NONE, 1, (disp)) | |
| 5100 | #define emit_cvtsi2sd_r128_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSI2SD_Vsd_Ed, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5101 | #define emit_cvtsi2sd_r128_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSI2SD_Vsd_Ed, dreg, (base), (index), (scale), (disp)) | |
| 5102 | #endif | |
| 5103 | ||
| 5104 | #define emit_cvtss2sd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTSS2SD_Vsd_Wss, dreg, sreg) | |
| 5105 | #define emit_cvtss2sd_r128_m32abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTSS2SD_Vsd_Wss, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5106 | #define emit_cvtss2sd_r128_m32bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTSS2SD_Vsd_Wss, dreg, (base), REG_NONE, 1, (disp)) | |
| 5107 | #define emit_cvtss2sd_r128_m32isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSS2SD_Vsd_Wss, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5108 | #define emit_cvtss2sd_r128_m32bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSS2SD_Vsd_Wss, dreg, (base), (index), (scale), (disp)) | |
| 5109 | ||
| 5110 | #define emit_cvtsd2si_r32_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTSD2SI_Gd_Wsd, dreg, sreg) | |
| 5111 | #define emit_cvtsd2si_r32_m64abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTSD2SI_Gd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5112 | #define emit_cvtsd2si_r32_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTSD2SI_Gd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5113 | #define emit_cvtsd2si_r32_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSD2SI_Gd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5114 | #define emit_cvtsd2si_r32_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTSD2SI_Gd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5115 | ||
| 5116 | #ifdef PTR64 | |
| 5117 | #define emit_cvtsd2si_r64_r128(e, dreg, sreg) emit_sse_r128_r128_rex(e, OP_CVTSD2SI_Gd_Wsd, dreg, sreg) | |
| 5118 | #define emit_cvtsd2si_r64_m64abs(e, dreg, addr) emit_sse_r128_mbisd_rex(e, OP_CVTSD2SI_Gd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5119 | #define emit_cvtsd2si_r64_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSD2SI_Gd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5120 | #define emit_cvtsd2si_r64_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSD2SI_Gd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5121 | #define emit_cvtsd2si_r64_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTSD2SI_Gd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5122 | #endif | |
| 5123 | ||
| 5124 | #define emit_cvttsd2si_r32_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTTSD2SI_Gd_Wsd, dreg, sreg) | |
| 5125 | #define emit_cvttsd2si_r32_m64abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTTSD2SI_Gd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5126 | #define emit_cvttsd2si_r32_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTTSD2SI_Gd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5127 | #define emit_cvttsd2si_r32_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTTSD2SI_Gd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5128 | #define emit_cvttsd2si_r32_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTTSD2SI_Gd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5129 | ||
| 5130 | #ifdef PTR64 | |
| 5131 | #define emit_cvttsd2si_r64_r128(e, dreg, sreg) emit_sse_r128_r128_rex(e, OP_CVTTSD2SI_Gd_Wsd, dreg, sreg) | |
| 5132 | #define emit_cvttsd2si_r64_m64abs(e, dreg, addr) emit_sse_r128_mbisd_rex(e, OP_CVTTSD2SI_Gd_Wsd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5133 | #define emit_cvttsd2si_r64_m64bd(e, dreg, base, disp) emit_sse_r128_mbisd_rex(e, OP_CVTTSD2SI_Gd_Wsd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5134 | #define emit_cvttsd2si_r64_m64isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTTSD2SI_Gd_Wsd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5135 | #define emit_cvttsd2si_r64_m64bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd_rex(e, OP_CVTTSD2SI_Gd_Wsd, dreg, (base), (index), (scale), (disp)) | |
| 5136 | #endif | |
| 5137 | ||
| 5138 | ||
| 5139 | ||
| 5140 | /*************************************************************************** | |
| 5141 | SSE PACKED DOUBLE EMITTERS | |
| 5142 | ***************************************************************************/ | |
| 5143 | ||
| 5144 | #define emit_movpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MOVPD_Vpd_Wpd, dreg, sreg) | |
| 5145 | #define emit_movpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MOVPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5146 | #define emit_movpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MOVPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5147 | #define emit_movpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MOVPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5148 | ||
| 5149 | #define emit_movpd_m128abs_r128(e, addr, sreg) emit_sse_r128_mbisd(e, OP_MOVPD_Wpd_Vpd, sreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5150 | #define emit_movpd_m128bd_r128(e, base, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVPD_Wpd_Vpd, sreg, (base), REG_NONE, 1, (disp)) | |
| 5151 | #define emit_movpd_m128isd_r128(e, index, scale, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVPD_Wpd_Vpd, sreg, REG_NONE, (index), (scale), (disp)) | |
| 5152 | ||
| 5153 | #define emit_addpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ADDPD_Vpd_Wpd, dreg, sreg) | |
| 5154 | #define emit_addpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ADDPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5155 | #define emit_addpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ADDPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5156 | #define emit_addpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ADDPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5157 | ||
| 5158 | #define emit_subpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SUBPD_Vpd_Wpd, dreg, sreg) | |
| 5159 | #define emit_subpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SUBPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5160 | #define emit_subpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SUBPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5161 | #define emit_subpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SUBPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5162 | ||
| 5163 | #define emit_mulpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MULPD_Vpd_Wpd, dreg, sreg) | |
| 5164 | #define emit_mulpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MULPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5165 | #define emit_mulpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MULPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5166 | #define emit_mulpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MULPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5167 | ||
| 5168 | #define emit_divpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_DIVPD_Vpd_Wpd, dreg, sreg) | |
| 5169 | #define emit_divpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_DIVPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5170 | #define emit_divpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_DIVPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5171 | #define emit_divpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_DIVPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5172 | ||
| 5173 | #define emit_sqrtpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SQRTPD_Vpd_Wpd, dreg, sreg) | |
| 5174 | #define emit_sqrtpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SQRTPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5175 | #define emit_sqrtpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SQRTPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5176 | #define emit_sqrtpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SQRTPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5177 | ||
| 5178 | #define emit_andpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ANDPD_Vpd_Wpd, dreg, sreg) | |
| 5179 | #define emit_andpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ANDPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5180 | #define emit_andpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ANDPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5181 | #define emit_andpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5182 | ||
| 5183 | #define emit_andnpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ANDNPD_Vpd_Wpd, dreg, sreg) | |
| 5184 | #define emit_andnpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ANDNPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5185 | #define emit_andnpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ANDNPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5186 | #define emit_andnpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDNPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5187 | ||
| 5188 | #define emit_orpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ORPD_Vpd_Wpd, dreg, sreg) | |
| 5189 | #define emit_orpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ORPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5190 | #define emit_orpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ORPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5191 | #define emit_orpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ORPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5192 | ||
| 5193 | #define emit_xorpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_XORPD_Vpd_Wpd, dreg, sreg) | |
| 5194 | #define emit_xorpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_XORPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5195 | #define emit_xorpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_XORPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5196 | #define emit_xorpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_XORPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5197 | ||
| 5198 | #define emit_cvtdq2pd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTDQ2PD_Vpd_Wq, dreg, sreg) | |
| 5199 | #define emit_cvtdq2pd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTDQ2PD_Vpd_Wq, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5200 | #define emit_cvtdq2pd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTDQ2PD_Vpd_Wq, dreg, (base), REG_NONE, 1, (disp)) | |
| 5201 | #define emit_cvtdq2pd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTDQ2PD_Vpd_Wq, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5202 | ||
| 5203 | #define emit_cvtps2pd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTPS2PD_Vpd_Wq, dreg, sreg) | |
| 5204 | #define emit_cvtps2pd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTPS2PD_Vpd_Wq, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5205 | #define emit_cvtps2pd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTPS2PD_Vpd_Wq, dreg, (base), REG_NONE, 1, (disp)) | |
| 5206 | #define emit_cvtps2pd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPS2PD_Vpd_Wq, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5207 | ||
| 5208 | #define emit_cvtpd2dq_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, sreg) | |
| 5209 | #define emit_cvtpd2dq_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5210 | #define emit_cvtpd2dq_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5211 | #define emit_cvtpd2dq_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5212 | ||
| 5213 | #define emit_cvttpd2dq_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, sreg) | |
| 5214 | #define emit_cvttpd2dq_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 5215 | #define emit_cvttpd2dq_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 5216 | #define emit_cvttpd2dq_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 5217 | /*************************************************************************** | |
| 5218 | ||
| 5219 | x86emit.h | |
| 5220 | ||
| 5221 | Generic x86/x64 code emitters. | |
| 5222 | ||
| 5223 | Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team. | |
| 5224 | Visit http://mamedev.org for licensing and usage restrictions. | |
| 5225 | ||
| 5226 | **************************************************************************** | |
| 5227 | ||
| 5228 | Important note: | |
| 5229 | ||
| 5230 | It is assumed in 64-bit mode that all byte register accesses are | |
| 5231 | intended to be to the low 8 bits (SPL,BPL,SIL,DIL) and not to the | |
| 5232 | upper half (AH,CH,DH,BH). | |
| 5233 | ||
| 5234 | ***************************************************************************/ | |
| 5235 | ||
| 5236 | ||
| 5237 | /*************************************************************************** | |
| 5238 | CONSTANTS | |
| 5239 | ***************************************************************************/ | |
| 5240 | ||
| 5241 | /* 32-bit versus 64-bit opcode flag */ | |
| 5242 | #define OP_32BIT 0 | |
| 5243 | #define OP_64BIT 8 | |
| 5244 | ||
| 5245 | ||
| 5246 | /* 16 registers on x64, only 8 on x86 */ | |
| 5247 | #ifdef PTR64 | |
| 5248 | #define REG_MAX 16 | |
| 5249 | #else | |
| 5250 | #define REG_MAX 8 | |
| 5251 | #endif | |
| 5252 | ||
| 5253 | ||
| 5254 | /* invalid register index for "none" */ | |
| 5255 | #define REG_NONE REG_MAX | |
| 5256 | ||
| 5257 | ||
| 5258 | /* 64-bit registers */ | |
| 5259 | #ifdef PTR64 | |
| 5260 | #define REG_RAX 0 | |
| 5261 | #define REG_RCX 1 | |
| 5262 | #define REG_RDX 2 | |
| 5263 | #define REG_RBX 3 | |
| 5264 | #define REG_RSP 4 | |
| 5265 | #define REG_RBP 5 | |
| 5266 | #define REG_RSI 6 | |
| 5267 | #define REG_RDI 7 | |
| 5268 | #define REG_R8 8 | |
| 5269 | #define REG_R9 9 | |
| 5270 | #define REG_R10 10 | |
| 5271 | #define REG_R11 11 | |
| 5272 | #define REG_R12 12 | |
| 5273 | #define REG_R13 13 | |
| 5274 | #define REG_R14 14 | |
| 5275 | #define REG_R15 15 | |
| 5276 | #endif | |
| 5277 | ||
| 5278 | /* 32-bit registers */ | |
| 5279 | #define REG_EAX 0 | |
| 5280 | #define REG_ECX 1 | |
| 5281 | #define REG_EDX 2 | |
| 5282 | #define REG_EBX 3 | |
| 5283 | #define REG_ESP 4 | |
| 5284 | #define REG_EBP 5 | |
| 5285 | #define REG_ESI 6 | |
| 5286 | #define REG_EDI 7 | |
| 5287 | #ifdef PTR64 | |
| 5288 | #define REG_R8D 8 | |
| 5289 | #define REG_R9D 9 | |
| 5290 | #define REG_R10D 10 | |
| 5291 | #define REG_R11D 11 | |
| 5292 | #define REG_R12D 12 | |
| 5293 | #define REG_R13D 13 | |
| 5294 | #define REG_R14D 14 | |
| 5295 | #define REG_R15D 15 | |
| 5296 | #endif | |
| 5297 | ||
| 5298 | /* 16-bit registers */ | |
| 5299 | #define REG_AX 0 | |
| 5300 | #define REG_CX 1 | |
| 5301 | #define REG_DX 2 | |
| 5302 | #define REG_BX 3 | |
| 5303 | #define REG_SP 4 | |
| 5304 | #define REG_BP 5 | |
| 5305 | #define REG_SI 6 | |
| 5306 | #define REG_DI 7 | |
| 5307 | #ifdef PTR64 | |
| 5308 | #define REG_R8W 8 | |
| 5309 | #define REG_R9W 9 | |
| 5310 | #define REG_R10W 10 | |
| 5311 | #define REG_R11W 11 | |
| 5312 | #define REG_R12W 12 | |
| 5313 | #define REG_R13W 13 | |
| 5314 | #define REG_R14W 14 | |
| 5315 | #define REG_R15W 15 | |
| 5316 | #endif | |
| 5317 | ||
| 5318 | /* 8-bit registers */ | |
| 5319 | #define REG_AL 0 | |
| 5320 | #define REG_CL 1 | |
| 5321 | #define REG_DL 2 | |
| 5322 | #define REG_BL 3 | |
| 5323 | #ifndef PTR64 | |
| 5324 | #define REG_AH 4 | |
| 5325 | #define REG_CH 5 | |
| 5326 | #define REG_DH 6 | |
| 5327 | #define REG_BH 7 | |
| 5328 | #else | |
| 5329 | #define REG_SPL 4 | |
| 5330 | #define REG_BPL 5 | |
| 5331 | #define REG_SIL 6 | |
| 5332 | #define REG_DIL 7 | |
| 5333 | #define REG_R8L 8 | |
| 5334 | #define REG_R9L 9 | |
| 5335 | #define REG_R10L 10 | |
| 5336 | #define REG_R11L 11 | |
| 5337 | #define REG_R12L 12 | |
| 5338 | #define REG_R13L 13 | |
| 5339 | #define REG_R14L 14 | |
| 5340 | #define REG_R15L 15 | |
| 5341 | #endif | |
| 5342 | ||
| 5343 | /* 64-bit MMX registers */ | |
| 5344 | #define REG_MM0 0 | |
| 5345 | #define REG_MM1 1 | |
| 5346 | #define REG_MM2 2 | |
| 5347 | #define REG_MM3 3 | |
| 5348 | #define REG_MM4 4 | |
| 5349 | #define REG_MM5 5 | |
| 5350 | #define REG_MM6 6 | |
| 5351 | #define REG_MM7 7 | |
| 5352 | #ifdef PTR64 | |
| 5353 | #define REG_MM8 8 | |
| 5354 | #define REG_MM9 9 | |
| 5355 | #define REG_MM10 10 | |
| 5356 | #define REG_MM11 11 | |
| 5357 | #define REG_MM12 12 | |
| 5358 | #define REG_MM13 13 | |
| 5359 | #define REG_MM14 14 | |
| 5360 | #define REG_MM15 15 | |
| 5361 | #endif | |
| 5362 | ||
| 5363 | /* 128-bit XMM registers */ | |
| 5364 | #define REG_XMM0 0 | |
| 5365 | #define REG_XMM1 1 | |
| 5366 | #define REG_XMM2 2 | |
| 5367 | #define REG_XMM3 3 | |
| 5368 | #define REG_XMM4 4 | |
| 5369 | #define REG_XMM5 5 | |
| 5370 | #define REG_XMM6 6 | |
| 5371 | #define REG_XMM7 7 | |
| 5372 | #ifdef PTR64 | |
| 5373 | #define REG_XMM8 8 | |
| 5374 | #define REG_XMM9 9 | |
| 5375 | #define REG_XMM10 10 | |
| 5376 | #define REG_XMM11 11 | |
| 5377 | #define REG_XMM12 12 | |
| 5378 | #define REG_XMM13 13 | |
| 5379 | #define REG_XMM14 14 | |
| 5380 | #define REG_XMM15 15 | |
| 5381 | #endif | |
| 5382 | ||
| 5383 | ||
| 5384 | /* conditions */ | |
| 5385 | #define COND_A 7 | |
| 5386 | #define COND_AE 3 | |
| 5387 | #define COND_B 2 | |
| 5388 | #define COND_BE 6 | |
| 5389 | #define COND_C 2 | |
| 5390 | #define COND_E 4 | |
| 5391 | #define COND_Z 4 | |
| 5392 | #define COND_G 15 | |
| 5393 | #define COND_GE 13 | |
| 5394 | #define COND_L 12 | |
| 5395 | #define COND_LE 14 | |
| 5396 | #define COND_NA 6 | |
| 5397 | #define COND_NAE 2 | |
| 5398 | #define COND_NB 3 | |
| 5399 | #define COND_NBE 7 | |
| 5400 | #define COND_NC 3 | |
| 5401 | #define COND_NE 5 | |
| 5402 | #define COND_NG 14 | |
| 5403 | #define COND_NGE 12 | |
| 5404 | #define COND_NL 13 | |
| 5405 | #define COND_NLE 15 | |
| 5406 | #define COND_NO 1 | |
| 5407 | #define COND_NP 11 | |
| 5408 | #define COND_NS 9 | |
| 5409 | #define COND_NZ 5 | |
| 5410 | #define COND_O 0 | |
| 5411 | #define COND_P 10 | |
| 5412 | #define COND_PE 10 | |
| 5413 | #define COND_PO 11 | |
| 5414 | #define COND_S 8 | |
| 5415 | #define COND_Z 4 | |
| 5416 | ||
| 5417 | ||
| 5418 | /* floating point rounding modes */ | |
| 203 | 5419 | #define FPRND_NEAR 0 |
| 204 | 5420 | #define FPRND_DOWN 1 |
| 205 | 5421 | #define FPRND_UP 2 |
| r936 | r937 | |
| 4592 | 9808 | SSE PACKED DOUBLE EMITTERS |
| 4593 | 9809 | ***************************************************************************/ |
| 4594 | 9810 | |
| 4595 | #define emit_movpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MOVPD_Vpd_Wpd, dreg, sreg) | |
| 4596 | #define emit_movpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MOVPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4597 | #define emit_movpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MOVPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4598 | #define emit_movpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MOVPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9811 | #define emit_movpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MOVPD_Vpd_Wpd, dreg, sreg) | |
| 9812 | #define emit_movpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MOVPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9813 | #define emit_movpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MOVPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9814 | #define emit_movpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MOVPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9815 | #define emit_movpd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_MOVPD_Vpd_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 4599 | 9816 | |
| 4600 | #define emit_movpd_m128abs_r128(e, addr, sreg) emit_sse_r128_mbisd(e, OP_MOVPD_Wpd_Vpd, sreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4601 | #define emit_movpd_m128bd_r128(e, base, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVPD_Wpd_Vpd, sreg, (base), REG_NONE, 1, (disp)) | |
| 4602 | #define emit_movpd_m128isd_r128(e, index, scale, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVPD_Wpd_Vpd, sreg, REG_NONE, (index), (scale), (disp)) | |
| 9817 | #define emit_movpd_m128abs_r128(e, addr, sreg) emit_sse_r128_mbisd(e, OP_MOVPD_Wpd_Vpd, sreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9818 | #define emit_movpd_m128bd_r128(e, base, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVPD_Wpd_Vpd, sreg, (base), REG_NONE, 1, (disp)) | |
| 9819 | #define emit_movpd_m128isd_r128(e, index, scale, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVPD_Wpd_Vpd, sreg, REG_NONE, (index), (scale), (disp)) | |
| 9820 | #define emit_movpd_m128bisd_r128(e, base, index, scale, disp, sreg) emit_sse_r128_mbisd(e, OP_MOVPD_Wpd_Vpd, sreg, (base), (index), (scale), (disp)) | |
| 4603 | 9821 | |
| 4604 | #define emit_addpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ADDPD_Vpd_Wpd, dreg, sreg) | |
| 4605 | #define emit_addpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ADDPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4606 | #define emit_addpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ADDPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4607 | #define emit_addpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ADDPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9822 | #define emit_addpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ADDPD_Vpd_Wpd, dreg, sreg) | |
| 9823 | #define emit_addpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ADDPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9824 | #define emit_addpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ADDPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9825 | #define emit_addpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ADDPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9826 | #define emit_addpd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_ADDPD_Vpd_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 4608 | 9827 | |
| 4609 | #define emit_subpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SUBPD_Vpd_Wpd, dreg, sreg) | |
| 4610 | #define emit_subpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SUBPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4611 | #define emit_subpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SUBPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4612 | #define emit_subpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SUBPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9828 | #define emit_subpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SUBPD_Vpd_Wpd, dreg, sreg) | |
| 9829 | #define emit_subpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SUBPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9830 | #define emit_subpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SUBPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9831 | #define emit_subpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SUBPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9832 | #define emit_subpd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_SUBPD_Vpd_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 4613 | 9833 | |
| 4614 | #define emit_mulpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MULPD_Vpd_Wpd, dreg, sreg) | |
| 4615 | #define emit_mulpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MULPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4616 | #define emit_mulpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MULPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4617 | #define emit_mulpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MULPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9834 | #define emit_mulpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_MULPD_Vpd_Wpd, dreg, sreg) | |
| 9835 | #define emit_mulpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_MULPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9836 | #define emit_mulpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_MULPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9837 | #define emit_mulpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_MULPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9838 | #define emit_mulpd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_MULPD_Vpd_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 4618 | 9839 | |
| 4619 | #define emit_divpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_DIVPD_Vpd_Wpd, dreg, sreg) | |
| 4620 | #define emit_divpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_DIVPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4621 | #define emit_divpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_DIVPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4622 | #define emit_divpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_DIVPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9840 | #define emit_divpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_DIVPD_Vpd_Wpd, dreg, sreg) | |
| 9841 | #define emit_divpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_DIVPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9842 | #define emit_divpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_DIVPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9843 | #define emit_divpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_DIVPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9844 | #define emit_divpd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_DIVPD_Vpd_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 4623 | 9845 | |
| 4624 | #define emit_sqrtpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SQRTPD_Vpd_Wpd, dreg, sreg) | |
| 4625 | #define emit_sqrtpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SQRTPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4626 | #define emit_sqrtpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SQRTPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4627 | #define emit_sqrtpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SQRTPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9846 | #define emit_sqrtpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_SQRTPD_Vpd_Wpd, dreg, sreg) | |
| 9847 | #define emit_sqrtpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_SQRTPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9848 | #define emit_sqrtpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_SQRTPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9849 | #define emit_sqrtpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_SQRTPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9850 | #define emit_sqrtpd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_SQRTPD_Vpd_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 4628 | 9851 | |
| 4629 | #define emit_andpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ANDPD_Vpd_Wpd, dreg, sreg) | |
| 4630 | #define emit_andpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ANDPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4631 | #define emit_andpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ANDPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4632 | #define emit_andpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9852 | #define emit_andpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ANDPD_Vpd_Wpd, dreg, sreg) | |
| 9853 | #define emit_andpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ANDPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9854 | #define emit_andpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ANDPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9855 | #define emit_andpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9856 | #define emit_andpd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDPD_Vpd_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 4633 | 9857 | |
| 4634 | #define emit_andnpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ANDNPD_Vpd_Wpd, dreg, sreg) | |
| 4635 | #define emit_andnpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ANDNPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4636 | #define emit_andnpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ANDNPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4637 | #define emit_andnpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDNPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9858 | #define emit_andnpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ANDNPD_Vpd_Wpd, dreg, sreg) | |
| 9859 | #define emit_andnpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ANDNPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9860 | #define emit_andnpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ANDNPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9861 | #define emit_andnpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDNPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9862 | #define emit_andnpd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_ANDNPD_Vpd_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 4638 | 9863 | |
| 4639 | #define emit_orpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ORPD_Vpd_Wpd, dreg, sreg) | |
| 4640 | #define emit_orpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ORPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4641 | #define emit_orpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ORPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4642 | #define emit_orpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ORPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9864 | #define emit_orpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_ORPD_Vpd_Wpd, dreg, sreg) | |
| 9865 | #define emit_orpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_ORPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9866 | #define emit_orpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_ORPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9867 | #define emit_orpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_ORPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9868 | #define emit_orpd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_ORPD_Vpd_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 4643 | 9869 | |
| 4644 | #define emit_xorpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_XORPD_Vpd_Wpd, dreg, sreg) | |
| 4645 | #define emit_xorpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_XORPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4646 | #define emit_xorpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_XORPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4647 | #define emit_xorpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_XORPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9870 | #define emit_xorpd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_XORPD_Vpd_Wpd, dreg, sreg) | |
| 9871 | #define emit_xorpd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_XORPD_Vpd_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9872 | #define emit_xorpd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_XORPD_Vpd_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9873 | #define emit_xorpd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_XORPD_Vpd_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9874 | #define emit_xorpd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_XORPD_Vpd_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 4648 | 9875 | |
| 4649 | #define emit_cvtdq2pd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTDQ2PD_Vpd_Wq, dreg, sreg) | |
| 4650 | #define emit_cvtdq2pd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTDQ2PD_Vpd_Wq, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4651 | #define emit_cvtdq2pd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTDQ2PD_Vpd_Wq, dreg, (base), REG_NONE, 1, (disp)) | |
| 4652 | #define emit_cvtdq2pd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTDQ2PD_Vpd_Wq, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9876 | #define emit_cvtdq2pd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTDQ2PD_Vpd_Wq, dreg, sreg) | |
| 9877 | #define emit_cvtdq2pd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTDQ2PD_Vpd_Wq, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9878 | #define emit_cvtdq2pd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTDQ2PD_Vpd_Wq, dreg, (base), REG_NONE, 1, (disp)) | |
| 9879 | #define emit_cvtdq2pd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTDQ2PD_Vpd_Wq, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9880 | #define emit_cvtdq2pd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTDQ2PD_Vpd_Wq, dreg, (base), (index), (scale), (disp)) | |
| 4653 | 9881 | |
| 4654 | #define emit_cvtps2pd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTPS2PD_Vpd_Wq, dreg, sreg) | |
| 4655 | #define emit_cvtps2pd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTPS2PD_Vpd_Wq, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4656 | #define emit_cvtps2pd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTPS2PD_Vpd_Wq, dreg, (base), REG_NONE, 1, (disp)) | |
| 4657 | #define emit_cvtps2pd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPS2PD_Vpd_Wq, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9882 | #define emit_cvtps2pd_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTPS2PD_Vpd_Wq, dreg, sreg) | |
| 9883 | #define emit_cvtps2pd_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTPS2PD_Vpd_Wq, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9884 | #define emit_cvtps2pd_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTPS2PD_Vpd_Wq, dreg, (base), REG_NONE, 1, (disp)) | |
| 9885 | #define emit_cvtps2pd_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPS2PD_Vpd_Wq, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9886 | #define emit_cvtps2pd_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPS2PD_Vpd_Wq, dreg, (base), (index), (scale), (disp)) | |
| 4658 | 9887 | |
| 4659 | #define emit_cvtpd2dq_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, sreg) | |
| 4660 | #define emit_cvtpd2dq_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4661 | #define emit_cvtpd2dq_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4662 | #define emit_cvtpd2dq_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9888 | #define emit_cvtpd2dq_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, sreg) | |
| 9889 | #define emit_cvtpd2dq_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9890 | #define emit_cvtpd2dq_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9891 | #define emit_cvtpd2dq_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9892 | #define emit_cvtpd2dq_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTPD2DQ_Vdq_Wpd, dreg, (base), (index), (scale), (disp)) | |
| 4663 | 9893 | |
| 4664 | #define emit_cvttpd2dq_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, sreg) | |
| 4665 | #define emit_cvttpd2dq_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 4666 | #define emit_cvttpd2dq_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 4667 | #define emit_cvttpd2dq_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9894 | #define emit_cvttpd2dq_r128_r128(e, dreg, sreg) emit_sse_r128_r128(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, sreg) | |
| 9895 | #define emit_cvttpd2dq_r128_m128abs(e, dreg, addr) emit_sse_r128_mbisd(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, REG_NONE, REG_NONE, 1, (INT32)(addr)) | |
| 9896 | #define emit_cvttpd2dq_r128_m128bd(e, dreg, base, disp) emit_sse_r128_mbisd(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, (base), REG_NONE, 1, (disp)) | |
| 9897 | #define emit_cvttpd2dq_r128_m128isd(e, dreg, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, REG_NONE, (index), (scale), (disp)) | |
| 9898 | #define emit_cvttpd2dq_r128_m128bisd(e, dreg, base, index, scale, disp) emit_sse_r128_mbisd(e, OP_CVTTPD2DQ_Vdq_Wpd, dreg, (base), (index), (scale), (disp)) |
| r936 | r937 | |
|---|---|---|
| 44 | 44 | return pBuf; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | static char *DasmCoProc_RT( char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0) | |
| 47 | static char *DasmCoProc_RT( char *pBuf, UINT32 opcode, const char *pConditionCode, const char *pBuf0) | |
| 48 | 48 | { |
| 49 | 49 | /* co processor register transfer */ |
| 50 | 50 | /* xxxx 1110 oooL nnnn dddd cccc ppp1 mmmm */ |
| r936 | r937 | |
| 64 | 64 | return pBuf; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | static char *DasmCoProc_DT( char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0 ) | |
| 67 | static char *DasmCoProc_DT( char *pBuf, UINT32 opcode, const char *pConditionCode, const char *pBuf0 ) | |
| 68 | 68 | { |
| 69 | 69 | /* co processor data transfer */ |
| 70 | 70 | /* xxxx 111P UNWL nnnn dddd pppp oooooooo */ |
| r936 | r937 | |
| 89 | 89 | return pBuf; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | static char *DasmCoProc_DO( char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0 ) | |
| 92 | static char *DasmCoProc_DO( char *pBuf, UINT32 opcode, const char *pConditionCode, const char *pBuf0 ) | |
| 93 | 93 | { |
| 94 | 94 | /* co processor data operation */ |
| 95 | 95 | /* xxxx 1110 oooo nnnn dddd cccc ppp0 mmmm */ |
| r936 | r937 | |
| 601 | 601 | if(arm7_dasm_cop_rt_callback) |
| 602 | 602 | arm7_dasm_cop_rt_callback(pBuf,opcode,(char*)pConditionCode,(char*)pBuf0); |
| 603 | 603 | else |
| 604 | DasmCoProc_RT(pBuf,opcode, | |
| 604 | DasmCoProc_RT(pBuf,opcode, | |
| 605 | 605 | } |
| 606 | 606 | //Data Op |
| 607 | 607 | else |
| r936 | r937 | |
| 609 | 609 | if(arm7_dasm_cop_do_callback) |
| 610 | 610 | arm7_dasm_cop_do_callback(pBuf,opcode,(char*)pConditionCode,(char*)pBuf0); |
| 611 | 611 | else |
| 612 | DasmCoProc_DO(pBuf,opcode, | |
| 612 | DasmCoProc_DO(pBuf,opcode, | |
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | else if( (opcode&0x0f000000) == 0x0f000000 ) //bits 27-24 == 1111 |
| r936 | r937 | |
|---|---|---|
| 7 | 7 | Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team. |
| 8 | 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | 9 | |
| 10 | **************************************************************************** | |
| 11 | ||
| 12 | ***** VERY IMPORTANT NOTICE ***** | |
| 13 | ||
| 14 | These functions and macros are provided to facilitate the mapping | |
| 15 | of devices on cpus with different data bus widths. | |
| 16 | Devices should be implemented using their native data bus width, | |
| 17 | since that ensures that read/write operations are kept atomic. | |
| 18 | If we discover you have abused the functionality presented in this | |
| 19 | file, you *will* be publicly humiliated and your code submission | |
| 20 | will probably not be accepted. Seriously, please do not abuse these | |
| 21 | functions/macros. | |
| 22 | ||
| 23 | **************************************************************************** | |
| 24 | ||
| 25 | Conversions supported: | |
| 26 | ||
| 27 | CW = CPU Data Bus Width in bits | |
| 28 | CBO = CPU Byte Order | |
| 29 | DW = Device Data Bus Width in bits | |
| 30 | DBO = Device Byte Order | |
| 31 | ||
| 32 | CW | CBO | DW | DBO | Functions to use | |
| 33 | ---+--------+----+--------+----------------------------------------------------------- | |
| 34 | 16 | Big | 8 | N/A | read16be_with_read8_handler,write16be_with_write8_handler | |
| 35 | 16 | Little | 8 | N/A | read16le_with_read8_handler,write16le_with_write8_handler | |
| 36 | ---+--------+----+--------+----------------------------------------------------------- | |
| 37 | 32 | Big | 8 | N/A | read32be_with_read8_handler,write32be_with_write8_handler | |
| 38 | 32 | Little | 8 | N/A | read32le_with_read8_handler,write32le_with_write8_handler | |
| 39 | 32 | Big | 16 | Big | read32be_with_16be_handler,write32be_with_16be_handler | |
| 40 | 32 | Little | 16 | Little | read32le_with_16le_handler,write32le_with_16le_handler | |
| 41 | 32 | Big | 16 | Little | read32be_with_16le_handler,write32be_with_16le_handler | |
| 42 | 32 | Little | 16 | Big | read32le_with_16be_handler,write32le_with_16be_handler | |
| 43 | ---+--------+----+--------+----------------------------------------------------------- | |
| 44 | 64 | Big | 8 | N/A | read64be_with_read8_handler,write64be_with_write8_handler | |
| 45 | 64 | Little | 8 | N/A | read64le_with_read8_handler,write64le_with_write8_handler | |
| 46 | 64 | Big | 16 | Big | read64be_with_16be_handler,write64be_with_16be_handler | |
| 47 | 64 | Little | 16 | Little | read64le_with_16le_handler,write64le_with_16le_handler | |
| 48 | 64 | Big | 16 | Little | read64be_with_16le_handler,write64be_with_16le_handler | |
| 49 | 64 | Little | 16 | Big | read64le_with_16be_handler,write64le_with_16be_handler | |
| 50 | 64 | Big | 32 | Big | read64be_with_32be_handler,write64be_with_32be_handler | |
| 51 | 64 | Little | 32 | Little | read64le_with_32le_handler,write64le_with_32le_handler | |
| 52 | 64 | Big | 32 | Little | read64be_with_32le_handler,write64be_with_32le_handler | |
| 53 | 64 | Little | 32 | Big | read64le_with_32be_handler,write64le_with_32be_handler | |
| 54 | ||
| 55 | You can also find at the bottom of this file a few convernient | |
| 56 | macros that will create the stub read and/or write handlers for | |
| 57 | the most common mappings, that will use the functions above. | |
| 58 | Here's an example on how to use them: Say you have a 8 bit device | |
| 59 | whose handlers are device8_r and device8_w, and you want to connect | |
| 60 | it to a 16 bit, big endian cpu. We'll say the device is mapped on | |
| 61 | the least significant byte of the data bus (LSB). | |
| 62 | ||
| 63 | In your driver, you would add: | |
| 64 | ||
| 65 | READWRITE8TO16BE_LSB( device16, device8_r, device8_w ) | |
| 66 | ||
| 67 | which will create two 16 bit memory handlers, one for read, called | |
| 68 | device16_r, and one for write, called device16_w, with the proper | |
| 69 | mapping. | |
| 70 | ||
| 71 | then in the MEMORY_MAP you would specify: | |
| 72 | ||
| 73 | AM_RANGE(0x000000, 0x0000ff) AM_READWRITE( device16_r, device16_w ) | |
| 74 | ||
| 75 | And that is all. Your device should be mapped properly. | |
| 76 | If you need to do custom mappings, or a mapping that is not currently | |
| 77 | supported in this file, you can always write the stub yourself, and | |
| 78 | call the above functions to invoke the base handlers. | |
| 79 | ||
| 10 | 80 | ***************************************************************************/ |
| 11 | 81 | |
| 82 | /************************************* | |
| 83 | * | |
| 84 | * 16-bit BE using 8-bit handlers | |
| 85 | * | |
| 86 | *************************************/ | |
| 12 | 87 | |
| 88 | INLINE UINT16 read16be_with_read8_handler(read8_handler handler, offs_t offset, UINT16 mem_mask) | |
| 89 | { | |
| 90 | UINT16 result = 0; | |
| 91 | if ((mem_mask & 0xff00) != 0xff00) | |
| 92 | result |= ((UINT16)(*handler)(offset * 2 + 0)) << 8; | |
| 93 | if ((mem_mask & 0x00ff) != 0x00ff) | |
| 94 | result |= ((UINT16)(*handler)(offset * 2 + 1)) << 0; | |
| 95 | return result; | |
| 96 | } | |
| 97 | ||
| 98 | ||
| 99 | INLINE void write16be_with_write8_handler(write8_handler handler, offs_t offset, UINT16 data, UINT16 mem_mask) | |
| 100 | { | |
| 101 | if ((mem_mask & 0xff00) != 0xff00) | |
| 102 | (*handler)(offset * 2 + 0, data >> 8); | |
| 103 | if ((mem_mask & 0x00ff) != 0x00ff) | |
| 104 | (*handler)(offset * 2 + 1, data >> 0); | |
| 105 | } | |
| 106 | ||
| 107 | ||
| 13 | 108 | /************************************* |
| 14 | 109 | * |
| 15 | 110 | * 16-bit LE using 8-bit handlers |
| r936 | r937 | |
| 20 | 115 | { |
| 21 | 116 | UINT16 result = 0; |
| 22 | 117 | if ((mem_mask & 0x00ff) != 0x00ff) |
| 23 | result |= ((UINT16) handler(offset * 2 + 0)) << 0; | |
| 118 | result |= ((UINT16) (*handler)(offset * 2 + 0)) << 0; | |
| 24 | 119 | if ((mem_mask & 0xff00) != 0xff00) |
| 25 | result |= ((UINT16) handler(offset * 2 + 1)) << 8; | |
| 120 | result |= ((UINT16) (*handler)(offset * 2 + 1)) << 8; | |
| 26 | 121 | return result; |
| 27 | 122 | } |
| 28 | 123 | |
| r936 | r937 | |
| 30 | 125 | INLINE void write16le_with_write8_handler(write8_handler handler, offs_t offset, UINT16 data, UINT16 mem_mask) |
| 31 | 126 | { |
| 32 | 127 | if ((mem_mask & 0x00ff) != 0x00ff) |
| 33 | handler(offset * 2 + 0, data >> 0); | |
| 128 | (*handler)(offset * 2 + 0, data >> 0); | |
| 34 | 129 | if ((mem_mask & 0xff00) != 0xff00) |
| 35 | handler(offset * 2 + 1, data >> 8); | |
| 130 | (*handler)(offset * 2 + 1, data >> 8); | |
| 36 | 131 | } |
| 37 | 132 | |
| 38 | 133 | |
| 134 | /************************************* | |
| 135 | * | |
| 136 | * 32-bit BE using 8-bit handlers | |
| 137 | * | |
| 138 | *************************************/ | |
| 39 | 139 | |
| 140 | INLINE UINT32 read32be_with_read8_handler(read8_handler handler, offs_t offset, UINT32 mem_mask) | |
| 141 | { | |
| 142 | UINT32 result = 0; | |
| 143 | if ((mem_mask & 0xffff0000) != 0xffff0000) | |
| 144 | result |= read16be_with_read8_handler(handler, offset * 2 + 0, mem_mask >> 16) << 16; | |
| 145 | if ((mem_mask & 0x0000ffff) != 0x0000ffff) | |
| 146 | result |= read16be_with_read8_handler(handler, offset * 2 + 1, mem_mask) << 0; | |
| 147 | return result; | |
| 148 | } | |
| 149 | ||
| 150 | ||
| 151 | INLINE void write32be_with_write8_handler(write8_handler handler, offs_t offset, UINT32 data, UINT32 mem_mask) | |
| 152 | { | |
| 153 | if ((mem_mask & 0xffff0000) != 0xffff0000) | |
| 154 | write16be_with_write8_handler(handler, offset * 2 + 0, data >> 16, mem_mask >> 16); | |
| 155 | if ((mem_mask & 0x0000ffff) != 0x0000ffff) | |
| 156 | write16be_with_write8_handler(handler, offset * 2 + 1, data, mem_mask); | |
| 157 | } | |
| 158 | ||
| 159 | ||
| 40 | 160 | /************************************* |
| 41 | 161 | * |
| 42 | 162 | * 32-bit LE using 8-bit handlers |
| r936 | r937 | |
| 63 | 183 | } |
| 64 | 184 | |
| 65 | 185 | |
| 186 | /************************************* | |
| 187 | * | |
| 188 | * 32-bit BE using 16-bit BE handlers | |
| 189 | * | |
| 190 | *************************************/ | |
| 66 | 191 | |
| 192 | INLINE UINT32 read32be_with_16be_handler(read16_handler handler, offs_t offset, UINT32 mem_mask) | |
| 193 | { | |
| 194 | UINT32 result = 0; | |
| 195 | if ((mem_mask & 0xffff0000) != 0xffff0000) | |
| 196 | result |= (*handler)(offset * 2 + 0, mem_mask >> 16) << 16; | |
| 197 | if ((mem_mask & 0x0000ffff) != 0x0000ffff) | |
| 198 | result |= (*handler)(offset * 2 + 1, mem_mask) << 0; | |
| 199 | return result; | |
| 200 | } | |
| 201 | ||
| 202 | ||
| 203 | INLINE void write32be_with_16be_handler(write16_handler handler, offs_t offset, UINT32 data, UINT32 mem_mask) | |
| 204 | { | |
| 205 | if ((mem_mask & 0xffff0000) != 0xffff0000) | |
| 206 | (*handler)(offset * 2 + 0, data >> 16, mem_mask >> 16); | |
| 207 | if ((mem_mask & 0x0000ffff) != 0x0000ffff) | |
| 208 | (*handler)(offset * 2 + 1, data, mem_mask); | |
| 209 | } | |
| 210 | ||
| 211 | ||
| 67 | 212 | /************************************* |
| 68 | 213 | * |
| 214 | * 32-bit LE using 16-bit LE handlers | |
| 215 | * | |
| 216 | *************************************/ | |
| 217 | ||
| 218 | INLINE UINT32 read32le_with_16le_handler(read16_handler handler, offs_t offset, UINT32 mem_mask) | |
| 219 | { | |
| 220 | UINT32 result = 0; | |
| 221 | if ((mem_mask & 0x0000ffff) != 0x0000ffff) | |
| 222 | result |= (*handler)(offset * 2 + 0, mem_mask) << 0; | |
| 223 | if ((mem_mask & 0xffff0000) != 0xffff0000) | |
| 224 | result |= (*handler)(offset * 2 + 1, mem_mask >> 16) << 16; | |
| 225 | return result; | |
| 226 | } | |
| 227 | ||
| 228 | ||
| 229 | INLINE void write32le_with_16le_handler(write16_handler handler, offs_t offset, UINT32 data, UINT32 mem_mask) | |
| 230 | { | |
| 231 | if ((mem_mask & 0x0000ffff) != 0x0000ffff) | |
| 232 | (*handler)(offset * 2 + 0, data, mem_mask); | |
| 233 | if ((mem_mask & 0xffff0000) != 0xffff0000) | |
| 234 | (*handler)(offset * 2 + 1, data >> 16, mem_mask >> 16); | |
| 235 | } | |
| 236 | ||
| 237 | ||
| 238 | /************************************* | |
| 239 | * | |
| 240 | * 32-bit BE using 16-bit LE handlers | |
| 241 | * | |
| 242 | *************************************/ | |
| 243 | ||
| 244 | INLINE UINT32 read32be_with_16le_handler(read16_handler handler, offs_t offset, UINT32 mem_mask) | |
| 245 | { | |
| 246 | UINT32 result = 0; | |
| 247 | mem_mask = FLIPENDIAN_INT32(mem_mask); | |
| 248 | result = read32le_with_16le_handler(handler, offset, mem_mask); | |
| 249 | return FLIPENDIAN_INT32(result); | |
| 250 | } | |
| 251 | ||
| 252 | ||
| 253 | INLINE void write32be_with_16le_handler(write16_handler handler, offs_t offset, UINT32 data, UINT32 mem_mask) | |
| 254 | { | |
| 255 | data = FLIPENDIAN_INT32(data); | |
| 256 | mem_mask = FLIPENDIAN_INT32(mem_mask); | |
| 257 | write32le_with_16le_handler(handler, offset, data, mem_mask); | |
| 258 | } | |
| 259 | ||
| 260 | ||
| 261 | /************************************* | |
| 262 | * | |
| 263 | * 32-bit LE using 16-bit BE handlers | |
| 264 | * | |
| 265 | *************************************/ | |
| 266 | ||
| 267 | INLINE UINT32 read32le_with_16be_handler(read16_handler handler, offs_t offset, UINT32 mem_mask) | |
| 268 | { | |
| 269 | UINT32 result = 0; | |
| 270 | mem_mask = FLIPENDIAN_INT32(mem_mask); | |
| 271 | result = read32be_with_16be_handler(handler, offset, mem_mask); | |
| 272 | return FLIPENDIAN_INT32(result); | |
| 273 | } | |
| 274 | ||
| 275 | ||
| 276 | INLINE void write32le_with_16be_handler(write16_handler handler, offs_t offset, UINT32 data, UINT32 mem_mask) | |
| 277 | { | |
| 278 | data = FLIPENDIAN_INT32(data); | |
| 279 | mem_mask = FLIPENDIAN_INT32(mem_mask); | |
| 280 | write32be_with_16be_handler(handler, offset, data, mem_mask); | |
| 281 | } | |
| 282 | ||
| 283 | ||
| 284 | /************************************* | |
| 285 | * | |
| 69 | 286 | * 64-bit BE using 8-bit handlers |
| 70 | 287 | * |
| 71 | 288 | *************************************/ |
| r936 | r937 | |
| 73 | 290 | INLINE UINT64 read64be_with_read8_handler(read8_handler handler, offs_t offset, UINT64 mem_mask) |
| 74 | 291 | { |
| 75 | 292 | UINT64 result = 0; |
| 76 | int i; | |
| 77 | ||
| 78 | for (i = 0; i < 8; i++) | |
| 79 | { | |
| 80 | if (((mem_mask >> (56 - i * 8)) & 0xff) == 0) | |
| 81 | result |= ((UINT64) handler(offset * 8 + i)) << (56 - i * 8); | |
| 82 | } | |
| 293 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 294 | result |= (UINT64)read32be_with_read8_handler(handler, offset * 2 + 0, mem_mask >> 32) << 32; | |
| 295 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 296 | result |= (UINT64)read32be_with_read8_handler(handler, offset * 2 + 1, mem_mask) << 0; | |
| 83 | 297 | return result; |
| 84 | 298 | } |
| 85 | 299 | |
| 300 | ||
| 86 | 301 | INLINE void write64be_with_write8_handler(write8_handler handler, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 87 | 302 | { |
| 88 | int i; | |
| 303 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 304 | write32be_with_write8_handler(handler, offset * 2 + 0, data >> 32, mem_mask >> 32); | |
| 305 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 306 | write32be_with_write8_handler(handler, offset * 2 + 1, data, mem_mask); | |
| 307 | } | |
| 89 | 308 | |
| 90 | for (i = 0; i < 8; i++) | |
| 91 | { | |
| 92 | if (((mem_mask >> (56 - i * 8)) & 0xff) == 0) | |
| 93 | handler(offset * 8 + i, data >> (56 - i * 8)); | |
| 94 | } | |
| 309 | ||
| 310 | /************************************* | |
| 311 | * | |
| 312 | * 64-bit LE using 8-bit handlers | |
| 313 | * | |
| 314 | *************************************/ | |
| 315 | ||
| 316 | INLINE UINT64 read64le_with_read8_handler(read8_handler handler, offs_t offset, UINT64 mem_mask) | |
| 317 | { | |
| 318 | UINT64 result = 0; | |
| 319 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 320 | result |= (UINT64)read32le_with_read8_handler(handler, offset * 2 + 0, mem_mask >> 0) << 0; | |
| 321 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 322 | result |= (UINT64)read32le_with_read8_handler(handler, offset * 2 + 1, mem_mask >> 32) << 32; | |
| 323 | return result; | |
| 95 | 324 | } |
| 96 | 325 | |
| 97 | 326 | |
| 327 | INLINE void write64le_with_write8_handler(write8_handler handler, offs_t offset, UINT64 data, UINT64 mem_mask) | |
| 328 | { | |
| 329 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 330 | write32le_with_write8_handler(handler, offset * 2 + 0, data >> 0, mem_mask >> 0); | |
| 331 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 332 | write32le_with_write8_handler(handler, offset * 2 + 1, data >> 32, mem_mask >> 32); | |
| 333 | } | |
| 98 | 334 | |
| 335 | ||
| 99 | 336 | /************************************* |
| 100 | 337 | * |
| 338 | * 64-bit BE using 16-bit BE handlers | |
| 339 | * | |
| 340 | *************************************/ | |
| 341 | ||
| 342 | INLINE UINT32 read64be_with_16be_handler(read16_handler handler, offs_t offset, UINT64 mem_mask) | |
| 343 | { | |
| 344 | UINT64 result = 0; | |
| 345 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 346 | result |= (UINT64)read32be_with_16be_handler(handler, offset * 2 + 0, mem_mask >> 32) << 32; | |
| 347 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 348 | result |= (UINT64)read32be_with_16be_handler(handler, offset * 2 + 1, mem_mask >> 0) << 0; | |
| 349 | return result; | |
| 350 | } | |
| 351 | ||
| 352 | ||
| 353 | INLINE void write64be_with_16be_handler(write16_handler handler, offs_t offset, UINT64 data, UINT64 mem_mask) | |
| 354 | { | |
| 355 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 356 | write32be_with_16be_handler(handler, offset * 2 + 0, data >> 32, mem_mask >> 32); | |
| 357 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 358 | write32be_with_16be_handler(handler, offset * 2 + 1, data >> 0, mem_mask >> 0); | |
| 359 | } | |
| 360 | ||
| 361 | ||
| 362 | /************************************* | |
| 363 | * | |
| 364 | * 64-bit LE using 16-bit LE handlers | |
| 365 | * | |
| 366 | *************************************/ | |
| 367 | ||
| 368 | INLINE UINT32 read64le_with_16le_handler(read16_handler handler, offs_t offset, UINT64 mem_mask) | |
| 369 | { | |
| 370 | UINT64 result = 0; | |
| 371 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 372 | result |= (UINT64)read32le_with_16le_handler(handler, offset * 2 + 0, mem_mask >> 0) << 0; | |
| 373 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 374 | result |= (UINT64)read32le_with_16le_handler(handler, offset * 2 + 1, mem_mask >> 32) << 32; | |
| 375 | return result; | |
| 376 | } | |
| 377 | ||
| 378 | ||
| 379 | INLINE void write64le_with_16le_handler(write16_handler handler, offs_t offset, UINT64 data, UINT64 mem_mask) | |
| 380 | { | |
| 381 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 382 | write32le_with_16le_handler(handler, offset * 2 + 0, data >> 0, mem_mask >> 0); | |
| 383 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 384 | write32le_with_16le_handler(handler, offset * 2 + 1, data >> 32, mem_mask >> 32); | |
| 385 | } | |
| 386 | ||
| 387 | ||
| 388 | /************************************* | |
| 389 | * | |
| 390 | * 64-bit BE using 16-bit LE handlers | |
| 391 | * | |
| 392 | *************************************/ | |
| 393 | ||
| 394 | INLINE UINT32 read64be_with_16le_handler(read16_handler handler, offs_t offset, UINT64 mem_mask) | |
| 395 | { | |
| 396 | UINT64 result = 0; | |
| 397 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 398 | result |= (UINT64)read32be_with_16le_handler(handler, offset * 2 + 0, mem_mask >> 32) << 32; | |
| 399 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 400 | result |= (UINT64)read32be_with_16le_handler(handler, offset * 2 + 1, mem_mask >> 0) << 0; | |
| 401 | return result; | |
| 402 | } | |
| 403 | ||
| 404 | ||
| 405 | INLINE void write64be_with_16le_handler(write16_handler handler, offs_t offset, UINT64 data, UINT64 mem_mask) | |
| 406 | { | |
| 407 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 408 | write32be_with_16le_handler(handler, offset * 2 + 0, data >> 32, mem_mask >> 32); | |
| 409 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 410 | write32be_with_16le_handler(handler, offset * 2 + 1, data >> 0, mem_mask >> 0); | |
| 411 | } | |
| 412 | ||
| 413 | ||
| 414 | /************************************* | |
| 415 | * | |
| 416 | * 64-bit LE using 16-bit BE handlers | |
| 417 | * | |
| 418 | *************************************/ | |
| 419 | ||
| 420 | INLINE UINT32 read64le_with_16be_handler(read16_handler handler, offs_t offset, UINT64 mem_mask) | |
| 421 | { | |
| 422 | UINT64 result = 0; | |
| 423 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 424 | result |= (UINT64)read32le_with_16be_handler(handler, offset * 2 + 0, mem_mask >> 0) << 0; | |
| 425 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 426 | result |= (UINT64)read32le_with_16be_handler(handler, offset * 2 + 1, mem_mask >> 32) << 32; | |
| 427 | return result; | |
| 428 | } | |
| 429 | ||
| 430 | ||
| 431 | INLINE void write64le_with_16be_handler(write16_handler handler, offs_t offset, UINT64 data, UINT64 mem_mask) | |
| 432 | { | |
| 433 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 434 | write32le_with_16be_handler(handler, offset * 2 + 0, data >> 0, mem_mask >> 0); | |
| 435 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 436 | write32le_with_16be_handler(handler, offset * 2 + 1, data >> 32, mem_mask >> 32); | |
| 437 | } | |
| 438 | ||
| 439 | ||
| 440 | /************************************* | |
| 441 | * | |
| 442 | * 64-bit BE using 32-bit BE handlers | |
| 443 | * | |
| 444 | *************************************/ | |
| 445 | ||
| 446 | INLINE UINT64 read64be_with_32be_handler(read32_handler handler, offs_t offset, UINT64 mem_mask) | |
| 447 | { | |
| 448 | UINT64 result = 0; | |
| 449 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 450 | result |= (UINT64)(*handler)(offset * 2 + 0, mem_mask >> 32) << 32; | |
| 451 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 452 | result |= (UINT64)(*handler)(offset * 2 + 1, mem_mask >> 0) << 0; | |
| 453 | return result; | |
| 454 | } | |
| 455 | ||
| 456 | ||
| 457 | INLINE void write64be_with_32be_handler(write32_handler handler, offs_t offset, UINT64 data, UINT64 mem_mask) | |
| 458 | { | |
| 459 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) | |
| 460 | (*handler)(offset * 2 + 0, data >> 32, mem_mask >> 32); | |
| 461 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) | |
| 462 | (*handler)(offset * 2 + 1, data >> 0, mem_mask >> 0); | |
| 463 | } | |
| 464 | ||
| 465 | ||
| 466 | /************************************* | |
| 467 | * | |
| 101 | 468 | * 64-bit LE using 32-bit LE handlers |
| 102 | 469 | * |
| 103 | 470 | *************************************/ |
| r936 | r937 | |
| 106 | 473 | { |
| 107 | 474 | UINT64 result = 0; |
| 108 | 475 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) |
| 109 | result |= ( | |
| 476 | result |= ( | |
| 110 | 477 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) |
| 111 | result |= ( | |
| 478 | result |= ( | |
| 112 | 479 | return result; |
| 113 | 480 | } |
| 114 | 481 | |
| 482 | ||
| 115 | 483 | INLINE void write64le_with_32le_handler(write32_handler handler, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 116 | 484 | { |
| 117 | 485 | if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) |
| 118 | handler(offset * 2 + 0, data >> | |
| 486 | (*handler)(offset * 2 + 0, data >> | |
| 119 | 487 | if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) |
| 120 | handler(offset * 2 + 1, data >> 32, mem_mask >> 32); | |
| 488 | (*handler)(offset * 2 + 1, data >> 32, mem_mask >> 32); | |
| 121 | 489 | } |
| 122 | 490 | |
| 123 | 491 | |
| 124 | ||
| 125 | 492 | /************************************* |
| 126 | 493 | * |
| 127 | 494 | * 64-bit BE using 32-bit LE handlers |
| r936 | r937 | |
| 136 | 503 | return FLIPENDIAN_INT64(result); |
| 137 | 504 | } |
| 138 | 505 | |
| 506 | ||
| 139 | 507 | INLINE void write64be_with_32le_handler(write32_handler handler, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 140 | 508 | { |
| 141 | 509 | data = FLIPENDIAN_INT64(data); |
| 142 | 510 | mem_mask = FLIPENDIAN_INT64(mem_mask); |
| 143 | 511 | write64le_with_32le_handler(handler, offset, data, mem_mask); |
| 144 | 512 | } |
| 513 | ||
| 514 | ||
| 515 | /************************************* | |
| 516 | * | |
| 517 | * 64-bit LE using 32-bit BE handlers | |
| 518 | * | |
| 519 | *************************************/ | |
| 520 | ||
| 521 | INLINE UINT64 read64le_with_32be_handler(read32_handler handler, offs_t offset, UINT64 mem_mask) | |
| 522 | { | |
| 523 | UINT64 result; | |
| 524 | mem_mask = FLIPENDIAN_INT64(mem_mask); | |
| 525 | result = read64be_with_32be_handler(handler, offset, mem_mask); | |
| 526 | return FLIPENDIAN_INT64(result); | |
| 527 | } | |
| 528 | ||
| 529 | ||
| 530 | INLINE void write64le_with_32be_handler(write32_handler handler, offs_t offset, UINT64 data, UINT64 mem_mask) | |
| 531 | { | |
| 532 | data = FLIPENDIAN_INT64(data); | |
| 533 | mem_mask = FLIPENDIAN_INT64(mem_mask); | |
| 534 | write64be_with_32be_handler(handler, offset, data, mem_mask); | |
| 535 | } | |
| 536 | ||
| 537 | ||
| 538 | ||
| 539 | /************************************************************************** | |
| 540 | ||
| 541 | Utility macros | |
| 542 | ||
| 543 | **************************************************************************/ | |
| 544 | ||
| 545 | #define READ_TEMPLATE(bits, name, handler, func) \ | |
| 546 | READ##bits##_HANDLER( name##_r ) \ | |
| 547 | { \ | |
| 548 | return func(handler, offset, mem_mask); \ | |
| 549 | } | |
| 550 | ||
| 551 | #define READ_TEMPLATE_COND(bits, name, handler, func, cond) \ | |
| 552 | READ##bits##_HANDLER( name##_r ) \ | |
| 553 | { \ | |
| 554 | if (cond) \ | |
| 555 | return func(handler, offset, mem_mask); \ | |
| 556 | return 0; \ | |
| 557 | } | |
| 558 | ||
| 559 | #define WRITE_TEMPLATE(bits, name, handler, func) \ | |
| 560 | WRITE##bits##_HANDLER( name##_w ) \ | |
| 561 | { \ | |
| 562 | func(handler, offset, data, mem_mask); \ | |
| 563 | } | |
| 564 | ||
| 565 | #define WRITE_TEMPLATE_COND(bits, name, handler, func, cond) \ | |
| 566 | WRITE##bits##_HANDLER( name##_w ) \ | |
| 567 | { \ | |
| 568 | if (cond) \ | |
| 569 | return func(handler, offset, data, mem_mask); \ | |
| 570 | } | |
| 571 | ||
| 572 | ||
| 573 | ||
| 574 | /************************************************************************** | |
| 575 | ||
| 576 | Generic conversions macros | |
| 577 | ||
| 578 | **************************************************************************/ | |
| 579 | ||
| 580 | ||
| 581 | /************************************* | |
| 582 | * 8->16be, 1:1 mapping | |
| 583 | ************************************/ | |
| 584 | ||
| 585 | #define READ8TO16BE( name, read8 ) \ | |
| 586 | READ_TEMPLATE( 16, name, read8, read16be_with_read8_handler ) | |
| 587 | ||
| 588 | ||
| 589 | #define WRITE8TO16BE( name, write8 ) \ | |
| 590 | WRITE_TEMPLATE( 16, name, write8, write16be_with_write8_handler ) | |
| 591 | ||
| 592 | ||
| 593 | #define READWRITE8TO16BE( name, read8, write8 ) \ | |
| 594 | READ8TO16BE(name,read8) \ | |
| 595 | WRITE8TO16BE(name,write8) | |
| 596 | ||
| 597 | ||
| 598 | /************************************* | |
| 599 | * 8->16le, 1:1 mapping | |
| 600 | ************************************/ | |
| 601 | ||
| 602 | #define READ8TO16LE( name, read8 ) \ | |
| 603 | READ_TEMPLATE( 16, name, read8, read16le_with_read8_handler ) | |
| 604 | ||
| 605 | ||
| 606 | #define WRITE8TO16LE( name, write8 ) \ | |
| 607 | WRITE_TEMPLATE( 16, name, write8, write16le_with_write8_handler ) | |
| 608 | ||
| 609 | ||
| 610 | #define READWRITE8TO16LE( name, read8, write8 ) \ | |
| 611 | READ8TO16LE(name,read8) \ | |
| 612 | WRITE8TO16LE(name,write8) | |
| 613 | ||
| 614 | ||
| 615 | /************************************* | |
| 616 | * 8->16be, MSB mapping | |
| 617 | ************************************/ | |
| 618 | ||
| 619 | #define READ8TO16BE_MSB( name, read8 ) \ | |
| 620 | READ_TEMPLATE_COND( 16, name, read8, read16be_with_read8_handler, ACCESSING_MSB ) | |
| 621 | ||
| 622 | ||
| 623 | #define WRITE8TO16BE_MSB( name, write8 ) \ | |
| 624 | WRITE_TEMPLATE_COND( 16, name, write8, write16be_with_write8_handler, ACCESSING_MSB ) | |
| 625 | ||
| 626 | ||
| 627 | #define READWRITE8TO16BE_MSB( name, read8, write8 ) \ | |
| 628 | READ8TO16BE_MSB(name,read8) \ | |
| 629 | WRITE8TO16BE_MSB(name,write8) | |
| 630 | ||
| 631 | ||
| 632 | /************************************* | |
| 633 | * 8->16le, MSB mapping | |
| 634 | ************************************/ | |
| 635 | ||
| 636 | #define READ8TO16LE_MSB( name, read8 ) \ | |
| 637 | READ_TEMPLATE_COND( 16, name, read8, read16le_with_read8_handler, ACCESSING_MSB ) | |
| 638 | ||
| 639 | ||
| 640 | #define WRITE8TO16LE_MSB( name, write8 ) \ | |
| 641 | WRITE_TEMPLATE_COND( 16, name, write8, write16le_with_write8_handler, ACCESSING_MSB ) | |
| 642 | ||
| 643 | ||
| 644 | #define READWRITE8TO16LE_MSB( name, read8, write8 ) \ | |
| 645 | READ8TO16LE_MSB(name,read8) \ | |
| 646 | WRITE8TO16LE_MSB(name,write8) | |
| 647 | ||
| 648 | ||
| 649 | /************************************* | |
| 650 | * 8->16be, LSB mapping | |
| 651 | ************************************/ | |
| 652 | ||
| 653 | #define READ8TO16BE_LSB( name, read8 ) \ | |
| 654 | READ_TEMPLATE_COND( 16, name, read8, read16be_with_read8_handler, ACCESSING_LSB ) | |
| 655 | ||
| 656 | ||
| 657 | #define WRITE8TO16BE_LSB( name, write8 ) \ | |
| 658 | WRITE_TEMPLATE_COND( 16, name, write8, write16be_with_write8_handler, ACCESSING_LSB ) | |
| 659 | ||
| 660 | ||
| 661 | #define READWRITE8TO16BE_LSB( name, read8, write8 ) \ | |
| 662 | READ8TO16BE_LSB(name,read8) \ | |
| 663 | WRITE8TO16BE_LSB(name,write8) | |
| 664 | ||
| 665 | ||
| 666 | /************************************* | |
| 667 | * 8->16le, LSB mapping | |
| 668 | ************************************/ | |
| 669 | ||
| 670 | #define READ8TO16LE_LSB( name, read8 ) \ | |
| 671 | READ_TEMPLATE_COND( 16, name, read8, read16le_with_read8_handler, ACCESSING_LSB ) | |
| 672 | ||
| 673 | ||
| 674 | #define WRITE8TO16LE_LSB( name, write8 ) \ | |
| 675 | WRITE_TEMPLATE_COND( 16, name, write8, write16le_with_write8_handler, ACCESSING_LSB ) | |
| 676 | ||
| 677 | ||
| 678 | #define READWRITE8TO16LE_LSB( name, read8, write8 ) \ | |
| 679 | READ8TO16LE_LSB(name,read8) \ | |
| 680 | WRITE8TO16LE_LSB(name,write8) | |
| 681 | ||
| 682 | ||
| 683 | /************************************* | |
| 684 | * 8->32be, 1:1 mapping | |
| 685 | ************************************/ | |
| 686 | ||
| 687 | #define READ8TO32BE( name, read8 ) \ | |
| 688 | READ_TEMPLATE( 32, name, read8, read32be_with_read8_handler ) | |
| 689 | ||
| 690 | ||
| 691 | #define WRITE8TO32BE( name, write8 ) \ | |
| 692 | WRITE_TEMPLATE( 32, name, write8, write32be_with_write8_handler ) | |
| 693 | ||
| 694 | ||
| 695 | #define READWRITE8TO32BE( name, read8, write8 ) \ | |
| 696 | READ8TO32BE(name,read8) \ | |
| 697 | WRITE8TO32BE(name,write8) | |
| 698 | ||
| 699 | ||
| 700 | /************************************* | |
| 701 | * 8->32le, 1:1 mapping | |
| 702 | ************************************/ | |
| 703 | ||
| 704 | #define READ8TO32LE( name, read8 ) \ | |
| 705 | READ_TEMPLATE( 32, name, read8, read32le_with_read8_handler ) | |
| 706 | ||
| 707 | ||
| 708 | #define WRITE8TO32LE( name, write8 ) \ | |
| 709 | WRITE_TEMPLATE( 32, name, write8, write32le_with_write8_handler ) | |
| 710 | ||
| 711 | ||
| 712 | #define READWRITE8TO32LE( name, read8, write8 ) \ | |
| 713 | READ8TO32LE(name,read8) \ | |
| 714 | WRITE8TO32LE(name,write8) | |
| 715 | ||
| 716 | ||
| 717 | /************************************* | |
| 718 | * 8->32be, MSB mapping | |
| 719 | ************************************/ | |
| 720 | ||
| 721 | #define READ8TO32BE_MSB( name, read8 ) \ | |
| 722 | READ_TEMPLATE_COND( 32, name, read8, read32be_with_read8_handler, ACCESSING_MSB32 ) | |
| 723 | ||
| 724 | ||
| 725 | #define WRITE8TO32BE_MSB( name, write8 ) \ | |
| 726 | WRITE_TEMPLATE_COND( 32, name, write8, write32be_with_write8_handler, ACCESSING_MSB32 ) | |
| 727 | ||
| 728 | ||
| 729 | #define READWRITE8TO32BE_MSB( name, read8, write8 ) \ | |
| 730 | READ8TO32BE_MSB(name,read8) \ | |
| 731 | WRITE8TO32BE_MSB(name,write8) | |
| 732 | ||
| 733 | ||
| 734 | /************************************* | |
| 735 | * 8->32le, MSB mapping | |
| 736 | ************************************/ | |
| 737 | ||
| 738 | #define READ8TO32LE_MSB( name, read8 ) \ | |
| 739 | READ_TEMPLATE_COND( 32, name, read8, read32le_with_read8_handler, ACCESSING_MSB32 ) | |
| 740 | ||
| 741 | ||
| 742 | #define WRITE8TO32LE_MSB( name, write8 ) \ | |
| 743 | WRITE_TEMPLATE_COND( 32, name, write8, write32le_with_write8_handler, ACCESSING_MSB32 ) | |
| 744 | ||
| 745 | ||
| 746 | #define READWRITE8TO32LE_MSB( name, read8, write8 ) \ | |
| 747 | READ8TO32LE_MSB(name,read8) \ | |
| 748 | WRITE8TO32LE_MSB(name,write8) | |
| 749 | ||
| 750 | ||
| 751 | /************************************* | |
| 752 | * 8->32be, LSB mapping | |
| 753 | ************************************/ | |
| 754 | ||
| 755 | #define READ8TO32BE_LSB( name, read8 ) \ | |
| 756 | READ_TEMPLATE_COND( 32, name, read8, read32be_with_read8_handler, ACCESSING_LSB32 ) | |
| 757 | ||
| 758 | ||
| 759 | #define WRITE8TO32BE_LSB( name, write8 ) \ | |
| 760 | WRITE_TEMPLATE_COND( 32, name, write8, write32be_with_write8_handler, ACCESSING_LSB32 ) | |
| 761 | ||
| 762 | ||
| 763 | #define READWRITE8TO32BE_LSB( name, read8, write8 ) \ | |
| 764 | READ8TO32BE_LSB(name,read8) \ | |
| 765 | WRITE8TO32BE_LSB(name,write8) | |
| 766 | ||
| 767 | ||
| 768 | /************************************* | |
| 769 | * 8->32le, LSB mapping | |
| 770 | ************************************/ | |
| 771 | ||
| 772 | #define READ8TO32LE_LSB( name, read8 ) \ | |
| 773 | READ_TEMPLATE_COND( 32, name, read8, read32le_with_read8_handler, ACCESSING_LSB32 ) | |
| 774 | ||
| 775 | ||
| 776 | #define WRITE8TO32LE_LSB( name, write8 ) \ | |
| 777 | WRITE_TEMPLATE_COND( 32, name, write8, write32le_with_write8_handler, ACCESSING_LSB32 ) | |
| 778 | ||
| 779 | ||
| 780 | #define READWRITE8TO32LE_LSB( name, read8, write8 ) \ | |
| 781 | READ8TO32LE_LSB(name,read8) \ | |
| 782 | WRITE8TO32LE_LSB(name,write8) | |
| 783 | ||
| 784 | ||
| 785 | /************************************* | |
| 786 | * 8->64be, 1:1 mapping | |
| 787 | ************************************/ | |
| 788 | ||
| 789 | #define READ8TO64BE( name, read8 ) \ | |
| 790 | READ_TEMPLATE( 64, name, read8, read64be_with_read8_handler ) | |
| 791 | ||
| 792 | ||
| 793 | #define WRITE8TO64BE( name, write8 ) \ | |
| 794 | WRITE_TEMPLATE( 64, name, write8, write64be_with_write8_handler ) | |
| 795 | ||
| 796 | ||
| 797 | #define READWRITE8TO64BE( name, read8, write8 ) \ | |
| 798 | READ8TO64BE(name,read8) \ | |
| 799 | WRITE8TO64BE(name,write8) | |
| 800 | ||
| 801 | ||
| 802 | /************************************* | |
| 803 | * 8->64le, 1:1 mapping | |
| 804 | ************************************/ | |
| 805 | ||
| 806 | #define READ8TO64LE( name, read8 ) \ | |
| 807 | READ_TEMPLATE( 64, name, read8, read64le_with_read8_handler ) | |
| 808 | ||
| 809 | ||
| 810 | #define WRITE8TO64LE( name, write8 ) \ | |
| 811 | WRITE_TEMPLATE( 64, name, write8, write64le_with_write8_handler ) | |
| 812 | ||
| 813 | ||
| 814 | #define READWRITE8TO64LE( name, read8, write8 ) \ | |
| 815 | READ8TO64LE(name,read8) \ | |
| 816 | WRITE8TO64LE(name,write8) | |
| 817 | ||
| 818 | ||
| 819 | /************************************* | |
| 820 | * 16be->32be, 1:1 mapping | |
| 821 | *************************************/ | |
| 822 | ||
| 823 | #define READ16BETO32BE( name, read16 ) \ | |
| 824 | READ_TEMPLATE( 32, name, read16, read32be_with_16be_handler ) | |
| 825 | ||
| 826 | ||
| 827 | #define WRITE16BETO32BE( name, write16 ) \ | |
| 828 | WRITE_TEMPLATE( 32, name, write16, write32be_with_16be_handler ) | |
| 829 | ||
| 830 | ||
| 831 | #define READWRITE16BETO32BE( name, read16, write16 ) \ | |
| 832 | READ16BETO32BE(name,read16) \ | |
| 833 | WRITE16BETO32BE(name,write16) | |
| 834 | ||
| 835 | ||
| 836 | /************************************* | |
| 837 | * 16le->32be, 1:1 mapping | |
| 838 | *************************************/ | |
| 839 | ||
| 840 | #define READ16LETO32BE( name, read16 ) \ | |
| 841 | READ_TEMPLATE( 32, name, read16, read32be_with_16le_handler ) | |
| 842 | ||
| 843 | ||
| 844 | #define WRITE16LETO32BE( name, write16 ) \ | |
| 845 | WRITE_TEMPLATE( 32, name, write16, write32be_with_16le_handler ) | |
| 846 | ||
| 847 | ||
| 848 | #define READWRITE16LETO32BE( name, read16, write16 ) \ | |
| 849 | READ16LETO32BE(name,read16) \ | |
| 850 | WRITE16LETO32BE(name,write16) | |
| 851 | ||
| 852 | ||
| 853 | /************************************* | |
| 854 | * 16be->32le, 1:1 mapping | |
| 855 | *************************************/ | |
| 856 | ||
| 857 | #define READ16BETO32LE( name, read16 ) \ | |
| 858 | READ_TEMPLATE( 32, name, read16, read32le_with_16be_handler ) | |
| 859 | ||
| 860 | ||
| 861 | #define WRITE16BETO32LE( name, write16 ) \ | |
| 862 | WRITE_TEMPLATE( 32, name, write16, write32le_with_16be_handler ) | |
| 863 | ||
| 864 | ||
| 865 | #define READWRITE16BETO32LE( name, read16, write16 ) \ | |
| 866 | READ16BETO32LE(name,read16) \ | |
| 867 | WRITE16BETO32LE(name,write16) | |
| 868 | ||
| 869 | ||
| 870 | /************************************* | |
| 871 | * 16le->32le, 1:1 mapping | |
| 872 | *************************************/ | |
| 873 | ||
| 874 | #define READ16LETO32LE( name, read16 ) \ | |
| 875 | READ_TEMPLATE( 32, name, read16, read32le_with_16le_handler ) | |
| 876 | ||
| 877 | ||
| 878 | #define WRITE16LETO32LE( name, write16 ) \ | |
| 879 | WRITE_TEMPLATE( 32, name, write16, write32le_with_16le_handler ) | |
| 880 | ||
| 881 | ||
| 882 | #define READWRITE16LETO32LE( name, read16, write16 ) \ | |
| 883 | READ16LETO32LE(name,read16) \ | |
| 884 | WRITE16LETO32LE(name,write16) | |
| 885 | ||
| 886 | ||
| 887 | /************************************* | |
| 888 | * 16be->32be, MSW mapping | |
| 889 | *************************************/ | |
| 890 | ||
| 891 | #define READ16BETO32BE_MSW( name, read16 ) \ | |
| 892 | READ_TEMPLATE_COND( 32, name, read16, read32be_with_16be_handler, ACCESSING_MSW32 ) | |
| 893 | ||
| 894 | ||
| 895 | #define WRITE16BETO32BE_MSW( name, write16 ) \ | |
| 896 | WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16be_handler, ACCESSING_MSW32 ) | |
| 897 | ||
| 898 | ||
| 899 | #define READWRITE16BETO32BE_MSW( name, read16, write16 ) \ | |
| 900 | READ16BETO32BE_MSW(name,read16) \ | |
| 901 | WRITE16BETO32BE_MSW(name,write16) | |
| 902 | ||
| 903 | ||
| 904 | /************************************* | |
| 905 | * 16le->32be, MSW mapping | |
| 906 | *************************************/ | |
| 907 | ||
| 908 | #define READ16LETO32BE_MSW( name, read16 ) \ | |
| 909 | READ_TEMPLATE_COND( 32, name, read16, read32be_with_16le_handler, ACCESSING_MSW32 ) | |
| 910 | ||
| 911 | ||
| 912 | #define WRITE16LETO32BE_MSW( name, write16 ) \ | |
| 913 | WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16le_handler, ACCESSING_MSW32 ) | |
| 914 | ||
| 915 | ||
| 916 | #define READWRITE16LETO32BE_MSW( name, read16, write16 ) \ | |
| 917 | READ16LETO32BE_MSW(name,read16) \ | |
| 918 | WRITE16LETO32BE_MSW(name,write16) | |
| 919 | ||
| 920 | ||
| 921 | /************************************* | |
| 922 | * 16be->32le, MSW mapping | |
| 923 | *************************************/ | |
| 924 | ||
| 925 | #define READ16BETO32LE_MSW( name, read16 ) \ | |
| 926 | READ_TEMPLATE_COND( 32, name, read16, read32le_with_16be_handler, ACCESSING_MSW32 ) | |
| 927 | ||
| 928 | ||
| 929 | #define WRITE16BETO32LE_MSW( name, write16 ) \ | |
| 930 | WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16be_handler, ACCESSING_MSW32 ) | |
| 931 | ||
| 932 | ||
| 933 | #define READWRITE16BETO32LE_MSW( name, read16, write16 ) \ | |
| 934 | READ16BETO32LE_MSW(name,read16) \ | |
| 935 | WRITE16BETO32LE_MSW(name,write16) | |
| 936 | ||
| 937 | ||
| 938 | /************************************* | |
| 939 | * 16le->32le, MSW mapping | |
| 940 | *************************************/ | |
| 941 | ||
| 942 | #define READ16LETO32LE_MSW( name, read16 ) \ | |
| 943 | READ_TEMPLATE_COND( 32, name, read16, read32le_with_16le_handler, ACCESSING_MSW32 ) | |
| 944 | ||
| 945 | ||
| 946 | #define WRITE16LETO32LE_MSW( name, write16 ) \ | |
| 947 | WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16le_handler, ACCESSING_MSW32 ) | |
| 948 | ||
| 949 | ||
| 950 | #define READWRITE16LETO32LE_MSW( name, read16, write16 ) \ | |
| 951 | READ16LETO32LE_MSW(name,read16) \ | |
| 952 | WRITE16LETO32LE_MSW(name,write16) | |
| 953 | ||
| 954 | /************************************* | |
| 955 | * 16be->32be, LSW mapping | |
| 956 | *************************************/ | |
| 957 | ||
| 958 | #define READ16BETO32BE_LSW( name, read16 ) \ | |
| 959 | READ_TEMPLATE_COND( 32, name, read16, read32be_with_16be_handler, ACCESSING_LSW32 ) | |
| 960 | ||
| 961 | ||
| 962 | #define WRITE16BETO32BE_LSW( name, write16 ) \ | |
| 963 | WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16be_handler, ACCESSING_LSW32 ) | |
| 964 | ||
| 965 | ||
| 966 | #define READWRITE16BETO32BE_LSW( name, read16, write16 ) \ | |
| 967 | READ16BETO32BE_LSW(name,read16) \ | |
| 968 | WRITE16BETO32BE_LSW(name,write16) | |
| 969 | ||
| 970 | ||
| 971 | /************************************* | |
| 972 | * 16le->32be, LSW mapping | |
| 973 | *************************************/ | |
| 974 | ||
| 975 | #define READ16LETO32BE_LSW( name, read16 ) \ | |
| 976 | READ_TEMPLATE_COND( 32, name, read16, read32be_with_16le_handler, ACCESSING_LSW32 ) | |
| 977 | ||
| 978 | ||
| 979 | #define WRITE16LETO32BE_LSW( name, write16 ) \ | |
| 980 | WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16le_handler, ACCESSING_LSW32 ) | |
| 981 | ||
| 982 | ||
| 983 | #define READWRITE16LETO32BE_LSW( name, read16, write16 ) \ | |
| 984 | READ16LETO32BE_LSW(name,read16) \ | |
| 985 | WRITE16LETO32BE_LSW(name,write16) | |
| 986 | ||
| 987 | ||
| 988 | /************************************* | |
| 989 | * 16be->32le, LSW mapping | |
| 990 | *************************************/ | |
| 991 | ||
| 992 | #define READ16BETO32LE_LSW( name, read16 ) \ | |
| 993 | READ_TEMPLATE_COND( 32, name, read16, read32le_with_16be_handler, ACCESSING_LSW32 ) | |
| 994 | ||
| 995 | ||
| 996 | #define WRITE16BETO32LE_LSW( name, write16 ) \ | |
| 997 | WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16be_handler, ACCESSING_LSW32 ) | |
| 998 | ||
| 999 | ||
| 1000 | #define READWRITE16BETO32LE_LSW( name, read16, write16 ) \ | |
| 1001 | READ16BETO32LE_LSW(name,read16) \ | |
| 1002 | WRITE16BETO32LE_LSW(name,write16) | |
| 1003 | ||
| 1004 | ||
| 1005 | /************************************* | |
| 1006 | * 16le->32le, LSW mapping | |
| 1007 | *************************************/ | |
| 1008 | ||
| 1009 | #define READ16LETO32LE_LSW( name, read16 ) \ | |
| 1010 | READ_TEMPLATE_COND( 32, name, read16, read32le_with_16le_handler, ACCESSING_LSW32 ) | |
| 1011 | ||
| 1012 | ||
| 1013 | #define WRITE16LETO32LE_LSW( name, write16 ) \ | |
| 1014 | WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16le_handler, ACCESSING_LSW32 ) | |
| 1015 | ||
| 1016 | ||
| 1017 | #define READWRITE16LETO32LE_LSW( name, read16, write16 ) \ | |
| 1018 | READ16LETO32LE_LSW(name,read16) \ | |
| 1019 | WRITE16LETO32LE_LSW(name,write16) | |
| 1020 |
| r936 | r937 | |
|---|---|---|
| 234 | 234 | static void palette_handler(ui_gfx_state *state) |
| 235 | 235 | { |
| 236 | 236 | int total = state->palette.which ? Machine->drv->color_table_len : Machine->drv->total_colors; |
| 237 | UINT16 *pens = state->palette.which ? Machine->game_colortable : NULL; | |
| 237 | const UINT16 *pens = state->palette.which ? Machine->game_colortable : NULL; | |
| 238 | 238 | const char *title = state->palette.which ? "COLORTABLE" : "PALETTE"; |
| 239 | rgb_t *raw_color = palette_ | |
| 239 | const rgb_t *raw_color = palette_ | |
| 240 | 240 | render_font *ui_font = ui_get_font(); |
| 241 | 241 | float cellwidth, cellheight; |
| 242 | 242 | float chwidth, chheight; |
| r936 | r937 | |
| 769 | 769 | }; |
| 770 | 770 | int width = (rotate & ORIENTATION_SWAP_XY) ? gfx->height : gfx->width; |
| 771 | 771 | int height = (rotate & ORIENTATION_SWAP_XY) ? gfx->width : gfx->height; |
| 772 | const pen_t *palette = (Machine->drv->total_colors != 0) ? palette_ | |
| 772 | const pen_t *palette = (Machine->drv->total_colors != 0) ? palette_ | |
| 773 | 773 | UINT32 rowpixels = bitmap->rowpixels; |
| 774 | 774 | const UINT16 *colortable = NULL; |
| 775 | 775 | UINT32 palette_mask = ~0; |
| r936 | r937 | |
| 777 | 777 | |
| 778 | 778 | /* select either the raw palette or the colortable */ |
| 779 | 779 | if (Machine->game_colortable != NULL) |
| 780 | colortable = &Machine->game_colortable[(gfx->colortable - Machine->remapped_colortable) + color * gfx->color_granularity]; | |
| 781 | else if (palette != NULL && gfx->colortable != NULL) | |
| 782 | palette += (gfx->colortable - Machine->remapped_colortable) + color * gfx->color_granularity; | |
| 780 | colortable = &Machine->game_colortable[gfx->color_base + color * gfx->color_granularity]; | |
| 781 | else if (palette != NULL) | |
| 782 | palette += gfx->color_base + color * gfx->color_granularity; | |
| 783 | 783 | else |
| 784 | 784 | { |
| 785 | 785 | palette = default_palette; |
| r936 | r937 | |
| 821 | 821 | s = src + effy * gfx->line_modulo; |
| 822 | 822 | |
| 823 | 823 | /* extract the pixel */ |
| 824 | if (gfx->flags & GFX_PACKED) | |
| 824 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 825 | 825 | pixel = (s[effx/2] >> ((effx & 1) * 4)) & 0xf; |
| 826 | 826 | else |
| 827 | 827 | pixel = s[effx]; |
| r936 | r937 | |
|---|---|---|
| 496 | 496 | case REGION_GFX7: fprintf(out, " region=\"gfx7\""); break; |
| 497 | 497 | case REGION_GFX8: fprintf(out, " region=\"gfx8\""); break; |
| 498 | 498 | case REGION_PROMS: fprintf(out, " region=\"proms\""); break; |
| 499 | case REGION_PLDS: fprintf(out, " region=\"plds\""); break; | |
| 499 | 500 | case REGION_SOUND1: fprintf(out, " region=\"sound1\""); break; |
| 500 | 501 | case REGION_SOUND2: fprintf(out, " region=\"sound2\""); break; |
| 501 | 502 | case REGION_SOUND3: fprintf(out, " region=\"sound3\""); break; |
| r936 | r937 | |
| 545 | 546 | |
| 546 | 547 | expand_machine_driver(game->drv, &drv); |
| 547 | 548 | |
| 548 | for( i = 0; i < MAX_SOUND && drv.sound[i].sound_type; i++ ) | |
| 549 | for( i = 0; i < MAX_SOUND && drv.sound[i].sound_type != SOUND_DUMMY; i++ ) | |
| 549 | 550 | { |
| 550 | 551 | const char **samplenames = NULL; |
| 551 | 552 | if( drv.sound[i].sound_type == SOUND_SAMPLES ) |
| r936 | r937 | |
| 572 | 573 | |
| 573 | 574 | expand_machine_driver(game->drv, &drv); |
| 574 | 575 | |
| 575 | for( i = 0; i < MAX_SOUND && drv.sound[i].sound_type; i++ ) | |
| 576 | for( i = 0; i < MAX_SOUND && drv.sound[i].sound_type != SOUND_DUMMY; i++ ) | |
| 576 | 577 | { |
| 577 | 578 | const char **samplenames = NULL; |
| 578 | 579 | if( drv.sound[i].sound_type == SOUND_SAMPLES ) |
| r936 | r937 | |
| 613 | 614 | |
| 614 | 615 | for(j=0;j<MAX_CPU;++j) |
| 615 | 616 | { |
| 616 | if (cpu[j].cpu_type!= | |
| 617 | if (cpu[j].cpu_type != CPU_DUMMY) | |
| 617 | 618 | { |
| 618 | 619 | fprintf(out, "\t\t<chip"); |
| 619 | 620 | fprintf(out, " type=\"cpu\""); |
| r936 | r937 | |
| 627 | 628 | |
| 628 | 629 | for(j=0;j<MAX_SOUND;++j) |
| 629 | 630 | { |
| 630 | if (sound[j].sound_type) | |
| 631 | if (sound[j].sound_type != SOUND_DUMMY) | |
| 631 | 632 | { |
| 632 | 633 | fprintf(out, "\t\t<chip"); |
| 633 | 634 | fprintf(out, " type=\"audio\""); |
| r936 | r937 | |
| 715 | 716 | i = 0; |
| 716 | 717 | while (i < MAX_SOUND && !has_sound) |
| 717 | 718 | { |
| 718 | if (sound[i].sound_type) | |
| 719 | if (sound[i].sound_type != SOUND_DUMMY) | |
| 719 | 720 | has_sound = 1; |
| 720 | 721 | ++i; |
| 721 | 722 | } |
| r936 | r937 | |
|---|---|---|
| 75 | 75 | { "throttle", "1", OPTION_BOOLEAN, "enable throttling to keep game running in sync with real time" }, |
| 76 | 76 | { "sleep", "1", OPTION_BOOLEAN, "enable sleeping, which gives time back to other applications when idle" }, |
| 77 | 77 | { "speed(0.01-100)", "1.0", 0, "controls the speed of gameplay, relative to realtime; smaller numbers are slower" }, |
| 78 | { "refreshspeed;rs", "0", OPTION_BOOLEAN, "automatically adjusts the speed of gameplay to keep the refresh rate lower than the screen" }, | |
| 78 | 79 | |
| 79 | 80 | /* rotation options */ |
| 80 | 81 | { NULL, NULL, OPTION_HEADER, "CORE ROTATION OPTIONS" }, |
| r936 | r937 | |
|---|---|---|
| 248 | 248 | into just two types now. Here is how to replicate that |
| 249 | 249 | functionality with the new system: |
| 250 | 250 | |
| 251 | TILEMAP_ | |
| 251 | TILEMAP_O | |
| 252 | 252 | you don't need to do anything; by default all pens map to |
| 253 | 253 | layer 0 and are thus non-transparent. Note that a lot of |
| 254 | 254 | code used to create OPAQUE tilemaps and then set the |
| 255 | 255 | transparent pen for them; this no longer works. |
| 256 | 256 | |
| 257 | TILEMAP_T | |
| 257 | TILEMAP_TRANSPARE | |
| 258 | 258 | transparent pen. To create the same effect, make a new tilemap |
| 259 | 259 | of type TILEMAP_TYPE_PEN, and then call |
| 260 | 260 | tilemap_set_transparent_pen() to specify which pen is |
| 261 | 261 | transparent; all other pens will map to layer 0. |
| 262 | 262 | |
| 263 | TILEMAP_T | |
| 263 | TILEMAP_TRANSPARENT_COLOR | |
| 264 | 264 | even has the same type name. Create a tilemap of type |
| 265 | 265 | TILEMAP_TYPE_COLORTABLE and call |
| 266 | 266 | tilemap_set_transparent_pen() to specify which remapped pen |
| 267 | 267 | is transparent. |
| 268 | 268 | |
| 269 | TILEMAP_T | |
| 269 | TILEMAP_BITMASK | |
| 270 | 270 | code, any tile_get_info callback can specify a bitmask which |
| 271 | 271 | will be processed after rendering to make some pixels |
| 272 | 272 | transparent. |
| 273 | 273 | |
| 274 | TILEMAP_ | |
| 274 | TILEMAP_S | |
| 275 | 275 | layers (called "front" and "back") based on their pens. It |
| 276 | 276 | also allowed for you to choose one of 4 mappings on a per-tile |
| 277 | 277 | basis. All of this functionality is now expanded: you can |
| r936 | r937 | |
| 281 | 281 | which still exists but maps onto the new behavior. The "front" |
| 282 | 282 | layer is now "layer 0" and the "back" layer is now "layer 1". |
| 283 | 283 | |
| 284 | TILEMAP_ | |
| 284 | TILEMAP_S | |
| 285 | 285 | and is not worth describing in detail how the new mapping |
| 286 | 286 | works. :) |
| 287 | 287 | |
| r936 | r937 | |
| 589 | 589 | const gfx_element * gfx = machine->gfx[gfxnum]; |
| 590 | 590 | int code = rawcode % gfx->total_elements; |
| 591 | 591 | tileinfo->pen_data = gfx->gfxdata + code * gfx->char_modulo; |
| 592 | tileinfo->palette_base = | |
| 592 | tileinfo->palette_base = | |
| 593 | 593 | tileinfo->flags = flags; |
| 594 | if (gfx->flags & GFX_PACKED) | |
| 594 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 595 | 595 | tileinfo->flags |= TILE_4BPP; |
| 596 | 596 | } |
| 597 | 597 |
| r936 | r937 | |
|---|---|---|
| 73 | 73 | #define OPTION_THROTTLE "throttle" |
| 74 | 74 | #define OPTION_SLEEP "sleep" |
| 75 | 75 | #define OPTION_SPEED "speed" |
| 76 | #define OPTION_REFRESHSPEED "refreshspeed" | |
| 76 | 77 | |
| 77 | 78 | /* core rotation options */ |
| 78 | 79 | #define OPTION_ROTATE "rotate" |
| r936 | r937 | |
|---|---|---|
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | /*************************************************************************** |
| 22 | GLOBAL VARIABLES | |
| 23 | ***************************************************************************/ | |
| 24 | ||
| 25 | static const game_driver *chd_gamedrv; | |
| 26 | ||
| 27 | ||
| 28 | ||
| 29 | /*************************************************************************** | |
| 30 | 22 | FUNCTION PROTOTYPES |
| 31 | 23 | ***************************************************************************/ |
| 32 | 24 | |
| r936 | r937 | |
| 34 | 26 | static int audit_one_disk(const rom_entry *rom, const game_driver *gamedrv, UINT32 validation, audit_record *record); |
| 35 | 27 | static int rom_used_by_parent(const game_driver *gamedrv, const rom_entry *romentry, const game_driver **parent); |
| 36 | 28 | |
| 37 | static chd_interface_file *audit_chd_open(const char *filename, const char *mode); | |
| 38 | static void audit_chd_close(chd_interface_file *file); | |
| 39 | static UINT32 audit_chd_read(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer); | |
| 40 | static UINT32 audit_chd_write(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer); | |
| 41 | static UINT64 audit_chd_length(chd_interface_file *file); | |
| 42 | 29 | |
| 43 | 30 | |
| 44 | ||
| 45 | 31 | /*************************************************************************** |
| 46 | HARD DISK INTERFACE | |
| 47 | ***************************************************************************/ | |
| 48 | ||
| 49 | static chd_interface audit_chd_interface = | |
| 50 | { | |
| 51 | audit_chd_open, | |
| 52 | audit_chd_close, | |
| 53 | audit_chd_read, | |
| 54 | audit_chd_write, | |
| 55 | audit_chd_length | |
| 56 | }; | |
| 57 | ||
| 58 | ||
| 59 | ||
| 60 | /*************************************************************************** | |
| 61 | 32 | INLINE FUNCTIONS |
| 62 | 33 | ***************************************************************************/ |
| 63 | 34 | |
| r936 | r937 | |
| 442 | 413 | |
| 443 | 414 | static int audit_one_disk(const rom_entry *rom, const game_driver *gamedrv, UINT32 validation, audit_record *record) |
| 444 | 415 | { |
| 416 | mame_file *source_file; | |
| 445 | 417 | chd_file *source; |
| 446 | 418 | chd_error err; |
| 447 | 419 | |
| r936 | r937 | |
| 451 | 423 | record->exphash = ROM_GETHASHDATA(rom); |
| 452 | 424 | |
| 453 | 425 | /* open the disk */ |
| 454 | chd_gamedrv = gamedrv; | |
| 455 | chd_set_interface(&audit_chd_interface); | |
| 456 | err = open_disk_image(gamedrv, rom, &source); | |
| 426 | err = open_disk_image(gamedrv, rom, &source_file, &source); | |
| 457 | 427 | |
| 458 | 428 | /* if we failed, report the error */ |
| 459 | 429 | if (err != CHDERR_NONE) |
| r936 | r937 | |
| 496 | 466 | set_status(record, AUDIT_STATUS_GOOD, SUBSTATUS_GOOD); |
| 497 | 467 | |
| 498 | 468 | chd_close(source); |
| 469 | mame_fclose(source_file); | |
| 499 | 470 | } |
| 500 | 471 | |
| 501 | 472 | /* return TRUE if we found anything at all */ |
| r936 | r937 | |
| 532 | 503 | |
| 533 | 504 | return FALSE; |
| 534 | 505 | } |
| 535 | ||
| 536 | ||
| 537 | ||
| 538 | /*************************************************************************** | |
| 539 | CHD INTERFACES | |
| 540 | ***************************************************************************/ | |
| 541 | ||
| 542 | /*------------------------------------------------- | |
| 543 | audit_chd_open - interface for opening | |
| 544 | a hard disk image | |
| 545 | -------------------------------------------------*/ | |
| 546 | ||
| 547 | static chd_interface_file *audit_chd_open(const char *filename, const char *mode) | |
| 548 | { | |
| 549 | const game_driver *drv; | |
| 550 | ||
| 551 | /* attempt reading up the chain through the parents */ | |
| 552 | for (drv = chd_gamedrv; drv != NULL; drv = driver_get_clone(drv)) | |
| 553 | { | |
| 554 | file_error filerr; | |
| 555 | mame_file *file; | |
| 556 | astring *fname; | |
| 557 | ||
| 558 | fname = astring_assemble_3(astring_alloc(), drv->name, PATH_SEPARATOR, filename); | |
| 559 | filerr = mame_fopen(SEARCHPATH_IMAGE, astring_c(fname), OPEN_FLAG_READ, &file); | |
| 560 | astring_free(fname); | |
| 561 | ||
| 562 | if (filerr == FILERR_NONE) | |
| 563 | return (chd_interface_file *)file; | |
| 564 | } | |
| 565 | return NULL; | |
| 566 | } | |
| 567 | ||
| 568 | ||
| 569 | /*------------------------------------------------- | |
| 570 | audit_chd_close - interface for closing | |
| 571 | a hard disk image | |
| 572 | -------------------------------------------------*/ | |
| 573 | ||
| 574 | static void audit_chd_close(chd_interface_file *file) | |
| 575 | { | |
| 576 | mame_fclose((mame_file *)file); | |
| 577 | } | |
| 578 | ||
| 579 | ||
| 580 | /*------------------------------------------------- | |
| 581 | audit_chd_read - interface for reading | |
| 582 | from a hard disk image | |
| 583 | -------------------------------------------------*/ | |
| 584 | ||
| 585 | static UINT32 audit_chd_read(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer) | |
| 586 | { | |
| 587 | mame_fseek((mame_file *)file, offset, SEEK_SET); | |
| 588 | return mame_fread((mame_file *)file, buffer, count); | |
| 589 | } | |
| 590 | ||
| 591 | ||
| 592 | /*------------------------------------------------- | |
| 593 | audit_chd_write - interface for writing | |
| 594 | to a hard disk image | |
| 595 | -------------------------------------------------*/ | |
| 596 | ||
| 597 | static UINT32 audit_chd_write(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer) | |
| 598 | { | |
| 599 | return 0; | |
| 600 | } | |
| 601 | ||
| 602 | ||
| 603 | /*------------------------------------------------- | |
| 604 | audit_chd_length - interface for getting | |
| 605 | the length a hard disk image | |
| 606 | -------------------------------------------------*/ | |
| 607 | ||
| 608 | static UINT64 audit_chd_length(chd_interface_file *file) | |
| 609 | { | |
| 610 | return mame_fsize((mame_file *)file); | |
| 611 | } |
| r936 | r937 | |
|---|---|---|
| 120 | 120 | UINT32 seconds_to_run; /* number of seconds to run before quitting */ |
| 121 | 121 | UINT8 auto_frameskip; /* flag: TRUE if we're automatically frameskipping */ |
| 122 | 122 | UINT32 speed; /* overall speed (*100) */ |
| 123 | UINT32 original_speed; /* originally-specified speed */ | |
| 124 | UINT8 refresh_speed; /* flag: TRUE if we max out our speed according to the refresh */ | |
| 123 | 125 | |
| 124 | 126 | /* frameskipping */ |
| 125 | 127 | UINT8 frameskip_level; /* current frameskip level */ |
| r936 | r937 | |
| 166 | 168 | static void init_buffered_spriteram(void); |
| 167 | 169 | |
| 168 | 170 | /* graphics decoding */ |
| 169 | static void allocate_graphics(const gfx_decode *gfxdecodeinfo); | |
| 170 | static void decode_graphics(const gfx_decode *gfxdecodeinfo); | |
| 171 | static void allocate_graphics(running_machine *machine, const gfx_decode *gfxdecodeinfo); | |
| 172 | static void decode_graphics(running_machine *machine, const gfx_decode *gfxdecodeinfo); | |
| 171 | 173 | |
| 172 | 174 | /* global rendering */ |
| 173 | 175 | static TIMER_CALLBACK( scanline0_callback ); |
| r936 | r937 | |
| 280 | 282 | global.auto_frameskip = options_get_bool(mame_options(), OPTION_AUTOFRAMESKIP); |
| 281 | 283 | global.frameskip_level = options_get_int(mame_options(), OPTION_FRAMESKIP); |
| 282 | 284 | global.seconds_to_run = options_get_int(mame_options(), OPTION_SECONDS_TO_RUN); |
| 283 | global.speed = (options_get_float(mame_options(), OPTION_SPEED) * 100.0 + 0.5); | |
| 285 | global.original_speed = global.speed = (options_get_float(mame_options(), OPTION_SPEED) * 100.0 + 0.5); | |
| 286 | global.refresh_speed = options_get_bool(mame_options(), OPTION_REFRESHSPEED); | |
| 284 | 287 | |
| 285 | 288 | /* allocate memory for our private data */ |
| 286 | 289 | viddata = machine->video_data = auto_malloc(sizeof(*viddata)); |
| r936 | r937 | |
| 331 | 334 | /* convert the gfx ROMs into character sets. This is done BEFORE calling the driver's */ |
| 332 | 335 | /* palette_init() routine because it might need to check the machine->gfx[] data */ |
| 333 | 336 | if (machine->drv->gfxdecodeinfo != NULL) |
| 334 | allocate_graphics(machine->drv->gfxdecodeinfo); | |
| 337 | allocate_graphics(machine, machine->drv->gfxdecodeinfo); | |
| 335 | 338 | |
| 336 | 339 | /* configure the palette */ |
| 337 | 340 | palette_config(machine); |
| 338 | 341 | |
| 339 | 342 | /* actually decode the graphics */ |
| 340 | 343 | if (machine->drv->gfxdecodeinfo != NULL) |
| 341 | decode_graphics(machine->drv->gfxdecodeinfo); | |
| 344 | decode_graphics(machine, machine->drv->gfxdecodeinfo); | |
| 342 | 345 | |
| 343 | 346 | /* reset video statics and get out of here */ |
| 344 | 347 | pdrawgfx_shadow_lowpri = 0; |
| r936 | r937 | |
| 482 | 485 | graphics |
| 483 | 486 | -------------------------------------------------*/ |
| 484 | 487 | |
| 485 | static void allocate_graphics(const gfx_decode *gfxdecodeinfo) | |
| 488 | static void allocate_graphics(running_machine *machine, const gfx_decode *gfxdecodeinfo) | |
| 486 | 489 | { |
| 487 | 490 | int i; |
| 488 | 491 | |
| r936 | r937 | |
| 578 | 581 | } |
| 579 | 582 | |
| 580 | 583 | /* allocate the graphics */ |
| 581 | | |
| 584 | machine->gfx[i] = allocgfx(&glcopy); | |
| 582 | 585 | |
| 583 | 586 | /* if we have a remapped colortable, point our local colortable to it */ |
| 584 | if (Machine->remapped_colortable != NULL) | |
| 585 | Machine->gfx[i]->colortable = &Machine->remapped_colortable[gfxdecodeinfo[i].color_codes_start]; | |
| 586 | Machine->gfx[i]->total_colors = gfxdecodeinfo[i].total_color_codes; | |
| 587 | machine->gfx[i]->total_colors = gfxdecodeinfo[i].total_color_codes; | |
| 588 | machine->gfx[i]->color_base = machine->drv->gfxdecodeinfo[i].color_codes_start; | |
| 587 | 589 | } |
| 588 | 590 | } |
| 589 | 591 | |
| r936 | r937 | |
| 592 | 594 | decode_graphics - decode the graphics |
| 593 | 595 | -------------------------------------------------*/ |
| 594 | 596 | |
| 595 | static void decode_graphics(const gfx_decode *gfxdecodeinfo) | |
| 597 | static void decode_graphics(running_machine *machine, const gfx_decode *gfxdecodeinfo) | |
| 596 | 598 | { |
| 597 | 599 | int totalgfx = 0, curgfx = 0; |
| 598 | 600 | char buffer[200]; |
| r936 | r937 | |
| 600 | 602 | |
| 601 | 603 | /* count total graphics elements */ |
| 602 | 604 | for (i = 0; i < MAX_GFX_ELEMENTS; i++) |
| 603 | if (Machine->gfx[i]) | |
| 604 | totalgfx += Machine->gfx[i]->total_elements; | |
| 605 | if (machine->gfx[i]) | |
| 606 | totalgfx += machine->gfx[i]->total_elements; | |
| 605 | 607 | |
| 606 | 608 | /* loop over all elements */ |
| 607 | 609 | for (i = 0; i < MAX_GFX_ELEMENTS; i++) |
| 608 | if ( | |
| 610 | if (machine->gfx[i] != NULL) | |
| 609 | 611 | { |
| 610 | 612 | /* if we have a valid region, decode it now */ |
| 611 | 613 | if (gfxdecodeinfo[i].memory_region > REGION_INVALID) |
| 612 | 614 | { |
| 613 | 615 | UINT8 *region_base = memory_region(gfxdecodeinfo[i].memory_region); |
| 614 | gfx_element *gfx = | |
| 616 | gfx_element *gfx = machine->gfx[i]; | |
| 615 | 617 | int j; |
| 616 | 618 | |
| 617 | 619 | /* now decode the actual graphics */ |
| r936 | r937 | |
| 629 | 631 | |
| 630 | 632 | /* otherwise, clear the target region */ |
| 631 | 633 | else |
| 632 | memset( | |
| 634 | memset(machine->gfx[i]->gfxdata, 0, machine->gfx[i]->char_modulo * machine->gfx[i]->total_elements); | |
| 633 | 635 | } |
| 634 | 636 | } |
| 635 | 637 | |
| r936 | r937 | |
| 694 | 696 | default: fatalerror("Invalid bitmap format!"); break; |
| 695 | 697 | } |
| 696 | 698 | |
| 697 | /* allocate | |
| 699 | /* allocate bi | |
| 698 | 700 | info->bitmap[0] = bitmap_alloc(curwidth, curheight, screen_format); |
| 701 | bitmap_set_palette(info->bitmap[0], Machine->palette); | |
| 699 | 702 | info->bitmap[1] = bitmap_alloc(curwidth, curheight, screen_format); |
| 703 | bitmap_set_palette(info->bitmap[1], Machine->palette); | |
| 704 | ||
| 705 | /* allocate textures */ | |
| 700 | 706 | info->texture[0] = render_texture_alloc(NULL, NULL); |
| 701 | 707 | render_texture_set_bitmap(info->texture[0], info->bitmap[0], visarea, info->config->palette_base, info->format); |
| 702 | 708 | info->texture[1] = render_texture_alloc(NULL, NULL); |
| r936 | r937 | |
| 714 | 720 | info->scantime = refresh / height; |
| 715 | 721 | info->pixeltime = refresh / (height * width); |
| 716 | 722 | |
| 723 | /* adjust speed if necessary */ | |
| 724 | if (global.refresh_speed) | |
| 725 | { | |
| 726 | float minrefresh = render_get_max_update_rate(); | |
| 727 | if (minrefresh != 0) | |
| 728 | { | |
| 729 | UINT32 target_speed = floor(minrefresh * 100.0 / SUBSECONDS_TO_HZ(refresh)); | |
| 730 | target_speed = MIN(target_speed, global.original_speed); | |
| 731 | if (target_speed != global.speed) | |
| 732 | { | |
| 733 | mame_printf_verbose("Adjusting target speed to %d%%\n", target_speed); | |
| 734 | global.speed = target_speed; | |
| 735 | } | |
| 736 | } | |
| 737 | } | |
| 738 | ||
| 717 | 739 | /* recompute the VBLANK timing */ |
| 718 | 740 | cpu_compute_vblank_timing(); |
| 719 | 741 | |
| r936 | r937 | |
| 1623 | 1645 | |
| 1624 | 1646 | void video_screen_save_snapshot(running_machine *machine, mame_file *fp, int scrnum) |
| 1625 | 1647 | { |
| 1648 | const rgb_t *palette = (machine->palette != NULL) ? palette_entry_list_adjusted(machine->palette) : NULL; | |
| 1626 | 1649 | png_info pnginfo = { 0 }; |
| 1627 | 1650 | mame_bitmap *bitmap; |
| 1628 | 1651 | png_error error; |
| r936 | r937 | |
| 1640 | 1663 | png_add_text(&pnginfo, "System", text); |
| 1641 | 1664 | |
| 1642 | 1665 | /* now do the actual work */ |
| 1643 | error = png_write_bitmap(mame_core_file(fp), &pnginfo, machine->video_data->snap_bitmap, machine->drv->total_colors, palette | |
| 1666 | error = png_write_bitmap(mame_core_file(fp), &pnginfo, machine->video_data->snap_bitmap, machine->drv->total_colors, palette | |
| 1644 | 1667 | |
| 1645 | 1668 | /* free any data allocated */ |
| 1646 | 1669 | png_free(&pnginfo); |
| r936 | r937 | |
| 1860 | 1883 | } |
| 1861 | 1884 | |
| 1862 | 1885 | /* write the next frame */ |
| 1863 | error = mng_capture_frame(mame_core_file(info->movie_file), &pnginfo, bitmap, machine->drv->total_colors, palette_ | |
| 1886 | error = mng_capture_frame(mame_core_file(info->movie_file), &pnginfo, bitmap, machine->drv->total_colors, palette_ | |
| 1864 | 1887 | png_free(&pnginfo); |
| 1865 | 1888 | if (error != PNGERR_NONE) |
| 1866 | 1889 | { |
| r936 | r937 | |
| 2037 | 2060 | |
| 2038 | 2061 | /*------------------------------------------------- |
| 2039 | 2062 | video_crosshair_set_screenmask_callback - |
| 2040 | install a callback to determine to which screen | |
| 2041 | crosshairs should be rendered | |
| 2063 | install a callback to determine to which screen | |
| 2064 | crosshairs should be rendered | |
| 2042 | 2065 | -------------------------------------------------*/ |
| 2043 | 2066 | |
| 2044 | 2067 | void video_crosshair_set_screenmask_callback(running_machine *machine, UINT32 (*get_screen_mask)(int player)) |
| r936 | r937 | |
|---|---|---|
| 40 | 40 | $(EMUOBJ)/drawgfx.o \ |
| 41 | 41 | $(EMUOBJ)/driver.o \ |
| 42 | 42 | $(EMUOBJ)/emuopts.o \ |
| 43 | $(EMUOBJ)/emupal.o \ | |
| 43 | 44 | $(EMUOBJ)/fileio.o \ |
| 44 | 45 | $(EMUOBJ)/hash.o \ |
| 45 | 46 | $(EMUOBJ)/info.o \ |
| r936 | r937 | |
| 50 | 51 | $(EMUOBJ)/mamecore.o \ |
| 51 | 52 | $(EMUOBJ)/memory.o \ |
| 52 | 53 | $(EMUOBJ)/output.o \ |
| 53 | $(EMUOBJ)/palette.o \ | |
| 54 | 54 | $(EMUOBJ)/render.o \ |
| 55 | 55 | $(EMUOBJ)/rendfont.o \ |
| 56 | 56 | $(EMUOBJ)/rendlay.o \ |
| r936 | r937 | |
|---|---|---|
| 168 | 168 | /* video-related information */ |
| 169 | 169 | gfx_element * gfx[MAX_GFX_ELEMENTS];/* array of pointers to graphic sets (chars, sprites) */ |
| 170 | 170 | screen_state screen[MAX_SCREENS];/* current screen state */ |
| 171 | palette_t * palette; /* global palette object */ | |
| 171 | 172 | |
| 172 | 173 | /* palette-related information */ |
| 173 | pen_t * pens; /* remapped palette pen numbers */ | |
| 174 | UINT16 * game_colortable; /* lookup table used to map gfx pen numbers to color numbers */ | |
| 175 | pen_t * remapped_colortable;/* the above, already remapped through Machine->pens */ | |
| 174 | /* fix me - some games try to modify remapped_colortable directly */ | |
| 175 | /* search for "palette hack" to find instances */ | |
| 176 | const pen_t * pens; /* remapped palette pen numbers */ | |
| 177 | const UINT16 * game_colortable; /* lookup table used to map gfx pen numbers to color numbers */ | |
| 178 | const pen_t * remapped_colortable;/* the above, already remapped through Machine->pens */ | |
| 176 | 179 | pen_t * shadow_table; /* table for looking up a shadowed pen */ |
| 177 | 180 | |
| 178 | 181 | /* audio-related information */ |
| r936 | r937 | |
|---|---|---|
| 160 | 160 | void m37702_get_info(UINT32 state, cpuinfo *info); |
| 161 | 161 | void m37710_get_info(UINT32 state, cpuinfo *info); |
| 162 | 162 | void ppc403_get_info(UINT32 state, cpuinfo *info); |
| 163 | void ppc601_get_info(UINT32 state, cpuinfo *info); | |
| 163 | 164 | void ppc602_get_info(UINT32 state, cpuinfo *info); |
| 164 | 165 | void ppc603_get_info(UINT32 state, cpuinfo *info); |
| 165 | 166 | void mpc8240_get_info(UINT32 state, cpuinfo *info); |
| r936 | r937 | |
| 671 | 672 | #if (HAS_PPC403) |
| 672 | 673 | { CPU_PPC403, ppc403_get_info }, |
| 673 | 674 | #endif |
| 675 | #if (HAS_PPC601) | |
| 676 | { CPU_PPC601, ppc601_get_info }, | |
| 677 | #endif | |
| 674 | 678 | #if (HAS_PPC602) |
| 675 | 679 | { CPU_PPC602, ppc602_get_info }, |
| 676 | 680 | #endif |
| r936 | r937 | |
|---|---|---|
| 74 | 74 | /* pen_t is used to represent pixel values in bitmaps */ |
| 75 | 75 | typedef UINT32 pen_t; |
| 76 | 76 | |
| 77 | /* rgb_t is used to represent 32-bit (A)RGB values */ | |
| 78 | typedef UINT32 rgb_t; | |
| 79 | ||
| 80 | 77 | /* stream_sample_t is used to represent a single sample in a sound stream */ |
| 81 | 78 | typedef INT32 stream_sample_t; |
| 82 | 79 |
| r936 | r937 | |
|---|---|---|
| 972 | 972 | bitmap_free(tempbitmap); |
| 973 | 973 | } |
| 974 | 974 | |
| 975 | ||
| 975 | 976 | /*------------------------------------------------- |
| 976 | 977 | layout_element_draw_led14segsc - draw a |
| 977 | 978 | 14-segment LCD with semicolon (2 extra segments) |
| r936 | r937 | |
| 1202 | 1203 | bitmap_free(tempbitmap); |
| 1203 | 1204 | } |
| 1204 | 1205 | |
| 1206 | ||
| 1205 | 1207 | /*------------------------------------------------- |
| 1206 | 1208 | layout_element_draw_led16segsc - draw a |
| 1207 | 1209 | 16-segment LCD with semicolon (2 extra segments) |
| 1208 | 1210 | -------------------------------------------------*/ |
| 1211 | ||
| 1209 | 1212 | static void layout_element_draw_led16segsc(mame_bitmap *dest, const rectangle *bounds, const render_color *color, int pattern) |
| 1210 | 1213 | { |
| 1211 | 1214 | const rgb_t onpen = MAKE_ARGB(0xff, 0xff, 0xff, 0xff); |
| r936 | r937 | |
| 1325 | 1328 | bitmap_free(tempbitmap); |
| 1326 | 1329 | } |
| 1327 | 1330 | |
| 1331 | ||
| 1332 | ||
| 1328 | 1333 | /*************************************************************************** |
| 1329 | 1334 | LAYOUT FILE PARSING |
| 1330 | 1335 | ***************************************************************************/ |
| r936 | r937 | |
|---|---|---|
| 171 | 171 | CPU_M37702, |
| 172 | 172 | CPU_M37710, |
| 173 | 173 | CPU_PPC403, |
| 174 | CPU_PPC601, | |
| 174 | 175 | CPU_PPC602, |
| 175 | 176 | CPU_PPC603, |
| 176 | 177 | CPU_MPC8240, |
| r936 | r937 | |
|---|---|---|
| 1084 | 1084 | bufptr += sprintf(bufptr, "%s\n%s %s\n\n%s:\n", Machine->gamedrv->description, Machine->gamedrv->year, Machine->gamedrv->manufacturer, ui_getstring(UI_cpu)); |
| 1085 | 1085 | |
| 1086 | 1086 | /* loop over all CPUs */ |
| 1087 | for (cpunum = 0; cpunum < MAX_CPU && Machine->drv->cpu[cpunum].cpu_type; cpunum += count) | |
| 1087 | for (cpunum = 0; cpunum < MAX_CPU && Machine->drv->cpu[cpunum].cpu_type != CPU_DUMMY; cpunum += count) | |
| 1088 | 1088 | { |
| 1089 | 1089 | int type = Machine->drv->cpu[cpunum].cpu_type; |
| 1090 | 1090 | int clock = Machine->drv->cpu[cpunum].cpu_clock; |
| r936 | r937 | |
| 1111 | 1111 | bufptr += sprintf(bufptr, "\n%s:\n", ui_getstring(UI_sound)); |
| 1112 | 1112 | |
| 1113 | 1113 | /* loop over all sound chips */ |
| 1114 | for (sndnum = 0; sndnum < MAX_SOUND && Machine->drv->sound[sndnum].sound_type; sndnum += count) | |
| 1114 | for (sndnum = 0; sndnum < MAX_SOUND && Machine->drv->sound[sndnum].sound_type != SOUND_DUMMY; sndnum += count) | |
| 1115 | 1115 | { |
| 1116 | 1116 | int type = Machine->drv->sound[sndnum].sound_type; |
| 1117 | 1117 | int clock = sndnum_clock(sndnum); |
| r936 | r937 | |
|---|---|---|
| 259 | 259 | |
| 260 | 260 | /* stop all the sound chips */ |
| 261 | 261 | for (sndnum = 0; sndnum < MAX_SOUND; sndnum++) |
| 262 | if (Machine->drv->sound[sndnum].sound_type != | |
| 262 | if (Machine->drv->sound[sndnum].sound_type != SOUND_DUMMY) | |
| 263 | 263 | sndintrf_exit_sound(sndnum); |
| 264 | 264 | |
| 265 | 265 | /* reset variables */ |
| r936 | r937 | |
| 296 | 296 | int index; |
| 297 | 297 | |
| 298 | 298 | /* stop when we hit an empty entry */ |
| 299 | if (msound->sound_type == | |
| 299 | if (msound->sound_type == SOUND_DUMMY) | |
| 300 | 300 | break; |
| 301 | 301 | totalsnd++; |
| 302 | 302 | |
| r936 | r937 | |
| 517 | 517 | |
| 518 | 518 | /* reset all the sound chips */ |
| 519 | 519 | for (sndnum = 0; sndnum < MAX_SOUND; sndnum++) |
| 520 | if (Machine->drv->sound[sndnum].sound_type != | |
| 520 | if (Machine->drv->sound[sndnum].sound_type != SOUND_DUMMY) | |
| 521 | 521 | sndnum_reset(sndnum); |
| 522 | 522 | } |
| 523 | 523 |
| r936 | r937 | |
|---|---|---|
| 76 | 76 | int cpunum; |
| 77 | 77 | |
| 78 | 78 | for (cpunum = 0; cpunum < MAX_CPU; cpunum++) |
| 79 | if (machine->cpu[cpunum].cpu_type == | |
| 79 | if (machine->cpu[cpunum].cpu_type == CPU_DUMMY) | |
| 80 | 80 | { |
| 81 | 81 | machine->cpu[cpunum].tag = tag; |
| 82 | 82 | machine->cpu[cpunum].cpu_type = type; |
| r936 | r937 | |
| 201 | 201 | int soundnum; |
| 202 | 202 | |
| 203 | 203 | for (soundnum = 0; soundnum < MAX_SOUND; soundnum++) |
| 204 | if (machine->sound[soundnum].sound_type == | |
| 204 | if (machine->sound[soundnum].sound_type == SOUND_DUMMY) | |
| 205 | 205 | { |
| 206 | 206 | machine->sound[soundnum].tag = tag; |
| 207 | 207 | machine->sound[soundnum].sound_type = type; |
| r936 | r937 | |
|---|---|---|
| 62 | 62 | #include "sndintrf.h" |
| 63 | 63 | #include "fileio.h" |
| 64 | 64 | #include "drawgfx.h" |
| 65 | #include "pal | |
| 65 | #include "emupal | |
| 66 | 66 | #include "sound.h" |
| 67 | 67 | #include "input.h" |
| 68 | 68 | #include "inptport.h" |
| r936 | r937 | |
|---|---|---|
| 128 | 128 | return; |
| 129 | 129 | |
| 130 | 130 | /* packed case */ |
| 131 | if (gfx->flags & GFX_PACKED) | |
| 131 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 132 | 132 | { |
| 133 | 133 | for (y = 0; y < gfx->height; y++) |
| 134 | 134 | { |
| r936 | r937 | |
| 172 | 172 | memset(dp, 0, gfx->char_modulo); |
| 173 | 173 | |
| 174 | 174 | /* packed case */ |
| 175 | if (gfx->flags & GFX_PACKED) | |
| 175 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 176 | 176 | { |
| 177 | 177 | for (plane = 0; plane < gl->planes; plane++) |
| 178 | 178 | { |
| r936 | r937 | |
| 257 | 257 | gfx->width = gl->width; |
| 258 | 258 | gfx->height = gl->height; |
| 259 | 259 | gfx->total_elements = gl->total; |
| 260 | gfx->color_depth = 1 << gl->planes; | |
| 260 | 261 | gfx->color_granularity = 1 << gl->planes; |
| 261 | 262 | if (gfx->color_granularity <= 32) |
| 262 | 263 | gfx->pen_usage = malloc_or_die(gfx->total_elements * sizeof(*gfx->pen_usage)); |
| r936 | r937 | |
| 269 | 270 | gfx->char_modulo = gl->charincrement / 8; |
| 270 | 271 | |
| 271 | 272 | /* don't free the data because we will get a pointer at decode time */ |
| 272 | gfx->flags |= GFX_DONT_FREE | |
| 273 | gfx->flags |= GFX_ELEMENT_DONT_FREE | |
| 273 | 274 | if (gl->planes <= 4) |
| 274 | gfx->flags |= GFX_PACKED; | |
| 275 | gfx->flags |= GFX_ELEMENT_PACKED; | |
| 275 | 276 | } |
| 276 | 277 | |
| 277 | 278 | /* decoded graphics case */ |
| r936 | r937 | |
| 304 | 305 | assert(last < gfx->total_elements); |
| 305 | 306 | |
| 306 | 307 | /* if this is raw graphics data, just set the pointer and compute pen usage */ |
| 307 | if (gfx->flags & GFX_DONT_FREE | |
| 308 | if (gfx->flags & GFX_ELEMENT_DONT_FREE | |
| 308 | 309 | { |
| 309 | 310 | /* if we got a pointer, set it */ |
| 310 | 311 | if (first == 0 && src) |
| r936 | r937 | |
| 341 | 342 | free((void *)gfx->layout.extxoffs); |
| 342 | 343 | if (gfx->pen_usage) |
| 343 | 344 | free(gfx->pen_usage); |
| 344 | if (!(gfx->flags & GFX_DONT_FREE | |
| 345 | if (!(gfx->flags & GFX_ELEMENT_DONT_FREE | |
| 345 | 346 | free(gfx->gfxdata); |
| 346 | 347 | free(gfx); |
| 347 | 348 | } |
| r936 | r937 | |
| 915 | 916 | mame_bitmap *pri_buffer,UINT32 pri_mask) |
| 916 | 917 | { |
| 917 | 918 | assert_always(gfx, "drawgfx() gfx == 0"); |
| 918 | assert_always(gfx->colortable || is_raw[transparency], "drawgfx() gfx->colortable == 0"); | |
| 919 | 919 | |
| 920 | 920 | code %= gfx->total_elements; |
| 921 | 921 | if (!is_raw[transparency]) |
| r936 | r937 | |
| 1402 | 1402 | /* ASG 980209 -- added 16-bit version */ |
| 1403 | 1403 | if (dest_bmp->bpp == 8) |
| 1404 | 1404 | { |
| 1405 | if( gfx | |
| 1405 | if( gfx | |
| 1406 | 1406 | { |
| 1407 | const pen_t *pal = & | |
| 1407 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 1408 | 1408 | UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| 1409 | 1409 | |
| 1410 | 1410 | int sprite_screen_height = (scaley*gfx->height+0x8000)>>16; |
| r936 | r937 | |
| 1478 | 1478 | { |
| 1479 | 1479 | if (pri_buffer) |
| 1480 | 1480 | { |
| 1481 | if (gfx->flags & GFX_PACKED) | |
| 1481 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 1482 | 1482 | { |
| 1483 | 1483 | for( y=sy; y<ey; y++ ) |
| 1484 | 1484 | { |
| r936 | r937 | |
| 1520 | 1520 | } |
| 1521 | 1521 | else |
| 1522 | 1522 | { |
| 1523 | if (gfx->flags & GFX_PACKED) | |
| 1523 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 1524 | 1524 | { |
| 1525 | 1525 | for( y=sy; y<ey; y++ ) |
| 1526 | 1526 | { |
| r936 | r937 | |
| 1562 | 1562 | { |
| 1563 | 1563 | if (pri_buffer) |
| 1564 | 1564 | { |
| 1565 | if (gfx->flags & GFX_PACKED) | |
| 1565 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 1566 | 1566 | { |
| 1567 | 1567 | for( y=sy; y<ey; y++ ) |
| 1568 | 1568 | { |
| r936 | r937 | |
| 1613 | 1613 | } |
| 1614 | 1614 | else |
| 1615 | 1615 | { |
| 1616 | if (gfx->flags & GFX_PACKED) | |
| 1616 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 1617 | 1617 | { |
| 1618 | 1618 | for( y=sy; y<ey; y++ ) |
| 1619 | 1619 | { |
| r936 | r937 | |
| 1996 | 1996 | /* ASG 980209 -- new 16-bit part */ |
| 1997 | 1997 | else if (dest_bmp->bpp == 16) |
| 1998 | 1998 | { |
| 1999 | if( gfx | |
| 1999 | if( gfx | |
| 2000 | 2000 | { |
| 2001 | const pen_t *pal = & | |
| 2001 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 2002 | 2002 | UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| 2003 | 2003 | |
| 2004 | 2004 | int sprite_screen_height = (scaley*gfx->height+0x8000)>>16; |
| r936 | r937 | |
| 2072 | 2072 | { |
| 2073 | 2073 | if (pri_buffer) |
| 2074 | 2074 | { |
| 2075 | if (gfx->flags & GFX_PACKED) | |
| 2075 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 2076 | 2076 | { |
| 2077 | 2077 | for( y=sy; y<ey; y++ ) |
| 2078 | 2078 | { |
| r936 | r937 | |
| 2115 | 2115 | } |
| 2116 | 2116 | else |
| 2117 | 2117 | { |
| 2118 | if (gfx->flags & GFX_PACKED) | |
| 2118 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 2119 | 2119 | { |
| 2120 | 2120 | for( y=sy; y<ey; y++ ) |
| 2121 | 2121 | { |
| r936 | r937 | |
| 2157 | 2157 | { |
| 2158 | 2158 | if (pri_buffer) |
| 2159 | 2159 | { |
| 2160 | if (gfx->flags & GFX_PACKED) | |
| 2160 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 2161 | 2161 | { |
| 2162 | 2162 | for( y=sy; y<ey; y++ ) |
| 2163 | 2163 | { |
| r936 | r937 | |
| 2208 | 2208 | } |
| 2209 | 2209 | else |
| 2210 | 2210 | { |
| 2211 | if (gfx->flags & GFX_PACKED) | |
| 2211 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 2212 | 2212 | { |
| 2213 | 2213 | for( y=sy; y<ey; y++ ) |
| 2214 | 2214 | { |
| r936 | r937 | |
| 2697 | 2697 | } |
| 2698 | 2698 | else |
| 2699 | 2699 | { |
| 2700 | if( gfx | |
| 2700 | if( gfx | |
| 2701 | 2701 | { |
| 2702 | const pen_t *pal = & | |
| 2702 | const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; | |
| 2703 | 2703 | UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo; |
| 2704 | 2704 | |
| 2705 | 2705 | int sprite_screen_height = (scaley*gfx->height+0x8000)>>16; |
| r936 | r937 | |
| 4950 | 4950 | int dw = ex-sx+1; /* dest width */ |
| 4951 | 4951 | int dh = ey-sy+1; /* dest height */ |
| 4952 | 4952 | int dm = dest->rowpixels; /* dest modulo */ |
| 4953 | const pen_t *paldata = & | |
| 4953 | const pen_t *paldata = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * color]; | |
| 4954 | 4954 | UINT8 *pribuf = (pri_buffer) ? BITMAP_ADDR8(pri_buffer, sy, sx) : NULL; |
| 4955 | 4955 | |
| 4956 | 4956 | /* optimizations for 1:1 mapping */ |
| r936 | r937 | |
| 4983 | 4983 | switch (transparency) |
| 4984 | 4984 | { |
| 4985 | 4985 | case TRANSPARENCY_NONE: |
| 4986 | if (gfx->flags & GFX_PACKED) | |
| 4986 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 4987 | 4987 | { |
| 4988 | 4988 | if (pribuf) |
| 4989 | 4989 | BLOCKMOVEPRI(4toN_opaque,(sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,paldata,pribuf,pri_mask)); |
| r936 | r937 | |
| 5000 | 5000 | break; |
| 5001 | 5001 | |
| 5002 | 5002 | case TRANSPARENCY_NONE_RAW: |
| 5003 | if (gfx->flags & GFX_PACKED) | |
| 5003 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 5004 | 5004 | { |
| 5005 | 5005 | if (pribuf) |
| 5006 | 5006 | BLOCKMOVERAWPRI(4toN_opaque,(sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,color,pribuf,pri_mask)); |
| r936 | r937 | |
| 5017 | 5017 | break; |
| 5018 | 5018 | |
| 5019 | 5019 | case TRANSPARENCY_PEN: |
| 5020 | if (gfx->flags & GFX_PACKED) | |
| 5020 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 5021 | 5021 | { |
| 5022 | 5022 | if (pribuf) |
| 5023 | 5023 | BLOCKMOVEPRI(4toN_transpen,(sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,paldata,pribuf,pri_mask,transparent_color)); |
| r936 | r937 | |
| 5034 | 5034 | break; |
| 5035 | 5035 | |
| 5036 | 5036 | case TRANSPARENCY_PEN_RAW: |
| 5037 | if (gfx->flags & GFX_PACKED) | |
| 5037 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 5038 | 5038 | { |
| 5039 | 5039 | if (pribuf) |
| 5040 | 5040 | BLOCKMOVERAWPRI(4toN_transpen,(sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,color,pribuf,pri_mask,transparent_color)); |
| r936 | r937 | |
| 5065 | 5065 | break; |
| 5066 | 5066 | |
| 5067 | 5067 | case TRANSPARENCY_COLOR: |
| 5068 | if (gfx->flags & GFX_PACKED) | |
| 5068 | if (gfx->flags & GFX_ELEMENT_PACKED) | |
| 5069 | 5069 | { |
| 5070 | 5070 | if (pribuf) |
| 5071 | 5071 | BLOCKMOVEPRI(4toN_transcolor,(sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,paldata,pribuf,pri_mask,Machine->game_colortable + (paldata - Machine->remapped_colortable),transparent_color)); |
| r936 | r937 | |
| 5493 | 5493 | |
| 5494 | 5494 | DECLAREG(draw_scanline, ( |
| 5495 | 5495 | mame_bitmap *bitmap,int x,int y,int length, |
| 5496 | const DATA_TYPE *src,pen_t *pens,int transparent_pen), | |
| 5496 | const DATA_TYPE *src,const pen_t *pens,int transparent_pen), | |
| 5497 | 5497 | { |
| 5498 | 5498 | /* 8bpp destination */ |
| 5499 | 5499 | if (bitmap->bpp == 8) |
| r936 | r937 | |
| 5633 | 5633 | |
| 5634 | 5634 | DECLAREG(pdraw_scanline, ( |
| 5635 | 5635 | mame_bitmap *bitmap,int x,int y,int length, |
| 5636 | const DATA_TYPE *src,pen_t *pens,int transparent_pen,int pri), | |
| 5636 | const DATA_TYPE *src,const pen_t *pens,int transparent_pen,int pri), | |
| 5637 | 5637 | { |
| 5638 | 5638 | /* 8bpp destination */ |
| 5639 | 5639 | if (bitmap->bpp == 8) |
| r936 | r937 | |
|---|---|---|
| 16 | 16 | |
| 17 | 17 | #include "mamecore.h" |
| 18 | 18 | |
| 19 | #define MAX_GFX_PLANES 8 | |
| 20 | #define MAX_GFX_SIZE 32 | |
| 21 | #define MAX_ABS_GFX_SIZE 1024 | |
| 22 | 19 | |
| 23 | #define EXTENDED_XOFFS { 0 } | |
| 24 | #define EXTENDED_YOFFS { 0 } | |
| 25 | 20 | |
| 26 | #define RGN_FRAC(num,den) (0x80000000 | (((num) & 0x0f) << 27) | (((den) & 0x0f) << 23)) | |
| 27 | #define IS_FRAC(offset) ((offset) & 0x80000000) | |
| 28 | #define FRAC_NUM(offset) (((offset) >> 27) & 0x0f) | |
| 29 | #define FRAC_DEN(offset) (((offset) >> 23) & 0x0f) | |
| 30 | #define FRAC_OFFSET(offset) ((offset) & 0x007fffff) | |
| 21 | /*************************************************************************** | |
| 22 | CONSTANTS | |
| 23 | ***************************************************************************/ | |
| 31 | 24 | |
| 32 | #define STEP2(START,STEP) (START),(START)+(STEP) | |
| 33 | #define STEP4(START,STEP) STEP2(START,STEP),STEP2((START)+2*(STEP),STEP) | |
| 34 | #define STEP8(START,STEP) STEP4(START,STEP),STEP4((START)+4*(STEP),STEP) | |
| 35 | #define STEP16(START,STEP) STEP8(START,STEP),STEP8((START)+8*(STEP),STEP) | |
| 36 | #define STEP32(START,STEP) STEP16(START,STEP),STEP16((START)+16*(STEP),STEP) | |
| 25 | #define MAX_GFX_PLANES 8 | |
| 26 | #define MAX_GFX_SIZE 32 | |
| 27 | #define MAX_ABS_GFX_SIZE 1024 | |
| 37 | 28 | |
| 29 | #define EXTENDED_XOFFS { 0 } | |
| 30 | #define EXTENDED_YOFFS { 0 } | |
| 38 | 31 | |
| 39 | struct _gfx_layout | |
| 40 | { | |
| 41 | UINT16 width,height; /* width and height (in pixels) of chars/sprites */ | |
| 42 | UINT32 total; /* total number of chars/sprites in the rom */ | |
| 43 | UINT16 planes; /* number of bitplanes */ | |
| 44 | UINT32 planeoffset[MAX_GFX_PLANES]; /* start of every bitplane (in bits) */ | |
| 45 | UINT32 xoffset[MAX_GFX_SIZE]; /* position of the bit corresponding to the pixel */ | |
| 46 | UINT32 yoffset[MAX_GFX_SIZE]; /* of the given coordinates */ | |
| 47 | UINT32 charincrement; /* distance between two consecutive characters/sprites (in bits) */ | |
| 48 | const UINT32 *extxoffs; /* extended X offset array for really big layouts */ | |
| 49 | const UINT32 *extyoffs; /* extended Y offset array for really big layouts */ | |
| 50 | }; | |
| 51 | typedef struct _gfx_layout gfx_layout; | |
| 32 | #define GFX_ELEMENT_PACKED 1 /* two 4bpp pixels are packed in one byte of gfxdata */ | |
| 33 | #define GFX_ELEMENT_DONT_FREE 2 /* gfxdata was not malloc()ed, so don't free it on exit */ | |
| 52 | 34 | |
| 53 | #define GFX_RAW 0x12345678 | |
| 35 | #define GFX_RAW 0x12345678 | |
| 54 | 36 | /* When planeoffset[0] is set to GFX_RAW, the gfx data is left as-is, with no conversion. |
| 55 | 37 | No buffer is allocated for the decoded data, and gfxdata is set to point to the source |
| 56 | 38 | data; therefore, you must not use ROMREGION_DISPOSE. |
| 57 | 39 | xoffset[0] is an optional displacement (*8) from the beginning of the source data, while |
| 58 | 40 | yoffset[0] is the line modulo (*8) and charincrement the char modulo (*8). They are *8 |
| 59 | 41 | for consistency with the usual behaviour, but the bottom 3 bits are not used. |
| 60 | GFX_PACKED is automatically set if planes is <= 4. | |
| 42 | GFX_ELEMENT_PACKED is automatically set if planes is <= 4. | |
| 61 | 43 | |
| 62 | 44 | This special mode can be used to save memory in games that require several different |
| 63 | 45 | handlings of the same ROM data (e.g. metro.c can use both 4bpp and 8bpp tiles, and both |
| r936 | r937 | |
| 66 | 48 | not be prerotated and will rely on GFX_SWAPXY. |
| 67 | 49 | */ |
| 68 | 50 | |
| 69 | ||
| 51 | ||
| 70 | 52 | { |
| 71 | UINT16 width,height; | |
| 53 | TRANSPARENCY_NONE, /* opaque with remapping */ | |
| 54 | TRANSPARENCY_NONE_RAW, /* opaque with no remapping */ | |
| 55 | TRANSPARENCY_PEN, /* single pen transparency with remapping */ | |
| 56 | TRANSPARENCY_PEN_RAW, /* single pen transparency with no remapping */ | |
| 57 | TRANSPARENCY_PENS, /* multiple pen transparency with remapping */ | |
| 58 | TRANSPARENCY_PENS_RAW, /* multiple pen transparency with no remapping */ | |
| 59 | TRANSPARENCY_COLOR, /* single remapped pen transparency with remapping */ | |
| 60 | TRANSPARENCY_PEN_TABLE, /* special pen remapping modes (see DRAWMODE_xxx below) with remapping */ | |
| 61 | TRANSPARENCY_PEN_TABLE_RAW, /* special pen remapping modes (see DRAWMODE_xxx below) with no remapping */ | |
| 62 | TRANSPARENCY_BLEND, /* blend two bitmaps, shifting the source and ORing to the dest with remapping */ | |
| 63 | TRANSPARENCY_BLEND_RAW, /* blend two bitmaps, shifting the source and ORing to the dest with no remapping */ | |
| 64 | TRANSPARENCY_ALPHA, /* single pen transparency, other pens alpha */ | |
| 65 | TRANSPARENCY_ALPHARANGE, /* single pen transparency, multiple pens alpha depending on array, see psikyosh.c */ | |
| 72 | 66 | |
| 73 | UINT32 total_elements; /* total number of characters/sprites */ | |
| 74 | UINT16 color_granularity; /* number of colors for each color code */ | |
| 75 | /* (for example, 4 for 2 bitplanes gfx) */ | |
| 76 | UINT32 total_colors; | |
| 77 | pen_t *colortable; /* map color codes to screen pens */ | |
| 78 | UINT32 *pen_usage; /* an array of total_elements entries. */ | |
| 79 | /* It is a table of the pens each character uses */ | |
| 80 | /* (bit 0 = pen 0, and so on). This is used by */ | |
| 81 | /* drawgfgx() to do optimizations like skipping */ | |
| 82 | /* drawing of a totally transparent character */ | |
| 83 | UINT8 *gfxdata; /* pixel data */ | |
| 84 | UINT32 line_modulo; /* amount to add to get to the next line (usually = width) */ | |
| 85 | UINT32 char_modulo; /* = line_modulo * height */ | |
| 86 | UINT32 flags; | |
| 87 | gfx_layout layout; /* references the original layout */ | |
| 67 | TRANSPARENCY_MODES /* total number of modes; must be last */ | |
| 88 | 68 | }; |
| 69 | ||
| 70 | enum | |
| 71 | { | |
| 72 | DRAWMODE_NONE, | |
| 73 | DRAWMODE_SOURCE, | |
| 74 | DRAWMODE_SHADOW | |
| 75 | }; | |
| 76 | ||
| 77 | ||
| 78 | ||
| 79 | /*************************************************************************** | |
| 80 | MACROS | |
| 81 | ***************************************************************************/ | |
| 82 | ||
| 83 | /* map old fillbitmap to new shared bitmap_fill code */ | |
| 84 | #define fillbitmap(dest, pen, clip) bitmap_fill(dest, clip, pen) | |
| 85 | ||
| 86 | /* these macros describe gfx_layouts in terms of fractions of a region */ | |
| 87 | /* they can be used for total, planeoffset, xoffset, yoffset */ | |
| 88 | #define RGN_FRAC(num,den) (0x80000000 | (((num) & 0x0f) << 27) | (((den) & 0x0f) << 23)) | |
| 89 | #define IS_FRAC(offset) ((offset) & 0x80000000) | |
| 90 | #define FRAC_NUM(offset) (((offset) >> 27) & 0x0f) | |
| 91 | #define FRAC_DEN(offset) (((offset) >> 23) & 0x0f) | |
| 92 | #define FRAC_OFFSET(offset) ((offset) & 0x007fffff) | |
| 93 | ||
| 94 | /* these macros are useful in gfx_layouts */ | |
| 95 | #define STEP2(START,STEP) (START),(START)+(STEP) | |
| 96 | #define STEP4(START,STEP) STEP2(START,STEP),STEP2((START)+2*(STEP),STEP) | |
| 97 | #define STEP8(START,STEP) STEP4(START,STEP),STEP4((START)+4*(STEP),STEP) | |
| 98 | #define STEP16(START,STEP) STEP8(START,STEP),STEP8((START)+8*(STEP),STEP) | |
| 99 | #define STEP32(START,STEP) STEP16(START,STEP),STEP16((START)+16*(STEP),STEP) | |
| 100 | ||
| 101 | ||
| 102 | ||
| 103 | /*************************************************************************** | |
| 104 | TYPE DEFINITIONS | |
| 105 | ***************************************************************************/ | |
| 106 | ||
| 107 | typedef struct _gfx_layout gfx_layout; | |
| 108 | struct _gfx_layout | |
| 109 | { | |
| 110 | UINT16 width; /* pixel width of each element */ | |
| 111 | UINT16 height; /* pixel height of each element */ | |
| 112 | UINT32 total; /* total number of elements, or RGN_FRAC() */ | |
| 113 | UINT16 planes; /* number of bitplanes */ | |
| 114 | UINT32 planeoffset[MAX_GFX_PLANES]; /* bit offset of each bitplane */ | |
| 115 | UINT32 xoffset[MAX_GFX_SIZE]; /* bit offset of each horizontal pixel */ | |
| 116 | UINT32 yoffset[MAX_GFX_SIZE]; /* bit offset of each vertical pixel */ | |
| 117 | UINT32 charincrement; /* distance between two consecutive elements (in bits) */ | |
| 118 | const UINT32 * extxoffs; /* extended X offset array for really big layouts */ | |
| 119 | const UINT32 * extyoffs; /* extended Y offset array for really big layouts */ | |
| 120 | }; | |
| 121 | ||
| 122 | ||
| 89 | 123 | /* In mamecore.h: typedef struct _gfx_element gfx_element; */ |
| 124 | struct _gfx_element | |
| 125 | { | |
| 126 | UINT16 width; /* pixel width of each element */ | |
| 127 | UINT16 height; /* pixel height of each element */ | |
| 128 | UINT8 flags; /* one of the GFX_ELEMENT_* flags above */ | |
| 129 | UINT32 total_elements; /* total number of decoded elements */ | |
| 90 | 130 | |
| 91 | #define GFX_PACKED 1 /* two 4bpp pixels are packed in one byte of gfxdata */ | |
| 92 | #define GFX_SWAPXY 2 /* characters are mirrored along the top-left/bottom-right diagonal */ | |
| 93 | #define GFX_DONT_FREE_GFXDATA 4 /* gfxdata was not malloc()ed, so don't free it on exit */ | |
| 131 | UINT32 color_base; /* base color for rendering */ | |
| 132 | UINT16 color_depth; /* number of colors each pixel can represent */ | |
| 133 | UINT16 color_granularity; /* number of colors for each color code */ | |
| 134 | UINT32 total_colors; /* number of color codes */ | |
| 94 | 135 | |
| 136 | UINT32 * pen_usage; /* bitmask of pens that are used (pens 0-31 only) */ | |
| 95 | 137 | |
| 138 | UINT8 * gfxdata; /* pixel data, 8bpp or 4bpp (if GFX_ELEMENT_PACKED) */ | |
| 139 | UINT32 line_modulo; /* bytes between each row of data */ | |
| 140 | UINT32 char_modulo; /* bytes between each element */ | |
| 141 | gfx_layout layout; /* copy of the original layout */ | |
| 142 | }; | |
| 143 | ||
| 144 | ||
| 96 | 145 | typedef struct _gfx_decode gfx_decode; |
| 97 | 146 | struct _gfx_decode |
| 98 | 147 | { |
| 99 | int memory_region; /* memory region where the data resides (usually 1) */ | |
| 100 | /* -1 marks the end of the array */ | |
| 101 | UINT32 start; /* beginning of data to decode */ | |
| 102 | const gfx_layout *gfxlayout; | |
| 103 | UINT16 color_codes_start; /* offset in the color lookup table where color codes start */ | |
| 104 | UINT16 total_color_codes; /* total number of color codes */ | |
| 105 | UINT8 xscale, yscale; /* optional pixel scaling factors */ | |
| 148 | int memory_region; /* memory region where the data resides; -1 marks the end of array */ | |
| 149 | UINT32 start; /* offset of beginning of data to decode */ | |
| 150 | const gfx_layout *gfxlayout; /* pointer to gfx_layout describing the layout */ | |
| 151 | UINT16 color_codes_start; /* offset in the color lookup table where color codes start */ | |
| 152 | UINT16 total_color_codes; /* total number of color codes */ | |
| 153 | UINT8 xscale; /* optional horizontal scaling factor; 0 means 1x */ | |
| 154 | UINT8 yscale; /* optional vertical scaling factor; 0 means 1x */ | |
| 106 | 155 | }; |
| 107 | 156 | |
| 108 | 157 | |
| r936 | r937 | |
| 113 | 162 | int alphad; |
| 114 | 163 | }; |
| 115 | 164 | |
| 116 | enum | |
| 117 | { | |
| 118 | TRANSPARENCY_NONE, /* opaque with remapping */ | |
| 119 | TRANSPARENCY_NONE_RAW, /* opaque with no remapping */ | |
| 120 | TRANSPARENCY_PEN, /* single pen transparency with remapping */ | |
| 121 | TRANSPARENCY_PEN_RAW, /* single pen transparency with no remapping */ | |
| 122 | TRANSPARENCY_PENS, /* multiple pen transparency with remapping */ | |
| 123 | TRANSPARENCY_PENS_RAW, /* multiple pen transparency with no remapping */ | |
| 124 | TRANSPARENCY_COLOR, /* single remapped pen transparency with remapping */ | |
| 125 | TRANSPARENCY_PEN_TABLE, /* special pen remapping modes (see DRAWMODE_xxx below) with remapping */ | |
| 126 | TRANSPARENCY_PEN_TABLE_RAW, /* special pen remapping modes (see DRAWMODE_xxx below) with no remapping */ | |
| 127 | TRANSPARENCY_BLEND, /* blend two bitmaps, shifting the source and ORing to the dest with remapping */ | |
| 128 | TRANSPARENCY_BLEND_RAW, /* blend two bitmaps, shifting the source and ORing to the dest with no remapping */ | |
| 129 | TRANSPARENCY_ALPHA, /* single pen transparency, other pens alpha */ | |
| 130 | TRANSPARENCY_ALPHARANGE, /* single pen transparency, multiple pens alpha depending on array, see psikyosh.c */ | |
| 131 | 165 | |
| 132 | TRANSPARENCY_MODES /* total number of modes; must be last */ | |
| 133 | }; | |
| 134 | 166 | |
| 167 | /*************************************************************************** | |
| 168 | GLOBAL VARIABLES | |
| 169 | ***************************************************************************/ | |
| 170 | ||
| 135 | 171 | /* drawing mode case TRANSPARENCY_ALPHARANGE */ |
| 136 | 172 | extern UINT8 gfx_alpharange_table[256]; |
| 137 | 173 | |
| 138 | 174 | /* drawing mode case TRANSPARENCY_PEN_TABLE */ |
| 139 | 175 | extern UINT8 gfx_drawmode_table[256]; |
| 140 | enum | |
| 141 | { | |
| 142 | DRAWMODE_NONE, | |
| 143 | DRAWMODE_SOURCE, | |
| 144 | DRAWMODE_SHADOW | |
| 145 | }; | |
| 146 | 176 | |
| 147 | 177 | /* By default, when drawing sprites with pdrawgfx, shadows affect the sprites below them. */ |
| 148 | 178 | /* Set this flag to 1 to make shadows only affect the background, leaving sprites at full brightness. */ |
| 149 | 179 | extern int pdrawgfx_shadow_lowpri; |
| 150 | 180 | |
| 151 | 181 | |
| 182 | ||
| 183 | /*************************************************************************** | |
| 184 | FUNCTION PROTOTYPES | |
| 185 | ***************************************************************************/ | |
| 186 | ||
| 152 | 187 | void drawgfx_init(running_machine *machine); |
| 153 | 188 | |
| 189 | ||
| 154 | 190 | void decodechar(gfx_element *gfx,int num,const unsigned char *src,const gfx_layout *gl); |
| 155 | 191 | gfx_element *allocgfx(const gfx_layout *gl); |
| 156 | 192 | void decodegfx(gfx_element *gfx, const UINT8 *src, UINT32 first, UINT32 count); |
| 157 | 193 | void freegfx(gfx_element *gfx); |
| 194 | ||
| 195 | ||
| 158 | 196 | void drawgfx(mame_bitmap *dest,const gfx_element *gfx, |
| 159 | 197 | unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy, |
| 160 | 198 | const rectangle *clip,int transparency,int transparent_color); |
| r936 | r937 | |
| 166 | 204 | unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy, |
| 167 | 205 | const rectangle *clip,int transparency,int transparent_color, |
| 168 | 206 | UINT32 priority_mask); |
| 207 | ||
| 208 | ||
| 209 | void drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx, | |
| 210 | unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy, | |
| 211 | const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley); | |
| 212 | void pdrawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx, | |
| 213 | unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy, | |
| 214 | const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley, | |
| 215 | UINT32 priority_mask); | |
| 216 | void mdrawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx, | |
| 217 | unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy, | |
| 218 | const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley, | |
| 219 | UINT32 priority_mask); | |
| 220 | ||
| 221 | ||
| 222 | void draw_scanline8(mame_bitmap *bitmap,int x,int y,int length,const UINT8 *src,const pen_t *pens,int transparent_pen); | |
| 223 | void draw_scanline16(mame_bitmap *bitmap,int x,int y,int length,const UINT16 *src,const pen_t *pens,int transparent_pen); | |
| 224 | void pdraw_scanline8(mame_bitmap *bitmap,int x,int y,int length,const UINT8 *src,const pen_t *pens,int transparent_pen,int pri); | |
| 225 | void pdraw_scanline16(mame_bitmap *bitmap,int x,int y,int length,const UINT16 *src,const pen_t *pens,int transparent_pen,int pri); | |
| 226 | void extract_scanline8(mame_bitmap *bitmap,int x,int y,int length,UINT8 *dst); | |
| 227 | void extract_scanline16(mame_bitmap *bitmap,int x,int y,int length,UINT16 *dst); | |
| 228 | ||
| 229 | ||
| 169 | 230 | void copybitmap(mame_bitmap *dest,mame_bitmap *src,int flipx,int flipy,int sx,int sy, |
| 170 | 231 | const rectangle *clip,int transparency,int transparent_color); |
| 171 | 232 | void copybitmap_remap(mame_bitmap *dest,mame_bitmap *src,int flipx,int flipy,int sx,int sy, |
| r936 | r937 | |
| 176 | 237 | void copyscrollbitmap_remap(mame_bitmap *dest,mame_bitmap *src, |
| 177 | 238 | int rows,const int *rowscroll,int cols,const int *colscroll, |
| 178 | 239 | const rectangle *clip,int transparency,int transparent_color); |
| 179 | void draw_scanline8(mame_bitmap *bitmap,int x,int y,int length,const UINT8 *src,pen_t *pens,int transparent_pen); | |
| 180 | void draw_scanline16(mame_bitmap *bitmap,int x,int y,int length,const UINT16 *src,pen_t *pens,int transparent_pen); | |
| 181 | void pdraw_scanline8(mame_bitmap *bitmap,int x,int y,int length,const UINT8 *src,pen_t *pens,int transparent_pen,int pri); | |
| 182 | void pdraw_scanline16(mame_bitmap *bitmap,int x,int y,int length,const UINT16 *src,pen_t *pens,int transparent_pen,int pri); | |
| 183 | void extract_scanline8(mame_bitmap *bitmap,int x,int y,int length,UINT8 *dst); | |
| 184 | void extract_scanline16(mame_bitmap *bitmap,int x,int y,int length,UINT16 *dst); | |
| 185 | 240 | |
| 186 | ||
| 187 | 241 | /* |
| 188 | 242 | Copy a bitmap applying rotation, zooming, and arbitrary distortion. |
| 189 | 243 | This function works in a way that mimics some real hardware like the Konami |
| r936 | r937 | |
| 216 | 270 | UINT32 startx,UINT32 starty,int incxx,int incxy,int incyx,int incyy,int wraparound, |
| 217 | 271 | const rectangle *clip,int transparency,int transparent_color,UINT32 priority); |
| 218 | 272 | |
| 219 | #define fillbitmap(dest, pen, clip) bitmap_fill(dest, clip, pen) | |
| 220 | 273 | |
| 221 | void fillbitmap(mame_bitmap *dest,pen_t pen,const rectangle *clip); | |
| 222 | void drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx, | |
| 223 | unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy, | |
| 224 | const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley); | |
| 225 | void pdrawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx, | |
| 226 | unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy, | |
| 227 | const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley, | |
| 228 | UINT32 priority_mask); | |
| 229 | void mdrawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx, | |
| 230 | unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy, | |
| 231 | const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley, | |
| 232 | UINT32 priority_mask); | |
| 233 | 274 | |
| 275 | /*************************************************************************** | |
| 276 | INLINE FUNCTIONS | |
| 277 | ***************************************************************************/ | |
| 234 | 278 | |
| 235 | ||
| 236 | 279 | /* Alpha blending functions */ |
| 237 | 280 | INLINE void alpha_set_level(int level) |
| 238 | 281 | { |
| r936 | r937 | |
|---|---|---|
| 84 | 84 | static file_error fopen_internal(core_options *opts, const char *searchpath, const char *filename, UINT32 crc, UINT32 flags, mame_file **file); |
| 85 | 85 | static file_error fopen_attempt_zipped(astring *fullname, UINT32 crc, UINT32 openflags, mame_file *file); |
| 86 | 86 | |
| 87 | /* CHD callbacks */ | |
| 88 | static chd_interface_file *chd_open_cb(const char *filename, const char *mode); | |
| 89 | static void chd_close_cb(chd_interface_file *file); | |
| 90 | static UINT32 chd_read_cb(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer); | |
| 91 | static UINT32 chd_write_cb(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer); | |
| 92 | static UINT64 chd_length_cb(chd_interface_file *file); | |
| 93 | ||
| 94 | 87 | /* path iteration */ |
| 95 | 88 | static void path_iterator_init(path_iterator *iterator, core_options *opts, const char *searchpath); |
| 96 | 89 | static int path_iterator_get_next(path_iterator *iterator, astring *buffer); |
| r936 | r937 | |
| 102 | 95 | |
| 103 | 96 | |
| 104 | 97 | /*************************************************************************** |
| 105 | HARD DISK INTERFACE | |
| 106 | ***************************************************************************/ | |
| 107 | ||
| 108 | static chd_interface mame_chd_interface = | |
| 109 | { | |
| 110 | chd_open_cb, | |
| 111 | chd_close_cb, | |
| 112 | chd_read_cb, | |
| 113 | chd_write_cb, | |
| 114 | chd_length_cb | |
| 115 | }; | |
| 116 | ||
| 117 | ||
| 118 | ||
| 119 | /*************************************************************************** | |
| 120 | 98 | CORE FUNCTIONS |
| 121 | 99 | ***************************************************************************/ |
| 122 | 100 | |
| r936 | r937 | |
| 128 | 106 | |
| 129 | 107 | void fileio_init(running_machine *machine) |
| 130 | 108 | { |
| 131 | chd_set_interface(&mame_chd_interface); | |
| 132 | 109 | add_exit_callback(machine, fileio_exit); |
| 133 | 110 | } |
| 134 | 111 | |
| r936 | r937 | |
| 752 | 729 | |
| 753 | 730 | |
| 754 | 731 | /*************************************************************************** |
| 755 | CHD CALLBACKS | |
| 756 | ***************************************************************************/ | |
| 757 | ||
| 758 | /*------------------------------------------------- | |
| 759 | chd_open_cb - interface for opening | |
| 760 | a hard disk image | |
| 761 | -------------------------------------------------*/ | |
| 762 | ||
| 763 | chd_interface_file *chd_open_cb(const char *filename, const char *mode) | |
| 764 | { | |
| 765 | file_error filerr; | |
| 766 | mame_file *file; | |
| 767 | ||
| 768 | /* look for read-only drives first in the ROM path */ | |
| 769 | if (mode[0] == 'r' && !strchr(mode, '+')) | |
| 770 | { | |
| 771 | astring *path = astring_alloc(); | |
| 772 | const game_driver *drv; | |
| 773 | ||
| 774 | /* attempt reading up the chain through the parents */ | |
| 775 | for (drv = Machine->gamedrv; drv != NULL; drv = driver_get_clone(drv)) | |
| 776 | { | |
| 777 | /* build up drv->name/filename in the path */ | |
| 778 | astring_cpyc(path, drv->name); | |
| 779 | astring_catc(path, PATH_SEPARATOR); | |
| 780 | astring_catc(path, filename); | |
| 781 | ||
| 782 | /* attempt to open */ | |
| 783 | filerr = mame_fopen(SEARCHPATH_IMAGE, astring_c(path), OPEN_FLAG_READ, &file); | |
| 784 | if (filerr == FILERR_NONE) | |
| 785 | { | |
| 786 | astring_free(path); | |
| 787 | return (chd_interface_file *)file; | |
| 788 | } | |
| 789 | } | |
| 790 | astring_free(path); | |
| 791 | return NULL; | |
| 792 | } | |
| 793 | ||
| 794 | /* look for read/write drives in the diff area */ | |
| 795 | filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE, &file); | |
| 796 | if (filerr != FILERR_NONE) | |
| 797 | filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); | |
| 798 | return (filerr == FILERR_NONE) ? (chd_interface_file *)file : NULL; | |
| 799 | } | |
| 800 | ||
| 801 | ||
| 802 | /*------------------------------------------------- | |
| 803 | chd_close_cb - interface for closing | |
| 804 | a hard disk image | |
| 805 | -------------------------------------------------*/ | |
| 806 | ||
| 807 | void chd_close_cb(chd_interface_file *file) | |
| 808 | { | |
| 809 | mame_fclose((mame_file *)file); | |
| 810 | } | |
| 811 | ||
| 812 | ||
| 813 | /*------------------------------------------------- | |
| 814 | chd_read_cb - interface for reading | |
| 815 | from a hard disk image | |
| 816 | -------------------------------------------------*/ | |
| 817 | ||
| 818 | UINT32 chd_read_cb(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer) | |
| 819 | { | |
| 820 | mame_fseek((mame_file *)file, offset, SEEK_SET); | |
| 821 | return mame_fread((mame_file *)file, buffer, count); | |
| 822 | } | |
| 823 | ||
| 824 | ||
| 825 | /*------------------------------------------------- | |
| 826 | chd_write_cb - interface for writing | |
| 827 | to a hard disk image | |
| 828 | -------------------------------------------------*/ | |
| 829 | ||
| 830 | UINT32 chd_write_cb(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer) | |
| 831 | { | |
| 832 | mame_fseek((mame_file *)file, offset, SEEK_SET); | |
| 833 | return mame_fwrite((mame_file *)file, buffer, count); | |
| 834 | } | |
| 835 | ||
| 836 | ||
| 837 | /*------------------------------------------------- | |
| 838 | chd_length_cb - interface for getting | |
| 839 | the length a hard disk image | |
| 840 | -------------------------------------------------*/ | |
| 841 | ||
| 842 | UINT64 chd_length_cb(chd_interface_file *file) | |
| 843 | { | |
| 844 | return mame_fsize((mame_file *)file); | |
| 845 | } | |
| 846 | ||
| 847 | ||
| 848 | ||
| 849 | /*************************************************************************** | |
| 850 | 732 | PATH ITERATION |
| 851 | 733 | ***************************************************************************/ |
| 852 | 734 |
| r936 | r937 | |
|---|---|---|
| 155 | 155 | INT32 height; /* height in pixels */ |
| 156 | 156 | render_bounds bounds; /* bounds of the target */ |
| 157 | 157 | float pixel_aspect; /* aspect ratio of individual pixels */ |
| 158 | float max_refresh; /* maximum refresh rate, 0 or if none */ | |
| 158 | 159 | int orientation; /* orientation */ |
| 159 | 160 | int layerconfig; /* layer configuration */ |
| 160 | 161 | layout_view * base_view; /* the view at the time of first frame */ |
| r936 | r937 | |
| 194 | 195 | float yoffset; /* Y offset of the container */ |
| 195 | 196 | mame_bitmap * overlaybitmap; /* overlay bitmap */ |
| 196 | 197 | render_texture * overlaytexture; /* overlay texture */ |
| 198 | palette_client * palclient; /* client to the system palette */ | |
| 197 | 199 | rgb_t bcglookup256[0x400];/* lookup table for brightness/contrast/gamma */ |
| 198 | 200 | rgb_t bcglookup32[0x80]; /* lookup table for brightness/contrast/gamma */ |
| 199 | 201 | rgb_t bcglookup[0x10000]; /* full palette lookup with bcg adjustements */ |
| r936 | r937 | |
| 254 | 256 | /* render targets */ |
| 255 | 257 | static void release_render_list(render_primitive_list *list); |
| 256 | 258 | static int load_layout_files(render_target *target, const char *layoutfile, int singlefile); |
| 257 | static void add_container_primitives(render_target *target, render_primitive_list *list, const object_transform *xform, | |
| 259 | static void add_container_primitives(render_target *target, render_primitive_list *list, const object_transform *xform, | |
| 258 | 260 | static void add_element_primitives(render_target *target, render_primitive_list *list, const object_transform *xform, const layout_element *element, int state, int blendmode); |
| 259 | 261 | static void add_clear_and_optimize_primitive_list(render_target *target, render_primitive_list *list); |
| 260 | 262 | |
| r936 | r937 | |
| 270 | 272 | static container_item *render_container_item_add_generic(render_container *container, UINT8 type, float x0, float y0, float x1, float y1, rgb_t argb); |
| 271 | 273 | static void render_container_overlay_scale(mame_bitmap *dest, const mame_bitmap *source, const rectangle *sbounds, void *param); |
| 272 | 274 | static void render_container_recompute_lookups(render_container *container); |
| 273 | static void render_container_update_palette( | |
| 275 | static void render_container_update_palette(rende | |
| 274 | 276 | |
| 275 | 277 | |
| 276 | 278 | |
| r936 | r937 | |
| 875 | 877 | |
| 876 | 878 | |
| 877 | 879 | /*------------------------------------------------- |
| 878 | render_set_ui_target - return the UI target | |
| 880 | render_get_max_update_rate - return the | |
| 881 | smallest maximum update rate across all targets | |
| 879 | 882 | -------------------------------------------------*/ |
| 880 | 883 | |
| 884 | float render_get_max_update_rate(void) | |
| 885 | { | |
| 886 | render_target *target; | |
| 887 | float minimum = 0; | |
| 888 | ||
| 889 | /* iterate over all live targets and or together their screen masks */ | |
| 890 | for (target = targetlist; target != NULL; target = target->next) | |
| 891 | if (target->max_refresh != 0) | |
| 892 | { | |
| 893 | if (minimum == 0) | |
| 894 | minimum = target->max_refresh; | |
| 895 | else | |
| 896 | minimum = MIN(target->max_refresh, minimum); | |
| 897 | } | |
| 898 | ||
| 899 | return minimum; | |
| 900 | } | |
| 901 | ||
| 902 | ||
| 903 | /*------------------------------------------------- | |
| 904 | render_set_ui_target - select the UI target | |
| 905 | -------------------------------------------------*/ | |
| 906 | ||
| 881 | 907 | void render_set_ui_target(render_target *target) |
| 882 | 908 | { |
| 883 | 909 | assert(target != NULL); |
| r936 | r937 | |
| 1143 | 1169 | |
| 1144 | 1170 | |
| 1145 | 1171 | /*------------------------------------------------- |
| 1172 | render_target_get_max_update_rate - get the | |
| 1173 | maximum update rate (refresh rate) of a target, | |
| 1174 | or 0 if no maximum | |
| 1175 | -------------------------------------------------*/ | |
| 1176 | ||
| 1177 | float render_target_get_max_update_rate(render_target *target) | |
| 1178 | { | |
| 1179 | return target->max_refresh; | |
| 1180 | } | |
| 1181 | ||
| 1182 | ||
| 1183 | /*------------------------------------------------- | |
| 1184 | render_target_set_max_update_rate - set the | |
| 1185 | maximum update rate (refresh rate) of a target, | |
| 1186 | or 0 if no maximum | |
| 1187 | -------------------------------------------------*/ | |
| 1188 | ||
| 1189 | void render_target_set_max_update_rate(render_target *target, float updates_per_second) | |
| 1190 | { | |
| 1191 | target->max_refresh = updates_per_second; | |
| 1192 | } | |
| 1193 | ||
| 1194 | ||
| 1195 | /*------------------------------------------------- | |
| 1146 | 1196 | render_target_get_orientation - get the |
| 1147 | 1197 | orientation of a target |
| 1148 | 1198 | -------------------------------------------------*/ |
| r936 | r937 | |
| 1616 | 1666 | based on the container |
| 1617 | 1667 | -------------------------------------------------*/ |
| 1618 | 1668 | |
| 1619 | static void add_container_primitives(render_target *target, render_primitive_list *list, const object_transform *xform, | |
| 1669 | static void add_container_primitives(render_target *target, render_primitive_list *list, const object_transform *xform, | |
| 1620 | 1670 | { |
| 1621 | 1671 | object_transform container_xform; |
| 1622 | 1672 | render_bounds cliprect; |
| 1623 | 1673 | render_primitive *prim; |
| 1624 | 1674 | container_item *item; |
| 1625 | 1675 | |
| 1676 | /* first update the palette for the container, if it is dirty */ | |
| 1677 | render_container_update_palette(container); | |
| 1678 | ||
| 1626 | 1679 | /* compute the clip rect */ |
| 1627 | 1680 | cliprect.x0 = xform->xoffs; |
| 1628 | 1681 | cliprect.y0 = xform->yoffs; |
| r936 | r937 | |
| 1722 | 1775 | /* override the palette with our adjusted palette */ |
| 1723 | 1776 | switch (item->texture->format) |
| 1724 | 1777 | { |
| 1725 | case TEXFORMAT_PALETTE16: prim->texture.palette = &container->bcglookup[prim->texture.palette - palette_get_adjusted_colors(Machine)]; break; | |
| 1726 | case TEXFORMAT_PALETTEA16: prim->texture.palette = &container->bcglookup[prim->texture.palette - palette_get_adjusted_colors(Machine)]; break; | |
| 1778 | case TEXFORMAT_PALETTE16: prim->texture.palette = &container->bcglookup[prim->texture.palette - palette_entry_list_adjusted(Machine->palette)]; break; | |
| 1779 | case TEXFORMAT_PALETTEA16: prim->texture.palette = &container->bcglookup[prim->texture.palette - palette_entry_list_adjusted(Machine->palette)]; break; | |
| 1727 | 1780 | case TEXFORMAT_RGB15: prim->texture.palette = &container->bcglookup32[0]; break; |
| 1728 | 1781 | case TEXFORMAT_RGB32: prim->texture.palette = &container->bcglookup256[0]; break; |
| 1729 | 1782 | case TEXFORMAT_ARGB32: prim->texture.palette = &container->bcglookup256[0]; break; |
| r936 | r937 | |
| 2273 | 2326 | static int render_texture_get_scaled(render_texture *texture, UINT32 dwidth, UINT32 dheight, render_texinfo *texinfo, render_ref **reflist) |
| 2274 | 2327 | { |
| 2275 | 2328 | UINT8 bpp = (texture->format == TEXFORMAT_PALETTE16 || texture->format == TEXFORMAT_PALETTEA16 || texture->format == TEXFORMAT_RGB15 || texture->format == TEXFORMAT_YUY16) ? 16 : 32; |
| 2276 | const rgb_t *palbase = (texture->format == TEXFORMAT_PALETTE16 || texture->format == TEXFORMAT_PALETTEA16) ? palette_ | |
| 2329 | const rgb_t *palbase = (texture->format == TEXFORMAT_PALETTE16 || texture->format == TEXFORMAT_PALETTEA16) ? palette_ | |
| 2277 | 2330 | scaled_texture *scaled = NULL; |
| 2278 | 2331 | int swidth, sheight; |
| 2279 | 2332 | int scalenum; |
| r936 | r937 | |
| 2398 | 2451 | /* make sure it is empty */ |
| 2399 | 2452 | render_container_empty(container); |
| 2400 | 2453 | |
| 2401 | /* allocate a notifier */ | |
| 2454 | /* allocate a client to the main palette */ | |
| 2455 | if (Machine->palette != NULL) | |
| 2456 | container->palclient = palette_client_alloc(Machine->palette); | |
| 2402 | 2457 | render_container_recompute_lookups(container); |
| 2403 | palette_add_notifier(Machine, render_container_update_palette, container); | |
| 2404 | 2458 | return container; |
| 2405 | 2459 | } |
| 2406 | 2460 | |
| r936 | r937 | |
| 2419 | 2473 | if (container->overlaytexture != NULL) |
| 2420 | 2474 | render_texture_free(container->overlaytexture); |
| 2421 | 2475 | |
| 2476 | /* release our palette client */ | |
| 2477 | if (container->palclient != NULL) | |
| 2478 | palette_client_free(container->palclient); | |
| 2479 | ||
| 2422 | 2480 | /* free the container itself */ |
| 2423 | 2481 | free(container); |
| 2424 | 2482 | } |
| r936 | r937 | |
| 2636 | 2694 | |
| 2637 | 2695 | /*------------------------------------------------- |
| 2638 | 2696 | render_container_set_overlay - set the |
| 2639 | ori | |
| 2697 | overlay bi | |
| 2640 | 2698 | -------------------------------------------------*/ |
| 2641 | 2699 | |
| 2642 | 2700 | void render_container_set_overlay(render_container *container, mame_bitmap *bitmap) |
| r936 | r937 | |
| 2803 | 2861 | |
| 2804 | 2862 | static void render_container_recompute_lookups(render_container *container) |
| 2805 | 2863 | { |
| 2806 | pen_t *adjusted_palette = palette_get_adjusted_colors(Machine); | |
| 2807 | int colors = palette_get_total_colors_with_ui(Machine); | |
| 2808 | 2864 | int i; |
| 2809 | 2865 | |
| 2810 | 2866 | /* recompute the 256 entry lookup table */ |
| r936 | r937 | |
| 2828 | 2884 | } |
| 2829 | 2885 | |
| 2830 | 2886 | /* recompute the palette entries */ |
| 2831 | f | |
| 2887 | if | |
| 2832 | 2888 | { |
| 2833 | pen_t newval = adjusted_palette[i]; | |
| 2834 | container->bcglookup[i] = (container->bcglookup[i] & 0xff000000) | | |
| 2835 | container->bcglookup256[0x200 + RGB_RED(newval)] | | |
| 2836 | container->bcglookup256[0x100 + RGB_GREEN(newval)] | | |
| 2837 | container->bcglookup256[0x000 + RGB_BLUE(newval)]; | |
| 2889 | palette_t *palette = palette_client_get_palette(container->palclient); | |
| 2890 | const pen_t *adjusted_palette = palette_entry_list_adjusted(palette); | |
| 2891 | int colors = palette_get_num_colors(palette) * palette_get_num_groups(palette); | |
| 2892 | ||
| 2893 | for (i = 0; i < colors; i++) | |
| 2894 | { | |
| 2895 | pen_t newval = adjusted_palette[i]; | |
| 2896 | container->bcglookup[i] = (container->bcglookup[i] & 0xff000000) | | |
| 2897 | container->bcglookup256[0x200 + RGB_RED(newval)] | | |
| 2898 | container->bcglookup256[0x100 + RGB_GREEN(newval)] | | |
| 2899 | container->bcglookup256[0x000 + RGB_BLUE(newval)]; | |
| 2900 | } | |
| 2838 | 2901 | } |
| 2839 | 2902 | } |
| 2840 | 2903 | |
| 2841 | 2904 | |
| 2842 | 2905 | /*------------------------------------------------- |
| 2843 | 2906 | render_container_update_palette - update |
| 2844 | a | |
| 2907 | any dirty | |
| 2845 | 2908 | -------------------------------------------------*/ |
| 2846 | 2909 | |
| 2847 | static void render_container_update_palette( | |
| 2910 | static void render_container_update_palette(rende | |
| 2848 | 2911 | { |
| 2849 | render_container *container = param; | |
| 2850 | assert(entry < ARRAY_LENGTH(container->bcglookup)); | |
| 2851 | container->bcglookup[entry] = (container->bcglookup[entry] & 0xff000000) | | |
| 2852 | container->bcglookup256[0x200 + RGB_RED(newval)] | | |
| 2853 | container->bcglookup256[0x100 + RGB_GREEN(newval)] | | |
| 2854 | container->bcglookup256[0x000 + RGB_BLUE(newval)]; | |
| 2912 | UINT32 mindirty, maxdirty; | |
| 2913 | const UINT32 *dirty; | |
| 2914 | ||
| 2915 | /* skip if no client */ | |
| 2916 | if (container->palclient == NULL) | |
| 2917 | return; | |
| 2918 | ||
| 2919 | /* get the dirty list */ | |
| 2920 | dirty = palette_client_get_dirty_list(container->palclient, &mindirty, &maxdirty); | |
| 2921 | ||
| 2922 | /* iterate over dirty items and update them */ | |
| 2923 | if (dirty != NULL) | |
| 2924 | { | |
| 2925 | palette_t *palette = palette_client_get_palette(container->palclient); | |
| 2926 | const pen_t *adjusted_palette = palette_entry_list_adjusted(palette); | |
| 2927 | UINT32 entry32, entry; | |
| 2928 | ||
| 2929 | /* loop over chunks of 32 entries, since we can quickly examine 32 at a time */ | |
| 2930 | for (entry32 = mindirty / 32; entry32 <= maxdirty / 32; entry32++) | |
| 2931 | { | |
| 2932 | UINT32 dirtybits = dirty[entry32]; | |
| 2933 | if (dirtybits != 0) | |
| 2934 | ||
| 2935 | /* this chunk of 32 has dirty entries; fix them up */ | |
| 2936 | for (entry = 0; entry < 32; entry++) | |
| 2937 | if (dirtybits & (1 << entry)) | |
| 2938 | { | |
| 2939 | UINT32 finalentry = entry32 * 32 + entry; | |
| 2940 | rgb_t newval = adjusted_palette[finalentry]; | |
| 2941 | container->bcglookup[finalentry] = (container->bcglookup[finalentry] & 0xff000000) | | |
| 2942 | container->bcglookup256[0x200 + RGB_RED(newval)] | | |
| 2943 | container->bcglookup256[0x100 + RGB_GREEN(newval)] | | |
| 2944 | container->bcglookup256[0x000 + RGB_BLUE(newval)]; | |
| 2945 | } | |
| 2946 | } | |
| 2947 | } | |
| 2855 | 2948 | } |
| r936 | r937 | |
|---|---|---|
| 562 | 562 | expand_machine_driver(drivers[drvindex]->drv, &drv); |
| 563 | 563 | |
| 564 | 564 | /* find samples interfaces */ |
| 565 | for (sndnum = 0; sndnum < MAX_SOUND && drv.sound[sndnum].sound_type; sndnum++) | |
| 565 | for (sndnum = 0; sndnum < MAX_SOUND && drv.sound[sndnum].sound_type != SOUND_DUMMY; sndnum++) | |
| 566 | 566 | if (drv.sound[sndnum].sound_type == SOUND_SAMPLES) |
| 567 | 567 | { |
| 568 | 568 | const char **samplenames = ((struct Samplesinterface *)drv.sound[sndnum].config)->samplenames; |
| r0 | r937 | |
|---|---|---|
| 1 | /****************************************************************************** | |
| 2 | ||
| 3 | emupal.c | |
| 4 | ||
| 5 | Emulator palette handling functions. | |
| 6 | ||
| 7 | Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team. | |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. | |
| 9 | ||
| 10 | ******************************************************************************/ | |
| 11 | ||
| 12 | #include "driver.h" | |
| 13 | #include <math.h> | |
| 14 | ||
| 15 | #define VERBOSE 0 | |
| 16 | ||
| 17 | ||
| 18 | /*************************************************************************** | |
| 19 | CONSTANTS | |
| 20 | ***************************************************************************/ | |
| 21 | ||
| 22 | #define PEN_BRIGHTNESS_BITS 8 | |
| 23 | #define MAX_PEN_BRIGHTNESS (4 << PEN_BRIGHTNESS_BITS) | |
| 24 | #define MAX_SHADOW_PRESETS 4 | |
| 25 | ||
| 26 | ||
| 27 | ||
| 28 | /*************************************************************************** | |
| 29 | TYPE DEFINITIONS | |
| 30 | ***************************************************************************/ | |
| 31 | ||
| 32 | /* information about a shadow table */ | |
| 33 | typedef struct _shadow_table_data shadow_table_data; | |
| 34 | struct _shadow_table_data | |
| 35 | { | |
| 36 | UINT32 * base; /* pointer to the base of the table */ | |
| 37 | INT16 dr; /* delta red value */ | |
| 38 | INT16 dg; /* delta green value */ | |
| 39 | INT16 db; /* delta blue value */ | |
| 40 | UINT8 noclip; /* clip? */ | |
| 41 | }; | |
| 42 | ||
| 43 | ||
| 44 | /* typedef struct _palette_private palette_private; */ | |
| 45 | struct _palette_private | |
| 46 | { | |
| 47 | bitmap_format format; /* format assumed for palette data */ | |
| 48 | ||
| 49 | UINT32 shadow_group; /* index of the shadow group, or 0 if none */ | |
| 50 | UINT32 hilight_group; /* index of the hilight group, or 0 if none */ | |
| 51 | ||
| 52 | pen_t black_pen; /* precomputed black pen value */ | |
| 53 | pen_t white_pen; /* precomputed white pen value */ | |
| 54 | ||
| 55 | shadow_table_data shadow_table[MAX_SHADOW_PRESETS]; /* array of shadow table data */ | |
| 56 | ||
| 57 | pen_t * save_pen; /* pens for save/restore */ | |
| 58 | float * save_bright; /* brightness for save/restore */ | |
| 59 | }; | |
| 60 | ||
| 61 | ||
| 62 | /* typedef struct _colortable colortable; */ | |
| 63 | struct _colortable | |
| 64 | { | |
| 65 | running_machine * machine; /* associated machine */ | |
| 66 | UINT32 entries; /* number of entries */ | |
| 67 | UINT32 palentries; /* number of palette entries */ | |
| 68 | UINT16 * raw; /* raw data about each entry */ | |
| 69 | rgb_t * palette; /* palette entries */ | |
| 70 | }; | |
| 71 | ||
| 72 | ||
| 73 | ||
| 74 | /*************************************************************************** | |
| 75 | FUNCTION PROTOTYPES | |
| 76 | ***************************************************************************/ | |
| 77 | ||
| 78 | static void palette_presave(void); | |
| 79 | static void palette_postload(void); | |
| 80 | static void palette_exit(running_machine *machine); | |
| 81 | static void allocate_palette(running_machine *machine, palette_private *palette); | |
| 82 | static void allocate_color_tables(running_machine *machine, palette_private *palette); | |
| 83 | static void allocate_shadow_tables(running_machine *machine, palette_private *palette); | |
| 84 | static void configure_rgb_shadows(running_machine *machine, int mode, float factor); | |
| 85 | ||
| 86 | ||
| 87 | ||
| 88 | /*************************************************************************** | |
| 89 | INITIALIZATION AND CONFIGURATION | |
| 90 | ***************************************************************************/ | |
| 91 | ||
| 92 | /*------------------------------------------------- | |
| 93 | palette_init - palette initialization that | |
| 94 | takes place before the display is created | |
| 95 | -------------------------------------------------*/ | |
| 96 | ||
| 97 | void palette_init(running_machine *machine) | |
| 98 | { | |
| 99 | palette_private *palette = auto_malloc(sizeof(*palette)); | |
| 100 | ||
| 101 | /* request cleanup */ | |
| 102 | machine->palette_data = palette; | |
| 103 | add_exit_callback(machine, palette_exit); | |
| 104 | ||
| 105 | /* reset all our data */ | |
| 106 | memset(palette, 0, sizeof(*palette)); | |
| 107 | palette->format = machine->screen[0].format; | |
| 108 | ||
| 109 | /* determine the color mode */ | |
| 110 | switch (palette->format) | |
| 111 | { | |
| 112 | case BITMAP_FORMAT_INDEXED16: | |
| 113 | /* indexed modes are fine for everything */ | |
| 114 | break; | |
| 115 | ||
| 116 | case BITMAP_FORMAT_RGB15: | |
| 117 | case BITMAP_FORMAT_RGB32: | |
| 118 | /* RGB modes can't use color tables */ | |
| 119 | assert(machine->drv->color_table_len == 0); | |
| 120 | break; | |
| 121 | ||
| 122 | case BITMAP_FORMAT_INVALID: | |
| 123 | /* invalid format means no palette - or at least it should */ | |
| 124 | assert(machine->drv->total_colors == 0); | |
| 125 | assert(machine->drv->color_table_len == 0); | |
| 126 | return; | |
| 127 | ||
| 128 | default: | |
| 129 | fatalerror("Unsupported screen bitmap format!"); | |
| 130 | break; | |
| 131 | } | |
| 132 | ||
| 133 | /* allocate all the data structures */ | |
| 134 | if (machine->drv->total_colors > 0) | |
| 135 | { | |
| 136 | int numcolors; | |
| 137 | ||
| 138 | allocate_palette(machine, palette); | |
| 139 | allocate_color_tables(machine, palette); | |
| 140 | allocate_shadow_tables(machine, palette); | |
| 141 | ||
| 142 | /* set up save/restore of the palette */ | |
| 143 | numcolors = palette_get_num_colors(machine->palette); | |
| 144 | palette->save_pen = auto_malloc(sizeof(*palette->save_pen) * numcolors); | |
| 145 | palette->save_bright = auto_malloc(sizeof(*palette->save_bright) * numcolors); | |
| 146 | state_save_register_global_pointer(palette->save_pen, numcolors); | |
| 147 | state_save_register_global_pointer(palette->save_bright, numcolors); | |
| 148 | state_save_register_func_presave(palette_presave); | |
| 149 | state_save_register_func_postload(palette_postload); | |
| 150 | } | |
| 151 | } | |
| 152 | ||
| 153 | ||
| 154 | /*------------------------------------------------- | |
| 155 | palette_config - palette initialization that | |
| 156 | takes place after the display is created | |
| 157 | -------------------------------------------------*/ | |
| 158 | ||
| 159 | void palette_config(running_machine *machine) | |
| 160 | { | |
| 161 | int total_colors = (machine->palette == NULL) ? 0 : palette_get_num_colors(machine->palette) * palette_get_num_groups(machine->palette); | |
| 162 | pen_t *remapped_colortable = NULL; | |
| 163 | UINT16 *colortable = NULL; | |
| 164 | int i; | |
| 165 | ||
| 166 | /* allocate memory for the colortables, if needed */ | |
| 167 | if (machine->drv->color_table_len > 0) | |
| 168 | { | |
| 169 | /* first for the raw colortable */ | |
| 170 | colortable = auto_malloc(machine->drv->color_table_len * sizeof(colortable[0])); | |
| 171 | for (i = 0; i < machine->drv->color_table_len; i++) | |
| 172 | colortable[i] = i % total_colors; | |
| 173 | ||
| 174 | /* then for the remapped colortable */ | |
| 175 | remapped_colortable = auto_malloc(machine->drv->color_table_len * sizeof(remapped_colortable[0])); | |
| 176 | } | |
| 177 | ||
| 178 | /* now let the driver modify the initial palette and colortable */ | |
| 179 | if (machine->drv->init_palette) | |
| 180 | (*machine->drv->init_palette)(machine, colortable, memory_region(REGION_PROMS)); | |
| 181 | ||
| 182 | /* now compute the remapped_colortable */ | |
| 183 | for (i = 0; i < machine->drv->color_table_len; i++) | |
| 184 | { | |
| 185 | pen_t color = colortable[i]; | |
| 186 | ||
| 187 | /* check for invalid colors set by machine->drv->init_palette */ | |
| 188 | assert(color < total_colors); | |
| 189 | remapped_colortable[i] = machine->pens[color]; | |
| 190 | } | |
| 191 | ||
| 192 | /* now we can set the final colortables */ | |
| 193 | machine->game_colortable = colortable; | |
| 194 | machine->remapped_colortable = (remapped_colortable != NULL) ? remapped_colortable : machine->pens; | |
| 195 | ||
| 196 | /* set the color table base for each graphics element */ | |
| 197 | for (i = 0; i < MAX_GFX_ELEMENTS; i++) | |
| 198 | if (machine->gfx[i] != NULL) | |
| 199 | machine->gfx[i]->color_base = machine->drv->gfxdecodeinfo[i].color_codes_start; | |
| 200 | } | |
| 201 | ||
| 202 | ||
| 203 | ||
| 204 | /*************************************************************************** | |
| 205 | SHADOW/HIGHLIGHT CONFIGURATION | |
| 206 | ***************************************************************************/ | |
| 207 | ||
| 208 | /*------------------------------------------------- | |
| 209 | palette_set_shadow_factor - set the global | |
| 210 | shadow brightness factor | |
| 211 | -------------------------------------------------*/ | |
| 212 | ||
| 213 | void palette_set_shadow_factor(running_machine *machine, double factor) | |
| 214 | { | |
| 215 | palette_private *palette = machine->palette_data; | |
| 216 | ||
| 217 | assert(palette->shadow_group != 0); | |
| 218 | palette_group_set_contrast(machine->palette, palette->shadow_group, factor); | |
| 219 | } | |
| 220 | ||
| 221 | ||
| 222 | /*------------------------------------------------- | |
| 223 | palette_set_highlight_factor - set the global | |
| 224 | highlight brightness factor | |
| 225 | -------------------------------------------------*/ | |
| 226 | ||
| 227 | void palette_set_highlight_factor(running_machine *machine, double factor) | |
| 228 | { | |
| 229 | palette_private *palette = machine->palette_data; | |
| 230 | ||
| 231 | assert(palette->hilight_group != 0); | |
| 232 | palette_group_set_contrast(machine->palette, palette->hilight_group, factor); | |
| 233 | } | |
| 234 | ||
| 235 | ||
| 236 | ||
| 237 | /*************************************************************************** | |
| 238 | SHADOW TABLE CONFIGURATION | |
| 239 | ***************************************************************************/ | |
| 240 | ||
| 241 | /*------------------------------------------------- | |
| 242 | palette_set_shadow_mode(mode) | |
| 243 | ||
| 244 | mode: 0 = use preset 0 (default shadow) | |
| 245 | 1 = use preset 1 (default highlight) | |
| 246 | 2 = use preset 2 * | |
| 247 | 3 = use preset 3 * | |
| 248 | ||
| 249 | * Preset 2 & 3 work independently under 32bpp, | |
| 250 | supporting up to four different types of | |
| 251 | shadows at one time. They mirror preset 1 & 2 | |
| 252 | in lower depth settings to maintain | |
| 253 | compatibility. | |
| 254 | ||
| 255 | ||
| 256 | palette_set_shadow_dRGB32(mode, dr, dg, db, noclip) | |
| 257 | ||
| 258 | mode: 0 to 3 (which preset to configure) | |
| 259 | ||
| 260 | dr: -255 to 255 ( red displacement ) | |
| 261 | dg: -255 to 255 ( green displacement ) | |
| 262 | db: -255 to 255 ( blue displacement ) | |
| 263 | ||
| 264 | noclip: 0 = resultant RGB clipped at 0x00/0xff | |
| 265 | 1 = resultant RGB wraparound 0x00/0xff | |
| 266 | ||
| 267 | ||
| 268 | * Color shadows only work under 32bpp. | |
| 269 | This function has no effect in lower color | |
| 270 | depths where | |
| 271 | ||
| 272 | palette_set_shadow_factor() or | |
| 273 | palette_set_highlight_factor() | |
| 274 | ||
| 275 | should be used instead. | |
| 276 | ||
| 277 | * 32-bit shadows are lossy. Even with zero RGB | |
| 278 | displacements the affected area will still look | |
| 279 | slightly darkened. | |
| 280 | ||
| 281 | Drivers should ensure all shadow pens in | |
| 282 | gfx_drawmode_table[] are set to DRAWMODE_NONE | |
| 283 | when RGB displacements are zero to avoid the | |
| 284 | darkening effect. | |
| 285 | -------------------------------------------------*/ | |
| 286 | ||
| 287 | /*------------------------------------------------- | |
| 288 | palette_set_shadow_mode - select 1 of 4 | |
| 289 | different live shadow tables | |
| 290 | -------------------------------------------------*/ | |
| 291 | ||
| 292 | void palette_set_shadow_mode(running_machine *machine, int mode) | |
| 293 | { | |
| 294 | palette_private *palette = machine->palette_data; | |
| 295 | assert(mode >= 0 && mode < MAX_SHADOW_PRESETS); | |
| 296 | machine->shadow_table = palette->shadow_table[mode].base; | |
| 297 | } | |
| 298 | ||
| 299 | ||
| 300 | /*------------------------------------------------- | |
| 301 | palette_set_shadow_dRGB32 - configure delta | |
| 302 | RGB values for 1 of 4 shadow tables | |
| 303 | -------------------------------------------------*/ | |
| 304 | ||
| 305 | void palette_set_shadow_dRGB32(running_machine *machine, int mode, int dr, int dg, int db, int noclip) | |
| 306 | { | |
| 307 | palette_private *palette = machine->palette_data; | |
| 308 | shadow_table_data *stable = &palette->shadow_table[mode]; | |
| 309 | int i; | |
| 310 | ||
| 311 | /* only applies to RGB direct modes */ | |
| 312 | assert(palette->format != BITMAP_FORMAT_INDEXED16); | |
| 313 | assert(stable->base != NULL); | |
| 314 | ||
| 315 | /* clamp the deltas (why?) */ | |
| 316 | if (dr < -0xff) dr = -0xff; else if (dr > 0xff) dr = 0xff; | |
| 317 | if (dg < -0xff) dg = -0xff; else if (dg > 0xff) dg = 0xff; | |
| 318 | if (db < -0xff) db = -0xff; else if (db > 0xff) db = 0xff; | |
| 319 | ||
| 320 | /* early exit if nothing changed */ | |
| 321 | if (dr == stable->dr && dg == stable->dg && db == stable->db && noclip == stable->noclip) | |
| 322 | return; | |
| 323 | stable->dr = dr; | |
| 324 | stable->dg = dg; | |
| 325 | stable->db = db; | |
| 326 | stable->noclip = noclip; | |
| 327 | ||
| 328 | #if VERBOSE | |
| 329 | popmessage("shadow %d recalc %d %d %d %02x", mode, dr, dg, db, noclip); | |
| 330 | #endif | |
| 331 | ||
| 332 | /* regenerate the table */ | |
| 333 | for (i = 0; i < 32768; i++) | |
| 334 | { | |
| 335 | int r = pal5bit(i >> 10) + dr; | |
| 336 | int g = pal5bit(i >> 5) + dg; | |
| 337 | int b = pal5bit(i >> 0) + db; | |
| 338 | pen_t final; | |
| 339 | ||
| 340 | /* apply clipping */ | |
| 341 | if (!noclip) | |
| 342 | { | |
| 343 | r = rgb_clamp(r); | |
| 344 | g = rgb_clamp(g); | |
| 345 | b = rgb_clamp(b); | |
| 346 | } | |
| 347 | final = MAKE_RGB(r, g, b); | |
| 348 | ||
| 349 | /* store either 16 or 32 bit */ | |
| 350 | if (palette->format == BITMAP_FORMAT_RGB32) | |
| 351 | stable->base[i] = final; | |
| 352 | else | |
| 353 | stable->base[i] = rgb_to_rgb15(final); | |
| 354 | } | |
| 355 | } | |
| 356 | ||
| 357 | ||
| 358 | ||
| 359 | /*************************************************************************** | |
| 360 | COLORTABLE MANAGEMENT | |
| 361 | ***************************************************************************/ | |
| 362 | ||
| 363 | /*------------------------------------------------- | |
| 364 | colortable_alloc - allocate a new colortable | |
| 365 | with the given number of entries | |
| 366 | -------------------------------------------------*/ | |
| 367 | ||
| 368 | colortable *colortable_alloc(running_machine *machine, UINT32 palettesize) | |
| 369 | { | |
| 370 | colortable *ctable; | |
| 371 | UINT32 index; | |
| 372 | ||
| 373 | /* allocate the colortable */ | |
| 374 | ctable = auto_malloc(sizeof(*ctable)); | |
| 375 | memset(ctable, 0, sizeof(*ctable)); | |
| 376 | ||
| 377 | /* fill in the basics */ | |
| 378 | ctable->machine = machine; | |
| 379 | ctable->entries = machine->drv->total_colors; | |
| 380 | ctable->palentries = palettesize; | |
| 381 | ||
| 382 | /* allocate the raw colortable */ | |
| 383 | ctable->raw = auto_malloc(ctable->entries * sizeof(*ctable->raw)); | |
| 384 | for (index = 0; index < ctable->entries; index++) | |
| 385 | ctable->raw[index] = index % ctable->palentries; | |
| 386 | ||
| 387 | /* allocate the palette */ | |
| 388 | ctable->palette = auto_malloc(ctable->palentries * sizeof(*ctable->palette)); | |
| 389 | for (index = 0; index < ctable->palentries; index++) | |
| 390 | ctable->palette[index] = RGB_BLACK; | |
| 391 | ||
| 392 | return ctable; | |
| 393 | } | |
| 394 | ||
| 395 | ||
| 396 | /*------------------------------------------------- | |
| 397 | colortable_entry_set_value - set the value | |
| 398 | of a colortable entry | |
| 399 | -------------------------------------------------*/ | |
| 400 | ||
| 401 | void colortable_entry_set_value(colortable *ctable, UINT32 entry, UINT16 value) | |
| 402 | { | |
| 403 | /* ensure values are within range */ | |
| 404 | assert(entry < ctable->entries); | |
| 405 | assert(value < ctable->palentries); | |
| 406 | ||
| 407 | /* update if it has changed */ | |
| 408 | if (ctable->raw[entry] != value) | |
| 409 | { | |
| 410 | ctable->raw[entry] = value; | |
| 411 | palette_set_color(ctable->machine, entry, ctable->palette[value]); | |
| 412 | } | |
| 413 | } | |
| 414 | ||
| 415 | ||
| 416 | /*------------------------------------------------- | |
| 417 | colortable_entry_get_value - return the value | |
| 418 | of a colortable entry | |
| 419 | -------------------------------------------------*/ | |
| 420 | ||
| 421 | UINT16 colortable_entry_get_value(colortable *ctable, UINT32 entry) | |
| 422 | { | |
| 423 | assert(entry < ctable->entries); | |
| 424 | return ctable->raw[entry]; | |
| 425 | } | |
| 426 | ||
| 427 | ||
| 428 | /*------------------------------------------------- | |
| 429 | colortable_palette_set_color - change the | |
| 430 | color of a colortable palette entry | |
| 431 | -------------------------------------------------*/ | |
| 432 | ||
| 433 | void colortable_palette_set_color(colortable *ctable, UINT32 entry, rgb_t color) | |
| 434 | { | |
| 435 | /* ensure values are within range */ | |
| 436 | assert(entry < ctable->palentries); | |
| 437 | ||
| 438 | /* update if it has changed */ | |
| 439 | if (ctable->palette[entry] != color) | |
| 440 | { | |
| 441 | UINT32 index; | |
| 442 | ||
| 443 | ctable->palette[entry] = color; | |
| 444 | ||
| 445 | /* update the palette for any colortable entries that reference it */ | |
| 446 | for (index = 0; index < ctable->entries; index++) | |
| 447 | if (ctable->raw[index] == entry) | |
| 448 | palette_set_color(ctable->machine, index, color); | |
| 449 | } | |
| 450 | } | |
| 451 | ||
| 452 | ||
| 453 | /*------------------------------------------------- | |
| 454 | colortable_entry_get_value - return the color | |
| 455 | of a colortable palette entry | |
| 456 | -------------------------------------------------*/ | |
| 457 | ||
| 458 | rgb_t colortable_palette_get_color(colortable *ctable, UINT32 entry) | |
| 459 | { | |
| 460 | assert(entry < ctable->palentries); | |
| 461 | return ctable->palette[entry]; | |
| 462 | } | |
| 463 | ||
| 464 | ||
| 465 | /*------------------------------------------------- | |
| 466 | colortable_get_transpen_mask - return a 32-bit | |
| 467 | transparency mask for a given gfx element and | |
| 468 | color | |
| 469 | -------------------------------------------------*/ | |
| 470 | ||
| 471 | UINT32 colortable_get_transpen_mask(colortable *ctable, const gfx_element *gfx, int color, int transcolor) | |
| 472 | { | |
| 473 | UINT32 entry = gfx->color_base + (color % gfx->total_colors) * gfx->color_granularity; | |
| 474 | UINT32 mask = 0; | |
| 475 | UINT32 count, bit; | |
| 476 | ||
| 477 | /* make sure we are in range */ | |
| 478 | assert(entry < ctable->entries); | |
| 479 | assert(gfx->color_depth <= 32); | |
| 480 | ||
| 481 | /* either gfx->color_depth entries or as many as we can get up until the end */ | |
| 482 | count = MIN(gfx->color_depth, ctable->entries - entry); | |
| 483 | ||
| 484 | /* set a bit anywhere the transcolor matches */ | |
| 485 | for (bit = 0; bit < count; bit++) | |
| 486 | if (ctable->raw[entry++] == transcolor) | |
| 487 | mask |= 1 << bit; | |
| 488 | ||
| 489 | /* return the final mask */ | |
| 490 | return mask; | |
| 491 | } | |
| 492 | ||
| 493 | ||
| 494 | /*------------------------------------------------- | |
| 495 | colortable_configure_tilemap_groups - | |
| 496 | configure groups in a tilemap to represent | |
| 497 | transparency based on colortable entries | |
| 498 | (each group maps to a gfx color) | |
| 499 | -------------------------------------------------*/ | |
| 500 | ||
| 501 | void colortable_configure_tilemap_groups(colortable *ctable, tilemap *tmap, const gfx_element *gfx, int transcolor) | |
| 502 | { | |
| 503 | int color; | |
| 504 | ||
| 505 | assert(gfx->total_colors <= TILEMAP_NUM_GROUPS); | |
| 506 | ||
| 507 | /* iterate over all colors in the tilemap */ | |
| 508 | for (color = 0; color < gfx->total_colors; color++) | |
| 509 | tilemap_set_transmask(tmap, color, colortable_get_transpen_mask(ctable, gfx, color, transcolor), 0); | |
| 510 | } | |
| 511 | ||
| 512 | ||
| 513 | ||
| 514 | /*************************************************************************** | |
| 515 | UTILITIES | |
| 516 | ***************************************************************************/ | |
| 517 | ||
| 518 | /*------------------------------------------------- | |
| 519 | get_black_pen - return the pen for a fixed | |
| 520 | black color | |
| 521 | -------------------------------------------------*/ | |
| 522 | ||
| 523 | pen_t get_black_pen(running_machine *machine) | |
| 524 | { | |
| 525 | palette_private *palette = machine->palette_data; | |
| 526 | return palette->black_pen; | |
| 527 | } | |
| 528 | ||
| 529 | ||
| 530 | /*------------------------------------------------- | |
| 531 | get_white_pen - return the pen for a fixed | |
| 532 | white color | |
| 533 | -------------------------------------------------*/ | |
| 534 | ||
| 535 | pen_t get_white_pen(running_machine *machine) | |
| 536 | { | |
| 537 | palette_private *palette = machine->palette_data; | |
| 538 | return palette->white_pen; | |
| 539 | } | |
| 540 | ||
| 541 | ||
| 542 | ||
| 543 | /*************************************************************************** | |
| 544 | INTERNAL FUNCTIONS | |
| 545 | ***************************************************************************/ | |
| 546 | ||
| 547 | /*------------------------------------------------- | |
| 548 | palette_presave - prepare the save arrays | |
| 549 | for saving | |
| 550 | -------------------------------------------------*/ | |
| 551 | ||
| 552 | static void palette_presave(void) | |
| 553 | { | |
| 554 | int numcolors = palette_get_num_colors(Machine->palette); | |
| 555 | palette_private *palette = Machine->palette_data; | |
| 556 | int index; | |
| 557 | ||
| 558 | /* fill the save arrays with updated pen and brightness information */ | |
| 559 | for (index = 0; index < numcolors; index++) | |
| 560 | { | |
| 561 | palette->save_pen[index] = palette_entry_get_color(Machine->palette, index); | |
| 562 | palette->save_bright[index] = palette_entry_get_contrast(Machine->palette, index); | |
| 563 | } | |
| 564 | } | |
| 565 | ||
| 566 | ||
| 567 | /*------------------------------------------------- | |
| 568 | palette_postload - called after restore to | |
| 569 | actually update the palette | |
| 570 | -------------------------------------------------*/ | |
| 571 | ||
| 572 | static void palette_postload(void) | |
| 573 | { | |
| 574 | int numcolors = palette_get_num_colors(Machine->palette); | |
| 575 | palette_private *palette = Machine->palette_data; | |
| 576 | int index; | |
| 577 | ||
| 578 | /* reset the pen and brightness for each entry */ | |
| 579 | for (index = 0; index < numcolors; index++) | |
| 580 | { | |
| 581 | palette_entry_set_color(Machine->palette, index, palette->save_pen[index]); | |
| 582 | palette_entry_set_contrast(Machine->palette, index, palette->save_bright[index]); | |
| 583 | } | |
| 584 | } | |
| 585 | ||
| 586 | ||
| 587 | /*------------------------------------------------- | |
| 588 | palette_exit - free any allocated memory | |
| 589 | -------------------------------------------------*/ | |
| 590 | ||
| 591 | static void palette_exit(running_machine *machine) | |
| 592 | { | |
| 593 | /* dereference the palette */ | |
| 594 | if (machine->palette != NULL) | |
| 595 | palette_deref(machine->palette); | |
| 596 | } | |
| 597 | ||
| 598 | ||
| 599 | /*------------------------------------------------- | |
| 600 | allocate_palette - allocate and configure the | |
| 601 | palette object itself | |
| 602 | -------------------------------------------------*/ | |
| 603 | ||
| 604 | static void allocate_palette(running_machine *machine, palette_private *palette) | |
| 605 | { | |
| 606 | int numgroups, index; | |
| 607 | ||
| 608 | /* determine the number of groups we need */ | |
| 609 | numgroups = 1; | |
| 610 | if (machine->drv->video_attributes & VIDEO_HAS_SHADOWS) | |
| 611 | palette->shadow_group = numgroups++; | |
| 612 | if (machine->drv->video_attributes & VIDEO_HAS_HIGHLIGHTS) | |
| 613 | palette->hilight_group = numgroups++; | |
| 614 | assert_always(machine->drv->total_colors * numgroups <= 65536, "Error: palette has more than 65536 colors."); | |
| 615 | ||
| 616 | /* allocate a palette object containing all the colors and groups */ | |
| 617 | machine->palette = palette_alloc(machine->drv->total_colors, numgroups); | |
| 618 | assert_always(machine->palette != NULL, "Failed to allocate system palette"); | |
| 619 | ||
| 620 | /* configure the groups */ | |
| 621 | if (palette->shadow_group != 0) | |
| 622 | palette_group_set_contrast(machine->palette, palette->shadow_group, PALETTE_DEFAULT_SHADOW_FACTOR); | |
| 623 | if (palette->hilight_group != 0) | |
| 624 | palette_group_set_contrast(machine->palette, palette->hilight_group, PALETTE_DEFAULT_HIGHLIGHT_FACTOR); | |
| 625 | ||
| 626 | /* set the initial colors to a standard rainbow */ | |
| 627 | for (index = 0; index < machine->drv->total_colors; index++) | |
| 628 | palette_entry_set_color(machine->palette, index, MAKE_RGB(pal1bit(index >> 0), pal1bit(index >> 1), pal1bit(index >> 2))); | |
| 629 | ||
| 630 | /* switch off the color mode */ | |
| 631 | switch (palette->format) | |
| 632 | { | |
| 633 | /* 16-bit paletteized case */ | |
| 634 | case BITMAP_FORMAT_INDEXED16: | |
| 635 | palette->black_pen = palette_get_black_entry(machine->palette); | |
| 636 | palette->white_pen = palette_get_white_entry(machine->palette); | |
| 637 | if (palette->black_pen >= 65536) | |
| 638 | palette->black_pen = 0; | |
| 639 | if (palette->white_pen >= 65536) | |
| 640 | palette->white_pen = 65536; | |
| 641 | break; | |
| 642 | ||
| 643 | /* 15-bit direct case */ | |
| 644 | case BITMAP_FORMAT_RGB15: | |
| 645 | palette->black_pen = rgb_to_rgb15(MAKE_RGB(0x00,0x00,0x00)); | |
| 646 | palette->white_pen = rgb_to_rgb15(MAKE_RGB(0xff,0xff,0xff)); | |
| 647 | break; | |
| 648 | ||
| 649 | /* 32-bit direct case */ | |
| 650 | case BITMAP_FORMAT_RGB32: | |
| 651 | palette->black_pen = MAKE_RGB(0x00,0x00,0x00); | |
| 652 | palette->white_pen = MAKE_RGB(0xff,0xff,0xff); | |
| 653 | break; | |
| 654 | ||
| 655 | /* screenless case */ | |
| 656 | case BITMAP_FORMAT_INVALID: | |
| 657 | default: | |
| 658 | break; | |
| 659 | } | |
| 660 | } | |
| 661 | ||
| 662 | ||
| 663 | /*------------------------------------------------- | |
| 664 | allocate_color_tables - allocate memory for | |
| 665 | pen and color tables | |
| 666 | -------------------------------------------------*/ | |
| 667 | ||
| 668 | static void allocate_color_tables(running_machine *machine, palette_private *palette) | |
| 669 | { | |
| 670 | int total_colors = palette_get_num_colors(machine->palette) * palette_get_num_groups(machine->palette); | |
| 671 | pen_t *pentable; | |
| 672 | int i; | |
| 673 | ||
| 674 | /* allocate memory for the pen table */ | |
| 675 | switch (palette->format) | |
| 676 | { | |
| 677 | case BITMAP_FORMAT_INDEXED16: | |
| 678 | /* create a dummy 1:1 mapping */ | |
| 679 | machine->pens = pentable = auto_malloc((total_colors + 2) * sizeof(machine->pens[0])); | |
| 680 | for (i = 0; i < total_colors + 2; i++) | |
| 681 | pentable[i] = i; | |
| 682 | break; | |
| 683 | ||
| 684 | case BITMAP_FORMAT_RGB15: | |
| 685 | machine->pens = palette_entry_list_adjusted_rgb15(machine->palette); | |
| 686 | break; | |
| 687 | ||
| 688 | case BITMAP_FORMAT_RGB32: | |
| 689 | machine->pens = palette_entry_list_adjusted(machine->palette); | |
| 690 | break; | |
| 691 | ||
| 692 | default: | |
| 693 | machine->pens = NULL; | |
| 694 | break; | |
| 695 | } | |
| 696 | } | |
| 697 | ||
| 698 | ||
| 699 | /*------------------------------------------------- | |
| 700 | allocate_shadow_tables - allocate memory for | |
| 701 | shadow tables | |
| 702 | -------------------------------------------------*/ | |
| 703 | ||
| 704 | static void allocate_shadow_tables(running_machine *machine, palette_private *palette) | |
| 705 | { | |
| 706 | /* if we have shadows, allocate shadow tables */ | |
| 707 | if (machine->drv->video_attributes & VIDEO_HAS_SHADOWS) | |
| 708 | { | |
| 709 | pen_t *table = auto_malloc(65536 * sizeof(*table)); | |
| 710 | int i; | |
| 711 | ||
| 712 | /* palettized mode gets a single 64k table in slots 0 and 2 */ | |
| 713 | if (palette->format == BITMAP_FORMAT_INDEXED16) | |
| 714 | { | |
| 715 | palette->shadow_table[0].base = palette->shadow_table[2].base = table; | |
| 716 | for (i = 0; i < 65536; i++) | |
| 717 | table[i] = (i < machine->drv->total_colors) ? (i + machine->drv->total_colors) : i; | |
| 718 | } | |
| 719 | ||
| 720 | /* RGB mode gets two 32k tables in slots 0 and 2 */ | |
| 721 | else | |
| 722 | { | |
| 723 | palette->shadow_table[0].base = table; | |
| 724 | palette->shadow_table[2].base = table + 32768; | |
| 725 | configure_rgb_shadows(machine, 0, PALETTE_DEFAULT_SHADOW_FACTOR); | |
| 726 | } | |
| 727 | } | |
| 728 | ||
| 729 | /* if we have hilights, allocate shadow tables */ | |
| 730 | if (machine->drv->video_attributes & VIDEO_HAS_HIGHLIGHTS) | |
| 731 | { | |
| 732 | pen_t *table = auto_malloc(65536 * sizeof(*table)); | |
| 733 | int i; | |
| 734 | ||
| 735 | /* palettized mode gets a single 64k table in slots 1 and 3 */ | |
| 736 | if (palette->format == BITMAP_FORMAT_INDEXED16) | |
| 737 | { | |
| 738 | palette->shadow_table[1].base = palette->shadow_table[3].base = table; | |
| 739 | for (i = 0; i < 65536; i++) | |
| 740 | table[i] = (i < machine->drv->total_colors) ? (i + 2 * machine->drv->total_colors) : i; | |
| 741 | } | |
| 742 | ||
| 743 | /* RGB mode gets two 32k tables in slots 1 and 3 */ | |
| 744 | else | |
| 745 | { | |
| 746 | palette->shadow_table[1].base = table; | |
| 747 | palette->shadow_table[3].base = table + 32768; | |
| 748 | configure_rgb_shadows(machine, 1, PALETTE_DEFAULT_HIGHLIGHT_FACTOR); | |
| 749 | } | |
| 750 | } | |
| 751 | ||
| 752 | /* set the default table */ | |
| 753 | machine->shadow_table = palette->shadow_table[0].base; | |
| 754 | } | |
| 755 | ||
| 756 | ||
| 757 | /*------------------------------------------------- | |
| 758 | configure_rgb_shadows - configure shadows | |
| 759 | for the RGB tables | |
| 760 | -------------------------------------------------*/ | |
| 761 | ||
| 762 | static void configure_rgb_shadows(running_machine *machine, int mode, float factor) | |
| 763 | { | |
| 764 | palette_private *palette = machine->palette_data; | |
| 765 | shadow_table_data *stable = &palette->shadow_table[mode]; | |
| 766 | int ifactor = (int)(factor * 256.0f); | |
| 767 | int i; | |
| 768 | ||
| 769 | /* only applies to RGB direct modes */ | |
| 770 | assert(palette->format != BITMAP_FORMAT_INDEXED16); | |
| 771 | assert(stable->base != NULL); | |
| 772 | ||
| 773 | #if VERBOSE | |
| 774 | popmessage("shadow %d recalc %d %d %d %02x", mode, dr, dg, db, noclip); | |
| 775 | #endif | |
| 776 | ||
| 777 | /* regenerate the table */ | |
| 778 | for (i = 0; i < 32768; i++) | |
| 779 | { | |
| 780 | UINT8 r = rgb_clamp((pal5bit(i >> 10) * ifactor) >> 8); | |
| 781 | UINT8 g = rgb_clamp((pal5bit(i >> 5) * ifactor) >> 8); | |
| 782 | UINT8 b = rgb_clamp((pal5bit(i >> 0) * ifactor) >> 8); | |
| 783 | pen_t final = MAKE_RGB(r, g, b); | |
| 784 | ||
| 785 | /* store either 16 or 32 bit */ | |
| 786 | if (palette->format == BITMAP_FORMAT_RGB32) | |
| 787 | stable->base[i] = final; | |
| 788 | else | |
| 789 | stable->base[i] = rgb_to_rgb15(final); | |
| 790 | } | |
| 791 | } |
| r936 | r937 | |
|---|---|---|
| 293 | 293 | FUNCTION PROTOTYPES |
| 294 | 294 | ***************************************************************************/ |
| 295 | 295 | |
| 296 | ||
| 297 | /* ----- core implementation ----- */ | |
| 298 | ||
| 299 | /* allocate base structures for the rendering system */ | |
| 296 | 300 | void render_init(running_machine *machine); |
| 301 | ||
| 302 | /* set a notifier that we call before doing long scaling operations */ | |
| 297 | 303 | void render_set_rescale_notify(running_machine *machine, int (*notifier)(running_machine *, int, int)); |
| 304 | ||
| 305 | /* return a bitmask indicating the live screens */ | |
| 298 | 306 | UINT32 render_get_live_screens_mask(void); |
| 299 | float render_get_ui_aspect(void); | |
| 307 | ||
| 308 | /* return the smallest maximum update rate across all targets */ | |
| 309 | float render_get_max_update_rate(void); | |
| 310 | ||
| 311 | /* select the UI target */ | |
| 300 | 312 | void render_set_ui_target(render_target *target); |
| 313 | ||
| 314 | /* return the UI target */ | |
| 301 | 315 | render_target *render_get_ui_target(void); |
| 302 | 316 | |
| 317 | /* return the aspect ratio for UI fonts */ | |
| 318 | float render_get_ui_aspect(void); | |
| 303 | 319 | |
| 320 | ||
| 321 | ||
| 304 | 322 | /* ----- render target management ----- */ |
| 305 | 323 | |
| 324 | /* allocate a new render target */ | |
| 306 | 325 | render_target *render_target_alloc(const char *layout, UINT32 flags); |
| 326 | ||
| 327 | /* free memory for a render target */ | |
| 307 | 328 | void render_target_free(render_target *target); |
| 329 | ||
| 330 | /* get a render_target by index */ | |
| 308 | 331 | render_target *render_target_get_indexed(int index); |
| 332 | ||
| 333 | /* return the name of the indexed view, or NULL if it doesn't exist */ | |
| 309 | 334 | const char *render_target_get_view_name(render_target *target, int viewindex); |
| 335 | ||
| 336 | /* return a bitmask of which screens are visible on a given view */ | |
| 310 | 337 | UINT32 render_target_get_view_screens(render_target *target, int viewindex); |
| 338 | ||
| 339 | /* get the bounds and pixel aspect of a target */ | |
| 311 | 340 | void render_target_get_bounds(render_target *target, INT32 *width, INT32 *height, float *pixel_aspect); |
| 341 | ||
| 342 | /* set the bounds and pixel aspect of a target */ | |
| 312 | 343 | void render_target_set_bounds(render_target *target, INT32 width, INT32 height, float pixel_aspect); |
| 344 | ||
| 345 | /* get the maximum update rate (refresh rate) of a target, or 0 if no maximum */ | |
| 346 | float render_target_get_max_update_rate(render_target *target); | |
| 347 | ||
| 348 | /* set the maximum update rate (refresh rate) of a target, or 0 if no maximum */ | |
| 349 | void render_target_set_max_update_rate(render_target *target, float updates_per_second); | |
| 350 | ||
| 351 | /* get the orientation of a target */ | |
| 313 | 352 | int render_target_get_orientation(render_target *target); |
| 353 | ||
| 354 | /* set the orientation of a target */ | |
| 314 | 355 | void render_target_set_orientation(render_target *target, int orientation); |
| 356 | ||
| 357 | /* get the layer config of a target */ | |
| 315 | 358 | int render_target_get_layer_config(render_target *target); |
| 359 | ||
| 360 | /* set the layer config of a target */ | |
| 316 | 361 | void render_target_set_layer_config(render_target *target, int layerconfig); |
| 362 | ||
| 363 | /* return the currently selected view index */ | |
| 317 | 364 | int render_target_get_view(render_target *target); |
| 365 | ||
| 366 | /* dynamically change the view for a target */ | |
| 318 | 367 | void render_target_set_view(render_target *target, int viewindex); |
| 368 | ||
| 369 | /* set the upper bound on the texture size */ | |
| 319 | 370 | void render_target_set_max_texture_size(render_target *target, int maxwidth, int maxheight); |
| 371 | ||
| 372 | /* compute the visible area for the given target with the current layout and proposed new parameters */ | |
| 320 | 373 | void render_target_compute_visible_area(render_target *target, INT32 target_width, INT32 target_height, float target_pixel_aspect, UINT8 target_orientation, INT32 *visible_width, INT32 *visible_height); |
| 374 | ||
| 375 | /* get the "minimum" size of a target, which is the smallest bounds that will ensure at least | |
| 376 | 1 target pixel per source pixel for all included screens */ | |
| 321 | 377 | void render_target_get_minimum_size(render_target *target, INT32 *minwidth, INT32 *minheight); |
| 378 | ||
| 379 | /* return a list of primitives for a given render target */ | |
| 322 | 380 | const render_primitive_list *render_target_get_primitives(render_target *target); |
| 323 | 381 | |
| 324 | 382 | |
| 383 | ||
| 325 | 384 | /* ----- render texture management ----- */ |
| 326 | 385 | |
| 386 | /* allocate a new texture */ | |
| 327 | 387 | render_texture *render_texture_alloc(texture_scaler scaler, void *param); |
| 388 | ||
| 389 | /* free an allocated texture */ | |
| 328 | 390 | void render_texture_free(render_texture *texture); |
| 391 | ||
| 392 | /* set a new source bitmap */ | |
| 329 | 393 | void render_texture_set_bitmap(render_texture *texture, mame_bitmap *bitmap, const rectangle *sbounds, UINT32 palettebase, int format); |
| 394 | ||
| 395 | /* generic high quality resampling scaler */ | |
| 330 | 396 | void render_texture_hq_scale(mame_bitmap *dest, const mame_bitmap *source, const rectangle *sbounds, void *param); |
| 331 | 397 | |
| 332 | 398 | |
| 399 | ||
| 333 | 400 | /* ----- render containers ----- */ |
| 334 | 401 | |
| 402 | /* empty a container in preparation for new stuff */ | |
| 335 | 403 | void render_container_empty(render_container *container); |
| 404 | ||
| 405 | /* return true if a container has nothing in it */ | |
| 336 | 406 | int render_container_is_empty(render_container *container); |
| 407 | ||
| 408 | /* return the orientation of a container */ | |
| 337 | 409 | int render_container_get_orientation(render_container *container); |
| 410 | ||
| 411 | /* set the orientation of a container */ | |
| 338 | 412 | void render_container_set_orientation(render_container *container, int orientation); |
| 413 | ||
| 414 | /* return the brightness of a container */ | |
| 339 | 415 | float render_container_get_brightness(render_container *container); |
| 416 | ||
| 417 | /* set the brightness of a container */ | |
| 340 | 418 | void render_container_set_brightness(render_container *container, float brightness); |
| 419 | ||
| 420 | /* return the contrast of a container */ | |
| 341 | 421 | float render_container_get_contrast(render_container *container); |
| 422 | ||
| 423 | /* set the contrast of a container */ | |
| 342 | 424 | void render_container_set_contrast(render_container *container, float contrast); |
| 425 | ||
| 426 | /* return the gamma of a container */ | |
| 343 | 427 | float render_container_get_gamma(render_container *container); |
| 428 | ||
| 429 | /* set the gamma of a container */ | |
| 344 | 430 | void render_container_set_gamma(render_container *container, float gamma); |
| 431 | ||
| 432 | /* return the X scale of a container */ | |
| 345 | 433 | float render_container_get_xscale(render_container *container); |
| 434 | ||
| 435 | /* set the X scale of a container */ | |
| 346 | 436 | void render_container_set_xscale(render_container *container, float xscale); |
| 437 | ||
| 438 | /* return the Y scale of a container */ | |
| 347 | 439 | float render_container_get_yscale(render_container *container); |
| 440 | ||
| 441 | /* set the Y scale of a container */ | |
| 348 | 442 | void render_container_set_yscale(render_container *container, float yscale); |
| 443 | ||
| 444 | /* return the X offset of a container */ | |
| 349 | 445 | float render_container_get_xoffset(render_container *container); |
| 446 | ||
| 447 | /* set the X offset of a container */ | |
| 350 | 448 | void render_container_set_xoffset(render_container *container, float xoffset); |
| 449 | ||
| 450 | /* return the Y offset of a container */ | |
| 351 | 451 | float render_container_get_yoffset(render_container *container); |
| 452 | ||
| 453 | /* set the Y offset of a container */ | |
| 352 | 454 | void render_container_set_yoffset(render_container *container, float yoffset); |
| 455 | ||
| 456 | /* set the overlay bitmap for the container */ | |
| 353 | 457 | void render_container_set_overlay(render_container *container, mame_bitmap *bitmap); |
| 458 | ||
| 459 | /* return a pointer to the UI container */ | |
| 354 | 460 | render_container *render_container_get_ui(void); |
| 461 | ||
| 462 | /* return a pointer to the indexed screen container */ | |
| 355 | 463 | render_container *render_container_get_screen(int screen); |
| 464 | ||
| 465 | /* set the opacity of a given palette entry */ | |
| 356 | 466 | void render_container_set_palette_alpha(render_container *container, UINT32 entry, UINT8 alpha); |
| 467 | ||
| 468 | /* add a line item to the specified container */ | |
| 357 | 469 | void render_container_add_line(render_container *container, float x0, float y0, float x1, float y1, float width, rgb_t argb, UINT32 flags); |
| 470 | ||
| 471 | /* add a quad item to the specified container */ | |
| 358 | 472 | void render_container_add_quad(render_container *container, float x0, float y0, float x1, float y1, rgb_t argb, render_texture *texture, UINT32 flags); |
| 473 | ||
| 474 | /* add a char item to the specified container */ | |
| 359 | 475 | void render_container_add_char(render_container *container, float x0, float y0, float height, float aspect, rgb_t argb, render_font *font, UINT16 ch); |
| 360 | 476 | |
| 361 | 477 |
| r936 | r937 | |
|---|---|---|
| 264 | 264 | |
| 265 | 265 | #ifndef MESS |
| 266 | 266 | /* make sure sound-less drivers are flagged */ |
| 267 | if ((driver->flags & GAME_IS_BIOS_ROOT) == 0 && drv->sound[0].sound_type == | |
| 267 | if ((driver->flags & GAME_IS_BIOS_ROOT) == 0 && drv->sound[0].sound_type == SOUND_DUMMY && (driver->flags & GAME_NO_SOUND) == 0 && strcmp(driver->name, "minivadr")) | |
| 268 | 268 | { |
| 269 | 269 | mame_printf_error("%s: %s missing GAME_NO_SOUND flag\n", driver->source_file, driver->name); |
| 270 | 270 | error = TRUE; |
| r936 | r937 | |
| 471 | 471 | int spacenum; |
| 472 | 472 | |
| 473 | 473 | /* skip empty entries */ |
| 474 | if (cpu->cpu_type == | |
| 474 | if (cpu->cpu_type == CPU_DUMMY) | |
| 475 | 475 | continue; |
| 476 | 476 | |
| 477 | 477 | /* checks to see if this driver is using a dummy CPU */ |
| r0 | r937 | |
|---|---|---|
| 1 | /****************************************************************************** | |
| 2 | ||
| 3 | emupal.h | |
| 4 | ||
| 5 | Emulator palette handling functions. | |
| 6 | ||
| 7 | Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team. | |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. | |
| 9 | ||
| 10 | There are several levels of abstraction in the way MAME handles the palette, | |
| 11 | and several display modes which can be used by the drivers. | |
| 12 | ||
| 13 | Palette | |
| 14 | ------- | |
| 15 | Note: in the following text, "color" refers to a color in the emulated | |
| 16 | game's virtual palette. For example, a game might be able to display 1024 | |
| 17 | colors at the same time. If the game uses RAM to change the available | |
| 18 | colors, the term "palette" refers to the colors available at any given time, | |
| 19 | not to the whole range of colors which can be produced by the hardware. The | |
| 20 | latter is referred to as "color space". | |
| 21 | The term "pen" refers to one of the maximum MAX_PENS colors that can be | |
| 22 | used to generate the display. | |
| 23 | ||
| 24 | So, to summarize, the three layers of palette abstraction are: | |
| 25 | ||
| 26 | P1) The game virtual palette (the "colors") | |
| 27 | P2) MAME's MAX_PENS colors palette (the "pens") | |
| 28 | P3) The OS specific hardware color registers (the "OS specific pens") | |
| 29 | ||
| 30 | The array Machine->pens[] is a lookup table which maps game colors to OS | |
| 31 | specific pens (P1 to P3). When you are working on bitmaps at the pixel level, | |
| 32 | *always* use Machine->pens to map the color numbers. *Never* use constants. | |
| 33 | For example if you want to make pixel (x,y) of color 3, do: | |
| 34 | *BITMAP_ADDR(bitmap, <type>, y, x) = Machine->pens[3]; | |
| 35 | ||
| 36 | ||
| 37 | Lookup table | |
| 38 | ------------ | |
| 39 | Palettes are only half of the story. To map the gfx data to colors, the | |
| 40 | graphics routines use a lookup table. For example if we have 4bpp tiles, | |
| 41 | which can have 256 different color codes, the lookup table for them will have | |
| 42 | 256 * 2^4 = 4096 elements. For games using a palette RAM, the lookup table is | |
| 43 | usually a 1:1 map. For games using PROMs, the lookup table is often larger | |
| 44 | than the palette itself so for example the game can display 256 colors out | |
| 45 | of a palette of 16. | |
| 46 | ||
| 47 | The palette and the lookup table are initialized to default values by the | |
| 48 | main core, but can be initialized by the driver using the function | |
| 49 | MachineDriver->vh_init_palette(). For games using palette RAM, that | |
| 50 | function is usually not needed, and the lookup table can be set up by | |
| 51 | properly initializing the color_codes_start and total_color_codes fields in | |
| 52 | the GfxDecodeInfo array. | |
| 53 | When vh_init_palette() initializes the lookup table, it maps gfx codes | |
| 54 | to game colors (P1 above). The lookup table will be converted by the core to | |
| 55 | map to OS specific pens (P3 above), and stored in Machine->remapped_colortable. | |
| 56 | ||
| 57 | ||
| 58 | Display modes | |
| 59 | ------------- | |
| 60 | The available display modes can be summarized in three categories: | |
| 61 | 1) Static palette. Use this for games which use PROMs for color generation. | |
| 62 | The palette is initialized by palette_init(), and never changed | |
| 63 | again. | |
| 64 | 2) Dynamic palette. Use this for games which use RAM for color generation. | |
| 65 | The palette can be dynamically modified by the driver using the function | |
| 66 | palette_set_color(). | |
| 67 | 3) Direct mapped 16-bit or 32-bit color. This should only be used in special | |
| 68 | cases, e.g. to support alpha blending. | |
| 69 | MachineDriver->video_attributes must contain VIDEO_RGB_DIRECT. | |
| 70 | ||
| 71 | ||
| 72 | Shadows(Highlights) Quick Reference | |
| 73 | ----------------------------------- | |
| 74 | ||
| 75 | 1) declare MDRV_VIDEO_ATTRIBUTES( ... VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS ... ) | |
| 76 | ||
| 77 | 2) set gfx_drawmode_table[0-n] to DRAWMODE_NONE, DRAWMODE_SOURCE or DRAWMODE_SHADOW | |
| 78 | ||
| 79 | 3) (optional) set shadow darkness or highlight brightness by | |
| 80 | palette_set_shadow_factor(0.0-1.0) or | |
| 81 | palette_set_highlight_factor(1.0-n.n) | |
| 82 | ||
| 83 | 4) before calling drawgfx use | |
| 84 | palette_set_shadow_mode(0) to arm shadows or | |
| 85 | palette_set_shadow_mode(1) to arm highlights | |
| 86 | ||
| 87 | 5) call drawgfx with the TRANSPARENCY_PEN_TABLE flag | |
| 88 | drawgfx( ..., cliprect, TRANSPARENCY_PEN_TABLE, transparent_color ) | |
| 89 | ||
| 90 | ******************************************************************************/ | |
| 91 | ||
| 92 | #pragma once | |
| 93 | ||
| 94 | #ifndef __EMUPAL_H__ | |
| 95 | #define __EMUPAL_H__ | |
| 96 | ||
| 97 | #include "palette.h" | |
| 98 | #include "memory.h" | |
| 99 | #include "tilemap.h" | |
| 100 | ||
| 101 | ||
| 102 | /*************************************************************************** | |
| 103 | CONSTANTS | |
| 104 | ***************************************************************************/ | |
| 105 | ||
| 106 | #define PALETTE_DEFAULT_SHADOW_FACTOR (0.6) | |
| 107 | #define PALETTE_DEFAULT_HIGHLIGHT_FACTOR (1/PALETTE_DEFAULT_SHADOW_FACTOR) | |
| 108 | ||
| 109 | ||
| 110 | ||
| 111 | /*************************************************************************** | |
| 112 | TYPE DEFINITIONS | |
| 113 | ***************************************************************************/ | |
| 114 | ||
| 115 | typedef struct _colortable colortable; | |
| 116 | ||
| 117 | ||
| 118 | ||
| 119 | /*************************************************************************** | |
| 120 | FUNCTION PROTOTYPES | |
| 121 | ***************************************************************************/ | |
| 122 | ||
| 123 | ||
| 124 | /* ----- initialization and configuration ----- */ | |
| 125 | ||
| 126 | /* palette initialization that takes place before the display is created */ | |
| 127 | void palette_init(running_machine *machine); | |
| 128 | ||
| 129 | /* palette initialization that takes place after the display is created */ | |
| 130 | void palette_config(running_machine *machine); | |
| 131 | ||
| 132 | ||
| 133 | ||
| 134 | /* ----- shadow/hilight configuration ----- */ | |
| 135 | ||
| 136 | /* set the global shadow brightness factor */ | |
| 137 | void palette_set_shadow_factor(running_machine *machine, double factor); | |
| 138 | ||
| 139 | /* set the global highlight brightness factor */ | |
| 140 | void palette_set_highlight_factor(running_machine *machine, double factor); | |
| 141 | ||
| 142 | ||
| 143 | ||
| 144 | /* ----- shadow table configuration ----- */ | |
| 145 | ||
| 146 | /* select 1 of 4 different live shadow tables */ | |
| 147 | void palette_set_shadow_mode(running_machine *machine, int mode); | |
| 148 | ||
| 149 | /* configure delta RGB values for 1 of 4 shadow tables */ | |
| 150 | void palette_set_shadow_dRGB32(running_machine *machine, int mode, int dr, int dg, int db, int noclip); | |
| 151 | ||
| 152 | ||
| 153 | ||
| 154 | /* ----- colortable management ----- */ | |
| 155 | ||
| 156 | /* allocate a new colortable with the given number of entries */ | |
| 157 | colortable *colortable_alloc(running_machine *machine, UINT32 palettesize); | |
| 158 | ||
| 159 | /* set the value of a colortable entry */ | |
| 160 | void colortable_entry_set_value(colortable *ctable, UINT32 entry, UINT16 value); | |
| 161 | ||
| 162 | /* return the value of a colortable entry */ | |
| 163 | UINT16 colortable_entry_get_value(colortable *ctable, UINT32 entry); | |
| 164 | ||
| 165 | /* change the color of a colortable palette entry */ | |
| 166 | void colortable_palette_set_color(colortable *ctable, UINT32 entry, rgb_t color); | |
| 167 | ||
| 168 | /* return the color of a colortable palette entry */ | |
| 169 | rgb_t colortable_palette_get_color(colortable *ctable, UINT32 entry); | |
| 170 | ||
| 171 | /* return a 32-bit transparency mask for a given gfx element and color */ | |
| 172 | UINT32 colortable_get_transpen_mask(colortable *ctable, const gfx_element *gfx, int color, int transcolor); | |
| 173 | ||
| 174 | /* configure groups in a tilemap to represent transparency based on colortable entries (each group maps to a gfx color) */ | |
| 175 | void colortable_configure_tilemap_groups(colortable *ctable, tilemap *tmap, const gfx_element *gfx, int transcolor); | |
| 176 | ||
| 177 | ||
| 178 | ||
| 179 | /* ----- utilities ----- */ | |
| 180 | ||
| 181 | /* return the pen for a fixed black color */ | |
| 182 | pen_t get_black_pen(running_machine *machine); | |
| 183 | ||
| 184 | /* return the pen for a fixed white color */ | |
| 185 | pen_t get_white_pen(running_machine *machine); | |
| 186 | ||
| 187 | ||
| 188 | ||
| 189 | ||
| 190 | /*************************************************************************** | |
| 191 | INLINE FUNCTIONS | |
| 192 | ***************************************************************************/ | |
| 193 | ||
| 194 | /*------------------------------------------------- | |
| 195 | palette_set_color - set a single palette | |
| 196 | entry | |
| 197 | -------------------------------------------------*/ | |
| 198 | ||
| 199 | INLINE void palette_set_color(running_machine *machine, pen_t pen, rgb_t rgb) | |
| 200 | { | |
| 201 | palette_entry_set_color(machine->palette, pen, rgb); | |
| 202 | } | |
| 203 | ||
| 204 | ||
| 205 | /*------------------------------------------------- | |
| 206 | palette_set_color_rgb - set a single palette | |
| 207 | entry with individual R,G,B components | |
| 208 | -------------------------------------------------*/ | |
| 209 | ||
| 210 | INLINE void palette_set_color_rgb(running_machine *machine, pen_t pen, UINT8 r, UINT8 g, UINT8 b) | |
| 211 | { | |
| 212 | palette_entry_set_color(machine->palette, pen, MAKE_RGB(r, g, b)); | |
| 213 | } | |
| 214 | ||
| 215 | ||
| 216 | /*------------------------------------------------- | |
| 217 | palette_get_color - return a single palette | |
| 218 | entry | |
| 219 | -------------------------------------------------*/ | |
| 220 | ||
| 221 | INLINE rgb_t palette_get_color(running_machine *machine, pen_t pen) | |
| 222 | { | |
| 223 | return palette_entry_get_color(machine->palette, pen); | |
| 224 | } | |
| 225 | ||
| 226 | ||
| 227 | /*------------------------------------------------- | |
| 228 | palette_set_brightness - set the per-pen | |
| 229 | brightness factor | |
| 230 | -------------------------------------------------*/ | |
| 231 | ||
| 232 | INLINE void palette_set_brightness(running_machine *machine, pen_t pen, double bright) | |
| 233 | { | |
| 234 | palette_entry_set_contrast(machine->palette, pen, bright); | |
| 235 | } | |
| 236 | ||
| 237 | ||
| 238 | /*------------------------------------------------- | |
| 239 | palette_set_colors - set multiple palette | |
| 240 | entries from an array of rgb_t values | |
| 241 | -------------------------------------------------*/ | |
| 242 | ||
| 243 | INLINE void palette_set_colors(running_machine *machine, pen_t color_base, const rgb_t *colors, int color_count) | |
| 244 | { | |
| 245 | while (color_count--) | |
| 246 | palette_entry_set_color(machine->palette, color_base++, *colors++); | |
| 247 | } | |
| 248 | ||
| 249 | ||
| 250 | #endif /* __PALETTE_H__ */ |
| r936 | r937 | |
|---|---|---|
| 41 | 41 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) |
| 42 | 42 | |
| 43 | 43 | MDRV_SCREEN_ADD("main", 0) |
| 44 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_ | |
| 44 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32 | |
| 45 | 45 | MDRV_SCREEN_SIZE(640,480) |
| 46 | 46 | MDRV_SCREEN_VISIBLE_AREA(0,639, 0,479) |
| 47 | 47 | MDRV_SCREEN_REFRESH_RATE(30) |
| r936 | r937 | |
|---|---|---|
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | /*************************************************************************** |
| 28 | TYPE DEFINITIONS | |
| 29 | ***************************************************************************/ | |
| 30 | ||
| 31 | typedef struct _open_chd open_chd; | |
| 32 | struct _open_chd | |
| 33 | { | |
| 34 | open_chd * next; /* pointer to next in the list */ | |
| 35 | chd_file * origchd; /* handle to the original CHD */ | |
| 36 | mame_file * origfile; /* file handle to the original CHD file */ | |
| 37 | chd_file * diffchd; /* handle to the diff CHD */ | |
| 38 | mame_file * difffile; /* file handle to the diff CHD file */ | |
| 39 | }; | |
| 40 | ||
| 41 | ||
| 42 | ||
| 43 | /*************************************************************************** | |
| 28 | 44 | GLOBAL VARIABLES |
| 29 | 45 | ***************************************************************************/ |
| 30 | 46 | |
| 31 | 47 | /* disks */ |
| 32 | static chd_file *disk_handle[4]; | |
| 48 | static open_chd *chd_list; | |
| 49 | static open_chd **chd_list_tailptr; | |
| 33 | 50 | |
| 34 | 51 | /* system BIOS */ |
| 35 | 52 | int system_bios; |
| r936 | r937 | |
| 44 | 61 | |
| 45 | 62 | chd_file *get_disk_handle(int diskindex) |
| 46 | 63 | { |
| 47 | return disk_handle[diskindex]; | |
| 64 | open_chd *curdisk; | |
| 65 | for (curdisk = chd_list; curdisk != NULL && diskindex-- != 0; curdisk = curdisk->next) ; | |
| 66 | return (curdisk->diffchd != NULL) ? curdisk->diffchd : curdisk->origchd; | |
| 48 | 67 | } |
| 49 | 68 | |
| 50 | 69 | |
| r936 | r937 | |
| 424 | 443 | if (type >= REGION_CPU1 && type < REGION_CPU1 + MAX_CPU) |
| 425 | 444 | { |
| 426 | 445 | int cputype = Machine->drv->cpu[type - REGION_CPU1].cpu_type; |
| 427 | if (cputype != | |
| 446 | if (cputype != CPU_DUMMY) | |
| 428 | 447 | { |
| 429 | 448 | datawidth = cputype_databus_width(cputype, ADDRESS_SPACE_PROGRAM) / 8; |
| 430 | 449 | littleendian = (cputype_endianness(cputype) == CPU_IS_LE); |
| r936 | r937 | |
| 795 | 814 | up the parent and loading by checksum |
| 796 | 815 | -------------------------------------------------*/ |
| 797 | 816 | |
| 798 | chd_error open_disk_image(const game_driver *gamedrv, const rom_entry *romp, chd_file **image) | |
| 817 | chd_error open_disk_image(const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd) | |
| 799 | 818 | { |
| 800 | 819 | const game_driver *drv; |
| 801 | 820 | const rom_entry *region, *rom; |
| 802 | 821 | astring *fname; |
| 822 | file_error filerr; | |
| 803 | 823 | chd_error err; |
| 804 | 824 | |
| 825 | *image_file = NULL; | |
| 826 | *image_chd = NULL; | |
| 827 | ||
| 805 | 828 | /* attempt to open the properly named file */ |
| 806 | fname = astring_assemble_2(astring_alloc(), ROM_GETNAME(romp), ".chd"); | |
| 807 | err = chd_open(astring_c(fname), CHD_OPEN_READ, NULL, image); | |
| 829 | fname = astring_assemble_4(astring_alloc(), gamedrv->name, PATH_SEPARATOR, ROM_GETNAME(romp), ".chd"); | |
| 830 | filerr = mame_fopen(SEARCHPATH_IMAGE, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_WRITE, image_file); | |
| 808 | 831 | astring_free(fname); |
| 809 | 832 | |
| 810 | /* if that worked, we're done */ | |
| 811 | if (err == CHDERR_NONE) | |
| 812 | return err; | |
| 833 | /* did the file open succeed? */ | |
| 834 | if (filerr == FILERR_NONE) | |
| 835 | { | |
| 836 | /* try to open the CHD */ | |
| 837 | err = chd_open_file(mame_core_file(*image_file), CHD_OPEN_READ, NULL, image_chd); | |
| 838 | if (err == CHDERR_NONE) | |
| 839 | return err; | |
| 813 | 840 | |
| 841 | /* close the file on failure */ | |
| 842 | mame_fclose(*image_file); | |
| 843 | *image_file = NULL; | |
| 844 | } | |
| 845 | else | |
| 846 | err = CHDERR_FILE_NOT_FOUND; | |
| 847 | ||
| 814 | 848 | /* otherwise, look at our parents for a CHD with an identical checksum */ |
| 815 | 849 | /* and try to open that */ |
| 816 | 850 | for (drv = gamedrv; drv != NULL; drv = driver_get_clone(drv)) |
| r936 | r937 | |
| 822 | 856 | if (strcmp(ROM_GETNAME(romp), ROM_GETNAME(rom)) != 0 && |
| 823 | 857 | hash_data_is_equal(ROM_GETHASHDATA(romp), ROM_GETHASHDATA(rom), 0)) |
| 824 | 858 | { |
| 825 | fname = astring_assemble_2(astring_alloc(), ROM_GETNAME(rom), ".chd"); | |
| 826 | err = chd_open(astring_c(fname), CHD_OPEN_READ, NULL, image); | |
| 859 | fname = astring_assemble_4(astring_alloc(), drv->name, PATH_SEPARATOR, ROM_GETNAME(rom), ".chd"); | |
| 860 | filerr = mame_fopen(SEARCHPATH_IMAGE, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_WRITE, image_file); | |
| 827 | 861 | astring_free(fname); |
| 828 | 862 | |
| 829 | /* if that worked, we're done */ | |
| 830 | if (err == CHDERR_NONE) | |
| 831 | return err; | |
| 863 | /* did the file open succeed? */ | |
| 864 | if (filerr == FILERR_NONE) | |
| 865 | { | |
| 866 | /* try to open the CHD */ | |
| 867 | err = chd_open_file(mame_core_file(*image_file), CHD_OPEN_READ, NULL, image_chd); | |
| 868 | if (err == CHDERR_NONE) | |
| 869 | return err; | |
| 870 | ||
| 871 | /* close the file on failure */ | |
| 872 | mame_fclose(*image_file); | |
| 873 | *image_file = NULL; | |
| 874 | } | |
| 832 | 875 | } |
| 833 | 876 | |
| 834 | 877 | return err; |
| r936 | r937 | |
| 836 | 879 | |
| 837 | 880 | |
| 838 | 881 | /*------------------------------------------------- |
| 882 | open_disk_diff - open a DISK diff file | |
| 883 | -------------------------------------------------*/ | |
| 884 | ||
| 885 | static chd_error open_disk_diff(const game_driver *drv, const rom_entry *romp, chd_file *source, mame_file **diff_file, chd_file **diff_chd) | |
| 886 | { | |
| 887 | astring *fname = astring_assemble_2(astring_alloc(), ROM_GETNAME(romp), ".dif"); | |
| 888 | file_error filerr; | |
| 889 | chd_error err; | |
| 890 | ||
| 891 | *diff_file = NULL; | |
| 892 | *diff_chd = NULL; | |
| 893 | ||
| 894 | /* try to open the diff */ | |
| 895 | debugload("Opening differencing image file: %s\n", astring_c(fname)); | |
| 896 | filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_WRITE, diff_file); | |
| 897 | if (filerr != FILERR_NONE) | |
| 898 | { | |
| 899 | /* didn't work; try creating it instead */ | |
| 900 | debugload("Creating differencing image: %s\n", astring_c(fname)); | |
| 901 | filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, diff_file); | |
| 902 | if (filerr != FILERR_NONE) | |
| 903 | { | |
| 904 | err = CHDERR_FILE_NOT_FOUND; | |
| 905 | goto done; | |
| 906 | } | |
| 907 | ||
| 908 | /* create the CHD */ | |
| 909 | err = chd_create_file(mame_core_file(*diff_file), 0, 0, CHDCOMPRESSION_NONE, source); | |
| 910 | if (err != CHDERR_NONE) | |
| 911 | goto done; | |
| 912 | } | |
| 913 | ||
| 914 | debugload("Opening differencing image file: %s\n", astring_c(fname)); | |
| 915 | err = chd_open_file(mame_core_file(*diff_file), CHD_OPEN_READWRITE, source, diff_chd); | |
| 916 | if (err != CHDERR_NONE) | |
| 917 | goto done; | |
| 918 | ||
| 919 | done: | |
| 920 | astring_free(fname); | |
| 921 | if ((err != CHDERR_NONE) && (*diff_file != NULL)) | |
| 922 | { | |
| 923 | mame_fclose(*diff_file); | |
| 924 | *diff_file = NULL; | |
| 925 | } | |
| 926 | return err; | |
| 927 | } | |
| 928 | ||
| 929 | ||
| 930 | /*------------------------------------------------- | |
| 839 | 931 | process_disk_entries - process all disk entries |
| 840 | 932 | for a region |
| 841 | 933 | -------------------------------------------------*/ |
| r936 | r937 | |
| 848 | 940 | /* handle files */ |
| 849 | 941 | if (ROMENTRY_ISFILE(romp)) |
| 850 | 942 | { |
| 851 | chd_file *source, *diff = NULL; | |
| 943 | char acthash[HASH_BUF_SIZE]; | |
| 944 | open_chd chd = { 0 }; | |
| 852 | 945 | chd_header header; |
| 853 | char filename[1024]; | |
| 854 | char acthash[HASH_BUF_SIZE]; | |
| 946 | astring *filename; | |
| 855 | 947 | chd_error err; |
| 856 | 948 | |
| 857 | 949 | /* make the filename of the source */ |
| 858 | | |
| 950 | | |
| 859 | 951 | |
| 860 | 952 | /* first open the source drive */ |
| 861 | debugload("Opening disk image: %s\n", filename); | |
| 862 | err = open_disk_image(Machine->gamedrv, romp, &source); | |
| 953 | debugload("Opening disk image: %s\n", astring_c(filename)); | |
| 954 | err = open_disk_image(Machine->gamedrv, romp, &chd.origfile, &chd.origchd); | |
| 863 | 955 | if (err != CHDERR_NONE) |
| 864 | 956 | { |
| 865 | 957 | if (err == CHDERR_UNSUPPORTED_VERSION) |
| 866 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s UNSUPPORTED CHD VERSION\n", filename); | |
| 958 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s UNSUPPORTED CHD VERSION\n", astring_c(filename)); | |
| 867 | 959 | else |
| 868 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s NOT FOUND\n", filename); | |
| 960 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s NOT FOUND\n", astring_c(filename)); | |
| 869 | 961 | |
| 870 | 962 | /* if this is NO_DUMP, keep going, though the system may not be able to handle it */ |
| 871 | 963 | if (hash_data_has_info(ROM_GETHASHDATA(romp), HASH_INFO_NO_DUMP)) |
| 872 | 964 | romdata->warnings++; |
| 873 | 965 | else |
| 874 | 966 | romdata->errors++; |
| 875 | romp++; | |
| 876 | continue; | |
| 967 | goto next; | |
| 877 | 968 | } |
| 878 | 969 | |
| 879 | 970 | /* get the header and extract the MD5/SHA1 */ |
| 880 | header = *chd_get_header( | |
| 971 | header = *chd_get_header(chd.o | |
| 881 | 972 | hash_data_clear(acthash); |
| 882 | 973 | hash_data_insert_binary_checksum(acthash, HASH_MD5, header.md5); |
| 883 | 974 | hash_data_insert_binary_checksum(acthash, HASH_SHA1, header.sha1); |
| r936 | r937 | |
| 885 | 976 | /* verify the MD5 */ |
| 886 | 977 | if (!hash_data_is_equal(ROM_GETHASHDATA(romp), acthash, 0)) |
| 887 | 978 | { |
| 888 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s WRONG CHECKSUMS:\n", filename); | |
| 979 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s WRONG CHECKSUMS:\n", astring_c(filename)); | |
| 889 | 980 | dump_wrong_and_correct_checksums(romdata, ROM_GETHASHDATA(romp), acthash); |
| 890 | 981 | romdata->warnings++; |
| 891 | 982 | } |
| 892 | 983 | else if (hash_data_has_info(ROM_GETHASHDATA(romp), HASH_INFO_BAD_DUMP)) |
| 893 | 984 | { |
| 894 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s CHD NEEDS REDUMP\n", filename); | |
| 985 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s CHD NEEDS REDUMP\n", astring_c(filename)); | |
| 895 | 986 | romdata->warnings++; |
| 896 | 987 | } |
| 897 | 988 | |
| 898 | 989 | /* if not read-only, make the diff file */ |
| 899 | 990 | if (!DISK_ISREADONLY(romp)) |
| 900 | 991 | { |
| 901 | /* make the filename of the diff */ | |
| 902 | sprintf(filename, "%s.dif", ROM_GETNAME(romp)); | |
| 903 | ||
| 904 | /* try to open the diff */ | |
| 905 | debugload("Opening differencing image: %s\n", filename); | |
| 906 | err = chd_open(filename, CHD_OPEN_READWRITE, source, &diff); | |
| 992 | /* try to open or create the diff */ | |
| 993 | err = open_disk_diff(Machine->gamedrv, romp, chd.origchd, &chd.difffile, &chd.diffchd); | |
| 907 | 994 | if (err != CHDERR_NONE) |
| 908 | 995 | { |
| 909 | /* didn't work; try creating it instead */ | |
| 910 | debugload("Creating differencing image: %s\n", filename); | |
| 911 | err = chd_create(filename, 0, 0, CHDCOMPRESSION_NONE, source); | |
| 912 | if (err != CHDERR_NONE) | |
| 913 | { | |
| 914 | if (err == CHDERR_UNSUPPORTED_VERSION) | |
| 915 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s UNSUPPORTED CHD VERSION\n", filename); | |
| 916 | else | |
| 917 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s: CAN'T CREATE DIFF FILE\n", filename); | |
| 918 | romdata->errors++; | |
| 919 | romp++; | |
| 920 | continue; | |
| 921 | } | |
| 922 | ||
| 923 | /* open the newly-created diff file */ | |
| 924 | debugload("Opening differencing image: %s\n", filename); | |
| 925 | err = chd_open(filename, CHD_OPEN_READWRITE, source, &diff); | |
| 926 | if (err != CHDERR_NONE) | |
| 927 | { | |
| 928 | if (err == CHDERR_UNSUPPORTED_VERSION) | |
| 929 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s UNSUPPORTED CHD VERSION\n", filename); | |
| 930 | else | |
| 931 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s: CAN'T OPEN DIFF FILE\n", filename); | |
| 932 | romdata->errors++; | |
| 933 | romp++; | |
| 934 | continue; | |
| 935 | } | |
| 996 | if (err == CHDERR_UNSUPPORTED_VERSION) | |
| 997 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s UNSUPPORTED CHD VERSION\n", astring_c(filename)); | |
| 998 | else | |
| 999 | sprintf(&romdata->errorbuf[strlen(romdata->errorbuf)], "%s: CAN'T OPEN DIFF FILE\n", astring_c(filename)); | |
| 1000 | romdata->errors++; | |
| 1001 | goto next; | |
| 936 | 1002 | } |
| 937 | 1003 | } |
| 938 | 1004 | |
| 939 | /* we're okay, | |
| 1005 | /* we're okay, add to the | |
| 940 | 1006 | debugload("Assigning to handle %d\n", DISK_GETINDEX(romp)); |
| 941 | disk_handle[DISK_GETINDEX(romp)] = DISK_ISREADONLY(romp) ? source : diff; | |
| 1007 | *chd_list_tailptr = auto_malloc(sizeof(**chd_list_tailptr)); | |
| 1008 | **chd_list_tailptr = chd; | |
| 1009 | chd_list_tailptr = &(*chd_list_tailptr)->next; | |
| 1010 | next: | |
| 942 | 1011 | romp++; |
| 1012 | astring_free(filename); | |
| 943 | 1013 | } |
| 944 | 1014 | } |
| 945 | 1015 | } |
| r936 | r937 | |
| 976 | 1046 | romdata.romstotal = count_roms(romp); |
| 977 | 1047 | |
| 978 | 1048 | /* reset the disk list */ |
| 979 | memset(disk_handle, 0, sizeof(disk_handle)); | |
| 1049 | chd_list = NULL; | |
| 1050 | chd_list_tailptr = &chd_list; | |
| 980 | 1051 | |
| 981 | 1052 | /* loop until we hit the end */ |
| 982 | 1053 | for (region = romp, regnum = 0; region; region = rom_next_region(region), regnum++) |
| r936 | r937 | |
| 1041 | 1112 | |
| 1042 | 1113 | void rom_exit(running_machine *machine) |
| 1043 | 1114 | { |
| 1115 | open_chd *curchd; | |
| 1044 | 1116 | int i; |
| 1045 | 1117 | |
| 1046 | 1118 | /* free the memory allocated for various regions */ |
| r936 | r937 | |
| 1048 | 1120 | free_memory_region(machine, i); |
| 1049 | 1121 | |
| 1050 | 1122 | /* close all hard drives */ |
| 1051 | chd_close_all(); | |
| 1123 | for (curchd = chd_list; curchd != NULL; curchd = curchd->next) | |
| 1124 | { | |
| 1125 | if (curchd->diffchd != NULL) | |
| 1126 | chd_close(curchd->diffchd); | |
| 1127 | if (curchd->difffile != NULL) | |
| 1128 | mame_fclose(curchd->difffile); | |
| 1129 | if (curchd->origchd != NULL) | |
| 1130 | chd_close(curchd->origchd); | |
| 1131 | if (curchd->origfile != NULL) | |
| 1132 | mame_fclose(curchd->origfile); | |
| 1133 | } | |
| 1052 | 1134 | } |
| 1053 | 1135 | |
| 1054 | 1136 |
| r936 | r937 | |
|---|---|---|
| 3751 | 3751 | #endif /* XML_DTD */ |
| 3752 | 3752 | dtd->hasParamEntityRefs = XML_TRUE; |
| 3753 | 3753 | if (startDoctypeDeclHandler) { |
| 3754 | XML_Char *tem; | |
| 3754 | 3755 | if (!XmlIsPublicId(enc, s, next, eventPP)) |
| 3755 | 3756 | return XML_ERROR_PUBLICID; |
| 3756 | | |
| 3757 | | |
| 3757 | 3758 | s + enc->minBytesPerChar, |
| 3758 | 3759 | next - enc->minBytesPerChar); |
| 3759 | if (! | |
| 3760 | if (! | |
| 3760 | 3761 | return XML_ERROR_NO_MEMORY; |
| 3761 | normalizePublicId((XML_Char *)doctypePubid); | |
| 3762 | normalizePublicId(tem); | |
| 3763 | doctypePubid = tem; | |
| 3762 | 3764 | poolFinish(&tempPool); |
| 3763 | 3765 | handleDefault = XML_FALSE; |
| 3764 | 3766 | goto alreadyChecked; |
| r936 | r937 | |
|---|---|---|
| 38 | 38 | $(LIBOBJ)/util/jedparse.o \ |
| 39 | 39 | $(LIBOBJ)/util/md5.o \ |
| 40 | 40 | $(LIBOBJ)/util/options.o \ |
| 41 | $(LIBOBJ)/util/palette.o \ | |
| 41 | 42 | $(LIBOBJ)/util/png.o \ |
| 42 | 43 | $(LIBOBJ)/util/pool.o \ |
| 43 | 44 | $(LIBOBJ)/util/sha1.o \ |
| r0 | r937 | |
|---|---|---|
| 1 | /****************************************************************************** | |
| 2 | ||
| 3 | palette.c | |
| 4 | ||
| 5 | Palette handling functions. | |
| 6 | ||
| 7 | Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team. | |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. | |
| 9 | ||
| 10 | ******************************************************************************/ | |
| 11 | ||
| 12 | #include "palette.h" | |
| 13 | ||
| 14 | ||
| 15 | ||
| 16 | /*************************************************************************** | |
| 17 | TYPE DEFINITIONS | |
| 18 | ***************************************************************************/ | |
| 19 | ||
| 20 | /* object to track dirty states */ | |
| 21 | typedef struct _dirty_state dirty_state; | |
| 22 | struct _dirty_state | |
| 23 | { | |
| 24 | UINT32 * dirty; /* bitmap of dirty entries */ | |
| 25 | UINT32 mindirty; /* minimum dirty entry */ | |
| 26 | UINT32 maxdirty; /* minimum dirty entry */ | |
| 27 | }; | |
| 28 | ||
| 29 | ||
| 30 | /* a single palette client */ | |
| 31 | struct _palette_client | |
| 32 | { | |
| 33 | palette_client *next; /* pointer to next client */ | |
| 34 | palette_t * palette; /* reference to the palette */ | |
| 35 | dirty_state live; /* live dirty state */ | |
| 36 | dirty_state previous; /* previous dirty state */ | |
| 37 | }; | |
| 38 | ||
| 39 | ||
| 40 | /* a palette object */ | |
| 41 | struct _palette_t | |
| 42 | { | |
| 43 | UINT32 refcount; /* reference count on the palette */ | |
| 44 | UINT32 numcolors; /* number of colors in the palette */ | |
| 45 | UINT32 numgroups; /* number of groups in the palette */ | |
| 46 | ||
| 47 | rgb_t * entry_color; /* array of raw colors */ | |
| 48 | float * entry_contrast; /* contrast value for each entry */ | |
| 49 | rgb_t * adjusted_color; /* array of adjusted colors */ | |
| 50 | rgb_t * adjusted_rgb15; /* array of adjusted colors as RGB15 */ | |
| 51 | ||
| 52 | float * group_bright; /* brightness value for each group */ | |
| 53 | float * group_contrast; /* contrast value for each group */ | |
| 54 | ||
| 55 | palette_client *client_list; /* list of clients for this palette */ | |
| 56 | }; | |
| 57 | ||
| 58 | ||
| 59 | ||
| 60 | /*************************************************************************** | |
| 61 | FUNCTION PROTOTYPES | |
| 62 | ***************************************************************************/ | |
| 63 | ||
| 64 | static void internal_palette_free(palette_t *palette); | |
| 65 | static void update_adjusted_color(palette_t *palette, UINT32 group, UINT32 index); | |
| 66 | ||
| 67 | ||
| 68 | ||
| 69 | /*************************************************************************** | |
| 70 | INLINE FUNCTIONS | |
| 71 | ***************************************************************************/ | |
| 72 | ||
| 73 | /*------------------------------------------------- | |
| 74 | adjust_palette_entry - adjust a palette | |
| 75 | entry for brightness | |
| 76 | -------------------------------------------------*/ | |
| 77 | ||
| 78 | INLINE rgb_t adjust_palette_entry(rgb_t entry, float brightness, float contrast) | |
| 79 | { | |
| 80 | int r = rgb_clamp((float)RGB_RED(entry) * contrast + brightness); | |
| 81 | int g = rgb_clamp((float)RGB_GREEN(entry) * contrast + brightness); | |
| 82 | int b = rgb_clamp((float)RGB_BLUE(entry) * contrast + brightness); | |
| 83 | return MAKE_RGB(r,g,b); | |
| 84 | } | |
| 85 | ||
| 86 | ||
| 87 | ||
| 88 | /*************************************************************************** | |
| 89 | PALETTE ALLOCATION | |
| 90 | ***************************************************************************/ | |
| 91 | ||
| 92 | /*------------------------------------------------- | |
| 93 | palette_alloc - allocate a new palette object | |
| 94 | and take a single reference on it | |
| 95 | -------------------------------------------------*/ | |
| 96 | ||
| 97 | palette_t *palette_alloc(UINT32 numcolors, UINT32 numgroups) | |
| 98 | { | |
| 99 | palette_t *palette; | |
| 100 | UINT32 index; | |
| 101 | ||
| 102 | /* allocate memory */ | |
| 103 | palette = malloc(sizeof(*palette)); | |
| 104 | if (palette == NULL) | |
| 105 | goto error; | |
| 106 | memset(palette, 0, sizeof(*palette)); | |
| 107 | ||
| 108 | /* allocate an array of palette entries and individual contrasts for each */ | |
| 109 | palette->entry_color = malloc(sizeof(*palette->entry_color) * numcolors); | |
| 110 | palette->entry_contrast = malloc(sizeof(*palette->entry_contrast) * numcolors); | |
| 111 | if (palette->entry_color == NULL || palette->entry_contrast == NULL) | |
| 112 | goto error; | |
| 113 | ||
| 114 | /* initialize the entries */ | |
| 115 | for (index = 0; index < numcolors; index++) | |
| 116 | { | |
| 117 | palette->entry_color[index] = RGB_BLACK; | |
| 118 | palette->entry_contrast[index] = 1.0f; | |
| 119 | } | |
| 120 | ||
| 121 | /* allocate an array of brightness and contrast for each group */ | |
| 122 | palette->group_bright = malloc(sizeof(*palette->group_bright) * numgroups); | |
| 123 | palette->group_contrast = malloc(sizeof(*palette->group_contrast) * numgroups); | |
| 124 | if (palette->group_bright == NULL || palette->group_contrast == NULL) | |
| 125 | goto error; | |
| 126 | ||
| 127 | /* initialize the entries */ | |
| 128 | for (index = 0; index < numgroups; index++) | |
| 129 | { | |
| 130 | palette->group_bright[index] = 0.0f; | |
| 131 | palette->group_contrast[index] = 1.0f; | |
| 132 | } | |
| 133 | ||
| 134 | /* allocate arrays for the adjusted colors */ | |
| 135 | palette->adjusted_color = malloc(sizeof(*palette->adjusted_color) * (numcolors * numgroups + 2)); | |
| 136 | palette->adjusted_rgb15 = malloc(sizeof(*palette->adjusted_rgb15) * (numcolors * numgroups + 2)); | |
| 137 | if (palette->adjusted_color == NULL || palette->adjusted_rgb15 == NULL) | |
| 138 | goto error; | |
| 139 | ||
| 140 | /* initialize the arrays */ | |
| 141 | for (index = 0; index < numcolors * numgroups; index++) | |
| 142 | { | |
| 143 | palette->adjusted_color[index] = RGB_BLACK; | |
| 144 | palette->adjusted_rgb15[index] = rgb_to_rgb15(RGB_BLACK); | |
| 145 | } | |
| 146 | ||
| 147 | /* add black and white as the last two colors */ | |
| 148 | palette->adjusted_color[index] = RGB_BLACK; | |
| 149 | palette->adjusted_rgb15[index++] = rgb_to_rgb15(RGB_BLACK); | |
| 150 | palette->adjusted_color[index] = RGB_WHITE; | |
| 151 | palette->adjusted_rgb15[index++] = rgb_to_rgb15(RGB_WHITE); | |
| 152 | ||
| 153 | /* initialize the remainder of the structure */ | |
| 154 | palette->refcount = 1; | |
| 155 | palette->numcolors = numcolors; | |
| 156 | palette->numgroups = numgroups; | |
| 157 | return palette; | |
| 158 | ||
| 159 | error: | |
| 160 | if (palette != NULL) | |
| 161 | internal_palette_free(palette); | |
| 162 | ||
| 163 | return NULL; | |
| 164 | } | |
| 165 | ||
| 166 | ||
| 167 | /*------------------------------------------------- | |
| 168 | palette_ref - reference a palette object, | |
| 169 | incrementing its reference count | |
| 170 | -------------------------------------------------*/ | |
| 171 | ||
| 172 | void palette_ref(palette_t *palette) | |
| 173 | { | |
| 174 | palette->refcount++; | |
| 175 | } | |
| 176 | ||
| 177 | ||
| 178 | /*------------------------------------------------- | |
| 179 | palette_deref - dereference a palette object; | |
| 180 | if the reference count goes to 0, it is freed | |
| 181 | -------------------------------------------------*/ | |
| 182 | ||
| 183 | void palette_deref(palette_t *palette) | |
| 184 | { | |
| 185 | /* if the reference count goes to 0, free */ | |
| 186 | if (--palette->refcount == 0) | |
| 187 | internal_palette_free(palette); | |
| 188 | } | |
| 189 | ||
| 190 | ||
| 191 | ||
| 192 | /*************************************************************************** | |
| 193 | PALETTE INFORMATION | |
| 194 | ***************************************************************************/ | |
| 195 | ||
| 196 | /*------------------------------------------------- | |
| 197 | palette_get_num_colors - return the number of | |
| 198 | colors allocated in the palette | |
| 199 | -------------------------------------------------*/ | |
| 200 | ||
| 201 | int palette_get_num_colors(palette_t *palette) | |
| 202 | { | |
| 203 | return palette->numcolors; | |
| 204 | } | |
| 205 | ||
| 206 | ||
| 207 | /*------------------------------------------------- | |
| 208 | palette_get_num_groups - return the number of | |
| 209 | groups managed by the palette | |
| 210 | -------------------------------------------------*/ | |
| 211 | ||
| 212 | int palette_get_num_groups(palette_t *palette) | |
| 213 | { | |
| 214 | return palette->numgroups; | |
| 215 | } | |
| 216 | ||
| 217 | ||
| 218 | /*------------------------------------------------- | |
| 219 | palette_get_black_entry - return the index of | |
| 220 | the black entry | |
| 221 | -------------------------------------------------*/ | |
| 222 | ||
| 223 | UINT32 palette_get_black_entry(palette_t *palette) | |
| 224 | { | |
| 225 | return palette->numcolors * palette->numgroups + 0; | |
| 226 | } | |
| 227 | ||
| 228 | ||
| 229 | /*------------------------------------------------- | |
| 230 | palette_get_white_entry - return the index of | |
| 231 | the white entry | |
| 232 | -------------------------------------------------*/ | |
| 233 | ||
| 234 | UINT32 palette_get_white_entry(palette_t *palette) | |
| 235 | { | |
| 236 | return palette->numcolors * palette->numgroups + 1; | |
| 237 | } | |
| 238 | ||
| 239 | ||
| 240 | ||
| 241 | /*************************************************************************** | |
| 242 | PALETTE CLIENTS | |
| 243 | ***************************************************************************/ | |
| 244 | ||
| 245 | /*------------------------------------------------- | |
| 246 | palette_client_alloc - add a new client to a | |
| 247 | palette | |
| 248 | -------------------------------------------------*/ | |
| 249 | ||
| 250 | palette_client *palette_client_alloc(palette_t *palette) | |
| 251 | { | |
| 252 | UINT32 total_colors = palette->numcolors * palette->numgroups; | |
| 253 | UINT32 dirty_dwords = (total_colors + 31) / 32; | |
| 254 | palette_client *client; | |
| 255 | ||
| 256 | /* allocate memory for the client */ | |
| 257 | client = malloc(sizeof(*client)); | |
| 258 | if (client == NULL) | |
| 259 | goto error; | |
| 260 | memset(client, 0, sizeof(*client)); | |
| 261 | ||
| 262 | /* allocate dirty lists */ | |
| 263 | client->live.dirty = malloc(dirty_dwords * sizeof(UINT32)); | |
| 264 | client->previous.dirty = malloc(dirty_dwords * sizeof(UINT32)); | |
| 265 | if (client->live.dirty == NULL || client->previous.dirty == NULL) | |
| 266 | goto error; | |
| 267 | ||
| 268 | /* mark everything dirty to start with */ | |
| 269 | memset(client->live.dirty, 0xff, dirty_dwords * sizeof(UINT32)); | |
| 270 | memset(client->previous.dirty, 0xff, dirty_dwords * sizeof(UINT32)); | |
| 271 | client->live.dirty[dirty_dwords - 1] &= (1 << (total_colors % 32)) - 1; | |
| 272 | client->previous.dirty[dirty_dwords - 1] &= (1 << (total_colors % 32)) - 1; | |
| 273 | ||
| 274 | /* initialize the rest of the structure and add a reference to a palette */ | |
| 275 | client->palette = palette; | |
| 276 | palette_ref(palette); | |
| 277 | client->live.mindirty = 0; | |
| 278 | client->live.maxdirty = total_colors - 1; | |
| 279 | ||
| 280 | /* now add us to the list of clients */ | |
| 281 | client->next = palette->client_list; | |
| 282 | palette->client_list = client; | |
| 283 | return client; | |
| 284 | ||
| 285 | error: | |
| 286 | if (client != NULL) | |
| 287 | { | |
| 288 | if (client->live.dirty != NULL) | |
| 289 | free(client->live.dirty); | |
| 290 | if (client->previous.dirty != NULL) | |
| 291 | free(client->previous.dirty); | |
| 292 | free(client); | |
| 293 | } | |
| 294 | return NULL; | |
| 295 | } | |
| 296 | ||
| 297 | ||
| 298 | /*------------------------------------------------- | |
| 299 | palette_client_free - remove a client from a | |
| 300 | palette | |
| 301 | -------------------------------------------------*/ | |
| 302 | ||
| 303 | void palette_client_free(palette_client *client) | |
| 304 | { | |
| 305 | palette_client **curptr; | |
| 306 | ||
| 307 | /* first locate and remove ourself from the palette's list */ | |
| 308 | for (curptr = &client->palette->client_list; *curptr != NULL; curptr = &(*curptr)->next) | |
| 309 | if (*curptr == client) | |
| 310 | { | |
| 311 | *curptr = client->next; | |
| 312 | break; | |
| 313 | } | |
| 314 | ||
| 315 | /* now deref the palette */ | |
| 316 | palette_deref(client->palette); | |
| 317 | ||
| 318 | /* free our data */ | |
| 319 | if (client->live.dirty != NULL) | |
| 320 | free(client->live.dirty); | |
| 321 | if (client->previous.dirty != NULL) | |
| 322 | free(client->previous.dirty); | |
| 323 | free(client); | |
| 324 | } | |
| 325 | ||
| 326 | ||
| 327 | /*------------------------------------------------- | |
| 328 | palette_client_get_palette - return a pointer | |
| 329 | to the palette for this client | |
| 330 | -------------------------------------------------*/ | |
| 331 | ||
| 332 | palette_t *palette_client_get_palette(palette_client *client) | |
| 333 | { | |
| 334 | return client->palette; | |
| 335 | } | |
| 336 | ||
| 337 | ||
| 338 | /*------------------------------------------------- | |
| 339 | palette_client_get_dirty_list - atomically get | |
| 340 | the current dirty list for a client | |
| 341 | -------------------------------------------------*/ | |
| 342 | ||
| 343 | const UINT32 *palette_client_get_dirty_list(palette_client *client, UINT32 *mindirty, UINT32 *maxdirty) | |
| 344 | { | |
| 345 | dirty_state temp; | |
| 346 | ||
| 347 | /* fill in the mindirty/maxdirty */ | |
| 348 | if (mindirty != NULL) | |
| 349 | *mindirty = client->live.mindirty; | |
| 350 | if (maxdirty != NULL) | |
| 351 | *maxdirty = client->live.maxdirty; | |
| 352 | ||
| 353 | /* if nothing to report, report nothing and don't swap */ | |
| 354 | if (client->live.mindirty > client->live.maxdirty) | |
| 355 | return NULL; | |
| 356 | ||
| 357 | /* swap the live and previous lists */ | |
| 358 | temp = client->live; | |
| 359 | client->live = client->previous; | |
| 360 | client->previous = temp; | |
| 361 | ||
| 362 | /* erase relevant entries in the new live one */ | |
| 363 | if (client->live.mindirty <= client->live.maxdirty) | |
| 364 | memset(client->live.dirty, client->live.mindirty / 8, (client->live.maxdirty / 8) + 1 - (client->live.mindirty / 8)); | |
| 365 | client->live.mindirty = client->palette->numcolors * client->palette->numgroups; | |
| 366 | client->live.maxdirty = 0; | |
| 367 | ||
| 368 | /* return a pointer to the previous table */ | |
| 369 | return client->previous.dirty; | |
| 370 | } | |
| 371 | ||
| 372 | ||
| 373 | ||
| 374 | /*************************************************************************** | |
| 375 | PALETTE COLOR MANAGEMENT | |
| 376 | ***************************************************************************/ | |
| 377 | ||
| 378 | /*------------------------------------------------- | |
| 379 | palette_entry_set_color - set the raw RGB | |
| 380 | color for a given palette index | |
| 381 | -------------------------------------------------*/ | |
| 382 | ||
| 383 | void palette_entry_set_color(palette_t *palette, UINT32 index, rgb_t rgb) | |
| 384 | { | |
| 385 | int groupnum; | |
| 386 | ||
| 387 | /* if out of range, or unchanged, ignore */ | |
| 388 | if (index >= palette->numcolors || palette->entry_color[index] == rgb) | |
| 389 | return; | |
| 390 | ||
| 391 | /* set the color */ | |
| 392 | palette->entry_color[index] = rgb; | |
| 393 | ||
| 394 | /* update across all groups */ | |
| 395 | for (groupnum = 0; groupnum < palette->numgroups; groupnum++) | |
| 396 | update_adjusted_color(palette, groupnum, index); | |
| 397 | } | |
| 398 | ||
| 399 | ||
| 400 | /*------------------------------------------------- | |
| 401 | palette_entry_get_color - return the raw RGB | |
| 402 | color for a given palette index | |
| 403 | -------------------------------------------------*/ | |
| 404 | ||
| 405 | rgb_t palette_entry_get_color(palette_t *palette, UINT32 index) | |
| 406 | { | |
| 407 | return (index < palette->numcolors) ? palette->entry_color[index] : RGB_BLACK; | |
| 408 | } | |
| 409 | ||
| 410 | ||
| 411 | /*------------------------------------------------- | |
| 412 | palette_entry_get_adjusted_color - return the | |
| 413 | adjusted RGB color (after all adjustments) for | |
| 414 | a given palette index | |
| 415 | -------------------------------------------------*/ | |
| 416 | ||
| 417 | rgb_t palette_entry_get_adjusted_color(palette_t *palette, UINT32 index) | |
| 418 | { | |
| 419 | return (index < palette->numcolors * palette->numgroups) ? palette->adjusted_color[index] : RGB_BLACK; | |
| 420 | } | |
| 421 | ||
| 422 | ||
| 423 | /*------------------------------------------------- | |
| 424 | palette_entry_list_raw - return the entire | |
| 425 | palette as an array of raw RGB values | |
| 426 | -------------------------------------------------*/ | |
| 427 | ||
| 428 | const rgb_t *palette_entry_list_raw(palette_t *palette) | |
| 429 | { | |
| 430 | return palette->entry_color; | |
| 431 | } | |
| 432 | ||
| 433 | ||
| 434 | /*------------------------------------------------- | |
| 435 | palette_entry_list_adjusted - return the | |
| 436 | entire palette as an array of adjusted RGB | |
| 437 | values | |
| 438 | -------------------------------------------------*/ | |
| 439 | ||
| 440 | const rgb_t *palette_entry_list_adjusted(palette_t *palette) | |
| 441 | { | |
| 442 | return palette->adjusted_color; | |
| 443 | } | |
| 444 | ||
| 445 | ||
| 446 | /*------------------------------------------------- | |
| 447 | palette_entry_list_adjusted_rgb15 - return the | |
| 448 | entire palette as an array of adjusted RGB-15 | |
| 449 | values | |
| 450 | -------------------------------------------------*/ | |
| 451 | ||
| 452 | const rgb_t *palette_entry_list_adjusted_rgb15(palette_t *palette) | |
| 453 | { | |
| 454 | return palette->adjusted_rgb15; | |
| 455 | } | |
| 456 | ||
| 457 | ||
| 458 | ||
| 459 | /*************************************************************************** | |
| 460 | PALETTE ADJUSTMENTS | |
| 461 | ***************************************************************************/ | |
| 462 | ||
| 463 | /*------------------------------------------------- | |
| 464 | palette_entry_set_contrast - set the contrast | |
| 465 | adjustment for a single palette index | |
| 466 | -------------------------------------------------*/ | |
| 467 | ||
| 468 | void palette_entry_set_contrast(palette_t *palette, UINT32 index, float contrast) | |
| 469 | { | |
| 470 | int groupnum; | |
| 471 | ||
| 472 | /* if out of range, or unchanged, ignore */ | |
| 473 | if (index >= palette->numcolors || palette->entry_contrast[index] == contrast) | |
| 474 | return; | |
| 475 | ||
| 476 | /* set the contrast */ | |
| 477 | palette->entry_contrast[index] = contrast; | |
| 478 | ||
| 479 | /* update across all groups */ | |
| 480 | for (groupnum = 0; groupnum < palette->numgroups; groupnum++) | |
| 481 | update_adjusted_color(palette, groupnum, index); | |
| 482 | } | |
| 483 | ||
| 484 | ||
| 485 | /*------------------------------------------------- | |
| 486 | palette_entry_get_contrast - return the | |
| 487 | contrast adjustment for a single palette index | |
| 488 | -------------------------------------------------*/ | |
| 489 | ||
| 490 | float palette_entry_get_contrast(palette_t *palette, UINT32 index) | |
| 491 | { | |
| 492 | return (index < palette->numcolors) ? palette->entry_contrast[index] : 1.0f; | |
| 493 | } | |
| 494 | ||
| 495 | ||
| 496 | /*------------------------------------------------- | |
| 497 | palette_group_set_brightness - configure | |
| 498 | overall brightness for a palette group | |
| 499 | -------------------------------------------------*/ | |
| 500 | ||
| 501 | void palette_group_set_brightness(palette_t *palette, UINT32 group, float brightness) | |
| 502 | { | |
| 503 | int index; | |
| 504 | ||
| 505 | /* if out of range, or unchanged, ignore */ | |
| 506 | if (group >= palette->numgroups || palette->group_bright[group] == brightness) | |
| 507 | return; | |
| 508 | ||
| 509 | /* set the contrast */ | |
| 510 | palette->group_bright[group] = brightness; | |
| 511 | ||
| 512 | /* update across all colors */ | |
| 513 | for (index = 0; index < palette->numcolors; index++) | |
| 514 | update_adjusted_color(palette, group, index); | |
| 515 | } | |
| 516 | ||
| 517 | ||
| 518 | /*------------------------------------------------- | |
| 519 | palette_group_set_contrast - configure | |
| 520 | overall contrast for a palette group | |
| 521 | -------------------------------------------------*/ | |
| 522 | ||
| 523 | void palette_group_set_contrast(palette_t *palette, UINT32 group, float contrast) | |
| 524 | { | |
| 525 | int index; | |
| 526 | ||
| 527 | /* if out of range, or unchanged, ignore */ | |
| 528 | if (group >= palette->numgroups || palette->group_contrast[group] == contrast) | |
| 529 | return; | |
| 530 | ||
| 531 | /* set the contrast */ | |
| 532 | palette->group_contrast[group] = contrast; | |
| 533 | ||
| 534 | /* update across all colors */ | |
| 535 | for (index = 0; index < palette->numcolors; index++) | |
| 536 | update_adjusted_color(palette, group, index); | |
| 537 | } | |
| 538 | ||
| 539 | ||
| 540 | ||
| 541 | /*************************************************************************** | |
| 542 | PALETTE UTILITIES | |
| 543 | ***************************************************************************/ | |
| 544 | ||
| 545 | /*------------------------------------------------- | |
| 546 | palette_normalize_range - normalize a range | |
| 547 | of palette entries | |
| 548 | -------------------------------------------------*/ | |
| 549 | ||
| 550 | void palette_normalize_range(palette_t *palette, UINT32 start, UINT32 end, int lum_min, int lum_max) | |
| 551 | { | |
| 552 | UINT32 ymin = 1000 * 255, ymax = 0; | |
| 553 | UINT32 tmin, tmax; | |
| 554 | UINT32 index; | |
| 555 | ||
| 556 | /* clamp within range */ | |
| 557 | start = MAX(start, 0); | |
| 558 | end = MIN(end, palette->numcolors - 1); | |
| 559 | ||
| 560 | /* find the minimum and maximum brightness of all the colors in the range */ | |
| 561 | for (index = start; index <= end; index++) | |
| 562 | { | |
| 563 | rgb_t rgb = palette->entry_color[index]; | |
| 564 | UINT32 y = 299 * RGB_RED(rgb) + 587 * RGB_GREEN(rgb) + 114 * RGB_BLUE(rgb); | |
| 565 | ymin = MIN(ymin, y); | |
| 566 | ymax = MAX(ymax, y); | |
| 567 | } | |
| 568 | ||
| 569 | /* determine target minimum/maximum */ | |
| 570 | tmin = (lum_min < 0) ? ((ymin + 500) / 1000) : lum_min; | |
| 571 | tmax = (lum_max < 0) ? ((ymax + 500) / 1000) : lum_max; | |
| 572 | ||
| 573 | /* now normalize the palette */ | |
| 574 | for (index = start; index <= end; index++) | |
| 575 | { | |
| 576 | rgb_t rgb = palette->entry_color[index]; | |
| 577 | UINT32 y = 299 * RGB_RED(rgb) + 587 * RGB_GREEN(rgb) + 114 * RGB_BLUE(rgb); | |
| 578 | UINT32 target = tmin + ((y - ymin) * (tmax - tmin + 1)) / (ymax - ymin); | |
| 579 | UINT8 r = (y == 0) ? 0 : rgb_clamp(RGB_RED(rgb) * 1000 * target / y); | |
| 580 | UINT8 g = (y == 0) ? 0 : rgb_clamp(RGB_GREEN(rgb) * 1000 * target / y); | |
| 581 | UINT8 b = (y == 0) ? 0 : rgb_clamp(RGB_BLUE(rgb) * 1000 * target / y); | |
| 582 | palette_entry_set_color(palette, index, MAKE_RGB(r, g, b)); | |
| 583 | } | |
| 584 | } | |
| 585 | ||
| 586 | ||
| 587 | ||
| 588 | /*************************************************************************** | |
| 589 | INTERNAL ROUTINES | |
| 590 | ***************************************************************************/ | |
| 591 | ||
| 592 | /*------------------------------------------------- | |
| 593 | internal_palette_free - free all allocations | |
| 594 | from a palette | |
| 595 | -------------------------------------------------*/ | |
| 596 | ||
| 597 | static void internal_palette_free(palette_t *palette) | |
| 598 | { | |
| 599 | /* free per-color data */ | |
| 600 | if (palette->entry_color != NULL) | |
| 601 | free(palette->entry_color); | |
| 602 | if (palette->entry_contrast != NULL) | |
| 603 | free(palette->entry_contrast); | |
| 604 | ||
| 605 | /* free per-group data */ | |
| 606 | if (palette->group_bright != NULL) | |
| 607 | free(palette->group_bright); | |
| 608 | if (palette->group_contrast != NULL) | |
| 609 | free(palette->group_contrast); | |
| 610 | ||
| 611 | /* free adjusted data */ | |
| 612 | if (palette->adjusted_color != NULL) | |
| 613 | free(palette->adjusted_color); | |
| 614 | if (palette->adjusted_rgb15 != NULL) | |
| 615 | free(palette->adjusted_rgb15); | |
| 616 | ||
| 617 | /* and the palette itself */ | |
| 618 | free(palette); | |
| 619 | } | |
| 620 | ||
| 621 | ||
| 622 | /*------------------------------------------------- | |
| 623 | update_adjusted_color - update a color index | |
| 624 | by group and index pair | |
| 625 | -------------------------------------------------*/ | |
| 626 | ||
| 627 | static void update_adjusted_color(palette_t *palette, UINT32 group, UINT32 index) | |
| 628 | { | |
| 629 | UINT32 finalindex = group * palette->numcolors + index; | |
| 630 | palette_client *client; | |
| 631 | rgb_t adjusted; | |
| 632 | ||
| 633 | /* compute the adjusted value */ | |
| 634 | adjusted = adjust_palette_entry(palette->entry_color[index], palette->group_bright[group], palette->group_contrast[group] * palette->entry_contrast[index]); | |
| 635 | ||
| 636 | /* if not different, ignore */ | |
| 637 | if (palette->adjusted_color[finalindex] == adjusted) | |
| 638 | return; | |
| 639 | ||
| 640 | /* otherwise, modify the adjusted color array */ | |
| 641 | palette->adjusted_color[finalindex] = adjusted; | |
| 642 | palette->adjusted_rgb15[finalindex] = rgb_to_rgb15(adjusted); | |
| 643 | ||
| 644 | /* mark dirty in all clients */ | |
| 645 | for (client = palette->client_list; client != NULL; client = client->next) | |
| 646 | { | |
| 647 | client->live.dirty[finalindex / 32] |= 1 << (finalindex % 32); | |
| 648 | client->live.mindirty = MIN(client->live.mindirty, finalindex); | |
| 649 | client->live.maxdirty = MAX(client->live.maxdirty, finalindex); | |
| 650 | } | |
| 651 | } |
| r936 | r937 | |
|---|---|---|
| 114 | 114 | }; |
| 115 | 115 | |
| 116 | 116 | |
| 117 | /* multifile object */ | |
| 118 | typedef struct _multi_file multi_file; | |
| 119 | struct _multi_file | |
| 120 | { | |
| 121 | UINT32 numfiles; /* number of files */ | |
| 122 | chd_interface_file ** files; /* array of open file handles */ | |
| 123 | UINT64 * length; /* array of file lengths */ | |
| 124 | }; | |
| 125 | ||
| 126 | ||
| 127 | 117 | /* internal representation of an open CHD file */ |
| 128 | 118 | struct _chd_file |
| 129 | 119 | { |
| 130 | 120 | UINT32 cookie; /* cookie, should equal COOKIE_VALUE */ |
| 131 | chd_file * next; /* pointer to next file in the global list */ | |
| 132 | 121 | |
| 133 | multi_file * file; /* handle to the open multi file */ | |
| 122 | core_file * file; /* handle to the open core file */ | |
| 123 | UINT8 owns_file; /* flag indicating if this file should be closed on chd_close() */ | |
| 134 | 124 | chd_header header; /* header, extracted from file */ |
| 135 | 125 | |
| 136 | 126 | chd_file * parent; /* pointer to parent file, or NULL */ |
| r936 | r937 | |
| 194 | 184 | GLOBAL VARIABLES |
| 195 | 185 | ***************************************************************************/ |
| 196 | 186 | |
| 197 | static chd_interface cur_interface; | |
| 198 | static chd_file *first_file; | |
| 199 | ||
| 200 | 187 | static const UINT8 nullmd5[CHD_MD5_BYTES] = { 0 }; |
| 201 | 188 | static const UINT8 nullsha1[CHD_SHA1_BYTES] = { 0 }; |
| 202 | 189 | |
| r936 | r937 | |
| 212 | 199 | |
| 213 | 200 | /* internal header operations */ |
| 214 | 201 | static chd_error header_validate(const chd_header *header); |
| 215 | static chd_error header_read(multi_file *file, chd_header *header); | |
| 216 | static chd_error header_write(multi_file *file, const chd_header *header); | |
| 202 | static chd_error header_read(core_file *file, chd_header *header); | |
| 203 | static chd_error header_write(core_file *file, const chd_header *header); | |
| 217 | 204 | |
| 218 | 205 | /* internal hunk read/write */ |
| 219 | 206 | static chd_error hunk_read_into_cache(chd_file *chd, UINT32 hunknum); |
| r936 | r937 | |
| 221 | 208 | static chd_error hunk_write_from_memory(chd_file *chd, UINT32 hunknum, const UINT8 *src); |
| 222 | 209 | |
| 223 | 210 | /* internal map access */ |
| 224 | static chd_error map_write_initial( | |
| 211 | static chd_error map_write_initial(core | |
| 225 | 212 | static chd_error map_read(chd_file *chd); |
| 226 | 213 | |
| 227 | 214 | /* internal CRC map access */ |
| r936 | r937 | |
| 250 | 237 | static chd_error av_codec_config(chd_file *chd, int param, void *config); |
| 251 | 238 | static chd_error av_codec_postinit(chd_file *chd); |
| 252 | 239 | |
| 253 | /* multifile routines */ | |
| 254 | static multi_file *multi_open(const char *filename, const char *mode); | |
| 255 | static void multi_close(multi_file *file); | |
| 256 | static UINT32 multi_read(multi_file *file, UINT64 offset, UINT32 count, void *buffer); | |
| 257 | static UINT32 multi_write(multi_file *file, UINT64 offset, UINT32 count, const void *buffer); | |
| 258 | static UINT64 multi_length(multi_file *file); | |
| 259 | 240 | |
| 260 | 241 | |
| 261 | ||
| 262 | 242 | /*************************************************************************** |
| 263 | 243 | CODEC INTERFACES |
| 264 | 244 | ***************************************************************************/ |
| r936 | r937 | |
| 494 | 474 | |
| 495 | 475 | |
| 496 | 476 | /*************************************************************************** |
| 497 | EXTERNAL INTERFACING | |
| 498 | ***************************************************************************/ | |
| 499 | ||
| 500 | /*------------------------------------------------- | |
| 501 | chd_set_interface - set the interface for | |
| 502 | CHD accesses | |
| 503 | -------------------------------------------------*/ | |
| 504 | ||
| 505 | void chd_set_interface(chd_interface *new_interface) | |
| 506 | { | |
| 507 | if (new_interface != NULL) | |
| 508 | cur_interface = *new_interface; | |
| 509 | else | |
| 510 | memset(&cur_interface, 0, sizeof(cur_interface)); | |
| 511 | } | |
| 512 | ||
| 513 | ||
| 514 | ||
| 515 | /*************************************************************************** | |
| 516 | 477 | CHD FILE MANAGEMENT |
| 517 | 478 | ***************************************************************************/ |
| 518 | 479 | |
| 519 | 480 | /*------------------------------------------------- |
| 520 | chd_create - create a new CHD file | |
| 481 | chd_create_file - create a new CHD file | |
| 521 | 482 | -------------------------------------------------*/ |
| 522 | 483 | |
| 523 | chd_error chd_create(co | |
| 484 | chd_error chd_create_file(co | |
| 524 | 485 | { |
| 525 | multi_file *file = NULL; | |
| 526 | 486 | chd_file *newchd = NULL; |
| 527 | 487 | chd_header header; |
| 528 | 488 | chd_error err; |
| 529 | 489 | int intfnum; |
| 530 | 490 | |
| 531 | /* punt if no interface */ | |
| 532 | if (cur_interface.open == NULL) | |
| 533 | EARLY_EXIT(err = CHDERR_NO_INTERFACE); | |
| 534 | ||
| 535 | 491 | /* verify parameters */ |
| 536 | if (filename == NULL) | |
| 537 | EARLY_EXIT(err = CHDERR_FILE_NOT_FOUND); | |
| 492 | if (file == NULL) | |
| 493 | EARLY_EXIT(err = CHDERR_INVALID_PARAMETER); | |
| 538 | 494 | if (parent == NULL && (logicalbytes == 0 || hunkbytes == 0)) |
| 539 | 495 | EARLY_EXIT(err = CHDERR_INVALID_PARAMETER); |
| 540 | 496 | |
| r936 | r937 | |
| 579 | 535 | if (err != CHDERR_NONE) |
| 580 | 536 | EARLY_EXIT(err); |
| 581 | 537 | |
| 582 | /* attempt to create the file */ | |
| 583 | file = multi_open(filename, "wb"); | |
| 584 | if (file == NULL) | |
| 585 | EARLY_EXIT(err = CHDERR_CANT_CREATE_FILE); | |
| 586 | ||
| 587 | 538 | /* write the resulting header */ |
| 588 | 539 | err = header_write(file, &header); |
| 589 | 540 | if (err != CHDERR_NONE) |
| r936 | r937 | |
| 594 | 545 | if (err != CHDERR_NONE) |
| 595 | 546 | EARLY_EXIT(err); |
| 596 | 547 | |
| 597 | /* all done */ | |
| 598 | multi_close(file); | |
| 599 | file = NULL; | |
| 600 | ||
| 601 | 548 | /* if we have a parent, clone the metadata */ |
| 602 | 549 | if (parent != NULL) |
| 603 | 550 | { |
| 604 | 551 | /* open the new CHD via the standard mechanism */ |
| 605 | err = chd_open | |
| 552 | err = chd_open_file(file, CHD_OPEN_READWRITE, parent, &newchd); | |
| 606 | 553 | if (err != CHDERR_NONE) |
| 607 | 554 | EARLY_EXIT(err); |
| 608 | 555 | |
| r936 | r937 | |
| 618 | 565 | return CHDERR_NONE; |
| 619 | 566 | |
| 620 | 567 | cleanup: |
| 621 | if (file != NULL) | |
| 622 | multi_close(file); | |
| 623 | 568 | if (newchd != NULL) |
| 624 | 569 | chd_close(newchd); |
| 625 | 570 | return err; |
| r936 | r937 | |
| 627 | 572 | |
| 628 | 573 | |
| 629 | 574 | /*------------------------------------------------- |
| 630 | chd_open - open a CHD file for access | |
| 575 | chd_open_file - open a CHD file for access | |
| 631 | 576 | -------------------------------------------------*/ |
| 632 | 577 | |
| 633 | chd_error chd_open(co | |
| 578 | chd_error chd_open_file(co | |
| 634 | 579 | { |
| 635 | 580 | chd_file *newchd = NULL; |
| 636 | chd_file **currptr; | |
| 637 | 581 | chd_error err; |
| 638 | 582 | int intfnum; |
| 639 | 583 | |
| 640 | /* punt if no interface */ | |
| 641 | if (cur_interface.open == NULL) | |
| 642 | EARLY_EXIT(err = CHDERR_NO_INTERFACE); | |
| 643 | ||
| 644 | 584 | /* verify parameters */ |
| 645 | if (filename == NULL) | |
| 646 | EARLY_EXIT(err = CHDERR_FILE_NOT_FOUND); | |
| 585 | if (file == NULL) | |
| 586 | EARLY_EXIT(err = CHDERR_INVALID_PARAMETER); | |
| 647 | 587 | |
| 648 | 588 | /* punt if invalid parent */ |
| 649 | 589 | if (parent != NULL && parent->cookie != COOKIE_VALUE) |
| r936 | r937 | |
| 656 | 596 | memset(newchd, 0, sizeof(*newchd)); |
| 657 | 597 | newchd->cookie = COOKIE_VALUE; |
| 658 | 598 | newchd->parent = parent; |
| 599 | newchd->file = file; | |
| 659 | 600 | |
| 660 | /* first attempt to open the file */ | |
| 661 | newchd->file = multi_open(filename, (mode == CHD_OPEN_READWRITE) ? "rb+" : "rb"); | |
| 662 | if (newchd->file == NULL) | |
| 663 | EARLY_EXIT(err = CHDERR_FILE_NOT_FOUND); | |
| 664 | ||
| 665 | 601 | /* now attempt to read the header */ |
| 666 | 602 | err = header_read(newchd->file, &newchd->header); |
| 667 | 603 | if (err != CHDERR_NONE) |
| r936 | r937 | |
| 734 | 670 | if (err != CHDERR_NONE) |
| 735 | 671 | EARLY_EXIT(err); |
| 736 | 672 | |
| 737 | /* hook us to the end of the global list */ | |
| 738 | for (currptr = &first_file; *currptr != NULL; currptr = &(*currptr)->next) ; | |
| 739 | *chd = *currptr = newchd; | |
| 740 | ||
| 741 | 673 | /* all done */ |
| 674 | *chd = newchd; | |
| 742 | 675 | return CHDERR_NONE; |
| 743 | 676 | |
| 744 | 677 | cleanup: |
| r936 | r937 | |
| 749 | 682 | |
| 750 | 683 | |
| 751 | 684 | /*------------------------------------------------- |
| 685 | chd_create - create a CHD file by | |
| 686 | filename | |
| 687 | -------------------------------------------------*/ | |
| 688 | ||
| 689 | chd_error chd_create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent) | |
| 690 | { | |
| 691 | core_file *file = NULL; | |
| 692 | file_error filerr; | |
| 693 | chd_error chderr; | |
| 694 | ||
| 695 | filerr = core_fopen(filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file); | |
| 696 | if (filerr != FILERR_NONE) | |
| 697 | { | |
| 698 | chderr = CHDERR_FILE_NOT_FOUND; | |
| 699 | goto cleanup; | |
| 700 | } | |
| 701 | ||
| 702 | chderr = chd_create_file(file, logicalbytes, hunkbytes, compression, parent); | |
| 703 | if (chderr != CHDERR_NONE) | |
| 704 | goto cleanup; | |
| 705 | ||
| 706 | cleanup: | |
| 707 | if (file != NULL) | |
| 708 | core_fclose(file); | |
| 709 | return chderr; | |
| 710 | } | |
| 711 | ||
| 712 | ||
| 713 | /*------------------------------------------------- | |
| 714 | chd_open - open a CHD file by | |
| 715 | filename | |
| 716 | -------------------------------------------------*/ | |
| 717 | ||
| 718 | chd_error chd_open(const char *filename, int mode, chd_file *parent, chd_file **chd) | |
| 719 | { | |
| 720 | chd_error err; | |
| 721 | file_error filerr; | |
| 722 | core_file *file = NULL; | |
| 723 | UINT32 openflags; | |
| 724 | ||
| 725 | /* choose the proper mode */ | |
| 726 | switch(mode) | |
| 727 | { | |
| 728 | case CHD_OPEN_READ: | |
| 729 | openflags = OPEN_FLAG_READ; | |
| 730 | break; | |
| 731 | ||
| 732 | case CHD_OPEN_READWRITE: | |
| 733 | openflags = OPEN_FLAG_READ | OPEN_FLAG_WRITE; | |
| 734 | break; | |
| 735 | ||
| 736 | default: | |
| 737 | err = CHDERR_INVALID_PARAMETER; | |
| 738 | goto cleanup; | |
| 739 | } | |
| 740 | ||
| 741 | /* open the file */ | |
| 742 | filerr = core_fopen(filename, openflags, &file); | |
| 743 | if (filerr != FILERR_NONE) | |
| 744 | { | |
| 745 | err = CHDERR_FILE_NOT_FOUND; | |
| 746 | goto cleanup; | |
| 747 | } | |
| 748 | ||
| 749 | /* now open the CHD */ | |
| 750 | err = chd_open_file(file, mode, parent, chd); | |
| 751 | if (err != CHDERR_NONE) | |
| 752 | goto cleanup; | |
| 753 | ||
| 754 | /* we now own this file */ | |
| 755 | (*chd)->owns_file = TRUE; | |
| 756 | ||
| 757 | cleanup: | |
| 758 | if ((err != CHDERR_NONE) && (file != NULL)) | |
| 759 | core_fclose(file); | |
| 760 | return err; | |
| 761 | } | |
| 762 | ||
| 763 | ||
| 764 | /*------------------------------------------------- | |
| 752 | 765 | chd_close - close a CHD file for access |
| 753 | 766 | -------------------------------------------------*/ |
| 754 | 767 | |
| 755 | 768 | void chd_close(chd_file *chd) |
| 756 | 769 | { |
| 757 | chd_file **currptr; | |
| 758 | ||
| 759 | 770 | /* punt if NULL or invalid */ |
| 760 | 771 | if (chd == NULL || chd->cookie != COOKIE_VALUE) |
| 761 | 772 | return; |
| r936 | r937 | |
| 796 | 807 | free(chd->crcmap); |
| 797 | 808 | |
| 798 | 809 | /* close the file */ |
| 799 | if (chd->file != NULL) | |
| 800 | multi_close(chd->file); | |
| 810 | if (chd->owns_file && chd->file != NULL) | |
| 811 | core_fclose(chd->file); | |
| 801 | 812 | |
| 802 | /* unlink ourselves */ | |
| 803 | for (currptr = &first_file; *currptr != NULL; currptr = &(*currptr)->next) | |
| 804 | if (*currptr == chd) | |
| 805 | { | |
| 806 | *currptr = (*currptr)->next; | |
| 807 | break; | |
| 808 | } | |
| 809 | ||
| 810 | 813 | #if PRINTF_MAX_HUNK |
| 811 | 814 | printf("Max hunk = %d/%d\n", chd->maxhunk, chd->header.totalhunks); |
| 812 | 815 | #endif |
| r936 | r937 | |
| 817 | 820 | |
| 818 | 821 | |
| 819 | 822 | /*------------------------------------------------- |
| 820 | chd_close_all - close all open CHD files | |
| 823 | chd_core_file - return the associated | |
| 824 | core_file | |
| 821 | 825 | -------------------------------------------------*/ |
| 822 | 826 | |
| 823 | ||
| 827 | core_file *chd_c | |
| 824 | 828 | { |
| 825 | while (first_file != NULL) | |
| 826 | chd_close(first_file); | |
| 829 | return chd->file; | |
| 827 | 830 | } |
| 828 | 831 | |
| 829 | 832 | |
| r936 | r937 | |
| 876 | 879 | |
| 877 | 880 | |
| 878 | 881 | /*------------------------------------------------- |
| 879 | chd_set_header - write the current header to | |
| 882 | chd_set_header_file - write the current header to | |
| 880 | 883 | the file |
| 881 | 884 | -------------------------------------------------*/ |
| 882 | 885 | |
| 883 | chd_error chd_set_header(co | |
| 886 | chd_error chd_set_header_file(co | |
| 884 | 887 | { |
| 885 | multi_file *file = NULL; | |
| 886 | 888 | chd_header oldheader; |
| 887 | 889 | chd_error err; |
| 888 | 890 | |
| 889 | /* punt if no interface */ | |
| 890 | if (cur_interface.open == NULL) | |
| 891 | EARLY_EXIT(err = CHDERR_NO_INTERFACE); | |
| 892 | ||
| 893 | /* punt if NULL or invalid */ | |
| 894 | if (filename == NULL || header == NULL) | |
| 895 | EARLY_EXIT(err = CHDERR_INVALID_PARAMETER); | |
| 896 | ||
| 897 | 891 | /* validate the header */ |
| 898 | 892 | err = header_validate(header); |
| 899 | 893 | if (err != CHDERR_NONE) |
| 900 | 894 | EARLY_EXIT(err); |
| 901 | 895 | |
| 902 | /* attempt to open the file */ | |
| 903 | file = multi_open(filename, "rb+"); | |
| 904 | if (file == NULL) | |
| 905 | EARLY_EXIT(err = CHDERR_FILE_NOT_FOUND); | |
| 906 | ||
| 907 | 896 | /* read the old header */ |
| 908 | 897 | err = header_read(file, &oldheader); |
| 909 | 898 | if (err != CHDERR_NONE) |
| r936 | r937 | |
| 930 | 919 | if (err != CHDERR_NONE) |
| 931 | 920 | EARLY_EXIT(err); |
| 932 | 921 | |
| 933 | /* close the file and return */ | |
| 934 | multi_close(file); | |
| 935 | 922 | return CHDERR_NONE; |
| 936 | 923 | |
| 937 | 924 | cleanup: |
| 938 | if (file) | |
| 939 | multi_close(file); | |
| 940 | 925 | return err; |
| 941 | 926 | } |
| 942 | 927 | |
| 943 | 928 | |
| 929 | /*------------------------------------------------- | |
| 930 | chd_set_header - write the current | |
| 931 | header to the file | |
| 932 | -------------------------------------------------*/ | |
| 944 | 933 | |
| 934 | chd_error chd_set_header(const char *filename, const chd_header *header) | |
| 935 | { | |
| 936 | core_file *file = NULL; | |
| 937 | file_error filerr; | |
| 938 | chd_error err; | |
| 939 | ||
| 940 | filerr = core_fopen(filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE, &file); | |
| 941 | if (filerr != FILERR_NONE) | |
| 942 | { | |
| 943 | err = CHDERR_FILE_NOT_FOUND; | |
| 944 | goto cleanup; | |
| 945 | } | |
| 946 | ||
| 947 | err = chd_set_header_file(file, header); | |
| 948 | if (err != CHDERR_NONE) | |
| 949 | goto cleanup; | |
| 950 | ||
| 951 | cleanup: | |
| 952 | if (file != NULL) | |
| 953 | core_fclose(file); | |
| 954 | return err; | |
| 955 | } | |
| 956 | ||
| 957 | ||
| 958 | ||
| 945 | 959 | /*************************************************************************** |
| 946 | 960 | CORE DATA READ/WRITE |
| 947 | 961 | ***************************************************************************/ |
| r936 | r937 | |
| 1128 | 1142 | |
| 1129 | 1143 | /* read the metadata */ |
| 1130 | 1144 | outputlen = MIN(outputlen, metaentry.length); |
| 1131 | count = multi_read(chd->file, metaentry.offset + METADATA_HEADER_SIZE, outputlen, output); | |
| 1145 | core_fseek(chd->file, metaentry.offset + METADATA_HEADER_SIZE, SEEK_SET); | |
| 1146 | count = core_fread(chd->file, output, outputlen); | |
| 1132 | 1147 | if (count != outputlen) |
| 1133 | 1148 | return CHDERR_READ_ERROR; |
| 1134 | 1149 | |
| r936 | r937 | |
| 1176 | 1191 | if (err == CHDERR_NONE && inputlen <= metaentry.length) |
| 1177 | 1192 | { |
| 1178 | 1193 | /* overwrite the original data with our new input data */ |
| 1179 | count = multi_write(chd->file, metaentry.offset + METADATA_HEADER_SIZE, inputlen, inputbuf); | |
| 1194 | core_fseek(chd->file, metaentry.offset + METADATA_HEADER_SIZE, SEEK_SET); | |
| 1195 | count = core_fwrite(chd->file, inputbuf, inputlen); | |
| 1180 | 1196 | if (count != inputlen) |
| 1181 | 1197 | return CHDERR_WRITE_ERROR; |
| 1182 | 1198 | |
| r936 | r937 | |
| 1204 | 1220 | put_bigendian_uint64(&raw_meta_header[8], (err == CHDERR_NONE) ? metaentry.next : 0); |
| 1205 | 1221 | |
| 1206 | 1222 | /* write out the new header */ |
| 1207 | offset = multi_length(chd->file); | |
| 1208 | count = multi_write(chd->file, offset, sizeof(raw_meta_header), raw_meta_header); | |
| 1223 | offset = core_fsize(chd->file); | |
| 1224 | core_fseek(chd->file, offset, SEEK_SET); | |
| 1225 | count = core_fwrite(chd->file, raw_meta_header, sizeof(raw_meta_header)); | |
| 1209 | 1226 | if (count != sizeof(raw_meta_header)) |
| 1210 | 1227 | return CHDERR_WRITE_ERROR; |
| 1211 | 1228 | |
| 1212 | 1229 | /* follow that with the data */ |
| 1213 | count = multi_write(chd->file, offset + METADATA_HEADER_SIZE, inputlen, inputbuf); | |
| 1230 | core_fseek(chd->file, offset + METADATA_HEADER_SIZE, SEEK_SET); | |
| 1231 | count = core_fwrite(chd->file, inputbuf, inputlen); | |
| 1214 | 1232 | if (count != inputlen) |
| 1215 | 1233 | return CHDERR_WRITE_ERROR; |
| 1216 | 1234 | |
| r936 | r937 | |
| 1298 | 1316 | { |
| 1299 | 1317 | chd_error err; |
| 1300 | 1318 | |
| 1301 | /* punt if no interface */ | |
| 1302 | if (cur_interface.open == NULL) | |
| 1303 | return CHDERR_NO_INTERFACE; | |
| 1304 | ||
| 1305 | 1319 | /* verify parameters */ |
| 1306 | 1320 | if (chd == NULL) |
| 1307 | 1321 | return CHDERR_INVALID_PARAMETER; |
| r936 | r937 | |
| 1379 | 1393 | /* update the ratio */ |
| 1380 | 1394 | if (curratio != NULL) |
| 1381 | 1395 | { |
| 1382 | UINT64 curlength = | |
| 1396 | UINT64 curlength = core | |
| 1383 | 1397 | *curratio = 1.0 - (double)curlength / (double)((UINT64)chd->comphunk * (UINT64)chd->header.hunkbytes); |
| 1384 | 1398 | } |
| 1385 | 1399 | |
| r936 | r937 | |
| 1422 | 1436 | |
| 1423 | 1437 | chd_error chd_verify_begin(chd_file *chd) |
| 1424 | 1438 | { |
| 1425 | /* punt if no interface */ | |
| 1426 | if (cur_interface.open == NULL) | |
| 1427 | return CHDERR_NO_INTERFACE; | |
| 1428 | ||
| 1429 | 1439 | /* verify parameters */ |
| 1430 | 1440 | if (chd == NULL) |
| 1431 | 1441 | return CHDERR_INVALID_PARAMETER; |
| r936 | r937 | |
| 1666 | 1676 | internal data structure |
| 1667 | 1677 | -------------------------------------------------*/ |
| 1668 | 1678 | |
| 1669 | static chd_error header_read( | |
| 1679 | static chd_error header_read(core | |
| 1670 | 1680 | { |
| 1671 | 1681 | UINT8 rawheader[CHD_MAX_HEADER_SIZE]; |
| 1672 | 1682 | UINT32 count; |
| r936 | r937 | |
| 1679 | 1689 | if (!file) |
| 1680 | 1690 | return CHDERR_INVALID_FILE; |
| 1681 | 1691 | |
| 1682 | /* punt if no interface */ | |
| 1683 | if (!cur_interface.read) | |
| 1684 | return CHDERR_NO_INTERFACE; | |
| 1685 | ||
| 1686 | 1692 | /* seek and read */ |
| 1687 | count = multi_read(file, 0, sizeof(rawheader), rawheader); | |
| 1693 | core_fseek(file, 0, SEEK_SET); | |
| 1694 | count = core_fread(file, rawheader, sizeof(rawheader)); | |
| 1688 | 1695 | if (count != sizeof(rawheader)) |
| 1689 | 1696 | return CHDERR_READ_ERROR; |
| 1690 | 1697 | |
| r936 | r937 | |
| 1748 | 1755 | internal data structure |
| 1749 | 1756 | -------------------------------------------------*/ |
| 1750 | 1757 | |
| 1751 | static chd_error header_write( | |
| 1758 | static chd_error header_write(core | |
| 1752 | 1759 | { |
| 1753 | 1760 | UINT8 rawheader[CHD_MAX_HEADER_SIZE]; |
| 1754 | 1761 | UINT32 count; |
| r936 | r937 | |
| 1761 | 1768 | if (!file) |
| 1762 | 1769 | return CHDERR_INVALID_FILE; |
| 1763 | 1770 | |
| 1764 | /* punt if no interface */ | |
| 1765 | if (!cur_interface.write) | |
| 1766 | return CHDERR_NO_INTERFACE; | |
| 1767 | ||
| 1768 | 1771 | /* only support writing modern headers */ |
| 1769 | 1772 | if (header->version != 3) |
| 1770 | 1773 | return CHDERR_INVALID_PARAMETER; |
| r936 | r937 | |
| 1787 | 1790 | memcpy(&rawheader[100], header->parentsha1, CHD_SHA1_BYTES); |
| 1788 | 1791 | |
| 1789 | 1792 | /* seek and write */ |
| 1790 | count = multi_write(file, 0, CHD_V3_HEADER_SIZE, rawheader); | |
| 1793 | core_fseek(file, 0, SEEK_SET); | |
| 1794 | count = core_fwrite(file, rawheader, CHD_V3_HEADER_SIZE); | |
| 1791 | 1795 | if (count != CHD_V3_HEADER_SIZE) |
| 1792 | 1796 | return CHDERR_WRITE_ERROR; |
| 1793 | 1797 | |
| r936 | r937 | |
| 1851 | 1855 | case MAP_ENTRY_TYPE_COMPRESSED: |
| 1852 | 1856 | |
| 1853 | 1857 | /* read it into the decompression buffer */ |
| 1854 | bytes = multi_read(chd->file, entry->offset, entry->length, chd->compressed); | |
| 1858 | core_fseek(chd->file, entry->offset, SEEK_SET); | |
| 1859 | bytes = core_fread(chd->file, chd->compressed, entry->length); | |
| 1855 | 1860 | if (bytes != entry->length) |
| 1856 | 1861 | return CHDERR_READ_ERROR; |
| 1857 | 1862 | |
| r936 | r937 | |
| 1865 | 1870 | |
| 1866 | 1871 | /* uncompressed data */ |
| 1867 | 1872 | case MAP_ENTRY_TYPE_UNCOMPRESSED: |
| 1868 | bytes = multi_read(chd->file, entry->offset, chd->header.hunkbytes, dest); | |
| 1873 | core_fseek(chd->file, entry->offset, SEEK_SET); | |
| 1874 | bytes = core_fread(chd->file, dest, chd->header.hunkbytes); | |
| 1869 | 1875 | if (bytes != chd->header.hunkbytes) |
| 1870 | 1876 | return CHDERR_READ_ERROR; |
| 1871 | 1877 | break; |
| r936 | r937 | |
| 1991 | 1997 | /* if the data doesn't fit into the previous entry, make a new one at the eof */ |
| 1992 | 1998 | newentry.offset = entry->offset; |
| 1993 | 1999 | if (newentry.offset == 0 || newentry.length > entry->length) |
| 1994 | newentry.offset = | |
| 2000 | newentry.offset = core | |
| 1995 | 2001 | |
| 1996 | 2002 | /* write the data */ |
| 1997 | bytes = multi_write(chd->file, newentry.offset, newentry.length, data); | |
| 2003 | core_fseek(chd->file, newentry.offset, SEEK_SET); | |
| 2004 | bytes = core_fwrite(chd->file, data, newentry.length); | |
| 1998 | 2005 | if (bytes != newentry.length) |
| 1999 | 2006 | return CHDERR_WRITE_ERROR; |
| 2000 | 2007 | |
| r936 | r937 | |
| 2004 | 2011 | |
| 2005 | 2012 | /* update the map on file */ |
| 2006 | 2013 | map_assemble(&fileentry[0], &chd->map[hunknum]); |
| 2007 | bytes = multi_write(chd->file, chd->header.length + hunknum * sizeof(fileentry), sizeof(fileentry), &fileentry[0]); | |
| 2014 | core_fseek(chd->file, chd->header.length + hunknum * sizeof(fileentry), SEEK_SET); | |
| 2015 | bytes = core_fwrite(chd->file, &fileentry[0], sizeof(fileentry)); | |
| 2008 | 2016 | if (bytes != sizeof(fileentry)) |
| 2009 | 2017 | return CHDERR_WRITE_ERROR; |
| 2010 | 2018 | |
| r936 | r937 | |
| 2022 | 2030 | a new CHD file |
| 2023 | 2031 | -------------------------------------------------*/ |
| 2024 | 2032 | |
| 2025 | static chd_error map_write_initial( | |
| 2033 | static chd_error map_write_initial(core | |
| 2026 | 2034 | { |
| 2027 | 2035 | UINT8 blank_map_entries[MAP_STACK_ENTRIES * MAP_ENTRY_SIZE]; |
| 2028 | 2036 | int fullchunks, remainder, count, i, j; |
| r936 | r937 | |
| 2056 | 2064 | } |
| 2057 | 2065 | |
| 2058 | 2066 | /* write the chunks */ |
| 2059 | count = multi_write(file, fileoffset, sizeof(blank_map_entries), blank_map_entries); | |
| 2067 | core_fseek(file, fileoffset, SEEK_SET); | |
| 2068 | count = core_fwrite(file, blank_map_entries, sizeof(blank_map_entries)); | |
| 2060 | 2069 | if (count != sizeof(blank_map_entries)) |
| 2061 | 2070 | return CHDERR_WRITE_ERROR; |
| 2062 | 2071 | fileoffset += sizeof(blank_map_entries); |
| r936 | r937 | |
| 2076 | 2085 | } |
| 2077 | 2086 | |
| 2078 | 2087 | /* write the chunks */ |
| 2079 | count = multi_write(file, fileoffset, remainder * MAP_ENTRY_SIZE, blank_map_entries); | |
| 2088 | core_fseek(file, fileoffset, SEEK_SET); | |
| 2089 | count = core_fwrite(file, blank_map_entries, remainder * MAP_ENTRY_SIZE); | |
| 2080 | 2090 | if (count != remainder * MAP_ENTRY_SIZE) |
| 2081 | 2091 | return CHDERR_WRITE_ERROR; |
| 2082 | 2092 | fileoffset += remainder * MAP_ENTRY_SIZE; |
| r936 | r937 | |
| 2084 | 2094 | |
| 2085 | 2095 | /* then write a special end-of-list cookie */ |
| 2086 | 2096 | memcpy(&blank_map_entries[0], END_OF_LIST_COOKIE, MAP_ENTRY_SIZE); |
| 2087 | count = multi_write(file, fileoffset, MAP_ENTRY_SIZE, blank_map_entries); | |
| 2097 | core_fseek(file, fileoffset, SEEK_SET); | |
| 2098 | count = core_fwrite(file, blank_map_entries, MAP_ENTRY_SIZE); | |
| 2088 | 2099 | if (count != MAP_ENTRY_SIZE) |
| 2089 | 2100 | return CHDERR_WRITE_ERROR; |
| 2090 | 2101 | |
| r936 | r937 | |
| 2120 | 2131 | entries = MAP_STACK_ENTRIES; |
| 2121 | 2132 | |
| 2122 | 2133 | /* read that many */ |
| 2123 | count = multi_read(chd->file, fileoffset, entries * entrysize, raw_map_entries); | |
| 2134 | core_fseek(chd->file, fileoffset, SEEK_SET); | |
| 2135 | count = core_fread(chd->file, raw_map_entries, entries * entrysize); | |
| 2124 | 2136 | if (count != entries * entrysize) |
| 2125 | 2137 | { |
| 2126 | 2138 | err = CHDERR_READ_ERROR; |
| r936 | r937 | |
| 2148 | 2160 | } |
| 2149 | 2161 | |
| 2150 | 2162 | /* verify the cookie */ |
| 2151 | count = multi_read(chd->file, fileoffset, entrysize, &cookie); | |
| 2163 | core_fseek(chd->file, fileoffset, SEEK_SET); | |
| 2164 | count = core_fread(chd->file, &cookie, entrysize); | |
| 2152 | 2165 | if (count != entrysize || memcmp(&cookie, END_OF_LIST_COOKIE, entrysize)) |
| 2153 | 2166 | { |
| 2154 | 2167 | err = CHDERR_INVALID_FILE; |
| r936 | r937 | |
| 2156 | 2169 | } |
| 2157 | 2170 | |
| 2158 | 2171 | /* verify the length */ |
| 2159 | if (maxoffset > | |
| 2172 | if (maxoffset > core | |
| 2160 | 2173 | { |
| 2161 | 2174 | err = CHDERR_INVALID_FILE; |
| 2162 | 2175 | goto cleanup; |
| r936 | r937 | |
| 2323 | 2336 | UINT32 count; |
| 2324 | 2337 | |
| 2325 | 2338 | /* read the raw header */ |
| 2326 | count = multi_read(chd->file, metaentry->offset, sizeof(raw_meta_header), raw_meta_header); | |
| 2339 | core_fseek(chd->file, metaentry->offset, SEEK_SET); | |
| 2340 | count = core_fread(chd->file, raw_meta_header, sizeof(raw_meta_header)); | |
| 2327 | 2341 | if (count != sizeof(raw_meta_header)) |
| 2328 | 2342 | break; |
| 2329 | 2343 | |
| r936 | r937 | |
| 2371 | 2385 | else |
| 2372 | 2386 | { |
| 2373 | 2387 | /* read the previous raw header */ |
| 2374 | count = multi_read(chd->file, prevoffset, sizeof(raw_meta_header), raw_meta_header); | |
| 2388 | core_fseek(chd->file, prevoffset, SEEK_SET); | |
| 2389 | count = core_fread(chd->file, raw_meta_header, sizeof(raw_meta_header)); | |
| 2375 | 2390 | if (count != sizeof(raw_meta_header)) |
| 2376 | 2391 | return CHDERR_READ_ERROR; |
| 2377 | 2392 | |
| r936 | r937 | |
| 2379 | 2394 | put_bigendian_uint64(&raw_meta_header[8], nextoffset); |
| 2380 | 2395 | |
| 2381 | 2396 | /* write the previous raw header */ |
| 2382 | count = multi_write(chd->file, prevoffset, sizeof(raw_meta_header), raw_meta_header); | |
| 2397 | core_fseek(chd->file, prevoffset, SEEK_SET); | |
| 2398 | count = core_fwrite(chd->file, raw_meta_header, sizeof(raw_meta_header)); | |
| 2383 | 2399 | if (count != sizeof(raw_meta_header)) |
| 2384 | 2400 | return CHDERR_WRITE_ERROR; |
| 2385 | 2401 | } |
| r936 | r937 | |
| 2399 | 2415 | UINT32 count; |
| 2400 | 2416 | |
| 2401 | 2417 | /* read the raw header */ |
| 2402 | count = multi_read(chd->file, offset, sizeof(raw_meta_header), raw_meta_header); | |
| 2418 | core_fseek(chd->file, offset, SEEK_SET); | |
| 2419 | count = core_fread(chd->file, raw_meta_header, sizeof(raw_meta_header)); | |
| 2403 | 2420 | if (count != sizeof(raw_meta_header)) |
| 2404 | 2421 | return CHDERR_READ_ERROR; |
| 2405 | 2422 | |
| r936 | r937 | |
| 2407 | 2424 | put_bigendian_uint32(&raw_meta_header[4], length); |
| 2408 | 2425 | |
| 2409 | 2426 | /* write the raw header */ |
| 2410 | count = multi_write(chd->file, offset, sizeof(raw_meta_header), raw_meta_header); | |
| 2427 | core_fseek(chd->file, offset, SEEK_SET); | |
| 2428 | count = core_fwrite(chd->file, raw_meta_header, sizeof(raw_meta_header)); | |
| 2411 | 2429 | if (count != sizeof(raw_meta_header)) |
| 2412 | 2430 | return CHDERR_WRITE_ERROR; |
| 2413 | 2431 | |
| r936 | r937 | |
| 2840 | 2858 | avcomp_decompress_config(data->compstate, data->decompconfig.decode_mask, data->decompconfig.video_buffer, data->decompconfig.video_stride, data->decompconfig.video_xor, data->decompconfig.audio_xor); |
| 2841 | 2859 | return CHDERR_NONE; |
| 2842 | 2860 | } |
| 2843 | ||
| 2844 | ||
| 2845 | ||
| 2846 | /*************************************************************************** | |
| 2847 | MULTIFILE ROUTINES | |
| 2848 | ***************************************************************************/ | |
| 2849 | ||
| 2850 | /*------------------------------------------------- | |
| 2851 | multi_open - open one or more files that | |
| 2852 | make up a CHD | |
| 2853 | -------------------------------------------------*/ | |
| 2854 | ||
| 2855 | static multi_file *multi_open(const char *filename, const char *mode) | |
| 2856 | { | |
| 2857 | chd_interface_file *chdfile = NULL; | |
| 2858 | multi_file *file = NULL; | |
| 2859 | char *curname = NULL; | |
| 2860 | int numfiles = 1; | |
| 2861 | int i; | |
| 2862 | ||
| 2863 | /* open the first file */ | |
| 2864 | chdfile = (*cur_interface.open)(filename, mode); | |
| 2865 | if (chdfile == NULL) | |
| 2866 | return NULL; | |
| 2867 | ||
| 2868 | /* allocate a new multi_file object */ | |
| 2869 | file = malloc(sizeof(*file)); | |
| 2870 | if (file == NULL) | |
| 2871 | goto error; | |
| 2872 | memset(file, 0, sizeof(*file)); | |
| 2873 | ||
| 2874 | /* if we're not writing, look for additional files */ | |
| 2875 | if (strchr(mode, 'w') == NULL && strchr(mode, '+') == NULL) | |
| 2876 | { | |
| 2877 | /* allocate a copy of the filename */ | |
| 2878 | curname = malloc(strlen(filename) + 1 + 4); | |
| 2879 | if (curname == NULL) | |
| 2880 | goto error; | |
| 2881 | ||
| 2882 | /* count how many files are available */ | |
| 2883 | for ( ; numfiles <= 1000; numfiles++) | |
| 2884 | { | |
| 2885 | chd_interface_file *tempfile; | |
| 2886 | ||
| 2887 | chd_multi_filename(filename, curname, numfiles - 1); | |
| 2888 | tempfile = (*cur_interface.open)(curname, mode); | |
| 2889 | if (tempfile == NULL) | |
| 2890 | break; | |
| 2891 | (*cur_interface.close)(tempfile); | |
| 2892 | } | |
| 2893 | } | |
| 2894 | ||
| 2895 | /* allocate memory for the file and length arrays */ | |
| 2896 | file->files = malloc(numfiles * sizeof(file->files[0])); | |
| 2897 | file->length = malloc(numfiles * sizeof(file->length[0])); | |
| 2898 | if (file->files == NULL || file->length == NULL) | |
| 2899 | goto error; | |
| 2900 | ||
| 2901 | /* fill in the first entry */ | |
| 2902 | file->files[0] = chdfile; | |
| 2903 | file->length[0] = (*cur_interface.length)(chdfile); | |
| 2904 | file->numfiles = numfiles; | |
| 2905 | ||
| 2906 | /* now open the remaining files for real */ | |
| 2907 | for (i = 1; i < file->numfiles; i++) | |
| 2908 | { | |
| 2909 | chd_multi_filename(filename, curname, i - 1); | |
| 2910 | file->files[i] = (*cur_interface.open)(curname, mode); | |
| 2911 | if (file->files[i] == NULL) | |
| 2912 | goto error; | |
| 2913 | file->length[i] = (*cur_interface.length)(file->files[i]); | |
| 2914 | } | |
| 2915 | ||
| 2916 | /* free memory */ | |
| 2917 | if (curname != NULL) | |
| 2918 | free(curname); | |
| 2919 | ||
| 2920 | return file; | |
| 2921 | ||
| 2922 | error: | |
| 2923 | if (file != NULL) | |
| 2924 | { | |
| 2925 | if (file->files != NULL) | |
| 2926 | free(file->files); | |
| 2927 | if (file->length != NULL) | |
| 2928 | free(file->length); | |
| 2929 | free(file); | |
| 2930 | } | |
| 2931 | if (curname != NULL) | |
| 2932 | free(curname); | |
| 2933 | if (chdfile != NULL) | |
| 2934 | (*cur_interface.close)(chdfile); | |
| 2935 | return NULL; | |
| 2936 | } | |
| 2937 | ||
| 2938 | ||
| 2939 | /*------------------------------------------------- | |
| 2940 | multi_close - close all open files associated | |
| 2941 | with a CHD | |
| 2942 | -------------------------------------------------*/ | |
| 2943 | ||
| 2944 | static void multi_close(multi_file *file) | |
| 2945 | { | |
| 2946 | int i; | |
| 2947 | ||
| 2948 | /* close all files */ | |
| 2949 | for (i = 0; i < file->numfiles; i++) | |
| 2950 | (*cur_interface.close)(file->files[i]); | |
| 2951 | ||
| 2952 | /* free memory */ | |
| 2953 | free(file->files); | |
| 2954 | free(file->length); | |
| 2955 | free(file); | |
| 2956 | } | |
| 2957 | ||
| 2958 | ||
| 2959 | /*------------------------------------------------- | |
| 2960 | multi_read - read from potentially multiple | |
| 2961 | files that make up a CHD | |
| 2962 | -------------------------------------------------*/ | |
| 2963 | ||
| 2964 | static UINT32 multi_read(multi_file *file, UINT64 offset, UINT32 count, void *buffer) | |
| 2965 | { | |
| 2966 | UINT64 baseoffset = 0; | |
| 2967 | UINT32 firstcount; | |
| 2968 | int i; | |
| 2969 | ||
| 2970 | /* find the file where the starting offset lives */ | |
| 2971 | for (i = 0; i < file->numfiles; i++) | |
| 2972 | { | |
| 2973 | if (offset >= baseoffset && offset < baseoffset + file->length[i]) | |
| 2974 | break; | |
| 2975 | baseoffset += file->length[i]; | |
| 2976 | } | |
| 2977 | ||
| 2978 | /* if past the total end, return nothing */ | |
| 2979 | if (i == file->numfiles) | |
| 2980 | return 0; | |
| 2981 | ||
| 2982 | /* if we don't cross the end of the file, just do the read */ | |
| 2983 | if (offset + count <= baseoffset + file->length[i]) | |
| 2984 | return (*cur_interface.read)(file->files[i], offset - baseoffset, count, buffer); | |
| 2985 | ||
| 2986 | /* otherwise, break it into two reads */ | |
| 2987 | firstcount = baseoffset + file->length[i] - offset; | |
| 2988 | return multi_read(file, offset, firstcount, buffer) + | |
| 2989 | multi_read(file, offset + firstcount, count - firstcount, (UINT8 *)buffer + firstcount); | |
| 2990 | } | |
| 2991 | ||
| 2992 | ||
| 2993 | /*------------------------------------------------- | |
| 2994 | multi_write - write to a CHD file; writes | |
| 2995 | past the end always go to the last file, no | |
| 2996 | matter how large it grows | |
| 2997 | -------------------------------------------------*/ | |
| 2998 | ||
| 2999 | static UINT32 multi_write(multi_file *file, UINT64 offset, UINT32 count, const void *buffer) | |
| 3000 | { | |
| 3001 | UINT64 baseoffset = 0; | |
| 3002 | UINT32 firstcount; | |
| 3003 | int i; | |
| 3004 | ||
| 3005 | /* find the file where the starting offset lives */ | |
| 3006 | for (i = 0; i < file->numfiles; i++) | |
| 3007 | { | |
| 3008 | if (offset >= baseoffset && offset < baseoffset + file->length[i]) | |
| 3009 | break; | |
| 3010 | baseoffset += file->length[i]; | |
| 3011 | } | |
| 3012 | ||
| 3013 | /* if past the total end, append to the last file */ | |
| 3014 | if (i == file->numfiles) | |
| 3015 | { | |
| 3016 | baseoffset -= file->length[--i]; | |
| 3017 | file->length[i] = (offset + count) - baseoffset; | |
| 3018 | } | |
| 3019 | ||
| 3020 | /* if we don't cross the end of the file, just do the write */ | |
| 3021 | if (offset + count <= baseoffset + file->length[i]) | |
| 3022 | return (*cur_interface.write)(file->files[i], offset - baseoffset, count, buffer); | |
| 3023 | ||
| 3024 | /* otherwise, break it into two writes */ | |
| 3025 | firstcount = baseoffset + file->length[i] - offset; | |
| 3026 | return multi_write(file, offset, firstcount, buffer) + | |
| 3027 | multi_write(file, offset + firstcount, count - firstcount, (UINT8 *)buffer + firstcount); | |
| 3028 | } | |
| 3029 | ||
| 3030 | ||
| 3031 | /*------------------------------------------------- | |
| 3032 | multi_length - return the total length of a | |
| 3033 | CHD file | |
| 3034 | -------------------------------------------------*/ | |
| 3035 | ||
| 3036 | static UINT64 multi_length(multi_file *file) | |
| 3037 | { | |
| 3038 | UINT64 totalsize = 0; | |
| 3039 | int i; | |
| 3040 | ||
| 3041 | /* sum the sizes of all the files */ | |
| 3042 | for (i = 0; i < file->numfiles; i++) | |
| 3043 | totalsize += file->length[i]; | |
| 3044 | return totalsize; | |
| 3045 | } |
| r0 | r937 | |
|---|---|---|
| 1 | /****************************************************************************** | |
| 2 | ||
| 3 | palette.c | |
| 4 | ||
| 5 | Core palette routines. | |
| 6 | ||
| 7 | Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team. | |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. | |
| 9 | ||
| 10 | ***************************************************************************/ | |
| 11 | ||
| 12 | #pragma once | |
| 13 | ||
| 14 | #ifndef __PALETTE_H__ | |
| 15 | #define __PALETTE_H__ | |
| 16 | ||
| 17 | #include "osdcore.h" | |
| 18 | ||
| 19 | ||
| 20 | /*************************************************************************** | |
| 21 | TYPE DEFINITIONS | |
| 22 | ***************************************************************************/ | |
| 23 | ||
| 24 | /* an rgb_t is a single combined R,G,B (and optionally alpha) value */ | |
| 25 | typedef UINT32 rgb_t; | |
| 26 | ||
| 27 | /* an rgb15_t is a single combined 15-bit R,G,B value */ | |
| 28 | typedef UINT16 rgb15_t; | |
| 29 | ||
| 30 | /* a palette is an opaque, reference counted object */ | |
| 31 | typedef struct _palette_t palette_t; | |
| 32 | ||
| 33 | /* a palette client is someone who is tracking the dirty state of a palette */ | |
| 34 | typedef struct _palette_client palette_client; | |
| 35 | ||
| 36 | ||
| 37 | ||
| 38 | /*************************************************************************** | |
| 39 | MACROS | |
| 40 | ***************************************************************************/ | |
| 41 | ||
| 42 | /* macros to assemble rgb_t values */ | |
| 43 | #define MAKE_RGB(r,g,b) ((((rgb_t)(r) & 0xff) << 16) | (((rgb_t)(g) & 0xff) << 8) | ((rgb_t)(b) & 0xff)) | |
| 44 | #define MAKE_ARGB(a,r,g,b) (MAKE_RGB(r,g,b) | (((rgb_t)(a) & 0xff) << 24)) | |
| 45 | ||
| 46 | /* macros to extract components from rgb_t values */ | |
| 47 | #define RGB_ALPHA(rgb) (((rgb) >> 24) & 0xff) | |
| 48 | #define RGB_RED(rgb) (((rgb) >> 16) & 0xff) | |
| 49 | #define RGB_GREEN(rgb) (((rgb) >> 8) & 0xff) | |
| 50 | #define RGB_BLUE(rgb) ((rgb) & 0xff) | |
| 51 | ||
| 52 | /* common colors */ | |
| 53 | #define RGB_BLACK (MAKE_RGB(0,0,0)) | |
| 54 | #define RGB_WHITE (MAKE_RGB(255,255,255)) | |
| 55 | ||
| 56 | ||
| 57 | ||
| 58 | /*************************************************************************** | |
| 59 | FUNCTION PROTOTYPES | |
| 60 | ***************************************************************************/ | |
| 61 | ||
| 62 | ||
| 63 | /* ----- palette allocation ----- */ | |
| 64 | ||
| 65 | /* allocate a new palette object and take a single reference on it */ | |
| 66 | palette_t *palette_alloc(UINT32 numcolors, UINT32 numgroups); | |
| 67 | ||
| 68 | /* reference a palette object, incrementing its reference count */ | |
| 69 | void palette_ref(palette_t *palette); | |
| 70 | ||
| 71 | /* dereference a palette object; if the reference count goes to 0, it is freed */ | |
| 72 | void palette_deref(palette_t *palette); | |
| 73 | ||
| 74 | ||
| 75 | ||
| 76 | /* ----- palette information ----- */ | |
| 77 | ||
| 78 | /* return the number of colors managed by the palette */ | |
| 79 | int palette_get_num_colors(palette_t *palette); | |
| 80 | ||
| 81 | /* return the number of groups managed by the palette */ | |
| 82 | int palette_get_num_groups(palette_t *palette); | |
| 83 | ||
| 84 | /* return the index of the black entry */ | |
| 85 | UINT32 palette_get_black_entry(palette_t *palette); | |
| 86 | ||
| 87 | /* return the index of the white entry */ | |
| 88 | UINT32 palette_get_white_entry(palette_t *palette); | |
| 89 | ||
| 90 | ||
| 91 | ||
| 92 | /* ----- palette clients ----- */ | |
| 93 | ||
| 94 | /* add a new client to a palette */ | |
| 95 | palette_client *palette_client_alloc(palette_t *palette); | |
| 96 | ||
| 97 | /* remove a client from a palette */ | |
| 98 | void palette_client_free(palette_client *client); | |
| 99 | ||
| 100 | /* return a pointer to the palette for this client */ | |
| 101 | palette_t *palette_client_get_palette(palette_client *client); | |
| 102 | ||
| 103 | /* atomically get the current dirty list for a client */ | |
| 104 | const UINT32 *palette_client_get_dirty_list(palette_client *client, UINT32 *mindirty, UINT32 *maxdirty); | |
| 105 | ||
| 106 | ||
| 107 | ||
| 108 | /* ----- color management ----- */ | |
| 109 | ||
| 110 | /* set the raw RGB color for a given palette index */ | |
| 111 | void palette_entry_set_color(palette_t *palette, UINT32 index, rgb_t rgb); | |
| 112 | ||
| 113 | /* return the raw RGB color for a given palette index */ | |
| 114 | rgb_t palette_entry_get_color(palette_t *palette, UINT32 index); | |
| 115 | ||
| 116 | /* return the adjusted RGB color (after all adjustments) for a given palette index */ | |
| 117 | rgb_t palette_entry_get_adjusted_color(palette_t *palette, UINT32 index); | |
| 118 | ||
| 119 | /* return the entire palette as an array of raw RGB values */ | |
| 120 | const rgb_t *palette_entry_list_raw(palette_t *palette); | |
| 121 | ||
| 122 | /* return the entire palette as an array of adjusted RGB values */ | |
| 123 | const rgb_t *palette_entry_list_adjusted(palette_t *palette); | |
| 124 | ||
| 125 | /* return the entire palette as an array of adjusted RGB-15 values */ | |
| 126 | const rgb_t *palette_entry_list_adjusted_rgb15(palette_t *palette); | |
| 127 | ||
| 128 | ||
| 129 | ||
| 130 | /* ----- palette adjustments ----- */ | |
| 131 | ||
| 132 | /* set the contrast adjustment for a single palette index */ | |
| 133 | void palette_entry_set_contrast(palette_t *palette, UINT32 index, float contrast); | |
| 134 | ||
| 135 | /* return the contrast adjustment for a single palette index */ | |
| 136 | float palette_entry_get_contrast(palette_t *palette, UINT32 index); | |
| 137 | ||
| 138 | /* configure overall brightness for a palette group */ | |
| 139 | void palette_group_set_brightness(palette_t *palette, UINT32 group, float brightness); | |
| 140 | ||
| 141 | /* configure overall contrast for a palette group */ | |
| 142 | void palette_group_set_contrast(palette_t *palette, UINT32 group, float contrast); | |
| 143 | ||
| 144 | ||
| 145 | ||
| 146 | /* ----- palette utilities ----- */ | |
| 147 | ||
| 148 | /* normalize a range of palette entries, mapping minimum brightness to lum_min and maximum | |
| 149 | brightness to lum_max; if either value is < 0, that boundary value is not modified */ | |
| 150 | void palette_normalize_range(palette_t *palette, UINT32 start, UINT32 end, int lum_min, int lum_max); | |
| 151 | ||
| 152 | ||
| 153 | ||
| 154 | /*************************************************************************** | |
| 155 | INLINE FUNCTIONS | |
| 156 | ***************************************************************************/ | |
| 157 | ||
| 158 | /*------------------------------------------------- | |
| 159 | rgb_to_rgb15 - convert an RGB triplet to | |
| 160 | a 15-bit OSD-specified RGB value | |
| 161 | -------------------------------------------------*/ | |
| 162 | ||
| 163 | INLINE rgb15_t rgb_to_rgb15(rgb_t rgb) | |
| 164 | { | |
| 165 | return ((RGB_RED(rgb) >> 3) << 10) | ((RGB_GREEN(rgb) >> 3) << 5) | ((RGB_BLUE(rgb) >> 3) << 0); | |
| 166 | } | |
| 167 | ||
| 168 | ||
| 169 | /*------------------------------------------------- | |
| 170 | rgb_clamp - clamp an RGB component to 0-255 | |
| 171 | -------------------------------------------------*/ | |
| 172 | ||
| 173 | INLINE UINT8 rgb_clamp(INT32 value) | |
| 174 | { | |
| 175 | if (value < 0) | |
| 176 | return 0; | |
| 177 | if (value > 255) | |
| 178 | return 255; | |
| 179 | return value; | |
| 180 | } | |
| 181 | ||
| 182 | ||
| 183 | /*------------------------------------------------- | |
| 184 | pal1bit - convert a 1-bit value to 8 bits | |
| 185 | -------------------------------------------------*/ | |
| 186 | ||
| 187 | INLINE UINT8 pal1bit(UINT8 bits) | |
| 188 | { | |
| 189 | return (bits & 1) ? 0xff : 0x00; | |
| 190 | } | |
| 191 | ||
| 192 | ||
| 193 | /*------------------------------------------------- | |
| 194 | pal2bit - convert a 2-bit value to 8 bits | |
| 195 | -------------------------------------------------*/ | |
| 196 | ||
| 197 | INLINE UINT8 pal2bit(UINT8 bits) | |
| 198 | { | |
| 199 | bits &= 3; | |
| 200 | return (bits << 6) | (bits << 4) | (bits << 2) | bits; | |
| 201 | } | |
| 202 | ||
| 203 | ||
| 204 | /*------------------------------------------------- | |
| 205 | pal3bit - convert a 3-bit value to 8 bits | |
| 206 | -------------------------------------------------*/ | |
| 207 | ||
| 208 | INLINE UINT8 pal3bit(UINT8 bits) | |
| 209 | { | |
| 210 | bits &= 7; | |
| 211 | return (bits << 5) | (bits << 2) | (bits >> 1); | |
| 212 | } | |
| 213 | ||
| 214 | ||
| 215 | /*------------------------------------------------- | |
| 216 | pal4bit - convert a 4-bit value to 8 bits | |
| 217 | -------------------------------------------------*/ | |
| 218 | ||
| 219 | INLINE UINT8 pal4bit(UINT8 bits) | |
| 220 | { | |
| 221 | bits &= 0xf; | |
| 222 | return (bits << 4) | bits; | |
| 223 | } | |
| 224 | ||
| 225 | ||
| 226 | /*------------------------------------------------- | |
| 227 | pal5bit - convert a 5-bit value to 8 bits | |
| 228 | -------------------------------------------------*/ | |
| 229 | ||
| 230 | INLINE UINT8 pal5bit(UINT8 bits) | |
| 231 | { | |
| 232 | bits &= 0x1f; | |
| 233 | return (bits << 3) | (bits >> 2); | |
| 234 | } | |
| 235 | ||
| 236 | ||
| 237 | /*------------------------------------------------- | |
| 238 | pal6bit - convert a 6-bit value to 8 bits | |
| 239 | -------------------------------------------------*/ | |
| 240 | ||
| 241 | INLINE UINT8 pal6bit(UINT8 bits) | |
| 242 | { | |
| 243 | bits &= 0x3f; | |
| 244 | return (bits << 2) | (bits >> 4); | |
| 245 | } | |
| 246 | ||
| 247 | ||
| 248 | /*------------------------------------------------- | |
| 249 | pal7bit - convert a 7-bit value to 8 bits | |
| 250 | -------------------------------------------------*/ | |
| 251 | ||
| 252 | INLINE UINT8 pal7bit(UINT8 bits) | |
| 253 | { | |
| 254 | bits &= 0x7f; | |
| 255 | return (bits << 1) | (bits >> 6); | |
| 256 | } | |
| 257 | ||
| 258 | ||
| 259 | #endif /* __PALETTE_H__ */ |
| r936 | r937 | |
|---|---|---|
| 13 | 13 | #define __CHD_H__ |
| 14 | 14 | |
| 15 | 15 | #include "osdcore.h" |
| 16 | #include "corefile.h" | |
| 16 | 17 | |
| 17 | 18 | |
| 18 | 19 | /*************************************************************************** |
| r936 | r937 | |
| 171 | 172 | |
| 172 | 173 | /* opaque types */ |
| 173 | 174 | typedef struct _chd_file chd_file; |
| 174 | typedef struct _chd_interface_file chd_interface_file; | |
| 175 | 175 | |
| 176 | 176 | |
| 177 | 177 | /* progress callback function */ |
| r936 | r937 | |
| 202 | 202 | }; |
| 203 | 203 | |
| 204 | 204 | |
| 205 | /* file I/O interface */ | |
| 206 | typedef struct _chd_interface chd_interface; | |
| 207 | struct _chd_interface | |
| 208 | { | |
| 209 | chd_interface_file *(*open)(const char *filename, const char *mode); | |
| 210 | void (*close)(chd_interface_file *file); | |
| 211 | UINT32 (*read)(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer); | |
| 212 | UINT32 (*write)(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer); | |
| 213 | UINT64 (*length)(chd_interface_file *file); | |
| 214 | }; | |
| 215 | ||
| 216 | ||
| 217 | 205 | /* A/V codec decompression configuration */ |
| 218 | 206 | typedef struct _av_codec_decompress_config av_codec_decompress_config; |
| 219 | 207 | struct _av_codec_decompress_config |
| r936 | r937 | |
| 232 | 220 | ***************************************************************************/ |
| 233 | 221 | |
| 234 | 222 | |
| 235 | /* ----- external interfacing ----- */ | |
| 236 | ||
| 237 | /* set the interface callbacks used for file I/O */ | |
| 238 | void chd_set_interface(chd_interface *new_interface); | |
| 239 | ||
| 240 | ||
| 241 | ||
| 242 | 223 | /* ----- CHD file management ----- */ |
| 243 | 224 | |
| 244 | 225 | /* create a new CHD file fitting the given description */ |
| 245 | 226 | chd_error chd_create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent); |
| 246 | 227 | |
| 228 | /* same as chd_create(), but accepts an already-opened core_file object */ | |
| 229 | chd_error chd_create_file(core_file *file, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent); | |
| 230 | ||
| 247 | 231 | /* open an existing CHD file */ |
| 248 | 232 | chd_error chd_open(const char *filename, int mode, chd_file *parent, chd_file **chd); |
| 249 | 233 | |
| 234 | /* same as chd_open(), but accepts an already-opened core_file object */ | |
| 235 | chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file **chd); | |
| 236 | ||
| 250 | 237 | /* close a CHD file */ |
| 251 | 238 | void chd_close(chd_file *chd); |
| 252 | 239 | |
| 253 | /* close all open CHD files */ | |
| 254 | void chd_close_all(void); | |
| 240 | /* return the associated core_file */ | |
| 241 | core_file *chd_core_file(chd_file *chd); | |
| 255 | 242 | |
| 256 | /* compute the indexed filename for multi-CHD use */ | |
| 257 | void chd_multi_filename(const char *origname, char *finalname, int index); | |
| 258 | 243 | |
| 259 | 244 | |
| 260 | ||
| 261 | 245 | /* ----- CHD header management ----- */ |
| 262 | 246 | |
| 263 | 247 | /* return a pointer to the extracted CHD header data */ |
| r936 | r937 | |
| 266 | 250 | /* set a modified header */ |
| 267 | 251 | chd_error chd_set_header(const char *filename, const chd_header *header); |
| 268 | 252 | |
| 253 | /* same as chd_set_header(), but accepts an already-opened core_file object */ | |
| 254 | chd_error chd_set_header_file(core_file *file, const chd_header *header); | |
| 269 | 255 | |
| 270 | 256 | |
| 257 | ||
| 271 | 258 | /* ----- core data read/write ----- */ |
| 272 | 259 | |
| 273 | 260 | /* read one hunk from the CHD file */ |
| r936 | r937 | |
|---|---|---|
| 39 | 39 | }; |
| 40 | 40 | |
| 41 | 41 | |
| 42 | /* temporary */ | |
| 43 | typedef UINT32 rgb_t; | |
| 44 | 42 | |
| 45 | #define RGB_ALPHA(x) (((x) >> 24) & 0xff) | |
| 46 | #define RGB_RED(x) (((x) >> 16) & 0xff) | |
| 47 | #define RGB_GREEN(x) (((x) >> 8) & 0xff) | |
| 48 | #define RGB_BLUE(x) (((x) >> 0) & 0xff) | |
| 49 | ||
| 50 | INLINE UINT8 pal5bit(UINT8 bits) | |
| 51 | { | |
| 52 | bits &= 0x1f; | |
| 53 | return (bits << 3) | (bits >> 2); | |
| 54 | } | |
| 55 | ||
| 56 | ||
| 57 | 43 | /*************************************************************************** |
| 58 | 44 | GLOBAL VARIABLES |
| 59 | 45 | ***************************************************************************/ |
| r936 | r937 | |
|---|---|---|
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | /*************************************************************************** |
| 17 | CON | |
| 17 | BITMAP ALLOCATION/CONFIGURATION | |
| 18 | 18 | ***************************************************************************/ |
| 19 | 19 | |
| 20 | /* VERY IMPORTANT: bitmap_alloc must allocate also a "safety area" 16 pixels wide all | |
| 21 | around the bitmap. This is required because, for performance reasons, some graphic | |
| 22 | routines don't clip at boundaries of the bitmap. */ | |
| 23 | #define BITMAP_SAFETY 16 | |
| 24 | ||
| 25 | ||
| 26 | ||
| 27 | /*************************************************************************** | |
| 28 | BITMAP ALLOCATION | |
| 29 | ***************************************************************************/ | |
| 30 | ||
| 31 | 20 | /*------------------------------------------------- |
| 32 | 21 | bitmap_alloc -- allocate memory for a new |
| 33 | 22 | bitmap of the given format |
| r936 | r937 | |
| 35 | 24 | |
| 36 | 25 | bitmap_t *bitmap_alloc(int width, int height, bitmap_format format) |
| 37 | 26 | { |
| 27 | return bitmap_alloc_slop(width, height, 0, 0, format); | |
| 28 | } | |
| 29 | ||
| 30 | ||
| 31 | /*------------------------------------------------- | |
| 32 | bitmap_alloc_slop -- allocate a new bitmap with | |
| 33 | additional slop on the borders | |
| 34 | -------------------------------------------------*/ | |
| 35 | ||
| 36 | bitmap_t *bitmap_alloc_slop(int width, int height, int xslop, int yslop, bitmap_format format) | |
| 37 | { | |
| 38 | 38 | int bpp = bitmap_format_to_bpp(format); |
| 39 | 39 | size_t allocbytes; |
| 40 | 40 | bitmap_t *bitmap; |
| r936 | r937 | |
| 45 | 45 | return NULL; |
| 46 | 46 | |
| 47 | 47 | /* round the width to a multiple of 8 and add some padding */ |
| 48 | rowpixels = (width + 2 * | |
| 48 | rowpixels = (width + 2 * xslop | |
| 49 | 49 | |
| 50 | 50 | /* allocate memory */ |
| 51 | allocbytes = sizeof(*bitmap) + rowpixels * (height + 2 * | |
| 51 | allocbytes = sizeof(*bitmap) + rowpixels * (height + 2 * yslop | |
| 52 | 52 | bitmap = malloc(allocbytes); |
| 53 | 53 | if (bitmap == NULL) |
| 54 | 54 | return NULL; |
| r936 | r937 | |
| 62 | 62 | bitmap->height = height; |
| 63 | 63 | bitmap->bpp = bpp; |
| 64 | 64 | bitmap->rowpixels = rowpixels; |
| 65 | bitmap->base = (UINT8 *)bitmap + sizeof(*bitmap) + rowpixels * | |
| 65 | bitmap->base = (UINT8 *)bitmap + sizeof(*bitmap) + rowpixels * yslop | |
| 66 | 66 | |
| 67 | 67 | return bitmap; |
| 68 | 68 | } |
| r936 | r937 | |
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | /*------------------------------------------------- |
| 103 | bitmap_set_palette -- associate a palette with | |
| 104 | a bitmap | |
| 105 | -------------------------------------------------*/ | |
| 106 | ||
| 107 | void bitmap_set_palette(bitmap_t *bitmap, palette_t *palette) | |
| 108 | { | |
| 109 | /* first dereference any existing palette */ | |
| 110 | if (bitmap->palette != NULL) | |
| 111 | { | |
| 112 | palette_deref(bitmap->palette); | |
| 113 | bitmap->palette = NULL; | |
| 114 | } | |
| 115 | ||
| 116 | /* then reference any new palette */ | |
| 117 | if (palette != NULL) | |
| 118 | { | |
| 119 | palette_ref(palette); | |
| 120 | bitmap->palette = palette; | |
| 121 | } | |
| 122 | } | |
| 123 | ||
| 124 | ||
| 125 | /*------------------------------------------------- | |
| 103 | 126 | bitmap_free -- release memory allocated for |
| 104 | 127 | a bitmap |
| 105 | 128 | -------------------------------------------------*/ |
| 106 | 129 | |
| 107 | 130 | void bitmap_free(bitmap_t *bitmap) |
| 108 | 131 | { |
| 132 | /* dereference the palette */ | |
| 133 | if (bitmap->palette != NULL) | |
| 134 | palette_deref(bitmap->palette); | |
| 135 | ||
| 136 | /* free the bitmap */ | |
| 109 | 137 | free(bitmap); |
| 110 | 138 | } |
| 111 | 139 |
| r936 | r937 | |
|---|---|---|
| 15 | 15 | #define __BITMAP_H__ |
| 16 | 16 | |
| 17 | 17 | #include "osdcore.h" |
| 18 | #include "palette.h" | |
| 18 | 19 | |
| 19 | 20 | |
| 20 | 21 | /*************************************************************************** |
| r936 | r937 | |
| 58 | 59 | int height; /* height of the bitmap */ |
| 59 | 60 | bitmap_format format; /* format of the bitmap */ |
| 60 | 61 | int bpp; /* bits per pixel */ |
| 62 | palette_t * palette; /* optional palette */ | |
| 61 | 63 | }; |
| 62 | 64 | |
| 63 | 65 | |
| r936 | r937 | |
| 80 | 82 | FUNCTION PROTOTYPES |
| 81 | 83 | ***************************************************************************/ |
| 82 | 84 | |
| 85 | ||
| 83 | 86 | /* ----- bitmap allocation ----- */ |
| 84 | 87 | |
| 88 | /* allocate a new bitmap of the given dimensions and format */ | |
| 85 | 89 | bitmap_t *bitmap_alloc(int width, int height, bitmap_format format); |
| 90 | ||
| 91 | /* allocate a new bitmap with additional slop on the borders */ | |
| 92 | bitmap_t *bitmap_alloc_slop(int width, int height, int xslop, int yslop, bitmap_format format); | |
| 93 | ||
| 94 | /* wrap a bitmap object around an existing array of data */ | |
| 86 | 95 | bitmap_t *bitmap_wrap(void *base, int width, int height, int rowpixels, bitmap_format format); |
| 96 | ||
| 97 | /* associate a palette with a bitmap */ | |
| 98 | void bitmap_set_palette(bitmap_t *bitmap, palette_t *palette); | |
| 99 | ||
| 100 | /* free allocated data for a bitmap */ | |
| 87 | 101 | void bitmap_free(bitmap_t *bitmap); |
| 88 | 102 | |
| 89 | 103 | |
| 104 | ||
| 90 | 105 | /* ----- bitmap drawing ----- */ |
| 91 | 106 | |
| 92 | void bitmap_fill(bitmap_t *dest, const rectangle *clip, UINT32 color); | |
| 107 | /* fill a bitmap with a single color, clipping to the given rectangle */ | |
| 108 | void bitmap_fill(bitmap_t *dest, const rectangle *clip, rgb_t color); | |
| 93 | 109 | |
| 94 | 110 | |
| 111 | ||
| 95 | 112 | /* ----- bitmap utilities ----- */ |
| 96 | 113 | |
| 114 | /* return the number of bits per pixel for a given bitmap format */ | |
| 97 | 115 | int bitmap_format_to_bpp(bitmap_format format); |
| 98 | 116 | |
| 99 | 117 | |
| 100 | 118 | |
| 119 | ||
| 101 | 120 | /*************************************************************************** |
| 102 | 121 | INLINE FUNCTIONS |
| 103 | 122 | ***************************************************************************/ |
| 104 | 123 | |
| 105 | /* compute the intersection of two rectangles */ | |
| 124 | /*------------------------------------------------- | |
| 125 | sect_rect - compute the intersection of two | |
| 126 | rectangles | |
| 127 | -------------------------------------------------*/ | |
| 128 | ||
| 106 | 129 | INLINE void sect_rect(rectangle *dst, const rectangle *src) |
| 107 | 130 | { |
| 108 | 131 | if (src->min_x > dst->min_x) dst->min_x = src->min_x; |
| r936 | r937 | |
| 112 | 135 | } |
| 113 | 136 | |
| 114 | 137 | |
| 115 | /* compute the union of two rectangles */ | |
| 138 | /*------------------------------------------------- | |
| 139 | union_rect - compute the union of two | |
| 140 | rectangles | |
| 141 | -------------------------------------------------*/ | |
| 142 | ||
| 116 | 143 | INLINE void union_rect(rectangle *dst, const rectangle *src) |
| 117 | 144 | { |
| 118 | 145 | if (src->min_x < dst->min_x) dst->min_x = src->min_x; |
| r936 | r937 | |
| 122 | 149 | } |
| 123 | 150 | |
| 124 | 151 | |
| 125 | /* draw a filled rectangle into a bitmap of arbitrary depth */ | |
| 152 | /*------------------------------------------------- | |
| 153 | plot_box - draw a filled rectangle into a | |
| 154 | bitmap of arbitrary depth | |
| 155 | -------------------------------------------------*/ | |
| 156 | ||
| 126 | 157 | INLINE void plot_box(bitmap_t *bitmap, int x, int y, int width, int height, UINT32 color) |
| 127 | 158 | { |
| 128 | 159 | rectangle clip; |
| r936 | r937 | |
|---|---|---|
| 85 | 85 | |
| 86 | 86 | /************************************* |
| 87 | 87 | * |
| 88 | * chd_create_ref()/chd_open_ref() | |
| 89 | * | |
| 90 | * These are a set of wrappers that wrap the chd_open() | |
| 91 | * and chd_create() functions to provide a way to open | |
| 92 | * the images with a filename. This is just a stopgap | |
| 93 | * measure until I get the core CHD code changed. For | |
| 94 | * now, this is an ugly hack but it works very well | |
| 95 | * | |
| 96 | * When these functions get moved into the core, it will | |
| 97 | * remove the need to specify an 'open' function in the | |
| 98 | * CHD interface | |
| 99 | * | |
| 100 | *************************************/ | |
| 101 | ||
| 102 | #define ENCODED_IMAGE_REF_PREFIX "/:/M/E/S/S//i/m/a/g/e//#" | |
| 103 | #define ENCODED_IMAGE_REF_FORMAT (ENCODED_IMAGE_REF_PREFIX "%p.chd") | |
| 104 | #define ENCODED_IMAGE_REF_LEN (sizeof(ENCODED_IMAGE_REF_PREFIX)+20) | |
| 105 | ||
| 106 | ||
| 107 | static void encode_ptr(void *ptr, char filename[ENCODED_IMAGE_REF_LEN]) | |
| 108 | { | |
| 109 | snprintf(filename, ENCODED_IMAGE_REF_LEN, ENCODED_IMAGE_REF_FORMAT, ptr); | |
| 110 | } | |
| 111 | ||
| 112 | ||
| 113 | ||
| 114 | int chd_create_ref(void *ref, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent) | |
| 115 | { | |
| 116 | char filename[ENCODED_IMAGE_REF_LEN]; | |
| 117 | encode_ptr(ref, filename); | |
| 118 | return chd_create(filename, logicalbytes, hunkbytes, compression, parent); | |
| 119 | } | |
| 120 | ||
| 121 | ||
| 122 | ||
| 123 | chd_error chd_open_ref(void *ref, int mode, chd_file *parent, chd_file **chd) | |
| 124 | { | |
| 125 | char filename[ENCODED_IMAGE_REF_LEN]; | |
| 126 | encode_ptr(ref, filename); | |
| 127 | return chd_open(filename, mode, parent, chd); | |
| 128 | } | |
| 129 | ||
| 130 | ||
| 131 | ||
| 132 | /************************************* | |
| 133 | * | |
| 134 | * decode_image_ref() | |
| 135 | * | |
| 136 | * This function will decode an image pointer, | |
| 137 | * provided one has been encoded in the ASCII | |
| 138 | * string. | |
| 139 | * | |
| 140 | *************************************/ | |
| 141 | ||
| 142 | static mess_image *decode_image_ref(const char encoded_image_ref[ENCODED_IMAGE_REF_LEN]) | |
| 143 | { | |
| 144 | void *ptr; | |
| 145 | char c[5] = { 0, }; | |
| 146 | ||
| 147 | /* scan the reference */ | |
| 148 | if (sscanf(encoded_image_ref, ENCODED_IMAGE_REF_PREFIX "%p%c%c%c%c", &ptr, &c[0], &c[1], &c[2], &c[3]) != 5) | |
| 149 | return NULL; | |
| 150 | ||
| 151 | /* check for the correct file extension */ | |
| 152 | if (strcmp(c, ".chd")) | |
| 153 | return NULL; | |
| 154 | ||
| 155 | /* success */ | |
| 156 | return (mess_image *) ptr; | |
| 157 | } | |
| 158 | ||
| 159 | ||
| 160 | ||
| 161 | /************************************* | |
| 162 | * | |
| 163 | * Interface between MAME's CHD system and MESS's image system | |
| 164 | * | |
| 165 | *************************************/ | |
| 166 | ||
| 167 | static chd_interface_file *mess_chd_open(const char *filename, const char *mode); | |
| 168 | static void mess_chd_close(chd_interface_file *file); | |
| 169 | static UINT32 mess_chd_read(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer); | |
| 170 | static UINT32 mess_chd_write(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer); | |
| 171 | static UINT64 mess_chd_length(chd_interface_file *file); | |
| 172 | ||
| 173 | static chd_interface mess_hard_disk_interface = | |
| 174 | { | |
| 175 | mess_chd_open, | |
| 176 | mess_chd_close, | |
| 177 | mess_chd_read, | |
| 178 | mess_chd_write, | |
| 179 | mess_chd_length | |
| 180 | }; | |
| 181 | ||
| 182 | ||
| 183 | static chd_interface_file *mess_chd_open(const char *filename, const char *mode) | |
| 184 | { | |
| 185 | file_error filerr; | |
| 186 | mess_image *image = decode_image_ref(filename); | |
| 187 | ||
| 188 | /* used when experimenting with CHDs */ | |
| 189 | if (USE_CHD_OPEN && !image) | |
| 190 | { | |
| 191 | mame_file *file; | |
| 192 | filerr = mame_fopen(SEARCHPATH_IMAGE, filename, OPEN_FLAG_READ, &file); | |
| 193 | return (chd_interface_file *) file; | |
| 194 | } | |
| 195 | ||
| 196 | /* invalid "file name"? */ | |
| 197 | if (!image) | |
| 198 | return NULL; | |
| 199 | ||
| 200 | /* read-only fp? */ | |
| 201 | if (!image_is_writable(image) && !(mode[0] == 'r' && !strchr(mode, '+'))) | |
| 202 | return NULL; | |
| 203 | ||
| 204 | /* otherwise return file pointer */ | |
| 205 | return (chd_interface_file *) image; | |
| 206 | } | |
| 207 | ||
| 208 | ||
| 209 | ||
| 210 | static void mess_chd_close(chd_interface_file *file) | |
| 211 | { | |
| 212 | } | |
| 213 | ||
| 214 | ||
| 215 | ||
| 216 | static UINT32 mess_chd_read(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer) | |
| 217 | { | |
| 218 | image_fseek((mess_image *)file, offset, SEEK_SET); | |
| 219 | return image_fread((mess_image *)file, buffer, count); | |
| 220 | } | |
| 221 | ||
| 222 | ||
| 223 | ||
| 224 | static UINT32 mess_chd_write(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer) | |
| 225 | { | |
| 226 | image_fseek((mess_image *)file, offset, SEEK_SET); | |
| 227 | return image_fwrite((mess_image *)file, buffer, count); | |
| 228 | } | |
| 229 | ||
| 230 | ||
| 231 | ||
| 232 | static UINT64 mess_chd_length(chd_interface_file *file) | |
| 233 | { | |
| 234 | return image_length((mess_image *)file); | |
| 235 | } | |
| 236 | ||
| 237 | ||
| 238 | ||
| 239 | ||
| 240 | /************************************* | |
| 241 | * | |
| 242 | 88 | * device_init_mess_hd() |
| 243 | 89 | * |
| 244 | 90 | * Device init |
| r936 | r937 | |
| 255 | 101 | |
| 256 | 102 | hd->hard_disk_handle = NULL; |
| 257 | 103 | |
| 258 | chd_set_interface(&mess_hard_disk_interface); | |
| 259 | ||
| 260 | 104 | return INIT_PASS; |
| 261 | 105 | } |
| 262 | 106 | |
| r936 | r937 | |
| 286 | 130 | { |
| 287 | 131 | is_writeable = image_is_writable(image); |
| 288 | 132 | chd = NULL; |
| 289 | err = chd_open_ref(image, is_writeable ? CHD_OPEN_READWRITE : CHD_OPEN_READ, NULL, &chd); | |
| 133 | err = chd_open_file(image_core_file(image), is_writeable ? CHD_OPEN_READWRITE : CHD_OPEN_READ, NULL, &chd); | |
| 290 | 134 | |
| 291 | 135 | /* special case; if we get CHDERR_FILE_NOT_WRITEABLE, make the |
| 292 | 136 | * image read only and repeat */ |
| r936 | r937 | |
| 348 | 192 | totalsectors = cylinders * heads * sectors; |
| 349 | 193 | |
| 350 | 194 | /* create the CHD file */ |
| 351 | err = chd_create_ref(image, (UINT64)totalsectors * (UINT64)sectorsize, hunksize, CHDCOMPRESSION_NONE, NULL); | |
| 195 | err = chd_create_file(image_core_file(image), (UINT64)totalsectors * (UINT64)sectorsize, hunksize, CHDCOMPRESSION_NONE, NULL); | |
| 352 | 196 | if (err != CHDERR_NONE) |
| 353 | 197 | goto error; |
| 354 | 198 |
| r936 | r937 | |
|---|---|---|
| 85 | 85 | * |
| 86 | 86 | *************************************/ |
| 87 | 87 | |
| 88 | #define ENCODED_IMAGE_REF_PREFIX "/:/M/E/S/S//i/m/a/g/e//#" | |
| 89 | #ifdef PTR64 | |
| 90 | #define ENCODED_IMAGE_REF_FORMAT (ENCODED_IMAGE_REF_PREFIX "%016llx") | |
| 91 | #else | |
| 92 | #define ENCODED_IMAGE_REF_FORMAT (ENCODED_IMAGE_REF_PREFIX "%016x") | |
| 93 | #endif | |
| 94 | #define ENCODED_IMAGE_REF_LEN (sizeof(ENCODED_IMAGE_REF_PREFIX)+16) | |
| 95 | ||
| 96 | ||
| 97 | static void encode_ptr(void *ptr, char filename[ENCODED_IMAGE_REF_LEN]) | |
| 98 | { | |
| 99 | snprintf(filename, ENCODED_IMAGE_REF_LEN, ENCODED_IMAGE_REF_FORMAT, | |
| 100 | (FPTR)ptr); | |
| 101 | } | |
| 102 | ||
| 103 | ||
| 104 | ||
| 105 | int chdcd_create_ref(void *ref, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent) | |
| 106 | { | |
| 107 | char filename[ENCODED_IMAGE_REF_LEN]; | |
| 108 | encode_ptr(ref, filename); | |
| 109 | return chd_create(filename, logicalbytes, hunkbytes, compression, parent); | |
| 110 | } | |
| 111 | ||
| 112 | ||
| 113 | ||
| 114 | chd_error chdcd_open_ref(void *ref, int mode, chd_file *parent, chd_file **chd) | |
| 115 | { | |
| 116 | char filename[ENCODED_IMAGE_REF_LEN]; | |
| 117 | encode_ptr(ref, filename); | |
| 118 | return chd_open(filename, mode, parent, chd); | |
| 119 | } | |
| 120 | ||
| 121 | ||
| 122 | ||
| 123 | 88 | /************************************* |
| 124 | 89 | * |
| 125 | * decode_image_ref() | |
| 126 | * | |
| 127 | * This function will decode an image pointer, | |
| 128 | * provided one has been encoded in the ASCII | |
| 129 | * string. | |
| 130 | * | |
| 131 | *************************************/ | |
| 132 | ||
| 133 | static mess_image *decode_image_ref(const char encoded_image_ref[ENCODED_IMAGE_REF_LEN]) | |
| 134 | { | |
| 135 | FPTR ptr; | |
| 136 | ||
| 137 | if (sscanf(encoded_image_ref, ENCODED_IMAGE_REF_FORMAT, &ptr) == 1) | |
| 138 | return (mess_image *) ptr; | |
| 139 | ||
| 140 | return NULL; | |
| 141 | } | |
| 142 | ||
| 143 | ||
| 144 | ||
| 145 | /************************************* | |
| 146 | * | |
| 147 | * Interface between MAME's CHD system and MESS's image system | |
| 148 | * | |
| 149 | *************************************/ | |
| 150 | ||
| 151 | static chd_interface_file *mess_chd_open(const char *filename, const char *mode); | |
| 152 | static void mess_chd_close(chd_interface_file *file); | |
| 153 | static UINT32 mess_chd_read(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer); | |
| 154 | static UINT32 mess_chd_write(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer); | |
| 155 | static UINT64 mess_chd_length(chd_interface_file *file); | |
| 156 | ||
| 157 | static chd_interface mess_cdrom_interface = | |
| 158 | { | |
| 159 | mess_chd_open, | |
| 160 | mess_chd_close, | |
| 161 | mess_chd_read, | |
| 162 | mess_chd_write, | |
| 163 | mess_chd_length | |
| 164 | }; | |
| 165 | ||
| 166 | ||
| 167 | static chd_interface_file *mess_chd_open(const char *filename, const char *mode) | |
| 168 | { | |
| 169 | mess_image *img = decode_image_ref(filename); | |
| 170 | ||
| 171 | /* invalid "file name"? */ | |
| 172 | assert(img); | |
| 173 | ||
| 174 | /* cdroms are read-only */ | |
| 175 | if (!(mode[0] == 'r' && !strchr(mode, '+'))) | |
| 176 | return NULL; | |
| 177 | ||
| 178 | /* otherwise return file pointer */ | |
| 179 | return (chd_interface_file *) img; | |
| 180 | } | |
| 181 | ||
| 182 | ||
| 183 | ||
| 184 | static void mess_chd_close(chd_interface_file *file) | |
| 185 | { | |
| 186 | } | |
| 187 | ||
| 188 | ||
| 189 | ||
| 190 | static UINT32 mess_chd_read(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer) | |
| 191 | { | |
| 192 | image_fseek((mess_image *)file, offset, SEEK_SET); | |
| 193 | return image_fread((mess_image *)file, buffer, count); | |
| 194 | } | |
| 195 | ||
| 196 | ||
| 197 | ||
| 198 | static UINT32 mess_chd_write(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer) | |
| 199 | { | |
| 200 | image_fseek((mess_image *)file, offset, SEEK_SET); | |
| 201 | return image_fwrite((mess_image *)file, buffer, count); | |
| 202 | } | |
| 203 | ||
| 204 | ||
| 205 | ||
| 206 | static UINT64 mess_chd_length(chd_interface_file *file) | |
| 207 | { | |
| 208 | return image_length((mess_image *)file); | |
| 209 | } | |
| 210 | ||
| 211 | ||
| 212 | ||
| 213 | /************************************* | |
| 214 | * | |
| 215 | 90 | * device_init_mess_cd() |
| 216 | 91 | * |
| 217 | 92 | * Device init |
| r936 | r937 | |
| 228 | 103 | |
| 229 | 104 | cd->cdrom_handle = NULL; |
| 230 | 105 | |
| 231 | chd_set_interface(&mess_cdrom_interface); | |
| 232 | ||
| 233 | 106 | return INIT_PASS; |
| 234 | 107 | } |
| 235 | 108 | |
| r936 | r937 | |
| 254 | 127 | cd = get_drive(image); |
| 255 | 128 | |
| 256 | 129 | /* open the CHD file */ |
| 257 | err = chd | |
| 130 | err = chd | |
| 258 | 131 | if (err) |
| 259 | 132 | goto error; |
| 260 | 133 |
| r936 | r937 | |
|---|---|---|
| 16 | 16 | #include "device.h" |
| 17 | 17 | #include "image.h" |
| 18 | 18 | #include "artworkx.h" |
| 19 | #include "memory.h" | |
| 19 | 20 | |
| 20 | 21 | |
| 21 | 22 |
| r936 | r937 | |
|---|---|---|
| 32 | 32 | |
| 33 | 33 | union |
| 34 | 34 | { |
| 35 | o | |
| 35 | core_file *file; | |
| 36 | 36 | UINT8 *buffer; |
| 37 | 37 | } u; |
| 38 | 38 | }; |
| r936 | r937 | |
| 112 | 112 | OPEN_FLAG_READ | OPEN_FLAG_WRITE, |
| 113 | 113 | OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE |
| 114 | 114 | }; |
| 115 | o | |
| 115 | core_file *f = NULL; | |
| 116 | 116 | char *buf = NULL; |
| 117 | 117 | int len, i; |
| 118 | 118 | imgtool_stream *s = NULL; |
| 119 | 119 | char c; |
| 120 | UINT64 filesize; | |
| 121 | 120 | |
| 122 | 121 | /* maybe we are just a ZIP? */ |
| 123 | 122 | ext = strrchr(fname, '.'); |
| 124 | 123 | if (ext && !mame_stricmp(ext, ".zip")) |
| 125 | 124 | return stream_open_zip(fname, NULL, read_or_write); |
| 126 | 125 | |
| 127 | filerr = o | |
| 126 | filerr = core_fopen(fname, write_modes[read_or_write], &f | |
| 128 | 127 | if (filerr != FILERR_NONE) |
| 129 | 128 | { |
| 130 | 129 | if (!read_or_write) |
| r936 | r937 | |
| 166 | 165 | memset(imgfile, 0, sizeof(*imgfile)); |
| 167 | 166 | imgfile->imgtype = IMG_FILE; |
| 168 | 167 | imgfile->position = 0; |
| 169 | imgfile->filesize = | |
| 168 | imgfile->filesize = core_fsize(f); | |
| 170 | 169 | imgfile->write_protect = read_or_write ? 0 : 1; |
| 171 | 170 | imgfile->u.file = f; |
| 172 | 171 | imgfile->name = fname; |
| 173 | 172 | return imgfile; |
| 174 | 173 | |
| 175 | 174 | error: |
| 176 | if (imgfile) | |
| 175 | if (imgfile != NULL) | |
| 177 | 176 | free((void *) imgfile); |
| 178 | if (f) | |
| 179 | osd_close(f); | |
| 177 | if (f != NULL) | |
| 178 | core_fclose(f); | |
| 180 | 179 | if (buf) |
| 181 | 180 | free(buf); |
| 182 | 181 | return (imgtool_stream *) NULL; |
| r936 | r937 | |
| 236 | 235 | switch(s->imgtype) |
| 237 | 236 | { |
| 238 | 237 | case IMG_FILE: |
| 239 | o | |
| 238 | core_fclose(s->u.file); | |
| 240 | 239 | break; |
| 241 | 240 | |
| 242 | 241 | case IMG_MEM: |
| r936 | r937 | |
| 252 | 251 | |
| 253 | 252 | |
| 254 | 253 | |
| 254 | core_file *stream_core_file(imgtool_stream *stream) | |
| 255 | { | |
| 256 | return (stream->imgtype == IMG_FILE) ? stream->u.file : NULL; | |
| 257 | } | |
| 258 | ||
| 259 | ||
| 260 | ||
| 255 | 261 | UINT32 stream_read(imgtool_stream *stream, void *buf, UINT32 sz) |
| 256 | 262 | { |
| 257 | file_error filerr; | |
| 258 | 263 | UINT32 result = 0; |
| 259 | 264 | |
| 260 | 265 | switch(stream->imgtype) |
| 261 | 266 | { |
| 262 | 267 | case IMG_FILE: |
| 263 | 268 | assert(sz == (UINT32) sz); |
| 264 | filerr = osd_read(stream->u.file, buf, stream->position, (UINT32) sz, &result); | |
| 269 | core_fseek(stream->u.file, stream->position, SEEK_SET); | |
| 270 | result = core_fread(stream->u.file, buf, (UINT32) sz); | |
| 265 | 271 | break; |
| 266 | 272 | |
| 267 | 273 | case IMG_MEM: |
| r936 | r937 | |
| 285 | 291 | |
| 286 | 292 | UINT32 stream_write(imgtool_stream *s, const void *buf, UINT32 sz) |
| 287 | 293 | { |
| 288 | file_error filerr; | |
| 289 | 294 | void *new_buffer; |
| 290 | 295 | UINT32 result = 0; |
| 291 | 296 | |
| r936 | r937 | |
| 316 | 321 | break; |
| 317 | 322 | |
| 318 | 323 | case IMG_FILE: |
| 319 | filerr = osd_write(s->u.file, buf, s->position, sz, &result); | |
| 324 | core_fseek(s->u.file, s->position, SEEK_SET); | |
| 325 | result = core_fwrite(s->u.file, buf, sz); | |
| 320 | 326 | break; |
| 321 | 327 | |
| 322 | 328 | default: |
| r936 | r937 | |
|---|---|---|
| 10 | 10 | #define STREAM_H |
| 11 | 11 | |
| 12 | 12 | #include "imgterrs.h" |
| 13 | #include "corefile.h" | |
| 13 | 14 | #include "mamecore.h" |
| 14 | 15 | |
| 15 | 16 | typedef struct _imgtool_stream imgtool_stream; |
| r936 | r937 | |
| 18 | 19 | imgtool_stream *stream_open_write_stream(int filesize); |
| 19 | 20 | imgtool_stream *stream_open_mem(void *buf, size_t sz); |
| 20 | 21 | void stream_close(imgtool_stream *stream); |
| 22 | core_file *stream_core_file(imgtool_stream *stream); | |
| 21 | 23 | UINT32 stream_read(imgtool_stream *stream, void *buf, UINT32 sz); |
| 22 | 24 | UINT32 stream_write(imgtool_stream *stream, const void *buf, UINT32 sz); |
| 23 | 25 | UINT64 stream_size(imgtool_stream *stream); |
| r936 | r937 | |
|---|---|---|
| 14 | 14 | #include "imghd.h" |
| 15 | 15 | |
| 16 | 16 | |
| 17 | /* Encoded mess_image: in order to have hard_disk_open handle mess_image | |
| 18 | pointers, we encode the reference as an ASCII string and pass it as a file | |
| 19 | name. mess_hard_disk_open then decodes the file name to get the original | |
| 20 | mess_image pointer. */ | |
| 21 | #define encoded_image_ref_prefix "/:/i/m/g/t/o/o/l//S/T/R/E/A/M//#" | |
| 22 | #define encoded_image_ref_len_format "%03d" | |
| 23 | #define encoded_image_ref_format encoded_image_ref_prefix encoded_image_ref_len_format "@%p" | |
| 24 | enum | |
| 25 | { | |
| 26 | ptr_max_len = 100, | |
| 27 | encoded_image_ref_len_offset = sizeof(encoded_image_ref_prefix)-1, | |
| 28 | encoded_image_ref_len_len = 3, | |
| 29 | encoded_image_ref_max_len = sizeof(encoded_image_ref_prefix)-1+encoded_image_ref_len_len+1+ptr_max_len+1 | |
| 30 | }; | |
| 31 | ||
| 32 | ||
| 33 | ||
| 34 | /* this should not be necessary, but I'd rather introduce a spectacular rather | |
| 35 | * than a subtle crash */ | |
| 36 | static void chd_save_interface(chd_interface *intf) | |
| 37 | { | |
| 38 | memset(intf, 0, sizeof(*intf)); | |
| 39 | } | |
| 40 | ||
| 41 | ||
| 42 | ||
| 43 | 17 | static imgtoolerr_t map_chd_error(chd_error chderr) |
| 44 | 18 | { |
| 45 | 19 | imgtoolerr_t err; |
| r936 | r937 | |
| 68 | 42 | |
| 69 | 43 | |
| 70 | 44 | /* |
| 71 | encode_image_ref() | |
| 72 | ||
| 73 | Encode an image pointer into an ASCII string that can be passed to | |
| 74 | hard_disk_open as a file name. | |
| 75 | */ | |
| 76 | static void encode_image_ref(const imgtool_stream *stream, char encoded_image_ref[encoded_image_ref_max_len]) | |
| 77 | { | |
| 78 | int actual_len; | |
| 79 | char buf[encoded_image_ref_len_len+1]; | |
| 80 | ||
| 81 | /* print, leaving len as 0 */ | |
| 82 | actual_len = snprintf(encoded_image_ref, encoded_image_ref_max_len, | |
| 83 | encoded_image_ref_format, 0, (void *) stream); | |
| 84 | ||
| 85 | /* debug check: has the buffer been filled */ | |
| 86 | assert(actual_len < (encoded_image_ref_max_len-1)); | |
| 87 | ||
| 88 | /* print actual lenght */ | |
| 89 | sprintf(buf, encoded_image_ref_len_format, actual_len); | |
| 90 | memcpy(encoded_image_ref+encoded_image_ref_len_offset, buf, encoded_image_ref_len_len); | |
| 91 | } | |
| 92 | ||
| 93 | /* | |
| 94 | decode_image_ref() | |
| 95 | ||
| 96 | This function will decode an image pointer, provided one has been encoded | |
| 97 | in the ASCII string. | |
| 98 | */ | |
| 99 | static imgtool_stream *decode_image_ref(const char *encoded_image_ref) | |
| 100 | { | |
| 101 | int expected_len; | |
| 102 | void *ptr; | |
| 103 | ||
| 104 | /* read original lenght and ptr */ | |
| 105 | if (sscanf(encoded_image_ref, encoded_image_ref_format, &expected_len, &ptr) == 2) | |
| 106 | { | |
| 107 | /* only return ptr if lenght match */ | |
| 108 | if (expected_len == strlen(encoded_image_ref)) | |
| 109 | return (imgtool_stream *) ptr; | |
| 110 | } | |
| 111 | ||
| 112 | return NULL; | |
| 113 | } | |
| 114 | ||
| 115 | ||
| 116 | static chd_interface_file *imgtool_chd_open(const char *filename, const char *mode); | |
| 117 | static void imgtool_chd_close(chd_interface_file *file); | |
| 118 | static UINT32 imgtool_chd_read(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer); | |
| 119 | static UINT32 imgtool_chd_write(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer); | |
| 120 | static UINT64 imgtool_chd_length(chd_interface_file *file); | |
| 121 | ||
| 122 | static chd_interface imgtool_chd_interface = | |
| 123 | { | |
| 124 | imgtool_chd_open, | |
| 125 | imgtool_chd_close, | |
| 126 | imgtool_chd_read, | |
| 127 | imgtool_chd_write, | |
| 128 | imgtool_chd_length | |
| 129 | }; | |
| 130 | ||
| 131 | /* | |
| 132 | MAME hard disk core interface | |
| 133 | */ | |
| 134 | ||
| 135 | /* | |
| 136 | imgtool_chd_open - interface for opening a hard disk image | |
| 137 | */ | |
| 138 | static chd_interface_file *imgtool_chd_open(const char *filename, const char *mode) | |
| 139 | { | |
| 140 | imgtool_stream *img = decode_image_ref(filename); | |
| 141 | ||
| 142 | /* invalid "file name"? */ | |
| 143 | if (img == NULL) | |
| 144 | return NULL; | |
| 145 | ||
| 146 | /* read-only fp? */ | |
| 147 | if ((stream_isreadonly(img)) && ! (mode[0] == 'r' && !strchr(mode, '+'))) | |
| 148 | return NULL; | |
| 149 | ||
| 150 | /* otherwise return file pointer */ | |
| 151 | return (chd_interface_file *) img; | |
| 152 | } | |
| 153 | ||
| 154 | /* | |
| 155 | imgtool_chd_close - interface for closing a hard disk image | |
| 156 | */ | |
| 157 | static void imgtool_chd_close(chd_interface_file *file) | |
| 158 | { | |
| 159 | } | |
| 160 | ||
| 161 | /* | |
| 162 | imgtool_chd_read - interface for reading from a hard disk image | |
| 163 | */ | |
| 164 | static UINT32 imgtool_chd_read(chd_interface_file *file, UINT64 offset, UINT32 count, void *buffer) | |
| 165 | { | |
| 166 | stream_seek((imgtool_stream *)file, offset, SEEK_SET); | |
| 167 | return stream_read((imgtool_stream *)file, buffer, count); | |
| 168 | } | |
| 169 | ||
| 170 | /* | |
| 171 | imgtool_chd_write - interface for writing to a hard disk image | |
| 172 | */ | |
| 173 | static UINT32 imgtool_chd_write(chd_interface_file *file, UINT64 offset, UINT32 count, const void *buffer) | |
| 174 | { | |
| 175 | stream_seek((imgtool_stream *)file, offset, SEEK_SET); | |
| 176 | return stream_write((imgtool_stream *)file, buffer, count); | |
| 177 | } | |
| 178 | ||
| 179 | /* | |
| 180 | imgtool_chd_write - interface for determining the length of a hard disk image | |
| 181 | */ | |
| 182 | static UINT64 imgtool_chd_length(chd_interface_file *file) | |
| 183 | { | |
| 184 | return stream_size((imgtool_stream *)file); | |
| 185 | } | |
| 186 | ||
| 187 | ||
| 188 | /* | |
| 189 | 45 | imghd_create() |
| 190 | 46 | |
| 191 | 47 | Create a MAME HD image |
| r936 | r937 | |
| 193 | 49 | imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 hunksize, UINT32 cylinders, UINT32 heads, UINT32 sectors, UINT32 seclen) |
| 194 | 50 | { |
| 195 | 51 | imgtoolerr_t err = IMGTOOLERR_SUCCESS; |
| 196 | char encoded_image_ref[encoded_image_ref_max_len]; | |
| 197 | chd_interface interface_save; | |
| 198 | 52 | UINT8 *cache = NULL; |
| 199 | 53 | chd_file *chd = NULL; |
| 200 | 54 | int rc; |
| r936 | r937 | |
| 202 | 56 | int hunknum, totalhunks; |
| 203 | 57 | char metadata[256]; |
| 204 | 58 | |
| 205 | /* jump through the hoops as required by the CHD system */ | |
| 206 | encode_image_ref(stream, encoded_image_ref); | |
| 207 | chd_save_interface(&interface_save); | |
| 208 | chd_set_interface(&imgtool_chd_interface); | |
| 209 | ||
| 210 | 59 | /* sanity check args */ |
| 211 | 60 | if (hunksize >= 2048) |
| 212 | 61 | { |
| r936 | r937 | |
| 227 | 76 | logicalbytes = (UINT64)cylinders * heads * sectors * seclen; |
| 228 | 77 | |
| 229 | 78 | /* create the new hard drive */ |
| 230 | rc = chd_create(e | |
| 79 | rc = chd_create_file(stream_core | |
| 231 | 80 | if (rc != CHDERR_NONE) |
| 232 | 81 | { |
| 233 | 82 | err = map_chd_error(rc); |
| r936 | r937 | |
| 235 | 84 | } |
| 236 | 85 | |
| 237 | 86 | /* open the new hard drive */ |
| 238 | rc = chd_open(e | |
| 87 | rc = chd_open_file(stream_core | |
| 239 | 88 | if (rc != CHDERR_NONE) |
| 240 | 89 | { |
| 241 | 90 | err = map_chd_error(rc); |
| r936 | r937 | |
| 278 | 127 | free(cache); |
| 279 | 128 | if (chd) |
| 280 | 129 | chd_close(chd); |
| 281 | chd_set_interface(&interface_save); | |
| 282 | 130 | return err; |
| 283 | 131 | } |
| 284 | 132 | |
| r936 | r937 | |
| 293 | 141 | { |
| 294 | 142 | chd_error chderr; |
| 295 | 143 | imgtoolerr_t err = IMGTOOLERR_SUCCESS; |
| 296 | char encoded_image_ref[encoded_image_ref_max_len]; | |
| 297 | chd_interface interface_save; | |
| 298 | 144 | |
| 299 | 145 | hard_disk->hard_disk = NULL; |
| 300 | 146 | hard_disk->chd = NULL; |
| 301 | encode_image_ref(stream, encoded_image_ref); | |
| 302 | 147 | |
| 303 | /* use our CHD interface */ | |
| 304 | chd_save_interface(&interface_save); | |
| 305 | chd_set_interface(&imgtool_chd_interface); | |
| 306 | ||
| 307 | chderr = chd_open(encoded_image_ref, stream_isreadonly(stream) ? CHD_OPEN_READ : CHD_OPEN_READWRITE, NULL, &hard_disk->chd); | |
| 148 | chderr = chd_open_file(stream_core_file(stream), stream_isreadonly(stream) ? CHD_OPEN_READ : CHD_OPEN_READWRITE, NULL, &hard_disk->chd); | |
| 308 | 149 | if (chderr) |
| 309 | 150 | { |
| 310 | 151 | err = map_chd_error(chderr); |
| r936 | r937 | |
| 322 | 163 | done: |
| 323 | 164 | if (err) |
| 324 | 165 | imghd_close(hard_disk); |
| 325 | chd_set_interface(&interface_save); | |
| 326 | 166 | return err; |
| 327 | 167 | } |
| 328 | 168 | |
| r936 | r937 | |
| 335 | 175 | */ |
| 336 | 176 | void imghd_close(struct mess_hard_disk_file *disk) |
| 337 | 177 | { |
| 338 | chd_interface interface_save; | |
| 339 | ||
| 340 | chd_save_interface(&interface_save); | |
| 341 | chd_set_interface(&imgtool_chd_interface); | |
| 342 | ||
| 343 | 178 | if (disk->hard_disk) |
| 344 | 179 | { |
| 345 | 180 | hard_disk_close(disk->hard_disk); |
| r936 | r937 | |
| 352 | 187 | } |
| 353 | 188 | if (disk->stream) |
| 354 | 189 | stream_close(disk->stream); |
| 355 | ||
| 356 | chd_set_interface(&interface_save); | |
| 357 | 190 | } |
| 358 | 191 | |
| 359 | 192 | |
| r936 | r937 | |
| 365 | 198 | */ |
| 366 | 199 | imgtoolerr_t imghd_read(struct mess_hard_disk_file *disk, UINT32 lbasector, void *buffer) |
| 367 | 200 | { |
| 368 | chd_interface interface_save; | |
| 369 | 201 | UINT32 reply; |
| 370 | ||
| 371 | chd_save_interface(&interface_save); | |
| 372 | chd_set_interface(&imgtool_chd_interface); | |
| 373 | 202 | reply = hard_disk_read(disk->hard_disk, lbasector, buffer); |
| 374 | chd_set_interface(&interface_save); | |
| 375 | ||
| 376 | 203 | return reply ? IMGTOOLERR_SUCCESS : map_chd_error(reply); |
| 377 | 204 | } |
| 378 | 205 | |
| r936 | r937 | |
| 385 | 212 | */ |
| 386 | 213 | imgtoolerr_t imghd_write(struct mess_hard_disk_file *disk, UINT32 lbasector, const void *buffer) |
| 387 | 214 | { |
| 388 | chd_interface interface_save; | |
| 389 | 215 | UINT32 reply; |
| 390 | ||
| 391 | chd_save_interface(&interface_save); | |
| 392 | chd_set_interface(&imgtool_chd_interface); | |
| 393 | 216 | reply = hard_disk_write(disk->hard_disk, lbasector, buffer); |
| 394 | chd_set_interface(&interface_save); | |
| 395 | ||
| 396 | 217 | return reply ? IMGTOOLERR_SUCCESS : map_chd_error(reply); |
| 397 | 218 | } |
| 398 | 219 | |
| r936 | r937 | |
| 405 | 226 | */ |
| 406 | 227 | const hard_disk_info *imghd_get_header(struct mess_hard_disk_file *disk) |
| 407 | 228 | { |
| 408 | chd_interface interface_save; | |
| 409 | 229 | const hard_disk_info *reply; |
| 410 | ||
| 411 | chd_save_interface(&interface_save); | |
| 412 | chd_set_interface(&imgtool_chd_interface); | |
| 413 | 230 | reply = hard_disk_get_info(disk->hard_disk); |
| 414 | chd_set_interface(&interface_save); | |
| 415 | ||
| 416 | 231 | return reply; |
| 417 | 232 | } |
| 418 | 233 |
| r936 | r937 | |
|---|---|---|
| 40 | 40 | char *err_message; |
| 41 | 41 | |
| 42 | 42 | /* variables that are only non-zero when an image is mounted */ |
| 43 | o | |
| 43 | core_file *file; | |
| 44 | 44 | char *name; |
| 45 | 45 | char *dir; |
| 46 | 46 | char *hash; |
| 47 | UINT64 length; | |
| 48 | UINT64 pos; | |
| 49 | 47 | char *basename_noext; |
| 50 | 48 | |
| 51 | 49 | /* flags */ |
| r936 | r937 | |
| 401 | 399 | { |
| 402 | 400 | /* success! */ |
| 403 | 401 | err = IMAGE_ERROR_SUCCESS; |
| 404 | image->ptr = ptr; | |
| 405 | image->length = header->uncompressed_length; | |
| 402 | core_fopen_ram(ptr, header->uncompressed_length, OPEN_FLAG_READ, &image->file); | |
| 406 | 403 | } |
| 407 | 404 | } |
| 408 | 405 | } |
| r936 | r937 | |
| 441 | 438 | file_extension = strrchr(path, '.'); |
| 442 | 439 | if (!file_extension || mame_stricmp(file_extension, ".zip")) |
| 443 | 440 | { |
| 444 | filerr = o | |
| 441 | filerr = core_fopen(path, open_flags, &image->file | |
| 445 | 442 | |
| 446 | 443 | /* did the open succeed? */ |
| 447 | 444 | switch(filerr) |
| r936 | r937 | |
| 614 | 611 | } |
| 615 | 612 | |
| 616 | 613 | /* verify the file */ |
| 617 | err = image->dev->imgverify(buffer, | |
| 614 | err = image->dev->imgverify(buffer, core_fsize( | |
| 618 | 615 | if (err) |
| 619 | 616 | { |
| 620 | 617 | image->err = IMAGE_ERROR_INVALIDIMAGE; |
| r936 | r937 | |
| 689 | 686 | { |
| 690 | 687 | if (image->file) |
| 691 | 688 | { |
| 692 | o | |
| 689 | core_fclose(image->file); | |
| 693 | 690 | image->file = NULL; |
| 694 | 691 | } |
| 695 | 692 | |
| r936 | r937 | |
| 699 | 696 | image->name = NULL; |
| 700 | 697 | image->dir = NULL; |
| 701 | 698 | image->hash = NULL; |
| 702 | image->length = 0; | |
| 703 | image->pos = 0; | |
| 704 | 699 | image->longname = NULL; |
| 705 | 700 | image->manufacturer = NULL; |
| 706 | 701 | image->year = NULL; |
| r936 | r937 | |
| 1089 | 1084 | |
| 1090 | 1085 | |
| 1091 | 1086 | /*------------------------------------------------- |
| 1087 | image_core_file | |
| 1088 | -------------------------------------------------*/ | |
| 1089 | ||
| 1090 | core_file *image_core_file(mess_image *image) | |
| 1091 | { | |
| 1092 | return image->file; | |
| 1093 | } | |
| 1094 | ||
| 1095 | ||
| 1096 | ||
| 1097 | /*------------------------------------------------- | |
| 1092 | 1098 | image_typename_id |
| 1093 | 1099 | -------------------------------------------------*/ |
| 1094 | 1100 | |
| r936 | r937 | |
| 1109 | 1115 | image_length |
| 1110 | 1116 | -------------------------------------------------*/ |
| 1111 | 1117 | |
| 1112 | UINT64 image_length(mess_image *img) | |
| 1118 | UINT64 image_length(mess_image *image) | |
| 1113 | 1119 | { |
| 1114 | return img->le | |
| 1120 | return core_fsize(image->file) | |
| 1115 | 1121 | } |
| 1116 | 1122 | |
| 1117 | 1123 | |
| r936 | r937 | |
| 1185 | 1191 | |
| 1186 | 1192 | UINT32 image_fread(mess_image *image, void *buffer, UINT32 length) |
| 1187 | 1193 | { |
| 1188 | length = MIN(length, image->length - image->pos); | |
| 1189 | ||
| 1190 | if (image->file) | |
| 1191 | osd_read(image->file, buffer, image->pos, length, &length); | |
| 1192 | else if (image->ptr) | |
| 1193 | memcpy(buffer, ((UINT8 *) image->ptr) + image->pos, length); | |
| 1194 | else | |
| 1195 | length = 0; | |
| 1196 | ||
| 1197 | image->pos += length; | |
| 1198 | return length; | |
| 1194 | return core_fread(image->file, buffer, length); | |
| 1199 | 1195 | } |
| 1200 | 1196 | |
| 1201 | 1197 | |
| r936 | r937 | |
| 1206 | 1202 | |
| 1207 | 1203 | UINT32 image_fwrite(mess_image *image, const void *buffer, UINT32 length) |
| 1208 | 1204 | { |
| 1209 | /* if we are not associated with a file, clip the length */ | |
| 1210 | if (!image->file) | |
| 1211 | length = MIN(length, image->length - image->pos); | |
| 1212 | ||
| 1213 | if (image->file) | |
| 1214 | { | |
| 1215 | osd_write(image->file, buffer, image->pos, length, &length); | |
| 1216 | ||
| 1217 | /* since we've written to the file, we may need to invalidate the pointer */ | |
| 1218 | if (image->ptr) | |
| 1219 | { | |
| 1220 | image_freeptr(image, image->ptr); | |
| 1221 | image->ptr = NULL; | |
| 1222 | } | |
| 1223 | } | |
| 1224 | else if (image->ptr) | |
| 1225 | { | |
| 1226 | memcpy(((UINT8 *) image->ptr) + image->pos, buffer, length); | |
| 1227 | } | |
| 1228 | else | |
| 1229 | length = 0; | |
| 1230 | ||
| 1231 | image->pos += length; | |
| 1232 | ||
| 1233 | /* did we grow the file? */ | |
| 1234 | if (image->length < image->pos) | |
| 1235 | image->length = image->pos; | |
| 1236 | ||
| 1237 | /* return */ | |
| 1238 | return length; | |
| 1205 | return core_fwrite(image->file, buffer, length); | |
| 1239 | 1206 | } |
| 1240 | 1207 | |
| 1241 | 1208 | |
| r936 | r937 | |
| 1246 | 1213 | |
| 1247 | 1214 | int image_fseek(mess_image *image, INT64 offset, int whence) |
| 1248 | 1215 | { |
| 1249 | switch(whence) | |
| 1250 | { | |
| 1251 | case SEEK_SET: | |
| 1252 | image->pos = offset; | |
| 1253 | break; | |
| 1254 | case SEEK_CUR: | |
| 1255 | image->pos += offset; | |
| 1256 | break; | |
| 1257 | case SEEK_END: | |
| 1258 | image->pos = image->length + offset; | |
| 1259 | break; | |
| 1260 | } | |
| 1261 | if (image->pos > image->length) | |
| 1262 | image->pos = image->length; | |
| 1263 | return 0; | |
| 1216 | return core_fseek(image->file, offset, whence); | |
| 1264 | 1217 | } |
| 1265 | 1218 | |
| 1266 | 1219 | |
| r936 | r937 | |
| 1271 | 1224 | |
| 1272 | 1225 | UINT64 image_ftell(mess_image *image) |
| 1273 | 1226 | { |
| 1274 | return image-> | |
| 1227 | return core_ftell(image->file); | |
| 1275 | 1228 | } |
| 1276 | 1229 | |
| 1277 | 1230 | |
| r936 | r937 | |
| 1296 | 1249 | |
| 1297 | 1250 | int image_feof(mess_image *image) |
| 1298 | 1251 | { |
| 1299 | return | |
| 1252 | return cor | |
| 1300 | 1253 | } |
| 1301 | 1254 | |
| 1302 | 1255 | |
| r936 | r937 | |
| 1307 | 1260 | |
| 1308 | 1261 | void *image_ptr(mess_image *image) |
| 1309 | 1262 | { |
| 1310 | UINT64 size; | |
| 1311 | UINT64 pos; | |
| 1312 | void *ptr; | |
| 1313 | ||
| 1314 | if (!image->ptr) | |
| 1315 | { | |
| 1316 | /* get the image size; bomb out if too big */ | |
| 1317 | size = image_length(image); | |
| 1318 | if (size != (UINT32) size) | |
| 1319 | return NULL; | |
| 1320 | ||
| 1321 | /* allocate the memory */ | |
| 1322 | ptr = image_malloc(image, (UINT32) size); | |
| 1323 | ||
| 1324 | /* save current position */ | |
| 1325 | pos = image_ftell(image); | |
| 1326 | ||
| 1327 | /* read all data */ | |
| 1328 | image_fseek(image, 0, SEEK_SET); | |
| 1329 | if (image_fread(image, ptr, (UINT32) size) != size) | |
| 1330 | return NULL; | |
| 1331 | ||
| 1332 | /* reset position */ | |
| 1333 | image_fseek(image, pos, SEEK_SET); | |
| 1334 | ||
| 1335 | /* success */ | |
| 1336 | image->ptr = ptr; | |
| 1337 | } | |
| 1338 | return image->ptr; | |
| 1263 | return (void *) core_fbuffer(image->file); | |
| 1339 | 1264 | } |
| 1340 | 1265 | |
| 1341 | 1266 |
| r936 | r937 | |
|---|---|---|
| 165 | 165 | white = Machine->pens[1]; |
| 166 | 166 | pointerelement = allocgfx(&pointerlayout); |
| 167 | 167 | decodegfx(pointerelement, pointermask, 0, 1); |
| 168 | pointerelement->colortable = pointercolortable; | |
| 168 | /* 7-Sep-2007 - After 0.118u5, you cannot revector the color table */ | |
| 169 | /* pointerelement->colortable = pointercolortable; */ | |
| 169 | 170 | pointercolortable[1] = Machine->pens[1]; |
| 170 | 171 | pointercolortable[2] = Machine->pens[0]; |
| 171 | 172 | pointerelement->total_colors = 3; |
| r936 | r937 | |
|---|---|---|
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | 1292 | WRITE8_HANDLER ( gbc_video_w ) { |
| 1293 | static const UINT16 gbc_to_gb_pal[4] = {32767, 21140, 10570, 0}; | |
| 1293 | /* static const UINT16 gbc_to_gb_pal[4] = {32767, 21140, 10570, 0}; */ | |
| 1294 | 1294 | static UINT16 BP = 0, OP = 0; |
| 1295 | 1295 | |
| 1296 | 1296 | switch( offset ) { |
| r936 | r937 | |
| 1319 | 1319 | /* Some GBC games are lazy and still call this */ |
| 1320 | 1320 | if( gbc_mode == GBC_MODE_MONO ) { |
| 1321 | 1321 | update_scanline(); |
| 1322 | Machine->remapped_colortable[0] = gbc_to_gb_pal[(data & 0x03)]; | |
| 1323 | Machine->remapped_colortable[1] = gbc_to_gb_pal[(data & 0x0C) >> 2]; | |
| 1324 | Machine->remapped_colortable[2] = gbc_to_gb_pal[(data & 0x30) >> 4]; | |
| 1325 | Machine->remapped_colortable[3] = gbc_to_gb_pal[(data & 0xC0) >> 6]; | |
| 1322 | /* 7-Sep-2007 - After 0.118u5, you cannot change remapped_colortable */ | |
| 1323 | /* | |
| 1324 | Machine->remapped_colortable[0] = gbc_to_gb_pal[(data & 0x03)]; | |
| 1325 | Machine->remapped_colortable[1] = gbc_to_gb_pal[(data & 0x0C) >> 2]; | |
| 1326 | Machine->remapped_colortable[2] = gbc_to_gb_pal[(data & 0x30) >> 4]; | |
| 1327 | Machine->remapped_colortable[3] = gbc_to_gb_pal[(data & 0xC0) >> 6]; | |
| 1328 | */ | |
| 1326 | 1329 | } |
| 1327 | 1330 | break; |
| 1328 | 1331 | case 0x08: /* OBP0 - GB Object 0 palette */ |
| 1329 | 1332 | if( gbc_mode == GBC_MODE_MONO ) /* Some GBC games are lazy and still call this */ |
| 1330 | 1333 | { |
| 1331 | Machine->remapped_colortable[4] = gbc_to_gb_pal[(data & 0x03)]; | |
| 1332 | Machine->remapped_colortable[5] = gbc_to_gb_pal[(data & 0x0C) >> 2]; | |
| 1333 | Machine->remapped_colortable[6] = gbc_to_gb_pal[(data & 0x30) >> 4]; | |
| 1334 | Machine->remapped_colortable[7] = gbc_to_gb_pal[(data & 0xC0) >> 6]; | |
| 1334 | /* 7-Sep-2007 - After 0.118u5, you cannot change remapped_colortable */ | |
| 1335 | /* | |
| 1336 | Machine->remapped_colortable[4] = gbc_to_gb_pal[(data & 0x03)]; | |
| 1337 | Machine->remapped_colortable[5] = gbc_to_gb_pal[(data & 0x0C) >> 2]; | |
| 1338 | Machine->remapped_colortable[6] = gbc_to_gb_pal[(data & 0x30) >> 4]; | |
| 1339 | Machine->remapped_colortable[7] = gbc_to_gb_pal[(data & 0xC0) >> 6]; | |
| 1340 | */ | |
| 1335 | 1341 | } |
| 1336 | 1342 | break; |
| 1337 | 1343 | case 0x09: /* OBP1 - GB Object 1 palette */ |
| 1338 | 1344 | if( gbc_mode == GBC_MODE_MONO ) /* Some GBC games are lazy and still call this */ |
| 1339 | 1345 | { |
| 1340 | Machine->remapped_colortable[8] = gbc_to_gb_pal[(data & 0x03)]; | |
| 1341 | Machine->remapped_colortable[9] = gbc_to_gb_pal[(data & 0x0C) >> 2]; | |
| 1342 | Machine->remapped_colortable[10] = gbc_to_gb_pal[(data & 0x30) >> 4]; | |
| 1343 | Machine->remapped_colortable[11] = gbc_to_gb_pal[(data & 0xC0) >> 6]; | |
| 1346 | /* 7-Sep-2007 - After 0.118u5, you cannot change remapped_colortable */ | |
| 1347 | /* | |
| 1348 | Machine->remapped_colortable[8] = gbc_to_gb_pal[(data & 0x03)]; | |
| 1349 | Machine->remapped_colortable[9] = gbc_to_gb_pal[(data & 0x0C) >> 2]; | |
| 1350 | Machine->remapped_colortable[10] = gbc_to_gb_pal[(data & 0x30) >> 4]; | |
| 1351 | Machine->remapped_colortable[11] = gbc_to_gb_pal[(data & 0xC0) >> 6]; | |
| 1352 | */ | |
| 1344 | 1353 | } |
| 1345 | 1354 | break; |
| 1346 | 1355 | case 0x11: /* HDMA1 - HBL General DMA - Source High */ |
| r936 | r937 | |
| 1381 | 1390 | break; |
| 1382 | 1391 | case 0x29: /* BCPD - background palette data */ |
| 1383 | 1392 | if( GBCBCPS & 0x1 ) |
| 1384 | Machine->remapped_colortable[(GBCBCPS & 0x3e) >> 1] = ((UINT16)(data & 0x7f) << 8) | BP; | |
| 1393 | { | |
| 1394 | /* 7-Sep-2007 - After 0.118u5, you cannot change remapped_colortable */ | |
| 1395 | /* Machine->remapped_colortable[(GBCBCPS & 0x3e) >> 1] = ((UINT16)(data & 0x7f) << 8) | BP; */ | |
| 1396 | } | |
| 1385 | 1397 | else |
| 1386 | 1398 | BP = data; |
| 1387 | 1399 | if( GBCBCPS & 0x80 ) |
| r936 | r937 | |
| 1394 | 1406 | break; |
| 1395 | 1407 | case 0x2B: /* OCPD - Object palette data */ |
| 1396 | 1408 | if( GBCOCPS & 0x1 ) |
| 1397 | Machine->remapped_colortable[GBC_PAL_OBJ_OFFSET + ((GBCOCPS & 0x3e) >> 1)] = ((UINT16)(data & 0x7f) << 8) | OP; | |
| 1409 | { | |
| 1410 | /* 7-Sep-2007 - After 0.118u5, you cannot change remapped_colortable */ | |
| 1411 | /* Machine->remapped_colortable[GBC_PAL_OBJ_OFFSET + ((GBCOCPS & 0x3e) >> 1)] = ((UINT16)(data & 0x7f) << 8) | OP; */ | |
| 1412 | } | |
| 1398 | 1413 | else |
| 1399 | 1414 | OP = data; |
| 1400 | 1415 | if( GBCOCPS & 0x80 ) |
| r936 | r937 | |
|---|---|---|
| 634 | 634 | INLINE void arcadia_draw_char(mame_bitmap *bitmap, UINT8 *ch, int color, |
| 635 | 635 | int y, int x) |
| 636 | 636 | { |
| 637 | /* 7-Sep-2007 - whomever wrote this crap code was dynamically remapping | |
| 638 | * the color table, a vile gross hack. Doesn't look like this is going | |
| 639 | * to survive the 0.118u5 transition */ | |
| 637 | 640 | int k,b; |
| 638 | 641 | if (arcadia_video.multicolor) { |
| 639 | 642 | int c; |
| 640 | 643 | if (color&0x40) c=arcadia_video.reg.d.pal[1]; |
| 641 | 644 | else c=arcadia_video.reg.d.pal[0]; |
| 642 | Machine->gfx[0]->colortable[1]=Machine->pens[(c>>3)&7]; | |
| 645 | /*Machine->gfx[0]->colortable[1]=Machine->pens[(c>>3)&7];*/ | |
| 643 | 646 | |
| 644 | 647 | if (color&0x80) c=arcadia_video.reg.d.pal[1]; |
| 645 | 648 | else c=arcadia_video.reg.d.pal[0]; |
| 646 | Machine->gfx[0]->colortable[0]=Machine->pens[c&7]; | |
| 649 | /*Machine->gfx[0]->colortable[0]=Machine->pens[c&7];*/ | |
| 647 | 650 | |
| 648 | 651 | } else { |
| 649 | Machine->gfx[0]->colortable[1]= | |
| 650 | Machine->pens[((arcadia_video.reg.d.pal[1]>>3)&1)|((color>>5)&6)]; | |
| 652 | /*Machine->gfx[0]->colortable[1]= | |
| 653 | Machine->pens[((arcadia_video.reg.d.pal[1]>>3)&1)|((color>>5)&6)];*/ | |
| 651 | 654 | } |
| 652 | 655 | |
| 653 | 656 | if (arcadia_video.doublescan) { |
| r936 | r937 | |
| 688 | 691 | h=arcadia_video.doublescan?16:8; |
| 689 | 692 | |
| 690 | 693 | if (bitmap->height-arcadia_video.line<h) h=bitmap->height-arcadia_video.line; |
| 691 | plot_box(bitmap, 0, y, bitmap->width, h, Machine->gfx[0]->color | |
| 694 | plot_box(bitmap, 0, y, bitmap->width, h, Machine->remapped_colortable[Machine->gfx[0]->color_ | |
| 692 | 695 | memset(arcadia_video.bg[y], 0, sizeof(arcadia_video.bg[0])*h); |
| 693 | 696 | for (x=XPOS+arcadia_video.shift, j=0; j<16;j++,x+=8) { |
| 694 | 697 | ch=chars1[j]; |
| r936 | r937 | |
| 742 | 745 | if (arcadia_video.pos[i].x<=-XPOS) continue; |
| 743 | 746 | if (arcadia_video.pos[i].x>=128+XPOS-8) continue; |
| 744 | 747 | |
| 748 | /* 7-Sep-2007 - whomever wrote this crap code was dynamically remapping | |
| 749 | * the color table, a vile gross hack. Doesn't look like this is going | |
| 750 | * to survive the 0.118u5 transition */ | |
| 745 | 751 | switch (i) { |
| 746 | 752 | case 0: |
| 747 | Machine->gfx[0]->colortable[1]=Machine->pens[(arcadia_video.reg.d.pal[3]>>3)&7]; | |
| 753 | /*Machine->gfx[0]->colortable[1]=Machine->pens[(arcadia_video.reg.d.pal[3]>>3)&7];*/ | |
| 748 | 754 | doublescan=arcadia_video.reg.d.pal[3]&0x80?FALSE:TRUE; |
| 749 | 755 | break; |
| 750 | 756 | case 1: |
| 751 | Machine->gfx[0]->colortable[1]=Machine->pens[arcadia_video.reg.d.pal[3]&7]; | |
| 757 | /*Machine->gfx[0]->colortable[1]=Machine->pens[arcadia_video.reg.d.pal[3]&7];*/ | |
| 752 | 758 | doublescan=arcadia_video.reg.d.pal[3]&0x40?FALSE:TRUE; |
| 753 | 759 | break; |
| 754 | 760 | case 2: |
| 755 | Machine->gfx[0]->colortable[1]=Machine->pens[(arcadia_video.reg.d.pal[2]>>3)&7]; | |
| 761 | /*Machine->gfx[0]->colortable[1]=Machine->pens[(arcadia_video.reg.d.pal[2]>>3)&7];*/ | |
| 756 | 762 | doublescan=arcadia_video.reg.d.pal[2]&0x80?FALSE:TRUE; |
| 757 | 763 | break; |
| 758 | 764 | case 3: |
| 759 | Machine->gfx[0]->colortable[1]=Machine->pens[arcadia_video.reg.d.pal[2]&7]; | |
| 765 | /*Machine->gfx[0]->colortable[1]=Machine->pens[arcadia_video.reg.d.pal[2]&7];*/ | |
| 760 | 766 | doublescan=arcadia_video.reg.d.pal[2]&0x40?FALSE:TRUE; |
| 761 | 767 | break; |
| 762 | 768 | } |
| r936 | r937 | |
| 803 | 809 | // unbelievable, reflects only charline, but alien invaders uses it for |
| 804 | 810 | // alien scrolling |
| 805 | 811 | |
| 806 | Machine->gfx[0]->colortable[0]=Machine->pens[arcadia_video.reg.d.pal[1]&7]; | |
| 812 | /* 7-Sep-2007 - whomever wrote this crap code was dynamically remapping | |
| 813 | * the color table, a vile gross hack. Doesn't look like this is going | |
| 814 | * to survive the 0.118u5 transition */ | |
| 815 | /*Machine->gfx[0]->colortable[0]=Machine->pens[arcadia_video.reg.d.pal[1]&7];*/ | |
| 807 | 816 | |
| 808 | 817 | if (arcadia_video.line<arcadia_video.ypos) |
| 809 | 818 | { |
| 810 | plot_box(arcadia_video.bitmap, 0, arcadia_video.line, Machine->screen[0].width, 1, Machine->gfx[0]->color | |
| 819 | plot_box(arcadia_video.bitmap, 0, arcadia_video.line, Machine->screen[0].width, 1, Machine->remapped_colortable[Machine->gfx[0]->color_ | |
| 811 | 820 | memset(arcadia_video.bg[arcadia_video.line], 0, sizeof(arcadia_video.bg[0])); |
| 812 | 821 | } |
| 813 | 822 | else |
| r936 | r937 | |
| 835 | 844 | else |
| 836 | 845 | { |
| 837 | 846 | arcadia_video.charline=0xd; |
| 838 | plot_box(arcadia_video.bitmap, 0, arcadia_video.line, Machine->screen[0].width, 1, Machine->gfx[0]->color | |
| 847 | plot_box(arcadia_video.bitmap, 0, arcadia_video.line, Machine->screen[0].width, 1, Machine->remapped_colortable[Machine->gfx[0]->color_ | |
| 839 | 848 | memset(arcadia_video.bg[arcadia_video.line], 0, sizeof(arcadia_video.bg[0])); |
| 840 | 849 | } |
| 841 | 850 | } |
| r936 | r937 | |
|---|---|---|
| 862 | 862 | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| 863 | 863 | Machine->gfx[gfx_index] = allocgfx(&x68k_pcg_8); |
| 864 | 864 | decodegfx(Machine->gfx[gfx_index] , memory_region(REGION_USER1), 0, 256); |
| 865 | Machine->gfx[gfx_index]->colortable = (Machine->remapped_colortable+0x100); | |
| 865 | /* 7-Sep-2007 - After 0.118u5, you cannot change the colortable */ | |
| 866 | /* Machine->gfx[gfx_index]->colortable = (Machine->remapped_colortable+0x100); */ | |
| 866 | 867 | Machine->gfx[gfx_index]->total_colors = 16; |
| 867 | 868 | |
| 868 | 869 | gfx_index++; |
| 869 | 870 | |
| 870 | 871 | Machine->gfx[gfx_index] = allocgfx(&x68k_pcg_16); |
| 871 | 872 | decodegfx(Machine->gfx[gfx_index] , memory_region(REGION_USER1), 0, 256); |
| 872 | Machine->gfx[gfx_index]->colortable = (Machine->remapped_colortable+0x100); | |
| 873 | /* 7-Sep-2007 - After 0.118u5, you cannot change the colortable */ | |
| 874 | /* Machine->gfx[gfx_index]->colortable = (Machine->remapped_colortable+0x100); */ | |
| 873 | 875 | Machine->gfx[gfx_index]->total_colors = 16; |
| 874 | 876 | |
| 875 | 877 | /* Tilemaps */ |
| r936 | r937 | |
|---|---|---|
| 510 | 510 | |
| 511 | 511 | if (height > 8) |
| 512 | 512 | { |
| 513 | bgcolor = | |
| 513 | bgcolor = Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (attr % gfx->total_colors)]; | |
| 514 | 514 | plot_box(bitmap, r->min_x, r->min_y + 8, width, height - 8, bgcolor); |
| 515 | 515 | } |
| 516 | 516 | } |
| r936 | r937 | |
|---|---|---|
| 131 | 131 | avigo_video_memory = auto_malloc(((AVIGO_SCREEN_WIDTH>>3)*AVIGO_SCREEN_HEIGHT)); |
| 132 | 132 | Machine->gfx[0] = stylus_pointer = allocgfx(&pointerlayout); |
| 133 | 133 | decodegfx(stylus_pointer, pointermask, 0, 1); |
| 134 | stylus_pointer->colortable = stylus_color_table; | |
| 134 | /* 7-Sep-2007 - After 0.118u5, you cannot revector the color table */ | |
| 135 | /*stylus_pointer->colortable = stylus_color_table;*/ | |
| 135 | 136 | stylus_pointer->total_colors = 3; |
| 136 | 137 | stylus_color_table[1] = Machine->pens[0]; |
| 137 | 138 | stylus_color_table[2] = Machine->pens[1]; |
| r936 | r937 | |
|---|---|---|
| 423 | 423 | int offset = ptr | ((color & 1) << 8); |
| 424 | 424 | |
| 425 | 425 | offset=(offset + (y >> 1)) & 0x1ff; |
| 426 | Machine->gfx[0]->colortable[1]=Machine->pens[16 + ((color & 0xe) >> 1)]; | |
| 426 | /* 7-Sep-2007 - whomever wrote this crap code was dynamically remapping | |
| 427 | * the color table, a vile gross hack. Doesn't look like this is going | |
| 428 | * to survive the 0.118u5 transition */ | |
| 429 | /* Machine->gfx[0]->colortable[1]=Machine->pens[16 + ((color & 0xe) >> 1)]; */ | |
| 427 | 430 | |
| 428 | 431 | // don't ask me about the technical background, but also this height thingy is needed |
| 429 | 432 | // invaders aliens (!) and shoot (-) |
| r936 | r937 | |
| 485 | 488 | |
| 486 | 489 | for (i=0; i<ARRAY_LENGTH(o2_vdc.s.sprites); i++) |
| 487 | 490 | { |
| 488 | Machine->gfx[0]->colortable[1]=Machine->pens[16+((o2_vdc.s.sprites[i].color>>3)&7)]; | |
| 491 | /* 7-Sep-2007 - whomever wrote this crap code was dynamically remapping | |
| 492 | * the color table, a vile gross hack. Doesn't look like this is going | |
| 493 | * to survive the 0.118u5 transition */ | |
| 494 | /* Machine->gfx[0]->colortable[1]=Machine->pens[16+((o2_vdc.s.sprites[i].color>>3)&7)]; */ | |
| 489 | 495 | |
| 490 | 496 | y=o2_vdc.s.sprites[i].y; |
| 491 | 497 | x=o2_vdc.s.sprites[i].x; |
| r936 | r937 | |
|---|---|---|
| 950 | 950 | { |
| 951 | 951 | cursorelement = allocgfx(&cursorlayout); |
| 952 | 952 | decodegfx(cursorelement, cursormask, 0, 1); |
| 953 | cursorelement->colortable = cursorcolortable; | |
| 953 | /* 7-Sep-2007 - After 0.118u5, you cannot revector the color table */ | |
| 954 | /* cursorelement->colortable = cursorcolortable; */ | |
| 954 | 955 | cursorcolortable[1] = Machine->pens[1]; |
| 955 | 956 | cursorelement->total_colors = 2; |
| 956 | 957 | ted7360_bitmap = auto_bitmap_alloc(Machine->screen[0].width, Machine->screen[0].height, BITMAP_FORMAT_INDEXED16); |
| r936 | r937 | |
|---|---|---|
| 433 | 433 | { |
| 434 | 434 | vc4000_draw_grid(collision); |
| 435 | 435 | |
| 436 | Machine->gfx[0]->colortable[1]=Machine->pens[8|((vc4000_video.reg.d.sprite_colors[0]>>3)&7)]; | |
| 436 | /* 7-Sep-2007 - whomever wrote this crap code was dynamically remapping | |
| 437 | * the color table, a vile gross hack. Doesn't look like this is going | |
| 438 | * to survive the 0.118u5 transition */ | |
| 439 | /* Machine->gfx[0]->colortable[1]=Machine->pens[8|((vc4000_video.reg.d.sprite_colors[0]>>3)&7)]; */ | |
| 437 | 440 | vc4000_sprite_update(vc4000_video.bitmap, collision, &vc4000_video.sprites[0]); |
| 438 | Machine->gfx[0]->colortable[1]=Machine->pens[8|(vc4000_video.reg.d.sprite_colors[0]&7)]; | |
| 441 | /* Machine->gfx[0]->colortable[1]=Machine->pens[8|(vc4000_video.reg.d.sprite_colors[0]&7)]; */ | |
| 439 | 442 | vc4000_sprite_update(vc4000_video.bitmap, collision, &vc4000_video.sprites[1]); |
| 440 | Machine->gfx[0]->colortable[1]=Machine->pens[8|((vc4000_video.reg.d.sprite_colors[1]>>3)&7)]; | |
| 443 | /* Machine->gfx[0]->colortable[1]=Machine->pens[8|((vc4000_video.reg.d.sprite_colors[1]>>3)&7)]; */ | |
| 441 | 444 | vc4000_sprite_update(vc4000_video.bitmap, collision, &vc4000_video.sprites[2]); |
| 442 | Machine->gfx[0]->colortable[1]=Machine->pens[8|(vc4000_video.reg.d.sprite_colors[1]&7)]; | |
| 445 | /* Machine->gfx[0]->colortable[1]=Machine->pens[8|(vc4000_video.reg.d.sprite_colors[1]&7)]; */ | |
| 443 | 446 | vc4000_sprite_update(vc4000_video.bitmap, collision, &vc4000_video.sprites[3]); |
| 444 | 447 | |
| 445 | 448 | for (i=0; i<256; i++) |
| r936 | r937 | |
|---|---|---|
| 105 | 105 | int image_exists(mess_image *image); |
| 106 | 106 | int image_slotexists(mess_image *image); |
| 107 | 107 | |
| 108 | core_file *image_core_file(mess_image *image); | |
| 108 | 109 | const char *image_typename_id(mess_image *image); |
| 109 | 110 | const char *image_filename(mess_image *image); |
| 110 | 111 | const char *image_basename(mess_image *image); |
| r936 | r937 | |
|---|---|---|
| 796 | 796 | } |
| 797 | 797 | if (sgb_bytecount == (sgb_packets << 4) ) |
| 798 | 798 | { |
| 799 | /* 7-Sep-2007 - After 0.118u5, you cannot change remapped_colortable */ | |
| 799 | 800 | switch( sgb_data[0] >> 3 ) |
| 800 | 801 | { |
| 801 | 802 | case 0x00: /* PAL01 */ |
| 803 | /* | |
| 802 | 804 | Machine->remapped_colortable[0*4 + 0] = sgb_data[1] | (sgb_data[2] << 8); |
| 803 | 805 | Machine->remapped_colortable[0*4 + 1] = sgb_data[3] | (sgb_data[4] << 8); |
| 804 | 806 | Machine->remapped_colortable[0*4 + 2] = sgb_data[5] | (sgb_data[6] << 8); |
| r936 | r937 | |
| 807 | 809 | Machine->remapped_colortable[1*4 + 1] = sgb_data[9] | (sgb_data[10] << 8); |
| 808 | 810 | Machine->remapped_colortable[1*4 + 2] = sgb_data[11] | (sgb_data[12] << 8); |
| 809 | 811 | Machine->remapped_colortable[1*4 + 3] = sgb_data[13] | (sgb_data[14] << 8); |
| 812 | */ | |
| 810 | 813 | break; |
| 811 | 814 | case 0x01: /* PAL23 */ |
| 815 | /* | |
| 812 | 816 | Machine->remapped_colortable[2*4 + 0] = sgb_data[1] | (sgb_data[2] << 8); |
| 813 | 817 | Machine->remapped_colortable[2*4 + 1] = sgb_data[3] | (sgb_data[4] << 8); |
| 814 | 818 | Machine->remapped_colortable[2*4 + 2] = sgb_data[5] | (sgb_data[6] << 8); |
| r936 | r937 | |
| 817 | 821 | Machine->remapped_colortable[3*4 + 1] = sgb_data[9] | (sgb_data[10] << 8); |
| 818 | 822 | Machine->remapped_colortable[3*4 + 2] = sgb_data[11] | (sgb_data[12] << 8); |
| 819 | 823 | Machine->remapped_colortable[3*4 + 3] = sgb_data[13] | (sgb_data[14] << 8); |
| 824 | */ | |
| 820 | 825 | break; |
| 821 | 826 | case 0x02: /* PAL03 */ |
| 827 | /* | |
| 822 | 828 | Machine->remapped_colortable[0*4 + 0] = sgb_data[1] | (sgb_data[2] << 8); |
| 823 | 829 | Machine->remapped_colortable[0*4 + 1] = sgb_data[3] | (sgb_data[4] << 8); |
| 824 | 830 | Machine->remapped_colortable[0*4 + 2] = sgb_data[5] | (sgb_data[6] << 8); |
| r936 | r937 | |
| 827 | 833 | Machine->remapped_colortable[3*4 + 1] = sgb_data[9] | (sgb_data[10] << 8); |
| 828 | 834 | Machine->remapped_colortable[3*4 + 2] = sgb_data[11] | (sgb_data[12] << 8); |
| 829 | 835 | Machine->remapped_colortable[3*4 + 3] = sgb_data[13] | (sgb_data[14] << 8); |
| 836 | */ | |
| 830 | 837 | break; |
| 831 | 838 | case 0x03: /* PAL12 */ |
| 839 | /* | |
| 832 | 840 | Machine->remapped_colortable[1*4 + 0] = sgb_data[1] | (sgb_data[2] << 8); |
| 833 | 841 | Machine->remapped_colortable[1*4 + 1] = sgb_data[3] | (sgb_data[4] << 8); |
| 834 | 842 | Machine->remapped_colortable[1*4 + 2] = sgb_data[5] | (sgb_data[6] << 8); |
| r936 | r937 | |
| 837 | 845 | Machine->remapped_colortable[2*4 + 1] = sgb_data[9] | (sgb_data[10] << 8); |
| 838 | 846 | Machine->remapped_colortable[2*4 + 2] = sgb_data[11] | (sgb_data[12] << 8); |
| 839 | 847 | Machine->remapped_colortable[2*4 + 3] = sgb_data[13] | (sgb_data[14] << 8); |
| 848 | */ | |
| 840 | 849 | break; |
| 841 | 850 | case 0x04: /* ATTR_BLK */ |
| 842 | 851 | { |
| r936 | r937 | |
| 1035 | 1044 | case 0x0A: /* PAL_SET */ |
| 1036 | 1045 | { |
| 1037 | 1046 | UINT16 index_, J, I; |
| 1047 | /* 7-Sep-2007 - After 0.118u5, you cannot change remapped_colortable */ | |
| 1038 | 1048 | |
| 1039 | 1049 | /* Palette 0 */ |
| 1040 | 1050 | index_ = (UINT16)(sgb_data[1] | (sgb_data[2] << 8)) * 4; |
| 1041 | Machine->remapped_colortable[0] = sgb_pal_data[index_]; | |
| 1042 | Machine->remapped_colortable[1] = sgb_pal_data[index_ + 1]; | |
| 1043 | Machine->remapped_colortable[2] = sgb_pal_data[index_ + 2]; | |
| 1044 | Machine->remapped_colortable[3] = sgb_pal_data[index_ + 3]; | |
| 1051 | /* | |
| 1052 | Machine->remapped_colortable[0] = sgb_pal_data[index_]; | |
| 1053 | Machine->remapped_colortable[1] = sgb_pal_data[index_ + 1]; | |
| 1054 | Machine->remapped_colortable[2] = sgb_pal_data[index_ + 2]; | |
| 1055 | Machine->remapped_colortable[3] = sgb_pal_data[index_ + 3]; | |
| 1056 | */ | |
| 1045 | 1057 | /* Palette 1 */ |
| 1046 | 1058 | index_ = (UINT16)(sgb_data[3] | (sgb_data[4] << 8)) * 4; |
| 1047 | Machine->remapped_colortable[4] = sgb_pal_data[index_]; | |
| 1048 | Machine->remapped_colortable[5] = sgb_pal_data[index_ + 1]; | |
| 1049 | Machine->remapped_colortable[6] = sgb_pal_data[index_ + 2]; | |
| 1050 | Machine->remapped_colortable[7] = sgb_pal_data[index_ + 3]; | |
| 1059 | /* | |
| 1060 | Machine->remapped_colortable[4] = sgb_pal_data[index_]; | |
| 1061 | Machine->remapped_colortable[5] = sgb_pal_data[index_ + 1]; | |
| 1062 | Machine->remapped_colortable[6] = sgb_pal_data[index_ + 2]; | |
| 1063 | Machine->remapped_colortable[7] = sgb_pal_data[index_ + 3]; | |
| 1064 | */ | |
| 1051 | 1065 | /* Palette 2 */ |
| 1052 | 1066 | index_ = (UINT16)(sgb_data[5] | (sgb_data[6] << 8)) * 4; |
| 1053 | Machine->remapped_colortable[8] = sgb_pal_data[index_]; | |
| 1054 | Machine->remapped_colortable[9] = sgb_pal_data[index_ + 1]; | |
| 1055 | Machine->remapped_colortable[10] = sgb_pal_data[index_ + 2]; | |
| 1056 | Machine->remapped_colortable[11] = sgb_pal_data[index_ + 3]; | |
| 1067 | /* | |
| 1068 | Machine->remapped_colortable[8] = sgb_pal_data[index_]; | |
| 1069 | Machine->remapped_colortable[9] = sgb_pal_data[index_ + 1]; | |
| 1070 | Machine->remapped_colortable[10] = sgb_pal_data[index_ + 2]; | |
| 1071 | Machine->remapped_colortable[11] = sgb_pal_data[index_ + 3]; | |
| 1072 | */ | |
| 1057 | 1073 | /* Palette 3 */ |
| 1058 | 1074 | index_ = (UINT16)(sgb_data[7] | (sgb_data[8] << 8)) * 4; |
| 1059 | Machine->remapped_colortable[12] = sgb_pal_data[index_]; | |
| 1060 | Machine->remapped_colortable[13] = sgb_pal_data[index_ + 1]; | |
| 1061 | Machine->remapped_colortable[14] = sgb_pal_data[index_ + 2]; | |
| 1062 | Machine->remapped_colortable[15] = sgb_pal_data[index_ + 3]; | |
| 1075 | /* | |
| 1076 | Machine->remapped_colortable[12] = sgb_pal_data[index_]; | |
| 1077 | Machine->remapped_colortable[13] = sgb_pal_data[index_ + 1]; | |
| 1078 | Machine->remapped_colortable[14] = sgb_pal_data[index_ + 2]; | |
| 1079 | Machine->remapped_colortable[15] = sgb_pal_data[index_ + 3]; | |
| 1080 | */ | |
| 1063 | 1081 | /* Attribute File */ |
| 1064 | 1082 | if( sgb_data[9] & 0x40 ) |
| 1065 | 1083 | sgb_window_mask = 0; |
| r936 | r937 | |
| 1132 | 1150 | { |
| 1133 | 1151 | col = program_read_byte_8 (0x8800 + (I*2)); |
| 1134 | 1152 | col |= (UINT16)(program_read_byte_8 (0x8800 + (I*2) + 1)) << 8; |
| 1135 | Machine->remapped_colortable[SGB_BORDER_PAL_OFFSET + I] = col; | |
| 1153 | /* 7-Sep-2007 - After 0.118u5, you cannot change remapped_colortable */ | |
| 1154 | /* Machine->remapped_colortable[SGB_BORDER_PAL_OFFSET + I] = col; */ | |
| 1136 | 1155 | } |
| 1137 | 1156 | } |
| 1138 | 1157 | else /* Do things normally */ |
| r936 | r937 | |
| 1142 | 1161 | { |
| 1143 | 1162 | col = program_read_byte_8 (0x9000 + (I*2)); |
| 1144 | 1163 | col |= (UINT16)(program_read_byte_8 (0x9000 + (I*2) + 1)) << 8; |
| 1145 | Machine->remapped_colortable[SGB_BORDER_PAL_OFFSET + I] = col; | |
| 1164 | /* 7-Sep-2007 - After 0.118u5, you cannot change remapped_colortable */ | |
| 1165 | /* Machine->remapped_colortable[SGB_BORDER_PAL_OFFSET + I] = col; */ | |
| 1146 | 1166 | } |
| 1147 | 1167 | } |
| 1148 | 1168 | } |
| r936 | r937 | |
|---|---|---|
| 177 | 177 | #CPUS += M37702 |
| 178 | 178 | #CPUS += M37710 |
| 179 | 179 | #CPUS += PPC403 |
| 180 | #CPUS += PPC601 | |
| 180 | 181 | #CPUS += PPC602 |
| 181 | 182 | CPUS += PPC603 |
| 182 | 183 | #CPUS += MPC8240 |
| r936 | r937 | |
|---|---|---|
| 60 | 60 | |
| 61 | 61 | Source Changes: |
| 62 | 62 | ---------------- |
| 63 | - The core is based on MAME 0.118u | |
| 63 | - The core is based on MAME 0.118u5. This incorporates all features of the | |
| 64 | 64 | update to this core. [MAME team] |
| 65 | 65 | |
| 66 | 66 |
| Previous | 15994 Revisions | Next |