Previous 199869 Revisions Next

r35421 Thursday 22nd January, 2015 at 20:05:15 UTC by Angelo Salese
Fixed non-terrain colors in Top Landing (also fixed out-of-bounds palette crash bug in it) [Angelo Salese]
[/branches/kale/src/build]png2bdc.py
[/branches/kale/src/mame/drivers]model2.c model3.c stv.c
[/branches/kale/src/mame/includes]model3.h
[/branches/kale/src/mame/machine]315-5881_helper.c
[/branches/kale/src/mame/video]taitoair.c
[/branches/kale/src/osd]osdepend.h
[/branches/kale/src/osd/modules]osdmodule.c osdmodule.h
[/branches/kale/src/osd/modules/font]font_module.h font_none.c font_osx.c font_sdl.c font_unix.c* font_windows.c
[/branches/kale/src/osd/modules/lib]osdobj_common.c osdobj_common.h
[/branches/kale/src/osd/sdl]main.c osdsdl.h sdl.mak sdlmain.c strconv.h
[/branches/kale/src/osd/windows]main.c netdev_pcap.h strconv.h windows.mak

branches/kale/src/build/png2bdc.py
r243932r243933
121121        fp.write('o')
122122        fp.write('n')
123123        fp.write('t')
124        fp.write(chr(hash32 >> 24 & 0xff))
125        fp.write(chr(hash32 >> 16 & 0xff))
126        fp.write(chr(hash32 >> 8 & 0xff))
127        fp.write(chr(hash32 >> 0 & 0xff))
128        fp.write(chr(font.height >> 8 & 0xff))
129        fp.write(chr(font.height >> 0 & 0xff))
130        fp.write(chr(font.yOffs >> 8 & 0xff))
131        fp.write(chr(font.yOffs >> 0 & 0xff))
132        fp.write(chr(numChars >> 24 & 0xff))
133        fp.write(chr(numChars >> 16 & 0xff))
134        fp.write(chr(numChars >> 8 & 0xff))
135        fp.write(chr(numChars >> 0 & 0xff))
124        fp.write(bytearray([hash32 >> 24 & 0xff]))
125        fp.write(bytearray([hash32 >> 16 & 0xff]))
126        fp.write(bytearray([hash32 >> 8 & 0xff]))
127        fp.write(bytearray([hash32 >> 0 & 0xff]))
128        fp.write(bytearray([font.height >> 8 & 0xff]))
129        fp.write(bytearray([font.height >> 0 & 0xff]))
130        fp.write(bytearray([font.yOffs >> 8 & 0xff]))
131        fp.write(bytearray([font.yOffs >> 0 & 0xff]))
132        fp.write(bytearray([numChars >> 24 & 0xff]))
133        fp.write(bytearray([numChars >> 16 & 0xff]))
134        fp.write(bytearray([numChars >> 8 & 0xff]))
135        fp.write(bytearray([numChars >> 0 & 0xff]))
136136       
137137        # Write a blank table at first (?)
138138        charTable = [0]*(numChars * CACHED_CHAR_SIZE)
139        for i in range(numChars * CACHED_CHAR_SIZE):
140            fp.write(chr(charTable[i]))
139        fp.write(bytearray(charTable))
141140       
142141        # Loop over all characters
143142        tableIndex = 0
r243932r243933
172171                    dBuffer.append(accum)
173172               
174173                # Write the data
175                for j in range(len(dBuffer)):
176                    fp.write(chr(dBuffer[j]))
174                fp.write(bytearray(dBuffer))
177175           
178176            destIndex = tableIndex * CACHED_CHAR_SIZE
179177            charTable[destIndex +  0] = i >> 8 & 0xff
r243932r243933
192190   
193191        # Seek back to the beginning and rewrite the table
194192        fp.seek(CACHED_HEADER_SIZE, 0)
195        for i in range(numChars * CACHED_CHAR_SIZE):
196            fp.write(chr(charTable[i]))
193        fp.write(bytearray(charTable))
197194   
198195        fp.close()
199196        return 0
branches/kale/src/mame/drivers/model2.c
r243932r243933
13231323   {
13241324      if (first_read == 1)
13251325      {
1326         // the RAM based schemes expect a dummy value before the start of the stream
1327         // to match the previous simulation (dynamite cop) I use 0x0000 here
1326         // is there a CPU core bug or similar?
1327         // the only way to return the same stream as the previous simulation (for dynamite cop) is to return a
1328         // 0x0000 as the first return value before returning the actual sequence.
1329         // note that even with our simulation code pilot kids crashes in the way it would if the protection failed, so something seems wrong.
13281330         first_read = 0;
13291331         retval = 0;
13301332      }
branches/kale/src/mame/drivers/model3.c
r243932r243933
17561756
17571757READ64_MEMBER(model3_state::model3_security_r)
17581758{
1759   UINT64 retvalue = U64(0xffffffffffffffff);
1760
17611759   switch(offset)
17621760   {
1763      case 0x00 / 8:    retvalue = 0; break;       /* status */
1761      case 0x00/8:    return 0;       /* status */
17641762      case 0x1c/8:                    /* security board data read */
17651763      {
17661764         if (core_stricmp(machine().system().name, "vs299") == 0 ||
17671765            core_stricmp(machine().system().name, "vs2v991") == 0)
17681766         {
1769            retvalue = (UINT64)vs299_prot_data[m_prot_data_ptr++] << 48;
1767            return (UINT64)vs299_prot_data[m_prot_data_ptr++] << 48;
17701768         }
17711769         else if (core_stricmp(machine().system().name, "swtrilgy") == 0 ||
17721770                  core_stricmp(machine().system().name, "swtrilgya") == 0)
r243932r243933
17761774            {
17771775               m_prot_data_ptr = 0;
17781776            }
1779            retvalue = data;
1777            return data;
17801778         }
17811779         else if (core_stricmp(machine().system().name, "fvipers2") == 0)
17821780         {
r243932r243933
17851783            {
17861784               m_prot_data_ptr = 0;
17871785            }
1788            retvalue = data;
1786            return data;
17891787         }
17901788         else if (core_stricmp(machine().system().name, "spikeout") == 0 ||
17911789                  core_stricmp(machine().system().name, "spikeofe") == 0)
r243932r243933
17951793            {
17961794               m_prot_data_ptr = 0;
17971795            }
1798            retvalue = data;
1796            return data;
17991797         }
18001798         else if (core_stricmp(machine().system().name, "eca") == 0 ||
18011799                  core_stricmp(machine().system().name, "ecax") == 0)
r243932r243933
18051803            {
18061804               m_prot_data_ptr = 0;
18071805            }
1808            retvalue = data;
1806            return data;
18091807         }
18101808         else if (core_stricmp(machine().system().name, "oceanhun") == 0)
18111809         {
r243932r243933
18141812            {
18151813               m_prot_data_ptr = 0;
18161814            }
1817            retvalue = data;
1815            return data;
18181816         }
18191817         else
18201818         {
1821            retvalue = 0;
1819            return 0;
18221820         }
1823         break;
18241821      }
18251822   }
1826   printf("model3_security_r offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(retvalue >> 32), (UINT32)(retvalue & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff));
1827
1828   return retvalue;
1823   return U64(0xffffffffffffffff);
18291824}
18301825
1831READ64_MEMBER(model3_state::model3_5881prot_r)
1832{
1833   UINT64 retvalue = U64(0xffffffffffffffff);
1834
1835   if (offset == 0x00 / 8)
1836   {
1837      retvalue = 0;
1838   }
1839   else if (offset == 0x18 / 8)
1840   {
1841      if (first_read == 1)
1842      {
1843         // the RAM based schemes expect a dummy value before the start of the stream
1844         // to match the previous simulation I use 0xffff here
1845         first_read = 0;
1846         retvalue = 0xffff << 16;
1847      }
1848      else
1849      {
1850         UINT8* base;
1851         retvalue = m_cryptdevice->do_decrypt(base);
1852         //   retvalue = ((retvalue & 0xff00) >> 8) | ((retvalue & 0x00ff) << 8); // don't endian swap the return value on this hardware
1853         retvalue <<= 16;
1854      }
1855
1856   //   printf("model3_5881prot_r offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(retvalue >> 32), (UINT32)(retvalue & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff));
1857   }
1858   else
1859   {
1860      printf("model3_5881prot_r offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(retvalue >> 32), (UINT32)(retvalue & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff));
1861   }
1862
1863   return retvalue;
1864
1865
1866}
1867
1868WRITE64_MEMBER(model3_state::model3_5881prot_w)
1869{
1870   if (offset == 0x10 / 8)
1871   {
1872      // code is copied to RAM first, so base address is always 0
1873      m_cryptdevice->set_addr_low(0);
1874      m_cryptdevice->set_addr_high(0);
1875
1876      if (data != 0)
1877         printf("model3_5881prot_w address isn't 0?\n");
1878
1879      first_read = 1;
1880   }
1881   else if (offset == 0x18 / 8)
1882   {
1883      UINT16 subkey = data >> (32 + 16);
1884      subkey = ((subkey & 0xff00) >> 8) | ((subkey & 0x00ff) << 8); // endian swap the sub-key for this hardware
1885      printf("model3_5881prot_w setting subkey %04x\n", subkey);
1886      m_cryptdevice->set_subkey(subkey);
1887   }
1888   else
1889   {
1890      printf("model3_5881prot_w offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(data >> 32), (UINT32)(data & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff));
1891   }
1892
1893
1894
1895}
1896
18971826WRITE64_MEMBER(model3_state::daytona2_rombank_w)
18981827{
18991828   if (ACCESSING_BITS_56_63)
r243932r243933
19181847   AM_RANGE(0xf00c0000, 0xf00dffff) AM_MIRROR(0x0e000000) AM_RAM AM_SHARE("backup")    /* backup SRAM */
19191848   AM_RANGE(0xf0100000, 0xf010003f) AM_MIRROR(0x0e000000) AM_READWRITE(model3_sys_r, model3_sys_w )
19201849   AM_RANGE(0xf0140000, 0xf014003f) AM_MIRROR(0x0e000000) AM_READWRITE(model3_rtc_r, model3_rtc_w )
1850   AM_RANGE(0xf0180000, 0xf019ffff) AM_MIRROR(0x0e000000) AM_RAM                           /* Security Board RAM */
1851   AM_RANGE(0xf01a0000, 0xf01a003f) AM_MIRROR(0x0e000000) AM_READ(model3_security_r )  /* Security board */
19211852
19221853   AM_RANGE(0xf1000000, 0xf10f7fff) AM_READWRITE(model3_char_r, model3_char_w )    /* character RAM */
19231854   AM_RANGE(0xf10f8000, 0xf10fffff) AM_READWRITE(model3_tile_r, model3_tile_w )    /* tilemaps */
r243932r243933
56605591   MCFG_SOUND_ROUTE(0, "rspeaker", 2.0)
56615592MACHINE_CONFIG_END
56625593
5663UINT16 model3_state::crypt_read_callback(UINT32 addr)
5664{
5665   UINT16 dat = 0;
5666   if (addr < 0x8000)
5667   {
5668      dat = m_maincpu->space().read_word((0xf0180000 + 4 * addr)); // every other word is unused in this RAM, probably 32-bit ram on 64-bit bus?
5669   }
5670
5671//   dat = ((dat & 0xff00) >> 8) | ((dat & 0x00ff) << 8);
5672//   printf("reading %04x\n", dat);
5673   return dat;
5674}
5675
5676static MACHINE_CONFIG_DERIVED( model3_21_5881, model3_21 )
5677   MCFG_DEVICE_ADD("315_5881", SEGA315_5881_CRYPT, 0)
5678   MCFG_SET_READ_CALLBACK(model3_state, crypt_read_callback)
5679MACHINE_CONFIG_END
5680
5681
56825594static void interleave_vroms(running_machine &machine)
56835595{
56845596   model3_state *state = machine.driver_data<model3_state>();
r243932r243933
57105622   }
57115623}
57125624
5713DRIVER_INIT_MEMBER(model3_state, genprot)
5714{
5715   INT64 key = get_315_5881_key(machine());
5716
5717   m_maincpu->space(AS_PROGRAM).install_ram(0xf0180000, 0xf019ffff, 0, 0x0e000000);
5718
5719   if (key != -1)
5720   {
5721//      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xf01a0000, 0xf01a003f, read64_delegate(FUNC(model3_state::model3_5881prot_r), this), write64_delegate(FUNC(model3_state::model3_5881prot_w), this));
5722      m_cryptdevice->set_key(key);
5723      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xf01a0000, 0xf01a003f, 0, 0x0e000000, read64_delegate(FUNC(model3_state::model3_5881prot_r), this), write64_delegate(FUNC(model3_state::model3_5881prot_w), this) );                   
5724   }
5725   else
5726   {
5727      m_maincpu->space(AS_PROGRAM).install_read_handler(0xf01a0000, 0xf01a003f, 0, 0x0e000000, read64_delegate(FUNC(model3_state::model3_security_r), this) );                   
5728   }
5729}
5730
57315625DRIVER_INIT_MEMBER(model3_state,model3_10)
57325626{
57335627   interleave_vroms(machine());
r243932r243933
59485842
59495843DRIVER_INIT_MEMBER(model3_state,swtrilgy)
59505844{
5951
59525845   UINT32 *rom = (UINT32*)memregion("user1")->base();
59535846   DRIVER_INIT_CALL(model3_20);
59545847
r243932r243933
59595852
59605853   rom[(0x043dc^4)/4] = 0x48000090;        // skip force feedback setup
59615854   rom[(0xf6e44^4)/4] = 0x60000000;
5962
5963
5964   DRIVER_INIT_CALL(genprot);
5965
59665855}
59675856
59685857DRIVER_INIT_MEMBER(model3_state,swtrilga)
r243932r243933
61146003GAME( 1999, vs299,    vs2v991, model3_20, model3, model3_state,      vs299, ROT0, "Sega", "Virtua Striker 2 '99", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
61156004
61166005/* Model 3 Step 2.1 */
6117GAME( 1998, daytona2,         0, model3_21,      daytona2, model3_state, daytona2, ROT0, "Sega", "Daytona USA 2 (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6118GAME( 1998, dayto2pe,         0, model3_21,      daytona2, model3_state, dayto2pe, ROT0, "Sega", "Daytona USA 2 Power Edition", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6119GAME( 1998, dirtdvls,         0, model3_21,      scud, model3_state,     dirtdvls, ROT0, "Sega", "Dirt Devils (set 1) (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6120GAME( 1998, dirtdvlsa, dirtdvls, model3_21,      scud, model3_state,     dirtdvls, ROT0, "Sega", "Dirt Devils (set 2) (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6121GAME( 1998, swtrilgy,         0, model3_21_5881, swtrilgy, model3_state, swtrilgy, ROT0, "Sega / LucasArts", "Star Wars Trilogy (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6122GAME( 1998, swtrilgya, swtrilgy, model3_21_5881, swtrilgy, model3_state, swtrilga, ROT0, "Sega / LucasArts", "Star Wars Trilogy", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6123GAME( 1998, spikeout,         0, model3_21,      model3, model3_state,   spikeout, ROT0, "Sega", "Spikeout (Revision C)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6124GAME( 1998, spikeofe,         0, model3_21,      model3, model3_state,   spikeofe, ROT0, "Sega", "Spikeout Final Edition", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6125GAME( 1998, magtruck,         0, model3_21,      eca, model3_state,      magtruck, ROT0, "Sega", "Magical Truck Adventure", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6126GAME( 1999, eca,              0, model3_21,      eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6127GAME( 1999, ecax,           eca, model3_21,      eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance (Export)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6128GAME( 1999, ecap,           eca, model3_21,      eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance (US location test?)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6006GAME( 1998, daytona2,         0, model3_21, daytona2, model3_state, daytona2, ROT0, "Sega", "Daytona USA 2 (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6007GAME( 1998, dayto2pe,         0, model3_21, daytona2, model3_state, dayto2pe, ROT0, "Sega", "Daytona USA 2 Power Edition", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6008GAME( 1998, dirtdvls,         0, model3_21, scud, model3_state,     dirtdvls, ROT0, "Sega", "Dirt Devils (set 1) (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6009GAME( 1998, dirtdvlsa, dirtdvls, model3_21, scud, model3_state,     dirtdvls, ROT0, "Sega", "Dirt Devils (set 2) (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6010GAME( 1998, swtrilgy,         0, model3_21, swtrilgy, model3_state, swtrilgy, ROT0, "Sega / LucasArts", "Star Wars Trilogy (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6011GAME( 1998, swtrilgya, swtrilgy, model3_21, swtrilgy, model3_state, swtrilga, ROT0, "Sega / LucasArts", "Star Wars Trilogy", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6012GAME( 1998, spikeout,         0, model3_21, model3, model3_state,   spikeout, ROT0, "Sega", "Spikeout (Revision C)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6013GAME( 1998, spikeofe,         0, model3_21, model3, model3_state,   spikeofe, ROT0, "Sega", "Spikeout Final Edition", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6014GAME( 1998, magtruck,         0, model3_21, eca, model3_state,      magtruck, ROT0, "Sega", "Magical Truck Adventure", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6015GAME( 1999, eca,              0, model3_21, eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6016GAME( 1999, ecax,           eca, model3_21, eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance (Export)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6017GAME( 1999, ecap,           eca, model3_21, eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance (US location test?)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
branches/kale/src/mame/drivers/stv.c
r243932r243933
30073007
30083008//GAME YEAR, NAME,     PARENT,  MACH, INP, INIT,      MONITOR
30093009/* Playable */
3010GAME( 1998, astrass,   stvbios, stv,      stv6b, stv_state,      astrass,    ROT0,   "Sunsoft",                      "Astra SuperStars (J 980514 V1.002)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3010GAME( 1998, astrass,   stvbios, stv,      stv6b, stv_state,     astrass,    ROT0,   "Sunsoft",                      "Astra SuperStars (J 980514 V1.002)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
30113011GAME( 1995, bakubaku,  stvbios, stv,      stv, stv_state,        stv,        ROT0,   "Sega",                         "Baku Baku Animal (J 950407 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30123012GAME( 1996, batmanfr,  stvbios, batmanfr, stv, stv_state,        batmanfr,   ROT0,   "Acclaim",                      "Batman Forever (JUE 960507 V1.000)", GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS )
30133013GAME( 1996, colmns97,  stvbios, stv,      stv, stv_state,        colmns97,   ROT0,   "Sega",                         "Columns '97 (JET 961209 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30143014GAME( 1997, cotton2,   stvbios, stv,      stv, stv_state,        cotton2,    ROT0,   "Success",                      "Cotton 2 (JUET 970902 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30153015GAME( 1998, cottonbm,  stvbios, stv,      stv, stv_state,        cottonbm,   ROT0,   "Success",                      "Cotton Boomerang (JUET 980709 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30163016GAME( 1995, critcrsh,  stvbios, stv,      critcrsh, stv_state,   critcrsh,   ROT0,   "Sega",                         "Critter Crusher (EA 951204 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3017GAME( 1999, danchih,   stvbios, stv,      stvmp, stv_state,      danchih,    ROT0,   "Altron (Tecmo license)",       "Danchi de Hanafuda (J 990607 V1.400)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3017GAME( 1999, danchih,   stvbios, stv,      stvmp, stv_state,     danchih,    ROT0,   "Altron (Tecmo license)",       "Danchi de Hanafuda (J 990607 V1.400)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30183018GAME( 2000, danchiq,   stvbios, stv,      stv, stv_state,        danchiq,    ROT0,   "Altron",                       "Danchi de Quiz Okusan Yontaku Desuyo! (J 001128 V1.200)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30193019GAME( 1996, diehard,   stvbios, stv,      stv, stv_state,        diehard,    ROT0,   "Sega",                         "Die Hard Arcade (UET 960515 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND  )
30203020GAME( 1996, dnmtdeka,  diehard, stv,      stv, stv_state,        dnmtdeka,   ROT0,   "Sega",                         "Dynamite Deka (J 960515 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND  )
30213021GAME( 1995, ejihon,    stvbios, stv,      stv, stv_state,        stv,        ROT0,   "Sega",                         "Ejihon Tantei Jimusyo (J 950613 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3022GAME( 1998, elandore,  stvbios, stv,      stv6b, stv_state,      elandore,   ROT0,   "Sai-Mate",                     "Touryuu Densetsu Elan-Doree / Elan Doree - Legend of Dragoon (JUET 980922 V1.006)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3023GAME( 1999, ffreveng,  stvbios, stv,      stv, stv_state,        ffreveng,   ROT0,   "Capcom",                       "Final Fight Revenge (JUET 990714 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30243022GAME( 1995, fhboxers,  stvbios, stv,      stv, stv_state,        fhboxers,   ROT0,   "Sega",                         "Funky Head Boxers (JUETBKAL 951218 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30253023GAME( 1997, findlove,  stvbios, stv,      stv, stv_state,        stv,        ROT0,   "Daiki / FCF",                  "Zenkoku Seifuku Bishoujo Grand Prix Find Love (J 971212 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3026GAME( 1994, gaxeduel,  stvbios, stv,      stv6b, stv_state,      gaxeduel,   ROT0,   "Sega",                         "Golden Axe - The Duel (JUETL 950117 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS)
3024GAME( 1994, gaxeduel,  stvbios, stv,      stv6b, stv_state,     gaxeduel,   ROT0,   "Sega",                         "Golden Axe - The Duel (JUETL 950117 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS)
30273025GAME( 1998, grdforce,  stvbios, stv,      stv, stv_state,        grdforce,   ROT0,   "Success",                      "Guardian Force (JUET 980318 V0.105)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3028GAME( 1998, groovef,   stvbios, stv,      stv6b, stv_state,      groovef,    ROT0,   "Atlus",                        "Groove on Fight - Gouketsuji Ichizoku 3 (J 970416 V1.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3026GAME( 1998, groovef,   stvbios, stv,      stv6b, stv_state,     groovef,    ROT0,   "Atlus",                        "Groove on Fight - Gouketsuji Ichizoku 3 (J 970416 V1.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30293027GAME( 1997, hanagumi,  stvbios, stv,      stv, stv_state,        hanagumi,   ROT0,   "Sega",                         "Sakura Taisen - Hanagumi Taisen Columns (J 971007 V1.010)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
30303028GAME( 1996, introdon,  stvbios, stv,      stv, stv_state,        stv,        ROT0,   "Sunsoft / Success",            "Karaoke Quiz Intro Don Don! (J 960213 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3031GAME( 1995, kiwames,   stvbios, stv,      stvmp, stv_state,      stvmp,      ROT0,   "Athena",                       "Pro Mahjong Kiwame S (J 951020 V1.208)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3029GAME( 1995, kiwames,   stvbios, stv,      stvmp, stv_state,     stvmp,      ROT0,   "Athena",                       "Pro Mahjong Kiwame S (J 951020 V1.208)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30323030GAME( 1997, maruchan,  stvbios, stv,      stv, stv_state,        maruchan,   ROT0,   "Sega / Toyosuisan",            "Maru-Chan de Goo! (J 971216 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30333031GAME( 1996, mausuke,   stvbios, stv,      stv, stv_state,        mausuke,    ROT0,   "Data East",                    "Mausuke no Ojama the World (J 960314 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30343032GAME( 1998, myfairld,  stvbios, stv,      myfairld, stv_state,   stvmp,      ROT0,   "Micronet",                     "Virtual Mahjong 2 - My Fair Lady (J 980608 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
r243932r243933
30463044GAME( 1995, sandor,    stvbios, stv,      stv, stv_state,        sandor,     ROT0,   "Sega",                         "Puzzle & Action: Sando-R (J 951114 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30473045GAME( 1997, thunt,     sandor,  stv,      stv, stv_state,        thunt,      ROT0,   "Sega",                         "Puzzle & Action: Treasure Hunt (JUET 970901 V2.00E)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30483046GAME( 1997, thuntk,    sandor,  stv,      stv, stv_state,        sandor,     ROT0,   "Sega / Deniam",                "Puzzle & Action: BoMulEul Chajara (JUET 970125 V2.00K)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3049GAME( 1998, twcup98,   stvbios, stv,      stv, stv_state,        twcup98,    ROT0,   "Tecmo",                        "Tecmo World Cup '98 (JUET 980410 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30503047GAME( 1995, smleague,  stvbios, stv,      stv, stv_state,        smleague,   ROT0,   "Sega",                         "Super Major League (U 960108 V1.000)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30513048GAME( 1995, finlarch,  smleague,stv,      stv, stv_state,        finlarch,   ROT0,   "Sega",                         "Final Arch (J 950714 V1.001)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30523049GAME( 1996, sokyugrt,  stvbios, stv,      stv, stv_state,        sokyugrt,   ROT0,   "Raizing / Eighting",           "Soukyugurentai / Terra Diver (JUET 960821 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
r243932r243933
30563053GAME( 1997, winterht,  stvbios, stv,      stv, stv_state,        winterht,   ROT0,   "Sega",                         "Winter Heat (JUET 971012 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30573054GAME( 1997, znpwfv,    stvbios, stv,      stv, stv_state,        znpwfv,     ROT0,   "Sega",                         "Zen Nippon Pro-Wrestling Featuring Virtua (J 971123 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30583055
3056/* Almost */
3057GAME( 1998, twcup98,   stvbios, stv,      stv, stv_state,        twcup98,    ROT0,   "Tecmo",                        "Tecmo World Cup '98 (JUET 980410 V1.000)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3058GAME( 1998, elandore,  stvbios, stv,      stv6b, stv_state,     elandore,   ROT0,   "Sai-Mate",                     "Touryuu Densetsu Elan-Doree / Elan Doree - Legend of Dragoon (JUET 980922 V1.006)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3059
30593060/* Unemulated printer / camera devices */
30603061GAME( 1998, stress,    stvbios, stv,      stv, stv_state,        stv,        ROT0,   "Sega",                         "Stress Busters (J 981020 V1.000)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
30613062GAME( 1997, nclubv3,   stvbios, stv,      stv, stv_state,        nameclv3,   ROT0,   "Sega",                         "Name Club Ver.3 (J 970723 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING )
r243932r243933
30823083GAME( 1997, techbowl,  stvbios, stv,      stv, stv_state,        stv,        ROT0,   "Sega",                         "Technical Bowling (J 971212 V1.000)", GAME_NOT_WORKING )
30833084GAME( 1999, micrombc,  stvbios, stv,      stv, stv_state,        stv,        ROT0,   "Sega",                         "Microman Battle Charge (J 990326 V1.000)", GAME_NOT_WORKING )
30843085
3086/* Black screen */
3087GAME( 1999, ffreveng,  stvbios, stv,      stv, stv_state,        ffreveng,   ROT0,   "Capcom",                       "Final Fight Revenge (JUET 990714 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3088
30853089/* CD games */
30863090GAME( 1995, sfish2,    0,       stv,      stv, stv_state,        stv,        ROT0,   "Sega",                         "Sport Fishing 2 (UET 951106 V1.10e)", GAME_NO_SOUND | GAME_NOT_WORKING )
30873091GAME( 1995, sfish2j,   sfish2,  stv,      stv, stv_state,        stv,        ROT0,   "Sega",                         "Sport Fishing 2 (J 951201 V1.100)", GAME_NO_SOUND | GAME_NOT_WORKING )
branches/kale/src/mame/includes/model3.h
r243932r243933
44#include "audio/dsbz80.h"
55#include "machine/eepromser.h"
66#include "sound/scsp.h"
7#include "machine/315-5881_crypt.h"
87
98typedef float MATRIX[4][4];
109typedef float VECTOR[4];
r243932r243933
7877      m_dsbz80(*this, DSBZ80_TAG),
7978      m_soundram(*this, "soundram"),
8079      m_gfxdecode(*this, "gfxdecode"),
81      m_palette(*this, "palette"),
82      m_cryptdevice(*this, "315_5881")
80      m_palette(*this, "palette")
8381   {
8482      m_step15_with_mpc106 = false;
8583      m_step20_with_old_real3d = false;
r243932r243933
9997
10098   required_device<gfxdecode_device> m_gfxdecode;
10199   required_device<palette_device> m_palette;
102   optional_device<sega_315_5881_crypt_device> m_cryptdevice;
103100
104101   tilemap_t *m_layer4[4];
105102   tilemap_t *m_layer8[4];
r243932r243933
235232   DECLARE_WRITE16_MEMBER(model3snd_ctrl);
236233   UINT32 pci_device_get_reg();
237234   void pci_device_set_reg(UINT32 value);
238   DECLARE_DRIVER_INIT(genprot);
239235   DECLARE_DRIVER_INIT(lemans24);
240236   DECLARE_DRIVER_INIT(vs298);
241237   DECLARE_DRIVER_INIT(vs299);
r243932r243933
337333   void tap_write(int tck, int tms, int tdi, int trst);
338334   void tap_reset();
339335   void tap_set_asic_ids();
340
341   DECLARE_READ64_MEMBER(model3_5881prot_r);
342   DECLARE_WRITE64_MEMBER(model3_5881prot_w);
343   int first_read;
344   UINT16 crypt_read_callback(UINT32 addr);
345
346336};
branches/kale/src/mame/machine/315-5881_helper.c
r243932r243933
3434   // name             key              gameid #     year     chip label     platform
3535   { "twcup98",         0x05200913 }, // 25209801    1998     317-5039-COM   ST-V
3636   { "astrass",         0x052e2901 }, // 25349801    1998     317-5040-COM   ST-V      (yes, the 317-5040-COM chip was reused for 3 different games and on both Naomi and ST-V!)
37   { "rsgun",           0x05272d01 }, //             1998     317-5041-COM   ST-V
38   { "sss",             0x052b6901 }, //             1998     317-5042-COM   ST-V
39   { "elandore",        0x05226d41 }, //             1998     317-5043-COM   ST-V
37   { "rsgun",           -1         }, //             1998     317-5041-COM   ST-V
38   { "sss",             -1         }, //             1998     317-5042-COM   ST-V
39   { "elandore",        -1         }, //             1998     317-5043-COM   ST-V
4040   { "ffreveng",        0x0524ac01 }, //             1998     317-5049-COM   ST-V
4141
4242   { "gundmct",         0x000e8010 }, // 841-0017    2001     ???            Naomi
r243932r243933
137137
138138
139139   { "vs298",           0x09234e96 }, //             ????     317-0237-COM   Model 3
140   { "swtrilgy",        0x11272a01 }, //             ????     317-0241-COM   Model 3
141   { "swtrilgya",       0x11272a01 }, //             ????     317-0241-COM   Model 3
140   { "swt",             0x11272a01 }, //             ????     317-0241-COM   Model 3
142141   { "vs299",           0x09222ac8 }, //             ????     317-0245-COM   Model 3
143142
144
145143   { NULL, 0 }    // end of table
146144};
147145
branches/kale/src/mame/video/taitoair.c
r243932r243933
229229         int xx1 = x1 >> TAITOAIR_FRAC_SHIFT;
230230         int xx2 = x2 >> TAITOAIR_FRAC_SHIFT;
231231         int grad_col;
232
232         int base_color;
233         
233234         if (xx1 <= cliprect.max_x || xx2 >= cliprect.min_x)
234235         {
235236            if (xx1 < cliprect.min_x)
236237               xx1 = cliprect.min_x;
237238            if (xx2 > cliprect.max_x)
238239               xx2 = cliprect.max_x;
240           
241            if(color & 0x40)
242            {
243               /* Non-terrain elements are colored with this. */
244               base_color = (color & 0x3f) + 0x340;
245               grad_col = 0;
246            }
247            else
248            {
249               /* Terrain elements, with a gradient applied. */
250               /* TODO: it's unknown if gradient color applies by global screen Y coordinate or there's a calculation to somewhere ... */
251               base_color = ((color & 0x3f) * 0x80) + 0x2040;
252               grad_col = (y1 >> 3) & 0x3f;
253            }
239254
240            /* TODO: it's unknown if gradient color applies by global screen Y coordinate or there's a calculation to somewhere ... */
241            grad_col = (y1 >> 3) & 0x3f;
242
243255            while (xx1 <= xx2)
244256            {
245               bitmap.pix16(y1, xx1) = color + grad_col;
257               bitmap.pix16(y1, xx1) = base_color + grad_col;
246258               xx1++;
247259            }
248260         }
r243932r243933
393405                  logerror("quad: unknown value %04x at %04x\n", m_line_ram[adr], adr);
394406                  break;
395407               }
396               m_q.col = ((m_line_ram[adr] & 0x007f) * 0x80) + 0x2040;
408               m_q.col = m_line_ram[adr] & 0x7f;//((m_line_ram[adr] & 0x007f) * 0x80) + 0x2040;
409
397410               adr--;
398411               pcount = 0;
399412               while (pcount < TAITOAIR_POLY_MAX_PT && adr >= 1 && !(m_line_ram[adr] & 0xc000))
branches/kale/src/osd/modules/font/font_module.h
r243932r243933
1/*
2 * font_module.h
3 *
4 */
5
6#ifndef FONT_MODULE_H_
7#define FONT_MODULE_H_
8
9#include "osdepend.h"
10#include "modules/osdmodule.h"
11
12//============================================================
13//  CONSTANTS
14//============================================================
15
16#define OSD_FONT_PROVIDER   "uifontprovider"
17
18class font_module
19{
20public:
21    virtual ~font_module() { }
22    virtual osd_font *font_alloc() = 0;
23};
24
25
26#endif /* FONT_MODULE_H_ */
branches/kale/src/osd/modules/font/font_none.c
r243932r243933
33 *
44 */
55
6#include "font_module.h"
7#include "modules/osdmodule.h"
6#include "osdepend.h"
87
98#include "astring.h"
109#include "corealloc.h"
r243932r243933
2625private:
2726};
2827
28osd_font *osd_font_alloc()
29{
30    return global_alloc(osd_font_none);
31}
32
2933bool osd_font_none::open(const char *font_path, const char *_name, int &height)
3034{
3135    return false;
r243932r243933
5256{
5357    return false;
5458}
55
56class font_none : public osd_module, public font_module
57{
58public:
59    font_none()
60    : osd_module(OSD_FONT_PROVIDER, "none"), font_module()
61    {
62    }
63
64    osd_font *font_alloc()
65    {
66        return global_alloc(osd_font_none);
67    }
68};
69
70MODULE_DEFINITION(FONT_NONE, font_none)
71
branches/kale/src/osd/modules/font/font_osx.c
r243932r243933
33 *
44 */
55
6#include "font_module.h"
7#include "modules/osdmodule.h"
8
9#ifdef SDLMAME_MACOSX
10
116#include <Carbon/Carbon.h>
127
8#include "osdepend.h"
9
1310#include "astring.h"
1411#include "corealloc.h"
1512#include "fileio.h"
r243932r243933
3532    CTFontRef m_font;
3633};
3734
35osd_font *osd_font_alloc()
36{
37    return global_alloc(osd_font_osx);
38}
39
3840bool osd_font_osx::open(const char *font_path, const char *_name, int &height)
3941{
4042    CFStringRef font_name = NULL;
r243932r243933
181183    return bitmap.valid();
182184}
183185
184
185class font_osx : public osd_module, public font_module
186{
187public:
188    font_osx()
189    : osd_module(OSD_FONT_PROVIDER, "osx"), font_module()
190    {
191    }
192
193    osd_font *font_alloc()
194    {
195        return global_alloc(osd_font_osx);
196    }
197
198};
199#else /* SDLMAME_UNIX */
200    MODULE_NOT_SUPPORTED(font_osx, OSD_FONT_PROVIDER, "osx")
201#endif
202
203MODULE_DEFINITION(FONT_OSX, font_osx)
branches/kale/src/osd/modules/font/font_sdl.c
r243932r243933
1/*
2 * font_sdl.c
3 *
4 */
5
6#include "font_module.h"
7#include "modules/osdmodule.h"
8
9#if defined(SDLMAME_UNIX) && (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN))
10
11#if (SDLMAME_SDL2)
12#include <SDL2/SDL_ttf.h>
13#else
14#include <SDL/SDL_ttf.h>
15#endif
16#ifndef SDLMAME_HAIKU
17#include <fontconfig/fontconfig.h>
18#endif
19
20
21#include "astring.h"
22#include "corealloc.h"
23#include "fileio.h"
24
25#define POINT_SIZE 144.0
26
27//-------------------------------------------------
28//  font_open - attempt to "open" a handle to the
29//  font with the given name
30//-------------------------------------------------
31
32class osd_font_sdl : public osd_font
33{
34public:
35    virtual ~osd_font_sdl() {};
36
37    virtual bool open(const char *font_path, const char *name, int &height);
38    virtual void close();
39    virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
40private:
41#ifndef SDLMAME_HAIKU
42    TTF_Font *search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles);
43#endif
44    bool BDF_Check_Magic(astring name);
45    TTF_Font * TTF_OpenFont_Magic(astring name, int fsize);
46    TTF_Font *m_font;
47};
48
49bool osd_font_sdl::open(const char *font_path, const char *_name, int &height)
50{
51    TTF_Font *font = (TTF_Font *)NULL;
52    bool bakedstyles = false;
53    int style = 0;
54
55    // accept qualifiers from the name
56    astring name(_name);
57
58    if (name == "default")
59    {
60        name = "Liberation Sans";
61    }
62
63    bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0);
64    bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0);
65    bool underline = (name.replace(0, "[U]", "") + name.replace(0, "[u]", "") > 0);
66    bool strike = (name.replace(0, "[S]", "") + name.replace(0, "[s]", "") > 0);
67
68    // first up, try it as a filename
69    font = TTF_OpenFont_Magic(name, POINT_SIZE);
70
71    // if no success, try the font path
72
73    if (!font)
74    {
75        osd_printf_verbose("Searching font %s in -%s\n", name.cstr(), OPTION_FONTPATH);
76        //emu_file file(options().font_path(), OPEN_FLAG_READ);
77        emu_file file(font_path, OPEN_FLAG_READ);
78        if (file.open(name) == FILERR_NONE)
79        {
80            astring full_name = file.fullpath();
81            font = TTF_OpenFont_Magic(full_name, POINT_SIZE);
82            if (font)
83                osd_printf_verbose("Found font %s\n", full_name.cstr());
84        }
85    }
86
87    // if that didn't work, crank up the FontConfig database
88#ifndef SDLMAME_HAIKU
89    if (!font)
90    {
91        font = search_font_config(name, bold, italic, underline, bakedstyles);
92    }
93#endif
94
95    if (!font)
96    {
97        if (!BDF_Check_Magic(name))
98        {
99            osd_printf_verbose("font %s is not TrueType or BDF, using MAME default\n", name.cstr());
100        }
101        return NULL;
102    }
103
104    // apply styles
105    if (!bakedstyles)
106    {
107        style |= bold ? TTF_STYLE_BOLD : 0;
108        style |= italic ? TTF_STYLE_ITALIC : 0;
109    }
110    style |= underline ? TTF_STYLE_UNDERLINE : 0;
111    // SDL_ttf 2.0.9 and earlier does not define TTF_STYLE_STRIKETHROUGH
112#if SDL_VERSIONNUM(TTF_MAJOR_VERSION, TTF_MINOR_VERSION, TTF_PATCHLEVEL) > SDL_VERSIONNUM(2,0,9)
113    style |= strike ? TTF_STYLE_STRIKETHROUGH : 0;
114#else
115    if (strike)
116        osd_printf_warning("Ignoring strikethrough for SDL_TTF older than 2.0.10\n");
117#endif // PATCHLEVEL
118    TTF_SetFontStyle(font, style);
119
120    height = TTF_FontLineSkip(font);
121
122    m_font = font;
123    return true;
124}
125
126//-------------------------------------------------
127//  font_close - release resources associated with
128//  a given OSD font
129//-------------------------------------------------
130
131void osd_font_sdl::close()
132{
133    TTF_CloseFont(this->m_font);
134}
135
136//-------------------------------------------------
137//  font_get_bitmap - allocate and populate a
138//  BITMAP_FORMAT_ARGB32 bitmap containing the
139//  pixel values rgb_t(0xff,0xff,0xff,0xff)
140//  or rgb_t(0x00,0xff,0xff,0xff) for each
141//  pixel of a black & white font
142//-------------------------------------------------
143
144bool osd_font_sdl::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
145{
146    TTF_Font *ttffont;
147    SDL_Surface *drawsurf;
148    SDL_Color fcol = { 0xff, 0xff, 0xff };
149    UINT16 ustr[16];
150
151    ttffont = m_font;
152
153    memset(ustr,0,sizeof(ustr));
154    ustr[0] = (UINT16)chnum;
155    drawsurf = TTF_RenderUNICODE_Solid(ttffont, ustr, fcol);
156
157    // was nothing returned?
158    if (drawsurf)
159    {
160        // allocate a MAME destination bitmap
161        bitmap.allocate(drawsurf->w, drawsurf->h);
162
163        // copy the rendered character image into it
164        for (int y = 0; y < bitmap.height(); y++)
165        {
166            UINT32 *dstrow = &bitmap.pix32(y);
167            UINT8 *srcrow = (UINT8 *)drawsurf->pixels;
168
169            srcrow += (y * drawsurf->pitch);
170
171            for (int x = 0; x < drawsurf->w; x++)
172            {
173                dstrow[x] = srcrow[x] ? rgb_t(0xff,0xff,0xff,0xff) : rgb_t(0x00,0xff,0xff,0xff);
174            }
175        }
176
177        // what are these?
178        xoffs = yoffs = 0;
179        width = drawsurf->w;
180
181        SDL_FreeSurface(drawsurf);
182    }
183
184    return bitmap.valid();
185}
186
187TTF_Font * osd_font_sdl::TTF_OpenFont_Magic(astring name, int fsize)
188{
189    emu_file file(OPEN_FLAG_READ);
190    if (file.open(name) == FILERR_NONE)
191    {
192        unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff };
193        unsigned char magic[5] = { 0x00, 0x01, 0x00, 0x00, 0x00 };
194        file.read(buffer,5);
195        if (memcmp(buffer, magic, 5))
196            return NULL;
197    }
198    return TTF_OpenFont(name.cstr(), POINT_SIZE);
199}
200
201bool osd_font_sdl::BDF_Check_Magic(astring name)
202{
203    emu_file file(OPEN_FLAG_READ);
204    if (file.open(name) == FILERR_NONE)
205    {
206        unsigned char buffer[9];
207        unsigned char magic[9] = { 'S', 'T', 'A', 'R', 'T', 'F', 'O', 'N', 'T' };
208        file.read(buffer, 9);
209        file.close();
210        if (!memcmp(buffer, magic, 9))
211            return true;
212    }
213
214    return false;
215}
216
217#ifndef SDLMAME_HAIKU
218TTF_Font *osd_font_sdl::search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles)
219{
220    TTF_Font *font = (TTF_Font *)NULL;
221    FcConfig *config;
222    FcPattern *pat;
223    FcObjectSet *os;
224    FcFontSet *fontset;
225    FcValue val;
226
227    config = FcConfigGetCurrent();
228    pat = FcPatternCreate();
229    os = FcObjectSetCreate();
230    FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr());
231
232    // try and get a font with the requested styles baked-in
233    if (bold)
234    {
235        if (italic)
236        {
237            FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold Italic");
238        }
239        else
240        {
241            FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold");
242        }
243    }
244    else if (italic)
245    {
246        FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Italic");
247    }
248    else
249    {
250        FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular");
251    }
252
253    FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType");
254
255    FcObjectSetAdd(os, FC_FILE);
256    fontset = FcFontList(config, pat, os);
257
258    for (int i = 0; i < fontset->nfont; i++)
259    {
260        if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch)
261        {
262            continue;
263        }
264
265        if (val.type != FcTypeString)
266        {
267            continue;
268        }
269
270        osd_printf_verbose("Matching font: %s\n", val.u.s);
271        {
272            astring match_name((const char*)val.u.s);
273            font = TTF_OpenFont_Magic(match_name, POINT_SIZE);
274        }
275
276        if (font)
277        {
278            bakedstyles = true;
279            break;
280        }
281    }
282
283    // didn't get a font above?  try again with no baked-in styles
284    if (!font)
285    {
286        FcPatternDestroy(pat);
287        FcFontSetDestroy(fontset);
288
289        pat = FcPatternCreate();
290        FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr());
291        FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular");
292        FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType");
293        fontset = FcFontList(config, pat, os);
294
295        for (int i = 0; i < fontset->nfont; i++)
296        {
297            if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch)
298            {
299                continue;
300            }
301
302            if (val.type != FcTypeString)
303            {
304                continue;
305            }
306
307            osd_printf_verbose("Matching unstyled font: %s\n", val.u.s);
308            {
309                astring match_name((const char*)val.u.s);
310                font = TTF_OpenFont_Magic(match_name, POINT_SIZE);
311            }
312
313            if (font)
314            {
315                break;
316            }
317        }
318    }
319
320    FcPatternDestroy(pat);
321    FcObjectSetDestroy(os);
322    FcFontSetDestroy(fontset);
323    return font;
324}
325#endif
326
327
328class font_sdl : public osd_module, public font_module
329{
330public:
331    font_sdl()
332    : osd_module(OSD_FONT_PROVIDER, "sdl"), font_module()
333    {
334    }
335
336    osd_font *font_alloc()
337    {
338        return global_alloc(osd_font_sdl);
339    }
340
341    virtual void init()
342    {
343        if (TTF_Init() == -1)
344        {
345            osd_printf_error("SDL_ttf failed: %s\n", TTF_GetError());
346        }
347    }
348
349    virtual void exit()
350    {
351        TTF_Quit();
352    }
353};
354#else /* SDLMAME_UNIX */
355    MODULE_NOT_SUPPORTED(font_sdl, OSD_FONT_PROVIDER, "sdl")
356#endif
357
358MODULE_DEFINITION(FONT_SDL, font_sdl)
359
360
branches/kale/src/osd/modules/font/font_unix.c
r0r243933
1/*
2 * font_sdl.c
3 *
4 */
5
6#if (SDLMAME_SDL2)
7#include <SDL2/SDL_ttf.h>
8#else
9#include <SDL/SDL_ttf.h>
10#endif
11#ifndef SDLMAME_HAIKU
12#include <fontconfig/fontconfig.h>
13#endif
14
15#include "osdepend.h"
16
17#include "astring.h"
18#include "corealloc.h"
19#include "fileio.h"
20
21#define POINT_SIZE 144.0
22
23//-------------------------------------------------
24//  font_open - attempt to "open" a handle to the
25//  font with the given name
26//-------------------------------------------------
27
28class osd_font_unix : public osd_font
29{
30public:
31    virtual ~osd_font_unix() {};
32
33    virtual bool open(const char *font_path, const char *name, int &height);
34    virtual void close();
35    virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
36private:
37#ifndef SDLMAME_HAIKU
38    TTF_Font *search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles);
39#endif
40    bool BDF_Check_Magic(astring name);
41    TTF_Font * TTF_OpenFont_Magic(astring name, int fsize);
42    TTF_Font *m_font;
43};
44
45osd_font *osd_font_alloc()
46{
47    return global_alloc(osd_font_unix);
48}
49
50bool osd_font_unix::open(const char *font_path, const char *_name, int &height)
51{
52    TTF_Font *font = (TTF_Font *)NULL;
53    bool bakedstyles = false;
54    int style = 0;
55
56    // accept qualifiers from the name
57    astring name(_name);
58
59    if (name == "default")
60    {
61        name = "Liberation Sans";
62    }
63
64    bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0);
65    bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0);
66    bool underline = (name.replace(0, "[U]", "") + name.replace(0, "[u]", "") > 0);
67    bool strike = (name.replace(0, "[S]", "") + name.replace(0, "[s]", "") > 0);
68
69    // first up, try it as a filename
70    font = TTF_OpenFont_Magic(name, POINT_SIZE);
71
72    // if no success, try the font path
73
74    if (!font)
75    {
76        osd_printf_verbose("Searching font %s in -%s\n", name.cstr(), OPTION_FONTPATH);
77        //emu_file file(options().font_path(), OPEN_FLAG_READ);
78        emu_file file(font_path, OPEN_FLAG_READ);
79        if (file.open(name) == FILERR_NONE)
80        {
81            astring full_name = file.fullpath();
82            font = TTF_OpenFont_Magic(full_name, POINT_SIZE);
83            if (font)
84                osd_printf_verbose("Found font %s\n", full_name.cstr());
85        }
86    }
87
88    // if that didn't work, crank up the FontConfig database
89#ifndef SDLMAME_HAIKU
90    if (!font)
91    {
92        font = search_font_config(name, bold, italic, underline, bakedstyles);
93    }
94#endif
95
96    if (!font)
97    {
98        if (!BDF_Check_Magic(name))
99        {
100            osd_printf_verbose("font %s is not TrueType or BDF, using MAME default\n", name.cstr());
101        }
102        return NULL;
103    }
104
105    // apply styles
106    if (!bakedstyles)
107    {
108        style |= bold ? TTF_STYLE_BOLD : 0;
109        style |= italic ? TTF_STYLE_ITALIC : 0;
110    }
111    style |= underline ? TTF_STYLE_UNDERLINE : 0;
112    // SDL_ttf 2.0.9 and earlier does not define TTF_STYLE_STRIKETHROUGH
113#if SDL_VERSIONNUM(TTF_MAJOR_VERSION, TTF_MINOR_VERSION, TTF_PATCHLEVEL) > SDL_VERSIONNUM(2,0,9)
114    style |= strike ? TTF_STYLE_STRIKETHROUGH : 0;
115#else
116    if (strike)
117        osd_printf_warning("Ignoring strikethrough for SDL_TTF older than 2.0.10\n");
118#endif // PATCHLEVEL
119    TTF_SetFontStyle(font, style);
120
121    height = TTF_FontLineSkip(font);
122
123    m_font = font;
124    return true;
125}
126
127//-------------------------------------------------
128//  font_close - release resources associated with
129//  a given OSD font
130//-------------------------------------------------
131
132void osd_font_unix::close()
133{
134    TTF_CloseFont(this->m_font);
135}
136
137//-------------------------------------------------
138//  font_get_bitmap - allocate and populate a
139//  BITMAP_FORMAT_ARGB32 bitmap containing the
140//  pixel values rgb_t(0xff,0xff,0xff,0xff)
141//  or rgb_t(0x00,0xff,0xff,0xff) for each
142//  pixel of a black & white font
143//-------------------------------------------------
144
145bool osd_font_unix::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
146{
147    TTF_Font *ttffont;
148    SDL_Surface *drawsurf;
149    SDL_Color fcol = { 0xff, 0xff, 0xff };
150    UINT16 ustr[16];
151
152    ttffont = m_font;
153
154    memset(ustr,0,sizeof(ustr));
155    ustr[0] = (UINT16)chnum;
156    drawsurf = TTF_RenderUNICODE_Solid(ttffont, ustr, fcol);
157
158    // was nothing returned?
159    if (drawsurf)
160    {
161        // allocate a MAME destination bitmap
162        bitmap.allocate(drawsurf->w, drawsurf->h);
163
164        // copy the rendered character image into it
165        for (int y = 0; y < bitmap.height(); y++)
166        {
167            UINT32 *dstrow = &bitmap.pix32(y);
168            UINT8 *srcrow = (UINT8 *)drawsurf->pixels;
169
170            srcrow += (y * drawsurf->pitch);
171
172            for (int x = 0; x < drawsurf->w; x++)
173            {
174                dstrow[x] = srcrow[x] ? rgb_t(0xff,0xff,0xff,0xff) : rgb_t(0x00,0xff,0xff,0xff);
175            }
176        }
177
178        // what are these?
179        xoffs = yoffs = 0;
180        width = drawsurf->w;
181
182        SDL_FreeSurface(drawsurf);
183    }
184
185    return bitmap.valid();
186}
187
188TTF_Font * osd_font_unix::TTF_OpenFont_Magic(astring name, int fsize)
189{
190    emu_file file(OPEN_FLAG_READ);
191    if (file.open(name) == FILERR_NONE)
192    {
193        unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff };
194        unsigned char magic[5] = { 0x00, 0x01, 0x00, 0x00, 0x00 };
195        file.read(buffer,5);
196        if (memcmp(buffer, magic, 5))
197            return NULL;
198    }
199    return TTF_OpenFont(name.cstr(), POINT_SIZE);
200}
201
202bool osd_font_unix::BDF_Check_Magic(astring name)
203{
204    emu_file file(OPEN_FLAG_READ);
205    if (file.open(name) == FILERR_NONE)
206    {
207        unsigned char buffer[9];
208        unsigned char magic[9] = { 'S', 'T', 'A', 'R', 'T', 'F', 'O', 'N', 'T' };
209        file.read(buffer, 9);
210        file.close();
211        if (!memcmp(buffer, magic, 9))
212            return true;
213    }
214
215    return false;
216}
217
218#ifndef SDLMAME_HAIKU
219TTF_Font *osd_font_unix::search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles)
220{
221    TTF_Font *font = (TTF_Font *)NULL;
222    FcConfig *config;
223    FcPattern *pat;
224    FcObjectSet *os;
225    FcFontSet *fontset;
226    FcValue val;
227
228    config = FcConfigGetCurrent();
229    pat = FcPatternCreate();
230    os = FcObjectSetCreate();
231    FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr());
232
233    // try and get a font with the requested styles baked-in
234    if (bold)
235    {
236        if (italic)
237        {
238            FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold Italic");
239        }
240        else
241        {
242            FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold");
243        }
244    }
245    else if (italic)
246    {
247        FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Italic");
248    }
249    else
250    {
251        FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular");
252    }
253
254    FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType");
255
256    FcObjectSetAdd(os, FC_FILE);
257    fontset = FcFontList(config, pat, os);
258
259    for (int i = 0; i < fontset->nfont; i++)
260    {
261        if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch)
262        {
263            continue;
264        }
265
266        if (val.type != FcTypeString)
267        {
268            continue;
269        }
270
271        osd_printf_verbose("Matching font: %s\n", val.u.s);
272        {
273            astring match_name((const char*)val.u.s);
274            font = TTF_OpenFont_Magic(match_name, POINT_SIZE);
275        }
276
277        if (font)
278        {
279            bakedstyles = true;
280            break;
281        }
282    }
283
284    // didn't get a font above?  try again with no baked-in styles
285    if (!font)
286    {
287        FcPatternDestroy(pat);
288        FcFontSetDestroy(fontset);
289
290        pat = FcPatternCreate();
291        FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr());
292        FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular");
293        FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType");
294        fontset = FcFontList(config, pat, os);
295
296        for (int i = 0; i < fontset->nfont; i++)
297        {
298            if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch)
299            {
300                continue;
301            }
302
303            if (val.type != FcTypeString)
304            {
305                continue;
306            }
307
308            osd_printf_verbose("Matching unstyled font: %s\n", val.u.s);
309            {
310                astring match_name((const char*)val.u.s);
311                font = TTF_OpenFont_Magic(match_name, POINT_SIZE);
312            }
313
314            if (font)
315            {
316                break;
317            }
318        }
319    }
320
321    FcPatternDestroy(pat);
322    FcObjectSetDestroy(os);
323    FcFontSetDestroy(fontset);
324    return font;
325}
326#endif
branches/kale/src/osd/modules/font/font_windows.c
r243932r243933
33 *
44 */
55
6#include "font_module.h"
7#include "modules/osdmodule.h"
8
9#if defined(OSD_WINDOWS) || defined(SDLMAME_WIN32)
10
116#define WIN32_LEAN_AND_MEAN
127#include <windows.h>
138#include <commctrl.h>
r243932r243933
1510#include <tchar.h>
1611#include <io.h>
1712
18#include "font_module.h"
19#include "modules/osdmodule.h"
13#include "osdepend.h"
2014
2115#include "strconv.h"
2216#include "astring.h"
r243932r243933
8478    HGDIOBJ m_font;
8579};
8680
81osd_font *osd_font_alloc()
82{
83    return global_alloc(osd_font_windows);
84}
85
8786bool osd_font_windows::open(const char *font_path, const char *_name, int &height)
8887{
8988    // accept qualifiers from the name
r243932r243933
299298    return bitmap.valid();
300299}
301300
302class font_win : public osd_module, public font_module
303{
304public:
305    font_win()
306    : osd_module(OSD_FONT_PROVIDER, "win"), font_module()
307    {
308    }
309
310    osd_font *font_alloc()
311    {
312        return global_alloc(osd_font_windows);
313    }
314
315};
316#else /* SDLMAME_UNIX */
317    MODULE_NOT_SUPPORTED(font_win, OSD_FONT_PROVIDER, "win")
318#endif
319
320MODULE_DEFINITION(FONT_WINDOWS, font_win)
branches/kale/src/osd/modules/lib/osdobj_common.c
r243932r243933
2020
2121const options_entry osd_options::s_option_entries[] =
2222{
23    { NULL,                                   NULL,       OPTION_HEADER,     "OSD FONT OPTIONS" },
24    { OSD_FONT_PROVIDER,                      "auto",     OPTION_STRING,     "provider for ui font: " },
25
2623    { NULL,                                   NULL,       OPTION_HEADER,     "OSD CLI OPTIONS" },
2724    { OSDCOMMAND_LIST_MIDI_DEVICES ";mlist",  "0",        OPTION_COMMAND,    "list available MIDI I/O devices" },
2825    { OSDCOMMAND_LIST_NETWORK_ADAPTERS ";nlist", "0",     OPTION_COMMAND,    "list available network adapters" },
r243932r243933
109106{
110107}
111108
112#define REGISTER_MODULE(_O, _X ) { extern const module_type _X; _O . register_module( _X ); }
113109
114110void osd_common_t::register_options()
115111{
116
117    REGISTER_MODULE(m_mod_man, FONT_OSX);
118    REGISTER_MODULE(m_mod_man, FONT_WINDOWS);
119    REGISTER_MODULE(m_mod_man, FONT_SDL);
120    REGISTER_MODULE(m_mod_man, FONT_NONE);
121
122    // after initialization we know which modules are supported
123
124    const char *names[20];
125    int num;
126    m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names);
127    dynamic_array<const char *> dnames;
128    for (int i = 0; i < num; i++)
129        dnames.append(names[i]);
130    update_option(OSD_FONT_PROVIDER, dnames);
131
132
133
134
135
136112    // Register video options and update options
137113    video_options_add("none", NULL);
138114    video_register();
r243932r243933
233209   if (options.verbose())
234210      g_print_verbose = true;
235211
236    m_font_module = select_module_options<font_module *>(options, OSD_FONT_PROVIDER);
237
238    m_mod_man.init();
239
240
241212   // ensure we get called on the way out
242213   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_common_t::osd_exit), this));
243214}
r243932r243933
568539
569540void osd_common_t::osd_exit()
570541{
571    m_mod_man.exit();
572
573    exit_subsystems();
542   exit_subsystems();
574543}
575544
576545void osd_common_t::video_options_add(const char *name, void *type)
branches/kale/src/osd/modules/lib/osdobj_common.h
r243932r243933
1414#define __OSDOBJ_COMMON__
1515
1616#include "osdepend.h"
17#include "modules/osdmodule.h"
18#include "modules/font/font_module.h"
1917#include "cliopts.h"
2018
2119//============================================================
r243932r243933
5755//  TYPE DEFINITIONS
5856//============================================================
5957
58/* FIXME: core_options inherits from osd_options. This will force any
59 * future osd implementation to use the options below. Actually, these
60 * options are *private* to the osd_core. This object should actually be an
61 * accessor object. Later ...
62 */
63
64/* FIXME: core_options inherits from osd_options. This will force any
65 * future osd implementation to use the options below. Actually, these
66 * options are *private* to the osd_core. This object should actually be an
67 * accessor object. Later ...
68 */
69
6070class osd_options : public cli_options
6171{
6272public:
r243932r243933
153163    // command option overrides
154164    virtual bool execute_command(const char *command);
155165
156    osd_font *font_alloc() { return m_font_module->font_alloc(); }
157
158166   // FIXME: everything below seems to be osd specific and not part of
159167   //        this INTERFACE but part of the osd IMPLEMENTATION
160168
r243932r243933
206214   running_machine *   m_machine;
207215   osd_options& m_options;
208216
209    osd_module_manager m_mod_man;
210    font_module *m_font_module;
211
212217   void update_option(const char * key, dynamic_array<const char *> &values);
213    // FIXME: should be elsewhere
214    osd_module *select_module_options(const core_options &opts, const astring &opt_name)
215    {
216        astring opt_val = opts.value(opt_name);
217        if (opt_val == "auto")
218            opt_val = "";
219        else if (!m_mod_man.type_has_name(opt_name, opt_val))
220        {
221            osd_printf_warning("Value %s not supported for option %s - falling back to auto\n", opt_val.cstr(), opt_name.cstr());
222            opt_val = "";
223        }
224        return m_mod_man.select_module(opt_name, opt_val);
225    }
226218
227    template<class C>
228    C select_module_options(const core_options &opts, const astring &opt_name)
229    {
230        return dynamic_cast<C>(select_module_options(opts, opt_name));
231    }
232
233219protected:
234220   osd_sound_interface* m_sound;
235221   osd_debugger_interface* m_debugger;
branches/kale/src/osd/modules/osdmodule.c
r243932r243933
1/*
2 * osdmodule.c
3 *
4 */
5
6#include "modules/osdmodule.h"
7
8osd_module_manager::osd_module_manager()
9{
10    for (int i=0; i<MAX_MODULES; i++)
11    {
12        m_modules[i]  = NULL;
13        m_selected[i] = NULL;
14    }
15}
16osd_module_manager::~osd_module_manager()
17{
18    for (int i = 0; m_modules[i] != NULL; i++)
19    {
20        m_modules[i]->~osd_module();
21        osd_free(m_modules[i]);
22    }
23}
24
25void osd_module_manager::register_module(const module_type &mod_type)
26{
27    osd_module *module = mod_type();
28    if (module->probe())
29    {
30        osd_printf_info("===> registered module %s %s\n", module->name(), module->type());
31
32        int i;
33        for (i = 0; m_modules[i] != NULL; i++)
34            ;
35        m_modules[i] = module;
36    }
37    else
38    {
39        osd_printf_info("===> not supported %s %s\n", module->name(), module->type());
40        module->~osd_module();
41        osd_free(module);
42    }
43}
44
45bool osd_module_manager::type_has_name(const char *type, const char *name)
46{
47    return (get_module_index(type, name) >= 0);
48}
49
50osd_module *osd_module_manager::get_module_generic(const char *type, const char *name)
51{
52    int i = get_module_index(type, name);
53    if (i>=0)
54        return m_modules[i];
55    else
56        return NULL;
57}
58
59osd_module *osd_module_manager::select_module(const char *type, const char *name)
60{
61    osd_module *m = get_module_generic(type, name);
62
63    // FIXME: check if already exists!
64    int i;
65    for (i = 0; m_selected[i] != NULL; i++)
66        ;
67    m_selected[i] = m;
68    return m;
69}
70
71void osd_module_manager::init()
72{
73    for (int i = 0; m_selected[i] != NULL; i++)
74    {
75        m_selected[i]->init();
76    }
77}
78
79void osd_module_manager::exit()
80{
81    // Find count
82    int cnt;
83    for (cnt = 0; m_selected[cnt] != NULL; cnt++)
84        ;
85    for (int i = cnt - 1; i >= 0; i--)
86    {
87        m_selected[i]->exit();
88        m_selected[i] = NULL;
89    }
90}
91
92int osd_module_manager::get_module_index(const char *type, const char *name)
93{
94    for (int i = 0; m_modules[i] != NULL; i++)
95    {
96        if (strcmp(m_modules[i]->type(), type) == 0 && ((name[0] == 0) || (strcmp(name, m_modules[i]->name())==0)))
97            return i;
98    }
99    return -1;
100}
101
102void osd_module_manager::get_module_names(const char *type, const int max, int *num, const char *names[])
103{
104    *num = 0;
105    for (int i = 0; m_modules[i] != NULL; i++)
106    {
107        if ((strcmp(m_modules[i]->type(), type) == 0) && (*num < max))
108        {
109            names[*num] = m_modules[i]->name();
110            *num = *num + 1;
111        }
112
113    }
114}
115
116
branches/kale/src/osd/modules/osdmodule.h
r243932r243933
1/***************************************************************************
2
3    osdmodule.h
4
5    OSD module manangement
6
7*******************************************************************c********/
8
9//#pragma once
10
11#ifndef __OSDMODULE_H__
12#define __OSDMODULE_H__
13
14#include "osdcore.h"
15#include "osdepend.h"
16
17//============================================================
18//  TYPE DEFINITIONS
19//============================================================
20
21class osd_module;
22
23// ======================> osd_module
24
25class osd_module
26{
27public:
28
29    osd_module(const char *type, const char *name)
30    : m_name(name), m_type(type)
31    {}
32    virtual ~osd_module() { }
33
34    const char * name() const { return m_name; }
35    const char * type() const { return m_type; }
36
37    virtual bool probe() const { return true; }
38
39    virtual void init() {  }
40    virtual void exit() {  }
41
42private:
43    astring     m_name;
44    astring     m_type;
45};
46
47// a module_type is simply a pointer to its alloc function
48typedef osd_module *(*module_type)();
49
50// this template function creates a stub which constructs a module
51template<class _ModuleClass>
52osd_module *module_creator()
53{
54    void *p = osd_malloc(sizeof(_ModuleClass));
55    return new(p) _ModuleClass;
56}
57
58class osd_module_manager
59{
60public:
61
62    static const int MAX_MODULES = 32;
63
64    osd_module_manager();
65    ~osd_module_manager();
66
67    void register_module(const module_type &mod_type);
68    bool type_has_name(const char *type, const char *name);
69
70    osd_module *get_module_generic(const char *type, const char *name);
71
72    template<class C>
73    C select_module(const char *type, const char *name = "")
74    {
75        return dynamic_cast<C>(select_module(type, name));
76    }
77
78    osd_module *select_module(const char *type, const char *name = "");
79
80    void get_module_names(const char *type, const int max, int *num, const char *names[]);
81
82    void init();
83
84    void exit();
85
86private:
87    int get_module_index(const char *type, const char *name);
88
89    osd_module *m_modules[MAX_MODULES];
90    osd_module *m_selected[MAX_MODULES];
91};
92
93#define MODULE_DEFINITION(_id, _class) \
94    extern const module_type _id ;  \
95    const module_type _id = &module_creator< _class >;
96
97
98#define MODULE_NOT_SUPPORTED(_mod, _type, _name) \
99    class _mod : public osd_module { \
100    public: \
101        _mod () \
102        : osd_module(_type, _name) {} \
103        bool probe() const { return false; } \
104    };
105
106#endif  /* __OSDMODULE_H__ */
branches/kale/src/osd/osdepend.h
r243932r243933
1818#include "unicode.h"
1919#include "cliopts.h"
2020
21
2221// forward references
2322class input_type_entry;     // FIXME: including emu.h does not work because emu.h includes osdepend.h
2423
r243932r243933
4140
4241// ======================> osd_interface
4342
43/* FIXME: this should be replaced by a proper module implementation
44 * For the time being only one font provider can be linked
45 */
46
47osd_font *osd_font_alloc();
48
4449// description of the currently-running machine
4550class osd_interface
4651{
r243932r243933
6671   virtual void *get_slider_list() = 0; // FIXME: returns slider_state *
6772
6873   // font interface
69   virtual osd_font *font_alloc() = 0;
7074
75   // font is allocated with global_alloc; therefore use global_free!
76   osd_font *font_alloc() { return osd_font_alloc(); }
77
7178   // command option overrides
7279   virtual bool execute_command(const char *command) = 0;
7380
branches/kale/src/osd/sdl/main.c
r243932r243933
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles
31//============================================================
42//
53//  main.c - Win32 main program
64//
5//  Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
6//  Visit http://mamedev.org for licensing and usage restrictions.
7//
8//  SDLMAME by Olivier Galibert and R. Belmont
9//
710//============================================================
811
912// standard windows headers
10#ifdef OSD_SDL
1113#define _WIN32_WINNT 0x0400
12#endif
1314#define WIN32_LEAN_AND_MEAN
1415#include <windows.h>
1516#include <tchar.h>
r243932r243933
3738   int i, rc;
3839   char **utf8_argv;
3940
40#ifdef OSD_SDL
4141#ifdef MALLOC_DEBUG
4242{
4343   extern int winalloc_in_main_code;
4444   winalloc_in_main_code = TRUE;
4545#endif
46#endif
4746
4847   /* convert arguments to UTF-8 */
4948   utf8_argv = (char **) malloc(argc * sizeof(*argv));
r243932r243933
6463      osd_free(utf8_argv[i]);
6564   free(utf8_argv);
6665
67#ifdef OSD_SDL
6866#ifdef MALLOC_DEBUG
6967   {
7068      void check_unfreed_mem(void);
r243932r243933
7371   winalloc_in_main_code = FALSE;
7472}
7573#endif
76#endif
7774
7875   return rc;
7976}
branches/kale/src/osd/sdl/osdsdl.h
r243932r243933
77#include "clifront.h"
88#include "modules/lib/osdobj_common.h"
99#include "video.h"
10#include "modules/osdmodule.h"
11#include "modules/font/font_module.h"
1210
1311//============================================================
1412//  System dependent defines
r243932r243933
222220   // FIXME: remove machine usage
223221   void extract_video_config(running_machine &machine);
224222
223
225224    sdl_options &m_options;
226225
227226   watchdog *m_watchdog;
branches/kale/src/osd/sdl/sdl.mak
r243932r243933
204204ifeq ($(TARGETOS),unix)
205205BASE_TARGETOS = unix
206206SYNC_IMPLEMENTATION = tc
207FONT_IMPLEMENTATION = sdl
207FONT_IMPLEMENTATION = unix
208208endif
209209
210210ifeq ($(TARGETOS),linux)
211211BASE_TARGETOS = unix
212212SYNC_IMPLEMENTATION = tc
213213SDL_NETWORK = taptun
214FONT_IMPLEMENTATION = sdl
214FONT_IMPLEMENTATION = unix
215215
216216ifndef NO_USE_MIDI
217217INCPATH += `pkg-config --cflags alsa`
r243932r243933
223223ifeq ($(TARGETOS),freebsd)
224224BASE_TARGETOS = unix
225225SYNC_IMPLEMENTATION = tc
226FONT_IMPLEMENTATION = sdl
226FONT_IMPLEMENTATION = unix
227227DEFS += -DNO_AFFINITY_NP
228228LIBS += -lutil
229229# /usr/local/include is not considered a system include directory
r243932r243933
235235ifeq ($(TARGETOS),openbsd)
236236BASE_TARGETOS = unix
237237SYNC_IMPLEMENTATION = ntc
238FONT_IMPLEMENTATION = sdl
238FONT_IMPLEMENTATION = unix
239239LIBS += -lutil
240240NO_USE_MIDI = 1
241241endif
r243932r243933
243243ifeq ($(TARGETOS),netbsd)
244244BASE_TARGETOS = unix
245245SYNC_IMPLEMENTATION = ntc
246FONT_IMPLEMENTATION = sdl
246FONT_IMPLEMENTATION = unix
247247LIBS += -lutil
248248NO_USE_MIDI = 1
249249endif
r243932r243933
252252BASE_TARGETOS = unix
253253DEFS += -DNO_AFFINITY_NP -UHAVE_VSNPRINTF -DNO_vsnprintf
254254SYNC_IMPLEMENTATION = tc
255FONT_IMPLEMENTATION = sdl
255FONT_IMPLEMENTATION = unix
256256NO_USE_MIDI = 1
257257endif
258258
259259ifeq ($(TARGETOS),haiku)
260260BASE_TARGETOS = unix
261261SYNC_IMPLEMENTATION = ntc
262FONT_IMPLEMENTATION = sdl
262FONT_IMPLEMENTATION = unix
263263NO_X11 = 1
264264NO_USE_XINPUT = 1
265265NO_USE_MIDI = 1
r243932r243933
430430   $(SDLOBJ)/sdlos_$(SDLOS_TARGETOS).o \
431431   $(OSDOBJ)/modules/lib/osdlib_$(SDLOS_TARGETOS).o \
432432   $(OSDOBJ)/modules/sync/sync_$(SYNC_IMPLEMENTATION).o \
433   $(OSDOBJ)/modules/osdmodule.o \
433   $(OSDOBJ)/modules/font/font_$(FONT_IMPLEMENTATION).o \
434434
435435ifdef NOASM
436436OSDCOREOBJS += $(OSDOBJ)/modules/sync/work_mini.o
r243932r243933
451451   $(SDLOBJ)/output.o \
452452   $(SDLOBJ)/watchdog.o \
453453   $(OSDOBJ)/modules/lib/osdobj_common.o  \
454   $(OSDOBJ)/modules/font/font_sdl.o \
455   $(OSDOBJ)/modules/font/font_windows.o \
456   $(OSDOBJ)/modules/font/font_osx.o \
457   $(OSDOBJ)/modules/font/font_none.o \
458454
459455ifdef NO_USE_MIDI
460456   OSDOBJS += $(OSDOBJ)/modules/midi/none.o
branches/kale/src/osd/sdl/sdlmain.c
r243932r243933
1212
1313#ifdef SDLMAME_UNIX
1414#if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_EMSCRIPTEN))
15#if (SDLMAME_SDL2)
16#include <SDL2/SDL_ttf.h>
17#else
18#include <SDL/SDL_ttf.h>
19#endif
1520#ifndef SDLMAME_HAIKU
1621#include <fontconfig/fontconfig.h>
1722#endif
r243932r243933
5661#include "input.h"
5762#include "osdsdl.h"
5863#include "modules/lib/osdlib.h"
59
6064#include "modules/sound/sdl_sound.h"
61
6265#if defined(SDLMAME_EMSCRIPTEN)
6366#include "modules/sound/js_sound.h"
6467#endif
r243932r243933
266269   set_default_value(SDLOPTION_INIPATH, ini_path.cstr());
267270}
268271
272
269273//============================================================
270274//  main
271275//============================================================
r243932r243933
297301   setvbuf(stdout, (char *) NULL, _IONBF, 0);
298302   setvbuf(stderr, (char *) NULL, _IONBF, 0);
299303
300   // FIXME: this should be done differently
301
304   //FIXME: move to font module
302305   #ifdef SDLMAME_UNIX
303306   sdl_entered_debugger = 0;
304307   #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN))
308   if (TTF_Init() == -1)
309   {
310      printf("SDL_ttf failed: %s\n", TTF_GetError());
311   }
305312   FcInit();
306313   #endif
307314   #endif
r243932r243933
348355   }
349356#endif
350357
358   // already called...
359   //SDL_Quit();
360
351361   #ifdef SDLMAME_UNIX
352362   #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN))
363   TTF_Quit();
353364   if (!sdl_entered_debugger)
354365   {
355366      FcFini();
r243932r243933
580591//  init
581592//============================================================
582593
583
584594void sdl_osd_interface::init(running_machine &machine)
585595{
586596   // call our parent
branches/kale/src/osd/sdl/strconv.h
r243932r243933
2222
2323#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
2424
25#if defined(SDLMAME_WIN32)
2625#define WIN32_LEAN_AND_MEAN
2726#include <windows.h>
28#endif
2927// the result of these functions has to be released with osd_free()
3028
3129CHAR *astring_from_utf8(const char *s);
branches/kale/src/osd/windows/main.c
r243932r243933
77//============================================================
88
99// standard windows headers
10#ifdef OSD_SDL
11#define _WIN32_WINNT 0x0400
12#endif
1310#define WIN32_LEAN_AND_MEAN
1411#include <windows.h>
1512#include <tchar.h>
r243932r243933
3734   int i, rc;
3835   char **utf8_argv;
3936
40#ifdef OSD_SDL
41#ifdef MALLOC_DEBUG
42{
43   extern int winalloc_in_main_code;
44   winalloc_in_main_code = TRUE;
45#endif
46#endif
47
4837   /* convert arguments to UTF-8 */
4938   utf8_argv = (char **) malloc(argc * sizeof(*argv));
5039   if (utf8_argv == NULL)
r243932r243933
6453      osd_free(utf8_argv[i]);
6554   free(utf8_argv);
6655
67#ifdef OSD_SDL
68#ifdef MALLOC_DEBUG
69   {
70      void check_unfreed_mem(void);
71      check_unfreed_mem();
72   }
73   winalloc_in_main_code = FALSE;
74}
75#endif
76#endif
77
7856   return rc;
7957}
branches/kale/src/osd/windows/netdev_pcap.h
r243932r243933
1#ifndef __NETDEV_PCAP_H__
2#define __NETDEV_PCAP_H__
1#ifndef __NETDEV_H
2#define __NETDEV_H
33
44void init_pcap();
55void deinit_pcap();
branches/kale/src/osd/windows/strconv.h
r243932r243933
2222
2323#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
2424
25#if defined(SDLMAME_WIN32)
26#define WIN32_LEAN_AND_MEAN
27#include <windows.h>
28#endif
2925// the result of these functions has to be released with osd_free()
3026
3127CHAR *astring_from_utf8(const char *s);
r243932r243933
4238#define utf8_from_tstring   utf8_from_astring
4339#endif // UNICODE
4440
45#if defined(SDLMAME_WIN32)
46#define _tcsncpy wcsncpy
47#endif
48
4941#endif //SDLMAME_WIN32
5042
5143
branches/kale/src/osd/windows/windows.mak
r243932r243933
358358   $(OSDOBJ)/modules/sync/work_osd.o \
359359   $(OSDOBJ)/modules/lib/osdlib_win32.o \
360360   $(OSDOBJ)/modules/font/font_windows.o \
361   $(OSDOBJ)/modules/osdmodule.o \
362361   $(WINOBJ)/winptty.o \
363362
364363
r243932r243933
382381   $(WINOBJ)/winmain.o \
383382   $(OSDOBJ)/modules/midi/portmidi.o \
384383   $(OSDOBJ)/modules/lib/osdobj_common.o  \
385   $(OSDOBJ)/modules/font/font_sdl.o \
386   $(OSDOBJ)/modules/font/font_windows.o \
387   $(OSDOBJ)/modules/font/font_osx.o \
388   $(OSDOBJ)/modules/font/font_none.o \
389384
390385ifdef USE_SDL
391386OSDOBJS += \


Previous 199869 Revisions Next


© 1997-2024 The MAME Team