Previous 15994 Revisions Next

r12563 Thursday 11th August, 2011 at 01:36:28 UTC by R. Belmont
mac: Added full emulation of Apple Hi-Resolution video card [R. Belmont]
[src/mess]mess.mak mess_dev.lst
[src/mess/drivers]mac.c
[src/mess/video]nubus_m2hires.c* nubus_m2hires.h*

src/mess/video/nubus_m2hires.c
r0r12563
1/***************************************************************************
2 
3  Apple Hi-Resolution Video Card emulation
4 
5  RAMDAC: control at Fs0940e0, data at Fs0940e4
6  Fs090010 bit 16 is vbl status, bit 17 must be "1" for proper operation
7  Fs08000x are the control registers
8 
9***************************************************************************/
10
11#include "emu.h"
12#include "video/nubus_m2hires.h"
13
14#define M2HIRES_SCREEN_NAME   "m2hires_screen"
15#define M2HIRES_ROM_REGION  "m2hires_rom"
16
17#define VRAM_SIZE   (0x80000)   // 512k max
18
19static SCREEN_UPDATE( m2hires );
20
21MACHINE_CONFIG_FRAGMENT( m2hires )
22   MCFG_SCREEN_ADD( M2HIRES_SCREEN_NAME, RASTER)
23   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
24   MCFG_SCREEN_UPDATE(m2hires)
25   MCFG_SCREEN_RAW_PARAMS(25175000, 800, 0, 640, 525, 0, 480)
26   MCFG_SCREEN_SIZE(1024,768)
27   MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
28MACHINE_CONFIG_END
29
30ROM_START( m2hires )
31   ROM_REGION(0x2000, M2HIRES_ROM_REGION, 0)
32   ROM_LOAD( "341-0660.bin", 0x0000, 0x2000, CRC(ea6f7913) SHA1(37c59f38ae34021d0cb86c2e76a598b7e6077c0d) )
33ROM_END                           
34
35//**************************************************************************
36//  GLOBAL VARIABLES
37//**************************************************************************
38
39const device_type NUBUS_M2HIRES = &device_creator<nubus_m2hires_device>;
40
41
42//-------------------------------------------------
43//  machine_config_additions - device-specific
44//  machine configurations
45//-------------------------------------------------
46
47machine_config_constructor nubus_m2hires_device::device_mconfig_additions() const
48{
49   return MACHINE_CONFIG_NAME( m2hires );
50}
51
52//-------------------------------------------------
53//  rom_region - device-specific ROM region
54//-------------------------------------------------
55
56const rom_entry *nubus_m2hires_device::device_rom_region() const
57{
58   return ROM_NAME( m2hires );
59}
60
61//**************************************************************************
62//  LIVE DEVICE
63//**************************************************************************
64
65//-------------------------------------------------
66//  nubus_m2hires_device - constructor
67//-------------------------------------------------
68
69nubus_m2hires_device::nubus_m2hires_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
70        device_t(mconfig, NUBUS_M2HIRES, "Macintosh II Hi-Resolution video card", tag, owner, clock),
71      device_nubus_card_interface(mconfig, *this),
72      device_slot_card_interface(mconfig, *this)
73{
74   m_shortname = "nb_m2hr";
75}
76
77nubus_m2hires_device::nubus_m2hires_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) :
78        device_t(mconfig, type, name, tag, owner, clock),
79      device_nubus_card_interface(mconfig, *this),
80      device_slot_card_interface(mconfig, *this)
81{
82   m_shortname = "nb_m2hr";
83}
84
85//-------------------------------------------------
86//  device_start - device-specific startup
87//-------------------------------------------------
88
89void nubus_m2hires_device::device_start()
90{
91   UINT32 slotspace;
92
93   // set_nubus_device makes m_slot valid
94   set_nubus_device();
95   install_declaration_rom(this, M2HIRES_ROM_REGION);
96
97   slotspace = get_slotspace();
98
99//   printf("[m2hires %p] slotspace = %x\n", this, slotspace);
100
101   m_vram = auto_alloc_array(machine(), UINT8, VRAM_SIZE);
102   m_vram32 = (UINT32 *)m_vram;
103
104   m_nubus->install_device(slotspace, slotspace+VRAM_SIZE-1, read32_delegate(FUNC(nubus_m2hires_device::vram_r), this), write32_delegate(FUNC(nubus_m2hires_device::vram_w), this));
105   m_nubus->install_device(slotspace+0x900000, slotspace+VRAM_SIZE-1+0x900000, read32_delegate(FUNC(nubus_m2hires_device::vram_r), this), write32_delegate(FUNC(nubus_m2hires_device::vram_w), this));
106   m_nubus->install_device(slotspace+0x80000, slotspace+0x8fffff, read32_delegate(FUNC(nubus_m2hires_device::m2hires_r), this), write32_delegate(FUNC(nubus_m2hires_device::m2hires_w), this));
107
108   m_timer = timer_alloc(0, NULL);
109   m_screen = NULL;   // can we look this up now?
110}
111
112//-------------------------------------------------
113//  device_reset - device-specific reset
114//-------------------------------------------------
115
116void nubus_m2hires_device::device_reset()
117{
118   m_count = 0;
119   m_clutoffs = 0;
120   m_vbl_disable = 1;
121   m_mode = 0;
122   memset(m_vram, 0, VRAM_SIZE);
123   memset(m_palette, 0, sizeof(m_palette));
124
125   m_palette[0] = MAKE_RGB(255, 255, 255);
126   m_palette[0x80] = MAKE_RGB(0, 0, 0);
127}
128
129
130void nubus_m2hires_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
131{
132   if (!m_vbl_disable)
133   {
134      m_nubus->set_irq_line(m_slot, ASSERT_LINE);
135   }
136
137   m_timer->adjust(m_screen->time_until_pos(479, 0), 0);
138}
139
140/***************************************************************************
141
142  Spectrum 24 PDQ section
143
144***************************************************************************/
145
146static SCREEN_UPDATE( m2hires )
147{
148   UINT32 *scanline;
149   int x, y;
150   nubus_m2hires_device *card = downcast<nubus_m2hires_device *>(screen->owner());
151   UINT8 pixels, *vram;
152
153   // first time?  kick off the VBL timer
154   if (!card->m_screen)
155   {
156      card->m_screen = screen;
157      card->m_timer->adjust(card->m_screen->time_until_pos(479, 0), 0);
158   }
159
160   vram = card->m_vram + 0x20;
161
162   switch (card->m_mode)
163   {
164      case 0: // 1 bpp?
165         for (y = 0; y < 480; y++)
166         {
167            scanline = BITMAP_ADDR32(bitmap, y, 0);
168            for (x = 0; x < 640/8; x++)
169            {
170               pixels = vram[(y * 128) + (BYTE4_XOR_BE(x))];
171
172               *scanline++ = card->m_palette[((pixels>>7)&0x1)];
173               *scanline++ = card->m_palette[((pixels>>6)&0x1)];
174               *scanline++ = card->m_palette[((pixels>>5)&0x1)];
175               *scanline++ = card->m_palette[((pixels>>4)&0x1)];
176               *scanline++ = card->m_palette[((pixels>>3)&0x1)];
177               *scanline++ = card->m_palette[((pixels>>2)&0x1)];
178               *scanline++ = card->m_palette[((pixels>>1)&0x1)];
179               *scanline++ = card->m_palette[(pixels&1)];
180            }
181         }
182         break;
183
184      case 1: // 2 bpp
185         for (y = 0; y < 480; y++)
186         {
187            scanline = BITMAP_ADDR32(bitmap, y, 0);
188            for (x = 0; x < 640/4; x++)
189            {
190               pixels = vram[(y * 256) + (BYTE4_XOR_BE(x))];
191
192               *scanline++ = card->m_palette[((pixels>>6)&3)];
193               *scanline++ = card->m_palette[((pixels>>4)&3)];
194               *scanline++ = card->m_palette[((pixels>>2)&3)];
195               *scanline++ = card->m_palette[(pixels&3)];
196            }
197         }
198         break;
199
200      case 2: // 4 bpp
201         for (y = 0; y < 480; y++)
202         {
203            scanline = BITMAP_ADDR32(bitmap, y, 0);
204
205            for (x = 0; x < 640/2; x++)
206            {
207               pixels = vram[(y * 512) + (BYTE4_XOR_BE(x))];
208
209               *scanline++ = card->m_palette[((pixels&0xf0)>>4)];
210               *scanline++ = card->m_palette[(pixels&0xf)];
211            }
212         }
213         break;
214
215      case 3: // 8 bpp
216         for (y = 0; y < 480; y++)
217         {
218            scanline = BITMAP_ADDR32(bitmap, y, 0);
219
220            for (x = 0; x < 640; x++)
221            {
222               pixels = vram[(y * 1024) + (BYTE4_XOR_BE(x))];
223               *scanline++ = card->m_palette[pixels];
224            }
225         }
226         break;
227
228      default:
229         fatalerror("m2hires: unknown video mode %d", card->m_mode);
230         break;
231
232   }
233   return 0;
234}
235
236WRITE32_MEMBER( nubus_m2hires_device::m2hires_w )
237{
238   data ^= 0xffffffff;
239
240   switch (offset)
241   {
242      case 1:         // mode
243         switch (data)
244         {
245            case 0x20000000:
246               m_mode = 0;
247               break;
248
249            case 0x40000000:
250               m_mode = 1;
251               break;
252
253            case 0x80000000:
254               m_mode = 2;
255               break;
256
257            case 0x00010000:
258               m_mode = 3;
259               break;
260         }
261         break;
262
263      case 0x5038:   // DAC control
264//         printf("%08x to DAC control (PC=%x)\n", data, cpu_get_pc(&space.device()));
265         m_clutoffs = (data>>24)&0xff;
266         break;
267
268      case 0x5039: // DAC data
269         m_colors[m_count++] = (data>>24) & 0xff;
270
271         if (m_count == 3)
272         {
273//            printf("RAMDAC: color %d = %02x %02x %02x (PC=%x)\n", m_clutoffs, m_colors[0], m_colors[1], m_colors[2], cpu_get_pc(&space.device()) );
274            palette_set_color(space.machine(), m_clutoffs, MAKE_RGB(m_colors[0], m_colors[1], m_colors[2]));
275            m_palette[m_clutoffs] = MAKE_RGB(m_colors[0], m_colors[1], m_colors[2]);
276            m_clutoffs++;
277            if (m_clutoffs > 255)
278            {
279               m_clutoffs = 0;
280            }
281            m_count = 0;
282         }
283         break;
284
285      case 0x8000:   // enable and ack VBL
286         m_vbl_disable = 0;
287         m_nubus->set_irq_line(m_slot, CLEAR_LINE);
288         break;
289
290      case 0x8001:   // disable VBL
291         m_vbl_disable = 1;
292         break;
293
294      default:
295//         printf("m2hires_w: %08x @ %x, mask %08x (PC=%x)\n", data, offset, mem_mask, cpu_get_pc(&space.device()));
296         break;
297   }
298}
299
300READ32_MEMBER( nubus_m2hires_device::m2hires_r )
301{
302   if (offset == 0x10010/4)
303   {
304      m_toggle ^= (1<<16);
305      return m_toggle | (1<<17);   // bit 17 indicates a 4/8bpp capable ASIC apparently; the firmware won't enter those modes otherwise (although they show in the list)
306   }
307/*   else
308   {
309      printf("m2hires_r: @ %x, mask %08x (PC=%x)\n", offset, mem_mask, cpu_get_pc(&space.device()));
310   }*/
311
312   return 0;
313}
314
315WRITE32_MEMBER( nubus_m2hires_device::vram_w )
316{
317   data ^= 0xffffffff;
318   COMBINE_DATA(&m_vram32[offset]);
319}
320
321READ32_MEMBER( nubus_m2hires_device::vram_r )
322{
323   return m_vram32[offset] ^ 0xffffffff;
324}
src/mess/video/nubus_m2hires.h
r0r12563
1#pragma once
2
3#ifndef __NUBUS_M2HIRES_H__
4#define __NUBUS_M2HIRES_H__
5
6#include "emu.h"
7#include "machine/nubus.h"
8
9//**************************************************************************
10//  TYPE DEFINITIONS
11//**************************************************************************
12
13// ======================> nubus_m2hires_device
14
15class nubus_m2hires_device :
16      public device_t,
17      public device_nubus_card_interface,
18      public device_slot_card_interface
19{
20public:
21        // construction/destruction
22        nubus_m2hires_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
23      nubus_m2hires_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
24
25      // optional information overrides
26      virtual machine_config_constructor device_mconfig_additions() const;
27      virtual const rom_entry *device_rom_region() const;
28
29protected:
30        // device-level overrides
31        virtual void device_start();
32        virtual void device_reset();
33        virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
34
35        DECLARE_READ32_MEMBER(m2hires_r);
36        DECLARE_WRITE32_MEMBER(m2hires_w);
37        DECLARE_READ32_MEMBER(vram_r);
38        DECLARE_WRITE32_MEMBER(vram_w);
39
40public:
41        UINT8 *m_vram;
42        UINT32 *m_vram32;
43        UINT32 m_mode, m_vbl_disable, m_toggle;
44        UINT32 m_palette[256], m_colors[3], m_count, m_clutoffs;
45        screen_device *m_screen;
46        emu_timer *m_timer;
47};
48
49
50// device type definition
51extern const device_type NUBUS_M2HIRES;
52
53#endif  /* __NUBUS_M2HIRES_H__ */
src/mess/mess_dev.lst
r12562r12563
9494NUBUS_CB264
9595NUBUS_VIKBW
9696NUBUS_SPECPDQ
97NUBUS_M2HIRES
9798PC1512_KEYBOARD
9899S1410
99100SED1330
src/mess/mess.mak
r12562r12563
650650   $(MESS_VIDEO)/nubus_cb264.o \
651651   $(MESS_VIDEO)/nubus_vikbw.o \
652652   $(MESS_VIDEO)/nubus_specpdq.o \
653   $(MESS_VIDEO)/nubus_m2hires.o \
653654
654655$(MESSOBJ)/applied.a:         \
655656   $(MESS_VIDEO)/mbee.o      \
src/mess/drivers/mac.c
r12562r12563
5757#include "video/nubus_cb264.h"
5858#include "video/nubus_vikbw.h"
5959#include "video/nubus_specpdq.h"
60#include "video/nubus_m2hires.h"
6061#include "includes/mac.h"
6162
6263#define C7M   (7833600)
r12562r12563
805806   SLOT_INTERFACE("824gc", NUBUS_824GC)   /* Apple 8*24 Graphics Card */
806807   SLOT_INTERFACE("cb264", NUBUS_CB264)   /* RasterOps ColorBoard 264 */
807808   SLOT_INTERFACE("vikbw", NUBUS_VIKBW)   /* Moniterm Viking board */
808   SLOT_INTERFACE("specpdq", NUBUS_SPECPDQ)   /* SuperMac Spectrum 24 PDQ */
809   SLOT_INTERFACE("specpdq", NUBUS_SPECPDQ)   /* SuperMac Spectrum PDQ */
810   SLOT_INTERFACE("m2hires", NUBUS_M2HIRES)   /* Apple Macintosh II Hi-Resolution Card */
809811SLOT_INTERFACE_END
810812
811813/***************************************************************************
r12562r12563
825827};
826828
827829
828static const floppy_interface mac_floppy_interface = //SONY_FLOPPY_ALLOW400K | SONY_FLOPPY_ALLOW800K
830static const floppy_interface mac_floppy_interface =
829831{
830832   DEVCB_NULL,
831833   DEVCB_NULL,

Previous 15994 Revisions Next


© 1998-2018 The MESS Team