src/mess/includes/coupe.h
| r2182 | r2183 | |
| 12 | 12 | #define COUPE_H_ |
| 13 | 13 | |
| 14 | 14 | |
| 15 | struct 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 | |
| 15 | 24 | /*----------- defined in drivers/coupe.c -----------*/ |
| 16 | 25 | |
| 17 | 26 | void coupe_irq(running_machine *machine, UINT8 src); |
| r2182 | r2183 | |
| 19 | 28 | |
| 20 | 29 | /*----------- defined in machine/coupe.c -----------*/ |
| 21 | 30 | |
| 22 | | extern UINT8 LMPR,HMPR,VMPR;/* Bank Select Registers (Low Page p250, Hi Page p251, Video Page p252) */ |
| 23 | | extern UINT8 CLUT[16]; /* 16 entries in a palette (no line affects supported yet!) */ |
| 24 | | extern UINT8 LINE_INT; /* Line interrupt register */ |
| 25 | | extern UINT8 STAT; /* returned when port 249 read */ |
| 31 | extern struct coupe_asic coupe_regs; |
| 26 | 32 | |
| 27 | 33 | void coupe_update_memory(void); |
| 28 | 34 | |
src/mess/video/coupe.c
| r2182 | r2183 | |
| 12 | 12 | #include "driver.h" |
| 13 | 13 | #include "includes/coupe.h" |
| 14 | 14 | |
| 15 | | unsigned char *sam_screen; |
| 16 | 15 | |
| 17 | 16 | static void drawMode4_line(bitmap_t *bitmap,int y) |
| 18 | 17 | { |
| r2182 | r2183 | |
| 21 | 20 | |
| 22 | 21 | for (x=0;x<256;) |
| 23 | 22 | { |
| 24 | | tmp=*(sam_screen + (x/2) + (y*128)); |
| 23 | tmp=*(videoram + (x/2) + (y*128)); |
| 25 | 24 | #ifdef MONO |
| 26 | 25 | if (tmp>>4) |
| 27 | 26 | { |
| r2182 | r2183 | |
| 46 | 45 | } |
| 47 | 46 | x++; |
| 48 | 47 | #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]; |
| 51 | 50 | 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]; |
| 54 | 53 | x++; |
| 55 | 54 | #endif |
| 56 | 55 | } |
| r2182 | r2183 | |
| 63 | 62 | |
| 64 | 63 | for (x=0;x<512;) |
| 65 | 64 | { |
| 66 | | tmp=*(sam_screen + (x/4) + (y*128)); |
| 65 | tmp=*(videoram + (x/4) + (y*128)); |
| 67 | 66 | #ifdef MONO |
| 68 | 67 | if (tmp>>6) |
| 69 | 68 | plot_pixel(bitmap,x,y,127); |
| r2182 | r2183 | |
| 86 | 85 | plot_pixel(bitmap,x,y,0); |
| 87 | 86 | x++; |
| 88 | 87 | #else |
| 89 | | *BITMAP_ADDR16(bitmap, y, x) = CLUT[tmp>>6]; |
| 88 | *BITMAP_ADDR16(bitmap, y, x) = coupe_regs.clut[tmp>>6]; |
| 90 | 89 | x++; |
| 91 | | *BITMAP_ADDR16(bitmap, y, x) = CLUT[(tmp>>4)&0x03]; |
| 90 | *BITMAP_ADDR16(bitmap, y, x) = coupe_regs.clut[(tmp>>4)&0x03]; |
| 92 | 91 | x++; |
| 93 | | *BITMAP_ADDR16(bitmap, y, x) = CLUT[(tmp>>2)&0x03]; |
| 92 | *BITMAP_ADDR16(bitmap, y, x) = coupe_regs.clut[(tmp>>2)&0x03]; |
| 94 | 93 | x++; |
| 95 | | *BITMAP_ADDR16(bitmap, y, x) = CLUT[tmp&0x03]; |
| 94 | *BITMAP_ADDR16(bitmap, y, x) = coupe_regs.clut[tmp&0x03]; |
| 96 | 95 | x++; |
| 97 | 96 | #endif |
| 98 | 97 | } |
| r2182 | r2183 | |
| 105 | 104 | unsigned short ink,pap; |
| 106 | 105 | unsigned char *attr; |
| 107 | 106 | |
| 108 | | attr=sam_screen + 32*192 + y*32; |
| 107 | attr=videoram + 32*192 + y*32; |
| 109 | 108 | |
| 110 | 109 | scrx=0; |
| 111 | 110 | for (x=0;x<256/8;x++) |
| 112 | 111 | { |
| 113 | | tmp=*(sam_screen + x + (y*32)); |
| 112 | tmp=*(videoram + x + (y*32)); |
| 114 | 113 | #ifdef MONO |
| 115 | 114 | ink=127; |
| 116 | 115 | pap=0; |
| 117 | 116 | #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]; |
| 120 | 119 | #endif |
| 121 | 120 | attr++; |
| 122 | 121 | |
| r2182 | r2183 | |
| 135 | 134 | unsigned short ink,pap; |
| 136 | 135 | unsigned char *attr; |
| 137 | 136 | |
| 138 | | attr=sam_screen + 32*192 + (y/8)*32; |
| 137 | attr=videoram + 32*192 + (y/8)*32; |
| 139 | 138 | |
| 140 | 139 | scrx=0; |
| 141 | 140 | scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); |
| 142 | 141 | for (x=0;x<256/8;x++) |
| 143 | 142 | { |
| 144 | | tmp=*(sam_screen + x + (y*32)); |
| 143 | tmp=*(videoram + x + (y*32)); |
| 145 | 144 | #ifdef MONO |
| 146 | 145 | ink=127; |
| 147 | 146 | pap=0; |
| 148 | 147 | #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]; |
| 151 | 150 | #endif |
| 152 | 151 | attr++; |
| 153 | 152 | for (b=0x80;b!=0;b>>=1) |
| r2182 | r2183 | |
| 163 | 162 | int scanline = video_screen_get_vpos(screen); |
| 164 | 163 | |
| 165 | 164 | /* line interrupt? */ |
| 166 | | if (LINE_INT == scanline) coupe_irq(screen->machine, 0x01); |
| 165 | if (coupe_regs.line_int == scanline) coupe_irq(screen->machine, 0x01); |
| 167 | 166 | |
| 168 | | switch ((VMPR & 0x60) >> 5) |
| 167 | switch ((coupe_regs.vmpr & 0x60) >> 5) |
| 169 | 168 | { |
| 170 | 169 | case 0: /* mode 1 */ |
| 171 | 170 | drawMode1_line(bitmap, scanline); |
src/mess/machine/coupe.c
| r2182 | r2183 | |
| 8 | 8 | ***************************************************************************/ |
| 9 | 9 | |
| 10 | 10 | #include "driver.h" |
| 11 | | #include "cpu/z80/z80.h" |
| 12 | 11 | #include "includes/coupe.h" |
| 13 | 12 | #include "devices/basicdsk.h" |
| 14 | 13 | #include "machine/wd17xx.h" |
| r2182 | r2183 | |
| 18 | 17 | #define LMPR_ROM1 0x40 /* If bit set rom1 is paged into bank 3, else its ram */ |
| 19 | 18 | |
| 20 | 19 | |
| 21 | | UINT8 LMPR,HMPR,VMPR; /* Bank Select Registers (Low Page p250, Hi Page p251, Video Page p252) */ |
| 22 | | UINT8 CLUT[16]; /* 16 entries in a palette (no line affects supported yet!) */ |
| 23 | | UINT8 LINE_INT; /* Line interrupt */ |
| 24 | | UINT8 STAT; /* returned when port 249 read */ |
| 20 | struct coupe_asic coupe_regs; |
| 25 | 21 | |
| 26 | | extern UINT8 *sam_screen; |
| 27 | 22 | |
| 28 | 23 | DEVICE_IMAGE_LOAD( coupe_floppy ) |
| 29 | 24 | { |
| 30 | | if (device_load_basicdsk_floppy(image)==INIT_PASS) |
| 25 | if (device_load_basicdsk_floppy(image) == INIT_PASS) |
| 31 | 26 | { |
| 32 | 27 | basicdsk_set_geometry(image, 80, 2, 10, 512, 1, 0, FALSE); |
| 33 | 28 | return INIT_PASS; |
| 34 | 29 | } |
| 30 | |
| 35 | 31 | return INIT_FAIL; |
| 36 | 32 | } |
| 37 | 33 | |
| 38 | 34 | |
| 39 | | |
| 40 | 35 | static void coupe_update_bank(int bank, UINT8 *memory, int is_readonly) |
| 41 | 36 | { |
| 42 | 37 | read8_machine_func rh; |
| r2182 | r2183 | |
| 62 | 57 | int is_readonly; |
| 63 | 58 | |
| 64 | 59 | /* 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 */ |
| 66 | 61 | { |
| 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]; |
| 69 | 64 | else |
| 70 | 65 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 71 | 66 | is_readonly = FALSE; |
| r2182 | r2183 | |
| 79 | 74 | |
| 80 | 75 | |
| 81 | 76 | /* 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]; |
| 84 | 79 | else |
| 85 | 80 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 86 | 81 | coupe_update_bank(2, memory, FALSE); |
| 87 | 82 | |
| 88 | 83 | |
| 89 | 84 | /* 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]; |
| 92 | 87 | else |
| 93 | 88 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 94 | 89 | coupe_update_bank(3, memory, FALSE); |
| 95 | 90 | |
| 96 | 91 | |
| 97 | 92 | /* 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 */ |
| 99 | 94 | { |
| 100 | 95 | memory = rom + 0x4000; |
| 101 | 96 | is_readonly = TRUE; |
| 102 | 97 | } |
| 103 | 98 | else |
| 104 | 99 | { |
| 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]; |
| 107 | 102 | else |
| 108 | 103 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 109 | 104 | is_readonly = FALSE; |
| r2182 | r2183 | |
| 111 | 106 | coupe_update_bank(4, memory, FALSE); |
| 112 | 107 | |
| 113 | 108 | |
| 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]; |
| 116 | 111 | else |
| 117 | | sam_screen = &mess_ram[((VMPR&0x1F) & PAGE_MASK) * 0x4000]; |
| 112 | videoram = &mess_ram[((coupe_regs.vmpr&0x1F) & PAGE_MASK) * 0x4000]; |
| 118 | 113 | } |
| 119 | 114 | |
| 120 | 115 | |
| 121 | 116 | MACHINE_RESET( coupe ) |
| 122 | 117 | { |
| 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 */ |
| 126 | 125 | |
| 127 | | LINE_INT = 0xFF; |
| 128 | | |
| 129 | | STAT = 0x1F; |
| 130 | | |
| 131 | 126 | coupe_update_memory(); |
| 132 | 127 | } |
| 133 | 128 | |
src/mess/drivers/coupe.c
| r2182 | r2183 | |
| 57 | 57 | #include "includes/coupe.h" |
| 58 | 58 | |
| 59 | 59 | /* components */ |
| 60 | | #include "cpu/z80/z80.h" |
| 61 | 60 | #include "machine/wd17xx.h" |
| 62 | 61 | #include "sound/saa1099.h" |
| 63 | 62 | #include "sound/speaker.h" |
| r2182 | r2183 | |
| 135 | 134 | |
| 136 | 135 | static WRITE8_HANDLER( coupe_clut_w ) |
| 137 | 136 | { |
| 138 | | CLUT[(offset >> 8) & 0x0f] = data & 0x7f; |
| 137 | coupe_regs.clut[(offset >> 8) & 0x0f] = data & 0x7f; |
| 139 | 138 | } |
| 140 | 139 | |
| 141 | 140 | |
| r2182 | r2183 | |
| 153 | 152 | if (row & 0x02) data &= readinputport(1) & 0xe0; |
| 154 | 153 | if (row & 0x01) data &= readinputport(0) & 0xe0; |
| 155 | 154 | |
| 156 | | return data | STAT; |
| 155 | return data | coupe_regs.status; |
| 157 | 156 | } |
| 158 | 157 | |
| 159 | 158 | |
| 160 | 159 | static WRITE8_HANDLER( coupe_line_int_w ) |
| 161 | 160 | { |
| 162 | | LINE_INT = data; |
| 161 | coupe_regs.line_int = data; |
| 163 | 162 | } |
| 164 | 163 | |
| 165 | 164 | |
| 166 | 165 | static READ8_HANDLER( coupe_lmpr_r ) |
| 167 | 166 | { |
| 168 | | return LMPR; |
| 167 | return coupe_regs.lmpr; |
| 169 | 168 | } |
| 170 | 169 | |
| 171 | 170 | |
| 172 | 171 | static WRITE8_HANDLER( coupe_lmpr_w ) |
| 173 | 172 | { |
| 174 | | LMPR = data; |
| 173 | coupe_regs.lmpr = data; |
| 175 | 174 | coupe_update_memory(); |
| 176 | 175 | } |
| 177 | 176 | |
| 178 | 177 | |
| 179 | 178 | static READ8_HANDLER( coupe_hmpr_r ) |
| 180 | 179 | { |
| 181 | | return HMPR; |
| 180 | return coupe_regs.hmpr; |
| 182 | 181 | } |
| 183 | 182 | |
| 184 | 183 | |
| 185 | 184 | static WRITE8_HANDLER( coupe_hmpr_w ) |
| 186 | 185 | { |
| 187 | | HMPR = data; |
| 186 | coupe_regs.hmpr = data; |
| 188 | 187 | coupe_update_memory(); |
| 189 | 188 | } |
| 190 | 189 | |
| 191 | 190 | |
| 192 | 191 | static READ8_HANDLER( coupe_vmpr_r ) |
| 193 | 192 | { |
| 194 | | return VMPR; |
| 193 | return coupe_regs.vmpr; |
| 195 | 194 | } |
| 196 | 195 | |
| 197 | 196 | |
| 198 | 197 | static WRITE8_HANDLER( coupe_vmpr_w ) |
| 199 | 198 | { |
| 200 | | VMPR = data; |
| 199 | coupe_regs.vmpr = data; |
| 201 | 200 | coupe_update_memory(); |
| 202 | 201 | } |
| 203 | 202 | |
| r2182 | r2183 | |
| 313 | 312 | cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); |
| 314 | 313 | |
| 315 | 314 | /* adjust STATUS register */ |
| 316 | | STAT |= param; |
| 315 | coupe_regs.status |= param; |
| 317 | 316 | } |
| 318 | 317 | |
| 319 | 318 | |
| r2182 | r2183 | |
| 324 | 323 | timer_set(ATTOTIME_IN_USEC(20), NULL, src, irq_off); |
| 325 | 324 | |
| 326 | 325 | /* adjust STATUS register */ |
| 327 | | STAT &= ~src; |
| 326 | coupe_regs.status &= ~src; |
| 328 | 327 | } |
| 329 | 328 | |
| 330 | 329 | |