本文整理汇总了C++中running_machine::rand方法的典型用法代码示例。如果您正苦于以下问题:C++ running_machine::rand方法的具体用法?C++ running_machine::rand怎么用?C++ running_machine::rand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类running_machine
的用法示例。
在下文中一共展示了running_machine::rand方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawCrt
static void drawCrt( running_machine &machine, bitmap_rgb32 &bitmap,const rectangle &cliprect )
{
dwarfd_state *state = machine.driver_data<dwarfd_state>();
int x, y;
for (y = 0; y < maxy; y++)
{
int count = y * 256;
int bank2 = 4;
if (y < TOPLINE || y > BOTTOMLINE)
{
bank2 = 0;
}
for (x = 0; x < maxx; x++)
{
int tile = 0;
int b = 0; //end marker
while (b == 0)
{
if (count < 0x8000)
tile = state->m_videobuf[count++];
else
return;
if (tile & 0x80)
{
if ((tile & 0xfc) == 0xf0)
{
switch (tile & 3)
{
case 0:
case 1: break;
case 2:
case 3: return;
}
}
if ((tile & 0xc0) == 0x80)
{
state->m_bank = (tile >> 2) & 3;
}
if ((tile & 0xc0) == 0xc0)
{
b = 1;
tile = machine.rand() & 0x7f;//(tile >> 2) & 0xf;
}
}
else
b = 1;
}
drawgfx_transpen(bitmap, cliprect, machine.gfx[0],
tile + (state->m_bank + bank2) * 128,
0,
0, 0,
x*8,y*8,0);
}
示例2: spacewar_sound_w
static void spacewar_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed)
{
samples_device *samples = machine.device<samples_device>("samples");
/* Explosion - rising edge */
if (SOUNDVAL_RISING_EDGE(0x01))
samples->start(0, (machine.rand() & 1) ? 0 : 6);
/* Fire sound - rising edge */
if (SOUNDVAL_RISING_EDGE(0x02))
samples->start(1, (machine.rand() & 1) ? 1 : 7);
/* Player 1 thrust - 0=on, 1=off */
if (SOUNDVAL_FALLING_EDGE(0x04))
samples->start(3, 3, true);
if (SOUNDVAL_RISING_EDGE(0x04))
samples->stop(3);
/* Player 2 thrust - 0=on, 1-off */
if (SOUNDVAL_FALLING_EDGE(0x08))
samples->start(4, 4, true);
if (SOUNDVAL_RISING_EDGE(0x08))
samples->stop(4);
/* Mute - 0=off, 1=on */
if (SOUNDVAL_FALLING_EDGE(0x10))
samples->start(2, 2, true); /* play idle sound */
if (SOUNDVAL_RISING_EDGE(0x10))
{
int i;
/* turn off all but the idle sound */
for (i = 0; i < 5; i++)
if (i != 2)
samples->stop(i);
/* Pop when board is shut off */
samples->start(2, 5);
}
}
示例3: cojag_sound_init
void cojag_sound_init(running_machine &machine)
{
int i;
/* fill the wave ROM -- these are pretty cheesy guesses */
for (i = 0; i < 0x80; i++)
{
/* F1D000 = triangle wave */
jaguar_wave_rom[0x000 + i] = ((i <= 0x40) ? i : 0x80 - i) * 32767 / 0x40;
/* F1D200 = full sine wave */
jaguar_wave_rom[0x080 + i] = (int)(32767. * sin(2.0 * M_PI * (double)i / (double)0x80));
/* F1D400 = amplitude modulated sine wave? */
jaguar_wave_rom[0x100 + i] = (int)(32767. * sin(2.0 * M_PI * (double)i / (double)0x80));
/* F1D600 = sine wave and second order harmonic */
jaguar_wave_rom[0x180 + i] = (int)(32767. * sin(2.0 * M_PI * (double)i / (double)0x80));
/* F1D800 = chirp (sine wave of increasing frequency) */
jaguar_wave_rom[0x200 + i] = (int)(32767. * sin(2.0 * M_PI * (double)i / (double)0x80));
/* F1DA00 = traingle wave with noise */
jaguar_wave_rom[0x280 + i] = jaguar_wave_rom[0x000 + i] * (machine.rand() % 32768) / 32768;
/* F1DC00 = spike */
jaguar_wave_rom[0x300 + i] = (i == 0x40) ? 32767 : 0;
/* F1DE00 = white noise */
jaguar_wave_rom[0x380 + i] = machine.rand() % 32768;
}
#if ENABLE_SPEEDUP_HACKS
if (jaguar_hacks_enabled)
machine.device("audiocpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0xf1a100, 0xf1a103, FUNC(dsp_flags_w));
#endif
}
示例4:
static void f1gp2_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
{
f1gp_state *state = machine.driver_data<f1gp_state>();
int offs;
offs = 0;
while (offs < 0x0400 && (state->m_spritelist[offs] & 0x4000) == 0)
{
int attr_start;
int map_start;
int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color;
attr_start = 4 * (state->m_spritelist[offs++] & 0x01ff);
ox = state->m_spritelist[attr_start + 1] & 0x01ff;
xsize = (state->m_spritelist[attr_start + 1] & 0x0e00) >> 9;
zoomx = (state->m_spritelist[attr_start + 1] & 0xf000) >> 12;
oy = state->m_spritelist[attr_start + 0] & 0x01ff;
ysize = (state->m_spritelist[attr_start + 0] & 0x0e00) >> 9;
zoomy = (state->m_spritelist[attr_start + 0] & 0xf000) >> 12;
flipx = state->m_spritelist[attr_start + 2] & 0x4000;
flipy = state->m_spritelist[attr_start + 2] & 0x8000;
color = (state->m_spritelist[attr_start + 2] & 0x1f00) >> 8;
map_start = state->m_spritelist[attr_start + 3] & 0x7fff;
// aerofgt has the following adjustment, but doing it here would break the title screen
// ox += (xsize*zoomx+2)/4;
// oy += (ysize*zoomy+2)/4;
zoomx = 32 - zoomx;
zoomy = 32 - zoomy;
if (state->m_spritelist[attr_start + 2] & 0x20ff)
color = machine.rand();
for (y = 0; y <= ysize; y++)
{
int sx,sy;
if (flipy) sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
else sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
for (x = 0; x <= xsize; x++)
{
int code;
if (flipx) sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16;
else sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
code = state->m_sprcgram[map_start & 0x3fff];
map_start++;
if (state->m_flipscreen)
drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[1],
code,
color,
!flipx,!flipy,
304-sx,208-sy,
zoomx << 11,zoomy << 11,15);
else
drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[1],
code,
color,
flipx,flipy,
sx,sy,
zoomx << 11,zoomy << 11,15);
}
}
}
}
示例5: printf
static void f1gpb_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect )
{
f1gp_state *state = machine.driver_data<f1gp_state>();
UINT16 *spriteram = state->m_spriteram;
int attr_start, start_offset = state->m_spriteram_size / 2 - 4;
// find the "end of list" to draw the sprites in reverse order
for (attr_start = 4; attr_start < state->m_spriteram_size / 2; attr_start += 4)
{
if (spriteram[attr_start + 3 - 4] == 0xffff) /* end of list marker */
{
start_offset = attr_start - 4;
break;
}
}
for (attr_start = start_offset;attr_start >= 4;attr_start -= 4)
{
int code, gfx;
int x, y, flipx, flipy, color, pri;
x = (spriteram[attr_start + 2] & 0x03ff) - 48;
y = (256 - (spriteram[attr_start + 3 - 4] & 0x03ff)) - 15;
flipx = spriteram[attr_start + 1] & 0x0800;
flipy = spriteram[attr_start + 1] & 0x8000;
color = spriteram[attr_start + 1] & 0x000f;
code = spriteram[attr_start + 0] & 0x3fff;
pri = 0; //?
if((spriteram[attr_start + 1] & 0x00f0) && (spriteram[attr_start + 1] & 0x00f0) != 0xc0)
{
printf("attr %X\n",spriteram[attr_start + 1] & 0x00f0);
code = machine.rand();
}
/*
if (spriteram[attr_start + 1] & ~0x88cf)
printf("1 = %X\n", spriteram[attr_start + 1] & ~0x88cf);
*/
if(code >= 0x2000)
{
gfx = 1;
code -= 0x2000;
}
else
{
gfx = 0;
}
pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1 + gfx],
code,
color,
flipx,flipy,
x,y,
machine.priority_bitmap,
pri ? 0 : 0x2,15);
// wrap around x
pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1 + gfx],
code,
color,
flipx,flipy,
x - 512,y,
machine.priority_bitmap,
pri ? 0 : 0x2,15);
}
}
示例6: fill_random
static void fill_random(running_machine &machine, UINT8 *base, UINT32 length)
{
while (length--)
*base++ = machine.rand();
}
示例7: LFO_Init
static void LFO_Init(running_machine &machine)
{
int i,s;
for(i=0;i<256;++i)
{
int a,p;
// float TL;
//Saw
a=255-i;
if(i<128)
p=i;
else
p=i-256;
ALFO_SAW[i]=a;
PLFO_SAW[i]=p;
//Square
if(i<128)
{
a=255;
p=127;
}
else
{
a=0;
p=-128;
}
ALFO_SQR[i]=a;
PLFO_SQR[i]=p;
//Tri
if(i<128)
a=255-(i*2);
else
a=(i*2)-256;
if(i<64)
p=i*2;
else if(i<128)
p=255-i*2;
else if(i<192)
p=256-i*2;
else
p=i*2-511;
ALFO_TRI[i]=a;
PLFO_TRI[i]=p;
//noise
//a=lfo_noise[i];
a=machine.rand()&0xff;
p=128-a;
ALFO_NOI[i]=a;
PLFO_NOI[i]=p;
}
for(s=0;s<8;++s)
{
float limit=PSCALE[s];
for(i=-128;i<128;++i)
{
PSCALES[s][i+128]=CENTS(((limit*(float) i)/128.0));
}
limit=-ASCALE[s];
for(i=0;i<256;++i)
{
ASCALES[s][i]=DB(((limit*(float) i)/256.0));
}
}
}
示例8: draw_sprites
static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
{
crshrace_state *state = machine.driver_data<crshrace_state>();
UINT16 *buffered_spriteram = machine.generic.buffered_spriteram.u16;
UINT16 *buffered_spriteram_2 = machine.generic.buffered_spriteram2.u16;
int offs;
offs = 0;
while (offs < 0x0400 && (buffered_spriteram[offs] & 0x4000) == 0)
{
int attr_start;
int map_start;
int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color;
/* table hand made by looking at the ship explosion in aerofgt attract mode */
/* it's almost a logarithmic scale but not exactly */
static const int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
attr_start = 4 * (buffered_spriteram[offs++] & 0x03ff);
ox = buffered_spriteram[attr_start + 1] & 0x01ff;
xsize = (buffered_spriteram[attr_start + 1] & 0x0e00) >> 9;
zoomx = (buffered_spriteram[attr_start + 1] & 0xf000) >> 12;
oy = buffered_spriteram[attr_start + 0] & 0x01ff;
ysize = (buffered_spriteram[attr_start + 0] & 0x0e00) >> 9;
zoomy = (buffered_spriteram[attr_start + 0] & 0xf000) >> 12;
flipx = buffered_spriteram[attr_start + 2] & 0x4000;
flipy = buffered_spriteram[attr_start + 2] & 0x8000;
color = (buffered_spriteram[attr_start + 2] & 0x1f00) >> 8;
map_start = buffered_spriteram[attr_start + 3] & 0x7fff;
zoomx = 16 - zoomtable[zoomx] / 8;
zoomy = 16 - zoomtable[zoomy] / 8;
if (buffered_spriteram[attr_start + 2] & 0x20ff) color = machine.rand();
for (y = 0; y <= ysize; y++)
{
int sx,sy;
if (flipy) sy = ((oy + zoomy * (ysize - y) + 16) & 0x1ff) - 16;
else sy = ((oy + zoomy * y + 16) & 0x1ff) - 16;
for (x = 0; x <= xsize; x++)
{
int code;
if (flipx) sx = ((ox + zoomx * (xsize - x) + 16) & 0x1ff) - 16;
else sx = ((ox + zoomx * x + 16) & 0x1ff) - 16;
code = buffered_spriteram_2[map_start & 0x7fff];
map_start++;
if (state->m_flipscreen)
drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[2],
code,
color,
!flipx,!flipy,
304-sx,208-sy,
0x1000 * zoomx,0x1000 * zoomy,15);
else
drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[2],
code,
color,
flipx,flipy,
sx,sy,
0x1000 * zoomx,0x1000 * zoomy,15);
}
}
}
}