Previous 199869 Revisions Next

r21001 Tuesday 12th February, 2013 at 20:59:59 UTC by Wilbert Pol
(MESS) gp32.c: Reduce tagmap lookups (nw)
[src/mess/drivers]gp32.c
[src/mess/includes]gp32.h

trunk/src/mess/includes/gp32.h
r21000r21001
11#ifndef _GP32_H_
22#define _GP32_H_
33
4#include "machine/smartmed.h"
5#include "sound/dac.h"
6#include "machine/nvram.h"
7
8
49#define INT_ADC       31
510#define INT_RTC       30
611#define INT_UTXD1     29
r21000r21001
8994      : driver_device(mconfig, type, tag)
9095      , m_s3c240x_ram(*this, "s3c240x_ram")
9196      , m_maincpu(*this, "maincpu")
97      , m_smartmedia(*this, "smartmedia")
98      , m_dac1(*this, "dac1")
99      , m_dac2(*this, "dac2")
100      , m_nvram(*this, "nvram")
101      , m_io_in0(*this, "IN0")
102      , m_io_in1(*this, "IN1")
92103   { }
93104
94105   virtual void video_start();
r21000r21001
174185
175186protected:
176187   required_device<cpu_device> m_maincpu;
188   required_device<smartmedia_image_device> m_smartmedia;
189   required_device<dac_device> m_dac1;
190   required_device<dac_device> m_dac2;
191   required_device<nvram_device> m_nvram;
192   required_ioport m_io_in0;
193   required_ioport m_io_in1;
177194
178195   UINT32 s3c240x_get_fclk(int reg);
179196   UINT32 s3c240x_get_hclk(int reg);
r21000r21001
199216   void s3c240x_iis_start();
200217   void s3c240x_iis_stop();
201218   void s3c240x_iis_recalc();
219   void smc_reset();
220   void smc_init();
221   UINT8 smc_read();
222   void smc_write(UINT8 data);
223   void smc_update();
224   void i2s_reset();
225   void i2s_init();
226   void i2s_write(int line, int data);
227   UINT8 eeprom_read(UINT16 address);
228   void eeprom_write(UINT16 address, UINT8 data);
229   void iic_start();
230   void iic_stop();
231   void iic_resume();
232   void s3c240x_machine_start();
233   void s3c240x_machine_reset();
202234};
203235
204236
trunk/src/mess/drivers/gp32.c
r21000r21001
1717#include "emu.h"
1818#include "cpu/arm7/arm7.h"
1919#include "cpu/arm7/arm7core.h"
20#include "machine/smartmed.h"
2120#include "includes/gp32.h"
22#include "sound/dac.h"
2321#include "rendlay.h"
24#include "machine/nvram.h"
2522
2623#define VERBOSE_LEVEL ( 0 )
2724
r21000r21001
892889
893890// SMARTMEDIA
894891
895static void smc_reset( running_machine &machine)
892void gp32_state::smc_reset()
896893{
897   gp32_state *state = machine.driver_data<gp32_state>();
898   verboselog( machine, 5, "smc_reset\n");
899   state->m_smc.add_latch = 0;
900   state->m_smc.chip = 0;
901   state->m_smc.cmd_latch = 0;
902   state->m_smc.do_read = 0;
903   state->m_smc.do_write = 0;
904   state->m_smc.read = 0;
905   state->m_smc.wp = 0;
906   state->m_smc.busy = 0;
894   verboselog( machine(), 5, "smc_reset\n");
895   m_smc.add_latch = 0;
896   m_smc.chip = 0;
897   m_smc.cmd_latch = 0;
898   m_smc.do_read = 0;
899   m_smc.do_write = 0;
900   m_smc.read = 0;
901   m_smc.wp = 0;
902   m_smc.busy = 0;
907903}
908904
909static void smc_init( running_machine &machine)
905void gp32_state::smc_init()
910906{
911   verboselog( machine, 5, "smc_init\n");
912   smc_reset( machine);
907   verboselog( machine(), 5, "smc_init\n");
908   smc_reset();
913909}
914910
915static UINT8 smc_read( running_machine &machine)
911UINT8 gp32_state::smc_read()
916912{
917   smartmedia_image_device *smartmedia = machine.device<smartmedia_image_device>( "smartmedia");
918913   UINT8 data;
919   data = smartmedia->data_r();
920   verboselog( machine, 5, "smc_read %08X\n", data);
914   data = m_smartmedia->data_r();
915   verboselog( machine(), 5, "smc_read %08X\n", data);
921916   return data;
922917}
923918
924static void smc_write( running_machine &machine, UINT8 data)
919void gp32_state::smc_write(UINT8 data)
925920{
926   gp32_state *state = machine.driver_data<gp32_state>();
927   verboselog( machine, 5, "smc_write %08X\n", data);
928   if ((state->m_smc.chip) && (!state->m_smc.read))
921   verboselog( machine(), 5, "smc_write %08X\n", data);
922   if ((m_smc.chip) && (!m_smc.read))
929923   {
930      smartmedia_image_device *smartmedia = machine.device<smartmedia_image_device>( "smartmedia");
931      if (state->m_smc.cmd_latch)
924      if (m_smc.cmd_latch)
932925      {
933         verboselog( machine, 5, "smartmedia_command_w %08X\n", data);
934         smartmedia->command_w(data);
926         verboselog( machine(), 5, "smartmedia_command_w %08X\n", data);
927         m_smartmedia->command_w(data);
935928      }
936      else if (state->m_smc.add_latch)
929      else if (m_smc.add_latch)
937930      {
938         verboselog( machine, 5, "smartmedia_address_w %08X\n", data);
939         smartmedia->address_w(data);
931         verboselog( machine(), 5, "smartmedia_address_w %08X\n", data);
932         m_smartmedia->address_w(data);
940933      }
941934      else
942935      {
943         verboselog( machine, 5, "smartmedia_data_w %08X\n", data);
944         smartmedia->data_w(data);
936         verboselog( machine(), 5, "smartmedia_data_w %08X\n", data);
937         m_smartmedia->data_w(data);
945938      }
946939   }
947940}
948941
949static void smc_update( running_machine &machine)
942void gp32_state::smc_update()
950943{
951   gp32_state *state = machine.driver_data<gp32_state>();
952   if (!state->m_smc.chip)
944   if (!m_smc.chip)
953945   {
954      smc_reset( machine);
946      smc_reset();
955947   }
956948   else
957949   {
958      if ((state->m_smc.do_write) && (!state->m_smc.read))
950      if ((m_smc.do_write) && (!m_smc.read))
959951      {
960         smc_write( machine, state->m_smc.datatx);
952         smc_write(m_smc.datatx);
961953      }
962      else if ((!state->m_smc.do_write) && (state->m_smc.do_read) && (state->m_smc.read) && (!state->m_smc.cmd_latch) && (!state->m_smc.add_latch))
954      else if ((!m_smc.do_write) && (m_smc.do_read) && (m_smc.read) && (!m_smc.cmd_latch) && (!m_smc.add_latch))
963955      {
964         state->m_smc.datarx = smc_read( machine);
956         m_smc.datarx = smc_read();
965957      }
966958   }
967959}
r21000r21001
972964#define I2S_L3M ( 2 )
973965#define I2S_L3D ( 3 )
974966
975static void i2s_reset( running_machine &machine)
967void gp32_state::i2s_reset()
976968{
977   gp32_state *state = machine.driver_data<gp32_state>();
978   verboselog( machine, 5, "i2s_reset\n");
979   state->m_i2s.l3d = 0;
980   state->m_i2s.l3m = 0;
981   state->m_i2s.l3c = 0;
969   verboselog( machine(), 5, "i2s_reset\n");
970   m_i2s.l3d = 0;
971   m_i2s.l3m = 0;
972   m_i2s.l3c = 0;
982973}
983974
984static void i2s_init( running_machine &machine)
975void gp32_state::i2s_init()
985976{
986   verboselog( machine, 5, "i2s_init\n");
987   i2s_reset( machine);
977   verboselog( machine(), 5, "i2s_init\n");
978   i2s_reset();
988979}
989980
990static void i2s_write( running_machine &machine, int line, int data)
981void gp32_state::i2s_write(int line, int data)
991982{
992   gp32_state *state = machine.driver_data<gp32_state>();
993983   switch (line)
994984   {
995985      case I2S_L3C :
996986      {
997         if (data != state->m_i2s.l3c)
987         if (data != m_i2s.l3c)
998988         {
999            verboselog( machine, 5, "I2S L3C %d\n", data);
1000            state->m_i2s.l3c = data;
989            verboselog( machine(), 5, "I2S L3C %d\n", data);
990            m_i2s.l3c = data;
1001991         }
1002992      }
1003993      break;
1004994      case I2S_L3M :
1005995      {
1006         if (data != state->m_i2s.l3m)
996         if (data != m_i2s.l3m)
1007997         {
1008            verboselog( machine, 5, "I2S L3M %d\n", data);
1009            state->m_i2s.l3m = data;
998            verboselog( machine(), 5, "I2S L3M %d\n", data);
999            m_i2s.l3m = data;
10101000         }
10111001      }
10121002      break;
10131003      case I2S_L3D :
10141004      {
1015         if (data != state->m_i2s.l3d)
1005         if (data != m_i2s.l3d)
10161006         {
1017            verboselog( machine, 5, "I2S L3D %d\n", data);
1018            state->m_i2s.l3d = data;
1007            verboselog( machine(), 5, "I2S L3D %d\n", data);
1008            m_i2s.l3d = data;
10191009         }
10201010      }
10211011      break;
r21000r21001
10441034         // smartmedia
10451035         data = (data & ~0x000000FF) | (m_smc.datarx & 0xFF);
10461036         // buttons
1047         data = (data & ~0x0000FF00) | (ioport( "IN0")->read() & 0x0000FF00);
1037         data = (data & ~0x0000FF00) | (m_io_in0->read() & 0x0000FF00);
10481038      }
10491039      break;
10501040      // PDDAT
10511041      case 0x24 / 4 :
10521042      {
1053         smartmedia_image_device *smartmedia = machine().device<smartmedia_image_device>( "smartmedia");
10541043         // smartmedia
10551044         data = (data & ~0x000003C0);
10561045         if (!m_smc.busy) data = data | 0x00000200;
10571046         if (!m_smc.do_read) data = data | 0x00000100;
10581047         if (!m_smc.chip) data = data | 0x00000080;
1059         if (!smartmedia->is_protected()) data = data | 0x00000040;
1048         if (!m_smartmedia->is_protected()) data = data | 0x00000040;
10601049      }
10611050      break;
10621051      // PEDAT
10631052      case 0x30 / 4 :
10641053      {
1065         smartmedia_image_device *smartmedia = machine().device<smartmedia_image_device>( "smartmedia");
10661054         // smartmedia
10671055         data = (data & ~0x0000003C);
10681056         if (m_smc.cmd_latch) data = data | 0x00000020;
10691057         if (m_smc.add_latch) data = data | 0x00000010;
10701058         if (!m_smc.do_write) data = data | 0x00000008;
1071         if (!smartmedia->is_present()) data = data | 0x00000004;
1059         if (!m_smartmedia->is_present()) data = data | 0x00000004;
10721060         // buttons
1073         data = (data & ~0x000000C0) | (ioport( "IN1")->read() & 0x000000C0);
1061         data = (data & ~0x000000C0) | (m_io_in1->read() & 0x000000C0);
10741062      }
10751063      break;
10761064   }
r21000r21001
10891077      {
10901078         // smartmedia
10911079         m_smc.read = ((data & 0x00000001) == 0);
1092         smc_update( machine());
1080         smc_update();
10931081      }
10941082      break;
10951083      // PBDAT
r21000r21001
11061094         m_smc.do_read = ((data & 0x00000100) == 0);
11071095         m_smc.chip = ((data & 0x00000080) == 0);
11081096         m_smc.wp = ((data & 0x00000040) == 0);
1109         smc_update( machine());
1097         smc_update();
11101098      }
11111099      break;
11121100      // PEDAT
r21000r21001
11161104         m_smc.cmd_latch = ((data & 0x00000020) != 0);
11171105         m_smc.add_latch = ((data & 0x00000010) != 0);
11181106         m_smc.do_write = ((data & 0x00000008) == 0);
1119         smc_update( machine());
1107         smc_update();
11201108         // sound
1121         i2s_write( machine(), I2S_L3D, (data & 0x00000800) ? 1 : 0);
1122         i2s_write( machine(), I2S_L3M, (data & 0x00000400) ? 1 : 0);
1123         i2s_write( machine(), I2S_L3C, (data & 0x00000200) ? 1 : 0);
1109         i2s_write(I2S_L3D, (data & 0x00000800) ? 1 : 0);
1110         i2s_write(I2S_L3M, (data & 0x00000400) ? 1 : 0);
1111         i2s_write(I2S_L3C, (data & 0x00000200) ? 1 : 0);
11241112      }
11251113      break;
11261114#if 0
r21000r21001
12511239
12521240// EEPROM
12531241
1254static UINT8 eeprom_read( running_machine &machine, UINT16 address)
1242UINT8 gp32_state::eeprom_read(UINT16 address)
12551243{
1256   gp32_state *state = machine.driver_data<gp32_state>();
12571244   UINT8 data;
1258   data = state->m_eeprom_data[address];
1259   verboselog( machine, 5, "EEPROM %04X -> %02X\n", address, data);
1245   data = m_eeprom_data[address];
1246   verboselog( machine(), 5, "EEPROM %04X -> %02X\n", address, data);
12601247   return data;
12611248}
12621249
1263static void eeprom_write( running_machine &machine, UINT16 address, UINT8 data)
1250void gp32_state::eeprom_write(UINT16 address, UINT8 data)
12641251{
1265   gp32_state *state = machine.driver_data<gp32_state>();
1266   verboselog( machine, 5, "EEPROM %04X <- %02X\n", address, data);
1267   state->m_eeprom_data[address] = data;
1252   verboselog( machine(), 5, "EEPROM %04X <- %02X\n", address, data);
1253   m_eeprom_data[address] = data;
12681254}
12691255
12701256// IIC
r21000r21001
13251311}
13261312#endif
13271313
1328static void iic_start( running_machine &machine)
1314void gp32_state::iic_start()
13291315{
1330   gp32_state *state = machine.driver_data<gp32_state>();
1331   verboselog( machine, 1, "IIC start\n");
1332   state->m_s3c240x_iic.data_index = 0;
1333   state->m_s3c240x_iic_timer->adjust( attotime::from_msec( 1));
1316   verboselog( machine(), 1, "IIC start\n");
1317   m_s3c240x_iic.data_index = 0;
1318   m_s3c240x_iic_timer->adjust( attotime::from_msec( 1));
13341319}
13351320
1336static void iic_stop( running_machine &machine)
1321void gp32_state::iic_stop()
13371322{
1338   gp32_state *state = machine.driver_data<gp32_state>();
1339   verboselog( machine, 1, "IIC stop\n");
1340   state->m_s3c240x_iic_timer->adjust( attotime::never);
1323   verboselog( machine(), 1, "IIC stop\n");
1324   m_s3c240x_iic_timer->adjust( attotime::never);
13411325}
13421326
1343static void iic_resume( running_machine &machine)
1327void gp32_state::iic_resume()
13441328{
1345   gp32_state *state = machine.driver_data<gp32_state>();
1346   verboselog( machine, 1, "IIC resume\n");
1347   state->m_s3c240x_iic_timer->adjust( attotime::from_msec( 1));
1329   verboselog( machine(), 1, "IIC resume\n");
1330   m_s3c240x_iic_timer->adjust( attotime::from_msec( 1));
13481331}
13491332
13501333READ32_MEMBER(gp32_state::s3c240x_iic_r)
r21000r21001
13891372            start_stop_condition = BIT( m_s3c240x_iic_regs[1], 5);
13901373            if (start_stop_condition != 0)
13911374            {
1392               iic_resume( machine());
1375               iic_resume();
13931376            }
13941377         }
13951378      }
r21000r21001
14011384         start_stop_condition = BIT( data, 5);
14021385         if (start_stop_condition != 0)
14031386         {
1404            iic_start( machine());
1387            iic_start();
14051388         }
14061389         else
14071390         {
1408            iic_stop( machine());
1391            iic_stop();
14091392         }
14101393      }
14111394      break;
r21000r21001
14291412         }
14301413         else
14311414         {
1432            UINT8 data_shift = eeprom_read( machine(), m_s3c240x_iic.address);
1415            UINT8 data_shift = eeprom_read(m_s3c240x_iic.address);
14331416            verboselog( machine(), 5, "IIC read %02X\n", data_shift);
14341417            m_s3c240x_iic_regs[3] = (m_s3c240x_iic_regs[3] & ~0xFF) | data_shift;
14351418         }
r21000r21001
14481431         }
14491432         if ((m_s3c240x_iic.data_index == 4) && (m_s3c240x_iic.data[0] == 0xA0))
14501433         {
1451            eeprom_write( machine(), m_s3c240x_iic.address, data_shift);
1434            eeprom_write(m_s3c240x_iic.address, data_shift);
14521435         }
14531436      }
14541437      break;
r21000r21001
15391522         }
15401523         if (m_s3c240x_iis.fifo_index == 2)
15411524         {
1542            dac_device *dac[2];
1543            dac[0] = machine().device<dac_device>("dac1");
1544            dac[1] = machine().device<dac_device>("dac2");
15451525            m_s3c240x_iis.fifo_index = 0;
1546            dac[0]->write_signed16(m_s3c240x_iis.fifo[0] + 0x8000);
1547            dac[1]->write_signed16(m_s3c240x_iis.fifo[1] + 0x8000);
1526            m_dac1->write_signed16(m_s3c240x_iis.fifo[0] + 0x8000);
1527            m_dac2->write_signed16(m_s3c240x_iis.fifo[1] + 0x8000);
15481528         }
15491529      }
15501530      break;
r21000r21001
16231603
16241604// ...
16251605
1626static void s3c240x_machine_start( running_machine &machine)
1606void gp32_state::s3c240x_machine_start()
16271607{
1628   gp32_state *state = machine.driver_data<gp32_state>();
1629   state->m_s3c240x_pwm_timer[0] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),state), (void *)(FPTR)0);
1630   state->m_s3c240x_pwm_timer[1] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),state), (void *)(FPTR)1);
1631   state->m_s3c240x_pwm_timer[2] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),state), (void *)(FPTR)2);
1632   state->m_s3c240x_pwm_timer[3] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),state), (void *)(FPTR)3);
1633   state->m_s3c240x_pwm_timer[4] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),state), (void *)(FPTR)4);
1634   state->m_s3c240x_dma_timer[0] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),state), (void *)(FPTR)0);
1635   state->m_s3c240x_dma_timer[1] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),state), (void *)(FPTR)1);
1636   state->m_s3c240x_dma_timer[2] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),state), (void *)(FPTR)2);
1637   state->m_s3c240x_dma_timer[3] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),state), (void *)(FPTR)3);
1638   state->m_s3c240x_iic_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_iic_timer_exp),state), (void *)(FPTR)0);
1639   state->m_s3c240x_iis_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_iis_timer_exp),state), (void *)(FPTR)0);
1640   state->m_s3c240x_lcd_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_lcd_timer_exp),state), (void *)(FPTR)0);
1641   state->m_eeprom_data = auto_alloc_array( machine, UINT8, 0x2000);
1642   machine.device<nvram_device>("nvram")->set_base(state->m_eeprom_data, 0x2000);
1643   smc_init( machine);
1644   i2s_init( machine);
1608   m_s3c240x_pwm_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),this), (void *)(FPTR)0);
1609   m_s3c240x_pwm_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),this), (void *)(FPTR)1);
1610   m_s3c240x_pwm_timer[2] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),this), (void *)(FPTR)2);
1611   m_s3c240x_pwm_timer[3] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),this), (void *)(FPTR)3);
1612   m_s3c240x_pwm_timer[4] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),this), (void *)(FPTR)4);
1613   m_s3c240x_dma_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),this), (void *)(FPTR)0);
1614   m_s3c240x_dma_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),this), (void *)(FPTR)1);
1615   m_s3c240x_dma_timer[2] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),this), (void *)(FPTR)2);
1616   m_s3c240x_dma_timer[3] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),this), (void *)(FPTR)3);
1617   m_s3c240x_iic_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_iic_timer_exp),this), (void *)(FPTR)0);
1618   m_s3c240x_iis_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_iis_timer_exp),this), (void *)(FPTR)0);
1619   m_s3c240x_lcd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_lcd_timer_exp),this), (void *)(FPTR)0);
1620   m_eeprom_data = auto_alloc_array( machine(), UINT8, 0x2000);
1621   m_nvram->set_base(m_eeprom_data, 0x2000);
1622   smc_init();
1623   i2s_init();
16451624}
16461625
1647static void s3c240x_machine_reset( running_machine &machine)
1626void gp32_state::s3c240x_machine_reset()
16481627{
1649   gp32_state *state = machine.driver_data<gp32_state>();
1650   smc_reset( machine);
1651   i2s_reset( machine);
1652   state->m_s3c240x_iis.fifo_index = 0;
1653   state->m_s3c240x_iic.data_index = 0;
1628   smc_reset();
1629   i2s_reset();
1630   m_s3c240x_iis.fifo_index = 0;
1631   m_s3c240x_iic.data_index = 0;
16541632}
16551633
16561634static ADDRESS_MAP_START( gp32_map, AS_PROGRAM, 32, gp32_state )
r21000r21001
16941672
16951673void gp32_state::machine_start()
16961674{
1697   s3c240x_machine_start(machine());
1675   s3c240x_machine_start();
16981676}
16991677
17001678void gp32_state::machine_reset()
17011679{
1702   s3c240x_machine_reset(machine());
1680   s3c240x_machine_reset();
17031681}
17041682
17051683static MACHINE_CONFIG_START( gp32, gp32_state )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team