Previous 199869 Revisions Next

r17567 Wednesday 29th August, 2012 at 19:24:36 UTC by Angelo Salese
Some changes, MB90082 != MB90092
[src/emu]emu.mak
[src/emu/cpu/z180]z180.c
[src/emu/video]mb90082.c* mb90082.h* mb90092.c mb90092.h
[src/mame/drivers]sfcbox.c

trunk/src/mame/drivers/sfcbox.c
r17566r17567
119119#include "cpu/g65816/g65816.h"
120120#include "cpu/z180/z180.h"
121121#include "machine/s3520cf.h"
122#include "video/mb90092.h"
122#include "video/mb90082.h"
123123#include "includes/snes.h"
124124#include "audio/snes_snd.h"
125125#include "rendlay.h"
r17566r17567
130130   sfcbox_state(const machine_config &mconfig, device_type type, const char *tag)
131131      : snes_state(mconfig, type, tag),
132132      m_bios(*this, "bios"),
133      m_mb90092(*this,"mb90092"),
133      m_mb90082(*this,"mb90082"),
134134      m_s3520cf(*this, "s3520cf")
135135      { }
136136
137137   required_device<cpu_device> m_bios;
138   required_device<mb90092_device> m_mb90092;
138   required_device<mb90082_device> m_mb90082;
139139   required_device<s3520cf_device> m_s3520cf;
140140
141141   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
r17566r17567
151151
152152UINT32 sfcbox_state::screen_update( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect )
153153{
154   m_mb90092->screen_update(screen,bitmap,cliprect);
154   m_mb90082->screen_update(screen,bitmap,cliprect);
155155   return 0;
156156}
157157
r17566r17567
280280}
281281
282282static ADDRESS_MAP_START( sfcbox_io, AS_IO, 8, sfcbox_state )
283   AM_RANGE(0x0b, 0x0b) AM_DEVWRITE("mb90092",mb90092_device,write)
283   AM_RANGE(0x0b, 0x0b) AM_DEVWRITE("mb90082",mb90082_device,write)
284284   AM_RANGE(0x00, 0x3f) AM_RAM // internal i/o
285285   AM_RANGE(0x80, 0x80) AM_READ_PORT("KEY") AM_WRITE(port_80_w) // Keyswitch and Button Inputs / SNES Transfer and Misc Output
286286   AM_RANGE(0x81, 0x81) AM_READWRITE(port_81_r,port_81_w) // SNES Transfer and Misc Input / Misc Output
r17566r17567
318318   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON8 )  PORT_NAME("Play Mode 1 Button")
319319
320320   PORT_START("OSD_CS")
321   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("mb90092", mb90092_device, set_cs_line)
321   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("mb90082", mb90082_device, set_cs_line)
322322
323323   PORT_START("SERIAL1_DATA1_L")
324324   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button A") PORT_PLAYER(1)
r17566r17567
489489   MCFG_CPU_PROGRAM_MAP(sfcbox_map)
490490   MCFG_CPU_IO_MAP(sfcbox_io)
491491
492   MCFG_MB90092_ADD("mb90092",XTAL_12MHz / 2) /* TODO: correct clock */
492   MCFG_MB90082_ADD("mb90082",XTAL_12MHz / 2) /* TODO: correct clock */
493493   MCFG_S3520CF_ADD("s3520cf") /* RTC */
494494
495495   MCFG_MACHINE_START( sfcbox )
trunk/src/emu/cpu/z180/z180.c
r17566r17567
903903   case Z180_CNTR:
904904      data = cpustate->IO_CNTR & Z180_CNTR_RMASK;
905905      data &= ~0x10; // Super Famicom Box sets the TE bit then wants it to be toggled after 8 bits transmitted
906      logerror("Z180 '%s' CNTR   rd $%02x ($%02x)\n", cpustate->device->tag(), data, cpustate->io[port & 0x3f]);
906      LOG(("Z180 '%s' CNTR   rd $%02x ($%02x)\n", cpustate->device->tag(), data, cpustate->io[port & 0x3f]));
907907      break;
908908
909909   case Z180_TRDR:
trunk/src/emu/video/mb90092.c
r17566r17567
1/***************************************************************************
2
3   Fujitsu MB90092 OSD
4
5   preliminary device by Angelo Salese
6
7   TODO:
8   - get a real charset ROM;
9
10***************************************************************************/
11
12#include "emu.h"
13#include "video/mb90092.h"
14
15
16
17//**************************************************************************
18//  GLOBAL VARIABLES
19//**************************************************************************
20
21// device type definition
22const device_type MB90092 = &device_creator<mb90092_device>;
23
24static ADDRESS_MAP_START( mb90092_vram, AS_0, 16, mb90092_device )
25   AM_RANGE(0x0000, 0x023f) AM_RAM // vram
26ADDRESS_MAP_END
27
28/* charset is undumped, but apparently a normal ASCII one is enough for the time being (for example "fnt0808.x1" in Sharp X1) */
29ROM_START( mb90092 )
30   ROM_REGION( 0x0800, "mb90092", 0 )
31   ROM_LOAD("mb90092_char.bin",     0x0000, 0x0800, NO_DUMP )
32ROM_END
33
34//-------------------------------------------------
35//  rom_region - device-specific ROM region
36//-------------------------------------------------
37
38const rom_entry *mb90092_device::device_rom_region() const
39{
40   return ROM_NAME( mb90092 );
41}
42
43//-------------------------------------------------
44//  memory_space_config - return a description of
45//  any address spaces owned by this device
46//-------------------------------------------------
47
48const address_space_config *mb90092_device::memory_space_config(address_spacenum spacenum) const
49{
50   return (spacenum == AS_0) ? &m_space_config : NULL;
51}
52
53//**************************************************************************
54//  INLINE HELPERS
55//**************************************************************************
56
57//-------------------------------------------------
58//  readbyte - read a byte at the given address
59//-------------------------------------------------
60
61inline UINT16 mb90092_device::read_word(offs_t address)
62{
63   return space()->read_word(address << 1);
64}
65
66//-------------------------------------------------
67//  writebyte - write a byte at the given address
68//-------------------------------------------------
69
70inline void mb90092_device::write_word(offs_t address, UINT16 data)
71{
72   space()->write_word(address << 1, data);
73}
74
75//**************************************************************************
76//  LIVE DEVICE
77//**************************************************************************
78
79//-------------------------------------------------
80//  mb90092_device - constructor
81//-------------------------------------------------
82
83mb90092_device::mb90092_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
84   : device_t(mconfig, MB90092, "mb90092", tag, owner, clock),
85     device_memory_interface(mconfig, *this),
86     m_space_config("videoram", ENDIANNESS_LITTLE, 16, 16, 0, NULL, *ADDRESS_MAP_NAME(mb90092_vram))
87{
88   m_shortname = "mb90092";
89
90}
91
92
93//-------------------------------------------------
94//  device_validity_check - perform validity checks
95//  on this device
96//-------------------------------------------------
97
98void mb90092_device::device_validity_check(validity_checker &valid) const
99{
100}
101
102
103//-------------------------------------------------
104//  device_start - device-specific startup
105//-------------------------------------------------
106
107void mb90092_device::device_start()
108{
109
110}
111
112
113//-------------------------------------------------
114//  device_reset - device-specific reset
115//-------------------------------------------------
116
117void mb90092_device::device_reset()
118{
119   int i;
120   m_cmd_ff = 0;
121
122   for(i=0;i<0x120;i++)
123      write_word(i,0x00ff);
124}
125
126
127//**************************************************************************
128//  READ/WRITE HANDLERS
129//**************************************************************************
130
131WRITE_LINE_MEMBER( mb90092_device::set_cs_line )
132{
133   m_reset_line = state;
134
135   if(m_reset_line != CLEAR_LINE)
136   {
137      // ...
138   }
139}
140
141
142WRITE8_MEMBER( mb90092_device::write )
143{
144   UINT16 dat;
145
146   switch(m_cmd_ff)
147   {
148      case OSD_COMMAND:
149         m_cmd = data & 0xf8;
150         m_cmd_param = data & 7;
151         //printf("cmd %02x\n",data);
152         break;
153      case OSD_DATA:
154         dat = ((m_cmd_param & 7)<<7) | (data & 0x7f);
155         switch(m_cmd)
156         {
157            case 0x80: // Preset VRAM address
158               m_osd_addr = dat & 0x1ff;
159               //m_vsl = (dat & 0x200) >> 9);
160               break;
161            case 0x88: //
162               break;
163            case 0x90: // Write Character
164               int x,y;
165               x = (m_osd_addr & 0x01f);
166               y = (m_osd_addr & 0x1e0) >> 5;
167               //printf("%d %d\n",x,y);
168               write_word(x+y*24,dat);
169
170               /* handle address increments */
171               x = ((x + 1) % 24);
172               if(x == 0)
173                  y = ((y + 1) % 12);
174               m_osd_addr = x + (y << 5);
175
176               break;
177
178         }
179         break;
180   }
181
182   m_cmd_ff ^= 1;
183}
184
185UINT32 mb90092_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
186{
187   int x,y;
188   UINT8 *pcg = memregion("mb90092")->base();
189   UINT16 tile;
190
191   for(y=0;y<12;y++)
192   {
193      for(x=0;x<24;x++)
194      {
195         int xi,yi;
196
197         tile = read_word(x+y*24);
198
199         /* TODO: charset hook-up is obviously WRONG so following mustn't be trusted at all */
200         for(yi=0;yi<16;yi++)
201         {
202            for(xi=0;xi<16;xi++)
203            {
204               UINT8 pix;
205               UINT32 pen;
206
207               pix = (pcg[(tile*8)+(yi >> 1)] >> (7-(xi >> 1))) & 1;
208
209               pen = pix ? 0xffffff : 0;
210               if(tile == 0xff)
211                  pen = 0;
212
213               bitmap.pix32(y*16+yi,x*16+xi) = pen;
214            }
215         }
216      }
217   }
218
219   return 0;
220}
trunk/src/emu/video/mb90092.h
r17566r17567
1/***************************************************************************
2
3Template for skeleton device
4
5***************************************************************************/
6
7#pragma once
8
9#ifndef __MB90092DEV_H__
10#define __MB90092DEV_H__
11
12
13
14//**************************************************************************
15//  INTERFACE CONFIGURATION MACROS
16//**************************************************************************
17
18#define MCFG_MB90092_ADD(_tag,_freq) \
19   MCFG_DEVICE_ADD(_tag, MB90092, _freq) \
20
21
22//**************************************************************************
23//  TYPE DEFINITIONS
24//**************************************************************************
25
26enum
27{
28   OSD_COMMAND = 0,
29   OSD_DATA
30};
31
32
33// ======================> mb90092_device
34
35class mb90092_device :   public device_t,
36                  public device_memory_interface
37{
38public:
39   // construction/destruction
40   mb90092_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
41
42   // I/O operations
43   DECLARE_WRITE8_MEMBER( write );
44   WRITE_LINE_MEMBER( set_cs_line );
45
46   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
47   virtual const rom_entry *device_rom_region() const;
48
49protected:
50   // device-level overrides
51   virtual void device_validity_check(validity_checker &valid) const;
52   virtual void device_start();
53   virtual void device_reset();
54   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
55
56private:
57   UINT8 m_cmd_ff;
58   UINT8 m_cmd,m_cmd_param;
59   UINT16 m_osd_addr;
60   UINT8 m_reset_line;
61
62   inline UINT16 read_word(offs_t address);
63   inline void write_word(offs_t address, UINT16 data);
64
65   const address_space_config      m_space_config;
66};
67
68
69// device type definition
70extern const device_type MB90092;
71
72
73
74//**************************************************************************
75//  GLOBAL VARIABLES
76//**************************************************************************
77
78
79
80#endif
trunk/src/emu/video/mb90082.c
r0r17567
1/***************************************************************************
2
3   Fujitsu MB90082 OSD
4
5   preliminary device by Angelo Salese
6
7   TODO:
8   - get a real charset ROM;
9
10***************************************************************************/
11
12#include "emu.h"
13#include "video/mb90082.h"
14
15
16
17//**************************************************************************
18//  GLOBAL VARIABLES
19//**************************************************************************
20
21// device type definition
22const device_type MB90082 = &device_creator<mb90082_device>;
23
24static ADDRESS_MAP_START( mb90082_vram, AS_0, 16, mb90082_device )
25   AM_RANGE(0x0000, 0x023f) AM_RAM // main screen vram
26   AM_RANGE(0x0400, 0x063f) AM_RAM // main screen attr
27//   AM_RANGE(0x0800, 0x0a3f) AM_RAM // sub screen vram
28//   AM_RANGE(0x0c00, 0x0e3f) AM_RAM // sub screen attr
29ADDRESS_MAP_END
30
31/* charset is undumped, but apparently a normal ASCII one is enough for the time being (for example "fnt0808.x1" in Sharp X1) */
32ROM_START( mb90082 )
33   ROM_REGION( 0x2000, "mb90082", ROMREGION_ERASEFF )
34   ROM_LOAD("mb90082_char.bin",     0x0000, 0x0800, NO_DUMP )
35ROM_END
36
37//-------------------------------------------------
38//  rom_region - device-specific ROM region
39//-------------------------------------------------
40
41const rom_entry *mb90082_device::device_rom_region() const
42{
43   return ROM_NAME( mb90082 );
44}
45
46//-------------------------------------------------
47//  memory_space_config - return a description of
48//  any address spaces owned by this device
49//-------------------------------------------------
50
51const address_space_config *mb90082_device::memory_space_config(address_spacenum spacenum) const
52{
53   return (spacenum == AS_0) ? &m_space_config : NULL;
54}
55
56//**************************************************************************
57//  INLINE HELPERS
58//**************************************************************************
59
60//-------------------------------------------------
61//  readbyte - read a byte at the given address
62//-------------------------------------------------
63
64inline UINT16 mb90082_device::read_word(offs_t address)
65{
66   return space()->read_word(address << 1);
67}
68
69//-------------------------------------------------
70//  writebyte - write a byte at the given address
71//-------------------------------------------------
72
73inline void mb90082_device::write_word(offs_t address, UINT16 data)
74{
75   space()->write_word(address << 1, data);
76}
77
78//**************************************************************************
79//  LIVE DEVICE
80//**************************************************************************
81
82//-------------------------------------------------
83//  mb90082_device - constructor
84//-------------------------------------------------
85
86mb90082_device::mb90082_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
87   : device_t(mconfig, MB90082, "mb90082", tag, owner, clock),
88     device_memory_interface(mconfig, *this),
89     m_space_config("videoram", ENDIANNESS_LITTLE, 16, 16, 0, NULL, *ADDRESS_MAP_NAME(mb90082_vram))
90{
91   m_shortname = "mb90082";
92
93}
94
95
96//-------------------------------------------------
97//  device_validity_check - perform validity checks
98//  on this device
99//-------------------------------------------------
100
101void mb90082_device::device_validity_check(validity_checker &valid) const
102{
103}
104
105
106//-------------------------------------------------
107//  device_start - device-specific startup
108//-------------------------------------------------
109
110void mb90082_device::device_start()
111{
112
113}
114
115
116//-------------------------------------------------
117//  device_reset - device-specific reset
118//-------------------------------------------------
119
120void mb90082_device::device_reset()
121{
122   m_cmd_ff = 0;
123}
124
125
126//**************************************************************************
127//  READ/WRITE HANDLERS
128//**************************************************************************
129
130WRITE_LINE_MEMBER( mb90082_device::set_cs_line )
131{
132   m_reset_line = state;
133
134   if(m_reset_line != CLEAR_LINE)
135   {
136      // ...
137   }
138}
139
140
141WRITE8_MEMBER( mb90082_device::write )
142{
143   UINT16 dat;
144
145   switch(m_cmd_ff)
146   {
147      case OSD_COMMAND:
148         m_cmd = data & 0xf8;
149         m_cmd_param = data & 7;
150         //printf("cmd %02x\n",data);
151         break;
152      case OSD_DATA:
153         dat = ((m_cmd_param & 7)<<7) | (data & 0x7f);
154         switch(m_cmd)
155         {
156            case 0x80: // Preset VRAM address
157               m_osd_addr = dat & 0x1ff;
158               m_fil = (dat & 0x200) >> 9;
159               break;
160            case 0x88: // Attribute select
161               m_attr = dat;
162               break;
163            case 0x90: // Write Character
164               int x,y;
165               x = (m_osd_addr & 0x01f);
166               y = (m_osd_addr & 0x1e0) >> 5;
167
168               if(m_fil)
169               {
170                  int i;
171                  if(x != 0)
172                     printf("FIL with %d %d\n",x,y);
173
174                  for(i=0;i<24;i++)
175                  {
176                     write_word((i+y*24)|0x000,dat);
177                     write_word((i+y*24)|0x200,m_attr);
178                  }
179               }
180               else
181               {
182                  write_word((x+y*24)|0x000,dat);
183                  write_word((x+y*24)|0x200,m_attr);
184
185                  /* handle address increments */
186                  x = ((x + 1) % 24);
187                  if(x == 0)
188                     y = ((y + 1) % 12);
189                  m_osd_addr = x + (y << 5);
190               }
191               break;
192            case 0xd0: // Set Under Color
193               m_uc = dat & 7;
194               break;
195
196         }
197         break;
198   }
199
200   m_cmd_ff ^= 1;
201}
202
203UINT32 mb90082_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
204{
205   int x,y;
206   UINT8 *pcg = memregion("mb90082")->base();
207   UINT16 tile,attr;
208   UINT8 bg_r,bg_g,bg_b;
209
210   /* TODO: there's probably a way to control the brightness in this */
211   bg_b = m_uc & 1 ? 0xdf : 0;
212   bg_g = m_uc & 2 ? 0xdf : 0;
213   bg_r = m_uc & 4 ? 0xdf : 0;
214   bitmap.fill(MAKE_ARGB(0xff,bg_r,bg_g,bg_b),cliprect);
215
216   for(y=0;y<12;y++)
217   {
218      for(x=0;x<24;x++)
219      {
220         int xi,yi;
221
222         tile = read_word(x+y*24);
223         attr = read_word((x+y*24)|0x200);
224
225         /* TODO: charset hook-up is obviously WRONG so following mustn't be trusted at all */
226         for(yi=0;yi<16;yi++)
227         {
228            for(xi=0;xi<16;xi++)
229            {
230               UINT8 pix;
231               UINT8 color = (attr & 0x70) >> 4;
232               UINT8 r,g,b;
233
234               pix = (pcg[(tile*8)+(yi >> 1)] >> (7-(xi >> 1))) & 1;
235
236               /* TODO: check this */
237               b = (color & 1) ? 0xff : 0;
238               g = (color & 2) ? 0xff : 0;
239               r = (color & 4) ? 0xff : 0;
240
241               if(tile != 0xff && pix != 0)
242                  bitmap.pix32(y*16+yi,x*16+xi) = r << 16 | g << 8 | b;
243            }
244         }
245      }
246   }
247
248   return 0;
249}
trunk/src/emu/video/mb90082.h
r0r17567
1/***************************************************************************
2
3Template for skeleton device
4
5***************************************************************************/
6
7#pragma once
8
9#ifndef __MB90082DEV_H__
10#define __MB90082DEV_H__
11
12
13
14//**************************************************************************
15//  INTERFACE CONFIGURATION MACROS
16//**************************************************************************
17
18#define MCFG_MB90082_ADD(_tag,_freq) \
19   MCFG_DEVICE_ADD(_tag, MB90082, _freq) \
20
21
22//**************************************************************************
23//  TYPE DEFINITIONS
24//**************************************************************************
25
26enum
27{
28   OSD_COMMAND = 0,
29   OSD_DATA
30};
31
32
33// ======================> mb90082_device
34
35class mb90082_device :   public device_t,
36                  public device_memory_interface
37{
38public:
39   // construction/destruction
40   mb90082_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
41
42   // I/O operations
43   DECLARE_WRITE8_MEMBER( write );
44   WRITE_LINE_MEMBER( set_cs_line );
45
46   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
47   virtual const rom_entry *device_rom_region() const;
48
49protected:
50   // device-level overrides
51   virtual void device_validity_check(validity_checker &valid) const;
52   virtual void device_start();
53   virtual void device_reset();
54   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
55
56private:
57   UINT8 m_cmd_ff;
58   UINT8 m_cmd,m_cmd_param;
59   UINT8 m_reset_line;
60
61   UINT16 m_osd_addr;
62   UINT8 m_fil;
63   UINT8 m_uc;
64   UINT8 m_attr;
65
66   inline UINT16 read_word(offs_t address);
67   inline void write_word(offs_t address, UINT16 data);
68
69   const address_space_config      m_space_config;
70};
71
72
73// device type definition
74extern const device_type MB90082;
75
76
77
78//**************************************************************************
79//  GLOBAL VARIABLES
80//**************************************************************************
81
82
83
84#endif
trunk/src/emu/emu.mak
r17566r17567
295295   $(EMUVIDEO)/i8275.o      \
296296   $(EMUVIDEO)/k053250.o      \
297297   $(EMUVIDEO)/m50458.o      \
298   $(EMUVIDEO)/mb90092.o      \
298   $(EMUVIDEO)/mb90082.o      \
299299   $(EMUVIDEO)/mc6845.o      \
300300   $(EMUVIDEO)/msm6255.o      \
301301   $(EMUVIDEO)/pc_cga.o      \

Previous 199869 Revisions Next


© 1997-2024 The MAME Team