diff --git a/hash/lantutor.xml b/hash/lantutor.xml index a07d3575f93..f62f968eae1 100644 --- a/hash/lantutor.xml +++ b/hash/lantutor.xml @@ -38,8 +38,8 @@ Texas Instruments - - + + diff --git a/hash/pasogo.xml b/hash/pasogo.xml index 11f5223417e..1d756c50043 100644 --- a/hash/pasogo.xml +++ b/hash/pasogo.xml @@ -2,7 +2,7 @@ -? output? to ram multiplexer 'A' pins + * |\----------------->? output? to ram multiplexer 'A' pins * \------------------< ? */ ROM_LOAD( "timing_b.ampal16r4a.u9.jed", 0x0000, 0xb08, CRC(643e6e83) SHA1(7db167883f9d6cf385ce496d08976dc16fc3e2c3)) diff --git a/src/mess/drivers/gamate.c b/src/mess/drivers/gamate.c index cc18fa3ba98..3e0480b3d4f 100644 --- a/src/mess/drivers/gamate.c +++ b/src/mess/drivers/gamate.c @@ -20,7 +20,7 @@ public: : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") , m_cart(*this, "cartslot") -#ifdef USE_GFX +#ifdef USE_GFX , m_gfxdecode(*this, "gfxdecode") #endif , m_io_joy(*this, "JOY") @@ -53,25 +53,25 @@ private: struct { - UINT8 reg[8]; - struct { - bool write; - bool page2; // else page1 + UINT8 reg[8]; + struct { + bool write; + bool page2; // else page1 UINT8 ypos, xpos/*tennis*/; - UINT8 data[2][0x100][0x20]; - } bitmap; - UINT8 x, y; + UINT8 data[2][0x100][0x20]; + } bitmap; + UINT8 x, y; bool y_increment; } video; struct { - bool set; + bool set; int bit_shifter; UINT8 cartridge_byte; UINT16 address; // in reality something more like short local cartridge address offset bool unprotected; bool failed; - + } card_protection; required_device m_maincpu; @@ -84,14 +84,14 @@ private: required_shared_ptr m_bios; emu_timer *timer1; emu_timer *timer2; - UINT8 bank_multi; + UINT8 bank_multi; UINT8 *m_cart_ptr; }; WRITE8_MEMBER( gamate_state::gamate_cart_protection_w ) { - logerror("%.6f protection write %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, data, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter); - + logerror("%.6f protection write %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, data, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter); + switch (offset) { case 0: card_protection.failed= card_protection.failed || ((card_protection.cartridge_byte&0x80)!=0) != ((data&4)!=0); @@ -105,11 +105,10 @@ WRITE8_MEMBER( gamate_state::gamate_cart_protection_w ) } READ8_MEMBER( gamate_state::gamate_cart_protection_r ) { - - UINT8 ret=1; - if (card_protection.bit_shifter==7 && card_protection.unprotected) { - ret=m_cart_ptr[bank_multi*0x4000]; - } else { + UINT8 ret=1; + if (card_protection.bit_shifter==7 && card_protection.unprotected) { + ret=m_cart_ptr[bank_multi*0x4000]; + } else { card_protection.bit_shifter++; if (card_protection.bit_shifter==8) { card_protection.bit_shifter=0; @@ -118,62 +117,62 @@ READ8_MEMBER( gamate_state::gamate_cart_protection_r ) } ret=(card_protection.cartridge_byte&0x80)?2:0; if (card_protection.bit_shifter==7 && !card_protection.failed) { // now protection chip on cartridge activates cartridge chip select on cpu accesses -// m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); // next time I will try to get this working +// m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); // next time I will try to get this working } card_protection.cartridge_byte<<=1; - } - logerror("%.6f protection read %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, ret, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter); - return ret; + } + logerror("%.6f protection read %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, ret, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter); + return ret; } READ8_MEMBER( gamate_state::protection_r ) { return card_protection.set? 3: 1; } // bits 0 and 1 checked WRITE8_MEMBER( gamate_state::protection_reset ) { - // writes 0x20 - card_protection.address=0x6005-0x6001; - card_protection.bit_shifter=0; - card_protection.cartridge_byte=m_cart_ptr[card_protection.address++];//m_cart_rom[card_protection.address++]; - card_protection.failed=false; - card_protection.unprotected=false; + // writes 0x20 + card_protection.address=0x6005-0x6001; + card_protection.bit_shifter=0; + card_protection.cartridge_byte=m_cart_ptr[card_protection.address++];//m_cart_rom[card_protection.address++]; + card_protection.failed=false; + card_protection.unprotected=false; } READ8_MEMBER( gamate_state::newer_protection_set ) { - card_protection.set=true; - return 0; + card_protection.set=true; + return 0; } WRITE8_MEMBER( gamate_state::gamate_video_w ) { - video.reg[offset]=data; - switch (offset) { - case 1: video.bitmap.write=data&0xc0; // more addressing mode + video.reg[offset]=data; + switch (offset) { + case 1: video.bitmap.write=data&0xc0; // more addressing mode video.y_increment=data&0x40; break; case 2: video.bitmap.xpos=data;break; // at least 7 bits case 3: video.bitmap.ypos=data;break; // at least 7 bits - case 4: video.bitmap.page2=data&0x80;video.x=data&0x7f;break; - case 5: video.y=data;break; - case 7: - if (video.bitmap.write) { - if (video.xpc(), video.x); - } else { - video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data; - } - if (video.y_increment) video.y++; + case 4: video.bitmap.page2=data&0x80;video.x=data&0x7f;break; + case 5: video.y=data;break; + case 7: + if (video.bitmap.write) { + if (video.xpc(), video.x); + } else { + video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data; + } + if (video.y_increment) video.y++; else video.x++; - } + } } WRITE8_MEMBER( gamate_state::cart_bankswitchmulti_w ) { - bank_multi=data; - membank("bankmulti")->set_base(m_cart_ptr+0x4000*data+1); + bank_multi=data; + membank("bankmulti")->set_base(m_cart_ptr+0x4000*data+1); } WRITE8_MEMBER( gamate_state::cart_bankswitch_w ) @@ -184,55 +183,55 @@ WRITE8_MEMBER( gamate_state::cart_bankswitch_w ) READ8_MEMBER( gamate_state::gamate_video_r ) { if (offset!=6) return 0; - UINT8 data=0; - if (video.bitmap.write) { - if (video.xpc()<0xf000) - logerror("%.6f video read %04x %02x\n",machine().time().as_double(),offset, data); - return data; + UINT8 data=0; + if (video.bitmap.write) { + if (video.xpc()<0xf000) + logerror("%.6f video read %04x %02x\n",machine().time().as_double(),offset, data); + return data; } WRITE8_MEMBER( gamate_state::gamate_audio_w ) { - logerror("%.6f %04x audio write %04x %02x\n",machine().time().as_double(),m_maincpu->pc(),offset,data); + logerror("%.6f %04x audio write %04x %02x\n",machine().time().as_double(),m_maincpu->pc(),offset,data); } READ8_MEMBER( gamate_state::gamate_audio_r ) { - logerror("%.6f %04x audio read %04x \n",machine().time().as_double(),m_maincpu->pc(),offset); + logerror("%.6f %04x audio read %04x \n",machine().time().as_double(),m_maincpu->pc(),offset); return 0; } READ8_MEMBER( gamate_state::gamate_pad_r ) { - UINT8 data=m_io_joy->read(); - return data; + UINT8 data=m_io_joy->read(); + return data; } static ADDRESS_MAP_START( gamate_mem, AS_PROGRAM, 8, gamate_state ) - AM_RANGE(0x0000, 0x03ff) AM_RAM - AM_RANGE(0x4000, 0x400d) AM_READWRITE(gamate_audio_r, gamate_audio_w) - AM_RANGE(0x4400, 0x4400) AM_READ(gamate_pad_r) - AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w) - AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set) - AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset) - AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r) + AM_RANGE(0x0000, 0x03ff) AM_RAM + AM_RANGE(0x4000, 0x400d) AM_READWRITE(gamate_audio_r, gamate_audio_w) + AM_RANGE(0x4400, 0x4400) AM_READ(gamate_pad_r) + AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w) + AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set) + AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset) + AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r) - AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti") - AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank") + AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti") + AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank") AM_RANGE(0x6000, 0x6000) AM_READWRITE(gamate_cart_protection_r, gamate_cart_protection_w) AM_RANGE(0x8000, 0x8000) AM_WRITE(cart_bankswitchmulti_w) AM_RANGE(0xc000, 0xc000) AM_WRITE(cart_bankswitch_w) - AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios") + AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios") ADDRESS_MAP_END @@ -251,30 +250,30 @@ INPUT_PORTS_END #ifdef USE_GFX static const struct gfx_layout gamate_charlayout = { - 4, /* width of object */ - 1, /* height of object */ - 256,/* 256 characters */ - 2, /* bits per pixel */ - { 0,4 }, /* no bitplanes */ - /* x offsets */ - { 0,1,2,3 }, - /* y offsets */ - { 0 }, - 8*1 /* size of 1 object in bits */ + 4, /* width of object */ + 1, /* height of object */ + 256,/* 256 characters */ + 2, /* bits per pixel */ + { 0,4 }, /* no bitplanes */ + /* x offsets */ + { 0,1,2,3 }, + /* y offsets */ + { 0 }, + 8*1 /* size of 1 object in bits */ }; static GFXDECODE_START( gamate ) - GFXDECODE_ENTRY( "gfx1", 0x0000, gamate_charlayout, 0, 0x100 ) + GFXDECODE_ENTRY( "gfx1", 0x0000, gamate_charlayout, 0, 0x100 ) GFXDECODE_END #endif /* palette in red, green, blue tribles */ static const unsigned char gamate_colors[4][3] = { - { 255,255,255 }, - { 0xa0, 0xa0, 0xa0 }, - { 0x60, 0x60, 0x60 }, - { 0, 0, 0 } + { 255,255,255 }, + { 0xa0, 0xa0, 0xa0 }, + { 0x60, 0x60, 0x60 }, + { 0, 0, 0 } }; PALETTE_INIT_MEMBER(gamate_state, gamate) @@ -299,21 +298,21 @@ static void BlitPlane(UINT16* line, UINT8 plane1, UINT8 plane2) UINT32 gamate_state::screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - int x, y, j; - for (y=0;y<152;y++) { - for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) { - UINT8 d1=video.bitmap.data[0][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f]; - UINT8 d2=video.bitmap.data[1][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f]; + int x, y, j; + for (y=0;y<152;y++) { + for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) { + UINT8 d1=video.bitmap.data[0][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f]; + UINT8 d2=video.bitmap.data[1][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f]; #ifdef USE_GFX - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, (d1&0xf)|((d2&0xf)<<4), 0,0,0,x+4,y); + m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, (d1&0xf)|((d2&0xf)<<4), 0,0,0,x+4,y); m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, (d1>>4)|(d2&0xf0),0,0,0,x,y); #else - BlitPlane(&bitmap.pix16(y, x+4), d1, d2); - BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4); -#endif - } - } - return 0; + BlitPlane(&bitmap.pix16(y, x+4), d1, d2); + BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4); +#endif + } + } + return 0; } DRIVER_INIT_MEMBER(gamate_state,gamate) @@ -322,7 +321,7 @@ DRIVER_INIT_MEMBER(gamate_state,gamate) #ifdef USE_GFX UINT8 *gfx=memregion("gfx1")->base(); for (int i=0; i<256; i++) gfx[i]=i; -#endif +#endif timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gamate_state::gamate_timer),this)); timer2 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gamate_state::gamate_timer2),this)); } @@ -332,12 +331,12 @@ void gamate_state::machine_start() { m_cart_ptr = memregion("maincpu")->base() + 0x6000; if (m_cart->exists()) { -// m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); +// m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); m_cart_ptr = m_cart->get_rom_base(); membank("bankmulti")->set_base(m_cart->get_rom_base()+1); membank("bank")->set_base(m_cart->get_rom_base()+0x4000); // bankswitched games in reality no offset } -// m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // default bios: $47 protection readback +// m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // default bios: $47 protection readback card_protection.set=false; bank_multi=0; card_protection.unprotected=false; @@ -390,7 +389,7 @@ static MACHINE_CONFIG_START( gamate, gamate_state ) #ifdef USE_GFX MCFG_GFXDECODE_ADD("gfxdecode", "palette", gamate ) -#endif +#endif MCFG_PALETTE_ADD("palette", ARRAY_LENGTH(gamate_colors)) MCFG_PALETTE_INIT_OWNER(gamate_state, gamate) MCFG_DEFAULT_LAYOUT(layout_lcd) @@ -408,13 +407,11 @@ ROM_START(gamate) ROMX_LOAD("gamate_bios_umc.bin", 0xf000, 0x1000, CRC(07090415) SHA1(ea449dc607601f9a68d855ad6ab53800d2e99297), ROM_BIOS(1) ) ROM_SYSTEM_BIOS(1, "newer", "NEWER") ROMX_LOAD("gamate_bios_9130__unknown__bit_icasc00001_9130-bs_r32261.bin", 0xf000, 0x1000, CRC(03a5f3a7) SHA1(4e9dfbfe916ca485530ef4221593ab68738e2217), ROM_BIOS(2) ) -#ifdef USE_GFX +#ifdef USE_GFX ROM_REGION(0x100,"gfx1", ROMREGION_ERASEFF) -#endif +#endif ROM_END /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME */ CONS( 19??, gamate, 0, 0, gamate, gamate, gamate_state, gamate, "Bit Corp", "Gamate", GAME_NO_SOUND) - - diff --git a/src/mess/drivers/hp16500.c b/src/mess/drivers/hp16500.c index 158cc05e8a2..ea9f58d37a6 100644 --- a/src/mess/drivers/hp16500.c +++ b/src/mess/drivers/hp16500.c @@ -19,7 +19,7 @@ MC68000 @ 10 MHz MC68A45 CRTC Z0765A08PSC floppy controller (NEC765 type) - TMS9914A GPIB bus interface + TMS9914A GPIB bus interface SCN2661 DUART/timer 16500b: @@ -50,10 +50,10 @@ #include "video/mc6845.h" #include "machine/mc68681.h" -#define MAINCPU_TAG "maincpu" -#define CRTC_TAG "crtc" -#define SCREEN_TAG "screen" -#define DUART_TAG "duart" +#define MAINCPU_TAG "maincpu" +#define CRTC_TAG "crtc" +#define SCREEN_TAG "screen" +#define DUART_TAG "duart" class hp16500_state : public driver_device { diff --git a/src/mess/drivers/hp9k_3xx.c b/src/mess/drivers/hp9k_3xx.c index 5996047b29a..f79f09b94c1 100644 --- a/src/mess/drivers/hp9k_3xx.c +++ b/src/mess/drivers/hp9k_3xx.c @@ -1,7 +1,7 @@ // license:BSD-3-Clause // copyright-holders:R. Belmont /*************************************************************************** - + hp9k3xx.c: preliminary driver for HP9000 300 Series (aka HP9000/3xx) Currently supporting: @@ -16,20 +16,20 @@ MC68881 FPU 330: - MC68020 CPU @ 16.67 MHz - MC68851 MMU - MC68881 FPU + MC68020 CPU @ 16.67 MHz + MC68851 MMU + MC68881 FPU 340: MC68030 CPU @ 16.67 MHz w/built-in MMU - MC68881 FPU + MC68881 FPU 380: MC68040 CPU @ 25 MHz w/built-in MMU and FPU 382: MC68040 CPU @ 25? MHz w/built-in MMU and FPU - Built-in VGA compatible video + Built-in VGA compatible video All models have an MC6840 PIT on IRQ6 clocked at 250 kHz. @@ -132,28 +132,28 @@ UINT32 hp9k3xx_state::hp98544_update(screen_device &screen, bitmap_rgb32 &bitmap // shared mappings for all 9000/3xx systems static ADDRESS_MAP_START(hp9k3xx_common, AS_PROGRAM, 32, hp9k3xx_state) - AM_RANGE(0x00000000, 0x0001ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP // writes to 1fffc are the LED + AM_RANGE(0x00000000, 0x0001ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP // writes to 1fffc are the LED - AM_RANGE(0x00500000, 0x0050000f) AM_RAM // this is sufficient to pass the DMA test for now + AM_RANGE(0x00500000, 0x0050000f) AM_RAM // this is sufficient to pass the DMA test for now - AM_RANGE(0x00510000, 0x00510003) AM_READWRITE(buserror_r, buserror_w) // no "Alpha display" - AM_RANGE(0x00538000, 0x00538003) AM_READWRITE(buserror_r, buserror_w) // no "Graphics" - AM_RANGE(0x005c0000, 0x005c0003) AM_READWRITE(buserror_r, buserror_w) // no add-on FP coprocessor + AM_RANGE(0x00510000, 0x00510003) AM_READWRITE(buserror_r, buserror_w) // no "Alpha display" + AM_RANGE(0x00538000, 0x00538003) AM_READWRITE(buserror_r, buserror_w) // no "Graphics" + AM_RANGE(0x005c0000, 0x005c0003) AM_READWRITE(buserror_r, buserror_w) // no add-on FP coprocessor AM_RANGE(0x005f8000, 0x005f800f) AM_DEVREADWRITE8(PTM6840_TAG, ptm6840_device, read, write, 0x00ff00ff) ADDRESS_MAP_END // 9000/310 - has onboard video that the graphics card used in other 3xxes conflicts with static ADDRESS_MAP_START(hp9k310_map, AS_PROGRAM, 16, hp9k3xx_state) - AM_RANGE(0x000000, 0x01ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP // writes to 1fffc are the LED + AM_RANGE(0x000000, 0x01ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP // writes to 1fffc are the LED - AM_RANGE(0x510000, 0x510003) AM_READWRITE(buserror16_r, buserror16_w) // no "Alpha display" - AM_RANGE(0x538000, 0x538003) AM_READWRITE(buserror16_r, buserror16_w) // no "Graphics" - AM_RANGE(0x5c0000, 0x5c0003) AM_READWRITE(buserror16_r, buserror16_w) // no add-on FP coprocessor + AM_RANGE(0x510000, 0x510003) AM_READWRITE(buserror16_r, buserror16_w) // no "Alpha display" + AM_RANGE(0x538000, 0x538003) AM_READWRITE(buserror16_r, buserror16_w) // no "Graphics" + AM_RANGE(0x5c0000, 0x5c0003) AM_READWRITE(buserror16_r, buserror16_w) // no add-on FP coprocessor AM_RANGE(0x5f8000, 0x5f800f) AM_DEVREADWRITE8(PTM6840_TAG, ptm6840_device, read, write, 0x00ff) - AM_RANGE(0x200000, 0x2fffff) AM_RAM AM_SHARE("vram16") // 98544 mono framebuffer - AM_RANGE(0x560000, 0x563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM + AM_RANGE(0x200000, 0x2fffff) AM_RAM AM_SHARE("vram16") // 98544 mono framebuffer + AM_RANGE(0x560000, 0x563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM AM_RANGE(0x700000, 0x7fffff) AM_READWRITE(buserror16_r, buserror16_w) AM_RANGE(0x800000, 0xffffff) AM_RAM @@ -161,8 +161,8 @@ ADDRESS_MAP_END // 9000/320 static ADDRESS_MAP_START(hp9k320_map, AS_PROGRAM, 32, hp9k3xx_state) - AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer - AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM + AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer + AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM AM_RANGE(0xffe00000, 0xffefffff) AM_READWRITE(buserror_r, buserror_w) AM_RANGE(0xfff00000, 0xffffffff) AM_RAM @@ -172,8 +172,8 @@ ADDRESS_MAP_END // 9000/330 and 9000/340 static ADDRESS_MAP_START(hp9k330_map, AS_PROGRAM, 32, hp9k3xx_state) - AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer - AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM + AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer + AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM AM_RANGE(0xffb00000, 0xffbfffff) AM_READWRITE(buserror_r, buserror_w) AM_RANGE(0xffc00000, 0xffffffff) AM_RAM @@ -183,8 +183,8 @@ ADDRESS_MAP_END // 9000/370 - 8 MB RAM standard static ADDRESS_MAP_START(hp9k370_map, AS_PROGRAM, 32, hp9k3xx_state) - AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer - AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM + AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram") // 98544 mono framebuffer + AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000) // 98544 mono ROM AM_RANGE(0xff700000, 0xff7fffff) AM_READWRITE(buserror_r, buserror_w) AM_RANGE(0xff800000, 0xffffffff) AM_RAM @@ -292,7 +292,7 @@ static MACHINE_CONFIG_START( hp9k310, hp9k3xx_state ) MCFG_CPU_PROGRAM_MAP(hp9k310_map) MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) - MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 + MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) MCFG_SCREEN_ADD( "screen", RASTER) @@ -308,7 +308,7 @@ static MACHINE_CONFIG_START( hp9k320, hp9k3xx_state ) MCFG_CPU_PROGRAM_MAP(hp9k320_map) MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) - MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 + MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) MCFG_SCREEN_ADD( "screen", RASTER) @@ -324,7 +324,7 @@ static MACHINE_CONFIG_START( hp9k330, hp9k3xx_state ) MCFG_CPU_PROGRAM_MAP(hp9k330_map) MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) - MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 + MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) MCFG_SCREEN_ADD( "screen", RASTER) @@ -340,7 +340,7 @@ static MACHINE_CONFIG_START( hp9k340, hp9k3xx_state ) MCFG_CPU_PROGRAM_MAP(hp9k330_map) MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) - MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 + MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) MCFG_SCREEN_ADD( "screen", RASTER) @@ -356,7 +356,7 @@ static MACHINE_CONFIG_START( hp9k370, hp9k3xx_state ) MCFG_CPU_PROGRAM_MAP(hp9k370_map) MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) - MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 + MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) MCFG_SCREEN_ADD( "screen", RASTER) @@ -368,11 +368,11 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_START( hp9k380, hp9k3xx_state ) /* basic machine hardware */ - MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000) // 25 MHz? 33? + MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000) // 25 MHz? 33? MCFG_CPU_PROGRAM_MAP(hp9k330_map) MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) - MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 + MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) MCFG_SCREEN_ADD( "screen", RASTER) @@ -384,11 +384,11 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_START( hp9k382, hp9k3xx_state ) /* basic machine hardware */ - MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000) // 25 MHz? 33? + MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000) // 25 MHz? 33? MCFG_CPU_PROGRAM_MAP(hp9k382_map) MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0) - MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 + MCFG_PTM6840_INTERNAL_CLOCK(250000.0f) // from oscillator module next to the 6840 MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f) MCFG_SCREEN_ADD( "screen", RASTER) @@ -400,12 +400,12 @@ MACHINE_CONFIG_END ROM_START( hp9k310 ) ROM_REGION( 0x20000, MAINCPU_TAG, 0 ) - ROM_LOAD16_BYTE( "1818-3771.bin", 0x000001, 0x008000, CRC(b9e4e3ad) SHA1(ed6f1fad94a15d95362701dbe124b52877fc3ec4) ) - ROM_LOAD16_BYTE( "1818-3772.bin", 0x000000, 0x008000, CRC(a3665919) SHA1(ec1bc7e5b7990a1b09af947a06401e8ed3cb0516) ) + ROM_LOAD16_BYTE( "1818-3771.bin", 0x000001, 0x008000, CRC(b9e4e3ad) SHA1(ed6f1fad94a15d95362701dbe124b52877fc3ec4) ) + ROM_LOAD16_BYTE( "1818-3772.bin", 0x000000, 0x008000, CRC(a3665919) SHA1(ec1bc7e5b7990a1b09af947a06401e8ed3cb0516) ) ROM_REGION( 0x800, "mcu", 0 ) - ROM_LOAD( "1820-4784_1.bin", 0x000000, 0x000800, CRC(e929044a) SHA1(90849a10bdb8c6e38e73ce027c9c0ad8b3956b1b) ) - ROM_LOAD( "1820-4784_2.bin", 0x000000, 0x000800, CRC(8defcf50) SHA1(d3abfea468a43db7c2369500a3e390e77a8e22e6) ) + ROM_LOAD( "1820-4784_1.bin", 0x000000, 0x000800, CRC(e929044a) SHA1(90849a10bdb8c6e38e73ce027c9c0ad8b3956b1b) ) + ROM_LOAD( "1820-4784_2.bin", 0x000000, 0x000800, CRC(8defcf50) SHA1(d3abfea468a43db7c2369500a3e390e77a8e22e6) ) ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE ) ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000000, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) ) @@ -413,10 +413,10 @@ ROM_END ROM_START( hp9k320 ) ROM_REGION( 0x20000, MAINCPU_TAG, 0 ) - ROM_LOAD16_BYTE( "5061-6538.bin", 0x000001, 0x004000, CRC(d6aafeb1) SHA1(88c6b0b2f504303cbbac0c496c26b85458ac5d63) ) - ROM_LOAD16_BYTE( "5061-6539.bin", 0x000000, 0x004000, CRC(a7ff104c) SHA1(c640fe68314654716bd41b04c6a7f4e560036c7e) ) - ROM_LOAD16_BYTE( "5061-6540.bin", 0x008001, 0x004000, CRC(4f6796d6) SHA1(fd254897ac1afb8628f40ea93213f60a082c8d36) ) - ROM_LOAD16_BYTE( "5061-6541.bin", 0x008000, 0x004000, CRC(39d32998) SHA1(6de1bda75187b0878c03c074942b807cf2924f0e) ) + ROM_LOAD16_BYTE( "5061-6538.bin", 0x000001, 0x004000, CRC(d6aafeb1) SHA1(88c6b0b2f504303cbbac0c496c26b85458ac5d63) ) + ROM_LOAD16_BYTE( "5061-6539.bin", 0x000000, 0x004000, CRC(a7ff104c) SHA1(c640fe68314654716bd41b04c6a7f4e560036c7e) ) + ROM_LOAD16_BYTE( "5061-6540.bin", 0x008001, 0x004000, CRC(4f6796d6) SHA1(fd254897ac1afb8628f40ea93213f60a082c8d36) ) + ROM_LOAD16_BYTE( "5061-6541.bin", 0x008000, 0x004000, CRC(39d32998) SHA1(6de1bda75187b0878c03c074942b807cf2924f0e) ) ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE | ROMREGION_32BIT ) ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000001, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) ) @@ -424,8 +424,8 @@ ROM_END ROM_START( hp9k330 ) ROM_REGION( 0x20000, MAINCPU_TAG, 0 ) - ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) ) - ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) ) + ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) ) + ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) ) ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE | ROMREGION_32BIT ) ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000001, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) ) @@ -433,8 +433,8 @@ ROM_END ROM_START( hp9k340 ) ROM_REGION( 0x20000, MAINCPU_TAG, 0 ) - ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) ) - ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) ) + ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) ) + ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) ) ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE | ROMREGION_32BIT ) ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000001, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) ) diff --git a/src/mess/drivers/nes.c b/src/mess/drivers/nes.c index 9a5ff708c76..48904369ecf 100644 --- a/src/mess/drivers/nes.c +++ b/src/mess/drivers/nes.c @@ -214,7 +214,7 @@ MACHINE_START_MEMBER( nes_state, fds ) { m_ciram = auto_alloc_array(machine(), UINT8, 0x800); setup_disk(m_disk); - + // register saves save_item(NAME(m_last_frame_flip)); save_pointer(NAME(m_ciram), 0x800); diff --git a/src/mess/drivers/ngen.c b/src/mess/drivers/ngen.c index ab2d3249c0f..6ba901c161b 100644 --- a/src/mess/drivers/ngen.c +++ b/src/mess/drivers/ngen.c @@ -406,7 +406,7 @@ READ16_MEMBER(ngen_state::peripheral_r) // X-bus module select // The bootstrap ROM creates a table at 0:FC9h, with a count, followed by the module IDs of each -// expansion module. The base I/O address for the currently selected module is set by writing to +// expansion module. The base I/O address for the currently selected module is set by writing to // this register (bits 0-7 are ignored) // TODO: make expansion modules slot devices WRITE16_MEMBER(ngen_state::xbus_w) @@ -435,7 +435,7 @@ WRITE16_MEMBER(ngen_state::xbus_w) READ16_MEMBER(ngen_state::xbus_r) { UINT16 ret = 0xffff; - + switch(m_xbus_current) { case 0x00: @@ -647,8 +647,8 @@ WRITE_LINE_MEMBER( ngen_state::dack3_w ) { set_dma_channel(3, state); } READ8_MEMBER(ngen_state::dma_3_dack_r) { - UINT16 ret = 0xffff; - + UINT16 ret = 0xffff; + if((m_hdc_control & 0x04) && m_disk_rom) { ret = m_disk_rom->base()[m_disk_rom_ptr++] << 8; @@ -659,7 +659,7 @@ READ8_MEMBER(ngen_state::dma_3_dack_r) //m_dmac->dreq3_w(0); } } - m_dma_high_byte = ret & 0xff00; + m_dma_high_byte = ret & 0xff00; return ret; } @@ -737,16 +737,16 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( ngen_io, AS_IO, 16, ngen_state ) AM_RANGE(0x0000, 0x0001) AM_READWRITE(xbus_r,xbus_w) - + // Floppy/Hard disk module -// AM_RANGE(0x0100, 0x0107) AM_DEVREADWRITE8("fdc",wd2797_t,read,write,0x00ff) // a guess for now -// AM_RANGE(0x0108, 0x0109) AM_WRITE8(fdc_control_w,0x00ff) -// AM_RANGE(0x010a, 0x010b) AM_WRITE8(hdc_control_w,0x00ff) -// AM_RANGE(0x010e, 0x010f) AM_WRITE8(disk_addr_ext,0x00ff) // X-Bus extended address register -// AM_RANGE(0x0110, 0x0117) AM_DEVREADWRITE8("fdc_timer",pit8253_device,read,write,0x00ff) +// AM_RANGE(0x0100, 0x0107) AM_DEVREADWRITE8("fdc",wd2797_t,read,write,0x00ff) // a guess for now +// AM_RANGE(0x0108, 0x0109) AM_WRITE8(fdc_control_w,0x00ff) +// AM_RANGE(0x010a, 0x010b) AM_WRITE8(hdc_control_w,0x00ff) +// AM_RANGE(0x010e, 0x010f) AM_WRITE8(disk_addr_ext,0x00ff) // X-Bus extended address register +// AM_RANGE(0x0110, 0x0117) AM_DEVREADWRITE8("fdc_timer",pit8253_device,read,write,0x00ff) // 0x0120-0x012f - WD1010 Winchester disk controller (unemulated) -// AM_RANGE(0x0130, 0x0137) AM_DEVREADWRITE8("hdc_timer",pit8253_device,read,write,0x00ff) - +// AM_RANGE(0x0130, 0x0137) AM_DEVREADWRITE8("hdc_timer",pit8253_device,read,write,0x00ff) + ADDRESS_MAP_END static ADDRESS_MAP_START( ngen386_mem, AS_PROGRAM, 32, ngen_state ) @@ -851,7 +851,7 @@ static MACHINE_CONFIG_START( ngen, ngen_state ) // keyboard UART (patent says i8251 is used for keyboard communications, it is located on the video board) MCFG_DEVICE_ADD("videouart", I8251, 0) // main clock unknown, Rx/Tx clocks are 19.53kHz -// MCFG_I8251_TXEMPTY_HANDLER(DEVWRITELINE("pic",pic8259_device,ir4_w)) +// MCFG_I8251_TXEMPTY_HANDLER(DEVWRITELINE("pic",pic8259_device,ir4_w)) MCFG_I8251_TXD_HANDLER(DEVWRITELINE("keyboard", rs232_port_device, write_txd)) MCFG_RS232_PORT_ADD("keyboard", keyboard, "ngen") MCFG_RS232_RXD_HANDLER(DEVWRITELINE("videouart", i8251_device, write_rxd)) @@ -865,12 +865,12 @@ static MACHINE_CONFIG_START( ngen, ngen_state ) MCFG_WD_FDC_DRQ_CALLBACK(DEVWRITELINE("maincpu",i80186_cpu_device,drq1_w)) MCFG_WD_FDC_FORCE_READY MCFG_DEVICE_ADD("fdc_timer", PIT8253, 0) - MCFG_PIT8253_CLK0(XTAL_20MHz / 20) + MCFG_PIT8253_CLK0(XTAL_20MHz / 20) MCFG_PIT8253_OUT0_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w)) // clocked on FDC data register access MCFG_PIT8253_CLK1(XTAL_20MHz / 20) MCFG_PIT8253_OUT1_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w)) // 1MHz MCFG_PIT8253_CLK2(XTAL_20MHz / 10) - MCFG_PIT8253_OUT2_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w)) + MCFG_PIT8253_OUT2_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w)) // TODO: WD1010 HDC (not implemented), use WD2010 for now MCFG_DEVICE_ADD("hdc", WD2010, XTAL_20MHz / 4) MCFG_WD2010_IN_BCS_CB(READ8(ngen_state,hd_buffer_r)) diff --git a/src/mess/drivers/pasogo.c b/src/mess/drivers/pasogo.c index 99f83dc1abf..b59011319c5 100644 --- a/src/mess/drivers/pasogo.c +++ b/src/mess/drivers/pasogo.c @@ -681,7 +681,7 @@ void pasogo_state::machine_reset() astring region_tag; m_maincpu_rom = memregion("maincpu"); m_cart_rom = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - if (!m_cart_rom) // this should never happen, since we make carts mandatory! + if (!m_cart_rom) // this should never happen, since we make carts mandatory! m_cart_rom = memregion("maincpu"); membank("bank27")->set_base(m_cart_rom->base()); diff --git a/src/mess/drivers/splitsec.c b/src/mess/drivers/splitsec.c index 719b67eb474..06b28f9163e 100644 --- a/src/mess/drivers/splitsec.c +++ b/src/mess/drivers/splitsec.c @@ -4,7 +4,7 @@ Parker Brothers Split Second * TMS1400NLL MP7314-N2 (die labeled MP7314) - + This is an electronic handheld reflex gaming device, it's straightforward to use. The included mini-games are: 1, 2, 3: Mad Maze* @@ -12,7 +12,7 @@ 6: Auto Cross 7: Stomp 8: Speedball - + *: higher number indicates higher difficulty @@ -167,7 +167,7 @@ WRITE16_MEMBER(splitsec_state::write_r) { // R8: speaker out m_speaker->level_w(data >> 8 & 1); - + // R9,R10: input mux // R0-R7: led columns m_r = data; diff --git a/src/mess/drivers/tispeak.c b/src/mess/drivers/tispeak.c index 9848aebbc80..cf42755f006 100644 --- a/src/mess/drivers/tispeak.c +++ b/src/mess/drivers/tispeak.c @@ -693,7 +693,7 @@ COMP( 1978, snspell, 0, 0, snspell, snspell, tispeak_state, snspell, COMP( 1980, snspella, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (US set 2)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND ) COMP( 1978, snspelluk, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (UK set 1)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND ) COMP( 1981, snspelluka, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (UK set 2)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND ) // different voice actor -COMP( 1979, snspelljp, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (Japan)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND ) +COMP( 1979, snspelljp, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (Japan)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND ) COMP( 1980, ladictee, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "La Dictee Magique (France)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND ) // doesn't work due to missing CD2702 MCU dump, German version has CD2702 too COMP( 1980, snmath, 0, 0, snmath, snmath, driver_device, 0, "Texas Instruments", "Speak & Math (US prototype)", GAME_IMPERFECT_SOUND ) // also US set 1 diff --git a/src/mess/includes/c65.h b/src/mess/includes/c65.h index 0cb898178e0..8b137891791 100644 --- a/src/mess/includes/c65.h +++ b/src/mess/includes/c65.h @@ -1,195 +1 @@ -/***************************************************************************** - * - * includes/c65.h - * - ****************************************************************************/ -#ifndef C65_H_ -#define C65_H_ - -#include "machine/mos6526.h" -#include "bus/cbmiec/cbmiec.h" -#include "imagedev/snapquik.h" -#include "machine/ram.h" -#include "sound/mos6581.h" -#include "video/vic4567.h" - -#define C64_MAX_ROMBANK 64 // .crt files contain multiple 'CHIPs', i.e. rom banks (of variable size) with headers. Known carts have at most 64 'CHIPs'. - -struct C64_ROM { - int addr, size, index, start; -}; - -struct c64_cart_t { - C64_ROM bank[C64_MAX_ROMBANK]; - INT8 game; - INT8 exrom; - UINT8 mapper; - UINT8 n_banks; -}; - -struct dma_t -{ - int version; - UINT8 data[4]; -}; - -struct fdc_t -{ - int state; - - UINT8 reg[0x0f]; - - UINT8 buffer[0x200]; - int cpu_pos; - int fdc_pos; - - UINT16 status; - - attotime time; - int head,track,sector; -}; - -struct expansion_ram_t -{ - UINT8 reg; -}; - -class c65_state : public driver_device -{ -public: - c65_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_cia0(*this, "cia_0"), - m_cia1(*this, "cia_1"), - m_sid_r(*this, "sid_r"), - m_vic(*this, "vic3"), - m_iec(*this, CBM_IEC_TAG), - m_colorram(*this, "colorram"), - m_basic(*this, "basic"), - m_chargen(*this, "chargen"), - m_kernal(*this, "kernal"), - m_c65_chargen(*this, "c65_chargen"), - m_interface(*this, "interface"), - m_roml_writable(0), - m_maincpu(*this, "maincpu"), - m_ram(*this, RAM_TAG) { } - - required_device m_cia0; - required_device m_cia1; - required_device m_sid_r; - required_device m_vic; - optional_device m_iec; - - required_shared_ptr m_colorram; - required_shared_ptr m_basic; - required_shared_ptr m_chargen; - required_shared_ptr m_kernal; - required_shared_ptr m_c65_chargen; - required_shared_ptr m_interface; - int m_old_level; - int m_old_data; - int m_old_exrom; - int m_old_game; - UINT8 m_vicirq; - emu_timer *m_datasette_timer; - emu_timer *m_cartridge_timer; - UINT8 *m_memory; - int m_pal; - int m_tape_on; - UINT8 *m_c64_roml; - UINT8 *m_c64_romh; - UINT8 *m_vicaddr; - UINT8 *m_c128_vicaddr; - UINT8 m_game; - UINT8 m_exrom; - UINT8 *m_io_mirror; - UINT8 m_port_data; - UINT8 *m_roml; - UINT8 *m_romh; - int m_roml_writable; - int m_ultimax; - int m_cia1_on; - int m_io_enabled; - int m_is_sx64; - UINT8 *m_io_ram_w_ptr; - UINT8 *m_io_ram_r_ptr; - c64_cart_t m_cart; - int m_nmilevel; int m_charset_select; - int m_c64mode; - UINT8 m_6511_port; - UINT8 m_keyline; - int m_old_value; - dma_t m_dma; - int m_dump_dma; - fdc_t m_fdc; - expansion_ram_t m_expansion_ram; - int m_io_on; - int m_io_dc00_on; - int m_cia0_irq, m_cia1_irq; - DECLARE_DRIVER_INIT(c65); - DECLARE_DRIVER_INIT(c65pal); - - DECLARE_READ8_MEMBER( c64_lightpen_x_cb ); - DECLARE_READ8_MEMBER( c64_lightpen_y_cb ); - DECLARE_READ8_MEMBER( c64_lightpen_button_cb ); - DECLARE_READ8_MEMBER( c64_dma_read ); - DECLARE_READ8_MEMBER( c64_dma_read_ultimax ); - DECLARE_READ8_MEMBER( c64_dma_read_color ); - DECLARE_WRITE_LINE_MEMBER( c64_vic_interrupt ); - DECLARE_READ8_MEMBER( c64_rdy_cb ); - DECLARE_READ8_MEMBER( sid_potx_r ); - DECLARE_READ8_MEMBER( sid_poty_r ); - DECLARE_MACHINE_START(c65); - UINT32 screen_update_c65(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(vic3_raster_irq); - INTERRUPT_GEN_MEMBER(c65_frame_interrupt); - DECLARE_READ8_MEMBER(c65_cia0_port_a_r); - DECLARE_READ8_MEMBER(c65_cia0_port_b_r); - DECLARE_WRITE8_MEMBER(c65_cia0_port_b_w); - DECLARE_READ8_MEMBER(c65_cia1_port_a_r); - DECLARE_WRITE8_MEMBER(c65_cia1_port_a_w); - DECLARE_WRITE_LINE_MEMBER(c65_cia1_interrupt); - void c64_legacy_driver_init(); - DECLARE_DEVICE_IMAGE_LOAD_MEMBER( c64_cart ); - DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER( c64_cart ); - DECLARE_WRITE_LINE_MEMBER(c65_cia0_interrupt); - DECLARE_READ8_MEMBER(c65_lightpen_x_cb); - DECLARE_READ8_MEMBER(c65_lightpen_y_cb); - DECLARE_READ8_MEMBER(c65_lightpen_button_cb); - DECLARE_READ8_MEMBER(c65_c64_mem_r); - DECLARE_READ8_MEMBER(c65_dma_read); - DECLARE_READ8_MEMBER(c65_dma_read_color); - DECLARE_WRITE_LINE_MEMBER(c65_vic_interrupt); - DECLARE_WRITE8_MEMBER(c65_bankswitch_interface); - DECLARE_READ8_MEMBER( c65_read_mem ); - DECLARE_WRITE8_MEMBER( c65_write_mem ); - DECLARE_READ8_MEMBER( c65_ram_expansion_r ); - DECLARE_WRITE8_MEMBER( c65_ram_expansion_w ); - DECLARE_WRITE8_MEMBER( c65_write_io ); - DECLARE_WRITE8_MEMBER( c65_write_io_dc00 ); - DECLARE_READ8_MEMBER( c65_read_io ); - DECLARE_READ8_MEMBER( c65_read_io_dc00 ); - DECLARE_QUICKLOAD_LOAD_MEMBER( cbm_c65 ); - - int c64_paddle_read( device_t *device, address_space &space, int which ); - void c65_nmi( ); - void c65_irq( int level ); - void c65_dma_port_w( int offset, int value ); - int c65_dma_port_r( int offset ); - void c65_6511_port_w( int offset, int value ); - int c65_6511_port_r( int offset ); - void c65_fdc_state(void); - void c65_fdc_w( int offset, int data ); - int c65_fdc_r( int offset ); - void c65_bankswitch( ); - void c65_colorram_write( int offset, int value ); - void c65_common_driver_init( ); - - required_device m_maincpu; - required_device m_ram; -}; - -MACHINE_CONFIG_EXTERN( c64_cartslot ); - -#endif /* C65_H_ */ diff --git a/src/mess/includes/mac.h b/src/mess/includes/mac.h index 82e5df5959d..c923ac860d9 100644 --- a/src/mess/includes/mac.h +++ b/src/mess/includes/mac.h @@ -291,9 +291,9 @@ public: INT32 m_adb_linestate; bool m_adb_srqflag; #define kADBKeyBufSize 32 - UINT8 m_adb_keybuf[kADBKeyBufSize]; - UINT8 m_adb_keybuf_start; - UINT8 m_adb_keybuf_end; + UINT8 m_adb_keybuf[kADBKeyBufSize]; + UINT8 m_adb_keybuf_start; + UINT8 m_adb_keybuf_end; // Portable/PB100 Power Manager IC comms (chapter 4, "Guide to the Macintosh Family Hardware", second edition) UINT8 m_pm_data_send, m_pm_data_recv, m_pm_ack, m_pm_req, m_pm_cmd[32], m_pm_out[32], m_pm_dptr, m_pm_sptr, m_pm_slen, m_pm_state; diff --git a/src/mess/machine/amstrad.c b/src/mess/machine/amstrad.c index 8c692622488..8600075be1d 100644 --- a/src/mess/machine/amstrad.c +++ b/src/mess/machine/amstrad.c @@ -3034,7 +3034,7 @@ MACHINE_START_MEMBER(amstrad_state,plus) astring region_tag; m_region_cart = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - if (!m_region_cart) // this should never happen, since we make carts mandatory! + if (!m_region_cart) // this should never happen, since we make carts mandatory! m_region_cart = memregion("maincpu"); } @@ -3078,7 +3078,7 @@ MACHINE_START_MEMBER(amstrad_state,gx4000) astring region_tag; m_region_cart = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - if (!m_region_cart) // this should never happen, since we make carts mandatory! + if (!m_region_cart) // this should never happen, since we make carts mandatory! m_region_cart = memregion("maincpu"); } diff --git a/src/mess/machine/c65.c b/src/mess/machine/c65.c deleted file mode 100644 index 8060f05c54c..00000000000 --- a/src/mess/machine/c65.c +++ /dev/null @@ -1,1337 +0,0 @@ -/*************************************************************************** - commodore c65 home computer - peter.trauner@jk.uni-linz.ac.at - documention - www.funet.fi - ***************************************************************************/ - -#include "emu.h" - -#include "includes/c65.h" -#include "cpu/m6502/m4510.h" -#include "sound/mos6581.h" -#include "machine/mos6526.h" -#include "bus/cbmiec/cbmiec.h" -#include "machine/ram.h" -#include "video/vic4567.h" -#include "imagedev/cassette.h" -#include "crsshair.h" -#include "formats/cbm_tap.h" - -#define VERBOSE_LEVEL 0 -#define DBG_LOG( MACHINE, N, M, A ) \ - do { \ - if(VERBOSE_LEVEL >= N) \ - { \ - if( M ) \ - logerror("%11.6f: %-24s", MACHINE.time().as_double(), (char*) M ); \ - logerror A; \ - } \ - } while (0) - - - -/*********************************************** - - Input Reading - Common Components - -***********************************************/ - -/* These are needed by c64, c65 and c128, each machine has also additional specific -components in its INTERRUPT_GEN */ - -/* keyboard lines */ -UINT8 c64_keyline[10]; - -void cbm_common_init(void) -{ - int i; - - for (i = 0; i < ARRAY_LENGTH(c64_keyline); i++) - c64_keyline[i] = 0xff; -} - -static TIMER_CALLBACK( lightpen_tick ) -{ - if (((machine.root_device().ioport("CTRLSEL")->read() & 0x07) == 0x04) || ((machine.root_device().ioport("CTRLSEL")->read() & 0x07) == 0x06)) - { - /* enable lightpen crosshair */ - crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL); - } - else - { - /* disable lightpen crosshair */ - crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE); - } -} - -void cbm_common_interrupt( device_t *device ) -{ - int value, i; - int controller1 = device->machine().root_device().ioport("CTRLSEL")->read() & 0x07; - int controller2 = device->machine().root_device().ioport("CTRLSEL")->read() & 0x70; - static const char *const c64ports[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7" }; - - /* Lines 0-7 : common keyboard */ - for (i = 0; i < 8; i++) - { - value = 0xff; - value &= ~device->machine().root_device().ioport(c64ports[i])->read(); - - /* Shift Lock is mapped on Left Shift */ - if ((i == 1) && (device->machine().root_device().ioport("SPECIAL")->read() & 0x40)) - value &= ~0x80; - - c64_keyline[i] = value; - } - - - value = 0xff; - switch(controller1) - { - case 0x00: - value &= ~device->machine().root_device().ioport("JOY1_1B")->read(); /* Joy1 Directions + Button 1 */ - break; - - case 0x01: - if (device->machine().root_device().ioport("OTHER")->read() & 0x40) /* Paddle2 Button */ - value &= ~0x08; - if (device->machine().root_device().ioport("OTHER")->read() & 0x80) /* Paddle1 Button */ - value &= ~0x04; - break; - - case 0x02: - if (device->machine().root_device().ioport("OTHER")->read() & 0x02) /* Mouse Button Left */ - value &= ~0x10; - if (device->machine().root_device().ioport("OTHER")->read() & 0x01) /* Mouse Button Right */ - value &= ~0x01; - break; - - case 0x03: - value &= ~(device->machine().root_device().ioport("JOY1_2B")->read() & 0x1f); /* Joy1 Directions + Button 1 */ - break; - - case 0x04: -/* was there any input on the lightpen? where is it mapped? */ -// if (device->machine().root_device().ioport("OTHER")->read() & 0x04) /* Lightpen Signal */ -// value &= ?? ; - break; - - case 0x07: - break; - - default: - logerror("Invalid Controller 1 Setting %d\n", controller1); - break; - } - - c64_keyline[8] = value; - - - value = 0xff; - switch(controller2) - { - case 0x00: - value &= ~device->machine().root_device().ioport("JOY2_1B")->read(); /* Joy2 Directions + Button 1 */ - break; - - case 0x10: - if (device->machine().root_device().ioport("OTHER")->read() & 0x10) /* Paddle4 Button */ - value &= ~0x08; - if (device->machine().root_device().ioport("OTHER")->read() & 0x20) /* Paddle3 Button */ - value &= ~0x04; - break; - - case 0x20: - if (device->machine().root_device().ioport("OTHER")->read() & 0x02) /* Mouse Button Left */ - value &= ~0x10; - if (device->machine().root_device().ioport("OTHER")->read() & 0x01) /* Mouse Button Right */ - value &= ~0x01; - break; - - case 0x30: - value &= ~(device->machine().root_device().ioport("JOY2_2B")->read() & 0x1f); /* Joy2 Directions + Button 1 */ - break; - - case 0x40: -/* was there any input on the lightpen? where is it mapped? */ -// if (device->machine().root_device().ioport("OTHER")->read() & 0x04) /* Lightpen Signal */ -// value &= ?? ; - break; - - case 0x70: - break; - - default: - logerror("Invalid Controller 2 Setting %d\n", controller2); - break; - } - - c64_keyline[9] = value; - -// vic2_frame_interrupt does nothing so this is not necessary -// vic2_frame_interrupt (device); - - /* check if lightpen has been chosen as input: if so, enable crosshair */ - device->machine().scheduler().timer_set(attotime::zero, FUNC(lightpen_tick)); - - set_led_status (device->machine(), 1, device->machine().root_device().ioport("SPECIAL")->read() & 0x40 ? 1 : 0); /* Shift Lock */ - set_led_status (device->machine(), 0, device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 ? 1 : 0); /* Joystick Swap */ -} - - -/*********************************************** - - CIA Common Handlers - -***********************************************/ - -/* These are shared by c64, c65 and c128. c65 and c128 also have additional specific -components (to select/read additional keyboard lines) */ - -/* - * CIA 0 - Port A - * bits 7-0 keyboard line select - * bits 7,6: paddle select( 01 port a, 10 port b) - * bit 4: joystick a fire button - * bits 3,2: Paddles port a fire button - * bits 3-0: joystick a direction - * - * CIA 0 - Port B - * bits 7-0: keyboard raw values - * bit 4: joystick b fire button, lightpen select - * bits 3,2: paddle b fire buttons (left,right) - * bits 3-0: joystick b direction - * - * flag cassette read input, serial request in - * irq to irq connected - */ - -UINT8 cbm_common_cia0_port_a_r( device_t *device, UINT8 output_b ) -{ - UINT8 value = 0xff; - - if (!(output_b & 0x80)) - { - UINT8 t = 0xff; - if (!(c64_keyline[7] & 0x80)) t &= ~0x80; - if (!(c64_keyline[6] & 0x80)) t &= ~0x40; - if (!(c64_keyline[5] & 0x80)) t &= ~0x20; - if (!(c64_keyline[4] & 0x80)) t &= ~0x10; - if (!(c64_keyline[3] & 0x80)) t &= ~0x08; - if (!(c64_keyline[2] & 0x80)) t &= ~0x04; - if (!(c64_keyline[1] & 0x80)) t &= ~0x02; - if (!(c64_keyline[0] & 0x80)) t &= ~0x01; - value &= t; - } - - if (!(output_b & 0x40)) - { - UINT8 t = 0xff; - if (!(c64_keyline[7] & 0x40)) t &= ~0x80; - if (!(c64_keyline[6] & 0x40)) t &= ~0x40; - if (!(c64_keyline[5] & 0x40)) t &= ~0x20; - if (!(c64_keyline[4] & 0x40)) t &= ~0x10; - if (!(c64_keyline[3] & 0x40)) t &= ~0x08; - if (!(c64_keyline[2] & 0x40)) t &= ~0x04; - if (!(c64_keyline[1] & 0x40)) t &= ~0x02; - if (!(c64_keyline[0] & 0x40)) t &= ~0x01; - value &= t; - } - - if (!(output_b & 0x20)) - { - UINT8 t = 0xff; - if (!(c64_keyline[7] & 0x20)) t &= ~0x80; - if (!(c64_keyline[6] & 0x20)) t &= ~0x40; - if (!(c64_keyline[5] & 0x20)) t &= ~0x20; - if (!(c64_keyline[4] & 0x20)) t &= ~0x10; - if (!(c64_keyline[3] & 0x20)) t &= ~0x08; - if (!(c64_keyline[2] & 0x20)) t &= ~0x04; - if (!(c64_keyline[1] & 0x20)) t &= ~0x02; - if (!(c64_keyline[0] & 0x20)) t &= ~0x01; - value &= t; - } - - if (!(output_b & 0x10)) - { - UINT8 t = 0xff; - if (!(c64_keyline[7] & 0x10)) t &= ~0x80; - if (!(c64_keyline[6] & 0x10)) t &= ~0x40; - if (!(c64_keyline[5] & 0x10)) t &= ~0x20; - if (!(c64_keyline[4] & 0x10)) t &= ~0x10; - if (!(c64_keyline[3] & 0x10)) t &= ~0x08; - if (!(c64_keyline[2] & 0x10)) t &= ~0x04; - if (!(c64_keyline[1] & 0x10)) t &= ~0x02; - if (!(c64_keyline[0] & 0x10)) t &= ~0x01; - value &= t; - } - - if (!(output_b & 0x08)) - { - UINT8 t = 0xff; - if (!(c64_keyline[7] & 0x08)) t &= ~0x80; - if (!(c64_keyline[6] & 0x08)) t &= ~0x40; - if (!(c64_keyline[5] & 0x08)) t &= ~0x20; - if (!(c64_keyline[4] & 0x08)) t &= ~0x10; - if (!(c64_keyline[3] & 0x08)) t &= ~0x08; - if (!(c64_keyline[2] & 0x08)) t &= ~0x04; - if (!(c64_keyline[1] & 0x08)) t &= ~0x02; - if (!(c64_keyline[0] & 0x08)) t &= ~0x01; - value &= t; - } - - if (!(output_b & 0x04)) - { - UINT8 t = 0xff; - if (!(c64_keyline[7] & 0x04)) t &= ~0x80; - if (!(c64_keyline[6] & 0x04)) t &= ~0x40; - if (!(c64_keyline[5] & 0x04)) t &= ~0x20; - if (!(c64_keyline[4] & 0x04)) t &= ~0x10; - if (!(c64_keyline[3] & 0x04)) t &= ~0x08; - if (!(c64_keyline[2] & 0x04)) t &= ~0x04; - if (!(c64_keyline[1] & 0x04)) t &= ~0x02; - if (!(c64_keyline[0] & 0x04)) t &= ~0x01; - value &= t; - } - - if (!(output_b & 0x02)) - { - UINT8 t = 0xff; - if (!(c64_keyline[7] & 0x02)) t &= ~0x80; - if (!(c64_keyline[6] & 0x02)) t &= ~0x40; - if (!(c64_keyline[5] & 0x02)) t &= ~0x20; - if (!(c64_keyline[4] & 0x02)) t &= ~0x10; - if (!(c64_keyline[3] & 0x02)) t &= ~0x08; - if (!(c64_keyline[2] & 0x02)) t &= ~0x04; - if (!(c64_keyline[1] & 0x02)) t &= ~0x02; - if (!(c64_keyline[0] & 0x02)) t &= ~0x01; - value &= t; - } - - if (!(output_b & 0x01)) - { - UINT8 t = 0xff; - if (!(c64_keyline[7] & 0x01)) t &= ~0x80; - if (!(c64_keyline[6] & 0x01)) t &= ~0x40; - if (!(c64_keyline[5] & 0x01)) t &= ~0x20; - if (!(c64_keyline[4] & 0x01)) t &= ~0x10; - if (!(c64_keyline[3] & 0x01)) t &= ~0x08; - if (!(c64_keyline[2] & 0x01)) t &= ~0x04; - if (!(c64_keyline[1] & 0x01)) t &= ~0x02; - if (!(c64_keyline[0] & 0x01)) t &= ~0x01; - value &= t; - } - - if ( device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 ) - value &= c64_keyline[8]; - else - value &= c64_keyline[9]; - - return value; -} - -UINT8 cbm_common_cia0_port_b_r( device_t *device, UINT8 output_a ) -{ - UINT8 value = 0xff; - - if (!(output_a & 0x80)) value &= c64_keyline[7]; - if (!(output_a & 0x40)) value &= c64_keyline[6]; - if (!(output_a & 0x20)) value &= c64_keyline[5]; - if (!(output_a & 0x10)) value &= c64_keyline[4]; - if (!(output_a & 0x08)) value &= c64_keyline[3]; - if (!(output_a & 0x04)) value &= c64_keyline[2]; - if (!(output_a & 0x02)) value &= c64_keyline[1]; - if (!(output_a & 0x01)) value &= c64_keyline[0]; - - if ( device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 ) - value &= c64_keyline[9]; - else - value &= c64_keyline[8]; - - return value; -} - - -/*********************************************** - - CBM Cartridges - -***********************************************/ - - -/* All the cartridge specific code has been moved - to machine/ drivers. Once more informations - surface about the cart expansions for systems - in c65.c, c128.c, cbmb.c and pet.c, the shared - code could be refactored to have here the - common functions */ - - - -/*********************************************** - - CBM Datasette Tapes - -***********************************************/ - -#if 0 -const cassette_interface cbm_cassette_interface = -{ - cbm_cassette_formats, - NULL, - (cassette_state) (CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED), - NULL -}; -#endif - - -/*UINT8 *c65_basic; */ -/*UINT8 *c65_kernal; */ -/*UINT8 *c65_dos; */ -/*UINT8 *c65_monitor; */ -/*UINT8 *c65_graphics; */ - - -void c65_state::c65_nmi( ) -{ - if (m_nmilevel != (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq) /* KEY_RESTORE */ - { - m_maincpu->set_input_line(INPUT_LINE_NMI, (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq); - - m_nmilevel = (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq; - } -} - - -/*********************************************** - - CIA Interfaces - -***********************************************/ - -/* - * CIA 0 - Port A keyboard line select - * CIA 0 - Port B keyboard line read - * - * flag cassette read input, serial request in - * irq to irq connected - * - * see machine/cbm.c - */ - -READ8_MEMBER(c65_state::c65_cia0_port_a_r) -{ - UINT8 cia0portb = m_cia0->pb_r(space, 0); - - return cbm_common_cia0_port_a_r(m_cia0, cia0portb); -} - -READ8_MEMBER(c65_state::c65_cia0_port_b_r) -{ - UINT8 value = 0xff; - UINT8 cia0porta = m_cia0->pa_r(space, 0); - - value &= cbm_common_cia0_port_b_r(m_cia0, cia0porta); - - if (!(m_6511_port & 0x02)) - value &= m_keyline; - - return value; -} - -WRITE8_MEMBER(c65_state::c65_cia0_port_b_w) -{ -// was there lightpen support in c65 video chip? -// vic3_device *vic3 = machine().device("vic3"); -// vic3->lightpen_write(data & 0x10); -} - -void c65_state::c65_irq( int level ) -{ - if (level != m_old_level) - { - DBG_LOG(machine(), 3, "mos4510", ("irq %s\n", level ? "start" : "end")); - m_maincpu->set_input_line(M4510_IRQ_LINE, level); - m_old_level = level; - } -} - -/* is this correct for c65 as well as c64? */ -WRITE_LINE_MEMBER(c65_state::c65_cia0_interrupt) -{ - m_cia0_irq = state; - c65_irq(state || m_vicirq); -} - -/* is this correct for c65 as well as c64? */ -WRITE_LINE_MEMBER(c65_state::c65_vic_interrupt) -{ -#if 1 - if (state != m_vicirq) - { - c65_irq (state || m_cia0_irq); - m_vicirq = state; - } -#endif -} - -/* - * CIA 1 - Port A - * bit 7 serial bus data input - * bit 6 serial bus clock input - * bit 5 serial bus data output - * bit 4 serial bus clock output - * bit 3 serial bus atn output - * bit 2 rs232 data output - * bits 1-0 vic-chip system memory bank select - * - * CIA 1 - Port B - * bit 7 user rs232 data set ready - * bit 6 user rs232 clear to send - * bit 5 user - * bit 4 user rs232 carrier detect - * bit 3 user rs232 ring indicator - * bit 2 user rs232 data terminal ready - * bit 1 user rs232 request to send - * bit 0 user rs232 received data - * - * flag restore key or rs232 received data input - * irq to nmi connected ? - */ -READ8_MEMBER(c65_state::c65_cia1_port_a_r) -{ - UINT8 value = 0xff; - - if (!m_iec->clk_r()) - value &= ~0x40; - - if (!m_iec->data_r()) - value &= ~0x80; - - return value; -} - -WRITE8_MEMBER(c65_state::c65_cia1_port_a_w) -{ - static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000}; - - m_iec->atn_w(!BIT(data, 3)); - m_iec->clk_w(!BIT(data, 4)); - m_iec->data_w(!BIT(data, 5)); - - m_vicaddr = m_memory + helper[data & 0x03]; -} - -WRITE_LINE_MEMBER(c65_state::c65_cia1_interrupt) -{ - m_cia1_irq = state; - c65_nmi(); -} - -/*********************************************** - - Memory Handlers - -***********************************************/ - -/* processor has only 1 mega address space !? */ -/* and system 8 megabyte */ -/* dma controller and bankswitch hardware ?*/ -READ8_MEMBER( c65_state::c65_read_mem ) -{ - UINT8 result; - if (offset <= 0x0ffff) - result = m_memory[offset]; - else - result = space.read_byte(offset); - return result; -} - -WRITE8_MEMBER( c65_state::c65_write_mem ) -{ - if (offset <= 0x0ffff) - m_memory[offset] = data; - else - space.write_byte(offset, data); -} - -/* dma chip at 0xd700 - used: - writing banknumber to offset 2 - writing hibyte to offset 1 - writing lobyte to offset 0 - cpu holded, dma transfer(data at address) executed, cpu activated - - command data: - 0 command (0 copy, 3 fill) - 1,2 length - 3,4,5 source - 6,7,8 dest - 9 subcommand - 10 mod - - version 1: - seldom copy (overlapping) from 0x402002 to 0x402008 - (making place for new line in basic area) - for whats this bit 0x400000, or is this really the address? - maybe means add counter to address for access, - so allowing up or down copies, and reordering copies - - version 2: - cmd 0x30 used for this -*/ -void c65_state::c65_dma_port_w( int offset, int value ) -{ - PAIR pair, src, dst, len; - UINT8 cmd, fill; - int i; - address_space &space = m_maincpu->space(AS_PROGRAM); - - switch (offset & 3) - { - case 2: - case 1: - m_dma.data[offset & 3] = value; - break; - case 0: - pair.b.h3 = 0; - pair.b.h2 = m_dma.data[2]; - pair.b.h = m_dma.data[1]; - pair.b.l = m_dma.data[0]=value; - cmd = c65_read_mem(space, pair.d++); - len.w.h = 0; - len.b.l = c65_read_mem(space, pair.d++); - len.b.h = c65_read_mem(space, pair.d++); - src.b.h3 = 0; - fill = src.b.l = c65_read_mem(space, pair.d++); - src.b.h = c65_read_mem(space, pair.d++); - src.b.h2 = c65_read_mem(space, pair.d++); - dst.b.h3 = 0; - dst.b.l = c65_read_mem(space, pair.d++); - dst.b.h = c65_read_mem(space, pair.d++); - dst.b.h2 = c65_read_mem(space, pair.d++); - - switch (cmd) - { - case 0: - if (src.d == 0x3ffff) m_dump_dma = 1; - if (m_dump_dma) - DBG_LOG(space.machine(), 1,"dma copy job", - ("len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n", - len.w.l, src.d, dst.d, c65_read_mem(space, pair.d), - c65_read_mem(space, pair.d + 1) ) ); - if ((m_dma.version == 1) - && ( (src.d&0x400000) || (dst.d & 0x400000))) - { - if (!(src.d & 0x400000)) - { - dst.d &= ~0x400000; - for (i = 0; i < len.w.l; i++) - c65_write_mem(space, dst.d--, c65_read_mem(space, src.d++)); - } - else if (!(dst.d & 0x400000)) - { - src.d &= ~0x400000; - for (i = 0; i < len.w.l; i++) - c65_write_mem(space, dst.d++, c65_read_mem(space, src.d--)); - } - else - { - src.d &= ~0x400000; - dst.d &= ~0x400000; - for (i = 0; i < len.w.l; i++) - c65_write_mem(space, --dst.d, c65_read_mem(space, --src.d)); - } - } - else - { - for (i = 0; i < len.w.l; i++) - c65_write_mem(space, dst.d++, c65_read_mem(space, src.d++)); - } - break; - case 3: - DBG_LOG(space.machine(), 3,"dma fill job", - ("len:%.4x value:%.2x dst:%.6x sub:%.2x modrm:%.2x\n", - len.w.l, fill, dst.d, c65_read_mem(space, pair.d), - c65_read_mem(space, pair.d + 1))); - for (i = 0; i < len.w.l; i++) - c65_write_mem(space, dst.d++, fill); - break; - case 0x30: - DBG_LOG(space.machine(), 1,"dma copy down", - ("len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n", - len.w.l, src.d, dst.d, c65_read_mem(space, pair.d), - c65_read_mem(space, pair.d + 1) ) ); - for (i = 0; i < len.w.l; i++) - c65_write_mem(space, dst.d--,c65_read_mem(space, src.d--)); - break; - default: - DBG_LOG(space.machine(), 1,"dma job", - ("cmd:%.2x len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n", - cmd,len.w.l, src.d, dst.d, c65_read_mem(space, pair.d), - c65_read_mem(space, pair.d + 1))); - } - break; - default: - DBG_LOG(space.machine(), 1, "dma chip write", ("%.3x %.2x\n", offset, value)); - break; - } -} - -int c65_state::c65_dma_port_r( int offset ) -{ - /* offset 3 bit 7 in progress ? */ - DBG_LOG(machine(), 2, "dma chip read", ("%.3x\n", offset)); - return 0x7f; -} - -void c65_state::c65_6511_port_w( int offset, int value ) -{ - if (offset == 7) - { - m_6511_port = value; - } - DBG_LOG(machine(), 2, "r6511 write", ("%.2x %.2x\n", offset, value)); -} - -int c65_state::c65_6511_port_r( int offset ) -{ - int data = 0xff; - - if (offset == 7) - { - if (ioport("SPECIAL")->read() & 0x20) - data &= ~1; - } - DBG_LOG(machine(), 2, "r6511 read", ("%.2x\n", offset)); - - return data; -} - -/* one docu states custom 4191 disk controller - (for 2 1MB MFM disk drives, 1 internal, the other extern (optional) 1565 - with integrated 512 byte buffer - - 0->0 reset ? - - 0->1, 0->0, wait until 2 positiv, 1->0 ??? - - 0->0, 0 not 0 means no drive ???, other system entries - - - reg 0 write/read - 0,1 written - bit 1 set - bit 2 set - bit 3 set - bit 4 set - - - reg 0 read - bit 0 - bit 1 - bit 2 - 0..2 ->$1d4 - - reg 1 write - $01 written - $18 written - $46 written - $80 written - $a1 written - $01 written, dec - $10 written - - reg 2 read/write?(lsr) - bit 2 - bit 4 - bit 5 busy waiting until zero, then reading reg 7 - bit 6 operation not activ flag!? or set overflow pin used - bit 7 busy flag? - - reg 3 read/write?(rcr) - bit 1 - bit 3 - bit 7 busy flag? - - reg 4 - track?? - 0 written - read -> $1d2 - cmp #$50 - bcs - - - reg 5 - sector ?? - 1 written - read -> $1d3 - cmp #$b bcc - - - reg 6 - head ?? - 0 written - read -> $1d1 - cmp #2 bcc - - reg 7 read - #4e written - 12 times 0, a1 a1 a1 fe written - - reg 8 read - #ff written - 16 times #ff written - - reg 9 - #60 written - -might use the set overflow input - -$21a6c 9a6c format -$21c97 9c97 write operation -$21ca0 9ca0 get byte? -$21cab 9cab read reg 7 -$21caf 9caf write reg 7 -$21cb3 -*/ - -#define FDC_LOST 4 -#define FDC_CRC 8 -#define FDC_RNF 0x10 -#define FDC_BUSY 0x80 -#define FDC_IRQ 0x200 - -#define FDC_CMD_MOTOR_SPIN_UP 0x10 - -#if 0 -void c65_state::c65_fdc_state(void) -{ - switch (m_fdc.state) - { - case FDC_CMD_MOTOR_SPIN_UP: - if (machine().time() - m_fdc.time) - { - m_fdc.state = 0; - m_fdc.status &= ~FDC_BUSY; - } - break; - } -} -#endif - -void c65_state::c65_fdc_w( int offset, int data ) -{ - DBG_LOG(machine(), 1, "fdc write", ("%.5x %.2x %.2x\n", machine().device("maincpu")->safe_pc(), offset, data)); - switch (offset & 0xf) - { - case 0: - m_fdc.reg[0] = data; - break; - case 1: - m_fdc.reg[1] = data; - switch (data & 0xf9) - { - case 0x20: // wait for motor spin up - m_fdc.status &= ~(FDC_IRQ|FDC_LOST|FDC_CRC|FDC_RNF); - m_fdc.status |= FDC_BUSY; - m_fdc.time = machine().time(); - m_fdc.state = FDC_CMD_MOTOR_SPIN_UP; - break; - case 0: // cancel - m_fdc.status &= ~(FDC_BUSY); - m_fdc.state = 0; - break; - case 0x80: // buffered write - case 0x40: // buffered read - case 0x81: // unbuffered write - case 0x41: // unbuffered read - case 0x30:case 0x31: // step - break; - } - break; - case 2: case 3: // read only - break; - case 4: - m_fdc.reg[offset & 0xf] = data; - m_fdc.track = data; - break; - case 5: - m_fdc.reg[offset & 0xf] = data; - m_fdc.sector = data; - break; - case 6: - m_fdc.reg[offset & 0xf] = data; - m_fdc.head = data; - break; - case 7: - m_fdc.buffer[m_fdc.cpu_pos++] = data; - break; - default: - m_fdc.reg[offset & 0xf] = data; - break; - } -} - -int c65_state::c65_fdc_r( int offset ) -{ - UINT8 data = 0; - switch (offset & 0xf) - { - case 0: - data = m_fdc.reg[0]; - break; - case 1: - data = m_fdc.reg[1]; - break; - case 2: - data = m_fdc.status; - break; - case 3: - data = m_fdc.status >> 8; - break; - case 4: - data = m_fdc.track; - break; - case 5: - data = m_fdc.sector; - break; - case 6: - data = m_fdc.head; - break; - case 7: - data = m_fdc.buffer[m_fdc.cpu_pos++]; - break; - default: - data = m_fdc.reg[offset & 0xf]; - break; - } - DBG_LOG(machine(), 1, "fdc read", ("%.5x %.2x %.2x\n", machine().device("maincpu")->safe_pc(), offset, data)); - return data; -} - -/* version 1 ramcheck - write 0:0 - read write read write 80000,90000,f0000 - write 0:8 - read write read write 80000,90000,f0000 - - version 2 ramcheck??? - read 0: - write 0:0 - read 0: - first read and second read bit 0x80 set --> nothing - write 0:0 - read 0 - write 0:ff -*/ - -READ8_MEMBER( c65_state::c65_ram_expansion_r ) -{ - UINT8 data = 0xff; - if (m_ram->size() > (128 * 1024)) - data = m_expansion_ram.reg; - return data; -} - -WRITE8_MEMBER( c65_state::c65_ram_expansion_w ) -{ - offs_t expansion_ram_begin; - offs_t expansion_ram_end; - - if (m_ram->size() > (128 * 1024)) - { - m_expansion_ram.reg = data; - - expansion_ram_begin = 0x80000; - expansion_ram_end = 0x80000 + (m_ram->size() - 128*1024) - 1; - - if (data == 0x00) { - space.install_readwrite_bank(expansion_ram_begin, expansion_ram_end,"bank16"); - membank("bank16")->set_base(m_ram->pointer() + 128*1024); - } else { - space.nop_readwrite(expansion_ram_begin, expansion_ram_end); - } - } -} - -WRITE8_MEMBER( c65_state::c65_write_io ) -{ - mos6581_device *sid_0 = machine().device("sid_r"); - mos6581_device *sid_1 = machine().device("sid_l"); - vic3_device *vic3 = machine().device("vic3"); - - switch (offset & 0xf00) - { - case 0x000: - if (offset < 0x80) - vic3->port_w(space, offset & 0x7f, data); - else if (offset < 0xa0) - c65_fdc_w(offset & 0x1f, data); - else - { - c65_ram_expansion_w(space, offset & 0x1f, data, mem_mask); - /*ram expansion crtl optional */ - } - break; - case 0x100: - case 0x200: - case 0x300: - vic3->palette_w(space, offset - 0x100, data); - break; - case 0x400: - if (offset<0x420) /* maybe 0x20 */ - sid_0->write(space, offset & 0x3f, data); - else if (offset<0x440) - sid_1->write(space, offset & 0x3f, data); - else - DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset, data)); - break; - case 0x500: - DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset, data)); - break; - case 0x600: - c65_6511_port_w(offset & 0xff,data); - break; - case 0x700: - c65_dma_port_w(offset & 0xff, data); - break; - } -} - -WRITE8_MEMBER( c65_state::c65_write_io_dc00 ) -{ - switch (offset & 0xf00) - { - case 0x000: - m_cia0->write(space, offset, data); - break; - case 0x100: - m_cia1->write(space, offset, data); - break; - case 0x200: - case 0x300: - DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset+0xc00, data)); - break; - } -} - -READ8_MEMBER( c65_state::c65_read_io ) -{ - mos6581_device *sid_0 = machine().device("sid_r"); - mos6581_device *sid_1 = machine().device("sid_l"); - vic3_device *vic3 = machine().device("vic3"); - - switch (offset & 0xf00) - { - case 0x000: - if (offset < 0x80) - return vic3->port_r(space, offset & 0x7f); - if (offset < 0xa0) - return c65_fdc_r(offset & 0x1f); - else - { - return c65_ram_expansion_r(space, offset & 0x1f, mem_mask); - /*return; ram expansion crtl optional */ - } - case 0x100: - case 0x200: - case 0x300: - /* read only !? */ - DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset)); - break; - case 0x400: - if (offset < 0x420) - return sid_0->read(space, offset & 0x3f); - if (offset < 0x440) - return sid_1->read(space, offset & 0x3f); - DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset)); - break; - case 0x500: - DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset)); - break; - case 0x600: - return c65_6511_port_r(offset&0xff); - case 0x700: - return c65_dma_port_r(offset&0xff); - } - return 0xff; -} - -READ8_MEMBER( c65_state::c65_read_io_dc00 ) -{ - switch (offset & 0x300) - { - case 0x000: - return m_cia0->read(space, offset); - case 0x100: - return m_cia1->read(space, offset); - case 0x200: - case 0x300: - DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset+0xc00)); - break; - } - return 0xff; -} - - -/* -d02f: - init a5 96 written (seems to be switch to c65 or vic3 mode) - go64 0 written -*/ - -/* bit 1 external sync enable (genlock) - bit 2 palette enable - bit 6 vic3 c65 character set */ -WRITE8_MEMBER(c65_state::c65_bankswitch_interface) -{ - DBG_LOG(machine(), 2, "c65 bankswitch", ("%.2x\n",data)); - - if (m_io_on) - { - if (data & 1) - { - membank("bank8")->set_base(m_colorram + 0x400); - membank("bank9")->set_base(m_colorram + 0x400); - m_maincpu->space(AS_PROGRAM).install_read_bank(0x0dc00, 0x0dfff, "bank8"); - m_maincpu->space(AS_PROGRAM).install_write_bank(0x0dc00, 0x0dfff, "bank9"); - } - else - { - m_maincpu->space(AS_PROGRAM).install_read_handler(0x0dc00, 0x0dfff, read8_delegate(FUNC(c65_state::c65_read_io_dc00),this)); - m_maincpu->space(AS_PROGRAM).install_write_handler(0x0dc00, 0x0dfff, write8_delegate(FUNC(c65_state::c65_write_io_dc00),this)); - } - } - - m_io_dc00_on = !(data & 1); -#if 0 - /* cartridge roms !?*/ - if (data & 0x08) - membank("bank1")->set_base(m_roml); - else - membank("bank1")->set_base(m_memory + 0x8000); - - if (data & 0x10) - membank("bank2")->set_base(m_basic); - else - membank("bank2")->set_base(m_memory + 0xa000); -#endif - if ((m_old_value^data) & 0x20) - { - /* bankswitching faulty when doing actual page */ - if (data & 0x20) - membank("bank3")->set_base(m_basic); - else - membank("bank3")->set_base(m_memory + 0xc000); - } - m_charset_select = data & 0x40; -#if 0 - /* cartridge roms !?*/ - if (data & 0x80) - membank("bank8")->set_base(m_kernal); - else - membank("bank6")->set_base(m_memory + 0xe000); -#endif - m_old_value = data; -} - -void c65_state::c65_bankswitch( ) -{ - int data, loram, hiram, charen; - - data = 0x00; // machine().device("maincpu")->get_port(); - if (data == m_old_data) - return; - - DBG_LOG(machine(), 1, "bankswitch", ("%d\n", data & 7)); - loram = (data & 1) ? 1 : 0; - hiram = (data & 2) ? 1 : 0; - charen = (data & 4) ? 1 : 0; - - if ((!m_game && m_exrom) || (loram && hiram && !m_exrom)) - membank("bank1")->set_base(m_roml); - else - membank("bank1")->set_base(m_memory + 0x8000); - - if ((!m_game && m_exrom && hiram) || (!m_exrom)) - membank("bank2")->set_base(m_romh); - else if (loram && hiram) - membank("bank2")->set_base(m_basic); - else - membank("bank2")->set_base(m_memory + 0xa000); - - if ((!m_game && m_exrom) || (charen && (loram || hiram))) - { - m_io_on = 1; - membank("bank6")->set_base(m_colorram); - membank("bank7")->set_base(m_colorram); - - if (m_io_dc00_on) - { - m_maincpu->space(AS_PROGRAM).install_read_handler(0x0dc00, 0x0dfff, read8_delegate(FUNC(c65_state::c65_read_io_dc00),this)); - m_maincpu->space(AS_PROGRAM).install_write_handler(0x0dc00, 0x0dfff, write8_delegate(FUNC(c65_state::c65_write_io_dc00),this)); - } - else - { - m_maincpu->space(AS_PROGRAM).install_read_bank(0x0dc00, 0x0dfff, "bank8"); - m_maincpu->space(AS_PROGRAM).install_write_bank(0x0dc00, 0x0dfff, "bank9"); - membank("bank8")->set_base(m_colorram + 0x400); - membank("bank9")->set_base(m_colorram + 0x400); - } - m_maincpu->space(AS_PROGRAM).install_read_handler(0x0d000, 0x0d7ff, read8_delegate(FUNC(c65_state::c65_read_io),this)); - m_maincpu->space(AS_PROGRAM).install_write_handler(0x0d000, 0x0d7ff, write8_delegate(FUNC(c65_state::c65_write_io),this)); - } - else - { - m_io_on = 0; - membank("bank5")->set_base(m_memory + 0xd000); - membank("bank7")->set_base(m_memory + 0xd800); - membank("bank9")->set_base(m_memory + 0xdc00); - if (!charen && (loram || hiram)) - { - membank("bank4")->set_base(m_chargen); - membank("bank6")->set_base(m_chargen + 0x800); - membank("bank8")->set_base(m_chargen + 0xc00); - } - else - { - membank("bank4")->set_base(m_memory + 0xd000); - membank("bank6")->set_base(m_memory + 0xd800); - membank("bank8")->set_base(m_memory + 0xdc00); - } - m_maincpu->space(AS_PROGRAM).install_read_bank(0x0d000, 0x0d7ff, "bank4"); - m_maincpu->space(AS_PROGRAM).install_write_bank(0x0d000, 0x0d7ff, "bank5"); - } - - if (!m_game && m_exrom) - { - membank("bank10")->set_base(m_romh); - } - else - { - if (hiram) - { - membank("bank10")->set_base(m_kernal); - } - else - { - membank("bank10")->set_base(m_memory + 0xe000); - } - } - m_old_data = data; -} - -#ifdef UNUSED_FUNCTION -void c65_state::c65_colorram_write( int offset, int value ) -{ - m_colorram[offset & 0x7ff] = value | 0xf0; -} -#endif - -/* - * only 14 address lines - * a15 and a14 portlines - * 0x1000-0x1fff, 0x9000-0x9fff char rom - */ -READ8_MEMBER(c65_state::c65_dma_read) -{ - if (!m_game && m_exrom) - { - if (offset < 0x3000) - return m_memory[offset]; - return m_romh[offset & 0x1fff]; - } - if ((m_vicaddr == m_memory) || (m_vicaddr == m_memory + 0x8000)) - { - if (offset < 0x1000) - return m_vicaddr[offset & 0x3fff]; - if (offset < 0x2000) { - if (m_charset_select) - return m_chargen[offset & 0xfff]; - else - return m_chargen[offset & 0xfff]; - } - return m_vicaddr[offset & 0x3fff]; - } - return m_vicaddr[offset & 0x3fff]; -} - -READ8_MEMBER(c65_state::c65_dma_read_color) -{ - if (m_c64mode) - return m_colorram[offset & 0x3ff] & 0xf; - return m_colorram[offset & 0x7ff]; -} - -void c65_state::c65_common_driver_init( ) -{ - m_memory = auto_alloc_array_clear(machine(), UINT8, 0x10000); - membank("bank11")->set_base(m_memory + 0x00000); - membank("bank12")->set_base(m_memory + 0x08000); - membank("bank13")->set_base(m_memory + 0x0a000); - membank("bank14")->set_base(m_memory + 0x0c000); - membank("bank15")->set_base(m_memory + 0x0e000); - - cbm_common_init(); - m_keyline = 0xff; - - m_pal = 0; - m_charset_select = 0; - m_6511_port = 0xff; - m_vicirq = 0; - m_old_data = -1; - - /* C65 had no datasette port */ - m_tape_on = 0; - m_game = 1; - m_exrom = 1; - - /*memset(m_memory + 0x40000, 0, 0x800000 - 0x40000); */ -} - -DRIVER_INIT_MEMBER(c65_state,c65) -{ - m_dma.version = 2; - c65_common_driver_init(); -} - -DRIVER_INIT_MEMBER(c65_state,c65pal) -{ - m_dma.version = 1; - c65_common_driver_init(); - m_pal = 1; -} - -MACHINE_START_MEMBER(c65_state,c65) -{ - /* clear upper memory */ - memset(m_ram->pointer() + 128*1024, 0xff, m_ram->size() - 128*1024); - -//removed cbm_drive_0_config (SERIAL, 10); -//removed cbm_drive_1_config (SERIAL, 11); - m_vicaddr = m_memory; - - m_c64mode = 0; - - c65_bankswitch_interface(m_maincpu->space(AS_PROGRAM),0,0xff); - c65_bankswitch(); -} - - -INTERRUPT_GEN_MEMBER(c65_state::c65_frame_interrupt) -{ - int value; - - c65_nmi(); - - /* common keys input ports */ - cbm_common_interrupt(&device); - - /* c65 specific: function keys input ports */ - value = 0xff; - - value &= ~ioport("FUNCT")->read(); - m_keyline = value; -} diff --git a/src/mess/machine/macadb.c b/src/mess/machine/macadb.c index 05d7b32db3a..dd0dafa208f 100644 --- a/src/mess/machine/macadb.c +++ b/src/mess/machine/macadb.c @@ -427,7 +427,7 @@ void mac_state::adb_talk() { if(m_adb_keybuf_start == m_adb_keybuf_end) { - // printf("%s: buffer empty\n", __func__); + // printf("%s: buffer empty\n", __func__); m_adb_buffer[0] = 0xff; m_adb_buffer[1] = 0xff; } diff --git a/src/mess/machine/nes.c b/src/mess/machine/nes.c index b6cf0d1d086..8990fb6ae03 100644 --- a/src/mess/machine/nes.c +++ b/src/mess/machine/nes.c @@ -139,7 +139,7 @@ READ8_MEMBER(nes_state::fc_in0_r) // bit 0 to controller port ret |= m_ctrl1->read_bit0(); - // expansion port bits (in the original FC, P2 controller was hooked to these lines + // expansion port bits (in the original FC, P2 controller was hooked to these lines // too, so in principle some homebrew hardware modification could use the same // connection with P1 controller too) ret |= m_ctrl1->read_exp(0); @@ -160,7 +160,7 @@ READ8_MEMBER(nes_state::fc_in1_r) // bit 0 to controller port ret |= m_ctrl2->read_bit0(); - // expansion port bits (in the original FC, P2 controller was hooked to these lines + // expansion port bits (in the original FC, P2 controller was hooked to these lines // too, so in principle some homebrew hardware modification could use the same // connection with P1 controller too) ret |= m_ctrl1->read_exp(1); @@ -193,10 +193,10 @@ NESCTRL_BRIGHTPIXEL_CB(nes_state::bright_pixel) { // get the pixel at the gun position UINT32 pix = m_ppu->get_pixel(x, y); - + // get the color base from the ppu UINT32 color_base = m_ppu->get_colorbase(); - + // check if the cursor is over a bright pixel if ((pix == color_base + 0x20) || (pix == color_base + 0x30) || (pix == color_base + 0x33) || (pix == color_base + 0x34)) diff --git a/src/mess/mess.mak b/src/mess/mess.mak index b9d3c410084..146a498ad78 100644 --- a/src/mess/mess.mak +++ b/src/mess/mess.mak @@ -1088,7 +1088,7 @@ $(MESSOBJ)/cbm.a: \ $(MESS_DRIVERS)/c128.o \ $(MESS_DRIVERS)/c64.o \ $(MESS_DRIVERS)/c64dtv.o \ - $(MESS_DRIVERS)/c65.o $(MESS_MACHINE)/c65.o \ + $(MESS_DRIVERS)/c65.o \ $(MESS_DRIVERS)/c900.o \ $(MESS_DRIVERS)/cbm2.o \ $(MESS_DRIVERS)/clcd.o \ diff --git a/src/osd/modules/debugger/debug_module.h b/src/osd/modules/debugger/debug_module.h index 789e511e596..78b15aa41ef 100644 --- a/src/osd/modules/debugger/debug_module.h +++ b/src/osd/modules/debugger/debug_module.h @@ -20,11 +20,11 @@ class debug_module { public: - virtual ~debug_module() { } + virtual ~debug_module() { } - virtual void init_debugger(running_machine &machine) = 0; - virtual void wait_for_debugger(device_t &device, bool firststop) = 0; - virtual void debugger_update() = 0; + virtual void init_debugger(running_machine &machine) = 0; + virtual void wait_for_debugger(device_t &device, bool firststop) = 0; + virtual void debugger_update() = 0; }; diff --git a/src/osd/modules/debugger/debugint.c b/src/osd/modules/debugger/debugint.c index dcf9e80b3e7..3230e032bb8 100644 --- a/src/osd/modules/debugger/debugint.c +++ b/src/osd/modules/debugger/debugint.c @@ -27,23 +27,23 @@ class debug_internal : public osd_module, public debug_module { public: - debug_internal() - : osd_module(OSD_DEBUG_PROVIDER, "internal"), debug_module(), - m_machine(NULL) - { - } + debug_internal() + : osd_module(OSD_DEBUG_PROVIDER, "internal"), debug_module(), + m_machine(NULL) + { + } - virtual ~debug_internal() { } + virtual ~debug_internal() { } - virtual int init() { return 0;} - virtual void exit(); + virtual int init() { return 0;} + virtual void exit(); - virtual void init_debugger(running_machine &machine); - virtual void wait_for_debugger(device_t &device, bool firststop); - virtual void debugger_update(); + virtual void init_debugger(running_machine &machine); + virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); private: - running_machine *m_machine; + running_machine *m_machine; }; diff --git a/src/osd/modules/debugger/debugqt.c b/src/osd/modules/debugger/debugqt.c index bd1914e1d71..ce675a0180d 100644 --- a/src/osd/modules/debugger/debugqt.c +++ b/src/osd/modules/debugger/debugqt.c @@ -37,23 +37,23 @@ class debug_qt : public osd_module, public debug_module { public: - debug_qt() - : osd_module(OSD_DEBUG_PROVIDER, "qt"), debug_module(), - m_machine(NULL) - { - } + debug_qt() + : osd_module(OSD_DEBUG_PROVIDER, "qt"), debug_module(), + m_machine(NULL) + { + } - virtual ~debug_qt() { } + virtual ~debug_qt() { } - virtual int init() { return 0;} - virtual void exit() { } + virtual int init() { return 0;} + virtual void exit() { } - virtual void init_debugger(running_machine &machine); - virtual void wait_for_debugger(device_t &device, bool firststop); - virtual void debugger_update(); + virtual void init_debugger(running_machine &machine); + virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); private: - running_machine *m_machine; + running_machine *m_machine; }; //============================================================ @@ -357,7 +357,7 @@ void debug_qt::debugger_update() } #else /* SDLMAME_UNIX */ - MODULE_NOT_SUPPORTED(debug_qt, OSD_DEBUG_PROVIDER, "qt") + MODULE_NOT_SUPPORTED(debug_qt, OSD_DEBUG_PROVIDER, "qt") #endif MODULE_DEFINITION(DEBUG_QT, debug_qt) diff --git a/src/osd/modules/debugger/debugwin.c b/src/osd/modules/debugger/debugwin.c index 5d31bf3cbdc..658731bc09c 100644 --- a/src/osd/modules/debugger/debugwin.c +++ b/src/osd/modules/debugger/debugwin.c @@ -44,23 +44,23 @@ class debugger_windows : public osd_module, public debug_module { public: - debugger_windows() - : osd_module(OSD_DEBUG_PROVIDER, "windows"), debug_module(), - m_machine(NULL) - { - } + debugger_windows() + : osd_module(OSD_DEBUG_PROVIDER, "windows"), debug_module(), + m_machine(NULL) + { + } - virtual ~debugger_windows() { } + virtual ~debugger_windows() { } - virtual int init() { return 0;} - virtual void exit(); + virtual int init() { return 0;} + virtual void exit(); - virtual void init_debugger(running_machine &machine); - virtual void wait_for_debugger(device_t &device, bool firststop); - virtual void debugger_update(); + virtual void init_debugger(running_machine &machine); + virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); private: - running_machine *m_machine; + running_machine *m_machine; }; //============================================================ // PARAMETERS @@ -3094,7 +3094,7 @@ static void smart_show_all(BOOL show) smart_show_window(info->wnd, show); } #else /* not windows */ - MODULE_NOT_SUPPORTED(debugger_windows, OSD_DEBUG_PROVIDER, "windows") + MODULE_NOT_SUPPORTED(debugger_windows, OSD_DEBUG_PROVIDER, "windows") #endif MODULE_DEFINITION(DEBUG_WINDOWS, debugger_windows) diff --git a/src/osd/modules/debugger/none.c b/src/osd/modules/debugger/none.c index 41e51174f05..7fc671880fd 100644 --- a/src/osd/modules/debugger/none.c +++ b/src/osd/modules/debugger/none.c @@ -12,28 +12,28 @@ class debug_none : public osd_module, public debug_module { public: - debug_none() - : osd_module(OSD_DEBUG_PROVIDER, "none"), debug_module(), - m_machine(NULL) - { - } + debug_none() + : osd_module(OSD_DEBUG_PROVIDER, "none"), debug_module(), + m_machine(NULL) + { + } - virtual ~debug_none() { } + virtual ~debug_none() { } - virtual int init() { return 0;} - virtual void exit() { } + virtual int init() { return 0;} + virtual void exit() { } - virtual void init_debugger(running_machine &machine); - virtual void wait_for_debugger(device_t &device, bool firststop); - virtual void debugger_update(); + virtual void init_debugger(running_machine &machine); + virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); private: - running_machine *m_machine; + running_machine *m_machine; }; void debug_none::init_debugger(running_machine &machine) { - m_machine = &machine; + m_machine = &machine; } void debug_none::wait_for_debugger(device_t &device, bool firststop) diff --git a/src/osd/modules/font/font_module.h b/src/osd/modules/font/font_module.h index e5e5499a2f5..816b6fc839b 100644 --- a/src/osd/modules/font/font_module.h +++ b/src/osd/modules/font/font_module.h @@ -18,8 +18,8 @@ class font_module { public: - virtual ~font_module() { } - virtual osd_font *font_alloc() = 0; + virtual ~font_module() { } + virtual osd_font *font_alloc() = 0; }; diff --git a/src/osd/modules/font/font_none.c b/src/osd/modules/font/font_none.c index 4d6cdbe48c9..8f19e448be1 100644 --- a/src/osd/modules/font/font_none.c +++ b/src/osd/modules/font/font_none.c @@ -14,17 +14,17 @@ class osd_font_none : public osd_font { public: - virtual ~osd_font_none() {}; + virtual ~osd_font_none() {}; - virtual bool open(const char *font_path, const char *name, int &height); - virtual void close(); - virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); + virtual bool open(const char *font_path, const char *name, int &height); + virtual void close(); + virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); private: }; bool osd_font_none::open(const char *font_path, const char *_name, int &height) { - return false; + return false; } //------------------------------------------------- @@ -46,22 +46,21 @@ void osd_font_none::close() bool osd_font_none::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) { - return false; + return false; } class font_none : public osd_module, public font_module { public: - font_none() - : osd_module(OSD_FONT_PROVIDER, "none"), font_module() - { - } + font_none() + : osd_module(OSD_FONT_PROVIDER, "none"), font_module() + { + } - osd_font *font_alloc() - { - return global_alloc(osd_font_none); - } + osd_font *font_alloc() + { + return global_alloc(osd_font_none); + } }; MODULE_DEFINITION(FONT_NONE, font_none) - diff --git a/src/osd/modules/font/font_osx.c b/src/osd/modules/font/font_osx.c index 6e7e62acedf..e7e58b35ad9 100644 --- a/src/osd/modules/font/font_osx.c +++ b/src/osd/modules/font/font_osx.c @@ -26,71 +26,71 @@ class osd_font_osx : public osd_font { public: - virtual ~osd_font_osx() {}; + virtual ~osd_font_osx() {}; - virtual bool open(const char *font_path, const char *name, int &height); - virtual void close(); - virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); + virtual bool open(const char *font_path, const char *name, int &height); + virtual void close(); + virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); private: - CTFontRef m_font; + CTFontRef m_font; }; bool osd_font_osx::open(const char *font_path, const char *_name, int &height) { - CFStringRef font_name = NULL; - CTFontRef ct_font = NULL; - CTFontDescriptorRef font_descriptor; - CGAffineTransform affine_transform = CGAffineTransformIdentity; + CFStringRef font_name = NULL; + CTFontRef ct_font = NULL; + CTFontDescriptorRef font_descriptor; + CGAffineTransform affine_transform = CGAffineTransformIdentity; - m_font = NULL; - astring name(_name); - printf("FONT NAME %s\n", _name); + m_font = NULL; + astring name(_name); + printf("FONT NAME %s\n", _name); #if 0 - if (name == "default") - { - name = "LucidaGrande"; - } + if (name == "default") + { + name = "LucidaGrande"; + } #endif - /* handle bdf fonts in the core */ - if (name.len() > 4) - if (name.makeupper().substr(name.len()-4,4) == ".BDF" ) - return false; + /* handle bdf fonts in the core */ + if (name.len() > 4) + if (name.makeupper().substr(name.len()-4,4) == ".BDF" ) + return false; - font_name = CFStringCreateWithCString( NULL, name.cstr(), kCFStringEncodingUTF8 ); - if( font_name != NULL ) - { - font_descriptor = CTFontDescriptorCreateWithNameAndSize( font_name, 0.0); //POINT_SIZE ); + font_name = CFStringCreateWithCString( NULL, name.cstr(), kCFStringEncodingUTF8 ); + if( font_name != NULL ) + { + font_descriptor = CTFontDescriptorCreateWithNameAndSize( font_name, 0.0); //POINT_SIZE ); - if( font_descriptor != NULL ) - { - ct_font = CTFontCreateWithFontDescriptor( font_descriptor, POINT_SIZE, &affine_transform ); + if( font_descriptor != NULL ) + { + ct_font = CTFontCreateWithFontDescriptor( font_descriptor, POINT_SIZE, &affine_transform ); - CFRelease( font_descriptor ); - } - } + CFRelease( font_descriptor ); + } + } - CFRelease( font_name ); + CFRelease( font_name ); - if (!ct_font) - { - osd_printf_verbose("Couldn't find/open font %s, using MAME default\n", name.cstr()); - return false; - } + if (!ct_font) + { + osd_printf_verbose("Couldn't find/open font %s, using MAME default\n", name.cstr()); + return false; + } - CFStringRef real_name = CTFontCopyPostScriptName( ct_font ); - char real_name_c_string[255]; - CFStringGetCString ( real_name, real_name_c_string, 255, kCFStringEncodingUTF8 ); - osd_printf_verbose("Matching font: %s\n", real_name_c_string); - CFRelease( real_name ); + CFStringRef real_name = CTFontCopyPostScriptName( ct_font ); + char real_name_c_string[255]; + CFStringGetCString ( real_name, real_name_c_string, 255, kCFStringEncodingUTF8 ); + osd_printf_verbose("Matching font: %s\n", real_name_c_string); + CFRelease( real_name ); - CGFloat line_height = 0.0; - line_height += CTFontGetAscent(ct_font); - line_height += CTFontGetDescent(ct_font); - line_height += CTFontGetLeading(ct_font); - height = ceilf(line_height * EXTRA_HEIGHT); + CGFloat line_height = 0.0; + line_height += CTFontGetAscent(ct_font); + line_height += CTFontGetDescent(ct_font); + line_height += CTFontGetLeading(ct_font); + height = ceilf(line_height * EXTRA_HEIGHT); - m_font = ct_font; - return true; + m_font = ct_font; + return true; } //------------------------------------------------- @@ -100,10 +100,10 @@ bool osd_font_osx::open(const char *font_path, const char *_name, int &height) void osd_font_osx::close() { - if( m_font != NULL ) - { - CFRelease( m_font ); - } + if( m_font != NULL ) + { + CFRelease( m_font ); + } } //------------------------------------------------- @@ -116,88 +116,88 @@ void osd_font_osx::close() bool osd_font_osx::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) { - UniChar uni_char; - CGGlyph glyph; - CTFontRef ct_font = m_font; - const CFIndex count = 1; - CGRect bounding_rect, success_rect; - CGContextRef context_ref; + UniChar uni_char; + CGGlyph glyph; + CTFontRef ct_font = m_font; + const CFIndex count = 1; + CGRect bounding_rect, success_rect; + CGContextRef context_ref; - if( chnum == ' ' ) - { - uni_char = 'n'; - CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); - success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count ); - uni_char = chnum; - CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); - } - else - { - uni_char = chnum; - CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); - success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count ); - } + if( chnum == ' ' ) + { + uni_char = 'n'; + CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); + success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count ); + uni_char = chnum; + CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); + } + else + { + uni_char = chnum; + CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); + success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count ); + } - if( CGRectEqualToRect( success_rect, CGRectNull ) == false ) - { - size_t bitmap_width; - size_t bitmap_height; + if( CGRectEqualToRect( success_rect, CGRectNull ) == false ) + { + size_t bitmap_width; + size_t bitmap_height; - bitmap_width = ceilf(bounding_rect.size.width * EXTRA_WIDTH); - bitmap_width = bitmap_width == 0 ? 1 : bitmap_width; + bitmap_width = ceilf(bounding_rect.size.width * EXTRA_WIDTH); + bitmap_width = bitmap_width == 0 ? 1 : bitmap_width; - bitmap_height = ceilf( (CTFontGetAscent(ct_font) + CTFontGetDescent(ct_font) + CTFontGetLeading(ct_font)) * EXTRA_HEIGHT); + bitmap_height = ceilf( (CTFontGetAscent(ct_font) + CTFontGetDescent(ct_font) + CTFontGetLeading(ct_font)) * EXTRA_HEIGHT); - xoffs = yoffs = 0; - width = bitmap_width; + xoffs = yoffs = 0; + width = bitmap_width; - size_t bits_per_component; - CGColorSpaceRef color_space; - CGBitmapInfo bitmap_info = kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst; + size_t bits_per_component; + CGColorSpaceRef color_space; + CGBitmapInfo bitmap_info = kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst; - color_space = CGColorSpaceCreateDeviceRGB(); - bits_per_component = 8; + color_space = CGColorSpaceCreateDeviceRGB(); + bits_per_component = 8; - bitmap.allocate(bitmap_width, bitmap_height); + bitmap.allocate(bitmap_width, bitmap_height); - context_ref = CGBitmapContextCreate( bitmap.raw_pixptr(0), bitmap_width, bitmap_height, bits_per_component, bitmap.rowpixels()*4, color_space, bitmap_info ); + context_ref = CGBitmapContextCreate( bitmap.raw_pixptr(0), bitmap_width, bitmap_height, bits_per_component, bitmap.rowpixels()*4, color_space, bitmap_info ); - if( context_ref != NULL ) - { - CGFontRef font_ref; - font_ref = CTFontCopyGraphicsFont( ct_font, NULL ); - CGContextSetTextPosition(context_ref, -bounding_rect.origin.x*EXTRA_WIDTH, CTFontGetDescent(ct_font)+CTFontGetLeading(ct_font) ); - CGContextSetRGBFillColor(context_ref, 1.0, 1.0, 1.0, 1.0); - CGContextSetFont( context_ref, font_ref ); - CGContextSetFontSize( context_ref, POINT_SIZE ); - CGContextShowGlyphs( context_ref, &glyph, count ); - CGFontRelease( font_ref ); - CGContextRelease( context_ref ); - } + if( context_ref != NULL ) + { + CGFontRef font_ref; + font_ref = CTFontCopyGraphicsFont( ct_font, NULL ); + CGContextSetTextPosition(context_ref, -bounding_rect.origin.x*EXTRA_WIDTH, CTFontGetDescent(ct_font)+CTFontGetLeading(ct_font) ); + CGContextSetRGBFillColor(context_ref, 1.0, 1.0, 1.0, 1.0); + CGContextSetFont( context_ref, font_ref ); + CGContextSetFontSize( context_ref, POINT_SIZE ); + CGContextShowGlyphs( context_ref, &glyph, count ); + CGFontRelease( font_ref ); + CGContextRelease( context_ref ); + } - CGColorSpaceRelease( color_space ); - } + CGColorSpaceRelease( color_space ); + } - return bitmap.valid(); + return bitmap.valid(); } class font_osx : public osd_module, public font_module { public: - font_osx() - : osd_module(OSD_FONT_PROVIDER, "osx"), font_module() - { - } + font_osx() + : osd_module(OSD_FONT_PROVIDER, "osx"), font_module() + { + } - osd_font *font_alloc() - { - return global_alloc(osd_font_osx); - } + osd_font *font_alloc() + { + return global_alloc(osd_font_osx); + } }; #else /* SDLMAME_UNIX */ - MODULE_NOT_SUPPORTED(font_osx, OSD_FONT_PROVIDER, "osx") + MODULE_NOT_SUPPORTED(font_osx, OSD_FONT_PROVIDER, "osx") #endif MODULE_DEFINITION(FONT_OSX, font_osx) diff --git a/src/osd/modules/font/font_sdl.c b/src/osd/modules/font/font_sdl.c index 6ae72ca4fb3..d10f7209ab1 100644 --- a/src/osd/modules/font/font_sdl.c +++ b/src/osd/modules/font/font_sdl.c @@ -32,95 +32,95 @@ class osd_font_sdl : public osd_font { public: - virtual ~osd_font_sdl() {}; + virtual ~osd_font_sdl() {}; - virtual bool open(const char *font_path, const char *name, int &height); - virtual void close(); - virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); + virtual bool open(const char *font_path, const char *name, int &height); + virtual void close(); + virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); private: #ifndef SDLMAME_HAIKU - TTF_Font *search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles); + TTF_Font *search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles); #endif - bool BDF_Check_Magic(astring name); - TTF_Font * TTF_OpenFont_Magic(astring name, int fsize); - TTF_Font *m_font; + bool BDF_Check_Magic(astring name); + TTF_Font * TTF_OpenFont_Magic(astring name, int fsize); + TTF_Font *m_font; }; bool osd_font_sdl::open(const char *font_path, const char *_name, int &height) { - TTF_Font *font = (TTF_Font *)NULL; - bool bakedstyles = false; - int style = 0; + TTF_Font *font = (TTF_Font *)NULL; + bool bakedstyles = false; + int style = 0; - // accept qualifiers from the name - astring name(_name); + // accept qualifiers from the name + astring name(_name); - if (name == "default") - { - name = "Liberation Sans"; - } + if (name == "default") + { + name = "Liberation Sans"; + } - bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0); - bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0); - bool underline = (name.replace(0, "[U]", "") + name.replace(0, "[u]", "") > 0); - bool strike = (name.replace(0, "[S]", "") + name.replace(0, "[s]", "") > 0); + bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0); + bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0); + bool underline = (name.replace(0, "[U]", "") + name.replace(0, "[u]", "") > 0); + bool strike = (name.replace(0, "[S]", "") + name.replace(0, "[s]", "") > 0); - // first up, try it as a filename - font = TTF_OpenFont_Magic(name, POINT_SIZE); + // first up, try it as a filename + font = TTF_OpenFont_Magic(name, POINT_SIZE); - // if no success, try the font path + // if no success, try the font path - if (!font) - { - osd_printf_verbose("Searching font %s in -%s\n", name.cstr(), OPTION_FONTPATH); - //emu_file file(options().font_path(), OPEN_FLAG_READ); - emu_file file(font_path, OPEN_FLAG_READ); - if (file.open(name) == FILERR_NONE) - { - astring full_name = file.fullpath(); - font = TTF_OpenFont_Magic(full_name, POINT_SIZE); - if (font) - osd_printf_verbose("Found font %s\n", full_name.cstr()); - } - } + if (!font) + { + osd_printf_verbose("Searching font %s in -%s\n", name.cstr(), OPTION_FONTPATH); + //emu_file file(options().font_path(), OPEN_FLAG_READ); + emu_file file(font_path, OPEN_FLAG_READ); + if (file.open(name) == FILERR_NONE) + { + astring full_name = file.fullpath(); + font = TTF_OpenFont_Magic(full_name, POINT_SIZE); + if (font) + osd_printf_verbose("Found font %s\n", full_name.cstr()); + } + } - // if that didn't work, crank up the FontConfig database + // if that didn't work, crank up the FontConfig database #ifndef SDLMAME_HAIKU - if (!font) - { - font = search_font_config(name, bold, italic, underline, bakedstyles); - } + if (!font) + { + font = search_font_config(name, bold, italic, underline, bakedstyles); + } #endif - if (!font) - { - if (!BDF_Check_Magic(name)) - { - osd_printf_verbose("font %s is not TrueType or BDF, using MAME default\n", name.cstr()); - } - return NULL; - } + if (!font) + { + if (!BDF_Check_Magic(name)) + { + osd_printf_verbose("font %s is not TrueType or BDF, using MAME default\n", name.cstr()); + } + return NULL; + } - // apply styles - if (!bakedstyles) - { - style |= bold ? TTF_STYLE_BOLD : 0; - style |= italic ? TTF_STYLE_ITALIC : 0; - } - style |= underline ? TTF_STYLE_UNDERLINE : 0; - // SDL_ttf 2.0.9 and earlier does not define TTF_STYLE_STRIKETHROUGH + // apply styles + if (!bakedstyles) + { + style |= bold ? TTF_STYLE_BOLD : 0; + style |= italic ? TTF_STYLE_ITALIC : 0; + } + style |= underline ? TTF_STYLE_UNDERLINE : 0; + // SDL_ttf 2.0.9 and earlier does not define TTF_STYLE_STRIKETHROUGH #if SDL_VERSIONNUM(TTF_MAJOR_VERSION, TTF_MINOR_VERSION, TTF_PATCHLEVEL) > SDL_VERSIONNUM(2,0,9) - style |= strike ? TTF_STYLE_STRIKETHROUGH : 0; + style |= strike ? TTF_STYLE_STRIKETHROUGH : 0; #else - if (strike) - osd_printf_warning("Ignoring strikethrough for SDL_TTF older than 2.0.10\n"); + if (strike) + osd_printf_warning("Ignoring strikethrough for SDL_TTF older than 2.0.10\n"); #endif // PATCHLEVEL - TTF_SetFontStyle(font, style); + TTF_SetFontStyle(font, style); - height = TTF_FontLineSkip(font); + height = TTF_FontLineSkip(font); - m_font = font; - return true; + m_font = font; + return true; } //------------------------------------------------- @@ -130,7 +130,7 @@ bool osd_font_sdl::open(const char *font_path, const char *_name, int &height) void osd_font_sdl::close() { - TTF_CloseFont(this->m_font); + TTF_CloseFont(this->m_font); } //------------------------------------------------- @@ -143,184 +143,184 @@ void osd_font_sdl::close() bool osd_font_sdl::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) { - TTF_Font *ttffont; - SDL_Surface *drawsurf; - SDL_Color fcol = { 0xff, 0xff, 0xff }; - UINT16 ustr[16]; + TTF_Font *ttffont; + SDL_Surface *drawsurf; + SDL_Color fcol = { 0xff, 0xff, 0xff }; + UINT16 ustr[16]; - ttffont = m_font; + ttffont = m_font; - memset(ustr,0,sizeof(ustr)); - ustr[0] = (UINT16)chnum; - drawsurf = TTF_RenderUNICODE_Solid(ttffont, ustr, fcol); + memset(ustr,0,sizeof(ustr)); + ustr[0] = (UINT16)chnum; + drawsurf = TTF_RenderUNICODE_Solid(ttffont, ustr, fcol); - // was nothing returned? - if (drawsurf) - { - // allocate a MAME destination bitmap - bitmap.allocate(drawsurf->w, drawsurf->h); + // was nothing returned? + if (drawsurf) + { + // allocate a MAME destination bitmap + bitmap.allocate(drawsurf->w, drawsurf->h); - // copy the rendered character image into it - for (int y = 0; y < bitmap.height(); y++) - { - UINT32 *dstrow = &bitmap.pix32(y); - UINT8 *srcrow = (UINT8 *)drawsurf->pixels; + // copy the rendered character image into it + for (int y = 0; y < bitmap.height(); y++) + { + UINT32 *dstrow = &bitmap.pix32(y); + UINT8 *srcrow = (UINT8 *)drawsurf->pixels; - srcrow += (y * drawsurf->pitch); + srcrow += (y * drawsurf->pitch); - for (int x = 0; x < drawsurf->w; x++) - { - dstrow[x] = srcrow[x] ? rgb_t(0xff,0xff,0xff,0xff) : rgb_t(0x00,0xff,0xff,0xff); - } - } + for (int x = 0; x < drawsurf->w; x++) + { + dstrow[x] = srcrow[x] ? rgb_t(0xff,0xff,0xff,0xff) : rgb_t(0x00,0xff,0xff,0xff); + } + } - // what are these? - xoffs = yoffs = 0; - width = drawsurf->w; + // what are these? + xoffs = yoffs = 0; + width = drawsurf->w; - SDL_FreeSurface(drawsurf); - } + SDL_FreeSurface(drawsurf); + } - return bitmap.valid(); + return bitmap.valid(); } TTF_Font * osd_font_sdl::TTF_OpenFont_Magic(astring name, int fsize) { - emu_file file(OPEN_FLAG_READ); - if (file.open(name) == FILERR_NONE) - { - unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff }; - unsigned char magic[5] = { 0x00, 0x01, 0x00, 0x00, 0x00 }; - file.read(buffer,5); - if (memcmp(buffer, magic, 5)) - return NULL; - } - return TTF_OpenFont(name.cstr(), POINT_SIZE); + emu_file file(OPEN_FLAG_READ); + if (file.open(name) == FILERR_NONE) + { + unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff }; + unsigned char magic[5] = { 0x00, 0x01, 0x00, 0x00, 0x00 }; + file.read(buffer,5); + if (memcmp(buffer, magic, 5)) + return NULL; + } + return TTF_OpenFont(name.cstr(), POINT_SIZE); } bool osd_font_sdl::BDF_Check_Magic(astring name) { - emu_file file(OPEN_FLAG_READ); - if (file.open(name) == FILERR_NONE) - { - unsigned char buffer[9]; - unsigned char magic[9] = { 'S', 'T', 'A', 'R', 'T', 'F', 'O', 'N', 'T' }; - file.read(buffer, 9); - file.close(); - if (!memcmp(buffer, magic, 9)) - return true; - } + emu_file file(OPEN_FLAG_READ); + if (file.open(name) == FILERR_NONE) + { + unsigned char buffer[9]; + unsigned char magic[9] = { 'S', 'T', 'A', 'R', 'T', 'F', 'O', 'N', 'T' }; + file.read(buffer, 9); + file.close(); + if (!memcmp(buffer, magic, 9)) + return true; + } - return false; + return false; } #ifndef SDLMAME_HAIKU TTF_Font *osd_font_sdl::search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles) { - TTF_Font *font = (TTF_Font *)NULL; - FcConfig *config; - FcPattern *pat; - FcObjectSet *os; - FcFontSet *fontset; - FcValue val; + TTF_Font *font = (TTF_Font *)NULL; + FcConfig *config; + FcPattern *pat; + FcObjectSet *os; + FcFontSet *fontset; + FcValue val; - config = FcConfigGetCurrent(); - pat = FcPatternCreate(); - os = FcObjectSetCreate(); - FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr()); + config = FcConfigGetCurrent(); + pat = FcPatternCreate(); + os = FcObjectSetCreate(); + FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr()); - // try and get a font with the requested styles baked-in - if (bold) - { - if (italic) - { - FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold Italic"); - } - else - { - FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold"); - } - } - else if (italic) - { - FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Italic"); - } - else - { - FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular"); - } + // try and get a font with the requested styles baked-in + if (bold) + { + if (italic) + { + FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold Italic"); + } + else + { + FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold"); + } + } + else if (italic) + { + FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Italic"); + } + else + { + FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular"); + } - FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType"); + FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType"); - FcObjectSetAdd(os, FC_FILE); - fontset = FcFontList(config, pat, os); + FcObjectSetAdd(os, FC_FILE); + fontset = FcFontList(config, pat, os); - for (int i = 0; i < fontset->nfont; i++) - { - if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch) - { - continue; - } + for (int i = 0; i < fontset->nfont; i++) + { + if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch) + { + continue; + } - if (val.type != FcTypeString) - { - continue; - } + if (val.type != FcTypeString) + { + continue; + } - osd_printf_verbose("Matching font: %s\n", val.u.s); - { - astring match_name((const char*)val.u.s); - font = TTF_OpenFont_Magic(match_name, POINT_SIZE); - } + osd_printf_verbose("Matching font: %s\n", val.u.s); + { + astring match_name((const char*)val.u.s); + font = TTF_OpenFont_Magic(match_name, POINT_SIZE); + } - if (font) - { - bakedstyles = true; - break; - } - } + if (font) + { + bakedstyles = true; + break; + } + } - // didn't get a font above? try again with no baked-in styles - if (!font) - { - FcPatternDestroy(pat); - FcFontSetDestroy(fontset); + // didn't get a font above? try again with no baked-in styles + if (!font) + { + FcPatternDestroy(pat); + FcFontSetDestroy(fontset); - pat = FcPatternCreate(); - FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr()); - FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular"); - FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType"); - fontset = FcFontList(config, pat, os); + pat = FcPatternCreate(); + FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr()); + FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular"); + FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType"); + fontset = FcFontList(config, pat, os); - for (int i = 0; i < fontset->nfont; i++) - { - if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch) - { - continue; - } + for (int i = 0; i < fontset->nfont; i++) + { + if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch) + { + continue; + } - if (val.type != FcTypeString) - { - continue; - } + if (val.type != FcTypeString) + { + continue; + } - osd_printf_verbose("Matching unstyled font: %s\n", val.u.s); - { - astring match_name((const char*)val.u.s); - font = TTF_OpenFont_Magic(match_name, POINT_SIZE); - } + osd_printf_verbose("Matching unstyled font: %s\n", val.u.s); + { + astring match_name((const char*)val.u.s); + font = TTF_OpenFont_Magic(match_name, POINT_SIZE); + } - if (font) - { - break; - } - } - } + if (font) + { + break; + } + } + } - FcPatternDestroy(pat); - FcObjectSetDestroy(os); - FcFontSetDestroy(fontset); - return font; + FcPatternDestroy(pat); + FcObjectSetDestroy(os); + FcFontSetDestroy(fontset); + return font; } #endif @@ -328,35 +328,33 @@ TTF_Font *osd_font_sdl::search_font_config(astring name, bool bold, bool italic, class font_sdl : public osd_module, public font_module { public: - font_sdl() - : osd_module(OSD_FONT_PROVIDER, "sdl"), font_module() - { - } + font_sdl() + : osd_module(OSD_FONT_PROVIDER, "sdl"), font_module() + { + } - osd_font *font_alloc() - { - return global_alloc(osd_font_sdl); - } + osd_font *font_alloc() + { + return global_alloc(osd_font_sdl); + } - int init() - { - if (TTF_Init() == -1) - { - osd_printf_error("SDL_ttf failed: %s\n", TTF_GetError()); - return -1; - } - return 0; - } + int init() + { + if (TTF_Init() == -1) + { + osd_printf_error("SDL_ttf failed: %s\n", TTF_GetError()); + return -1; + } + return 0; + } - virtual void exit() - { - TTF_Quit(); - } + virtual void exit() + { + TTF_Quit(); + } }; #else /* SDLMAME_UNIX */ - MODULE_NOT_SUPPORTED(font_sdl, OSD_FONT_PROVIDER, "sdl") + MODULE_NOT_SUPPORTED(font_sdl, OSD_FONT_PROVIDER, "sdl") #endif MODULE_DEFINITION(FONT_SDL, font_sdl) - - diff --git a/src/osd/modules/font/font_windows.c b/src/osd/modules/font/font_windows.c index 054ef077148..458534f3a74 100644 --- a/src/osd/modules/font/font_windows.c +++ b/src/osd/modules/font/font_windows.c @@ -34,72 +34,72 @@ class osd_font_windows : public osd_font { public: - virtual ~osd_font_windows() {}; + virtual ~osd_font_windows() {}; - virtual bool open(const char *font_path, const char *name, int &height); - virtual void close(); - virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); + virtual bool open(const char *font_path, const char *name, int &height); + virtual void close(); + virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); private: - HGDIOBJ m_font; + HGDIOBJ m_font; }; bool osd_font_windows::open(const char *font_path, const char *_name, int &height) { - // accept qualifiers from the name - astring name(_name); - if (name == "default") name = "Tahoma"; - bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0); - bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0); + // accept qualifiers from the name + astring name(_name); + if (name == "default") name = "Tahoma"; + bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0); + bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0); - // build a basic LOGFONT description of what we want - LOGFONT logfont; - logfont.lfHeight = DEFAULT_FONT_HEIGHT; - logfont.lfWidth = 0; - logfont.lfEscapement = 0; - logfont.lfOrientation = 0; - logfont.lfWeight = bold ? FW_BOLD : FW_MEDIUM; - logfont.lfItalic = italic; - logfont.lfUnderline = FALSE; - logfont.lfStrikeOut = FALSE; - logfont.lfCharSet = ANSI_CHARSET; - logfont.lfOutPrecision = OUT_DEFAULT_PRECIS; - logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; - logfont.lfQuality = NONANTIALIASED_QUALITY; - logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; + // build a basic LOGFONT description of what we want + LOGFONT logfont; + logfont.lfHeight = DEFAULT_FONT_HEIGHT; + logfont.lfWidth = 0; + logfont.lfEscapement = 0; + logfont.lfOrientation = 0; + logfont.lfWeight = bold ? FW_BOLD : FW_MEDIUM; + logfont.lfItalic = italic; + logfont.lfUnderline = FALSE; + logfont.lfStrikeOut = FALSE; + logfont.lfCharSet = ANSI_CHARSET; + logfont.lfOutPrecision = OUT_DEFAULT_PRECIS; + logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; + logfont.lfQuality = NONANTIALIASED_QUALITY; + logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - // copy in the face name - TCHAR *face = tstring_from_utf8(name); - _tcsncpy(logfont.lfFaceName, face, sizeof(logfont.lfFaceName) / sizeof(TCHAR)); - logfont.lfFaceName[sizeof(logfont.lfFaceName) / sizeof(TCHAR)-1] = 0; - osd_free(face); + // copy in the face name + TCHAR *face = tstring_from_utf8(name); + _tcsncpy(logfont.lfFaceName, face, sizeof(logfont.lfFaceName) / sizeof(TCHAR)); + logfont.lfFaceName[sizeof(logfont.lfFaceName) / sizeof(TCHAR)-1] = 0; + osd_free(face); - // create the font - height = logfont.lfHeight; - m_font = CreateFontIndirect(&logfont); - if (m_font == NULL) - return false; + // create the font + height = logfont.lfHeight; + m_font = CreateFontIndirect(&logfont); + if (m_font == NULL) + return false; - // select it into a temp DC and get the real font name - HDC dummyDC = CreateCompatibleDC(NULL); - HGDIOBJ oldfont = SelectObject(dummyDC, m_font); - TCHAR realname[100]; - GetTextFace(dummyDC, ARRAY_LENGTH(realname), realname); - SelectObject(dummyDC, oldfont); - DeleteDC(dummyDC); + // select it into a temp DC and get the real font name + HDC dummyDC = CreateCompatibleDC(NULL); + HGDIOBJ oldfont = SelectObject(dummyDC, m_font); + TCHAR realname[100]; + GetTextFace(dummyDC, ARRAY_LENGTH(realname), realname); + SelectObject(dummyDC, oldfont); + DeleteDC(dummyDC); - // if it doesn't match our request, fail - char *utf = utf8_from_tstring(realname); - int result = core_stricmp(utf, name); - osd_free(utf); + // if it doesn't match our request, fail + char *utf = utf8_from_tstring(realname); + int result = core_stricmp(utf, name); + osd_free(utf); - // if we didn't match, nuke our font and fall back - if (result != 0) - { - DeleteObject(m_font); - m_font = NULL; - return false; - } - return true; + // if we didn't match, nuke our font and fall back + if (result != 0) + { + DeleteObject(m_font); + m_font = NULL; + return false; + } + return true; } //------------------------------------------------- @@ -109,9 +109,9 @@ bool osd_font_windows::open(const char *font_path, const char *_name, int &heigh void osd_font_windows::close() { - // delete the font ojbect - if (m_font != NULL) - DeleteObject(m_font); + // delete the font ojbect + if (m_font != NULL) + DeleteObject(m_font); } @@ -125,155 +125,155 @@ void osd_font_windows::close() bool osd_font_windows::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) { - // create a dummy DC to work with - HDC dummyDC = CreateCompatibleDC(NULL); - HGDIOBJ oldfont = SelectObject(dummyDC, m_font); + // create a dummy DC to work with + HDC dummyDC = CreateCompatibleDC(NULL); + HGDIOBJ oldfont = SelectObject(dummyDC, m_font); - // get the text metrics - TEXTMETRIC metrics = { 0 }; - GetTextMetrics(dummyDC, &metrics); + // get the text metrics + TEXTMETRIC metrics = { 0 }; + GetTextMetrics(dummyDC, &metrics); - // get the width of this character - ABC abc; - if (!GetCharABCWidths(dummyDC, chnum, chnum, &abc)) - { - abc.abcA = 0; - abc.abcC = 0; - GetCharWidth32(dummyDC, chnum, chnum, reinterpret_cast(&abc.abcB)); - } - width = abc.abcA + abc.abcB + abc.abcC; + // get the width of this character + ABC abc; + if (!GetCharABCWidths(dummyDC, chnum, chnum, &abc)) + { + abc.abcA = 0; + abc.abcC = 0; + GetCharWidth32(dummyDC, chnum, chnum, reinterpret_cast(&abc.abcB)); + } + width = abc.abcA + abc.abcB + abc.abcC; - // determine desired bitmap size - int bmwidth = (50 + abc.abcA + abc.abcB + abc.abcC + 50 + 31) & ~31; - int bmheight = 50 + metrics.tmHeight + 50; + // determine desired bitmap size + int bmwidth = (50 + abc.abcA + abc.abcB + abc.abcC + 50 + 31) & ~31; + int bmheight = 50 + metrics.tmHeight + 50; - // describe the bitmap we want - BYTE bitmapinfodata[sizeof(BITMAPINFOHEADER)+2 * sizeof(RGBQUAD)] = { 0 }; - BITMAPINFO &info = *reinterpret_cast(bitmapinfodata); - info.bmiHeader.biSize = sizeof(info.bmiHeader); - info.bmiHeader.biWidth = bmwidth; - info.bmiHeader.biHeight = -bmheight; - info.bmiHeader.biPlanes = 1; - info.bmiHeader.biBitCount = 1; - info.bmiHeader.biCompression = BI_RGB; - info.bmiHeader.biSizeImage = 0; - info.bmiHeader.biXPelsPerMeter = GetDeviceCaps(dummyDC, HORZRES) / GetDeviceCaps(dummyDC, HORZSIZE); - info.bmiHeader.biYPelsPerMeter = GetDeviceCaps(dummyDC, VERTRES) / GetDeviceCaps(dummyDC, VERTSIZE); - info.bmiHeader.biClrUsed = 0; - info.bmiHeader.biClrImportant = 0; - RGBQUAD col1 = info.bmiColors[0]; - RGBQUAD col2 = info.bmiColors[1]; - col1.rgbBlue = col1.rgbGreen = col1.rgbRed = 0x00; - col2.rgbBlue = col2.rgbGreen = col2.rgbRed = 0xff; + // describe the bitmap we want + BYTE bitmapinfodata[sizeof(BITMAPINFOHEADER)+2 * sizeof(RGBQUAD)] = { 0 }; + BITMAPINFO &info = *reinterpret_cast(bitmapinfodata); + info.bmiHeader.biSize = sizeof(info.bmiHeader); + info.bmiHeader.biWidth = bmwidth; + info.bmiHeader.biHeight = -bmheight; + info.bmiHeader.biPlanes = 1; + info.bmiHeader.biBitCount = 1; + info.bmiHeader.biCompression = BI_RGB; + info.bmiHeader.biSizeImage = 0; + info.bmiHeader.biXPelsPerMeter = GetDeviceCaps(dummyDC, HORZRES) / GetDeviceCaps(dummyDC, HORZSIZE); + info.bmiHeader.biYPelsPerMeter = GetDeviceCaps(dummyDC, VERTRES) / GetDeviceCaps(dummyDC, VERTSIZE); + info.bmiHeader.biClrUsed = 0; + info.bmiHeader.biClrImportant = 0; + RGBQUAD col1 = info.bmiColors[0]; + RGBQUAD col2 = info.bmiColors[1]; + col1.rgbBlue = col1.rgbGreen = col1.rgbRed = 0x00; + col2.rgbBlue = col2.rgbGreen = col2.rgbRed = 0xff; - // create a DIB to render to - BYTE *bits; - HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast(&bits), NULL, 0); - HGDIOBJ oldbitmap = SelectObject(dummyDC, dib); + // create a DIB to render to + BYTE *bits; + HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast(&bits), NULL, 0); + HGDIOBJ oldbitmap = SelectObject(dummyDC, dib); - // clear the bitmap - int rowbytes = bmwidth / 8; - memset(bits, 0, rowbytes * bmheight); + // clear the bitmap + int rowbytes = bmwidth / 8; + memset(bits, 0, rowbytes * bmheight); - // now draw the character - WCHAR tempchar = chnum; - SetTextColor(dummyDC, RGB(0xff, 0xff, 0xff)); - SetBkColor(dummyDC, RGB(0x00, 0x00, 0x00)); - ExtTextOutW(dummyDC, 50 + abc.abcA, 50, ETO_OPAQUE, NULL, &tempchar, 1, NULL); + // now draw the character + WCHAR tempchar = chnum; + SetTextColor(dummyDC, RGB(0xff, 0xff, 0xff)); + SetBkColor(dummyDC, RGB(0x00, 0x00, 0x00)); + ExtTextOutW(dummyDC, 50 + abc.abcA, 50, ETO_OPAQUE, NULL, &tempchar, 1, NULL); - // characters are expected to be full-height - rectangle actbounds; - actbounds.min_y = 50; - actbounds.max_y = 50 + metrics.tmHeight - 1; + // characters are expected to be full-height + rectangle actbounds; + actbounds.min_y = 50; + actbounds.max_y = 50 + metrics.tmHeight - 1; - // determine the actual left of the character - for (actbounds.min_x = 0; actbounds.min_x < rowbytes; actbounds.min_x++) - { - BYTE *offs = bits + actbounds.min_x; - UINT8 summary = 0; - for (int y = 0; y < bmheight; y++) - summary |= offs[y * rowbytes]; - if (summary != 0) - { - actbounds.min_x *= 8; - if (!(summary & 0x80)) actbounds.min_x++; - if (!(summary & 0xc0)) actbounds.min_x++; - if (!(summary & 0xe0)) actbounds.min_x++; - if (!(summary & 0xf0)) actbounds.min_x++; - if (!(summary & 0xf8)) actbounds.min_x++; - if (!(summary & 0xfc)) actbounds.min_x++; - if (!(summary & 0xfe)) actbounds.min_x++; - break; - } - } + // determine the actual left of the character + for (actbounds.min_x = 0; actbounds.min_x < rowbytes; actbounds.min_x++) + { + BYTE *offs = bits + actbounds.min_x; + UINT8 summary = 0; + for (int y = 0; y < bmheight; y++) + summary |= offs[y * rowbytes]; + if (summary != 0) + { + actbounds.min_x *= 8; + if (!(summary & 0x80)) actbounds.min_x++; + if (!(summary & 0xc0)) actbounds.min_x++; + if (!(summary & 0xe0)) actbounds.min_x++; + if (!(summary & 0xf0)) actbounds.min_x++; + if (!(summary & 0xf8)) actbounds.min_x++; + if (!(summary & 0xfc)) actbounds.min_x++; + if (!(summary & 0xfe)) actbounds.min_x++; + break; + } + } - // determine the actual right of the character - for (actbounds.max_x = rowbytes - 1; actbounds.max_x >= 0; actbounds.max_x--) - { - BYTE *offs = bits + actbounds.max_x; - UINT8 summary = 0; - for (int y = 0; y < bmheight; y++) - summary |= offs[y * rowbytes]; - if (summary != 0) - { - actbounds.max_x *= 8; - if (summary & 0x7f) actbounds.max_x++; - if (summary & 0x3f) actbounds.max_x++; - if (summary & 0x1f) actbounds.max_x++; - if (summary & 0x0f) actbounds.max_x++; - if (summary & 0x07) actbounds.max_x++; - if (summary & 0x03) actbounds.max_x++; - if (summary & 0x01) actbounds.max_x++; - break; - } - } + // determine the actual right of the character + for (actbounds.max_x = rowbytes - 1; actbounds.max_x >= 0; actbounds.max_x--) + { + BYTE *offs = bits + actbounds.max_x; + UINT8 summary = 0; + for (int y = 0; y < bmheight; y++) + summary |= offs[y * rowbytes]; + if (summary != 0) + { + actbounds.max_x *= 8; + if (summary & 0x7f) actbounds.max_x++; + if (summary & 0x3f) actbounds.max_x++; + if (summary & 0x1f) actbounds.max_x++; + if (summary & 0x0f) actbounds.max_x++; + if (summary & 0x07) actbounds.max_x++; + if (summary & 0x03) actbounds.max_x++; + if (summary & 0x01) actbounds.max_x++; + break; + } + } - // allocate a new bitmap - if (actbounds.max_x >= actbounds.min_x && actbounds.max_y >= actbounds.min_y) - { - bitmap.allocate(actbounds.max_x + 1 - actbounds.min_x, actbounds.max_y + 1 - actbounds.min_y); + // allocate a new bitmap + if (actbounds.max_x >= actbounds.min_x && actbounds.max_y >= actbounds.min_y) + { + bitmap.allocate(actbounds.max_x + 1 - actbounds.min_x, actbounds.max_y + 1 - actbounds.min_y); - // copy the bits into it - for (int y = 0; y < bitmap.height(); y++) - { - UINT32 *dstrow = &bitmap.pix32(y); - UINT8 *srcrow = &bits[(y + actbounds.min_y) * rowbytes]; - for (int x = 0; x < bitmap.width(); x++) - { - int effx = x + actbounds.min_x; - dstrow[x] = ((srcrow[effx / 8] << (effx % 8)) & 0x80) ? rgb_t(0xff, 0xff, 0xff, 0xff) : rgb_t(0x00, 0xff, 0xff, 0xff); - } - } + // copy the bits into it + for (int y = 0; y < bitmap.height(); y++) + { + UINT32 *dstrow = &bitmap.pix32(y); + UINT8 *srcrow = &bits[(y + actbounds.min_y) * rowbytes]; + for (int x = 0; x < bitmap.width(); x++) + { + int effx = x + actbounds.min_x; + dstrow[x] = ((srcrow[effx / 8] << (effx % 8)) & 0x80) ? rgb_t(0xff, 0xff, 0xff, 0xff) : rgb_t(0x00, 0xff, 0xff, 0xff); + } + } - // set the final offset values - xoffs = actbounds.min_x - (50 + abc.abcA); - yoffs = actbounds.max_y - (50 + metrics.tmAscent); - } + // set the final offset values + xoffs = actbounds.min_x - (50 + abc.abcA); + yoffs = actbounds.max_y - (50 + metrics.tmAscent); + } - // de-select the font and release the DC - SelectObject(dummyDC, oldbitmap); - DeleteObject(dib); - SelectObject(dummyDC, oldfont); - DeleteDC(dummyDC); - return bitmap.valid(); + // de-select the font and release the DC + SelectObject(dummyDC, oldbitmap); + DeleteObject(dib); + SelectObject(dummyDC, oldfont); + DeleteDC(dummyDC); + return bitmap.valid(); } class font_win : public osd_module, public font_module { public: - font_win() - : osd_module(OSD_FONT_PROVIDER, "win"), font_module() - { - } + font_win() + : osd_module(OSD_FONT_PROVIDER, "win"), font_module() + { + } - osd_font *font_alloc() - { - return global_alloc(osd_font_windows); - } + osd_font *font_alloc() + { + return global_alloc(osd_font_windows); + } }; #else /* SDLMAME_UNIX */ - MODULE_NOT_SUPPORTED(font_win, OSD_FONT_PROVIDER, "win") + MODULE_NOT_SUPPORTED(font_win, OSD_FONT_PROVIDER, "win") #endif MODULE_DEFINITION(FONT_WINDOWS, font_win) diff --git a/src/osd/modules/lib/osdlib_macosx.c b/src/osd/modules/lib/osdlib_macosx.c index 5d6233bce25..088cbd969df 100644 --- a/src/osd/modules/lib/osdlib_macosx.c +++ b/src/osd/modules/lib/osdlib_macosx.c @@ -34,7 +34,7 @@ const char *osd_getenv(const char *name) { - return getenv(name); + return getenv(name); } //============================================================ @@ -43,7 +43,7 @@ const char *osd_getenv(const char *name) int osd_setenv(const char *name, const char *value, int overwrite) { - return setenv(name, value, overwrite); + return setenv(name, value, overwrite); } //============================================================ @@ -52,7 +52,7 @@ int osd_setenv(const char *name, const char *value, int overwrite) void osd_process_kill(void) { - kill(getpid(), SIGKILL); + kill(getpid(), SIGKILL); } //============================================================ @@ -61,22 +61,22 @@ void osd_process_kill(void) int osd_get_num_processors(void) { - int processors = 1; + int processors = 1; - struct host_basic_info host_basic_info; - unsigned int count; - kern_return_t r; - mach_port_t my_mach_host_self; + struct host_basic_info host_basic_info; + unsigned int count; + kern_return_t r; + mach_port_t my_mach_host_self; - count = HOST_BASIC_INFO_COUNT; - my_mach_host_self = mach_host_self(); - if ( ( r = host_info(my_mach_host_self, HOST_BASIC_INFO, (host_info_t)(&host_basic_info), &count)) == KERN_SUCCESS ) - { - processors = host_basic_info.avail_cpus; - } - mach_port_deallocate(mach_task_self(), my_mach_host_self); + count = HOST_BASIC_INFO_COUNT; + my_mach_host_self = mach_host_self(); + if ( ( r = host_info(my_mach_host_self, HOST_BASIC_INFO, (host_info_t)(&host_basic_info), &count)) == KERN_SUCCESS ) + { + processors = host_basic_info.avail_cpus; + } + mach_port_deallocate(mach_task_self(), my_mach_host_self); - return processors; + return processors; } //============================================================ @@ -86,7 +86,7 @@ int osd_get_num_processors(void) void *osd_malloc(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -100,7 +100,7 @@ void *osd_malloc(size_t size) void *osd_malloc_array(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -114,7 +114,7 @@ void *osd_malloc_array(size_t size) void osd_free(void *ptr) { #ifndef MALLOC_DEBUG - free(ptr); + free(ptr); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -131,9 +131,9 @@ void osd_free(void *ptr) void *osd_alloc_executable(size_t size) { #if defined(SDLMAME_BSD) || defined(SDLMAME_MACOSX) - return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); + return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); #elif defined(SDLMAME_UNIX) - return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0); + return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0); #endif } @@ -146,9 +146,9 @@ void *osd_alloc_executable(size_t size) void osd_free_executable(void *ptr, size_t size) { #ifdef SDLMAME_SOLARIS - munmap((char *)ptr, size); + munmap((char *)ptr, size); #else - munmap(ptr, size); + munmap(ptr, size); #endif } @@ -158,13 +158,13 @@ void osd_free_executable(void *ptr, size_t size) void osd_break_into_debugger(const char *message) { - #ifdef MAME_DEBUG - printf("MAME exception: %s\n", message); - printf("Attempting to fall into debugger\n"); - kill(getpid(), SIGTRAP); - #else - printf("Ignoring MAME exception: %s\n", message); - #endif + #ifdef MAME_DEBUG + printf("MAME exception: %s\n", message); + printf("Attempting to fall into debugger\n"); + kill(getpid(), SIGTRAP); + #else + printf("Ignoring MAME exception: %s\n", message); + #endif } @@ -191,36 +191,36 @@ static osd_ticks_t ticks_per_second; static osd_ticks_t init_cycle_counter(void) { - osd_ticks_t start, end; - osd_ticks_t a, b; + osd_ticks_t start, end; + osd_ticks_t a, b; - cycle_counter = mach_cycle_counter; - ticks_counter = mach_cycle_counter; + cycle_counter = mach_cycle_counter; + ticks_counter = mach_cycle_counter; - // wait for an edge on the timeGetTime call - a = SDL_GetTicks(); - do - { - b = SDL_GetTicks(); - } while (a == b); + // wait for an edge on the timeGetTime call + a = SDL_GetTicks(); + do + { + b = SDL_GetTicks(); + } while (a == b); - // get the starting cycle count - start = (*cycle_counter)(); + // get the starting cycle count + start = (*cycle_counter)(); - // now wait for 1/4 second total - do - { - a = SDL_GetTicks(); - } while (a - b < 250); + // now wait for 1/4 second total + do + { + a = SDL_GetTicks(); + } while (a - b < 250); - // get the ending cycle count - end = (*cycle_counter)(); + // get the ending cycle count + end = (*cycle_counter)(); - // compute ticks_per_sec - ticks_per_second = (end - start) * 4; + // compute ticks_per_sec + ticks_per_second = (end - start) * 4; - // return the current cycle count - return (*cycle_counter)(); + // return the current cycle count + return (*cycle_counter)(); } //============================================================ @@ -232,7 +232,7 @@ static osd_ticks_t init_cycle_counter(void) //============================================================ static osd_ticks_t mach_cycle_counter(void) { - return mach_absolute_time(); + return mach_absolute_time(); } //============================================================ @@ -241,7 +241,7 @@ static osd_ticks_t mach_cycle_counter(void) osd_ticks_t osd_ticks(void) { - return (*cycle_counter)(); + return (*cycle_counter)(); } @@ -251,12 +251,12 @@ osd_ticks_t osd_ticks(void) osd_ticks_t osd_ticks_per_second(void) { - if (ticks_per_second == 0) - { - // if we haven't computed the value yet, there's no time like the present - init_cycle_counter(); - } - return ticks_per_second; + if (ticks_per_second == 0) + { + // if we haven't computed the value yet, there's no time like the present + init_cycle_counter(); + } + return ticks_per_second; } @@ -267,20 +267,20 @@ osd_ticks_t osd_ticks_per_second(void) void osd_sleep(osd_ticks_t duration) { - UINT32 msec; + UINT32 msec; - // make sure we've computed ticks_per_second - if (ticks_per_second == 0) - (void)osd_ticks(); + // make sure we've computed ticks_per_second + if (ticks_per_second == 0) + (void)osd_ticks(); - // convert to milliseconds, rounding down - msec = (UINT32)(duration * 1000 / ticks_per_second); + // convert to milliseconds, rounding down + msec = (UINT32)(duration * 1000 / ticks_per_second); - // only sleep if at least 2 full milliseconds - if (msec >= 2) - { - // take a couple of msecs off the top for good measure - msec -= 2; - usleep(msec*1000); - } + // only sleep if at least 2 full milliseconds + if (msec >= 2) + { + // take a couple of msecs off the top for good measure + msec -= 2; + usleep(msec*1000); + } } diff --git a/src/osd/modules/lib/osdlib_os2.c b/src/osd/modules/lib/osdlib_os2.c index d852ea5ce93..9e1ab8fd52d 100644 --- a/src/osd/modules/lib/osdlib_os2.c +++ b/src/osd/modules/lib/osdlib_os2.c @@ -31,7 +31,7 @@ const char *osd_getenv(const char *name) { - return getenv(name); + return getenv(name); } //============================================================ @@ -40,7 +40,7 @@ const char *osd_getenv(const char *name) int osd_setenv(const char *name, const char *value, int overwrite) { - return setenv(name, value, overwrite); + return setenv(name, value, overwrite); } //============================================================ @@ -49,7 +49,7 @@ int osd_setenv(const char *name, const char *value, int overwrite) void osd_process_kill(void) { - fprintf(stderr,"osd_process_kill missing in OS/2 build\n"); + fprintf(stderr,"osd_process_kill missing in OS/2 build\n"); } //============================================================ @@ -58,11 +58,11 @@ void osd_process_kill(void) int osd_get_num_processors(void) { - ULONG numprocs = 1; + ULONG numprocs = 1; - DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &numprocs, sizeof(numprocs)); + DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &numprocs, sizeof(numprocs)); - return numprocs; + return numprocs; } //============================================================ @@ -72,7 +72,7 @@ int osd_get_num_processors(void) void *osd_malloc(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -86,7 +86,7 @@ void *osd_malloc(size_t size) void *osd_malloc_array(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -100,7 +100,7 @@ void *osd_malloc_array(size_t size) void osd_free(void *ptr) { #ifndef MALLOC_DEBUG - free(ptr); + free(ptr); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -116,10 +116,10 @@ void osd_free(void *ptr) void *osd_alloc_executable(size_t size) { - void *p; + void *p; - DosAllocMem( &p, size, fALLOC ); - return p; + DosAllocMem( &p, size, fALLOC ); + return p; } //============================================================ @@ -130,7 +130,7 @@ void *osd_alloc_executable(size_t size) void osd_free_executable(void *ptr, size_t size) { - DosFreeMem( ptr ); + DosFreeMem( ptr ); } //============================================================ @@ -139,7 +139,7 @@ void osd_free_executable(void *ptr, size_t size) void osd_break_into_debugger(const char *message) { - printf("Ignoring MAME exception: %s\n", message); + printf("Ignoring MAME exception: %s\n", message); } //============================================================ @@ -167,65 +167,65 @@ static osd_ticks_t ticks_per_second; static osd_ticks_t init_cycle_counter(void) { - osd_ticks_t start, end; - osd_ticks_t a, b; + osd_ticks_t start, end; + osd_ticks_t a, b; - ULONG frequency; - PTIB ptib; - ULONG ulClass; - ULONG ulDelta; + ULONG frequency; + PTIB ptib; + ULONG ulClass; + ULONG ulDelta; - DosGetInfoBlocks( &ptib, NULL ); - ulClass = HIBYTE( ptib->tib_ptib2->tib2_ulpri ); - ulDelta = LOBYTE( ptib->tib_ptib2->tib2_ulpri ); + DosGetInfoBlocks( &ptib, NULL ); + ulClass = HIBYTE( ptib->tib_ptib2->tib2_ulpri ); + ulDelta = LOBYTE( ptib->tib_ptib2->tib2_ulpri ); - if ( DosTmrQueryFreq( &frequency ) == 0 ) - { - // use performance counter if available as it is constant - cycle_counter = performance_cycle_counter; - ticks_counter = performance_cycle_counter; + if ( DosTmrQueryFreq( &frequency ) == 0 ) + { + // use performance counter if available as it is constant + cycle_counter = performance_cycle_counter; + ticks_counter = performance_cycle_counter; - ticks_per_second = frequency; + ticks_per_second = frequency; - // return the current cycle count - return (*cycle_counter)(); - } - else - { - fprintf(stderr, "No Timer available!\n"); - exit(-1); - } + // return the current cycle count + return (*cycle_counter)(); + } + else + { + fprintf(stderr, "No Timer available!\n"); + exit(-1); + } - // temporarily set our priority higher - DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, 0 ); + // temporarily set our priority higher + DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, 0 ); - // wait for an edge on the timeGetTime call - a = SDL_GetTicks(); - do - { - b = SDL_GetTicks(); - } while (a == b); + // wait for an edge on the timeGetTime call + a = SDL_GetTicks(); + do + { + b = SDL_GetTicks(); + } while (a == b); - // get the starting cycle count - start = (*cycle_counter)(); + // get the starting cycle count + start = (*cycle_counter)(); - // now wait for 1/4 second total - do - { - a = SDL_GetTicks(); - } while (a - b < 250); + // now wait for 1/4 second total + do + { + a = SDL_GetTicks(); + } while (a - b < 250); - // get the ending cycle count - end = (*cycle_counter)(); + // get the ending cycle count + end = (*cycle_counter)(); - // compute ticks_per_sec - ticks_per_second = (end - start) * 4; + // compute ticks_per_sec + ticks_per_second = (end - start) * 4; - // restore our priority - DosSetPriority( PRTYS_THREAD, ulClass, ulDelta, 0 ); + // restore our priority + DosSetPriority( PRTYS_THREAD, ulClass, ulDelta, 0 ); - // return the current cycle count - return (*cycle_counter)(); + // return the current cycle count + return (*cycle_counter)(); } //============================================================ @@ -234,10 +234,10 @@ static osd_ticks_t init_cycle_counter(void) static osd_ticks_t performance_cycle_counter(void) { - QWORD qwTime; + QWORD qwTime; - DosTmrQueryTime( &qwTime ); - return (osd_ticks_t)qwTime.ulLo; + DosTmrQueryTime( &qwTime ); + return (osd_ticks_t)qwTime.ulLo; } //============================================================ @@ -246,7 +246,7 @@ static osd_ticks_t performance_cycle_counter(void) osd_ticks_t osd_ticks(void) { - return (*cycle_counter)(); + return (*cycle_counter)(); } @@ -256,12 +256,12 @@ osd_ticks_t osd_ticks(void) osd_ticks_t osd_ticks_per_second(void) { - if (ticks_per_second == 0) - { - // if we haven't computed the value yet, there's no time like the present - init_cycle_counter(); - } - return ticks_per_second; + if (ticks_per_second == 0) + { + // if we haven't computed the value yet, there's no time like the present + init_cycle_counter(); + } + return ticks_per_second; } @@ -271,21 +271,20 @@ osd_ticks_t osd_ticks_per_second(void) void osd_sleep(osd_ticks_t duration) { - UINT32 msec; + UINT32 msec; - // make sure we've computed ticks_per_second - if (ticks_per_second == 0) - (void)osd_ticks(); + // make sure we've computed ticks_per_second + if (ticks_per_second == 0) + (void)osd_ticks(); - // convert to milliseconds, rounding down - msec = (UINT32)(duration * 1000 / ticks_per_second); + // convert to milliseconds, rounding down + msec = (UINT32)(duration * 1000 / ticks_per_second); - // only sleep if at least 2 full milliseconds - if (msec >= 2) - { - // take a couple of msecs off the top for good measure - msec -= 2; - usleep(msec*1000); - } + // only sleep if at least 2 full milliseconds + if (msec >= 2) + { + // take a couple of msecs off the top for good measure + msec -= 2; + usleep(msec*1000); + } } - diff --git a/src/osd/modules/lib/osdlib_unix.c b/src/osd/modules/lib/osdlib_unix.c index 39eed83b918..7fe3c37988d 100644 --- a/src/osd/modules/lib/osdlib_unix.c +++ b/src/osd/modules/lib/osdlib_unix.c @@ -30,7 +30,7 @@ const char *osd_getenv(const char *name) { - return getenv(name); + return getenv(name); } //============================================================ @@ -39,7 +39,7 @@ const char *osd_getenv(const char *name) int osd_setenv(const char *name, const char *value, int overwrite) { - return setenv(name, value, overwrite); + return setenv(name, value, overwrite); } //============================================================ @@ -48,7 +48,7 @@ int osd_setenv(const char *name, const char *value, int overwrite) void osd_process_kill(void) { - kill(getpid(), SIGKILL); + kill(getpid(), SIGKILL); } //============================================================ @@ -57,12 +57,12 @@ void osd_process_kill(void) int osd_get_num_processors(void) { - int processors = 1; + int processors = 1; #if defined(_SC_NPROCESSORS_ONLN) - processors = sysconf(_SC_NPROCESSORS_ONLN); + processors = sysconf(_SC_NPROCESSORS_ONLN); #endif - return processors; + return processors; } //============================================================ @@ -72,7 +72,7 @@ int osd_get_num_processors(void) void *osd_malloc(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -86,7 +86,7 @@ void *osd_malloc(size_t size) void *osd_malloc_array(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -100,7 +100,7 @@ void *osd_malloc_array(size_t size) void osd_free(void *ptr) { #ifndef MALLOC_DEBUG - free(ptr); + free(ptr); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -116,9 +116,9 @@ void osd_free(void *ptr) void *osd_alloc_executable(size_t size) { #if defined(SDLMAME_BSD) || defined(SDLMAME_MACOSX) - return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); + return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); #elif defined(SDLMAME_UNIX) - return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0); + return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0); #endif } @@ -131,9 +131,9 @@ void *osd_alloc_executable(size_t size) void osd_free_executable(void *ptr, size_t size) { #ifdef SDLMAME_SOLARIS - munmap((char *)ptr, size); + munmap((char *)ptr, size); #else - munmap(ptr, size); + munmap(ptr, size); #endif } @@ -143,13 +143,13 @@ void osd_free_executable(void *ptr, size_t size) void osd_break_into_debugger(const char *message) { - #ifdef MAME_DEBUG - printf("MAME exception: %s\n", message); - printf("Attempting to fall into debugger\n"); - kill(getpid(), SIGTRAP); - #else - printf("Ignoring MAME exception: %s\n", message); - #endif + #ifdef MAME_DEBUG + printf("MAME exception: %s\n", message); + printf("Attempting to fall into debugger\n"); + kill(getpid(), SIGTRAP); + #else + printf("Ignoring MAME exception: %s\n", message); + #endif } @@ -160,15 +160,15 @@ void osd_break_into_debugger(const char *message) osd_ticks_t osd_ticks(void) { #ifdef SDLMAME_EMSCRIPTEN - return (osd_ticks_t)(emscripten_get_now() * 1000.0); + return (osd_ticks_t)(emscripten_get_now() * 1000.0); #else - struct timeval tp; - static osd_ticks_t start_sec = 0; + struct timeval tp; + static osd_ticks_t start_sec = 0; - gettimeofday(&tp, NULL); - if (start_sec==0) - start_sec = tp.tv_sec; - return (tp.tv_sec - start_sec) * (osd_ticks_t) 1000000 + tp.tv_usec; + gettimeofday(&tp, NULL); + if (start_sec==0) + start_sec = tp.tv_sec; + return (tp.tv_sec - start_sec) * (osd_ticks_t) 1000000 + tp.tv_usec; #endif } @@ -179,7 +179,7 @@ osd_ticks_t osd_ticks(void) osd_ticks_t osd_ticks_per_second(void) { - return (osd_ticks_t) 1000000; + return (osd_ticks_t) 1000000; } //============================================================ @@ -188,16 +188,16 @@ osd_ticks_t osd_ticks_per_second(void) void osd_sleep(osd_ticks_t duration) { - UINT32 msec; + UINT32 msec; - // convert to milliseconds, rounding down - msec = (UINT32)(duration * 1000 / osd_ticks_per_second()); + // convert to milliseconds, rounding down + msec = (UINT32)(duration * 1000 / osd_ticks_per_second()); - // only sleep if at least 2 full milliseconds - if (msec >= 2) - { - // take a couple of msecs off the top for good measure - msec -= 2; - usleep(msec*1000); - } + // only sleep if at least 2 full milliseconds + if (msec >= 2) + { + // take a couple of msecs off the top for good measure + msec -= 2; + usleep(msec*1000); + } } diff --git a/src/osd/modules/lib/osdlib_win32.c b/src/osd/modules/lib/osdlib_win32.c index 4d78820f7d6..3150cdafc97 100644 --- a/src/osd/modules/lib/osdlib_win32.c +++ b/src/osd/modules/lib/osdlib_win32.c @@ -53,7 +53,7 @@ void (*s_debugger_stack_crawler)() = NULL; const char *osd_getenv(const char *name) { - return getenv(name); + return getenv(name); } @@ -63,23 +63,23 @@ const char *osd_getenv(const char *name) int osd_setenv(const char *name, const char *value, int overwrite) { - char *buf; - int result; + char *buf; + int result; - if (!overwrite) - { - if (osd_getenv(name) != NULL) - return 0; - } - buf = (char *) osd_malloc_array(strlen(name)+strlen(value)+2); - sprintf(buf, "%s=%s", name, value); - result = putenv(buf); + if (!overwrite) + { + if (osd_getenv(name) != NULL) + return 0; + } + buf = (char *) osd_malloc_array(strlen(name)+strlen(value)+2); + sprintf(buf, "%s=%s", name, value); + result = putenv(buf); - /* will be referenced by environment - * Therefore it is not freed here - */ + /* will be referenced by environment + * Therefore it is not freed here + */ - return result; + return result; } //============================================================ @@ -88,7 +88,7 @@ int osd_setenv(const char *name, const char *value, int overwrite) void osd_process_kill(void) { - TerminateProcess(GetCurrentProcess(), -1); + TerminateProcess(GetCurrentProcess(), -1); } //============================================================ @@ -97,13 +97,13 @@ void osd_process_kill(void) int osd_get_num_processors(void) { - SYSTEM_INFO info; + SYSTEM_INFO info; - // otherwise, fetch the info from the system - GetSystemInfo(&info); + // otherwise, fetch the info from the system + GetSystemInfo(&info); - // max out at 4 for now since scaling above that seems to do poorly - return MIN(info.dwNumberOfProcessors, 4); + // max out at 4 for now since scaling above that seems to do poorly + return MIN(info.dwNumberOfProcessors, 4); } //============================================================ @@ -113,17 +113,17 @@ int osd_get_num_processors(void) void *osd_malloc(size_t size) { #ifndef MALLOC_DEBUG - return HeapAlloc(GetProcessHeap(), 0, size); + return HeapAlloc(GetProcessHeap(), 0, size); #else - // add in space for the size - size += sizeof(size_t); + // add in space for the size + size += sizeof(size_t); - // basic objects just come from the heap - void *result = HeapAlloc(GetProcessHeap(), 0, size); + // basic objects just come from the heap + void *result = HeapAlloc(GetProcessHeap(), 0, size); - // store the size and return and pointer to the data afterward - *reinterpret_cast(result) = size; - return reinterpret_cast(result) + sizeof(size_t); + // store the size and return and pointer to the data afterward + *reinterpret_cast(result) = size; + return reinterpret_cast(result) + sizeof(size_t); #endif } @@ -135,30 +135,30 @@ void *osd_malloc(size_t size) void *osd_malloc_array(size_t size) { #ifndef MALLOC_DEBUG - return HeapAlloc(GetProcessHeap(), 0, size); + return HeapAlloc(GetProcessHeap(), 0, size); #else - // add in space for the size - size += sizeof(size_t); + // add in space for the size + size += sizeof(size_t); - // round the size up to a page boundary - size_t rounded_size = ((size + sizeof(void *) + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; + // round the size up to a page boundary + size_t rounded_size = ((size + sizeof(void *) + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; - // reserve that much memory, plus two guard pages - void *page_base = VirtualAlloc(NULL, rounded_size + 2 * PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS); - if (page_base == NULL) - return NULL; + // reserve that much memory, plus two guard pages + void *page_base = VirtualAlloc(NULL, rounded_size + 2 * PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS); + if (page_base == NULL) + return NULL; - // now allow access to everything but the first and last pages - page_base = VirtualAlloc(reinterpret_cast(page_base) + PAGE_SIZE, rounded_size, MEM_COMMIT, PAGE_READWRITE); - if (page_base == NULL) - return NULL; + // now allow access to everything but the first and last pages + page_base = VirtualAlloc(reinterpret_cast(page_base) + PAGE_SIZE, rounded_size, MEM_COMMIT, PAGE_READWRITE); + if (page_base == NULL) + return NULL; - // work backwards from the page base to get to the block base - void *result = GUARD_ALIGN_START ? page_base : (reinterpret_cast(page_base) + rounded_size - size); + // work backwards from the page base to get to the block base + void *result = GUARD_ALIGN_START ? page_base : (reinterpret_cast(page_base) + rounded_size - size); - // store the size at the start with a flag indicating it has a guard page - *reinterpret_cast(result) = size | 0x80000000; - return reinterpret_cast(result) + sizeof(size_t); + // store the size at the start with a flag indicating it has a guard page + *reinterpret_cast(result) = size | 0x80000000; + return reinterpret_cast(result) + sizeof(size_t); #endif } @@ -170,20 +170,20 @@ void *osd_malloc_array(size_t size) void osd_free(void *ptr) { #ifndef MALLOC_DEBUG - HeapFree(GetProcessHeap(), 0, ptr); + HeapFree(GetProcessHeap(), 0, ptr); #else - size_t size = reinterpret_cast(ptr)[-1]; + size_t size = reinterpret_cast(ptr)[-1]; - // if no guard page, just free the pointer - if ((size & 0x80000000) == 0) - HeapFree(GetProcessHeap(), 0, reinterpret_cast(ptr) - sizeof(size_t)); + // if no guard page, just free the pointer + if ((size & 0x80000000) == 0) + HeapFree(GetProcessHeap(), 0, reinterpret_cast(ptr) - sizeof(size_t)); - // large items need more care - else - { - ULONG_PTR page_base = (reinterpret_cast(ptr) - sizeof(size_t)) & ~(PAGE_SIZE - 1); - VirtualFree(reinterpret_cast(page_base - PAGE_SIZE), 0, MEM_RELEASE); - } + // large items need more care + else + { + ULONG_PTR page_base = (reinterpret_cast(ptr) - sizeof(size_t)) & ~(PAGE_SIZE - 1); + VirtualFree(reinterpret_cast(page_base - PAGE_SIZE), 0, MEM_RELEASE); + } #endif } @@ -197,7 +197,7 @@ void osd_free(void *ptr) void *osd_alloc_executable(size_t size) { - return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); } @@ -209,7 +209,7 @@ void *osd_alloc_executable(size_t size) void osd_free_executable(void *ptr, size_t size) { - VirtualFree(ptr, 0, MEM_RELEASE); + VirtualFree(ptr, 0, MEM_RELEASE); } @@ -220,19 +220,19 @@ void osd_free_executable(void *ptr, size_t size) void osd_break_into_debugger(const char *message) { #ifdef OSD_WINDOWS - if (IsDebuggerPresent()) - { - win_output_debug_string_utf8(message); - DebugBreak(); - } - else if (s_debugger_stack_crawler != NULL) - (*s_debugger_stack_crawler)(); + if (IsDebuggerPresent()) + { + win_output_debug_string_utf8(message); + DebugBreak(); + } + else if (s_debugger_stack_crawler != NULL) + (*s_debugger_stack_crawler)(); #else - if (IsDebuggerPresent()) - { - OutputDebugStringA(message); - DebugBreak(); - } + if (IsDebuggerPresent()) + { + OutputDebugStringA(message); + DebugBreak(); + } #endif } @@ -252,36 +252,36 @@ static BOOL using_qpc = TRUE; osd_ticks_t osd_ticks(void) { - LARGE_INTEGER performance_count; + LARGE_INTEGER performance_count; - // if we're suspended, just return that - if (suspend_ticks != 0) - return suspend_ticks; + // if we're suspended, just return that + if (suspend_ticks != 0) + return suspend_ticks; - // if we have a per second count, just go for it - if (ticks_per_second != 0) - { - // QueryPerformanceCounter if we can - if (using_qpc) - { - QueryPerformanceCounter(&performance_count); - return (osd_ticks_t)performance_count.QuadPart - suspend_ticks; - } + // if we have a per second count, just go for it + if (ticks_per_second != 0) + { + // QueryPerformanceCounter if we can + if (using_qpc) + { + QueryPerformanceCounter(&performance_count); + return (osd_ticks_t)performance_count.QuadPart - suspend_ticks; + } - // otherwise, fall back to timeGetTime - else - return (osd_ticks_t)timeGetTime() - suspend_ticks; - } + // otherwise, fall back to timeGetTime + else + return (osd_ticks_t)timeGetTime() - suspend_ticks; + } - // if not, we have to determine it - using_qpc = QueryPerformanceFrequency(&performance_count) && (performance_count.QuadPart != 0); - if (using_qpc) - ticks_per_second = (osd_ticks_t)performance_count.QuadPart; - else - ticks_per_second = 1000; + // if not, we have to determine it + using_qpc = QueryPerformanceFrequency(&performance_count) && (performance_count.QuadPart != 0); + if (using_qpc) + ticks_per_second = (osd_ticks_t)performance_count.QuadPart; + else + ticks_per_second = 1000; - // call ourselves to get the first value - return osd_ticks(); + // call ourselves to get the first value + return osd_ticks(); } @@ -291,9 +291,9 @@ osd_ticks_t osd_ticks(void) osd_ticks_t osd_ticks_per_second(void) { - if (ticks_per_second == 0) - osd_ticks(); - return ticks_per_second; + if (ticks_per_second == 0) + osd_ticks(); + return ticks_per_second; } //============================================================ @@ -302,28 +302,28 @@ osd_ticks_t osd_ticks_per_second(void) void osd_sleep(osd_ticks_t duration) { - DWORD msec; + DWORD msec; - // make sure we've computed ticks_per_second - if (ticks_per_second == 0) - (void)osd_ticks(); + // make sure we've computed ticks_per_second + if (ticks_per_second == 0) + (void)osd_ticks(); - // convert to milliseconds, rounding down - msec = (DWORD)(duration * 1000 / ticks_per_second); + // convert to milliseconds, rounding down + msec = (DWORD)(duration * 1000 / ticks_per_second); - // only sleep if at least 2 full milliseconds - if (msec >= 2) - { - HANDLE current_thread = GetCurrentThread(); - int old_priority = GetThreadPriority(current_thread); + // only sleep if at least 2 full milliseconds + if (msec >= 2) + { + HANDLE current_thread = GetCurrentThread(); + int old_priority = GetThreadPriority(current_thread); - // take a couple of msecs off the top for good measure - msec -= 2; + // take a couple of msecs off the top for good measure + msec -= 2; - // bump our thread priority super high so that we get - // priority when we need it - SetThreadPriority(current_thread, THREAD_PRIORITY_TIME_CRITICAL); - Sleep(msec); - SetThreadPriority(current_thread, old_priority); - } + // bump our thread priority super high so that we get + // priority when we need it + SetThreadPriority(current_thread, THREAD_PRIORITY_TIME_CRITICAL); + Sleep(msec); + SetThreadPriority(current_thread, old_priority); + } } diff --git a/src/osd/modules/lib/osdobj_common.c b/src/osd/modules/lib/osdobj_common.c index 73580dba2fd..57731edc591 100644 --- a/src/osd/modules/lib/osdobj_common.c +++ b/src/osd/modules/lib/osdobj_common.c @@ -17,79 +17,79 @@ extern bool g_print_verbose; const options_entry osd_options::s_option_entries[] = { - { NULL, NULL, OPTION_HEADER, "OSD FONT OPTIONS" }, - { OSD_FONT_PROVIDER, "auto", OPTION_STRING, "provider for ui font: " }, + { NULL, NULL, OPTION_HEADER, "OSD FONT OPTIONS" }, + { OSD_FONT_PROVIDER, "auto", OPTION_STRING, "provider for ui font: " }, - { NULL, NULL, OPTION_HEADER, "OSD CLI OPTIONS" }, - { OSDCOMMAND_LIST_MIDI_DEVICES ";mlist", "0", OPTION_COMMAND, "list available MIDI I/O devices" }, - { OSDCOMMAND_LIST_NETWORK_ADAPTERS ";nlist", "0", OPTION_COMMAND, "list available network adapters" }, + { NULL, NULL, OPTION_HEADER, "OSD CLI OPTIONS" }, + { OSDCOMMAND_LIST_MIDI_DEVICES ";mlist", "0", OPTION_COMMAND, "list available MIDI I/O devices" }, + { OSDCOMMAND_LIST_NETWORK_ADAPTERS ";nlist", "0", OPTION_COMMAND, "list available network adapters" }, - // debugging options - { NULL, NULL, OPTION_HEADER, "OSD DEBUGGING OPTIONS" }, - { OSDOPTION_DEBUGGER, OSDOPTVAL_AUTO, OPTION_STRING, "debugger used : " }, - { OSDOPTION_WATCHDOG ";wdog", "0", OPTION_INTEGER, "force the program to terminate if no updates within specified number of seconds" }, + // debugging options + { NULL, NULL, OPTION_HEADER, "OSD DEBUGGING OPTIONS" }, + { OSDOPTION_DEBUGGER, OSDOPTVAL_AUTO, OPTION_STRING, "debugger used : " }, + { OSDOPTION_WATCHDOG ";wdog", "0", OPTION_INTEGER, "force the program to terminate if no updates within specified number of seconds" }, - // performance options - { NULL, NULL, OPTION_HEADER, "OSD PERFORMANCE OPTIONS" }, - { OSDOPTION_MULTITHREADING ";mt", "0", OPTION_BOOLEAN, "enable multithreading; this enables rendering and blitting on a separate thread" }, - { OSDOPTION_NUMPROCESSORS ";np", OSDOPTVAL_AUTO, OPTION_STRING, "number of processors; this overrides the number the system reports" }, - { OSDOPTION_BENCH, "0", OPTION_INTEGER, "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" }, - // video options - { NULL, NULL, OPTION_HEADER, "OSD VIDEO OPTIONS" }, + // performance options + { NULL, NULL, OPTION_HEADER, "OSD PERFORMANCE OPTIONS" }, + { OSDOPTION_MULTITHREADING ";mt", "0", OPTION_BOOLEAN, "enable multithreading; this enables rendering and blitting on a separate thread" }, + { OSDOPTION_NUMPROCESSORS ";np", OSDOPTVAL_AUTO, OPTION_STRING, "number of processors; this overrides the number the system reports" }, + { OSDOPTION_BENCH, "0", OPTION_INTEGER, "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" }, + // video options + { NULL, NULL, OPTION_HEADER, "OSD VIDEO OPTIONS" }, // OS X can be trusted to have working hardware OpenGL, so default to it on for the best user experience - { OSDOPTION_VIDEO, OSDOPTVAL_AUTO, OPTION_STRING, "video output method: " }, - { OSDOPTION_NUMSCREENS "(1-4)", "1", OPTION_INTEGER, "number of screens to create; usually, you want just one" }, - { OSDOPTION_WINDOW ";w", "0", OPTION_BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" }, - { OSDOPTION_MAXIMIZE ";max", "1", OPTION_BOOLEAN, "default to maximized windows; otherwise, windows will be minimized" }, - { OSDOPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" }, - { OSDOPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" }, - { OSDOPTION_WAITVSYNC ";vs", "0", OPTION_BOOLEAN, "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" }, - { OSDOPTION_SYNCREFRESH ";srf", "0", OPTION_BOOLEAN, "enable using the start of VBLANK for throttling instead of the game time" }, + { OSDOPTION_VIDEO, OSDOPTVAL_AUTO, OPTION_STRING, "video output method: " }, + { OSDOPTION_NUMSCREENS "(1-4)", "1", OPTION_INTEGER, "number of screens to create; usually, you want just one" }, + { OSDOPTION_WINDOW ";w", "0", OPTION_BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" }, + { OSDOPTION_MAXIMIZE ";max", "1", OPTION_BOOLEAN, "default to maximized windows; otherwise, windows will be minimized" }, + { OSDOPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" }, + { OSDOPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" }, + { OSDOPTION_WAITVSYNC ";vs", "0", OPTION_BOOLEAN, "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" }, + { OSDOPTION_SYNCREFRESH ";srf", "0", OPTION_BOOLEAN, "enable using the start of VBLANK for throttling instead of the game time" }, - // per-window options - { NULL, NULL, OPTION_HEADER, "OSD PER-WINDOW VIDEO OPTIONS" }, - { OSDOPTION_SCREEN, OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_ASPECT ";screen_aspect", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio for all screens; 'auto' here will try to make a best guess" }, - { OSDOPTION_RESOLUTION ";r", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution for all screens; format is x[@] or 'auto'" }, - { OSDOPTION_VIEW, OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for all screens" }, + // per-window options + { NULL, NULL, OPTION_HEADER, "OSD PER-WINDOW VIDEO OPTIONS" }, + { OSDOPTION_SCREEN, OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_ASPECT ";screen_aspect", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio for all screens; 'auto' here will try to make a best guess" }, + { OSDOPTION_RESOLUTION ";r", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution for all screens; format is x[@] or 'auto'" }, + { OSDOPTION_VIEW, OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for all screens" }, - { OSDOPTION_SCREEN "0", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_ASPECT "0", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the first screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_RESOLUTION "0;r0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the first screen; format is x[@] or 'auto'" }, - { OSDOPTION_VIEW "0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the first screen" }, + { OSDOPTION_SCREEN "0", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_ASPECT "0", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the first screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_RESOLUTION "0;r0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the first screen; format is x[@] or 'auto'" }, + { OSDOPTION_VIEW "0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the first screen" }, - { OSDOPTION_SCREEN "1", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the second screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_ASPECT "1", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the second screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_RESOLUTION "1;r1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the second screen; format is x[@] or 'auto'" }, - { OSDOPTION_VIEW "1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the second screen" }, + { OSDOPTION_SCREEN "1", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the second screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_ASPECT "1", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the second screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_RESOLUTION "1;r1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the second screen; format is x[@] or 'auto'" }, + { OSDOPTION_VIEW "1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the second screen" }, - { OSDOPTION_SCREEN "2", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the third screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_ASPECT "2", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the third screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_RESOLUTION "2;r2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the third screen; format is x[@] or 'auto'" }, - { OSDOPTION_VIEW "2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the third screen" }, + { OSDOPTION_SCREEN "2", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the third screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_ASPECT "2", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the third screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_RESOLUTION "2;r2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the third screen; format is x[@] or 'auto'" }, + { OSDOPTION_VIEW "2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the third screen" }, - { OSDOPTION_SCREEN "3", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the fourth screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_ASPECT "3", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_RESOLUTION "3;r3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the fourth screen; format is x[@] or 'auto'" }, - { OSDOPTION_VIEW "3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the fourth screen" }, + { OSDOPTION_SCREEN "3", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the fourth screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_ASPECT "3", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_RESOLUTION "3;r3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the fourth screen; format is x[@] or 'auto'" }, + { OSDOPTION_VIEW "3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the fourth screen" }, - // full screen options - { NULL, NULL, OPTION_HEADER, "OSD FULL SCREEN OPTIONS" }, - { OSDOPTION_SWITCHRES, "0", OPTION_BOOLEAN, "enable resolution switching" }, + // full screen options + { NULL, NULL, OPTION_HEADER, "OSD FULL SCREEN OPTIONS" }, + { OSDOPTION_SWITCHRES, "0", OPTION_BOOLEAN, "enable resolution switching" }, - // sound options - { NULL, NULL, OPTION_HEADER, "OSD SOUND OPTIONS" }, - { OSDOPTION_SOUND, OSDOPTVAL_AUTO, OPTION_STRING, "sound output method: " }, - { OSDOPTION_AUDIO_LATENCY "(1-5)", "2", OPTION_INTEGER, "set audio latency (increase to reduce glitches, decrease for responsiveness)" }, + // sound options + { NULL, NULL, OPTION_HEADER, "OSD SOUND OPTIONS" }, + { OSDOPTION_SOUND, OSDOPTVAL_AUTO, OPTION_STRING, "sound output method: " }, + { OSDOPTION_AUDIO_LATENCY "(1-5)", "2", OPTION_INTEGER, "set audio latency (increase to reduce glitches, decrease for responsiveness)" }, - // End of list - { NULL } + // End of list + { NULL } }; osd_options::osd_options() : cli_options() { - add_entries(osd_options::s_option_entries); + add_entries(osd_options::s_option_entries); }; @@ -99,9 +99,9 @@ osd_options::osd_options() osd_common_t::osd_common_t(osd_options &options) : m_machine(NULL), - m_options(options), - m_sound(NULL), - m_debugger(NULL) + m_options(options), + m_sound(NULL), + m_debugger(NULL) { } @@ -110,52 +110,51 @@ osd_common_t::osd_common_t(osd_options &options) void osd_common_t::register_options() { + REGISTER_MODULE(m_mod_man, FONT_OSX); + REGISTER_MODULE(m_mod_man, FONT_WINDOWS); + REGISTER_MODULE(m_mod_man, FONT_SDL); + REGISTER_MODULE(m_mod_man, FONT_NONE); - REGISTER_MODULE(m_mod_man, FONT_OSX); - REGISTER_MODULE(m_mod_man, FONT_WINDOWS); - REGISTER_MODULE(m_mod_man, FONT_SDL); - REGISTER_MODULE(m_mod_man, FONT_NONE); - - REGISTER_MODULE(m_mod_man, SOUND_DSOUND); - REGISTER_MODULE(m_mod_man, SOUND_JS); - REGISTER_MODULE(m_mod_man, SOUND_SDL); - REGISTER_MODULE(m_mod_man, SOUND_NONE); + REGISTER_MODULE(m_mod_man, SOUND_DSOUND); + REGISTER_MODULE(m_mod_man, SOUND_JS); + REGISTER_MODULE(m_mod_man, SOUND_SDL); + REGISTER_MODULE(m_mod_man, SOUND_NONE); #ifdef SDLMAME_MACOSX - REGISTER_MODULE(m_mod_man, DEBUG_OSX); + REGISTER_MODULE(m_mod_man, DEBUG_OSX); #endif - REGISTER_MODULE(m_mod_man, DEBUG_WINDOWS); - REGISTER_MODULE(m_mod_man, DEBUG_QT); - REGISTER_MODULE(m_mod_man, DEBUG_INTERNAL); - REGISTER_MODULE(m_mod_man, DEBUG_NONE); + REGISTER_MODULE(m_mod_man, DEBUG_WINDOWS); + REGISTER_MODULE(m_mod_man, DEBUG_QT); + REGISTER_MODULE(m_mod_man, DEBUG_INTERNAL); + REGISTER_MODULE(m_mod_man, DEBUG_NONE); - // after initialization we know which modules are supported + // after initialization we know which modules are supported - const char *names[20]; - int num; - m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names); - dynamic_array dnames; - for (int i = 0; i < num; i++) - dnames.append(names[i]); - update_option(OSD_FONT_PROVIDER, dnames); + const char *names[20]; + int num; + m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names); + dynamic_array dnames; + for (int i = 0; i < num; i++) + dnames.append(names[i]); + update_option(OSD_FONT_PROVIDER, dnames); - m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, &num, names); - dnames.reset(); - for (int i = 0; i < num; i++) - dnames.append(names[i]); - update_option(OSD_SOUND_PROVIDER, dnames); + m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, &num, names); + dnames.reset(); + for (int i = 0; i < num; i++) + dnames.append(names[i]); + update_option(OSD_SOUND_PROVIDER, dnames); - // Register debugger options and update options - m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, &num, names); - dnames.reset(); - for (int i = 0; i < num; i++) - dnames.append(names[i]); - update_option(OSD_DEBUG_PROVIDER, dnames); + // Register debugger options and update options + m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, &num, names); + dnames.reset(); + for (int i = 0; i < num; i++) + dnames.append(names[i]); + update_option(OSD_DEBUG_PROVIDER, dnames); - // Register video options and update options - video_options_add("none", NULL); - video_register(); - update_option(OSDOPTION_VIDEO, m_video_names); + // Register video options and update options + video_options_add("none", NULL); + video_register(); + update_option(OSDOPTION_VIDEO, m_video_names); } void osd_common_t::update_option(const char * key, dynamic_array &values) @@ -305,7 +304,7 @@ void osd_common_t::update_audio_stream(const INT16 *buffer, int samples_this_fra // It provides an array of stereo samples in L-R order which should be // output at the configured sample_rate. // - m_sound->update_audio_stream(m_machine->video().throttled(), buffer,samples_this_frame); + m_sound->update_audio_stream(m_machine->video().throttled(), buffer,samples_this_frame); } @@ -322,8 +321,8 @@ void osd_common_t::set_mastervolume(int attenuation) // while (attenuation++ < 0) // volume /= 1.122018454; // = (10 ^ (1/20)) = 1dB // - if (m_sound != NULL) - m_sound->set_mastervolume(attenuation); + if (m_sound != NULL) + m_sound->set_mastervolume(attenuation); } @@ -398,20 +397,20 @@ void *osd_common_t::get_slider_list() bool osd_common_t::execute_command(const char *command) { - if (strcmp(command, OSDCOMMAND_LIST_NETWORK_ADAPTERS) == 0) - { - network_init(); - osd_list_network_adapters(); - network_exit(); - return true; - } - else if (strcmp(command, OSDCOMMAND_LIST_MIDI_DEVICES) == 0) - { - osd_list_midi_devices(); - return true; - } + if (strcmp(command, OSDCOMMAND_LIST_NETWORK_ADAPTERS) == 0) + { + network_init(); + osd_list_network_adapters(); + network_exit(); + return true; + } + else if (strcmp(command, OSDCOMMAND_LIST_MIDI_DEVICES) == 0) + { + osd_list_midi_devices(); + return true; + } - return false; + return false; } @@ -437,15 +436,15 @@ void osd_common_t::init_subsystems() #endif midi_init(); - m_font_module = select_module_options(options(), OSD_FONT_PROVIDER); + m_font_module = select_module_options(options(), OSD_FONT_PROVIDER); - m_sound = select_module_options(options(), OSD_SOUND_PROVIDER); - m_sound->m_sample_rate = options().sample_rate(); - m_sound->m_audio_latency = options().audio_latency(); + m_sound = select_module_options(options(), OSD_SOUND_PROVIDER); + m_sound->m_sample_rate = options().sample_rate(); + m_sound->m_audio_latency = options().audio_latency(); - m_debugger = select_module_options(options(), OSD_DEBUG_PROVIDER); + m_debugger = select_module_options(options(), OSD_DEBUG_PROVIDER); - m_mod_man.init(); + m_mod_man.init(); } @@ -524,9 +523,9 @@ void osd_common_t::network_exit() void osd_common_t::osd_exit() { - m_mod_man.exit(); + m_mod_man.exit(); - exit_subsystems(); + exit_subsystems(); } void osd_common_t::video_options_add(const char *name, void *type) @@ -537,13 +536,11 @@ void osd_common_t::video_options_add(const char *name, void *type) bool osd_common_t::midi_init() { - // this should be done on the OS_level - return osd_midi_init(); + // this should be done on the OS_level + return osd_midi_init(); } void osd_common_t::midi_exit() { - osd_midi_exit(); + osd_midi_exit(); } - - diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h index 3ea631a4495..322bcadf682 100644 --- a/src/osd/modules/lib/osdobj_common.h +++ b/src/osd/modules/lib/osdobj_common.h @@ -62,47 +62,47 @@ class osd_options : public cli_options { public: - // construction/destruction - osd_options(); + // construction/destruction + osd_options(); - // debugging options - const char *debugger() const { return value(OSDOPTION_DEBUGGER); } - int watchdog() const { return int_value(OSDOPTION_WATCHDOG); } + // debugging options + const char *debugger() const { return value(OSDOPTION_DEBUGGER); } + int watchdog() const { return int_value(OSDOPTION_WATCHDOG); } - // performance options - bool multithreading() const { return bool_value(OSDOPTION_MULTITHREADING); } - const char *numprocessors() const { return value(OSDOPTION_NUMPROCESSORS); } - int bench() const { return int_value(OSDOPTION_BENCH); } + // performance options + bool multithreading() const { return bool_value(OSDOPTION_MULTITHREADING); } + const char *numprocessors() const { return value(OSDOPTION_NUMPROCESSORS); } + int bench() const { return int_value(OSDOPTION_BENCH); } - // video options - const char *video() const { return value(OSDOPTION_VIDEO); } - int numscreens() const { return int_value(OSDOPTION_NUMSCREENS); } - bool window() const { return bool_value(OSDOPTION_WINDOW); } - bool maximize() const { return bool_value(OSDOPTION_MAXIMIZE); } - bool keep_aspect() const { return bool_value(OSDOPTION_KEEPASPECT); } - bool uneven_stretch() const { return bool_value(OSDOPTION_UNEVENSTRETCH); } - bool wait_vsync() const { return bool_value(OSDOPTION_WAITVSYNC); } - bool sync_refresh() const { return bool_value(OSDOPTION_SYNCREFRESH); } + // video options + const char *video() const { return value(OSDOPTION_VIDEO); } + int numscreens() const { return int_value(OSDOPTION_NUMSCREENS); } + bool window() const { return bool_value(OSDOPTION_WINDOW); } + bool maximize() const { return bool_value(OSDOPTION_MAXIMIZE); } + bool keep_aspect() const { return bool_value(OSDOPTION_KEEPASPECT); } + bool uneven_stretch() const { return bool_value(OSDOPTION_UNEVENSTRETCH); } + bool wait_vsync() const { return bool_value(OSDOPTION_WAITVSYNC); } + bool sync_refresh() const { return bool_value(OSDOPTION_SYNCREFRESH); } - // per-window options - const char *screen() const { return value(OSDOPTION_SCREEN); } - const char *aspect() const { return value(OSDOPTION_ASPECT); } - const char *resolution() const { return value(OSDOPTION_RESOLUTION); } - const char *view() const { return value(OSDOPTION_VIEW); } - const char *screen(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_SCREEN, index)); } - const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_ASPECT, index)); } - const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_RESOLUTION, index)); } - const char *view(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_VIEW, index)); } + // per-window options + const char *screen() const { return value(OSDOPTION_SCREEN); } + const char *aspect() const { return value(OSDOPTION_ASPECT); } + const char *resolution() const { return value(OSDOPTION_RESOLUTION); } + const char *view() const { return value(OSDOPTION_VIEW); } + const char *screen(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_SCREEN, index)); } + const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_ASPECT, index)); } + const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_RESOLUTION, index)); } + const char *view(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_VIEW, index)); } - // full screen options - bool switch_res() const { return bool_value(OSDOPTION_SWITCHRES); } + // full screen options + bool switch_res() const { return bool_value(OSDOPTION_SWITCHRES); } - // sound options - const char *sound() const { return value(OSDOPTION_SOUND); } - int audio_latency() const { return int_value(OSDOPTION_AUDIO_LATENCY); } + // sound options + const char *sound() const { return value(OSDOPTION_SOUND); } + int audio_latency() const { return int_value(OSDOPTION_AUDIO_LATENCY); } private: - static const options_entry s_option_entries[]; + static const options_entry s_option_entries[]; }; // ======================> osd_interface @@ -142,77 +142,77 @@ public: // video overridables virtual void *get_slider_list(); - // command option overrides - virtual bool execute_command(const char *command); + // command option overrides + virtual bool execute_command(const char *command); - osd_font *font_alloc() { return m_font_module->font_alloc(); } + osd_font *font_alloc() { return m_font_module->font_alloc(); } // FIXME: everything below seems to be osd specific and not part of // this INTERFACE but part of the osd IMPLEMENTATION - // getters - running_machine &machine() { assert(m_machine != NULL); return *m_machine; } + // getters + running_machine &machine() { assert(m_machine != NULL); return *m_machine; } - virtual void debugger_update(); + virtual void debugger_update(); - virtual void init_subsystems(); + virtual void init_subsystems(); - virtual bool video_init(); - virtual void video_register(); - virtual bool window_init(); + virtual bool video_init(); + virtual void video_register(); + virtual bool window_init(); - virtual void input_resume(); - virtual bool output_init(); - virtual bool network_init(); - virtual bool midi_init(); + virtual void input_resume(); + virtual bool output_init(); + virtual bool network_init(); + virtual bool midi_init(); - virtual void exit_subsystems(); - virtual void video_exit(); - virtual void window_exit(); - virtual void input_exit(); - virtual void output_exit(); - virtual void network_exit(); - virtual void midi_exit(); + virtual void exit_subsystems(); + virtual void video_exit(); + virtual void window_exit(); + virtual void input_exit(); + virtual void output_exit(); + virtual void network_exit(); + virtual void midi_exit(); - virtual void osd_exit(); + virtual void osd_exit(); - virtual void video_options_add(const char *name, void *type); + virtual void video_options_add(const char *name, void *type); - osd_options &options() { return m_options; } + osd_options &options() { return m_options; } protected: - virtual bool input_init(); - virtual void input_pause(); + virtual bool input_init(); + virtual void input_pause(); private: // internal state running_machine * m_machine; osd_options& m_options; - osd_module_manager m_mod_man; - font_module *m_font_module; + osd_module_manager m_mod_man; + font_module *m_font_module; void update_option(const char * key, dynamic_array &values); - // FIXME: should be elsewhere - osd_module *select_module_options(const core_options &opts, const astring &opt_name) - { - astring opt_val = opts.value(opt_name); - if (opt_val == "auto") - opt_val = ""; - else if (!m_mod_man.type_has_name(opt_name, opt_val)) - { - osd_printf_warning("Value %s not supported for option %s - falling back to auto\n", opt_val.cstr(), opt_name.cstr()); - opt_val = ""; - } - return m_mod_man.select_module(opt_name, opt_val); - } + // FIXME: should be elsewhere + osd_module *select_module_options(const core_options &opts, const astring &opt_name) + { + astring opt_val = opts.value(opt_name); + if (opt_val == "auto") + opt_val = ""; + else if (!m_mod_man.type_has_name(opt_name, opt_val)) + { + osd_printf_warning("Value %s not supported for option %s - falling back to auto\n", opt_val.cstr(), opt_name.cstr()); + opt_val = ""; + } + return m_mod_man.select_module(opt_name, opt_val); + } - template - C select_module_options(const core_options &opts, const astring &opt_name) - { - return dynamic_cast(select_module_options(opts, opt_name)); - } + template + C select_module_options(const core_options &opts, const astring &opt_name) + { + return dynamic_cast(select_module_options(opts, opt_name)); + } protected: sound_module* m_sound; diff --git a/src/osd/modules/midi/none.c b/src/osd/modules/midi/none.c index 2f5658fc973..4319eef5ea8 100644 --- a/src/osd/modules/midi/none.c +++ b/src/osd/modules/midi/none.c @@ -10,12 +10,12 @@ struct osd_midi_device { - int dummy; + int dummy; }; bool osd_midi_init() { - return true; + return true; } void osd_midi_exit() @@ -24,17 +24,17 @@ void osd_midi_exit() void osd_list_midi_devices(void) { - osd_printf_warning("\nMIDI is not supported in this build\n"); + osd_printf_warning("\nMIDI is not supported in this build\n"); } osd_midi_device *osd_open_midi_input(const char *devname) { - return NULL; + return NULL; } osd_midi_device *osd_open_midi_output(const char *devname) { - return NULL; + return NULL; } void osd_close_midi_channel(osd_midi_device *dev) @@ -43,12 +43,12 @@ void osd_close_midi_channel(osd_midi_device *dev) bool osd_poll_midi_channel(osd_midi_device *dev) { - return false; + return false; } int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut) { - return 0; + return 0; } void osd_write_midi_channel(osd_midi_device *dev, UINT8 data) diff --git a/src/osd/modules/midi/portmidi.c b/src/osd/modules/midi/portmidi.c index 2e0add931a3..0b93bf690dd 100644 --- a/src/osd/modules/midi/portmidi.c +++ b/src/osd/modules/midi/portmidi.c @@ -16,405 +16,405 @@ static const int RX_EVENT_BUF_SIZE = 512; struct osd_midi_device { - PortMidiStream *pmStream; - PmEvent rx_evBuf[RX_EVENT_BUF_SIZE]; - UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes - int xmit_cnt; - UINT8 last_status; - bool rx_sysex; + PortMidiStream *pmStream; + PmEvent rx_evBuf[RX_EVENT_BUF_SIZE]; + UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes + int xmit_cnt; + UINT8 last_status; + bool rx_sysex; }; bool osd_midi_init() { - Pm_Initialize(); - return true; + Pm_Initialize(); + return true; } void osd_midi_exit() { - Pm_Terminate(); + Pm_Terminate(); } void osd_list_midi_devices(void) { - int num_devs = Pm_CountDevices(); - const PmDeviceInfo *pmInfo; + int num_devs = Pm_CountDevices(); + const PmDeviceInfo *pmInfo; - printf("\n"); + printf("\n"); - if (num_devs == 0) - { - printf("No MIDI ports were found\n"); - return; - } + if (num_devs == 0) + { + printf("No MIDI ports were found\n"); + return; + } - printf("MIDI input ports:\n"); - for (int i = 0; i < num_devs; i++) - { - pmInfo = Pm_GetDeviceInfo(i); + printf("MIDI input ports:\n"); + for (int i = 0; i < num_devs; i++) + { + pmInfo = Pm_GetDeviceInfo(i); - if (pmInfo->input) - { - printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultInputDeviceID()) ? "(default)" : ""); - } - } + if (pmInfo->input) + { + printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultInputDeviceID()) ? "(default)" : ""); + } + } - printf("\nMIDI output ports:\n"); - for (int i = 0; i < num_devs; i++) - { - pmInfo = Pm_GetDeviceInfo(i); + printf("\nMIDI output ports:\n"); + for (int i = 0; i < num_devs; i++) + { + pmInfo = Pm_GetDeviceInfo(i); - if (pmInfo->output) - { - printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultOutputDeviceID()) ? "(default)" : ""); - } - } + if (pmInfo->output) + { + printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultOutputDeviceID()) ? "(default)" : ""); + } + } } osd_midi_device *osd_open_midi_input(const char *devname) { - int num_devs = Pm_CountDevices(); - int found_dev = -1; - const PmDeviceInfo *pmInfo; - PortMidiStream *stm; - osd_midi_device *ret; + int num_devs = Pm_CountDevices(); + int found_dev = -1; + const PmDeviceInfo *pmInfo; + PortMidiStream *stm; + osd_midi_device *ret; - if (!strcmp("default", devname)) - { - found_dev = Pm_GetDefaultInputDeviceID(); - } - else - { - for (int i = 0; i < num_devs; i++) - { - pmInfo = Pm_GetDeviceInfo(i); + if (!strcmp("default", devname)) + { + found_dev = Pm_GetDefaultInputDeviceID(); + } + else + { + for (int i = 0; i < num_devs; i++) + { + pmInfo = Pm_GetDeviceInfo(i); - if (pmInfo->input) - { - if (!strcmp(devname, pmInfo->name)) - { - found_dev = i; - break; - } - } - } - } + if (pmInfo->input) + { + if (!strcmp(devname, pmInfo->name)) + { + found_dev = i; + break; + } + } + } + } - if (found_dev >= 0) - { - if (Pm_OpenInput(&stm, found_dev, NULL, RX_EVENT_BUF_SIZE, NULL, NULL) == pmNoError) - { - ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); - memset(ret, 0, sizeof(osd_midi_device)); - ret->pmStream = stm; - return ret; - } - else - { - printf("Couldn't open PM device\n"); - return NULL; - } - } - else - { - return NULL; - } + if (found_dev >= 0) + { + if (Pm_OpenInput(&stm, found_dev, NULL, RX_EVENT_BUF_SIZE, NULL, NULL) == pmNoError) + { + ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); + memset(ret, 0, sizeof(osd_midi_device)); + ret->pmStream = stm; + return ret; + } + else + { + printf("Couldn't open PM device\n"); + return NULL; + } + } + else + { + return NULL; + } } osd_midi_device *osd_open_midi_output(const char *devname) { - int num_devs = Pm_CountDevices(); - int found_dev = -1; - const PmDeviceInfo *pmInfo; - PortMidiStream *stm; - osd_midi_device *ret; + int num_devs = Pm_CountDevices(); + int found_dev = -1; + const PmDeviceInfo *pmInfo; + PortMidiStream *stm; + osd_midi_device *ret; - if (!strcmp("default", devname)) - { - found_dev = Pm_GetDefaultOutputDeviceID(); - } - else - { - for (int i = 0; i < num_devs; i++) - { - pmInfo = Pm_GetDeviceInfo(i); + if (!strcmp("default", devname)) + { + found_dev = Pm_GetDefaultOutputDeviceID(); + } + else + { + for (int i = 0; i < num_devs; i++) + { + pmInfo = Pm_GetDeviceInfo(i); - if (pmInfo->output) - { - if (!strcmp(devname, pmInfo->name)) - { - found_dev = i; - break; - } - } - } - } + if (pmInfo->output) + { + if (!strcmp(devname, pmInfo->name)) + { + found_dev = i; + break; + } + } + } + } - if (found_dev >= 0) - { - if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError) - { - ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); - memset(ret, 0, sizeof(osd_midi_device)); - ret->pmStream = stm; - return ret; - } - else - { - printf("Couldn't open PM device\n"); - return NULL; - } - } - else - { - return NULL; - } - return NULL; + if (found_dev >= 0) + { + if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError) + { + ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); + memset(ret, 0, sizeof(osd_midi_device)); + ret->pmStream = stm; + return ret; + } + else + { + printf("Couldn't open PM device\n"); + return NULL; + } + } + else + { + return NULL; + } + return NULL; } void osd_close_midi_channel(osd_midi_device *dev) { - Pm_Close(dev->pmStream); - osd_free(dev); + Pm_Close(dev->pmStream); + osd_free(dev); } bool osd_poll_midi_channel(osd_midi_device *dev) { - PmError chk = Pm_Poll(dev->pmStream); + PmError chk = Pm_Poll(dev->pmStream); - return (chk == pmGotData) ? true : false; + return (chk == pmGotData) ? true : false; } int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut) { - int msgsRead = Pm_Read(dev->pmStream, dev->rx_evBuf, RX_EVENT_BUF_SIZE); - int bytesOut = 0; + int msgsRead = Pm_Read(dev->pmStream, dev->rx_evBuf, RX_EVENT_BUF_SIZE); + int bytesOut = 0; - if (msgsRead <= 0) - { - return 0; - } + if (msgsRead <= 0) + { + return 0; + } - for (int msg = 0; msg < msgsRead; msg++) - { - UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message); + for (int msg = 0; msg < msgsRead; msg++) + { + UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message); - if (dev->rx_sysex) - { - if (status & 0x80) // sys real-time imposing on us? - { - if ((status == 0xf2) || (status == 0xf3)) - { - *pOut++ = status; - *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); - *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); - bytesOut += 3; - } - else - { - *pOut++ = status; - bytesOut++; - if (status == MIDI_EOX) - { - dev->rx_sysex = false; - } - } - } - else // shift out the sysex bytes - { - for (int i = 0; i < 4; i++) - { - UINT8 byte = dev->rx_evBuf[msg].message & 0xff; - *pOut++ = byte; - bytesOut++; - if (byte == MIDI_EOX) - { - dev->rx_sysex = false; - break; - } - dev->rx_evBuf[msg].message >>= 8; - } - } - } - else - { - switch ((status>>4) & 0xf) - { - case 0xc: // 2-byte messages - case 0xd: - *pOut++ = status; - *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); - bytesOut += 2; - break; + if (dev->rx_sysex) + { + if (status & 0x80) // sys real-time imposing on us? + { + if ((status == 0xf2) || (status == 0xf3)) + { + *pOut++ = status; + *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); + *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); + bytesOut += 3; + } + else + { + *pOut++ = status; + bytesOut++; + if (status == MIDI_EOX) + { + dev->rx_sysex = false; + } + } + } + else // shift out the sysex bytes + { + for (int i = 0; i < 4; i++) + { + UINT8 byte = dev->rx_evBuf[msg].message & 0xff; + *pOut++ = byte; + bytesOut++; + if (byte == MIDI_EOX) + { + dev->rx_sysex = false; + break; + } + dev->rx_evBuf[msg].message >>= 8; + } + } + } + else + { + switch ((status>>4) & 0xf) + { + case 0xc: // 2-byte messages + case 0xd: + *pOut++ = status; + *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); + bytesOut += 2; + break; - case 0xf: // system common - switch (status & 0xf) - { - case 0: // System Exclusive - { - *pOut++ = status; // this should be OK: the shortest legal sysex is F0 tt dd F7, I believe - *pOut++ = (dev->rx_evBuf[msg].message>>8) & 0xff; - *pOut++ = (dev->rx_evBuf[msg].message>>16) & 0xff; - UINT8 last = *pOut++ = (dev->rx_evBuf[msg].message>>24) & 0xff; - bytesOut += 4; - dev->rx_sysex = (last != MIDI_EOX); - break; - } + case 0xf: // system common + switch (status & 0xf) + { + case 0: // System Exclusive + { + *pOut++ = status; // this should be OK: the shortest legal sysex is F0 tt dd F7, I believe + *pOut++ = (dev->rx_evBuf[msg].message>>8) & 0xff; + *pOut++ = (dev->rx_evBuf[msg].message>>16) & 0xff; + UINT8 last = *pOut++ = (dev->rx_evBuf[msg].message>>24) & 0xff; + bytesOut += 4; + dev->rx_sysex = (last != MIDI_EOX); + break; + } - case 7: // End of System Exclusive - *pOut++ = status; - bytesOut += 1; - dev->rx_sysex = false; - break; + case 7: // End of System Exclusive + *pOut++ = status; + bytesOut += 1; + dev->rx_sysex = false; + break; - case 2: // song pos - case 3: // song select - *pOut++ = status; - *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); - *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); - bytesOut += 3; - break; + case 2: // song pos + case 3: // song select + *pOut++ = status; + *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); + *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); + bytesOut += 3; + break; - default: // all other defined Fx messages are 1 byte - break; - } - break; + default: // all other defined Fx messages are 1 byte + break; + } + break; - default: - *pOut++ = status; - *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); - *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); - bytesOut += 3; - break; - } - } - } + default: + *pOut++ = status; + *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); + *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); + bytesOut += 3; + break; + } + } + } - return bytesOut; + return bytesOut; } void osd_write_midi_channel(osd_midi_device *dev, UINT8 data) { - int bytes_needed = 0; - PmEvent ev; - ev.timestamp = 0; // use the current time + int bytes_needed = 0; + PmEvent ev; + ev.timestamp = 0; // use the current time // printf("write: %02x (%d)\n", data, dev->xmit_cnt); - // reject data bytes when no valid status exists - if ((dev->last_status == 0) && !(data & 0x80)) - { - dev->xmit_cnt = 0; - return; - } + // reject data bytes when no valid status exists + if ((dev->last_status == 0) && !(data & 0x80)) + { + dev->xmit_cnt = 0; + return; + } - if (dev->xmit_cnt >= 4) - { - printf("MIDI out: packet assembly overflow, contact MAMEdev!\n"); - return; - } + if (dev->xmit_cnt >= 4) + { + printf("MIDI out: packet assembly overflow, contact MAMEdev!\n"); + return; + } - // handle sysex - if (dev->last_status == MIDI_SYSEX) - { + // handle sysex + if (dev->last_status == MIDI_SYSEX) + { // printf("sysex: %02x (%d)\n", data, dev->xmit_cnt); - // if we get a status that isn't sysex, assume it's system common - if ((data & 0x80) && (data != MIDI_EOX)) - { + // if we get a status that isn't sysex, assume it's system common + if ((data & 0x80) && (data != MIDI_EOX)) + { // printf("common during sysex!\n"); - ev.message = Pm_Message(data, 0, 0); - Pm_Write(dev->pmStream, &ev, 1); - return; - } + ev.message = Pm_Message(data, 0, 0); + Pm_Write(dev->pmStream, &ev, 1); + return; + } - dev->xmit_in[dev->xmit_cnt++] = data; + dev->xmit_in[dev->xmit_cnt++] = data; - // if EOX or 4 bytes filled, transmit 4 bytes - if ((dev->xmit_cnt == 4) || (data == MIDI_EOX)) - { - ev.message = dev->xmit_in[0] | (dev->xmit_in[1]<<8) | (dev->xmit_in[2]<<16) | (dev->xmit_in[3]<<24); - Pm_Write(dev->pmStream, &ev, 1); - dev->xmit_in[0] = dev->xmit_in[1] = dev->xmit_in[2] = dev->xmit_in[3] = 0; - dev->xmit_cnt = 0; + // if EOX or 4 bytes filled, transmit 4 bytes + if ((dev->xmit_cnt == 4) || (data == MIDI_EOX)) + { + ev.message = dev->xmit_in[0] | (dev->xmit_in[1]<<8) | (dev->xmit_in[2]<<16) | (dev->xmit_in[3]<<24); + Pm_Write(dev->pmStream, &ev, 1); + dev->xmit_in[0] = dev->xmit_in[1] = dev->xmit_in[2] = dev->xmit_in[3] = 0; + dev->xmit_cnt = 0; // printf("SysEx packet: %08x\n", ev.message); - // if this is EOX, kill the running status - if (data == MIDI_EOX) - { - dev->last_status = 0; - } - } + // if this is EOX, kill the running status + if (data == MIDI_EOX) + { + dev->last_status = 0; + } + } - return; - } + return; + } - // handle running status. don't allow system real-time messages to be considered as running status. - if ((dev->xmit_cnt == 0) && (data & 0x80) && (data < 0xf8)) - { - dev->last_status = data; - } + // handle running status. don't allow system real-time messages to be considered as running status. + if ((dev->xmit_cnt == 0) && (data & 0x80) && (data < 0xf8)) + { + dev->last_status = data; + } - if ((dev->xmit_cnt == 0) && !(data & 0x80)) - { - dev->xmit_in[dev->xmit_cnt++] = dev->last_status; - dev->xmit_in[dev->xmit_cnt++] = data; + if ((dev->xmit_cnt == 0) && !(data & 0x80)) + { + dev->xmit_in[dev->xmit_cnt++] = dev->last_status; + dev->xmit_in[dev->xmit_cnt++] = data; // printf("\trunning status: [%d] = %02x, [%d] = %02x, last_status = %02x\n", dev->xmit_cnt-2, dev->last_status, dev->xmit_cnt-1, data, dev->last_status); - } - else - { - dev->xmit_in[dev->xmit_cnt++] = data; + } + else + { + dev->xmit_in[dev->xmit_cnt++] = data; // printf("\tNRS: [%d] = %02x\n", dev->xmit_cnt-1, data); - } + } - if ((dev->xmit_cnt == 1) && (dev->xmit_in[0] == MIDI_SYSEX)) - { + if ((dev->xmit_cnt == 1) && (dev->xmit_in[0] == MIDI_SYSEX)) + { // printf("Start SysEx!\n"); - dev->last_status = MIDI_SYSEX; - return; - } + dev->last_status = MIDI_SYSEX; + return; + } - // are we there yet? + // are we there yet? // printf("status check: %02x\n", dev->xmit_in[0]); - switch ((dev->xmit_in[0]>>4) & 0xf) - { - case 0xc: // 2-byte messages - case 0xd: - bytes_needed = 2; - break; + switch ((dev->xmit_in[0]>>4) & 0xf) + { + case 0xc: // 2-byte messages + case 0xd: + bytes_needed = 2; + break; - case 0xf: // system common - switch (dev->xmit_in[0] & 0xf) - { - case 0: // System Exclusive is handled above - break; + case 0xf: // system common + switch (dev->xmit_in[0] & 0xf) + { + case 0: // System Exclusive is handled above + break; - case 7: // End of System Exclusive - bytes_needed = 1; - break; + case 7: // End of System Exclusive + bytes_needed = 1; + break; - case 2: // song pos - case 3: // song select - bytes_needed = 3; - break; + case 2: // song pos + case 3: // song select + bytes_needed = 3; + break; - default: // all other defined Fx messages are 1 byte - bytes_needed = 1; - break; - } - break; + default: // all other defined Fx messages are 1 byte + bytes_needed = 1; + break; + } + break; - default: - bytes_needed = 3; - break; - } + default: + bytes_needed = 3; + break; + } - if (dev->xmit_cnt == bytes_needed) - { - ev.message = Pm_Message(dev->xmit_in[0], dev->xmit_in[1], dev->xmit_in[2]); - Pm_Write(dev->pmStream, &ev, 1); - dev->xmit_cnt = 0; - } + if (dev->xmit_cnt == bytes_needed) + { + ev.message = Pm_Message(dev->xmit_in[0], dev->xmit_in[1], dev->xmit_in[2]); + Pm_Write(dev->pmStream, &ev, 1); + dev->xmit_cnt = 0; + } } diff --git a/src/osd/modules/osdmodule.c b/src/osd/modules/osdmodule.c index e907d89249e..06c36b0e3d4 100644 --- a/src/osd/modules/osdmodule.c +++ b/src/osd/modules/osdmodule.c @@ -7,110 +7,108 @@ osd_module_manager::osd_module_manager() { - for (int i=0; i~osd_module(); - osd_free(m_modules[i]); - } + for (int i = 0; m_modules[i] != NULL; i++) + { + m_modules[i]->~osd_module(); + osd_free(m_modules[i]); + } } void osd_module_manager::register_module(const module_type &mod_type) { - osd_module *module = mod_type(); - if (module->probe()) - { - osd_printf_verbose("===> registered module %s %s\n", module->name(), module->type()); + osd_module *module = mod_type(); + if (module->probe()) + { + osd_printf_verbose("===> registered module %s %s\n", module->name(), module->type()); - int i; - for (i = 0; m_modules[i] != NULL; i++) - ; - m_modules[i] = module; - } - else - { - osd_printf_verbose("===> not supported %s %s\n", module->name(), module->type()); - module->~osd_module(); - osd_free(module); - } + int i; + for (i = 0; m_modules[i] != NULL; i++) + ; + m_modules[i] = module; + } + else + { + osd_printf_verbose("===> not supported %s %s\n", module->name(), module->type()); + module->~osd_module(); + osd_free(module); + } } bool osd_module_manager::type_has_name(const char *type, const char *name) { - return (get_module_index(type, name) >= 0); + return (get_module_index(type, name) >= 0); } osd_module *osd_module_manager::get_module_generic(const char *type, const char *name) { - int i = get_module_index(type, name); - if (i>=0) - return m_modules[i]; - else - return NULL; + int i = get_module_index(type, name); + if (i>=0) + return m_modules[i]; + else + return NULL; } osd_module *osd_module_manager::select_module(const char *type, const char *name) { - osd_module *m = get_module_generic(type, name); + osd_module *m = get_module_generic(type, name); - // FIXME: check if already exists! - int i; - for (i = 0; m_selected[i] != NULL; i++) - ; - m_selected[i] = m; - return m; + // FIXME: check if already exists! + int i; + for (i = 0; m_selected[i] != NULL; i++) + ; + m_selected[i] = m; + return m; } void osd_module_manager::init() { - for (int i = 0; m_selected[i] != NULL; i++) - { - m_selected[i]->init(); - } + for (int i = 0; m_selected[i] != NULL; i++) + { + m_selected[i]->init(); + } } void osd_module_manager::exit() { - // Find count - int cnt; - for (cnt = 0; m_selected[cnt] != NULL; cnt++) - ; - for (int i = cnt - 1; i >= 0; i--) - { - m_selected[i]->exit(); - m_selected[i] = NULL; - } + // Find count + int cnt; + for (cnt = 0; m_selected[cnt] != NULL; cnt++) + ; + for (int i = cnt - 1; i >= 0; i--) + { + m_selected[i]->exit(); + m_selected[i] = NULL; + } } int osd_module_manager::get_module_index(const char *type, const char *name) { - for (int i = 0; m_modules[i] != NULL; i++) - { - if (strcmp(m_modules[i]->type(), type) == 0 && ((name[0] == 0) || (strcmp(name, m_modules[i]->name())==0))) - return i; - } - return -1; + for (int i = 0; m_modules[i] != NULL; i++) + { + if (strcmp(m_modules[i]->type(), type) == 0 && ((name[0] == 0) || (strcmp(name, m_modules[i]->name())==0))) + return i; + } + return -1; } void osd_module_manager::get_module_names(const char *type, const int max, int *num, const char *names[]) { - *num = 0; - for (int i = 0; m_modules[i] != NULL; i++) - { - if ((strcmp(m_modules[i]->type(), type) == 0) && (*num < max)) - { - names[*num] = m_modules[i]->name(); - *num = *num + 1; - } + *num = 0; + for (int i = 0; m_modules[i] != NULL; i++) + { + if ((strcmp(m_modules[i]->type(), type) == 0) && (*num < max)) + { + names[*num] = m_modules[i]->name(); + *num = *num + 1; + } - } + } } - - diff --git a/src/osd/modules/osdmodule.h b/src/osd/modules/osdmodule.h index 9d24f56a0ec..15748d39ca9 100644 --- a/src/osd/modules/osdmodule.h +++ b/src/osd/modules/osdmodule.h @@ -26,22 +26,22 @@ class osd_module { public: - osd_module(const char *type, const char *name) - : m_name(name), m_type(type) - {} - virtual ~osd_module() { } + osd_module(const char *type, const char *name) + : m_name(name), m_type(type) + {} + virtual ~osd_module() { } - const char * name() const { return m_name; } - const char * type() const { return m_type; } + const char * name() const { return m_name; } + const char * type() const { return m_type; } - virtual bool probe() const { return true; } + virtual bool probe() const { return true; } - virtual int init() { return 0; } - virtual void exit() { } + virtual int init() { return 0; } + virtual void exit() { } private: - astring m_name; - astring m_type; + astring m_name; + astring m_type; }; // a module_type is simply a pointer to its alloc function @@ -51,56 +51,56 @@ typedef osd_module *(*module_type)(); template osd_module *module_creator() { - void *p = osd_malloc(sizeof(_ModuleClass)); - return new(p) _ModuleClass; + void *p = osd_malloc(sizeof(_ModuleClass)); + return new(p) _ModuleClass; } class osd_module_manager { public: - static const int MAX_MODULES = 32; + static const int MAX_MODULES = 32; - osd_module_manager(); - ~osd_module_manager(); + osd_module_manager(); + ~osd_module_manager(); - void register_module(const module_type &mod_type); - bool type_has_name(const char *type, const char *name); + void register_module(const module_type &mod_type); + bool type_has_name(const char *type, const char *name); - osd_module *get_module_generic(const char *type, const char *name); + osd_module *get_module_generic(const char *type, const char *name); - template - C select_module(const char *type, const char *name = "") - { - return dynamic_cast(select_module(type, name)); - } + template + C select_module(const char *type, const char *name = "") + { + return dynamic_cast(select_module(type, name)); + } - osd_module *select_module(const char *type, const char *name = ""); + osd_module *select_module(const char *type, const char *name = ""); - void get_module_names(const char *type, const int max, int *num, const char *names[]); + void get_module_names(const char *type, const int max, int *num, const char *names[]); - void init(); + void init(); - void exit(); + void exit(); private: - int get_module_index(const char *type, const char *name); + int get_module_index(const char *type, const char *name); - osd_module *m_modules[MAX_MODULES]; - osd_module *m_selected[MAX_MODULES]; + osd_module *m_modules[MAX_MODULES]; + osd_module *m_selected[MAX_MODULES]; }; #define MODULE_DEFINITION(_id, _class) \ - extern const module_type _id ; \ - const module_type _id = &module_creator< _class >; + extern const module_type _id ; \ + const module_type _id = &module_creator< _class >; #define MODULE_NOT_SUPPORTED(_mod, _type, _name) \ - class _mod : public osd_module { \ - public: \ - _mod () \ - : osd_module(_type, _name) {} \ - bool probe() const { return false; } \ - }; + class _mod : public osd_module { \ + public: \ + _mod () \ + : osd_module(_type, _name) {} \ + bool probe() const { return false; } \ + }; #endif /* __OSDMODULE_H__ */ diff --git a/src/osd/modules/sound/direct_sound.c b/src/osd/modules/sound/direct_sound.c index 95e033b3351..bd30d730ee7 100644 --- a/src/osd/modules/sound/direct_sound.c +++ b/src/osd/modules/sound/direct_sound.c @@ -51,26 +51,26 @@ class sound_direct_sound : public osd_module, public sound_module { public: - sound_direct_sound() - : osd_module(OSD_SOUND_PROVIDER, "dsound"), sound_module() - { - } - virtual ~sound_direct_sound() { } + sound_direct_sound() + : osd_module(OSD_SOUND_PROVIDER, "dsound"), sound_module() + { + } + virtual ~sound_direct_sound() { } - virtual int init(); - virtual void exit(); + virtual int init(); + virtual void exit(); - // sound_module + // sound_module - virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame); - virtual void set_mastervolume(int attenuation); + virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame); + virtual void set_mastervolume(int attenuation); private: - HRESULT dsound_init(); - void dsound_kill(); - HRESULT dsound_create_buffers(); - void dsound_destroy_buffers(); - void copy_sample_data(const INT16 *data, int bytes_to_copy); + HRESULT dsound_init(); + void dsound_kill(); + HRESULT dsound_create_buffers(); + void dsound_destroy_buffers(); + void copy_sample_data(const INT16 *data, int bytes_to_copy); }; @@ -448,7 +448,7 @@ void sound_direct_sound::dsound_destroy_buffers(void) } #else /* SDLMAME_UNIX */ - MODULE_NOT_SUPPORTED(sound_direct_sound, OSD_SOUND_PROVIDER, "dsound") + MODULE_NOT_SUPPORTED(sound_direct_sound, OSD_SOUND_PROVIDER, "dsound") #endif MODULE_DEFINITION(SOUND_DSOUND, sound_direct_sound) diff --git a/src/osd/modules/sound/js_sound.c b/src/osd/modules/sound/js_sound.c index f3e11785633..93d76a22c4f 100644 --- a/src/osd/modules/sound/js_sound.c +++ b/src/osd/modules/sound/js_sound.c @@ -19,36 +19,36 @@ class sound_js : public osd_module, public sound_module { public: - sound_js() - : osd_module(OSD_SOUND_PROVIDER, "js"), sound_module() - { - } - virtual ~sound_js() { } + sound_js() + : osd_module(OSD_SOUND_PROVIDER, "js"), sound_module() + { + } + virtual ~sound_js() { } - virtual int init(); - virtual void exit(); + virtual int init(); + virtual void exit(); - // sound_module + // sound_module - virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame) - { - EM_ASM_ARGS({ - // Forward audio stream update on to JS backend implementation. - jsmess_update_audio_stream($1, $2); - }, (unsigned int)buffer, samples_this_frame); - } - virtual void set_mastervolume(int attenuation) - { - EM_ASM_ARGS({ - // Forward volume update on to JS backend implementation. - jsmess_set_mastervolume($0); - }, attenuation); - } + virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame) + { + EM_ASM_ARGS({ + // Forward audio stream update on to JS backend implementation. + jsmess_update_audio_stream($1, $2); + }, (unsigned int)buffer, samples_this_frame); + } + virtual void set_mastervolume(int attenuation) + { + EM_ASM_ARGS({ + // Forward volume update on to JS backend implementation. + jsmess_set_mastervolume($0); + }, attenuation); + } }; #else /* SDLMAME_UNIX */ - MODULE_NOT_SUPPORTED(sound_js, OSD_SOUND_PROVIDER, "js") + MODULE_NOT_SUPPORTED(sound_js, OSD_SOUND_PROVIDER, "js") #endif MODULE_DEFINITION(SOUND_JS, sound_js) diff --git a/src/osd/modules/sound/none.c b/src/osd/modules/sound/none.c index e0173d39d59..501b064afab 100644 --- a/src/osd/modules/sound/none.c +++ b/src/osd/modules/sound/none.c @@ -14,19 +14,19 @@ class sound_none : public osd_module, public sound_module { public: - sound_none() - : osd_module(OSD_SOUND_PROVIDER, "none"), sound_module() - { - } - virtual ~sound_none() { } + sound_none() + : osd_module(OSD_SOUND_PROVIDER, "none"), sound_module() + { + } + virtual ~sound_none() { } - virtual int init() { return 0; } - virtual void exit() { } + virtual int init() { return 0; } + virtual void exit() { } - // sound_module + // sound_module - virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame) { } - virtual void set_mastervolume(int attenuation) { } + virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame) { } + virtual void set_mastervolume(int attenuation) { } }; diff --git a/src/osd/modules/sound/sdl_sound.c b/src/osd/modules/sound/sdl_sound.c index bb46e9f6b91..185cb9976e7 100644 --- a/src/osd/modules/sound/sdl_sound.c +++ b/src/osd/modules/sound/sdl_sound.c @@ -12,7 +12,7 @@ #include "sound_module.h" #include "modules/osdmodule.h" -#if (!defined(SDLMAME_EMSCRIPTEN)) && (!defined(OSD_WINDOWS)) +#if (!defined(OSD_WINDOWS)) // standard sdl header #include "../../sdl/sdlinc.h" @@ -43,53 +43,53 @@ class sound_sdl : public osd_module, public sound_module { public: - friend void sdl_callback(void *userdata, Uint8 *stream, int len); + friend void sdl_callback(void *userdata, Uint8 *stream, int len); - // number of samples per SDL callback - static const int SDL_XFER_SAMPLES = 512; + // number of samples per SDL callback + static const int SDL_XFER_SAMPLES = 512; - sound_sdl() - : osd_module(OSD_SOUND_PROVIDER, "sdl"), sound_module(), - stream_in_initialized(0), - stream_loop(0), - attenuation(0) - { - sdl_xfer_samples = SDL_XFER_SAMPLES; - } - virtual ~sound_sdl() { } + sound_sdl() + : osd_module(OSD_SOUND_PROVIDER, "sdl"), sound_module(), + stream_in_initialized(0), + stream_loop(0), + attenuation(0) + { + sdl_xfer_samples = SDL_XFER_SAMPLES; + } + virtual ~sound_sdl() { } - virtual int init(); - virtual void exit(); + virtual int init(); + virtual void exit(); - // sound_module + // sound_module - virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame); - virtual void set_mastervolume(int attenuation); + virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame); + virtual void set_mastervolume(int attenuation); private: - int lock_buffer(bool is_throttled, long offset, long size, void **buffer1, long *length1, void **buffer2, long *length2); - void unlock_buffer(void); - void att_memcpy(void *dest, const INT16 *data, int bytes_to_copy); - void copy_sample_data(bool is_throttled, const INT16 *data, int bytes_to_copy); - int sdl_create_buffers(void); - void sdl_destroy_buffers(void); + int lock_buffer(bool is_throttled, long offset, long size, void **buffer1, long *length1, void **buffer2, long *length2); + void unlock_buffer(void); + void att_memcpy(void *dest, const INT16 *data, int bytes_to_copy); + void copy_sample_data(bool is_throttled, const INT16 *data, int bytes_to_copy); + int sdl_create_buffers(void); + void sdl_destroy_buffers(void); - int sdl_xfer_samples; - int stream_in_initialized; - int stream_loop; - int attenuation; + int sdl_xfer_samples; + int stream_in_initialized; + int stream_loop; + int attenuation; - int buf_locked; + int buf_locked; - INT8 *stream_buffer; - volatile INT32 stream_playpos; + INT8 *stream_buffer; + volatile INT32 stream_playpos; - UINT32 stream_buffer_size; - UINT32 stream_buffer_in; + UINT32 stream_buffer_size; + UINT32 stream_buffer_in; - // buffer over/underflow counts - int buffer_underflows; - int buffer_overflows; + // buffer over/underflow counts + int buffer_underflows; + int buffer_overflows; }; @@ -354,7 +354,7 @@ void sound_sdl::set_mastervolume(int _attenuation) //============================================================ static void sdl_callback(void *userdata, Uint8 *stream, int len) { - sound_sdl *thiz = (sound_sdl *) userdata; + sound_sdl *thiz = (sound_sdl *) userdata; int len1, len2, sb_in; sb_in = thiz->stream_buffer_in; @@ -379,20 +379,20 @@ static void sdl_callback(void *userdata, Uint8 *stream, int len) len2 = 0; } - memcpy(stream, thiz->stream_buffer + thiz->stream_playpos, len1); - memset(thiz->stream_buffer + thiz->stream_playpos, 0, len1); // no longer needed - if (len2) - { - memcpy(stream+len1, thiz->stream_buffer, len2); - memset(thiz->stream_buffer, 0, len2); // no longer needed - } + memcpy(stream, thiz->stream_buffer + thiz->stream_playpos, len1); + memset(thiz->stream_buffer + thiz->stream_playpos, 0, len1); // no longer needed + if (len2) + { + memcpy(stream+len1, thiz->stream_buffer, len2); + memset(thiz->stream_buffer, 0, len2); // no longer needed + } // move the play cursor - thiz->stream_playpos += len1 + len2; + thiz->stream_playpos += len1 + len2; if (thiz->stream_playpos >= thiz->stream_buffer_size) { - thiz->stream_playpos -= thiz->stream_buffer_size; + thiz->stream_playpos -= thiz->stream_buffer_size; thiz->stream_loop = 0; if (LOG_SOUND) @@ -416,81 +416,81 @@ int sound_sdl::init() SDL_AudioSpec aspec, obtained; char audio_driver[16] = ""; - if (LOG_SOUND) - sound_log = fopen(SDLMAME_SOUND_LOG, "w"); + if (LOG_SOUND) + sound_log = fopen(SDLMAME_SOUND_LOG, "w"); - // skip if sound disabled - if (sample_rate() != 0) - { - if (SDL_InitSubSystem(SDL_INIT_AUDIO)) { - osd_printf_error("Could not initialize SDL %s\n", SDL_GetError()); - return -1; - } + // skip if sound disabled + if (sample_rate() != 0) + { + if (SDL_InitSubSystem(SDL_INIT_AUDIO)) { + osd_printf_error("Could not initialize SDL %s\n", SDL_GetError()); + return -1; + } - osd_printf_verbose("Audio: Start initialization\n"); - #if (SDLMAME_SDL2) - strncpy(audio_driver, SDL_GetCurrentAudioDriver(), sizeof(audio_driver)); - #else - SDL_AudioDriverName(audio_driver, sizeof(audio_driver)); - #endif - osd_printf_verbose("Audio: Driver is %s\n", audio_driver); + osd_printf_verbose("Audio: Start initialization\n"); + #if (SDLMAME_SDL2) + strncpy(audio_driver, SDL_GetCurrentAudioDriver(), sizeof(audio_driver)); + #else + SDL_AudioDriverName(audio_driver, sizeof(audio_driver)); + #endif + osd_printf_verbose("Audio: Driver is %s\n", audio_driver); - sdl_xfer_samples = SDL_XFER_SAMPLES; - stream_in_initialized = 0; - stream_loop = 0; + sdl_xfer_samples = SDL_XFER_SAMPLES; + stream_in_initialized = 0; + stream_loop = 0; - // set up the audio specs - aspec.freq = sample_rate(); - aspec.format = AUDIO_S16SYS; // keep endian independent - aspec.channels = n_channels; - aspec.samples = sdl_xfer_samples; - aspec.callback = sdl_callback; - aspec.userdata = this; + // set up the audio specs + aspec.freq = sample_rate(); + aspec.format = AUDIO_S16SYS; // keep endian independent + aspec.channels = n_channels; + aspec.samples = sdl_xfer_samples; + aspec.callback = sdl_callback; + aspec.userdata = this; - if (SDL_OpenAudio(&aspec, &obtained) < 0) - goto cant_start_audio; + if (SDL_OpenAudio(&aspec, &obtained) < 0) + goto cant_start_audio; - osd_printf_verbose("Audio: frequency: %d, channels: %d, samples: %d\n", - obtained.freq, obtained.channels, obtained.samples); + osd_printf_verbose("Audio: frequency: %d, channels: %d, samples: %d\n", + obtained.freq, obtained.channels, obtained.samples); - sdl_xfer_samples = obtained.samples; + sdl_xfer_samples = obtained.samples; - audio_latency = m_audio_latency; + audio_latency = m_audio_latency; - // pin audio latency - if (audio_latency > MAX_AUDIO_LATENCY) - { - audio_latency = MAX_AUDIO_LATENCY; - } - else if (audio_latency < 1) - { - audio_latency = 1; - } + // pin audio latency + if (audio_latency > MAX_AUDIO_LATENCY) + { + audio_latency = MAX_AUDIO_LATENCY; + } + else if (audio_latency < 1) + { + audio_latency = 1; + } - // compute the buffer sizes - stream_buffer_size = (sample_rate() * 2 * sizeof(INT16) * (2 + audio_latency)) / 30; - stream_buffer_size = (stream_buffer_size / 1024) * 1024; - if (stream_buffer_size < 1024) - stream_buffer_size = 1024; + // compute the buffer sizes + stream_buffer_size = (sample_rate() * 2 * sizeof(INT16) * (2 + audio_latency)) / 30; + stream_buffer_size = (stream_buffer_size / 1024) * 1024; + if (stream_buffer_size < 1024) + stream_buffer_size = 1024; - // create the buffers - if (sdl_create_buffers()) - goto cant_create_buffers; + // create the buffers + if (sdl_create_buffers()) + goto cant_create_buffers; - // set the startup volume - set_mastervolume(attenuation); - osd_printf_verbose("Audio: End initialization\n"); - return 0; + // set the startup volume + set_mastervolume(attenuation); + osd_printf_verbose("Audio: End initialization\n"); + return 0; - // error handling - cant_create_buffers: - cant_start_audio: - osd_printf_verbose("Audio: Initialization failed. SDL error: %s\n", SDL_GetError()); + // error handling + cant_create_buffers: + cant_start_audio: + osd_printf_verbose("Audio: Initialization failed. SDL error: %s\n", SDL_GetError()); - return -1; - } + return -1; + } - return 0; + return 0; } @@ -501,27 +501,27 @@ int sound_sdl::init() void sound_sdl::exit() { - // if nothing to do, don't do it - if (sample_rate() == 0) - return; + // if nothing to do, don't do it + if (sample_rate() == 0) + return; - osd_printf_verbose("sdl_kill: closing audio\n"); + osd_printf_verbose("sdl_kill: closing audio\n"); SDL_CloseAudio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); - // kill the buffers - sdl_destroy_buffers(); + // kill the buffers + sdl_destroy_buffers(); - // print out over/underflow stats - if (buffer_overflows || buffer_underflows) - osd_printf_verbose("Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows); + // print out over/underflow stats + if (buffer_overflows || buffer_underflows) + osd_printf_verbose("Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows); - if (LOG_SOUND) - { - fprintf(sound_log, "Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows); - fclose(sound_log); - } + if (LOG_SOUND) + { + fprintf(sound_log, "Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows); + fclose(sound_log); + } } @@ -555,7 +555,7 @@ void sound_sdl::sdl_destroy_buffers(void) #else /* SDLMAME_UNIX */ - MODULE_NOT_SUPPORTED(sound_sdl, OSD_SOUND_PROVIDER, "sdl") + MODULE_NOT_SUPPORTED(sound_sdl, OSD_SOUND_PROVIDER, "sdl") #endif MODULE_DEFINITION(SOUND_SDL, sound_sdl) diff --git a/src/osd/modules/sound/sound_module.h b/src/osd/modules/sound/sound_module.h index d339af55973..087ace0a714 100644 --- a/src/osd/modules/sound/sound_module.h +++ b/src/osd/modules/sound/sound_module.h @@ -18,17 +18,17 @@ class sound_module { public: - sound_module() : m_sample_rate(0), m_audio_latency(1) { } + sound_module() : m_sample_rate(0), m_audio_latency(1) { } - virtual ~sound_module() { } + virtual ~sound_module() { } - virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame) = 0; - virtual void set_mastervolume(int attenuation) = 0; + virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame) = 0; + virtual void set_mastervolume(int attenuation) = 0; - int sample_rate() { return m_sample_rate; } + int sample_rate() { return m_sample_rate; } - int m_sample_rate; - int m_audio_latency; + int m_sample_rate; + int m_audio_latency; }; #endif /* FONT_MODULE_H_ */ diff --git a/src/osd/modules/sync/sync_mini.c b/src/osd/modules/sync/sync_mini.c index e710cc7f214..a09303aed80 100644 --- a/src/osd/modules/sync/sync_mini.c +++ b/src/osd/modules/sync/sync_mini.c @@ -160,4 +160,3 @@ int osd_thread_cpu_affinity(osd_thread *thread, UINT32 mask) void osd_thread_wait_free(osd_thread *thread) { } - diff --git a/src/osd/modules/sync/sync_ntc.c b/src/osd/modules/sync/sync_ntc.c index ecd5cd51eaf..9da576b5149 100644 --- a/src/osd/modules/sync/sync_ntc.c +++ b/src/osd/modules/sync/sync_ntc.c @@ -411,7 +411,7 @@ int osd_event_wait(osd_event *event, osd_ticks_t timeout) { if (timeout == OSD_EVENT_WAIT_INFINITE) timeout = osd_ticks_per_second() * (osd_ticks_t)10000; - + pthread_mutex_lock(&event->mutex); if (!timeout) { @@ -531,4 +531,3 @@ void osd_thread_wait_free(osd_thread *thread) pthread_join(thread->thread, NULL); free(thread); } - diff --git a/src/osd/modules/sync/sync_os2.c b/src/osd/modules/sync/sync_os2.c index e6df73d083d..9c0612c1288 100644 --- a/src/osd/modules/sync/sync_os2.c +++ b/src/osd/modules/sync/sync_os2.c @@ -388,7 +388,7 @@ int osd_event_wait(osd_event *event, osd_ticks_t timeout) { ULONG rc; ULONG timeout_param; - + if (timeout == OSD_EVENT_WAIT_INFINITE) timeout_param = SEM_INDEFINITE_WAIT; else diff --git a/src/osd/modules/sync/sync_sdl.c b/src/osd/modules/sync/sync_sdl.c index edfc3d105d4..cea1337c7f8 100644 --- a/src/osd/modules/sync/sync_sdl.c +++ b/src/osd/modules/sync/sync_sdl.c @@ -326,9 +326,9 @@ osd_thread *osd_thread_create(osd_thread_callback callback, void *cbparam) thread->callback = callback; thread->param = cbparam; #ifdef SDLMAME_SDL2 - thread->thread = SDL_CreateThread(worker_thread_entry, "Thread", thread); + thread->thread = SDL_CreateThread(worker_thread_entry, "Thread", thread); #else - thread->thread = SDL_CreateThread(worker_thread_entry, thread); + thread->thread = SDL_CreateThread(worker_thread_entry, thread); #endif if ( thread->thread == NULL ) { @@ -366,4 +366,3 @@ void osd_thread_wait_free(osd_thread *thread) SDL_WaitThread(thread->thread, &status); free(thread); } - diff --git a/src/osd/modules/sync/sync_tc.c b/src/osd/modules/sync/sync_tc.c index 6c05599baef..b3f63e7c05b 100644 --- a/src/osd/modules/sync/sync_tc.c +++ b/src/osd/modules/sync/sync_tc.c @@ -246,7 +246,7 @@ int osd_event_wait(osd_event *event, osd_ticks_t timeout) { if (timeout == OSD_EVENT_WAIT_INFINITE) timeout = osd_ticks_per_second() * (osd_ticks_t)10000; - + pthread_mutex_lock(&event->mutex); if (!timeout) { @@ -389,4 +389,3 @@ void osd_thread_wait_free(osd_thread *thread) pthread_join(thread->thread, NULL); free(thread); } - diff --git a/src/osd/modules/sync/sync_windows.c b/src/osd/modules/sync/sync_windows.c index b7d266a52ad..85ee4f35fd7 100644 --- a/src/osd/modules/sync/sync_windows.c +++ b/src/osd/modules/sync/sync_windows.c @@ -244,7 +244,7 @@ int osd_event_wait(osd_event *event, osd_ticks_t timeout) timeout_param = INFINITE; else timeout_param = timeout * 1000 / osd_ticks_per_second(); - + int ret = WaitForSingleObject((HANDLE) event, timeout_param); return (ret == WAIT_OBJECT_0); } diff --git a/src/osd/modules/sync/work_osd.c b/src/osd/modules/sync/work_osd.c index 6c080b5a2ed..89dec09b122 100644 --- a/src/osd/modules/sync/work_osd.c +++ b/src/osd/modules/sync/work_osd.c @@ -70,22 +70,22 @@ typedef void *PVOID; template static void spin_while(const volatile _PtrType * volatile ptr, const _PtrType val, const osd_ticks_t timeout, const int invert = 0) { - osd_ticks_t stopspin = osd_ticks() + timeout; + osd_ticks_t stopspin = osd_ticks() + timeout; - do { - int spin = 10000; - while (--spin) - { - if ((*ptr != val) ^ invert) - return; - } - } while (((*ptr == val) ^ invert) && osd_ticks() < stopspin); + do { + int spin = 10000; + while (--spin) + { + if ((*ptr != val) ^ invert) + return; + } + } while (((*ptr == val) ^ invert) && osd_ticks() < stopspin); } template static void spin_while_not(const volatile _PtrType * volatile ptr, const _PtrType val, const osd_ticks_t timeout) { - spin_while(ptr, val, timeout, 1); + spin_while(ptr, val, timeout, 1); } @@ -553,7 +553,7 @@ int osd_work_item_wait(osd_work_item *item, osd_ticks_t timeout) if (item->event == NULL) { // TODO: do we need to measure the spin time here as well? and how can we do it? - spin_while(&item->done, 0, timeout); + spin_while(&item->done, 0, timeout); } // otherwise, block on the event until done diff --git a/src/osd/osdcore.c b/src/osd/osdcore.c index 5079f8be2d6..fff285c02da 100644 --- a/src/osd/osdcore.c +++ b/src/osd/osdcore.c @@ -54,9 +54,9 @@ static output_delegate output_cb[OSD_OUTPUT_CHANNEL_COUNT] = output_delegate osd_set_output_channel(output_channel channel, output_delegate callback) { if (!(channel < OSD_OUTPUT_CHANNEL_COUNT) || callback.isnull()) - { - throw std::exception(); - } + { + throw std::exception(); + } /* return the originals if requested */ output_delegate prevcb = output_cb[channel]; @@ -166,4 +166,3 @@ void CLIB_DECL osd_printf_log(const char *format, ...) va_end(argptr); } #endif - diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h index 4e2afcae223..d42c2de88b4 100644 --- a/src/osd/osdepend.h +++ b/src/osd/osdepend.h @@ -32,11 +32,11 @@ class input_type_entry; // FIXME: including emu.h does not work because emu. class osd_font { public: - virtual ~osd_font() {} + virtual ~osd_font() {} - virtual bool open(const char *font_path, const char *name, int &height) = 0; - virtual void close() = 0; - virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) = 0; + virtual bool open(const char *font_path, const char *name, int &height) = 0; + virtual void close() = 0; + virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) = 0; }; // ======================> osd_interface diff --git a/src/osd/osdmini/minimisc.c b/src/osd/osdmini/minimisc.c index fa01a02fe10..0fd8162f179 100644 --- a/src/osd/osdmini/minimisc.c +++ b/src/osd/osdmini/minimisc.c @@ -81,4 +81,3 @@ char *osd_get_clipboard_text(void) // can't support clipboards generically return NULL; } - diff --git a/src/osd/sdl/blit13.h b/src/osd/sdl/blit13.h index 6b8de983dc2..07177d5e750 100644 --- a/src/osd/sdl/blit13.h +++ b/src/osd/sdl/blit13.h @@ -114,7 +114,7 @@ INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette) #define TEXCOPY_M( _name, _src_type, _dest_type, _op, _len_div) \ INLINE void texcopy_##_name (const texture_info *texture, const render_texinfo *texsource) { \ - ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \ + ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \ int x, y; \ /* loop over Y */ \ for (y = 0; y < texsource->height; y++) { \ @@ -134,7 +134,7 @@ INLINE void texcopy_##_name (const texture_info *texture, const render_texinfo * #define TEXROT( _name, _src_type, _dest_type, _op) \ INLINE void texcopy_rot_##_name (const texture_info *texture, const render_texinfo *texsource) { \ - ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \ + ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \ int x, y; \ const quad_setup_data *setup = &texture->m_setup; \ int dudx = setup->dudx; \ diff --git a/src/osd/sdl/draw13.c b/src/osd/sdl/draw13.c index c6cc098592d..130080ae54b 100644 --- a/src/osd/sdl/draw13.c +++ b/src/osd/sdl/draw13.c @@ -48,12 +48,12 @@ enum static inline bool is_opaque(const float &a) { - return (a >= 1.0f); + return (a >= 1.0f); } static inline bool is_transparent(const float &a) { - return (a < 0.0001f); + return (a < 0.0001f); } //============================================================ @@ -63,11 +63,11 @@ static inline bool is_transparent(const float &a) struct quad_setup_data { - quad_setup_data() - : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0), - rotwidth(0), rotheight(0) - {} - void compute(const render_primitive &prim); + quad_setup_data() + : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0), + rotwidth(0), rotheight(0) + {} + void compute(const render_primitive &prim); INT32 dudx, dvdx, dudy, dvdy; INT32 startu, startv; @@ -105,16 +105,16 @@ struct sdl_info; /* texture_info holds information about a texture */ class texture_info { - friend class simple_list; + friend class simple_list; public: - texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags); - ~texture_info(); + texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags); + ~texture_info(); - void set_data(const render_texinfo &texsource, const UINT32 flags); - void render_quad(const render_primitive *prim, const int x, const int y); - bool matches(const render_primitive &prim, const quad_setup_data &setup); + void set_data(const render_texinfo &texsource, const UINT32 flags); + void render_quad(const render_primitive *prim, const int x, const int y); + bool matches(const render_primitive &prim, const quad_setup_data &setup); - copy_info_t *compute_size_type(); + copy_info_t *compute_size_type(); void *m_pixels; // pixels for the texture int m_pitch; @@ -125,49 +125,49 @@ public: osd_ticks_t m_last_access; int raw_width() const { return m_texinfo.width; } - int raw_height() const { return m_texinfo.height; } + int raw_height() const { return m_texinfo.height; } - texture_info *next() { return m_next; } - const render_texinfo &texinfo() const { return m_texinfo; } - render_texinfo &texinfo() { return m_texinfo; } + texture_info *next() { return m_next; } + const render_texinfo &texinfo() const { return m_texinfo; } + render_texinfo &texinfo() { return m_texinfo; } - const HashT hash() const { return m_hash; } - const UINT32 flags() const { return m_flags; } - const bool is_pixels_owned() const { // do we own / allocated it ? - return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC) - && (m_copyinfo->func != NULL)) ; - } + const HashT hash() const { return m_hash; } + const UINT32 flags() const { return m_flags; } + const bool is_pixels_owned() const { // do we own / allocated it ? + return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC) + && (m_copyinfo->func != NULL)) ; + } private: - Uint32 m_sdl_access; - SDL_Renderer * m_renderer; - render_texinfo m_texinfo; // copy of the texture info - HashT m_hash; // hash value for the texture (must be >= pointer size) - UINT32 m_flags; // rendering flags + Uint32 m_sdl_access; + SDL_Renderer * m_renderer; + render_texinfo m_texinfo; // copy of the texture info + HashT m_hash; // hash value for the texture (must be >= pointer size) + UINT32 m_flags; // rendering flags - SDL_Texture * m_texture_id; - int m_is_rotated; + SDL_Texture * m_texture_id; + int m_is_rotated; - int m_format; // texture format - SDL_BlendMode m_sdl_blendmode; + int m_format; // texture format + SDL_BlendMode m_sdl_blendmode; - texture_info * m_next; // next texture in the list + texture_info * m_next; // next texture in the list }; /* sdl_info is the information about SDL for the current screen */ struct sdl_info { - sdl_info() - : m_blittimer(0), m_renderer(NULL), - m_hofs(0), m_vofs(0), - m_resize_pending(0), m_resize_width(0), m_resize_height(0), - m_last_blit_time(0), m_last_blit_pixels(0) - {} + sdl_info() + : m_blittimer(0), m_renderer(NULL), + m_hofs(0), m_vofs(0), + m_resize_pending(0), m_resize_width(0), m_resize_height(0), + m_last_blit_time(0), m_last_blit_pixels(0) + {} - void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y); + void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y); - texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup); - texture_info *texture_update(const render_primitive &prim); + texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup); + texture_info *texture_update(const render_primitive &prim); INT32 m_blittimer; @@ -389,46 +389,46 @@ void texture_info::render_quad(const render_primitive *prim, const int x, const target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0); target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0); - SDL_SetTextureBlendMode(m_texture_id, m_sdl_blendmode); - set_coloralphamode(m_texture_id, &prim->color); - SDL_RenderCopy(m_renderer, m_texture_id, NULL, &target_rect); + SDL_SetTextureBlendMode(m_texture_id, m_sdl_blendmode); + set_coloralphamode(m_texture_id, &prim->color); + SDL_RenderCopy(m_renderer, m_texture_id, NULL, &target_rect); } void sdl_info::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y) { - SDL_Rect target_rect; + SDL_Rect target_rect; - target_rect.x = x; - target_rect.y = y; - target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0); - target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0); + target_rect.x = x; + target_rect.y = y; + target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0); + target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0); - if (texture) - { - copy_info_t *copyinfo = texture->m_copyinfo; - copyinfo->time -= osd_ticks(); - texture->render_quad(prim, x, y); - copyinfo->time += osd_ticks(); + if (texture) + { + copy_info_t *copyinfo = texture->m_copyinfo; + copyinfo->time -= osd_ticks(); + texture->render_quad(prim, x, y); + copyinfo->time += osd_ticks(); - copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->raw_width() * texture->raw_height())); - if (m_last_blit_pixels) - { - copyinfo->time += (m_last_blit_time * (INT64) (texture->raw_width() * texture->raw_height())) / (INT64) m_last_blit_pixels; - } - copyinfo->samples++; - copyinfo->perf = ( texture->m_copyinfo->pixel_count * (osd_ticks_per_second()/1000)) / texture->m_copyinfo->time; - } - else - { - UINT32 sr = (UINT32)(255.0f * prim->color.r); - UINT32 sg = (UINT32)(255.0f * prim->color.g); - UINT32 sb = (UINT32)(255.0f * prim->color.b); - UINT32 sa = (UINT32)(255.0f * prim->color.a); + copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->raw_width() * texture->raw_height())); + if (m_last_blit_pixels) + { + copyinfo->time += (m_last_blit_time * (INT64) (texture->raw_width() * texture->raw_height())) / (INT64) m_last_blit_pixels; + } + copyinfo->samples++; + copyinfo->perf = ( texture->m_copyinfo->pixel_count * (osd_ticks_per_second()/1000)) / texture->m_copyinfo->time; + } + else + { + UINT32 sr = (UINT32)(255.0f * prim->color.r); + UINT32 sg = (UINT32)(255.0f * prim->color.g); + UINT32 sb = (UINT32)(255.0f * prim->color.b); + UINT32 sa = (UINT32)(255.0f * prim->color.a); - SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); - SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa); - SDL_RenderFillRect(m_renderer, &target_rect); - } + SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); + SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa); + SDL_RenderFillRect(m_renderer, &target_rect); + } } static int RendererSupportsFormat(SDL_Renderer *renderer, Uint32 format, Uint32 access, const char *sformat) @@ -518,18 +518,18 @@ int drawsdl2_init(running_machine &machine, sdl_draw_info *callbacks) else osd_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : ""); - /* Enable bilinear filtering in case it is supported. - * This applies to all texture operations. However, artwort is pre-scaled - * and thus shouldn't be affected. - */ - if (video_config.filter) - { - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); - } - else - { - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); - } + /* Enable bilinear filtering in case it is supported. + * This applies to all texture operations. However, artwort is pre-scaled + * and thus shouldn't be affected. + */ + if (video_config.filter) + { + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); + } + else + { + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); + } return 0; } @@ -604,7 +604,7 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height { SDL_DisplayMode mode; //SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode); - SDL_GetWindowDisplayMode(window->sdl_window, &mode); + SDL_GetWindowDisplayMode(window->sdl_window, &mode); sdl->m_original_mode = mode; mode.w = width; mode.h = height; @@ -630,13 +630,13 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height osd_printf_warning("Ignoring depth %d\n", window->depth); } } - SDL_SetWindowDisplayMode(window->sdl_window, &mode); // Try to set mode + SDL_SetWindowDisplayMode(window->sdl_window, &mode); // Try to set mode #ifndef SDLMAME_WIN32 - /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution - * is in place after the mode switch - which will most likely be the case - * This is a hack to work around a deficiency in SDL2 - */ - SDL_WarpMouseInWindow(window->sdl_window, 1, 1); + /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution + * is in place after the mode switch - which will most likely be the case + * This is a hack to work around a deficiency in SDL2 + */ + SDL_WarpMouseInWindow(window->sdl_window, 1, 1); #endif } else @@ -736,7 +736,7 @@ static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update) SDL_GetWindowSize(window->sdl_window, &window->width, &window->height); sdl->m_resize_pending = 0; SDL_RenderSetViewport(sdl->m_renderer, NULL); - //sdlvideo_monitor_refresh(window->monitor()); + //sdlvideo_monitor_refresh(window->monitor()); } @@ -855,14 +855,14 @@ static void drawsdl2_window_destroy(sdl_window_info *window) drawsdl2_destroy_all_textures(window); - if (window->fullscreen() && video_config.switchres) - { - SDL_SetWindowFullscreen(window->sdl_window, 0); // Try to set mode - SDL_SetWindowDisplayMode(window->sdl_window, &sdl->m_original_mode); // Try to set mode - SDL_SetWindowFullscreen(window->sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode - } + if (window->fullscreen() && video_config.switchres) + { + SDL_SetWindowFullscreen(window->sdl_window, 0); // Try to set mode + SDL_SetWindowDisplayMode(window->sdl_window, &sdl->m_original_mode); // Try to set mode + SDL_SetWindowFullscreen(window->sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode + } - SDL_DestroyWindow(window->sdl_window); + SDL_DestroyWindow(window->sdl_window); global_free(sdl); window->dxdata = NULL; @@ -889,7 +889,7 @@ copy_info_t *texture_info::compute_size_type() { if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) { - int perf = bi->perf; + int perf = bi->perf; if (perf == 0) return bi; else if (perf > (maxperf * 102) / 100) @@ -920,15 +920,15 @@ copy_info_t *texture_info::compute_size_type() bool texture_info::matches(const render_primitive &prim, const quad_setup_data &setup) { - return texinfo().base == prim.texture.base && - texinfo().width == prim.texture.width && - texinfo().height == prim.texture.height && - texinfo().rowpixels == prim.texture.rowpixels && - m_setup.dudx == setup.dudx && - m_setup.dvdx == setup.dvdx && - m_setup.dudy == setup.dudy && - m_setup.dvdy == setup.dvdy && - ((flags() ^ prim.flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0; + return texinfo().base == prim.texture.base && + texinfo().width == prim.texture.width && + texinfo().height == prim.texture.height && + texinfo().rowpixels == prim.texture.rowpixels && + m_setup.dudx == setup.dudx && + m_setup.dvdx == setup.dvdx && + m_setup.dudy == setup.dudy && + m_setup.dvdy == setup.dvdy && + ((flags() ^ prim.flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0; } //============================================================ @@ -937,9 +937,8 @@ bool texture_info::matches(const render_primitive &prim, const quad_setup_data & texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, UINT32 flags) { - // fill in the core data - m_renderer = renderer; + m_renderer = renderer; m_hash = texture_compute_hash(texsource, flags); m_flags = flags; m_texinfo = texsource; @@ -997,10 +996,10 @@ texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsour if (m_sdl_access == SDL_TEXTUREACCESS_STATIC) { - if (m_copyinfo->func != NULL) - m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->dst_bpp); - else - m_pixels = NULL; + if (m_copyinfo->func != NULL) + m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->dst_bpp); + else + m_pixels = NULL; } m_last_access = osd_ticks(); @@ -1008,9 +1007,9 @@ texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsour texture_info::~texture_info() { - if ( is_pixels_owned() && (m_pixels != NULL) ) - free(m_pixels); - SDL_DestroyTexture(m_texture_id); + if ( is_pixels_owned() && (m_pixels != NULL) ) + free(m_pixels); + SDL_DestroyTexture(m_texture_id); } //============================================================ @@ -1082,9 +1081,9 @@ void quad_setup_data::compute(const render_primitive &prim) #if 0 printf("tl.u %f tl.v %f\n", texcoords->tl.u, texcoords->tl.v); - printf("tr.u %f tr.v %f\n", texcoords->tr.u, texcoords->tr.v); - printf("bl.u %f bl.v %f\n", texcoords->bl.u, texcoords->bl.v); - printf("br.u %f br.v %f\n", texcoords->br.u, texcoords->br.v); + printf("tr.u %f tr.v %f\n", texcoords->tr.u, texcoords->tr.v); + printf("bl.u %f bl.v %f\n", texcoords->bl.u, texcoords->bl.v); + printf("br.u %f br.v %f\n", texcoords->br.u, texcoords->br.v); /* compute start and delta U,V coordinates now */ #endif @@ -1162,7 +1161,7 @@ texture_info * sdl_info::texture_update(const render_primitive &prim) if (texture == NULL && prim.texture.base != NULL) { texture = global_alloc(texture_info(m_renderer, prim.texture, setup, prim.flags)); - /* add us to the texture list */ + /* add us to the texture list */ m_texlist.prepend(*texture); } @@ -1191,9 +1190,9 @@ static void drawsdl2_destroy_all_textures(sdl_window_info *window) if(window->primlist) { window->primlist->acquire_lock(); - sdl->m_texlist.reset(); - window->primlist->release_lock(); + sdl->m_texlist.reset(); + window->primlist->release_lock(); } else - sdl->m_texlist.reset(); + sdl->m_texlist.reset(); } diff --git a/src/osd/sdl/drawogl.c b/src/osd/sdl/drawogl.c index 4d9bd21a2e8..7fe795b43ed 100644 --- a/src/osd/sdl/drawogl.c +++ b/src/osd/sdl/drawogl.c @@ -161,24 +161,24 @@ struct texture_info; /* texture_info holds information about a texture */ struct texture_info { - texture_info() - : hash(0), flags(0), rawwidth(0), rawheight(0), - rawwidth_create(0), rawheight_create(0), - type(0), format(0), borderpix(0), xprescale(0), yprescale(0), nocopy(0), - texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(NULL), - data_own(0), texCoordBufferName(0) - { - for (int i=0; i<2; i++) - { - mpass_textureunit[i] = 0; - mpass_texture_mamebm[i] = 0; - mpass_fbo_mamebm[i] = 0; - mpass_texture_scrn[i] = 0; - mpass_fbo_scrn[i] = 0; - } - for (int i=0; i<8; i++) - texCoord[i] = 0.0f; - } + texture_info() + : hash(0), flags(0), rawwidth(0), rawheight(0), + rawwidth_create(0), rawheight_create(0), + type(0), format(0), borderpix(0), xprescale(0), yprescale(0), nocopy(0), + texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(NULL), + data_own(0), texCoordBufferName(0) + { + for (int i=0; i<2; i++) + { + mpass_textureunit[i] = 0; + mpass_texture_mamebm[i] = 0; + mpass_fbo_mamebm[i] = 0; + mpass_texture_scrn[i] = 0; + mpass_fbo_scrn[i] = 0; + } + for (int i=0; i<8; i++) + texCoord[i] = 0.0f; + } HashT hash; // hash value for the texture (must be >= pointer size) UINT32 flags; // rendering flags @@ -217,35 +217,35 @@ struct texture_info /* sdl_info is the information about SDL for the current screen */ struct sdl_info { - sdl_info() - : blittimer(0), extra_flags(0), + sdl_info() + : blittimer(0), extra_flags(0), #if (SDLMAME_SDL2) - gl_context_id(0), + gl_context_id(0), #else - sdlsurf(NULL), + sdlsurf(NULL), #endif - initialized(0), - last_blendmode(0), - texture_max_width(0), - texture_max_height(0), - texpoweroftwo(0), - usevbo(0), usepbo(0), usefbo(0), useglsl(0), glsl(NULL), - glsl_program_num(0), - glsl_program_mb2sc(0), - usetexturerect(0), - init_context(0), - last_hofs(0.0f), - last_vofs(0.0f), - surf_w(0), - surf_h(0) - { - for (int i=0; i < HASH_SIZE + OVERFLOW_SIZE; i++) - texhash[i] = NULL; - for (int i=0; i < 2*GLSL_SHADER_MAX; i++) - glsl_program[i] = 0; - for (int i=0; i < 8; i++) - texVerticex[i] = 0.0f; - } + initialized(0), + last_blendmode(0), + texture_max_width(0), + texture_max_height(0), + texpoweroftwo(0), + usevbo(0), usepbo(0), usefbo(0), useglsl(0), glsl(NULL), + glsl_program_num(0), + glsl_program_mb2sc(0), + usetexturerect(0), + init_context(0), + last_hofs(0.0f), + last_vofs(0.0f), + surf_w(0), + surf_h(0) + { + for (int i=0; i < HASH_SIZE + OVERFLOW_SIZE; i++) + texhash[i] = NULL; + for (int i=0; i < 2*GLSL_SHADER_MAX; i++) + glsl_program[i] = 0; + for (int i=0; i < 8; i++) + texVerticex[i] = 0.0f; + } INT32 blittimer; UINT32 extra_flags; @@ -3079,40 +3079,40 @@ static void drawogl_destroy_all_textures(sdl_window_info *window) sdl->texhash[i] = NULL; if (texture != NULL) { - if(sdl->usevbo) - { - pfn_glDeleteBuffers( 1, &(texture->texCoordBufferName) ); - texture->texCoordBufferName=0; - } + if(sdl->usevbo) + { + pfn_glDeleteBuffers( 1, &(texture->texCoordBufferName) ); + texture->texCoordBufferName=0; + } - if(sdl->usepbo && texture->pbo) - { - pfn_glDeleteBuffers( 1, (GLuint *)&(texture->pbo) ); - texture->pbo=0; - } + if(sdl->usepbo && texture->pbo) + { + pfn_glDeleteBuffers( 1, (GLuint *)&(texture->pbo) ); + texture->pbo=0; + } - if( sdl->glsl_program_num > 1 ) - { - assert(sdl->usefbo); - pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_mamebm[0]); - glDeleteTextures(2, (GLuint *)&texture->mpass_texture_mamebm[0]); - } + if( sdl->glsl_program_num > 1 ) + { + assert(sdl->usefbo); + pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_mamebm[0]); + glDeleteTextures(2, (GLuint *)&texture->mpass_texture_mamebm[0]); + } - if ( sdl->glsl_program_mb2sc < sdl->glsl_program_num - 1 ) - { - assert(sdl->usefbo); - pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_scrn[0]); - glDeleteTextures(2, (GLuint *)&texture->mpass_texture_scrn[0]); - } + if ( sdl->glsl_program_mb2sc < sdl->glsl_program_num - 1 ) + { + assert(sdl->usefbo); + pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_scrn[0]); + glDeleteTextures(2, (GLuint *)&texture->mpass_texture_scrn[0]); + } - glDeleteTextures(1, (GLuint *)&texture->texture); - if ( texture->data_own ) - { - free(texture->data); - texture->data=NULL; - texture->data_own=FALSE; - } - global_free(texture); + glDeleteTextures(1, (GLuint *)&texture->texture); + if ( texture->data_own ) + { + free(texture->data); + texture->data=NULL; + texture->data_own=FALSE; + } + global_free(texture); } i++; } diff --git a/src/osd/sdl/input.c b/src/osd/sdl/input.c index 4b2f1e57093..87c534a5e5d 100644 --- a/src/osd/sdl/input.c +++ b/src/osd/sdl/input.c @@ -1986,16 +1986,16 @@ void sdlinput_poll(running_machine &machine) else { #ifndef SDLMAME_WIN32 - /* FIXME: SDL2 sends some spurious resize events on Ubuntu - * while in fullscreen mode. Ignore them for now. - */ - if (!window->fullscreen()) + /* FIXME: SDL2 sends some spurious resize events on Ubuntu + * while in fullscreen mode. Ignore them for now. + */ + if (!window->fullscreen()) #endif - { - //printf("event data1,data2 %d x %d %ld\n", event.window.data1, event.window.data2, sizeof(SDL_Event)); - if (event.window.data1 != window->width || event.window.data2 != window->height) - window->window_resize(event.window.data1, event.window.data2); - } + { + //printf("event data1,data2 %d x %d %ld\n", event.window.data1, event.window.data2, sizeof(SDL_Event)); + if (event.window.data1 != window->width || event.window.data2 != window->height) + window->window_resize(event.window.data1, event.window.data2); + } } focus_window = window; break; diff --git a/src/osd/sdl/netdev_pcap.c b/src/osd/sdl/netdev_pcap.c index 54d837cc9fe..ec72fe5ed8a 100644 --- a/src/osd/sdl/netdev_pcap.c +++ b/src/osd/sdl/netdev_pcap.c @@ -98,11 +98,11 @@ void init_pcap() return; } - while(devs) - { - add_netdev(devs->name, devs->description, create_pcap); - devs = devs->next; - } + while(devs) + { + add_netdev(devs->name, devs->description, create_pcap); + devs = devs->next; + } } void deinit_pcap() diff --git a/src/osd/sdl/netdev_pcap_osx.c b/src/osd/sdl/netdev_pcap_osx.c index 9485f65775d..864732ff601 100644 --- a/src/osd/sdl/netdev_pcap_osx.c +++ b/src/osd/sdl/netdev_pcap_osx.c @@ -150,11 +150,11 @@ void init_pcap() } #if 1 - while(devs) - { - add_netdev(devs->name, devs->description, create_pcap); - devs = devs->next; - } + while(devs) + { + add_netdev(devs->name, devs->description, create_pcap); + devs = devs->next; + } #else if (devs) { diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index 47bce66a8ee..3bbed8efd16 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -30,7 +30,7 @@ #define SDL13_COMBINE_RESIZE (0) #endif #else - #define SDLMAME_INIT_IN_WORKER_THREAD (0) + #define SDLMAME_INIT_IN_WORKER_THREAD (0) #define SDL13_COMBINE_RESIZE (0) #endif @@ -199,7 +199,7 @@ public: #ifdef USE_NETWORK virtual bool network_init(); #endif - //virtual bool midi_init(); + //virtual bool midi_init(); virtual void video_exit(); virtual void window_exit(); @@ -208,9 +208,9 @@ public: #ifdef USE_NETWORK virtual void network_exit(); #endif - //virtual void midi_exit(); + //virtual void midi_exit(); - sdl_options &options() { return m_options; } + sdl_options &options() { return m_options; } private: virtual void osd_exit(); @@ -220,7 +220,7 @@ private: // FIXME: remove machine usage void extract_video_config(running_machine &machine); - sdl_options &m_options; + sdl_options &m_options; watchdog *m_watchdog; diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index 2abe695be4e..ca4ae3329dc 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -738,7 +738,7 @@ DEBUGOBJS = \ $(OSDOBJ)/modules/debugger/qt/debugqtdeviceinformationwindow.moc.o DEFS += -DUSE_QTDEBUG=1 - + else DEFS += -DUSE_QTDEBUG=0 endif diff --git a/src/osd/sdl/sdldir.c b/src/osd/sdl/sdldir.c index 4c3b29dea34..ba1184adc20 100644 --- a/src/osd/sdl/sdldir.c +++ b/src/osd/sdl/sdldir.c @@ -152,7 +152,6 @@ osd_directory *osd_opendir(const char *dirname) if (tmpstr[0] == '$') { - envstr = (char *) osd_malloc_array(strlen(tmpstr)+1); strcpy(envstr, tmpstr); diff --git a/src/osd/sdl/sdlfile.c b/src/osd/sdl/sdlfile.c index 6df7615f1ab..5dc2b309cc9 100644 --- a/src/osd/sdl/sdlfile.c +++ b/src/osd/sdl/sdlfile.c @@ -188,7 +188,7 @@ file_error osd_open(const char *path, UINT32 openflags, osd_file **file, UINT64 envstr[i] = '\0'; - const char *envval = osd_getenv(&envstr[1]); + const char *envval = osd_getenv(&envstr[1]); if (envval != NULL) { j = strlen(envval) + strlen(tmpstr) + 1; @@ -505,31 +505,31 @@ int osd_is_absolute_path(const char *path) osd_directory_entry *osd_stat(const char *path) { - int err; - osd_directory_entry *result = NULL; - #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN) - struct stat st; - #else - struct stat64 st; - #endif + int err; + osd_directory_entry *result = NULL; + #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN) + struct stat st; + #else + struct stat64 st; + #endif - #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN) - err = stat(path, &st); - #else - err = stat64(path, &st); - #endif + #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN) + err = stat(path, &st); + #else + err = stat64(path, &st); + #endif - if( err == -1) return NULL; + if( err == -1) return NULL; - // create an osd_directory_entry; be sure to make sure that the caller can - // free all resources by just freeing the resulting osd_directory_entry - result = (osd_directory_entry *) osd_malloc_array(sizeof(*result) + strlen(path) + 1); - strcpy(((char *) result) + sizeof(*result), path); - result->name = ((char *) result) + sizeof(*result); - result->type = S_ISDIR(st.st_mode) ? ENTTYPE_DIR : ENTTYPE_FILE; - result->size = (UINT64)st.st_size; + // create an osd_directory_entry; be sure to make sure that the caller can + // free all resources by just freeing the resulting osd_directory_entry + result = (osd_directory_entry *) osd_malloc_array(sizeof(*result) + strlen(path) + 1); + strcpy(((char *) result) + sizeof(*result), path); + result->name = ((char *) result) + sizeof(*result); + result->type = S_ISDIR(st.st_mode) ? ENTTYPE_DIR : ENTTYPE_FILE; + result->size = (UINT64)st.st_size; - return result; + return result; } //============================================================ @@ -538,32 +538,32 @@ osd_directory_entry *osd_stat(const char *path) file_error osd_get_full_path(char **dst, const char *path) { - file_error err; - char path_buffer[512]; + file_error err; + char path_buffer[512]; - err = FILERR_NONE; + err = FILERR_NONE; - if (getcwd(path_buffer, 511) == NULL) - { - printf("osd_get_full_path: failed!\n"); - err = FILERR_FAILURE; - } - else - { - *dst = (char *)osd_malloc_array(strlen(path_buffer)+strlen(path)+3); + if (getcwd(path_buffer, 511) == NULL) + { + printf("osd_get_full_path: failed!\n"); + err = FILERR_FAILURE; + } + else + { + *dst = (char *)osd_malloc_array(strlen(path_buffer)+strlen(path)+3); - // if it's already a full path, just pass it through - if (path[0] == '/') - { - strcpy(*dst, path); - } - else - { - sprintf(*dst, "%s%s%s", path_buffer, PATH_SEPARATOR, path); - } - } + // if it's already a full path, just pass it through + if (path[0] == '/') + { + strcpy(*dst, path); + } + else + { + sprintf(*dst, "%s%s%s", path_buffer, PATH_SEPARATOR, path); + } + } - return err; + return err; } //============================================================ @@ -572,8 +572,8 @@ file_error osd_get_full_path(char **dst, const char *path) const char *osd_get_volume_name(int idx) { - if (idx!=0) return NULL; - return "/"; + if (idx!=0) return NULL; + return "/"; } #endif diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c index e6c9e8ed5e1..6337717631b 100644 --- a/src/osd/sdl/sdlmain.c +++ b/src/osd/sdl/sdlmain.c @@ -319,7 +319,7 @@ int main(int argc, char *argv[]) #endif { - sdl_options options; + sdl_options options; sdl_osd_interface osd(options); osd.register_options(); cli_frontend frontend(options, osd); @@ -688,5 +688,3 @@ char *utf8_from_wstring(const WCHAR *wstring) } #endif - - diff --git a/src/osd/sdl/sdlos_macosx.c b/src/osd/sdl/sdlos_macosx.c index 2c0f582c885..3585780f31e 100644 --- a/src/osd/sdl/sdlos_macosx.c +++ b/src/osd/sdl/sdlos_macosx.c @@ -121,4 +121,3 @@ char *osd_get_clipboard_text(void) return result; } - diff --git a/src/osd/sdl/sdlos_unix.c b/src/osd/sdl/sdlos_unix.c index cee3f498724..c5180bc13b7 100644 --- a/src/osd/sdl/sdlos_unix.c +++ b/src/osd/sdl/sdlos_unix.c @@ -147,6 +147,3 @@ char *osd_get_clipboard_text(void) return result; } #endif - - - diff --git a/src/osd/sdl/sdlos_win32.c b/src/osd/sdl/sdlos_win32.c index a5ede43df00..ab488b0d70b 100644 --- a/src/osd/sdl/sdlos_win32.c +++ b/src/osd/sdl/sdlos_win32.c @@ -101,4 +101,3 @@ char *osd_get_clipboard_text(void) return result; } - diff --git a/src/osd/sdl/sdlptty_unix.c b/src/osd/sdl/sdlptty_unix.c index bc9b3a8ff25..60eac1436dd 100644 --- a/src/osd/sdl/sdlptty_unix.c +++ b/src/osd/sdl/sdlptty_unix.c @@ -111,21 +111,21 @@ const char *sdlfile_ptty_identifier = ""; file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize) { - return FILERR_ACCESS_DENIED; + return FILERR_ACCESS_DENIED; } file_error sdl_read_ptty(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) { - return FILERR_ACCESS_DENIED; + return FILERR_ACCESS_DENIED; } file_error sdl_write_ptty(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) { - return FILERR_ACCESS_DENIED; + return FILERR_ACCESS_DENIED; } file_error sdl_close_ptty(osd_file *file) { - return FILERR_ACCESS_DENIED; + return FILERR_ACCESS_DENIED; } #endif diff --git a/src/osd/sdl/strconv.c b/src/osd/sdl/strconv.c index 73d1f576c0a..3eedf040127 100644 --- a/src/osd/sdl/strconv.c +++ b/src/osd/sdl/strconv.c @@ -127,15 +127,15 @@ int osd_uchar_from_osdchar(UINT32 *uchar, const char *osdchar, size_t count) int osd_uchar_from_osdchar(unicode_char *uchar, const char *osdchar, size_t count) { - wchar_t wch; + wchar_t wch; - count = mbstowcs(&wch, (char *)osdchar, 1); - if (count != -1) - *uchar = wch; - else - *uchar = 0; + count = mbstowcs(&wch, (char *)osdchar, 1); + if (count != -1) + *uchar = wch; + else + *uchar = 0; - return count; + return count; } #endif diff --git a/src/osd/sdl/video.c b/src/osd/sdl/video.c index bef84f9ba86..5a8da9eb031 100644 --- a/src/osd/sdl/video.c +++ b/src/osd/sdl/video.c @@ -154,9 +154,9 @@ void sdlvideo_monitor_refresh(sdl_monitor_info *monitor) #if defined(SDLMAME_WIN32) SDL_GetDesktopDisplayMode(monitor->handle, &dmode); - #else - SDL_GetCurrentDisplayMode(monitor->handle, &dmode); - #endif + #else + SDL_GetCurrentDisplayMode(monitor->handle, &dmode); + #endif monitor->monitor_width = dmode.w; monitor->monitor_height = dmode.h; monitor->center_width = dmode.w; diff --git a/src/osd/sdl/window.c b/src/osd/sdl/window.c index 3edd6e87c87..88325d682ad 100644 --- a/src/osd/sdl/window.c +++ b/src/osd/sdl/window.c @@ -270,35 +270,35 @@ bool sdl_osd_interface::window_init() * The code below will document which hints were set. */ const char * hints[] = { SDL_HINT_FRAMEBUFFER_ACCELERATION, - SDL_HINT_RENDER_DRIVER, SDL_HINT_RENDER_OPENGL_SHADERS, - SDL_HINT_RENDER_SCALE_QUALITY, - SDL_HINT_RENDER_VSYNC, - SDL_HINT_VIDEO_X11_XVIDMODE, SDL_HINT_VIDEO_X11_XINERAMA, - SDL_HINT_VIDEO_X11_XRANDR, SDL_HINT_GRAB_KEYBOARD, - SDL_HINT_MOUSE_RELATIVE_MODE_WARP, - SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_HINT_IDLE_TIMER_DISABLED, - SDL_HINT_ORIENTATIONS, - SDL_HINT_XINPUT_ENABLED, SDL_HINT_GAMECONTROLLERCONFIG, - SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_HINT_ALLOW_TOPMOST, - SDL_HINT_TIMER_RESOLUTION, + SDL_HINT_RENDER_DRIVER, SDL_HINT_RENDER_OPENGL_SHADERS, + SDL_HINT_RENDER_SCALE_QUALITY, + SDL_HINT_RENDER_VSYNC, + SDL_HINT_VIDEO_X11_XVIDMODE, SDL_HINT_VIDEO_X11_XINERAMA, + SDL_HINT_VIDEO_X11_XRANDR, SDL_HINT_GRAB_KEYBOARD, + SDL_HINT_MOUSE_RELATIVE_MODE_WARP, + SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_HINT_IDLE_TIMER_DISABLED, + SDL_HINT_ORIENTATIONS, + SDL_HINT_XINPUT_ENABLED, SDL_HINT_GAMECONTROLLERCONFIG, + SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_HINT_ALLOW_TOPMOST, + SDL_HINT_TIMER_RESOLUTION, #if SDL_VERSION_ATLEAST(2, 0, 2) - SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_HINT_VIDEO_ALLOW_SCREENSAVER, - SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, - SDL_HINT_VIDEO_WIN_D3DCOMPILER, SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT, - SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, + SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_HINT_VIDEO_ALLOW_SCREENSAVER, + SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, + SDL_HINT_VIDEO_WIN_D3DCOMPILER, SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT, + SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, #endif #if SDL_VERSION_ATLEAST(2, 0, 3) - SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_HINT_VIDEO_HIGHDPI_DISABLED, - SDL_HINT_WINRT_PRIVACY_POLICY_URL, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL, - SDL_HINT_WINRT_HANDLE_BACK_BUTTON, + SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_HINT_VIDEO_HIGHDPI_DISABLED, + SDL_HINT_WINRT_PRIVACY_POLICY_URL, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL, + SDL_HINT_WINRT_HANDLE_BACK_BUTTON, #endif - NULL - }; + NULL + }; - osd_printf_verbose("\nHints:\n"); - for (int i = 0; hints[i] != NULL; i++) - osd_printf_verbose("\t%-40s %s\n", hints[i], SDL_GetHint(hints[i])); + osd_printf_verbose("\nHints:\n"); + for (int i = 0; hints[i] != NULL; i++) + osd_printf_verbose("\t%-40s %s\n", hints[i], SDL_GetHint(hints[i])); #endif // set up the window list @@ -1018,17 +1018,17 @@ void sdl_window_info::video_window_update(running_machine &machine) if (osd_event_wait(rendered_event, event_wait_ticks)) { - if ((!fullscreen()) || (video_config.switchres)) - { - blit_surface_size(width, height); - } - else - { - blit_surface_size(monitor()->center_width, monitor()->center_height); - } + if ((!fullscreen()) || (video_config.switchres)) + { + blit_surface_size(width, height); + } + else + { + blit_surface_size(monitor()->center_width, monitor()->center_height); + } // ensure the target bounds are up-to-date, and then get the primitives - set_target_bounds(this); + set_target_bounds(this); render_primitive_list &primlist = target->get_primitives(); diff --git a/src/osd/sdl/window.h b/src/osd/sdl/window.h index 3b47433a91d..ca7d8746c04 100644 --- a/src/osd/sdl/window.h +++ b/src/osd/sdl/window.h @@ -61,8 +61,8 @@ struct sdl_window_info m_fullscreen = !video_config.windowed; prescale = video_config.prescale; - windowed_width = config->width; - windowed_height = config->height; + windowed_width = config->width; + windowed_height = config->height; } void video_window_update(running_machine &machine); diff --git a/src/osd/windows/vconv.c b/src/osd/windows/vconv.c index 05657ad5777..e8bc4626c41 100644 --- a/src/osd/windows/vconv.c +++ b/src/osd/windows/vconv.c @@ -91,7 +91,7 @@ static const translation_info gcc_translate[] = // warning C4510: 'xxx' : default constructor could not be generated // warning C4512: 'xxx' : assignment operator could not be generated // warning C4514: 'xxx' : unreferenced inline function has been removed - // warning C4619: #pragma warning : there is no warning number 'xxx' + // warning C4619: #pragma warning : there is no warning number 'xxx' // warning C4571: Informational: catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught // warning C4610: struct 'xxx' can never be instantiated - user defined constructor required // warning C4625: 'xxx' : copy constructor could not be generated because a base class copy constructor is inaccessible or deleted diff --git a/src/osd/windows/windows.mak b/src/osd/windows/windows.mak index ef16e5a9aed..832e0dae8b6 100644 --- a/src/osd/windows/windows.mak +++ b/src/osd/windows/windows.mak @@ -313,7 +313,7 @@ LDFLAGS += -static-libgcc ifeq ($(CROSS_BUILD),1) LDFLAGS += -static -endif +endif # TODO: needs to use $(CC) TEST_GCC := $(shell gcc --version) diff --git a/src/tools/chdman.c b/src/tools/chdman.c index a824c701d74..c71f7d2b94d 100644 --- a/src/tools/chdman.c +++ b/src/tools/chdman.c @@ -1702,7 +1702,7 @@ static void do_create_hd(parameters_t ¶ms) report_error(1, "Invalid size string"); } } - + // process compression chd_codec_type compression[4]; memcpy(compression, s_default_hd_compression, sizeof(compression)); @@ -1757,7 +1757,7 @@ static void do_create_hd(parameters_t ¶ms) if (sscanf(metadata, HARD_DISK_METADATA_FORMAT, &cylinders, &heads, §ors, §or_size) != 4) report_error(1, "Error parsing hard disk metadata in parent CHD"); } - + // validate the size if (filesize % sector_size != 0) report_error(1, "Data size is not divisible by sector size %d", sector_size); diff --git a/src/tools/nltool.c b/src/tools/nltool.c index 8228b2ba2c8..22d4cf6bd8d 100644 --- a/src/tools/nltool.c +++ b/src/tools/nltool.c @@ -88,10 +88,10 @@ struct options_entry oplist[] = }; NETLIST_START(dummy) - /* Standard stuff */ + /* Standard stuff */ - CLOCK(clk, 1000) // 1000 Hz - SOLVER(Solver, 48000) + CLOCK(clk, 1000) // 1000 Hz + SOLVER(Solver, 48000) NETLIST_END() @@ -172,7 +172,7 @@ public: nl_util::pstring_list ll = nl_util::split(m_logs, ":"); for (int i=0; i < ll.count(); i++) { - pstring name = "log_" + ll[i]; + pstring name = "log_" + ll[i]; /*netlist_device_t *nc = */ m_setup->register_dev("nld_log", name); m_setup->register_link(name + ".I", ll[i]); } @@ -241,10 +241,10 @@ static void listdevices() nt.init(); const netlist_factory_t::list_t &list = nt.setup().factory().list(); - netlist_sources_t sources; + netlist_sources_t sources; - sources.add(netlist_source_t("dummy", &netlist_dummy)); - sources.parse(nt.setup(),"dummy"); + sources.add(netlist_source_t("dummy", &netlist_dummy)); + sources.parse(nt.setup(),"dummy"); nt.setup().start_devices(); nt.setup().resolve_inputs(); diff --git a/src/version.c b/src/version.c index ed6293382da..ced7e922540 100644 --- a/src/version.c +++ b/src/version.c @@ -8,7 +8,7 @@ ***************************************************************************/ -#define BARE_BUILD_VERSION "0.157" +#define BARE_BUILD_VERSION "0.158" extern const char bare_build_version[]; extern const char build_version[];