Previous 15994 Revisions Next

r2183 Monday 31st March, 2008 at 11:46:23 UTC by Dirk Best
[COUPE] Some 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
r2182r2183
1212#define COUPE_H_
1313
1414
15struct coupe_asic
16{
17   UINT8 lmpr, hmpr, vmpr; /* memory pages */   
18   UINT8 clut[16];         /* color lookup table, 16 entries */
19   UINT8 line_int;         /* line interrupt */
20   UINT8 status;           /* status register */
21};
22
23
1524/*----------- defined in drivers/coupe.c -----------*/
1625
1726void coupe_irq(running_machine *machine, UINT8 src);
r2182r2183
1928
2029/*----------- defined in machine/coupe.c -----------*/
2130
22extern UINT8 LMPR,HMPR,VMPR;/* Bank Select Registers (Low Page p250, Hi Page p251, Video Page p252) */
23extern UINT8 CLUT[16];      /* 16 entries in a palette (no line affects supported yet!) */
24extern UINT8 LINE_INT;      /* Line interrupt register */
25extern UINT8 STAT;         /* returned when port 249 read */
31extern struct coupe_asic coupe_regs;
2632
2733void coupe_update_memory(void);
2834
src/mess/video/coupe.c
r2182r2183
1212#include "driver.h"
1313#include "includes/coupe.h"
1414
15unsigned char *sam_screen;
1615
1716static void drawMode4_line(bitmap_t *bitmap,int y)
1817{
r2182r2183
2120
2221   for (x=0;x<256;)
2322   {
24      tmp=*(sam_screen + (x/2) + (y*128));
23      tmp=*(videoram + (x/2) + (y*128));
2524#ifdef MONO
2625      if (tmp>>4)
2726      {
r2182r2183
4645      }
4746      x++;
4847#else
49      *BITMAP_ADDR16(bitmap, y, x*2+0) = CLUT[tmp>>4];
50      *BITMAP_ADDR16(bitmap, y, x*2+1) = CLUT[tmp>>4];
48      *BITMAP_ADDR16(bitmap, y, x*2+0) = coupe_regs.clut[tmp>>4];
49      *BITMAP_ADDR16(bitmap, y, x*2+1) = coupe_regs.clut[tmp>>4];
5150      x++;
52      *BITMAP_ADDR16(bitmap, y, x*2+0) = CLUT[tmp&0x0F];
53      *BITMAP_ADDR16(bitmap, y, x*2+1) = CLUT[tmp&0x0F];
51      *BITMAP_ADDR16(bitmap, y, x*2+0) = coupe_regs.clut[tmp&0x0F];
52      *BITMAP_ADDR16(bitmap, y, x*2+1) = coupe_regs.clut[tmp&0x0F];
5453      x++;
5554#endif
5655   }
r2182r2183
6362
6463   for (x=0;x<512;)
6564   {
66      tmp=*(sam_screen + (x/4) + (y*128));
65      tmp=*(videoram + (x/4) + (y*128));
6766#ifdef MONO
6867      if (tmp>>6)
6968         plot_pixel(bitmap,x,y,127);
r2182r2183
8685         plot_pixel(bitmap,x,y,0);
8786      x++;
8887#else
89      *BITMAP_ADDR16(bitmap, y, x) = CLUT[tmp>>6];
88      *BITMAP_ADDR16(bitmap, y, x) = coupe_regs.clut[tmp>>6];
9089      x++;
91      *BITMAP_ADDR16(bitmap, y, x) = CLUT[(tmp>>4)&0x03];
90      *BITMAP_ADDR16(bitmap, y, x) = coupe_regs.clut[(tmp>>4)&0x03];
9291      x++;
93      *BITMAP_ADDR16(bitmap, y, x) = CLUT[(tmp>>2)&0x03];
92      *BITMAP_ADDR16(bitmap, y, x) = coupe_regs.clut[(tmp>>2)&0x03];
9493      x++;
95      *BITMAP_ADDR16(bitmap, y, x) = CLUT[tmp&0x03];
94      *BITMAP_ADDR16(bitmap, y, x) = coupe_regs.clut[tmp&0x03];
9695      x++;
9796#endif
9897   }
r2182r2183
105104   unsigned short ink,pap;
106105   unsigned char *attr;
107106
108   attr=sam_screen + 32*192 + y*32;
107   attr=videoram + 32*192 + y*32;
109108
110109   scrx=0;
111110   for (x=0;x<256/8;x++)
112111   {
113      tmp=*(sam_screen + x + (y*32));
112      tmp=*(videoram + x + (y*32));
114113#ifdef MONO
115114      ink=127;
116115      pap=0;
117116#else
118      ink=CLUT[(*attr) & 0x07];
119      pap=CLUT[((*attr)>>3) & 0x07];
117      ink=coupe_regs.clut[(*attr) & 0x07];
118      pap=coupe_regs.clut[((*attr)>>3) & 0x07];
120119#endif
121120      attr++;
122121
r2182r2183
135134   unsigned short ink,pap;
136135   unsigned char *attr;
137136
138   attr=sam_screen + 32*192 + (y/8)*32;
137   attr=videoram + 32*192 + (y/8)*32;
139138
140139   scrx=0;
141140   scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0);
142141   for (x=0;x<256/8;x++)
143142   {
144      tmp=*(sam_screen + x + (y*32));
143      tmp=*(videoram + x + (y*32));
145144#ifdef MONO
146145      ink=127;
147146      pap=0;
148147#else
149      ink=CLUT[(*attr) & 0x07];
150      pap=CLUT[((*attr)>>3) & 0x07];
148      ink=coupe_regs.clut[(*attr) & 0x07];
149      pap=coupe_regs.clut[((*attr)>>3) & 0x07];
151150#endif
152151      attr++;
153152      for (b=0x80;b!=0;b>>=1)
r2182r2183
163162   int scanline = video_screen_get_vpos(screen);
164163
165164   /* line interrupt? */
166   if (LINE_INT == scanline) coupe_irq(screen->machine, 0x01);
165   if (coupe_regs.line_int == scanline) coupe_irq(screen->machine, 0x01);
167166
168   switch ((VMPR & 0x60) >> 5)
167   switch ((coupe_regs.vmpr & 0x60) >> 5)
169168   {
170169   case 0: /* mode 1 */
171170      drawMode1_line(bitmap, scanline);
src/mess/machine/coupe.c
r2182r2183
88***************************************************************************/
99
1010#include "driver.h"
11#include "cpu/z80/z80.h"
1211#include "includes/coupe.h"
1312#include "devices/basicdsk.h"
1413#include "machine/wd17xx.h"
r2182r2183
1817#define LMPR_ROM1   0x40   /* If bit set rom1 is paged into bank 3, else its ram */
1918
2019
21UINT8 LMPR,HMPR,VMPR;   /* Bank Select Registers (Low Page p250, Hi Page p251, Video Page p252) */
22UINT8 CLUT[16];       /* 16 entries in a palette (no line affects supported yet!) */
23UINT8 LINE_INT;       /* Line interrupt */
24UINT8 STAT;          /* returned when port 249 read */
20struct coupe_asic coupe_regs;
2521
26extern UINT8 *sam_screen;
2722
2823DEVICE_IMAGE_LOAD( coupe_floppy )
2924{
30   if (device_load_basicdsk_floppy(image)==INIT_PASS)
25   if (device_load_basicdsk_floppy(image) == INIT_PASS)
3126   {
3227      basicdsk_set_geometry(image, 80, 2, 10, 512, 1, 0, FALSE);
3328      return INIT_PASS;
3429   }
30
3531   return INIT_FAIL;
3632}
3733
3834
39
4035static void coupe_update_bank(int bank, UINT8 *memory, int is_readonly)
4136{
4237   read8_machine_func rh;
r2182r2183
6257   int is_readonly;
6358
6459   /* BANK1 */
65    if (LMPR & LMPR_RAM0)   /* Is ram paged in at bank 1 */
60    if (coupe_regs.lmpr & LMPR_RAM0)   /* Is ram paged in at bank 1 */
6661   {
67      if ((LMPR & 0x1F) <= PAGE_MASK)
68         memory = &mess_ram[(LMPR & PAGE_MASK) * 0x4000];
62      if ((coupe_regs.lmpr & 0x1F) <= PAGE_MASK)
63         memory = &mess_ram[(coupe_regs.lmpr & PAGE_MASK) * 0x4000];
6964      else
7065         memory = NULL;   /* Attempt to page in non existant ram region */
7166      is_readonly = FALSE;
r2182r2183
7974
8075
8176   /* BANK2 */
82   if (( (LMPR+1) & 0x1F) <= PAGE_MASK)
83      memory = &mess_ram[((LMPR+1) & PAGE_MASK) * 0x4000];
77   if (( (coupe_regs.lmpr+1) & 0x1F) <= PAGE_MASK)
78      memory = &mess_ram[((coupe_regs.lmpr+1) & PAGE_MASK) * 0x4000];
8479   else
8580      memory = NULL;   /* Attempt to page in non existant ram region */
8681   coupe_update_bank(2, memory, FALSE);
8782
8883
8984   /* BANK3 */
90   if ( (HMPR & 0x1F) <= PAGE_MASK )
91      memory = &mess_ram[(HMPR & PAGE_MASK)*0x4000];
85   if ( (coupe_regs.hmpr & 0x1F) <= PAGE_MASK )
86      memory = &mess_ram[(coupe_regs.hmpr & PAGE_MASK)*0x4000];
9287   else
9388      memory = NULL;   /* Attempt to page in non existant ram region */
9489   coupe_update_bank(3, memory, FALSE);
9590
9691
9792   /* BANK4 */
98   if (LMPR & LMPR_ROM1)   /* Is Rom1 paged in at bank 4 */
93   if (coupe_regs.lmpr & LMPR_ROM1)   /* Is Rom1 paged in at bank 4 */
9994   {
10095      memory = rom + 0x4000;
10196      is_readonly = TRUE;
10297   }
10398   else
10499   {
105      if (( (HMPR+1) & 0x1F) <= PAGE_MASK)
106         memory = &mess_ram[((HMPR+1) & PAGE_MASK) * 0x4000];
100      if (( (coupe_regs.hmpr+1) & 0x1F) <= PAGE_MASK)
101         memory = &mess_ram[((coupe_regs.hmpr+1) & PAGE_MASK) * 0x4000];
107102      else
108103         memory = NULL;   /* Attempt to page in non existant ram region */
109104      is_readonly = FALSE;
r2182r2183
111106   coupe_update_bank(4, memory, FALSE);
112107
113108
114   if (VMPR & 0x40)   /* if bit set in 2 bank screen mode */
115      sam_screen = &mess_ram[((VMPR&0x1E) & PAGE_MASK) * 0x4000];
109   if (coupe_regs.vmpr & 0x40)   /* if bit set in 2 bank screen mode */
110      videoram = &mess_ram[((coupe_regs.vmpr&0x1E) & PAGE_MASK) * 0x4000];
116111   else
117      sam_screen = &mess_ram[((VMPR&0x1F) & PAGE_MASK) * 0x4000];
112      videoram = &mess_ram[((coupe_regs.vmpr&0x1F) & PAGE_MASK) * 0x4000];
118113}
119114
120115
121116MACHINE_RESET( coupe )
122117{
123    LMPR = 0x0F;            /* ROM0 paged in, ROM1 paged out RAM Banks */
124    HMPR = 0x01;
125    VMPR = 0x81;
118   memset(&coupe_regs, 0, sizeof(coupe_regs));
119   
120    coupe_regs.lmpr = 0x0f;      /* ROM0 paged in, ROM1 paged out RAM Banks */
121    coupe_regs.hmpr = 0x01;
122    coupe_regs.vmpr = 0x81;
123    coupe_regs.line_int = 0xff;  /* line interrupts disabled */
124    coupe_regs.status = 0x1f;    /* no interrupts active */
126125
127    LINE_INT = 0xFF;
128
129    STAT = 0x1F;
130
131126    coupe_update_memory();
132127}
133128
src/mess/drivers/coupe.c
r2182r2183
5757#include "includes/coupe.h"
5858
5959/* components */
60#include "cpu/z80/z80.h"
6160#include "machine/wd17xx.h"
6261#include "sound/saa1099.h"
6362#include "sound/speaker.h"
r2182r2183
135134
136135static WRITE8_HANDLER( coupe_clut_w )
137136{   
138   CLUT[(offset >> 8) & 0x0f] = data & 0x7f;
137   coupe_regs.clut[(offset >> 8) & 0x0f] = data & 0x7f;
139138}
140139
141140
r2182r2183
153152   if (row & 0x02) data &= readinputport(1) & 0xe0;
154153   if (row & 0x01) data &= readinputport(0) & 0xe0;
155154
156   return data | STAT;
155   return data | coupe_regs.status;
157156}
158157
159158
160159static WRITE8_HANDLER( coupe_line_int_w )
161160{
162   LINE_INT = data;
161   coupe_regs.line_int = data;
163162}
164163
165164
166165static READ8_HANDLER( coupe_lmpr_r )
167166{
168   return LMPR;
167   return coupe_regs.lmpr;
169168}
170169
171170
172171static WRITE8_HANDLER( coupe_lmpr_w )
173172{
174   LMPR = data;
173   coupe_regs.lmpr = data;
175174   coupe_update_memory();
176175}
177176
178177
179178static READ8_HANDLER( coupe_hmpr_r )
180179{
181   return HMPR;
180   return coupe_regs.hmpr;
182181}
183182
184183
185184static WRITE8_HANDLER( coupe_hmpr_w )
186185{
187   HMPR = data;
186   coupe_regs.hmpr = data;
188187   coupe_update_memory();
189188}
190189
191190
192191static READ8_HANDLER( coupe_vmpr_r )
193192{
194   return VMPR;
193   return coupe_regs.vmpr;
195194}
196195
197196
198197static WRITE8_HANDLER( coupe_vmpr_w )
199198{
200   VMPR = data;
199   coupe_regs.vmpr = data;
201200   coupe_update_memory();
202201}
203202
r2182r2183
313312   cpunum_set_input_line(machine, 0, 0, CLEAR_LINE);
314313   
315314   /* adjust STATUS register */
316   STAT |= param;
315   coupe_regs.status |= param;
317316}
318317
319318
r2182r2183
324323   timer_set(ATTOTIME_IN_USEC(20), NULL, src, irq_off);
325324   
326325   /* adjust STATUS register */
327   STAT &= ~src;
326   coupe_regs.status &= ~src;
328327}
329328
330329

Previous 15994 Revisions Next


© 1998-2018 The MESS Team