Previous 199869 Revisions Next

r26024 Wednesday 6th November, 2013 at 18:33:02 UTC by Angelo Salese
Extra space for i/o in VCU
[src/emu/sound]nes_apu.c nes_defs.h
[src/emu/video]mb_vcu.c mb_vcu.h

trunk/src/emu/video/mb_vcu.c
r26023r26024
44
55Device for Mazer Blazer/Great Guns custom Video Controller Unit
66
7Written by Angelo Salese, based off old implementation by Jarek Burczynski
8
9TODO:
10- understand what exactly modes 0x03 and 0x13 really reads in set_clr() and
11  where it puts results (yeah, shared VCU RAM, but exactly where?). Almost
12  surely Mazer Blazer tries to read the pixel data for collision detection and
13  Great Guns read backs VRAM for VCU test (patched for now, btw).
14- Understand look-up tables in i/o space.
15- Understand how to handle layer clearance.
16- Understand how planes are really handled.
17- Understand how transparent pens are handled (is 0x0f always transparent or
18  there's some clut gimmick? Great Guns title screen makes me think of the
19  latter option)
20
721***************************************************************************/
822
923#include "emu.h"
r26023r26024
2236   AM_RANGE(0x00000,0x7ffff) AM_RAM // enough for a 256x256x4 x 2 pages of framebuffer with 4 layers (TODO: doubled for simplicity)
2337ADDRESS_MAP_END
2438
39
40static ADDRESS_MAP_START( mb_vcu_pal_ram, AS_1, 8, mb_vcu_device )
41   AM_RANGE(0x0000, 0x00ff) AM_RAM
42   AM_RANGE(0x0200, 0x02ff) AM_RAM
43   AM_RANGE(0x0400, 0x04ff) AM_RAM
44   AM_RANGE(0x0600, 0x06ff) AM_WRITE(mb_vcu_paletteram_w)
45ADDRESS_MAP_END
46
47WRITE8_MEMBER( mb_vcu_device::mb_vcu_paletteram_w )
48{
49   int r,g,b, bit0, bit1, bit2;
50
51   UINT8 colour = data;
52
53   /* red component */
54   bit1 = (colour >> 7) & 0x01;
55   bit0 = (colour >> 6) & 0x01;
56   r = combine_2_weights(m_weights_r, bit0, bit1);
57
58   /* green component */
59   bit2 = (colour >> 5) & 0x01;
60   bit1 = (colour >> 4) & 0x01;
61   bit0 = (colour >> 3) & 0x01;
62   g = combine_3_weights(m_weights_g, bit0, bit1, bit2);
63
64   /* blue component */
65   bit2 = (colour >> 2) & 0x01;
66   bit1 = (colour >> 1) & 0x01;
67   bit0 = (colour >> 0) & 0x01;
68   b = combine_3_weights(m_weights_b, bit0, bit1, bit2);
69
70   palette_set_color(machine(), offset, MAKE_RGB(r, g, b));
71}
72
2573//-------------------------------------------------
2674//  memory_space_config - return a description of
2775//  any address spaces owned by this device
r26023r26024
2977
3078const address_space_config *mb_vcu_device::memory_space_config(address_spacenum spacenum) const
3179{
32   return (spacenum == AS_0) ? &m_space_config : NULL;
80   switch (spacenum)
81   {
82      case AS_0: return &m_videoram_space_config;
83      case AS_1: return &m_paletteram_space_config;
84      default: return NULL;
85   }
3386}
3487
3588//**************************************************************************
r26023r26024
4093//  read_byte - read a byte at the given address
4194//-------------------------------------------------
4295
43inline UINT16 mb_vcu_device::read_byte(offs_t address)
96inline UINT8 mb_vcu_device::read_byte(offs_t address)
4497{
45   return space().read_byte(address);
98   return space(AS_0).read_byte(address);
4699}
47100
48101//-------------------------------------------------
49//  write_word - write a word at the given address
102//  write_byte - write a byte at the given address
50103//-------------------------------------------------
51104
52105inline void mb_vcu_device::write_byte(offs_t address, UINT8 data)
53106{
54   space().write_byte(address, data);
107   space(AS_0).write_byte(address, data);
55108}
56109
110//-------------------------------------------------
111//  read_byte - read a byte at the given i/o
112//-------------------------------------------------
113
114inline UINT8 mb_vcu_device::read_io(offs_t address)
115{
116   return space(AS_1).read_byte(address);
117}
118
119//-------------------------------------------------
120//  write_byte - write a byte at the given i/o
121//-------------------------------------------------
122
123inline void mb_vcu_device::write_io(offs_t address, UINT8 data)
124{
125   space(AS_1).write_byte(address, data);
126}
127
128
57129//**************************************************************************
58130//  LIVE DEVICE
59131//**************************************************************************
r26023r26024
66138   : device_t(mconfig, MB_VCU, "Mazer Blazer custom VCU", tag, owner, clock, "mb_vcu", __FILE__),
67139      device_memory_interface(mconfig, *this),
68140      device_video_interface(mconfig, *this),
69      m_space_config("videoram", ENDIANNESS_LITTLE, 8, 19, 0, NULL, *ADDRESS_MAP_NAME(mb_vcu_vram))
141      m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 19, 0, NULL, *ADDRESS_MAP_NAME(mb_vcu_vram)),
142      m_paletteram_space_config("palram", ENDIANNESS_LITTLE, 8, 16, 0, NULL, *ADDRESS_MAP_NAME(mb_vcu_pal_ram))
70143{
71144}
72145
r26023r26024
256329               if(dstx >= 0 && dsty >= 0 && dstx < 256 && dsty < 256)
257330               {
258331                  dot = m_cpu->space(AS_PROGRAM).read_byte(((offset + (bits >> 3)) & 0x1fff) + 0x4000) >> (6-(bits & 7));
259                  dot&= 3;
260332
261                  switch(dot)
333                  switch(dot & 3)
262334                  {
263335                     case 0:
264336                        pen = m_color1 & 0xf;
r26023r26024
292364   return 0; // open bus?
293365}
294366
367/*
368---0 -111 (0x07) write to i/o?
369---0 -011 (0x03) read to i/o?
370---1 -011 (0x13) read to vram?
371*/
295372READ8_MEMBER( mb_vcu_device::load_set_clr )
296373{
297374   int xi,yi;
r26023r26024
355432         break;
356433
357434      case 0x07:
358         switch(m_ypos)
359         {
360            case 6:
361               int r,g,b, bit0, bit1, bit2;
435         for(int i=0;i<m_pix_xsize;i++)
436            write_io(i+(m_ypos<<8),m_ram[offset + i]);
362437
363               for(int i=0;i<m_pix_xsize;i++)
364               {
365                  UINT8 colour = m_ram[offset + i];
366                  /* red component */
367                  bit1 = (colour >> 7) & 0x01;
368                  bit0 = (colour >> 6) & 0x01;
369                  r = combine_2_weights(m_weights_r, bit0, bit1);
370
371                  /* green component */
372                  bit2 = (colour >> 5) & 0x01;
373                  bit1 = (colour >> 4) & 0x01;
374                  bit0 = (colour >> 3) & 0x01;
375                  g = combine_3_weights(m_weights_g, bit0, bit1, bit2);
376
377                  /* blue component */
378                  bit2 = (colour >> 2) & 0x01;
379                  bit1 = (colour >> 1) & 0x01;
380                  bit0 = (colour >> 0) & 0x01;
381                  b = combine_3_weights(m_weights_b, bit0, bit1, bit2);
382
383                  palette_set_color(machine(), i, MAKE_RGB(r, g, b));
384               }
385               break;
386         }
387438         break;
388439   }
389440
trunk/src/emu/video/mb_vcu.h
r26023r26024
5353   DECLARE_WRITE8_MEMBER( background_color_w );
5454   DECLARE_READ8_MEMBER( status_r );
5555   DECLARE_WRITE8_MEMBER( vbank_w );
56   DECLARE_WRITE8_MEMBER( mb_vcu_paletteram_w );
5657
5758   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
5859   void screen_eof(void);
r26023r26024
6566   virtual void device_reset();
6667   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
6768private:
68   inline UINT16 read_byte(offs_t address);
69   inline UINT8 read_byte(offs_t address);
6970   inline void write_byte(offs_t address, UINT8 data);
71   inline UINT8 read_io(offs_t address);
72   inline void write_io(offs_t address, UINT8 data);
7073
71   const address_space_config      m_space_config;
74   const address_space_config      m_videoram_space_config;
75   const address_space_config      m_paletteram_space_config;
7276   UINT8 m_status;
7377   UINT8 *m_ram;
7478   cpu_device *m_cpu;
trunk/src/emu/sound/nes_defs.h
r26023r26024
5555      queue_t():
5656      pos(0),
5757      reg(""),val("") {}
58   
58
5959   int pos;
6060   unsigned char reg, val;
6161};
r26023r26024
108108         env_vol = 0;
109109         enabled = false;
110110      }
111         
111
112112   uint8 regs[4];
113113   int vbl_length;
114114   int freq;
r26023r26024
139139         counter_started = false;
140140         enabled = false;
141141      }
142   
142
143143   uint8 regs[4]; /* regs[1] unused */
144144   int linear_length;
145145   int vbl_length;
r26023r26024
199199      memory = NULL;
200200      vol = NULL;
201201      }
202     
202
203203   uint8 regs[4];
204204   uint32 address;
205205   uint32 length;
r26023r26024
223223      buf_pos = 0;
224224      step_mode = 0;
225225      }
226     
226
227227   /* Sound channels */
228228   square_t   squ[2];
229229   triangle_t tri;
trunk/src/emu/sound/nes_apu.c
r26023r26024
114114   {
115115      m_noise_lut[i] = 0;
116116   }
117   
117
118118   for (int i = 0; i < 0X20; i++)
119119   {
120120      m_vbl_times[i] = 0;
121121   }
122   
122
123123   for (int i = 0; i < SYNCS_MAX1; i++)
124124   {
125125      m_sync_times1[i] = 0;
126126   }
127   
127
128128   for (int i = 0; i < SYNCS_MAX2; i++)
129129   {
130130      m_sync_times2[i] = 0;
r26023r26024
233233   #else
234234   save_item(NAME(m_APU.buf_pos));
235235   save_item(NAME(m_APU.step_mode));
236   #endif   
236   #endif
237237}
238238
239239/* TODO: sound channels should *ALL* have DC volume decay */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team