Previous 15994 Revisions Next

r2128 Friday 28th March, 2008 at 17:29:51 UTC by Dirk Best
[COUPE] Rewrote interrupt handling, cleanups
[src/mess/drivers]coupe.c
[src/mess/includes]coupe.h
[src/mess/machine]coupe.c
[src/mess/video]coupe.c

src/mess/includes/coupe.h
r2127r2128
3131#define LMPR_RAM0   0x20   /* If bit set ram is paged into bank 0, else its rom0 */
3232#define LMPR_ROM1   0x40   /* If bit set rom1 is paged into bank 3, else its ram */
3333
34/*----------- defined in drivers/coupe.c -----------*/
3435
36void coupe_irq(running_machine *machine, UINT8 src);
37
38
3539/*----------- defined in machine/coupe.c -----------*/
3640
3741extern UINT8 LMPR,HMPR,VMPR;/* Bank Select Registers (Low Page p250, Hi Page p251, Video Page p252) */
r2127r2128
4044extern UINT8 SOUND_REG[32]; /* 32 sound registers */
4145extern UINT8 LINE_INT;      /* Line interrupt register */
4246extern UINT8 LPEN,HPEN;    /* ??? */
43extern UINT8 CURLINE;      /* Current scanline */
4447extern UINT8 STAT;         /* returned when port 249 read */
4548
4649void coupe_update_memory(void);
src/mess/video/coupe.c
r2127r2128
160160
161161VIDEO_UPDATE( coupe )
162162{
163   int scanline = video_screen_get_vpos(screen);
164
165   HPEN = scanline;
166
167   /* line interrupt? */
168   if (LINE_INT == scanline) coupe_irq(screen->machine, 0x01);
169
163170   switch ((VMPR & 0x60) >> 5)
164171   {
165172   case 0: /* mode 1 */
166      drawMode1_line(bitmap, video_screen_get_vpos(screen));
173      drawMode1_line(bitmap, scanline);
167174      break;
168175   case 1: /* mode 2 */
169      drawMode2_line(bitmap, video_screen_get_vpos(screen));
176      drawMode2_line(bitmap, scanline);
170177      break;
171178   case 2: /* mode 3 */
172      drawMode3_line(bitmap, video_screen_get_vpos(screen));
179      drawMode3_line(bitmap, scanline);
173180      break;
174181   case 3: /* mode 4 */
175      drawMode4_line(bitmap, video_screen_get_vpos(screen));
182      drawMode4_line(bitmap, scanline);
176183      break;
177184   }
178185
src/mess/machine/coupe.c
r2127r2128
2020UINT8 SOUND_REG[32];   /* 32 sound registers */
2121UINT8 LINE_INT;       /* Line interrupt */
2222UINT8 LPEN,HPEN;      /* ??? */
23UINT8 CURLINE;         /* Current scanline */
2423UINT8 STAT;          /* returned when port 249 read */
2524
2625extern UINT8 *sam_screen;
r2127r2128
129128
130129    STAT = 0x1F;
131130
132    CURLINE = 0x00;
133
134131    coupe_update_memory();
135132}
136133
src/mess/drivers/coupe.c
r2127r2128
5252
5353***************************************************************************/
5454
55/* core includes */
5556#include "driver.h"
56#include "deprecat.h"
57#include "includes/coupe.h"
58
59/* components */
5760#include "cpu/z80/z80.h"
58#include "includes/coupe.h"
5961#include "machine/wd17xx.h"
60#include "devices/basicdsk.h"
6162#include "sound/saa1099.h"
6263#include "sound/speaker.h"
6364
64static ADDRESS_MAP_START( coupe_mem , ADDRESS_SPACE_PROGRAM, 8)
65   AM_RANGE( 0x0000, 0x3FFF) AM_RAMBANK(1)
66   AM_RANGE( 0x4000, 0x7FFF) AM_RAMBANK(2)
67   AM_RANGE( 0x8000, 0xBFFF) AM_RAMBANK(3)
68   AM_RANGE( 0xC000, 0xFFFF) AM_RAMBANK(4)
69ADDRESS_MAP_END
65/* devices */
66#include "devices/basicdsk.h"
7067
71static INTERRUPT_GEN( coupe_line_interrupt )
72{
73   int interrupted=0;   /* This is used to allow me to clear the STAT flag (easiest way I can do it!) */
7468
75   HPEN = CURLINE;
7669
77   if (LINE_INT<192)
78   {
79      if (CURLINE == LINE_INT)
80      {
81         /* No other interrupts can occur - NOT CORRECT!!! */
82            STAT=0x1E;
83         cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
84         interrupted=1;
85      }
86   }
70static unsigned char getSamKey1(unsigned char hi);
71static unsigned char getSamKey2(unsigned char hi);
8772
88   CURLINE = (CURLINE + 1) % (192+10);
8973
90   if (CURLINE == 193)
91   {
92      if (interrupted)
93         STAT&=~0x08;
94      else
95         STAT=0x17;
96
97      cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
98      interrupted=1;
99   }
100
101   if (!interrupted)
102      STAT=0x1F;
103}
104
105static unsigned char getSamKey1(unsigned char hi)
106{
107   unsigned char result;
108
109   hi=~hi;
110   result=0xFF;
111
112   if (hi==0x00)
113      result &=readinputport(8) & 0x1F;
114   else
115   {
116      if (hi&0x80) result &= readinputport(7) & 0x1F;
117      if (hi&0x40) result &= readinputport(6) & 0x1F;
118      if (hi&0x20) result &= readinputport(5) & 0x1F;
119      if (hi&0x10) result &= readinputport(4) & 0x1F;
120      if (hi&0x08) result &= readinputport(3) & 0x1F;
121      if (hi&0x04) result &= readinputport(2) & 0x1F;
122      if (hi&0x02) result &= readinputport(1) & 0x1F;
123      if (hi&0x01) result &= readinputport(0) & 0x1F;
124   }
125
126   return result;
127}
128
129static unsigned char getSamKey2(unsigned char hi)
130{
131   unsigned char result;
132
133   hi=~hi;
134   result=0xFF;
135
136   if (hi==0x00)
137   {
138      /* does not map to any keys? */
139   }
140   else
141   {
142      if (hi&0x80) result &= readinputport(7) & 0xE0;
143      if (hi&0x40) result &= readinputport(6) & 0xE0;
144      if (hi&0x20) result &= readinputport(5) & 0xE0;
145      if (hi&0x10) result &= readinputport(4) & 0xE0;
146      if (hi&0x08) result &= readinputport(3) & 0xE0;
147      if (hi&0x04) result &= readinputport(2) & 0xE0;
148      if (hi&0x02) result &= readinputport(1) & 0xE0;
149      if (hi&0x01) result &= readinputport(0) & 0xE0;
150   }
151
152   return result;
153}
154
155
15674static READ8_HANDLER( coupe_port_r )
15775{
15876    if (offset==SSND_ADDR)  /* Sound address request */
r2127r2128
18199        return wd17xx_data_r(machine, 0);
182100   case LPEN_PORT:
183101      return LPEN;
184   case STAT_PORT:
102   case STAT_PORT:     
185103      return ((getSamKey2((offset >> 8)&0xFF))&0xE0) | STAT;
186104   case LMPR_PORT:
187105      return LMPR;
r2127r2128
268186   }
269187}
270188
271static ADDRESS_MAP_START( coupe_io , ADDRESS_SPACE_IO, 8)
272   AM_RANGE( 0x0000, 0x0ffff) AM_READWRITE( coupe_port_r, coupe_port_w )
189
190
191/*************************************
192 *
193 *  Address maps
194 *
195 *************************************/
196
197static ADDRESS_MAP_START( coupe_mem, ADDRESS_SPACE_PROGRAM, 8 )
198   AM_RANGE(0x0000, 0x3fff) AM_RAMBANK(1)
199   AM_RANGE(0x4000, 0x7fff) AM_RAMBANK(2)
200   AM_RANGE(0x8000, 0xbfff) AM_RAMBANK(3)
201   AM_RANGE(0xc000, 0xffff) AM_RAMBANK(4)
273202ADDRESS_MAP_END
274203
275static GFXDECODE_START( coupe_gfxdecodeinfo )
276GFXDECODE_END
204static ADDRESS_MAP_START( coupe_io, ADDRESS_SPACE_IO, 8 )
205   AM_RANGE(0x0000, 0x0ffff) AM_READWRITE(coupe_port_r, coupe_port_w)
206ADDRESS_MAP_END
277207
208
209
210/*************************************
211 *
212 *  Interrupts
213 *
214 *************************************/
215
216static TIMER_CALLBACK( irq_off )
217{
218   /* clear interrupt */
219   cpunum_set_input_line(machine, 0, 0, CLEAR_LINE);
220   
221   /* adjust STATUS register */
222   STAT |= param;
223}
224
225
226void coupe_irq(running_machine *machine, UINT8 src)
227{
228   /* set irq and a timer to set it off again */
229   cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
230   timer_set(ATTOTIME_IN_USEC(20), NULL, src, irq_off);
231   
232   /* adjust STATUS register */
233   STAT &= ~src;
234}
235
236
237static INTERRUPT_GEN( coupe_frame_interrupt )
238{
239   /* signal frame interrupt */
240   coupe_irq(machine, 0x08);
241}
242
243
244
245/*************************************
246 *
247 *  Inputs
248 *
249 *************************************/
250
251static unsigned char getSamKey1(unsigned char hi)
252{
253   unsigned char result;
254
255   hi=~hi;
256   result=0xFF;
257
258   if (hi==0x00)
259      result &=readinputport(8) & 0x1F;
260   else
261   {
262      if (hi&0x80) result &= readinputport(7) & 0x1F;
263      if (hi&0x40) result &= readinputport(6) & 0x1F;
264      if (hi&0x20) result &= readinputport(5) & 0x1F;
265      if (hi&0x10) result &= readinputport(4) & 0x1F;
266      if (hi&0x08) result &= readinputport(3) & 0x1F;
267      if (hi&0x04) result &= readinputport(2) & 0x1F;
268      if (hi&0x02) result &= readinputport(1) & 0x1F;
269      if (hi&0x01) result &= readinputport(0) & 0x1F;
270   }
271
272   return result;
273}
274
275
276static unsigned char getSamKey2(unsigned char hi)
277{
278   unsigned char result;
279
280   hi=~hi;
281   result=0xFF;
282
283   if (hi==0x00)
284   {
285      /* does not map to any keys? */
286   }
287   else
288   {
289      if (hi&0x80) result &= readinputport(7) & 0xE0;
290      if (hi&0x40) result &= readinputport(6) & 0xE0;
291      if (hi&0x20) result &= readinputport(5) & 0xE0;
292      if (hi&0x10) result &= readinputport(4) & 0xE0;
293      if (hi&0x08) result &= readinputport(3) & 0xE0;
294      if (hi&0x04) result &= readinputport(2) & 0xE0;
295      if (hi&0x02) result &= readinputport(1) & 0xE0;
296      if (hi&0x01) result &= readinputport(0) & 0xE0;
297   }
298
299   return result;
300}
301
302
278303static INPUT_PORTS_START( coupe )
279304   PORT_START // FE  0
280305   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT)
r2127r2128
414439
415440
416441
442/*************************************
443 *
444 *  Machine drivers
445 *
446 *************************************/
447
417448static MACHINE_DRIVER_START( coupe )
418449   /* basic machine hardware */
419450   MDRV_CPU_ADD(Z80, 6000000)        /* 6 Mhz */
420451   MDRV_CPU_PROGRAM_MAP(coupe_mem, 0)
421452   MDRV_CPU_IO_MAP(coupe_io, 0)
422   MDRV_CPU_VBLANK_INT_HACK(coupe_line_interrupt, 192 + 10)   /* 192 scanlines + 10 lines of vblank (approx).. */
423   MDRV_SCREEN_ADD("main", RASTER)
424   MDRV_SCREEN_REFRESH_RATE(50)
425   MDRV_SCREEN_VBLANK_TIME(0)
426   MDRV_INTERLEAVE(1)
427
453   MDRV_CPU_VBLANK_INT("main", coupe_frame_interrupt)
428454   MDRV_MACHINE_START( coupe )
429455
430456    /* video hardware */
457   MDRV_SCREEN_ADD("main", RASTER)
458   MDRV_SCREEN_REFRESH_RATE(50)
459   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500))
431460   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
432   MDRV_SCREEN_SIZE(64*8, 24*8)
461   MDRV_SCREEN_SIZE(64*8, 24*8 + 10)
433462   MDRV_SCREEN_VISIBLE_AREA(0, 64*8-1, 0, 24*8-1)
434   MDRV_GFXDECODE( coupe_gfxdecodeinfo )
435463   MDRV_PALETTE_LENGTH(128)
436464   MDRV_PALETTE_INIT(coupe)
437465
r2127r2128
446474   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
447475MACHINE_DRIVER_END
448476
449/***************************************************************************
450477
451  Game driver(s)
452478
453***************************************************************************/
479/*************************************
480 *
481 *  ROM definitions
482 *
483 *************************************/
454484
455485ROM_START(coupe)
456486   ROM_REGION(0x8000,REGION_CPU1,0)
r2127r2128
489519   ROMX_LOAD("rom30", 0x0000, 0x8000, CRC(e535c25d) SHA1(d390f0be420dfb12b1e54a4f528b5055d7d97e2a), ROM_BIOS(14))
490520ROM_END
491521
522
523
524/*************************************
525 *
526 *  Devices
527 *
528 *************************************/
529
492530static void coupe_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
493531{
494532   /* floppy */
495533   switch(state)
496534   {
497535      /* --- the following bits of info are returned as 64-bit signed integers --- */
498      case MESS_DEVINFO_INT_COUNT:                     info->i = 2; break;
536      case MESS_DEVINFO_INT_COUNT:         info->i = 2; break;
499537
500538      /* --- the following bits of info are returned as pointers to data or functions --- */
501      case MESS_DEVINFO_PTR_LOAD:                     info->load = device_load_coupe_floppy; break;
539      case MESS_DEVINFO_PTR_LOAD:            info->load = device_load_coupe_floppy; break;
502540
503541      /* --- the following bits of info are returned as NULL-terminated strings --- */
504      case MESS_DEVINFO_STR_FILE_EXTENSIONS:            strcpy(info->s = device_temp_str(), "dsk"); break;
542      case MESS_DEVINFO_STR_FILE_EXTENSIONS:   strcpy(info->s = device_temp_str(), "dsk"); break;
505543
506      default:                              legacybasicdsk_device_getinfo(devclass, state, info); break;
544      default:                        legacybasicdsk_device_getinfo(devclass, state, info); break;
507545   }
508546}
509547
548
510549SYSTEM_CONFIG_START(coupe)
511550   CONFIG_RAM_DEFAULT(256 * 1024)
512551   CONFIG_RAM(512 * 1024)
r2127r2128
514553   CONFIG_DEVICE(coupe_floppy_getinfo)
515554SYSTEM_CONFIG_END
516555
517/*    YEAR  NAME      PARENT    COMPAT  MACHINE         INPUT     INIT  CONFIG  COMPANY                           FULLNAME */
518COMP( 1989, coupe,     0,      0,      coupe,         coupe,     0,   coupe,   "Miles Gordon Technology plc",    "Sam Coupe" , 0)
556
557
558/*************************************
559 *
560 *  Game drivers
561 *
562 *************************************/
563
564/*    YEAR  NAME   PARENT  COMPAT  MACHINE  INPUT  INIT  CONFIG  COMPANY                        FULLNAME     FLAGS */
565COMP( 1989, coupe, 0,      0,      coupe,   coupe, 0,    coupe,  "Miles Gordon Technology plc", "Sam Coupe", 0 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team